crc32_fast.c:read32le:
  429|    792|{
  430|    792|	uint32_t num = read32ne(buf);
  431|    792|	return conv32le(num);
  ------------------
  |  |  194|    792|#		define conv32le(num) ((uint32_t)(num))
  ------------------
  432|    792|}
crc32_fast.c:read32ne:
  343|    792|{
  344|       |#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING
  345|       |	return *(const uint32_t *)buf;
  346|       |#else
  347|    792|	uint32_t num;
  348|    792|	memcpy(&num, buf, sizeof(num));
  349|    792|	return num;
  350|    792|#endif
  351|    792|}
crc32_fast.c:read16le:
  413|    644|{
  414|    644|	uint16_t num = read16ne(buf);
  415|    644|	return conv16le(num);
  ------------------
  |  |  191|    644|#		define conv16le(num) ((uint16_t)(num))
  ------------------
  416|    644|}
crc32_fast.c:read16ne:
  330|    644|{
  331|       |#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING
  332|       |	return *(const uint16_t *)buf;
  333|       |#else
  334|    644|	uint16_t num;
  335|    644|	memcpy(&num, buf, sizeof(num));
  336|    644|	return num;
  337|    644|#endif
  338|    644|}
crc32_fast.c:read64le:
  445|  1.01k|{
  446|  1.01k|	uint64_t num = read64ne(buf);
  447|  1.01k|	return conv64le(num);
  ------------------
  |  |  197|  1.01k|#		define conv64le(num) ((uint64_t)(num))
  ------------------
  448|  1.01k|}
crc32_fast.c:read64ne:
  356|  1.01k|{
  357|       |#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING
  358|       |	return *(const uint64_t *)buf;
  359|       |#else
  360|  1.01k|	uint64_t num;
  361|  1.01k|	memcpy(&num, buf, sizeof(num));
  362|  1.01k|	return num;
  363|  1.01k|#endif
  364|  1.01k|}

crc32_fast.c:crc32_set_func:
  153|      2|{
  154|      2|	crc32_func = crc32_resolve();
  155|      2|	return;
  156|      2|}
lzma_crc32:
  178|  9.53k|{
  179|  9.53k|#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)
  180|       |/*
  181|       |#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR
  182|       |	// See crc32_dispatch(). This would be the alternative which uses
  183|       |	// locking and doesn't use crc32_dispatch(). Note that on Windows
  184|       |	// this method needs Vista threads.
  185|       |	mythread_once(crc32_set_func);
  186|       |#endif
  187|       |*/
  188|  9.53k|	return crc32_func(buf, size, crc);
  189|       |
  190|       |#elif defined(CRC32_ARCH_OPTIMIZED)
  191|       |	return crc32_arch_optimized(buf, size, crc);
  192|       |
  193|       |#else
  194|       |	return lzma_crc32_generic(buf, size, crc);
  195|       |#endif
  196|  9.53k|}
crc32_fast.c:crc32_resolve:
  133|      2|{
  134|      2|	return is_arch_extension_supported()
  ------------------
  |  Branch (134:9): [True: 2, False: 0]
  ------------------
  135|      2|			? &crc32_arch_optimized : &lzma_crc32_generic;
  136|      2|}

crc32_fast.c:is_arch_extension_supported:
  340|      2|{
  341|      2|	int success = 1;
  342|      2|	uint32_t r[4]; // eax, ebx, ecx, edx
  343|       |
  344|       |#if defined(_MSC_VER)
  345|       |	// This needs <intrin.h> with MSVC. ICC has it as a built-in
  346|       |	// on all platforms.
  347|       |	__cpuid((int *)r, 1);
  348|       |#elif defined(HAVE_CPUID_H)
  349|       |	// Compared to just using __asm__ to run CPUID, this also checks
  350|       |	// that CPUID is supported and saves and restores ebx as that is
  351|       |	// needed with GCC < 5 with position-independent code (PIC).
  352|      2|	success = __get_cpuid(1, &r[0], &r[1], &r[2], &r[3]);
  353|       |#else
  354|       |	// Just a fallback that shouldn't be needed.
  355|       |	__asm__("cpuid\n\t"
  356|       |			: "=a"(r[0]), "=b"(r[1]), "=c"(r[2]), "=d"(r[3])
  357|       |			: "a"(1), "c"(0));
  358|       |#endif
  359|       |
  360|       |	// Returns true if these are supported:
  361|       |	// CLMUL (bit 1 in ecx)
  362|       |	// SSSE3 (bit 9 in ecx)
  363|       |	// SSE4.1 (bit 19 in ecx)
  364|      2|	const uint32_t ecx_mask = (1 << 1) | (1 << 9) | (1 << 19);
  365|      2|	return success && (r[2] & ecx_mask) == ecx_mask;
  ------------------
  |  Branch (365:9): [True: 2, False: 0]
  |  Branch (365:20): [True: 2, False: 0]
  ------------------
  366|       |
  367|       |	// Alternative methods that weren't used:
  368|       |	//   - ICC's _may_i_use_cpu_feature: the other methods should work too.
  369|       |	//   - GCC >= 6 / Clang / ICX __builtin_cpu_supports("pclmul")
  370|       |	//
  371|       |	// CPUID decoding is needed with MSVC anyway and older GCC. This keeps
  372|       |	// the feature checks in the build system simpler too. The nice thing
  373|       |	// about __builtin_cpu_supports would be that it generates very short
  374|       |	// code as is it only reads a variable set at startup but a few bytes
  375|       |	// doesn't matter here.
  376|      2|}
crc32_fast.c:crc32_arch_optimized:
  154|  9.53k|{
  155|       |	// We will assume that there is at least one byte of input.
  156|  9.53k|	if (size == 0)
  ------------------
  |  Branch (156:6): [True: 14, False: 9.52k]
  ------------------
  157|     14|		return crc;
  158|       |
  159|       |	// See crc_clmul_consts_gen.c.
  160|  9.52k|#if BUILDING_CRC_CLMUL == 32
  161|  9.52k|	const __m128i fold512 = _mm_set_epi64x(0x1d9513d7, 0x8f352d95);
  162|  9.52k|	const __m128i fold128 = _mm_set_epi64x(0xccaa009e, 0xae689191);
  163|  9.52k|	const __m128i mu_p = _mm_set_epi64x(
  164|  9.52k|		(int64_t)0xb4e5b025f7011641, 0x1db710640);
  165|       |#else
  166|       |	const __m128i fold512 = _mm_set_epi64x(
  167|       |		(int64_t)0x081f6054a7842df4, (int64_t)0x6ae3efbb9dd441f3);
  168|       |
  169|       |	const __m128i fold128 = _mm_set_epi64x(
  170|       |		(int64_t)0xdabe95afc7875f40, (int64_t)0xe05dd497ca393ae4);
  171|       |
  172|       |	const __m128i mu_p = _mm_set_epi64x(
  173|       |		(int64_t)0x9c3e466c172963d5, (int64_t)0x92d8af2baf0e1e84);
  174|       |#endif
  175|       |
  176|  9.52k|	__m128i v0, v1, v2, v3;
  177|       |
  178|  9.52k|	crc = ~crc;
  179|       |
  180|  9.52k|	if (size < 8) {
  ------------------
  |  Branch (180:6): [True: 1.89k, False: 7.62k]
  ------------------
  181|  1.89k|		uint64_t x = crc;
  182|  1.89k|		size_t i = 0;
  183|       |
  184|       |		// Checking the bit instead of comparing the size means
  185|       |		// that we don't need to update the size between the steps.
  186|  1.89k|		if (size & 4) {
  ------------------
  |  Branch (186:7): [True: 792, False: 1.10k]
  ------------------
  187|    792|			x ^= read32le(buf);
  188|    792|			buf += 4;
  189|    792|			i = 32;
  190|    792|		}
  191|       |
  192|  1.89k|		if (size & 2) {
  ------------------
  |  Branch (192:7): [True: 644, False: 1.25k]
  ------------------
  193|    644|			x ^= (uint64_t)read16le(buf) << i;
  194|    644|			buf += 2;
  195|    644|			i += 16;
  196|    644|		}
  197|       |
  198|  1.89k|		if (size & 1)
  ------------------
  |  Branch (198:7): [True: 1.30k, False: 593]
  ------------------
  199|  1.30k|			x ^= (uint64_t)*buf << i;
  200|       |
  201|  1.89k|		v0 = my_set_low64((int64_t)x);
  ------------------
  |  |   65|  1.89k|#	define my_set_low64(a) _mm_cvtsi64_si128(a)
  ------------------
  202|  1.89k|		v0 = shift_left(v0, 8 - size);
  203|       |
  204|  7.62k|	} else if (size < 16) {
  ------------------
  |  Branch (204:13): [True: 546, False: 7.08k]
  ------------------
  205|    546|		v0 = my_set_low64((int64_t)(crc ^ read64le(buf)));
  ------------------
  |  |   65|    546|#	define my_set_low64(a) _mm_cvtsi64_si128(a)
  ------------------
  206|       |
  207|       |		// NOTE: buf is intentionally left 8 bytes behind so that
  208|       |		// we can read the last 1-7 bytes with read64le(buf + size).
  209|    546|		size -= 8;
  210|       |
  211|       |		// Handling 8-byte input specially is a speed optimization
  212|       |		// as the clmul can be skipped. A branch is also needed to
  213|       |		// avoid a too high shift amount.
  214|    546|		if (size > 0) {
  ------------------
  |  Branch (214:7): [True: 469, False: 77]
  ------------------
  215|    469|			const size_t padding = 8 - size;
  216|    469|			uint64_t high = read64le(buf + size) >> (padding * 8);
  217|       |
  218|       |#if defined(__i386__) || defined(_M_IX86)
  219|       |			// Simple but likely not the best code for 32-bit x86.
  220|       |			v0 = _mm_insert_epi32(v0, (int32_t)high, 2);
  221|       |			v0 = _mm_insert_epi32(v0, (int32_t)(high >> 32), 3);
  222|       |#else
  223|    469|			v0 = _mm_insert_epi64(v0, (int64_t)high, 1);
  224|    469|#endif
  225|       |
  226|    469|			v0 = shift_left(v0, padding);
  227|       |
  228|    469|			v1 = _mm_srli_si128(v0, 8);
  229|    469|			v0 = _mm_clmulepi64_si128(v0, fold128, 0x10);
  230|    469|			v0 = _mm_xor_si128(v0, v1);
  231|    469|		}
  232|  7.08k|	} else {
  233|  7.08k|		v0 = my_set_low64((int64_t)crc);
  ------------------
  |  |   65|  7.08k|#	define my_set_low64(a) _mm_cvtsi64_si128(a)
  ------------------
  234|       |
  235|       |		// To align or not to align the buf pointer? If the end of
  236|       |		// the buffer isn't aligned, aligning the pointer here would
  237|       |		// make us do an extra folding step with the associated byte
  238|       |		// shuffling overhead. The cost of that would need to be
  239|       |		// lower than the benefit of aligned reads. Testing on an old
  240|       |		// Intel Ivy Bridge processor suggested that aligning isn't
  241|       |		// worth the cost but it likely depends on the processor and
  242|       |		// buffer size. Unaligned loads (MOVDQU) should be fast on
  243|       |		// x86 processors that support PCLMULQDQ, so we don't align
  244|       |		// the buf pointer here.
  245|       |
  246|       |		// Read the first (and possibly the only) full 16 bytes.
  247|  7.08k|		v0 = _mm_xor_si128(v0, my_load128(buf));
  248|  7.08k|		buf += 16;
  249|  7.08k|		size -= 16;
  250|       |
  251|  7.08k|		if (size >= 48) {
  ------------------
  |  Branch (251:7): [True: 6.92k, False: 154]
  ------------------
  252|  6.92k|			v1 = my_load128(buf);
  253|  6.92k|			v2 = my_load128(buf + 16);
  254|  6.92k|			v3 = my_load128(buf + 32);
  255|  6.92k|			buf += 48;
  256|  6.92k|			size -= 48;
  257|       |
  258|   493k|			while (size >= 64) {
  ------------------
  |  Branch (258:11): [True: 487k, False: 6.92k]
  ------------------
  259|   487k|				v0 = fold_xor(v0, fold512, buf);
  260|   487k|				v1 = fold_xor(v1, fold512, buf + 16);
  261|   487k|				v2 = fold_xor(v2, fold512, buf + 32);
  262|   487k|				v3 = fold_xor(v3, fold512, buf + 48);
  263|   487k|				buf += 64;
  264|   487k|				size -= 64;
  265|   487k|			}
  266|       |
  267|  6.92k|			v0 = _mm_xor_si128(v1, fold(v0, fold128));
  268|  6.92k|			v0 = _mm_xor_si128(v2, fold(v0, fold128));
  269|  6.92k|			v0 = _mm_xor_si128(v3, fold(v0, fold128));
  270|  6.92k|		}
  271|       |
  272|  27.3k|		while (size >= 16) {
  ------------------
  |  Branch (272:10): [True: 20.2k, False: 7.08k]
  ------------------
  273|  20.2k|			v0 = fold_xor(v0, fold128, buf);
  274|  20.2k|			buf += 16;
  275|  20.2k|			size -= 16;
  276|  20.2k|		}
  277|       |
  278|  7.08k|		if (size > 0) {
  ------------------
  |  Branch (278:7): [True: 6.89k, False: 186]
  ------------------
  279|       |			// We want the last "size" number of input bytes to
  280|       |			// be at the high bits of v1. First do a full 16-byte
  281|       |			// load and then mask the low bytes to zeros.
  282|  6.89k|			v1 = my_load128(buf + size - 16);
  283|  6.89k|			v1 = keep_high_bytes(v1, size);
  284|       |
  285|       |			// Shift high bytes from v0 to the low bytes of v1.
  286|       |			//
  287|       |			// Alternatively we could replace the combination
  288|       |			// keep_high_bytes + shift_right + _mm_or_si128 with
  289|       |			// _mm_shuffle_epi8 + _mm_blendv_epi8 but that would
  290|       |			// require larger tables for the masks. Now there are
  291|       |			// three loads (instead of two) from the mask tables
  292|       |			// but they all are from the same cache line.
  293|  6.89k|			v1 = _mm_or_si128(v1, shift_right(v0, size));
  294|       |
  295|       |			// Shift high bytes of v0 away, padding the
  296|       |			// low bytes with zeros.
  297|  6.89k|			v0 = shift_left(v0, 16 - size);
  298|       |
  299|  6.89k|			v0 = _mm_xor_si128(v1, fold(v0, fold128));
  300|  6.89k|		}
  301|       |
  302|  7.08k|		v1 = _mm_srli_si128(v0, 8);
  303|  7.08k|		v0 = _mm_clmulepi64_si128(v0, fold128, 0x10);
  304|  7.08k|		v0 = _mm_xor_si128(v0, v1);
  305|  7.08k|	}
  306|       |
  307|       |	// Barrett reduction
  308|       |
  309|  9.52k|#if BUILDING_CRC_CLMUL == 32
  310|  9.52k|	v1 = _mm_clmulepi64_si128(v0, mu_p, 0x10); // v0 * mu
  311|  9.52k|	v1 = _mm_clmulepi64_si128(v1, mu_p, 0x00); // v1 * p
  312|  9.52k|	v0 = _mm_xor_si128(v0, v1);
  313|  9.52k|	return ~(uint32_t)_mm_extract_epi32(v0, 2);
  314|       |#else
  315|       |	// Because p is 65 bits but one bit doesn't fit into the 64-bit
  316|       |	// half of __m128i, finish the second clmul by shifting v1 left
  317|       |	// by 64 bits and xorring it to the final result.
  318|       |	v1 = _mm_clmulepi64_si128(v0, mu_p, 0x10); // v0 * mu
  319|       |	v2 = _mm_slli_si128(v1, 8);
  320|       |	v1 = _mm_clmulepi64_si128(v1, mu_p, 0x00); // v1 * p
  321|       |	v0 = _mm_xor_si128(v0, v2);
  322|       |	v0 = _mm_xor_si128(v0, v1);
  323|       |#if defined(__i386__) || defined(_M_IX86)
  324|       |	return ~(((uint64_t)(uint32_t)_mm_extract_epi32(v0, 3) << 32) |
  325|       |			(uint64_t)(uint32_t)_mm_extract_epi32(v0, 2));
  326|       |#else
  327|       |	return ~(uint64_t)_mm_extract_epi64(v0, 1);
  328|       |#endif
  329|       |#endif
  330|  9.53k|}
