They don't work for me (on Debian bullseye). For example, from the
example/sdl-imageviewer directory:
$ make
g++ -lSDL2 -lSDL2_image sdl-imageviewer.cc -o sdl-imageviewer
/usr/bin/ld: /tmp/cciX1mj2.o: in function `draw(SDL_Window*)':
sdl-imageviewer.cc:(.text+0x36e44): undefined reference to `SDL_GetWindowSurface'
/usr/bin/ld: sdl-imageviewer.cc:(.text+0x36e69): undefined reference to `SDL_CreateRenderer'
/usr/bin/ld: sdl-imageviewer.cc:(.text+0x36e79): undefined reference to `SDL_RenderClear'
etc
collect2: error: ld returned 1 exit status
make: *** [<builtin>: sdl-imageviewer] Error 1
Swapping the g++ args around to
g++ sdl-imageviewer.cc -lSDL2 -lSDL2_image -o sdl-imageviewer
works, but the recommended approach is to use the existing top-level
build-example.sh script instead.
"// ---------------- Fundamentals\n\n// WUFFS_BASE__MAGIC is a magic number to check that initializers are called.\n// It's not foolproof, given C doesn't automatically zero memory before use,\n// but it should catch 99.99% of cases.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"wuffs\").\n#define WUFFS_BASE__MAGIC ((uint32_t)0x3CCB6C71)\n\n// WUFFS_BASE__DISABLED is a magic number to indicate that a non-recoverable\n// error was previously encountered.\n//\n// Its (non-zero) value is arbitrary, based on md5sum(\"disabled\").\n#define WUFFS_BASE__DISABLED ((uint32_t)0x075AE3D2)\n\n// Use switch cases for coroutine suspension points, similar to the technique\n// in https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html\n//\n// The implicit fallthrough is intentional.\n//\n// We use trivial macros instead of an explicit assignment and case statement\n// so that clang-format doesn't get confused by the unusual \"case\"s.\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0 case 0:;\n#define WUFFS_BASE__COROUTINE_SUSPENSION_"+
"// --------\n\n// wuffs_base__iterate_total_advance returns the exclusive pointer-offset at\n// which iteration should stop. The overall slice has length total_len, each\n// iteration's sub-slice has length iter_len and are placed iter_advance apart.\n//\n// The iter_advance may not be larger than iter_len. The iter_advance may be\n// smaller than iter_len, in which case the sub-slices will overlap.\n//\n// The return value r satisfies ((0 <= r) && (r <= total_len)).\n//\n// For example, if total_len = 15, iter_len = 5 and iter_advance = 3, there are\n// four iterations at offsets 0, 3, 6 and 9. This function returns 12.\n//\n// 0123456789012345\n// [....]\n// [....]\n// [....]\n// [....]\n// $\n// 0123456789012345\n//\n// For example, if total_len = 15, iter_len = 5 and iter_advance = 5, there are\n// three iterations at offsets 0, 5 and 10. This function returns 15.\n//\n// 0123456789012345\n// [....]\n// [....]\n// [....]\n// $\n// 0123456789012345\nstatic inline size_t //\nwuf"+
"// ---------------- Slices and Tables\n\n// wuffs_base__slice_u8__prefix returns up to the first up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__prefix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if (((uint64_t)(s.len)) > up_to) {\n s.len = ((size_t)up_to);\n }\n return s;\n}\n\n// wuffs_base__slice_u8__suffix returns up to the last up_to bytes of s.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__suffix(wuffs_base__slice_u8 s, uint64_t up_to) {\n if (((uint64_t)(s.len)) > up_to) {\n s.ptr += ((uint64_t)(s.len)) - up_to;\n s.len = ((size_t)up_to);\n }\n return s;\n}\n\n// wuffs_base__slice_u8__copy_from_slice calls memmove(dst.ptr, src.ptr, len)\n// where len is the minimum of dst.len and src.len.\n//\n// Passing a wuffs_base__slice_u8 with all fields NULL or zero (a valid, empty\n// slice) is valid and results in a no-op.\nstatic inline uint64_t //\nwuffs_base__slice_u8__copy_from_slice(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 s"+
"// ---------------- Slices and Tables (Utility)\n\n#define wuffs_base__utility__empty_slice_u8 wuffs_base__empty_slice_u8\n"+
""
constBaseFundamentalPublicH=""+
"// ---------------- Version\n\n// WUFFS_VERSION is the major.minor.patch version, as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The pre-release label\n// and build metadata are part of the string representation (such as\n// \"1.2.3-beta+456.20181231\") but not the uint64_t representation.\n//\n// WUFFS_VERSION_PRE_RELEASE_LABEL (such as \"\", \"beta\" or \"rc.1\") being\n// non-empty denotes a developer preview, not a release version, and has no\n// backwards or forwards compatibility guarantees.\n//\n// WUFFS_VERSION_BUILD_METADATA_XXX, if non-zero, are the number of commits and\n// the last commit date in the repository used to build this library. Within\n// each major.minor branch, the commit count should increase monotonically.\n//\n// ¡ Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION 0\n#define WUFFS_VERSION_MAJOR 0\n#define WUFFS_VERSION_MINOR 0\n#define WUFFS_VERSION_PATCH 0\n#de"+
"// ---------------- Configuration\n\n// Define WUFFS_CONFIG__AVOID_CPU_ARCH to avoid any code tied to a specific CPU\n// architecture, such as SSE SIMD for the x86 CPU family.\n#if defined(WUFFS_CONFIG__AVOID_CPU_ARCH) // (#if-chain ref AVOID_CPU_ARCH_0)\n// No-op.\n#else // (#if-chain ref AVOID_CPU_ARCH_0)\n\n// The \"defined(__clang__)\" isn't redundant. While vanilla clang defines\n// __GNUC__, clang-cl (which mimics MSVC's cl.exe) does not.\n#if defined(__GNUC__) || defined(__clang__)\n#define WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(arg) __attribute__((target(arg)))\n#else\n#define WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET(arg)\n#endif // defined(__GNUC__) || defined(__clang__)\n\n#if defined(__GNUC__) // (#if-chain ref AVOID_CPU_ARCH_1)\n\n// To simplify Wuffs code, \"cpu_arch >= arm_xxx\" requires xxx but also\n// unaligned little-endian load/stores.\n#if defined(__ARM_FEATURE_UNALIGNED) && !defined(__native_client__) && \\\n defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)\n// Not all gcc versions define __ARM_A"+
"CLE, even if they support crc32\n// intrinsics. Look for __ARM_FEATURE_CRC32 instead.\n#if defined(__ARM_FEATURE_CRC32)\n#include <arm_acle.h>\n#define WUFFS_BASE__CPU_ARCH__ARM_CRC32\n#endif // defined(__ARM_FEATURE_CRC32)\n#if defined(__ARM_NEON)\n#include <arm_neon.h>\n#define WUFFS_BASE__CPU_ARCH__ARM_NEON\n#endif // defined(__ARM_NEON)\n#endif // defined(__ARM_FEATURE_UNALIGNED) etc\n\n// Similarly, \"cpu_arch >= x86_sse42\" requires SSE4.2 but also PCLMUL and\n// POPCNT. This is checked at runtime via cpuid, not at compile time.\n//\n// Likewise, \"cpu_arch >= x86_avx2\" also requires PCLMUL, POPCNT and SSE4.2.\n#if defined(__x86_64__) && !defined(__native_client__)\n#include <cpuid.h>\n#include <x86intrin.h>\n#define WUFFS_BASE__CPU_ARCH__X86_64\n#endif // defined(__x86_64__) && !defined(__native_client__)\n\n#elif defined(_MSC_VER) // (#if-chain ref AVOID_CPU_ARCH_1)\n\n#if defined(_M_X64)\n#if defined(__AVX__) || defined(__clang__)\n\n// We need <intrin.h> for the __cpuid function.\n#include <intrin.h>\n// That's not enough for"+
" X64 SIMD, with clang-cl, if we want to use\n// \"__attribute__((target(arg)))\" without e.g. \"/arch:AVX\".\n//\n// Some web pages suggest that <immintrin.h> is all you need, as it pulls in\n// the earlier SIMD families like SSE4.2, but that doesn't seem to work in\n// practice, possibly for the same reason that just <intrin.h> doesn't work.\n#include <immintrin.h> // AVX, AVX2, FMA, POPCNT\n#include <nmmintrin.h> // SSE4.2\n#include <wmmintrin.h> // AES, PCLMUL\n#define WUFFS_BASE__CPU_ARCH__X86_64\n\n#else // defined(__AVX__) || defined(__clang__)\n\n// clang-cl (which defines both __clang__ and _MSC_VER) supports\n// \"__attribute__((target(arg)))\".\n//\n// For MSVC's cl.exe (unlike clang or gcc), SIMD capability is a compile-time\n// property of the source file (e.g. a /arch:AVX or -mavx compiler flag), not\n// of individual functions (that can be conditionally selected at runtime).\n#pragma message(\"Wuffs with MSVC+X64 needs /arch:AVX for best performance\")\n\n#endif // defined(__AVX__) || defined(__clang__)\n#endif // defi"+
"// --------\n\n// Define WUFFS_CONFIG__STATIC_FUNCTIONS to make all of Wuffs' functions have\n// static storage. The motivation is discussed in the \"ALLOW STATIC\n// IMPLEMENTATION\" section of\n// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt\n#if defined(WUFFS_CONFIG__STATIC_FUNCTIONS)\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif // defined(WUFFS_CONFIG__STATIC_FUNCTIONS)\n\n"+
""+
"// ---------------- CPU Architecture\n\nstatic inline bool //\nwuffs_base__cpu_arch__have_arm_crc32() {\n#if defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)\n return true;\n#else\n return false;\n#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)\n}\n\nstatic inline bool //\nwuffs_base__cpu_arch__have_arm_neon() {\n#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)\n return true;\n#else\n return false;\n#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)\n}\n\nstatic inline bool //\nwuffs_base__cpu_arch__have_x86_avx2() {\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n // GCC defines these macros but MSVC does not.\n // - bit_AVX2 = (1 << 5)\n const unsigned int avx2_ebx7 = 0x00000020;\n // GCC defines these macros but MSVC does not.\n // - bit_PCLMUL = (1 << 1)\n // - bit_POPCNT = (1 << 23)\n // - bit_SSE4_2 = (1 << 20)\n const unsigned int avx2_ecx1 = 0x00900002;\n\n // clang defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).\n#if defined(__GNUC__)\n unsigned int eax7 = 0;\n unsigned int ebx7 = 0;\n unsigned int ecx7 ="+
" 0;\n unsigned int edx7 = 0;\n if (__get_cpuid_count(7, 0, &eax7, &ebx7, &ecx7, &edx7) &&\n ((ebx7 & avx2_ebx7) == avx2_ebx7)) {\n unsigned int eax1 = 0;\n unsigned int ebx1 = 0;\n unsigned int ecx1 = 0;\n unsigned int edx1 = 0;\n if (__get_cpuid(1, &eax1, &ebx1, &ecx1, &edx1) &&\n ((ecx1 & avx2_ecx1) == avx2_ecx1)) {\n return true;\n }\n }\n#elif defined(_MSC_VER) // defined(__GNUC__)\n int x7[4];\n __cpuidex(x7, 7, 0);\n if ((((unsigned int)(x7[1])) & avx2_ebx7) == avx2_ebx7) {\n int x1[4];\n __cpuid(x1, 1);\n if ((((unsigned int)(x1[2])) & avx2_ecx1) == avx2_ecx1) {\n return true;\n }\n }\n#else\n#error \"WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler\"\n#endif // defined(__GNUC__); defined(_MSC_VER)\n#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)\n return false;\n}\n\nstatic inline bool //\nwuffs_base__cpu_arch__have_x86_bmi2() {\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n // GCC defines these macros but MSVC does not.\n // - bit_BMI2 = (1 << 8)\n const u"+
"nsigned int bmi2_ebx7 = 0x00000100;\n\n // clang defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).\n#if defined(__GNUC__)\n unsigned int eax7 = 0;\n unsigned int ebx7 = 0;\n unsigned int ecx7 = 0;\n unsigned int edx7 = 0;\n if (__get_cpuid_count(7, 0, &eax7, &ebx7, &ecx7, &edx7) &&\n ((ebx7 & bmi2_ebx7) == bmi2_ebx7)) {\n return true;\n }\n#elif defined(_MSC_VER) // defined(__GNUC__)\n int x7[4];\n __cpuidex(x7, 7, 0);\n if ((((unsigned int)(x7[1])) & bmi2_ebx7) == bmi2_ebx7) {\n return true;\n }\n#else\n#error \"WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler\"\n#endif // defined(__GNUC__); defined(_MSC_VER)\n#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)\n return false;\n}\n\nstatic inline bool //\nwuffs_base__cpu_arch__have_x86_sse42() {\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n // GCC defines these macros but MSVC does not.\n // - bit_PCLMUL = (1 << 1)\n // - bit_POPCNT = (1 << 23)\n // - bit_SSE4_2 = (1 << 20)\n const unsigned int sse42_ecx1 = 0x00900002;\n\n // clan"+
"g defines __GNUC__ and clang-cl defines _MSC_VER (but not __GNUC__).\n#if defined(__GNUC__)\n unsigned int eax1 = 0;\n unsigned int ebx1 = 0;\n unsigned int ecx1 = 0;\n unsigned int edx1 = 0;\n if (__get_cpuid(1, &eax1, &ebx1, &ecx1, &edx1) &&\n ((ecx1 & sse42_ecx1) == sse42_ecx1)) {\n return true;\n }\n#elif defined(_MSC_VER) // defined(__GNUC__)\n int x1[4];\n __cpuid(x1, 1);\n if ((((unsigned int)(x1[2])) & sse42_ecx1) == sse42_ecx1) {\n return true;\n }\n#else\n#error \"WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler\"\n#endif // defined(__GNUC__); defined(_MSC_VER)\n#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)\n return false;\n}\n\n"+
""+
"// ---------------- Fundamentals\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if defined(__WORDSIZE)\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n#endif\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__POTENTIALLY_UNUSED __attribute__((unused))\n#define WUFFS_BASE__WARN_UNUSED_RESULT __attribute__((warn_unused_result))\n#else\n#define WUFFS_BASE__POTENTIALLY_UNUSED\n#define WUFFS_BASE__WARN_UNUSED_RESULT\n#endif\n\n"+
""+
"// --------\n\n// Options (bitwise or'ed together) for wuffs_foo__bar__initialize functions.\n\n#define WUFFS_INITIALIZE__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// WUFFS_INITIALIZE__ALREADY_ZEROED means that the \"self\" receiver struct value\n// has already been set to all zeroes.\n#define WUFFS_INITIALIZE__ALREADY_ZEROED ((uint32_t)0x00000001)\n\n// WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED means that, absent\n// WUFFS_INITIALIZE__ALREADY_ZEROED, only some of the \"self\" receiver struct\n// value will be set to all zeroes. Internal buffers, which tend to be a large\n// proportion of the struct's size, will be left uninitialized. Internal means\n// that the buffer is contained by the receiver struct, as opposed to being\n// passed as a separately allocated \"work buffer\".\n//\n// For more detail, see:\n// https://github.com/google/wuffs/blob/main/doc/note/initialization.md\n#define WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED \\\n ((uint32_t)0x00000002)\n\n"+
""+
"// --------\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g()\".\ntypedef struct wuffs_base__empty_struct__struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__empty_struct;\n\nstatic inline wuffs_base__empty_struct //\nwuffs_base__make_empty_struct() {\n wuffs_base__empty_struct ret;\n ret.private_impl = 0;\n return "+
"ret;\n}\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct wuffs_base__utility__struct {\n // private_impl is a placeholder field. It isn't explicitly used, except that\n // without it, the sizeof a struct with no fields can differ across C/C++\n // compilers, and it is undefined behavior in C99. For example, gcc says that\n // the sizeof an empty struct is 0, and g++ says that it is 1. This leads to\n // ABI incompatibility if a Wuffs .c file is processed by one compiler and\n // its .h file with another compiler.\n //\n // Instead, we explicitly insert an otherwise unused field, so that the\n // sizeof this struct is always 1.\n uint8_t private_impl;\n} wuffs_base__utility;\n\ntypedef struct wuffs_base__vtable__struct {\n const char* vtable_name;\n const void* function_pointers;\n} wuffs_base__vtable;\n\n"+
"// --------\n\n// WUFFS_BASE__RESULT is a result type: either a status (an error) or a value.\n//\n// A result with all fields NULL or zero is as valid as a zero-valued T.\n#define WUFFS_BASE__RESULT(T) \\\n struct { \\\n wuffs_base__status status; \\\n T value; \\\n }\n\ntypedef WUFFS_BASE__RESULT(double) wuffs_base__result_f64;\ntypedef WUFFS_BASE__RESULT(int64_t) wuffs_base__result_i64;\ntypedef WUFFS_BASE__RESULT(uint64_t) wuffs_base__result_u64;\n\n"+
""+
"// --------\n\n// wuffs_base__transform__output is the result of transforming from a src slice\n// to a dst slice.\ntypedef struct wuffs_base__transform__output__struct {\n wuffs_base__status status;\n size_t num_dst;\n size_t num_src;\n} wuffs_base__transform__output;\n\n"+
"// --------\n\n// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a\n// second. See https://github.com/OculusVR/Flicks\ntypedef int64_t wuffs_base__flicks;\n\n#define WUFFS_BASE__FLICKS_PER_SECOND ((uint64_t)705600000)\n#define WUFFS_BASE__FLICKS_PER_MILLISECOND ((uint64_t)705600)\n\n"+
""+
"// ---------------- Numeric Types\n\n// The helpers below are functions, instead of macros, because their arguments\n// can be an expression that we shouldn't evaluate more than once.\n//\n// They are static, so that linking multiple wuffs .o files won't complain about\n// duplicate function definitions.\n//\n// They are explicitly marked inline, even if modern compilers don't use the\n// inline attribute to guide optimizations such as inlining, to avoid the\n// -Wunused-function warning, and we like to compile with -Wall -Werror.\n\nstatic inline int8_t //\nwuffs_base__i8__min(int8_t x, int8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline int8_t //\nwuffs_base__i8__max(int8_t x, int8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline int16_t //\nwuffs_base__i16__min(int16_t x, int16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline int16_t //\nwuffs_base__i16__max(int16_t x, int16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline int32_t //\nwuffs_base__i32__min(int32_t x, int32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline "+
"int32_t //\nwuffs_base__i32__max(int32_t x, int32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline int64_t //\nwuffs_base__i64__min(int64_t x, int64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline int64_t //\nwuffs_base__i64__max(int64_t x, int64_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint8_t //\nwuffs_base__u8__min(uint8_t x, uint8_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint8_t //\nwuffs_base__u8__max(uint8_t x, uint8_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__min(uint16_t x, uint16_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__max(uint16_t x, uint16_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__min(uint32_t x, uint32_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__max(uint32_t x, uint32_t y) {\n return x > y ? x : y;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__min(uint64_t x, uint64_t y) {\n return x < y ? x : y;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__m"+
"ax(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\n\n"+
"// ---------------- Slices and Tables\n\n// WUFFS_BASE__SLICE is a 1-dimensional buffer.\n//\n// len measures a number of elements, not necessarily a size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty slice.\n#define WUFFS_BASE__SLICE(T) \\\n struct { \\\n T* ptr; \\\n size_t len; \\\n }\n\n// WUFFS_BASE__TABLE is a 2-dimensional buffer.\n//\n// width, height and stride measure a number of elements, not necessarily a\n// size in bytes.\n//\n// A value with all fields NULL or zero is a valid, empty table.\n#define WUFFS_BASE__TABLE(T) \\\n struct { \\\n T* ptr; \\\n size_t width; \\\n size_t height; \\\n size_t stride; \\\n }\n\ntypedef WUFFS_BASE__SLICE(uint8_t) wuffs_base__slice_u8;\ntypedef WUFFS_BASE__SLICE(uint16_t) wuffs_base__slice_u16;\ntypedef WUFFS_BASE__SLICE(uint32_t) wuffs_base__slice_u32;\ntypedef WUFFS_BASE__SLICE(uint64_t) wuffs_base__slice_u64;\n\ntypedef WUFFS_BASE__TABLE(u"+
" return wuffs_base__make_slice_u8(s.ptr + i, ((size_t)(s.len - i)));\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n// wuffs_base__slice_u8__subslice_j returns s[:j].\n//\n// It returns an empty slice if j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_j(wuffs_base__slice_u8 s, uint64_t j) {\n if ((j <= SIZE_MAX) && (j <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr, ((size_t)j));\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n// wuffs_base__slice_u8__subslice_ij returns s[i:j].\n//\n// It returns an empty slice if i or j is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_ij(wuffs_base__slice_u8 s,\n uint64_t i,\n uint64_t j) {\n if ((i <= j) && (j <= SIZE_MAX) && (j <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr + i, ((size_t)(j - i)));\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n// wuffs_base__table__flattened_length returns the number o"+
"f elements covered\n// by the 1-dimensional span that backs a 2-dimensional table. This counts the\n// elements inside the table and, when width != stride, the elements outside\n// the table but between its rows.\n//\n// For example, consider a width 10, height 4, stride 10 table. Mark its first\n// and last (inclusive) elements with 'a' and 'z'. This function returns 40.\n//\n// a123456789\n// 0123456789\n// 0123456789\n// 012345678z\n//\n// Now consider the sub-table of that from (2, 1) inclusive to (8, 4) exclusive.\n//\n// a123456789\n// 01iiiiiioo\n// ooiiiiiioo\n// ooiiiiii8z\n//\n// This function (called with width 6, height 3, stride 10) returns 26: 18 'i'\n// inside elements plus 8 'o' outside elements. Note that 26 is less than a\n// naive (height * stride = 30) computation. Indeed, advancing 29 elements from\n// the first 'i' would venture past 'z', out of bounds of the original table.\n//\n// It does not check for overflow, but if the arguments come from a table that\n// exists in memory and each el"+
"ement occupies a positive number of bytes then\n// the result should be bounded by the amount of allocatable memory (which\n// shouldn't overflow SIZE_MAX).\nstatic inline size_t //\nwuffs_base__table__flattened_length(size_t width,\n size_t height,\n size_t stride) {\n if (height == 0) {\n return 0;\n }\n return ((height - 1) * stride) + width;\n}\n\n"+
""+
"// ---------------- Magic Numbers\n\n// wuffs_base__magic_number_guess_fourcc guesses the file format of some data,\n// given its opening bytes. It returns a positive FourCC value on success.\n//\n// It returns zero if nothing matches its hard-coded list of 'magic numbers'.\n//\n// It returns a negative value if a longer prefix is required for a conclusive\n// result. For example, seeing a single 'B' byte is not enough to discriminate\n// the BMP and BPG image file formats.\n//\n// It does not do a full validity check. Like any guess made from a short\n// prefix of the data, it may return false positives. Data that starts with 99\n// bytes of valid JPEG followed by corruption or truncation is an invalid JPEG\n// image overall, but this function will still return WUFFS_BASE__FOURCC__JPEG.\n//\n// Another source of false positives is that some 'magic numbers' are valid\n// ASCII data. A file starting with \"GIF87a and GIF89a are the two versions of\n// GIF\" will match GIF's 'magic number' even if it's plain text, not an image.\n//"+
"\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__MAGIC sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC int32_t //\nwuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix);\n"+
""
constBaseMemoryPrivateH=""+
"// ---------------- Memory Allocation\n"+
""
constBaseMemoryPublicH=""+
"// ---------------- Memory Allocation\n\n// The memory allocation related functions in this section aren't used by Wuffs\n// per se, but they may be helpful to the code that uses Wuffs.\n\n// wuffs_base__malloc_slice_uxx wraps calling a malloc-like function, except\n// that it takes a uint64_t number of elements instead of a size_t size in\n// bytes, and it returns a slice (a pointer and a length) instead of just a\n// pointer.\n//\n// You can pass the C stdlib's malloc as the malloc_func.\n//\n// It returns an empty slice (containing a NULL ptr field) if (num_uxx *\n// sizeof(uintxx_t)) would overflow SIZE_MAX.\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__malloc_slice_u8(void* (*malloc_func)(size_t), uint64_t num_u8) {\n if (malloc_func && (num_u8 <= (SIZE_MAX / sizeof(uint8_t)))) {\n void* p = (*malloc_func)((size_t)(num_u8 * sizeof(uint8_t)));\n if (p) {\n return wuffs_base__make_slice_u8((uint8_t*)(p), (size_t)num_u8);\n }\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__s"+
"// ---------------- Images\n\n// wuffs_base__color_u32_argb_premul is an 8 bit per channel premultiplied\n// Alpha, Red, Green, Blue color, as a uint32_t value. Its value is always\n// 0xAARRGGBB (Alpha most significant, Blue least), regardless of endianness.\ntypedef uint32_t wuffs_base__color_u32_argb_premul;\n\n// wuffs_base__color_u32_argb_premul__is_valid returns whether c's Red, Green\n// and Blue channels are all less than or equal to its Alpha channel. c uses\n// premultiplied alpha, so 50% opaque 100% saturated red is 0x7F7F_0000 and a\n// value like 0x7F80_0000 is invalid.\nstatic inline bool //\nwuffs_base__color_u32_argb_premul__is_valid(\n wuffs_base__color_u32_argb_premul c) {\n uint32_t a = 0xFF & (c >> 24);\n uint32_t r = 0xFF & (c >> 16);\n uint32_t g = 0xFF & (c >> 8);\n uint32_t b = 0xFF & (c >> 0);\n return (a >= r) && (a >= g) && (a >= b);\n}\n\nstatic inline uint16_t //\nwuffs_base__color_u32_argb_premul__as__color_u16_rgb_565(\n wuffs_base__color_u32_argb_premul c) {\n uint32_t r5 = 0xF800 & (c >"+
"> 8);\n uint32_t g6 = 0x07E0 & (c >> 5);\n uint32_t b5 = 0x001F & (c >> 3);\n return (uint16_t)(r5 | g6 | b5);\n}\n\nstatic inline wuffs_base__color_u32_argb_premul //\nwuffs_base__color_u16_rgb_565__as__color_u32_argb_premul(uint16_t rgb_565) {\n uint32_t b5 = 0x1F & (rgb_565 >> 0);\n uint32_t b = (b5 << 3) | (b5 >> 2);\n uint32_t g6 = 0x3F & (rgb_565 >> 5);\n uint32_t g = (g6 << 2) | (g6 >> 4);\n uint32_t r5 = 0x1F & (rgb_565 >> 11);\n uint32_t r = (r5 << 3) | (r5 >> 2);\n return 0xFF000000 | (r << 16) | (g << 8) | (b << 0);\n}\n\nstatic inline uint8_t //\nwuffs_base__color_u32_argb_premul__as__color_u8_gray(\n wuffs_base__color_u32_argb_premul c) {\n // Work in 16-bit color.\n uint32_t cr = 0x101 * (0xFF & (c >> 16));\n uint32_t cg = 0x101 * (0xFF & (c >> 8));\n uint32_t cb = 0x101 * (0xFF & (c >> 0));\n\n // These coefficients (the fractions 0.299, 0.587 and 0.114) are the same\n // as those given by the JFIF specification.\n //\n // Note that 19595 + 38470 + 7471 equals 65536, also known as (1 << 16). We\n //"+
" shift by 24, not just by 16, because the return value is 8-bit color, not\n // 16-bit color.\n uint32_t weighted_average = (19595 * cr) + (38470 * cg) + (7471 * cb) + 32768;\n return (uint8_t)(weighted_average >> 24);\n}\n\nstatic inline uint16_t //\nwuffs_base__color_u32_argb_premul__as__color_u16_gray(\n wuffs_base__color_u32_argb_premul c) {\n // Work in 16-bit color.\n uint32_t cr = 0x101 * (0xFF & (c >> 16));\n uint32_t cg = 0x101 * (0xFF & (c >> 8));\n uint32_t cb = 0x101 * (0xFF & (c >> 0));\n\n // These coefficients (the fractions 0.299, 0.587 and 0.114) are the same\n // as those given by the JFIF specification.\n //\n // Note that 19595 + 38470 + 7471 equals 65536, also known as (1 << 16).\n uint32_t weighted_average = (19595 * cr) + (38470 * cg) + (7471 * cb) + 32768;\n return (uint16_t)(weighted_average >> 16);\n}\n\n// wuffs_base__color_u32_argb_nonpremul__as__color_u32_argb_premul converts\n// from non-premultiplied alpha to premultiplied alpha.\nstatic inline wuffs_base__color_u32_argb_premul //\nwuf"+
"fs_base__color_u32_argb_nonpremul__as__color_u32_argb_premul(\n uint32_t argb_nonpremul) {\n // Multiplying by 0x101 (twice, once for alpha and once for color) converts\n // from 8-bit to 16-bit color. Shifting right by 8 undoes that.\n //\n // Working in the higher bit depth can produce slightly different (and\n // arguably slightly more accurate) results. For example, given 8-bit blue\n // and alpha of 0x80 and 0x81:\n //\n // - ((0x80 * 0x81 ) / 0xFF ) = 0x40 = 0x40\n // - ((0x8080 * 0x8181) / 0xFFFF) >> 8 = 0x4101 >> 8 = 0x41\n uint32_t a = 0xFF & (argb_nonpremul >> 24);\n uint32_t a16 = a * (0x101 * 0x101);\n\n uint32_t r = 0xFF & (argb_nonpremul >> 16);\n r = ((r * a16) / 0xFFFF) >> 8;\n uint32_t g = 0xFF & (argb_nonpremul >> 8);\n g = ((g * a16) / 0xFFFF) >> 8;\n uint32_t b = 0xFF & (argb_nonpremul >> 0);\n b = ((b * a16) / 0xFFFF) >> 8;\n\n return (a << 24) | (r << 16) | (g << 8) | (b << 0);\n}\n\n// wuffs_base__color_u32_argb_premul__as__color_u32_argb_nonpremul converts\n// from premul"+
"tiplied alpha to non-premultiplied alpha.\nstatic inline uint32_t //\nwuffs_base__color_u32_argb_premul__as__color_u32_argb_nonpremul(\n wuffs_base__color_u32_argb_premul c) {\n uint32_t a = 0xFF & (c >> 24);\n if (a == 0xFF) {\n return c;\n } else if (a == 0) {\n return 0;\n }\n uint32_t a16 = a * 0x101;\n\n uint32_t r = 0xFF & (c >> 16);\n r = ((r * (0x101 * 0xFFFF)) / a16) >> 8;\n uint32_t g = 0xFF & (c >> 8);\n g = ((g * (0x101 * 0xFFFF)) / a16) >> 8;\n uint32_t b = 0xFF & (c >> 0);\n b = ((b * (0x101 * 0xFFFF)) / a16) >> 8;\n\n return (a << 24) | (r << 16) | (g << 8) | (b << 0);\n}\n\n// wuffs_base__color_u64_argb_nonpremul__as__color_u32_argb_premul converts\n// from 4x16LE non-premultiplied alpha to 4x8 premultiplied alpha.\nstatic inline wuffs_base__color_u32_argb_premul //\nwuffs_base__color_u64_argb_nonpremul__as__color_u32_argb_premul(\n uint64_t argb_nonpremul) {\n uint32_t a16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 48)));\n\n uint32_t r16 = ((uint32_t)(0xFFFF & (argb_nonpremul >> 32)));\n r16 ="+
"// --------\n\ntypedef uint8_t wuffs_base__pixel_blend;\n\n// wuffs_base__pixel_blend encodes how to blend source and destination pixels,\n// accounting for transparency. It encompasses the Porter-Duff compositing\n// operators as well as the other blending modes defined by PDF.\n//\n// TODO: implement the other modes.\n#define WUFFS_BASE__PIXEL_BLEND__SRC ((wuffs_base__pixel_blend)0)\n#define WUFFS_BASE__PIXEL_BLEND__SRC_OVER ((wuffs_base__pixel_blend)1)\n\n"+
""+
"// --------\n\n// wuffs_base__pixel_alpha_transparency is a pixel format's alpha channel\n// model. It is a property of the pixel format in general, not of a specific\n// pixel. An RGBA pixel format (with alpha) can still have fully opaque pixels.\ntypedef uint32_t wuffs_base__pixel_alpha_transparency;\n\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__OPAQUE 0\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__NONPREMULTIPLIED_ALPHA 1\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__PREMULTIPLIED_ALPHA 2\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__BINARY_ALPHA 3\n\n// Deprecated: use WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__NONPREMULTIPLIED_ALPHA\n// instead.\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__NON_PREMULTIPLIED_ALPHA 1\n\n"+
""+
"// --------\n\n#define WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX 4\n\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__INDEX_PLANE 0\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE 3\n\n// A palette is 256 entries × 4 bytes per entry (e.g. BGRA).\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH 1024\n\n// wuffs_base__pixel_format encodes the format of the bytes that constitute an\n// image frame's pixel data.\n//\n// See https://github.com/google/wuffs/blob/main/doc/note/pixel-formats.md\n//\n// Do not manipulate its bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_format__num_planes instead.\ntypedef struct wuffs_base__pixel_format__struct {\n uint32_t repr;\n\n#ifdef __cplusplus\n inline bool is_valid() const;\n inline uint32_t bits_per_pixel() const;\n inline bool is_direct() const;\n inline bool is_indexed() const;\n inline bool is_interleaved() const;\n inline bool is_planar() const;\n inline uint32_t num_planes() const;\n inline wuffs_base__pixel_alpha_tran"+
"sparency transparency() const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_format;\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__make_pixel_format(uint32_t repr) {\n wuffs_base__pixel_format f;\n f.repr = repr;\n return f;\n}\n\n// Common 8-bit-depth pixel formats. This list is not exhaustive; not all valid\n// wuffs_base__pixel_format values are present.\n\n#define WUFFS_BASE__PIXEL_FORMAT__INVALID 0x00000000\n\n#define WUFFS_BASE__PIXEL_FORMAT__A 0x02000008\n\n#define WUFFS_BASE__PIXEL_FORMAT__Y 0x20000008\n#define WUFFS_BASE__PIXEL_FORMAT__Y_16LE 0x2000000B\n#define WUFFS_BASE__PIXEL_FORMAT__Y_16BE 0x2010000B\n#define WUFFS_BASE__PIXEL_FORMAT__YA_NONPREMUL 0x21000008\n#define WUFFS_BASE__PIXEL_FORMAT__YA_PREMUL 0x22000008\n\n#define WUFFS_BASE__PIXEL_FORMAT__YCBCR 0x40020888\n#define WUFFS_BASE__PIXEL_FORMAT__YCBCRA_NONPREMUL 0x41038888\n#define WUFFS_BASE__PIXEL_FORMAT__YCBCRK 0x50038888\n\n#define WUFFS_BASE__PIXEL_FORMAT__YCOCG 0x60020888\n#define WUFFS_BASE__PIXEL_FORMAT__YCOCGA_NONPREMUL 0x61038888\n#define WUFFS"+
"// --------\n\ntypedef struct wuffs_base__pixel_config__struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_format pixfmt;\n wuffs_base__pixel_subsampling pixsub;\n uint32_t width;\n uint32_t height;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height);\n inline void invalidate();\n inline bool is_valid() const;\n inline wuffs_base__pixel_format pixel_format() const;\n inline wuffs_base__pixel_subsampling pixel_subsampling() const;\n inline wuffs_base__rect_ie_u32 bounds() const;\n inline uint32_t width() const;\n inline uint32_t height() const;\n inline uint64_t pixbuf_len() const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_config;\n\nstatic inline wuffs_base__pixel_config //\nwuffs_base__null_pixel_config() {\n wuffs_base__pixel_config ret;\n ret.private_im"+
"pl.pixfmt.repr = 0;\n ret.private_impl.pixsub.repr = 0;\n ret.private_impl.width = 0;\n ret.private_impl.height = 0;\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__pixel_config__set(wuffs_base__pixel_config* c,\n uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height) {\n if (!c) {\n return;\n }\n if (pixfmt_repr) {\n uint64_t wh = ((uint64_t)width) * ((uint64_t)height);\n // TODO: handle things other than 1 byte per pixel.\n if (wh <= ((uint64_t)SIZE_MAX)) {\n c->private_impl.pixfmt.repr = pixfmt_repr;\n c->private_impl.pixsub.repr = pixsub_repr;\n c->private_impl.width = width;\n c->private_impl.height = height;\n return;\n }\n }\n\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub.repr = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n}\n\nstatic inline void "+
" //\nwuffs_base__pixel_config__invalidate(wuffs_base__pixel_config* c) {\n if (c) {\n c->private_impl.pixfmt.repr = 0;\n c->private_impl.pixsub.repr = 0;\n c->private_impl.width = 0;\n c->private_impl.height = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__pixel_config__is_valid(const wuffs_base__pixel_config* c) {\n return c && c->private_impl.pixfmt.repr;\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_config__pixel_format(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixfmt : wuffs_base__make_pixel_format(0);\n}\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config__pixel_subsampling(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.pixsub : wuffs_base__make_pixel_subsampling(0);\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config__bounds(const wuffs_base__pixel_config* c) {\n if (c) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = c->private_impl.width;\n r"+
"et.max_excl_y = c->private_impl.height;\n return ret;\n }\n\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_excl_x = 0;\n ret.max_excl_y = 0;\n return ret;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__width(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.width : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_config__height(const wuffs_base__pixel_config* c) {\n return c ? c->private_impl.height : 0;\n}\n\n// TODO: this is the right API for planar (not interleaved) pixbufs? Should it\n// allow decoding into a color model different from the format's intrinsic one?\n// For example, decoding a JPEG image straight to RGBA instead of to YCbCr?\nstatic inline uint64_t //\nwuffs_base__pixel_config__pixbuf_len(const wuffs_base__pixel_config* c) {\n if (!c) {\n return 0;\n }\n if (wuffs_base__pixel_format__is_planar(&c->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return 0;\n }\n uint32_t bits_per"+
"_pixel =\n wuffs_base__pixel_format__bits_per_pixel(&c->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return 0;\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint64_t n =\n ((uint64_t)c->private_impl.width) * ((uint64_t)c->private_impl.height);\n if (n > (UINT64_MAX / bytes_per_pixel)) {\n return 0;\n }\n n *= bytes_per_pixel;\n\n if (wuffs_base__pixel_format__is_indexed(&c->private_impl.pixfmt)) {\n if (n >\n (UINT64_MAX - WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH)) {\n return 0;\n }\n n += WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;\n }\n\n return n;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__pixel_config::set(uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height) {\n wuffs_base__pixel_config__set(this, pixfmt_repr, pixsub_"+
"// --------\n\n// wuffs_base__animation_disposal encodes, for an animated image, how to\n// dispose of a frame after displaying it:\n// - None means to draw the next frame on top of this one.\n// - Restore Background means to clear the frame's dirty rectangle to \"the\n// background color\" (in practice, this means transparent black) before\n// drawing the next frame.\n// - Restore Previous means to undo the current frame, so that the next frame\n// is drawn on top of the previous one.\ntypedef uint8_t wuffs_base__animation_disposal;\n\n#define WUFFS_BASE__ANIMATION_DISPOSAL__NONE ((wuffs_base__animation_disposal)0)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND \\\n ((wuffs_base__animation_disposal)1)\n#define WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_PREVIOUS \\\n ((wuffs_base__animation_disposal)2)\n\n"+
""+
"// --------\n\ntypedef struct wuffs_base__frame_config__struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__rect_ie_u32 bounds;\n wuffs_base__flicks duration;\n uint64_t index;\n uint64_t io_position;\n wuffs_base__animation_disposal disposal;\n bool opaque_within_bounds;\n bool overwrite_instead_of_blend;\n wuffs_base__color_u32_argb_premul background_color;\n } private_impl;\n\n#ifdef __cplusplus\n inline void set(wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_position,\n wuffs_base__animation_disposal disposal,\n bool opaque_within_bounds,\n bool overwrite_instead_of_blend,\n wuffs_base__color_u32_argb_premul background_color);\n inline wuffs_base__rect_ie_u32 bounds() const;\n inline uint32_t width() const;\n inline uint32_t hei"+
"ct_ie_u32__width(&c->private_impl.bounds) : 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__frame_config__height(const wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_ie_u32__height(&c->private_impl.bounds) : 0;\n}\n\n// wuffs_base__frame_config__duration returns the amount of time to display\n// this frame. Zero means to display forever - a still (non-animated) image.\nstatic inline wuffs_base__flicks //\nwuffs_base__frame_config__duration(const wuffs_base__frame_config* c) {\n return c ? c->private_impl.duration : 0;\n}\n\n// wuffs_base__frame_config__index returns the index of this frame. The first\n// frame in an image has index 0, the second frame has index 1, and so on.\nstatic inline uint64_t //\nwuffs_base__frame_config__index(const wuffs_base__frame_config* c) {\n return c ? c->private_impl.index : 0;\n}\n\n// wuffs_base__frame_config__io_position returns the I/O stream position before\n// the frame config.\nstatic inline uint64_t //\nwuffs_base__frame_config__io_position(const wuffs_base__frame_config* c"+
") {\n return c ? c->private_impl.io_position : 0;\n}\n\n// wuffs_base__frame_config__disposal returns, for an animated image, how to\n// dispose of this frame after displaying it.\nstatic inline wuffs_base__animation_disposal //\nwuffs_base__frame_config__disposal(const wuffs_base__frame_config* c) {\n return c ? c->private_impl.disposal : 0;\n}\n\n// wuffs_base__frame_config__opaque_within_bounds returns whether all pixels\n// within the frame's bounds are fully opaque. It makes no claim about pixels\n// outside the frame bounds but still inside the overall image. The two\n// bounding rectangles can differ for animated images.\n//\n// Its semantics are conservative. It is valid for a fully opaque frame to have\n// this value be false: a false negative.\n//\n// If true, drawing the frame with WUFFS_BASE__PIXEL_BLEND__SRC and\n// WUFFS_BASE__PIXEL_BLEND__SRC_OVER should be equivalent, in terms of\n// resultant pixels, but the former may be faster.\nstatic inline bool //\nwuffs_base__frame_config__opaque_within_bounds(\n const "+
"wuffs_base__frame_config* c) {\n return c && c->private_impl.opaque_within_bounds;\n}\n\n// wuffs_base__frame_config__overwrite_instead_of_blend returns, for an\n// animated image, whether to ignore the previous image state (within the frame\n// bounds) when drawing this incremental frame. Equivalently, whether to use\n// WUFFS_BASE__PIXEL_BLEND__SRC instead of WUFFS_BASE__PIXEL_BLEND__SRC_OVER.\n//\n// The WebP spec (https://developers.google.com/speed/webp/docs/riff_container)\n// calls this the \"Blending method\" bit. WebP's \"Do not blend\" corresponds to\n// Wuffs' \"overwrite_instead_of_blend\".\nstatic inline bool //\nwuffs_base__frame_config__overwrite_instead_of_blend(\n const wuffs_base__frame_config* c) {\n return c && c->private_impl.overwrite_instead_of_blend;\n}\n\nstatic inline wuffs_base__color_u32_argb_premul //\nwuffs_base__frame_config__background_color(const wuffs_base__frame_config* c) {\n return c ? c->private_impl.background_color : 0;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__frame_config::set"+
" wuffs_base__slice_u8 pixbuf_memory) {\n if (!pb) {\n return wuffs_base__make_status(wuffs_base__error__bad_receiver);\n }\n memset(pb, 0, sizeof(*pb));\n if (!pixcfg) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n if (wuffs_base__pixel_format__is_planar(&pixcfg->private_impl.pixfmt)) {\n // TODO: support planar pixel formats, concious of pixel subsampling.\n return wuffs_base__make_status(wuffs_base__error__unsupported_option);\n }\n uint32_t bits_per_pixel =\n wuffs_base__pixel_format__bits_per_pixel(&pixcfg->private_impl.pixfmt);\n if ((bits_per_pixel == 0) || ((bits_per_pixel % 8) != 0)) {\n // TODO: support fraction-of-byte pixels, e.g. 1 bit per pixel?\n return wuffs_base__make_status(wuffs_base__error__unsupported_option);\n }\n uint64_t bytes_per_pixel = bits_per_pixel / 8;\n\n uint8_t* ptr = pixbuf_memory.ptr;\n uint64_t len = pixbuf_memory.len;\n if (wuffs_base__pixel_format__is_indexed(&pixcfg->private_impl.pixfmt)) {\n // Split a WU"+
"FFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH byte\n // chunk (1024 bytes = 256 palette entries × 4 bytes per entry) from the\n // start of pixbuf_memory. We split from the start, not the end, so that\n // the both chunks' pointers have the same alignment as the original\n // pointer, up to an alignment of 1024.\n if (len < WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return wuffs_base__make_status(\n wuffs_base__error__bad_argument_length_too_short);\n }\n wuffs_base__table_u8* tab =\n &pb->private_impl\n .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];\n tab->ptr = ptr;\n tab->width = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;\n tab->height = 1;\n tab->stride = WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;\n ptr += WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;\n len -= WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH;\n }\n\n uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *\n "+
"// --------\n\ntypedef struct wuffs_base__decode_frame_options__struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n uint8_t TODO;\n } private_impl;\n\n#ifdef __cplusplus\n#endif // __cplusplus\n\n} wuffs_base__decode_frame_options;\n\n#ifdef __cplusplus\n\n#endif // __cplusplus\n\n"+
""+
"// --------\n\n// wuffs_base__pixel_palette__closest_element returns the index of the palette\n// element that minimizes the sum of squared differences of the four ARGB\n// channels, working in premultiplied alpha. Ties favor the smaller index.\n//\n// The palette_slice.len may equal (N*4), for N less than 256, which means that\n// only the first N palette elements are considered. It returns 0 when N is 0.\n//\n// Applying this function on a per-pixel basis will not produce whole-of-image\n// dithering.\nWUFFS_BASE__MAYBE_STATIC uint8_t //\nwuffs_base__pixel_palette__closest_element(\n wuffs_base__slice_u8 palette_slice,\n wuffs_base__pixel_format palette_format,\n wuffs_base__color_u32_argb_premul c);\n\n"+
""+
"// --------\n\n// TODO: should the func type take restrict pointers?\ntypedef uint64_t (*wuffs_base__pixel_swizzler__func)(uint8_t* dst_ptr,\n size_t dst_len,\n uint8_t* dst_palette_ptr,\n size_t dst_palette_len,\n const uint8_t* src_ptr,\n size_t src_len);\n\ntypedef uint64_t (*wuffs_base__pixel_swizzler__transparent_black_func)(\n uint8_t* dst_ptr,\n size_t dst_len,\n uint8_t* dst_palette_ptr,\n size_t dst_palette_len,\n uint64_t num_pixels,\n uint32_t dst_pixfmt_bytes_per_pixel);\n\ntypedef struct wuffs_base__pixel_swizzler__struct {\n // Do not access the private_impl's fields directly. There is no API/ABI\n // compatibility or safety guarantee if you do so.\n struct {\n wuffs_base__pixel_swizzler__func func;\n wuffs_base__pixel_swizzler__transpa"+
"rent_black_func transparent_black_func;\n uint32_t dst_pixfmt_bytes_per_pixel;\n uint32_t src_pixfmt_bytes_per_pixel;\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status prepare(wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_pixfmt,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend);\n inline uint64_t swizzle_interleaved_from_slice(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_swizzler;\n\n// wuffs_base__pixel_swizzler__prepare readies the pixel swizzler so that its\n// other methods may be called.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__PIXCONV sub-module, not\n// just WUFFS_CONFIG__MOD"+
"ULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__status //\nwuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_pixfmt,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend);\n\n// wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice converts pixels\n// from a source format to a destination format.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__PIXCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC uint64_t //\nwuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(\n const wuffs_base__pixel_swizzler* p,\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n "+
"// ---------------- I/O\n\nstatic inline uint64_t //\nwuffs_base__io__count_since(uint64_t mark, uint64_t index) {\n if (index >= mark) {\n return index - mark;\n }\n return 0;\n}\n\n// TODO: drop the \"const\" in \"const uint8_t* ptr\". Some though required about\n// the base.io_reader.since method returning a mutable \"slice base.u8\".\n#if defined(__GNUC__)\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wcast-qual\"\n#endif\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io__since(uint64_t mark, uint64_t index, const uint8_t* ptr) {\n if (index >= mark) {\n return wuffs_base__make_slice_u8(((uint8_t*)ptr) + mark,\n ((size_t)(index - mark)));\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n#if defined(__GNUC__)\n#pragma GCC diagnostic pop\n#endif\n\n"+
""+
"// --------\n\nstatic inline void //\nwuffs_base__io_reader__limit(const uint8_t** ptr_io2_r,\n const uint8_t* iop_r,\n uint64_t limit) {\n if (((uint64_t)(*ptr_io2_r - iop_r)) > limit) {\n *ptr_io2_r = iop_r + limit;\n }\n}\n\nstatic inline uint32_t //\nwuffs_base__io_reader__limited_copy_u32_to_slice(const uint8_t** ptr_iop_r,\n const uint8_t* io2_r,\n uint32_t length,\n wuffs_base__slice_u8 dst) {\n const uint8_t* iop_r = *ptr_iop_r;\n size_t n = dst.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io2_r - iop_r))) {\n n = (size_t)(io2_r - iop_r);\n }\n if (n > 0) {\n memmove(dst.ptr, iop_r, n);\n *ptr_iop_r += n;\n }\n return (uint32_t)(n);\n}\n\n// wuffs_base__io_reader__match7 returns whether the io_reader's upcoming bytes\n// start with the given prefix (up to 7 bytes long). It is peek-like, not\n"+
"// read-like, in that there are no side-effects.\n//\n// The low 3 bits of a hold the prefix length, n.\n//\n// The high 56 bits of a hold the prefix itself, in little-endian order. The\n// first prefix byte is in bits 8..=15, the second prefix byte is in bits\n// 16..=23, etc. The high (8 * (7 - n)) bits are ignored.\n//\n// There are three possible return values:\n// - 0 means success.\n// - 1 means inconclusive, equivalent to \"$short read\".\n// - 2 means failure.\nstatic inline uint32_t //\nwuffs_base__io_reader__match7(const uint8_t* iop_r,\n const uint8_t* io2_r,\n wuffs_base__io_buffer* r,\n uint64_t a) {\n uint32_t n = a & 7;\n a >>= 8;\n if ((io2_r - iop_r) >= 8) {\n uint64_t x = wuffs_base__peek_u64le__no_bounds_check(iop_r);\n uint32_t shift = 8 * (8 - n);\n return ((a << shift) == (x << shift)) ? 0 : 2;\n }\n for (; n > 0; n--) {\n if (iop_r >= io2_r) {\n return (r && r->meta.closed) ? 2 : 1;\n } else if (*iop_"+
" uint32_t distance) {\n if (!distance) {\n return 0;\n }\n uint8_t* p = *ptr_iop_w;\n if ((size_t)(p - io1_w) < (size_t)(distance)) {\n return 0;\n }\n uint8_t* q = p - distance;\n size_t n = (size_t)(io2_w - p);\n if ((size_t)(length) > n) {\n length = (uint32_t)(n);\n } else {\n n = (size_t)(length);\n }\n // TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that\n // is mostly because 3 is the minimum length for the deflate format. This\n // function implementation shouldn't overfit to that one format. Perhaps the\n // limited_copy_u32_from_history Wuffs method should also take an unroll hint\n // argument, and the cgen can look if that argument is the constant\n // expression '3'.\n //\n // See also wuffs_base__io_writer__limited_copy_u32_from_history_fast below.\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_w"+
"riter__limited_copy_u32_from_history_fast is like the\n// wuffs_base__io_writer__limited_copy_u32_from_history function above, but has\n// stronger pre-conditions.\n//\n// The caller needs to prove that:\n// - length <= (io2_w - *ptr_iop_w)\n// - distance >= 1\n// - distance <= (*ptr_iop_w - io1_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint8_t* q = p - distance;\n uint32_t n = length;\n for (; n >= 3; n -= 3) {\n *p++ = *q++;\n *p++ = *q++;\n *p++ = *q++;\n }\n for (; n; n--) {\n *p++ = *q++;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_dist"+
"ance_1_fast\n// copies the previous byte (the one immediately before *ptr_iop_w), copying 8\n// byte chunks at a time. Each chunk contains 8 repetitions of the same byte.\n//\n// In terms of number of bytes copied, length is rounded up to a multiple of 8.\n// As a special case, a zero length rounds up to 8 (even though 0 is already a\n// multiple of 8), since there is always at least one 8 byte chunk copied.\n//\n// In terms of advancing *ptr_iop_w, length is not rounded up.\n//\n// The caller needs to prove that:\n// - (length + 8) <= (io2_w - *ptr_iop_w)\n// - distance == 1\n// - distance <= (*ptr_iop_w - io1_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(\n uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n uint64_t x = p[-1];\n x |= x << 8;\n x |= x << 16;\n x |= x << 32;\n uint32_t n = length;\n while (1) {\n wuffs_base__poke_u64le__no_bounds_check("+
"p, x);\n if (n <= 8) {\n p += n;\n break;\n }\n p += 8;\n n -= 8;\n }\n *ptr_iop_w = p;\n return length;\n}\n\n// wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast is\n// like the wuffs_base__io_writer__limited_copy_u32_from_history_fast function\n// above, but copies 8 byte chunks at a time.\n//\n// In terms of number of bytes copied, length is rounded up to a multiple of 8.\n// As a special case, a zero length rounds up to 8 (even though 0 is already a\n// multiple of 8), since there is always at least one 8 byte chunk copied.\n//\n// In terms of advancing *ptr_iop_w, length is not rounded up.\n//\n// The caller needs to prove that:\n// - (length + 8) <= (io2_w - *ptr_iop_w)\n// - distance >= 8\n// - distance <= (*ptr_iop_w - io1_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(\n uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n uint32_t distance) {\n uint8_t* p = *ptr_iop_w;\n u"+
"int8_t* q = p - distance;\n uint32_t n = length;\n while (1) {\n memcpy(p, q, 8);\n if (n <= 8) {\n p += n;\n break;\n }\n p += 8;\n q += 8;\n n -= 8;\n }\n *ptr_iop_w = p;\n return length;\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_copy_u32_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n const uint8_t** ptr_iop_r,\n const uint8_t* io2_r) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = length;\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n const uint8_t* iop_r = *ptr_iop_r;\n if (n > ((size_t)(io2_r - iop_r))) {\n n = (size_t)(io2_r - iop_r);\n }\n if (n > 0) {\n memmove(iop_w, iop_r, n);\n *ptr_iop_w += n;\n *ptr_iop_r += n;\n }\n return (uint32_t)(n);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__limited_co"+
"// ---------------- I/O\n//\n// See (/doc/note/io-input-output.md).\n\n// wuffs_base__io_buffer_meta is the metadata for a wuffs_base__io_buffer's\n// data.\ntypedef struct wuffs_base__io_buffer_meta__struct {\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n uint64_t pos; // Buffer position (relative to the start of stream).\n bool closed; // No further writes are expected.\n} wuffs_base__io_buffer_meta;\n\n// wuffs_base__io_buffer is a 1-dimensional buffer (a pointer and length) plus\n// additional metadata.\n//\n// A value with all fields zero is a valid, empty buffer.\ntypedef struct wuffs_base__io_buffer__struct {\n wuffs_base__slice_u8 data;\n wuffs_base__io_buffer_meta meta;\n\n#ifdef __cplusplus\n inline bool is_valid() const;\n inline void compact();\n inline size_t reader_length() const;\n inline uint8_t* reader_pointer() const;\n inline uint64_t reader_position() const;\n inline wuffs_base__slice_u8 reader_slice() const;\n inline size_t writer_length"+
"// ---------------- String Conversions\n\n// Options (bitwise or'ed together) for wuffs_base__parse_number_xxx\n// functions. The XXX options apply to both integer and floating point. The FXX\n// options apply only to floating point.\n\n#define WUFFS_BASE__PARSE_NUMBER_XXX__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES means to accept\n// inputs like \"00\", \"0644\" and \"00.7\". By default, they are rejected.\n#define WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES \\\n ((uint32_t)0x00000001)\n\n// WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES means to accept inputs like\n// \"1__2\" and \"_3.141_592\". By default, they are rejected.\n#define WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES ((uint32_t)0x00000002)\n\n// WUFFS_BASE__PARSE_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA means to accept\n// \"1,5\" and not \"1.5\" as one-and-a-half.\n//\n// If the caller wants to accept either, it is responsible for canonicalizing\n// the input before calling wuffs_base__parse_numb"+
"er_fxx. The caller also has\n// more context on e.g. exactly how to treat something like \"$1,234\".\n#define WUFFS_BASE__PARSE_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA \\\n ((uint32_t)0x00000010)\n\n// WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN means to reject inputs that\n// would lead to infinite or Not-a-Number floating point values. By default,\n// they are accepted.\n//\n// This affects the literal \"inf\" as input, but also affects inputs like\n// \"1e999\" that would overflow double-precision floating point.\n#define WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN ((uint32_t)0x00000020)\n\n"+
""+
"// --------\n\n// Options (bitwise or'ed together) for wuffs_base__render_number_xxx\n// functions. The XXX options apply to both integer and floating point. The FXX\n// options apply only to floating point.\n\n#define WUFFS_BASE__RENDER_NUMBER_XXX__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT means to render to the right side\n// (higher indexes) of the destination slice, leaving any untouched bytes on\n// the left side (lower indexes). The default is vice versa: rendering on the\n// left with slack on the right.\n#define WUFFS_BASE__RENDER_NUMBER_XXX__ALIGN_RIGHT ((uint32_t)0x00000100)\n\n// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN means to render the leading\n// \"+\" for non-negative numbers: \"+0\" and \"+12.3\" instead of \"0\" and \"12.3\".\n#define WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN ((uint32_t)0x00000200)\n\n// WUFFS_BASE__RENDER_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA means to render\n// one-and-a-half as \"1,5\" instead of \"1.5\".\n#define WUFFS_BASE__RENDER_NUMBER_F"+
"XX__DECIMAL_SEPARATOR_IS_A_COMMA \\\n ((uint32_t)0x00001000)\n\n// WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ETC means whether to never\n// (EXPONENT_ABSENT, equivalent to printf's \"%f\") or to always\n// (EXPONENT_PRESENT, equivalent to printf's \"%e\") render a floating point\n// number as \"1.23e+05\" instead of \"123000\".\n//\n// Having both bits set is the same has having neither bit set, where the\n// notation used depends on whether the exponent is sufficiently large: \"0.5\"\n// is preferred over \"5e-01\" but \"5e-09\" is preferred over \"0.000000005\".\n#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT ((uint32_t)0x00002000)\n#define WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT ((uint32_t)0x00004000)\n\n// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION means to render the\n// smallest number of digits so that parsing the resultant string will recover\n// the same double-precision floating point number.\n//\n// For example, double-precision cannot distinguish between 0.3 and\n// 0.2999999999999999888977697537484345957636"+
"83319091796875, so when this bit\n// is set, rendering the latter will produce \"0.3\" but rendering\n// 0.3000000000000000444089209850062616169452667236328125 will produce\n// \"0.30000000000000004\".\n#define WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION \\\n ((uint32_t)0x00008000)\n\n"+
""+
"// ---------------- IEEE 754 Floating Point\n\n// wuffs_base__ieee_754_bit_representation__etc converts between a double\n// precision numerical value and its IEEE 754 representations:\n// - 16-bit: 1 sign bit, 5 exponent bits, 10 explicit significand bits.\n// - 32-bit: 1 sign bit, 8 exponent bits, 23 explicit significand bits.\n// - 64-bit: 1 sign bit, 11 exponent bits, 52 explicit significand bits.\n//\n// For example, it converts between:\n// - +1.0 and 0x3C00, 0x3F80_0000 or 0x3FF0_0000_0000_0000.\n// - +5.5 and 0x4580, 0x40B0_0000 or 0x4016_0000_0000_0000.\n// - -inf and 0xFC00, 0xFF80_0000 or 0xFFF0_0000_0000_0000.\n//\n// Converting from f64 to shorter formats (f16 or f32, represented in C as\n// uint16_t and uint32_t) may be lossy. Such functions have names that look\n// like etc_truncate, as converting finite numbers produce equal or smaller\n// (closer-to-zero) finite numbers. For example, 1048576.0 is a perfectly valid\n// f64 number, but converting it to a f16 (with truncation) produces 65504.0,\n// the"+
" largest finite f16 number. Truncating a f64-typed value d to f32 does\n// not always produce the same result as the C-style cast ((float)d), as\n// casting can convert from finite numbers to infinite ones.\n//\n// Converting infinities or NaNs produces infinities or NaNs and always report\n// no loss, even though there a multiple NaN representations so that round-\n// tripping a f64-typed NaN may produce a different 64 bits. Nonetheless, the\n// etc_truncate functions preserve a NaN's \"quiet vs signaling\" bit.\n//\n// See https://en.wikipedia.org/wiki/Double-precision_floating-point_format\n\ntypedef struct wuffs_base__lossy_value_u16__struct {\n uint16_t value;\n bool lossy;\n} wuffs_base__lossy_value_u16;\n\ntypedef struct wuffs_base__lossy_value_u32__struct {\n uint32_t value;\n bool lossy;\n} wuffs_base__lossy_value_u32;\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u16 //\nwuffs_base__ieee_754_bit_representation__from_f64_to_u16_truncate(double f);\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u32 //\nwuffs_ba"+
"se__ieee_754_bit_representation__from_f64_to_u32_truncate(double f);\n\nstatic inline uint64_t //\nwuffs_base__ieee_754_bit_representation__from_f64_to_u64(double f) {\n uint64_t u = 0;\n if (sizeof(uint64_t) == sizeof(double)) {\n memcpy(&u, &f, sizeof(uint64_t));\n }\n return u;\n}\n\nstatic inline double //\nwuffs_base__ieee_754_bit_representation__from_u16_to_f64(uint16_t u) {\n uint64_t v = ((uint64_t)(u & 0x8000)) << 48;\n\n do {\n uint64_t exp = (u >> 10) & 0x1F;\n uint64_t man = u & 0x3FF;\n if (exp == 0x1F) { // Infinity or NaN.\n exp = 2047;\n } else if (exp != 0) { // Normal.\n exp += 1008; // 1008 = 1023 - 15, the difference in biases.\n } else if (man != 0) { // Subnormal but non-zero.\n uint32_t clz = wuffs_base__count_leading_zeroes_u64(man);\n exp = 1062 - clz; // 1062 = 1008 + 64 - 10.\n man = 0x3FF & (man << (clz - 53));\n } else { // Zero.\n break;\n }\n v |= (exp << 52) | (man << 42);\n } while (0);\n\n double f = 0;\n if (sizeof(uint64_t) ="+
"// ---------------- Parsing and Rendering Numbers\n\n// wuffs_base__parse_number_f64 parses the floating point number in s. For\n// example, if s contains the bytes \"1.5\" then it will return the double 1.5.\n//\n// It returns an error if s does not contain a floating point number.\n//\n// It does not necessarily return an error if the conversion is lossy, e.g. if\n// s is \"0.3\", which double-precision floating point cannot represent exactly.\n//\n// Similarly, the returned value may be infinite (and no error returned) even\n// if s was not \"inf\", when the input is nominally finite but sufficiently\n// larger than DBL_MAX, about 1.8e+308.\n//\n// It is similar to the C standard library's strtod function, but:\n// - Errors are returned in-band (in a result type), not out-of-band (errno).\n// - It takes a slice (a pointer and length), not a NUL-terminated C string.\n// - It does not take an optional endptr argument. It does not allow a partial\n// parse: it returns an error unless all of s is consumed.\n// - It does not all"+
"ow whitespace, leading or otherwise.\n// - It does not allow hexadecimal floating point numbers.\n// - It is not affected by i18n / l10n settings such as environment variables.\n//\n// The options argument can change these, but by default, it:\n// - Allows \"inf\", \"+Infinity\" and \"-NAN\", case insensitive. Similarly,\n// without an explicit opt-out, it would successfully parse \"1e999\" as\n// infinity, even though it overflows double-precision floating point.\n// - Rejects underscores. With an explicit opt-in, \"_3.141_592\" would\n// successfully parse as an approximation to π.\n// - Rejects unnecessary leading zeroes: \"00\", \"0644\" and \"00.7\".\n// - Uses a dot '1.5' instead of a comma '1,5' for the decimal separator.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__FLOATCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__result_f64 //\nwuffs_base__parse_number_f64(wuffs_base__"+
"slice_u8 s, uint32_t options);\n\n// wuffs_base__parse_number_i64 parses the ASCII integer in s. For example, if\n// s contains the bytes \"-123\" then it will return the int64_t -123.\n//\n// It returns an error if s does not contain an integer or if the integer\n// within would overflow an int64_t.\n//\n// It is similar to wuffs_base__parse_number_u64 but it returns a signed\n// integer, not an unsigned integer. It also allows a leading '+' or '-'.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__result_i64 //\nwuffs_base__parse_number_i64(wuffs_base__slice_u8 s, uint32_t options);\n\n// wuffs_base__parse_number_u64 parses the ASCII integer in s. For example, if\n// s contains the bytes \"123\" then it will return the uint64_t 123.\n//\n// It returns an error if s does not contain an integer or if the integer\n// within would overflow a uin"+
"t64_t.\n//\n// It is similar to the C standard library's strtoull function, but:\n// - Errors are returned in-band (in a result type), not out-of-band (errno).\n// - It takes a slice (a pointer and length), not a NUL-terminated C string.\n// - It does not take an optional endptr argument. It does not allow a partial\n// parse: it returns an error unless all of s is consumed.\n// - It does not allow whitespace, leading or otherwise.\n// - It does not allow a leading '+' or '-'.\n// - It does not take a base argument (e.g. base 10 vs base 16). Instead, it\n// always accepts both decimal (e.g \"1234\", \"0d5678\") and hexadecimal (e.g.\n// \"0x9aBC\"). The caller is responsible for prior filtering of e.g. hex\n// numbers if they are unwanted. For example, Wuffs' JSON decoder will only\n// produce a wuffs_base__token for decimal numbers, not hexadecimal.\n// - It is not affected by i18n / l10n settings such as environment variables.\n//\n// The options argument can change these, but by default, it:\n// - Rejects "+
"underscores. With an explicit opt-in, \"__0D_1_002\" would\n// successfully parse as \"one thousand and two\". Underscores are still\n// rejected inside the optional 2-byte opening \"0d\" or \"0X\" that denotes\n// base-10 or base-16.\n// - Rejects unnecessary leading zeroes: \"00\" and \"0644\".\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__result_u64 //\nwuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options);\n\n"+
""+
"// --------\n\n// WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL is the string length of\n// \"-9223372036854775808\" and \"+9223372036854775807\", INT64_MIN and INT64_MAX.\n#define WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL 20\n\n// WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL is the string length of\n// \"+18446744073709551615\", UINT64_MAX.\n#define WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL 21\n\n// wuffs_base__render_number_f64 writes the decimal encoding of x to dst and\n// returns the number of bytes written. If dst is shorter than the entire\n// encoding, it returns 0 (and no bytes are written).\n//\n// For those familiar with C's printf or Go's fmt.Printf functions:\n// - \"%e\" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT option.\n// - \"%f\" means the WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT option.\n// - \"%g\" means neither or both bits are set.\n//\n// The precision argument controls the number of digits rendered, excluding the\n// exponent (the \"e+05\" in \"1.23e+05\"):\n// - for \"%e\" and \"%f\" it is the number of digits after t"+
"he decimal separator,\n// - for \"%g\" it is the number of significant digits (and trailing zeroes are\n// removed).\n//\n// A precision of 6 gives similar output to printf's defaults.\n//\n// A precision greater than 4095 is equivalent to 4095.\n//\n// The precision argument is ignored when the\n// WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION option is set. This is\n// similar to Go's strconv.FormatFloat with a negative (i.e. non-sensical)\n// precision, but there is no corresponding feature in C's printf.\n//\n// Extreme values of x will be rendered as \"NaN\", \"Inf\" (or \"+Inf\" if the\n// WUFFS_BASE__RENDER_NUMBER_XXX__LEADING_PLUS_SIGN option is set) or \"-Inf\".\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__FLOATCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__render_number_f64(wuffs_base__slice_u8 dst,\n double x,\n "+
" uint32_t precision,\n uint32_t options);\n\n// wuffs_base__render_number_i64 writes the decimal encoding of x to dst and\n// returns the number of bytes written. If dst is shorter than the entire\n// encoding, it returns 0 (and no bytes are written).\n//\n// dst will never be too short if its length is at least 20, also known as\n// WUFFS_BASE__I64__BYTE_LENGTH__MAX_INCL.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__render_number_i64(wuffs_base__slice_u8 dst,\n int64_t x,\n uint32_t options);\n\n// wuffs_base__render_number_u64 writes the decimal encoding of x to dst and\n// returns the number of bytes written. If dst is shorter than the entire\n// encoding, it returns 0 (and no bytes are written).\n//\n// dst will never be too sho"+
"rt if its length is at least 21, also known as\n// WUFFS_BASE__U64__BYTE_LENGTH__MAX_INCL.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__render_number_u64(wuffs_base__slice_u8 dst,\n uint64_t x,\n uint32_t options);\n\n"+
""+
"// ---------------- Base-16\n\n// Options (bitwise or'ed together) for wuffs_base__base_16__xxx functions.\n\n#define WUFFS_BASE__BASE_16__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// wuffs_base__base_16__decode2 converts \"6A6b\" to \"jk\", where e.g. 'j' is\n// U+006A. There are 2 src bytes for every dst byte.\n//\n// It assumes that the src bytes are two hexadecimal digits (0-9, A-F, a-f),\n// repeated. It may write nonsense bytes if not, although it will not read or\n// write out of bounds.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_16__decode2(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n// wuffs_base__base_16__decode4 converts both \"\\\\x6A\\\\x6b\" and \"??6a??6B\" "+
"to\n// \"jk\", where e.g. 'j' is U+006A. There are 4 src bytes for every dst byte.\n//\n// It assumes that the src bytes are two ignored bytes and then two hexadecimal\n// digits (0-9, A-F, a-f), repeated. It may write nonsense bytes if not,\n// although it will not read or write out of bounds.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_16__decode4(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n// wuffs_base__base_16__encode2 converts \"jk\" to \"6A6B\", where e.g. 'j' is\n// U+006A. There are 2 dst bytes for every src byte.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV"+
" sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_16__encode2(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n// wuffs_base__base_16__encode4 converts \"jk\" to \"\\\\x6A\\\\x6B\", where e.g. 'j'\n// is U+006A. There are 4 dst bytes for every src byte.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_16__encode2(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n"+
""+
"// ---------------- Base-64\n\n// Options (bitwise or'ed together) for wuffs_base__base_64__xxx functions.\n\n#define WUFFS_BASE__BASE_64__DEFAULT_OPTIONS ((uint32_t)0x00000000)\n\n// WUFFS_BASE__BASE_64__DECODE_ALLOW_PADDING means that, when decoding base-64,\n// the input may (but does not need to) be padded with '=' bytes so that the\n// overall encoded length in bytes is a multiple of 4. A successful decoding\n// will return a num_src that includes those padding bytes.\n//\n// Excess padding (e.g. three final '='s) will be rejected as bad data.\n#define WUFFS_BASE__BASE_64__DECODE_ALLOW_PADDING ((uint32_t)0x00000001)\n\n// WUFFS_BASE__BASE_64__ENCODE_EMIT_PADDING means that, when encoding base-64,\n// the output will be padded with '=' bytes so that the overall encoded length\n// in bytes is a multiple of 4.\n#define WUFFS_BASE__BASE_64__ENCODE_EMIT_PADDING ((uint32_t)0x00000002)\n\n// WUFFS_BASE__BASE_64__URL_ALPHABET means that, for base-64, the URL-friendly\n// and file-name-friendly alphabet be used, as per RFC 4648 sect"+
"ion 5. When\n// this option bit is off, the standard alphabet from section 4 is used.\n#define WUFFS_BASE__BASE_64__URL_ALPHABET ((uint32_t)0x00000100)\n\n// wuffs_base__base_64__decode transforms base-64 encoded bytes from src to\n// arbitrary bytes in dst.\n//\n// It will not permit line breaks or other whitespace in src. Filtering those\n// out is the responsibility of the caller.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_64__decode(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n// wuffs_base__base_64__encode transforms arbitrary bytes from src to base-64\n// encoded bytes in dst.\n//\n// For modular builds that divide the base module into sub-modules, using this"+
"\n// function requires the WUFFS_CONFIG__MODULE__BASE__INTCONV sub-module, not\n// just WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__transform__output //\nwuffs_base__base_64__encode(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src,\n bool src_closed,\n uint32_t options);\n\n"+
"// --------\n\n// wuffs_base__utf_8__encode writes the UTF-8 encoding of code_point to s and\n// returns the number of bytes written. If code_point is invalid, or if s is\n// shorter than the entire encoding, it returns 0 (and no bytes are written).\n//\n// s will never be too short if its length is at least 4, also known as\n// WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__utf_8__encode(wuffs_base__slice_u8 dst, uint32_t code_point);\n\n// wuffs_base__utf_8__next returns the next UTF-8 code point (and that code\n// point's byte length) at the start of the read-only slice (s_ptr, s_len).\n//\n// There are exactly two cases in which this function returns something where\n// wuffs_base__utf_8__next__output__is_valid is false:\n// - If s is empty then it returns {.code_point=0, .byte_len"+
"gth=0}.\n// - If s is non-empty and starts with invalid UTF-8 then it returns\n// {.code_point=WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER, .byte_length=1}.\n//\n// Otherwise, it returns something where\n// wuffs_base__utf_8__next__output__is_valid is true.\n//\n// In any case, it always returns an output that satisfies both of:\n// - (output.code_point <= WUFFS_BASE__UNICODE_CODE_POINT__MAX_INCL).\n// - (output.byte_length <= s_len).\n//\n// If s is a sub-slice of a larger slice of valid UTF-8, but that sub-slice\n// boundary occurs in the middle of a multi-byte UTF-8 encoding of a single\n// code point, then this function may return something invalid. It is the\n// caller's responsibility to split on or otherwise manage UTF-8 boundaries.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output //\nwuffs_base__utf_8__next("+
"const uint8_t* s_ptr, size_t s_len);\n\n// wuffs_base__utf_8__next_from_end is like wuffs_base__utf_8__next except that\n// it looks at the end of (s_ptr, s_len) instead of the start.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC wuffs_base__utf_8__next__output //\nwuffs_base__utf_8__next_from_end(const uint8_t* s_ptr, size_t s_len);\n\n// wuffs_base__utf_8__longest_valid_prefix returns the largest n such that the\n// sub-slice s[..n] is valid UTF-8, where s is the read-only slice (s_ptr,\n// s_len).\n//\n// In particular, it returns s_len if and only if all of s is valid UTF-8.\n//\n// If s is a sub-slice of a larger slice of valid UTF-8, but that sub-slice\n// boundary occurs in the middle of a multi-byte UTF-8 encoding of a single\n// code point, then this function will return less than s_len. It is the\n// caller's responsibility to split on or "+
"otherwise manage UTF-8 boundaries.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__utf_8__longest_valid_prefix(const uint8_t* s_ptr, size_t s_len);\n\n// wuffs_base__ascii__longest_valid_prefix returns the largest n such that the\n// sub-slice s[..n] is valid ASCII, where s is the read-only slice (s_ptr,\n// s_len).\n//\n// In particular, it returns s_len if and only if all of s is valid ASCII.\n// Equivalently, when none of the bytes in s have the 0x80 high bit set.\n//\n// For modular builds that divide the base module into sub-modules, using this\n// function requires the WUFFS_CONFIG__MODULE__BASE__UTF8 sub-module, not just\n// WUFFS_CONFIG__MODULE__BASE__CORE.\nWUFFS_BASE__MAYBE_STATIC size_t //\nwuffs_base__ascii__longest_valid_prefix(const uint8_t* s_ptr, size_t s_len);\n"+
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004\n\n// COMMENT_ANY is a bit-wise or of COMMENT_BLOCK AND COMMENT_LINE.\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006\n\n"+
"// --------\n\n// DEFINITELY_FOO means that the destination bytes (and also the source bytes,\n// for 1_DST_1_SRC_COPY) are in the FOO format. Definitely means that the lack\n// of the bit means \"maybe FOO\". It does not necessarily mean \"not FOO\".\n//\n// CHAIN_ETC means that decoding the entire token chain forms a UTF-8 or ASCII\n// string, not just this current token. CHAIN_ETC_UTF_8 therefore distinguishes\n// Unicode (UTF-8) strings from byte strings. MUST means that the the token\n// producer (e.g. parser) must verify this. SHOULD means that the token\n// consumer (e.g. renderer) should verify this.\n//\n// When a CHAIN_ETC_UTF_8 bit is set, the parser must ensure that non-ASCII\n// code points (with multi-byte UTF-8 encodings) do not straddle token\n// boundaries. Checking UTF-8 validity can inspect each token separately.\n//\n// The lack of any particular bit is conservative: it is valid for all-ASCII\n// strings, in a single- or multi-token chain, to have none of these bits set.\n#define WUFFS_BASE__TOKEN__VBD__STRING_"+
"_DEFINITELY_UTF_8 0x00001\n#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002\n#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_UTF_8 0x00004\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020\n#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_ASCII 0x00040\n\n// CONVERT_D_DST_S_SRC means that multiples of S source bytes (possibly padded)\n// produces multiples of D destination bytes. For example,\n// CONVERT_1_DST_4_SRC_BACKSLASH_X means a source like \"\\\\x23\\\\x67\\\\xAB\", where\n// 12 src bytes encode 3 dst bytes.\n//\n// Post-processing may further transform those D destination bytes (e.g. treat\n// \"\\\\xFF\" as the Unicode code point U+00FF instead of the byte 0xFF), but that\n// is out of scope of this VBD's semantics.\n//\n// When src is the empty string, multiple conversion algorithms are applicable\n// (so these bits are not necessarily mutually exclusive), all producing the\n// same empty dst string.\n#define WU"+
"// --------\n\n// For a source string of \"123\" or \"0x9A\", it is valid for a tokenizer to\n// return any combination of:\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT.\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED.\n// - WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED.\n//\n// For a source string of \"+123\" or \"-0x9A\", only the first two are valid.\n//\n// For a source string of \"123.\", only the first one is valid.\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED 0x00004\n\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_INF 0x00010\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_POS_INF 0x00020\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_NAN 0x00040\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_POS_NAN 0x00080\n\n// The number 300 might be represented as \"\\x01\\x2C\", \"\\x2C\\x01\\x00\\x00\" or\n// \"300\", which are big-en"+
"dian, little-endian or text. For binary formats, the\n// token length (after adjusting for FORMAT_IGNORE_ETC) discriminates\n// e.g. u16 little-endian vs u32 little-endian.\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_LITTLE_ENDIAN 0x00200\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400\n\n#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000\n\n"+
""+
"// --------\n\n// wuffs_base__token__value returns the token's high 46 bits, sign-extended. A\n// negative value means an extended token, non-negative means a simple token.\nstatic inline int64_t //\nwuffs_base__token__value(const wuffs_base__token* t) {\n return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE__SHIFT;\n}\n\n// wuffs_base__token__value_extension returns a negative value if the token was\n// not an extended token.\nstatic inline int64_t //\nwuffs_base__token__value_extension(const wuffs_base__token* t) {\n return (~(int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT;\n}\n\n// wuffs_base__token__value_major returns a negative value if the token was not\n// a simple token.\nstatic inline int64_t //\nwuffs_base__token__value_major(const wuffs_base__token* t) {\n return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT;\n}\n\n// wuffs_base__token__value_base_category returns a negative value if the token\n// was not a simple token.\nstatic inline int64_t //\nwuffs_base__token__value_base_cat"+
"egory(const wuffs_base__token* t) {\n return ((int64_t)(t->repr)) >> WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_minor(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT) & 0x1FFFFFF;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__value_base_detail(const wuffs_base__token* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT) & 0x1FFFFF;\n}\n\nstatic inline int64_t //\nwuffs_base__token__value_base_detail__sign_extended(\n const wuffs_base__token* t) {\n // The VBD is 21 bits in the middle of t->repr. Left shift the high (64 - 21\n // - ETC__SHIFT) bits off, then right shift (sign-extending) back down.\n uint64_t u = t->repr << (43 - WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT);\n return ((int64_t)u) >> 43;\n}\n\nstatic inline bool //\nwuffs_base__token__continued(const wuffs_base__token* t) {\n return t->repr & 0x10000;\n}\n\nstatic inline uint64_t //\nwuffs_base__token__length(const wuffs_base__token*"+
"// --------\n\n// wuffs_base__token_buffer_meta is the metadata for a\n// wuffs_base__token_buffer's data.\ntypedef struct wuffs_base__token_buffer_meta__struct {\n size_t wi; // Write index. Invariant: wi <= len.\n size_t ri; // Read index. Invariant: ri <= wi.\n uint64_t pos; // Position of the buffer start relative to the stream start.\n bool closed; // No further writes are expected.\n} wuffs_base__token_buffer_meta;\n\n// wuffs_base__token_buffer is a 1-dimensional buffer (a pointer and length)\n// plus additional metadata.\n//\n// A value with all fields zero is a valid, empty buffer.\ntypedef struct wuffs_base__token_buffer__struct {\n wuffs_base__slice_token data;\n wuffs_base__token_buffer_meta meta;\n\n#ifdef __cplusplus\n inline bool is_valid() const;\n inline void compact();\n inline uint64_t reader_length() const;\n inline wuffs_base__token* reader_pointer() const;\n inline wuffs_base__slice_token reader_slice() const;\n inline uint64_t reader_token_position() const;\n inline uint64_t writer_lengt"+
"// ---------------- IEEE 754 Floating Point\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u16 //\nwuffs_base__ieee_754_bit_representation__from_f64_to_u16_truncate(double f) {\n uint64_t u = 0;\n if (sizeof(uint64_t) == sizeof(double)) {\n memcpy(&u, &f, sizeof(uint64_t));\n }\n uint16_t neg = ((uint16_t)((u >> 63) << 15));\n u &= 0x7FFFFFFFFFFFFFFF;\n uint64_t exp = u >> 52;\n uint64_t man = u & 0x000FFFFFFFFFFFFF;\n\n if (exp == 0x7FF) {\n if (man == 0) { // Infinity.\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg | 0x7C00;\n ret.lossy = false;\n return ret;\n }\n // NaN. Shift the 52 mantissa bits to 10 mantissa bits, keeping the most\n // significant mantissa bit (quiet vs signaling NaNs). Also set the low 9\n // bits of ret.value so that the 10-bit mantissa is non-zero.\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg | 0x7DFF | ((uint16_t)(man >> 42));\n ret.lossy = false;\n return ret;\n\n } else if (exp > 0x40E) { // Truncate to the largest finite f16."+
"\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg | 0x7BFF;\n ret.lossy = true;\n return ret;\n\n } else if (exp <= 0x3E6) { // Truncate to zero.\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg;\n ret.lossy = (u != 0);\n return ret;\n\n } else if (exp <= 0x3F0) { // Normal f64, subnormal f16.\n // Convert from a 53-bit mantissa (after realizing the implicit bit) to a\n // 10-bit mantissa and then adjust for the exponent.\n man |= 0x0010000000000000;\n uint32_t shift = ((uint32_t)(1051 - exp)); // 1051 = 0x3F0 + 53 - 10.\n uint64_t shifted_man = man >> shift;\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg | ((uint16_t)shifted_man);\n ret.lossy = (shifted_man << shift) != man;\n return ret;\n }\n\n // Normal f64, normal f16.\n\n // Re-bias from 1023 to 15 and shift above f16's 10 mantissa bits.\n exp = (exp - 1008) << 10; // 1008 = 1023 - 15 = 0x3FF - 0xF.\n\n // Convert from a 52-bit mantissa (excluding the implicit bit) to a 10-bit\n // mantissa (again excluding"+
" the implicit bit). We lose some information if\n // any of the bottom 42 bits are non-zero.\n wuffs_base__lossy_value_u16 ret;\n ret.value = neg | ((uint16_t)exp) | ((uint16_t)(man >> 42));\n ret.lossy = (man << 22) != 0;\n return ret;\n}\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__lossy_value_u32 //\nwuffs_base__ieee_754_bit_representation__from_f64_to_u32_truncate(double f) {\n uint64_t u = 0;\n if (sizeof(uint64_t) == sizeof(double)) {\n memcpy(&u, &f, sizeof(uint64_t));\n }\n uint32_t neg = ((uint32_t)(u >> 63)) << 31;\n u &= 0x7FFFFFFFFFFFFFFF;\n uint64_t exp = u >> 52;\n uint64_t man = u & 0x000FFFFFFFFFFFFF;\n\n if (exp == 0x7FF) {\n if (man == 0) { // Infinity.\n wuffs_base__lossy_value_u32 ret;\n ret.value = neg | 0x7F800000;\n ret.lossy = false;\n return ret;\n }\n // NaN. Shift the 52 mantissa bits to 23 mantissa bits, keeping the most\n // significant mantissa bit (quiet vs signaling NaNs). Also set the low 22\n // bits of ret.value so that the 23-bit mantissa is non-zero.\n "+
" wuffs_base__lossy_value_u32 ret;\n ret.value = neg | 0x7FBFFFFF | ((uint32_t)(man >> 29));\n ret.lossy = false;\n return ret;\n\n } else if (exp > 0x47E) { // Truncate to the largest finite f32.\n wuffs_base__lossy_value_u32 ret;\n ret.value = neg | 0x7F7FFFFF;\n ret.lossy = true;\n return ret;\n\n } else if (exp <= 0x369) { // Truncate to zero.\n wuffs_base__lossy_value_u32 ret;\n ret.value = neg;\n ret.lossy = (u != 0);\n return ret;\n\n } else if (exp <= 0x380) { // Normal f64, subnormal f32.\n // Convert from a 53-bit mantissa (after realizing the implicit bit) to a\n // 23-bit mantissa and then adjust for the exponent.\n man |= 0x0010000000000000;\n uint32_t shift = ((uint32_t)(926 - exp)); // 926 = 0x380 + 53 - 23.\n uint64_t shifted_man = man >> shift;\n wuffs_base__lossy_value_u32 ret;\n ret.value = neg | ((uint32_t)shifted_man);\n ret.lossy = (shifted_man << shift) != man;\n return ret;\n }\n\n // Normal f64, normal f32.\n\n // Re-bias from 1023 to 127 and shi"+
"ft above f32's 23 mantissa bits.\n exp = (exp - 896) << 23; // 896 = 1023 - 127 = 0x3FF - 0x7F.\n\n // Convert from a 52-bit mantissa (excluding the implicit bit) to a 23-bit\n // mantissa (again excluding the implicit bit). We lose some information if\n // any of the bottom 29 bits are non-zero.\n wuffs_base__lossy_value_u32 ret;\n ret.value = neg | ((uint32_t)exp) | ((uint32_t)(man >> 29));\n ret.lossy = (man << 35) != 0;\n return ret;\n}\n\n"+
""+
"// --------\n\n#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE 2047\n#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION 800\n\n// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL is the largest N\n// such that ((10 << N) < (1 << 64)).\n#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL 60\n\n// wuffs_base__private_implementation__high_prec_dec (abbreviated as HPD) is a\n// fixed precision floating point decimal number, augmented with ±infinity\n// values, but it cannot represent NaN (Not a Number).\n//\n// \"High precision\" means that the mantissa holds 800 decimal digits. 800 is\n// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION.\n//\n// An HPD isn't for general purpose arithmetic, only for conversions to and\n// from IEEE 754 double-precision floating point, where the largest and\n// smallest positive, finite values are approximately 1.8e+308 and 4.9e-324.\n// HPD exponents above +2047 mean infinity, below -2047 mean zero. The ±2047\n// bounds are further a"+
"way from zero than ±(324 + 800), where 800 and 2047 is\n// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION and\n// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE.\n//\n// digits[.. num_digits] are the number's digits in big-endian order. The\n// uint8_t values are in the range [0 ..= 9], not ['0' ..= '9'], where e.g. '7'\n// is the ASCII value 0x37.\n//\n// decimal_point is the index (within digits) of the decimal point. It may be\n// negative or be larger than num_digits, in which case the explicit digits are\n// padded with implicit zeroes.\n//\n// For example, if num_digits is 3 and digits is \"\\x07\\x08\\x09\":\n// - A decimal_point of -2 means \".00789\"\n// - A decimal_point of -1 means \".0789\"\n// - A decimal_point of +0 means \".789\"\n// - A decimal_point of +1 means \"7.89\"\n// - A decimal_point of +2 means \"78.9\"\n// - A decimal_point of +3 means \"789.\"\n// - A decimal_point of +4 means \"7890.\"\n// - A decimal_point of +5 means \"78900.\"\n//\n// As above, a decimal_point higher than +2047"+
" means that the overall value is\n// infinity, lower than -2047 means zero.\n//\n// negative is a sign bit. An HPD can distinguish positive and negative zero.\n//\n// truncated is whether there are more than\n// WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION digits, and at\n// least one of those extra digits are non-zero. The existence of long-tail\n// digits can affect rounding.\n//\n// The \"all fields are zero\" value is valid, and represents the number +0.\ntypedef struct wuffs_base__private_implementation__high_prec_dec__struct {\n uint32_t num_digits;\n int32_t decimal_point;\n bool negative;\n bool truncated;\n uint8_t digits[WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION];\n} wuffs_base__private_implementation__high_prec_dec;\n\n// wuffs_base__private_implementation__high_prec_dec__trim trims trailing\n// zeroes from the h->digits[.. h->num_digits] slice. They have no benefit,\n// since we explicitly track h->decimal_point.\n//\n// Preconditions:\n// - h is non-NULL.\nstatic inline void //\nwuffs_bas"+
"e__private_implementation__high_prec_dec__trim(\n wuffs_base__private_implementation__high_prec_dec* h) {\n while ((h->num_digits > 0) && (h->digits[h->num_digits - 1] == 0)) {\n h->num_digits--;\n }\n}\n\n// wuffs_base__private_implementation__high_prec_dec__assign sets h to\n// represent the number x.\n//\n// Preconditions:\n// - h is non-NULL.\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__assign(\n wuffs_base__private_implementation__high_prec_dec* h,\n uint64_t x,\n bool negative) {\n uint32_t n = 0;\n\n // Set h->digits.\n if (x > 0) {\n // Calculate the digits, working right-to-left. After we determine n (how\n // many digits there are), copy from buf to h->digits.\n //\n // UINT64_MAX, 18446744073709551615, is 20 digits long. It can be faster to\n // copy a constant number of bytes than a variable number (20 instead of\n // n). Make buf large enough (and start writing to it from the middle) so\n // that can we always copy 20 bytes: the slice buf[(20-n) .. (40-n)].\n"+
" uint8_t buf[40] = {0};\n uint8_t* ptr = &buf[20];\n do {\n uint64_t remaining = x / 10;\n x -= remaining * 10;\n ptr--;\n *ptr = (uint8_t)x;\n n++;\n x = remaining;\n } while (x > 0);\n memcpy(h->digits, ptr, 20);\n }\n\n // Set h's other fields.\n h->num_digits = n;\n h->decimal_point = (int32_t)n;\n h->negative = negative;\n h->truncated = false;\n wuffs_base__private_implementation__high_prec_dec__trim(h);\n}\n\nstatic wuffs_base__status //\nwuffs_base__private_implementation__high_prec_dec__parse(\n wuffs_base__private_implementation__high_prec_dec* h,\n wuffs_base__slice_u8 s,\n uint32_t options) {\n if (!h) {\n return wuffs_base__make_status(wuffs_base__error__bad_receiver);\n }\n h->num_digits = 0;\n h->decimal_point = 0;\n h->negative = false;\n h->truncated = false;\n\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n\n if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES) {\n for (;; p++) {\n if (p >= q) {\n return wuffs_base__make_status"+
"(wuffs_base__error__bad_argument);\n } else if (*p != '_') {\n break;\n }\n }\n }\n\n // Parse sign.\n do {\n if (*p == '+') {\n p++;\n } else if (*p == '-') {\n h->negative = true;\n p++;\n } else {\n break;\n }\n if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES) {\n for (;; p++) {\n if (p >= q) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n } else if (*p != '_') {\n break;\n }\n }\n }\n } while (0);\n\n // Parse digits, up to (and including) a '.', 'E' or 'e'. Examples for each\n // limb in this if-else chain:\n // - \"0.789\"\n // - \"1002.789\"\n // - \".789\"\n // - Other (invalid input).\n uint32_t nd = 0;\n int32_t dp = 0;\n bool no_digits_before_separator = false;\n if (('0' == *p) &&\n !(options &\n WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES)) {\n p++;\n for (;; p++) {\n if (p >= q) {\n goto after_all;\n } else if (*p ==\n ("+
"// --------\n\n// wuffs_base__private_implementation__high_prec_dec__rounded_integer returns\n// the integral (non-fractional) part of h, provided that it is 18 or fewer\n// decimal digits. For 19 or more digits, it returns UINT64_MAX. Note that:\n// - (1 << 53) is 9007199254740992, which has 16 decimal digits.\n// - (1 << 56) is 72057594037927936, which has 17 decimal digits.\n// - (1 << 59) is 576460752303423488, which has 18 decimal digits.\n// - (1 << 63) is 9223372036854775808, which has 19 decimal digits.\n// and that IEEE 754 double precision has 52 mantissa bits.\n//\n// That integral part is rounded-to-even: rounding 7.5 or 8.5 both give 8.\n//\n// h's negative bit is ignored: rounding -8.6 returns 9.\n//\n// See below for preconditions.\nstatic uint64_t //\nwuffs_base__private_implementation__high_prec_dec__rounded_integer(\n wuffs_base__private_implementation__high_prec_dec* h) {\n if ((h->num_digits == 0) || (h->decimal_point < 0)) {\n return 0;\n } else if (h->decimal_point > 18) {\n return U"+
"INT64_MAX;\n }\n\n uint32_t dp = (uint32_t)(h->decimal_point);\n uint64_t n = 0;\n uint32_t i = 0;\n for (; i < dp; i++) {\n n = (10 * n) + ((i < h->num_digits) ? h->digits[i] : 0);\n }\n\n bool round_up = false;\n if (dp < h->num_digits) {\n round_up = h->digits[dp] >= 5;\n if ((h->digits[dp] == 5) && (dp + 1 == h->num_digits)) {\n // We are exactly halfway. If we're truncated, round up, otherwise round\n // to even.\n round_up = h->truncated || //\n ((dp > 0) && (1 & h->digits[dp - 1]));\n }\n }\n if (round_up) {\n n++;\n }\n\n return n;\n}\n\n// wuffs_base__private_implementation__high_prec_dec__small_xshift shifts h's\n// number (where 'x' is 'l' or 'r' for left or right) by a small shift value.\n//\n// Preconditions:\n// - h is non-NULL.\n// - h->decimal_point is \"not extreme\".\n// - shift is non-zero.\n// - shift is \"a small shift\".\n//\n// \"Not extreme\" means within\n// ±WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE.\n//\n// \"A small shift\" means not more than\n/"+
"/ WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.\n//\n// wuffs_base__private_implementation__high_prec_dec__rounded_integer and\n// wuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits\n// have the same preconditions.\n//\n// wuffs_base__private_implementation__high_prec_dec__lshift keeps the first\n// two preconditions but not the last two. Its shift argument is signed and\n// does not need to be \"small\": zero is a no-op, positive means left shift and\n// negative means right shift.\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__small_lshift(\n wuffs_base__private_implementation__high_prec_dec* h,\n uint32_t shift) {\n if (h->num_digits == 0) {\n return;\n }\n uint32_t num_new_digits =\n wuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits(\n h, shift);\n uint32_t rx = h->num_digits - 1; // Read index.\n uint32_t wx = h->num_digits - 1 + num_new_digits; // Write index.\n uint64_t n = 0;\n\n // Repeat: pick up "+
"a digit, put down a digit, right to left.\n while (((int32_t)rx) >= 0) {\n n += ((uint64_t)(h->digits[rx])) << shift;\n uint64_t quo = n / 10;\n uint64_t rem = n - (10 * quo);\n if (wx < WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->digits[wx] = (uint8_t)rem;\n } else if (rem > 0) {\n h->truncated = true;\n }\n n = quo;\n wx--;\n rx--;\n }\n\n // Put down leading digits, right to left.\n while (n > 0) {\n uint64_t quo = n / 10;\n uint64_t rem = n - (10 * quo);\n if (wx < WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->digits[wx] = (uint8_t)rem;\n } else if (rem > 0) {\n h->truncated = true;\n }\n n = quo;\n wx--;\n }\n\n // Finish.\n h->num_digits += num_new_digits;\n if (h->num_digits >\n WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->num_digits = WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION;\n }\n h->decimal_point += (int32_t)num_new_digits;\n wuffs_base__private_implementation__high_pre"+
"c_dec__trim(h);\n}\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__small_rshift(\n wuffs_base__private_implementation__high_prec_dec* h,\n uint32_t shift) {\n uint32_t rx = 0; // Read index.\n uint32_t wx = 0; // Write index.\n uint64_t n = 0;\n\n // Pick up enough leading digits to cover the first shift.\n while ((n >> shift) == 0) {\n if (rx < h->num_digits) {\n // Read a digit.\n n = (10 * n) + h->digits[rx++];\n } else if (n == 0) {\n // h's number used to be zero and remains zero.\n return;\n } else {\n // Read sufficient implicit trailing zeroes.\n while ((n >> shift) == 0) {\n n = 10 * n;\n rx++;\n }\n break;\n }\n }\n h->decimal_point -= ((int32_t)(rx - 1));\n if (h->decimal_point <\n -WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE) {\n // After the shift, h's number is effectively zero.\n h->num_digits = 0;\n h->decimal_point = 0;\n h->truncated = false;\n return;\n }\n\n // Repeat: pick up a digi"+
"t, put down a digit, left to right.\n uint64_t mask = (((uint64_t)(1)) << shift) - 1;\n while (rx < h->num_digits) {\n uint8_t new_digit = ((uint8_t)(n >> shift));\n n = (10 * (n & mask)) + h->digits[rx++];\n h->digits[wx++] = new_digit;\n }\n\n // Put down trailing digits, left to right.\n while (n > 0) {\n uint8_t new_digit = ((uint8_t)(n >> shift));\n n = 10 * (n & mask);\n if (wx < WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->digits[wx++] = new_digit;\n } else if (new_digit > 0) {\n h->truncated = true;\n }\n }\n\n // Finish.\n h->num_digits = wx;\n wuffs_base__private_implementation__high_prec_dec__trim(h);\n}\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__lshift(\n wuffs_base__private_implementation__high_prec_dec* h,\n int32_t shift) {\n if (shift > 0) {\n while (shift > +WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL) {\n wuffs_base__private_implementation__high_prec_dec__small_lshift(\n h, WUFFS_BASE__PRIVATE_I"+
"// --------\n\n// wuffs_base__private_implementation__high_prec_dec__round_etc rounds h's\n// number. For those functions that take an n argument, rounding produces at\n// most n digits (which is not necessarily at most n decimal places). Negative\n// n values are ignored, as well as any n greater than or equal to h's number\n// of digits. The etc__round_just_enough function implicitly chooses an n to\n// implement WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION.\n//\n// Preconditions:\n// - h is non-NULL.\n// - h->decimal_point is \"not extreme\".\n//\n// \"Not extreme\" means within\n// ±WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE.\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__round_down(\n wuffs_base__private_implementation__high_prec_dec* h,\n int32_t n) {\n if ((n < 0) || (h->num_digits <= (uint32_t)n)) {\n return;\n }\n h->num_digits = (uint32_t)(n);\n wuffs_base__private_implementation__high_prec_dec__trim(h);\n}\n\nstatic void //\nwuffs_base__private_implementation__hi"+
"gh_prec_dec__round_up(\n wuffs_base__private_implementation__high_prec_dec* h,\n int32_t n) {\n if ((n < 0) || (h->num_digits <= (uint32_t)n)) {\n return;\n }\n\n for (n--; n >= 0; n--) {\n if (h->digits[n] < 9) {\n h->digits[n]++;\n h->num_digits = (uint32_t)(n + 1);\n return;\n }\n }\n\n // The number is all 9s. Change to a single 1 and adjust the decimal point.\n h->digits[0] = 1;\n h->num_digits = 1;\n h->decimal_point++;\n}\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__round_nearest(\n wuffs_base__private_implementation__high_prec_dec* h,\n int32_t n) {\n if ((n < 0) || (h->num_digits <= (uint32_t)n)) {\n return;\n }\n bool up = h->digits[n] >= 5;\n if ((h->digits[n] == 5) && ((n + 1) == ((int32_t)(h->num_digits)))) {\n up = h->truncated || //\n ((n > 0) && ((h->digits[n - 1] & 1) != 0));\n }\n\n if (up) {\n wuffs_base__private_implementation__high_prec_dec__round_up(h, n);\n } else {\n wuffs_base__private_implementation__high_prec_dec__round_do"+
"wn(h, n);\n }\n}\n\nstatic void //\nwuffs_base__private_implementation__high_prec_dec__round_just_enough(\n wuffs_base__private_implementation__high_prec_dec* h,\n int32_t exp2,\n uint64_t mantissa) {\n // The magic numbers 52 and 53 in this function are because IEEE 754 double\n // precision has 52 mantissa bits.\n //\n // Let f be the floating point number represented by exp2 and mantissa (and\n // also the number in h): the number (mantissa * (2 ** (exp2 - 52))).\n //\n // If f is zero or a small integer, we can return early.\n if ((mantissa == 0) ||\n ((exp2 < 53) && (h->decimal_point >= ((int32_t)(h->num_digits))))) {\n return;\n }\n\n // The smallest normal f has an exp2 of -1022 and a mantissa of (1 << 52).\n // Subnormal numbers have the same exp2 but a smaller mantissa.\n static const int32_t min_incl_normal_exp2 = -1022;\n static const uint64_t min_incl_normal_mantissa = 0x0010000000000000ul;\n\n // Compute lower and upper bounds such that any number between them (possibly\n // inclusive) wil"+
"l round to f. First, the lower bound. Our number f is:\n // ((mantissa + 0) * (2 ** ( exp2 - 52)))\n //\n // The next lowest floating point number is:\n // ((mantissa - 1) * (2 ** ( exp2 - 52)))\n // unless (mantissa - 1) drops the (1 << 52) bit and exp2 is not the\n // min_incl_normal_exp2. Either way, call it:\n // ((l_mantissa) * (2 ** (l_exp2 - 52)))\n //\n // The lower bound is halfway between them (noting that 52 became 53):\n // (((2 * l_mantissa) + 1) * (2 ** (l_exp2 - 53)))\n int32_t l_exp2 = exp2;\n uint64_t l_mantissa = mantissa - 1;\n if ((exp2 > min_incl_normal_exp2) && (mantissa <= min_incl_normal_mantissa)) {\n l_exp2 = exp2 - 1;\n l_mantissa = (2 * mantissa) - 1;\n }\n wuffs_base__private_implementation__high_prec_dec lower;\n wuffs_base__private_implementation__high_prec_dec__assign(\n &lower, (2 * l_mantissa) + 1, false);\n wuffs_base__private_implementation__high_prec_dec__lshift(&lower,\n "+
"l_exp2 - 53);\n\n // Next, the upper bound. Our number f is:\n // ((mantissa + 0) * (2 ** (exp2 - 52)))\n //\n // The next highest floating point number is:\n // ((mantissa + 1) * (2 ** (exp2 - 52)))\n //\n // The upper bound is halfway between them (noting that 52 became 53):\n // (((2 * mantissa) + 1) * (2 ** (exp2 - 53)))\n wuffs_base__private_implementation__high_prec_dec upper;\n wuffs_base__private_implementation__high_prec_dec__assign(\n &upper, (2 * mantissa) + 1, false);\n wuffs_base__private_implementation__high_prec_dec__lshift(&upper, exp2 - 53);\n\n // The lower and upper bounds are possible outputs only if the original\n // mantissa is even, so that IEEE round-to-even would round to the original\n // mantissa and not its neighbors.\n bool inclusive = (mantissa & 1) == 0;\n\n // As we walk the digits, we want to know whether rounding up would fall\n // within the upper bound. This is tracked by upper_delta:\n // - When -1, the digits of h and upper are the same so far.\n // -"+
" When +0, we saw a difference of 1 between h and upper on a previous\n // digit and subsequently only 9s for h and 0s for upper. Thus, rounding\n // up may fall outside of the bound if !inclusive.\n // - When +1, the difference is greater than 1 and we know that rounding up\n // falls within the bound.\n //\n // This is a state machine with three states. The numerical value for each\n // state (-1, +0 or +1) isn't important, other than their order.\n int upper_delta = -1;\n\n // We can now figure out the shortest number of digits required. Walk the\n // digits until h has distinguished itself from lower or upper.\n //\n // The zi and zd variables are indexes and digits, for z in l (lower), h (the\n // number) and u (upper).\n //\n // The lower, h and upper numbers may have their decimal points at different\n // places. In this case, upper is the longest, so we iterate ui starting from\n // 0 and iterate li and hi starting from either 0 or -1.\n int32_t ui = 0;\n for (;; ui++) {\n // Calculate hd, t"+
"he middle number's digit.\n int32_t hi = ui - upper.decimal_point + h->decimal_point;\n if (hi >= ((int32_t)(h->num_digits))) {\n break;\n }\n uint8_t hd = (((uint32_t)hi) < h->num_digits) ? h->digits[hi] : 0;\n\n // Calculate ld, the lower bound's digit.\n int32_t li = ui - upper.decimal_point + lower.decimal_point;\n uint8_t ld = (((uint32_t)li) < lower.num_digits) ? lower.digits[li] : 0;\n\n // We can round down (truncate) if lower has a different digit than h or if\n // lower is inclusive and is exactly the result of rounding down (i.e. we\n // have reached the final digit of lower).\n bool can_round_down =\n (ld != hd) || //\n (inclusive && ((li + 1) == ((int32_t)(lower.num_digits))));\n\n // Calculate ud, the upper bound's digit, and update upper_delta.\n uint8_t ud = (((uint32_t)ui) < upper.num_digits) ? upper.digits[ui] : 0;\n if (upper_delta < 0) {\n if ((hd + 1) < ud) {\n // For example:\n // h = 12345???\n // upper = 12347???\n "+
" upper_delta = +1;\n } else if (hd != ud) {\n // For example:\n // h = 12345???\n // upper = 12346???\n upper_delta = +0;\n }\n } else if (upper_delta == 0) {\n if ((hd != 9) || (ud != 0)) {\n // For example:\n // h = 1234598?\n // upper = 1234600?\n upper_delta = +1;\n }\n }\n\n // We can round up if upper has a different digit than h and either upper\n // is inclusive or upper is bigger than the result of rounding up.\n bool can_round_up =\n (upper_delta > 0) || //\n ((upper_delta == 0) && //\n (inclusive || ((ui + 1) < ((int32_t)(upper.num_digits)))));\n\n // If we can round either way, round to nearest. If we can round only one\n // way, do it. If we can't round, continue the loop.\n if (can_round_down) {\n if (can_round_up) {\n wuffs_base__private_implementation__high_prec_dec__round_nearest(\n h, hi + 1);\n return;\n } else {\n wuffs_base__private_implementat"+
"ion__high_prec_dec__round_down(h,\n hi + 1);\n return;\n }\n } else {\n if (can_round_up) {\n wuffs_base__private_implementation__high_prec_dec__round_up(h, hi + 1);\n return;\n }\n }\n }\n}\n\n"+
""+
"// --------\n\n// wuffs_base__private_implementation__parse_number_f64_eisel_lemire produces\n// the IEEE 754 double-precision value for an exact mantissa and base-10\n// exponent. For example:\n// - when parsing \"12345.678e+02\", man is 12345678 and exp10 is -1.\n// - when parsing \"-12\", man is 12 and exp10 is 0. Processing the leading\n// minus sign is the responsibility of the caller, not this function.\n//\n// On success, it returns a non-negative int64_t such that the low 63 bits hold\n// the 11-bit exponent and 52-bit mantissa.\n//\n// On failure, it returns a negative value.\n//\n// The algorithm is based on an original idea by Michael Eisel that was refined\n// by Daniel Lemire. See\n// https://lemire.me/blog/2020/03/10/fast-float-parsing-in-practice/\n// and\n// https://nigeltao.github.io/blog/2020/eisel-lemire.html\n//\n// Preconditions:\n// - man is non-zero.\n// - exp10 is in the range [-307 ..= 288], the same range of the\n// wuffs_base__private_implementation__powers_of_10 array.\n//\n// The exp10 range (and th"+
"e fact that man is in the range [1 ..= UINT64_MAX],\n// approximately [1 ..= 1.85e+19]) means that (man * (10 ** exp10)) is in the\n// range [1e-307 ..= 1.85e+307]. This is entirely within the range of normal\n// (neither subnormal nor non-finite) f64 values: DBL_MIN and DBL_MAX are\n// approximately 2.23e–308 and 1.80e+308.\nstatic int64_t //\nwuffs_base__private_implementation__parse_number_f64_eisel_lemire(\n uint64_t man,\n int32_t exp10) {\n // Look up the (possibly truncated) base-2 representation of (10 ** exp10).\n // The look-up table was constructed so that it is already normalized: the\n // table entry's mantissa's MSB (most significant bit) is on.\n const uint64_t* po10 =\n &wuffs_base__private_implementation__powers_of_10[exp10 + 307][0];\n\n // Normalize the man argument. The (man != 0) precondition means that a\n // non-zero bit exists.\n uint32_t clz = wuffs_base__count_leading_zeroes_u64(man);\n man <<= clz;\n\n // Calculate the return value's base-2 exponent. We might tweak it by ±1\n //"+
" later, but its initial value comes from a linear scaling of exp10,\n // converting from power-of-10 to power-of-2, and adjusting by clz.\n //\n // The magic constants are:\n // - 1087 = 1023 + 64. The 1023 is the f64 exponent bias. The 64 is because\n // the look-up table uses 64-bit mantissas.\n // - 217706 is such that the ratio 217706 / 65536 ≈ 3.321930 is close enough\n // (over the practical range of exp10) to log(10) / log(2) ≈ 3.321928.\n // - 65536 = 1<<16 is arbitrary but a power of 2, so division is a shift.\n //\n // Equality of the linearly-scaled value and the actual power-of-2, over the\n // range of exp10 arguments that this function accepts, is confirmed by\n // script/print-mpb-powers-of-10.go\n uint64_t ret_exp2 =\n ((uint64_t)(((217706 * exp10) >> 16) + 1087)) - ((uint64_t)clz);\n\n // Multiply the two mantissas. Normalization means that both mantissas are at\n // least (1<<63), so the 128-bit product must be at least (1<<126). The high\n // 64 bits of the product, x_hi, mu"+
"st therefore be at least (1<<62).\n //\n // As a consequence, x_hi has either 0 or 1 leading zeroes. Shifting x_hi\n // right by either 9 or 10 bits (depending on x_hi's MSB) will therefore\n // leave the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on.\n wuffs_base__multiply_u64__output x = wuffs_base__multiply_u64(man, po10[1]);\n uint64_t x_hi = x.hi;\n uint64_t x_lo = x.lo;\n\n // Before we shift right by at least 9 bits, recall that the look-up table\n // entry was possibly truncated. We have so far only calculated a lower bound\n // for the product (man * e), where e is (10 ** exp10). The upper bound would\n // add a further (man * 1) to the 128-bit product, which overflows the lower\n // 64-bit limb if ((x_lo + man) < man).\n //\n // If overflow occurs, that adds 1 to x_hi. Since we're about to shift right\n // by at least 9 bits, that carried 1 can be ignored unless the higher 64-bit\n // limb's low 9 bits are all on.\n //\n // For example, parsing \"9999999999999999999\" will take the if-t"+
"rue branch\n // here, since:\n // - x_hi = 0x4563918244F3FFFF\n // - x_lo = 0x8000000000000000\n // - man = 0x8AC7230489E7FFFF\n if (((x_hi & 0x1FF) == 0x1FF) && ((x_lo + man) < man)) {\n // Refine our calculation of (man * e). Before, our approximation of e used\n // a \"low resolution\" 64-bit mantissa. Now use a \"high resolution\" 128-bit\n // mantissa. We've already calculated x = (man * bits_0_to_63_incl_of_e).\n // Now calculate y = (man * bits_64_to_127_incl_of_e).\n wuffs_base__multiply_u64__output y = wuffs_base__multiply_u64(man, po10[0]);\n uint64_t y_hi = y.hi;\n uint64_t y_lo = y.lo;\n\n // Merge the 128-bit x and 128-bit y, which overlap by 64 bits, to\n // calculate the 192-bit product of the 64-bit man by the 128-bit e.\n // As we exit this if-block, we only care about the high 128 bits\n // (merged_hi and merged_lo) of that 192-bit product.\n //\n // For example, parsing \"1.234e-45\" will take the if-true branch here,\n // since:\n // - x_hi = 0x70B7E3696DB29FFF\n"+
" // - x_lo = 0xE040000000000000\n // - y_hi = 0x33718BBEAB0E0D7A\n // - y_lo = 0xA880000000000000\n uint64_t merged_hi = x_hi;\n uint64_t merged_lo = x_lo + y_hi;\n if (merged_lo < x_lo) {\n merged_hi++; // Carry the overflow bit.\n }\n\n // The \"high resolution\" approximation of e is still a lower bound. Once\n // again, see if the upper bound is large enough to produce a different\n // result. This time, if it does, give up instead of reaching for an even\n // more precise approximation to e.\n //\n // This three-part check is similar to the two-part check that guarded the\n // if block that we're now in, but it has an extra term for the middle 64\n // bits (checking that adding 1 to merged_lo would overflow).\n //\n // For example, parsing \"5.9604644775390625e-8\" will take the if-true\n // branch here, since:\n // - merged_hi = 0x7FFFFFFFFFFFFFFF\n // - merged_lo = 0xFFFFFFFFFFFFFFFF\n // - y_lo = 0x4DB3FFC120988200\n // - man = 0xD3C21BCEC"+
"CEDA100\n if (((merged_hi & 0x1FF) == 0x1FF) && ((merged_lo + 1) == 0) &&\n (y_lo + man < man)) {\n return -1;\n }\n\n // Replace the 128-bit x with merged.\n x_hi = merged_hi;\n x_lo = merged_lo;\n }\n\n // As mentioned above, shifting x_hi right by either 9 or 10 bits will leave\n // the top 10 MSBs (bits 54 ..= 63) off and the 11th MSB (bit 53) on. If the\n // MSB (before shifting) was on, adjust ret_exp2 for the larger shift.\n //\n // Having bit 53 on (and higher bits off) means that ret_mantissa is a 54-bit\n // number.\n uint64_t msb = x_hi >> 63;\n uint64_t ret_mantissa = x_hi >> (msb + 9);\n ret_exp2 -= 1 ^ msb;\n\n // IEEE 754 rounds to-nearest with ties rounded to-even. Rounding to-even can\n // be tricky. If we're half-way between two exactly representable numbers\n // (x's low 73 bits are zero and the next 2 bits that matter are \"01\"), give\n // up instead of trying to pick the winner.\n //\n // Technically, we could tighten the condition by changing \"73\" to \"73 or 74,\n // depen"+
"ding on msb\", but a flat \"73\" is simpler.\n //\n // For example, parsing \"1e+23\" will take the if-true branch here, since:\n // - x_hi = 0x54B40B1F852BDA00\n // - ret_mantissa = 0x002A5A058FC295ED\n if ((x_lo == 0) && ((x_hi & 0x1FF) == 0) && ((ret_mantissa & 3) == 1)) {\n return -1;\n }\n\n // If we're not halfway then it's rounding to-nearest. Starting with a 54-bit\n // number, carry the lowest bit (bit 0) up if it's on. Regardless of whether\n // it was on or off, shifting right by one then produces a 53-bit number. If\n // carrying up overflowed, shift again.\n ret_mantissa += ret_mantissa & 1;\n ret_mantissa >>= 1;\n // This if block is equivalent to (but benchmarks slightly faster than) the\n // following branchless form:\n // uint64_t overflow_adjustment = ret_mantissa >> 53;\n // ret_mantissa >>= overflow_adjustment;\n // ret_exp2 += overflow_adjustment;\n //\n // For example, parsing \"7.2057594037927933e+16\" will take the if-true\n // branch here, since:\n // - x_hi ="+
" 0x7FFFFFFFFFFFFE80\n // - ret_mantissa = 0x0020000000000000\n if ((ret_mantissa >> 53) > 0) {\n ret_mantissa >>= 1;\n ret_exp2++;\n }\n\n // Starting with a 53-bit number, IEEE 754 double-precision normal numbers\n // have an implicit mantissa bit. Mask that away and keep the low 52 bits.\n ret_mantissa &= 0x000FFFFFFFFFFFFF;\n\n // Pack the bits and return.\n return ((int64_t)(ret_mantissa | (ret_exp2 << 52)));\n}\n\n"+
""+
"// --------\n\nstatic wuffs_base__result_f64 //\nwuffs_base__private_implementation__parse_number_f64_special(\n wuffs_base__slice_u8 s,\n uint32_t options) {\n do {\n if (options & WUFFS_BASE__PARSE_NUMBER_FXX__REJECT_INF_AND_NAN) {\n goto fail;\n }\n\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p >= q) {\n goto fail;\n }\n\n // Parse sign.\n bool negative = false;\n do {\n if (*p == '+') {\n p++;\n } else if (*p == '-') {\n negative = true;\n p++;\n } else {\n break;\n }\n for (; (p < q) && (*p == '_'); p++) {\n }\n } while (0);\n if (p >= q) {\n goto fail;\n }\n\n bool nan = false;\n switch (p[0]) {\n case 'I':\n case 'i':\n if (((q - p) < 3) || //\n ((p[1] != 'N') && (p[1] != 'n')) || //\n ((p[2] != 'F') && (p[2] != 'f'))) {\n goto fail;\n }\n p += 3;\n\n if ((p >= q) || (*p == '_"+
" ret.status.repr = NULL;\n ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n (nan ? 0x7FFFFFFFFFFFFFFF : 0x7FF0000000000000) |\n (negative ? 0x8000000000000000 : 0));\n return ret;\n } while (0);\n\nfail:\n do {\n wuffs_base__result_f64 ret;\n ret.status.repr = wuffs_base__error__bad_argument;\n ret.value = 0;\n return ret;\n } while (0);\n}\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__result_f64 //\nwuffs_base__private_implementation__high_prec_dec__to_f64(\n wuffs_base__private_implementation__high_prec_dec* h,\n uint32_t options) {\n do {\n // powers converts decimal powers of 10 to binary powers of 2. For example,\n // (10000 >> 13) is 1. It stops before the elements exceed 60, also known\n // as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.\n static const uint32_t num_powers = 19;\n static const uint8_t powers[19] = {\n 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //\n 33, 36, 39, 43, 46, 49, 53, 56, 59, //\n };\n\n // Handl"+
"e zero and obvious extremes. The largest and smallest positive\n // finite f64 values are approximately 1.8e+308 and 4.9e-324.\n if ((h->num_digits == 0) || (h->decimal_point < -326)) {\n goto zero;\n } else if (h->decimal_point > 310) {\n goto infinity;\n }\n\n // Try the fast Eisel-Lemire algorithm again. Calculating the (man, exp10)\n // pair from the high_prec_dec h is more correct but slower than the\n // approach taken in wuffs_base__parse_number_f64. The latter is optimized\n // for the common cases (e.g. assuming no underscores or a leading '+'\n // sign) rather than the full set of cases allowed by the Wuffs API.\n if (h->num_digits <= 19) {\n uint64_t man = 0;\n uint32_t i;\n for (i = 0; i < h->num_digits; i++) {\n man = (10 * man) + h->digits[i];\n }\n int32_t exp10 = h->decimal_point - ((int32_t)(h->num_digits));\n if ((man != 0) && (-307 <= exp10) && (exp10 <= 288)) {\n int64_t r =\n wuffs_base__private_implementation__parse"+
"_number_f64_eisel_lemire(\n man, exp10);\n if (r >= 0) {\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n ((uint64_t)r) | (((uint64_t)(h->negative)) << 63));\n return ret;\n }\n }\n }\n\n // When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See\n // https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html\n //\n // Scale by powers of 2 until we're in the range [½ .. 1], which gives us\n // our exponent (in base-2). First we shift right, possibly a little too\n // far, ending with a value certainly below 1 and possibly below ½...\n const int32_t f64_bias = -1023;\n int32_t exp2 = 0;\n while (h->decimal_point > 0) {\n uint32_t n = (uint32_t)(+h->decimal_point);\n uint32_t shift =\n (n < num_powers)\n ? powers[n]\n : WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;\n\n "+
" wuffs_base__private_implementation__high_prec_dec__small_rshift(h, shift);\n if (h->decimal_point <\n -WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE) {\n goto zero;\n }\n exp2 += (int32_t)shift;\n }\n // ...then we shift left, putting us in [½ .. 1].\n while (h->decimal_point <= 0) {\n uint32_t shift;\n if (h->decimal_point == 0) {\n if (h->digits[0] >= 5) {\n break;\n }\n shift = (h->digits[0] < 2) ? 2 : 1;\n } else {\n uint32_t n = (uint32_t)(-h->decimal_point);\n shift = (n < num_powers)\n ? powers[n]\n : WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;\n }\n\n wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);\n if (h->decimal_point >\n +WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE) {\n goto infinity;\n }\n exp2 -= (int32_t)shift;\n }\n\n // We're in the range [½ .. 1] but f64 uses "+
"[1 .. 2].\n exp2--;\n\n // The minimum normal exponent is (f64_bias + 1).\n while ((f64_bias + 1) > exp2) {\n uint32_t n = (uint32_t)((f64_bias + 1) - exp2);\n if (n > WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL) {\n n = WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;\n }\n wuffs_base__private_implementation__high_prec_dec__small_rshift(h, n);\n exp2 += (int32_t)n;\n }\n\n // Check for overflow.\n if ((exp2 - f64_bias) >= 0x07FF) { // (1 << 11) - 1.\n goto infinity;\n }\n\n // Extract 53 bits for the mantissa (in base-2).\n wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53);\n uint64_t man2 =\n wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);\n\n // Rounding might have added one bit. If so, shift and re-check overflow.\n if ((man2 >> 53) != 0) {\n man2 >>= 1;\n exp2++;\n if ((exp2 - f64_bias) >= 0x07FF) { // (1 << 11) - 1.\n goto infinity;\n }\n }\n\n // Handle su"+
";\n ret.value = 0;\n return ret;\n }\n\n uint64_t bits = h->negative ? 0xFFF0000000000000 : 0x7FF0000000000000;\n\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(bits);\n return ret;\n } while (0);\n}\n\nstatic inline bool //\nwuffs_base__private_implementation__is_decimal_digit(uint8_t c) {\n return ('0' <= c) && (c <= '9');\n}\n\nWUFFS_BASE__MAYBE_STATIC wuffs_base__result_f64 //\nwuffs_base__parse_number_f64(wuffs_base__slice_u8 s, uint32_t options) {\n // In practice, almost all \"dd.ddddE±xxx\" numbers can be represented\n // losslessly by a uint64_t mantissa \"dddddd\" and an int32_t base-10\n // exponent, adjusting \"xxx\" for the position (if present) of the decimal\n // separator '.' or ','.\n //\n // This (u64 man, i32 exp10) data structure is superficially similar to the\n // \"Do It Yourself Floating Point\" type from Loitsch (†), but the exponent\n // here is base-10, not base-2.\n //\n // If s's number fits in "+
"a (man, exp10), parse that pair with the\n // Eisel-Lemire algorithm. If not, or if Eisel-Lemire fails, parsing s with\n // the fallback algorithm is slower but comprehensive.\n //\n // † \"Printing Floating-Point Numbers Quickly and Accurately with Integers\"\n // (https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf).\n // Florian Loitsch is also the primary contributor to\n // https://github.com/google/double-conversion\n do {\n // Calculating that (man, exp10) pair needs to stay within s's bounds.\n // Provided that s isn't extremely long, work on a NUL-terminated copy of\n // s's contents. The NUL byte isn't a valid part of \"±dd.ddddE±xxx\".\n //\n // As the pointer p walks the contents, it's faster to repeatedly check \"is\n // *p a valid digit\" than \"is p within bounds and *p a valid digit\".\n if (s.len >= 256) {\n goto fallback;\n }\n uint8_t z[256];\n memcpy(&z[0], s.ptr, s.len);\n z[s.len] = 0;\n const uint8_t* p = &z[0];\n\n // Look for a leading minus "+
"sign. Technically, we could also look for an\n // optional plus sign, but the \"script/process-json-numbers.c with -p\"\n // benchmark is noticably slower if we do. It's optional and, in practice,\n // usually absent. Let the fallback catch it.\n bool negative = (*p == '-');\n if (negative) {\n p++;\n }\n\n // After walking \"dd.dddd\", comparing p later with p now will produce the\n // number of \"d\"s and \".\"s.\n const uint8_t* const start_of_digits_ptr = p;\n\n // Walk the \"d\"s before a '.', 'E', NUL byte, etc. If it starts with '0',\n // it must be a single '0'. If it starts with a non-zero decimal digit, it\n // can be a sequence of decimal digits.\n //\n // Update the man variable during the walk. It's OK if man overflows now.\n // We'll detect that later.\n uint64_t man;\n if (*p == '0') {\n man = 0;\n p++;\n if (wuffs_base__private_implementation__is_decimal_digit(*p)) {\n goto fallback;\n }\n } else if (wuffs_base__private_implementation__is_decim"+
"al_digit(*p)) {\n man = ((uint8_t)(*p - '0'));\n p++;\n for (; wuffs_base__private_implementation__is_decimal_digit(*p); p++) {\n man = (10 * man) + ((uint8_t)(*p - '0'));\n }\n } else {\n goto fallback;\n }\n\n // Walk the \"d\"s after the optional decimal separator ('.' or ','),\n // updating the man and exp10 variables.\n int32_t exp10 = 0;\n if (*p ==\n ((options & WUFFS_BASE__PARSE_NUMBER_FXX__DECIMAL_SEPARATOR_IS_A_COMMA)\n ? ','\n : '.')) {\n p++;\n const uint8_t* first_after_separator_ptr = p;\n if (!wuffs_base__private_implementation__is_decimal_digit(*p)) {\n goto fallback;\n }\n man = (10 * man) + ((uint8_t)(*p - '0'));\n p++;\n for (; wuffs_base__private_implementation__is_decimal_digit(*p); p++) {\n man = (10 * man) + ((uint8_t)(*p - '0'));\n }\n exp10 = ((int32_t)(first_after_separator_ptr - p));\n }\n\n // Count the number of digits:\n // - for an input of \"314159\", digit_count "+
"is 6.\n // - for an input of \"3.14159\", digit_count is 7.\n //\n // This is off-by-one if there is a decimal separator. That's OK for now.\n // We'll correct for that later. The \"script/process-json-numbers.c with\n // -p\" benchmark is noticably slower if we try to correct for that now.\n uint32_t digit_count = (uint32_t)(p - start_of_digits_ptr);\n\n // Update exp10 for the optional exponent, starting with 'E' or 'e'.\n if ((*p | 0x20) == 'e') {\n p++;\n int32_t exp_sign = +1;\n if (*p == '-') {\n p++;\n exp_sign = -1;\n } else if (*p == '+') {\n p++;\n }\n if (!wuffs_base__private_implementation__is_decimal_digit(*p)) {\n goto fallback;\n }\n int32_t exp_num = ((uint8_t)(*p - '0'));\n p++;\n // The rest of the exp_num walking has a peculiar control flow but, once\n // again, the \"script/process-json-numbers.c with -p\" benchmark is\n // sensitive to alternative formulations.\n if (wuffs_base__private_implementation__i"+
"s_decimal_digit(*p)) {\n exp_num = (10 * exp_num) + ((uint8_t)(*p - '0'));\n p++;\n }\n if (wuffs_base__private_implementation__is_decimal_digit(*p)) {\n exp_num = (10 * exp_num) + ((uint8_t)(*p - '0'));\n p++;\n }\n while (wuffs_base__private_implementation__is_decimal_digit(*p)) {\n if (exp_num > 0x1000000) {\n goto fallback;\n }\n exp_num = (10 * exp_num) + ((uint8_t)(*p - '0'));\n p++;\n }\n exp10 += exp_sign * exp_num;\n }\n\n // The Wuffs API is that the original slice has no trailing data. It also\n // allows underscores, which we don't catch here but the fallback should.\n if (p != &z[s.len]) {\n goto fallback;\n }\n\n // Check that the uint64_t typed man variable has not overflowed, based on\n // digit_count.\n //\n // For reference:\n // - (1 << 63) is 9223372036854775808, which has 19 decimal digits.\n // - (1 << 64) is 18446744073709551616, which has 20 decimal digits.\n // - 19 nines, "+
" 9999999999999999999, is 0x8AC7230489E7FFFF, which has 64\n // bits and 16 hexadecimal digits.\n // - 20 nines, 99999999999999999999, is 0x56BC75E2D630FFFFF, which has 67\n // bits and 17 hexadecimal digits.\n if (digit_count > 19) {\n // Even if we have more than 19 pseudo-digits, it's not yet definitely an\n // overflow. Recall that digit_count might be off-by-one (too large) if\n // there's a decimal separator. It will also over-report the number of\n // meaningful digits if the input looks something like \"0.000dddExxx\".\n //\n // We adjust by the number of leading '0's and '.'s and re-compare to 19.\n // Once again, technically, we could skip ','s too, but that perturbs the\n // \"script/process-json-numbers.c with -p\" benchmark.\n const uint8_t* q = start_of_digits_ptr;\n for (; (*q == '0') || (*q == '.'); q++) {\n }\n digit_count -= (uint32_t)(q - start_of_digits_ptr);\n if (digit_count > 19) {\n goto fallback;\n }\n }\n\n "+
" // The wuffs_base__private_implementation__parse_number_f64_eisel_lemire\n // preconditions include that exp10 is in the range [-307 ..= 288].\n if ((exp10 < -307) || (288 < exp10)) {\n goto fallback;\n }\n\n // If both man and (10 ** exp10) are exactly representable by a double, we\n // don't need to run the Eisel-Lemire algorithm.\n if ((-22 <= exp10) && (exp10 <= 22) && ((man >> 53) == 0)) {\n double d = (double)man;\n if (exp10 >= 0) {\n d *= wuffs_base__private_implementation__f64_powers_of_10[+exp10];\n } else {\n d /= wuffs_base__private_implementation__f64_powers_of_10[-exp10];\n }\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = negative ? -d : +d;\n return ret;\n }\n\n // The wuffs_base__private_implementation__parse_number_f64_eisel_lemire\n // preconditions include that man is non-zero. Parsing \"0\" should be caught\n // by the \"If both man and (10 ** exp10)\" above, but \"0e99\" might not.\n if (man == 0) {\n "+
" goto fallback;\n }\n\n // Our man and exp10 are in range. Run the Eisel-Lemire algorithm.\n int64_t r =\n wuffs_base__private_implementation__parse_number_f64_eisel_lemire(\n man, exp10);\n if (r < 0) {\n goto fallback;\n }\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n ((uint64_t)r) | (((uint64_t)negative) << 63));\n return ret;\n } while (0);\n\nfallback:\n do {\n wuffs_base__private_implementation__high_prec_dec h;\n wuffs_base__status status =\n wuffs_base__private_implementation__high_prec_dec__parse(&h, s,\n options);\n if (status.repr) {\n return wuffs_base__private_implementation__parse_number_f64_special(\n s, options);\n }\n return wuffs_base__private_implementation__high_prec_dec__to_f64(&h,\n options);\n } while (0);\n"+
"tivity (1 bit), base-2 exponent (11 bits\n // with a -1023 bias) and mantissa (52 bits).\n uint64_t bits = wuffs_base__ieee_754_bit_representation__from_f64_to_u64(x);\n bool neg = (bits >> 63) != 0;\n int32_t exp2 = ((int32_t)(bits >> 52)) & 0x7FF;\n uint64_t man = bits & 0x000FFFFFFFFFFFFFul;\n\n // Apply the exponent bias and set the implicit top bit of the mantissa,\n // unless x is subnormal. Also take care of Inf and NaN.\n if (exp2 == 0x7FF) {\n if (man != 0) {\n return wuffs_base__private_implementation__render_nan(dst);\n }\n return wuffs_base__private_implementation__render_inf(dst, neg, options);\n } else if (exp2 == 0) {\n exp2 = -1022;\n } else {\n exp2 -= 1023;\n man |= 0x0010000000000000ul;\n }\n\n // Ensure that precision isn't too large.\n if (precision > 4095) {\n precision = 4095;\n }\n\n // Convert from the (neg, exp2, man) tuple to an HPD.\n wuffs_base__private_implementation__high_prec_dec h;\n wuffs_base__private_implementation__high_prec_dec__assign(&h, man, neg);\n if ("+
"h.num_digits > 0) {\n wuffs_base__private_implementation__high_prec_dec__lshift(\n &h, exp2 - 52); // 52 mantissa bits.\n }\n\n // Handle the \"%e\" and \"%f\" formats.\n switch (options & (WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT |\n WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_PRESENT)) {\n case WUFFS_BASE__RENDER_NUMBER_FXX__EXPONENT_ABSENT: // The \"%\"f\" format.\n if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {\n wuffs_base__private_implementation__high_prec_dec__round_just_enough(\n &h, exp2, man);\n int32_t p = ((int32_t)(h.num_digits)) - h.decimal_point;\n precision = ((uint32_t)(wuffs_base__i32__max(0, p)));\n } else {\n wuffs_base__private_implementation__high_prec_dec__round_nearest(\n &h, ((int32_t)precision) + h.decimal_point);\n }\n return wuffs_base__private_implementation__high_prec_dec__render_exponent_absent(\n dst, &h, precision, options);\n\n case WUFFS_BASE__RENDER_NUMBER_FX"+
"X__EXPONENT_PRESENT: // The \"%e\" format.\n if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {\n wuffs_base__private_implementation__high_prec_dec__round_just_enough(\n &h, exp2, man);\n precision = (h.num_digits > 0) ? (h.num_digits - 1) : 0;\n } else {\n wuffs_base__private_implementation__high_prec_dec__round_nearest(\n &h, ((int32_t)precision) + 1);\n }\n return wuffs_base__private_implementation__high_prec_dec__render_exponent_present(\n dst, &h, precision, options);\n }\n\n // We have the \"%g\" format and so precision means the number of significant\n // digits, not the number of digits after the decimal separator. Perform\n // rounding and determine whether to use \"%e\" or \"%f\".\n int32_t e_threshold = 0;\n if (options & WUFFS_BASE__RENDER_NUMBER_FXX__JUST_ENOUGH_PRECISION) {\n wuffs_base__private_implementation__high_prec_dec__round_just_enough(\n &h, exp2, man);\n precision = h.num_digits;\n e_threshold = 6;\n }"+
" else {\n if (precision == 0) {\n precision = 1;\n }\n wuffs_base__private_implementation__high_prec_dec__round_nearest(\n &h, ((int32_t)precision));\n e_threshold = ((int32_t)precision);\n int32_t nd = ((int32_t)(h.num_digits));\n if ((e_threshold > nd) && (nd >= h.decimal_point)) {\n e_threshold = nd;\n }\n }\n\n // Use the \"%e\" format if the exponent is large.\n int32_t e = h.decimal_point - 1;\n if ((e < -4) || (e_threshold <= e)) {\n uint32_t p = wuffs_base__u32__min(precision, h.num_digits);\n return wuffs_base__private_implementation__high_prec_dec__render_exponent_present(\n dst, &h, (p > 0) ? (p - 1) : 0, options);\n }\n\n // Use the \"%f\" format otherwise.\n int32_t p = ((int32_t)precision);\n if (p > h.decimal_point) {\n p = ((int32_t)(h.num_digits));\n }\n precision = ((uint32_t)(wuffs_base__i32__max(0, p - h.decimal_point)));\n return wuffs_base__private_implementation__high_prec_dec__render_exponent_absent(\n dst, &h, precision, options);\n}\n"+
""
constBaseFloatConvSubmoduleDataC=""+
"// ---------------- IEEE 754 Floating Point\n\n// The etc__hpd_left_shift and etc__powers_of_5 tables were printed by\n// script/print-hpd-left-shift.go. That script has an optional -comments flag,\n// whose output is not copied here, which prints further detail.\n//\n// These tables are used in\n// wuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits.\n\n// wuffs_base__private_implementation__hpd_left_shift[i] encodes the number of\n// new digits created after multiplying a positive integer by (1 << i): the\n// additional length in the decimal representation. For example, shifting \"234\"\n// by 3 (equivalent to multiplying by 8) will produce \"1872\". Going from a\n// 3-length string to a 4-length string means that 1 new digit was added (and\n// existing digits may have changed).\n//\n// Shifting by i can add either N or N-1 new digits, depending on whether the\n// original positive integer compares >= or < to the i'th power of 5 (as 10\n// equals 2 * 5). Comparison is lexicographic, not numerical.\n//\n// For "+
"example, shifting by 4 (i.e. multiplying by 16) can add 1 or 2 new\n// digits, depending on a lexicographic comparison to (5 ** 4), i.e. \"625\":\n// - (\"1\" << 4) is \"16\", which adds 1 new digit.\n// - (\"5678\" << 4) is \"90848\", which adds 1 new digit.\n// - (\"624\" << 4) is \"9984\", which adds 1 new digit.\n// - (\"62498\" << 4) is \"999968\", which adds 1 new digit.\n// - (\"625\" << 4) is \"10000\", which adds 2 new digits.\n// - (\"625001\" << 4) is \"10000016\", which adds 2 new digits.\n// - (\"7008\" << 4) is \"112128\", which adds 2 new digits.\n// - (\"99\" << 4) is \"1584\", which adds 2 new digits.\n//\n// Thus, when i is 4, N is 2 and (5 ** i) is \"625\". This etc__hpd_left_shift\n// array encodes this as:\n// - etc__hpd_left_shift[4] is 0x1006 = (2 << 11) | 0x0006.\n// - etc__hpd_left_shift[5] is 0x1009 = (? << 11) | 0x0009.\n// where the ? isn't relevant for i == 4.\n//\n// The high 5 bits of etc__hpd_left_shift[i] is N, the higher of the two\n// possible number of new digits. The low 1"+
"1 bits are an offset into the\n// etc__powers_of_5 array (of length 0x051C, so offsets fit in 11 bits). When i\n// is 4, its offset and the next one is 6 and 9, and etc__powers_of_5[6 .. 9]\n// is the string \"\\x06\\x02\\x05\", so the relevant power of 5 is \"625\".\n//\n// Thanks to Ken Thompson for the original idea.\nstatic const uint16_t wuffs_base__private_implementation__hpd_left_shift[65] = {\n 0x0000, 0x0800, 0x0801, 0x0803, 0x1006, 0x1009, 0x100D, 0x1812, 0x1817,\n 0x181D, 0x2024, 0x202B, 0x2033, 0x203C, 0x2846, 0x2850, 0x285B, 0x3067,\n 0x3073, 0x3080, 0x388E, 0x389C, 0x38AB, 0x38BB, 0x40CC, 0x40DD, 0x40EF,\n 0x4902, 0x4915, 0x4929, 0x513E, 0x5153, 0x5169, 0x5180, 0x5998, 0x59B0,\n 0x59C9, 0x61E3, 0x61FD, 0x6218, 0x6A34, 0x6A50, 0x6A6D, 0x6A8B, 0x72AA,\n 0x72C9, 0x72E9, 0x7B0A, 0x7B2B, 0x7B4D, 0x8370, 0x8393, 0x83B7, 0x83DC,\n 0x8C02, 0x8C28, 0x8C4F, 0x9477, 0x949F, 0x94C8, 0x9CF2, 0x051C, 0x051C,\n 0x051C, 0x051C,\n};\n\n// wuffs_base__private_implementation__powers_of_5 contains the powers of 5,\n"+
"// --------\n\n// wuffs_base__private_implementation__powers_of_10 contains truncated\n// approximations to the powers of 10, ranging from 1e-307 to 1e+288 inclusive,\n// as 596 pairs of uint64_t values (a 128-bit mantissa).\n//\n// There's also an implicit third column (implied by a linear formula involving\n// the base-10 exponent) that is the base-2 exponent, biased by a magic\n// constant. That constant (1214 or 0x04BE) equals 1023 + 191. 1023 is the bias\n// for IEEE 754 double-precision floating point. 191 is ((3 * 64) - 1) and\n// wuffs_base__private_implementation__parse_number_f64_eisel_lemire works with\n// multiples-of-64-bit mantissas.\n//\n// For example, the third row holds the approximation to 1e-305:\n// 0xE0B62E29_29ABA83C_331ACDAB_FE94DE87 * (2 ** (0x0049 - 0x04BE))\n//\n// Similarly, 1e+4 is approximated by:\n// 0x9C400000_00000000_00000000_00000000 * (2 ** (0x044C - 0x04BE))\n//\n// Similarly, 1e+68 is approximated by:\n// 0xED63A231_D4C4FB27_4CA7AAA8_63EE4BDD * (2 ** (0x0520 - 0x04BE))\n//\n// This table"+
" size_t src_len8 = src_len / 8;\n size_t len = (dst_len4 < src_len8) ? dst_len4 : src_len8;\n uint8_t* d = dst_ptr;\n const uint8_t* s = src_ptr;\n size_t n = len;\n\n while (n >= 1) {\n uint64_t d0 = wuffs_base__color_u32__as__color_u64(\n wuffs_base__peek_u32le__no_bounds_check(d + (0 * 4)));\n uint64_t s0 = wuffs_base__swap_u64_argb_abgr(\n wuffs_base__peek_u64le__no_bounds_check(s + (0 * 8)));\n wuffs_base__poke_u32le__no_bounds_check(\n d + (0 * 4),\n wuffs_base__color_u64__as__color_u32(\n wuffs_base__composite_nonpremul_nonpremul_u64_axxx(d0, s0)));\n\n s += 1 * 8;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\n"+
""+
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__rgbw__bgr_565(uint8_t* dst_ptr,\n size_t dst_len,\n uint8_t* dst_palette_ptr,\n size_t dst_palette_len,\n const uint8_t* src_ptr,\n size_t src_len) {\n size_t dst_len4 = dst_len / 4;\n size_t src_len2 = src_len / 2;\n size_t len = (dst_len4 < src_len2) ? dst_len4 : src_len2;\n uint8_t* d = dst_ptr;\n const uint8_t* s = src_ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n wuffs_base__poke_u32le__no_bounds_check(\n d + (0 * 4),\n wuffs_base__swap_u32_argb_abgr(\n wuffs_base__color_u16_rgb_565__as__color_u32_argb_premul(\n wuffs_base__peek_u16le__no_bounds_check(s + (0 * 2)))));\n\n s += 1 * 2;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\n"+
""+
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxx__index__src(uint8_t* dst_ptr,\n size_t dst_len,\n uint8_t* dst_palette_ptr,\n size_t dst_palette_len,\n const uint8_t* src_ptr,\n size_t src_len) {\n if (dst_palette_len !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return 0;\n }\n size_t dst_len3 = dst_len / 3;\n size_t len = (dst_len3 < src_len) ? dst_len3 : src_len;\n uint8_t* d = dst_ptr;\n const uint8_t* s = src_ptr;\n size_t n = len;\n\n const size_t loop_unroll_count = 4;\n\n // The comparison in the while condition is \">\", not \">=\", because with\n // \">=\", the last 4-byte store could write past the end of the dst slice.\n //\n // Each 4-byte store writes one too many bytes, but a subsequent store\n // will overwrite that with the correct byte. There is always"+
" another\n // store, whether a 4-byte store in this loop or a 1-byte store in the\n // next loop.\n while (n > loop_unroll_count) {\n wuffs_base__poke_u32le__no_bounds_check(\n d + (0 * 3), wuffs_base__peek_u32le__no_bounds_check(\n dst_palette_ptr + ((size_t)s[0] * 4)));\n wuffs_base__poke_u32le__no_bounds_check(\n d + (1 * 3), wuffs_base__peek_u32le__no_bounds_check(\n dst_palette_ptr + ((size_t)s[1] * 4)));\n wuffs_base__poke_u32le__no_bounds_check(\n d + (2 * 3), wuffs_base__peek_u32le__no_bounds_check(\n dst_palette_ptr + ((size_t)s[2] * 4)));\n wuffs_base__poke_u32le__no_bounds_check(\n d + (3 * 3), wuffs_base__peek_u32le__no_bounds_check(\n dst_palette_ptr + ((size_t)s[3] * 4)));\n\n s += loop_unroll_count * 1;\n d += loop_unroll_count * 3;\n n -= loop_unroll_count;\n }\n\n while (n >= 1) {\n uint32_t s0 = wuffs_base__peek_u32le__no_bounds_check(dst_palette_ptr +\n "+
"// --------\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__y(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__Y:\n return wuffs_base__pixel_swizzler__copy_1_1;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n return wuffs_base__pixel_swizzler__bgr_565__y;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n return wuffs_base__pixel_swizzler__xxx__y;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BA"+
"SE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__xxxx__y__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__xxxx__y;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__xxxxxxxx__y;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__y_16be(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n "+
" wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__Y:\n return wuffs_base__pixel_swizzler__y__y_16be;\n\n case WUFFS_BASE__PIXEL_FORMAT__Y_16LE:\n return wuffs_base__pixel_swizzler__y_16le__y_16be;\n\n case WUFFS_BASE__PIXEL_FORMAT__Y_16BE:\n return wuffs_base__pixel_swizzler__copy_2_2;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n return wuffs_base__pixel_swizzler__bgr_565__y_16be;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n return wuffs_base__pixel_swizzler__xxx__y_16be;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__pixel_swizzler__xxx"+
"x__y_16be;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__xxxxxxxx__y_16be;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__indexed__bgra_nonpremul(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__copy_1_1;\n }\n return NULL;"+
"\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n if (wuffs_base__pixel_swizzler__squash_align4_bgr_565_8888(\n dst_palette.ptr, dst_palette.len, src_palette.ptr,\n src_palette.len, true) !=\n (WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH / 4)) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__bgr_565__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__bgr_565__index_bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n if (wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src(\n "+
" dst_palette.ptr, dst_palette.len, NULL, 0, src_palette.ptr,\n src_palette.len) !=\n (WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH / 4)) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__xxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__xxx__index_bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__xxxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_O"+
"VER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__index_bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__xxxxxxxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__index_bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n if (wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src(\n dst_palette.ptr, dst_palette.len, NULL, 0, src_palette.ptr,\n src_palette.len) !=\n (WUFFS_BASE__PIXEL_FORMAT__INDEXED__P"+
"ALETTE_BYTE_LENGTH / 4)) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__xxxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH) {\n return NULL;\n }\n return wuffs_base__pixel_swizzler__bgra_premul__index_bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n if (wuffs_base__pixel_swizzler__swap_rgbx_bgrx(\n dst_palette.ptr, dst_palette.len, NULL, 0, src_palette.ptr,\n src_palette.len) !=\n (WUFFS_BASE__PIXEL_FORMAT__INDEXED__PALETTE_BYTE_LENGTH / 4)) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__xxxx__index__src;\n case WUFFS_BASE__PI"+
":\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n return wuffs_base__pixel_swizzler__bgrw__bgr_565;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__bgrw_4x16le__bgr_565;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__pixel_swizzler__rgbw__bgr_565;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__bgr(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n "+
"wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n return wuffs_base__pixel_swizzler__bgr_565__bgr;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n return wuffs_base__pixel_swizzler__copy_3_3;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n return wuffs_base__pixel_swizzler__bgrw__bgr;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__bgrw_4x16le__bgr;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n return wuffs_base__pixel_swizzler__swap_rgb_bgr;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch"+
"__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__bgrw__rgb__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__bgrw__rgb;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__bgra_nonpremul(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src;\n case WUFFS_"+
"BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__copy_4_4;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__bgra_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_premul__b"+
"gra_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n retur"+
"n wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n // TODO.\n break;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__bgra_nonpremul_4x16le(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul_4x16le__src_over;\n }\n "+
" return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr__bgra_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr__bgra_nonpremul_4x16le__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_nonpremul_4x16le__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__copy_8_8;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x"+
"16le__bgra_nonpremul_4x16le__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul_4x16le__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__rgba_nonpremul__bgra_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__rgba_nonpremul__bgra_nonpremul_4x16le__src_over;\n }\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT"+
"__RGBA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul_4x16le__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul_4x16le__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n // TODO.\n break;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__bgra_premul(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__bgra_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n "+
" return wuffs_base__pixel_swizzler__bgr_565__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr__bgra_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__bgra_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__S"+
"RC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__copy_4_4;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n "+
" case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n return wuffs_base__pixel_swizzler__bgrw__bgrx;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__bgrw_4x16le__bgrx;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n return wuffs_base__pixel_swizzler__copy_4_4;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__pixel_swizzler__bgrw__rgbx;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__rgb(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 "+
"src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n return wuffs_base__pixel_swizzler__bgr_565__rgb;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n return wuffs_base__pixel_swizzler__swap_rgb_bgr;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__bgrw__rgb__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__bgrw__rgb;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n return wuffs_base__pixel_swizzler__bgrw_4x16le__rgb;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n return wuffs_base__pixel_swizzler__copy_3_3;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_"+
"PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__pixel_swizzler__bgrw__bgr;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__rgba_nonpremul(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__rgba_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr_565__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr__rgba_nonpremul__src;\n case WUFFS_B"+
"ASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__rgba_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__rgba_nonpremul__src_over;\n }\n "+
" return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__copy_4_4;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return"+
" wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n // TODO.\n break;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__rgba_premul(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_pixfmt,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__rgba_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr_565__rgba_premul__src_over;\n }\n return NULL;\n\n case WUFFS_"+
"BASE__PIXEL_FORMAT__BGR:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr__rgba_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr__rgba_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__rgba_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__rgba_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul_4x16le__rgba_premul__src_over;\n }\n "+
" return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n#if defined(WUFFS_BASE__CPU_ARCH__X86_64)\n if (wuffs_base__cpu_arch__have_x86_sse42()) {\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx__sse42;\n }\n#endif\n return wuffs_base__pixel_swizzler__swap_rgbx_bgrx;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_premul__rgba_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_premul__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgra_nonpremul__bgra_premul__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return w"+
"// ---------------- Auxiliary - Base\n\n// Auxiliary code is discussed at\n// https://github.com/google/wuffs/blob/main/doc/note/auxiliary-code.md\n\n#include <stdio.h>\n\n#include <string>\n\nnamespace wuffs_aux {\n\nusing IOBuffer = wuffs_base__io_buffer;\n\n// MemOwner represents ownership of some memory. Dynamically allocated memory\n// (e.g. from malloc or new) is typically paired with free or delete, invoked\n// when the std::unique_ptr is destroyed. Statically allocated memory might use\n// MemOwner(nullptr, &free), even if that statically allocated memory is not\n// nullptr, since calling free(nullptr) is a no-op.\nusing MemOwner = std::unique_ptr<void, decltype(&free)>;\n\nnamespace sync_io {\n\n"+
"// --------\n\n// FileInput is an Input that reads from a file source.\n//\n// It does not take responsibility for closing the file when done.\nclass FileInput : public Input {\n public:\n FileInput(FILE* f);\n\n virtual std::string CopyIn(IOBuffer* dst);\n\n private:\n FILE* m_f;\n\n // Delete the copy and assign constructors.\n FileInput(const FileInput&) = delete;\n FileInput& operator=(const FileInput&) = delete;\n};\n\n"+
""+
"// --------\n\n// MemoryInput is an Input that reads from an in-memory source.\n//\n// It does not take responsibility for freeing the memory when done.\nclass MemoryInput : public Input {\n public:\n MemoryInput(const char* ptr, size_t len);\n MemoryInput(const uint8_t* ptr, size_t len);\n\n virtual IOBuffer* BringsItsOwnIOBuffer();\n virtual std::string CopyIn(IOBuffer* dst);\n\n private:\n IOBuffer m_io;\n\n // Delete the copy and assign constructors.\n MemoryInput(const MemoryInput&) = delete;\n MemoryInput& operator=(const MemoryInput&) = delete;\n};\n\n"+
"io_array = std::unique_ptr<uint8_t[]>(new uint8_t[4096]);\n fallback_io_buf = wuffs_base__ptr_u8__writer(fallback_io_array.get(), 4096);\n io_buf = &fallback_io_buf;\n }\n // cursor_index is discussed at\n // https://nigeltao.github.io/blog/2020/jsonptr.html#the-cursor-index\n size_t cursor_index = 0;\n std::string ret_error_message;\n std::string io_error_message;\n\n do {\n // Prepare the low-level CBOR decoder.\n wuffs_cbor__decoder::unique_ptr dec = wuffs_cbor__decoder::alloc();\n if (!dec) {\n ret_error_message = \"wuffs_aux::DecodeCbor: out of memory\";\n goto done;\n }\n for (size_t i = 0; i < quirks.len; i++) {\n dec->set_quirk_enabled(quirks.ptr[i], true);\n }\n\n // Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.\n wuffs_base__token tok_array[256];\n wuffs_base__token_buffer tok_buf =\n wuffs_base__slice_token__writer(wuffs_base__make_slice_token(\n &tok_array[0], (sizeof(tok_array) / sizeof(tok_array[0]))));\n wuffs_base__status tok_status = w"+
"uffs_base__make_status(nullptr);\n\n // Prepare other state.\n int32_t depth = 0;\n std::string str;\n int64_t extension_category = 0;\n uint64_t extension_detail = 0;\n\n // Valid token's VBCs range in 0 ..= 15. Values over that are for tokens\n // from outside of the base package, such as the CBOR package.\n constexpr int64_t EXT_CAT__CBOR_TAG = 16;\n\n // Loop, doing these two things:\n // 1. Get the next token.\n // 2. Process that token.\n while (true) {\n // 1. Get the next token.\n\n while (tok_buf.meta.ri >= tok_buf.meta.wi) {\n if (tok_status.repr == nullptr) {\n // No-op.\n } else if (tok_status.repr == wuffs_base__suspension__short_write) {\n tok_buf.compact();\n } else if (tok_status.repr == wuffs_base__suspension__short_read) {\n // Read from input to io_buf.\n if (!io_error_message.empty()) {\n ret_error_message = std::move(io_error_message);\n goto done;\n } else if (cursor_index != io_bu"+
"lists) and CBOR\n // maps (dictionaries).\n //\n // The flags bits combine exactly one of:\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT\n // and exactly one of:\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT\n\n virtual std::string Push(uint32_t flags) = 0;\n virtual std::string Pop(uint32_t flags) = 0;\n\n // Done is always the last Callback method called by DecodeCbor, whether or\n // not parsing the input as CBOR encountered an error. Even when successful,\n // trailing data may remain in input and buffer.\n //\n // Do not keep a reference to buffer or buffer.data.ptr after Done returns,\n // as DecodeCbor may then de-allocate the backing array.\n //\n // The default Done implementation is a no-op.\n virtual void //\n Done(DecodeCborResult& result, sync_io::Input& input, IOBuffer& buffer);\n}"+
";\n\n// DecodeCbor calls callbacks based on the CBOR-formatted data in input.\n//\n// On success, the returned error_message is empty and cursor_position counts\n// the number of bytes consumed. On failure, error_message is non-empty and\n// cursor_position is the location of the error. That error may be a content\n// error (invalid CBOR) or an input error (e.g. network failure).\nDecodeCborResult //\nDecodeCbor(DecodeCborCallbacks& callbacks,\n sync_io::Input& input,\n wuffs_base__slice_u32 quirks = wuffs_base__empty_slice_u32());\n\n} // namespace wuffs_aux\n"+
" DecodeImageResult(std::move(error_message));\n }\n fourcc = (int32_t)(minfo.io_redirect__fourcc());\n if (fourcc == 0) {\n return DecodeImageResult(DecodeImage_UnsupportedImageFormat);\n }\n image_decoder.reset();\n }\n\n // Select the image decoder.\n image_decoder = callbacks.SelectDecoder(\n (uint32_t)fourcc,\n fourcc ? wuffs_base__empty_slice_u8() : io_buf.reader_slice());\n if (!image_decoder) {\n return DecodeImageResult(DecodeImage_UnsupportedImageFormat);\n }\n\n // Decode the image config.\n while (true) {\n wuffs_base__status id_dic_status =\n image_decoder->decode_image_config(&image_config, &io_buf);\n if (id_dic_status.repr == nullptr) {\n break;\n } else if (id_dic_status.repr == wuffs_base__note__i_o_redirect) {\n if (redirected) {\n return DecodeImageResult(DecodeImage_UnsupportedImageFormat);\n }\n redirected = true;\n goto redirect;\n } else if (id_dic_status.repr != wuffs_bas"+
"e__suspension__short_read) {\n return DecodeImageResult(id_dic_status.message());\n } else if (io_buf.meta.closed) {\n return DecodeImageResult(DecodeImage_UnexpectedEndOfFile);\n } else {\n std::string error_message = input.CopyIn(&io_buf);\n if (!error_message.empty()) {\n return DecodeImageResult(std::move(error_message));\n }\n }\n }\n } while (false);\n\n // Select the pixel format.\n uint32_t w = image_config.pixcfg.width();\n uint32_t h = image_config.pixcfg.height();\n if ((w > max_incl_dimension) || (h > max_incl_dimension)) {\n return DecodeImageResult(DecodeImage_MaxInclDimensionExceeded);\n }\n wuffs_base__pixel_format pixel_format = callbacks.SelectPixfmt(image_config);\n if (pixel_format.repr != image_config.pixcfg.pixel_format().repr) {\n switch (pixel_format.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT"+
"__BGRA_NONPREMUL_4X16LE:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n break;\n default:\n return DecodeImageResult(DecodeImage_UnsupportedPixelFormat);\n }\n image_config.pixcfg.set(pixel_format.repr,\n WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, w, h);\n }\n\n // Allocate the pixel buffer.\n bool valid_background_color =\n wuffs_base__color_u32_argb_premul__is_valid(background_color);\n DecodeImageCallbacks::AllocPixbufResult alloc_pixbuf_result =\n callbacks.AllocPixbuf(image_config, valid_background_color);\n if (!alloc_pixbuf_result.error_message.empty()) {\n return DecodeImageResult(std::move(alloc_pixbuf_result.error_message));\n }\n wuffs_base__pixel_buffer pixel_buffer = alloc_pixbuf_result.pixbuf;\n if (valid_background_color) {\n wuffs_base__status pb_scufr_status = pixel_buffer.set_color_u32_fill_rect(\n pixel_buffer.pixcfg.bounds(), b"+
"ackground_color);\n if (pb_scufr_status.repr != nullptr) {\n return DecodeImageResult(pb_scufr_status.message());\n }\n }\n\n // Allocate the work buffer. Wuffs' decoders conventionally assume that this\n // can be uninitialized memory.\n wuffs_base__range_ii_u64 workbuf_len = image_decoder->workbuf_len();\n DecodeImageCallbacks::AllocWorkbufResult alloc_workbuf_result =\n callbacks.AllocWorkbuf(workbuf_len, true);\n if (!alloc_workbuf_result.error_message.empty()) {\n return DecodeImageResult(std::move(alloc_workbuf_result.error_message));\n } else if (alloc_workbuf_result.workbuf.len < workbuf_len.min_incl) {\n return DecodeImageResult(DecodeImage_BufferIsTooShort);\n }\n\n // Decode the frame config.\n wuffs_base__frame_config frame_config = wuffs_base__null_frame_config();\n while (true) {\n wuffs_base__status id_dfc_status =\n image_decoder->decode_frame_config(&frame_config, &io_buf);\n if (id_dfc_status.repr == nullptr) {\n break;\n } else if (id_dfc_status.repr != wuffs_b"+
"ase__suspension__short_read) {\n return DecodeImageResult(id_dfc_status.message());\n } else if (io_buf.meta.closed) {\n return DecodeImageResult(DecodeImage_UnexpectedEndOfFile);\n } else {\n std::string error_message = input.CopyIn(&io_buf);\n if (!error_message.empty()) {\n return DecodeImageResult(std::move(error_message));\n }\n }\n }\n\n // Decode the frame (the pixels).\n //\n // From here on, always returns the pixel_buffer. If we get this far, we can\n // still display a partial image, even if we encounter an error.\n std::string message(\"\");\n if ((pixel_blend == WUFFS_BASE__PIXEL_BLEND__SRC_OVER) &&\n frame_config.overwrite_instead_of_blend()) {\n pixel_blend = WUFFS_BASE__PIXEL_BLEND__SRC;\n }\n while (true) {\n wuffs_base__status id_df_status =\n image_decoder->decode_frame(&pixel_buffer, &io_buf, pixel_blend,\n alloc_workbuf_result.workbuf, nullptr);\n if (id_df_status.repr == nullptr) {\n break;\n } else if ("+
"// ---------------- Auxiliary - Image\n\nnamespace wuffs_aux {\n\nstruct DecodeImageResult {\n DecodeImageResult(MemOwner&& pixbuf_mem_owner0,\n wuffs_base__pixel_buffer pixbuf0,\n std::string&& error_message0);\n DecodeImageResult(std::string&& error_message0);\n\n MemOwner pixbuf_mem_owner;\n wuffs_base__pixel_buffer pixbuf;\n std::string error_message;\n};\n\n// DecodeImageCallbacks are the callbacks given to DecodeImage. They are always\n// called in this order:\n// 1. SelectDecoder\n// 2. SelectPixfmt\n// 3. AllocPixbuf\n// 4. AllocWorkbuf\n// 5. Done\n//\n// It may return early - the third callback might not be invoked if the second\n// one fails - but the final callback (Done) is always invoked.\nclass DecodeImageCallbacks {\n public:\n // AllocPixbufResult holds a memory allocation (the result of malloc or new,\n // a statically allocated pointer, etc), or an error message. The memory is\n // de-allocated when mem_owner goes out of scope and is destroyed.\n struct AllocPixbufResu"+
"lt {\n AllocPixbufResult(MemOwner&& mem_owner0, wuffs_base__pixel_buffer pixbuf0);\n AllocPixbufResult(std::string&& error_message0);\n\n MemOwner mem_owner;\n wuffs_base__pixel_buffer pixbuf;\n std::string error_message;\n };\n\n // AllocWorkbufResult holds a memory allocation (the result of malloc or new,\n // a statically allocated pointer, etc), or an error message. The memory is\n // de-allocated when mem_owner goes out of scope and is destroyed.\n struct AllocWorkbufResult {\n AllocWorkbufResult(MemOwner&& mem_owner0, wuffs_base__slice_u8 workbuf0);\n AllocWorkbufResult(std::string&& error_message0);\n\n MemOwner mem_owner;\n wuffs_base__slice_u8 workbuf;\n std::string error_message;\n };\n\n virtual ~DecodeImageCallbacks();\n\n // SelectDecoder returns the image decoder for the input data's file format.\n // Returning a nullptr means failure (DecodeImage_UnsupportedImageFormat).\n //\n // Common formats will have a FourCC value in the range [1 ..= 0x7FFF_FFFF],\n // such as WUFFS_BASE__F"+
"OURCC__JPEG. A zero FourCC value means that the\n // caller is responsible for examining the opening bytes (a prefix) of the\n // input data. SelectDecoder implementations should not modify those bytes.\n //\n // SelectDecoder might be called more than once, since some image file\n // formats can wrap others. For example, a nominal BMP file can actually\n // contain a JPEG or a PNG.\n //\n // The default SelectDecoder accepts the FOURCC codes listed below. For\n // modular builds (i.e. when #define'ing WUFFS_CONFIG__MODULES), acceptance\n // of the ETC file format is optional (for each value of ETC) and depends on\n // the corresponding module to be enabled at compile time (i.e. #define'ing\n // WUFFS_CONFIG__MODULE__ETC).\n // - WUFFS_BASE__FOURCC__BMP\n // - WUFFS_BASE__FOURCC__GIF\n // - WUFFS_BASE__FOURCC__NIE\n // - WUFFS_BASE__FOURCC__PNG\n // - WUFFS_BASE__FOURCC__WBMP\n virtual wuffs_base__image_decoder::unique_ptr //\n SelectDecoder(uint32_t fourcc, wuffs_base__slice_u8 prefix);\n\n // SelectPix"+
"fmt returns the destination pixel format for AllocPixbuf. It\n // should return wuffs_base__make_pixel_format(etc) called with one of:\n // - WUFFS_BASE__PIXEL_FORMAT__BGR_565\n // - WUFFS_BASE__PIXEL_FORMAT__BGR\n // - WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL\n // - WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE\n // - WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL\n // - WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL\n // - WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL\n // or return image_config.pixcfg.pixel_format(). The latter means to use the\n // image file's natural pixel format. For example, GIF images' natural pixel\n // format is an indexed one.\n //\n // Returning otherwise means failure (DecodeImage_UnsupportedPixelFormat).\n //\n // The default SelectPixfmt implementation returns\n // wuffs_base__make_pixel_format(WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL) which\n // is 4 bytes per pixel (8 bits per channel × 4 channels).\n virtual wuffs_base__pixel_format //\n SelectPixfmt(const wuffs_base__image_config& image_"+
"config);\n\n // AllocPixbuf allocates the pixel buffer.\n //\n // allow_uninitialized_memory will be true if a valid background_color was\n // passed to DecodeImage, since the pixel buffer's contents will be\n // overwritten with that color after AllocPixbuf returns.\n //\n // The default AllocPixbuf implementation allocates either uninitialized or\n // zeroed memory. Zeroed memory typically corresponds to filling with opaque\n // black or transparent black, depending on the pixel format.\n virtual AllocPixbufResult //\n AllocPixbuf(const wuffs_base__image_config& image_config,\n bool allow_uninitialized_memory);\n\n // AllocWorkbuf allocates the work buffer. The allocated buffer's length\n // should be at least len_range.min_incl, but larger allocations (up to\n // len_range.max_incl) may have better performance (by using more memory).\n //\n // The default AllocWorkbuf implementation allocates len_range.max_incl bytes\n // of either uninitialized or zeroed memory.\n virtual AllocWorkbufResult //"+
"\n AllocWorkbuf(wuffs_base__range_ii_u64 len_range,\n bool allow_uninitialized_memory);\n\n // Done is always the last Callback method called by DecodeImage, whether or\n // not parsing the input encountered an error. Even when successful, trailing\n // data may remain in input and buffer.\n //\n // The image_decoder is the one returned by SelectDecoder (if SelectDecoder\n // was successful), or a no-op unique_ptr otherwise. Like any unique_ptr,\n // ownership moves to the Done implementation.\n //\n // Do not keep a reference to buffer or buffer.data.ptr after Done returns,\n // as DecodeImage may then de-allocate the backing array.\n //\n // The default Done implementation is a no-op, other than running the\n // image_decoder unique_ptr destructor.\n virtual void //\n Done(DecodeImageResult& result,\n sync_io::Input& input,\n IOBuffer& buffer,\n wuffs_base__image_decoder::unique_ptr image_decoder);\n};\n\nextern const char DecodeImage_BufferIsTooShort[];\nextern const char DecodeImag"+
"e_MaxInclDimensionExceeded[];\nextern const char DecodeImage_OutOfMemory[];\nextern const char DecodeImage_UnexpectedEndOfFile[];\nextern const char DecodeImage_UnsupportedImageFormat[];\nextern const char DecodeImage_UnsupportedPixelBlend[];\nextern const char DecodeImage_UnsupportedPixelConfiguration[];\nextern const char DecodeImage_UnsupportedPixelFormat[];\n\n// DecodeImage decodes the image data in input. A variety of image file formats\n// can be decoded, depending on what callbacks.SelectDecoder returns.\n//\n// For animated formats, only the first frame is returned, since the API is\n// simpler for synchronous I/O and having DecodeImage only return when\n// completely done, but rendering animation often involves handling other\n// events in between animation frames. To decode multiple frames of animated\n// images, or for asynchronous I/O (e.g. when decoding an image streamed over\n// the network), use Wuffs' lower level C API instead of its higher level,\n// simplified C++ API (the wuffs_aux API).\n//\n// The DecodeIm"+
"ageResult's fields depend on whether decoding succeeded:\n// - On total success, the error_message is empty and pixbuf.pixcfg.is_valid()\n// is true.\n// - On partial success (e.g. the input file was truncated but we are still\n// able to decode some of the pixels), error_message is non-empty but\n// pixbuf.pixcfg.is_valid() is still true. It is up to the caller whether to\n// accept or reject partial success.\n// - On failure, the error_message is non_empty and pixbuf.pixcfg.is_valid()\n// is false.\n//\n// The callbacks allocate the pixel buffer memory and work buffer memory. On\n// success, pixel buffer memory ownership is passed to the DecodeImage caller\n// as the returned pixbuf_mem_owner. Regardless of success or failure, the work\n// buffer memory is deleted.\n//\n// The pixel_blend (one of the constants listed below) determines how to\n// composite the decoded image over the pixel buffer's original pixels (as\n// returned by callbacks.AllocPixbuf):\n// - WUFFS_BASE__PIXEL_BLEND__SRC\n// - WUFFS_BASE"+
"__PIXEL_BLEND__SRC_OVER\n//\n// The background_color is used to fill the pixel buffer after\n// callbacks.AllocPixbuf returns, if it is valid in the\n// wuffs_base__color_u32_argb_premul__is_valid sense. The default value,\n// 0x0000_0001, is not valid since its Blue channel value (0x01) is greater\n// than its Alpha channel value (0x00). A valid background_color will typically\n// be overwritten when pixel_blend is WUFFS_BASE__PIXEL_BLEND__SRC, but might\n// still be visible on partial (not total) success or when pixel_blend is\n// WUFFS_BASE__PIXEL_BLEND__SRC_OVER and the decoded image is not fully opaque.\n//\n// Decoding fails (with DecodeImage_MaxInclDimensionExceeded) if the image's\n// width or height is greater than max_incl_dimension.\nDecodeImageResult //\nDecodeImage(DecodeImageCallbacks& callbacks,\n sync_io::Input& input,\n wuffs_base__pixel_blend pixel_blend = WUFFS_BASE__PIXEL_BLEND__SRC,\n wuffs_base__color_u32_argb_premul background_color = 1, // Invalid.\n uint32_"+
"// --------\n\nnamespace {\n\n// DecodeJson_SplitJsonPointer returns (\"bar\", 8) for (\"/foo/bar/b~1z/qux\", 5,\n// etc). It returns a 0 size_t when s has invalid JSON Pointer syntax or i is\n// out of bounds.\n//\n// The string returned is unescaped. If calling it again, this time with i=8,\n// the \"b~1z\" substring would be returned as \"b/z\".\nstd::pair<std::string, size_t> //\nDecodeJson_SplitJsonPointer(std::string& s,\n size_t i,\n bool allow_tilde_n_tilde_r_tilde_t) {\n std::string fragment;\n if (i > s.size()) {\n return std::make_pair(std::string(), 0);\n }\n while (i < s.size()) {\n char c = s[i];\n if (c == '/') {\n break;\n } else if (c != '~') {\n fragment.push_back(c);\n i++;\n continue;\n }\n i++;\n if (i >= s.size()) {\n return std::make_pair(std::string(), 0);\n }\n c = s[i];\n if (c == '0') {\n fragment.push_back('~');\n i++;\n continue;\n } else if (c == '1') {\n fragment.push_back('/');\n i++"+
"RUCTURE__TO_LIST) {\n goto do_list;\n }\n goto do_dict;\n }\n\ndo_dict:\n // Alternate between these two things:\n // 1. Decode the next dict key (a string). If it matches the fragment, we're\n // done (success). If we've reached the dict's end (VBD__STRUCTURE__POP)\n // so that there was no next dict key, we're done (failure).\n // 2. Otherwise, skip the next dict value.\n while (true) {\n for (std::string str; true;) {\n WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN;\n\n int64_t vbc = token.value_base_category();\n uint64_t vbd = token.value_base_detail();\n switch (vbc) {\n case WUFFS_BASE__TOKEN__VBC__FILLER:\n continue;\n\n case WUFFS_BASE__TOKEN__VBC__STRUCTURE:\n if (vbd & WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH) {\n goto fail;\n }\n return DecodeJson_NoMatch;\n\n case WUFFS_BASE__TOKEN__VBC__STRING: {\n if (vbd & WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP) {\n // No-op.\n } els"+
"e if (vbd &\n WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY) {\n const char* ptr = // Convert from (uint8_t*).\n static_cast<const char*>(static_cast<void*>(token_ptr));\n str.append(ptr, static_cast<size_t>(token_len));\n } else {\n goto fail;\n }\n break;\n }\n\n case WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT: {\n uint8_t u[WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL];\n size_t n = wuffs_base__utf_8__encode(\n wuffs_base__make_slice_u8(\n &u[0], WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL),\n static_cast<uint32_t>(vbd));\n const char* ptr = // Convert from (uint8_t*).\n static_cast<const char*>(static_cast<void*>(&u[0]));\n str.append(ptr, n);\n break;\n }\n\n default:\n goto fail;\n }\n\n if (token.continued()) {\n continue;\n }\n if (str == json_pointer_fragment) {\n "+
" wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n 0x7FF0000000000000ul));\n goto parsed_a_value;\n } else if (vbd & WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_NAN) {\n ret_error_message = callbacks.AppendF64(\n wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n 0xFFFFFFFFFFFFFFFFul));\n goto parsed_a_value;\n } else if (vbd & WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_POS_NAN) {\n ret_error_message = callbacks.AppendF64(\n wuffs_base__ieee_754_bit_representation__from_u64_to_f64(\n 0x7FFFFFFFFFFFFFFFul));\n goto parsed_a_value;\n }\n goto fail;\n }\n }\n\n fail:\n ret_error_message =\n \"wuffs_aux::DecodeJson: internal error: unexpected token\";\n goto done;\n\n parsed_a_value:\n // If an error was encountered, we are done. Otherwise, (depth == 0)\n // after parsing a value is equivalent to havi"+
"ng decoded the entire JSON\n // value (for an empty json_pointer query) or having decoded the\n // pointed-to JSON value (for a non-empty json_pointer query). In the\n // latter case, we are also done.\n //\n // However, if quirks like WUFFS_JSON__QUIRK_ALLOW_TRAILING_FILLER or\n // WUFFS_JSON__QUIRK_EXPECT_TRAILING_NEW_LINE_OR_EOF are passed, decoding\n // the entire JSON value should also consume any trailing filler, in case\n // the DecodeJson caller wants to subsequently check that the input is\n // completely exhausted (and otherwise raise \"valid JSON followed by\n // further (unexpected) data\"). We aren't done yet. Instead, keep the\n // loop running until WUFFS_AUX__DECODE_JSON__GET_THE_NEXT_TOKEN's\n // decode_tokens returns an ok status.\n if (!ret_error_message.empty() ||\n ((depth == 0) && !json_pointer.empty())) {\n goto done;\n }\n }\n } while (false);\n\ndone:\n DecodeJsonResult result(\n std::move(ret_error_message),\n "+
"// ---------------- Auxiliary - JSON\n\nnamespace wuffs_aux {\n\nstruct DecodeJsonResult {\n DecodeJsonResult(std::string&& error_message0, uint64_t cursor_position0);\n\n std::string error_message;\n uint64_t cursor_position;\n};\n\nclass DecodeJsonCallbacks {\n public:\n virtual ~DecodeJsonCallbacks();\n\n // AppendXxx are called for leaf nodes: literals, numbers and strings. For\n // strings, the Callbacks implementation is responsible for tracking map keys\n // versus other values.\n\n virtual std::string AppendNull() = 0;\n virtual std::string AppendBool(bool val) = 0;\n virtual std::string AppendF64(double val) = 0;\n virtual std::string AppendI64(int64_t val) = 0;\n virtual std::string AppendTextString(std::string&& val) = 0;\n\n // Push and Pop are called for container nodes: JSON arrays (lists) and JSON\n // objects (dictionaries).\n //\n // The flags bits combine exactly one of:\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST\n // - WUFFS_BASE__TOKEN__V"+
"BD__STRUCTURE__FROM_DICT\n // and exactly one of:\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST\n // - WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT\n\n virtual std::string Push(uint32_t flags) = 0;\n virtual std::string Pop(uint32_t flags) = 0;\n\n // Done is always the last Callback method called by DecodeJson, whether or\n // not parsing the input as JSON encountered an error. Even when successful,\n // trailing data may remain in input and buffer. See \"Unintuitive JSON\n // Parsing\" (https://nullprogram.com/blog/2019/12/28/) which discusses JSON\n // parsing and when it stops.\n //\n // Do not keep a reference to buffer or buffer.data.ptr after Done returns,\n // as DecodeJson may then de-allocate the backing array.\n //\n // The default Done implementation is a no-op.\n virtual void //\n Done(DecodeJsonResult& result, sync_io::Input& input, IOBuffer& buffer);\n};\n\nextern const char DecodeJson_BadJsonPointer[];\nextern const char DecodeJson_NoMatch[];\n\n//"+
" DecodeJson calls callbacks based on the JSON-formatted data in input.\n//\n// On success, the returned error_message is empty and cursor_position counts\n// the number of bytes consumed. On failure, error_message is non-empty and\n// cursor_position is the location of the error. That error may be a content\n// error (invalid JSON) or an input error (e.g. network failure).\n//\n// json_pointer is a query in the JSON Pointer (RFC 6901) syntax. The callbacks\n// run for the input's sub-node that matches the query. DecodeJson_NoMatch is\n// returned if no matching sub-node was found. The empty query matches the\n// input's root node, consistent with JSON Pointer semantics.\n//\n// The JSON Pointer implementation is greedy: duplicate keys are not rejected\n// but only the first match for each '/'-separated fragment is followed.\nDecodeJsonResult //\nDecodeJson(DecodeJsonCallbacks& callbacks,\n sync_io::Input& input,\n wuffs_base__slice_u32 quirks = wuffs_base__empty_slice_u32(),\n std::string json_po"+
"// Copyright 2017 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n"+
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.