modernc.org/z@v1.7.4/internal/example_windows_amd64.go (about)

     1  // Code generated by 'ccgo -lmodernc.org/z/lib -o internal\example_windows_amd64.go -trace-translation-units C:\Users\0xjnml\go\src\modernc.org\z\tmp\cdb.json example.exe', DO NOT EDIT.
     2  
     3  package main
     4  
     5  import (
     6  	"math"
     7  	"reflect"
     8  	"sync/atomic"
     9  	"unsafe"
    10  
    11  	"modernc.org/libc"
    12  	"modernc.org/libc/sys/types"
    13  	"modernc.org/z/lib"
    14  )
    15  
    16  var _ = math.Pi
    17  var _ reflect.Kind
    18  var _ atomic.Value
    19  var _ unsafe.Pointer
    20  var _ types.Size_t
    21  
    22  func main() { libc.Start(main1) }
    23  
    24  type ptrdiff_t = int64 /* <builtin>:3:26 */
    25  
    26  type size_t = uint64 /* <builtin>:9:23 */
    27  
    28  type wchar_t = uint16 /* <builtin>:15:24 */
    29  
    30  type va_list = uintptr /* <builtin>:50:27 */
    31  
    32  type ssize_t = int64 /* crtdefs.h:45:35 */
    33  
    34  type rsize_t = size_t /* crtdefs.h:52:16 */
    35  
    36  type intptr_t = int64 /* crtdefs.h:62:35 */
    37  
    38  type uintptr_t = uint64 /* crtdefs.h:75:44 */
    39  
    40  type wint_t = uint16   /* crtdefs.h:106:24 */
    41  type wctype_t = uint16 /* crtdefs.h:107:24 */
    42  
    43  type errno_t = int32 /* crtdefs.h:113:13 */
    44  
    45  type time_t = int64 /* crtdefs.h:138:20 */
    46  
    47  type threadlocaleinfostruct = struct {
    48  	refcount      int32
    49  	lc_codepage   uint32
    50  	lc_collate_cp uint32
    51  	lc_handle     [6]uint32
    52  	lc_id         [6]LC_ID
    53  	lc_category   [6]struct {
    54  		locale    uintptr
    55  		wlocale   uintptr
    56  		refcount  uintptr
    57  		wrefcount uintptr
    58  	}
    59  	lc_clike            int32
    60  	mb_cur_max          int32
    61  	lconv_intl_refcount uintptr
    62  	lconv_num_refcount  uintptr
    63  	lconv_mon_refcount  uintptr
    64  	lconv               uintptr
    65  	ctype1_refcount     uintptr
    66  	ctype1              uintptr
    67  	pctype              uintptr
    68  	pclmap              uintptr
    69  	pcumap              uintptr
    70  	lc_time_curr        uintptr
    71  } /* crtdefs.h:422:1 */
    72  
    73  type pthreadlocinfo = uintptr /* crtdefs.h:424:39 */
    74  type pthreadmbcinfo = uintptr /* crtdefs.h:425:36 */
    75  
    76  type localeinfo_struct = struct {
    77  	locinfo pthreadlocinfo
    78  	mbcinfo pthreadmbcinfo
    79  } /* crtdefs.h:428:9 */
    80  
    81  type _locale_tstruct = localeinfo_struct /* crtdefs.h:431:3 */
    82  type _locale_t = uintptr                 /* crtdefs.h:431:19 */
    83  
    84  type tagLC_ID = struct {
    85  	wLanguage uint16
    86  	wCountry  uint16
    87  	wCodePage uint16
    88  } /* crtdefs.h:422:1 */
    89  
    90  type LC_ID = tagLC_ID  /* crtdefs.h:439:3 */
    91  type LPLC_ID = uintptr /* crtdefs.h:439:9 */
    92  
    93  type threadlocinfo = threadlocaleinfostruct /* crtdefs.h:468:3 */
    94  
    95  // ISO C Standard:  7.17  Common definitions  <stddef.h>
    96  
    97  // Any one of these symbols __need_* means that GNU libc
    98  //    wants us just to define one data type.  So don't define
    99  //    the symbols that indicate this file's entire job has been done.
   100  // snaroff@next.com says the NeXT needs this.
   101  // Irix 5.1 needs this.
   102  
   103  // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
   104  //    defined if the corresponding type is *not* defined.
   105  //    FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_
   106  
   107  // Sequent's header files use _PTRDIFF_T_ in some conflicting way.
   108  //    Just ignore it.
   109  
   110  // On VxWorks, <type/vxTypesBase.h> may have defined macros like
   111  //    _TYPE_size_t which will typedef size_t.  fixincludes patched the
   112  //    vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
   113  //    not defined, and so that defining this macro defines _GCC_SIZE_T.
   114  //    If we find that the macros are still defined at this point, we must
   115  //    invoke them so that the type is defined as expected.
   116  
   117  // In case nobody has defined these types, but we aren't running under
   118  //    GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
   119  //    __WCHAR_TYPE__ have reasonable values.  This can happen if the
   120  //    parts of GCC is compiled by an older compiler, that actually
   121  //    include gstddef.h, such as collect2.
   122  
   123  // Signed type of difference of two pointers.
   124  
   125  // Define this type if we are doing the whole job,
   126  //    or if we want this type in particular.
   127  
   128  // If this symbol has done its job, get rid of it.
   129  
   130  // Unsigned type of `sizeof' something.
   131  
   132  // Define this type if we are doing the whole job,
   133  //    or if we want this type in particular.
   134  
   135  // Wide character type.
   136  //    Locale-writers should change this as necessary to
   137  //    be big enough to hold unique values not between 0 and 127,
   138  //    and not (wchar_t) -1, for each defined multibyte character.
   139  
   140  // Define this type if we are doing the whole job,
   141  //    or if we want this type in particular.
   142  
   143  //  In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
   144  //     are already defined.
   145  //  BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.
   146  
   147  // A null pointer constant.
   148  
   149  // Offset of member MEMBER in a struct of type TYPE.
   150  
   151  // Type whose alignment is supported in every context and is at least
   152  //    as great as that of any standard type not using alignment
   153  //    specifiers.
   154  type max_align_t = struct {
   155  	__max_align_ll int64
   156  	__max_align_ld float64
   157  } /* stddef.h:426:3 */
   158  
   159  // Copyright (C) 1989-2018 Free Software Foundation, Inc.
   160  //
   161  // This file is part of GCC.
   162  //
   163  // GCC is free software; you can redistribute it and/or modify
   164  // it under the terms of the GNU General Public License as published by
   165  // the Free Software Foundation; either version 3, or (at your option)
   166  // any later version.
   167  //
   168  // GCC is distributed in the hope that it will be useful,
   169  // but WITHOUT ANY WARRANTY; without even the implied warranty of
   170  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   171  // GNU General Public License for more details.
   172  //
   173  // Under Section 7 of GPL version 3, you are granted additional
   174  // permissions described in the GCC Runtime Library Exception, version
   175  // 3.1, as published by the Free Software Foundation.
   176  //
   177  // You should have received a copy of the GNU General Public License and
   178  // a copy of the GCC Runtime Library Exception along with this program;
   179  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   180  // <http://www.gnu.org/licenses/>.
   181  
   182  // ISO C Standard:  7.17  Common definitions  <stddef.h>
   183  type z_size_t = size_t /* zconf.h:248:21 */
   184  
   185  // Maximum value for memLevel in deflateInit2
   186  
   187  // Maximum value for windowBits in deflateInit2 and inflateInit2.
   188  // WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
   189  // created by gzip. (Files created by minigzip can still be extracted by
   190  // gzip.)
   191  
   192  // The memory requirements for deflate are (in bytes):
   193  //             (1 << (windowBits+2)) +  (1 << (memLevel+9))
   194  //  that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
   195  //  plus a few kilobytes for small objects. For example, if you want to reduce
   196  //  the default memory requirements from 256K to 128K, compile with
   197  //      make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
   198  //  Of course this will generally degrade compression (there's no free lunch).
   199  //
   200  //    The memory requirements for inflate are (in bytes) 1 << windowBits
   201  //  that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
   202  //  for small objects.
   203  
   204  // Type declarations
   205  
   206  // The following definitions for FAR are needed only for MSDOS mixed
   207  // model programming (small or medium model with some far allocations).
   208  // This was tested only with MSC; for other MSDOS compilers you may have
   209  // to define NO_MEMCPY in zutil.h.  If you don't need the mixed model,
   210  // just define FAR to be empty.
   211  
   212  // If building or using zlib as a DLL, define ZLIB_DLL.
   213  // This is not mandatory, but it offers a little performance increase.
   214  // If building or using zlib with the WINAPI/WINAPIV calling convention,
   215  // define ZLIB_WINAPI.
   216  // Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
   217  
   218  type Byte = uint8   /* zconf.h:391:24 */ // 8 bits
   219  type uInt = uint32  /* zconf.h:393:24 */ // 16 bits or more
   220  type uLong = uint32 /* zconf.h:394:24 */ // 32 bits or more
   221  
   222  type Bytef = Byte   /* zconf.h:400:22 */
   223  type charf = int8   /* zconf.h:402:19 */
   224  type intf = int32   /* zconf.h:403:19 */
   225  type uIntf = uInt   /* zconf.h:404:19 */
   226  type uLongf = uLong /* zconf.h:405:19 */
   227  
   228  type voidpc = uintptr /* zconf.h:408:23 */
   229  type voidpf = uintptr /* zconf.h:409:23 */
   230  type voidp = uintptr  /* zconf.h:410:23 */
   231  
   232  // Copyright (C) 1992-2018 Free Software Foundation, Inc.
   233  //
   234  // This file is part of GCC.
   235  //
   236  // GCC is free software; you can redistribute it and/or modify it under
   237  // the terms of the GNU General Public License as published by the Free
   238  // Software Foundation; either version 3, or (at your option) any later
   239  // version.
   240  //
   241  // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   242  // WARRANTY; without even the implied warranty of MERCHANTABILITY or
   243  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   244  // for more details.
   245  //
   246  // Under Section 7 of GPL version 3, you are granted additional
   247  // permissions described in the GCC Runtime Library Exception, version
   248  // 3.1, as published by the Free Software Foundation.
   249  //
   250  // You should have received a copy of the GNU General Public License and
   251  // a copy of the GCC Runtime Library Exception along with this program;
   252  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   253  // <http://www.gnu.org/licenses/>.
   254  
   255  // This administrivia gets added to the beginning of limits.h
   256  //    if the system has its own version of limits.h.
   257  
   258  // We use _GCC_LIMITS_H_ because we want this not to match
   259  //    any macros that the system's limits.h uses for its own purposes.
   260  
   261  // Use "..." so that we find syslimits.h only in this same directory.
   262  // syslimits.h stands for the system's own limits.h file.
   263  //    If we can use it ok unmodified, then we install this text.
   264  //    If fixincludes fixes it, then the fixed version is installed
   265  //    instead of this text.
   266  
   267  // *
   268  // This file has no copyright assigned and is placed in the Public Domain.
   269  // This file is part of the mingw-w64 runtime package.
   270  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   271  // *
   272  // This file has no copyright assigned and is placed in the Public Domain.
   273  // This file is part of the mingw-w64 runtime package.
   274  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   275  
   276  // File system limits
   277  //
   278  // NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
   279  //       required for the NUL. TODO: Test?
   280  // NOTE: PATH_MAX is the POSIX equivalent for Microsoft's MAX_PATH; the two
   281  //       are semantically identical, with a limit of 259 characters for the
   282  //       path name, plus one for a terminating NUL, for a total of 260.
   283  
   284  // Copyright (C) 1991-2018 Free Software Foundation, Inc.
   285  //
   286  // This file is part of GCC.
   287  //
   288  // GCC is free software; you can redistribute it and/or modify it under
   289  // the terms of the GNU General Public License as published by the Free
   290  // Software Foundation; either version 3, or (at your option) any later
   291  // version.
   292  //
   293  // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   294  // WARRANTY; without even the implied warranty of MERCHANTABILITY or
   295  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   296  // for more details.
   297  //
   298  // Under Section 7 of GPL version 3, you are granted additional
   299  // permissions described in the GCC Runtime Library Exception, version
   300  // 3.1, as published by the Free Software Foundation.
   301  //
   302  // You should have received a copy of the GNU General Public License and
   303  // a copy of the GCC Runtime Library Exception along with this program;
   304  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   305  // <http://www.gnu.org/licenses/>.
   306  
   307  // Number of bits in a `char'.
   308  
   309  // Maximum length of a multibyte character.
   310  
   311  // Minimum and maximum values a `signed char' can hold.
   312  
   313  // Maximum value an `unsigned char' can hold.  (Minimum is 0).
   314  
   315  // Minimum and maximum values a `char' can hold.
   316  
   317  // Minimum and maximum values a `signed short int' can hold.
   318  
   319  // Maximum value an `unsigned short int' can hold.  (Minimum is 0).
   320  
   321  // Minimum and maximum values a `signed int' can hold.
   322  
   323  // Maximum value an `unsigned int' can hold.  (Minimum is 0).
   324  
   325  // Minimum and maximum values a `signed long int' can hold.
   326  //    (Same as `int').
   327  
   328  // Maximum value an `unsigned long int' can hold.  (Minimum is 0).
   329  
   330  // Minimum and maximum values a `signed long long int' can hold.
   331  
   332  // Maximum value an `unsigned long long int' can hold.  (Minimum is 0).
   333  
   334  // Minimum and maximum values a `signed long long int' can hold.
   335  
   336  // Maximum value an `unsigned long long int' can hold.  (Minimum is 0).
   337  
   338  // This administrivia gets added to the end of limits.h
   339  //    if the system has its own version of limits.h.
   340  
   341  type z_crc_t = uint32 /* zconf.h:429:17 */
   342  
   343  // *
   344  // This file has no copyright assigned and is placed in the Public Domain.
   345  // This file is part of the mingw-w64 runtime package.
   346  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   347  
   348  // *
   349  // This file has no copyright assigned and is placed in the Public Domain.
   350  // This file is part of the mingw-w64 runtime package.
   351  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   352  
   353  type _ino_t = uint16 /* types.h:43:24 */
   354  type ino_t = uint16  /* types.h:45:24 */
   355  
   356  type _dev_t = uint32 /* types.h:51:22 */
   357  type dev_t = uint32  /* types.h:53:22 */
   358  
   359  type _pid_t = int64 /* types.h:63:17 */
   360  
   361  type pid_t = _pid_t /* types.h:68:16 */
   362  
   363  type _mode_t = uint16 /* types.h:74:24 */
   364  
   365  type mode_t = _mode_t /* types.h:77:17 */
   366  
   367  type _off_t = int32  /* _mingw_off_t.h:5:16 */
   368  type off32_t = int32 /* _mingw_off_t.h:7:16 */
   369  
   370  type _off64_t = int64 /* _mingw_off_t.h:13:39 */
   371  type off64_t = int64  /* _mingw_off_t.h:15:39 */
   372  
   373  type off_t = off64_t /* _mingw_off_t.h:24:17 */
   374  
   375  type useconds_t = uint32 /* types.h:84:22 */
   376  
   377  type timespec = struct {
   378  	tv_sec  time_t
   379  	tv_nsec int32
   380  	_       [4]byte
   381  } /* types.h:89:1 */
   382  
   383  type itimerspec = struct {
   384  	it_interval struct {
   385  		tv_sec  time_t
   386  		tv_nsec int32
   387  		_       [4]byte
   388  	}
   389  	it_value struct {
   390  		tv_sec  time_t
   391  		tv_nsec int32
   392  		_       [4]byte
   393  	}
   394  } /* types.h:94:1 */
   395  
   396  type _sigset_t = uint64 /* types.h:104:28 */
   397  
   398  // Copyright (C) 1989, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
   399  //
   400  // This file is part of GCC.
   401  //
   402  // GCC is free software; you can redistribute it and/or modify
   403  // it under the terms of the GNU General Public License as published by
   404  // the Free Software Foundation; either version 2, or (at your option)
   405  // any later version.
   406  //
   407  // GCC is distributed in the hope that it will be useful,
   408  // but WITHOUT ANY WARRANTY; without even the implied warranty of
   409  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   410  // GNU General Public License for more details.
   411  //
   412  // You should have received a copy of the GNU General Public License
   413  // along with GCC; see the file COPYING.  If not, write to
   414  // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
   415  // Boston, MA 02110-1301, USA.
   416  
   417  // As a special exception, if you include this header file into source
   418  //    files compiled by GCC, this header file does not by itself cause
   419  //    the resulting executable to be covered by the GNU General Public
   420  //    License.  This exception does not however invalidate any other
   421  //    reasons why the executable file might be covered by the GNU General
   422  //    Public License.
   423  
   424  // ISO C Standard:  7.15  Variable arguments  <stdarg.h>
   425  
   426  // Define __gnuc_va_list.
   427  
   428  // Define the standard macros for the user,
   429  //    if this invocation was from the user program.
   430  
   431  // Define va_list, if desired, from __gnuc_va_list.
   432  // We deliberately do not define va_list when called from
   433  //    stdio.h, because ANSI C says that stdio.h is not supposed to define
   434  //    va_list.  stdio.h needs to have access to that data type,
   435  //    but must not use that name.  It should use the name __gnuc_va_list,
   436  //    which is safe because it is reserved for the implementation.
   437  
   438  // The macro _VA_LIST_ is the same thing used by this file in Ultrix.
   439  //    But on BSD NET2 we must not test or define or undef it.
   440  //    (Note that the comments in NET 2's ansi.h
   441  //    are incorrect for _VA_LIST_--see stdio.h!)
   442  // The macro _VA_LIST_DEFINED is used in Windows NT 3.5
   443  
   444  // include mingw stuff
   445  // *
   446  // This file has no copyright assigned and is placed in the Public Domain.
   447  // This file is part of the mingw-w64 runtime package.
   448  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   449  
   450  // *
   451  // This file has no copyright assigned and is placed in the Public Domain.
   452  // This file is part of the mingw-w64 runtime package.
   453  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   454  
   455  // Copyright (C) 1989-2018 Free Software Foundation, Inc.
   456  //
   457  // This file is part of GCC.
   458  //
   459  // GCC is free software; you can redistribute it and/or modify
   460  // it under the terms of the GNU General Public License as published by
   461  // the Free Software Foundation; either version 3, or (at your option)
   462  // any later version.
   463  //
   464  // GCC is distributed in the hope that it will be useful,
   465  // but WITHOUT ANY WARRANTY; without even the implied warranty of
   466  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   467  // GNU General Public License for more details.
   468  //
   469  // Under Section 7 of GPL version 3, you are granted additional
   470  // permissions described in the GCC Runtime Library Exception, version
   471  // 3.1, as published by the Free Software Foundation.
   472  //
   473  // You should have received a copy of the GNU General Public License and
   474  // a copy of the GCC Runtime Library Exception along with this program;
   475  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   476  // <http://www.gnu.org/licenses/>.
   477  
   478  // ISO C Standard:  7.15  Variable arguments  <stdarg.h>
   479  
   480  // *
   481  // This file has no copyright assigned and is placed in the Public Domain.
   482  // This file is part of the mingw-w64 runtime package.
   483  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   484  
   485  // *
   486  // This file has no copyright assigned and is placed in the Public Domain.
   487  // This file is part of the mingw-w64 runtime package.
   488  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   489  
   490  // ISO C Standard:  7.17  Common definitions  <stddef.h>
   491  
   492  // Copyright (C) 1989-2018 Free Software Foundation, Inc.
   493  //
   494  // This file is part of GCC.
   495  //
   496  // GCC is free software; you can redistribute it and/or modify
   497  // it under the terms of the GNU General Public License as published by
   498  // the Free Software Foundation; either version 3, or (at your option)
   499  // any later version.
   500  //
   501  // GCC is distributed in the hope that it will be useful,
   502  // but WITHOUT ANY WARRANTY; without even the implied warranty of
   503  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   504  // GNU General Public License for more details.
   505  //
   506  // Under Section 7 of GPL version 3, you are granted additional
   507  // permissions described in the GCC Runtime Library Exception, version
   508  // 3.1, as published by the Free Software Foundation.
   509  //
   510  // You should have received a copy of the GNU General Public License and
   511  // a copy of the GCC Runtime Library Exception along with this program;
   512  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   513  // <http://www.gnu.org/licenses/>.
   514  
   515  // ISO C Standard:  7.17  Common definitions  <stddef.h>
   516  
   517  // a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
   518  // "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
   519  // though the former does not conform to the LFS document), but considering
   520  // both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
   521  // equivalently requesting no 64-bit operations
   522  
   523  // MVS linker does not support external names larger than 8 bytes
   524  
   525  //
   526  //     The 'zlib' compression library provides in-memory compression and
   527  //   decompression functions, including integrity checks of the uncompressed data.
   528  //   This version of the library supports only one compression method (deflation)
   529  //   but other algorithms will be added later and will have the same stream
   530  //   interface.
   531  //
   532  //     Compression can be done in a single step if the buffers are large enough,
   533  //   or can be done by repeated calls of the compression function.  In the latter
   534  //   case, the application must provide more input and/or consume the output
   535  //   (providing more output space) before each call.
   536  //
   537  //     The compressed data format used by default by the in-memory functions is
   538  //   the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
   539  //   around a deflate stream, which is itself documented in RFC 1951.
   540  //
   541  //     The library also supports reading and writing files in gzip (.gz) format
   542  //   with an interface similar to that of stdio using the functions that start
   543  //   with "gz".  The gzip format is different from the zlib format.  gzip is a
   544  //   gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
   545  //
   546  //     This library can optionally read and write gzip and raw deflate streams in
   547  //   memory as well.
   548  //
   549  //     The zlib format was designed to be compact and fast for use in memory
   550  //   and on communications channels.  The gzip format was designed for single-
   551  //   file compression on file systems, has a larger header than zlib to maintain
   552  //   directory information, and uses a different, slower check method than zlib.
   553  //
   554  //     The library does not install any signal handler.  The decoder checks
   555  //   the consistency of the compressed data, so the library should never crash
   556  //   even in the case of corrupted input.
   557  
   558  type alloc_func = uintptr /* zlib.h:81:16 */
   559  type free_func = uintptr  /* zlib.h:82:16 */
   560  
   561  type z_stream_s = struct {
   562  	next_in   uintptr
   563  	avail_in  uInt
   564  	total_in  uLong
   565  	next_out  uintptr
   566  	avail_out uInt
   567  	total_out uLong
   568  	msg       uintptr
   569  	state     uintptr
   570  	zalloc    alloc_func
   571  	zfree     free_func
   572  	opaque    voidpf
   573  	data_type int32
   574  	adler     uLong
   575  	reserved  uLong
   576  	_         [4]byte
   577  } /* zlib.h:86:9 */
   578  
   579  type z_stream = z_stream_s /* zlib.h:106:3 */
   580  
   581  type z_streamp = uintptr /* zlib.h:108:22 */
   582  
   583  //
   584  //      gzip header information passed to and from zlib routines.  See RFC 1952
   585  //   for more details on the meanings of these fields.
   586  type gz_header_s = struct {
   587  	text      int32
   588  	time      uLong
   589  	xflags    int32
   590  	os        int32
   591  	extra     uintptr
   592  	extra_len uInt
   593  	extra_max uInt
   594  	name      uintptr
   595  	name_max  uInt
   596  	_         [4]byte
   597  	comment   uintptr
   598  	comm_max  uInt
   599  	hcrc      int32
   600  	done      int32
   601  	_         [4]byte
   602  } /* zlib.h:114:9 */
   603  
   604  //
   605  //      gzip header information passed to and from zlib routines.  See RFC 1952
   606  //   for more details on the meanings of these fields.
   607  type gz_header = gz_header_s /* zlib.h:129:3 */
   608  
   609  type gz_headerp = uintptr /* zlib.h:131:23 */
   610  //
   611  //      inflateGetHeader() requests that gzip header information be stored in the
   612  //    provided gz_header structure.  inflateGetHeader() may be called after
   613  //    inflateInit2() or inflateReset(), and before the first call of inflate().
   614  //    As inflate() processes the gzip stream, head->done is zero until the header
   615  //    is completed, at which time head->done is set to one.  If a zlib stream is
   616  //    being decoded, then head->done is set to -1 to indicate that there will be
   617  //    no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
   618  //    used to force inflate() to return immediately after header processing is
   619  //    complete and before any actual data is decompressed.
   620  //
   621  //      The text, time, xflags, and os fields are filled in with the gzip header
   622  //    contents.  hcrc is set to true if there is a header CRC.  (The header CRC
   623  //    was valid if done is set to one.) If extra is not Z_NULL, then extra_max
   624  //    contains the maximum number of bytes to write to extra.  Once done is true,
   625  //    extra_len contains the actual extra field length, and extra contains the
   626  //    extra field, or that field truncated if extra_max is less than extra_len.
   627  //    If name is not Z_NULL, then up to name_max characters are written there,
   628  //    terminated with a zero unless the length is greater than name_max.  If
   629  //    comment is not Z_NULL, then up to comm_max characters are written there,
   630  //    terminated with a zero unless the length is greater than comm_max.  When any
   631  //    of extra, name, or comment are not Z_NULL and the respective field is not
   632  //    present in the header, then that field is set to Z_NULL to signal its
   633  //    absence.  This allows the use of deflateSetHeader() with the returned
   634  //    structure to duplicate the header.  However if those fields are set to
   635  //    allocated memory, then the application will need to save those pointers
   636  //    elsewhere so that they can be eventually freed.
   637  //
   638  //      If inflateGetHeader is not used, then the header information is simply
   639  //    discarded.  The header is always checked for validity, including the header
   640  //    CRC if present.  inflateReset() will reset the process to discard the header
   641  //    information.  The application would need to call inflateGetHeader() again to
   642  //    retrieve the header from the next gzip stream.
   643  //
   644  //      inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
   645  //    stream state was inconsistent.
   646  
   647  //
   648  // ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
   649  //                                         unsigned char FAR *window));
   650  //
   651  //      Initialize the internal stream state for decompression using inflateBack()
   652  //    calls.  The fields zalloc, zfree and opaque in strm must be initialized
   653  //    before the call.  If zalloc and zfree are Z_NULL, then the default library-
   654  //    derived memory allocation routines are used.  windowBits is the base two
   655  //    logarithm of the window size, in the range 8..15.  window is a caller
   656  //    supplied buffer of that size.  Except for special applications where it is
   657  //    assured that deflate was used with small window sizes, windowBits must be 15
   658  //    and a 32K byte window must be supplied to be able to decompress general
   659  //    deflate streams.
   660  //
   661  //      See inflateBack() for the usage of these routines.
   662  //
   663  //      inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
   664  //    the parameters are invalid, Z_MEM_ERROR if the internal state could not be
   665  //    allocated, or Z_VERSION_ERROR if the version of the library does not match
   666  //    the version of the header file.
   667  
   668  type in_func = uintptr  /* zlib.h:1092:18 */
   669  type out_func = uintptr /* zlib.h:1094:13 */
   670  //
   671  //      Same as uncompress, except that sourceLen is a pointer, where the
   672  //    length of the source is *sourceLen.  On return, *sourceLen is the number of
   673  //    source bytes consumed.
   674  
   675  // gzip file access functions
   676  
   677  //
   678  //      This library supports reading and writing files in gzip (.gz) format with
   679  //    an interface similar to that of stdio, using the functions that start with
   680  //    "gz".  The gzip format is different from the zlib format.  gzip is a gzip
   681  //    wrapper, documented in RFC 1952, wrapped around a deflate stream.
   682  
   683  type gzFile_s = struct {
   684  	have uint32
   685  	_    [4]byte
   686  	next uintptr
   687  	pos  int32
   688  	_    [4]byte
   689  } /* zlib.h:1300:9 */
   690  
   691  //
   692  //      Same as uncompress, except that sourceLen is a pointer, where the
   693  //    length of the source is *sourceLen.  On return, *sourceLen is the number of
   694  //    source bytes consumed.
   695  
   696  // gzip file access functions
   697  
   698  //
   699  //      This library supports reading and writing files in gzip (.gz) format with
   700  //    an interface similar to that of stdio, using the functions that start with
   701  //    "gz".  The gzip format is different from the zlib format.  gzip is a gzip
   702  //    wrapper, documented in RFC 1952, wrapped around a deflate stream.
   703  
   704  type gzFile = uintptr /* zlib.h:1300:25 */
   705  
   706  // *
   707  // This file has no copyright assigned and is placed in the Public Domain.
   708  // This file is part of the mingw-w64 runtime package.
   709  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   710  
   711  // *
   712  // This file has no copyright assigned and is placed in the Public Domain.
   713  // This file is part of the mingw-w64 runtime package.
   714  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   715  
   716  // *
   717  // This file has no copyright assigned and is placed in the Public Domain.
   718  // This file is part of the mingw-w64 runtime package.
   719  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   720  
   721  // Undefine __mingw_<printf> macros.
   722  
   723  type _iobuf = struct {
   724  	_ptr      uintptr
   725  	_cnt      int32
   726  	_         [4]byte
   727  	_base     uintptr
   728  	_flag     int32
   729  	_file     int32
   730  	_charbuf  int32
   731  	_bufsiz   int32
   732  	_tmpfname uintptr
   733  } /* stdio.h:26:3 */
   734  
   735  type FILE = _iobuf /* stdio.h:36:25 */
   736  
   737  type fpos_t = int64 /* stdio.h:104:37 */
   738  
   739  func vsnwprintf(tls *libc.TLS, s uintptr, n size_t, format uintptr, arg va_list) int32 { /* stdio.h:1209:15: */
   740  	return libc.X_vsnwprintf(tls, s, n, format, arg)
   741  
   742  }
   743  
   744  // *
   745  // This file has no copyright assigned and is placed in the Public Domain.
   746  // This file is part of the mingw-w64 runtime package.
   747  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   748  
   749  // *
   750  // This file has no copyright assigned and is placed in the Public Domain.
   751  // This file is part of the mingw-w64 runtime package.
   752  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   753  
   754  func vswprintf(tls *libc.TLS, __stream uintptr, __count size_t, __format uintptr, __local_argv uintptr) int32 { /* swprintf.inl:27:5: */
   755  	return vsnwprintf(tls, __stream, __count, __format, __local_argv)
   756  }
   757  
   758  // *
   759  // This file has no copyright assigned and is placed in the Public Domain.
   760  // This file is part of the mingw-w64 runtime package.
   761  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   762  
   763  // *
   764  // This file has no copyright assigned and is placed in the Public Domain.
   765  // This file is part of the mingw-w64 runtime package.
   766  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   767  
   768  // Copyright (C) 1992-2018 Free Software Foundation, Inc.
   769  //
   770  // This file is part of GCC.
   771  //
   772  // GCC is free software; you can redistribute it and/or modify it under
   773  // the terms of the GNU General Public License as published by the Free
   774  // Software Foundation; either version 3, or (at your option) any later
   775  // version.
   776  //
   777  // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
   778  // WARRANTY; without even the implied warranty of MERCHANTABILITY or
   779  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   780  // for more details.
   781  //
   782  // Under Section 7 of GPL version 3, you are granted additional
   783  // permissions described in the GCC Runtime Library Exception, version
   784  // 3.1, as published by the Free Software Foundation.
   785  //
   786  // You should have received a copy of the GNU General Public License and
   787  // a copy of the GCC Runtime Library Exception along with this program;
   788  // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   789  // <http://www.gnu.org/licenses/>.
   790  
   791  // This administrivia gets added to the beginning of limits.h
   792  //    if the system has its own version of limits.h.
   793  
   794  // We use _GCC_LIMITS_H_ because we want this not to match
   795  //    any macros that the system's limits.h uses for its own purposes.
   796  
   797  type _onexit_t = uintptr /* stdlib.h:49:15 */
   798  
   799  type _div_t = struct {
   800  	quot int32
   801  	rem  int32
   802  } /* stdlib.h:59:11 */
   803  
   804  type div_t = _div_t /* stdlib.h:62:5 */
   805  
   806  type _ldiv_t = struct {
   807  	quot int32
   808  	rem  int32
   809  } /* stdlib.h:64:11 */
   810  
   811  type ldiv_t = _ldiv_t /* stdlib.h:67:5 */
   812  
   813  type _LDOUBLE = struct{ ld [10]uint8 } /* stdlib.h:76:5 */
   814  
   815  type _CRT_DOUBLE = struct{ x float64 } /* stdlib.h:83:5 */
   816  
   817  type _CRT_FLOAT = struct{ f float32 } /* stdlib.h:87:5 */
   818  
   819  type _LONGDOUBLE = struct{ x float64 } /* stdlib.h:94:5 */
   820  
   821  type _LDBL12 = struct{ ld12 [12]uint8 } /* stdlib.h:101:5 */
   822  
   823  type _purecall_handler = uintptr /* stdlib.h:142:16 */
   824  
   825  type _invalid_parameter_handler = uintptr /* stdlib.h:147:16 */
   826  
   827  type lldiv_t = struct {
   828  	quot int64
   829  	rem  int64
   830  } /* stdlib.h:699:61 */
   831  
   832  // *
   833  // This file has no copyright assigned and is placed in the Public Domain.
   834  // This file is part of the mingw-w64 runtime package.
   835  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   836  
   837  // *
   838  // This file has no copyright assigned and is placed in the Public Domain.
   839  // This file is part of the mingw-w64 runtime package.
   840  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   841  
   842  // Return codes for _heapwalk()
   843  
   844  // Values for _heapinfo.useflag
   845  
   846  // The structure used to walk through the heap with _heapwalk.
   847  type _heapinfo = struct {
   848  	_pentry  uintptr
   849  	_size    size_t
   850  	_useflag int32
   851  	_        [4]byte
   852  } /* malloc.h:46:11 */
   853  
   854  // *
   855  // This file has no copyright assigned and is placed in the Public Domain.
   856  // This file is part of the mingw-w64 runtime package.
   857  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   858  
   859  // *
   860  // This file has no copyright assigned and is placed in the Public Domain.
   861  // This file is part of the mingw-w64 runtime package.
   862  // No warranty is given; refer to the file DISCLAIMER.PD within this package.
   863  
   864  // Return codes for _heapwalk()
   865  
   866  // Values for _heapinfo.useflag
   867  
   868  // The structure used to walk through the heap with _heapwalk.
   869  type _HEAPINFO = _heapinfo /* malloc.h:50:5 */
   870  
   871  var hello = *(*[14]int8)(unsafe.Pointer(ts /* "hello, hello!" */)) /* example.c:29:21 */
   872  // "hello world" would be more standard, but the repeated "hello"
   873  // stresses the compression code better, sorry...
   874  
   875  var dictionary = *(*[6]int8)(unsafe.Pointer(ts + 14 /* "hello" */)) /* example.c:34:19 */
   876  var dictId uLong                                                    /* example.c:35:14: */
   877  
   878  var zalloc alloc_func = uintptr(0) /* example.c:77:19 */
   879  var zfree free_func = uintptr(0)   /* example.c:78:18 */
   880  
   881  // ===========================================================================
   882  // Test compress() and uncompress()
   883  func test_compress(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:88:6: */
   884  	bp := tls.Alloc(48)
   885  	defer tls.Free(48)
   886  	*(*uLong)(unsafe.Pointer(bp + 40)) = comprLen
   887  	*(*uLong)(unsafe.Pointer(bp + 44)) = uncomprLen
   888  
   889  	var err int32
   890  	var len uLong = (uLong(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uLong(1))
   891  
   892  	err = z.Xcompress(tls, compr, bp+40 /* &comprLen */, uintptr(uintptr(unsafe.Pointer(&hello))), len)
   893  	{
   894  		if err != 0 {
   895  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+34 /* "compress" */, err))
   896  			libc.Xexit(tls, 1)
   897  		}
   898  	}
   899  
   900  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
   901  
   902  	err = z.Xuncompress(tls, uncompr, bp+44 /* &uncomprLen */, compr, *(*uLong)(unsafe.Pointer(bp + 40 /* comprLen */)))
   903  	{
   904  		if err != 0 {
   905  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+51 /* "uncompress" */, err))
   906  			libc.Xexit(tls, 1)
   907  		}
   908  	}
   909  
   910  	if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 {
   911  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+62 /* "bad uncompress\n" */, 0)
   912  		libc.Xexit(tls, 1)
   913  	} else {
   914  		libc.Xprintf(tls, ts+78 /* "uncompress(): %s..." */, libc.VaList(bp+32, uncompr))
   915  	}
   916  }
   917  
   918  // ===========================================================================
   919  // Test read/write of .gz files
   920  func test_gzio(tls *libc.TLS, fname uintptr, uncompr uintptr, uncomprLen uLong) { /* example.c:114:6: */
   921  	bp := tls.Alloc(84)
   922  	defer tls.Free(84)
   923  
   924  	// var err int32 at bp+80, 4
   925  
   926  	var len int32 = (int32(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + 1)
   927  	var file gzFile
   928  	var pos int32
   929  
   930  	file = z.Xgzopen(tls, fname, ts+96 /* "wb" */)
   931  	if file == (uintptr(0)) {
   932  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+99 /* "gzopen error\n" */, 0)
   933  		libc.Xexit(tls, 1)
   934  	}
   935  	z.Xgzputc(tls, file, 'h')
   936  	if z.Xgzputs(tls, file, ts+113 /* "ello" */) != 4 {
   937  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+118 /* "gzputs err: %s\n" */, libc.VaList(bp, z.Xgzerror(tls, file, bp+80 /* &err */)))
   938  		libc.Xexit(tls, 1)
   939  	}
   940  	if z.Xgzprintf(tls, file, ts+134 /* ", %s!" */, libc.VaList(bp+8, ts+14 /* "hello" */)) != 8 {
   941  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+140 /* "gzprintf err: %s..." */, libc.VaList(bp+16, z.Xgzerror(tls, file, bp+80 /* &err */)))
   942  		libc.Xexit(tls, 1)
   943  	}
   944  	z.Xgzseek(tls, file, 1, 1) // add one zero byte
   945  	z.Xgzclose(tls, file)
   946  
   947  	file = z.Xgzopen(tls, fname, ts+158 /* "rb" */)
   948  	if file == (uintptr(0)) {
   949  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+99 /* "gzopen error\n" */, 0)
   950  		libc.Xexit(tls, 1)
   951  	}
   952  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
   953  
   954  	if z.Xgzread(tls, file, uncompr, uint32(uncomprLen)) != len {
   955  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+161 /* "gzread err: %s\n" */, libc.VaList(bp+24, z.Xgzerror(tls, file, bp+80 /* &err */)))
   956  		libc.Xexit(tls, 1)
   957  	}
   958  	if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 {
   959  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+177 /* "bad gzread: %s\n" */, libc.VaList(bp+32, uncompr))
   960  		libc.Xexit(tls, 1)
   961  	} else {
   962  		libc.Xprintf(tls, ts+193 /* "gzread(): %s\n" */, libc.VaList(bp+40, uncompr))
   963  	}
   964  
   965  	pos = z.Xgzseek(tls, file, -8, 1)
   966  	if (pos != 6) || (z.Xgztell(tls, file) != pos) {
   967  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+207, /* "gzseek error, po..." */
   968  			libc.VaList(bp+48, pos, z.Xgztell(tls, file)))
   969  		libc.Xexit(tls, 1)
   970  	}
   971  
   972  	if (func() int32 {
   973  		if (*gzFile_s)(unsafe.Pointer(file)).have != 0 {
   974  			return int32(func() uint8 {
   975  				(*gzFile_s)(unsafe.Pointer(file)).have--
   976  				(*gzFile_s)(unsafe.Pointer(file)).pos++
   977  				return *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&((*gzFile_s)(unsafe.Pointer(file)).next), 1)))
   978  			}())
   979  		}
   980  		return z.Xgzgetc(tls, file)
   981  	}()) != ' ' {
   982  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+242 /* "gzgetc error\n" */, 0)
   983  		libc.Xexit(tls, 1)
   984  	}
   985  
   986  	if z.Xgzungetc(tls, ' ', file) != ' ' {
   987  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+256 /* "gzungetc error\n" */, 0)
   988  		libc.Xexit(tls, 1)
   989  	}
   990  
   991  	z.Xgzgets(tls, file, uncompr, int32(uncomprLen))
   992  	if libc.Xstrlen(tls, uncompr) != uint64(7) { // " hello!"
   993  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+272 /* "gzgets err after..." */, libc.VaList(bp+64, z.Xgzerror(tls, file, bp+80 /* &err */)))
   994  		libc.Xexit(tls, 1)
   995  	}
   996  	if libc.Xstrcmp(tls, uncompr, (uintptr(unsafe.Pointer(&hello))+uintptr(6))) != 0 {
   997  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+301 /* "bad gzgets after..." */, 0)
   998  		libc.Xexit(tls, 1)
   999  	} else {
  1000  		libc.Xprintf(tls, ts+326 /* "gzgets() after g..." */, libc.VaList(bp+72, uncompr))
  1001  	}
  1002  
  1003  	z.Xgzclose(tls, file)
  1004  }
  1005  
  1006  // ===========================================================================
  1007  // Test deflate() with small buffers
  1008  func test_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:200:6: */
  1009  	bp := tls.Alloc(152)
  1010  	defer tls.Free(152)
  1011  
  1012  	// var c_stream z_stream at bp+64, 88
  1013  	// compression stream
  1014  	var err int32
  1015  	var len uLong = (uLong(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uLong(1))
  1016  
  1017  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc
  1018  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree
  1019  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0)
  1020  
  1021  	err = z.XdeflateInit_(tls, bp+64 /* &c_stream */, -1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1022  	{
  1023  		if err != 0 {
  1024  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err))
  1025  			libc.Xexit(tls, 1)
  1026  		}
  1027  	}
  1028  
  1029  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello)))
  1030  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr
  1031  
  1032  	for ((*z_stream)(unsafe.Pointer(bp+64 /* &c_stream */)).total_in != len) && ((*z_stream)(unsafe.Pointer(bp+64 /* &c_stream */)).total_out < comprLen) {
  1033  		(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = libc.AssignPtrUint32(bp+64 /* &c_stream */ +24 /* &.avail_out */, uInt(1)) // force small buffers
  1034  		err = z.Xdeflate(tls, bp+64 /* &c_stream */, 0)
  1035  		{
  1036  			if err != 0 {
  1037  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err))
  1038  				libc.Xexit(tls, 1)
  1039  			}
  1040  		}
  1041  
  1042  	}
  1043  	// Finish the stream, still forcing small buffers:
  1044  	for {
  1045  		(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(1)
  1046  		err = z.Xdeflate(tls, bp+64 /* &c_stream */, 4)
  1047  		if err == 1 {
  1048  			break
  1049  		}
  1050  		{
  1051  			if err != 0 {
  1052  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err))
  1053  				libc.Xexit(tls, 1)
  1054  			}
  1055  		}
  1056  
  1057  	}
  1058  
  1059  	err = z.XdeflateEnd(tls, bp+64 /* &c_stream */)
  1060  	{
  1061  		if err != 0 {
  1062  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+380 /* "deflateEnd" */, err))
  1063  			libc.Xexit(tls, 1)
  1064  		}
  1065  	}
  1066  
  1067  }
  1068  
  1069  // ===========================================================================
  1070  // Test inflate() with small buffers
  1071  func test_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:238:6: */
  1072  	bp := tls.Alloc(144)
  1073  	defer tls.Free(144)
  1074  
  1075  	var err int32
  1076  	// var d_stream z_stream at bp+56, 88
  1077  	// decompression stream
  1078  
  1079  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
  1080  
  1081  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc
  1082  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree
  1083  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0)
  1084  
  1085  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr
  1086  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(0)
  1087  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr
  1088  
  1089  	err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1090  	{
  1091  		if err != 0 {
  1092  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err))
  1093  			libc.Xexit(tls, 1)
  1094  		}
  1095  	}
  1096  
  1097  	for ((*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out < uncomprLen) && ((*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_in < comprLen) {
  1098  		(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = libc.AssignPtrUint32(bp+56 /* &d_stream */ +24 /* &.avail_out */, uInt(1)) // force small buffers
  1099  		err = z.Xinflate(tls, bp+56 /* &d_stream */, 0)
  1100  		if err == 1 {
  1101  			break
  1102  		}
  1103  		{
  1104  			if err != 0 {
  1105  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+403 /* "inflate" */, err))
  1106  				libc.Xexit(tls, 1)
  1107  			}
  1108  		}
  1109  
  1110  	}
  1111  
  1112  	err = z.XinflateEnd(tls, bp+56 /* &d_stream */)
  1113  	{
  1114  		if err != 0 {
  1115  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err))
  1116  			libc.Xexit(tls, 1)
  1117  		}
  1118  	}
  1119  
  1120  	if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 {
  1121  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+422 /* "bad inflate\n" */, 0)
  1122  		libc.Xexit(tls, 1)
  1123  	} else {
  1124  		libc.Xprintf(tls, ts+435 /* "inflate(): %s\n" */, libc.VaList(bp+48, uncompr))
  1125  	}
  1126  }
  1127  
  1128  // ===========================================================================
  1129  // Test deflate() with large buffers and dynamic change of compression level
  1130  func test_large_deflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:279:6: */
  1131  	bp := tls.Alloc(168)
  1132  	defer tls.Free(168)
  1133  
  1134  	// var c_stream z_stream at bp+80, 88
  1135  	// compression stream
  1136  	var err int32
  1137  
  1138  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zalloc = zalloc
  1139  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).zfree = zfree
  1140  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).opaque = uintptr(0)
  1141  
  1142  	err = z.XdeflateInit_(tls, bp+80 /* &c_stream */, 1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1143  	{
  1144  		if err != 0 {
  1145  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err))
  1146  			libc.Xexit(tls, 1)
  1147  		}
  1148  	}
  1149  
  1150  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_out = compr
  1151  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_out = uInt(comprLen)
  1152  
  1153  	// At this point, uncompr is still mostly zeroes, so it should compress
  1154  	// very well:
  1155  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr
  1156  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen)
  1157  	err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0)
  1158  	{
  1159  		if err != 0 {
  1160  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err))
  1161  			libc.Xexit(tls, 1)
  1162  		}
  1163  	}
  1164  
  1165  	if (*z_stream)(unsafe.Pointer(bp+80 /* &c_stream */)).avail_in != uInt(0) {
  1166  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+450 /* "deflate not gree..." */, 0)
  1167  		libc.Xexit(tls, 1)
  1168  	}
  1169  
  1170  	// Feed in already compressed data and switch to no compression:
  1171  	z.XdeflateParams(tls, bp+80 /* &c_stream */, 0, 0)
  1172  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = compr
  1173  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = (uInt(comprLen) / uInt(2))
  1174  	err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0)
  1175  	{
  1176  		if err != 0 {
  1177  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err))
  1178  			libc.Xexit(tls, 1)
  1179  		}
  1180  	}
  1181  
  1182  	// Switch back to compressing mode:
  1183  	z.XdeflateParams(tls, bp+80 /* &c_stream */, 9, 1)
  1184  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).next_in = uncompr
  1185  	(*z_stream)(unsafe.Pointer(bp + 80 /* &c_stream */)).avail_in = uInt(uncomprLen)
  1186  	err = z.Xdeflate(tls, bp+80 /* &c_stream */, 0)
  1187  	{
  1188  		if err != 0 {
  1189  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+372 /* "deflate" */, err))
  1190  			libc.Xexit(tls, 1)
  1191  		}
  1192  	}
  1193  
  1194  	err = z.Xdeflate(tls, bp+80 /* &c_stream */, 4)
  1195  	if err != 1 {
  1196  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+470 /* "deflate should r..." */, 0)
  1197  		libc.Xexit(tls, 1)
  1198  	}
  1199  	err = z.XdeflateEnd(tls, bp+80 /* &c_stream */)
  1200  	{
  1201  		if err != 0 {
  1202  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+64, ts+380 /* "deflateEnd" */, err))
  1203  			libc.Xexit(tls, 1)
  1204  		}
  1205  	}
  1206  
  1207  }
  1208  
  1209  // ===========================================================================
  1210  // Test inflate() with large buffers
  1211  func test_large_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:334:6: */
  1212  	bp := tls.Alloc(144)
  1213  	defer tls.Free(144)
  1214  
  1215  	var err int32
  1216  	// var d_stream z_stream at bp+56, 88
  1217  	// decompression stream
  1218  
  1219  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
  1220  
  1221  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc
  1222  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree
  1223  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0)
  1224  
  1225  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr
  1226  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen)
  1227  
  1228  	err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1229  	{
  1230  		if err != 0 {
  1231  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err))
  1232  			libc.Xexit(tls, 1)
  1233  		}
  1234  	}
  1235  
  1236  	for {
  1237  		(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr // discard the output
  1238  		(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen)
  1239  		err = z.Xinflate(tls, bp+56 /* &d_stream */, 0)
  1240  		if err == 1 {
  1241  			break
  1242  		}
  1243  		{
  1244  			if err != 0 {
  1245  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+506 /* "large inflate" */, err))
  1246  				libc.Xexit(tls, 1)
  1247  			}
  1248  		}
  1249  
  1250  	}
  1251  
  1252  	err = z.XinflateEnd(tls, bp+56 /* &d_stream */)
  1253  	{
  1254  		if err != 0 {
  1255  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err))
  1256  			libc.Xexit(tls, 1)
  1257  		}
  1258  	}
  1259  
  1260  	if (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out != ((uLong(2) * uncomprLen) + (comprLen / uLong(2))) {
  1261  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+520 /* "bad large inflat..." */, libc.VaList(bp+48, (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).total_out))
  1262  		libc.Xexit(tls, 1)
  1263  	} else {
  1264  		libc.Xprintf(tls, ts+544 /* "large_inflate():..." */, 0)
  1265  	}
  1266  }
  1267  
  1268  // ===========================================================================
  1269  // Test deflate() with full flush
  1270  func test_flush(tls *libc.TLS, compr uintptr, comprLen uintptr) { /* example.c:375:6: */
  1271  	bp := tls.Alloc(152)
  1272  	defer tls.Free(152)
  1273  
  1274  	// var c_stream z_stream at bp+64, 88
  1275  	// compression stream
  1276  	var err int32
  1277  	var len uInt = (uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1))
  1278  
  1279  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zalloc = zalloc
  1280  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).zfree = zfree
  1281  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).opaque = uintptr(0)
  1282  
  1283  	err = z.XdeflateInit_(tls, bp+64 /* &c_stream */, -1, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1284  	{
  1285  		if err != 0 {
  1286  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err))
  1287  			libc.Xexit(tls, 1)
  1288  		}
  1289  	}
  1290  
  1291  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello)))
  1292  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).next_out = compr
  1293  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = uInt(3)
  1294  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_out = uInt(*(*uLong)(unsafe.Pointer(comprLen)))
  1295  	err = z.Xdeflate(tls, bp+64 /* &c_stream */, 3)
  1296  	{
  1297  		if err != 0 {
  1298  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+372 /* "deflate" */, err))
  1299  			libc.Xexit(tls, 1)
  1300  		}
  1301  	}
  1302  
  1303  	*(*Byte)(unsafe.Pointer(compr + 3))++ // force an error in first compressed block
  1304  	(*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).avail_in = (len - uInt(3))
  1305  
  1306  	err = z.Xdeflate(tls, bp+64 /* &c_stream */, 4)
  1307  	if err != 1 {
  1308  		{
  1309  			if err != 0 {
  1310  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+372 /* "deflate" */, err))
  1311  				libc.Xexit(tls, 1)
  1312  			}
  1313  		}
  1314  
  1315  	}
  1316  	err = z.XdeflateEnd(tls, bp+64 /* &c_stream */)
  1317  	{
  1318  		if err != 0 {
  1319  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+380 /* "deflateEnd" */, err))
  1320  			libc.Xexit(tls, 1)
  1321  		}
  1322  	}
  1323  
  1324  	*(*uLong)(unsafe.Pointer(comprLen)) = (*z_stream)(unsafe.Pointer(bp + 64 /* &c_stream */)).total_out
  1325  }
  1326  
  1327  // ===========================================================================
  1328  // Test inflateSync()
  1329  func test_sync(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:413:6: */
  1330  	bp := tls.Alloc(160)
  1331  	defer tls.Free(160)
  1332  
  1333  	var err int32
  1334  	// var d_stream z_stream at bp+72, 88
  1335  	// decompression stream
  1336  
  1337  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
  1338  
  1339  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zalloc = zalloc
  1340  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).zfree = zfree
  1341  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).opaque = uintptr(0)
  1342  
  1343  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_in = compr
  1344  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = uInt(2) // just read the zlib header
  1345  
  1346  	err = z.XinflateInit_(tls, bp+72 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1347  	{
  1348  		if err != 0 {
  1349  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err))
  1350  			libc.Xexit(tls, 1)
  1351  		}
  1352  	}
  1353  
  1354  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).next_out = uncompr
  1355  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_out = uInt(uncomprLen)
  1356  
  1357  	err = z.Xinflate(tls, bp+72 /* &d_stream */, 0)
  1358  	{
  1359  		if err != 0 {
  1360  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+403 /* "inflate" */, err))
  1361  			libc.Xexit(tls, 1)
  1362  		}
  1363  	}
  1364  
  1365  	(*z_stream)(unsafe.Pointer(bp + 72 /* &d_stream */)).avail_in = (uInt(comprLen) - uInt(2)) // read all compressed data
  1366  	err = z.XinflateSync(tls, bp+72 /* &d_stream */)                                           /* but skip the damaged part */
  1367  	{
  1368  		if err != 0 {
  1369  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+565 /* "inflateSync" */, err))
  1370  			libc.Xexit(tls, 1)
  1371  		}
  1372  	}
  1373  
  1374  	err = z.Xinflate(tls, bp+72 /* &d_stream */, 4)
  1375  	if err != (-3) {
  1376  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+577 /* "inflate should r..." */, 0)
  1377  		// Because of incorrect adler32
  1378  		libc.Xexit(tls, 1)
  1379  	}
  1380  	err = z.XinflateEnd(tls, bp+72 /* &d_stream */)
  1381  	{
  1382  		if err != 0 {
  1383  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+48, ts+411 /* "inflateEnd" */, err))
  1384  			libc.Xexit(tls, 1)
  1385  		}
  1386  	}
  1387  
  1388  	libc.Xprintf(tls, ts+611 /* "after inflateSyn..." */, libc.VaList(bp+64, uncompr))
  1389  }
  1390  
  1391  // ===========================================================================
  1392  // Test deflate() with preset dictionary
  1393  func test_dict_deflate(tls *libc.TLS, compr uintptr, comprLen uLong) { /* example.c:457:6: */
  1394  	bp := tls.Alloc(136)
  1395  	defer tls.Free(136)
  1396  
  1397  	// var c_stream z_stream at bp+48, 88
  1398  	// compression stream
  1399  	var err int32
  1400  
  1401  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zalloc = zalloc
  1402  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).zfree = zfree
  1403  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).opaque = uintptr(0)
  1404  
  1405  	err = z.XdeflateInit_(tls, bp+48 /* &c_stream */, 9, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1406  	{
  1407  		if err != 0 {
  1408  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+360 /* "deflateInit" */, err))
  1409  			libc.Xexit(tls, 1)
  1410  		}
  1411  	}
  1412  
  1413  	err = z.XdeflateSetDictionary(tls, bp+48, /* &c_stream */
  1414  		uintptr(uintptr(unsafe.Pointer(&dictionary))), uint32(int32(unsafe.Sizeof(dictionary))))
  1415  	{
  1416  		if err != 0 {
  1417  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+639 /* "deflateSetDictio..." */, err))
  1418  			libc.Xexit(tls, 1)
  1419  		}
  1420  	}
  1421  
  1422  	dictId = (*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).adler
  1423  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_out = compr
  1424  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_out = uInt(comprLen)
  1425  
  1426  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).next_in = uintptr(uintptr(unsafe.Pointer(&hello)))
  1427  	(*z_stream)(unsafe.Pointer(bp + 48 /* &c_stream */)).avail_in = (uInt(libc.Xstrlen(tls, uintptr(unsafe.Pointer(&hello)))) + uInt(1))
  1428  
  1429  	err = z.Xdeflate(tls, bp+48 /* &c_stream */, 4)
  1430  	if err != 1 {
  1431  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+470 /* "deflate should r..." */, 0)
  1432  		libc.Xexit(tls, 1)
  1433  	}
  1434  	err = z.XdeflateEnd(tls, bp+48 /* &c_stream */)
  1435  	{
  1436  		if err != 0 {
  1437  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+380 /* "deflateEnd" */, err))
  1438  			libc.Xexit(tls, 1)
  1439  		}
  1440  	}
  1441  
  1442  }
  1443  
  1444  // ===========================================================================
  1445  // Test inflate() with a preset dictionary
  1446  func test_dict_inflate(tls *libc.TLS, compr uintptr, comprLen uLong, uncompr uintptr, uncomprLen uLong) { /* example.c:494:6: */
  1447  	bp := tls.Alloc(144)
  1448  	defer tls.Free(144)
  1449  
  1450  	var err int32
  1451  	// var d_stream z_stream at bp+56, 88
  1452  	// decompression stream
  1453  
  1454  	libc.Xstrcpy(tls, uncompr, ts+43 /* "garbage" */)
  1455  
  1456  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zalloc = zalloc
  1457  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).zfree = zfree
  1458  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).opaque = uintptr(0)
  1459  
  1460  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_in = compr
  1461  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_in = uInt(comprLen)
  1462  
  1463  	err = z.XinflateInit_(tls, bp+56 /* &d_stream */, ts+353 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{})))
  1464  	{
  1465  		if err != 0 {
  1466  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp, ts+391 /* "inflateInit" */, err))
  1467  			libc.Xexit(tls, 1)
  1468  		}
  1469  	}
  1470  
  1471  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).next_out = uncompr
  1472  	(*z_stream)(unsafe.Pointer(bp + 56 /* &d_stream */)).avail_out = uInt(uncomprLen)
  1473  
  1474  	for {
  1475  		err = z.Xinflate(tls, bp+56 /* &d_stream */, 0)
  1476  		if err == 1 {
  1477  			break
  1478  		}
  1479  		if err == 2 {
  1480  			if (*z_stream)(unsafe.Pointer(bp+56 /* &d_stream */)).adler != dictId {
  1481  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+660 /* "unexpected dicti..." */, 0)
  1482  				libc.Xexit(tls, 1)
  1483  			}
  1484  			err = z.XinflateSetDictionary(tls, bp+56 /* &d_stream */, uintptr(uintptr(unsafe.Pointer(&dictionary))),
  1485  				uint32(int32(unsafe.Sizeof(dictionary))))
  1486  		}
  1487  		{
  1488  			if err != 0 {
  1489  				libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+16, ts+682 /* "inflate with dic..." */, err))
  1490  				libc.Xexit(tls, 1)
  1491  			}
  1492  		}
  1493  
  1494  	}
  1495  
  1496  	err = z.XinflateEnd(tls, bp+56 /* &d_stream */)
  1497  	{
  1498  		if err != 0 {
  1499  			libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+20 /* "%s error: %d\n" */, libc.VaList(bp+32, ts+411 /* "inflateEnd" */, err))
  1500  			libc.Xexit(tls, 1)
  1501  		}
  1502  	}
  1503  
  1504  	if libc.Xstrcmp(tls, uncompr, uintptr(unsafe.Pointer(&hello))) != 0 {
  1505  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+700 /* "bad inflate with..." */, 0)
  1506  		libc.Xexit(tls, 1)
  1507  	} else {
  1508  		libc.Xprintf(tls, ts+723 /* "inflate with dic..." */, libc.VaList(bp+48, uncompr))
  1509  	}
  1510  }
  1511  
  1512  // ===========================================================================
  1513  // Usage:  example [output.gz  [input.gz]]
  1514  
  1515  func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* example.c:545:5: */
  1516  	bp := tls.Alloc(28)
  1517  	defer tls.Free(28)
  1518  
  1519  	var compr uintptr
  1520  	var uncompr uintptr
  1521  	*(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = (uint32(uint64(10000) * uint64(unsafe.Sizeof(int32(0))))) // don't overflow on MSDOS
  1522  	var uncomprLen uLong = *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */))
  1523  
  1524  	if int32(*(*int8)(unsafe.Pointer(z.XzlibVersion(tls)))) != int32(*(*int8)(unsafe.Pointer(myVersion))) {
  1525  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+752 /* "incompatible zli..." */, 0)
  1526  		libc.Xexit(tls, 1)
  1527  
  1528  	} else if libc.Xstrcmp(tls, z.XzlibVersion(tls), ts+353 /* "1.2.11" */) != 0 {
  1529  		libc.Xfprintf(tls, libc.X__acrt_iob_func(tls, uint32(2)), ts+779 /* "warning: differe..." */, 0)
  1530  	}
  1531  
  1532  	libc.Xprintf(tls, ts+812, /* "zlib version %s ..." */
  1533  		libc.VaList(bp, ts+353 /* "1.2.11" */, 0x12b0, z.XzlibCompileFlags(tls)))
  1534  
  1535  	compr = libc.Xcalloc(tls, uint64(uInt(*(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)))), uint64(1))
  1536  	uncompr = libc.Xcalloc(tls, uint64(uInt(uncomprLen)), uint64(1))
  1537  	// compr and uncompr are cleared to avoid reading uninitialized
  1538  	// data and to ensure that uncompr compresses well.
  1539  	if (compr == uintptr(0)) || (uncompr == uintptr(0)) {
  1540  		libc.Xprintf(tls, ts+861 /* "out of memory\n" */, 0)
  1541  		libc.Xexit(tls, 1)
  1542  	}
  1543  
  1544  	test_compress(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1545  
  1546  	test_gzio(tls, func() uintptr {
  1547  		if argc > 1 {
  1548  			return *(*uintptr)(unsafe.Pointer(argv + 1*8))
  1549  		}
  1550  		return ts + 876 /* "foo.gz" */
  1551  	}(),
  1552  		uncompr, uncomprLen)
  1553  
  1554  	test_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)))
  1555  	test_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1556  
  1557  	test_large_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1558  	test_large_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1559  
  1560  	test_flush(tls, compr, bp+24 /* &comprLen */)
  1561  	test_sync(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1562  	*(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)) = uncomprLen
  1563  
  1564  	test_dict_deflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)))
  1565  	test_dict_inflate(tls, compr, *(*uLong)(unsafe.Pointer(bp + 24 /* comprLen */)), uncompr, uncomprLen)
  1566  
  1567  	libc.Xfree(tls, compr)
  1568  	libc.Xfree(tls, uncompr)
  1569  
  1570  	return 0
  1571  }
  1572  
  1573  var myVersion uintptr = ts + 353 /* "1.2.11" */ /* example.c:552:22 */
  1574  
  1575  var ts1 = "hello, hello!\x00hello\x00%s error: %d\n\x00compress\x00garbage\x00uncompress\x00bad uncompress\n\x00uncompress(): %s\n\x00wb\x00gzopen error\n\x00ello\x00gzputs err: %s\n\x00, %s!\x00gzprintf err: %s\n\x00rb\x00gzread err: %s\n\x00bad gzread: %s\n\x00gzread(): %s\n\x00gzseek error, pos=%ld, gztell=%ld\n\x00gzgetc error\n\x00gzungetc error\n\x00gzgets err after gzseek: %s\n\x00bad gzgets after gzseek\n\x00gzgets() after gzseek: %s\n\x001.2.11\x00deflateInit\x00deflate\x00deflateEnd\x00inflateInit\x00inflate\x00inflateEnd\x00bad inflate\n\x00inflate(): %s\n\x00deflate not greedy\n\x00deflate should report Z_STREAM_END\n\x00large inflate\x00bad large inflate: %ld\n\x00large_inflate(): OK\n\x00inflateSync\x00inflate should report DATA_ERROR\n\x00after inflateSync(): hel%s\n\x00deflateSetDictionary\x00unexpected dictionary\x00inflate with dict\x00bad inflate with dict\n\x00inflate with dictionary: %s\n\x00incompatible zlib version\n\x00warning: different zlib version\n\x00zlib version %s = 0x%04x, compile flags = 0x%lx\n\x00out of memory\n\x00foo.gz\x00"
  1576  var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data