crc32_fast.c:shift_left:
  113|  9.26k|{
  114|  9.26k|	return _mm_shuffle_epi8(v, my_load128((vmasks + 32 - amount)));
  115|  9.26k|}
crc32_fast.c:my_load128:
   95|  2.02M|{
   96|  2.02M|	return _mm_loadu_si128((const __m128i *)p);
   97|  2.02M|}
crc32_fast.c:fold_xor:
  140|  1.96M|{
  141|  1.96M|	return _mm_xor_si128(my_load128(buf), fold(v, k));
  142|  1.96M|}
crc32_fast.c:fold:
  130|  1.99M|{
  131|  1.99M|	__m128i a = _mm_clmulepi64_si128(v, k, 0x00);
  132|       |	__m128i b = _mm_clmulepi64_si128(v, k, 0x11);
  133|  1.99M|	return _mm_xor_si128(a, b);
  134|  1.99M|}
crc32_fast.c:keep_high_bytes:
  104|  6.89k|{
  105|  6.89k|	return _mm_and_si128(my_load128((vmasks + count)), v);
  106|  6.89k|}
crc32_fast.c:shift_right:
  122|  6.89k|{
  123|  6.89k|	return _mm_shuffle_epi8(v, my_load128((vmasks + 32 + amount)));
  124|  6.89k|}

lzma_alloc:
   40|  13.6k|{
   41|       |	// Some malloc() variants return NULL if called with size == 0.
   42|  13.6k|	if (size == 0)
  ------------------
  |  Branch (42:6): [True: 0, False: 13.6k]
  ------------------
   43|      0|		size = 1;
   44|       |
   45|  13.6k|	void *ptr;
   46|       |
   47|  13.6k|	if (allocator != NULL && allocator->alloc != NULL)
  ------------------
  |  Branch (47:6): [True: 6.96k, False: 6.72k]
  |  Branch (47:27): [True: 6.96k, False: 0]
  ------------------
   48|  6.96k|		ptr = allocator->alloc(allocator->opaque, 1, size);
   49|  6.72k|	else
   50|  6.72k|		ptr = malloc(size);
   51|       |
   52|  13.6k|	return ptr;
   53|  13.6k|}
lzma_free:
   80|  13.6k|{
   81|  13.6k|	if (allocator != NULL && allocator->free != NULL)
  ------------------
  |  Branch (81:6): [True: 6.74k, False: 6.92k]
  |  Branch (81:27): [True: 0, False: 6.74k]
  ------------------
   82|      0|		allocator->free(allocator->opaque, ptr);
   83|  13.6k|	else
   84|  13.6k|		free(ptr);
   85|       |
   86|  13.6k|	return;
   87|  13.6k|}
lzma_next_end:
  153|  2.54k|{
  154|  2.54k|	if (next->init != (uintptr_t)(NULL)) {
  ------------------
  |  Branch (154:6): [True: 1.27k, False: 1.27k]
  ------------------
  155|       |		// To avoid tiny end functions that simply call
  156|       |		// lzma_free(coder, allocator), we allow leaving next->end
  157|       |		// NULL and call lzma_free() here.
  158|  1.27k|		if (next->end != NULL)
  ------------------
  |  Branch (158:7): [True: 1.27k, False: 3]
  ------------------
  159|  1.27k|			next->end(next->coder, allocator);
  160|      3|		else
  161|      3|			lzma_free(next->coder, allocator);
  162|       |
  163|       |		// Reset the variables so the we don't accidentally think
  164|       |		// that it is an already initialized coder.
  165|  1.27k|		*next = LZMA_NEXT_CODER_INIT;
  ------------------
  |  |  278|  1.27k|	(lzma_next_coder){ \
  |  |  279|  1.27k|		.coder = NULL, \
  |  |  280|  1.27k|		.init = (uintptr_t)(NULL), \
  |  |  281|  1.27k|		.id = LZMA_VLI_UNKNOWN, \
  |  |  ------------------
  |  |  |  |   37|  1.27k|#define LZMA_VLI_UNKNOWN UINT64_MAX
  |  |  ------------------
  |  |  282|  1.27k|		.code = NULL, \
  |  |  283|  1.27k|		.end = NULL, \
  |  |  284|  1.27k|		.get_progress = NULL, \
  |  |  285|  1.27k|		.get_check = NULL, \
  |  |  286|  1.27k|		.memconfig = NULL, \
  |  |  287|  1.27k|		.update = NULL, \
  |  |  288|  1.27k|		.set_out_limit = NULL, \
  |  |  289|  1.27k|	}
  ------------------
  166|  1.27k|	}
  167|       |
  168|  2.54k|	return;
  169|  2.54k|}
lzma_strm_init:
  178|  3.78k|{
  179|  3.78k|	if (strm == NULL)
  ------------------
  |  Branch (179:6): [True: 0, False: 3.78k]
  ------------------
  180|      0|		return LZMA_PROG_ERROR;
  181|       |
  182|  3.78k|	if (strm->internal == NULL) {
  ------------------
  |  Branch (182:6): [True: 1.28k, False: 2.50k]
  ------------------
  183|  1.28k|		strm->internal = lzma_alloc(sizeof(lzma_internal),
  184|  1.28k|				strm->allocator);
  185|  1.28k|		if (strm->internal == NULL)
  ------------------
  |  Branch (185:7): [True: 7, False: 1.27k]
  ------------------
  186|      7|			return LZMA_MEM_ERROR;
  187|       |
  188|  1.27k|		strm->internal->next = LZMA_NEXT_CODER_INIT;
  ------------------
  |  |  278|  1.27k|	(lzma_next_coder){ \
  |  |  279|  1.27k|		.coder = NULL, \
  |  |  280|  1.27k|		.init = (uintptr_t)(NULL), \
  |  |  281|  1.27k|		.id = LZMA_VLI_UNKNOWN, \
  |  |  ------------------
  |  |  |  |   37|  1.27k|#define LZMA_VLI_UNKNOWN UINT64_MAX
  |  |  ------------------
  |  |  282|  1.27k|		.code = NULL, \
  |  |  283|  1.27k|		.end = NULL, \
  |  |  284|  1.27k|		.get_progress = NULL, \
  |  |  285|  1.27k|		.get_check = NULL, \
  |  |  286|  1.27k|		.memconfig = NULL, \
  |  |  287|  1.27k|		.update = NULL, \
  |  |  288|  1.27k|		.set_out_limit = NULL, \
  |  |  289|  1.27k|	}
  ------------------
  189|  1.27k|	}
  190|       |
  191|  3.77k|	memzero(strm->internal->supported_actions,
  ------------------
  |  |  201|  3.77k|#define memzero(s, n) memset(s, 0, n)
  ------------------
  192|  3.77k|			sizeof(strm->internal->supported_actions));
  193|  3.77k|	strm->internal->sequence = ISEQ_RUN;
  194|  3.77k|	strm->internal->allow_buf_error = false;
  195|       |
  196|  3.77k|	strm->total_in = 0;
  197|  3.77k|	strm->total_out = 0;
  198|       |
  199|  3.77k|	return LZMA_OK;
  200|  3.78k|}
