blob: fb9ca00cfd1a498d1563e53d4b48093c0afcc2ea [file] [log] [blame]
// Code generated by running "go generate". DO NOT EDIT.
// Copyright 2017 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cgen
const baseAllImplC = "" +
"#ifndef WUFFS_INCLUDE_GUARD__BASE\n#define WUFFS_INCLUDE_GUARD__BASE\n\n#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n#define WUFFS_CONFIG__MODULES\n#define WUFFS_CONFIG__MODULE__BASE\n#endif\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING ABOVE.\n\n// !! INSERT base/copyright\n\n#include <stdbool.h>\n#include <stdint.h>\n#include <stdlib.h>\n#include <string.h>\n\n#ifdef __cplusplus\n#if __cplusplus >= 201103L\n#include <memory>\n#else\n#warning \"Wuffs' C++ code requires -std=c++11 or later\"\n#endif\n\nextern \"C\" {\n#endif\n\n// !! INSERT base/all-public.h.\n\n// !! INSERT InterfaceDeclarations.\n\n" +
"" +
"// ----------------\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n// WUFFS C HEADER ENDS HERE.\n#ifdef WUFFS_IMPLEMENTATION\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// !! INSERT base/all-private.h.\n\n" +
"" +
"// ----------------\n\n#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BASE)\n\nconst uint8_t wuffs_base__low_bits_mask__u8[9] = {\n 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF,\n};\n\nconst uint16_t wuffs_base__low_bits_mask__u16[17] = {\n 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,\n 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF,\n};\n\nconst uint32_t wuffs_base__low_bits_mask__u32[33] = {\n 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F,\n 0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF,\n 0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF, 0x0001FFFF,\n 0x0003FFFF, 0x0007FFFF, 0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF,\n 0x00FFFFFF, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x1FFFFFFF,\n 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF,\n};\n\nconst uint64_t wuffs_base__low_bits_mask__u64[65] = {\n 0x0000000000000000, 0x0000000000000001, 0x0000000000000003,\n 0x0000000000" +
"000007, 0x000000000000000F, 0x000000000000001F,\n 0x000000000000003F, 0x000000000000007F, 0x00000000000000FF,\n 0x00000000000001FF, 0x00000000000003FF, 0x00000000000007FF,\n 0x0000000000000FFF, 0x0000000000001FFF, 0x0000000000003FFF,\n 0x0000000000007FFF, 0x000000000000FFFF, 0x000000000001FFFF,\n 0x000000000003FFFF, 0x000000000007FFFF, 0x00000000000FFFFF,\n 0x00000000001FFFFF, 0x00000000003FFFFF, 0x00000000007FFFFF,\n 0x0000000000FFFFFF, 0x0000000001FFFFFF, 0x0000000003FFFFFF,\n 0x0000000007FFFFFF, 0x000000000FFFFFFF, 0x000000001FFFFFFF,\n 0x000000003FFFFFFF, 0x000000007FFFFFFF, 0x00000000FFFFFFFF,\n 0x00000001FFFFFFFF, 0x00000003FFFFFFFF, 0x00000007FFFFFFFF,\n 0x0000000FFFFFFFFF, 0x0000001FFFFFFFFF, 0x0000003FFFFFFFFF,\n 0x0000007FFFFFFFFF, 0x000000FFFFFFFFFF, 0x000001FFFFFFFFFF,\n 0x000003FFFFFFFFFF, 0x000007FFFFFFFFFF, 0x00000FFFFFFFFFFF,\n 0x00001FFFFFFFFFFF, 0x00003FFFFFFFFFFF, 0x00007FFFFFFFFFFF,\n 0x0000FFFFFFFFFFFF, 0x0001FFFFFFFFFFFF, 0x0003FFFFFFFFFFFF,\n 0x0007FFFFFF" +
"FFFFFF, 0x000FFFFFFFFFFFFF, 0x001FFFFFFFFFFFFF,\n 0x003FFFFFFFFFFFFF, 0x007FFFFFFFFFFFFF, 0x00FFFFFFFFFFFFFF,\n 0x01FFFFFFFFFFFFFF, 0x03FFFFFFFFFFFFFF, 0x07FFFFFFFFFFFFFF,\n 0x0FFFFFFFFFFFFFFF, 0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF,\n 0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF,\n};\n\n// !! INSERT wuffs_base__status strings.\n\n// !! INSERT InterfaceDefinitions.\n\n// !! INSERT base/image-impl.c.\n\n// !! INSERT base/strconv-impl.c.\n\n#endif // !defined(WUFFS_CONFIG__MODULES) ||\n // defined(WUFFS_CONFIG__MODULE__BASE)\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif // WUFFS_IMPLEMENTATION\n\n// !! WUFFS MONOLITHIC RELEASE DISCARDS EVERYTHING BELOW.\n\n#endif // WUFFS_INCLUDE_GUARD__BASE\n" +
""
const baseImageImplC = "" +
"// ---------------- Images\n\nconst uint32_t wuffs_base__pixel_format__bits_per_channel[16] = {\n 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,\n 0x08, 0x0A, 0x0C, 0x10, 0x18, 0x20, 0x30, 0x40,\n};\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__squash_bgr_565_888(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len4 = (dst.len < src.len ? dst.len : src.len) / 4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n\n size_t n = len4;\n while (n--) {\n uint32_t argb = wuffs_base__load_u32le__no_bounds_check(s);\n uint32_t b5 = 0x1F & (argb >> (8 - 5));\n uint32_t g6 = 0x3F & (argb >> (16 - 6));\n uint32_t r5 = 0x1F & (argb >> (24 - 5));\n uint32_t alpha = argb & 0xFF000000;\n wuffs_base__store_u32le__no_bounds_check(\n d, alpha | (r5 << 11) | (g6 << 5) | (b5 << 0));\n s += 4;\n d += 4;\n }\n return len4 * 4;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__swap_rgbx_bgrx(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t len4 = (dst.len < src.len ? dst.len : src.len) / 4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n\n size_t n = len4;\n while (n--) {\n " +
" uint8_t b0 = s[0];\n uint8_t b1 = s[1];\n uint8_t b2 = s[2];\n uint8_t b3 = s[3];\n d[0] = b2;\n d[1] = b1;\n d[2] = b0;\n d[3] = b3;\n s += 4;\n d += 4;\n }\n return len4 * 4;\n}\n\nstatic inline uint32_t //\nwuffs_base__swap_u32_argb_abgr(uint32_t u) {\n uint32_t o = u & 0xFF00FF00;\n uint32_t r = u & 0x00FF0000;\n uint32_t b = u & 0x000000FF;\n return o | (r >> 16) | (b << 16);\n}\n\n" +
"" +
"// --------\n\nstatic inline uint32_t //\nwuffs_base__composite_nonpremul_nonpremul_u32_axxx(uint32_t dst_nonpremul,\n uint32_t src_nonpremul) {\n // Convert from 8-bit color to 16-bit color.\n uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));\n uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));\n uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));\n uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));\n uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));\n uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));\n uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));\n uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));\n\n // Convert dst from nonpremul to premul.\n dr = (dr * da) / 0xFFFF;\n dg = (dg * da) / 0xFFFF;\n db = (db * da) / 0xFFFF;\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (nonpremul) over dst (premul).\n da = sa + ((da * ia) / 0xFFFF);\n dr = ((sr * sa) + (dr * i" +
"a)) / 0xFFFF;\n dg = ((sg * sa) + (dg * ia)) / 0xFFFF;\n db = ((sb * sa) + (db * ia)) / 0xFFFF;\n\n // Convert dst from premul to nonpremul.\n if (da != 0) {\n dr = (dr * 0xFFFF) / da;\n dg = (dg * 0xFFFF) / da;\n db = (db * 0xFFFF) / da;\n }\n\n // Convert from 16-bit color to 8-bit color and combine the components.\n da >>= 8;\n dr >>= 8;\n dg >>= 8;\n db >>= 8;\n return (db << 0) | (dg << 8) | (dr << 16) | (da << 24);\n}\n\nstatic inline uint32_t //\nwuffs_base__composite_nonpremul_premul_u32_axxx(uint32_t dst_nonpremul,\n uint32_t src_premul) {\n // Convert from 8-bit color to 16-bit color.\n uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));\n uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));\n uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));\n uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));\n uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));\n uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));\n uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8))" +
";\n uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));\n\n // Convert dst from nonpremul to premul.\n dr = (dr * da) / 0xFFFF;\n dg = (dg * da) / 0xFFFF;\n db = (db * da) / 0xFFFF;\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (premul) over dst (premul).\n da = sa + ((da * ia) / 0xFFFF);\n dr = sr + ((dr * ia) / 0xFFFF);\n dg = sg + ((dg * ia) / 0xFFFF);\n db = sb + ((db * ia) / 0xFFFF);\n\n // Convert dst from premul to nonpremul.\n if (da != 0) {\n dr = (dr * 0xFFFF) / da;\n dg = (dg * 0xFFFF) / da;\n db = (db * 0xFFFF) / da;\n }\n\n // Convert from 16-bit color to 8-bit color and combine the components.\n da >>= 8;\n dr >>= 8;\n dg >>= 8;\n db >>= 8;\n return (db << 0) | (dg << 8) | (dr << 16) | (da << 24);\n}\n\nstatic inline uint32_t //\nwuffs_base__composite_premul_nonpremul_u32_axxx(uint32_t dst_premul,\n uint32_t src_nonpremul) {\n // Convert from 8-bit color to 16-bit color.\n " +
" uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));\n uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));\n uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));\n uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));\n uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));\n uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));\n uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));\n uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (nonpremul) over dst (premul).\n da = sa + ((da * ia) / 0xFFFF);\n dr = ((sr * sa) + (dr * ia)) / 0xFFFF;\n dg = ((sg * sa) + (dg * ia)) / 0xFFFF;\n db = ((sb * sa) + (db * ia)) / 0xFFFF;\n\n // Convert from 16-bit color to 8-bit color and combine the components.\n da >>= 8;\n dr >>= 8;\n dg >>= 8;\n db >>= 8;\n return (db << 0) | (dg << 8) | (dr << 16) | (da << 24);\n}\n\nstatic inline uint32_t //\nwuffs_base__composite_premul_premul_u32_axxx(uint32_t dst_premul,\n " +
" uint32_t src_premul) {\n // Convert from 8-bit color to 16-bit color.\n uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));\n uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));\n uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));\n uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));\n uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));\n uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));\n uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));\n uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (premul) over dst (premul).\n da = sa + ((da * ia) / 0xFFFF);\n dr = sr + ((dr * ia) / 0xFFFF);\n dg = sg + ((dg * ia) / 0xFFFF);\n db = sb + ((db * ia) / 0xFFFF);\n\n // Convert from 16-bit color to 8-bit color and combine the components.\n da >>= 8;\n dr >>= 8;\n dg >>= 8;\n db >>= 8;\n return (db << 0) | (dg << 8) | (dr << 16) | (da << 24);\n}\n\n" +
"" +
"// --------\n\nwuffs_base__color_u32_argb_premul //\nwuffs_base__pixel_buffer__color_u32_at(const wuffs_base__pixel_buffer* pb,\n uint32_t x,\n uint32_t y) {\n if (!pb || (x >= pb->pixcfg.private_impl.width) ||\n (y >= pb->pixcfg.private_impl.height)) {\n return 0;\n }\n\n if (wuffs_base__pixel_format__is_planar(&pb->pixcfg.private_impl.pixfmt)) {\n // TODO: support planar formats.\n return 0;\n }\n\n size_t stride = pb->private_impl.planes[0].stride;\n uint8_t* row = pb->private_impl.planes[0].ptr + (stride * ((size_t)y));\n\n switch (pb->pixcfg.private_impl.pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:\n return wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x)));\n\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY: {\n uint8_t* palette = pb->private_impl.planes[3].ptr;\n return wu" +
"ffs_base__load_u32le__no_bounds_check(palette +\n (4 * ((size_t)row[x])));\n }\n\n // Common formats above. Rarer formats below.\n\n case WUFFS_BASE__PIXEL_FORMAT__Y:\n return 0xFF000000 | (0x00010101 * ((uint32_t)(row[x])));\n\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL: {\n uint8_t* palette = pb->private_impl.planes[3].ptr;\n return wuffs_base__premul_u32_axxx(\n wuffs_base__load_u32le__no_bounds_check(palette +\n (4 * ((size_t)row[x]))));\n }\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n return wuffs_base__color_u16_rgb_565__as__color_u32_argb_premul(\n wuffs_base__load_u16le__no_bounds_check(row + (2 * ((size_t)x))));\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n return 0xFF000000 |\n wuffs_base__load_u24le__no_bounds_check(row + (3 * ((size_t)x)));\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n return wuffs_base__premul_u32_axxx(\n " +
" wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x))));\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n return 0xFF000000 |\n wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x)));\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n return wuffs_base__swap_u32_argb_abgr(\n 0xFF000000 |\n wuffs_base__load_u24le__no_bounds_check(row + (3 * ((size_t)x))));\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n return wuffs_base__swap_u32_argb_abgr(wuffs_base__premul_u32_axxx(\n wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x)))));\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n return wuffs_base__swap_u32_argb_abgr(\n wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x))));\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__swap_u32_argb_abgr(\n 0xFF000000 |\n wuffs_base__load_u32le__no_bounds_check(row + (4 * ((size_t)x))));\n\n defaul" +
"t:\n // TODO: support more formats.\n break;\n }\n\n return 0;\n}\n\nwuffs_base__status //\nwuffs_base__pixel_buffer__set_color_u32_at(\n wuffs_base__pixel_buffer* pb,\n uint32_t x,\n uint32_t y,\n wuffs_base__color_u32_argb_premul color) {\n if (!pb) {\n return wuffs_base__make_status(wuffs_base__error__bad_receiver);\n }\n if ((x >= pb->pixcfg.private_impl.width) ||\n (y >= pb->pixcfg.private_impl.height)) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n\n if (wuffs_base__pixel_format__is_planar(&pb->pixcfg.private_impl.pixfmt)) {\n // TODO: support planar formats.\n return wuffs_base__make_status(wuffs_base__error__unsupported_option);\n }\n\n size_t stride = pb->private_impl.planes[0].stride;\n uint8_t* row = pb->private_impl.planes[0].ptr + (stride * ((size_t)y));\n\n switch (pb->pixcfg.private_impl.pixfmt.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n wuffs_base__store_u32le__no_bounds_check(row + (4 *" +
" ((size_t)x)), color);\n break;\n\n // Common formats above. Rarer formats below.\n\n case WUFFS_BASE__PIXEL_FORMAT__Y:\n wuffs_base__store_u8__no_bounds_check(\n row + ((size_t)x), wuffs_base__color_u32_argb_premul__as_gray(color));\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY:\n wuffs_base__store_u8__no_bounds_check(\n row + ((size_t)x), wuffs_base__pixel_palette__closest_element(\n wuffs_base__pixel_buffer__palette(pb),\n pb->pixcfg.private_impl.pixfmt, color));\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n wuffs_base__store_u16le__no_bounds_check(\n row + (2 * ((size_t)x)),\n wuffs_base__color_u32_argb_premul__as__color_u16_rgb_565(color));\n break;\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n wuffs_base__store_u24le__no_bounds_check(row + (3 * ((size_t)x)), color);\n break;\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n wuffs_base__sto" +
"re_u32le__no_bounds_check(\n row + (4 * ((size_t)x)), wuffs_base__nonpremul_u32_axxx(color));\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n wuffs_base__store_u24le__no_bounds_check(\n row + (3 * ((size_t)x)), wuffs_base__swap_u32_argb_abgr(color));\n break;\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:\n wuffs_base__store_u32le__no_bounds_check(\n row + (4 * ((size_t)x)), wuffs_base__nonpremul_u32_axxx(\n wuffs_base__swap_u32_argb_abgr(color)));\n break;\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBX:\n wuffs_base__store_u32le__no_bounds_check(\n row + (4 * ((size_t)x)), wuffs_base__swap_u32_argb_abgr(color));\n break;\n\n default:\n // TODO: support more formats.\n return wuffs_base__make_status(wuffs_base__error__unsupported_option);\n }\n\n return wuffs_base__make_status(NULL);\n}\n\n" +
"" +
"// --------\n\nuint8_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 size_t n = palette_slice.len / 4;\n if (n > 256) {\n n = 256;\n }\n size_t best_index = 0;\n uint64_t best_score = 0xFFFFFFFFFFFFFFFF;\n\n // Work in 16-bit color.\n uint32_t ca = 0x101 * (0xFF & (c >> 24));\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 switch (palette_format.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY: {\n bool nonpremul = palette_format.repr ==\n WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL;\n\n size_t i;\n for (i = 0; i < n; i++) {\n // Work in 16-bit color.\n uint32_t pb = 0x101 * ((uint32_t)(palette_slice.ptr[(4 * i) + 0]))" +
";\n uint32_t pg = 0x101 * ((uint32_t)(palette_slice.ptr[(4 * i) + 1]));\n uint32_t pr = 0x101 * ((uint32_t)(palette_slice.ptr[(4 * i) + 2]));\n uint32_t pa = 0x101 * ((uint32_t)(palette_slice.ptr[(4 * i) + 3]));\n\n // Convert to premultiplied alpha.\n if (nonpremul && (pa != 0xFFFF)) {\n pb = (pb * pa) / 0xFFFF;\n pg = (pg * pa) / 0xFFFF;\n pr = (pr * pa) / 0xFFFF;\n }\n\n // These deltas are conceptually int32_t (signed) but after squaring,\n // it's equivalent to work in uint32_t (unsigned).\n pb -= cb;\n pg -= cg;\n pr -= cr;\n pa -= ca;\n uint64_t score = ((uint64_t)(pb * pb)) + ((uint64_t)(pg * pg)) +\n ((uint64_t)(pr * pr)) + ((uint64_t)(pa * pa));\n if (best_score > score) {\n best_score = score;\n best_index = i;\n }\n }\n break;\n }\n }\n\n return (uint8_t)best_index;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__copy_1_1(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n return wuffs_base__slice_u8__copy_from_slice(dst, src);\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__copy_3_3(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len3 = dst.len / 3;\n size_t src_len3 = src.len / 3;\n size_t len = dst_len3 < src_len3 ? dst_len3 : src_len3;\n if (len > 0) {\n memmove(dst.ptr, src.ptr, len * 3);\n }\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__copy_4_4(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len4 <" +
" src_len4 ? dst_len4 : src_len4;\n if (len > 0) {\n memmove(dst.ptr, src.ptr, len * 4);\n }\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__bgr(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len2 = dst.len / 2;\n size_t src_len3 = src.len / 3;\n size_t len = dst_len2 < src_len3 ? dst_len2 : src_len3;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t b5 = s[0] >> 3;\n uint32_t g6 = s[1] >> 2;\n uint32_t r5 = s[2] >> 3;\n uint32_t rgb_565 = (r5 << 11) | (g6 << 5) | (b5 << 0);\n wuffs_base__store_u16le__no_bounds_check(d + (0 * 2), (uint16_t)rgb_565);\n\n s += 1 * 3;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul__src(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len2 = dst.len / 2;\n size_t src_len4 = src.len / 4;\n size_t len = " +
"dst_len2 < src_len4 ? dst_len2 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n wuffs_base__store_u16le__no_bounds_check(\n d + (0 * 2),\n wuffs_base__color_u32_argb_premul__as__color_u16_rgb_565(\n wuffs_base__premul_u32_axxx(\n wuffs_base__load_u32le__no_bounds_check(s + (0 * 4)))));\n\n s += 1 * 4;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__bgra_nonpremul__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len2 = dst.len / 2;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len2 < src_len4 ? dst_len2 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n // Convert from 8-bit color to 16-bit color.\n uint32_t sa = 0x101 * ((uint32_t)s[3]);\n uint32_t sr = 0x101 * ((uint32_t)s[2]);\n uint32_" +
"t sg = 0x101 * ((uint32_t)s[1]);\n uint32_t sb = 0x101 * ((uint32_t)s[0]);\n\n // Convert from 565 color to 16-bit color.\n uint32_t old_rgb_565 = wuffs_base__load_u16le__no_bounds_check(d + (0 * 2));\n uint32_t old_r5 = 0x1F & (old_rgb_565 >> 11);\n uint32_t dr = (0x8421 * old_r5) >> 4;\n uint32_t old_g6 = 0x3F & (old_rgb_565 >> 5);\n uint32_t dg = (0x1041 * old_g6) >> 2;\n uint32_t old_b5 = 0x1F & (old_rgb_565 >> 0);\n uint32_t db = (0x8421 * old_b5) >> 4;\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (nonpremul) over dst (premul).\n dr = ((sr * sa) + (dr * ia)) / 0xFFFF;\n dg = ((sg * sa) + (dg * ia)) / 0xFFFF;\n db = ((sb * sa) + (db * ia)) / 0xFFFF;\n\n // Convert from 16-bit color to 565 color and combine the components.\n uint32_t new_r5 = 0x1F & (dr >> 11);\n uint32_t new_g6 = 0x3F & (dg >> 10);\n uint32_t new_b5 = 0x1F & (db >> 11);\n uint32_t new_rgb_565 = (new_r5 << 11) | (new_g6 << 5" +
") | (new_b5 << 0);\n wuffs_base__store_u16le__no_bounds_check(d + (0 * 2),\n (uint16_t)new_rgb_565);\n\n s += 1 * 4;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__y(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len2 = dst.len / 2;\n size_t len = dst_len2 < src.len ? dst_len2 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t y5 = s[0] >> 3;\n uint32_t y6 = s[0] >> 2;\n uint32_t rgb_565 = (y5 << 11) | (y6 << 5) | (y5 << 0);\n wuffs_base__store_u16le__no_bounds_check(d + (0 * 2), (uint16_t)rgb_565);\n\n s += 1 * 1;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__index__src(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_p" +
"alette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\n return 0;\n }\n size_t dst_len2 = dst.len / 2;\n size_t len = dst_len2 < src.len ? dst_len2 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n const size_t loop_unroll_count = 4;\n\n while (n >= loop_unroll_count) {\n wuffs_base__store_u16le__no_bounds_check(\n d + (0 * 2), wuffs_base__load_u16le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[0] * 4)));\n wuffs_base__store_u16le__no_bounds_check(\n d + (1 * 2), wuffs_base__load_u16le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[1] * 4)));\n wuffs_base__store_u16le__no_bounds_check(\n d + (2 * 2), wuffs_base__load_u16le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[2] * 4)));\n wuffs_base__store_u16le__no_bounds_check(\n d + (3 * 2), wuffs_base__load_u16le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[3] * 4)));\n\n s += l" +
"oop_unroll_count * 1;\n d += loop_unroll_count * 2;\n n -= loop_unroll_count;\n }\n\n while (n >= 1) {\n wuffs_base__store_u16le__no_bounds_check(\n d + (0 * 2), wuffs_base__load_u16le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[0] * 4)));\n\n s += 1 * 1;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr_565__index_binary_alpha__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\n return 0;\n }\n size_t dst_len2 = dst.len / 2;\n size_t len = dst_len2 < src.len ? dst_len2 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n if (s0) {\n wuffs_base__store_u16le__no_bounds_check(d + (0 * 2), (uint16_t)s0);\n " +
" }\n\n s += 1 * 1;\n d += 1 * 2;\n n -= 1;\n }\n\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len3 = dst.len / 3;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len3 < src_len4 ? dst_len3 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t s0 = wuffs_base__premul_u32_axxx(\n wuffs_base__load_u32le__no_bounds_check(s + (0 * 4)));\n wuffs_base__store_u24le__no_bounds_check(d + (0 * 3), s0);\n\n s += 1 * 4;\n d += 1 * 3;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len3 = dst.len / 3;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len3 < src_len4 ? dst_len3 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len" +
";\n\n // TODO: unroll.\n\n while (n >= 1) {\n // Convert from 8-bit color to 16-bit color.\n uint32_t sa = 0x101 * ((uint32_t)s[3]);\n uint32_t sr = 0x101 * ((uint32_t)s[2]);\n uint32_t sg = 0x101 * ((uint32_t)s[1]);\n uint32_t sb = 0x101 * ((uint32_t)s[0]);\n uint32_t dr = 0x101 * ((uint32_t)d[2]);\n uint32_t dg = 0x101 * ((uint32_t)d[1]);\n uint32_t db = 0x101 * ((uint32_t)d[0]);\n\n // Calculate the inverse of the src-alpha: how much of the dst to keep.\n uint32_t ia = 0xFFFF - sa;\n\n // Composite src (nonpremul) over dst (premul).\n dr = ((sr * sa) + (dr * ia)) / 0xFFFF;\n dg = ((sg * sa) + (dg * ia)) / 0xFFFF;\n db = ((sb * sa) + (db * ia)) / 0xFFFF;\n\n // Convert from 16-bit color to 8-bit color.\n d[0] = (uint8_t)(db >> 8);\n d[1] = (uint8_t)(dg >> 8);\n d[2] = (uint8_t)(dr >> 8);\n\n s += 1 * 4;\n d += 1 * 3;\n n -= 1;\n }\n\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgra_nonpremul__bgra_nonpremul__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len4 < src_len4 ? dst_len4 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t d0 = wuffs_base__load_u32le__no_bounds_check(d + (0 * 4));\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(s + (0 * 4));\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4),\n wuffs_base__composite_nonpremul_nonpremul_u32_axxx(d0, s0));\n\n s += 1 * 4;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len4 < src_len4 ? dst_len4 : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(s + (0 * 4));\n wuffs_base__store_u32le__no_bounds_check(d + (0 * 4),\n wuffs_base__premul_u32_axxx(s0));\n\n s += 1 * 4;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__bgra_premul__bgra_nonpremul__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t src_len4 = src.len / 4;\n size_t len = dst_len4 < src_len4 ? dst_len4 : src_len4;\n uint8_t* d" +
" = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint32_t d0 = wuffs_base__load_u32le__no_bounds_check(d + (0 * 4));\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(s + (0 * 4));\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4), wuffs_base__composite_premul_nonpremul_u32_axxx(d0, s0));\n\n s += 1 * 4;\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(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\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 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__store_u32le__no_bounds_check(\n d + (0 * 3), wuffs_base__load_u32le__no_bounds_c" +
"heck(\n dst_palette.ptr + ((size_t)s[0] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (1 * 3), wuffs_base__load_u32le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[1] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (2 * 3), wuffs_base__load_u32le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[2] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (3 * 3), wuffs_base__load_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__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n wuffs_base__store_u24le__no_bounds_check(d + (0 * 3), s0);\n\n s += 1 * 1;\n d += 1 * 3;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__" +
"pixel_swizzler__xxx__index_binary_alpha__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\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 uint8_t* s = src.ptr;\n size_t n = len;\n\n const size_t loop_unroll_count = 4;\n\n while (n >= loop_unroll_count) {\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n if (s0) {\n wuffs_base__store_u24le__no_bounds_check(d + (0 * 3), s0);\n }\n uint32_t s1 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[1] * 4));\n if (s1) {\n wuffs_base__store_u24le__no_bounds_check(d + (1 * 3), s1);\n }\n uint32_t s2 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n " +
" ((size_t)s[2] * 4));\n if (s2) {\n wuffs_base__store_u24le__no_bounds_check(d + (2 * 3), s2);\n }\n uint32_t s3 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[3] * 4));\n if (s3) {\n wuffs_base__store_u24le__no_bounds_check(d + (3 * 3), s3);\n }\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__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n if (s0) {\n wuffs_base__store_u24le__no_bounds_check(d + (0 * 3), s0);\n }\n\n s += 1 * 1;\n d += 1 * 3;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxx__y(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\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 uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n uint8_t s0 = s[0];\n d[0] = s0;\n d[1] = s0;\n d[2] = s0;\n\n s += 1 * 1;\n d += 1 * 3;\n n -= 1;\n }\n\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxxx__index__src(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\n return 0;\n }\n size_t dst_len4 = dst.len / 4;\n size_t len = dst_len4 < src.len ? dst_len4 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n const size_t loop_unroll_count = 4;\n\n while (n >= loop_unroll_count) {\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4), wuffs_base__load_u32le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[0] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (1 * 4), wuffs_base__load_u32le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[1] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (2 * 4), wuffs_base__load_u32le__no_bounds_check(\n dst_pale" +
"tte.ptr + ((size_t)s[2] * 4)));\n wuffs_base__store_u32le__no_bounds_check(\n d + (3 * 4), wuffs_base__load_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 * 4;\n n -= loop_unroll_count;\n }\n\n while (n >= 1) {\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4), wuffs_base__load_u32le__no_bounds_check(\n dst_palette.ptr + ((size_t)s[0] * 4)));\n\n s += 1 * 1;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxxx__index_binary_alpha__src_over(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (dst_palette.len != 1024) {\n return 0;\n }\n size_t dst_len4 = dst.len / 4;\n size_t len = dst_len4 < src.len ? dst_len4 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n const size_t loop_unroll_count = 4;\n\n while (n >= loop_unroll_count)" +
" {\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n if (s0) {\n wuffs_base__store_u32le__no_bounds_check(d + (0 * 4), s0);\n }\n uint32_t s1 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[1] * 4));\n if (s1) {\n wuffs_base__store_u32le__no_bounds_check(d + (1 * 4), s1);\n }\n uint32_t s2 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[2] * 4));\n if (s2) {\n wuffs_base__store_u32le__no_bounds_check(d + (2 * 4), s2);\n }\n uint32_t s3 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[3] * 4));\n if (s3) {\n wuffs_base__store_u32le__no_bounds_check(d + (3 * 4), s3);\n }\n\n s += loop_unroll_count * 1;\n d += loop_unroll_count *" +
" 4;\n n -= loop_unroll_count;\n }\n\n while (n >= 1) {\n uint32_t s0 = wuffs_base__load_u32le__no_bounds_check(dst_palette.ptr +\n ((size_t)s[0] * 4));\n if (s0) {\n wuffs_base__store_u32le__no_bounds_check(d + (0 * 4), s0);\n }\n\n s += 1 * 1;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxxx__xxx(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t src_len3 = src.len / 3;\n size_t len = dst_len4 < src_len3 ? dst_len4 : src_len3;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4),\n 0xFF000000 | wuffs_base__load_u24le__no_bounds_check(s + (0 * 3)));\n\n s += 1 * 3;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n" +
"\nstatic uint64_t //\nwuffs_base__pixel_swizzler__xxxx__y(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n size_t dst_len4 = dst.len / 4;\n size_t len = dst_len4 < src.len ? dst_len4 : src.len;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n // TODO: unroll.\n\n while (n >= 1) {\n wuffs_base__store_u32le__no_bounds_check(\n d + (0 * 4), 0xFF000000 | (0x010101 * (uint32_t)s[0]));\n\n s += 1 * 1;\n d += 1 * 4;\n n -= 1;\n }\n\n return len;\n}\n\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_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_format.repr) {\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_BASE__PIXEL_FORMAT__RGBA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:\n case WU" +
"FFS_BASE__PIXEL_FORMAT__RGBX:\n return wuffs_base__pixel_swizzler__xxxx__y;\n }\n return NULL;\n}\n\nstatic wuffs_base__pixel_swizzler__func //\nwuffs_base__pixel_swizzler__prepare__indexed__bgra_binary(\n wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_format.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL:\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\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 if (wuffs_base__pixel_swizzler__squash_bgr_565_888(dst_palette,\n " +
" src_palette) != 1024) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__bgr_565__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__bgr_565__index_binary_alpha__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_palette) !=\n 1024) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__xxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__xxx__index_binary_alpha__src_over;\n }\n return NULL;\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 if (wuffs_base__slice_u8__copy_from_slice(dst_palette, src_pa" +
"lette) !=\n 1024) {\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_OVER:\n return wuffs_base__pixel_swizzler__xxxx__index_binary_alpha__src_over;\n }\n return NULL;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\n if (wuffs_base__pixel_swizzler__swap_rgbx_bgrx(dst_palette,\n src_palette) != 1024) {\n return NULL;\n }\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swizzler__xxx__index__src;\n case WUFFS_BASE__PIXEL_BLEND__SRC_OVER:\n return wuffs_base__pixel_swizzler__xxx__index_binary_alpha__src_over;\n }\n return NULL;\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 if (wuffs_base__pixel_swizzler__" +
"swap_rgbx_bgrx(dst_palette,\n src_palette) != 1024) {\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_OVER:\n return wuffs_base__pixel_swizzler__xxxx__index_binary_alpha__src_over;\n }\n return NULL;\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_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_format.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__B" +
"GR:\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__xxxx__xxx;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\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 // TODO.\n break;\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_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n switch (dst_format.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__BGR_565:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_b" +
"ase__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_PREMUL:\n switch (blend) {\n case WUFFS_BASE__PIXEL_BLEND__SRC:\n return wuffs_base__pixel_swiz" +
"zler__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__BGRA_BINARY:\n case WUFFS_BASE__PIXEL_FORMAT__BGRX:\n // TODO.\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__RGB:\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 // TODO.\n break;\n }\n return NULL;\n}\n\n" +
"" +
"// --------\n\nwuffs_base__status //\nwuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend) {\n if (!p) {\n return wuffs_base__make_status(wuffs_base__error__bad_receiver);\n }\n\n // TODO: support many more formats.\n\n wuffs_base__pixel_swizzler__func func = NULL;\n\n switch (src_format.repr) {\n case WUFFS_BASE__PIXEL_FORMAT__Y:\n func = wuffs_base__pixel_swizzler__prepare__y(p, dst_format, dst_palette,\n src_palette, blend);\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY:\n func = wuffs_base__pixel_swizzler__prepare__indexed__bgra_binary(\n p, dst_format, dst_" +
"palette, src_palette, blend);\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGR:\n func = wuffs_base__pixel_swizzler__prepare__bgr(\n p, dst_format, dst_palette, src_palette, blend);\n break;\n\n case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:\n func = wuffs_base__pixel_swizzler__prepare__bgra_nonpremul(\n p, dst_format, dst_palette, src_palette, blend);\n break;\n }\n\n p->private_impl.func = func;\n return wuffs_base__make_status(\n func ? NULL : wuffs_base__error__unsupported_pixel_swizzler_option);\n}\n\nuint64_t //\nwuffs_base__pixel_swizzler__swizzle_interleaved(\n const wuffs_base__pixel_swizzler* p,\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) {\n if (p && p->private_impl.func) {\n return (*p->private_impl.func)(dst, dst_palette, src);\n }\n return 0;\n}\n" +
""
const baseStrConvImplC = "" +
"// ---------------- String Conversions\n\n// wuffs_base__parse_number__foo_digits entries are 0x00 for invalid digits,\n// and (0x80 | v) for valid digits, where v is the 4 bit value.\n\nstatic const uint8_t wuffs_base__parse_number__decimal_digits[256] = {\n // 0 1 2 3 4 5 6 7\n // 8 9 A B C D E F\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.\n 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.\n 0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.\n 0x00, 0" +
"x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, " +
"0x00, 0x00, // 0xB8 ..= 0xBF.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.\n // 0 1 2 3 4 5 6 7\n // 8 9 A B C D E F\n};\n\nstatic const uint8_t wuffs_base__parse_number__hexadecimal_digits[256] = {\n // 0 1 2 3 4 5 6 7\n // 8 9 A B C D E F\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F." +
"\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.\n 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, // 0x30 ..= 0x37. '0'-'7'.\n 0x88, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F. '8'-'9'.\n\n 0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x40 ..= 0x47. 'A'-'F'.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.\n 0x00, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x00, // 0x60 ..= 0x67. 'a'-'f'.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 ..= 0x6F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 .." +
"= 0x7F.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x80 ..= 0x87.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x88 ..= 0x8F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x90 ..= 0x97.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x98 ..= 0x9F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA0 ..= 0xA7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xA8 ..= 0xAF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB0 ..= 0xB7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xB8 ..= 0xBF.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC0 ..= 0xC7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xC8 ..= 0xCF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD0 ..= 0xD7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xD8 ..= 0xDF.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE0 ..= 0xE7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xE8 ..= 0xEF.\n 0x00, 0x00, 0x00" +
", 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF0 ..= 0xF7.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0xF8 ..= 0xFF.\n // 0 1 2 3 4 5 6 7\n // 8 9 A B C D E F\n};\n\n" +
"" +
"// --------\n\nwuffs_base__result_i64 //\nwuffs_base__parse_number_i64(wuffs_base__slice_u8 s) {\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n\n for (; (p < q) && (*p == '_'); p++) {\n }\n\n bool negative = false;\n if (p >= q) {\n goto fail_bad_argument;\n } else if (*p == '-') {\n p++;\n negative = true;\n } else if (*p == '+') {\n p++;\n }\n\n do {\n wuffs_base__result_u64 r = wuffs_base__parse_number_u64(\n wuffs_base__make_slice_u8(p, (size_t)(q - p)));\n if (r.status.repr != NULL) {\n wuffs_base__result_i64 ret;\n ret.status.repr = r.status.repr;\n ret.value = 0;\n return ret;\n } else if (negative) {\n if (r.value > 0x8000000000000000) {\n goto fail_out_of_bounds;\n }\n wuffs_base__result_i64 ret;\n ret.status.repr = NULL;\n ret.value = -(int64_t)(r.value);\n return ret;\n } else if (r.value > 0x7FFFFFFFFFFFFFFF) {\n goto fail_out_of_bounds;\n } else {\n wuffs_base__result_i64 ret;\n ret.status.repr = NULL;\n ret.v" +
"alue = +(int64_t)(r.value);\n return ret;\n }\n } while (0);\n\nfail_bad_argument:\n do {\n wuffs_base__result_i64 ret;\n ret.status.repr = wuffs_base__error__bad_argument;\n ret.value = 0;\n return ret;\n } while (0);\n\nfail_out_of_bounds:\n do {\n wuffs_base__result_i64 ret;\n ret.status.repr = wuffs_base__error__out_of_bounds;\n ret.value = 0;\n return ret;\n } while (0);\n}\n\nwuffs_base__result_u64 //\nwuffs_base__parse_number_u64(wuffs_base__slice_u8 s) {\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n\n for (; (p < q) && (*p == '_'); p++) {\n }\n\n if (p >= q) {\n goto fail_bad_argument;\n\n } else if (*p == '0') {\n p++;\n if (p >= q) {\n goto ok_zero;\n }\n if (*p == '_') {\n p++;\n for (; p < q; p++) {\n if (*p != '_') {\n goto fail_bad_argument;\n }\n }\n goto ok_zero;\n }\n\n if ((*p == 'x') || (*p == 'X')) {\n p++;\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p < q) {\n goto hexadecimal;\n }\n\n " +
" } else if ((*p == 'd') || (*p == 'D')) {\n p++;\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p < q) {\n goto decimal;\n }\n }\n\n goto fail_bad_argument;\n }\n\ndecimal:\n do {\n uint64_t v = wuffs_base__parse_number__decimal_digits[*p++];\n if (v == 0) {\n goto fail_bad_argument;\n }\n v &= 0x0F;\n\n // UINT64_MAX is 18446744073709551615, which is ((10 * max10) + max1).\n const uint64_t max10 = 1844674407370955161;\n const uint8_t max1 = 5;\n\n for (; p < q; p++) {\n if (*p == '_') {\n continue;\n }\n uint8_t digit = wuffs_base__parse_number__decimal_digits[*p];\n if (digit == 0) {\n goto fail_bad_argument;\n }\n digit &= 0x0F;\n if ((v > max10) || ((v == max10) && (digit > max1))) {\n goto fail_out_of_bounds;\n }\n v = (10 * v) + ((uint64_t)(digit));\n }\n\n wuffs_base__result_u64 ret;\n ret.status.repr = NULL;\n ret.value = v;\n return ret;\n } while (0);\n\nhexadecimal:\n do {\n uint64_t v = " +
"wuffs_base__parse_number__hexadecimal_digits[*p++];\n if (v == 0) {\n goto fail_bad_argument;\n }\n v &= 0x0F;\n\n for (; p < q; p++) {\n if (*p == '_') {\n continue;\n }\n uint8_t digit = wuffs_base__parse_number__hexadecimal_digits[*p];\n if (digit == 0) {\n goto fail_bad_argument;\n }\n digit &= 0x0F;\n if ((v >> 60) != 0) {\n goto fail_out_of_bounds;\n }\n v = (v << 4) | ((uint64_t)(digit));\n }\n\n wuffs_base__result_u64 ret;\n ret.status.repr = NULL;\n ret.value = v;\n return ret;\n } while (0);\n\nok_zero:\n do {\n wuffs_base__result_u64 ret;\n ret.status.repr = NULL;\n ret.value = 0;\n return ret;\n } while (0);\n\nfail_bad_argument:\n do {\n wuffs_base__result_u64 ret;\n ret.status.repr = wuffs_base__error__bad_argument;\n ret.value = 0;\n return ret;\n } while (0);\n\nfail_out_of_bounds:\n do {\n wuffs_base__result_u64 ret;\n ret.status.repr = wuffs_base__error__out_of_bounds;\n ret.value = 0;\n return ret;\n " +
" } while (0);\n}\n\n " +
"" +
"// ---------------- IEEE 754 Floating Point\n\n#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE 1023\n#define WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION 500\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 500 decimal digits. 500 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 +1023 mean infinity, below -1023 mean zero. Th" +
"e ±1023\n// bounds are further away from zero than ±(324 + 500), where 500 and 1023 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 +1023 means that the overall value is\n// infinity, lower than -1023 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 {\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_base__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\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 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 for (; (p < q) && (*p == '_'); p++) {\n }\n if (p >= q) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\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 for (; (p < q) && (*p == '_'); p++) {\n }\n } while (0);\n\n // Parse digits.\n uint32_t nd = 0;\n int32_t dp = 0;\n bool saw_digits = false;\n " +
"bool saw_non_zero_digits = false;\n bool saw_dot = false;\n for (; p < q; p++) {\n if (*p == '_') {\n // No-op.\n\n } else if ((*p == '.') || (*p == ',')) {\n // As per https://en.wikipedia.org/wiki/Decimal_separator, both '.' or\n // ',' are commonly used. We just parse either, regardless of LOCALE.\n if (saw_dot) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n saw_dot = true;\n dp = (int32_t)nd;\n\n } else if ('0' == *p) {\n if (!saw_dot && !saw_non_zero_digits && saw_digits) {\n // We don't allow unnecessary leading zeroes: \"000123\" or \"0644\".\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n saw_digits = true;\n if (nd == 0) {\n // Track leading zeroes implicitly.\n dp--;\n } else if (nd <\n WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->digits[nd++] = 0;\n } else {\n // Long-tail zeroes are ignored.\n }\n\n } else if (('" +
"0' < *p) && (*p <= '9')) {\n if (!saw_dot && !saw_non_zero_digits && saw_digits) {\n // We don't allow unnecessary leading zeroes: \"000123\" or \"0644\".\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n saw_digits = true;\n saw_non_zero_digits = true;\n if (nd < WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION) {\n h->digits[nd++] = (uint8_t)(*p - '0');\n } else {\n // Long-tail non-zeroes set the truncated bit.\n h->truncated = true;\n }\n\n } else {\n break;\n }\n }\n\n if (!saw_digits) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n if (!saw_dot) {\n dp = (int32_t)nd;\n }\n\n // Parse exponent.\n if ((p < q) && ((*p == 'E') || (*p == 'e'))) {\n p++;\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p >= q) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n\n int32_t exp_sign = +1;\n if (*p == '+') {\n p++;\n } else if (*p == '-') {\n " +
"exp_sign = -1;\n p++;\n }\n\n int32_t exp = 0;\n const int32_t exp_large =\n WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE +\n WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DIGITS_PRECISION;\n bool saw_exp_digits = false;\n for (; p < q; p++) {\n if (*p == '_') {\n // No-op.\n } else if (('0' <= *p) && (*p <= '9')) {\n saw_exp_digits = true;\n if (exp < exp_large) {\n exp = (10 * exp) + ((int32_t)(*p - '0'));\n }\n } else {\n break;\n }\n }\n if (!saw_exp_digits) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n dp += exp_sign * exp;\n }\n\n // Finish.\n if (p != q) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n h->num_digits = nd;\n if (nd == 0) {\n h->decimal_point = 0;\n } else if (dp <\n -WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE) {\n h->decimal_point =\n -WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__" +
"RANGE - 1;\n } else if (dp >\n +WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE) {\n h->decimal_point =\n +WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__DECIMAL_POINT__RANGE + 1;\n } else {\n h->decimal_point = dp;\n }\n wuffs_base__private_implementation__high_prec_dec__trim(h);\n return wuffs_base__make_status(NULL);\n}\n\n" +
"" +
"// --------\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. mul" +
"tiplying 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 11 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// concatenated together: \"5\", \"" +
"25\", \"125\", \"625\", \"3125\", etc.\nstatic const uint8_t wuffs_base__private_implementation__powers_of_5[0x051C] = {\n 5, 2, 5, 1, 2, 5, 6, 2, 5, 3, 1, 2, 5, 1, 5, 6, 2, 5, 7, 8, 1, 2, 5, 3, 9,\n 0, 6, 2, 5, 1, 9, 5, 3, 1, 2, 5, 9, 7, 6, 5, 6, 2, 5, 4, 8, 8, 2, 8, 1, 2,\n 5, 2, 4, 4, 1, 4, 0, 6, 2, 5, 1, 2, 2, 0, 7, 0, 3, 1, 2, 5, 6, 1, 0, 3, 5,\n 1, 5, 6, 2, 5, 3, 0, 5, 1, 7, 5, 7, 8, 1, 2, 5, 1, 5, 2, 5, 8, 7, 8, 9, 0,\n 6, 2, 5, 7, 6, 2, 9, 3, 9, 4, 5, 3, 1, 2, 5, 3, 8, 1, 4, 6, 9, 7, 2, 6, 5,\n 6, 2, 5, 1, 9, 0, 7, 3, 4, 8, 6, 3, 2, 8, 1, 2, 5, 9, 5, 3, 6, 7, 4, 3, 1,\n 6, 4, 0, 6, 2, 5, 4, 7, 6, 8, 3, 7, 1, 5, 8, 2, 0, 3, 1, 2, 5, 2, 3, 8, 4,\n 1, 8, 5, 7, 9, 1, 0, 1, 5, 6, 2, 5, 1, 1, 9, 2, 0, 9, 2, 8, 9, 5, 5, 0, 7,\n 8, 1, 2, 5, 5, 9, 6, 0, 4, 6, 4, 4, 7, 7, 5, 3, 9, 0, 6, 2, 5, 2, 9, 8, 0,\n 2, 3, 2, 2, 3, 8, 7, 6, 9, 5, 3, 1, 2, 5, 1, 4, 9, 0, 1, 1, 6, 1, 1, 9, 3,\n 8, 4, 7, 6, 5, 6, 2, 5, 7, 4, 5, 0, 5, 8, 0, 5, 9, 6, 9, 2, 3, 8, 2, 8, 1,\n 2, 5, 3, 7, 2, 5, 2, 9, 0, 2, 9, 8, 4," +
" 6, 1, 9, 1, 4, 0, 6, 2, 5, 1, 8, 6,\n 2, 6, 4, 5, 1, 4, 9, 2, 3, 0, 9, 5, 7, 0, 3, 1, 2, 5, 9, 3, 1, 3, 2, 2, 5,\n 7, 4, 6, 1, 5, 4, 7, 8, 5, 1, 5, 6, 2, 5, 4, 6, 5, 6, 6, 1, 2, 8, 7, 3, 0,\n 7, 7, 3, 9, 2, 5, 7, 8, 1, 2, 5, 2, 3, 2, 8, 3, 0, 6, 4, 3, 6, 5, 3, 8, 6,\n 9, 6, 2, 8, 9, 0, 6, 2, 5, 1, 1, 6, 4, 1, 5, 3, 2, 1, 8, 2, 6, 9, 3, 4, 8,\n 1, 4, 4, 5, 3, 1, 2, 5, 5, 8, 2, 0, 7, 6, 6, 0, 9, 1, 3, 4, 6, 7, 4, 0, 7,\n 2, 2, 6, 5, 6, 2, 5, 2, 9, 1, 0, 3, 8, 3, 0, 4, 5, 6, 7, 3, 3, 7, 0, 3, 6,\n 1, 3, 2, 8, 1, 2, 5, 1, 4, 5, 5, 1, 9, 1, 5, 2, 2, 8, 3, 6, 6, 8, 5, 1, 8,\n 0, 6, 6, 4, 0, 6, 2, 5, 7, 2, 7, 5, 9, 5, 7, 6, 1, 4, 1, 8, 3, 4, 2, 5, 9,\n 0, 3, 3, 2, 0, 3, 1, 2, 5, 3, 6, 3, 7, 9, 7, 8, 8, 0, 7, 0, 9, 1, 7, 1, 2,\n 9, 5, 1, 6, 6, 0, 1, 5, 6, 2, 5, 1, 8, 1, 8, 9, 8, 9, 4, 0, 3, 5, 4, 5, 8,\n 5, 6, 4, 7, 5, 8, 3, 0, 0, 7, 8, 1, 2, 5, 9, 0, 9, 4, 9, 4, 7, 0, 1, 7, 7,\n 2, 9, 2, 8, 2, 3, 7, 9, 1, 5, 0, 3, 9, 0, 6, 2, 5, 4, 5, 4, 7, 4, 7, 3, 5,\n 0, 8, 8, 6, 4, 6, 4, 1, 1, 8, 9, 5," +
" 7, 5, 1, 9, 5, 3, 1, 2, 5, 2, 2, 7, 3,\n 7, 3, 6, 7, 5, 4, 4, 3, 2, 3, 2, 0, 5, 9, 4, 7, 8, 7, 5, 9, 7, 6, 5, 6, 2,\n 5, 1, 1, 3, 6, 8, 6, 8, 3, 7, 7, 2, 1, 6, 1, 6, 0, 2, 9, 7, 3, 9, 3, 7, 9,\n 8, 8, 2, 8, 1, 2, 5, 5, 6, 8, 4, 3, 4, 1, 8, 8, 6, 0, 8, 0, 8, 0, 1, 4, 8,\n 6, 9, 6, 8, 9, 9, 4, 1, 4, 0, 6, 2, 5, 2, 8, 4, 2, 1, 7, 0, 9, 4, 3, 0, 4,\n 0, 4, 0, 0, 7, 4, 3, 4, 8, 4, 4, 9, 7, 0, 7, 0, 3, 1, 2, 5, 1, 4, 2, 1, 0,\n 8, 5, 4, 7, 1, 5, 2, 0, 2, 0, 0, 3, 7, 1, 7, 4, 2, 2, 4, 8, 5, 3, 5, 1, 5,\n 6, 2, 5, 7, 1, 0, 5, 4, 2, 7, 3, 5, 7, 6, 0, 1, 0, 0, 1, 8, 5, 8, 7, 1, 1,\n 2, 4, 2, 6, 7, 5, 7, 8, 1, 2, 5, 3, 5, 5, 2, 7, 1, 3, 6, 7, 8, 8, 0, 0, 5,\n 0, 0, 9, 2, 9, 3, 5, 5, 6, 2, 1, 3, 3, 7, 8, 9, 0, 6, 2, 5, 1, 7, 7, 6, 3,\n 5, 6, 8, 3, 9, 4, 0, 0, 2, 5, 0, 4, 6, 4, 6, 7, 7, 8, 1, 0, 6, 6, 8, 9, 4,\n 5, 3, 1, 2, 5, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3,\n 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5, 4, 4, 4, 0, 8, 9, 2, 0, 9, 8,\n 5, 0, 0, 6, 2, 6, 1, 6, 1, 6, 9," +
" 4, 5, 2, 6, 6, 7, 2, 3, 6, 3, 2, 8, 1, 2,\n 5, 2, 2, 2, 0, 4, 4, 6, 0, 4, 9, 2, 5, 0, 3, 1, 3, 0, 8, 0, 8, 4, 7, 2, 6,\n 3, 3, 3, 6, 1, 8, 1, 6, 4, 0, 6, 2, 5, 1, 1, 1, 0, 2, 2, 3, 0, 2, 4, 6, 2,\n 5, 1, 5, 6, 5, 4, 0, 4, 2, 3, 6, 3, 1, 6, 6, 8, 0, 9, 0, 8, 2, 0, 3, 1, 2,\n 5, 5, 5, 5, 1, 1, 1, 5, 1, 2, 3, 1, 2, 5, 7, 8, 2, 7, 0, 2, 1, 1, 8, 1, 5,\n 8, 3, 4, 0, 4, 5, 4, 1, 0, 1, 5, 6, 2, 5, 2, 7, 7, 5, 5, 5, 7, 5, 6, 1, 5,\n 6, 2, 8, 9, 1, 3, 5, 1, 0, 5, 9, 0, 7, 9, 1, 7, 0, 2, 2, 7, 0, 5, 0, 7, 8,\n 1, 2, 5, 1, 3, 8, 7, 7, 7, 8, 7, 8, 0, 7, 8, 1, 4, 4, 5, 6, 7, 5, 5, 2, 9,\n 5, 3, 9, 5, 8, 5, 1, 1, 3, 5, 2, 5, 3, 9, 0, 6, 2, 5, 6, 9, 3, 8, 8, 9, 3,\n 9, 0, 3, 9, 0, 7, 2, 2, 8, 3, 7, 7, 6, 4, 7, 6, 9, 7, 9, 2, 5, 5, 6, 7, 6,\n 2, 6, 9, 5, 3, 1, 2, 5, 3, 4, 6, 9, 4, 4, 6, 9, 5, 1, 9, 5, 3, 6, 1, 4, 1,\n 8, 8, 8, 2, 3, 8, 4, 8, 9, 6, 2, 7, 8, 3, 8, 1, 3, 4, 7, 6, 5, 6, 2, 5, 1,\n 7, 3, 4, 7, 2, 3, 4, 7, 5, 9, 7, 6, 8, 0, 7, 0, 9, 4, 4, 1, 1, 9, 2, 4, 4,\n 8, 1, 3, 9, 1, 9, 0, 6, 7, 3," +
" 8, 2, 8, 1, 2, 5, 8, 6, 7, 3, 6, 1, 7, 3, 7,\n 9, 8, 8, 4, 0, 3, 5, 4, 7, 2, 0, 5, 9, 6, 2, 2, 4, 0, 6, 9, 5, 9, 5, 3, 3,\n 6, 9, 1, 4, 0, 6, 2, 5,\n};\n\n// wuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits\n// returns the number of additional decimal digits when left-shifting by shift.\n//\n// See below for preconditions.\nstatic uint32_t //\nwuffs_base__private_implementation__high_prec_dec__lshift_num_new_digits(\n wuffs_base__private_implementation__high_prec_dec* h,\n uint32_t shift) {\n // Masking with 0x3F should be unnecessary (assuming the preconditions) but\n // it's cheap and ensures that we don't overflow the\n // wuffs_base__private_implementation__hpd_left_shift array.\n shift &= 63;\n\n uint32_t x_a = wuffs_base__private_implementation__hpd_left_shift[shift];\n uint32_t x_b = wuffs_base__private_implementation__hpd_left_shift[shift + 1];\n uint32_t num_new_digits = x_a >> 11;\n uint32_t pow5_a = 0x7FF & x_a;\n uint32_t pow5_b = 0x7FF & x_b;\n\n const uint8_t* pow5 =\n " +
" &wuffs_base__private_implementation__powers_of_5[pow5_a];\n uint32_t i = 0;\n uint32_t n = pow5_b - pow5_a;\n for (; i < n; i++) {\n if (i >= h->num_digits) {\n return num_new_digits - 1;\n } else if (h->digits[i] == pow5[i]) {\n continue;\n } else if (h->digits[i] < pow5[i]) {\n return num_new_digits - 1;\n } else {\n return num_new_digits;\n }\n }\n return num_new_digits;\n}\n\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\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->d" +
"igits[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_prec_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->negative = false;\n h->truncated = false;\n return;\n }\n\n // Repeat: pick up a digit, 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_digi" +
"t;\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\n" +
"" +
"// --------\n\n// The wuffs_base__private_implementation__etc_powers_of_10 tables were printed\n// by script/print-mpb-powers-of-10.go. That script has an optional -comments\n// flag, whose output is not copied here, which prints further detail.\n//\n// These tables are used in\n// wuffs_base__private_implementation__medium_prec_bin__assign_from_hpd.\n\n// wuffs_base__private_implementation__big_powers_of_10 contains approximations\n// to the powers of 10, ranging from 1e-348 to 1e+340, with the exponent\n// stepping by 8: -348, -340, -332, ..., -12, -4, +4, +12, ..., +340. Each step\n// consists of three uint32_t elements. There are 87 triples, 87 * 3 = 261.\n//\n// For example, the third approximation, for 1e-332, consists of the uint32_t\n// triple (0x3055AC76, 0x8B16FB20, 0xFFFFFB72). The first two of that triple\n// are a little-endian uint64_t value: 0x8B16FB203055AC76. The last one is an\n// int32_t value: -1166. Together, they represent the approximation:\n// 1e-332 ≈ 0x8B16FB203055AC76 * (2 ** -1166)\n// Similarly," +
" the (0x00000000, 0x9C400000, 0xFFFFFFCE) uint32_t triple means:\n// 1e+4 ≈ 0x9C40000000000000 * (2 ** -50) // This approx'n is exact.\n// Similarly, the (0xD4C4FB27, 0xED63A231, 0x000000A2) uint32_t triple means:\n// 1e+68 ≈ 0xED63A231D4C4FB27 * (2 ** 162)\nstatic const uint32_t\n wuffs_base__private_implementation__big_powers_of_10[261] = {\n 0x081C0288, 0xFA8FD5A0, 0xFFFFFB3C, 0xA23EBF76, 0xBAAEE17F, 0xFFFFFB57,\n 0x3055AC76, 0x8B16FB20, 0xFFFFFB72, 0x5DCE35EA, 0xCF42894A, 0xFFFFFB8C,\n 0x55653B2D, 0x9A6BB0AA, 0xFFFFFBA7, 0x3D1A45DF, 0xE61ACF03, 0xFFFFFBC1,\n 0xC79AC6CA, 0xAB70FE17, 0xFFFFFBDC, 0xBEBCDC4F, 0xFF77B1FC, 0xFFFFFBF6,\n 0x416BD60C, 0xBE5691EF, 0xFFFFFC11, 0x907FFC3C, 0x8DD01FAD, 0xFFFFFC2C,\n 0x31559A83, 0xD3515C28, 0xFFFFFC46, 0xADA6C9B5, 0x9D71AC8F, 0xFFFFFC61,\n 0x23EE8BCB, 0xEA9C2277, 0xFFFFFC7B, 0x4078536D, 0xAECC4991, 0xFFFFFC96,\n 0x5DB6CE57, 0x823C1279, 0xFFFFFCB1, 0x4DFB5637, 0xC2109436, 0xFFFFFCCB,\n 0x3848984F, 0x909" +
"6EA6F, 0xFFFFFCE6, 0x25823AC7, 0xD77485CB, 0xFFFFFD00,\n 0x97BF97F4, 0xA086CFCD, 0xFFFFFD1B, 0x172AACE5, 0xEF340A98, 0xFFFFFD35,\n 0x2A35B28E, 0xB23867FB, 0xFFFFFD50, 0xD2C63F3B, 0x84C8D4DF, 0xFFFFFD6B,\n 0x1AD3CDBA, 0xC5DD4427, 0xFFFFFD85, 0xBB25C996, 0x936B9FCE, 0xFFFFFDA0,\n 0x7D62A584, 0xDBAC6C24, 0xFFFFFDBA, 0x0D5FDAF6, 0xA3AB6658, 0xFFFFFDD5,\n 0xDEC3F126, 0xF3E2F893, 0xFFFFFDEF, 0xAAFF80B8, 0xB5B5ADA8, 0xFFFFFE0A,\n 0x6C7C4A8B, 0x87625F05, 0xFFFFFE25, 0x34C13053, 0xC9BCFF60, 0xFFFFFE3F,\n 0x91BA2655, 0x964E858C, 0xFFFFFE5A, 0x70297EBD, 0xDFF97724, 0xFFFFFE74,\n 0xB8E5B88F, 0xA6DFBD9F, 0xFFFFFE8F, 0x88747D94, 0xF8A95FCF, 0xFFFFFEA9,\n 0x8FA89BCF, 0xB9447093, 0xFFFFFEC4, 0xBF0F156B, 0x8A08F0F8, 0xFFFFFEDF,\n 0x653131B6, 0xCDB02555, 0xFFFFFEF9, 0xD07B7FAC, 0x993FE2C6, 0xFFFFFF14,\n 0x2A2B3B06, 0xE45C10C4, 0xFFFFFF2E, 0x697392D3, 0xAA242499, 0xFFFFFF49,\n 0x8300CA0E, 0xFD87B5F2, 0xFFFFFF63, 0x92111AEB, 0xBCE50864, 0xFFFFFF7E,\n 0" +
"x6F5088CC, 0x8CBCCC09, 0xFFFFFF99, 0xE219652C, 0xD1B71758, 0xFFFFFFB3,\n 0x00000000, 0x9C400000, 0xFFFFFFCE, 0x00000000, 0xE8D4A510, 0xFFFFFFE8,\n 0xAC620000, 0xAD78EBC5, 0x00000003, 0xF8940984, 0x813F3978, 0x0000001E,\n 0xC90715B3, 0xC097CE7B, 0x00000038, 0x7BEA5C70, 0x8F7E32CE, 0x00000053,\n 0xABE98068, 0xD5D238A4, 0x0000006D, 0x179A2245, 0x9F4F2726, 0x00000088,\n 0xD4C4FB27, 0xED63A231, 0x000000A2, 0x8CC8ADA8, 0xB0DE6538, 0x000000BD,\n 0x1AAB65DB, 0x83C7088E, 0x000000D8, 0x42711D9A, 0xC45D1DF9, 0x000000F2,\n 0xA61BE758, 0x924D692C, 0x0000010D, 0x1A708DEA, 0xDA01EE64, 0x00000127,\n 0x9AEF774A, 0xA26DA399, 0x00000142, 0xB47D6B85, 0xF209787B, 0x0000015C,\n 0x79DD1877, 0xB454E4A1, 0x00000177, 0x5B9BC5C2, 0x865B8692, 0x00000192,\n 0xC8965D3D, 0xC83553C5, 0x000001AC, 0xFA97A0B3, 0x952AB45C, 0x000001C7,\n 0x99A05FE3, 0xDE469FBD, 0x000001E1, 0xDB398C25, 0xA59BC234, 0x000001FC,\n 0xA3989F5C, 0xF6C69A72, 0x00000216, 0x54E9BECE, 0xB7DCBF53, 0x000" +
"00231,\n 0xF22241E2, 0x88FCF317, 0x0000024C, 0xD35C78A5, 0xCC20CE9B, 0x00000266,\n 0x7B2153DF, 0x98165AF3, 0x00000281, 0x971F303A, 0xE2A0B5DC, 0x0000029B,\n 0x5CE3B396, 0xA8D9D153, 0x000002B6, 0xA4A7443C, 0xFB9B7CD9, 0x000002D0,\n 0xA7A44410, 0xBB764C4C, 0x000002EB, 0xB6409C1A, 0x8BAB8EEF, 0x00000306,\n 0xA657842C, 0xD01FEF10, 0x00000320, 0xE9913129, 0x9B10A4E5, 0x0000033B,\n 0xA19C0C9D, 0xE7109BFB, 0x00000355, 0x623BF429, 0xAC2820D9, 0x00000370,\n 0x7AA7CF85, 0x80444B5E, 0x0000038B, 0x03ACDD2D, 0xBF21E440, 0x000003A5,\n 0x5E44FF8F, 0x8E679C2F, 0x000003C0, 0x9C8CB841, 0xD433179D, 0x000003DA,\n 0xB4E31BA9, 0x9E19DB92, 0x000003F5, 0xBADF77D9, 0xEB96BF6E, 0x0000040F,\n 0x9BF0EE6B, 0xAF87023B, 0x0000042A,\n};\n\n// wuffs_base__private_implementation__small_powers_of_10 contains\n// approximations to the powers of 10, ranging from 1e+0 to 1e+7, with the\n// exponent stepping by 1. Each step consists of three uint32_t elements.\n//\n// For example, the third appr" +
"oximation, for 1e+2, consists of the uint32_t\n// triple (0x00000000, 0xC8000000, 0xFFFFFFC7). The first two of that triple\n// are a little-endian uint64_t value: 0xC800000000000000. The last one is an\n// int32_t value: -57. Together, they represent the approximation:\n// 1e+2 ≈ 0xC800000000000000 * (2 ** -57) // This approx'n is exact.\n// Similarly, the (0x00000000, 0x9C400000, 0xFFFFFFCE) uint32_t triple means:\n// 1e+4 ≈ 0x9C40000000000000 * (2 ** -50) // This approx'n is exact.\nstatic const uint32_t\n wuffs_base__private_implementation__small_powers_of_10[24] = {\n 0x00000000, 0x80000000, 0xFFFFFFC1, 0x00000000, 0xA0000000, 0xFFFFFFC4,\n 0x00000000, 0xC8000000, 0xFFFFFFC7, 0x00000000, 0xFA000000, 0xFFFFFFCA,\n 0x00000000, 0x9C400000, 0xFFFFFFCE, 0x00000000, 0xC3500000, 0xFFFFFFD1,\n 0x00000000, 0xF4240000, 0xFFFFFFD4, 0x00000000, 0x98968000, 0xFFFFFFD8,\n};\n\n// wuffs_base__private_implementation__f64_powers_of_10 holds powers of 10 that\n// can be exactly represented" +
" by a float64 (what C calls a double).\nstatic const double wuffs_base__private_implementation__f64_powers_of_10[23] = {\n 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11,\n 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22,\n};\n\n" +
"" +
"// --------\n\n// wuffs_base__private_implementation__medium_prec_bin (abbreviated as MPB) is\n// a fixed precision floating point binary number. Unlike IEEE 754 Floating\n// Point, it cannot represent infinity or NaN (Not a Number).\n//\n// \"Medium precision\" means that the mantissa holds 64 binary digits, a little\n// more than \"double precision\", and sizeof(MPB) > sizeof(double). 64 is\n// obviously the number of bits in a uint64_t.\n//\n// An MPB isn't for general purpose arithmetic, only for conversions to and\n// from IEEE 754 double-precision floating point.\n//\n// There is no implicit mantissa bit. The mantissa field is zero if and only if\n// the overall floating point value is ±0. An MPB is normalized if the mantissa\n// is zero or its high bit (the 1<<63 bit) is set.\n//\n// There is no negative bit. An MPB can only represent non-negative numbers.\n//\n// The \"all fields are zero\" value is valid, and represents the number +0.\n//\n// This is the \"Do It Yourself Floating Point\" data structure from Loitsch,\n// \"Printin" +
"g Floating-Point Numbers Quickly and Accurately with Integers\"\n// (https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf).\n//\n// Florian Loitsch is also the primary contributor to\n// https://github.com/google/double-conversion\ntypedef struct {\n uint64_t mantissa;\n int32_t exp2;\n} wuffs_base__private_implementation__medium_prec_bin;\n\nstatic uint32_t //\nwuffs_base__private_implementation__medium_prec_bin__normalize(\n wuffs_base__private_implementation__medium_prec_bin* m) {\n if (m->mantissa == 0) {\n return 0;\n }\n uint32_t shift = wuffs_base__count_leading_zeroes_u64(m->mantissa);\n m->mantissa <<= shift;\n m->exp2 -= (int32_t)shift;\n return shift;\n}\n\n// wuffs_base__private_implementation__medium_prec_bin__mul_pow_10 sets m to be\n// (m * pow), where pow comes from an etc_powers_of_10 triple starting at p.\n//\n// The result is rounded, but not necessarily normalized.\n//\n// Preconditions:\n// - m is non-NULL.\n// - m->mantissa is non-zero.\n// - m->mantissa's high bit is set (i.e. m is " +
"normalized).\n//\n// The etc_powers_of_10 triple is already normalized.\nstatic void //\nwuffs_base__private_implementation__medium_prec_bin__mul_pow_10(\n wuffs_base__private_implementation__medium_prec_bin* m,\n const uint32_t* p) {\n uint64_t p_mantissa = ((uint64_t)p[0]) | (((uint64_t)p[1]) << 32);\n int32_t p_exp2 = (int32_t)p[2];\n\n wuffs_base__multiply_u64__output o =\n wuffs_base__multiply_u64(m->mantissa, p_mantissa);\n // Round the mantissa up. It cannot overflow because the maximum possible\n // value of o.hi is 0xFFFFFFFFFFFFFFFE.\n m->mantissa = o.hi + (o.lo >> 63);\n m->exp2 = m->exp2 + p_exp2 + 64;\n}\n\n// wuffs_base__private_implementation__medium_prec_bin__as_f64 converts m to a\n// double (what C calls a double-precision float64).\n//\n// Preconditions:\n// - m is non-NULL.\n// - m->mantissa is non-zero.\n// - m->mantissa's high bit is set (i.e. m is normalized).\nstatic double //\nwuffs_base__private_implementation__medium_prec_bin__as_f64(\n const wuffs_base__private_implementation__mediu" +
"m_prec_bin* m,\n bool negative) {\n uint64_t mantissa64 = m->mantissa;\n // An mpb's mantissa has the implicit (binary) decimal point at the right\n // hand end of the mantissa's explicit digits. A double-precision's mantissa\n // has that decimal point near the left hand end. There's also an explicit\n // versus implicit leading 1 bit (binary digit). Together, the difference in\n // semantics corresponds to adding 63.\n int32_t exp2 = m->exp2 + 63;\n\n // Ensure that exp2 is at least -1022, the minimum double-precision exponent\n // for normal (as opposed to subnormal) numbers.\n if (-1022 > exp2) {\n uint32_t n = (uint32_t)(-1022 - exp2);\n mantissa64 >>= n;\n exp2 += (int32_t)n;\n }\n\n // Extract the (1 + 52) bits from the 64-bit mantissa64. 52 is the number of\n // explicit mantissa bits in a double-precision f64.\n //\n // Before, we have 64 bits and due to normalization, the high bit 'H' is 1.\n // 63 55 47 etc 15 7\n // H210_9876_5432_1098_7654_etc_etc_etc_5432_109" +
"8_7654_3210\n // ++++_++++_++++_++++_++++_etc_etc_etc_++++_+..._...._.... Kept bits.\n // ...._...._...H_2109_8765_etc_etc_etc_6543_2109_8765_4321 After shifting.\n // After, we have 53 bits (and bit #52 is this 'H' bit).\n uint64_t mantissa53 = mantissa64 >> 11;\n\n // Round up if the old bit #10 (the highest bit dropped by shifting) was set.\n // We also fix any overflow from rounding up.\n if (mantissa64 & 1024) {\n mantissa53++;\n if ((mantissa53 >> 53) != 0) {\n mantissa53 >>= 1;\n exp2++;\n }\n }\n\n // Handle double-precision infinity (a nominal exponent of 1024) and\n // subnormals (an exponent of -1023 and no implicit mantissa bit, bit #52).\n if (exp2 >= 1024) {\n mantissa53 = 0;\n exp2 = 1024;\n } else if ((mantissa53 >> 52) == 0) {\n exp2 = -1023;\n }\n\n // Pack the bits and return.\n const int32_t f64_bias = -1023;\n uint64_t exp2_bits =\n (uint64_t)((exp2 - f64_bias) & 0x07FF); // (1 << 11) - 1.\n uint64_t bits = (mantissa53 & 0x000FFFFFFFFFFFFF) | // (1 << 52" +
") - 1.\n (exp2_bits << 52) | //\n (negative ? 0x8000000000000000 : 0); // (1 << 63).\n return wuffs_base__ieee_754_bit_representation__to_f64(bits);\n}\n\n// wuffs_base__private_implementation__medium_prec_bin__parse_number_f64\n// converts from an HPD to a double, using an MPB as scratch space. It returns\n// a NULL status.repr if there is no ambiguity in the truncation or rounding to\n// a float64 (an IEEE 754 double-precision floating point value).\n//\n// It may modify m even if it returns a non-NULL status.repr.\nstatic wuffs_base__result_f64 //\nwuffs_base__private_implementation__medium_prec_bin__parse_number_f64(\n wuffs_base__private_implementation__medium_prec_bin* m,\n const wuffs_base__private_implementation__high_prec_dec* h,\n bool skip_fast_path_for_tests) {\n do {\n // m->mantissa is a uint64_t, which is an integer approximation to a\n // rational value - h's underlying digits after m's normalization. This\n // error is an upper bound on th" +
"e difference between the approximate and\n // actual value.\n //\n // The DiyFpStrtod function in https://github.com/google/double-conversion\n // uses a finer grain (1/8th of the ULP, Unit in the Last Place) when\n // tracking error. This implementation is coarser (1 ULP) but simpler.\n //\n // It is an error in the \"numerical approximation\" sense, not in the\n // typical programming sense (as in \"bad input\" or \"a result type\").\n uint64_t error = 0;\n\n // Convert up to 19 decimal digits (in h->digits) to 64 binary digits (in\n // m->mantissa): (1e19 < (1<<64)) and ((1<<64) < 1e20). If we have more\n // than 19 digits, we're truncating (with error).\n uint32_t i;\n uint32_t i_end = h->num_digits;\n if (i_end > 19) {\n i_end = 19;\n error = 1;\n }\n uint64_t mantissa = 0;\n for (i = 0; i < i_end; i++) {\n mantissa = (10 * mantissa) + h->digits[i];\n }\n m->mantissa = mantissa;\n m->exp2 = 0;\n\n // Check that exp10 lies in the (big_powers_of_10 + small_po" +
"wers_of_10)\n // range, -348 ..= +347, stepping big_powers_of_10 by 8 (which is 87\n // triples) and small_powers_of_10 by 1 (which is 8 triples).\n int32_t exp10 = h->decimal_point - ((int32_t)(i_end));\n if (exp10 < -348) {\n goto fail;\n }\n uint32_t bpo10 = ((uint32_t)(exp10 + 348)) / 8;\n uint32_t spo10 = ((uint32_t)(exp10 + 348)) % 8;\n if (bpo10 >= 87) {\n goto fail;\n }\n\n // Try a fast path, if float64 math would be exact.\n //\n // 15 is such that 1e15 can be losslessly represented in a float64\n // mantissa: (1e15 < (1<<53)) and ((1<<53) < 1e16).\n //\n // 22 is the maximum valid index for the\n // wuffs_base__private_implementation__f64_powers_of_10 array.\n do {\n if (skip_fast_path_for_tests || ((mantissa >> 52) != 0)) {\n break;\n }\n double d = (double)mantissa;\n\n if (exp10 == 0) {\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = h->negative ? -d : +d;\n return ret;\n\n } else if (e" +
"xp10 > 0) {\n if (exp10 > 22) {\n if (exp10 > (15 + 22)) {\n break;\n }\n // If exp10 is in the range 23 ..= 37, try moving a few of the zeroes\n // from the exponent to the mantissa. If we're still under 1e15, we\n // haven't truncated any mantissa bits.\n if (exp10 > 22) {\n d *= wuffs_base__private_implementation__f64_powers_of_10[exp10 -\n 22];\n exp10 = 22;\n if (d >= 1e15) {\n break;\n }\n }\n }\n d *= wuffs_base__private_implementation__f64_powers_of_10[exp10];\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = h->negative ? -d : +d;\n return ret;\n\n } else { // \"if (exp10 < 0)\" is effectively \"if (true)\" here.\n if (exp10 < -22) {\n break;\n }\n d /= wuffs_base__private_implementation__f64_powers_of_10[-exp10];\n wuffs_bas" +
"e__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = h->negative ? -d : +d;\n return ret;\n }\n } while (0);\n\n // Normalize (and scale the error).\n error <<= wuffs_base__private_implementation__medium_prec_bin__normalize(m);\n\n // Multiplying two MPB values nominally multiplies two mantissas, call them\n // A and B, which are integer approximations to the precise values (A+a)\n // and (B+b) for some error terms a and b.\n //\n // MPB multiplication calculates (((A+a) * (B+b)) >> 64) to be ((A*B) >>\n // 64). Shifting (truncating) and rounding introduces further error. The\n // difference between the calculated result:\n // ((A*B ) >> 64)\n // and the true result:\n // ((A*B + A*b + a*B + a*b) >> 64) + rounding_error\n // is:\n // (( A*b + a*B + a*b) >> 64) + rounding_error\n // which can be re-grouped as:\n // ((A*b) >> 64) + ((a*(B+b)) >> 64) + rounding_error\n //\n // Now, let A and a be \"m->mantissa\" and \"erro" +
"r\", and B and b be the\n // pre-calculated power of 10. A and B are both less than (1 << 64), a is\n // the \"error\" local variable and b is less than 1.\n //\n // An upper bound (in absolute value) on ((A*b) >> 64) is therefore 1.\n //\n // An upper bound on ((a*(B+b)) >> 64) is a, also known as error.\n //\n // Finally, the rounding_error is at most 1.\n //\n // In total, calling mpb__mul_pow_10 will raise the worst-case error by 2.\n // The subsequent re-normalization can multiply that by a further factor.\n\n // Multiply by small_powers_of_10[etc].\n wuffs_base__private_implementation__medium_prec_bin__mul_pow_10(\n m, &wuffs_base__private_implementation__small_powers_of_10[3 * spo10]);\n error += 2;\n error <<= wuffs_base__private_implementation__medium_prec_bin__normalize(m);\n\n // Multiply by big_powers_of_10[etc].\n wuffs_base__private_implementation__medium_prec_bin__mul_pow_10(\n m, &wuffs_base__private_implementation__big_powers_of_10[3 * bpo10]);\n err" +
"or += 2;\n error <<= wuffs_base__private_implementation__medium_prec_bin__normalize(m);\n\n // We have a good approximation of h, but we still have to check whether\n // the error is small enough. Equivalently, whether the number of surplus\n // mantissa bits (the bits dropped when going from m's 64 mantissa bits to\n // the smaller number of double-precision mantissa bits) would always round\n // up or down, even when perturbed by ±error. We start at 11 surplus bits\n // (m has 64, double-precision has 1+52), but it can be higher for\n // subnormals.\n //\n // In many cases, the error is small enough and we return true.\n const int32_t f64_bias = -1023;\n int32_t subnormal_exp2 = f64_bias - 63;\n uint32_t surplus_bits = 11;\n if (subnormal_exp2 >= m->exp2) {\n surplus_bits += 1 + ((uint32_t)(subnormal_exp2 - m->exp2));\n }\n\n uint64_t surplus_mask =\n (((uint64_t)1) << surplus_bits) - 1; // e.g. 0x07FF.\n uint64_t surplus = m->mantissa & surplus_mask;\n uint64_t" +
" halfway = ((uint64_t)1) << (surplus_bits - 1); // e.g. 0x0400.\n\n // Do the final calculation in *signed* arithmetic.\n int64_t i_surplus = (int64_t)surplus;\n int64_t i_halfway = (int64_t)halfway;\n int64_t i_error = (int64_t)error;\n\n if ((i_surplus > (i_halfway - i_error)) &&\n (i_surplus < (i_halfway + i_error))) {\n goto fail;\n }\n\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base__private_implementation__medium_prec_bin__as_f64(\n m, h->negative);\n return ret;\n } while (0);\n\nfail:\n do {\n wuffs_base__result_f64 ret;\n ret.status.repr = \"#base: mpb__parse_number_f64 failed\";\n ret.value = 0;\n return ret;\n } while (0);\n}\n\n" +
"" +
"// --------\n\nwuffs_base__result_f64 //\nwuffs_base__parse_number_f64_special(wuffs_base__slice_u8 s,\n const char* fallback_status_repr) {\n do {\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 fallback;\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 fallback;\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 fallback;\n }\n p += 3;\n\n if ((p >= q) || (*p == '_')) {\n break;\n } else if (((q - p) < 5) || " +
" //\n ((p[0] != 'I') && (p[0] != 'i')) || //\n ((p[1] != 'N') && (p[1] != 'n')) || //\n ((p[2] != 'I') && (p[2] != 'i')) || //\n ((p[3] != 'T') && (p[3] != 't')) || //\n ((p[4] != 'Y') && (p[4] != 'y'))) {\n goto fallback;\n }\n p += 5;\n\n if ((p >= q) || (*p == '_')) {\n break;\n }\n goto fallback;\n\n case 'N':\n case 'n':\n if (((q - p) < 3) || //\n ((p[1] != 'A') && (p[1] != 'a')) || //\n ((p[2] != 'N') && (p[2] != 'n'))) {\n goto fallback;\n }\n p += 3;\n\n if ((p >= q) || (*p == '_')) {\n nan = true;\n break;\n }\n goto fallback;\n\n default:\n goto fallback;\n }\n\n // Finish.\n for (; (p < q) && (*p == '_'); p++) {\n }\n if (p != q) {\n goto fallback;\n }\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = w" +
"uffs_base__ieee_754_bit_representation__to_f64(\n (nan ? 0x7FFFFFFFFFFFFFFF : 0x7FF0000000000000) |\n (negative ? 0x8000000000000000 : 0));\n return ret;\n } while (0);\n\nfallback:\n do {\n wuffs_base__result_f64 ret;\n ret.status.repr = fallback_status_repr;\n ret.value = 0;\n return ret;\n } while (0);\n}\n\nwuffs_base__result_f64 //\nwuffs_base__parse_number_f64(wuffs_base__slice_u8 s) {\n wuffs_base__private_implementation__medium_prec_bin m;\n wuffs_base__private_implementation__high_prec_dec h;\n\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 wuffs_base__status status =\n wuffs_base__private_implementat" +
"ion__high_prec_dec__parse(&h, s);\n if (status.repr) {\n return wuffs_base__parse_number_f64_special(s, status.repr);\n }\n\n // Handle 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 wuffs_base__result_f64 mpb_result =\n wuffs_base__private_implementation__medium_prec_bin__parse_number_f64(\n &m, &h, false);\n if (mpb_result.status.repr == NULL) {\n return mpb_result;\n }\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,\n 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,\n " +
" 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 subnormal numbers.\n if ((man2 >> 52) == 0) {\n exp2 = f64_bias;\n }\n\n // Pack the bits and return.\n uint64_t exp2_bits =\n (uint64_t)((exp2 - f64_bias) & 0x07FF); // (1 << 11) - 1.\n uint64_t bits = (man2 & 0x000FFFFFFFFFFFFF) | // (1 << 52) - 1.\n (exp2_bits << 52) | //\n (h.negative ? 0x8000000000000000 : 0); // (1 << 63).\n\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base__ieee_754_bit_representation__to_f64(bits);\n return ret;\n } while (0);\n\nzero:\n do {\n uint64_t bits = h.negative ? 0x8000000000000000 : 0;\n\n wuffs_base__result_f64 ret;\n ret.status.repr = NULL;\n ret.value = wuffs_base" +
"__ieee_754_bit_representation__to_f64(bits);\n return ret;\n } while (0);\n\ninfinity:\n do {\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__to_f64(bits);\n return ret;\n } while (0);\n}\n\n" +
"" +
"// ---------------- Hexadecimal\n\nsize_t //\nwuffs_base__hexadecimal__decode2(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t src_len2 = src.len / 2;\n size_t len = dst.len < src_len2 ? dst.len : src_len2;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n while (n--) {\n *d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[0]] << 4) |\n (wuffs_base__parse_number__hexadecimal_digits[s[1]] & 0x0F));\n d += 1;\n s += 2;\n }\n\n return len;\n}\n\nsize_t //\nwuffs_base__hexadecimal__decode4(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src) {\n size_t src_len4 = src.len / 4;\n size_t len = dst.len < src_len4 ? dst.len : src_len4;\n uint8_t* d = dst.ptr;\n uint8_t* s = src.ptr;\n size_t n = len;\n\n while (n--) {\n *d = (uint8_t)((wuffs_base__parse_number__hexadecimal_digits[s[2]] << 4) |\n (wuffs_base__parse_number__hexadecimal_digits[s[3]] & 0x0F));\n d += 1;\n s +" +
"= 4;\n }\n\n return len;\n}\n\n" +
"" +
"// ---------------- Unicode and UTF-8\n\nsize_t //\nwuffs_base__utf_8__encode(wuffs_base__slice_u8 dst, uint32_t code_point) {\n if (code_point <= 0x7F) {\n if (dst.len >= 1) {\n dst.ptr[0] = (uint8_t)(code_point);\n return 1;\n }\n\n } else if (code_point <= 0x07FF) {\n if (dst.len >= 2) {\n dst.ptr[0] = (uint8_t)(0xC0 | ((code_point >> 6)));\n dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));\n return 2;\n }\n\n } else if (code_point <= 0xFFFF) {\n if ((dst.len >= 3) && ((code_point < 0xD800) || (0xDFFF < code_point))) {\n dst.ptr[0] = (uint8_t)(0xE0 | ((code_point >> 12)));\n dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3F));\n dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));\n return 3;\n }\n\n } else if (code_point <= 0x10FFFF) {\n if (dst.len >= 4) {\n dst.ptr[0] = (uint8_t)(0xF0 | ((code_point >> 18)));\n dst.ptr[1] = (uint8_t)(0x80 | ((code_point >> 12) & 0x3F));\n dst.ptr[2] = (uint8_t)(0x80 | ((code_point >> 6) & 0x3" +
"F));\n dst.ptr[3] = (uint8_t)(0x80 | ((code_point >> 0) & 0x3F));\n return 4;\n }\n }\n\n return 0;\n}\n\n// wuffs_base__utf_8__byte_length_minus_1 is the byte length (minus 1) of a\n// UTF-8 encoded code point, based on the encoding's initial byte.\n// - 0x00 is 1-byte UTF-8 (ASCII).\n// - 0x01 is the start of 2-byte UTF-8.\n// - 0x02 is the start of 3-byte UTF-8.\n// - 0x03 is the start of 4-byte UTF-8.\n// - 0x40 is a UTF-8 tail byte.\n// - 0x80 is invalid UTF-8.\n//\n// RFC 3629 (UTF-8) gives this grammar for valid UTF-8:\n// UTF8-1 = %x00-7F\n// UTF8-2 = %xC2-DF UTF8-tail\n// UTF8-3 = %xE0 %xA0-BF UTF8-tail / %xE1-EC 2( UTF8-tail ) /\n// %xED %x80-9F UTF8-tail / %xEE-EF 2( UTF8-tail )\n// UTF8-4 = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /\n// %xF4 %x80-8F 2( UTF8-tail )\n// UTF8-tail = %x80-BF\nstatic const uint8_t wuffs_base__utf_8__byte_length_minus_1[256] = {\n // 0 1 2 3 4 5 6 7\n // 8 9" +
" A B C D E F\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x00 ..= 0x07.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x08 ..= 0x0F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x10 ..= 0x17.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x18 ..= 0x1F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20 ..= 0x27.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28 ..= 0x2F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x30 ..= 0x37.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x38 ..= 0x3F.\n\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x40 ..= 0x47.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x48 ..= 0x4F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x50 ..= 0x57.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x58 ..= 0x5F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x60 ..= 0x67.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x68 .." +
"= 0x6F.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x70 ..= 0x77.\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x78 ..= 0x7F.\n\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x80 ..= 0x87.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x88 ..= 0x8F.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x90 ..= 0x97.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0x98 ..= 0x9F.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA0 ..= 0xA7.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xA8 ..= 0xAF.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB0 ..= 0xB7.\n 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, // 0xB8 ..= 0xBF.\n\n 0x80, 0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC0 ..= 0xC7.\n 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xC8 ..= 0xCF.\n 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD0 ..= 0xD7.\n 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, // 0xD8 ..= 0xDF.\n 0x02, 0x02, 0x02" +
", 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE0 ..= 0xE7.\n 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, // 0xE8 ..= 0xEF.\n 0x03, 0x03, 0x03, 0x03, 0x03, 0x80, 0x80, 0x80, // 0xF0 ..= 0xF7.\n 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, // 0xF8 ..= 0xFF.\n // 0 1 2 3 4 5 6 7\n // 8 9 A B C D E F\n};\n\nwuffs_base__utf_8__next__output //\nwuffs_base__utf_8__next(wuffs_base__slice_u8 s) {\n if (s.len == 0) {\n return wuffs_base__make_utf_8__next__output(0, 0);\n }\n uint32_t c = s.ptr[0];\n switch (wuffs_base__utf_8__byte_length_minus_1[c & 0xFF]) {\n case 0:\n return wuffs_base__make_utf_8__next__output(c, 1);\n\n case 1:\n if (s.len < 2) {\n break;\n }\n c = wuffs_base__load_u16le__no_bounds_check(s.ptr);\n if ((c & 0xC000) != 0x8000) {\n break;\n }\n c = (0x0007C0 & (c << 6)) | (0x00003F & (c >> 8));\n return wuffs_base__make_utf_8__next__output(c, 2);\n\n case 2:\n if (s.len < 3) {\n " +
" break;\n }\n c = wuffs_base__load_u24le__no_bounds_check(s.ptr);\n if ((c & 0xC0C000) != 0x808000) {\n break;\n }\n c = (0x00F000 & (c << 12)) | (0x000FC0 & (c >> 2)) |\n (0x00003F & (c >> 16));\n if ((c <= 0x07FF) || ((0xD800 <= c) && (c <= 0xDFFF))) {\n break;\n }\n return wuffs_base__make_utf_8__next__output(c, 3);\n\n case 3:\n if (s.len < 4) {\n break;\n }\n c = wuffs_base__load_u32le__no_bounds_check(s.ptr);\n if ((c & 0xC0C0C000) != 0x80808000) {\n break;\n }\n c = (0x1C0000 & (c << 18)) | (0x03F000 & (c << 4)) |\n (0x000FC0 & (c >> 10)) | (0x00003F & (c >> 24));\n if ((c <= 0xFFFF) || (0x110000 <= c)) {\n break;\n }\n return wuffs_base__make_utf_8__next__output(c, 4);\n }\n\n return wuffs_base__make_utf_8__next__output(\n WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER, 1);\n}\n\nsize_t //\nwuffs_base__utf_8__longest_valid_prefix(wuffs_base__slice_u8 s) {\n // TODO: possibly optimize the all-A" +
"SCII case (4 or 8 bytes at a time).\n //\n // TODO: possibly optimize this by manually inlining the\n // wuffs_base__utf_8__next calls.\n size_t original_len = s.len;\n while (s.len > 0) {\n wuffs_base__utf_8__next__output o = wuffs_base__utf_8__next(s);\n if ((o.code_point > 0x7F) && (o.byte_length == 1)) {\n break;\n }\n s.ptr += o.byte_length;\n s.len -= o.byte_length;\n }\n return original_len - s.len;\n}\n\nsize_t //\nwuffs_base__ascii__longest_valid_prefix(wuffs_base__slice_u8 s) {\n // TODO: possibly optimize this by checking 4 or 8 bytes at a time.\n uint8_t* original_ptr = s.ptr;\n uint8_t* p = s.ptr;\n uint8_t* q = s.ptr + s.len;\n for (; (p != q) && ((*p & 0x80) == 0); p++) {\n }\n return (size_t)(p - original_ptr);\n}\n" +
""
const baseCorePrivateH = "" +
"static inline wuffs_base__empty_struct //\nwuffs_base__ignore_status(wuffs_base__status z) {\n return wuffs_base__make_empty_struct();\n}\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// Denote intentional fallthroughs for -Wimplicit-fallthrough.\n//\n// The order matters here. Clang also defines \"__GNUC__\".\n#if defined(__clang__) && defined(__cplusplus) && (__cplusplus >= 201103L)\n#define WUFFS_BASE__FALLTHROUGH [[clang::fallthrough]]\n#elif !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 7)\n#define WUFFS_BAS" +
"E__FALLTHROUGH __attribute__((fallthrough))\n#else\n#define WUFFS_BASE__FALLTHROUGH\n#endif\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// 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_POINT(n) \\\n coro_susp_point = n; \\\n WUFFS_BASE__FALLTHROUGH; \\\n case n:;\n\n#define WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(n) \\\n if (!status.repr) { \\\n goto ok; \\\n } else if (*status.repr != '$') { \\\n goto exit; \\\n } \\\n coro_susp_point" +
" = n; \\\n goto suspend; \\\n case n:;\n\n// Clang also defines \"__GNUC__\".\n#if defined(__GNUC__)\n#define WUFFS_BASE__LIKELY(expr) (__builtin_expect(!!(expr), 1))\n#define WUFFS_BASE__UNLIKELY(expr) (__builtin_expect(!!(expr), 0))\n#else\n#define WUFFS_BASE__LIKELY(expr) (expr)\n#define WUFFS_BASE__UNLIKELY(expr) (expr)\n#endif\n\n" +
"" +
"// ---------------- Numeric Types\n\nextern const uint8_t wuffs_base__low_bits_mask__u8[9];\nextern const uint16_t wuffs_base__low_bits_mask__u16[17];\nextern const uint32_t wuffs_base__low_bits_mask__u32[33];\nextern const uint64_t wuffs_base__low_bits_mask__u64[65];\n\n#define WUFFS_BASE__LOW_BITS_MASK__U8(n) (wuffs_base__low_bits_mask__u8[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U16(n) (wuffs_base__low_bits_mask__u16[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U32(n) (wuffs_base__low_bits_mask__u32[n])\n#define WUFFS_BASE__LOW_BITS_MASK__U64(n) (wuffs_base__low_bits_mask__u64[n])\n\n" +
"" +
"// --------\n\nstatic inline void //\nwuffs_base__u8__sat_add_indirect(uint8_t* x, uint8_t y) {\n *x = wuffs_base__u8__sat_add(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u8__sat_sub_indirect(uint8_t* x, uint8_t y) {\n *x = wuffs_base__u8__sat_sub(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u16__sat_add_indirect(uint16_t* x, uint16_t y) {\n *x = wuffs_base__u16__sat_add(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u16__sat_sub_indirect(uint16_t* x, uint16_t y) {\n *x = wuffs_base__u16__sat_sub(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u32__sat_add_indirect(uint32_t* x, uint32_t y) {\n *x = wuffs_base__u32__sat_add(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u32__sat_sub_indirect(uint32_t* x, uint32_t y) {\n *x = wuffs_base__u32__sat_sub(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u64__sat_add_indirect(uint64_t* x, uint64_t y) {\n *x = wuffs_base__u64__sat_add(*x, y);\n}\n\nstatic inline void //\nwuffs_base__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {\n *x = wuffs_base__u64__sat_sub(*x, y);\n}\n\n" +
"" +
"// ---------------- 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 = 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 = 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 src) {\n size_t len = dst.l" +
"en < src.len ? dst.len : src.len;\n if (len > 0) {\n memmove(dst.ptr, src.ptr, len);\n }\n return len;\n}\n\n" +
"" +
"// --------\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__table_u8__row(wuffs_base__table_u8 t, uint32_t y) {\n if (y < t.height) {\n return wuffs_base__make_slice_u8(t.ptr + (t.stride * y), t.width);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\n " +
"" +
"// ---------------- Slices and Tables (Utility)\n\n#define wuffs_base__utility__empty_slice_u8 wuffs_base__empty_slice_u8\n" +
""
const baseCorePublicH = "" +
"// ---------------- Fundamentals\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 ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint" +
"64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_PRE_RELEASE_LABEL \"work.in.progress\"\n#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 0\n#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 0\n#define WUFFS_VERSION_STRING \"0.0.0+0.00000000\"\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#ifdef WUFFS_CONFIG__STATIC_FUNCTIONS\n#define WUFFS_BASE__MAYBE_STATIC static\n#else\n#define WUFFS_BASE__MAYBE_STATIC\n#endif\n\n" +
"" +
"// --------\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#ifdef __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#if defined(__clang__)\n#define WUFFS_BASE__POTENTIALLY_UNUSED_FIELD __attribute__((unused))\n#else\n#define WUFFS_BASE__POTENTIALLY_UNUSED_FIELD\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// Flags 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)0x" +
"00000001)\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/master/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 {\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 {\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 {\n const char* vtable_name;\n const void* function_pointers;\n} wuffs_base__vtable;\n\n" +
"" +
"// --------\n\n// See https://github.com/google/wuffs/blob/master/doc/note/statuses.md\ntypedef struct {\n const char* repr;\n\n#ifdef __cplusplus\n inline bool is_complete() const;\n inline bool is_error() const;\n inline bool is_note() const;\n inline bool is_ok() const;\n inline bool is_suspension() const;\n inline const char* message() const;\n#endif // __cplusplus\n\n} wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline wuffs_base__status //\nwuffs_base__make_status(const char* repr) {\n wuffs_base__status z;\n z.repr = repr;\n return z;\n}\n\nstatic inline bool //\nwuffs_base__status__is_complete(const wuffs_base__status* z) {\n return (z->repr == NULL) || ((*z->repr != '$') && (*z->repr != '#'));\n}\n\nstatic inline bool //\nwuffs_base__status__is_error(const wuffs_base__status* z) {\n return z->repr && (*z->repr == '#');\n}\n\nstatic inline bool //\nwuffs_base__status__is_note(const wuffs_base__status* z) {\n return z->repr && (*z->repr != '$') && (*z->repr != '#');\n}\n\nstatic inline bool //\nwu" +
"ffs_base__status__is_ok(const wuffs_base__status* z) {\n return z->repr == NULL;\n}\n\nstatic inline bool //\nwuffs_base__status__is_suspension(const wuffs_base__status* z) {\n return z->repr && (*z->repr == '$');\n}\n\n// wuffs_base__status__message strips the leading '$', '#' or '@'.\nstatic inline const char* //\nwuffs_base__status__message(const wuffs_base__status* z) {\n if (z->repr) {\n if ((*z->repr == '$') || (*z->repr == '#') || (*z->repr == '@')) {\n return z->repr + 1;\n }\n }\n return z->repr;\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__status::is_complete() const {\n return wuffs_base__status__is_complete(this);\n}\n\ninline bool //\nwuffs_base__status::is_error() const {\n return wuffs_base__status__is_error(this);\n}\n\ninline bool //\nwuffs_base__status::is_note() const {\n return wuffs_base__status__is_note(this);\n}\n\ninline bool //\nwuffs_base__status::is_ok() const {\n return wuffs_base__status__is_ok(this);\n}\n\ninline bool //\nwuffs_base__status::is_suspension() const {\n return wuffs_base" +
"__status__is_suspension(this);\n}\n\ninline const char* //\nwuffs_base__status::message() const {\n return wuffs_base__status__message(this);\n}\n\n#endif // __cplusplus\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// FourCC constants.\n\n// !! INSERT FourCCs.\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 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__max(uint64_t x, uint64_t y) {\n return x > y ? x : y;\n}\n\n" +
"" +
"// --------\n\n// Saturating arithmetic (sat_add, sat_sub) branchless bit-twiddling algorithms\n// are per https://locklessinc.com/articles/sat_arithmetic/\n//\n// It is important that the underlying types are unsigned integers, as signed\n// integer arithmetic overflow is undefined behavior in C.\n\nstatic inline uint8_t //\nwuffs_base__u8__sat_add(uint8_t x, uint8_t y) {\n uint8_t res = (uint8_t)(x + y);\n res |= (uint8_t)(-(res < x));\n return res;\n}\n\nstatic inline uint8_t //\nwuffs_base__u8__sat_sub(uint8_t x, uint8_t y) {\n uint8_t res = (uint8_t)(x - y);\n res &= (uint8_t)(-(res <= x));\n return res;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__sat_add(uint16_t x, uint16_t y) {\n uint16_t res = (uint16_t)(x + y);\n res |= (uint16_t)(-(res < x));\n return res;\n}\n\nstatic inline uint16_t //\nwuffs_base__u16__sat_sub(uint16_t x, uint16_t y) {\n uint16_t res = (uint16_t)(x - y);\n res &= (uint16_t)(-(res <= x));\n return res;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__sat_add(uint32_t x, uint32_t y) {\n uint32" +
"_t res = (uint32_t)(x + y);\n res |= (uint32_t)(-(res < x));\n return res;\n}\n\nstatic inline uint32_t //\nwuffs_base__u32__sat_sub(uint32_t x, uint32_t y) {\n uint32_t res = (uint32_t)(x - y);\n res &= (uint32_t)(-(res <= x));\n return res;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__sat_add(uint64_t x, uint64_t y) {\n uint64_t res = (uint64_t)(x + y);\n res |= (uint64_t)(-(res < x));\n return res;\n}\n\nstatic inline uint64_t //\nwuffs_base__u64__sat_sub(uint64_t x, uint64_t y) {\n uint64_t res = (uint64_t)(x - y);\n res &= (uint64_t)(-(res <= x));\n return res;\n}\n\n" +
"" +
"// --------\n\ntypedef struct {\n uint64_t hi;\n uint64_t lo;\n} wuffs_base__multiply_u64__output;\n\n// wuffs_base__multiply_u64 returns x*y as a 128-bit value.\n//\n// The maximum inclusive output hi_lo is 0xFFFFFFFFFFFFFFFE_0000000000000001.\nstatic inline wuffs_base__multiply_u64__output //\nwuffs_base__multiply_u64(uint64_t x, uint64_t y) {\n uint64_t x0 = x & 0xFFFFFFFF;\n uint64_t x1 = x >> 32;\n uint64_t y0 = y & 0xFFFFFFFF;\n uint64_t y1 = y >> 32;\n uint64_t w0 = x0 * y0;\n uint64_t t = (x1 * y0) + (w0 >> 32);\n uint64_t w1 = t & 0xFFFFFFFF;\n uint64_t w2 = t >> 32;\n w1 += x0 * y1;\n wuffs_base__multiply_u64__output o;\n o.hi = (x1 * y1) + w2 + (w1 >> 32);\n o.lo = x * y;\n return o;\n}\n\n " +
"" +
"// --------\n\n#if defined(__GNUC__) && (__SIZEOF_LONG__ == 8)\n\nstatic inline uint32_t //\nwuffs_base__count_leading_zeroes_u64(uint64_t u) {\n return u ? ((uint32_t)(__builtin_clzl(u))) : 64u;\n}\n\n#else\n\nstatic inline uint32_t //\nwuffs_base__count_leading_zeroes_u64(uint64_t u) {\n if (u == 0) {\n return 64;\n }\n\n uint32_t n = 0;\n if ((u >> 32) == 0) {\n n |= 32;\n u <<= 32;\n }\n if ((u >> 48) == 0) {\n n |= 16;\n u <<= 16;\n }\n if ((u >> 56) == 0) {\n n |= 8;\n u <<= 8;\n }\n if ((u >> 60) == 0) {\n n |= 4;\n u <<= 4;\n }\n if ((u >> 62) == 0) {\n n |= 2;\n u <<= 2;\n }\n if ((u >> 63) == 0) {\n n |= 1;\n u <<= 1;\n }\n return n;\n}\n\n#endif // defined(__GNUC__) && (__SIZEOF_LONG__ == 8)\n\n " +
"" +
"// --------\n\n#define wuffs_base__load_u8be__no_bounds_check \\\n wuffs_base__load_u8__no_bounds_check\n#define wuffs_base__load_u8le__no_bounds_check \\\n wuffs_base__load_u8__no_bounds_check\n\nstatic inline uint8_t //\nwuffs_base__load_u8__no_bounds_check(uint8_t* p) {\n return p[0];\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16be__no_bounds_check(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));\n}\n\nstatic inline uint16_t //\nwuffs_base__load_u16le__no_bounds_check(uint8_t* p) {\n return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24be__no_bounds_check(uint8_t* p) {\n return ((uint32_t)(p[0]) << 16) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u24le__no_bounds_check(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32be__no_bounds_check(" +
"uint8_t* p) {\n return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |\n ((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__load_u32le__no_bounds_check(uint8_t* p) {\n return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |\n ((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40be__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 32) | ((uint64_t)(p[1]) << 24) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 8) |\n ((uint64_t)(p[4]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u40le__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48be__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 40) | ((uint64_t)(p[1]) << 32) |\n ((uint64_t)(p[2]) << 24) | ((uint64_t)" +
"(p[3]) << 16) |\n ((uint64_t)(p[4]) << 8) | ((uint64_t)(p[5]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u48le__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u56be__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 48) | ((uint64_t)(p[1]) << 40) |\n ((uint64_t)(p[2]) << 32) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 16) | ((uint64_t)(p[5]) << 8) |\n ((uint64_t)(p[6]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u56le__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64be__no_bounds_ch" +
"eck(uint8_t* p) {\n return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |\n ((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |\n ((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |\n ((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);\n}\n\nstatic inline uint64_t //\nwuffs_base__load_u64le__no_bounds_check(uint8_t* p) {\n return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |\n ((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |\n ((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |\n ((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);\n}\n\n " +
"" +
"// --------\n\n#define wuffs_base__store_u8be__no_bounds_check \\\n wuffs_base__store_u8__no_bounds_check\n#define wuffs_base__store_u8le__no_bounds_check \\\n wuffs_base__store_u8__no_bounds_check\n\nstatic inline void //\nwuffs_base__store_u8__no_bounds_check(uint8_t* p, uint8_t x) {\n p[0] = x;\n}\n\nstatic inline void //\nwuffs_base__store_u16be__no_bounds_check(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 8);\n p[1] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u16le__no_bounds_check(uint8_t* p, uint16_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n}\n\nstatic inline void //\nwuffs_base__store_u24be__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 16);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u24le__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n}\n\nstatic inline void //\nwuffs_base__store_u32be__no_bounds_check(uint8_t* p," +
" uint32_t x) {\n p[0] = (uint8_t)(x >> 24);\n p[1] = (uint8_t)(x >> 16);\n p[2] = (uint8_t)(x >> 8);\n p[3] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u32le__no_bounds_check(uint8_t* p, uint32_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n}\n\nstatic inline void //\nwuffs_base__store_u40be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 32);\n p[1] = (uint8_t)(x >> 24);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 8);\n p[4] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u40le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n}\n\nstatic inline void //\nwuffs_base__store_u48be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 40);\n p[1] = (uint8_t)(x >> 32);\n p[2] = (uint8_t)(x >> 24);\n p[3] = (uint8_t)(x >> 16);\n p[4] " +
"= (uint8_t)(x >> 8);\n p[5] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u48le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n}\n\nstatic inline void //\nwuffs_base__store_u56be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 48);\n p[1] = (uint8_t)(x >> 40);\n p[2] = (uint8_t)(x >> 32);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 16);\n p[5] = (uint8_t)(x >> 8);\n p[6] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u56le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n}\n\nstatic inline void //\nwuffs_base__store_u64be__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 56);\n" +
" p[1] = (uint8_t)(x >> 48);\n p[2] = (uint8_t)(x >> 40);\n p[3] = (uint8_t)(x >> 32);\n p[4] = (uint8_t)(x >> 24);\n p[5] = (uint8_t)(x >> 16);\n p[6] = (uint8_t)(x >> 8);\n p[7] = (uint8_t)(x >> 0);\n}\n\nstatic inline void //\nwuffs_base__store_u64le__no_bounds_check(uint8_t* p, uint64_t x) {\n p[0] = (uint8_t)(x >> 0);\n p[1] = (uint8_t)(x >> 8);\n p[2] = (uint8_t)(x >> 16);\n p[3] = (uint8_t)(x >> 24);\n p[4] = (uint8_t)(x >> 32);\n p[5] = (uint8_t)(x >> 40);\n p[6] = (uint8_t)(x >> 48);\n p[7] = (uint8_t)(x >> 56);\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" +
"int8_t) wuffs_base__table_u8;\ntypedef WUFFS_BASE__TABLE(uint16_t) wuffs_base__table_u16;\ntypedef WUFFS_BASE__TABLE(uint32_t) wuffs_base__table_u32;\ntypedef WUFFS_BASE__TABLE(uint64_t) wuffs_base__table_u64;\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__make_slice_u8(uint8_t* ptr, size_t len) {\n wuffs_base__slice_u8 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u16 //\nwuffs_base__make_slice_u16(uint16_t* ptr, size_t len) {\n wuffs_base__slice_u16 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u32 //\nwuffs_base__make_slice_u32(uint32_t* ptr, size_t len) {\n wuffs_base__slice_u32 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u64 //\nwuffs_base__make_slice_u64(uint64_t* ptr, size_t len) {\n wuffs_base__slice_u64 ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__empty_slice_u8() {\n wuffs_base__slice_u8 ret;\n ret.ptr = NULL;\n" +
" ret.len = 0;\n return ret;\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__empty_table_u8() {\n wuffs_base__table_u8 ret;\n ret.ptr = NULL;\n ret.width = 0;\n ret.height = 0;\n ret.stride = 0;\n return ret;\n}\n\n// wuffs_base__slice_u8__subslice_i returns s[i:].\n//\n// It returns an empty slice if i is out of bounds.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__slice_u8__subslice_i(wuffs_base__slice_u8 s, uint64_t i) {\n if ((i <= SIZE_MAX) && (i <= s.len)) {\n return wuffs_base__make_slice_u8(s.ptr + i, 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, 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 s" +
"lice 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, j - i);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n" +
""
const baseMemoryPrivateH = "" +
"// ---------------- Memory Allocation\n" +
""
const baseMemoryPublicH = "" +
"// ---------------- 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)(num_u8 * sizeof(uint8_t));\n if (p) {\n return wuffs_base__make_slice_u8((uint8_t*)(p), num_u8);\n }\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u16 //\nwuffs" +
"_base__malloc_slice_u16(void* (*malloc_func)(size_t), uint64_t num_u16) {\n if (malloc_func && (num_u16 <= (SIZE_MAX / sizeof(uint16_t)))) {\n void* p = (*malloc_func)(num_u16 * sizeof(uint16_t));\n if (p) {\n return wuffs_base__make_slice_u16((uint16_t*)(p), num_u16);\n }\n }\n return wuffs_base__make_slice_u16(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u32 //\nwuffs_base__malloc_slice_u32(void* (*malloc_func)(size_t), uint64_t num_u32) {\n if (malloc_func && (num_u32 <= (SIZE_MAX / sizeof(uint32_t)))) {\n void* p = (*malloc_func)(num_u32 * sizeof(uint32_t));\n if (p) {\n return wuffs_base__make_slice_u32((uint32_t*)(p), num_u32);\n }\n }\n return wuffs_base__make_slice_u32(NULL, 0);\n}\n\nstatic inline wuffs_base__slice_u64 //\nwuffs_base__malloc_slice_u64(void* (*malloc_func)(size_t), uint64_t num_u64) {\n if (malloc_func && (num_u64 <= (SIZE_MAX / sizeof(uint64_t)))) {\n void* p = (*malloc_func)(num_u64 * sizeof(uint64_t));\n if (p) {\n return wuffs_base__make_slice_u64((uint64_" +
"t*)(p), num_u64);\n }\n }\n return wuffs_base__make_slice_u64(NULL, 0);\n}\n" +
""
const baseImagePrivateH = "" +
"// ---------------- Images\n\n" +
"" +
"// ---------------- Images (Utility)\n\n#define wuffs_base__utility__make_pixel_format wuffs_base__make_pixel_format\n" +
""
const baseImagePublicH = "" +
"// ---------------- 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\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 c) {\n uint32_t b5 = 0x1F & (c >> 0);\n uint32_t b = (b5 << 3) | (b5 >> 2);\n uint32_t g6 = 0x3F & (c >> 5);\n uint32_t g = (g6 << 2) | (g6 >> 4);\n uint32_t r5 = 0x1F & (c >> 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_a" +
"rgb_premul__as_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\n// wuffs_base__premul_u32_axxx converts from non-premultiplied alpha to\n// premultiplied alpha. The \"axxx\" means either \"argb\" or \"abgr\".\nstatic inline uint32_t //\nwuffs_base__premul_u32_axxx(uint32_t 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 // W" +
"orking 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 & (nonpremul >> 24);\n uint32_t a16 = a * (0x101 * 0x101);\n\n uint32_t r = 0xFF & (nonpremul >> 16);\n r = ((r * a16) / 0xFFFF) >> 8;\n uint32_t g = 0xFF & (nonpremul >> 8);\n g = ((g * a16) / 0xFFFF) >> 8;\n uint32_t b = 0xFF & (nonpremul >> 0);\n b = ((b * a16) / 0xFFFF) >> 8;\n\n return (a << 24) | (r << 16) | (g << 8) | (b << 0);\n}\n\n// wuffs_base__nonpremul_u32_axxx converts from premultiplied alpha to\n// non-premultiplied alpha. The \"axxx\" means either \"argb\" or \"abgr\".\nstatic inline uint32_t //\nwuffs_base__nonpremul_u32_axxx(uint32_t premul) {\n uint32_t a = 0xFF & (premul >> 24);\n if (a == 0xFF) {\n return premul;\n } else if (a == 0) {\n return 0;\n }\n uint32_t a16 = a * 0x" +
"101;\n\n uint32_t r = 0xFF & (premul >> 16);\n r = ((r * (0x101 * 0xFFFF)) / a16) >> 8;\n uint32_t g = 0xFF & (premul >> 8);\n g = ((g * (0x101 * 0xFFFF)) / a16) >> 8;\n uint32_t b = 0xFF & (premul >> 0);\n b = ((b * (0x101 * 0xFFFF)) / a16) >> 8;\n\n return (a << 24) | (r << 16) | (g << 8) | (b << 0);\n}\n\n" +
"" +
"// --------\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__NON_PREMULTIPLIED_ALPHA 1\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__PREMULTIPLIED_ALPHA 2\n#define WUFFS_BASE__PIXEL_ALPHA_TRANSPARENCY__BINARY_ALPHA 3\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// 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/master/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 {\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_transparency transparency() const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_format;\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__make_pixel_format(uint3" +
"2_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\n // valid 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__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_BASE__PIXEL_FORMAT__YCOCGK 0x70038888\n\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_NONPREMUL 0x81040008\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_PREMUL 0x82040008\n#define WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY 0x83040008\n\n#define WUFFS_BASE__" +
"PIXEL_FORMAT__BGR_565 0x80000565\n#define WUFFS_BASE__PIXEL_FORMAT__BGR 0x80000888\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL 0x81008888\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL 0x82008888\n#define WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY 0x83008888\n#define WUFFS_BASE__PIXEL_FORMAT__BGRX 0x90008888\n\n#define WUFFS_BASE__PIXEL_FORMAT__RGB 0xA0000888\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL 0xA1008888\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL 0xA2008888\n#define WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY 0xA3008888\n#define WUFFS_BASE__PIXEL_FORMAT__RGBX 0xB0008888\n\n#define WUFFS_BASE__PIXEL_FORMAT__CMY 0xC0020888\n#define WUFFS_BASE__PIXEL_FORMAT__CMYK 0xD0038888\n\nextern const uint32_t wuffs_base__pixel_format__bits_per_channel[16];\n\nstatic inline bool //\nwuffs_base__pixel_format__is_valid(const wuffs_base__pixel_format* f) {\n return f->repr != 0;\n}\n\n// wuffs_base__pixel_format__bits_per_pixel returns the number of bits per\n// pixel for interleaved pixel formats, and returns 0 for planar pixel forma" +
"ts.\nstatic inline uint32_t //\nwuffs_base__pixel_format__bits_per_pixel(const wuffs_base__pixel_format* f) {\n if (((f->repr >> 16) & 0x03) != 0) {\n return 0;\n }\n return wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 0)] +\n wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 4)] +\n wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 8)] +\n wuffs_base__pixel_format__bits_per_channel[0x0F & (f->repr >> 12)];\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_direct(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 18) & 0x01) == 0;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_indexed(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 18) & 0x01) != 0;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_interleaved(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & 0x03) == 0;\n}\n\nstatic inline bool //\nwuffs_base__pixel_format__is_planar(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & " +
"0x03) != 0;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_format__num_planes(const wuffs_base__pixel_format* f) {\n return ((f->repr >> 16) & 0x03) + 1;\n}\n\nstatic inline wuffs_base__pixel_alpha_transparency //\nwuffs_base__pixel_format__transparency(const wuffs_base__pixel_format* f) {\n return (wuffs_base__pixel_alpha_transparency)((f->repr >> 24) & 0x03);\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__pixel_format::is_valid() const {\n return wuffs_base__pixel_format__is_valid(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_format::bits_per_pixel() const {\n return wuffs_base__pixel_format__bits_per_pixel(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_direct() const {\n return wuffs_base__pixel_format__is_direct(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_indexed() const {\n return wuffs_base__pixel_format__is_indexed(this);\n}\n\ninline bool //\nwuffs_base__pixel_format::is_interleaved() const {\n return wuffs_base__pixel_format__is_interleaved(this);\n}\n\ninline bool //\nwuffs_base__pi" +
"xel_format::is_planar() const {\n return wuffs_base__pixel_format__is_planar(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_format::num_planes() const {\n return wuffs_base__pixel_format__num_planes(this);\n}\n\ninline wuffs_base__pixel_alpha_transparency //\nwuffs_base__pixel_format::transparency() const {\n return wuffs_base__pixel_format__transparency(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\n// wuffs_base__pixel_subsampling encodes whether sample values cover one pixel\n// or cover multiple pixels.\n//\n// See https://github.com/google/wuffs/blob/master/doc/note/pixel-subsampling.md\n//\n// Do not manipulate its bits directly; they are private implementation\n// details. Use methods such as wuffs_base__pixel_subsampling__bias_x instead.\ntypedef struct {\n uint32_t repr;\n\n#ifdef __cplusplus\n inline uint32_t bias_x(uint32_t plane) const;\n inline uint32_t denominator_x(uint32_t plane) const;\n inline uint32_t bias_y(uint32_t plane) const;\n inline uint32_t denominator_y(uint32_t plane) const;\n#endif // __cplusplus\n\n} wuffs_base__pixel_subsampling;\n\nstatic inline wuffs_base__pixel_subsampling //\nwuffs_base__make_pixel_subsampling(uint32_t repr) {\n wuffs_base__pixel_subsampling s;\n s.repr = repr;\n return s;\n}\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__NONE 0x00000000\n\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__444 0x000000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__440 0x010100\n#define WUFFS_BASE__" +
"PIXEL_SUBSAMPLING__422 0x101000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__420 0x111100\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__411 0x303000\n#define WUFFS_BASE__PIXEL_SUBSAMPLING__410 0x313100\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_x(const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 6;\n return (s->repr >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__denominator_x(\n const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 4;\n return ((s->repr >> shift) & 0x03) + 1;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__bias_y(const wuffs_base__pixel_subsampling* s,\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 2;\n return (s->repr >> shift) & 0x03;\n}\n\nstatic inline uint32_t //\nwuffs_base__pixel_subsampling__denominator_y(\n const wuffs_base__pixel_subsampling* s," +
"\n uint32_t plane) {\n uint32_t shift = ((plane & 0x03) * 8) + 0;\n return ((s->repr >> shift) & 0x03) + 1;\n}\n\n#ifdef __cplusplus\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::bias_x(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__bias_x(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::denominator_x(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__denominator_x(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::bias_y(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__bias_y(this, plane);\n}\n\ninline uint32_t //\nwuffs_base__pixel_subsampling::denominator_y(uint32_t plane) const {\n return wuffs_base__pixel_subsampling__denominator_y(this, plane);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef 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_impl.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__inv" +
"alidate(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 ret.max_excl_y = c->private_impl.h" +
"eight;\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 > (UINT64_MAX - 1024)) {\n return 0;\n }\n n += 1024;\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_repr, width, height);\n}\n\ninline void //\nwuffs_base__pixel_config::invalidate() {\n wuffs_base__pixel_config__invalidate(this);\n}\n\ninline boo" +
"l //\nwuffs_base__pixel_config::is_valid() const {\n return wuffs_base__pixel_config__is_valid(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_config::pixel_format() const {\n return wuffs_base__pixel_config__pixel_format(this);\n}\n\ninline wuffs_base__pixel_subsampling //\nwuffs_base__pixel_config::pixel_subsampling() const {\n return wuffs_base__pixel_config__pixel_subsampling(this);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__pixel_config::bounds() const {\n return wuffs_base__pixel_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::width() const {\n return wuffs_base__pixel_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__pixel_config::height() const {\n return wuffs_base__pixel_config__height(this);\n}\n\ninline uint64_t //\nwuffs_base__pixel_config::pixbuf_len() const {\n return wuffs_base__pixel_config__pixbuf_len(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\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 uint64_t first_frame_io_position;\n bool first_frame_is_opaque;\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 uint64_t first_frame_io_position,\n bool first_frame_is_opaque);\n inline void invalidate();\n inline bool is_valid() const;\n inline uint64_t first_frame_io_position() const;\n inline bool first_frame_is_opaque() const;\n#endif // __cplusplus\n\n} wuffs_base__image_config;\n\nstatic inline wuffs_base__image_config //\nwuffs_base__null_image_config() {\n wuffs_base__image_config ret;\n ret.pixcfg = wuffs_base__null_pixel_config();\n ret.private_impl.first_frame_io_position = 0;\n ret.private_impl.first_frame_is_opaque = false;" +
"\n return ret;\n}\n\n// TODO: Should this function return bool? An error type?\nstatic inline void //\nwuffs_base__image_config__set(wuffs_base__image_config* c,\n uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n if (!c) {\n return;\n }\n if (pixfmt_repr) {\n c->pixcfg.private_impl.pixfmt.repr = pixfmt_repr;\n c->pixcfg.private_impl.pixsub.repr = pixsub_repr;\n c->pixcfg.private_impl.width = width;\n c->pixcfg.private_impl.height = height;\n c->private_impl.first_frame_io_position = first_frame_io_position;\n c->private_impl.first_frame_is_opaque = first_frame_is_opaque;\n return;\n }\n\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub.repr = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.he" +
"ight = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n}\n\nstatic inline void //\nwuffs_base__image_config__invalidate(wuffs_base__image_config* c) {\n if (c) {\n c->pixcfg.private_impl.pixfmt.repr = 0;\n c->pixcfg.private_impl.pixsub.repr = 0;\n c->pixcfg.private_impl.width = 0;\n c->pixcfg.private_impl.height = 0;\n c->private_impl.first_frame_io_position = 0;\n c->private_impl.first_frame_is_opaque = 0;\n }\n}\n\nstatic inline bool //\nwuffs_base__image_config__is_valid(const wuffs_base__image_config* c) {\n return c && wuffs_base__pixel_config__is_valid(&(c->pixcfg));\n}\n\nstatic inline uint64_t //\nwuffs_base__image_config__first_frame_io_position(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_io_position : 0;\n}\n\nstatic inline bool //\nwuffs_base__image_config__first_frame_is_opaque(\n const wuffs_base__image_config* c) {\n return c ? c->private_impl.first_frame_is_opaque : false;\n}\n\n#ifdef __cplusplus\n\ninline void" +
" //\nwuffs_base__image_config::set(uint32_t pixfmt_repr,\n uint32_t pixsub_repr,\n uint32_t width,\n uint32_t height,\n uint64_t first_frame_io_position,\n bool first_frame_is_opaque) {\n wuffs_base__image_config__set(this, pixfmt_repr, pixsub_repr, width, height,\n first_frame_io_position, first_frame_is_opaque);\n}\n\ninline void //\nwuffs_base__image_config::invalidate() {\n wuffs_base__image_config__invalidate(this);\n}\n\ninline bool //\nwuffs_base__image_config::is_valid() const {\n return wuffs_base__image_config__is_valid(this);\n}\n\ninline uint64_t //\nwuffs_base__image_config::first_frame_io_position() const {\n return wuffs_base__image_config__first_frame_io_position(this);\n}\n\ninline bool //\nwuffs_base__image_config::first_frame_is_opaque() const {\n return wuffs_base__image_config__first_frame_is_opaque(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\n// Deprecated: use wuffs_base__pixel_blend instead.\n//\n// wuffs_base__animation_blend encodes, for an animated image, how to blend the\n// transparent pixels of this frame with the existing canvas. In Porter-Duff\n// compositing operator terminology:\n// - 0 means the frame may be transparent, and should be blended \"src over\n// dst\", also known as just \"over\".\n// - 1 means the frame may be transparent, and should be blended \"src\".\n// - 2 means the frame is completely opaque, so that \"src over dst\" and \"src\"\n// are equivalent.\n//\n// These semantics are conservative. It is valid for a completely opaque frame\n// to have a blend value other than 2.\ntypedef uint8_t wuffs_base__animation_blend;\n\n#define WUFFS_BASE__ANIMATION_BLEND__SRC_OVER_DST \\\n ((wuffs_base__animation_blend)0)\n#define WUFFS_BASE__ANIMATION_BLEND__SRC ((wuffs_base__animation_blend)1)\n#define WUFFS_BASE__ANIMATION_BLEND__OPAQUE ((wuffs_base__animation_blend)2)\n\n" +
"" +
"// --------\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 {\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 update(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 height() con" +
"st;\n inline wuffs_base__flicks duration() const;\n inline uint64_t index() const;\n inline uint64_t io_position() const;\n inline wuffs_base__animation_disposal disposal() const;\n inline bool opaque_within_bounds() const;\n inline bool overwrite_instead_of_blend() const;\n inline wuffs_base__color_u32_argb_premul background_color() const;\n#endif // __cplusplus\n\n} wuffs_base__frame_config;\n\nstatic inline wuffs_base__frame_config //\nwuffs_base__null_frame_config() {\n wuffs_base__frame_config ret;\n ret.private_impl.bounds = wuffs_base__make_rect_ie_u32(0, 0, 0, 0);\n ret.private_impl.duration = 0;\n ret.private_impl.index = 0;\n ret.private_impl.io_position = 0;\n ret.private_impl.disposal = 0;\n ret.private_impl.opaque_within_bounds = false;\n ret.private_impl.overwrite_instead_of_blend = false;\n return ret;\n}\n\nstatic inline void //\nwuffs_base__frame_config__update(\n wuffs_base__frame_config* c,\n wuffs_base__rect_ie_u32 bounds,\n wuffs_base__flicks duration,\n uint64_t index,\n uint64_t io_p" +
"osition,\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 if (!c) {\n return;\n }\n\n c->private_impl.bounds = bounds;\n c->private_impl.duration = duration;\n c->private_impl.index = index;\n c->private_impl.io_position = io_position;\n c->private_impl.disposal = disposal;\n c->private_impl.opaque_within_bounds = opaque_within_bounds;\n c->private_impl.overwrite_instead_of_blend = overwrite_instead_of_blend;\n c->private_impl.background_color = background_color;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config__bounds(const wuffs_base__frame_config* c) {\n if (c) {\n return c->private_impl.bounds;\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__frame_config__width(const wuffs_base__frame_config* c) {\n return c ? wuffs_base__rect_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::update(\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 wuffs_base__frame_config__update(\n this, bounds, duration, index, io_position, disposal,\n opaque_within_bounds, overwrite_instead_of_blend, background_color);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__frame_config::bounds() const {\n return wuffs_base__frame_config__bounds(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::width() const {\n return wuffs_base__frame_config__width(this);\n}\n\ninline uint32_t //\nwuffs_base__frame_config::height() const {\n return wuffs_base__frame_config__height(this);\n}\n\ninline wuffs_base__flicks //\nwuffs_base__frame_config::duration() const {\n return wuffs_base__frame_config__duration(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::index() const {\n return wuffs_b" +
"ase__frame_config__index(this);\n}\n\ninline uint64_t //\nwuffs_base__frame_config::io_position() const {\n return wuffs_base__frame_config__io_position(this);\n}\n\ninline wuffs_base__animation_disposal //\nwuffs_base__frame_config::disposal() const {\n return wuffs_base__frame_config__disposal(this);\n}\n\ninline bool //\nwuffs_base__frame_config::opaque_within_bounds() const {\n return wuffs_base__frame_config__opaque_within_bounds(this);\n}\n\ninline bool //\nwuffs_base__frame_config::overwrite_instead_of_blend() const {\n return wuffs_base__frame_config__overwrite_instead_of_blend(this);\n}\n\ninline wuffs_base__color_u32_argb_premul //\nwuffs_base__frame_config::background_color() const {\n return wuffs_base__frame_config__background_color(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct {\n wuffs_base__pixel_config pixcfg;\n\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__table_u8 planes[WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX];\n // TODO: color spaces.\n } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status set_from_slice(\n const wuffs_base__pixel_config* pixcfg,\n wuffs_base__slice_u8 pixbuf_memory);\n inline wuffs_base__status set_from_table(\n const wuffs_base__pixel_config* pixcfg,\n wuffs_base__table_u8 pixbuf_memory);\n inline wuffs_base__slice_u8 palette();\n inline wuffs_base__pixel_format pixel_format() const;\n inline wuffs_base__table_u8 plane(uint32_t p);\n inline wuffs_base__color_u32_argb_premul color_u32_at(uint32_t x,\n uint32_t y) const;\n inline wuffs_base__status set_color_u32_at(\n uint32_t x,\n uint32_t y,\n wuffs_base__color_u32_argb_premul co" +
"lor);\n#endif // __cplusplus\n\n} wuffs_base__pixel_buffer;\n\nstatic inline wuffs_base__pixel_buffer //\nwuffs_base__null_pixel_buffer() {\n wuffs_base__pixel_buffer ret;\n ret.pixcfg = wuffs_base__null_pixel_config();\n ret.private_impl.planes[0] = wuffs_base__empty_table_u8();\n ret.private_impl.planes[1] = wuffs_base__empty_table_u8();\n ret.private_impl.planes[2] = wuffs_base__empty_table_u8();\n ret.private_impl.planes[3] = wuffs_base__empty_table_u8();\n return ret;\n}\n\nstatic inline wuffs_base__status //\nwuffs_base__pixel_buffer__set_from_slice(wuffs_base__pixel_buffer* pb,\n const wuffs_base__pixel_config* pixcfg,\n 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 1024 byte chunk (256 palette entries × 4 bytes per entry) from\n // the start of pixbuf_memory. We split from the start, not the end, so\n // that the both chunks' pointers have the same alignment as the original\n // pointer, up to an alignment of 1024.\n if (len < 1024) {\n return wuffs_base__make_status(\n wuffs_bas" +
"e__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 = 1024;\n tab->height = 1;\n tab->stride = 1024;\n ptr += 1024;\n len -= 1024;\n }\n\n uint64_t wh = ((uint64_t)pixcfg->private_impl.width) *\n ((uint64_t)pixcfg->private_impl.height);\n size_t width = (size_t)(pixcfg->private_impl.width);\n if ((wh > (UINT64_MAX / bytes_per_pixel)) ||\n (width > (SIZE_MAX / bytes_per_pixel))) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n wh *= bytes_per_pixel;\n width *= bytes_per_pixel;\n if (wh > len) {\n return wuffs_base__make_status(\n wuffs_base__error__bad_argument_length_too_short);\n }\n\n pb->pixcfg = *pixcfg;\n wuffs_base__table_u8* tab = &pb->private_impl.planes[0];\n tab->ptr = ptr;\n tab->width = width;\n tab->height = pixcfg->private_impl.height;\n tab->stride = width;\n return wuffs_base__m" +
"ake_status(NULL);\n}\n\nstatic inline wuffs_base__status //\nwuffs_base__pixel_buffer__set_from_table(wuffs_base__pixel_buffer* pb,\n const wuffs_base__pixel_config* pixcfg,\n wuffs_base__table_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 wuffs_base__pixel_format__is_planar(&pixcfg->private_impl.pixfmt)) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\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 uint64_t width_in_bytes =\n ((uint64_t)pixcfg->private_impl.width) * bytes_per_pixe" +
"l;\n if ((width_in_bytes > pixbuf_memory.width) ||\n (pixcfg->private_impl.height > pixbuf_memory.height)) {\n return wuffs_base__make_status(wuffs_base__error__bad_argument);\n }\n\n pb->pixcfg = *pixcfg;\n pb->private_impl.planes[0] = pixbuf_memory;\n return wuffs_base__make_status(NULL);\n}\n\n// wuffs_base__pixel_buffer__palette returns the palette color data. If\n// non-empty, it will have length 1024.\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer__palette(wuffs_base__pixel_buffer* pb) {\n if (pb &&\n wuffs_base__pixel_format__is_indexed(&pb->pixcfg.private_impl.pixfmt)) {\n wuffs_base__table_u8* tab =\n &pb->private_impl\n .planes[WUFFS_BASE__PIXEL_FORMAT__INDEXED__COLOR_PLANE];\n if ((tab->width == 1024) && (tab->height == 1)) {\n return wuffs_base__make_slice_u8(tab->ptr, 1024);\n }\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer__pixel_format(const wuffs_base__pixel_buffer* pb) {\n" +
" if (pb) {\n return pb->pixcfg.private_impl.pixfmt;\n }\n return wuffs_base__make_pixel_format(WUFFS_BASE__PIXEL_FORMAT__INVALID);\n}\n\nstatic inline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer__plane(wuffs_base__pixel_buffer* pb, uint32_t p) {\n if (pb && (p < WUFFS_BASE__PIXEL_FORMAT__NUM_PLANES_MAX)) {\n return pb->private_impl.planes[p];\n }\n\n wuffs_base__table_u8 ret;\n ret.ptr = NULL;\n ret.width = 0;\n ret.height = 0;\n ret.stride = 0;\n return ret;\n}\n\nwuffs_base__color_u32_argb_premul //\nwuffs_base__pixel_buffer__color_u32_at(const wuffs_base__pixel_buffer* pb,\n uint32_t x,\n uint32_t y);\n\nwuffs_base__status //\nwuffs_base__pixel_buffer__set_color_u32_at(\n wuffs_base__pixel_buffer* pb,\n uint32_t x,\n uint32_t y,\n wuffs_base__color_u32_argb_premul color);\n\n#ifdef __cplusplus\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_from_slice(\n const wuffs_base__pixel_config* pixcfg_arg,\n wuffs_bas" +
"e__slice_u8 pixbuf_memory) {\n return wuffs_base__pixel_buffer__set_from_slice(this, pixcfg_arg,\n pixbuf_memory);\n}\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_from_table(\n const wuffs_base__pixel_config* pixcfg_arg,\n wuffs_base__table_u8 pixbuf_memory) {\n return wuffs_base__pixel_buffer__set_from_table(this, pixcfg_arg,\n pixbuf_memory);\n}\n\ninline wuffs_base__slice_u8 //\nwuffs_base__pixel_buffer::palette() {\n return wuffs_base__pixel_buffer__palette(this);\n}\n\ninline wuffs_base__pixel_format //\nwuffs_base__pixel_buffer::pixel_format() const {\n return wuffs_base__pixel_buffer__pixel_format(this);\n}\n\ninline wuffs_base__table_u8 //\nwuffs_base__pixel_buffer::plane(uint32_t p) {\n return wuffs_base__pixel_buffer__plane(this, p);\n}\n\ninline wuffs_base__color_u32_argb_premul //\nwuffs_base__pixel_buffer::color_u32_at(uint32_t x, uint32_t y) const {\n return wuffs_base__pixel_buffer__color_u32_" +
"at(this, x, y);\n}\n\ninline wuffs_base__status //\nwuffs_base__pixel_buffer::set_color_u32_at(\n uint32_t x,\n uint32_t y,\n wuffs_base__color_u32_argb_premul color) {\n return wuffs_base__pixel_buffer__set_color_u32_at(this, x, y, color);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef 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.\nuint8_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)(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src);\n\ntypedef 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 } private_impl;\n\n#ifdef __cplusplus\n inline wuffs_base__status prepare(wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend);\n inline uint64_t swizzle_interleaved(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) const;\n#endi" +
"f // __cplusplus\n\n} wuffs_base__pixel_swizzler;\n\nwuffs_base__status //\nwuffs_base__pixel_swizzler__prepare(wuffs_base__pixel_swizzler* p,\n wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src_palette,\n wuffs_base__pixel_blend blend);\n\nuint64_t //\nwuffs_base__pixel_swizzler__swizzle_interleaved(\n const wuffs_base__pixel_swizzler* p,\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src);\n\n#ifdef __cplusplus\n\ninline wuffs_base__status //\nwuffs_base__pixel_swizzler::prepare(wuffs_base__pixel_format dst_format,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__pixel_format src_format,\n wuffs_base__slice_u8 src" +
"_palette,\n wuffs_base__pixel_blend blend) {\n return wuffs_base__pixel_swizzler__prepare(this, dst_format, dst_palette,\n src_format, src_palette, blend);\n}\n\nuint64_t //\nwuffs_base__pixel_swizzler::swizzle_interleaved(\n wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 dst_palette,\n wuffs_base__slice_u8 src) const {\n return wuffs_base__pixel_swizzler__swizzle_interleaved(this, dst, dst_palette,\n src);\n}\n\n#endif // __cplusplus\n" +
""
const baseIOPrivateH = "" +
"// ---------------- 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\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io__since(uint64_t mark, uint64_t index, uint8_t* ptr) {\n if (index >= mark) {\n return wuffs_base__make_slice_u8(ptr + mark, index - mark);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w,\n uint8_t* io1_w,\n uint8_t* io2_w,\n uint32_t length,\n 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 // copy_n32_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__copy_n32_from_history_fast below.\n //\n // Alternatively, or additionally, have a sloppy_copy_n32_from_history method\n // that copies 8 bytes at a time, possibly writing more than length bytes?\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__copy_n32_from_history_fast is like the\n// wuffs_base__io_writer__copy_n32_from_history function above, but has\n// stronger pre-conditions. The caller needs to prove" +
" that:\n// - distance > 0\n// - distance <= (*ptr_iop_w - io1_w)\n// - length <= (io2_w - *ptr_iop_w)\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_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\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t length,\n uint8_t** ptr_iop_r,\n " +
" 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 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 uint64_t //\nwuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += n;\n }\n return (uint64_t)(n);\n}\n\nstatic inline uint32_t //\nwuffs_base__io_writer__copy_n32_from_slice(uint8_t** ptr_iop_w,\n uint8_t* io2_w,\n uint32_t" +
" length,\n wuffs_base__slice_u8 src) {\n uint8_t* iop_w = *ptr_iop_w;\n size_t n = src.len;\n if (n > length) {\n n = length;\n }\n if (n > ((size_t)(io2_w - iop_w))) {\n n = (size_t)(io2_w - iop_w);\n }\n if (n > 0) {\n memmove(iop_w, src.ptr, n);\n *ptr_iop_w += 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(ui" +
"nt8_t* iop_r,\n 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__load_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_r != ((uint8_t)(a))) {\n return 2;\n }\n iop_r++;\n a >>= 8;\n }\n return 0;\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_reader__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_r,\n uint8_t** ptr_io0_r,\n uint8_t** ptr_io1_r,\n uint8_t** ptr_io2_r,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = data.len;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = fal" +
"se;\n\n *ptr_iop_r = data.ptr;\n *ptr_io0_r = data.ptr;\n *ptr_io1_r = data.ptr;\n *ptr_io2_r = data.ptr + data.len;\n\n return b;\n}\n\nstatic inline wuffs_base__slice_u8 //\nwuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io2_r, uint64_t n) {\n if (n <= ((size_t)(io2_r - *ptr_iop_r))) {\n uint8_t* p = *ptr_iop_r;\n *ptr_iop_r += n;\n return wuffs_base__make_slice_u8(p, n);\n }\n return wuffs_base__make_slice_u8(NULL, 0);\n}\n\nstatic inline wuffs_base__io_buffer* //\nwuffs_base__io_writer__set(wuffs_base__io_buffer* b,\n uint8_t** ptr_iop_w,\n uint8_t** ptr_io0_w,\n uint8_t** ptr_io1_w,\n uint8_t** ptr_io2_w,\n wuffs_base__slice_u8 data) {\n b->data = data;\n b->meta.wi = 0;\n b->meta.ri = 0;\n b->meta.pos = 0;\n b->meta.closed = false;\n\n *ptr_iop_w = data.ptr;\n *ptr_io0_w = data.ptr;\n *ptr_io1_w = data.ptr;\n *ptr_io2_w = data.ptr + data.len;\n\n return b;\n}\n\n " +
"" +
"// ---------------- I/O (Utility)\n\n#define wuffs_base__utility__empty_io_reader wuffs_base__empty_io_reader\n#define wuffs_base__utility__empty_io_writer wuffs_base__empty_io_writer\n" +
""
const baseIOPublicH = "" +
"// ---------------- 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 {\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__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 {\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 uint64_t reader_available() const;\n inline uint64_t reader_io_position() const;\n inline uint64_t writer_available() const;\n inline uint64_t writer_io_position() const;\n#endif // __cplusplus\n\n} wuffs_base__io_buffer;\n\nstatic inline wuffs_base__io_buf" +
"fer //\nwuffs_base__make_io_buffer(wuffs_base__slice_u8 data,\n wuffs_base__io_buffer_meta meta) {\n wuffs_base__io_buffer ret;\n ret.data = data;\n ret.meta = meta;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer_meta //\nwuffs_base__make_io_buffer_meta(size_t wi,\n size_t ri,\n uint64_t pos,\n bool closed) {\n wuffs_base__io_buffer_meta ret;\n ret.wi = wi;\n ret.ri = ri;\n ret.pos = pos;\n ret.closed = closed;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__ptr_u8__reader(uint8_t* ptr, size_t len, bool closed) {\n wuffs_base__io_buffer ret;\n ret.data.ptr = ptr;\n ret.data.len = len;\n ret.meta.wi = len;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = closed;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__ptr_u8__writer(uint8_t* ptr, size_t len) {\n wuffs_base__io_buffer ret;\n ret.data.ptr = ptr;\n ret.data.len = len;\n ret.meta.wi = 0" +
";\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__slice_u8__reader(wuffs_base__slice_u8 s, bool closed) {\n wuffs_base__io_buffer ret;\n ret.data.ptr = s.ptr;\n ret.data.len = s.len;\n ret.meta.wi = s.len;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = closed;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__slice_u8__writer(wuffs_base__slice_u8 s) {\n wuffs_base__io_buffer ret;\n ret.data.ptr = s.ptr;\n ret.data.len = s.len;\n ret.meta.wi = 0;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer //\nwuffs_base__empty_io_buffer() {\n wuffs_base__io_buffer ret;\n ret.data.ptr = NULL;\n ret.data.len = 0;\n ret.meta.wi = 0;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__io_buffer_meta //\nwuffs_base__empty_io_buffer_meta() {\n wuffs_base__io_buffer_meta ret;\n ret.wi = " +
"0;\n ret.ri = 0;\n ret.pos = 0;\n ret.closed = false;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__io_buffer__is_valid(const wuffs_base__io_buffer* buf) {\n if (buf) {\n if (buf->data.ptr) {\n return (buf->meta.ri <= buf->meta.wi) && (buf->meta.wi <= buf->data.len);\n } else {\n return (buf->meta.ri == 0) && (buf->meta.wi == 0) && (buf->data.len == 0);\n }\n }\n return false;\n}\n\n// wuffs_base__io_buffer__compact moves any written but unread bytes to the\n// start of the buffer.\nstatic inline void //\nwuffs_base__io_buffer__compact(wuffs_base__io_buffer* buf) {\n if (!buf || (buf->meta.ri == 0)) {\n return;\n }\n buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);\n size_t n = buf->meta.wi - buf->meta.ri;\n if (n != 0) {\n memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri, n);\n }\n buf->meta.wi = n;\n buf->meta.ri = 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__reader_available(const wuffs_base__io_buffer* buf) {\n return buf ? buf->meta.wi - buf->meta.ri" +
" : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__reader_io_position(const wuffs_base__io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__writer_available(const wuffs_base__io_buffer* buf) {\n return buf ? buf->data.len - buf->meta.wi : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__io_buffer__writer_io_position(const wuffs_base__io_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__io_buffer::is_valid() const {\n return wuffs_base__io_buffer__is_valid(this);\n}\n\ninline void //\nwuffs_base__io_buffer::compact() {\n wuffs_base__io_buffer__compact(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer::reader_available() const {\n return wuffs_base__io_buffer__reader_available(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer::reader_io_position() const {\n return wuffs_base__io_buffer__reader_io_position(this);\n}\n\ninline uint" +
"64_t //\nwuffs_base__io_buffer::writer_available() const {\n return wuffs_base__io_buffer__writer_available(this);\n}\n\ninline uint64_t //\nwuffs_base__io_buffer::writer_io_position() const {\n return wuffs_base__io_buffer__writer_io_position(this);\n}\n\n#endif // __cplusplus\n" +
""
const baseRangePrivateH = "" +
"// ---------------- Ranges and Rects\n\nstatic inline uint32_t //\nwuffs_base__range_ii_u32__get_min_incl(const wuffs_base__range_ii_u32* r) {\n return r->min_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ii_u32__get_max_incl(const wuffs_base__range_ii_u32* r) {\n return r->max_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ie_u32__get_min_incl(const wuffs_base__range_ie_u32* r) {\n return r->min_incl;\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ie_u32__get_max_excl(const wuffs_base__range_ie_u32* r) {\n return r->max_excl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ii_u64__get_min_incl(const wuffs_base__range_ii_u64* r) {\n return r->min_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ii_u64__get_max_incl(const wuffs_base__range_ii_u64* r) {\n return r->max_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ie_u64__get_min_incl(const wuffs_base__range_ie_u64* r) {\n return r->min_incl;\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ie_u64__get_max_excl(const wuffs_base__range_" +
"ie_u64* r) {\n return r->max_excl;\n}\n\n" +
"" +
"// ---------------- Ranges and Rects (Utility)\n\n#define wuffs_base__utility__empty_range_ii_u32 wuffs_base__empty_range_ii_u32\n#define wuffs_base__utility__empty_range_ie_u32 wuffs_base__empty_range_ie_u32\n#define wuffs_base__utility__empty_range_ii_u64 wuffs_base__empty_range_ii_u64\n#define wuffs_base__utility__empty_range_ie_u64 wuffs_base__empty_range_ie_u64\n#define wuffs_base__utility__empty_rect_ii_u32 wuffs_base__empty_rect_ii_u32\n#define wuffs_base__utility__empty_rect_ie_u32 wuffs_base__empty_rect_ie_u32\n#define wuffs_base__utility__make_range_ii_u32 wuffs_base__make_range_ii_u32\n#define wuffs_base__utility__make_range_ie_u32 wuffs_base__make_range_ie_u32\n#define wuffs_base__utility__make_range_ii_u64 wuffs_base__make_range_ii_u64\n#define wuffs_base__utility__make_range_ie_u64 wuffs_base__make_range_ie_u64\n#define wuffs_base__utility__make_rect_ii_u32 wuffs_base__make_rect_ii_u32\n#define wuffs_base__utility__make_rect_ie_u32 wuffs_base__make_rect_ie_u32\n" +
""
const baseRangePublicH = "" +
"// ---------------- Ranges and Rects\n\n// See https://github.com/google/wuffs/blob/master/doc/note/ranges-and-rects.md\n\ntypedef struct wuffs_base__range_ii_u32__struct {\n uint32_t min_incl;\n uint32_t max_incl;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__range_ii_u32__struct s) const;\n inline wuffs_base__range_ii_u32__struct intersect(\n wuffs_base__range_ii_u32__struct s) const;\n inline wuffs_base__range_ii_u32__struct unite(\n wuffs_base__range_ii_u32__struct s) const;\n inline bool contains(uint32_t x) const;\n inline bool contains_range(wuffs_base__range_ii_u32__struct s) const;\n#endif // __cplusplus\n\n} wuffs_base__range_ii_u32;\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__empty_range_ii_u32() {\n wuffs_base__range_ii_u32 ret;\n ret.min_incl = 0;\n ret.max_incl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__make_range_ii_u32(uint32_t min_incl, uint32_t max_incl) {\n wuffs_base__range_ii_u32 ret;\n ret.min_incl = m" +
"in_incl;\n ret.max_incl = max_incl;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u32__is_empty(const wuffs_base__range_ii_u32* r) {\n return r->min_incl > r->max_incl;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u32__equals(const wuffs_base__range_ii_u32* r,\n wuffs_base__range_ii_u32 s) {\n return (r->min_incl == s.min_incl && r->max_incl == s.max_incl) ||\n (wuffs_base__range_ii_u32__is_empty(r) &&\n wuffs_base__range_ii_u32__is_empty(&s));\n}\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__range_ii_u32__intersect(const wuffs_base__range_ii_u32* r,\n wuffs_base__range_ii_u32 s) {\n wuffs_base__range_ii_u32 t;\n t.min_incl = wuffs_base__u32__max(r->min_incl, s.min_incl);\n t.max_incl = wuffs_base__u32__min(r->max_incl, s.max_incl);\n return t;\n}\n\nstatic inline wuffs_base__range_ii_u32 //\nwuffs_base__range_ii_u32__unite(const wuffs_base__range_ii_u32* r,\n wuffs_base__range_" +
"ii_u32 s) {\n if (wuffs_base__range_ii_u32__is_empty(r)) {\n return s;\n }\n if (wuffs_base__range_ii_u32__is_empty(&s)) {\n return *r;\n }\n wuffs_base__range_ii_u32 t;\n t.min_incl = wuffs_base__u32__min(r->min_incl, s.min_incl);\n t.max_incl = wuffs_base__u32__max(r->max_incl, s.max_incl);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u32__contains(const wuffs_base__range_ii_u32* r,\n uint32_t x) {\n return (r->min_incl <= x) && (x <= r->max_incl);\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u32__contains_range(const wuffs_base__range_ii_u32* r,\n wuffs_base__range_ii_u32 s) {\n return wuffs_base__range_ii_u32__equals(\n &s, wuffs_base__range_ii_u32__intersect(r, s));\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__range_ii_u32::is_empty() const {\n return wuffs_base__range_ii_u32__is_empty(this);\n}\n\ninline bool //\nwuffs_base__range_ii_u32::equals(wuffs_base__range_ii_u32 s) const {\n return wuffs_base__rang" +
"e_ii_u32__equals(this, s);\n}\n\ninline wuffs_base__range_ii_u32 //\nwuffs_base__range_ii_u32::intersect(wuffs_base__range_ii_u32 s) const {\n return wuffs_base__range_ii_u32__intersect(this, s);\n}\n\ninline wuffs_base__range_ii_u32 //\nwuffs_base__range_ii_u32::unite(wuffs_base__range_ii_u32 s) const {\n return wuffs_base__range_ii_u32__unite(this, s);\n}\n\ninline bool //\nwuffs_base__range_ii_u32::contains(uint32_t x) const {\n return wuffs_base__range_ii_u32__contains(this, x);\n}\n\ninline bool //\nwuffs_base__range_ii_u32::contains_range(wuffs_base__range_ii_u32 s) const {\n return wuffs_base__range_ii_u32__contains_range(this, s);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct wuffs_base__range_ie_u32__struct {\n uint32_t min_incl;\n uint32_t max_excl;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__range_ie_u32__struct s) const;\n inline wuffs_base__range_ie_u32__struct intersect(\n wuffs_base__range_ie_u32__struct s) const;\n inline wuffs_base__range_ie_u32__struct unite(\n wuffs_base__range_ie_u32__struct s) const;\n inline bool contains(uint32_t x) const;\n inline bool contains_range(wuffs_base__range_ie_u32__struct s) const;\n inline uint32_t length() const;\n#endif // __cplusplus\n\n} wuffs_base__range_ie_u32;\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__empty_range_ie_u32() {\n wuffs_base__range_ie_u32 ret;\n ret.min_incl = 0;\n ret.max_excl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__make_range_ie_u32(uint32_t min_incl, uint32_t max_excl) {\n wuffs_base__range_ie_u32 ret;\n ret.min_incl = min_incl;\n ret.max_excl = max_excl;\n return ret;\n}\n\nstatic inline bool " +
" //\nwuffs_base__range_ie_u32__is_empty(const wuffs_base__range_ie_u32* r) {\n return r->min_incl >= r->max_excl;\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u32__equals(const wuffs_base__range_ie_u32* r,\n wuffs_base__range_ie_u32 s) {\n return (r->min_incl == s.min_incl && r->max_excl == s.max_excl) ||\n (wuffs_base__range_ie_u32__is_empty(r) &&\n wuffs_base__range_ie_u32__is_empty(&s));\n}\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__range_ie_u32__intersect(const wuffs_base__range_ie_u32* r,\n wuffs_base__range_ie_u32 s) {\n wuffs_base__range_ie_u32 t;\n t.min_incl = wuffs_base__u32__max(r->min_incl, s.min_incl);\n t.max_excl = wuffs_base__u32__min(r->max_excl, s.max_excl);\n return t;\n}\n\nstatic inline wuffs_base__range_ie_u32 //\nwuffs_base__range_ie_u32__unite(const wuffs_base__range_ie_u32* r,\n wuffs_base__range_ie_u32 s) {\n if (wuffs_base__range_ie_u32__is_empty(r)) {\n return s" +
";\n }\n if (wuffs_base__range_ie_u32__is_empty(&s)) {\n return *r;\n }\n wuffs_base__range_ie_u32 t;\n t.min_incl = wuffs_base__u32__min(r->min_incl, s.min_incl);\n t.max_excl = wuffs_base__u32__max(r->max_excl, s.max_excl);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u32__contains(const wuffs_base__range_ie_u32* r,\n uint32_t x) {\n return (r->min_incl <= x) && (x < r->max_excl);\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u32__contains_range(const wuffs_base__range_ie_u32* r,\n wuffs_base__range_ie_u32 s) {\n return wuffs_base__range_ie_u32__equals(\n &s, wuffs_base__range_ie_u32__intersect(r, s));\n}\n\nstatic inline uint32_t //\nwuffs_base__range_ie_u32__length(const wuffs_base__range_ie_u32* r) {\n return wuffs_base__u32__sat_sub(r->max_excl, r->min_incl);\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__range_ie_u32::is_empty() const {\n return wuffs_base__range_ie_u32__is_empty(this);\n}\n\ninline bool //\nwuffs" +
"_base__range_ie_u32::equals(wuffs_base__range_ie_u32 s) const {\n return wuffs_base__range_ie_u32__equals(this, s);\n}\n\ninline wuffs_base__range_ie_u32 //\nwuffs_base__range_ie_u32::intersect(wuffs_base__range_ie_u32 s) const {\n return wuffs_base__range_ie_u32__intersect(this, s);\n}\n\ninline wuffs_base__range_ie_u32 //\nwuffs_base__range_ie_u32::unite(wuffs_base__range_ie_u32 s) const {\n return wuffs_base__range_ie_u32__unite(this, s);\n}\n\ninline bool //\nwuffs_base__range_ie_u32::contains(uint32_t x) const {\n return wuffs_base__range_ie_u32__contains(this, x);\n}\n\ninline bool //\nwuffs_base__range_ie_u32::contains_range(wuffs_base__range_ie_u32 s) const {\n return wuffs_base__range_ie_u32__contains_range(this, s);\n}\n\ninline uint32_t //\nwuffs_base__range_ie_u32::length() const {\n return wuffs_base__range_ie_u32__length(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct wuffs_base__range_ii_u64__struct {\n uint64_t min_incl;\n uint64_t max_incl;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__range_ii_u64__struct s) const;\n inline wuffs_base__range_ii_u64__struct intersect(\n wuffs_base__range_ii_u64__struct s) const;\n inline wuffs_base__range_ii_u64__struct unite(\n wuffs_base__range_ii_u64__struct s) const;\n inline bool contains(uint64_t x) const;\n inline bool contains_range(wuffs_base__range_ii_u64__struct s) const;\n#endif // __cplusplus\n\n} wuffs_base__range_ii_u64;\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__empty_range_ii_u64() {\n wuffs_base__range_ii_u64 ret;\n ret.min_incl = 0;\n ret.max_incl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__make_range_ii_u64(uint64_t min_incl, uint64_t max_incl) {\n wuffs_base__range_ii_u64 ret;\n ret.min_incl = min_incl;\n ret.max_incl = max_incl;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u64__is_e" +
"mpty(const wuffs_base__range_ii_u64* r) {\n return r->min_incl > r->max_incl;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u64__equals(const wuffs_base__range_ii_u64* r,\n wuffs_base__range_ii_u64 s) {\n return (r->min_incl == s.min_incl && r->max_incl == s.max_incl) ||\n (wuffs_base__range_ii_u64__is_empty(r) &&\n wuffs_base__range_ii_u64__is_empty(&s));\n}\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__range_ii_u64__intersect(const wuffs_base__range_ii_u64* r,\n wuffs_base__range_ii_u64 s) {\n wuffs_base__range_ii_u64 t;\n t.min_incl = wuffs_base__u64__max(r->min_incl, s.min_incl);\n t.max_incl = wuffs_base__u64__min(r->max_incl, s.max_incl);\n return t;\n}\n\nstatic inline wuffs_base__range_ii_u64 //\nwuffs_base__range_ii_u64__unite(const wuffs_base__range_ii_u64* r,\n wuffs_base__range_ii_u64 s) {\n if (wuffs_base__range_ii_u64__is_empty(r)) {\n return s;\n }\n if (wuffs_base__range_ii_u6" +
"4__is_empty(&s)) {\n return *r;\n }\n wuffs_base__range_ii_u64 t;\n t.min_incl = wuffs_base__u64__min(r->min_incl, s.min_incl);\n t.max_incl = wuffs_base__u64__max(r->max_incl, s.max_incl);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u64__contains(const wuffs_base__range_ii_u64* r,\n uint64_t x) {\n return (r->min_incl <= x) && (x <= r->max_incl);\n}\n\nstatic inline bool //\nwuffs_base__range_ii_u64__contains_range(const wuffs_base__range_ii_u64* r,\n wuffs_base__range_ii_u64 s) {\n return wuffs_base__range_ii_u64__equals(\n &s, wuffs_base__range_ii_u64__intersect(r, s));\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__range_ii_u64::is_empty() const {\n return wuffs_base__range_ii_u64__is_empty(this);\n}\n\ninline bool //\nwuffs_base__range_ii_u64::equals(wuffs_base__range_ii_u64 s) const {\n return wuffs_base__range_ii_u64__equals(this, s);\n}\n\ninline wuffs_base__range_ii_u64 //\nwuffs_base__range_ii_u64::intersect(wuff" +
"s_base__range_ii_u64 s) const {\n return wuffs_base__range_ii_u64__intersect(this, s);\n}\n\ninline wuffs_base__range_ii_u64 //\nwuffs_base__range_ii_u64::unite(wuffs_base__range_ii_u64 s) const {\n return wuffs_base__range_ii_u64__unite(this, s);\n}\n\ninline bool //\nwuffs_base__range_ii_u64::contains(uint64_t x) const {\n return wuffs_base__range_ii_u64__contains(this, x);\n}\n\ninline bool //\nwuffs_base__range_ii_u64::contains_range(wuffs_base__range_ii_u64 s) const {\n return wuffs_base__range_ii_u64__contains_range(this, s);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct wuffs_base__range_ie_u64__struct {\n uint64_t min_incl;\n uint64_t max_excl;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__range_ie_u64__struct s) const;\n inline wuffs_base__range_ie_u64__struct intersect(\n wuffs_base__range_ie_u64__struct s) const;\n inline wuffs_base__range_ie_u64__struct unite(\n wuffs_base__range_ie_u64__struct s) const;\n inline bool contains(uint64_t x) const;\n inline bool contains_range(wuffs_base__range_ie_u64__struct s) const;\n inline uint64_t length() const;\n#endif // __cplusplus\n\n} wuffs_base__range_ie_u64;\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__empty_range_ie_u64() {\n wuffs_base__range_ie_u64 ret;\n ret.min_incl = 0;\n ret.max_excl = 0;\n return ret;\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__make_range_ie_u64(uint64_t min_incl, uint64_t max_excl) {\n wuffs_base__range_ie_u64 ret;\n ret.min_incl = min_incl;\n ret.max_excl = max_excl;\n return ret;\n}\n\nstatic inline bool " +
" //\nwuffs_base__range_ie_u64__is_empty(const wuffs_base__range_ie_u64* r) {\n return r->min_incl >= r->max_excl;\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u64__equals(const wuffs_base__range_ie_u64* r,\n wuffs_base__range_ie_u64 s) {\n return (r->min_incl == s.min_incl && r->max_excl == s.max_excl) ||\n (wuffs_base__range_ie_u64__is_empty(r) &&\n wuffs_base__range_ie_u64__is_empty(&s));\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__range_ie_u64__intersect(const wuffs_base__range_ie_u64* r,\n wuffs_base__range_ie_u64 s) {\n wuffs_base__range_ie_u64 t;\n t.min_incl = wuffs_base__u64__max(r->min_incl, s.min_incl);\n t.max_excl = wuffs_base__u64__min(r->max_excl, s.max_excl);\n return t;\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__range_ie_u64__unite(const wuffs_base__range_ie_u64* r,\n wuffs_base__range_ie_u64 s) {\n if (wuffs_base__range_ie_u64__is_empty(r)) {\n return s" +
";\n }\n if (wuffs_base__range_ie_u64__is_empty(&s)) {\n return *r;\n }\n wuffs_base__range_ie_u64 t;\n t.min_incl = wuffs_base__u64__min(r->min_incl, s.min_incl);\n t.max_excl = wuffs_base__u64__max(r->max_excl, s.max_excl);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u64__contains(const wuffs_base__range_ie_u64* r,\n uint64_t x) {\n return (r->min_incl <= x) && (x < r->max_excl);\n}\n\nstatic inline bool //\nwuffs_base__range_ie_u64__contains_range(const wuffs_base__range_ie_u64* r,\n wuffs_base__range_ie_u64 s) {\n return wuffs_base__range_ie_u64__equals(\n &s, wuffs_base__range_ie_u64__intersect(r, s));\n}\n\nstatic inline uint64_t //\nwuffs_base__range_ie_u64__length(const wuffs_base__range_ie_u64* r) {\n return wuffs_base__u64__sat_sub(r->max_excl, r->min_incl);\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__range_ie_u64::is_empty() const {\n return wuffs_base__range_ie_u64__is_empty(this);\n}\n\ninline bool //\nwuffs" +
"_base__range_ie_u64::equals(wuffs_base__range_ie_u64 s) const {\n return wuffs_base__range_ie_u64__equals(this, s);\n}\n\ninline wuffs_base__range_ie_u64 //\nwuffs_base__range_ie_u64::intersect(wuffs_base__range_ie_u64 s) const {\n return wuffs_base__range_ie_u64__intersect(this, s);\n}\n\ninline wuffs_base__range_ie_u64 //\nwuffs_base__range_ie_u64::unite(wuffs_base__range_ie_u64 s) const {\n return wuffs_base__range_ie_u64__unite(this, s);\n}\n\ninline bool //\nwuffs_base__range_ie_u64::contains(uint64_t x) const {\n return wuffs_base__range_ie_u64__contains(this, x);\n}\n\ninline bool //\nwuffs_base__range_ie_u64::contains_range(wuffs_base__range_ie_u64 s) const {\n return wuffs_base__range_ie_u64__contains_range(this, s);\n}\n\ninline uint64_t //\nwuffs_base__range_ie_u64::length() const {\n return wuffs_base__range_ie_u64__length(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct wuffs_base__rect_ii_u32__struct {\n uint32_t min_incl_x;\n uint32_t min_incl_y;\n uint32_t max_incl_x;\n uint32_t max_incl_y;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__rect_ii_u32__struct s) const;\n inline wuffs_base__rect_ii_u32__struct intersect(\n wuffs_base__rect_ii_u32__struct s) const;\n inline wuffs_base__rect_ii_u32__struct unite(\n wuffs_base__rect_ii_u32__struct s) const;\n inline bool contains(uint32_t x, uint32_t y) const;\n inline bool contains_rect(wuffs_base__rect_ii_u32__struct s) const;\n#endif // __cplusplus\n\n} wuffs_base__rect_ii_u32;\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__empty_rect_ii_u32() {\n wuffs_base__rect_ii_u32 ret;\n ret.min_incl_x = 0;\n ret.min_incl_y = 0;\n ret.max_incl_x = 0;\n ret.max_incl_y = 0;\n return ret;\n}\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__make_rect_ii_u32(uint32_t min_incl_x,\n uint32_t min_incl_y,\n " +
"uint32_t max_incl_x,\n uint32_t max_incl_y) {\n wuffs_base__rect_ii_u32 ret;\n ret.min_incl_x = min_incl_x;\n ret.min_incl_y = min_incl_y;\n ret.max_incl_x = max_incl_x;\n ret.max_incl_y = max_incl_y;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__rect_ii_u32__is_empty(const wuffs_base__rect_ii_u32* r) {\n return (r->min_incl_x > r->max_incl_x) || (r->min_incl_y > r->max_incl_y);\n}\n\nstatic inline bool //\nwuffs_base__rect_ii_u32__equals(const wuffs_base__rect_ii_u32* r,\n wuffs_base__rect_ii_u32 s) {\n return (r->min_incl_x == s.min_incl_x && r->min_incl_y == s.min_incl_y &&\n r->max_incl_x == s.max_incl_x && r->max_incl_y == s.max_incl_y) ||\n (wuffs_base__rect_ii_u32__is_empty(r) &&\n wuffs_base__rect_ii_u32__is_empty(&s));\n}\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__rect_ii_u32__intersect(const wuffs_base__rect_ii_u32* r,\n wuffs_base__rect_ii_u32 s) {\n wuffs_base__rect_ii_u32" +
" t;\n t.min_incl_x = wuffs_base__u32__max(r->min_incl_x, s.min_incl_x);\n t.min_incl_y = wuffs_base__u32__max(r->min_incl_y, s.min_incl_y);\n t.max_incl_x = wuffs_base__u32__min(r->max_incl_x, s.max_incl_x);\n t.max_incl_y = wuffs_base__u32__min(r->max_incl_y, s.max_incl_y);\n return t;\n}\n\nstatic inline wuffs_base__rect_ii_u32 //\nwuffs_base__rect_ii_u32__unite(const wuffs_base__rect_ii_u32* r,\n wuffs_base__rect_ii_u32 s) {\n if (wuffs_base__rect_ii_u32__is_empty(r)) {\n return s;\n }\n if (wuffs_base__rect_ii_u32__is_empty(&s)) {\n return *r;\n }\n wuffs_base__rect_ii_u32 t;\n t.min_incl_x = wuffs_base__u32__min(r->min_incl_x, s.min_incl_x);\n t.min_incl_y = wuffs_base__u32__min(r->min_incl_y, s.min_incl_y);\n t.max_incl_x = wuffs_base__u32__max(r->max_incl_x, s.max_incl_x);\n t.max_incl_y = wuffs_base__u32__max(r->max_incl_y, s.max_incl_y);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__rect_ii_u32__contains(const wuffs_base__rect_ii_u32* r,\n " +
" uint32_t x,\n uint32_t y) {\n return (r->min_incl_x <= x) && (x <= r->max_incl_x) && (r->min_incl_y <= y) &&\n (y <= r->max_incl_y);\n}\n\nstatic inline bool //\nwuffs_base__rect_ii_u32__contains_rect(const wuffs_base__rect_ii_u32* r,\n wuffs_base__rect_ii_u32 s) {\n return wuffs_base__rect_ii_u32__equals(\n &s, wuffs_base__rect_ii_u32__intersect(r, s));\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__rect_ii_u32::is_empty() const {\n return wuffs_base__rect_ii_u32__is_empty(this);\n}\n\ninline bool //\nwuffs_base__rect_ii_u32::equals(wuffs_base__rect_ii_u32 s) const {\n return wuffs_base__rect_ii_u32__equals(this, s);\n}\n\ninline wuffs_base__rect_ii_u32 //\nwuffs_base__rect_ii_u32::intersect(wuffs_base__rect_ii_u32 s) const {\n return wuffs_base__rect_ii_u32__intersect(this, s);\n}\n\ninline wuffs_base__rect_ii_u32 //\nwuffs_base__rect_ii_u32::unite(wuffs_base__rect_ii_u32 s) const {\n return wuffs_base__rect_ii_u32__unite(this, s);" +
"\n}\n\ninline bool //\nwuffs_base__rect_ii_u32::contains(uint32_t x, uint32_t y) const {\n return wuffs_base__rect_ii_u32__contains(this, x, y);\n}\n\ninline bool //\nwuffs_base__rect_ii_u32::contains_rect(wuffs_base__rect_ii_u32 s) const {\n return wuffs_base__rect_ii_u32__contains_rect(this, s);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef struct wuffs_base__rect_ie_u32__struct {\n uint32_t min_incl_x;\n uint32_t min_incl_y;\n uint32_t max_excl_x;\n uint32_t max_excl_y;\n\n#ifdef __cplusplus\n inline bool is_empty() const;\n inline bool equals(wuffs_base__rect_ie_u32__struct s) const;\n inline wuffs_base__rect_ie_u32__struct intersect(\n wuffs_base__rect_ie_u32__struct s) const;\n inline wuffs_base__rect_ie_u32__struct unite(\n wuffs_base__rect_ie_u32__struct s) const;\n inline bool contains(uint32_t x, uint32_t y) const;\n inline bool contains_rect(wuffs_base__rect_ie_u32__struct s) const;\n inline uint32_t width() const;\n inline uint32_t height() const;\n#endif // __cplusplus\n\n} wuffs_base__rect_ie_u32;\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__empty_rect_ie_u32() {\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 wuffs_base__rect_ie_u32 //\nwuffs_base__make_rect_ie_u32(uint32_t min_incl_x,\n " +
" uint32_t min_incl_y,\n uint32_t max_excl_x,\n uint32_t max_excl_y) {\n wuffs_base__rect_ie_u32 ret;\n ret.min_incl_x = min_incl_x;\n ret.min_incl_y = min_incl_y;\n ret.max_excl_x = max_excl_x;\n ret.max_excl_y = max_excl_y;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__rect_ie_u32__is_empty(const wuffs_base__rect_ie_u32* r) {\n return (r->min_incl_x >= r->max_excl_x) || (r->min_incl_y >= r->max_excl_y);\n}\n\nstatic inline bool //\nwuffs_base__rect_ie_u32__equals(const wuffs_base__rect_ie_u32* r,\n wuffs_base__rect_ie_u32 s) {\n return (r->min_incl_x == s.min_incl_x && r->min_incl_y == s.min_incl_y &&\n r->max_excl_x == s.max_excl_x && r->max_excl_y == s.max_excl_y) ||\n (wuffs_base__rect_ie_u32__is_empty(r) &&\n wuffs_base__rect_ie_u32__is_empty(&s));\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__rect_ie_u32__intersect(const wuffs_base__rect_ie_u32* r,\n " +
" wuffs_base__rect_ie_u32 s) {\n wuffs_base__rect_ie_u32 t;\n t.min_incl_x = wuffs_base__u32__max(r->min_incl_x, s.min_incl_x);\n t.min_incl_y = wuffs_base__u32__max(r->min_incl_y, s.min_incl_y);\n t.max_excl_x = wuffs_base__u32__min(r->max_excl_x, s.max_excl_x);\n t.max_excl_y = wuffs_base__u32__min(r->max_excl_y, s.max_excl_y);\n return t;\n}\n\nstatic inline wuffs_base__rect_ie_u32 //\nwuffs_base__rect_ie_u32__unite(const wuffs_base__rect_ie_u32* r,\n wuffs_base__rect_ie_u32 s) {\n if (wuffs_base__rect_ie_u32__is_empty(r)) {\n return s;\n }\n if (wuffs_base__rect_ie_u32__is_empty(&s)) {\n return *r;\n }\n wuffs_base__rect_ie_u32 t;\n t.min_incl_x = wuffs_base__u32__min(r->min_incl_x, s.min_incl_x);\n t.min_incl_y = wuffs_base__u32__min(r->min_incl_y, s.min_incl_y);\n t.max_excl_x = wuffs_base__u32__max(r->max_excl_x, s.max_excl_x);\n t.max_excl_y = wuffs_base__u32__max(r->max_excl_y, s.max_excl_y);\n return t;\n}\n\nstatic inline bool //\nwuffs_base__rect_ie_u32__con" +
"tains(const wuffs_base__rect_ie_u32* r,\n uint32_t x,\n uint32_t y) {\n return (r->min_incl_x <= x) && (x < r->max_excl_x) && (r->min_incl_y <= y) &&\n (y < r->max_excl_y);\n}\n\nstatic inline bool //\nwuffs_base__rect_ie_u32__contains_rect(const wuffs_base__rect_ie_u32* r,\n wuffs_base__rect_ie_u32 s) {\n return wuffs_base__rect_ie_u32__equals(\n &s, wuffs_base__rect_ie_u32__intersect(r, s));\n}\n\nstatic inline uint32_t //\nwuffs_base__rect_ie_u32__width(const wuffs_base__rect_ie_u32* r) {\n return wuffs_base__u32__sat_sub(r->max_excl_x, r->min_incl_x);\n}\n\nstatic inline uint32_t //\nwuffs_base__rect_ie_u32__height(const wuffs_base__rect_ie_u32* r) {\n return wuffs_base__u32__sat_sub(r->max_excl_y, r->min_incl_y);\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__rect_ie_u32::is_empty() const {\n return wuffs_base__rect_ie_u32__is_empty(this);\n}\n\ninline bool //\nwuffs_base__rect_ie_u32::equals(wuffs_bas" +
"e__rect_ie_u32 s) const {\n return wuffs_base__rect_ie_u32__equals(this, s);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__rect_ie_u32::intersect(wuffs_base__rect_ie_u32 s) const {\n return wuffs_base__rect_ie_u32__intersect(this, s);\n}\n\ninline wuffs_base__rect_ie_u32 //\nwuffs_base__rect_ie_u32::unite(wuffs_base__rect_ie_u32 s) const {\n return wuffs_base__rect_ie_u32__unite(this, s);\n}\n\ninline bool //\nwuffs_base__rect_ie_u32::contains(uint32_t x, uint32_t y) const {\n return wuffs_base__rect_ie_u32__contains(this, x, y);\n}\n\ninline bool //\nwuffs_base__rect_ie_u32::contains_rect(wuffs_base__rect_ie_u32 s) const {\n return wuffs_base__rect_ie_u32__contains_rect(this, s);\n}\n\ninline uint32_t //\nwuffs_base__rect_ie_u32::width() const {\n return wuffs_base__rect_ie_u32__width(this);\n}\n\ninline uint32_t //\nwuffs_base__rect_ie_u32::height() const {\n return wuffs_base__rect_ie_u32__height(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// ---------------- More Information\n\n// wuffs_base__more_information holds additional fields, typically when a Wuffs\n// method returns a [note status](/doc/note/statuses.md).\n//\n// The flavor field follows the base38 namespace\n// convention](/doc/note/base38-and-fourcc.md). The other fields' semantics\n// depends on the flavor.\ntypedef struct {\n uint32_t flavor;\n uint32_t w;\n uint64_t x;\n uint64_t y;\n uint64_t z;\n\n#ifdef __cplusplus\n inline void set(uint32_t flavor_arg,\n uint32_t w_arg,\n uint64_t x_arg,\n uint64_t y_arg,\n uint64_t z_arg);\n inline uint32_t io_redirect__fourcc() const;\n inline wuffs_base__range_ie_u64 io_redirect__range() const;\n inline uint64_t io_seek__position() const;\n inline uint32_t metadata__fourcc() const;\n inline wuffs_base__range_ie_u64 metadata__range() const;\n#endif // __cplusplus\n\n} wuffs_base__more_information;\n\n#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__IO_REDIRECT 1\n#define WUFFS_BASE__MORE_INFORMA" +
"TION__FLAVOR__IO_SEEK 2\n#define WUFFS_BASE__MORE_INFORMATION__FLAVOR__METADATA 3\n\nstatic inline wuffs_base__more_information //\nwuffs_base__empty_more_information() {\n wuffs_base__more_information ret;\n ret.flavor = 0;\n ret.w = 0;\n ret.x = 0;\n ret.y = 0;\n ret.z = 0;\n return ret;\n}\n\nstatic inline void //\nwuffs_base__more_information__set(wuffs_base__more_information* m,\n uint32_t flavor,\n uint32_t w,\n uint64_t x,\n uint64_t y,\n uint64_t z) {\n if (!m) {\n return;\n }\n m->flavor = flavor;\n m->w = w;\n m->x = x;\n m->y = y;\n m->z = z;\n}\n\nstatic inline uint32_t //\nwuffs_base__more_information__io_redirect__fourcc(\n const wuffs_base__more_information* m) {\n return m->w;\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__more_information__io_redirect__range(\n const wuffs_base__more_information* m) {\n wuffs_base__range_ie_u64" +
" ret;\n ret.min_incl = m->y;\n ret.max_excl = m->z;\n return ret;\n}\n\nstatic inline uint64_t //\nwuffs_base__more_information__io_seek__position(\n const wuffs_base__more_information* m) {\n return m->x;\n}\n\nstatic inline uint32_t //\nwuffs_base__more_information__metadata__fourcc(\n const wuffs_base__more_information* m) {\n return m->w;\n}\n\nstatic inline wuffs_base__range_ie_u64 //\nwuffs_base__more_information__metadata__range(\n const wuffs_base__more_information* m) {\n wuffs_base__range_ie_u64 ret;\n ret.min_incl = m->y;\n ret.max_excl = m->z;\n return ret;\n}\n\n#ifdef __cplusplus\n\ninline void //\nwuffs_base__more_information::set(uint32_t flavor_arg,\n uint32_t w_arg,\n uint64_t x_arg,\n uint64_t y_arg,\n uint64_t z_arg) {\n wuffs_base__more_information__set(this, flavor_arg, w_arg, x_arg, y_arg,\n z_arg);\n}\n\ninline uint32_t //\nwuffs_base__m" +
"ore_information::io_redirect__fourcc() const {\n return wuffs_base__more_information__io_redirect__fourcc(this);\n}\n\ninline wuffs_base__range_ie_u64 //\nwuffs_base__more_information::io_redirect__range() const {\n return wuffs_base__more_information__io_redirect__range(this);\n}\n\ninline uint64_t //\nwuffs_base__more_information::io_seek__position() const {\n return wuffs_base__more_information__io_seek__position(this);\n}\n\ninline uint32_t //\nwuffs_base__more_information::metadata__fourcc() const {\n return wuffs_base__more_information__metadata__fourcc(this);\n}\n\ninline wuffs_base__range_ie_u64 //\nwuffs_base__more_information::metadata__range() const {\n return wuffs_base__more_information__metadata__range(this);\n}\n\n#endif // __cplusplus\n" +
""
const baseStrConvPrivateH = "" +
"// ---------------- String Conversions\n\n" +
"" +
"// ---------------- Unicode and UTF-8\n" +
""
const baseStrConvPublicH = "" +
"// ---------------- String Conversions\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 '-'.\nwuffs_base__result_i64 //\nwuffs_base__parse_number_i64(wuffs_base__slice_u8 s);\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 uint64_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 allow unnecessary leading zeroes (\"0\" is valid and its sole\n// zero is necessary). All of \"00\", \"0644\" and \"007\" are invalid.\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// - It does allow arbitrary underscores, except inside the optional 2-byte\n// opening \"0d\" or \"0X\" that denotes base-10 or base-16. For example,\n// \"__0D_1_002\"" +
" would successfully parse as \"one thousand and two\".\nwuffs_base__result_u64 //\nwuffs_base__parse_number_u64(wuffs_base__slice_u8 s);\n\n" +
"" +
"// ---------------- IEEE 754 Floating Point\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 allow whi" +
"tespace, leading or otherwise.\n// - It does not allow unnecessary leading zeroes (\"0\" is valid and its sole\n// zero is necessary). All of \"00\", \"0644\" and \"00.7\" are invalid.\n// - It is not affected by i18n / l10n settings such as environment variables.\n// - Conversely, it always accepts either ',' or '.' as a decimal separator.\n// In particular, \"3,141,592\" is always invalid but \"3,141\" is always valid\n// (and approximately π). The caller is responsible for e.g. previously\n// rejecting or filtering s if it contains a comma, if that is unacceptable\n// to the caller. For example, JSON numbers always use a dot '.' and never a\n// comma ',', regardless of the LOCALE environment variable.\n// - It does allow arbitrary underscores. For example, \"_3.141_592\" would\n// successfully parse, again approximately π.\n// - It does allow \"inf\", \"+Infinity\" and \"-NAN\", case insensitive, but it\n// does not permit \"nan\" to be followed by an integer mantissa.\n// - It does not allow hexadecimal float" +
"ing point numbers.\nwuffs_base__result_f64 //\nwuffs_base__parse_number_f64(wuffs_base__slice_u8 s);\n\n// wuffs_base__ieee_754_bit_representation__etc converts between a double\n// precision numerical value and its IEEE 754 64-bit representation (1 sign\n// bit, 11 exponent bits, 52 explicit significand bits).\n//\n// For example, it converts between:\n// - +1.0 and 0x3FF0_0000_0000_0000.\n// - +5.5 and 0x4016_0000_0000_0000.\n// - -inf and 0xFFF0_0000_0000_0000.\n//\n// See https://en.wikipedia.org/wiki/Double-precision_floating-point_format\n\nstatic inline uint64_t //\nwuffs_base__ieee_754_bit_representation__from_f64(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__to_f64(uint64_t u) {\n double f = 0;\n if (sizeof(uint64_t) == sizeof(double)) {\n memcpy(&f, &u, sizeof(uint64_t));\n }\n return f;\n}\n\n" +
"" +
"// ---------------- Hexadecimal\n\n// wuffs_base__hexadecimal__decode2 converts \"6A6b\" to \"jk\", where e.g. 'j' is\n// U+006A. There are 2 source bytes for every destination byte.\n//\n// It returns the number of dst bytes written: the minimum of dst.len and\n// (src.len / 2). Excess source bytes are ignored.\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.\nsize_t //\nwuffs_base__hexadecimal__decode2(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src);\n\n// wuffs_base__hexadecimal__decode4 converts \"\\\\x6A\\\\x6b\" to \"jk\", where e.g.\n// 'j' is U+006A. There are 4 source bytes for every destination byte.\n//\n// It returns the number of dst bytes written: the minimum of dst.len and\n// (src.len / 4). Excess source bytes are ignored.\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 wri" +
"te nonsense bytes if not,\n// although it will not read or write out of bounds.\nsize_t //\nwuffs_base__hexadecimal__decode4(wuffs_base__slice_u8 dst,\n wuffs_base__slice_u8 src);\n\n" +
"" +
"// ---------------- Unicode and UTF-8\n\n#define WUFFS_BASE__UNICODE_CODE_POINT__MIN_INCL 0x00000000\n#define WUFFS_BASE__UNICODE_CODE_POINT__MAX_INCL 0x0010FFFF\n\n#define WUFFS_BASE__UNICODE_REPLACEMENT_CHARACTER 0x0000FFFD\n\n#define WUFFS_BASE__UNICODE_SURROGATE__MIN_INCL 0x0000D800\n#define WUFFS_BASE__UNICODE_SURROGATE__MAX_INCL 0x0000DFFF\n\n#define WUFFS_BASE__ASCII__MIN_INCL 0x00\n#define WUFFS_BASE__ASCII__MAX_INCL 0x7F\n\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH__MIN_INCL 1\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH__MAX_INCL 4\n\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_1__CODE_POINT__MIN_INCL 0x00000000\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_1__CODE_POINT__MAX_INCL 0x0000007F\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_2__CODE_POINT__MIN_INCL 0x00000080\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_2__CODE_POINT__MAX_INCL 0x000007FF\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_3__CODE_POINT__MIN_INCL 0x00000800\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_3__CODE_POINT__MAX_INCL 0x0000FFFF\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_4__CODE_POINT_" +
"_MIN_INCL 0x00010000\n#define WUFFS_BASE__UTF_8__BYTE_LENGTH_4__CODE_POINT__MAX_INCL 0x0010FFFF\n\n" +
"" +
"// --------\n\n// wuffs_base__utf_8__next__output is the type returned by\n// wuffs_base__utf_8__next.\ntypedef struct {\n uint32_t code_point;\n uint32_t byte_length;\n\n#ifdef __cplusplus\n inline bool is_valid() const;\n#endif // __cplusplus\n\n} wuffs_base__utf_8__next__output;\n\nstatic inline wuffs_base__utf_8__next__output //\nwuffs_base__make_utf_8__next__output(uint32_t code_point,\n uint32_t byte_length) {\n wuffs_base__utf_8__next__output ret;\n ret.code_point = code_point;\n ret.byte_length = byte_length;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__utf_8__next__output__is_valid(\n const wuffs_base__utf_8__next__output* o) {\n if (o) {\n uint32_t cp = o->code_point;\n switch (o->byte_length) {\n case 1:\n return (cp <= 0x7F);\n case 2:\n return (0x080 <= cp) && (cp <= 0x7FF);\n case 3:\n // Avoid the 0xD800 ..= 0xDFFF surrogate range.\n return ((0x0800 <= cp) && (cp <= 0xD7FF)) ||\n ((0xE000 <= cp) && (cp <= 0xF" +
"FFF));\n case 4:\n return (0x00010000 <= cp) && (cp <= 0x0010FFFF);\n }\n }\n return false;\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__utf_8__next__output::is_valid() const {\n return wuffs_base__utf_8__next__output__is_valid(this);\n}\n\n#endif // __cplusplus\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.\nsize_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 s.\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_length=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.\nwuffs_base__utf_8__next__output //\nwuffs_base__utf_8__next(wuffs_base__slice_u8 s);\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.\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 sp" +
"lit on or otherwise manage UTF-8 boundaries.\nsize_t //\nwuffs_base__utf_8__longest_valid_prefix(wuffs_base__slice_u8 s);\n\n// wuffs_base__ascii__longest_valid_prefix returns the largest n such that the\n// sub-slice s[..n] is valid ASCII.\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.\nsize_t //\nwuffs_base__ascii__longest_valid_prefix(wuffs_base__slice_u8 s);\n" +
""
const baseTokenPrivateH = "" +
"// ---------------- Tokens\n\n" +
"" +
"// ---------------- Tokens (Utility)\n" +
""
const baseTokenPublicH = "" +
"// ---------------- Tokens\n\n// wuffs_base__token is an element of a byte stream's tokenization.\n//\n// See https://github.com/google/wuffs/blob/master/doc/note/tokens.md\ntypedef struct {\n uint64_t repr;\n\n#ifdef __cplusplus\n inline int64_t value() const;\n inline int64_t value_extension() const;\n inline int64_t value_major() const;\n inline int64_t value_base_category() const;\n inline uint64_t value_minor() const;\n inline uint64_t value_base_detail() const;\n inline bool continued() const;\n inline uint64_t length() const;\n#endif // __cplusplus\n\n} wuffs_base__token;\n\nstatic inline wuffs_base__token //\nwuffs_base__make_token(uint64_t repr) {\n wuffs_base__token ret;\n ret.repr = repr;\n return ret;\n}\n\n " +
"" +
"// --------\n\n#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF\n\n#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17\n#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17\n#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42\n#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17\n#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38\n#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17\n#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16\n#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0\n\n " +
"" +
"// --------\n\n#define WUFFS_BASE__TOKEN__VBC__FILLER 0\n#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1\n#define WUFFS_BASE__TOKEN__VBC__STRING 2\n#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3\n#define WUFFS_BASE__TOKEN__VBC__LITERAL 4\n#define WUFFS_BASE__TOKEN__VBC__NUMBER 5\n\n " +
"" +
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00001\n#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002\n\n " +
"" +
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000\n#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000\n\n" +
"" +
"// --------\n\n// \"DEFINITELY_FOO\" means that the destination bytes (and also the source\n// bytes, for 1_DST_1_SRC_COPY) are in the FOO format. Definitely means that\n// the lack of the bit is conservative: it is valid for all-ASCII strings to\n// have neither DEFINITELY_UTF_8 or DEFINITELY_ASCII bits set.\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001\n#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00002\n\n// \"CONVERT_D_DST_S_SRC\" means that multiples of S source bytes (possibly\n// padded) 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 mutual" +
"ly exclusive), all producing the\n// same empty dst string.\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00010\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00020\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00040\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00080\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x00100\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x00200\n#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x00400\n\n " +
"" +
"// --------\n\n#define WUFFS_BASE__TOKEN__VBD__LITERAL__UNDEFINED 0x00001\n#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002\n#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004\n#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008\n\n " +
"" +
"// --------\n\n// For a source string of \"123\" or \"0x9A\", it is valid for a tokenizer to\n// return any one 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-endian, li" +
"ttle-endian or text. For binary formats, the\n// token length discriminates 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" +
"" +
"// --------\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 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* t) {\n return (t->repr >> WUFFS_BASE__TOKEN__LENGTH__SHIFT) & 0xFFFF;\n}\n\n#ifdef __cplusplus\n\ninline int64_t //\nwuffs_base__token::value() const {\n return wuffs_base__token__value(this);\n}\n\ninline int64_t //\nwuffs_base__token::value_extension() const {\n return wuffs_base__token__value_extension(this);\n}\n\ninline int64_t //\nwuffs_base__token::value_major() const {\n retu" +
"rn wuffs_base__token__value_major(this);\n}\n\ninline int64_t //\nwuffs_base__token::value_base_category() const {\n return wuffs_base__token__value_base_category(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_minor() const {\n return wuffs_base__token__value_minor(this);\n}\n\ninline uint64_t //\nwuffs_base__token::value_base_detail() const {\n return wuffs_base__token__value_base_detail(this);\n}\n\ninline bool //\nwuffs_base__token::continued() const {\n return wuffs_base__token__continued(this);\n}\n\ninline uint64_t //\nwuffs_base__token::length() const {\n return wuffs_base__token__length(this);\n}\n\n#endif // __cplusplus\n\n" +
"" +
"// --------\n\ntypedef WUFFS_BASE__SLICE(wuffs_base__token) wuffs_base__slice_token;\n\nstatic inline wuffs_base__slice_token //\nwuffs_base__make_slice_token(wuffs_base__token* ptr, size_t len) {\n wuffs_base__slice_token ret;\n ret.ptr = ptr;\n ret.len = len;\n return ret;\n}\n\n" +
"" +
"// --------\n\n// wuffs_base__token_buffer_meta is the metadata for a\n// wuffs_base__token_buffer's data.\ntypedef 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 {\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_available() const;\n inline uint64_t reader_token_position() const;\n inline uint64_t writer_available() const;\n inline uint64_t writer_token_position() const;\n#endif // __cplusplus\n\n} wuffs_base__token_buffer;\n\nstatic inline wuffs_base__token_buffer //\nwuffs_base__make" +
"_token_buffer(wuffs_base__slice_token data,\n wuffs_base__token_buffer_meta meta) {\n wuffs_base__token_buffer ret;\n ret.data = data;\n ret.meta = meta;\n return ret;\n}\n\nstatic inline wuffs_base__token_buffer_meta //\nwuffs_base__make_token_buffer_meta(size_t wi,\n size_t ri,\n uint64_t pos,\n bool closed) {\n wuffs_base__token_buffer_meta ret;\n ret.wi = wi;\n ret.ri = ri;\n ret.pos = pos;\n ret.closed = closed;\n return ret;\n}\n\nstatic inline wuffs_base__token_buffer //\nwuffs_base__slice_token__reader(wuffs_base__slice_token s, bool closed) {\n wuffs_base__token_buffer ret;\n ret.data.ptr = s.ptr;\n ret.data.len = s.len;\n ret.meta.wi = s.len;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = closed;\n return ret;\n}\n\nstatic inline wuffs_base__token_buffer //\nwuffs_base__slice_token__writer(wuffs_base__slice_token s) {\n wuffs_base__token_buffer ret;\n ret.data.ptr = s.ptr" +
";\n ret.data.len = s.len;\n ret.meta.wi = 0;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__token_buffer //\nwuffs_base__empty_token_buffer() {\n wuffs_base__token_buffer ret;\n ret.data.ptr = NULL;\n ret.data.len = 0;\n ret.meta.wi = 0;\n ret.meta.ri = 0;\n ret.meta.pos = 0;\n ret.meta.closed = false;\n return ret;\n}\n\nstatic inline wuffs_base__token_buffer_meta //\nwuffs_base__empty_token_buffer_meta() {\n wuffs_base__token_buffer_meta ret;\n ret.wi = 0;\n ret.ri = 0;\n ret.pos = 0;\n ret.closed = false;\n return ret;\n}\n\nstatic inline bool //\nwuffs_base__token_buffer__is_valid(const wuffs_base__token_buffer* buf) {\n if (buf) {\n if (buf->data.ptr) {\n return (buf->meta.ri <= buf->meta.wi) && (buf->meta.wi <= buf->data.len);\n } else {\n return (buf->meta.ri == 0) && (buf->meta.wi == 0) && (buf->data.len == 0);\n }\n }\n return false;\n}\n\n// wuffs_base__token_buffer__compact moves any written but unread tokens to the\n// start of the " +
"buffer.\nstatic inline void //\nwuffs_base__token_buffer__compact(wuffs_base__token_buffer* buf) {\n if (!buf || (buf->meta.ri == 0)) {\n return;\n }\n buf->meta.pos = wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri);\n size_t n = buf->meta.wi - buf->meta.ri;\n if (n != 0) {\n memmove(buf->data.ptr, buf->data.ptr + buf->meta.ri,\n n * sizeof(wuffs_base__token));\n }\n buf->meta.wi = n;\n buf->meta.ri = 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__token_buffer__reader_available(\n const wuffs_base__token_buffer* buf) {\n return buf ? buf->meta.wi - buf->meta.ri : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__token_buffer__reader_token_position(\n const wuffs_base__token_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.ri) : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__token_buffer__writer_available(\n const wuffs_base__token_buffer* buf) {\n return buf ? buf->data.len - buf->meta.wi : 0;\n}\n\nstatic inline uint64_t //\nwuffs_base__token_buffer__writer_token_p" +
"osition(\n const wuffs_base__token_buffer* buf) {\n return buf ? wuffs_base__u64__sat_add(buf->meta.pos, buf->meta.wi) : 0;\n}\n\n#ifdef __cplusplus\n\ninline bool //\nwuffs_base__token_buffer::is_valid() const {\n return wuffs_base__token_buffer__is_valid(this);\n}\n\ninline void //\nwuffs_base__token_buffer::compact() {\n wuffs_base__token_buffer__compact(this);\n}\n\ninline uint64_t //\nwuffs_base__token_buffer::reader_available() const {\n return wuffs_base__token_buffer__reader_available(this);\n}\n\ninline uint64_t //\nwuffs_base__token_buffer::reader_token_position() const {\n return wuffs_base__token_buffer__reader_token_position(this);\n}\n\ninline uint64_t //\nwuffs_base__token_buffer::writer_available() const {\n return wuffs_base__token_buffer__writer_available(this);\n}\n\ninline uint64_t //\nwuffs_base__token_buffer::writer_token_position() const {\n return wuffs_base__token_buffer__writer_token_position(this);\n}\n\n#endif // __cplusplus\n" +
""
const baseCopyright = "" +
"// 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\n" +
""