LZ4_decompress_safe:
 2570|    139|{
 2571|    139|    return LZ4_decompress_generic(source, dest, compressedSize, maxDecompressedSize,
 2572|    139|                                  decode_full_block, noDict,
 2573|       |                                  (BYTE*)dest, NULL, 0);
 2574|    139|}
LZ4_decompress_safe_forceExtDict:
 2644|    151|{
 2645|    151|    DEBUGLOG(5, "LZ4_decompress_safe_forceExtDict");
  ------------------
  |  |  289|    151|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2646|    151|    return LZ4_decompress_generic(source, dest, compressedSize, maxOutputSize,
 2647|    151|                                  decode_full_block, usingExtDict,
 2648|    151|                                  (BYTE*)dest, (const BYTE*)dictStart, dictSize);
 2649|    151|}
LZ4_decompress_safe_usingDict:
 2843|    151|{
 2844|    151|    if (dictSize < 0) return -1;
  ------------------
  |  Branch (2844:9): [True: 0, False: 151]
  ------------------
 2845|    151|    if (dictSize==0)
  ------------------
  |  Branch (2845:9): [True: 0, False: 151]
  ------------------
 2846|      0|        return LZ4_decompress_safe(source, dest, compressedSize, maxOutputSize);
 2847|    151|    if (dictStart+dictSize == dest) {
  ------------------
  |  Branch (2847:9): [True: 0, False: 151]
  ------------------
 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|    151|    assert(dictSize >= 0);
  ------------------
  |  |  273|    151|#    define assert(condition) ((void)0)
  ------------------
 2855|    151|    return LZ4_decompress_safe_forceExtDict(source, dest, compressedSize, maxOutputSize, dictStart, (size_t)dictSize);
 2856|    151|}
lz4.c:LZ4_isLittleEndian:
  364|  1.06k|{
  365|  1.06k|    const union { U32 u; BYTE c[4]; } one = { 1 };   /* don't use static : performance detrimental */
  366|  1.06k|    return one.c[0];
  367|  1.06k|}
lz4.c:LZ4_wildCopy8:
  466|    465|{
  467|    465|    BYTE* d = (BYTE*)dstPtr;
  468|    465|    const BYTE* s = (const BYTE*)srcPtr;
  469|    465|    BYTE* const e = (BYTE*)dstEnd;
  470|       |
  471|  7.16k|    do { LZ4_memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  |  349|  7.16k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (471:50): [True: 6.70k, False: 465]
  ------------------
  472|    465|}
lz4.c:LZ4_read16:
  393|  1.06k|static U16 LZ4_read16(const void* ptr) { return ((const LZ4_unalign16*)ptr)->u16; }
lz4.c:LZ4_write32:
  398|    546|static void LZ4_write32(void* memPtr, U32 value) { ((LZ4_unalign32*)memPtr)->u32 = value; }
lz4.c:LZ4_decompress_generic:
 2225|    290|{
 2226|    290|    if ((src == NULL) || (outputSize < 0)) { return -1; }
  ------------------
  |  Branch (2226:9): [True: 0, False: 290]
  |  Branch (2226:26): [True: 0, False: 290]
  ------------------
 2227|       |
 2228|    290|    {   const BYTE* ip = (const BYTE*) src;
 2229|    290|        const BYTE* const iend = ip + srcSize;
 2230|       |
 2231|    290|        BYTE* op = (BYTE*) dst;
 2232|    290|        BYTE* const oend = op + outputSize;
 2233|       |
 2234|    290|        const BYTE* const dictEnd = (dictStart == NULL) ? NULL : dictStart + dictSize;
  ------------------
  |  Branch (2234:37): [True: 139, False: 151]
  ------------------
 2235|       |
 2236|       |        /* withPrefix64k : offset <= 65535 can't reach beyond the 64 KB prefix */
 2237|    290|        const int checkOffset = (dict != withPrefix64k) && (dictSize < (int)(64 KB));
  ------------------
  |  |  251|    290|#define KB *(1 <<10)
  ------------------
  |  Branch (2237:33): [True: 290, False: 0]
  |  Branch (2237:60): [True: 290, False: 0]
  ------------------
 2238|       |
 2239|       |
 2240|       |        /* Set up the "end" pointers for the shortcut. */
 2241|    290|        const BYTE* const shortiend = iend - 14 /*maxLL*/ - 2 /*offset*/;
 2242|    290|        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|    290|        const BYTE* match;
 2246|    290|        size_t offset;
 2247|    290|        size_t ml;   /* match length */
 2248|       |
 2249|       |
 2250|    290|        DEBUGLOG(5, "LZ4_decompress_generic (srcSize:%i, dstSize:%i)", srcSize, outputSize);
  ------------------
  |  |  289|    290|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2251|       |
 2252|       |        /* Special cases */
 2253|    290|        assert(lowPrefix <= op);
  ------------------
  |  |  273|    290|#    define assert(condition) ((void)0)
  ------------------
 2254|    290|        if (unlikely(outputSize==0)) {
  ------------------
  |  |  180|    290|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    290|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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|    290|        if (unlikely(srcSize<=0)) { return -1; }
  ------------------
  |  |  180|    290|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    290|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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|    290|#if LZ4_FAST_DEC_LOOP
 2267|    290|        if ((oend - op) < FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|    290|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2267:13): [True: 11, False: 279]
  ------------------
 2268|     11|            DEBUGLOG(6, "move to safe decode loop");
  ------------------
  |  |  289|     11|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2269|     11|            goto safe_decode;
 2270|     11|        }
 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|    279|        if ( (dict==usingExtDict)
  ------------------
  |  Branch (2276:14): [True: 144, False: 135]
  ------------------
 2277|    144|          && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  255|    144|#define LZ4_DISTANCE_ABSOLUTE_MAX 65535
  ------------------
                        && ((uptrval)dictEnd - (uptrval)lowPrefix - LZ4_DISTANCE_ABSOLUTE_MAX < FASTLOOP_SAFE_DISTANCE) ) {
  ------------------
  |  |  248|    144|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2277:14): [True: 0, False: 144]
  ------------------
 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|    279|        DEBUGLOG(6, "using fast decode loop");
  ------------------
  |  |  289|    279|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2287|    914|        while (1) {
  ------------------
  |  Branch (2287:16): [True: 914, Folded]
  ------------------
 2288|    914|            unsigned token;
 2289|    914|            size_t ll;   /* literal length */
 2290|    914|            BYTE* cpy;
 2291|       |            /* Main fastloop assertion: We can always wildcopy FASTLOOP_SAFE_DISTANCE */
 2292|    914|            assert(oend - op >= FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  |  273|    914|#    define assert(condition) ((void)0)
  ------------------
 2293|    914|            assert(ip < iend);
  ------------------
  |  |  273|    914|#    define assert(condition) ((void)0)
  ------------------
 2294|    914|            token = *ip++;
 2295|    914|            ll = token >> ML_BITS;
  ------------------
  |  |  260|    914|#define ML_BITS  4
  ------------------
 2296|    914|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|    914|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2297|       |
 2298|       |            /* too close to input end : the safe loop restarts this sequence */
 2299|    914|            if (ip > iend-(16 + 1/*max lit + offset + nextToken*/)) { ip--; break; }
  ------------------
  |  Branch (2299:17): [True: 72, False: 842]
  ------------------
 2300|       |
 2301|       |            /* decode literal length */
 2302|    842|            if (ll == RUN_MASK) {
  ------------------
  |  |  263|    842|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    842|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    842|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2302:17): [True: 149, False: 693]
  ------------------
 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|    149|                const BYTE* const tokenPos = ip-1;
 2306|    149|                size_t const addl = read_variable_length(&ip, iend - RUN_MASK);
  ------------------
  |  |  263|    149|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    149|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    149|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2307|    149|                if (addl == rvl_error) {
  ------------------
  |  Branch (2307:21): [True: 8, False: 141]
  ------------------
 2308|      8|                    DEBUGLOG(6, "error reading long literal length");
  ------------------
  |  |  289|      8|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2309|      8|                    goto _output_error;
 2310|      8|                }
 2311|    141|                ll += addl;
 2312|    141|                if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    141|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    141|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2313|    141|                if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    141|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    141|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 141]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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|    141|                cpy = op+ll;
 2318|    141|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|    141|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2319|    141|              #if LZ4_WILDCOPY64
 2320|    141|                if ((cpy>oend-64) || (ip+ll>iend-64)) { ip = tokenPos; break; }
  ------------------
  |  Branch (2320:21): [True: 14, False: 127]
  |  Branch (2320:38): [True: 120, 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|    693|            } else {
 2328|    693|                DEBUGLOG(7, "copy %u bytes in a 16-bytes stripe", (unsigned)ll);
  ------------------
  |  |  289|    693|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2329|       |                /* Literals can only be <= 14, but hope compilers optimize better when copy by a register size */
 2330|    693|                LZ4_memcpy(op, ip, 16);
  ------------------
  |  |  349|    693|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2331|    693|                ip += ll; op += ll;
 2332|    693|            }
 2333|       |
 2334|       |            /* get offset */
 2335|    700|            offset = LZ4_readLE16(ip); ip+=2;
 2336|    700|            DEBUGLOG(6, "blockPos%6u: offset = %u", (unsigned)(op-(BYTE*)dst), (unsigned)offset);
  ------------------
  |  |  289|    700|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2337|    700|            match = op - offset;
 2338|    700|            assert(match <= op);  /* overflow check */
  ------------------
  |  |  273|    700|#    define assert(condition) ((void)0)
  ------------------
 2339|       |
 2340|       |            /* get matchlength */
 2341|    700|            ml = token & ML_MASK;
  ------------------
  |  |  261|    700|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    700|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2342|    700|            DEBUGLOG(7, "  match length token = %u (len==%u)", (unsigned)ml, (unsigned)ml+MINMATCH);
  ------------------
  |  |  289|    700|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2343|       |
 2344|    700|            if (ml == ML_MASK) {
  ------------------
  |  |  261|    700|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    700|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2344:17): [True: 281, False: 419]
  ------------------
 2345|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2346|    281|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|    281|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2347|    281|                if (addl == rvl_error) {
  ------------------
  |  Branch (2347:21): [True: 5, False: 276]
  ------------------
 2348|      5|                    DEBUGLOG(5, "error reading long match length");
  ------------------
  |  |  289|      5|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2349|      5|                    goto _output_error;
 2350|      5|                }
 2351|    276|                ml += addl;
 2352|    276|                DEBUGLOG(7, "  long match length == %u", (unsigned)ml + MINMATCH);
  ------------------
  |  |  289|    276|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2353|    276|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    276|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    276|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 276]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2354|    276|            }
 2355|    695|            ml += MINMATCH;
  ------------------
  |  |  242|    695|#define MINMATCH 4
  ------------------
 2356|       |
 2357|    695|            if (op + ml >= oend - FASTLOOP_SAFE_DISTANCE) {
  ------------------
  |  |  248|    695|#define FASTLOOP_SAFE_DISTANCE 64
  ------------------
  |  Branch (2357:17): [True: 25, False: 670]
  ------------------
 2358|     25|                DEBUGLOG(7, "moving to safe_match_copy (ml==%u)", (unsigned)ml);
  ------------------
  |  |  289|     25|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2359|     25|                goto safe_match_copy;
 2360|     25|            }
 2361|       |
 2362|       |            /* match length from token only (<= 18), no overlap, within prefix : copy 18 bytes */
 2363|    670|            if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|    670|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    670|#define ML_BITS  4
  |  |  ------------------
  ------------------
                          if ( ((token & ML_MASK) != ML_MASK) && (offset >= 8)
  ------------------
  |  |  261|    670|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    670|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2363:18): [True: 413, False: 257]
  |  Branch (2363:52): [True: 98, False: 315]
  ------------------
 2364|     98|              && ((dict == withPrefix64k) || (match >= lowPrefix)) ) {
  ------------------
  |  Branch (2364:19): [True: 0, False: 98]
  |  Branch (2364:46): [True: 56, False: 42]
  ------------------
 2365|     56|                assert(match >= lowPrefix);
  ------------------
  |  |  273|     56|#    define assert(condition) ((void)0)
  ------------------
 2366|     56|                assert(match <= op);
  ------------------
  |  |  273|     56|#    define assert(condition) ((void)0)
  ------------------
 2367|     56|                assert(op + 18 <= oend);
  ------------------
  |  |  273|     56|#    define assert(condition) ((void)0)
  ------------------
 2368|     56|                LZ4_memcpy(op, match, 8);
  ------------------
  |  |  349|     56|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2369|     56|                LZ4_memcpy(op+8, match+8, 8);
  ------------------
  |  |  349|     56|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2370|     56|                LZ4_memcpy(op+16, match+16, 2);
  ------------------
  |  |  349|     56|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2371|     56|                op += ml;
 2372|     56|                continue;
 2373|     56|            }
 2374|       |
 2375|       |            /* match ends far from oend : no end-of-block condition to check */
 2376|    614|            assert(op + ml < oend - FASTLOOP_SAFE_DISTANCE);
  ------------------
  |  |  273|    614|#    define assert(condition) ((void)0)
  ------------------
 2377|       |
 2378|    614|            if ( checkOffset && (unlikely(match + dictSize < lowPrefix)) ) {
  ------------------
  |  |  180|    614|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    614|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2378:18): [True: 614, False: 0]
  |  Branch (2378:33): [True: 35, False: 579]
  ------------------
 2379|     35|                DEBUGLOG(5, "Error : pos=%zi, offset=%zi => outside buffers", op-lowPrefix, op-match);
  ------------------
  |  |  289|     35|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2380|     35|                goto _offset_error;
 2381|     35|            }
 2382|       |            /* match starting within external dictionary */
 2383|    579|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2383:17): [True: 312, False: 267]
  |  Branch (2383:41): [True: 47, False: 265]
  ------------------
 2384|     47|                assert(dictEnd != NULL);
  ------------------
  |  |  273|     47|#    define assert(condition) ((void)0)
  ------------------
 2385|     47|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2386|     47|                continue;
 2387|     47|            }
 2388|       |
 2389|       |            /* copy match within block */
 2390|    532|            cpy = op + ml;
 2391|       |
 2392|    532|            assert((op <= oend) && (oend-op >= 64));
  ------------------
  |  |  273|    532|#    define assert(condition) ((void)0)
  ------------------
 2393|    532|            if (unlikely(offset<16)) {
  ------------------
  |  |  180|    532|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    532|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 468, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2394|    468|                LZ4_memcpy_using_offset(op, match, cpy, offset);
 2395|    468|    #if LZ4_WILDCOPY64
 2396|    468|            } else if (offset >= 64) {
  ------------------
  |  Branch (2396:24): [True: 32, False: 32]
  ------------------
 2397|     32|                LZ4_wildCopy64(op, match, cpy);
 2398|     32|    #endif
 2399|     32|            } else {
 2400|     32|                LZ4_wildCopy32(op, match, cpy);
 2401|     32|            }
 2402|       |
 2403|    532|            op = cpy;   /* wildcopy correction */
 2404|    532|        }
 2405|    217|    safe_decode:
 2406|    217|#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|    217|        DEBUGLOG(6, "using safe decode loop");
  ------------------
  |  |  289|    217|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2413|    522|        while (1) {
  ------------------
  |  Branch (2413:16): [True: 522, Folded]
  ------------------
 2414|    522|            unsigned token;
 2415|    522|            size_t ll;   /* literal length */
 2416|    522|            BYTE* cpy;
 2417|    522|            assert(ip < iend);
  ------------------
  |  |  273|    522|#    define assert(condition) ((void)0)
  ------------------
 2418|    522|            token = *ip++;
 2419|    522|            ll = token >> ML_BITS;
  ------------------
  |  |  260|    522|#define ML_BITS  4
  ------------------
 2420|    522|            DEBUGLOG(7, "blockPos%6u: litLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ll);
  ------------------
  |  |  289|    522|#  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|    522|            if ( (ll != RUN_MASK)
  ------------------
  |  |  263|    522|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    522|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    522|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2430:18): [True: 331, False: 191]
  ------------------
 2431|       |                /* strictly "less than" on input, to re-enter the loop with at least one byte */
 2432|    331|              && likely((ip < shortiend) & (op <= shortoend)) ) {
  ------------------
  |  |  177|    331|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|    331|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 137, False: 194]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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: 111, False: 26]
  ------------------
 2447|    111|                  && (offset >= 8)
  ------------------
  |  Branch (2447:22): [True: 56, False: 55]
  ------------------
 2448|     56|                  && (dict==withPrefix64k || match >= lowPrefix) ) {
  ------------------
  |  Branch (2448:23): [True: 0, False: 56]
  |  Branch (2448:46): [True: 34, False: 22]
  ------------------
 2449|       |                    /* Copy the match. */
 2450|     34|                    LZ4_memcpy(op + 0, match + 0, 8);
  ------------------
  |  |  349|     34|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2451|     34|                    LZ4_memcpy(op + 8, match + 8, 8);
  ------------------
  |  |  349|     34|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2452|     34|                    LZ4_memcpy(op +16, match +16, 2);
  ------------------
  |  |  349|     34|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2453|     34|                    op += ml + MINMATCH;
  ------------------
  |  |  242|     34|#define MINMATCH 4
  ------------------
 2454|       |                    /* Both stages worked, load the next token. */
 2455|     34|                    continue;
 2456|     34|                }
 2457|       |                /* The second stage didn't work out, but the info is ready for the match copy below. */
 2458|    385|            } else {
 2459|       |                /* decode literal length */
 2460|    385|                if (ll == RUN_MASK) {
  ------------------
  |  |  263|    385|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    385|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    385|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2460:21): [True: 191, False: 194]
  ------------------
 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|    191|                    size_t const addl = read_variable_length(&ip, iend-RUN_MASK);
  ------------------
  |  |  263|    191|#define RUN_MASK ((1U<<RUN_BITS)-1)
  |  |  ------------------
  |  |  |  |  262|    191|#define RUN_BITS (8-ML_BITS)
  |  |  |  |  ------------------
  |  |  |  |  |  |  260|    191|#define ML_BITS  4
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2464|    191|                    if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2464:25): [True: 29, False: 162]
  ------------------
 2465|    162|                    ll += addl;
 2466|    162|                    if (unlikely((uptrval)(op)+ll<(uptrval)(op))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    162|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    162|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 162]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2467|    162|                    if (unlikely((uptrval)(ip)+ll<(uptrval)(ip))) { goto _output_error; } /* overflow detection */
  ------------------
  |  |  180|    162|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    162|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 162]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2468|    162|                }
 2469|       |
 2470|       |                /* copy literals */
 2471|    356|                cpy = op+ll;
 2472|    356|                LZ4_STATIC_ASSERT(MFLIMIT >= WILDCOPYLENGTH);
  ------------------
  |  |  277|    356|#define LZ4_STATIC_ASSERT(c)   { enum { LZ4_static_assert = 1/(int)(!!(c)) }; }   /* use after variable declarations */
  ------------------
 2473|    356|                if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  246|    356|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
                              if ((cpy>oend-MFLIMIT) || (ip+ll>iend-(2+1+LASTLITERALS))) {
  ------------------
  |  |  245|    328|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2473:21): [True: 28, False: 328]
  |  Branch (2473:43): [True: 99, False: 229]
  ------------------
 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|    127|                    if (partialDecoding) {
  ------------------
  |  Branch (2476:25): [True: 0, False: 127]
  ------------------
 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|    127|                    } else if ((ip+ll != iend) || (cpy > oend)) {
  ------------------
  |  Branch (2480:32): [True: 123, False: 4]
  |  Branch (2480:51): [True: 1, False: 3]
  ------------------
 2481|       |                        /* last literals must end exactly at input end, within output */
 2482|    124|                        DEBUGLOG(5, "invalid last literals : they end at iend%+zi and oend%+zi", (ip+ll)-iend, cpy-oend);
  ------------------
  |  |  289|    124|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2483|    124|                        if ((ip+ll <= iend) && (cpy > oend-MFLIMIT)) goto _dst_too_small;   /* output full, input left */
  ------------------
  |  |  246|     50|#define MFLIMIT       12   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
  |  Branch (2483:29): [True: 50, False: 74]
  |  Branch (2483:48): [True: 6, False: 44]
  ------------------
 2484|    118|                        goto _output_error;
 2485|    124|                    }
 2486|      3|                    LZ4_memmove(op, ip, ll);  /* supports overlapping memory regions, for in-place decompression scenarios */
  ------------------
  |  |  357|      3|#    define LZ4_memmove __builtin_memmove
  ------------------
 2487|      3|                    ip += ll;
 2488|      3|                    op += ll;
 2489|       |                    /* end of block, unless partialDecoding can go on : output not full, input left for a match */
 2490|      3|                    if (!partialDecoding || (op == oend) || (ip >= (iend-2))) {
  ------------------
  |  Branch (2490:25): [True: 3, False: 0]
  |  Branch (2490:45): [True: 0, False: 0]
  |  Branch (2490:61): [True: 0, False: 0]
  ------------------
 2491|      3|                        break;
 2492|      3|                    }
 2493|    229|                } else {
 2494|    229|                    LZ4_wildCopy8(op, ip, cpy);   /* can overwrite up to 8 bytes beyond cpy */
 2495|    229|                    ip += ll; op = cpy;
 2496|    229|                }
 2497|       |
 2498|       |                /* get offset */
 2499|    229|                offset = LZ4_readLE16(ip); ip+=2;
 2500|    229|                match = op - offset;
 2501|       |
 2502|       |                /* get matchlength */
 2503|    229|                ml = token & ML_MASK;
  ------------------
  |  |  261|    229|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    229|#define ML_BITS  4
  |  |  ------------------
  ------------------
 2504|    229|                DEBUGLOG(7, "blockPos%6u: matchLength token = %u", (unsigned)(op-(BYTE*)dst), (unsigned)ml);
  ------------------
  |  |  289|    229|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2505|    229|            }
 2506|       |
 2507|       |            /* literals copied, offset decoded, ml == match length token */
 2508|    332|            if (ml == ML_MASK) {
  ------------------
  |  |  261|    332|#define ML_MASK  ((1U<<ML_BITS)-1)
  |  |  ------------------
  |  |  |  |  260|    332|#define ML_BITS  4
  |  |  ------------------
  ------------------
  |  Branch (2508:17): [True: 125, False: 207]
  ------------------
 2509|       |                /* after match length extension bytes, at least 1 token + LASTLITERALS literals must remain */
 2510|    125|                size_t const addl = read_variable_length(&ip, iend - (1 + LASTLITERALS));
  ------------------
  |  |  245|    125|#define LASTLITERALS   5   /* see ../doc/lz4_Block_format.md#parsing-restrictions */
  ------------------
 2511|    125|                if (addl == rvl_error) { goto _output_error; }
  ------------------
  |  Branch (2511:21): [True: 4, False: 121]
  ------------------
 2512|    121|                ml += addl;
 2513|    121|                if (unlikely((uptrval)(op)+ml<(uptrval)op)) goto _output_error;   /* overflow detection */
  ------------------
  |  |  180|    121|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    121|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 0, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2514|    121|            }
 2515|    328|            ml += MINMATCH;
  ------------------
  |  |  242|    328|#define MINMATCH 4
  ------------------
 2516|       |
 2517|    328|#if LZ4_FAST_DEC_LOOP
 2518|    353|        safe_match_copy:
 2519|    353|#endif
 2520|       |            /* literals copied, match fully decoded (ml includes MINMATCH), offset not validated yet */
 2521|    353|            if ((checkOffset) && (unlikely(match + dictSize < lowPrefix))) goto _offset_error;   /* Error : offset outside buffers */
  ------------------
  |  |  180|    353|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    353|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  ------------------
  ------------------
  |  Branch (2521:17): [True: 353, False: 0]
  |  Branch (2521:34): [True: 76, False: 277]
  ------------------
 2522|       |
 2523|       |            /* end of block : the last LASTLITERALS bytes must be literals */
 2524|    277|            assert(op <= oend);
  ------------------
  |  |  273|    277|#    define assert(condition) ((void)0)
  ------------------
 2525|    277|            if (unlikely(op+ml > oend-LASTLITERALS)) {
  ------------------
  |  |  180|    277|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    277|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 6, False: 271]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2526|      6|                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: 6]
  ------------------
 2527|      6|                else goto _dst_too_small;
 2528|      6|            }
 2529|       |
 2530|       |            /* match starting within external dictionary */
 2531|    271|            if ((dict==usingExtDict) && (match < lowPrefix)) {
  ------------------
  |  Branch (2531:17): [True: 143, False: 128]
  |  Branch (2531:41): [True: 27, False: 116]
  ------------------
 2532|     27|                assert(dictEnd != NULL);
  ------------------
  |  |  273|     27|#    define assert(condition) ((void)0)
  ------------------
 2533|     27|                op = LZ4_copyExtDictMatch(op, match, ml, lowPrefix, dictEnd);
 2534|     27|                continue;
 2535|     27|            }
 2536|    244|            assert(match >= lowPrefix);
  ------------------
  |  |  273|    244|#    define assert(condition) ((void)0)
  ------------------
 2537|       |
 2538|       |            /* close to block end : no wild copy */
 2539|    244|            if (unlikely(op+ml > oend-MATCH_SAFEGUARD_DISTANCE)) {
  ------------------
  |  |  180|    244|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    244|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 5, False: 239]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2540|      5|                op = LZ4_copyMatchExact(op, match, ml);
 2541|      5|                if (op == oend) { break; }   /* partialDecoding : output buffer full */
  ------------------
  |  Branch (2541:21): [True: 0, False: 5]
  ------------------
 2542|      5|                continue;
 2543|      5|            }
 2544|       |
 2545|       |            /* copy match within block */
 2546|    239|            cpy = op + ml;
 2547|    239|            LZ4_memcpy_using_offset_base(op, match, cpy, offset);
 2548|    239|            op = cpy;   /* wildcopy correction */
 2549|    239|        }
 2550|       |
 2551|       |        /* end of decoding */
 2552|      3|        DEBUGLOG(5, "decoded %i bytes", (int) (((char*)op)-dst));
  ------------------
  |  |  289|      3|#  define DEBUGLOG(l, ...) {}    /* disabled */
  ------------------
 2553|      3|        return (int) (((char*)op)-dst);     /* Nb of output bytes decoded */
 2554|       |
 2555|       |        /* errors : see LZ4_decompress_safe() in lz4.h */
 2556|    164|    _output_error:
 2557|    164|        return -1;
 2558|     12|    _dst_too_small:
 2559|     12|        return -2;
 2560|    111|    _offset_error:
 2561|    111|        return -3;
 2562|    217|    }
 2563|    217|}
lz4.c:read_variable_length:
 2132|    746|{
 2133|    746|    Rvl_t s, length = 0;
 2134|    746|    assert(ipPtr != NULL);
  ------------------
  |  |  273|    746|#    define assert(condition) ((void)0)
  ------------------
 2135|    746|    assert(*ipPtr !=  NULL);
  ------------------
  |  |  273|    746|#    define assert(condition) ((void)0)
  ------------------
 2136|    746|    assert(ilimit != NULL);
  ------------------
  |  |  273|    746|#    define assert(condition) ((void)0)
  ------------------
 2137|    746|    if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|    746|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    746|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 30, False: 716]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2138|     30|        return rvl_error;
 2139|     30|    }
 2140|    716|    s = **ipPtr;
 2141|    716|    (*ipPtr)++;
 2142|    716|    length += s;
 2143|    716|    if (likely(s != 255)) return length;
  ------------------
  |  |  177|    716|#define likely(expr)     expect((expr) != 0, 1)
  |  |  ------------------
  |  |  |  |  171|    716|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 468, False: 248]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2144|  1.48k|    do {
 2145|  1.48k|        if (unlikely((*ipPtr) >= ilimit)) {    /* read limit reached */
  ------------------
  |  |  180|  1.48k|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|  1.48k|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 16, False: 1.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|     16|            return rvl_error;
 2147|     16|        }
 2148|  1.46k|        s = **ipPtr;
 2149|  1.46k|        (*ipPtr)++;
 2150|  1.46k|        length += s;
 2151|       |        /* accumulator overflow detection (32-bit mode only) */
 2152|  1.46k|        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.46k]
  ------------------
 2153|      0|            return rvl_error;
 2154|      0|        }
 2155|  1.46k|    } while (s == 255);
  ------------------
  |  Branch (2155:14): [True: 1.23k, False: 232]
  ------------------
 2156|       |
 2157|    232|    return length;
 2158|    248|}
lz4.c:LZ4_wildCopy64:
  537|     39|{
  538|     39|    BYTE* d = (BYTE*)dstPtr;
  539|     39|    const BYTE* s = (const BYTE*)srcPtr;
  540|     39|    BYTE* const e = (BYTE*)dstEnd;
  541|       |
  542|    271|    do { LZ4_memcpy(d,s,64); d+=64; s+=64; } while (d<e);
  ------------------
  |  |  349|    271|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (542:53): [True: 232, False: 39]
  ------------------
  543|     39|}
lz4.c:LZ4_readLE16:
  431|  1.06k|{
  432|  1.06k|    if (LZ4_isLittleEndian()) {
  ------------------
  |  Branch (432:9): [True: 1.06k, False: 0]
  ------------------
  433|  1.06k|        return LZ4_read16(memPtr);
  434|  1.06k|    } else {
  435|      0|        const BYTE* p = (const BYTE*)memPtr;
  436|      0|        return (U16)((U16)p[0] | (p[1]<<8));
  437|      0|    }
  438|  1.06k|}
lz4.c:LZ4_copyExtDictMatch:
 2193|     74|{
 2194|     74|    if (length <= (size_t)(lowPrefix-match)) {
  ------------------
  |  Branch (2194:9): [True: 19, False: 55]
  ------------------
 2195|       |        /* match fits entirely within external dictionary : just copy */
 2196|     19|        LZ4_memmove(op, dictEnd - (lowPrefix-match), length);
  ------------------
  |  |  357|     19|#    define LZ4_memmove __builtin_memmove
  ------------------
 2197|     19|        return op + length;
 2198|     55|    } else {
 2199|       |        /* match stretches into both external dictionary and current block */
 2200|     55|        size_t const copySize = (size_t)(lowPrefix - match);
 2201|     55|        LZ4_memcpy(op, dictEnd - copySize, copySize);
  ------------------
  |  |  349|     55|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2202|     55|        return LZ4_copyMatchExact(op + copySize, lowPrefix, length - copySize);
 2203|     55|    }
 2204|     74|}
lz4.c:LZ4_memcpy_using_offset:
  564|    468|{
  565|    468|    BYTE v[8];
  566|       |
  567|    468|    assert(dstEnd >= dstPtr + MINMATCH);
  ------------------
  |  |  273|    468|#    define assert(condition) ((void)0)
  ------------------
  568|       |
  569|    468|    switch(offset) {
  570|     48|    case 1:
  ------------------
  |  Branch (570:5): [True: 48, False: 420]
  ------------------
  571|     48|        MEM_INIT(v, *srcPtr, 8);
  ------------------
  |  |  236|     48|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|     48|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
  572|     48|        break;
  573|      8|    case 2:
  ------------------
  |  Branch (573:5): [True: 8, False: 460]
  ------------------
  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|     37|    case 4:
  ------------------
  |  Branch (585:5): [True: 37, False: 431]
  ------------------
  586|     37|        LZ4_memcpy(v, srcPtr, 4);
  ------------------
  |  |  349|     37|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  587|     37|        LZ4_memcpy(&v[4], srcPtr, 4);
  ------------------
  |  |  349|     37|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  588|     37|        break;
  589|    375|    default:
  ------------------
  |  Branch (589:5): [True: 375, False: 93]
  ------------------
  590|    375|        LZ4_memcpy_using_offset_base(dstPtr, srcPtr, dstEnd, offset);
  591|    375|        return;
  592|    468|    }
  593|       |
  594|     93|    LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|     93|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  595|     93|    dstPtr += 8;
  596|  1.32k|    while (dstPtr < dstEnd) {
  ------------------
  |  Branch (596:12): [True: 1.23k, False: 93]
  ------------------
  597|  1.23k|        LZ4_memcpy(dstPtr, v, 8);
  ------------------
  |  |  349|  1.23k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  598|  1.23k|        dstPtr += 8;
  599|  1.23k|    }
  600|     93|}
lz4.c:LZ4_wildCopy32:
  551|     32|{
  552|     32|    BYTE* d = (BYTE*)dstPtr;
  553|     32|    const BYTE* s = (const BYTE*)srcPtr;
  554|     32|    BYTE* const e = (BYTE*)dstEnd;
  555|       |
  556|  1.30k|    do { LZ4_memcpy(d,s,16); LZ4_memcpy(d+16,s+16,16); d+=32; s+=32; } while (d<e);
  ------------------
  |  |  349|  1.30k|#    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|  1.30k|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  |  Branch (556:79): [True: 1.26k, False: 32]
  ------------------
  557|     32|}
lz4.c:LZ4_copyMatchExact:
 2167|     60|{
 2168|     60|    if (unlikely(match == op)) {   /* invalid offset 0 : clear the match segment, see doc/lz4_Block_format.md */
  ------------------
  |  |  180|     60|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|     60|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 2, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2169|      2|        MEM_INIT(op, 0, length);
  ------------------
  |  |  236|      2|#define MEM_INIT(p,v,s)   LZ4_memset((p),(v),(s))
  |  |  ------------------
  |  |  |  |  234|      2|#  define LZ4_memset(p,v,s) memset((p),(v),(s))
  |  |  ------------------
  ------------------
 2170|      2|        return op + length;
 2171|      2|    }
 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|    288|    while (length > (size_t)(op - match)) {
  ------------------
  |  Branch (2175:12): [True: 230, False: 58]
  ------------------
 2176|    230|        size_t const available = (size_t)(op - match);
 2177|    230|        LZ4_memcpy(op, match, available);
  ------------------
  |  |  349|    230|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2178|    230|        op += available;
 2179|    230|        length -= available;
 2180|    230|        if (available >= 2048) match += available;
  ------------------
  |  Branch (2180:13): [True: 0, False: 230]
  ------------------
 2181|    230|    }
 2182|     58|    LZ4_memcpy(op, match, length);
  ------------------
  |  |  349|     58|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
 2183|     58|    return op + length;
 2184|     60|}
lz4.c:LZ4_memcpy_using_offset_base:
  497|    614|{
  498|    614|    assert(srcPtr + offset == dstPtr);
  ------------------
  |  |  273|    614|#    define assert(condition) ((void)0)
  ------------------
  499|    614|    if (unlikely(offset < 8)) {
  ------------------
  |  |  180|    614|#define unlikely(expr)   expect((expr) != 0, 0)
  |  |  ------------------
  |  |  |  |  171|    614|#  define expect(expr,value)    (__builtin_expect ((expr),(value)) )
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (171:33): [True: 546, False: 68]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|    546|        LZ4_write32(dstPtr, 0);   /* silence an msan warning when offset==0 */
  501|    546|        dstPtr[0] = srcPtr[0];
  502|    546|        dstPtr[1] = srcPtr[1];
  503|    546|        dstPtr[2] = srcPtr[2];
  504|    546|        dstPtr[3] = srcPtr[3];
  505|    546|        srcPtr += inc32table[offset];
  506|    546|        LZ4_memcpy(dstPtr+4, srcPtr, 4);
  ------------------
  |  |  349|    546|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  507|    546|        srcPtr -= dec64table[offset];
  508|    546|    } else {
  509|     68|        LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|     68|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  510|     68|        srcPtr += 8;
  511|     68|    }
  512|    614|    dstPtr += 8;
  513|       |
  514|       |    /* srcPtr is now at least 8 bytes behind dstPtr */
  515|    614|    LZ4_memcpy(dstPtr, srcPtr, 8);
  ------------------
  |  |  349|    614|#    define LZ4_memcpy(dst, src, size) __builtin_memcpy(dst, src, size)
  ------------------
  516|    614|    if (dstEnd > dstPtr + 8) { LZ4_wildCopy8(dstPtr + 8, srcPtr + 8, dstEnd); }
  ------------------
  |  Branch (516:9): [True: 236, False: 378]
  ------------------
  517|    614|}

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|      5|static int force_init_empty(void) {
   64|      5|    return 0;
   65|      5|}

zng_inflateResetKeep:
   61|      6|int32_t Z_EXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) {
   62|      6|    struct inflate_state *state;
   63|       |
   64|      6|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (64:9): [True: 0, False: 6]
  ------------------
   65|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
   66|      6|    state = (struct inflate_state *)strm->state;
   67|      6|    strm->total_in = strm->total_out = state->total = 0;
   68|      6|    strm->msg = NULL;
   69|      6|    if (state->wrap)        /* to support ill-conceived Java test suite */
  ------------------
  |  Branch (69:9): [True: 6, False: 0]
  ------------------
   70|      6|        strm->adler = state->wrap & 1;
   71|      6|    state->mode = HEAD;
   72|      6|    state->check = ADLER32_INITIAL_VALUE;
  ------------------
  |  |   65|      6|#define ADLER32_INITIAL_VALUE 1 /* initial adler-32 hash value */
  ------------------
   73|      6|    state->last = 0;
   74|      6|    state->havedict = 0;
   75|      6|    state->flags = -1;
   76|      6|    state->head = NULL;
   77|      6|    state->hold = 0;
   78|      6|    state->bits = 0;
   79|      6|    state->lencode = state->distcode = state->next = state->codes;
   80|      6|    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|      6|    INFLATE_RESET_KEEP_HOOK(strm);  /* hook for IBM Z DFLTCC */
  ------------------
  |  |   25|      6|#  define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0)
  |  |  ------------------
  |  |  |  Branch (25:54): [Folded, False: 6]
  |  |  ------------------
  ------------------
   88|      6|    Tracev((stderr, "inflate: reset\n"));
   89|      6|    return Z_OK;
  ------------------
  |  |  180|      6|#define Z_OK            0
  ------------------
   90|      6|}
zng_inflateReset:
   92|      6|int32_t Z_EXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) {
   93|      6|    struct inflate_state *state;
   94|       |
   95|      6|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (95:9): [True: 0, False: 6]
  ------------------
   96|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
   97|      6|    state = (struct inflate_state *)strm->state;
   98|      6|    state->wsize = 0;
   99|      6|    state->whave = 0;
  100|      6|    state->wnext = 0;
  101|      6|    return PREFIX(inflateResetKeep)(strm);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
  102|      6|}
zng_inflateReset2:
  104|      6|int32_t Z_EXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int32_t windowBits) {
  105|      6|    int wrap;
  106|      6|    struct inflate_state *state;
  107|       |
  108|       |    /* get the state */
  109|      6|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (109:9): [True: 0, False: 6]
  ------------------
  110|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  111|      6|    state = (struct inflate_state *)strm->state;
  112|       |
  113|       |    /* extract wrap request from windowBits parameter */
  114|      6|    if (windowBits < 0) {
  ------------------
  |  Branch (114:9): [True: 0, False: 6]
  ------------------
  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|      6|    } else {
  120|      6|        wrap = (windowBits >> 4) + 5;
  121|      6|#ifdef GUNZIP
  122|      6|        if (windowBits < 48)
  ------------------
  |  Branch (122:13): [True: 6, False: 0]
  ------------------
  123|      6|            windowBits &= MAX_WBITS;
  ------------------
  |  |   39|      6|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  124|      6|#endif
  125|      6|    }
  126|       |
  127|       |    /* set number of window bits */
  128|      6|    if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   36|     12|#  define MIN_WBITS   8  /* 256 LZ77 window */
  ------------------
                  if (windowBits && (windowBits < MIN_WBITS || windowBits > MAX_WBITS))
  ------------------
  |  |   39|      6|#  define MAX_WBITS   15 /* 32K LZ77 window */
  ------------------
  |  Branch (128:9): [True: 6, False: 0]
  |  Branch (128:24): [True: 0, False: 6]
  |  Branch (128:50): [True: 0, False: 6]
  ------------------
  129|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  130|       |
  131|       |    /* update state and reset the rest of it */
  132|      6|    state->wrap = wrap;
  133|      6|    state->wbits = (unsigned)windowBits;
  134|      6|    return PREFIX(inflateReset)(strm);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
  135|      6|}
alloc_inflate:
  152|      6|Z_INTERNAL inflate_allocs* alloc_inflate(PREFIX3(stream) *strm) {
  153|      6|    int curr_size = 0;
  154|       |
  155|       |    /* Define sizes */
  156|      6|    int window_size = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64); /* 64B padding for chunksize */
  ------------------
  |  |   23|      6|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  157|      6|    int state_size = sizeof(inflate_state);
  158|      6|    int alloc_size = sizeof(inflate_allocs);
  159|       |
  160|       |    /* Calculate relative buffer positions and paddings */
  161|      6|    LOGSZP("window", window_size, PAD_WINDOW(curr_size), PADSZ(curr_size,WINDOW_PAD_SIZE));
  162|      6|    int window_pos = PAD_WINDOW(curr_size);
  ------------------
  |  |  465|      6|#  define PAD_WINDOW            PAD_64
  |  |  ------------------
  |  |  |  |  245|      6|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  |  |  ------------------
  |  |  |  |  |  |  243|      6|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|      6|    curr_size = window_pos + window_size;
  164|       |
  165|      6|    LOGSZP("state", state_size, PAD_64(curr_size), PADSZ(curr_size,64));
  166|      6|    int state_pos = PAD_64(curr_size);
  ------------------
  |  |  245|      6|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  243|      6|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  167|      6|    curr_size = state_pos + state_size;
  168|       |
  169|      6|    LOGSZP("alloc", alloc_size, PAD_16(curr_size), PADSZ(curr_size,16));
  170|      6|    int alloc_pos = PAD_16(curr_size);
  ------------------
  |  |  244|      6|#define PAD_16(bpos) ((bpos) + PADSZ((bpos),16))
  |  |  ------------------
  |  |  |  |  243|      6|#define PADSZ(bpos, pad) (((pad) - ((uintptr_t)(bpos) % (pad))) % (pad))
  |  |  ------------------
  ------------------
  171|      6|    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|      6|    int total_size = PAD_64(curr_size + (WINDOW_PAD_SIZE - 1));
  ------------------
  |  |  245|      6|#define PAD_64(bpos) ((bpos) + PADSZ((bpos),64))
  |  |  ------------------
  |  |  |  |  243|      6|#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|      6|    char *original_buf = (char *)strm->zalloc(strm->opaque, 1, total_size);
  178|      6|    if (original_buf == NULL)
  ------------------
  |  Branch (178:9): [True: 0, False: 6]
  ------------------
  179|      0|        return NULL;
  180|       |
  181|      6|    char *buff = (char *)HINT_ALIGNED_WINDOW((char *)PAD_WINDOW(original_buf));
  ------------------
  |  |  467|      6|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  236|      6|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  231|      6|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|      6|    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|      6|    inflate_allocs *alloc_bufs  = (struct inflate_allocs_s *)(buff + alloc_pos);
  186|      6|    alloc_bufs->buf_start = original_buf;
  187|      6|    alloc_bufs->zfree = strm->zfree;
  188|       |
  189|      6|    alloc_bufs->window =  (unsigned char *)HINT_ALIGNED_WINDOW((buff + window_pos));
  ------------------
  |  |  467|      6|#  define HINT_ALIGNED_WINDOW   HINT_ALIGNED_64
  |  |  ------------------
  |  |  |  |  236|      6|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  |  |  ------------------
  |  |  |  |  |  |  231|      6|#  define HINT_ALIGNED(p,n) __builtin_assume_aligned((void *)(p),(n))
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|      6|    alloc_bufs->state = (inflate_state *)HINT_ALIGNED_64((buff + state_pos));
  ------------------
  |  |  236|      6|#define HINT_ALIGNED_64(p) HINT_ALIGNED((p),64)
  |  |  ------------------
  |  |  |  |  231|      6|#  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|      6|    return alloc_bufs;
  200|      6|}
free_inflate:
  205|      6|Z_INTERNAL void free_inflate(PREFIX3(stream) *strm) {
  206|      6|    struct inflate_state *state = (struct inflate_state *)strm->state;
  207|       |
  208|      6|    if (state->alloc_bufs != NULL) {
  ------------------
  |  Branch (208:9): [True: 6, False: 0]
  ------------------
  209|      6|        inflate_allocs *alloc_bufs = state->alloc_bufs;
  210|      6|        alloc_bufs->zfree(strm->opaque, alloc_bufs->buf_start);
  211|       |        strm->state = NULL;
  212|      6|    }
  213|      6|}
zng_inflateInit2:
  219|      6|int32_t ZNG_CONDEXPORT PREFIX(inflateInit2)(PREFIX3(stream) *strm, int32_t windowBits) {
  220|      6|    struct inflate_state *state;
  221|      6|    int32_t ret;
  222|       |
  223|       |    /* Initialize functable */
  224|      6|    FUNCTABLE_INIT;
  ------------------
  |  |   48|      6|#  define FUNCTABLE_INIT if (functable.force_init()) {return Z_VERSION_ERROR;}
  |  |  ------------------
  |  |  |  |  188|      0|#define Z_VERSION_ERROR (-6)
  |  |  ------------------
  |  |  |  Branch (48:30): [True: 0, False: 6]
  |  |  ------------------
  ------------------
  225|       |
  226|      6|    if (strm == NULL)
  ------------------
  |  Branch (226:9): [True: 0, False: 6]
  ------------------
  227|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
  228|      6|    strm->msg = NULL;                   /* in case we return an error */
  229|      6|    if (strm->zalloc == NULL) {
  ------------------
  |  Branch (229:9): [True: 6, False: 0]
  ------------------
  230|      6|        strm->zalloc = PREFIX(zcalloc);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
  231|      6|        strm->opaque = NULL;
  232|      6|    }
  233|      6|    if (strm->zfree == NULL)
  ------------------
  |  Branch (233:9): [True: 6, False: 0]
  ------------------
  234|      6|        strm->zfree = PREFIX(zcfree);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
  235|       |
  236|      6|    inflate_allocs *alloc_bufs = alloc_inflate(strm);
  237|      6|    if (alloc_bufs == NULL)
  ------------------
  |  Branch (237:9): [True: 0, False: 6]
  ------------------
  238|      0|        return Z_MEM_ERROR;
  ------------------
  |  |  186|      0|#define Z_MEM_ERROR    (-4)
  ------------------
  239|       |
  240|      6|    state = alloc_bufs->state;
  241|      6|    state->window = alloc_bufs->window;
  242|      6|    state->alloc_bufs = alloc_bufs;
  243|      6|    state->wbufsize = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64);
  ------------------
  |  |   23|      6|#  define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
  ------------------
  244|      6|    Tracev((stderr, "inflate: allocated\n"));
  245|       |
  246|      6|    strm->state = (struct internal_state *)state;
  247|      6|    state->strm = strm;
  248|      6|    state->mode = HEAD;     /* to pass state test in inflateReset2() */
  249|      6|    ret = PREFIX(inflateReset2)(strm, windowBits);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
  250|      6|    if (ret != Z_OK) {
  ------------------
  |  |  180|      6|#define Z_OK            0
  ------------------
  |  Branch (250:9): [True: 0, False: 6]
  ------------------
  251|      0|        free_inflate(strm);
  252|      0|    }
  253|      6|    return ret;
  254|      6|}
zng_inflateInit:
  257|      6|int32_t Z_EXPORT PREFIX(inflateInit)(PREFIX3(stream) *strm) {
  258|      6|    return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |   97|      6|#  define PREFIX(x) zng_ ## x
  ------------------
                  return PREFIX(inflateInit2)(strm, DEF_WBITS);
  ------------------
  |  |   35|      6|#  define DEF_WBITS MAX_WBITS
  |  |  ------------------
  |  |  |  |   39|      6|#  define MAX_WBITS   15 /* 32K LZ77 window */
  |  |  ------------------
  ------------------
  259|      6|}
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|     12|        switch (state->mode) {
  508|      8|        case HEAD:
  ------------------
  |  Branch (508:9): [True: 8, False: 4]
  ------------------
  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|     18|        while (bits < (unsigned)(n)) \
  |  |  ------------------
  |  |  |  Branch (108:16): [True: 14, False: 4]
  |  |  ------------------
  |  |  109|     14|            PULLBYTE(); \
  |  |  ------------------
  |  |  |  |  386|     14|    do { \
  |  |  |  |  387|     14|        if (have == 0) goto inf_leave; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (387:13): [True: 4, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  388|     14|        have--; \
  |  |  |  |  389|     10|        hold += ((uint64_t)(*next++) << bits); \
  |  |  |  |  390|     10|        bits += 8; \
  |  |  |  |  391|     10|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (391:14): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  110|      8|    } while (0)
  |  |  ------------------
  |  |  |  Branch (110:14): [Folded, False: 4]
  |  |  ------------------
  ------------------
  514|      4|#ifdef GUNZIP
  515|      4|            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
  ------------------
  |  Branch (515:17): [True: 0, False: 4]
  |  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|      4|            if (state->head != NULL)
  ------------------
  |  Branch (524:17): [True: 0, False: 4]
  ------------------
  525|      0|                state->head->done = -1;
  526|      4|            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
  ------------------
  |  Branch (526:17): [True: 0, False: 4]
  ------------------
  527|       |#else
  528|       |            if (
  529|       |#endif
  530|      4|                ((BITS(8) << 8) + (hold >> 8)) % 31) {
  ------------------
  |  |  114|      4|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
  |  Branch (530:17): [True: 2, False: 2]
  ------------------
  531|      2|                SET_BAD("incorrect header check");
  ------------------
  |  |  132|      2|    do { \
  |  |  133|      2|        state->mode = BAD; \
  |  |  134|      2|        strm->msg = (char *)errmsg; \
  |  |  135|      2|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 2]
  |  |  ------------------
  ------------------
  532|      2|                break;
  533|      2|            }
  534|      2|            if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  114|      2|    (hold & ((1U << (unsigned)(n)) - 1))
  ------------------
                          if (BITS(4) != Z_DEFLATED) {
  ------------------
  |  |  212|      2|#define Z_DEFLATED   8
  ------------------
  |  Branch (534:17): [True: 1, False: 1]
  ------------------
  535|      1|                SET_BAD("unknown compression method");
  ------------------
  |  |  132|      1|    do { \
  |  |  133|      1|        state->mode = BAD; \
  |  |  134|      1|        strm->msg = (char *)errmsg; \
  |  |  135|      1|    } while (0)
  |  |  ------------------
  |  |  |  Branch (135:14): [Folded, False: 1]
  |  |  ------------------
  ------------------
  536|      1|                break;
  537|      1|            }
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
  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: 12]
  ------------------
 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: 12]
  ------------------
 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: 12]
  ------------------
 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: 12]
  ------------------
 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: 12]
  ------------------
 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: 12]
  ------------------
 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: 12]
  ------------------
 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|      4|        case BAD:
  ------------------
  |  Branch (1160:9): [True: 4, False: 8]
  ------------------
 1161|      4|            ret = Z_DATA_ERROR;
  ------------------
  |  |  185|      4|#define Z_DATA_ERROR   (-3)
  ------------------
 1162|      4|            goto inf_leave;
 1163|       |
 1164|      0|        case SYNC:
  ------------------
  |  Branch (1164:9): [True: 0, False: 12]
  ------------------
 1165|       |
 1166|      0|        default:                 /* can't happen, but makes compilers happy */
  ------------------
  |  Branch (1166:9): [True: 0, False: 12]
  ------------------
 1167|      0|            return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1168|     12|        }
 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|      6|#define Z_FINISH        4
  ------------------
                  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) {
  ------------------
  |  |  180|      2|#define Z_OK            0
  ------------------
  |  Branch (1192:11): [True: 2, False: 6]
  |  Branch (1192:22): [True: 2, False: 0]
  |  Branch (1192:35): [True: 0, False: 6]
  |  Branch (1192:57): [True: 2, False: 0]
  ------------------
 1193|       |        /* when no sliding window is used, hash the output bytes if no CHECK state */
 1194|      2|        if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |   31|      4|#  define INFLATE_NEED_CHECKSUM(strm) 1
  |  |  ------------------
  |  |  |  Branch (31:39): [True: 2, Folded]
  |  |  ------------------
  ------------------
                      if (INFLATE_NEED_CHECKSUM(strm) && !state->wsize && flush == Z_FINISH) {
  ------------------
  |  |  175|      2|#define Z_FINISH        4
  ------------------
  |  Branch (1194:44): [True: 2, False: 0]
  |  Branch (1194:61): [True: 0, False: 2]
  ------------------
 1195|      0|            inf_chksum(strm, put - check_bytes, check_bytes);
 1196|      0|        }
 1197|      2|        ret = Z_BUF_ERROR;
  ------------------
  |  |  187|      2|#define Z_BUF_ERROR    (-5)
  ------------------
 1198|      2|    }
 1199|      8|    return ret;
 1200|      8|}
zng_inflateEnd:
 1202|      6|int32_t Z_EXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) {
 1203|      6|    if (inflateStateCheck(strm))
  ------------------
  |  Branch (1203:9): [True: 0, False: 6]
  ------------------
 1204|      0|        return Z_STREAM_ERROR;
  ------------------
  |  |  184|      0|#define Z_STREAM_ERROR (-2)
  ------------------
 1205|       |
 1206|       |    /* Free allocated buffers */
 1207|      6|    free_inflate(strm);
 1208|       |
 1209|      6|    Tracev((stderr, "inflate: end\n"));
 1210|      6|    return Z_OK;
  ------------------
  |  |  180|      6|#define Z_OK            0
  ------------------
 1211|      6|}
inflate.c:inflateStateCheck:
   51|     32|static int inflateStateCheck(PREFIX3(stream) *strm) {
   52|     32|    struct inflate_state *state;
   53|     32|    if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL)
  ------------------
  |  Branch (53:9): [True: 0, False: 32]
  |  Branch (53:25): [True: 0, False: 32]
  |  Branch (53:49): [True: 0, False: 32]
  ------------------
   54|      0|        return 1;
   55|     32|    state = (struct inflate_state *)strm->state;
   56|     32|    if (state == NULL || state->alloc_bufs == NULL || state->strm != strm || state->mode < HEAD || state->mode > SYNC)
  ------------------
  |  Branch (56:9): [True: 0, False: 32]
  |  Branch (56:26): [True: 0, False: 32]
  |  Branch (56:55): [True: 0, False: 32]
  |  Branch (56:78): [True: 0, False: 32]
  |  Branch (56:100): [True: 0, False: 32]
  ------------------
   57|      0|        return 1;
   58|     32|    return 0;
   59|     32|}

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

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

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

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

zstd_decompress.c:ZSTD_cpuid:
   32|     15|MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
   33|     15|    U32 f1c = 0;
   34|     15|    U32 f1d = 0;
   35|     15|    U32 f7b = 0;
   36|     15|    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|     15|    __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
  124|     15|    if (n >= 1) {
  ------------------
  |  Branch (124:9): [True: 15, False: 0]
  ------------------
  125|     15|      U32 f1a;
  126|     15|      __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
  127|     15|    }
  128|     15|    if (n >= 7) {
  ------------------
  |  Branch (128:9): [True: 15, False: 0]
  ------------------
  129|     15|      U32 f7a;
  130|     15|      __asm__("cpuid"
  131|     15|              : "=a"(f7a), "=b"(f7b), "=c"(f7c)
  132|     15|              : "a"(7), "c"(0)
  133|     15|              : "edx");
  134|     15|    }
  135|     15|#endif
  136|     15|    {
  137|     15|        ZSTD_cpuid_t cpuid;
  138|     15|        cpuid.f1c = f1c;
  139|     15|        cpuid.f1d = f1d;
  140|     15|        cpuid.f7b = f7b;
  141|     15|        cpuid.f7c = f7c;
  142|     15|        return cpuid;
  143|     15|    }
  144|     15|}
zstd_decompress.c:ZSTD_cpuid_bmi1:
  147|     15|  MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) {                 \
  148|     15|    return ((cpuid.r) & (1U << bit)) != 0;                                     \
  149|     15|  }
zstd_decompress.c:ZSTD_cpuid_bmi2:
  147|     15|  MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) {                 \
  148|     15|    return ((cpuid.r) & (1U << bit)) != 0;                                     \
  149|     15|  }

zstd_common.c:ERR_isError:
   52|     29|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     29|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     29|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     29|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
zstd_common.c:ERR_getErrorCode:
   54|     14|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: 14]
  ------------------
zstd_ddict.c:ERR_isError:
   52|     28|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     28|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     28|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     28|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
zstd_decompress.c:ERR_isError:
   52|     79|ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
  ------------------
  |  |   49|     79|#define ERROR(name) ZSTD_ERROR(name)
  |  |  ------------------
  |  |  |  |   50|     79|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|     79|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------

zstd_ddict.c:MEM_readLE32:
  322|      9|{
  323|      9|    if (MEM_isLittleEndian())
  ------------------
  |  Branch (323:9): [True: 9, False: 0]
  ------------------
  324|      9|        return MEM_read32(memPtr);
  325|      0|    else
  326|      0|        return MEM_swap32(MEM_read32(memPtr));
  327|      9|}
zstd_ddict.c:MEM_isLittleEndian:
  141|      9|{
  142|      9|#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  143|      9|    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|      9|}
zstd_ddict.c:MEM_read32:
  183|      9|MEM_STATIC U32 MEM_read32(const void* ptr) { return *(const unalign32*)ptr; }
zstd_decompress.c:MEM_readLE32:
  322|     52|{
  323|     52|    if (MEM_isLittleEndian())
  ------------------
  |  Branch (323:9): [True: 52, False: 0]
  ------------------
  324|     52|        return MEM_read32(memPtr);
  325|      0|    else
  326|      0|        return MEM_swap32(MEM_read32(memPtr));
  327|     52|}
zstd_decompress.c:MEM_isLittleEndian:
  141|     52|{
  142|     52|#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
  143|     52|    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|     52|}
zstd_decompress.c:MEM_read32:
  183|     52|MEM_STATIC U32 MEM_read32(const void* ptr) { return *(const unalign32*)ptr; }

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

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

ZSTD_DDict_dictContent:
   47|     13|{
   48|     13|    assert(ddict != NULL);
  ------------------
  |  |   70|     13|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   49|     13|    return ddict->dictContent;
   50|     13|}
ZSTD_DDict_dictSize:
   53|     13|{
   54|     13|    assert(ddict != NULL);
  ------------------
  |  |   70|     13|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   55|     13|    return ddict->dictSize;
   56|     13|}
ZSTD_copyDDictParameters:
   59|      6|{
   60|      6|    DEBUGLOG(4, "ZSTD_copyDDictParameters");
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
   61|      6|    assert(dctx != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   62|      6|    assert(ddict != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
   63|      6|    dctx->dictID = ddict->dictID;
   64|      6|    dctx->prefixStart = ddict->dictContent;
   65|      6|    dctx->virtualStart = ddict->dictContent;
   66|      6|    dctx->dictEnd = (const BYTE*)ddict->dictContent + ddict->dictSize;
   67|      6|    dctx->previousDstEnd = dctx->dictEnd;
   68|      6|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
   69|      6|    dctx->dictContentBeginForFuzzing = dctx->prefixStart;
   70|      6|    dctx->dictContentEndForFuzzing = dctx->previousDstEnd;
   71|      6|#endif
   72|      6|    if (ddict->entropyPresent) {
  ------------------
  |  Branch (72:9): [True: 0, False: 6]
  ------------------
   73|      0|        dctx->litEntropy = 1;
   74|      0|        dctx->fseEntropy = 1;
   75|      0|        dctx->LLTptr = ddict->entropy.LLTable;
   76|      0|        dctx->MLTptr = ddict->entropy.MLTable;
   77|      0|        dctx->OFTptr = ddict->entropy.OFTable;
   78|      0|        dctx->HUFptr = ddict->entropy.hufTable;
   79|      0|        dctx->entropy.rep[0] = ddict->entropy.rep[0];
   80|      0|        dctx->entropy.rep[1] = ddict->entropy.rep[1];
   81|      0|        dctx->entropy.rep[2] = ddict->entropy.rep[2];
   82|      6|    } else {
   83|      6|        dctx->litEntropy = 0;
   84|      6|        dctx->fseEntropy = 0;
   85|      6|    }
   86|      6|}
ZSTD_createDDict_advanced:
  149|     14|{
  150|     14|    if ((!customMem.customAlloc) ^ (!customMem.customFree)) return NULL;
  ------------------
  |  Branch (150:9): [True: 0, False: 14]
  ------------------
  151|       |
  152|     14|    {   ZSTD_DDict* const ddict = (ZSTD_DDict*) ZSTD_customMalloc(sizeof(ZSTD_DDict), customMem);
  153|     14|        if (ddict == NULL) return NULL;
  ------------------
  |  Branch (153:13): [True: 0, False: 14]
  ------------------
  154|     14|        ddict->cMem = customMem;
  155|     14|        {   size_t const initResult = ZSTD_initDDict_internal(ddict,
  156|     14|                                            dict, dictSize,
  157|     14|                                            dictLoadMethod, dictContentType);
  158|     14|            if (ZSTD_isError(initResult)) {
  ------------------
  |  |   44|     14|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (158:17): [True: 0, False: 14]
  ------------------
  159|      0|                ZSTD_freeDDict(ddict);
  160|      0|                return NULL;
  161|      0|        }   }
  162|     14|        return ddict;
  163|     14|    }
  164|     14|}
ZSTD_createDDict:
  171|     14|{
  172|     14|    ZSTD_customMem const allocator = { NULL, NULL, NULL };
  173|     14|    return ZSTD_createDDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, allocator);
  174|     14|}
ZSTD_freeDDict:
  213|     37|{
  214|     37|    if (ddict==NULL) return 0;   /* support free on NULL */
  ------------------
  |  Branch (214:9): [True: 23, False: 14]
  ------------------
  215|     14|    {   ZSTD_customMem const cMem = ddict->cMem;
  216|     14|        ZSTD_customFree(ddict->dictBuffer, cMem);
  217|     14|        ZSTD_customFree(ddict, cMem);
  218|     14|        return 0;
  219|     37|    }
  220|     37|}
ZSTD_sizeof_DDict:
  231|     14|{
  232|     14|    if (ddict==NULL) return 0;   /* support sizeof on NULL */
  ------------------
  |  Branch (232:9): [True: 14, False: 0]
  ------------------
  233|      0|    return sizeof(*ddict) + (ddict->dictBuffer ? ddict->dictSize : 0) ;
  ------------------
  |  Branch (233:30): [True: 0, False: 0]
  ------------------
  234|     14|}
zstd_ddict.c:ZSTD_initDDict_internal:
  124|     14|{
  125|     14|    if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) {
  ------------------
  |  Branch (125:9): [True: 0, False: 14]
  |  Branch (125:47): [True: 0, False: 14]
  |  Branch (125:58): [True: 0, False: 14]
  ------------------
  126|      0|        ddict->dictBuffer = NULL;
  127|      0|        ddict->dictContent = dict;
  128|      0|        if (!dict) dictSize = 0;
  ------------------
  |  Branch (128:13): [True: 0, False: 0]
  ------------------
  129|     14|    } else {
  130|     14|        void* const internalBuffer = ZSTD_customMalloc(dictSize, ddict->cMem);
  131|     14|        ddict->dictBuffer = internalBuffer;
  132|     14|        ddict->dictContent = internalBuffer;
  133|     14|        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 (133:13): [True: 0, False: 14]
  ------------------
  134|     14|        ZSTD_memcpy(internalBuffer, dict, dictSize);
  ------------------
  |  |   44|     14|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  135|     14|    }
  136|     14|    ddict->dictSize = dictSize;
  137|     14|    ddict->entropy.hufTable[0] = (HUF_DTable)((ZSTD_HUFFDTABLE_CAPACITY_LOG)*0x1000001);  /* cover both little and big endian */
  ------------------
  |  |   78|     14|#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
  ------------------
  138|       |
  139|       |    /* parse dictionary content */
  140|     14|    FORWARD_IF_ERROR( ZSTD_loadEntropy_intoDDict(ddict, dictContentType) , "");
  ------------------
  |  |  146|     14|    do {                                                                           \
  |  |  147|     14|        size_t const err_code = (err);                                             \
  |  |  148|     14|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 0, False: 14]
  |  |  ------------------
  |  |  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|     14|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 14]
  |  |  ------------------
  ------------------
  141|       |
  142|     14|    return 0;
  143|     14|}
zstd_ddict.c:ZSTD_loadEntropy_intoDDict:
   92|     14|{
   93|     14|    ddict->dictID = 0;
   94|     14|    ddict->entropyPresent = 0;
   95|     14|    if (dictContentType == ZSTD_dct_rawContent) return 0;
  ------------------
  |  Branch (95:9): [True: 0, False: 14]
  ------------------
   96|       |
   97|     14|    if (ddict->dictSize < 8) {
  ------------------
  |  Branch (97:9): [True: 5, False: 9]
  ------------------
   98|      5|        if (dictContentType == ZSTD_dct_fullDict)
  ------------------
  |  Branch (98:13): [True: 0, False: 5]
  ------------------
   99|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|      5|        return 0;   /* pure content mode */
  101|      5|    }
  102|      9|    {   U32 const magic = MEM_readLE32(ddict->dictContent);
  103|      9|        if (magic != ZSTD_MAGIC_DICTIONARY) {
  ------------------
  |  |  143|      9|#define ZSTD_MAGIC_DICTIONARY       0xEC30A437    /* valid since v0.7.0 */
  ------------------
  |  Branch (103:13): [True: 9, False: 0]
  ------------------
  104|      9|            if (dictContentType == ZSTD_dct_fullDict)
  ------------------
  |  Branch (104:17): [True: 0, False: 9]
  ------------------
  105|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|      9|            return 0;   /* pure content mode */
  107|      9|        }
  108|      9|    }
  109|      0|    ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
  ------------------
  |  |   82|      0|#define ZSTD_FRAMEIDSIZE 4   /* magic number size */
  ------------------
  110|       |
  111|       |    /* load entropy tables */
  112|      0|    RETURN_ERROR_IF(ZSTD_isError(ZSTD_loadDEntropy(
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  113|      0|            &ddict->entropy, ddict->dictContent, ddict->dictSize)),
  114|      0|        dictionary_corrupted, "");
  115|      0|    ddict->entropyPresent = 1;
  116|      0|    return 0;
  117|      0|}

ZSTD_sizeof_DCtx:
  222|     14|{
  223|     14|    if (dctx==NULL) return 0;   /* support sizeof NULL */
  ------------------
  |  Branch (223:9): [True: 0, False: 14]
  ------------------
  224|     14|    return sizeof(*dctx)
  225|     14|           + ZSTD_sizeof_DDict(dctx->ddictLocal)
  226|     14|           + dctx->inBuffSize + dctx->outBuffSize;
  227|     14|}
ZSTD_createDCtx:
  311|     15|{
  312|     15|    DEBUGLOG(3, "ZSTD_createDCtx");
  ------------------
  |  |  104|     15|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 15]
  |  |  ------------------
  ------------------
  313|     15|    return ZSTD_createDCtx_internal(ZSTD_defaultCMem);
  314|     15|}
ZSTD_freeDCtx:
  325|     15|{
  326|     15|    if (dctx==NULL) return 0;   /* support free on NULL */
  ------------------
  |  Branch (326:9): [True: 0, False: 15]
  ------------------
  327|     15|    RETURN_ERROR_IF(dctx->staticSize, memory_allocation, "not compatible with static DCtx");
  ------------------
  |  |  114|     15|    do {                                                                       \
  |  |  115|     15|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 15]
  |  |  ------------------
  |  |  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|     15|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 15]
  |  |  ------------------
  ------------------
  328|     15|    {   ZSTD_customMem const cMem = dctx->customMem;
  329|     15|        ZSTD_clearDict(dctx);
  330|     15|        ZSTD_customFree(dctx->inBuff, cMem);
  331|     15|        dctx->inBuff = NULL;
  332|     15|#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
  333|     15|        if (dctx->legacyContext)
  ------------------
  |  Branch (333:13): [True: 0, False: 15]
  ------------------
  334|      0|            ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
  335|     15|#endif
  336|     15|        if (dctx->ddictSet) {
  ------------------
  |  Branch (336:13): [True: 0, False: 15]
  ------------------
  337|      0|            ZSTD_freeDDictHashSet(dctx->ddictSet, cMem);
  338|       |            dctx->ddictSet = NULL;
  339|      0|        }
  340|     15|        ZSTD_customFree(dctx, cMem);
  341|     15|        return 0;
  342|     15|    }
  343|     15|}
ZSTD_getFrameHeader_advanced:
  448|     12|{
  449|     12|    const BYTE* ip = (const BYTE*)src;
  450|     12|    size_t const minInputSize = ZSTD_startingInputLength(format);
  451|       |
  452|     12|    DEBUGLOG(5, "ZSTD_getFrameHeader_advanced: minInputSize = %zu, srcSize = %zu", minInputSize, srcSize);
  ------------------
  |  |  104|     12|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 12]
  |  |  ------------------
  ------------------
  453|       |
  454|     12|    if (srcSize > 0) {
  ------------------
  |  Branch (454:9): [True: 12, False: 0]
  ------------------
  455|       |        /* note : technically could be considered an assert(), since it's an invalid entry */
  456|     12|        RETURN_ERROR_IF(src==NULL, GENERIC, "invalid parameter : src==NULL, but srcSize>0");
  ------------------
  |  |  114|     12|    do {                                                                       \
  |  |  115|     12|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 12]
  |  |  ------------------
  |  |  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|     12|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 12]
  |  |  ------------------
  ------------------
  457|     12|    }
  458|     12|    if (srcSize < minInputSize) {
  ------------------
  |  Branch (458:9): [True: 0, False: 12]
  ------------------
  459|      0|        if (srcSize > 0 && format != ZSTD_f_zstd1_magicless) {
  ------------------
  |  Branch (459:13): [True: 0, False: 0]
  |  Branch (459:28): [True: 0, False: 0]
  ------------------
  460|       |            /* when receiving less than @minInputSize bytes,
  461|       |             * control these bytes at least correspond to a supported magic number
  462|       |             * in order to error out early if they don't.
  463|       |            **/
  464|      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]
  |  |  ------------------
  ------------------
  465|      0|            unsigned char hbuf[4]; MEM_writeLE32(hbuf, ZSTD_MAGICNUMBER);
  ------------------
  |  |  142|      0|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  466|      0|            assert(src != NULL);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  467|      0|            ZSTD_memcpy(hbuf, src, toCopy);
  ------------------
  |  |   44|      0|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  468|      0|            if ( MEM_readLE32(hbuf) != ZSTD_MAGICNUMBER ) {
  ------------------
  |  |  142|      0|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  |  Branch (468:18): [True: 0, False: 0]
  ------------------
  469|       |                /* not a zstd frame : let's check if it's a skippable frame */
  470|      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 */
  ------------------
  471|      0|                ZSTD_memcpy(hbuf, src, toCopy);
  ------------------
  |  |   44|      0|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
  472|      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 (472:21): [True: 0, False: 0]
  ------------------
  473|      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]
  |  |  ------------------
  ------------------
  474|      0|                                "first bytes don't correspond to any supported magic number");
  475|      0|        }   }   }
  476|      0|        return minInputSize;
  477|      0|    }
  478|       |
  479|     12|    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|     12|# define ZSTD_memset(p,v,l) __builtin_memset((p),(v),(l))
  ------------------
  480|     12|    if ( (format != ZSTD_f_zstd1_magicless)
  ------------------
  |  Branch (480:10): [True: 12, False: 0]
  ------------------
  481|     12|      && (MEM_readLE32(src) != ZSTD_MAGICNUMBER) ) {
  ------------------
  |  |  142|     12|#define ZSTD_MAGICNUMBER            0xFD2FB528    /* valid since v0.8.0 */
  ------------------
  |  Branch (481:10): [True: 12, False: 0]
  ------------------
  482|     12|        if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  145|     12|#define ZSTD_MAGIC_SKIPPABLE_MASK   0xFFFFFFF0
  ------------------
                      if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  144|     12|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  |  Branch (482:13): [True: 0, False: 12]
  ------------------
  483|       |            /* skippable frame */
  484|      0|            if (srcSize < ZSTD_SKIPPABLEHEADERSIZE)
  ------------------
  |  | 1260|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  |  Branch (484:17): [True: 0, False: 0]
  ------------------
  485|      0|                return ZSTD_SKIPPABLEHEADERSIZE; /* magic number + frame length */
  ------------------
  |  | 1260|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  486|      0|            ZSTD_memset(zfhPtr, 0, sizeof(*zfhPtr));
  ------------------
  |  |   46|      0|# define ZSTD_memset(p,v,l) __builtin_memset((p),(v),(l))
  ------------------
  487|      0|            zfhPtr->frameType = ZSTD_skippableFrame;
  488|      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 */
  ------------------
  489|      0|            zfhPtr->headerSize = ZSTD_SKIPPABLEHEADERSIZE;
  ------------------
  |  | 1260|      0|#define ZSTD_SKIPPABLEHEADERSIZE    8
  ------------------
  490|      0|            zfhPtr->frameContentSize = MEM_readLE32((const char *)src + ZSTD_FRAMEIDSIZE);
  ------------------
  |  |   82|      0|#define ZSTD_FRAMEIDSIZE 4   /* magic number size */
  ------------------
  491|      0|            return 0;
  492|      0|        }
  493|     12|        RETURN_ERROR(prefix_unknown, "");
  ------------------
  |  |  131|     12|    do {                                                                     \
  |  |  132|     12|        RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  133|     12|              __FILE__, __LINE__, ERR_QUOTE(ERROR(err)));                    \
  |  |  134|     12|        _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                               \
  |  |  ------------------
  |  |  |  |   98|     12|    do {                                           \
  |  |  |  |   99|     12|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|     12|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  135|     12|        RAWLOG(3, ": " __VA_ARGS__);                                         \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  136|     12|        RAWLOG(3, "\n");                                                     \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  137|     12|        return ERROR(err);                                                   \
  |  |  ------------------
  |  |  |  |   49|     12|#define ERROR(name) ZSTD_ERROR(name)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     12|#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|     12|#define PREFIX(name) ZSTD_error_##name
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  138|     12|    } while(0)
  |  |  ------------------
  |  |  |  Branch (138:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  494|     12|    }
  495|       |
  496|       |    /* ensure there is enough `srcSize` to fully read/decode frame header */
  497|      0|    {   size_t const fhsize = ZSTD_frameHeaderSize_internal(src, srcSize, format);
  498|      0|        if (srcSize < fhsize) return fhsize;
  ------------------
  |  Branch (498:13): [True: 0, False: 0]
  ------------------
  499|      0|        zfhPtr->headerSize = (U32)fhsize;
  500|      0|    }
  501|       |
  502|      0|    {   BYTE const fhdByte = ip[minInputSize-1];
  503|      0|        size_t pos = minInputSize;
  504|      0|        U32 const dictIDSizeCode = fhdByte&3;
  505|      0|        U32 const checksumFlag = (fhdByte>>2)&1;
  506|      0|        U32 const singleSegment = (fhdByte>>5)&1;
  507|      0|        U32 const fcsID = fhdByte>>6;
  508|      0|        U64 windowSize = 0;
  509|      0|        U32 dictID = 0;
  510|      0|        U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
  ------------------
  |  |  203|      0|#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
  ------------------
  511|      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]
  |  |  ------------------
  ------------------
  512|      0|                        "reserved bits, must be zero");
  513|       |
  514|      0|        if (!singleSegment) {
  ------------------
  |  Branch (514:13): [True: 0, False: 0]
  ------------------
  515|      0|            BYTE const wlByte = ip[pos++];
  516|      0|            U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN;
  ------------------
  |  |   78|      0|#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
  ------------------
  517|      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]
  |  |  ------------------
  ------------------
  518|      0|            windowSize = (1ULL << windowLog);
  519|      0|            windowSize += (windowSize >> 3) * (wlByte&7);
  520|      0|        }
  521|      0|        switch(dictIDSizeCode)
  522|      0|        {
  523|      0|            default:
  ------------------
  |  Branch (523:13): [True: 0, False: 0]
  ------------------
  524|      0|                assert(0);  /* impossible */
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  525|      0|                ZSTD_FALLTHROUGH;
  ------------------
  |  |  262|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
  526|      0|            case 0 : break;
  ------------------
  |  Branch (526:13): [True: 0, False: 0]
  ------------------
  527|      0|            case 1 : dictID = ip[pos]; pos++; break;
  ------------------
  |  Branch (527:13): [True: 0, False: 0]
  ------------------
  528|      0|            case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break;
  ------------------
  |  Branch (528:13): [True: 0, False: 0]
  ------------------
  529|      0|            case 3 : dictID = MEM_readLE32(ip+pos); pos+=4; break;
  ------------------
  |  Branch (529:13): [True: 0, False: 0]
  ------------------
  530|      0|        }
  531|      0|        switch(fcsID)
  532|      0|        {
  533|      0|            default:
  ------------------
  |  Branch (533:13): [True: 0, False: 0]
  ------------------
  534|      0|                assert(0);  /* impossible */
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  535|      0|                ZSTD_FALLTHROUGH;
  ------------------
  |  |  262|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
  536|      0|            case 0 : if (singleSegment) frameContentSize = ip[pos]; break;
  ------------------
  |  Branch (536:13): [True: 0, False: 0]
  |  Branch (536:26): [True: 0, False: 0]
  ------------------
  537|      0|            case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break;
  ------------------
  |  Branch (537:13): [True: 0, False: 0]
  ------------------
  538|      0|            case 2 : frameContentSize = MEM_readLE32(ip+pos); break;
  ------------------
  |  Branch (538:13): [True: 0, False: 0]
  ------------------
  539|      0|            case 3 : frameContentSize = MEM_readLE64(ip+pos); break;
  ------------------
  |  Branch (539:13): [True: 0, False: 0]
  ------------------
  540|      0|        }
  541|      0|        if (singleSegment) windowSize = frameContentSize;
  ------------------
  |  Branch (541:13): [True: 0, False: 0]
  ------------------
  542|       |
  543|      0|        zfhPtr->frameType = ZSTD_frame;
  544|      0|        zfhPtr->frameContentSize = frameContentSize;
  545|      0|        zfhPtr->windowSize = windowSize;
  546|      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]
  |  |  ------------------
  ------------------
  547|      0|        zfhPtr->dictID = dictID;
  548|      0|        zfhPtr->checksumFlag = checksumFlag;
  549|      0|    }
  550|      0|    return 0;
  551|      0|}
ZSTD_decompressDCtx:
 1198|      8|{
 1199|      8|    return ZSTD_decompress_usingDDict(dctx, dst, dstCapacity, src, srcSize, ZSTD_getDDict(dctx));
 1200|      8|}
ZSTD_decompressBegin:
 1561|     14|{
 1562|     14|    assert(dctx != NULL);
  ------------------
  |  |   70|     14|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1563|     14|#if ZSTD_TRACE
 1564|     14|    dctx->traceCtx = (ZSTD_trace_decompress_begin != NULL) ? ZSTD_trace_decompress_begin(dctx) : 0;
  ------------------
  |  Branch (1564:22): [True: 0, False: 14]
  ------------------
 1565|     14|#endif
 1566|     14|    dctx->expected = ZSTD_startingInputLength(dctx->format);  /* dctx->format must be properly set */
 1567|     14|    dctx->stage = ZSTDds_getFrameHeaderSize;
 1568|     14|    dctx->processedCSize = 0;
 1569|     14|    dctx->decodedSize = 0;
 1570|     14|    dctx->previousDstEnd = NULL;
 1571|     14|    dctx->prefixStart = NULL;
 1572|     14|    dctx->virtualStart = NULL;
 1573|     14|    dctx->dictEnd = NULL;
 1574|     14|    dctx->entropy.hufTable[0] = (HUF_DTable)((ZSTD_HUFFDTABLE_CAPACITY_LOG)*0x1000001);  /* cover both little and big endian */
  ------------------
  |  |   78|     14|#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
  ------------------
 1575|     14|    dctx->litEntropy = dctx->fseEntropy = 0;
 1576|     14|    dctx->dictID = 0;
 1577|     14|    dctx->bType = bt_reserved;
 1578|     14|    dctx->isFrameDecompression = 1;
 1579|     14|    ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue));
  ------------------
  |  |   43|     14|#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
  |  |  ------------------
  |  |  |  |   39|     14|#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
  |  |  ------------------
  ------------------
 1580|     14|    ZSTD_memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue));  /* initial repcodes */
  ------------------
  |  |   44|     14|# define ZSTD_memcpy(d,s,l) __builtin_memcpy((d),(s),(l))
  ------------------
 1581|     14|    dctx->LLTptr = dctx->entropy.LLTable;
 1582|     14|    dctx->MLTptr = dctx->entropy.MLTable;
 1583|     14|    dctx->OFTptr = dctx->entropy.OFTable;
 1584|     14|    dctx->HUFptr = dctx->entropy.hufTable;
 1585|     14|    return 0;
 1586|     14|}
ZSTD_decompressBegin_usingDict:
 1589|      8|{
 1590|      8|    FORWARD_IF_ERROR( ZSTD_decompressBegin(dctx) , "");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1591|      8|    if (dict && dictSize)
  ------------------
  |  Branch (1591:9): [True: 0, False: 8]
  |  Branch (1591:17): [True: 0, False: 0]
  ------------------
 1592|      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]
  |  |  ------------------
  ------------------
 1593|      8|            ZSTD_isError(ZSTD_decompress_insertDictionary(dctx, dict, dictSize)),
 1594|      8|            dictionary_corrupted, "");
 1595|      8|    return 0;
 1596|      8|}
ZSTD_decompressBegin_usingDDict:
 1602|      6|{
 1603|      6|    DEBUGLOG(4, "ZSTD_decompressBegin_usingDDict");
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1604|      6|    assert(dctx != NULL);
  ------------------
  |  |   70|      6|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1605|      6|    if (ddict) {
  ------------------
  |  Branch (1605:9): [True: 6, False: 0]
  ------------------
 1606|      6|        const char* const dictStart = (const char*)ZSTD_DDict_dictContent(ddict);
 1607|      6|        size_t const dictSize = ZSTD_DDict_dictSize(ddict);
 1608|      6|        const void* const dictEnd = dictStart + dictSize;
 1609|      6|        dctx->ddictIsCold = (dctx->dictEnd != dictEnd);
 1610|      6|        DEBUGLOG(4, "DDict is %s",
  ------------------
  |  |  104|      6|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 6]
  |  |  ------------------
  ------------------
 1611|      6|                    dctx->ddictIsCold ? "~cold~" : "hot!");
 1612|      6|    }
 1613|      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]
  |  |  ------------------
  ------------------
 1614|      6|    if (ddict) {   /* NULL ddict is equivalent to no dictionary */
  ------------------
  |  Branch (1614:9): [True: 6, False: 0]
  ------------------
 1615|      6|        ZSTD_copyDDictParameters(dctx, ddict);
 1616|      6|    }
 1617|      6|    return 0;
 1618|      6|}
ZSTD_decompress_usingDDict:
 1660|     15|{
 1661|       |    /* pass content and size in case legacy frames are encountered */
 1662|     15|    return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
 1663|       |                                     NULL, 0,
 1664|     15|                                     ddict);
 1665|     15|}
zstd_decompress.c:ZSTD_initDCtx_internal:
  253|     15|{
  254|     15|    dctx->staticSize  = 0;
  255|     15|    dctx->ddict       = NULL;
  256|     15|    dctx->ddictLocal  = NULL;
  257|     15|    dctx->dictEnd     = NULL;
  258|     15|    dctx->ddictIsCold = 0;
  259|     15|    dctx->dictUses = ZSTD_dont_use;
  260|     15|    dctx->inBuff      = NULL;
  261|     15|    dctx->inBuffSize  = 0;
  262|     15|    dctx->outBuffSize = 0;
  263|     15|    dctx->streamStage = zdss_init;
  264|     15|#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
  265|     15|    dctx->legacyContext = NULL;
  266|     15|    dctx->previousLegacyVersion = 0;
  267|     15|#endif
  268|     15|    dctx->noForwardProgress = 0;
  269|     15|    dctx->oversizedDuration = 0;
  270|     15|    dctx->isFrameDecompression = 1;
  271|     15|#if DYNAMIC_BMI2
  272|     15|    dctx->bmi2 = ZSTD_cpuSupportsBmi2();
  273|     15|#endif
  274|     15|    dctx->ddictSet = NULL;
  275|     15|    ZSTD_DCtx_resetParameters(dctx);
  276|     15|#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  277|       |    dctx->dictContentEndForFuzzing = NULL;
  278|     15|#endif
  279|     15|}
zstd_decompress.c:ZSTD_createDCtx_internal:
  294|     15|static ZSTD_DCtx* ZSTD_createDCtx_internal(ZSTD_customMem customMem) {
  295|     15|    if ((!customMem.customAlloc) ^ (!customMem.customFree)) return NULL;
  ------------------
  |  Branch (295:9): [True: 0, False: 15]
  ------------------
  296|       |
  297|     15|    {   ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_customMalloc(sizeof(*dctx), customMem);
  298|     15|        if (!dctx) return NULL;
  ------------------
  |  Branch (298:13): [True: 0, False: 15]
  ------------------
  299|     15|        dctx->customMem = customMem;
  300|     15|        ZSTD_initDCtx_internal(dctx);
  301|     15|        return dctx;
  302|     15|    }
  303|     15|}
zstd_decompress.c:ZSTD_clearDict:
  317|     23|{
  318|     23|    ZSTD_freeDDict(dctx->ddictLocal);
  319|     23|    dctx->ddictLocal = NULL;
  320|       |    dctx->ddict = NULL;
  321|     23|    dctx->dictUses = ZSTD_dont_use;
  322|     23|}
zstd_decompress.c:ZSTD_frameHeaderSize_internal:
  417|     13|{
  418|     13|    size_t const minInputSize = ZSTD_startingInputLength(format);
  419|     13|    RETURN_ERROR_IF(srcSize < minInputSize, srcSize_wrong, "");
  ------------------
  |  |  114|     13|    do {                                                                       \
  |  |  115|     13|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 0, False: 13]
  |  |  ------------------
  |  |  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|     13|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 13]
  |  |  ------------------
  ------------------
  420|       |
  421|     13|    {   BYTE const fhd = ((const BYTE*)src)[minInputSize-1];
  422|     13|        U32 const dictID= fhd & 3;
  423|     13|        U32 const singleSegment = (fhd >> 5) & 1;
  424|     13|        U32 const fcsId = fhd >> 6;
  425|     13|        return minInputSize + !singleSegment
  426|     13|             + ZSTD_did_fieldSize[dictID] + ZSTD_fcs_fieldSize[fcsId]
  427|     13|             + (singleSegment && !fcsId);
  ------------------
  |  Branch (427:17): [True: 8, False: 5]
  |  Branch (427:34): [True: 1, False: 7]
  ------------------
  428|     13|    }
  429|     13|}
zstd_decompress.c:ZSTD_startingInputLength:
  233|     54|{
  234|     54|    size_t const startingInputLength = ZSTD_FRAMEHEADERSIZE_PREFIX(format);
  ------------------
  |  | 1257|     54|#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1)   /* minimum input size required to query frame header size */
  |  |  ------------------
  |  |  |  Branch (1257:46): [True: 54, False: 0]
  |  |  ------------------
  ------------------
  235|       |    /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */
  236|     54|    assert( (format == ZSTD_f_zstd1) || (format == ZSTD_f_zstd1_magicless) );
  ------------------
  |  |   70|     54|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  237|     54|    return startingInputLength;
  238|     54|}
zstd_decompress.c:ZSTD_decompressMultiFrame:
 1075|     15|{
 1076|     15|    void* const dststart = dst;
 1077|     15|    int moreThan1Frame = 0;
 1078|       |
 1079|     15|    DEBUGLOG(5, "ZSTD_decompressMultiFrame");
  ------------------
  |  |  104|     15|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 15]
  |  |  ------------------
  ------------------
 1080|     15|    assert(dict==NULL || ddict==NULL);  /* either dict or ddict set, not both */
  ------------------
  |  |   70|     15|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1081|       |
 1082|     15|    if (ddict) {
  ------------------
  |  Branch (1082:9): [True: 7, False: 8]
  ------------------
 1083|      7|        dict = ZSTD_DDict_dictContent(ddict);
 1084|      7|        dictSize = ZSTD_DDict_dictSize(ddict);
 1085|      7|    }
 1086|       |
 1087|     15|    while (srcSize >= ZSTD_startingInputLength(dctx->format)) {
  ------------------
  |  Branch (1087:12): [True: 14, False: 1]
  ------------------
 1088|       |
 1089|     14|#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
 1090|     14|        if (dctx->format == ZSTD_f_zstd1 && ZSTD_isLegacy(src, srcSize)) {
  ------------------
  |  Branch (1090:13): [True: 14, False: 0]
  |  Branch (1090:45): [True: 0, False: 14]
  ------------------
 1091|      0|            size_t decodedSize;
 1092|      0|            size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
 1093|      0|            if (ZSTD_isError(frameSize)) return frameSize;
  ------------------
  |  |   44|      0|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (1093:17): [True: 0, False: 0]
  ------------------
 1094|      0|            RETURN_ERROR_IF(dctx->staticSize, memory_allocation,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1095|      0|                "legacy support is not compatible with static dctx");
 1096|       |
 1097|      0|            decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize);
 1098|      0|            if (ZSTD_isError(decodedSize)) return decodedSize;
  ------------------
  |  |   44|      0|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (1098:17): [True: 0, False: 0]
  ------------------
 1099|       |
 1100|      0|            {
 1101|      0|                unsigned long long const expectedSize = ZSTD_getFrameContentSize(src, srcSize);
 1102|      0|                RETURN_ERROR_IF(expectedSize == ZSTD_CONTENTSIZE_ERROR, corruption_detected, "Corrupted frame header!");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1103|      0|                if (expectedSize != ZSTD_CONTENTSIZE_UNKNOWN) {
  ------------------
  |  |  203|      0|#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
  ------------------
  |  Branch (1103:21): [True: 0, False: 0]
  ------------------
 1104|      0|                    RETURN_ERROR_IF(expectedSize != decodedSize, corruption_detected,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1105|      0|                        "Frame header size does not match decoded size!");
 1106|      0|                }
 1107|      0|            }
 1108|       |
 1109|      0|            assert(decodedSize <= dstCapacity);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1110|      0|            dst = (BYTE*)dst + decodedSize;
 1111|      0|            dstCapacity -= decodedSize;
 1112|       |
 1113|      0|            src = (const BYTE*)src + frameSize;
 1114|      0|            srcSize -= frameSize;
 1115|       |
 1116|      0|            continue;
 1117|      0|        }
 1118|     14|#endif
 1119|       |
 1120|     14|        if (dctx->format == ZSTD_f_zstd1 && srcSize >= 4) {
  ------------------
  |  Branch (1120:13): [True: 14, False: 0]
  |  Branch (1120:45): [True: 14, False: 0]
  ------------------
 1121|     14|            U32 const magicNumber = MEM_readLE32(src);
 1122|     14|            DEBUGLOG(5, "reading magic number %08X", (unsigned)magicNumber);
  ------------------
  |  |  104|     14|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 14]
  |  |  ------------------
  ------------------
 1123|     14|            if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  145|     14|#define ZSTD_MAGIC_SKIPPABLE_MASK   0xFFFFFFF0
  ------------------
                          if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
  ------------------
  |  |  144|     14|#define ZSTD_MAGIC_SKIPPABLE_START  0x184D2A50    /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
  ------------------
  |  Branch (1123:17): [True: 0, False: 14]
  ------------------
 1124|       |                /* skippable frame detected : skip it */
 1125|      0|                size_t const skippableSize = readSkippableFrameSize(src, srcSize);
 1126|      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]
  |  |  ------------------
  ------------------
 1127|      0|                assert(skippableSize <= srcSize);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1128|       |
 1129|      0|                src = (const BYTE *)src + skippableSize;
 1130|      0|                srcSize -= skippableSize;
 1131|      0|                continue; /* check next frame */
 1132|      0|        }   }
 1133|       |
 1134|     14|        if (ddict) {
  ------------------
  |  Branch (1134:13): [True: 6, False: 8]
  ------------------
 1135|       |            /* we were called from ZSTD_decompress_usingDDict */
 1136|      6|            FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDDict(dctx, ddict), "");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1137|      8|        } else {
 1138|       |            /* this will initialize correctly with no dict if dict == NULL, so
 1139|       |             * use this in all cases but ddict */
 1140|      8|            FORWARD_IF_ERROR(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize), "");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1141|      8|        }
 1142|     14|        ZSTD_checkContinuity(dctx, dst, dstCapacity);
 1143|       |
 1144|     14|        {   const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity,
 1145|     14|                                                    &src, &srcSize);
 1146|     14|            RETURN_ERROR_IF(
  ------------------
  |  |  114|     14|    do {                                                                       \
  |  |  115|     40|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 12, False: 2]
  |  |  |  Branch (115:13): [True: 0, False: 12]
  |  |  ------------------
  |  |  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|     14|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 14]
  |  |  ------------------
  ------------------
 1147|     14|                (ZSTD_getErrorCode(res) == ZSTD_error_prefix_unknown)
 1148|     14|             && (moreThan1Frame==1),
 1149|     14|                srcSize_wrong,
 1150|     14|                "At least one frame successfully completed, "
 1151|     14|                "but following bytes are garbage: "
 1152|     14|                "it's more likely to be a srcSize error, "
 1153|     14|                "specifying more input bytes than size of frame(s). "
 1154|     14|                "Note: one could be unlucky, it might be a corruption error instead, "
 1155|     14|                "happening right at the place where we expect zstd magic bytes. "
 1156|     14|                "But this is _much_ less likely than a srcSize field error.");
 1157|     14|            if (ZSTD_isError(res)) return res;
  ------------------
  |  |   44|     14|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (1157:17): [True: 14, False: 0]
  ------------------
 1158|      0|            assert(res <= dstCapacity);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1159|      0|            if (res != 0)
  ------------------
  |  Branch (1159:17): [True: 0, False: 0]
  ------------------
 1160|      0|                dst = (BYTE*)dst + res;
 1161|      0|            dstCapacity -= res;
 1162|      0|        }
 1163|      0|        moreThan1Frame = 1;
 1164|      0|    }  /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
 1165|       |
 1166|      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]
  |  |  ------------------
  ------------------
 1167|       |
 1168|      0|    return (size_t)((BYTE*)dst - (BYTE*)dststart);
 1169|      1|}
zstd_decompress.c:ZSTD_decompressFrame:
  956|     14|{
  957|     14|    const BYTE* const istart = (const BYTE*)(*srcPtr);
  958|     14|    const BYTE* ip = istart;
  959|     14|    BYTE* const ostart = (BYTE*)dst;
  960|     14|    BYTE* const oend = dstCapacity != 0 ? ostart + dstCapacity : ostart;
  ------------------
  |  Branch (960:24): [True: 14, False: 0]
  ------------------
  961|     14|    BYTE* op = ostart;
  962|     14|    size_t remainingSrcSize = *srcSizePtr;
  963|       |
  964|     14|    DEBUGLOG(4, "ZSTD_decompressFrame (srcSize:%i)", (int)*srcSizePtr);
  ------------------
  |  |  104|     14|#  define DEBUGLOG(l, ...) do { } while (0)    /* disabled */
  |  |  ------------------
  |  |  |  Branch (104:42): [Folded, False: 14]
  |  |  ------------------
  ------------------
  965|       |
  966|       |    /* check */
  967|     14|    RETURN_ERROR_IF(
  ------------------
  |  |  114|     14|    do {                                                                       \
  |  |  115|     42|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 14, False: 0]
  |  |  |  Branch (115:13): [True: 1, False: 13]
  |  |  ------------------
  |  |  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|     14|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 13]
  |  |  ------------------
  ------------------
  968|     14|        remainingSrcSize < ZSTD_FRAMEHEADERSIZE_MIN(dctx->format)+ZSTD_blockHeaderSize,
  969|     14|        srcSize_wrong, "");
  970|       |
  971|       |    /* Frame Header */
  972|     13|    {   size_t const frameHeaderSize = ZSTD_frameHeaderSize_internal(
  973|     13|                ip, ZSTD_FRAMEHEADERSIZE_PREFIX(dctx->format), dctx->format);
  ------------------
  |  | 1257|     13|#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1)   /* minimum input size required to query frame header size */
  |  |  ------------------
  |  |  |  Branch (1257:46): [True: 13, False: 0]
  |  |  ------------------
  ------------------
  974|     13|        if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize;
  ------------------
  |  |   44|     13|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (974:13): [True: 0, False: 13]
  ------------------
  975|     13|        RETURN_ERROR_IF(remainingSrcSize < frameHeaderSize+ZSTD_blockHeaderSize,
  ------------------
  |  |  114|     13|    do {                                                                       \
  |  |  115|     13|        if (cond) {                                                            \
  |  |  ------------------
  |  |  |  Branch (115:13): [True: 1, False: 12]
  |  |  ------------------
  |  |  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|     13|    } while (0)
  |  |  ------------------
  |  |  |  Branch (123:14): [Folded, False: 12]
  |  |  ------------------
  ------------------
  976|     13|                        srcSize_wrong, "");
  977|     12|        FORWARD_IF_ERROR( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) , "");
  ------------------
  |  |  146|     12|    do {                                                                           \
  |  |  147|     12|        size_t const err_code = (err);                                             \
  |  |  148|     12|        if (ERR_isError(err_code)) {                                               \
  |  |  ------------------
  |  |  |  Branch (148:13): [True: 12, False: 0]
  |  |  ------------------
  |  |  149|     12|            RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s",                 \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  150|     12|                  __FILE__, __LINE__, ERR_QUOTE(err), ERR_getErrorName(err_code)); \
  |  |  151|     12|            _FORCE_HAS_FORMAT_STRING(__VA_ARGS__);                                 \
  |  |  ------------------
  |  |  |  |   98|     12|    do {                                           \
  |  |  |  |   99|     12|        if (0) {                                   \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  100|      0|            _force_has_format_string(__VA_ARGS__); \
  |  |  |  |  101|      0|        }                                          \
  |  |  |  |  102|     12|    } while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (102:14): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  152|     12|            RAWLOG(3, ": " __VA_ARGS__);                                           \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  153|     12|            RAWLOG(3, "\n");                                                       \
  |  |  ------------------
  |  |  |  |  103|     12|#  define RAWLOG(l, ...)   do { } while (0)    /* disabled */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (103:42): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  154|     12|            return err_code;                                                       \
  |  |  155|     12|        }                                                                          \
  |  |  156|     12|    } while(0)
  |  |  ------------------
  |  |  |  Branch (156:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  978|      0|        ip += frameHeaderSize; remainingSrcSize -= frameHeaderSize;
  979|      0|    }
  980|       |
  981|       |    /* Shrink the blockSizeMax if enabled */
  982|      0|    if (dctx->maxBlockSizeParam != 0)
  ------------------
  |  Branch (982:9): [True: 0, False: 0]
  ------------------
  983|      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]
  |  |  ------------------
  ------------------
  984|       |
  985|       |    /* Loop on each block */
  986|      0|    while (1) {
  ------------------
  |  Branch (986:12): [True: 0, Folded]
  ------------------
  987|      0|        BYTE* oBlockEnd = oend;
  988|      0|        size_t decodedSize;
  989|      0|        blockProperties_t blockProperties;
  990|      0|        size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSrcSize, &blockProperties);
  991|      0|        if (ZSTD_isError(cBlockSize)) return cBlockSize;
  ------------------
  |  |   44|      0|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (991:13): [True: 0, False: 0]
  ------------------
  992|       |
  993|      0|        ip += ZSTD_blockHeaderSize;
  994|      0|        remainingSrcSize -= ZSTD_blockHeaderSize;
  995|      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]
  |  |  ------------------
  ------------------
  996|       |
  997|      0|        if (ip >= op && ip < oBlockEnd) {
  ------------------
  |  Branch (997:13): [True: 0, False: 0]
  |  Branch (997:25): [True: 0, False: 0]
  ------------------
  998|       |            /* We are decompressing in-place. Limit the output pointer so that we
  999|       |             * don't overwrite the block that we are currently reading. This will
 1000|       |             * fail decompression if the input & output pointers aren't spaced
 1001|       |             * far enough apart.
 1002|       |             *
 1003|       |             * This is important to set, even when the pointers are far enough
 1004|       |             * apart, because ZSTD_decompressBlock_internal() can decide to store
 1005|       |             * literals in the output buffer, after the block it is decompressing.
 1006|       |             * Since we don't want anything to overwrite our input, we have to tell
 1007|       |             * ZSTD_decompressBlock_internal to never write past ip.
 1008|       |             *
 1009|       |             * See ZSTD_allocateLiteralsBuffer() for reference.
 1010|       |             */
 1011|      0|            oBlockEnd = op + (ip - op);
 1012|      0|        }
 1013|       |
 1014|      0|        switch(blockProperties.blockType)
 1015|      0|        {
 1016|      0|        case bt_compressed:
  ------------------
  |  Branch (1016:9): [True: 0, False: 0]
  ------------------
 1017|      0|            assert(dctx->isFrameDecompression == 1);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1018|      0|            decodedSize = ZSTD_decompressBlock_internal(dctx, op, (size_t)(oBlockEnd-op), ip, cBlockSize, not_streaming);
 1019|      0|            break;
 1020|      0|        case bt_raw :
  ------------------
  |  Branch (1020:9): [True: 0, False: 0]
  ------------------
 1021|       |            /* Use oend instead of oBlockEnd because this function is safe to overlap. It uses memmove. */
 1022|      0|            decodedSize = ZSTD_copyRawBlock(op, (size_t)(oend-op), ip, cBlockSize);
 1023|      0|            break;
 1024|      0|        case bt_rle :
  ------------------
  |  Branch (1024:9): [True: 0, False: 0]
  ------------------
 1025|      0|            decodedSize = ZSTD_setRleBlock(op, (size_t)(oBlockEnd-op), *ip, blockProperties.origSize);
 1026|      0|            break;
 1027|      0|        case bt_reserved :
  ------------------
  |  Branch (1027:9): [True: 0, False: 0]
  ------------------
 1028|      0|        default:
  ------------------
  |  Branch (1028:9): [True: 0, False: 0]
  ------------------
 1029|      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]
  |  |  ------------------
  ------------------
 1030|      0|        }
 1031|      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]
  |  |  ------------------
  ------------------
 1032|      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]
  |  |  ------------------
  ------------------
 1033|      0|        if (dctx->validateChecksum) {
  ------------------
  |  Branch (1033:13): [True: 0, False: 0]
  ------------------
 1034|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1035|      0|        }
 1036|      0|        if (decodedSize) /* support dst = NULL,0 */ {
  ------------------
  |  Branch (1036:13): [True: 0, False: 0]
  ------------------
 1037|      0|            op += decodedSize;
 1038|      0|        }
 1039|      0|        assert(ip != NULL);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1040|      0|        ip += cBlockSize;
 1041|      0|        remainingSrcSize -= cBlockSize;
 1042|      0|        if (blockProperties.lastBlock) break;
  ------------------
  |  Branch (1042:13): [True: 0, False: 0]
  ------------------
 1043|      0|    }
 1044|       |
 1045|      0|    if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
  ------------------
  |  |  203|      0|#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
  ------------------
  |  Branch (1045:9): [True: 0, False: 0]
  ------------------
 1046|      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]
  |  |  ------------------
  ------------------
 1047|      0|                        corruption_detected, "");
 1048|      0|    }
 1049|      0|    if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
  ------------------
  |  Branch (1049:9): [True: 0, False: 0]
  ------------------
 1050|      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]
  |  |  ------------------
  ------------------
 1051|      0|        if (!dctx->forceIgnoreChecksum) {
  ------------------
  |  Branch (1051:13): [True: 0, False: 0]
  ------------------
 1052|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1053|      0|            U32 checkRead;
 1054|      0|            checkRead = MEM_readLE32(ip);
 1055|      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]
  |  |  ------------------
  ------------------
 1056|      0|        }
 1057|      0|        ip += 4;
 1058|      0|        remainingSrcSize -= 4;
 1059|      0|    }
 1060|      0|    ZSTD_DCtx_trace_end(dctx, (U64)(op-ostart), (U64)(ip-istart), /* streaming */ 0);
 1061|       |    /* Allow caller to get size read */
 1062|      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]
  |  |  ------------------
  ------------------
 1063|      0|    *srcPtr = ip;
 1064|      0|    *srcSizePtr = remainingSrcSize;
 1065|      0|    return (size_t)(op-ostart);
 1066|      0|}
zstd_decompress.c:ZSTD_getDDict:
 1181|      8|{
 1182|      8|    switch (dctx->dictUses) {
 1183|      0|    default:
  ------------------
  |  Branch (1183:5): [True: 0, False: 8]
  ------------------
 1184|      0|        assert(0 /* Impossible */);
  ------------------
  |  |   70|      0|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
 1185|      0|        ZSTD_FALLTHROUGH;
  ------------------
  |  |  262|      0|#  define ZSTD_FALLTHROUGH ; __attribute__((__fallthrough__))
  ------------------
 1186|      8|    case ZSTD_dont_use:
  ------------------
  |  Branch (1186:5): [True: 8, False: 0]
  ------------------
 1187|      8|        ZSTD_clearDict(dctx);
 1188|      8|        return NULL;
 1189|      0|    case ZSTD_use_indefinitely:
  ------------------
  |  Branch (1189:5): [True: 0, False: 8]
  ------------------
 1190|      0|        return dctx->ddict;
 1191|      0|    case ZSTD_use_once:
  ------------------
  |  Branch (1191:5): [True: 0, False: 8]
  ------------------
 1192|      0|        dctx->dictUses = ZSTD_dont_use;
 1193|      0|        return dctx->ddict;
 1194|      8|    }
 1195|      8|}
zstd_decompress.c:ZSTD_decodeFrameHeader:
  703|     12|{
  704|     12|    size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
  705|     12|    if (ZSTD_isError(result)) return result;    /* invalid header */
  ------------------
  |  |   44|     12|#define ZSTD_isError ERR_isError   /* for inlining */
  ------------------
  |  Branch (705:9): [True: 12, False: 0]
  ------------------
  706|      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]
  |  |  ------------------
  ------------------
  707|       |
  708|       |    /* Reference DDict requested by frame if dctx references multiple ddicts */
  709|      0|    if (dctx->refMultipleDDicts == ZSTD_rmd_refMultipleDDicts && dctx->ddictSet) {
  ------------------
  |  Branch (709:9): [True: 0, False: 0]
  |  Branch (709:66): [True: 0, False: 0]
  ------------------
  710|      0|        ZSTD_DCtx_selectFrameDDict(dctx);
  711|      0|    }
  712|       |
  713|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  714|       |    /* Skip the dictID check in fuzzing mode, because it makes the search
  715|       |     * harder.
  716|       |     */
  717|       |    RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
  718|       |                    dictionary_wrong, "");
  719|       |#endif
  720|      0|    dctx->validateChecksum = (dctx->fParams.checksumFlag && !dctx->forceIgnoreChecksum) ? 1 : 0;
  ------------------
  |  Branch (720:31): [True: 0, False: 0]
  |  Branch (720:61): [True: 0, False: 0]
  ------------------
  721|      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 (721:9): [True: 0, False: 0]
  ------------------
  722|      0|    dctx->processedCSize += headerSize;
  723|      0|    return 0;
  724|      0|}
zstd_decompress.c:ZSTD_DCtx_resetParameters:
  241|     15|{
  242|     15|    assert(dctx->streamStage == zdss_init);
  ------------------
  |  |   70|     15|#    define assert(condition) ((void)0)   /* disable assert (default) */
  ------------------
  243|     15|    dctx->format = ZSTD_f_zstd1;
  244|     15|    dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
  ------------------
  |  |   40|     15|#  define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + 1)
  |  |  ------------------
  |  |  |  | 1287|     15|#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27   /* by default, the streaming decoder will refuse any frame
  |  |  ------------------
  ------------------
  245|     15|    dctx->outBufferMode = ZSTD_bm_buffered;
  246|     15|    dctx->forceIgnoreChecksum = ZSTD_d_validateChecksum;
  247|     15|    dctx->refMultipleDDicts = ZSTD_rmd_refSingleDDict;
  248|     15|    dctx->disableHufAsm = 0;
  249|     15|    dctx->maxBlockSizeParam = 0;
  250|     15|}

ZSTD_checkContinuity:
 2179|     14|{
 2180|     14|    if (dst != dctx->previousDstEnd && dstSize > 0) {   /* not contiguous */
  ------------------
  |  Branch (2180:9): [True: 14, False: 0]
  |  Branch (2180:40): [True: 14, False: 0]
  ------------------
 2181|     14|        dctx->dictEnd = dctx->previousDstEnd;
 2182|     14|        dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
 2183|     14|        dctx->prefixStart = dst;
 2184|     14|        dctx->previousDstEnd = dst;
 2185|     14|    }
 2186|     14|}

zstd_decompress.c:ZSTD_isLegacy:
   57|     14|{
   58|     14|    U32 magicNumberLE;
   59|     14|    if (srcSize<4) return 0;
  ------------------
  |  Branch (59:9): [True: 0, False: 14]
  ------------------
   60|     14|    magicNumberLE = MEM_readLE32(src);
   61|     14|    switch(magicNumberLE)
   62|     14|    {
   63|       |#if (ZSTD_LEGACY_SUPPORT <= 1)
   64|       |        case ZSTDv01_magicNumberLE:return 1;
   65|       |#endif
   66|       |#if (ZSTD_LEGACY_SUPPORT <= 2)
   67|       |        case ZSTDv02_magicNumber : return 2;
   68|       |#endif
   69|       |#if (ZSTD_LEGACY_SUPPORT <= 3)
   70|       |        case ZSTDv03_magicNumber : return 3;
   71|       |#endif
   72|       |#if (ZSTD_LEGACY_SUPPORT <= 4)
   73|       |        case ZSTDv04_magicNumber : return 4;
   74|       |#endif
   75|      0|#if (ZSTD_LEGACY_SUPPORT <= 5)
   76|      0|        case ZSTDv05_MAGICNUMBER : return 5;
  ------------------
  |  |  153|      0|#define ZSTDv05_MAGICNUMBER 0xFD2FB525   /* v0.5 */
  ------------------
  |  Branch (76:9): [True: 0, False: 14]
  ------------------
   77|      0|#endif
   78|      0|#if (ZSTD_LEGACY_SUPPORT <= 6)
   79|      0|        case ZSTDv06_MAGICNUMBER : return 6;
  ------------------
  |  |  164|      0|#define ZSTDv06_MAGICNUMBER 0xFD2FB526   /* v0.6 */
  ------------------
  |  Branch (79:9): [True: 0, False: 14]
  ------------------
   80|      0|#endif
   81|      0|#if (ZSTD_LEGACY_SUPPORT <= 7)
   82|      0|        case ZSTDv07_MAGICNUMBER : return 7;
  ------------------
  |  |  180|      0|#define ZSTDv07_MAGICNUMBER            0xFD2FB527   /* v0.7 */
  ------------------
  |  Branch (82:9): [True: 0, False: 14]
  ------------------
   83|      0|#endif
   84|     14|        default : return 0;
  ------------------
  |  Branch (84:9): [True: 14, False: 0]
  ------------------
   85|     14|    }
   86|     14|}

b2nd_serialize_meta:
   43|  13.7k|                        uint8_t **smeta) {
   44|  13.7k|  if (dtype == NULL) {
  ------------------
  |  Branch (44:7): [True: 0, False: 13.7k]
  ------------------
   45|      0|    dtype = B2ND_DEFAULT_DTYPE;
  ------------------
  |  |   61|      0|#define B2ND_DEFAULT_DTYPE "|u1"
  ------------------
   46|      0|  }
   47|       |  // dtype checks
   48|  13.7k|  if (dtype_format < 0) {
  ------------------
  |  Branch (48:7): [True: 0, False: 13.7k]
  ------------------
   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|  13.7k|  size_t dtype_len0 = strlen(dtype);
   53|  13.7k|  if (dtype_len0 > INT32_MAX) {
  ------------------
  |  Branch (53:7): [True: 0, False: 13.7k]
  ------------------
   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|  13.7k|  const int32_t dtype_len = (int32_t) dtype_len0;
   58|       |  // Allocate space for b2nd metalayer
   59|  13.7k|  int32_t max_smeta_len = (int32_t) (1 + 1 + 1 + (1 + ndim * (1 + sizeof(int64_t))) +
   60|  13.7k|                                     (1 + ndim * (1 + sizeof(int32_t))) + (1 + ndim * (1 + sizeof(int32_t))) +
   61|  13.7k|                                     1 + 1 + sizeof(int32_t) + dtype_len);
   62|  13.7k|  *smeta = malloc((size_t) max_smeta_len);
   63|  13.7k|  BLOSC_ERROR_NULL(*smeta, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  13.7k|    do {                                            \
  |  |  105|  13.7k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 13.7k]
  |  |  ------------------
  |  |  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|  13.7k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 13.7k]
  |  |  ------------------
  ------------------
   64|  13.7k|  uint8_t *pmeta = *smeta;
   65|       |
   66|       |  // Build an array with 7 entries (version, ndim, shape, chunkshape, blockshape, dtype_format, dtype)
   67|  13.7k|  *pmeta++ = 0x90 + 7;
   68|       |
   69|       |  // version entry
   70|  13.7k|  *pmeta++ = B2ND_METALAYER_VERSION;  // positive fixnum (7-bit positive integer)
  ------------------
  |  |   47|  13.7k|#define B2ND_METALAYER_VERSION 0
  ------------------
   71|       |
   72|       |  // ndim entry
   73|  13.7k|  *pmeta++ = (uint8_t) ndim;  // positive fixnum (7-bit positive integer)
   74|       |
   75|       |  // shape entry
   76|  13.7k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   77|  70.1k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (77:23): [True: 56.3k, False: 13.7k]
  ------------------
   78|  56.3k|    *pmeta++ = 0xd3;  // int64
   79|  56.3k|    swap_store(pmeta, shape + i, sizeof(int64_t));
   80|  56.3k|    pmeta += sizeof(int64_t);
   81|  56.3k|  }
   82|       |
   83|       |  // chunkshape entry
   84|  13.7k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   85|  70.1k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (85:23): [True: 56.3k, False: 13.7k]
  ------------------
   86|  56.3k|    *pmeta++ = 0xd2;  // int32
   87|  56.3k|    swap_store(pmeta, chunkshape + i, sizeof(int32_t));
   88|  56.3k|    pmeta += sizeof(int32_t);
   89|  56.3k|  }
   90|       |
   91|       |  // blockshape entry
   92|  13.7k|  *pmeta++ = (uint8_t) (0x90) + ndim;  // fix array with ndim elements
   93|  70.1k|  for (uint8_t i = 0; i < ndim; i++) {
  ------------------
  |  Branch (93:23): [True: 56.3k, False: 13.7k]
  ------------------
   94|  56.3k|    *pmeta++ = 0xd2;  // int32
   95|  56.3k|    swap_store(pmeta, blockshape + i, sizeof(int32_t));
   96|  56.3k|    pmeta += sizeof(int32_t);
   97|  56.3k|  }
   98|       |
   99|       |  // dtype entry
  100|  13.7k|  *pmeta++ = dtype_format;  // positive fixint (7-bit positive integer)
  101|  13.7k|  *pmeta++ = (uint8_t) (0xdb);  // str with up to 2^31 elements
  102|  13.7k|  swap_store(pmeta, &dtype_len, sizeof(int32_t));
  103|  13.7k|  pmeta += sizeof(int32_t);
  104|  13.7k|  memcpy(pmeta, dtype, dtype_len);
  105|  13.7k|  pmeta += dtype_len;
  106|       |
  107|  13.7k|  int32_t slen = (int32_t) (pmeta - *smeta);
  108|  13.7k|  if (max_smeta_len != slen) {
  ------------------
  |  Branch (108:7): [True: 0, False: 13.7k]
  ------------------
  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|  13.7k|  return (int)slen;
  114|  13.7k|}
b2nd_deserialize_meta:
  118|  7.55k|                          int32_t *chunkshape, int32_t *blockshape, char **dtype, int8_t *dtype_format) {
  119|  7.55k|  return b2nd_deserialize_meta_inline(smeta, smeta_len, ndim, shape, chunkshape, blockshape, dtype, dtype_format);
  120|  7.55k|}
update_shape:
  302|  16.3k|                 const int32_t *chunkshape, const int32_t *blockshape) {
  303|  16.3k|  BLOSC_ERROR(update_shape_struct(array, ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  16.3k|    do {                                            \
  |  |  112|  16.3k|        int rc_ = (rc);                             \
  |  |  113|  16.3k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 16.3k]
  |  |  ------------------
  |  |  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|  16.3k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 16.3k]
  |  |  ------------------
  ------------------
  304|  16.3k|  return publish_shape_meta(array);
  305|  16.3k|}
array_without_schunk:
  380|  15.0k|int array_without_schunk(b2nd_context_t *ctx, b2nd_array_t **array) {
  381|       |  /* Create a b2nd_array_t buffer */
  382|  15.0k|  (*array) = (b2nd_array_t *) malloc(sizeof(b2nd_array_t));
  383|  15.0k|  BLOSC_ERROR_NULL(*array, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  15.0k|    do {                                            \
  |  |  105|  15.0k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 15.0k]
  |  |  ------------------
  |  |  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|  15.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15.0k]
  |  |  ------------------
  ------------------
  384|       |
  385|  15.0k|  (*array)->sc = NULL;
  386|  15.0k|  (*array)->last_tick = 0;
  387|       |
  388|  15.0k|  (*array)->ndim = ctx->ndim;
  389|  15.0k|  int64_t *shape = ctx->shape;
  390|  15.0k|  int32_t *chunkshape = ctx->chunkshape;
  391|  15.0k|  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|  15.0k|  int rc = update_shape(*array, ctx->ndim, shape, chunkshape, blockshape);
  396|  15.0k|  if (rc < 0) {
  ------------------
  |  Branch (396:7): [True: 0, False: 15.0k]
  ------------------
  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|  15.0k|  if (ctx->dtype != NULL) {
  ------------------
  |  Branch (402:7): [True: 15.0k, False: 0]
  ------------------
  403|  15.0k|    (*array)->dtype = malloc(strlen(ctx->dtype) + 1);
  404|  15.0k|    strcpy((*array)->dtype, ctx->dtype);
  405|  15.0k|  } else {
  406|      0|    (*array)->dtype = NULL;
  407|      0|  }
  408|       |
  409|  15.0k|  (*array)->dtype_format = ctx->dtype_format;
  410|       |
  411|       |  // The partition cache (empty initially)
  412|  15.0k|  (*array)->chunk_cache.data = NULL;
  413|  15.0k|  (*array)->chunk_cache.nchunk = -1;  // means no valid cache yet
  414|       |
  415|  15.0k|  return BLOSC2_ERROR_SUCCESS;
  416|  15.0k|}
array_new:
  419|  12.4k|int array_new(b2nd_context_t *ctx, int special_value, b2nd_array_t **array) {
  420|  12.4k|  BLOSC_ERROR(array_without_schunk(ctx, array));
  ------------------
  |  |  111|  12.4k|    do {                                            \
  |  |  112|  12.4k|        int rc_ = (rc);                             \
  |  |  113|  12.4k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 12.4k]
  |  |  ------------------
  |  |  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|  12.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 12.4k]
  |  |  ------------------
  ------------------
  421|       |
  422|  12.4k|  int rc = BLOSC2_ERROR_FAILURE;
  423|  12.4k|  blosc2_schunk *sc = blosc2_schunk_new(ctx->b2_storage);
  424|  12.4k|  if (sc == NULL) {
  ------------------
  |  Branch (424:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  (*array)->sc = sc;
  430|       |  // Set the chunksize for the schunk, as it cannot be derived from storage
  431|  12.4k|  if (sc->typesize <= 0) {
  ------------------
  |  Branch (431:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if ((*array)->extchunknitems < 0) {
  ------------------
  |  Branch (436:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if ((uint64_t)(*array)->extchunknitems > (uint64_t)SIZE_MAX) {
  ------------------
  |  Branch (441:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  size_t chunkbytes_size = 0;
  447|  12.4k|  if (!blosc2_checked_mul_size((size_t)(*array)->extchunknitems, (size_t)sc->typesize, &chunkbytes_size)) {
  ------------------
  |  Branch (447:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if (chunkbytes_size > BLOSC2_MAX_BUFFERSIZE || chunkbytes_size > INT32_MAX) {
  ------------------
  |  Branch (452:7): [True: 5, False: 12.4k]
  |  Branch (452:50): [True: 0, False: 12.4k]
  ------------------
  453|      5|    BLOSC_TRACE_ERROR("Chunksize exceeds maximum of %d", BLOSC2_MAX_BUFFERSIZE);
  ------------------
  |  |   93|      5|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      5|    do {                                            \
  |  |  |  |   98|      5|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      5|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      5|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|      5|    rc = BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
  455|      5|    goto failed;
  456|      5|  }
  457|  12.4k|  int32_t chunksize = (int32_t)chunkbytes_size;
  458|  12.4k|  sc->chunksize = chunksize;
  459|       |
  460|       |  // Serialize the dimension info
  461|  12.4k|  if (sc->nmetalayers >= BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  12.4k|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (461:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  uint8_t *smeta = NULL;
  466|  12.4k|  int32_t smeta_len = b2nd_serialize_meta(ctx->ndim,
  467|  12.4k|                                          (*array)->shape,
  468|  12.4k|                                          (*array)->chunkshape,
  469|  12.4k|                                          (*array)->blockshape,
  470|  12.4k|                                          (*array)->dtype,
  471|  12.4k|                                          (*array)->dtype_format,
  472|  12.4k|                                          &smeta);
  473|  12.4k|  if (smeta_len < 0) {
  ------------------
  |  Branch (473:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  int meta_rc = blosc2_meta_add(sc, "b2nd", smeta, smeta_len);
  480|  12.4k|  free(smeta);
  481|  12.4k|  if (meta_rc < 0) {
  ------------------
  |  Branch (481:7): [True: 0, False: 12.4k]
  ------------------
  482|      0|    goto failed;
  483|      0|  }
  484|       |
  485|  12.4k|  for (int i = 0; i < ctx->nmetalayers; ++i) {
  ------------------
  |  Branch (485:19): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if ((*array)->nitems != 0) {
  ------------------
  |  Branch (495:7): [True: 9.99k, False: 2.49k]
  ------------------
  496|  9.99k|    int64_t nchunks = (*array)->extnitems / (*array)->chunknitems;
  497|  9.99k|    int64_t nitems = nchunks * (*array)->extchunknitems;
  498|  9.99k|    if (blosc2_schunk_fill_special(sc, nitems, special_value, chunksize) < 0) {
  ------------------
  |  Branch (498:9): [True: 0, False: 9.99k]
  ------------------
  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|  9.99k|  }
  503|       |
  504|  12.4k|  return BLOSC2_ERROR_SUCCESS;
  505|       |
  506|      5|  failed:
  507|      5|  b2nd_free(*array);
  508|       |  *array = NULL;
  509|      5|  return rc;
  510|  12.4k|}
b2nd_empty:
  523|  4.77k|int b2nd_empty(b2nd_context_t *ctx, b2nd_array_t **array) {
  524|  4.77k|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.77k|    do {                                            \
  |  |  105|  4.77k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.77k]
  |  |  ------------------
  |  |  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.77k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.77k]
  |  |  ------------------
  ------------------
  525|  4.77k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.77k|    do {                                            \
  |  |  105|  4.77k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.77k]
  |  |  ------------------
  |  |  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.77k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.77k]
  |  |  ------------------
  ------------------
  526|       |
  527|       |  // Fill with zeros to avoid variable cratios
  528|  4.77k|  BLOSC_ERROR(array_new(ctx, BLOSC2_SPECIAL_ZERO, array));
  ------------------
  |  |  111|  4.77k|    do {                                            \
  |  |  112|  4.77k|        int rc_ = (rc);                             \
  |  |  113|  4.77k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 4, False: 4.77k]
  |  |  ------------------
  |  |  114|      4|            char *error_msg = print_error(rc_);     \
  |  |  115|      4|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      4|            return rc_;                             \
  |  |  117|      4|        }                                           \
  |  |  118|  4.77k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 4.77k]
  |  |  ------------------
  ------------------
  529|       |
  530|  4.77k|  return BLOSC2_ERROR_SUCCESS;
  531|  4.77k|}
b2nd_zeros:
  534|  7.71k|int b2nd_zeros(b2nd_context_t *ctx, b2nd_array_t **array) {
  535|  7.71k|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.71k|    do {                                            \
  |  |  105|  7.71k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.71k]
  |  |  ------------------
  |  |  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.71k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.71k]
  |  |  ------------------
  ------------------
  536|  7.71k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.71k|    do {                                            \
  |  |  105|  7.71k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.71k]
  |  |  ------------------
  |  |  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.71k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.71k]
  |  |  ------------------
  ------------------
  537|       |
  538|  7.71k|  BLOSC_ERROR(array_new(ctx, BLOSC2_SPECIAL_ZERO, array));
  ------------------
  |  |  111|  7.71k|    do {                                            \
  |  |  112|  7.71k|        int rc_ = (rc);                             \
  |  |  113|  7.71k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 7.71k]
  |  |  ------------------
  |  |  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|  7.71k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 7.71k]
  |  |  ------------------
  ------------------
  539|       |
  540|  7.71k|  return BLOSC2_ERROR_SUCCESS;
  541|  7.71k|}
b2nd_full:
  561|  1.65k|int b2nd_full(b2nd_context_t *ctx, b2nd_array_t **array, const void *fill_value) {
  562|  1.65k|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.65k|    do {                                            \
  |  |  105|  1.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.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|  1.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.65k]
  |  |  ------------------
  ------------------
  563|  1.65k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.65k|    do {                                            \
  |  |  105|  1.65k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.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|  1.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.65k]
  |  |  ------------------
  ------------------
  564|       |
  565|  1.65k|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|  1.65k|    do {                                            \
  |  |  112|  1.65k|        int rc_ = (rc);                             \
  |  |  113|  1.65k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 2, False: 1.64k]
  |  |  ------------------
  |  |  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|  1.65k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.64k]
  |  |  ------------------
  ------------------
  566|       |
  567|  1.64k|  if ((*array)->sc->typesize <= 0) {
  ------------------
  |  Branch (567:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  if ((*array)->extchunknitems < 0) {
  ------------------
  |  Branch (571:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  if ((uint64_t)(*array)->extchunknitems > (uint64_t)SIZE_MAX) {
  ------------------
  |  Branch (575:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  size_t chunkbytes_size = 0;
  580|  1.64k|  if (!blosc2_checked_mul_size((size_t)(*array)->extchunknitems, (size_t)(*array)->sc->typesize, &chunkbytes_size)) {
  ------------------
  |  Branch (580:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  if (chunkbytes_size > BLOSC2_MAX_BUFFERSIZE || chunkbytes_size > INT32_MAX) {
  ------------------
  |  Branch (584:7): [True: 0, False: 1.64k]
  |  Branch (584:50): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  int32_t chunkbytes = (int32_t)chunkbytes_size;
  589|       |
  590|  1.64k|  blosc2_cparams *cparams;
  591|  1.64k|  if (blosc2_schunk_get_cparams((*array)->sc, &cparams) != 0) {
  ------------------
  |  Branch (591:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  int32_t chunksize = BLOSC_EXTENDED_HEADER_LENGTH + (*array)->sc->typesize;
  596|  1.64k|  uint8_t *chunk = malloc(chunksize);
  597|  1.64k|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  1.64k|    do {                                            \
  |  |  105|  1.64k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.64k]
  |  |  ------------------
  |  |  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.64k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.64k]
  |  |  ------------------
  ------------------
  598|  1.64k|  int rc = blosc2_chunk_repeatval(*cparams, chunkbytes, chunk, chunksize, fill_value);
  599|  1.64k|  free(cparams);
  600|  25.2k|  for (int64_t i = 0; rc >= 0 && i < (*array)->sc->nchunks; ++i) {
  ------------------
  |  Branch (600:23): [True: 25.2k, False: 0]
  |  Branch (600:34): [True: 23.6k, False: 1.64k]
  ------------------
  601|  23.6k|    if (blosc2_schunk_update_chunk((*array)->sc, i, chunk, true) < 0) {
  ------------------
  |  Branch (601:9): [True: 0, False: 23.6k]
  ------------------
  602|      0|      rc = BLOSC2_ERROR_FAILURE;
  603|      0|    }
  604|  23.6k|  }
  605|  1.64k|  free(chunk);
  606|  1.64k|  if (rc < 0) {
  ------------------
  |  Branch (606:7): [True: 0, False: 1.64k]
  ------------------
  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|  1.64k|  return BLOSC2_ERROR_SUCCESS;
  611|  1.64k|}
b2nd_from_schunk:
  643|  2.54k|int b2nd_from_schunk(blosc2_schunk *schunk, b2nd_array_t **array) {
  644|  2.54k|  BLOSC_ERROR_NULL(schunk, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  645|  2.54k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  646|       |
  647|  2.54k|  if (schunk == NULL) {
  ------------------
  |  Branch (647:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  blosc2_cparams *cparams;
  653|  2.54k|  if (blosc2_schunk_get_cparams(schunk, &cparams) < 0) {
  ------------------
  |  Branch (653:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  free(cparams);
  658|       |
  659|  2.54k|  b2nd_context_t params = {0};
  660|  2.54k|  params.b2_storage = schunk->storage;
  661|       |
  662|       |  // Deserialize the b2nd metalayer
  663|  2.54k|  uint8_t *smeta;
  664|  2.54k|  int32_t smeta_len;
  665|  2.54k|  if (blosc2_meta_get(schunk, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (665:7): [True: 2, False: 2.54k]
  ------------------
  666|       |    // Try with a caterva metalayer; we are meant to be backward compatible with it
  667|      2|    if (blosc2_meta_get(schunk, "caterva", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (667:9): [True: 2, False: 0]
  ------------------
  668|      2|      BLOSC_ERROR(BLOSC2_ERROR_METALAYER_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  669|      2|    }
  670|      2|  }
  671|  2.54k|  int rc_meta = b2nd_deserialize_meta(smeta, smeta_len, &params.ndim, params.shape,
  672|  2.54k|                                      params.chunkshape, params.blockshape, &params.dtype,
  673|  2.54k|                                      &params.dtype_format);
  674|  2.54k|  free(smeta);
  675|  2.54k|  BLOSC_ERROR(rc_meta);
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  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|  13.7k|  for (int i = 0; i < params.ndim; ++i) {
  ------------------
  |  Branch (687:19): [True: 11.2k, False: 2.54k]
  ------------------
  688|  11.2k|    if (params.shape[i] != 0 &&
  ------------------
  |  Branch (688:9): [True: 10.2k, False: 934]
  ------------------
  689|  10.2k|        (params.chunkshape[i] == 0 || params.blockshape[i] == 0)) {
  ------------------
  |  Branch (689:10): [True: 0, False: 10.2k]
  |  Branch (689:39): [True: 0, False: 10.2k]
  ------------------
  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|  11.2k|  }
  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|  2.54k|  int rc = array_without_schunk(&params, array);
  700|  2.54k|  free(params.dtype);
  701|  2.54k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  702|       |
  703|  2.54k|  rc = check_schunk_matches_meta(schunk, *array);
  704|  2.54k|  if (rc < 0) {
  ------------------
  |  Branch (704:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  (*array)->sc = schunk;
  712|  2.54k|  (*array)->last_tick = schunk->change_tick;
  713|       |
  714|  2.54k|  if ((*array) == NULL) {
  ------------------
  |  Branch (714:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  return BLOSC2_ERROR_SUCCESS;
  720|  2.54k|}
b2nd_to_cframe:
  724|  2.54k|                   bool *needs_free) {
  725|  2.54k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  726|  2.54k|  BLOSC_ERROR_NULL(cframe, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  727|  2.54k|  BLOSC_ERROR_NULL(cframe_len, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  728|  2.54k|  BLOSC_ERROR_NULL(needs_free, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  729|       |
  730|  2.54k|  *cframe_len = blosc2_schunk_to_buffer(array->sc, cframe, needs_free);
  731|  2.54k|  if (*cframe_len <= 0) {
  ------------------
  |  Branch (731:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  return BLOSC2_ERROR_SUCCESS;
  736|  2.54k|}
b2nd_from_cframe:
  739|  4.89k|int b2nd_from_cframe(uint8_t *cframe, int64_t cframe_len, bool copy, b2nd_array_t **array) {
  740|  4.89k|  BLOSC_ERROR_NULL(cframe, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.89k|    do {                                            \
  |  |  105|  4.89k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.89k]
  |  |  ------------------
  |  |  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.89k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.89k]
  |  |  ------------------
  ------------------
  741|  4.89k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  4.89k|    do {                                            \
  |  |  105|  4.89k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.89k]
  |  |  ------------------
  |  |  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.89k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.89k]
  |  |  ------------------
  ------------------
  742|       |
  743|  4.89k|  blosc2_schunk *sc = blosc2_schunk_from_buffer(cframe, cframe_len, copy);
  744|  4.89k|  if (sc == NULL) {
  ------------------
  |  Branch (744:7): [True: 2.35k, False: 2.54k]
  ------------------
  745|  2.35k|    BLOSC_TRACE_ERROR("Blosc error");
  ------------------
  |  |   93|  2.35k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  2.35k|    do {                                            \
  |  |  |  |   98|  2.35k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  2.35k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  2.35k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  746|  2.35k|    return BLOSC2_ERROR_FAILURE;
  747|  2.35k|  }
  748|       |  // ...and create a b2nd array out of it
  749|  2.54k|  int rc = b2nd_from_schunk(sc, array);
  750|  2.54k|  if (rc < 0) {
  ------------------
  |  Branch (750:7): [True: 2, False: 2.54k]
  ------------------
  751|      2|    blosc2_schunk_free(sc);
  752|      2|    return rc;
  753|      2|  }
  754|       |
  755|  2.54k|  return BLOSC2_ERROR_SUCCESS;
  756|  2.54k|}
b2nd_free:
  799|  15.0k|int b2nd_free(b2nd_array_t *array) {
  800|  15.0k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  15.0k|    do {                                            \
  |  |  105|  15.0k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 15.0k]
  |  |  ------------------
  |  |  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|  15.0k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 15.0k]
  |  |  ------------------
  ------------------
  801|       |
  802|  15.0k|  if (array) {
  ------------------
  |  Branch (802:7): [True: 15.0k, False: 0]
  ------------------
  803|  15.0k|    if (array->sc != NULL) {
  ------------------
  |  Branch (803:9): [True: 15.0k, False: 0]
  ------------------
  804|  15.0k|      blosc2_schunk_free(array->sc);
  805|  15.0k|    }
  806|  15.0k|    free(array->dtype);
  807|  15.0k|    free(array);
  808|  15.0k|  }
  809|  15.0k|  return BLOSC2_ERROR_SUCCESS;
  810|  15.0k|}
b2nd_from_cbuffer:
  813|    255|int b2nd_from_cbuffer(b2nd_context_t *ctx, b2nd_array_t **array, const void *buffer, int64_t buffersize) {
  814|    255|  BLOSC_ERROR_NULL(ctx, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    255|    do {                                            \
  |  |  105|    255|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 255]
  |  |  ------------------
  |  |  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|    255|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 255]
  |  |  ------------------
  ------------------
  815|    255|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    255|    do {                                            \
  |  |  105|    255|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 255]
  |  |  ------------------
  |  |  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|    255|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 255]
  |  |  ------------------
  ------------------
  816|    255|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|    255|    do {                                            \
  |  |  105|    255|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 255]
  |  |  ------------------
  |  |  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|    255|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 255]
  |  |  ------------------
  ------------------
  817|       |
  818|    255|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|    255|    do {                                            \
  |  |  112|    255|        int rc_ = (rc);                             \
  |  |  113|    255|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1, False: 254]
  |  |  ------------------
  |  |  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|    255|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 254]
  |  |  ------------------
  ------------------
  819|       |
  820|    254|  if (buffersize < (int64_t) (*array)->nitems * (*array)->sc->typesize) {
  ------------------
  |  Branch (820:7): [True: 18, False: 236]
  ------------------
  821|     18|    BLOSC_TRACE_ERROR("The buffersize (%lld) is smaller than the array size (%lld)",
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  822|     18|                        (long long) buffersize, (long long) (*array)->nitems * (*array)->sc->typesize);
  823|     18|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|     18|    do {                                            \
  |  |  112|     18|        int rc_ = (rc);                             \
  |  |  113|     18|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 18, False: 0]
  |  |  ------------------
  |  |  114|     18|            char *error_msg = print_error(rc_);     \
  |  |  115|     18|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|     18|            return rc_;                             \
  |  |  117|     18|        }                                           \
  |  |  118|     18|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  824|     18|  }
  825|       |
  826|    236|  if ((*array)->nitems == 0) {
  ------------------
  |  Branch (826:7): [True: 117, False: 119]
  ------------------
  827|    117|    return BLOSC2_ERROR_SUCCESS;
  828|    117|  }
  829|       |
  830|    119|  int64_t start[B2ND_MAX_DIM] = {0};
  831|    119|  int64_t *stop = (*array)->shape;
  832|    119|  int64_t *shape = (*array)->shape;
  833|    119|  BLOSC_ERROR(b2nd_set_slice_cbuffer(buffer, shape, buffersize, start, stop, *array));
  ------------------
  |  |  111|    119|    do {                                            \
  |  |  112|    119|        int rc_ = (rc);                             \
  |  |  113|    119|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 119]
  |  |  ------------------
  |  |  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|    119|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 119]
  |  |  ------------------
  ------------------
  834|       |
  835|    119|  return BLOSC2_ERROR_SUCCESS;
  836|    119|}
b2nd_to_cbuffer:
  840|  7.48k|                    int64_t buffersize) {
  841|  7.48k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.48k|    do {                                            \
  |  |  105|  7.48k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.48k]
  |  |  ------------------
  |  |  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.48k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.48k]
  |  |  ------------------
  ------------------
  842|  7.48k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.48k|    do {                                            \
  |  |  105|  7.48k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.48k]
  |  |  ------------------
  |  |  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.48k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.48k]
  |  |  ------------------
  ------------------
  843|  7.48k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) array));
  ------------------
  |  |  111|  7.48k|    do {                                            \
  |  |  112|  7.48k|        int rc_ = (rc);                             \
  |  |  113|  7.48k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 7.48k]
  |  |  ------------------
  |  |  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.48k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 7.48k]
  |  |  ------------------
  ------------------
  844|       |
  845|  7.48k|  if (buffersize < (int64_t) array->nitems * array->sc->typesize) {
  ------------------
  |  Branch (845:7): [True: 11, False: 7.47k]
  ------------------
  846|     11|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|     11|    do {                                            \
  |  |  112|     11|        int rc_ = (rc);                             \
  |  |  113|     11|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 11, False: 0]
  |  |  ------------------
  |  |  114|     11|            char *error_msg = print_error(rc_);     \
  |  |  115|     11|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|     11|            return rc_;                             \
  |  |  117|     11|        }                                           \
  |  |  118|     11|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  847|     11|  }
  848|       |
  849|  7.47k|  if (array->nitems == 0) {
  ------------------
  |  Branch (849:7): [True: 1.97k, False: 5.49k]
  ------------------
  850|  1.97k|    return BLOSC2_ERROR_SUCCESS;
  851|  1.97k|  }
  852|       |
  853|  5.49k|  int64_t start[B2ND_MAX_DIM] = {0};
  854|  5.49k|  const int64_t *stop = array->shape;
  855|  5.49k|  BLOSC_ERROR(b2nd_get_slice_cbuffer(array, start, stop, buffer, array->shape, buffersize));
  ------------------
  |  |  111|  5.49k|    do {                                            \
  |  |  112|  5.49k|        int rc_ = (rc);                             \
  |  |  113|  5.49k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 5.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|  5.49k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 5.49k]
  |  |  ------------------
  ------------------
  856|  5.49k|  return BLOSC2_ERROR_SUCCESS;
  857|  5.49k|}
get_set_slice:
 1531|  1.07M|                  prefetch_batch *prefetch) {
 1532|  1.07M|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.07M|    do {                                            \
  |  |  105|  1.07M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.07M]
  |  |  ------------------
  |  |  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.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 1533|  1.07M|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.07M|    do {                                            \
  |  |  105|  1.07M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.07M]
  |  |  ------------------
  |  |  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.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 1534|  1.07M|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.07M|    do {                                            \
  |  |  105|  1.07M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.07M]
  |  |  ------------------
  |  |  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.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 1535|  1.07M|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.07M|    do {                                            \
  |  |  105|  1.07M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.07M]
  |  |  ------------------
  |  |  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.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 1536|  1.07M|  if (buffersize < 0) {
  ------------------
  |  Branch (1536:7): [True: 0, False: 1.07M]
  ------------------
 1537|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1538|      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]
  |  |  ------------------
  ------------------
 1539|      0|  }
 1540|       |
 1541|  1.07M|  uint8_t *buffer_b = buffer;
 1542|  1.07M|  int8_t ndim = array->ndim;
 1543|       |
 1544|       |  // 0-dim case
 1545|  1.07M|  if (ndim == 0) {
  ------------------
  |  Branch (1545:7): [True: 0, False: 1.07M]
  ------------------
 1546|      0|    if (set_slice) {
  ------------------
  |  Branch (1546:9): [True: 0, False: 0]
  ------------------
 1547|      0|      int32_t chunk_size = array->sc->typesize + BLOSC2_MAX_OVERHEAD;
 1548|      0|      uint8_t *chunk = malloc(chunk_size);
 1549|      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]
  |  |  ------------------
  ------------------
 1550|      0|      if (blosc2_compress_ctx(array->sc->cctx, buffer_b, array->sc->typesize, chunk, chunk_size) < 0 ||
  ------------------
  |  Branch (1550:11): [True: 0, False: 0]
  ------------------
 1551|      0|          blosc2_schunk_update_chunk(array->sc, 0, chunk, false) < 0) {
  ------------------
  |  Branch (1551:11): [True: 0, False: 0]
  ------------------
 1552|       |        // Neither a failed compression nor a failed update took the chunk
 1553|      0|        free(chunk);
 1554|      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]
  |  |  ------------------
  ------------------
 1555|      0|      }
 1556|       |
 1557|      0|    } else {
 1558|       |      // The item is the whole slice: zero it first (an uninitialized chunk
 1559|       |      // decompresses to nothing), with slice_only nothing else
 1560|      0|      memset(buffer_b, 0, slice_only ? (size_t)array->sc->typesize : (size_t)buffersize);
  ------------------
  |  Branch (1560:27): [True: 0, False: 0]
  ------------------
 1561|      0|      if (blosc2_schunk_decompress_chunk(array->sc, 0, buffer_b, array->sc->typesize) < 0) {
  ------------------
  |  Branch (1561:11): [True: 0, False: 0]
  ------------------
 1562|      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]
  |  |  ------------------
  ------------------
 1563|      0|      }
 1564|      0|    }
 1565|      0|    return BLOSC2_ERROR_SUCCESS;
 1566|      0|  }
 1567|       |
 1568|  1.07M|  if (array->nitems == 0) {
  ------------------
  |  Branch (1568:7): [True: 412k, False: 661k]
  ------------------
 1569|   412k|    if (!set_slice && !slice_only) {
  ------------------
  |  Branch (1569:9): [True: 412k, False: 534]
  |  Branch (1569:23): [True: 412k, False: 0]
  ------------------
 1570|   412k|      memset(buffer_b, 0, (size_t)buffersize);
 1571|   412k|    }
 1572|   412k|    return BLOSC2_ERROR_SUCCESS;
 1573|   412k|  }
 1574|       |
 1575|   661k|  int64_t nelems_slice = 1;
 1576|  2.64M|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1576:19): [True: 1.98M, False: 661k]
  ------------------
 1577|  1.98M|    if (stop[i] - start[i] > shape[i]) {
  ------------------
  |  Branch (1577:9): [True: 0, False: 1.98M]
  ------------------
 1578|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1579|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1580|      0|    }
 1581|  1.98M|    nelems_slice *= stop[i] - start[i];
 1582|  1.98M|  }
 1583|   661k|  int64_t slice_nbytes = nelems_slice * array->sc->typesize;
 1584|       |  // Compute in 64 bits and range-check: the cast used to bind to extchunknitems
 1585|       |  // alone, truncating it before the multiply and sizing buffers from the
 1586|       |  // wrapped value while offsets kept using the full extent (see #795)
 1587|   661k|  int64_t data_nbytes_64 = 0;
 1588|   661k|  if (!blosc2_checked_mul_i64_nonneg(array->extchunknitems, array->sc->typesize, &data_nbytes_64) ||
  ------------------
  |  Branch (1588:7): [True: 0, False: 661k]
  ------------------
 1589|   661k|      data_nbytes_64 > INT32_MAX) {
  ------------------
  |  Branch (1589:7): [True: 0, False: 661k]
  ------------------
 1590|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 1590|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1591|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 1592|      0|  }
 1593|   661k|  int32_t data_nbytes = (int32_t) data_nbytes_64;
 1594|       |
 1595|   661k|  if (buffersize < slice_nbytes) {
  ------------------
  |  Branch (1595:7): [True: 0, False: 661k]
  ------------------
 1596|      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]
  |  |  ------------------
  ------------------
 1597|      0|  }
 1598|       |
 1599|   661k|  int64_t buffer_strides[B2ND_MAX_DIM];
 1600|   661k|  buffer_strides[ndim - 1] = 1;
 1601|  1.98M|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (1601:26): [True: 1.32M, False: 661k]
  ------------------
 1602|  1.32M|    buffer_strides[i] = buffer_strides[i + 1] * shape[i + 1];
 1603|  1.32M|  }
 1604|       |
 1605|   661k|  bool prefault = false;
 1606|   661k|  bool slice_zeroed = false;  // all items of the slice are zeros in the buffer already
 1607|   661k|  if (!set_slice && slice_only) {
  ------------------
  |  Branch (1607:7): [True: 127k, False: 533k]
  |  Branch (1607:21): [True: 0, False: 127k]
  ------------------
 1608|       |    // Only the slice's box gets written, but a fresh buffer still wants its
 1609|       |    // pages faulted in before several threads decompress into it (see
 1610|       |    // buffer_wants_prefault()).  That maps pages and changes no byte.
 1611|      0|    int64_t last = 0;
 1612|      0|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1612:21): [True: 0, False: 0]
  ------------------
 1613|      0|      last += (stop[i] - start[i] - 1) * buffer_strides[i];
 1614|      0|    }
 1615|      0|    prefault = buffer_wants_prefault(buffer_b, (last + 1) * array->sc->typesize, array->sc->dctx->nthreads);
 1616|      0|  }
 1617|   661k|  else if (!set_slice) {
  ------------------
  |  Branch (1617:12): [True: 127k, False: 533k]
  ------------------
 1618|   127k|    bool slice_fills_buffer = true;
 1619|       |    // The get paths below write every item of the slice, so only buffer
 1620|       |    // bytes outside of it need to be pre-initialized to be defined and
 1621|       |    // deterministic.  Skipping the rest saves a pass over the buffer, which
 1622|       |    // for a freshly allocated one is also where all its page faults hit.
 1623|   200k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1623:21): [True: 190k, False: 10.6k]
  ------------------
 1624|   190k|      if (start[i] < 0 || stop[i] < start[i] || stop[i] > array->shape[i] ||
  ------------------
  |  Branch (1624:11): [True: 0, False: 190k]
  |  Branch (1624:27): [True: 0, False: 190k]
  |  Branch (1624:49): [True: 116k, False: 73.9k]
  ------------------
 1625|   116k|          stop[i] - start[i] != shape[i]) {
  ------------------
  |  Branch (1625:11): [True: 0, False: 73.9k]
  ------------------
 1626|   116k|        slice_fills_buffer = false;
 1627|   116k|        break;
 1628|   116k|      }
 1629|   190k|    }
 1630|   127k|    if (slice_fills_buffer) {
  ------------------
  |  Branch (1630:9): [True: 10.6k, False: 116k]
  ------------------
 1631|  10.6k|      memset(buffer_b + slice_nbytes, 0, (size_t)(buffersize - slice_nbytes));
 1632|  10.6k|      prefault = buffer_wants_prefault(buffer_b, slice_nbytes, array->sc->dctx->nthreads);
 1633|  10.6k|    }
 1634|   116k|    else {
 1635|   116k|      memset(buffer_b, 0, (size_t)buffersize);
 1636|   116k|      slice_zeroed = true;
 1637|   116k|    }
 1638|   127k|  }
 1639|       |
 1640|       |  // Chunk-sized scratch (see scratch_malloc()), allocated lazily: the compact
 1641|       |  // get path below never needs it, and for large chunks just the malloc/free
 1642|       |  // pair costs O(chunksize) in page-table work (it is way above the malloc
 1643|       |  // mmap threshold), which would dominate small reads.
 1644|   661k|  uint8_t *data = NULL;
 1645|   661k|  size_t data_capacity = 0;
 1646|       |  // Block-sized scratch for the compact get path (lazily allocated too).
 1647|   661k|  uint8_t *block_data = NULL;
 1648|   661k|  size_t block_data_capacity = 0;
 1649|   661k|  int32_t block_nbytes = (int32_t) (array->blocknitems * array->sc->typesize);
 1650|   661k|  bool *block_maskout = NULL;
 1651|   661k|  int rc = BLOSC2_ERROR_SUCCESS;
 1652|       |
 1653|   661k|  int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 1654|  2.64M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1654:19): [True: 1.98M, False: 661k]
  ------------------
 1655|  1.98M|    chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 1656|  1.98M|  }
 1657|       |
 1658|   661k|  int64_t chunks_in_array_strides[B2ND_MAX_DIM];
 1659|   661k|  chunks_in_array_strides[ndim - 1] = 1;
 1660|  1.98M|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (1660:26): [True: 1.32M, False: 661k]
  ------------------
 1661|  1.32M|    chunks_in_array_strides[i] = chunks_in_array_strides[i + 1] * chunks_in_array[i + 1];
 1662|  1.32M|  }
 1663|       |
 1664|   661k|  int64_t blocks_in_chunk[B2ND_MAX_DIM] = {0};
 1665|  2.64M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1665:19): [True: 1.98M, False: 661k]
  ------------------
 1666|  1.98M|    blocks_in_chunk[i] = array->extchunkshape[i] / array->blockshape[i];
 1667|  1.98M|  }
 1668|   661k|  int32_t nblocks = (int32_t) array->extchunknitems / array->blocknitems;
 1669|   661k|  int64_t blockshape[B2ND_MAX_DIM];
 1670|  2.64M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1670:19): [True: 1.98M, False: 661k]
  ------------------
 1671|  1.98M|    blockshape[i] = array->blockshape[i];
 1672|  1.98M|  }
 1673|       |
 1674|   661k|  bool blocks_in_c_order = chunk_blocks_in_c_order(array);
 1675|   661k|  bool has_delta = filters_contain(array->sc->filters, BLOSC_DELTA);
 1676|   661k|  blosc2_context *dctx = array->sc->dctx;
 1677|       |  // The scatter get path brings its own postfilter, so it cannot serve
 1678|       |  // handles that have one (e.g. python-blosc2's lazy UDFs).
 1679|   661k|  bool can_scatter = !has_delta && dctx->postfilter == NULL;
  ------------------
  |  Branch (1679:22): [True: 661k, False: 0]
  |  Branch (1679:36): [True: 661k, False: 0]
  ------------------
 1680|       |  // Likewise for the gather set path and prefilters (python-blosc2 installs
 1681|       |  // some for lazy expressions); DELTA encodes against the first block of the
 1682|       |  // compressor input, which the gather does not fill.
 1683|   661k|  blosc2_context *cctx = array->sc->cctx;
 1684|   661k|  bool can_gather = cctx->prefilter == NULL && !filters_contain(cctx->filters, BLOSC_DELTA);
  ------------------
  |  Branch (1684:21): [True: 661k, False: 0]
  |  Branch (1684:48): [True: 661k, False: 0]
  ------------------
 1685|       |
 1686|       |  // Compute the number of chunks to update
 1687|   661k|  int64_t update_start[B2ND_MAX_DIM];
 1688|   661k|  int64_t update_shape[B2ND_MAX_DIM];
 1689|       |
 1690|   661k|  int64_t update_nchunks = 1;
 1691|  2.64M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1691:19): [True: 1.98M, False: 661k]
  ------------------
 1692|  1.98M|    int64_t pos = 0;
 1693|  31.2M|    while (pos <= start[i]) {
  ------------------
  |  Branch (1693:12): [True: 29.2M, False: 1.98M]
  ------------------
 1694|  29.2M|      pos += array->chunkshape[i];
 1695|  29.2M|    }
 1696|  1.98M|    update_start[i] = pos / array->chunkshape[i] - 1;
 1697|  2.53M|    while (pos < stop[i]) {
  ------------------
  |  Branch (1697:12): [True: 551k, False: 1.98M]
  ------------------
 1698|   551k|      pos += array->chunkshape[i];
 1699|   551k|    }
 1700|  1.98M|    update_shape[i] = pos / array->chunkshape[i] - update_start[i];
 1701|  1.98M|    update_nchunks *= update_shape[i];
 1702|  1.98M|  }
 1703|       |
 1704|   661k|  prefetch_batch *own_prefetch = set_slice || prefetch != NULL ? NULL : prefetch_slice(array, start, stop);
  ------------------
  |  Branch (1704:34): [True: 533k, False: 127k]
  |  Branch (1704:47): [True: 0, False: 127k]
  ------------------
 1705|   661k|  prefetch = own_prefetch != NULL ? own_prefetch : prefetch;
  ------------------
  |  Branch (1705:14): [True: 0, False: 661k]
  ------------------
 1706|       |
 1707|       |  // Chunks of zeros (b2nd_zeros(), sparse data) and uninitialized ones read
 1708|       |  // as zeros without decompression.  Find them from the index first; if they
 1709|       |  // hold a good part of the slice, zero the slice in one pass and skip them
 1710|       |  // (zeroing chunk by chunk writes many short rows: an all-zero 384^3 float16
 1711|       |  // box took 24 ms that way, 1.9 ms in one pass), else zero their boxes only.
 1712|       |  // Not with a postfilter, which may compute the items of special chunks,
 1713|       |  // and not for slices smaller than a block, where decompressing is cheap.
 1714|   661k|  int64_t *slice_chunks = NULL;  // the slice's chunks in loop order, then...
 1715|   661k|  uint8_t *zero_chunk = NULL;  // ...whether each reads as zeros (same allocation)
 1716|   661k|  if (!set_slice && dctx->postfilter == NULL && nelems_slice >= array->blocknitems) {
  ------------------
  |  Branch (1716:7): [True: 127k, False: 533k]
  |  Branch (1716:21): [True: 127k, False: 0]
  |  Branch (1716:49): [True: 62.4k, False: 64.5k]
  ------------------
 1717|  62.4k|    slice_chunks = malloc((size_t) update_nchunks * (sizeof(int64_t) + 1));
 1718|  62.4k|    if (slice_chunks == NULL) {
  ------------------
  |  Branch (1718:9): [True: 0, False: 62.4k]
  ------------------
 1719|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1720|      0|      goto out;
 1721|      0|    }
 1722|  62.4k|    zero_chunk = (uint8_t *) (slice_chunks + update_nchunks);
 1723|  1.03M|    for (int64_t u = 0; u < update_nchunks; ++u) {
  ------------------
  |  Branch (1723:25): [True: 970k, False: 62.4k]
  ------------------
 1724|   970k|      int64_t idx[B2ND_MAX_DIM] = {0};
 1725|   970k|      blosc2_unidim_to_multidim(ndim, update_shape, u, idx);
 1726|  4.53M|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1726:23): [True: 3.56M, False: 970k]
  ------------------
 1727|  3.56M|        idx[i] += update_start[i];
 1728|  3.56M|      }
 1729|   970k|      blosc2_multidim_to_unidim(idx, ndim, chunks_in_array_strides, &slice_chunks[u]);
 1730|   970k|    }
 1731|  62.4k|    if (chunks_special(array->sc, slice_chunks, update_nchunks, zero_chunk) < 0) {
  ------------------
  |  Branch (1731:9): [True: 37.8k, False: 24.6k]
  ------------------
 1732|  37.8k|      memset(zero_chunk, 0, (size_t) update_nchunks);  // the normal path reports what is wrong
 1733|  37.8k|    }
 1734|  62.4k|    int64_t zero_nitems = 0;
 1735|  1.03M|    for (int64_t u = 0; u < update_nchunks; ++u) {
  ------------------
  |  Branch (1735:25): [True: 970k, False: 62.4k]
  ------------------
 1736|   970k|      zero_chunk[u] = zero_chunk[u] == BLOSC2_SPECIAL_ZERO || zero_chunk[u] == BLOSC2_SPECIAL_UNINIT;
  ------------------
  |  Branch (1736:23): [True: 178k, False: 792k]
  |  Branch (1736:63): [True: 0, False: 792k]
  ------------------
 1737|   970k|      if (zero_chunk[u]) {
  ------------------
  |  Branch (1737:11): [True: 178k, False: 792k]
  ------------------
 1738|   178k|        int64_t cstart[B2ND_MAX_DIM], cstop[B2ND_MAX_DIM], bstart[B2ND_MAX_DIM], bstop[B2ND_MAX_DIM];
 1739|   178k|        chunk_box(array, slice_chunks[u], start, stop, cstart, cstop);
 1740|   178k|        zero_nitems += chunk_slice_box(ndim, cstart, cstop, start, stop, bstart, bstop);
 1741|   178k|      }
 1742|   970k|    }
 1743|  62.4k|    if (!slice_zeroed && 4 * zero_nitems >= nelems_slice) {
  ------------------
  |  Branch (1743:9): [True: 6.89k, False: 55.5k]
  |  Branch (1743:26): [True: 2.08k, False: 4.81k]
  ------------------
 1744|       |      // The slice's box of the buffer (the whole buffer unless slice_only; one memset() then)
 1745|  2.08k|      int64_t zstart[B2ND_MAX_DIM] = {0};
 1746|  2.08k|      int64_t zstop[B2ND_MAX_DIM];
 1747|  8.12k|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1747:23): [True: 6.04k, False: 2.08k]
  ------------------
 1748|  6.04k|        zstop[i] = stop[i] - start[i];
 1749|  6.04k|      }
 1750|  2.08k|      b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, zstart, zstop);
 1751|  2.08k|      slice_zeroed = true;
 1752|  2.08k|    }
 1753|  62.4k|  }
 1754|       |
 1755|  2.59M|  for (int64_t update_nchunk = 0; update_nchunk < update_nchunks; ++update_nchunk) {
  ------------------
  |  Branch (1755:35): [True: 1.93M, False: 660k]
  ------------------
 1756|  1.93M|    int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 1757|  1.93M|    blosc2_unidim_to_multidim(ndim, update_shape, update_nchunk, nchunk_ndim);
 1758|  10.7M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1758:21): [True: 8.79M, False: 1.93M]
  ------------------
 1759|  8.79M|      nchunk_ndim[i] += update_start[i];
 1760|  8.79M|    }
 1761|  1.93M|    int64_t nchunk;
 1762|  1.93M|    blosc2_multidim_to_unidim(nchunk_ndim, ndim, chunks_in_array_strides, &nchunk);
 1763|       |
 1764|       |    // Check if the chunk needs to be updated
 1765|  1.93M|    int64_t chunk_start[B2ND_MAX_DIM] = {0};
 1766|  1.93M|    int64_t chunk_stop[B2ND_MAX_DIM] = {0};
 1767|  10.7M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1767:21): [True: 8.79M, False: 1.93M]
  ------------------
 1768|  8.79M|      chunk_start[i] = nchunk_ndim[i] * array->chunkshape[i];
 1769|  8.79M|      chunk_stop[i] = chunk_start[i] + array->chunkshape[i];
 1770|  8.79M|      if (chunk_stop[i] > array->shape[i]) {
  ------------------
  |  Branch (1770:11): [True: 4.59M, False: 4.19M]
  ------------------
 1771|  4.59M|        chunk_stop[i] = array->shape[i];
 1772|  4.59M|      }
 1773|  8.79M|    }
 1774|  1.93M|    bool chunk_empty = false;
 1775|  10.7M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1775:21): [True: 8.79M, False: 1.93M]
  ------------------
 1776|  8.79M|      chunk_empty |= (chunk_stop[i] <= start[i] || chunk_start[i] >= stop[i]);
  ------------------
  |  Branch (1776:23): [True: 1.72M, False: 7.07M]
  |  Branch (1776:52): [True: 167k, False: 6.90M]
  ------------------
 1777|  8.79M|    }
 1778|  1.93M|    if (chunk_empty) {
  ------------------
  |  Branch (1778:9): [True: 314k, False: 1.61M]
  ------------------
 1779|   314k|      continue;
 1780|   314k|    }
 1781|  1.61M|    if (zero_chunk != NULL && zero_chunk[update_nchunk]) {
  ------------------
  |  Branch (1781:9): [True: 810k, False: 807k]
  |  Branch (1781:31): [True: 166k, False: 644k]
  ------------------
 1782|   166k|      if (!slice_zeroed) {
  ------------------
  |  Branch (1782:11): [True: 14.0k, False: 152k]
  ------------------
 1783|  14.0k|        int64_t box_start[B2ND_MAX_DIM];
 1784|  14.0k|        int64_t box_stop[B2ND_MAX_DIM];
 1785|  14.0k|        chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop, box_start, box_stop);
 1786|  14.0k|        b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, box_start, box_stop);
 1787|  14.0k|      }
 1788|   166k|      continue;
 1789|   166k|    }
 1790|       |    // Decompress each chunk as soon as it has been read ahead, while the later ones are still coming in
 1791|  1.45M|    prefetch_batch_wait(prefetch, nchunk);
 1792|  1.45M|    slice_chunk_t slice_chunk;
 1793|  1.45M|    memset(&slice_chunk, 0, sizeof(slice_chunk));
 1794|  1.45M|    slice_chunk.array = array;
 1795|  1.45M|    slice_chunk.buffer = buffer_b;
 1796|  1.45M|    slice_chunk.buffershape = shape;
 1797|  1.45M|    slice_chunk.start = start;
 1798|  1.45M|    slice_chunk.stop = stop;
 1799|  1.45M|    slice_chunk.chunk_start = chunk_start;
 1800|  1.45M|    slice_chunk.chunk_stop = chunk_stop;
 1801|  1.45M|    slice_chunk.blocks_in_chunk = blocks_in_chunk;
 1802|  1.45M|    slice_chunk.blockshape = blockshape;
 1803|       |
 1804|       |    // A whole chunk that is one run of the buffer in its decompressed layout
 1805|       |    // is (de)compressed straight from/into the buffer.
 1806|  1.45M|    int64_t run_offset;
 1807|  1.45M|    if (blocks_in_c_order &&
  ------------------
  |  Branch (1807:9): [True: 1.01M, False: 440k]
  ------------------
 1808|  1.01M|        chunk_contiguous_in_buffer(array, chunk_start, start, stop, shape, &run_offset)) {
  ------------------
  |  Branch (1808:9): [True: 782k, False: 228k]
  ------------------
 1809|   782k|      uint8_t *run = buffer_b + run_offset;
 1810|   782k|      if (set_slice) {
  ------------------
  |  Branch (1810:11): [True: 395k, False: 387k]
  ------------------
 1811|   395k|        rc = compress_update_chunk(array, nchunk, run, data_nbytes, NULL);
 1812|   395k|        if (rc < 0) {
  ------------------
  |  Branch (1812:13): [True: 0, False: 395k]
  ------------------
 1813|      0|          goto out;
 1814|      0|        }
 1815|   395k|      }
 1816|   387k|      else {
 1817|       |        // All threads start writing their blocks at once; with shares
 1818|       |        // below a huge page several of them hit each one
 1819|   387k|        if (prefault && data_nbytes / dctx->nthreads < (1 << 20) &&
  ------------------
  |  Branch (1819:13): [True: 0, False: 387k]
  |  Branch (1819:25): [True: 0, False: 0]
  ------------------
 1820|      0|            block_nbytes < (1 << 20)) {
  ------------------
  |  Branch (1820:13): [True: 0, False: 0]
  ------------------
 1821|      0|          prefault_range(run, data_nbytes);
 1822|      0|        }
 1823|   387k|        rc = blosc2_schunk_decompress_chunk(array->sc, nchunk, run, data_nbytes);
 1824|   387k|        if (rc < 0) {
  ------------------
  |  Branch (1824:13): [True: 0, False: 387k]
  ------------------
 1825|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1826|      0|          goto out;
 1827|      0|        }
 1828|   387k|        if (decoded_nothing(dctx, rc)) {
  ------------------
  |  Branch (1828:13): [True: 0, False: 387k]
  ------------------
 1829|      0|          memset(run, 0, (size_t)data_nbytes);
 1830|      0|        }
 1831|   387k|        rc = BLOSC2_ERROR_SUCCESS;
 1832|   387k|      }
 1833|   782k|      continue;
 1834|   782k|    }
 1835|       |
 1836|       |    // Compact get path state for this chunk (see below).
 1837|  1.45M|    bool use_compact = false;
 1838|   669k|    uint8_t *lazychunk = NULL;
 1839|   669k|    bool lazychunk_needs_free = false;
 1840|   669k|    int32_t lazychunk_cbytes = 0;
 1841|   669k|    if (set_slice) {
  ------------------
  |  Branch (1841:9): [True: 372k, False: 296k]
  ------------------
 1842|   372k|      if (data == NULL) {
  ------------------
  |  Branch (1842:11): [True: 139k, False: 233k]
  ------------------
 1843|   139k|        data = scratch_malloc(array, data_nbytes, &data_capacity);
 1844|   139k|        if (data == NULL) {
  ------------------
  |  Branch (1844:13): [True: 0, False: 139k]
  ------------------
 1845|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1846|      0|          goto out;
 1847|      0|        }
 1848|   139k|      }
 1849|       |      // Check if all the chunk is going to be updated and avoid the decompression
 1850|   372k|      bool decompress_chunk = false;
 1851|  2.41M|      for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1851:23): [True: 2.03M, False: 372k]
  ------------------
 1852|  2.03M|        decompress_chunk |= (chunk_start[i] < start[i] || chunk_stop[i] > stop[i]);
  ------------------
  |  Branch (1852:30): [True: 14.7k, False: 2.02M]
  |  Branch (1852:59): [True: 4.12k, False: 2.02M]
  ------------------
 1853|  2.03M|      }
 1854|       |
 1855|       |      // On a partly overwritten chunk the gather copies every block that
 1856|       |      // keeps old items once more, so it only pays when the slice covers a
 1857|       |      // good part of the chunk.
 1858|   372k|      int64_t box_start[B2ND_MAX_DIM];
 1859|   372k|      int64_t box_stop[B2ND_MAX_DIM];
 1860|   372k|      int64_t overlap_nitems = chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop,
 1861|   372k|                                               box_start, box_stop);
 1862|   372k|      if (can_gather && (!decompress_chunk || 2 * overlap_nitems >= array->extchunknitems)) {
  ------------------
  |  Branch (1862:11): [True: 372k, False: 0]
  |  Branch (1862:26): [True: 355k, False: 16.9k]
  |  Branch (1862:47): [True: 2.58k, False: 14.3k]
  ------------------
 1863|       |        // Gather path: the compression threads take the new items straight
 1864|       |        // from the buffer.  Only blocks keeping some old items need the old
 1865|       |        // chunk, and when there are none `data` stays untouched.
 1866|   358k|        if (decompress_chunk) {
  ------------------
  |  Branch (1866:13): [True: 2.58k, False: 355k]
  ------------------
 1867|  2.58k|          if (block_maskout == NULL) {
  ------------------
  |  Branch (1867:15): [True: 206, False: 2.37k]
  ------------------
 1868|    206|            block_maskout = malloc(nblocks);
 1869|    206|            if (block_maskout == NULL) {
  ------------------
  |  Branch (1869:17): [True: 0, False: 206]
  ------------------
 1870|      0|              rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1871|      0|              goto out;
 1872|      0|            }
 1873|    206|          }
 1874|  44.8k|          for (int nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (1874:32): [True: 42.2k, False: 2.58k]
  ------------------
 1875|  42.2k|            block_overlap_t overlap;
 1876|  42.2k|            block_maskout[nblock] = block_slice_overlap(&slice_chunk, nblock, &overlap) &&
  ------------------
  |  Branch (1876:37): [True: 26.2k, False: 15.9k]
  ------------------
 1877|  26.2k|                                    overlap.whole_block;
  ------------------
  |  Branch (1877:37): [True: 21.0k, False: 5.25k]
  ------------------
 1878|  42.2k|          }
 1879|  2.58k|          int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 1880|  2.58k|                                             NULL, NULL, data, data_nbytes);
 1881|  2.58k|          if (err < 0) {
  ------------------
  |  Branch (1881:15): [True: 3, False: 2.58k]
  ------------------
 1882|      3|            BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1883|      3|            rc = BLOSC2_ERROR_FAILURE;
 1884|      3|            goto out;
 1885|      3|          }
 1886|  2.58k|          if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (1886:15): [True: 0, False: 2.58k]
  ------------------
 1887|      0|            memset(data, 0, data_nbytes);
 1888|      0|          }
 1889|  2.58k|        }
 1890|   358k|        slice_chunk.keep_old = decompress_chunk;
 1891|   358k|        rc = compress_update_chunk(array, nchunk, data, data_nbytes, &slice_chunk);
 1892|   358k|        if (rc < 0) {
  ------------------
  |  Branch (1892:13): [True: 118, False: 358k]
  ------------------
 1893|    118|          goto out;
 1894|    118|        }
 1895|   358k|        continue;
 1896|   358k|      }
 1897|       |
 1898|  14.3k|      if (decompress_chunk) {
  ------------------
  |  Branch (1898:11): [True: 14.3k, False: 0]
  ------------------
 1899|  14.3k|        int err = blosc2_schunk_decompress_chunk(array->sc, nchunk, data, data_nbytes);
 1900|  14.3k|        if (err < 0) {
  ------------------
  |  Branch (1900:13): [True: 269, False: 14.0k]
  ------------------
 1901|    269|          BLOSC_TRACE_ERROR("Error decompressing chunk");
  ------------------
  |  |   93|    269|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    269|    do {                                            \
  |  |  |  |   98|    269|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    269|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 269, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    269|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1902|    269|          rc = BLOSC2_ERROR_FAILURE;
 1903|    269|          goto out;
 1904|    269|        }
 1905|  14.0k|        if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (1905:13): [True: 0, False: 14.0k]
  ------------------
 1906|      0|          memset(data, 0, data_nbytes);
 1907|      0|        }
 1908|  14.0k|      } else {
 1909|       |        // Avoid writing non zero padding from previous chunk
 1910|      0|        memset(data, 0, data_nbytes);
 1911|      0|      }
 1912|   296k|    } else {
 1913|   296k|      if (block_maskout == NULL) {
  ------------------
  |  Branch (1913:11): [True: 12.6k, False: 283k]
  ------------------
 1914|  12.6k|        block_maskout = malloc(nblocks);
 1915|  12.6k|        if (block_maskout == NULL) {
  ------------------
  |  Branch (1915:13): [True: 0, False: 12.6k]
  ------------------
 1916|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1917|      0|          goto out;
 1918|      0|        }
 1919|  12.6k|      }
 1920|       |      // Delta filter encodes subsequent blocks relative to the reference block (block 0): if any block in the chunk
 1921|       |      // is needed, block 0 must be decompressed as reference
 1922|   296k|      int32_t nblocks_needed = (int32_t) slice_chunk_maskout(&slice_chunk, nblocks, has_delta, block_maskout);
 1923|       |
 1924|       |      // Compact get path: when only a fraction of the chunk's blocks is
 1925|       |      // needed, decompress just those blocks -- one at a time, straight
 1926|       |      // from the (lazy)chunk -- instead of decompressing into a chunk-sized
 1927|       |      // scratch.  This keeps the working buffer at one block, so small reads
 1928|       |      // from arrays with large chunks stay O(request), not O(chunksize).
 1929|       |      // Larger requests keep the maskout path, which decompresses the needed
 1930|       |      // blocks in parallel.
 1931|       |      //
 1932|       |      // The threshold depends on the storage backend.  On disk, the maskout
 1933|       |      // path reads the *whole* compressed chunk per call while the compact
 1934|       |      // path only reads the touched blocks, so compact wins by 10-100x well
 1935|       |      // past needed == nblocks/4 for typical data.  In memory there is no
 1936|       |      // I/O to save: for poorly-compressible data the maskout path's
 1937|       |      // parallel decompression overtakes the compact path's serial one at
 1938|       |      // around 2-4 needed blocks, so stay conservative there (1/16 keeps
 1939|       |      // the possible loss window narrow while still capturing the common
 1940|       |      // 1-2 block reads, where compact always wins or ties).
 1941|       |      //
 1942|       |      // If DELTA is used, blocks cannot be decompressed independently; keep maskout path.
 1943|   296k|      use_compact = slice_chunk_compact(array, nblocks_needed, has_delta);
 1944|   296k|      if (use_compact) {
  ------------------
  |  Branch (1944:11): [True: 66.3k, False: 229k]
  ------------------
 1945|  66.3k|        lazychunk_cbytes = blosc2_schunk_get_lazychunk(array->sc, nchunk, &lazychunk,
 1946|  66.3k|                                                       &lazychunk_needs_free);
 1947|  66.3k|        if (lazychunk_cbytes < 0) {
  ------------------
  |  Branch (1947:13): [True: 538, False: 65.8k]
  ------------------
 1948|    538|          BLOSC_TRACE_ERROR("Error getting the lazy chunk");
  ------------------
  |  |   93|    538|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    538|    do {                                            \
  |  |  |  |   98|    538|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    538|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 538, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    538|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1949|    538|          rc = BLOSC2_ERROR_FAILURE;
 1950|    538|          goto out;
 1951|    538|        }
 1952|  65.8k|        if (block_data == NULL) {
  ------------------
  |  Branch (1952:13): [True: 3.44k, False: 62.3k]
  ------------------
 1953|  3.44k|          block_data = scratch_malloc(array, block_nbytes, &block_data_capacity);
 1954|  3.44k|          if (block_data == NULL) {
  ------------------
  |  Branch (1954:15): [True: 0, False: 3.44k]
  ------------------
 1955|      0|            if (lazychunk_needs_free) {
  ------------------
  |  Branch (1955:17): [True: 0, False: 0]
  ------------------
 1956|      0|              free(lazychunk);
 1957|      0|            }
 1958|      0|            rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1959|      0|            goto out;
 1960|      0|          }
 1961|  3.44k|        }
 1962|   229k|      } else {
 1963|   229k|        if (data == NULL) {
  ------------------
  |  Branch (1963:13): [True: 11.2k, False: 218k]
  ------------------
 1964|  11.2k|          data = scratch_malloc(array, data_nbytes, &data_capacity);
 1965|  11.2k|          if (data == NULL) {
  ------------------
  |  Branch (1965:15): [True: 0, False: 11.2k]
  ------------------
 1966|      0|            rc = BLOSC2_ERROR_MEMORY_ALLOC;
 1967|      0|            goto out;
 1968|      0|          }
 1969|  11.2k|        }
 1970|   229k|        bool scattered = false;
 1971|   229k|        if (can_scatter) {
  ------------------
  |  Branch (1971:13): [True: 229k, False: 0]
  ------------------
 1972|       |          // Scatter path: the needed blocks go from the worker threads that
 1973|       |          // decode them straight to the buffer.  `data` only satisfies the
 1974|       |          // decompressor's destination size and stays untouched.
 1975|   229k|          int64_t box_start[B2ND_MAX_DIM];
 1976|   229k|          int64_t box_stop[B2ND_MAX_DIM];
 1977|   229k|          chunk_slice_box(ndim, chunk_start, chunk_stop, start, stop, box_start, box_stop);
 1978|   229k|          if (prefault) {
  ------------------
  |  Branch (1978:15): [True: 0, False: 229k]
  ------------------
 1979|      0|            int64_t box_last[B2ND_MAX_DIM];
 1980|      0|            for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1980:29): [True: 0, False: 0]
  ------------------
 1981|      0|              box_last[i] = box_stop[i] - 1;
 1982|      0|            }
 1983|      0|            int64_t first;
 1984|      0|            int64_t last;
 1985|      0|            blosc2_multidim_to_unidim(box_start, ndim, buffer_strides, &first);
 1986|      0|            blosc2_multidim_to_unidim(box_last, ndim, buffer_strides, &last);
 1987|      0|            prefault_range(buffer_b + first * array->sc->typesize,
 1988|      0|                           (last + 1 - first) * array->sc->typesize);
 1989|      0|          }
 1990|   229k|          int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 1991|   229k|                                             slice_scatter_postfilter, &slice_chunk, data, data_nbytes);
 1992|   229k|          if (err < 0) {
  ------------------
  |  Branch (1992:15): [True: 0, False: 229k]
  ------------------
 1993|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1994|      0|            rc = BLOSC2_ERROR_FAILURE;
 1995|      0|            goto out;
 1996|      0|          }
 1997|   229k|          if (err == 0) {
  ------------------
  |  Branch (1997:15): [True: 0, False: 229k]
  ------------------
 1998|       |            // Missing chunk: nothing was decoded
 1999|      0|            b2nd_zero_box(ndim, array->sc->typesize, buffer_b, shape, box_start, box_stop);
 2000|      0|          }
 2001|   229k|          scattered = err == 0 || !scatter_unsupported(dctx);
  ------------------
  |  Branch (2001:23): [True: 0, False: 229k]
  |  Branch (2001:35): [True: 229k, False: 0]
  ------------------
 2002|   229k|        }
 2003|   229k|        if (scattered) {
  ------------------
  |  Branch (2003:13): [True: 229k, False: 0]
  ------------------
 2004|   229k|          continue;
 2005|   229k|        }
 2006|      0|        int err = schunk_decompress_masked(array->sc, nchunk, NULL, 0, block_maskout, nblocks,
 2007|      0|                                           NULL, NULL, data, data_nbytes);
 2008|      0|        if (err < 0) {
  ------------------
  |  Branch (2008:13): [True: 0, False: 0]
  ------------------
 2009|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2010|      0|          rc = BLOSC2_ERROR_FAILURE;
 2011|      0|          goto out;
 2012|      0|        }
 2013|      0|        if (decoded_nothing(dctx, err)) {
  ------------------
  |  Branch (2013:13): [True: 0, False: 0]
  ------------------
 2014|      0|          memset(data, 0, data_nbytes);
 2015|      0|        }
 2016|      0|      }
 2017|   296k|    }
 2018|       |
 2019|       |    // Iterate over blocks
 2020|       |
 2021|  25.9M|    for (int nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (2021:26): [True: 25.8M, False: 79.9k]
  ------------------
 2022|  25.8M|      block_overlap_t overlap;
 2023|  25.8M|      if (!block_slice_overlap(&slice_chunk, nblock, &overlap)) {
  ------------------
  |  Branch (2023:11): [True: 25.6M, False: 249k]
  ------------------
 2024|  25.6M|        continue;
 2025|  25.6M|      }
 2026|       |
 2027|   249k|      uint8_t *dst;
 2028|   249k|      if (use_compact) {
  ------------------
  |  Branch (2028:11): [True: 222k, False: 27.8k]
  ------------------
 2029|       |        // Decompress just this block from the (lazy)chunk.
 2030|   222k|        int grc = blosc2_getitem_bytes_ctx(array->sc->dctx, lazychunk, lazychunk_cbytes,
 2031|   222k|                                           (int32_t) ((int64_t) nblock * block_nbytes), block_nbytes,
 2032|   222k|                                           block_data, block_nbytes);
 2033|   222k|        if (grc < 0) {
  ------------------
  |  Branch (2033:13): [True: 0, False: 222k]
  ------------------
 2034|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2035|      0|          if (lazychunk_needs_free) {
  ------------------
  |  Branch (2035:15): [True: 0, False: 0]
  ------------------
 2036|      0|            free(lazychunk);
 2037|      0|          }
 2038|      0|          rc = BLOSC2_ERROR_FAILURE;
 2039|      0|          goto out;
 2040|      0|        }
 2041|   222k|        if (decoded_nothing(dctx, grc)) {
  ------------------
  |  Branch (2041:13): [True: 0, False: 222k]
  ------------------
 2042|      0|          memset(block_data, 0, block_nbytes);
 2043|      0|        }
 2044|   222k|        dst = block_data;
 2045|   222k|      } else {
 2046|  27.8k|        dst = &data[nblock * array->blocknitems * array->sc->typesize];
 2047|  27.8k|      }
 2048|       |
 2049|   249k|      if (set_slice) {
  ------------------
  |  Branch (2049:11): [True: 27.8k, False: 222k]
  ------------------
 2050|  27.8k|        b2nd_copy_buffer2(ndim, array->sc->typesize,
 2051|  27.8k|                          buffer_b, shape, overlap.dst_start, overlap.dst_stop,
 2052|  27.8k|                          dst, blockshape, overlap.src_start);
 2053|   222k|      } else {
 2054|   222k|        b2nd_copy_buffer2(ndim, array->sc->typesize,
 2055|   222k|                          dst, blockshape, overlap.src_start, overlap.src_stop,
 2056|   222k|                          buffer_b, shape, overlap.dst_start);
 2057|   222k|      }
 2058|   249k|    }
 2059|       |
 2060|  79.9k|    if (use_compact && lazychunk_needs_free) {
  ------------------
  |  Branch (2060:9): [True: 65.8k, False: 14.0k]
  |  Branch (2060:24): [True: 4.76k, False: 61.0k]
  ------------------
 2061|  4.76k|      free(lazychunk);
 2062|  4.76k|    }
 2063|       |
 2064|  79.9k|    if (set_slice) {
  ------------------
  |  Branch (2064:9): [True: 14.0k, False: 65.8k]
  ------------------
 2065|  14.0k|      rc = compress_update_chunk(array, nchunk, data, data_nbytes, NULL);
 2066|  14.0k|      if (rc < 0) {
  ------------------
  |  Branch (2066:11): [True: 0, False: 14.0k]
  ------------------
 2067|      0|        goto out;
 2068|      0|      }
 2069|  14.0k|    }
 2070|  79.9k|  }
 2071|       |
 2072|   661k|  out:
 2073|   661k|  free(slice_chunks);
 2074|   661k|  prefetch_batch_free(own_prefetch);
 2075|   661k|  blosc2_tmp_free(data, data_capacity);
 2076|   661k|  blosc2_tmp_free(block_data, block_data_capacity);
 2077|   661k|  free(block_maskout);
 2078|       |
 2079|   661k|  return rc;
 2080|   661k|}
b2nd_get_slice_cbuffer:
 2120|  8.04k|                           void *buffer, const int64_t *buffershape, int64_t buffersize) {
 2121|  8.04k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.04k|    do {                                            \
  |  |  105|  8.04k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.04k]
  |  |  ------------------
  |  |  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.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.04k]
  |  |  ------------------
  ------------------
 2122|  8.04k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.04k|    do {                                            \
  |  |  105|  8.04k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.04k]
  |  |  ------------------
  |  |  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.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.04k]
  |  |  ------------------
  ------------------
 2123|  8.04k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.04k|    do {                                            \
  |  |  105|  8.04k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.04k]
  |  |  ------------------
  |  |  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.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.04k]
  |  |  ------------------
  ------------------
 2124|  8.04k|  BLOSC_ERROR_NULL(buffershape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.04k|    do {                                            \
  |  |  105|  8.04k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.04k]
  |  |  ------------------
  |  |  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.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.04k]
  |  |  ------------------
  ------------------
 2125|  8.04k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  8.04k|    do {                                            \
  |  |  105|  8.04k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 8.04k]
  |  |  ------------------
  |  |  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.04k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 8.04k]
  |  |  ------------------
  ------------------
 2126|       |
 2127|  8.04k|  return locked_get_set_slice(buffer, buffersize, start, stop, buffershape, (b2nd_array_t *) array,
 2128|  8.04k|                              false, false, NULL);
 2129|  8.04k|}
b2nd_set_slice_cbuffer:
 2179|   534k|                           b2nd_array_t *array) {
 2180|   534k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|   534k|    do {                                            \
  |  |  105|   534k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 534k]
  |  |  ------------------
  |  |  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|   534k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 534k]
  |  |  ------------------
  ------------------
 2181|   534k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|   534k|    do {                                            \
  |  |  105|   534k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 534k]
  |  |  ------------------
  |  |  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|   534k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 534k]
  |  |  ------------------
  ------------------
 2182|   534k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|   534k|    do {                                            \
  |  |  105|   534k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 534k]
  |  |  ------------------
  |  |  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|   534k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 534k]
  |  |  ------------------
  ------------------
 2183|   534k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|   534k|    do {                                            \
  |  |  105|   534k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 534k]
  |  |  ------------------
  |  |  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|   534k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 534k]
  |  |  ------------------
  ------------------
 2184|       |
 2185|   534k|  return locked_get_set_slice((void *) buffer, buffersize, start, stop, buffershape, array, true, false, NULL);
 2186|   534k|}
b2nd_get_slice:
 2194|  2.54k|                   const int64_t *stop) {
 2195|  2.54k|  BLOSC_ERROR_NULL(src, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2196|  2.54k|  BLOSC_ERROR_NULL(start, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2197|  2.54k|  BLOSC_ERROR_NULL(stop, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2198|  2.54k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2199|  2.54k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) src));
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2200|       |
 2201|  2.54k|  ctx->ndim = src->ndim;
 2202|  13.7k|  for (int i = 0; i < src->ndim; ++i) {
  ------------------
  |  Branch (2202:19): [True: 11.2k, False: 2.54k]
  ------------------
 2203|  11.2k|    ctx->shape[i] = stop[i] - start[i];
 2204|  11.2k|  }
 2205|       |
 2206|       |  // Add data
 2207|  2.54k|  BLOSC_ERROR(b2nd_empty(ctx, array));
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2208|       |
 2209|  2.54k|  if ((*array)->nitems == 0) {
  ------------------
  |  Branch (2209:7): [True: 1.16k, False: 1.37k]
  ------------------
 2210|  1.16k|    return BLOSC2_ERROR_SUCCESS;
 2211|  1.16k|  }
 2212|       |
 2213|       |  // Read the chunks of the whole source slice ahead, not only those of one result chunk at a time
 2214|  1.37k|  prefetch_batch *prefetch = prefetch_slice(src, start, stop);
 2215|  1.37k|  int rc = get_slice_chunks(ctx, array, src, start, prefetch);
 2216|  1.37k|  prefetch_batch_free(prefetch);
 2217|  1.37k|  return rc;
 2218|  2.54k|}
view_new:
 2315|  7.37k|int view_new(const b2nd_array_t *array, b2nd_array_t **view, b2nd_context_t *ctx1) {
 2316|       |
 2317|  7.37k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.37k|    do {                                            \
  |  |  105|  7.37k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.37k]
  |  |  ------------------
  ------------------
 2318|  7.37k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.37k|    do {                                            \
  |  |  105|  7.37k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.37k]
  |  |  ------------------
  ------------------
 2319|       |
 2320|       |  // The view is not contiguous (points to the original contiguous cframe which has different shape)
 2321|       |  // so we set contiguous to false, which forces a copy when calling to_cframe
 2322|  7.37k|  ctx1->b2_storage->contiguous = false;
 2323|       |
 2324|       |
 2325|       |  /* Fill view with zeros */
 2326|  7.37k|  BLOSC_ERROR(b2nd_zeros(ctx1, view));
  ------------------
  |  |  111|  7.37k|    do {                                            \
  |  |  112|  7.37k|        int rc_ = (rc);                             \
  |  |  113|  7.37k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 7.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 7.37k]
  |  |  ------------------
  ------------------
 2327|       |  // Free the chunks in base array
 2328|   724k|  for (int i = 0; i < (*view)->sc->nchunks; i++) {
  ------------------
  |  Branch (2328:19): [True: 716k, False: 7.37k]
  ------------------
 2329|   716k|    free((*view)->sc->data[i]);
 2330|   716k|  }
 2331|  7.37k|  free((*view)->sc->data);
 2332|  7.37k|  (*view)->sc->view = true;
 2333|  7.37k|  (*view)->sc->data = array->sc->data; // point view to the same data
 2334|  7.37k|  (*view)->sc->frame = array->sc->frame; // if original array is contiguous, point to frame
 2335|  7.37k|  (*view)->sc->nvlmetalayers = array->sc->nvlmetalayers; //
 2336|  7.37k|  for (int i = 0; i< array->sc->nvlmetalayers; i++) {
  ------------------
  |  Branch (2336:19): [True: 0, False: 7.37k]
  ------------------
 2337|      0|    (*view)->sc->vlmetalayers[i] = array->sc->vlmetalayers[i]; // add ptrs to vlmetalayers
 2338|      0|  }
 2339|       |
 2340|  7.37k|  return BLOSC2_ERROR_SUCCESS;
 2341|  7.37k|}
b2nd_expand_dims:
 2343|  2.37k|int b2nd_expand_dims(const b2nd_array_t *array, b2nd_array_t **view, const bool *axis, const uint8_t final_dims) {
 2344|  2.37k|  BLOSC_ERROR(refresh_if_stale((b2nd_array_t *) array));
  ------------------
  |  |  111|  2.37k|    do {                                            \
  |  |  112|  2.37k|        int rc_ = (rc);                             \
  |  |  113|  2.37k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.37k]
  |  |  ------------------
  ------------------
 2345|  4.75k|  for (int i = 0; i < array->sc->nmetalayers; ++i) {
  ------------------
  |  Branch (2345:19): [True: 2.37k, False: 2.37k]
  ------------------
 2346|  2.37k|    if (strcmp(array->sc->metalayers[i]->name, "b2nd") != 0) {
  ------------------
  |  Branch (2346:9): [True: 0, False: 2.37k]
  ------------------
 2347|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2348|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2349|      0|    }
 2350|  2.37k|  }
 2351|  2.37k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.37k|    do {                                            \
  |  |  105|  2.37k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.37k]
  |  |  ------------------
  ------------------
 2352|  2.37k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.37k|    do {                                            \
  |  |  105|  2.37k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.37k]
  |  |  ------------------
  |  |  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.37k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.37k]
  |  |  ------------------
  ------------------
 2353|       |
 2354|  2.37k|  uint8_t old_idx = 0;
 2355|  2.37k|  int64_t newshape[B2ND_MAX_DIM];
 2356|  2.37k|  int32_t newchunkshape[B2ND_MAX_DIM];
 2357|  2.37k|  int32_t newblockshape[B2ND_MAX_DIM];
 2358|       |
 2359|  15.7k|  for (int i = 0; i < final_dims; ++i) {
  ------------------
  |  Branch (2359:19): [True: 13.3k, False: 2.37k]
  ------------------
 2360|  13.3k|    if (axis[i] == true) {
  ------------------
  |  Branch (2360:9): [True: 4.75k, False: 8.61k]
  ------------------
 2361|  4.75k|      newshape[i] = 1;
 2362|  4.75k|      newchunkshape[i] = 1;
 2363|  4.75k|      newblockshape[i] = 1;
 2364|  4.75k|    }
 2365|  8.61k|    else {
 2366|  8.61k|      if (old_idx == array->ndim) {
  ------------------
  |  Branch (2366:11): [True: 0, False: 8.61k]
  ------------------
 2367|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2368|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2369|      0|      }
 2370|  8.61k|      newshape[i] = array->shape[old_idx];
 2371|  8.61k|      newchunkshape[i] = array->chunkshape[old_idx];
 2372|  8.61k|      newblockshape[i] = array->blockshape[old_idx];
 2373|  8.61k|      old_idx++;
 2374|  8.61k|    }
 2375|  13.3k|  }
 2376|       |
 2377|       |  //views only deal with cparams/dparams; storage is always in-memory (ephemeral).
 2378|  2.37k|  blosc2_cparams cparams = *(array->sc->storage->cparams);
 2379|  2.37k|  blosc2_dparams dparams = *(array->sc->storage->dparams);
 2380|  2.37k|  blosc2_storage b2_storage1 = {.cparams=&cparams, .dparams=&dparams};
 2381|       |
 2382|  2.37k|  b2nd_context_t *ctx1 = b2nd_create_ctx(&b2_storage1, final_dims, newshape,
 2383|  2.37k|                                        newchunkshape, newblockshape, array->dtype,
 2384|  2.37k|                                        array->dtype_format, NULL, 0);
 2385|       |
 2386|  2.37k|  view_new(array, view, ctx1);
 2387|  2.37k|  b2nd_free_ctx(ctx1);
 2388|       |
 2389|  2.37k|  return BLOSC2_ERROR_SUCCESS;
 2390|  2.37k|}
b2nd_squeeze:
 2393|  2.54k|int b2nd_squeeze(b2nd_array_t *array, b2nd_array_t **view) {
 2394|  2.54k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2395|  2.54k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  2.54k|    do {                                            \
  |  |  105|  2.54k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2396|       |
 2397|  2.54k|  bool index[B2ND_MAX_DIM];
 2398|       |
 2399|  13.7k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2399:19): [True: 11.2k, False: 2.54k]
  ------------------
 2400|  11.2k|    if (array->shape[i] != 1) {
  ------------------
  |  Branch (2400:9): [True: 6.44k, False: 4.77k]
  ------------------
 2401|  6.44k|      index[i] = false;
 2402|  6.44k|    } else {
 2403|  4.77k|      index[i] = true;
 2404|  4.77k|    }
 2405|  11.2k|  }
 2406|  2.54k|  BLOSC_ERROR(b2nd_squeeze_index(array, view, index));
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 2.54k]
  |  |  ------------------
  |  |  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.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
 2407|       |
 2408|  2.54k|  return BLOSC2_ERROR_SUCCESS;
 2409|  2.54k|}
b2nd_squeeze_index:
 2412|  5.09k|int b2nd_squeeze_index(b2nd_array_t *array, b2nd_array_t **view, const bool *index) {
 2413|  5.09k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  5.09k|    do {                                            \
  |  |  112|  5.09k|        int rc_ = (rc);                             \
  |  |  113|  5.09k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 5.09k]
  |  |  ------------------
  |  |  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|  5.09k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 5.09k]
  |  |  ------------------
  ------------------
 2414|  10.1k|  for (int i = 0; i < array->sc->nmetalayers; ++i) {
  ------------------
  |  Branch (2414:19): [True: 5.09k, False: 5.09k]
  ------------------
 2415|  5.09k|    if (strcmp(array->sc->metalayers[i]->name, "b2nd") != 0) {
  ------------------
  |  Branch (2415:9): [True: 0, False: 5.09k]
  ------------------
 2416|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2417|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2418|      0|    }
 2419|  5.09k|  }
 2420|  5.09k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  5.09k|    do {                                            \
  |  |  105|  5.09k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 5.09k]
  |  |  ------------------
  |  |  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.09k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.09k]
  |  |  ------------------
  ------------------
 2421|  5.09k|  BLOSC_ERROR_NULL(view, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  5.09k|    do {                                            \
  |  |  105|  5.09k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 5.09k]
  |  |  ------------------
  |  |  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.09k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 5.09k]
  |  |  ------------------
  ------------------
 2422|       |
 2423|  5.09k|  uint8_t nones = 0;
 2424|  5.09k|  int64_t newshape[B2ND_MAX_DIM];
 2425|  5.09k|  int32_t newchunkshape[B2ND_MAX_DIM];
 2426|  5.09k|  int32_t newblockshape[B2ND_MAX_DIM];
 2427|       |
 2428|  27.0k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2428:19): [True: 22.0k, False: 5.00k]
  ------------------
 2429|  22.0k|    if (index[i] == true) {
  ------------------
  |  Branch (2429:9): [True: 7.95k, False: 14.0k]
  ------------------
 2430|  7.95k|      if (array->shape[i] != 1) {
  ------------------
  |  Branch (2430:11): [True: 90, False: 7.86k]
  ------------------
 2431|     90|        BLOSC_ERROR(BLOSC2_ERROR_INVALID_INDEX);
  ------------------
  |  |  111|     90|    do {                                            \
  |  |  112|     90|        int rc_ = (rc);                             \
  |  |  113|     90|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 90, False: 0]
  |  |  ------------------
  |  |  114|     90|            char *error_msg = print_error(rc_);     \
  |  |  115|     90|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|     90|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|     90|    do {                                            \
  |  |  |  |  |  |   98|     90|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|     90|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 90, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|     90|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|     90|            return rc_;                             \
  |  |  117|     90|        }                                           \
  |  |  118|     90|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2432|     90|      }
 2433|  14.0k|    } else {
 2434|  14.0k|      newshape[nones] = array->shape[i];
 2435|  14.0k|      newchunkshape[nones] = array->chunkshape[i];
 2436|  14.0k|      newblockshape[nones] = array->blockshape[i];
 2437|  14.0k|      nones += 1;
 2438|  14.0k|    }
 2439|  22.0k|  }
 2440|       |
 2441|       |  //views only deal with cparams/dparams; storage is always in-memory (ephemeral).
 2442|  5.00k|  blosc2_cparams cparams = *(array->sc->storage->cparams);
 2443|  5.00k|  blosc2_dparams dparams = *(array->sc->storage->dparams);
 2444|  5.00k|  blosc2_storage b2_storage1 = {.cparams=&cparams, .dparams=&dparams};
 2445|       |
 2446|  5.00k|  b2nd_context_t *ctx1 = b2nd_create_ctx(&b2_storage1, nones, newshape,
 2447|  5.00k|                                        newchunkshape, newblockshape, array->dtype,
 2448|  5.00k|                                        array->dtype_format, NULL, 0);
 2449|       |
 2450|  5.00k|  view_new(array, view, ctx1);
 2451|  5.00k|  b2nd_free_ctx(ctx1);
 2452|       |
 2453|  5.00k|  return BLOSC2_ERROR_SUCCESS;
 2454|  5.09k|}
extend_shape:
 2760|  1.40k|int extend_shape(b2nd_array_t *array, const int64_t *new_shape, const int64_t *start) {
 2761|  1.40k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.40k|    do {                                            \
  |  |  105|  1.40k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2762|  1.40k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.40k|    do {                                            \
  |  |  105|  1.40k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2763|       |
 2764|  1.40k|  int8_t ndim = array->ndim;
 2765|  1.40k|  int64_t diffs_shape[B2ND_MAX_DIM];
 2766|  1.40k|  int64_t diffs_sum = 0;
 2767|  7.96k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (2767:19): [True: 6.56k, False: 1.40k]
  ------------------
 2768|  6.56k|    diffs_shape[i] = new_shape[i] - array->shape[i];
 2769|  6.56k|    diffs_sum += diffs_shape[i];
 2770|  6.56k|    if (diffs_shape[i] < 0) {
  ------------------
  |  Branch (2770:9): [True: 0, False: 6.56k]
  ------------------
 2771|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2772|      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]
  |  |  ------------------
  ------------------
 2773|      0|    }
 2774|  6.56k|    if (array->shape[i] == INT64_MAX) {
  ------------------
  |  Branch (2774:9): [True: 0, False: 6.56k]
  ------------------
 2775|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2775|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2776|      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]
  |  |  ------------------
  ------------------
 2777|      0|    }
 2778|  6.56k|  }
 2779|  1.40k|  if (diffs_sum == 0) {
  ------------------
  |  Branch (2779:7): [True: 98, False: 1.30k]
  ------------------
 2780|       |    // Shapes are equal. Do nothing.
 2781|     98|    return BLOSC2_ERROR_SUCCESS;
 2782|     98|  }
 2783|       |
 2784|  1.30k|  int64_t old_nchunks = array->sc->nchunks;
 2785|       |  // aux array to keep old shapes
 2786|  1.30k|  b2nd_array_t *aux = malloc(sizeof(b2nd_array_t));
 2787|  1.30k|  BLOSC_ERROR_NULL(aux, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  1.30k|    do {                                            \
  |  |  105|  1.30k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.30k]
  |  |  ------------------
  |  |  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.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 2788|  1.30k|  aux->sc = NULL;
 2789|  1.30k|  BLOSC_ERROR(update_shape(aux, ndim, array->shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|  1.30k|    do {                                            \
  |  |  112|  1.30k|        int rc_ = (rc);                             \
  |  |  113|  1.30k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.30k]
  |  |  ------------------
  |  |  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.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 2790|       |
 2791|       |  // SWMR ordering for growth: make the data (special chunks) exist first and
 2792|       |  // publish the new shape in the metalayer last, so a concurrent reader never
 2793|       |  // sees a shape that points at chunks that are not there yet.
 2794|  1.30k|  BLOSC_ERROR(update_shape_struct(array, ndim, new_shape, array->chunkshape, array->blockshape));
  ------------------
  |  |  111|  1.30k|    do {                                            \
  |  |  112|  1.30k|        int rc_ = (rc);                             \
  |  |  113|  1.30k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.30k]
  |  |  ------------------
  |  |  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.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 2795|       |
 2796|  1.30k|  int64_t nchunks = array->extnitems / array->chunknitems;
 2797|  1.30k|  int64_t nchunks_;
 2798|  1.30k|  int64_t nchunk_ndim[B2ND_MAX_DIM];
 2799|  1.30k|  blosc2_cparams *cparams;
 2800|  1.30k|  BLOSC_ERROR(blosc2_schunk_get_cparams(array->sc, &cparams));
  ------------------
  |  |  111|  1.30k|    do {                                            \
  |  |  112|  1.30k|        int rc_ = (rc);                             \
  |  |  113|  1.30k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.30k]
  |  |  ------------------
  |  |  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.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 2801|  1.30k|  void *chunk;
 2802|  1.30k|  int64_t csize;
 2803|  1.30k|  if (nchunks != old_nchunks) {
  ------------------
  |  Branch (2803:7): [True: 1.10k, False: 193]
  ------------------
 2804|  1.10k|    if (start == NULL) {
  ------------------
  |  Branch (2804:9): [True: 454, False: 655]
  ------------------
 2805|    454|      start = aux->shape;
 2806|    454|    }
 2807|  1.10k|    int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 2808|  7.16k|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2808:21): [True: 6.05k, False: 1.10k]
  ------------------
 2809|  6.05k|      chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 2810|  6.05k|    }
 2811|   343k|    for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (2811:25): [True: 342k, False: 1.10k]
  ------------------
 2812|   342k|      blosc2_unidim_to_multidim(ndim, chunks_in_array, i, nchunk_ndim);
 2813|  1.11M|      for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (2813:23): [True: 995k, False: 123k]
  ------------------
 2814|   995k|        if (start[j] <= (array->chunkshape[j] * nchunk_ndim[j])
  ------------------
  |  Branch (2814:13): [True: 929k, False: 66.3k]
  ------------------
 2815|   929k|            && (array->chunkshape[j] * nchunk_ndim[j]) < (start[j] + new_shape[j] - aux->shape[j])) {
  ------------------
  |  Branch (2815:16): [True: 218k, False: 710k]
  ------------------
 2816|   218k|          chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
 2817|   218k|          BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   218k|    do {                                            \
  |  |  105|   218k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 218k]
  |  |  ------------------
  |  |  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|   218k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 218k]
  |  |  ------------------
  ------------------
 2818|   218k|          csize = blosc2_chunk_zeros(*cparams, array->sc->chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 2819|   218k|          if (csize < 0) {
  ------------------
  |  Branch (2819:15): [True: 0, False: 218k]
  ------------------
 2820|      0|            free(aux);
 2821|      0|            free(cparams);
 2822|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2823|      0|            return BLOSC2_ERROR_FAILURE;
 2824|      0|          }
 2825|   218k|          nchunks_ = blosc2_schunk_insert_chunk(array->sc, i, chunk, false);
 2826|   218k|          if (nchunks_ < 0) {
  ------------------
  |  Branch (2826:15): [True: 0, False: 218k]
  ------------------
 2827|       |            // A failed insert leaves the chunk to us
 2828|      0|            free(chunk);
 2829|      0|            free(aux);
 2830|      0|            free(cparams);
 2831|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2832|      0|            return BLOSC2_ERROR_FAILURE;
 2833|      0|          }
 2834|   218k|          break;
 2835|   218k|        }
 2836|   995k|      }
 2837|   342k|    }
 2838|  1.10k|  }
 2839|  1.30k|  free(aux);
 2840|  1.30k|  free(cparams);
 2841|       |
 2842|       |  // Data is in place; now publish the grown shape (shape last, see above)
 2843|  1.30k|  BLOSC_ERROR(publish_shape_meta(array));
  ------------------
  |  |  111|  1.30k|    do {                                            \
  |  |  112|  1.30k|        int rc_ = (rc);                             \
  |  |  113|  1.30k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.30k]
  |  |  ------------------
  |  |  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.30k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.30k]
  |  |  ------------------
  ------------------
 2844|       |
 2845|  1.30k|  return BLOSC2_ERROR_SUCCESS;
 2846|  1.30k|}
shrink_shape:
 2849|  1.40k|int shrink_shape(b2nd_array_t *array, const int64_t *new_shape, const int64_t *start) {
 2850|  1.40k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.40k|    do {                                            \
  |  |  105|  1.40k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2851|  1.40k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.40k|    do {                                            \
  |  |  105|  1.40k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2852|       |
 2853|  1.40k|  int8_t ndim = array->ndim;
 2854|  1.40k|  int64_t diffs_shape[B2ND_MAX_DIM];
 2855|  1.40k|  int64_t diffs_sum = 0;
 2856|  7.96k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (2856:19): [True: 6.56k, False: 1.40k]
  ------------------
 2857|  6.56k|    diffs_shape[i] = new_shape[i] - array->shape[i];
 2858|  6.56k|    diffs_sum += diffs_shape[i];
 2859|  6.56k|    if (diffs_shape[i] > 0) {
  ------------------
  |  Branch (2859:9): [True: 0, False: 6.56k]
  ------------------
 2860|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2861|      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]
  |  |  ------------------
  ------------------
 2862|      0|    }
 2863|  6.56k|    if (array->shape[i] == 0) {
  ------------------
  |  Branch (2863:9): [True: 1.66k, False: 4.89k]
  ------------------
 2864|  1.66k|      continue;
 2865|  1.66k|    }
 2866|  6.56k|  }
 2867|  1.40k|  if (diffs_sum == 0) {
  ------------------
  |  Branch (2867:7): [True: 1.40k, False: 0]
  ------------------
 2868|       |    // Shapes are equal. Do nothing.
 2869|  1.40k|    return BLOSC2_ERROR_SUCCESS;
 2870|  1.40k|  }
 2871|       |
 2872|      0|  int64_t old_nchunks = array->sc->nchunks;
 2873|       |  // aux array to keep old shapes
 2874|      0|  b2nd_array_t *aux = malloc(sizeof(b2nd_array_t));
 2875|      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]
  |  |  ------------------
  ------------------
 2876|      0|  aux->sc = NULL;
 2877|      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]
  |  |  ------------------
  ------------------
 2878|       |
 2879|      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]
  |  |  ------------------
  ------------------
 2880|       |
 2881|       |  // Delete chunks if needed
 2882|      0|  int64_t chunks_in_array_old[B2ND_MAX_DIM] = {0};
 2883|      0|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2883:19): [True: 0, False: 0]
  ------------------
 2884|      0|    chunks_in_array_old[i] = aux->extshape[i] / aux->chunkshape[i];
 2885|      0|  }
 2886|      0|  if (start == NULL) {
  ------------------
  |  Branch (2886:7): [True: 0, False: 0]
  ------------------
 2887|      0|    start = new_shape;
 2888|      0|  }
 2889|       |
 2890|      0|  int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 2891|      0|  int64_t nchunks_;
 2892|      0|  for (int i = (int) old_nchunks - 1; i >= 0; --i) {
  ------------------
  |  Branch (2892:39): [True: 0, False: 0]
  ------------------
 2893|      0|    blosc2_unidim_to_multidim(ndim, chunks_in_array_old, i, nchunk_ndim);
 2894|      0|    for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (2894:21): [True: 0, False: 0]
  ------------------
 2895|      0|      if (start[j] <= (array->chunkshape[j] * nchunk_ndim[j])
  ------------------
  |  Branch (2895:11): [True: 0, False: 0]
  ------------------
 2896|      0|          && (array->chunkshape[j] * nchunk_ndim[j]) < (start[j] + aux->shape[j] - new_shape[j])) {
  ------------------
  |  Branch (2896:14): [True: 0, False: 0]
  ------------------
 2897|      0|        nchunks_ = blosc2_schunk_delete_chunk(array->sc, i);
 2898|      0|        if (nchunks_ < 0) {
  ------------------
  |  Branch (2898:13): [True: 0, False: 0]
  ------------------
 2899|      0|          free(aux);
 2900|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2901|      0|          return BLOSC2_ERROR_FAILURE;
 2902|      0|        }
 2903|      0|        break;
 2904|      0|      }
 2905|      0|    }
 2906|      0|  }
 2907|      0|  free(aux);
 2908|       |
 2909|      0|  return BLOSC2_ERROR_SUCCESS;
 2910|      0|}
b2nd_resize:
 2914|  3.23k|                const int64_t *start) {
 2915|  3.23k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.23k|    do {                                            \
  |  |  105|  3.23k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.23k]
  |  |  ------------------
  |  |  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.23k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.23k]
  |  |  ------------------
  ------------------
 2916|  3.23k|  BLOSC_ERROR_NULL(new_shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.23k|    do {                                            \
  |  |  105|  3.23k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.23k]
  |  |  ------------------
  |  |  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.23k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.23k]
  |  |  ------------------
  ------------------
 2917|  3.23k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  3.23k|    do {                                            \
  |  |  112|  3.23k|        int rc_ = (rc);                             \
  |  |  113|  3.23k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 3.23k]
  |  |  ------------------
  |  |  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.23k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 3.23k]
  |  |  ------------------
  ------------------
 2918|       |
 2919|  15.3k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2919:19): [True: 12.1k, False: 3.23k]
  ------------------
 2920|  12.1k|    if (new_shape[i] < 0) {
  ------------------
  |  Branch (2920:9): [True: 0, False: 12.1k]
  ------------------
 2921|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2922|      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]
  |  |  ------------------
  ------------------
 2923|      0|    }
 2924|  12.1k|    if (new_shape[i] != array->shape[i] && (array->chunkshape[i] <= 0 || array->chunknitems <= 0)) {
  ------------------
  |  Branch (2924:9): [True: 7.59k, False: 4.52k]
  |  Branch (2924:45): [True: 0, False: 7.59k]
  |  Branch (2924:74): [True: 0, False: 7.59k]
  ------------------
 2925|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2926|      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]
  |  |  ------------------
  ------------------
 2927|      0|    }
 2928|  12.1k|  }
 2929|       |
 2930|  3.23k|  if (start != NULL) {
  ------------------
  |  Branch (2930:7): [True: 2.60k, False: 627]
  ------------------
 2931|  7.09k|    for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2931:21): [True: 6.32k, False: 773]
  ------------------
 2932|  6.32k|      if (start[i] < 0 || start[i] > array->shape[i]) {
  ------------------
  |  Branch (2932:11): [True: 0, False: 6.32k]
  |  Branch (2932:27): [True: 318, False: 6.00k]
  ------------------
 2933|    318|        BLOSC_TRACE_ERROR("`start` must be in [0, shape] in all dims");
  ------------------
  |  |   93|    318|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    318|    do {                                            \
  |  |  |  |   98|    318|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    318|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 318, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    318|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2934|    318|        BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|    318|    do {                                            \
  |  |  112|    318|        int rc_ = (rc);                             \
  |  |  113|    318|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 318, False: 0]
  |  |  ------------------
  |  |  114|    318|            char *error_msg = print_error(rc_);     \
  |  |  115|    318|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    318|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    318|    do {                                            \
  |  |  |  |  |  |   98|    318|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    318|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 318, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    318|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    318|            return rc_;                             \
  |  |  117|    318|        }                                           \
  |  |  118|    318|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2935|    318|      }
 2936|  6.00k|      if ((new_shape[i] > array->shape[i] && start[i] != array->shape[i])
  ------------------
  |  Branch (2936:12): [True: 4.11k, False: 1.89k]
  |  Branch (2936:46): [True: 2.26k, False: 1.84k]
  ------------------
 2937|  3.73k|          || (new_shape[i] < array->shape[i]
  ------------------
  |  Branch (2937:15): [True: 0, False: 3.73k]
  ------------------
 2938|  2.26k|              && (start[i] + array->shape[i] - new_shape[i]) != array->shape[i])) {
  ------------------
  |  Branch (2938:18): [True: 0, False: 0]
  ------------------
 2939|       |        // Chunks cannot be cut unless they are in the last position
 2940|  2.26k|        if (array->chunkshape[i] <= 0 || start[i] % array->chunkshape[i] != 0) {
  ------------------
  |  Branch (2940:13): [True: 0, False: 2.26k]
  |  Branch (2940:42): [True: 853, False: 1.41k]
  ------------------
 2941|    853|          BLOSC_TRACE_ERROR("If array end is not being modified "
  ------------------
  |  |   93|    853|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    853|    do {                                            \
  |  |  |  |   98|    853|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    853|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 853, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    853|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2942|    853|                              "`start` must be a multiple of chunkshape in all dims");
 2943|    853|          BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|    853|    do {                                            \
  |  |  112|    853|        int rc_ = (rc);                             \
  |  |  113|    853|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 853, False: 0]
  |  |  ------------------
  |  |  114|    853|            char *error_msg = print_error(rc_);     \
  |  |  115|    853|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    853|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    853|    do {                                            \
  |  |  |  |  |  |   98|    853|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    853|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 853, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    853|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    853|            return rc_;                             \
  |  |  117|    853|        }                                           \
  |  |  118|    853|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2944|    853|        }
 2945|  1.41k|        if ((new_shape[i] - array->shape[i]) % array->chunkshape[i] != 0) {
  ------------------
  |  Branch (2945:13): [True: 659, False: 754]
  ------------------
 2946|    659|          BLOSC_TRACE_ERROR("If array end is not being modified "
  ------------------
  |  |   93|    659|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    659|    do {                                            \
  |  |  |  |   98|    659|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    659|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 659, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    659|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2947|    659|                              "`(new_shape - shape)` must be multiple of chunkshape in all dims");
 2948|    659|          BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|    659|    do {                                            \
  |  |  112|    659|        int rc_ = (rc);                             \
  |  |  113|    659|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 659, False: 0]
  |  |  ------------------
  |  |  114|    659|            char *error_msg = print_error(rc_);     \
  |  |  115|    659|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    659|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    659|    do {                                            \
  |  |  |  |  |  |   98|    659|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    659|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 659, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    659|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    659|            return rc_;                             \
  |  |  117|    659|        }                                           \
  |  |  118|    659|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2949|    659|        }
 2950|  1.41k|      }
 2951|  6.00k|    }
 2952|  2.60k|  }
 2953|       |
 2954|       |  // Get shrunk shape
 2955|  1.40k|  int64_t shrunk_shape[B2ND_MAX_DIM] = {0};
 2956|  7.96k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (2956:19): [True: 6.56k, False: 1.40k]
  ------------------
 2957|  6.56k|    if (new_shape[i] <= array->shape[i]) {
  ------------------
  |  Branch (2957:9): [True: 3.58k, False: 2.98k]
  ------------------
 2958|  3.58k|      shrunk_shape[i] = new_shape[i];
 2959|  3.58k|    } else {
 2960|  2.98k|      shrunk_shape[i] = array->shape[i];
 2961|  2.98k|    }
 2962|  6.56k|  }
 2963|       |
 2964|       |  // A resize is a sequence (metalayer update + chunk inserts/deletes); hold
 2965|       |  // the exclusive frame lock across it so locked handles see it atomically.
 2966|       |  // For unlocked handles this is a no-op and the data-first/shape-last
 2967|       |  // ordering in extend_shape/shrink_shape keeps readers safe.  The updated
 2968|       |  // boundary chunks leave holes until the end (see locked_get_set_slice()).
 2969|  1.40k|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 2970|  1.40k|  BLOSC_ERROR(frame_begin_updates(frame));
  ------------------
  |  |  111|  1.40k|    do {                                            \
  |  |  112|  1.40k|        int rc_ = (rc);                             \
  |  |  113|  1.40k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2971|  1.40k|  int rc = shrink_shape(array, shrunk_shape, start);
 2972|  1.40k|  if (rc >= 0) {
  ------------------
  |  Branch (2972:7): [True: 1.40k, False: 0]
  ------------------
 2973|  1.40k|    rc = extend_shape(array, new_shape, start);
 2974|  1.40k|  }
 2975|  1.40k|  int end_rc = frame_end_updates(frame, array->sc);
 2976|  1.40k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  1.40k|    do {                                            \
  |  |  112|  1.40k|        int rc_ = (rc);                             \
  |  |  113|  1.40k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2977|  1.40k|  BLOSC_ERROR(end_rc);
  ------------------
  |  |  111|  1.40k|    do {                                            \
  |  |  112|  1.40k|        int rc_ = (rc);                             \
  |  |  113|  1.40k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.40k]
  |  |  ------------------
  |  |  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.40k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 2978|       |
 2979|  1.40k|  return BLOSC2_ERROR_SUCCESS;
 2980|  1.40k|}
b2nd_insert:
 2984|  3.70k|                int8_t axis, int64_t insert_start) {
 2985|       |
 2986|  3.70k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.70k|    do {                                            \
  |  |  105|  3.70k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.70k]
  |  |  ------------------
  |  |  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.70k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.70k]
  |  |  ------------------
  ------------------
 2987|  3.70k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  3.70k|    do {                                            \
  |  |  105|  3.70k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.70k]
  |  |  ------------------
  |  |  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.70k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.70k]
  |  |  ------------------
  ------------------
 2988|  3.70k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  3.70k|    do {                                            \
  |  |  112|  3.70k|        int rc_ = (rc);                             \
  |  |  113|  3.70k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 3.70k]
  |  |  ------------------
  |  |  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.70k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 3.70k]
  |  |  ------------------
  ------------------
 2989|       |
 2990|  3.70k|  if (axis < 0 || axis >= array->ndim) {
  ------------------
  |  Branch (2990:7): [True: 0, False: 3.70k]
  |  Branch (2990:19): [True: 0, False: 3.70k]
  ------------------
 2991|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2992|      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]
  |  |  ------------------
  ------------------
 2993|      0|  }
 2994|  3.70k|  if (insert_start < 0 || insert_start > array->shape[axis] || buffersize < 0) {
  ------------------
  |  Branch (2994:7): [True: 0, False: 3.70k]
  |  Branch (2994:27): [True: 0, False: 3.70k]
  |  Branch (2994:64): [True: 0, False: 3.70k]
  ------------------
 2995|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2996|      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]
  |  |  ------------------
  ------------------
 2997|      0|  }
 2998|       |
 2999|  3.70k|  int64_t axis_size = array->sc->typesize;
 3000|  3.70k|  int64_t buffershape[B2ND_MAX_DIM];
 3001|  15.7k|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (3001:19): [True: 12.0k, False: 3.70k]
  ------------------
 3002|  12.0k|    if (i != axis) {
  ------------------
  |  Branch (3002:9): [True: 8.36k, False: 3.70k]
  ------------------
 3003|  8.36k|      axis_size *= array->shape[i];
 3004|  8.36k|      buffershape[i] = array->shape[i];
 3005|  8.36k|    }
 3006|  12.0k|  }
 3007|  3.70k|  if (axis_size <= 0 || buffersize % axis_size != 0) {
  ------------------
  |  Branch (3007:7): [True: 225, False: 3.47k]
  |  Branch (3007:25): [True: 2.31k, False: 1.16k]
  ------------------
 3008|  2.54k|    BLOSC_TRACE_ERROR("`buffersize` must be multiple of the array cross-section");
  ------------------
  |  |   93|  2.54k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  2.54k|    do {                                            \
  |  |  |  |   98|  2.54k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  2.54k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 2.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  2.54k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3009|  2.54k|    BLOSC_ERROR(BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  111|  2.54k|    do {                                            \
  |  |  112|  2.54k|        int rc_ = (rc);                             \
  |  |  113|  2.54k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 2.54k, False: 0]
  |  |  ------------------
  |  |  114|  2.54k|            char *error_msg = print_error(rc_);     \
  |  |  115|  2.54k|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|  2.54k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|  2.54k|    do {                                            \
  |  |  |  |  |  |   98|  2.54k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|  2.54k|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 2.54k, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|  2.54k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|  2.54k|            return rc_;                             \
  |  |  117|  2.54k|        }                                           \
  |  |  118|  2.54k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3010|  2.54k|  }
 3011|  1.16k|  int64_t newshape[B2ND_MAX_DIM];
 3012|  1.16k|  memcpy(newshape, array->shape, array->ndim * sizeof(int64_t));
 3013|  1.16k|  newshape[axis] += buffersize / axis_size;
 3014|  1.16k|  buffershape[axis] = newshape[axis] - array->shape[axis];
 3015|  1.16k|  int64_t start[B2ND_MAX_DIM] = {0};
 3016|  1.16k|  start[axis] = insert_start;
 3017|       |
 3018|  1.16k|  if (insert_start == array->shape[axis]) {
  ------------------
  |  Branch (3018:7): [True: 563, False: 601]
  ------------------
 3019|    563|    BLOSC_ERROR(b2nd_resize(array, newshape, NULL));
  ------------------
  |  |  111|    563|    do {                                            \
  |  |  112|    563|        int rc_ = (rc);                             \
  |  |  113|    563|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 563]
  |  |  ------------------
  |  |  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|    563|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 563]
  |  |  ------------------
  ------------------
 3020|    601|  } else {
 3021|    601|    BLOSC_ERROR(b2nd_resize(array, newshape, start));
  ------------------
  |  |  111|    601|    do {                                            \
  |  |  112|    601|        int rc_ = (rc);                             \
  |  |  113|    601|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 247, False: 354]
  |  |  ------------------
  |  |  114|    247|            char *error_msg = print_error(rc_);     \
  |  |  115|    247|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    247|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    247|    do {                                            \
  |  |  |  |  |  |   98|    247|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    247|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 247, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    247|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    247|            return rc_;                             \
  |  |  117|    247|        }                                           \
  |  |  118|    601|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 354]
  |  |  ------------------
  ------------------
 3022|    601|  }
 3023|       |
 3024|    917|  int64_t stop[B2ND_MAX_DIM];
 3025|    917|  memcpy(stop, array->shape, sizeof(int64_t) * array->ndim);
 3026|    917|  stop[axis] = start[axis] + buffershape[axis];
 3027|    917|  BLOSC_ERROR(b2nd_set_slice_cbuffer(buffer, buffershape, buffersize, start, stop, array));
  ------------------
  |  |  111|    917|    do {                                            \
  |  |  112|    917|        int rc_ = (rc);                             \
  |  |  113|    917|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 917]
  |  |  ------------------
  |  |  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|    917|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 917]
  |  |  ------------------
  ------------------
 3028|       |
 3029|    917|  return BLOSC2_ERROR_SUCCESS;
 3030|    917|}
b2nd_append:
 3034|  1.88k|                int8_t axis) {
 3035|  1.88k|  BLOSC_ERROR_NULL(array, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.88k|    do {                                            \
  |  |  105|  1.88k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.88k]
  |  |  ------------------
  |  |  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.88k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.88k]
  |  |  ------------------
  ------------------
 3036|  1.88k|  BLOSC_ERROR_NULL(buffer, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  1.88k|    do {                                            \
  |  |  105|  1.88k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.88k]
  |  |  ------------------
  |  |  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.88k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.88k]
  |  |  ------------------
  ------------------
 3037|  1.88k|  BLOSC_ERROR(refresh_if_stale(array));
  ------------------
  |  |  111|  1.88k|    do {                                            \
  |  |  112|  1.88k|        int rc_ = (rc);                             \
  |  |  113|  1.88k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.88k]
  |  |  ------------------
  |  |  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.88k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.88k]
  |  |  ------------------
  ------------------
 3038|       |
 3039|  1.88k|  if (axis < 0 || axis >= array->ndim || buffersize < 0) {
  ------------------
  |  Branch (3039:7): [True: 0, False: 1.88k]
  |  Branch (3039:19): [True: 0, False: 1.88k]
  |  Branch (3039:42): [True: 0, False: 1.88k]
  ------------------
 3040|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3041|      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]
  |  |  ------------------
  ------------------
 3042|      0|  }
 3043|       |
 3044|  1.88k|  int32_t chunksize = array->sc->chunksize;
 3045|  1.88k|  if (chunksize <= 0) {
  ------------------
  |  Branch (3045:7): [True: 0, False: 1.88k]
  ------------------
 3046|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3047|      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]
  |  |  ------------------
  ------------------
 3048|      0|  }
 3049|  1.88k|  int64_t nchunks_append = buffersize / chunksize;
 3050|       |  // Check whether chunkshape and blockshape are compatible with accelerated path.
 3051|       |  // Essentially, we are checking whether the buffer is a multiple of the chunksize
 3052|       |  // and that the chunkshape and blockshape are the same, except for the first axis.
 3053|       |  // Also, axis needs to be the first one.
 3054|  1.88k|  bool compat_chunks_blocks = true;
 3055|  3.56k|  for (int i = 1; i < array->ndim; ++i) {
  ------------------
  |  Branch (3055:19): [True: 2.90k, False: 655]
  ------------------
 3056|  2.90k|    if (array->chunkshape[i] != array->blockshape[i]) {
  ------------------
  |  Branch (3056:9): [True: 1.22k, False: 1.67k]
  ------------------
 3057|  1.22k|      compat_chunks_blocks = false;
 3058|  1.22k|      break;
 3059|  1.22k|    }
 3060|  2.90k|  }
 3061|  1.88k|  if (axis > 0) {
  ------------------
  |  Branch (3061:7): [True: 0, False: 1.88k]
  ------------------
 3062|      0|    compat_chunks_blocks = false;
 3063|      0|  }
 3064|       |  // General case where a buffer has a different size than the chunksize
 3065|  1.88k|  if (!compat_chunks_blocks || buffersize % chunksize != 0 || nchunks_append != 1) {
  ------------------
  |  Branch (3065:7): [True: 1.22k, False: 655]
  |  Branch (3065:32): [True: 470, False: 185]
  |  Branch (3065:63): [True: 121, False: 64]
  ------------------
 3066|  1.82k|    BLOSC_ERROR(b2nd_insert(array, buffer, buffersize, axis, array->shape[axis]));
  ------------------
  |  |  111|  1.82k|    do {                                            \
  |  |  112|  1.82k|        int rc_ = (rc);                             \
  |  |  113|  1.82k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 1.25k, False: 563]
  |  |  ------------------
  |  |  114|  1.25k|            char *error_msg = print_error(rc_);     \
  |  |  115|  1.25k|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|  1.25k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|  1.25k|    do {                                            \
  |  |  |  |  |  |   98|  1.25k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|  1.25k|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 1.25k, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|  1.25k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|  1.25k|            return rc_;                             \
  |  |  117|  1.25k|        }                                           \
  |  |  118|  1.82k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 563]
  |  |  ------------------
  ------------------
 3067|    563|    return BLOSC2_ERROR_SUCCESS;
 3068|  1.82k|  }
 3069|       |
 3070|       |  // Accelerated path for buffers that are of the same size as the chunksize
 3071|       |  // printf("accelerated path\n");
 3072|       |
 3073|       |  // Append the buffer to the underlying schunk. This is very fast, as
 3074|       |  // it doesn't need to do internal partitioning.
 3075|     64|  BLOSC_ERROR(blosc2_schunk_append_buffer(array->sc, (void*)buffer, buffersize));
  ------------------
  |  |  111|     64|    do {                                            \
  |  |  112|     64|        int rc_ = (rc);                             \
  |  |  113|     64|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 64]
  |  |  ------------------
  |  |  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|     64|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 64]
  |  |  ------------------
  ------------------
 3076|       |
 3077|       |  // Finally, resize the array
 3078|     64|  int64_t newshape[B2ND_MAX_DIM];
 3079|     64|  memcpy(newshape, array->shape, array->ndim * sizeof(int64_t));
 3080|     64|  newshape[axis] += nchunks_append * array->chunkshape[axis];
 3081|     64|  BLOSC_ERROR(b2nd_resize(array, newshape, NULL));
  ------------------
  |  |  111|     64|    do {                                            \
  |  |  112|     64|        int rc_ = (rc);                             \
  |  |  113|     64|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 64]
  |  |  ------------------
  |  |  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|     64|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 64]
  |  |  ------------------
  ------------------
 3082|       |
 3083|     64|  return BLOSC2_ERROR_SUCCESS;
 3084|     64|}
b2nd_create_ctx:
 3695|  9.94k|                int32_t nmetalayers) {
 3696|  9.94k|  if (ndim < 0 || ndim > B2ND_MAX_DIM) {
  ------------------
  |  |   50|  9.94k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (3696:7): [True: 0, False: 9.94k]
  |  Branch (3696:19): [True: 0, False: 9.94k]
  ------------------
 3697|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 3697|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3698|      0|    return NULL;
 3699|      0|  }
 3700|       |
 3701|  9.94k|  if (ndim > 0) {
  ------------------
  |  Branch (3701:7): [True: 9.91k, False: 32]
  ------------------
 3702|  9.91k|    if (shape == NULL || chunkshape == NULL || blockshape == NULL) {
  ------------------
  |  Branch (3702:9): [True: 0, False: 9.91k]
  |  Branch (3702:26): [True: 0, False: 9.91k]
  |  Branch (3702:48): [True: 0, False: 9.91k]
  ------------------
 3703|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3704|      0|      return NULL;
 3705|      0|    }
 3706|  9.91k|    if (validate_shape_chunkshape_blockshape(ndim, shape, chunkshape, blockshape) < 0) {
  ------------------
  |  Branch (3706:9): [True: 0, False: 9.91k]
  ------------------
 3707|      0|      return NULL;
 3708|      0|    }
 3709|  9.91k|  }
 3710|       |
 3711|  9.94k|  b2nd_context_t *ctx = malloc(sizeof(b2nd_context_t));
 3712|  9.94k|  BLOSC_ERROR_NULL(ctx, NULL);
  ------------------
  |  |  104|  9.94k|    do {                                            \
  |  |  105|  9.94k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 9.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|  9.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.94k]
  |  |  ------------------
  ------------------
 3713|  9.94k|  blosc2_storage *params_b2_storage = malloc(sizeof(blosc2_storage));
 3714|  9.94k|  BLOSC_ERROR_NULL(params_b2_storage, NULL);
  ------------------
  |  |  104|  9.94k|    do {                                            \
  |  |  105|  9.94k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 9.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|  9.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.94k]
  |  |  ------------------
  ------------------
 3715|  9.94k|  if (b2_storage == NULL) {
  ------------------
  |  Branch (3715:7): [True: 0, False: 9.94k]
  ------------------
 3716|      0|    memcpy(params_b2_storage, &BLOSC2_STORAGE_DEFAULTS, sizeof(blosc2_storage));
 3717|      0|  }
 3718|  9.94k|  else {
 3719|  9.94k|    memcpy(params_b2_storage, b2_storage, sizeof(blosc2_storage));
 3720|  9.94k|  }
 3721|  9.94k|  blosc2_cparams *cparams = malloc(sizeof(blosc2_cparams));
 3722|  9.94k|  BLOSC_ERROR_NULL(cparams, NULL);
  ------------------
  |  |  104|  9.94k|    do {                                            \
  |  |  105|  9.94k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 9.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|  9.94k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 9.94k]
  |  |  ------------------
  ------------------
 3723|       |  // We need a copy of cparams mainly to be able to modify blocksize
 3724|  9.94k|  if (params_b2_storage->cparams == NULL) {
  ------------------
  |  Branch (3724:7): [True: 0, False: 9.94k]
  ------------------
 3725|      0|    memcpy(cparams, &BLOSC2_CPARAMS_DEFAULTS, sizeof(blosc2_cparams));
 3726|      0|  }
 3727|  9.94k|  else {
 3728|  9.94k|    memcpy(cparams, params_b2_storage->cparams, sizeof(blosc2_cparams));
 3729|  9.94k|  }
 3730|       |
 3731|  9.94k|  if (dtype == NULL) {
  ------------------
  |  Branch (3731:7): [True: 2.56k, False: 7.37k]
  ------------------
 3732|       |    // ctx->dtype = strdup(B2ND_DEFAULT_DTYPE);
 3733|  2.56k|    char buf[16] = {0};
 3734|  2.56k|    snprintf(buf, sizeof(buf), "|S%d", cparams->typesize);
 3735|  2.56k|    ctx->dtype = strdup(buf);
 3736|  2.56k|  }
 3737|  7.37k|  else {
 3738|  7.37k|    ctx->dtype = strdup(dtype);
 3739|  7.37k|  }
 3740|  9.94k|  ctx->dtype_format = dtype_format;
 3741|       |
 3742|  9.94k|  params_b2_storage->cparams = cparams;
 3743|  9.94k|  ctx->b2_storage = params_b2_storage;
 3744|  9.94k|  ctx->ndim = ndim;
 3745|  9.94k|  int32_t blocknitems = 1;
 3746|  9.94k|  bool blocksize_overflow = false;
 3747|  48.7k|  for (int i = 0; i < ndim; i++) {
  ------------------
  |  Branch (3747:19): [True: 38.7k, False: 9.94k]
  ------------------
 3748|  38.7k|    ctx->shape[i] = shape[i];
 3749|  38.7k|    ctx->chunkshape[i] = chunkshape[i];
 3750|  38.7k|    ctx->blockshape[i] = blockshape[i];
 3751|  38.7k|    if (!blosc2_checked_mul_i32_nonneg(blocknitems, ctx->blockshape[i], &blocknitems)) {
  ------------------
  |  Branch (3751:9): [True: 0, False: 38.7k]
  ------------------
 3752|      0|      blocksize_overflow = true;
 3753|      0|      break;
 3754|      0|    }
 3755|  38.7k|  }
 3756|       |  // update_shape_struct() rejects this too, but only once an array is built out
 3757|       |  // of the context; catching it here keeps cparams->blocksize from wrapping
 3758|  9.94k|  if (blocksize_overflow ||
  ------------------
  |  Branch (3758:7): [True: 0, False: 9.94k]
  ------------------
 3759|  9.94k|      !blosc2_checked_mul_i32_nonneg(blocknitems, cparams->typesize, &cparams->blocksize)) {
  ------------------
  |  Branch (3759:7): [True: 0, False: 9.94k]
  ------------------
 3760|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3761|      0|    free(ctx->dtype);
 3762|      0|    free(cparams);
 3763|      0|    free(params_b2_storage);
 3764|      0|    free(ctx);
 3765|      0|    return NULL;
 3766|      0|  }
 3767|       |
 3768|  9.94k|  ctx->nmetalayers = nmetalayers;
 3769|  9.94k|  for (int i = 0; i < nmetalayers; ++i) {
  ------------------
  |  Branch (3769:19): [True: 0, False: 9.94k]
  ------------------
 3770|      0|    ctx->metalayers[i] = metalayers[i];
 3771|      0|  }
 3772|       |
 3773|       |#if defined(HAVE_ZFP)
 3774|       |  #include "blosc2/codecs-registry.h"
 3775|       |  if ((ctx->b2_storage->cparams->compcode >= BLOSC_CODEC_ZFP_FIXED_ACCURACY) &&
 3776|       |      (ctx->b2_storage->cparams->compcode <= BLOSC_CODEC_ZFP_FIXED_RATE)) {
 3777|       |    for (int i = 0; i < BLOSC2_MAX_FILTERS; ++i) {
 3778|       |      if ((ctx->b2_storage->cparams->filters[i] == BLOSC_SHUFFLE) ||
 3779|       |          (ctx->b2_storage->cparams->filters[i] == BLOSC_BITSHUFFLE)) {
 3780|       |        BLOSC_TRACE_ERROR("ZFP cannot be run in presence of SHUFFLE / BITSHUFFLE");
 3781|       |        return NULL;
 3782|       |      }
 3783|       |    }
 3784|       |  }
 3785|       |#endif /* HAVE_ZFP */
 3786|       |
 3787|  9.94k|  return ctx;
 3788|  9.94k|}
b2nd_free_ctx:
 3791|  9.94k|int b2nd_free_ctx(b2nd_context_t *ctx) {
 3792|  9.94k|  ctx->b2_storage->cparams->schunk = NULL;
 3793|  9.94k|  free(ctx->b2_storage->cparams);
 3794|  9.94k|  free(ctx->b2_storage);
 3795|  9.94k|  free(ctx->dtype);
 3796|  9.94k|  free(ctx);
 3797|       |
 3798|  9.94k|  return BLOSC2_ERROR_SUCCESS;
 3799|  9.94k|}
b2nd.c:update_shape_struct:
  155|  22.6k|                               const int32_t *chunkshape, const int32_t *blockshape) {
  156|  22.6k|  BLOSC_ERROR(validate_shape_chunkshape_blockshape(ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  22.6k|    do {                                            \
  |  |  112|  22.6k|        int rc_ = (rc);                             \
  |  |  113|  22.6k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 22.6k]
  |  |  ------------------
  |  |  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|  22.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 22.6k]
  |  |  ------------------
  ------------------
  157|       |
  158|  22.6k|  array->ndim = ndim;
  159|  22.6k|  array->nitems = 1;
  160|  22.6k|  array->extnitems = 1;
  161|  22.6k|  array->extchunknitems = 1;
  162|  22.6k|  array->chunknitems = 1;
  163|  22.6k|  array->blocknitems = 1;
  164|   385k|  for (int i = 0; i < B2ND_MAX_DIM; ++i) {
  ------------------
  |  |   50|   385k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (164:19): [True: 362k, False: 22.6k]
  ------------------
  165|   362k|    if (i < ndim) {
  ------------------
  |  Branch (165:9): [True: 96.3k, False: 266k]
  ------------------
  166|  96.3k|      array->shape[i] = shape[i];
  167|  96.3k|      array->chunkshape[i] = chunkshape[i];
  168|  96.3k|      array->blockshape[i] = blockshape[i];
  169|  96.3k|      if (array->chunkshape[i] != 0) {
  ------------------
  |  Branch (169:11): [True: 96.3k, False: 0]
  ------------------
  170|  96.3k|        if (shape[i] % array->chunkshape[i] == 0) {
  ------------------
  |  Branch (170:13): [True: 59.7k, False: 36.6k]
  ------------------
  171|  59.7k|          array->extshape[i] = shape[i];
  172|  59.7k|        } else {
  173|       |          // Rounding shape up to the next chunk must not wrap int64
  174|  36.6k|          if (shape[i] > INT64_MAX - chunkshape[i]) {
  ------------------
  |  Branch (174:15): [True: 0, False: 36.6k]
  ------------------
  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|  36.6k|          array->extshape[i] = shape[i] + chunkshape[i] - shape[i] % chunkshape[i];
  179|  36.6k|        }
  180|  96.3k|        if (chunkshape[i] % blockshape[i] == 0) {
  ------------------
  |  Branch (180:13): [True: 65.9k, False: 30.4k]
  ------------------
  181|  65.9k|          array->extchunkshape[i] = chunkshape[i];
  182|  65.9k|        } else {
  183|       |          // Done in 64 bits: the sum of two int32 values does not fit in int32,
  184|       |          // and extchunkshape is int64 anyway
  185|  30.4k|          array->extchunkshape[i] =
  186|  30.4k|                  (int64_t) chunkshape[i] + blockshape[i] - chunkshape[i] % blockshape[i];
  187|  30.4k|        }
  188|  96.3k|      } else {
  189|      0|        array->extchunkshape[i] = chunkshape[i];
  190|      0|        array->extshape[i] = 0;
  191|      0|      }
  192|   266k|    } else {
  193|   266k|      array->blockshape[i] = 1;
  194|   266k|      array->chunkshape[i] = 1;
  195|   266k|      array->extshape[i] = 1;
  196|   266k|      array->extchunkshape[i] = 1;
  197|   266k|      array->shape[i] = 1;
  198|   266k|    }
  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|   362k|    if (!blosc2_checked_mul_i64_nonneg(array->nitems, array->shape[i], &array->nitems) ||
  ------------------
  |  Branch (201:9): [True: 0, False: 362k]
  ------------------
  202|   362k|        !blosc2_checked_mul_i64_nonneg(array->extnitems, array->extshape[i], &array->extnitems) ||
  ------------------
  |  Branch (202:9): [True: 0, False: 362k]
  ------------------
  203|   362k|        !blosc2_checked_mul_i64_nonneg(array->extchunknitems, array->extchunkshape[i],
  ------------------
  |  Branch (203:9): [True: 0, False: 362k]
  ------------------
  204|   362k|                                       &array->extchunknitems) ||
  205|   362k|        !blosc2_checked_mul_i32_nonneg(array->chunknitems, array->chunkshape[i], &array->chunknitems) ||
  ------------------
  |  Branch (205:9): [True: 0, False: 362k]
  ------------------
  206|   362k|        !blosc2_checked_mul_i32_nonneg(array->blocknitems, array->blockshape[i], &array->blocknitems)) {
  ------------------
  |  Branch (206:9): [True: 0, False: 362k]
  ------------------
  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|   362k|  }
  211|       |
  212|       |  // Compute strides
  213|  22.6k|  if (ndim > 0) {
  ------------------
  |  Branch (213:7): [True: 22.6k, False: 32]
  ------------------
  214|  22.6k|    array->item_array_strides[ndim - 1] = 1;
  215|  22.6k|    array->item_extchunk_strides[ndim - 1] = 1;
  216|  22.6k|    array->item_chunk_strides[ndim - 1] = 1;
  217|  22.6k|    array->item_block_strides[ndim - 1] = 1;
  218|  22.6k|    array->block_chunk_strides[ndim - 1] = 1;
  219|  22.6k|    array->chunk_array_strides[ndim - 1] = 1;
  220|  22.6k|  }
  221|  96.4k|  for (int i = ndim - 2; i >= 0; --i) {
  ------------------
  |  Branch (221:26): [True: 73.7k, False: 22.6k]
  ------------------
  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|  73.7k|    if (shape[i + 1] != 0 && array->chunkshape[i + 1] != 0 &&
  ------------------
  |  Branch (232:9): [True: 53.2k, False: 20.4k]
  |  Branch (232:30): [True: 53.2k, False: 0]
  ------------------
  233|  53.2k|        array->blockshape[i + 1] != 0) {
  ------------------
  |  Branch (233:9): [True: 53.2k, False: 0]
  ------------------
  234|  53.2k|      if (!blosc2_checked_mul_i64_nonneg(array->item_array_strides[i + 1], array->shape[i + 1],
  ------------------
  |  Branch (234:11): [True: 0, False: 53.2k]
  ------------------
  235|  53.2k|                                         &array->item_array_strides[i]) ||
  236|  53.2k|          !blosc2_checked_mul_i64_nonneg(array->item_extchunk_strides[i + 1], array->extchunkshape[i + 1],
  ------------------
  |  Branch (236:11): [True: 0, False: 53.2k]
  ------------------
  237|  53.2k|                                         &array->item_extchunk_strides[i]) ||
  238|  53.2k|          !blosc2_checked_mul_i64_nonneg(array->item_chunk_strides[i + 1], array->chunkshape[i + 1],
  ------------------
  |  Branch (238:11): [True: 0, False: 53.2k]
  ------------------
  239|  53.2k|                                         &array->item_chunk_strides[i]) ||
  240|  53.2k|          !blosc2_checked_mul_i64_nonneg(array->item_block_strides[i + 1], array->blockshape[i + 1],
  ------------------
  |  Branch (240:11): [True: 0, False: 53.2k]
  ------------------
  241|  53.2k|                                         &array->item_block_strides[i]) ||
  242|  53.2k|          !blosc2_checked_mul_i64_nonneg(array->block_chunk_strides[i + 1],
  ------------------
  |  Branch (242:11): [True: 0, False: 53.2k]
  ------------------
  243|  53.2k|                                         array->extchunkshape[i + 1] / array->blockshape[i + 1],
  244|  53.2k|                                         &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|  53.2k|      int64_t extent;
  251|  53.2k|      if (!blosc2_checked_mul_i64_nonneg(array->extshape[i + 1], array->chunkshape[i + 1], &extent) ||
  ------------------
  |  Branch (251:11): [True: 0, False: 53.2k]
  ------------------
  252|  53.2k|          !blosc2_checked_mul_i64_nonneg(array->chunk_array_strides[i + 1], extent,
  ------------------
  |  Branch (252:11): [True: 0, False: 53.2k]
  ------------------
  253|  53.2k|                                         &array->chunk_array_strides[i])) {
  254|      0|        array->chunk_array_strides[i] = 0;
  255|      0|      }
  256|  53.2k|    } else {
  257|  20.4k|      array->item_array_strides[i] = 0;
  258|  20.4k|      array->item_extchunk_strides[i] = 0;
  259|  20.4k|      array->item_chunk_strides[i] = 0;
  260|  20.4k|      array->item_block_strides[i] = 0;
  261|  20.4k|      array->block_chunk_strides[i] = 0;
  262|  20.4k|      array->chunk_array_strides[i] = 0;
  263|  20.4k|    }
  264|  73.7k|  }
  265|  22.6k|  return BLOSC2_ERROR_SUCCESS;
  266|  22.6k|}
b2nd.c:publish_shape_meta:
  270|  17.6k|static int publish_shape_meta(b2nd_array_t *array) {
  271|  17.6k|  if (!array->sc) {
  ------------------
  |  Branch (271:7): [True: 16.3k, False: 1.30k]
  ------------------
  272|  16.3k|    return BLOSC2_ERROR_SUCCESS;
  273|  16.3k|  }
  274|  1.30k|  uint8_t *smeta = NULL;
  275|       |  // Serialize the dimension info ...
  276|  1.30k|  int32_t smeta_len =
  277|  1.30k|          b2nd_serialize_meta(array->ndim, array->shape, array->chunkshape, array->blockshape,
  278|  1.30k|                              array->dtype, array->dtype_format, &smeta);
  279|  1.30k|  if (smeta_len < 0) {
  ------------------
  |  Branch (279:7): [True: 0, False: 1.30k]
  ------------------
  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.30k|  if (blosc2_meta_exists(array->sc, "b2nd") < 0) {
  ------------------
  |  Branch (284:7): [True: 0, False: 1.30k]
  ------------------
  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.30k|  } else {
  289|  1.30k|    if (blosc2_meta_update(array->sc, "b2nd", smeta, smeta_len) < 0) {
  ------------------
  |  Branch (289:9): [True: 0, False: 1.30k]
  ------------------
  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.30k|  }
  293|  1.30k|  free(smeta);
  294|       |  // The meta mutation bumped the schunk change tick; this struct is in sync
  295|  1.30k|  array->last_tick = array->sc->change_tick;
  296|       |
  297|  1.30k|  return BLOSC2_ERROR_SUCCESS;
  298|  1.30k|}
b2nd.c:refresh_if_stale:
  313|  1.09M|static int refresh_if_stale(b2nd_array_t *array) {
  314|  1.09M|  blosc2_schunk *sc = array->sc;
  315|  1.09M|  if (sc == NULL || sc->frame == NULL) {
  ------------------
  |  Branch (315:7): [True: 0, False: 1.09M]
  |  Branch (315:21): [True: 0, False: 1.09M]
  ------------------
  316|      0|    return BLOSC2_ERROR_SUCCESS;
  317|      0|  }
  318|  1.09M|  BLOSC_ERROR(frame_check_stale((blosc2_frame_s *) sc->frame));
  ------------------
  |  |  111|  1.09M|    do {                                            \
  |  |  112|  1.09M|        int rc_ = (rc);                             \
  |  |  113|  1.09M|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.09M]
  |  |  ------------------
  |  |  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.09M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.09M]
  |  |  ------------------
  ------------------
  319|  1.09M|  if (array->last_tick == sc->change_tick) {
  ------------------
  |  Branch (319:7): [True: 1.09M, False: 5.01k]
  ------------------
  320|  1.09M|    return BLOSC2_ERROR_SUCCESS;
  321|  1.09M|  }
  322|       |
  323|  5.01k|  uint8_t *smeta;
  324|  5.01k|  int32_t smeta_len;
  325|  5.01k|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (325:7): [True: 0, False: 5.01k]
  ------------------
  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|  5.01k|  int8_t ndim;
  345|  5.01k|  int64_t shape[B2ND_MAX_DIM];
  346|  5.01k|  int32_t chunkshape[B2ND_MAX_DIM];
  347|  5.01k|  int32_t blockshape[B2ND_MAX_DIM];
  348|  5.01k|  char *dtype;
  349|  5.01k|  int8_t dtype_format;
  350|  5.01k|  int rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape,
  351|  5.01k|                                 &dtype, &dtype_format);
  352|  5.01k|  free(smeta);
  353|  5.01k|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  5.01k|    do {                                            \
  |  |  112|  5.01k|        int rc_ = (rc);                             \
  |  |  113|  5.01k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 5.01k]
  |  |  ------------------
  |  |  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|  5.01k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 5.01k]
  |  |  ------------------
  ------------------
  354|  5.01k|  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|  5.01k|  if (ndim != array->ndim ||
  ------------------
  |  Branch (359:7): [True: 0, False: 5.01k]
  ------------------
  360|  5.01k|      memcmp(chunkshape, array->chunkshape, ndim * sizeof(int32_t)) != 0 ||
  ------------------
  |  Branch (360:7): [True: 0, False: 5.01k]
  ------------------
  361|  5.01k|      memcmp(blockshape, array->blockshape, ndim * sizeof(int32_t)) != 0) {
  ------------------
  |  Branch (361:7): [True: 0, False: 5.01k]
  ------------------
  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|  5.01k|  BLOSC_ERROR(update_shape_struct(array, ndim, shape, chunkshape, blockshape));
  ------------------
  |  |  111|  5.01k|    do {                                            \
  |  |  112|  5.01k|        int rc_ = (rc);                             \
  |  |  113|  5.01k|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 5.01k]
  |  |  ------------------
  |  |  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|  5.01k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 5.01k]
  |  |  ------------------
  ------------------
  368|  5.01k|  array->last_tick = sc->change_tick;
  369|       |
  370|  5.01k|  return 1;
  371|  5.01k|}
b2nd.c:check_schunk_matches_meta:
  620|  2.54k|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|  2.54k|  int64_t needed_nchunks = array->chunknitems == 0 ? 0 : array->extnitems / array->chunknitems;
  ------------------
  |  Branch (623:28): [True: 0, False: 2.54k]
  ------------------
  624|  2.54k|  if (schunk->nchunks < needed_nchunks) {
  ------------------
  |  Branch (624:7): [True: 0, False: 2.54k]
  ------------------
  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|  2.54k|  int64_t chunkbytes;
  632|  2.54k|  if (schunk->nchunks > 0 && schunk->chunksize > 0 &&
  ------------------
  |  Branch (632:7): [True: 2.27k, False: 267]
  |  Branch (632:30): [True: 2.27k, False: 0]
  ------------------
  633|  2.27k|      (!blosc2_checked_mul_i64_nonneg(array->extchunknitems, schunk->typesize, &chunkbytes) ||
  ------------------
  |  Branch (633:8): [True: 0, False: 2.27k]
  ------------------
  634|  2.27k|       chunkbytes != schunk->chunksize)) {
  ------------------
  |  Branch (634:8): [True: 0, False: 2.27k]
  ------------------
  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|  2.54k|  return BLOSC2_ERROR_SUCCESS;
  640|  2.54k|}
b2nd.c:buffer_wants_prefault:
 1206|  10.6k|static bool buffer_wants_prefault(const uint8_t *buffer, int64_t nbytes, int nthreads) {
 1207|  10.6k|#if defined(__linux__)
 1208|       |  // A huge page is 2 MB with 4 KB pages; other page sizes are not probed
 1209|  10.6k|  enum { huge_page = 2 << 20, small_page = 4096, npages = huge_page / small_page };
 1210|  10.6k|  if (nthreads < 2 || nbytes < 2 * huge_page || sysconf(_SC_PAGESIZE) != small_page) {
  ------------------
  |  Branch (1210:7): [True: 10.6k, False: 0]
  |  Branch (1210:23): [True: 0, False: 0]
  |  Branch (1210:49): [True: 0, False: 0]
  ------------------
 1211|  10.6k|    return false;
 1212|  10.6k|  }
 1213|       |  // The aligned huge page around the middle lies inside a buffer of 4 MB or more,
 1214|       |  // away from its first page, where malloc writes its chunk header
 1215|      0|  uint8_t *block = (uint8_t *) (((uintptr_t) buffer + (uintptr_t) (nbytes / 2)) & ~(uintptr_t) (huge_page - 1));
 1216|      0|  unsigned char resident[npages];
 1217|      0|  if (mincore(block, huge_page, resident) != 0) {
  ------------------
  |  Branch (1217:7): [True: 0, False: 0]
  ------------------
 1218|      0|    return false;
 1219|      0|  }
 1220|      0|  for (int i = 0; i < npages; i++) {
  ------------------
  |  Branch (1220:19): [True: 0, False: 0]
  ------------------
 1221|      0|    if (resident[i] & 1) {
  ------------------
  |  Branch (1221:9): [True: 0, False: 0]
  ------------------
 1222|      0|      return false;
 1223|      0|    }
 1224|      0|  }
 1225|       |  // Fault in one page as a write would, and see whether the whole huge page came
 1226|       |  // with it (best effort: kernels before 5.14 cannot, and then nothing is prefaulted)
 1227|      0|  if (madvise(block + huge_page / 2, small_page, MADV_POPULATE_WRITE) != 0 ||
  ------------------
  |  Branch (1227:7): [True: 0, False: 0]
  ------------------
 1228|      0|      mincore(block, huge_page, resident) != 0) {
  ------------------
  |  Branch (1228:7): [True: 0, False: 0]
  ------------------
 1229|      0|    return false;
 1230|      0|  }
 1231|      0|  for (int i = 0; i < npages; i++) {
  ------------------
  |  Branch (1231:19): [True: 0, False: 0]
  ------------------
 1232|      0|    if ((resident[i] & 1) == 0) {
  ------------------
  |  Branch (1232:9): [True: 0, False: 0]
  ------------------
 1233|      0|      return false;
 1234|      0|    }
 1235|      0|  }
 1236|      0|  return true;
 1237|       |#else
 1238|       |  BLOSC_UNUSED_PARAM(buffer);
 1239|       |  BLOSC_UNUSED_PARAM(nbytes);
 1240|       |  BLOSC_UNUSED_PARAM(nthreads);
 1241|       |  return false;
 1242|       |#endif
 1243|      0|}
b2nd.c:chunk_blocks_in_c_order:
 1068|   661k|static bool chunk_blocks_in_c_order(const b2nd_array_t *array) {
 1069|   661k|  int k = 0;
 1070|  2.34M|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1070:19): [True: 1.83M, False: 510k]
  ------------------
 1071|  1.83M|    if (array->chunkshape[i] % array->blockshape[i] != 0) {
  ------------------
  |  Branch (1071:9): [True: 146k, False: 1.69M]
  ------------------
 1072|   146k|      return false;
 1073|   146k|    }
 1074|  1.69M|    if (i > k && array->chunkshape[i] != array->blockshape[i]) {
  ------------------
  |  Branch (1074:9): [True: 19.4k, False: 1.67M]
  |  Branch (1074:18): [True: 3.26k, False: 16.1k]
  ------------------
 1075|  3.26k|      return false;
 1076|  3.26k|    }
 1077|  1.68M|    if (i == k && array->blockshape[i] == 1) {
  ------------------
  |  Branch (1077:9): [True: 1.67M, False: 16.1k]
  |  Branch (1077:19): [True: 1.60M, False: 70.0k]
  ------------------
 1078|  1.60M|      k++;
 1079|  1.60M|    }
 1080|  1.68M|  }
 1081|   510k|  return true;
 1082|   661k|}
b2nd.c:prefetch_slice:
 1448|   128k|static prefetch_batch* prefetch_slice(const b2nd_array_t *array, const int64_t *start, const int64_t *stop) {
 1449|   128k|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 1450|   128k|  if (!prefetch_applies(frame)) {
  ------------------
  |  Branch (1450:7): [True: 128k, False: 0]
  ------------------
 1451|   128k|    return NULL;
 1452|   128k|  }
 1453|      0|  int8_t ndim = array->ndim;
 1454|      0|  int64_t nblocks = array->blocknitems > 0 ? array->extchunknitems / array->blocknitems : 0;
  ------------------
  |  Branch (1454:21): [True: 0, False: 0]
  ------------------
 1455|      0|  int64_t *nchunks = NULL;
 1456|      0|  int64_t n = b2nd_get_slice_nchunks(array, start, stop, &nchunks);
 1457|      0|  int64_t chunk_start[B2ND_MAX_DIM];
 1458|      0|  int64_t chunk_stop[B2ND_MAX_DIM];
 1459|      0|  int64_t npartial = 0;
 1460|      0|  for (int64_t c = 0; c < n && nblocks > 0; ++c) {
  ------------------
  |  Branch (1460:23): [True: 0, False: 0]
  |  Branch (1460:32): [True: 0, False: 0]
  ------------------
 1461|      0|    npartial += chunk_box(array, nchunks[c], start, stop, chunk_start, chunk_stop);
 1462|      0|  }
 1463|       |  // One maskout per chunk covered in part (NULL for a chunk read whole), all in one allocation
 1464|      0|  const bool **maskouts = NULL;
 1465|      0|  if (npartial > 0) {
  ------------------
  |  Branch (1465:7): [True: 0, False: 0]
  ------------------
 1466|      0|    maskouts = calloc(1, n * sizeof(bool *) + npartial * nblocks * sizeof(bool));
 1467|      0|  }
 1468|      0|  if (maskouts != NULL) {
  ------------------
  |  Branch (1468:7): [True: 0, False: 0]
  ------------------
 1469|      0|    bool *row = (bool *) (maskouts + n);
 1470|      0|    int64_t blocks_in_chunk[B2ND_MAX_DIM];
 1471|      0|    int64_t blockshape[B2ND_MAX_DIM];
 1472|      0|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1472:21): [True: 0, False: 0]
  ------------------
 1473|      0|      blocks_in_chunk[i] = array->extchunkshape[i] / array->blockshape[i];
 1474|      0|      blockshape[i] = array->blockshape[i];
 1475|      0|    }
 1476|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(array->sc->storage->io->id);
 1477|      0|    bool mapped = io_cb != NULL && !io_cb->is_allocation_necessary;
  ------------------
  |  Branch (1477:19): [True: 0, False: 0]
  |  Branch (1477:36): [True: 0, False: 0]
  ------------------
 1478|      0|    bool has_delta = filters_contain(array->sc->filters, BLOSC_DELTA);
 1479|      0|    slice_chunk_t slice_chunk;
 1480|      0|    memset(&slice_chunk, 0, sizeof(slice_chunk));
 1481|      0|    slice_chunk.array = array;
 1482|      0|    slice_chunk.start = start;
 1483|      0|    slice_chunk.stop = stop;
 1484|      0|    slice_chunk.chunk_start = chunk_start;
 1485|      0|    slice_chunk.chunk_stop = chunk_stop;
 1486|      0|    slice_chunk.blocks_in_chunk = blocks_in_chunk;
 1487|      0|    slice_chunk.blockshape = blockshape;
 1488|      0|    for (int64_t c = 0; c < n; ++c) {
  ------------------
  |  Branch (1488:25): [True: 0, False: 0]
  ------------------
 1489|      0|      if (!chunk_box(array, nchunks[c], start, stop, chunk_start, chunk_stop)) {
  ------------------
  |  Branch (1489:11): [True: 0, False: 0]
  ------------------
 1490|      0|        continue;  // read whole
 1491|      0|      }
 1492|      0|      int64_t nneeded = slice_chunk_maskout(&slice_chunk, nblocks, has_delta, row);
 1493|      0|      if (mapped || slice_chunk_compact(array, nneeded, has_delta)) {
  ------------------
  |  Branch (1493:11): [True: 0, False: 0]
  |  Branch (1493:21): [True: 0, False: 0]
  ------------------
 1494|      0|        maskouts[c] = row;
 1495|      0|        row += nblocks;
 1496|      0|      }
 1497|      0|    }
 1498|      0|  }
 1499|      0|  prefetch_batch *batch = prefetch_batch_new(frame, nchunks, n, maskouts, nblocks);
 1500|      0|  free(maskouts);
 1501|      0|  free(nchunks);
 1502|      0|  return batch;
 1503|   128k|}
b2nd.c:chunks_special:
 1510|  62.4k|static int chunks_special(blosc2_schunk *sc, const int64_t *nchunks, int64_t n, uint8_t *special) {
 1511|  62.4k|  if (sc->frame != NULL) {
  ------------------
  |  Branch (1511:7): [True: 62.4k, False: 0]
  ------------------
 1512|  62.4k|    return frame_get_chunks_special((blosc2_frame_s *) sc->frame, nchunks, n, special);
 1513|  62.4k|  }
 1514|      0|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (1514:23): [True: 0, False: 0]
  ------------------
 1515|      0|    if (nchunks[k] < 0 || nchunks[k] >= sc->nchunks || sc->data[nchunks[k]] == NULL) {
  ------------------
  |  Branch (1515:9): [True: 0, False: 0]
  |  Branch (1515:27): [True: 0, False: 0]
  |  Branch (1515:56): [True: 0, False: 0]
  ------------------
 1516|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1517|      0|    }
 1518|      0|    const uint8_t *chunk = sc->data[nchunks[k]];
 1519|      0|    special[k] = (uint8_t) chunk_special_in_offset(chunk, sw32_(chunk + BLOSC2_CHUNK_CBYTES));
 1520|      0|  }
 1521|      0|  return BLOSC2_ERROR_SUCCESS;
 1522|      0|}
b2nd.c:chunk_box:
 1426|   178k|                      int64_t *chunk_start, int64_t *chunk_stop) {
 1427|   178k|  int64_t chunks_in_array[B2ND_MAX_DIM];
 1428|   178k|  int64_t nchunk_ndim[B2ND_MAX_DIM];
 1429|  1.10M|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1429:19): [True: 927k, False: 178k]
  ------------------
 1430|   927k|    chunks_in_array[i] = array->extshape[i] / array->chunkshape[i];
 1431|   927k|  }
 1432|   178k|  blosc2_unidim_to_multidim(array->ndim, chunks_in_array, nchunk, nchunk_ndim);
 1433|   178k|  bool partial = false;
 1434|  1.10M|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1434:19): [True: 927k, False: 178k]
  ------------------
 1435|   927k|    chunk_start[i] = nchunk_ndim[i] * array->chunkshape[i];
 1436|   927k|    chunk_stop[i] = chunk_start[i] + array->chunkshape[i] < array->shape[i] ?
  ------------------
  |  Branch (1436:21): [True: 319k, False: 608k]
  ------------------
 1437|   608k|                    chunk_start[i] + array->chunkshape[i] : array->shape[i];
 1438|   927k|    partial |= start[i] > chunk_start[i] || stop[i] < chunk_stop[i];
  ------------------
  |  Branch (1438:16): [True: 17.7k, False: 910k]
  |  Branch (1438:45): [True: 13.1k, False: 896k]
  ------------------
 1439|   927k|  }
 1440|   178k|  return partial;
 1441|   178k|}
b2nd.c:chunk_slice_box:
 1184|   794k|                               int64_t *box_stop) {
 1185|   794k|  int64_t nitems = 1;
 1186|  5.10M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1186:19): [True: 4.30M, False: 794k]
  ------------------
 1187|  4.30M|    box_start[i] = (chunk_start[i] > start[i] ? chunk_start[i] : start[i]) - start[i];
  ------------------
  |  Branch (1187:21): [True: 844k, False: 3.46M]
  ------------------
 1188|  4.30M|    box_stop[i] = (chunk_stop[i] < stop[i] ? chunk_stop[i] : stop[i]) - start[i];
  ------------------
  |  Branch (1188:20): [True: 867k, False: 3.43M]
  ------------------
 1189|  4.30M|    nitems *= box_stop[i] - box_start[i];
 1190|  4.30M|  }
 1191|   794k|  return nitems;
 1192|   794k|}
b2nd.c:chunk_contiguous_in_buffer:
 1090|  1.01M|                                       const int64_t *shape, int64_t *offset) {
 1091|       |  // Leading dims where the chunk is one item wide can sit anywhere; past the
 1092|       |  // first wider dim the chunk has to span the buffer.
 1093|  1.01M|  bool must_span = false;
 1094|  1.01M|  int64_t off = 0;
 1095|  3.32M|  for (int i = 0; i < array->ndim; ++i) {
  ------------------
  |  Branch (1095:19): [True: 2.54M, False: 782k]
  ------------------
 1096|  2.54M|    int64_t extent = array->chunkshape[i];
 1097|  2.54M|    if (chunk_start[i] < start[i] || chunk_start[i] + extent > stop[i] ||
  ------------------
  |  Branch (1097:9): [True: 3.92k, False: 2.53M]
  |  Branch (1097:38): [True: 204k, False: 2.33M]
  ------------------
 1098|  2.33M|        chunk_start[i] + extent > array->shape[i]) {
  ------------------
  |  Branch (1098:9): [True: 7.03k, False: 2.32M]
  ------------------
 1099|   215k|      return false;
 1100|   215k|    }
 1101|  2.32M|    if (must_span && extent != shape[i]) {
  ------------------
  |  Branch (1101:9): [True: 24.9k, False: 2.29M]
  |  Branch (1101:22): [True: 12.8k, False: 12.1k]
  ------------------
 1102|  12.8k|      return false;
 1103|  12.8k|    }
 1104|  2.31M|    if (extent > 1) {
  ------------------
  |  Branch (1104:9): [True: 53.4k, False: 2.25M]
  ------------------
 1105|  53.4k|      must_span = true;
 1106|  53.4k|    }
 1107|  2.31M|    off = off * shape[i] + (chunk_start[i] - start[i]);
 1108|  2.31M|  }
 1109|   782k|  *offset = off * array->sc->typesize;
 1110|       |  return true;
 1111|  1.01M|}
b2nd.c:compress_update_chunk:
 1349|   767k|                                 int32_t nbytes, slice_chunk_t *gather) {
 1350|   767k|  int32_t chunk_nbytes = nbytes + BLOSC2_MAX_OVERHEAD;
 1351|   767k|  size_t chunk_capacity;
 1352|   767k|  uint8_t *chunk = scratch_malloc(array, chunk_nbytes, &chunk_capacity);
 1353|   767k|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   767k|    do {                                            \
  |  |  105|   767k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 767k]
  |  |  ------------------
  |  |  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|   767k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 767k]
  |  |  ------------------
  ------------------
 1354|       |  // Update current_chunk in case a prefilter is applied
 1355|   767k|  array->sc->current_nchunk = nchunk;
 1356|   767k|  blosc2_context *cctx = array->sc->cctx;
 1357|   767k|  blosc2_prefilter_params params;
 1358|   767k|  blosc2_prefilter_params *saved_preparams = cctx->preparams;
 1359|   767k|  bool saved_full_write = cctx->prefilter_full_write;
 1360|   767k|  if (gather != NULL) {
  ------------------
  |  Branch (1360:7): [True: 358k, False: 409k]
  ------------------
 1361|   358k|    memset(&params, 0, sizeof(params));
 1362|   358k|    params.user_data = gather;
 1363|   358k|    cctx->prefilter = slice_gather_prefilter;
 1364|   358k|    cctx->preparams = &params;
 1365|       |    /* The gather callback copies old contents or clears partial/padding blocks;
 1366|       |     * a whole-block slice copy needs no preliminary memset. */
 1367|   358k|    cctx->prefilter_full_write = true;
 1368|   358k|  }
 1369|   767k|  int brc = blosc2_compress_ctx(cctx, src, nbytes, chunk, chunk_nbytes);
 1370|   767k|  if (gather != NULL) {
  ------------------
  |  Branch (1370:7): [True: 358k, False: 409k]
  ------------------
 1371|   358k|    cctx->prefilter = NULL;
 1372|   358k|    cctx->preparams = saved_preparams;
 1373|   358k|    cctx->prefilter_full_write = saved_full_write;
 1374|   358k|  }
 1375|   767k|  if (brc < 0) {
  ------------------
  |  Branch (1375:7): [True: 0, False: 767k]
  ------------------
 1376|      0|    blosc2_tmp_free(chunk, chunk_capacity);
 1377|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1378|      0|    return BLOSC2_ERROR_FAILURE;
 1379|      0|  }
 1380|       |  // A frame stores its own copy of the chunk, so it is lent a reused buffer; an
 1381|       |  // in-memory super-chunk keeps the buffer itself
 1382|   767k|  bool in_frame = array->sc->frame != NULL;
 1383|   767k|  int64_t brc_ = in_frame ? schunk_update_chunk_lent(array->sc, nchunk, chunk)
  ------------------
  |  Branch (1383:18): [True: 767k, False: 0]
  ------------------
 1384|   767k|                          : blosc2_schunk_update_chunk(array->sc, nchunk, chunk, false);
 1385|   767k|  if (in_frame || brc_ < 0) {
  ------------------
  |  Branch (1385:7): [True: 767k, False: 0]
  |  Branch (1385:19): [True: 0, False: 0]
  ------------------
 1386|       |    // A failed update leaves the chunk to us
 1387|   767k|    blosc2_tmp_free(chunk, chunk_capacity);
 1388|   767k|  }
 1389|   767k|  if (brc_ < 0) {
  ------------------
  |  Branch (1389:7): [True: 118, False: 767k]
  ------------------
 1390|    118|    BLOSC_TRACE_ERROR("Blosc can not update the chunk");
  ------------------
  |  |   93|    118|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    118|    do {                                            \
  |  |  |  |   98|    118|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    118|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 118, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    118|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1391|    118|    return BLOSC2_ERROR_FAILURE;
 1392|    118|  }
 1393|   767k|  return BLOSC2_ERROR_SUCCESS;
 1394|   767k|}
b2nd.c:slice_gather_prefilter:
 1312|  12.9M|static int slice_gather_prefilter(blosc2_prefilter_params *params) {
 1313|  12.9M|  const slice_chunk_t *c = params->user_data;
 1314|  12.9M|  const b2nd_array_t *array = c->array;
 1315|  12.9M|  int8_t ndim = array->ndim;
 1316|  12.9M|  int32_t typesize = array->sc->typesize;
 1317|  12.9M|  if (params->output_size != array->blocknitems * typesize) {
  ------------------
  |  Branch (1317:7): [True: 0, False: 12.9M]
  ------------------
 1318|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1319|      0|    return BLOSC2_ERROR_FAILURE;
 1320|      0|  }
 1321|  12.9M|  block_overlap_t overlap;
 1322|  12.9M|  bool overlaps = block_slice_overlap(c, params->nblock, &overlap);
 1323|  12.9M|  if (!(overlaps && overlap.whole_block)) {
  ------------------
  |  Branch (1323:9): [True: 585k, False: 12.4M]
  |  Branch (1323:21): [True: 152k, False: 432k]
  ------------------
 1324|  12.8M|    if (c->keep_old) {
  ------------------
  |  Branch (1324:9): [True: 30.1k, False: 12.8M]
  ------------------
 1325|  30.1k|      memcpy(params->output, params->input, (size_t) params->output_size);
 1326|  12.8M|    } else {
 1327|  12.8M|      memset(params->output, 0, (size_t) params->output_size);
 1328|  12.8M|    }
 1329|  12.8M|  }
 1330|  12.9M|  if (!overlaps) {
  ------------------
  |  Branch (1330:7): [True: 12.4M, False: 585k]
  ------------------
 1331|  12.4M|    return 0;
 1332|  12.4M|  }
 1333|   585k|  return b2nd_copy_buffer2(ndim, typesize, c->buffer, c->buffershape, overlap.dst_start,
 1334|   585k|                           overlap.dst_stop, params->output, c->blockshape, overlap.src_start);
 1335|  12.9M|}
b2nd.c:decoded_nothing:
 1304|   626k|static bool decoded_nothing(const blosc2_context *dctx, int rc) {
 1305|   626k|  return rc == 0 || (dctx->special_type == BLOSC2_SPECIAL_UNINIT && dctx->postfilter == NULL);
  ------------------
  |  Branch (1305:10): [True: 0, False: 626k]
  |  Branch (1305:22): [True: 0, False: 626k]
  |  Branch (1305:69): [True: 0, False: 0]
  ------------------
 1306|   626k|}
b2nd.c:scratch_malloc:
 1340|   921k|static uint8_t *scratch_malloc(const b2nd_array_t *array, int32_t nbytes, size_t *capacity) {
 1341|   921k|  return schunk_scratch_malloc(array->sc, nbytes, capacity);
 1342|   921k|}
b2nd.c:block_slice_overlap:
 1149|  66.1M|static bool block_slice_overlap(const slice_chunk_t *c, int64_t nblock, block_overlap_t *overlap) {
 1150|  66.1M|  int8_t ndim = c->array->ndim;
 1151|  66.1M|  int64_t nblock_ndim[B2ND_MAX_DIM] = {0};
 1152|  66.1M|  blosc2_unidim_to_multidim(ndim, (int64_t *) c->blocks_in_chunk, nblock, nblock_ndim);
 1153|  66.1M|  bool whole_block = true;
 1154|   148M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (1154:19): [True: 145M, False: 2.76M]
  ------------------
 1155|   145M|    int64_t block_start = c->chunk_start[i] + nblock_ndim[i] * c->blockshape[i];
 1156|   145M|    int64_t block_stop = block_start + c->blockshape[i];
 1157|   145M|    if (block_stop > c->chunk_stop[i]) {
  ------------------
  |  Branch (1157:9): [True: 69.8M, False: 75.6M]
  ------------------
 1158|  69.8M|      block_stop = c->chunk_stop[i];
 1159|  69.8M|    }
 1160|   145M|    int64_t lo = block_start > c->start[i] ? block_start : c->start[i];
  ------------------
  |  Branch (1160:18): [True: 98.7M, False: 46.7M]
  ------------------
 1161|   145M|    int64_t hi = block_stop < c->stop[i] ? block_stop : c->stop[i];
  ------------------
  |  Branch (1161:18): [True: 46.1M, False: 99.3M]
  ------------------
 1162|   145M|    if (lo >= hi) {
  ------------------
  |  Branch (1162:9): [True: 63.3M, False: 82.1M]
  ------------------
 1163|  63.3M|      return false;
 1164|  63.3M|    }
 1165|  82.1M|    whole_block &= lo == block_start && hi == block_start + c->blockshape[i];
  ------------------
  |  Branch (1165:20): [True: 81.9M, False: 200k]
  |  Branch (1165:41): [True: 72.4M, False: 9.51M]
  ------------------
 1166|  82.1M|    if (overlap != NULL) {
  ------------------
  |  Branch (1166:9): [True: 52.8M, False: 29.2M]
  ------------------
 1167|  52.8M|      overlap->src_start[i] = lo - block_start;
 1168|  52.8M|      overlap->src_stop[i] = hi - block_start;
 1169|  52.8M|      overlap->dst_start[i] = lo - c->start[i];
 1170|  52.8M|      overlap->dst_stop[i] = hi - c->start[i];
 1171|  52.8M|    }
 1172|  82.1M|  }
 1173|  2.76M|  if (overlap != NULL) {
  ------------------
  |  Branch (1173:7): [True: 1.70M, False: 1.06M]
  ------------------
 1174|  1.70M|    overlap->whole_block = whole_block;
 1175|  1.70M|  }
 1176|       |  return true;
 1177|  66.1M|}
b2nd.c:slice_chunk_maskout:
 1399|   296k|static int64_t slice_chunk_maskout(const slice_chunk_t *c, int64_t nblocks, bool has_delta, bool *maskout) {
 1400|   296k|  int64_t nneeded = 0;
 1401|  26.6M|  for (int64_t nblock = 0; nblock < nblocks; ++nblock) {
  ------------------
  |  Branch (1401:28): [True: 26.3M, False: 296k]
  ------------------
 1402|  26.3M|    maskout[nblock] = !block_slice_overlap(c, nblock, NULL);
 1403|  26.3M|    nneeded += !maskout[nblock];
 1404|  26.3M|  }
 1405|   296k|  if (has_delta && nneeded > 0) {
  ------------------
  |  Branch (1405:7): [True: 0, False: 296k]
  |  Branch (1405:20): [True: 0, False: 0]
  ------------------
 1406|       |    maskout[0] = false;
 1407|      0|  }
 1408|   296k|  return nneeded;
 1409|   296k|}
b2nd.c:slice_chunk_compact:
 1414|   296k|static bool slice_chunk_compact(const b2nd_array_t *array, int64_t nblocks_needed, bool has_delta) {
 1415|   296k|  bool on_disk = array->sc->storage != NULL && array->sc->storage->urlpath != NULL;
  ------------------
  |  Branch (1415:18): [True: 296k, False: 0]
  |  Branch (1415:48): [True: 0, False: 296k]
  ------------------
 1416|   296k|  int64_t frac = on_disk ? 4 : 16;
  ------------------
  |  Branch (1416:18): [True: 0, False: 296k]
  ------------------
 1417|   296k|  int64_t block_nbytes = (int64_t) array->blocknitems * array->sc->typesize;
 1418|   296k|  int64_t data_nbytes = array->extchunknitems * array->sc->typesize;
 1419|   296k|  return !has_delta && nblocks_needed * block_nbytes * frac <= data_nbytes;
  ------------------
  |  Branch (1419:10): [True: 296k, False: 0]
  |  Branch (1419:24): [True: 66.3k, False: 229k]
  ------------------
 1420|   296k|}
b2nd.c:slice_scatter_postfilter:
 1269|   841k|static int slice_scatter_postfilter(blosc2_postfilter_params *params) {
 1270|   841k|  const slice_chunk_t *c = params->user_data;
 1271|   841k|  const b2nd_array_t *array = c->array;
 1272|   841k|  int8_t ndim = array->ndim;
 1273|   841k|  int32_t typesize = array->sc->typesize;
 1274|   841k|  if (params->size != array->blocknitems * typesize) {
  ------------------
  |  Branch (1274:7): [True: 0, False: 841k]
  ------------------
 1275|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1276|      0|    return BLOSC2_ERROR_FAILURE;
 1277|      0|  }
 1278|   841k|  block_overlap_t overlap;
 1279|   841k|  if (!block_slice_overlap(c, params->nblock, &overlap)) {
  ------------------
  |  Branch (1279:7): [True: 0, False: 841k]
  ------------------
 1280|      0|    return 0;
 1281|      0|  }
 1282|   841k|  if (params->ctx->special_type == BLOSC2_SPECIAL_UNINIT) {
  ------------------
  |  Branch (1282:7): [True: 0, False: 841k]
  ------------------
 1283|       |    // Nothing was decoded into the input; hand out zeros rather than stale memory
 1284|      0|    b2nd_zero_box(ndim, typesize, c->buffer, c->buffershape, overlap.dst_start, overlap.dst_stop);
 1285|      0|    return 0;
 1286|      0|  }
 1287|   841k|  return b2nd_copy_buffer2(ndim, typesize, params->input, c->blockshape, overlap.src_start,
 1288|   841k|                           overlap.src_stop, c->buffer, c->buffershape, overlap.dst_start);
 1289|   841k|}
b2nd.c:scatter_unsupported:
 1295|   229k|static bool scatter_unsupported(const blosc2_context *dctx) {
 1296|   229k|  return (dctx->blosc2_flags & BLOSC2_INSTR_CODEC) || filters_contain(dctx->filters, BLOSC_DELTA);
  ------------------
  |  Branch (1296:10): [True: 0, False: 229k]
  |  Branch (1296:55): [True: 0, False: 229k]
  ------------------
 1297|   229k|}
b2nd.c:locked_get_set_slice:
 2099|  1.07M|                                bool set_slice, bool slice_only, prefetch_batch *prefetch) {
 2100|  1.07M|  blosc2_frame_s *frame = (blosc2_frame_s *) array->sc->frame;
 2101|  1.07M|  BLOSC_ERROR(set_slice ? frame_begin_updates(frame) : frame_lock(frame, false));
  ------------------
  |  |  111|  1.07M|    do {                                            \
  |  |  112|  2.14M|        int rc_ = (rc);                             \
  |  |  ------------------
  |  |  |  Branch (112:20): [True: 534k, False: 539k]
  |  |  ------------------
  |  |  113|  1.07M|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 0, False: 1.07M]
  |  |  ------------------
  |  |  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.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 2102|  1.07M|  int rc = refresh_if_stale(array);
 2103|  1.07M|  if (rc >= 0) {
  ------------------
  |  Branch (2103:7): [True: 1.07M, False: 0]
  ------------------
 2104|  1.07M|    rc = get_set_slice(buffer, buffersize, start, stop, shape, array, set_slice, slice_only, prefetch);
 2105|  1.07M|  }
 2106|  1.07M|  if (set_slice) {
  ------------------
  |  Branch (2106:7): [True: 534k, False: 539k]
  ------------------
 2107|   534k|    int end_rc = frame_end_updates(frame, array->sc);
 2108|   534k|    rc = (rc < 0) ? rc : end_rc;
  ------------------
  |  Branch (2108:10): [True: 390, False: 534k]
  ------------------
 2109|   534k|  }
 2110|   539k|  else {
 2111|   539k|    frame_unlock(frame);
 2112|   539k|  }
 2113|  1.07M|  BLOSC_ERROR(rc);
  ------------------
  |  |  111|  1.07M|    do {                                            \
  |  |  112|  1.07M|        int rc_ = (rc);                             \
  |  |  113|  1.07M|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 928, False: 1.07M]
  |  |  ------------------
  |  |  114|    928|            char *error_msg = print_error(rc_);     \
  |  |  115|    928|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   93|    928|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  |  |  ------------------
  |  |  |  |  |  |   97|    928|    do {                                            \
  |  |  |  |  |  |   98|    928|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |  |  |   99|    928|        if (!__e) { break; }                        \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (99:13): [True: 928, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  100|    928|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|    928|            return rc_;                             \
  |  |  117|    928|        }                                           \
  |  |  118|  1.07M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 1.07M]
  |  |  ------------------
  ------------------
 2114|       |
 2115|  1.07M|  return BLOSC2_ERROR_SUCCESS;
 2116|  1.07M|}
b2nd.c:get_slice_chunks:
 2226|  1.37k|                            const int64_t *start, prefetch_batch *prefetch) {
 2227|  1.37k|  int8_t ndim = (*array)->ndim;
 2228|  1.37k|  int64_t chunks_in_array[B2ND_MAX_DIM] = {0};
 2229|  4.93k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2229:19): [True: 3.55k, False: 1.37k]
  ------------------
 2230|  3.55k|    chunks_in_array[i] = (*array)->extshape[i] / (*array)->chunkshape[i];
 2231|  3.55k|  }
 2232|  1.37k|  int64_t nchunks = (*array)->sc->nchunks;
 2233|   532k|  for (int64_t nchunk = 0; nchunk < nchunks; ++nchunk) {
  ------------------
  |  Branch (2233:28): [True: 531k, False: 1.23k]
  ------------------
 2234|   531k|    int64_t nchunk_ndim[B2ND_MAX_DIM] = {0};
 2235|   531k|    blosc2_unidim_to_multidim(ndim, chunks_in_array, nchunk, nchunk_ndim);
 2236|       |
 2237|       |    // Check if the chunk needs to be updated
 2238|   531k|    int64_t chunk_start[B2ND_MAX_DIM] = {0};
 2239|   531k|    int64_t chunk_stop[B2ND_MAX_DIM] = {0};
 2240|   531k|    int64_t chunk_shape[B2ND_MAX_DIM] = {0};
 2241|  2.11M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2241:21): [True: 1.58M, False: 531k]
  ------------------
 2242|  1.58M|      chunk_start[i] = nchunk_ndim[i] * (*array)->chunkshape[i];
 2243|  1.58M|      chunk_stop[i] = chunk_start[i] + (*array)->chunkshape[i];
 2244|  1.58M|      if (chunk_stop[i] > (*array)->shape[i]) {
  ------------------
  |  Branch (2244:11): [True: 178k, False: 1.40M]
  ------------------
 2245|   178k|        chunk_stop[i] = (*array)->shape[i];
 2246|   178k|      }
 2247|  1.58M|      chunk_shape[i] = chunk_stop[i] - chunk_start[i];
 2248|  1.58M|    }
 2249|       |
 2250|   531k|    int64_t src_start[B2ND_MAX_DIM] = {0};
 2251|   531k|    int64_t src_stop[B2ND_MAX_DIM] = {0};
 2252|  2.11M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2252:21): [True: 1.58M, False: 531k]
  ------------------
 2253|  1.58M|      src_start[i] = chunk_start[i] + start[i];
 2254|  1.58M|      src_stop[i] = chunk_stop[i] + start[i];
 2255|  1.58M|    }
 2256|   531k|    if (ctx->b2_storage->cparams->typesize <= 0) {
  ------------------
  |  Branch (2256:9): [True: 0, False: 531k]
  ------------------
 2257|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2258|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2259|      0|    }
 2260|   531k|    size_t buffersize = (size_t)ctx->b2_storage->cparams->typesize;
 2261|  2.11M|    for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (2261:21): [True: 1.58M, False: 531k]
  ------------------
 2262|  1.58M|      if (chunk_shape[i] < 0) {
  ------------------
  |  Branch (2262:11): [True: 0, False: 1.58M]
  ------------------
 2263|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2264|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2265|      0|      }
 2266|  1.58M|      if (!blosc2_checked_mul_size(buffersize, (size_t)chunk_shape[i], &buffersize)) {
  ------------------
  |  Branch (2266:11): [True: 0, False: 1.58M]
  ------------------
 2267|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2268|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 2269|      0|      }
 2270|  1.58M|    }
 2271|   531k|    if (buffersize == 0 || buffersize > (size_t)INT64_MAX) {
  ------------------
  |  Branch (2271:9): [True: 0, False: 531k]
  |  Branch (2271:28): [True: 0, False: 531k]
  ------------------
 2272|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2273|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2274|      0|    }
 2275|   531k|    size_t capacity;
 2276|   531k|    uint8_t *buffer = blosc2_tmp_malloc(buffersize, &capacity);
 2277|   531k|    if (buffer == NULL) {
  ------------------
  |  Branch (2277:9): [True: 0, False: 531k]
  ------------------
 2278|      0|      b2nd_free(*array);
 2279|      0|      *array = NULL;
 2280|      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]
  |  |  ------------------
  ------------------
 2281|      0|    }
 2282|   531k|    int g_rc = locked_get_set_slice(buffer, (int64_t) buffersize, src_start, src_stop, chunk_shape,
 2283|   531k|                                    (b2nd_array_t *) src, false, false, prefetch);
 2284|   531k|    if (g_rc < 0) {
  ------------------
  |  Branch (2284:9): [True: 148, False: 530k]
  ------------------
 2285|    148|      blosc2_tmp_free(buffer, capacity);
 2286|    148|      b2nd_free(*array);
 2287|    148|      *array = NULL;
 2288|    148|      return g_rc;
 2289|    148|    }
 2290|   530k|    int s_rc = b2nd_set_slice_cbuffer(buffer, chunk_shape, (int64_t)buffersize, chunk_start,
 2291|   530k|                                      chunk_stop, *array);
 2292|   530k|    blosc2_tmp_free(buffer, capacity);
 2293|   530k|    if (s_rc < 0) {
  ------------------
  |  Branch (2293:9): [True: 0, False: 530k]
  ------------------
 2294|      0|      b2nd_free(*array);
 2295|      0|      *array = NULL;
 2296|      0|      return s_rc;
 2297|      0|    }
 2298|   530k|  }
 2299|       |
 2300|  1.23k|  return BLOSC2_ERROR_SUCCESS;
 2301|  1.37k|}
b2nd.c:validate_shape_chunkshape_blockshape:
  124|  32.5k|                                                const int32_t *chunkshape, const int32_t *blockshape) {
  125|   167k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (125:19): [True: 135k, False: 32.5k]
  ------------------
  126|   135k|    if (shape[i] < 0) {
  ------------------
  |  Branch (126:9): [True: 0, False: 135k]
  ------------------
  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|   135k|    if (chunkshape[i] < 0 || blockshape[i] < 0) {
  ------------------
  |  Branch (130:9): [True: 0, False: 135k]
  |  Branch (130:30): [True: 0, False: 135k]
  ------------------
  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|   135k|    bool chunkshape_is_zero = (chunkshape[i] == 0);
  136|   135k|    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|   135k|    if (blockshape_is_zero && !chunkshape_is_zero) {
  ------------------
  |  Branch (140:9): [True: 0, False: 135k]
  |  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|   135k|  }
  145|       |
  146|  32.5k|  return BLOSC2_ERROR_SUCCESS;
  147|  32.5k|}

b2nd_copy_buffer2:
  192|  1.67M|                      const int64_t *dst_start) {
  193|  1.67M|  int64_t copy_shape[B2ND_MAX_DIM];
  194|  8.66M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (194:19): [True: 6.98M, False: 1.67M]
  ------------------
  195|  6.98M|    copy_shape[i] = src_stop[i] - src_start[i];
  196|  6.98M|    if (copy_shape[i] == 0) {
  ------------------
  |  Branch (196:9): [True: 0, False: 6.98M]
  ------------------
  197|      0|      return BLOSC2_ERROR_SUCCESS;
  198|      0|    }
  199|  6.98M|  }
  200|  1.67M|  copy_or_zero_box(ndim, itemsize, copy_shape, src, src_pad_shape, src_start, dst, dst_pad_shape, dst_start);
  201|       |
  202|  1.67M|  return BLOSC2_ERROR_SUCCESS;
  203|  1.67M|}
b2nd_zero_box:
  208|  16.1k|                   const int64_t *box_start, const int64_t *box_stop) {
  209|  16.1k|  int64_t box_shape[B2ND_MAX_DIM];
  210|   110k|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (210:19): [True: 93.9k, False: 16.1k]
  ------------------
  211|  93.9k|    box_shape[i] = box_stop[i] - box_start[i];
  212|  93.9k|    if (box_shape[i] <= 0) {
  ------------------
  |  Branch (212:9): [True: 0, False: 93.9k]
  ------------------
  213|      0|      return;
  214|      0|    }
  215|  93.9k|  }
  216|  16.1k|  copy_or_zero_box(ndim, itemsize, box_shape, NULL, dst_pad_shape, box_start, dst, dst_pad_shape, box_start);
  217|  16.1k|}
b2nd_utils.c:copy_or_zero_box:
  156|  1.69M|                             uint8_t *dst, const int64_t *dst_pad_shape, const int64_t *dst_start) {
  157|  1.69M|  int64_t src_strides[B2ND_MAX_DIM];
  158|  1.69M|  int64_t dst_strides[B2ND_MAX_DIM];
  159|  1.69M|  byte_strides(ndim, itemsize, src_pad_shape, src_strides);
  160|  1.69M|  byte_strides(ndim, itemsize, dst_pad_shape, dst_strides);
  161|  1.69M|  int64_t src_offset = 0;
  162|  1.69M|  int64_t dst_offset = 0;
  163|  8.77M|  for (int i = 0; i < ndim; ++i) {
  ------------------
  |  Branch (163:19): [True: 7.07M, False: 1.69M]
  ------------------
  164|  7.07M|    src_offset += src_start[i] * src_strides[i];
  165|  7.07M|    dst_offset += dst_start[i] * dst_strides[i];
  166|  7.07M|  }
  167|  1.69M|  dst += dst_offset;
  168|  1.69M|  if (src != NULL) {
  ------------------
  |  Branch (168:7): [True: 1.67M, False: 16.1k]
  ------------------
  169|  1.67M|    src += src_offset;
  170|  1.67M|  }
  171|       |
  172|  1.69M|  int64_t shape[B2ND_MAX_DIM];
  173|  1.69M|  int64_t src_bstrides[B2ND_MAX_DIM];
  174|  1.69M|  int64_t dst_bstrides[B2ND_MAX_DIM];
  175|  1.69M|  int ndim_bytes = simplify_box(ndim, itemsize, box_shape, src_strides, dst_strides, shape, src_bstrides,
  176|  1.69M|                                dst_bstrides);
  177|  1.69M|  if (ndim_bytes > 1) {
  ------------------
  |  Branch (177:7): [True: 539k, False: 1.15M]
  ------------------
  178|   539k|    copy_box(ndim_bytes, shape, src, src_bstrides, dst, dst_bstrides);
  179|  1.15M|  } else if (src == NULL) {
  ------------------
  |  Branch (179:14): [True: 14.9k, False: 1.13M]
  ------------------
  180|  14.9k|    memset(dst, 0, (size_t) shape[0]);
  181|  1.13M|  } else {
  182|  1.13M|    memcpy(dst, src, (size_t) shape[0]);
  183|  1.13M|  }
  184|  1.69M|}
b2nd_utils.c:byte_strides:
  143|  3.38M|static void byte_strides(int8_t ndim, int32_t itemsize, const int64_t *pad_shape, int64_t *strides) {
  144|  3.38M|  int64_t stride = itemsize;
  145|  17.5M|  for (int i = ndim - 1; i >= 0; --i) {
  ------------------
  |  Branch (145:26): [True: 14.1M, False: 3.38M]
  ------------------
  146|  14.1M|    strides[i] = stride;
  147|  14.1M|    stride *= pad_shape[i];
  148|  14.1M|  }
  149|  3.38M|}
b2nd_utils.c:simplify_box:
  114|  1.69M|                        int64_t *shape, int64_t *src_bstrides, int64_t *dst_bstrides) {
  115|  1.69M|  int n = 0;
  116|  1.69M|  int64_t extent = itemsize;
  117|  1.69M|  int64_t src_stride = 1;
  118|  1.69M|  int64_t dst_stride = 1;
  119|  8.77M|  for (int i = ndim - 1; i >= 0; --i) {
  ------------------
  |  Branch (119:26): [True: 7.07M, False: 1.69M]
  ------------------
  120|  7.07M|    if (box_shape[i] == 1) {
  ------------------
  |  Branch (120:9): [True: 6.14M, False: 931k]
  ------------------
  121|  6.14M|      continue;
  122|  6.14M|    }
  123|   931k|    if (src_strides[i] == src_stride * extent && dst_strides[i] == dst_stride * extent) {
  ------------------
  |  Branch (123:9): [True: 720k, False: 211k]
  |  Branch (123:50): [True: 349k, False: 371k]
  ------------------
  124|   349k|      extent *= box_shape[i];
  125|   349k|      continue;
  126|   349k|    }
  127|   582k|    shape[n] = extent;
  128|   582k|    src_bstrides[n] = src_stride;
  129|   582k|    dst_bstrides[n] = dst_stride;
  130|   582k|    ++n;
  131|   582k|    extent = box_shape[i];
  132|   582k|    src_stride = src_strides[i];
  133|   582k|    dst_stride = dst_strides[i];
  134|   582k|  }
  135|  1.69M|  shape[n] = extent;
  136|  1.69M|  src_bstrides[n] = src_stride;
  137|  1.69M|  dst_bstrides[n] = dst_stride;
  138|  1.69M|  return n + 1;
  139|  1.69M|}
b2nd_utils.c:copy_box:
   69|   539k|                     uint8_t *dst, const int64_t *dst_strides) {
   70|   539k|  const int64_t row_nbytes = shape[0];
   71|   539k|  const int64_t nrows = shape[1];
   72|   539k|  const int64_t src_row_stride = src_strides[1];
   73|   539k|  const int64_t dst_row_stride = dst_strides[1];
   74|   539k|  int64_t index[B2ND_MAX_DIM];
   75|   582k|  for (int i = 2; i < ndim; ++i) {
  ------------------
  |  Branch (75:19): [True: 43.3k, False: 539k]
  ------------------
   76|  43.3k|    index[i] = 0;
   77|  43.3k|  }
   78|   846k|  for (;;) {
   79|   846k|    int64_t src_offset = 0;
   80|   846k|    int64_t dst_offset = 0;
   81|  1.34M|    for (int i = 2; i < ndim; ++i) {
  ------------------
  |  Branch (81:21): [True: 502k, False: 846k]
  ------------------
   82|   502k|      src_offset += index[i] * src_strides[i];
   83|   502k|      dst_offset += index[i] * dst_strides[i];
   84|   502k|    }
   85|   846k|    if (src == NULL) {
  ------------------
  |  Branch (85:9): [True: 1.62k, False: 844k]
  ------------------
   86|  1.62k|      uint8_t *row = dst + dst_offset;
   87|  18.0k|      for (int64_t r = 0; r < nrows; ++r) {
  ------------------
  |  Branch (87:27): [True: 16.3k, False: 1.62k]
  ------------------
   88|  16.3k|        memset(row, 0, (size_t) row_nbytes);
   89|  16.3k|        row += dst_row_stride;
   90|  16.3k|      }
   91|   844k|    } else {
   92|   844k|      copy_rows(dst + dst_offset, dst_row_stride, src + src_offset, src_row_stride, nrows, row_nbytes);
   93|   844k|    }
   94|   846k|    int i = 2;
   95|   913k|    while (i < ndim && ++index[i] == shape[i]) {
  ------------------
  |  Branch (95:12): [True: 374k, False: 539k]
  |  Branch (95:24): [True: 67.0k, False: 307k]
  ------------------
   96|  67.0k|      index[i] = 0;
   97|  67.0k|      ++i;
   98|  67.0k|    }
   99|   846k|    if (i == ndim) {
  ------------------
  |  Branch (99:9): [True: 539k, False: 307k]
  ------------------
  100|   539k|      break;
  101|   539k|    }
  102|   846k|  }
  103|   539k|}
b2nd_utils.c:copy_rows:
   23|   844k|                             int64_t nrows, int64_t row_nbytes) {
   24|   844k|#define COPY_ROWS(stmt)                     \
   25|   844k|  for (int64_t r = nrows; r > 0; --r) {     \
   26|   844k|    stmt;                                   \
   27|   844k|    dst += dst_stride;                      \
   28|   844k|    src += src_stride;                      \
   29|   844k|  }
   30|   844k|#define MOVE_2X(n)                                                     \
   31|   844k|  memcpy(dst, src, n);                                                 \
   32|   844k|  memcpy(dst + row_nbytes - (n), src + row_nbytes - (n), n)
   33|       |
   34|   844k|  if (row_nbytes > 64) {
  ------------------
  |  Branch (34:7): [True: 52.8k, False: 791k]
  ------------------
   35|  52.8k|    COPY_ROWS(memcpy(dst, src, (size_t) row_nbytes))
  ------------------
  |  |   25|   273k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 220k, False: 52.8k]
  |  |  ------------------
  |  |   26|   220k|    stmt;                                   \
  |  |   27|   220k|    dst += dst_stride;                      \
  |  |   28|   220k|    src += src_stride;                      \
  |  |   29|   220k|  }
  ------------------
   36|   791k|  } else if (row_nbytes > 32) {
  ------------------
  |  Branch (36:14): [True: 38.9k, False: 752k]
  ------------------
   37|  38.9k|    COPY_ROWS(MOVE_2X(32))
  ------------------
  |  |   25|   207k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 168k, False: 38.9k]
  |  |  ------------------
  |  |   26|   168k|    stmt;                                   \
  |  |   27|   168k|    dst += dst_stride;                      \
  |  |   28|   168k|    src += src_stride;                      \
  |  |   29|   168k|  }
  ------------------
   38|   752k|  } else if (row_nbytes == 32) {
  ------------------
  |  Branch (38:14): [True: 12.0k, False: 740k]
  ------------------
   39|  12.0k|    COPY_ROWS(memcpy(dst, src, 32))
  ------------------
  |  |   25|  58.8k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 46.7k, False: 12.0k]
  |  |  ------------------
  |  |   26|  46.7k|    stmt;                                   \
  |  |   27|  46.7k|    dst += dst_stride;                      \
  |  |   28|  46.7k|    src += src_stride;                      \
  |  |   29|  46.7k|  }
  ------------------
   40|   740k|  } else if (row_nbytes > 16) {
  ------------------
  |  Branch (40:14): [True: 51.9k, False: 688k]
  ------------------
   41|  51.9k|    COPY_ROWS(MOVE_2X(16))
  ------------------
  |  |   25|   244k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 192k, False: 51.9k]
  |  |  ------------------
  |  |   26|   192k|    stmt;                                   \
  |  |   27|   192k|    dst += dst_stride;                      \
  |  |   28|   192k|    src += src_stride;                      \
  |  |   29|   192k|  }
  ------------------
   42|   688k|  } else if (row_nbytes == 16) {
  ------------------
  |  Branch (42:14): [True: 10.2k, False: 678k]
  ------------------
   43|  10.2k|    COPY_ROWS(memcpy(dst, src, 16))
  ------------------
  |  |   25|  58.7k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 48.5k, False: 10.2k]
  |  |  ------------------
  |  |   26|  48.5k|    stmt;                                   \
  |  |   27|  48.5k|    dst += dst_stride;                      \
  |  |   28|  48.5k|    src += src_stride;                      \
  |  |   29|  48.5k|  }
  ------------------
   44|   678k|  } else if (row_nbytes > 8) {
  ------------------
  |  Branch (44:14): [True: 24.8k, False: 653k]
  ------------------
   45|  24.8k|    COPY_ROWS(MOVE_2X(8))
  ------------------
  |  |   25|   130k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 105k, False: 24.8k]
  |  |  ------------------
  |  |   26|   105k|    stmt;                                   \
  |  |   27|   105k|    dst += dst_stride;                      \
  |  |   28|   105k|    src += src_stride;                      \
  |  |   29|   105k|  }
  ------------------
   46|   653k|  } else if (row_nbytes == 8) {
  ------------------
  |  Branch (46:14): [True: 157k, False: 496k]
  ------------------
   47|   157k|    COPY_ROWS(memcpy(dst, src, 8))
  ------------------
  |  |   25|  1.04M|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 886k, False: 157k]
  |  |  ------------------
  |  |   26|   886k|    stmt;                                   \
  |  |   27|   886k|    dst += dst_stride;                      \
  |  |   28|   886k|    src += src_stride;                      \
  |  |   29|   886k|  }
  ------------------
   48|   496k|  } else if (row_nbytes > 4) {
  ------------------
  |  Branch (48:14): [True: 223k, False: 272k]
  ------------------
   49|   223k|    COPY_ROWS(MOVE_2X(4))
  ------------------
  |  |   25|  1.50M|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 1.28M, False: 223k]
  |  |  ------------------
  |  |   26|  1.28M|    stmt;                                   \
  |  |   27|  1.28M|    dst += dst_stride;                      \
  |  |   28|  1.28M|    src += src_stride;                      \
  |  |   29|  1.28M|  }
  ------------------
   50|   272k|  } else if (row_nbytes == 4) {
  ------------------
  |  Branch (50:14): [True: 64.8k, False: 207k]
  ------------------
   51|  64.8k|    COPY_ROWS(memcpy(dst, src, 4))
  ------------------
  |  |   25|   480k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 415k, False: 64.8k]
  |  |  ------------------
  |  |   26|   415k|    stmt;                                   \
  |  |   27|   415k|    dst += dst_stride;                      \
  |  |   28|   415k|    src += src_stride;                      \
  |  |   29|   415k|  }
  ------------------
   52|   207k|  } else if (row_nbytes > 2) {
  ------------------
  |  Branch (52:14): [True: 32.5k, False: 174k]
  ------------------
   53|  32.5k|    COPY_ROWS(MOVE_2X(2))
  ------------------
  |  |   25|   261k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 229k, False: 32.5k]
  |  |  ------------------
  |  |   26|   229k|    stmt;                                   \
  |  |   27|   229k|    dst += dst_stride;                      \
  |  |   28|   229k|    src += src_stride;                      \
  |  |   29|   229k|  }
  ------------------
   54|   174k|  } else if (row_nbytes == 2) {
  ------------------
  |  Branch (54:14): [True: 64.1k, False: 110k]
  ------------------
   55|  64.1k|    COPY_ROWS(memcpy(dst, src, 2))
  ------------------
  |  |   25|   408k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 344k, False: 64.1k]
  |  |  ------------------
  |  |   26|   344k|    stmt;                                   \
  |  |   27|   344k|    dst += dst_stride;                      \
  |  |   28|   344k|    src += src_stride;                      \
  |  |   29|   344k|  }
  ------------------
   56|   110k|  } else {
   57|   110k|    COPY_ROWS(*dst = *src)
  ------------------
  |  |   25|   769k|  for (int64_t r = nrows; r > 0; --r) {     \
  |  |  ------------------
  |  |  |  Branch (25:27): [True: 658k, False: 110k]
  |  |  ------------------
  |  |   26|   658k|    stmt;                                   \
  |  |   27|   658k|    dst += dst_stride;                      \
  |  |   28|   658k|    src += src_stride;                      \
  |  |   29|   658k|  }
  ------------------
   58|   110k|  }
   59|   844k|#undef MOVE_2X
   60|   844k|#undef COPY_ROWS
   61|   844k|}

bshuf_trans_byte_bitrow_AVX:
  131|    146|                                    const size_t elem_size) {
  132|       |
  133|    146|  size_t hh, ii, jj, kk, mm;
  134|    146|  const char* in_b = (const char*) in;
  135|    146|  char* out_b = (char*) out;
  136|       |
  137|    146|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    146|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 146]
  |  |  ------------------
  ------------------
  138|       |
  139|    146|  size_t nrows = 8 * elem_size;
  140|    146|  size_t nbyte_row = size / 8;
  141|       |
  142|    146|  if (elem_size % 4) return bshuf_trans_byte_bitrow_SSE(in, out, size,
  ------------------
  |  Branch (142:7): [True: 71, False: 75]
  ------------------
  143|     71|                                                        elem_size);
  144|       |
  145|     75|  __m256i ymm_0[8];
  146|     75|  __m256i ymm_1[8];
  147|     75|  __m256i ymm_storeage[8][4];
  148|       |
  149|  36.7k|  for (jj = 0; jj + 31 < nbyte_row; jj += 32) {
  ------------------
  |  Branch (149:16): [True: 36.7k, False: 75]
  ------------------
  150|   365k|    for (ii = 0; ii + 3 < elem_size; ii += 4) {
  ------------------
  |  Branch (150:18): [True: 328k, False: 36.7k]
  ------------------
  151|  1.64M|      for (hh = 0; hh < 4; hh ++) {
  ------------------
  |  Branch (151:20): [True: 1.31M, False: 328k]
  ------------------
  152|       |
  153|  11.8M|        for (kk = 0; kk < 8; kk ++){
  ------------------
  |  Branch (153:22): [True: 10.5M, False: 1.31M]
  ------------------
  154|  10.5M|          ymm_0[kk] = _mm256_loadu_si256((__m256i *) &in_b[
  155|  10.5M|              (ii * 8 + hh * 8 + kk) * nbyte_row + jj]);
  156|  10.5M|        }
  157|       |
  158|  6.57M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (158:22): [True: 5.25M, False: 1.31M]
  ------------------
  159|  5.25M|          ymm_1[kk] = _mm256_unpacklo_epi8(ymm_0[kk * 2],
  160|  5.25M|                                           ymm_0[kk * 2 + 1]);
  161|  5.25M|          ymm_1[kk + 4] = _mm256_unpackhi_epi8(ymm_0[kk * 2],
  162|  5.25M|                                               ymm_0[kk * 2 + 1]);
  163|  5.25M|        }
  164|       |
  165|  3.94M|        for (kk = 0; kk < 2; kk ++){
  ------------------
  |  Branch (165:22): [True: 2.62M, False: 1.31M]
  ------------------
  166|  7.88M|          for (mm = 0; mm < 2; mm ++){
  ------------------
  |  Branch (166:24): [True: 5.25M, False: 2.62M]
  ------------------
  167|  5.25M|            ymm_0[kk * 4 + mm] = _mm256_unpacklo_epi16(
  168|  5.25M|                ymm_1[kk * 4 + mm * 2],
  169|  5.25M|                ymm_1[kk * 4 + mm * 2 + 1]);
  170|  5.25M|            ymm_0[kk * 4 + mm + 2] = _mm256_unpackhi_epi16(
  171|  5.25M|                ymm_1[kk * 4 + mm * 2],
  172|  5.25M|                ymm_1[kk * 4 + mm * 2 + 1]);
  173|  5.25M|          }
  174|  2.62M|        }
  175|       |
  176|  6.57M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (176:22): [True: 5.25M, False: 1.31M]
  ------------------
  177|  5.25M|          ymm_1[kk * 2] = _mm256_unpacklo_epi32(ymm_0[kk * 2],
  178|  5.25M|                                                ymm_0[kk * 2 + 1]);
  179|  5.25M|          ymm_1[kk * 2 + 1] = _mm256_unpackhi_epi32(ymm_0[kk * 2],
  180|  5.25M|                                                    ymm_0[kk * 2 + 1]);
  181|  5.25M|        }
  182|       |
  183|  11.8M|        for (kk = 0; kk < 8; kk ++){
  ------------------
  |  Branch (183:22): [True: 10.5M, False: 1.31M]
  ------------------
  184|  10.5M|          ymm_storeage[kk][hh] = ymm_1[kk];
  185|  10.5M|        }
  186|  1.31M|      }
  187|       |
  188|  2.95M|      for (mm = 0; mm < 8; mm ++) {
  ------------------
  |  Branch (188:20): [True: 2.62M, False: 328k]
  ------------------
  189|       |
  190|  13.1M|        for (kk = 0; kk < 4; kk ++){
  ------------------
  |  Branch (190:22): [True: 10.5M, False: 2.62M]
  ------------------
  191|  10.5M|          ymm_0[kk] = ymm_storeage[mm][kk];
  192|  10.5M|        }
  193|       |
  194|  2.62M|        ymm_1[0] = _mm256_unpacklo_epi64(ymm_0[0], ymm_0[1]);
  195|  2.62M|        ymm_1[1] = _mm256_unpacklo_epi64(ymm_0[2], ymm_0[3]);
  196|  2.62M|        ymm_1[2] = _mm256_unpackhi_epi64(ymm_0[0], ymm_0[1]);
  197|  2.62M|        ymm_1[3] = _mm256_unpackhi_epi64(ymm_0[2], ymm_0[3]);
  198|       |
  199|  2.62M|        ymm_0[0] = _mm256_permute2x128_si256(ymm_1[0], ymm_1[1], 32);
  200|  2.62M|        ymm_0[1] = _mm256_permute2x128_si256(ymm_1[2], ymm_1[3], 32);
  201|  2.62M|        ymm_0[2] = _mm256_permute2x128_si256(ymm_1[0], ymm_1[1], 49);
  202|  2.62M|        ymm_0[3] = _mm256_permute2x128_si256(ymm_1[2], ymm_1[3], 49);
  203|       |
  204|  2.62M|        _mm256_storeu_si256((__m256i *) &out_b[
  205|  2.62M|            (jj + mm * 2 + 0 * 16) * nrows + ii * 8], ymm_0[0]);
  206|  2.62M|        _mm256_storeu_si256((__m256i *) &out_b[
  207|  2.62M|            (jj + mm * 2 + 0 * 16 + 1) * nrows + ii * 8], ymm_0[1]);
  208|  2.62M|        _mm256_storeu_si256((__m256i *) &out_b[
  209|  2.62M|            (jj + mm * 2 + 1 * 16) * nrows + ii * 8], ymm_0[2]);
  210|  2.62M|        _mm256_storeu_si256((__m256i *) &out_b[
  211|  2.62M|            (jj + mm * 2 + 1 * 16 + 1) * nrows + ii * 8], ymm_0[3]);
  212|  2.62M|      }
  213|   328k|    }
  214|  36.7k|  }
  215|  59.5k|  for (ii = 0; ii < nrows; ii ++ ) {
  ------------------
  |  Branch (215:16): [True: 59.5k, False: 75]
  ------------------
  216|   765k|    for (jj = nbyte_row - nbyte_row % 32; jj < nbyte_row; jj ++) {
  ------------------
  |  Branch (216:43): [True: 705k, False: 59.5k]
  ------------------
  217|   705k|      out_b[jj * nrows + ii] = in_b[ii * nbyte_row + jj];
  218|   705k|    }
  219|  59.5k|  }
  220|     75|  return size * elem_size;
  221|    146|}
bshuf_shuffle_bit_eightelem_AVX:
  242|    146|                                        const size_t elem_size) {
  243|       |
  244|    146|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    146|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 146]
  |  |  ------------------
  ------------------
  245|       |
  246|       |  // With a bit of care, this could be written such that such that it is
  247|       |  // in_buf = out_buf safe.
  248|    146|  const char* in_b = (const char*) in;
  249|    146|  char* out_b = (char*) out;
  250|       |
  251|    146|  size_t ii, jj, kk;
  252|    146|  size_t nbyte = elem_size * size;
  253|       |
  254|    146|  __m256i ymm;
  255|    146|  int32_t bt;
  256|       |
  257|    146|  if (elem_size <= 2) {
  ------------------
  |  Branch (257:7): [True: 0, False: 146]
  ------------------
  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|    146|  } else if (elem_size % 4) {
  ------------------
  |  Branch (275:14): [True: 71, False: 75]
  ------------------
  276|     71|    return bshuf_shuffle_bit_eightelem_SSE(in, out, size, elem_size);
  277|     75|  } else {
  278|  1.93k|    for (jj = 0; jj + 31 < 8 * elem_size; jj += 32) {
  ------------------
  |  Branch (278:18): [True: 1.86k, False: 75]
  ------------------
  279|  10.5M|      for (ii = 0; ii + 8 * elem_size - 1 < nbyte;
  ------------------
  |  Branch (279:20): [True: 10.5M, False: 1.86k]
  ------------------
  280|  10.5M|           ii += 8 * elem_size) {
  281|  10.5M|        ymm = _mm256_loadu_si256((__m256i *) &in_b[ii + jj]);
  282|  94.8M|        for (kk = 0; kk < 8; kk++) {
  ------------------
  |  Branch (282:22): [True: 84.3M, False: 10.5M]
  ------------------
  283|  84.3M|          bt = _mm256_movemask_epi8(ymm);
  284|  84.3M|          ymm = _mm256_slli_epi16(ymm, 1);
  285|  84.3M|          size_t ind = (ii + jj / 8 + (7 - kk) * elem_size);
  286|  84.3M|          * (int32_t *) &out_b[ind] = bt;
  287|  84.3M|        }
  288|  10.5M|      }
  289|  1.86k|    }
  290|     75|  }
  291|     75|  return size * elem_size;
  292|    146|}
bshuf_untrans_bit_elem_AVX:
  297|    352|                                   const size_t elem_size, void* tmp_buf) {
  298|       |
  299|    352|  int64_t count;
  300|       |
  301|    352|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|    352|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 352]
  |  |  ------------------
  ------------------
  302|       |
  303|    352|  if (elem_size == 1) return bshuf_untrans_bit_byte_SSE(in, out, size);
  ------------------
  |  Branch (303:7): [True: 57, False: 295]
  ------------------
  304|    295|  if ((elem_size == 2 || elem_size == 4 || elem_size == 8 || elem_size == 16)
  ------------------
  |  Branch (304:8): [True: 46, False: 249]
  |  Branch (304:26): [True: 51, False: 198]
  |  Branch (304:44): [True: 39, False: 159]
  |  Branch (304:62): [True: 13, False: 146]
  ------------------
  305|    149|      && size <= INT32_MAX / elem_size) {
  ------------------
  |  Branch (305:10): [True: 149, False: 0]
  ------------------
  306|    965|    for (size_t j = 0; j < elem_size; ++j) {
  ------------------
  |  Branch (306:24): [True: 816, False: 149]
  ------------------
  307|    816|      bshuf_untrans_bit_byte_SSE((const uint8_t*)in + j * size, (uint8_t*)tmp_buf + j * size, size);
  308|    816|    }
  309|    149|    unshuffle_avx2((int32_t)elem_size, (int32_t)(size * elem_size), tmp_buf, out);
  310|    149|    return size * elem_size;
  311|    149|  }
  312|    146|  count = bshuf_trans_byte_bitrow_AVX(in, tmp_buf, size, elem_size);
  313|    146|  CHECK_ERR(count);
  ------------------
  |  |   40|    146|        do {                              \
  |  |   41|    146|          if ((count) < 0)                \
  |  |  ------------------
  |  |  |  Branch (41:15): [True: 0, False: 146]
  |  |  ------------------
  |  |   42|    146|            return count;                 \
  |  |   43|    146|         } while (0)
  |  |  ------------------
  |  |  |  Branch (43:19): [Folded, False: 146]
  |  |  ------------------
  ------------------
  314|    146|  count =  bshuf_shuffle_bit_eightelem_AVX(tmp_buf, out, size, elem_size);
  315|       |
  316|    146|  return count;
  317|    146|}

bshuf_shuffle_bit_eightelem_scal:
  194|     46|        const size_t size, const size_t elem_size) {
  195|       |
  196|     46|  const char *in_b;
  197|     46|  char *out_b;
  198|     46|  uint64_t x, t;
  199|     46|  size_t ii, jj, kk;
  200|     46|  size_t nbyte, out_index;
  201|       |
  202|     46|  uint64_t e=1;
  203|     46|  const int little_endian = *(uint8_t *) &e == 1;
  204|     46|  const size_t elem_skip = little_endian ? elem_size : -elem_size;
  ------------------
  |  Branch (204:28): [True: 46, False: 0]
  ------------------
  205|     46|  const uint64_t elem_offset = little_endian ? 0 : 7 * elem_size;
  ------------------
  |  Branch (205:32): [True: 46, False: 0]
  ------------------
  206|       |
  207|     46|  CHECK_MULT_EIGHT(size);
  ------------------
  |  |   35|     46|#define CHECK_MULT_EIGHT(n) if (n % 8) return -80;
  |  |  ------------------
  |  |  |  Branch (35:33): [True: 0, False: 46]
  |  |  ------------------
  ------------------
  208|       |
  209|     46|  in_b = (const char*) in;
  210|     46|  out_b = (char*) out;
  211|       |
  212|     46|  nbyte = elem_size * size;
  213|       |
  214|  2.87k|  for (jj = 0; jj < 8 * elem_size; jj += 8) {
  ------------------
  |  Branch (214:16): [True: 2.82k, False: 46]
  ------------------
  215|  1.83M|    for (ii = 0; ii + 8 * elem_size - 1 < nbyte; ii += 8 * elem_size) {
  ------------------
  |  Branch (215:18): [True: 1.82M, False: 2.82k]
  ------------------
  216|  1.82M|      x = *((uint64_t*) &in_b[ii + jj]);
  217|  1.82M|      if (little_endian) {
  ------------------
  |  Branch (217:11): [True: 1.82M, False: 0]
  ------------------
  218|  1.82M|        TRANS_BIT_8X8(x, t);
  ------------------
  |  |   54|  1.82M|#define TRANS_BIT_8X8(x, t) {                                               \
  |  |   55|  1.82M|        t = (x ^ (x >> 7)) & 0x00AA00AA00AA00AALL;                          \
  |  |   56|  1.82M|        x = x ^ t ^ (t << 7);                                               \
  |  |   57|  1.82M|        t = (x ^ (x >> 14)) & 0x0000CCCC0000CCCCLL;                         \
  |  |   58|  1.82M|        x = x ^ t ^ (t << 14);                                              \
  |  |   59|  1.82M|        t = (x ^ (x >> 28)) & 0x00000000F0F0F0F0LL;                         \
  |  |   60|  1.82M|        x = x ^ t ^ (t << 28);                                              \
  |  |   61|  1.82M|    }
  ------------------
  219|  1.82M|      } 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|  16.4M|      for (kk = 0; kk < 8; kk++) {
  ------------------
  |  Branch (222:20): [True: 14.6M, False: 1.82M]
  ------------------
  223|  14.6M|        out_index = ii + jj / 8 + elem_offset + kk * elem_skip;
  224|  14.6M|        *((uint8_t*) &out_b[out_index]) = x;
  225|  14.6M|        x = x >> 8;
  226|  14.6M|      }
  227|  1.82M|    }
  228|  2.82k|  }
  229|     46|  return size * elem_size;
  230|     46|}

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

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

blosc2.c:is_little_endian:
   42|  71.5M|static bool is_little_endian(void) {
   43|  71.5M|  static const int i = 1;
   44|  71.5M|  char* p = (char*)&i;
   45|       |
   46|  71.5M|  if (p[0] == 1) {
  ------------------
  |  Branch (46:7): [True: 71.5M, False: 0]
  ------------------
   47|  71.5M|    return true;
   48|  71.5M|  }
   49|      0|  else {
   50|       |    return false;
   51|      0|  }
   52|  71.5M|}
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|  31.3M|static inline void _sw32(void* dest, int32_t a) {
  242|  31.3M|  uint8_t* dest_ = (uint8_t*)dest;
  243|  31.3M|  uint8_t* pa = (uint8_t*)&a;
  244|       |
  245|  31.3M|  bool little_endian = is_little_endian();
  246|  31.3M|  if (little_endian) {
  ------------------
  |  Branch (246:7): [True: 31.3M, False: 0]
  ------------------
  247|  31.3M|    memcpy(dest_, &a, sizeof(a));;
  248|  31.3M|  }
  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|  31.3M|}
blosc2.c:sw32_:
  216|  11.3M|static inline int32_t sw32_(const void* pa) {
  217|  11.3M|  int32_t idest;
  218|       |
  219|  11.3M|  bool little_endian = is_little_endian();
  220|  11.3M|  if (little_endian) {
  ------------------
  |  Branch (220:7): [True: 11.3M, False: 0]
  ------------------
  221|  11.3M|    memcpy(&idest, pa, sizeof(idest));
  222|  11.3M|  }
  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|  11.3M|  return idest;
  238|  11.3M|}
blosc2.c:filters_contain:
  131|  2.96M|static inline bool filters_contain(const uint8_t *filters, uint8_t id) {
  132|  20.7M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (132:19): [True: 17.8M, False: 2.96M]
  ------------------
  133|  17.8M|    if (filters[i] == id) {
  ------------------
  |  Branch (133:9): [True: 18, False: 17.8M]
  ------------------
  134|     18|      return true;
  135|     18|    }
  136|  17.8M|  }
  137|  2.96M|  return false;
  138|  2.96M|}
schunk.c:blosc2_nchunks_to_offsets_nbytes:
  103|  3.40k|static inline bool blosc2_nchunks_to_offsets_nbytes(int64_t nchunks, int32_t *off_nbytes) {
  104|  3.40k|  const int64_t max_nchunks = INT32_MAX / (int64_t)sizeof(int64_t);
  105|  3.40k|  if (nchunks < 0 || nchunks > max_nchunks) {
  ------------------
  |  Branch (105:7): [True: 0, False: 3.40k]
  |  Branch (105:22): [True: 0, False: 3.40k]
  ------------------
  106|      0|    return false;
  107|      0|  }
  108|  3.40k|  if (off_nbytes != NULL) {
  ------------------
  |  Branch (108:7): [True: 0, False: 3.40k]
  ------------------
  109|      0|    *off_nbytes = (int32_t)(nchunks * (int64_t)sizeof(int64_t));
  110|      0|  }
  111|       |  return true;
  112|  3.40k|}
schunk.c:get_chunk_flags2:
  121|  3.44M|static inline uint8_t get_chunk_flags2(const uint8_t *chunk, int32_t chunk_cbytes) {
  122|  3.44M|  uint8_t flags = chunk[BLOSC2_CHUNK_FLAGS];
  123|  3.44M|  bool extended_header = (flags & BLOSC_DOSHUFFLE) && (flags & BLOSC_DOBITSHUFFLE);
  ------------------
  |  Branch (123:26): [True: 3.44M, False: 0]
  |  Branch (123:55): [True: 3.44M, False: 0]
  ------------------
  124|  3.44M|  if (!extended_header || chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (124:7): [True: 0, False: 3.44M]
  |  Branch (124:27): [True: 0, False: 3.44M]
  ------------------
  125|      0|    return 0;
  126|      0|  }
  127|  3.44M|  return chunk[BLOSC2_CHUNK_BLOSC2_FLAGS2];
  128|  3.44M|}
schunk.c:chunksize_after_adding:
  166|   935k|                                         int32_t nbytes, bool at_end) {
  167|   935k|  if (*chunksize == 0) {
  ------------------
  |  Branch (167:7): [True: 0, False: 935k]
  ------------------
  168|      0|    return true;
  169|      0|  }
  170|   935k|  int32_t size = (*chunksize == -1) ? nbytes : *chunksize;
  ------------------
  |  Branch (170:18): [True: 0, False: 935k]
  ------------------
  171|   935k|  if (nchunks > 0 && (last_nbytes < size || nbytes > size || (!at_end && nbytes != size))) {
  ------------------
  |  Branch (171:7): [True: 928k, False: 6.85k]
  |  Branch (171:23): [True: 0, False: 928k]
  |  Branch (171:45): [True: 0, False: 928k]
  |  Branch (171:63): [True: 110k, False: 818k]
  |  Branch (171:74): [True: 0, False: 110k]
  ------------------
  172|      0|    *chunksize = 0;
  173|      0|    return true;
  174|      0|  }
  175|   935k|  if (size > 0 && nbytes > size) {
  ------------------
  |  Branch (175:7): [True: 935k, False: 0]
  |  Branch (175:19): [True: 0, False: 935k]
  ------------------
  176|      0|    return false;
  177|      0|  }
  178|   935k|  *chunksize = size;
  179|       |  return true;
  180|   935k|}
schunk.c:chunk_special_in_offset:
  143|  1.00M|static inline int chunk_special_in_offset(const uint8_t *chunk, int32_t cbytes) {
  144|  1.00M|  if (cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.00M]
  ------------------
  145|      0|    return 0;
  146|      0|  }
  147|  1.00M|  int special_value = (chunk[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
  148|  1.00M|  switch (special_value) {
  149|   376k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (149:5): [True: 376k, False: 633k]
  ------------------
  150|   376k|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (150:5): [True: 0, False: 1.00M]
  ------------------
  151|   376k|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (151:5): [True: 0, False: 1.00M]
  ------------------
  152|   376k|      return special_value;
  153|   633k|    default:
  ------------------
  |  Branch (153:5): [True: 633k, False: 376k]
  ------------------
  154|   633k|      return 0;
  155|  1.00M|  }
  156|  1.00M|}
frame.c:endian_handler:
   56|  53.6M|{
   57|  53.6M|  bool little_endian = is_little_endian();
   58|  53.6M|  if (little_endian == little) {
  ------------------
  |  Branch (58:7): [True: 376k, False: 53.2M]
  ------------------
   59|   376k|    memcpy(dest, pa, size);
   60|   376k|  }
   61|  53.2M|  else {
   62|  53.2M|    uint8_t* pa_ = (uint8_t*)pa;
   63|  53.2M|    uint8_t pa2_[8];
   64|  53.2M|    switch (size) {
   65|  18.6M|      case 8:
  ------------------
  |  Branch (65:7): [True: 18.6M, False: 34.6M]
  ------------------
   66|  18.6M|        pa2_[0] = pa_[7];
   67|  18.6M|        pa2_[1] = pa_[6];
   68|  18.6M|        pa2_[2] = pa_[5];
   69|  18.6M|        pa2_[3] = pa_[4];
   70|  18.6M|        pa2_[4] = pa_[3];
   71|  18.6M|        pa2_[5] = pa_[2];
   72|  18.6M|        pa2_[6] = pa_[1];
   73|  18.6M|        pa2_[7] = pa_[0];
   74|  18.6M|        break;
   75|  26.4M|      case 4:
  ------------------
  |  Branch (75:7): [True: 26.4M, False: 26.8M]
  ------------------
   76|  26.4M|        pa2_[0] = pa_[3];
   77|  26.4M|        pa2_[1] = pa_[2];
   78|  26.4M|        pa2_[2] = pa_[1];
   79|  26.4M|        pa2_[3] = pa_[0];
   80|  26.4M|        break;
   81|  8.21M|      case 2:
  ------------------
  |  Branch (81:7): [True: 8.21M, False: 45.0M]
  ------------------
   82|  8.21M|        pa2_[0] = pa_[1];
   83|  8.21M|        pa2_[1] = pa_[0];
   84|  8.21M|        break;
   85|  4.83k|      case 1:
  ------------------
  |  Branch (85:7): [True: 4.83k, False: 53.2M]
  ------------------
   86|  4.83k|        pa2_[0] = pa_[0];
   87|  4.83k|        break;
   88|      0|      default:
  ------------------
  |  Branch (88:7): [True: 0, False: 53.2M]
  ------------------
   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|  53.2M|    }
   91|  53.2M|    memcpy(dest, pa2_, size);
   92|  53.2M|  }
   93|  53.6M|}
frame.c:is_little_endian:
   42|  53.6M|static bool is_little_endian(void) {
   43|  53.6M|  static const int i = 1;
   44|  53.6M|  char* p = (char*)&i;
   45|       |
   46|  53.6M|  if (p[0] == 1) {
  ------------------
  |  Branch (46:7): [True: 53.6M, False: 0]
  ------------------
   47|  53.6M|    return true;
   48|  53.6M|  }
   49|      0|  else {
   50|       |    return false;
   51|      0|  }
   52|  53.6M|}
frame.c:blosc2_nchunks_to_offsets_nbytes:
  103|  9.37M|static inline bool blosc2_nchunks_to_offsets_nbytes(int64_t nchunks, int32_t *off_nbytes) {
  104|  9.37M|  const int64_t max_nchunks = INT32_MAX / (int64_t)sizeof(int64_t);
  105|  9.37M|  if (nchunks < 0 || nchunks > max_nchunks) {
  ------------------
  |  Branch (105:7): [True: 0, False: 9.37M]
  |  Branch (105:22): [True: 52, False: 9.37M]
  ------------------
  106|     52|    return false;
  107|     52|  }
  108|  9.37M|  if (off_nbytes != NULL) {
  ------------------
  |  Branch (108:7): [True: 9.37M, False: 0]
  ------------------
  109|  9.37M|    *off_nbytes = (int32_t)(nchunks * (int64_t)sizeof(int64_t));
  110|  9.37M|  }
  111|       |  return true;
  112|  9.37M|}
frame.c:chunk_special_in_offset:
  143|  1.00M|static inline int chunk_special_in_offset(const uint8_t *chunk, int32_t cbytes) {
  144|  1.00M|  if (cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (144:7): [True: 0, False: 1.00M]
  ------------------
  145|      0|    return 0;
  146|      0|  }
  147|  1.00M|  int special_value = (chunk[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
  148|  1.00M|  switch (special_value) {
  149|   376k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (149:5): [True: 376k, False: 633k]
  ------------------
  150|   376k|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (150:5): [True: 0, False: 1.00M]
  ------------------
  151|   376k|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (151:5): [True: 0, False: 1.00M]
  ------------------
  152|   376k|      return special_value;
  153|   633k|    default:
  ------------------
  |  Branch (153:5): [True: 633k, False: 376k]
  ------------------
  154|   633k|      return 0;
  155|  1.00M|  }
  156|  1.00M|}
b2nd.c:filters_contain:
  131|  1.55M|static inline bool filters_contain(const uint8_t *filters, uint8_t id) {
  132|  10.8M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (132:19): [True: 9.31M, False: 1.55M]
  ------------------
  133|  9.31M|    if (filters[i] == id) {
  ------------------
  |  Branch (133:9): [True: 0, False: 9.31M]
  ------------------
  134|      0|      return true;
  135|      0|    }
  136|  9.31M|  }
  137|  1.55M|  return false;
  138|  1.55M|}

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

do_nothing:
  797|   229M|int do_nothing(const blosc2_context* context, int i, char cmode) {
  798|   229M|  uint8_t filter = context->filters[i];
  799|   229M|  if (filter == BLOSC_SHUFFLE) {
  ------------------
  |  Branch (799:7): [True: 50.9M, False: 178M]
  ------------------
  800|       |    // Shuffling single bytes is the identity, so skip it instead of copying the block
  801|  50.9M|    return shuffle_size(context, i) == 1;
  802|  50.9M|  }
  803|   178M|  if (cmode == 'c') {
  ------------------
  |  Branch (803:7): [True: 150M, False: 27.6M]
  ------------------
  804|   150M|    return (filter == BLOSC_NOFILTER);
  805|   150M|  } else {
  806|       |    // TRUNC_PREC do not have to be applied during decompression
  807|  27.6M|    return ((filter == BLOSC_NOFILTER) || (filter == BLOSC_TRUNC_PREC));
  ------------------
  |  Branch (807:13): [True: 27.6M, False: 7.31k]
  |  Branch (807:43): [True: 314, False: 7.00k]
  ------------------
  808|  27.6M|  }
  809|   178M|}
next_filter:
  812|  10.3M|int next_filter(const blosc2_context* context, int current_filter, char cmode) {
  813|  11.2M|  for (int i = current_filter - 1; i >= 0; i--) {
  ------------------
  |  Branch (813:36): [True: 11.0M, False: 148k]
  ------------------
  814|  11.0M|    if (!do_nothing(context, i, cmode)) {
  ------------------
  |  Branch (814:9): [True: 10.1M, False: 892k]
  ------------------
  815|  10.1M|      return context->filters[i];
  816|  10.1M|    }
  817|  11.0M|  }
  818|   148k|  return BLOSC_NOFILTER;
  819|  10.3M|}
last_filter:
  822|  21.8M|int last_filter(const blosc2_context* context, char cmode) {
  823|  21.8M|  int last_index = -1;
  824|   153M|  for (int i = BLOSC2_MAX_FILTERS - 1; i >= 0; i--) {
  ------------------
  |  Branch (824:40): [True: 131M, False: 21.8M]
  ------------------
  825|   131M|    if (!do_nothing(context, i, cmode))  {
  ------------------
  |  Branch (825:9): [True: 17.5M, False: 113M]
  ------------------
  826|  17.5M|      last_index = i;
  827|  17.5M|    }
  828|   131M|  }
  829|  21.8M|  return last_index;
  830|  21.8M|}
read_chunk_header:
  909|  27.0M|{
  910|  27.0M|  memset(header, 0, sizeof(blosc_header));
  911|       |
  912|  27.0M|  if (srcsize < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (912:7): [True: 0, False: 27.0M]
  ------------------
  913|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  914|      0|    return BLOSC2_ERROR_READ_BUFFER;
  915|      0|  }
  916|       |
  917|  27.0M|  memcpy(header, src, BLOSC_MIN_HEADER_LENGTH);
  918|       |
  919|  27.0M|  bool little_endian = is_little_endian();
  920|       |
  921|  27.0M|  if (!little_endian) {
  ------------------
  |  Branch (921:7): [True: 0, False: 27.0M]
  ------------------
  922|      0|    header->nbytes = bswap32_(header->nbytes);
  923|      0|    header->blocksize = bswap32_(header->blocksize);
  924|      0|    header->cbytes = bswap32_(header->cbytes);
  925|      0|  }
  926|       |
  927|  27.0M|  if (header->cbytes < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (927:7): [True: 17, False: 27.0M]
  ------------------
  928|     17|    BLOSC_TRACE_ERROR("`cbytes` is too small to read min header.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  929|     17|    return BLOSC2_ERROR_INVALID_HEADER;
  930|     17|  }
  931|  27.0M|  if (header->blocksize <= 0) {
  ------------------
  |  Branch (931:7): [True: 15, False: 27.0M]
  ------------------
  932|     15|    BLOSC_TRACE_ERROR("`blocksize` is zero");
  ------------------
  |  |   93|     15|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     15|    do {                                            \
  |  |  |  |   98|     15|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     15|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     15|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|     15|    return BLOSC2_ERROR_INVALID_HEADER;
  934|     15|  }
  935|  27.0M|  if (header->blocksize > BLOSC2_MAXBLOCKSIZE) {
  ------------------
  |  Branch (935:7): [True: 2, False: 27.0M]
  ------------------
  936|      2|    BLOSC_TRACE_ERROR("`blocksize` greater than maximum allowed");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  937|      2|    return BLOSC2_ERROR_INVALID_HEADER;
  938|      2|  }
  939|  27.0M|  if (header->typesize == 0) {
  ------------------
  |  Branch (939:7): [True: 2, False: 27.0M]
  ------------------
  940|      2|    BLOSC_TRACE_ERROR("`typesize` is zero.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|      2|    return BLOSC2_ERROR_INVALID_HEADER;
  942|      2|  }
  943|       |
  944|       |  /* Read extended header if it is wanted */
  945|  27.0M|  if ((extended_header) && (header->flags & BLOSC_DOSHUFFLE) && (header->flags & BLOSC_DOBITSHUFFLE)) {
  ------------------
  |  Branch (945:7): [True: 4.61M, False: 22.4M]
  |  Branch (945:28): [True: 4.61M, False: 355]
  |  Branch (945:65): [True: 4.61M, False: 30]
  ------------------
  946|  4.61M|    if (header->cbytes < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (946:9): [True: 1, False: 4.61M]
  ------------------
  947|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|      1|      return BLOSC2_ERROR_INVALID_HEADER;
  949|      1|    }
  950|  4.61M|    if (srcsize < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (950:9): [True: 0, False: 4.61M]
  ------------------
  951|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  952|      0|      return BLOSC2_ERROR_READ_BUFFER;
  953|      0|    }
  954|       |
  955|  4.61M|    memcpy((uint8_t *)header + BLOSC_MIN_HEADER_LENGTH, src + BLOSC_MIN_HEADER_LENGTH,
  956|  4.61M|      BLOSC_EXTENDED_HEADER_LENGTH - BLOSC_MIN_HEADER_LENGTH);
  957|       |
  958|  4.61M|    if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) && (header->blosc2_flags != 0)) {
  ------------------
  |  Branch (958:9): [True: 102, False: 4.61M]
  |  Branch (958:55): [True: 84, False: 18]
  ------------------
  959|     84|      int32_t special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
  960|     84|      if (special_type != 0) {
  ------------------
  |  Branch (960:11): [True: 1, False: 83]
  ------------------
  961|      1|        BLOSC_TRACE_ERROR("VL-block chunks cannot use special chunk encodings.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  962|      1|        return BLOSC2_ERROR_INVALID_HEADER;
  963|      1|      }
  964|     84|    }
  965|       |
  966|  4.61M|    int32_t special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
  967|  4.61M|    if (special_type != 0) {
  ------------------
  |  Branch (967:9): [True: 178k, False: 4.43M]
  ------------------
  968|   178k|      if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (968:11): [True: 159k, False: 19.3k]
  ------------------
  969|       |        // In this case, the actual type size must be derived from the cbytes
  970|   159k|        int32_t typesize = header->cbytes - BLOSC_EXTENDED_HEADER_LENGTH;
  971|   159k|        if (typesize <= 0) {
  ------------------
  |  Branch (971:13): [True: 1, False: 159k]
  ------------------
  972|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|      1|          return BLOSC2_ERROR_INVALID_HEADER;
  974|      1|        }
  975|   159k|        if (typesize > BLOSC2_MAXTYPESIZE) {
  ------------------
  |  Branch (975:13): [True: 0, False: 159k]
  ------------------
  976|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  977|      0|          return BLOSC2_ERROR_INVALID_HEADER;
  978|      0|        }
  979|   159k|        if (typesize > header->nbytes) {
  ------------------
  |  Branch (979:13): [True: 1, False: 159k]
  ------------------
  980|      1|          BLOSC_TRACE_ERROR("`typesize` is greater than `nbytes`");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|      1|          return BLOSC2_ERROR_INVALID_HEADER;
  982|      1|        }
  983|   159k|        if (header->nbytes % typesize != 0) {
  ------------------
  |  Branch (983:13): [True: 1, False: 159k]
  ------------------
  984|      1|          BLOSC_TRACE_ERROR("`nbytes` is not a multiple of typesize");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  985|      1|          return BLOSC2_ERROR_INVALID_HEADER;
  986|      1|        }
  987|   159k|      }
  988|  19.3k|      else {
  989|       |        // All-zero chunks fill with memset, which works regardless of element alignment.
  990|  19.3k|        if (special_type != BLOSC2_SPECIAL_ZERO
  ------------------
  |  Branch (990:13): [True: 69, False: 19.3k]
  ------------------
  991|     69|            && header->nbytes % header->typesize != 0) {
  ------------------
  |  Branch (991:16): [True: 1, False: 68]
  ------------------
  992|      1|          BLOSC_TRACE_ERROR("`nbytes` is not a multiple of typesize");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  993|      1|          return BLOSC2_ERROR_INVALID_HEADER;
  994|      1|        }
  995|  19.3k|      }
  996|   178k|    }
  997|       |    // The number of filters depends on the version of the header. Blosc2 alpha series
  998|       |    // did not initialize filters to zero beyond the max supported.
  999|  4.61M|    if (header->version == BLOSC2_VERSION_FORMAT_ALPHA) {
  ------------------
  |  Branch (999:9): [True: 108, False: 4.61M]
  ------------------
 1000|    108|      header->filters[5] = 0;
 1001|    108|      header->filters_meta[5] = 0;
 1002|    108|    }
 1003|  4.61M|  }
 1004|  22.4M|  else {
 1005|  22.4M|    flags_to_filters(header->flags, header->filters);
 1006|  22.4M|  }
 1007|  27.0M|  if (header->version > BLOSC2_VERSION_FORMAT &&
  ------------------
  |  Branch (1007:7): [True: 1.60M, False: 25.4M]
  ------------------
 1008|  1.60M|      (header->blosc2_flags2 & (uint8_t)~BLOSC2_VL_BLOCKS) != 0) {
  ------------------
  |  Branch (1008:7): [True: 1, False: 1.60M]
  ------------------
 1009|       |    /* Version from future with unsupported chunk features. */
 1010|      1|    return BLOSC2_ERROR_VERSION_SUPPORT;
 1011|      1|  }
 1012|  27.0M|  if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0 &&
  ------------------
  |  Branch (1012:7): [True: 100, False: 27.0M]
  ------------------
 1013|    100|      (header->flags & (uint8_t)BLOSC_MEMCPYED) != 0) {
  ------------------
  |  Branch (1013:7): [True: 1, False: 99]
  ------------------
 1014|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1015|      1|    return BLOSC2_ERROR_INVALID_HEADER;
 1016|      1|  }
 1017|  27.0M|  if ((header->blosc2_flags2 & BLOSC2_VL_BLOCKS) == 0 &&
  ------------------
  |  Branch (1017:7): [True: 27.0M, False: 99]
  ------------------
 1018|  27.0M|      header->nbytes > 0 && header->blocksize > header->nbytes) {
  ------------------
  |  Branch (1018:7): [True: 27.0M, False: 61]
  |  Branch (1018:29): [True: 3.84k, False: 27.0M]
  ------------------
 1019|  3.84k|    header->blocksize = header->nbytes;
 1020|  3.84k|  }
 1021|  27.0M|  return 0;
 1022|  27.0M|}
fill_codec:
 1178|      4|int fill_codec(blosc2_codec *codec) {
 1179|      4|  int rc = BLOSC2_ERROR_SUCCESS;
 1180|      4|  static_lock(&g_plugin_lock);
  ------------------
  |  |  132|      4|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 1181|       |  /* Unless another thread loaded it meanwhile */
 1182|      4|  if (codec->encoder == NULL || codec->decoder == NULL) {
  ------------------
  |  Branch (1182:7): [True: 4, False: 0]
  |  Branch (1182:33): [True: 0, False: 0]
  ------------------
 1183|      4|    rc = load_codec_locked(codec);
 1184|      4|  }
 1185|      4|  static_unlock(&g_plugin_lock);
  ------------------
  |  |  133|      4|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 1186|      4|  return rc;
 1187|      4|}
pipeline_forward:
 1318|  16.5M|                          uint8_t* dest, uint8_t* tmp) {
 1319|  16.5M|  blosc2_context* context = thread_context->parent_context;
 1320|  16.5M|  uint8_t* _src = (uint8_t*)src + offset;
 1321|  16.5M|  uint8_t* _tmp = tmp;
 1322|  16.5M|  uint8_t* _dest = dest;
 1323|  16.5M|  int32_t typesize = context->typesize;
 1324|  16.5M|  uint8_t* filters = context->filters;
 1325|  16.5M|  uint8_t* filters_meta = context->filters_meta;
 1326|  16.5M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 1327|  16.5M|  bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
  ------------------
  |  Branch (1327:31): [True: 12.9M, False: 3.58M]
  ------------------
 1328|       |
 1329|       |  /* Prefilter function */
 1330|  16.5M|  if (context->prefilter != NULL) {
  ------------------
  |  Branch (1330:7): [True: 12.9M, False: 3.58M]
  ------------------
 1331|       |    // Create new prefilter parameters for this block (must be private for each thread)
 1332|  12.9M|    blosc2_prefilter_params preparams;
 1333|  12.9M|    memcpy(&preparams, context->preparams, sizeof(preparams));
 1334|       |    // Calculate output_size based on number of elements and output typesize
 1335|  12.9M|    int32_t nelems = bsize / typesize;  // number of elements in the input block
 1336|       |    // If output_typesize is not set (0), default to input typesize (no type conversion)
 1337|  12.9M|    int32_t output_typesize_actual = (preparams.output_typesize > 0) ? preparams.output_typesize : typesize;
  ------------------
  |  Branch (1337:38): [True: 0, False: 12.9M]
  ------------------
 1338|  12.9M|    int32_t output_size = nelems * output_typesize_actual;  // output size in bytes
 1339|  12.9M|    preparams.output_typesize = output_typesize_actual;  // ensure it's set
 1340|       |    /* Legacy callbacks may leave bytes unwritten or accumulate into the output.
 1341|       |     * Only audited full-write callbacks may bypass this initialization. */
 1342|  12.9M|    if (!output_is_disposable && !context->prefilter_full_write) {
  ------------------
  |  Branch (1342:9): [True: 12.9M, False: 0]
  |  Branch (1342:34): [True: 0, False: 12.9M]
  ------------------
 1343|      0|      memset(_dest, 0, output_size);
 1344|      0|    }
 1345|  12.9M|    preparams.input = _src;
 1346|  12.9M|    preparams.output = _dest;
 1347|  12.9M|    preparams.output_size = output_size;
 1348|  12.9M|    preparams.output_offset = offset;
 1349|  12.9M|    preparams.nblock = offset / context->blocksize;
 1350|  12.9M|    preparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (1350:24): [True: 12.9M, False: 0]
  ------------------
 1351|  12.9M|    preparams.tid = thread_context->tid;
 1352|  12.9M|    preparams.ttmp = thread_context->tmp;
 1353|  12.9M|    preparams.ttmp_nbytes = thread_context->tmp_nbytes;
 1354|  12.9M|    preparams.ctx = context;
 1355|  12.9M|    preparams.output_is_disposable = output_is_disposable;
 1356|       |
 1357|  12.9M|    if (context->prefilter(&preparams) != 0) {
  ------------------
  |  Branch (1357:9): [True: 0, False: 12.9M]
  ------------------
 1358|      0|      if (output_is_disposable) {
  ------------------
  |  Branch (1358:11): [True: 0, False: 0]
  ------------------
 1359|       |        // Output is going to be discarded; no more filters are required
 1360|      0|        BLOSC_TRACE_INFO("Output is disposable");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1361|      0|        return _dest;
 1362|      0|      }
 1363|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1364|      0|      return NULL;
 1365|      0|    }
 1366|       |
 1367|  12.9M|    if (memcpyed) {
  ------------------
  |  Branch (1367:9): [True: 2.99M, False: 9.99M]
  ------------------
 1368|       |      // No more filters are required
 1369|  2.99M|      return _dest;
 1370|  2.99M|    }
 1371|  9.99M|    _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1372|  9.99M|  }
 1373|       |
 1374|       |  /* Process the filter pipeline */
 1375|  95.0M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1375:19): [True: 81.4M, False: 13.5M]
  ------------------
 1376|  81.4M|    int rc = BLOSC2_ERROR_SUCCESS;
 1377|  81.4M|    if (do_nothing(context, i, 'c')) {
  ------------------
  |  Branch (1377:9): [True: 69.9M, False: 11.4M]
  ------------------
 1378|  69.9M|      continue;
 1379|  69.9M|    }
 1380|  11.4M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1381|  11.4M|    int fused_size = fused_shuffle_bytedelta_size(context, i);
 1382|  11.4M|    if (fused_size && shuffle_bytedelta_forward(_src, _dest, bsize, fused_size)) {
  ------------------
  |  Branch (1382:9): [True: 0, False: 11.4M]
  |  Branch (1382:23): [True: 0, False: 0]
  ------------------
 1383|      0|      i++;
 1384|      0|      _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1385|      0|      continue;
 1386|      0|    }
 1387|  11.4M|#endif
 1388|  11.4M|    if (filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (1388:9): [True: 11.4M, False: 18.4E]
  ------------------
 1389|  11.4M|      switch (filters[i]) {
 1390|  11.4M|        case BLOSC_SHUFFLE:
  ------------------
  |  Branch (1390:9): [True: 11.4M, False: 155]
  ------------------
 1391|  11.4M|          blosc2_shuffle(shuffle_size(context, i), bsize, _src, _dest);
 1392|  11.4M|          break;
 1393|      0|        case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (1393:9): [True: 0, False: 11.4M]
  ------------------
 1394|      0|          if (context->blosc1_format && ((bsize / typesize) % 8) != 0) {
  ------------------
  |  Branch (1394:15): [True: 0, False: 0]
  |  Branch (1394:41): [True: 0, False: 0]
  ------------------
 1395|       |            // Format version 2 (Blosc1) only bit-shuffles blocks whose number of
 1396|       |            // elements is a multiple of 8; other blocks are stored unshuffled.
 1397|      0|            memcpy(_dest, _src, (size_t)bsize);
 1398|      0|          }
 1399|      0|          else if (bitshuffle(typesize, bsize, _src, _dest, bitshuffle_scratch(thread_context, bsize)) < 0) {
  ------------------
  |  Branch (1399:20): [True: 0, False: 0]
  ------------------
 1400|      0|            return NULL;
 1401|      0|          }
 1402|      0|          break;
 1403|      0|        case BLOSC_DELTA:
  ------------------
  |  Branch (1403:9): [True: 0, False: 11.4M]
  ------------------
 1404|      0|          delta_encoder(offset == 0 ? _src : src, offset, bsize, typesize, _src, _dest);
  ------------------
  |  Branch (1404:25): [True: 0, False: 0]
  ------------------
 1405|      0|          break;
 1406|      0|        case BLOSC_TRUNC_PREC:
  ------------------
  |  Branch (1406:9): [True: 0, False: 11.4M]
  ------------------
 1407|      0|          if (truncate_precision(filters_meta[i], typesize, bsize, _src, _dest) < 0) {
  ------------------
  |  Branch (1407:15): [True: 0, False: 0]
  ------------------
 1408|      0|            return NULL;
 1409|      0|          }
 1410|      0|          break;
 1411|      0|        default:
  ------------------
  |  Branch (1411:9): [True: 0, False: 11.4M]
  ------------------
 1412|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1413|      0|          return NULL;
 1414|  11.4M|      }
 1415|  11.4M|    }
 1416|  18.4E|    else {
 1417|       |      // Look for the filters_meta in user filters and run it
 1418|  18.4E|      for (uint64_t j = 0; j < g_nfilters; ++j) {
  ------------------
  |  Branch (1418:28): [True: 0, False: 18.4E]
  ------------------
 1419|      0|        if (g_filters[j].id == filters[i]) {
  ------------------
  |  Branch (1419:13): [True: 0, False: 0]
  ------------------
 1420|      0|          if (load_acquire_ptr(&g_filters[j].backward) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1420:15): [True: 0, False: 0]
  ------------------
 1421|       |            // Dynamically load library
 1422|      0|            if (fill_filter(&g_filters[j]) < 0) {
  ------------------
  |  Branch (1422:17): [True: 0, False: 0]
  ------------------
 1423|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1424|      0|              return NULL;
 1425|      0|            }
 1426|      0|          }
 1427|      0|          if (g_filters[j].forward != NULL) {
  ------------------
  |  Branch (1427:15): [True: 0, False: 0]
  ------------------
 1428|      0|            blosc2_cparams cparams;
 1429|      0|            blosc2_ctx_get_cparams(context, &cparams);
 1430|      0|            rc = g_filters[j].forward(_src, _dest, bsize, filters_meta[i], &cparams, g_filters[j].id);
 1431|      0|          } else {
 1432|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1433|      0|            return NULL;
 1434|      0|          }
 1435|      0|          if (rc != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1435:15): [True: 0, False: 0]
  ------------------
 1436|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1437|      0|            return NULL;
 1438|      0|          }
 1439|      0|          goto urfiltersuccess;
 1440|      0|        }
 1441|      0|      }
 1442|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1443|  18.4E|      return NULL;
 1444|       |
 1445|      0|      urfiltersuccess:;
 1446|       |
 1447|      0|    }
 1448|       |
 1449|       |    // do_nothing() skipped the filters that leave the block as it is
 1450|  11.4M|    _cycle_buffers_forward(&_src, &_dest, &_tmp, src + offset);
 1451|  11.4M|  }
 1452|  13.5M|  return _src;
 1453|  13.5M|}
pipeline_backward:
 1824|  5.22M|                      uint8_t* tmp2, int last_filter_index, int32_t nblock) {
 1825|  5.22M|  (void)tmp2;
 1826|  5.22M|  blosc2_context* context = thread_context->parent_context;
 1827|  5.22M|  int32_t typesize = context->typesize;
 1828|  5.22M|  uint8_t* filters = context->filters;
 1829|  5.22M|  uint8_t* filters_meta = context->filters_meta;
 1830|  5.22M|  uint8_t* _src = (next_filter(context, BLOSC2_MAX_FILTERS, 'd') == BLOSC_DELTA &&
  ------------------
  |  Branch (1830:20): [True: 149, False: 5.22M]
  ------------------
 1831|  5.22M|                   context->postfilter == NULL) ? (dest + offset) : src;
  ------------------
  |  Branch (1831:20): [True: 149, False: 0]
  ------------------
 1832|  5.22M|  uint8_t* _dest = tmp;
 1833|  5.22M|  int errcode = 0;
 1834|       |
 1835|  6.12M|  for (int i = BLOSC2_MAX_FILTERS - 1; i >= 0; i--) {
  ------------------
  |  Branch (1835:40): [True: 5.97M, False: 148k]
  ------------------
 1836|  5.97M|    if (do_nothing(context, i, 'd')) {
  ------------------
  |  Branch (1836:9): [True: 892k, False: 5.08M]
  ------------------
 1837|   892k|      continue;
 1838|   892k|    }
 1839|  5.08M|    int first_index = i;
 1840|  5.08M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1841|  5.08M|    int fused_size = fused_shuffle_bytedelta_size(context, i - 1);
 1842|  5.08M|    if (fused_size) {
  ------------------
  |  Branch (1842:9): [True: 72, False: 5.08M]
  ------------------
 1843|     72|      first_index = i - 1;
 1844|     72|    }
 1845|  5.08M|#endif
 1846|       |    // Delta filter requires the whole chunk ready. A fused inverse ends at
 1847|       |    // SHUFFLE's position, so select its sink using the pair's first index.
 1848|  5.08M|    int last_copy_filter = (last_filter_index == first_index) || (filters[i] == BLOSC_DELTA) ||
  ------------------
  |  Branch (1848:28): [True: 5.08M, False: 1.17k]
  |  Branch (1848:66): [True: 231, False: 945]
  ------------------
 1849|    945|                           (next_filter(context, first_index, 'd') == BLOSC_DELTA);
  ------------------
  |  Branch (1849:28): [True: 390, False: 555]
  ------------------
 1850|  5.08M|    if (last_copy_filter && context->postfilter == NULL &&
  ------------------
  |  Branch (1850:9): [True: 5.08M, False: 555]
  |  Branch (1850:29): [True: 4.96M, False: 116k]
  ------------------
 1851|  4.96M|        (filters[i] == BLOSC_DELTA || _src != dest + offset)) {
  ------------------
  |  Branch (1851:10): [True: 642, False: 4.96M]
  |  Branch (1851:39): [True: 4.96M, False: 73]
  ------------------
 1852|  4.96M|      _dest = dest + offset;
 1853|  4.96M|    } else {
 1854|   116k|      _dest = (_src == src) ? tmp : src;
  ------------------
  |  Branch (1854:15): [True: 116k, False: 286]
  ------------------
 1855|   116k|    }
 1856|  5.08M|    int rc = BLOSC2_ERROR_SUCCESS;
 1857|  5.08M|#ifdef BLOSC_USE_FUSED_SHUFFLE_BYTEDELTA
 1858|  5.08M|    if (fused_size && shuffle_bytedelta_backward(_src, _dest, bsize, fused_size)) {
  ------------------
  |  Branch (1858:9): [True: 72, False: 5.08M]
  |  Branch (1858:23): [True: 72, False: 0]
  ------------------
 1859|     72|      i--;
 1860|     72|      _src = _dest;
 1861|     72|      if (last_filter_index == i) {
  ------------------
  |  Branch (1861:11): [True: 49, False: 23]
  ------------------
 1862|     49|        break;
 1863|     49|      }
 1864|     23|      continue;
 1865|     72|    }
 1866|  5.08M|#endif
 1867|  5.08M|    if (filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (1867:9): [True: 5.08M, False: 411]
  ------------------
 1868|  5.08M|      switch (filters[i]) {
 1869|  5.08M|        case BLOSC_SHUFFLE:
  ------------------
  |  Branch (1869:9): [True: 5.08M, False: 1.13k]
  ------------------
 1870|  5.08M|          blosc2_unshuffle(shuffle_size(context, i), bsize, _src, _dest);
 1871|  5.08M|          break;
 1872|    465|        case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (1872:9): [True: 465, False: 5.08M]
  ------------------
 1873|    465|          if (bitunshuffle(typesize, bsize, _src, _dest, bitshuffle_scratch(thread_context, bsize),
  ------------------
  |  Branch (1873:15): [True: 0, False: 465]
  ------------------
 1874|    465|                           context->src[BLOSC2_CHUNK_VERSION]) < 0) {
 1875|      0|            return BLOSC2_ERROR_FILTER_PIPELINE;
 1876|      0|          }
 1877|    465|          break;
 1878|    642|        case BLOSC_DELTA:
  ------------------
  |  Branch (1878:9): [True: 642, False: 5.08M]
  ------------------
 1879|    642|          if (_src != _dest) {
  ------------------
  |  Branch (1879:15): [True: 41, False: 601]
  ------------------
 1880|     41|            memcpy(_dest, _src, (size_t)bsize);
 1881|     41|          }
 1882|    642|          if (offset != 0 && !thread_context->serial) {
  ------------------
  |  Branch (1882:15): [True: 152, False: 490]
  |  Branch (1882:30): [True: 0, False: 152]
  ------------------
 1883|      0|            delta_wait_dref(context);
 1884|      0|          }
 1885|    642|          delta_decoder(offset == 0 ? _dest : dest, offset, bsize, typesize, _dest);
  ------------------
  |  Branch (1885:25): [True: 490, False: 152]
  ------------------
 1886|    642|          break;
 1887|     25|        default:
  ------------------
  |  Branch (1887:9): [True: 25, False: 5.08M]
  ------------------
 1888|     25|          BLOSC_TRACE_ERROR("Filter %d not handled during decompression.", filters[i]);
  ------------------
  |  |   93|     25|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     25|    do {                                            \
  |  |  |  |   98|     25|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     25|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     25|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1889|     25|          errcode = -1;
 1890|  5.08M|      }
 1891|  5.08M|    } else {
 1892|       |        // Look for the filters_meta in user filters and run it
 1893|  1.57k|        for (uint64_t j = 0; j < g_nfilters; ++j) {
  ------------------
  |  Branch (1893:30): [True: 1.50k, False: 73]
  ------------------
 1894|  1.50k|          if (g_filters[j].id == filters[i]) {
  ------------------
  |  Branch (1894:15): [True: 338, False: 1.16k]
  ------------------
 1895|    338|            if (load_acquire_ptr(&g_filters[j].backward) == NULL) {
  ------------------
  |  |  144|    338|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1895:17): [True: 0, False: 338]
  ------------------
 1896|       |              // Dynamically load filter
 1897|      0|              if (fill_filter(&g_filters[j]) < 0) {
  ------------------
  |  Branch (1897:19): [True: 0, False: 0]
  ------------------
 1898|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1899|      0|                return BLOSC2_ERROR_FILTER_PIPELINE;
 1900|      0|              }
 1901|      0|            }
 1902|    338|            if (g_filters[j].backward != NULL) {
  ------------------
  |  Branch (1902:17): [True: 338, False: 0]
  ------------------
 1903|    338|              blosc2_dparams dparams;
 1904|    338|              blosc2_ctx_get_dparams(context, &dparams);
 1905|    338|              rc = g_filters[j].backward(_src, _dest, bsize, filters_meta[i], &dparams, g_filters[j].id);
 1906|    338|            } else {
 1907|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1908|      0|              return BLOSC2_ERROR_FILTER_PIPELINE;
 1909|      0|            }
 1910|    338|            if (rc != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1910:17): [True: 17, False: 321]
  ------------------
 1911|     17|              BLOSC_TRACE_ERROR("User-defined filter %d failed during decompression.", filters[i]);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|     17|              return rc;
 1913|     17|            }
 1914|    321|            goto urfiltersuccess;
 1915|    338|          }
 1916|  1.50k|        }
 1917|     73|      BLOSC_TRACE_ERROR("User-defined filter %d not found during decompression.", filters[i]);
  ------------------
  |  |   93|     73|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     73|    do {                                            \
  |  |  |  |   98|     73|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     73|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     73|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1918|     73|      return BLOSC2_ERROR_FILTER_PIPELINE;
 1919|    321|      urfiltersuccess:;
 1920|    321|    }
 1921|       |
 1922|       |    // do_nothing() skipped the filters that leave the block as it is (TRUNC_PREC is not undone);
 1923|       |    // the output of this filter is the input of the next one
 1924|  5.08M|    _src = _dest;
 1925|  5.08M|    if (last_filter_index == i) {
  ------------------
  |  Branch (1925:9): [True: 5.08M, False: 1.11k]
  ------------------
 1926|  5.08M|      break;
 1927|  5.08M|    }
 1928|  5.08M|  }
 1929|       |
 1930|  5.22M|  if (context->postfilter == NULL && _src != dest + offset) {
  ------------------
  |  Branch (1930:7): [True: 4.96M, False: 264k]
  |  Branch (1930:38): [True: 15, False: 4.96M]
  ------------------
 1931|     15|    memcpy(dest + offset, _src, (unsigned int)bsize);
 1932|     15|  }
 1933|       |
 1934|       |  /* Postfilter function */
 1935|  5.22M|  if (context->postfilter != NULL) {
  ------------------
  |  Branch (1935:7): [True: 264k, False: 4.96M]
  ------------------
 1936|       |    // Create new postfilter parameters for this block (must be private for each thread)
 1937|   264k|    blosc2_postfilter_params postparams;
 1938|   264k|    memcpy(&postparams, context->postparams, sizeof(postparams));
 1939|   264k|    postparams.input = _src;
 1940|   264k|    postparams.output = dest + offset;
 1941|   264k|    postparams.size = bsize;
 1942|   264k|    postparams.typesize = typesize;
 1943|   264k|    postparams.offset = nblock * context->blocksize;
 1944|   264k|    postparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (1944:25): [True: 264k, False: 0]
  ------------------
 1945|   264k|    postparams.nblock = nblock;
 1946|   264k|    postparams.tid = thread_context->tid;
 1947|   264k|    postparams.ttmp = thread_context->tmp;
 1948|   264k|    postparams.ttmp_nbytes = thread_context->tmp_nbytes;
 1949|   264k|    postparams.ctx = context;
 1950|       |
 1951|   264k|    if (context->postfilter(&postparams) != 0) {
  ------------------
  |  Branch (1951:9): [True: 0, False: 264k]
  ------------------
 1952|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1953|      0|      return BLOSC2_ERROR_POSTFILTER;
 1954|      0|    }
 1955|   264k|  }
 1956|       |
 1957|  5.22M|  return errcode;
 1958|  5.22M|}
free_thread_context:
 2648|  3.79k|void free_thread_context(struct thread_context* thread_context) {
 2649|  3.79k|  destroy_thread_context(thread_context);
 2650|  3.79k|  my_free(thread_context);
 2651|  3.79k|}
blosc2_compress_ctx:
 3652|  1.77M|                        void* dest, int32_t destsize) {
 3653|  1.77M|  int error, cbytes;
 3654|       |
 3655|  1.77M|  if (context->do_compress != 1) {
  ------------------
  |  Branch (3655:7): [True: 0, False: 1.77M]
  ------------------
 3656|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3657|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 3658|      0|  }
 3659|       |
 3660|  1.77M|  error = initialize_context_compression(
 3661|  1.77M|          context, src, srcsize, dest, destsize,
 3662|  1.77M|          context->clevel, context->filters, context->filters_meta,
 3663|  1.77M|          context->typesize, context->compcode, context->blocksize,
 3664|  1.77M|          context->new_nthreads, context->nthreads, context->splitmode,
 3665|  1.77M|          context->tuner_id, context->tuner_params, context->schunk);
 3666|  1.77M|  if (error <= 0) {
  ------------------
  |  Branch (3666:7): [True: 0, False: 1.77M]
  ------------------
 3667|      0|    return error;
 3668|      0|  }
 3669|       |
 3670|  1.77M|  error = blosc1_format_check(context);
 3671|  1.77M|  if (error < 0) {
  ------------------
  |  Branch (3671:7): [True: 0, False: 1.77M]
  ------------------
 3672|      0|    return error;
 3673|      0|  }
 3674|       |
 3675|       |  /* Write the extended header, or the Blosc1 header if requested */
 3676|  1.77M|  error = write_compression_header(context, !context->blosc1_format);
 3677|  1.77M|  if (error < 0) {
  ------------------
  |  Branch (3677:7): [True: 0, False: 1.77M]
  ------------------
 3678|      0|    return error;
 3679|      0|  }
 3680|       |
 3681|  1.77M|  cbytes = blosc_compress_context(context);
 3682|  1.77M|  if (cbytes < 0) {
  ------------------
  |  Branch (3682:7): [True: 0, False: 1.77M]
  ------------------
 3683|      0|    return cbytes;
 3684|      0|  }
 3685|       |
 3686|  1.77M|  if (context->use_dict && context->dict_cdict == NULL) {
  ------------------
  |  Branch (3686:7): [True: 0, False: 1.77M]
  |  Branch (3686:28): [True: 0, False: 0]
  ------------------
 3687|       |    /* blosc_compress_context() overwrites context->destsize with the training-pass output
 3688|       |     * size.  Restore it so that the real compression pass has the correct output-buffer size. */
 3689|      0|    context->destsize = destsize;
 3690|       |
 3691|      0|    bool is_lz4 = (context->compcode == BLOSC_LZ4 || context->compcode == BLOSC_LZ4HC);
  ------------------
  |  Branch (3691:20): [True: 0, False: 0]
  |  Branch (3691:54): [True: 0, False: 0]
  ------------------
 3692|      0|    if (!is_lz4 && context->compcode != BLOSC_ZSTD) {
  ------------------
  |  Branch (3692:9): [True: 0, False: 0]
  |  Branch (3692:20): [True: 0, False: 0]
  ------------------
 3693|      0|      const char* compname;
 3694|      0|      compname = clibcode_to_clibname(context->compcode);
 3695|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3696|      0|                        compname);
 3697|      0|      return BLOSC2_ERROR_CODEC_DICT;
 3698|      0|    }
 3699|       |
 3700|       |    // Build the dictionary out of the filters outcome and compress with it.
 3701|       |    // For LZ4/LZ4HC the raw samples are used directly (no training algorithm).
 3702|       |    // For ZSTD, ZDICT_trainFromBuffer() is used.
 3703|      0|    int32_t dict_maxsize = BLOSC2_MAXDICTSIZE;
 3704|       |    // Do not make the dict more than 5% larger than uncompressed buffer
 3705|      0|    if (dict_maxsize > srcsize / 20) {
  ------------------
  |  Branch (3705:9): [True: 0, False: 0]
  ------------------
 3706|      0|      dict_maxsize = srcsize / 20;
 3707|      0|    }
 3708|      0|    void* samples_buffer = context->dest + context->header_overhead;
 3709|      0|    unsigned nblocks = (unsigned)context->nblocks;
 3710|      0|    int dont_split = (context->header_flags & 0x10) >> 4;
 3711|      0|    if (!dont_split) {
  ------------------
  |  Branch (3711:9): [True: 0, False: 0]
  ------------------
 3712|      0|      nblocks = nblocks * context->typesize;
 3713|      0|    }
 3714|      0|    if (nblocks < 8) {
  ------------------
  |  Branch (3714:9): [True: 0, False: 0]
  ------------------
 3715|      0|      nblocks = 8;
 3716|      0|    }
 3717|       |
 3718|      0|    unsigned sample_fraction = 16;
 3719|      0|    size_t sample_size = context->sourcesize / nblocks / sample_fraction;
 3720|       |
 3721|       |    // When the data is too small to produce useful dict samples,
 3722|       |    // fall back to plain compression without a dict.
 3723|      0|    if (dict_maxsize < BLOSC2_MINUSEFULDICT || sample_size == 0) {
  ------------------
  |  Branch (3723:9): [True: 0, False: 0]
  |  Branch (3723:48): [True: 0, False: 0]
  ------------------
 3724|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3725|      0|                          "  Falling back to plain compression.", dict_maxsize, sample_size);
 3726|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3727|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3728|      0|      cbytes = blosc_compress_context_without_dict(context);
 3729|      0|    }
 3730|      0|    else if (is_lz4) {
  ------------------
  |  Branch (3730:14): [True: 0, False: 0]
  ------------------
 3731|       |      // LZ4/LZ4HC: use raw sample data directly as the dictionary (no training step).
 3732|      0|      int32_t dict_actual_size = (int32_t)(nblocks * sample_size);
 3733|      0|      if (dict_actual_size > dict_maxsize) {
  ------------------
  |  Branch (3733:11): [True: 0, False: 0]
  ------------------
 3734|      0|        dict_actual_size = dict_maxsize;
 3735|      0|      }
 3736|       |
 3737|       |      // Reset bstarts and embed dict in the output buffer.
 3738|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3739|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3740|       |      /* Move dict bytes; samples_buffer overlaps the dict (and its size) in dest,
 3741|       |         so this has to be a memmove, done before writing the size */
 3742|      0|      context->dict_buffer = context->dest + context->output_bytes + sizeof(int32_t);
 3743|      0|      memmove(context->dict_buffer, samples_buffer, (size_t)dict_actual_size);
 3744|       |      /* Write dict size */
 3745|      0|      _sw32(context->dest + context->output_bytes, dict_actual_size);
 3746|      0|      context->output_bytes += (int32_t)sizeof(int32_t);
 3747|       |      /* Build the stream used as cdict (pre-loaded with the dict bytes) */
 3748|      0|      if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (3748:11): [True: 0, False: 0]
  ------------------
 3749|      0|        LZ4_streamHC_t* lz4hc_cdict = LZ4_createStreamHC();
 3750|      0|        LZ4_loadDictHC(lz4hc_cdict, (const char*)context->dict_buffer, dict_actual_size);
 3751|      0|        context->dict_cdict = lz4hc_cdict;
 3752|      0|      } else {
 3753|      0|        LZ4_stream_t* lz4_cdict = LZ4_createStream();
 3754|      0|        LZ4_loadDict(lz4_cdict, (const char*)context->dict_buffer, dict_actual_size);
 3755|      0|        context->dict_cdict = lz4_cdict;
 3756|      0|      }
 3757|      0|      context->output_bytes += dict_actual_size;
 3758|      0|      context->dict_size = dict_actual_size;
 3759|       |
 3760|       |      /* Compress with dict */
 3761|      0|      cbytes = blosc_compress_context(context);
 3762|       |
 3763|       |      // Invalidate the dictionary so the context can be reused for the next chunk
 3764|      0|      context->dict_buffer = NULL;
 3765|      0|      if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (3765:11): [True: 0, False: 0]
  ------------------
 3766|      0|        LZ4_freeStreamHC((LZ4_streamHC_t*)context->dict_cdict);
 3767|      0|      } else {
 3768|      0|        LZ4_freeStream((LZ4_stream_t*)context->dict_cdict);
 3769|      0|      }
 3770|      0|      context->dict_cdict = NULL;
 3771|      0|    }
 3772|      0|#ifdef HAVE_ZSTD
 3773|      0|    else {
 3774|       |    // Populate the samples sizes for training the dictionary
 3775|      0|    size_t* samples_sizes = malloc(nblocks * sizeof(size_t));
 3776|      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]
  |  |  ------------------
  ------------------
 3777|      0|    for (size_t i = 0; i < nblocks; i++) {
  ------------------
  |  Branch (3777:24): [True: 0, False: 0]
  ------------------
 3778|      0|      samples_sizes[i] = sample_size;
 3779|      0|    }
 3780|       |
 3781|       |    // Train from samples
 3782|      0|    void* dict_buffer = malloc(dict_maxsize);
 3783|      0|    if (dict_buffer == NULL) {
  ------------------
  |  Branch (3783:9): [True: 0, False: 0]
  ------------------
 3784|      0|      free(samples_sizes);
 3785|      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]
  |  |  ------------------
  ------------------
 3786|      0|    }
 3787|      0|    int32_t dict_actual_size = (int32_t)ZDICT_trainFromBuffer(
 3788|      0|        dict_buffer, dict_maxsize,
 3789|      0|        samples_buffer, samples_sizes, nblocks);
 3790|       |
 3791|       |    // TODO: experiment with parameters of low-level fast cover algorithm
 3792|       |    // Note that this API is still unstable.  See: https://github.com/facebook/zstd/issues/1599
 3793|       |    // ZDICT_fastCover_params_t fast_cover_params;
 3794|       |    // memset(&fast_cover_params, 0, sizeof(fast_cover_params));
 3795|       |    // fast_cover_params.d = nblocks;
 3796|       |    // fast_cover_params.steps = 4;
 3797|       |    // fast_cover_params.zParams.compressionLevel = context->clevel;
 3798|       |    // size_t dict_actual_size = ZDICT_optimizeTrainFromBuffer_fastCover(
 3799|       |    //   dict_buffer, dict_maxsize, samples_buffer, samples_sizes, nblocks,
 3800|       |    //   &fast_cover_params);
 3801|       |
 3802|      0|    free(samples_sizes);
 3803|      0|    if (ZDICT_isError(dict_actual_size) != ZSTD_error_no_error) {
  ------------------
  |  Branch (3803:9): [True: 0, False: 0]
  ------------------
 3804|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3805|      0|                          "  Falling back to plain compression.",
 3806|      0|                          ZDICT_getErrorName(dict_actual_size));
 3807|      0|      free(dict_buffer);
 3808|      0|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3809|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3810|      0|      cbytes = blosc_compress_context_without_dict(context);
 3811|      0|    }
 3812|      0|    else {
 3813|      0|    assert(dict_actual_size > 0);
 3814|       |
 3815|       |    // Update bytes counter and pointers to bstarts for the new compressed buffer
 3816|      0|    context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3817|      0|    context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3818|       |    /* Write the size of trained dict at the end of bstarts */
 3819|      0|    _sw32(context->dest + context->output_bytes, (int32_t)dict_actual_size);
 3820|      0|    context->output_bytes += sizeof(int32_t);
 3821|       |    /* Write the trained dict afterwards */
 3822|      0|    context->dict_buffer = context->dest + context->output_bytes;
 3823|      0|    memcpy(context->dict_buffer, dict_buffer, (unsigned int)dict_actual_size);
 3824|      0|    context->dict_cdict = ZSTD_createCDict(dict_buffer, dict_actual_size, 1);  // TODO: use get_accel()
 3825|      0|    free(dict_buffer);      // the dictionary is copied in the header now
 3826|      0|    context->output_bytes += (int32_t)dict_actual_size;
 3827|      0|    context->dict_size = dict_actual_size;
 3828|       |
 3829|       |    /* Compress with dict */
 3830|      0|    cbytes = blosc_compress_context(context);
 3831|       |
 3832|       |    // Invalidate the dictionary for compressing other chunks using the same context
 3833|      0|    context->dict_buffer = NULL;
 3834|      0|    ZSTD_freeCDict(context->dict_cdict);
 3835|      0|    context->dict_cdict = NULL;
 3836|      0|    }  // ZDICT_isError
 3837|      0|    }  // ZSTD else branch
 3838|      0|#endif  // HAVE_ZSTD
 3839|      0|  }
 3840|       |
 3841|  1.77M|  return cbytes;
 3842|  1.77M|}
build_filters:
 4225|  2.39M|                   const int32_t typesize, uint8_t* filters) {
 4226|       |
 4227|       |  /* Fill the end part of the filter pipeline */
 4228|  2.39M|  if ((doshuffle == BLOSC_SHUFFLE) && (typesize > 1))
  ------------------
  |  Branch (4228:7): [True: 0, False: 2.39M]
  |  Branch (4228:39): [True: 0, False: 0]
  ------------------
 4229|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_SHUFFLE;
 4230|  2.39M|  if (doshuffle == BLOSC_BITSHUFFLE)
  ------------------
  |  Branch (4230:7): [True: 0, False: 2.39M]
  ------------------
 4231|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_BITSHUFFLE;
 4232|  2.39M|  if (doshuffle == BLOSC_NOSHUFFLE)
  ------------------
  |  Branch (4232:7): [True: 0, False: 2.39M]
  ------------------
 4233|      0|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_NOSHUFFLE;
 4234|  2.39M|  if (delta)
  ------------------
  |  Branch (4234:7): [True: 0, False: 2.39M]
  ------------------
 4235|      0|    filters[BLOSC2_MAX_FILTERS - 2] = BLOSC_DELTA;
 4236|  2.39M|}
blosc2_decompress_ctx:
 4486|  1.64M|                          void* dest, int32_t destsize) {
 4487|  1.64M|  int result;
 4488|       |
 4489|  1.64M|  if (context->do_compress != 0) {
  ------------------
  |  Branch (4489:7): [True: 0, False: 1.64M]
  ------------------
 4490|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4491|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4492|      0|  }
 4493|       |
 4494|  1.64M|  result = blosc_run_decompression_with_context(context, src, srcsize, dest, destsize);
 4495|       |
 4496|       |  // Reset a possible block_maskout
 4497|  1.64M|  ctx_clear_maskout(context);
 4498|       |
 4499|  1.64M|  return result;
 4500|  1.64M|}
_blosc_getitem:
 4873|  2.96M|                   int start, int nitems, void* dest, int32_t destsize) {
 4874|  2.96M|  uint8_t* _src = (uint8_t*)(src);  /* current pos for source buffer */
 4875|  2.96M|  uint8_t* _dest = (uint8_t*)(dest);
 4876|  2.96M|  int32_t ntbytes = 0;              /* the number of uncompressed bytes */
 4877|  2.96M|  int32_t bsize, bsize2, leftoverblock;
 4878|  2.96M|  int32_t startb, stopb;
 4879|  2.96M|  int32_t stop;
 4880|  2.96M|  int32_t nitems_bytes;
 4881|  2.96M|  int64_t start64 = (int64_t)start;
 4882|  2.96M|  int64_t nitems64 = (int64_t)nitems;
 4883|  2.96M|  int64_t typesize64 = (int64_t)header->typesize;
 4884|  2.96M|  int64_t stop64;
 4885|  2.96M|  int64_t nitems_bytes64;
 4886|  2.96M|  int64_t start_bytes64;
 4887|  2.96M|  int64_t stop_bytes64;
 4888|  2.96M|  int j, rc;
 4889|       |
 4890|  2.96M|  if (nitems == 0) {
  ------------------
  |  Branch (4890:7): [True: 0, False: 2.96M]
  ------------------
 4891|       |    // We have nothing to do
 4892|      0|    return 0;
 4893|      0|  }
 4894|  2.96M|  if (nitems < 0) {
  ------------------
  |  Branch (4894:7): [True: 0, False: 2.96M]
  ------------------
 4895|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4896|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4897|      0|  }
 4898|       |
 4899|  2.96M|  nitems_bytes64 = nitems64 * typesize64;
 4900|  2.96M|  if (nitems_bytes64 < 0 || nitems_bytes64 > INT32_MAX || nitems_bytes64 > destsize) {
  ------------------
  |  Branch (4900:7): [True: 0, False: 2.96M]
  |  Branch (4900:29): [True: 0, False: 2.96M]
  |  Branch (4900:59): [True: 7, False: 2.96M]
  ------------------
 4901|      7|    BLOSC_TRACE_ERROR("`nitems`*`typesize` out of dest bounds.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4902|      7|    return BLOSC2_ERROR_WRITE_BUFFER;
 4903|      7|  }
 4904|  2.96M|  nitems_bytes = (int32_t)nitems_bytes64;
 4905|       |
 4906|  2.96M|  int32_t* bstarts = (int32_t*)(_src + context->header_overhead);
 4907|       |
 4908|       |  /* Check region boundaries */
 4909|  2.96M|  start_bytes64 = start64 * typesize64;
 4910|  2.96M|  if ((start < 0) || (start_bytes64 < 0) || (start_bytes64 > header->nbytes)) {
  ------------------
  |  Branch (4910:7): [True: 0, False: 2.96M]
  |  Branch (4910:22): [True: 0, False: 2.96M]
  |  Branch (4910:45): [True: 0, False: 2.96M]
  ------------------
 4911|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4912|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4913|      0|  }
 4914|       |
 4915|  2.96M|  stop64 = start64 + nitems64;
 4916|  2.96M|  if ((stop64 < 0) || (stop64 > INT32_MAX)) {
  ------------------
  |  Branch (4916:7): [True: 0, False: 2.96M]
  |  Branch (4916:23): [True: 0, False: 2.96M]
  ------------------
 4917|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4918|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4919|      0|  }
 4920|  2.96M|  stop = (int32_t)stop64;
 4921|       |
 4922|  2.96M|  stop_bytes64 = stop64 * typesize64;
 4923|  2.96M|  if ((stop_bytes64 < 0) || (stop_bytes64 > header->nbytes)) {
  ------------------
  |  Branch (4923:7): [True: 0, False: 2.96M]
  |  Branch (4923:29): [True: 0, False: 2.96M]
  ------------------
 4924|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4925|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4926|      0|  }
 4927|       |
 4928|  2.96M|  bool chunk_memcpyed = (header->flags & (uint8_t)BLOSC_MEMCPYED) != 0;
 4929|  2.96M|  if (!context->special_type && !chunk_memcpyed &&
  ------------------
  |  Branch (4929:7): [True: 2.85M, False: 112k]
  |  Branch (4929:33): [True: 2.73M, False: 121k]
  ------------------
 4930|  2.73M|      ((uint8_t *)(_src + srcsize) < (uint8_t *)(bstarts + context->nblocks))) {
  ------------------
  |  Branch (4930:7): [True: 0, False: 2.73M]
  ------------------
 4931|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4932|      0|    return BLOSC2_ERROR_READ_BUFFER;
 4933|      0|  }
 4934|       |
 4935|  2.96M|  bool memcpyed = header->flags & (uint8_t)BLOSC_MEMCPYED;
 4936|  2.96M|  if (context->special_type) {
  ------------------
  |  Branch (4936:7): [True: 112k, False: 2.85M]
  ------------------
 4937|       |    // Fake a runlen as if its a memcpyed chunk
 4938|   112k|    memcpyed = true;
 4939|   112k|  }
 4940|       |
 4941|  2.96M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (4941:19): [True: 2.96M, False: 42]
  ------------------
 4942|  2.96M|                  (context->blosc2_flags & 0x08u) && !context->special_type);
  ------------------
  |  Branch (4942:19): [True: 0, False: 2.96M]
  |  Branch (4942:54): [True: 0, False: 0]
  ------------------
 4943|  2.96M|  if (memcpyed && !is_lazy && !context->postfilter) {
  ------------------
  |  Branch (4943:7): [True: 233k, False: 2.73M]
  |  Branch (4943:19): [True: 233k, False: 0]
  |  Branch (4943:31): [True: 233k, False: 0]
  ------------------
 4944|       |    // Short-circuit for (non-lazy) memcpyed or special values
 4945|   233k|    ntbytes = nitems_bytes;
 4946|   233k|    switch (context->special_type) {
 4947|   108k|      case BLOSC2_SPECIAL_VALUE: {
  ------------------
  |  Branch (4947:7): [True: 108k, False: 125k]
  ------------------
 4948|       |        // The repeated value's width is cbytes minus the header, not the header
 4949|       |        // typesize byte (which is left unconstrained for special-value chunks).
 4950|       |        // Derive it the same way blosc_d() does so a crafted typesize cannot make
 4951|       |        // set_values() read past the end of the chunk.
 4952|   108k|        int32_t value_typesize = header->cbytes - context->header_overhead;
 4953|   108k|        rc = set_values(value_typesize, _src, _dest, ntbytes);
 4954|   108k|        if (rc < 0) {
  ------------------
  |  Branch (4954:13): [True: 1, False: 108k]
  ------------------
 4955|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4956|      1|          return BLOSC2_ERROR_DATA;
 4957|      1|        }
 4958|   108k|        break;
 4959|   108k|      }
 4960|   108k|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (4960:7): [True: 0, False: 233k]
  ------------------
 4961|      0|        rc = set_nans(context->typesize, _dest, ntbytes);
 4962|      0|        if (rc < 0) {
  ------------------
  |  Branch (4962:13): [True: 0, False: 0]
  ------------------
 4963|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4964|      0|          return BLOSC2_ERROR_DATA;
 4965|      0|        }
 4966|      0|        break;
 4967|  4.05k|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (4967:7): [True: 4.05k, False: 229k]
  ------------------
 4968|  4.05k|        memset(_dest, 0, ntbytes);
 4969|  4.05k|        break;
 4970|      0|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (4970:7): [True: 0, False: 233k]
  ------------------
 4971|       |        // We do nothing here
 4972|      0|        break;
 4973|   121k|      case BLOSC2_NO_SPECIAL:
  ------------------
  |  Branch (4973:7): [True: 121k, False: 112k]
  ------------------
 4974|   121k|        {
 4975|   121k|          int64_t src_offset64 = (int64_t)context->header_overhead + start_bytes64;
 4976|   121k|          int64_t src_stop64 = src_offset64 + nitems_bytes64;
 4977|   121k|          if ((src_offset64 < 0) || (src_stop64 < src_offset64) || (src_stop64 > srcsize)) {
  ------------------
  |  Branch (4977:15): [True: 0, False: 121k]
  |  Branch (4977:37): [True: 0, False: 121k]
  |  Branch (4977:68): [True: 0, False: 121k]
  ------------------
 4978|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4979|      0|            return BLOSC2_ERROR_READ_BUFFER;
 4980|      0|          }
 4981|   121k|          _src += (int32_t)src_offset64;
 4982|   121k|        }
 4983|      0|        memcpy(_dest, _src, ntbytes);
 4984|   121k|        break;
 4985|      0|      default:
  ------------------
  |  Branch (4985:7): [True: 0, False: 233k]
  ------------------
 4986|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4987|      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]
  |  |  ------------------
  ------------------
 4988|   233k|    }
 4989|   233k|    return ntbytes;
 4990|   233k|  }
 4991|       |
 4992|  2.73M|  if (filters_contain(context->filters, BLOSC_DELTA)) {
  ------------------
  |  Branch (4992:7): [True: 18, False: 2.73M]
  ------------------
 4993|     18|    uint8_t* full_chunk = malloc((size_t)header->nbytes);
 4994|     18|    if (full_chunk == NULL) {
  ------------------
  |  Branch (4994:9): [True: 0, False: 18]
  ------------------
 4995|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 4996|      0|    }
 4997|     18|    int dbytes = blosc2_decompress_ctx(context, src, srcsize, full_chunk, header->nbytes);
 4998|     18|    context->dest = NULL;
 4999|     18|    context->destsize = 0;
 5000|     18|    if (dbytes < 0 || dbytes != header->nbytes) {
  ------------------
  |  Branch (5000:9): [True: 0, False: 18]
  |  Branch (5000:23): [True: 0, False: 18]
  ------------------
 5001|      0|      free(full_chunk);
 5002|      0|      return dbytes < 0 ? dbytes : BLOSC2_ERROR_DATA;
  ------------------
  |  Branch (5002:14): [True: 0, False: 0]
  ------------------
 5003|      0|    }
 5004|     18|    memcpy(dest, full_chunk + start_bytes64, (size_t)nitems_bytes);
 5005|     18|    free(full_chunk);
 5006|     18|    return nitems_bytes;
 5007|     18|  }
 5008|       |
 5009|  2.73M|  struct thread_context* scontext = serial_context_get(context);
 5010|  2.73M|  BLOSC_ERROR_NULL(scontext, BLOSC2_ERROR_THREAD_CREATE);
  ------------------
  |  |  104|  2.73M|    do {                                            \
  |  |  105|  2.73M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.73M]
  |  |  ------------------
  |  |  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.73M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.73M]
  |  |  ------------------
  ------------------
 5011|       |
 5012|   188M|  for (j = 0; j < context->nblocks; j++) {
  ------------------
  |  Branch (5012:15): [True: 187M, False: 1.25M]
  ------------------
 5013|   187M|    bsize = header->blocksize;
 5014|   187M|    leftoverblock = 0;
 5015|   187M|    if ((j == context->nblocks - 1) && (context->leftover > 0)) {
  ------------------
  |  Branch (5015:9): [True: 2.04M, False: 185M]
  |  Branch (5015:40): [True: 917k, False: 1.12M]
  ------------------
 5016|   917k|      bsize = context->leftover;
 5017|   917k|      leftoverblock = 1;
 5018|   917k|    }
 5019|       |
 5020|       |    /* Compute start & stop for each block */
 5021|   187M|    startb = start * header->typesize - j * header->blocksize;
 5022|   187M|    stopb = stop * header->typesize - j * header->blocksize;
 5023|   187M|    if (stopb <= 0) {
  ------------------
  |  Branch (5023:9): [True: 1.47M, False: 185M]
  ------------------
 5024|       |      // We can exit as soon as this block is beyond stop
 5025|  1.47M|      break;
 5026|  1.47M|    }
 5027|   185M|    if (startb >= header->blocksize) {
  ------------------
  |  Branch (5027:9): [True: 183M, False: 2.73M]
  ------------------
 5028|   183M|      continue;
 5029|   183M|    }
 5030|  2.73M|    if (startb < 0) {
  ------------------
  |  Branch (5030:9): [True: 226, False: 2.73M]
  ------------------
 5031|    226|      startb = 0;
 5032|    226|    }
 5033|  2.73M|    if (stopb > header->blocksize) {
  ------------------
  |  Branch (5033:9): [True: 226, False: 2.73M]
  ------------------
 5034|    226|      stopb = header->blocksize;
 5035|    226|    }
 5036|  2.73M|    bsize2 = stopb - startb;
 5037|       |
 5038|  2.73M|#if defined(HAVE_ZFP)
 5039|  2.73M|    if (context->compcode == BLOSC_CODEC_ZFP_FIXED_RATE) {
  ------------------
  |  Branch (5039:9): [True: 0, False: 2.73M]
  ------------------
 5040|       |      // The items in this block
 5041|      0|      scontext->zfp_cell_start = startb / context->typesize;
 5042|      0|      scontext->zfp_cell_nitems = bsize2 / context->typesize;
 5043|      0|    }
 5044|  2.73M|#endif /* HAVE_ZFP */
 5045|       |
 5046|       |    /* Do the actual data copy */
 5047|       |    // Regular decompression.  Put results in tmp2.
 5048|       |    // If the items are exactly this block, decompress it in destination and avoid a copy
 5049|  2.73M|    bool get_single_block = ((ntbytes == 0) && (startb == 0) && (bsize == nitems_bytes));
  ------------------
  |  Branch (5049:30): [True: 2.73M, False: 226]
  |  Branch (5049:48): [True: 1.04M, False: 1.68M]
  |  Branch (5049:65): [True: 46.9k, False: 1.00M]
  ------------------
 5050|  2.73M|    uint8_t* tmp2 = get_single_block ? dest : scontext->tmp2;
  ------------------
  |  Branch (5050:21): [True: 46.9k, False: 2.68M]
  ------------------
 5051|       |
 5052|       |    // If memcpyed we don't have a bstarts section (because it is not needed)
 5053|  2.73M|    int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (5053:26): [True: 0, False: 2.73M]
  ------------------
 5054|  2.73M|      context->header_overhead + j * header->blocksize : sw32_(bstarts + j);
 5055|       |
 5056|  2.73M|    int32_t cbytes = blosc_d(scontext, bsize, leftoverblock, memcpyed,
 5057|  2.73M|                             src, srcsize, src_offset, j,
 5058|  2.73M|                             tmp2, 0, scontext->tmp, scontext->tmp3);
 5059|  2.73M|    if (cbytes < 0) {
  ------------------
  |  Branch (5059:9): [True: 0, False: 2.73M]
  ------------------
 5060|      0|      ntbytes = cbytes;
 5061|      0|      break;
 5062|      0|    }
 5063|  2.73M|    if (!get_single_block) {
  ------------------
  |  Branch (5063:9): [True: 2.68M, False: 46.9k]
  ------------------
 5064|       |      /* Copy to destination.  When ZFP decoded just the requested items (a single
 5065|       |         cell), they are at the start of tmp2, else the whole block was decoded. */
 5066|  2.68M|      bool zfp_cell = (scontext->zfp_cell_nitems > 0) && (cbytes == bsize2);
  ------------------
  |  Branch (5066:23): [True: 0, False: 2.68M]
  |  Branch (5066:58): [True: 0, False: 0]
  ------------------
 5067|  2.68M|      memcpy((uint8_t *) dest + ntbytes, tmp2 + (zfp_cell ? 0 : startb), (unsigned int) bsize2);
  ------------------
  |  Branch (5067:50): [True: 0, False: 2.68M]
  ------------------
 5068|  2.68M|    }
 5069|  2.73M|    ntbytes += bsize2;
 5070|  2.73M|  }
 5071|       |
 5072|  2.73M|  scontext->zfp_cell_nitems = 0;
 5073|  2.73M|  serial_context_put(scontext);
 5074|       |
 5075|  2.73M|  if (ntbytes >= 0 && ntbytes != nitems_bytes) {
  ------------------
  |  Branch (5075:7): [True: 2.73M, False: 0]
  |  Branch (5075:23): [True: 0, False: 2.73M]
  ------------------
 5076|       |    // A partial decode must not look like a success: callers that only test for
 5077|       |    // a negative return would silently keep hold of an incompletely filled dest.
 5078|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5079|      0|                      ntbytes, nitems_bytes);
 5080|      0|    return BLOSC2_ERROR_DATA;
 5081|      0|  }
 5082|       |
 5083|  2.73M|  return ntbytes;
 5084|  2.73M|}
blosc2_getitem:
 5086|  2.74M|int blosc2_getitem(const void* src, int32_t srcsize, int start, int nitems, void* dest, int32_t destsize) {
 5087|  2.74M|  blosc2_context context;
 5088|  2.74M|  int result;
 5089|       |
 5090|       |  /* Minimally populate the context */
 5091|  2.74M|  memset(&context, 0, sizeof(blosc2_context));
 5092|       |
 5093|  2.74M|  context.schunk = g_schunk;
 5094|  2.74M|  context.nthreads = 1;  // force a serial decompression; fixes #95
 5095|       |
 5096|       |  /* Call the actual getitem function */
 5097|  2.74M|  result = blosc2_getitem_ctx(&context, src, srcsize, start, nitems, dest, destsize);
 5098|       |
 5099|       |  /* Release resources */
 5100|  2.74M|  if (context.serial_context != NULL) {
  ------------------
  |  Branch (5100:7): [True: 2, False: 2.74M]
  ------------------
 5101|      2|    free_thread_context(context.serial_context);
 5102|      2|  }
 5103|  2.74M|  return result;
 5104|  2.74M|}
blosc2_getitem_ctx:
 5148|  2.74M|    int start, int nitems, void* dest, int32_t destsize) {
 5149|  2.74M|  blosc_header header;
 5150|  2.74M|  int result = getitem_read_header(src, srcsize, &header);
 5151|  2.74M|  if (result < 0) {
  ------------------
  |  Branch (5151:7): [True: 0, False: 2.74M]
  ------------------
 5152|      0|    return result;
 5153|      0|  }
 5154|       |
 5155|  2.74M|  return getitem_with_header(context, &header, src, srcsize, start, nitems, dest, destsize);
 5156|  2.74M|}
blosc2_getitem_bytes_ctx:
 5159|   222k|    int32_t start, int32_t nbytes, void* dest, int32_t destsize) {
 5160|   222k|  blosc_header header;
 5161|   222k|  int result = getitem_read_header(src, srcsize, &header);
 5162|   222k|  if (result < 0) {
  ------------------
  |  Branch (5162:7): [True: 0, False: 222k]
  ------------------
 5163|      0|    return result;
 5164|      0|  }
 5165|       |
 5166|   222k|  if (start < 0 || nbytes < 0) {
  ------------------
  |  Branch (5166:7): [True: 0, False: 222k]
  |  Branch (5166:20): [True: 0, False: 222k]
  ------------------
 5167|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5168|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5169|      0|  }
 5170|       |
 5171|       |  /* The typesize a chunk records is 1 whenever the original one exceeded
 5172|       |     BLOSC_MAX_TYPESIZE, so for wide types this conversion is a no-op and the
 5173|       |     alignment check below is vacuous.  That is the whole point of this entry
 5174|       |     point: the caller never has to know whether the cap kicked in. */
 5175|   222k|  int32_t typesize = header.typesize;
 5176|   222k|  if ((start % typesize != 0) || (nbytes % typesize != 0)) {
  ------------------
  |  Branch (5176:7): [True: 0, False: 222k]
  |  Branch (5176:34): [True: 0, False: 222k]
  ------------------
 5177|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5178|      0|                      "the typesize stored in the chunk (%d).", start, nbytes, typesize);
 5179|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5180|      0|  }
 5181|       |
 5182|   222k|  return getitem_with_header(context, &header, src, srcsize, start / typesize,
 5183|   222k|                             nbytes / typesize, dest, destsize);
 5184|   222k|}
blosc2_get_nthreads:
 6247|  8.55k|{
 6248|  8.55k|  int16_t nthreads;
 6249|  8.55k|  blosc2_init();
 6250|  8.55k|  blosc2_pthread_mutex_lock(&global_comp_mutex);
  ------------------
  |  |   92|  8.55k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6251|  8.55k|  nthreads = g_nthreads;
 6252|  8.55k|  blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|  8.55k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6253|  8.55k|  return nthreads;
 6254|  8.55k|}
blosc2_set_nthreads:
 6256|  4.92k|int16_t blosc2_set_nthreads(int16_t nthreads) {
 6257|  4.92k|  int16_t ret;          /* the previous number of threads */
 6258|       |
 6259|       |  /* Check whether the library should be initialized */
 6260|  4.92k|  blosc2_init();
 6261|       |
 6262|  4.92k|  blosc2_pthread_mutex_lock(&global_comp_mutex);
  ------------------
  |  |   92|  4.92k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6263|  4.92k|  ret = g_nthreads;
 6264|  4.92k|  if (nthreads != ret) {
  ------------------
  |  Branch (6264:7): [True: 0, False: 4.92k]
  ------------------
 6265|      0|    int16_t old_new_nthreads = g_global_context->new_nthreads;
 6266|      0|    int16_t old_nthreads = g_global_context->nthreads;
 6267|      0|    g_nthreads = nthreads;
 6268|      0|    g_global_context->new_nthreads = nthreads;
 6269|      0|    int16_t ret2 = check_nthreads(g_global_context, true);
 6270|      0|    if (ret2 < 0) {
  ------------------
  |  Branch (6270:9): [True: 0, False: 0]
  ------------------
 6271|      0|      g_nthreads = ret;
 6272|      0|      g_global_context->new_nthreads = old_new_nthreads;
 6273|      0|      g_global_context->nthreads = old_nthreads;
 6274|      0|      check_nthreads(g_global_context, true);
 6275|      0|      blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6276|      0|      return ret2;
 6277|      0|    }
 6278|      0|  }
 6279|  4.92k|  blosc2_pthread_mutex_unlock(&global_comp_mutex);
  ------------------
  |  |   93|  4.92k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6280|       |
 6281|  4.92k|  return ret;
 6282|  4.92k|}
blosc2_cbuffer_sizes:
 6399|  22.4M|int blosc2_cbuffer_sizes(const void* cbuffer, int32_t* nbytes, int32_t* cbytes, int32_t* blocksize) {
 6400|  22.4M|  blosc_header header;
 6401|  22.4M|  int rc = read_chunk_header((uint8_t *) cbuffer, BLOSC_MIN_HEADER_LENGTH, false, &header);
 6402|  22.4M|  if (rc < 0) {
  ------------------
  |  Branch (6402:7): [True: 36, False: 22.4M]
  ------------------
 6403|       |    /* Return zeros if error reading header */
 6404|     36|    memset(&header, 0, sizeof(header));
 6405|     36|  }
 6406|       |
 6407|       |  /* Read the interesting values */
 6408|  22.4M|  if (nbytes != NULL)
  ------------------
  |  Branch (6408:7): [True: 18.4M, False: 4.03M]
  ------------------
 6409|  18.4M|    *nbytes = header.nbytes;
 6410|  22.4M|  if (cbytes != NULL)
  ------------------
  |  Branch (6410:7): [True: 21.5M, False: 932k]
  ------------------
 6411|  21.5M|    *cbytes = header.cbytes;
 6412|  22.4M|  if (blocksize != NULL)
  ------------------
  |  Branch (6412:7): [True: 4.44M, False: 18.0M]
  ------------------
 6413|  4.44M|    *blocksize = header.blocksize;
 6414|  22.4M|  return rc;
 6415|  22.4M|}
blosc2_init:
 6605|   400k|void blosc2_init(void) {
 6606|       |  /* Return if Blosc is already initialized */
 6607|   400k|  if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  142|   400k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  104|   400k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6607:7): [True: 395k, False: 4.92k]
  ------------------
 6608|       |
 6609|  4.92k|#if !defined(_WIN32)
 6610|       |  /* Before g_init_lock is taken: from now on a fork() waits for it */
 6611|  4.92k|  pthread_once(&atfork_once, register_atfork);
 6612|  4.92k|#endif
 6613|  4.92k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  4.92k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6614|       |  /* Teardown drops this lock while joining prefetch workers.  Wait without
 6615|       |     holding it so the destroyer can finish; never reinitialize live globals. */
 6616|  4.92k|  while (g_initlib == BLOSC_STATE_TEARDOWN) {
  ------------------
  |  |  105|  4.92k|#define BLOSC_STATE_TEARDOWN      2
  ------------------
  |  Branch (6616:10): [True: 0, False: 4.92k]
  ------------------
 6617|       |#if defined(_WIN32)
 6618|       |    SleepConditionVariableSRW(&g_init_cv, &g_init_lock, INFINITE, 0);
 6619|       |#else
 6620|      0|    pthread_cond_wait(&g_init_cv, &g_init_lock);
 6621|      0|#endif
 6622|      0|  }
 6623|       |  /* Unless another thread initialized it meanwhile */
 6624|  4.92k|  if (g_initlib != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  4.92k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6624:7): [True: 4.92k, False: 0]
  ------------------
 6625|  4.92k|    blosc2_init_locked();
 6626|  4.92k|  }
 6627|  4.92k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  4.92k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6628|  4.92k|}
blosc2_tmp_malloc:
 6792|  1.45M|void *blosc2_tmp_malloc(size_t nbytes, size_t *capacity) {
 6793|  1.45M|  *capacity = nbytes;
 6794|  1.45M|#if !defined(_WIN32)
 6795|  1.45M|  tmp_cache_t *cache = nbytes >= BLOSC2_TMP_CACHE_MIN ? tmp_cache_get(false) : NULL;
  ------------------
  |  | 6659|  1.45M|#define BLOSC2_TMP_CACHE_MIN (64 * 1024)
  ------------------
  |  Branch (6795:24): [True: 13.3k, False: 1.43M]
  ------------------
 6796|  1.45M|  if (cache != NULL) {
  ------------------
  |  Branch (6796:7): [True: 13.3k, False: 1.43M]
  ------------------
 6797|       |    // The smallest buffer that fits, and not one far larger than needed
 6798|  13.3k|    int best = -1;
 6799|  66.7k|    for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6658|  66.7k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (6799:21): [True: 53.4k, False: 13.3k]
  ------------------
 6800|  53.4k|      if (cache->ptr[i] != NULL && cache->size[i] >= nbytes && cache->size[i] / 2 <= nbytes &&
  ------------------
  |  Branch (6800:11): [True: 20.7k, False: 32.7k]
  |  Branch (6800:36): [True: 16.4k, False: 4.29k]
  |  Branch (6800:64): [True: 15.7k, False: 629]
  ------------------
 6801|  15.7k|          (best < 0 || cache->size[i] < cache->size[best])) {
  ------------------
  |  Branch (6801:12): [True: 11.2k, False: 4.57k]
  |  Branch (6801:24): [True: 44, False: 4.53k]
  ------------------
 6802|  11.2k|        best = i;
 6803|  11.2k|      }
 6804|  53.4k|    }
 6805|  13.3k|    if (best >= 0) {
  ------------------
  |  Branch (6805:9): [True: 11.2k, False: 2.15k]
  ------------------
 6806|  11.2k|      void *ptr = cache->ptr[best];
 6807|  11.2k|      *capacity = cache->size[best];
 6808|  11.2k|      cache->ptr[best] = NULL;
 6809|  11.2k|      cache->size[best] = 0;
 6810|  11.2k|      return ptr;
 6811|  11.2k|    }
 6812|  13.3k|  }
 6813|  1.44M|#endif
 6814|  1.44M|  return malloc(nbytes);
 6815|  1.45M|}
blosc2_tmp_free:
 6817|  2.63M|void blosc2_tmp_free(void *ptr, size_t capacity) {
 6818|  2.63M|  if (ptr == NULL) {
  ------------------
  |  Branch (6818:7): [True: 1.16M, False: 1.46M]
  ------------------
 6819|  1.16M|    return;
 6820|  1.16M|  }
 6821|  1.46M|#if !defined(_WIN32)
 6822|  1.46M|  tmp_cache_t *cache = NULL;
 6823|  1.46M|  if (capacity >= BLOSC2_TMP_CACHE_MIN && capacity <= BLOSC2_TMP_CACHE_MAX / 2) {
  ------------------
  |  | 6659|  2.93M|#define BLOSC2_TMP_CACHE_MIN (64 * 1024)
  ------------------
                if (capacity >= BLOSC2_TMP_CACHE_MIN && capacity <= BLOSC2_TMP_CACHE_MAX / 2) {
  ------------------
  |  | 6660|  13.3k|#define BLOSC2_TMP_CACHE_MAX (64 * 1024 * 1024)
  ------------------
  |  Branch (6823:7): [True: 13.3k, False: 1.45M]
  |  Branch (6823:43): [True: 12.5k, False: 786]
  ------------------
 6824|  12.5k|    cache = tmp_cache_get(true);
 6825|  12.5k|  }
 6826|  1.46M|  if (cache != NULL) {
  ------------------
  |  Branch (6826:7): [True: 12.5k, False: 1.45M]
  ------------------
 6827|       |    // Make room by dropping the smallest buffers (each one smaller than this)
 6828|  12.5k|    for (;;) {
 6829|  12.5k|      size_t total = capacity;
 6830|  12.5k|      int empty = -1;
 6831|  12.5k|      int smallest = -1;
 6832|  62.8k|      for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6658|  62.8k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (6832:23): [True: 50.2k, False: 12.5k]
  ------------------
 6833|  50.2k|        if (cache->ptr[i] == NULL) {
  ------------------
  |  Branch (6833:13): [True: 40.2k, False: 10.0k]
  ------------------
 6834|  40.2k|          empty = i;
 6835|  40.2k|          continue;
 6836|  40.2k|        }
 6837|  10.0k|        total += cache->size[i];
 6838|  10.0k|        if (smallest < 0 || cache->size[i] < cache->size[smallest]) {
  ------------------
  |  Branch (6838:13): [True: 7.71k, False: 2.32k]
  |  Branch (6838:29): [True: 678, False: 1.64k]
  ------------------
 6839|  8.39k|          smallest = i;
 6840|  8.39k|        }
 6841|  10.0k|      }
 6842|  12.5k|      if (empty >= 0 && total <= BLOSC2_TMP_CACHE_MAX) {
  ------------------
  |  | 6660|  12.5k|#define BLOSC2_TMP_CACHE_MAX (64 * 1024 * 1024)
  ------------------
  |  Branch (6842:11): [True: 12.5k, False: 0]
  |  Branch (6842:25): [True: 12.5k, False: 15]
  ------------------
 6843|  12.5k|        cache->ptr[empty] = ptr;
 6844|  12.5k|        cache->size[empty] = capacity;
 6845|  12.5k|        return;
 6846|  12.5k|      }
 6847|     15|      if (smallest < 0 || cache->size[smallest] >= capacity) {
  ------------------
  |  Branch (6847:11): [True: 0, False: 15]
  |  Branch (6847:27): [True: 9, False: 6]
  ------------------
 6848|      9|        break;
 6849|      9|      }
 6850|      6|      free(cache->ptr[smallest]);
 6851|      6|      cache->ptr[smallest] = NULL;
 6852|      6|      cache->size[smallest] = 0;
 6853|      6|    }
 6854|  12.5k|  }
 6855|       |#else
 6856|       |  BLOSC_UNUSED_PARAM(capacity);
 6857|       |#endif
 6858|  1.45M|  free(ptr);
 6859|  1.45M|}
blosc2_tmp_cache_clear:
 6861|  9.84k|void blosc2_tmp_cache_clear(void) {
 6862|  9.84k|#if !defined(_WIN32)
 6863|  9.84k|  tmp_cache_t *cache = tmp_cache_get(false);
 6864|  9.84k|  if (cache != NULL) {
  ------------------
  |  Branch (6864:7): [True: 9.84k, False: 0]
  ------------------
 6865|  49.2k|    for (int i = 0; i < BLOSC2_TMP_CACHE_SLOTS; ++i) {
  ------------------
  |  | 6658|  49.2k|#define BLOSC2_TMP_CACHE_SLOTS 4
  ------------------
  |  Branch (6865:21): [True: 39.3k, False: 9.84k]
  ------------------
 6866|  39.3k|      free(cache->ptr[i]);
 6867|  39.3k|      cache->ptr[i] = NULL;
 6868|  39.3k|      cache->size[i] = 0;
 6869|  39.3k|    }
 6870|  9.84k|    if (cache->serial != NULL && !cache->serial_busy) {
  ------------------
  |  Branch (6870:9): [True: 3.59k, False: 6.25k]
  |  Branch (6870:34): [True: 3.59k, False: 0]
  ------------------
 6871|  3.59k|      free_thread_context(cache->serial);
 6872|       |      cache->serial = NULL;
 6873|  3.59k|    }
 6874|  9.84k|  }
 6875|  9.84k|#endif
 6876|  9.84k|}
blosc2_destroy:
 6914|  4.92k|void blosc2_destroy(void) {
 6915|       |  /* Return if Blosc is not initialized */
 6916|  4.92k|  if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  142|  4.92k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) return;
  ------------------
  |  |  104|  4.92k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6916:7): [True: 0, False: 4.92k]
  ------------------
 6917|       |
 6918|  4.92k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  4.92k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6919|  4.92k|  if (g_initlib != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  4.92k|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (6919:7): [True: 0, False: 4.92k]
  ------------------
 6920|      0|    static_unlock(&g_init_lock);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6921|      0|    return;
 6922|      0|  }
 6923|  4.92k|  store_release_int(&g_initlib, BLOSC_STATE_TEARDOWN);
  ------------------
  |  |  143|  4.92k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 6924|  4.92k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  4.92k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6925|       |
 6926|       |  /* Not under g_init_lock: a fork() holds the read-ahead pool's lock while it
 6927|       |     waits for g_init_lock (prefetch.c registers its fork handlers later).
 6928|       |     New prefetch operations and threads are blocked by blosc2_is_initialized(). */
 6929|  4.92k|  prefetch_destroy();
 6930|       |
 6931|  4.92k|  static_lock(&g_init_lock);
  ------------------
  |  |  132|  4.92k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6932|  4.92k|  blosc2_destroy_locked();
 6933|  4.92k|  store_release_int(&g_initlib, BLOSC_STATE_UNINITIALIZED);
  ------------------
  |  |  143|  4.92k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 6934|       |#if defined(_WIN32)
 6935|       |  WakeAllConditionVariable(&g_init_cv);
 6936|       |#else
 6937|  4.92k|  pthread_cond_broadcast(&g_init_cv);
 6938|  4.92k|#endif
 6939|  4.92k|  static_unlock(&g_init_lock);
  ------------------
  |  |  133|  4.92k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6940|  4.92k|}
blosc2_create_cctx:
 6946|  2.39M|blosc2_context* blosc2_create_cctx(blosc2_cparams cparams) {
 6947|  2.39M|  blosc2_context* context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 6948|  2.39M|  BLOSC_ERROR_NULL(context, NULL);
  ------------------
  |  |  104|  2.39M|    do {                                            \
  |  |  105|  2.39M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 2.39M]
  |  |  ------------------
  |  |  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.39M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 2.39M]
  |  |  ------------------
  ------------------
 6949|       |
 6950|       |  /* Populate the context, using zeros as default values */
 6951|  2.39M|  memset(context, 0, sizeof(blosc2_context));
 6952|       |  /* Early, so that the cleanup at `failed` can always destroy it */
 6953|  2.39M|  blosc2_pthread_mutex_init(&context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  2.39M|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 6954|  2.39M|  context->do_compress = 1;   /* meant for compression */
 6955|  2.39M|  context->use_dict = cparams.use_dict;
 6956|  2.39M|  if (cparams.instr_codec) {
  ------------------
  |  Branch (6956:7): [True: 0, False: 2.39M]
  ------------------
 6957|      0|    context->blosc2_flags = BLOSC2_INSTR_CODEC;
 6958|      0|  }
 6959|       |
 6960|  16.7M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (6960:19): [True: 14.3M, False: 2.39M]
  ------------------
 6961|  14.3M|    context->filters[i] = cparams.filters[i];
 6962|  14.3M|    context->filters_meta[i] = cparams.filters_meta[i];
 6963|       |
 6964|  14.3M|    if (context->filters[i] >= BLOSC_LAST_FILTER && context->filters[i] <= BLOSC2_DEFINED_FILTERS_STOP) {
  ------------------
  |  Branch (6964:9): [True: 114, False: 14.3M]
  |  Branch (6964:53): [True: 11, False: 103]
  ------------------
 6965|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6966|     11|                        context->filters[i]);
 6967|     11|      goto failed;
 6968|     11|    }
 6969|  14.3M|    if (context->filters[i] > BLOSC_LAST_REGISTERED_FILTER && context->filters[i] <= BLOSC2_GLOBAL_REGISTERED_FILTERS_STOP) {
  ------------------
  |  Branch (6969:9): [True: 93, False: 14.3M]
  |  Branch (6969:63): [True: 20, False: 73]
  ------------------
 6970|     20|      BLOSC_TRACE_ERROR("filter (%d) is not yet defined",
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6971|     20|                        context->filters[i]);
 6972|     20|      goto failed;
 6973|     20|    }
 6974|  14.3M|  }
 6975|       |
 6976|  2.39M|#if defined(HAVE_ZFP)
 6977|  2.39M|#include "blosc2/codecs-registry.h"
 6978|  2.39M|  if ((context->compcode >= BLOSC_CODEC_ZFP_FIXED_ACCURACY) && (context->compcode <= BLOSC_CODEC_ZFP_FIXED_RATE)) {
  ------------------
  |  Branch (6978:7): [True: 0, False: 2.39M]
  |  Branch (6978:64): [True: 0, False: 0]
  ------------------
 6979|      0|    for (int i = 0; i < BLOSC2_MAX_FILTERS; ++i) {
  ------------------
  |  Branch (6979:21): [True: 0, False: 0]
  ------------------
 6980|      0|      if ((context->filters[i] == BLOSC_SHUFFLE) || (context->filters[i] == BLOSC_BITSHUFFLE)) {
  ------------------
  |  Branch (6980:11): [True: 0, False: 0]
  |  Branch (6980:53): [True: 0, False: 0]
  ------------------
 6981|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6982|      0|        goto failed;
 6983|      0|      }
 6984|      0|    }
 6985|      0|  }
 6986|  2.39M|#endif /* HAVE_ZFP */
 6987|       |
 6988|       |  /* Check for a BLOSC_SHUFFLE environment variable */
 6989|  2.39M|  int doshuffle = -1;
 6990|  2.39M|  char* envvar = getenv("BLOSC_SHUFFLE");
 6991|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (6991:7): [True: 0, False: 2.39M]
  ------------------
 6992|      0|    if (strcmp(envvar, "NOSHUFFLE") == 0) {
  ------------------
  |  Branch (6992:9): [True: 0, False: 0]
  ------------------
 6993|      0|      doshuffle = BLOSC_NOSHUFFLE;
 6994|      0|    }
 6995|      0|    else if (strcmp(envvar, "SHUFFLE") == 0) {
  ------------------
  |  Branch (6995:14): [True: 0, False: 0]
  ------------------
 6996|      0|      doshuffle = BLOSC_SHUFFLE;
 6997|      0|    }
 6998|      0|    else if (strcmp(envvar, "BITSHUFFLE") == 0) {
  ------------------
  |  Branch (6998:14): [True: 0, False: 0]
  ------------------
 6999|      0|      doshuffle = BLOSC_BITSHUFFLE;
 7000|      0|    }
 7001|      0|    else {
 7002|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7003|      0|    }
 7004|      0|  }
 7005|       |  /* Check for a BLOSC_DELTA environment variable */
 7006|  2.39M|  int dodelta = BLOSC_NOFILTER;
 7007|  2.39M|  envvar = getenv("BLOSC_DELTA");
 7008|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7008:7): [True: 0, False: 2.39M]
  ------------------
 7009|      0|    if (strcmp(envvar, "1") == 0) {
  ------------------
  |  Branch (7009:9): [True: 0, False: 0]
  ------------------
 7010|      0|      dodelta = BLOSC_DELTA;
 7011|      0|    } else if (strcmp(envvar, "0") == 0){
  ------------------
  |  Branch (7011:16): [True: 0, False: 0]
  ------------------
 7012|      0|      dodelta = BLOSC_NOFILTER;
 7013|      0|    }
 7014|      0|    else {
 7015|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7016|      0|    }
 7017|      0|  }
 7018|       |  /* Check for a BLOSC_TYPESIZE environment variable */
 7019|  2.39M|  context->typesize = cparams.typesize;
 7020|  2.39M|  envvar = getenv("BLOSC_TYPESIZE");
 7021|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7021:7): [True: 0, False: 2.39M]
  ------------------
 7022|      0|    int32_t value;
 7023|      0|    errno = 0; /* To distinguish success/failure after call */
 7024|      0|    value = (int32_t) strtol(envvar, NULL, 10);
 7025|      0|    if ((errno != EINVAL) && (value > 0)) {
  ------------------
  |  Branch (7025:9): [True: 0, False: 0]
  |  Branch (7025:30): [True: 0, False: 0]
  ------------------
 7026|      0|      context->typesize = value;
 7027|      0|    }
 7028|      0|    else {
 7029|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7030|      0|    }
 7031|      0|  }
 7032|  2.39M|  build_filters(doshuffle, dodelta, context->typesize, context->filters);
 7033|       |
 7034|  2.39M|  context->clevel = cparams.clevel;
 7035|       |  /* Check for a BLOSC_CLEVEL environment variable */
 7036|  2.39M|  envvar = getenv("BLOSC_CLEVEL");
 7037|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7037:7): [True: 0, False: 2.39M]
  ------------------
 7038|      0|    int value;
 7039|      0|    errno = 0; /* To distinguish success/failure after call */
 7040|      0|    value = (int)strtol(envvar, NULL, 10);
 7041|      0|    if ((errno != EINVAL) && (value >= 0)) {
  ------------------
  |  Branch (7041:9): [True: 0, False: 0]
  |  Branch (7041:30): [True: 0, False: 0]
  ------------------
 7042|      0|      context->clevel = value;
 7043|      0|    }
 7044|      0|    else {
 7045|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7046|      0|    }
 7047|      0|  }
 7048|       |
 7049|  2.39M|  context->compcode = cparams.compcode;
 7050|       |  /* Check for a BLOSC_COMPRESSOR environment variable */
 7051|  2.39M|  envvar = getenv("BLOSC_COMPRESSOR");
 7052|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7052:7): [True: 0, False: 2.39M]
  ------------------
 7053|      0|    int codec = blosc2_compname_to_compcode(envvar);
 7054|      0|    if (codec >= BLOSC_LAST_CODEC) {
  ------------------
  |  Branch (7054:9): [True: 0, False: 0]
  ------------------
 7055|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7056|      0|      goto failed;
 7057|      0|    }
 7058|      0|    context->compcode = codec;
 7059|      0|  }
 7060|  2.39M|  context->compcode_meta = cparams.compcode_meta;
 7061|       |
 7062|  2.39M|  context->blocksize = cparams.blocksize;
 7063|       |  /* Check for a BLOSC_BLOCKSIZE environment variable */
 7064|  2.39M|  envvar = getenv("BLOSC_BLOCKSIZE");
 7065|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7065:7): [True: 0, False: 2.39M]
  ------------------
 7066|      0|    int32_t blocksize;
 7067|      0|    errno = 0; /* To distinguish success/failure after call */
 7068|      0|    blocksize = (int32_t) strtol(envvar, NULL, 10);
 7069|      0|    if ((errno != EINVAL) && (blocksize > 0)) {
  ------------------
  |  Branch (7069:9): [True: 0, False: 0]
  |  Branch (7069:30): [True: 0, False: 0]
  ------------------
 7070|      0|      context->blocksize = blocksize;
 7071|      0|    }
 7072|      0|    else {
 7073|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7074|      0|    }
 7075|      0|  }
 7076|       |
 7077|  2.39M|  context->nthreads = cparams.nthreads;
 7078|       |  /* Check for a BLOSC_NTHREADS environment variable */
 7079|  2.39M|  envvar = getenv("BLOSC_NTHREADS");
 7080|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7080:7): [True: 0, False: 2.39M]
  ------------------
 7081|      0|    errno = 0; /* To distinguish success/failure after call */
 7082|      0|    int16_t nthreads = (int16_t) strtol(envvar, NULL, 10);
 7083|      0|    if ((errno != EINVAL) && (nthreads > 0)) {
  ------------------
  |  Branch (7083:9): [True: 0, False: 0]
  |  Branch (7083:30): [True: 0, False: 0]
  ------------------
 7084|      0|      context->nthreads = nthreads;
 7085|      0|    }
 7086|      0|    else {
 7087|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7088|      0|    }
 7089|      0|  }
 7090|  2.39M|  context->new_nthreads = context->nthreads;
 7091|       |
 7092|  2.39M|  context->splitmode = cparams.splitmode;
 7093|       |  /* Check for a BLOSC_SPLITMODE environment variable */
 7094|  2.39M|  envvar = getenv("BLOSC_SPLITMODE");
 7095|  2.39M|  if (envvar != NULL) {
  ------------------
  |  Branch (7095:7): [True: 0, False: 2.39M]
  ------------------
 7096|      0|    int32_t splitmode = -1;
 7097|      0|    if (strcmp(envvar, "ALWAYS") == 0) {
  ------------------
  |  Branch (7097:9): [True: 0, False: 0]
  ------------------
 7098|      0|      splitmode = BLOSC_ALWAYS_SPLIT;
 7099|      0|    }
 7100|      0|    else if (strcmp(envvar, "NEVER") == 0) {
  ------------------
  |  Branch (7100:14): [True: 0, False: 0]
  ------------------
 7101|      0|      splitmode = BLOSC_NEVER_SPLIT;
 7102|      0|    }
 7103|      0|    else if (strcmp(envvar, "AUTO") == 0) {
  ------------------
  |  Branch (7103:14): [True: 0, False: 0]
  ------------------
 7104|      0|      splitmode = BLOSC_AUTO_SPLIT;
 7105|      0|    }
 7106|      0|    else if (strcmp(envvar, "FORWARD_COMPAT") == 0) {
  ------------------
  |  Branch (7106:14): [True: 0, False: 0]
  ------------------
 7107|      0|      splitmode = BLOSC_FORWARD_COMPAT_SPLIT;
 7108|      0|    }
 7109|      0|    else {
 7110|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7111|      0|    }
 7112|      0|    if (splitmode >= 0) {
  ------------------
  |  Branch (7112:9): [True: 0, False: 0]
  ------------------
 7113|      0|      context->splitmode = splitmode;
 7114|      0|    }
 7115|      0|  }
 7116|       |
 7117|  2.39M|  context->threads_started = 0;
 7118|  2.39M|  context->schunk = cparams.schunk;
 7119|       |
 7120|  2.39M|  if (cparams.prefilter != NULL) {
  ------------------
  |  Branch (7120:7): [True: 0, False: 2.39M]
  ------------------
 7121|      0|    context->prefilter = cparams.prefilter;
 7122|      0|    context->preparams = (blosc2_prefilter_params*)my_malloc(sizeof(blosc2_prefilter_params));
 7123|      0|    if (context->preparams == NULL) {
  ------------------
  |  Branch (7123:9): [True: 0, False: 0]
  ------------------
 7124|      0|      goto failed;
 7125|      0|    }
 7126|      0|    memcpy(context->preparams, cparams.preparams, sizeof(blosc2_prefilter_params));
 7127|      0|  }
 7128|       |
 7129|  2.39M|  if (cparams.tuner_id <= 0) {
  ------------------
  |  Branch (7129:7): [True: 2.39M, False: 0]
  ------------------
 7130|  2.39M|    cparams.tuner_id = g_tuner;
 7131|  2.39M|  } else {
 7132|      0|    for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7132:21): [True: 0, False: 0]
  ------------------
 7133|      0|      if (g_tuners[i].id == cparams.tuner_id) {
  ------------------
  |  Branch (7133:11): [True: 0, False: 0]
  ------------------
 7134|      0|        if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (7134:13): [True: 0, False: 0]
  ------------------
 7135|      0|          if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (7135:15): [True: 0, False: 0]
  ------------------
 7136|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7137|      0|            goto failed;
 7138|      0|          }
 7139|      0|        }
 7140|      0|        if (g_tuners[i].init(cparams.tuner_params, context, NULL) < 0) {
  ------------------
  |  Branch (7140:13): [True: 0, False: 0]
  ------------------
 7141|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7142|      0|          goto failed;
 7143|      0|        }
 7144|      0|        goto urtunersuccess;
 7145|      0|      }
 7146|      0|    }
 7147|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7148|      0|    goto failed;
 7149|      0|  }
 7150|  2.39M|  urtunersuccess:;
 7151|       |
 7152|  2.39M|  context->tuner_id = cparams.tuner_id;
 7153|       |
 7154|  2.39M|  context->codec_params = cparams.codec_params;
 7155|  2.39M|  memcpy(context->filter_params, cparams.filter_params, BLOSC2_MAX_FILTERS * sizeof(void*));
 7156|       |
 7157|  2.39M|  return context;
 7158|       |
 7159|     31|failed:
 7160|     31|  my_free(context->preparams);
 7161|     31|  blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|     31|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7162|     31|  my_free(context);
 7163|       |  return NULL;
 7164|  2.39M|}
blosc2_create_dctx:
 7167|  1.03M|blosc2_context* blosc2_create_dctx(blosc2_dparams dparams) {
 7168|  1.03M|  blosc2_context* context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 7169|  1.03M|  BLOSC_ERROR_NULL(context, NULL);
  ------------------
  |  |  104|  1.03M|    do {                                            \
  |  |  105|  1.03M|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 1.03M]
  |  |  ------------------
  |  |  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.03M|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 1.03M]
  |  |  ------------------
  ------------------
 7170|       |
 7171|       |  /* Populate the context, using zeros as default values */
 7172|  1.03M|  memset(context, 0, sizeof(blosc2_context));
 7173|  1.03M|  context->do_compress = 0;   /* Meant for decompression */
 7174|       |
 7175|  1.03M|  context->nthreads = dparams.nthreads;
 7176|  1.03M|  char* envvar = getenv("BLOSC_NTHREADS");
 7177|  1.03M|  if (envvar != NULL) {
  ------------------
  |  Branch (7177:7): [True: 0, False: 1.03M]
  ------------------
 7178|      0|    errno = 0; /* To distinguish success/failure after call */
 7179|      0|    long nthreads = strtol(envvar, NULL, 10);
 7180|      0|    if ((errno != EINVAL) && (nthreads > 0)) {
  ------------------
  |  Branch (7180:9): [True: 0, False: 0]
  |  Branch (7180:30): [True: 0, False: 0]
  ------------------
 7181|      0|      context->nthreads = (int16_t) nthreads;
 7182|      0|    }
 7183|      0|  }
 7184|  1.03M|  context->new_nthreads = context->nthreads;
 7185|       |
 7186|  1.03M|  context->threads_started = 0;
 7187|  1.03M|  context->block_maskout = NULL;
 7188|  1.03M|  context->block_maskout_nitems = 0;
 7189|  1.03M|  blosc2_pthread_mutex_init(&context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  1.03M|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 7190|  1.03M|  context->schunk = dparams.schunk;
 7191|       |
 7192|  1.03M|  if (dparams.postfilter != NULL) {
  ------------------
  |  Branch (7192:7): [True: 0, False: 1.03M]
  ------------------
 7193|      0|    context->postfilter = dparams.postfilter;
 7194|      0|    context->postparams = (blosc2_postfilter_params*)my_malloc(sizeof(blosc2_postfilter_params));
 7195|      0|    if (context->postparams == NULL) {
  ------------------
  |  Branch (7195:9): [True: 0, False: 0]
  ------------------
 7196|      0|      blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7197|      0|      my_free(context);
 7198|      0|      return NULL;
 7199|      0|    }
 7200|      0|    memcpy(context->postparams, dparams.postparams, sizeof(blosc2_postfilter_params));
 7201|      0|  }
 7202|       |
 7203|  1.03M|  return context;
 7204|  1.03M|}
blosc2_free_ctx:
 7207|  3.42M|void blosc2_free_ctx(blosc2_context* context) {
 7208|  3.42M|  if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED ||
  ------------------
  |  |  142|  3.42M|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) == BLOSC_STATE_INITIALIZED ||
  ------------------
  |  |  104|  6.85M|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7208:7): [True: 3.42M, False: 4.92k]
  ------------------
 7209|  4.92k|      context->thread_backend == BLOSC_BACKEND_PER_CONTEXT ||
  ------------------
  |  |   36|  3.43M|#define BLOSC_BACKEND_PER_CONTEXT 3   /* per-context threads; used on Windows */
  ------------------
  |  Branch (7209:7): [True: 0, False: 4.92k]
  ------------------
 7210|  3.42M|      context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|  4.92k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (7210:7): [True: 0, False: 4.92k]
  ------------------
 7211|  3.42M|    release_thread_backend(context);
 7212|  3.42M|  }
 7213|  3.42M|  if (context->serial_context != NULL) {
  ------------------
  |  Branch (7213:7): [True: 201, False: 3.42M]
  ------------------
 7214|    201|    free_thread_context(context->serial_context);
 7215|    201|  }
 7216|  3.42M|  blosc2_pthread_mutex_destroy(&context->nchunk_mutex);
  ------------------
  |  |   91|  3.42M|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 7217|  3.42M|  release_context_dict_buffer(context);
 7218|  3.42M|  if (context->dict_cdict != NULL) {
  ------------------
  |  Branch (7218:7): [True: 0, False: 3.42M]
  ------------------
 7219|      0|    if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (7219:9): [True: 0, False: 0]
  ------------------
 7220|      0|      LZ4_freeStream((LZ4_stream_t*)context->dict_cdict);
 7221|      0|    } else if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (7221:16): [True: 0, False: 0]
  ------------------
 7222|      0|      LZ4_freeStreamHC((LZ4_streamHC_t*)context->dict_cdict);
 7223|      0|    }
 7224|      0|#ifdef HAVE_ZSTD
 7225|      0|    else if (context->compcode == BLOSC_ZSTD) {
  ------------------
  |  Branch (7225:14): [True: 0, False: 0]
  ------------------
 7226|      0|      ZSTD_freeCDict(context->dict_cdict);
 7227|      0|    }
 7228|      0|#endif
 7229|      0|  }
 7230|  3.42M|  if (context->dict_ddict != NULL) {
  ------------------
  |  Branch (7230:7): [True: 14, False: 3.42M]
  ------------------
 7231|     14|#ifdef HAVE_ZSTD
 7232|     14|    ZSTD_freeDDict(context->dict_ddict);
 7233|     14|#endif
 7234|     14|  }
 7235|  3.42M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (7235:7): [True: 0, False: 3.42M]
  ------------------
 7236|      0|    int rc;
 7237|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (7237:9): [True: 0, False: 0]
  |  Branch (7237:49): [True: 0, False: 0]
  ------------------
 7238|      0|      rc = blosc_stune_free(context);
 7239|      0|    } else {
 7240|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7240:23): [True: 0, False: 0]
  ------------------
 7241|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (7241:13): [True: 0, False: 0]
  ------------------
 7242|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (7242:15): [True: 0, False: 0]
  ------------------
 7243|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (7243:17): [True: 0, False: 0]
  ------------------
 7244|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7245|      0|              return;
 7246|      0|            }
 7247|      0|          }
 7248|      0|          rc = g_tuners[i].free(context);
 7249|      0|          goto urtunersuccess;
 7250|      0|        }
 7251|      0|      }
 7252|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7253|      0|      return;
 7254|      0|      urtunersuccess:;
 7255|      0|    }
 7256|      0|    if (rc < 0) {
  ------------------
  |  Branch (7256:9): [True: 0, False: 0]
  ------------------
 7257|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7258|      0|      return;
 7259|      0|    }
 7260|      0|  }
 7261|       |  /* May be needed if codec_params ever contains nested objects
 7262|       |  if (context->codec_params != NULL) {
 7263|       |    int rc;
 7264|       |    for (int i = 0; i < g_ncodecs; ++i) {
 7265|       |      if (g_codecs[i].compcode == context->compcode) {
 7266|       |        if (g_codecs[i].free == NULL) {
 7267|       |          // Dynamically load codec plugin
 7268|       |          if (fill_codec(&g_codecs[i]) < 0) {
 7269|       |            BLOSC_TRACE_ERROR("Could not load codec %d.", g_codecs[i].compcode);
 7270|       |            return BLOSC2_ERROR_CODEC_SUPPORT;
 7271|       |          }
 7272|       |        }
 7273|       |        if (g_codecs[i].free == NULL){
 7274|       |          // no free func, codec_params is simple
 7275|       |          my_free(context->codec_params);
 7276|       |        }
 7277|       |        else{ // has free function for codec_params (e.g. openzl)
 7278|       |        rc = g_codecs[i].free(context->codec_params);
 7279|       |          goto urcodecsuccess;
 7280|       |        }
 7281|       |      }
 7282|       |    }
 7283|       |      BLOSC_TRACE_ERROR("User-defined compressor codec %d not found", context->compcode);
 7284|       |      return BLOSC2_ERROR_CODEC_SUPPORT;
 7285|       |    urcodecsuccess:;
 7286|       |    if (rc < 0) {
 7287|       |      BLOSC_TRACE_ERROR("Error in user-defined codec free function\n");
 7288|       |      return;
 7289|       |    }
 7290|       |  }
 7291|       |  */
 7292|  3.42M|  if (context->prefilter != NULL) {
  ------------------
  |  Branch (7292:7): [True: 0, False: 3.42M]
  ------------------
 7293|      0|    my_free(context->preparams);
 7294|      0|  }
 7295|  3.42M|  if (context->postfilter != NULL) {
  ------------------
  |  Branch (7295:7): [True: 0, False: 3.42M]
  ------------------
 7296|      0|    my_free(context->postparams);
 7297|      0|  }
 7298|       |
 7299|  3.42M|  if (context->block_maskout != NULL) {
  ------------------
  |  Branch (7299:7): [True: 0, False: 3.42M]
  ------------------
 7300|      0|    free(context->block_maskout);
 7301|      0|  }
 7302|  3.42M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (7302:7): [True: 91, False: 3.42M]
  ------------------
 7303|     91|    free(context->blocknbytes);
 7304|     91|  }
 7305|  3.42M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (7305:7): [True: 91, False: 3.42M]
  ------------------
 7306|     91|    free(context->blockoffsets);
 7307|     91|  }
 7308|  3.42M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (7308:7): [True: 91, False: 3.42M]
  ------------------
 7309|     91|    free(context->blockcbytes);
 7310|     91|  }
 7311|  3.42M|  my_free(context);
 7312|  3.42M|}
blosc2_ctx_get_dparams:
 7339|    425|int blosc2_ctx_get_dparams(blosc2_context *ctx, blosc2_dparams *dparams) {
 7340|    425|  dparams->nthreads = ctx->nthreads;
 7341|    425|  dparams->schunk = ctx->schunk;
 7342|    425|  dparams->postfilter = ctx->postfilter;
 7343|    425|  dparams->postparams = ctx->postparams;
 7344|    425|  dparams->typesize = ctx->typesize;
 7345|       |
 7346|    425|  return BLOSC2_ERROR_SUCCESS;
 7347|    425|}
blosc2_set_maskout:
 7360|   232k|int blosc2_set_maskout(blosc2_context *ctx, bool *maskout, int nblocks) {
 7361|       |  // Get rid of a possible mask here (also if the allocation below fails)
 7362|   232k|  ctx_clear_maskout(ctx);
 7363|       |
 7364|   232k|  bool *maskout_ = malloc(nblocks);
 7365|   232k|  BLOSC_ERROR_NULL(maskout_, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|   232k|    do {                                            \
  |  |  105|   232k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 232k]
  |  |  ------------------
  |  |  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|   232k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 232k]
  |  |  ------------------
  ------------------
 7366|   232k|  memcpy(maskout_, maskout, nblocks);
 7367|   232k|  ctx->block_maskout = maskout_;
 7368|   232k|  ctx->block_maskout_nitems = nblocks;
 7369|       |
 7370|   232k|  return 0;
 7371|   232k|}
blosc2_chunk_zeros:
 7375|  1.35M|int blosc2_chunk_zeros(blosc2_cparams cparams, const int32_t nbytes, void* dest, int32_t destsize) {
 7376|  1.35M|  if (destsize < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (7376:7): [True: 0, False: 1.35M]
  ------------------
 7377|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7378|      0|    return BLOSC2_ERROR_DATA;
 7379|      0|  }
 7380|       |
 7381|  1.35M|  if ((nbytes > 0) && (nbytes % cparams.typesize)) {
  ------------------
  |  Branch (7381:7): [True: 1.35M, False: 6.58k]
  |  Branch (7381:23): [True: 0, False: 1.35M]
  ------------------
 7382|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7383|      0|    return BLOSC2_ERROR_DATA;
 7384|      0|  }
 7385|       |
 7386|  1.35M|  blosc_header header;
 7387|  1.35M|  blosc2_context* context = blosc2_create_cctx(cparams);
 7388|  1.35M|  if (context == NULL) {
  ------------------
  |  Branch (7388:7): [True: 0, False: 1.35M]
  ------------------
 7389|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7390|      0|    return BLOSC2_ERROR_NULL_POINTER;
 7391|      0|  }
 7392|       |
 7393|  1.35M|  int error = initialize_context_compression(
 7394|  1.35M|          context, NULL, nbytes, dest, destsize,
 7395|  1.35M|          context->clevel, context->filters, context->filters_meta,
 7396|  1.35M|          context->typesize, context->compcode, context->blocksize,
 7397|  1.35M|          context->new_nthreads, context->nthreads, context->splitmode,
 7398|  1.35M|          context->tuner_id, context->tuner_params, context->schunk);
 7399|  1.35M|  if (error <= 0) {
  ------------------
  |  Branch (7399:7): [True: 0, False: 1.35M]
  ------------------
 7400|      0|    blosc2_free_ctx(context);
 7401|      0|    return error;
 7402|      0|  }
 7403|       |
 7404|  1.35M|  memset(&header, 0, sizeof(header));
 7405|  1.35M|  header.version = BLOSC2_VERSION_FORMAT_STABLE;
 7406|  1.35M|  header.versionlz = BLOSC_BLOSCLZ_VERSION_FORMAT;
 7407|  1.35M|  header.flags = BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE;  // extended header
 7408|  1.35M|  header.typesize = context->typesize;
 7409|  1.35M|  header.nbytes = (int32_t)nbytes;
 7410|  1.35M|  header.blocksize = context->blocksize;
 7411|  1.35M|  header.cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 7412|  1.35M|  header.blosc2_flags = BLOSC2_SPECIAL_ZERO << 4;  // mark chunk as all zeros
 7413|  1.35M|  memcpy((uint8_t *)dest, &header, sizeof(header));
 7414|       |
 7415|  1.35M|  blosc2_free_ctx(context);
 7416|       |
 7417|  1.35M|  return BLOSC_EXTENDED_HEADER_LENGTH;
 7418|  1.35M|}
blosc2_chunk_repeatval:
 7516|  5.05k|                           void* dest, int32_t destsize, const void* repeatval) {
 7517|  5.05k|  if (destsize < BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize) {
  ------------------
  |  Branch (7517:7): [True: 0, False: 5.05k]
  ------------------
 7518|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7519|      0|    return BLOSC2_ERROR_DATA;
 7520|      0|  }
 7521|       |
 7522|  5.05k|  if (nbytes % cparams.typesize) {
  ------------------
  |  Branch (7522:7): [True: 0, False: 5.05k]
  ------------------
 7523|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7524|      0|    return BLOSC2_ERROR_DATA;
 7525|      0|  }
 7526|       |
 7527|  5.05k|  blosc_header header;
 7528|  5.05k|  blosc2_context* context = blosc2_create_cctx(cparams);
 7529|  5.05k|  if (context == NULL) {
  ------------------
  |  Branch (7529:7): [True: 0, False: 5.05k]
  ------------------
 7530|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7531|      0|    return BLOSC2_ERROR_NULL_POINTER;
 7532|      0|  }
 7533|       |
 7534|  5.05k|  int error = initialize_context_compression(
 7535|  5.05k|          context, NULL, nbytes, dest, destsize,
 7536|  5.05k|          context->clevel, context->filters, context->filters_meta,
 7537|  5.05k|          context->typesize, context->compcode, context->blocksize,
 7538|  5.05k|          context->new_nthreads, context->nthreads, context->splitmode,
 7539|  5.05k|          context->tuner_id, context->tuner_params, context->schunk);
 7540|  5.05k|  if (error <= 0) {
  ------------------
  |  Branch (7540:7): [True: 0, False: 5.05k]
  ------------------
 7541|      0|    blosc2_free_ctx(context);
 7542|      0|    return error;
 7543|      0|  }
 7544|       |
 7545|  5.05k|  memset(&header, 0, sizeof(header));
 7546|  5.05k|  header.version = BLOSC2_VERSION_FORMAT_STABLE;
 7547|  5.05k|  header.versionlz = BLOSC_BLOSCLZ_VERSION_FORMAT;
 7548|  5.05k|  header.flags = BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE;  // extended header
 7549|  5.05k|  header.typesize = context->typesize;
 7550|  5.05k|  header.nbytes = (int32_t)nbytes;
 7551|  5.05k|  header.blocksize = context->blocksize;
 7552|  5.05k|  header.cbytes = BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize;
 7553|  5.05k|  header.blosc2_flags = BLOSC2_SPECIAL_VALUE << 4;  // mark chunk as all repeated value
 7554|  5.05k|  memcpy((uint8_t *)dest, &header, sizeof(header));
 7555|  5.05k|  memcpy((uint8_t *)dest + sizeof(header), repeatval, cparams.typesize);
 7556|       |
 7557|  5.05k|  blosc2_free_ctx(context);
 7558|       |
 7559|  5.05k|  return BLOSC_EXTENDED_HEADER_LENGTH + cparams.typesize;
 7560|  5.05k|}
register_filter_private:
 7565|  24.6k|int register_filter_private(blosc2_filter *filter) {
 7566|  24.6k|    BLOSC_ERROR_NULL(filter, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  24.6k|    do {                                            \
  |  |  105|  24.6k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 24.6k]
  |  |  ------------------
  |  |  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|  24.6k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 24.6k]
  |  |  ------------------
  ------------------
 7567|  24.6k|    if (g_nfilters == UINT8_MAX) {
  ------------------
  |  Branch (7567:9): [True: 0, False: 24.6k]
  ------------------
 7568|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7569|      0|        return BLOSC2_ERROR_CODEC_SUPPORT;
 7570|      0|    }
 7571|  24.6k|    if (filter->id < BLOSC2_GLOBAL_REGISTERED_FILTERS_START) {
  ------------------
  |  Branch (7571:9): [True: 0, False: 24.6k]
  ------------------
 7572|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7573|      0|        return BLOSC2_ERROR_FAILURE;
 7574|      0|    }
 7575|       |    /* This condition can never be fulfilled
 7576|       |    if (filter->id > BLOSC2_USER_REGISTERED_FILTERS_STOP) {
 7577|       |        BLOSC_TRACE_ERROR("The id must be less than or equal to %d", BLOSC2_USER_REGISTERED_FILTERS_STOP);
 7578|       |        return BLOSC2_ERROR_FAILURE;
 7579|       |    }
 7580|       |    */
 7581|       |
 7582|  73.8k|    for (uint64_t i = 0; i < g_nfilters; ++i) {
  ------------------
  |  Branch (7582:26): [True: 49.2k, False: 24.6k]
  ------------------
 7583|  49.2k|      if (g_filters[i].id == filter->id) {
  ------------------
  |  Branch (7583:11): [True: 0, False: 49.2k]
  ------------------
 7584|      0|        if (strcmp(g_filters[i].name, filter->name) != 0) {
  ------------------
  |  Branch (7584:13): [True: 0, False: 0]
  ------------------
 7585|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7586|      0|                            "  Choose another one !", filter->id, g_filters[i].name);
 7587|      0|          return BLOSC2_ERROR_FAILURE;
 7588|      0|        }
 7589|      0|        else {
 7590|       |          // Already registered, so no more actions needed
 7591|      0|          return BLOSC2_ERROR_SUCCESS;
 7592|      0|        }
 7593|      0|      }
 7594|  49.2k|    }
 7595|       |
 7596|  24.6k|    blosc2_filter *filter_new = &g_filters[g_nfilters++];
 7597|  24.6k|    memcpy(filter_new, filter, sizeof(blosc2_filter));
 7598|       |
 7599|  24.6k|    return BLOSC2_ERROR_SUCCESS;
 7600|  24.6k|}
register_codec_private:
 7615|  44.2k|int register_codec_private(blosc2_codec *codec) {
 7616|  44.2k|    BLOSC_ERROR_NULL(codec, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  44.2k|    do {                                            \
  |  |  105|  44.2k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 44.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|  44.2k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 44.2k]
  |  |  ------------------
  ------------------
 7617|  44.2k|    if (g_ncodecs == UINT8_MAX) {
  ------------------
  |  Branch (7617:9): [True: 0, False: 44.2k]
  ------------------
 7618|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7619|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 7620|      0|    }
 7621|  44.2k|    if (codec->compcode < BLOSC2_GLOBAL_REGISTERED_CODECS_START) {
  ------------------
  |  Branch (7621:9): [True: 0, False: 44.2k]
  ------------------
 7622|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7623|      0|      return BLOSC2_ERROR_FAILURE;
 7624|      0|    }
 7625|       |    /* This condition can never be fulfilled
 7626|       |    if (codec->compcode > BLOSC2_USER_REGISTERED_CODECS_STOP) {
 7627|       |      BLOSC_TRACE_ERROR("The id must be less or equal to %d", BLOSC2_USER_REGISTERED_CODECS_STOP);
 7628|       |      return BLOSC2_ERROR_FAILURE;
 7629|       |    }
 7630|       |     */
 7631|       |
 7632|   221k|    for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (7632:21): [True: 177k, False: 44.2k]
  ------------------
 7633|   177k|      if (g_codecs[i].compcode == codec->compcode) {
  ------------------
  |  Branch (7633:11): [True: 0, False: 177k]
  ------------------
 7634|      0|        if (strcmp(g_codecs[i].compname, codec->compname) != 0) {
  ------------------
  |  Branch (7634:13): [True: 0, False: 0]
  ------------------
 7635|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7636|      0|                            "  Choose another one !", codec->compcode, codec->compname);
 7637|      0|          return BLOSC2_ERROR_CODEC_PARAM;
 7638|      0|        }
 7639|      0|        else {
 7640|       |          // Already registered, so no more actions needed
 7641|      0|          return BLOSC2_ERROR_SUCCESS;
 7642|      0|        }
 7643|      0|      }
 7644|   177k|    }
 7645|       |
 7646|  44.2k|    blosc2_codec *codec_new = &g_codecs[g_ncodecs++];
 7647|  44.2k|    memcpy(codec_new, codec, sizeof(blosc2_codec));
 7648|       |
 7649|  44.2k|    return BLOSC2_ERROR_SUCCESS;
 7650|  44.2k|}
register_tuner_private:
 7665|  4.92k|int register_tuner_private(blosc2_tuner *tuner) {
 7666|  4.92k|  BLOSC_ERROR_NULL(tuner, BLOSC2_ERROR_INVALID_PARAM);
  ------------------
  |  |  104|  4.92k|    do {                                            \
  |  |  105|  4.92k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.92k]
  |  |  ------------------
  |  |  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.92k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.92k]
  |  |  ------------------
  ------------------
 7667|  4.92k|  if (g_ntuners == UINT8_MAX) {
  ------------------
  |  Branch (7667:7): [True: 0, False: 4.92k]
  ------------------
 7668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7669|      0|    return BLOSC2_ERROR_CODEC_SUPPORT;
 7670|      0|  }
 7671|  4.92k|  if (tuner->id < BLOSC2_GLOBAL_REGISTERED_TUNER_START) {
  ------------------
  |  Branch (7671:7): [True: 0, False: 4.92k]
  ------------------
 7672|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7673|      0|    return BLOSC2_ERROR_FAILURE;
 7674|      0|  }
 7675|       |
 7676|  4.92k|  for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (7676:19): [True: 0, False: 4.92k]
  ------------------
 7677|      0|    if (g_tuners[i].id == tuner->id) {
  ------------------
  |  Branch (7677:9): [True: 0, False: 0]
  ------------------
 7678|      0|      if (strcmp(g_tuners[i].name, tuner->name) != 0) {
  ------------------
  |  Branch (7678:11): [True: 0, False: 0]
  ------------------
 7679|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7680|      0|                          "  Choose another one !", tuner->id, g_tuners[i].name);
 7681|      0|        return BLOSC2_ERROR_FAILURE;
 7682|      0|      }
 7683|      0|      else {
 7684|       |        // Already registered, so no more actions needed
 7685|      0|        return BLOSC2_ERROR_SUCCESS;
 7686|      0|      }
 7687|      0|    }
 7688|      0|  }
 7689|       |
 7690|  4.92k|  blosc2_tuner *tuner_new = &g_tuners[g_ntuners++];
 7691|  4.92k|  memcpy(tuner_new, tuner, sizeof(blosc2_tuner));
 7692|       |
 7693|  4.92k|  return BLOSC2_ERROR_SUCCESS;
 7694|  4.92k|}
_blosc2_register_io_cb:
 7707|  9.84k|int _blosc2_register_io_cb(const blosc2_io_cb *io) {
 7708|       |
 7709|  14.7k|  for (uint64_t i = 0; i < g_nio; ++i) {
  ------------------
  |  Branch (7709:24): [True: 14.7k, False: 2]
  ------------------
 7710|  14.7k|    if (g_ios[i].id == io->id) {
  ------------------
  |  Branch (7710:9): [True: 9.84k, False: 4.92k]
  ------------------
 7711|  9.84k|      if (strcmp(g_ios[i].name, io->name) != 0) {
  ------------------
  |  Branch (7711:11): [True: 0, False: 9.84k]
  ------------------
 7712|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7713|      0|                          "  Choose another one !", io->id, g_ios[i].name);
 7714|      0|        return BLOSC2_ERROR_PLUGIN_IO;
 7715|      0|      }
 7716|  9.84k|      else {
 7717|       |        // Already registered, so no more actions needed
 7718|  9.84k|        return BLOSC2_ERROR_SUCCESS;
 7719|  9.84k|      }
 7720|  9.84k|    }
 7721|  14.7k|  }
 7722|       |
 7723|      2|  blosc2_io_cb *io_new = &g_ios[g_nio++];
 7724|      2|  memcpy(io_new, io, sizeof(blosc2_io_cb));
 7725|       |
 7726|      2|  return BLOSC2_ERROR_SUCCESS;
 7727|  9.84k|}
blosc2_get_io_cb:
 7744|  8.60M|blosc2_io_cb *blosc2_get_io_cb(uint8_t id) {
 7745|       |  // If g_initlib is not set by blosc2_init() this function will try to read
 7746|       |  // uninitialized memory. We should therefore always return NULL in that case
 7747|  8.60M|  if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  142|  8.60M|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
                if (load_acquire_int(&g_initlib) != BLOSC_STATE_INITIALIZED) {
  ------------------
  |  |  104|  8.60M|#define BLOSC_STATE_INITIALIZED   1
  ------------------
  |  Branch (7747:7): [True: 0, False: 8.60M]
  ------------------
 7748|      0|    return NULL;
 7749|      0|  }
 7750|  8.60M|  for (uint64_t i = 0; i < g_nio; ++i) {
  ------------------
  |  Branch (7750:24): [True: 8.60M, False: 0]
  ------------------
 7751|  8.60M|    if (g_ios[i].id == id) {
  ------------------
  |  Branch (7751:9): [True: 8.60M, False: 0]
  ------------------
 7752|  8.60M|      return &g_ios[i];
 7753|  8.60M|    }
 7754|  8.60M|  }
 7755|      0|  if (id == BLOSC2_IO_FILESYSTEM) {
  ------------------
  |  Branch (7755:7): [True: 0, False: 0]
  ------------------
 7756|      0|    if (_blosc2_register_io_cb(&BLOSC2_IO_CB_DEFAULTS) < 0) {
  ------------------
  |  Branch (7756:9): [True: 0, False: 0]
  ------------------
 7757|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7758|      0|      return NULL;
 7759|      0|    }
 7760|      0|    return blosc2_get_io_cb(id);
 7761|      0|  }
 7762|      0|  else if (id == BLOSC2_IO_FILESYSTEM_MMAP) {
  ------------------
  |  Branch (7762:12): [True: 0, False: 0]
  ------------------
 7763|      0|    if (_blosc2_register_io_cb(&BLOSC2_IO_CB_MMAP) < 0) {
  ------------------
  |  Branch (7763:9): [True: 0, False: 0]
  ------------------
 7764|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7765|      0|      return NULL;
 7766|      0|    }
 7767|      0|    return blosc2_get_io_cb(id);
 7768|      0|  }
 7769|      0|  return NULL;
 7770|      0|}
blosc2_unidim_to_multidim:
 7772|  70.0M|void blosc2_unidim_to_multidim(uint8_t ndim, int64_t *shape, int64_t i, int64_t *index) {
 7773|  70.0M|  if (ndim == 0) {
  ------------------
  |  Branch (7773:7): [True: 0, False: 70.0M]
  ------------------
 7774|      0|    return;
 7775|      0|  }
 7776|  70.0M|  assert(ndim <= B2ND_MAX_DIM);
 7777|  70.0M|  int64_t strides[B2ND_MAX_DIM];
 7778|       |
 7779|  70.0M|  strides[ndim - 1] = 1;
 7780|   410M|  for (int j = ndim - 2; j >= 0; --j) {
  ------------------
  |  Branch (7780:26): [True: 340M, False: 70.0M]
  ------------------
 7781|   340M|      strides[j] = shape[j + 1] * strides[j + 1];
 7782|   340M|  }
 7783|       |
 7784|  70.0M|  index[0] = i / strides[0];
 7785|   410M|  for (int j = 1; j < ndim; ++j) {
  ------------------
  |  Branch (7785:19): [True: 340M, False: 70.0M]
  ------------------
 7786|   340M|      index[j] = (i % strides[j - 1]) / strides[j];
 7787|   340M|  }
 7788|  70.0M|}
blosc2_multidim_to_unidim:
 7790|  2.90M|void blosc2_multidim_to_unidim(const int64_t *index, int8_t ndim, const int64_t *strides, int64_t *i) {
 7791|  2.90M|  *i = 0;
 7792|  15.2M|  for (int j = 0; j < ndim; ++j) {
  ------------------
  |  Branch (7792:19): [True: 12.3M, False: 2.90M]
  ------------------
 7793|  12.3M|    *i += index[j] * strides[j];
 7794|  12.3M|  }
 7795|  2.90M|}
blosc2_error_string:
 7842|  6.94k|const char *blosc2_error_string(int error_code) {
 7843|  6.94k|  switch (error_code) {
 7844|    940|    case BLOSC2_ERROR_FAILURE:
  ------------------
  |  Branch (7844:5): [True: 940, False: 6.00k]
  ------------------
 7845|    940|      return "Generic failure";
 7846|      0|    case BLOSC2_ERROR_STREAM:
  ------------------
  |  Branch (7846:5): [True: 0, False: 6.94k]
  ------------------
 7847|      0|      return "Bad stream";
 7848|      3|    case BLOSC2_ERROR_DATA:
  ------------------
  |  Branch (7848:5): [True: 3, False: 6.94k]
  ------------------
 7849|      3|      return "Invalid data";
 7850|      0|    case BLOSC2_ERROR_MEMORY_ALLOC:
  ------------------
  |  Branch (7850:5): [True: 0, False: 6.94k]
  ------------------
 7851|      0|      return "Memory alloc/realloc failure";
 7852|      0|    case BLOSC2_ERROR_READ_BUFFER:
  ------------------
  |  Branch (7852:5): [True: 0, False: 6.94k]
  ------------------
 7853|      0|      return "Not enough space to read";
 7854|      1|    case BLOSC2_ERROR_WRITE_BUFFER:
  ------------------
  |  Branch (7854:5): [True: 1, False: 6.94k]
  ------------------
 7855|      1|      return "Not enough space to write";
 7856|      0|    case BLOSC2_ERROR_CODEC_SUPPORT:
  ------------------
  |  Branch (7856:5): [True: 0, False: 6.94k]
  ------------------
 7857|      0|      return "Codec not supported";
 7858|      0|    case BLOSC2_ERROR_CODEC_PARAM:
  ------------------
  |  Branch (7858:5): [True: 0, False: 6.94k]
  ------------------
 7859|      0|      return "Invalid parameter supplied to codec";
 7860|      0|    case BLOSC2_ERROR_CODEC_DICT:
  ------------------
  |  Branch (7860:5): [True: 0, False: 6.94k]
  ------------------
 7861|      0|      return "Codec dictionary error";
 7862|      0|    case BLOSC2_ERROR_VERSION_SUPPORT:
  ------------------
  |  Branch (7862:5): [True: 0, False: 6.94k]
  ------------------
 7863|      0|      return "Version not supported";
 7864|      0|    case BLOSC2_ERROR_INVALID_HEADER:
  ------------------
  |  Branch (7864:5): [True: 0, False: 6.94k]
  ------------------
 7865|      0|      return "Invalid value in header";
 7866|  5.90k|    case BLOSC2_ERROR_INVALID_PARAM:
  ------------------
  |  Branch (7866:5): [True: 5.90k, False: 1.04k]
  ------------------
 7867|  5.90k|      return "Invalid parameter supplied to function";
 7868|      0|    case BLOSC2_ERROR_FILE_READ:
  ------------------
  |  Branch (7868:5): [True: 0, False: 6.94k]
  ------------------
 7869|      0|      return "File read failure";
 7870|      0|    case BLOSC2_ERROR_FILE_WRITE:
  ------------------
  |  Branch (7870:5): [True: 0, False: 6.94k]
  ------------------
 7871|      0|      return "File write failure";
 7872|      0|    case BLOSC2_ERROR_FILE_OPEN:
  ------------------
  |  Branch (7872:5): [True: 0, False: 6.94k]
  ------------------
 7873|      0|      return "File open failure";
 7874|      0|    case BLOSC2_ERROR_NOT_FOUND:
  ------------------
  |  Branch (7874:5): [True: 0, False: 6.94k]
  ------------------
 7875|      0|      return "Not found";
 7876|      0|    case BLOSC2_ERROR_RUN_LENGTH:
  ------------------
  |  Branch (7876:5): [True: 0, False: 6.94k]
  ------------------
 7877|      0|      return "Bad run length encoding";
 7878|      0|    case BLOSC2_ERROR_FILTER_PIPELINE:
  ------------------
  |  Branch (7878:5): [True: 0, False: 6.94k]
  ------------------
 7879|      0|      return "Filter pipeline error";
 7880|      0|    case BLOSC2_ERROR_CHUNK_INSERT:
  ------------------
  |  Branch (7880:5): [True: 0, False: 6.94k]
  ------------------
 7881|      0|      return "Chunk insert failure";
 7882|      0|    case BLOSC2_ERROR_CHUNK_APPEND:
  ------------------
  |  Branch (7882:5): [True: 0, False: 6.94k]
  ------------------
 7883|      0|      return "Chunk append failure";
 7884|      0|    case BLOSC2_ERROR_CHUNK_UPDATE:
  ------------------
  |  Branch (7884:5): [True: 0, False: 6.94k]
  ------------------
 7885|      0|      return "Chunk update failure";
 7886|      0|    case BLOSC2_ERROR_2GB_LIMIT:
  ------------------
  |  Branch (7886:5): [True: 0, False: 6.94k]
  ------------------
 7887|      0|      return "Sizes larger than 2gb not supported";
 7888|      0|    case BLOSC2_ERROR_SCHUNK_COPY:
  ------------------
  |  Branch (7888:5): [True: 0, False: 6.94k]
  ------------------
 7889|      0|      return "Super-chunk copy failure";
 7890|      0|    case BLOSC2_ERROR_FRAME_TYPE:
  ------------------
  |  Branch (7890:5): [True: 0, False: 6.94k]
  ------------------
 7891|      0|      return "Wrong type for frame";
 7892|      0|    case BLOSC2_ERROR_FILE_TRUNCATE:
  ------------------
  |  Branch (7892:5): [True: 0, False: 6.94k]
  ------------------
 7893|      0|      return "File truncate failure";
 7894|      0|    case BLOSC2_ERROR_LOCK:
  ------------------
  |  Branch (7894:5): [True: 0, False: 6.94k]
  ------------------
 7895|      0|      return "Frame lock failure";
 7896|      0|    case BLOSC2_ERROR_THREAD_CREATE:
  ------------------
  |  Branch (7896:5): [True: 0, False: 6.94k]
  ------------------
 7897|      0|      return "Thread or thread context creation failure";
 7898|      0|    case BLOSC2_ERROR_POSTFILTER:
  ------------------
  |  Branch (7898:5): [True: 0, False: 6.94k]
  ------------------
 7899|      0|      return "Postfilter failure";
 7900|      0|    case BLOSC2_ERROR_FRAME_SPECIAL:
  ------------------
  |  Branch (7900:5): [True: 0, False: 6.94k]
  ------------------
 7901|      0|      return "Special frame failure";
 7902|      0|    case BLOSC2_ERROR_SCHUNK_SPECIAL:
  ------------------
  |  Branch (7902:5): [True: 0, False: 6.94k]
  ------------------
 7903|      0|      return "Special super-chunk failure";
 7904|      0|    case BLOSC2_ERROR_PLUGIN_IO:
  ------------------
  |  Branch (7904:5): [True: 0, False: 6.94k]
  ------------------
 7905|      0|      return "IO plugin error";
 7906|      0|    case BLOSC2_ERROR_FILE_REMOVE:
  ------------------
  |  Branch (7906:5): [True: 0, False: 6.94k]
  ------------------
 7907|      0|      return "Remove file failure";
 7908|      0|    case BLOSC2_ERROR_NULL_POINTER:
  ------------------
  |  Branch (7908:5): [True: 0, False: 6.94k]
  ------------------
 7909|      0|      return "Pointer is null";
 7910|     90|    case BLOSC2_ERROR_INVALID_INDEX:
  ------------------
  |  Branch (7910:5): [True: 90, False: 6.85k]
  ------------------
 7911|     90|      return "Invalid index";
 7912|      2|    case BLOSC2_ERROR_METALAYER_NOT_FOUND:
  ------------------
  |  Branch (7912:5): [True: 2, False: 6.94k]
  ------------------
 7913|      2|      return "Metalayer has not been found";
 7914|      8|    case BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED:
  ------------------
  |  Branch (7914:5): [True: 8, False: 6.93k]
  ------------------
 7915|      8|      return "Maximum buffersize exceeded";
 7916|      0|    case BLOSC2_ERROR_TUNER:
  ------------------
  |  Branch (7916:5): [True: 0, False: 6.94k]
  ------------------
 7917|      0|      return "Tuner failure";
 7918|      0|    default:
  ------------------
  |  Branch (7918:5): [True: 0, False: 6.94k]
  ------------------
 7919|      0|      return "Unknown error";
 7920|  6.94k|  }
 7921|  6.94k|}
blosc2.c:shuffle_size:
  773|  67.4M|static int32_t shuffle_size(const blosc2_context* context, int i) {
  774|  67.4M|  return context->filters_meta[i] == 0 ? context->typesize : context->filters_meta[i];
  ------------------
  |  Branch (774:10): [True: 67.4M, False: 682]
  ------------------
  775|  67.4M|}
blosc2.c:flags_to_filters:
  857|  22.4M|static void flags_to_filters(const uint8_t flags, uint8_t* filters) {
  858|       |  /* Initialize the filter pipeline */
  859|  22.4M|  memset(filters, 0, BLOSC2_MAX_FILTERS);
  860|       |  /* Fill the filter pipeline */
  861|  22.4M|  if (flags & BLOSC_DOSHUFFLE)
  ------------------
  |  Branch (861:7): [True: 22.4M, False: 2.02k]
  ------------------
  862|  22.4M|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_SHUFFLE;
  863|  22.4M|  if (flags & BLOSC_DOBITSHUFFLE)
  ------------------
  |  Branch (863:7): [True: 22.4M, False: 777]
  ------------------
  864|  22.4M|    filters[BLOSC2_MAX_FILTERS - 1] = BLOSC_BITSHUFFLE;
  865|  22.4M|  if (flags & BLOSC_DODELTA)
  ------------------
  |  Branch (865:7): [True: 1.61M, False: 20.8M]
  ------------------
  866|  1.61M|    filters[BLOSC2_MAX_FILTERS - 2] = BLOSC_DELTA;
  867|  22.4M|}
blosc2.c:load_codec_locked:
 1137|      4|static int load_codec_locked(blosc2_codec *codec) {
 1138|      4|  char libpath[PATH_MAX];
 1139|      4|  void *lib = load_lib(codec->compname, libpath);
 1140|      4|  if(lib == NULL) {
  ------------------
  |  Branch (1140:6): [True: 4, False: 0]
  ------------------
 1141|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1142|      4|    return BLOSC2_ERROR_FAILURE;
 1143|      4|  }
 1144|       |
 1145|      0|  codec_info *info = dlsym(lib, "info");
 1146|      0|  if (info == NULL) {
  ------------------
  |  Branch (1146:7): [True: 0, False: 0]
  ------------------
 1147|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1148|      0|    dlclose(lib);
 1149|      0|    return BLOSC2_ERROR_FAILURE;
 1150|      0|  }
 1151|      0|  void *encoder = plugin_dlsym(lib, info->encoder);
 1152|      0|  void *decoder = plugin_dlsym(lib, info->decoder);
 1153|       |
 1154|      0|  if (encoder == NULL || decoder == NULL) {
  ------------------
  |  Branch (1154:7): [True: 0, False: 0]
  |  Branch (1154:26): [True: 0, False: 0]
  ------------------
 1155|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1156|      0|    dlclose(lib);
 1157|      0|    return BLOSC2_ERROR_FAILURE;
 1158|      0|  }
 1159|      0|  codec->encoder = encoder;
 1160|      0|  store_release_ptr(&codec->decoder, decoder);
  ------------------
  |  |  145|      0|#define store_release_ptr(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 1161|       |
 1162|       |  /* If ever add .free function in future for codec params
 1163|       |  codecparams_info *info2 = dlsym(lib, "info2");
 1164|       |  if (info2 != NULL) {
 1165|       |    // New plugin (e.g. openzl) with free function for codec_params defined
 1166|       |    // will be used when destroying context in blosc2_free_ctx
 1167|       |      codec->free = dlsym(lib, info2->free);
 1168|       |  }
 1169|       |  else{
 1170|       |    codec->free = NULL;
 1171|       |  }
 1172|       |  */
 1173|       |
 1174|      0|  return BLOSC2_ERROR_SUCCESS;
 1175|      0|}
blosc2.c:_cycle_buffers_forward:
 1293|  21.4M|                                   const uint8_t *input) {
 1294|  21.4M|  uint8_t *prev_src = *src;
 1295|  21.4M|  *src = *dest;
 1296|  21.4M|  *dest = (prev_src == input) ? *tmp : prev_src;
  ------------------
  |  Branch (1296:11): [True: 13.5M, False: 7.86M]
  ------------------
 1297|  21.4M|}
blosc2.c:fused_shuffle_bytedelta_size:
  781|  16.5M|static int fused_shuffle_bytedelta_size(const blosc2_context *context, int i) {
  782|  16.5M|  if (i < 0 || i + 1 >= BLOSC2_MAX_FILTERS || context->filters[i] != BLOSC_SHUFFLE ||
  ------------------
  |  Branch (782:7): [True: 137, False: 16.5M]
  |  Branch (782:16): [True: 11.4M, False: 5.08M]
  |  Branch (782:47): [True: 5.08M, False: 280]
  ------------------
  783|  16.5M|      context->filters[i + 1] != BLOSC_FILTER_BYTEDELTA) {
  ------------------
  |  Branch (783:7): [True: 152, False: 128]
  ------------------
  784|  16.5M|    return 0;
  785|  16.5M|  }
  786|     56|  int delta_size = context->filters_meta[i + 1];
  787|     56|  if (delta_size == 0 && context->schunk != NULL) {
  ------------------
  |  Branch (787:7): [True: 1, False: 55]
  |  Branch (787:26): [True: 0, False: 1]
  ------------------
  788|      0|    delta_size = context->schunk->typesize;
  789|      0|  }
  790|     56|  int size = shuffle_size(context, i);
  791|     91|  return (size == 2 || size == 4 || size == 8) && size == delta_size &&
  ------------------
  |  Branch (791:11): [True: 18.4E, False: 87]
  |  Branch (791:24): [True: 22, False: 65]
  |  Branch (791:37): [True: 28, False: 37]
  |  Branch (791:51): [True: 72, False: 19]
  ------------------
  792|  18.4E|         shuffle_bytedelta_available() ? size : 0;
  ------------------
  |  Branch (792:10): [True: 72, False: 0]
  ------------------
  793|  16.5M|}
blosc2.c:bitshuffle_scratch:
 1304|    465|static uint8_t* bitshuffle_scratch(struct thread_context* thread_context, int32_t bsize) {
 1305|    465|  size_t offset = (size_t)(thread_context->tmp4 - thread_context->tmp);
 1306|    465|  size_t shift = (16 - ((uintptr_t)thread_context->tmp4 & 15)) & 15;
 1307|    465|  if (offset + shift + (size_t)bsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (1307:7): [True: 404, False: 61]
  ------------------
 1308|    404|    return thread_context->tmp4 + shift;
 1309|    404|  }
 1310|     61|  if (offset + (size_t)bsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (1310:7): [True: 61, False: 0]
  ------------------
 1311|     61|    return thread_context->tmp4;
 1312|     61|  }
 1313|      0|  return NULL;
 1314|     61|}
blosc2.c:destroy_thread_context:
 2629|  4.13k|static void destroy_thread_context(struct thread_context* thread_context) {
 2630|  4.13k|  my_free(thread_context->tmp);
 2631|  4.13k|  free(thread_context->blosclz_state);
 2632|  4.13k|#if defined(HAVE_ZSTD)
 2633|  4.13k|  if (thread_context->zstd_cctx != NULL) {
  ------------------
  |  Branch (2633:7): [True: 0, False: 4.13k]
  ------------------
 2634|      0|    ZSTD_freeCCtx(thread_context->zstd_cctx);
 2635|      0|  }
 2636|  4.13k|  if (thread_context->zstd_dctx != NULL) {
  ------------------
  |  Branch (2636:7): [True: 15, False: 4.11k]
  ------------------
 2637|     15|    ZSTD_freeDCtx(thread_context->zstd_dctx);
 2638|     15|  }
 2639|  4.13k|#endif
 2640|  4.13k|  if (thread_context->lz4_cstream != NULL) {
  ------------------
  |  Branch (2640:7): [True: 0, False: 4.13k]
  ------------------
 2641|      0|    LZ4_freeStream((LZ4_stream_t*)thread_context->lz4_cstream);
 2642|      0|  }
 2643|  4.13k|  if (thread_context->lz4hc_cstream != NULL) {
  ------------------
  |  Branch (2643:7): [True: 0, False: 4.13k]
  ------------------
 2644|      0|    LZ4_freeStreamHC((LZ4_streamHC_t*)thread_context->lz4hc_cstream);
 2645|      0|  }
 2646|  4.13k|}
blosc2.c:my_free:
  394|  4.78M|static void my_free(void* block) {
  395|       |#if defined(_WIN32)
  396|       |  _aligned_free(block);
  397|       |#else
  398|  4.78M|  free(block);
  399|  4.78M|#endif  /* _WIN32 */
  400|  4.78M|}
blosc2.c:initialize_context_compression:
 2819|  3.14M|        blosc2_schunk* schunk) {
 2820|       |
 2821|       |  /* The block size and the filters divide by the typesize */
 2822|  3.14M|  if (typesize <= 0) {
  ------------------
  |  Branch (2822:7): [True: 0, False: 3.14M]
  ------------------
 2823|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2824|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2825|      0|  }
 2826|       |
 2827|       |  /* Check typesize limits */
 2828|  3.14M|  if (typesize > BLOSC2_MAXTYPESIZE) {
  ------------------
  |  Branch (2828:7): [True: 0, False: 3.14M]
  ------------------
 2829|       |    // If typesize is too large for Blosc2, return an error
 2830|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2831|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2832|      0|  }
 2833|       |  /* Now, cap typesize so that blosc2 split machinery can continue to work.  This has to be
 2834|       |     done before the tuner chooses the block size, which depends on the typesize: a buffer
 2835|       |     with a larger typesize is a plain stream of bytes and is blocked as one. */
 2836|  3.14M|  if (typesize > BLOSC_MAX_TYPESIZE) {
  ------------------
  |  Branch (2836:7): [True: 0, False: 3.14M]
  ------------------
 2837|       |    /* If typesize is too large, treat buffer as an 1-byte stream. */
 2838|      0|    typesize = 1;
 2839|      0|  }
 2840|       |
 2841|       |  /* Set parameters */
 2842|  3.14M|  context->do_compress = 1;
 2843|  3.14M|  context->src = (const uint8_t*)src;
 2844|  3.14M|  context->srcsize = srcsize;
 2845|  3.14M|  context->dest = (uint8_t*)dest;
 2846|  3.14M|  context->output_bytes = 0;
 2847|  3.14M|  context->destsize = destsize;
 2848|  3.14M|  context->sourcesize = srcsize;
 2849|  3.14M|  context->typesize = typesize;
 2850|  3.14M|  context->filter_flags = filters_to_flags(filters);
 2851|  21.9M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (2851:19): [True: 18.8M, False: 3.14M]
  ------------------
 2852|  18.8M|    context->filters[i] = filters[i];
 2853|  18.8M|    context->filters_meta[i] = filters_meta[i];
 2854|  18.8M|  }
 2855|  3.14M|  context->compcode = compressor;
 2856|  3.14M|  context->nthreads = nthreads;
 2857|  3.14M|  context->new_nthreads = new_nthreads;
 2858|  3.14M|  context->clevel = clevel;
 2859|  3.14M|  context->schunk = schunk;
 2860|  3.14M|  context->tuner_params = tuner_params;
 2861|  3.14M|  context->tuner_id = tuner_id;
 2862|  3.14M|  context->splitmode = splitmode;
 2863|  3.14M|  context->blosc2_flags2 = 0;
 2864|  3.14M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (2864:7): [True: 0, False: 3.14M]
  ------------------
 2865|      0|    free(context->blocknbytes);
 2866|      0|    context->blocknbytes = NULL;
 2867|      0|  }
 2868|  3.14M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (2868:7): [True: 0, False: 3.14M]
  ------------------
 2869|      0|    free(context->blockoffsets);
 2870|      0|    context->blockoffsets = NULL;
 2871|      0|  }
 2872|  3.14M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (2872:7): [True: 0, False: 3.14M]
  ------------------
 2873|      0|    free(context->blockcbytes);
 2874|      0|    context->blockcbytes = NULL;
 2875|      0|  }
 2876|  3.14M|  context->vlblock_sources = NULL;
 2877|  3.14M|  context->vlblock_dests = NULL;
 2878|       |  /* tuner some compression parameters */
 2879|  3.14M|  context->blocksize = (int32_t)blocksize;
 2880|  3.14M|  int rc = 0;
 2881|  3.14M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (2881:7): [True: 0, False: 3.14M]
  ------------------
 2882|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (2882:9): [True: 0, False: 0]
  |  Branch (2882:49): [True: 0, False: 0]
  ------------------
 2883|      0|      if (blosc_stune_next_cparams(context) < 0) {
  ------------------
  |  Branch (2883:11): [True: 0, False: 0]
  ------------------
 2884|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2885|      0|        return BLOSC2_ERROR_TUNER;
 2886|      0|      }
 2887|      0|    } else {
 2888|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (2888:23): [True: 0, False: 0]
  ------------------
 2889|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (2889:13): [True: 0, False: 0]
  ------------------
 2890|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2890:15): [True: 0, False: 0]
  ------------------
 2891|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (2891:17): [True: 0, False: 0]
  ------------------
 2892|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2893|      0|              return BLOSC2_ERROR_FAILURE;
 2894|      0|            }
 2895|      0|          }
 2896|      0|          if (g_tuners[i].next_cparams(context) < 0) {
  ------------------
  |  Branch (2896:15): [True: 0, False: 0]
  ------------------
 2897|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2898|      0|            return BLOSC2_ERROR_TUNER;
 2899|      0|          }
 2900|      0|          if (g_tuners[i].id == BLOSC_BTUNE && context->blocksize == 0) {
  ------------------
  |  Branch (2900:15): [True: 0, False: 0]
  |  Branch (2900:48): [True: 0, False: 0]
  ------------------
 2901|       |            // Call stune for initializing blocksize
 2902|      0|            if (blosc_stune_next_blocksize(context) < 0) {
  ------------------
  |  Branch (2902:17): [True: 0, False: 0]
  ------------------
 2903|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2904|      0|              return BLOSC2_ERROR_TUNER;
 2905|      0|            }
 2906|      0|          }
 2907|      0|          goto urtunersuccess;
 2908|      0|        }
 2909|      0|      }
 2910|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2911|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2912|      0|    }
 2913|  3.14M|  } else {
 2914|  3.14M|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|  3.14M|#define BLOSC_STUNE 0
  ------------------
  |  Branch (2914:9): [True: 3.14M, False: 0]
  |  Branch (2914:49): [True: 3.14M, False: 0]
  ------------------
 2915|  3.14M|      rc = blosc_stune_next_blocksize(context);
 2916|  3.14M|    } else {
 2917|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (2917:23): [True: 0, False: 0]
  ------------------
 2918|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (2918:13): [True: 0, False: 0]
  ------------------
 2919|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2919:15): [True: 0, False: 0]
  ------------------
 2920|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (2920:17): [True: 0, False: 0]
  ------------------
 2921|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2922|      0|              return BLOSC2_ERROR_FAILURE;
 2923|      0|            }
 2924|      0|          }
 2925|      0|          rc = g_tuners[i].next_blocksize(context);
 2926|      0|          goto urtunersuccess;
 2927|      0|        }
 2928|      0|      }
 2929|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2930|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2931|      0|    }
 2932|  3.14M|  }
 2933|  3.14M|  urtunersuccess:;
 2934|  3.14M|  if (rc < 0) {
  ------------------
  |  Branch (2934:7): [True: 0, False: 3.14M]
  ------------------
 2935|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2936|      0|    return BLOSC2_ERROR_TUNER;
 2937|      0|  }
 2938|       |  /* The header must record the block size that the tuner settled on (it rounds a requested
 2939|       |     one to a multiple of the typesize, for instance), not the one that was asked for: a reader
 2940|       |     splits the chunk into blocks of the size in the header.  Variable-length block chunks
 2941|       |     store something else there and set it themselves. */
 2942|  3.14M|  context->header_blocksize = context->blocksize;
 2943|       |
 2944|       |
 2945|       |  /* Check buffer size limits */
 2946|  3.14M|  if (srcsize > BLOSC2_MAX_BUFFERSIZE) {
  ------------------
  |  Branch (2946:7): [True: 0, False: 3.14M]
  ------------------
 2947|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2948|      0|                      BLOSC2_MAX_BUFFERSIZE);
 2949|      0|    return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
 2950|      0|  }
 2951|       |
 2952|  3.14M|  if (destsize < BLOSC2_MAX_OVERHEAD) {
  ------------------
  |  Branch (2952:7): [True: 0, False: 3.14M]
  ------------------
 2953|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2954|      0|                      BLOSC2_MAX_OVERHEAD);
 2955|      0|    return BLOSC2_ERROR_MAX_BUFSIZE_EXCEEDED;
 2956|      0|  }
 2957|       |
 2958|       |  /* Compression level */
 2959|  3.14M|  if (clevel < 0 || clevel > 9) {
  ------------------
  |  Branch (2959:7): [True: 0, False: 3.14M]
  |  Branch (2959:21): [True: 0, False: 3.14M]
  ------------------
 2960|       |    /* If clevel not in 0..9, print an error */
 2961|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2962|      0|    return BLOSC2_ERROR_CODEC_PARAM;
 2963|      0|  }
 2964|       |
 2965|       |  /* Dictionary support is only available for ZSTD, LZ4, and LZ4HC.
 2966|       |   * Skip the check when src is NULL (special-value chunks): no compression
 2967|       |   * will actually happen, so codec compatibility is irrelevant. */
 2968|  3.14M|  if (src != NULL && context->use_dict && context->compcode != BLOSC_ZSTD &&
  ------------------
  |  Branch (2968:7): [True: 1.77M, False: 1.36M]
  |  Branch (2968:22): [True: 0, False: 1.77M]
  |  Branch (2968:43): [True: 0, False: 0]
  ------------------
 2969|      0|      context->compcode != BLOSC_LZ4 && context->compcode != BLOSC_LZ4HC) {
  ------------------
  |  Branch (2969:7): [True: 0, False: 0]
  |  Branch (2969:41): [True: 0, False: 0]
  ------------------
 2970|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2971|      0|    return BLOSC2_ERROR_CODEC_PARAM;
 2972|      0|  }
 2973|       |
 2974|  3.14M|  blosc2_calculate_blocks(context);
 2975|       |
 2976|  3.14M|  return 1;
 2977|  3.14M|}
blosc2.c:filters_to_flags:
  834|  7.75M|static uint8_t filters_to_flags(const uint8_t* filters) {
  835|  7.75M|  uint8_t flags = 0;
  836|       |
  837|  54.3M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (837:19): [True: 46.5M, False: 7.75M]
  ------------------
  838|  46.5M|    switch (filters[i]) {
  839|  7.57M|      case BLOSC_SHUFFLE:
  ------------------
  |  Branch (839:7): [True: 7.57M, False: 38.9M]
  ------------------
  840|  7.57M|        flags |= BLOSC_DOSHUFFLE;
  841|  7.57M|        break;
  842|    366|      case BLOSC_BITSHUFFLE:
  ------------------
  |  Branch (842:7): [True: 366, False: 46.5M]
  ------------------
  843|    366|        flags |= BLOSC_DOBITSHUFFLE;
  844|    366|        break;
  845|    319|      case BLOSC_DELTA:
  ------------------
  |  Branch (845:7): [True: 319, False: 46.5M]
  ------------------
  846|    319|        flags |= BLOSC_DODELTA;
  847|    319|        break;
  848|  38.9M|      default :
  ------------------
  |  Branch (848:7): [True: 38.9M, False: 7.57M]
  ------------------
  849|  38.9M|        break;
  850|  46.5M|    }
  851|  46.5M|  }
  852|  7.75M|  return flags;
  853|  7.75M|}
blosc2.c:blosc2_calculate_blocks:
 1024|  7.75M|static inline void blosc2_calculate_blocks(blosc2_context* context) {
 1025|       |  /* Compute number of blocks in buffer */
 1026|  7.75M|  context->nblocks = context->sourcesize / context->blocksize;
 1027|  7.75M|  context->leftover = context->sourcesize % context->blocksize;
 1028|  7.75M|  context->nblocks = (context->leftover > 0) ?
  ------------------
  |  Branch (1028:22): [True: 2.70M, False: 5.05M]
  ------------------
 1029|  5.05M|                     (context->nblocks + 1) : context->nblocks;
 1030|  7.75M|}
blosc2.c:blosc1_format_check:
 3612|  1.77M|static int blosc1_format_check(const blosc2_context* context) {
 3613|  1.77M|  if (!context->blosc1_format) {
  ------------------
  |  Branch (3613:7): [True: 1.77M, False: 0]
  ------------------
 3614|  1.77M|    return BLOSC2_ERROR_SUCCESS;
 3615|  1.77M|  }
 3616|      0|  switch (context->compcode) {
 3617|      0|    case BLOSC_BLOSCLZ:
  ------------------
  |  Branch (3617:5): [True: 0, False: 0]
  ------------------
 3618|      0|    case BLOSC_LZ4:
  ------------------
  |  Branch (3618:5): [True: 0, False: 0]
  ------------------
 3619|      0|    case BLOSC_LZ4HC:
  ------------------
  |  Branch (3619:5): [True: 0, False: 0]
  ------------------
 3620|      0|    case BLOSC_ZLIB:
  ------------------
  |  Branch (3620:5): [True: 0, False: 0]
  ------------------
 3621|      0|    case BLOSC_ZSTD:
  ------------------
  |  Branch (3621:5): [True: 0, False: 0]
  ------------------
 3622|      0|      break;
 3623|      0|    default:
  ------------------
  |  Branch (3623:5): [True: 0, False: 0]
  ------------------
 3624|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3625|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 3626|      0|  }
 3627|       |  /* The Blosc1 header only has flags for a shuffle or a bitshuffle, so the pipeline can have
 3628|       |     one of those and nothing else, in any of its slots. */
 3629|      0|  int nfilters = 0;
 3630|      0|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (3630:19): [True: 0, False: 0]
  ------------------
 3631|      0|    uint8_t filter = context->filters[i];
 3632|      0|    if (filter == BLOSC_NOFILTER) {
  ------------------
  |  Branch (3632:9): [True: 0, False: 0]
  ------------------
 3633|      0|      continue;
 3634|      0|    }
 3635|      0|    bool plain_shuffle = (filter == BLOSC_SHUFFLE || filter == BLOSC_BITSHUFFLE) &&
  ------------------
  |  Branch (3635:27): [True: 0, False: 0]
  |  Branch (3635:54): [True: 0, False: 0]
  ------------------
 3636|      0|                         context->filters_meta[i] == 0;
  ------------------
  |  Branch (3636:26): [True: 0, False: 0]
  ------------------
 3637|      0|    if (!plain_shuffle || ++nfilters > 1) {
  ------------------
  |  Branch (3637:9): [True: 0, False: 0]
  |  Branch (3637:27): [True: 0, False: 0]
  ------------------
 3638|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3639|      0|      return BLOSC2_ERROR_FILTER_PIPELINE;
 3640|      0|    }
 3641|      0|  }
 3642|      0|  if (context->use_dict || (context->blosc2_flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (3642:7): [True: 0, False: 0]
  |  Branch (3642:28): [True: 0, False: 0]
  ------------------
 3643|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3644|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 3645|      0|  }
 3646|      0|  return BLOSC2_ERROR_SUCCESS;
 3647|      0|}
blosc2.c:write_compression_header:
 3384|  1.77M|static int write_compression_header(blosc2_context* context, bool extended_header) {
 3385|  1.77M|  blosc_header header;
 3386|  1.77M|  int dont_split;
 3387|  1.77M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 3388|       |
 3389|  1.77M|  if (context->clevel == 0) {
  ------------------
  |  Branch (3389:7): [True: 224k, False: 1.55M]
  ------------------
 3390|       |    /* Compression level 0 means no compression — dicts serve no purpose here */
 3391|   224k|    context->use_dict = 0;
 3392|   224k|  }
 3393|       |
 3394|  1.77M|  int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (3394:23): [True: 0, False: 1.77M]
  |  Branch (3394:44): [True: 0, False: 0]
  ------------------
 3395|       |
 3396|  1.77M|  context->header_flags = 0;
 3397|       |
 3398|  1.77M|  if (!vlblocks && context->clevel == 0) {
  ------------------
  |  Branch (3398:7): [True: 1.77M, False: 0]
  |  Branch (3398:20): [True: 224k, False: 1.55M]
  ------------------
 3399|       |    /* Compression level 0 means buffer to be memcpy'ed */
 3400|   224k|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3401|   224k|  }
 3402|  1.77M|  if (!vlblocks && context->sourcesize < BLOSC_MIN_BUFFERSIZE) {
  ------------------
  |  Branch (3402:7): [True: 1.77M, False: 0]
  |  Branch (3402:20): [True: 408k, False: 1.36M]
  ------------------
 3403|       |    /* Buffer is too small.  Try memcpy'ing. */
 3404|   408k|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3405|   408k|  }
 3406|       |
 3407|  1.77M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 3408|  1.77M|  if (extended_header) {
  ------------------
  |  Branch (3408:7): [True: 1.77M, False: 0]
  ------------------
 3409|       |    /* Indicate that we are building an extended header */
 3410|  1.77M|    context->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 3411|  1.77M|    context->header_flags |= (BLOSC_DOSHUFFLE | BLOSC_DOBITSHUFFLE);
 3412|       |    /* Store filter pipeline info at the end of the header */
 3413|  1.77M|    if (dict_training || memcpyed) {
  ------------------
  |  Branch (3413:9): [True: 0, False: 1.77M]
  |  Branch (3413:26): [True: 440k, False: 1.33M]
  ------------------
 3414|   440k|      context->bstarts = NULL;
 3415|   440k|      context->output_bytes = context->header_overhead;
 3416|  1.33M|    } else {
 3417|  1.33M|      context->bstarts = (int32_t*)(context->dest + context->header_overhead);
 3418|  1.33M|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3419|  1.33M|    }
 3420|  1.77M|  } else {
 3421|       |    // Regular header
 3422|      0|    context->header_overhead = BLOSC_MIN_HEADER_LENGTH;
 3423|      0|    if (memcpyed) {
  ------------------
  |  Branch (3423:9): [True: 0, False: 0]
  ------------------
 3424|      0|      context->bstarts = NULL;
 3425|      0|      context->output_bytes = context->header_overhead;
 3426|      0|    } else {
 3427|      0|      context->bstarts = (int32_t *) (context->dest + context->header_overhead);
 3428|      0|      context->output_bytes = context->header_overhead + (int32_t)sizeof(int32_t) * context->nblocks;
 3429|      0|    }
 3430|      0|  }
 3431|       |
 3432|       |  /* If the header + block starts don't fit in destsize, fall back to memcpy */
 3433|  1.77M|  if (!memcpyed && context->output_bytes > context->destsize) {
  ------------------
  |  Branch (3433:7): [True: 1.33M, False: 440k]
  |  Branch (3433:20): [True: 2.52k, False: 1.33M]
  ------------------
 3434|  2.52k|    context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3435|  2.52k|    memcpyed = true;
 3436|  2.52k|    context->bstarts = NULL;
 3437|  2.52k|    context->output_bytes = context->header_overhead;
 3438|  2.52k|  }
 3439|       |
 3440|       |  // when memcpyed bit is set, there is no point in dealing with others
 3441|  1.77M|  if (!memcpyed) {
  ------------------
  |  Branch (3441:7): [True: 1.33M, False: 442k]
  ------------------
 3442|  1.33M|    if (context->filter_flags & BLOSC_DOSHUFFLE) {
  ------------------
  |  Branch (3442:9): [True: 1.33M, False: 0]
  ------------------
 3443|       |      /* Byte-shuffle is active */
 3444|  1.33M|      context->header_flags |= BLOSC_DOSHUFFLE;
 3445|  1.33M|    }
 3446|       |
 3447|  1.33M|    if (context->filter_flags & BLOSC_DOBITSHUFFLE) {
  ------------------
  |  Branch (3447:9): [True: 0, False: 1.33M]
  ------------------
 3448|       |      /* Bit-shuffle is active */
 3449|      0|      context->header_flags |= BLOSC_DOBITSHUFFLE;
 3450|      0|    }
 3451|       |
 3452|  1.33M|    if (context->filter_flags & BLOSC_DODELTA) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 1.33M]
  ------------------
 3453|       |      /* Delta is active */
 3454|      0|      context->header_flags |= BLOSC_DODELTA;
 3455|      0|    }
 3456|       |
 3457|  1.33M|    dont_split = vlblocks || !split_block(context, context->typesize,
  ------------------
  |  Branch (3457:18): [True: 0, False: 1.33M]
  |  Branch (3457:30): [True: 1.12M, False: 208k]
  ------------------
 3458|  1.33M|                                          context->blocksize);
 3459|       |
 3460|       |    /* dont_split is in bit 4 */
 3461|  1.33M|    context->header_flags |= dont_split << 4;
 3462|       |    /* codec starts at bit 5 */
 3463|  1.33M|    uint8_t compformat = compcode_to_compformat(context->compcode);
 3464|  1.33M|    context->header_flags |= compformat << 5;
 3465|  1.33M|  }
 3466|       |
 3467|       |  // Create blosc header and store to dest
 3468|  1.77M|  blosc2_initialize_header_from_context(context, &header, extended_header);
 3469|       |
 3470|  1.77M|  memcpy(context->dest, &header, (extended_header) ?
  ------------------
  |  Branch (3470:34): [True: 1.77M, False: 0]
  ------------------
 3471|  1.77M|    BLOSC_EXTENDED_HEADER_LENGTH : BLOSC_MIN_HEADER_LENGTH);
 3472|       |
 3473|  1.77M|  return 1;
 3474|  1.77M|}
blosc2.c:compcode_to_compformat:
  518|  1.33M|static int compcode_to_compformat(int compcode) {
  519|  1.33M|  switch (compcode) {
  520|  1.33M|    case BLOSC_BLOSCLZ: return BLOSC_BLOSCLZ_FORMAT;
  ------------------
  |  Branch (520:5): [True: 1.33M, False: 0]
  ------------------
  521|      0|    case BLOSC_LZ4:     return BLOSC_LZ4_FORMAT;
  ------------------
  |  Branch (521:5): [True: 0, False: 1.33M]
  ------------------
  522|      0|    case BLOSC_LZ4HC:   return BLOSC_LZ4HC_FORMAT;
  ------------------
  |  Branch (522:5): [True: 0, False: 1.33M]
  ------------------
  523|       |
  524|      0|#if defined(HAVE_ZLIB)
  525|      0|    case BLOSC_ZLIB:    return BLOSC_ZLIB_FORMAT;
  ------------------
  |  Branch (525:5): [True: 0, False: 1.33M]
  ------------------
  526|      0|#endif /*  HAVE_ZLIB */
  527|       |
  528|      0|#if defined(HAVE_ZSTD)
  529|      0|    case BLOSC_ZSTD:    return BLOSC_ZSTD_FORMAT;
  ------------------
  |  Branch (529:5): [True: 0, False: 1.33M]
  ------------------
  530|      0|      break;
  531|      0|#endif /*  HAVE_ZSTD */
  532|      0|    default:
  ------------------
  |  Branch (532:5): [True: 0, False: 1.33M]
  ------------------
  533|      0|      return BLOSC_UDCODEC_FORMAT;
  534|  1.33M|  }
  535|      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]
  |  |  ------------------
  ------------------
  536|      0|}
blosc2.c:blosc2_initialize_header_from_context:
 1238|  1.77M|static int blosc2_initialize_header_from_context(blosc2_context* context, blosc_header* header, bool extended_header) {
 1239|  1.77M|  int32_t header_blocksize = (int32_t)(context->header_blocksize > 0 ? context->header_blocksize : context->blocksize);
  ------------------
  |  Branch (1239:40): [True: 1.77M, False: 0]
  ------------------
 1240|  1.77M|  if ((context->blosc2_flags2 & BLOSC2_VL_BLOCKS) == 0 &&
  ------------------
  |  Branch (1240:7): [True: 1.77M, False: 0]
  ------------------
 1241|  1.77M|      context->sourcesize > 0 && header_blocksize > context->sourcesize) {
  ------------------
  |  Branch (1241:7): [True: 1.77M, False: 0]
  |  Branch (1241:34): [True: 0, False: 1.77M]
  ------------------
 1242|      0|    header_blocksize = (int32_t)context->sourcesize;
 1243|      0|  }
 1244|  1.77M|  memset(header, 0, sizeof(blosc_header));
 1245|       |
 1246|  1.77M|  header->version = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) ?
  ------------------
  |  Branch (1246:21): [True: 0, False: 1.77M]
  ------------------
 1247|      0|                    BLOSC2_VERSION_FORMAT_VL_BLOCKS :
 1248|  1.77M|                    BLOSC2_VERSION_FORMAT_STABLE;
 1249|  1.77M|  if (context->blosc1_format) {
  ------------------
  |  Branch (1249:7): [True: 0, False: 1.77M]
  ------------------
 1250|      0|    header->version = BLOSC1_VERSION_FORMAT;
 1251|      0|  }
 1252|  1.77M|  header->versionlz = compcode_to_compversion(context->compcode);
 1253|  1.77M|  header->flags = context->header_flags;
 1254|  1.77M|  header->typesize = (uint8_t)context->typesize;
 1255|  1.77M|  header->nbytes = (int32_t)context->sourcesize;
 1256|  1.77M|  header->blocksize = header_blocksize;
 1257|       |
 1258|  1.77M|  int little_endian = is_little_endian();
 1259|  1.77M|  if (!little_endian) {
  ------------------
  |  Branch (1259:7): [True: 0, False: 1.77M]
  ------------------
 1260|      0|    header->nbytes = bswap32_(header->nbytes);
 1261|      0|    header->blocksize = bswap32_(header->blocksize);
 1262|       |    // cbytes written after compression
 1263|      0|  }
 1264|       |
 1265|  1.77M|  if (extended_header) {
  ------------------
  |  Branch (1265:7): [True: 1.77M, False: 0]
  ------------------
 1266|       |    /* Store filter pipeline info at the end of the header */
 1267|  12.4M|    for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1267:21): [True: 10.6M, False: 1.77M]
  ------------------
 1268|  10.6M|      header->filters[i] = context->filters[i];
 1269|  10.6M|      header->filters_meta[i] = context->filters_meta[i];
 1270|  10.6M|    }
 1271|  1.77M|    header->udcompcode = context->compcode;
 1272|  1.77M|    header->compcode_meta = context->compcode_meta;
 1273|  1.77M|    header->blosc2_flags2 = context->blosc2_flags2;
 1274|       |
 1275|  1.77M|    if (!little_endian) {
  ------------------
  |  Branch (1275:9): [True: 0, False: 1.77M]
  ------------------
 1276|      0|      header->blosc2_flags |= BLOSC2_BIGENDIAN;
 1277|      0|    }
 1278|  1.77M|    if (context->use_dict) {
  ------------------
  |  Branch (1278:9): [True: 0, False: 1.77M]
  ------------------
 1279|      0|      header->blosc2_flags |= BLOSC2_USEDICT;
 1280|      0|    }
 1281|  1.77M|    if (context->blosc2_flags & BLOSC2_INSTR_CODEC) {
  ------------------
  |  Branch (1281:9): [True: 0, False: 1.77M]
  ------------------
 1282|      0|      header->blosc2_flags |= BLOSC2_INSTR_CODEC;
 1283|      0|    }
 1284|  1.77M|  }
 1285|       |
 1286|  1.77M|  return 0;
 1287|  1.77M|}
blosc2.c:compcode_to_compversion:
  540|  1.77M|static int compcode_to_compversion(int compcode) {
  541|       |  /* Write compressor format */
  542|  1.77M|  switch (compcode) {
  543|  1.77M|    case BLOSC_BLOSCLZ:
  ------------------
  |  Branch (543:5): [True: 1.77M, False: 0]
  ------------------
  544|  1.77M|      return BLOSC_BLOSCLZ_VERSION_FORMAT;
  545|      0|    case BLOSC_LZ4:
  ------------------
  |  Branch (545:5): [True: 0, False: 1.77M]
  ------------------
  546|      0|      return BLOSC_LZ4_VERSION_FORMAT;
  547|      0|    case BLOSC_LZ4HC:
  ------------------
  |  Branch (547:5): [True: 0, False: 1.77M]
  ------------------
  548|      0|      return BLOSC_LZ4HC_VERSION_FORMAT;
  549|       |
  550|      0|#if defined(HAVE_ZLIB)
  551|      0|    case BLOSC_ZLIB:
  ------------------
  |  Branch (551:5): [True: 0, False: 1.77M]
  ------------------
  552|      0|      return BLOSC_ZLIB_VERSION_FORMAT;
  553|      0|      break;
  554|      0|#endif /*  HAVE_ZLIB */
  555|       |
  556|      0|#if defined(HAVE_ZSTD)
  557|      0|    case BLOSC_ZSTD:
  ------------------
  |  Branch (557:5): [True: 0, False: 1.77M]
  ------------------
  558|      0|      return BLOSC_ZSTD_VERSION_FORMAT;
  559|      0|      break;
  560|      0|#endif /*  HAVE_ZSTD */
  561|      0|    default:
  ------------------
  |  Branch (561:5): [True: 0, False: 1.77M]
  ------------------
  562|      0|      for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (562:23): [True: 0, False: 0]
  ------------------
  563|      0|        if (compcode == g_codecs[i].compcode) {
  ------------------
  |  Branch (563:13): [True: 0, False: 0]
  ------------------
  564|      0|          return g_codecs[i].version;
  565|      0|        }
  566|      0|      }
  567|  1.77M|  }
  568|      0|  return BLOSC2_ERROR_FAILURE;
  569|  1.77M|}
blosc2.c:blosc_compress_context:
 3477|  1.77M|static int blosc_compress_context(blosc2_context* context) {
 3478|  1.77M|  int ntbytes = 0;
 3479|  1.77M|  blosc_timestamp_t last, current;
 3480|  1.77M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 3481|       |
 3482|  1.77M|  blosc_set_timestamp(&last);
 3483|       |
 3484|  1.77M|  if (!memcpyed) {
  ------------------
  |  Branch (3484:7): [True: 1.33M, False: 442k]
  ------------------
 3485|       |    /* Do the actual compression */
 3486|  1.33M|    ntbytes = do_job(context);
 3487|  1.33M|    if (ntbytes < 0) {
  ------------------
  |  Branch (3487:9): [True: 0, False: 1.33M]
  ------------------
 3488|      0|      return ntbytes;
 3489|      0|    }
 3490|  1.33M|    if (ntbytes == 0) {
  ------------------
  |  Branch (3490:9): [True: 35.0k, False: 1.30M]
  ------------------
 3491|       |      // Try out with a memcpy later on (last chance for fitting src buffer in dest).
 3492|  35.0k|      context->header_flags |= (uint8_t)BLOSC_MEMCPYED;
 3493|  35.0k|      memcpyed = true;
 3494|  35.0k|    }
 3495|  1.33M|  }
 3496|       |
 3497|  1.77M|  int dont_split = (context->header_flags & 0x10) >> 4;
 3498|  1.77M|  int nstreams = context->nblocks;
 3499|  1.77M|  if (!dont_split) {
  ------------------
  |  Branch (3499:7): [True: 651k, False: 1.12M]
  ------------------
 3500|       |    // When splitting, the number of streams is computed differently
 3501|   651k|    if (context->leftover) {
  ------------------
  |  Branch (3501:9): [True: 0, False: 651k]
  ------------------
 3502|      0|      nstreams = (context->nblocks - 1) * context->typesize + 1;
 3503|      0|    }
 3504|   651k|    else {
 3505|   651k|      nstreams *= context->typesize;
 3506|   651k|    }
 3507|   651k|  }
 3508|       |
 3509|  1.77M|  if (memcpyed) {
  ------------------
  |  Branch (3509:7): [True: 477k, False: 1.30M]
  ------------------
 3510|   477k|    if (context->sourcesize + context->header_overhead > context->destsize) {
  ------------------
  |  Branch (3510:9): [True: 0, False: 477k]
  ------------------
 3511|       |      /* We are exceeding maximum output size */
 3512|      0|      ntbytes = 0;
 3513|      0|    }
 3514|   477k|    else {
 3515|   477k|      context->output_bytes = context->header_overhead;
 3516|   477k|      ntbytes = do_job(context);
 3517|   477k|      if (ntbytes < 0) {
  ------------------
  |  Branch (3517:11): [True: 0, False: 477k]
  ------------------
 3518|      0|        return ntbytes;
 3519|      0|      }
 3520|       |      // Success!  update the memcpy bit in header
 3521|   477k|      context->dest[BLOSC2_CHUNK_FLAGS] = context->header_flags;
 3522|   477k|      if (context->dict_cdict != NULL) {
  ------------------
  |  Branch (3522:11): [True: 0, False: 477k]
  ------------------
 3523|       |        // The copy overwrote the dictionary that this pass was going to use
 3524|      0|        context->dest[BLOSC2_CHUNK_BLOSC2_FLAGS] &= ~(uint8_t)BLOSC2_USEDICT;
 3525|      0|      }
 3526|       |      // and clear the memcpy bit in context (for next reuse)
 3527|   477k|      context->header_flags &= ~(uint8_t)BLOSC_MEMCPYED;
 3528|   477k|    }
 3529|   477k|  }
 3530|  1.30M|  else {
 3531|       |    // Check whether we have a run for the whole chunk
 3532|  1.30M|    int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (3532:25): [True: 0, False: 1.30M]
  |  Branch (3532:46): [True: 0, False: 0]
  ------------------
 3533|  1.30M|    int start_csizes = context->header_overhead + 4 * context->nblocks;
 3534|  1.30M|    if (!dict_training && ntbytes == (int)(start_csizes + nstreams * sizeof(int32_t))) {
  ------------------
  |  Branch (3534:9): [True: 1.30M, False: 0]
  |  Branch (3534:27): [True: 157k, False: 1.14M]
  ------------------
 3535|       |      // The streams are all zero runs (by construction).  Encode it...
 3536|   157k|      context->dest[BLOSC2_CHUNK_BLOSC2_FLAGS] |= BLOSC2_SPECIAL_ZERO << 4;
 3537|       |      // ...and assign the new chunk length
 3538|   157k|      ntbytes = context->header_overhead;
 3539|   157k|    }
 3540|  1.30M|  }
 3541|       |
 3542|       |  /* Set the number of compressed bytes in header */
 3543|  1.77M|  _sw32(context->dest + BLOSC2_CHUNK_CBYTES, ntbytes);
 3544|  1.77M|  if (context->blosc2_flags & BLOSC2_INSTR_CODEC) {
  ------------------
  |  Branch (3544:7): [True: 0, False: 1.77M]
  ------------------
 3545|      0|    dont_split = (context->header_flags & 0x10) >> 4;
 3546|      0|    int32_t blocksize = dont_split ? (int32_t)sizeof(blosc2_instr) : (int32_t)sizeof(blosc2_instr) * context->typesize;
  ------------------
  |  Branch (3546:25): [True: 0, False: 0]
  ------------------
 3547|      0|    _sw32(context->dest + BLOSC2_CHUNK_NBYTES, nstreams * (int32_t)sizeof(blosc2_instr));
 3548|      0|    _sw32(context->dest + BLOSC2_CHUNK_BLOCKSIZE, blocksize);
 3549|      0|  }
 3550|       |
 3551|       |  /* Set the number of bytes in dest buffer (might be useful for tuner) */
 3552|  1.77M|  context->destsize = ntbytes;
 3553|       |
 3554|  1.77M|  if (context->tuner_params != NULL) {
  ------------------
  |  Branch (3554:7): [True: 0, False: 1.77M]
  ------------------
 3555|      0|    blosc_set_timestamp(&current);
 3556|      0|    double ctime = blosc_elapsed_secs(last, current);
 3557|      0|    int rc;
 3558|      0|    if (context->tuner_id < BLOSC_LAST_TUNER && context->tuner_id == BLOSC_STUNE) {
  ------------------
  |  |   26|      0|#define BLOSC_STUNE 0
  ------------------
  |  Branch (3558:9): [True: 0, False: 0]
  |  Branch (3558:49): [True: 0, False: 0]
  ------------------
 3559|      0|      rc = blosc_stune_update(context, ctime);
 3560|      0|    } else {
 3561|      0|      for (int i = 0; i < g_ntuners; ++i) {
  ------------------
  |  Branch (3561:23): [True: 0, False: 0]
  ------------------
 3562|      0|        if (g_tuners[i].id == context->tuner_id) {
  ------------------
  |  Branch (3562:13): [True: 0, False: 0]
  ------------------
 3563|      0|          if (load_acquire_ptr(&g_tuners[i].init) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (3563:15): [True: 0, False: 0]
  ------------------
 3564|      0|            if (fill_tuner(&g_tuners[i]) < 0) {
  ------------------
  |  Branch (3564:17): [True: 0, False: 0]
  ------------------
 3565|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3566|      0|              return BLOSC2_ERROR_FAILURE;
 3567|      0|            }
 3568|      0|          }
 3569|      0|          rc = g_tuners[i].update(context, ctime);
 3570|      0|          goto urtunersuccess;
 3571|      0|        }
 3572|      0|      }
 3573|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3574|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 3575|      0|      urtunersuccess:;
 3576|      0|    }
 3577|      0|    if (rc < 0) {
  ------------------
  |  Branch (3577:9): [True: 0, False: 0]
  ------------------
 3578|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3579|      0|      return BLOSC2_ERROR_TUNER;
 3580|      0|    }
 3581|      0|  }
 3582|       |
 3583|  1.77M|  return ntbytes;
 3584|  1.77M|}
blosc2.c:clibcode_to_clibname:
  427|      1|static const char* clibcode_to_clibname(int clibcode) {
  428|      1|  if (clibcode == BLOSC_BLOSCLZ_LIB) return BLOSC_BLOSCLZ_LIBNAME;
  ------------------
  |  |  367|      0|#define BLOSC_BLOSCLZ_LIBNAME   "BloscLZ"
  ------------------
  |  Branch (428:7): [True: 0, False: 1]
  ------------------
  429|      1|  if (clibcode == BLOSC_LZ4_LIB) return BLOSC_LZ4_LIBNAME;
  ------------------
  |  |  368|      0|#define BLOSC_LZ4_LIBNAME       "LZ4"
  ------------------
  |  Branch (429:7): [True: 0, False: 1]
  ------------------
  430|      1|  if (clibcode == BLOSC_ZLIB_LIB) return BLOSC_ZLIB_LIBNAME;
  ------------------
  |  |  369|      0|#define BLOSC_ZLIB_LIBNAME      "Zlib"
  ------------------
  |  Branch (430:7): [True: 0, False: 1]
  ------------------
  431|      1|  if (clibcode == BLOSC_ZSTD_LIB) return BLOSC_ZSTD_LIBNAME;
  ------------------
  |  |  370|      0|#define BLOSC_ZSTD_LIBNAME      "Zstd"
  ------------------
  |  Branch (431:7): [True: 0, False: 1]
  ------------------
  432|     10|  for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (432:19): [True: 9, False: 1]
  ------------------
  433|      9|    if (clibcode == g_codecs[i].complib)
  ------------------
  |  Branch (433:9): [True: 0, False: 9]
  ------------------
  434|      0|      return g_codecs[i].compname;
  435|      9|  }
  436|      1|  return NULL;                  /* should never happen */
  437|      1|}
blosc2.c:blosc_run_decompression_with_context:
 4453|  1.64M|                                                void* dest, int32_t destsize) {
 4454|  1.64M|  blosc_header header;
 4455|  1.64M|  int32_t ntbytes;
 4456|  1.64M|  int rc;
 4457|       |
 4458|  1.64M|  rc = read_chunk_header(src, srcsize, true, &header);
 4459|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (4459:7): [True: 8, False: 1.64M]
  ------------------
 4460|      8|    return rc;
 4461|      8|  }
 4462|       |
 4463|  1.64M|  if (header.nbytes > destsize) {
  ------------------
  |  Branch (4463:7): [True: 0, False: 1.64M]
  ------------------
 4464|       |    // Not enough space for writing into the destination
 4465|      0|    return BLOSC2_ERROR_WRITE_BUFFER;
 4466|      0|  }
 4467|       |
 4468|  1.64M|  rc = initialize_context_decompression(context, &header, src, srcsize, dest, destsize);
 4469|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (4469:7): [True: 158, False: 1.64M]
  ------------------
 4470|    158|    return rc;
 4471|    158|  }
 4472|       |
 4473|       |  /* Do the actual decompression */
 4474|  1.64M|  ntbytes = do_job(context);
 4475|  1.64M|  if (ntbytes < 0) {
  ------------------
  |  Branch (4475:7): [True: 739, False: 1.64M]
  ------------------
 4476|    739|    return ntbytes;
 4477|    739|  }
 4478|       |
 4479|  1.64M|  assert(ntbytes <= (int32_t)destsize);
 4480|  1.64M|  return ntbytes;
 4481|  1.64M|}
blosc2.c:initialize_context_decompression:
 3146|  1.64M|                                            int32_t srcsize, void* dest, int32_t destsize) {
 3147|  1.64M|  int32_t bstarts_end;
 3148|  1.64M|  bool vlblocks;
 3149|       |
 3150|  1.64M|  context->do_compress = 0;
 3151|  1.64M|  context->src = (const uint8_t*)src;
 3152|  1.64M|  context->srcsize = srcsize;
 3153|  1.64M|  context->dest = (uint8_t*)dest;
 3154|  1.64M|  context->destsize = destsize;
 3155|  1.64M|  context->output_bytes = 0;
 3156|  1.64M|  context->vlblock_sources = NULL;
 3157|  1.64M|  context->vlblock_dests = NULL;
 3158|  1.64M|  if (context->blocknbytes != NULL) {
  ------------------
  |  Branch (3158:7): [True: 0, False: 1.64M]
  ------------------
 3159|      0|    free(context->blocknbytes);
 3160|      0|    context->blocknbytes = NULL;
 3161|      0|  }
 3162|  1.64M|  if (context->blockoffsets != NULL) {
  ------------------
  |  Branch (3162:7): [True: 0, False: 1.64M]
  ------------------
 3163|      0|    free(context->blockoffsets);
 3164|      0|    context->blockoffsets = NULL;
 3165|      0|  }
 3166|  1.64M|  if (context->blockcbytes != NULL) {
  ------------------
  |  Branch (3166:7): [True: 0, False: 1.64M]
  ------------------
 3167|      0|    free(context->blockcbytes);
 3168|      0|    context->blockcbytes = NULL;
 3169|      0|  }
 3170|       |
 3171|  1.64M|  int rc = blosc2_initialize_context_from_header(context, header);
 3172|  1.64M|  if (rc < 0) {
  ------------------
  |  Branch (3172:7): [True: 0, False: 1.64M]
  ------------------
 3173|      0|    return rc;
 3174|      0|  }
 3175|  1.64M|  clear_context_decompression_dict(context);
 3176|  1.64M|  vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 3177|  1.64M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (3177:19): [True: 1.64M, False: 337]
  ------------------
 3178|  1.64M|                  (context->blosc2_flags & 0x08u));
  ------------------
  |  Branch (3178:19): [True: 71, False: 1.64M]
  ------------------
 3179|       |
 3180|       |  /* Check that we have enough space to decompress */
 3181|  1.64M|  if (context->sourcesize > (int32_t)context->destsize) {
  ------------------
  |  Branch (3181:7): [True: 0, False: 1.64M]
  ------------------
 3182|      0|    return BLOSC2_ERROR_WRITE_BUFFER;
 3183|      0|  }
 3184|       |
 3185|  1.64M|  if (context->block_maskout != NULL) {
  ------------------
  |  Branch (3185:7): [True: 232k, False: 1.41M]
  ------------------
 3186|   232k|    if (context->block_maskout_nitems != context->nblocks) {
  ------------------
  |  Branch (3186:9): [True: 0, False: 232k]
  ------------------
 3187|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3188|      0|                        " of blocks in chunk (%d).",
 3189|      0|                        context->block_maskout_nitems, context->nblocks);
 3190|      0|      return BLOSC2_ERROR_DATA;
 3191|      0|    }
 3192|   232k|    if (filters_contain(context->filters, BLOSC_DELTA)) {
  ------------------
  |  Branch (3192:9): [True: 0, False: 232k]
  ------------------
 3193|      0|      bool any_needed = false;
 3194|      0|      for (int i = 0; i < context->block_maskout_nitems; ++i) {
  ------------------
  |  Branch (3194:23): [True: 0, False: 0]
  ------------------
 3195|      0|        if (!context->block_maskout[i]) {
  ------------------
  |  Branch (3195:13): [True: 0, False: 0]
  ------------------
 3196|      0|          any_needed = true;
 3197|      0|          break;
 3198|      0|        }
 3199|      0|      }
 3200|      0|      if (any_needed) {
  ------------------
  |  Branch (3200:11): [True: 0, False: 0]
  ------------------
 3201|       |        // Delta filter encodes subsequent blocks relative to block 0; block 0 must be unmasked.
 3202|      0|        context->block_maskout[0] = false;
 3203|      0|      }
 3204|      0|    }
 3205|   232k|  }
 3206|       |
 3207|  1.64M|  context->special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
 3208|  1.64M|  if (context->special_type > BLOSC2_SPECIAL_LASTID) {
  ------------------
  |  Branch (3208:7): [True: 1, False: 1.64M]
  ------------------
 3209|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3210|      1|                      context->special_type);
 3211|      1|    return BLOSC2_ERROR_DATA;
 3212|      1|  }
 3213|       |
 3214|  1.64M|  int memcpyed = (context->header_flags & (uint8_t) BLOSC_MEMCPYED);
 3215|  1.64M|  if (memcpyed && (header->cbytes != header->nbytes + context->header_overhead)) {
  ------------------
  |  Branch (3215:7): [True: 441k, False: 1.20M]
  |  Branch (3215:19): [True: 7, False: 441k]
  ------------------
 3216|      7|    BLOSC_TRACE_ERROR("Wrong header info for this memcpyed chunk");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3217|      7|    return BLOSC2_ERROR_DATA;
 3218|      7|  }
 3219|       |
 3220|  1.64M|  if ((header->nbytes == 0) && (header->cbytes == context->header_overhead) &&
  ------------------
  |  Branch (3220:7): [True: 0, False: 1.64M]
  |  Branch (3220:32): [True: 0, False: 0]
  ------------------
 3221|      0|      !context->special_type) {
  ------------------
  |  Branch (3221:7): [True: 0, False: 0]
  ------------------
 3222|       |    // A compressed buffer with only a header can only contain a zero-length buffer
 3223|      0|    return 0;
 3224|      0|  }
 3225|       |
 3226|  1.64M|  context->bstarts = (int32_t *) (context->src + context->header_overhead);
 3227|  1.64M|  bstarts_end = context->header_overhead;
 3228|  1.64M|  if (!context->special_type && !memcpyed) {
  ------------------
  |  Branch (3228:7): [True: 1.58M, False: 66.4k]
  |  Branch (3228:33): [True: 1.14M, False: 441k]
  ------------------
 3229|  1.14M|    size_t bstarts_end_tmp;
 3230|  1.14M|    size_t bstarts_nbytes;
 3231|  1.14M|    if (context->nblocks < 0 ||
  ------------------
  |  Branch (3231:9): [True: 0, False: 1.14M]
  ------------------
 3232|  1.14M|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &bstarts_nbytes) ||
  ------------------
  |  Branch (3232:9): [True: 0, False: 1.14M]
  ------------------
 3233|  1.14M|        !blosc2_checked_add_size((size_t)context->header_overhead, bstarts_nbytes, &bstarts_end_tmp) ||
  ------------------
  |  Branch (3233:9): [True: 0, False: 1.14M]
  ------------------
 3234|  1.14M|        bstarts_end_tmp > (size_t)INT32_MAX) {
  ------------------
  |  Branch (3234:9): [True: 2, False: 1.14M]
  ------------------
 3235|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3236|      2|      return BLOSC2_ERROR_INVALID_HEADER;
 3237|      2|    }
 3238|       |    /* If chunk is not special or a memcpyed, we do have a bstarts section */
 3239|  1.14M|    bstarts_end = (int32_t)bstarts_end_tmp;
 3240|  1.14M|  }
 3241|       |
 3242|  1.64M|  if (srcsize < bstarts_end) {
  ------------------
  |  Branch (3242:7): [True: 15, False: 1.64M]
  ------------------
 3243|     15|    BLOSC_TRACE_ERROR("`bstarts` exceeds length of source buffer.");
  ------------------
  |  |   93|     15|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     15|    do {                                            \
  |  |  |  |   98|     15|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     15|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     15|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3244|     15|    return BLOSC2_ERROR_READ_BUFFER;
 3245|     15|  }
 3246|       |
 3247|  1.64M|  if (vlblocks && is_lazy && !context->special_type && !memcpyed) {
  ------------------
  |  Branch (3247:7): [True: 94, False: 1.64M]
  |  Branch (3247:19): [True: 27, False: 67]
  |  Branch (3247:30): [True: 27, False: 0]
  |  Branch (3247:56): [True: 27, False: 0]
  ------------------
 3248|     27|    size_t block_csizes_nbytes;
 3249|     27|    size_t trailer_meta_nbytes;
 3250|     27|    size_t lazy_trailer_end;
 3251|     27|    if (context->srcsize < 0 || context->nblocks < 0 ||
  ------------------
  |  Branch (3251:9): [True: 0, False: 27]
  |  Branch (3251:33): [True: 0, False: 27]
  ------------------
 3252|     27|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &block_csizes_nbytes) ||
  ------------------
  |  Branch (3252:9): [True: 0, False: 27]
  ------------------
 3253|     27|        !blosc2_checked_add_size(sizeof(int32_t) + sizeof(int64_t), block_csizes_nbytes, &trailer_meta_nbytes) ||
  ------------------
  |  Branch (3253:9): [True: 0, False: 27]
  ------------------
 3254|     27|        !blosc2_checked_add_size((size_t)bstarts_end, trailer_meta_nbytes, &lazy_trailer_end) ||
  ------------------
  |  Branch (3254:9): [True: 0, False: 27]
  ------------------
 3255|     27|        (size_t)context->srcsize < lazy_trailer_end) {
  ------------------
  |  Branch (3255:9): [True: 2, False: 25]
  ------------------
 3256|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3257|      2|      return BLOSC2_ERROR_READ_BUFFER;
 3258|      2|    }
 3259|     27|  }
 3260|  1.64M|  srcsize -= bstarts_end;
 3261|       |
 3262|       |  /* Read optional dictionary if flag set.  A memcpyed chunk has none, even if the flag says so
 3263|       |     (older versions left it on chunks with a dictionary that did not compress) */
 3264|  1.64M|  if ((context->blosc2_flags & BLOSC2_USEDICT) && !memcpyed && !is_lazy) {
  ------------------
  |  Branch (3264:7): [True: 233, False: 1.64M]
  |  Branch (3264:51): [True: 233, False: 0]
  |  Branch (3264:64): [True: 224, False: 9]
  ------------------
 3265|    224|    context->use_dict = 1;
 3266|       |    // The dictionary section is after the bstarts block: [int32 size | raw bytes]
 3267|    224|    if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (3267:9): [True: 1, False: 223]
  ------------------
 3268|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3269|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3270|      1|    }
 3271|    223|    srcsize -= sizeof(int32_t);
 3272|       |    // Read dictionary size
 3273|    223|    context->dict_size = sw32_(context->src + bstarts_end);
 3274|    223|    if (context->dict_size <= 0 || context->dict_size > BLOSC2_MAXDICTSIZE) {
  ------------------
  |  Branch (3274:9): [True: 15, False: 208]
  |  Branch (3274:36): [True: 12, False: 196]
  ------------------
 3275|     27|      BLOSC_TRACE_ERROR("Dictionary size is smaller than minimum or larger than maximum allowed.");
  ------------------
  |  |   93|     27|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     27|    do {                                            \
  |  |  |  |   98|     27|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     27|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 27, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     27|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3276|     27|      return BLOSC2_ERROR_CODEC_DICT;
 3277|     27|    }
 3278|    196|    if (srcsize < (int32_t)context->dict_size) {
  ------------------
  |  Branch (3278:9): [True: 6, False: 190]
  ------------------
 3279|      6|      BLOSC_TRACE_ERROR("Not enough space to read entire dictionary.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3280|      6|      return BLOSC2_ERROR_READ_BUFFER;
 3281|      6|    }
 3282|    190|    srcsize -= context->dict_size;
 3283|       |    // dict_buffer points directly into the source chunk — no copy needed
 3284|    190|    context->dict_buffer = (void*)(context->src + bstarts_end + sizeof(int32_t));
 3285|    190|    context->dict_buffer_owned = false;
 3286|    190|#if defined(HAVE_ZSTD)
 3287|       |    // context->compcode during decompression holds the format code (flags >> 5),
 3288|       |    // so compare against BLOSC_ZSTD_FORMAT (not BLOSC_ZSTD).
 3289|    190|    if (context->compcode == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (3289:9): [True: 14, False: 176]
  ------------------
 3290|     14|      context->dict_ddict = ZSTD_createDDict(context->dict_buffer, context->dict_size);
 3291|     14|      if (context->dict_ddict == NULL) {
  ------------------
  |  Branch (3291:11): [True: 0, False: 14]
  ------------------
 3292|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3293|      0|        return BLOSC2_ERROR_CODEC_DICT;
 3294|      0|      }
 3295|     14|    }
 3296|    190|#endif   // HAVE_ZSTD
 3297|       |    // For LZ4/LZ4HC: dict_buffer and dict_size are sufficient; no digested object needed.
 3298|    190|  }
 3299|  1.64M|  else if ((context->blosc2_flags & BLOSC2_USEDICT) && !memcpyed && is_lazy) {
  ------------------
  |  Branch (3299:12): [True: 9, False: 1.64M]
  |  Branch (3299:56): [True: 9, False: 0]
  |  Branch (3299:69): [True: 9, False: 0]
  ------------------
 3300|      9|    rc = load_lazy_chunk_dict(context, header, bstarts_end);
 3301|      9|    if (rc < 0) {
  ------------------
  |  Branch (3301:9): [True: 9, False: 0]
  ------------------
 3302|      9|      return rc;
 3303|      9|    }
 3304|      9|  }
 3305|       |
 3306|  1.64M|  if (vlblocks && !context->special_type && !memcpyed) {
  ------------------
  |  Branch (3306:7): [True: 91, False: 1.64M]
  |  Branch (3306:19): [True: 91, False: 0]
  |  Branch (3306:45): [True: 91, False: 0]
  ------------------
 3307|     91|    context->blocknbytes = malloc((size_t)context->nblocks * sizeof(int32_t));
 3308|     91|    BLOSC_ERROR_NULL(context->blocknbytes, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     91|    do {                                            \
  |  |  105|     91|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 91]
  |  |  ------------------
  |  |  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|     91|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 91]
  |  |  ------------------
  ------------------
 3309|     91|    context->blockoffsets = malloc((size_t)context->nblocks * sizeof(int32_t));
 3310|     91|    BLOSC_ERROR_NULL(context->blockoffsets, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     91|    do {                                            \
  |  |  105|     91|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 91]
  |  |  ------------------
  |  |  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|     91|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 91]
  |  |  ------------------
  ------------------
 3311|     91|    context->blockcbytes = malloc((size_t)context->nblocks * sizeof(int32_t));
 3312|     91|    BLOSC_ERROR_NULL(context->blockcbytes, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     91|    do {                                            \
  |  |  105|     91|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 91]
  |  |  ------------------
  |  |  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|     91|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 91]
  |  |  ------------------
  ------------------
 3313|       |
 3314|     91|    if (is_lazy) {
  ------------------
  |  Branch (3314:9): [True: 24, False: 67]
  ------------------
 3315|       |      // Lazy VL: block data is on disk, so blocknbytes is unknown at this point.
 3316|       |      // Populate blockcbytes from bstarts differences; blocksize gets max(blockcbytes)
 3317|       |      // as a safe upper bound so tmp buffers are large enough for the lazy block read.
 3318|     24|      int32_t max_csize = 0;
 3319|     26|      for (int32_t i = 0; i < context->nblocks; ++i) {
  ------------------
  |  Branch (3319:27): [True: 25, False: 1]
  ------------------
 3320|     25|        int32_t bstart = sw32_(context->bstarts + i);
 3321|     25|        int32_t next_bstart = (i + 1 < context->nblocks) ?
  ------------------
  |  Branch (3321:31): [True: 9, False: 16]
  ------------------
 3322|     16|            sw32_(context->bstarts + i + 1) : header->cbytes;
 3323|     25|        if (bstart < bstarts_end || next_bstart <= bstart ||
  ------------------
  |  Branch (3323:13): [True: 8, False: 17]
  |  Branch (3323:37): [True: 11, False: 6]
  ------------------
 3324|     23|            next_bstart > header->cbytes) {
  ------------------
  |  Branch (3324:13): [True: 4, False: 2]
  ------------------
 3325|     23|          BLOSC_TRACE_ERROR("Invalid VL-block offsets in lazy chunk.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3326|     23|          return BLOSC2_ERROR_INVALID_HEADER;
 3327|     23|        }
 3328|      2|        context->blocknbytes[i] = 0;   // unknown until block is read from disk
 3329|      2|        context->blockoffsets[i] = 0;  // unknown
 3330|      2|        context->blockcbytes[i] = next_bstart - bstart;
 3331|      2|        if (context->blockcbytes[i] > max_csize) {
  ------------------
  |  Branch (3331:13): [True: 2, False: 0]
  ------------------
 3332|      2|          max_csize = context->blockcbytes[i];
 3333|      2|        }
 3334|      2|      }
 3335|      1|      context->blocksize = max_csize;
 3336|      1|      context->leftover = 0;
 3337|      1|    }
 3338|     67|    else {
 3339|     67|      int32_t max_blocksize = 0;
 3340|     67|      int64_t total_nbytes = 0;
 3341|     67|      int32_t prev_bstart = 0;
 3342|     77|      for (int32_t i = 0; i < context->nblocks; ++i) {
  ------------------
  |  Branch (3342:27): [True: 67, False: 10]
  ------------------
 3343|     67|        int32_t bstart = sw32_(context->bstarts + i);
 3344|     67|        int32_t next_bstart = (i + 1 < context->nblocks) ?
  ------------------
  |  Branch (3344:31): [True: 10, False: 57]
  ------------------
 3345|     57|            sw32_(context->bstarts + i + 1) : header->cbytes;
 3346|     67|        if (bstart < bstarts_end || bstart <= prev_bstart || next_bstart <= bstart ||
  ------------------
  |  Branch (3346:13): [True: 2, False: 65]
  |  Branch (3346:37): [True: 0, False: 65]
  |  Branch (3346:62): [True: 25, False: 40]
  ------------------
 3347|     40|            next_bstart > header->cbytes || bstart > context->srcsize - (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (3347:13): [True: 5, False: 35]
  |  Branch (3347:45): [True: 1, False: 34]
  ------------------
 3348|     33|          BLOSC_TRACE_ERROR("Invalid VL-block offsets in chunk.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3349|     33|          return BLOSC2_ERROR_INVALID_HEADER;
 3350|     33|        }
 3351|     34|        context->blocknbytes[i] = sw32_(context->src + bstart);
 3352|     34|        context->blockcbytes[i] = next_bstart - bstart;
 3353|     34|        if (context->blocknbytes[i] <= 0) {
  ------------------
  |  Branch (3353:13): [True: 6, False: 28]
  ------------------
 3354|      6|          BLOSC_TRACE_ERROR("Invalid VL-block uncompressed size in chunk.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3355|      6|          return BLOSC2_ERROR_INVALID_HEADER;
 3356|      6|        }
 3357|     28|        if (total_nbytes > INT32_MAX) {
  ------------------
  |  Branch (3357:13): [True: 0, False: 28]
  ------------------
 3358|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3359|      0|          return BLOSC2_ERROR_INVALID_HEADER;
 3360|      0|        }
 3361|     28|        context->blockoffsets[i] = (int32_t)total_nbytes;
 3362|     28|        total_nbytes += context->blocknbytes[i];
 3363|     28|        if (total_nbytes > context->sourcesize) {
  ------------------
  |  Branch (3363:13): [True: 18, False: 10]
  ------------------
 3364|     18|          BLOSC_TRACE_ERROR("VL-block sizes exceed chunk nbytes.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3365|     18|          return BLOSC2_ERROR_INVALID_HEADER;
 3366|     18|        }
 3367|     10|        if (context->blocknbytes[i] > max_blocksize) {
  ------------------
  |  Branch (3367:13): [True: 10, False: 0]
  ------------------
 3368|     10|          max_blocksize = context->blocknbytes[i];
 3369|     10|        }
 3370|     10|        prev_bstart = bstart;
 3371|     10|      }
 3372|     10|      if (total_nbytes != context->sourcesize) {
  ------------------
  |  Branch (3372:11): [True: 8, False: 2]
  ------------------
 3373|      8|        BLOSC_TRACE_ERROR("VL-block sizes do not add up to chunk nbytes.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3374|      8|        return BLOSC2_ERROR_INVALID_HEADER;
 3375|      8|      }
 3376|      2|      context->blocksize = max_blocksize;
 3377|      2|      context->leftover = 0;
 3378|      2|    }
 3379|     91|  }
 3380|       |
 3381|  1.64M|  return 0;
 3382|  1.64M|}
blosc2.c:load_lazy_chunk_dict:
 3092|      9|static int load_lazy_chunk_dict(blosc2_context* context, blosc_header* header, int32_t bstarts_end) {
 3093|      9|  int32_t dict_offset = bstarts_end;
 3094|      9|  if (header->cbytes < dict_offset + (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (3094:7): [True: 1, False: 8]
  ------------------
 3095|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3096|      1|    return BLOSC2_ERROR_INVALID_HEADER;
 3097|      1|  }
 3098|       |
 3099|      8|  uint8_t dict_size_buf[sizeof(int32_t)];
 3100|      8|  int rc = read_lazy_chunk_bytes(context, dict_offset, dict_size_buf, (int32_t)sizeof(dict_size_buf),
 3101|      8|                                 "Cannot open frame file for lazy chunk dictionary read.",
 3102|      8|                                 "Cannot read lazy chunk dictionary size from disk.");
 3103|      8|  if (rc < 0) {
  ------------------
  |  Branch (3103:7): [True: 8, False: 0]
  ------------------
 3104|      8|    return rc;
 3105|      8|  }
 3106|       |
 3107|      0|  context->dict_size = sw32_(dict_size_buf);
 3108|      0|  if (context->dict_size <= 0 || context->dict_size > BLOSC2_MAXDICTSIZE) {
  ------------------
  |  Branch (3108:7): [True: 0, False: 0]
  |  Branch (3108:34): [True: 0, False: 0]
  ------------------
 3109|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3110|      0|    return BLOSC2_ERROR_CODEC_DICT;
 3111|      0|  }
 3112|      0|  if (header->cbytes < dict_offset + (int32_t)sizeof(int32_t) + context->dict_size) {
  ------------------
  |  Branch (3112:7): [True: 0, False: 0]
  ------------------
 3113|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3114|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3115|      0|  }
 3116|       |
 3117|      0|  context->dict_buffer = malloc((size_t)context->dict_size);
 3118|      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]
  |  |  ------------------
  ------------------
 3119|      0|  context->dict_buffer_owned = true;
 3120|      0|  rc = read_lazy_chunk_bytes(context, dict_offset + (int32_t)sizeof(int32_t),
 3121|      0|                             context->dict_buffer, context->dict_size,
 3122|      0|                             "Cannot open frame file for lazy chunk dictionary read.",
 3123|      0|                             "Cannot read lazy chunk dictionary from disk.");
 3124|      0|  if (rc < 0) {
  ------------------
  |  Branch (3124:7): [True: 0, False: 0]
  ------------------
 3125|      0|    release_context_dict_buffer(context);
 3126|      0|    return rc;
 3127|      0|  }
 3128|       |
 3129|      0|  context->use_dict = 1;
 3130|      0|#if defined(HAVE_ZSTD)
 3131|      0|  if (context->compcode == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (3131:7): [True: 0, False: 0]
  ------------------
 3132|      0|    context->dict_ddict = ZSTD_createDDict(context->dict_buffer, context->dict_size);
 3133|      0|    if (context->dict_ddict == NULL) {
  ------------------
  |  Branch (3133:9): [True: 0, False: 0]
  ------------------
 3134|      0|      release_context_dict_buffer(context);
 3135|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3136|      0|      return BLOSC2_ERROR_CODEC_DICT;
 3137|      0|    }
 3138|      0|  }
 3139|      0|#endif
 3140|       |
 3141|      0|  return 0;
 3142|      0|}
blosc2.c:do_job:
 2776|  3.46M|static int do_job(blosc2_context* context) {
 2777|  3.46M|  int32_t ntbytes;
 2778|       |
 2779|       |  /* Set sentinels */
 2780|  3.46M|  context->dref_not_init = 1;
 2781|       |
 2782|       |  /* Apply thread-count changes before deciding whether this operation actually
 2783|       |     needs a parallel backend.  POSIX defers backend startup for serial jobs.
 2784|       |     Windows keeps its existing per-context thread lifecycle and starts/rebinds
 2785|       |     the backend eagerly. */
 2786|       |#if defined(_WIN32)
 2787|       |  int rc = check_nthreads(context, true);
 2788|       |#else
 2789|  3.46M|  int rc = check_nthreads(context, false);
 2790|  3.46M|#endif
 2791|       |
 2792|       |  /* Run serially with one thread, with fewer than two full blocks of source
 2793|       |     data, or if thread configuration/backend setup fails. */
 2794|  3.46M|  if (context->nthreads == 1 || (context->sourcesize / context->blocksize) <= 1 || rc < 0) {
  ------------------
  |  Branch (2794:7): [True: 2.44M, False: 1.01M]
  |  Branch (2794:33): [True: 634k, False: 382k]
  |  Branch (2794:84): [True: 0, False: 382k]
  ------------------
 2795|  3.07M|    ntbytes = run_serial_job(context);
 2796|  3.07M|  }
 2797|   382k|  else {
 2798|   382k|    rc = check_nthreads(context, true);
 2799|   382k|    if (rc < 0) {
  ------------------
  |  Branch (2799:9): [True: 0, False: 382k]
  ------------------
 2800|       |      /* Backend startup failed; run serially and retry on the next parallel job. */
 2801|      0|      ntbytes = run_serial_job(context);
 2802|      0|    }
 2803|   382k|    else {
 2804|   382k|      ntbytes = parallel_blosc(context);
 2805|   382k|    }
 2806|   382k|  }
 2807|       |
 2808|  3.46M|  return ntbytes;
 2809|  3.46M|}
blosc2.c:run_serial_job:
 2764|  3.07M|static int run_serial_job(blosc2_context* context) {
 2765|  3.07M|  struct thread_context* thread_context = serial_context_get(context);
 2766|  3.07M|  if (thread_context == NULL) {
  ------------------
  |  Branch (2766:7): [True: 0, False: 3.07M]
  ------------------
 2767|      0|    return BLOSC2_ERROR_THREAD_CREATE;
 2768|      0|  }
 2769|  3.07M|  int ntbytes = serial_blosc(thread_context);
 2770|  3.07M|  serial_context_put(thread_context);
 2771|  3.07M|  return ntbytes;
 2772|  3.07M|}
blosc2.c:serial_blosc:
 2511|  3.07M|static int serial_blosc(struct thread_context* thread_context) {
 2512|  3.07M|  blosc2_context* context = thread_context->parent_context;
 2513|  3.07M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 2514|  3.07M|  int32_t j, bsize, leftoverblock;
 2515|  3.07M|  int32_t cbytes;
 2516|  3.07M|  int32_t ntbytes = context->output_bytes;
 2517|  3.07M|  int32_t* bstarts = context->bstarts;
 2518|  3.07M|  uint8_t* tmp = thread_context->tmp;
 2519|  3.07M|  uint8_t* tmp2 = thread_context->tmp2;
 2520|  3.07M|  int dict_training = context->use_dict && (context->dict_cdict == NULL);
  ------------------
  |  Branch (2520:23): [True: 189, False: 3.07M]
  |  Branch (2520:44): [True: 189, False: 0]
  ------------------
 2521|  3.07M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 2522|  3.07M|  if (!context->do_compress && context->special_type) {
  ------------------
  |  Branch (2522:7): [True: 1.64M, False: 1.43M]
  |  Branch (2522:32): [True: 66.4k, False: 1.58M]
  ------------------
 2523|       |    // Fake a runlen as if it was a memcpyed chunk
 2524|  66.4k|    memcpyed = true;
 2525|  66.4k|  }
 2526|       |
 2527|  30.3M|  for (j = 0; j < context->nblocks; j++) {
  ------------------
  |  Branch (2527:15): [True: 27.3M, False: 3.04M]
  ------------------
 2528|  27.3M|    if (context->do_compress && !memcpyed && !dict_training) {
  ------------------
  |  Branch (2528:9): [True: 17.5M, False: 9.83M]
  |  Branch (2528:33): [True: 12.4M, False: 5.09M]
  |  Branch (2528:46): [True: 12.4M, False: 0]
  ------------------
 2529|  12.4M|      _sw32(bstarts + j, ntbytes);
 2530|  12.4M|    }
 2531|  27.3M|    bsize = vlblocks ? context->blocknbytes[j] : context->blocksize;
  ------------------
  |  Branch (2531:13): [True: 3, False: 27.3M]
  ------------------
 2532|  27.3M|    leftoverblock = 0;
 2533|  27.3M|    if (!vlblocks && (j == context->nblocks - 1) && (context->leftover > 0)) {
  ------------------
  |  Branch (2533:9): [True: 27.3M, False: 3]
  |  Branch (2533:22): [True: 3.05M, False: 24.3M]
  |  Branch (2533:53): [True: 804k, False: 2.24M]
  ------------------
 2534|   804k|      bsize = context->leftover;
 2535|   804k|      leftoverblock = 1;
 2536|   804k|    }
 2537|  27.3M|    if (context->do_compress) {
  ------------------
  |  Branch (2537:9): [True: 17.5M, False: 9.83M]
  ------------------
 2538|  17.5M|      if (memcpyed && !context->prefilter) {
  ------------------
  |  Branch (2538:11): [True: 5.09M, False: 12.4M]
  |  Branch (2538:23): [True: 2.09M, False: 2.99M]
  ------------------
 2539|       |        /* We want to memcpy only */
 2540|  2.09M|        memcpy(context->dest + context->header_overhead + j * context->blocksize,
 2541|  2.09M|               context->src + j * context->blocksize, (unsigned int)bsize);
 2542|  2.09M|        cbytes = (int32_t)bsize;
 2543|  2.09M|      }
 2544|  15.4M|      else {
 2545|       |        /* Regular compression */
 2546|  15.4M|        cbytes = blosc_c(thread_context, bsize, leftoverblock, ntbytes,
 2547|  15.4M|                         context->destsize,
 2548|  15.4M|                         vlblocks ? context->vlblock_sources[j] : context->src,
  ------------------
  |  Branch (2548:26): [True: 0, False: 15.4M]
  ------------------
 2549|  15.4M|                         vlblocks ? 0 : j * context->blocksize,
  ------------------
  |  Branch (2549:26): [True: 0, False: 15.4M]
  ------------------
 2550|  15.4M|                         context->dest + ntbytes, tmp, tmp2);
 2551|  15.4M|        if (cbytes == 0) {
  ------------------
  |  Branch (2551:13): [True: 35.0k, False: 15.3M]
  ------------------
 2552|  35.0k|          ntbytes = 0;              /* incompressible data */
 2553|  35.0k|          break;
 2554|  35.0k|        }
 2555|  15.4M|      }
 2556|  17.5M|    }
 2557|  9.83M|    else {
 2558|       |      /* Regular decompression */
 2559|       |      // If memcpyed we don't have a bstarts section (because it is not needed)
 2560|  9.83M|      int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (2560:28): [True: 6.69M, False: 3.13M]
  ------------------
 2561|  6.69M|          context->header_overhead + j * context->blocksize : sw32_(bstarts + j);
 2562|  9.83M|      uint8_t *dest_block = (vlblocks && context->vlblock_dests != NULL) ? context->vlblock_dests[j] : context->dest;
  ------------------
  |  Branch (2562:30): [True: 3, False: 9.83M]
  |  Branch (2562:42): [True: 0, False: 3]
  ------------------
 2563|  9.83M|      int32_t dest_offset = (vlblocks && context->vlblock_dests != NULL) ? 0 :
  ------------------
  |  Branch (2563:30): [True: 3, False: 9.83M]
  |  Branch (2563:42): [True: 0, False: 3]
  ------------------
 2564|  9.83M|                            (vlblocks ? context->blockoffsets[j] : j * context->blocksize);
  ------------------
  |  Branch (2564:30): [True: 3, False: 9.83M]
  ------------------
 2565|  9.83M|      cbytes = blosc_d(thread_context, bsize, leftoverblock, memcpyed,
 2566|  9.83M|                       context->src, context->srcsize, src_offset, j,
 2567|  9.83M|                       dest_block, dest_offset, tmp, tmp2);
 2568|  9.83M|    }
 2569|       |
 2570|  27.3M|    if (cbytes < 0) {
  ------------------
  |  Branch (2570:9): [True: 739, False: 27.3M]
  ------------------
 2571|    739|      ntbytes = cbytes;         /* error in blosc_c or blosc_d */
 2572|    739|      break;
 2573|    739|    }
 2574|  27.3M|    ntbytes += cbytes;
 2575|  27.3M|  }
 2576|       |
 2577|  3.07M|  return ntbytes;
 2578|  3.07M|}
blosc2.c:blosc_c:
 1518|  16.6M|                   uint8_t* tmp, uint8_t* tmp2) {
 1519|  16.6M|  blosc2_context* context = thread_context->parent_context;
 1520|  16.6M|  int dont_split = (context->header_flags & 0x10) >> 4;
 1521|  16.6M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 1522|  16.6M|  int dict_training = context->use_dict && context->dict_cdict == NULL;
  ------------------
  |  Branch (1522:23): [True: 0, False: 16.6M]
  |  Branch (1522:44): [True: 0, False: 0]
  ------------------
 1523|  16.6M|  int32_t j, neblock, nstreams;
 1524|  16.6M|  int32_t cbytes;                   /* number of compressed bytes in split */
 1525|  16.6M|  int32_t ctbytes = 0;              /* number of compressed bytes in block */
 1526|  16.6M|  int32_t maxout;
 1527|  16.6M|  int32_t typesize = context->typesize;
 1528|  16.6M|  bool output_is_disposable = (context->preparams != NULL) ? context->preparams->output_is_disposable : false;
  ------------------
  |  Branch (1528:31): [True: 12.9M, False: 3.63M]
  ------------------
 1529|  16.6M|  const char* compname;
 1530|  16.6M|  int accel;
 1531|  16.6M|  const uint8_t* _src;
 1532|  16.6M|  uint8_t *_tmp = tmp, *_tmp2 = tmp2;
 1533|  16.6M|  int last_filter_index = last_filter(context, 'c');
 1534|  16.6M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 1535|  16.6M|  bool instr_codec = context->blosc2_flags & BLOSC2_INSTR_CODEC;
 1536|  16.6M|  blosc_timestamp_t last, current;
 1537|  16.6M|  float filter_time = 0.f;
 1538|       |
 1539|  16.6M|  if (instr_codec) {
  ------------------
  |  Branch (1539:7): [True: 0, False: 16.6M]
  ------------------
 1540|      0|    blosc_set_timestamp(&last);
 1541|      0|  }
 1542|       |
 1543|       |  // See whether we have a run here
 1544|  16.6M|  if (last_filter_index >= 0 || context->prefilter != NULL) {
  ------------------
  |  Branch (1544:7): [True: 12.4M, False: 4.19M]
  |  Branch (1544:33): [True: 4.13M, False: 53.0k]
  ------------------
 1545|       |    /* Apply the filter pipeline just for the prefilter */
 1546|  16.5M|    if (memcpyed && context->prefilter != NULL) {
  ------------------
  |  Branch (1546:9): [True: 2.99M, False: 13.5M]
  |  Branch (1546:21): [True: 2.99M, False: 0]
  ------------------
 1547|       |      // We only need the prefilter output
 1548|  2.99M|      _src = pipeline_forward(thread_context, bsize, src, offset, dest, _tmp2);
 1549|  2.99M|      if (_src == NULL) {
  ------------------
  |  Branch (1549:11): [True: 0, False: 2.99M]
  ------------------
 1550|      0|        return BLOSC2_ERROR_FILTER_PIPELINE;
 1551|      0|      }
 1552|  2.99M|      return bsize;
 1553|  2.99M|    }
 1554|       |    /* Apply regular filter pipeline */
 1555|  13.5M|    _src = pipeline_forward(thread_context, bsize, src, offset, _tmp, _tmp2);
 1556|  13.5M|    if (_src == NULL) {
  ------------------
  |  Branch (1556:9): [True: 0, False: 13.5M]
  ------------------
 1557|      0|      return BLOSC2_ERROR_FILTER_PIPELINE;
 1558|      0|    }
 1559|  13.5M|  } else {
 1560|  55.7k|    _src = src + offset;
 1561|  55.7k|  }
 1562|       |
 1563|  13.6M|  if (instr_codec) {
  ------------------
  |  Branch (1563:7): [True: 0, False: 13.6M]
  ------------------
 1564|      0|    blosc_set_timestamp(&current);
 1565|      0|    filter_time = (float) blosc_elapsed_secs(last, current);
 1566|      0|    last = current;
 1567|      0|  }
 1568|       |
 1569|  13.6M|  assert(context->clevel > 0);
 1570|       |
 1571|       |  /* Calculate acceleration for different compressors */
 1572|  13.6M|  accel = get_accel(context);
 1573|       |
 1574|       |  /* The number of compressed data streams for this block */
 1575|  13.6M|  if (!dont_split && !leftoverblock && !dict_training) {
  ------------------
  |  Branch (1575:7): [True: 1.97M, False: 11.6M]
  |  Branch (1575:22): [True: 1.97M, False: 0]
  |  Branch (1575:40): [True: 1.97M, False: 0]
  ------------------
 1576|  1.97M|    nstreams = (int32_t)typesize;
 1577|  1.97M|  }
 1578|  11.6M|  else {
 1579|  11.6M|    nstreams = 1;
 1580|  11.6M|  }
 1581|  13.6M|  neblock = bsize / nstreams;
 1582|  29.5M|  for (j = 0; j < nstreams; j++) {
  ------------------
  |  Branch (1582:15): [True: 15.9M, False: 13.5M]
  ------------------
 1583|  15.9M|    if (instr_codec) {
  ------------------
  |  Branch (1583:9): [True: 0, False: 15.9M]
  ------------------
 1584|      0|      blosc_set_timestamp(&last);
 1585|      0|    }
 1586|  15.9M|    if (!dict_training) {
  ------------------
  |  Branch (1586:9): [True: 15.9M, False: 18.4E]
  ------------------
 1587|  15.9M|      dest += sizeof(int32_t);
 1588|  15.9M|      ntbytes += sizeof(int32_t);
 1589|  15.9M|      ctbytes += sizeof(int32_t);
 1590|       |
 1591|  15.9M|      if (!vlblocks && context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && output_is_disposable) {
  ------------------
  |  Branch (1591:11): [True: 15.9M, False: 58]
  |  Branch (1591:24): [True: 15.9M, False: 18.4E]
  |  Branch (1591:84): [True: 0, False: 15.9M]
  ------------------
 1592|       |        // Simulate a run of 0s
 1593|      0|        BLOSC_TRACE_INFO("Output is disposable, simulating a run of 0s");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1594|      0|        memset(dest - 4, 0, sizeof(int32_t));
 1595|      0|        continue;
 1596|      0|      }
 1597|       |
 1598|  15.9M|      const uint8_t *ip = (uint8_t *) _src + j * neblock;
 1599|  15.9M|      const uint8_t *ipbound = (uint8_t *) _src + (j + 1) * neblock;
 1600|       |
 1601|  15.9M|      if (!vlblocks && context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH && get_run(ip, ipbound)) {
  ------------------
  |  Branch (1601:11): [True: 15.9M, False: 337]
  |  Branch (1601:24): [True: 15.9M, False: 57]
  |  Branch (1601:84): [True: 12.4M, False: 3.50M]
  ------------------
 1602|       |        // A run
 1603|  12.4M|        int32_t value = _src[j * neblock];
 1604|  12.4M|        if (ntbytes > destsize) {
  ------------------
  |  Branch (1604:13): [True: 21.4k, False: 12.4M]
  ------------------
 1605|  21.4k|          return 0;    /* Non-compressible data */
 1606|  21.4k|        }
 1607|       |
 1608|  12.4M|        if (instr_codec) {
  ------------------
  |  Branch (1608:13): [True: 0, False: 12.4M]
  ------------------
 1609|      0|          blosc_set_timestamp(&current);
 1610|      0|          int32_t instr_size = sizeof(blosc2_instr);
 1611|      0|          ntbytes += instr_size;
 1612|      0|          ctbytes += instr_size;
 1613|      0|          if (ntbytes > destsize) {
  ------------------
  |  Branch (1613:15): [True: 0, False: 0]
  ------------------
 1614|      0|            return 0;    /* Non-compressible data */
 1615|      0|          }
 1616|      0|          _sw32(dest - 4, instr_size);
 1617|      0|          blosc2_instr *desti = (blosc2_instr *)dest;
 1618|      0|          memset(desti, 0, sizeof(blosc2_instr));
 1619|       |          // Special values have an overhead of about 1 int32
 1620|      0|          int32_t ssize = value == 0 ? sizeof(int32_t) : sizeof(int32_t) + 1;
  ------------------
  |  Branch (1620:27): [True: 0, False: 0]
  ------------------
 1621|      0|          desti->cratio = (float) neblock / (float) ssize;
 1622|      0|          float ctime = (float) blosc_elapsed_secs(last, current);
 1623|      0|          desti->cspeed = (float) neblock / ctime;
 1624|      0|          desti->filter_speed = (float) neblock / filter_time;
 1625|      0|          desti->flags[0] = 1;    // mark a runlen
 1626|      0|          dest += instr_size;
 1627|      0|          continue;
 1628|      0|        }
 1629|       |
 1630|       |        // Encode the repeated byte in the first (LSB) byte of the length of the split.
 1631|  12.4M|        _sw32(dest - 4, -value);    // write the value in two's complement
 1632|  12.4M|        if (value > 0) {
  ------------------
  |  Branch (1632:13): [True: 598k, False: 11.8M]
  ------------------
 1633|       |          // Mark encoding as a run-length (== 0 is always a 0's run)
 1634|   598k|          ntbytes += 1;
 1635|   598k|          ctbytes += 1;
 1636|   598k|          if (ntbytes > destsize) {
  ------------------
  |  Branch (1636:15): [True: 256, False: 598k]
  ------------------
 1637|    256|            return 0;    /* Non-compressible data */
 1638|    256|          }
 1639|       |          // Set MSB bit (sign) to 1 (not really necessary here, but for demonstration purposes)
 1640|       |          // dest[-1] |= 0x80;
 1641|   598k|          dest[0] = 0x1;   // set run-length bit (0) in token
 1642|   598k|          dest += 1;
 1643|   598k|        }
 1644|  12.4M|        continue;
 1645|  12.4M|      }
 1646|  15.9M|    }
 1647|       |
 1648|  3.50M|    maxout = neblock;
 1649|  3.50M|    if (ntbytes + maxout > destsize && !instr_codec) {
  ------------------
  |  Branch (1649:9): [True: 458k, False: 3.05M]
  |  Branch (1649:40): [True: 458k, False: 0]
  ------------------
 1650|       |      /* avoid buffer * overrun */
 1651|   458k|      maxout = destsize - ntbytes;
 1652|   458k|      if (maxout <= 0) {
  ------------------
  |  Branch (1652:11): [True: 2.51k, False: 455k]
  ------------------
 1653|  2.51k|        return 0;                  /* non-compressible block */
 1654|  2.51k|      }
 1655|   458k|    }
 1656|  3.50M|    if (dict_training) {
  ------------------
  |  Branch (1656:9): [True: 0, False: 3.50M]
  ------------------
 1657|       |      // We are in the build dict state, so don't compress
 1658|       |      // TODO: copy only a percentage for sampling
 1659|      0|      memcpy(dest, _src + j * neblock, (unsigned int)neblock);
 1660|      0|      cbytes = (int32_t)neblock;
 1661|      0|    }
 1662|  3.50M|    else if (context->compcode == BLOSC_BLOSCLZ) {
  ------------------
  |  Branch (1662:14): [True: 3.50M, False: 39]
  ------------------
 1663|  3.50M|      if (thread_context->blosclz_state == NULL) {
  ------------------
  |  Branch (1663:11): [True: 2.30k, False: 3.50M]
  ------------------
 1664|  2.30k|        thread_context->blosclz_state = calloc(1, sizeof(blosclz_state));
 1665|  2.30k|      }
 1666|  3.50M|      cbytes = thread_context->blosclz_state != NULL ?
  ------------------
  |  Branch (1666:16): [True: 3.50M, False: 18.4E]
  ------------------
 1667|  3.50M|               blosclz_compress_state(context->clevel, _src + j * neblock, (int)neblock,
 1668|  3.50M|                                      dest, maxout, thread_context->blosclz_state) :
 1669|  18.4E|               blosclz_compress(context->clevel, _src + j * neblock, (int)neblock,
 1670|  18.4E|                                dest, maxout, context);
 1671|  3.50M|    }
 1672|     39|    else if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (1672:14): [True: 0, False: 39]
  ------------------
 1673|      0|      cbytes = lz4_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1674|      0|                                 (char*)dest, (size_t)maxout, accel,
 1675|      0|                                 thread_context);
 1676|      0|    }
 1677|     39|    else if (context->compcode == BLOSC_LZ4HC) {
  ------------------
  |  Branch (1677:14): [True: 0, False: 39]
  ------------------
 1678|      0|      cbytes = lz4hc_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1679|      0|                                   (char*)dest, (size_t)maxout, context->clevel,
 1680|      0|                                   thread_context);
 1681|      0|    }
 1682|     39|  #if defined(HAVE_ZLIB)
 1683|     39|    else if (context->compcode == BLOSC_ZLIB) {
  ------------------
  |  Branch (1683:14): [True: 0, False: 39]
  ------------------
 1684|      0|      cbytes = zlib_wrap_compress((char*)_src + j * neblock, (size_t)neblock,
 1685|      0|                                  (char*)dest, (size_t)maxout, context->clevel);
 1686|      0|    }
 1687|     39|  #endif /* HAVE_ZLIB */
 1688|     39|  #if defined(HAVE_ZSTD)
 1689|     39|    else if (context->compcode == BLOSC_ZSTD) {
  ------------------
  |  Branch (1689:14): [True: 0, False: 39]
  ------------------
 1690|      0|      cbytes = zstd_wrap_compress(thread_context,
 1691|      0|                                  (char*)_src + j * neblock, (size_t)neblock,
 1692|      0|                                  (char*)dest, (size_t)maxout, context->clevel);
 1693|      0|    }
 1694|     39|  #endif /* HAVE_ZSTD */
 1695|     39|    else if (context->compcode > BLOSC2_DEFINED_CODECS_STOP) {
  ------------------
  |  Branch (1695:14): [True: 0, False: 39]
  ------------------
 1696|      0|      for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (1696:23): [True: 0, False: 0]
  ------------------
 1697|      0|        if (g_codecs[i].compcode == context->compcode) {
  ------------------
  |  Branch (1697:13): [True: 0, False: 0]
  ------------------
 1698|      0|          if (load_acquire_ptr(&g_codecs[i].decoder) == NULL) {
  ------------------
  |  |  144|      0|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (1698:15): [True: 0, False: 0]
  ------------------
 1699|       |            // Dynamically load codec plugin
 1700|      0|            if (fill_codec(&g_codecs[i]) < 0) {
  ------------------
  |  Branch (1700:17): [True: 0, False: 0]
  ------------------
 1701|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1702|      0|              return BLOSC2_ERROR_CODEC_SUPPORT;
 1703|      0|            }
 1704|      0|          }
 1705|      0|          blosc2_cparams cparams;
 1706|      0|          blosc2_ctx_get_cparams(context, &cparams);
 1707|      0|          cbytes = g_codecs[i].encoder(_src + j * neblock,
 1708|      0|                                        neblock,
 1709|      0|                                        dest,
 1710|      0|                                        maxout,
 1711|      0|                                        context->compcode_meta,
 1712|      0|                                        &cparams,
 1713|      0|                                        context->src);
 1714|      0|          goto urcodecsuccess;
 1715|      0|        }
 1716|      0|      }
 1717|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1718|      0|      return BLOSC2_ERROR_CODEC_SUPPORT;
 1719|      0|    urcodecsuccess:
 1720|      0|      ;
 1721|     39|    } else {
 1722|     39|      blosc2_compcode_to_compname(context->compcode, &compname);
 1723|     39|      BLOSC_TRACE_ERROR("Blosc has not been compiled with '%s' compression support."
  ------------------
  |  |   93|     39|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     39|    do {                                            \
  |  |  |  |   98|     39|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     39|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 0, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  100|     39|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|     39|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1724|     39|                        "Please use one having it.", compname);
 1725|     39|      return BLOSC2_ERROR_CODEC_SUPPORT;
 1726|     39|    }
 1727|       |
 1728|  3.50M|    if (cbytes > maxout) {
  ------------------
  |  Branch (1728:9): [True: 0, False: 3.50M]
  ------------------
 1729|       |      /* Buffer overrun caused by compression (should never happen) */
 1730|      0|      return BLOSC2_ERROR_WRITE_BUFFER;
 1731|      0|    }
 1732|  3.50M|    if (cbytes < 0) {
  ------------------
  |  Branch (1732:9): [True: 0, False: 3.50M]
  ------------------
 1733|       |      /* cbytes should never be negative */
 1734|      0|      return BLOSC2_ERROR_DATA;
 1735|      0|    }
 1736|  3.50M|    if (cbytes == 0) {
  ------------------
  |  Branch (1736:9): [True: 426k, False: 3.08M]
  ------------------
 1737|       |      // When cbytes is 0, the compressor has not been able to compress anything
 1738|   426k|      cbytes = neblock;
 1739|   426k|    }
 1740|       |
 1741|  3.50M|    if (instr_codec) {
  ------------------
  |  Branch (1741:9): [True: 0, False: 3.50M]
  ------------------
 1742|      0|      blosc_set_timestamp(&current);
 1743|      0|      int32_t instr_size = sizeof(blosc2_instr);
 1744|      0|      ntbytes += instr_size;
 1745|      0|      ctbytes += instr_size;
 1746|      0|      if (ntbytes > destsize) {
  ------------------
  |  Branch (1746:11): [True: 0, False: 0]
  ------------------
 1747|      0|        return 0;    /* Non-compressible data */
 1748|      0|      }
 1749|      0|      _sw32(dest - 4, vlblocks ? neblock : instr_size);
  ------------------
  |  Branch (1749:23): [True: 0, False: 0]
  ------------------
 1750|      0|      float ctime = (float)blosc_elapsed_secs(last, current);
 1751|      0|      blosc2_instr *desti = (blosc2_instr *)dest;
 1752|      0|      memset(desti, 0, sizeof(blosc2_instr));
 1753|       |      // cratio is computed having into account 1 additional int (csize)
 1754|      0|      desti->cratio = (float)neblock / (float)(cbytes + sizeof(int32_t));
 1755|      0|      desti->cspeed = (float)neblock / ctime;
 1756|      0|      desti->filter_speed = (float) neblock / filter_time;
 1757|      0|      dest += instr_size;
 1758|      0|      continue;
 1759|      0|    }
 1760|       |
 1761|  3.50M|    if (!dict_training) {
  ------------------
  |  Branch (1761:9): [True: 3.50M, False: 18.4E]
  ------------------
 1762|  3.50M|      if (cbytes == neblock) {
  ------------------
  |  Branch (1762:11): [True: 426k, False: 3.08M]
  ------------------
 1763|       |        /* The compressor has been unable to compress data at all. */
 1764|       |        /* Before doing the copy, check that we are not running into a
 1765|       |           buffer overflow. */
 1766|   426k|        if ((ntbytes + neblock) > destsize) {
  ------------------
  |  Branch (1766:13): [True: 10.8k, False: 415k]
  ------------------
 1767|  10.8k|          return 0;    /* Non-compressible data */
 1768|  10.8k|        }
 1769|   415k|        memcpy(dest, _src + j * neblock, (unsigned int)neblock);
 1770|   415k|        cbytes = neblock;
 1771|   415k|      }
 1772|  3.49M|      _sw32(dest - 4, vlblocks ? neblock : cbytes);
  ------------------
  |  Branch (1772:23): [True: 0, False: 3.49M]
  ------------------
 1773|  3.49M|    }
 1774|  3.49M|    dest += cbytes;
 1775|  3.49M|    ntbytes += cbytes;
 1776|  3.49M|    ctbytes += cbytes;
 1777|  3.49M|  }  /* Closes j < nstreams */
 1778|       |
 1779|  13.5M|  return ctbytes;
 1780|  13.6M|}
blosc2.c:get_accel:
  759|  13.6M|static int get_accel(const blosc2_context* context) {
  760|  13.6M|  int clevel = context->clevel;
  761|       |
  762|  13.6M|  if (context->compcode == BLOSC_LZ4) {
  ------------------
  |  Branch (762:7): [True: 0, False: 13.6M]
  ------------------
  763|       |    /* This acceleration setting based on discussions held in:
  764|       |     * https://groups.google.com/forum/#!topic/lz4c/zosy90P8MQw
  765|       |     */
  766|      0|    return (10 - clevel);
  767|      0|  }
  768|  13.6M|  return 1;
  769|  13.6M|}
blosc2.c:get_run:
 1460|  15.9M|static bool get_run(const uint8_t* ip, const uint8_t* ip_bound) {
 1461|  15.9M|  uint8_t x = *ip;
 1462|  15.9M|  int64_t value, value2;
 1463|       |  /* Broadcast the value for every byte in a 64-bit register */
 1464|  15.9M|  memset(&value, x, 8);
 1465|  15.9M|#if defined(BLOSC_RUN_SSE2) || defined(BLOSC_RUN_NEON)
 1466|  15.9M|  if (ip_bound - ip >= 64) {
  ------------------
  |  Branch (1466:7): [True: 8.98M, False: 6.98M]
  ------------------
 1467|       |    /* Streams that are not runs mostly differ in their first bytes */
 1468|  8.98M|    memcpy(&value2, ip, 8);
 1469|  8.98M|    if (value != value2) {
  ------------------
  |  Branch (1469:9): [True: 1.29M, False: 7.68M]
  ------------------
 1470|  1.29M|      return false;
 1471|  1.29M|    }
 1472|  8.98M|  }
 1473|  14.6M|#endif
 1474|  14.6M|#if defined(BLOSC_RUN_SSE2)
 1475|  14.6M|  const __m128i vx = _mm_set1_epi8((char)x);
 1476|   916M|  while (ip_bound - ip >= 64) {
  ------------------
  |  Branch (1476:10): [True: 903M, False: 12.8M]
  ------------------
 1477|   903M|    const __m128i* p = (const __m128i*)ip;
 1478|   903M|    __m128i eq01 = _mm_and_si128(_mm_cmpeq_epi8(_mm_loadu_si128(p), vx),
 1479|   903M|                                 _mm_cmpeq_epi8(_mm_loadu_si128(p + 1), vx));
 1480|   903M|    __m128i eq23 = _mm_and_si128(_mm_cmpeq_epi8(_mm_loadu_si128(p + 2), vx),
 1481|   903M|                                 _mm_cmpeq_epi8(_mm_loadu_si128(p + 3), vx));
 1482|   903M|    if (_mm_movemask_epi8(_mm_and_si128(eq01, eq23)) != 0xFFFF) {
  ------------------
  |  Branch (1482:9): [True: 1.80M, False: 902M]
  ------------------
 1483|  1.80M|      return false;
 1484|  1.80M|    }
 1485|   902M|    ip += 64;
 1486|   902M|  }
 1487|       |#elif defined(BLOSC_RUN_NEON)
 1488|       |  const uint8x16_t vx = vdupq_n_u8(x);
 1489|       |  while (ip_bound - ip >= 64) {
 1490|       |    uint8x16_t diff01 = vorrq_u8(veorq_u8(vld1q_u8(ip), vx), veorq_u8(vld1q_u8(ip + 16), vx));
 1491|       |    uint8x16_t diff23 = vorrq_u8(veorq_u8(vld1q_u8(ip + 32), vx), veorq_u8(vld1q_u8(ip + 48), vx));
 1492|       |    if (vmaxvq_u32(vreinterpretq_u32_u8(vorrq_u8(diff01, diff23))) != 0) {
 1493|       |      return false;
 1494|       |    }
 1495|       |    ip += 64;
 1496|       |  }
 1497|       |#endif
 1498|  32.0M|  while (ip < (ip_bound - 8)) {
  ------------------
  |  Branch (1498:10): [True: 19.5M, False: 12.5M]
  ------------------
 1499|  19.5M|    memcpy(&value2, ip, 8);
 1500|  19.5M|    if (value != value2) {
  ------------------
  |  Branch (1500:9): [True: 357k, False: 19.1M]
  ------------------
 1501|       |      // Values differ.  We don't have a run.
 1502|   357k|      return false;
 1503|   357k|    }
 1504|  19.1M|    else {
 1505|  19.1M|      ip += 8;
 1506|  19.1M|    }
 1507|  19.5M|  }
 1508|       |  /* Look into the remainder */
 1509|  88.2M|  while ((ip < ip_bound) && (*ip == x)) ip++;
  ------------------
  |  Branch (1509:10): [True: 75.7M, False: 12.4M]
  |  Branch (1509:29): [True: 75.6M, False: 49.8k]
  ------------------
 1510|  12.5M|  return ip == ip_bound ? true : false;
  ------------------
  |  Branch (1510:10): [True: 12.4M, False: 46.6k]
  ------------------
 1511|  12.8M|}
blosc2.c:parallel_blosc:
 6125|   382k|static int parallel_blosc(blosc2_context* context) {
 6126|       |#if defined(_WIN32)
 6127|       |  /* Windows: per-context threads using WAIT_INIT/WAIT_FINISH barriers.
 6128|       |   * No job-group struct; workers read/write context fields directly. */
 6129|       |  context->job = NULL;
 6130|       |  context->thread_giveup_code = 1;
 6131|       |  context->thread_nblock = -1;
 6132|       |
 6133|       |  if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
 6134|       |    threads_callback(threads_callback_data, t_blosc_do_job,
 6135|       |                     context->nthreads, sizeof(struct thread_context), (void*) context->thread_contexts);
 6136|       |  }
 6137|       |  else {
 6138|       |    /* BLOSC_BACKEND_PER_CONTEXT: post job to sleeping workers and wait. */
 6139|       |    blosc2_pthread_mutex_lock(&context->jobs_mutex);
 6140|       |    context->active_workers = context->nthreads;
 6141|       |    context->job_seq++;
 6142|       |    blosc2_pthread_cond_broadcast(&context->jobs_ready);
 6143|       |    while (context->active_workers > 0) {
 6144|       |      blosc2_pthread_cond_wait(&context->jobs_done, &context->jobs_mutex);
 6145|       |    }
 6146|       |    blosc2_pthread_mutex_unlock(&context->jobs_mutex);
 6147|       |  }
 6148|       |
 6149|       |  if (context->thread_giveup_code <= 0) {
 6150|       |    return context->thread_giveup_code;
 6151|       |  }
 6152|       |  return (int)context->output_bytes;
 6153|       |
 6154|       |#else  /* !_WIN32 */
 6155|       |
 6156|   382k|  struct blosc_job_group job;
 6157|       |
 6158|   382k|  job_group_init(&job, context);
 6159|   382k|  context->job = &job;
 6160|       |
 6161|   382k|  if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|   382k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (6161:7): [True: 0, False: 382k]
  ------------------
 6162|      0|    blosc2_pthread_mutex_lock(&job.mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6163|      0|    job.active_workers = context->nthreads;
 6164|      0|    job.pending_workers = 0;
 6165|      0|    blosc2_pthread_mutex_unlock(&job.mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6166|      0|    threads_callback(threads_callback_data, t_blosc_do_job,
 6167|      0|                     context->nthreads, sizeof(struct thread_context), (void*) context->thread_contexts);
 6168|      0|  }
 6169|   382k|  else {
 6170|   382k|    struct blosc_shared_pool *pool = context->thread_pool;
 6171|   382k|    blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|   382k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6172|   382k|    int32_t enqueued = 0;
 6173|       |    /* More workers than blocks cannot add useful parallel work. */
 6174|   382k|    int32_t workers = context->nthreads < context->nblocks ? context->nthreads : context->nblocks;
  ------------------
  |  Branch (6174:23): [True: 0, False: 382k]
  ------------------
 6175|  1.57M|    for (int32_t tid = 0; tid < workers; ++tid) {
  ------------------
  |  Branch (6175:27): [True: 1.19M, False: 382k]
  ------------------
 6176|  1.19M|      struct blosc_job_queue_entry *entry = (struct blosc_job_queue_entry *)my_malloc(sizeof(*entry));
 6177|  1.19M|      if (entry == NULL) {
  ------------------
  |  Branch (6177:11): [True: 0, False: 1.19M]
  ------------------
 6178|       |        /* Drain already-enqueued entries so they don't reference the
 6179|       |           stack-allocated job after we return. */
 6180|      0|        struct blosc_job_queue_entry **pp = &pool->job_queue_head;
 6181|      0|        while (*pp != NULL) {
  ------------------
  |  Branch (6181:16): [True: 0, False: 0]
  ------------------
 6182|      0|          if ((*pp)->job == &job) {
  ------------------
  |  Branch (6182:15): [True: 0, False: 0]
  ------------------
 6183|      0|            struct blosc_job_queue_entry *victim = *pp;
 6184|      0|            *pp = victim->next;
 6185|      0|            my_free(victim);
 6186|      0|            pool->active_jobs--;
 6187|      0|          } else {
 6188|      0|            pp = &(*pp)->next;
 6189|      0|          }
 6190|      0|        }
 6191|      0|        pool->job_queue_tail = NULL;
 6192|       |        /* Recompute tail */
 6193|      0|        for (struct blosc_job_queue_entry *e = pool->job_queue_head; e != NULL; e = e->next) {
  ------------------
  |  Branch (6193:70): [True: 0, False: 0]
  ------------------
 6194|      0|          pool->job_queue_tail = e;
 6195|      0|        }
 6196|      0|        blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6197|      0|        context->job = NULL;
 6198|      0|        job_group_destroy(&job);
 6199|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 6200|      0|      }
 6201|  1.19M|      memset(entry, 0, sizeof(*entry));
 6202|  1.19M|      entry->job = &job;
 6203|  1.19M|      entry->logical_tid = tid;
 6204|  1.19M|      if (pool->job_queue_tail != NULL) {
  ------------------
  |  Branch (6204:11): [True: 814k, False: 382k]
  ------------------
 6205|   814k|        pool->job_queue_tail->next = entry;
 6206|   814k|      }
 6207|   382k|      else {
 6208|   382k|        pool->job_queue_head = entry;
 6209|   382k|      }
 6210|  1.19M|      pool->job_queue_tail = entry;
 6211|  1.19M|      pool->active_jobs++;
 6212|  1.19M|      enqueued++;
 6213|  1.19M|    }
 6214|       |    /* Set active_workers to the actual number enqueued */
 6215|   382k|    blosc2_pthread_mutex_lock(&job.mutex);
  ------------------
  |  |   92|   382k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6216|   382k|    job.active_workers = enqueued;
 6217|   382k|    job.pending_workers = enqueued;
 6218|   382k|    blosc2_pthread_mutex_unlock(&job.mutex);
  ------------------
  |  |   93|   382k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6219|   382k|    blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|   382k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6220|       |    /* Wake after unlocking (workers woken under pool->mutex block on it and
 6221|       |       start one handoff at a time), and wake all idle workers, also when fewer
 6222|       |       got an entry: the first ones up take the entries, so the job does not
 6223|       |       wait for a worker that is slow to wake. */
 6224|   382k|    blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|   382k|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 6225|       |
 6226|   382k|    blosc2_pthread_mutex_lock(&job.mutex);
  ------------------
  |  |   92|   382k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 6227|   763k|    while (!job.completed) {
  ------------------
  |  Branch (6227:12): [True: 381k, False: 382k]
  ------------------
 6228|   381k|      blosc2_pthread_cond_wait(&job.completion_cv, &job.mutex);
  ------------------
  |  |   98|   381k|#define blosc2_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
  ------------------
 6229|   381k|    }
 6230|   382k|    blosc2_pthread_mutex_unlock(&job.mutex);
  ------------------
  |  |   93|   382k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 6231|   382k|  }
 6232|       |
 6233|   382k|  context->job = NULL;
 6234|   382k|  context->output_bytes = job.output_bytes;
 6235|   382k|  context->thread_giveup_code = job.giveup_code;
 6236|   382k|  job_group_destroy(&job);
 6237|       |
 6238|   382k|  if (context->thread_giveup_code <= 0) {
  ------------------
  |  Branch (6238:7): [True: 0, False: 382k]
  ------------------
 6239|      0|    return context->thread_giveup_code;
 6240|      0|  }
 6241|   382k|  return (int)context->output_bytes;
 6242|       |
 6243|   382k|#endif  /* _WIN32 */
 6244|   382k|}
blosc2.c:job_group_init:
 5686|   382k|static void job_group_init(struct blosc_job_group *job, blosc2_context *context) {
 5687|   382k|  memset(job, 0, sizeof(*job));
 5688|   382k|  job->context = context;
 5689|   382k|  job->next_block = -1;
 5690|   382k|  job->output_bytes = context->output_bytes;
 5691|   382k|  job->giveup_code = 1;
 5692|   382k|  job->dref_not_init = 1;
 5693|   382k|  bool compress = context->do_compress != 0;
 5694|   382k|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 5695|   382k|  if (!compress && context->special_type) {
  ------------------
  |  Branch (5695:7): [True: 0, False: 382k]
  |  Branch (5695:20): [True: 0, False: 0]
  ------------------
 5696|      0|    memcpyed = true;
 5697|      0|  }
 5698|   382k|  job->static_schedule = (!compress || memcpyed) && context->block_maskout == NULL;
  ------------------
  |  Branch (5698:27): [True: 0, False: 382k]
  |  Branch (5698:40): [True: 0, False: 382k]
  |  Branch (5698:53): [True: 0, False: 0]
  ------------------
 5699|   382k|  blosc2_pthread_mutex_init(&job->mutex, NULL);
  ------------------
  |  |   90|   382k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5700|   382k|  blosc2_pthread_mutex_init(&job->delta_mutex, NULL);
  ------------------
  |  |   90|   382k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5701|   382k|  blosc2_pthread_cond_init(&job->delta_cv, NULL);
  ------------------
  |  |   96|   382k|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5702|   382k|  blosc2_pthread_cond_init(&job->completion_cv, NULL);
  ------------------
  |  |   96|   382k|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5703|   382k|}
blosc2.c:t_blosc_do_job:
 5488|  1.19M|static void t_blosc_do_job(void *ctxt) {
 5489|  1.19M|  struct thread_context* thcontext = (struct thread_context*)ctxt;
 5490|  1.19M|  blosc2_context* context = thcontext->parent_context;
 5491|  1.19M|  struct blosc_job_group* job = context->job;
 5492|  1.19M|  int32_t cbytes;
 5493|  1.19M|  int32_t ntdest;
 5494|  1.19M|  int32_t tblocks;
 5495|  1.19M|  int32_t tblock;
 5496|  1.19M|  int32_t nblock_;
 5497|  1.19M|  int32_t bsize;
 5498|  1.19M|  int32_t leftoverblock;
 5499|  1.19M|  int32_t blocksize;
 5500|  1.19M|  int32_t ebsize;
 5501|  1.19M|  int32_t srcsize;
 5502|  1.19M|  bool compress = context->do_compress != 0;
 5503|  1.19M|  int32_t maxbytes;
 5504|  1.19M|  int32_t nblocks;
 5505|  1.19M|  int32_t leftover;
 5506|  1.19M|  int32_t leftover2;
 5507|  1.19M|  int32_t* bstarts;
 5508|  1.19M|  const uint8_t* src;
 5509|  1.19M|  uint8_t* dest;
 5510|  1.19M|  uint8_t* tmp;
 5511|  1.19M|  uint8_t* tmp2;
 5512|  1.19M|  uint8_t* tmp3;
 5513|       |
 5514|  1.19M|  blocksize = context->blocksize;
 5515|  1.19M|  ebsize = blocksize + context->typesize * (int32_t)sizeof(int32_t);
 5516|  1.19M|  maxbytes = context->destsize;
 5517|  1.19M|  nblocks = context->nblocks;
 5518|  1.19M|  leftover = context->leftover;
 5519|  1.19M|  bstarts = context->bstarts;
 5520|  1.19M|  src = context->src;
 5521|  1.19M|  srcsize = context->srcsize;
 5522|  1.19M|  dest = context->dest;
 5523|       |
 5524|  1.19M|  if (fit_thread_context(thcontext, context) < 0) {
  ------------------
  |  Branch (5524:7): [True: 0, False: 1.19M]
  ------------------
 5525|      0|    blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5526|      0|    job->giveup_code = BLOSC2_ERROR_MEMORY_ALLOC;
 5527|      0|    blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5528|      0|    if (!compress) {
  ------------------
  |  Branch (5528:9): [True: 0, False: 0]
  ------------------
 5529|      0|      delta_release_dref(context);
 5530|      0|    }
 5531|      0|    goto job_done;
 5532|      0|  }
 5533|       |
 5534|  1.19M|  tmp = thcontext->tmp;
 5535|  1.19M|  tmp2 = thcontext->tmp2;
 5536|  1.19M|  tmp3 = thcontext->tmp3;
 5537|       |
 5538|  1.19M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 5539|  1.19M|  bool memcpyed = context->header_flags & (uint8_t)BLOSC_MEMCPYED;
 5540|  1.19M|  if (!context->do_compress && context->special_type) {
  ------------------
  |  Branch (5540:7): [True: 0, False: 1.19M]
  |  Branch (5540:32): [True: 0, False: 0]
  ------------------
 5541|      0|    memcpyed = true;
 5542|      0|  }
 5543|       |
 5544|  1.19M|  if (job->static_schedule) {
  ------------------
  |  Branch (5544:7): [True: 0, False: 1.19M]
  ------------------
 5545|      0|    tblocks = nblocks / context->nthreads;
 5546|      0|    leftover2 = nblocks % context->nthreads;
 5547|      0|    tblocks = (leftover2 > 0) ? tblocks + 1 : tblocks;
  ------------------
  |  Branch (5547:15): [True: 0, False: 0]
  ------------------
 5548|      0|    nblock_ = thcontext->tid * tblocks;
 5549|      0|    tblock = nblock_ + tblocks;
 5550|      0|    if (tblock > nblocks) {
  ------------------
  |  Branch (5550:9): [True: 0, False: 0]
  ------------------
 5551|      0|      tblock = nblocks;
 5552|      0|    }
 5553|      0|  }
 5554|  1.19M|  else {
 5555|  1.19M|    nblock_ = claim_job_block(job);
 5556|  1.19M|    tblock = nblocks;
 5557|  1.19M|  }
 5558|       |
 5559|  1.19M|  leftoverblock = 0;
 5560|  2.39M|  while (nblock_ < tblock) {
  ------------------
  |  Branch (5560:10): [True: 1.19M, False: 1.19M]
  ------------------
 5561|  1.19M|    if (job->static_schedule) {
  ------------------
  |  Branch (5561:9): [True: 0, False: 1.19M]
  ------------------
 5562|      0|      blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5563|      0|      if (job->giveup_code <= 0) {
  ------------------
  |  Branch (5563:11): [True: 0, False: 0]
  ------------------
 5564|      0|        blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5565|      0|        break;
 5566|      0|      }
 5567|      0|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5568|      0|    }
 5569|       |
 5570|  1.19M|    bsize = vlblocks ? context->blocknbytes[nblock_] : blocksize;
  ------------------
  |  Branch (5570:13): [True: 0, False: 1.19M]
  ------------------
 5571|  1.19M|    leftoverblock = 0;
 5572|  1.19M|    if (!vlblocks && nblock_ == (nblocks - 1) && (leftover > 0)) {
  ------------------
  |  Branch (5572:9): [True: 1.19M, False: 160]
  |  Branch (5572:22): [True: 382k, False: 814k]
  |  Branch (5572:50): [True: 341k, False: 40.9k]
  ------------------
 5573|   341k|      bsize = leftover;
 5574|   341k|      leftoverblock = 1;
 5575|   341k|    }
 5576|  1.19M|    if (compress) {
  ------------------
  |  Branch (5576:9): [True: 1.19M, False: 103]
  ------------------
 5577|  1.19M|      if (memcpyed) {
  ------------------
  |  Branch (5577:11): [True: 0, False: 1.19M]
  ------------------
 5578|      0|        if (!context->prefilter) {
  ------------------
  |  Branch (5578:13): [True: 0, False: 0]
  ------------------
 5579|      0|          memcpy(dest + context->header_overhead + nblock_ * blocksize,
 5580|      0|                 src + nblock_ * blocksize, (unsigned int) bsize);
 5581|      0|          cbytes = (int32_t)bsize;
 5582|      0|        }
 5583|      0|        else {
 5584|      0|          cbytes = blosc_c(thcontext, bsize, leftoverblock, 0,
 5585|      0|                           ebsize,
 5586|      0|                           vlblocks ? context->vlblock_sources[nblock_] : src,
  ------------------
  |  Branch (5586:28): [True: 0, False: 0]
  ------------------
 5587|      0|                           vlblocks ? 0 : nblock_ * blocksize,
  ------------------
  |  Branch (5587:28): [True: 0, False: 0]
  ------------------
 5588|      0|                           dest + context->header_overhead + nblock_ * blocksize,
 5589|      0|                           tmp, tmp3);
 5590|      0|        }
 5591|      0|      }
 5592|  1.19M|      else {
 5593|  1.19M|        cbytes = blosc_c(thcontext, bsize, leftoverblock, 0,
 5594|  1.19M|                         ebsize,
 5595|  1.19M|                         vlblocks ? context->vlblock_sources[nblock_] : src,
  ------------------
  |  Branch (5595:26): [True: 0, False: 1.19M]
  ------------------
 5596|  1.19M|                         vlblocks ? 0 : nblock_ * blocksize,
  ------------------
  |  Branch (5596:26): [True: 0, False: 1.19M]
  ------------------
 5597|  1.19M|                         tmp2, tmp, tmp3);
 5598|  1.19M|      }
 5599|  1.19M|    }
 5600|    103|    else {
 5601|    103|      if (context->special_type == BLOSC2_NO_SPECIAL && !memcpyed &&
  ------------------
  |  Branch (5601:11): [True: 0, False: 103]
  |  Branch (5601:57): [True: 0, False: 0]
  ------------------
 5602|      0|          (srcsize < (int32_t)(context->header_overhead + (sizeof(int32_t) * nblocks)))) {
  ------------------
  |  Branch (5602:11): [True: 0, False: 0]
  ------------------
 5603|      0|        cbytes = -1;
 5604|      0|      }
 5605|    103|      else {
 5606|    103|        int32_t src_offset = memcpyed ?
  ------------------
  |  Branch (5606:30): [True: 0, False: 103]
  ------------------
 5607|    103|            context->header_overhead + nblock_ * blocksize : sw32_(bstarts + nblock_);
 5608|    103|        uint8_t *dest_block = (vlblocks && context->vlblock_dests != NULL) ? context->vlblock_dests[nblock_] : dest;
  ------------------
  |  Branch (5608:32): [True: 0, False: 103]
  |  Branch (5608:44): [True: 0, False: 0]
  ------------------
 5609|    103|        int32_t dest_offset = (vlblocks && context->vlblock_dests != NULL) ? 0 :
  ------------------
  |  Branch (5609:32): [True: 0, False: 103]
  |  Branch (5609:44): [True: 0, False: 0]
  ------------------
 5610|    103|                              (vlblocks ? context->blockoffsets[nblock_] : nblock_ * blocksize);
  ------------------
  |  Branch (5610:32): [True: 0, False: 103]
  ------------------
 5611|    103|        cbytes = blosc_d(thcontext, bsize, leftoverblock, memcpyed,
 5612|    103|                         src, srcsize, src_offset, nblock_,
 5613|    103|                         dest_block, dest_offset, tmp, tmp2);
 5614|    103|      }
 5615|    103|      if (nblock_ == 0 || cbytes < 0) {
  ------------------
  |  Branch (5615:11): [True: 103, False: 0]
  |  Branch (5615:27): [True: 0, False: 0]
  ------------------
 5616|      0|        delta_release_dref(context);
 5617|      0|      }
 5618|    103|    }
 5619|       |
 5620|  1.19M|    if (cbytes < 0) {
  ------------------
  |  Branch (5620:9): [True: 0, False: 1.19M]
  ------------------
 5621|      0|      blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5622|      0|      if (job->giveup_code > 0) {
  ------------------
  |  Branch (5622:11): [True: 0, False: 0]
  ------------------
 5623|      0|        job->giveup_code = cbytes;
 5624|      0|      }
 5625|      0|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5626|      0|      break;
 5627|      0|    }
 5628|       |
 5629|  1.19M|    blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5630|  1.19M|    if (job->giveup_code <= 0) {
  ------------------
  |  Branch (5630:9): [True: 0, False: 1.19M]
  ------------------
 5631|      0|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5632|      0|      break;
 5633|      0|    }
 5634|  1.19M|    if (compress && !memcpyed) {
  ------------------
  |  Branch (5634:9): [True: 1.19M, False: 18.4E]
  |  Branch (5634:21): [True: 1.19M, False: 0]
  ------------------
 5635|  1.19M|      ntdest = job->output_bytes;
 5636|  1.19M|      if (!(context->use_dict && context->dict_cdict == NULL)) {
  ------------------
  |  Branch (5636:13): [True: 0, False: 1.19M]
  |  Branch (5636:34): [True: 0, False: 0]
  ------------------
 5637|  1.19M|        _sw32(bstarts + nblock_, (int32_t)ntdest);
 5638|  1.19M|      }
 5639|  1.19M|      if ((cbytes == 0) || (ntdest + cbytes > maxbytes)) {
  ------------------
  |  Branch (5639:11): [True: 0, False: 1.19M]
  |  Branch (5639:28): [True: 0, False: 1.19M]
  ------------------
 5640|      0|        job->giveup_code = 0;
 5641|      0|        blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5642|      0|        break;
 5643|      0|      }
 5644|  1.19M|      job->output_bytes += cbytes;
 5645|       |      // Claim the next block while reserving this block's output: one lock
 5646|       |      // acquisition instead of separate cancellation, output and queue locks.
 5647|  1.19M|      if (!job->static_schedule) {
  ------------------
  |  Branch (5647:11): [True: 1.19M, False: 0]
  ------------------
 5648|  1.19M|        nblock_ = ++job->next_block;
 5649|  1.19M|      }
 5650|  1.19M|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5651|  1.19M|      memcpy(dest + ntdest, tmp2, (unsigned int)cbytes);
 5652|  1.19M|    }
 5653|  18.4E|    else {
 5654|  18.4E|      job->output_bytes += cbytes;
 5655|  18.4E|      if (!job->static_schedule) {
  ------------------
  |  Branch (5655:11): [True: 0, False: 18.4E]
  ------------------
 5656|      0|        nblock_ = ++job->next_block;
 5657|      0|      }
 5658|  18.4E|      blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|  18.4E|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5659|  18.4E|    }
 5660|       |
 5661|  1.19M|    if (job->static_schedule) {
  ------------------
  |  Branch (5661:9): [True: 0, False: 1.19M]
  ------------------
 5662|      0|      nblock_++;
 5663|      0|    }
 5664|  1.19M|  }
 5665|       |
 5666|  1.19M|job_done:
 5667|  1.19M|  blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5668|  1.19M|  job->blocks_completed++;
 5669|  1.19M|  if (--job->active_workers == 0) {
  ------------------
  |  Branch (5669:7): [True: 382k, False: 814k]
  ------------------
 5670|   382k|    if (job->static_schedule && job->giveup_code > 0) {
  ------------------
  |  Branch (5670:9): [True: 0, False: 382k]
  |  Branch (5670:33): [True: 0, False: 0]
  ------------------
 5671|      0|      job->output_bytes = context->sourcesize;
 5672|      0|      if (compress) {
  ------------------
  |  Branch (5672:11): [True: 0, False: 0]
  ------------------
 5673|      0|        job->output_bytes += context->header_overhead;
 5674|      0|      }
 5675|      0|    }
 5676|   382k|    if (context->thread_backend == BLOSC_BACKEND_CALLBACK) {
  ------------------
  |  |   35|   382k|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (5676:9): [True: 0, False: 382k]
  ------------------
 5677|      0|      job->completed = true;
 5678|      0|      blosc2_pthread_cond_broadcast(&job->completion_cv);
  ------------------
  |  |  100|      0|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5679|      0|    }
 5680|   382k|  }
 5681|  1.19M|  blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5682|  1.19M|}
blosc2.c:fit_thread_context:
 2704|  7.00M|static int fit_thread_context(struct thread_context* thread_context, blosc2_context* context) {
 2705|  7.00M|  int32_t ebsize = context->blocksize + context->typesize * (int32_t)sizeof(int32_t);
 2706|  7.00M|  if ((size_t)4 * ebsize <= thread_context->tmp_nbytes) {
  ------------------
  |  Branch (2706:7): [True: 6.85M, False: 151k]
  ------------------
 2707|  6.85M|    return 0;
 2708|  6.85M|  }
 2709|   151k|  my_free(thread_context->tmp);
 2710|   151k|  thread_context->tmp = my_malloc((size_t)4 * ebsize);
 2711|   151k|  if (thread_context->tmp == NULL) {
  ------------------
  |  Branch (2711:7): [True: 0, False: 151k]
  ------------------
 2712|      0|    thread_context->tmp_nbytes = 0;
 2713|      0|    thread_context->tmp_blocksize = 0;
 2714|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2715|      0|  }
 2716|   151k|  thread_context->tmp_nbytes = (size_t)4 * ebsize;
 2717|   151k|  thread_context->tmp2 = thread_context->tmp + ebsize;
 2718|   151k|  thread_context->tmp3 = thread_context->tmp2 + ebsize;
 2719|   151k|  thread_context->tmp4 = thread_context->tmp3 + ebsize;
 2720|   151k|  thread_context->tmp_blocksize = context->blocksize;
 2721|   151k|  return 0;
 2722|   151k|}
blosc2.c:claim_job_block:
 5479|  1.19M|static int32_t claim_job_block(struct blosc_job_group *job) {
 5480|  1.19M|  int32_t nblock_;
 5481|  1.19M|  blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5482|  1.19M|  nblock_ = job->giveup_code > 0 ? ++job->next_block : INT32_MAX;
  ------------------
  |  Branch (5482:13): [True: 1.19M, False: 18.4E]
  ------------------
 5483|  1.19M|  blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5484|  1.19M|  return nblock_;
 5485|  1.19M|}
blosc2.c:job_group_destroy:
 5705|   382k|static void job_group_destroy(struct blosc_job_group *job) {
 5706|   382k|  blosc2_pthread_mutex_destroy(&job->mutex);
  ------------------
  |  |   91|   382k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5707|   382k|  blosc2_pthread_mutex_destroy(&job->delta_mutex);
  ------------------
  |  |   91|   382k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5708|   382k|  blosc2_pthread_cond_destroy(&job->delta_cv);
  ------------------
  |  |   97|   382k|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5709|   382k|  blosc2_pthread_cond_destroy(&job->completion_cv);
  ------------------
  |  |   97|   382k|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5710|   382k|}
blosc2.c:read_lazy_chunk_bytes:
 3004|      8|                                 const char* open_error, const char* read_error) {
 3005|      8|  int32_t chunk_cbytes;
 3006|      8|  if (context->src == NULL || context->srcsize < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3006:7): [True: 0, False: 8]
  |  Branch (3006:31): [True: 0, False: 8]
  ------------------
 3007|      8|      offset < 0 || nbytes < 0 || context->nblocks <= 0 ||
  ------------------
  |  Branch (3007:7): [True: 0, False: 8]
  |  Branch (3007:21): [True: 0, False: 8]
  |  Branch (3007:35): [True: 0, False: 8]
  ------------------
 3008|      8|      blosc2_cbuffer_sizes(context->src, NULL, &chunk_cbytes, NULL) < 0 ||
  ------------------
  |  Branch (3008:7): [True: 0, False: 8]
  ------------------
 3009|      8|      offset > chunk_cbytes || nbytes > chunk_cbytes - offset) {
  ------------------
  |  Branch (3009:7): [True: 0, False: 8]
  |  Branch (3009:32): [True: 0, False: 8]
  ------------------
 3010|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3011|      0|  }
 3012|      8|  int64_t trailer_end = BLOSC_EXTENDED_HEADER_LENGTH +
 3013|      8|      (int64_t)context->nblocks * sizeof(int32_t) + sizeof(int32_t) + sizeof(int64_t);
 3014|      8|  if (trailer_end > context->srcsize) return BLOSC2_ERROR_READ_BUFFER;
  ------------------
  |  Branch (3014:7): [True: 4, False: 4]
  ------------------
 3015|      4|  if (context->schunk == NULL || context->schunk->frame == NULL) {
  ------------------
  |  Branch (3015:7): [True: 4, False: 0]
  |  Branch (3015:34): [True: 0, False: 0]
  ------------------
 3016|      4|    BLOSC_TRACE_ERROR("Lazy chunk needs an associated super-chunk with a frame.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3017|      4|    return BLOSC2_ERROR_INVALID_PARAM;
 3018|      4|  }
 3019|       |
 3020|      0|  blosc2_frame_s* frame = (blosc2_frame_s*)context->schunk->frame;
 3021|      0|  blosc2_io_cb* io_cb = blosc2_get_io_cb(context->schunk->storage->io->id);
 3022|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (3022:7): [True: 0, False: 0]
  ------------------
 3023|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3024|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 3025|      0|  }
 3026|       |
 3027|      0|  int32_t trailer_offset = BLOSC_EXTENDED_HEADER_LENGTH +
 3028|      0|                           context->nblocks * (int32_t)sizeof(int32_t);
 3029|      0|  int32_t nchunk_lazy;
 3030|      0|  int64_t chunk_offset;
 3031|      0|  memcpy(&nchunk_lazy, context->src + trailer_offset, sizeof(nchunk_lazy));
 3032|      0|  memcpy(&chunk_offset, context->src + trailer_offset + (int32_t)sizeof(int32_t), sizeof(chunk_offset));
 3033|      0|  if (nchunk_lazy < 0 || chunk_offset < 0 || frame->file_offset < 0 ||
  ------------------
  |  Branch (3033:7): [True: 0, False: 0]
  |  Branch (3033:26): [True: 0, False: 0]
  |  Branch (3033:46): [True: 0, False: 0]
  ------------------
 3034|      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 (3034:8): [True: 0, False: 0]
  |  Branch (3034:27): [True: 0, False: 0]
  ------------------
 3035|      0|       chunk_offset > frame->len || chunk_cbytes > frame->len - chunk_offset))) {
  ------------------
  |  Branch (3035:8): [True: 0, False: 0]
  |  Branch (3035:37): [True: 0, False: 0]
  ------------------
 3036|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3037|      0|  }
 3038|       |
 3039|      0|  void* fp = NULL;
 3040|      0|  int64_t io_pos;
 3041|      0|  if (frame->sframe) {
  ------------------
  |  Branch (3041:7): [True: 0, False: 0]
  ------------------
 3042|      0|    fp = sframe_open_chunk(frame->urlpath, nchunk_lazy, "rb", context->schunk->storage->io);
 3043|      0|    io_pos = offset;
 3044|      0|  }
 3045|      0|  else {
 3046|      0|    if (chunk_offset < 0 || offset < 0) {
  ------------------
  |  Branch (3046:9): [True: 0, False: 0]
  |  Branch (3046:29): [True: 0, False: 0]
  ------------------
 3047|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3048|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3049|      0|    }
 3050|      0|    fp = frame_reader_acquire(frame, context->schunk->storage->io);
 3051|      0|    if (!blosc2_checked_add_i64(frame->file_offset, chunk_offset, &io_pos)) {
  ------------------
  |  Branch (3051:9): [True: 0, False: 0]
  ------------------
 3052|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3053|      0|      if (fp != NULL) {
  ------------------
  |  Branch (3053:11): [True: 0, False: 0]
  ------------------
 3054|      0|        frame_reader_release(frame, io_cb, fp);
 3055|      0|      }
 3056|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3057|      0|    }
 3058|      0|    if (!blosc2_checked_add_i64(io_pos, offset, &io_pos)) {
  ------------------
  |  Branch (3058:9): [True: 0, False: 0]
  ------------------
 3059|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3060|      0|      if (fp != NULL) {
  ------------------
  |  Branch (3060:11): [True: 0, False: 0]
  ------------------
 3061|      0|        frame_reader_release(frame, io_cb, fp);
 3062|      0|      }
 3063|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3064|      0|    }
 3065|      0|  }
 3066|      0|  if (fp == NULL) {
  ------------------
  |  Branch (3066:7): [True: 0, False: 0]
  ------------------
 3067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3068|      0|    return BLOSC2_ERROR_FILE_OPEN;
 3069|      0|  }
 3070|      0|  if (!blosc2_checked_add_i64(io_pos, nbytes, NULL)) {
  ------------------
  |  Branch (3070:7): [True: 0, False: 0]
  ------------------
 3071|      0|    frame_reader_release(frame, io_cb, fp);
 3072|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 3073|      0|  }
 3074|       |
 3075|      0|  uint8_t* read_buffer = buffer;
 3076|      0|  int64_t rbytes = io_cb->read((void**)&read_buffer, 1, nbytes, io_pos, fp);
 3077|      0|  bool complete = rbytes == nbytes && read_buffer != NULL;
  ------------------
  |  Branch (3077:19): [True: 0, False: 0]
  |  Branch (3077:39): [True: 0, False: 0]
  ------------------
 3078|      0|  if (complete && read_buffer != buffer) {
  ------------------
  |  Branch (3078:7): [True: 0, False: 0]
  |  Branch (3078:19): [True: 0, False: 0]
  ------------------
 3079|       |    // An io that hands out its own memory (mmap) keeps owning it
 3080|      0|    memcpy(buffer, read_buffer, (size_t)nbytes);
 3081|      0|  }
 3082|      0|  frame_reader_release(frame, io_cb, fp);
 3083|      0|  if (!complete) {
  ------------------
  |  Branch (3083:7): [True: 0, False: 0]
  ------------------
 3084|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3085|      0|    return BLOSC2_ERROR_FILE_READ;
 3086|      0|  }
 3087|       |
 3088|      0|  return 0;
 3089|      0|}
blosc2.c:serial_context_get:
 2736|  5.81M|static struct thread_context* serial_context_get(blosc2_context* context) {
 2737|  5.81M|  struct thread_context* thread_context = NULL;
 2738|  5.81M|  if (context->serial_context == NULL) {
  ------------------
  |  Branch (2738:7): [True: 5.81M, False: 1.92k]
  ------------------
 2739|  5.81M|    thread_context = serial_context_take_tls(context);
 2740|  5.81M|  }
 2741|  5.81M|  if (thread_context == NULL) {
  ------------------
  |  Branch (2741:7): [True: 2.12k, False: 5.81M]
  ------------------
 2742|  2.12k|    if (context->serial_context != NULL &&
  ------------------
  |  Branch (2742:9): [True: 1.92k, False: 201]
  ------------------
 2743|  1.92k|        context->serial_context->tmp_blocksize != context->blocksize) {
  ------------------
  |  Branch (2743:9): [True: 0, False: 1.92k]
  ------------------
 2744|      0|      free_thread_context(context->serial_context);
 2745|      0|      context->serial_context = NULL;
 2746|      0|    }
 2747|  2.12k|    if (context->serial_context == NULL) {
  ------------------
  |  Branch (2747:9): [True: 201, False: 1.92k]
  ------------------
 2748|    201|      context->serial_context = create_thread_context(context, 0);
 2749|    201|      if (context->serial_context == NULL) {
  ------------------
  |  Branch (2749:11): [True: 0, False: 201]
  ------------------
 2750|      0|        return NULL;
 2751|      0|      }
 2752|    201|    }
 2753|  1.92k|    else if (fit_thread_context(context->serial_context, context) < 0) {
  ------------------
  |  Branch (2753:14): [True: 0, False: 1.92k]
  ------------------
 2754|      0|      return NULL;
 2755|      0|    }
 2756|  2.12k|    thread_context = context->serial_context;
 2757|  2.12k|  }
 2758|  5.81M|  thread_context->parent_context = context;
 2759|  5.81M|  thread_context->tid = 0;
 2760|       |  thread_context->serial = true;
 2761|  5.81M|  return thread_context;
 2762|  5.81M|}
blosc2.c:serial_context_take_tls:
 6741|  5.81M|static struct thread_context* serial_context_take_tls(blosc2_context* context) {
 6742|  5.81M|#if !defined(_WIN32)
 6743|  5.81M|  int32_t ebsize = context->blocksize + context->typesize * (int32_t)sizeof(int32_t);
 6744|  5.81M|  if ((size_t)4 * ebsize > BLOSC2_SERIAL_TLS_MAX) {
  ------------------
  |  | 6664|  5.81M|#define BLOSC2_SERIAL_TLS_MAX (16 * 1024 * 1024)
  ------------------
  |  Branch (6744:7): [True: 201, False: 5.81M]
  ------------------
 6745|    201|    return NULL;
 6746|    201|  }
 6747|  5.81M|  tmp_cache_t *cache = tmp_cache_get(true);
 6748|  5.81M|  if (cache == NULL || cache->serial_busy) {
  ------------------
  |  Branch (6748:7): [True: 0, False: 5.81M]
  |  Branch (6748:24): [True: 0, False: 5.81M]
  ------------------
 6749|      0|    return NULL;
 6750|      0|  }
 6751|  5.81M|  if (cache->serial == NULL) {
  ------------------
  |  Branch (6751:7): [True: 3.59k, False: 5.80M]
  ------------------
 6752|  3.59k|    cache->serial = create_thread_context(context, 0);
 6753|  3.59k|    if (cache->serial == NULL) {
  ------------------
  |  Branch (6753:9): [True: 0, False: 3.59k]
  ------------------
 6754|      0|      return NULL;
 6755|      0|    }
 6756|  3.59k|  }
 6757|  5.80M|  else if (fit_thread_context(cache->serial, context) < 0) {
  ------------------
  |  Branch (6757:12): [True: 0, False: 5.80M]
  ------------------
 6758|      0|    return NULL;
 6759|      0|  }
 6760|  5.81M|  cache->serial_busy = true;
 6761|  5.81M|  return cache->serial;
 6762|       |#else
 6763|       |  BLOSC_UNUSED_PARAM(context);
 6764|       |  return NULL;
 6765|       |#endif
 6766|  5.81M|}
blosc2.c:create_thread_context:
 2616|  3.79k|create_thread_context(blosc2_context* context, int32_t tid) {
 2617|  3.79k|  struct thread_context* thread_context;
 2618|  3.79k|  thread_context = (struct thread_context*)my_malloc(sizeof(struct thread_context));
 2619|  3.79k|  BLOSC_ERROR_NULL(thread_context, NULL);
  ------------------
  |  |  104|  3.79k|    do {                                            \
  |  |  105|  3.79k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 3.79k]
  |  |  ------------------
  |  |  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.79k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 3.79k]
  |  |  ------------------
  ------------------
 2620|  3.79k|  int rc = init_thread_context(thread_context, context, tid);
 2621|  3.79k|  if (rc < 0) {
  ------------------
  |  Branch (2621:7): [True: 0, False: 3.79k]
  ------------------
 2622|      0|    my_free(thread_context);
 2623|      0|    return NULL;
 2624|      0|  }
 2625|  3.79k|  return thread_context;
 2626|  3.79k|}
blosc2.c:init_thread_context:
 2584|  4.13k|{
 2585|  4.13k|  int32_t ebsize;
 2586|       |
 2587|  4.13k|  thread_context->parent_context = context;
 2588|  4.13k|  thread_context->owner_pool = NULL;
 2589|  4.13k|  thread_context->tid = tid;
 2590|  4.13k|  thread_context->serial = false;
 2591|  4.13k|  thread_context->blosclz_state = NULL;
 2592|       |
 2593|  4.13k|  int32_t blocksize = context != NULL ? context->blocksize : 0;
  ------------------
  |  Branch (2593:23): [True: 3.79k, False: 336]
  ------------------
 2594|  4.13k|  int32_t typesize = context != NULL ? context->typesize : 0;
  ------------------
  |  Branch (2594:22): [True: 3.79k, False: 336]
  ------------------
 2595|  4.13k|  ebsize = blocksize + typesize * (signed)sizeof(int32_t);
 2596|  4.13k|  thread_context->tmp_nbytes = (size_t)4 * ebsize;
 2597|  4.13k|  thread_context->tmp = my_malloc(thread_context->tmp_nbytes);
 2598|  4.13k|  BLOSC_ERROR_NULL(thread_context->tmp, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  4.13k|    do {                                            \
  |  |  105|  4.13k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 4.13k]
  |  |  ------------------
  |  |  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.13k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 4.13k]
  |  |  ------------------
  ------------------
 2599|  4.13k|  thread_context->tmp2 = thread_context->tmp + ebsize;
 2600|  4.13k|  thread_context->tmp3 = thread_context->tmp2 + ebsize;
 2601|  4.13k|  thread_context->tmp4 = thread_context->tmp3 + ebsize;
 2602|  4.13k|  thread_context->tmp_blocksize = blocksize;
 2603|  4.13k|  thread_context->zfp_cell_nitems = 0;
 2604|  4.13k|  thread_context->zfp_cell_start = 0;
 2605|  4.13k|  #if defined(HAVE_ZSTD)
 2606|  4.13k|  thread_context->zstd_cctx = NULL;
 2607|  4.13k|  thread_context->zstd_dctx = NULL;
 2608|  4.13k|  #endif
 2609|  4.13k|  thread_context->lz4_cstream = NULL;
 2610|  4.13k|  thread_context->lz4hc_cstream = NULL;
 2611|       |
 2612|  4.13k|  return 0;
 2613|  4.13k|}
blosc2.c:blosc_d:
 2062|  12.5M|    int32_t nblock, uint8_t* dest, int32_t dest_offset, uint8_t* tmp, uint8_t* tmp2) {
 2063|  12.5M|  blosc2_context* context = thread_context->parent_context;
 2064|  12.5M|  uint8_t *tmp3 = thread_context->tmp4;
 2065|  12.5M|  bool vlblocks = (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) != 0;
 2066|  12.5M|  int32_t compformat = (context->header_flags & (uint8_t)0xe0) >> 5u;
 2067|  12.5M|  int dont_split = (context->header_flags & 0x10) >> 4;
 2068|  12.5M|  int32_t chunk_nbytes;
 2069|  12.5M|  int32_t chunk_cbytes;
 2070|  12.5M|  int nstreams;
 2071|  12.5M|  int32_t neblock;
 2072|  12.5M|  int32_t nbytes;                /* number of decompressed bytes in split */
 2073|  12.5M|  int32_t cbytes;                /* number of compressed bytes in split */
 2074|       |  // int32_t ctbytes = 0;           /* number of compressed bytes in block */
 2075|  12.5M|  int32_t ntbytes = 0;           /* number of uncompressed bytes in block */
 2076|  12.5M|  uint8_t* _dest;
 2077|  12.5M|  int32_t typesize = context->typesize;
 2078|  12.5M|  bool instr_codec = context->blosc2_flags & BLOSC2_INSTR_CODEC;
 2079|  12.5M|  const char* compname;
 2080|  12.5M|  int rc;
 2081|       |
 2082|  12.5M|  if (context->block_maskout != NULL && context->block_maskout[nblock]) {
  ------------------
  |  Branch (2082:7): [True: 2.84M, False: 9.71M]
  |  Branch (2082:41): [True: 1.98M, False: 863k]
  ------------------
 2083|       |    // Do not decompress, but act as if we successfully decompressed everything
 2084|  1.98M|    return bsize;
 2085|  1.98M|  }
 2086|       |
 2087|  10.5M|  rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 2088|  10.5M|  if (rc < 0) {
  ------------------
  |  Branch (2088:7): [True: 0, False: 10.5M]
  ------------------
 2089|      0|    return rc;
 2090|      0|  }
 2091|  10.5M|  if (context->special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (2091:7): [True: 2.40M, False: 8.17M]
  ------------------
 2092|       |    // We need the actual typesize in this case, but it cannot be encoded in the header, so derive it from cbytes
 2093|  2.40M|    typesize = chunk_cbytes - context->header_overhead;
 2094|  2.40M|  }
 2095|       |
 2096|       |  // In some situations (lazychunks) the context can arrive uninitialized
 2097|       |  // (but BITSHUFFLE needs it for accessing the format of the chunk)
 2098|  10.5M|  if (context->src == NULL) {
  ------------------
  |  Branch (2098:7): [True: 0, False: 10.5M]
  ------------------
 2099|      0|    context->src = src;
 2100|      0|  }
 2101|       |
 2102|       |  // Chunks with special values cannot be lazy
 2103|  10.5M|  bool is_lazy = ((context->header_overhead == BLOSC_EXTENDED_HEADER_LENGTH) &&
  ------------------
  |  Branch (2103:19): [True: 10.5M, False: 615]
  ------------------
 2104|  10.5M|          (context->blosc2_flags & 0x08u) && !context->special_type);
  ------------------
  |  Branch (2104:11): [True: 1.11M, False: 9.46M]
  |  Branch (2104:46): [True: 1, False: 1.11M]
  ------------------
 2105|  10.5M|  if (is_lazy) {
  ------------------
  |  Branch (2105:7): [True: 1, False: 10.5M]
  ------------------
 2106|       |    // The chunk is on disk, so just lazily load the block
 2107|      1|    if (context->schunk == NULL) {
  ------------------
  |  Branch (2107:9): [True: 1, False: 0]
  ------------------
 2108|      1|      BLOSC_TRACE_ERROR("Lazy chunk needs an associated super-chunk.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2109|      1|      return BLOSC2_ERROR_INVALID_PARAM;
 2110|      1|    }
 2111|      0|    if (context->schunk->frame == NULL) {
  ------------------
  |  Branch (2111:9): [True: 0, False: 0]
  ------------------
 2112|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2113|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 2114|      0|    }
 2115|      0|    blosc2_frame_s* frame = (blosc2_frame_s*)context->schunk->frame;
 2116|      0|    size_t bstarts_nbytes;
 2117|      0|    size_t trailer_offset;
 2118|      0|    size_t block_csizes_nbytes;
 2119|      0|    size_t trailer_meta_nbytes;
 2120|      0|    size_t lazy_trailer_end;
 2121|      0|    if (srcsize < 0 || context->nblocks < 0 ||
  ------------------
  |  Branch (2121:9): [True: 0, False: 0]
  |  Branch (2121:24): [True: 0, False: 0]
  ------------------
 2122|      0|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &bstarts_nbytes) ||
  ------------------
  |  Branch (2122:9): [True: 0, False: 0]
  ------------------
 2123|      0|        !blosc2_checked_add_size((size_t)BLOSC_EXTENDED_HEADER_LENGTH, bstarts_nbytes, &trailer_offset) ||
  ------------------
  |  Branch (2123:9): [True: 0, False: 0]
  ------------------
 2124|      0|        !blosc2_checked_mul_size((size_t)context->nblocks, sizeof(int32_t), &block_csizes_nbytes) ||
  ------------------
  |  Branch (2124:9): [True: 0, False: 0]
  ------------------
 2125|      0|        !blosc2_checked_add_size(sizeof(int32_t) + sizeof(int64_t), block_csizes_nbytes, &trailer_meta_nbytes) ||
  ------------------
  |  Branch (2125:9): [True: 0, False: 0]
  ------------------
 2126|      0|        !blosc2_checked_add_size(trailer_offset, trailer_meta_nbytes, &lazy_trailer_end) ||
  ------------------
  |  Branch (2126:9): [True: 0, False: 0]
  ------------------
 2127|      0|        (size_t)srcsize < lazy_trailer_end) {
  ------------------
  |  Branch (2127:9): [True: 0, False: 0]
  ------------------
 2128|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2129|      0|      return BLOSC2_ERROR_READ_BUFFER;
 2130|      0|    }
 2131|      0|    int32_t nchunk;
 2132|      0|    int64_t chunk_offset;
 2133|       |    // The nchunk and the offset of the current chunk are in the trailer
 2134|      0|    memcpy(&nchunk, src + trailer_offset, sizeof(nchunk));
 2135|      0|    memcpy(&chunk_offset, src + trailer_offset + sizeof(int32_t), sizeof(chunk_offset));
 2136|       |    // Get the csize of the nblock
 2137|      0|    if (nblock < 0 || nblock >= context->nblocks) {
  ------------------
  |  Branch (2137:9): [True: 0, False: 0]
  |  Branch (2137:23): [True: 0, False: 0]
  ------------------
 2138|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2139|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2140|      0|    }
 2141|      0|    int32_t *block_csizes = (int32_t *)(src + trailer_offset + sizeof(int32_t) + sizeof(int64_t));
 2142|      0|    int32_t block_csize = block_csizes[nblock];
 2143|      0|    int32_t max_lazy_block_csize = context->blocksize + context->typesize * (signed)sizeof(int32_t);
 2144|      0|    if (block_csize <= 0 || block_csize > max_lazy_block_csize) {
  ------------------
  |  Branch (2144:9): [True: 0, False: 0]
  |  Branch (2144:29): [True: 0, False: 0]
  ------------------
 2145|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2147|      0|    }
 2148|      0|    if (vlblocks && block_csize <= (int32_t)sizeof(int32_t)) {
  ------------------
  |  Branch (2148:9): [True: 0, False: 0]
  |  Branch (2148:21): [True: 0, False: 0]
  ------------------
 2149|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2150|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 2151|      0|    }
 2152|       |    // Read the lazy block on disk
 2153|      0|    void* fp = NULL;
 2154|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(context->schunk->storage->io->id);
 2155|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (2155:9): [True: 0, False: 0]
  ------------------
 2156|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2157|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 2158|      0|    }
 2159|       |
 2160|      0|    int64_t io_pos = 0;
 2161|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2161:9): [True: 0, False: 0]
  ------------------
 2162|       |      // The chunk is not in the frame
 2163|      0|      fp = sframe_open_chunk(frame->urlpath, nchunk, "rb", context->schunk->storage->io);
 2164|      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]
  |  |  ------------------
  ------------------
 2165|       |      // The offset of the block is src_offset
 2166|      0|      if (src_offset < 0) {
  ------------------
  |  Branch (2166:11): [True: 0, False: 0]
  ------------------
 2167|      0|        frame_reader_release(frame, io_cb, fp);
 2168|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2169|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2170|      0|      }
 2171|      0|      io_pos = src_offset;
 2172|      0|    }
 2173|      0|    else {
 2174|      0|      fp = frame_reader_acquire(frame, context->schunk->storage->io);
 2175|      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]
  |  |  ------------------
  ------------------
 2176|       |      // The offset of the block is src_offset
 2177|      0|      if (src_offset < 0) {
  ------------------
  |  Branch (2177:11): [True: 0, False: 0]
  ------------------
 2178|      0|        frame_reader_release(frame, io_cb, fp);
 2179|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2180|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2181|      0|      }
 2182|      0|      if (chunk_offset < 0) {
  ------------------
  |  Branch (2182:11): [True: 0, False: 0]
  ------------------
 2183|      0|        frame_reader_release(frame, io_cb, fp);
 2184|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2185|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2186|      0|      }
 2187|      0|      if (!blosc2_checked_add_i64(frame->file_offset, chunk_offset, &io_pos)) {
  ------------------
  |  Branch (2187:11): [True: 0, False: 0]
  ------------------
 2188|      0|        frame_reader_release(frame, io_cb, fp);
 2189|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2190|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2191|      0|      }
 2192|      0|      if (!blosc2_checked_add_i64(io_pos, src_offset, &io_pos)) {
  ------------------
  |  Branch (2192:11): [True: 0, False: 0]
  ------------------
 2193|      0|        frame_reader_release(frame, io_cb, fp);
 2194|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2195|      0|        return BLOSC2_ERROR_INVALID_HEADER;
 2196|      0|      }
 2197|      0|    }
 2198|       |    // We can make use of tmp3 because it will be used after src is not needed anymore
 2199|      0|    int64_t rbytes = io_cb->read((void**)&tmp3, 1, block_csize, io_pos, fp);
 2200|      0|    frame_reader_release(frame, io_cb, fp);
 2201|      0|    if ((int32_t)rbytes != block_csize) {
  ------------------
  |  Branch (2201:9): [True: 0, False: 0]
  ------------------
 2202|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2203|      0|      return BLOSC2_ERROR_READ_BUFFER;
 2204|      0|    }
 2205|      0|    src = tmp3;
 2206|      0|    src_offset = 0;
 2207|      0|    srcsize = block_csize;
 2208|      0|  }
 2209|       |
 2210|       |  // If the chunk is memcpyed, we just have to copy the block to dest and return
 2211|  10.5M|  if (memcpyed) {
  ------------------
  |  Branch (2211:7): [True: 5.34M, False: 5.23M]
  ------------------
 2212|  5.34M|    int bsize_ = leftoverblock ? chunk_nbytes % context->blocksize : bsize;
  ------------------
  |  Branch (2212:18): [True: 137, False: 5.34M]
  ------------------
 2213|  5.34M|    if (!context->special_type) {
  ------------------
  |  Branch (2213:9): [True: 1.05M, False: 4.28M]
  ------------------
 2214|  1.05M|      if (chunk_nbytes + context->header_overhead != chunk_cbytes) {
  ------------------
  |  Branch (2214:11): [True: 0, False: 1.05M]
  ------------------
 2215|      0|        return BLOSC2_ERROR_WRITE_BUFFER;
 2216|      0|      }
 2217|  1.05M|      if (chunk_cbytes < context->header_overhead + (nblock * context->blocksize) + bsize_) {
  ------------------
  |  Branch (2217:11): [True: 0, False: 1.05M]
  ------------------
 2218|       |        /* Not enough input to copy block */
 2219|      0|        return BLOSC2_ERROR_READ_BUFFER;
 2220|      0|      }
 2221|  1.05M|    }
 2222|  5.34M|    if (!is_lazy) {
  ------------------
  |  Branch (2222:9): [True: 5.34M, False: 0]
  ------------------
 2223|  5.34M|      src += context->header_overhead + nblock * context->blocksize;
 2224|  5.34M|    }
 2225|  5.34M|    _dest = dest + dest_offset;
 2226|  5.34M|    if (context->postfilter != NULL) {
  ------------------
  |  Branch (2226:9): [True: 577k, False: 4.76M]
  ------------------
 2227|       |      // We are making use of a postfilter, so use a temp for destination
 2228|   577k|      _dest = tmp;
 2229|   577k|    }
 2230|  5.34M|    rc = 0;
 2231|  5.34M|    switch (context->special_type) {
 2232|  2.40M|      case BLOSC2_SPECIAL_VALUE:
  ------------------
  |  Branch (2232:7): [True: 2.40M, False: 2.93M]
  ------------------
 2233|       |        // All repeated values
 2234|  2.40M|        rc = set_values(typesize, context->src, _dest, bsize_);
 2235|  2.40M|        if (rc < 0) {
  ------------------
  |  Branch (2235:13): [True: 1, False: 2.40M]
  ------------------
 2236|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2237|      1|          return BLOSC2_ERROR_DATA;
 2238|      1|        }
 2239|  2.40M|        break;
 2240|  2.40M|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (2240:7): [True: 1.60M, False: 3.73M]
  ------------------
 2241|  1.60M|        rc = set_nans(context->typesize, _dest, bsize_);
 2242|  1.60M|        if (rc < 0) {
  ------------------
  |  Branch (2242:13): [True: 5, False: 1.60M]
  ------------------
 2243|      5|          BLOSC_TRACE_ERROR("set_nans failed");
  ------------------
  |  |   93|      5|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      5|    do {                                            \
  |  |  |  |   98|      5|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      5|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      5|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2244|      5|          return BLOSC2_ERROR_DATA;
 2245|      5|        }
 2246|  1.60M|        break;
 2247|  1.60M|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (2247:7): [True: 273k, False: 5.06M]
  ------------------
 2248|   273k|        memset(_dest, 0, bsize_);
 2249|   273k|        break;
 2250|    317|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (2250:7): [True: 317, False: 5.34M]
  ------------------
 2251|       |        // We do nothing here
 2252|    317|        break;
 2253|  1.05M|      default:
  ------------------
  |  Branch (2253:7): [True: 1.05M, False: 4.28M]
  ------------------
 2254|  1.05M|        memcpy(_dest, src, bsize_);
 2255|  5.34M|    }
 2256|  5.34M|    if (context->postfilter != NULL) {
  ------------------
  |  Branch (2256:9): [True: 577k, False: 4.76M]
  ------------------
 2257|       |      // Create new postfilter parameters for this block (must be private for each thread)
 2258|   577k|      blosc2_postfilter_params postparams;
 2259|   577k|      memcpy(&postparams, context->postparams, sizeof(postparams));
 2260|   577k|      postparams.input = tmp;
 2261|   577k|      postparams.output = dest + dest_offset;
 2262|   577k|      postparams.size = bsize;
 2263|   577k|      postparams.typesize = typesize;
 2264|   577k|      postparams.offset = nblock * context->blocksize;
 2265|   577k|      postparams.nchunk = context->schunk != NULL ? context->schunk->current_nchunk : -1;
  ------------------
  |  Branch (2265:27): [True: 577k, False: 0]
  ------------------
 2266|   577k|      postparams.nblock = nblock;
 2267|   577k|      postparams.tid = thread_context->tid;
 2268|   577k|      postparams.ttmp = thread_context->tmp;
 2269|   577k|      postparams.ttmp_nbytes = thread_context->tmp_nbytes;
 2270|   577k|      postparams.ctx = context;
 2271|       |
 2272|       |      // Execute the postfilter (the processed block will be copied to dest)
 2273|   577k|      if (context->postfilter(&postparams) != 0) {
  ------------------
  |  Branch (2273:11): [True: 0, False: 577k]
  ------------------
 2274|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2275|      0|        return BLOSC2_ERROR_POSTFILTER;
 2276|      0|      }
 2277|   577k|    }
 2278|  5.34M|    thread_context->zfp_cell_nitems = 0;
 2279|       |
 2280|  5.34M|    return bsize_;
 2281|  5.34M|  }
 2282|       |
 2283|  5.23M|  if (!is_lazy && (src_offset <= 0 || src_offset >= srcsize)) {
  ------------------
  |  Branch (2283:7): [True: 5.23M, False: 0]
  |  Branch (2283:20): [True: 93, False: 5.23M]
  |  Branch (2283:39): [True: 58, False: 5.23M]
  ------------------
 2284|       |    /* Invalid block src offset encountered */
 2285|    151|    return BLOSC2_ERROR_DATA;
 2286|    151|  }
 2287|       |
 2288|  5.23M|  src += src_offset;
 2289|  5.23M|  if (vlblocks) {
  ------------------
  |  Branch (2289:7): [True: 2, False: 5.23M]
  ------------------
 2290|      2|    if (context->blockcbytes == NULL || nblock >= context->nblocks ||
  ------------------
  |  Branch (2290:9): [True: 0, False: 2]
  |  Branch (2290:41): [True: 0, False: 2]
  ------------------
 2291|      2|        context->blockcbytes[nblock] <= (int32_t)sizeof(int32_t) ||
  ------------------
  |  Branch (2291:9): [True: 1, False: 1]
  ------------------
 2292|      1|        src_offset > srcsize - context->blockcbytes[nblock]) {
  ------------------
  |  Branch (2292:9): [True: 0, False: 1]
  ------------------
 2293|      1|      return BLOSC2_ERROR_DATA;
 2294|      1|    }
 2295|      1|    srcsize = context->blockcbytes[nblock];
 2296|      1|  }
 2297|  5.23M|  else {
 2298|  5.23M|    srcsize -= src_offset;
 2299|  5.23M|  }
 2300|       |
 2301|  5.23M|  int last_filter_index = last_filter(context, 'd');
 2302|  5.23M|  if (instr_codec) {
  ------------------
  |  Branch (2302:7): [True: 41, False: 5.23M]
  ------------------
 2303|       |    // If instrumented, we don't want to run the filters
 2304|     41|    _dest = dest + dest_offset;
 2305|     41|  }
 2306|  5.23M|  else if (((last_filter_index >= 0) &&
  ------------------
  |  Branch (2306:13): [True: 5.08M, False: 157k]
  ------------------
 2307|  5.08M|       (next_filter(context, BLOSC2_MAX_FILTERS, 'd') != BLOSC_DELTA)) ||
  ------------------
  |  Branch (2307:8): [True: 5.08M, False: 152]
  ------------------
 2308|  5.22M|    context->postfilter != NULL) {
  ------------------
  |  Branch (2308:5): [True: 148k, False: 9.19k]
  ------------------
 2309|       |    // We are making use of some filter, so use a temp for destination
 2310|  5.22M|    _dest = tmp;
 2311|  5.22M|  }
 2312|  9.19k|  else {
 2313|       |    // If no filters, or only DELTA in pipeline
 2314|  9.19k|    _dest = dest + dest_offset;
 2315|  9.19k|  }
 2316|       |
 2317|       |  /* The number of compressed data streams for this block */
 2318|  5.23M|  if (vlblocks) {
  ------------------
  |  Branch (2318:7): [True: 1, False: 5.23M]
  ------------------
 2319|      1|    nstreams = 1;
 2320|      1|  }
 2321|  5.23M|  else if (!dont_split && !leftoverblock) {
  ------------------
  |  Branch (2321:12): [True: 181k, False: 5.05M]
  |  Branch (2321:27): [True: 181k, False: 5]
  ------------------
 2322|   181k|    nstreams = context->typesize;
 2323|   181k|  }
 2324|  5.05M|  else {
 2325|  5.05M|    nstreams = 1;
 2326|  5.05M|  }
 2327|       |
 2328|  5.23M|  neblock = bsize / nstreams;
 2329|  5.23M|  if (neblock == 0) {
  ------------------
  |  Branch (2329:7): [True: 1, False: 5.23M]
  ------------------
 2330|       |    /* Not enough space to output bytes */
 2331|      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]
  |  |  ------------------
  ------------------
 2332|      1|  }
 2333|       |  /* The splits must cover the whole block, or part of tmp is left unwritten */
 2334|  5.23M|  if (neblock * nstreams != bsize) {
  ------------------
  |  Branch (2334:7): [True: 3, False: 5.23M]
  ------------------
 2335|      3|    BLOSC_ERROR(BLOSC2_ERROR_DATA);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2336|      3|  }
 2337|  10.7M|  for (int j = 0; j < nstreams; j++) {
  ------------------
  |  Branch (2337:19): [True: 5.49M, False: 5.23M]
  ------------------
 2338|  5.49M|    if (vlblocks) {
  ------------------
  |  Branch (2338:9): [True: 1, False: 5.49M]
  ------------------
 2339|      1|      if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (2339:11): [True: 0, False: 1]
  ------------------
 2340|       |        /* Not enough input to read compressed bytes */
 2341|      0|        return BLOSC2_ERROR_READ_BUFFER;
 2342|      0|      }
 2343|      1|      neblock = sw32_(src);
 2344|      1|      if (neblock != bsize) {
  ------------------
  |  Branch (2344:11): [True: 0, False: 1]
  ------------------
 2345|      0|        return BLOSC2_ERROR_DATA;
 2346|      0|      }
 2347|      1|      src += sizeof(int32_t);
 2348|      1|      cbytes = srcsize - (int32_t)sizeof(int32_t);
 2349|      1|      srcsize = 0;
 2350|      1|    }
 2351|  5.49M|    else {
 2352|  5.49M|      if (srcsize < (signed)sizeof(int32_t)) {
  ------------------
  |  Branch (2352:11): [True: 1, False: 5.49M]
  ------------------
 2353|       |        /* Not enough input to read compressed size */
 2354|      1|        return BLOSC2_ERROR_READ_BUFFER;
 2355|      1|      }
 2356|  5.49M|      srcsize -= sizeof(int32_t);
 2357|  5.49M|      cbytes = sw32_(src);      /* amount of compressed bytes */
 2358|  5.49M|      if (cbytes > 0) {
  ------------------
  |  Branch (2358:11): [True: 5.15M, False: 344k]
  ------------------
 2359|  5.15M|        if (srcsize < cbytes) {
  ------------------
  |  Branch (2359:13): [True: 22, False: 5.15M]
  ------------------
 2360|       |          /* Not enough input to read compressed bytes */
 2361|     22|          return BLOSC2_ERROR_READ_BUFFER;
 2362|     22|        }
 2363|  5.15M|        srcsize -= cbytes;
 2364|  5.15M|      }
 2365|  5.49M|      src += sizeof(int32_t);
 2366|  5.49M|    }
 2367|       |    // ctbytes += (signed)sizeof(int32_t);
 2368|       |
 2369|       |    /* Uncompress */
 2370|  5.49M|    if (!vlblocks && cbytes == 0) {
  ------------------
  |  Branch (2370:9): [True: 5.49M, False: 1]
  |  Branch (2370:22): [True: 201k, False: 5.29M]
  ------------------
 2371|       |      // A run of 0's
 2372|   201k|      memset(_dest, 0, (unsigned int)neblock);
 2373|   201k|      nbytes = neblock;
 2374|   201k|    }
 2375|  5.29M|    else if (!vlblocks && cbytes < 0) {
  ------------------
  |  Branch (2375:14): [True: 5.29M, False: 1]
  |  Branch (2375:27): [True: 143k, False: 5.15M]
  ------------------
 2376|       |      // A negative number means some encoding depending on the token that comes next
 2377|   143k|      uint8_t token;
 2378|       |
 2379|   143k|      if (srcsize < (signed)sizeof(uint8_t)) {
  ------------------
  |  Branch (2379:11): [True: 1, False: 143k]
  ------------------
 2380|       |        // Not enough input to read token */
 2381|      1|        return BLOSC2_ERROR_READ_BUFFER;
 2382|      1|      }
 2383|   143k|      srcsize -= sizeof(uint8_t);
 2384|       |
 2385|   143k|      token = src[0];
 2386|   143k|      src += 1;
 2387|       |      // ctbytes += 1;
 2388|       |
 2389|   143k|      if (token & 0x1) {
  ------------------
  |  Branch (2389:11): [True: 143k, False: 7]
  ------------------
 2390|       |        // A run of bytes that are different than 0
 2391|   143k|        if (cbytes < -255) {
  ------------------
  |  Branch (2391:13): [True: 28, False: 143k]
  ------------------
 2392|       |          // Runs can only encode a byte
 2393|     28|          return BLOSC2_ERROR_RUN_LENGTH;
 2394|     28|        }
 2395|   143k|        uint8_t value = -cbytes;
 2396|   143k|        memset(_dest, value, (unsigned int)neblock);
 2397|   143k|      } else {
 2398|      7|        BLOSC_TRACE_ERROR("Invalid or unsupported compressed stream token value - %d", token);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2399|      7|        return BLOSC2_ERROR_RUN_LENGTH;
 2400|      7|      }
 2401|   143k|      nbytes = neblock;
 2402|   143k|      cbytes = 0;  // everything is encoded in the cbytes token
 2403|   143k|    }
 2404|  5.15M|    else if (cbytes == neblock) {
  ------------------
  |  Branch (2404:14): [True: 89.2k, False: 5.06M]
  ------------------
 2405|  89.2k|      memcpy(_dest, src, (unsigned int)neblock);
 2406|  89.2k|      nbytes = (int32_t)neblock;
 2407|  89.2k|    }
 2408|  5.06M|    else {
 2409|  5.06M|      if (compformat == BLOSC_BLOSCLZ_FORMAT) {
  ------------------
  |  Branch (2409:11): [True: 5.06M, False: 409]
  ------------------
 2410|  5.06M|        nbytes = blosclz_decompress(src, cbytes, _dest, (int)neblock);
 2411|  5.06M|      }
 2412|    409|      else if (compformat == BLOSC_LZ4_FORMAT) {
  ------------------
  |  Branch (2412:16): [True: 290, False: 119]
  ------------------
 2413|    290|        nbytes = lz4_wrap_decompress((char*)src, (size_t)cbytes,
 2414|    290|                                     (char*)_dest, (size_t)neblock,
 2415|    290|                                     thread_context);
 2416|    290|      }
 2417|    119|  #if defined(HAVE_ZLIB)
 2418|    119|      else if (compformat == BLOSC_ZLIB_FORMAT) {
  ------------------
  |  Branch (2418:16): [True: 6, False: 113]
  ------------------
 2419|      6|        nbytes = zlib_wrap_decompress((char*)src, (size_t)cbytes,
 2420|      6|                                      (char*)_dest, (size_t)neblock);
 2421|      6|      }
 2422|    113|  #endif /*  HAVE_ZLIB */
 2423|    113|  #if defined(HAVE_ZSTD)
 2424|    113|      else if (compformat == BLOSC_ZSTD_FORMAT) {
  ------------------
  |  Branch (2424:16): [True: 15, False: 98]
  ------------------
 2425|     15|        nbytes = zstd_wrap_decompress(thread_context,
 2426|     15|                                      (char*)src, (size_t)cbytes,
 2427|     15|                                      (char*)_dest, (size_t)neblock);
 2428|     15|      }
 2429|     98|  #endif /*  HAVE_ZSTD */
 2430|     98|      else if (compformat == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (2430:16): [True: 97, False: 1]
  ------------------
 2431|     97|        bool getcell = false;
 2432|       |
 2433|     97|#if defined(HAVE_ZFP)
 2434|     97|        if ((context->compcode == BLOSC_CODEC_ZFP_FIXED_RATE) &&
  ------------------
  |  Branch (2434:13): [True: 1, False: 96]
  ------------------
 2435|      1|            (thread_context->zfp_cell_nitems > 0)) {
  ------------------
  |  Branch (2435:13): [True: 0, False: 1]
  ------------------
 2436|      0|          nbytes = zfp_getcell(thread_context, src, cbytes, _dest, neblock);
 2437|      0|          if (nbytes < 0) {
  ------------------
  |  Branch (2437:15): [True: 0, False: 0]
  ------------------
 2438|      0|            return BLOSC2_ERROR_DATA;
 2439|      0|          }
 2440|      0|          if (nbytes == thread_context->zfp_cell_nitems * typesize) {
  ------------------
  |  Branch (2440:15): [True: 0, False: 0]
  ------------------
 2441|      0|            getcell = true;
 2442|      0|          }
 2443|      0|        }
 2444|     97|#endif /* HAVE_ZFP */
 2445|     97|        if (!getcell) {
  ------------------
  |  Branch (2445:13): [True: 97, False: 0]
  ------------------
 2446|     97|          thread_context->zfp_cell_nitems = 0;
 2447|    179|          for (int i = 0; i < g_ncodecs; ++i) {
  ------------------
  |  Branch (2447:27): [True: 173, False: 6]
  ------------------
 2448|    173|            if (g_codecs[i].compcode == context->compcode) {
  ------------------
  |  Branch (2448:17): [True: 91, False: 82]
  ------------------
 2449|     91|              if (load_acquire_ptr(&g_codecs[i].decoder) == NULL) {
  ------------------
  |  |  144|     91|#define load_acquire_ptr(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2449:19): [True: 4, False: 87]
  ------------------
 2450|       |                // Dynamically load codec plugin
 2451|      4|                if (fill_codec(&g_codecs[i]) < 0) {
  ------------------
  |  Branch (2451:21): [True: 4, False: 0]
  ------------------
 2452|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2453|      4|                  return BLOSC2_ERROR_CODEC_SUPPORT;
 2454|      4|                }
 2455|      4|              }
 2456|     87|              blosc2_dparams dparams;
 2457|     87|              blosc2_ctx_get_dparams(context, &dparams);
 2458|     87|              nbytes = g_codecs[i].decoder(src,
 2459|     87|                                           cbytes,
 2460|     87|                                           _dest,
 2461|     87|                                           neblock,
 2462|     87|                                           context->compcode_meta,
 2463|     87|                                           &dparams,
 2464|     87|                                           context->src);
 2465|     87|              goto urcodecsuccess;
 2466|     91|            }
 2467|    173|          }
 2468|      6|          BLOSC_TRACE_ERROR("User-defined compressor codec %d not found during decompression", context->compcode);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2469|      6|          return BLOSC2_ERROR_CODEC_SUPPORT;
 2470|     97|        }
 2471|     87|      urcodecsuccess:
 2472|     87|        ;
 2473|     87|      }
 2474|      1|      else {
 2475|      1|        compname = clibcode_to_clibname(compformat);
 2476|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2477|      1|                "Blosc has not been compiled with decompression "
 2478|      1|                "support for '%s' format.  "
 2479|      1|                "Please recompile for adding this support.", compname);
 2480|      1|        return BLOSC2_ERROR_CODEC_SUPPORT;
 2481|      1|      }
 2482|       |
 2483|       |      /* Check that decompressed bytes number is correct */
 2484|  5.06M|      if ((nbytes != neblock) && (thread_context->zfp_cell_nitems == 0)) {
  ------------------
  |  Branch (2484:11): [True: 409, False: 5.06M]
  |  Branch (2484:34): [True: 409, False: 0]
  ------------------
 2485|    409|        return BLOSC2_ERROR_DATA;
 2486|    409|      }
 2487|       |
 2488|  5.06M|    }
 2489|  5.49M|    src += cbytes;
 2490|       |    // ctbytes += cbytes;
 2491|  5.49M|    _dest += nbytes;
 2492|  5.49M|    ntbytes += nbytes;
 2493|  5.49M|  } /* Closes j < nstreams */
 2494|       |
 2495|  5.23M|  if (!instr_codec) {
  ------------------
  |  Branch (2495:7): [True: 5.23M, False: 20]
  ------------------
 2496|  5.23M|    if (last_filter_index >= 0 || context->postfilter != NULL) {
  ------------------
  |  Branch (2496:9): [True: 5.08M, False: 157k]
  |  Branch (2496:35): [True: 148k, False: 9.03k]
  ------------------
 2497|       |      /* Apply regular filter pipeline */
 2498|  5.22M|      int errcode = pipeline_backward(thread_context, bsize, dest, dest_offset, tmp, tmp2, tmp3,
 2499|  5.22M|                                      last_filter_index, nblock);
 2500|  5.22M|      if (errcode < 0)
  ------------------
  |  Branch (2500:11): [True: 97, False: 5.22M]
  ------------------
 2501|     97|        return errcode;
 2502|  5.22M|    }
 2503|  5.23M|  }
 2504|       |
 2505|       |  /* Return the number of uncompressed bytes */
 2506|  5.23M|  return (int)ntbytes;
 2507|  5.23M|}
blosc2.c:lz4_wrap_decompress:
  641|    290|                               struct thread_context* thread_context) {
  642|    290|  int nbytes;
  643|    290|  blosc2_context* context = thread_context->parent_context;
  644|    290|  if (context->use_dict && context->dict_buffer != NULL && context->dict_size > 0) {
  ------------------
  |  Branch (644:7): [True: 151, False: 139]
  |  Branch (644:28): [True: 151, False: 0]
  |  Branch (644:60): [True: 151, False: 0]
  ------------------
  645|    151|    nbytes = LZ4_decompress_safe_usingDict(input, output,
  646|    151|                                           (int)compressed_length, (int)maxout,
  647|    151|                                           (const char*)context->dict_buffer,
  648|    151|                                           (int)context->dict_size);
  649|    151|  } else {
  650|    139|    nbytes = LZ4_decompress_safe(input, output, (int)compressed_length, (int)maxout);
  651|    139|  }
  652|    290|  if (nbytes != (int)maxout) {
  ------------------
  |  Branch (652:7): [True: 289, False: 1]
  ------------------
  653|    289|    return 0;
  654|    289|  }
  655|      1|  return (int)maxout;
  656|    290|}
blosc2.c:zlib_wrap_decompress:
  680|      6|                                char* output, size_t maxout) {
  681|      6|  int status;
  682|      6|#if defined(HAVE_ZLIB_NG) && ! defined(ZLIB_COMPAT)
  683|      6|  size_t ul = maxout;
  684|      6|  status = zng_uncompress(
  685|      6|      (uint8_t*)output, &ul, (uint8_t*)input, compressed_length);
  686|       |#else
  687|       |  uLongf ul = (uLongf)maxout;
  688|       |  status = uncompress(
  689|       |      (Bytef*)output, &ul, (Bytef*)input, (uLong)compressed_length);
  690|       |#endif
  691|      6|  if (status != Z_OK) {
  ------------------
  |  |  180|      6|#define Z_OK            0
  ------------------
  |  Branch (691:7): [True: 6, False: 0]
  ------------------
  692|      6|    return 0;
  693|      6|  }
  694|      0|  return (int)ul;
  695|      6|}
blosc2.c:zstd_wrap_decompress:
  732|     15|                                char* output, size_t maxout) {
  733|     15|  size_t code;
  734|     15|  blosc2_context* context = thread_context->parent_context;
  735|       |
  736|     15|  if (thread_context->zstd_dctx == NULL) {
  ------------------
  |  Branch (736:7): [True: 15, False: 0]
  ------------------
  737|     15|    thread_context->zstd_dctx = ZSTD_createDCtx();
  738|     15|  }
  739|       |
  740|     15|  if (context->use_dict) {
  ------------------
  |  Branch (740:7): [True: 7, False: 8]
  ------------------
  741|      7|    assert(context->dict_ddict != NULL);
  742|      7|    code = ZSTD_decompress_usingDDict(
  743|      7|            thread_context->zstd_dctx, (void*)output, maxout, (void*)input,
  744|      7|            compressed_length, context->dict_ddict);
  745|      8|  } else {
  746|      8|    code = ZSTD_decompressDCtx(thread_context->zstd_dctx,
  747|      8|        (void*)output, maxout, (void*)input, compressed_length);
  748|      8|  }
  749|     15|  if (ZSTD_isError(code) != ZSTD_error_no_error) {
  ------------------
  |  Branch (749:7): [True: 15, False: 0]
  ------------------
  750|     15|    BLOSC_TRACE_ERROR("Error in ZSTD decompression: '%s'.  Giving up.",
  ------------------
  |  |   93|     15|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     15|    do {                                            \
  |  |  |  |   98|     15|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     15|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     15|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  751|     15|                      ZDICT_getErrorName(code));
  752|     15|    return 0;
  753|     15|  }
  754|      0|  return (int)code;
  755|     15|}
blosc2.c:set_values:
 1993|  2.51M|static int32_t set_values(int32_t typesize, const uint8_t* src, uint8_t* dest, int32_t destsize) {
 1994|       |#if defined(BLOSC_STRICT_ALIGN)
 1995|       |  if (destsize % typesize != 0) {
 1996|       |    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
 1997|       |  }
 1998|       |  int32_t nitems = destsize / typesize;
 1999|       |  if (nitems == 0) {
 2000|       |    return 0;
 2001|       |  }
 2002|       |  for (int i = 0; i < nitems; i++) {
 2003|       |    memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
 2004|       |  }
 2005|       |#else
 2006|  2.51M|  if (destsize % typesize != 0) {
  ------------------
  |  Branch (2006:7): [True: 2, False: 2.51M]
  ------------------
 2007|      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]
  |  |  ------------------
  ------------------
 2008|      2|  }
 2009|  2.51M|  int32_t nitems = destsize / typesize;
 2010|  2.51M|  if (nitems == 0) {
  ------------------
  |  Branch (2010:7): [True: 0, False: 2.51M]
  ------------------
 2011|      0|    return 0;
 2012|      0|  }
 2013|       |
 2014|  2.51M|  switch (typesize) {
 2015|  1.22M|    case 8: {
  ------------------
  |  Branch (2015:5): [True: 1.22M, False: 1.28M]
  ------------------
 2016|  1.22M|      int64_t val8 = ((int64_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2017|  1.22M|      int64_t* dest8 = (int64_t*)dest;
 2018|   942M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2018:23): [True: 941M, False: 1.22M]
  ------------------
 2019|   941M|        dest8[i] = val8;
 2020|   941M|      }
 2021|  1.22M|      break;
 2022|      0|    }
 2023|   379k|    case 4: {
  ------------------
  |  Branch (2023:5): [True: 379k, False: 2.13M]
  ------------------
 2024|   379k|      int32_t val4 = ((int32_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2025|   379k|      int32_t* dest4 = (int32_t*)dest;
 2026|  1.86G|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2026:23): [True: 1.86G, False: 379k]
  ------------------
 2027|  1.86G|        dest4[i] = val4;
 2028|  1.86G|      }
 2029|   379k|      break;
 2030|      0|    }
 2031|   112k|    case 2: {
  ------------------
  |  Branch (2031:5): [True: 112k, False: 2.39M]
  ------------------
 2032|   112k|      int16_t val2 = ((int16_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2033|   112k|      int16_t* dest2 = (int16_t*)dest;
 2034|   115M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2034:23): [True: 115M, False: 112k]
  ------------------
 2035|   115M|        dest2[i] = val2;
 2036|   115M|      }
 2037|   112k|      break;
 2038|      0|    }
 2039|   285k|    case 1: {
  ------------------
  |  Branch (2039:5): [True: 285k, False: 2.22M]
  ------------------
 2040|   285k|      int8_t val1 = ((int8_t*)(src + BLOSC_EXTENDED_HEADER_LENGTH))[0];
 2041|   285k|      int8_t* dest1 = (int8_t*)dest;
 2042|   515M|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2042:23): [True: 515M, False: 285k]
  ------------------
 2043|   515M|        dest1[i] = val1;
 2044|   515M|      }
 2045|   285k|      break;
 2046|      0|    }
 2047|   507k|    default:
  ------------------
  |  Branch (2047:5): [True: 507k, False: 2.00M]
  ------------------
 2048|  2.55G|      for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (2048:23): [True: 2.55G, False: 507k]
  ------------------
 2049|  2.55G|        memcpy(dest + i * typesize, src + BLOSC_EXTENDED_HEADER_LENGTH, typesize);
 2050|  2.55G|      }
 2051|  2.51M|  }
 2052|  2.51M|#endif
 2053|       |
 2054|  2.51M|  return nitems;
 2055|  2.51M|}
blosc2.c:set_nans:
 1961|  1.60M|static int32_t set_nans(int32_t typesize, uint8_t* dest, int32_t destsize) {
 1962|  1.60M|  if (destsize % typesize != 0) {
  ------------------
  |  Branch (1962:7): [True: 4, False: 1.60M]
  ------------------
 1963|      4|    BLOSC_TRACE_ERROR("destsize can only be a multiple of typesize");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1964|      4|    BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      4|    do {                                            \
  |  |  112|      4|        int rc_ = (rc);                             \
  |  |  113|      4|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 4, False: 0]
  |  |  ------------------
  |  |  114|      4|            char *error_msg = print_error(rc_);     \
  |  |  115|      4|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      4|            return rc_;                             \
  |  |  117|      4|        }                                           \
  |  |  118|      4|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1965|      4|  }
 1966|  1.60M|  int32_t nitems = destsize / typesize;
 1967|  1.60M|  if (nitems == 0) {
  ------------------
  |  Branch (1967:7): [True: 0, False: 1.60M]
  ------------------
 1968|      0|    return 0;
 1969|      0|  }
 1970|       |
 1971|  1.60M|  if (typesize == 4) {
  ------------------
  |  Branch (1971:7): [True: 1.12M, False: 480k]
  ------------------
 1972|  1.12M|    float* dest_ = (float*)dest;
 1973|  1.12M|    float val = nanf("");
 1974|   805M|    for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (1974:21): [True: 803M, False: 1.12M]
  ------------------
 1975|   803M|      dest_[i] = val;
 1976|   803M|    }
 1977|  1.12M|    return nitems;
 1978|  1.12M|  }
 1979|   480k|  else if (typesize == 8) {
  ------------------
  |  Branch (1979:12): [True: 480k, False: 1]
  ------------------
 1980|   480k|    double* dest_ = (double*)dest;
 1981|   480k|    double val = nan("");
 1982|   155M|    for (int i = 0; i < nitems; i++) {
  ------------------
  |  Branch (1982:21): [True: 155M, False: 480k]
  ------------------
 1983|   155M|      dest_[i] = val;
 1984|   155M|    }
 1985|   480k|    return nitems;
 1986|   480k|  }
 1987|       |
 1988|      1|  BLOSC_TRACE_ERROR("Unsupported typesize for NaN");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1989|      1|  return BLOSC2_ERROR_DATA;
 1990|  1.60M|}
blosc2.c:getitem_read_header:
 5115|  2.96M|static int getitem_read_header(const void* src, int32_t srcsize, blosc_header* header) {
 5116|  2.96M|  int result = read_chunk_header((uint8_t *) src, srcsize, true, header);
 5117|  2.96M|  if (result < 0) {
  ------------------
  |  Branch (5117:7): [True: 0, False: 2.96M]
  ------------------
 5118|      0|    return result;
 5119|      0|  }
 5120|  2.96M|  if (header->blosc2_flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (5120:7): [True: 0, False: 2.96M]
  ------------------
 5121|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5122|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 5123|      0|  }
 5124|  2.96M|  return 0;
 5125|  2.96M|}
blosc2.c:getitem_with_header:
 5131|  2.96M|                               int start, int nitems, void* dest, int32_t destsize) {
 5132|       |  /* Minimally populate the context */
 5133|  2.96M|  context->src = src;
 5134|  2.96M|  context->srcsize = srcsize;
 5135|  2.96M|  context->dest = dest;
 5136|  2.96M|  context->destsize = destsize;
 5137|       |
 5138|  2.96M|  int result = blosc2_initialize_context_from_header(context, header);
 5139|  2.96M|  if (result < 0) {
  ------------------
  |  Branch (5139:7): [True: 0, False: 2.96M]
  ------------------
 5140|      0|    return result;
 5141|      0|  }
 5142|       |
 5143|       |  /* Call the actual getitem function */
 5144|  2.96M|  return _blosc_getitem(context, header, src, srcsize, start, nitems, dest, destsize);
 5145|  2.96M|}
blosc2.c:blosc2_initialize_context_from_header:
 1032|  4.61M|static int blosc2_initialize_context_from_header(blosc2_context* context, blosc_header* header) {
 1033|  4.61M|  context->header_flags = header->flags;
 1034|  4.61M|  context->typesize = header->typesize;
 1035|  4.61M|  context->sourcesize = header->nbytes;
 1036|  4.61M|  context->header_blocksize = header->blocksize;
 1037|  4.61M|  context->blocksize = header->blocksize;
 1038|  4.61M|  context->blosc2_flags2 = header->blosc2_flags2;
 1039|  4.61M|  context->blosc2_flags = header->blosc2_flags;
 1040|  4.61M|  context->compcode = header->flags >> 5;
 1041|  4.61M|  if (context->compcode == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (1041:7): [True: 125, False: 4.61M]
  ------------------
 1042|    125|    context->compcode = header->udcompcode;
 1043|    125|  }
 1044|  4.61M|  if (context->blosc2_flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (1044:7): [True: 99, False: 4.61M]
  ------------------
 1045|     99|    context->nblocks = header->blocksize;
 1046|     99|    context->leftover = 0;
 1047|     99|    context->blocksize = 0;
 1048|     99|  }
 1049|  4.61M|  else {
 1050|  4.61M|    blosc2_calculate_blocks(context);
 1051|  4.61M|  }
 1052|       |
 1053|  4.61M|  bool is_lazy = false;
 1054|  4.61M|  if ((context->header_flags & BLOSC_DOSHUFFLE) &&
  ------------------
  |  Branch (1054:7): [True: 4.61M, False: 355]
  ------------------
 1055|  4.61M|      (context->header_flags & BLOSC_DOBITSHUFFLE)) {
  ------------------
  |  Branch (1055:7): [True: 4.61M, False: 30]
  ------------------
 1056|       |    /* Extended header */
 1057|  4.61M|    context->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 1058|       |
 1059|  4.61M|    memcpy(context->filters, header->filters, BLOSC2_MAX_FILTERS);
 1060|  4.61M|    memcpy(context->filters_meta, header->filters_meta, BLOSC2_MAX_FILTERS);
 1061|  4.61M|    context->compcode_meta = header->compcode_meta;
 1062|       |
 1063|  4.61M|    context->filter_flags = filters_to_flags(header->filters);
 1064|  4.61M|    context->special_type = (header->blosc2_flags >> 4) & BLOSC2_SPECIAL_MASK;
 1065|       |
 1066|       |    // Chunks with special values cannot be lazy (as in blosc_d()), and their
 1067|       |    // value is read from the buffer, so the cbytes check below must apply
 1068|  4.61M|    is_lazy = (context->blosc2_flags & 0x08u) && !context->special_type;
  ------------------
  |  Branch (1068:15): [True: 71, False: 4.61M]
  |  Branch (1068:50): [True: 34, False: 37]
  ------------------
 1069|  4.61M|  }
 1070|    385|  else {
 1071|    385|    context->header_overhead = BLOSC_MIN_HEADER_LENGTH;
 1072|    385|    context->filter_flags = get_filter_flags(context->header_flags, context->typesize);
 1073|    385|    flags_to_filters(context->header_flags, context->filters);
 1074|    385|  }
 1075|       |
 1076|       |  // Some checks for malformed headers
 1077|  4.61M|  if (!is_lazy && header->cbytes > context->srcsize) {
  ------------------
  |  Branch (1077:7): [True: 4.61M, False: 34]
  |  Branch (1077:19): [True: 0, False: 4.61M]
  ------------------
 1078|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1079|      0|  }
 1080|       |
 1081|  4.61M|  return 0;
 1082|  4.61M|}
blosc2.c:get_filter_flags:
  872|    385|                                const int32_t typesize) {
  873|    385|  uint8_t flags = 0;
  874|       |
  875|    385|  if ((header_flags & BLOSC_DOSHUFFLE) && (typesize > 1)) {
  ------------------
  |  Branch (875:7): [True: 30, False: 355]
  |  Branch (875:43): [True: 13, False: 17]
  ------------------
  876|     13|    flags |= BLOSC_DOSHUFFLE;
  877|     13|  }
  878|    385|  if (header_flags & BLOSC_DOBITSHUFFLE) {
  ------------------
  |  Branch (878:7): [True: 240, False: 145]
  ------------------
  879|    240|    flags |= BLOSC_DOBITSHUFFLE;
  880|    240|  }
  881|    385|  if (header_flags & BLOSC_DODELTA) {
  ------------------
  |  Branch (881:7): [True: 354, False: 31]
  ------------------
  882|    354|    flags |= BLOSC_DODELTA;
  883|    354|  }
  884|    385|  if (header_flags & BLOSC_MEMCPYED) {
  ------------------
  |  Branch (884:7): [True: 101, False: 284]
  ------------------
  885|    101|    flags |= BLOSC_MEMCPYED;
  886|    101|  }
  887|    385|  return flags;
  888|    385|}
blosc2.c:clear_context_decompression_dict:
 2989|  1.64M|static void clear_context_decompression_dict(blosc2_context* context) {
 2990|  1.64M|  context->use_dict = 0;
 2991|  1.64M|  release_context_dict_buffer(context);
 2992|  1.64M|#if defined(HAVE_ZSTD)
 2993|  1.64M|  if (context->dict_ddict != NULL) {
  ------------------
  |  Branch (2993:7): [True: 0, False: 1.64M]
  ------------------
 2994|      0|    ZSTD_freeDDict(context->dict_ddict);
 2995|      0|    context->dict_ddict = NULL;
 2996|      0|  }
 2997|       |#else
 2998|       |  context->dict_ddict = NULL;
 2999|       |#endif
 3000|  1.64M|}
blosc2.c:check_nthreads:
 2654|  3.84M|static int check_nthreads(blosc2_context* context, bool start_backend) {
 2655|  3.84M|  if (context->new_nthreads != context->nthreads && context->new_nthreads <= 0) {
  ------------------
  |  Branch (2655:7): [True: 18, False: 3.84M]
  |  Branch (2655:53): [True: 18, False: 0]
  ------------------
 2656|     18|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  ------------------
  |  |   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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2656|      0|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2657|     18|    return BLOSC2_ERROR_INVALID_PARAM;
 2658|     18|  }
 2659|  3.84M|  if (context->nthreads <= 0) {
  ------------------
  |  Branch (2659:7): [True: 0, False: 3.84M]
  ------------------
 2660|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2660|      0|    BLOSC_TRACE_ERROR("nthreads must be >= 1 and <= %d", INT16_MAX);
  |  |  |  |  ------------------
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2661|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2662|      0|  }
 2663|       |
 2664|       |  /* Detect a pool that was torn down by blosc2_destroy() while this context
 2665|       |   * was still alive, or that belongs to the parent of a forked process.  The
 2666|       |   * epoch mismatch tells us the pool pointer is dangling or has no threads;
 2667|       |   * clear it so the re-attach logic below creates a fresh one. */
 2668|  3.84M|  if (context->thread_backend == BLOSC_BACKEND_SHARED_POOL &&
  ------------------
  |  |   34|  7.68M|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
  |  Branch (2668:7): [True: 0, False: 3.84M]
  ------------------
 2669|      0|      context->pool_epoch != load_acquire_int(&g_destroy_count)) {
  ------------------
  |  |  142|      0|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (2669:7): [True: 0, False: 0]
  ------------------
 2670|      0|    context->thread_pool = NULL;
 2671|      0|    context->threads_started = 0;
 2672|      0|    context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|      0|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 2673|      0|  }
 2674|       |
 2675|  3.84M|  if (context->new_nthreads != context->nthreads) {
  ------------------
  |  Branch (2675:7): [True: 0, False: 3.84M]
  ------------------
 2676|      0|    release_thread_backend(context);
 2677|      0|    context->nthreads = context->new_nthreads;
 2678|      0|  }
 2679|  3.84M|  if (start_backend && context->nthreads > 1 && context->threads_started == 0) {
  ------------------
  |  Branch (2679:7): [True: 382k, False: 3.46M]
  |  Branch (2679:24): [True: 382k, False: 0]
  |  Branch (2679:49): [True: 382k, False: 0]
  ------------------
 2680|   382k|    int rc;
 2681|   382k|    if (threads_callback) {
  ------------------
  |  Branch (2681:9): [True: 0, False: 382k]
  ------------------
 2682|      0|      rc = init_callback_threads(context);
 2683|      0|    }
 2684|   382k|    else {
 2685|       |#if defined(_WIN32)
 2686|       |      rc = init_threadpool(context);
 2687|       |#else
 2688|   382k|      rc = attach_shared_pool(context);
 2689|   382k|#endif
 2690|   382k|    }
 2691|   382k|    if (rc < 0) {
  ------------------
  |  Branch (2691:9): [True: 0, False: 382k]
  ------------------
 2692|      0|      return rc;
 2693|      0|    }
 2694|   382k|  }
 2695|  3.84M|  if (context->nthreads <= 1) {
  ------------------
  |  Branch (2695:7): [True: 2.44M, False: 1.39M]
  ------------------
 2696|  2.44M|    context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|  2.44M|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 2697|  2.44M|  }
 2698|       |
 2699|  3.84M|  return context->nthreads;
 2700|  3.84M|}
blosc2.c:attach_shared_pool:
 5913|   382k|static int attach_shared_pool(blosc2_context *context) {
 5914|   382k|  struct blosc_shared_pool *pool;
 5915|       |
 5916|   382k|  blosc2_init();
 5917|   382k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|   382k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 5918|   382k|  pool = find_shared_pool_locked(context->nthreads);
 5919|   382k|  if (pool == NULL) {
  ------------------
  |  Branch (5919:7): [True: 84, False: 382k]
  ------------------
 5920|     84|    int rc = create_shared_pool(context->nthreads, &pool);
 5921|     84|    if (rc < 0) {
  ------------------
  |  Branch (5921:9): [True: 0, False: 84]
  ------------------
 5922|      0|      static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 5923|      0|      return rc;
 5924|      0|    }
 5925|     84|    pool->next = shared_pools;
 5926|     84|    shared_pools = pool;
 5927|     84|  }
 5928|   382k|  pool->context_refs++;
 5929|   382k|  context->thread_pool = pool;
 5930|   382k|  context->thread_backend = BLOSC_BACKEND_SHARED_POOL;
  ------------------
  |  |   34|   382k|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
 5931|   382k|  context->threads_started = context->nthreads;
 5932|   382k|  context->pool_epoch = load_acquire_int(&g_destroy_count);
  ------------------
  |  |  142|   382k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
 5933|   382k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|   382k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 5934|   382k|  return 0;
 5935|   382k|}
blosc2.c:find_shared_pool_locked:
 5765|   382k|static struct blosc_shared_pool* find_shared_pool_locked(int16_t nthreads) {
 5766|   382k|  struct blosc_shared_pool *pool = shared_pools;
 5767|   382k|  while (pool != NULL) {
  ------------------
  |  Branch (5767:10): [True: 382k, False: 84]
  ------------------
 5768|   382k|    if (pool->nthreads == nthreads) {
  ------------------
  |  Branch (5768:9): [True: 382k, False: 0]
  ------------------
 5769|   382k|      return pool;
 5770|   382k|    }
 5771|      0|    pool = pool->next;
 5772|      0|  }
 5773|     84|  return NULL;
 5774|   382k|}
blosc2.c:create_shared_pool:
 5776|     84|static int create_shared_pool(int16_t nthreads, struct blosc_shared_pool **pool_out) {
 5777|     84|  int rc = 0;
 5778|     84|  int rc2;
 5779|     84|  int32_t contexts_init = 0;    // per-thread contexts successfully initialized
 5780|     84|  int32_t threads_started = 0;  // worker threads successfully created
 5781|     84|#if !defined(_WIN32)
 5782|     84|  bool attr_inited = false;
 5783|     84|#endif
 5784|     84|  struct blosc_shared_pool *pool = (struct blosc_shared_pool *)my_malloc(sizeof(*pool));
 5785|     84|  BLOSC_ERROR_NULL(pool, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     84|    do {                                            \
  |  |  105|     84|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 84]
  |  |  ------------------
  |  |  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|     84|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 84]
  |  |  ------------------
  ------------------
 5786|     84|  memset(pool, 0, sizeof(*pool));
 5787|     84|  pool->nthreads = nthreads;
 5788|     84|  blosc2_pthread_mutex_init(&pool->mutex, NULL);
  ------------------
  |  |   90|     84|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 5789|     84|  blosc2_pthread_cond_init(&pool->work_cv, NULL);
  ------------------
  |  |   96|     84|#define blosc2_pthread_cond_init(a, b) pthread_cond_init((a), (b))
  ------------------
 5790|     84|  pool->threads = (blosc2_pthread_t*)my_malloc(nthreads * sizeof(blosc2_pthread_t));
 5791|     84|  if (pool->threads == NULL) { rc = BLOSC2_ERROR_MEMORY_ALLOC; goto error; }
  ------------------
  |  Branch (5791:7): [True: 0, False: 84]
  ------------------
 5792|     84|  pool->thread_contexts = (struct thread_context*)my_malloc((size_t)nthreads * sizeof(struct thread_context));
 5793|     84|  if (pool->thread_contexts == NULL) { rc = BLOSC2_ERROR_MEMORY_ALLOC; goto error; }
  ------------------
  |  Branch (5793:7): [True: 0, False: 84]
  ------------------
 5794|     84|  memset(pool->thread_contexts, 0, (size_t)nthreads * sizeof(struct thread_context));
 5795|     84|#if !defined(_WIN32)
 5796|     84|  pthread_attr_init(&pool->ct_attr);
 5797|     84|  pthread_attr_setdetachstate(&pool->ct_attr, PTHREAD_CREATE_JOINABLE);
 5798|     84|  attr_inited = true;
 5799|     84|#endif
 5800|    420|  for (int32_t tid = 0; tid < nthreads; ++tid) {
  ------------------
  |  Branch (5800:25): [True: 336, False: 84]
  ------------------
 5801|    336|    rc = init_thread_context(pool->thread_contexts + tid, NULL, tid);
 5802|    336|    if (rc < 0) {
  ------------------
  |  Branch (5802:9): [True: 0, False: 336]
  ------------------
 5803|      0|      goto error;
 5804|      0|    }
 5805|    336|    contexts_init++;
 5806|    336|    pool->thread_contexts[tid].owner_pool = pool;
 5807|    336|#if !defined(_WIN32)
 5808|    336|    rc2 = blosc2_pthread_create(&pool->threads[tid], &pool->ct_attr, shared_pool_worker,
  ------------------
  |  |  103|    336|#define blosc2_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
  ------------------
 5809|    336|                                (void*)(pool->thread_contexts + tid));
 5810|       |#else
 5811|       |    rc2 = blosc2_pthread_create(&pool->threads[tid], NULL, shared_pool_worker,
 5812|       |                                (void*)(pool->thread_contexts + tid));
 5813|       |#endif
 5814|    336|    if (rc2) {
  ------------------
  |  Branch (5814:9): [True: 0, False: 336]
  ------------------
 5815|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5816|      0|      rc = BLOSC2_ERROR_THREAD_CREATE;
 5817|      0|      goto error;
 5818|      0|    }
 5819|    336|    threads_started++;
 5820|    336|  }
 5821|     84|  *pool_out = pool;
 5822|     84|  return 0;
 5823|       |
 5824|      0|error:
 5825|       |  // A worker frees its own thread context when it exits (see shared_pool_worker),
 5826|       |  // so signal shutdown and join the ones already started before freeing anything.
 5827|      0|  if (threads_started > 0) {
  ------------------
  |  Branch (5827:7): [True: 0, False: 0]
  ------------------
 5828|      0|    blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5829|      0|    pool->shutdown = 1;
 5830|      0|    blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|      0|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5831|      0|    blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5832|      0|    for (int32_t t = 0; t < threads_started; ++t) {
  ------------------
  |  Branch (5832:25): [True: 0, False: 0]
  ------------------
 5833|      0|      void *status;
 5834|      0|      blosc2_pthread_join(pool->threads[t], &status);
  ------------------
  |  |  104|      0|#define blosc2_pthread_join(a, b) pthread_join((a), (b))
  ------------------
 5835|      0|    }
 5836|      0|  }
 5837|       |  // Contexts that were initialized but never got a running worker have no owner
 5838|       |  // to free them; tear those down here (the started ones did it themselves).
 5839|      0|  for (int32_t t = threads_started; t < contexts_init; ++t) {
  ------------------
  |  Branch (5839:37): [True: 0, False: 0]
  ------------------
 5840|      0|    destroy_thread_context(pool->thread_contexts + t);
 5841|      0|  }
 5842|      0|#if !defined(_WIN32)
 5843|      0|  if (attr_inited) {
  ------------------
  |  Branch (5843:7): [True: 0, False: 0]
  ------------------
 5844|      0|    pthread_attr_destroy(&pool->ct_attr);
 5845|      0|  }
 5846|      0|#endif
 5847|      0|  if (pool->thread_contexts != NULL) {
  ------------------
  |  Branch (5847:7): [True: 0, False: 0]
  ------------------
 5848|      0|    my_free(pool->thread_contexts);
 5849|      0|  }
 5850|      0|  if (pool->threads != NULL) {
  ------------------
  |  Branch (5850:7): [True: 0, False: 0]
  ------------------
 5851|      0|    my_free(pool->threads);
 5852|      0|  }
 5853|      0|  blosc2_pthread_cond_destroy(&pool->work_cv);
  ------------------
  |  |   97|      0|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5854|      0|  blosc2_pthread_mutex_destroy(&pool->mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5855|      0|  my_free(pool);
 5856|      0|  return rc;
 5857|     84|}
blosc2.c:shared_pool_worker:
 5712|    336|static void* shared_pool_worker(void* arg) {
 5713|    336|  struct thread_context* thcontext = (struct thread_context*)arg;
 5714|    336|  struct blosc_shared_pool* pool = thcontext->owner_pool;
 5715|       |
 5716|  1.19M|  while (1) {
  ------------------
  |  Branch (5716:10): [True: 1.19M, Folded]
  ------------------
 5717|  1.19M|    struct blosc_job_group* job = NULL;
 5718|  1.19M|    struct blosc_job_queue_entry* entry = NULL;
 5719|  1.19M|    blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5720|  2.72M|    while (!pool->shutdown && pool->job_queue_head == NULL) {
  ------------------
  |  Branch (5720:12): [True: 2.72M, False: 251]
  |  Branch (5720:31): [True: 1.52M, False: 1.19M]
  ------------------
 5721|  1.52M|      blosc2_pthread_cond_wait(&pool->work_cv, &pool->mutex);
  ------------------
  |  |   98|  1.52M|#define blosc2_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
  ------------------
 5722|  1.52M|    }
 5723|  1.19M|    if (pool->shutdown) {
  ------------------
  |  Branch (5723:9): [True: 336, False: 1.19M]
  ------------------
 5724|    336|      blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|    336|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5725|    336|      break;
 5726|    336|    }
 5727|  1.19M|    entry = pool->job_queue_head;
 5728|  1.19M|    job = entry->job;
 5729|  1.19M|    pool->job_queue_head = entry->next;
 5730|  1.19M|    if (pool->job_queue_head == NULL) {
  ------------------
  |  Branch (5730:9): [True: 382k, False: 814k]
  ------------------
 5731|   382k|      pool->job_queue_tail = NULL;
 5732|   382k|    }
 5733|  1.19M|    blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5734|  1.19M|    int32_t logical_tid = entry->logical_tid;
 5735|  1.19M|    my_free(entry);
 5736|       |
 5737|  1.19M|    thcontext->parent_context = job->context;
 5738|  1.19M|    thcontext->tid = logical_tid;
 5739|  1.19M|    t_blosc_do_job(thcontext);
 5740|  1.19M|    thcontext->parent_context = NULL;
 5741|       |
 5742|       |    /* Signal job completion BEFORE touching pool accounting.
 5743|       |     * The job struct is stack-allocated in parallel_blosc; the main thread
 5744|       |     * is allowed to destroy it as soon as completed==true is visible.
 5745|       |     * Decrementing pending_workers here (under job->mutex) guarantees that
 5746|       |     * every worker has finished with the job before the last decrement can
 5747|       |     * reach 0 and wake the main thread.  Doing the pool accounting afterwards
 5748|       |     * is safe because it no longer references the job. */
 5749|  1.19M|    blosc2_pthread_mutex_lock(&job->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5750|  1.19M|    if (--job->pending_workers == 0) {
  ------------------
  |  Branch (5750:9): [True: 382k, False: 814k]
  ------------------
 5751|   382k|      job->completed = true;
 5752|   382k|      blosc2_pthread_cond_broadcast(&job->completion_cv);
  ------------------
  |  |  100|   382k|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5753|   382k|    }
 5754|  1.19M|    blosc2_pthread_mutex_unlock(&job->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5755|       |
 5756|  1.19M|    blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|  1.19M|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5757|  1.19M|    pool->active_jobs--;
 5758|  1.19M|    blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|  1.19M|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5759|  1.19M|  }
 5760|       |
 5761|    336|  destroy_thread_context(thcontext);
 5762|       |  return NULL;
 5763|    336|}
blosc2.c:register_atfork:
  293|      1|static void register_atfork(void) {
  294|      1|  if (pthread_atfork(atfork_prepare, atfork_parent, atfork_child) != 0) {
  ------------------
  |  Branch (294:7): [True: 0, False: 1]
  ------------------
  295|       |    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|      0|  }
  297|      1|}
blosc2.c:blosc2_init_locked:
 6543|  4.92k|static void blosc2_init_locked(void) {
 6544|  4.92k|  BLOSC2_IO_CB_DEFAULTS.id = BLOSC2_IO_FILESYSTEM;
 6545|  4.92k|  BLOSC2_IO_CB_DEFAULTS.name = "filesystem";
 6546|  4.92k|  BLOSC2_IO_CB_DEFAULTS.is_allocation_necessary = true;
 6547|  4.92k|  BLOSC2_IO_CB_DEFAULTS.open = (blosc2_open_cb) blosc2_stdio_open;
 6548|  4.92k|  BLOSC2_IO_CB_DEFAULTS.close = (blosc2_close_cb) blosc2_stdio_close;
 6549|  4.92k|  BLOSC2_IO_CB_DEFAULTS.size = (blosc2_size_cb) blosc2_stdio_size;
 6550|  4.92k|  BLOSC2_IO_CB_DEFAULTS.write = (blosc2_write_cb) blosc2_stdio_write;
 6551|  4.92k|  BLOSC2_IO_CB_DEFAULTS.read = (blosc2_read_cb) blosc2_stdio_read;
 6552|  4.92k|  BLOSC2_IO_CB_DEFAULTS.truncate = (blosc2_truncate_cb) blosc2_stdio_truncate;
 6553|  4.92k|  BLOSC2_IO_CB_DEFAULTS.destroy = (blosc2_destroy_cb) blosc2_stdio_destroy;
 6554|       |
 6555|  4.92k|  _blosc2_register_io_cb(&BLOSC2_IO_CB_DEFAULTS);
 6556|       |
 6557|  4.92k|  BLOSC2_IO_CB_MMAP.id = BLOSC2_IO_FILESYSTEM_MMAP;
 6558|  4.92k|  BLOSC2_IO_CB_MMAP.name = "filesystem_mmap";
 6559|  4.92k|  BLOSC2_IO_CB_MMAP.is_allocation_necessary = false;
 6560|  4.92k|  BLOSC2_IO_CB_MMAP.open = (blosc2_open_cb) blosc2_stdio_mmap_open;
 6561|  4.92k|  BLOSC2_IO_CB_MMAP.close = (blosc2_close_cb) blosc2_stdio_mmap_close;
 6562|  4.92k|  BLOSC2_IO_CB_MMAP.read = (blosc2_read_cb) blosc2_stdio_mmap_read;
 6563|  4.92k|  BLOSC2_IO_CB_MMAP.size = (blosc2_size_cb) blosc2_stdio_mmap_size;
 6564|  4.92k|  BLOSC2_IO_CB_MMAP.write = (blosc2_write_cb) blosc2_stdio_mmap_write;
 6565|  4.92k|  BLOSC2_IO_CB_MMAP.truncate = (blosc2_truncate_cb) blosc2_stdio_mmap_truncate;
 6566|  4.92k|  BLOSC2_IO_CB_MMAP.destroy = (blosc2_destroy_cb) blosc2_stdio_mmap_destroy;
 6567|       |
 6568|  4.92k|  _blosc2_register_io_cb(&BLOSC2_IO_CB_MMAP);
 6569|       |
 6570|       |  // BLOSC_PREFETCH=<nthreads> turns read-ahead on without touching the sources (see blosc2_set_prefetch())
 6571|  4.92k|  const char *prefetch_env = getenv("BLOSC_PREFETCH");
 6572|  4.92k|  if (prefetch_env != NULL && prefetch_env[0] != '\0') {
  ------------------
  |  Branch (6572:7): [True: 0, False: 4.92k]
  |  Branch (6572:31): [True: 0, False: 0]
  ------------------
 6573|      0|    long nthreads = strtol(prefetch_env, NULL, 10);
 6574|      0|    if (nthreads > 0 && nthreads <= BLOSC2_PREFETCH_MAX_NTHREADS) {
  ------------------
  |  |  786|      0|#define BLOSC2_PREFETCH_MAX_NTHREADS 256
  ------------------
  |  Branch (6574:9): [True: 0, False: 0]
  |  Branch (6574:25): [True: 0, False: 0]
  ------------------
 6575|      0|      blosc2_set_prefetch((int) nthreads, 0, 0);
 6576|      0|    }
 6577|      0|  }
 6578|       |  // BLOSC_PREFETCH_POPULATE: of which memory-mapped frames read-ahead populates the mapping: of all (1), of none (0),
 6579|       |  // or, if unset or empty, of those on GPFS
 6580|  4.92k|  const char *populate_env = getenv("BLOSC_PREFETCH_POPULATE");
 6581|  4.92k|  prefetch_set_populate(populate_env != NULL && populate_env[0] != '\0' ? strtol(populate_env, NULL, 10) != 0 : -1);
  ------------------
  |  Branch (6581:25): [True: 0, False: 4.92k]
  |  Branch (6581:49): [True: 0, False: 0]
  ------------------
 6582|       |
 6583|  4.92k|  g_ncodecs = 0;
 6584|  4.92k|  g_nfilters = 0;
 6585|  4.92k|  g_ntuners = 0;
 6586|       |
 6587|  4.92k|#if defined(HAVE_PLUGINS)
 6588|  4.92k|  #include "blosc2/blosc2-common.h"
 6589|  4.92k|  #include "blosc2/blosc2-stdio.h"
 6590|  4.92k|  register_codecs();
 6591|  4.92k|  register_filters();
 6592|  4.92k|  register_tuners();
 6593|  4.92k|#endif
 6594|  4.92k|  blosc2_pthread_mutex_init(&global_comp_mutex, NULL);
  ------------------
  |  |   90|  4.92k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 6595|       |  /* Create a global context */
 6596|  4.92k|  g_global_context = (blosc2_context*)my_malloc(sizeof(blosc2_context));
 6597|  4.92k|  memset(g_global_context, 0, sizeof(blosc2_context));
 6598|  4.92k|  g_global_context->nthreads = g_nthreads;
 6599|  4.92k|  g_global_context->new_nthreads = g_nthreads;
 6600|  4.92k|  blosc2_pthread_mutex_init(&g_global_context->nchunk_mutex, NULL);
  ------------------
  |  |   90|  4.92k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
 6601|  4.92k|  store_release_int(&g_initlib, BLOSC_STATE_INITIALIZED);
  ------------------
  |  |  143|  4.92k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 6602|  4.92k|}
blosc2.c:blosc2_free_resources_locked:
 6631|  4.92k|static int blosc2_free_resources_locked(void) {
 6632|       |  /* The calling thread's temporaries (other threads free theirs at exit) */
 6633|  4.92k|  blosc2_tmp_cache_clear();
 6634|  4.92k|  int rc = release_thread_backend(g_global_context);
 6635|       |  /* The thread pools that no context uses (kept for reuse) */
 6636|  4.92k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  4.92k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6637|  4.92k|  struct blosc_shared_pool *unused = unlink_unused_pools_locked(0);
 6638|  4.92k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  4.92k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6639|  4.92k|  destroy_shared_pools(unused);
 6640|  4.92k|  return rc;
 6641|  4.92k|}
blosc2.c:unlink_unused_pools_locked:
 5894|   387k|static struct blosc_shared_pool *unlink_unused_pools_locked(int keep) {
 5895|   387k|  struct blosc_shared_pool *unused = NULL;
 5896|   387k|  struct blosc_shared_pool **prev = &shared_pools;
 5897|   769k|  while (*prev != NULL) {
  ------------------
  |  Branch (5897:10): [True: 382k, False: 387k]
  ------------------
 5898|   382k|    struct blosc_shared_pool *pool = *prev;
 5899|   382k|    if (pool->context_refs == 0) {
  ------------------
  |  Branch (5899:9): [True: 382k, False: 0]
  ------------------
 5900|   382k|      if (keep == 0) {
  ------------------
  |  Branch (5900:11): [True: 84, False: 382k]
  ------------------
 5901|     84|        *prev = pool->next;
 5902|     84|        pool->next = unused;
 5903|     84|        unused = pool;
 5904|     84|        continue;
 5905|     84|      }
 5906|   382k|      keep--;
 5907|   382k|    }
 5908|   382k|    prev = &pool->next;
 5909|   382k|  }
 5910|   387k|  return unused;
 5911|   387k|}
blosc2.c:destroy_shared_pools:
 5881|   392k|static void destroy_shared_pools(struct blosc_shared_pool *pool) {
 5882|   392k|  while (pool != NULL) {
  ------------------
  |  Branch (5882:10): [True: 84, False: 392k]
  ------------------
 5883|     84|    struct blosc_shared_pool *next = pool->next;
 5884|     84|    destroy_shared_pool(pool);
 5885|     84|    pool = next;
 5886|     84|  }
 5887|   392k|}
blosc2.c:destroy_shared_pool:
 5859|     84|static void destroy_shared_pool(struct blosc_shared_pool *pool) {
 5860|     84|  void *status;
 5861|       |
 5862|     84|  blosc2_pthread_mutex_lock(&pool->mutex);
  ------------------
  |  |   92|     84|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 5863|     84|  pool->shutdown = 1;
 5864|     84|  blosc2_pthread_cond_broadcast(&pool->work_cv);
  ------------------
  |  |  100|     84|#define blosc2_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
  ------------------
 5865|     84|  blosc2_pthread_mutex_unlock(&pool->mutex);
  ------------------
  |  |   93|     84|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 5866|       |
 5867|    420|  for (int32_t t = 0; t < pool->nthreads; ++t) {
  ------------------
  |  Branch (5867:23): [True: 336, False: 84]
  ------------------
 5868|    336|    blosc2_pthread_join(pool->threads[t], &status);
  ------------------
  |  |  104|    336|#define blosc2_pthread_join(a, b) pthread_join((a), (b))
  ------------------
 5869|    336|  }
 5870|     84|#if !defined(_WIN32)
 5871|     84|  pthread_attr_destroy(&pool->ct_attr);
 5872|     84|#endif
 5873|     84|  my_free(pool->threads);
 5874|     84|  my_free(pool->thread_contexts);
 5875|     84|  blosc2_pthread_cond_destroy(&pool->work_cv);
  ------------------
  |  |   97|     84|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 5876|     84|  blosc2_pthread_mutex_destroy(&pool->mutex);
  ------------------
  |  |   91|     84|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 5877|     84|  my_free(pool);
 5878|     84|}
blosc2.c:serial_context_put:
 6768|  5.81M|static void serial_context_put(struct thread_context* thread_context) {
 6769|  5.81M|#if !defined(_WIN32)
 6770|  5.81M|  tmp_cache_t *cache = tmp_cache_get(false);
 6771|  5.81M|  if (cache != NULL && cache->serial == thread_context) {
  ------------------
  |  Branch (6771:7): [True: 5.81M, False: 0]
  |  Branch (6771:24): [True: 5.81M, False: 2.12k]
  ------------------
 6772|  5.81M|    blosc2_context* context = thread_context->parent_context;
 6773|  5.81M|    if (context->serial_context == NULL &&
  ------------------
  |  Branch (6773:9): [True: 5.81M, False: 0]
  ------------------
 6774|  5.81M|        thread_context_nbytes(thread_context) > BLOSC2_SERIAL_TLS_MAX) {
  ------------------
  |  | 6664|  5.81M|#define BLOSC2_SERIAL_TLS_MAX (16 * 1024 * 1024)
  ------------------
  |  Branch (6774:9): [True: 2, False: 5.81M]
  ------------------
 6775|       |      /* Grown too large to keep per thread (e.g. ZSTD compression state for
 6776|       |         large blocks at high levels): the context that needed it keeps it, as
 6777|       |         if it had always been its own, and the thread starts a new one */
 6778|      2|      thread_context->tmp_blocksize = context->blocksize;
 6779|      2|      context->serial_context = thread_context;
 6780|      2|      cache->serial = NULL;
 6781|      2|    }
 6782|  5.81M|    else {
 6783|  5.81M|      thread_context->parent_context = NULL;
 6784|  5.81M|    }
 6785|  5.81M|    cache->serial_busy = false;
 6786|  5.81M|  }
 6787|       |#else
 6788|       |  BLOSC_UNUSED_PARAM(thread_context);
 6789|       |#endif
 6790|  5.81M|}
blosc2.c:thread_context_nbytes:
 6714|  5.81M|static size_t thread_context_nbytes(const struct thread_context* thread_context) {
 6715|  5.81M|  size_t nbytes = thread_context->tmp_nbytes +
 6716|  5.81M|                  (thread_context->blosclz_state != NULL ? sizeof(blosclz_state) : 0);
  ------------------
  |  Branch (6716:20): [True: 4.13M, False: 1.67M]
  ------------------
 6717|  5.81M|#if defined(HAVE_ZSTD)
 6718|  5.81M|  if (thread_context->zstd_cctx != NULL) {
  ------------------
  |  Branch (6718:7): [True: 0, False: 5.81M]
  ------------------
 6719|      0|    nbytes += ZSTD_sizeof_CCtx(thread_context->zstd_cctx);
 6720|      0|  }
 6721|  5.81M|  if (thread_context->zstd_dctx != NULL) {
  ------------------
  |  Branch (6721:7): [True: 14, False: 5.81M]
  ------------------
 6722|     14|    nbytes += ZSTD_sizeof_DCtx(thread_context->zstd_dctx);
 6723|     14|  }
 6724|  5.81M|#endif
 6725|  5.81M|  if (thread_context->lz4_cstream != NULL) {
  ------------------
  |  Branch (6725:7): [True: 0, False: 5.81M]
  ------------------
 6726|      0|    nbytes += sizeof(LZ4_stream_t);
 6727|      0|  }
 6728|  5.81M|  if (thread_context->lz4hc_cstream != NULL) {
  ------------------
  |  Branch (6728:7): [True: 0, False: 5.81M]
  ------------------
 6729|      0|    nbytes += sizeof(LZ4_streamHC_t);
 6730|      0|  }
 6731|  5.81M|  return nbytes;
 6732|  5.81M|}
blosc2.c:tmp_cache_get:
 6695|  11.6M|static tmp_cache_t *tmp_cache_get(bool create) {
 6696|  11.6M|  pthread_once(&tmp_cache_once, tmp_cache_init);
 6697|  11.6M|  if (!tmp_cache_ready) {
  ------------------
  |  Branch (6697:7): [True: 0, False: 11.6M]
  ------------------
 6698|      0|    return NULL;
 6699|      0|  }
 6700|  11.6M|  tmp_cache_t *cache = pthread_getspecific(tmp_cache_key);
 6701|  11.6M|  if (cache == NULL && create) {
  ------------------
  |  Branch (6701:7): [True: 1, False: 11.6M]
  |  Branch (6701:24): [True: 1, False: 0]
  ------------------
 6702|      1|    cache = calloc(1, sizeof(tmp_cache_t));
 6703|      1|    if (cache != NULL && pthread_setspecific(tmp_cache_key, cache) != 0) {
  ------------------
  |  Branch (6703:9): [True: 1, False: 0]
  |  Branch (6703:26): [True: 0, False: 1]
  ------------------
 6704|      0|      free(cache);
 6705|       |      cache = NULL;
 6706|      0|    }
 6707|      1|  }
 6708|  11.6M|  return cache;
 6709|  11.6M|}
blosc2.c:tmp_cache_init:
 6691|      1|static void tmp_cache_init(void) {
 6692|      1|  tmp_cache_ready = pthread_key_create(&tmp_cache_key, tmp_cache_release) == 0;
 6693|      1|}
blosc2.c:blosc2_destroy_locked:
 6892|  4.92k|static void blosc2_destroy_locked(void) {
 6893|  4.92k|  blosc2_free_resources_locked();
 6894|  4.92k|  blosc2_free_ctx(g_global_context);
 6895|  4.92k|  blosc2_tmp_cache_clear();
 6896|       |
 6897|       |  /* Atomically invalidate outstanding context pointers and detach the registry.
 6898|       |   * A release either finishes its refcount update before this, or observes the
 6899|       |   * new epoch without dereferencing its stale pool.  Join outside the lock. */
 6900|  4.92k|  static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|  4.92k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6901|  4.92k|  store_release_int(&g_destroy_count, load_acquire_int(&g_destroy_count) + 1);
  ------------------
  |  |  143|  4.92k|#define store_release_int(p, v) __atomic_store_n((p), (v), __ATOMIC_RELEASE)
  ------------------
 6902|  4.92k|  struct blosc_shared_pool *pools = shared_pools;
 6903|  4.92k|  shared_pools = NULL;
 6904|  4.92k|  static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|  4.92k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6905|  4.92k|  destroy_shared_pools(pools);
 6906|       |
 6907|  4.92k|  blosc2_pthread_mutex_destroy(&global_comp_mutex);
  ------------------
  |  |   91|  4.92k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 6908|  4.92k|}
blosc2.c:my_malloc:
  365|  4.78M|static uint8_t* my_malloc(size_t size) {
  366|  4.78M|  void* block = NULL;
  367|  4.78M|  int res = 0;
  368|       |  /* Keep aligned allocations valid under Valgrind and POSIX wrappers. */
  369|  4.78M|  if (size == 0) {
  ------------------
  |  Branch (369:7): [True: 336, False: 4.78M]
  ------------------
  370|    336|    size = 1;
  371|    336|  }
  372|       |
  373|       |/* Do an alignment to 32 bytes because AVX2 is supported */
  374|       |#if defined(_WIN32)
  375|       |  /* A (void *) cast needed for avoiding a warning with MINGW :-/ */
  376|       |  block = (void *)_aligned_malloc(size, 32);
  377|       |#elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
  378|       |  /* Platform does have an implementation of posix_memalign */
  379|  4.78M|  res = posix_memalign(&block, 32, size);
  380|       |#else
  381|       |  block = malloc(size);
  382|       |#endif  /* _WIN32 */
  383|       |
  384|  4.78M|  if (block == NULL || res != 0) {
  ------------------
  |  Branch (384:7): [True: 0, False: 4.78M]
  |  Branch (384:24): [True: 0, False: 4.78M]
  ------------------
  385|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|      0|    return NULL;
  387|      0|  }
  388|       |
  389|  4.78M|  return (uint8_t*)block;
  390|  4.78M|}
blosc2.c:release_thread_backend:
 6049|  3.42M|static int release_thread_backend(blosc2_context *context) {
 6050|  3.42M|  if (context->thread_backend == BLOSC_BACKEND_CALLBACK && context->threads_started > 0) {
  ------------------
  |  |   35|  6.85M|#define BLOSC_BACKEND_CALLBACK 2
  ------------------
  |  Branch (6050:7): [True: 0, False: 3.42M]
  |  Branch (6050:60): [True: 0, False: 0]
  ------------------
 6051|      0|    for (int32_t t = 0; t < context->threads_started; t++) {
  ------------------
  |  Branch (6051:25): [True: 0, False: 0]
  ------------------
 6052|      0|      destroy_thread_context(context->thread_contexts + t);
 6053|      0|    }
 6054|      0|    my_free(context->thread_contexts);
 6055|      0|    context->thread_contexts = NULL;
 6056|      0|    blosc2_pthread_mutex_destroy(&context->count_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 6057|      0|    blosc2_pthread_mutex_destroy(&context->delta_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 6058|      0|    blosc2_pthread_cond_destroy(&context->delta_cv);
  ------------------
  |  |   97|      0|#define blosc2_pthread_cond_destroy(a) pthread_cond_destroy((a))
  ------------------
 6059|      0|  }
 6060|       |#if defined(_WIN32)
 6061|       |  else if (context->thread_backend == BLOSC_BACKEND_PER_CONTEXT && context->threads_started > 0) {
 6062|       |    /* Signal all workers to exit. */
 6063|       |    blosc2_pthread_mutex_lock(&context->jobs_mutex);
 6064|       |    context->end_threads = 1;
 6065|       |    blosc2_pthread_cond_broadcast(&context->jobs_ready);
 6066|       |    blosc2_pthread_mutex_unlock(&context->jobs_mutex);
 6067|       |
 6068|       |    for (int32_t t = 0; t < context->threads_started; t++) {
 6069|       |      blosc2_pthread_join(context->threads[t], NULL);
 6070|       |    }
 6071|       |    my_free(context->threads);
 6072|       |    context->threads = NULL;
 6073|       |    blosc2_pthread_cond_destroy(&context->jobs_done);
 6074|       |    blosc2_pthread_cond_destroy(&context->jobs_ready);
 6075|       |    blosc2_pthread_mutex_destroy(&context->jobs_mutex);
 6076|       |    blosc2_pthread_cond_destroy(&context->delta_cv);
 6077|       |    blosc2_pthread_mutex_destroy(&context->delta_mutex);
 6078|       |    blosc2_pthread_mutex_destroy(&context->count_mutex);
 6079|       |  }
 6080|       |#endif  /* _WIN32 */
 6081|  3.42M|  else if (context->thread_backend == BLOSC_BACKEND_SHARED_POOL && context->thread_pool != NULL) {
  ------------------
  |  |   34|  6.85M|#define BLOSC_BACKEND_SHARED_POOL 1
  ------------------
  |  Branch (6081:12): [True: 382k, False: 3.04M]
  |  Branch (6081:68): [True: 382k, False: 0]
  ------------------
 6082|   382k|    struct blosc_shared_pool *pool = context->thread_pool;
 6083|       |
 6084|   382k|    static_lock(&pool_registry_mutex);
  ------------------
  |  |  132|   382k|#define static_lock(l) pthread_mutex_lock(l)
  ------------------
 6085|   382k|    if (context->pool_epoch != load_acquire_int(&g_destroy_count)) {
  ------------------
  |  |  142|   382k|#define load_acquire_int(p) __atomic_load_n((p), __ATOMIC_ACQUIRE)
  ------------------
  |  Branch (6085:9): [True: 0, False: 382k]
  ------------------
 6086|       |      /* Check under the process-lifetime registry lock: destruction cannot
 6087|       |       * invalidate the pool between this check and the refcount update. */
 6088|      0|      static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|      0|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6089|      0|      context->thread_pool = NULL;
 6090|      0|      context->threads_started = 0;
 6091|      0|      context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|      0|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 6092|      0|      return 0;
 6093|      0|    }
 6094|       |
 6095|       |    /* A pool that no context uses any more stays registered for the next
 6096|       |     * contexts with the same nthreads: contexts that live for one call
 6097|       |     * (python-blosc2's compress2()/decompress2(), BLOSC_NOLOCK) would otherwise
 6098|       |     * start and join all of its threads every time.  The most recently
 6099|       |     * released unused pools are kept, the others destroyed (the pool moves to
 6100|       |     * the front of the registry); blosc2_free_resources() destroys all. */
 6101|   382k|    struct blosc_shared_pool *unused = NULL;
 6102|   382k|    pool->context_refs--;
 6103|   382k|    if (pool->context_refs == 0) {
  ------------------
  |  Branch (6103:9): [True: 382k, False: 0]
  ------------------
 6104|   382k|      struct blosc_shared_pool **prev = &shared_pools;
 6105|   382k|      while (*prev != NULL && *prev != pool) {
  ------------------
  |  Branch (6105:14): [True: 382k, False: 0]
  |  Branch (6105:31): [True: 0, False: 382k]
  ------------------
 6106|      0|        prev = &(*prev)->next;
 6107|      0|      }
 6108|   382k|      if (*prev == pool) {
  ------------------
  |  Branch (6108:11): [True: 382k, False: 0]
  ------------------
 6109|   382k|        *prev = pool->next;
 6110|   382k|        pool->next = shared_pools;
 6111|   382k|        shared_pools = pool;
 6112|   382k|      }
 6113|   382k|      unused = unlink_unused_pools_locked(BLOSC2_UNUSED_POOLS_MAX);
  ------------------
  |  |  187|   382k|#define BLOSC2_UNUSED_POOLS_MAX 2
  ------------------
 6114|   382k|    }
 6115|   382k|    static_unlock(&pool_registry_mutex);
  ------------------
  |  |  133|   382k|#define static_unlock(l) pthread_mutex_unlock(l)
  ------------------
 6116|   382k|    destroy_shared_pools(unused);
 6117|   382k|    context->thread_pool = NULL;
 6118|   382k|  }
 6119|       |
 6120|  3.42M|  context->threads_started = 0;
 6121|  3.42M|  context->thread_backend = BLOSC_BACKEND_SERIAL;
  ------------------
  |  |   33|  3.42M|#define BLOSC_BACKEND_SERIAL 0
  ------------------
 6122|  3.42M|  return 0;
 6123|  3.42M|}
blosc2.c:release_context_dict_buffer:
 2979|  5.07M|static void release_context_dict_buffer(blosc2_context* context) {
 2980|  5.07M|  if (context->dict_buffer_owned && context->dict_buffer != NULL) {
  ------------------
  |  Branch (2980:7): [True: 0, False: 5.07M]
  |  Branch (2980:37): [True: 0, False: 0]
  ------------------
 2981|      0|    free(context->dict_buffer);
 2982|      0|  }
 2983|  5.07M|  context->dict_buffer = NULL;
 2984|       |  context->dict_buffer_owned = false;
 2985|  5.07M|  context->dict_size = 0;
 2986|  5.07M|}

blosclz_compress_state:
  750|  3.50M|                           void* output, int maxout, blosclz_state* state) {
  751|  3.50M|  if (state->tagged) {
  ------------------
  |  Branch (751:7): [True: 2.02M, False: 1.48M]
  ------------------
  752|  2.02M|    return compress_impl(clevel, input, length, output, maxout, state->htab, state, 1);
  753|  2.02M|  }
  754|  1.48M|  return compress_impl(clevel, input, length, output, maxout, state->htab, state, 0);
  755|  3.50M|}
blosclz_decompress:
  833|  5.06M|int blosclz_decompress(const void* input, int length, void* output, int maxout) {
  834|  5.06M|  const uint8_t* ip = (const uint8_t*)input;
  835|  5.06M|  const uint8_t* ip_limit = ip + length;
  836|  5.06M|  uint8_t* op = (uint8_t*)output;
  837|  5.06M|  uint32_t ctrl;
  838|  5.06M|  uint8_t* op_limit = op + maxout;
  839|  5.06M|  if (BLOSCLZ_UNLIKELY(length == 0)) {
  ------------------
  |  |   39|  5.06M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 0, False: 5.06M]
  |  |  ------------------
  ------------------
  840|      0|    return 0;
  841|      0|  }
  842|  5.06M|  ctrl = (*ip++) & 31U;
  843|       |
  844|   873M|  while (1) {
  ------------------
  |  Branch (844:10): [True: 873M, Folded]
  ------------------
  845|   873M|    if (ctrl >= 32) {
  ------------------
  |  Branch (845:9): [True: 462M, False: 411M]
  ------------------
  846|       |      // match
  847|   462M|      int32_t len = (int32_t)(ctrl >> 5U) - 1 ;
  848|   462M|      int32_t ofs = (int32_t)(ctrl & 31U) << 8U;
  849|   462M|      uint8_t code;
  850|   462M|      const uint8_t* ref = op - ofs;
  851|       |
  852|   462M|      if (len == 7 - 1) {
  ------------------
  |  Branch (852:11): [True: 117M, False: 344M]
  ------------------
  853|   117M|#ifdef BLOSCLZ_WIDE_DECODE
  854|       |        /* Long runs encode their lengths as consecutive 255-byte extensions.
  855|       |         * Consume eight together, keeping an offset byte in reserve. */
  856|   134M|        while (ip_limit - ip >= 9) {
  ------------------
  |  Branch (856:16): [True: 131M, False: 3.41M]
  ------------------
  857|   131M|          uint64_t extensions;
  858|   131M|          memcpy(&extensions, ip, sizeof(extensions));
  859|   131M|          if (extensions != UINT64_MAX) {
  ------------------
  |  Branch (859:15): [True: 114M, False: 17.1M]
  ------------------
  860|   114M|            break;
  861|   114M|          }
  862|  17.1M|          if (BLOSCLZ_UNLIKELY(len > maxout - 8 * 255)) {
  ------------------
  |  |   39|  17.1M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 0, False: 17.1M]
  |  |  ------------------
  ------------------
  863|      0|            return 0;
  864|      0|          }
  865|  17.1M|          len += 8 * 255;
  866|  17.1M|          ip += 8;
  867|  17.1M|        }
  868|   117M|#endif
  869|   173M|        do {
  870|   173M|          if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
  ------------------
  |  |   39|   173M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 173M]
  |  |  ------------------
  ------------------
  871|      1|            return 0;
  872|      1|          }
  873|   173M|          code = *ip++;
  874|       |          /* Guard before the addition so that `len` can never wrap past
  875|       |             INT32_MAX.  The subsequent `len += 3` adds at most 3 more,
  876|       |             so capping at maxout here is safe and sufficient. */
  877|   173M|          if (BLOSCLZ_UNLIKELY(len > maxout - code)) {
  ------------------
  |  |   39|   173M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 3, False: 173M]
  |  |  ------------------
  ------------------
  878|      3|            return 0;
  879|      3|          }
  880|   173M|          len += code;
  881|   173M|        } while (code == 255);
  ------------------
  |  Branch (881:18): [True: 55.2M, False: 117M]
  ------------------
  882|   117M|      }
  883|   344M|      else {
  884|   344M|        if (BLOSCLZ_UNLIKELY(ip + 1 >= ip_limit)) {
  ------------------
  |  |   39|   344M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 2, False: 344M]
  |  |  ------------------
  ------------------
  885|      2|          return 0;
  886|      2|        }
  887|   344M|      }
  888|   462M|      code = *ip++;
  889|   462M|      len += 3;
  890|   462M|      ref -= code;
  891|       |
  892|       |      /* match from 16-bit distance */
  893|   462M|      if (BLOSCLZ_UNLIKELY(code == 255)) {
  ------------------
  |  |   39|   462M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1.98M, False: 460M]
  |  |  ------------------
  ------------------
  894|  1.98M|        if (ofs == (31U << 8U)) {
  ------------------
  |  Branch (894:13): [True: 623k, False: 1.35M]
  ------------------
  895|   623k|          if (ip + 1 >= ip_limit) {
  ------------------
  |  Branch (895:15): [True: 1, False: 623k]
  ------------------
  896|      1|            return 0;
  897|      1|          }
  898|   623k|          ofs = (*ip++) << 8U;
  899|   623k|          ofs += *ip++;
  900|   623k|          ref = op - ofs - MAX_DISTANCE;
  ------------------
  |  |   50|   623k|#define MAX_DISTANCE 8191
  ------------------
  901|   623k|        }
  902|  1.98M|      }
  903|       |
  904|   462M|      if (BLOSCLZ_UNLIKELY(len > op_limit - op)) {
  ------------------
  |  |   39|   462M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 462M]
  |  |  ------------------
  ------------------
  905|      1|        return 0;
  906|      1|      }
  907|       |
  908|   462M|      if (BLOSCLZ_UNLIKELY(ref <= (uint8_t*)output)) {
  ------------------
  |  |   39|   462M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 462M]
  |  |  ------------------
  ------------------
  909|      1|        return 0;
  910|      1|      }
  911|       |
  912|   462M|      if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
  ------------------
  |  |   39|   462M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 462M]
  |  |  ------------------
  ------------------
  913|   462M|      ctrl = *ip++;
  914|       |
  915|   462M|      ref--;
  916|   462M|      if (ref == op - 1) {
  ------------------
  |  Branch (916:11): [True: 301M, False: 160M]
  ------------------
  917|       |        /* optimized copy for a run */
  918|   301M|        memset(op, *ref, len);
  919|   301M|        op += len;
  920|   301M|      }
  921|   160M|#ifdef BLOSCLZ_WIDE_DECODE
  922|   160M|      else if ((op - ref >= 16) && (op_limit - op - len >= 16)) {
  ------------------
  |  Branch (922:16): [True: 139M, False: 21.8M]
  |  Branch (922:36): [True: 137M, False: 1.46M]
  ------------------
  923|   137M|        wild_copy_16(op, ref, op + len);
  924|   137M|        op += len;
  925|   137M|      }
  926|  23.2M|#endif
  927|  23.2M|      else if ((op - ref >= 8) && (op_limit - op - len >= 8)) {
  ------------------
  |  Branch (927:16): [True: 13.5M, False: 9.71M]
  |  Branch (927:35): [True: 12.1M, False: 1.36M]
  ------------------
  928|       |        // copy with an overlap not larger than 8
  929|  12.1M|        wild_copy(op, ref, op + len);
  930|  12.1M|        op += len;
  931|  12.1M|      }
  932|  11.0M|      else {
  933|       |        // general copy with any overlap
  934|       |#if 0 && defined(__AVX2__)
  935|       |        if (op - ref <= 16) {
  936|       |          // This is not faster on a combination of compilers (clang, gcc, icc) or machines, but
  937|       |          // it is not too slower either.
  938|       |          op = copy_match_16(op, ref, len);
  939|       |        }
  940|       |        else {
  941|       |#endif
  942|  11.0M|          op = copy_match(op, ref, (unsigned) len);
  943|       |#if 0 && defined(__AVX2__)
  944|       |        }
  945|       |#endif
  946|  11.0M|      }
  947|   462M|    }
  948|   411M|    else {
  949|       |      // literal
  950|   411M|      ctrl++;
  951|   411M|      if (BLOSCLZ_UNLIKELY(ctrl > op_limit - op)) {
  ------------------
  |  |   39|   411M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 411M]
  |  |  ------------------
  ------------------
  952|      1|        return 0;
  953|      1|      }
  954|   411M|      if (BLOSCLZ_UNLIKELY(ctrl > ip_limit - ip)) {
  ------------------
  |  |   39|   411M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1, False: 411M]
  |  |  ------------------
  ------------------
  955|      1|        return 0;
  956|      1|      }
  957|       |
  958|   411M|#ifdef BLOSCLZ_WIDE_DECODE
  959|       |      /* Fixed-size copies can inline.  Overcopy only within both buffers;
  960|       |       * subsequent tokens overwrite the extra output bytes. */
  961|   411M|      if (ctrl <= 16 && op_limit - op >= 16 && ip_limit - ip >= 16) {
  ------------------
  |  Branch (961:11): [True: 366M, False: 44.1M]
  |  Branch (961:25): [True: 361M, False: 5.06M]
  |  Branch (961:48): [True: 358M, False: 3.45M]
  ------------------
  962|   358M|        memcpy(op, ip, 16);
  963|   358M|      }
  964|  52.6M|      else if (op_limit - op >= 32 && ip_limit - ip >= 32) {
  ------------------
  |  Branch (964:16): [True: 47.2M, False: 5.42M]
  |  Branch (964:39): [True: 44.1M, False: 3.11M]
  ------------------
  965|  44.1M|        memcpy(op, ip, 32);
  966|  44.1M|      }
  967|  8.54M|      else
  968|  8.54M|#endif
  969|  8.54M|      {
  970|  8.54M|        memcpy(op, ip, ctrl);
  971|  8.54M|      }
  972|   411M|      op += ctrl; ip += ctrl;
  973|       |      // On GCC-6, fastcopy this is still faster than plain memcpy
  974|       |      // However, using recent CLANG/LLVM 9.0, there is almost no difference
  975|       |      // in performance.
  976|       |      // And starting on CLANG/LLVM 10 and GCC 9, memcpy is generally faster.
  977|       |      // op = fastcopy(op, ip, (unsigned) ctrl); ip += ctrl;
  978|       |
  979|   411M|      if (BLOSCLZ_UNLIKELY(ip >= ip_limit)) break;
  ------------------
  |  |   39|   411M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 5.06M, False: 405M]
  |  |  ------------------
  ------------------
  980|   405M|      ctrl = *ip++;
  981|   405M|    }
  982|   873M|  }
  983|       |
  984|  5.06M|  return (int)(op - (uint8_t*)output);
  985|  5.06M|}
blosclz.c:compress_impl:
  538|  3.50M|                                        int maxout, uint32_t htab[], blosclz_state* state, const int tagged) {
  539|  3.50M|  uint8_t* ibase = (uint8_t*)input;
  540|       |
  541|       |  /* Keep match coverage and boundary positioning consistent across levels.
  542|       |   * A shift of 4 truncates matches further and can disrupt periodic byte deltas,
  543|       |   * reducing both compression ratio and speed on floating-point ramps. */
  544|  3.50M|  unsigned ipshift = 3;
  545|       |  /* Retain the higher-level minimum: accepting more short matches can prevent
  546|       |   * finding longer matches and increase decompression work. */
  547|  3.50M|  unsigned minlen = clevel == 1 ? 3 : 4;
  ------------------
  |  Branch (547:21): [True: 97.6k, False: 3.40M]
  ------------------
  548|       |
  549|       |  /* Grow the table gradually from 1 KB at level 1 to 64 KB at level 7.
  550|       |   * Smaller tables also bound the entropy probe, reducing low-level work on
  551|       |   * the small alphabets produced by filtered ramps. */
  552|  3.50M|  uint8_t hashlog_[10] = {0, HASH_LOG - 6, HASH_LOG - 5, HASH_LOG - 4, HASH_LOG - 3,
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                uint8_t hashlog_[10] = {0, HASH_LOG - 6, HASH_LOG - 5, HASH_LOG - 4, HASH_LOG - 3,
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                uint8_t hashlog_[10] = {0, HASH_LOG - 6, HASH_LOG - 5, HASH_LOG - 4, HASH_LOG - 3,
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                uint8_t hashlog_[10] = {0, HASH_LOG - 6, HASH_LOG - 5, HASH_LOG - 4, HASH_LOG - 3,
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
  553|  3.50M|                          HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                                        HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                                        HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                                        HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
                                        HASH_LOG - 2, HASH_LOG - 1, HASH_LOG, HASH_LOG, HASH_LOG};
  ------------------
  |  |   61|  3.50M|#define HASH_LOG (14U)
  ------------------
  554|  3.50M|  uint8_t hashlog = hashlog_[clevel];
  555|       |
  556|       |  // Experiments say that checking 1/4 of the buffer is enough to figure out approx cratio
  557|       |  // UPDATE: new experiments with ERA5 datasets (float32) say that checking the whole buffer
  558|       |  // is better (specially when combined with bitshuffle).
  559|       |  // The loss in speed for checking the whole buffer is pretty negligible too.
  560|  3.50M|  int maxlen = length;
  561|  3.50M|  if (clevel < 2) {
  ------------------
  |  Branch (561:7): [True: 97.6k, False: 3.40M]
  ------------------
  562|  97.6k|    maxlen /= 8;
  563|  97.6k|  }
  564|  3.40M|  else if (clevel < 4) {
  ------------------
  |  Branch (564:12): [True: 124k, False: 3.28M]
  ------------------
  565|   124k|    maxlen /= 4;
  566|   124k|  }
  567|  3.28M|  else if (clevel < 7) {
  ------------------
  |  Branch (567:12): [True: 2.29M, False: 989k]
  ------------------
  568|  2.29M|    maxlen /= 2;
  569|  2.29M|  }
  570|       |  // Start probing somewhere inside the buffer
  571|  3.50M|  int shift = length - maxlen;
  572|       |  // Actual entropy probing!
  573|  3.50M|  uint32_t base = htab_reset(htab, hashlog, state, maxlen, tagged);
  574|  3.50M|  double cratio = get_cratio(ibase + shift, maxlen, minlen, ipshift, htab, hashlog, base, tagged);
  575|  3.50M|  if (state != NULL) {
  ------------------
  |  Branch (575:7): [True: 3.50M, False: 18.4E]
  ------------------
  576|       |    /* Tagged lookups cost a bit per hash probe; they only pay off when skipping
  577|       |     * the (large) table clear matters, i.e. on very compressible data. */
  578|  3.50M|    state->tagged = clevel >= 4 && cratio >= 8.0;
  ------------------
  |  Branch (578:21): [True: 3.28M, False: 222k]
  |  Branch (578:36): [True: 2.02M, False: 1.26M]
  ------------------
  579|  3.50M|  }
  580|       |  // discard probes with small compression ratios (too expensive)
  581|  3.50M|  double cratio_[10] = {0, 2, 1.5, 1.2, 1.2, 1.2, 1.2, 1.15, 1.1, 1.0};
  582|  3.50M|  if (cratio < cratio_[clevel]) {
  ------------------
  |  Branch (582:7): [True: 165k, False: 3.34M]
  ------------------
  583|   165k|      goto out;
  584|   165k|  }
  585|       |
  586|  3.34M|  uint8_t* ip = ibase;
  587|  3.34M|  uint8_t* ip_bound = ibase + length - 1;
  588|  3.34M|  uint8_t* ip_limit = ibase + length - 12;
  589|  3.34M|  uint8_t* op = (uint8_t*)output;
  590|  3.34M|  const uint8_t* op_limit = op + maxout;
  591|  3.34M|  uint32_t seq;
  592|  3.34M|  uint8_t copy;
  593|  3.34M|  uint32_t hval;
  594|       |
  595|       |  /* input and output buffer cannot be less than 16 and 66 bytes or we can get into trouble */
  596|  3.34M|  if (length < 16 || maxout < 66) {
  ------------------
  |  Branch (596:7): [True: 18.4E, False: 3.34M]
  |  Branch (596:22): [True: 259k, False: 3.08M]
  ------------------
  597|   260k|    return 0;
  598|   260k|  }
  599|       |
  600|       |  // Initialize the hash table
  601|  3.08M|  base = htab_reset(htab, hashlog, state, length, tagged);
  602|       |
  603|       |  /* we start with literal copy */
  604|  3.08M|  copy = 4;
  605|  3.08M|  *op++ = MAX_COPY - 1;
  ------------------
  |  |   49|  3.08M|#define MAX_COPY 32U
  ------------------
  606|  3.08M|  *op++ = *ip++;
  607|  3.08M|  *op++ = *ip++;
  608|  3.08M|  *op++ = *ip++;
  609|  3.08M|  *op++ = *ip++;
  610|       |
  611|       |  /* main loop */
  612|   879M|  while (BLOSCLZ_LIKELY(ip < ip_limit)) {
  ------------------
  |  |   38|   879M|#define BLOSCLZ_LIKELY(c)    (c)
  |  |  ------------------
  |  |  |  Branch (38:30): [True: 876M, False: 3.07M]
  |  |  ------------------
  ------------------
  613|   876M|    const uint8_t* ref;
  614|   876M|    unsigned distance;
  615|   876M|    uint8_t* anchor = ip;    /* comparison starting-point */
  616|       |
  617|       |    /* find potential match */
  618|   876M|    seq = BLOSCLZ_READU32(ip);
  ------------------
  |  |   58|   876M|  #define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
  ------------------
  619|   876M|    HASH_FUNCTION(hval, seq, hashlog)
  ------------------
  |  |   64|   876M|#define HASH_FUNCTION(v, s, h) {      \
  |  |   65|   876M|  (v) = ((s) * 2654435761U) >> (32U - (h)); \
  |  |   66|   876M|}
  ------------------
  620|   876M|    ref = ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  407|   876M|#define HTAB_GET(entry, base) (tagged ? ((entry) >= (base) ? (entry) - (base) : 0) : (entry))
  |  |  ------------------
  |  |  |  Branch (407:32): [True: 741M, False: 135M]
  |  |  |  Branch (407:42): [True: 246M, False: 494M]
  |  |  ------------------
  ------------------
  621|       |    /* With no pending literals, try the position following the previous
  622|       |     * occurrence of ip[-1..2].  Its alignment can break a chain of short
  623|       |     * matches on periodic data even when the ordinary candidate also matches.
  624|       |     * Read the old entry before updating it, then reload the ordinary candidate:
  625|       |     * the two hashes can share a slot. */
  626|   876M|    if (copy == 0 && ip > ibase + 4 && ip_bound - ip >= 8) {
  ------------------
  |  Branch (626:9): [True: 157M, False: 718M]
  |  Branch (626:22): [True: 157M, False: 18.4E]
  |  Branch (626:40): [True: 157M, False: 16.0k]
  ------------------
  627|   157M|      uint32_t prevhash;
  628|   157M|      HASH_FUNCTION(prevhash, BLOSCLZ_READU32(ip - 1), hashlog)
  ------------------
  |  |   64|   157M|#define HASH_FUNCTION(v, s, h) {      \
  |  |   65|   157M|  (v) = ((s) * 2654435761U) >> (32U - (h)); \
  |  |   66|   157M|}
  ------------------
  629|   157M|      const uint8_t *candidate = ibase + HTAB_GET(htab[prevhash], base) + 1;
  ------------------
  |  |  407|   157M|#define HTAB_GET(entry, base) (tagged ? ((entry) >= (base) ? (entry) - (base) : 0) : (entry))
  |  |  ------------------
  |  |  |  Branch (407:32): [True: 135M, False: 21.4M]
  |  |  |  Branch (407:42): [True: 44.5M, False: 91.2M]
  |  |  ------------------
  ------------------
  630|   157M|      htab[prevhash] = (uint32_t)(ip - 1 - ibase) + base;
  631|   157M|      ref = ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  407|   157M|#define HTAB_GET(entry, base) (tagged ? ((entry) >= (base) ? (entry) - (base) : 0) : (entry))
  |  |  ------------------
  |  |  |  Branch (407:32): [True: 135M, False: 21.3M]
  |  |  |  Branch (407:42): [True: 40.5M, False: 95.4M]
  |  |  ------------------
  ------------------
  632|   157M|      if (candidate < ip && ip - candidate < MAX_FARDISTANCE &&
  ------------------
  |  |   51|   303M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   50|   146M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (632:11): [True: 146M, False: 10.8M]
  |  Branch (632:29): [True: 146M, False: 18.4E]
  ------------------
  633|   146M|          memcmp(candidate, ip, 8) == 0) {
  ------------------
  |  Branch (633:11): [True: 16.2M, False: 130M]
  ------------------
  634|  16.2M|        ref = candidate;
  635|  16.2M|      }
  636|   157M|    }
  637|       |
  638|       |    /* calculate distance to the match */
  639|   876M|    distance = (unsigned int)(anchor - ref);
  640|       |
  641|       |    /* update hash table */
  642|   876M|    htab[hval] = (uint32_t) (anchor - ibase) + base;
  643|       |
  644|   876M|    if (distance == 0 || (distance >= MAX_FARDISTANCE)) {
  ------------------
  |  |   51|   876M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   50|   876M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (644:9): [True: 18.4E, False: 876M]
  |  Branch (644:26): [True: 18.4E, False: 876M]
  ------------------
  645|  38.3k|      LITERAL(ip, op, op_limit, anchor, copy)
  ------------------
  |  |  333|  38.3k|#define LITERAL(ip, op, op_limit, anchor, copy) {       \
  |  |  334|  38.3k|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))          \
  |  |  ------------------
  |  |  |  |   39|  38.3k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 38.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  335|  38.3k|    goto out;                                           \
  |  |  336|  38.3k|  *(op)++ = *(anchor)++;                                \
  |  |  337|  38.3k|  (ip) = (anchor);                                      \
  |  |  338|  38.3k|  (copy)++;                                             \
  |  |  339|  38.3k|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|  38.3k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 603, False: 37.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  340|    603|    (copy) = 0;                                         \
  |  |  341|    603|    *(op)++ = MAX_COPY-1;                               \
  |  |  ------------------
  |  |  |  |   49|    603|#define MAX_COPY 32U
  |  |  ------------------
  |  |  342|    603|  }                                                     \
  |  |  343|  38.3k|}
  ------------------
  646|      0|      continue;
  647|  38.3k|    }
  648|       |
  649|       |    /* is this a match? check the first 4 bytes */
  650|   876M|    if (BLOSCLZ_UNLIKELY(BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip))) {
  ------------------
  |  |   39|   876M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 245M, False: 630M]
  |  |  ------------------
  ------------------
  651|   245M|      ref += 4;
  652|   630M|    } else {
  653|       |      /* no luck, copy as a literal */
  654|   630M|      LITERAL(ip, op, op_limit, anchor, copy)
  ------------------
  |  |  333|   630M|#define LITERAL(ip, op, op_limit, anchor, copy) {       \
  |  |  334|   630M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))          \
  |  |  ------------------
  |  |  |  |   39|   630M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 47, False: 630M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  335|   630M|    goto out;                                           \
  |  |  336|   630M|  *(op)++ = *(anchor)++;                                \
  |  |  337|   630M|  (ip) = (anchor);                                      \
  |  |  338|   630M|  (copy)++;                                             \
  |  |  339|   630M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|   630M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 11.9M, False: 618M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  340|  11.9M|    (copy) = 0;                                         \
  |  |  341|  11.9M|    *(op)++ = MAX_COPY-1;                               \
  |  |  ------------------
  |  |  |  |   49|  11.9M|#define MAX_COPY 32U
  |  |  ------------------
  |  |  342|  11.9M|  }                                                     \
  |  |  343|   630M|}
  ------------------
  655|      0|      continue;
  656|   630M|    }
  657|       |
  658|       |    /* last matched byte */
  659|   245M|    ip = anchor + 4;
  660|       |
  661|       |    /* distance is biased */
  662|   245M|    distance--;
  663|       |
  664|       |    /* get runs or matches; zero distance means a run */
  665|   245M|    ip = get_run_or_match(ip, ip_bound, ref, !distance);
  666|       |
  667|       |    /* length is biased, '1' means a match of 3 bytes */
  668|   245M|    ip -= ipshift;
  669|       |
  670|   245M|    unsigned len = (int)(ip - anchor);
  671|       |
  672|       |    // Encoding short lengths is expensive during decompression
  673|   245M|    if (len < minlen || (len <= 5 && distance >= MAX_DISTANCE)) {
  ------------------
  |  |   50|  99.7M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (673:9): [True: 96.2M, False: 149M]
  |  Branch (673:26): [True: 99.7M, False: 49.5M]
  |  Branch (673:38): [True: 197k, False: 99.5M]
  ------------------
  674|  99.6M|      LITERAL(ip, op, op_limit, anchor, copy)
  ------------------
  |  |  333|  99.6M|#define LITERAL(ip, op, op_limit, anchor, copy) {       \
  |  |  334|  99.6M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))          \
  |  |  ------------------
  |  |  |  |   39|  99.6M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 48, False: 99.6M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  335|  99.6M|    goto out;                                           \
  |  |  336|  99.6M|  *(op)++ = *(anchor)++;                                \
  |  |  337|  99.6M|  (ip) = (anchor);                                      \
  |  |  338|  99.6M|  (copy)++;                                             \
  |  |  339|  99.6M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|  99.6M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 623k, False: 99.0M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  340|   623k|    (copy) = 0;                                         \
  |  |  341|   623k|    *(op)++ = MAX_COPY-1;                               \
  |  |  ------------------
  |  |  |  |   49|   623k|#define MAX_COPY 32U
  |  |  ------------------
  |  |  342|   623k|  }                                                     \
  |  |  343|  99.6M|}
  ------------------
  675|      0|      continue;
  676|  99.6M|    }
  677|       |
  678|       |    /* if we have copied something, adjust the copy count */
  679|   146M|    if (copy)
  ------------------
  |  Branch (679:9): [True: 118M, False: 27.2M]
  ------------------
  680|       |      /* copy is biased, '0' means 1 byte copy */
  681|   118M|      *(op - copy - 1) = (uint8_t)(copy - 1);
  682|  27.2M|    else
  683|       |      /* back, to overwrite the copy count */
  684|  27.2M|      op--;
  685|       |    /* reset literal counter */
  686|   146M|    copy = 0;
  687|       |
  688|       |    /* encode the match */
  689|   149M|    if (distance < MAX_DISTANCE) {
  ------------------
  |  |   50|   146M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (689:9): [True: 149M, False: 18.4E]
  ------------------
  690|   149M|      if (len < 7) {
  ------------------
  |  Branch (690:11): [True: 107M, False: 41.4M]
  ------------------
  691|   107M|        MATCH_SHORT(op, op_limit, len, distance)
  ------------------
  |  |  355|   107M|#define MATCH_SHORT(op, op_limit, len, distance) {        \
  |  |  356|   107M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))            \
  |  |  ------------------
  |  |  |  |   39|   107M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 15, False: 107M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  357|   107M|    goto out;                                             \
  |  |  358|   107M|  *(op)++ = (uint8_t)(((len) << 5U) + ((distance) >> 8U));\
  |  |  359|   107M|  *(op)++ = (uint8_t)(((distance) & 255U));               \
  |  |  360|   107M|}
  ------------------
  692|   107M|      } else {
  693|   124M|        MATCH_LONG(op, op_limit, len, distance)
  ------------------
  |  |  362|  41.4M|#define MATCH_LONG(op, op_limit, len, distance) {       \
  |  |  363|  41.4M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))          \
  |  |  ------------------
  |  |  |  |   39|  41.4M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 41.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  364|  41.4M|    goto out;                                           \
  |  |  365|  41.4M|  *(op)++ = (uint8_t)((7U << 5U) + ((distance) >> 8U)); \
  |  |  366|   127M|  for ((len) -= 7; (len) >= 255; (len) -= 255) {        \
  |  |  ------------------
  |  |  |  Branch (366:20): [True: 86.0M, False: 41.4M]
  |  |  ------------------
  |  |  367|  86.0M|    if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))        \
  |  |  ------------------
  |  |  |  |   39|  86.0M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 86.0M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  368|  86.0M|      goto out;                                         \
  |  |  369|  86.0M|    *(op)++ = 255;                                      \
  |  |  370|  86.0M|  }                                                     \
  |  |  371|  41.4M|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 2))          \
  |  |  ------------------
  |  |  |  |   39|  41.4M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 44, False: 41.4M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  372|  41.4M|    goto out;                                           \
  |  |  373|  41.4M|  *(op)++ = (uint8_t)(len);                             \
  |  |  374|  41.4M|  *(op)++ = (uint8_t)(((distance) & 255U));             \
  |  |  375|  41.4M|}
  ------------------
  694|   124M|      }
  695|  18.4E|    } else {
  696|       |      /* far away, but not yet in the another galaxy... */
  697|  18.4E|      distance -= MAX_DISTANCE;
  ------------------
  |  |   50|  18.4E|#define MAX_DISTANCE 8191
  ------------------
  698|  18.4E|      if (len < 7) {
  ------------------
  |  Branch (698:11): [True: 21.2k, False: 18.4E]
  ------------------
  699|  21.2k|        MATCH_SHORT_FAR(op, op_limit, len, distance)
  ------------------
  |  |  377|  21.2k|#define MATCH_SHORT_FAR(op, op_limit, len, distance) {      \
  |  |  378|  21.2k|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 4))              \
  |  |  ------------------
  |  |  |  |   39|  21.2k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 21.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  379|  21.2k|    goto out;                                               \
  |  |  380|  21.2k|  *(op)++ = (uint8_t)(((len) << 5U) + 31);                  \
  |  |  381|  21.2k|  *(op)++ = 255;                                            \
  |  |  382|  21.2k|  *(op)++ = (uint8_t)((distance) >> 8U);                    \
  |  |  383|  21.2k|  *(op)++ = (uint8_t)((distance) & 255U);                   \
  |  |  384|  21.2k|}
  ------------------
  700|  18.4E|      } else {
  701|  18.4E|        MATCH_LONG_FAR(op, op_limit, len, distance)
  ------------------
  |  |  386|  18.4E|#define MATCH_LONG_FAR(op, op_limit, len, distance) {       \
  |  |  387|  18.4E|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))              \
  |  |  ------------------
  |  |  |  |   39|  18.4E|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 18.4E]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  388|  18.4E|    goto out;                                               \
  |  |  389|  18.4E|  *(op)++ = (7U << 5U) + 31;                                \
  |  |  390|  18.4E|  for ((len) -= 7; (len) >= 255; (len) -= 255) {            \
  |  |  ------------------
  |  |  |  Branch (390:20): [True: 747k, False: 18.4E]
  |  |  ------------------
  |  |  391|   747k|    if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 1))            \
  |  |  ------------------
  |  |  |  |   39|   747k|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 747k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  392|   747k|      goto out;                                             \
  |  |  393|   747k|    *(op)++ = 255;                                          \
  |  |  394|   747k|  }                                                         \
  |  |  395|  18.4E|  if (BLOSCLZ_UNLIKELY((op_limit) - (op) < 4))              \
  |  |  ------------------
  |  |  |  |   39|  18.4E|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 18.4E]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  396|  18.4E|    goto out;                                               \
  |  |  397|  18.4E|  *(op)++ = (uint8_t)(len);                                 \
  |  |  398|  18.4E|  *(op)++ = 255;                                            \
  |  |  399|  18.4E|  *(op)++ = (uint8_t)((distance) >> 8U);                    \
  |  |  400|  18.4E|  *(op)++ = (uint8_t)((distance) & 255U);                   \
  |  |  401|  18.4E|}
  ------------------
  702|  18.4E|      }
  703|  18.4E|    }
  704|       |
  705|       |    /* Advance past the biased match length.  Update the boundary hashes on
  706|       |     * the next iteration, preserving the old ip-1 entry for the extra candidate. */
  707|   146M|    ip += 2;
  708|       |
  709|   146M|    if (BLOSCLZ_UNLIKELY(op_limit - op < 1))
  ------------------
  |  |   39|   146M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 45, False: 146M]
  |  |  ------------------
  ------------------
  710|     45|      goto out;
  711|       |
  712|       |    /* assuming literal copy */
  713|   146M|    *op++ = MAX_COPY - 1;
  ------------------
  |  |   49|   146M|#define MAX_COPY 32U
  ------------------
  714|   146M|  }
  715|       |
  716|       |  /* left-over as literal copy */
  717|  14.0M|  while (BLOSCLZ_UNLIKELY(ip <= ip_bound)) {
  ------------------
  |  |   39|  14.0M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 10.9M, False: 3.07M]
  |  |  ------------------
  ------------------
  718|  10.9M|    if (BLOSCLZ_UNLIKELY(op_limit - op < 2)) goto out;
  ------------------
  |  |   39|  10.9M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 417, False: 10.9M]
  |  |  ------------------
  ------------------
  719|  10.9M|    *op++ = *ip++;
  720|  10.9M|    copy++;
  721|  10.9M|    if (BLOSCLZ_UNLIKELY(copy == MAX_COPY)) {
  ------------------
  |  |   39|  10.9M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 1.48k, False: 10.9M]
  |  |  ------------------
  ------------------
  722|  1.48k|      copy = 0;
  723|  1.48k|      *op++ = MAX_COPY - 1;
  ------------------
  |  |   49|  1.48k|#define MAX_COPY 32U
  ------------------
  724|  1.48k|    }
  725|  10.9M|  }
  726|       |
  727|       |  /* if we have copied something, adjust the copy length */
  728|  3.07M|  if (copy)
  ------------------
  |  Branch (728:7): [True: 3.08M, False: 18.4E]
  ------------------
  729|  3.08M|    *(op - copy - 1) = (uint8_t)(copy - 1);
  730|  18.4E|  else
  731|  18.4E|    op--;
  732|       |
  733|       |  /* marker for blosclz */
  734|  3.07M|  *(uint8_t*)output |= (1U << 5U);
  735|       |
  736|  3.07M|  return (int)(op - (uint8_t*)output);
  737|       |
  738|   166k|  out:
  739|   166k|  return 0;
  740|  3.07M|}
blosclz.c:htab_reset:
  519|  6.58M|                                          const int tagged) {
  520|  6.58M|  if (!tagged) {
  ------------------
  |  Branch (520:7): [True: 2.61M, False: 3.96M]
  ------------------
  521|  2.61M|    memset(htab, 0, (1U << hashlog) * sizeof(uint32_t));
  522|       |    /* untagged entries (< span) must look stale to the next tagged pass */
  523|  2.61M|    if (state != NULL && state->base < (uint32_t)span) {
  ------------------
  |  Branch (523:9): [True: 2.61M, False: 101]
  |  Branch (523:26): [True: 9.76k, False: 2.60M]
  ------------------
  524|  9.76k|      state->base = (uint32_t)span;
  525|  9.76k|    }
  526|  2.61M|    return 0;
  527|  2.61M|  }
  528|  3.96M|  if (state->base > UINT32_MAX - (uint32_t)span) {
  ------------------
  |  Branch (528:7): [True: 0, False: 3.96M]
  ------------------
  529|      0|    memset(state->htab, 0, sizeof(state->htab));
  530|      0|    state->base = 0;
  531|      0|  }
  532|  3.96M|  uint32_t base = state->base;
  533|  3.96M|  state->base += (uint32_t)span;
  534|  3.96M|  return base;
  535|  6.58M|}
blosclz.c:get_cratio:
  417|  3.50M|                                        int8_t hashlog, uint32_t base, const int tagged) {
  418|  3.50M|  uint8_t* ip = ibase;
  419|  3.50M|  int32_t oc = 0;
  420|  3.50M|  const uint16_t hashlen = (1U << (uint8_t)hashlog);
  421|  3.50M|  uint32_t hval;
  422|  3.50M|  uint32_t seq;
  423|  3.50M|  uint8_t copy;
  424|       |  // Make a tradeoff between testing too much and too little
  425|  3.50M|  uint16_t limit = (maxlen > hashlen) ? hashlen : maxlen;
  ------------------
  |  Branch (425:20): [True: 1.49M, False: 2.01M]
  ------------------
  426|  3.50M|  uint8_t* ip_bound = ibase + limit - 1;
  427|  3.50M|  uint8_t* ip_limit = ibase + limit - 12;
  428|       |
  429|       |
  430|       |  /* we start with literal copy */
  431|  3.50M|  copy = 4;
  432|  3.50M|  oc += 5;
  433|       |
  434|       |  /* main loop */
  435|  27.3M|  while (BLOSCLZ_LIKELY(ip < ip_limit)) {
  ------------------
  |  |   38|  27.3M|#define BLOSCLZ_LIKELY(c)    (c)
  |  |  ------------------
  |  |  |  Branch (38:30): [True: 23.8M, False: 3.50M]
  |  |  ------------------
  ------------------
  436|  23.8M|    const uint8_t* ref;
  437|  23.8M|    unsigned distance;
  438|  23.8M|    uint8_t* anchor = ip;    /* comparison starting-point */
  439|       |
  440|       |    /* find potential match */
  441|  23.8M|    seq = BLOSCLZ_READU32(ip);
  ------------------
  |  |   58|  23.8M|  #define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
  ------------------
  442|  23.8M|    HASH_FUNCTION(hval, seq, hashlog)
  ------------------
  |  |   64|  23.8M|#define HASH_FUNCTION(v, s, h) {      \
  |  |   65|  23.8M|  (v) = ((s) * 2654435761U) >> (32U - (h)); \
  |  |   66|  23.8M|}
  ------------------
  443|  23.8M|    ref = ibase + HTAB_GET(htab[hval], base);
  ------------------
  |  |  407|  23.8M|#define HTAB_GET(entry, base) (tagged ? ((entry) >= (base) ? (entry) - (base) : 0) : (entry))
  |  |  ------------------
  |  |  |  Branch (407:32): [True: 10.6M, False: 13.1M]
  |  |  |  Branch (407:42): [True: 7.09M, False: 3.59M]
  |  |  ------------------
  ------------------
  444|       |
  445|       |    /* calculate distance to the match */
  446|  23.8M|    distance = (unsigned int)(anchor - ref);
  447|       |
  448|       |    /* update hash table */
  449|  23.8M|    htab[hval] = (uint32_t) (anchor - ibase) + base;
  450|       |
  451|  23.8M|    if (distance == 0 || (distance >= MAX_FARDISTANCE)) {
  ------------------
  |  |   51|  20.4M|#define MAX_FARDISTANCE (65535 + MAX_DISTANCE - 1)
  |  |  ------------------
  |  |  |  |   50|  20.4M|#define MAX_DISTANCE 8191
  |  |  ------------------
  ------------------
  |  Branch (451:9): [True: 3.36M, False: 20.4M]
  |  Branch (451:26): [True: 18.4E, False: 20.4M]
  ------------------
  452|  3.36M|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  345|  3.36M|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  346|  3.36M|  oc++; (anchor)++;                                     \
  |  |  347|  3.36M|  (ip) = (anchor);                                      \
  |  |  348|  3.36M|  (copy)++;                                             \
  |  |  349|  3.36M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|  3.36M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 0, False: 3.36M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  350|      0|    (copy) = 0;                                         \
  |  |  351|      0|    oc++;                                               \
  |  |  352|      0|  }                                                     \
  |  |  353|  3.36M|}
  ------------------
  453|  3.36M|      continue;
  454|  3.36M|    }
  455|       |
  456|       |    /* is this a match? check the first 4 bytes */
  457|  20.4M|    if (BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip)) {
  ------------------
  |  |   58|  20.4M|  #define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
  ------------------
                  if (BLOSCLZ_READU32(ref) == BLOSCLZ_READU32(ip)) {
  ------------------
  |  |   58|  20.4M|  #define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
  ------------------
  |  Branch (457:9): [True: 13.5M, False: 6.86M]
  ------------------
  458|  13.5M|      ref += 4;
  459|  13.5M|    }
  460|  6.86M|    else {
  461|       |      /* no luck, copy as a literal */
  462|  6.86M|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  345|  6.86M|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  346|  6.86M|  oc++; (anchor)++;                                     \
  |  |  347|  6.86M|  (ip) = (anchor);                                      \
  |  |  348|  6.86M|  (copy)++;                                             \
  |  |  349|  6.86M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|  6.86M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 13.4k, False: 6.85M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  350|  13.4k|    (copy) = 0;                                         \
  |  |  351|  13.4k|    oc++;                                               \
  |  |  352|  13.4k|  }                                                     \
  |  |  353|  6.86M|}
  ------------------
  463|  6.86M|      continue;
  464|  6.86M|    }
  465|       |
  466|       |    /* last matched byte */
  467|  13.5M|    ip = anchor + 4;
  468|       |
  469|       |    /* distance is biased */
  470|  13.5M|    distance--;
  471|       |
  472|       |    /* get runs or matches; zero distance means a run */
  473|  13.5M|    ip = get_run_or_match(ip, ip_bound, ref, !distance);
  474|       |
  475|  13.5M|    ip -= ipshift;
  476|  13.5M|    int len = (int)(ip - anchor);
  477|  13.5M|    if (len < minlen) {
  ------------------
  |  Branch (477:9): [True: 2.97M, False: 10.6M]
  ------------------
  478|  2.97M|      LITERAL2(ip, anchor, copy)
  ------------------
  |  |  345|  2.97M|#define LITERAL2(ip, anchor, copy) {                    \
  |  |  346|  2.97M|  oc++; (anchor)++;                                     \
  |  |  347|  2.97M|  (ip) = (anchor);                                      \
  |  |  348|  2.97M|  (copy)++;                                             \
  |  |  349|  2.97M|  if (BLOSCLZ_UNLIKELY((copy) == MAX_COPY)) {           \
  |  |  ------------------
  |  |  |  |   39|  2.97M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (39:30): [True: 1.15k, False: 2.96M]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  350|  1.15k|    (copy) = 0;                                         \
  |  |  351|  1.15k|    oc++;                                               \
  |  |  352|  1.15k|  }                                                     \
  |  |  353|  2.97M|}
  ------------------
  479|  2.97M|      continue;
  480|  2.97M|    }
  481|       |
  482|       |    /* if we haven't copied anything, adjust the output counter */
  483|  10.6M|    if (!copy)
  ------------------
  |  Branch (483:9): [True: 1.78M, False: 8.82M]
  ------------------
  484|  1.78M|      oc--;
  485|       |    /* reset literal counter */
  486|  10.6M|    copy = 0;
  487|       |
  488|       |    /* encode the match */
  489|  10.6M|    if (distance < MAX_DISTANCE) {
  ------------------
  |  |   50|  10.6M|#define MAX_DISTANCE 8191
  ------------------
  |  Branch (489:9): [True: 10.6M, False: 18.4E]
  ------------------
  490|  10.6M|      if (len >= 7) {
  ------------------
  |  Branch (490:11): [True: 6.76M, False: 3.84M]
  ------------------
  491|  6.76M|        oc += ((len - 7) / 255) + 1;
  492|  6.76M|      }
  493|  10.6M|      oc += 2;
  494|  10.6M|    }
  495|  18.4E|    else {
  496|       |      /* far away, but not yet in the another galaxy... */
  497|  18.4E|      if (len >= 7) {
  ------------------
  |  Branch (497:11): [True: 1.32k, False: 18.4E]
  ------------------
  498|  1.32k|        oc += ((len - 7) / 255) + 1;
  499|  1.32k|      }
  500|  18.4E|      oc += 4;
  501|  18.4E|    }
  502|       |
  503|       |    /* update the hash at match boundary */
  504|  10.6M|    seq = BLOSCLZ_READU32(ip);
  ------------------
  |  |   58|  10.6M|  #define BLOSCLZ_READU32(p) *((const uint32_t*)(p))
  ------------------
  505|  10.6M|    HASH_FUNCTION(hval, seq, hashlog)
  ------------------
  |  |   64|  10.6M|#define HASH_FUNCTION(v, s, h) {      \
  |  |   65|  10.6M|  (v) = ((s) * 2654435761U) >> (32U - (h)); \
  |  |   66|  10.6M|}
  ------------------
  506|  10.6M|    htab[hval] = (uint32_t)(ip++ - ibase) + base;
  507|  10.6M|    ip++;
  508|       |    /* assuming literal copy */
  509|  10.6M|    oc++;
  510|  10.6M|  }
  511|       |
  512|  3.50M|  double ic = (double)(ip - ibase);
  513|  3.50M|  return ic / (double)oc;
  514|  3.50M|}
blosclz.c:get_run_or_match:
  299|   258M|static uint8_t* get_run_or_match(uint8_t* ip, uint8_t* ip_bound, const uint8_t* ref, bool run) {
  300|   258M|  if (BLOSCLZ_UNLIKELY(run)) {
  ------------------
  |  |   39|   258M|#define BLOSCLZ_UNLIKELY(c)  (c)
  |  |  ------------------
  |  |  |  Branch (39:30): [True: 159M, False: 98.8M]
  |  |  ------------------
  ------------------
  301|       |#if defined(__AVX2__)
  302|       |    // Extensive experiments on AMD Ryzen3 say that regular get_run is faster
  303|       |    // ip = get_run_32(ip, ip_bound, ref);
  304|       |    ip = get_run(ip, ip_bound, ref);
  305|       |#elif defined(__SSE2__)
  306|       |    // Extensive experiments on AMD Ryzen3 say that regular get_run is faster
  307|       |    // ip = get_run_16(ip, ip_bound, ref);
  308|   159M|    ip = get_run(ip, ip_bound, ref);
  309|       |#elif defined(__aarch64__) || defined(_M_ARM64)
  310|       |    ip = get_run_neon(ip, ip_bound, ref);
  311|       |#else
  312|       |    ip = get_run(ip, ip_bound, ref);
  313|       |#endif
  314|   159M|  }
  315|  98.8M|  else {
  316|       |#if defined(__AVX2__)
  317|       |    // Extensive experiments on AMD Ryzen3 say that regular get_match_16 is faster
  318|       |    // ip = get_match_32(ip, ip_bound, ref);
  319|       |    ip = get_match_16(ip, ip_bound, ref);
  320|       |#elif defined(__SSE2__)
  321|       |    ip = get_match_16(ip, ip_bound, ref);
  322|       |#elif defined(__aarch64__) || defined(_M_ARM64)
  323|       |    ip = get_match_neon(ip, ip_bound, ref);
  324|       |#else
  325|       |    ip = get_match(ip, ip_bound, ref);
  326|       |#endif
  327|  98.8M|  }
  328|       |
  329|   258M|  return ip;
  330|   258M|}
blosclz.c:get_run:
  124|   159M|static uint8_t *get_run(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
  125|   159M|  uint8_t x = ip[-1];
  126|   159M|  int64_t value, value2;
  127|       |  /* Broadcast the value for every byte in a 64-bit register */
  128|   159M|  memset(&value, x, 8);
  129|       |  /* safe because the outer check against ip limit */
  130|  1.43G|  while (ip < (ip_bound - sizeof(int64_t))) {
  ------------------
  |  Branch (130:10): [True: 1.43G, False: 3.89M]
  ------------------
  131|       |#if defined(BLOSC_STRICT_ALIGN)
  132|       |    memcpy(&value2, ref, 8);
  133|       |#else
  134|  1.43G|    value2 = ((int64_t*)ref)[0];
  135|  1.43G|#endif
  136|  1.43G|    if (value != value2) {
  ------------------
  |  Branch (136:9): [True: 155M, False: 1.27G]
  ------------------
  137|       |      /* Return the byte that starts to differ */
  138|   592M|      while (*ref++ == x) ip++;
  ------------------
  |  Branch (138:14): [True: 436M, False: 155M]
  ------------------
  139|   155M|      return ip;
  140|   155M|    }
  141|  1.27G|    else {
  142|  1.27G|      ip += 8;
  143|  1.27G|      ref += 8;
  144|  1.27G|    }
  145|  1.43G|  }
  146|       |  /* Look into the remainder */
  147|  20.3M|  while ((ip < ip_bound) && (*ref++ == x)) ip++;
  ------------------
  |  Branch (147:10): [True: 16.6M, False: 3.76M]
  |  Branch (147:29): [True: 16.4M, False: 128k]
  ------------------
  148|  3.89M|  return ip;
  149|   159M|}
blosclz.c:get_match_16:
  175|   102M|static uint8_t *get_match_16(uint8_t *ip, const uint8_t *ip_bound, const uint8_t *ref) {
  176|   102M|  __m128i value, value2, cmp;
  177|       |
  178|  1.26G|  while (ip < (ip_bound - sizeof(__m128i))) {
  ------------------
  |  Branch (178:10): [True: 1.26G, False: 1.05M]
  ------------------
  179|  1.26G|    value = _mm_loadu_si128((__m128i *) ip);
  180|  1.26G|    value2 = _mm_loadu_si128((__m128i *) ref);
  181|  1.26G|    cmp = _mm_cmpeq_epi32(value, value2);
  182|  1.26G|    if (_mm_movemask_epi8(cmp) != 0xFFFF) {
  ------------------
  |  Branch (182:9): [True: 101M, False: 1.16G]
  ------------------
  183|       |      /* Return the byte that starts to differ */
  184|   440M|      while (*ref++ == *ip++) {}
  ------------------
  |  Branch (184:14): [True: 339M, False: 101M]
  ------------------
  185|   101M|      return ip;
  186|   101M|    }
  187|  1.16G|    else {
  188|  1.16G|      ip += sizeof(__m128i);
  189|  1.16G|      ref += sizeof(__m128i);
  190|  1.16G|    }
  191|  1.26G|  }
  192|       |  /* Look into the remainder */
  193|  8.04M|  while ((ip < ip_bound) && (*ref++ == *ip++)) {}
  ------------------
  |  Branch (193:10): [True: 7.38M, False: 656k]
  |  Branch (193:29): [True: 6.98M, False: 398k]
  ------------------
  194|  1.05M|  return ip;
  195|   102M|}
blosclz.c:wild_copy_16:
  828|   137M|static inline void wild_copy_16(uint8_t *out, const uint8_t *from, uint8_t *end) {
  829|  1.44G|  do { memcpy(out, from, 16); out += 16; from += 16; } while (out < end);
  ------------------
  |  Branch (829:63): [True: 1.31G, False: 137M]
  ------------------
  830|   137M|}
blosclz.c:wild_copy:
  813|  12.1M|static inline void wild_copy(uint8_t *out, const uint8_t* from, uint8_t* end) {
  814|  12.1M|  uint8_t* d = out;
  815|  12.1M|  const uint8_t* s = from;
  816|  12.1M|  uint8_t* const e = end;
  817|       |
  818|   161M|  do { memcpy(d,s,8); d+=8; s+=8; } while (d<e);
  ------------------
  |  Branch (818:44): [True: 148M, False: 12.1M]
  ------------------
  819|  12.1M|}

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

delta_decoder:
   97|    862|                   int32_t typesize, uint8_t* dest) {
   98|    862|  int32_t i;
   99|       |
  100|    862|  if (offset == 0) {
  ------------------
  |  Branch (100:7): [True: 650, False: 212]
  ------------------
  101|       |    /* Decode delta for the reference block */
  102|    650|    switch (typesize) {
  103|    140|      case 1:
  ------------------
  |  Branch (103:7): [True: 140, False: 510]
  ------------------
  104|   423M|        for (i = 1; i < nbytes; i++) {
  ------------------
  |  Branch (104:21): [True: 423M, False: 140]
  ------------------
  105|   423M|          dest[i] ^= dref[i-1];
  106|   423M|        }
  107|    140|        break;
  108|     89|      case 2:
  ------------------
  |  Branch (108:7): [True: 89, False: 561]
  ------------------
  109|  4.63M|        for (i = 1; i < nbytes / 2; i++) {
  ------------------
  |  Branch (109:21): [True: 4.63M, False: 89]
  ------------------
  110|  4.63M|          ((uint16_t *)dest)[i] ^= ((uint16_t *)dref)[i-1];
  111|  4.63M|        }
  112|     89|        break;
  113|     65|      case 4:
  ------------------
  |  Branch (113:7): [True: 65, False: 585]
  ------------------
  114|   152M|        for (i = 1; i < nbytes / 4; i++) {
  ------------------
  |  Branch (114:21): [True: 152M, False: 65]
  ------------------
  115|   152M|          ((uint32_t *)dest)[i] ^= ((uint32_t *)dref)[i-1];
  116|   152M|        }
  117|     65|        break;
  118|    196|      case 8:
  ------------------
  |  Branch (118:7): [True: 196, False: 454]
  ------------------
  119|  56.4M|        for (i = 1; i < nbytes / 8; i++) {
  ------------------
  |  Branch (119:21): [True: 56.4M, False: 196]
  ------------------
  120|  56.4M|          ((uint64_t *)dest)[i] ^= ((uint64_t *)dref)[i-1];
  121|  56.4M|        }
  122|    196|        break;
  123|    160|      default:
  ------------------
  |  Branch (123:7): [True: 160, False: 490]
  ------------------
  124|    160|        if ((typesize % 8) == 0) {
  ------------------
  |  Branch (124:13): [True: 78, False: 82]
  ------------------
  125|     78|          delta_decoder(dref, offset, nbytes, 8, dest);
  126|     82|        } else {
  127|     82|          delta_decoder(dref, offset, nbytes, 1, dest);
  128|     82|        }
  129|    650|    }
  130|    650|  } else {
  131|       |    /* Decode delta for the non-reference blocks */
  132|    212|    switch (typesize) {
  133|     57|      case 1:
  ------------------
  |  Branch (133:7): [True: 57, False: 155]
  ------------------
  134|  84.2M|        for (i = 0; i < nbytes; i++) {
  ------------------
  |  Branch (134:21): [True: 84.2M, False: 57]
  ------------------
  135|  84.2M|          dest[i] ^= dref[i];
  136|  84.2M|        }
  137|     57|        break;
  138|     26|      case 2:
  ------------------
  |  Branch (138:7): [True: 26, False: 186]
  ------------------
  139|  1.87M|        for (i = 0; i < nbytes / 2; i++) {
  ------------------
  |  Branch (139:21): [True: 1.87M, False: 26]
  ------------------
  140|  1.87M|          ((uint16_t *)dest)[i] ^= ((uint16_t *)dref)[i];
  141|  1.87M|        }
  142|     26|        break;
  143|     22|      case 4:
  ------------------
  |  Branch (143:7): [True: 22, False: 190]
  ------------------
  144|  13.4M|        for (i = 0; i < nbytes / 4; i++) {
  ------------------
  |  Branch (144:21): [True: 13.4M, False: 22]
  ------------------
  145|  13.4M|          ((uint32_t *)dest)[i] ^= ((uint32_t *)dref)[i];
  146|  13.4M|        }
  147|     22|        break;
  148|     47|      case 8:
  ------------------
  |  Branch (148:7): [True: 47, False: 165]
  ------------------
  149|  37.1M|        for (i = 0; i < nbytes / 8; i++) {
  ------------------
  |  Branch (149:21): [True: 37.1M, False: 47]
  ------------------
  150|  37.1M|          ((uint64_t *)dest)[i] ^= ((uint64_t *)dref)[i];
  151|  37.1M|        }
  152|     47|        break;
  153|     60|      default:
  ------------------
  |  Branch (153:7): [True: 60, False: 152]
  ------------------
  154|     60|        if ((typesize % 8) == 0) {
  ------------------
  |  Branch (154:13): [True: 28, False: 32]
  ------------------
  155|     28|          delta_decoder(dref, offset, nbytes, 8, dest);
  156|     32|        } else {
  157|     32|          delta_decoder(dref, offset, nbytes, 1, dest);
  158|     32|        }
  159|    212|    }
  160|    212|  }
  161|    862|}

fastcopy:
  504|  1.22M|unsigned char *fastcopy(unsigned char *out, const unsigned char *from, unsigned len) {
  505|  1.22M|  switch (len) {
  506|  4.17k|    case 32:
  ------------------
  |  Branch (506:5): [True: 4.17k, False: 1.21M]
  ------------------
  507|  4.17k|      return copy_32_bytes(out, from);
  508|  21.2k|    case 16:
  ------------------
  |  Branch (508:5): [True: 21.2k, False: 1.20M]
  ------------------
  509|  21.2k|      return copy_16_bytes(out, from);
  510|  5.09k|    case 8:
  ------------------
  |  Branch (510:5): [True: 5.09k, False: 1.21M]
  ------------------
  511|  5.09k|      return copy_8_bytes(out, from);
  512|  1.19M|    default: {
  ------------------
  |  Branch (512:5): [True: 1.19M, False: 30.4k]
  ------------------
  513|  1.19M|    }
  514|  1.22M|  }
  515|  1.19M|  if (len < 8) {
  ------------------
  |  Branch (515:7): [True: 13.6k, False: 1.17M]
  ------------------
  516|  13.6k|    return copy_bytes(out, from, len);
  517|  13.6k|  }
  518|  1.17M|#if defined(__SSE2__)
  519|  1.17M|  if (len < 16) {
  ------------------
  |  Branch (519:7): [True: 77.3k, False: 1.10M]
  ------------------
  520|  77.3k|    return chunk_memcpy(out, from, len);
  521|  77.3k|  }
  522|  1.10M|#if !defined(__AVX2__)
  523|  1.10M|  return chunk_memcpy_unaligned(out, from, len);
  524|       |#else
  525|       |  if (len < 32) {
  526|       |    return chunk_memcpy_16(out, from, len);
  527|       |  }
  528|       |  return chunk_memcpy_unaligned(out, from, len);
  529|       |#endif  // !__AVX2__
  530|       |#else
  531|       |  return chunk_memcpy(out, from, len);
  532|       |#endif  // __SSE2__
  533|  1.17M|}
copy_match:
  537|  11.0M|unsigned char* copy_match(unsigned char *out, const unsigned char *from, unsigned len) {
  538|       |#if defined(__AVX2__)
  539|       |  unsigned sz = sizeof(__m256i);
  540|       |#elif defined(__SSE2__)
  541|       |  unsigned sz = sizeof(__m128i);
  542|       |#else
  543|       |  unsigned sz = sizeof(uint64_t);
  544|       |#endif
  545|       |
  546|       |#if ((defined(__GNUC__) && BLOSC_GCC_VERSION < 800) && !defined(__clang__) && !defined(__ICC) && !defined(__ICL))
  547|       |  // GCC < 8 in fully optimization mode seems to have problems with the code further below so stop here
  548|       |  for (; len > 0; len--) {
  549|       |    *out++ = *from++;
  550|       |  }
  551|       |  return out;
  552|       |#endif
  553|       |
  554|       |  // If out and from are away more than the size of the copy, then a fastcopy is safe
  555|  11.0M|  unsigned overlap_dist = (unsigned) (out - from);
  556|  11.0M|  if (overlap_dist > sz) {
  ------------------
  |  Branch (556:7): [True: 1.22M, False: 9.86M]
  ------------------
  557|  1.22M|    return fastcopy(out, from, len);
  558|  1.22M|  }
  559|       |
  560|       |  // Otherwise we need to be more careful so as not to overwrite destination
  561|  9.86M|  switch (overlap_dist) {
  562|      0|    case 32:
  ------------------
  |  Branch (562:5): [True: 0, False: 9.86M]
  ------------------
  563|      0|      for (; len >= 32; len -= 32) {
  ------------------
  |  Branch (563:14): [True: 0, False: 0]
  ------------------
  564|      0|        out = copy_32_bytes(out, from);
  565|      0|      }
  566|      0|      break;
  567|      0|    case 30:
  ------------------
  |  Branch (567:5): [True: 0, False: 9.86M]
  ------------------
  568|      0|      for (; len >= 30; len -= 30) {
  ------------------
  |  Branch (568:14): [True: 0, False: 0]
  ------------------
  569|      0|        out = copy_16_bytes(out, from);
  570|      0|        out = copy_8_bytes(out, from + 16);
  571|      0|        out = copy_4_bytes(out, from + 24);
  572|      0|        out = copy_2_bytes(out, from + 28);
  573|      0|      }
  574|      0|      break;
  575|      0|    case 28:
  ------------------
  |  Branch (575:5): [True: 0, False: 9.86M]
  ------------------
  576|      0|      for (; len >= 28; len -= 28) {
  ------------------
  |  Branch (576:14): [True: 0, False: 0]
  ------------------
  577|      0|        out = copy_16_bytes(out, from);
  578|      0|        out = copy_8_bytes(out, from + 16);
  579|      0|        out = copy_4_bytes(out, from + 24);
  580|      0|      }
  581|      0|      break;
  582|      0|    case 26:
  ------------------
  |  Branch (582:5): [True: 0, False: 9.86M]
  ------------------
  583|      0|      for (; len >= 26; len -= 26) {
  ------------------
  |  Branch (583:14): [True: 0, False: 0]
  ------------------
  584|      0|        out = copy_16_bytes(out, from);
  585|      0|        out = copy_8_bytes(out, from + 16);
  586|      0|        out = copy_2_bytes(out, from + 24);
  587|      0|      }
  588|      0|      break;
  589|      0|    case 24:
  ------------------
  |  Branch (589:5): [True: 0, False: 9.86M]
  ------------------
  590|      0|      for (; len >= 24; len -= 24) {
  ------------------
  |  Branch (590:14): [True: 0, False: 0]
  ------------------
  591|      0|        out = copy_16_bytes(out, from);
  592|      0|        out = copy_8_bytes(out, from + 16);
  593|      0|      }
  594|      0|      break;
  595|      0|    case 22:
  ------------------
  |  Branch (595:5): [True: 0, False: 9.86M]
  ------------------
  596|      0|      for (; len >= 22; len -= 22) {
  ------------------
  |  Branch (596:14): [True: 0, False: 0]
  ------------------
  597|      0|        out = copy_16_bytes(out, from);
  598|      0|        out = copy_4_bytes(out, from + 16);
  599|      0|        out = copy_2_bytes(out, from + 20);
  600|      0|      }
  601|      0|      break;
  602|      0|    case 20:
  ------------------
  |  Branch (602:5): [True: 0, False: 9.86M]
  ------------------
  603|      0|      for (; len >= 20; len -= 20) {
  ------------------
  |  Branch (603:14): [True: 0, False: 0]
  ------------------
  604|      0|        out = copy_16_bytes(out, from);
  605|      0|        out = copy_4_bytes(out, from + 16);
  606|      0|      }
  607|      0|      break;
  608|      0|    case 18:
  ------------------
  |  Branch (608:5): [True: 0, False: 9.86M]
  ------------------
  609|      0|      for (; len >= 18; len -= 18) {
  ------------------
  |  Branch (609:14): [True: 0, False: 0]
  ------------------
  610|      0|        out = copy_16_bytes(out, from);
  611|      0|        out = copy_2_bytes(out, from + 16);
  612|      0|      }
  613|      0|      break;
  614|  9.52k|    case 16:
  ------------------
  |  Branch (614:5): [True: 9.52k, False: 9.85M]
  ------------------
  615|   584k|      for (; len >= 16; len -= 16) {
  ------------------
  |  Branch (615:14): [True: 575k, False: 9.52k]
  ------------------
  616|   575k|        out = copy_16_bytes(out, from);
  617|   575k|      }
  618|  9.52k|      break;
  619|  42.4k|    case 8:
  ------------------
  |  Branch (619:5): [True: 42.4k, False: 9.82M]
  ------------------
  620|  4.97M|      for (; len >= 8; len -= 8) {
  ------------------
  |  Branch (620:14): [True: 4.93M, False: 42.4k]
  ------------------
  621|  4.93M|        out = copy_8_bytes(out, from);
  622|  4.93M|      }
  623|  42.4k|      break;
  624|  2.26M|    case 4:
  ------------------
  |  Branch (624:5): [True: 2.26M, False: 7.60M]
  ------------------
  625|  2.19G|      for (; len >= 4; len -= 4) {
  ------------------
  |  Branch (625:14): [True: 2.18G, False: 2.26M]
  ------------------
  626|  2.18G|        out = copy_4_bytes(out, from);
  627|  2.18G|      }
  628|  2.26M|      break;
  629|   196k|    case 2:
  ------------------
  |  Branch (629:5): [True: 196k, False: 9.66M]
  ------------------
  630|   874k|      for (; len >= 2; len -= 2) {
  ------------------
  |  Branch (630:14): [True: 677k, False: 196k]
  ------------------
  631|   677k|        out = copy_2_bytes(out, from);
  632|   677k|      }
  633|   196k|      break;
  634|  7.35M|    default:
  ------------------
  |  Branch (634:5): [True: 7.35M, False: 2.50M]
  ------------------
  635|  6.06G|      for (; len > 0; len--) {
  ------------------
  |  Branch (635:14): [True: 6.06G, False: 7.35M]
  ------------------
  636|  6.06G|        *out++ = *from++;
  637|  6.06G|      }
  638|  9.86M|  }
  639|       |
  640|       |  // Copy the leftovers
  641|  13.1M|  for (; len > 0; len--) {
  ------------------
  |  Branch (641:10): [True: 3.32M, False: 9.86M]
  ------------------
  642|  3.32M|    *out++ = *from++;
  643|  3.32M|  }
  644|       |
  645|  9.86M|  return out;
  646|  9.86M|}
fastcopy.c:copy_32_bytes:
  118|  4.17k|static inline unsigned char *copy_32_bytes(unsigned char *out, const unsigned char *from) {
  119|       |#if defined(__AVX2__)
  120|       |  __m256i chunk;
  121|       |  chunk = _mm256_loadu_si256((__m256i*)from);
  122|       |  _mm256_storeu_si256((__m256i*)out, chunk);
  123|       |  out += 32;
  124|       |#elif defined(__SSE2__)
  125|       |  __m128i chunk;
  126|  4.17k|  chunk = _mm_loadu_si128((__m128i*)from);
  127|  4.17k|  _mm_storeu_si128((__m128i*)out, chunk);
  128|  4.17k|  from += 16; out += 16;
  129|  4.17k|  chunk = _mm_loadu_si128((__m128i*)from);
  130|  4.17k|  _mm_storeu_si128((__m128i*)out, chunk);
  131|  4.17k|  out += 16;
  132|       |#elif !defined(BLOSC_STRICT_ALIGN)
  133|       |  *(uint64_t*)out = *(uint64_t*)from;
  134|       |  from += 8; out += 8;
  135|       |  *(uint64_t*)out = *(uint64_t*)from;
  136|       |  from += 8; out += 8;
  137|       |  *(uint64_t*)out = *(uint64_t*)from;
  138|       |  from += 8; out += 8;
  139|       |  *(uint64_t*)out = *(uint64_t*)from;
  140|       |  from += 8; out += 8;
  141|       |#else
  142|       |  int i;
  143|       |  for (i = 0; i < 32; i++) {
  144|       |    *out++ = *from++;
  145|       |  }
  146|       |#endif
  147|  4.17k|  return out;
  148|  4.17k|}
fastcopy.c:copy_16_bytes:
   98|   377M|static inline unsigned char *copy_16_bytes(unsigned char *out, const unsigned char *from) {
   99|   377M|#if defined(__SSE2__)
  100|   377M|  __m128i chunk;
  101|   377M|  chunk = _mm_loadu_si128((__m128i*)from);
  102|   377M|  _mm_storeu_si128((__m128i*)out, chunk);
  103|   377M|  out += 16;
  104|       |#elif !defined(BLOSC_STRICT_ALIGN)
  105|       |  *(uint64_t*)out = *(uint64_t*)from;
  106|       |   from += 8; out += 8;
  107|       |   *(uint64_t*)out = *(uint64_t*)from;
  108|       |   from += 8; out += 8;
  109|       |#else
  110|       |   int i;
  111|       |   for (i = 0; i < 16; i++) {
  112|       |     *out++ = *from++;
  113|       |   }
  114|       |#endif
  115|   377M|  return out;
  116|   377M|}
fastcopy.c:copy_8_bytes:
   86|  5.09M|static inline unsigned char *copy_8_bytes(unsigned char *out, const unsigned char *from) {
   87|       |#if defined(BLOSC_STRICT_ALIGN)
   88|       |  uint64_t chunk;
   89|       |  memcpy(&chunk, from, 8);
   90|       |  memcpy(out, &chunk, 8);
   91|       |#else
   92|  5.09M|  *(uint64_t *) out = *(uint64_t *) from;
   93|  5.09M|#endif
   94|  5.09M|  return out + 8;
   95|  5.09M|}
fastcopy.c:copy_bytes:
  161|  13.6k|static inline unsigned char *copy_bytes(unsigned char *out, const unsigned char *from, unsigned len) {
  162|  13.6k|  assert(len < 8);
  163|       |
  164|       |#ifdef BLOSC_STRICT_ALIGN
  165|       |  while (len--) {
  166|       |    *out++ = *from++;
  167|       |  }
  168|       |#else
  169|  13.6k|  switch (len) {
  170|  11.7k|    case 7:
  ------------------
  |  Branch (170:5): [True: 11.7k, False: 1.97k]
  ------------------
  171|  11.7k|      return copy_7_bytes(out, from);
  172|  1.97k|    case 6:
  ------------------
  |  Branch (172:5): [True: 1.97k, False: 11.7k]
  ------------------
  173|  1.97k|      return copy_6_bytes(out, from);
  174|      0|    case 5:
  ------------------
  |  Branch (174:5): [True: 0, False: 13.6k]
  ------------------
  175|      0|      return copy_5_bytes(out, from);
  176|      0|    case 4:
  ------------------
  |  Branch (176:5): [True: 0, False: 13.6k]
  ------------------
  177|      0|      return copy_4_bytes(out, from);
  178|      0|    case 3:
  ------------------
  |  Branch (178:5): [True: 0, False: 13.6k]
  ------------------
  179|      0|      return copy_3_bytes(out, from);
  180|      0|    case 2:
  ------------------
  |  Branch (180:5): [True: 0, False: 13.6k]
  ------------------
  181|      0|      return copy_2_bytes(out, from);
  182|      0|    case 1:
  ------------------
  |  Branch (182:5): [True: 0, False: 13.6k]
  ------------------
  183|      0|      return copy_1_bytes(out, from);
  184|      0|    case 0:
  ------------------
  |  Branch (184:5): [True: 0, False: 13.6k]
  ------------------
  185|      0|      return out;
  186|      0|    default:
  ------------------
  |  Branch (186:5): [True: 0, False: 13.6k]
  ------------------
  187|      0|      assert(0);
  188|  13.6k|  }
  189|      0|#endif /* BLOSC_STRICT_ALIGN */
  190|      0|  return out;
  191|  13.6k|}
fastcopy.c:copy_7_bytes:
   80|  11.7k|static inline unsigned char *copy_7_bytes(unsigned char *out, const unsigned char *from) {
   81|  11.7k|  out = copy_3_bytes(out, from);
   82|  11.7k|  return copy_4_bytes(out, from + 3);
   83|  11.7k|}
fastcopy.c:copy_6_bytes:
   75|  1.97k|static inline unsigned char *copy_6_bytes(unsigned char *out, const unsigned char *from) {
   76|  1.97k|  out = copy_2_bytes(out, from);
   77|  1.97k|  return copy_4_bytes(out, from + 2);
   78|  1.97k|}
fastcopy.c:copy_3_bytes:
   65|  11.7k|static inline unsigned char *copy_3_bytes(unsigned char *out, const unsigned char *from) {
   66|  11.7k|  out = copy_1_bytes(out, from);
   67|  11.7k|  return copy_2_bytes(out, from + 1);
   68|  11.7k|}
fastcopy.c:copy_1_bytes:
   60|  11.7k|static inline unsigned char *copy_1_bytes(unsigned char *out, const unsigned char *from) {
   61|  11.7k|  *out++ = *from;
   62|  11.7k|  return out;
   63|  11.7k|}
fastcopy.c:chunk_memcpy:
  200|  77.3k|static inline unsigned char *chunk_memcpy(unsigned char *out, const unsigned char *from, unsigned len) {
  201|  77.3k|  unsigned sz = sizeof(uint64_t);
  202|  77.3k|  unsigned rem = len % sz;
  203|  77.3k|  unsigned by8;
  204|       |
  205|  77.3k|  assert(len >= sz);
  206|       |
  207|       |  /* Copy a few bytes to make sure the loop below has a multiple of SZ bytes to be copied. */
  208|  77.3k|  copy_8_bytes(out, from);
  209|       |
  210|  77.3k|  len /= sz;
  211|  77.3k|  out += rem;
  212|  77.3k|  from += rem;
  213|       |
  214|  77.3k|  by8 = len % 8;
  215|  77.3k|  len -= by8;
  216|  77.3k|  switch (by8) {
  217|      0|    case 7:
  ------------------
  |  Branch (217:5): [True: 0, False: 77.3k]
  ------------------
  218|      0|      out = copy_8_bytes(out, from);
  219|      0|      from += sz;
  220|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  221|       |      __attribute__ ((fallthrough));  // Shut-up -Wimplicit-fallthrough warning in GCC
  222|       |      #endif
  223|      0|    case 6:
  ------------------
  |  Branch (223:5): [True: 0, False: 77.3k]
  ------------------
  224|      0|      out = copy_8_bytes(out, from);
  225|      0|      from += sz;
  226|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  227|       |      __attribute__ ((fallthrough));
  228|       |      #endif
  229|      0|    case 5:
  ------------------
  |  Branch (229:5): [True: 0, False: 77.3k]
  ------------------
  230|      0|      out = copy_8_bytes(out, from);
  231|      0|      from += sz;
  232|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  233|       |      __attribute__ ((fallthrough));
  234|       |      #endif
  235|      0|    case 4:
  ------------------
  |  Branch (235:5): [True: 0, False: 77.3k]
  ------------------
  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 3:
  ------------------
  |  Branch (241:5): [True: 0, False: 77.3k]
  ------------------
  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 2:
  ------------------
  |  Branch (247:5): [True: 0, False: 77.3k]
  ------------------
  248|      0|      out = copy_8_bytes(out, from);
  249|      0|      from += sz;
  250|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  251|       |      __attribute__ ((fallthrough));
  252|       |      #endif
  253|  77.3k|    case 1:
  ------------------
  |  Branch (253:5): [True: 77.3k, False: 0]
  ------------------
  254|  77.3k|      out = copy_8_bytes(out, from);
  255|  77.3k|      from += sz;
  256|       |      #ifdef AVOID_FALLTHROUGH_WARNING
  257|       |      __attribute__ ((fallthrough));
  258|       |      #endif
  259|  77.3k|    default:
  ------------------
  |  Branch (259:5): [True: 0, False: 77.3k]
  ------------------
  260|  77.3k|      break;
  261|  77.3k|  }
  262|       |
  263|  77.3k|  while (len) {
  ------------------
  |  Branch (263:10): [True: 0, False: 77.3k]
  ------------------
  264|      0|    out = copy_8_bytes(out, from);
  265|      0|    from += sz;
  266|      0|    out = copy_8_bytes(out, from);
  267|      0|    from += sz;
  268|      0|    out = copy_8_bytes(out, from);
  269|      0|    from += sz;
  270|      0|    out = copy_8_bytes(out, from);
  271|      0|    from += sz;
  272|      0|    out = copy_8_bytes(out, from);
  273|      0|    from += sz;
  274|      0|    out = copy_8_bytes(out, from);
  275|      0|    from += sz;
  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|       |
  281|      0|    len -= 8;
  282|      0|  }
  283|       |
  284|  77.3k|  return out;
  285|  77.3k|}
fastcopy.c:chunk_memcpy_unaligned:
  410|  1.10M|static inline unsigned char *chunk_memcpy_unaligned(unsigned char *out, const unsigned char *from, unsigned len) {
  411|       |#if defined(__AVX2__)
  412|       |  unsigned sz = sizeof(__m256i);
  413|       |#elif defined(__SSE2__)
  414|       |  unsigned sz = sizeof(__m128i);
  415|  1.10M|#endif
  416|  1.10M|  unsigned rem = len % sz;
  417|  1.10M|  unsigned ilen;
  418|       |
  419|  1.10M|  assert(len >= sz);
  420|       |
  421|       |  /* Copy a few bytes to make sure the loop below has a multiple of SZ bytes to be copied. */
  422|       |#if defined(__AVX2__)
  423|       |  copy_32_bytes(out, from);
  424|       |#elif defined(__SSE2__)
  425|       |  copy_16_bytes(out, from);
  426|  1.10M|#endif
  427|       |
  428|  1.10M|  len /= sz;
  429|  1.10M|  out += rem;
  430|  1.10M|  from += rem;
  431|       |
  432|   377M|  for (ilen = 0; ilen < len; ilen++) {
  ------------------
  |  Branch (432:18): [True: 375M, False: 1.10M]
  ------------------
  433|       |#if defined(__AVX2__)
  434|       |    copy_32_bytes(out, from);
  435|       |#elif defined(__SSE2__)
  436|       |    copy_16_bytes(out, from);
  437|   375M|#endif
  438|   375M|    out += sz;
  439|   375M|    from += sz;
  440|   375M|  }
  441|       |
  442|  1.10M|  return out;
  443|  1.10M|}
fastcopy.c:copy_4_bytes:
   48|  2.18G|static inline unsigned char *copy_4_bytes(unsigned char *out, const unsigned char *from) {
   49|       |#if defined(BLOSC_STRICT_ALIGN)
   50|       |  uint32_t chunk;
   51|       |  memcpy(&chunk, from, 4);
   52|       |  memcpy(out, &chunk, 4);
   53|       |#else
   54|  2.18G|  *(uint32_t *) out = *(uint32_t *) from;
   55|  2.18G|#endif
   56|  2.18G|  return out + 4;
   57|  2.18G|}
fastcopy.c:copy_2_bytes:
   37|   691k|static inline unsigned char *copy_2_bytes(unsigned char *out, const unsigned char *from) {
   38|       |#if defined(BLOSC_STRICT_ALIGN)
   39|       |  uint16_t chunk;
   40|       |  memcpy(&chunk, from, 2);
   41|       |  memcpy(out, &chunk, 2);
   42|       |#else
   43|   691k|  *(uint16_t *) out = *(uint16_t *) from;
   44|   691k|#endif
   45|   691k|  return out + 2;
   46|   691k|}

frame_reader_invalidate:
  439|  9.88k|void frame_reader_invalidate(blosc2_frame_s* frame) {
  440|  9.88k|  blosc2_pthread_mutex_lock(&frame->read_fp_mutex);
  ------------------
  |  |   92|  9.88k|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
  441|  9.88k|  frame_writer_close_locked(frame);
  442|  9.88k|  frame_reader_close_locked(frame, true);
  443|  9.88k|  blosc2_pthread_mutex_unlock(&frame->read_fp_mutex);
  ------------------
  |  |   93|  9.88k|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
  444|  9.88k|}
frame_new:
  619|  5.11k|blosc2_frame_s* frame_new(const char* urlpath) {
  620|  5.11k|  blosc2_frame_s* new_frame = frame_alloc();
  621|  5.11k|  if (new_frame == NULL) {
  ------------------
  |  Branch (621:7): [True: 0, False: 5.11k]
  ------------------
  622|      0|    return NULL;
  623|      0|  }
  624|  5.11k|  if (urlpath != NULL) {
  ------------------
  |  Branch (624:7): [True: 0, False: 5.11k]
  ------------------
  625|      0|    char* new_urlpath = malloc(strlen(urlpath) + 1);  // + 1 for the trailing NULL
  626|      0|    if (new_urlpath == NULL) {
  ------------------
  |  Branch (626:9): [True: 0, False: 0]
  ------------------
  627|      0|      blosc2_pthread_mutex_destroy(&new_frame->read_fp_mutex);
  ------------------
  |  |   91|      0|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
  628|      0|      free(new_frame);
  629|      0|      return NULL;
  630|      0|    }
  631|      0|    new_frame->urlpath = strcpy(new_urlpath, urlpath);
  632|      0|    new_frame->file_offset = 0;
  633|      0|  }
  634|  5.11k|  return new_frame;
  635|  5.11k|}
frame_set_locking:
  656|  5.11k|void frame_set_locking(blosc2_frame_s* frame, const blosc2_io* io) {
  657|  5.11k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (657:7): [True: 5.11k, False: 0]
  ------------------
  658|  5.11k|    return;
  659|  5.11k|  }
  660|      0|  if (frame_locking_requested(io)) {
  ------------------
  |  Branch (660:7): [True: 0, False: 0]
  ------------------
  661|       |    frame->locking = true;
  662|      0|    frame->lock_fd = -1;
  663|      0|  }
  664|      0|}
frame_lock:
  775|  3.51M|int frame_lock(blosc2_frame_s* frame, bool exclusive) {
  776|  3.51M|  if (frame == NULL || !frame->locking) {
  ------------------
  |  Branch (776:7): [True: 716k, False: 2.79M]
  |  Branch (776:24): [True: 2.79M, False: 0]
  ------------------
  777|  3.51M|    return BLOSC2_ERROR_SUCCESS;
  778|  3.51M|  }
  779|      0|  if (frame->lock_depth > 0) {
  ------------------
  |  Branch (779:7): [True: 0, False: 0]
  ------------------
  780|       |    // Already held by this handle (a nested call); the outer lock covers us
  781|      0|    frame->lock_depth++;
  782|      0|    return BLOSC2_ERROR_SUCCESS;
  783|      0|  }
  784|      0|  if (frame->lock_fd == -1) {
  ------------------
  |  Branch (784:7): [True: 0, False: 0]
  ------------------
  785|       |    // Lazily open the sidecar, kept for the frame's lifetime
  786|      0|    char* path = frame_lock_path(frame);
  787|      0|    if (path == NULL) {
  ------------------
  |  Branch (787:9): [True: 0, False: 0]
  ------------------
  788|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
  789|      0|    }
  790|       |#if defined(_WIN32)
  791|       |    HANDLE h = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
  792|       |                           FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  793|       |                           NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  794|       |    if (h == INVALID_HANDLE_VALUE) {
  795|       |      BLOSC_TRACE_ERROR("Cannot open the lock file in: %s", path);
  796|       |      free(path);
  797|       |      return BLOSC2_ERROR_LOCK;
  798|       |    }
  799|       |    frame->lock_fd = (intptr_t)h;
  800|       |#else
  801|      0|    int fd = open(path, O_CREAT | O_RDWR | O_CLOEXEC, 0666);
  802|      0|    if (fd < 0) {
  ------------------
  |  Branch (802:9): [True: 0, False: 0]
  ------------------
  803|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  804|      0|      free(path);
  805|      0|      return BLOSC2_ERROR_LOCK;
  806|      0|    }
  807|      0|    frame->lock_fd = fd;
  808|      0|#endif
  809|      0|    free(path);
  810|      0|  }
  811|      0|  if (frame_os_lock(frame, exclusive) < 0) {
  ------------------
  |  Branch (811:7): [True: 0, False: 0]
  ------------------
  812|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  813|      0|    return BLOSC2_ERROR_LOCK;
  814|      0|  }
  815|       |  // Generation counter: writers bump it, everyone compares it with the last
  816|       |  // value it saw.  This detects mutations by other handles exactly, even when
  817|       |  // the frame length on disk ends up unchanged (which the length-based
  818|       |  // staleness check in frame_refresh_if_stale() cannot see).
  819|      0|  uint64_t seq;
  820|      0|  if (frame_lock_read_seq(frame, &seq) < 0 ||
  ------------------
  |  Branch (820:7): [True: 0, False: 0]
  ------------------
  821|      0|      (exclusive && frame_lock_write_seq(frame, seq + 1) < 0)) {
  ------------------
  |  Branch (821:8): [True: 0, False: 0]
  |  Branch (821:21): [True: 0, False: 0]
  ------------------
  822|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|      0|    frame_os_unlock(frame);
  824|      0|    return BLOSC2_ERROR_LOCK;
  825|      0|  }
  826|      0|  if (seq != frame->lock_seq) {
  ------------------
  |  Branch (826:7): [True: 0, False: 0]
  ------------------
  827|      0|    frame->force_refresh = true;
  828|      0|  }
  829|      0|  if (exclusive) {
  ------------------
  |  Branch (829:7): [True: 0, False: 0]
  ------------------
  830|      0|    seq++;
  831|      0|  }
  832|      0|  frame->lock_seq = seq;
  833|      0|  frame->lock_depth = 1;
  834|      0|  return BLOSC2_ERROR_SUCCESS;
  835|      0|}
frame_unlock:
  838|  3.51M|int frame_unlock(blosc2_frame_s* frame) {
  839|  3.51M|  if (frame == NULL || !frame->locking || frame->lock_depth == 0) {
  ------------------
  |  Branch (839:7): [True: 716k, False: 2.79M]
  |  Branch (839:24): [True: 2.79M, False: 0]
  |  Branch (839:43): [True: 0, False: 0]
  ------------------
  840|  3.51M|    return BLOSC2_ERROR_SUCCESS;
  841|  3.51M|  }
  842|      0|  if (--frame->lock_depth > 0) {
  ------------------
  |  Branch (842:7): [True: 0, False: 0]
  ------------------
  843|      0|    return BLOSC2_ERROR_SUCCESS;
  844|      0|  }
  845|       |  // Hand our writes over before the next lock holder looks: closing the cached
  846|       |  // writer is what pushes them to the server on NFS (close-to-open consistency).
  847|       |  // A no-op unless this handle wrote since it last let go of the lock.
  848|      0|  frame_writer_close(frame);
  849|      0|  if (frame_os_unlock(frame) < 0) {
  ------------------
  |  Branch (849:7): [True: 0, False: 0]
  ------------------
  850|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|      0|    return BLOSC2_ERROR_LOCK;
  852|      0|  }
  853|      0|  return BLOSC2_ERROR_SUCCESS;
  854|      0|}
frame_free:
  858|  9.88k|int frame_free(blosc2_frame_s* frame) {
  859|       |
  860|  9.88k|  frame_reader_invalidate(frame);
  861|  9.88k|  blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|  9.88k|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
  862|       |
  863|  9.88k|  if (frame->locking && frame->lock_fd != -1) {
  ------------------
  |  Branch (863:7): [True: 0, False: 9.88k]
  |  Branch (863:25): [True: 0, False: 0]
  ------------------
  864|       |#if defined(_WIN32)
  865|       |    CloseHandle((HANDLE)frame->lock_fd);
  866|       |#else
  867|      0|    close((int)frame->lock_fd);
  868|      0|#endif
  869|      0|  }
  870|       |
  871|  9.88k|  if (frame->cframe != NULL && !frame->avoid_cframe_free) {
  ------------------
  |  Branch (871:7): [True: 9.88k, False: 0]
  |  Branch (871:32): [True: 5.11k, False: 4.77k]
  ------------------
  872|  5.11k|    free(frame->cframe);
  873|  5.11k|  }
  874|       |
  875|  9.88k|  if (frame->coffsets != NULL && frame->coffsets_needs_free) {
  ------------------
  |  Branch (875:7): [True: 0, False: 9.88k]
  |  Branch (875:34): [True: 0, False: 0]
  ------------------
  876|      0|    free(frame->coffsets);
  877|      0|  }
  878|       |
  879|  9.88k|  if (frame->urlpath != NULL) {
  ------------------
  |  Branch (879:7): [True: 0, False: 9.88k]
  ------------------
  880|      0|    free(frame->urlpath);
  881|      0|  }
  882|  9.88k|  free(frame->holes);
  883|       |
  884|  9.88k|  free(frame);
  885|       |
  886|  9.88k|  return 0;
  887|  9.88k|}
new_header_frame:
  890|  1.02M|void *new_header_frame(blosc2_schunk *schunk, blosc2_frame_s *frame) {
  891|  1.02M|  if (frame == NULL) {
  ------------------
  |  Branch (891:7): [True: 0, False: 1.02M]
  ------------------
  892|      0|    return NULL;
  893|      0|  }
  894|  1.02M|  uint8_t* h2 = calloc(FRAME_HEADER_MINLEN, 1);
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|  1.02M|  uint8_t* h2p = h2;
  896|       |
  897|       |  // The msgpack header starts here
  898|  1.02M|  *h2p = 0x90;  // fixarray...
  899|  1.02M|  *h2p += 14;   // ...with 13 elements
  900|  1.02M|  h2p += 1;
  901|       |
  902|       |  // Magic number
  903|  1.02M|  *h2p = 0xa0 + 8;  // str with 8 elements
  904|  1.02M|  h2p += 1;
  905|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (905:7): [True: 0, False: 1.02M]
  ------------------
  906|      0|    return NULL;
  907|      0|  }
  908|  1.02M|  strcpy((char*)h2p, "b2frame");
  909|  1.02M|  h2p += 8;
  910|       |
  911|       |  // Header size
  912|  1.02M|  *h2p = 0xd2;  // int32
  913|  1.02M|  h2p += 1 + 4;
  914|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (914:7): [True: 0, False: 1.02M]
  ------------------
  915|      0|    return NULL;
  916|      0|  }
  917|       |
  918|       |  // Total frame size
  919|  1.02M|  *h2p = 0xcf;  // uint64
  920|       |  // Fill it with frame->len which is known *after* the creation of the frame (e.g. when updating the header)
  921|  1.02M|  int64_t flen = frame->len;
  922|  1.02M|  to_big(h2 + FRAME_LEN, &flen, sizeof(flen));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
  923|  1.02M|  h2p += 1 + 8;
  924|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (924:7): [True: 0, False: 1.02M]
  ------------------
  925|      0|    return NULL;
  926|      0|  }
  927|       |
  928|       |  // Flags
  929|  1.02M|  *h2p = 0xa0 + 4;  // str with 4 elements
  930|  1.02M|  h2p += 1;
  931|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (931:7): [True: 0, False: 1.02M]
  ------------------
  932|      0|    return NULL;
  933|      0|  }
  934|       |  // General flags
  935|  1.02M|  if (schunk->chunksize == 0 || (schunk->flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (935:7): [True: 0, False: 1.02M]
  |  Branch (935:33): [True: 0, False: 1.02M]
  ------------------
  936|      0|    *h2p = BLOSC2_VERSION_FRAME_FORMAT_VL_BLOCKS;  // version
  937|      0|  }
  938|  1.02M|  else {
  939|  1.02M|    *h2p = BLOSC2_VERSION_FRAME_FORMAT_RC1;  // version
  940|  1.02M|  }
  941|  1.02M|  *h2p += 0x10;  // 64-bit offsets.  We only support this for now.
  942|  1.02M|  if (schunk->chunksize == 0) {
  ------------------
  |  Branch (942:7): [True: 0, False: 1.02M]
  ------------------
  943|      0|    *h2p |= FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   26|      0|#define FRAME_VARIABLE_CHUNKS (1U << 6)
  ------------------
  944|      0|  }
  945|  1.02M|  if (schunk->flags2 & BLOSC2_VL_BLOCKS) {
  ------------------
  |  Branch (945:7): [True: 0, False: 1.02M]
  ------------------
  946|      0|    *h2p |= FRAME_VL_BLOCKS;
  ------------------
  |  |   27|      0|#define FRAME_VL_BLOCKS (1U << 7)
  ------------------
  947|      0|  }
  948|  1.02M|  h2p += 1;
  949|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (949:7): [True: 0, False: 1.02M]
  ------------------
  950|      0|    return NULL;
  951|      0|  }
  952|       |
  953|       |  // Frame type
  954|       |  // We only support contiguous and sparse directories frames currently
  955|  1.02M|  *h2p = frame->sframe ? 1 : 0;
  ------------------
  |  Branch (955:10): [True: 0, False: 1.02M]
  ------------------
  956|  1.02M|  h2p += 1;
  957|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (957:7): [True: 0, False: 1.02M]
  ------------------
  958|      0|    return NULL;
  959|      0|  }
  960|       |
  961|       |  // Codec flags
  962|  1.02M|  *h2p = schunk->compcode;
  963|  1.02M|  if (schunk->compcode >= BLOSC_LAST_CODEC) {
  ------------------
  |  Branch (963:7): [True: 0, False: 1.02M]
  ------------------
  964|      0|    *h2p = BLOSC_UDCODEC_FORMAT;
  965|      0|  }
  966|  1.02M|  *h2p += (schunk->clevel) << 4u;  // clevel
  967|  1.02M|  h2p += 1;
  968|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (968:7): [True: 0, False: 1.02M]
  ------------------
  969|      0|    return NULL;
  970|      0|  }
  971|       |
  972|       |  // Other flags
  973|  1.02M|  *h2p = schunk->splitmode - 1;
  974|  1.02M|  h2p += 1;
  975|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (975:7): [True: 0, False: 1.02M]
  ------------------
  976|      0|    return NULL;
  977|      0|  }
  978|       |
  979|       |  // Uncompressed size
  980|  1.02M|  *h2p = 0xd3;  // int64
  981|  1.02M|  h2p += 1;
  982|  1.02M|  int64_t nbytes = schunk->nbytes;
  983|  1.02M|  to_big(h2p, &nbytes, sizeof(nbytes));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
  984|  1.02M|  h2p += 8;
  985|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (985:7): [True: 0, False: 1.02M]
  ------------------
  986|      0|    return NULL;
  987|      0|  }
  988|       |
  989|       |  // Compressed size
  990|  1.02M|  *h2p = 0xd3;  // int64
  991|  1.02M|  h2p += 1;
  992|  1.02M|  int64_t cbytes = schunk->cbytes;
  993|  1.02M|  to_big(h2p, &cbytes, sizeof(cbytes));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
  994|  1.02M|  h2p += 8;
  995|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (995:7): [True: 0, False: 1.02M]
  ------------------
  996|      0|    return NULL;
  997|      0|  }
  998|       |
  999|       |  // Type size
 1000|  1.02M|  *h2p = 0xd2;  // int32
 1001|  1.02M|  h2p += 1;
 1002|  1.02M|  int32_t typesize = schunk->typesize;
 1003|  1.02M|  to_big(h2p, &typesize, sizeof(typesize));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1004|  1.02M|  h2p += 4;
 1005|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1005:7): [True: 0, False: 1.02M]
  ------------------
 1006|      0|    return NULL;
 1007|      0|  }
 1008|       |
 1009|       |  // Block size
 1010|  1.02M|  *h2p = 0xd2;  // int32
 1011|  1.02M|  h2p += 1;
 1012|  1.02M|  int32_t blocksize = schunk->blocksize;
 1013|  1.02M|  to_big(h2p, &blocksize, sizeof(blocksize));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1014|  1.02M|  h2p += 4;
 1015|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1015:7): [True: 0, False: 1.02M]
  ------------------
 1016|      0|    return NULL;
 1017|      0|  }
 1018|       |
 1019|       |  // Chunk size
 1020|  1.02M|  *h2p = 0xd2;  // int32
 1021|  1.02M|  h2p += 1;
 1022|  1.02M|  int32_t chunksize = schunk->chunksize;
 1023|  1.02M|  to_big(h2p, &chunksize, sizeof(chunksize));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1024|  1.02M|  h2p += 4;
 1025|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1025:7): [True: 0, False: 1.02M]
  ------------------
 1026|      0|    return NULL;
 1027|      0|  }
 1028|       |
 1029|       |  // Number of threads for compression
 1030|  1.02M|  *h2p = 0xd1;  // int16
 1031|  1.02M|  h2p += 1;
 1032|  1.02M|  int16_t nthreads = (int16_t)schunk->cctx->nthreads;
 1033|  1.02M|  to_big(h2p, &nthreads, sizeof(nthreads));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1034|  1.02M|  h2p += 2;
 1035|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1035:7): [True: 0, False: 1.02M]
  ------------------
 1036|      0|    return NULL;
 1037|      0|  }
 1038|       |
 1039|       |  // Number of threads for decompression
 1040|  1.02M|  *h2p = 0xd1;  // int16
 1041|  1.02M|  h2p += 1;
 1042|  1.02M|  nthreads = (int16_t)schunk->dctx->nthreads;
 1043|  1.02M|  to_big(h2p, &nthreads, sizeof(nthreads));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1044|  1.02M|  h2p += 2;
 1045|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1045:7): [True: 0, False: 1.02M]
  ------------------
 1046|      0|    return NULL;
 1047|      0|  }
 1048|       |
 1049|       |  // The boolean for variable-length metalayers
 1050|  1.02M|  *h2p = (schunk->nvlmetalayers > 0) ? (uint8_t)0xc3 : (uint8_t)0xc2;
  ------------------
  |  Branch (1050:10): [True: 0, False: 1.02M]
  ------------------
 1051|  1.02M|  h2p += 1;
 1052|  1.02M|  if (h2p - h2 >= FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1052:7): [True: 0, False: 1.02M]
  ------------------
 1053|      0|    return NULL;
 1054|      0|  }
 1055|       |
 1056|       |  // The space for FRAME_FILTER_PIPELINE
 1057|  1.02M|  *h2p = 0xd8;  //  fixext 16
 1058|  1.02M|  h2p += 1;
 1059|  1.02M|  if (BLOSC2_MAX_FILTERS > FRAME_FILTER_PIPELINE_MAX) {
  ------------------
  |  |   53|  1.02M|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
  |  Branch (1059:7): [Folded, False: 1.02M]
  ------------------
 1060|      0|    return NULL;
 1061|      0|  }
 1062|       |  // Store the filter pipeline in header
 1063|  1.02M|  uint8_t* mp_filters = h2 + FRAME_FILTER_PIPELINE + 1;
  ------------------
  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1064|  1.02M|  uint8_t* mp_meta = h2 + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                uint8_t* mp_meta = h2 + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   53|  1.02M|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
 1065|  7.17M|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (1065:19): [True: 6.15M, False: 1.02M]
  ------------------
 1066|  6.15M|      mp_filters[i] = schunk->filters[i];
 1067|  6.15M|      mp_meta[i] = schunk->filters_meta[i];
 1068|  6.15M|  }
 1069|  1.02M|  *h2p = (uint8_t) BLOSC2_MAX_FILTERS;
 1070|  1.02M|  h2p += 1;
 1071|  1.02M|  h2p += 16;
 1072|       |
 1073|       |  // User-defined codec and codec metadata
 1074|  1.02M|  uint8_t* udcodec = h2 + FRAME_UDCODEC;
  ------------------
  |  |   45|  1.02M|#define FRAME_UDCODEC (FRAME_FILTER_PIPELINE + 1 + 6) // 77
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1075|  1.02M|  *udcodec = schunk->compcode;
 1076|  1.02M|  uint8_t* codec_meta = h2 + FRAME_CODEC_META;
  ------------------
  |  |   46|  1.02M|#define FRAME_CODEC_META (FRAME_FILTER_PIPELINE + 1 + 7) // 78
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|  1.02M|  *codec_meta = schunk->compcode_meta;
 1078|       |
 1079|       |  // Other flags 2 (byte 0x55): bit 0 = use_dict
 1080|  1.02M|  h2[FRAME_OTHER_FLAGS2] = schunk->use_dict ? FRAME_USE_DICT : 0;
  ------------------
  |  |   47|  1.02M|#define FRAME_OTHER_FLAGS2 (FRAME_FILTER_PIPELINE + 1 + 14)  // 85
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#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 (1080:28): [True: 0, False: 1.02M]
  ------------------
 1081|       |
 1082|  1.02M|  if (h2p - h2 != FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1082:7): [True: 0, False: 1.02M]
  ------------------
 1083|      0|    return NULL;
 1084|      0|  }
 1085|       |
 1086|  1.02M|  int32_t hsize = FRAME_HEADER_MINLEN;
  ------------------
  |  |   49|  1.02M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  1.02M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  1.02M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  1.02M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  1.02M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  1.02M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  1.02M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  1.02M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  1.02M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  1.02M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  1.02M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  1.02M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  1.02M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  1.02M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1087|       |
 1088|       |  // Now, deal with metalayers
 1089|  1.02M|  uint16_t nmetalayers = schunk->nmetalayers;
 1090|  1.02M|  if (nmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  1.02M|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (1090:7): [True: 0, False: 1.02M]
  ------------------
 1091|      0|    return NULL;
 1092|      0|  }
 1093|       |
 1094|       |  // Make space for the header of metalayers (array marker, size, map of offsets)
 1095|  1.02M|  h2 = realloc(h2, (size_t)hsize + 1 + 1 + 2 + 1 + 2);
 1096|  1.02M|  h2p = h2 + hsize;
 1097|       |
 1098|       |  // The msgpack header for the metalayers (array_marker, size, map of offsets, list of metalayers)
 1099|  1.02M|  *h2p = 0x90 + 3;  // array with 3 elements
 1100|  1.02M|  h2p += 1;
 1101|       |
 1102|       |  // Size for the map (index) of offsets, including this uint16 size (to be filled out later on)
 1103|  1.02M|  *h2p = 0xcd;  // uint16
 1104|  1.02M|  h2p += 1 + 2;
 1105|       |
 1106|       |  // Map (index) of offsets for optional metalayers
 1107|  1.02M|  *h2p = 0xde;  // map 16 with N keys
 1108|  1.02M|  h2p += 1;
 1109|  1.02M|  to_big(h2p, &nmetalayers, sizeof(nmetalayers));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1110|  1.02M|  h2p += sizeof(nmetalayers);
 1111|  1.02M|  int32_t current_header_len = (int32_t)(h2p - h2);
 1112|  1.02M|  int32_t *offtooff = malloc(nmetalayers * sizeof(int32_t));
 1113|  1.02M|  if (offtooff == NULL) {
  ------------------
  |  Branch (1113:7): [True: 0, False: 1.02M]
  ------------------
 1114|      0|    free(h2);
 1115|      0|    return NULL;
 1116|      0|  }
 1117|  2.04M|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (1117:28): [True: 1.02M, False: 1.02M]
  ------------------
 1118|  1.02M|    if (frame == NULL) {
  ------------------
  |  Branch (1118:9): [True: 0, False: 1.02M]
  ------------------
 1119|      0|      free(offtooff);
 1120|      0|      free(h2);
 1121|      0|      return NULL;
 1122|      0|    }
 1123|  1.02M|    blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 1124|  1.02M|    uint8_t namelen = (uint8_t) strlen(metalayer->name);
 1125|  1.02M|    h2 = realloc(h2, (size_t)current_header_len + 1 + namelen + 1 + 4);
 1126|  1.02M|    h2p = h2 + current_header_len;
 1127|       |    // Store the metalayer
 1128|  1.02M|    if (namelen >= (1U << 5U)) {  // metalayer strings cannot be longer than 32 bytes
  ------------------
  |  Branch (1128:9): [True: 0, False: 1.02M]
  ------------------
 1129|      0|      free(offtooff);
 1130|      0|      free(h2);
 1131|      0|      return NULL;
 1132|      0|    }
 1133|  1.02M|    *h2p = (uint8_t)0xa0 + namelen;  // str
 1134|  1.02M|    h2p += 1;
 1135|  1.02M|    memcpy(h2p, metalayer->name, namelen);
 1136|  1.02M|    h2p += namelen;
 1137|       |    // Space for storing the offset for the value of this metalayer
 1138|  1.02M|    *h2p = 0xd2;  // int32
 1139|  1.02M|    h2p += 1;
 1140|  1.02M|    offtooff[nmetalayer] = (int32_t)(h2p - h2);
 1141|  1.02M|    h2p += 4;
 1142|  1.02M|    current_header_len += 1 + namelen + 1 + 4;
 1143|  1.02M|  }
 1144|  1.02M|  int32_t hsize2 = (int32_t)(h2p - h2);
 1145|  1.02M|  if (hsize2 != current_header_len) {  // sanity check
  ------------------
  |  Branch (1145:7): [True: 0, False: 1.02M]
  ------------------
 1146|      0|    free(offtooff);
 1147|      0|    free(h2);
 1148|      0|    return NULL;
 1149|      0|  }
 1150|       |
 1151|       |  // Map size + int16 size
 1152|  1.02M|  if ((uint32_t) (hsize2 - hsize) >= (1U << 16U)) {
  ------------------
  |  Branch (1152:7): [True: 0, False: 1.02M]
  ------------------
 1153|      0|    free(offtooff);
 1154|      0|    free(h2);
 1155|      0|    return NULL;
 1156|      0|  }
 1157|  1.02M|  uint16_t map_size = (uint16_t) (hsize2 - hsize);
 1158|  1.02M|  to_big(h2 + FRAME_IDX_SIZE, &map_size, sizeof(map_size));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1159|       |
 1160|       |  // Make space for an (empty) array
 1161|  1.02M|  hsize = (int32_t)(h2p - h2);
 1162|  1.02M|  h2 = realloc(h2, (size_t)hsize + 2 + 1 + 2);
 1163|  1.02M|  h2p = h2 + hsize;
 1164|       |
 1165|       |  // Now, store the values in an array
 1166|  1.02M|  *h2p = 0xdc;  // array 16 with N elements
 1167|  1.02M|  h2p += 1;
 1168|  1.02M|  to_big(h2p, &nmetalayers, sizeof(nmetalayers));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1169|  1.02M|  h2p += sizeof(nmetalayers);
 1170|  1.02M|  current_header_len = (int32_t)(h2p - h2);
 1171|  2.04M|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (1171:28): [True: 1.02M, False: 1.02M]
  ------------------
 1172|  1.02M|    if (frame == NULL) {
  ------------------
  |  Branch (1172:9): [True: 0, False: 1.02M]
  ------------------
 1173|      0|      free(offtooff);
 1174|      0|      free(h2);
 1175|      0|      return NULL;
 1176|      0|    }
 1177|  1.02M|    blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 1178|  1.02M|    h2 = realloc(h2, (size_t)current_header_len + 1 + 4 + metalayer->content_len);
 1179|  1.02M|    h2p = h2 + current_header_len;
 1180|       |    // Store the serialized contents for this metalayer
 1181|  1.02M|    *h2p = 0xc6;  // bin32
 1182|  1.02M|    h2p += 1;
 1183|  1.02M|    to_big(h2p, &(metalayer->content_len), sizeof(metalayer->content_len));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1184|  1.02M|    h2p += 4;
 1185|  1.02M|    memcpy(h2p, metalayer->content, metalayer->content_len);  // buffer, no need to swap
 1186|  1.02M|    h2p += metalayer->content_len;
 1187|       |    // Update the offset now that we know it
 1188|  1.02M|    to_big(h2 + offtooff[nmetalayer], &current_header_len, sizeof(current_header_len));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1189|  1.02M|    current_header_len += 1 + 4 + metalayer->content_len;
 1190|  1.02M|  }
 1191|  1.02M|  free(offtooff);
 1192|  1.02M|  hsize = (int32_t)(h2p - h2);
 1193|  1.02M|  if (hsize != current_header_len) {  // sanity check
  ------------------
  |  Branch (1193:7): [True: 0, False: 1.02M]
  ------------------
 1194|      0|    free(h2);
 1195|      0|    return NULL;
 1196|      0|  }
 1197|       |
 1198|       |  // Set the length of the whole header now that we know it
 1199|  1.02M|  to_big(h2 + FRAME_HEADER_LEN, &hsize, sizeof(hsize));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1200|       |
 1201|  1.02M|  return h2;
 1202|  1.02M|}
get_header_info:
 1211|  4.83M|                    uint8_t *splitmode, uint8_t *use_dict, const blosc2_io *io) {
 1212|  4.83M|  uint8_t* framep = frame->cframe;
 1213|  4.83M|  uint8_t* header_ptr;
 1214|  4.83M|  uint8_t header[FRAME_HEADER_MINLEN];
 1215|       |
 1216|  4.83M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(io->id);
 1217|  4.83M|  if (io_cb == NULL) {
  ------------------
  |  Branch (1217:7): [True: 0, False: 4.83M]
  ------------------
 1218|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1219|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1220|      0|  }
 1221|       |
 1222|  4.83M|  if (frame->len <= 0) {
  ------------------
  |  Branch (1222:7): [True: 0, False: 4.83M]
  ------------------
 1223|      0|    return BLOSC2_ERROR_READ_BUFFER;
 1224|      0|  }
 1225|       |
 1226|  4.83M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (1226:7): [True: 0, False: 4.83M]
  ------------------
 1227|      0|    int64_t rbytes = 0;
 1228|      0|    void* fp = NULL;
 1229|      0|    int64_t io_pos = 0;
 1230|      0|    if (frame->sframe) {
  ------------------
  |  Branch (1230:9): [True: 0, False: 0]
  ------------------
 1231|      0|      fp = sframe_open_index(frame->urlpath, "rb", io);
 1232|      0|      if (fp == NULL) {
  ------------------
  |  Branch (1232:11): [True: 0, False: 0]
  ------------------
 1233|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1234|      0|        return BLOSC2_ERROR_FILE_OPEN;
 1235|      0|      }
 1236|      0|    }
 1237|      0|    else {
 1238|       |      /* Ahead of the header read, not after it: everything downstream (and
 1239|       |         frame_refresh_if_stale in particular) trusts the length this read
 1240|       |         returns, so a stale handle here would pair old metadata with the
 1241|       |         replacement's bytes. */
 1242|      0|      frame_reader_revalidate(frame);
 1243|      0|      fp = frame_reader_acquire(frame, io);
 1244|      0|      if (fp == NULL) {
  ------------------
  |  Branch (1244:11): [True: 0, False: 0]
  ------------------
 1245|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1246|      0|        return BLOSC2_ERROR_FILE_OPEN;
 1247|      0|      }
 1248|      0|      io_pos = frame->file_offset;
 1249|      0|    }
 1250|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (1250:9): [True: 0, False: 0]
  ------------------
 1251|      0|      header_ptr = header;
 1252|      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
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1253|      0|    frame_reader_release(frame, io_cb, fp);
 1254|      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 (1254:9): [True: 0, False: 0]
  ------------------
 1255|      0|      return BLOSC2_ERROR_FILE_READ;
 1256|      0|    }
 1257|      0|    framep = header_ptr;
 1258|      0|  }
 1259|       |
 1260|       |  // Consistency check for frame type
 1261|  4.83M|  uint8_t frame_type = framep[FRAME_TYPE];
  ------------------
  |  |   33|  4.83M|#define FRAME_TYPE (FRAME_FLAGS + 1)  // 26
  |  |  ------------------
  |  |  |  |   32|  4.83M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  4.83M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  4.83M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  4.83M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1262|  4.83M|  uint8_t frame_version = framep[FRAME_FLAGS] & 0x0fu;
  ------------------
  |  |   32|  4.83M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  4.83M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  4.83M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  4.83M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1263|  4.83M|  if (frame_version > BLOSC2_VERSION_FRAME_FORMAT) {
  ------------------
  |  Branch (1263:7): [True: 2, False: 4.83M]
  ------------------
 1264|      2|    BLOSC_TRACE_ERROR("Unsupported cframe version: %u", frame_version);
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1265|      2|    return BLOSC2_ERROR_VERSION_SUPPORT;
 1266|      2|  }
 1267|  4.83M|  if (frame->sframe) {
  ------------------
  |  Branch (1267:7): [True: 0, False: 4.83M]
  ------------------
 1268|      0|    if (frame_type != FRAME_DIRECTORY_TYPE) {
  ------------------
  |  |   22|      0|#define FRAME_DIRECTORY_TYPE 1
  ------------------
  |  Branch (1268:9): [True: 0, False: 0]
  ------------------
 1269|      0|      return BLOSC2_ERROR_FRAME_TYPE;
 1270|      0|    }
 1271|  4.83M|  } else {
 1272|  4.83M|    if (frame_type != FRAME_CONTIGUOUS_TYPE) {
  ------------------
  |  |   21|  4.83M|#define FRAME_CONTIGUOUS_TYPE 0
  ------------------
  |  Branch (1272:9): [True: 4, False: 4.83M]
  ------------------
 1273|      4|      return BLOSC2_ERROR_FRAME_TYPE;
 1274|      4|    }
 1275|  4.83M|  }
 1276|       |
 1277|       |  // Fetch some internal lengths
 1278|  4.83M|  from_big(header_len, framep + FRAME_HEADER_LEN, sizeof(*header_len));
  ------------------
  |  |   38|  4.83M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1279|  4.83M|  if (*header_len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  4.83M|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  4.83M|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.83M|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  4.83M|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  4.83M|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  4.83M|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.83M|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.83M|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.83M|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.83M|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.83M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.83M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.83M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.83M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (1279:7): [True: 29, False: 4.83M]
  ------------------
 1280|     29|    BLOSC_TRACE_ERROR("Header length is zero or smaller than min allowed.");
  ------------------
  |  |   93|     29|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     29|    do {                                            \
  |  |  |  |   98|     29|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     29|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     29|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1281|     29|    return BLOSC2_ERROR_INVALID_HEADER;
 1282|     29|  }
 1283|  4.83M|  from_big(frame_len, framep + FRAME_LEN, sizeof(*frame_len));
  ------------------
  |  |   38|  4.83M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1284|  4.83M|  if (*header_len > *frame_len) {
  ------------------
  |  Branch (1284:7): [True: 8, False: 4.83M]
  ------------------
 1285|      8|    BLOSC_TRACE_ERROR("Header length exceeds length of the frame.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1286|      8|    return BLOSC2_ERROR_INVALID_HEADER;
 1287|      8|  }
 1288|  4.83M|  from_big(nbytes, framep + FRAME_NBYTES, sizeof(*nbytes));
  ------------------
  |  |   38|  4.83M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1289|  4.83M|  from_big(cbytes, framep + FRAME_CBYTES, sizeof(*cbytes));
  ------------------
  |  |   38|  4.83M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1290|  4.83M|  from_big(blocksize, framep + FRAME_BLOCKSIZE, sizeof(*blocksize));
  ------------------
  |  |   38|  4.83M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1291|  4.83M|  if (chunksize != NULL) {
  ------------------
  |  Branch (1291:7): [True: 4.82M, False: 3.40k]
  ------------------
 1292|  4.82M|    from_big(chunksize, framep + FRAME_CHUNKSIZE, sizeof(*chunksize));
  ------------------
  |  |   38|  4.82M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1293|  4.82M|  }
 1294|  4.83M|  if (typesize != NULL) {
  ------------------
  |  Branch (1294:7): [True: 2.72M, False: 2.10M]
  ------------------
 1295|  2.72M|    from_big(typesize, framep + FRAME_TYPESIZE, sizeof(*typesize));
  ------------------
  |  |   38|  2.72M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1296|  2.72M|    if (*typesize <= 0) {
  ------------------
  |  Branch (1296:9): [True: 32, False: 2.72M]
  ------------------
 1297|     32|      BLOSC_TRACE_ERROR("`typesize` cannot be zero or negative.");
  ------------------
  |  |   93|     32|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     32|    do {                                            \
  |  |  |  |   98|     32|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     32|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     32|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1298|     32|      return BLOSC2_ERROR_INVALID_HEADER;
 1299|     32|    }
 1300|  2.72M|  }
 1301|       |
 1302|       |  // Codecs
 1303|  4.83M|  uint8_t frame_codecs = framep[FRAME_CODECS];
  ------------------
  |  |   34|  4.83M|#define FRAME_CODECS (FRAME_FLAGS + 2)  // 27
  |  |  ------------------
  |  |  |  |   32|  4.83M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  4.83M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  4.83M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  4.83M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1304|  4.83M|  if (clevel != NULL) {
  ------------------
  |  Branch (1304:7): [True: 4.70k, False: 4.82M]
  ------------------
 1305|  4.70k|    *clevel = frame_codecs >> 4u;
 1306|  4.70k|  }
 1307|  4.83M|  if (compcode != NULL) {
  ------------------
  |  Branch (1307:7): [True: 4.70k, False: 4.82M]
  ------------------
 1308|  4.70k|    *compcode = frame_codecs & 0xFu;
 1309|  4.70k|    if (*compcode == BLOSC_UDCODEC_FORMAT) {
  ------------------
  |  Branch (1309:9): [True: 137, False: 4.56k]
  ------------------
 1310|    137|      from_big(compcode, framep + FRAME_UDCODEC, sizeof(*compcode));
  ------------------
  |  |   38|    137|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1311|    137|    }
 1312|  4.70k|  }
 1313|       |
 1314|       |  // Other flags
 1315|  4.83M|  uint8_t other_flags = framep[FRAME_OTHER_FLAGS];
  ------------------
  |  |   35|  4.83M|#define FRAME_OTHER_FLAGS (FRAME_FLAGS + 3)  // 28
  |  |  ------------------
  |  |  |  |   32|  4.83M|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|  4.83M|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   30|  4.83M|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   29|  4.83M|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1316|  4.83M|  if (splitmode != NULL) {
  ------------------
  |  Branch (1316:7): [True: 4.70k, False: 4.82M]
  ------------------
 1317|  4.70k|    *splitmode = (other_flags & 0x03u) + 1;
 1318|  4.70k|  }
 1319|       |
 1320|       |  // Other flags 2: bit 0 = use_dict
 1321|  4.83M|  if (use_dict != NULL) {
  ------------------
  |  Branch (1321:7): [True: 4.70k, False: 4.82M]
  ------------------
 1322|  4.70k|    *use_dict = (framep[FRAME_OTHER_FLAGS2] & FRAME_USE_DICT) ? 1 : 0;
  ------------------
  |  |   47|  4.70k|#define FRAME_OTHER_FLAGS2 (FRAME_FILTER_PIPELINE + 1 + 14)  // 85
  |  |  ------------------
  |  |  |  |   44|  4.70k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.70k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  4.70k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  4.70k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  4.70k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.70k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.70k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.70k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.70k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.70k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.70k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.70k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.70k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  *use_dict = (framep[FRAME_OTHER_FLAGS2] & FRAME_USE_DICT) ? 1 : 0;
  ------------------
  |  |   48|  4.70k|#define FRAME_USE_DICT (1U << 0)   //!< bit 0 of other_flags2: use dictionary compression
  ------------------
  |  Branch (1322:17): [True: 223, False: 4.47k]
  ------------------
 1323|  4.70k|  }
 1324|       |
 1325|  4.83M|  if (compcode_meta != NULL) {
  ------------------
  |  Branch (1325:7): [True: 4.70k, False: 4.82M]
  ------------------
 1326|  4.70k|    from_big(compcode_meta, framep + FRAME_CODEC_META, sizeof(*compcode_meta));
  ------------------
  |  |   38|  4.70k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 1327|  4.70k|  }
 1328|       |
 1329|       |  // Filters
 1330|  4.83M|  if (filters != NULL && filters_meta != NULL) {
  ------------------
  |  Branch (1330:7): [True: 4.70k, False: 4.82M]
  |  Branch (1330:26): [True: 4.70k, False: 0]
  ------------------
 1331|  4.70k|    uint8_t nfilters = framep[FRAME_FILTER_PIPELINE];
  ------------------
  |  |   44|  4.70k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  4.70k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  4.70k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  4.70k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  4.70k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.70k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.70k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.70k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.70k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.70k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.70k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.70k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.70k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1332|  4.70k|    if (nfilters > BLOSC2_MAX_FILTERS) {
  ------------------
  |  Branch (1332:9): [True: 1, False: 4.69k]
  ------------------
 1333|      1|      BLOSC_TRACE_ERROR("The number of filters in frame header are too large for Blosc2.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1334|      1|      return BLOSC2_ERROR_INVALID_HEADER;
 1335|      1|    }
 1336|  4.69k|    uint8_t *filters_ = framep + FRAME_FILTER_PIPELINE + 1;
  ------------------
  |  |   44|  4.69k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  4.69k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  4.69k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  4.69k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  4.69k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.69k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.69k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.69k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.69k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.69k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.69k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.69k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.69k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1337|  4.69k|    uint8_t *filters_meta_ = framep + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   44|  4.69k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  ------------------
  |  |  |  |   43|  4.69k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  ------------------
  |  |  |  |  |  |   42|  4.69k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   41|  4.69k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   40|  4.69k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.69k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.69k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.69k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.69k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.69k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.69k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.69k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.69k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  uint8_t *filters_meta_ = framep + FRAME_FILTER_PIPELINE + 1 + FRAME_FILTER_PIPELINE_MAX;
  ------------------
  |  |   53|  4.69k|#define FRAME_FILTER_PIPELINE_MAX (8)  // the maximum number of filters that can be stored in header
  ------------------
 1338|  20.3k|    for (int i = 0; i < nfilters; i++) {
  ------------------
  |  Branch (1338:21): [True: 15.6k, False: 4.69k]
  ------------------
 1339|  15.6k|      filters[i] = filters_[i];
 1340|  15.6k|      filters_meta[i] = filters_meta_[i];
 1341|  15.6k|    }
 1342|  4.69k|  }
 1343|       |
 1344|  4.83M|  if (*nbytes > 0) {
  ------------------
  |  Branch (1344:7): [True: 4.81M, False: 15.1k]
  ------------------
 1345|  4.81M|    if (*chunksize > 0) {
  ------------------
  |  Branch (1345:9): [True: 4.81M, False: 1.73k]
  ------------------
 1346|       |      // We can compute the number of chunks directly when there is a fixed chunk size.
 1347|  4.81M|      *nchunks = *nbytes / *chunksize;
 1348|  4.81M|      if (*nbytes % *chunksize > 0) {
  ------------------
  |  Branch (1348:11): [True: 283, False: 4.81M]
  ------------------
 1349|    283|        *nchunks += 1;
 1350|    283|      }
 1351|       |
 1352|       |      // Sanity check for compressed sizes
 1353|  4.81M|      if ((*cbytes < 0) || ((int64_t)*nchunks * *chunksize < *nbytes)) {
  ------------------
  |  Branch (1353:11): [True: 34, False: 4.81M]
  |  Branch (1353:28): [True: 5, False: 4.81M]
  ------------------
 1354|     39|        BLOSC_TRACE_ERROR("Invalid compressed size in frame header.");
  ------------------
  |  |   93|     39|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     39|    do {                                            \
  |  |  |  |   98|     39|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     39|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 39, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     39|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1355|     39|        return BLOSC2_ERROR_INVALID_HEADER;
 1356|     39|      }
 1357|  4.81M|    }
 1358|  1.73k|    else if (*chunksize == 0) {
  ------------------
  |  Branch (1358:14): [True: 1.70k, False: 33]
  ------------------
 1359|  1.70k|      int32_t coffsets_nbytes;
 1360|  1.70k|      int rc2 = get_coffsets_nbytes(frame, *header_len, *cbytes, &coffsets_nbytes, io);
 1361|  1.70k|      if (rc2 < 0) {
  ------------------
  |  Branch (1361:11): [True: 248, False: 1.45k]
  ------------------
 1362|    248|        return rc2;
 1363|    248|      }
 1364|  1.45k|      if (coffsets_nbytes < 0 || coffsets_nbytes % (int32_t)sizeof(int64_t) != 0) {
  ------------------
  |  Branch (1364:11): [True: 30, False: 1.42k]
  |  Branch (1364:34): [True: 2, False: 1.42k]
  ------------------
 1365|     32|        BLOSC_TRACE_ERROR("Invalid offsets chunk in frame header.");
  ------------------
  |  |   93|     32|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     32|    do {                                            \
  |  |  |  |   98|     32|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     32|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     32|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1366|     32|        return BLOSC2_ERROR_INVALID_HEADER;
 1367|     32|      }
 1368|  1.42k|      *nchunks = coffsets_nbytes / (int32_t)sizeof(int64_t);
 1369|  1.42k|    }
 1370|     33|    else {
 1371|     33|      BLOSC_TRACE_ERROR("Invalid chunk size in frame header.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1372|     33|      return BLOSC2_ERROR_INVALID_HEADER;
 1373|     33|    }
 1374|  4.81M|  } else {
 1375|  15.1k|    *nchunks = 0;
 1376|  15.1k|  }
 1377|       |
 1378|  4.83M|  if (*nchunks > 0) {
  ------------------
  |  Branch (1378:7): [True: 4.81M, False: 15.1k]
  ------------------
 1379|  4.81M|    int32_t off_nbytes;
 1380|  4.81M|    if (!blosc2_nchunks_to_offsets_nbytes(*nchunks, &off_nbytes)) {
  ------------------
  |  Branch (1380:9): [True: 52, False: 4.81M]
  ------------------
 1381|     52|      BLOSC_TRACE_ERROR("Invalid number of chunks in frame header.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1382|     52|      return BLOSC2_ERROR_INVALID_HEADER;
 1383|     52|    }
 1384|  4.81M|  }
 1385|       |
 1386|  4.83M|  return 0;
 1387|  4.83M|}
get_trailer_offset:
 1390|  1.02M|int64_t get_trailer_offset(blosc2_frame_s *frame, int32_t header_len, bool has_coffsets) {
 1391|  1.02M|  if (!has_coffsets) {
  ------------------
  |  Branch (1391:7): [True: 10.5k, False: 1.01M]
  ------------------
 1392|       |    // No data chunks yet
 1393|  10.5k|    return header_len;
 1394|  10.5k|  }
 1395|  1.01M|  return frame->len - frame->trailer_len;
 1396|  1.02M|}
frame_check_stale:
 1582|  2.03M|int frame_check_stale(blosc2_frame_s *frame) {
 1583|  2.03M|  if (frame == NULL || frame->cframe != NULL || frame->schunk == NULL) {
  ------------------
  |  Branch (1583:7): [True: 716k, False: 1.31M]
  |  Branch (1583:24): [True: 1.31M, False: 0]
  |  Branch (1583:49): [True: 0, False: 0]
  ------------------
 1584|  2.03M|    return 0;
 1585|  2.03M|  }
 1586|      0|  if (frame_lock(frame, false) < 0) {
  ------------------
  |  Branch (1586:7): [True: 0, False: 0]
  ------------------
 1587|      0|    return BLOSC2_ERROR_LOCK;
 1588|      0|  }
 1589|      0|  int32_t header_len;
 1590|      0|  int64_t frame_len;
 1591|      0|  int64_t nbytes;
 1592|      0|  int64_t cbytes;
 1593|      0|  int32_t blocksize;
 1594|      0|  int32_t chunksize;
 1595|      0|  int64_t nchunks;
 1596|      0|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 1597|      0|                           &blocksize, &chunksize, &nchunks,
 1598|      0|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 1599|      0|                           frame->schunk->storage->io);
 1600|      0|  if (rc < 0) {
  ------------------
  |  Branch (1600:7): [True: 0, False: 0]
  ------------------
 1601|       |    // The on-disk header cannot be read right now (e.g. a freshly created
 1602|       |    // frame not yet flushed to disk, or another process mid-write).  The
 1603|       |    // poll is opportunistic: keep the cached view, exactly as before polling
 1604|       |    // existed.  A genuinely torn frame still errors out in the data-access
 1605|       |    // paths that need it.
 1606|      0|    frame_unlock(frame);
 1607|      0|    return 0;
 1608|      0|  }
 1609|      0|  rc = frame_refresh_if_stale(frame, frame_len);
 1610|      0|  if (rc > 0) {
  ------------------
  |  Branch (1610:7): [True: 0, False: 0]
  ------------------
 1611|      0|    frame->schunk->nbytes = nbytes;
 1612|      0|    frame->schunk->cbytes = cbytes;
 1613|      0|    frame->schunk->nchunks = nchunks;
 1614|      0|  }
 1615|      0|  frame_unlock(frame);
 1616|      0|  return rc;
 1617|      0|}
update_frame_len:
 1703|  1.02M|int update_frame_len(blosc2_frame_s* frame, int64_t len) {
 1704|  1.02M|  int rc = 1;
 1705|  1.02M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 1706|  1.02M|  if (io_cb == NULL) {
  ------------------
  |  Branch (1706:7): [True: 0, False: 1.02M]
  ------------------
 1707|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1708|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1709|      0|  }
 1710|       |
 1711|  1.02M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (1711:7): [True: 1.02M, False: 0]
  ------------------
 1712|  1.02M|    to_big(frame->cframe + FRAME_LEN, &len, sizeof(int64_t));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1713|  1.02M|  }
 1714|      0|  else {
 1715|      0|    void* fp = NULL;
 1716|      0|    if (frame->sframe) {
  ------------------
  |  Branch (1716:9): [True: 0, False: 0]
  ------------------
 1717|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 1718|      0|                             frame->schunk->storage->io);
 1719|      0|    }
 1720|      0|    else {
 1721|      0|      fp = frame_writer_acquire(frame, io_cb);
 1722|      0|    }
 1723|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1723:9): [True: 0, False: 0]
  ------------------
 1724|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1725|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1726|      0|    }
 1727|      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
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|      0|    int64_t swap_len;
 1729|      0|    to_big(&swap_len, &len, sizeof(int64_t));
  ------------------
  |  |   37|      0|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1730|      0|    int64_t wbytes = io_cb->write(&swap_len, 1, sizeof(int64_t), io_pos, fp);
 1731|      0|    frame_writer_release(frame, io_cb, fp);
 1732|      0|    if (wbytes != sizeof(int64_t)) {
  ------------------
  |  Branch (1732:9): [True: 0, False: 0]
  ------------------
 1733|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1734|      0|      return BLOSC2_ERROR_FILE_WRITE;
 1735|      0|    }
 1736|      0|  }
 1737|  1.02M|  return rc;
 1738|  1.02M|}
frame_update_trailer:
 1741|  1.02M|int frame_update_trailer(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 1742|  1.02M|  if (frame != NULL && frame->len == 0) {
  ------------------
  |  Branch (1742:7): [True: 1.02M, False: 0]
  |  Branch (1742:24): [True: 0, False: 1.02M]
  ------------------
 1743|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1744|      0|  }
 1745|       |
 1746|       |  // Create the trailer in msgpack (see the frame format document)
 1747|  1.02M|  uint32_t trailer_len = FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  1.02M|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 1748|  1.02M|  uint8_t* trailer = (uint8_t*)calloc((size_t)trailer_len, 1);
 1749|  1.02M|  uint8_t* ptrailer = trailer;
 1750|  1.02M|  *ptrailer = 0x90 + 4;  // fixarray with 4 elements
 1751|  1.02M|  ptrailer += 1;
 1752|       |  // Trailer format version
 1753|  1.02M|  *ptrailer = FRAME_TRAILER_VERSION;
  ------------------
  |  |   56|  1.02M|#define FRAME_TRAILER_VERSION (1U)        // can be up to 127
  ------------------
 1754|  1.02M|  ptrailer += 1;
 1755|       |
 1756|  1.02M|  int32_t current_trailer_len = (int32_t)(ptrailer - trailer);
 1757|       |
 1758|       |  // Now, deal with variable-length metalayers
 1759|  1.02M|  int16_t nvlmetalayers = schunk->nvlmetalayers;
 1760|  1.02M|  if (nvlmetalayers < 0 || nvlmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  1.02M|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (1760:7): [True: 0, False: 1.02M]
  |  Branch (1760:28): [True: 0, False: 1.02M]
  ------------------
 1761|      0|    return -1;
 1762|      0|  }
 1763|       |
 1764|       |  // Make space for the header of metalayers (array marker, size, map of offsets)
 1765|  1.02M|  trailer = realloc(trailer, (size_t) current_trailer_len + 1 + 1 + 2 + 1 + 2);
 1766|  1.02M|  ptrailer = trailer + current_trailer_len;
 1767|       |
 1768|       |  // The msgpack header for the metalayers (array_marker, size, map of offsets, list of metalayers)
 1769|  1.02M|  *ptrailer = 0x90 + 3;  // array with 3 elements
 1770|  1.02M|  ptrailer += 1;
 1771|       |
 1772|  1.02M|  int32_t tsize = (int32_t)(ptrailer - trailer);
 1773|       |
 1774|       |  // Size for the map (index) of metalayer offsets, including this uint16 size (to be filled out later on)
 1775|  1.02M|  *ptrailer = 0xcd;  // uint16
 1776|  1.02M|  ptrailer += 1 + 2;
 1777|       |
 1778|       |  // Map (index) of offsets for optional metalayers
 1779|  1.02M|  *ptrailer = 0xde;  // map 16 with N keys
 1780|  1.02M|  ptrailer += 1;
 1781|  1.02M|  to_big(ptrailer, &nvlmetalayers, sizeof(nvlmetalayers));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1782|  1.02M|  ptrailer += sizeof(nvlmetalayers);
 1783|  1.02M|  current_trailer_len = (int32_t)(ptrailer - trailer);
 1784|  1.02M|  int32_t *offtodata = malloc(nvlmetalayers * sizeof(int32_t));
 1785|  1.02M|  for (int nvlmetalayer = 0; nvlmetalayer < nvlmetalayers; nvlmetalayer++) {
  ------------------
  |  Branch (1785:30): [True: 0, False: 1.02M]
  ------------------
 1786|      0|    if (frame == NULL) {
  ------------------
  |  Branch (1786:9): [True: 0, False: 0]
  ------------------
 1787|      0|      return -1;
 1788|      0|    }
 1789|      0|    blosc2_metalayer *vlmetalayer = schunk->vlmetalayers[nvlmetalayer];
 1790|      0|    uint8_t name_len = (uint8_t) strlen(vlmetalayer->name);
 1791|      0|    trailer = realloc(trailer, (size_t)current_trailer_len + 1 + name_len + 1 + 4);
 1792|      0|    ptrailer = trailer + current_trailer_len;
 1793|       |    // Store the vlmetalayer
 1794|      0|    if (name_len >= (1U << 5U)) {  // metalayer strings cannot be longer than 32 bytes
  ------------------
  |  Branch (1794:9): [True: 0, False: 0]
  ------------------
 1795|      0|      free(offtodata);
 1796|      0|      return -1;
 1797|      0|    }
 1798|      0|    *ptrailer = (uint8_t)0xa0 + name_len;  // str
 1799|      0|    ptrailer += 1;
 1800|      0|    memcpy(ptrailer, vlmetalayer->name, name_len);
 1801|      0|    ptrailer += name_len;
 1802|       |    // Space for storing the offset for the value of this vlmetalayer
 1803|      0|    *ptrailer = 0xd2;  // int32
 1804|      0|    ptrailer += 1;
 1805|      0|    offtodata[nvlmetalayer] = (int32_t)(ptrailer - trailer);
 1806|      0|    ptrailer += 4;
 1807|      0|    current_trailer_len += 1 + name_len + 1 + 4;
 1808|      0|  }
 1809|  1.02M|  int32_t tsize2 = (int32_t)(ptrailer - trailer);
 1810|  1.02M|  if (tsize2 != current_trailer_len) {  // sanity check
  ------------------
  |  Branch (1810:7): [True: 0, False: 1.02M]
  ------------------
 1811|      0|    return -1;
 1812|      0|  }
 1813|       |
 1814|       |  // Map size + int16 size
 1815|  1.02M|  if ((uint32_t) (tsize2 - tsize) >= (1U << 16U)) {
  ------------------
  |  Branch (1815:7): [True: 0, False: 1.02M]
  ------------------
 1816|      0|    return -1;
 1817|      0|  }
 1818|  1.02M|  uint16_t map_size = (uint16_t) (tsize2 - tsize);
 1819|  1.02M|  to_big(trailer + 4, &map_size, sizeof(map_size));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1820|       |
 1821|       |  // Make space for an (empty) array
 1822|  1.02M|  tsize = (int32_t)(ptrailer - trailer);
 1823|  1.02M|  trailer = realloc(trailer, (size_t) tsize + 2 + 1 + 2);
 1824|  1.02M|  ptrailer = trailer + tsize;
 1825|       |
 1826|       |  // Now, store the values in an array
 1827|  1.02M|  *ptrailer = 0xdc;  // array 16 with N elements
 1828|  1.02M|  ptrailer += 1;
 1829|  1.02M|  to_big(ptrailer, &nvlmetalayers, sizeof(nvlmetalayers));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1830|  1.02M|  ptrailer += sizeof(nvlmetalayers);
 1831|  1.02M|  current_trailer_len = (int32_t)(ptrailer - trailer);
 1832|  1.02M|  for (int nvlmetalayer = 0; nvlmetalayer < nvlmetalayers; nvlmetalayer++) {
  ------------------
  |  Branch (1832:30): [True: 0, False: 1.02M]
  ------------------
 1833|      0|    if (frame == NULL) {
  ------------------
  |  Branch (1833:9): [True: 0, False: 0]
  ------------------
 1834|      0|      return -1;
 1835|      0|    }
 1836|      0|    blosc2_metalayer *vlmetalayer = schunk->vlmetalayers[nvlmetalayer];
 1837|      0|    trailer = realloc(trailer, (size_t)current_trailer_len + 1 + 4 + vlmetalayer->content_len);
 1838|      0|    ptrailer = trailer + current_trailer_len;
 1839|       |    // Store the serialized contents for this vlmetalayer
 1840|      0|    *ptrailer = 0xc6;  // bin32
 1841|      0|    ptrailer += 1;
 1842|      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)
  ------------------
 1843|      0|    ptrailer += 4;
 1844|      0|    memcpy(ptrailer, vlmetalayer->content, vlmetalayer->content_len);  // buffer, no need to swap
 1845|      0|    ptrailer += vlmetalayer->content_len;
 1846|       |    // Update the offset now that we know it
 1847|      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)
  ------------------
 1848|      0|    current_trailer_len += 1 + 4 + vlmetalayer->content_len;
 1849|      0|  }
 1850|  1.02M|  free(offtodata);
 1851|  1.02M|  tsize = (int32_t)(ptrailer - trailer);
 1852|  1.02M|  if (tsize != current_trailer_len) {  // sanity check
  ------------------
  |  Branch (1852:7): [True: 0, False: 1.02M]
  ------------------
 1853|      0|    return -1;
 1854|      0|  }
 1855|       |
 1856|  1.02M|  trailer = realloc(trailer, (size_t)current_trailer_len + 23);
 1857|  1.02M|  ptrailer = trailer + current_trailer_len;
 1858|  1.02M|  trailer_len = (ptrailer - trailer) + 23;
 1859|       |
 1860|       |  // Trailer length
 1861|  1.02M|  *ptrailer = 0xce;  // uint32
 1862|  1.02M|  ptrailer += 1;
 1863|  1.02M|  to_big(ptrailer, &trailer_len, sizeof(uint32_t));
  ------------------
  |  |   37|  1.02M|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 1864|  1.02M|  ptrailer += sizeof(uint32_t);
 1865|       |  // Up to 16 bytes for frame fingerprint (using XXH3 included in https://github.com/Cyan4973/xxHash)
 1866|       |  // Maybe someone would need 256-bit in the future, but for the time being 128-bit seems like a good tradeoff
 1867|  1.02M|  *ptrailer = 0xd8;  // fixext 16
 1868|  1.02M|  ptrailer += 1;
 1869|  1.02M|  *ptrailer = 0;  // fingerprint type: 0 -> no fp; 1 -> 32-bit; 2 -> 64-bit; 3 -> 128-bit
 1870|  1.02M|  ptrailer += 1;
 1871|       |
 1872|       |  // Remove call to memset when we compute an actual fingerprint
 1873|  1.02M|  memset(ptrailer, 0, 16);
 1874|       |  // Uncomment call to memcpy when we compute an actual fingerprint
 1875|       |  // memcpy(ptrailer, xxh3_fingerprint, sizeof(xxh3_fingerprint));
 1876|  1.02M|  ptrailer += 16;
 1877|       |
 1878|       |  // Sanity check
 1879|  1.02M|  ptrdiff_t actual_trailer_len = ptrailer - trailer;
 1880|  1.02M|  if (actual_trailer_len < 0 || (uint64_t)actual_trailer_len != (uint64_t)trailer_len) {
  ------------------
  |  Branch (1880:7): [True: 0, False: 1.02M]
  |  Branch (1880:33): [True: 0, False: 1.02M]
  ------------------
 1881|      0|    return BLOSC2_ERROR_DATA;
 1882|      0|  }
 1883|       |
 1884|  1.02M|  int32_t header_len;
 1885|  1.02M|  int64_t frame_len;
 1886|  1.02M|  int64_t nbytes;
 1887|  1.02M|  int64_t cbytes;
 1888|  1.02M|  int32_t blocksize;
 1889|  1.02M|  int32_t chunksize;
 1890|  1.02M|  int64_t nchunks;
 1891|  1.02M|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 1892|  1.02M|                            &blocksize, &chunksize, &nchunks,
 1893|  1.02M|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 1894|  1.02M|                            frame->schunk->storage->io);
 1895|  1.02M|  if (ret < 0) {
  ------------------
  |  Branch (1895:7): [True: 0, False: 1.02M]
  ------------------
 1896|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|      0|    return ret;
 1898|      0|  }
 1899|       |
 1900|  1.02M|  int64_t trailer_offset = get_trailer_offset(frame, header_len, nbytes > 0);
 1901|       |
 1902|  1.02M|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (1902:7): [True: 0, False: 1.02M]
  ------------------
 1903|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|      0|    return BLOSC2_ERROR_READ_BUFFER;
 1905|      0|  }
 1906|       |
 1907|  1.02M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 1908|  1.02M|  if (io_cb == NULL) {
  ------------------
  |  Branch (1908:7): [True: 0, False: 1.02M]
  ------------------
 1909|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1910|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1911|      0|  }
 1912|       |  // Update the trailer.  As there are no internal offsets to the trailer section,
 1913|       |  // and it is always at the end of the frame, we can just write (or overwrite) it
 1914|       |  // at the end of the frame.
 1915|  1.02M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (1915:7): [True: 1.02M, False: 0]
  ------------------
 1916|  1.02M|    frame->cframe = realloc(frame->cframe, (size_t)(trailer_offset + trailer_len));
 1917|  1.02M|    if (frame->cframe == NULL) {
  ------------------
  |  Branch (1917:9): [True: 0, False: 1.02M]
  ------------------
 1918|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1919|      0|      free(trailer);
 1920|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 1921|      0|    }
 1922|  1.02M|    memcpy(frame->cframe + trailer_offset, trailer, trailer_len);
 1923|  1.02M|  }
 1924|      0|  else {
 1925|      0|    void* fp = NULL;
 1926|      0|    if (frame->sframe) {
  ------------------
  |  Branch (1926:9): [True: 0, False: 0]
  ------------------
 1927|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 1928|      0|                             frame->schunk->storage->io);
 1929|      0|    }
 1930|      0|    else {
 1931|      0|      fp = frame_writer_acquire(frame, io_cb);
 1932|      0|    }
 1933|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1933:9): [True: 0, False: 0]
  ------------------
 1934|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1935|      0|      free(trailer);
 1936|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1937|      0|    }
 1938|      0|    int64_t io_pos = frame->file_offset + trailer_offset;
 1939|      0|    int64_t wbytes = io_cb->write(trailer, 1, trailer_len, io_pos, fp);
 1940|      0|    if (wbytes != trailer_len) {
  ------------------
  |  Branch (1940:9): [True: 0, False: 0]
  ------------------
 1941|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1942|      0|      frame->file_end = 0;  // a partial write may have moved the end of the file
 1943|      0|      frame_writer_release(frame, io_cb, fp);
 1944|      0|      free(trailer);
 1945|      0|      return BLOSC2_ERROR_FILE_WRITE;
 1946|      0|    }
 1947|      0|    int64_t trunc_pos = frame->file_offset + trailer_offset + trailer_len;
 1948|       |    // Only cut the file when the frame really got shorter than it.  A growing
 1949|       |    // frame leaves no stale bytes behind its trailer, and a truncate is never
 1950|       |    // free: on NFS it is a synchronous flush plus a SETATTR round trip, and XFS
 1951|       |    // flushes the file on the next close after any truncate that does not grow
 1952|       |    // it.  Other backends keep truncating unconditionally.
 1953|       |    //
 1954|       |    // file_end is the size we last left the file at.  A write that failed
 1955|       |    // halfway through an earlier update can have left bytes past it, which are
 1956|       |    // then only cut by the next update that shrinks the frame.  That is
 1957|       |    // harmless: the frame length is read from the header, not the file size.
 1958|      0|    bool must_truncate = true;
 1959|      0|    if (!frame->sframe && frame->schunk->storage->io->id == BLOSC2_IO_FILESYSTEM) {
  ------------------
  |  Branch (1959:9): [True: 0, False: 0]
  |  Branch (1959:27): [True: 0, False: 0]
  ------------------
 1960|      0|      if (frame->file_end <= 0) {
  ------------------
  |  Branch (1960:11): [True: 0, False: 0]
  ------------------
 1961|      0|        frame->file_end = io_cb->size(fp);  // once per handle; negative on error
 1962|      0|      }
 1963|      0|      must_truncate = frame->file_end <= 0 || trunc_pos < frame->file_end;
  ------------------
  |  Branch (1963:23): [True: 0, False: 0]
  |  Branch (1963:47): [True: 0, False: 0]
  ------------------
 1964|      0|    }
 1965|      0|    if (must_truncate && io_cb->truncate(fp, trunc_pos) != 0) {
  ------------------
  |  Branch (1965:9): [True: 0, False: 0]
  |  Branch (1965:26): [True: 0, False: 0]
  ------------------
 1966|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1967|      0|      frame->file_end = 0;
 1968|      0|      frame_writer_release(frame, io_cb, fp);
 1969|      0|      free(trailer);
 1970|      0|      return BLOSC2_ERROR_FILE_TRUNCATE;
 1971|      0|    }
 1972|      0|    frame->file_end = trunc_pos;
 1973|      0|    frame_writer_release(frame, io_cb, fp);
 1974|       |
 1975|      0|  }
 1976|  1.02M|  free(trailer);
 1977|       |
 1978|  1.02M|  int rc = update_frame_len(frame, trailer_offset + trailer_len);
 1979|  1.02M|  if (rc < 0) {
  ------------------
  |  Branch (1979:7): [True: 0, False: 1.02M]
  ------------------
 1980|      0|    return rc;
 1981|      0|  }
 1982|  1.02M|  frame->len = trailer_offset + trailer_len;
 1983|  1.02M|  frame->trailer_len = trailer_len;
 1984|       |
 1985|  1.02M|  return 1;
 1986|  1.02M|}
frame_from_cframe:
 2224|  4.88k|blosc2_frame_s* frame_from_cframe(uint8_t *cframe, int64_t len, bool copy) {
 2225|       |  // Get the length of the frame
 2226|  4.88k|  const uint8_t* header = cframe;
 2227|  4.88k|  int64_t frame_len;
 2228|  4.88k|  if (len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  4.88k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  4.88k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.88k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  4.88k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  4.88k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  4.88k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.88k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.88k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.88k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.88k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.88k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.88k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.88k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.88k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2228:7): [True: 0, False: 4.88k]
  ------------------
 2229|      0|    return NULL;
 2230|      0|  }
 2231|       |
 2232|  4.88k|  from_big(&frame_len, header + FRAME_LEN, sizeof(frame_len));
  ------------------
  |  |   38|  4.88k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2233|  4.88k|  if (frame_len != len) {   // sanity check
  ------------------
  |  Branch (2233:7): [True: 81, False: 4.80k]
  ------------------
 2234|     81|    return NULL;
 2235|     81|  }
 2236|       |
 2237|  4.80k|  blosc2_frame_s* frame = frame_alloc();
 2238|  4.80k|  if (frame == NULL) {
  ------------------
  |  Branch (2238:7): [True: 0, False: 4.80k]
  ------------------
 2239|      0|    return NULL;
 2240|      0|  }
 2241|  4.80k|  frame->len = frame_len;
 2242|  4.80k|  frame->file_offset = 0;
 2243|       |
 2244|       |  // Now, the trailer length
 2245|  4.80k|  const uint8_t* trailer = cframe + frame_len - FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  4.80k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2246|  4.80k|  int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   58|  4.80k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
                int trailer_offset = FRAME_TRAILER_MINLEN - FRAME_TRAILER_LEN_OFFSET;
  ------------------
  |  |   59|  4.80k|#define FRAME_TRAILER_LEN_OFFSET (22)  // offset to trailer length (counting from the end)
  ------------------
 2247|  4.80k|  if (trailer[trailer_offset - 1] != 0xce) {
  ------------------
  |  Branch (2247:7): [True: 10, False: 4.79k]
  ------------------
 2248|     10|    blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|     10|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 2249|     10|    free(frame);
 2250|     10|    return NULL;
 2251|     10|  }
 2252|  4.79k|  uint32_t trailer_len;
 2253|  4.79k|  from_big(&trailer_len, trailer + trailer_offset, sizeof(trailer_len));
  ------------------
  |  |   38|  4.79k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2254|  4.79k|  if (trailer_len < FRAME_TRAILER_MINLEN || trailer_len > INT32_MAX ||
  ------------------
  |  |   58|  9.58k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (2254:7): [True: 1, False: 4.79k]
  |  Branch (2254:45): [True: 7, False: 4.78k]
  ------------------
 2255|  4.78k|      (int64_t)trailer_len > frame_len ||
  ------------------
  |  Branch (2255:7): [True: 8, False: 4.77k]
  ------------------
 2256|  4.77k|      (int64_t)trailer_len > frame_len - FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  4.77k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  4.77k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.77k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  4.77k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  4.77k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  4.77k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.77k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.77k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.77k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.77k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.77k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.77k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.77k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.77k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (2256:7): [True: 1, False: 4.77k]
  ------------------
 2257|     17|    blosc2_pthread_mutex_destroy(&frame->read_fp_mutex);
  ------------------
  |  |   91|     17|#define blosc2_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
  ------------------
 2258|     17|    free(frame);
 2259|     17|    return NULL;
 2260|     17|  }
 2261|  4.77k|  frame->trailer_len = trailer_len;
 2262|       |
 2263|  4.77k|  if (copy) {
  ------------------
  |  Branch (2263:7): [True: 0, False: 4.77k]
  ------------------
 2264|      0|    frame->cframe = malloc((size_t)len);
 2265|      0|    memcpy(frame->cframe, cframe, (size_t)len);
 2266|      0|  }
 2267|  4.77k|  else {
 2268|  4.77k|    frame->cframe = cframe;
 2269|  4.77k|    frame->avoid_cframe_free = true;
 2270|  4.77k|  }
 2271|       |
 2272|  4.77k|  return frame;
 2273|  4.79k|}
frame_from_schunk:
 2280|  5.11k|int64_t frame_from_schunk(blosc2_schunk *schunk, blosc2_frame_s *frame) {
 2281|  5.11k|  frame->file_offset = 0;
 2282|  5.11k|  int64_t nchunks = schunk->nchunks;
 2283|  5.11k|  int64_t cbytes = schunk->cbytes;
 2284|  5.11k|  int32_t chunk_cbytes;
 2285|  5.11k|  int32_t chunk_nbytes;
 2286|  5.11k|  uint64_t* data_tmp = NULL;
 2287|  5.11k|  uint8_t* off_chunk = NULL;
 2288|  5.11k|  blosc2_io_cb* io_cb = NULL;
 2289|  5.11k|  void* fp = NULL;
 2290|  5.11k|  int rc;
 2291|       |
 2292|  5.11k|  uint8_t* h2 = new_header_frame(schunk, frame);
 2293|  5.11k|  if (h2 == NULL) {
  ------------------
  |  Branch (2293:7): [True: 0, False: 5.11k]
  ------------------
 2294|      0|    return BLOSC2_ERROR_DATA;
 2295|      0|  }
 2296|  5.11k|  uint32_t h2len;
 2297|  5.11k|  from_big(&h2len, h2 + FRAME_HEADER_LEN, sizeof(h2len));
  ------------------
  |  |   38|  5.11k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2298|       |  // Build the offsets chunk
 2299|  5.11k|  int32_t chunksize = -1;
 2300|  5.11k|  int32_t off_cbytes = 0;
 2301|  5.11k|  uint64_t coffset = 0;
 2302|  5.11k|  int32_t off_nbytes;
 2303|  5.11k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (2303:7): [True: 0, False: 5.11k]
  ------------------
 2304|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2305|      0|    rc = BLOSC2_ERROR_DATA;
 2306|      0|    goto failed;
 2307|      0|  }
 2308|  5.11k|  data_tmp = malloc((size_t)off_nbytes);
 2309|  5.11k|  if (data_tmp == NULL) {
  ------------------
  |  Branch (2309:7): [True: 0, False: 5.11k]
  ------------------
 2310|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2311|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 2312|      0|    goto failed;
 2313|      0|  }
 2314|  5.11k|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (2314:23): [True: 0, False: 5.11k]
  ------------------
 2315|      0|    rc = blosc2_cbuffer_sizes(schunk->data[i], &chunk_nbytes, &chunk_cbytes, NULL);
 2316|      0|    if (rc < 0) {
  ------------------
  |  Branch (2316:9): [True: 0, False: 0]
  ------------------
 2317|      0|      goto failed;
 2318|      0|    }
 2319|      0|    data_tmp[i] = coffset;
 2320|      0|    coffset += chunk_cbytes;
 2321|      0|    if (i == 0) {
  ------------------
  |  Branch (2321:9): [True: 0, False: 0]
  ------------------
 2322|      0|      chunksize = chunk_nbytes;
 2323|      0|    }
 2324|      0|    else if (chunksize != chunk_nbytes) {
  ------------------
  |  Branch (2324:14): [True: 0, False: 0]
  ------------------
 2325|       |      // Variable size  // TODO: update flags for this (or do not use them at all)
 2326|      0|      chunksize = 0;
 2327|      0|    }
 2328|      0|  }
 2329|  5.11k|  if ((int64_t)coffset != cbytes) {
  ------------------
  |  Branch (2329:7): [True: 0, False: 5.11k]
  ------------------
 2330|      0|    rc = BLOSC2_ERROR_DATA;
 2331|      0|    goto failed;
 2332|      0|  }
 2333|  5.11k|  if (nchunks > 0) {
  ------------------
  |  Branch (2333:7): [True: 0, False: 5.11k]
  ------------------
 2334|      0|    off_cbytes = compress_offsets((const int64_t*)data_tmp, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 2335|      0|                                  &off_chunk);
 2336|      0|    if (off_cbytes < 0) {
  ------------------
  |  Branch (2336:9): [True: 0, False: 0]
  ------------------
 2337|      0|      rc = off_cbytes;
 2338|      0|      goto failed;
 2339|      0|    }
 2340|      0|  }
 2341|  5.11k|  else {
 2342|  5.11k|    off_cbytes = 0;
 2343|  5.11k|  }
 2344|       |
 2345|       |  // Now that we know them, fill the chunksize and frame length in header
 2346|  5.11k|  to_big(h2 + FRAME_CHUNKSIZE, &chunksize, sizeof(chunksize));
  ------------------
  |  |   37|  5.11k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2347|  5.11k|  if (chunksize == 0) {
  ------------------
  |  Branch (2347:7): [True: 0, False: 5.11k]
  ------------------
 2348|      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)
  ------------------
 2349|      0|  }
 2350|  5.11k|  else {
 2351|  5.11k|    h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   32|  5.11k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  5.11k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  5.11k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  5.11k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VARIABLE_CHUNKS;
  ------------------
  |  |   26|  5.11k|#define FRAME_VARIABLE_CHUNKS (1U << 6)
  ------------------
 2352|  5.11k|  }
 2353|  5.11k|  if (schunk->chunksize == 0 || (schunk->flags2 & BLOSC2_VL_BLOCKS)) {
  ------------------
  |  Branch (2353:7): [True: 0, False: 5.11k]
  |  Branch (2353:33): [True: 0, False: 5.11k]
  ------------------
 2354|      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
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2355|      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)
  ------------------
 2356|      0|  }
 2357|  5.11k|  else {
 2358|  5.11k|    h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_RC1);
  ------------------
  |  |   32|  5.11k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  5.11k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  5.11k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  5.11k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] = (uint8_t)((h2[FRAME_FLAGS] & (uint8_t)~0x0fu) | BLOSC2_VERSION_FRAME_FORMAT_RC1);
  ------------------
  |  |   32|  5.11k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  5.11k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  5.11k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  5.11k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2359|  5.11k|    h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VL_BLOCKS;
  ------------------
  |  |   32|  5.11k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  ------------------
  |  |  |  |   31|  5.11k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  ------------------
  |  |  |  |  |  |   30|  5.11k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   29|  5.11k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  h2[FRAME_FLAGS] &= (uint8_t)~FRAME_VL_BLOCKS;
  ------------------
  |  |   27|  5.11k|#define FRAME_VL_BLOCKS (1U << 7)
  ------------------
 2360|  5.11k|  }
 2361|  5.11k|  frame->len = h2len + cbytes + off_cbytes + FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|  5.11k|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2362|  5.11k|  if (frame->sframe) {
  ------------------
  |  Branch (2362:7): [True: 0, False: 5.11k]
  ------------------
 2363|      0|    frame->len = h2len + off_cbytes + FRAME_TRAILER_MINLEN;
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
 2364|      0|  }
 2365|  5.11k|  int64_t tbytes = frame->len;
 2366|  5.11k|  to_big(h2 + FRAME_LEN, &tbytes, sizeof(tbytes));
  ------------------
  |  |   37|  5.11k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2367|       |
 2368|  5.11k|  const blosc2_io* io = frame->schunk->storage->io;
 2369|  5.11k|  io_cb = blosc2_get_io_cb(io->id);
 2370|  5.11k|  if (io_cb == NULL) {
  ------------------
  |  Branch (2370:7): [True: 0, False: 5.11k]
  ------------------
 2371|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2372|      0|    rc = BLOSC2_ERROR_PLUGIN_IO;
 2373|      0|    goto failed;
 2374|      0|  }
 2375|       |
 2376|       |  // Create the frame and put the header at the beginning
 2377|  5.11k|  int64_t io_pos = 0;
 2378|  5.11k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2378:7): [True: 5.11k, False: 0]
  ------------------
 2379|  5.11k|    frame->cframe = malloc((size_t)frame->len);
 2380|  5.11k|    memcpy(frame->cframe, h2, h2len);
 2381|  5.11k|  }
 2382|      0|  else {
 2383|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2383:9): [True: 0, False: 0]
  ------------------
 2384|      0|      fp = sframe_open_index(frame->urlpath, "wb", io);
 2385|      0|    }
 2386|      0|    else {
 2387|       |      // The file is about to be recreated from scratch; drop any cached reader
 2388|      0|      frame_reader_invalidate(frame);
 2389|       |      // Where the handle can stay open as the cached writer (which is "rb+"
 2390|       |      // everywhere else), open it readable too
 2391|      0|      fp = io_cb->open(frame->urlpath, reader_cacheable(io) ? "wb+" : "wb", io->params);
  ------------------
  |  Branch (2391:40): [True: 0, False: 0]
  ------------------
 2392|      0|    }
 2393|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2393:9): [True: 0, False: 0]
  ------------------
 2394|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2395|      0|      rc = BLOSC2_ERROR_FILE_OPEN;
 2396|      0|      goto failed;
 2397|      0|    }
 2398|      0|    io_cb->write(h2, h2len, 1, io_pos, fp);
 2399|      0|    io_pos += h2len;
 2400|      0|  }
 2401|       |
 2402|       |  // Fill the frame with the actual data chunks
 2403|  5.11k|  if (!frame->sframe) {
  ------------------
  |  Branch (2403:7): [True: 5.11k, False: 0]
  ------------------
 2404|  5.11k|    coffset = 0;
 2405|  5.11k|    for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (2405:25): [True: 0, False: 5.11k]
  ------------------
 2406|      0|      uint8_t* data_chunk = schunk->data[i];
 2407|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 2408|      0|      if (rc < 0) {
  ------------------
  |  Branch (2408:11): [True: 0, False: 0]
  ------------------
 2409|      0|        goto failed;
 2410|      0|      }
 2411|      0|      if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2411:11): [True: 0, False: 0]
  ------------------
 2412|      0|        memcpy(frame->cframe + h2len + coffset, data_chunk, (size_t)chunk_cbytes);
 2413|      0|      } else {
 2414|      0|        io_cb->write(data_chunk, chunk_cbytes, 1, io_pos, fp);
 2415|      0|        io_pos += chunk_cbytes;
 2416|      0|      }
 2417|      0|      coffset += chunk_cbytes;
 2418|      0|    }
 2419|  5.11k|    if ((int64_t)coffset != cbytes) {
  ------------------
  |  Branch (2419:9): [True: 0, False: 5.11k]
  ------------------
 2420|      0|      rc = BLOSC2_ERROR_FAILURE;
 2421|      0|      goto failed;
 2422|      0|    }
 2423|  5.11k|  }
 2424|       |
 2425|       |  // Copy the offsets chunk at the end of the frame (there is none without chunks)
 2426|  5.11k|  if (frame->urlpath == NULL) {
  ------------------
  |  Branch (2426:7): [True: 5.11k, False: 0]
  ------------------
 2427|  5.11k|    if (off_cbytes > 0) {
  ------------------
  |  Branch (2427:9): [True: 0, False: 5.11k]
  ------------------
 2428|      0|      memcpy(frame->cframe + h2len + cbytes, off_chunk, off_cbytes);
 2429|      0|    }
 2430|  5.11k|  }
 2431|      0|  else {
 2432|      0|    if (off_cbytes > 0) {
  ------------------
  |  Branch (2432:9): [True: 0, False: 0]
  ------------------
 2433|      0|      io_cb->write(off_chunk, off_cbytes, 1, io_pos, fp);
 2434|      0|    }
 2435|       |    // Only a handle opened readable above can be adopted
 2436|      0|    if (!frame_writer_adopt(frame, io, fp)) {
  ------------------
  |  Branch (2436:9): [True: 0, False: 0]
  ------------------
 2437|      0|      io_cb->close(fp);
 2438|      0|    }
 2439|      0|    fp = NULL;
 2440|       |    // The file was created from scratch, so its size is exactly what we wrote
 2441|      0|    frame->file_end = frame->sframe ? 0 : io_pos + off_cbytes;
  ------------------
  |  Branch (2441:23): [True: 0, False: 0]
  ------------------
 2442|      0|  }
 2443|  5.11k|  free(off_chunk);
 2444|  5.11k|  free(data_tmp);
 2445|  5.11k|  free(h2);
 2446|  5.11k|  rc = frame_update_trailer(frame, schunk);
 2447|  5.11k|  if (rc < 0) {
  ------------------
  |  Branch (2447:7): [True: 0, False: 5.11k]
  ------------------
 2448|      0|    return rc;
 2449|      0|  }
 2450|       |
 2451|  5.11k|  return frame->len;
 2452|       |
 2453|      0|  failed:
 2454|      0|  if (fp != NULL) {
  ------------------
  |  Branch (2454:7): [True: 0, False: 0]
  ------------------
 2455|      0|    io_cb->close(fp);
 2456|      0|  }
 2457|      0|  free(off_chunk);
 2458|      0|  free(data_tmp);
 2459|      0|  free(h2);
 2460|      0|  return rc;
 2461|  5.11k|}
get_coffsets:
 2466|  3.75M|                      int64_t nchunks, int32_t *off_cbytes) {
 2467|  3.75M|  int32_t chunk_cbytes;
 2468|  3.75M|  int rc;
 2469|       |
 2470|  3.75M|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (2470:7): [True: 0, False: 3.75M]
  ------------------
 2471|      0|    if (off_cbytes != NULL) {
  ------------------
  |  Branch (2471:9): [True: 0, False: 0]
  ------------------
 2472|      0|      rc = blosc2_cbuffer_sizes(frame->coffsets, NULL, &chunk_cbytes, NULL);
 2473|      0|      if (rc < 0) {
  ------------------
  |  Branch (2473:11): [True: 0, False: 0]
  ------------------
 2474|      0|        return NULL;
 2475|      0|      }
 2476|      0|      *off_cbytes = (int32_t)chunk_cbytes;
 2477|      0|    }
 2478|      0|    return frame->coffsets;
 2479|      0|  }
 2480|  3.75M|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (2480:7): [True: 3.75M, False: 0]
  ------------------
 2481|  3.75M|    int64_t off_pos = header_len;
 2482|  3.75M|    if (cbytes < INT64_MAX - header_len) {
  ------------------
  |  Branch (2482:9): [True: 3.75M, False: 71]
  ------------------
 2483|  3.75M|      off_pos += cbytes;
 2484|  3.75M|    }
 2485|       |    // Check that there is enough room to read Blosc header
 2486|  3.75M|    if (off_pos < 0 || off_pos > INT64_MAX - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (2486:9): [True: 0, False: 3.75M]
  |  Branch (2486:24): [True: 1, False: 3.75M]
  ------------------
 2487|  3.75M|        off_pos + BLOSC_EXTENDED_HEADER_LENGTH > frame->len) {
  ------------------
  |  Branch (2487:9): [True: 105, False: 3.75M]
  ------------------
 2488|    106|      BLOSC_TRACE_ERROR("Cannot read the offsets outside of frame boundary.");
  ------------------
  |  |   93|    106|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    106|    do {                                            \
  |  |  |  |   98|    106|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    106|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 106, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    106|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2489|    106|      return NULL;
 2490|    106|    }
 2491|       |    // For in-memory frames, the coffset is just one pointer away
 2492|  3.75M|    uint8_t* off_start = frame->cframe + off_pos;
 2493|  3.75M|    if (off_cbytes != NULL) {
  ------------------
  |  Branch (2493:9): [True: 3.75M, False: 0]
  ------------------
 2494|  3.75M|      int32_t chunk_nbytes;
 2495|  3.75M|      int32_t chunk_blocksize;
 2496|  3.75M|      rc = blosc2_cbuffer_sizes(off_start, &chunk_nbytes, &chunk_cbytes, &chunk_blocksize);
 2497|  3.75M|      if (rc < 0) {
  ------------------
  |  Branch (2497:11): [True: 11, False: 3.75M]
  ------------------
 2498|     11|        return NULL;
 2499|     11|      }
 2500|  3.75M|      *off_cbytes = (int32_t)chunk_cbytes;
 2501|  3.75M|      if (*off_cbytes < 0 || off_pos + *off_cbytes > frame->len) {
  ------------------
  |  Branch (2501:11): [True: 0, False: 3.75M]
  |  Branch (2501:30): [True: 26, False: 3.75M]
  ------------------
 2502|     26|        BLOSC_TRACE_ERROR("Cannot read the cbytes outside of frame boundary.");
  ------------------
  |  |   93|     26|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     26|    do {                                            \
  |  |  |  |   98|     26|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     26|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     26|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2503|     26|        return NULL;
 2504|     26|      }
 2505|  3.75M|      int32_t expected_off_nbytes;
 2506|  3.75M|      if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &expected_off_nbytes)) {
  ------------------
  |  Branch (2506:11): [True: 0, False: 3.75M]
  ------------------
 2507|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2508|      0|        return NULL;
 2509|      0|      }
 2510|  3.75M|      if (chunk_nbytes != expected_off_nbytes) {
  ------------------
  |  Branch (2510:11): [True: 43, False: 3.75M]
  ------------------
 2511|     43|        BLOSC_TRACE_ERROR("The number of chunks in offset idx "
  ------------------
  |  |   93|     43|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     43|    do {                                            \
  |  |  |  |   98|     43|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     43|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 43, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     43|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2512|     43|                          "does not match the ones in the header frame.");
 2513|     43|        return NULL;
 2514|     43|      }
 2515|       |
 2516|  3.75M|    }
 2517|  3.75M|    return off_start;
 2518|  3.75M|  }
 2519|       |
 2520|      0|  int64_t trailer_offset = get_trailer_offset(frame, header_len, true);
 2521|       |
 2522|      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 (2522:7): [True: 0, False: 0]
  |  Branch (2522:56): [True: 0, False: 0]
  ------------------
 2523|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2524|      0|    return NULL;
 2525|      0|  }
 2526|       |
 2527|      0|  int64_t coffsets_cbytes64;
 2528|      0|  if (frame->sframe) {
  ------------------
  |  Branch (2528:7): [True: 0, False: 0]
  ------------------
 2529|      0|    coffsets_cbytes64 = trailer_offset - header_len;
 2530|      0|  }
 2531|      0|  else {
 2532|      0|    coffsets_cbytes64 = trailer_offset - (header_len + cbytes);
 2533|      0|  }
 2534|      0|  if (coffsets_cbytes64 <= 0 || coffsets_cbytes64 > INT32_MAX) {
  ------------------
  |  Branch (2534:7): [True: 0, False: 0]
  |  Branch (2534:33): [True: 0, False: 0]
  ------------------
 2535|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2536|      0|    return NULL;
 2537|      0|  }
 2538|      0|  int32_t coffsets_cbytes = (int32_t)coffsets_cbytes64;
 2539|       |
 2540|      0|  if (off_cbytes != NULL) {
  ------------------
  |  Branch (2540:7): [True: 0, False: 0]
  ------------------
 2541|      0|    *off_cbytes = coffsets_cbytes;
 2542|      0|  }
 2543|       |
 2544|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2545|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (2545:7): [True: 0, False: 0]
  ------------------
 2546|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2547|      0|    return NULL;
 2548|      0|  }
 2549|       |
 2550|      0|  void* fp = NULL;
 2551|      0|  uint8_t* coffsets;
 2552|      0|  if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (2552:7): [True: 0, False: 0]
  ------------------
 2553|      0|    coffsets = malloc((size_t)coffsets_cbytes);
 2554|      0|    frame->coffsets_needs_free = true;
 2555|      0|  }
 2556|      0|  else {
 2557|      0|    frame->coffsets_needs_free = false;
 2558|      0|  }
 2559|       |
 2560|      0|  int64_t io_pos = 0;
 2561|      0|  if (frame->sframe) {
  ------------------
  |  Branch (2561:7): [True: 0, False: 0]
  ------------------
 2562|      0|    fp = sframe_open_index(frame->urlpath, "rb",
 2563|      0|                           frame->schunk->storage->io);
 2564|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2564:9): [True: 0, False: 0]
  ------------------
 2565|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2566|      0|      return NULL;
 2567|      0|    }
 2568|      0|    io_pos = header_len + 0;
 2569|      0|  }
 2570|      0|  else {
 2571|      0|    fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 2572|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2572:9): [True: 0, False: 0]
  ------------------
 2573|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2574|      0|      return NULL;
 2575|      0|    }
 2576|      0|    io_pos = frame->file_offset + header_len + cbytes;
 2577|      0|  }
 2578|      0|  int64_t rbytes = io_cb->read((void**)&coffsets, 1, coffsets_cbytes, io_pos, fp);
 2579|      0|  frame_reader_release(frame, io_cb, fp);
 2580|      0|  if (rbytes != coffsets_cbytes) {
  ------------------
  |  Branch (2580:7): [True: 0, False: 0]
  ------------------
 2581|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2582|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (2582:9): [True: 0, False: 0]
  ------------------
 2583|      0|      free(coffsets);
 2584|      0|    return NULL;
 2585|      0|  }
 2586|      0|  frame->coffsets = coffsets;
 2587|      0|  return coffsets;
 2588|      0|}
frame_update_header:
 2648|  1.02M|int frame_update_header(blosc2_frame_s* frame, blosc2_schunk* schunk, bool new) {
 2649|  1.02M|  uint8_t* framep = frame->cframe;
 2650|  1.02M|  uint8_t* header_ptr;
 2651|  1.02M|  uint8_t header[FRAME_HEADER_MINLEN];
 2652|       |
 2653|  1.02M|  if (frame->len <= 0) {
  ------------------
  |  Branch (2653:7): [True: 0, False: 1.02M]
  ------------------
 2654|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2655|      0|  }
 2656|       |
 2657|  1.02M|  if (new && schunk->cbytes > 0) {
  ------------------
  |  Branch (2657:7): [True: 5.10k, False: 1.01M]
  |  Branch (2657:14): [True: 0, False: 5.10k]
  ------------------
 2658|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2659|      0|                      "has been appended.");
 2660|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2661|      0|  }
 2662|       |
 2663|  1.02M|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2664|  1.02M|  if (io_cb == NULL) {
  ------------------
  |  Branch (2664:7): [True: 0, False: 1.02M]
  ------------------
 2665|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2666|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 2667|      0|  }
 2668|       |
 2669|  1.02M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (2669:7): [True: 0, False: 1.02M]
  ------------------
 2670|      0|    int64_t rbytes = 0;
 2671|      0|    void* fp = NULL;
 2672|      0|    int64_t io_pos = 0;
 2673|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2673:9): [True: 0, False: 0]
  ------------------
 2674|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 2675|      0|                             frame->schunk->storage->io);
 2676|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2676:11): [True: 0, False: 0]
  ------------------
 2677|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2678|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2679|      0|      }
 2680|      0|    }
 2681|      0|    else {
 2682|      0|      frame_reader_revalidate(frame);
 2683|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 2684|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2684:11): [True: 0, False: 0]
  ------------------
 2685|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2686|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2687|      0|      }
 2688|      0|      io_pos = frame->file_offset;
 2689|      0|    }
 2690|      0|    if (fp != NULL) {
  ------------------
  |  Branch (2690:9): [True: 0, False: 0]
  ------------------
 2691|      0|      if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (2691:11): [True: 0, False: 0]
  ------------------
 2692|      0|        header_ptr = header;
 2693|      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
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2694|      0|      frame_reader_release(frame, io_cb, fp);
 2695|      0|    }
 2696|      0|    (void) rbytes;
 2697|      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 (2697:9): [True: 0, False: 0]
  ------------------
 2698|      0|      return BLOSC2_ERROR_FILE_WRITE;
 2699|      0|    }
 2700|      0|    framep = header_ptr;
 2701|      0|  }
 2702|  1.02M|  uint32_t prev_h2len;
 2703|  1.02M|  from_big(&prev_h2len, framep + FRAME_HEADER_LEN, sizeof(prev_h2len));
  ------------------
  |  |   38|  1.02M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2704|       |
 2705|       |  // Build a new header
 2706|  1.02M|  uint8_t* h2 = new_header_frame(schunk, frame);
 2707|  1.02M|  if (h2 == NULL) {
  ------------------
  |  Branch (2707:7): [True: 0, False: 1.02M]
  ------------------
 2708|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2709|      0|  }
 2710|  1.02M|  uint32_t h2len;
 2711|  1.02M|  from_big(&h2len, h2 + FRAME_HEADER_LEN, sizeof(h2len));
  ------------------
  |  |   38|  1.02M|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2712|       |
 2713|       |  // The frame length is outdated when adding a new metalayer, so update it
 2714|  1.02M|  if (new) {
  ------------------
  |  Branch (2714:7): [True: 5.10k, False: 1.01M]
  ------------------
 2715|  5.10k|    int64_t frame_len = h2len;  // at adding time, we only have to worry of the header for now
 2716|  5.10k|    to_big(h2 + FRAME_LEN, &frame_len, sizeof(frame_len));
  ------------------
  |  |   37|  5.10k|#define to_big(dest, src, itemsize)       endian_handler(false, dest, src, itemsize)
  ------------------
 2717|  5.10k|    frame->len = frame_len;
 2718|  5.10k|  }
 2719|       |
 2720|  1.02M|  if (!new && prev_h2len != h2len) {
  ------------------
  |  Branch (2720:7): [True: 1.01M, False: 5.10k]
  |  Branch (2720:15): [True: 0, False: 1.01M]
  ------------------
 2721|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2722|      0|    free(h2);
 2723|      0|    return BLOSC2_ERROR_DATA;
 2724|      0|  }
 2725|       |
 2726|  1.02M|  void* fp = NULL;
 2727|  1.02M|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (2727:7): [True: 0, False: 1.02M]
  ------------------
 2728|       |    // Write updated header down to file
 2729|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2729:9): [True: 0, False: 0]
  ------------------
 2730|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 2731|      0|                             frame->schunk->storage->io);
 2732|      0|    }
 2733|      0|    else {
 2734|      0|      fp = frame_writer_acquire(frame, io_cb);
 2735|      0|    }
 2736|      0|    if (fp == NULL) {
  ------------------
  |  Branch (2736:9): [True: 0, False: 0]
  ------------------
 2737|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2738|      0|      free(h2);
 2739|      0|      return BLOSC2_ERROR_FILE_OPEN;
 2740|      0|    }
 2741|      0|    int64_t io_pos = frame->file_offset;
 2742|      0|    io_cb->write(h2, h2len, 1, io_pos, fp);
 2743|      0|    frame_writer_release(frame, io_cb, fp);
 2744|      0|  }
 2745|  1.02M|  else {
 2746|  1.02M|    if (new) {
  ------------------
  |  Branch (2746:9): [True: 5.10k, False: 1.01M]
  ------------------
 2747|  5.10k|      void *new_cframe = realloc(frame->cframe, h2len);
 2748|  5.10k|      if (new_cframe == NULL) {
  ------------------
  |  Branch (2748:11): [True: 0, False: 5.10k]
  ------------------
 2749|      0|        free(h2);
 2750|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 2751|      0|      }
 2752|  5.10k|      frame->cframe = new_cframe;
 2753|  5.10k|    }
 2754|  1.02M|    memcpy(frame->cframe, h2, h2len);
 2755|  1.02M|  }
 2756|  1.02M|  free(h2);
 2757|       |
 2758|  1.02M|  return 1;
 2759|  1.02M|}
frame_get_metalayers:
 2888|  2.71k|int frame_get_metalayers(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 2889|  2.71k|  int32_t header_len;
 2890|  2.71k|  int64_t frame_len;
 2891|  2.71k|  int64_t nbytes;
 2892|  2.71k|  int64_t cbytes;
 2893|  2.71k|  int32_t blocksize;
 2894|  2.71k|  int32_t chunksize;
 2895|  2.71k|  int64_t nchunks;
 2896|  2.71k|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 2897|  2.71k|                            &blocksize, &chunksize, &nchunks,
 2898|  2.71k|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 2899|  2.71k|                            schunk->storage->io);
 2900|  2.71k|  if (ret < 0) {
  ------------------
  |  Branch (2900:7): [True: 0, False: 2.71k]
  ------------------
 2901|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2902|      0|    return ret;
 2903|      0|  }
 2904|       |
 2905|       |  // Get the header
 2906|  2.71k|  uint8_t* header = NULL;
 2907|  2.71k|  bool needs_free = false;
 2908|  2.71k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (2908:7): [True: 2.71k, False: 0]
  ------------------
 2909|  2.71k|    header = frame->cframe;
 2910|  2.71k|  } else {
 2911|      0|    int64_t rbytes = 0;
 2912|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 2913|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (2913:9): [True: 0, False: 0]
  ------------------
 2914|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2915|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 2916|      0|    }
 2917|       |
 2918|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (2918:9): [True: 0, False: 0]
  ------------------
 2919|      0|      header = malloc(header_len);
 2920|      0|      needs_free = true;
 2921|      0|    }
 2922|      0|    else {
 2923|      0|      needs_free = false;
 2924|      0|    }
 2925|       |
 2926|      0|    void* fp = NULL;
 2927|      0|    int64_t io_pos = 0;
 2928|      0|    if (frame->sframe) {
  ------------------
  |  Branch (2928:9): [True: 0, False: 0]
  ------------------
 2929|      0|      fp = sframe_open_index(frame->urlpath, "rb",
 2930|      0|                             frame->schunk->storage->io);
 2931|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2931:11): [True: 0, False: 0]
  ------------------
 2932|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2933|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2934|      0|      }
 2935|      0|    }
 2936|      0|    else {
 2937|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 2938|      0|      if (fp == NULL) {
  ------------------
  |  Branch (2938:11): [True: 0, False: 0]
  ------------------
 2939|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2940|      0|        return BLOSC2_ERROR_FILE_OPEN;
 2941|      0|      }
 2942|      0|      io_pos = frame->file_offset;
 2943|      0|    }
 2944|      0|    if (fp != NULL) {
  ------------------
  |  Branch (2944:9): [True: 0, False: 0]
  ------------------
 2945|      0|      rbytes = io_cb->read((void**)&header, 1, header_len, io_pos, fp);
 2946|      0|      frame_reader_release(frame, io_cb, fp);
 2947|      0|    }
 2948|      0|    if (rbytes != header_len) {
  ------------------
  |  Branch (2948:9): [True: 0, False: 0]
  ------------------
 2949|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2950|      0|      if (needs_free)
  ------------------
  |  Branch (2950:11): [True: 0, False: 0]
  ------------------
 2951|      0|        free(header);
 2952|      0|      return BLOSC2_ERROR_FILE_READ;
 2953|      0|    }
 2954|      0|  }
 2955|       |
 2956|  2.71k|  ret = get_meta_from_header(frame, schunk, header, header_len);
 2957|       |
 2958|  2.71k|  if (frame->cframe == NULL && needs_free) {
  ------------------
  |  Branch (2958:7): [True: 0, False: 2.71k]
  |  Branch (2958:32): [True: 0, False: 0]
  ------------------
 2959|      0|    free(header);
 2960|      0|  }
 2961|       |
 2962|  2.71k|  return ret;
 2963|  2.71k|}
frame_get_vlmetalayers:
 3099|  2.63k|int frame_get_vlmetalayers(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 3100|  2.63k|  int32_t header_len;
 3101|  2.63k|  int64_t frame_len;
 3102|  2.63k|  int64_t nbytes;
 3103|  2.63k|  int64_t cbytes;
 3104|  2.63k|  int32_t blocksize;
 3105|  2.63k|  int32_t chunksize;
 3106|  2.63k|  int64_t nchunks;
 3107|  2.63k|  int ret = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 3108|  2.63k|                            &blocksize, &chunksize, &nchunks,
 3109|  2.63k|                            NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3110|  2.63k|                            schunk->storage->io);
 3111|  2.63k|  if (ret < 0) {
  ------------------
  |  Branch (3111:7): [True: 0, False: 2.63k]
  ------------------
 3112|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3113|      0|    return ret;
 3114|      0|  }
 3115|       |
 3116|  2.63k|  int64_t trailer_offset = get_trailer_offset(frame, header_len, nbytes > 0);
 3117|  2.63k|  int32_t trailer_len = (int32_t) frame->trailer_len;
 3118|       |
 3119|  2.63k|  if (trailer_offset < BLOSC_EXTENDED_HEADER_LENGTH || trailer_offset + trailer_len > frame->len) {
  ------------------
  |  Branch (3119:7): [True: 0, False: 2.63k]
  |  Branch (3119:56): [True: 4, False: 2.63k]
  ------------------
 3120|      4|    BLOSC_TRACE_ERROR("Cannot access the trailer out of the frame.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3121|      4|    return BLOSC2_ERROR_READ_BUFFER;
 3122|      4|  }
 3123|       |
 3124|       |  // Get the trailer
 3125|  2.63k|  uint8_t* trailer = NULL;
 3126|  2.63k|  bool needs_free = false;
 3127|  2.63k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (3127:7): [True: 2.63k, False: 0]
  ------------------
 3128|  2.63k|    trailer = frame->cframe + trailer_offset;
 3129|  2.63k|  } else {
 3130|      0|    int64_t rbytes = 0;
 3131|       |
 3132|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 3133|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (3133:9): [True: 0, False: 0]
  ------------------
 3134|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3135|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 3136|      0|    }
 3137|       |
 3138|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (3138:9): [True: 0, False: 0]
  ------------------
 3139|      0|      trailer = malloc(trailer_len);
 3140|      0|      needs_free = true;
 3141|      0|    }
 3142|      0|    else {
 3143|      0|      needs_free = false;
 3144|      0|    }
 3145|       |
 3146|      0|    void* fp = NULL;
 3147|      0|    int64_t io_pos = 0;
 3148|      0|    if (frame->sframe) {
  ------------------
  |  Branch (3148:9): [True: 0, False: 0]
  ------------------
 3149|       |      // Check for overflow before calculating length
 3150|      0|      if (strlen(frame->urlpath) > SIZE_MAX - strlen("/chunks.b2frame") - 1) {
  ------------------
  |  Branch (3150:11): [True: 0, False: 0]
  ------------------
 3151|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3152|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3152:13): [True: 0, False: 0]
  ------------------
 3153|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 3154|      0|      }
 3155|      0|      size_t _len = strlen(frame->urlpath) + strlen("/chunks.b2frame") + 1;
 3156|      0|      char* eframe_name = malloc(_len);
 3157|      0|      if (eframe_name == NULL) {
  ------------------
  |  Branch (3157:11): [True: 0, False: 0]
  ------------------
 3158|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3159|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3159:13): [True: 0, False: 0]
  ------------------
 3160|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 3161|      0|      }
 3162|      0|      int _w = snprintf(eframe_name, _len, "%s/chunks.b2frame", frame->urlpath);
 3163|      0|      if (_w < 0 || (size_t)_w >= _len) {
  ------------------
  |  Branch (3163:11): [True: 0, False: 0]
  |  Branch (3163:21): [True: 0, False: 0]
  ------------------
 3164|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3165|      0|        free(eframe_name);
 3166|      0|        if (needs_free) free(trailer);
  ------------------
  |  Branch (3166:13): [True: 0, False: 0]
  ------------------
 3167|      0|        return BLOSC2_ERROR_INVALID_PARAM;
 3168|      0|      }
 3169|      0|      fp = io_cb->open(eframe_name, "rb", frame->schunk->storage->io->params);
 3170|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3170:11): [True: 0, False: 0]
  ------------------
 3171|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3172|      0|        free(eframe_name);
 3173|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3174|      0|      }
 3175|      0|      free(eframe_name);
 3176|      0|      io_pos = trailer_offset;
 3177|      0|    }
 3178|      0|    else {
 3179|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 3180|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3180:11): [True: 0, False: 0]
  ------------------
 3181|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3182|      0|        return BLOSC2_ERROR_FILE_OPEN;
 3183|      0|      }
 3184|      0|      io_pos = frame->file_offset + trailer_offset;
 3185|      0|    }
 3186|      0|    if (fp != NULL) {
  ------------------
  |  Branch (3186:9): [True: 0, False: 0]
  ------------------
 3187|      0|      rbytes = io_cb->read((void**)&trailer, 1, trailer_len, io_pos, fp);
 3188|      0|      frame_reader_release(frame, io_cb, fp);
 3189|      0|    }
 3190|      0|    if (rbytes != trailer_len) {
  ------------------
  |  Branch (3190:9): [True: 0, False: 0]
  ------------------
 3191|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3192|      0|      if (needs_free)
  ------------------
  |  Branch (3192:11): [True: 0, False: 0]
  ------------------
 3193|      0|        free(trailer);
 3194|      0|      return BLOSC2_ERROR_FILE_READ;
 3195|      0|    }
 3196|      0|  }
 3197|       |
 3198|  2.63k|  ret = get_vlmeta_from_trailer(frame, schunk, trailer, trailer_len);
 3199|       |
 3200|  2.63k|  if (frame->cframe == NULL && needs_free) {
  ------------------
  |  Branch (3200:7): [True: 0, False: 2.63k]
  |  Branch (3200:32): [True: 0, False: 0]
  ------------------
 3201|      0|    free(trailer);
 3202|      0|  }
 3203|       |
 3204|  2.63k|  return ret;
 3205|  2.63k|}
get_new_storage:
 3211|  16.7k|                                const blosc2_io* iodefaults) {
 3212|       |
 3213|  16.7k|  blosc2_storage* new_storage = (blosc2_storage*)calloc(1, sizeof(blosc2_storage));
 3214|  16.7k|  memcpy(new_storage, storage, sizeof(blosc2_storage));
 3215|  16.7k|  if (storage->urlpath != NULL) {
  ------------------
  |  Branch (3215:7): [True: 0, False: 16.7k]
  ------------------
 3216|      0|    char* urlpath = normalize_urlpath(storage->urlpath);
 3217|      0|    new_storage->urlpath = malloc(strlen(urlpath) + 1);
 3218|      0|    strcpy(new_storage->urlpath, urlpath);
 3219|      0|  }
 3220|       |
 3221|       |  // cparams
 3222|  16.7k|  blosc2_cparams* cparams = malloc(sizeof(blosc2_cparams));
 3223|  16.7k|  if (storage->cparams != NULL) {
  ------------------
  |  Branch (3223:7): [True: 12.4k, False: 4.26k]
  ------------------
 3224|  12.4k|    memcpy(cparams, storage->cparams, sizeof(blosc2_cparams));
 3225|  12.4k|  } else {
 3226|  4.26k|    memcpy(cparams, cdefaults, sizeof(blosc2_cparams));
 3227|  4.26k|  }
 3228|  16.7k|  new_storage->cparams = cparams;
 3229|       |
 3230|       |  // dparams
 3231|  16.7k|  blosc2_dparams* dparams = malloc(sizeof(blosc2_dparams));
 3232|  16.7k|  if (storage->dparams != NULL) {
  ------------------
  |  Branch (3232:7): [True: 12.4k, False: 4.26k]
  ------------------
 3233|  12.4k|    memcpy(dparams, storage->dparams, sizeof(blosc2_dparams));
 3234|  12.4k|  }
 3235|  4.26k|  else {
 3236|  4.26k|    memcpy(dparams, ddefaults, sizeof(blosc2_dparams));
 3237|  4.26k|  }
 3238|  16.7k|  new_storage->dparams = dparams;
 3239|       |
 3240|       |  // iodefaults
 3241|  16.7k|  blosc2_io* udio = malloc(sizeof(blosc2_io));
 3242|  16.7k|  if (storage->io != NULL) {
  ------------------
  |  Branch (3242:7): [True: 0, False: 16.7k]
  ------------------
 3243|      0|    memcpy(udio, storage->io, sizeof(blosc2_io));
 3244|      0|  }
 3245|  16.7k|  else {
 3246|  16.7k|    memcpy(udio, iodefaults, sizeof(blosc2_io));
 3247|  16.7k|  }
 3248|  16.7k|  new_storage->io = udio;
 3249|       |
 3250|  16.7k|  return new_storage;
 3251|  16.7k|}
frame_to_schunk:
 3315|  4.77k|blosc2_schunk* frame_to_schunk(blosc2_frame_s* frame, bool copy, const blosc2_io *udio) {
 3316|  4.77k|  int32_t header_len;
 3317|  4.77k|  int64_t frame_len;
 3318|  4.77k|  int rc;
 3319|  4.77k|  bool frame_attached = true;
 3320|  4.77k|  blosc2_schunk* schunk = calloc(1, sizeof(blosc2_schunk));
 3321|  4.77k|  blosc2_cparams *cparams = NULL;
 3322|  4.77k|  blosc2_dparams *dparams = NULL;
 3323|  4.77k|  int64_t *offsets = NULL;
 3324|  4.77k|  if (schunk == NULL) {
  ------------------
  |  Branch (3324:7): [True: 0, False: 4.77k]
  ------------------
 3325|      0|    return NULL;
 3326|      0|  }
 3327|  4.77k|  schunk->frame = (blosc2_frame*)frame;
 3328|  4.77k|  frame->schunk = schunk;
 3329|       |
 3330|  4.77k|  rc = get_header_info(frame, &header_len, &frame_len, &schunk->nbytes,
 3331|  4.77k|                       &schunk->cbytes, &schunk->blocksize,
 3332|  4.77k|                       &schunk->chunksize, &schunk->nchunks, &schunk->typesize,
 3333|  4.77k|                       &schunk->compcode, &schunk->compcode_meta, &schunk->clevel, schunk->filters,
 3334|  4.77k|                       schunk->filters_meta, &schunk->splitmode, &schunk->use_dict, udio);
 3335|  4.77k|  if (rc < 0) {
  ------------------
  |  Branch (3335:7): [True: 480, False: 4.29k]
  ------------------
 3336|    480|    BLOSC_TRACE_ERROR("Unable to get meta info from frame.");
  ------------------
  |  |   93|    480|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    480|    do {                                            \
  |  |  |  |   98|    480|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    480|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 480, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    480|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3337|    480|    goto error;
 3338|    480|  }
 3339|  4.29k|  int64_t nchunks = schunk->nchunks;
 3340|  4.29k|  int64_t nbytes = schunk->nbytes;
 3341|  4.29k|  (void) nbytes;
 3342|  4.29k|  int64_t cbytes = schunk->cbytes;
 3343|       |
 3344|       |  // Compression and decompression contexts
 3345|  4.29k|  blosc2_schunk_get_cparams(schunk, &cparams);
 3346|  4.29k|  schunk->cctx = blosc2_create_cctx(*cparams);
 3347|  4.29k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (3347:7): [True: 31, False: 4.26k]
  ------------------
 3348|     31|    BLOSC_TRACE_ERROR("Error while creating the compression context");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3349|     31|    goto error;
 3350|     31|  }
 3351|  4.26k|  blosc2_schunk_get_dparams(schunk, &dparams);
 3352|  4.26k|  schunk->dctx = blosc2_create_dctx(*dparams);
 3353|  4.26k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (3353:7): [True: 0, False: 4.26k]
  ------------------
 3354|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3355|      0|    goto error;
 3356|      0|  }
 3357|  4.26k|  blosc2_storage storage = {.contiguous = copy ? false : true};
  ------------------
  |  Branch (3357:43): [True: 0, False: 4.26k]
  ------------------
 3358|  4.26k|  schunk->storage = get_new_storage(&storage, cparams, dparams, udio);
 3359|  4.26k|  free(cparams);
 3360|  4.26k|  cparams = NULL;
 3361|  4.26k|  free(dparams);
 3362|  4.26k|  dparams = NULL;
 3363|  4.26k|  if (nchunks > 0) {
  ------------------
  |  Branch (3363:7): [True: 3.82k, False: 437]
  ------------------
 3364|  3.82k|    rc = validate_offsets_chunk(frame, header_len, cbytes, nchunks);
 3365|  3.82k|    if (rc < 0) {
  ------------------
  |  Branch (3365:9): [True: 1.48k, False: 2.34k]
  ------------------
 3366|  1.48k|      BLOSC_TRACE_ERROR("Cannot validate frame offsets.");
  ------------------
  |  |   93|  1.48k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  1.48k|    do {                                            \
  |  |  |  |   98|  1.48k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  1.48k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 1.48k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  1.48k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3367|  1.48k|      goto error;
 3368|  1.48k|    }
 3369|  3.82k|  }
 3370|  2.77k|  if (nchunks > 0) {
  ------------------
  |  Branch (3370:7): [True: 2.34k, False: 437]
  ------------------
 3371|  2.34k|    uint8_t *chunk;
 3372|  2.34k|    bool needs_free;
 3373|       |    // A lazy chunk is enough here: only the header is needed for the flags2 byte
 3374|  2.34k|    rc = frame_get_lazychunk(frame, 0, &chunk, &needs_free);
 3375|  2.34k|    if (rc < 0) {
  ------------------
  |  Branch (3375:9): [True: 63, False: 2.27k]
  ------------------
 3376|     63|      BLOSC_TRACE_ERROR("Cannot inspect the first chunk in frame.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3377|     63|      goto error;
 3378|     63|    }
 3379|  2.27k|    schunk->flags2 = (rc >= BLOSC_EXTENDED_HEADER_LENGTH) ? chunk[BLOSC2_CHUNK_BLOSC2_FLAGS2] : 0;
  ------------------
  |  Branch (3379:22): [True: 2.27k, False: 0]
  ------------------
 3380|  2.27k|    if (needs_free) {
  ------------------
  |  Branch (3380:9): [True: 490, False: 1.78k]
  ------------------
 3381|    490|      free(chunk);
 3382|    490|    }
 3383|  2.27k|  }
 3384|  2.71k|  if (!copy) {
  ------------------
  |  Branch (3384:7): [True: 2.71k, False: 0]
  ------------------
 3385|  2.71k|    goto out;
 3386|  2.71k|  }
 3387|       |
 3388|       |  // We are not attached to a frame anymore
 3389|      0|  schunk->frame = NULL;
 3390|      0|  frame_attached = false;
 3391|       |
 3392|      0|  if (nchunks == 0) {
  ------------------
  |  Branch (3392:7): [True: 0, False: 0]
  ------------------
 3393|      0|    frame->schunk = NULL;
 3394|      0|    goto out;
 3395|      0|  }
 3396|       |
 3397|       |  // Get the compressed offsets
 3398|      0|  int32_t coffsets_cbytes = 0;
 3399|      0|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 3400|      0|  if (coffsets == NULL) {
  ------------------
  |  Branch (3400:7): [True: 0, False: 0]
  ------------------
 3401|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3402|      0|    goto error;
 3403|      0|  }
 3404|       |
 3405|       |  // Decompress offsets
 3406|      0|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 3407|      0|  blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 3408|      0|  if (dctx == NULL) {
  ------------------
  |  Branch (3408:7): [True: 0, False: 0]
  ------------------
 3409|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3410|      0|    goto error;
 3411|      0|  }
 3412|      0|  int32_t offsets_nbytes;
 3413|      0|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &offsets_nbytes)) {
  ------------------
  |  Branch (3413:7): [True: 0, False: 0]
  ------------------
 3414|      0|    blosc2_free_ctx(dctx);
 3415|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3416|      0|    goto error;
 3417|      0|  }
 3418|      0|  offsets = (int64_t *) malloc((size_t)offsets_nbytes);
 3419|      0|  if (offsets == NULL) {
  ------------------
  |  Branch (3419:7): [True: 0, False: 0]
  ------------------
 3420|      0|    blosc2_free_ctx(dctx);
 3421|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3422|      0|    goto error;
 3423|      0|  }
 3424|      0|  int32_t off_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes,
 3425|      0|                                             offsets, offsets_nbytes);
 3426|      0|  blosc2_free_ctx(dctx);
 3427|      0|  if (off_nbytes < 0) {
  ------------------
  |  Branch (3427:7): [True: 0, False: 0]
  ------------------
 3428|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3429|      0|    goto error;
 3430|      0|  }
 3431|       |
 3432|       |  // We want the contiguous schunk, so create the actual data chunks (and, while doing this,
 3433|       |  // get a guess at the blocksize used in this frame)
 3434|      0|  int64_t acc_nbytes = 0;
 3435|      0|  int64_t acc_cbytes = 0;
 3436|      0|  int32_t blocksize = 0;
 3437|      0|  int32_t chunk_nbytes;
 3438|      0|  int32_t chunk_cbytes;
 3439|      0|  int32_t chunk_blocksize;
 3440|      0|  size_t prev_alloc = BLOSC_EXTENDED_HEADER_LENGTH;
 3441|      0|  uint8_t* data_chunk = NULL;
 3442|      0|  bool needs_free = false;
 3443|      0|  const blosc2_io_cb *io_cb = blosc2_get_io_cb(udio->id);
 3444|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (3444:7): [True: 0, False: 0]
  ------------------
 3445|      0|    blosc2_schunk_free(schunk);
 3446|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3447|      0|    return NULL;
 3448|      0|  }
 3449|       |
 3450|      0|  void* fp = NULL;
 3451|      0|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (3451:7): [True: 0, False: 0]
  ------------------
 3452|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (3452:9): [True: 0, False: 0]
  ------------------
 3453|      0|      data_chunk = malloc((size_t)prev_alloc);
 3454|      0|      needs_free = true;
 3455|      0|    }
 3456|      0|    else {
 3457|      0|      needs_free = false;
 3458|      0|    }
 3459|       |
 3460|      0|    if (!frame->sframe) {
  ------------------
  |  Branch (3460:9): [True: 0, False: 0]
  ------------------
 3461|       |      // If not the chunks won't be in the frame
 3462|      0|      fp = frame_reader_acquire(frame, udio);
 3463|      0|      if (fp == NULL) {
  ------------------
  |  Branch (3463:11): [True: 0, False: 0]
  ------------------
 3464|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3465|      0|        rc = BLOSC2_ERROR_FILE_OPEN;
 3466|      0|        goto end;
 3467|      0|      }
 3468|      0|    }
 3469|      0|  }
 3470|       |  /* calloc(): the loop below can stop at a bad chunk, and the error path frees
 3471|       |     every data[i] with i < nchunks, also the ones never set */
 3472|      0|  schunk->data = calloc(nchunks, sizeof(void*));
 3473|      0|  if (schunk->data == NULL && nchunks > 0) {
  ------------------
  |  Branch (3473:7): [True: 0, False: 0]
  |  Branch (3473:31): [True: 0, False: 0]
  ------------------
 3474|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3475|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 3476|      0|    goto end;
 3477|      0|  }
 3478|      0|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (3478:23): [True: 0, False: 0]
  ------------------
 3479|      0|    if (frame->cframe != NULL) {
  ------------------
  |  Branch (3479:9): [True: 0, False: 0]
  ------------------
 3480|      0|      if (needs_free) {
  ------------------
  |  Branch (3480:11): [True: 0, False: 0]
  ------------------
 3481|      0|        free(data_chunk);
 3482|      0|      }
 3483|      0|      if (offsets[i] < 0) {
  ------------------
  |  Branch (3483:11): [True: 0, False: 0]
  ------------------
 3484|      0|        int64_t rbytes = frame_get_chunk(frame, i, &data_chunk, &needs_free);
 3485|      0|        if (rbytes < 0) {
  ------------------
  |  Branch (3485:13): [True: 0, False: 0]
  ------------------
 3486|      0|          break;
 3487|      0|        }
 3488|      0|      }
 3489|      0|      else {
 3490|      0|        if (offsets[i] > INT64_MAX - header_len ||
  ------------------
  |  Branch (3490:13): [True: 0, False: 0]
  ------------------
 3491|      0|            header_len + offsets[i] > frame->len - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3491:13): [True: 0, False: 0]
  ------------------
 3492|      0|            offsets[i] > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3492:13): [True: 0, False: 0]
  ------------------
 3493|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 3494|      0|          break;
 3495|      0|        }
 3496|      0|        data_chunk = frame->cframe + header_len + offsets[i];
 3497|      0|        needs_free = false;
 3498|      0|      }
 3499|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 3500|      0|      if (rc < 0) {
  ------------------
  |  Branch (3500:11): [True: 0, False: 0]
  ------------------
 3501|      0|        break;
 3502|      0|      }
 3503|      0|      if (offsets[i] >= 0 &&
  ------------------
  |  Branch (3503:11): [True: 0, False: 0]
  ------------------
 3504|      0|          (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3504:12): [True: 0, False: 0]
  ------------------
 3505|      0|           offsets[i] > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (3505:12): [True: 0, False: 0]
  ------------------
 3506|      0|           offsets[i] + chunk_cbytes > cbytes)) {
  ------------------
  |  Branch (3506:12): [True: 0, False: 0]
  ------------------
 3507|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 3508|      0|        break;
 3509|      0|      }
 3510|      0|    }
 3511|      0|    else {
 3512|      0|      int64_t rbytes;
 3513|      0|      if (offsets[i] < 0 || frame->sframe) {
  ------------------
  |  Branch (3513:11): [True: 0, False: 0]
  |  Branch (3513:29): [True: 0, False: 0]
  ------------------
 3514|      0|        if (needs_free) {
  ------------------
  |  Branch (3514:13): [True: 0, False: 0]
  ------------------
 3515|      0|          free(data_chunk);
 3516|      0|        }
 3517|      0|        rbytes = frame_get_chunk(frame, i, &data_chunk, &needs_free);
 3518|      0|        if (rbytes < 0) {
  ------------------
  |  Branch (3518:13): [True: 0, False: 0]
  ------------------
 3519|      0|          break;
 3520|      0|        }
 3521|      0|      }
 3522|      0|      else {
 3523|      0|        if (offsets[i] > INT64_MAX - header_len ||
  ------------------
  |  Branch (3523:13): [True: 0, False: 0]
  ------------------
 3524|      0|            header_len + offsets[i] > frame->len - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3524:13): [True: 0, False: 0]
  ------------------
 3525|      0|            offsets[i] > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3525:13): [True: 0, False: 0]
  ------------------
 3526|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 3527|      0|          break;
 3528|      0|        }
 3529|      0|        int64_t io_pos = frame->file_offset + header_len + offsets[i];
 3530|      0|        rbytes = io_cb->read((void**)&data_chunk, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 3531|      0|      }
 3532|      0|      if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3532:11): [True: 0, False: 0]
  ------------------
 3533|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 3534|      0|        break;
 3535|      0|      }
 3536|      0|      rc = blosc2_cbuffer_sizes(data_chunk, NULL, &chunk_cbytes, NULL);
 3537|      0|      if (rc < 0) {
  ------------------
  |  Branch (3537:11): [True: 0, False: 0]
  ------------------
 3538|      0|        break;
 3539|      0|      }
 3540|      0|      if (offsets[i] >= 0 &&
  ------------------
  |  Branch (3540:11): [True: 0, False: 0]
  ------------------
 3541|      0|          (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3541:12): [True: 0, False: 0]
  ------------------
 3542|      0|           offsets[i] > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (3542:12): [True: 0, False: 0]
  ------------------
 3543|      0|           offsets[i] + chunk_cbytes > cbytes)) {
  ------------------
  |  Branch (3543:12): [True: 0, False: 0]
  ------------------
 3544|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 3545|      0|        break;
 3546|      0|      }
 3547|      0|      if (chunk_cbytes > (int32_t)prev_alloc) {
  ------------------
  |  Branch (3547:11): [True: 0, False: 0]
  ------------------
 3548|      0|        if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (3548:13): [True: 0, False: 0]
  ------------------
 3549|      0|          data_chunk = realloc(data_chunk, chunk_cbytes);
 3550|      0|        if (data_chunk == NULL) {
  ------------------
  |  Branch (3550:13): [True: 0, False: 0]
  ------------------
 3551|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3552|      0|          rc = BLOSC2_ERROR_MEMORY_ALLOC;
 3553|      0|          break;
 3554|      0|        }
 3555|      0|        prev_alloc = chunk_cbytes;
 3556|      0|      }
 3557|      0|      if (!frame->sframe) {
  ------------------
  |  Branch (3557:11): [True: 0, False: 0]
  ------------------
 3558|      0|        int64_t io_pos = frame->file_offset + header_len + offsets[i];
 3559|      0|        rbytes = io_cb->read((void**)&data_chunk, 1, chunk_cbytes, io_pos, fp);
 3560|      0|        if (rbytes != chunk_cbytes) {
  ------------------
  |  Branch (3560:13): [True: 0, False: 0]
  ------------------
 3561|      0|          rc = BLOSC2_ERROR_READ_BUFFER;
 3562|      0|          break;
 3563|      0|        }
 3564|      0|      }
 3565|      0|    }
 3566|      0|    uint8_t* new_chunk = malloc(chunk_cbytes);
 3567|      0|    memcpy(new_chunk, data_chunk, chunk_cbytes);
 3568|      0|    schunk->data[i] = new_chunk;
 3569|      0|    rc = blosc2_cbuffer_sizes(data_chunk, &chunk_nbytes, NULL, &chunk_blocksize);
 3570|      0|    if (rc < 0) {
  ------------------
  |  Branch (3570:9): [True: 0, False: 0]
  ------------------
 3571|      0|      break;
 3572|      0|    }
 3573|      0|    acc_nbytes += chunk_nbytes;
 3574|      0|    acc_cbytes += chunk_cbytes;
 3575|      0|    if (i == 0) {
  ------------------
  |  Branch (3575:9): [True: 0, False: 0]
  ------------------
 3576|      0|      blocksize = chunk_blocksize;
 3577|      0|    }
 3578|      0|    else if (blocksize != chunk_blocksize) {
  ------------------
  |  Branch (3578:14): [True: 0, False: 0]
  ------------------
 3579|       |      // Blocksize varies
 3580|      0|      blocksize = 0;
 3581|      0|    }
 3582|      0|  }
 3583|       |
 3584|       |  // We are not attached to a schunk anymore
 3585|      0|  frame->schunk = NULL;
 3586|       |
 3587|      0|  end:
 3588|      0|  if (needs_free) {
  ------------------
  |  Branch (3588:7): [True: 0, False: 0]
  ------------------
 3589|      0|    free(data_chunk);
 3590|      0|  }
 3591|      0|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (3591:7): [True: 0, False: 0]
  ------------------
 3592|      0|    if (!frame->sframe) {
  ------------------
  |  Branch (3592:9): [True: 0, False: 0]
  ------------------
 3593|      0|      frame_reader_release(frame, io_cb, fp);
 3594|      0|    }
 3595|      0|  }
 3596|      0|  free(offsets);
 3597|       |  // Avoid a double-free in the `error:` cleanup below, which is reached
 3598|       |  // when frame_get_metalayers / frame_get_vlmetalayers reject a malformed
 3599|       |  // metalayer index after we've already freed `offsets` here.
 3600|      0|  offsets = NULL;
 3601|       |
 3602|       |  // cframes and sframes have different ways to store chunks with special values:
 3603|       |  // 1) cframes represent special chunks as negative offsets
 3604|       |  // 2) sframes does not have the concept of offsets, but rather of data pointers (.data)
 3605|       |  //    so they always have a pointer to a special chunk
 3606|       |  // This is why cframes and sframes have different cbytes and hence, we cannot enforce acc_bytes == schunk->cbytes
 3607|       |  // In the future, maybe we could provide special meanings for .data[i] > 0x7FFFFFFF, but not there yet
 3608|       |  // if (rc < 0 || acc_nbytes != nbytes || acc_cbytes != cbytes) {
 3609|      0|  if (rc < 0 || acc_nbytes != nbytes) {
  ------------------
  |  Branch (3609:7): [True: 0, False: 0]
  |  Branch (3609:17): [True: 0, False: 0]
  ------------------
 3610|      0|    goto error;
 3611|      0|  }
 3612|       |  // Update counters
 3613|      0|  schunk->cbytes = acc_cbytes;
 3614|      0|  schunk->blocksize = blocksize;
 3615|       |
 3616|  2.71k|  out:
 3617|  2.71k|  rc = frame_get_metalayers(frame, schunk);
 3618|  2.71k|  if (rc < 0) {
  ------------------
  |  Branch (3618:7): [True: 80, False: 2.63k]
  ------------------
 3619|     80|    BLOSC_TRACE_ERROR("Cannot access the metalayers.");
  ------------------
  |  |   93|     80|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     80|    do {                                            \
  |  |  |  |   98|     80|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     80|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 80, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     80|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3620|     80|    goto error;
 3621|     80|  }
 3622|       |
 3623|  2.63k|  rc = frame_get_vlmetalayers(frame, schunk);
 3624|  2.63k|  if (rc < 0) {
  ------------------
  |  Branch (3624:7): [True: 88, False: 2.54k]
  ------------------
 3625|     88|    BLOSC_TRACE_ERROR("Cannot access the vlmetalayers.");
  ------------------
  |  |   93|     88|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     88|    do {                                            \
  |  |  |  |   98|     88|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     88|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 88, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     88|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3626|     88|    goto error;
 3627|     88|  }
 3628|       |
 3629|  2.54k|  return schunk;
 3630|       |
 3631|  2.22k|error:
 3632|  2.22k|  free(cparams);
 3633|  2.22k|  free(dparams);
 3634|  2.22k|  free(offsets);
 3635|  2.22k|  if (schunk != NULL) {
  ------------------
  |  Branch (3635:7): [True: 2.22k, False: 0]
  ------------------
 3636|  2.22k|    blosc2_schunk_free(schunk);
 3637|  2.22k|  }
 3638|  2.22k|  if (!frame_attached) {
  ------------------
  |  Branch (3638:7): [True: 0, False: 2.22k]
  ------------------
 3639|      0|    frame->schunk = NULL;
 3640|      0|    frame_free(frame);
 3641|      0|  }
 3642|       |  return NULL;
 3643|  2.63k|}
get_coffset:
 3665|  2.72M|                int64_t nchunk, int64_t nchunks, int64_t *offset) {
 3666|  2.72M|  int32_t off_cbytes;
 3667|       |  // Get the offset to nchunk
 3668|  2.72M|  uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &off_cbytes);
 3669|  2.72M|  if (coffsets == NULL) {
  ------------------
  |  Branch (3669:7): [True: 0, False: 2.72M]
  ------------------
 3670|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3671|      0|    return BLOSC2_ERROR_DATA;
 3672|      0|  }
 3673|       |
 3674|       |  // Get the 64-bit offset
 3675|  2.72M|  int rc = blosc2_getitem(coffsets, off_cbytes, (int32_t)nchunk, 1, offset, (int32_t)sizeof(int64_t));
 3676|  2.72M|  if (rc < 0) {
  ------------------
  |  Branch (3676:7): [True: 8, False: 2.72M]
  ------------------
 3677|      8|    BLOSC_TRACE_ERROR("Problems retrieving a chunk offset.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3678|  2.72M|  } else if (!frame->sframe && *offset >= 0) {
  ------------------
  |  Branch (3678:14): [True: 2.72M, False: 0]
  |  Branch (3678:32): [True: 1.59M, False: 1.12M]
  ------------------
 3679|  1.59M|    if (cbytes < 0 || cbytes > INT64_MAX - header_len) {
  ------------------
  |  Branch (3679:9): [True: 0, False: 1.59M]
  |  Branch (3679:23): [True: 22, False: 1.59M]
  ------------------
 3680|     22|      BLOSC_TRACE_ERROR("Invalid compressed size in frame header.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3681|     22|      return BLOSC2_ERROR_INVALID_HEADER;
 3682|     22|    }
 3683|  1.59M|    if (*offset > INT64_MAX - header_len) {
  ------------------
  |  Branch (3683:9): [True: 0, False: 1.59M]
  ------------------
 3684|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3685|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3686|      0|    }
 3687|  1.59M|    int64_t chunk_pos = header_len + *offset;
 3688|  1.59M|    int64_t data_limit = header_len + cbytes;
 3689|  1.59M|    if (chunk_pos < header_len ||
  ------------------
  |  Branch (3689:9): [True: 0, False: 1.59M]
  ------------------
 3690|  1.59M|        chunk_pos > data_limit - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (3690:9): [True: 17, False: 1.59M]
  ------------------
 3691|  1.59M|        chunk_pos > frame->len - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3691:9): [True: 13, False: 1.59M]
  ------------------
 3692|     30|      BLOSC_TRACE_ERROR("Cannot read chunk %" PRId64 " outside of frame boundary.", nchunk);
  ------------------
  |  |   93|     30|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     30|    do {                                            \
  |  |  |  |   98|     30|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     30|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     30|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3693|     30|      return BLOSC2_ERROR_INVALID_HEADER;
 3694|     30|    }
 3695|  1.59M|  }
 3696|       |
 3697|  2.72M|  return rc;
 3698|  2.72M|}
frame_get_chunks_special:
 3769|  62.4k|int frame_get_chunks_special(blosc2_frame_s *frame, const int64_t *nchunks, int64_t n, uint8_t *special) {
 3770|  62.4k|  int64_t *off;
 3771|  62.4k|  int64_t lo;
 3772|  62.4k|  int64_t span_end;
 3773|  62.4k|  int32_t header_len;
 3774|  62.4k|  int64_t cbytes;
 3775|  62.4k|  int32_t chunksize;
 3776|  62.4k|  int rc = frame_read_index_span(frame, nchunks, n, 0, &off, &lo, &span_end, &header_len, &cbytes, &chunksize);
 3777|  62.4k|  if (rc < 0 || off == NULL) {
  ------------------
  |  Branch (3777:7): [True: 37.8k, False: 24.6k]
  |  Branch (3777:17): [True: 0, False: 24.6k]
  ------------------
 3778|  37.8k|    return rc;
 3779|  37.8k|  }
 3780|   839k|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (3780:23): [True: 814k, False: 24.6k]
  ------------------
 3781|   814k|    int64_t offset = off[nchunks[k] - lo];
 3782|   814k|    special[k] = offset < 0 ? (uint8_t) (((uint64_t) offset >> (8 * 7)) & BLOSC2_SPECIAL_MASK) : 0;
  ------------------
  |  Branch (3782:18): [True: 178k, False: 636k]
  ------------------
 3783|   814k|  }
 3784|  24.6k|  free(off);
 3785|  24.6k|  return BLOSC2_ERROR_SUCCESS;
 3786|  62.4k|}
frame_special_chunk:
 3881|  20.5k|                        uint8_t** chunk, int32_t cbytes, bool *needs_free) {
 3882|  20.5k|  *chunk = malloc(cbytes);
 3883|  20.5k|  *needs_free = true;
 3884|  20.5k|  int rc = *chunk == NULL ? BLOSC2_ERROR_MEMORY_ALLOC
  ------------------
  |  Branch (3884:12): [True: 0, False: 20.5k]
  ------------------
 3885|  20.5k|                          : special_chunk_into(special_value, nbytes, typesize, blocksize, *chunk, cbytes);
 3886|  20.5k|  if (rc < 0) {
  ------------------
  |  Branch (3886:7): [True: 0, False: 20.5k]
  ------------------
 3887|      0|    free(*chunk);
 3888|      0|    *needs_free = false;
 3889|      0|    *chunk = NULL;
 3890|      0|  }
 3891|       |
 3892|  20.5k|  return rc;
 3893|  20.5k|}
frame_get_lazychunk:
 4090|  68.1k|int frame_get_lazychunk(blosc2_frame_s *frame, int64_t nchunk, uint8_t **chunk, bool *needs_free) {
 4091|  68.1k|  int32_t header_len;
 4092|  68.1k|  int64_t frame_len;
 4093|  68.1k|  int64_t nbytes;
 4094|  68.1k|  int64_t cbytes;
 4095|  68.1k|  int32_t blocksize;
 4096|  68.1k|  int32_t chunksize;
 4097|  68.1k|  int64_t nchunks;
 4098|  68.1k|  int32_t typesize;
 4099|  68.1k|  int32_t lazychunk_cbytes;
 4100|  68.1k|  int64_t offset;
 4101|  68.1k|  void* fp = NULL;
 4102|  68.1k|  int32_t* block_csizes = NULL;
 4103|  68.1k|  struct csize_idx *csize_idx = NULL;
 4104|       |
 4105|  68.1k|  *chunk = NULL;
 4106|  68.1k|  *needs_free = false;
 4107|  68.1k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 4108|  68.1k|                           &blocksize, &chunksize, &nchunks,
 4109|  68.1k|                           &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4110|  68.1k|                           frame->schunk->storage->io);
 4111|  68.1k|  if (rc < 0) {
  ------------------
  |  Branch (4111:7): [True: 0, False: 68.1k]
  ------------------
 4112|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4113|      0|    return rc;
 4114|      0|  }
 4115|  68.1k|  rc = frame_refresh_if_stale(frame, frame_len);
 4116|  68.1k|  if (rc < 0) {
  ------------------
  |  Branch (4116:7): [True: 0, False: 68.1k]
  ------------------
 4117|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4118|      0|    return rc;
 4119|      0|  }
 4120|  68.1k|  if (rc > 0) {
  ------------------
  |  Branch (4120:7): [True: 0, False: 68.1k]
  ------------------
 4121|       |    // Keep the schunk-level counters in sync with the refreshed on-disk state
 4122|       |    // (see frame_get_chunk).
 4123|      0|    frame->schunk->nbytes = nbytes;
 4124|      0|    frame->schunk->cbytes = cbytes;
 4125|      0|    frame->schunk->nchunks = nchunks;
 4126|      0|  }
 4127|       |
 4128|  68.1k|  if (nchunk >= nchunks) {
  ------------------
  |  Branch (4128:7): [True: 0, False: 68.1k]
  ------------------
 4129|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4130|      0|                      "('%" PRId64 "') in frame.", nchunk, nchunks);
 4131|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4132|      0|  }
 4133|       |
 4134|       |  // Get the offset to nchunk
 4135|  68.1k|  rc = get_coffset(frame, header_len, cbytes, nchunk, nchunks, &offset);
 4136|  68.1k|  if (rc < 0) {
  ------------------
  |  Branch (4136:7): [True: 60, False: 68.1k]
  ------------------
 4137|     60|    BLOSC_TRACE_ERROR("Unable to get offset to chunk %" PRId64 ".", nchunk);
  ------------------
  |  |   93|     60|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     60|    do {                                            \
  |  |  |  |   98|     60|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     60|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     60|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4138|     60|    return rc;
 4139|     60|  }
 4140|       |
 4141|  68.1k|  if (offset < 0) {
  ------------------
  |  Branch (4141:7): [True: 5.25k, False: 62.8k]
  ------------------
 4142|       |    // Special value
 4143|  5.25k|    if (chunksize <= 0) {
  ------------------
  |  Branch (4143:9): [True: 3, False: 5.25k]
  ------------------
 4144|      3|      BLOSC_TRACE_ERROR("Cannot synthesize special chunk with chunksize <= 0.");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4145|      3|      return BLOSC2_ERROR_INVALID_HEADER;
 4146|      3|    }
 4147|  5.25k|    lazychunk_cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 4148|  5.25k|    int32_t chunksize_ = chunksize;
 4149|  5.25k|    if ((nchunk == nchunks - 1) && (nbytes % chunksize)) {
  ------------------
  |  Branch (4149:9): [True: 340, False: 4.91k]
  |  Branch (4149:36): [True: 0, False: 340]
  ------------------
 4150|       |      // Last chunk is incomplete.  Compute its actual size.
 4151|      0|      chunksize_ = (int32_t) (nbytes % chunksize);
 4152|      0|    }
 4153|  5.25k|    rc = frame_special_chunk(offset, chunksize_, typesize, blocksize, chunk,
 4154|  5.25k|                             (int32_t)lazychunk_cbytes, needs_free);
 4155|  5.25k|    goto end;
 4156|  5.25k|  }
 4157|       |
 4158|  62.8k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4159|  62.8k|  if (io_cb == NULL) {
  ------------------
  |  Branch (4159:7): [True: 0, False: 62.8k]
  ------------------
 4160|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4161|      0|    rc = BLOSC2_ERROR_PLUGIN_IO;
 4162|      0|    goto end;
 4163|      0|  }
 4164|       |
 4165|  62.8k|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (4165:7): [True: 0, False: 62.8k]
  ------------------
 4166|       |    // TODO: make this portable across different endianness
 4167|       |    // Get info for building a lazy chunk
 4168|      0|    int32_t chunk_nbytes;
 4169|      0|    int32_t chunk_cbytes;
 4170|      0|    int32_t chunk_blocksize;
 4171|      0|    uint8_t* header_ptr;
 4172|      0|    uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 4173|      0|    int64_t io_pos = 0;
 4174|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4174:9): [True: 0, False: 0]
  ------------------
 4175|       |      // The chunk is not in the frame
 4176|      0|      fp = sframe_open_chunk(frame->urlpath, offset, "rb",
 4177|      0|                             frame->schunk->storage->io);
 4178|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4178:11): [True: 0, False: 0]
  ------------------
 4179|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4180|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4181|      0|      }
 4182|      0|    }
 4183|      0|    else {
 4184|      0|      fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 4185|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4185:11): [True: 0, False: 0]
  ------------------
 4186|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4187|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4188|      0|      }
 4189|      0|      io_pos = frame->file_offset + header_len + offset;
 4190|      0|    }
 4191|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (4191:9): [True: 0, False: 0]
  ------------------
 4192|      0|      header_ptr = header;
 4193|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 4194|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4194:9): [True: 0, False: 0]
  ------------------
 4195|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4196|      0|      rc = BLOSC2_ERROR_FILE_READ;
 4197|      0|      goto end;
 4198|      0|    }
 4199|      0|    rc = blosc2_cbuffer_sizes(header_ptr, &chunk_nbytes, &chunk_cbytes, &chunk_blocksize);
 4200|      0|    if (rc < 0) {
  ------------------
  |  Branch (4200:9): [True: 0, False: 0]
  ------------------
 4201|      0|      goto end;
 4202|      0|    }
 4203|      0|    if (chunk_nbytes < 0 || chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH || chunk_blocksize <= 0) {
  ------------------
  |  Branch (4203:9): [True: 0, False: 0]
  |  Branch (4203:29): [True: 0, False: 0]
  |  Branch (4203:76): [True: 0, False: 0]
  ------------------
 4204|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4205|      0|      goto end;
 4206|      0|    }
 4207|      0|    bool vlblocks = (header_ptr[BLOSC2_CHUNK_BLOSC2_FLAGS2] & BLOSC2_VL_BLOCKS) != 0;
 4208|      0|    size_t nblocks;
 4209|      0|    size_t leftover_block = 0;
 4210|      0|    if (vlblocks) {
  ------------------
  |  Branch (4210:9): [True: 0, False: 0]
  ------------------
 4211|      0|      nblocks = (size_t)chunk_blocksize;
 4212|      0|    }
 4213|      0|    else {
 4214|      0|      nblocks = (size_t)chunk_nbytes / (size_t)chunk_blocksize;
 4215|      0|      leftover_block = (size_t)chunk_nbytes % (size_t)chunk_blocksize;
 4216|      0|      if (leftover_block) {
  ------------------
  |  Branch (4216:11): [True: 0, False: 0]
  ------------------
 4217|      0|        if (nblocks == SIZE_MAX) {
  ------------------
  |  Branch (4217:13): [True: 0, False: 0]
  ------------------
 4218|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4219|      0|          goto end;
 4220|      0|        }
 4221|      0|        nblocks += 1;
 4222|      0|      }
 4223|      0|    }
 4224|      0|    if (nblocks == 0 || nblocks > (size_t)INT_MAX) {
  ------------------
  |  Branch (4224:9): [True: 0, False: 0]
  |  Branch (4224:25): [True: 0, False: 0]
  ------------------
 4225|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4226|      0|      goto end;
 4227|      0|    }
 4228|       |    // Allocate space for the lazy chunk
 4229|      0|    int32_t special_type = (header_ptr[BLOSC2_CHUNK_BLOSC2_FLAGS] >> 4) & BLOSC2_SPECIAL_MASK;
 4230|      0|    int memcpyed = header_ptr[BLOSC2_CHUNK_FLAGS] & (uint8_t) BLOSC_MEMCPYED;
 4231|       |
 4232|      0|    int32_t trailer_offset;
 4233|      0|    size_t streams_offset = BLOSC_EXTENDED_HEADER_LENGTH;
 4234|      0|    size_t trailer_offset_sz = BLOSC_EXTENDED_HEADER_LENGTH;
 4235|      0|    size_t trailer_len_sz = 0;
 4236|      0|    size_t lazychunk_cbytes_sz = 0;
 4237|      0|    size_t bstarts_nbytes = 0;
 4238|      0|    if (special_type == 0) {
  ------------------
  |  Branch (4238:9): [True: 0, False: 0]
  ------------------
 4239|      0|      if (nblocks > SIZE_MAX / sizeof(int32_t)) {
  ------------------
  |  Branch (4239:11): [True: 0, False: 0]
  ------------------
 4240|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4241|      0|        goto end;
 4242|      0|      }
 4243|      0|      bstarts_nbytes = nblocks * sizeof(int32_t);
 4244|       |
 4245|      0|      if (!memcpyed) {
  ------------------
  |  Branch (4245:11): [True: 0, False: 0]
  ------------------
 4246|      0|        if ((size_t)chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4246:13): [True: 0, False: 0]
  ------------------
 4247|      0|            bstarts_nbytes > (size_t)chunk_cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4247:13): [True: 0, False: 0]
  ------------------
 4248|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4249|      0|          goto end;
 4250|      0|        }
 4251|      0|      }
 4252|       |
 4253|      0|      if (bstarts_nbytes > SIZE_MAX - trailer_offset_sz) {
  ------------------
  |  Branch (4253:11): [True: 0, False: 0]
  ------------------
 4254|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4255|      0|        goto end;
 4256|      0|      }
 4257|      0|      trailer_offset_sz += bstarts_nbytes;
 4258|       |      // Regular values have offsets for blocks
 4259|      0|      if (!memcpyed) {
  ------------------
  |  Branch (4259:11): [True: 0, False: 0]
  ------------------
 4260|      0|        if (bstarts_nbytes > SIZE_MAX - streams_offset) {
  ------------------
  |  Branch (4260:13): [True: 0, False: 0]
  ------------------
 4261|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4262|      0|          goto end;
 4263|      0|        }
 4264|      0|        streams_offset += bstarts_nbytes;
 4265|      0|      }
 4266|       |
 4267|      0|      if (bstarts_nbytes > SIZE_MAX - (sizeof(int32_t) + sizeof(int64_t))) {
  ------------------
  |  Branch (4267:11): [True: 0, False: 0]
  ------------------
 4268|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4269|      0|        goto end;
 4270|      0|      }
 4271|      0|      trailer_len_sz = sizeof(int32_t) + sizeof(int64_t) + bstarts_nbytes;
 4272|      0|      if (trailer_len_sz > SIZE_MAX - trailer_offset_sz) {
  ------------------
  |  Branch (4272:11): [True: 0, False: 0]
  ------------------
 4273|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4274|      0|        goto end;
 4275|      0|      }
 4276|      0|      lazychunk_cbytes_sz = trailer_offset_sz + trailer_len_sz;
 4277|      0|    }
 4278|      0|    else if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (4278:14): [True: 0, False: 0]
  ------------------
 4279|      0|      if (typesize <= 0) {
  ------------------
  |  Branch (4279:11): [True: 0, False: 0]
  ------------------
 4280|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4281|      0|        goto end;
 4282|      0|      }
 4283|      0|      if ((size_t)typesize > SIZE_MAX - trailer_offset_sz ||
  ------------------
  |  Branch (4283:11): [True: 0, False: 0]
  ------------------
 4284|      0|          (size_t)typesize > SIZE_MAX - streams_offset) {
  ------------------
  |  Branch (4284:11): [True: 0, False: 0]
  ------------------
 4285|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4286|      0|        goto end;
 4287|      0|      }
 4288|      0|      trailer_offset_sz += (size_t)typesize;
 4289|      0|      streams_offset += (size_t)typesize;
 4290|      0|      lazychunk_cbytes_sz = trailer_offset_sz;
 4291|      0|    }
 4292|      0|    else {
 4293|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4294|      0|      goto end;
 4295|      0|    }
 4296|       |
 4297|      0|    if (streams_offset > (size_t)chunk_cbytes ||
  ------------------
  |  Branch (4297:9): [True: 0, False: 0]
  ------------------
 4298|      0|        trailer_offset_sz > INT32_MAX ||
  ------------------
  |  Branch (4298:9): [True: 0, False: 0]
  ------------------
 4299|      0|        trailer_len_sz > INT32_MAX ||
  ------------------
  |  Branch (4299:9): [True: 0, False: 0]
  ------------------
 4300|      0|        lazychunk_cbytes_sz > INT32_MAX) {
  ------------------
  |  Branch (4300:9): [True: 0, False: 0]
  ------------------
 4301|      0|      rc = BLOSC2_ERROR_INVALID_HEADER;
 4302|      0|      goto end;
 4303|      0|    }
 4304|       |
 4305|      0|    trailer_offset = (int32_t)trailer_offset_sz;
 4306|      0|    lazychunk_cbytes = (int32_t)lazychunk_cbytes_sz;
 4307|       |
 4308|       |    // Read just the full header and bstarts section too (lazy partial length)
 4309|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4309:9): [True: 0, False: 0]
  ------------------
 4310|      0|      io_pos = 0;
 4311|      0|    }
 4312|      0|    else {
 4313|      0|      io_pos = frame->file_offset + header_len + offset;
 4314|      0|    }
 4315|       |
 4316|       |    // The case here is a bit special because more memory is allocated than read from the file
 4317|       |    // and the chunk is modified after reading. Due to the modification, we cannot directly use
 4318|       |    // the memory provided by the io
 4319|      0|    *chunk = malloc((size_t)lazychunk_cbytes);
 4320|      0|    if (*chunk == NULL) {
  ------------------
  |  Branch (4320:9): [True: 0, False: 0]
  ------------------
 4321|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4322|      0|      goto end;
 4323|      0|    }
 4324|      0|    *needs_free = true;
 4325|       |
 4326|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (4326:9): [True: 0, False: 0]
  ------------------
 4327|      0|      rbytes = io_cb->read((void**)chunk, 1, (int64_t)streams_offset, io_pos, fp);
 4328|      0|    }
 4329|      0|    else {
 4330|       |      // The io hands out its own memory (mmap) and none at all for a read past
 4331|       |      // its end, which a damaged offset or header asks for: copy only after a
 4332|       |      // complete read
 4333|      0|      uint8_t* chunk_ptr = NULL;
 4334|      0|      rbytes = io_cb->read((void**)&chunk_ptr, 1, (int64_t)streams_offset, io_pos, fp);
 4335|      0|      if (rbytes == (int64_t)streams_offset && chunk_ptr != NULL) {
  ------------------
  |  Branch (4335:11): [True: 0, False: 0]
  |  Branch (4335:48): [True: 0, False: 0]
  ------------------
 4336|      0|        memcpy(*chunk, chunk_ptr, streams_offset);
 4337|      0|      }
 4338|      0|      else {
 4339|      0|        rbytes = BLOSC2_ERROR_FILE_READ;
 4340|      0|      }
 4341|      0|    }
 4342|       |
 4343|      0|    if (rbytes != (int64_t)streams_offset) {
  ------------------
  |  Branch (4343:9): [True: 0, False: 0]
  ------------------
 4344|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4345|      0|      rc = BLOSC2_ERROR_FILE_READ;
 4346|      0|      goto end;
 4347|      0|    }
 4348|      0|    if (special_type == BLOSC2_SPECIAL_VALUE) {
  ------------------
  |  Branch (4348:9): [True: 0, False: 0]
  ------------------
 4349|       |      // Value runlen is not returning a lazy chunk.  We are done.
 4350|      0|      goto end;
 4351|      0|    }
 4352|       |
 4353|       |    // Mark chunk as lazy
 4354|      0|    uint8_t* blosc2_flags = *chunk + BLOSC2_CHUNK_BLOSC2_FLAGS;
 4355|      0|    *blosc2_flags |= 0x08U;
 4356|       |
 4357|       |    // Add the trailer (currently, nchunk + offset + block_csizes)
 4358|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4358:9): [True: 0, False: 0]
  ------------------
 4359|      0|      *(int32_t*)(*chunk + trailer_offset) = (int32_t)offset;   // offset is nchunk for sframes
 4360|      0|      *(int64_t*)(*chunk + trailer_offset + sizeof(int32_t)) = offset;
 4361|      0|    }
 4362|      0|    else {
 4363|      0|      *(int32_t*)(*chunk + trailer_offset) = (int32_t)nchunk;
 4364|      0|      *(int64_t*)(*chunk + trailer_offset + sizeof(int32_t)) = header_len + offset;
 4365|      0|    }
 4366|       |
 4367|      0|    block_csizes = malloc(nblocks * sizeof(int32_t));
 4368|      0|    if (block_csizes == NULL) {
  ------------------
  |  Branch (4368:9): [True: 0, False: 0]
  ------------------
 4369|      0|      rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4370|      0|      goto end;
 4371|      0|    }
 4372|       |
 4373|      0|    if (memcpyed) {
  ------------------
  |  Branch (4373:9): [True: 0, False: 0]
  ------------------
 4374|       |      // When memcpyed the blocksizes are trivial to compute
 4375|      0|      for (size_t i = 0; i + 1 < nblocks; i++) {
  ------------------
  |  Branch (4375:26): [True: 0, False: 0]
  ------------------
 4376|      0|        block_csizes[i] = (int)chunk_blocksize;
 4377|      0|      }
 4378|       |      // The last block could be incomplete, mainly due to the fact that the block size is not divisible
 4379|       |      // by the typesize
 4380|      0|      block_csizes[nblocks - 1] = (int32_t)leftover_block ? (int32_t)leftover_block : chunk_blocksize;
  ------------------
  |  Branch (4380:35): [True: 0, False: 0]
  ------------------
 4381|      0|    }
 4382|      0|    else {
 4383|       |      // In regular, compressed chunks, we need to sort the bstarts (they can be out
 4384|       |      // of order because of multi-threading), and get a reverse index too.
 4385|      0|      memcpy(block_csizes, *chunk + BLOSC_EXTENDED_HEADER_LENGTH, nblocks * sizeof(int32_t));
 4386|       |      // Helper structure to keep track of original indexes
 4387|      0|      csize_idx = malloc(nblocks * sizeof(struct csize_idx));
 4388|      0|      if (csize_idx == NULL) {
  ------------------
  |  Branch (4388:11): [True: 0, False: 0]
  ------------------
 4389|      0|        rc = BLOSC2_ERROR_MEMORY_ALLOC;
 4390|      0|        goto end;
 4391|      0|      }
 4392|      0|      for (size_t n = 0; n < nblocks; n++) {
  ------------------
  |  Branch (4392:26): [True: 0, False: 0]
  ------------------
 4393|       |        // A block starts within its chunk, at or after streams_offset; damaged
 4394|       |        // starts would point into chunk headers or overflow the differences below
 4395|       |        // (and in sort_offset())
 4396|      0|        if (block_csizes[n] < (int64_t)streams_offset || block_csizes[n] > chunk_cbytes) {
  ------------------
  |  Branch (4396:13): [True: 0, False: 0]
  |  Branch (4396:58): [True: 0, False: 0]
  ------------------
 4397|      0|          rc = BLOSC2_ERROR_INVALID_HEADER;
 4398|      0|          goto end;
 4399|      0|        }
 4400|      0|        csize_idx[n].val = block_csizes[n];
 4401|      0|        csize_idx[n].idx = (int)n;
 4402|      0|      }
 4403|      0|      qsort(csize_idx, nblocks, sizeof(struct csize_idx), &sort_offset);
 4404|       |      // Compute the actual csizes
 4405|      0|      int idx;
 4406|      0|      for (size_t n = 0; n + 1 < nblocks; n++) {
  ------------------
  |  Branch (4406:26): [True: 0, False: 0]
  ------------------
 4407|      0|        idx = csize_idx[n].idx;
 4408|      0|        block_csizes[idx] = csize_idx[n + 1].val - csize_idx[n].val;
 4409|      0|      }
 4410|      0|      idx = csize_idx[nblocks - 1].idx;
 4411|      0|      block_csizes[idx] = chunk_cbytes - csize_idx[nblocks - 1].val;
 4412|      0|      free(csize_idx);
 4413|      0|      csize_idx = NULL;
 4414|      0|    }
 4415|       |    // Copy the csizes at the end of the trailer
 4416|      0|    void *trailer_csizes = *chunk + lazychunk_cbytes - nblocks * sizeof(int32_t);
 4417|      0|    memcpy(trailer_csizes, block_csizes, nblocks * sizeof(int32_t));
 4418|      0|    free(block_csizes);
 4419|      0|    block_csizes = NULL;
 4420|  62.8k|  } else {
 4421|       |    // The chunk is in memory and just one pointer away
 4422|  62.8k|    int64_t chunk_header_offset = header_len + offset;
 4423|  62.8k|    int64_t chunk_cbytes_offset = chunk_header_offset + BLOSC_MIN_HEADER_LENGTH;
 4424|       |
 4425|  62.8k|    *chunk = frame->cframe + chunk_header_offset;
 4426|       |
 4427|  62.8k|    if (chunk_header_offset < 0 ||
  ------------------
  |  Branch (4427:9): [True: 0, False: 62.8k]
  ------------------
 4428|  62.8k|        chunk_cbytes_offset < chunk_header_offset ||
  ------------------
  |  Branch (4428:9): [True: 0, False: 62.8k]
  ------------------
 4429|  62.8k|        chunk_cbytes_offset > frame->len) {
  ------------------
  |  Branch (4429:9): [True: 0, False: 62.8k]
  ------------------
 4430|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4431|      0|      rc = BLOSC2_ERROR_READ_BUFFER;
 4432|  62.8k|    } else {
 4433|  62.8k|      int32_t chunk_blocksize = 0;
 4434|  62.8k|      rc = blosc2_cbuffer_sizes(*chunk, NULL, &lazychunk_cbytes, &chunk_blocksize);
 4435|  62.8k|      if (rc < 0) {
  ------------------
  |  Branch (4435:11): [True: 0, False: 62.8k]
  ------------------
 4436|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4437|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 4438|      0|      }
 4439|  62.8k|      else if (chunk_blocksize <= 0) {
  ------------------
  |  Branch (4439:16): [True: 0, False: 62.8k]
  ------------------
 4440|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4441|      0|        rc = BLOSC2_ERROR_INVALID_HEADER;
 4442|      0|      }
 4443|  62.8k|      else if (lazychunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4443:16): [True: 0, False: 62.8k]
  ------------------
 4444|  62.8k|               chunk_header_offset > INT64_MAX - lazychunk_cbytes ||
  ------------------
  |  Branch (4444:16): [True: 0, False: 62.8k]
  ------------------
 4445|  62.8k|               chunk_header_offset + lazychunk_cbytes > frame_len) {
  ------------------
  |  Branch (4445:16): [True: 0, False: 62.8k]
  ------------------
 4446|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4447|      0|        rc = BLOSC2_ERROR_READ_BUFFER;
 4448|      0|      }
 4449|  62.8k|    }
 4450|  62.8k|  }
 4451|       |
 4452|  68.1k|  end:
 4453|  68.1k|  if (csize_idx != NULL) {
  ------------------
  |  Branch (4453:7): [True: 0, False: 68.1k]
  ------------------
 4454|      0|    free(csize_idx);
 4455|      0|  }
 4456|  68.1k|  if (block_csizes != NULL) {
  ------------------
  |  Branch (4456:7): [True: 0, False: 68.1k]
  ------------------
 4457|      0|    free(block_csizes);
 4458|      0|  }
 4459|  68.1k|  if (fp != NULL) {
  ------------------
  |  Branch (4459:7): [True: 0, False: 68.1k]
  ------------------
 4460|      0|    frame_reader_release(frame, io_cb, fp);
 4461|      0|  }
 4462|  68.1k|  if (rc < 0) {
  ------------------
  |  Branch (4462:7): [True: 0, False: 68.1k]
  ------------------
 4463|      0|    if (*needs_free) {
  ------------------
  |  Branch (4463:9): [True: 0, False: 0]
  ------------------
 4464|      0|      free(*chunk);
 4465|      0|      *chunk = NULL;
 4466|      0|      *needs_free = false;
 4467|      0|    }
 4468|      0|    return rc;
 4469|      0|  }
 4470|       |
 4471|  68.1k|  return (int)lazychunk_cbytes;
 4472|  68.1k|}
frame_get_chunk_header:
 4599|  2.01M|int frame_get_chunk_header(blosc2_frame_s* frame, int64_t nchunk, uint8_t* header) {
 4600|  2.01M|  frame_fields f;
 4601|  2.01M|  int rc = get_frame_fields(frame, &f);
 4602|  2.01M|  if (rc < 0) {
  ------------------
  |  Branch (4602:7): [True: 0, False: 2.01M]
  ------------------
 4603|      0|    return rc;
 4604|      0|  }
 4605|  2.01M|  int64_t offset;
 4606|       |  return read_frame_chunk_header(frame, &f, nchunk, NULL, header, &offset);
 4607|  2.01M|}
frame_fill_special:
 4612|  3.40k|                       int32_t chunksize, blosc2_schunk* schunk) {
 4613|  3.40k|  int32_t header_len;
 4614|  3.40k|  int64_t frame_len;
 4615|  3.40k|  int64_t nbytes;
 4616|  3.40k|  int64_t cbytes;
 4617|  3.40k|  int32_t blocksize;
 4618|  3.40k|  int32_t typesize;
 4619|  3.40k|  int64_t nchunks;
 4620|       |
 4621|  3.40k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, NULL,
 4622|  3.40k|                           &nchunks, &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4623|  3.40k|                           schunk->storage->io);
 4624|  3.40k|  if (rc < 0) {
  ------------------
  |  Branch (4624:7): [True: 0, False: 3.40k]
  ------------------
 4625|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4626|      0|    return BLOSC2_ERROR_DATA;
 4627|      0|  }
 4628|       |
 4629|  3.40k|  if (nitems == 0) {
  ------------------
  |  Branch (4629:7): [True: 0, False: 3.40k]
  ------------------
 4630|      0|    return frame_len;
 4631|      0|  }
 4632|       |
 4633|  3.40k|  if ((nitems / chunksize) > INT_MAX) {
  ------------------
  |  Branch (4633:7): [True: 0, False: 3.40k]
  ------------------
 4634|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4635|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4636|      0|  }
 4637|       |
 4638|  3.40k|  if ((nbytes > 0) || (cbytes > 0)) {
  ------------------
  |  Branch (4638:7): [True: 0, False: 3.40k]
  |  Branch (4638:23): [True: 0, False: 3.40k]
  ------------------
 4639|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4640|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4641|      0|  }
 4642|       |
 4643|       |  // Compute the number of chunks and the length of the offsets chunk
 4644|  3.40k|  int32_t chunkitems = chunksize / typesize;
 4645|  3.40k|  if (chunkitems <= 0) {
  ------------------
  |  Branch (4645:7): [True: 0, False: 3.40k]
  ------------------
 4646|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4647|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4648|      0|  }
 4649|  3.40k|  nchunks = nitems / chunkitems;
 4650|  3.40k|  int32_t leftover_items = (int32_t)(nitems % chunkitems);
 4651|  3.40k|  if (leftover_items) {
  ------------------
  |  Branch (4651:7): [True: 0, False: 3.40k]
  ------------------
 4652|      0|    nchunks += 1;
 4653|      0|  }
 4654|       |
 4655|  3.40k|  blosc2_cparams* cparams;
 4656|  3.40k|  blosc2_schunk_get_cparams(schunk, &cparams);
 4657|       |
 4658|       |  // Build the offsets with a special chunk
 4659|  3.40k|  int new_off_cbytes = BLOSC_EXTENDED_HEADER_LENGTH + sizeof(int64_t);
 4660|  3.40k|  uint8_t* off_chunk = malloc(new_off_cbytes);
 4661|  3.40k|  uint64_t offset_value = ((uint64_t)1 << 63);
 4662|  3.40k|  uint8_t* sample_chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
 4663|  3.40k|  if (off_chunk == NULL || sample_chunk == NULL) {
  ------------------
  |  Branch (4663:7): [True: 0, False: 3.40k]
  |  Branch (4663:28): [True: 0, False: 3.40k]
  ------------------
 4664|      0|    free(off_chunk);
 4665|      0|    free(sample_chunk);
 4666|      0|    free(cparams);
 4667|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4668|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 4669|      0|  }
 4670|  3.40k|  int csize;
 4671|  3.40k|  switch (special_value) {
 4672|  3.40k|    case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (4672:5): [True: 3.40k, False: 0]
  ------------------
 4673|  3.40k|      offset_value += (uint64_t) BLOSC2_SPECIAL_ZERO << (8 * 7);
 4674|  3.40k|      csize = blosc2_chunk_zeros(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4675|  3.40k|      break;
 4676|      0|    case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (4676:5): [True: 0, False: 3.40k]
  ------------------
 4677|      0|      offset_value += (uint64_t) BLOSC2_SPECIAL_UNINIT << (8 * 7);
 4678|      0|      csize = blosc2_chunk_uninit(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4679|      0|      break;
 4680|      0|    case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (4680:5): [True: 0, False: 3.40k]
  ------------------
 4681|      0|      offset_value += (uint64_t)BLOSC2_SPECIAL_NAN << (8 * 7);
 4682|      0|      csize = blosc2_chunk_nans(*cparams, chunksize, sample_chunk, BLOSC_EXTENDED_HEADER_LENGTH);
 4683|      0|      break;
 4684|      0|    default:
  ------------------
  |  Branch (4684:5): [True: 0, False: 3.40k]
  ------------------
 4685|      0|      free(off_chunk);
 4686|      0|      free(sample_chunk);
 4687|      0|      free(cparams);
 4688|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4689|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4690|  3.40k|  }
 4691|  3.40k|  if (csize < 0) {
  ------------------
  |  Branch (4691:7): [True: 0, False: 3.40k]
  ------------------
 4692|      0|    free(off_chunk);
 4693|      0|    free(sample_chunk);
 4694|      0|    free(cparams);
 4695|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4696|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4697|      0|  }
 4698|  3.40k|  cparams->typesize = sizeof(int64_t);  // change it to offsets typesize
 4699|       |  // cparams->blocksize = 0;   // automatic blocksize
 4700|  3.40k|  cparams->blocksize = 8 * 2 * 1024;  // based on experiments with create_frame.c bench
 4701|  3.40k|  cparams->clevel = 5;
 4702|  3.40k|  cparams->compcode = BLOSC_BLOSCLZ;
 4703|  3.40k|  int32_t special_nbytes;
 4704|  3.40k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &special_nbytes)) {
  ------------------
  |  Branch (4704:7): [True: 0, False: 3.40k]
  ------------------
 4705|      0|    free(off_chunk);
 4706|      0|    free(sample_chunk);
 4707|      0|    free(cparams);
 4708|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4709|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4710|      0|  }
 4711|  3.40k|  rc = blosc2_chunk_repeatval(*cparams, special_nbytes, off_chunk, new_off_cbytes, &offset_value);
 4712|  3.40k|  free(cparams);
 4713|  3.40k|  if (rc < 0) {
  ------------------
  |  Branch (4713:7): [True: 0, False: 3.40k]
  ------------------
 4714|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4715|      0|    return BLOSC2_ERROR_DATA;
 4716|      0|  }
 4717|       |
 4718|       |  // Get the blocksize associated to the sample chunk
 4719|  3.40k|  blosc2_cbuffer_sizes(sample_chunk, NULL, NULL, &blocksize);
 4720|  3.40k|  free(sample_chunk);
 4721|       |  // and use it for the super-chunk
 4722|  3.40k|  schunk->blocksize = blocksize;
 4723|       |  // schunk->blocksize = 0;  // for experimenting with automatic blocksize
 4724|       |
 4725|       |  // We have the new offsets; update the frame.
 4726|  3.40k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4727|  3.40k|  if (io_cb == NULL) {
  ------------------
  |  Branch (4727:7): [True: 0, False: 3.40k]
  ------------------
 4728|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4729|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 4730|      0|  }
 4731|       |
 4732|  3.40k|  int64_t new_frame_len = header_len + new_off_cbytes + frame->trailer_len;
 4733|  3.40k|  void* fp = NULL;
 4734|  3.40k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (4734:7): [True: 3.40k, False: 0]
  ------------------
 4735|  3.40k|    uint8_t* framep = frame->cframe;
 4736|       |    /* Make space for the new chunk and copy it */
 4737|  3.40k|    frame->cframe = framep = realloc(framep, (size_t)new_frame_len);
 4738|  3.40k|    if (framep == NULL) {
  ------------------
  |  Branch (4738:9): [True: 0, False: 3.40k]
  ------------------
 4739|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4740|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4741|      0|    }
 4742|       |    /* Copy the offsets */
 4743|  3.40k|    memcpy(framep + header_len, off_chunk, (size_t)new_off_cbytes);
 4744|  3.40k|  }
 4745|      0|  else {
 4746|      0|    size_t wbytes;
 4747|      0|    int64_t io_pos = 0;
 4748|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4748:9): [True: 0, False: 0]
  ------------------
 4749|       |      // Update the offsets chunk in the chunks frame
 4750|      0|      fp = sframe_open_index(frame->urlpath, "rb+", frame->schunk->storage->io);
 4751|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4751:11): [True: 0, False: 0]
  ------------------
 4752|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4753|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4754|      0|      }
 4755|      0|      io_pos = frame->file_offset + header_len;
 4756|      0|    }
 4757|      0|    else {
 4758|       |      // Regular frame
 4759|      0|      fp = frame_writer_acquire(frame, io_cb);
 4760|      0|      if (fp == NULL) {
  ------------------
  |  Branch (4760:11): [True: 0, False: 0]
  ------------------
 4761|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4762|      0|        return BLOSC2_ERROR_FILE_OPEN;
 4763|      0|      }
 4764|      0|      io_pos = frame->file_offset + header_len + cbytes;
 4765|      0|    }
 4766|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 4767|      0|    frame_writer_release(frame, io_cb, fp);
 4768|      0|    if (wbytes != (size_t)new_off_cbytes) {
  ------------------
  |  Branch (4768:9): [True: 0, False: 0]
  ------------------
 4769|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4770|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 4771|      0|    }
 4772|      0|  }
 4773|       |
 4774|       |  // Invalidate the cache for chunk offsets
 4775|  3.40k|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (4775:7): [True: 0, False: 3.40k]
  ------------------
 4776|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (4776:9): [True: 0, False: 0]
  ------------------
 4777|      0|      free(frame->coffsets);
 4778|      0|    frame->coffsets = NULL;
 4779|      0|  }
 4780|  3.40k|  free(off_chunk);
 4781|       |
 4782|  3.40k|  frame->len = new_frame_len;
 4783|  3.40k|  rc = frame_update_header(frame, schunk, false);
 4784|  3.40k|  if (rc < 0) {
  ------------------
  |  Branch (4784:7): [True: 0, False: 3.40k]
  ------------------
 4785|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4786|      0|  }
 4787|       |
 4788|  3.40k|  rc = frame_update_trailer(frame, schunk);
 4789|  3.40k|  if (rc < 0) {
  ------------------
  |  Branch (4789:7): [True: 0, False: 3.40k]
  ------------------
 4790|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
 4791|      0|  }
 4792|       |
 4793|  3.40k|  return frame->len;
 4794|  3.40k|}
frame_append_chunk:
 4864|     64|void* frame_append_chunk(blosc2_frame_s* frame, void* chunk, blosc2_schunk* schunk) {
 4865|     64|  int32_t header_len;
 4866|     64|  int64_t frame_len;
 4867|     64|  int64_t nbytes;
 4868|     64|  int64_t cbytes;
 4869|     64|  int32_t blocksize;
 4870|     64|  int32_t chunksize;
 4871|     64|  int64_t nchunks;
 4872|     64|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, &chunksize,
 4873|     64|                           &nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 4874|     64|                           frame->schunk->storage->io);
 4875|     64|  if (rc < 0) {
  ------------------
  |  Branch (4875:7): [True: 0, False: 64]
  ------------------
 4876|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4877|      0|    return NULL;
 4878|      0|  }
 4879|     64|  rc = frame_refresh_if_stale(frame, frame_len);
 4880|     64|  if (rc < 0) {
  ------------------
  |  Branch (4880:7): [True: 0, False: 64]
  ------------------
 4881|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4882|      0|    return NULL;
 4883|      0|  }
 4884|       |
 4885|       |  /* The uncompressed and compressed sizes start at byte 4 and 12 */
 4886|     64|  int32_t chunk_nbytes;
 4887|     64|  int32_t chunk_cbytes;
 4888|     64|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 4889|     64|  if (rc < 0) {
  ------------------
  |  Branch (4889:7): [True: 0, False: 64]
  ------------------
 4890|      0|    return NULL;
 4891|      0|  }
 4892|       |
 4893|     64|  if ((nchunks > 0) && (chunksize > 0) && (schunk->chunksize != 0) && (chunk_nbytes > chunksize)) {
  ------------------
  |  Branch (4893:7): [True: 40, False: 24]
  |  Branch (4893:24): [True: 40, False: 0]
  |  Branch (4893:43): [True: 40, False: 0]
  |  Branch (4893:71): [True: 0, False: 40]
  ------------------
 4894|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4895|      0|                      "not allowed yet %d != %d.", chunk_nbytes, chunksize);
 4896|      0|    return NULL;
 4897|      0|  }
 4898|       |
 4899|       |  // Check that we are not appending a small chunk after another small chunk
 4900|     64|  int32_t chunk_nbytes_last = 0;
 4901|     64|  if (frame_needs_last_nbytes(chunksize, nchunks, chunk_nbytes)) {
  ------------------
  |  Branch (4901:7): [True: 0, False: 64]
  ------------------
 4902|      0|    uint8_t last_header[BLOSC_EXTENDED_HEADER_LENGTH];
 4903|      0|    rc = frame_get_chunk_header(frame, nchunks - 1, last_header);
 4904|      0|    if (rc < 0) {
  ------------------
  |  Branch (4904:9): [True: 0, False: 0]
  ------------------
 4905|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4906|      0|    } else {
 4907|      0|      rc = blosc2_cbuffer_sizes(last_header, &chunk_nbytes_last, NULL, NULL);
 4908|      0|    }
 4909|      0|    if (rc < 0) {
  ------------------
  |  Branch (4909:9): [True: 0, False: 0]
  ------------------
 4910|      0|      return NULL;
 4911|      0|    }
 4912|      0|  }
 4913|     64|  if (!frame_takes_chunk(chunksize, nchunks, nbytes, chunk_nbytes_last, chunk_nbytes)) {
  ------------------
  |  Branch (4913:7): [True: 0, False: 64]
  ------------------
 4914|      0|    return NULL;
 4915|      0|  }
 4916|       |
 4917|       |  // Get the current offsets and add one more
 4918|     64|  int32_t off_nbytes = (int32_t) ((nchunks + 1) * sizeof(int64_t));
 4919|     64|  int64_t* offsets = (int64_t *) malloc((size_t)off_nbytes);
 4920|     64|  if (offsets == NULL) {
  ------------------
  |  Branch (4920:7): [True: 0, False: 64]
  ------------------
 4921|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4922|      0|    return NULL;
 4923|      0|  }
 4924|     64|  if (nchunks > 0) {
  ------------------
  |  Branch (4924:7): [True: 40, False: 24]
  ------------------
 4925|     40|    int32_t coffsets_cbytes;
 4926|     40|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 4927|     40|    if (coffsets == NULL) {
  ------------------
  |  Branch (4927:9): [True: 0, False: 40]
  ------------------
 4928|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4929|      0|      free(offsets);
 4930|      0|      return NULL;
 4931|      0|    }
 4932|       |    // Decompress offsets
 4933|     40|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 4934|     40|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 4935|     40|    if (dctx == NULL) {
  ------------------
  |  Branch (4935:9): [True: 0, False: 40]
  ------------------
 4936|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4937|      0|      free(offsets);
 4938|      0|      return NULL;
 4939|      0|    }
 4940|     40|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets,
 4941|     40|                                                off_nbytes);
 4942|     40|    blosc2_free_ctx(dctx);
 4943|     40|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (4943:9): [True: 0, False: 40]
  ------------------
 4944|      0|      free(offsets);
 4945|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4946|      0|      return NULL;
 4947|      0|    }
 4948|     40|  }
 4949|       |
 4950|       |  // Add the new offset
 4951|     64|  int64_t sframe_chunk_id = -1;
 4952|     64|  int special_value = chunk_special_in_offset(chunk, chunk_cbytes);
 4953|     64|  if (special_value) {
  ------------------
  |  Branch (4953:7): [True: 1, False: 63]
  ------------------
 4954|      1|    special_offset(offsets + nchunks, special_value);
 4955|      1|    chunk_cbytes = 0;   // we don't need to store the chunk
 4956|      1|  }
 4957|     63|  else if (frame->sframe) {
  ------------------
  |  Branch (4957:12): [True: 0, False: 63]
  ------------------
 4958|       |    // Compute the sframe_chunk_id value
 4959|      0|    for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (4959:25): [True: 0, False: 0]
  ------------------
 4960|      0|      if (offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (4960:11): [True: 0, False: 0]
  ------------------
 4961|      0|        sframe_chunk_id = offsets[i];
 4962|      0|      }
 4963|      0|    }
 4964|      0|    offsets[nchunks] = ++sframe_chunk_id;
 4965|      0|  }
 4966|     63|  else {
 4967|     63|    offsets[nchunks] = cbytes;
 4968|     63|  }
 4969|       |
 4970|       |  // Re-compress the offsets again
 4971|     64|  uint8_t* off_chunk;
 4972|     64|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 4973|     64|                                            &off_chunk);
 4974|     64|  free(offsets);
 4975|     64|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (4975:7): [True: 0, False: 64]
  ------------------
 4976|      0|    return NULL;
 4977|      0|  }
 4978|       |
 4979|     64|  int64_t new_cbytes = cbytes + chunk_cbytes;
 4980|     64|  int64_t new_frame_len;
 4981|     64|  if (frame->sframe) {
  ------------------
  |  Branch (4981:7): [True: 0, False: 64]
  ------------------
 4982|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 4983|      0|  }
 4984|     64|  else {
 4985|     64|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 4986|     64|  }
 4987|       |
 4988|     64|  void* fp = NULL;
 4989|     64|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (4989:7): [True: 64, False: 0]
  ------------------
 4990|       |    /* Make space for the new chunk and copy it (keeping the frame if that fails) */
 4991|     64|    uint8_t* framep = realloc(frame->cframe, (size_t)new_frame_len);
 4992|     64|    if (framep == NULL) {
  ------------------
  |  Branch (4992:9): [True: 0, False: 64]
  ------------------
 4993|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4994|      0|      goto failed;
 4995|      0|    }
 4996|     64|    frame->cframe = framep;
 4997|       |    /* Copy the chunk */
 4998|     64|    memcpy(framep + header_len + cbytes, chunk, (size_t)chunk_cbytes);
 4999|       |    /* Copy the offsets */
 5000|     64|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 5001|     64|  }
 5002|      0|  else {
 5003|      0|    int64_t wbytes;
 5004|      0|    int64_t io_pos = 0;
 5005|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 5006|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (5006:9): [True: 0, False: 0]
  ------------------
 5007|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5008|      0|      goto failed;
 5009|      0|    }
 5010|       |
 5011|      0|    if (frame->sframe) {
  ------------------
  |  Branch (5011:9): [True: 0, False: 0]
  ------------------
 5012|       |      // Update the offsets chunk in the chunks frame
 5013|      0|      if (chunk_cbytes != 0) {
  ------------------
  |  Branch (5013:11): [True: 0, False: 0]
  ------------------
 5014|      0|        if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (5014:13): [True: 0, False: 0]
  ------------------
 5015|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5016|      0|          goto failed;
 5017|      0|        }
 5018|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (5018:13): [True: 0, False: 0]
  ------------------
 5019|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5020|      0|          goto failed;
 5021|      0|        }
 5022|      0|      }
 5023|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 5024|      0|                             frame->schunk->storage->io);
 5025|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5025:11): [True: 0, False: 0]
  ------------------
 5026|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5027|      0|        goto failed;
 5028|      0|      }
 5029|      0|      io_pos = frame->file_offset + header_len;
 5030|      0|    }
 5031|      0|    else {
 5032|       |      // Regular frame
 5033|      0|      fp = frame_writer_acquire(frame, io_cb);
 5034|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5034:11): [True: 0, False: 0]
  ------------------
 5035|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5036|      0|        goto failed;
 5037|      0|      }
 5038|      0|      io_pos = frame->file_offset + header_len + cbytes;
 5039|      0|      wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 5040|      0|      io_pos += chunk_cbytes;
 5041|      0|      if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (5041:11): [True: 0, False: 0]
  ------------------
 5042|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5043|      0|                          " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 5044|      0|                          wbytes, (int64_t)chunk_cbytes, io_pos - (int64_t)chunk_cbytes, nchunks);
 5045|      0|        frame->file_end = 0;
 5046|      0|        frame_writer_release(frame, io_cb, fp);
 5047|      0|        goto failed;
 5048|      0|      }
 5049|      0|    }
 5050|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 5051|      0|    frame_writer_release(frame, io_cb, fp);
 5052|      0|    if (wbytes != new_off_cbytes) {
  ------------------
  |  Branch (5052:9): [True: 0, False: 0]
  ------------------
 5053|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5054|      0|      frame->file_end = 0;
 5055|      0|      goto failed;
 5056|      0|    }
 5057|      0|  }
 5058|       |  // Invalidate the cache for chunk offsets
 5059|     64|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (5059:7): [True: 0, False: 64]
  ------------------
 5060|      0|    if (frame->coffsets_needs_free)
  ------------------
  |  Branch (5060:9): [True: 0, False: 0]
  ------------------
 5061|      0|      free(frame->coffsets);
 5062|      0|    frame->coffsets = NULL;
 5063|      0|  }
 5064|     64|  free(off_chunk);
 5065|       |
 5066|     64|  frame->len = new_frame_len;
 5067|     64|  rc = frame_update_header(frame, schunk, false);
 5068|     64|  if (rc < 0) {
  ------------------
  |  Branch (5068:7): [True: 0, False: 64]
  ------------------
 5069|      0|    frame->len = frame_len;
 5070|      0|    return NULL;
 5071|      0|  }
 5072|       |
 5073|     64|  rc = frame_update_trailer(frame, schunk);
 5074|     64|  if (rc < 0) {
  ------------------
  |  Branch (5074:7): [True: 0, False: 64]
  ------------------
 5075|      0|    frame->len = frame_len;
 5076|      0|    return NULL;
 5077|      0|  }
 5078|       |
 5079|     64|  return frame;
 5080|       |
 5081|      0|  failed:
 5082|       |  // The caller still owns the chunk; the offsets chunk is ours
 5083|      0|  free(off_chunk);
 5084|       |  return NULL;
 5085|     64|}
frame_insert_chunk:
 5621|   218k|void* frame_insert_chunk(blosc2_frame_s* frame, int64_t nchunk, void* chunk, blosc2_schunk* schunk) {
 5622|   218k|  uint8_t* chunk_ = chunk;
 5623|   218k|  int32_t header_len;
 5624|   218k|  int64_t frame_len;
 5625|   218k|  int64_t nbytes;
 5626|   218k|  int64_t cbytes;
 5627|   218k|  int32_t blocksize;
 5628|   218k|  int32_t chunksize;
 5629|   218k|  int64_t nchunks;
 5630|   218k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 5631|   218k|                           &blocksize, &chunksize, &nchunks,
 5632|   218k|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 5633|   218k|                           frame->schunk->storage->io);
 5634|   218k|  if (rc < 0) {
  ------------------
  |  Branch (5634:7): [True: 0, False: 218k]
  ------------------
 5635|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5636|      0|    return NULL;
 5637|      0|  }
 5638|   218k|  rc = frame_refresh_if_stale(frame, frame_len);
 5639|   218k|  if (rc < 0) {
  ------------------
  |  Branch (5639:7): [True: 0, False: 218k]
  ------------------
 5640|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5641|      0|    return NULL;
 5642|      0|  }
 5643|   218k|  int32_t chunk_cbytes;
 5644|   218k|  rc = blosc2_cbuffer_sizes(chunk_, NULL, &chunk_cbytes, NULL);
 5645|   218k|  if (rc < 0) {
  ------------------
  |  Branch (5645:7): [True: 0, False: 218k]
  ------------------
 5646|      0|    return NULL;
 5647|      0|  }
 5648|       |
 5649|       |  // Get the current offsets
 5650|   218k|  int32_t off_nbytes = (int32_t) ((nchunks + 1) * sizeof(int64_t));
 5651|   218k|  int64_t* offsets = (int64_t *) malloc((size_t)off_nbytes);
 5652|   218k|  if (offsets == NULL) {
  ------------------
  |  Branch (5652:7): [True: 0, False: 218k]
  ------------------
 5653|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5654|      0|    return NULL;
 5655|      0|  }
 5656|   218k|  if (nchunks > 0) {
  ------------------
  |  Branch (5656:7): [True: 218k, False: 243]
  ------------------
 5657|   218k|    int32_t coffsets_cbytes = 0;
 5658|   218k|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 5659|   218k|    if (coffsets == NULL) {
  ------------------
  |  Branch (5659:9): [True: 0, False: 218k]
  ------------------
 5660|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5661|      0|      free(offsets);
 5662|      0|      return NULL;
 5663|      0|    }
 5664|       |    // Decompress offsets
 5665|   218k|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 5666|   218k|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 5667|   218k|    if (dctx == NULL) {
  ------------------
  |  Branch (5667:9): [True: 0, False: 218k]
  ------------------
 5668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5669|      0|      free(offsets);
 5670|      0|      return NULL;
 5671|      0|    }
 5672|   218k|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 5673|   218k|    blosc2_free_ctx(dctx);
 5674|   218k|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (5674:9): [True: 0, False: 218k]
  ------------------
 5675|      0|      free(offsets);
 5676|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5677|      0|      return NULL;
 5678|      0|    }
 5679|   218k|  }
 5680|       |
 5681|       |  // TODO: Improvement: Check if new chunk is smaller than previous one
 5682|       |
 5683|       |  // Move offsets
 5684|   143M|  for (int64_t i = nchunks; i > nchunk; i--) {
  ------------------
  |  Branch (5684:29): [True: 142M, False: 218k]
  ------------------
 5685|   142M|    offsets[i] = offsets[i - 1];
 5686|   142M|  }
 5687|       |  // Add the new offset
 5688|   218k|  int64_t sframe_chunk_id = -1;
 5689|   218k|  int special_value = chunk_special_in_offset(chunk_, chunk_cbytes);
 5690|   218k|  if (special_value) {
  ------------------
  |  Branch (5690:7): [True: 218k, False: 0]
  ------------------
 5691|   218k|    special_offset(offsets + nchunk, special_value);
 5692|   218k|    chunk_cbytes = 0;   // we don't need to store the chunk
 5693|   218k|  }
 5694|      0|  else if (frame->sframe) {
  ------------------
  |  Branch (5694:12): [True: 0, False: 0]
  ------------------
 5695|      0|    for (int64_t i = 0; i <= nchunks; ++i) {
  ------------------
  |  Branch (5695:25): [True: 0, False: 0]
  ------------------
 5696|       |      // offsets[nchunk] is still uninitialized here
 5697|      0|      if (i != nchunk && offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (5697:11): [True: 0, False: 0]
  |  Branch (5697:26): [True: 0, False: 0]
  ------------------
 5698|      0|        sframe_chunk_id = offsets[i];
 5699|      0|      }
 5700|      0|    }
 5701|      0|    offsets[nchunk] = ++sframe_chunk_id;
 5702|      0|  }
 5703|      0|  else {
 5704|      0|    offsets[nchunk] = cbytes;
 5705|      0|  }
 5706|       |
 5707|       |  // Re-compress the offsets again
 5708|   218k|  uint8_t* off_chunk;
 5709|   218k|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 5710|   218k|                                            &off_chunk);
 5711|   218k|  free(offsets);
 5712|   218k|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (5712:7): [True: 0, False: 218k]
  ------------------
 5713|      0|    return NULL;
 5714|      0|  }
 5715|       |
 5716|   218k|  int64_t new_cbytes = cbytes + chunk_cbytes;
 5717|       |
 5718|   218k|  int64_t new_frame_len;
 5719|   218k|  if (frame->sframe) {
  ------------------
  |  Branch (5719:7): [True: 0, False: 218k]
  ------------------
 5720|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 5721|      0|  }
 5722|   218k|  else {
 5723|   218k|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 5724|   218k|  }
 5725|       |
 5726|       |  // Add the chunk and update meta
 5727|   218k|  void* fp = NULL;
 5728|   218k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (5728:7): [True: 218k, False: 0]
  ------------------
 5729|       |    /* Make space for the new chunk and copy it (keeping the frame if that fails) */
 5730|   218k|    uint8_t* framep = realloc(frame->cframe, (size_t)new_frame_len);
 5731|   218k|    if (framep == NULL) {
  ------------------
  |  Branch (5731:9): [True: 0, False: 218k]
  ------------------
 5732|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5733|      0|      goto failed;
 5734|      0|    }
 5735|   218k|    frame->cframe = framep;
 5736|       |    /* Copy the chunk */
 5737|   218k|    memcpy(framep + header_len + cbytes, chunk, (size_t)chunk_cbytes);
 5738|       |    /* Copy the offsets */
 5739|   218k|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 5740|   218k|  } else {
 5741|      0|    int64_t wbytes;
 5742|       |
 5743|      0|    int64_t io_pos = 0;
 5744|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 5745|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (5745:9): [True: 0, False: 0]
  ------------------
 5746|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5747|      0|      goto failed;
 5748|      0|    }
 5749|       |
 5750|      0|    if (frame->sframe) {
  ------------------
  |  Branch (5750:9): [True: 0, False: 0]
  ------------------
 5751|      0|      if (chunk_cbytes != 0) {
  ------------------
  |  Branch (5751:11): [True: 0, False: 0]
  ------------------
 5752|      0|        if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (5752:13): [True: 0, False: 0]
  ------------------
 5753|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5754|      0|          goto failed;
 5755|      0|        }
 5756|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (5756:13): [True: 0, False: 0]
  ------------------
 5757|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5758|      0|          goto failed;
 5759|      0|        }
 5760|      0|      }
 5761|       |      // Update the offsets chunk in the chunks frame
 5762|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 5763|      0|                             frame->schunk->storage->io);
 5764|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5764:11): [True: 0, False: 0]
  ------------------
 5765|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5766|      0|        goto failed;
 5767|      0|      }
 5768|      0|      io_pos = frame->file_offset + header_len + 0;
 5769|      0|    }
 5770|      0|    else {
 5771|       |      // Regular frame
 5772|      0|      fp = frame_writer_acquire(frame, io_cb);
 5773|      0|      if (fp == NULL) {
  ------------------
  |  Branch (5773:11): [True: 0, False: 0]
  ------------------
 5774|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5775|      0|        goto failed;
 5776|      0|      }
 5777|      0|      io_pos = frame->file_offset + header_len + cbytes;
 5778|      0|      wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 5779|      0|      io_pos += chunk_cbytes;
 5780|      0|      if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (5780:11): [True: 0, False: 0]
  ------------------
 5781|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5782|      0|                          " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 5783|      0|                          wbytes, (int64_t)chunk_cbytes, io_pos - (int64_t)chunk_cbytes, nchunk);
 5784|      0|        frame->file_end = 0;
 5785|      0|        frame_writer_release(frame, io_cb, fp);
 5786|      0|        goto failed;
 5787|      0|      }
 5788|      0|    }
 5789|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 5790|      0|    frame_writer_release(frame, io_cb, fp);
 5791|      0|    if (wbytes != new_off_cbytes) {
  ------------------
  |  Branch (5791:9): [True: 0, False: 0]
  ------------------
 5792|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5793|      0|      frame->file_end = 0;
 5794|      0|      goto failed;
 5795|      0|    }
 5796|       |    // Invalidate the cache for chunk offsets
 5797|      0|    if (frame->coffsets != NULL) {
  ------------------
  |  Branch (5797:9): [True: 0, False: 0]
  ------------------
 5798|      0|      if (frame->coffsets_needs_free)
  ------------------
  |  Branch (5798:11): [True: 0, False: 0]
  ------------------
 5799|      0|        free(frame->coffsets);
 5800|      0|      frame->coffsets = NULL;
 5801|      0|    }
 5802|      0|  }
 5803|   218k|  free(off_chunk);
 5804|       |
 5805|   218k|  frame->len = new_frame_len;
 5806|   218k|  rc = frame_update_header(frame, schunk, false);
 5807|   218k|  if (rc < 0) {
  ------------------
  |  Branch (5807:7): [True: 0, False: 218k]
  ------------------
 5808|      0|    frame->len = frame_len;
 5809|      0|    return NULL;
 5810|      0|  }
 5811|       |
 5812|   218k|  rc = frame_update_trailer(frame, schunk);
 5813|   218k|  if (rc < 0) {
  ------------------
  |  Branch (5813:7): [True: 0, False: 218k]
  ------------------
 5814|      0|    frame->len = frame_len;
 5815|      0|    return NULL;
 5816|      0|  }
 5817|       |
 5818|   218k|  return frame;
 5819|       |
 5820|      0|  failed:
 5821|       |  // The caller still owns the chunk; the offsets chunk is ours
 5822|      0|  free(off_chunk);
 5823|       |  return NULL;
 5824|   218k|}
frame_update_chunk:
 6010|   791k|                         int32_t cbytes_old) {
 6011|   791k|  uint8_t *chunk_ = (uint8_t *) chunk;
 6012|   791k|  int64_t* offsets = NULL;
 6013|   791k|  uint8_t* off_chunk = NULL;
 6014|   791k|  int32_t header_len;
 6015|   791k|  int64_t frame_len;
 6016|   791k|  int64_t nbytes;
 6017|   791k|  int64_t cbytes;
 6018|   791k|  int32_t blocksize;
 6019|   791k|  int32_t chunksize;
 6020|   791k|  int64_t nchunks;
 6021|   791k|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 6022|   791k|                           &blocksize, &chunksize, &nchunks,
 6023|   791k|                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 6024|   791k|                           frame->schunk->storage->io);
 6025|   791k|  if (rc < 0) {
  ------------------
  |  Branch (6025:7): [True: 0, False: 791k]
  ------------------
 6026|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6027|      0|    goto failed;
 6028|      0|  }
 6029|   791k|  rc = frame_refresh_if_stale(frame, frame_len);
 6030|   791k|  if (rc < 0) {
  ------------------
  |  Branch (6030:7): [True: 0, False: 791k]
  ------------------
 6031|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6032|      0|    goto failed;
 6033|      0|  }
 6034|   791k|  if (nchunk >= nchunks) {
  ------------------
  |  Branch (6034:7): [True: 0, False: 791k]
  ------------------
 6035|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6036|      0|    goto failed;
 6037|      0|  }
 6038|       |
 6039|   791k|  int32_t chunk_cbytes;
 6040|   791k|  rc = blosc2_cbuffer_sizes(chunk, NULL, &chunk_cbytes, NULL);
 6041|   791k|  if (rc < 0) {
  ------------------
  |  Branch (6041:7): [True: 0, False: 791k]
  ------------------
 6042|      0|    goto failed;
 6043|      0|  }
 6044|       |
 6045|       |  // Get the current offsets
 6046|   791k|  int32_t off_nbytes;
 6047|   791k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (6047:7): [True: 0, False: 791k]
  ------------------
 6048|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6049|      0|    goto failed;
 6050|      0|  }
 6051|   791k|  offsets = (int64_t *) malloc((size_t)off_nbytes);
 6052|   791k|  if (offsets == NULL) {
  ------------------
  |  Branch (6052:7): [True: 0, False: 791k]
  ------------------
 6053|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6054|      0|    goto failed;
 6055|      0|  }
 6056|   791k|  if (nchunks > 0) {
  ------------------
  |  Branch (6056:7): [True: 791k, False: 0]
  ------------------
 6057|   791k|    int32_t coffsets_cbytes = 0;
 6058|   791k|    uint8_t *coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 6059|   791k|    if (coffsets == NULL) {
  ------------------
  |  Branch (6059:9): [True: 0, False: 791k]
  ------------------
 6060|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6061|      0|      goto failed;
 6062|      0|    }
 6063|       |    // Decompress offsets
 6064|   791k|    blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 6065|   791k|    blosc2_context *dctx = blosc2_create_dctx(off_dparams);
 6066|   791k|    if (dctx == NULL) {
  ------------------
  |  Branch (6066:9): [True: 0, False: 791k]
  ------------------
 6067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6068|      0|      goto failed;
 6069|      0|    }
 6070|   791k|    int32_t prev_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 6071|   791k|    blosc2_free_ctx(dctx);
 6072|   791k|    if (prev_nbytes < 0) {
  ------------------
  |  Branch (6072:9): [True: 0, False: 791k]
  ------------------
 6073|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6074|      0|      goto failed;
 6075|      0|    }
 6076|   791k|  }
 6077|   791k|  int64_t old_offset = 0;
 6078|   791k|  if (!frame->sframe) {
  ------------------
  |  Branch (6078:7): [True: 791k, False: 0]
  ------------------
 6079|   791k|    old_offset = offsets[nchunk];
 6080|   791k|  }
 6081|       |
 6082|       |  // Add the new offset
 6083|   791k|  int64_t sframe_chunk_id = -1;
 6084|   791k|  int64_t old_sframe_chunk_id = -1;
 6085|   791k|  int64_t delta_cbytes = 0;
 6086|   791k|  bool old_chunk_is_regular = (!frame->sframe && old_offset >= 0);
  ------------------
  |  Branch (6086:32): [True: 791k, False: 0]
  |  Branch (6086:50): [True: 19.5k, False: 771k]
  ------------------
 6087|   791k|  bool new_chunk_is_regular = true;
 6088|   791k|  int64_t new_chunk_offset = cbytes;
 6089|       |  // Inside frame_begin_updates(), a resized chunk leaves a hole instead of moving the payload behind it
 6090|   791k|  bool defer = !frame->sframe && frame->updates_depth > 0;
  ------------------
  |  Branch (6090:16): [True: 791k, False: 0]
  |  Branch (6090:34): [True: 767k, False: 23.6k]
  ------------------
 6091|   791k|  if (frame->sframe) {
  ------------------
  |  Branch (6091:7): [True: 0, False: 791k]
  ------------------
 6092|      0|    if (offsets[nchunk] < 0) {
  ------------------
  |  Branch (6092:9): [True: 0, False: 0]
  ------------------
 6093|      0|      sframe_chunk_id = -1;
 6094|      0|    }
 6095|      0|    else {
 6096|       |      // In case there was a reorder in a sframe
 6097|      0|      sframe_chunk_id = offsets[nchunk];
 6098|      0|      old_sframe_chunk_id = offsets[nchunk];
 6099|      0|    }
 6100|      0|  }
 6101|   791k|  int special_value = chunk_special_in_offset(chunk_, chunk_cbytes);
 6102|   791k|  bool is_special_chunk = special_value != 0;
 6103|   791k|  if (is_special_chunk) {
  ------------------
  |  Branch (6103:7): [True: 157k, False: 633k]
  ------------------
 6104|   157k|    special_offset(offsets + nchunk, special_value);
 6105|   157k|  }
 6106|   633k|  else if (frame->sframe) {
  ------------------
  |  Branch (6106:12): [True: 0, False: 633k]
  ------------------
 6107|      0|    if (sframe_chunk_id < 0) {
  ------------------
  |  Branch (6107:9): [True: 0, False: 0]
  ------------------
 6108|      0|      for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (6108:27): [True: 0, False: 0]
  ------------------
 6109|      0|        if (offsets[i] > sframe_chunk_id) {
  ------------------
  |  Branch (6109:13): [True: 0, False: 0]
  ------------------
 6110|      0|          sframe_chunk_id = offsets[i];
 6111|      0|        }
 6112|      0|      }
 6113|      0|      offsets[nchunk] = ++sframe_chunk_id;
 6114|      0|    }
 6115|      0|  }
 6116|   633k|  else {
 6117|   633k|    if (old_chunk_is_regular) {
  ------------------
  |  Branch (6117:9): [True: 17.8k, False: 615k]
  ------------------
 6118|  17.8k|      new_chunk_offset = old_offset;
 6119|  17.8k|    }
 6120|   633k|    offsets[nchunk] = new_chunk_offset;
 6121|   633k|  }
 6122|   791k|  if (is_special_chunk) {
  ------------------
  |  Branch (6122:7): [True: 157k, False: 633k]
  ------------------
 6123|   157k|    chunk_cbytes = 0;   // Special chunks are encoded in offsets and have no stored payload.
 6124|   157k|    new_chunk_is_regular = false;
 6125|   157k|  }
 6126|   791k|  if (defer) {
  ------------------
  |  Branch (6126:7): [True: 767k, False: 23.6k]
  ------------------
 6127|   767k|    if (old_chunk_is_regular || new_chunk_is_regular) {
  ------------------
  |  Branch (6127:9): [True: 19.5k, False: 747k]
  |  Branch (6127:33): [True: 591k, False: 156k]
  ------------------
 6128|   611k|      int64_t payload_end = cbytes;
 6129|   611k|      new_chunk_offset = holes_place(frame, old_chunk_is_regular ? old_offset : -1, cbytes_old, chunk_cbytes,
  ------------------
  |  Branch (6129:45): [True: 19.5k, False: 591k]
  ------------------
 6130|   611k|                                     &payload_end);
 6131|   611k|      delta_cbytes = payload_end - cbytes;
 6132|   611k|      if (new_chunk_is_regular) {
  ------------------
  |  Branch (6132:11): [True: 609k, False: 1.74k]
  ------------------
 6133|   609k|        offsets[nchunk] = new_chunk_offset;
 6134|   609k|      }
 6135|   611k|    }
 6136|   767k|  }
 6137|  23.6k|  else if (!frame->sframe) {
  ------------------
  |  Branch (6137:12): [True: 23.6k, False: 0]
  ------------------
 6138|  23.6k|    if (old_chunk_is_regular) {
  ------------------
  |  Branch (6138:9): [True: 0, False: 23.6k]
  ------------------
 6139|      0|      delta_cbytes = (int64_t)chunk_cbytes - cbytes_old;
 6140|      0|      for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (6140:27): [True: 0, False: 0]
  ------------------
 6141|      0|        if (i == nchunk || offsets[i] < 0) {
  ------------------
  |  Branch (6141:13): [True: 0, False: 0]
  |  Branch (6141:28): [True: 0, False: 0]
  ------------------
 6142|      0|          continue;
 6143|      0|        }
 6144|      0|        if (offsets[i] > old_offset) {
  ------------------
  |  Branch (6144:13): [True: 0, False: 0]
  ------------------
 6145|      0|          offsets[i] += delta_cbytes;
 6146|      0|        }
 6147|      0|      }
 6148|      0|    }
 6149|  23.6k|    else if (new_chunk_is_regular) {
  ------------------
  |  Branch (6149:14): [True: 23.6k, False: 0]
  ------------------
 6150|  23.6k|      delta_cbytes = chunk_cbytes;
 6151|  23.6k|    }
 6152|  23.6k|  }
 6153|       |  // Re-compress the offsets again
 6154|   791k|  int32_t new_off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD,
 6155|   791k|                                            &off_chunk);
 6156|   791k|  free(offsets);
 6157|   791k|  offsets = NULL;
 6158|   791k|  if (new_off_cbytes < 0) {
  ------------------
  |  Branch (6158:7): [True: 0, False: 791k]
  ------------------
 6159|      0|    goto failed;
 6160|      0|  }
 6161|       |
 6162|   791k|  int64_t new_cbytes = cbytes;
 6163|   791k|  if (!frame->sframe) {
  ------------------
  |  Branch (6163:7): [True: 791k, False: 0]
  ------------------
 6164|   791k|    new_cbytes += delta_cbytes;
 6165|   791k|  }
 6166|      0|  else {
 6167|      0|    new_cbytes = schunk->cbytes;
 6168|      0|  }
 6169|   791k|  int64_t new_frame_len;
 6170|   791k|  if (frame->sframe) {
  ------------------
  |  Branch (6170:7): [True: 0, False: 791k]
  ------------------
 6171|       |    // The chunk is not stored in the frame
 6172|      0|    new_frame_len = header_len + 0 + new_off_cbytes + frame->trailer_len;
 6173|      0|  }
 6174|   791k|  else {
 6175|   791k|    new_frame_len = header_len + new_cbytes + new_off_cbytes + frame->trailer_len;
 6176|   791k|  }
 6177|       |
 6178|   791k|  void* fp = NULL;
 6179|   791k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (6179:7): [True: 791k, False: 0]
  ------------------
 6180|   791k|    uint8_t* framep = frame->cframe;
 6181|   791k|    if (new_frame_len > frame->len) {
  ------------------
  |  Branch (6181:9): [True: 622k, False: 168k]
  ------------------
 6182|       |      // Keep the frame if the realloc fails
 6183|   622k|      framep = realloc(framep, (size_t)new_frame_len);
 6184|   622k|      if (framep == NULL) {
  ------------------
  |  Branch (6184:11): [True: 0, False: 622k]
  ------------------
 6185|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6186|      0|        goto failed;
 6187|      0|      }
 6188|   622k|      frame->cframe = framep;
 6189|   622k|    }
 6190|   791k|    if (!frame->sframe && old_chunk_is_regular && !defer) {
  ------------------
  |  Branch (6190:9): [True: 791k, False: 0]
  |  Branch (6190:27): [True: 19.5k, False: 771k]
  |  Branch (6190:51): [True: 0, False: 19.5k]
  ------------------
 6191|      0|      int64_t tail_src_offset = old_offset + cbytes_old;
 6192|      0|      int64_t tail_dst_offset = old_offset + chunk_cbytes;
 6193|      0|      int64_t tail_nbytes = cbytes - tail_src_offset;
 6194|      0|      if (tail_nbytes > 0 && tail_src_offset != tail_dst_offset) {
  ------------------
  |  Branch (6194:11): [True: 0, False: 0]
  |  Branch (6194:30): [True: 0, False: 0]
  ------------------
 6195|      0|        memmove(framep + header_len + tail_dst_offset, framep + header_len + tail_src_offset, (size_t)tail_nbytes);
 6196|      0|      }
 6197|      0|    }
 6198|   791k|    if (!frame->sframe && new_chunk_is_regular) {
  ------------------
  |  Branch (6198:9): [True: 791k, False: 0]
  |  Branch (6198:27): [True: 633k, False: 157k]
  ------------------
 6199|   633k|      memcpy(framep + header_len + new_chunk_offset, chunk, (size_t)chunk_cbytes);
 6200|   633k|    }
 6201|       |    /* Copy the offsets */
 6202|   791k|    memcpy(framep + header_len + new_cbytes, off_chunk, (size_t)new_off_cbytes);
 6203|   791k|  } else {
 6204|      0|    int64_t wbytes;
 6205|       |
 6206|      0|    int64_t io_pos = 0;
 6207|      0|    blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 6208|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (6208:9): [True: 0, False: 0]
  ------------------
 6209|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6210|      0|      goto failed;
 6211|      0|    }
 6212|       |
 6213|      0|    if (frame->sframe) {
  ------------------
  |  Branch (6213:9): [True: 0, False: 0]
  ------------------
 6214|       |      // Create or update chunk file only for chunks with stored payload (regular or VALUE)
 6215|      0|      if (!is_special_chunk && sframe_chunk_id >= 0) {
  ------------------
  |  Branch (6215:11): [True: 0, False: 0]
  |  Branch (6215:32): [True: 0, False: 0]
  ------------------
 6216|      0|        if (sframe_create_chunk(frame, chunk, sframe_chunk_id, chunk_cbytes) == NULL) {
  ------------------
  |  Branch (6216:13): [True: 0, False: 0]
  ------------------
 6217|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6218|      0|          goto failed;
 6219|      0|        }
 6220|      0|      }
 6221|       |      // Update the offsets chunk in the chunks frame
 6222|      0|      fp = sframe_open_index(frame->urlpath, "rb+",
 6223|      0|                             frame->schunk->storage->io);
 6224|      0|      if (fp == NULL) {
  ------------------
  |  Branch (6224:11): [True: 0, False: 0]
  ------------------
 6225|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6226|      0|        goto failed;
 6227|      0|      }
 6228|      0|      io_pos = frame->file_offset + header_len + 0;
 6229|      0|    }
 6230|      0|    else {
 6231|       |      // Regular frame
 6232|      0|      fp = frame_writer_acquire(frame, io_cb);
 6233|      0|      if (fp == NULL) {
  ------------------
  |  Branch (6233:11): [True: 0, False: 0]
  ------------------
 6234|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6235|      0|        goto failed;
 6236|      0|      }
 6237|      0|      if (old_chunk_is_regular && !defer) {
  ------------------
  |  Branch (6237:11): [True: 0, False: 0]
  |  Branch (6237:35): [True: 0, False: 0]
  ------------------
 6238|      0|        int64_t tail_src_offset = old_offset + cbytes_old;
 6239|      0|        int64_t tail_dst_offset = old_offset + chunk_cbytes;
 6240|      0|        int64_t tail_nbytes = cbytes - tail_src_offset;
 6241|      0|        if (tail_nbytes < 0) {
  ------------------
  |  Branch (6241:13): [True: 0, False: 0]
  ------------------
 6242|      0|          frame_writer_release(frame, io_cb, fp);
 6243|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6244|      0|          goto failed;
 6245|      0|        }
 6246|      0|        if (tail_nbytes > 0 && tail_src_offset != tail_dst_offset) {
  ------------------
  |  Branch (6246:13): [True: 0, False: 0]
  |  Branch (6246:32): [True: 0, False: 0]
  ------------------
 6247|      0|          int rc_move = frame_move_range(io_cb, fp,
 6248|      0|                                         frame->file_offset + header_len + tail_src_offset,
 6249|      0|                                         frame->file_offset + header_len + tail_dst_offset,
 6250|      0|                                         tail_nbytes, 0);
 6251|      0|          if (rc_move < 0) {
  ------------------
  |  Branch (6251:15): [True: 0, False: 0]
  ------------------
 6252|      0|            frame->file_end = 0;
 6253|      0|            frame_writer_release(frame, io_cb, fp);
 6254|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6255|      0|            goto failed;
 6256|      0|          }
 6257|      0|        }
 6258|      0|      }
 6259|      0|      if (new_chunk_is_regular) {
  ------------------
  |  Branch (6259:11): [True: 0, False: 0]
  ------------------
 6260|      0|        io_pos = frame->file_offset + header_len + new_chunk_offset;
 6261|      0|        wbytes = io_cb->write(chunk, 1, chunk_cbytes, io_pos, fp);  // the new chunk
 6262|      0|        if (wbytes != chunk_cbytes) {
  ------------------
  |  Branch (6262:13): [True: 0, False: 0]
  ------------------
 6263|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6264|      0|                            " bytes at position %" PRId64 ", nchunk=%" PRId64 ").",
 6265|      0|                            wbytes, (int64_t)chunk_cbytes, io_pos, nchunk);
 6266|      0|          frame->file_end = 0;
 6267|      0|          frame_writer_release(frame, io_cb, fp);
 6268|      0|          goto failed;
 6269|      0|        }
 6270|      0|      }
 6271|      0|      io_pos = frame->file_offset + header_len + new_cbytes;
 6272|      0|    }
 6273|      0|    wbytes = io_cb->write(off_chunk, 1, new_off_cbytes, io_pos, fp);  // the new offsets
 6274|      0|    frame_writer_release(frame, io_cb, fp);
 6275|      0|    if (wbytes != new_off_cbytes) {
  ------------------
  |  Branch (6275:9): [True: 0, False: 0]
  ------------------
 6276|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6277|      0|      frame->file_end = 0;
 6278|      0|      goto failed;
 6279|      0|    }
 6280|       |    // Invalidate the cache for chunk offsets
 6281|      0|    if (frame->coffsets != NULL) {
  ------------------
  |  Branch (6281:9): [True: 0, False: 0]
  ------------------
 6282|      0|      if (frame->coffsets_needs_free)
  ------------------
  |  Branch (6282:11): [True: 0, False: 0]
  ------------------
 6283|      0|        free(frame->coffsets);
 6284|      0|      frame->coffsets = NULL;
 6285|      0|    }
 6286|      0|  }
 6287|   791k|  free(off_chunk);
 6288|   791k|  off_chunk = NULL;
 6289|       |
 6290|   791k|  if (defer) {
  ------------------
  |  Branch (6290:7): [True: 767k, False: 23.6k]
  ------------------
 6291|       |    // The header describes the payload as it lies, holes included
 6292|   767k|    schunk->cbytes = new_cbytes;
 6293|   767k|  }
 6294|   791k|  frame->len = new_frame_len;
 6295|   791k|  rc = frame_update_header(frame, schunk, false);
 6296|   791k|  if (rc < 0) {
  ------------------
  |  Branch (6296:7): [True: 0, False: 791k]
  ------------------
 6297|      0|    frame->len = frame_len;
 6298|      0|    goto failed;
 6299|      0|  }
 6300|       |
 6301|   791k|  rc = frame_update_trailer(frame, schunk);
 6302|   791k|  if (rc < 0) {
  ------------------
  |  Branch (6302:7): [True: 0, False: 791k]
  ------------------
 6303|      0|    frame->len = frame_len;
 6304|      0|    goto failed;
 6305|      0|  }
 6306|       |
 6307|   791k|  if (frame->sframe && is_special_chunk && old_sframe_chunk_id >= 0) {
  ------------------
  |  Branch (6307:7): [True: 0, False: 791k]
  |  Branch (6307:24): [True: 0, False: 0]
  |  Branch (6307:44): [True: 0, False: 0]
  ------------------
 6308|      0|    const blosc2_io *io = (frame->schunk && frame->schunk->storage) ? frame->schunk->storage->io : NULL;
  ------------------
  |  Branch (6308:28): [True: 0, False: 0]
  |  Branch (6308:45): [True: 0, False: 0]
  ------------------
 6309|      0|    int err = sframe_delete_chunk(frame->urlpath, old_sframe_chunk_id, io);
 6310|      0|    if (err != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (6310:9): [True: 0, False: 0]
  ------------------
 6311|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6312|      0|                          old_sframe_chunk_id, err);
 6313|       |      // Do not return NULL: the update was already committed to the index and trailer.
 6314|       |      // Distinguish orphan cleanup failure from failure to commit the update.
 6315|      0|    }
 6316|      0|  }
 6317|       |
 6318|   791k|  return frame;
 6319|       |
 6320|      0|  failed:
 6321|      0|  free(offsets);
 6322|      0|  free(off_chunk);
 6323|       |  return NULL;
 6324|   791k|}
frame_begin_updates:
 6507|   535k|int frame_begin_updates(blosc2_frame_s* frame) {
 6508|   535k|  if (frame == NULL) {
  ------------------
  |  Branch (6508:7): [True: 0, False: 535k]
  ------------------
 6509|      0|    return BLOSC2_ERROR_SUCCESS;
 6510|      0|  }
 6511|   535k|  int rc = frame_lock(frame, true);
 6512|   535k|  if (rc < 0) {
  ------------------
  |  Branch (6512:7): [True: 0, False: 535k]
  ------------------
 6513|      0|    return rc;
 6514|      0|  }
 6515|   535k|  if (!frame->sframe && frame->updates_depth++ == 0) {
  ------------------
  |  Branch (6515:7): [True: 535k, False: 0]
  |  Branch (6515:25): [True: 535k, False: 0]
  ------------------
 6516|   535k|    frame->nholes = 0;
 6517|       |    frame->holes_lost = false;
 6518|   535k|  }
 6519|   535k|  return BLOSC2_ERROR_SUCCESS;
 6520|   535k|}
frame_end_updates:
 6523|   535k|int frame_end_updates(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 6524|   535k|  if (frame == NULL) {
  ------------------
  |  Branch (6524:7): [True: 0, False: 535k]
  ------------------
 6525|      0|    return BLOSC2_ERROR_SUCCESS;
 6526|      0|  }
 6527|   535k|  int rc = BLOSC2_ERROR_SUCCESS;
 6528|   535k|  if (!frame->sframe && frame->updates_depth > 0 && --frame->updates_depth == 0) {
  ------------------
  |  Branch (6528:7): [True: 535k, False: 0]
  |  Branch (6528:25): [True: 535k, False: 0]
  |  Branch (6528:53): [True: 535k, False: 0]
  ------------------
 6529|   535k|    if (frame->holes_lost) {
  ------------------
  |  Branch (6529:9): [True: 0, False: 535k]
  ------------------
 6530|       |      // Valid, just larger: the holes stay as dead space, like the space of deleted chunks
 6531|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6532|      0|    }
 6533|   535k|    else if (frame->nholes > 0) {
  ------------------
  |  Branch (6533:14): [True: 787, False: 535k]
  ------------------
 6534|    787|      rc = frame_compact(frame, schunk);
 6535|    787|    }
 6536|   535k|    frame->nholes = 0;
 6537|   535k|    frame->holes_lost = false;
 6538|   535k|  }
 6539|   535k|  int unlock_rc = frame_unlock(frame);
 6540|   535k|  return rc < 0 ? rc : unlock_rc;
  ------------------
  |  Branch (6540:10): [True: 0, False: 535k]
  ------------------
 6541|   535k|}
frame_decompress_chunk:
 6872|   634k|int frame_decompress_chunk(blosc2_context *dctx, blosc2_frame_s* frame, int64_t nchunk, void *dest, int32_t nbytes) {
 6873|   634k|  uint8_t* src = NULL;
 6874|   634k|  bool needs_free = false;
 6875|   634k|  int32_t srcsize;
 6876|   634k|  int32_t chunk_nbytes;
 6877|   634k|  int32_t chunk_cbytes;
 6878|   634k|  int rc;
 6879|       |
 6880|   634k|  size_t capacity = 0;
 6881|   634k|  rc = get_chunk(frame, nchunk, &src, &needs_free, &capacity);
 6882|   634k|  if (rc < 0) {
  ------------------
  |  Branch (6882:7): [True: 0, False: 634k]
  ------------------
 6883|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6884|      0|    goto end;
 6885|      0|  }
 6886|   634k|  srcsize = rc;
 6887|   634k|  if (srcsize < BLOSC_MIN_HEADER_LENGTH) {
  ------------------
  |  Branch (6887:7): [True: 0, False: 634k]
  ------------------
 6888|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6889|      0|    rc = BLOSC2_ERROR_READ_BUFFER;
 6890|      0|    goto end;
 6891|      0|  }
 6892|       |
 6893|   634k|  rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 6894|   634k|  if (rc < 0) {
  ------------------
  |  Branch (6894:7): [True: 0, False: 634k]
  ------------------
 6895|      0|    goto end;
 6896|      0|  }
 6897|       |  /* The header cbytes is used as srcsize below, so it must fit in what was read */
 6898|   634k|  if (chunk_cbytes > srcsize) {
  ------------------
  |  Branch (6898:7): [True: 0, False: 634k]
  ------------------
 6899|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6900|      0|    rc = BLOSC2_ERROR_INVALID_HEADER;
 6901|      0|    goto end;
 6902|      0|  }
 6903|       |
 6904|       |  /* Create a buffer for destination */
 6905|   634k|  if (chunk_nbytes > nbytes) {
  ------------------
  |  Branch (6905:7): [True: 0, False: 634k]
  ------------------
 6906|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6907|      0|    rc = BLOSC2_ERROR_WRITE_BUFFER;
 6908|      0|    goto end;
 6909|      0|  }
 6910|       |  /* And decompress it */
 6911|   634k|  dctx->header_overhead = BLOSC_EXTENDED_HEADER_LENGTH;
 6912|   634k|  int chunksize = rc = blosc2_decompress_ctx(dctx, src, chunk_cbytes, dest, nbytes);
 6913|   634k|  if (chunksize < 0 || chunksize != chunk_nbytes) {
  ------------------
  |  Branch (6913:7): [True: 0, False: 634k]
  |  Branch (6913:24): [True: 0, False: 634k]
  ------------------
 6914|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6915|      0|    if (chunksize >= 0)
  ------------------
  |  Branch (6915:9): [True: 0, False: 0]
  ------------------
 6916|      0|      rc = BLOSC2_ERROR_FAILURE;
 6917|      0|  }
 6918|   634k|  end:
 6919|   634k|  if (needs_free) {
  ------------------
  |  Branch (6919:7): [True: 15.2k, False: 619k]
  ------------------
 6920|  15.2k|    blosc2_tmp_free(src, capacity);
 6921|  15.2k|  }
 6922|   634k|  return rc;
 6923|   634k|}
frame.c:frame_writer_close_locked:
  424|  9.88k|static void frame_writer_close_locked(blosc2_frame_s* frame) {
  425|  9.88k|  if (frame->write_fp != NULL) {
  ------------------
  |  Branch (425:7): [True: 0, False: 9.88k]
  ------------------
  426|       |    /* Only the filesystem backend ever populates write_fp */
  427|      0|    blosc2_stdio_close(frame->write_fp);
  428|      0|    frame->write_fp = NULL;
  429|      0|#if !defined(_WIN32)
  430|      0|    reader_cache_return();
  431|      0|#endif
  432|      0|  }
  433|       |  frame->write_fp_stale = false;
  434|  9.88k|  frame->file_end = 0;
  435|  9.88k|}
frame.c:frame_reader_close_locked:
  395|  9.88k|static bool frame_reader_close_locked(blosc2_frame_s* frame, bool force) {
  396|  9.88k|  if (frame->read_fp == NULL) {
  ------------------
  |  Branch (396:7): [True: 9.88k, False: 0]
  ------------------
  397|  9.88k|    return true;
  398|  9.88k|  }
  399|      0|  if (frame->read_fp_refs > 0 && !force) {
  ------------------
  |  Branch (399:7): [True: 0, False: 0]
  |  Branch (399:34): [True: 0, False: 0]
  ------------------
  400|       |    /* A caller up the stack is reading through it (frame_to_schunk holds it
  401|       |       across its whole chunk loop, and that loop re-enters get_header_info).
  402|       |       Closing it here would hand that caller a dangling handle, and its own
  403|       |       release would then close it a second time.  Leave it: the operation in
  404|       |       flight finishes on the file it started on, and the next revalidate --
  405|       |       past that release -- drops it. */
  406|      0|    return false;
  407|      0|  }
  408|       |  /* read_fp only ever comes from the filesystem backend, so close it directly:
  409|       |     blosc2_get_io_cb() would return NULL after a blosc2_destroy(), and then the
  410|       |     descriptor would leak while its cache slot got handed back anyway. */
  411|      0|  blosc2_stdio_close(frame->read_fp);
  412|      0|  frame->read_fp = NULL;
  413|      0|  frame->read_fp_refs = 0;
  414|      0|#if !defined(_WIN32)
  415|      0|  reader_cache_return();
  416|      0|#endif
  417|       |  return true;
  418|      0|}
frame.c:frame_alloc:
  288|  9.91k|static blosc2_frame_s* frame_alloc(void) {
  289|  9.91k|  blosc2_frame_s* frame = calloc(1, sizeof(blosc2_frame_s));
  290|  9.91k|  if (frame != NULL) {
  ------------------
  |  Branch (290:7): [True: 9.91k, False: 0]
  ------------------
  291|  9.91k|    blosc2_pthread_mutex_init(&frame->read_fp_mutex, NULL);
  ------------------
  |  |   90|  9.91k|#define blosc2_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
  ------------------
  292|  9.91k|  }
  293|  9.91k|  return frame;
  294|  9.91k|}
frame.c:frame_refresh_if_stale:
 1405|  3.79M|static int frame_refresh_if_stale(blosc2_frame_s *frame, int64_t frame_len_on_disk) {
 1406|  3.79M|  if (frame->cframe != NULL || frame->schunk == NULL ||
  ------------------
  |  Branch (1406:7): [True: 3.79M, False: 0]
  |  Branch (1406:32): [True: 0, False: 0]
  ------------------
 1407|  3.79M|      (!frame->force_refresh && frame_len_on_disk == frame->len)) {
  ------------------
  |  Branch (1407:8): [True: 0, False: 0]
  |  Branch (1407:33): [True: 0, False: 0]
  ------------------
 1408|  3.79M|    return 0;
 1409|  3.79M|  }
 1410|       |  // Saved so the metalayer-reload retry loop below can roll back to a fully
 1411|       |  // consistent state on exhaustion, rather than leaving frame->len/trailer_len
 1412|       |  // committed to the new value with no metalayers to match it.
 1413|      0|  int64_t old_len = frame->len;
 1414|      0|  uint32_t old_trailer_len = frame->trailer_len;
 1415|       |
 1416|      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 (1416:7): [True: 0, False: 0]
  ------------------
 1417|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1418|      0|    return BLOSC2_ERROR_FILE_READ;
 1419|      0|  }
 1420|       |
 1421|       |  // Read and validate the trailer *before* mutating any frame state below,
 1422|       |  // so a transient torn read (a writer without locking has no coordination
 1423|       |  // preventing a reader from landing mid-rewrite here -- the documented
 1424|       |  // SWMR-without-locking tradeoff) can be handled opportunistically: keep
 1425|       |  // the old cached view and let the next access retry, the same way
 1426|       |  // frame_check_stale()'s header read already does a few lines up in the
 1427|       |  // caller. Once frame->len/coffsets are overwritten below, a failure
 1428|       |  // partway through would leave the frame in a self-inconsistent state
 1429|       |  // (new length, stale trailer/offsets), so those mutations only happen
 1430|       |  // after the trailer is confirmed good.
 1431|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 1432|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (1432:7): [True: 0, False: 0]
  ------------------
 1433|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1434|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1435|      0|  }
 1436|      0|  void* fp;
 1437|      0|  if (frame->sframe) {
  ------------------
  |  Branch (1437:7): [True: 0, False: 0]
  ------------------
 1438|      0|    fp = sframe_open_index(frame->urlpath, "rb", frame->schunk->storage->io);
 1439|      0|  }
 1440|      0|  else {
 1441|      0|    fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 1442|      0|  }
 1443|      0|  if (fp == NULL) {
  ------------------
  |  Branch (1443:7): [True: 0, False: 0]
  ------------------
 1444|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1445|      0|    return BLOSC2_ERROR_FILE_OPEN;
 1446|      0|  }
 1447|      0|  uint8_t trailer[FRAME_TRAILER_MINLEN];
 1448|      0|  uint8_t* trailer_ptr = trailer;
 1449|      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)
  ------------------
 1450|      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)
  ------------------
 1451|      0|  frame_reader_release(frame, io_cb, fp);
 1452|      0|  if (rbytes != FRAME_TRAILER_MINLEN) {
  ------------------
  |  |   58|      0|#define FRAME_TRAILER_MINLEN (25)  // minimum length for the trailer (msgpack overhead)
  ------------------
  |  Branch (1452:7): [True: 0, False: 0]
  ------------------
 1453|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1454|      0|    return 0;  // opportunistic: transient, keep the cached view, retry later
 1455|      0|  }
 1456|      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)
  ------------------
 1457|      0|  if (trailer_ptr[trailer_offset - 1] != 0xce) {
  ------------------
  |  Branch (1457:7): [True: 0, False: 0]
  ------------------
 1458|       |    // Not a valid trailer; most likely we are reading a frame in the middle of
 1459|       |    // being rewritten by another handle without locking (locked handles
 1460|       |    // fully serialize, so this only happens under the no-locking contract).
 1461|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1462|      0|    return 0;  // opportunistic, same reasoning as above
 1463|      0|  }
 1464|      0|  uint32_t trailer_len;
 1465|      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)
  ------------------
 1466|      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 (1466:7): [True: 0, False: 0]
  |  Branch (1466:45): [True: 0, False: 0]
  ------------------
 1467|      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 (1467:7): [True: 0, False: 0]
  ------------------
 1468|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1469|      0|    return 0;  // opportunistic, same reasoning as above
 1470|      0|  }
 1471|       |
 1472|       |  // Trailer confirmed good: now safe to commit the new length. The lock
 1473|       |  // generation counter (see frame_lock) may have flagged a mutation that
 1474|       |  // left the frame length unchanged; only clear that flag here, once a
 1475|       |  // refresh has actually happened -- clearing it earlier and then bailing
 1476|       |  // out opportunistically above would permanently lose a same-length
 1477|       |  // mutation notification on a torn-read retry. The cached offsets index is
 1478|       |  // dropped further down, only once the metalayer/vlmetalayer reload below
 1479|       |  // has actually succeeded -- neither of those touches frame->coffsets, so
 1480|       |  // deferring this keeps the old view of it fully intact for the
 1481|       |  // opportunistic rollback path below, exactly as strong as the trailer
 1482|       |  // read's own bail-outs above.
 1483|      0|  frame->force_refresh = false;
 1484|      0|  frame->len = frame_len_on_disk;
 1485|      0|  frame->file_end = 0;  // another handle wrote the file; its size is unknown again
 1486|      0|  if (frame->nholes > 0) {
  ------------------
  |  Branch (1486:7): [True: 0, False: 0]
  ------------------
 1487|       |    // Nor do we know its free space any more (only an unlocked writer gets here inside frame_begin_updates())
 1488|      0|    frame->nholes = 0;
 1489|      0|    frame->holes_lost = true;
 1490|      0|  }
 1491|      0|  frame->trailer_len = trailer_len;
 1492|       |
 1493|       |  // The header metalayers and trailer vlmetalayers were cached at open time;
 1494|       |  // reload them so metadata changes made by another handle (e.g. a b2nd shape
 1495|       |  // update) become visible too.  The guard protects against re-entering from
 1496|       |  // the reload path itself (get_header_info does not refresh, but cheap
 1497|       |  // insurance against future changes there).
 1498|       |  //
 1499|       |  // frame_get_metalayers()/frame_get_vlmetalayers() each do their own fully
 1500|       |  // independent header/trailer re-read (separate from the trailer read
 1501|       |  // above), so without locking they can hit the same transient torn-read
 1502|       |  // window. Unlike that trailer read, there's no way to validate first and
 1503|       |  // commit after: schunk_free_metalayers()/schunk_free_vlmetalayers() must
 1504|       |  // run before a reload attempt (the parsers write straight into
 1505|       |  // schunk->metalayers[]/vlmetalayers[] as they go), so a single failed
 1506|       |  // attempt already discards the old cached set. Retry a bounded number of
 1507|       |  // times -- both free helpers are NULL-safe and re-run cleanly against a
 1508|       |  // partial prior attempt, and each attempt is a fresh independent read, so
 1509|       |  // this self-heals once the writer's rewrite stabilizes.
 1510|       |  //
 1511|       |  // This reasoning only holds without locking, though: frame_check_stale()
 1512|       |  // (the only caller) holds the shared frame lock across this entire call
 1513|       |  // when frame->locking is set, which fully excludes writers for its
 1514|       |  // duration -- so under locking a reload failure here cannot be a torn
 1515|       |  // read, it is a genuine problem (corruption or a real I/O error), and
 1516|       |  // retrying 50 times would just waste ~50ms holding that shared lock
 1517|       |  // before silently masking it. Retry once (i.e. don't retry) and propagate
 1518|       |  // the error under locking; keep the opportunistic bounded retry + silent
 1519|       |  // rollback for the no-locking case only.
 1520|       |  //
 1521|       |  // On exhaustion in the no-locking case, roll back frame->len/trailer_len
 1522|       |  // to what they were before this call and force a full retry on the next
 1523|       |  // poll (frame->force_refresh = true) -- otherwise frame_len_on_disk ==
 1524|       |  // frame->len would short-circuit every subsequent call at the top of this
 1525|       |  // function, permanently stranding this handle with an empty metalayer set.
 1526|      0|  if (!frame->refreshing) {
  ------------------
  |  Branch (1526:7): [True: 0, False: 0]
  ------------------
 1527|      0|    frame->refreshing = true;
 1528|      0|    int rc = -1;
 1529|      0|    const int max_attempts = frame->locking ? 1 : 50;
  ------------------
  |  Branch (1529:30): [True: 0, False: 0]
  ------------------
 1530|      0|    for (int attempt = 0; attempt < max_attempts; attempt++) {
  ------------------
  |  Branch (1530:27): [True: 0, False: 0]
  ------------------
 1531|      0|      schunk_free_metalayers(frame->schunk);
 1532|      0|      rc = frame_get_metalayers(frame, frame->schunk);
 1533|      0|      if (rc >= 0) {
  ------------------
  |  Branch (1533:11): [True: 0, False: 0]
  ------------------
 1534|      0|        schunk_free_vlmetalayers(frame->schunk);
 1535|      0|        rc = frame_get_vlmetalayers(frame, frame->schunk);
 1536|      0|      }
 1537|      0|      if (rc >= 0 || attempt + 1 == max_attempts) {
  ------------------
  |  Branch (1537:11): [True: 0, False: 0]
  |  Branch (1537:22): [True: 0, False: 0]
  ------------------
 1538|      0|        break;
 1539|      0|      }
 1540|       |#if defined(_WIN32)
 1541|       |      Sleep(1);
 1542|       |#else
 1543|      0|      usleep(1000);
 1544|      0|#endif
 1545|      0|    }
 1546|      0|    frame->refreshing = false;
 1547|      0|    if (rc < 0) {
  ------------------
  |  Branch (1547:9): [True: 0, False: 0]
  ------------------
 1548|      0|      if (frame->locking) {
  ------------------
  |  Branch (1548:11): [True: 0, False: 0]
  ------------------
 1549|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1550|      0|                          "(locked handle: this is not a transient race).");
 1551|      0|        return rc;
 1552|      0|      }
 1553|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1554|      0|                        "after retries; rolling back to the previous cached view.");
 1555|      0|      frame->len = old_len;
 1556|      0|      frame->trailer_len = old_trailer_len;
 1557|      0|      frame->force_refresh = true;
 1558|      0|      return 0;
 1559|      0|    }
 1560|      0|  }
 1561|      0|  frame->schunk->change_tick++;
 1562|       |
 1563|       |  // Cached offsets index invalidated only now, after a fully successful
 1564|       |  // refresh: recomputed lazily from the fresh trailer on demand.
 1565|      0|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (1565:7): [True: 0, False: 0]
  ------------------
 1566|      0|    if (frame->coffsets_needs_free) {
  ------------------
  |  Branch (1566:9): [True: 0, False: 0]
  ------------------
 1567|      0|      free(frame->coffsets);
 1568|      0|    }
 1569|      0|    frame->coffsets = NULL;
 1570|      0|  }
 1571|       |
 1572|      0|  return 1;
 1573|      0|}
frame.c:get_coffsets_nbytes:
 1620|  1.70k|                               int32_t *coffsets_nbytes, const blosc2_io *io) {
 1621|  1.70k|  int32_t chunk_cbytes;
 1622|  1.70k|  int rc;
 1623|  1.70k|  int64_t off_pos = header_len;
 1624|  1.70k|  if (!frame->sframe) {
  ------------------
  |  Branch (1624:7): [True: 1.70k, False: 0]
  ------------------
 1625|  1.70k|    if (cbytes < INT64_MAX - header_len) {
  ------------------
  |  Branch (1625:9): [True: 1.63k, False: 73]
  ------------------
 1626|  1.63k|      off_pos += cbytes;
 1627|  1.63k|    }
 1628|  1.70k|  }
 1629|       |
 1630|  1.70k|  if (off_pos < 0 || off_pos > INT64_MAX - BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (1630:7): [True: 67, False: 1.63k]
  |  Branch (1630:22): [True: 1, False: 1.63k]
  ------------------
 1631|  1.63k|      off_pos + BLOSC_EXTENDED_HEADER_LENGTH > frame->len) {
  ------------------
  |  Branch (1631:7): [True: 119, False: 1.51k]
  ------------------
 1632|    187|    BLOSC_TRACE_ERROR("Cannot read the offsets outside of frame boundary.");
  ------------------
  |  |   93|    187|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    187|    do {                                            \
  |  |  |  |   98|    187|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    187|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 187, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    187|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1633|    187|    return BLOSC2_ERROR_INVALID_HEADER;
 1634|    187|  }
 1635|       |
 1636|  1.51k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (1636:7): [True: 1.51k, False: 0]
  ------------------
 1637|  1.51k|    uint8_t *off_start = frame->cframe + off_pos;
 1638|  1.51k|    rc = blosc2_cbuffer_sizes(off_start, coffsets_nbytes, &chunk_cbytes, NULL);
 1639|  1.51k|    if (rc < 0) {
  ------------------
  |  Branch (1639:9): [True: 25, False: 1.49k]
  ------------------
 1640|     25|      return rc;
 1641|     25|    }
 1642|  1.49k|    if (chunk_cbytes < 0 || off_pos + chunk_cbytes > frame->len) {
  ------------------
  |  Branch (1642:9): [True: 0, False: 1.49k]
  |  Branch (1642:29): [True: 36, False: 1.45k]
  ------------------
 1643|     36|      BLOSC_TRACE_ERROR("Cannot read the cbytes outside of frame boundary.");
  ------------------
  |  |   93|     36|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     36|    do {                                            \
  |  |  |  |   98|     36|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     36|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 36, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     36|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1644|     36|      return BLOSC2_ERROR_INVALID_HEADER;
 1645|     36|    }
 1646|  1.45k|    return 0;
 1647|  1.49k|  }
 1648|       |
 1649|      0|  int64_t trailer_offset = get_trailer_offset(frame, header_len, true);
 1650|      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 (1650:7): [True: 0, False: 0]
  |  Branch (1650:56): [True: 0, False: 0]
  ------------------
 1651|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1652|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1653|      0|  }
 1654|       |
 1655|      0|  blosc2_io_cb *io_cb = blosc2_get_io_cb(io->id);
 1656|      0|  if (io_cb == NULL) {
  ------------------
  |  Branch (1656:7): [True: 0, False: 0]
  ------------------
 1657|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1658|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 1659|      0|  }
 1660|       |
 1661|      0|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1662|      0|  uint8_t *header_ptr = header;
 1663|      0|  void *fp = NULL;
 1664|      0|  int64_t io_pos = 0;
 1665|      0|  if (frame->sframe) {
  ------------------
  |  Branch (1665:7): [True: 0, False: 0]
  ------------------
 1666|      0|    fp = sframe_open_index(frame->urlpath, "rb", io);
 1667|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1667:9): [True: 0, False: 0]
  ------------------
 1668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1669|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1670|      0|    }
 1671|      0|    io_pos = off_pos;
 1672|      0|  }
 1673|      0|  else {
 1674|      0|    fp = frame_reader_acquire(frame, io);
 1675|      0|    if (fp == NULL) {
  ------------------
  |  Branch (1675:9): [True: 0, False: 0]
  ------------------
 1676|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|      0|      return BLOSC2_ERROR_FILE_OPEN;
 1678|      0|    }
 1679|      0|    io_pos = frame->file_offset + off_pos;
 1680|      0|  }
 1681|      0|  int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, fp);
 1682|      0|  frame_reader_release(frame, io_cb, fp);
 1683|      0|  if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (1683:7): [True: 0, False: 0]
  ------------------
 1684|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1685|      0|    return BLOSC2_ERROR_FILE_READ;
 1686|      0|  }
 1687|       |
 1688|      0|  rc = blosc2_cbuffer_sizes(header_ptr, coffsets_nbytes, &chunk_cbytes, NULL);
 1689|      0|  if (rc < 0) {
  ------------------
  |  Branch (1689:7): [True: 0, False: 0]
  ------------------
 1690|      0|    return rc;
 1691|      0|  }
 1692|       |
 1693|      0|  if (chunk_cbytes < 0 || off_pos + chunk_cbytes > trailer_offset) {
  ------------------
  |  Branch (1693:7): [True: 0, False: 0]
  |  Branch (1693:27): [True: 0, False: 0]
  ------------------
 1694|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1695|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 1696|      0|  }
 1697|       |
 1698|      0|  return 0;
 1699|      0|}
frame.c:get_meta_from_header:
 2763|  2.71k|                                int32_t header_len) {
 2764|  2.71k|  BLOSC_UNUSED_PARAM(frame);
  ------------------
  |  |   28|  2.71k|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
 2765|  2.71k|  int64_t header_pos = FRAME_IDX_SIZE;
  ------------------
  |  |   51|  2.71k|#define FRAME_IDX_SIZE (FRAME_METALAYERS + 1 + 1)  // 89
  |  |  ------------------
  |  |  |  |   50|  2.71k|#define FRAME_METALAYERS (FRAME_HEADER_MINLEN)  // 87
  |  |  |  |  ------------------
  |  |  |  |  |  |   49|  2.71k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|  2.71k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  2.71k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   42|  2.71k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   41|  2.71k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   40|  2.71k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  2.71k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  2.71k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.71k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  2.71k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  2.71k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  2.71k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  2.71k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  2.71k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2766|       |
 2767|       |  // Get the size for the index of metalayers
 2768|  2.71k|  uint16_t idx_size;
 2769|  2.71k|  header_pos += sizeof(idx_size);
 2770|  2.71k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2770:7): [True: 1, False: 2.71k]
  ------------------
 2771|      1|    return BLOSC2_ERROR_READ_BUFFER;
 2772|      1|  }
 2773|  2.71k|  from_big(&idx_size, header + FRAME_IDX_SIZE, sizeof(idx_size));
  ------------------
  |  |   38|  2.71k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2774|       |
 2775|       |  // Get the actual index of metalayers
 2776|  2.71k|  uint8_t* metalayers_idx = header + FRAME_IDX_SIZE + 2;
  ------------------
  |  |   51|  2.71k|#define FRAME_IDX_SIZE (FRAME_METALAYERS + 1 + 1)  // 89
  |  |  ------------------
  |  |  |  |   50|  2.71k|#define FRAME_METALAYERS (FRAME_HEADER_MINLEN)  // 87
  |  |  |  |  ------------------
  |  |  |  |  |  |   49|  2.71k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|  2.71k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   43|  2.71k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   42|  2.71k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   41|  2.71k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   40|  2.71k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  2.71k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  2.71k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  2.71k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  2.71k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  2.71k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  2.71k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  2.71k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  2.71k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2777|  2.71k|  header_pos += 1;
 2778|  2.71k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2778:7): [True: 1, False: 2.71k]
  ------------------
 2779|      1|    return BLOSC2_ERROR_READ_BUFFER;
 2780|      1|  }
 2781|  2.71k|  if (metalayers_idx[0] != 0xde) {   // sanity check
  ------------------
  |  Branch (2781:7): [True: 40, False: 2.67k]
  ------------------
 2782|     40|    return BLOSC2_ERROR_DATA;
 2783|     40|  }
 2784|  2.67k|  uint8_t* idxp = metalayers_idx + 1;
 2785|  2.67k|  uint16_t nmetalayers;
 2786|  2.67k|  header_pos += sizeof(nmetalayers);
 2787|  2.67k|  if (header_len < header_pos) {
  ------------------
  |  Branch (2787:7): [True: 1, False: 2.67k]
  ------------------
 2788|      1|    return BLOSC2_ERROR_READ_BUFFER;
 2789|      1|  }
 2790|  2.67k|  from_big(&nmetalayers, idxp, sizeof(uint16_t));
  ------------------
  |  |   38|  2.67k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2791|  2.67k|  idxp += 2;
 2792|  2.67k|  if (nmetalayers > BLOSC2_MAX_METALAYERS) {
  ------------------
  |  | 1895|  2.67k|#define BLOSC2_MAX_METALAYERS 16
  ------------------
  |  Branch (2792:7): [True: 1, False: 2.67k]
  ------------------
 2793|      1|    return BLOSC2_ERROR_DATA;
 2794|      1|  }
 2795|  2.67k|  schunk->nmetalayers = nmetalayers;
 2796|       |
 2797|       |  // Populate the metalayers and its serialized values
 2798|  5.22k|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2798:28): [True: 2.58k, False: 2.63k]
  ------------------
 2799|  2.58k|    header_pos += 1;
 2800|  2.58k|    if (header_len < header_pos) {
  ------------------
  |  Branch (2800:9): [True: 1, False: 2.58k]
  ------------------
 2801|      1|      return BLOSC2_ERROR_READ_BUFFER;
 2802|      1|    }
 2803|  2.58k|    if ((*idxp & 0xe0u) != 0xa0u) {   // sanity check
  ------------------
  |  Branch (2803:9): [True: 7, False: 2.58k]
  ------------------
 2804|      7|      return BLOSC2_ERROR_DATA;
 2805|      7|    }
 2806|  2.58k|    blosc2_metalayer* metalayer = calloc(1, sizeof(blosc2_metalayer));
 2807|  2.58k|    if (metalayer == NULL) {
  ------------------
  |  Branch (2807:9): [True: 0, False: 2.58k]
  ------------------
 2808|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2809|      0|    }
 2810|  2.58k|    schunk->metalayers[nmetalayer] = metalayer;
 2811|       |
 2812|       |    // Populate the metalayer string
 2813|  2.58k|    uint8_t nslen = *idxp & (uint8_t)0x1F;
 2814|  2.58k|    idxp += 1;
 2815|  2.58k|    header_pos += nslen;
 2816|  2.58k|    if (header_len < header_pos) {
  ------------------
  |  Branch (2816:9): [True: 1, False: 2.58k]
  ------------------
 2817|      1|      return BLOSC2_ERROR_READ_BUFFER;
 2818|      1|    }
 2819|  2.58k|    char* ns = malloc((size_t)nslen + 1);
 2820|  2.58k|    if (ns == NULL) {
  ------------------
  |  Branch (2820:9): [True: 0, False: 2.58k]
  ------------------
 2821|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2822|      0|    }
 2823|  2.58k|    memcpy(ns, idxp, nslen);
 2824|  2.58k|    ns[nslen] = '\0';
 2825|  2.58k|    idxp += nslen;
 2826|  2.58k|    metalayer->name = ns;
 2827|       |
 2828|       |    // Populate the serialized value for this metalayer
 2829|       |    // Get the offset
 2830|  2.58k|    header_pos += 1;
 2831|  2.58k|    if (header_len < header_pos) {
  ------------------
  |  Branch (2831:9): [True: 1, False: 2.57k]
  ------------------
 2832|      1|      return BLOSC2_ERROR_READ_BUFFER;
 2833|      1|    }
 2834|  2.57k|    if ((*idxp & 0xffu) != 0xd2u) {   // sanity check
  ------------------
  |  Branch (2834:9): [True: 7, False: 2.57k]
  ------------------
 2835|      7|      return BLOSC2_ERROR_DATA;
 2836|      7|    }
 2837|  2.57k|    idxp += 1;
 2838|  2.57k|    int32_t offset;
 2839|  2.57k|    header_pos += sizeof(offset);
 2840|  2.57k|    if (header_len < header_pos) {
  ------------------
  |  Branch (2840:9): [True: 1, False: 2.57k]
  ------------------
 2841|      1|      return BLOSC2_ERROR_READ_BUFFER;
 2842|      1|    }
 2843|  2.57k|    from_big(&offset, idxp, sizeof(offset));
  ------------------
  |  |   38|  2.57k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2844|  2.57k|    idxp += 4;
 2845|  2.57k|    if (offset < 0 || offset >= header_len) {
  ------------------
  |  Branch (2845:9): [True: 5, False: 2.56k]
  |  Branch (2845:23): [True: 3, False: 2.56k]
  ------------------
 2846|       |      // Offset is less than zero or exceeds header length
 2847|      8|      return BLOSC2_ERROR_DATA;
 2848|      8|    }
 2849|       |    // Go to offset and see if we have the correct marker
 2850|  2.56k|    uint8_t* content_marker = header + offset;
 2851|  2.56k|    if ((int64_t)header_len < (int64_t)offset + 1 + 4) {
  ------------------
  |  Branch (2851:9): [True: 1, False: 2.56k]
  ------------------
 2852|      1|      return BLOSC2_ERROR_READ_BUFFER;
 2853|      1|    }
 2854|  2.56k|    if (*content_marker != 0xc6) {
  ------------------
  |  Branch (2854:9): [True: 3, False: 2.55k]
  ------------------
 2855|      3|      return BLOSC2_ERROR_DATA;
 2856|      3|    }
 2857|       |
 2858|       |    // Read the size of the content
 2859|  2.55k|    int32_t content_len;
 2860|  2.55k|    from_big(&content_len, content_marker + 1, sizeof(content_len));
  ------------------
  |  |   38|  2.55k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2861|  2.55k|    if (content_len < 0) {
  ------------------
  |  Branch (2861:9): [True: 1, False: 2.55k]
  ------------------
 2862|      1|      return BLOSC2_ERROR_DATA;
 2863|      1|    }
 2864|  2.55k|    metalayer->content_len = content_len;
 2865|       |
 2866|       |    // Finally, read the content. Use 64-bit arithmetic so a malicious
 2867|       |    // (offset, content_len) pair near INT32_MAX cannot wrap and bypass the
 2868|       |    // bounds check, which would let memcpy below read past the header buffer.
 2869|  2.55k|    if ((int64_t)header_len < (int64_t)offset + 1 + 4 + (int64_t)content_len) {
  ------------------
  |  Branch (2869:9): [True: 5, False: 2.55k]
  ------------------
 2870|      5|      return BLOSC2_ERROR_READ_BUFFER;
 2871|      5|    }
 2872|  2.55k|    char* content = malloc((size_t)content_len);
 2873|       |    // malloc(0) is allowed to return NULL, and blosc2_meta_add accepts
 2874|       |    // content_len == 0, so only treat NULL as an allocation failure when
 2875|       |    // a non-zero allocation was requested.
 2876|  2.55k|    if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (2876:9): [True: 2.54k, False: 5]
  |  Branch (2876:28): [True: 0, False: 2.54k]
  ------------------
 2877|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 2878|      0|    }
 2879|  2.55k|    if (content_len > 0) {
  ------------------
  |  Branch (2879:9): [True: 2.54k, False: 5]
  ------------------
 2880|  2.54k|      memcpy(content, content_marker + 1 + 4, (size_t)content_len);
 2881|  2.54k|    }
 2882|  2.55k|    metalayer->content = (uint8_t*)content;
 2883|  2.55k|  }
 2884|       |
 2885|  2.63k|  return 1;
 2886|  2.67k|}
frame.c:get_vlmeta_from_trailer:
 2966|  2.63k|                                   int32_t trailer_len) {
 2967|       |
 2968|  2.63k|  BLOSC_UNUSED_PARAM(frame);
  ------------------
  |  |   28|  2.63k|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
 2969|  2.63k|  int64_t trailer_pos = FRAME_TRAILER_VLMETALAYERS + 2;
  ------------------
  |  |   60|  2.63k|#define FRAME_TRAILER_VLMETALAYERS (2)
  ------------------
 2970|  2.63k|  uint8_t* idxp = trailer + trailer_pos;
 2971|       |
 2972|       |  // Get the size for the index of metalayers
 2973|  2.63k|  trailer_pos += 2;
 2974|  2.63k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (2974:7): [True: 0, False: 2.63k]
  ------------------
 2975|      0|    return BLOSC2_ERROR_READ_BUFFER;
 2976|      0|  }
 2977|  2.63k|  uint16_t idx_size;
 2978|  2.63k|  from_big(&idx_size, idxp, sizeof(idx_size));
  ------------------
  |  |   38|  2.63k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 2979|  2.63k|  idxp += 2;
 2980|       |
 2981|  2.63k|  trailer_pos += 1;
 2982|       |  // Get the actual index of metalayers
 2983|  2.63k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (2983:7): [True: 0, False: 2.63k]
  ------------------
 2984|      0|    return BLOSC2_ERROR_READ_BUFFER;
 2985|      0|  }
 2986|  2.63k|  if (idxp[0] != 0xde) {   // sanity check
  ------------------
  |  Branch (2986:7): [True: 9, False: 2.62k]
  ------------------
 2987|      9|    return BLOSC2_ERROR_DATA;
 2988|      9|  }
 2989|  2.62k|  idxp += 1;
 2990|       |
 2991|       |  // The on-wire encoding is unsigned (uint16 follows the msgpack `0xde`
 2992|       |  // map16 marker), but `schunk->nvlmetalayers` is int16_t. Decoding into a
 2993|       |  // signed local would let raw bytes like 0xff 0xff slip past the
 2994|       |  // `> BLOSC2_MAX_VLMETALAYERS` ceiling as a negative count, after which
 2995|       |  // a later `blosc2_vlmeta_add` would write through `vlmetalayers[-1]`
 2996|       |  // and corrupt adjacent schunk fields. Decode unsigned, then narrow.
 2997|  2.62k|  uint16_t nmetalayers;
 2998|  2.62k|  trailer_pos += sizeof(nmetalayers);
 2999|  2.62k|  if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (2999:7): [True: 0, False: 2.62k]
  ------------------
 3000|      0|    return BLOSC2_ERROR_READ_BUFFER;
 3001|      0|  }
 3002|  2.62k|  from_big(&nmetalayers, idxp, sizeof(uint16_t));
  ------------------
  |  |   38|  2.62k|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3003|  2.62k|  idxp += 2;
 3004|  2.62k|  if (nmetalayers > BLOSC2_MAX_VLMETALAYERS) {
  ------------------
  |  | 1901|  2.62k|#define BLOSC2_MAX_VLMETALAYERS (8 * 1024)
  ------------------
  |  Branch (3004:7): [True: 2, False: 2.62k]
  ------------------
 3005|      2|    return BLOSC2_ERROR_DATA;
 3006|      2|  }
 3007|  2.62k|  schunk->nvlmetalayers = (int16_t)nmetalayers;
 3008|       |
 3009|       |  // Populate the metalayers and its serialized values
 3010|  2.64k|  for (int nmetalayer = 0; nmetalayer < nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (3010:28): [True: 97, False: 2.54k]
  ------------------
 3011|     97|    trailer_pos += 1;
 3012|     97|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3012:9): [True: 1, False: 96]
  ------------------
 3013|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3014|      1|    }
 3015|     96|    if ((*idxp & 0xe0u) != 0xa0u) {   // sanity check
  ------------------
  |  Branch (3015:9): [True: 22, False: 74]
  ------------------
 3016|     22|      return BLOSC2_ERROR_DATA;
 3017|     22|    }
 3018|     74|    blosc2_metalayer* metalayer = calloc(1, sizeof(blosc2_metalayer));
 3019|     74|    if (metalayer == NULL) {
  ------------------
  |  Branch (3019:9): [True: 0, False: 74]
  ------------------
 3020|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3021|      0|    }
 3022|     74|    schunk->vlmetalayers[nmetalayer] = metalayer;
 3023|       |
 3024|       |    // Populate the metalayer string
 3025|     74|    uint8_t nslen = *idxp & (uint8_t)0x1F;
 3026|     74|    idxp += 1;
 3027|     74|    trailer_pos += nslen;
 3028|     74|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3028:9): [True: 1, False: 73]
  ------------------
 3029|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3030|      1|    }
 3031|     73|    char* ns = malloc((size_t)nslen + 1);
 3032|     73|    if (ns == NULL) {
  ------------------
  |  Branch (3032:9): [True: 0, False: 73]
  ------------------
 3033|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3034|      0|    }
 3035|     73|    memcpy(ns, idxp, nslen);
 3036|     73|    ns[nslen] = '\0';
 3037|     73|    idxp += nslen;
 3038|     73|    metalayer->name = ns;
 3039|       |
 3040|       |    // Populate the serialized value for this metalayer
 3041|       |    // Get the offset
 3042|     73|    trailer_pos += 1;
 3043|     73|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3043:9): [True: 1, False: 72]
  ------------------
 3044|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3045|      1|    }
 3046|     72|    if ((*idxp & 0xffu) != 0xd2u) {   // sanity check
  ------------------
  |  Branch (3046:9): [True: 10, False: 62]
  ------------------
 3047|     10|      return BLOSC2_ERROR_DATA;
 3048|     10|    }
 3049|     62|    idxp += 1;
 3050|     62|    int32_t offset;
 3051|     62|    trailer_pos += sizeof(offset);
 3052|     62|    if (trailer_len < trailer_pos) {
  ------------------
  |  Branch (3052:9): [True: 1, False: 61]
  ------------------
 3053|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3054|      1|    }
 3055|     61|    from_big(&offset, idxp, sizeof(offset));
  ------------------
  |  |   38|     61|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3056|     61|    idxp += 4;
 3057|     61|    if (offset < 0 || offset >= trailer_len) {
  ------------------
  |  Branch (3057:9): [True: 3, False: 58]
  |  Branch (3057:23): [True: 20, False: 38]
  ------------------
 3058|       |      // Offset is less than zero or exceeds trailer length
 3059|     23|      return BLOSC2_ERROR_DATA;
 3060|     23|    }
 3061|       |    // Go to offset and see if we have the correct marker
 3062|     38|    uint8_t* content_marker = trailer + offset;
 3063|     38|    if ((int64_t)trailer_len < (int64_t)offset + 1 + 4) {
  ------------------
  |  Branch (3063:9): [True: 1, False: 37]
  ------------------
 3064|      1|      return BLOSC2_ERROR_READ_BUFFER;
 3065|      1|    }
 3066|     37|    if (*content_marker != 0xc6) {
  ------------------
  |  Branch (3066:9): [True: 4, False: 33]
  ------------------
 3067|      4|      return BLOSC2_ERROR_DATA;
 3068|      4|    }
 3069|       |
 3070|       |    // Read the size of the content
 3071|     33|    int32_t content_len;
 3072|     33|    from_big(&content_len, content_marker + 1, sizeof(content_len));
  ------------------
  |  |   38|     33|#define from_big(dest, src, itemsize)     endian_handler(false, dest, src, itemsize)
  ------------------
 3073|     33|    if (content_len < 0) {
  ------------------
  |  Branch (3073:9): [True: 3, False: 30]
  ------------------
 3074|      3|      return BLOSC2_ERROR_DATA;
 3075|      3|    }
 3076|     30|    metalayer->content_len = content_len;
 3077|       |
 3078|       |    // Finally, read the content. Use 64-bit arithmetic so a malicious
 3079|       |    // (offset, content_len) pair near INT32_MAX cannot wrap and bypass the
 3080|       |    // bounds check, which would let memcpy below read past the trailer buffer.
 3081|     30|    if ((int64_t)trailer_len < (int64_t)offset + 1 + 4 + (int64_t)content_len) {
  ------------------
  |  Branch (3081:9): [True: 6, False: 24]
  ------------------
 3082|      6|      return BLOSC2_ERROR_READ_BUFFER;
 3083|      6|    }
 3084|     24|    char* content = malloc((size_t)content_len);
 3085|       |    // Same zero-length carve-out as in get_meta_from_header: malloc(0) may
 3086|       |    // return NULL on some platforms, and the public API allows
 3087|       |    // content_len == 0, so don't reject a valid empty vlmetalayer.
 3088|     24|    if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (3088:9): [True: 8, False: 16]
  |  Branch (3088:28): [True: 0, False: 8]
  ------------------
 3089|      0|      return BLOSC2_ERROR_MEMORY_ALLOC;
 3090|      0|    }
 3091|     24|    if (content_len > 0) {
  ------------------
  |  Branch (3091:9): [True: 8, False: 16]
  ------------------
 3092|      8|      memcpy(content, content_marker + 1 + 4, (size_t)content_len);
 3093|      8|    }
 3094|     24|    metalayer->content = (uint8_t*)content;
 3095|     24|  }
 3096|  2.54k|  return 1;
 3097|  2.62k|}
frame.c:validate_offsets_chunk:
 3255|  3.82k|                                  int64_t nchunks) {
 3256|  3.82k|  int32_t coffsets_cbytes = 0;
 3257|  3.82k|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 3258|  3.82k|  if (coffsets == NULL) {
  ------------------
  |  Branch (3258:7): [True: 186, False: 3.64k]
  ------------------
 3259|    186|    BLOSC_TRACE_ERROR("Cannot get compressed offsets from frame.");
  ------------------
  |  |   93|    186|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    186|    do {                                            \
  |  |  |  |   98|    186|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    186|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 186, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    186|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3260|    186|    return BLOSC2_ERROR_DATA;
 3261|    186|  }
 3262|       |
 3263|  3.64k|  int32_t offsets_nbytes;
 3264|  3.64k|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &offsets_nbytes)) {
  ------------------
  |  Branch (3264:7): [True: 0, False: 3.64k]
  ------------------
 3265|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3266|      0|    return BLOSC2_ERROR_FAILURE;
 3267|      0|  }
 3268|       |
 3269|  3.64k|  int64_t* offsets = (int64_t*)malloc((size_t)offsets_nbytes);
 3270|  3.64k|  if (offsets == NULL) {
  ------------------
  |  Branch (3270:7): [True: 0, False: 3.64k]
  ------------------
 3271|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3272|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 3273|      0|  }
 3274|       |
 3275|  3.64k|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 3276|  3.64k|  blosc2_context* dctx = blosc2_create_dctx(off_dparams);
 3277|  3.64k|  if (dctx == NULL) {
  ------------------
  |  Branch (3277:7): [True: 0, False: 3.64k]
  ------------------
 3278|      0|    free(offsets);
 3279|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3280|      0|    return BLOSC2_ERROR_FAILURE;
 3281|      0|  }
 3282|       |
 3283|  3.64k|  int32_t off_nbytes = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes,
 3284|  3.64k|                                             offsets, offsets_nbytes);
 3285|  3.64k|  blosc2_free_ctx(dctx);
 3286|  3.64k|  if (off_nbytes != offsets_nbytes) {
  ------------------
  |  Branch (3286:7): [True: 905, False: 2.73k]
  ------------------
 3287|    905|    free(offsets);
 3288|    905|    BLOSC_TRACE_ERROR("Cannot decompress offsets chunk.");
  ------------------
  |  |   93|    905|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    905|    do {                                            \
  |  |  |  |   98|    905|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    905|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 905, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    905|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3289|    905|    return BLOSC2_ERROR_DATA;
 3290|    905|  }
 3291|       |
 3292|  11.6M|  for (int64_t i = 0; i < nchunks; ++i) {
  ------------------
  |  Branch (3292:23): [True: 11.6M, False: 2.34k]
  ------------------
 3293|  11.6M|    int64_t offset = offsets[i];
 3294|  11.6M|    if (offset < 0) {
  ------------------
  |  Branch (3294:9): [True: 10.8M, False: 757k]
  ------------------
 3295|  10.8M|      continue;
 3296|  10.8M|    }
 3297|   757k|    if (offset > INT64_MAX - header_len || offset > cbytes - BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (3297:9): [True: 1, False: 757k]
  |  Branch (3297:44): [True: 394, False: 757k]
  ------------------
 3298|    395|      free(offsets);
 3299|    395|      BLOSC_TRACE_ERROR("Offset for chunk %" PRId64 " is out of bounds.", i);
  ------------------
  |  |   93|    395|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    395|    do {                                            \
  |  |  |  |   98|    395|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    395|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 395, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    395|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3300|    395|      return BLOSC2_ERROR_INVALID_HEADER;
 3301|    395|    }
 3302|       |    /* Offsets do not need to be monotonic.  Frame mutations like insert can append
 3303|       |     * chunk payloads at the end of the cframe while updating the logical chunk order
 3304|       |     * only in the offsets table, so a valid frame may legitimately contain
 3305|       |     * non-monotonic non-negative offsets.
 3306|       |     */
 3307|   757k|  }
 3308|       |
 3309|  2.34k|  free(offsets);
 3310|  2.34k|  return 0;
 3311|  2.73k|}
frame.c:frame_read_index_span:
 3711|  62.4k|                                 int64_t *cbytes, int32_t *chunksize) {
 3712|  62.4k|  *off = NULL;
 3713|  62.4k|  int64_t frame_len;
 3714|  62.4k|  int64_t frame_nbytes;
 3715|  62.4k|  int32_t blocksize;
 3716|  62.4k|  int64_t frame_nchunks;
 3717|  62.4k|  int rc = get_header_info(frame, header_len, &frame_len, &frame_nbytes, cbytes, &blocksize, chunksize,
 3718|  62.4k|                           &frame_nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3719|  62.4k|                           frame->schunk->storage->io);
 3720|  62.4k|  if (rc < 0) {
  ------------------
  |  Branch (3720:7): [True: 0, False: 62.4k]
  ------------------
 3721|      0|    return rc;
 3722|      0|  }
 3723|       |  // A different handle may have changed the index, including a same-length
 3724|       |  // reorder flagged by frame_lock().  Refresh before reusing cached offsets.
 3725|  62.4k|  rc = frame_refresh_if_stale(frame, frame_len);
 3726|  62.4k|  if (rc < 0) {
  ------------------
  |  Branch (3726:7): [True: 0, False: 62.4k]
  ------------------
 3727|      0|    return rc;
 3728|      0|  }
 3729|  62.4k|  if (rc > 0) {
  ------------------
  |  Branch (3729:7): [True: 0, False: 62.4k]
  ------------------
 3730|      0|    frame->schunk->nbytes = frame_nbytes;
 3731|      0|    frame->schunk->cbytes = *cbytes;
 3732|      0|    frame->schunk->nchunks = frame_nchunks;
 3733|      0|  }
 3734|  62.4k|  int64_t hi = -1;
 3735|  62.4k|  *lo = INT64_MAX;
 3736|   893k|  for (int64_t k = 0; k < n; ++k) {
  ------------------
  |  Branch (3736:23): [True: 868k, False: 24.6k]
  ------------------
 3737|   868k|    if (nchunks[k] < 0 || nchunks[k] >= frame_nchunks) {
  ------------------
  |  Branch (3737:9): [True: 0, False: 868k]
  |  Branch (3737:27): [True: 37.8k, False: 830k]
  ------------------
 3738|  37.8k|      BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks ('%" PRId64 "').",
  ------------------
  |  |   93|  37.8k|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|  37.8k|    do {                                            \
  |  |  |  |   98|  37.8k|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|  37.8k|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 37.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|  37.8k|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3739|  37.8k|                        nchunks[k], frame_nchunks);
 3740|  37.8k|      return BLOSC2_ERROR_INVALID_PARAM;
 3741|  37.8k|    }
 3742|   830k|    *lo = nchunks[k] < *lo ? nchunks[k] : *lo;
  ------------------
  |  Branch (3742:11): [True: 25.3k, False: 805k]
  ------------------
 3743|   830k|    hi = nchunks[k] > hi ? nchunks[k] : hi;
  ------------------
  |  Branch (3743:10): [True: 817k, False: 12.9k]
  ------------------
 3744|   830k|  }
 3745|  24.6k|  if (n <= 0) {
  ------------------
  |  Branch (3745:7): [True: 0, False: 24.6k]
  ------------------
 3746|      0|    return BLOSC2_ERROR_SUCCESS;
 3747|      0|  }
 3748|  24.6k|  int32_t off_cbytes;
 3749|  24.6k|  uint8_t *coffsets = get_coffsets(frame, *header_len, *cbytes, frame_nchunks, &off_cbytes);
 3750|  24.6k|  if (coffsets == NULL) {
  ------------------
  |  Branch (3750:7): [True: 0, False: 24.6k]
  ------------------
 3751|      0|    return BLOSC2_ERROR_DATA;
 3752|      0|  }
 3753|  24.6k|  *span_end = hi + 1 + lookahead < frame_nchunks ? hi + 1 + lookahead : frame_nchunks;
  ------------------
  |  Branch (3753:15): [True: 20.1k, False: 4.43k]
  ------------------
 3754|  24.6k|  *off = malloc((size_t) (*span_end - *lo) * sizeof(int64_t));
 3755|  24.6k|  if (*off == NULL) {
  ------------------
  |  Branch (3755:7): [True: 0, False: 24.6k]
  ------------------
 3756|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 3757|      0|  }
 3758|  24.6k|  rc = blosc2_getitem(coffsets, off_cbytes, (int32_t) *lo, (int32_t) (*span_end - *lo), *off,
 3759|  24.6k|                      (int32_t) ((*span_end - *lo) * sizeof(int64_t)));
 3760|  24.6k|  if (rc < 0) {
  ------------------
  |  Branch (3760:7): [True: 0, False: 24.6k]
  ------------------
 3761|      0|    free(*off);
 3762|      0|    *off = NULL;
 3763|      0|    return rc;
 3764|      0|  }
 3765|  24.6k|  return BLOSC2_ERROR_SUCCESS;
 3766|  24.6k|}
frame.c:special_chunk_into:
 3842|  1.12M|                              uint8_t* dest, int32_t cbytes) {
 3843|  1.12M|  int rc = 0;
 3844|       |
 3845|       |  // Detect the kind of special value
 3846|  1.12M|  uint64_t zeros_mask = (uint64_t) BLOSC2_SPECIAL_ZERO << (8 * 7);  // chunk of zeros
 3847|  1.12M|  uint64_t nans_mask = (uint64_t) BLOSC2_SPECIAL_NAN << (8 * 7);  // chunk of NaNs
 3848|  1.12M|  uint64_t uninit_mask = (uint64_t) BLOSC2_SPECIAL_UNINIT << (8 * 7);  // chunk of uninit values
 3849|       |
 3850|  1.12M|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
 3851|  1.12M|  cparams.typesize = typesize;
 3852|  1.12M|  cparams.blocksize = blocksize;
 3853|  1.12M|  if (special_value & zeros_mask) {
  ------------------
  |  Branch (3853:7): [True: 1.12M, False: 0]
  ------------------
 3854|  1.12M|    rc = blosc2_chunk_zeros(cparams, nbytes, dest, cbytes);
 3855|  1.12M|    if (rc < 0) {
  ------------------
  |  Branch (3855:9): [True: 0, False: 1.12M]
  ------------------
 3856|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3857|      0|    }
 3858|  1.12M|  }
 3859|      0|  else if (special_value & uninit_mask) {
  ------------------
  |  Branch (3859:12): [True: 0, False: 0]
  ------------------
 3860|      0|    rc = blosc2_chunk_uninit(cparams, nbytes, dest, cbytes);
 3861|      0|    if (rc < 0) {
  ------------------
  |  Branch (3861:9): [True: 0, False: 0]
  ------------------
 3862|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3863|      0|    }
 3864|      0|  }
 3865|      0|  else if (special_value & nans_mask) {
  ------------------
  |  Branch (3865:12): [True: 0, False: 0]
  ------------------
 3866|      0|    rc = blosc2_chunk_nans(cparams, nbytes, dest, cbytes);
 3867|      0|    if (rc < 0) {
  ------------------
  |  Branch (3867:9): [True: 0, False: 0]
  ------------------
 3868|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3869|      0|    }
 3870|      0|  }
 3871|      0|  else {
 3872|       |    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3873|      0|    rc = BLOSC2_ERROR_DATA;
 3874|      0|  }
 3875|  1.12M|  return rc;
 3876|  1.12M|}
frame.c:get_chunk:
 3910|   634k|                     size_t *capacity) {
 3911|   634k|  if (capacity != NULL) {
  ------------------
  |  Branch (3911:7): [True: 634k, False: 0]
  ------------------
 3912|   634k|    *capacity = 0;
 3913|   634k|  }
 3914|   634k|  int32_t header_len;
 3915|   634k|  int64_t frame_len;
 3916|   634k|  int64_t nbytes;
 3917|   634k|  int64_t cbytes;
 3918|   634k|  int32_t blocksize;
 3919|   634k|  int32_t chunksize;
 3920|   634k|  int64_t nchunks;
 3921|   634k|  int32_t typesize;
 3922|   634k|  int64_t offset;
 3923|   634k|  int32_t chunk_cbytes;
 3924|   634k|  int rc;
 3925|       |
 3926|   634k|  *chunk = NULL;
 3927|   634k|  *needs_free = false;
 3928|   634k|  rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes,
 3929|   634k|                       &blocksize, &chunksize, &nchunks,
 3930|   634k|                       &typesize, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 3931|   634k|                       frame->schunk->storage->io);
 3932|   634k|  if (rc < 0) {
  ------------------
  |  Branch (3932:7): [True: 0, False: 634k]
  ------------------
 3933|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3934|      0|    return rc;
 3935|      0|  }
 3936|   634k|  rc = frame_refresh_if_stale(frame, frame_len);
 3937|   634k|  if (rc < 0) {
  ------------------
  |  Branch (3937:7): [True: 0, False: 634k]
  ------------------
 3938|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3939|      0|    return rc;
 3940|      0|  }
 3941|   634k|  if (rc > 0) {
  ------------------
  |  Branch (3941:7): [True: 0, False: 634k]
  ------------------
 3942|       |    // Keep the schunk-level counters in sync with the refreshed on-disk state.
 3943|       |    // Mutating ops (update/delete) read a chunk before adjusting the counters,
 3944|       |    // so this also gives them a fresh base to apply their deltas on.
 3945|      0|    frame->schunk->nbytes = nbytes;
 3946|      0|    frame->schunk->cbytes = cbytes;
 3947|      0|    frame->schunk->nchunks = nchunks;
 3948|      0|  }
 3949|       |
 3950|   634k|  if ((nchunks > 0) && (nchunk >= nchunks)) {
  ------------------
  |  Branch (3950:7): [True: 634k, False: 0]
  |  Branch (3950:24): [True: 0, False: 634k]
  ------------------
 3951|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3952|      0|                    "('%" PRId64 "') in frame.", nchunk, nchunks);
 3953|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 3954|      0|  }
 3955|       |
 3956|       |  // Get the offset to nchunk
 3957|   634k|  rc = get_coffset(frame, header_len, cbytes, nchunk, nchunks, &offset);
 3958|   634k|  if (rc < 0) {
  ------------------
  |  Branch (3958:7): [True: 0, False: 634k]
  ------------------
 3959|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3960|      0|    return rc;
 3961|      0|  }
 3962|       |
 3963|   634k|  if (offset < 0) {
  ------------------
  |  Branch (3963:7): [True: 15.2k, False: 619k]
  ------------------
 3964|       |    // Special value
 3965|  15.2k|    if (chunksize <= 0) {
  ------------------
  |  Branch (3965:9): [True: 0, False: 15.2k]
  ------------------
 3966|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3967|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 3968|      0|    }
 3969|  15.2k|    chunk_cbytes = BLOSC_EXTENDED_HEADER_LENGTH;
 3970|  15.2k|    int32_t chunksize_ = chunksize;
 3971|  15.2k|    if ((nchunk == nchunks - 1) && (nbytes % chunksize)) {
  ------------------
  |  Branch (3971:9): [True: 876, False: 14.3k]
  |  Branch (3971:36): [True: 0, False: 876]
  ------------------
 3972|       |      // Last chunk is incomplete.  Compute its actual size.
 3973|      0|      chunksize_ = (int32_t) (nbytes % chunksize);
 3974|      0|    }
 3975|  15.2k|    rc = frame_special_chunk(offset, chunksize_, typesize, blocksize, chunk, chunk_cbytes, needs_free);
 3976|  15.2k|    if (rc < 0) {
  ------------------
  |  Branch (3976:9): [True: 0, False: 15.2k]
  ------------------
 3977|      0|      return rc;
 3978|      0|    }
 3979|  15.2k|    goto end;
 3980|  15.2k|  }
 3981|       |
 3982|   619k|  if (frame->sframe) {
  ------------------
  |  Branch (3982:7): [True: 0, False: 619k]
  ------------------
 3983|       |    // Sparse on-disk
 3984|      0|    nchunk = offset;
 3985|      0|    return sframe_get_chunk(frame, nchunk, chunk, needs_free);
 3986|      0|  }
 3987|       |
 3988|   619k|  blosc2_io_cb *io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 3989|   619k|  if (io_cb == NULL) {
  ------------------
  |  Branch (3989:7): [True: 0, False: 619k]
  ------------------
 3990|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3991|      0|    return BLOSC2_ERROR_PLUGIN_IO;
 3992|      0|  }
 3993|       |
 3994|   619k|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (3994:7): [True: 0, False: 619k]
  ------------------
 3995|      0|    uint8_t* header_ptr;
 3996|      0|    uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 3997|      0|    void* fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 3998|      0|    if (fp == NULL) {
  ------------------
  |  Branch (3998:9): [True: 0, False: 0]
  ------------------
 3999|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4000|      0|      return BLOSC2_ERROR_FILE_OPEN;
 4001|      0|    }
 4002|      0|    if (io_cb->is_allocation_necessary)
  ------------------
  |  Branch (4002:9): [True: 0, False: 0]
  ------------------
 4003|      0|      header_ptr = header;
 4004|      0|    int64_t io_pos = frame->file_offset + header_len + offset;
 4005|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, sizeof(header), io_pos, fp);
 4006|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4006:9): [True: 0, False: 0]
  ------------------
 4007|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4008|      0|      frame_reader_release(frame, io_cb, fp);
 4009|      0|      return BLOSC2_ERROR_FILE_READ;
 4010|      0|    }
 4011|      0|    rc = blosc2_cbuffer_sizes(header_ptr, NULL, &chunk_cbytes, NULL);
 4012|      0|    if (rc < 0) {
  ------------------
  |  Branch (4012:9): [True: 0, False: 0]
  ------------------
 4013|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4014|      0|      frame_reader_release(frame, io_cb, fp);
 4015|      0|      return rc;
 4016|      0|    }
 4017|      0|    if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4017:9): [True: 0, False: 0]
  ------------------
 4018|      0|        offset > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (4018:9): [True: 0, False: 0]
  ------------------
 4019|      0|        offset + chunk_cbytes > cbytes) {
  ------------------
  |  Branch (4019:9): [True: 0, False: 0]
  ------------------
 4020|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4021|      0|      frame_reader_release(frame, io_cb, fp);
 4022|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4023|      0|    }
 4024|      0|    if (io_cb->is_allocation_necessary) {
  ------------------
  |  Branch (4024:9): [True: 0, False: 0]
  ------------------
 4025|      0|      *chunk = capacity != NULL ? blosc2_tmp_malloc(chunk_cbytes, capacity) : malloc(chunk_cbytes);
  ------------------
  |  Branch (4025:16): [True: 0, False: 0]
  ------------------
 4026|      0|      if (*chunk == NULL) {
  ------------------
  |  Branch (4026:11): [True: 0, False: 0]
  ------------------
 4027|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4028|      0|        frame_reader_release(frame, io_cb, fp);
 4029|      0|        return BLOSC2_ERROR_MEMORY_ALLOC;
 4030|      0|      }
 4031|      0|      *needs_free = true;
 4032|      0|    }
 4033|      0|    else {
 4034|      0|      *needs_free = false;
 4035|      0|    }
 4036|       |
 4037|      0|    io_pos = frame->file_offset + header_len + offset;
 4038|      0|    rbytes = io_cb->read((void**)chunk, 1, chunk_cbytes, io_pos, fp);
 4039|      0|    frame_reader_release(frame, io_cb, fp);
 4040|      0|    if (rbytes != chunk_cbytes) {
  ------------------
  |  Branch (4040:9): [True: 0, False: 0]
  ------------------
 4041|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4042|      0|      if (*needs_free) {
  ------------------
  |  Branch (4042:11): [True: 0, False: 0]
  ------------------
 4043|      0|        free(*chunk);
 4044|      0|        *chunk = NULL;
 4045|      0|        *needs_free = false;
 4046|      0|      }
 4047|      0|      return BLOSC2_ERROR_FILE_READ;
 4048|      0|    }
 4049|       |
 4050|   619k|  } else {
 4051|       |    // The chunk is in memory and just one pointer away
 4052|   619k|    *chunk = frame->cframe + header_len + offset;
 4053|   619k|    int32_t chunk_blocksize = 0;
 4054|   619k|    rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, &chunk_blocksize);
 4055|   619k|    if (rc < 0) {
  ------------------
  |  Branch (4055:9): [True: 0, False: 619k]
  ------------------
 4056|      0|      return rc;
 4057|      0|    }
 4058|   619k|    if (chunk_blocksize <= 0) {
  ------------------
  |  Branch (4058:9): [True: 0, False: 619k]
  ------------------
 4059|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4060|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4061|      0|    }
 4062|   619k|    if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4062:9): [True: 0, False: 619k]
  ------------------
 4063|   619k|        offset > INT64_MAX - chunk_cbytes ||
  ------------------
  |  Branch (4063:9): [True: 0, False: 619k]
  ------------------
 4064|   619k|        offset + chunk_cbytes > cbytes) {
  ------------------
  |  Branch (4064:9): [True: 0, False: 619k]
  ------------------
 4065|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4066|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4067|      0|    }
 4068|   619k|  }
 4069|       |
 4070|   634k|  end:
 4071|   634k|  return (int32_t)chunk_cbytes;
 4072|   619k|}
frame.c:get_frame_fields:
 4489|  2.01M|static int get_frame_fields(blosc2_frame_s* frame, frame_fields* f) {
 4490|  2.01M|  int64_t frame_len;
 4491|  2.01M|  int rc = get_header_info(frame, &f->header_len, &frame_len, &f->nbytes, &f->cbytes, &f->blocksize,
 4492|  2.01M|                           &f->chunksize, &f->nchunks, &f->typesize, NULL, NULL, NULL, NULL, NULL, NULL,
 4493|  2.01M|                           NULL, frame->schunk->storage->io);
 4494|  2.01M|  if (rc < 0) {
  ------------------
  |  Branch (4494:7): [True: 0, False: 2.01M]
  ------------------
 4495|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4496|      0|    return rc;
 4497|      0|  }
 4498|  2.01M|  rc = frame_refresh_if_stale(frame, frame_len);
 4499|  2.01M|  if (rc < 0) {
  ------------------
  |  Branch (4499:7): [True: 0, False: 2.01M]
  ------------------
 4500|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4501|      0|    return rc;
 4502|      0|  }
 4503|  2.01M|  if (rc > 0) {
  ------------------
  |  Branch (4503:7): [True: 0, False: 2.01M]
  ------------------
 4504|      0|    frame->schunk->nbytes = f->nbytes;
 4505|      0|    frame->schunk->cbytes = f->cbytes;
 4506|      0|    frame->schunk->nchunks = f->nchunks;
 4507|      0|  }
 4508|  2.01M|  return BLOSC2_ERROR_SUCCESS;
 4509|  2.01M|}
frame.c:read_frame_chunk_header:
 4518|  2.01M|                                   uint8_t* header, int64_t* offset) {
 4519|  2.01M|  if (nchunk < 0 || nchunk >= f->nchunks) {
  ------------------
  |  Branch (4519:7): [True: 0, False: 2.01M]
  |  Branch (4519:21): [True: 0, False: 2.01M]
  ------------------
 4520|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4521|      0|                      "('%" PRId64 "') in frame.", nchunk, f->nchunks);
 4522|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 4523|      0|  }
 4524|  2.01M|  int rc = get_coffset(frame, f->header_len, f->cbytes, nchunk, f->nchunks, offset);
 4525|  2.01M|  if (rc < 0) {
  ------------------
  |  Branch (4525:7): [True: 0, False: 2.01M]
  ------------------
 4526|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4527|      0|    return rc;
 4528|      0|  }
 4529|  2.01M|  if (*offset < 0) {
  ------------------
  |  Branch (4529:7): [True: 1.10M, False: 915k]
  ------------------
 4530|  1.10M|    if (f->chunksize <= 0) {
  ------------------
  |  Branch (4530:9): [True: 0, False: 1.10M]
  ------------------
 4531|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4532|      0|      return BLOSC2_ERROR_INVALID_HEADER;
 4533|      0|    }
 4534|  1.10M|    int32_t chunksize = f->chunksize;
 4535|  1.10M|    if ((nchunk == f->nchunks - 1) && (f->nbytes % f->chunksize)) {
  ------------------
  |  Branch (4535:9): [True: 112k, False: 990k]
  |  Branch (4535:39): [True: 0, False: 112k]
  ------------------
 4536|       |      // Last chunk is incomplete.  Compute its actual size.
 4537|      0|      chunksize = (int32_t) (f->nbytes % f->chunksize);
 4538|      0|    }
 4539|  1.10M|    return special_chunk_into(*offset, chunksize, f->typesize, f->blocksize, header,
 4540|  1.10M|                              BLOSC_EXTENDED_HEADER_LENGTH);
 4541|  1.10M|  }
 4542|       |
 4543|   915k|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (4543:7): [True: 915k, False: 0]
  ------------------
 4544|       |    // get_coffset() checked that the header is inside the frame
 4545|   915k|    memcpy(header, frame->cframe + f->header_len + *offset, BLOSC_EXTENDED_HEADER_LENGTH);
 4546|   915k|  }
 4547|      0|  else {
 4548|      0|    blosc2_io_cb* io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 4549|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (4549:9): [True: 0, False: 0]
  ------------------
 4550|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4551|      0|      return BLOSC2_ERROR_PLUGIN_IO;
 4552|      0|    }
 4553|      0|    void* chunk_fp = fp;
 4554|      0|    int64_t io_pos = frame->file_offset + f->header_len + *offset;
 4555|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4555:9): [True: 0, False: 0]
  ------------------
 4556|      0|      chunk_fp = sframe_open_chunk(frame->urlpath, *offset, "rb", frame->schunk->storage->io);
 4557|      0|      io_pos = 0;
 4558|      0|    }
 4559|      0|    else if (fp == NULL) {
  ------------------
  |  Branch (4559:14): [True: 0, False: 0]
  ------------------
 4560|      0|      chunk_fp = frame_reader_acquire(frame, frame->schunk->storage->io);
 4561|      0|    }
 4562|      0|    if (chunk_fp == NULL) {
  ------------------
  |  Branch (4562:9): [True: 0, False: 0]
  ------------------
 4563|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4564|      0|      return BLOSC2_ERROR_FILE_OPEN;
 4565|      0|    }
 4566|      0|    uint8_t* header_ptr = header;
 4567|      0|    int64_t rbytes = io_cb->read((void**)&header_ptr, 1, BLOSC_EXTENDED_HEADER_LENGTH, io_pos, chunk_fp);
 4568|      0|    if (rbytes == BLOSC_EXTENDED_HEADER_LENGTH && header_ptr != header) {
  ------------------
  |  Branch (4568:9): [True: 0, False: 0]
  |  Branch (4568:51): [True: 0, False: 0]
  ------------------
 4569|      0|      memcpy(header, header_ptr, BLOSC_EXTENDED_HEADER_LENGTH);
 4570|      0|    }
 4571|      0|    if (frame->sframe) {
  ------------------
  |  Branch (4571:9): [True: 0, False: 0]
  ------------------
 4572|      0|      io_cb->close(chunk_fp);
 4573|      0|    }
 4574|      0|    else if (fp == NULL) {
  ------------------
  |  Branch (4574:14): [True: 0, False: 0]
  ------------------
 4575|      0|      frame_reader_release(frame, io_cb, chunk_fp);
 4576|      0|    }
 4577|      0|    if (rbytes != BLOSC_EXTENDED_HEADER_LENGTH) {
  ------------------
  |  Branch (4577:9): [True: 0, False: 0]
  ------------------
 4578|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4579|      0|      return BLOSC2_ERROR_FILE_READ;
 4580|      0|    }
 4581|      0|  }
 4582|   915k|  int32_t chunk_cbytes;
 4583|   915k|  rc = blosc2_cbuffer_sizes(header, NULL, &chunk_cbytes, NULL);
 4584|   915k|  if (rc < 0) {
  ------------------
  |  Branch (4584:7): [True: 0, False: 915k]
  ------------------
 4585|      0|    return rc;
 4586|      0|  }
 4587|   915k|  int64_t chunk_end;
 4588|   915k|  if (chunk_cbytes < BLOSC_EXTENDED_HEADER_LENGTH ||
  ------------------
  |  Branch (4588:7): [True: 0, False: 915k]
  ------------------
 4589|   915k|      (!frame->sframe && (!blosc2_checked_add_i64_nonneg(*offset, chunk_cbytes, &chunk_end) ||
  ------------------
  |  Branch (4589:8): [True: 915k, False: 0]
  |  Branch (4589:27): [True: 0, False: 915k]
  ------------------
 4590|   915k|                          chunk_end > f->cbytes))) {
  ------------------
  |  Branch (4590:27): [True: 0, False: 915k]
  ------------------
 4591|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4592|      0|    return BLOSC2_ERROR_INVALID_HEADER;
 4593|      0|  }
 4594|   915k|  return chunk_cbytes;
 4595|   915k|}
frame.c:compress_offsets:
 4803|  1.01M|                                uint8_t** off_chunk) {
 4804|  1.01M|  *off_chunk = NULL;
 4805|  1.01M|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
 4806|  1.01M|  cparams.splitmode = BLOSC_NEVER_SPLIT;
 4807|  1.01M|  cparams.typesize = sizeof(int64_t);
 4808|  1.01M|  cparams.blocksize = 16 * 1024;  // based on experiments with create_frame.c bench
 4809|  1.01M|  cparams.nthreads = 4;  // 4 threads seems a decent default for nowadays CPUs
 4810|  1.01M|  cparams.compcode = BLOSC_BLOSCLZ;
 4811|  1.01M|  blosc2_context* cctx = blosc2_create_cctx(cparams);
 4812|  1.01M|  if (cctx == NULL) {
  ------------------
  |  Branch (4812:7): [True: 0, False: 1.01M]
  ------------------
 4813|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4814|      0|    return BLOSC2_ERROR_NULL_POINTER;
 4815|      0|  }
 4816|  1.01M|  cctx->typesize = sizeof(int64_t);  // override a possible BLOSC_TYPESIZE env variable (or chaos may appear)
 4817|  1.01M|  uint8_t* chunk = malloc((size_t)dest_nbytes);
 4818|  1.01M|  if (chunk == NULL) {
  ------------------
  |  Branch (4818:7): [True: 0, False: 1.01M]
  ------------------
 4819|      0|    blosc2_free_ctx(cctx);
 4820|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4821|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 4822|      0|  }
 4823|  1.01M|  int32_t off_cbytes = blosc2_compress_ctx(cctx, offsets, off_nbytes, chunk, dest_nbytes);
 4824|  1.01M|  blosc2_free_ctx(cctx);
 4825|  1.01M|  if (off_cbytes < 0) {
  ------------------
  |  Branch (4825:7): [True: 0, False: 1.01M]
  ------------------
 4826|      0|    free(chunk);
 4827|      0|    return off_cbytes;
 4828|      0|  }
 4829|  1.01M|  *off_chunk = chunk;
 4830|  1.01M|  return off_cbytes;
 4831|  1.01M|}
frame.c:frame_needs_last_nbytes:
 4843|    128|static bool frame_needs_last_nbytes(int32_t chunksize, int64_t nchunks, int32_t chunk_nbytes) {
 4844|    128|  return chunksize > 0 && nchunks > 0 && chunk_nbytes < chunksize;
  ------------------
  |  Branch (4844:10): [True: 128, False: 0]
  |  Branch (4844:27): [True: 80, False: 48]
  |  Branch (4844:42): [True: 0, False: 80]
  ------------------
 4845|    128|}
frame.c:frame_takes_chunk:
 4851|     64|                              int32_t chunk_nbytes) {
 4852|     64|  if (frame_needs_last_nbytes(chunksize, nchunks, chunk_nbytes) && last_nbytes < chunksize &&
  ------------------
  |  Branch (4852:7): [True: 0, False: 64]
  |  Branch (4852:68): [True: 0, False: 0]
  ------------------
 4853|      0|      nbytes < chunksize) {
  ------------------
  |  Branch (4853:7): [True: 0, False: 0]
  ------------------
 4854|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4855|      0|                      "than the frame chunksize is not allowed yet: %d != %d.",
 4856|      0|                      chunk_nbytes, chunksize);
 4857|      0|    return false;
 4858|      0|  }
 4859|     64|  return true;
 4860|     64|}
frame.c:special_offset:
 4835|   376k|static void special_offset(int64_t* offset, int special_value) {
 4836|   376k|  uint64_t offset_value = ((uint64_t)1 << 63) + ((uint64_t)special_value << (8 * 7));
 4837|       |  to_little(offset, &offset_value, sizeof(uint64_t));
  ------------------
  |  |   35|   376k|#define to_little(dest, src, itemsize)    endian_handler(true, dest, src, itemsize)
  ------------------
 4838|   376k|}
frame.c:holes_place:
 5988|   611k|                           int64_t* payload_end) {
 5989|   611k|  int64_t start = *payload_end;
 5990|   611k|  int64_t len = 0;
 5991|   611k|  if (old_offset >= 0) {
  ------------------
  |  Branch (5991:7): [True: 19.5k, False: 591k]
  ------------------
 5992|  19.5k|    holes_take_run(frame, old_offset, old_len, &start, &len);
 5993|  19.5k|  }
 5994|   611k|  if (start + len == *payload_end) {
  ------------------
  |  Branch (5994:7): [True: 593k, False: 17.8k]
  ------------------
 5995|   593k|    *payload_end = start + new_len;
 5996|   593k|    return start;
 5997|   593k|  }
 5998|  17.8k|  if (new_len <= len) {
  ------------------
  |  Branch (5998:7): [True: 11.7k, False: 6.01k]
  ------------------
 5999|  11.7k|    holes_add(frame, start + new_len, len - new_len);
 6000|  11.7k|    return start;
 6001|  11.7k|  }
 6002|  6.01k|  holes_add(frame, start, len);
 6003|  6.01k|  int64_t offset = *payload_end;
 6004|  6.01k|  *payload_end += new_len;
 6005|  6.01k|  return offset;
 6006|  17.8k|}
frame.c:holes_take_run:
 5959|  19.5k|                           int64_t* run_len) {
 5960|  19.5k|  int64_t start = offset;
 5961|  19.5k|  int64_t end = offset + len;
 5962|  66.9k|  for (int64_t i = 0; i < frame->nholes;) {
  ------------------
  |  Branch (5962:23): [True: 47.3k, False: 19.5k]
  ------------------
 5963|  47.3k|    int64_t hole_start = frame->holes[2 * i];
 5964|  47.3k|    int64_t hole_end = hole_start + frame->holes[2 * i + 1];
 5965|  47.3k|    if (hole_end == start || hole_start == end) {
  ------------------
  |  Branch (5965:9): [True: 8.12k, False: 39.2k]
  |  Branch (5965:30): [True: 635, False: 38.6k]
  ------------------
 5966|  8.76k|      start = (hole_end == start) ? hole_start : start;
  ------------------
  |  Branch (5966:15): [True: 8.12k, False: 635]
  ------------------
 5967|  8.76k|      end = (hole_start == end) ? hole_end : end;
  ------------------
  |  Branch (5967:13): [True: 635, False: 8.12k]
  ------------------
 5968|  8.76k|      frame->nholes--;
 5969|  8.76k|      frame->holes[2 * i] = frame->holes[2 * frame->nholes];
 5970|  8.76k|      frame->holes[2 * i + 1] = frame->holes[2 * frame->nholes + 1];
 5971|  8.76k|      i = 0;  // the longer run may touch a hole seen already
 5972|  8.76k|      continue;
 5973|  8.76k|    }
 5974|  38.6k|    i++;
 5975|  38.6k|  }
 5976|  19.5k|  *run_start = start;
 5977|  19.5k|  *run_len = end - start;
 5978|  19.5k|}
frame.c:holes_add:
 5936|  17.8k|static void holes_add(blosc2_frame_s* frame, int64_t offset, int64_t len) {
 5937|  17.8k|  if (len <= 0) {
  ------------------
  |  Branch (5937:7): [True: 7.67k, False: 10.1k]
  ------------------
 5938|  7.67k|    return;
 5939|  7.67k|  }
 5940|  10.1k|  if (frame->nholes == frame->holes_cap) {
  ------------------
  |  Branch (5940:7): [True: 773, False: 9.35k]
  ------------------
 5941|    773|    int64_t cap = frame->holes_cap > 0 ? 2 * frame->holes_cap : 64;
  ------------------
  |  Branch (5941:19): [True: 0, False: 773]
  ------------------
 5942|    773|    int64_t* holes = realloc(frame->holes, (size_t)cap * 2 * sizeof(int64_t));
 5943|    773|    if (holes == NULL) {
  ------------------
  |  Branch (5943:9): [True: 0, False: 773]
  ------------------
 5944|      0|      frame->holes_lost = true;  // the frame stays valid, just with some dead space
 5945|      0|      return;
 5946|      0|    }
 5947|    773|    frame->holes = holes;
 5948|    773|    frame->holes_cap = cap;
 5949|    773|  }
 5950|  10.1k|  frame->holes[2 * frame->nholes] = offset;
 5951|  10.1k|  frame->holes[2 * frame->nholes + 1] = len;
 5952|  10.1k|  frame->nholes++;
 5953|  10.1k|}
frame.c:frame_compact:
 6338|    787|static int frame_compact(blosc2_frame_s* frame, blosc2_schunk* schunk) {
 6339|    787|  int32_t header_len;
 6340|    787|  int64_t frame_len;
 6341|    787|  int64_t nbytes;
 6342|    787|  int64_t cbytes;
 6343|    787|  int32_t blocksize;
 6344|    787|  int32_t chunksize;
 6345|    787|  int64_t nchunks;
 6346|    787|  int rc = get_header_info(frame, &header_len, &frame_len, &nbytes, &cbytes, &blocksize, &chunksize,
 6347|    787|                           &nchunks, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 6348|    787|                           frame->schunk->storage->io);
 6349|    787|  if (rc < 0) {
  ------------------
  |  Branch (6349:7): [True: 0, False: 787]
  ------------------
 6350|      0|    return rc;
 6351|      0|  }
 6352|    787|  int64_t nholes = frame->nholes;
 6353|    787|  int64_t* holes = frame->holes;  // (offset, length) pairs
 6354|    787|  qsort(holes, (size_t)nholes, 2 * sizeof(int64_t), compare_holes);
 6355|  2.14k|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6355:23): [True: 1.36k, False: 787]
  ------------------
 6356|  1.36k|    int64_t next = (k + 1 < nholes) ? holes[2 * (k + 1)] : cbytes;
  ------------------
  |  Branch (6356:20): [True: 575, False: 787]
  ------------------
 6357|  1.36k|    if (holes[2 * k] < 0 || holes[2 * k + 1] <= 0 || holes[2 * k] + holes[2 * k + 1] > next) {
  ------------------
  |  Branch (6357:9): [True: 0, False: 1.36k]
  |  Branch (6357:29): [True: 0, False: 1.36k]
  |  Branch (6357:54): [True: 0, False: 1.36k]
  ------------------
 6358|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6359|      0|      return BLOSC2_ERROR_DATA;
 6360|      0|    }
 6361|  1.36k|  }
 6362|    787|  if (nchunks == 0) {
  ------------------
  |  Branch (6362:7): [True: 0, False: 787]
  ------------------
 6363|      0|    return BLOSC2_ERROR_SUCCESS;  // all chunks got deleted: no offsets to rewrite, the payload stays
 6364|      0|  }
 6365|       |
 6366|    787|  int32_t off_nbytes;
 6367|    787|  if (!blosc2_nchunks_to_offsets_nbytes(nchunks, &off_nbytes)) {
  ------------------
  |  Branch (6367:7): [True: 0, False: 787]
  ------------------
 6368|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6369|      0|    return BLOSC2_ERROR_DATA;
 6370|      0|  }
 6371|    787|  int64_t* offsets = malloc((size_t)off_nbytes);
 6372|    787|  int64_t* shifts = malloc((size_t)(nholes + 1) * sizeof(int64_t));  // shifts[k]: length of the first k holes
 6373|    787|  uint8_t* off_chunk = NULL;
 6374|    787|  blosc2_io_cb* io_cb = NULL;
 6375|    787|  void* fp = NULL;
 6376|    787|  if (offsets == NULL || shifts == NULL) {
  ------------------
  |  Branch (6376:7): [True: 0, False: 787]
  |  Branch (6376:26): [True: 0, False: 787]
  ------------------
 6377|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 6378|      0|    goto out;
 6379|      0|  }
 6380|    787|  shifts[0] = 0;
 6381|  2.14k|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6381:23): [True: 1.36k, False: 787]
  ------------------
 6382|  1.36k|    shifts[k + 1] = shifts[k] + holes[2 * k + 1];
 6383|  1.36k|  }
 6384|    787|  int32_t coffsets_cbytes = 0;
 6385|    787|  uint8_t* coffsets = get_coffsets(frame, header_len, cbytes, nchunks, &coffsets_cbytes);
 6386|    787|  if (coffsets == NULL) {
  ------------------
  |  Branch (6386:7): [True: 0, False: 787]
  ------------------
 6387|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6388|      0|    rc = BLOSC2_ERROR_DATA;
 6389|      0|    goto out;
 6390|      0|  }
 6391|    787|  blosc2_dparams off_dparams = BLOSC2_DPARAMS_DEFAULTS;
 6392|    787|  blosc2_context* dctx = blosc2_create_dctx(off_dparams);
 6393|    787|  if (dctx == NULL) {
  ------------------
  |  Branch (6393:7): [True: 0, False: 787]
  ------------------
 6394|      0|    rc = BLOSC2_ERROR_MEMORY_ALLOC;
 6395|      0|    goto out;
 6396|      0|  }
 6397|    787|  rc = blosc2_decompress_ctx(dctx, coffsets, coffsets_cbytes, offsets, off_nbytes);
 6398|    787|  blosc2_free_ctx(dctx);
 6399|    787|  if (rc < 0) {
  ------------------
  |  Branch (6399:7): [True: 0, False: 787]
  ------------------
 6400|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6401|      0|    goto out;
 6402|      0|  }
 6403|       |
 6404|       |  // A stored chunk moves by the length of the holes before it
 6405|  16.0k|  for (int64_t i = 0; i < nchunks; i++) {
  ------------------
  |  Branch (6405:23): [True: 15.2k, False: 787]
  ------------------
 6406|  15.2k|    if (offsets[i] < 0) {
  ------------------
  |  Branch (6406:9): [True: 1.90k, False: 13.3k]
  ------------------
 6407|  1.90k|      continue;  // stored in its offset
 6408|  1.90k|    }
 6409|  13.3k|    int64_t lo = 0;
 6410|  13.3k|    int64_t hi = nholes;  // the holes [0, lo) start before the chunk, [hi, nholes) after it
 6411|  32.4k|    while (lo < hi) {
  ------------------
  |  Branch (6411:12): [True: 19.1k, False: 13.3k]
  ------------------
 6412|  19.1k|      int64_t mid = lo + (hi - lo) / 2;
 6413|  19.1k|      if (holes[2 * mid] < offsets[i]) {
  ------------------
  |  Branch (6413:11): [True: 11.9k, False: 7.23k]
  ------------------
 6414|  11.9k|        lo = mid + 1;
 6415|  11.9k|      }
 6416|  7.23k|      else {
 6417|  7.23k|        hi = mid;
 6418|  7.23k|      }
 6419|  19.1k|    }
 6420|  13.3k|    if ((lo > 0 && offsets[i] < holes[2 * (lo - 1)] + holes[2 * (lo - 1) + 1]) ||
  ------------------
  |  Branch (6420:10): [True: 9.72k, False: 3.59k]
  |  Branch (6420:20): [True: 0, False: 9.72k]
  ------------------
 6421|  13.3k|        (lo < nholes && offsets[i] == holes[2 * lo])) {
  ------------------
  |  Branch (6421:10): [True: 5.26k, False: 8.05k]
  |  Branch (6421:25): [True: 0, False: 5.26k]
  ------------------
 6422|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6423|      0|      rc = BLOSC2_ERROR_DATA;
 6424|      0|      goto out;
 6425|      0|    }
 6426|  13.3k|    offsets[i] -= shifts[lo];
 6427|  13.3k|  }
 6428|       |
 6429|    787|  if (frame->cframe == NULL) {
  ------------------
  |  Branch (6429:7): [True: 0, False: 787]
  ------------------
 6430|      0|    io_cb = blosc2_get_io_cb(frame->schunk->storage->io->id);
 6431|      0|    if (io_cb == NULL) {
  ------------------
  |  Branch (6431:9): [True: 0, False: 0]
  ------------------
 6432|      0|      rc = BLOSC2_ERROR_PLUGIN_IO;
 6433|      0|      goto out;
 6434|      0|    }
 6435|      0|    fp = frame_writer_acquire(frame, io_cb);
 6436|      0|    if (fp == NULL) {
  ------------------
  |  Branch (6436:9): [True: 0, False: 0]
  ------------------
 6437|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6438|      0|      rc = BLOSC2_ERROR_FILE_OPEN;
 6439|      0|      goto out;
 6440|      0|    }
 6441|      0|  }
 6442|       |  // The stretch behind each hole moves down by the length of all holes up to it
 6443|  2.14k|  for (int64_t k = 0; k < nholes; k++) {
  ------------------
  |  Branch (6443:23): [True: 1.36k, False: 787]
  ------------------
 6444|  1.36k|    int64_t shift = shifts[k + 1];
 6445|  1.36k|    int64_t src = holes[2 * k] + holes[2 * k + 1];
 6446|  1.36k|    int64_t len = ((k + 1 < nholes) ? holes[2 * (k + 1)] : cbytes) - src;
  ------------------
  |  Branch (6446:20): [True: 575, False: 787]
  ------------------
 6447|  1.36k|    if (len == 0) {
  ------------------
  |  Branch (6447:9): [True: 0, False: 1.36k]
  ------------------
 6448|      0|      continue;
 6449|      0|    }
 6450|  1.36k|    if (frame->cframe != NULL) {
  ------------------
  |  Branch (6450:9): [True: 1.36k, False: 0]
  ------------------
 6451|  1.36k|      memmove(frame->cframe + header_len + src - shift, frame->cframe + header_len + src, (size_t)len);
 6452|  1.36k|    }
 6453|      0|    else {
 6454|      0|      rc = frame_move_range(io_cb, fp, frame->file_offset + header_len + src,
 6455|      0|                            frame->file_offset + header_len + src - shift, len, 0);
 6456|      0|      if (rc < 0) {
  ------------------
  |  Branch (6456:11): [True: 0, False: 0]
  ------------------
 6457|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6458|      0|        frame->file_end = 0;
 6459|      0|        goto out;
 6460|      0|      }
 6461|      0|    }
 6462|  1.36k|  }
 6463|    787|  int64_t new_cbytes = cbytes - shifts[nholes];
 6464|       |
 6465|    787|  int32_t off_cbytes = compress_offsets(offsets, off_nbytes, off_nbytes + BLOSC2_MAX_OVERHEAD, &off_chunk);
 6466|    787|  if (off_cbytes < 0) {
  ------------------
  |  Branch (6466:7): [True: 0, False: 787]
  ------------------
 6467|      0|    rc = off_cbytes;
 6468|      0|    goto out;
 6469|      0|  }
 6470|    787|  if (frame->cframe != NULL) {
  ------------------
  |  Branch (6470:7): [True: 787, False: 0]
  ------------------
 6471|       |    // The payload got shorter: the offsets fit into the frame
 6472|    787|    memcpy(frame->cframe + header_len + new_cbytes, off_chunk, (size_t)off_cbytes);
 6473|    787|  }
 6474|      0|  else {
 6475|      0|    int64_t wbytes = io_cb->write(off_chunk, 1, off_cbytes, frame->file_offset + header_len + new_cbytes, fp);
 6476|      0|    if (wbytes != off_cbytes) {
  ------------------
  |  Branch (6476:9): [True: 0, False: 0]
  ------------------
 6477|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6478|      0|      frame->file_end = 0;
 6479|      0|      rc = BLOSC2_ERROR_FILE_WRITE;
 6480|      0|      goto out;
 6481|      0|    }
 6482|      0|  }
 6483|    787|  if (frame->coffsets != NULL) {
  ------------------
  |  Branch (6483:7): [True: 0, False: 787]
  ------------------
 6484|      0|    if (frame->coffsets_needs_free) {
  ------------------
  |  Branch (6484:9): [True: 0, False: 0]
  ------------------
 6485|      0|      free(frame->coffsets);
 6486|      0|    }
 6487|      0|    frame->coffsets = NULL;
 6488|      0|  }
 6489|    787|  schunk->cbytes = new_cbytes;
 6490|    787|  frame->len = header_len + new_cbytes + off_cbytes + frame->trailer_len;
 6491|    787|  rc = frame_update_header(frame, schunk, false);
 6492|    787|  if (rc >= 0) {
  ------------------
  |  Branch (6492:7): [True: 787, False: 0]
  ------------------
 6493|    787|    rc = frame_update_trailer(frame, schunk);  // cuts the file too
 6494|    787|  }
 6495|       |
 6496|    787|  out:
 6497|    787|  if (fp != NULL) {
  ------------------
  |  Branch (6497:7): [True: 0, False: 787]
  ------------------
 6498|      0|    frame_writer_release(frame, io_cb, fp);
 6499|      0|  }
 6500|    787|  free(off_chunk);
 6501|    787|  free(offsets);
 6502|    787|  free(shifts);
 6503|    787|  return rc < 0 ? rc : BLOSC2_ERROR_SUCCESS;
  ------------------
  |  Branch (6503:10): [True: 0, False: 787]
  ------------------
 6504|    787|}
frame.c:compare_holes:
 6327|  1.14k|static int compare_holes(const void* a, const void* b) {
 6328|  1.14k|  int64_t x = *(const int64_t*)a;
 6329|  1.14k|  int64_t y = *(const int64_t*)b;
 6330|  1.14k|  return (x > y) - (x < y);
 6331|  1.14k|}

prefetch_set_populate:
   85|  4.92k|void prefetch_set_populate(int mode) {
   86|  4.92k|  g_populate = mode < 0 ? -1 : (mode > 0);
  ------------------
  |  Branch (86:16): [True: 4.92k, False: 0]
  ------------------
   87|  4.92k|}
prefetch_applies:
  133|   128k|bool prefetch_applies(const blosc2_frame_s *frame) {
  134|   128k|  return prefetch_enabled() && frame != NULL && frame->cframe == NULL && !frame->sframe && frame->urlpath != NULL &&
  ------------------
  |  Branch (134:10): [True: 0, False: 128k]
  |  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|   128k|}
prefetch_destroy:
  338|  4.92k|void prefetch_destroy(void) {
  339|  4.92k|  pthread_mutex_lock(&destroy_mutex);
  340|  4.92k|  pthread_mutex_lock(&pool.mutex);
  341|  4.92k|  if (pool.threads == NULL) {
  ------------------
  |  Branch (341:7): [True: 4.92k, False: 0]
  ------------------
  342|  4.92k|    pthread_mutex_unlock(&pool.mutex);
  343|  4.92k|    pthread_mutex_unlock(&destroy_mutex);
  344|  4.92k|    return;
  345|  4.92k|  }
  346|      0|  pool.stop = true;
  347|      0|  pthread_cond_broadcast(&pool.work);
  348|      0|  int nthreads = pool.nthreads;
  349|      0|  pthread_t *threads = pool.threads;
  350|      0|  pool.threads = NULL;
  351|      0|  pool.nthreads = 0;
  352|      0|  pthread_mutex_unlock(&pool.mutex);
  353|       |
  354|      0|  for (int i = 0; i < nthreads; ++i) {
  ------------------
  |  Branch (354:19): [True: 0, False: 0]
  ------------------
  355|      0|    pthread_join(threads[i], NULL);
  356|      0|  }
  357|      0|  free(threads);
  358|       |
  359|      0|  pthread_mutex_lock(&pool.mutex);
  360|       |  pool.stop = false;
  361|      0|  pthread_mutex_unlock(&pool.mutex);
  362|      0|  pthread_mutex_unlock(&destroy_mutex);
  363|      0|}
prefetch_batch_wait:
  908|  1.45M|void prefetch_batch_wait(prefetch_batch *batch, int64_t nchunk) {
  909|  1.45M|  if (batch == NULL) {
  ------------------
  |  Branch (909:7): [True: 1.45M, False: 0]
  ------------------
  910|  1.45M|    return;
  911|  1.45M|  }
  912|      0|  pthread_mutex_lock(&pool.mutex);
  913|       |  // The slice reads the chunks in the order given, so this is mostly the next one
  914|      0|  for (int64_t k = 0; k < batch->nchunks; ++k) {
  ------------------
  |  Branch (914:23): [True: 0, False: 0]
  ------------------
  915|      0|    int64_t i = (batch->cursor + k) % batch->nchunks;
  916|      0|    if (batch->chunks[i] == nchunk) {
  ------------------
  |  Branch (916:9): [True: 0, False: 0]
  ------------------
  917|      0|      batch->cursor = i + 1;
  918|      0|      raise_limit(batch, batch->end_piece[i], batch->end_piece[i]);
  919|      0|      wait_pieces(batch, batch->end_piece[i]);
  920|      0|      break;
  921|      0|    }
  922|      0|  }
  923|      0|  pthread_mutex_unlock(&pool.mutex);
  924|      0|}
prefetch_batch_free:
  927|   662k|void prefetch_batch_free(prefetch_batch *batch) {
  928|   662k|  if (batch == NULL) {
  ------------------
  |  Branch (928:7): [True: 662k, False: 0]
  ------------------
  929|   662k|    return;
  930|   662k|  }
  931|      0|  pthread_mutex_lock(&pool.mutex);
  932|      0|  batch->limit = batch->next;
  933|      0|  wait_pieces(batch, batch->next);
  934|      0|  prefetch_batch **link = &pool.batches;
  935|      0|  while (*link != batch) {
  ------------------
  |  Branch (935:10): [True: 0, False: 0]
  ------------------
  936|      0|    link = &(*link)->next_batch;
  937|      0|  }
  938|      0|  *link = batch->next_batch;
  939|      0|  pool.nbatches--;
  940|      0|  pthread_mutex_unlock(&pool.mutex);
  941|      0|  pthread_cond_destroy(&batch->progress);
  942|      0|  close(batch->fd);
  943|      0|  free(batch);
  944|      0|}
prefetch.c:prefetch_enabled:
  128|   128k|static bool prefetch_enabled(void) {
  129|   128k|  return g_nthreads > 0 && blosc2_is_initialized();
  ------------------
  |  Branch (129:10): [True: 0, False: 128k]
  |  Branch (129:28): [True: 0, False: 0]
  ------------------
  130|   128k|}

blosc2_schunk_get_cparams:
   73|  19.7k|int blosc2_schunk_get_cparams(blosc2_schunk *schunk, blosc2_cparams **cparams) {
   74|  19.7k|  *cparams = calloc(1, sizeof(blosc2_cparams));
   75|  19.7k|  (*cparams)->schunk = schunk;
   76|   138k|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (76:19): [True: 118k, False: 19.7k]
  ------------------
   77|   118k|    (*cparams)->filters[i] = schunk->filters[i];
   78|   118k|    (*cparams)->filters_meta[i] = schunk->filters_meta[i];
   79|   118k|  }
   80|  19.7k|  (*cparams)->compcode = schunk->compcode;
   81|  19.7k|  (*cparams)->compcode_meta = schunk->compcode_meta;
   82|  19.7k|  (*cparams)->clevel = schunk->clevel;
   83|  19.7k|  (*cparams)->typesize = schunk->typesize;
   84|  19.7k|  (*cparams)->blocksize = schunk->blocksize;
   85|  19.7k|  (*cparams)->splitmode = schunk->splitmode;
   86|  19.7k|  (*cparams)->use_dict = schunk->use_dict;
   87|  19.7k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (87:7): [True: 4.29k, False: 15.4k]
  ------------------
   88|  4.29k|    (*cparams)->nthreads = blosc2_get_nthreads();
   89|  4.29k|  }
   90|  15.4k|  else {
   91|  15.4k|    (*cparams)->nthreads = (int16_t)schunk->cctx->nthreads;
   92|  15.4k|  }
   93|  19.7k|  return 0;
   94|  19.7k|}
blosc2_schunk_get_dparams:
   98|  4.26k|int blosc2_schunk_get_dparams(blosc2_schunk *schunk, blosc2_dparams **dparams) {
   99|  4.26k|  *dparams = calloc(1, sizeof(blosc2_dparams));
  100|  4.26k|  (*dparams)->schunk = schunk;
  101|  4.26k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (101:7): [True: 4.26k, False: 0]
  ------------------
  102|  4.26k|    (*dparams)->nthreads = blosc2_get_nthreads();
  103|  4.26k|  }
  104|      0|  else {
  105|      0|    (*dparams)->nthreads = schunk->dctx->nthreads;
  106|      0|  }
  107|  4.26k|  return 0;
  108|  4.26k|}
update_schunk_properties:
  111|  12.4k|int update_schunk_properties(struct blosc2_schunk* schunk) {
  112|  12.4k|  blosc2_cparams* cparams = schunk->storage->cparams;
  113|  12.4k|  blosc2_dparams* dparams = schunk->storage->dparams;
  114|       |
  115|  87.4k|  for (int i = 0; i < BLOSC2_MAX_FILTERS; i++) {
  ------------------
  |  Branch (115:19): [True: 74.9k, False: 12.4k]
  ------------------
  116|  74.9k|    schunk->filters[i] = cparams->filters[i];
  117|  74.9k|    schunk->filters_meta[i] = cparams->filters_meta[i];
  118|  74.9k|  }
  119|  12.4k|  schunk->compcode = cparams->compcode;
  120|  12.4k|  schunk->compcode_meta = cparams->compcode_meta;
  121|  12.4k|  schunk->clevel = cparams->clevel;
  122|  12.4k|  schunk->splitmode = cparams->splitmode;
  123|  12.4k|  schunk->use_dict = (uint8_t)cparams->use_dict;
  124|  12.4k|  schunk->typesize = cparams->typesize;
  125|  12.4k|  schunk->blocksize = cparams->blocksize;
  126|  12.4k|  schunk->chunksize = -1;
  127|  12.4k|  schunk->flags2 = 0;
  128|  12.4k|  schunk->tuner_params = cparams->tuner_params;
  129|  12.4k|  schunk->tuner_id = cparams->tuner_id;
  130|  12.4k|  if (cparams->tuner_id == BLOSC_BTUNE) {
  ------------------
  |  Branch (130:7): [True: 0, False: 12.4k]
  ------------------
  131|      0|    cparams->use_dict = 0;
  132|      0|  }
  133|       |  /* The compression context */
  134|  12.4k|  if (schunk->cctx != NULL) {
  ------------------
  |  Branch (134:7): [True: 0, False: 12.4k]
  ------------------
  135|      0|    blosc2_free_ctx(schunk->cctx);
  136|      0|  }
  137|  12.4k|  cparams->schunk = schunk;
  138|  12.4k|  schunk->cctx = blosc2_create_cctx(*cparams);
  139|  12.4k|  if (schunk->cctx == NULL) {
  ------------------
  |  Branch (139:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if (schunk->dctx != NULL) {
  ------------------
  |  Branch (145:7): [True: 0, False: 12.4k]
  ------------------
  146|      0|    blosc2_free_ctx(schunk->dctx);
  147|      0|  }
  148|  12.4k|  dparams->schunk = schunk;
  149|  12.4k|  schunk->dctx = blosc2_create_dctx(*dparams);
  150|  12.4k|  if (schunk->dctx == NULL) {
  ------------------
  |  Branch (150:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  return BLOSC2_ERROR_SUCCESS;
  156|  12.4k|}
blosc2_schunk_new:
  166|  12.4k|blosc2_schunk* blosc2_schunk_new(blosc2_storage *storage) {
  167|  12.4k|  blosc2_schunk* schunk = calloc(1, sizeof(blosc2_schunk));
  168|  12.4k|  schunk->version = 0;     /* pre-first version */
  169|  12.4k|  schunk->view = false;  /* not a view by default */
  170|       |
  171|       |  // Get the storage with proper defaults
  172|  12.4k|  schunk->storage = get_new_storage(storage, &BLOSC2_CPARAMS_DEFAULTS, &BLOSC2_DPARAMS_DEFAULTS, &BLOSC2_IO_DEFAULTS);
  173|       |  // Update the (local variable) storage
  174|  12.4k|  storage = schunk->storage;
  175|       |
  176|  12.4k|  char* tradeoff = getenv("BTUNE_TRADEOFF");
  177|  12.4k|  if (tradeoff != NULL) {
  ------------------
  |  Branch (177:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if (update_schunk_properties(schunk) < 0) {
  ------------------
  |  Branch (183:7): [True: 0, False: 12.4k]
  ------------------
  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|  12.4k|  if (!storage->contiguous && storage->urlpath != NULL){
  ------------------
  |  Branch (189:7): [True: 7.37k, False: 5.11k]
  |  Branch (189:31): [True: 0, False: 7.37k]
  ------------------
  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|  12.4k|  if (storage->contiguous){
  ------------------
  |  Branch (225:7): [True: 5.11k, False: 7.37k]
  ------------------
  226|       |    // We want a contiguous frame as storage
  227|  5.11k|    if (storage->urlpath != NULL) {
  ------------------
  |  Branch (227:9): [True: 0, False: 5.11k]
  ------------------
  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|  5.11k|    blosc2_frame_s* frame = frame_new(storage->urlpath);
  235|  5.11k|    if (frame == NULL) {
  ------------------
  |  Branch (235:9): [True: 0, False: 5.11k]
  ------------------
  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|  5.11k|    frame->sframe = false;
  241|  5.11k|    frame_set_locking(frame, schunk->storage->io);
  242|       |    // Initialize frame (basically, encode the header)
  243|  5.11k|    frame->schunk = schunk;
  244|  5.11k|    int64_t frame_len = frame_from_schunk(schunk, frame);
  245|  5.11k|    if (frame_len < 0) {
  ------------------
  |  Branch (245:9): [True: 0, False: 5.11k]
  ------------------
  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|  5.11k|    schunk->frame = (blosc2_frame*)frame;
  252|  5.11k|  }
  253|       |
  254|  12.4k|  return schunk;
  255|  12.4k|}
blosc2_schunk_to_buffer:
  567|  2.54k|int64_t blosc2_schunk_to_buffer(blosc2_schunk* schunk, uint8_t** dest, bool* needs_free) {
  568|  2.54k|  blosc2_frame_s* frame;
  569|  2.54k|  int64_t cframe_len;
  570|       |
  571|       |  // Initialize defaults in case of errors
  572|  2.54k|  *dest = NULL;
  573|  2.54k|  *needs_free = false;
  574|       |
  575|  2.54k|  if ((schunk->storage->contiguous == true) && (schunk->storage->urlpath == NULL)) {
  ------------------
  |  Branch (575:7): [True: 2.54k, False: 0]
  |  Branch (575:48): [True: 2.54k, False: 0]
  ------------------
  576|  2.54k|    frame =  (blosc2_frame_s*)(schunk->frame);
  577|  2.54k|    *dest = frame->cframe;
  578|  2.54k|    cframe_len = frame->len;
  579|  2.54k|    *needs_free = false;
  580|  2.54k|  }
  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|  2.54k|  return cframe_len;
  598|       |
  599|  2.54k|}
schunk_free_metalayers:
  790|  17.2k|void schunk_free_metalayers(blosc2_schunk *schunk) {
  791|  32.5k|  for (int i = 0; i < schunk->nmetalayers; i++) {
  ------------------
  |  Branch (791:19): [True: 15.2k, False: 17.2k]
  ------------------
  792|  15.2k|    if (schunk->metalayers[i] != NULL) {
  ------------------
  |  Branch (792:9): [True: 15.0k, False: 179]
  ------------------
  793|  15.0k|      free(schunk->metalayers[i]->name);
  794|  15.0k|      free(schunk->metalayers[i]->content);
  795|  15.0k|      free(schunk->metalayers[i]);
  796|       |      schunk->metalayers[i] = NULL;
  797|  15.0k|    }
  798|  15.2k|  }
  799|  17.2k|  schunk->nmetalayers = 0;
  800|  17.2k|}
schunk_free_vlmetalayers:
  803|  17.2k|void schunk_free_vlmetalayers(blosc2_schunk *schunk) {
  804|  42.8k|  for (int i = 0; i < schunk->nvlmetalayers; i++) {
  ------------------
  |  Branch (804:19): [True: 25.5k, False: 17.2k]
  ------------------
  805|  25.5k|    if (schunk->vlmetalayers[i] != NULL) {
  ------------------
  |  Branch (805:9): [True: 74, False: 25.5k]
  ------------------
  806|     74|      free(schunk->vlmetalayers[i]->name);
  807|     74|      free(schunk->vlmetalayers[i]->content);
  808|     74|      free(schunk->vlmetalayers[i]);
  809|       |      schunk->vlmetalayers[i] = NULL;
  810|     74|    }
  811|  25.5k|  }
  812|  17.2k|  schunk->nvlmetalayers = 0;
  813|  17.2k|}
blosc2_schunk_free:
  816|  17.2k|int blosc2_schunk_free(blosc2_schunk *schunk) {
  817|  17.2k|  int err = 0;
  818|       |
  819|       |  // If it is a view, the data belongs to original array and should not be freed
  820|  17.2k|  if (schunk->data != NULL && !schunk->view) {
  ------------------
  |  Branch (820:7): [True: 0, False: 17.2k]
  |  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|  17.2k|  if (schunk->cctx != NULL)
  ------------------
  |  Branch (826:7): [True: 16.7k, False: 511]
  ------------------
  827|  16.7k|    blosc2_free_ctx(schunk->cctx);
  828|  17.2k|  if (schunk->dctx != NULL)
  ------------------
  |  Branch (828:7): [True: 16.7k, False: 511]
  ------------------
  829|  16.7k|    blosc2_free_ctx(schunk->dctx);
  830|  17.2k|  if (schunk->blockshape != NULL)
  ------------------
  |  Branch (830:7): [True: 0, False: 17.2k]
  ------------------
  831|      0|    free(schunk->blockshape);
  832|       |
  833|  17.2k|  schunk_free_metalayers(schunk);
  834|       |
  835|  17.2k|  if (schunk->storage != NULL) {
  ------------------
  |  Branch (835:7): [True: 16.7k, False: 511]
  ------------------
  836|  16.7k|    blosc2_io_cb *io_cb = blosc2_get_io_cb(schunk->storage->io->id);
  837|  16.7k|    if (io_cb != NULL) {
  ------------------
  |  Branch (837:9): [True: 16.7k, False: 0]
  ------------------
  838|  16.7k|      int rc = io_cb->destroy(schunk->storage->io->params);
  839|  16.7k|      if (rc < 0) {
  ------------------
  |  Branch (839:11): [True: 0, False: 16.7k]
  ------------------
  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|  16.7k|    }
  844|       |
  845|  16.7k|    if (schunk->storage->urlpath != NULL) {
  ------------------
  |  Branch (845:9): [True: 0, False: 16.7k]
  ------------------
  846|      0|      free(schunk->storage->urlpath);
  847|      0|    }
  848|  16.7k|    free(schunk->storage->cparams);
  849|  16.7k|    free(schunk->storage->dparams);
  850|  16.7k|    free(schunk->storage->io);
  851|  16.7k|    free(schunk->storage);
  852|  16.7k|  }
  853|       |
  854|       |  // If it is a view, the frame belongs to original array and should not be freed
  855|  17.2k|  if (schunk->frame != NULL && !schunk->view) {
  ------------------
  |  Branch (855:7): [True: 17.2k, False: 0]
  |  Branch (855:32): [True: 9.88k, False: 7.37k]
  ------------------
  856|  9.88k|    frame_free((blosc2_frame_s *) schunk->frame);
  857|  9.88k|  }
  858|       |
  859|  17.2k|  schunk_free_vlmetalayers(schunk);
  860|       |
  861|  17.2k|  free(schunk);
  862|       |
  863|  17.2k|  return err;
  864|  17.2k|}
blosc2_schunk_from_buffer:
  868|  4.89k|blosc2_schunk* blosc2_schunk_from_buffer(uint8_t *cframe, int64_t len, bool copy) {
  869|       |  // Check that the buffer actually comes from a cframe
  870|  4.89k|  if (cframe == NULL || len < FRAME_HEADER_MINLEN) {
  ------------------
  |  |   49|  4.89k|#define FRAME_HEADER_MINLEN (FRAME_FILTER_PIPELINE + 1 + 16)  // 87 <- minimum length
  |  |  ------------------
  |  |  |  |   44|  4.89k|#define FRAME_FILTER_PIPELINE (FRAME_HAS_VLMETALAYERS + 1 + 1) // 70
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|  4.89k|#define FRAME_HAS_VLMETALAYERS (FRAME_NTHREADS_D + 2)  // 68
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   42|  4.89k|#define FRAME_NTHREADS_D (FRAME_NTHREADS_C + 2 + 1)  // 66
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |   41|  4.89k|#define FRAME_NTHREADS_C (FRAME_CHUNKSIZE + 4 + 1)  // 63
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |   40|  4.89k|#define FRAME_CHUNKSIZE (FRAME_BLOCKSIZE + 4 + 1)  // 58
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |   39|  4.89k|#define FRAME_BLOCKSIZE (FRAME_TYPESIZE + 4 + 1)  // 53
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   38|  4.89k|#define FRAME_TYPESIZE (FRAME_CBYTES + 8 + 1) // 48
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   37|  4.89k|#define FRAME_CBYTES (FRAME_NBYTES + 8 + 1)  // 39
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   36|  4.89k|#define FRAME_NBYTES (FRAME_FLAGS + 4 + 1)  // 30
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   32|  4.89k|#define FRAME_FLAGS (FRAME_LEN + 8 + 1)  // 25
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   31|  4.89k|#define FRAME_LEN (FRAME_HEADER_LEN + 4 + 1)  // 16
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   30|  4.89k|#define FRAME_HEADER_LEN (FRAME_HEADER_MAGIC + 8 + 1)  // 11
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |   29|  4.89k|#define FRAME_HEADER_MAGIC 2
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (870:7): [True: 0, False: 4.89k]
  |  Branch (870:25): [True: 2, False: 4.89k]
  ------------------
  871|      2|    return NULL;
  872|      2|  }
  873|  4.89k|  char *magic_number = (char *)cframe + FRAME_HEADER_MAGIC;
  ------------------
  |  |   29|  4.89k|#define FRAME_HEADER_MAGIC 2
  ------------------
  874|  4.89k|  if (memcmp(magic_number, "b2frame", sizeof("b2frame")) != 0) {
  ------------------
  |  Branch (874:7): [True: 14, False: 4.88k]
  ------------------
  875|     14|    return NULL;
  876|     14|  }
  877|  4.88k|  blosc2_frame_s* frame = frame_from_cframe(cframe, len, false);
  878|  4.88k|  if (frame == NULL) {
  ------------------
  |  Branch (878:7): [True: 108, False: 4.77k]
  ------------------
  879|    108|    return NULL;
  880|    108|  }
  881|  4.77k|  blosc2_schunk* schunk = frame_to_schunk(frame, copy, &BLOSC2_IO_DEFAULTS);
  882|  4.77k|  if (schunk && copy) {
  ------------------
  |  Branch (882:7): [True: 2.54k, False: 2.22k]
  |  Branch (882:17): [True: 0, False: 2.54k]
  ------------------
  883|       |    // Super-chunk has its own copy of frame
  884|      0|    frame_free(frame);
  885|      0|  }
  886|  4.77k|  return schunk;
  887|  4.88k|}
blosc2_schunk_fill_special:
  942|  9.99k|                               int32_t chunksize) {
  943|  9.99k|  if (nitems == 0) {
  ------------------
  |  Branch (943:7): [True: 0, False: 9.99k]
  ------------------
  944|      0|    return 0;
  945|      0|  }
  946|       |
  947|  9.99k|  int32_t typesize = schunk->typesize;
  948|  9.99k|  if (nitems < 0 || chunksize <= 0 || typesize <= 0) {
  ------------------
  |  Branch (948:7): [True: 0, False: 9.99k]
  |  Branch (948:21): [True: 0, False: 9.99k]
  |  Branch (948:39): [True: 0, False: 9.99k]
  ------------------
  949|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  950|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  951|      0|  }
  952|       |
  953|  9.99k|  if ((schunk->nbytes > 0) || (schunk->cbytes > 0)) {
  ------------------
  |  Branch (953:7): [True: 0, False: 9.99k]
  |  Branch (953:31): [True: 0, False: 9.99k]
  ------------------
  954|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|      0|    return BLOSC2_ERROR_FRAME_SPECIAL;
  956|      0|  }
  957|       |
  958|       |  // Compute the number of chunks and the length of the offsets chunk
  959|  9.99k|  int32_t chunkitems = chunksize / typesize;
  960|  9.99k|  if (chunkitems <= 0) {
  ------------------
  |  Branch (960:7): [True: 0, False: 9.99k]
  ------------------
  961|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  962|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  963|      0|  }
  964|  9.99k|  int64_t nchunks = nitems / chunkitems;
  965|  9.99k|  if (nchunks > INT_MAX) {
  ------------------
  |  Branch (965:7): [True: 0, False: 9.99k]
  ------------------
  966|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|      0|    return BLOSC2_ERROR_SCHUNK_SPECIAL;
  968|      0|  }
  969|  9.99k|  if (!blosc2_checked_mul_i64_nonneg(nitems, typesize, NULL)) {
  ------------------
  |  Branch (969:7): [True: 0, False: 9.99k]
  ------------------
  970|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  971|      0|    return BLOSC2_ERROR_SCHUNK_SPECIAL;
  972|      0|  }
  973|  9.99k|  int32_t leftover_items = (int32_t)(nitems % chunkitems);
  974|       |
  975|  9.99k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (975:7): [True: 6.58k, False: 3.40k]
  ------------------
  976|       |    // Build the special chunks
  977|  6.58k|    int32_t leftover_size = leftover_items * typesize;
  978|  6.58k|    void* chunk = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
  979|  6.58k|    void* chunk2 = malloc(BLOSC_EXTENDED_HEADER_LENGTH);
  980|  6.58k|    blosc2_cparams* cparams;
  981|  6.58k|    blosc2_schunk_get_cparams(schunk, &cparams);
  982|  6.58k|    int csize, csize2;
  983|  6.58k|    switch (special_value) {
  984|  6.58k|      case BLOSC2_SPECIAL_ZERO:
  ------------------
  |  Branch (984:7): [True: 6.58k, False: 0]
  ------------------
  985|  6.58k|        csize = blosc2_chunk_zeros(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
  986|  6.58k|        csize2 = blosc2_chunk_zeros(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
  987|  6.58k|        break;
  988|      0|      case BLOSC2_SPECIAL_UNINIT:
  ------------------
  |  Branch (988:7): [True: 0, False: 6.58k]
  ------------------
  989|      0|        csize = blosc2_chunk_uninit(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
  990|      0|        csize2 = blosc2_chunk_uninit(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
  991|      0|        break;
  992|      0|      case BLOSC2_SPECIAL_NAN:
  ------------------
  |  Branch (992:7): [True: 0, False: 6.58k]
  ------------------
  993|      0|        csize = blosc2_chunk_nans(*cparams, chunksize, chunk, BLOSC_EXTENDED_HEADER_LENGTH);
  994|      0|        csize2 = blosc2_chunk_nans(*cparams, leftover_size, chunk2, BLOSC_EXTENDED_HEADER_LENGTH);
  995|      0|        break;
  996|      0|      default:
  ------------------
  |  Branch (996:7): [True: 0, False: 6.58k]
  ------------------
  997|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
  999|  6.58k|    }
 1000|  6.58k|    free(cparams);
 1001|  6.58k|    if (csize < 0 || csize2 < 0) {
  ------------------
  |  Branch (1001:9): [True: 0, False: 6.58k]
  |  Branch (1001:22): [True: 0, False: 6.58k]
  ------------------
 1002|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|      0|      return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1004|      0|    }
 1005|       |
 1006|   723k|    for (int nchunk = 0; nchunk < nchunks; nchunk++) {
  ------------------
  |  Branch (1006:26): [True: 716k, False: 6.58k]
  ------------------
 1007|   716k|      int64_t nchunk_ = blosc2_schunk_append_chunk(schunk, chunk, true);
 1008|   716k|      if (nchunk_ != nchunk + 1) {
  ------------------
  |  Branch (1008:11): [True: 0, False: 716k]
  ------------------
 1009|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1010|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1011|      0|      }
 1012|   716k|    }
 1013|       |
 1014|  6.58k|    if (leftover_items) {
  ------------------
  |  Branch (1014:9): [True: 0, False: 6.58k]
  ------------------
 1015|      0|      int64_t nchunk_ = blosc2_schunk_append_chunk(schunk, chunk2, true);
 1016|      0|      if (nchunk_ != nchunks + 1) {
  ------------------
  |  Branch (1016:11): [True: 0, False: 0]
  ------------------
 1017|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1018|      0|        return BLOSC2_ERROR_SCHUNK_SPECIAL;
 1019|      0|      }
 1020|      0|    }
 1021|  6.58k|    free(chunk);
 1022|  6.58k|    free(chunk2);
 1023|  6.58k|  }
 1024|  3.40k|  else {
 1025|       |    /* Fill an empty frame with special values (fast path). */
 1026|  3.40k|    blosc2_frame_s *frame = (blosc2_frame_s *) schunk->frame;
 1027|  3.40k|    int64_t total_chunks = nchunks + (leftover_items ? 1 : 0);
  ------------------
  |  Branch (1027:39): [True: 0, False: 3.40k]
  ------------------
 1028|  3.40k|    if (!blosc2_nchunks_to_offsets_nbytes(total_chunks, NULL)) {
  ------------------
  |  Branch (1028:9): [True: 0, False: 3.40k]
  ------------------
 1029|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1030|      0|      return BLOSC2_ERROR_FRAME_SPECIAL;
 1031|      0|    }
 1032|       |
 1033|  3.40k|    int64_t old_nchunks = schunk->nchunks;
 1034|  3.40k|    int64_t old_nbytes = schunk->nbytes;
 1035|  3.40k|    int32_t old_chunksize = schunk->chunksize;
 1036|       |
 1037|       |    /* Update counters (necessary for the frame_fill_special() logic) */
 1038|  3.40k|    if (leftover_items) {
  ------------------
  |  Branch (1038:9): [True: 0, False: 3.40k]
  ------------------
 1039|      0|      nchunks += 1;
 1040|      0|    }
 1041|  3.40k|    schunk->chunksize = chunksize;
 1042|  3.40k|    schunk->nchunks = nchunks;
 1043|  3.40k|    schunk->nbytes = nitems * typesize;
 1044|  3.40k|    int rc = frame_lock(frame, true);
 1045|  3.40k|    if (rc < 0) {
  ------------------
  |  Branch (1045:9): [True: 0, False: 3.40k]
  ------------------
 1046|      0|      schunk->chunksize = old_chunksize;
 1047|      0|      schunk->nchunks = old_nchunks;
 1048|      0|      schunk->nbytes = old_nbytes;
 1049|      0|      return rc;
 1050|      0|    }
 1051|  3.40k|    int64_t frame_len = frame_fill_special(frame, nitems, special_value, chunksize, schunk);
 1052|  3.40k|    frame_unlock(frame);
 1053|  3.40k|    if (frame_len < 0) {
  ------------------
  |  Branch (1053:9): [True: 0, False: 3.40k]
  ------------------
 1054|      0|      schunk->chunksize = old_chunksize;
 1055|      0|      schunk->nchunks = old_nchunks;
 1056|      0|      schunk->nbytes = old_nbytes;
 1057|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1058|      0|      return frame_len;
 1059|      0|    }
 1060|  3.40k|  }
 1061|       |
 1062|  9.99k|  return schunk->nchunks;
 1063|  9.99k|}
blosc2_schunk_append_chunk:
 1282|   716k|int64_t blosc2_schunk_append_chunk(blosc2_schunk *schunk, uint8_t *chunk, bool copy) {
 1283|   716k|  return schunk_append_chunk_locked(schunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1283:52): [True: 716k, False: 0]
  ------------------
 1284|   716k|}
blosc2_schunk_insert_chunk:
 1419|   218k|int64_t blosc2_schunk_insert_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy) {
 1420|   218k|  return schunk_insert_chunk_locked(schunk, nchunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1420:60): [True: 0, False: 218k]
  ------------------
 1421|   218k|}
blosc2_schunk_update_chunk:
 1558|  23.6k|int64_t blosc2_schunk_update_chunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk, bool copy) {
 1559|  23.6k|  return schunk_update_chunk_locked(schunk, nchunk, chunk, copy ? CHUNK_COPIED : CHUNK_GIVEN);
  ------------------
  |  Branch (1559:60): [True: 23.6k, False: 0]
  ------------------
 1560|  23.6k|}
schunk_update_chunk_lent:
 1563|   767k|int64_t schunk_update_chunk_lent(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk) {
 1564|   767k|  return schunk_update_chunk_locked(schunk, nchunk, chunk, CHUNK_LENT);
 1565|   767k|}
schunk_scratch_malloc:
 1638|   921k|uint8_t *schunk_scratch_malloc(const blosc2_schunk *schunk, int32_t nbytes, size_t *capacity) {
 1639|   921k|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1639:7): [True: 921k, False: 0]
  ------------------
 1640|   921k|    return blosc2_tmp_malloc((size_t) nbytes, capacity);
 1641|   921k|  }
 1642|      0|  *capacity = 0;
 1643|      0|  return malloc((size_t) nbytes);
 1644|   921k|}
blosc2_schunk_append_buffer:
 1710|     64|int64_t blosc2_schunk_append_buffer(blosc2_schunk *schunk, const void *src, int32_t nbytes) {
 1711|     64|  return schunk_compress_store(schunk, schunk->nchunks, src, nbytes, WRITE_APPEND,
 1712|     64|                               "blosc2_schunk_append_buffer");
 1713|     64|}
blosc2_schunk_decompress_chunk:
 1734|   634k|                                   void *dest, int32_t nbytes) {
 1735|   634k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_decompress_chunk");
 1736|   634k|  if (rc < 0) {
  ------------------
  |  Branch (1736:7): [True: 272, False: 634k]
  ------------------
 1737|    272|    return rc;
 1738|    272|  }
 1739|       |
 1740|   634k|  int32_t chunk_nbytes;
 1741|   634k|  int32_t chunk_cbytes;
 1742|   634k|  int chunksize;
 1743|   634k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1744|       |
 1745|   634k|  schunk->current_nchunk = nchunk;
 1746|   634k|  if (frame == NULL) {
  ------------------
  |  Branch (1746:7): [True: 0, False: 634k]
  ------------------
 1747|      0|    uint8_t* src = schunk->data[nchunk];
 1748|      0|    if (src == 0) {
  ------------------
  |  Branch (1748:9): [True: 0, False: 0]
  ------------------
 1749|      0|      return 0;
 1750|      0|    }
 1751|       |
 1752|      0|    rc = blosc2_cbuffer_sizes(src, &chunk_nbytes, &chunk_cbytes, NULL);
 1753|      0|    if (rc < 0) {
  ------------------
  |  Branch (1753:9): [True: 0, False: 0]
  ------------------
 1754|      0|      return rc;
 1755|      0|    }
 1756|       |
 1757|      0|    if (nbytes < chunk_nbytes) {
  ------------------
  |  Branch (1757:9): [True: 0, False: 0]
  ------------------
 1758|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1759|      0|                        "('%d' bytes, but '%d' are needed).", nbytes, chunk_nbytes);
 1760|      0|      return BLOSC2_ERROR_INVALID_PARAM;
 1761|      0|    }
 1762|       |
 1763|      0|    chunksize = blosc2_decompress_ctx(schunk->dctx, src, chunk_cbytes, dest, nbytes);
 1764|      0|    if (chunksize < 0 || chunksize != chunk_nbytes) {
  ------------------
  |  Branch (1764:9): [True: 0, False: 0]
  |  Branch (1764:26): [True: 0, False: 0]
  ------------------
 1765|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1766|      0|      if (chunksize < 0)
  ------------------
  |  Branch (1766:11): [True: 0, False: 0]
  ------------------
 1767|      0|        return chunksize;
 1768|      0|      return BLOSC2_ERROR_FAILURE;
 1769|      0|    }
 1770|   634k|  } else {
 1771|   634k|    rc = frame_lock(frame, false);
 1772|   634k|    if (rc < 0) {
  ------------------
  |  Branch (1772:9): [True: 0, False: 634k]
  ------------------
 1773|      0|      return rc;
 1774|      0|    }
 1775|   634k|    chunksize = frame_decompress_chunk(schunk->dctx, frame, nchunk, dest, nbytes);
 1776|   634k|    frame_unlock(frame);
 1777|   634k|    if (chunksize < 0) {
  ------------------
  |  Branch (1777:9): [True: 0, False: 634k]
  ------------------
 1778|      0|      return chunksize;
 1779|      0|    }
 1780|   634k|  }
 1781|   634k|  return chunksize;
 1782|   634k|}
blosc2_schunk_get_lazychunk:
 1871|  66.3k|int blosc2_schunk_get_lazychunk(blosc2_schunk *schunk, int64_t nchunk, uint8_t **chunk, bool *needs_free) {
 1872|  66.3k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_get_lazychunk");
 1873|  66.3k|  if (rc < 0) {
  ------------------
  |  Branch (1873:7): [True: 538, False: 65.8k]
  ------------------
 1874|    538|    return rc;
 1875|    538|  }
 1876|       |
 1877|  65.8k|  if (ctx_uses_parallel_backend(schunk->dctx)) {
  ------------------
  |  Branch (1877:7): [True: 0, False: 65.8k]
  ------------------
 1878|      0|    blosc2_pthread_mutex_lock(&schunk->dctx->nchunk_mutex);
  ------------------
  |  |   92|      0|#define blosc2_pthread_mutex_lock(a) pthread_mutex_lock((a))
  ------------------
 1879|      0|    schunk->current_nchunk = nchunk;
 1880|      0|    blosc2_pthread_mutex_unlock(&schunk->dctx->nchunk_mutex);
  ------------------
  |  |   93|      0|#define blosc2_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
  ------------------
 1881|      0|  }
 1882|  65.8k|  else {
 1883|  65.8k|    schunk->current_nchunk = nchunk;
 1884|  65.8k|  }
 1885|  65.8k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1886|  65.8k|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1886:7): [True: 65.8k, False: 0]
  ------------------
 1887|  65.8k|    rc = frame_lock(frame, false);
 1888|  65.8k|    if (rc < 0) {
  ------------------
  |  Branch (1888:9): [True: 0, False: 65.8k]
  ------------------
 1889|      0|      return rc;
 1890|      0|    }
 1891|  65.8k|    rc = frame_get_lazychunk(frame, nchunk, chunk, needs_free);
 1892|  65.8k|    frame_unlock(frame);
 1893|  65.8k|    return rc;
 1894|  65.8k|  }
 1895|       |
 1896|      0|  *chunk = schunk->data[nchunk];
 1897|      0|  if (*chunk == 0) {
  ------------------
  |  Branch (1897:7): [True: 0, False: 0]
  ------------------
 1898|      0|    *needs_free = 0;
 1899|      0|    return 0;
 1900|      0|  }
 1901|       |
 1902|      0|  *needs_free = false;
 1903|      0|  int32_t chunk_cbytes;
 1904|      0|  rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, NULL);
 1905|      0|  if (rc < 0) {
  ------------------
  |  Branch (1905:7): [True: 0, False: 0]
  ------------------
 1906|      0|    return rc;
 1907|      0|  }
 1908|      0|  return (int)chunk_cbytes;
 1909|      0|}
schunk_decompress_masked:
 1994|   232k|                             void *user_data, void *dest, int32_t destsize) {
 1995|   232k|  blosc2_context *dctx = schunk->dctx;
 1996|   232k|  int rc = blosc2_set_maskout(dctx, (bool *) maskout, nblocks);
 1997|   232k|  if (rc < 0) {
  ------------------
  |  Branch (1997:7): [True: 0, False: 232k]
  ------------------
 1998|      0|    return rc;
 1999|      0|  }
 2000|   232k|  blosc2_postfilter_fn saved_postfilter = dctx->postfilter;
 2001|   232k|  blosc2_postfilter_params *saved_postparams = dctx->postparams;
 2002|   232k|  blosc2_postfilter_params params;
 2003|   232k|  if (postfilter != NULL) {
  ------------------
  |  Branch (2003:7): [True: 229k, False: 2.58k]
  ------------------
 2004|   229k|    memset(&params, 0, sizeof(params));
 2005|   229k|    params.user_data = user_data;
 2006|   229k|    dctx->postfilter = postfilter;
 2007|   229k|    dctx->postparams = &params;
 2008|   229k|  }
 2009|   232k|  if (chunk != NULL) {
  ------------------
  |  Branch (2009:7): [True: 0, False: 232k]
  ------------------
 2010|      0|    rc = blosc2_decompress_ctx(dctx, chunk, cbytes, dest, destsize);
 2011|      0|  }
 2012|   232k|  else {
 2013|   232k|    rc = blosc2_schunk_decompress_chunk(schunk, nchunk, dest, destsize);
 2014|   232k|  }
 2015|   232k|  dctx->postfilter = saved_postfilter;
 2016|   232k|  dctx->postparams = saved_postparams;
 2017|       |  // A decompression that failed early, or a missing chunk, leaves the mask set
 2018|   232k|  ctx_clear_maskout(dctx);
 2019|   232k|  return rc;
 2020|   232k|}
metalayer_flush:
 2802|  12.4k|int metalayer_flush(blosc2_schunk* schunk) {
 2803|  12.4k|  int rc = BLOSC2_ERROR_SUCCESS;
 2804|  12.4k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 2805|  12.4k|  if (frame == NULL) {
  ------------------
  |  Branch (2805:7): [True: 7.37k, False: 5.10k]
  ------------------
 2806|  7.37k|    return rc;
 2807|  7.37k|  }
 2808|  5.10k|  rc = frame_lock(frame, true);
 2809|  5.10k|  if (rc < 0) {
  ------------------
  |  Branch (2809:7): [True: 0, False: 5.10k]
  ------------------
 2810|      0|    return rc;
 2811|      0|  }
 2812|  5.10k|  rc = frame_update_header(frame, schunk, true);
 2813|  5.10k|  if (rc < 0) {
  ------------------
  |  Branch (2813:7): [True: 0, False: 5.10k]
  ------------------
 2814|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2815|      0|    frame_unlock(frame);
 2816|      0|    return rc;
 2817|      0|  }
 2818|  5.10k|  rc = frame_update_trailer(frame, schunk);
 2819|  5.10k|  if (rc < 0) {
  ------------------
  |  Branch (2819:7): [True: 0, False: 5.10k]
  ------------------
 2820|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2821|      0|    frame_unlock(frame);
 2822|      0|    return rc;
 2823|      0|  }
 2824|  5.10k|  frame_unlock(frame);
 2825|  5.10k|  return rc;
 2826|  5.10k|}
blosc2_meta_add:
 2833|  12.4k|int blosc2_meta_add(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len) {
 2834|  12.4k|  if (schunk == NULL || name == NULL) {
  ------------------
  |  Branch (2834:7): [True: 0, False: 12.4k]
  |  Branch (2834:25): [True: 0, False: 12.4k]
  ------------------
 2835|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2836|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2837|      0|  }
 2838|  12.4k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2839|  12.4k|  if (nmetalayer >= 0) {
  ------------------
  |  Branch (2839:7): [True: 0, False: 12.4k]
  ------------------
 2840|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2841|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2842|      0|  }
 2843|  12.4k|  if (content_len < 0) {
  ------------------
  |  Branch (2843:7): [True: 0, False: 12.4k]
  ------------------
 2844|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2845|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2846|      0|  }
 2847|  12.4k|  if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (2847:7): [True: 12.4k, False: 0]
  |  Branch (2847:26): [True: 0, False: 12.4k]
  ------------------
 2848|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2849|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2850|      0|  }
 2851|       |
 2852|       |  // Add the metalayer
 2853|  12.4k|  blosc2_metalayer *metalayer = malloc(sizeof(blosc2_metalayer));
 2854|  12.4k|  BLOSC_ERROR_NULL(metalayer, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  12.4k|    do {                                            \
  |  |  105|  12.4k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 12.4k]
  |  |  ------------------
  |  |  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|  12.4k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 12.4k]
  |  |  ------------------
  ------------------
 2855|       |
 2856|  12.4k|  char* name_ = malloc(strlen(name) + 1);
 2857|  12.4k|  if (name_ == NULL) {
  ------------------
  |  Branch (2857:7): [True: 0, False: 12.4k]
  ------------------
 2858|      0|    free(metalayer);
 2859|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2860|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2861|      0|  }
 2862|  12.4k|  strcpy(name_, name);
 2863|  12.4k|  metalayer->name = name_;
 2864|       |
 2865|  12.4k|  uint8_t* content_buf = malloc((size_t)content_len);
 2866|  12.4k|  if (content_buf == NULL && content_len > 0) {
  ------------------
  |  Branch (2866:7): [True: 0, False: 12.4k]
  |  Branch (2866:30): [True: 0, False: 0]
  ------------------
 2867|      0|    free(name_);
 2868|      0|    free(metalayer);
 2869|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2870|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2871|      0|  }
 2872|  12.4k|  if (content_len > 0) {
  ------------------
  |  Branch (2872:7): [True: 12.4k, False: 0]
  ------------------
 2873|  12.4k|    memcpy(content_buf, content, content_len);
 2874|  12.4k|  }
 2875|  12.4k|  metalayer->content = content_buf;
 2876|  12.4k|  metalayer->content_len = content_len;
 2877|  12.4k|  schunk->metalayers[schunk->nmetalayers] = metalayer;
 2878|  12.4k|  schunk->nmetalayers += 1;
 2879|       |
 2880|  12.4k|  int rc = metalayer_flush(schunk);
 2881|  12.4k|  if (rc < 0) {
  ------------------
  |  Branch (2881:7): [True: 0, False: 12.4k]
  ------------------
 2882|      0|    return rc;
 2883|      0|  }
 2884|  12.4k|  schunk->change_tick++;
 2885|       |
 2886|  12.4k|  return schunk->nmetalayers - 1;
 2887|  12.4k|}
blosc2_meta_update:
 2894|  1.30k|int blosc2_meta_update(blosc2_schunk *schunk, const char *name, uint8_t *content, int32_t content_len) {
 2895|  1.30k|  if (schunk == NULL || name == NULL) {
  ------------------
  |  Branch (2895:7): [True: 0, False: 1.30k]
  |  Branch (2895:25): [True: 0, False: 1.30k]
  ------------------
 2896|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2897|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2898|      0|  }
 2899|  1.30k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2900|  1.30k|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2900:7): [True: 0, False: 1.30k]
  ------------------
 2901|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2902|      0|    return nmetalayer;
 2903|      0|  }
 2904|  1.30k|  if (content_len < 0) {
  ------------------
  |  Branch (2904:7): [True: 0, False: 1.30k]
  ------------------
 2905|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2906|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2907|      0|  }
 2908|  1.30k|  if (content_len > 0 && content == NULL) {
  ------------------
  |  Branch (2908:7): [True: 1.30k, False: 0]
  |  Branch (2908:26): [True: 0, False: 1.30k]
  ------------------
 2909|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2910|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2911|      0|  }
 2912|       |
 2913|  1.30k|  blosc2_metalayer *metalayer = schunk->metalayers[nmetalayer];
 2914|  1.30k|  if (content_len > metalayer->content_len) {
  ------------------
  |  Branch (2914:7): [True: 0, False: 1.30k]
  ------------------
 2915|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|      0|    return nmetalayer;
 2917|      0|  }
 2918|       |
 2919|       |  // Update the contents of the metalayer
 2920|  1.30k|  if (content_len > 0) {
  ------------------
  |  Branch (2920:7): [True: 1.30k, False: 0]
  ------------------
 2921|  1.30k|    memmove(metalayer->content, content, content_len);
 2922|  1.30k|  }
 2923|       |
 2924|       |  // Update the metalayers in frame (as size has not changed, we don't need to update the trailer)
 2925|  1.30k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 2926|  1.30k|  if (frame != NULL) {
  ------------------
  |  Branch (2926:7): [True: 1.30k, False: 0]
  ------------------
 2927|  1.30k|    int rc = frame_lock(frame, true);
 2928|  1.30k|    if (rc < 0) {
  ------------------
  |  Branch (2928:9): [True: 0, False: 1.30k]
  ------------------
 2929|      0|      return rc;
 2930|      0|    }
 2931|  1.30k|    rc = frame_update_header(frame, schunk, false);
 2932|  1.30k|    frame_unlock(frame);
 2933|  1.30k|    if (rc < 0) {
  ------------------
  |  Branch (2933:9): [True: 0, False: 1.30k]
  ------------------
 2934|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2935|      0|      return rc;
 2936|      0|    }
 2937|  1.30k|  }
 2938|  1.30k|  schunk->change_tick++;
 2939|       |
 2940|  1.30k|  return nmetalayer;
 2941|  1.30k|}
schunk.c:schunk_append_chunk_locked:
 1261|   716k|static int64_t schunk_append_chunk_locked(blosc2_schunk *schunk, uint8_t *chunk, chunk_handover how) {
 1262|   716k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1263|   716k|  int rc = frame_lock(frame, true);
 1264|   716k|  if (rc < 0) {
  ------------------
  |  Branch (1264:7): [True: 0, False: 716k]
  ------------------
 1265|      0|    return rc;
 1266|      0|  }
 1267|       |  // Sync the cached counters before the delta below is applied to them, so a
 1268|       |  // handle whose lock acquisition just flagged staleness does not persist
 1269|       |  // wrong nbytes/cbytes/nchunks (see plans/todo-locking-swmr.md item 1).
 1270|   716k|  rc = frame_check_stale(frame);
 1271|   716k|  if (rc < 0) {
  ------------------
  |  Branch (1271:7): [True: 0, False: 716k]
  ------------------
 1272|      0|    frame_unlock(frame);
 1273|      0|    return rc;
 1274|      0|  }
 1275|   716k|  int64_t nchunks = schunk_append_chunk_unlocked(schunk, chunk, how);
 1276|   716k|  frame_unlock(frame);
 1277|   716k|  return nchunks;
 1278|   716k|}
schunk.c:schunk_append_chunk_unlocked:
 1163|   716k|static int64_t schunk_append_chunk_unlocked(blosc2_schunk *schunk, uint8_t *chunk, chunk_handover how) {
 1164|   716k|  int32_t chunk_nbytes;
 1165|   716k|  int32_t chunk_cbytes;
 1166|   716k|  int64_t nchunks = schunk->nchunks;
 1167|       |
 1168|   716k|  int rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1169|   716k|  if (rc < 0) {
  ------------------
  |  Branch (1169:7): [True: 0, False: 716k]
  ------------------
 1170|      0|    return rc;
 1171|      0|  }
 1172|       |  // Saved, so that the super-chunk is left unchanged if appending to the frame fails
 1173|   716k|  uint8_t old_flags2 = schunk->flags2;
 1174|   716k|  int32_t old_chunksize = schunk->chunksize;
 1175|   716k|  int64_t old_current_nchunk = schunk->current_nchunk;
 1176|   716k|  int64_t old_nbytes = schunk->nbytes;
 1177|   716k|  int64_t old_cbytes = schunk->cbytes;
 1178|       |
 1179|   716k|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1180|   716k|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1181|   716k|  if (nchunks > 0) {
  ------------------
  |  Branch (1181:7): [True: 710k, False: 6.60k]
  ------------------
 1182|   710k|    uint8_t first_flags2;
 1183|   710k|    rc = schunk_get_chunk_flags2(schunk, 0, &first_flags2);
 1184|   710k|    if (rc < 0) {
  ------------------
  |  Branch (1184:9): [True: 0, False: 710k]
  ------------------
 1185|      0|      return rc;
 1186|      0|    }
 1187|   710k|    if (((first_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1187:9): [True: 0, False: 710k]
  ------------------
 1188|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1189|      0|      return BLOSC2_ERROR_CHUNK_APPEND;
 1190|      0|    }
 1191|   710k|  }
 1192|  6.60k|  else {
 1193|  6.60k|    schunk->flags2 = flags2;
 1194|  6.60k|  }
 1195|       |
 1196|   716k|  int32_t last_nbytes = 0;
 1197|   716k|  if (schunk->chunksize != 0 && nchunks > 0) {
  ------------------
  |  Branch (1197:7): [True: 716k, False: 0]
  |  Branch (1197:33): [True: 710k, False: 6.60k]
  ------------------
 1198|   710k|    rc = schunk_get_chunk_nbytes(schunk, nchunks - 1, &last_nbytes);
 1199|   710k|    if (rc < 0) {
  ------------------
  |  Branch (1199:9): [True: 0, False: 710k]
  ------------------
 1200|      0|      return rc;
 1201|      0|    }
 1202|   710k|  }
 1203|   716k|  int32_t chunksize = schunk->chunksize;
 1204|   716k|  if (!chunksize_after_adding(&schunk->chunksize, nchunks, last_nbytes, chunk_nbytes, true)) {
  ------------------
  |  Branch (1204:7): [True: 0, False: 716k]
  ------------------
 1205|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1206|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1207|      0|    return BLOSC2_ERROR_CHUNK_APPEND;
 1208|      0|  }
 1209|       |
 1210|       |  /* Update counters */
 1211|   716k|  schunk->current_nchunk = nchunks;
 1212|   716k|  schunk->nchunks = nchunks + 1;
 1213|   716k|  schunk->nbytes += chunk_nbytes;
 1214|       |  // A frame codes special chunks in their offsets
 1215|   716k|  if (schunk->frame == NULL || !chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1215:7): [True: 716k, False: 64]
  |  Branch (1215:32): [True: 63, False: 1]
  ------------------
 1216|   716k|    schunk->cbytes += chunk_cbytes;
 1217|   716k|  }
 1218|       |
 1219|   716k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1220|   716k|  bool private_copy = chunk_needs_private_copy(frame, how);
 1221|   716k|  if (private_copy) {
  ------------------
  |  Branch (1221:7): [True: 716k, False: 64]
  ------------------
 1222|       |    // Make a copy of the chunk
 1223|   716k|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1224|   716k|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1225|   716k|    chunk = chunk_copy;
 1226|   716k|  }
 1227|       |
 1228|       |  // Update super-chunk or frame
 1229|   716k|  if (frame == NULL) {
  ------------------
  |  Branch (1229:7): [True: 716k, False: 64]
  ------------------
 1230|   716k|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1230:9): [True: 0, False: 716k]
  |  Branch (1230:31): [True: 0, False: 0]
  ------------------
 1231|       |      // We still want to do a shrink of the chunk
 1232|      0|      chunk = realloc(chunk, chunk_cbytes);
 1233|      0|    }
 1234|       |
 1235|       |    /* Make space for appending the copy of the chunk and do it */
 1236|   716k|    if ((nchunks + 1) * sizeof(void *) > schunk->data_len) {
  ------------------
  |  Branch (1236:9): [True: 7.58k, False: 709k]
  ------------------
 1237|       |      // Extend the data pointer by one memory page (4k)
 1238|  7.58k|      schunk->data_len += 4096;  // must be a multiple of sizeof(void*)
 1239|  7.58k|      schunk->data = realloc(schunk->data, schunk->data_len);
 1240|  7.58k|    }
 1241|   716k|    schunk->data[nchunks] = chunk;
 1242|   716k|  }
 1243|     64|  else {
 1244|     64|    bool written = frame_append_chunk(frame, chunk, schunk) != NULL;
 1245|     64|    frame_write_done(chunk, how, private_copy, written);
 1246|     64|    if (!written) {
  ------------------
  |  Branch (1246:9): [True: 0, False: 64]
  ------------------
 1247|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1248|      0|      schunk->flags2 = old_flags2;
 1249|      0|      schunk->chunksize = old_chunksize;
 1250|      0|      schunk->current_nchunk = old_current_nchunk;
 1251|      0|      schunk->nchunks = nchunks;
 1252|      0|      schunk->nbytes = old_nbytes;
 1253|      0|      schunk->cbytes = old_cbytes;
 1254|      0|      return BLOSC2_ERROR_CHUNK_APPEND;
 1255|      0|    }
 1256|     64|  }
 1257|   716k|  return schunk->nchunks;
 1258|   716k|}
schunk.c:schunk_get_chunk_flags2:
 1097|  1.71M|static int schunk_get_chunk_flags2(blosc2_schunk *schunk, int64_t nchunk, uint8_t *chunk_flags2) {
 1098|  1.71M|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1099|  1.71M|  const uint8_t *chunk;
 1100|  1.71M|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1101|  1.71M|  if (rc < 0) {
  ------------------
  |  Branch (1101:7): [True: 0, False: 1.71M]
  ------------------
 1102|      0|    return rc;
 1103|      0|  }
 1104|  1.71M|  if (chunk == NULL) {
  ------------------
  |  Branch (1104:7): [True: 0, False: 1.71M]
  ------------------
 1105|      0|    return BLOSC2_ERROR_DATA;
 1106|      0|  }
 1107|  1.71M|  *chunk_flags2 = get_chunk_flags2(chunk, rc);
 1108|  1.71M|  return 0;
 1109|  1.71M|}
schunk.c:schunk_get_chunk_header:
 1070|  3.43M|                                   const uint8_t **chunk) {
 1071|  3.43M|  if (schunk->frame != NULL) {
  ------------------
  |  Branch (1071:7): [True: 2.01M, False: 1.42M]
  ------------------
 1072|  2.01M|    *chunk = header;
 1073|  2.01M|    return frame_get_chunk_header((blosc2_frame_s *)schunk->frame, nchunk, header);
 1074|  2.01M|  }
 1075|  1.42M|  *chunk = schunk->data[nchunk];
 1076|  1.42M|  if (*chunk == NULL) {
  ------------------
  |  Branch (1076:7): [True: 0, False: 1.42M]
  ------------------
 1077|      0|    return 0;
 1078|      0|  }
 1079|  1.42M|  int32_t chunk_cbytes;
 1080|  1.42M|  int rc = blosc2_cbuffer_sizes(*chunk, NULL, &chunk_cbytes, NULL);
 1081|  1.42M|  return rc < 0 ? rc : chunk_cbytes;
  ------------------
  |  Branch (1081:10): [True: 0, False: 1.42M]
  ------------------
 1082|  1.42M|}
schunk.c:schunk_get_chunk_nbytes:
 1084|   928k|static int schunk_get_chunk_nbytes(blosc2_schunk *schunk, int64_t nchunk, int32_t *chunk_nbytes) {
 1085|   928k|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1086|   928k|  const uint8_t *chunk;
 1087|   928k|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1088|   928k|  if (rc < 0) {
  ------------------
  |  Branch (1088:7): [True: 0, False: 928k]
  ------------------
 1089|      0|    return rc;
 1090|      0|  }
 1091|   928k|  if (chunk == NULL) {
  ------------------
  |  Branch (1091:7): [True: 0, False: 928k]
  ------------------
 1092|      0|    return BLOSC2_ERROR_DATA;
 1093|      0|  }
 1094|   928k|  return blosc2_cbuffer_sizes(chunk, chunk_nbytes, NULL, NULL);
 1095|   928k|}
schunk.c:chunk_needs_private_copy:
 1147|  1.72M|static bool chunk_needs_private_copy(const blosc2_frame_s *frame, chunk_handover how) {
 1148|  1.72M|  return how == CHUNK_COPIED || (how == CHUNK_LENT && frame == NULL);
  ------------------
  |  Branch (1148:10): [True: 740k, False: 986k]
  |  Branch (1148:34): [True: 767k, False: 218k]
  |  Branch (1148:55): [True: 0, False: 767k]
  ------------------
 1149|  1.72M|}
schunk.c:frame_write_done:
 1155|  1.00M|static void frame_write_done(uint8_t *chunk, chunk_handover how, bool private_copy, bool written) {
 1156|  1.00M|  if (private_copy || (written && how == CHUNK_GIVEN)) {
  ------------------
  |  Branch (1156:7): [True: 23.6k, False: 986k]
  |  Branch (1156:24): [True: 986k, False: 0]
  |  Branch (1156:35): [True: 218k, False: 767k]
  ------------------
 1157|   242k|    free(chunk);
 1158|   242k|  }
 1159|  1.00M|}
schunk.c:schunk_insert_chunk_locked:
 1399|   218k|                                          chunk_handover how) {
 1400|   218k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1401|   218k|  int rc = frame_lock(frame, true);
 1402|   218k|  if (rc < 0) {
  ------------------
  |  Branch (1402:7): [True: 0, False: 218k]
  ------------------
 1403|      0|    return rc;
 1404|      0|  }
 1405|       |  // See schunk_append_chunk_locked() for why this must happen before the
 1406|       |  // counter deltas below are applied.
 1407|   218k|  rc = frame_check_stale(frame);
 1408|   218k|  if (rc < 0) {
  ------------------
  |  Branch (1408:7): [True: 0, False: 218k]
  ------------------
 1409|      0|    frame_unlock(frame);
 1410|      0|    return rc;
 1411|      0|  }
 1412|   218k|  int64_t nchunks = schunk_insert_chunk_unlocked(schunk, nchunk, chunk, how);
 1413|   218k|  frame_unlock(frame);
 1414|   218k|  return nchunks;
 1415|   218k|}
schunk.c:schunk_insert_chunk_unlocked:
 1289|   218k|                                            chunk_handover how) {
 1290|   218k|  int rc = validate_nchunk(schunk, nchunk, true, "blosc2_schunk_insert_chunk");
 1291|   218k|  if (rc < 0) {
  ------------------
  |  Branch (1291:7): [True: 0, False: 218k]
  ------------------
 1292|      0|    return rc;
 1293|      0|  }
 1294|       |
 1295|   218k|  int32_t chunk_nbytes;
 1296|   218k|  int32_t chunk_cbytes;
 1297|   218k|  int64_t nchunks = schunk->nchunks;
 1298|       |
 1299|   218k|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1300|   218k|  if (rc < 0) {
  ------------------
  |  Branch (1300:7): [True: 0, False: 218k]
  ------------------
 1301|      0|    return rc;
 1302|      0|  }
 1303|       |  // Saved, so that the super-chunk is left unchanged if inserting into the frame fails
 1304|   218k|  uint8_t old_flags2 = schunk->flags2;
 1305|   218k|  int32_t old_chunksize = schunk->chunksize;
 1306|   218k|  int64_t old_current_nchunk = schunk->current_nchunk;
 1307|   218k|  int64_t old_nbytes = schunk->nbytes;
 1308|   218k|  int64_t old_cbytes = schunk->cbytes;
 1309|   218k|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1310|   218k|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1311|   218k|  if (nchunks > 0) {
  ------------------
  |  Branch (1311:7): [True: 218k, False: 243]
  ------------------
 1312|   218k|    uint8_t first_flags2;
 1313|   218k|    rc = schunk_get_chunk_flags2(schunk, 0, &first_flags2);
 1314|   218k|    if (rc < 0) {
  ------------------
  |  Branch (1314:9): [True: 0, False: 218k]
  ------------------
 1315|      0|      return rc;
 1316|      0|    }
 1317|   218k|    if (((first_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1317:9): [True: 0, False: 218k]
  ------------------
 1318|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1319|      0|      return BLOSC2_ERROR_CHUNK_INSERT;
 1320|      0|    }
 1321|   218k|  }
 1322|    243|  else {
 1323|    243|    schunk->flags2 = flags2;
 1324|    243|  }
 1325|       |
 1326|   218k|  int32_t last_nbytes = 0;
 1327|   218k|  if (schunk->chunksize != 0 && nchunks > 0) {
  ------------------
  |  Branch (1327:7): [True: 218k, False: 0]
  |  Branch (1327:33): [True: 218k, False: 243]
  ------------------
 1328|   218k|    rc = schunk_get_chunk_nbytes(schunk, nchunks - 1, &last_nbytes);
 1329|   218k|    if (rc < 0) {
  ------------------
  |  Branch (1329:9): [True: 0, False: 218k]
  ------------------
 1330|      0|      return rc;
 1331|      0|    }
 1332|   218k|  }
 1333|   218k|  int32_t chunksize = schunk->chunksize;
 1334|   218k|  if (!chunksize_after_adding(&schunk->chunksize, nchunks, last_nbytes, chunk_nbytes,
  ------------------
  |  Branch (1334:7): [True: 0, False: 218k]
  ------------------
 1335|   218k|                              nchunk == nchunks)) {
 1336|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1337|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1338|      0|    return BLOSC2_ERROR_CHUNK_INSERT;
 1339|      0|  }
 1340|       |
 1341|       |  /* Update counters */
 1342|   218k|  schunk->current_nchunk = nchunk;
 1343|   218k|  schunk->nchunks = nchunks + 1;
 1344|   218k|  schunk->nbytes += chunk_nbytes;
 1345|       |  // A frame codes special chunks in their offsets
 1346|   218k|  if (schunk->frame == NULL || !chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1346:7): [True: 0, False: 218k]
  |  Branch (1346:32): [True: 0, False: 218k]
  ------------------
 1347|      0|    schunk->cbytes += chunk_cbytes;
 1348|      0|  }
 1349|       |
 1350|   218k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1351|   218k|  bool private_copy = chunk_needs_private_copy(frame, how);
 1352|   218k|  if (private_copy) {
  ------------------
  |  Branch (1352:7): [True: 0, False: 218k]
  ------------------
 1353|       |    // Make a copy of the chunk
 1354|      0|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1355|      0|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1356|      0|    chunk = chunk_copy;
 1357|      0|  }
 1358|       |
 1359|       |  // Update super-chunk or frame
 1360|   218k|  if (frame == NULL) {
  ------------------
  |  Branch (1360:7): [True: 0, False: 218k]
  ------------------
 1361|      0|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1361:9): [True: 0, False: 0]
  |  Branch (1361:31): [True: 0, False: 0]
  ------------------
 1362|       |      // We still want to do a shrink of the chunk
 1363|      0|      chunk = realloc(chunk, chunk_cbytes);
 1364|      0|    }
 1365|       |
 1366|       |    // Make space for appending the copy of the chunk and do it
 1367|      0|    if ((nchunks + 1) * sizeof(void *) > schunk->data_len) {
  ------------------
  |  Branch (1367:9): [True: 0, False: 0]
  ------------------
 1368|       |      // Extend the data pointer by one memory page (4k)
 1369|      0|      schunk->data_len += 4096;  // must be a multiple of sizeof(void*)
 1370|      0|      schunk->data = realloc(schunk->data, schunk->data_len);
 1371|      0|    }
 1372|       |
 1373|       |    // Reorder the offsets and insert the new chunk
 1374|      0|    for (int64_t i = nchunks; i > nchunk; --i) {
  ------------------
  |  Branch (1374:31): [True: 0, False: 0]
  ------------------
 1375|      0|      schunk->data[i] = schunk->data[i-1];
 1376|      0|    }
 1377|      0|    schunk->data[nchunk] = chunk;
 1378|      0|  }
 1379|       |
 1380|   218k|  else {
 1381|   218k|    bool written = frame_insert_chunk(frame, nchunk, chunk, schunk) != NULL;
 1382|   218k|    frame_write_done(chunk, how, private_copy, written);
 1383|   218k|    if (!written) {
  ------------------
  |  Branch (1383:9): [True: 0, False: 218k]
  ------------------
 1384|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|      0|      schunk->flags2 = old_flags2;
 1386|      0|      schunk->chunksize = old_chunksize;
 1387|      0|      schunk->current_nchunk = old_current_nchunk;
 1388|      0|      schunk->nchunks = nchunks;
 1389|      0|      schunk->nbytes = old_nbytes;
 1390|      0|      schunk->cbytes = old_cbytes;
 1391|      0|      return BLOSC2_ERROR_CHUNK_INSERT;
 1392|      0|    }
 1393|   218k|  }
 1394|   218k|  return schunk->nchunks;
 1395|   218k|}
schunk.c:schunk_update_chunk_locked:
 1546|   791k|                                          chunk_handover how) {
 1547|   791k|  blosc2_frame_s* frame = (blosc2_frame_s*)schunk->frame;
 1548|   791k|  int rc = frame_lock(frame, true);
 1549|   791k|  if (rc < 0) {
  ------------------
  |  Branch (1549:7): [True: 0, False: 791k]
  ------------------
 1550|      0|    return rc;
 1551|      0|  }
 1552|   791k|  int64_t nchunks = schunk_update_chunk_unlocked(schunk, nchunk, chunk, how);
 1553|   791k|  frame_unlock(frame);
 1554|   791k|  return nchunks;
 1555|   791k|}
schunk.c:schunk_update_chunk_unlocked:
 1425|   791k|                                            chunk_handover how) {
 1426|   791k|  int rc = validate_nchunk(schunk, nchunk, false, "blosc2_schunk_update_chunk");
 1427|   791k|  if (rc < 0) {
  ------------------
  |  Branch (1427:7): [True: 118, False: 791k]
  ------------------
 1428|    118|    return rc;
 1429|    118|  }
 1430|       |
 1431|   791k|  uint8_t old_flags2 = schunk->flags2;
 1432|   791k|  int32_t old_chunksize = schunk->chunksize;
 1433|   791k|  int64_t old_current_nchunk = schunk->current_nchunk;
 1434|   791k|  int64_t old_nbytes = schunk->nbytes;
 1435|   791k|  int64_t old_cbytes = schunk->cbytes;
 1436|       |
 1437|   791k|  int32_t chunk_nbytes;
 1438|   791k|  int32_t chunk_cbytes;
 1439|       |
 1440|   791k|  rc = blosc2_cbuffer_sizes(chunk, &chunk_nbytes, &chunk_cbytes, NULL);
 1441|   791k|  if (rc < 0) {
  ------------------
  |  Branch (1441:7): [True: 0, False: 791k]
  ------------------
 1442|      0|    return rc;
 1443|      0|  }
 1444|   791k|  uint8_t flags2 = get_chunk_flags2(chunk, chunk_cbytes);
 1445|   791k|  bool chunk_vlblocks = (flags2 & BLOSC2_VL_BLOCKS) != 0;
 1446|   791k|  if (schunk->nchunks > 1 || (schunk->nchunks == 1 && nchunk != 0)) {
  ------------------
  |  Branch (1446:7): [True: 790k, False: 875]
  |  Branch (1446:31): [True: 875, False: 0]
  |  Branch (1446:55): [True: 0, False: 875]
  ------------------
 1447|   790k|    int64_t ref_nchunk = (nchunk == 0) ? 1 : 0;
  ------------------
  |  Branch (1447:26): [True: 3.39k, False: 786k]
  ------------------
 1448|   790k|    uint8_t ref_flags2;
 1449|   790k|    rc = schunk_get_chunk_flags2(schunk, ref_nchunk, &ref_flags2);
 1450|   790k|    if (rc < 0) {
  ------------------
  |  Branch (1450:9): [True: 0, False: 790k]
  ------------------
 1451|      0|      return rc;
 1452|      0|    }
 1453|   790k|    if (((ref_flags2 & BLOSC2_VL_BLOCKS) != 0) != chunk_vlblocks) {
  ------------------
  |  Branch (1453:9): [True: 0, False: 790k]
  ------------------
 1454|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1455|      0|      return BLOSC2_ERROR_CHUNK_UPDATE;
 1456|      0|    }
 1457|   790k|  }
 1458|    875|  else {
 1459|    875|    schunk->flags2 = flags2;
 1460|    875|  }
 1461|       |
 1462|   791k|  int32_t chunksize = schunk->chunksize;
 1463|   791k|  bool variable_chunksize = (chunksize == 0);
 1464|   791k|  if (chunksize == -1) {
  ------------------
  |  Branch (1464:7): [True: 0, False: 791k]
  ------------------
 1465|      0|    schunk->chunksize = chunk_nbytes;  // The super-chunk is initialized now
 1466|      0|    chunksize = schunk->chunksize;
 1467|      0|  }
 1468|       |
 1469|   791k|  if (!variable_chunksize && (chunk_nbytes > chunksize ||
  ------------------
  |  Branch (1469:7): [True: 791k, False: 0]
  |  Branch (1469:31): [True: 0, False: 791k]
  ------------------
 1470|   791k|      (nchunk != schunk->nchunks - 1 && chunk_nbytes != chunksize))) {
  ------------------
  |  Branch (1470:8): [True: 786k, False: 4.25k]
  |  Branch (1470:41): [True: 0, False: 786k]
  ------------------
 1471|      0|    variable_chunksize = true;
 1472|      0|    schunk->chunksize = 0;
 1473|      0|  }
 1474|   791k|  if (!variable_chunksize && chunksize > 0 && chunk_nbytes > chunksize) {
  ------------------
  |  Branch (1474:7): [True: 791k, False: 0]
  |  Branch (1474:30): [True: 791k, False: 0]
  |  Branch (1474:47): [True: 0, False: 791k]
  ------------------
 1475|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|      0|                      "is not supported yet: %d > %d.", chunk_nbytes, chunksize);
 1477|      0|    return BLOSC2_ERROR_CHUNK_UPDATE;
 1478|      0|  }
 1479|       |
 1480|       |  // Only the sizes of the old chunk are needed, so do not read all of it from disk
 1481|   791k|  int32_t chunk_nbytes_old;
 1482|   791k|  int32_t chunk_cbytes_old;
 1483|   791k|  rc = schunk_get_counted_sizes(schunk, nchunk, &chunk_nbytes_old, &chunk_cbytes_old);
 1484|   791k|  if (rc < 0) {
  ------------------
  |  Branch (1484:7): [True: 0, False: 791k]
  ------------------
 1485|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1486|      0|    return rc;
 1487|      0|  }
 1488|   791k|  schunk->current_nchunk = nchunk;
 1489|       |
 1490|   791k|  blosc2_frame_s* frame = (blosc2_frame_s*)(schunk->frame);
 1491|   791k|  bool private_copy = chunk_needs_private_copy(frame, how);
 1492|   791k|  if (private_copy) {
  ------------------
  |  Branch (1492:7): [True: 23.6k, False: 767k]
  ------------------
 1493|       |    // Make a copy of the chunk
 1494|  23.6k|    uint8_t *chunk_copy = malloc(chunk_cbytes);
 1495|  23.6k|    memcpy(chunk_copy, chunk, chunk_cbytes);
 1496|  23.6k|    chunk = chunk_copy;
 1497|  23.6k|  }
 1498|       |
 1499|   791k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (1499:7): [True: 0, False: 791k]
  ------------------
 1500|       |    /* Update counters */
 1501|      0|    schunk->nbytes += chunk_nbytes;
 1502|      0|    schunk->nbytes -= chunk_nbytes_old;
 1503|      0|    schunk->cbytes += chunk_cbytes;
 1504|      0|    schunk->cbytes -= chunk_cbytes_old;
 1505|   791k|  } else {
 1506|       |    // A frame codes special chunks in their offsets
 1507|   791k|    schunk->nbytes += chunk_nbytes;
 1508|   791k|    schunk->nbytes -= chunk_nbytes_old;
 1509|   791k|    if (!chunk_special_in_offset(chunk, chunk_cbytes)) {
  ------------------
  |  Branch (1509:9): [True: 633k, False: 157k]
  ------------------
 1510|   633k|      schunk->cbytes += chunk_cbytes;
 1511|   633k|    }
 1512|   791k|    schunk->cbytes -= chunk_cbytes_old;
 1513|   791k|  }
 1514|       |
 1515|       |  // Update super-chunk or frame
 1516|   791k|  if (schunk->frame == NULL) {
  ------------------
  |  Branch (1516:7): [True: 0, False: 791k]
  ------------------
 1517|      0|    if (how == CHUNK_GIVEN && (chunk_cbytes < chunk_nbytes)) {
  ------------------
  |  Branch (1517:9): [True: 0, False: 0]
  |  Branch (1517:31): [True: 0, False: 0]
  ------------------
 1518|       |      // We still want to do a shrink of the chunk
 1519|      0|      chunk = realloc(chunk, chunk_cbytes);
 1520|      0|    }
 1521|       |
 1522|       |    // Free old chunk and add reference to new chunk
 1523|      0|    if (schunk->data[nchunk] != 0) {
  ------------------
  |  Branch (1523:9): [True: 0, False: 0]
  ------------------
 1524|      0|      free(schunk->data[nchunk]);
 1525|      0|    }
 1526|      0|    schunk->data[nchunk] = chunk;
 1527|      0|  }
 1528|   791k|  else {
 1529|   791k|    bool written = frame_update_chunk(frame, nchunk, chunk, schunk, chunk_cbytes_old) != NULL;
 1530|   791k|    frame_write_done(chunk, how, private_copy, written);
 1531|   791k|    if (!written) {
  ------------------
  |  Branch (1531:9): [True: 0, False: 791k]
  ------------------
 1532|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1533|      0|      schunk->flags2 = old_flags2;
 1534|      0|      schunk->chunksize = old_chunksize;
 1535|      0|      schunk->current_nchunk = old_current_nchunk;
 1536|      0|      schunk->nbytes = old_nbytes;
 1537|      0|      schunk->cbytes = old_cbytes;
 1538|      0|      return BLOSC2_ERROR_CHUNK_UPDATE;
 1539|      0|    }
 1540|   791k|  }
 1541|       |
 1542|   791k|  return schunk->nchunks;
 1543|   791k|}
schunk.c:schunk_get_counted_sizes:
 1114|   791k|                                    int32_t *chunk_cbytes) {
 1115|   791k|  *chunk_nbytes = 0;
 1116|   791k|  *chunk_cbytes = 0;
 1117|   791k|  uint8_t header[BLOSC_EXTENDED_HEADER_LENGTH];
 1118|   791k|  const uint8_t *chunk;
 1119|   791k|  int rc = schunk_get_chunk_header(schunk, nchunk, header, &chunk);
 1120|   791k|  if (rc < 0 || chunk == NULL) {
  ------------------
  |  Branch (1120:7): [True: 0, False: 791k]
  |  Branch (1120:17): [True: 0, False: 791k]
  ------------------
 1121|      0|    return rc;
 1122|      0|  }
 1123|   791k|  rc = blosc2_cbuffer_sizes(chunk, chunk_nbytes, chunk_cbytes, NULL);
 1124|   791k|  if (rc < 0) {
  ------------------
  |  Branch (1124:7): [True: 0, False: 791k]
  ------------------
 1125|      0|    return rc;
 1126|      0|  }
 1127|   791k|  if (*chunk_cbytes == BLOSC2_MAX_OVERHEAD) {
  ------------------
  |  Branch (1127:7): [True: 771k, False: 19.5k]
  ------------------
 1128|   771k|    *chunk_cbytes = 0;
 1129|   771k|  }
 1130|   791k|  return BLOSC2_ERROR_SUCCESS;
 1131|   791k|}
schunk.c:schunk_compress_store:
 1661|     64|                                     int32_t nbytes, chunk_write_op op, const char *func_name) {
 1662|     64|  if (nbytes < 0 || nbytes > BLOSC2_MAX_BUFFERSIZE) {
  ------------------
  |  Branch (1662:7): [True: 0, False: 64]
  |  Branch (1662:21): [True: 0, False: 64]
  ------------------
 1663|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1664|      0|                      BLOSC2_MAX_BUFFERSIZE, func_name);
 1665|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 1666|      0|  }
 1667|       |  // `nchunk` is left to the store below, which checks it under the frame lock (inserts and
 1668|       |  // appends after refreshing a handle that another one made stale).
 1669|     64|  bool in_frame = schunk->frame != NULL;
 1670|     64|  int32_t dest_nbytes = nbytes + BLOSC2_MAX_OVERHEAD;
 1671|     64|  size_t capacity;
 1672|     64|  uint8_t *chunk = schunk_scratch_malloc(schunk, dest_nbytes, &capacity);
 1673|     64|  BLOSC_ERROR_NULL(chunk, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|     64|    do {                                            \
  |  |  105|     64|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 64]
  |  |  ------------------
  |  |  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|     64|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 64]
  |  |  ------------------
  ------------------
 1674|       |  // Prefilters read the number of the chunk being compressed
 1675|     64|  int64_t old_current_nchunk = schunk->current_nchunk;
 1676|     64|  schunk->current_nchunk = nchunk;
 1677|     64|  int cbytes = blosc2_compress_ctx(schunk->cctx, src, nbytes, chunk, dest_nbytes);
 1678|     64|  if (cbytes <= 0) {
  ------------------
  |  Branch (1678:7): [True: 0, False: 64]
  ------------------
 1679|      0|    blosc2_tmp_free(chunk, capacity);
 1680|      0|    schunk->current_nchunk = old_current_nchunk;
 1681|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1682|      0|    return cbytes < 0 ? cbytes : BLOSC2_ERROR_WRITE_BUFFER;
  ------------------
  |  Branch (1682:12): [True: 0, False: 0]
  ------------------
 1683|      0|  }
 1684|     64|  chunk_handover how = in_frame ? CHUNK_LENT : CHUNK_GIVEN;
  ------------------
  |  Branch (1684:24): [True: 64, False: 0]
  ------------------
 1685|     64|  int64_t nchunks;
 1686|     64|  switch (op) {
 1687|     64|    case WRITE_APPEND:
  ------------------
  |  Branch (1687:5): [True: 64, False: 0]
  ------------------
 1688|     64|      nchunks = schunk_append_chunk_locked(schunk, chunk, how);
 1689|     64|      break;
 1690|      0|    case WRITE_INSERT:
  ------------------
  |  Branch (1690:5): [True: 0, False: 64]
  ------------------
 1691|      0|      nchunks = schunk_insert_chunk_locked(schunk, nchunk, chunk, how);
 1692|      0|      break;
 1693|      0|    default:
  ------------------
  |  Branch (1693:5): [True: 0, False: 64]
  ------------------
 1694|      0|      nchunks = schunk_update_chunk_locked(schunk, nchunk, chunk, how);
 1695|      0|      break;
 1696|     64|  }
 1697|       |  // A frame wrote a copy of the chunk, and a failed store leaves it to us
 1698|     64|  if (in_frame || nchunks < 0) {
  ------------------
  |  Branch (1698:7): [True: 64, False: 0]
  |  Branch (1698:19): [True: 0, False: 0]
  ------------------
 1699|     64|    blosc2_tmp_free(chunk, capacity);
 1700|     64|  }
 1701|     64|  if (nchunks < 0) {
  ------------------
  |  Branch (1701:7): [True: 0, False: 64]
  ------------------
 1702|      0|    schunk->current_nchunk = old_current_nchunk;
 1703|       |    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|      0|  }
 1705|     64|  return nchunks;
 1706|     64|}
schunk.c:validate_nchunk:
   47|  1.71M|static int validate_nchunk(blosc2_schunk *schunk, int64_t nchunk, bool allow_end, const char *func_name) {
   48|  1.71M|  if (nchunk < 0) {
  ------------------
  |  Branch (48:7): [True: 0, False: 1.71M]
  ------------------
   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.71M|  if (allow_end) {
  ------------------
  |  Branch (53:7): [True: 218k, False: 1.49M]
  ------------------
   54|   218k|    if (nchunk > schunk->nchunks) {
  ------------------
  |  Branch (54:9): [True: 0, False: 218k]
  ------------------
   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|   218k|  }
   60|  1.49M|  else {
   61|  1.49M|    if (nchunk >= schunk->nchunks) {
  ------------------
  |  Branch (61:9): [True: 928, False: 1.49M]
  ------------------
   62|    928|      BLOSC_TRACE_ERROR("nchunk ('%" PRId64 "') exceeds the number of chunks "
  ------------------
  |  |   93|    928|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|    928|    do {                                            \
  |  |  |  |   98|    928|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|    928|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 928, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|    928|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|    928|                        "('%" PRId64 "') in %s.", nchunk, schunk->nchunks, func_name);
   64|    928|      return BLOSC2_ERROR_INVALID_PARAM;
   65|    928|    }
   66|  1.49M|  }
   67|       |
   68|  1.71M|  return BLOSC2_ERROR_SUCCESS;
   69|  1.71M|}

shuffle_avx2:
  718|  11.4M|             const uint8_t *_src, uint8_t *_dest) {
  719|  11.4M|  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|  11.4M|  if (blocksize < vectorized_chunk_size) {
  ------------------
  |  Branch (723:7): [True: 9.00M, False: 2.43M]
  ------------------
  724|  9.00M|    shuffle_generic(bytesoftype, blocksize, _src, _dest);
  725|  9.00M|    return;
  726|  9.00M|  }
  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|  2.43M|  const int32_t vectorizable_bytes = blocksize - (blocksize % vectorized_chunk_size);
  734|       |
  735|  2.43M|  const int32_t vectorizable_elements = vectorizable_bytes / bytesoftype;
  736|  2.43M|  const int32_t total_elements = blocksize / bytesoftype;
  737|       |
  738|       |  /* Optimized shuffle implementations */
  739|  2.43M|  switch (bytesoftype) {
  740|  59.4k|    case 2:
  ------------------
  |  Branch (740:5): [True: 59.4k, False: 2.37M]
  ------------------
  741|  59.4k|      shuffle2_avx2(_dest, _src, vectorizable_elements, total_elements);
  742|  59.4k|      break;
  743|  49.3k|    case 4:
  ------------------
  |  Branch (743:5): [True: 49.3k, False: 2.38M]
  ------------------
  744|  49.3k|      shuffle4_avx2(_dest, _src, vectorizable_elements, total_elements);
  745|  49.3k|      break;
  746|  2.01M|    case 8:
  ------------------
  |  Branch (746:5): [True: 2.01M, False: 419k]
  ------------------
  747|  2.01M|      shuffle8_avx2(_dest, _src, vectorizable_elements, total_elements);
  748|  2.01M|      break;
  749|      0|    case 16:
  ------------------
  |  Branch (749:5): [True: 0, False: 2.43M]
  ------------------
  750|      0|      shuffle16_avx2(_dest, _src, vectorizable_elements, total_elements);
  751|      0|      break;
  752|   311k|    default:
  ------------------
  |  Branch (752:5): [True: 311k, False: 2.12M]
  ------------------
  753|       |      /* For types larger than 16 bytes, use the AVX2 tiled shuffle. */
  754|   311k|      if (bytesoftype > (int32_t)sizeof(__m128i)) {
  ------------------
  |  Branch (754:11): [True: 0, False: 311k]
  ------------------
  755|      0|        shuffle16_tiled_avx2(_dest, _src, vectorizable_elements, total_elements, bytesoftype);
  756|      0|      }
  757|   311k|      else {
  758|       |        /* Non-optimized shuffle */
  759|   311k|        shuffle_generic(bytesoftype, blocksize, _src, _dest);
  760|       |        /* The non-optimized function covers the whole buffer,
  761|       |           so we're done processing here. */
  762|   311k|        return;
  763|   311k|      }
  764|  2.43M|  }
  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|  2.12M|  if (vectorizable_bytes < blocksize) {
  ------------------
  |  Branch (769:7): [True: 930k, False: 1.19M]
  ------------------
  770|   930k|    shuffle_generic_inline(bytesoftype, vectorizable_bytes, blocksize, _src, _dest);
  771|   930k|  }
  772|  2.12M|}
unshuffle_avx2:
  777|  5.08M|               const uint8_t *_src, uint8_t *_dest) {
  778|  5.08M|  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|  5.08M|  if (blocksize < vectorized_chunk_size) {
  ------------------
  |  Branch (782:7): [True: 459k, False: 4.62M]
  ------------------
  783|   459k|    unshuffle_generic(bytesoftype, blocksize, _src, _dest);
  784|   459k|    return;
  785|   459k|  }
  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.62M|  const int32_t vectorizable_bytes = blocksize - (blocksize % vectorized_chunk_size);
  793|       |
  794|  4.62M|  const int32_t vectorizable_elements = vectorizable_bytes / bytesoftype;
  795|  4.62M|  const int32_t total_elements = blocksize / bytesoftype;
  796|       |
  797|       |  /* Optimized unshuffle implementations */
  798|  4.62M|  switch (bytesoftype) {
  799|  2.51k|    case 2:
  ------------------
  |  Branch (799:5): [True: 2.51k, False: 4.61M]
  ------------------
  800|  2.51k|      unshuffle2_avx2(_dest, _src, vectorizable_elements, total_elements);
  801|  2.51k|      break;
  802|  3.54k|    case 4:
  ------------------
  |  Branch (802:5): [True: 3.54k, False: 4.61M]
  ------------------
  803|  3.54k|      unshuffle4_avx2(_dest, _src, vectorizable_elements, total_elements);
  804|  3.54k|      break;
  805|  4.59M|    case 8:
  ------------------
  |  Branch (805:5): [True: 4.59M, False: 25.6k]
  ------------------
  806|  4.59M|      unshuffle8_avx2(_dest, _src, vectorizable_elements, total_elements);
  807|  4.59M|      break;
  808|     37|    case 12:
  ------------------
  |  Branch (808:5): [True: 37, False: 4.62M]
  ------------------
  809|     37|      unshuffle12_avx2(_dest, _src, vectorizable_elements, total_elements);
  810|     37|      break;
  811|     35|    case 16:
  ------------------
  |  Branch (811:5): [True: 35, False: 4.62M]
  ------------------
  812|     35|      unshuffle16_avx2(_dest, _src, vectorizable_elements, total_elements);
  813|     35|      break;
  814|  19.5k|    default:
  ------------------
  |  Branch (814:5): [True: 19.5k, False: 4.60M]
  ------------------
  815|       |      /* For types larger than 16 bytes, use the AVX2 tiled unshuffle. */
  816|  19.5k|      if (bytesoftype > (int32_t)sizeof(__m128i)) {
  ------------------
  |  Branch (816:11): [True: 90, False: 19.4k]
  ------------------
  817|     90|        unshuffle16_tiled_avx2(_dest, _src, vectorizable_elements, total_elements, bytesoftype);
  818|     90|      }
  819|  19.4k|      else {
  820|       |        /* Non-optimized unshuffle */
  821|  19.4k|        unshuffle_generic(bytesoftype, blocksize, _src, _dest);
  822|       |        /* The non-optimized function covers the whole buffer,
  823|       |           so we're done processing here. */
  824|  19.4k|        return;
  825|  19.4k|      }
  826|  4.62M|  }
  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.60M|  if (vectorizable_bytes < blocksize) {
  ------------------
  |  Branch (831:7): [True: 1.84M, False: 2.76M]
  ------------------
  832|  1.84M|    unshuffle_generic_inline(bytesoftype, vectorizable_bytes, blocksize, _src, _dest);
  833|  1.84M|  }
  834|  4.60M|}
shuffle-avx2.c:shuffle2_avx2:
   75|  59.4k|              const int32_t vectorizable_elements, const int32_t total_elements) {
   76|  59.4k|  static const int32_t bytesoftype = 2;
   77|  59.4k|  int32_t j;
   78|  59.4k|  const __m256i mask = _mm256_set1_epi16(0x00ff);
   79|       |
   80|   126M|  for (j = 0; j < vectorizable_elements; j += sizeof(__m256i)) {
  ------------------
  |  Branch (80:15): [True: 126M, False: 59.4k]
  ------------------
   81|       |    /* Fetch 32 elements (64 bytes), pack low/high bytes, and fix cross-lane order. */
   82|   126M|    __m256i y0 = _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype)));
   83|   126M|    __m256i y1 = _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype) + sizeof(__m256i)));
   84|   126M|    __m256i lo = _mm256_permute4x64_epi64(
   85|   126M|        _mm256_packus_epi16(_mm256_and_si256(y0, mask), _mm256_and_si256(y1, mask)), 0xd8);
   86|   126M|    __m256i hi = _mm256_permute4x64_epi64(
   87|   126M|        _mm256_packus_epi16(_mm256_srli_epi16(y0, 8), _mm256_srli_epi16(y1, 8)), 0xd8);
   88|       |
   89|       |    /* Store the result vectors */
   90|   126M|    _mm256_storeu_si256((__m256i*)(dest + j), lo);
   91|   126M|    _mm256_storeu_si256((__m256i*)(dest + j + total_elements), hi);
   92|   126M|  }
   93|  59.4k|}
shuffle-avx2.c:shuffle4_avx2:
   98|  49.3k|              const int32_t vectorizable_elements, const int32_t total_elements) {
   99|  49.3k|  static const int32_t bytesoftype = 4;
  100|  49.3k|  int32_t i;
  101|  49.3k|  int j;
  102|  49.3k|  __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|  49.3k|  const __m256i shmask = _mm256_set_epi8(
  109|  49.3k|      0x0f, 0x0b, 0x07, 0x03, 0x0e, 0x0a, 0x06, 0x02,
  110|  49.3k|      0x0d, 0x09, 0x05, 0x01, 0x0c, 0x08, 0x04, 0x00,
  111|  49.3k|      0x0f, 0x0b, 0x07, 0x03, 0x0e, 0x0a, 0x06, 0x02,
  112|  49.3k|      0x0d, 0x09, 0x05, 0x01, 0x0c, 0x08, 0x04, 0x00);
  113|  49.3k|  const __m256i mask = _mm256_set_epi32(
  114|  49.3k|      0x07, 0x03, 0x06, 0x02, 0x05, 0x01, 0x04, 0x00);
  115|       |
  116|  36.2M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (116:15): [True: 36.2M, False: 49.3k]
  ------------------
  117|       |    /* Fetch 32 elements (128 bytes) then transpose bytes and words within 128-bit lanes. */
  118|   181M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (118:17): [True: 144M, False: 36.2M]
  ------------------
  119|   144M|      ymm0[j] = _mm256_shuffle_epi8(
  120|   144M|          _mm256_loadu_si256((__m256i*)(src + (i * bytesoftype) + (j * sizeof(__m256i)))),
  121|   144M|          shmask);
  122|   144M|    }
  123|       |    /* Transpose double words */
  124|   108M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (124:17): [True: 72.4M, False: 36.2M]
  ------------------
  125|  72.4M|      ymm1[j * 2] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  126|  72.4M|      ymm1[j * 2 + 1] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  127|  72.4M|    }
  128|       |    /* Transpose quad words */
  129|   108M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (129:17): [True: 72.4M, False: 36.2M]
  ------------------
  130|  72.4M|      ymm0[j * 2] = _mm256_unpacklo_epi64(ymm1[j], ymm1[j + 2]);
  131|  72.4M|      ymm0[j * 2 + 1] = _mm256_unpackhi_epi64(ymm1[j], ymm1[j + 2]);
  132|  72.4M|    }
  133|   181M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (133:17): [True: 144M, False: 36.2M]
  ------------------
  134|   144M|      ymm0[j] = _mm256_permutevar8x32_epi32(ymm0[j], mask);
  135|   144M|    }
  136|       |    /* Store the result vectors */
  137|  36.2M|    uint8_t* const dest_for_ith_element = dest + i;
  138|   181M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (138:17): [True: 144M, False: 36.2M]
  ------------------
  139|   144M|      _mm256_storeu_si256((__m256i*)(dest_for_ith_element + (j * total_elements)), ymm0[j]);
  140|   144M|    }
  141|  36.2M|  }
  142|  49.3k|}
shuffle-avx2.c:shuffle8_avx2:
  147|  2.01M|              const int32_t vectorizable_elements, const int32_t total_elements) {
  148|  2.01M|  static const int32_t bytesoftype = 8;
  149|  2.01M|  int32_t j;
  150|  2.01M|  int k, l;
  151|  2.01M|  __m256i ymm0[8], ymm1[8];
  152|  2.01M|  const __m256i shmask_in = _mm256_set_epi8(
  153|  2.01M|      0x0f, 0x07, 0x0e, 0x06, 0x0d, 0x05, 0x0c, 0x04,
  154|  2.01M|      0x0b, 0x03, 0x0a, 0x02, 0x09, 0x01, 0x08, 0x00,
  155|  2.01M|      0x0f, 0x07, 0x0e, 0x06, 0x0d, 0x05, 0x0c, 0x04,
  156|  2.01M|      0x0b, 0x03, 0x0a, 0x02, 0x09, 0x01, 0x08, 0x00);
  157|  2.01M|  const __m256i shmask_out = _mm256_set_epi8(
  158|  2.01M|      0x0f, 0x0e, 0x07, 0x06, 0x0d, 0x0c, 0x05, 0x04,
  159|  2.01M|      0x0b, 0x0a, 0x03, 0x02, 0x09, 0x08, 0x01, 0x00,
  160|  2.01M|      0x0f, 0x0e, 0x07, 0x06, 0x0d, 0x0c, 0x05, 0x04,
  161|  2.01M|      0x0b, 0x0a, 0x03, 0x02, 0x09, 0x08, 0x01, 0x00);
  162|       |
  163|   159M|  for (j = 0; j < vectorizable_elements; j += sizeof(__m256i)) {
  ------------------
  |  Branch (163:15): [True: 157M, False: 2.01M]
  ------------------
  164|       |    /* Fetch 32 elements (256 bytes) then transpose bytes. */
  165|  1.41G|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (165:17): [True: 1.25G, False: 157M]
  ------------------
  166|  1.25G|      ymm1[k] = _mm256_shuffle_epi8(
  167|  1.25G|          _mm256_loadu_si256((__m256i*)(src + (j * bytesoftype) + (k * sizeof(__m256i)))),
  168|  1.25G|          shmask_in);
  169|  1.25G|    }
  170|       |    /* Transpose words */
  171|   786M|    for (k = 0, l = 0; k < 4; k++, l += 2) {
  ------------------
  |  Branch (171:24): [True: 629M, False: 157M]
  ------------------
  172|   629M|      ymm0[k * 2] = _mm256_unpacklo_epi16(ymm1[l], ymm1[l + 1]);
  173|   629M|      ymm0[k * 2 + 1] = _mm256_unpackhi_epi16(ymm1[l], ymm1[l + 1]);
  174|   629M|    }
  175|       |    /* Transpose double words */
  176|   786M|    for (k = 0, l = 0; k < 4; k++, l++) {
  ------------------
  |  Branch (176:24): [True: 629M, False: 157M]
  ------------------
  177|   629M|      if (k == 2) l += 2;
  ------------------
  |  Branch (177:11): [True: 157M, False: 471M]
  ------------------
  178|   629M|      ymm1[k * 2] = _mm256_unpacklo_epi32(ymm0[l], ymm0[l + 2]);
  179|   629M|      ymm1[k * 2 + 1] = _mm256_unpackhi_epi32(ymm0[l], ymm0[l + 2]);
  180|   629M|    }
  181|       |    /* Transpose quad words */
  182|   786M|    for (k = 0; k < 4; k++) {
  ------------------
  |  Branch (182:17): [True: 629M, False: 157M]
  ------------------
  183|   629M|      ymm0[k * 2] = _mm256_unpacklo_epi64(ymm1[k], ymm1[k + 4]);
  184|   629M|      ymm0[k * 2 + 1] = _mm256_unpackhi_epi64(ymm1[k], ymm1[k + 4]);
  185|   629M|    }
  186|  1.41G|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (186:17): [True: 1.25G, False: 157M]
  ------------------
  187|  1.25G|      ymm0[k] = _mm256_shuffle_epi8(
  188|  1.25G|          _mm256_permute4x64_epi64(ymm0[k], 0xD8), shmask_out);
  189|  1.25G|    }
  190|       |    /* Store the result vectors */
  191|   157M|    uint8_t* const dest_for_jth_element = dest + j;
  192|  1.41G|    for (k = 0; k < 8; k++) {
  ------------------
  |  Branch (192:17): [True: 1.25G, False: 157M]
  ------------------
  193|  1.25G|      _mm256_storeu_si256((__m256i*)(dest_for_jth_element + (k * total_elements)), ymm0[k]);
  194|  1.25G|    }
  195|   157M|  }
  196|  2.01M|}
shuffle-avx2.c:unshuffle2_avx2:
  331|  2.51k|                const int32_t vectorizable_elements, const int32_t total_elements) {
  332|  2.51k|  static const int32_t bytesoftype = 2;
  333|  2.51k|  int32_t i;
  334|  2.51k|  int j;
  335|  2.51k|  __m256i ymm0[2], ymm1[2];
  336|       |
  337|  1.12M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (337:15): [True: 1.11M, False: 2.51k]
  ------------------
  338|       |    /* Load 32 elements (64 bytes) into 2 YMM registers. */
  339|  1.11M|    const uint8_t* const src_for_ith_element = src + i;
  340|  3.35M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (340:17): [True: 2.23M, False: 1.11M]
  ------------------
  341|  2.23M|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  342|  2.23M|    }
  343|       |    /* Shuffle bytes */
  344|  3.35M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (344:17): [True: 2.23M, False: 1.11M]
  ------------------
  345|  2.23M|      ymm0[j] = _mm256_permute4x64_epi64(ymm0[j], 0xd8);
  346|  2.23M|    }
  347|       |    /* Compute the low 64 bytes */
  348|  1.11M|    ymm1[0] = _mm256_unpacklo_epi8(ymm0[0], ymm0[1]);
  349|       |    /* Compute the hi 64 bytes */
  350|  1.11M|    ymm1[1] = _mm256_unpackhi_epi8(ymm0[0], ymm0[1]);
  351|       |    /* Store the result vectors in proper order */
  352|  1.11M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  353|  1.11M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[1]);
  354|  1.11M|  }
  355|  2.51k|}
shuffle-avx2.c:unshuffle4_avx2:
  360|  3.54k|                const int32_t vectorizable_elements, const int32_t total_elements) {
  361|  3.54k|  static const int32_t bytesoftype = 4;
  362|  3.54k|  int32_t i;
  363|  3.54k|  int j;
  364|  3.54k|  __m256i ymm0[4], ymm1[4];
  365|       |
  366|  13.3M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (366:15): [True: 13.3M, False: 3.54k]
  ------------------
  367|       |    /* Load 32 elements (128 bytes) into 4 YMM registers. */
  368|  13.3M|    const uint8_t* const src_for_ith_element = src + i;
  369|  66.8M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (369:17): [True: 53.4M, False: 13.3M]
  ------------------
  370|  53.4M|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  371|  53.4M|    }
  372|       |    /* Shuffle bytes */
  373|  40.0M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (373:17): [True: 26.7M, False: 13.3M]
  ------------------
  374|       |      /* Compute the low 64 bytes */
  375|  26.7M|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  376|       |      /* Compute the hi 64 bytes */
  377|  26.7M|      ymm1[2 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  378|  26.7M|    }
  379|       |    /* Shuffle 2-byte words */
  380|  40.0M|    for (j = 0; j < 2; j++) {
  ------------------
  |  Branch (380:17): [True: 26.7M, False: 13.3M]
  ------------------
  381|       |      /* Compute the low 64 bytes */
  382|  26.7M|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  383|       |      /* Compute the hi 64 bytes */
  384|  26.7M|      ymm0[2 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  385|  26.7M|    }
  386|  13.3M|    ymm1[0] = _mm256_permute2x128_si256(ymm0[0], ymm0[2], 0x20);
  387|  13.3M|    ymm1[1] = _mm256_permute2x128_si256(ymm0[1], ymm0[3], 0x20);
  388|  13.3M|    ymm1[2] = _mm256_permute2x128_si256(ymm0[0], ymm0[2], 0x31);
  389|  13.3M|    ymm1[3] = _mm256_permute2x128_si256(ymm0[1], ymm0[3], 0x31);
  390|       |
  391|       |    /* Store the result vectors in proper order */
  392|  66.8M|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (392:17): [True: 53.4M, False: 13.3M]
  ------------------
  393|  53.4M|      _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (j * sizeof(__m256i))), ymm1[j]);
  394|  53.4M|    }
  395|  13.3M|  }
  396|  3.54k|}
shuffle-avx2.c:unshuffle8_avx2:
  401|  4.59M|                const int32_t vectorizable_elements, const int32_t total_elements) {
  402|  4.59M|  static const int32_t bytesoftype = 8;
  403|  4.59M|  int32_t i;
  404|  4.59M|  int j;
  405|  4.59M|  __m256i ymm0[8], ymm1[8];
  406|       |
  407|   230M|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (407:15): [True: 226M, False: 4.59M]
  ------------------
  408|       |    /* Fetch 32 elements (256 bytes) into 8 YMM registers. */
  409|   226M|    const uint8_t* const src_for_ith_element = src + i;
  410|  2.03G|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (410:17): [True: 1.80G, False: 226M]
  ------------------
  411|  1.80G|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  412|  1.80G|    }
  413|       |    /* Shuffle bytes */
  414|  1.13G|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (414:17): [True: 904M, False: 226M]
  ------------------
  415|       |      /* Compute the low 32 bytes */
  416|   904M|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  417|       |      /* Compute the hi 32 bytes */
  418|   904M|      ymm1[4 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  419|   904M|    }
  420|       |    /* Shuffle words */
  421|  1.13G|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (421:17): [True: 904M, False: 226M]
  ------------------
  422|       |      /* Compute the low 32 bytes */
  423|   904M|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  424|       |      /* Compute the hi 32 bytes */
  425|   904M|      ymm0[4 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  426|   904M|    }
  427|  2.03G|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (427:17): [True: 1.80G, False: 226M]
  ------------------
  428|  1.80G|      ymm0[j] = _mm256_permute4x64_epi64(ymm0[j], 0xd8);
  429|  1.80G|    }
  430|       |
  431|       |    /* Shuffle 4-byte dwords */
  432|  1.13G|    for (j = 0; j < 4; j++) {
  ------------------
  |  Branch (432:17): [True: 904M, False: 226M]
  ------------------
  433|       |      /* Compute the low 32 bytes */
  434|   904M|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  435|       |      /* Compute the hi 32 bytes */
  436|   904M|      ymm1[4 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  437|   904M|    }
  438|       |
  439|       |    /* Store the result vectors in proper order */
  440|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  441|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[2]);
  442|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * sizeof(__m256i))), ymm1[1]);
  443|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * sizeof(__m256i))), ymm1[3]);
  444|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * sizeof(__m256i))), ymm1[4]);
  445|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * sizeof(__m256i))), ymm1[6]);
  446|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * sizeof(__m256i))), ymm1[5]);
  447|   226M|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * sizeof(__m256i))), ymm1[7]);
  448|   226M|  }
  449|  4.59M|}
shuffle-avx2.c:unshuffle12_avx2:
  526|     37|    const int32_t vectorizable_elements, const int32_t total_elements) {
  527|     37|  static const int32_t bytesoftype = 12;
  528|     37|  int32_t i;
  529|     37|  int j;
  530|     37|  __m256i ymm0[16], ymm1[16];
  531|       |
  532|     37|  __m256i permute = _mm256_set_epi32(0,0,6,5,4,2,1,0);
  533|     37|  __m256i store_mask = _mm256_set_epi32(0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);
  534|     37|  int32_t jump = 2*bytesoftype;
  535|  18.4k|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (535:15): [True: 18.4k, False: 37]
  ------------------
  536|       |    /* Fetch 24 elements (384 bytes) into 12 YMM registers. */
  537|  18.4k|    const uint8_t* const src_for_ith_element = src + i;
  538|   239k|    for (j = 0; j < bytesoftype; j++) {
  ------------------
  |  Branch (538:17): [True: 220k, False: 18.4k]
  ------------------
  539|   220k|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  540|   220k|    }
  541|       |    /* Initialize the last 4 registers (128 bytes) to null */
  542|  92.0k|    for (j = bytesoftype; j < 16; j++) {
  ------------------
  |  Branch (542:27): [True: 73.6k, False: 18.4k]
  ------------------
  543|  73.6k|      ymm0[j] = _mm256_setzero_si256();
  544|  73.6k|    }
  545|       |
  546|       |    /* Shuffle bytes */
  547|   165k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (547:17): [True: 147k, False: 18.4k]
  ------------------
  548|       |      /* Compute the low 32 bytes */
  549|   147k|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  550|       |      /* Compute the hi 32 bytes */
  551|   147k|      ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  552|   147k|    }
  553|       |    /* Shuffle 2-byte words */
  554|   165k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (554:17): [True: 147k, False: 18.4k]
  ------------------
  555|       |      /* Compute the low 32 bytes */
  556|   147k|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  557|       |      /* Compute the hi 32 bytes */
  558|   147k|      ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  559|   147k|    }
  560|       |    /* Shuffle 4-byte dwords */
  561|   165k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (561:17): [True: 147k, False: 18.4k]
  ------------------
  562|       |      /* Compute the low 32 bytes */
  563|   147k|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  564|       |      /* Compute the hi 32 bytes */
  565|   147k|      ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  566|   147k|    }
  567|       |
  568|       |    /* Shuffle 8-byte qwords */
  569|   165k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (569:17): [True: 147k, False: 18.4k]
  ------------------
  570|       |      /* Compute the low 32 bytes */
  571|   147k|      ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  572|       |      /* Compute the hi 32 bytes */
  573|   147k|      ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  574|   147k|    }
  575|       |
  576|       |
  577|   165k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (577:17): [True: 147k, False: 18.4k]
  ------------------
  578|   147k|      ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  579|   147k|      ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  580|   147k|      ymm1[j] = _mm256_permutevar8x32_epi32(ymm1[j], permute);
  581|   147k|      ymm1[j+8] = _mm256_permutevar8x32_epi32(ymm1[j+8], permute);
  582|       |
  583|       |
  584|   147k|    }
  585|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * jump)), ymm1[0]);
  586|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * jump)), ymm1[4]);
  587|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * jump)), ymm1[2]);
  588|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * jump)), ymm1[6]);
  589|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * jump)), ymm1[1]);
  590|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * jump)), ymm1[5]);
  591|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * jump)), ymm1[3]);
  592|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * jump)), ymm1[7]);
  593|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (8 * jump)), ymm1[8]);
  594|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (9 * jump)), ymm1[12]);
  595|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (10 * jump)), ymm1[10]);
  596|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (11 * jump)), ymm1[14]);
  597|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (12 * jump)), ymm1[9]);
  598|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (13 * jump)), ymm1[13]);
  599|  18.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (14 * jump)), ymm1[11]);
  600|  18.4k|    _mm256_maskstore_epi32((int *)(dest + (i * bytesoftype) + (15 * jump)), store_mask, ymm1[15]);
  601|  18.4k|  }
  602|     37|}
shuffle-avx2.c:unshuffle16_avx2:
  454|     35|                 const int32_t vectorizable_elements, const int32_t total_elements) {
  455|     35|  static const int32_t bytesoftype = 16;
  456|     35|  int32_t i;
  457|     35|  int j;
  458|     35|  __m256i ymm0[16], ymm1[16];
  459|       |
  460|  11.4k|  for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (460:15): [True: 11.4k, False: 35]
  ------------------
  461|       |    /* Fetch 32 elements (512 bytes) into 16 YMM registers. */
  462|  11.4k|    const uint8_t* const src_for_ith_element = src + i;
  463|   194k|    for (j = 0; j < 16; j++) {
  ------------------
  |  Branch (463:17): [True: 183k, False: 11.4k]
  ------------------
  464|   183k|      ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (j * total_elements)));
  465|   183k|    }
  466|       |
  467|       |    /* Shuffle bytes */
  468|   102k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (468:17): [True: 91.5k, False: 11.4k]
  ------------------
  469|       |      /* Compute the low 32 bytes */
  470|  91.5k|      ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  471|       |      /* Compute the hi 32 bytes */
  472|  91.5k|      ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  473|  91.5k|    }
  474|       |    /* Shuffle 2-byte words */
  475|   102k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (475:17): [True: 91.5k, False: 11.4k]
  ------------------
  476|       |      /* Compute the low 32 bytes */
  477|  91.5k|      ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  478|       |      /* Compute the hi 32 bytes */
  479|  91.5k|      ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  480|  91.5k|    }
  481|       |    /* Shuffle 4-byte dwords */
  482|   102k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (482:17): [True: 91.5k, False: 11.4k]
  ------------------
  483|       |      /* Compute the low 32 bytes */
  484|  91.5k|      ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  485|       |      /* Compute the hi 32 bytes */
  486|  91.5k|      ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  487|  91.5k|    }
  488|       |
  489|       |    /* Shuffle 8-byte qwords */
  490|   102k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (490:17): [True: 91.5k, False: 11.4k]
  ------------------
  491|       |      /* Compute the low 32 bytes */
  492|  91.5k|      ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  493|       |      /* Compute the hi 32 bytes */
  494|  91.5k|      ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  495|  91.5k|    }
  496|       |
  497|   102k|    for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (497:17): [True: 91.5k, False: 11.4k]
  ------------------
  498|  91.5k|      ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  499|  91.5k|      ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  500|  91.5k|    }
  501|       |
  502|       |    /* Store the result vectors in proper order */
  503|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (0 * sizeof(__m256i))), ymm1[0]);
  504|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (1 * sizeof(__m256i))), ymm1[4]);
  505|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (2 * sizeof(__m256i))), ymm1[2]);
  506|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (3 * sizeof(__m256i))), ymm1[6]);
  507|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (4 * sizeof(__m256i))), ymm1[1]);
  508|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (5 * sizeof(__m256i))), ymm1[5]);
  509|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (6 * sizeof(__m256i))), ymm1[3]);
  510|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (7 * sizeof(__m256i))), ymm1[7]);
  511|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (8 * sizeof(__m256i))), ymm1[8]);
  512|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (9 * sizeof(__m256i))), ymm1[12]);
  513|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (10 * sizeof(__m256i))), ymm1[10]);
  514|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (11 * sizeof(__m256i))), ymm1[14]);
  515|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (12 * sizeof(__m256i))), ymm1[9]);
  516|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (13 * sizeof(__m256i))), ymm1[13]);
  517|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (14 * sizeof(__m256i))), ymm1[11]);
  518|  11.4k|    _mm256_storeu_si256((__m256i*)(dest + (i * bytesoftype) + (15 * sizeof(__m256i))), ymm1[15]);
  519|  11.4k|  }
  520|     35|}
shuffle-avx2.c:unshuffle16_tiled_avx2:
  606|     90|                       const int32_t vectorizable_elements, const int32_t total_elements, const int32_t bytesoftype) {
  607|     90|  int32_t i;
  608|     90|  int j;
  609|     90|  __m256i ymm0[16], ymm1[16];
  610|       |
  611|     90|  const lldiv_t vecs_per_el = lldiv(bytesoftype, sizeof(__m128i));
  612|     90|  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|     90|  int32_t offset_into_type;
  617|    913|  for (offset_into_type = 0; offset_into_type < bytesoftype;
  ------------------
  |  Branch (617:30): [True: 823, False: 90]
  ------------------
  618|    823|       offset_into_type += (offset_into_type == 0 && vecs_rem > 0 ? vecs_rem : (int32_t)sizeof(__m128i))) {
  ------------------
  |  Branch (618:29): [True: 90, False: 733]
  |  Branch (618:54): [True: 73, False: 17]
  ------------------
  619|  39.4k|    for (i = 0; i < vectorizable_elements; i += sizeof(__m256i)) {
  ------------------
  |  Branch (619:17): [True: 38.6k, False: 823]
  ------------------
  620|       |      /* Load the first 16 bytes of 32 adjacent elements (512 bytes) into 16 YMM registers */
  621|  38.6k|      const uint8_t* const src_for_ith_element = src + i;
  622|   656k|      for (j = 0; j < 16; j++) {
  ------------------
  |  Branch (622:19): [True: 618k, False: 38.6k]
  ------------------
  623|   618k|        ymm0[j] = _mm256_loadu_si256((__m256i*)(src_for_ith_element + (total_elements * (offset_into_type + j))));
  624|   618k|      }
  625|       |
  626|       |      /* Shuffle bytes */
  627|   347k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (627:19): [True: 309k, False: 38.6k]
  ------------------
  628|       |        /* Compute the low 32 bytes */
  629|   309k|        ymm1[j] = _mm256_unpacklo_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  630|       |        /* Compute the hi 32 bytes */
  631|   309k|        ymm1[8 + j] = _mm256_unpackhi_epi8(ymm0[j * 2], ymm0[j * 2 + 1]);
  632|   309k|      }
  633|       |      /* Shuffle 2-byte words */
  634|   347k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (634:19): [True: 309k, False: 38.6k]
  ------------------
  635|       |        /* Compute the low 32 bytes */
  636|   309k|        ymm0[j] = _mm256_unpacklo_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  637|       |        /* Compute the hi 32 bytes */
  638|   309k|        ymm0[8 + j] = _mm256_unpackhi_epi16(ymm1[j * 2], ymm1[j * 2 + 1]);
  639|   309k|      }
  640|       |      /* Shuffle 4-byte dwords */
  641|   347k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (641:19): [True: 309k, False: 38.6k]
  ------------------
  642|       |        /* Compute the low 32 bytes */
  643|   309k|        ymm1[j] = _mm256_unpacklo_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  644|       |        /* Compute the hi 32 bytes */
  645|   309k|        ymm1[8 + j] = _mm256_unpackhi_epi32(ymm0[j * 2], ymm0[j * 2 + 1]);
  646|   309k|      }
  647|       |
  648|       |      /* Shuffle 8-byte qwords */
  649|   347k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (649:19): [True: 309k, False: 38.6k]
  ------------------
  650|       |        /* Compute the low 32 bytes */
  651|   309k|        ymm0[j] = _mm256_unpacklo_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  652|       |        /* Compute the hi 32 bytes */
  653|   309k|        ymm0[8 + j] = _mm256_unpackhi_epi64(ymm1[j * 2], ymm1[j * 2 + 1]);
  654|   309k|      }
  655|       |
  656|   347k|      for (j = 0; j < 8; j++) {
  ------------------
  |  Branch (656:19): [True: 309k, False: 38.6k]
  ------------------
  657|   309k|        ymm1[j] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x20);
  658|   309k|        ymm1[j + 8] = _mm256_permute2x128_si256(ymm0[j], ymm0[j + 8], 0x31);
  659|   309k|      }
  660|       |
  661|       |      /* Store the result vectors in proper order */
  662|  38.6k|      const uint8_t* const dest_with_offset = dest + offset_into_type;
  663|  38.6k|      _mm256_storeu2_m128i(
  664|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x01) * bytesoftype),
  665|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x00) * bytesoftype), ymm1[0]);
  666|  38.6k|      _mm256_storeu2_m128i(
  667|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x03) * bytesoftype),
  668|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x02) * bytesoftype), ymm1[4]);
  669|  38.6k|      _mm256_storeu2_m128i(
  670|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x05) * bytesoftype),
  671|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x04) * bytesoftype), ymm1[2]);
  672|  38.6k|      _mm256_storeu2_m128i(
  673|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x07) * bytesoftype),
  674|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x06) * bytesoftype), ymm1[6]);
  675|  38.6k|      _mm256_storeu2_m128i(
  676|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x09) * bytesoftype),
  677|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x08) * bytesoftype), ymm1[1]);
  678|  38.6k|      _mm256_storeu2_m128i(
  679|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0b) * bytesoftype),
  680|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0a) * bytesoftype), ymm1[5]);
  681|  38.6k|      _mm256_storeu2_m128i(
  682|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0d) * bytesoftype),
  683|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0c) * bytesoftype), ymm1[3]);
  684|  38.6k|      _mm256_storeu2_m128i(
  685|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0f) * bytesoftype),
  686|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x0e) * bytesoftype), ymm1[7]);
  687|  38.6k|      _mm256_storeu2_m128i(
  688|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x11) * bytesoftype),
  689|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x10) * bytesoftype), ymm1[8]);
  690|  38.6k|      _mm256_storeu2_m128i(
  691|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x13) * bytesoftype),
  692|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x12) * bytesoftype), ymm1[12]);
  693|  38.6k|      _mm256_storeu2_m128i(
  694|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x15) * bytesoftype),
  695|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x14) * bytesoftype), ymm1[10]);
  696|  38.6k|      _mm256_storeu2_m128i(
  697|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x17) * bytesoftype),
  698|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x16) * bytesoftype), ymm1[14]);
  699|  38.6k|      _mm256_storeu2_m128i(
  700|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x19) * bytesoftype),
  701|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x18) * bytesoftype), ymm1[9]);
  702|  38.6k|      _mm256_storeu2_m128i(
  703|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1b) * bytesoftype),
  704|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1a) * bytesoftype), ymm1[13]);
  705|  38.6k|      _mm256_storeu2_m128i(
  706|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1d) * bytesoftype),
  707|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1c) * bytesoftype), ymm1[11]);
  708|  38.6k|      _mm256_storeu2_m128i(
  709|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1f) * bytesoftype),
  710|  38.6k|          (__m128i*)(dest_with_offset + (i + 0x1e) * bytesoftype), ymm1[15]);
  711|  38.6k|    }
  712|    823|  }
  713|     90|}

shuffle_bytedelta_ssse3_backward:
  164|     72|int shuffle_bytedelta_ssse3_backward(const uint8_t *input, uint8_t *output, int32_t length, int typesize) {
  165|     72|  switch (typesize) {
  166|     36|    case 2: return backward2(input, output, length);
  ------------------
  |  Branch (166:5): [True: 36, False: 36]
  ------------------
  167|     16|    case 4: return backward4(input, output, length);
  ------------------
  |  Branch (167:5): [True: 16, False: 56]
  ------------------
  168|     20|    case 8: return backward8(input, output, length);
  ------------------
  |  Branch (168:5): [True: 20, False: 52]
  ------------------
  169|      0|    default: return 0;
  ------------------
  |  Branch (169:5): [True: 0, False: 72]
  ------------------
  170|     72|  }
  171|     72|}
shuffle-bytedelta-ssse3.c:prefix_sum16:
   94|   469k|static inline __m128i prefix_sum16(__m128i value) {
   95|   469k|  value = _mm_add_epi8(value, _mm_slli_si128(value, 1));
   96|   469k|  value = _mm_add_epi8(value, _mm_slli_si128(value, 2));
   97|   469k|  value = _mm_add_epi8(value, _mm_slli_si128(value, 4));
   98|       |  return _mm_add_epi8(value, _mm_slli_si128(value, 8));
   99|   469k|}
shuffle-bytedelta-ssse3.c:store_planes16:
   59|   197k|static inline void store_planes16(uint8_t *output, const __m128i *planes, int typesize) {
   60|   197k|  if (typesize == 2) {
  ------------------
  |  Branch (60:7): [True: 168k, False: 29.2k]
  ------------------
   61|   168k|    _mm_storeu_si128((__m128i *)output, _mm_unpacklo_epi8(planes[0], planes[1]));
   62|   168k|    _mm_storeu_si128((__m128i *)(output + 16), _mm_unpackhi_epi8(planes[0], planes[1]));
   63|   168k|  }
   64|  29.2k|  else if (typesize == 4) {
  ------------------
  |  Branch (64:12): [True: 25.4k, False: 3.85k]
  ------------------
   65|  25.4k|    __m128i a[4];
   66|  25.4k|    a[0] = _mm_unpacklo_epi8(planes[0], planes[1]);
   67|  25.4k|    a[1] = _mm_unpackhi_epi8(planes[0], planes[1]);
   68|  25.4k|    a[2] = _mm_unpacklo_epi8(planes[2], planes[3]);
   69|  25.4k|    a[3] = _mm_unpackhi_epi8(planes[2], planes[3]);
   70|  25.4k|    _mm_storeu_si128((__m128i *)output, _mm_unpacklo_epi16(a[0], a[2]));
   71|  25.4k|    _mm_storeu_si128((__m128i *)(output + 16), _mm_unpackhi_epi16(a[0], a[2]));
   72|  25.4k|    _mm_storeu_si128((__m128i *)(output + 32), _mm_unpacklo_epi16(a[1], a[3]));
   73|  25.4k|    _mm_storeu_si128((__m128i *)(output + 48), _mm_unpackhi_epi16(a[1], a[3]));
   74|  25.4k|  }
   75|  3.85k|  else {
   76|  3.85k|    __m128i a[8], b[8];
   77|  19.2k|    for (int p = 0; p < 4; p++) {
  ------------------
  |  Branch (77:21): [True: 15.4k, False: 3.85k]
  ------------------
   78|  15.4k|      a[p * 2] = _mm_unpacklo_epi8(planes[p * 2], planes[p * 2 + 1]);
   79|  15.4k|      a[p * 2 + 1] = _mm_unpackhi_epi8(planes[p * 2], planes[p * 2 + 1]);
   80|  15.4k|    }
   81|  11.5k|    for (int p = 0; p < 2; p++) {
  ------------------
  |  Branch (81:21): [True: 7.70k, False: 3.85k]
  ------------------
   82|  7.70k|      b[p * 2] = _mm_unpacklo_epi16(a[p], a[p + 2]);
   83|  7.70k|      b[p * 2 + 1] = _mm_unpackhi_epi16(a[p], a[p + 2]);
   84|  7.70k|      b[p * 2 + 4] = _mm_unpacklo_epi16(a[p + 4], a[p + 6]);
   85|  7.70k|      b[p * 2 + 5] = _mm_unpackhi_epi16(a[p + 4], a[p + 6]);
   86|  7.70k|    }
   87|  19.2k|    for (int p = 0; p < 4; p++) {
  ------------------
  |  Branch (87:21): [True: 15.4k, False: 3.85k]
  ------------------
   88|  15.4k|      _mm_storeu_si128((__m128i *)(output + p * 32), _mm_unpacklo_epi32(b[p], b[p + 4]));
   89|  15.4k|      _mm_storeu_si128((__m128i *)(output + p * 32 + 16), _mm_unpackhi_epi32(b[p], b[p + 4]));
   90|  15.4k|    }
   91|  3.85k|  }
   92|   197k|}

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

shuffle-generic.c:shuffle_generic_inline:
   36|  9.31M|                                   const uint8_t *_src, uint8_t *_dest) {
   37|  9.31M|  int32_t i, j;
   38|       |  /* Calculate the number of elements in the block. */
   39|  9.31M|  const int32_t neblock_quot = blocksize / type_size;
   40|  9.31M|  const int32_t neblock_rem = blocksize % type_size;
   41|  9.31M|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   42|       |
   43|       |
   44|       |  /* Non-optimized shuffle */
   45|  79.4M|  for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (45:15): [True: 70.1M, False: 9.31M]
  ------------------
   46|  21.9G|    for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (46:37): [True: 21.9G, False: 70.1M]
  ------------------
   47|  21.9G|      _dest[j * neblock_quot + i] = _src[i * type_size + j];
   48|  21.9G|    }
   49|  70.1M|  }
   50|       |
   51|       |  /* Copy any leftover bytes in the block without shuffling them. */
   52|  9.31M|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   53|  9.31M|}
shuffle-generic.c:unshuffle_generic_inline:
   64|   478k|                                     const uint8_t *_src, uint8_t *_dest) {
   65|   478k|  int32_t i, j;
   66|       |
   67|       |  /* Calculate the number of elements in the block. */
   68|   478k|  const int32_t neblock_quot = blocksize / type_size;
   69|   478k|  const int32_t neblock_rem = blocksize % type_size;
   70|   478k|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   71|       |
   72|       |  /* Non-optimized unshuffle */
   73|  86.3M|  for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (73:35): [True: 85.8M, False: 478k]
  ------------------
   74|   656M|    for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (74:17): [True: 571M, False: 85.8M]
  ------------------
   75|   571M|      _dest[i * type_size + j] = _src[j * neblock_quot + i];
   76|   571M|    }
   77|  85.8M|  }
   78|       |
   79|       |  /* Copy any leftover bytes in the block without unshuffling them. */
   80|   478k|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   81|   478k|}
shuffle-avx2.c:shuffle_generic_inline:
   36|   930k|                                   const uint8_t *_src, uint8_t *_dest) {
   37|   930k|  int32_t i, j;
   38|       |  /* Calculate the number of elements in the block. */
   39|   930k|  const int32_t neblock_quot = blocksize / type_size;
   40|   930k|  const int32_t neblock_rem = blocksize % type_size;
   41|   930k|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   42|       |
   43|       |
   44|       |  /* Non-optimized shuffle */
   45|  7.90M|  for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (45:15): [True: 6.97M, False: 930k]
  ------------------
   46|   113M|    for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (46:37): [True: 106M, False: 6.97M]
  ------------------
   47|   106M|      _dest[j * neblock_quot + i] = _src[i * type_size + j];
   48|   106M|    }
   49|  6.97M|  }
   50|       |
   51|       |  /* Copy any leftover bytes in the block without shuffling them. */
   52|   930k|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   53|   930k|}
shuffle-avx2.c:unshuffle_generic_inline:
   64|  1.84M|                                     const uint8_t *_src, uint8_t *_dest) {
   65|  1.84M|  int32_t i, j;
   66|       |
   67|       |  /* Calculate the number of elements in the block. */
   68|  1.84M|  const int32_t neblock_quot = blocksize / type_size;
   69|  1.84M|  const int32_t neblock_rem = blocksize % type_size;
   70|  1.84M|  const int32_t vectorizable_elements = vectorizable_blocksize / type_size;
   71|       |
   72|       |  /* Non-optimized unshuffle */
   73|  32.5M|  for (i = vectorizable_elements; i < (int32_t)neblock_quot; i++) {
  ------------------
  |  Branch (73:35): [True: 30.7M, False: 1.84M]
  ------------------
   74|   276M|    for (j = 0; j < type_size; j++) {
  ------------------
  |  Branch (74:17): [True: 245M, False: 30.7M]
  ------------------
   75|   245M|      _dest[i * type_size + j] = _src[j * neblock_quot + i];
   76|   245M|    }
   77|  30.7M|  }
   78|       |
   79|       |  /* Copy any leftover bytes in the block without unshuffling them. */
   80|  1.84M|  memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem);
   81|  1.84M|}

shuffle_bytedelta_available:
  432|     72|int shuffle_bytedelta_available(void) {
  433|     72|  init_shuffle_implementation();
  434|       |  return host_shuffle_bytedelta_forward != NULL;
  435|     72|}
shuffle_bytedelta_backward:
  446|     72|int shuffle_bytedelta_backward(const uint8_t *input, uint8_t *output, int32_t length, int typesize) {
  447|     72|  init_shuffle_implementation();
  448|     72|  if ((typesize != 2 && typesize != 4 && typesize != 8) || length < 0 || input == output ||
  ------------------
  |  Branch (448:8): [True: 36, False: 36]
  |  Branch (448:25): [True: 20, False: 16]
  |  Branch (448:42): [True: 0, False: 20]
  |  Branch (448:60): [True: 0, False: 72]
  |  Branch (448:74): [True: 0, False: 72]
  ------------------
  449|     72|      host_shuffle_bytedelta_backward == NULL) {
  ------------------
  |  Branch (449:7): [True: 0, False: 72]
  ------------------
  450|      0|    return 0;
  451|      0|  }
  452|     72|  return host_shuffle_bytedelta_backward(input, output, length, typesize);
  453|     72|}
blosc2_shuffle:
  459|  11.4M|               const void* src, void* dest) {
  460|       |  /* Initialize the shuffle implementation if necessary. */
  461|  11.4M|  init_shuffle_implementation();
  462|       |
  463|  11.4M|  if (typesize < 1 || typesize > 256 || blocksize < 0) {
  ------------------
  |  Branch (463:7): [True: 797, False: 11.4M]
  |  Branch (463:23): [True: 18.4E, False: 11.4M]
  |  Branch (463:41): [True: 41, False: 11.4M]
  ------------------
  464|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  465|      0|  }
  466|       |
  467|       |  /* Shuffling single bytes is the identity; the generic routine would copy them one by one. */
  468|  11.4M|  if (typesize == 1) {
  ------------------
  |  Branch (468:7): [True: 0, False: 11.4M]
  ------------------
  469|      0|    if (dest != src) {
  ------------------
  |  Branch (469:9): [True: 0, False: 0]
  ------------------
  470|      0|      memcpy(dest, src, (size_t)blocksize);
  471|      0|    }
  472|      0|    return blocksize;
  473|      0|  }
  474|       |
  475|       |  /* The implementation is initialized.
  476|       |     Dispatch to its shuffle routine. */
  477|  11.4M|  (host_implementation.shuffle)(typesize, blocksize, src, dest);
  478|       |
  479|  11.4M|  return blocksize;
  480|  11.4M|}
blosc2_unshuffle:
  486|  5.08M|                 const void* src, void* dest) {
  487|       |  /* Initialize the shuffle implementation if necessary. */
  488|  5.08M|  init_shuffle_implementation();
  489|       |
  490|  5.08M|  if (typesize < 1 || typesize > 256 || blocksize < 0) {
  ------------------
  |  Branch (490:7): [True: 0, False: 5.08M]
  |  Branch (490:23): [True: 0, False: 5.08M]
  |  Branch (490:41): [True: 0, False: 5.08M]
  ------------------
  491|      0|    return BLOSC2_ERROR_INVALID_PARAM;
  492|      0|  }
  493|       |
  494|       |  /* Unshuffling single bytes is the identity (see blosc2_shuffle). */
  495|  5.08M|  if (typesize == 1) {
  ------------------
  |  Branch (495:7): [True: 0, False: 5.08M]
  ------------------
  496|      0|    if (dest != src) {
  ------------------
  |  Branch (496:9): [True: 0, False: 0]
  ------------------
  497|      0|      memcpy(dest, src, (size_t)blocksize);
  498|      0|    }
  499|      0|    return blocksize;
  500|      0|  }
  501|       |
  502|       |  /* The implementation is initialized.
  503|       |     Dispatch to it's unshuffle routine. */
  504|  5.08M|  (host_implementation.unshuffle)(typesize, blocksize, src, dest);
  505|       |
  506|  5.08M|  return blocksize;
  507|  5.08M|}
bitunshuffle:
  566|    465|                     const uint8_t format_version) {
  567|       |  /* Initialize the shuffle implementation if necessary. */
  568|    465|  init_shuffle_implementation();
  569|    465|  size_t size = blocksize / typesize;
  570|       |
  571|    465|  if (format_version == 2) {
  ------------------
  |  Branch (571:7): [True: 155, False: 310]
  ------------------
  572|       |    /* Starting from version 3, bitshuffle() works differently */
  573|    155|    if ((size % 8) == 0) {
  ------------------
  |  Branch (573:9): [True: 100, False: 55]
  ------------------
  574|       |      /* The number of elems is a multiple of 8 which is supported by
  575|       |         bitshuffle. */
  576|    100|      int ret = (int) run_bitshuffle(host_implementation.bitunshuffle,
  577|    100|                                     src, dest, size, typesize, tmp);
  578|    100|      if (ret < 0) {
  ------------------
  |  Branch (578:11): [True: 0, False: 100]
  ------------------
  579|       |        // Some error in bitshuffle (should not happen)
  580|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  581|      0|        return ret;
  582|      0|      }
  583|       |      /* Copy the leftovers (the bytes that do not make up a whole element), as
  584|       |         Blosc1 does when it writes them after the shuffled part. */
  585|    100|      size_t offset = size * typesize;
  586|    100|      memcpy((uint8_t *) dest + offset, (const uint8_t *) src + offset, blocksize - offset);
  587|    100|    }
  588|     55|    else {
  589|     55|      memcpy(dest, src, blocksize);
  590|     55|    }
  591|    155|  }
  592|    310|  else {
  593|       |    /* bitshuffle only supports a number of bytes that is a multiple of 8. */
  594|    310|    size -= size % 8;
  595|    310|    int ret = (int) run_bitshuffle(host_implementation.bitunshuffle, src, dest, size, typesize, tmp);
  596|    310|    if (ret < 0) {
  ------------------
  |  Branch (596:9): [True: 0, False: 310]
  ------------------
  597|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|      0|      return ret;
  599|      0|    }
  600|       |
  601|       |    /* Copy the leftovers */
  602|    310|    size_t offset = size * typesize;
  603|    310|    memcpy((uint8_t *) dest + offset, (const uint8_t *) src + offset, blocksize - offset);
  604|    310|  }
  605|       |
  606|    465|  return blocksize;
  607|    465|}
shuffle.c:init_shuffle_implementation:
  425|  16.5M|static void init_shuffle_implementation(void) {
  426|  16.5M|  pthread_once(&implementation_once, set_host_implementation);
  427|  16.5M|}
shuffle.c:set_host_implementation:
  391|      1|static void set_host_implementation(void) {
  392|      1|  host_implementation = get_shuffle_implementation();
  393|      1|#if defined(SHUFFLE_BYTEDELTA_SSSE3_ENABLED)
  394|       |  /* SSSE3 needs only the legacy XMM state, not AVX/XSAVE or YMM support. */
  395|      1|  if (blosc_get_cpu_features() & BLOSC_HAVE_SSSE3) {
  ------------------
  |  Branch (395:7): [True: 1, False: 0]
  ------------------
  396|      1|    host_shuffle_bytedelta_forward = shuffle_bytedelta_ssse3_forward;
  397|      1|    host_shuffle_bytedelta_backward = shuffle_bytedelta_ssse3_backward;
  398|      1|  }
  399|       |#elif defined(__aarch64__) || defined(_M_ARM64)
  400|       |  host_shuffle_bytedelta_forward = shuffle_bytedelta_neon_forward;
  401|       |  host_shuffle_bytedelta_backward = shuffle_bytedelta_neon_backward;
  402|       |#endif
  403|      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:
  512|    410|                              const size_t size, const size_t typesize, void* tmp) {
  513|    410|  if (size == 0) {
  ------------------
  |  Branch (513:7): [True: 58, False: 352]
  ------------------
  514|     58|    return 0;  /* fewer than 8 elements: only leftovers */
  515|     58|  }
  516|    352|  void* scratch = (tmp != NULL) ? tmp : malloc(size * typesize);
  ------------------
  |  Branch (516:19): [True: 352, False: 0]
  ------------------
  517|    352|  if (scratch == NULL) {
  ------------------
  |  Branch (517:7): [True: 0, False: 352]
  ------------------
  518|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
  519|      0|  }
  520|    352|  int64_t ret = routine(src, dest, size, typesize, scratch);
  521|    352|  if (scratch != tmp) {
  ------------------
  |  Branch (521:7): [True: 0, False: 352]
  ------------------
  522|      0|    free(scratch);
  523|      0|  }
  524|    352|  return ret;
  525|    352|}

blosc_stune_next_blocksize:
   47|  3.14M|int blosc_stune_next_blocksize(blosc2_context *context) {
   48|  3.14M|  int32_t clevel = context->clevel;
   49|  3.14M|  int32_t typesize = context->typesize;
   50|  3.14M|  int32_t nbytes = context->sourcesize;
   51|  3.14M|  int32_t user_blocksize = context->blocksize;
   52|  3.14M|  int32_t blocksize = nbytes;
   53|       |
   54|       |  // Protection against very small buffers
   55|  3.14M|  if (nbytes < typesize) {
  ------------------
  |  Branch (55:7): [True: 6.58k, False: 3.13M]
  ------------------
   56|  6.58k|    context->blocksize = 1;
   57|  6.58k|    return BLOSC2_ERROR_SUCCESS;
   58|  6.58k|  }
   59|       |
   60|  3.13M|  int splitmode = split_block(context, typesize, blocksize);
   61|  3.13M|  if (user_blocksize) {
  ------------------
  |  Branch (61:7): [True: 3.13M, False: 0]
  ------------------
   62|  3.13M|    blocksize = user_blocksize;
   63|  3.13M|    goto last;
   64|  3.13M|  }
   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.13M|  last:
  150|       |  /* Check that blocksize is not too large */
  151|  3.13M|  if (blocksize > nbytes) {
  ------------------
  |  Branch (151:7): [True: 392k, False: 2.74M]
  ------------------
  152|   392k|    blocksize = nbytes;
  153|   392k|  }
  154|       |
  155|       |  // blocksize *must absolutely* be a multiple of the typesize
  156|  3.13M|  if (blocksize > typesize) {
  ------------------
  |  Branch (156:7): [True: 2.28M, False: 845k]
  ------------------
  157|  2.28M|    blocksize = blocksize / typesize * typesize;
  158|  2.28M|  }
  159|       |
  160|  3.13M|  context->blocksize = blocksize;
  161|  3.13M|  BLOSC_INFO("compcode: %d, clevel: %d, blocksize: %d, splitmode: %d, typesize: %d",
  ------------------
  |  |  121|  3.13M|    do {                                            \
  |  |  122|  3.13M|        const char *__e = getenv("BLOSC_INFO");     \
  |  |  123|  3.13M|        if (!__e) { break; }                        \
  |  |  ------------------
  |  |  |  Branch (123:13): [True: 3.13M, False: 0]
  |  |  ------------------
  |  |  124|  3.13M|        fprintf(stderr, "[INFO] - " msg "\n", ##__VA_ARGS__); \
  |  |  125|      0|    } while(0)
  |  |  ------------------
  |  |  |  Branch (125:13): [Folded, False: 0]
  |  |  ------------------
  ------------------
  162|  3.13M|             context->compcode, context->clevel, blocksize, splitmode, typesize);
  163|       |
  164|  3.13M|  return BLOSC2_ERROR_SUCCESS;
  165|      0|}
split_block:
  190|  4.47M|int split_block(blosc2_context *context, int32_t typesize, int32_t blocksize) {
  191|  4.47M|  if (context->blosc1_format &&
  ------------------
  |  Branch (191:7): [True: 0, False: 4.47M]
  ------------------
  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|  4.47M|  switch (context->splitmode) {
  197|      0|    case BLOSC_ALWAYS_SPLIT:
  ------------------
  |  Branch (197:5): [True: 0, False: 4.47M]
  ------------------
  198|      0|      return 1;
  199|  2.01M|    case BLOSC_NEVER_SPLIT:
  ------------------
  |  Branch (199:5): [True: 2.01M, False: 2.45M]
  ------------------
  200|  2.01M|      return 0;
  201|  2.45M|    case BLOSC_FORWARD_COMPAT_SPLIT:
  ------------------
  |  Branch (201:5): [True: 2.45M, False: 2.01M]
  ------------------
  202|  2.45M|    case BLOSC_AUTO_SPLIT:
  ------------------
  |  Branch (202:5): [True: 0, False: 4.47M]
  ------------------
  203|       |      // These cases will be handled later
  204|  2.45M|      break;
  205|      0|    default:
  ------------------
  |  Branch (205:5): [True: 0, False: 4.47M]
  ------------------
  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|  4.47M|  }
  208|       |
  209|  2.45M|  int compcode = context->compcode;
  210|  2.45M|  if (compcode == BLOSC_CODEC_OPENZL) {
  ------------------
  |  Branch (210:7): [True: 0, False: 2.45M]
  ------------------
  211|       |    // Never split blocks for OpenZL, as it has its own block mechanisms
  212|      0|    return 0;
  213|      0|  }
  214|  2.45M|  return (
  215|       |          // Fast codecs like blosclz, lz4 seems to prefer to split
  216|  2.45M|          ((compcode == BLOSC_BLOSCLZ) || (compcode == BLOSC_LZ4)
  ------------------
  |  Branch (216:12): [True: 2.45M, 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|  2.45M|            ) &&
  220|       |          // ...but split seems to harm cratio too much when not using shuffle
  221|  2.45M|          (context->filter_flags & BLOSC_DOSHUFFLE) &&
  ------------------
  |  Branch (221:11): [True: 2.45M, False: 0]
  ------------------
  222|  2.45M|          (typesize <= MAX_STREAMS) &&
  ------------------
  |  |   24|  2.45M|#define MAX_STREAMS 16 /* Cannot be larger than 128 */
  ------------------
  |  Branch (222:11): [True: 2.45M, False: 0]
  ------------------
  223|  2.45M|          (blocksize / typesize) >= BLOSC_MIN_BUFFERSIZE);
  ------------------
  |  Branch (223:11): [True: 1.46M, False: 993k]
  ------------------
  224|  2.45M|}

blosc_set_timestamp:
   56|  1.77M|void blosc_set_timestamp(blosc_timestamp_t* timestamp) {
   57|       |  clock_gettime(CLOCK_MONOTONIC, timestamp);
   58|  1.77M|}

b2nd.c:b2nd_deserialize_meta_inline:
  707|  7.55k|                                                int32_t *chunkshape, int32_t *blockshape, char **dtype, int8_t *dtype_format) {
  708|  7.55k|  BLOSC_ERROR_NULL(smeta, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  709|  7.55k|  BLOSC_ERROR_NULL(ndim, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  710|  7.55k|  BLOSC_ERROR_NULL(shape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  711|  7.55k|  BLOSC_ERROR_NULL(chunkshape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  712|  7.55k|  BLOSC_ERROR_NULL(blockshape, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  713|  7.55k|  if (dtype != NULL) {
  ------------------
  |  Branch (713:7): [True: 7.55k, False: 0]
  ------------------
  714|  7.55k|    *dtype = NULL;
  715|  7.55k|  }
  716|  7.55k|  if (dtype_format != NULL) {
  ------------------
  |  Branch (716:7): [True: 7.55k, False: 0]
  ------------------
  717|  7.55k|    *dtype_format = 0;
  718|  7.55k|  }
  719|  7.55k|  if (smeta_len <= 0) {
  ------------------
  |  Branch (719:7): [True: 0, False: 7.55k]
  ------------------
  720|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  721|      0|    return BLOSC2_ERROR_FAILURE;
  722|      0|  }
  723|       |
  724|  7.55k|  const uint8_t *pmeta = smeta;
  725|       |
  726|  7.55k|#define B2ND_REQUIRE_META_NBYTES(nbytes)                                             \
  727|  7.55k|  do {                                                                                \
  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  731|  7.55k|      BLOSC_TRACE_ERROR("Malformed b2nd metalayer: truncated metadata");            \
  732|  7.55k|      return BLOSC2_ERROR_FAILURE;                                                    \
  733|  7.55k|    }                                                                                 \
  734|  7.55k|  } while (0)
  735|       |
  736|       |  // Check that we have an array with 7 entries (version, ndim, shape, chunkshape, blockshape, dtype_format, dtype)
  737|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  738|  7.55k|  pmeta += 1;
  739|       |
  740|       |  // version entry
  741|       |  // int8_t version = (int8_t)pmeta[0];  // positive fixnum (7-bit positive integer) commented to avoid warning
  742|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  743|  7.55k|  pmeta += 1;
  744|       |
  745|       |  // ndim entry
  746|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  747|  7.55k|  *ndim = (int8_t) pmeta[0];
  748|  7.55k|  int8_t ndim_aux = *ndim;  // positive fixnum (7-bit positive integer)
  749|  7.55k|  if (ndim_aux < 0 || ndim_aux > B2ND_MAX_DIM) {
  ------------------
  |  |   50|  7.55k|#define B2ND_MAX_DIM 16
  ------------------
  |  Branch (749:7): [True: 0, False: 7.55k]
  |  Branch (749:23): [True: 0, False: 7.55k]
  ------------------
  750|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  751|      0|    return BLOSC2_ERROR_FAILURE;
  752|      0|  }
  753|  7.55k|  pmeta += 1;
  754|       |
  755|       |  // shape entry
  756|       |  // Initialize to ones, as required by b2nd
  757|  41.0k|  for (int i = 0; i < ndim_aux; i++) shape[i] = 1;
  ------------------
  |  Branch (757:19): [True: 33.4k, False: 7.55k]
  ------------------
  758|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  759|  7.55k|  pmeta += 1;
  760|  41.0k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (760:22): [True: 33.4k, False: 7.55k]
  ------------------
  761|  33.4k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int64_t));
  ------------------
  |  |  727|  33.4k|  do {                                                                                \
  |  |  728|  33.4k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  33.4k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  33.4k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 33.4k]
  |  |  |  Branch (730:29): [True: 0, False: 33.4k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  33.4k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 33.4k]
  |  |  ------------------
  ------------------
  762|  33.4k|    pmeta += 1;
  763|  33.4k|    swap_store(shape + i, pmeta, sizeof(int64_t));
  764|  33.4k|    pmeta += sizeof(int64_t);
  765|  33.4k|  }
  766|       |
  767|       |  // chunkshape entry
  768|       |  // Initialize to ones, as required by b2nd
  769|  41.0k|  for (int i = 0; i < ndim_aux; i++) chunkshape[i] = 1;
  ------------------
  |  Branch (769:19): [True: 33.4k, False: 7.55k]
  ------------------
  770|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  771|  7.55k|  pmeta += 1;
  772|  41.0k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (772:22): [True: 33.4k, False: 7.55k]
  ------------------
  773|  33.4k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int32_t));
  ------------------
  |  |  727|  33.4k|  do {                                                                                \
  |  |  728|  33.4k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  33.4k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  33.4k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 33.4k]
  |  |  |  Branch (730:29): [True: 0, False: 33.4k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  33.4k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 33.4k]
  |  |  ------------------
  ------------------
  774|  33.4k|    pmeta += 1;
  775|  33.4k|    swap_store(chunkshape + i, pmeta, sizeof(int32_t));
  776|  33.4k|    pmeta += sizeof(int32_t);
  777|  33.4k|  }
  778|       |
  779|       |  // blockshape entry
  780|       |  // Initialize to ones, as required by b2nd
  781|  41.0k|  for (int i = 0; i < ndim_aux; i++) blockshape[i] = 1;
  ------------------
  |  Branch (781:19): [True: 33.4k, False: 7.55k]
  ------------------
  782|  7.55k|  B2ND_REQUIRE_META_NBYTES(1);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  783|  7.55k|  pmeta += 1;
  784|  41.0k|  for (int8_t i = 0; i < ndim_aux; i++) {
  ------------------
  |  Branch (784:22): [True: 33.4k, False: 7.55k]
  ------------------
  785|  33.4k|    B2ND_REQUIRE_META_NBYTES(1 + sizeof(int32_t));
  ------------------
  |  |  727|  33.4k|  do {                                                                                \
  |  |  728|  33.4k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  33.4k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  33.4k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 33.4k]
  |  |  |  Branch (730:29): [True: 0, False: 33.4k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  33.4k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 33.4k]
  |  |  ------------------
  ------------------
  786|  33.4k|    pmeta += 1;
  787|  33.4k|    swap_store(blockshape + i, pmeta, sizeof(int32_t));
  788|  33.4k|    pmeta += sizeof(int32_t);
  789|  33.4k|  }
  790|       |
  791|       |  // dtype entry
  792|  7.55k|  if (dtype_format == NULL || dtype == NULL) {
  ------------------
  |  Branch (792:7): [True: 0, False: 7.55k]
  |  Branch (792:31): [True: 0, False: 7.55k]
  ------------------
  793|      0|    return (int32_t)(pmeta - smeta);
  794|      0|  }
  795|  7.55k|  if (pmeta - smeta < smeta_len) {
  ------------------
  |  Branch (795:7): [True: 7.55k, False: 0]
  ------------------
  796|       |    // dtype info is here
  797|  7.55k|    B2ND_REQUIRE_META_NBYTES(1 + 1 + sizeof(int32_t));
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  798|  7.55k|    *dtype_format = (int8_t) *(pmeta++);
  799|  7.55k|    if (*pmeta != 0xdb) {
  ------------------
  |  Branch (799:9): [True: 0, False: 7.55k]
  ------------------
  800|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  801|      0|      return BLOSC2_ERROR_FAILURE;
  802|      0|    }
  803|  7.55k|    pmeta += 1;
  804|  7.55k|    int32_t dtype_len;
  805|  7.55k|    swap_store(&dtype_len, pmeta, sizeof(int32_t));
  806|  7.55k|    pmeta += sizeof(int32_t);
  807|  7.55k|    if (dtype_len < 0) {
  ------------------
  |  Branch (807:9): [True: 0, False: 7.55k]
  ------------------
  808|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|      0|      return BLOSC2_ERROR_FAILURE;
  810|      0|    }
  811|  7.55k|    B2ND_REQUIRE_META_NBYTES(dtype_len);
  ------------------
  |  |  727|  7.55k|  do {                                                                                \
  |  |  728|  7.55k|    size_t consumed = (size_t)(pmeta - smeta);                                        \
  |  |  729|  7.55k|    size_t total = (size_t)smeta_len;                                                 \
  |  |  730|  7.55k|    if (consumed > total || (total - consumed) < (size_t)(nbytes)) {                 \
  |  |  ------------------
  |  |  |  Branch (730:9): [True: 0, False: 7.55k]
  |  |  |  Branch (730:29): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  731|      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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  732|      0|      return BLOSC2_ERROR_FAILURE;                                                    \
  |  |  733|      0|    }                                                                                 \
  |  |  734|  7.55k|  } while (0)
  |  |  ------------------
  |  |  |  Branch (734:12): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  812|  7.55k|    size_t dtype_len_ = (size_t)dtype_len;
  813|  7.55k|    *dtype = (char*)malloc(dtype_len_ + 1);
  814|  7.55k|    BLOSC_ERROR_NULL(*dtype, BLOSC2_ERROR_MEMORY_ALLOC);
  ------------------
  |  |  104|  7.55k|    do {                                            \
  |  |  105|  7.55k|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 7.55k]
  |  |  ------------------
  |  |  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.55k|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 7.55k]
  |  |  ------------------
  ------------------
  815|  7.55k|    char* dtype_ = *dtype;
  816|  7.55k|    memcpy(dtype_, (char*)pmeta, dtype_len_);
  817|  7.55k|    dtype_[dtype_len_] = '\0';
  818|  7.55k|    pmeta += dtype_len_;
  819|  7.55k|  }
  820|      0|  else {
  821|       |    // dtype is mandatory in b2nd metalayer, but this is mainly meant as
  822|       |    // a fall-back for deprecated caterva headers
  823|      0|    *dtype = NULL;
  824|      0|    *dtype_format = 0;
  825|      0|  }
  826|       |
  827|  7.55k|#undef B2ND_REQUIRE_META_NBYTES
  828|       |
  829|  7.55k|  int32_t slen = (int32_t) (pmeta - smeta);
  830|  7.55k|  return (int)slen;
  831|  7.55k|}

blosc2.c:print_error:
  525|     10|static char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|     10|  return (char *) blosc2_error_string(rc);
  528|     10|}
schunk.c:blosc2_meta_exists:
 2685|  13.7k|static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) {
 2686|  13.7k|  if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) {
  ------------------
  |  | 1896|  13.7k|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  ------------------
  |  Branch (2686:7): [True: 0, False: 13.7k]
  ------------------
 2687|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2687|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2688|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2689|      0|  }
 2690|       |
 2691|  13.7k|  if (schunk == NULL) {
  ------------------
  |  Branch (2691:7): [True: 0, False: 13.7k]
  ------------------
 2692|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2693|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2694|      0|  }
 2695|       |
 2696|  13.7k|  for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2696:28): [True: 1.30k, False: 12.4k]
  ------------------
 2697|  1.30k|    if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) {
  ------------------
  |  Branch (2697:9): [True: 1.30k, False: 0]
  ------------------
 2698|  1.30k|      return nmetalayer;
 2699|  1.30k|    }
 2700|  1.30k|  }
 2701|  12.4k|  return BLOSC2_ERROR_NOT_FOUND;
 2702|  13.7k|}
b2nd.c:print_error:
  525|  6.93k|static char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|  6.93k|  return (char *) blosc2_error_string(rc);
  528|  6.93k|}
b2nd.c:swap_store:
 3254|   290k|static inline void swap_store(void *dest, const void *pa, int size) {
 3255|   290k|  uint8_t *pa_ = (uint8_t *) pa;
 3256|   290k|  uint8_t *pa2_ = (uint8_t*)malloc((size_t) size);
 3257|   290k|  int i = 1; /* for big/little endian detection */
 3258|   290k|  char *p = (char *) &i;
 3259|       |
 3260|   290k|  if (p[0] == 1) {
  ------------------
  |  Branch (3260:7): [True: 290k, False: 0]
  ------------------
 3261|       |    /* little endian */
 3262|   290k|    switch (size) {
 3263|  89.8k|      case 8:
  ------------------
  |  Branch (3263:7): [True: 89.8k, False: 201k]
  ------------------
 3264|  89.8k|        pa2_[0] = pa_[7];
 3265|  89.8k|        pa2_[1] = pa_[6];
 3266|  89.8k|        pa2_[2] = pa_[5];
 3267|  89.8k|        pa2_[3] = pa_[4];
 3268|  89.8k|        pa2_[4] = pa_[3];
 3269|  89.8k|        pa2_[5] = pa_[2];
 3270|  89.8k|        pa2_[6] = pa_[1];
 3271|  89.8k|        pa2_[7] = pa_[0];
 3272|  89.8k|        break;
 3273|   201k|      case 4:
  ------------------
  |  Branch (3273:7): [True: 201k, False: 89.8k]
  ------------------
 3274|   201k|        pa2_[0] = pa_[3];
 3275|   201k|        pa2_[1] = pa_[2];
 3276|   201k|        pa2_[2] = pa_[1];
 3277|   201k|        pa2_[3] = pa_[0];
 3278|   201k|        break;
 3279|      0|      case 2:
  ------------------
  |  Branch (3279:7): [True: 0, False: 290k]
  ------------------
 3280|      0|        pa2_[0] = pa_[1];
 3281|      0|        pa2_[1] = pa_[0];
 3282|      0|        break;
 3283|      0|      case 1:
  ------------------
  |  Branch (3283:7): [True: 0, False: 290k]
  ------------------
 3284|      0|        pa2_[0] = pa_[0];
 3285|      0|        break;
 3286|      0|      default:
  ------------------
  |  Branch (3286:7): [True: 0, False: 290k]
  ------------------
 3287|      0|        fprintf(stderr, "Unhandled nitems: %d\n", size);
 3288|   290k|    }
 3289|   290k|  } else {
 3290|       |    /* big endian: native byte order is already big-endian, just copy */
 3291|      0|    memcpy(pa2_, pa_, size);
 3292|      0|  }
 3293|   290k|  memcpy(dest, pa2_, size);
 3294|   290k|  free(pa2_);
 3295|   290k|}
b2nd.c:blosc2_meta_exists:
 2685|  8.86k|static inline int blosc2_meta_exists(blosc2_schunk *schunk, const char *name) {
 2686|  8.86k|  if (strlen(name) > BLOSC2_METALAYER_NAME_MAXLEN) {
  ------------------
  |  | 1896|  8.86k|#define BLOSC2_METALAYER_NAME_MAXLEN 31
  ------------------
  |  Branch (2686:7): [True: 0, False: 8.86k]
  ------------------
 2687|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  | 2687|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2688|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2689|      0|  }
 2690|       |
 2691|  8.86k|  if (schunk == NULL) {
  ------------------
  |  Branch (2691:7): [True: 0, False: 8.86k]
  ------------------
 2692|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2693|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2694|      0|  }
 2695|       |
 2696|  8.86k|  for (int nmetalayer = 0; nmetalayer < schunk->nmetalayers; nmetalayer++) {
  ------------------
  |  Branch (2696:28): [True: 8.85k, False: 4]
  ------------------
 2697|  8.85k|    if (strcmp(name, schunk->metalayers[nmetalayer]->name) == 0) {
  ------------------
  |  Branch (2697:9): [True: 8.85k, False: 0]
  ------------------
 2698|  8.85k|      return nmetalayer;
 2699|  8.85k|    }
 2700|  8.85k|  }
 2701|      4|  return BLOSC2_ERROR_NOT_FOUND;
 2702|  8.86k|}
b2nd.c:blosc2_meta_get:
 2754|  7.56k|                                  int32_t *content_len) {
 2755|  7.56k|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2755:7): [True: 0, False: 7.56k]
  |  Branch (2755:25): [True: 0, False: 7.56k]
  |  Branch (2755:41): [True: 0, False: 7.56k]
  |  Branch (2755:60): [True: 0, False: 7.56k]
  ------------------
 2756|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2757|      0|    return BLOSC2_ERROR_INVALID_PARAM;
 2758|      0|  }
 2759|       |
 2760|  7.56k|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2761|  7.56k|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2761:7): [True: 4, False: 7.55k]
  ------------------
 2762|      4|    BLOSC_TRACE_WARNING("Metalayer \"%s\" not found.", name);
  ------------------
  |  |   94|      4|#define BLOSC_TRACE_WARNING(msg, ...) BLOSC_TRACE(warning, 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2763|      4|    return nmetalayer;
 2764|      4|  }
 2765|  7.55k|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2766|  7.55k|  if (len < 0) {
  ------------------
  |  Branch (2766:7): [True: 0, False: 7.55k]
  ------------------
 2767|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2768|      0|    return BLOSC2_ERROR_DATA;
 2769|      0|  }
 2770|  7.55k|  *content_len = len;
 2771|  7.55k|  if (len == 0) {
  ------------------
  |  Branch (2771:7): [True: 0, False: 7.55k]
  ------------------
 2772|      0|    *content = NULL;
 2773|      0|    return nmetalayer;
 2774|      0|  }
 2775|  7.55k|  *content = (uint8_t*)malloc((size_t)len);
 2776|  7.55k|  if (*content == NULL) {
  ------------------
  |  Branch (2776:7): [True: 0, False: 7.55k]
  ------------------
 2777|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2778|      0|    *content_len = 0;
 2779|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2780|      0|  }
 2781|  7.55k|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2781:7): [True: 7.55k, False: 0]
  |  Branch (2781:18): [True: 0, False: 7.55k]
  ------------------
 2782|      0|    free(*content);
 2783|      0|    *content = NULL;
 2784|      0|    *content_len = 0;
 2785|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2786|      0|    return BLOSC2_ERROR_DATA;
 2787|      0|  }
 2788|  7.55k|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2789|  7.55k|  return nmetalayer;
 2790|  7.55k|}
ndcell.c:blosc2_meta_get:
 2754|      9|                                  int32_t *content_len) {
 2755|      9|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2755:7): [True: 9, False: 0]
  |  Branch (2755:25): [True: 0, False: 0]
  |  Branch (2755:41): [True: 0, False: 0]
  |  Branch (2755:60): [True: 0, False: 0]
  ------------------
 2756|      9|    BLOSC_TRACE_ERROR("Invalid parameters.");
  ------------------
  |  |   93|      9|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      9|    do {                                            \
  |  |  |  |   98|      9|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      9|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      9|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2757|      9|    return BLOSC2_ERROR_INVALID_PARAM;
 2758|      9|  }
 2759|       |
 2760|      0|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2761|      0|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2761:7): [True: 0, False: 0]
  ------------------
 2762|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2763|      0|    return nmetalayer;
 2764|      0|  }
 2765|      0|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2766|      0|  if (len < 0) {
  ------------------
  |  Branch (2766:7): [True: 0, False: 0]
  ------------------
 2767|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2768|      0|    return BLOSC2_ERROR_DATA;
 2769|      0|  }
 2770|      0|  *content_len = len;
 2771|      0|  if (len == 0) {
  ------------------
  |  Branch (2771:7): [True: 0, False: 0]
  ------------------
 2772|      0|    *content = NULL;
 2773|      0|    return nmetalayer;
 2774|      0|  }
 2775|      0|  *content = (uint8_t*)malloc((size_t)len);
 2776|      0|  if (*content == NULL) {
  ------------------
  |  Branch (2776:7): [True: 0, False: 0]
  ------------------
 2777|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2778|      0|    *content_len = 0;
 2779|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2780|      0|  }
 2781|      0|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2781:7): [True: 0, False: 0]
  |  Branch (2781:18): [True: 0, False: 0]
  ------------------
 2782|      0|    free(*content);
 2783|      0|    *content = NULL;
 2784|      0|    *content_len = 0;
 2785|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2786|      0|    return BLOSC2_ERROR_DATA;
 2787|      0|  }
 2788|      0|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2789|      0|  return nmetalayer;
 2790|      0|}
ndmean.c:blosc2_meta_get:
 2754|      2|                                  int32_t *content_len) {
 2755|      2|  if (schunk == NULL || name == NULL || content == NULL || content_len == NULL) {
  ------------------
  |  Branch (2755:7): [True: 2, False: 0]
  |  Branch (2755:25): [True: 0, False: 0]
  |  Branch (2755:41): [True: 0, False: 0]
  |  Branch (2755:60): [True: 0, False: 0]
  ------------------
 2756|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2757|      2|    return BLOSC2_ERROR_INVALID_PARAM;
 2758|      2|  }
 2759|       |
 2760|      0|  int nmetalayer = blosc2_meta_exists(schunk, name);
 2761|      0|  if (nmetalayer < 0) {
  ------------------
  |  Branch (2761:7): [True: 0, False: 0]
  ------------------
 2762|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2763|      0|    return nmetalayer;
 2764|      0|  }
 2765|      0|  int32_t len = schunk->metalayers[nmetalayer]->content_len;
 2766|      0|  if (len < 0) {
  ------------------
  |  Branch (2766:7): [True: 0, False: 0]
  ------------------
 2767|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2768|      0|    return BLOSC2_ERROR_DATA;
 2769|      0|  }
 2770|      0|  *content_len = len;
 2771|      0|  if (len == 0) {
  ------------------
  |  Branch (2771:7): [True: 0, False: 0]
  ------------------
 2772|      0|    *content = NULL;
 2773|      0|    return nmetalayer;
 2774|      0|  }
 2775|      0|  *content = (uint8_t*)malloc((size_t)len);
 2776|      0|  if (*content == NULL) {
  ------------------
  |  Branch (2776:7): [True: 0, False: 0]
  ------------------
 2777|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2778|      0|    *content_len = 0;
 2779|      0|    return BLOSC2_ERROR_MEMORY_ALLOC;
 2780|      0|  }
 2781|      0|  if (len > 0 && schunk->metalayers[nmetalayer]->content == NULL) {
  ------------------
  |  Branch (2781:7): [True: 0, False: 0]
  |  Branch (2781:18): [True: 0, False: 0]
  ------------------
 2782|      0|    free(*content);
 2783|      0|    *content = NULL;
 2784|      0|    *content_len = 0;
 2785|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2786|      0|    return BLOSC2_ERROR_DATA;
 2787|      0|  }
 2788|      0|  memcpy(*content, schunk->metalayers[nmetalayer]->content, (size_t)len);
 2789|      0|  return nmetalayer;
 2790|      0|}
bytedelta.c:print_error:
  525|      6|static char *print_error(int rc) {
  526|       |  // TODO: remove this function, use blosc2_error_string only
  527|      6|  return (char *) blosc2_error_string(rc);
  528|      6|}

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

ndlz_decompress:
   42|     84|                    uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
   43|     84|  NDLZ_ERROR_NULL(input);
  ------------------
  |  |   19|     84|  do {                           \
  |  |   20|     84|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 84]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     84|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 84]
  |  |  ------------------
  ------------------
   44|     84|  NDLZ_ERROR_NULL(output);
  ------------------
  |  |   19|     84|  do {                           \
  |  |   20|     84|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 84]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     84|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 84]
  |  |  ------------------
  ------------------
   45|     84|  NDLZ_ERROR_NULL(dparams);
  ------------------
  |  |   19|     84|  do {                           \
  |  |   20|     84|    if ((pointer) == NULL) {     \
  |  |  ------------------
  |  |  |  Branch (20:9): [True: 0, False: 84]
  |  |  ------------------
  |  |   21|      0|      return 0;                  \
  |  |   22|      0|    }                            \
  |  |   23|     84|  } while (0)
  |  |  ------------------
  |  |  |  Branch (23:12): [Folded, False: 84]
  |  |  ------------------
  ------------------
   46|     84|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|     84|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
   47|       |
   48|     84|  switch (meta) {
   49|     35|    case 4:
  ------------------
  |  Branch (49:5): [True: 35, False: 49]
  ------------------
   50|     35|      return ndlz4_decompress(input, input_len, output, output_len, meta, dparams);
   51|     48|    case 8:
  ------------------
  |  Branch (51:5): [True: 48, False: 36]
  ------------------
   52|     48|      return ndlz8_decompress(input, input_len, output, output_len, meta, dparams);
   53|      1|    default:
  ------------------
  |  Branch (53:5): [True: 1, False: 83]
  ------------------
   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|     84|  }
   56|      1|  return BLOSC2_ERROR_FAILURE;
   57|     84|}

ndlz4_decompress:
  526|     35|                     uint8_t meta, blosc2_dparams *dparams) {
  527|     35|  BLOSC_UNUSED_PARAM(meta);
  ------------------
  |  |   28|     35|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  528|     35|  BLOSC_UNUSED_PARAM(dparams);
  ------------------
  |  |   28|     35|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  529|     35|  BLOSC_ERROR_NULL(input, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     35|    do {                                            \
  |  |  105|     35|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 35]
  |  |  ------------------
  |  |  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|     35|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 35]
  |  |  ------------------
  ------------------
  530|     35|  BLOSC_ERROR_NULL(output, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     35|    do {                                            \
  |  |  105|     35|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 35]
  |  |  ------------------
  |  |  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|     35|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 35]
  |  |  ------------------
  ------------------
  531|       |
  532|     35|  uint8_t *ip = (uint8_t *) input;
  533|     35|  uint8_t *op = (uint8_t *) output;
  534|     35|  uint8_t ndim;
  535|     35|  int32_t blockshape[2];
  536|     35|  int32_t eshape[2];
  537|     35|  uint8_t *buffercpy;
  538|     35|  uint8_t local_buffer[16];
  539|     35|  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|     35|  if (NDLZ_UNEXPECT_CONDITIONAL(input_len < (int32_t) (1 + 2 * sizeof(int32_t)))) {
  ------------------
  |  |   30|     35|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 1, False: 34]
  |  |  ------------------
  ------------------
  546|      1|    return 0;
  547|      1|  }
  548|     34|  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|     34|#define NDLZ4_CHECK_RANGE(pos, len)                                              \
  560|     34|  do {                                                                           \
  561|     34|    int64_t _pos = (int64_t) (pos);                                              \
  562|     34|    int64_t _len = (int64_t) (len);                                              \
  563|     34|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  564|     34|      BLOSC_TRACE_ERROR("ndlz4: out-of-bounds reference in compressed stream");  \
  565|     34|      return BLOSC2_ERROR_FAILURE;                                               \
  566|     34|    }                                                                            \
  567|     34|  } while (0)
  568|       |
  569|       |  /* we start with literal copy */
  570|     34|  ndim = *ip;
  571|     34|  ip++;
  572|     34|  if (ndim != 2) {
  ------------------
  |  Branch (572:7): [True: 2, False: 32]
  ------------------
  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|     32|  memcpy(&blockshape[0], ip, 4);
  577|     32|  ip += 4;
  578|     32|  memcpy(&blockshape[1], ip, 4);
  579|     32|  ip += 4;
  580|       |
  581|       |  // Sanity check.  See https://www.cve.org/CVERecord?id=CVE-2024-3204
  582|     32|  if (output_len < 0 || blockshape[0] < 0 || blockshape[1] < 0) {
  ------------------
  |  Branch (582:7): [True: 0, False: 32]
  |  Branch (582:25): [True: 5, False: 27]
  |  Branch (582:46): [True: 1, False: 26]
  ------------------
  583|      6|    BLOSC_TRACE_ERROR("Output length or blockshape is negative");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|      6|    return BLOSC2_ERROR_FAILURE;
  585|      6|  }
  586|       |
  587|     26|  eshape[0] = ((blockshape[0] + 3) / 4) * 4;
  588|     26|  eshape[1] = ((blockshape[1] + 3) / 4) * 4;
  589|       |
  590|     26|  if (NDLZ_UNEXPECT_CONDITIONAL((int64_t)output_len < (int64_t)blockshape[0] * (int64_t)blockshape[1])) {
  ------------------
  |  |   30|     26|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 23, False: 3]
  |  |  ------------------
  ------------------
  591|     23|    BLOSC_TRACE_ERROR("The blockshape is bigger than the output buffer");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|     23|    return 0;
  593|     23|  }
  594|      3|  memset(op, 0, blockshape[0] * blockshape[1]);
  595|       |
  596|      3|  uint32_t i_stop[2];
  597|      9|  for (int i = 0; i < 2; ++i) {
  ------------------
  |  Branch (597:19): [True: 6, False: 3]
  ------------------
  598|      6|    i_stop[i] = eshape[i] / 4;
  599|      6|  }
  600|       |
  601|       |  /* main loop */
  602|      3|  uint32_t ii[2];
  603|      3|  uint32_t padding[2] = {0};
  604|      3|  uint32_t ind = 0;
  605|      3|  uint8_t cell_aux[16];
  606|  1.59G|  for (ii[0] = 0; ii[0] < i_stop[0]; ++ii[0]) {
  ------------------
  |  Branch (606:19): [True: 1.59G, False: 3]
  ------------------
  607|  1.59G|    for (ii[1] = 0; ii[1] < i_stop[1]; ++ii[1]) {      // for each cell
  ------------------
  |  Branch (607:21): [True: 0, False: 1.59G]
  ------------------
  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|  1.59G|  }
  770|      3|  ind += padding[1];
  771|       |
  772|      3|  if ((int32_t)ind != (blockshape[0] * blockshape[1])) {
  ------------------
  |  Branch (772:7): [True: 0, False: 3]
  ------------------
  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|      3|  if (ind > (uint32_t) output_len) {
  ------------------
  |  Branch (776:7): [True: 0, False: 3]
  ------------------
  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|      3|  return (int) ind;
  782|      3|#undef NDLZ4_CHECK_RANGE
  783|      3|}

ndlz8_decompress:
  444|     48|                     uint8_t meta, blosc2_dparams *dparams) {
  445|     48|  BLOSC_UNUSED_PARAM(meta);
  ------------------
  |  |   28|     48|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  446|     48|  BLOSC_UNUSED_PARAM(dparams);
  ------------------
  |  |   28|     48|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  447|     48|  BLOSC_ERROR_NULL(input, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     48|    do {                                            \
  |  |  105|     48|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 48]
  |  |  ------------------
  |  |  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|     48|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 48]
  |  |  ------------------
  ------------------
  448|     48|  BLOSC_ERROR_NULL(output, BLOSC2_ERROR_NULL_POINTER);
  ------------------
  |  |  104|     48|    do {                                            \
  |  |  105|     48|        if ((pointer) == NULL) {                    \
  |  |  ------------------
  |  |  |  Branch (105:13): [True: 0, False: 48]
  |  |  ------------------
  |  |  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|     48|    } while (0)
  |  |  ------------------
  |  |  |  Branch (109:14): [Folded, False: 48]
  |  |  ------------------
  ------------------
  449|       |
  450|     48|  const int cell_shape = 8;
  451|     48|  const int cell_size = 64;
  452|     48|  uint8_t *ip = (uint8_t *) input;
  453|     48|  uint8_t *op = (uint8_t *) output;
  454|     48|  uint8_t ndim;
  455|     48|  int32_t blockshape[2];
  456|     48|  int32_t eshape[2];
  457|     48|  uint8_t *buffercpy;
  458|     48|  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|     48|  if (NDLZ_UNEXPECT_CONDITIONAL(input_len < (int32_t) (1 + 2 * sizeof(int32_t)))) {
  ------------------
  |  |   30|     48|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 1, False: 47]
  |  |  ------------------
  ------------------
  465|      1|    return 0;
  466|      1|  }
  467|     47|  uint8_t *ip_limit = ip + input_len;
  468|       |
  469|       |  /* we start with literal copy */
  470|     47|  ndim = *ip;
  471|     47|  ip++;
  472|     47|  if (ndim != 2) {
  ------------------
  |  Branch (472:7): [True: 1, False: 46]
  ------------------
  473|      1|    BLOSC_TRACE_ERROR("This codec only works for ndim = 2");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|      1|    return BLOSC2_ERROR_FAILURE;
  475|      1|  }
  476|     46|  memcpy(&blockshape[0], ip, 4);
  477|     46|  ip += 4;
  478|     46|  memcpy(&blockshape[1], ip, 4);
  479|     46|  ip += 4;
  480|       |
  481|       |  // Sanity check.  See https://www.cve.org/CVERecord?id=CVE-2024-3203
  482|     46|  if (output_len < 0 || blockshape[0] < 0 || blockshape[1] < 0) {
  ------------------
  |  Branch (482:7): [True: 0, False: 46]
  |  Branch (482:25): [True: 3, False: 43]
  |  Branch (482:46): [True: 11, False: 32]
  ------------------
  483|     14|    BLOSC_TRACE_ERROR("Output length or blockshape is negative");
  ------------------
  |  |   93|     14|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     14|    do {                                            \
  |  |  |  |   98|     14|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     14|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     14|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|     14|    return BLOSC2_ERROR_FAILURE;
  485|     14|  }
  486|       |
  487|     32|  eshape[0] = ((blockshape[0] + 7) / cell_shape) * cell_shape;
  488|     32|  eshape[1] = ((blockshape[1] + 7) / cell_shape) * cell_shape;
  489|       |
  490|     32|  if (NDLZ_UNEXPECT_CONDITIONAL((int64_t)output_len < (int64_t)blockshape[0] * (int64_t)blockshape[1])) {
  ------------------
  |  |   30|     32|#define NDLZ_UNEXPECT_CONDITIONAL(c)  (__builtin_expect((c), 0))
  |  |  ------------------
  |  |  |  Branch (30:39): [True: 29, False: 3]
  |  |  ------------------
  ------------------
  491|     29|    BLOSC_TRACE_ERROR("The blockshape is bigger than the output buffer");
  ------------------
  |  |   93|     29|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|     29|    do {                                            \
  |  |  |  |   98|     29|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|     29|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|     29|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  492|     29|    return 0;
  493|     29|  }
  494|      3|  memset(op, 0, blockshape[0] * blockshape[1]);
  495|       |
  496|      3|  int32_t i_stop[2];
  497|      9|  for (int i = 0; i < 2; ++i) {
  ------------------
  |  Branch (497:19): [True: 6, False: 3]
  ------------------
  498|      6|    i_stop[i] = eshape[i] / cell_shape;
  499|      6|  }
  500|       |
  501|       |  /* main loop */
  502|      3|  int32_t ii[2];
  503|      3|  int32_t padding[2] = {0};
  504|      3|  int32_t ind = 0;
  505|      3|  uint8_t *local_buffer = malloc(cell_size);
  506|      3|  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|      3|#define NDLZ8_CHECK_RANGE(pos, len)                                              \
  518|      3|  do {                                                                           \
  519|      3|    int64_t _pos = (int64_t) (pos);                                              \
  520|      3|    int64_t _len = (int64_t) (len);                                              \
  521|      3|    if (_pos < 0 || _len < 0 || _pos > (int64_t) input_len - _len) {             \
  522|      3|      free(local_buffer);                                                        \
  523|      3|      free(cell_aux);                                                            \
  524|      3|      BLOSC_TRACE_ERROR("ndlz8: out-of-bounds reference in compressed stream");  \
  525|      3|      return BLOSC2_ERROR_FAILURE;                                               \
  526|      3|    }                                                                            \
  527|      3|  } while (0)
  528|       |
  529|   289M|  for (ii[0] = 0; ii[0] < i_stop[0]; ++ii[0]) {
  ------------------
  |  Branch (529:19): [True: 289M, False: 3]
  ------------------
  530|   289M|    for (ii[1] = 0; ii[1] < i_stop[1]; ++ii[1]) {      // for each cell
  ------------------
  |  Branch (530:21): [True: 0, False: 289M]
  ------------------
  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|   289M|  }
  651|      3|  ind += padding[1];
  652|       |
  653|      3|  free(cell_aux);
  654|      3|  free(local_buffer);
  655|       |
  656|      3|  if (ind != (blockshape[0] * blockshape[1])) {
  ------------------
  |  Branch (656:7): [True: 0, False: 3]
  ------------------
  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|      3|  if (ind > output_len) {
  ------------------
  |  Branch (660:7): [True: 0, False: 3]
  ------------------
  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|      3|  return (int) ind;
  666|      3|#undef NDLZ8_CHECK_RANGE
  667|      3|}

zfp_acc_decompress:
  294|      1|                       int32_t output_len, uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
  295|      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]
  |  |  ------------------
  ------------------
  296|      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]
  |  |  ------------------
  ------------------
  297|      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]
  |  |  ------------------
  ------------------
  298|      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]
  |  |  ------------------
  ------------------
  299|      0|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|      0|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  300|       |
  301|      0|  blosc2_schunk *sc = dparams->schunk;
  302|      0|  int32_t typesize = sc->typesize;
  303|       |
  304|      0|  double tol = (int8_t) meta;
  305|      0|  int8_t ndim;
  306|      0|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  307|      0|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  308|      0|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  309|      0|  uint8_t *smeta;
  310|      0|  int32_t smeta_len;
  311|      0|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (311:7): [True: 0, False: 0]
  ------------------
  312|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  313|      0|    free(shape);
  314|      0|    free(chunkshape);
  315|      0|    free(blockshape);
  316|      0|    return BLOSC2_ERROR_FAILURE;
  317|      0|  }
  318|      0|  int deserialize_rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL);
  319|      0|  free(smeta);
  320|       |
  321|      0|  if (zfp_check_output_size(deserialize_rc, ndim, blockshape, typesize, output_len) < 0) {
  ------------------
  |  Branch (321:7): [True: 0, False: 0]
  ------------------
  322|      0|    free(shape);
  323|      0|    free(chunkshape);
  324|      0|    free(blockshape);
  325|      0|    return BLOSC2_ERROR_FAILURE;
  326|      0|  }
  327|       |
  328|      0|  zfp_type type;     /* array scalar type */
  329|      0|  zfp_field *field;  /* array meta data */
  330|      0|  zfp_stream *zfp;   /* compressed stream */
  331|      0|  bitstream *stream = NULL; /* bit stream to write to or read from */
  332|      0|  uint8_t *padded_input = NULL;
  333|      0|  size_t zfpsize;    /* byte size of compressed stream */
  334|      0|  double tolerance = pow(10, tol);
  335|       |
  336|      0|  switch (typesize) {
  337|      0|    case sizeof(float):
  ------------------
  |  Branch (337:5): [True: 0, False: 0]
  ------------------
  338|      0|      type = zfp_type_float;
  339|      0|      break;
  340|      0|    case sizeof(double):
  ------------------
  |  Branch (340:5): [True: 0, False: 0]
  ------------------
  341|      0|      type = zfp_type_double;
  342|      0|      break;
  343|      0|    default:
  ------------------
  |  Branch (343:5): [True: 0, False: 0]
  ------------------
  344|      0|      free(shape);
  345|      0|      free(chunkshape);
  346|      0|      free(blockshape);
  347|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  348|      0|      return BLOSC2_ERROR_FAILURE;
  349|      0|  }
  350|       |
  351|      0|  zfp = zfp_stream_open(NULL);
  352|      0|  zfp_stream_set_accuracy(zfp, tolerance);
  353|       |
  354|      0|  switch (ndim) {
  355|      0|    case 1:
  ------------------
  |  Branch (355:5): [True: 0, False: 0]
  ------------------
  356|      0|      field = zfp_field_1d((void *) output, type, blockshape[0]);
  357|      0|      break;
  358|      0|    case 2:
  ------------------
  |  Branch (358:5): [True: 0, False: 0]
  ------------------
  359|      0|      field = zfp_field_2d((void *) output, type, blockshape[1], blockshape[0]);
  360|      0|      break;
  361|      0|    case 3:
  ------------------
  |  Branch (361:5): [True: 0, False: 0]
  ------------------
  362|      0|      field = zfp_field_3d((void *) output, type, blockshape[2], blockshape[1], blockshape[0]);
  363|      0|      break;
  364|      0|    case 4:
  ------------------
  |  Branch (364:5): [True: 0, False: 0]
  ------------------
  365|      0|      field = zfp_field_4d((void *) output, type, blockshape[3], blockshape[2], blockshape[1], blockshape[0]);
  366|      0|      break;
  367|      0|    default:
  ------------------
  |  Branch (367:5): [True: 0, False: 0]
  ------------------
  368|      0|      free(shape);
  369|      0|      free(chunkshape);
  370|      0|      free(blockshape);
  371|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|      0|      return BLOSC2_ERROR_FAILURE;
  373|      0|  }
  374|       |
  375|      0|  size_t blocks = zfp_field_blocks(field);
  376|      0|  size_t min_bytes = (blocks + CHAR_BIT - 1) / CHAR_BIT;
  377|      0|  if (min_bytes < sizeof(uint64_t)) {
  ------------------
  |  Branch (377:7): [True: 0, False: 0]
  ------------------
  378|      0|    min_bytes = sizeof(uint64_t);
  379|      0|  }
  380|      0|  if (input_len < (int32_t) min_bytes) {
  ------------------
  |  Branch (380:7): [True: 0, False: 0]
  ------------------
  381|      0|    BLOSC_TRACE_ERROR("ZFP acc: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|      0|                      "bitstream size (%zu bytes)", input_len, min_bytes);
  383|      0|    zfp_field_free(field);
  384|      0|    zfp_stream_close(zfp);
  385|      0|    free(shape);
  386|      0|    free(chunkshape);
  387|      0|    free(blockshape);
  388|      0|    return BLOSC2_ERROR_FAILURE;
  389|      0|  }
  390|       |
  391|      0|  if (zfp_open_padded_stream(input, input_len, zfp, field, &stream, &padded_input) != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (391:7): [True: 0, False: 0]
  ------------------
  392|      0|    zfp_field_free(field);
  393|      0|    zfp_stream_close(zfp);
  394|      0|    free(shape);
  395|      0|    free(chunkshape);
  396|      0|    free(blockshape);
  397|      0|    return BLOSC2_ERROR_FAILURE;
  398|      0|  }
  399|       |
  400|      0|  zfpsize = zfp_decompress(zfp, field);
  401|       |
  402|       |  /* clean up */
  403|      0|  zfp_field_free(field);
  404|      0|  zfp_stream_close(zfp);
  405|      0|  zfp_close_padded_stream(stream, padded_input);
  406|      0|  free(shape);
  407|      0|  free(chunkshape);
  408|      0|  free(blockshape);
  409|       |
  410|      0|  if (zfpsize == 0) {
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|      0|    return (int) zfpsize;
  413|      0|  }
  414|       |
  415|      0|  return (int) output_len;
  416|      0|}
zfp_prec_decompress:
  593|      1|                        int32_t output_len, uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
  594|      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]
  |  |  ------------------
  ------------------
  595|      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]
  |  |  ------------------
  ------------------
  596|      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]
  |  |  ------------------
  ------------------
  597|      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]
  |  |  ------------------
  ------------------
  598|      0|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|      0|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  599|       |
  600|      0|  blosc2_schunk *sc = dparams->schunk;
  601|      0|  int32_t typesize = sc->typesize;
  602|      0|  int8_t ndim;
  603|      0|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  604|      0|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  605|      0|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  606|      0|  uint8_t *smeta;
  607|      0|  int32_t smeta_len;
  608|      0|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (608:7): [True: 0, False: 0]
  ------------------
  609|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|      0|    free(shape);
  611|      0|    free(chunkshape);
  612|      0|    free(blockshape);
  613|      0|    return BLOSC2_ERROR_FAILURE;
  614|      0|  }
  615|      0|  int deserialize_rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL);
  616|      0|  free(smeta);
  617|       |
  618|      0|  if (zfp_check_output_size(deserialize_rc, ndim, blockshape, typesize, output_len) < 0) {
  ------------------
  |  Branch (618:7): [True: 0, False: 0]
  ------------------
  619|      0|    free(shape);
  620|      0|    free(chunkshape);
  621|      0|    free(blockshape);
  622|      0|    return BLOSC2_ERROR_FAILURE;
  623|      0|  }
  624|       |
  625|      0|  zfp_type type;     /* array scalar type */
  626|      0|  zfp_field *field;  /* array meta data */
  627|      0|  zfp_stream *zfp;   /* compressed stream */
  628|      0|  bitstream *stream = NULL; /* bit stream to write to or read from */
  629|      0|  uint8_t *padded_input = NULL;
  630|      0|  size_t zfpsize;    /* byte size of compressed stream */
  631|       |
  632|      0|  uint prec;
  633|      0|  switch (ndim) {
  634|      0|    case 1:
  ------------------
  |  Branch (634:5): [True: 0, False: 0]
  ------------------
  635|      0|      prec = meta + 5;
  636|      0|      break;
  637|      0|    case 2:
  ------------------
  |  Branch (637:5): [True: 0, False: 0]
  ------------------
  638|      0|      prec = meta + 7;
  639|      0|      break;
  640|      0|    case 3:
  ------------------
  |  Branch (640:5): [True: 0, False: 0]
  ------------------
  641|      0|      prec = meta + 9;
  642|      0|      break;
  643|      0|    case 4:
  ------------------
  |  Branch (643:5): [True: 0, False: 0]
  ------------------
  644|      0|      prec = meta + 11;
  645|      0|      break;
  646|      0|    default:
  ------------------
  |  Branch (646:5): [True: 0, False: 0]
  ------------------
  647|      0|      free(shape);
  648|      0|      free(chunkshape);
  649|      0|      free(blockshape);
  650|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|      0|      return BLOSC2_ERROR_FAILURE;
  652|      0|  }
  653|       |
  654|      0|  if (prec > ZFP_MAX_PREC) {
  ------------------
  |  |   20|      0|#define ZFP_MAX_PREC    64 /* maximum precision supported */
  ------------------
  |  Branch (654:7): [True: 0, False: 0]
  ------------------
  655|      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__); \
  |  |  |  |  ------------------
  |  |  |  |  |  |  655|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|      0|    prec = ZFP_MAX_PREC;
  ------------------
  |  |   20|      0|#define ZFP_MAX_PREC    64 /* maximum precision supported */
  ------------------
  657|      0|  }
  658|       |
  659|      0|  switch (typesize) {
  660|      0|    case sizeof(float):
  ------------------
  |  Branch (660:5): [True: 0, False: 0]
  ------------------
  661|      0|      type = zfp_type_float;
  662|      0|      break;
  663|      0|    case sizeof(double):
  ------------------
  |  Branch (663:5): [True: 0, False: 0]
  ------------------
  664|      0|      type = zfp_type_double;
  665|      0|      break;
  666|      0|    default:
  ------------------
  |  Branch (666:5): [True: 0, False: 0]
  ------------------
  667|      0|      free(shape);
  668|      0|      free(chunkshape);
  669|      0|      free(blockshape);
  670|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|      0|      return BLOSC2_ERROR_FAILURE;
  672|      0|  }
  673|       |
  674|      0|  zfp = zfp_stream_open(NULL);
  675|      0|  zfp_stream_set_precision(zfp, prec);
  676|       |
  677|      0|  switch (ndim) {
  678|      0|    case 1:
  ------------------
  |  Branch (678:5): [True: 0, False: 0]
  ------------------
  679|      0|      field = zfp_field_1d((void *) output, type, blockshape[0]);
  680|      0|      break;
  681|      0|    case 2:
  ------------------
  |  Branch (681:5): [True: 0, False: 0]
  ------------------
  682|      0|      field = zfp_field_2d((void *) output, type, blockshape[1], blockshape[0]);
  683|      0|      break;
  684|      0|    case 3:
  ------------------
  |  Branch (684:5): [True: 0, False: 0]
  ------------------
  685|      0|      field = zfp_field_3d((void *) output, type, blockshape[2], blockshape[1], blockshape[0]);
  686|      0|      break;
  687|      0|    case 4:
  ------------------
  |  Branch (687:5): [True: 0, False: 0]
  ------------------
  688|      0|      field = zfp_field_4d((void *) output, type, blockshape[3], blockshape[2], blockshape[1], blockshape[0]);
  689|      0|      break;
  690|      0|    default:
  ------------------
  |  Branch (690:5): [True: 0, False: 0]
  ------------------
  691|      0|      free(shape);
  692|      0|      free(chunkshape);
  693|      0|      free(blockshape);
  694|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|      0|      return BLOSC2_ERROR_FAILURE;
  696|      0|  }
  697|       |
  698|      0|  size_t blocks = zfp_field_blocks(field);
  699|      0|  size_t min_bytes = (blocks + CHAR_BIT - 1) / CHAR_BIT;
  700|      0|  if (min_bytes < sizeof(uint64_t)) {
  ------------------
  |  Branch (700:7): [True: 0, False: 0]
  ------------------
  701|      0|    min_bytes = sizeof(uint64_t);
  702|      0|  }
  703|      0|  if (input_len < (int32_t) min_bytes) {
  ------------------
  |  Branch (703:7): [True: 0, False: 0]
  ------------------
  704|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|      0|                      "bitstream size (%zu bytes)", input_len, min_bytes);
  706|      0|    zfp_field_free(field);
  707|      0|    zfp_stream_close(zfp);
  708|      0|    free(shape);
  709|      0|    free(chunkshape);
  710|      0|    free(blockshape);
  711|      0|    return BLOSC2_ERROR_FAILURE;
  712|      0|  }
  713|       |
  714|      0|  if (zfp_open_padded_stream(input, input_len, zfp, field, &stream, &padded_input) != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (714:7): [True: 0, False: 0]
  ------------------
  715|      0|    zfp_field_free(field);
  716|      0|    zfp_stream_close(zfp);
  717|      0|    free(shape);
  718|      0|    free(chunkshape);
  719|      0|    free(blockshape);
  720|      0|    return BLOSC2_ERROR_FAILURE;
  721|      0|  }
  722|       |
  723|      0|  zfpsize = zfp_decompress(zfp, field);
  724|       |
  725|       |  /* clean up */
  726|      0|  zfp_field_free(field);
  727|      0|  zfp_stream_close(zfp);
  728|      0|  zfp_close_padded_stream(stream, padded_input);
  729|      0|  free(shape);
  730|      0|  free(chunkshape);
  731|      0|  free(blockshape);
  732|       |
  733|      0|  if (zfpsize == 0) {
  ------------------
  |  Branch (733:7): [True: 0, False: 0]
  ------------------
  734|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|      0|    return (int) zfpsize;
  736|      0|  }
  737|       |
  738|      0|  return (int) output_len;
  739|      0|}
zfp_rate_decompress:
  903|      1|                        int32_t output_len, uint8_t meta, blosc2_dparams *dparams, const void *chunk) {
  904|      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]
  |  |  ------------------
  ------------------
  905|      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]
  |  |  ------------------
  ------------------
  906|      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]
  |  |  ------------------
  ------------------
  907|      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]
  |  |  ------------------
  ------------------
  908|      0|  BLOSC_UNUSED_PARAM(chunk);
  ------------------
  |  |   28|      0|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  909|       |
  910|      0|  blosc2_schunk *sc = dparams->schunk;
  911|      0|  int32_t typesize = sc->typesize;
  912|       |
  913|      0|  double ratio = (double) meta / 100.0;
  914|      0|  int8_t ndim;
  915|      0|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  916|      0|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  917|      0|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      0|#define B2ND_MAX_DIM 16
  ------------------
  918|      0|  uint8_t *smeta;
  919|      0|  int32_t smeta_len;
  920|      0|  if (blosc2_meta_get(sc, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (920:7): [True: 0, False: 0]
  ------------------
  921|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  922|      0|    free(shape);
  923|      0|    free(chunkshape);
  924|      0|    free(blockshape);
  925|      0|    return BLOSC2_ERROR_FAILURE;
  926|      0|  }
  927|      0|  int deserialize_rc = b2nd_deserialize_meta(smeta, smeta_len, &ndim, shape, chunkshape, blockshape, NULL, NULL);
  928|      0|  free(smeta);
  929|       |
  930|      0|  if (zfp_check_output_size(deserialize_rc, ndim, blockshape, typesize, output_len) < 0) {
  ------------------
  |  Branch (930:7): [True: 0, False: 0]
  ------------------
  931|      0|    free(shape);
  932|      0|    free(chunkshape);
  933|      0|    free(blockshape);
  934|      0|    return BLOSC2_ERROR_FAILURE;
  935|      0|  }
  936|       |
  937|      0|  zfp_type type;     /* array scalar type */
  938|      0|  zfp_field *field;  /* array meta data */
  939|      0|  zfp_stream *zfp;   /* compressed stream */
  940|      0|  bitstream *stream = NULL; /* bit stream to write to or read from */
  941|      0|  uint8_t *padded_input = NULL;
  942|      0|  size_t zfpsize;    /* byte size of compressed stream */
  943|       |
  944|      0|  switch (typesize) {
  945|      0|    case sizeof(float):
  ------------------
  |  Branch (945:5): [True: 0, False: 0]
  ------------------
  946|      0|      type = zfp_type_float;
  947|      0|      break;
  948|      0|    case sizeof(double):
  ------------------
  |  Branch (948:5): [True: 0, False: 0]
  ------------------
  949|      0|      type = zfp_type_double;
  950|      0|      break;
  951|      0|    default:
  ------------------
  |  Branch (951:5): [True: 0, False: 0]
  ------------------
  952|      0|      free(shape);
  953|      0|      free(chunkshape);
  954|      0|      free(blockshape);
  955|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|      0|      return BLOSC2_ERROR_FAILURE;
  957|      0|  }
  958|      0|  double rate =
  959|      0|      ratio * (double) typesize * 8;     // convert from output size / input size to output bits per input value
  960|      0|  zfp = zfp_stream_open(NULL);
  961|      0|  zfp_stream_set_rate(zfp, rate, type, ndim, zfp_false);
  962|       |
  963|      0|  switch (ndim) {
  964|      0|    case 1:
  ------------------
  |  Branch (964:5): [True: 0, False: 0]
  ------------------
  965|      0|      field = zfp_field_1d((void *) output, type, blockshape[0]);
  966|      0|      break;
  967|      0|    case 2:
  ------------------
  |  Branch (967:5): [True: 0, False: 0]
  ------------------
  968|      0|      field = zfp_field_2d((void *) output, type, blockshape[1], blockshape[0]);
  969|      0|      break;
  970|      0|    case 3:
  ------------------
  |  Branch (970:5): [True: 0, False: 0]
  ------------------
  971|      0|      field = zfp_field_3d((void *) output, type, blockshape[2], blockshape[1], blockshape[0]);
  972|      0|      break;
  973|      0|    case 4:
  ------------------
  |  Branch (973:5): [True: 0, False: 0]
  ------------------
  974|      0|      field = zfp_field_4d((void *) output, type, blockshape[3], blockshape[2], blockshape[1], blockshape[0]);
  975|      0|      break;
  976|      0|    default:
  ------------------
  |  Branch (976:5): [True: 0, False: 0]
  ------------------
  977|      0|      free(shape);
  978|      0|      free(chunkshape);
  979|      0|      free(blockshape);
  980|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|      0|      return BLOSC2_ERROR_FAILURE;
  982|      0|  }
  983|       |
  984|      0|  size_t blocks = zfp_field_blocks(field);
  985|      0|  uint n = 1u << (2 * ndim);
  986|      0|  uint bits = (uint) floor(n * rate + 0.5);
  987|      0|  switch (type) {
  988|      0|    case zfp_type_float:
  ------------------
  |  Branch (988:5): [True: 0, False: 0]
  ------------------
  989|      0|      if (bits < 1 + 8u) {
  ------------------
  |  Branch (989:11): [True: 0, False: 0]
  ------------------
  990|      0|        bits = 1 + 8u;
  991|      0|      }
  992|      0|      break;
  993|      0|    case zfp_type_double:
  ------------------
  |  Branch (993:5): [True: 0, False: 0]
  ------------------
  994|      0|      if (bits < 1 + 11u) {
  ------------------
  |  Branch (994:11): [True: 0, False: 0]
  ------------------
  995|      0|        bits = 1 + 11u;
  996|      0|      }
  997|      0|      break;
  998|      0|    default:
  ------------------
  |  Branch (998:5): [True: 0, False: 0]
  ------------------
  999|      0|      break;
 1000|      0|  }
 1001|      0|  if (bits > 0 && blocks > SIZE_MAX / bits) {
  ------------------
  |  Branch (1001:7): [True: 0, False: 0]
  |  Branch (1001:19): [True: 0, False: 0]
  ------------------
 1002|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|      0|    zfp_field_free(field);
 1004|      0|    zfp_stream_close(zfp);
 1005|      0|    free(shape);
 1006|      0|    free(chunkshape);
 1007|      0|    free(blockshape);
 1008|      0|    return BLOSC2_ERROR_FAILURE;
 1009|      0|  }
 1010|      0|  size_t required_bits = blocks * (size_t) bits;
 1011|      0|  size_t required_bytes = (required_bits + CHAR_BIT - 1) / CHAR_BIT;
 1012|      0|  if (required_bytes < sizeof(uint64_t)) {
  ------------------
  |  Branch (1012:7): [True: 0, False: 0]
  ------------------
 1013|      0|    required_bytes = sizeof(uint64_t);
 1014|      0|  }
 1015|      0|  if (input_len < (int32_t) required_bytes) {
  ------------------
  |  Branch (1015:7): [True: 0, False: 0]
  ------------------
 1016|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1017|      0|                      "bitstream size (%zu bytes)", input_len, required_bytes);
 1018|      0|    zfp_field_free(field);
 1019|      0|    zfp_stream_close(zfp);
 1020|      0|    free(shape);
 1021|      0|    free(chunkshape);
 1022|      0|    free(blockshape);
 1023|      0|    return BLOSC2_ERROR_FAILURE;
 1024|      0|  }
 1025|       |
 1026|      0|  if (zfp_open_padded_stream(input, input_len, zfp, field, &stream, &padded_input) != BLOSC2_ERROR_SUCCESS) {
  ------------------
  |  Branch (1026:7): [True: 0, False: 0]
  ------------------
 1027|      0|    zfp_field_free(field);
 1028|      0|    zfp_stream_close(zfp);
 1029|      0|    free(shape);
 1030|      0|    free(chunkshape);
 1031|      0|    free(blockshape);
 1032|      0|    return BLOSC2_ERROR_FAILURE;
 1033|      0|  }
 1034|       |
 1035|      0|  zfpsize = zfp_decompress(zfp, field);
 1036|       |
 1037|       |  /* clean up */
 1038|      0|  zfp_field_free(field);
 1039|      0|  zfp_stream_close(zfp);
 1040|      0|  zfp_close_padded_stream(stream, padded_input);
 1041|      0|  free(shape);
 1042|      0|  free(chunkshape);
 1043|      0|  free(blockshape);
 1044|       |
 1045|      0|  if (zfpsize == 0) {
  ------------------
  |  Branch (1045:7): [True: 0, False: 0]
  ------------------
 1046|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1047|      0|    return (int) zfpsize;
 1048|      0|  }
 1049|       |
 1050|      0|  return (int) output_len;
 1051|      0|}

simd_load:
   34|   808k|bytes16 simd_load(const void* ptr) { return _mm_loadu_si128((const __m128i*)ptr); }
simd_store:
   35|   808k|void simd_store(void* ptr, bytes16 x) { _mm_storeu_si128((__m128i*)ptr, x); }
simd_add:
   38|   808k|bytes16 simd_add(bytes16 a, bytes16 b) { return _mm_add_epi8(a, b); }
simd_duplane15:
   40|   808k|bytes16 simd_duplane15(bytes16 x) { return _mm_shuffle_epi8(x, _mm_set1_epi8(15)); }
simd_prefix_sum:
   43|   808k|{
   44|       |  // Sklansky-style sum from https://gist.github.com/rygorous/4212be0cd009584e4184e641ca210528
   45|   808k|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 8));
   46|   808k|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 16));
   47|   808k|  x = _mm_add_epi8(x, _mm_slli_epi64(x, 32));
   48|   808k|  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|   808k|  return x;
   50|   808k|}
simd_get_last:
   52|  2.41k|uint8_t simd_get_last(bytes16 x) { return (_mm_extract_epi16(x, 7) >> 8) & 0xFF; }
bytedelta_backward:
  332|    122|                       blosc2_dparams *dparams, uint8_t id) {
  333|    122|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|    122|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  334|       |
  335|    122|  int typesize = meta;
  336|    122|  if (typesize == 0) {
  ------------------
  |  Branch (336:7): [True: 2, False: 120]
  ------------------
  337|      2|    if (dparams->schunk == NULL) {
  ------------------
  |  Branch (337:9): [True: 2, False: 0]
  ------------------
  338|      2|      BLOSC_TRACE_ERROR("When meta is 0, you need to be on a schunk!");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  339|      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]
  |  |  ------------------
  ------------------
  340|      2|    }
  341|      0|    blosc2_schunk* schunk = (blosc2_schunk*)(dparams->schunk);
  342|      0|    typesize = schunk->typesize;
  343|      0|  }
  344|       |
  345|    120|  const int stream_len = length / typesize;
  346|  12.0k|  for (int ich = 0; ich < typesize; ++ich) {
  ------------------
  |  Branch (346:21): [True: 11.9k, False: 120]
  ------------------
  347|  11.9k|    int ip = 0;
  348|  11.9k|    uint8_t _v2 = 0;
  349|       |    // SIMD fetch 16 bytes from each channel, prefix-sum un-delta
  350|  11.9k|#if defined(CPU_HAS_SIMD)
  351|  11.9k|    bytes16 v2 = {0};
  352|   544k|    for (; ip < stream_len - 15; ip += 16) {
  ------------------
  |  Branch (352:12): [True: 532k, False: 11.9k]
  ------------------
  353|   532k|      bytes16 v = simd_load(input);
  354|   532k|      input += 16;
  355|       |      // un-delta via prefix sum
  356|   532k|      v2 = simd_add(simd_prefix_sum(v), simd_duplane15(v2));
  357|   532k|      simd_store(output, v2);
  358|   532k|      output += 16;
  359|   532k|    }
  360|  11.9k|    if (stream_len > 15) {
  ------------------
  |  Branch (360:9): [True: 2.41k, False: 9.56k]
  ------------------
  361|  2.41k|      _v2 = simd_get_last(v2);
  362|  2.41k|    }
  363|  11.9k|#endif // #if defined(CPU_HAS_SIMD)
  364|       |    // scalar leftover
  365|  36.3k|    for (; ip < stream_len; ip++) {
  ------------------
  |  Branch (365:12): [True: 24.3k, False: 11.9k]
  ------------------
  366|  24.3k|      uint8_t v = *input + _v2;
  367|  24.3k|      input++;
  368|  24.3k|      *output = v;
  369|  24.3k|      output++;
  370|  24.3k|      _v2 = v;
  371|  24.3k|    }
  372|  11.9k|  }
  373|       |
  374|       |  // Mirror of the forward pass: restore the trailing bytes verbatim.
  375|    120|  memcpy(output, input, (size_t)(length - stream_len * typesize));
  376|       |
  377|    120|  return BLOSC2_ERROR_SUCCESS;
  378|    122|}
bytedelta_backward_buggy:
  428|    195|                             uint8_t meta, blosc2_dparams *dparams, uint8_t id) {
  429|    195|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|    195|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  430|       |
  431|    195|  int typesize = meta;
  432|    195|  if (typesize == 0) {
  ------------------
  |  Branch (432:7): [True: 4, False: 191]
  ------------------
  433|      4|    if (dparams->schunk == NULL) {
  ------------------
  |  Branch (433:9): [True: 4, False: 0]
  ------------------
  434|      4|      BLOSC_TRACE_ERROR("When meta is 0, you need to be on a schunk!");
  ------------------
  |  |   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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  435|      4|      BLOSC_ERROR(BLOSC2_ERROR_FAILURE);
  ------------------
  |  |  111|      4|    do {                                            \
  |  |  112|      4|        int rc_ = (rc);                             \
  |  |  113|      4|        if (rc_ < BLOSC2_ERROR_SUCCESS) {           \
  |  |  ------------------
  |  |  |  Branch (113:13): [True: 4, False: 0]
  |  |  ------------------
  |  |  114|      4|            char *error_msg = print_error(rc_);     \
  |  |  115|      4|            BLOSC_TRACE_ERROR("%s", error_msg);     \
  |  |  ------------------
  |  |  |  |   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]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  116|      4|            return rc_;                             \
  |  |  117|      4|        }                                           \
  |  |  118|      4|    } while (0)
  |  |  ------------------
  |  |  |  Branch (118:14): [Folded, False: 0]
  |  |  ------------------
  ------------------
  436|      4|    }
  437|      0|    blosc2_schunk* schunk = (blosc2_schunk*)(dparams->schunk);
  438|      0|    typesize = schunk->typesize;
  439|      0|  }
  440|       |
  441|    191|  const int stream_len = length / typesize;
  442|  14.5k|  for (int ich = 0; ich < typesize; ++ich) {
  ------------------
  |  Branch (442:21): [True: 14.3k, False: 191]
  ------------------
  443|  14.3k|    int ip = 0;
  444|       |    // SIMD fetch 16 bytes from each channel, prefix-sum un-delta
  445|  14.3k|#if defined(CPU_HAS_SIMD)
  446|  14.3k|    bytes16 v2 = {0};
  447|   290k|    for (; ip < stream_len - 15; ip += 16) {
  ------------------
  |  Branch (447:12): [True: 275k, False: 14.3k]
  ------------------
  448|   275k|      bytes16 v = simd_load(input);
  449|   275k|      input += 16;
  450|       |      // un-delta via prefix sum
  451|   275k|      v2 = simd_add(simd_prefix_sum(v), simd_duplane15(v2));
  452|   275k|      simd_store(output, v2);
  453|   275k|      output += 16;
  454|   275k|    }
  455|  14.3k|#endif // #if defined(CPU_HAS_SIMD)
  456|       |    // scalar leftover
  457|  14.3k|    uint8_t _v2 = 0;
  458|  40.0k|    for (; ip < stream_len; ip++) {
  ------------------
  |  Branch (458:12): [True: 25.6k, False: 14.3k]
  ------------------
  459|  25.6k|      uint8_t v = *input + _v2;
  460|  25.6k|      input++;
  461|  25.6k|      *output = v;
  462|  25.6k|      output++;
  463|  25.6k|      _v2 = v;
  464|  25.6k|    }
  465|  14.3k|  }
  466|       |
  467|    191|  return BLOSC2_ERROR_SUCCESS;
  468|    195|}

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

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

ndcell_backward:
  205|      9|                   uint8_t id) {
  206|      9|  BLOSC_UNUSED_PARAM(id);
  ------------------
  |  |   28|      9|#define BLOSC_UNUSED_PARAM(x) ((void)(x))
  ------------------
  207|      9|  blosc2_schunk *schunk = dparams->schunk;
  208|      9|  int8_t ndim;
  209|      9|  int64_t *shape = malloc(B2ND_MAX_DIM * sizeof(int64_t));
  ------------------
  |  |   50|      9|#define B2ND_MAX_DIM 16
  ------------------
  210|      9|  int32_t *chunkshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      9|#define B2ND_MAX_DIM 16
  ------------------
  211|      9|  int32_t *blockshape = malloc(B2ND_MAX_DIM * sizeof(int32_t));
  ------------------
  |  |   50|      9|#define B2ND_MAX_DIM 16
  ------------------
  212|      9|  uint8_t *smeta;
  213|      9|  int32_t smeta_len;
  214|      9|  if (blosc2_meta_get(schunk, "b2nd", &smeta, &smeta_len) < 0) {
  ------------------
  |  Branch (214:7): [True: 9, False: 0]
  ------------------
  215|      9|    free(shape);
  216|      9|    free(chunkshape);
  217|      9|    free(blockshape);
  218|      9|    BLOSC_TRACE_ERROR("b2nd layer not found!");
  ------------------
  |  |   93|      9|#define BLOSC_TRACE_ERROR(msg, ...) BLOSC_TRACE(error, msg, ##__VA_ARGS__)
  |  |  ------------------
  |  |  |  |   97|      9|    do {                                            \
  |  |  |  |   98|      9|        const char *__e = getenv("BLOSC_TRACE");    \
  |  |  |  |   99|      9|        if (!__e) { break; }                        \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (99:13): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  100|      9|        fprintf(stderr, "[%s] - " msg " (%s:%d)\n", #cat, ##__VA_ARGS__, __FILE__, __LINE__); \
  |  |  |  |  101|      0|    } while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (101:13): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      9|    return BLOSC2_ERROR_FAILURE;
  220|      9|  }
  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|  4.92k|void register_tuners(void) {
   14|       |
   15|  4.92k|  blosc2_tuner btune;
   16|  4.92k|  btune.id = BLOSC_BTUNE;
   17|  4.92k|  btune.name = "btune";
   18|  4.92k|  btune.init = NULL;
   19|  4.92k|  btune.next_cparams = NULL;
   20|  4.92k|  btune.next_blocksize = NULL;
   21|  4.92k|  btune.update = NULL;
   22|  4.92k|  btune.free = NULL;
   23|       |
   24|  4.92k|  register_tuner_private(&btune);
   25|  4.92k|}

LLVMFuzzerTestOneInput:
   50|  4.92k|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   51|  4.92k|  tail_reader r = {data, size};
   52|       |
   53|  4.92k|  if (size < 16) {
  ------------------
  |  Branch (53:7): [True: 6, False: 4.92k]
  ------------------
   54|      6|    return 0;
   55|      6|  }
   56|       |
   57|  4.92k|  uint8_t mode = (uint8_t)(tail_u8(&r) % 5);
   58|  4.92k|  int8_t ndim = (int8_t)(tail_u8(&r) % FUZZ_MAX_DIM + 1);
  ------------------
  |  |   29|  4.92k|#define FUZZ_MAX_DIM 16        /* B2ND_MAX_DIM */
  ------------------
   59|  4.92k|  uint8_t typesize = (uint8_t)(tail_u8(&r) % 8 + 1);
   60|       |
   61|  4.92k|  int64_t shape[FUZZ_MAX_DIM] = {0};
   62|  4.92k|  int32_t chunkshape[FUZZ_MAX_DIM] = {0};
   63|  4.92k|  int32_t blockshape[FUZZ_MAX_DIM] = {0};
   64|  4.92k|  int64_t start[FUZZ_MAX_DIM] = {0};
   65|  4.92k|  int64_t stop[FUZZ_MAX_DIM] = {0};
   66|  4.92k|  int64_t diff[FUZZ_MAX_DIM] = {0};
   67|  4.92k|  int64_t shape_items = 1;
   68|  4.92k|  int64_t chunk_items = 1;
   69|  4.92k|  int64_t nchunks_est = 1;
   70|  4.92k|  int64_t req = 1;
   71|  4.92k|  int8_t d;
   72|       |
   73|  25.4k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (73:15): [True: 20.5k, False: 4.92k]
  ------------------
   74|  20.5k|    int64_t ext = tail_dim(&r);
   75|  20.5k|    if (ext > 0 && shape_items * ext > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  17.4k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (75:9): [True: 17.4k, False: 3.12k]
  |  Branch (75:20): [True: 3.86k, False: 13.5k]
  ------------------
   76|  3.86k|      ext = 1;
   77|  3.86k|    }
   78|  20.5k|    shape[d] = ext;
   79|  20.5k|    if (ext > 0) {
  ------------------
  |  Branch (79:9): [True: 17.4k, False: 3.12k]
  ------------------
   80|  17.4k|      shape_items *= ext;
   81|  17.4k|    }
   82|       |
   83|  20.5k|    int32_t c_ext = (int32_t)(tail_u8(&r) % FUZZ_MAX_EXTENT + 1);
  ------------------
  |  |   30|  20.5k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
   84|  20.5k|    if (chunk_items * c_ext > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  20.5k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (84:9): [True: 6.38k, False: 14.1k]
  ------------------
   85|  6.38k|      c_ext = 1;
   86|  6.38k|    }
   87|  20.5k|    int64_t dim_chunks = ext > 0 ? (ext + c_ext - 1) / c_ext : 1;
  ------------------
  |  Branch (87:26): [True: 17.4k, False: 3.12k]
  ------------------
   88|  20.5k|    if (nchunks_est * dim_chunks > 64 && ext > 0) {
  ------------------
  |  Branch (88:9): [True: 1.42k, False: 19.1k]
  |  Branch (88:42): [True: 1.42k, False: 0]
  ------------------
   89|  1.42k|      c_ext = (int32_t)ext;
   90|  1.42k|      dim_chunks = 1;
   91|  1.42k|    }
   92|  20.5k|    chunkshape[d] = c_ext;
   93|  20.5k|    chunk_items *= c_ext;
   94|  20.5k|    nchunks_est *= dim_chunks;
   95|       |
   96|  20.5k|    blockshape[d] = (int32_t)(tail_u8(&r) % c_ext + 1);
   97|  20.5k|  }
   98|  25.4k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (98:15): [True: 20.5k, False: 4.92k]
  ------------------
   99|  20.5k|    start[d] = tail_dim(&r);
  100|  20.5k|    stop[d] = tail_dim(&r);
  101|  20.5k|    diff[d] = stop[d] - start[d];
  102|  20.5k|    if (diff[d] < 0) {
  ------------------
  |  Branch (102:9): [True: 2.69k, False: 17.8k]
  ------------------
  103|  2.69k|      diff[d] = 0;
  104|  2.69k|      stop[d] = start[d];
  105|  2.69k|    }
  106|  20.5k|    if (diff[d] > 0 && req * diff[d] > FUZZ_MAX_ITEMS) {
  ------------------
  |  |   31|  5.80k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (106:9): [True: 5.80k, False: 14.7k]
  |  Branch (106:24): [True: 927, False: 4.87k]
  ------------------
  107|    927|      diff[d] = 1;
  108|    927|      stop[d] = start[d] + 1;
  109|    927|    }
  110|  20.5k|    if (diff[d] > 0) {
  ------------------
  |  Branch (110:9): [True: 5.80k, False: 14.7k]
  ------------------
  111|  5.80k|      req *= diff[d];
  112|  5.80k|    }
  113|  20.5k|  }
  114|  9.24k|  for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (114:15): [True: 7.85k, False: 1.39k]
  ------------------
  115|  7.85k|    if (diff[d] == 0) {
  ------------------
  |  Branch (115:9): [True: 3.52k, False: 4.32k]
  ------------------
  116|  3.52k|      req = 0;
  117|  3.52k|      break;
  118|  3.52k|    }
  119|  7.85k|  }
  120|       |
  121|       |  /* The head bytes that were not consumed as control bytes are the payload. */
  122|  4.92k|  const uint8_t *payload = data;
  123|  4.92k|  size_t payload_len = r.size;
  124|       |
  125|  4.92k|  blosc2_init();
  126|  4.92k|  blosc2_set_nthreads(1);
  127|       |
  128|  4.92k|  if (mode == 4) {
  ------------------
  |  Branch (128:7): [True: 2.35k, False: 2.56k]
  ------------------
  129|       |    /* Parser mode: the whole input is an untrusted b2nd frame. */
  130|  2.35k|    b2nd_array_t *parsed = NULL;
  131|  2.35k|    if (b2nd_from_cframe((uint8_t *)data, (int64_t)size, false, &parsed) >= 0 &&
  ------------------
  |  Branch (131:9): [True: 0, False: 2.35k]
  ------------------
  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|  2.35k|    blosc2_destroy();
  145|  2.35k|    return 0;
  146|  2.35k|  }
  147|       |
  148|  2.56k|  blosc2_cparams cparams = BLOSC2_CPARAMS_DEFAULTS;
  149|  2.56k|  cparams.typesize = typesize;
  150|  2.56k|  cparams.clevel = tail_u8(&r) % 10;
  151|  2.56k|  cparams.nthreads = 1;
  152|  2.56k|  blosc2_dparams dparams = BLOSC2_DPARAMS_DEFAULTS;
  153|  2.56k|  dparams.nthreads = 1;
  154|  2.56k|  blosc2_storage storage = {.cparams = &cparams, .dparams = &dparams,
  155|  2.56k|                            .contiguous = true};
  156|       |
  157|  2.56k|  b2nd_context_t *ctx = b2nd_create_ctx(&storage, ndim, shape, chunkshape,
  158|  2.56k|                                        blockshape, NULL, 0, NULL, 0);
  159|  2.56k|  if (ctx == NULL) {
  ------------------
  |  Branch (159:7): [True: 0, False: 2.56k]
  ------------------
  160|      0|    blosc2_destroy();
  161|      0|    return 0;
  162|      0|  }
  163|       |
  164|  2.56k|  b2nd_array_t *arr = NULL;
  165|  2.56k|  int rc = BLOSC2_ERROR_DATA;
  166|  2.56k|  switch (mode) {
  167|    255|    case 0:
  ------------------
  |  Branch (167:5): [True: 255, False: 2.31k]
  ------------------
  168|    255|      rc = b2nd_from_cbuffer(ctx, &arr, payload, (int64_t)payload_len);
  169|    255|      break;
  170|    339|    case 1:
  ------------------
  |  Branch (170:5): [True: 339, False: 2.22k]
  ------------------
  171|    339|      rc = b2nd_zeros(ctx, &arr);
  172|    339|      break;
  173|    324|    case 2:
  ------------------
  |  Branch (173:5): [True: 324, False: 2.24k]
  ------------------
  174|    324|      rc = b2nd_empty(ctx, &arr);
  175|    324|      break;
  176|  1.65k|    default: {
  ------------------
  |  Branch (176:5): [True: 1.65k, False: 918]
  ------------------
  177|  1.65k|      uint8_t fill_value[8] = {0};
  178|  1.65k|      if (payload_len > 0) {
  ------------------
  |  Branch (178:11): [True: 1.26k, False: 388]
  ------------------
  179|  1.26k|        memcpy(fill_value, payload,
  180|  1.26k|               payload_len < typesize ? payload_len : typesize);
  ------------------
  |  Branch (180:16): [True: 413, False: 849]
  ------------------
  181|  1.26k|      }
  182|  1.65k|      rc = b2nd_full(ctx, &arr, fill_value);
  183|  1.65k|      break;
  184|      0|    }
  185|  2.56k|  }
  186|  2.56k|  if (rc < 0 || arr == NULL) {
  ------------------
  |  Branch (186:7): [True: 23, False: 2.54k]
  |  Branch (186:17): [True: 0, False: 2.54k]
  ------------------
  187|       |    /* b2nd_empty inside b2nd_from_cbuffer may have assigned *array even on
  188|       |     * error; free it whenever it is set. */
  189|     23|    if (arr != NULL) {
  ------------------
  |  Branch (189:9): [True: 18, False: 5]
  ------------------
  190|     18|      b2nd_free(arr);
  191|     18|    }
  192|     23|    b2nd_free_ctx(ctx);
  193|     23|    blosc2_destroy();
  194|     23|    return 0;
  195|     23|  }
  196|       |
  197|  2.54k|  uint8_t *buf = (uint8_t *)malloc((size_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  2.54k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  198|  2.54k|  if (buf != NULL) {
  ------------------
  |  Branch (198:7): [True: 2.54k, False: 0]
  ------------------
  199|       |    /* Get a slice into a plain buffer. */
  200|  2.54k|    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|  2.54k|    b2nd_array_t *slice = NULL;
  204|  2.54k|    if (b2nd_get_slice(ctx, &slice, arr, start, stop) >= 0 && slice != NULL) {
  ------------------
  |  Branch (204:9): [True: 2.39k, False: 148]
  |  Branch (204:63): [True: 2.39k, False: 0]
  ------------------
  205|  2.39k|      b2nd_to_cbuffer(slice, buf, req * typesize);
  206|  2.39k|      b2nd_free(slice);
  207|  2.39k|    }
  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|  2.54k|    memset(buf, 0, (size_t)req * typesize);
  212|  2.54k|    memcpy(buf, payload,
  213|  2.54k|           payload_len < (size_t)req * typesize ? payload_len
  ------------------
  |  Branch (213:12): [True: 1.31k, False: 1.22k]
  ------------------
  214|  2.54k|                                                : (size_t)req * typesize);
  215|  2.54k|    b2nd_set_slice_cbuffer(buf, diff, (int64_t)req * typesize, start, stop, arr);
  216|       |
  217|       |    /* Read the whole array back. */
  218|  2.54k|    b2nd_to_cbuffer(arr, buf, (int64_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  2.54k|#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|  2.54k|    size_t max_grow = (arr->sc != NULL && arr->sc->chunksize > 0)
  ------------------
  |  Branch (221:24): [True: 2.54k, False: 0]
  |  Branch (221:43): [True: 2.54k, False: 0]
  ------------------
  222|  2.54k|                          ? (size_t)arr->sc->chunksize * 4
  223|  2.54k|                          : 4096;
  224|  2.54k|    if (max_grow > 4096) {
  ------------------
  |  Branch (224:9): [True: 1.59k, False: 953]
  ------------------
  225|  1.59k|      max_grow = 4096;
  226|  1.59k|    }
  227|  2.54k|    size_t grow_len = payload_len < max_grow ? payload_len : max_grow;
  ------------------
  |  Branch (227:23): [True: 2.40k, False: 138]
  ------------------
  228|  2.54k|    if (grow_len > 0) {
  ------------------
  |  Branch (228:9): [True: 1.88k, False: 661]
  ------------------
  229|  1.88k|      b2nd_append(arr, payload, (int64_t)grow_len, 0);
  230|  1.88k|      b2nd_insert(arr, payload, (int64_t)grow_len, 0, 0);
  231|  1.88k|    }
  232|       |
  233|       |    /* Resize up (bounded by both items and chunk count). */
  234|  2.54k|    int64_t new_shape[FUZZ_MAX_DIM];
  235|  2.54k|    int64_t new_total = 1;
  236|  2.54k|    int64_t new_nchunks = 1;
  237|  13.7k|    for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (237:17): [True: 11.2k, False: 2.54k]
  ------------------
  238|  11.2k|      int64_t cand = arr->shape[d] < FUZZ_MAX_EXTENT ? arr->shape[d] + 1 : arr->shape[d];
  ------------------
  |  |   30|  11.2k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
  |  Branch (238:22): [True: 10.6k, False: 520]
  ------------------
  239|  11.2k|      int64_t cand_chunks = (cand > 0 && arr->chunkshape[d] > 0)
  ------------------
  |  Branch (239:30): [True: 11.2k, False: 0]
  |  Branch (239:42): [True: 11.2k, False: 0]
  ------------------
  240|  11.2k|                                ? (cand + arr->chunkshape[d] - 1) / arr->chunkshape[d]
  241|  11.2k|                                : 1;
  242|  11.2k|      if (cand > 0 && (new_total * cand > 2 * FUZZ_MAX_ITEMS || new_nchunks * cand_chunks > 64)) {
  ------------------
  |  |   31|  22.4k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (242:11): [True: 11.2k, False: 0]
  |  Branch (242:24): [True: 1.35k, False: 9.86k]
  |  Branch (242:65): [True: 1.47k, False: 8.38k]
  ------------------
  243|  2.83k|        cand = arr->shape[d];
  244|  2.83k|        cand_chunks = (cand > 0 && arr->chunkshape[d] > 0)
  ------------------
  |  Branch (244:24): [True: 2.70k, False: 124]
  |  Branch (244:36): [True: 2.70k, False: 0]
  ------------------
  245|  2.83k|                          ? (cand + arr->chunkshape[d] - 1) / arr->chunkshape[d]
  246|  2.83k|                          : 1;
  247|  2.83k|      }
  248|  11.2k|      new_shape[d] = cand;
  249|  11.2k|      if (cand > 0) {
  ------------------
  |  Branch (249:11): [True: 11.0k, False: 124]
  ------------------
  250|  11.0k|        new_total *= cand;
  251|  11.0k|      }
  252|  11.2k|      new_nchunks *= cand_chunks;
  253|  11.2k|    }
  254|  2.54k|    if (new_total <= 2 * FUZZ_MAX_ITEMS && new_nchunks <= 64) {
  ------------------
  |  |   31|  5.09k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  |  Branch (254:9): [True: 2.23k, False: 310]
  |  Branch (254:44): [True: 2.00k, False: 233]
  ------------------
  255|  2.00k|      b2nd_resize(arr, new_shape, start);
  256|  2.00k|    }
  257|       |
  258|       |    /* Structural views. */
  259|  2.54k|    b2nd_array_t *view = NULL;
  260|  2.54k|    if (b2nd_squeeze(arr, &view) >= 0 && view != NULL) {
  ------------------
  |  Branch (260:9): [True: 2.54k, False: 0]
  |  Branch (260:42): [True: 2.54k, False: 0]
  ------------------
  261|  2.54k|      b2nd_free(view);
  262|  2.54k|    }
  263|  2.54k|    bool squeeze_index[FUZZ_MAX_DIM];
  264|  13.7k|    for (d = 0; d < ndim; d++) {
  ------------------
  |  Branch (264:17): [True: 11.2k, False: 2.54k]
  ------------------
  265|  11.2k|      squeeze_index[d] = (shape[d] == 1);
  266|  11.2k|    }
  267|  2.54k|    view = NULL;
  268|  2.54k|    if (b2nd_squeeze_index(arr, &view, squeeze_index) >= 0 && view != NULL) {
  ------------------
  |  Branch (268:9): [True: 2.45k, False: 90]
  |  Branch (268:63): [True: 2.45k, False: 0]
  ------------------
  269|  2.45k|      b2nd_free(view);
  270|  2.45k|    }
  271|  2.54k|    if (ndim + 2 <= FUZZ_MAX_DIM) {
  ------------------
  |  |   29|  2.54k|#define FUZZ_MAX_DIM 16        /* B2ND_MAX_DIM */
  ------------------
  |  Branch (271:9): [True: 2.37k, False: 166]
  ------------------
  272|  2.37k|      bool axis[FUZZ_MAX_DIM] = {false};
  273|  2.37k|      axis[0] = true;
  274|  2.37k|      axis[ndim] = true;
  275|  2.37k|      view = NULL;
  276|  2.37k|      if (b2nd_expand_dims(arr, &view, axis, (uint8_t)(ndim + 2)) >= 0 &&
  ------------------
  |  Branch (276:11): [True: 2.37k, False: 0]
  ------------------
  277|  2.37k|          view != NULL) {
  ------------------
  |  Branch (277:11): [True: 2.37k, False: 0]
  ------------------
  278|  2.37k|        b2nd_free(view);
  279|  2.37k|      }
  280|  2.37k|    }
  281|       |
  282|       |    /* Serialize and parse again (round trip through the frame format). */
  283|  2.54k|    uint8_t *cframe = NULL;
  284|  2.54k|    int64_t len = 0;
  285|  2.54k|    bool needs_free = false;
  286|  2.54k|    if (b2nd_to_cframe(arr, &cframe, &len, &needs_free) >= 0 && len > 0 &&
  ------------------
  |  Branch (286:9): [True: 2.54k, False: 0]
  |  Branch (286:65): [True: 2.54k, False: 0]
  ------------------
  287|  2.54k|        cframe != NULL) {
  ------------------
  |  Branch (287:9): [True: 2.54k, False: 0]
  ------------------
  288|  2.54k|      b2nd_array_t *again = NULL;
  289|  2.54k|      if (b2nd_from_cframe(cframe, len, false, &again) >= 0 && again != NULL) {
  ------------------
  |  Branch (289:11): [True: 2.54k, False: 0]
  |  Branch (289:64): [True: 2.54k, False: 0]
  ------------------
  290|  2.54k|        b2nd_to_cbuffer(again, buf, (int64_t)FUZZ_MAX_ITEMS * 8);
  ------------------
  |  |   31|  2.54k|#define FUZZ_MAX_ITEMS 8192    /* cap on elements of any allocated buffer */
  ------------------
  291|  2.54k|        b2nd_free(again);
  292|  2.54k|      }
  293|  2.54k|      if (needs_free) {
  ------------------
  |  Branch (293:11): [True: 0, False: 2.54k]
  ------------------
  294|      0|        free(cframe);
  295|      0|      }
  296|  2.54k|    }
  297|       |
  298|  2.54k|    free(buf);
  299|  2.54k|  }
  300|       |
  301|  2.54k|  b2nd_free(arr);
  302|  2.54k|  b2nd_free_ctx(ctx);
  303|  2.54k|  blosc2_destroy();
  304|  2.54k|  return 0;
  305|  2.56k|}
fuzz_b2nd.c:tail_u8:
   38|   120k|static uint8_t tail_u8(tail_reader *r) {
   39|   120k|  if (r->size == 0) {
  ------------------
  |  Branch (39:7): [True: 13.2k, False: 106k]
  ------------------
   40|  13.2k|    return 0;
   41|  13.2k|  }
   42|   106k|  r->size--;
   43|   106k|  return r->data[r->size];
   44|   120k|}
fuzz_b2nd.c:tail_dim:
   46|  61.6k|static int64_t tail_dim(tail_reader *r) {
   47|  61.6k|  return (int64_t)(tail_u8(r) % (FUZZ_MAX_EXTENT + 1));
  ------------------
  |  |   30|  61.6k|#define FUZZ_MAX_EXTENT 64     /* per-dimension bound */
  ------------------
   48|  61.6k|}