lzma_code:
  205|  12.6k|{
  206|       |	// Sanity checks
  207|  12.6k|	if ((strm->next_in == NULL && strm->avail_in != 0)
  ------------------
  |  Branch (207:7): [True: 0, False: 12.6k]
  |  Branch (207:32): [True: 0, False: 0]
  ------------------
  208|  12.6k|			|| (strm->next_out == NULL && strm->avail_out != 0)
  ------------------
  |  Branch (208:8): [True: 0, False: 12.6k]
  |  Branch (208:34): [True: 0, False: 0]
  ------------------
  209|  12.6k|			|| strm->internal == NULL
  ------------------
  |  Branch (209:7): [True: 0, False: 12.6k]
  ------------------
  210|  12.6k|			|| strm->internal->next.code == NULL
  ------------------
  |  Branch (210:7): [True: 0, False: 12.6k]
  ------------------
  211|  12.6k|			|| (unsigned int)(action) > LZMA_ACTION_MAX
  ------------------
  |  |  162|  25.2k|#define LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER))
  ------------------
  |  Branch (211:7): [True: 0, False: 12.6k]
  ------------------
  212|  12.6k|			|| !strm->internal->supported_actions[action])
  ------------------
  |  Branch (212:7): [True: 0, False: 12.6k]
  ------------------
  213|      0|		return LZMA_PROG_ERROR;
  214|       |
  215|       |	// Check if unsupported members have been set to non-zero or non-NULL,
  216|       |	// which would indicate that some new feature is wanted.
  217|  12.6k|	if (strm->reserved_ptr1 != NULL
  ------------------
  |  Branch (217:6): [True: 0, False: 12.6k]
  ------------------
  218|  12.6k|			|| strm->reserved_ptr2 != NULL
  ------------------
  |  Branch (218:7): [True: 0, False: 12.6k]
  ------------------
  219|  12.6k|			|| strm->reserved_ptr3 != NULL
  ------------------
  |  Branch (219:7): [True: 0, False: 12.6k]
  ------------------
  220|  12.6k|			|| strm->reserved_ptr4 != NULL
  ------------------
  |  Branch (220:7): [True: 0, False: 12.6k]
  ------------------
  221|  12.6k|			|| strm->reserved_int2 != 0
  ------------------
  |  Branch (221:7): [True: 0, False: 12.6k]
  ------------------
  222|  12.6k|			|| strm->reserved_int3 != 0
  ------------------
  |  Branch (222:7): [True: 0, False: 12.6k]
  ------------------
  223|  12.6k|			|| strm->reserved_int4 != 0
  ------------------
  |  Branch (223:7): [True: 0, False: 12.6k]
  ------------------
  224|  12.6k|			|| strm->reserved_enum1 != LZMA_RESERVED_ENUM
  ------------------
  |  Branch (224:7): [True: 0, False: 12.6k]
  ------------------
  225|  12.6k|			|| strm->reserved_enum2 != LZMA_RESERVED_ENUM)
  ------------------
  |  Branch (225:7): [True: 0, False: 12.6k]
  ------------------
  226|      0|		return LZMA_OPTIONS_ERROR;
  227|       |
  228|  12.6k|	switch (strm->internal->sequence) {
  229|  12.2k|	case ISEQ_RUN:
  ------------------
  |  Branch (229:2): [True: 12.2k, False: 428]
  ------------------
  230|  12.2k|		switch (action) {
  ------------------
  |  Branch (230:11): [True: 12.2k, False: 0]
  ------------------
  231|  10.7k|		case LZMA_RUN:
  ------------------
  |  Branch (231:3): [True: 10.7k, False: 1.43k]
  ------------------
  232|  10.7k|			break;
  233|       |
  234|      0|		case LZMA_SYNC_FLUSH:
  ------------------
  |  Branch (234:3): [True: 0, False: 12.2k]
  ------------------
  235|      0|			strm->internal->sequence = ISEQ_SYNC_FLUSH;
  236|      0|			break;
  237|       |
  238|      0|		case LZMA_FULL_FLUSH:
  ------------------
  |  Branch (238:3): [True: 0, False: 12.2k]
  ------------------
  239|      0|			strm->internal->sequence = ISEQ_FULL_FLUSH;
  240|      0|			break;
  241|       |
  242|  1.43k|		case LZMA_FINISH:
  ------------------
  |  Branch (242:3): [True: 1.43k, False: 10.7k]
  ------------------
  243|  1.43k|			strm->internal->sequence = ISEQ_FINISH;
  244|  1.43k|			break;
  245|       |
  246|      0|		case LZMA_FULL_BARRIER:
  ------------------
  |  Branch (246:3): [True: 0, False: 12.2k]
  ------------------
  247|      0|			strm->internal->sequence = ISEQ_FULL_BARRIER;
  248|      0|			break;
  249|  12.2k|		}
  250|       |
  251|  12.2k|		break;
  252|       |
  253|  12.2k|	case ISEQ_SYNC_FLUSH:
  ------------------
  |  Branch (253:2): [True: 0, False: 12.6k]
  ------------------
  254|       |		// The same action must be used until we return
  255|       |		// LZMA_STREAM_END, and the amount of input must not change.
  256|      0|		if (action != LZMA_SYNC_FLUSH
  ------------------
  |  Branch (256:7): [True: 0, False: 0]
  ------------------
  257|      0|				|| strm->internal->avail_in != strm->avail_in)
  ------------------
  |  Branch (257:8): [True: 0, False: 0]
  ------------------
  258|      0|			return LZMA_PROG_ERROR;
  259|       |
  260|      0|		break;
  261|       |
  262|      0|	case ISEQ_FULL_FLUSH:
  ------------------
  |  Branch (262:2): [True: 0, False: 12.6k]
  ------------------
  263|      0|		if (action != LZMA_FULL_FLUSH
  ------------------
  |  Branch (263:7): [True: 0, False: 0]
  ------------------
  264|      0|				|| strm->internal->avail_in != strm->avail_in)
  ------------------
  |  Branch (264:8): [True: 0, False: 0]
  ------------------
  265|      0|			return LZMA_PROG_ERROR;
  266|       |
  267|      0|		break;
  268|       |
  269|    428|	case ISEQ_FINISH:
  ------------------
  |  Branch (269:2): [True: 428, False: 12.2k]
  ------------------
  270|    428|		if (action != LZMA_FINISH
  ------------------
  |  Branch (270:7): [True: 0, False: 428]
  ------------------
  271|    428|				|| strm->internal->avail_in != strm->avail_in)
  ------------------
  |  Branch (271:8): [True: 0, False: 428]
  ------------------
  272|      0|			return LZMA_PROG_ERROR;
  273|       |
  274|    428|		break;
  275|       |
  276|    428|	case ISEQ_FULL_BARRIER:
  ------------------
  |  Branch (276:2): [True: 0, False: 12.6k]
  ------------------
  277|      0|		if (action != LZMA_FULL_BARRIER
  ------------------
  |  Branch (277:7): [True: 0, False: 0]
  ------------------
  278|      0|				|| strm->internal->avail_in != strm->avail_in)
  ------------------
  |  Branch (278:8): [True: 0, False: 0]
  ------------------
  279|      0|			return LZMA_PROG_ERROR;
  280|       |
  281|      0|		break;
  282|       |
  283|      0|	case ISEQ_END:
  ------------------
  |  Branch (283:2): [True: 0, False: 12.6k]
  ------------------
  284|      0|		return LZMA_STREAM_END;
  285|       |
  286|      0|	case ISEQ_ERROR:
  ------------------
  |  Branch (286:2): [True: 0, False: 12.6k]
  ------------------
  287|      0|	default:
  ------------------
  |  Branch (287:2): [True: 0, False: 12.6k]
  ------------------
  288|      0|		return LZMA_PROG_ERROR;
  289|  12.6k|	}
  290|       |
  291|  12.6k|	size_t in_pos = 0;
  292|  12.6k|	size_t out_pos = 0;
  293|  12.6k|	lzma_ret ret = strm->internal->next.code(
  294|  12.6k|			strm->internal->next.coder, strm->allocator,
  295|  12.6k|			strm->next_in, &in_pos, strm->avail_in,
  296|  12.6k|			strm->next_out, &out_pos, strm->avail_out, action);
  297|       |
  298|       |	// Updating next_in and next_out has to be skipped when they are NULL
  299|       |	// to avoid null pointer + 0 (undefined behavior). Do this by checking
  300|       |	// in_pos > 0 and out_pos > 0 because this way NULL + non-zero (a bug)
  301|       |	// will get caught one way or other.
  302|  12.6k|	if (in_pos > 0) {
  ------------------
  |  Branch (302:6): [True: 10.8k, False: 1.74k]
  ------------------
  303|  10.8k|		strm->next_in += in_pos;
  304|  10.8k|		strm->avail_in -= in_pos;
  305|  10.8k|		strm->total_in += in_pos;
  306|  10.8k|	}
  307|       |
  308|  12.6k|	if (out_pos > 0) {
  ------------------
  |  Branch (308:6): [True: 0, False: 12.6k]
  ------------------
  309|      0|		strm->next_out += out_pos;
  310|      0|		strm->avail_out -= out_pos;
  311|      0|		strm->total_out += out_pos;
  312|      0|	}
  313|       |
  314|  12.6k|	strm->internal->avail_in = strm->avail_in;
  315|       |
  316|  12.6k|	switch (ret) {
  317|  9.75k|	case LZMA_OK:
  ------------------
  |  Branch (317:2): [True: 9.75k, False: 2.88k]
  ------------------
  318|       |		// Don't return LZMA_BUF_ERROR when it happens the first time.
  319|       |		// This is to avoid returning LZMA_BUF_ERROR when avail_out
  320|       |		// was zero but still there was no more data left to written
  321|       |		// to next_out.
  322|  9.75k|		if (out_pos == 0 && in_pos == 0) {
  ------------------
  |  Branch (322:7): [True: 9.75k, False: 0]
  |  Branch (322:23): [True: 1.74k, False: 8.00k]
  ------------------
  323|  1.74k|			if (strm->internal->allow_buf_error)
  ------------------
  |  Branch (323:8): [True: 874, False: 874]
  ------------------
  324|    874|				ret = LZMA_BUF_ERROR;
  325|    874|			else
  326|    874|				strm->internal->allow_buf_error = true;
  327|  8.00k|		} else {
  328|  8.00k|			strm->internal->allow_buf_error = false;
  329|  8.00k|		}
  330|  9.75k|		break;
  331|       |
  332|      0|	case LZMA_TIMED_OUT:
  ------------------
  |  |  168|      0|#define LZMA_TIMED_OUT LZMA_RET_INTERNAL1
  ------------------
  |  Branch (332:2): [True: 0, False: 12.6k]
  ------------------
  333|      0|		strm->internal->allow_buf_error = false;
  334|      0|		ret = LZMA_OK;
  335|      0|		break;
  336|       |
  337|      0|	case LZMA_SEEK_NEEDED:
  ------------------
  |  Branch (337:2): [True: 0, False: 12.6k]
  ------------------
  338|      0|		strm->internal->allow_buf_error = false;
  339|       |
  340|       |		// If LZMA_FINISH was used, reset it back to the
  341|       |		// LZMA_RUN-based state so that new input can be supplied
  342|       |		// by the application.
  343|      0|		if (strm->internal->sequence == ISEQ_FINISH)
  ------------------
  |  Branch (343:7): [True: 0, False: 0]
  ------------------
  344|      0|			strm->internal->sequence = ISEQ_RUN;
  345|       |
  346|      0|		break;
  347|       |
  348|    100|	case LZMA_STREAM_END:
  ------------------
  |  Branch (348:2): [True: 100, False: 12.5k]
  ------------------
  349|    100|		if (strm->internal->sequence == ISEQ_SYNC_FLUSH
  ------------------
  |  Branch (349:7): [True: 0, False: 100]
  ------------------
  350|    100|				|| strm->internal->sequence == ISEQ_FULL_FLUSH
  ------------------
  |  Branch (350:8): [True: 0, False: 100]
  ------------------
  351|    100|				|| strm->internal->sequence
  ------------------
  |  Branch (351:8): [True: 0, False: 100]
  ------------------
  352|    100|					== ISEQ_FULL_BARRIER)
  353|      0|			strm->internal->sequence = ISEQ_RUN;
  354|    100|		else
  355|    100|			strm->internal->sequence = ISEQ_END;
  356|       |
  357|    100|		FALLTHROUGH;
  ------------------
  |  |  224|    100|#	define FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  358|       |
  359|    100|	case LZMA_NO_CHECK:
  ------------------
  |  Branch (359:2): [True: 0, False: 12.6k]
  ------------------
  360|    100|	case LZMA_UNSUPPORTED_CHECK:
  ------------------
  |  Branch (360:2): [True: 0, False: 12.6k]
  ------------------
  361|    100|	case LZMA_GET_CHECK:
  ------------------
  |  Branch (361:2): [True: 0, False: 12.6k]
  ------------------
  362|    163|	case LZMA_MEMLIMIT_ERROR:
  ------------------
  |  Branch (362:2): [True: 63, False: 12.5k]
  ------------------
  363|       |		// Something else than LZMA_OK, but not a fatal error,
  364|       |		// that is, coding may be continued (except if ISEQ_END).
  365|    163|		strm->internal->allow_buf_error = false;
  366|    163|		break;
  367|       |
  368|  2.72k|	default:
  ------------------
  |  Branch (368:2): [True: 2.72k, False: 9.91k]
  ------------------
  369|       |		// All the other errors are fatal; coding cannot be continued.
  370|  2.72k|		assert(ret != LZMA_BUF_ERROR);
  ------------------
  |  Branch (370:3): [True: 0, False: 2.72k]
  |  Branch (370:3): [True: 2.72k, False: 0]
  ------------------
  371|  2.72k|		strm->internal->sequence = ISEQ_ERROR;
  372|  2.72k|		break;
  373|  12.6k|	}
  374|       |
  375|  12.6k|	return ret;
  376|  12.6k|}
