fn generateLen(smith: *Smith, will_memset: bool) usize {
@disableInstrumentation();
// 1 << 24 indicates to generate an unweighted usize.
// 1 << 25 indicates to provide a value relative to the maximum usize.
const len = smith.valueWeightedWithHash(
u32,
if (!will_memset) comptime &.{
// zig fmt: off
.rangeLessThan(u32, 1 , 1 << 6 , 1 << 15), // 2^21 - 2^4 times below so 16x odds
.rangeLessThan(u32, 1 << 6, 1 << 17, 1 ), // 2^17 - 2^4 times below so 16x odds
.value (u32, 1 << 24, 1 << 12), // 2^12
.value (u32, 1 << 25, 1 << 12), // 2^12
// zig fmt: on
} else comptime &.{
// zig fmt: off
.rangeLessThan(u32, 1 , 1 << 6, 1 << 17), // 2^23 - 2^6 times below so 64x odds
.rangeLessThan(u32, 1 << 6, 1 << 17, 1 ), // 2^17 - 2^6 times below so 64x odds
.value (u32, 1 << 24, 1 << 10), // 2^10
.value (u32, 1 << 25, 1 << 10), // 2^10
// zig fmt: on
},
// Give the fuzzer different hashes when the weights used differ
// so that it does not reuse values from other probabilities.
if (!will_memset) 0x38a74424 else 0xec581ff0,
);
if (len == 1 << 24) return @max(1, smith.value(usize));
if (len == 1 << 25) return @as(usize, math.maxInt(usize)) - smith.value(u16);
return len;
}