lzma_end:
  381|  1.27k|{
  382|  1.27k|	if (strm != NULL && strm->internal != NULL) {
  ------------------
  |  Branch (382:6): [True: 1.27k, False: 0]
  |  Branch (382:22): [True: 1.27k, False: 6]
  ------------------
  383|  1.27k|		lzma_next_end(&strm->internal->next, strm->allocator);
  384|  1.27k|		lzma_free(strm->internal, strm->allocator);
  385|  1.27k|		strm->internal = NULL;
  386|  1.27k|	}
  387|       |
  388|  1.27k|	return;
  389|  1.27k|}

lzma_index_init:
  461|  5.03k|{
  462|  5.03k|	lzma_index *i = index_init_plain(allocator);
  463|  5.03k|	if (i == NULL)
  ------------------
  |  Branch (463:6): [True: 10, False: 5.02k]
  ------------------
  464|     10|		return NULL;
  465|       |
  466|  5.02k|	index_stream *s = index_stream_init(
  467|  5.02k|			i->compressed_bias, i->uncompressed_bias,
  468|  5.02k|			0, i->block_number_bias, allocator);
  469|  5.02k|	if (s == NULL) {
  ------------------
  |  Branch (469:6): [True: 4, False: 5.02k]
  ------------------
  470|      4|		lzma_free(i, allocator);
  471|      4|		return NULL;
  472|      4|	}
  473|       |
  474|  5.02k|	index_tree_append(&i->streams, &s->node, true);
  475|       |
  476|  5.02k|	return i;
  477|  5.02k|}
lzma_index_end:
  482|  10.0k|{
  483|       |	// NOTE: If you modify this function, check also the bottom
  484|       |	// of lzma_index_cat().
  485|  10.0k|	if (i != NULL) {
  ------------------
  |  Branch (485:6): [True: 5.02k, False: 4.99k]
  ------------------
  486|  5.02k|		index_tree_end(&i->streams, allocator, &index_stream_end);
  487|  5.02k|		lzma_free(i, allocator);
  488|  5.02k|	}
  489|       |
  490|  10.0k|	return;
  491|  10.0k|}
lzma_index_prealloc:
  496|  2.02k|{
  497|  2.02k|	if (records > PREALLOC_MAX)
  ------------------
  |  |   33|  2.02k|#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))
  ------------------
  |  Branch (497:6): [True: 0, False: 2.02k]
  ------------------
  498|      0|		return true;
  499|       |
  500|       |	// If index_decoder.c calls us with records == 0, it's decoding
  501|       |	// an Index that has no Records. In that case the decoder won't call
  502|       |	// lzma_index_append() at all, and i->prealloc isn't used during
  503|       |	// the Index decoding either.
  504|       |	//
  505|       |	// Normally the first lzma_index_append() call from the Index decoder
  506|       |	// would reset i->prealloc to INDEX_GROUP_SIZE. With no Records,
  507|       |	// lzma_index_append() isn't called and the resetting of prealloc
  508|       |	// won't occur either. Thus, if records == 0, use the default value
  509|       |	// INDEX_GROUP_SIZE instead.
  510|       |	//
  511|       |	// NOTE: lzma_index_append() assumes i->prealloc > 0. liblzma <= 5.8.2
  512|       |	// didn't have this check and could set i->prealloc = 0, which would
  513|       |	// result in a buffer overflow if the application called
  514|       |	// lzma_index_append() after decoding an empty Index. Appending
  515|       |	// Records after decoding an Index is a rare thing to do, but
  516|       |	// it is supposed to work.
  517|  2.02k|	if (records == 0)
  ------------------
  |  Branch (517:6): [True: 184, False: 1.84k]
  ------------------
  518|    184|		records = INDEX_GROUP_SIZE;
  ------------------
  |  |   29|    184|#define INDEX_GROUP_SIZE 512
  ------------------
  519|       |
  520|  2.02k|	i->prealloc = (size_t)(records);
  521|       |	return false;
  522|  2.02k|}
lzma_index_memusage:
  527|  2.08k|{
  528|       |	// This calculates an upper bound that is only a little bit
  529|       |	// bigger than the exact maximum memory usage with the given
  530|       |	// parameters.
  531|       |
  532|       |	// Typical malloc() overhead is 2 * sizeof(void *) but we take
  533|       |	// a little bit extra just in case. Using LZMA_MEMUSAGE_BASE
  534|       |	// instead would give too inaccurate estimate.
  535|  2.08k|	const size_t alloc_overhead = 4 * sizeof(void *);
  536|       |
  537|       |	// Amount of memory needed for each Stream base structures.
  538|       |	// We assume that every Stream has at least one Block and
  539|       |	// thus at least one group.
  540|  2.08k|	const size_t stream_base = sizeof(index_stream)
  541|  2.08k|			+ sizeof(index_group) + 2 * alloc_overhead;
  542|       |
  543|       |	// Amount of memory needed per group.
  544|  2.08k|	const size_t group_base = sizeof(index_group)
  545|  2.08k|			+ INDEX_GROUP_SIZE * sizeof(index_record)
  ------------------
  |  |   29|  2.08k|#define INDEX_GROUP_SIZE 512
  ------------------
  546|  2.08k|			+ alloc_overhead;
  547|       |
  548|       |	// Number of groups. There may actually be more, but that overhead
  549|       |	// has been taken into account in stream_base already.
  550|  2.08k|	const lzma_vli groups
  551|  2.08k|			= (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE;
  ------------------
  |  |   29|  2.08k|#define INDEX_GROUP_SIZE 512
  ------------------
              			= (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE;
  ------------------
  |  |   29|  2.08k|#define INDEX_GROUP_SIZE 512
  ------------------
  552|       |
  553|       |	// Memory used by index_stream and index_group structures.
  554|  2.08k|	const uint64_t streams_mem = streams * stream_base;
  555|  2.08k|	const uint64_t groups_mem = groups * group_base;
  556|       |
  557|       |	// Memory used by the base structure.
  558|  2.08k|	const uint64_t index_base = sizeof(lzma_index) + alloc_overhead;
  559|       |
  560|       |	// Validate the arguments and catch integer overflows.
  561|  2.08k|	const uint64_t limit = UINT64_MAX - index_base;
  562|  2.08k|	if (streams == 0 || streams > STREAMS_MAX || blocks > LZMA_VLI_MAX
  ------------------
  |  |   22|  4.17k|#define STREAMS_MAX UINT32_MAX
  ------------------
              	if (streams == 0 || streams > STREAMS_MAX || blocks > LZMA_VLI_MAX
  ------------------
  |  |   32|  4.17k|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (562:6): [True: 0, False: 2.08k]
  |  Branch (562:22): [True: 0, False: 2.08k]
  |  Branch (562:47): [True: 0, False: 2.08k]
  ------------------
  563|  2.08k|			|| streams > limit / stream_base
  ------------------
  |  Branch (563:7): [True: 0, False: 2.08k]
  ------------------
  564|  2.08k|			|| groups > limit / group_base
  ------------------
  |  Branch (564:7): [True: 0, False: 2.08k]
  ------------------
  565|  2.08k|			|| limit - streams_mem < groups_mem)
  ------------------
  |  Branch (565:7): [True: 0, False: 2.08k]
  ------------------
  566|      0|		return UINT64_MAX;
  567|       |
  568|  2.08k|	return index_base + streams_mem + groups_mem;
  569|  2.08k|}
lzma_index_padding_size:
  676|    275|{
  677|       |	return (LZMA_VLI_C(4) - index_size_unpadded(
  ------------------
  |  |   47|    275|#define LZMA_VLI_C(n) UINT64_C(n)
  ------------------
  678|    275|			i->record_count, i->index_list_size)) & 3;
  679|    275|}
lzma_index_append:
  724|  14.5M|{
  725|       |	// Validate.
  726|  14.5M|	if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN
  ------------------
  |  |   24|  14.5M|#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  |  Branch (726:6): [True: 0, False: 14.5M]
  |  Branch (726:19): [True: 0, False: 14.5M]
  ------------------
  727|  14.5M|			|| unpadded_size > UNPADDED_SIZE_MAX
  ------------------
  |  |   27|  29.0M|#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  |  |  ------------------
  |  |               #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  |  Branch (727:7): [True: 0, False: 14.5M]
  ------------------
  728|  14.5M|			|| uncompressed_size > LZMA_VLI_MAX)
  ------------------
  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (728:7): [True: 0, False: 14.5M]
  ------------------
  729|      0|		return LZMA_PROG_ERROR;
  730|       |
  731|  14.5M|	index_stream *s = (index_stream *)(i->streams.rightmost);
  732|  14.5M|	index_group *g = (index_group *)(s->groups.rightmost);
  733|       |
  734|  14.5M|	const lzma_vli compressed_base = g == NULL ? 0
  ------------------
  |  Branch (734:35): [True: 1.08k, False: 14.5M]
  ------------------
  735|  14.5M|			: vli_ceil4(g->records[g->last].unpadded_sum);
  736|  14.5M|	const lzma_vli uncompressed_base = g == NULL ? 0
  ------------------
  |  Branch (736:37): [True: 1.08k, False: 14.5M]
  ------------------
  737|  14.5M|			: g->records[g->last].uncompressed_sum;
  738|  14.5M|	const uint32_t index_list_size_add = lzma_vli_size(unpadded_size)
  739|  14.5M|			+ lzma_vli_size(uncompressed_size);
  740|       |
  741|       |	// Check that uncompressed size will not overflow.
  742|  14.5M|	if (uncompressed_base + uncompressed_size > LZMA_VLI_MAX)
  ------------------
  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (742:6): [True: 80, False: 14.5M]
  ------------------
  743|     80|		return LZMA_DATA_ERROR;
  744|       |
  745|       |	// Check that the new unpadded sum will not overflow. This is
  746|       |	// checked again in index_file_size(), but the unpadded sum is
  747|       |	// passed to vli_ceil4() which expects a valid lzma_vli value.
  748|  14.5M|	if (compressed_base + unpadded_size > UNPADDED_SIZE_MAX)
  ------------------
  |  |   27|  14.5M|#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  |  |  ------------------
  |  |               #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  |  Branch (748:6): [True: 24, False: 14.5M]
  ------------------
  749|     24|		return LZMA_DATA_ERROR;
  750|       |
  751|       |	// Check that the file size will stay within limits.
  752|  14.5M|	if (index_file_size(s->node.compressed_base - i->compressed_bias,
  ------------------
  |  Branch (752:6): [True: 31, False: 14.5M]
  ------------------
  753|  14.5M|			compressed_base + unpadded_size, s->record_count + 1,
  754|  14.5M|			s->index_list_size + index_list_size_add,
  755|  14.5M|			s->stream_padding) == LZMA_VLI_UNKNOWN)
  ------------------
  |  |   37|  14.5M|#define LZMA_VLI_UNKNOWN UINT64_MAX
  ------------------
  756|     31|		return LZMA_DATA_ERROR;
  757|       |
  758|       |	// The size of the Index field must not exceed the maximum value
  759|       |	// that can be stored in the Backward Size field.
  760|  14.5M|	if (index_size(i->record_count + 1,
  ------------------
  |  Branch (760:6): [True: 0, False: 14.5M]
  ------------------
  761|  14.5M|			i->index_list_size + index_list_size_add)
  762|  14.5M|			> LZMA_BACKWARD_SIZE_MAX)
  ------------------
  |  |   77|  14.5M|#	define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  763|      0|		return LZMA_DATA_ERROR;
  764|       |
  765|  14.5M|	if (g != NULL && g->last + 1 < g->allocated) {
  ------------------
  |  Branch (765:6): [True: 14.5M, False: 1.06k]
  |  Branch (765:19): [True: 14.5M, False: 0]
  ------------------
  766|       |		// There is space in the last group at least for one Record.
  767|  14.5M|		++g->last;
  768|  14.5M|	} else {
  769|       |		// We need to allocate a new group.
  770|  1.06k|		assert(i->prealloc > 0);
  ------------------
  |  Branch (770:3): [True: 0, False: 1.06k]
  |  Branch (770:3): [True: 1.06k, False: 0]
  ------------------
  771|  1.06k|		g = lzma_alloc(sizeof(index_group)
  772|  1.06k|				+ i->prealloc * sizeof(index_record),
  773|  1.06k|				allocator);
  774|  1.06k|		if (g == NULL)
  ------------------
  |  Branch (774:7): [True: 4, False: 1.06k]
  ------------------
  775|      4|			return LZMA_MEM_ERROR;
  776|       |
  777|  1.06k|		g->last = 0;
  778|  1.06k|		g->allocated = i->prealloc;
  779|       |
  780|       |		// Reset prealloc so that if the application happens to
  781|       |		// add new Records, the allocation size will be sane.
  782|  1.06k|		i->prealloc = INDEX_GROUP_SIZE;
  ------------------
  |  |   29|  1.06k|#define INDEX_GROUP_SIZE 512
  ------------------
  783|       |
  784|       |		// Set the start offsets of this group.
  785|  1.06k|		g->node.uncompressed_base = uncompressed_base;
  786|  1.06k|		g->node.compressed_base = compressed_base;
  787|  1.06k|		g->number_base = s->record_count + 1;
  788|       |
  789|       |		// Add the new group to the Stream.
  790|  1.06k|		index_tree_append(&s->groups, &g->node, false);
  791|  1.06k|	}
  792|       |
  793|       |	// Add the new Record to the group.
  794|  14.5M|	g->records[g->last].uncompressed_sum
  795|  14.5M|			= uncompressed_base + uncompressed_size;
  796|  14.5M|	g->records[g->last].unpadded_sum
  797|  14.5M|			= compressed_base + unpadded_size;
  798|       |
  799|       |	// Update the totals.
  800|  14.5M|	++s->record_count;
  801|  14.5M|	s->index_list_size += index_list_size_add;
  802|       |
  803|  14.5M|	i->total_size += vli_ceil4(unpadded_size);
  804|  14.5M|	i->uncompressed_size += uncompressed_size;
  805|  14.5M|	++i->record_count;
  806|  14.5M|	i->index_list_size += index_list_size_add;
  807|       |
  808|  14.5M|	return LZMA_OK;
  809|  14.5M|}
index.c:index_init_plain:
  440|  5.03k|{
  441|  5.03k|	lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);
  442|  5.03k|	if (i != NULL) {
  ------------------
  |  Branch (442:6): [True: 5.02k, False: 10]
  ------------------
  443|  5.02k|		index_tree_init(&i->streams);
  444|  5.02k|		i->uncompressed_bias = LZMA_VLI_MAX;
  ------------------
  |  |   32|  5.02k|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  445|  5.02k|		i->compressed_bias = LZMA_VLI_MAX;
  ------------------
  |  |   32|  5.02k|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  446|  5.02k|		i->block_number_bias = LZMA_VLI_MAX;
  ------------------
  |  |   32|  5.02k|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  447|  5.02k|		i->uncompressed_size = 0;
  448|  5.02k|		i->total_size = 0;
  449|  5.02k|		i->record_count = 0;
  450|  5.02k|		i->index_list_size = 0;
  451|  5.02k|		i->prealloc = INDEX_GROUP_SIZE;
  ------------------
  |  |   29|  5.02k|#define INDEX_GROUP_SIZE 512
  ------------------
  452|  5.02k|		i->checks = 0;
  453|  5.02k|	}
  454|       |
  455|  5.03k|	return i;
  456|  5.03k|}
index.c:index_tree_init:
  203|  10.0k|{
  204|  10.0k|	tree->root = NULL;
  205|  10.0k|	tree->leftmost = NULL;
  206|       |	tree->rightmost = NULL;
  207|  10.0k|	tree->count = 0;
  208|  10.0k|	return;
  209|  10.0k|}
index.c:index_stream_init:
  402|  5.02k|{
  403|  5.02k|	index_stream *s = lzma_alloc(sizeof(index_stream), allocator);
  404|  5.02k|	if (s == NULL)
  ------------------
  |  Branch (404:6): [True: 4, False: 5.02k]
  ------------------
  405|      4|		return NULL;
  406|       |
  407|  5.02k|	s->node.uncompressed_base = uncompressed_base;
  408|  5.02k|	s->node.compressed_base = compressed_base;
  409|  5.02k|	s->node.parent = NULL;
  410|  5.02k|	s->node.left = NULL;
  411|  5.02k|	s->node.right = NULL;
  412|       |
  413|  5.02k|	s->number = stream_number;
  414|  5.02k|	s->block_number_base = block_number_base;
  415|       |
  416|  5.02k|	index_tree_init(&s->groups);
  417|       |
  418|  5.02k|	s->record_count = 0;
  419|  5.02k|	s->index_list_size = 0;
  420|  5.02k|	s->stream_flags.version = UINT32_MAX;
  421|  5.02k|	s->stream_padding = 0;
  422|       |
  423|  5.02k|	return s;
  424|  5.02k|}
index.c:index_tree_append:
  254|  6.08k|{
  255|  6.08k|	node->parent = prepend ? tree->leftmost : tree->rightmost;
  ------------------
  |  Branch (255:17): [True: 5.02k, False: 1.06k]
  ------------------
  256|  6.08k|	node->left = NULL;
  257|  6.08k|	node->right = NULL;
  258|       |
  259|  6.08k|	++tree->count;
  260|       |
  261|       |	// Handle the special case of adding the first node.
  262|  6.08k|	if (tree->root == NULL) {
  ------------------
  |  Branch (262:6): [True: 6.08k, False: 0]
  ------------------
  263|  6.08k|		tree->root = node;
  264|  6.08k|		tree->leftmost = node;
  265|  6.08k|		tree->rightmost = node;
  266|  6.08k|		return;
  267|  6.08k|	}
  268|       |
  269|       |	// Add the new node before the leftmost or after the rightmost node.
  270|      0|	if (prepend) {
  ------------------
  |  Branch (270:6): [True: 0, False: 0]
  ------------------
  271|      0|		assert(tree->leftmost->uncompressed_base
  ------------------
  |  Branch (271:3): [True: 0, False: 0]
  |  Branch (271:3): [True: 0, False: 0]
  ------------------
  272|      0|				>= node->uncompressed_base);
  273|      0|		assert(tree->leftmost->compressed_base
  ------------------
  |  Branch (273:3): [True: 0, False: 0]
  |  Branch (273:3): [True: 0, False: 0]
  ------------------
  274|      0|				> node->compressed_base);
  275|      0|		tree->leftmost->left = node;
  276|      0|		tree->leftmost = node;
  277|      0|	} else {
  278|      0|		assert(tree->rightmost->uncompressed_base
  ------------------
  |  Branch (278:3): [True: 0, False: 0]
  |  Branch (278:3): [True: 0, False: 0]
  ------------------
  279|      0|				<= node->uncompressed_base);
  280|      0|		assert(tree->rightmost->compressed_base
  ------------------
  |  Branch (280:3): [True: 0, False: 0]
  |  Branch (280:3): [True: 0, False: 0]
  ------------------
  281|      0|				< node->compressed_base);
  282|      0|		tree->rightmost->right = node;
  283|      0|		tree->rightmost = node;
  284|      0|	}
  285|       |
  286|       |	// Balance the AVL-tree if needed. We don't need to keep the balance
  287|       |	// factors in nodes, because we always fill the tree sequentially,
  288|       |	// and thus know the state of the tree just by looking at the node
  289|       |	// count. From the node count we can calculate how many steps to go
  290|       |	// up in the tree to find the rotation root.
  291|      0|	uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));
  292|      0|	if (up != 0) {
  ------------------
  |  Branch (292:6): [True: 0, False: 0]
  ------------------
  293|       |		// Locate the root node for the rotation.
  294|      0|		up = ctz32(tree->count) + 2;
  295|      0|		do {
  296|      0|			node = node->parent;
  297|      0|		} while (--up > 0);
  ------------------
  |  Branch (297:12): [True: 0, False: 0]
  ------------------
  298|       |
  299|       |		// Rotate right/left using node as the rotation root.
  300|      0|		index_tree_node *pivot = prepend ? node->left : node->right;
  ------------------
  |  Branch (300:28): [True: 0, False: 0]
  ------------------
  301|       |
  302|      0|		if (node->parent == NULL) {
  ------------------
  |  Branch (302:7): [True: 0, False: 0]
  ------------------
  303|      0|			tree->root = pivot;
  304|      0|		} else if (prepend) {
  ------------------
  |  Branch (304:14): [True: 0, False: 0]
  ------------------
  305|      0|			assert(node->parent->left == node);
  ------------------
  |  Branch (305:4): [True: 0, False: 0]
  |  Branch (305:4): [True: 0, False: 0]
  ------------------
  306|      0|			node->parent->left = pivot;
  307|      0|		} else {
  308|      0|			assert(node->parent->right == node);
  ------------------
  |  Branch (308:4): [True: 0, False: 0]
  |  Branch (308:4): [True: 0, False: 0]
  ------------------
  309|      0|			node->parent->right = pivot;
  310|      0|		}
  311|       |
  312|      0|		pivot->parent = node->parent;
  313|       |
  314|      0|		if (prepend) {
  ------------------
  |  Branch (314:7): [True: 0, False: 0]
  ------------------
  315|      0|			node->left = pivot->right;
  316|      0|			if (node->left != NULL)
  ------------------
  |  Branch (316:8): [True: 0, False: 0]
  ------------------
  317|      0|				node->left->parent = node;
  318|       |
  319|      0|			pivot->right = node;
  320|      0|		} else {
  321|      0|			node->right = pivot->left;
  322|      0|			if (node->right != NULL)
  ------------------
  |  Branch (322:8): [True: 0, False: 0]
  ------------------
  323|      0|				node->right->parent = node;
  324|       |
  325|      0|			pivot->left = node;
  326|      0|		}
  327|       |
  328|      0|		node->parent = pivot;
  329|      0|	}
  330|       |
  331|      0|	return;
  332|      0|}
index.c:index_tree_end:
  237|  10.0k|{
  238|  10.0k|	assert(free_func != NULL);
  ------------------
  |  Branch (238:2): [True: 0, False: 10.0k]
  |  Branch (238:2): [True: 10.0k, False: 0]
  ------------------
  239|       |
  240|  10.0k|	if (tree->root != NULL)
  ------------------
  |  Branch (240:6): [True: 6.08k, False: 3.95k]
  ------------------
  241|  6.08k|		index_tree_node_end(tree->root, allocator, free_func);
  242|       |
  243|  10.0k|	return;
  244|  10.0k|}
index.c:index_tree_node_end:
  216|  6.08k|{
  217|       |	// The tree won't ever be very huge, so recursion should be fine.
  218|       |	// 20 levels in the tree is likely quite a lot already in practice.
  219|  6.08k|	if (node->left != NULL)
  ------------------
  |  Branch (219:6): [True: 0, False: 6.08k]
  ------------------
  220|      0|		index_tree_node_end(node->left, allocator, free_func);
  221|       |
  222|  6.08k|	if (node->right != NULL)
  ------------------
  |  Branch (222:6): [True: 0, False: 6.08k]
  ------------------
  223|      0|		index_tree_node_end(node->right, allocator, free_func);
  224|       |
  225|  6.08k|	free_func(node, allocator);
  226|  6.08k|	return;
  227|  6.08k|}
index.c:index_stream_end:
  430|  5.02k|{
  431|  5.02k|	index_stream *s = node;
  432|  5.02k|	index_tree_end(&s->groups, allocator, &lzma_free);
  433|  5.02k|	lzma_free(s, allocator);
  434|  5.02k|	return;
  435|  5.02k|}
index.c:index_file_size:
  621|  14.5M|{
  622|       |	// Earlier Streams and Stream Paddings + Stream Header
  623|       |	// + Blocks + Index + Stream Footer + Stream Padding
  624|       |	//
  625|       |	// This might go over LZMA_VLI_MAX due to too big unpadded_sum
  626|       |	// when this function is used in lzma_index_append().
  627|  14.5M|	lzma_vli file_size = compressed_base + 2 * LZMA_STREAM_HEADER_SIZE
  ------------------
  |  |   25|  14.5M|#define LZMA_STREAM_HEADER_SIZE 12
  ------------------
  628|  14.5M|			+ stream_padding + vli_ceil4(unpadded_sum);
  629|  14.5M|	if (file_size > LZMA_VLI_MAX)
  ------------------
  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (629:6): [True: 19, False: 14.5M]
  ------------------
  630|     19|		return LZMA_VLI_UNKNOWN;
  ------------------
  |  |   37|     19|#define LZMA_VLI_UNKNOWN UINT64_MAX
  ------------------
  631|       |
  632|       |	// The same applies here.
  633|  14.5M|	file_size += index_size(record_count, index_list_size);
  634|  14.5M|	if (file_size > LZMA_VLI_MAX)
  ------------------
  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (634:6): [True: 12, False: 14.5M]
  ------------------
  635|     12|		return LZMA_VLI_UNKNOWN;
  ------------------
  |  |   37|     12|#define LZMA_VLI_UNKNOWN UINT64_MAX
  ------------------
  636|       |
  637|  14.5M|	return file_size;
  638|  14.5M|}

index.c:index_size:
   67|  29.0M|{
   68|  29.0M|	return vli_ceil4(index_size_unpadded(count, index_list_size));
   69|  29.0M|}
index.c:index_size_unpadded:
   58|  29.0M|{
   59|       |	// Index Indicator + Number of Records + List of Records + CRC32
   60|  29.0M|	return 1 + lzma_vli_size(count) + index_list_size + 4;
   61|  29.0M|}
index.c:vli_ceil4:
   49|  72.6M|{
   50|  72.6M|	assert(vli <= UNPADDED_SIZE_MAX);
  ------------------
  |  Branch (50:2): [True: 0, False: 72.6M]
  |  Branch (50:2): [True: 72.6M, False: 0]
  ------------------
   51|  72.6M|	return (vli + 3) & ~LZMA_VLI_C(3);
  ------------------
  |  |   47|  72.6M|#define LZMA_VLI_C(n) UINT64_C(n)
  ------------------
   52|  72.6M|}

lzma_index_decoder_init:
  312|  3.77k|{
  313|  3.77k|	lzma_next_coder_init(&lzma_index_decoder_init, next, allocator);
  ------------------
  |  |  389|  3.77k|#define lzma_next_coder_init(func, next, allocator) \
  |  |  390|  3.77k|do { \
  |  |  391|  3.77k|	if ((uintptr_t)(func) != (next)->init) \
  |  |  ------------------
  |  |  |  Branch (391:6): [True: 1.27k, False: 2.50k]
  |  |  ------------------
  |  |  392|  3.77k|		lzma_next_end(next, allocator); \
  |  |  393|  3.77k|	(next)->init = (uintptr_t)(func); \
  |  |  394|  3.77k|} while (0)
  |  |  ------------------
  |  |  |  Branch (394:10): [Folded, False: 3.77k]
  |  |  ------------------
  ------------------
  314|       |
  315|  3.77k|	if (i == NULL)
  ------------------
  |  Branch (315:6): [True: 0, False: 3.77k]
  ------------------
  316|      0|		return LZMA_PROG_ERROR;
  317|       |
  318|  3.77k|	lzma_index_coder *coder = next->coder;
  319|  3.77k|	if (coder == NULL) {
  ------------------
  |  Branch (319:6): [True: 1.27k, False: 2.50k]
  ------------------
  320|  1.27k|		coder = lzma_alloc(sizeof(lzma_index_coder), allocator);
  321|  1.27k|		if (coder == NULL)
  ------------------
  |  Branch (321:7): [True: 3, False: 1.27k]
  ------------------
  322|      3|			return LZMA_MEM_ERROR;
  323|       |
  324|  1.27k|		next->coder = coder;
  325|  1.27k|		next->code = &index_decode;
  326|  1.27k|		next->end = &index_decoder_end;
  327|  1.27k|		next->memconfig = &index_decoder_memconfig;
  328|  1.27k|		coder->index = NULL;
  329|  2.50k|	} else {
  330|  2.50k|		lzma_index_end(coder->index, allocator);
  331|  2.50k|	}
  332|       |
  333|  3.77k|	return index_decoder_reset(
  334|  3.77k|			coder, allocator, i, memlimit, input_size_max);
  335|  3.77k|}
lzma_index_decoder:
  340|  3.78k|{
  341|       |	// If i isn't NULL, *i must always be initialized due to
  342|       |	// the wording in the API docs. This way it is initialized
  343|       |	// if we return LZMA_PROG_ERROR due to strm == NULL.
  344|  3.78k|	if (i != NULL)
  ------------------
  |  Branch (344:6): [True: 3.78k, False: 0]
  ------------------
  345|  3.78k|		*i = NULL;
  346|       |
  347|  3.78k|	lzma_next_strm_init(lzma_index_decoder_init, strm, i, memlimit,
  ------------------
  |  |  401|  3.78k|#define lzma_next_strm_init(func, strm, ...) \
  |  |  402|  3.78k|do { \
  |  |  403|  3.78k|	return_if_error(lzma_strm_init(strm)); \
  |  |  ------------------
  |  |  |  |  376|  3.78k|#define return_if_error(expr) \
  |  |  |  |  377|  3.78k|do { \
  |  |  |  |  378|  3.78k|	const lzma_ret ret_ = (expr); \
  |  |  |  |  379|  3.78k|	if (ret_ != LZMA_OK) \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (379:6): [True: 7, False: 3.77k]
  |  |  |  |  ------------------
  |  |  |  |  380|  3.78k|		return ret_; \
  |  |  |  |  381|  3.78k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (381:10): [Folded, False: 3.77k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  404|  3.78k|	const lzma_ret ret_ = func(&(strm)->internal->next, \
  |  |  405|  3.77k|			(strm)->allocator, __VA_ARGS__); \
  |  |  406|  3.77k|	if (ret_ != LZMA_OK) { \
  |  |  ------------------
  |  |  |  Branch (406:6): [True: 17, False: 3.76k]
  |  |  ------------------
  |  |  407|     17|		lzma_end(strm); \
  |  |  408|     17|		return ret_; \
  |  |  409|     17|	} \
  |  |  410|  3.77k|} while (0)
  |  |  ------------------
  |  |  |  Branch (410:10): [Folded, False: 3.76k]
  |  |  ------------------
  ------------------
  348|  3.78k|			LZMA_BACKWARD_SIZE_MAX);
  349|       |
  350|  3.76k|	strm->internal->supported_actions[LZMA_RUN] = true;
  351|  3.76k|	strm->internal->supported_actions[LZMA_FINISH] = true;
  352|       |
  353|  3.76k|	return LZMA_OK;
  354|  3.78k|}
lzma_index_buffer_decode:
  361|  1.26k|{
  362|       |	// If i isn't NULL, *i must always be initialized due to
  363|       |	// the wording in the API docs.
  364|  1.26k|	if (i != NULL)
  ------------------
  |  Branch (364:6): [True: 1.26k, False: 0]
  ------------------
  365|  1.26k|		*i = NULL;
  366|       |
  367|       |	// Sanity checks
  368|  1.26k|	if (i == NULL || memlimit == NULL
  ------------------
  |  Branch (368:6): [True: 0, False: 1.26k]
  |  Branch (368:19): [True: 0, False: 1.26k]
  ------------------
  369|  1.26k|			|| in == NULL || in_pos == NULL || *in_pos > in_size)
  ------------------
  |  Branch (369:7): [True: 0, False: 1.26k]
  |  Branch (369:21): [True: 0, False: 1.26k]
  |  Branch (369:39): [True: 0, False: 1.26k]
  ------------------
  370|      0|		return LZMA_PROG_ERROR;
  371|       |
  372|       |	// Initialize the decoder.
  373|  1.26k|	lzma_index_coder coder;
  374|  1.26k|	const uint64_t input_size_max = in_size - *in_pos;
  375|  1.26k|	return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit,
  ------------------
  |  |  376|  1.26k|#define return_if_error(expr) \
  |  |  377|  1.26k|do { \
  |  |  378|  2.52k|	const lzma_ret ret_ = (expr); \
  |  |  ------------------
  |  |  |  Branch (378:25): [True: 1.26k, False: 0]
  |  |  ------------------
  |  |  379|  1.26k|	if (ret_ != LZMA_OK) \
  |  |  ------------------
  |  |  |  Branch (379:6): [True: 0, False: 1.26k]
  |  |  ------------------
  |  |  380|  1.26k|		return ret_; \
  |  |  381|  1.26k|} while (0)
  |  |  ------------------
  |  |  |  Branch (381:10): [Folded, False: 1.26k]
  |  |  ------------------
  ------------------
  376|  1.26k|			my_min(input_size_max, LZMA_BACKWARD_SIZE_MAX)));
  377|       |
  378|       |	// Store the input start position so that we can restore it in case
  379|       |	// of an error.
  380|  1.26k|	const size_t in_start = *in_pos;
  381|       |
  382|       |	// Do the actual decoding.
  383|  1.26k|	lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size,
  384|  1.26k|			NULL, NULL, 0, LZMA_RUN);
  385|       |
  386|  1.26k|	if (ret == LZMA_STREAM_END) {
  ------------------
  |  Branch (386:6): [True: 42, False: 1.22k]
  ------------------
  387|     42|		ret = LZMA_OK;
  388|  1.22k|	} else {
  389|       |		// Something went wrong, free the Index structure and restore
  390|       |		// the input position.
  391|  1.22k|		lzma_index_end(coder.index, allocator);
  392|  1.22k|		*in_pos = in_start;
  393|       |
  394|  1.22k|		if (ret == LZMA_OK) {
  ------------------
  |  Branch (394:7): [True: 585, False: 635]
  ------------------
  395|       |			// The input is truncated or otherwise corrupt.
  396|       |			// Use LZMA_DATA_ERROR instead of LZMA_BUF_ERROR
  397|       |			// like lzma_vli_decode() does in single-call mode.
  398|    585|			ret = LZMA_DATA_ERROR;
  399|       |
  400|    635|		} else if (ret == LZMA_MEMLIMIT_ERROR) {
  ------------------
  |  Branch (400:14): [True: 0, False: 635]
  ------------------
  401|       |			// Tell the caller how much memory would have
  402|       |			// been needed.
  403|      0|			*memlimit = coder.memused;
  404|      0|		}
  405|  1.22k|	}
  406|       |
  407|  1.26k|	return ret;
  408|  1.26k|}
index_decoder.c:index_decode:
   73|  13.9k|{
   74|  13.9k|	lzma_index_coder *coder = coder_ptr;
   75|       |
   76|       |	// Similar optimization as in index_encoder.c
   77|  13.9k|	const size_t in_start = *in_pos;
   78|  13.9k|	lzma_ret ret = LZMA_OK;
   79|       |
   80|  29.0M|	while (*in_pos < in_size)
  ------------------
  |  Branch (80:9): [True: 29.0M, False: 8.75k]
  ------------------
   81|  29.0M|	switch (coder->sequence) {
   82|  4.36k|	case SEQ_INDICATOR:
  ------------------
  |  Branch (82:2): [True: 4.36k, False: 29.0M]
  ------------------
   83|       |		// Return LZMA_DATA_ERROR instead of e.g. LZMA_PROG_ERROR or
   84|       |		// LZMA_FORMAT_ERROR, because a typical usage case for Index
   85|       |		// decoder is when parsing the Stream backwards. If seeking
   86|       |		// backward from the Stream Footer gives us something that
   87|       |		// doesn't begin with Index Indicator, the file is considered
   88|       |		// corrupt, not "programming error" or "unrecognized file
   89|       |		// format". One could argue that the application should
   90|       |		// verify the Index Indicator before trying to decode the
   91|       |		// Index, but well, I suppose it is simpler this way.
   92|  4.36k|		if (in[(*in_pos)++] != INDEX_INDICATOR)
  ------------------
  |  |   30|  4.36k|#define INDEX_INDICATOR 0
  ------------------
  |  Branch (92:7): [True: 1.65k, False: 2.71k]
  ------------------
   93|  1.65k|			return LZMA_DATA_ERROR;
   94|       |
   95|  2.71k|		coder->sequence = SEQ_COUNT;
   96|  2.71k|		break;
   97|       |
   98|  2.80k|	case SEQ_COUNT:
  ------------------
  |  Branch (98:2): [True: 2.80k, False: 29.0M]
  ------------------
   99|  2.80k|		ret = lzma_vli_decode(&coder->count, &coder->pos,
  100|  2.80k|				in, in_pos, in_size);
  101|  2.80k|		if (ret != LZMA_STREAM_END)
  ------------------
  |  Branch (101:7): [True: 258, False: 2.54k]
  ------------------
  102|    258|			goto out;
  103|       |
  104|       |		// Reject Number of Records values that are clearly invalid.
  105|  2.54k|		if (coder->count > coder->number_of_records_max)
  ------------------
  |  Branch (105:7): [True: 462, False: 2.08k]
  ------------------
  106|    462|			return LZMA_DATA_ERROR;
  107|       |
  108|  2.08k|		coder->pos = 0;
  109|  2.08k|		coder->sequence = SEQ_MEMUSAGE;
  110|  2.08k|		FALLTHROUGH;
  ------------------
  |  |  224|  2.08k|#	define FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  111|       |
  112|  2.08k|	case SEQ_MEMUSAGE:
  ------------------
  |  Branch (112:2): [True: 0, False: 29.0M]
  ------------------
  113|  2.08k|		coder->memused = lzma_index_memusage(1, coder->count);
  114|       |
  115|       |		// We sanity-checked coder->count in SEQ_COUNT, which
  116|       |		// guarantees that lzma_index_memusage() won't fail.
  117|  2.08k|		assert(coder->memused != UINT64_MAX);
  ------------------
  |  Branch (117:3): [True: 0, False: 2.08k]
  |  Branch (117:3): [True: 2.08k, False: 0]
  ------------------
  118|       |
  119|  2.08k|		if (coder->memused > coder->memlimit) {
  ------------------
  |  Branch (119:7): [True: 63, False: 2.02k]
  ------------------
  120|     63|			ret = LZMA_MEMLIMIT_ERROR;
  121|     63|			goto out;
  122|     63|		}
  123|       |
  124|       |		// Tell the Index handling code how many Records this
  125|       |		// Index has to allow it to allocate memory more efficiently.
  126|       |		// If the Record count is so high that memory allocation would
  127|       |		// fail later, return LZMA_MEM_ERROR now.
  128|  2.02k|		if (lzma_index_prealloc(coder->index, coder->count))
  ------------------
  |  Branch (128:7): [True: 0, False: 2.02k]
  ------------------
  129|      0|			return LZMA_MEM_ERROR;
  130|       |
  131|  2.02k|		ret = LZMA_OK;
  132|  2.02k|		coder->sequence = coder->count == 0
  ------------------
  |  Branch (132:21): [True: 184, False: 1.84k]
  ------------------
  133|  2.02k|				? SEQ_PADDING_INIT : SEQ_UNPADDED;
  134|  2.02k|		break;
  135|       |
  136|  14.5M|	case SEQ_UNPADDED:
  ------------------
  |  Branch (136:2): [True: 14.5M, False: 14.5M]
  ------------------
  137|  29.0M|	case SEQ_UNCOMPRESSED: {
  ------------------
  |  Branch (137:2): [True: 14.5M, False: 14.5M]
  ------------------
  138|  29.0M|		lzma_vli *size = coder->sequence == SEQ_UNPADDED
  ------------------
  |  Branch (138:20): [True: 14.5M, False: 14.5M]
  ------------------
  139|  29.0M|				? &coder->unpadded_size
  140|  29.0M|				: &coder->uncompressed_size;
  141|       |
  142|  29.0M|		ret = lzma_vli_decode(size, &coder->pos,
  143|  29.0M|				in, in_pos, in_size);
  144|  29.0M|		if (ret != LZMA_STREAM_END)
  ------------------
  |  Branch (144:7): [True: 2.04k, False: 29.0M]
  ------------------
  145|  2.04k|			goto out;
  146|       |
  147|  29.0M|		ret = LZMA_OK;
  148|  29.0M|		coder->pos = 0;
  149|       |
  150|  29.0M|		if (coder->sequence == SEQ_UNPADDED) {
  ------------------
  |  Branch (150:7): [True: 14.5M, False: 14.5M]
  ------------------
  151|       |			// Validate that encoded Unpadded Size isn't too small
  152|       |			// or too big.
  153|  14.5M|			if (coder->unpadded_size < UNPADDED_SIZE_MIN
  ------------------
  |  |   24|  14.5M|#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  |  Branch (153:8): [True: 239, False: 14.5M]
  ------------------
  154|  14.5M|					|| coder->unpadded_size
  ------------------
  |  Branch (154:9): [True: 13, False: 14.5M]
  ------------------
  155|  14.5M|						> UNPADDED_SIZE_MAX)
  ------------------
  |  |   27|  14.5M|#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   32|  14.5M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  |  |  ------------------
  |  |               #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
  |  |  ------------------
  |  |  |  |   47|  14.5M|#define LZMA_VLI_C(n) UINT64_C(n)
  |  |  ------------------
  ------------------
  156|    252|				return LZMA_DATA_ERROR;
  157|       |
  158|  14.5M|			coder->sequence = SEQ_UNCOMPRESSED;
  159|  14.5M|		} else {
  160|       |			// Add the decoded Record to the Index.
  161|  14.5M|			return_if_error(lzma_index_append(
  ------------------
  |  |  376|  14.5M|#define return_if_error(expr) \
  |  |  377|  14.5M|do { \
  |  |  378|  14.5M|	const lzma_ret ret_ = (expr); \
  |  |  379|  14.5M|	if (ret_ != LZMA_OK) \
  |  |  ------------------
  |  |  |  Branch (379:6): [True: 139, False: 14.5M]
  |  |  ------------------
  |  |  380|  14.5M|		return ret_; \
  |  |  381|  14.5M|} while (0)
  |  |  ------------------
  |  |  |  Branch (381:10): [Folded, False: 14.5M]
  |  |  ------------------
  ------------------
  162|  14.5M|					coder->index, allocator,
  163|  14.5M|					coder->unpadded_size,
  164|  14.5M|					coder->uncompressed_size));
  165|       |
  166|       |			// Check if this was the last Record.
  167|  14.5M|			coder->sequence = --coder->count == 0
  ------------------
  |  Branch (167:22): [True: 182, False: 14.5M]
  ------------------
  168|  14.5M|					? SEQ_PADDING_INIT
  169|  14.5M|					: SEQ_UNPADDED;
  170|  14.5M|		}
  171|       |
  172|  29.0M|		break;
  173|  29.0M|	}
  174|       |
  175|  29.0M|	case SEQ_PADDING_INIT:
  ------------------
  |  Branch (175:2): [True: 275, False: 29.0M]
  ------------------
  176|    275|		coder->pos = lzma_index_padding_size(coder->index);
  177|    275|		coder->sequence = SEQ_PADDING;
  178|    275|		FALLTHROUGH;
  ------------------
  |  |  224|    275|#	define FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  179|       |
  180|    483|	case SEQ_PADDING:
  ------------------
  |  Branch (180:2): [True: 208, False: 29.0M]
  ------------------
  181|    483|		if (coder->pos > 0) {
  ------------------
  |  Branch (181:7): [True: 320, False: 163]
  ------------------
  182|    320|			--coder->pos;
  183|    320|			if (in[(*in_pos)++] != 0x00)
  ------------------
  |  Branch (183:8): [True: 91, False: 229]
  ------------------
  184|     91|				return LZMA_DATA_ERROR;
  185|       |
  186|    229|			break;
  187|    320|		}
  188|       |
  189|       |		// Finish the CRC32 calculation.
  190|    163|		coder->crc32 = lzma_crc32(in + in_start,
  191|    163|				*in_pos - in_start, coder->crc32);
  192|       |
  193|    163|		coder->sequence = SEQ_CRC32;
  194|    163|		FALLTHROUGH;
  ------------------
  |  |  224|    163|#	define FALLTHROUGH __attribute__((__fallthrough__))
  ------------------
  195|       |
  196|    184|	case SEQ_CRC32:
  ------------------
  |  Branch (196:2): [True: 21, False: 29.0M]
  ------------------
  197|    655|		do {
  198|    655|			if (*in_pos == in_size)
  ------------------
  |  Branch (198:8): [True: 42, False: 613]
  ------------------
  199|     42|				return LZMA_OK;
  200|       |
  201|    613|			if (((coder->crc32 >> (coder->pos * 8)) & 0xFF)
  ------------------
  |  Branch (201:8): [True: 610, False: 3]
  ------------------
  202|    613|					!= in[(*in_pos)++]) {
  203|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  204|       |				return LZMA_DATA_ERROR;
  205|       |#endif
  206|    610|			}
  207|       |
  208|    613|		} while (++coder->pos < 4);
  ------------------
  |  Branch (208:12): [True: 471, False: 142]
  ------------------
  209|       |
  210|       |		// Decoding was successful, now we can let the application
  211|       |		// see the decoded Index.
  212|    142|		*coder->index_ptr = coder->index;
  213|       |
  214|       |		// Make index NULL so we don't free it unintentionally.
  215|    142|		coder->index = NULL;
  216|       |
  217|    142|		return LZMA_STREAM_END;
  218|       |
  219|      0|	default:
  ------------------
  |  Branch (219:2): [True: 0, False: 29.0M]
  ------------------
  220|      0|		assert(0);
  ------------------
  |  Branch (220:3): [Folded, False: 0]
  |  Branch (220:3): [Folded, False: 0]
  ------------------
  221|      0|		return LZMA_PROG_ERROR;
  222|  29.0M|	}
  223|       |
  224|  11.1k|out:
  225|       |	// Update the CRC32.
  226|       |	//
  227|       |	// Avoid null pointer + 0 (undefined behavior) in "in + in_start".
  228|       |	// In such a case we had no input and thus in_used == 0.
  229|  11.1k|	{
  230|  11.1k|		const size_t in_used = *in_pos - in_start;
  231|  11.1k|		if (in_used > 0)
  ------------------
  |  Branch (231:7): [True: 9.37k, False: 1.74k]
  ------------------
  232|  9.37k|			coder->crc32 = lzma_crc32(in + in_start,
  233|  9.37k|					in_used, coder->crc32);
  234|  11.1k|	}
  235|       |
  236|  11.1k|	return ret;
  237|  13.9k|}
index_decoder.c:index_decoder_end:
  242|  1.27k|{
  243|  1.27k|	lzma_index_coder *coder = coder_ptr;
  244|  1.27k|	lzma_index_end(coder->index, allocator);
  245|  1.27k|	lzma_free(coder, allocator);
  246|  1.27k|	return;
  247|  1.27k|}
index_decoder.c:index_decoder_reset:
  276|  5.03k|{
  277|       |	// Remember the pointer given by the application. We will set it
  278|       |	// to point to the decoded Index only if decoding is successful.
  279|       |	// Before that, keep it NULL so that applications can always safely
  280|       |	// pass it to lzma_index_end() no matter did decoding succeed or not.
  281|  5.03k|	coder->index_ptr = i;
  282|  5.03k|	*i = NULL;
  283|       |
  284|       |	// We always allocate a new lzma_index.
  285|  5.03k|	coder->index = lzma_index_init(allocator);
  286|  5.03k|	if (coder->index == NULL)
  ------------------
  |  Branch (286:6): [True: 14, False: 5.02k]
  ------------------
  287|     14|		return LZMA_MEM_ERROR;
  288|       |
  289|       |	// Approximate how many Records the Index may contain at most when
  290|       |	// we know that the Index won't be larger than input_size_max bytes.
  291|       |	// Each Record must consume at least two bytes. The CRC32 etc.
  292|       |	// consume a few bytes too, but we don't need an exact value.
  293|       |	//
  294|       |	// file_info.c knows Backward Size and passes it to us. When we have
  295|       |	// no information, input_size_max equals LZMA_BACKWARD_SIZE_MAX.
  296|  5.02k|	coder->number_of_records_max = input_size_max / 2;
  297|       |
  298|       |	// Initialize the rest.
  299|  5.02k|	coder->sequence = SEQ_INDICATOR;
  300|  5.02k|	coder->memlimit = my_max(1, memlimit);
  ------------------
  |  |  207|  5.02k|#define my_max(x, y) ((x) > (y) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (207:23): [True: 0, False: 5.02k]
  |  |  ------------------
  ------------------
  301|  5.02k|	coder->memused = 1; // If _memconfig() is called before SEQ_MEMUSAGE.
  302|  5.02k|	coder->pos = 0;
  303|  5.02k|	coder->crc32 = 0;
  304|       |
  305|  5.02k|	return LZMA_OK;
  306|  5.03k|}

lzma_vli_decode:
   19|  29.0M|{
   20|       |	// If we haven't been given vli_pos, work in single-call mode.
   21|  29.0M|	size_t vli_pos_internal = 0;
   22|  29.0M|	if (vli_pos == NULL) {
  ------------------
  |  Branch (22:6): [True: 0, False: 29.0M]
  ------------------
   23|      0|		vli_pos = &vli_pos_internal;
   24|      0|		*vli = 0;
   25|       |
   26|       |		// If there's no input, use LZMA_DATA_ERROR. This way it is
   27|       |		// easy to decode VLIs from buffers that have known size,
   28|       |		// and get the correct error code in case the buffer is
   29|       |		// too short.
   30|      0|		if (*in_pos >= in_size)
  ------------------
  |  Branch (30:7): [True: 0, False: 0]
  ------------------
   31|      0|			return LZMA_DATA_ERROR;
   32|       |
   33|  29.0M|	} else {
   34|       |		// Initialize *vli when starting to decode a new integer.
   35|  29.0M|		if (*vli_pos == 0)
  ------------------
  |  Branch (35:7): [True: 29.0M, False: 1.44k]
  ------------------
   36|  29.0M|			*vli = 0;
   37|       |
   38|       |		// Validate the arguments.
   39|  29.0M|		if (*vli_pos >= LZMA_VLI_BYTES_MAX
  ------------------
  |  |   42|  58.1M|#define LZMA_VLI_BYTES_MAX 9
  ------------------
  |  Branch (39:7): [True: 0, False: 29.0M]
  ------------------
   40|  29.0M|				|| (*vli >> (*vli_pos * 7)) != 0)
  ------------------
  |  Branch (40:8): [True: 0, False: 29.0M]
  ------------------
   41|      0|			return LZMA_PROG_ERROR;
   42|       |
   43|  29.0M|		if (*in_pos >= in_size)
  ------------------
  |  Branch (43:7): [True: 0, False: 29.0M]
  ------------------
   44|      0|			return LZMA_BUF_ERROR;
   45|  29.0M|	}
   46|       |
   47|  33.4M|	do {
   48|       |		// Read the next byte. Use a temporary variable so that we
   49|       |		// can update *in_pos immediately.
   50|  33.4M|		const uint8_t byte = in[*in_pos];
   51|  33.4M|		++*in_pos;
   52|       |
   53|       |		// Add the newly read byte to *vli.
   54|  33.4M|		*vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7);
   55|  33.4M|		++*vli_pos;
   56|       |
   57|       |		// Check if this is the last byte of a multibyte integer.
   58|  33.4M|		if ((byte & 0x80) == 0) {
  ------------------
  |  Branch (58:7): [True: 29.0M, False: 4.36M]
  ------------------
   59|       |			// We don't allow using variable-length integers as
   60|       |			// padding i.e. the encoding must use the most the
   61|       |			// compact form.
   62|  29.0M|			if (byte == 0x00 && *vli_pos > 1)
  ------------------
  |  Branch (62:8): [True: 2.14k, False: 29.0M]
  |  Branch (62:24): [True: 738, False: 1.40k]
  ------------------
   63|    738|				return LZMA_DATA_ERROR;
   64|       |
   65|  29.0M|			return vli_pos == &vli_pos_internal
  ------------------
  |  Branch (65:11): [True: 0, False: 29.0M]
  ------------------
   66|  29.0M|					? LZMA_OK : LZMA_STREAM_END;
   67|  29.0M|		}
   68|       |
   69|       |		// There is at least one more byte coming. If we have already
   70|       |		// read maximum number of bytes, the integer is considered
   71|       |		// corrupt.
   72|       |		//
   73|       |		// If we need bigger integers in future, old versions liblzma
   74|       |		// will confusingly indicate the file being corrupt instead of
   75|       |		// unsupported. I suppose it's still better this way, because
   76|       |		// in the foreseeable future (writing this in 2008) the only
   77|       |		// reason why files would appear having over 63-bit integers
   78|       |		// is that the files are simply corrupt.
   79|  4.36M|		if (*vli_pos == LZMA_VLI_BYTES_MAX)
  ------------------
  |  |   42|  4.36M|#define LZMA_VLI_BYTES_MAX 9
  ------------------
  |  Branch (79:7): [True: 24, False: 4.36M]
  ------------------
   80|     24|			return LZMA_DATA_ERROR;
   81|       |
   82|  4.36M|	} while (*in_pos < in_size);
  ------------------
  |  Branch (82:11): [True: 4.36M, False: 1.54k]
  ------------------
   83|       |
   84|  1.54k|	return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK;
  ------------------
  |  Branch (84:9): [True: 0, False: 1.54k]
  ------------------
   85|  29.0M|}

lzma_vli_size:
   17|  58.1M|{
   18|  58.1M|	if (vli > LZMA_VLI_MAX)
  ------------------
  |  |   32|  58.1M|#define LZMA_VLI_MAX (UINT64_MAX / 2)
  ------------------
  |  Branch (18:6): [True: 0, False: 58.1M]
  ------------------
   19|      0|		return 0;
   20|       |
   21|  58.1M|	uint32_t i = 0;
   22|   115M|	do {
   23|   115M|		vli >>= 7;
   24|   115M|		++i;
   25|   115M|	} while (vli != 0);
  ------------------
  |  Branch (25:11): [True: 57.8M, False: 58.1M]
  ------------------
   26|       |
   27|  58.1M|	assert(i <= LZMA_VLI_BYTES_MAX);
  ------------------
  |  Branch (27:2): [True: 0, False: 58.1M]
  |  Branch (27:2): [True: 58.1M, False: 0]
  ------------------
   28|  58.1M|	return i;
   29|  58.1M|}

fuzz_decode_index.c:prepare_stream:
   46|  1.26k|{
   47|  1.26k|	stream->next_in = inbuf;
   48|  1.26k|	stream->avail_in = inbuf_size;
   49|       |
   50|       |	// Unless the input is very tiny, make one allocation in 1024 fail
   51|       |	// based on the last two input bytes and inbuf_size.
   52|  1.26k|	if (inbuf_size >= 10) {
  ------------------
  |  Branch (52:6): [True: 813, False: 449]
  ------------------
   53|    813|		alloc_fail = inbuf[inbuf_size - 2]
   54|    813|				^ ((inbuf[inbuf_size - 1]) << 2)
   55|    813|				^ (inbuf_size & 0x3FF);
   56|       |
   57|    813|		static const lzma_allocator my_allocator
   58|    813|				= { &my_alloc, NULL, NULL };
   59|    813|		stream->allocator = &my_allocator;
   60|    813|	}
   61|  1.26k|}
fuzz_decode_index.c:my_alloc:
   33|  6.96k|{
   34|  6.96k|	(void)opaque;
   35|  6.96k|	(void)nmemb;
   36|       |
   37|  6.96k|	if (--alloc_fail == 0)
  ------------------
  |  Branch (37:6): [True: 28, False: 6.93k]
  ------------------
   38|     28|		return NULL;
   39|       |
   40|  6.93k|	return malloc(size);
   41|  6.96k|}
fuzz_decode_index.c:fuzz_code:
   66|  3.76k|{
   67|       |	// Output buffer for decompressed data. This is write only; nothing
   68|       |	// cares about the actual data written here.
   69|  3.76k|	uint8_t outbuf[4096];
   70|       |
   71|       |	// Pass half of the input on the first call and then proceed in
   72|       |	// chunks. It's fine that this rounds to 0 when inbuf_size is 1.
   73|  3.76k|	stream->next_in = inbuf;
   74|  3.76k|	stream->avail_in = inbuf_size / 2;
   75|       |
   76|  3.76k|	stream->next_out = NULL;
   77|  3.76k|	stream->avail_out = 0;
   78|       |
   79|  3.76k|	lzma_action action = LZMA_RUN;
   80|       |
   81|  3.76k|	lzma_ret ret;
   82|  12.6k|	do {
   83|  12.6k|		if (stream->avail_in == 0 && inbuf_size > 0) {
  ------------------
  |  Branch (83:7): [True: 9.72k, False: 2.91k]
  |  Branch (83:32): [True: 7.97k, False: 1.74k]
  ------------------
   84|  7.97k|			const size_t chunk_size = inbuf_size < IN_CHUNK_SIZE
  ------------------
  |  |   25|  7.97k|#define IN_CHUNK_SIZE 2047
  ------------------
  |  Branch (84:30): [True: 1.42k, False: 6.55k]
  ------------------
   85|  7.97k|					? inbuf_size : IN_CHUNK_SIZE;
  ------------------
  |  |   25|  6.55k|#define IN_CHUNK_SIZE 2047
  ------------------
   86|       |
   87|  7.97k|			stream->next_in = inbuf;
   88|  7.97k|			stream->avail_in = chunk_size;
   89|       |
   90|  7.97k|			inbuf += chunk_size;
   91|  7.97k|			inbuf_size -= chunk_size;
   92|       |
   93|  7.97k|			if (inbuf_size == 0)
  ------------------
  |  Branch (93:8): [True: 1.43k, False: 6.54k]
  ------------------
   94|  1.43k|				action = LZMA_FINISH;
   95|  7.97k|		}
   96|       |
   97|  12.6k|		if (stream->avail_out == 0) {
  ------------------
  |  Branch (97:7): [True: 3.76k, False: 8.88k]
  ------------------
   98|       |			// outbuf became full. We don't care about the
   99|       |			// uncompressed data there, so we simply reuse
  100|       |			// the outbuf and overwrite the old data.
  101|  3.76k|			stream->next_out = outbuf;
  102|  3.76k|			stream->avail_out = sizeof(outbuf);
  103|  3.76k|		}
  104|  12.6k|	} while ((ret = lzma_code(stream, action)) == LZMA_OK);
  ------------------
  |  Branch (104:11): [True: 8.88k, False: 3.76k]
  ------------------
  105|       |
  106|       |	// LZMA_PROG_ERROR should never happen as long as the code calling
  107|       |	// the liblzma functions is correct. Thus LZMA_PROG_ERROR is a sign
  108|       |	// of a bug in either this function or in liblzma.
  109|  3.76k|	if (ret == LZMA_PROG_ERROR) {
  ------------------
  |  Branch (109:6): [True: 0, False: 3.76k]
  ------------------
  110|       |		fprintf(stderr, "lzma_code() returned LZMA_PROG_ERROR\n");
  111|      0|		abort();
  112|      0|	}
  113|  3.76k|}

LLVMFuzzerTestOneInput:
   21|  1.26k|{
   22|  1.26k|	lzma_stream strm = LZMA_STREAM_INIT;
  ------------------
  |  |  611|  1.26k|	{ NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
  |  |  612|  1.26k|	NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
  |  |  613|  1.26k|	LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
  ------------------
   23|  1.26k|	prepare_stream(&strm, inbuf, inbuf_size);
   24|       |
   25|  1.26k|	lzma_ret ret;
   26|       |
   27|  5.04k|	for (int i = 0; i < 3; ++i) {
  ------------------
  |  Branch (27:18): [True: 3.78k, False: 1.26k]
  ------------------
   28|       |		// The initial pointer value must be ignored.
   29|  3.78k|		lzma_index *idx = (void *)1;
   30|  3.78k|		ret = lzma_index_decoder(&strm, &idx, MEM_LIMIT);
  ------------------
  |  |   22|  3.78k|#define MEM_LIMIT (300 << 20) // 300 MiB
  ------------------
   31|       |
   32|  3.78k|		if (ret == LZMA_MEM_ERROR)
  ------------------
  |  Branch (32:7): [True: 24, False: 3.76k]
  ------------------
   33|     24|			continue;
   34|       |
   35|  3.76k|		if (ret != LZMA_OK) {
  ------------------
  |  Branch (35:7): [True: 0, False: 3.76k]
  ------------------
   36|       |			// This should never happen unless the system has
   37|       |			// no free memory or address space to allow the small
   38|       |			// allocations that the initialization requires.
   39|      0|			fprintf(stderr, "lzma_index_decoder() failed (%d)\n",
   40|      0|					ret);
   41|      0|			abort();
   42|      0|		}
   43|       |
   44|  3.76k|		fuzz_code(&strm, strm.next_in, strm.avail_in);
   45|  3.76k|		lzma_index_end(idx, NULL);
   46|  3.76k|	}
   47|       |
   48|  1.26k|	{
   49|       |		// Fuzz the single-call API too.
   50|  1.26k|		lzma_index *idx = (void *)1;
   51|  1.26k|		uint64_t memlimit = MEM_LIMIT;
  ------------------
  |  |   22|  1.26k|#define MEM_LIMIT (300 << 20) // 300 MiB
  ------------------
   52|  1.26k|		size_t inbuf_pos = 0;
   53|  1.26k|		if (lzma_index_buffer_decode(&idx, &memlimit, NULL,
  ------------------
  |  Branch (53:7): [True: 0, False: 1.26k]
  ------------------
   54|  1.26k|				inbuf, &inbuf_pos, inbuf_size)
   55|  1.26k|				== LZMA_PROG_ERROR) {
   56|      0|			fprintf(stderr, "lzma_index_buffer_decode() failed "
   57|      0|					"with LZMA_PROG_ERROR\n");
   58|      0|			abort();
   59|      0|		}
   60|       |
   61|  1.26k|		lzma_index_end(idx, NULL);
   62|  1.26k|	}
   63|       |
   64|      0|	lzma_end(&strm);
   65|  1.26k|	return 0;
   66|  1.26k|}

