diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-16 11:10:10 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-16 11:10:10 -0700 |
commit | ee1fc9904b58181e02cf48ae05308478327eeb3f (patch) | |
tree | 03fd37619c98f802f03a77da3a3ccc547c42d0be /third_party | |
parent | 19520c66ee9ca26ebf9f89ba4b106f495a1d5059 (diff) |
add lzma.js in thirdparty
Diffstat (limited to 'third_party')
28 files changed, 4919 insertions, 0 deletions
diff --git a/third_party/lzma.js/README.markdown b/third_party/lzma.js/README.markdown new file mode 100644 index 00000000..e2c90730 --- /dev/null +++ b/third_party/lzma.js/README.markdown @@ -0,0 +1,37 @@ + +lzma.js +======= + +An LZMA implementation in JavaScript, compiled from lzip using Emscripten +with the goal of having a small and fast implementation as much as +possible. + +lzip is GPL, additional code is MIT + + +Building +-------- + +Run doit.sh. It will build both a native build, lzma-native, and lzma.js. +Both are useful because you can use the native build to compress locally, +and the JS build to decompress on the client browser. But, you can use +whichever you want in either location. + + +Usage +----- + +LZMA.compress(data) receives an array of 8-bit data and returns an + array of compressed data. + +LZMA.decompress(data) receives an array of compressed 8-bit data and + returns an array of decompressed data. + + +Use lzma-decoder.js if you just need to decode. It's 66K, or 23K +if your webserver does gzip. If you need compression too, use +lzma-full.js which is a little larger. + +See test-decoder.js, test-full.js and test-full.html for example +uses. + diff --git a/third_party/lzma.js/doit.sh b/third_party/lzma.js/doit.sh new file mode 100755 index 00000000..44a3941e --- /dev/null +++ b/third_party/lzma.js/doit.sh @@ -0,0 +1,33 @@ +cd lzip + +echo "native" +make clean +DECODER_ONLY=0 make lzip -j 4 # native build +mv lzip ../lzma-native + +echo "bitcode full (encoder+decoder)" +make clean +DECODER_ONLY=0 ~/Dev/emscripten/emmake make lzip -j 4 +mv lzip lzip-full.bc + +echo "bitcode decoder only" +make clean +DECODER_ONLY=1 ~/Dev/emscripten/emmake make lzip -j 4 +mv lzip lzip-decoder.bc + +cd .. + +echo "javascript full" +~/Dev/emscripten/emcc -O2 lzip/lzip-full.bc -o lzma-full.raw.js +# -s INLINING_LIMIT=0 +cat pre.js > lzma-full.js +cat lzma-full.raw.js >> lzma-full.js +cat post.js >> lzma-full.js + +echo "javascript decoder" +~/Dev/emscripten/emcc -O2 lzip/lzip-decoder.bc -o lzma-decoder.raw.js +# -s INLINING_LIMIT=0 +cat pre.js > lzma-decoder.js +cat lzma-decoder.raw.js >> lzma-decoder.js +cat post.js >> lzma-decoder.js + diff --git a/third_party/lzma.js/lzip/AUTHORS b/third_party/lzma.js/lzip/AUTHORS new file mode 100644 index 00000000..ada24df3 --- /dev/null +++ b/third_party/lzma.js/lzip/AUTHORS @@ -0,0 +1,7 @@ +Lzip was written by Antonio Diaz Diaz. + +The ideas embodied in lzip are due to (at least) the following people: +Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for +the definition of Markov chains), G.N.N. Martin (for the definition of +range encoding), Igor Pavlov (for putting all the above together in +LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). diff --git a/third_party/lzma.js/lzip/COPYING b/third_party/lzma.js/lzip/COPYING new file mode 100644 index 00000000..44325404 --- /dev/null +++ b/third_party/lzma.js/lzip/COPYING @@ -0,0 +1,676 @@ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. + diff --git a/third_party/lzma.js/lzip/ChangeLog b/third_party/lzma.js/lzip/ChangeLog new file mode 100644 index 00000000..88accb13 --- /dev/null +++ b/third_party/lzma.js/lzip/ChangeLog @@ -0,0 +1,201 @@ +2011-04-30 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.12 released. + * main.cc: Added new option `-F, --recompress'. + * encoder.h (update_prices): Update high length symbol prices + independently of the value of `pos_state'. This gives better + compression for large values of `--match-length' without being + slower. + * encoder.h encoder.cc: Optimize pair price calculations. This + reduces compression time for large values of `--match-length' + by up to 6%. + * Compression time of option `-0' has been reduced by 2%. + * main.cc (decompress): Print only one status line for each + multimember file when only one `-v' is specified. + * main.cc (decompress): Print up to 6 bytes of trailing garbage + when `-vvvv' is specified. + * main.cc (open_instream): Do not show the message + " and `--stdout' was not specified" for directories, etc. + * lziprecover.cc: If `-v' is not specified show errors only. + * testsuite/unzcrash.cc: Use Arg_parser. + * testsuite/unzcrash.cc: Added new options `-b', `-p' and `-s'. + +2010-09-16 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.11 released. + * Added new option `-0' which produces a compression speed and + ratio comparable to those of `gzip -9'. + * fast_encoder.h fast_encoder.cc: New files. + * main.cc: Match length limit set by options -1 to -8 has been + reduced to extend range of use towards gzip. Lower numbers now + compress less but faster. (-1 now takes 43% less time for only + 20% larger compressed size). + * encoder.cc: Compression of option -9 has been slightly increased. + * lziprecover.cc: Added new option `--merge' which tries to + produce a correct file merging the good parts of two or more + damaged copies. + * lziprecover.cc: Added new option `--repair' for repairing a + 1-byte error in single-member files. + * decoder.cc (decode_member): Detect file errors earlier to + improve efficiency of lziprecover's new repair capability. + This change also prevents (harmless) access to uninitialized + memory when decompressing a corrupt file. + * lziprecover.cc: Added new option `--force'. + * lziprecover.cc: Added new option `--output'. + * lziprecover.cc: Added new option `--split' to select the until + now only operation of splitting multimember files. + * lziprecover.cc: If no operation is specified, warn the user + and do nothing. + * main.cc: Fixed warning about fchown's return value being ignored. + * decoder.cc: `-tvvvv' now also shows compression ratio. + * main.cc: Set stdin/stdout in binary mode on MSVC and OS2. + * New examples have been added to the manual. + * testsuite: `test1' renamed to `test.txt'. Added new tests. + * Matchfinder types HC4 (4 bytes hash-chain) and HT4 (4 bytes + hash-table) have been tested and found no better than the + current BT4. + +2010-04-05 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.10 released. + * decoder.h: Input_buffer integrated in Range_decoder. + * main.cc: File specified with option `-o' is now created with + mode 0666 if umask allows it, deleted if interrupted by user. + * main.cc: New constant `o_binary'. + * main.cc: Dictionary size for options -2, -3, -4 and -8 has + been changed to improve linearity of compressed sizes. + * lzip.h: Fixed warnings produced by over-optimization (-O3). + * Makefile.in: Added quotes to directory names. + +2010-01-17 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.9 released. + * main.cc (main): Return at least 1 if closing stdout fails. + * Makefile.in: Added `--name' option to help2man invocation. + * testsuite/check.sh: Use `test1' instead of `COPYING' for testing. + +2009-09-02 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.8 released. + * Compression time has been reduced by 4%. + * Lzdiff and lzgrep have been moved to the new package zutils. + * Fixed warnings on sistems where uint32_t != unsigned int. + +2009-06-25 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.7 released. + * decoder.h (copy_block): Fixed memcpy overlap introduced in 1.6. + +2009-06-22 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.6 released. + * Decompression time has been reduced by 17%. + * Added decompression support for Sync Flush marker. + * Added support for .tbz extension to lzdiff and lzgrep. + * Added man pages for lzdiff, lzgrep and lziprecover. + * encoder.cc (Matchfinder): Reduce memory use to 9x if input file + is smaller than dictionary size limit. + * decoder.cc: Added extra flush calls to improve partial + decompression of corrupt files. + * `--test' no more needs `/dev/null'. + * Removed some `bashisms' from lzdiff and lzgrep. + * Dictionary size for options `-1' to `-4' has been changed. + * main.cc (signal_handler): Declared as `extern "C"'. + * Makefile.in: Extra files are now installed by default. + * testsuite/check.sh: Test lziprecover. + * Added `export LC_ALL=C' to all scripts. + +2009-04-12 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.5 released. + * lzip.h: Coded dictionary size implemented in File_header. + * Fixed some includes that prevented compilation with GCC 4.4. + * `member_size' and `volume_size' are now accurate limits. + * Compression speed has been improved. + * Implemented bt4 type matchfinder. + * Added chapter `Algorithm' to the manual. + * Lzdiff and lzgrep now accept `-h' for `--help' and + `-V' for `--version'. + * Makefile.in: Man page is now installed by default. + * testsuite/check.sh: Verify that files are open in binary mode. + +2009-01-24 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.4 released. + * Implemented compression of version 1 files. + * Added new option `--member-size'. + * Added new option `--volume-size'. + * Added new option `--output'. + * main.cc: Read from non regular files if `--stdout' is specified. + * Added `lziprecover', a member recoverer program. + * testsuite/unzcrash.cc: Test all 1-byte errors. + +2008-12-21 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.3 released. + * This version automatically chooses the smallest possible + dictionary size for each file during compression, saving + memory during decompression. + * Implemented decompression of version 1 files. + * testsuite/check.sh: Replaced `diff -q' with `cmp'. + +2008-12-10 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.2 released. + * encoder.cc: A 1-byte read outside allocated memory has been fixed. + * lzip.h: Dictionary size limit has been reduced to 512MiB because + setting it to 1GiB causes overflow of a 32 bit integer. + * Added `lzdiff', a diff/cmp wrapper for gzip, bzip2, lzip and + non-compressed files. + * Added `lzgrep', a grep wrapper for gzip, bzip2, lzip and + non-compressed files. + * `make install-info' should now work on Debian and OS X. + +2008-11-17 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.1 released. + * Changed short name of option `--dictionary-size' to `-s'. + * Changed short name of option `--match-length' to `-m'. + * Changed LONG_LONG_MAX to LLONG_MAX. + +2008-10-14 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 1.0 released. + * `-tvv' shows file version and dictionary size. + +2008-09-30 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.5 released. + * Decompression is now 1% faster. + +2008-09-23 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.4 released. + * Code cleanup for global variable `verbosity'. + * Regained the compression ratio of 0.2 with 5% faster speed. + * Fixed compilation on sistems where size_t != unsigned int. + +2008-09-15 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.3 released. + * encoder.cc: Compression is now 15% faster, 1% worse. + * main.cc (main): Make `-t' option override `-c'. + * main.cc (decompress): Show `done' instead of `ok' when not testing. + * encoder.h: Use trials[] to return the list of pairs. + +2008-09-09 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.2 released. + * encoder.cc: Small improvements in compression speed. + * Small documentation changes. + +2008-08-20 Antonio Diaz Diaz <ant_diaz@teleline.es> + + * Version 0.1 released. + + +Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + +This file is a collection of facts, and thus it is not copyrightable, +but just in case, you have unlimited permission to copy, distribute and +modify it. diff --git a/third_party/lzma.js/lzip/INSTALL b/third_party/lzma.js/lzip/INSTALL new file mode 100644 index 00000000..b516f570 --- /dev/null +++ b/third_party/lzma.js/lzip/INSTALL @@ -0,0 +1,56 @@ +Requirements +------------ +You will need a C++ compiler. +I use gcc 4.3.5 and 3.3.6, but the code should compile with any +standards compliant compiler. +Gcc is available at http://gcc.gnu.org. + + +Procedure +--------- +1. Unpack the archive if you have not done so already: + + lzip -cd lzip[version].tar.lz | tar -xf - +or + gzip -cd lzip[version].tar.gz | tar -xf - + +This creates the directory ./lzip[version] containing the source from +the main archive. + +2. Change to lzip directory and run configure. + (Try `configure --help' for usage instructions). + + cd lzip[version] + ./configure + +3. Run make. + + make + +4. Optionally, type `make check' to run the tests that come with lzip. + +5. Type `make install' to install the programs and any data files and + documentation. + + +Another way +----------- +You can also compile lzip into a separate directory. To do this, you +must use a version of `make' that supports the `VPATH' variable, such +as GNU `make'. `cd' to the directory where you want the object files +and executables to go and run the `configure' script. `configure' +automatically checks for the source code in `.', in `..' and in the +directory that `configure' is in. + +`configure' recognizes the option `--srcdir=DIR' to control where to +look for the sources. Usually `configure' can determine that directory +automatically. + +After running `configure', you can run `make' and `make install' as +explained above. + + +Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + +This file is free documentation: you have unlimited permission to copy, +distribute and modify it. diff --git a/third_party/lzma.js/lzip/Makefile b/third_party/lzma.js/lzip/Makefile new file mode 100644 index 00000000..ca6a6ef7 --- /dev/null +++ b/third_party/lzma.js/lzip/Makefile @@ -0,0 +1,158 @@ +# Makefile for Lzip - Data compressor based on the LZMA algorithm +# Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. +# This file was generated automatically by configure. Do not edit. +# +# This Makefile is free software: you have unlimited permission +# to copy, distribute and modify it. + +pkgname = lzip +pkgversion = 1.12 +progname = lzip +VPATH = . +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +datadir = $(prefix)/share +infodir = $(datadir)/info +mandir = $(datadir)/man +sysconfdir = $(prefix)/etc +CPPFLAGS = -DDECODER_ONLY=$(DECODER_ONLY) +CXXFLAGS = -Wall -W -O2 +LDFLAGS = + +DISTNAME = $(pkgname)-$(pkgversion) +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) -p -m 755 +INSTALL_DATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -d -m 755 +SHELL = /bin/sh + +objs = decoder.o encoder.o fast_encoder.o main.o +recobjs = decoder.o lziprecover.o +unzobjs = unzcrash.o + + +.PHONY : all install install-info install-man install-strip \ + uninstall uninstall-info uninstall-man \ + doc info man check dist clean distclean + +all : $(progname) + +$(progname) : $(objs) + $(CXX) $(LDFLAGS) -o $@ $(objs) + +$(progname)_profiled : $(objs) + $(CXX) $(LDFLAGS) -pg -o $@ $(objs) + +lziprecover : $(recobjs) + $(CXX) $(LDFLAGS) -o $@ $(recobjs) + +unzcrash : $(unzobjs) + $(CXX) $(LDFLAGS) -o $@ $(unzobjs) + +main.o : main.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +lziprecover.o : lziprecover.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +unzcrash.o : testsuite/unzcrash.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +%.o : %.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< + +$(objs) : Makefile +decoder.o : lzip.h decoder.h +encoder.o : lzip.h encoder.h +fast_encoder.o : lzip.h encoder.h fast_encoder.h +main.o : lzip.h decoder.h encoder.h fast_encoder.h +lziprecover.o : lzip.h decoder.h Makefile +unzcrash.o : Makefile + + +doc : info man + +info : $(VPATH)/doc/$(pkgname).info + +$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texinfo + cd $(VPATH)/doc && makeinfo $(pkgname).texinfo + +man : $(VPATH)/doc/$(progname).1 $(VPATH)/doc/lziprecover.1 + +$(VPATH)/doc/$(progname).1 : $(progname) + help2man -n 'reduces the size of files' \ + -o $@ ./$(progname) + +$(VPATH)/doc/lziprecover.1 : lziprecover + help2man -n 'recovers data from damaged lzip files' \ + -o $@ --no-info ./lziprecover + +Makefile : $(VPATH)/configure $(VPATH)/Makefile.in + ./config.status + +check : all + @$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion) + +install : all install-info install-man + if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi + $(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(progname)" + $(INSTALL_PROGRAM) ./lziprecover "$(DESTDIR)$(bindir)/lziprecover" + +install-info : + if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi + $(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info" + -install-info --info-dir="$(DESTDIR)$(infodir)" $(DESTDIR)$(infodir)/$(pkgname).info + +install-man : + if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi + $(INSTALL_DATA) $(VPATH)/doc/$(progname).1 "$(DESTDIR)$(mandir)/man1/$(progname).1" + $(INSTALL_DATA) $(VPATH)/doc/lziprecover.1 "$(DESTDIR)$(mandir)/man1/lziprecover.1" + +install-strip : all + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install + +uninstall : uninstall-info uninstall-man + -rm -f "$(DESTDIR)$(bindir)/$(progname)" + -rm -f "$(DESTDIR)$(bindir)/lziprecover" + +uninstall-info : + -install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" + -rm -f "$(DESTDIR)$(infodir)/$(pkgname).info" + +uninstall-man : + -rm -f "$(DESTDIR)$(mandir)/man1/$(progname).1" + -rm -f "$(DESTDIR)$(mandir)/man1/lziprecover.1" + +dist : doc + ln -sf $(VPATH) $(DISTNAME) + tar -cvf $(DISTNAME).tar \ + $(DISTNAME)/AUTHORS \ + $(DISTNAME)/COPYING \ + $(DISTNAME)/ChangeLog \ + $(DISTNAME)/INSTALL \ + $(DISTNAME)/Makefile.in \ + $(DISTNAME)/NEWS \ + $(DISTNAME)/README \ + $(DISTNAME)/configure \ + $(DISTNAME)/doc/$(progname).1 \ + $(DISTNAME)/doc/lziprecover.1 \ + $(DISTNAME)/doc/$(pkgname).info \ + $(DISTNAME)/doc/$(pkgname).texinfo \ + $(DISTNAME)/testsuite/check.sh \ + $(DISTNAME)/testsuite/test.txt \ + $(DISTNAME)/testsuite/test_bad[1-5].lz \ + $(DISTNAME)/testsuite/test_sync.lz \ + $(DISTNAME)/testsuite/test_v[01].lz \ + $(DISTNAME)/testsuite/unzcrash.cc \ + $(DISTNAME)/*.h \ + $(DISTNAME)/*.cc + rm -f $(DISTNAME) + lzip -v -9 $(DISTNAME).tar + +clean : + -rm -f $(progname) $(progname)_profiled $(objs) + -rm -f lziprecover lziprecover.o unzcrash unzcrash.o + +distclean : clean + -rm -f Makefile config.status *.tar *.tar.lz diff --git a/third_party/lzma.js/lzip/Makefile.in b/third_party/lzma.js/lzip/Makefile.in new file mode 100644 index 00000000..30aba743 --- /dev/null +++ b/third_party/lzma.js/lzip/Makefile.in @@ -0,0 +1,138 @@ + +DISTNAME = $(pkgname)-$(pkgversion) +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) -p -m 755 +INSTALL_DATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -d -m 755 +SHELL = /bin/sh + +objs = arg_parser.o decoder.o encoder.o fast_encoder.o main.o +recobjs = arg_parser.o decoder.o lziprecover.o +unzobjs = arg_parser.o unzcrash.o + + +.PHONY : all install install-info install-man install-strip \ + uninstall uninstall-info uninstall-man \ + doc info man check dist clean distclean + +all : $(progname) lziprecover + +$(progname) : $(objs) + $(CXX) $(LDFLAGS) -o $@ $(objs) + +$(progname)_profiled : $(objs) + $(CXX) $(LDFLAGS) -pg -o $@ $(objs) + +lziprecover : $(recobjs) + $(CXX) $(LDFLAGS) -o $@ $(recobjs) + +unzcrash : $(unzobjs) + $(CXX) $(LDFLAGS) -o $@ $(unzobjs) + +main.o : main.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +lziprecover.o : lziprecover.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +unzcrash.o : testsuite/unzcrash.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $< + +%.o : %.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< + +$(objs) : Makefile +arg_parser.o : arg_parser.h +decoder.o : lzip.h decoder.h +encoder.o : lzip.h encoder.h +fast_encoder.o : lzip.h encoder.h fast_encoder.h +main.o : arg_parser.h lzip.h decoder.h encoder.h fast_encoder.h +lziprecover.o : arg_parser.h lzip.h decoder.h Makefile +unzcrash.o : arg_parser.h Makefile + + +doc : info man + +info : $(VPATH)/doc/$(pkgname).info + +$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texinfo + cd $(VPATH)/doc && makeinfo $(pkgname).texinfo + +man : $(VPATH)/doc/$(progname).1 $(VPATH)/doc/lziprecover.1 + +$(VPATH)/doc/$(progname).1 : $(progname) + help2man -n 'reduces the size of files' \ + -o $@ ./$(progname) + +$(VPATH)/doc/lziprecover.1 : lziprecover + help2man -n 'recovers data from damaged lzip files' \ + -o $@ --no-info ./lziprecover + +Makefile : $(VPATH)/configure $(VPATH)/Makefile.in + ./config.status + +check : all + @$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion) + +install : all install-info install-man + if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi + $(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(progname)" + $(INSTALL_PROGRAM) ./lziprecover "$(DESTDIR)$(bindir)/lziprecover" + +install-info : + if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi + $(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info" + -install-info --info-dir="$(DESTDIR)$(infodir)" $(DESTDIR)$(infodir)/$(pkgname).info + +install-man : + if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi + $(INSTALL_DATA) $(VPATH)/doc/$(progname).1 "$(DESTDIR)$(mandir)/man1/$(progname).1" + $(INSTALL_DATA) $(VPATH)/doc/lziprecover.1 "$(DESTDIR)$(mandir)/man1/lziprecover.1" + +install-strip : all + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install + +uninstall : uninstall-info uninstall-man + -rm -f "$(DESTDIR)$(bindir)/$(progname)" + -rm -f "$(DESTDIR)$(bindir)/lziprecover" + +uninstall-info : + -install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" + -rm -f "$(DESTDIR)$(infodir)/$(pkgname).info" + +uninstall-man : + -rm -f "$(DESTDIR)$(mandir)/man1/$(progname).1" + -rm -f "$(DESTDIR)$(mandir)/man1/lziprecover.1" + +dist : doc + ln -sf $(VPATH) $(DISTNAME) + tar -cvf $(DISTNAME).tar \ + $(DISTNAME)/AUTHORS \ + $(DISTNAME)/COPYING \ + $(DISTNAME)/ChangeLog \ + $(DISTNAME)/INSTALL \ + $(DISTNAME)/Makefile.in \ + $(DISTNAME)/NEWS \ + $(DISTNAME)/README \ + $(DISTNAME)/configure \ + $(DISTNAME)/doc/$(progname).1 \ + $(DISTNAME)/doc/lziprecover.1 \ + $(DISTNAME)/doc/$(pkgname).info \ + $(DISTNAME)/doc/$(pkgname).texinfo \ + $(DISTNAME)/testsuite/check.sh \ + $(DISTNAME)/testsuite/test.txt \ + $(DISTNAME)/testsuite/test_bad[1-5].lz \ + $(DISTNAME)/testsuite/test_sync.lz \ + $(DISTNAME)/testsuite/test_v[01].lz \ + $(DISTNAME)/testsuite/unzcrash.cc \ + $(DISTNAME)/*.h \ + $(DISTNAME)/*.cc + rm -f $(DISTNAME) + lzip -v -9 $(DISTNAME).tar + +clean : + -rm -f $(progname) $(progname)_profiled $(objs) + -rm -f lziprecover lziprecover.o unzcrash unzcrash.o + +distclean : clean + -rm -f Makefile config.status *.tar *.tar.lz diff --git a/third_party/lzma.js/lzip/NEWS b/third_party/lzma.js/lzip/NEWS new file mode 100644 index 00000000..affec93b --- /dev/null +++ b/third_party/lzma.js/lzip/NEWS @@ -0,0 +1,22 @@ +Changes in version 1.12: + +The option "-F, --recompress", which forces recompression of files whose +name already has the ".lz" or ".tlz" suffix, has been added. + +For large values of "--match-length", compression ratio has been +slightly increased and compression time has been reduced by up to 6%. + +Compression time of option "-0" has been reduced by 2%. + +Print only one status line for each multimember file when only one "-v" +is specified. + +Print up to 6 bytes of trailing garbage when "-vvvv" is specified. + +Do not show the message "and `--stdout' was not specified" for file +types that can't be read (directories, etc). + +If "--verbose" is not specified, lziprecover now only shows errors and +warnings. + +Options "--bits", "--position" and "--size" has been added to unzcrash. diff --git a/third_party/lzma.js/lzip/README b/third_party/lzma.js/lzip/README new file mode 100644 index 00000000..d075ab38 --- /dev/null +++ b/third_party/lzma.js/lzip/README @@ -0,0 +1,77 @@ +Description + +Lzip is a lossless data compressor based on the LZMA algorithm, with +very safe integrity checking and a user interface similar to the one of +gzip or bzip2. Lzip decompresses almost as fast as gzip and compresses +better than bzip2, which makes it well suited for software distribution +and data archiving. + +Lziprecover is a data recovery tool for lzip compressed files able to +repair slightly damaged files, recover badly damaged files from two or +more copies, and extract undamaged members from multi-member files. If +the cause of file corruption is damaged media, the combination GNU +ddrescue + lziprecover is the best option for recovering data from +multiple damaged copies. + +Lzip replaces every file given in the command line with a compressed +version of itself, with the name "original_name.lz". Each compressed +file has the same modification date, permissions, and, when possible, +ownership as the corresponding original, so that these properties can be +correctly restored at decompression time. Lzip is able to read from some +types of non regular files if the "--stdout" option is specified. + +If no file names are specified, lzip compresses (or decompresses) from +standard input to standard output. In this case, lzip will decline to +write compressed output to a terminal, as this would be entirely +incomprehensible and therefore pointless. + +Lzip will correctly decompress a file which is the concatenation of two +or more compressed files. The result is the concatenation of the +corresponding uncompressed files. Integrity testing of concatenated +compressed files is also supported. + +Lzip can produce multimember files and safely recover, with lziprecover, +the undamaged members in case of file damage. Lzip can also split the +compressed output in volumes of a given size, even when reading from +standard input. This allows the direct creation of multivolume +compressed tar archives. + +Lzip will automatically use the smallest possible dictionary size +without exceeding the given limit. Keep in mind that the decompression +memory requirement is affected at compression time by the choice of +dictionary size limit. + +As a self-check for your protection, lzip stores in the member trailer +the 32-bit CRC of the original data and the size of the original data, +to make sure that the decompressed version of the data is identical to +the original. This guards against corruption of the compressed data, and +against undetected bugs in lzip (hopefully very unlikely). The chances +of data corruption going undetected are microscopic, less than one +chance in 4000 million for each member processed. Be aware, though, that +the check occurs upon decompression, so it can only tell you that +something is wrong. It can't help you recover the original uncompressed +data. + +Lzip implements a simplified version of the LZMA (Lempel-Ziv-Markov +chain-Algorithm) algorithm. The high compression of LZMA comes from +combining two basic, well-proven compression ideas: sliding dictionaries +(LZ77/78) and markov models (the thing used by every compression +algorithm that uses a range encoder or similar order-0 entropy coder as +its last stage) with segregation of contexts according to what the bits +are used for. + +The ideas embodied in lzip are due to (at least) the following people: +Abraham Lempel and Jacob Ziv (for the LZ algorithm), Andrey Markov (for +the definition of Markov chains), G.N.N. Martin (for the definition of +range encoding), Igor Pavlov (for putting all the above together in +LZMA), and Julian Seward (for bzip2's CLI and the idea of unzcrash). + + +Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + +This file is free documentation: you have unlimited permission to copy, +distribute and modify it. + +The file Makefile.in is a data file used by configure to produce the +Makefile. It has the same copyright owner and permissions that configure +itself. diff --git a/third_party/lzma.js/lzip/config.status b/third_party/lzma.js/lzip/config.status new file mode 100755 index 00000000..610b2a05 --- /dev/null +++ b/third_party/lzma.js/lzip/config.status @@ -0,0 +1,8 @@ +#! /bin/sh +# This file was generated automatically by configure. Do not edit. +# Run this file to recreate the current configuration. +# +# This script is free software: you have unlimited permission +# to copy, distribute and modify it. + +exec /bin/sh ./configure --no-create diff --git a/third_party/lzma.js/lzip/configure b/third_party/lzma.js/lzip/configure new file mode 100755 index 00000000..8b291a6f --- /dev/null +++ b/third_party/lzma.js/lzip/configure @@ -0,0 +1,192 @@ +#! /bin/sh +# configure script for Lzip - Data compressor based on the LZMA algorithm +# Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. +# +# This configure script is free software: you have unlimited permission +# to copy, distribute and modify it. + +args= +no_create= +pkgname=lzip +pkgversion=1.12 +progname=lzip +srctrigger=lzip.h + +# clear some things potentially inherited from environment. +LC_ALL=C +export LC_ALL +srcdir= +prefix=/usr/local +exec_prefix='$(prefix)' +bindir='$(exec_prefix)/bin' +datadir='$(prefix)/share' +infodir='$(datadir)/info' +mandir='$(datadir)/man' +sysconfdir='$(prefix)/etc' +CXX= +CPPFLAGS= +CXXFLAGS='-Wall -W -O2' +LDFLAGS= + +# Loop over all args +while [ -n "$1" ] ; do + + # Get the first arg, and shuffle + option=$1 + shift + + # Add the argument quoted to args + args="${args} \"${option}\"" + + # Split out the argument for options that take them + case ${option} in + *=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,'` ;; + esac + + # Process the options + case ${option} in + --help | --he* | -h) + echo "Usage: configure [options]" + echo + echo "Options: [defaults in brackets]" + echo " -h, --help display this help and exit" + echo " -V, --version output version information and exit" + echo " --srcdir=DIR find the sources in DIR [. or ..]" + echo " --prefix=DIR install into DIR [${prefix}]" + echo " --exec-prefix=DIR base directory for arch-dependent files [${exec_prefix}]" + echo " --bindir=DIR user executables directory [${bindir}]" + echo " --datadir=DIR base directory for doc and data [${datadir}]" + echo " --infodir=DIR info files directory [${infodir}]" + echo " --mandir=DIR man pages directory [${mandir}]" + echo " --sysconfdir=DIR read-only single-machine data directory [${sysconfdir}]" + echo " CXX=COMPILER C++ compiler to use [g++]" + echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]" + echo " CXXFLAGS=OPTIONS command line options for the C++ compiler [${CXXFLAGS}]" + echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]" + echo + exit 0 ;; + --version | --ve* | -V) + echo "Configure script for ${pkgname} version ${pkgversion}" + exit 0 ;; + --srcdir* | --sr*) + srcdir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --prefix* | --pr*) + prefix=`echo ${optarg} | sed -e 's,/$,,'` ;; + --exec-prefix* | --ex*) + exec_prefix=`echo ${optarg} | sed -e 's,/$,,'` ;; + --bindir* | --bi*) + bindir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --datadir* | --da*) + datadir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --infodir* | --inf*) + infodir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --mandir* | --ma*) + mandir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --sysconfdir* | --sy*) + sysconfdir=`echo ${optarg} | sed -e 's,/$,,'` ;; + --no-create | --no-c*) + no_create=yes ;; + + CXX=*) CXX=${optarg} ;; + CPPFLAGS=*) CPPFLAGS=${optarg} ;; + CXXFLAGS=*) CXXFLAGS=${optarg} ;; + LDFLAGS=*) LDFLAGS=${optarg} ;; + + --* | *=* | *-*-*) ;; + *) + echo "configure: Unrecognized option: \"${option}\"; use --help for usage." 1>&2 + exit 1 ;; + esac +done + +# Find the source files, if location was not specified. +srcdirtext= +if [ -z "${srcdir}" ] ; then + srcdirtext="or . or .." ; srcdir=. + if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi + if [ ! -r ${srcdir}/${srctrigger} ] ; then + ## the sed command below emulates the dirname command + srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + fi +fi + +if [ ! -r ${srcdir}/${srctrigger} ] ; then + exec 1>&2 + echo + echo "configure: Can't find sources in ${srcdir} ${srcdirtext}" + echo "configure: (At least ${srctrigger} is missing)." + exit 1 +fi + +# Set srcdir to . if that's what it is. +if [ "`pwd`" = "`cd ${srcdir} ; pwd`" ] ; then srcdir=. ; fi + +# checking whether we are using GNU C++. +if [ -z "${CXX}" ] ; then # Let the user override the test. + if [ -x /bin/g++ ] || + [ -x /usr/bin/g++ ] || + [ -x /usr/local/bin/g++ ] ; then + CXX="g++" + else + CXX="c++" + fi +fi + +echo +if [ -z "${no_create}" ] ; then + echo "creating config.status" + rm -f config.status + cat > config.status << EOF +#! /bin/sh +# This file was generated automatically by configure. Do not edit. +# Run this file to recreate the current configuration. +# +# This script is free software: you have unlimited permission +# to copy, distribute and modify it. + +exec /bin/sh $0 ${args} --no-create +EOF + chmod +x config.status +fi + +echo "creating Makefile" +echo "VPATH = ${srcdir}" +echo "prefix = ${prefix}" +echo "exec_prefix = ${exec_prefix}" +echo "bindir = ${bindir}" +echo "datadir = ${datadir}" +echo "infodir = ${infodir}" +echo "mandir = ${mandir}" +echo "sysconfdir = ${sysconfdir}" +echo "CXX = ${CXX}" +echo "CPPFLAGS = ${CPPFLAGS}" +echo "CXXFLAGS = ${CXXFLAGS}" +echo "LDFLAGS = ${LDFLAGS}" +rm -f Makefile +cat > Makefile << EOF +# Makefile for Lzip - Data compressor based on the LZMA algorithm +# Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. +# This file was generated automatically by configure. Do not edit. +# +# This Makefile is free software: you have unlimited permission +# to copy, distribute and modify it. + +pkgname = ${pkgname} +pkgversion = ${pkgversion} +progname = ${progname} +VPATH = ${srcdir} +prefix = ${prefix} +exec_prefix = ${exec_prefix} +bindir = ${bindir} +datadir = ${datadir} +infodir = ${infodir} +mandir = ${mandir} +sysconfdir = ${sysconfdir} +CXX = ${CXX} +CPPFLAGS = ${CPPFLAGS} +CXXFLAGS = ${CXXFLAGS} +LDFLAGS = ${LDFLAGS} +EOF +cat ${srcdir}/Makefile.in >> Makefile + +echo "OK. Now you can run make." diff --git a/third_party/lzma.js/lzip/decoder.cc b/third_party/lzma.js/lzip/decoder.cc new file mode 100644 index 00000000..e0860c05 --- /dev/null +++ b/third_party/lzma.js/lzip/decoder.cc @@ -0,0 +1,252 @@ +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define _FILE_OFFSET_BITS 64 + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <unistd.h> + +#include "lzip.h" +#include "decoder.h" + + +const CRC32 crc32; + + +// Returns the number of bytes really read. +// If (returned value < size) and (errno == 0), means EOF was reached. +// +int readblock( const int fd, uint8_t * const buf, const int size ) + { + int rest = size; + errno = 0; + while( rest > 0 ) + { + errno = 0; + const int n = read( fd, buf + size - rest, rest ); + if( n > 0 ) rest -= n; + else if( n == 0 ) break; + else if( errno != EINTR && errno != EAGAIN ) break; + } + return ( rest > 0 ) ? size - rest : size; + } + + +// Returns the number of bytes really written. +// If (returned value < size), it is always an error. +// +int writeblock( const int fd, const uint8_t * const buf, const int size ) + { + int rest = size; + errno = 0; + while( rest > 0 ) + { + errno = 0; + const int n = write( fd, buf + size - rest, rest ); + if( n > 0 ) rest -= n; + else if( errno && errno != EINTR && errno != EAGAIN ) break; + } + return ( rest > 0 ) ? size - rest : size; + } + + +bool Range_decoder::read_block() + { + if( !at_stream_end ) + { + stream_pos = readblock( infd, buffer, buffer_size ); + if( stream_pos != buffer_size && errno ) exit(-1); + at_stream_end = ( stream_pos < buffer_size ); + partial_member_pos += pos; + pos = 0; + } + return pos < stream_pos; + } + + +void LZ_decoder::flush_data() + { + const int size = pos - stream_pos; + if( size > 0 ) + { + crc32.update( crc_, buffer + stream_pos, size ); + if( outfd >= 0 && + writeblock( outfd, buffer + stream_pos, size ) != size ) + exit(-1); + if( pos >= buffer_size ) { partial_data_pos += pos; pos = 0; } + stream_pos = pos; + } + } + + +bool LZ_decoder::verify_trailer() const + { + File_trailer trailer; + const int trailer_size = File_trailer::size( member_version ); + const long long member_size = range_decoder.member_position() + trailer_size; + bool error = false; + + for( int i = 0; i < trailer_size && !error; ++i ) + { + if( !range_decoder.finished() ) + trailer.data[i] = range_decoder.get_byte(); + else + { + error = true; + for( ; i < trailer_size; ++i ) trailer.data[i] = 0; + } + } + if( member_version == 0 ) trailer.member_size( member_size ); + if( !range_decoder.code_is_zero() ) + { + error = true; + pp( "Range decoder final code is not zero" ); + } + if( trailer.data_crc() != crc() ) + { + error = true; + } + if( trailer.data_size() != data_position() ) + { + error = true; + } + if( trailer.member_size() != member_size ) + { + error = true; + } + return !error; + } + + +// Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF, +// 3 = trailer error, 4 = unknown marker found. +int LZ_decoder::decode_member() + { + Bit_model bm_match[State::states][pos_states]; + Bit_model bm_rep[State::states]; + Bit_model bm_rep0[State::states]; + Bit_model bm_rep1[State::states]; + Bit_model bm_rep2[State::states]; + Bit_model bm_len[State::states][pos_states]; + Bit_model bm_dis_slot[max_dis_states][1<<dis_slot_bits]; + Bit_model bm_dis[modeled_distances-end_dis_model+1]; + Bit_model bm_align[dis_align_size]; + + unsigned int rep0 = 0; // rep[0-3] latest four distances + unsigned int rep1 = 0; // used for efficient coding of + unsigned int rep2 = 0; // repeated distances + unsigned int rep3 = 0; + + Len_decoder len_decoder; + Len_decoder rep_match_len_decoder; + Literal_decoder literal_decoder; + State state; + range_decoder.load(); + + while( true ) + { + if( range_decoder.finished() ) { flush_data(); return 2; } + const int pos_state = data_position() & pos_state_mask; + if( range_decoder.decode_bit( bm_match[state()][pos_state] ) == 0 ) + { + const uint8_t prev_byte = get_prev_byte(); + if( state.is_char() ) + put_byte( literal_decoder.decode( range_decoder, prev_byte ) ); + else + put_byte( literal_decoder.decode_matched( range_decoder, prev_byte, + get_byte( rep0 ) ) ); + state.set_char(); + } + else + { + int len; + if( range_decoder.decode_bit( bm_rep[state()] ) == 1 ) + { + len = 0; + if( range_decoder.decode_bit( bm_rep0[state()] ) == 1 ) + { + unsigned int distance; + if( range_decoder.decode_bit( bm_rep1[state()] ) == 0 ) + distance = rep1; + else + { + if( range_decoder.decode_bit( bm_rep2[state()] ) == 0 ) + distance = rep2; + else { distance = rep3; rep3 = rep2; } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + else + { + if( range_decoder.decode_bit( bm_len[state()][pos_state] ) == 0 ) + { state.set_short_rep(); len = 1; } + } + if( len == 0 ) + { + state.set_rep(); + len = min_match_len + rep_match_len_decoder.decode( range_decoder, pos_state ); + } + } + else + { + const unsigned int rep0_saved = rep0; + len = min_match_len + len_decoder.decode( range_decoder, pos_state ); + const int dis_slot = range_decoder.decode_tree( bm_dis_slot[get_dis_state(len)], dis_slot_bits ); + if( dis_slot < start_dis_model ) rep0 = dis_slot; + else + { + const int direct_bits = ( dis_slot >> 1 ) - 1; + rep0 = ( 2 | ( dis_slot & 1 ) ) << direct_bits; + if( dis_slot < end_dis_model ) + rep0 += range_decoder.decode_tree_reversed( bm_dis + rep0 - dis_slot, direct_bits ); + else + { + rep0 += range_decoder.decode( direct_bits - dis_align_bits ) << dis_align_bits; + rep0 += range_decoder.decode_tree_reversed( bm_align, dis_align_bits ); + if( rep0 == 0xFFFFFFFFU ) // Marker found + { + rep0 = rep0_saved; + range_decoder.normalize(); + flush_data(); + if( len == min_match_len ) // End Of Stream marker + { + if( verify_trailer() ) return 0; else return 3; + } + if( len == min_match_len + 1 ) // Sync Flush marker + { + range_decoder.load(); continue; + } + return 4; + } + } + } + rep3 = rep2; rep2 = rep1; rep1 = rep0_saved; + state.set_match(); + if( rep0 >= (unsigned int)dictionary_size || + ( rep0 >= (unsigned int)pos && !partial_data_pos ) ) + { flush_data(); return 1; } + } + copy_block( rep0, len ); + } + } + } diff --git a/third_party/lzma.js/lzip/decoder.h b/third_party/lzma.js/lzip/decoder.h new file mode 100644 index 00000000..25e279eb --- /dev/null +++ b/third_party/lzma.js/lzip/decoder.h @@ -0,0 +1,268 @@ +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +class Range_decoder + { + enum { buffer_size = 16384 }; + long long partial_member_pos; + uint8_t * const buffer; // input buffer + int pos; // current pos in buffer + int stream_pos; // when reached, a new block must be read + uint32_t code; + uint32_t range; + const int infd; // input file descriptor + bool at_stream_end; + + bool read_block(); + +public: + Range_decoder( const int ifd ) + : + partial_member_pos( 0 ), + buffer( new uint8_t[buffer_size] ), + pos( 0 ), + stream_pos( 0 ), + code( 0 ), + range( 0xFFFFFFFFU ), + infd( ifd ), + at_stream_end( false ) {} + + ~Range_decoder() { delete[] buffer; } + + bool code_is_zero() const { return ( code == 0 ); } + bool finished() { return pos >= stream_pos && !read_block(); } + long long member_position() const + { return partial_member_pos + pos; } + void reset_member_position() + { partial_member_pos = -pos; } + + uint8_t get_byte() + { + if( finished() ) return 0x55; // make code != 0 + return buffer[pos++]; + } + + void load() + { + code = 0; + range = 0xFFFFFFFFU; + for( int i = 0; i < 5; ++i ) code = (code << 8) | get_byte(); + } + + void normalize() + { + if( range <= 0x00FFFFFFU ) + { range <<= 8; code = (code << 8) | get_byte(); } + } + + int decode( const int num_bits ) + { + int symbol = 0; + for( int i = num_bits; i > 0; --i ) + { + symbol <<= 1; + if( range <= 0x00FFFFFFU ) + { + range <<= 7; code = (code << 8) | get_byte(); + if( code >= range ) { code -= range; symbol |= 1; } + } + else + { + range >>= 1; + if( code >= range ) { code -= range; symbol |= 1; } + } + } + return symbol; + } + + int decode_bit( Bit_model & bm ) + { + normalize(); + const uint32_t bound = ( range >> bit_model_total_bits ) * bm.probability; + if( code < bound ) + { + range = bound; + bm.probability += (bit_model_total - bm.probability) >> bit_model_move_bits; + return 0; + } + else + { + range -= bound; + code -= bound; + bm.probability -= bm.probability >> bit_model_move_bits; + return 1; + } + } + + int decode_tree( Bit_model bm[], const int num_bits ) + { + int model = 1; + for( int i = num_bits; i > 0; --i ) + model = ( model << 1 ) | decode_bit( bm[model] ); + return model - (1 << num_bits); + } + + int decode_tree_reversed( Bit_model bm[], const int num_bits ) + { + int model = 1; + int symbol = 0; + for( int i = 0; i < num_bits; ++i ) + { + const int bit = decode_bit( bm[model] ); + model <<= 1; + if( bit ) { model |= 1; symbol |= (1 << i); } + } + return symbol; + } + + int decode_matched( Bit_model bm[], const int match_byte ) + { + Bit_model * const bm1 = bm + 0x100; + int symbol = 1; + for( int i = 7; i >= 0; --i ) + { + const int match_bit = ( match_byte >> i ) & 1; + const int bit = decode_bit( bm1[(match_bit<<8)+symbol] ); + symbol = ( symbol << 1 ) | bit; + if( match_bit != bit ) + { + while( --i >= 0 ) + symbol = ( symbol << 1 ) | decode_bit( bm[symbol] ); + break; + } + } + return symbol & 0xFF; + } + }; + + +class Len_decoder + { + Bit_model choice1; + Bit_model choice2; + Bit_model bm_low[pos_states][len_low_symbols]; + Bit_model bm_mid[pos_states][len_mid_symbols]; + Bit_model bm_high[len_high_symbols]; + +public: + int decode( Range_decoder & range_decoder, const int pos_state ) + { + if( range_decoder.decode_bit( choice1 ) == 0 ) + return range_decoder.decode_tree( bm_low[pos_state], len_low_bits ); + if( range_decoder.decode_bit( choice2 ) == 0 ) + return len_low_symbols + + range_decoder.decode_tree( bm_mid[pos_state], len_mid_bits ); + return len_low_symbols + len_mid_symbols + + range_decoder.decode_tree( bm_high, len_high_bits ); + } + }; + + +class Literal_decoder + { + Bit_model bm_literal[1<<literal_context_bits][0x300]; + + int lstate( const int prev_byte ) const + { return ( prev_byte >> ( 8 - literal_context_bits ) ); } + +public: + uint8_t decode( Range_decoder & range_decoder, const uint8_t prev_byte ) + { return range_decoder.decode_tree( bm_literal[lstate(prev_byte)], 8 ); } + + uint8_t decode_matched( Range_decoder & range_decoder, + const uint8_t prev_byte, const uint8_t match_byte ) + { return range_decoder.decode_matched( bm_literal[lstate(prev_byte)], + match_byte ); } + }; + + +class LZ_decoder + { + long long partial_data_pos; + const int dictionary_size; + const int buffer_size; + uint8_t * const buffer; // output buffer + int pos; // current pos in buffer + int stream_pos; // first byte not yet written to file + uint32_t crc_; + const int outfd; // output file descriptor + const int member_version; + Range_decoder & range_decoder; + + void flush_data(); + bool verify_trailer() const; + + uint8_t get_prev_byte() const + { + const int i = ( ( pos > 0 ) ? pos : buffer_size ) - 1; + return buffer[i]; + } + + uint8_t get_byte( const int distance ) const + { + int i = pos - distance - 1; + if( i < 0 ) i += buffer_size; + return buffer[i]; + } + + void put_byte( const uint8_t b ) + { + buffer[pos] = b; + if( ++pos >= buffer_size ) flush_data(); + } + + void copy_block( const int distance, int len ) + { + int i = pos - distance - 1; + if( i < 0 ) i += buffer_size; + if( len < buffer_size - max( pos, i ) && len <= abs( pos - i ) ) + { + memcpy( buffer + pos, buffer + i, len ); + pos += len; + } + else for( ; len > 0; --len ) + { + buffer[pos] = buffer[i]; + if( ++pos >= buffer_size ) flush_data(); + if( ++i >= buffer_size ) i = 0; + } + } + +public: + LZ_decoder( const File_header & header, Range_decoder & rdec, const int ofd ) + : + partial_data_pos( 0 ), + dictionary_size( header.dictionary_size() ), + buffer_size( max( 65536, dictionary_size ) ), + buffer( new uint8_t[buffer_size] ), + pos( 0 ), + stream_pos( 0 ), + crc_( 0xFFFFFFFFU ), + outfd( ofd ), + member_version( header.version() ), + range_decoder( rdec ) + { buffer[buffer_size-1] = 0; } // prev_byte of first_byte + + ~LZ_decoder() { delete[] buffer; } + + uint32_t crc() const { return crc_ ^ 0xFFFFFFFFU; } + + long long data_position() const + { return partial_data_pos + pos; } + + int decode_member(); + }; diff --git a/third_party/lzma.js/lzip/encoder.cc b/third_party/lzma.js/lzip/encoder.cc new file mode 100644 index 00000000..f4f0ef30 --- /dev/null +++ b/third_party/lzma.js/lzip/encoder.cc @@ -0,0 +1,643 @@ +#if !DECODER_ONLY + +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define _FILE_OFFSET_BITS 64 + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include "lzip.h" +#include "encoder.h" + + +Dis_slots dis_slots; +Prob_prices prob_prices; + + +bool Matchfinder::read_block() + { + if( !at_stream_end && stream_pos < buffer_size ) + { + const int size = buffer_size - stream_pos; + const int rd = readblock( infd, buffer + stream_pos, size ); + stream_pos += rd; + if( rd != size && errno ) throw Error( "Read error" ); + at_stream_end = ( rd < size ); + } + return pos < stream_pos; + } + + +Matchfinder::Matchfinder( const int dict_size, const int len_limit, + const int ifd ) + : + partial_data_pos( 0 ), + prev_positions( new int32_t[num_prev_positions] ), + pos( 0 ), + cyclic_pos( 0 ), + stream_pos( 0 ), + match_len_limit_( len_limit ), + cycles( ( len_limit < max_match_len ) ? 16 + ( len_limit / 2 ) : 256 ), + infd( ifd ), + at_stream_end( false ) + { + const int buffer_size_limit = ( 2 * dict_size ) + before_size + after_size; + buffer_size = max( 65536, dict_size ); + buffer = (uint8_t *)malloc( buffer_size ); + if( !buffer ) exit(-1); + if( read_block() && !at_stream_end && buffer_size < buffer_size_limit ) + { + buffer_size = buffer_size_limit; + buffer = (uint8_t *)realloc( buffer, buffer_size ); + if( !buffer ) exit(-1); + read_block(); + } + if( at_stream_end && stream_pos < dict_size ) + dictionary_size_ = max( (int)min_dictionary_size, stream_pos ); + else dictionary_size_ = dict_size; + pos_limit = buffer_size; + if( !at_stream_end ) pos_limit -= after_size; + prev_pos_tree = new int32_t[2*dictionary_size_]; + for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; + } + + +void Matchfinder::reset() + { + const int size = stream_pos - pos; + if( size > 0 ) memmove( buffer, buffer + pos, size ); + partial_data_pos = 0; + stream_pos -= pos; + pos = 0; + cyclic_pos = 0; + for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; + read_block(); + } + + +void Matchfinder::move_pos() + { + if( ++cyclic_pos >= dictionary_size_ ) cyclic_pos = 0; + if( ++pos >= pos_limit ) + { + if( pos > stream_pos ) + internal_error( "pos > stream_pos in Matchfinder::move_pos" ); + if( !at_stream_end ) + { + const int offset = pos - dictionary_size_ - before_size; + const int size = stream_pos - offset; + memmove( buffer, buffer + offset, size ); + partial_data_pos += offset; + pos -= offset; + stream_pos -= offset; + for( int i = 0; i < num_prev_positions; ++i ) + if( prev_positions[i] >= 0 ) prev_positions[i] -= offset; + for( int i = 0; i < 2 * dictionary_size_; ++i ) + if( prev_pos_tree[i] >= 0 ) prev_pos_tree[i] -= offset; + read_block(); + } + } + } + + +int Matchfinder::longest_match_len( int * const distances ) throw() + { + int len_limit = match_len_limit_; + if( len_limit > available_bytes() ) + { + len_limit = available_bytes(); + if( len_limit < 4 ) return 0; + } + + int maxlen = min_match_len - 1; + const int min_pos = (pos >= dictionary_size_) ? + (pos - dictionary_size_ + 1) : 0; + const uint8_t * const data = buffer + pos; + const int key2 = num_prev_positions4 + num_prev_positions3 + + ( ( (int)data[0] << 8 ) | data[1] ); + const uint32_t tmp = crc32[data[0]] ^ data[1] ^ ( (uint32_t)data[2] << 8 ); + const int key3 = num_prev_positions4 + + (int)( tmp & ( num_prev_positions3 - 1 ) ); + const int key4 = (int)( ( tmp ^ ( crc32[data[3]] << 5 ) ) & + ( num_prev_positions4 - 1 ) ); + + if( distances ) + { + int np = prev_positions[key2]; + if( np >= min_pos ) + { distances[2] = pos - np - 1; maxlen = 2; } + else distances[2] = 0x7FFFFFFF; + np = prev_positions[key3]; + if( np >= min_pos && buffer[np] == data[0] ) + { distances[3] = pos - np - 1; maxlen = 3; } + else distances[3] = 0x7FFFFFFF; + distances[4] = 0x7FFFFFFF; + } + + prev_positions[key2] = pos; + prev_positions[key3] = pos; + int newpos = prev_positions[key4]; + prev_positions[key4] = pos; + + int32_t * ptr0 = prev_pos_tree + ( cyclic_pos << 1 ); + int32_t * ptr1 = ptr0 + 1; + int len = 0, len0 = 0, len1 = 0; + + for( int count = cycles; ; ) + { + if( newpos < min_pos || --count < 0 ) { *ptr0 = *ptr1 = -1; break; } + const uint8_t * const newdata = buffer + newpos; + while( len < len_limit && newdata[len] == data[len] ) ++len; + + const int delta = pos - newpos; + if( distances ) while( maxlen < len ) distances[++maxlen] = delta - 1; + + int32_t * const newptr = prev_pos_tree + + ( ( cyclic_pos - delta + + ( ( cyclic_pos >= delta ) ? 0 : dictionary_size_ ) ) << 1 ); + + if( len < len_limit ) + { + if( newdata[len] < data[len] ) + { + *ptr0 = newpos; + ptr0 = newptr + 1; + newpos = *ptr0; + len0 = len; if( len1 < len ) len = len1; + } + else + { + *ptr1 = newpos; + ptr1 = newptr; + newpos = *ptr1; + len1 = len; if( len0 < len ) len = len0; + } + } + else + { + *ptr0 = newptr[0]; + *ptr1 = newptr[1]; + break; + } + } + if( distances ) + { + if( distances[3] > distances[4] ) distances[3] = distances[4]; + if( distances[2] > distances[3] ) distances[2] = distances[3]; + } + return maxlen; + } + + +void Range_encoder::flush_data() + { + if( pos > 0 ) + { + if( outfd >= 0 && writeblock( outfd, buffer, pos ) != pos ) + throw Error( "Write error" ); + partial_member_pos += pos; + pos = 0; + } + } + + +void Len_encoder::encode( Range_encoder & range_encoder, int symbol, + const int pos_state ) + { + symbol -= min_match_len; + if( symbol < len_low_symbols ) + { + range_encoder.encode_bit( choice1, 0 ); + range_encoder.encode_tree( bm_low[pos_state], symbol, len_low_bits ); + } + else + { + range_encoder.encode_bit( choice1, 1 ); + if( symbol < len_low_symbols + len_mid_symbols ) + { + range_encoder.encode_bit( choice2, 0 ); + range_encoder.encode_tree( bm_mid[pos_state], symbol - len_low_symbols, len_mid_bits ); + } + else + { + range_encoder.encode_bit( choice2, 1 ); + range_encoder.encode_tree( bm_high, symbol - len_low_symbols - len_mid_symbols, len_high_bits ); + } + } + if( --counters[pos_state] <= 0 ) update_prices( pos_state ); + } + + +void LZ_encoder::fill_align_prices() throw() + { + for( int i = 0; i < dis_align_size; ++i ) + align_prices[i] = price_symbol_reversed( bm_align, i, dis_align_bits ); + align_price_count = dis_align_size; + } + + +void LZ_encoder::fill_distance_prices() throw() + { + for( int dis = start_dis_model; dis < modeled_distances; ++dis ) + { + const int dis_slot = dis_slots.table( dis ); + const int direct_bits = ( dis_slot >> 1 ) - 1; + const int base = ( 2 | ( dis_slot & 1 ) ) << direct_bits; + const int price = + price_symbol_reversed( bm_dis + base - dis_slot, dis - base, direct_bits ); + for( int dis_state = 0; dis_state < max_dis_states; ++dis_state ) + dis_prices[dis_state][dis] = price; + } + + for( int dis_state = 0; dis_state < max_dis_states; ++dis_state ) + { + int * const dsp = dis_slot_prices[dis_state]; + const Bit_model * const bmds = bm_dis_slot[dis_state]; + int slot = 0; + for( ; slot < end_dis_model && slot < num_dis_slots; ++slot ) + dsp[slot] = price_symbol( bmds, slot, dis_slot_bits ); + for( ; slot < num_dis_slots; ++slot ) + dsp[slot] = price_symbol( bmds, slot, dis_slot_bits ) + + (((( slot >> 1 ) - 1 ) - dis_align_bits ) << price_shift ); + + int * const dp = dis_prices[dis_state]; + int dis = 0; + for( ; dis < start_dis_model; ++dis ) + dp[dis] = dsp[dis]; + for( ; dis < modeled_distances; ++dis ) + dp[dis] += dsp[dis_slots.table( dis )]; + } + } + + +// Return value == number of bytes advanced (ahead). +// trials[0]..trials[retval-1] contain the steps to encode. +// ( trials[0].dis == -1 && trials[0].price == 1 ) means literal. +int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances], + const State & state ) + { + int main_len; + if( longest_match_found > 0 ) // from previous call + { + main_len = longest_match_found; + longest_match_found = 0; + } + else main_len = read_match_distances(); + + int replens[num_rep_distances]; + int rep_index = 0; + for( int i = 0; i < num_rep_distances; ++i ) + { + replens[i] = matchfinder.true_match_len( 0, reps[i] + 1, max_match_len ); + if( replens[i] > replens[rep_index] ) rep_index = i; + } + if( replens[rep_index] >= matchfinder.match_len_limit() ) + { + trials[0].dis = rep_index; + trials[0].price = replens[rep_index]; + move_pos( replens[rep_index], true ); + return replens[rep_index]; + } + + if( main_len >= matchfinder.match_len_limit() ) + { + trials[0].dis = match_distances[matchfinder.match_len_limit()] + + num_rep_distances; + trials[0].price = main_len; + move_pos( main_len, true ); + return main_len; + } + + { + const int pos_state = matchfinder.data_position() & pos_state_mask; + const uint8_t prev_byte = matchfinder[-1]; + const uint8_t cur_byte = matchfinder[0]; + const uint8_t match_byte = matchfinder[-reps[0]-1]; + + trials[0].state = state; + for( int i = 0; i < num_rep_distances; ++i ) trials[0].reps[i] = reps[i]; + trials[1].dis = -1; + trials[1].prev_index = 0; + trials[1].price = price0( bm_match[state()][pos_state] ); + if( state.is_char() ) + trials[1].price += literal_encoder.price_symbol( prev_byte, cur_byte ); + else + trials[1].price += literal_encoder.price_matched( prev_byte, cur_byte, match_byte ); + + const int match_price = price1( bm_match[state()][pos_state] ); + const int rep_match_price = match_price + price1( bm_rep[state()] ); + + if( match_byte == cur_byte ) + trials[1].update( 0, 0, rep_match_price + price_rep_len1( state, pos_state ) ); + + if( main_len < min_match_len ) + { + trials[0].dis = trials[1].dis; + trials[0].price = 1; + matchfinder.move_pos(); + return 1; + } + + if( main_len <= replens[rep_index] ) + { + main_len = replens[rep_index]; + for( int len = min_match_len; len <= main_len; ++len ) + trials[len].price = infinite_price; + } + else + { + const int normal_match_price = match_price + price0( bm_rep[state()] ); + for( int len = min_match_len; len <= main_len; ++len ) + { + trials[len].dis = match_distances[len] + num_rep_distances; + trials[len].prev_index = 0; + trials[len].price = normal_match_price + + price_pair( match_distances[len], len, pos_state ); + } + } + + for( int rep = 0; rep < num_rep_distances; ++rep ) + { + const int price = rep_match_price + + price_rep( rep, state, pos_state ); + for( int len = min_match_len; len <= replens[rep]; ++len ) + trials[len].update( rep, 0, price + + rep_match_len_encoder.price( len, pos_state ) ); + } + } + + int cur = 0; + int num_trials = main_len; + matchfinder.move_pos(); + + while( true ) + { + if( ++cur >= num_trials ) // no more initialized trials + { + backward( cur ); + return cur; + } + const int newlen = read_match_distances(); + if( newlen >= matchfinder.match_len_limit() ) + { + longest_match_found = newlen; + backward( cur ); + return cur; + } + + Trial & cur_trial = trials[cur]; + const int prev_index = cur_trial.prev_index; + + cur_trial.state = trials[prev_index].state; + + for( int i = 0; i < num_rep_distances; ++i ) + cur_trial.reps[i] = trials[prev_index].reps[i]; + if( prev_index == cur - 1 ) + { + if( cur_trial.dis == 0 ) cur_trial.state.set_short_rep(); + else cur_trial.state.set_char(); + } + else + { + if( cur_trial.dis < num_rep_distances ) cur_trial.state.set_rep(); + else cur_trial.state.set_match(); + mtf_reps( cur_trial.dis, cur_trial.reps ); + } + + const int pos_state = matchfinder.data_position() & pos_state_mask; + const uint8_t prev_byte = matchfinder[-1]; + const uint8_t cur_byte = matchfinder[0]; + const uint8_t match_byte = matchfinder[-cur_trial.reps[0]-1]; + + int next_price = cur_trial.price + + price0( bm_match[cur_trial.state()][pos_state] ); + if( cur_trial.state.is_char() ) + next_price += literal_encoder.price_symbol( prev_byte, cur_byte ); + else + next_price += literal_encoder.price_matched( prev_byte, cur_byte, match_byte ); + matchfinder.move_pos(); + + Trial & next_trial = trials[cur+1]; + + next_trial.update( -1, cur, next_price ); + + const int match_price = cur_trial.price + price1( bm_match[cur_trial.state()][pos_state] ); + const int rep_match_price = match_price + price1( bm_rep[cur_trial.state()] ); + + if( match_byte == cur_byte && next_trial.dis != 0 ) + next_trial.update( 0, cur, rep_match_price + + price_rep_len1( cur_trial.state, pos_state ) ); + + const int len_limit = min( min( max_num_trials - 1 - cur, + matchfinder.available_bytes() ), matchfinder.match_len_limit() ); + if( len_limit < min_match_len ) continue; + + for( int rep = 0; rep < num_rep_distances; ++rep ) + { + const int dis = cur_trial.reps[rep] + 1; + int len = 0; + const uint8_t * const data = matchfinder.ptr_to_current_pos() - 1; + while( len < len_limit && data[len] == data[len-dis] ) ++len; + if( len >= min_match_len ) + { + const int price = rep_match_price + + price_rep( rep, cur_trial.state, pos_state ); + while( num_trials < cur + len ) + trials[++num_trials].price = infinite_price; + for( ; len >= min_match_len; --len ) + trials[cur+len].update( rep, cur, price + + rep_match_len_encoder.price( len, pos_state ) ); + } + } + + if( newlen <= len_limit && + ( newlen > min_match_len || + ( newlen == min_match_len && + match_distances[min_match_len] < modeled_distances ) ) ) + { + const int normal_match_price = match_price + + price0( bm_rep[cur_trial.state()] ); + while( num_trials < cur + newlen ) + trials[++num_trials].price = infinite_price; + + int dis = match_distances[min_match_len]; + int dis_state = get_dis_state( min_match_len ); + int dis_price = infinite_price; + if( dis < modeled_distances ) + trials[cur+min_match_len].update( dis + num_rep_distances, cur, + normal_match_price + dis_prices[dis_state][dis] + + len_encoder.price( min_match_len, pos_state ) ); + for( int len = min_match_len + 1; len <= newlen; ++len ) + { + if( dis != match_distances[len] || dis_state < max_dis_states - 1 ) + { + dis = match_distances[len]; + dis_state = get_dis_state( len ); + dis_price = price_dis( dis, dis_state ); + } + trials[cur+len].update( dis + num_rep_distances, cur, + normal_match_price + dis_price + + len_encoder.price( len, pos_state ) ); + } + } + } + } + + + // End Of Stream mark => (dis == 0xFFFFFFFFU, len == min_match_len) +void LZ_encoder::full_flush( const State & state ) + { + const int pos_state = matchfinder.data_position() & pos_state_mask; + range_encoder.encode_bit( bm_match[state()][pos_state], 1 ); + range_encoder.encode_bit( bm_rep[state()], 0 ); + encode_pair( 0xFFFFFFFFU, min_match_len, pos_state ); + range_encoder.flush(); + File_trailer trailer; + trailer.data_crc( crc() ); + trailer.data_size( matchfinder.data_position() ); + trailer.member_size( range_encoder.member_position() + File_trailer::size() ); + for( int i = 0; i < File_trailer::size(); ++i ) + range_encoder.put_byte( trailer.data[i] ); + range_encoder.flush_data(); + } + + +LZ_encoder::LZ_encoder( Matchfinder & mf, const File_header & header, + const int outfd ) + : + longest_match_found( 0 ), + crc_( 0xFFFFFFFFU ), + matchfinder( mf ), + range_encoder( outfd ), + len_encoder( matchfinder.match_len_limit() ), + rep_match_len_encoder( matchfinder.match_len_limit() ), + num_dis_slots( 2 * real_bits( matchfinder.dictionary_size() - 1 ) ) + { + fill_align_prices(); + + for( int i = 0; i < File_header::size; ++i ) + range_encoder.put_byte( header.data[i] ); + } + + +bool LZ_encoder::encode_member( const long long member_size ) + { + const long long member_size_limit = + member_size - File_trailer::size() - max_marker_size; + const int fill_count = ( matchfinder.match_len_limit() > 12 ) ? 512 : 2048; + int fill_counter = 0; + int rep_distances[num_rep_distances]; + State state; + for( int i = 0; i < num_rep_distances; ++i ) rep_distances[i] = 0; + + if( matchfinder.data_position() != 0 || + range_encoder.member_position() != File_header::size ) + return false; // can be called only once + + if( !matchfinder.finished() ) // encode first byte + { + const uint8_t prev_byte = 0; + const uint8_t cur_byte = matchfinder[0]; + range_encoder.encode_bit( bm_match[state()][0], 0 ); + literal_encoder.encode( range_encoder, prev_byte, cur_byte ); + crc32.update( crc_, cur_byte ); + move_pos( 1 ); + } + + while( true ) + { + if( matchfinder.finished() ) { full_flush( state ); return true; } + if( fill_counter <= 0 ) + { fill_distance_prices(); fill_counter = fill_count; } + + int ahead = sequence_optimizer( rep_distances, state ); + if( ahead <= 0 ) return false; + fill_counter -= ahead; + + for( int i = 0; ; ) + { + const int pos_state = + ( matchfinder.data_position() - ahead ) & pos_state_mask; + const int dis = trials[i].dis; + const int len = trials[i].price; + + bool bit = ( dis < 0 && len == 1 ); + range_encoder.encode_bit( bm_match[state()][pos_state], !bit ); + if( bit ) // literal byte + { + const uint8_t prev_byte = matchfinder[-ahead-1]; + const uint8_t cur_byte = matchfinder[-ahead]; + crc32.update( crc_, cur_byte ); + if( state.is_char() ) + literal_encoder.encode( range_encoder, prev_byte, cur_byte ); + else + { + const uint8_t match_byte = matchfinder[-ahead-rep_distances[0]-1]; + literal_encoder.encode_matched( range_encoder, + prev_byte, cur_byte, match_byte ); + } + state.set_char(); + } + else // match or repeated match + { + crc32.update( crc_, matchfinder.ptr_to_current_pos() - ahead, len ); + mtf_reps( dis, rep_distances ); + bit = ( dis < num_rep_distances ); + range_encoder.encode_bit( bm_rep[state()], bit ); + if( bit ) + { + bit = ( dis == 0 ); + range_encoder.encode_bit( bm_rep0[state()], !bit ); + if( bit ) + range_encoder.encode_bit( bm_len[state()][pos_state], len > 1 ); + else + { + range_encoder.encode_bit( bm_rep1[state()], dis > 1 ); + if( dis > 1 ) + range_encoder.encode_bit( bm_rep2[state()], dis > 2 ); + } + if( len == 1 ) state.set_short_rep(); + else + { + rep_match_len_encoder.encode( range_encoder, len, pos_state ); + state.set_rep(); + } + } + else + { + encode_pair( dis - num_rep_distances, len, pos_state ); + state.set_match(); + } + } + ahead -= len; i += len; + if( range_encoder.member_position() >= member_size_limit ) + { + if( !matchfinder.dec_pos( ahead ) ) return false; + full_flush( state ); + return true; + } + if( ahead <= 0 ) break; + } + } + } + +#endif + diff --git a/third_party/lzma.js/lzip/encoder.h b/third_party/lzma.js/lzip/encoder.h new file mode 100644 index 00000000..2c445407 --- /dev/null +++ b/third_party/lzma.js/lzip/encoder.h @@ -0,0 +1,582 @@ +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +enum { max_num_trials = 1 << 12, + price_shift = 6 }; + +class Dis_slots + { + unsigned char data[1<<12]; + +public: + void init() throw() + { + for( int slot = 0; slot < 4; ++slot ) data[slot] = slot; + for( int i = 4, size = 2, slot = 4; slot < 24; slot += 2 ) + { + memset( &data[i], slot, size ); + memset( &data[i+size], slot + 1, size ); + size <<= 1; + i += size; + } + } + + unsigned char table( const int dis ) const throw() { return data[dis]; } + + int operator[]( const uint32_t dis ) const throw() + { + if( dis < (1 << 12) ) return data[dis]; + if( dis < (1 << 23) ) return data[dis>>11] + 22; + return data[dis>>22] + 44; + } + }; + +extern Dis_slots dis_slots; + + +class Prob_prices + { + int data[bit_model_total >> 2]; + +public: + void init() throw() + { + const int num_bits = ( bit_model_total_bits - 2 ); + int j = 1, end = 2; + data[0] = bit_model_total_bits << price_shift; + for( int i = num_bits - 1; i >= 0; --i, end <<= 1 ) + { + for( ; j < end; ++j ) + data[j] = ( i << price_shift ) + + ( ( (end - j) << price_shift ) >> ( num_bits - i - 1 ) ); + } + } + + int operator[]( const int probability ) const throw() + { return data[probability >> 2]; } + }; + +extern Prob_prices prob_prices; + + +inline int price0( const Bit_model & bm ) throw() + { return prob_prices[bm.probability]; } + +inline int price1( const Bit_model & bm ) throw() + { return prob_prices[bit_model_total-bm.probability]; } + +inline int price_bit( const Bit_model & bm, const int bit ) throw() + { if( bit ) return price1( bm ); else return price0( bm ); } + + +inline int price_symbol( const Bit_model bm[], int symbol, const int num_bits ) throw() + { + int price = 0; + symbol |= ( 1 << num_bits ); + while( symbol > 1 ) + { + const int bit = symbol & 1; + symbol >>= 1; + price += price_bit( bm[symbol], bit ); + } + return price; + } + + +inline int price_symbol_reversed( const Bit_model bm[], int symbol, + const int num_bits ) throw() + { + int price = 0; + int model = 1; + for( int i = num_bits; i > 0; --i ) + { + const int bit = symbol & 1; + symbol >>= 1; + price += price_bit( bm[model], bit ); + model = ( model << 1 ) | bit; + } + return price; + } + + +inline int price_matched( const Bit_model bm[], const int symbol, + const int match_byte ) throw() + { + int price = 0; + int model = 1; + + for( int i = 7; i >= 0; --i ) + { + const int match_bit = ( match_byte >> i ) & 1; + int bit = ( symbol >> i ) & 1; + price += price_bit( bm[(match_bit<<8)+model+0x100], bit ); + model = ( model << 1 ) | bit; + if( match_bit != bit ) + { + while( --i >= 0 ) + { + bit = ( symbol >> i ) & 1; + price += price_bit( bm[model], bit ); + model = ( model << 1 ) | bit; + } + break; + } + } + return price; + } + + +class Matchfinder + { + enum { // bytes to keep in buffer before dictionary + before_size = max_num_trials + 1, + // bytes to keep in buffer after pos + after_size = max_match_len, + num_prev_positions4 = 1 << 20, + num_prev_positions3 = 1 << 18, + num_prev_positions2 = 1 << 16, + num_prev_positions = num_prev_positions4 + num_prev_positions3 + + num_prev_positions2 }; + + long long partial_data_pos; + uint8_t * buffer; // input buffer + int32_t * const prev_positions; // last seen position of key + int32_t * prev_pos_tree; + int dictionary_size_; // bytes to keep in buffer before pos + int buffer_size; + int pos; // current pos in buffer + int cyclic_pos; // current pos in dictionary + int stream_pos; // first byte not yet read from file + int pos_limit; // when reached, a new block must be read + const int match_len_limit_; + const int cycles; + const int infd; // input file descriptor + bool at_stream_end; // stream_pos shows real end of file + + bool read_block(); + +public: + Matchfinder( const int dict_size, const int len_limit, const int ifd ); + + ~Matchfinder() + { delete[] prev_pos_tree; delete[] prev_positions; free( buffer ); } + + uint8_t operator[]( const int i ) const throw() { return buffer[pos+i]; } + int available_bytes() const throw() { return stream_pos - pos; } + long long data_position() const throw() { return partial_data_pos + pos; } + int dictionary_size() const throw() { return dictionary_size_; } + bool finished() const throw() { return at_stream_end && pos >= stream_pos; } + int match_len_limit() const throw() { return match_len_limit_; } + const uint8_t * ptr_to_current_pos() const throw() { return buffer + pos; } + + bool dec_pos( const int ahead ) throw() + { + if( ahead < 0 || pos < ahead ) return false; + pos -= ahead; + cyclic_pos -= ahead; + if( cyclic_pos < 0 ) cyclic_pos += dictionary_size_; + return true; + } + + int true_match_len( const int index, const int distance, int len_limit ) const throw() + { + if( index + len_limit > available_bytes() ) + len_limit = available_bytes() - index; + const uint8_t * const data = buffer + pos + index - distance; + int i = 0; + while( i < len_limit && data[i] == data[i+distance] ) ++i; + return i; + } + + void reset(); + void move_pos(); + int longest_match_len( int * const distances = 0 ) throw(); + }; + + +class Range_encoder + { + enum { buffer_size = 65536 }; + uint64_t low; + long long partial_member_pos; + uint8_t * const buffer; // output buffer + int pos; // current pos in buffer + uint32_t range; + int ff_count; + const int outfd; // output file descriptor + uint8_t cache; + + void shift_low() + { + const uint32_t carry = low >> 32; + if( low < 0xFF000000U || carry == 1 ) + { + put_byte( cache + carry ); + for( ; ff_count > 0; --ff_count ) put_byte( 0xFF + carry ); + cache = low >> 24; + } + else ++ff_count; + low = ( low & 0x00FFFFFFU ) << 8; + } + +public: + Range_encoder( const int ofd ) + : + low( 0 ), + partial_member_pos( 0 ), + buffer( new uint8_t[buffer_size] ), + pos( 0 ), + range( 0xFFFFFFFFU ), + ff_count( 0 ), + outfd( ofd ), + cache( 0 ) {} + + ~Range_encoder() { delete[] buffer; } + + long long member_position() const throw() + { return partial_member_pos + pos + ff_count; } + + void flush() { for( int i = 0; i < 5; ++i ) shift_low(); } + void flush_data(); + + void put_byte( const uint8_t b ) + { + buffer[pos] = b; + if( ++pos >= buffer_size ) flush_data(); + } + + void encode( const int symbol, const int num_bits ) + { + for( int i = num_bits - 1; i >= 0; --i ) + { + range >>= 1; + if( (symbol >> i) & 1 ) low += range; + if( range <= 0x00FFFFFFU ) { range <<= 8; shift_low(); } + } + } + + void encode_bit( Bit_model & bm, const int bit ) + { + const uint32_t bound = ( range >> bit_model_total_bits ) * bm.probability; + if( !bit ) + { + range = bound; + bm.probability += (bit_model_total - bm.probability) >> bit_model_move_bits; + } + else + { + low += bound; + range -= bound; + bm.probability -= bm.probability >> bit_model_move_bits; + } + if( range <= 0x00FFFFFFU ) { range <<= 8; shift_low(); } + } + + void encode_tree( Bit_model bm[], const int symbol, const int num_bits ) + { + int mask = ( 1 << ( num_bits - 1 ) ); + int model = 1; + for( int i = num_bits; i > 0; --i, mask >>= 1 ) + { + const int bit = ( symbol & mask ); + encode_bit( bm[model], bit ); + model <<= 1; + if( bit ) model |= 1; + } + } + + void encode_tree_reversed( Bit_model bm[], int symbol, const int num_bits ) + { + int model = 1; + for( int i = num_bits; i > 0; --i ) + { + const int bit = symbol & 1; + encode_bit( bm[model], bit ); + model = ( model << 1 ) | bit; + symbol >>= 1; + } + } + + void encode_matched( Bit_model bm[], int symbol, int match_byte ) + { + int model = 1; + for( int i = 7; i >= 0; --i ) + { + const int match_bit = ( match_byte >> i ) & 1; + int bit = ( symbol >> i ) & 1; + encode_bit( bm[(match_bit<<8)+model+0x100], bit ); + model = ( model << 1 ) | bit; + if( match_bit != bit ) + { + while( --i >= 0 ) + { + bit = ( symbol >> i ) & 1; + encode_bit( bm[model], bit ); + model = ( model << 1 ) | bit; + } + break; + } + } + } + }; + + +class Len_encoder + { + Bit_model choice1; + Bit_model choice2; + Bit_model bm_low[pos_states][len_low_symbols]; + Bit_model bm_mid[pos_states][len_mid_symbols]; + Bit_model bm_high[len_high_symbols]; + int prices[pos_states][max_len_symbols]; + const int len_symbols; + int counters[pos_states]; + + void update_prices( const int pos_state ) throw() + { + int * const pps = prices[pos_state]; + int tmp = price0( choice1 ); + int len = 0; + for( ; len < len_low_symbols && len < len_symbols; ++len ) + pps[len] = tmp + + price_symbol( bm_low[pos_state], len, len_low_bits ); + tmp = price1( choice1 ); + for( ; len < len_low_symbols + len_mid_symbols && len < len_symbols; ++len ) + pps[len] = tmp + price0( choice2 ) + + price_symbol( bm_mid[pos_state], len - len_low_symbols, len_mid_bits ); + for( ; len < len_symbols; ++len ) + // using 4 slots per value makes "price" faster + prices[3][len] = prices[2][len] = prices[1][len] = prices[0][len] = + tmp + price1( choice2 ) + + price_symbol( bm_high, len - len_low_symbols - len_mid_symbols, len_high_bits ); + counters[pos_state] = len_symbols; + } + +public: + Len_encoder( const int len_limit ) + : len_symbols( len_limit + 1 - min_match_len ) + { + for( int i = 0; i < pos_states; ++i ) update_prices( i ); + } + + void encode( Range_encoder & range_encoder, int symbol, + const int pos_state ); + + int price( const int symbol, const int pos_state ) const throw() + { return prices[pos_state][symbol - min_match_len]; } + }; + + +class Literal_encoder + { + Bit_model bm_literal[1<<literal_context_bits][0x300]; + + int lstate( const uint8_t prev_byte ) const throw() + { return ( prev_byte >> ( 8 - literal_context_bits ) ); } + +public: + void encode( Range_encoder & range_encoder, + uint8_t prev_byte, uint8_t symbol ) + { range_encoder.encode_tree( bm_literal[lstate(prev_byte)], symbol, 8 ); } + + void encode_matched( Range_encoder & range_encoder, + uint8_t prev_byte, uint8_t symbol, uint8_t match_byte ) + { range_encoder.encode_matched( bm_literal[lstate(prev_byte)], + symbol, match_byte ); } + + int price_symbol( uint8_t prev_byte, uint8_t symbol ) const throw() + { return ::price_symbol( bm_literal[lstate(prev_byte)], symbol, 8 ); } + + int price_matched( uint8_t prev_byte, uint8_t symbol, + uint8_t match_byte ) const throw() + { return ::price_matched( bm_literal[lstate(prev_byte)], + symbol, match_byte ); } + }; + + +class LZ_encoder + { + enum { infinite_price = 0x0FFFFFFF, + max_marker_size = 16, + num_rep_distances = 4 }; // must be 4 + + struct Trial + { + State state; + int dis; + int prev_index; // index of prev trial in trials[] + int price; // dual use var; cumulative price, match length + int reps[num_rep_distances]; + void update( const int d, const int p_i, const int pr ) throw() + { if( pr < price ) { dis = d; prev_index = p_i; price = pr; } } + }; + + int longest_match_found; + uint32_t crc_; + + Bit_model bm_match[State::states][pos_states]; + Bit_model bm_rep[State::states]; + Bit_model bm_rep0[State::states]; + Bit_model bm_rep1[State::states]; + Bit_model bm_rep2[State::states]; + Bit_model bm_len[State::states][pos_states]; + Bit_model bm_dis_slot[max_dis_states][1<<dis_slot_bits]; + Bit_model bm_dis[modeled_distances-end_dis_model+1]; + Bit_model bm_align[dis_align_size]; + + Matchfinder & matchfinder; + Range_encoder range_encoder; + Len_encoder len_encoder; + Len_encoder rep_match_len_encoder; + Literal_encoder literal_encoder; + + const int num_dis_slots; + int match_distances[max_match_len+1]; + Trial trials[max_num_trials]; + + int dis_slot_prices[max_dis_states][2*max_dictionary_bits]; + int dis_prices[max_dis_states][modeled_distances]; + int align_prices[dis_align_size]; + int align_price_count; + + void fill_align_prices() throw(); + void fill_distance_prices() throw(); + + uint32_t crc() const throw() { return crc_ ^ 0xFFFFFFFFU; } + + // move-to-front dis in/into reps + void mtf_reps( const int dis, int reps[num_rep_distances] ) throw() + { + if( dis >= num_rep_distances ) + { + for( int i = num_rep_distances - 1; i > 0; --i ) reps[i] = reps[i-1]; + reps[0] = dis - num_rep_distances; + } + else if( dis > 0 ) + { + const int distance = reps[dis]; + for( int i = dis; i > 0; --i ) reps[i] = reps[i-1]; + reps[0] = distance; + } + } + + int price_rep_len1( const State & state, const int pos_state ) const throw() + { + return price0( bm_rep0[state()] ) + price0( bm_len[state()][pos_state] ); + } + + int price_rep( const int rep, const State & state, + const int pos_state ) const throw() + { + if( rep == 0 ) return price0( bm_rep0[state()] ) + + price1( bm_len[state()][pos_state] ); + int price = price1( bm_rep0[state()] ); + if( rep == 1 ) + price += price0( bm_rep1[state()] ); + else + { + price += price1( bm_rep1[state()] ); + price += price_bit( bm_rep2[state()], rep - 2 ); + } + return price; + } + + int price_dis( const int dis, const int dis_state ) const throw() + { + if( dis < modeled_distances ) + return dis_prices[dis_state][dis]; + else + return dis_slot_prices[dis_state][dis_slots[dis]] + + align_prices[dis & (dis_align_size - 1)]; + } + + int price_pair( const int dis, const int len, const int pos_state ) const throw() + { + if( len <= min_match_len && dis >= modeled_distances ) + return infinite_price; + return len_encoder.price( len, pos_state ) + + price_dis( dis, get_dis_state( len ) ); + } + + void encode_pair( const uint32_t dis, const int len, const int pos_state ) throw() + { + len_encoder.encode( range_encoder, len, pos_state ); + const int dis_slot = dis_slots[dis]; + range_encoder.encode_tree( bm_dis_slot[get_dis_state(len)], dis_slot, dis_slot_bits ); + + if( dis_slot >= start_dis_model ) + { + const int direct_bits = ( dis_slot >> 1 ) - 1; + const uint32_t base = ( 2 | ( dis_slot & 1 ) ) << direct_bits; + const uint32_t direct_dis = dis - base; + + if( dis_slot < end_dis_model ) + range_encoder.encode_tree_reversed( bm_dis + base - dis_slot, + direct_dis, direct_bits ); + else + { + range_encoder.encode( direct_dis >> dis_align_bits, direct_bits - dis_align_bits ); + range_encoder.encode_tree_reversed( bm_align, direct_dis, dis_align_bits ); + if( --align_price_count <= 0 ) fill_align_prices(); + } + } + } + + int read_match_distances() throw() + { + int len = matchfinder.longest_match_len( match_distances ); + if( len == matchfinder.match_len_limit() ) + len += matchfinder.true_match_len( len, match_distances[len] + 1, max_match_len - len ); + return len; + } + + void move_pos( int n, bool skip = false ) + { + while( --n >= 0 ) + { + if( skip ) skip = false; + else matchfinder.longest_match_len(); + matchfinder.move_pos(); + } + } + + void backward( int cur ) + { + int & dis = trials[cur].dis; + while( cur > 0 ) + { + const int prev_index = trials[cur].prev_index; + Trial & prev_trial = trials[prev_index]; + prev_trial.price = cur - prev_index; // len + cur = dis; dis = prev_trial.dis; prev_trial.dis = cur; + cur = prev_index; + } + } + + int sequence_optimizer( const int reps[num_rep_distances], + const State & state ); + + void full_flush( const State & state ); + +public: + LZ_encoder( Matchfinder & mf, const File_header & header, const int outfd ); + + bool encode_member( const long long member_size ); + + long long member_position() const throw() + { return range_encoder.member_position(); } + }; diff --git a/third_party/lzma.js/lzip/fast_encoder.cc b/third_party/lzma.js/lzip/fast_encoder.cc new file mode 100644 index 00000000..59965af4 --- /dev/null +++ b/third_party/lzma.js/lzip/fast_encoder.cc @@ -0,0 +1,378 @@ +#if !DECODER_ONLY + +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#define _FILE_OFFSET_BITS 64 + +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> + +#include "lzip.h" +#include "encoder.h" +#include "fast_encoder.h" + + +bool Fmatchfinder::read_block() + { + if( !at_stream_end && stream_pos < buffer_size ) + { + const int size = buffer_size - stream_pos; + const int rd = readblock( infd, buffer + stream_pos, size ); + stream_pos += rd; + if( rd != size && errno ) throw Error( "Read error" ); + at_stream_end = ( rd < size ); + } + return pos < stream_pos; + } + + +Fmatchfinder::Fmatchfinder( const int ifd ) + : + partial_data_pos( 0 ), + prev_positions( new int32_t[num_prev_positions] ), + pos( 0 ), + cyclic_pos( 0 ), + key4( 0 ), + stream_pos( 0 ), + match_len_limit_( 16 ), + infd( ifd ), + at_stream_end( false ) + { + const int dict_size = 65536; + const int buffer_size_limit = ( 16 * dict_size ) + before_size + after_size; + buffer_size = dict_size; + buffer = (uint8_t *)malloc( buffer_size ); + if( !buffer ) exit(-1); + if( read_block() && !at_stream_end && buffer_size < buffer_size_limit ) + { + buffer_size = buffer_size_limit; + buffer = (uint8_t *)realloc( buffer, buffer_size ); + if( !buffer ) exit(-1); + read_block(); + } + if( at_stream_end && stream_pos < dict_size ) + dictionary_size_ = max( (int)min_dictionary_size, stream_pos ); + else dictionary_size_ = dict_size; + pos_limit = buffer_size; + if( !at_stream_end ) pos_limit -= after_size; + prev_pos_chain = new int32_t[dictionary_size_]; + for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; + } + + +void Fmatchfinder::reset() + { + const int size = stream_pos - pos; + if( size > 0 ) memmove( buffer, buffer + pos, size ); + partial_data_pos = 0; + stream_pos -= pos; + pos = 0; + cyclic_pos = 0; + key4 = 0; + for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; + read_block(); + } + + +void Fmatchfinder::move_pos() + { + if( ++cyclic_pos >= dictionary_size_ ) cyclic_pos = 0; + if( ++pos >= pos_limit ) + { + if( pos > stream_pos ) + internal_error( "pos > stream_pos in Fmatchfinder::move_pos" ); + if( !at_stream_end ) + { + const int offset = pos - dictionary_size_ - before_size; + const int size = stream_pos - offset; + memmove( buffer, buffer + offset, size ); + partial_data_pos += offset; + pos -= offset; + stream_pos -= offset; + for( int i = 0; i < num_prev_positions; ++i ) + if( prev_positions[i] >= 0 ) prev_positions[i] -= offset; + for( int i = 0; i < dictionary_size_; ++i ) + if( prev_pos_chain[i] >= 0 ) prev_pos_chain[i] -= offset; + read_block(); + } + } + } + + +int Fmatchfinder::longest_match_len( int * const distance ) + { + int len_limit = match_len_limit_; + if( len_limit > available_bytes() ) + { + len_limit = available_bytes(); + if( len_limit < 4 ) return 0; + } + + const uint8_t * const data = buffer + pos; + key4 = ( ( key4 << 4 ) ^ data[3] ) & ( num_prev_positions - 1 ); + + int newpos = prev_positions[key4]; + prev_positions[key4] = pos; + + int32_t * ptr0 = prev_pos_chain + cyclic_pos; + int maxlen = 0; + + for( int count = 4; ; ) + { + if( newpos < (pos - dictionary_size_ + 1) || newpos < 0 || --count < 0 ) + { *ptr0 = -1; break; } + const uint8_t * const newdata = buffer + newpos; + int len = 0; + if( newdata[maxlen] == data[maxlen] ) + while( len < len_limit && newdata[len] == data[len] ) ++len; + + const int delta = pos - newpos; + if( maxlen < len ) { maxlen = len; *distance = delta - 1; } + + int32_t * const newptr = prev_pos_chain + + ( cyclic_pos - delta + + ( ( cyclic_pos >= delta ) ? 0 : dictionary_size_ ) ); + + if( len < len_limit ) + { + *ptr0 = newpos; + ptr0 = newptr; + newpos = *ptr0; + } + else + { + *ptr0 = *newptr; + break; + } + } + return maxlen; + } + + +void Fmatchfinder::longest_match_len() + { + int len_limit = match_len_limit_; + if( len_limit > available_bytes() ) + { + len_limit = available_bytes(); + if( len_limit < 4 ) return; + } + + const uint8_t * const data = buffer + pos; + key4 = ( ( key4 << 4 ) ^ data[3] ) & ( num_prev_positions - 1 ); + + const int newpos = prev_positions[key4]; + prev_positions[key4] = pos; + + int32_t * const ptr0 = prev_pos_chain + cyclic_pos; + + if( newpos < (pos - dictionary_size_ + 1) || newpos < 0 ) *ptr0 = -1; + else + { + const uint8_t * const newdata = buffer + newpos; + if( newdata[len_limit-1] != data[len_limit-1] || + memcmp( newdata, data, len_limit - 1 ) ) *ptr0 = newpos; + else + { + int idx = cyclic_pos - pos + newpos; + if( idx < 0 ) idx += dictionary_size_; + *ptr0 = prev_pos_chain[idx]; + } + } + } + + +// Return value == number of bytes advanced (len). +// *disp returns the distance to encode. +// ( *disp == -1 && len == 1 ) means literal. +int FLZ_encoder::sequence_optimizer( const int reps[num_rep_distances], + int * const disp, const State & state ) + { + const int main_len = read_match_distances(); + + int replen = 0; + int rep_index = 0; + for( int i = 0; i < num_rep_distances; ++i ) + { + const int len = fmatchfinder.true_match_len( 0, reps[i] + 1, max_match_len ); + if( len > replen ) { replen = len; rep_index = i; } + } + if( replen > min_match_len && replen + 4 > main_len ) + { + *disp = rep_index; + move_pos( replen, true ); + return replen; + } + + if( main_len > min_match_len || + ( main_len == min_match_len && match_distance < modeled_distances ) ) + { + *disp = num_rep_distances + match_distance; + move_pos( main_len, true ); + return main_len; + } + + const uint8_t cur_byte = fmatchfinder[0]; + const uint8_t match_byte = fmatchfinder[-reps[0]-1]; + + *disp = -1; + if( match_byte == cur_byte ) + { + const uint8_t prev_byte = fmatchfinder[-1]; + const int pos_state = fmatchfinder.data_position() & pos_state_mask; + int price = price0( bm_match[state()][pos_state] ); + if( state.is_char() ) + price += literal_encoder.price_symbol( prev_byte, cur_byte ); + else + price += literal_encoder.price_matched( prev_byte, cur_byte, match_byte ); + const int short_rep_price = price1( bm_match[state()][pos_state] ) + + price1( bm_rep[state()] ) + + price0( bm_rep0[state()] ) + + price0( bm_len[state()][pos_state] ); + if( short_rep_price < price ) *disp = 0; + } + + fmatchfinder.move_pos(); + return 1; + } + + + // End Of Stream mark => (dis == 0xFFFFFFFFU, len == min_match_len) +void FLZ_encoder::full_flush( const State & state ) + { + const int pos_state = fmatchfinder.data_position() & pos_state_mask; + range_encoder.encode_bit( bm_match[state()][pos_state], 1 ); + range_encoder.encode_bit( bm_rep[state()], 0 ); + encode_pair( 0xFFFFFFFFU, min_match_len, pos_state ); + range_encoder.flush(); + File_trailer trailer; + trailer.data_crc( crc() ); + trailer.data_size( fmatchfinder.data_position() ); + trailer.member_size( range_encoder.member_position() + File_trailer::size() ); + for( int i = 0; i < File_trailer::size(); ++i ) + range_encoder.put_byte( trailer.data[i] ); + range_encoder.flush_data(); + } + + +FLZ_encoder::FLZ_encoder( Fmatchfinder & mf, const File_header & header, + const int outfd ) + : + crc_( 0xFFFFFFFFU ), + fmatchfinder( mf ), + range_encoder( outfd ), + len_encoder( fmatchfinder.match_len_limit() ), + rep_match_len_encoder( fmatchfinder.match_len_limit() ), + num_dis_slots( 2 * real_bits( fmatchfinder.dictionary_size() - 1 ) ) + { + for( int i = 0; i < File_header::size; ++i ) + range_encoder.put_byte( header.data[i] ); + } + + +bool FLZ_encoder::encode_member( const long long member_size ) + { + const long long member_size_limit = + member_size - File_trailer::size() - max_marker_size; + int rep_distances[num_rep_distances]; + State state; + for( int i = 0; i < num_rep_distances; ++i ) rep_distances[i] = 0; + + if( fmatchfinder.data_position() != 0 || + range_encoder.member_position() != File_header::size ) + return false; // can be called only once + + if( !fmatchfinder.finished() ) // encode first byte + { + const uint8_t prev_byte = 0; + const uint8_t cur_byte = fmatchfinder[0]; + range_encoder.encode_bit( bm_match[state()][0], 0 ); + literal_encoder.encode( range_encoder, prev_byte, cur_byte ); + crc32.update( crc_, cur_byte ); + move_pos( 1 ); + } + + while( true ) + { + if( fmatchfinder.finished() ) { full_flush( state ); return true; } + + const int pos_state = fmatchfinder.data_position() & pos_state_mask; + int dis; + const int len = sequence_optimizer( rep_distances, &dis, state ); + if( len <= 0 ) return false; + + bool bit = ( dis < 0 && len == 1 ); + range_encoder.encode_bit( bm_match[state()][pos_state], !bit ); + if( bit ) // literal byte + { + const uint8_t prev_byte = fmatchfinder[-len-1]; + const uint8_t cur_byte = fmatchfinder[-len]; + crc32.update( crc_, cur_byte ); + if( state.is_char() ) + literal_encoder.encode( range_encoder, prev_byte, cur_byte ); + else + { + const uint8_t match_byte = fmatchfinder[-len-rep_distances[0]-1]; + literal_encoder.encode_matched( range_encoder, + prev_byte, cur_byte, match_byte ); + } + state.set_char(); + } + else // match or repeated match + { + crc32.update( crc_, fmatchfinder.ptr_to_current_pos() - len, len ); + mtf_reps( dis, rep_distances ); + bit = ( dis < num_rep_distances ); + range_encoder.encode_bit( bm_rep[state()], bit ); + if( bit ) + { + bit = ( dis == 0 ); + range_encoder.encode_bit( bm_rep0[state()], !bit ); + if( bit ) + range_encoder.encode_bit( bm_len[state()][pos_state], len > 1 ); + else + { + range_encoder.encode_bit( bm_rep1[state()], dis > 1 ); + if( dis > 1 ) + range_encoder.encode_bit( bm_rep2[state()], dis > 2 ); + } + if( len == 1 ) state.set_short_rep(); + else + { + rep_match_len_encoder.encode( range_encoder, len, pos_state ); + state.set_rep(); + } + } + else + { + encode_pair( dis - num_rep_distances, len, pos_state ); + state.set_match(); + } + } + if( range_encoder.member_position() >= member_size_limit ) + { + full_flush( state ); + return true; + } + } + } + +#endif + diff --git a/third_party/lzma.js/lzip/fast_encoder.h b/third_party/lzma.js/lzip/fast_encoder.h new file mode 100644 index 00000000..b18b8a82 --- /dev/null +++ b/third_party/lzma.js/lzip/fast_encoder.h @@ -0,0 +1,171 @@ +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +class Fmatchfinder + { + enum { // bytes to keep in buffer before dictionary + before_size = max_match_len + 1, + // bytes to keep in buffer after pos + after_size = max_match_len, + num_prev_positions = 1 << 16 }; + + long long partial_data_pos; + uint8_t * buffer; // input buffer + int32_t * const prev_positions; // last seen position of key + int32_t * prev_pos_chain; + int dictionary_size_; // bytes to keep in buffer before pos + int buffer_size; + int pos; // current pos in buffer + int cyclic_pos; // current pos in dictionary + int key4; // key made from latest 4 bytes + int stream_pos; // first byte not yet read from file + int pos_limit; // when reached, a new block must be read + const int match_len_limit_; + const int infd; // input file descriptor + bool at_stream_end; // stream_pos shows real end of file + + bool read_block(); + +public: + Fmatchfinder( const int ifd ); + + ~Fmatchfinder() + { delete[] prev_pos_chain; delete[] prev_positions; free( buffer ); } + + uint8_t operator[]( const int i ) const { return buffer[pos+i]; } + int available_bytes() const { return stream_pos - pos; } + long long data_position() const { return partial_data_pos + pos; } + int dictionary_size() const { return dictionary_size_; } + bool finished() const { return at_stream_end && pos >= stream_pos; } + int match_len_limit() const { return match_len_limit_; } + const uint8_t * ptr_to_current_pos() const { return buffer + pos; } + + int true_match_len( const int index, const int distance, int len_limit ) const + { + if( index + len_limit > available_bytes() ) + len_limit = available_bytes() - index; + const uint8_t * const data = buffer + pos + index - distance; + int i = 0; + while( i < len_limit && data[i] == data[i+distance] ) ++i; + return i; + } + + void reset(); + void move_pos(); + int longest_match_len( int * const distance ); + void longest_match_len(); + }; + + +class FLZ_encoder + { + enum { max_marker_size = 16, + num_rep_distances = 4 }; // must be 4 + + uint32_t crc_; + + Bit_model bm_match[State::states][pos_states]; + Bit_model bm_rep[State::states]; + Bit_model bm_rep0[State::states]; + Bit_model bm_rep1[State::states]; + Bit_model bm_rep2[State::states]; + Bit_model bm_len[State::states][pos_states]; + Bit_model bm_dis_slot[max_dis_states][1<<dis_slot_bits]; + Bit_model bm_dis[modeled_distances-end_dis_model+1]; + Bit_model bm_align[dis_align_size]; + + Fmatchfinder & fmatchfinder; + Range_encoder range_encoder; + Len_encoder len_encoder; + Len_encoder rep_match_len_encoder; + Literal_encoder literal_encoder; + + const int num_dis_slots; + int match_distance; + + uint32_t crc() const { return crc_ ^ 0xFFFFFFFFU; } + + // move-to-front dis in/into reps + void mtf_reps( const int dis, int reps[num_rep_distances] ) + { + if( dis >= num_rep_distances ) + { + for( int i = num_rep_distances - 1; i > 0; --i ) reps[i] = reps[i-1]; + reps[0] = dis - num_rep_distances; + } + else if( dis > 0 ) + { + const int distance = reps[dis]; + for( int i = dis; i > 0; --i ) reps[i] = reps[i-1]; + reps[0] = distance; + } + } + + void encode_pair( const uint32_t dis, const int len, const int pos_state ) + { + len_encoder.encode( range_encoder, len, pos_state ); + const int dis_slot = dis_slots[dis]; + range_encoder.encode_tree( bm_dis_slot[get_dis_state(len)], dis_slot, dis_slot_bits ); + + if( dis_slot >= start_dis_model ) + { + const int direct_bits = ( dis_slot >> 1 ) - 1; + const uint32_t base = ( 2 | ( dis_slot & 1 ) ) << direct_bits; + const uint32_t direct_dis = dis - base; + + if( dis_slot < end_dis_model ) + range_encoder.encode_tree_reversed( bm_dis + base - dis_slot, + direct_dis, direct_bits ); + else + { + range_encoder.encode( direct_dis >> dis_align_bits, direct_bits - dis_align_bits ); + range_encoder.encode_tree_reversed( bm_align, direct_dis, dis_align_bits ); + } + } + } + + int read_match_distances() + { + int len = fmatchfinder.longest_match_len( &match_distance ); + if( len == fmatchfinder.match_len_limit() ) + len += fmatchfinder.true_match_len( len, match_distance + 1, max_match_len - len ); + return len; + } + + void move_pos( int n, bool skip = false ) + { + while( --n >= 0 ) + { + if( skip ) skip = false; + else fmatchfinder.longest_match_len(); + fmatchfinder.move_pos(); + } + } + + int sequence_optimizer( const int reps[num_rep_distances], + int * const disp, const State & state ); + + void full_flush( const State & state ); + +public: + FLZ_encoder( Fmatchfinder & mf, const File_header & header, const int outfd ); + + bool encode_member( const long long member_size ); + + long long member_position() const + { return range_encoder.member_position(); } + }; diff --git a/third_party/lzma.js/lzip/lzip.h b/third_party/lzma.js/lzip/lzip.h new file mode 100644 index 00000000..1a49ca4b --- /dev/null +++ b/third_party/lzma.js/lzip/lzip.h @@ -0,0 +1,264 @@ +#define max(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) + +#define min(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) + +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +class State + { + unsigned char st; + +public: + enum { states = 12 }; + State() : st( 0 ) {} + unsigned char operator()() const { return st; } + bool is_char() const { return st < 7; } + + void set_char() + { + static const unsigned char next[states] = + { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; + st = next[st]; + } + + void set_match() + { + static const unsigned char next[states] = + { 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10 }; + st = next[st]; + } + + void set_rep() + { + static const unsigned char next[states] = + { 8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11 }; + st = next[st]; + } + + void set_short_rep() + { + static const unsigned char next[states] = + { 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11 }; + st = next[st]; + } + }; + + +enum { + min_dictionary_bits = 12, + min_dictionary_size = 1 << min_dictionary_bits, + max_dictionary_bits = 29, + max_dictionary_size = 1 << max_dictionary_bits, + literal_context_bits = 3, + pos_state_bits = 2, + pos_states = 1 << pos_state_bits, + pos_state_mask = pos_states - 1, + + dis_slot_bits = 6, + start_dis_model = 4, + end_dis_model = 14, + modeled_distances = 1 << (end_dis_model / 2), + dis_align_bits = 4, + dis_align_size = 1 << dis_align_bits, + + len_low_bits = 3, + len_mid_bits = 3, + len_high_bits = 8, + len_low_symbols = 1 << len_low_bits, + len_mid_symbols = 1 << len_mid_bits, + len_high_symbols = 1 << len_high_bits, + max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols, + + min_match_len = 2, // must be 2 + max_match_len = min_match_len + max_len_symbols - 1, // 273 + min_match_len_limit = 5, + + max_dis_states = 4 }; + +inline int get_dis_state( int len ) + { + len -= min_match_len; + if( len >= max_dis_states ) len = max_dis_states - 1; + return len; + } + + +enum { bit_model_move_bits = 5, + bit_model_total_bits = 11, + bit_model_total = 1 << bit_model_total_bits }; + +struct Bit_model + { + unsigned int probability; + Bit_model() : probability( bit_model_total / 2 ) {} + }; + + +class CRC32 + { + uint32_t data[256]; // Table of CRCs of all 8-bit messages. + +public: + CRC32() + { + for( unsigned int n = 0; n < 256; ++n ) + { + unsigned int c = n; + for( int k = 0; k < 8; ++k ) + { if( c & 1 ) c = 0xEDB88320U ^ ( c >> 1 ); else c >>= 1; } + data[n] = c; + } + } + + uint32_t operator[]( const uint8_t byte ) const { return data[byte]; } + void update( uint32_t & crc, const uint8_t byte ) const + { crc = data[(crc^byte)&0xFF] ^ ( crc >> 8 ); } + void update( uint32_t & crc, const uint8_t * const buffer, const int size ) const + { + for( int i = 0; i < size; ++i ) + crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 ); + } + }; + +extern const CRC32 crc32; + + +inline int real_bits( const int value ) + { + int bits = 0; + for( int i = 1, mask = 1; mask > 0; ++i, mask <<= 1 ) + if( value & mask ) bits = i; + return bits; + } + +const uint8_t magic_string[4] = { 'L', 'Z', 'I', 'P' }; + +struct File_header + { + uint8_t data[6]; // 0-3 magic bytes + // 4 version + // 5 coded_dict_size + enum { size = 6 }; + + void set_magic() + { memcpy( data, magic_string, 4 ); data[4] = 1; } + + bool verify_magic() const + { return ( memcmp( data, magic_string, 4 ) == 0 ); } + + uint8_t version() const { return data[4]; } + bool verify_version() const { return ( data[4] <= 1 ); } + + int dictionary_size() const + { + int sz = ( 1 << ( data[5] & 0x1F ) ); + if( sz > min_dictionary_size && sz <= max_dictionary_size ) + sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 0x07 ); + return sz; + } + + bool dictionary_size( const int sz ) + { + if( sz >= min_dictionary_size && sz <= max_dictionary_size ) + { + data[5] = real_bits( sz - 1 ); + if( sz > min_dictionary_size ) + { + const int base_size = 1 << data[5]; + const int wedge = base_size / 16; + for( int i = 7; i >= 1; --i ) + if( base_size - ( i * wedge ) >= sz ) + { data[5] |= ( i << 5 ); break; } + } + return true; + } + return false; + } + }; + + +struct File_trailer + { + uint8_t data[20]; // 0-3 CRC32 of the uncompressed data + // 4-11 size of the uncompressed data + // 12-19 member size including header and trailer + + static int size( const int version = 1 ) + { return ( ( version >= 1 ) ? 20 : 12 ); } + + uint32_t data_crc() const + { + uint32_t tmp = 0; + for( int i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; } + return tmp; + } + + void data_crc( uint32_t crc ) + { for( int i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; } } + + long long data_size() const + { + long long tmp = 0; + for( int i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; } + return tmp; + } + + void data_size( long long sz ) + { + for( int i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } + } + + long long member_size() const + { + long long tmp = 0; + for( int i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; } + return tmp; + } + + void member_size( long long sz ) + { + for( int i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } + } + }; + + +struct Error + { + const char * const msg; + Error( const char * const s ) : msg( s ) {} + }; + + +// defined in main.cc lziprecover.cc +void show_error( const char * const msg, const int errcode = 0, + const bool help = false ); +void internal_error( const char * const msg ); + +// defined in decoder.cc +int readblock( const int fd, uint8_t * const buf, const int size ); +int writeblock( const int fd, const uint8_t * const buf, const int size ); + +// XXX +extern void pp(const char *p=NULL); + diff --git a/third_party/lzma.js/lzip/main.cc b/third_party/lzma.js/lzip/main.cc new file mode 100644 index 00000000..86465b0a --- /dev/null +++ b/third_party/lzma.js/lzip/main.cc @@ -0,0 +1,545 @@ +/* Lzip - Data compressor based on the LZMA algorithm + Copyright (C) 2008, 2009, 2010, 2011 Antonio Diaz Diaz. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +/* + Return values: 0 for a normal exit, 1 for environmental problems + (file not found, invalid flags, I/O errors, etc), 2 to indicate a + corrupt or invalid input file, 3 for an internal consistency error + (eg, bug) which caused lzip to panic. +*/ + +#define _FILE_OFFSET_BITS 64 + +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <stdint.h> +#include <unistd.h> +#include <utime.h> +#include <sys/stat.h> +#if defined(__MSVCRT__) +#include <io.h> +#define fchmod(x,y) 0 +#define fchown(x,y,z) 0 +#define SIGHUP SIGTERM +#define S_ISSOCK(x) 0 +#define S_IRGRP 0 +#define S_IWGRP 0 +#define S_IROTH 0 +#define S_IWOTH 0 +#endif +#if defined(__OS2__) +#include <io.h> +#endif + +#include "lzip.h" +#include "decoder.h" + +#if !DECODER_ONLY +#include "encoder.h" +#include "fast_encoder.h" +#endif + +#if CHAR_BIT != 8 +#error "Environments where CHAR_BIT != 8 are not supported." +#endif + +#ifndef LLONG_MAX +#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL +#endif +#ifndef LLONG_MIN +#define LLONG_MIN (-LLONG_MAX - 1LL) +#endif +#ifndef ULLONG_MAX +#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL +#endif + + +void pp(const char *p) { if (p) fputs(p, stderr); } + +namespace { + +const char * const Program_name = "Lzip"; +const char * const program_name = "lzip"; +const char * const program_year = "2011"; +const char * invocation_name = 0; + +#ifdef O_BINARY +const int o_binary = O_BINARY; +#else +const int o_binary = 0; +#endif + +struct { const char * from; const char * to; } const known_extensions[] = { +{ ".lz", "" }, +{ ".tlz", ".tar" }, +{ 0, 0 } }; + +struct Lzma_options +{ + int dictionary_size; // 4KiB..512MiB + int match_len_limit; // 5..273 +}; + +enum Mode { m_compress, m_decompress, m_test }; + +int outfd = -1; +int verbosity = 0; +bool delete_output_on_interrupt = false; + + +void show_help() +{ + printf( "%s - Data compressor based on the LZMA algorithm.\n", Program_name ); + printf( "<< Most of these are unsupported. Compressing/decompressing from stdin to stdout is the right way! >>\n" ); + printf( "\nUsage: %s [options] [files]\n", invocation_name ); + printf( "\nOptions:\n" ); + printf( " -h, --help display this help and exit\n" ); + printf( " -V, --version output version information and exit\n" ); + printf( " -b, --member-size=<n> set member size limit in bytes\n" ); + printf( " -c, --stdout send output to standard output\n" ); + printf( " -d, --decompress decompress\n" ); + printf( " -f, --force overwrite existing output files\n" ); + printf( " -F, --recompress force recompression of compressed files\n" ); + printf( " -k, --keep keep (don't delete) input files\n" ); + printf( " -m, --match-length=<n> set match length limit in bytes [36]\n" ); + printf( " -o, --output=<file> if reading stdin, place the output into <file>\n" ); + printf( " -q, --quiet suppress all messages\n" ); + printf( " -s, --dictionary-size=<n> set dictionary size limit in bytes [8MiB]\n" ); + printf( " -S, --volume-size=<n> set volume size limit in bytes\n" ); + printf( " -t, --test test compressed file integrity\n" ); + printf( " -v, --verbose be verbose (a 2nd -v gives more)\n" ); + printf( " -0 .. -9 set compression level [default 6]\n" ); + printf( " --fast alias for -0\n" ); + printf( " --best alias for -9\n" ); + printf( "If no file names are given, %s compresses or decompresses\n", program_name ); + printf( "from standard input to standard output.\n" ); + printf( "Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,\n" ); + printf( "Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...\n" ); + printf( "\nReport bugs to lzip-bug@nongnu.org\n" ); + printf( "Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" ); +} + + +void show_version() +{ + printf( "%s %s\n", Program_name, PROGVERSION ); + printf( "Copyright (C) %s Antonio Diaz Diaz.\n", program_year ); + printf( "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" ); + printf( "This is free software: you are free to change and redistribute it.\n" ); + printf( "There is NO WARRANTY, to the extent permitted by law.\n" ); +} + + +const char * format_num( long long num ) +{ + const char * const prefix[8] = + { "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" }; + enum { buf_size = 16, factor = 1024 }; + static char buf[buf_size]; + const char *p = ""; + + for( int i = 0; i < 8 && ( llabs( num ) > 9999 || + ( llabs( num ) >= factor && num % factor == 0 ) ); ++i ) + { num /= factor; p = prefix[i]; } + snprintf( buf, buf_size, "%lld %s", num, p ); + return buf; +} + + +bool open_outstream( const bool force ) +{ + return false; +} + + +bool check_tty( const int infd, const Mode program_mode ) +{ + if( program_mode == m_compress && outfd >= 0 && isatty( outfd ) ) + { + show_error( "I won't write compressed data to a terminal.", 0, true ); + return false; + } + if( ( program_mode == m_decompress || program_mode == m_test ) && + isatty( infd ) ) + { + show_error( "I won't read compressed data from a terminal.", 0, true ); + return false; + } + return true; +} + + +void cleanup_and_fail( const int retval ) +{ + exit( retval ); +} + + + // Set permissions, owner and times. +void close_and_set_permissions( const struct stat * const in_statsp ) +{ + bool error = false; + if( in_statsp ) + { + if( ( fchown( outfd, in_statsp->st_uid, in_statsp->st_gid ) != 0 && + errno != EPERM ) || + fchmod( outfd, in_statsp->st_mode ) != 0 ) + error = true; + // fchown will in many cases return with EPERM, which can be safely ignored. + } + if( close( outfd ) == 0 ) outfd = -1; + else cleanup_and_fail( 1 ); + delete_output_on_interrupt = false; + if( !in_statsp ) return; + if( !error ) + { + struct utimbuf t; + t.actime = in_statsp->st_atime; + t.modtime = in_statsp->st_mtime; + //if( utime( output_filename.c_str(), &t ) != 0 ) error = true; + } + if( error ) + { + show_error( "Can't change output file attributes." ); + cleanup_and_fail( 1 ); + } +} + + +bool next_filename() +{ + return false; +} + +#if !DECODER_ONLY +int compress( const long long member_size, const long long volume_size, + const Lzma_options & encoder_options, const int infd, + const struct stat * const in_statsp ) +{ + File_header header; + header.set_magic(); + if( !header.dictionary_size( encoder_options.dictionary_size ) || + encoder_options.match_len_limit < min_match_len_limit || + encoder_options.match_len_limit > max_match_len ) + internal_error( "invalid argument to encoder" ); + int retval = 0; + + Matchfinder matchfinder( header.dictionary_size(), + encoder_options.match_len_limit, infd ); + header.dictionary_size( matchfinder.dictionary_size() ); + + long long in_size = 0, out_size = 0, partial_volume_size = 0; + while( true ) // encode one member per iteration + { + LZ_encoder encoder( matchfinder, header, outfd ); + const long long size = + min( member_size, volume_size - partial_volume_size ); + if( !encoder.encode_member( size ) ) + { pp( "Encoder error" ); retval = 1; break; } + in_size += matchfinder.data_position(); + out_size += encoder.member_position(); + if( matchfinder.finished() ) break; + partial_volume_size += encoder.member_position(); + if( partial_volume_size >= volume_size - min_dictionary_size ) + { + partial_volume_size = 0; + if( delete_output_on_interrupt ) + { + close_and_set_permissions( in_statsp ); + if( !next_filename() ) + { pp( "Too many volume files" ); retval = 1; break; } + if( !open_outstream( true ) ) { retval = 1; break; } + delete_output_on_interrupt = true; + } + } + matchfinder.reset(); + } + + if( retval == 0 && verbosity >= 1 ) + { + if( in_size <= 0 || out_size <= 0 ) + fprintf( stderr, "No data compressed.\n" ); + else + fprintf( stderr, "%6.3f:1, %6.3f bits/byte, " + "%5.2f%% saved, %lld in, %lld out.\n", + (double)in_size / out_size, + ( 8.0 * out_size ) / in_size, + 100.0 * ( 1.0 - ( (double)out_size / in_size ) ), + in_size, out_size ); + } + return retval; +} + + +int fcompress( const long long member_size, const long long volume_size, + const int infd, + const struct stat * const in_statsp ) +{ + if( verbosity >= 1 ) pp(); + File_header header; + header.set_magic(); + int retval = 0; + + Fmatchfinder fmatchfinder( infd ); + header.dictionary_size( fmatchfinder.dictionary_size() ); + + long long in_size = 0, out_size = 0, partial_volume_size = 0; + while( true ) // encode one member per iteration + { + FLZ_encoder encoder( fmatchfinder, header, outfd ); + const long long size = + min( member_size, volume_size - partial_volume_size ); + if( !encoder.encode_member( size ) ) + { pp( "Encoder error" ); retval = 1; break; } + in_size += fmatchfinder.data_position(); + out_size += encoder.member_position(); + if( fmatchfinder.finished() ) break; + partial_volume_size += encoder.member_position(); + if( partial_volume_size >= volume_size - min_dictionary_size ) + { + partial_volume_size = 0; + if( delete_output_on_interrupt ) + { + close_and_set_permissions( in_statsp ); + if( !next_filename() ) + { pp( "Too many volume files" ); retval = 1; break; } + if( !open_outstream( true ) ) { retval = 1; break; } + delete_output_on_interrupt = true; + } + } + fmatchfinder.reset(); + } + + if( retval == 0 && verbosity >= 1 ) + { + if( in_size <= 0 || out_size <= 0 ) + fprintf( stderr, "No data compressed.\n" ); + else + fprintf( stderr, "%6.3f:1, %6.3f bits/byte, " + "%5.2f%% saved, %lld in, %lld out.\n", + (double)in_size / out_size, + ( 8.0 * out_size ) / in_size, + 100.0 * ( 1.0 - ( (double)out_size / in_size ) ), + in_size, out_size ); + } + return retval; +} +#endif + +int decompress( const int infd, const bool testing ) +{ + int retval = 0; + + Range_decoder rdec( infd ); + long long partial_file_pos = 0; + for( bool first_member = true; ; first_member = false ) + { + File_header header; + int size; + rdec.reset_member_position(); + for( size = 0; size < File_header::size && !rdec.finished(); ++size ) + header.data[size] = rdec.get_byte(); + if( rdec.finished() ) // End Of File + { + if( first_member ) + { pp( "Error reading member header" ); retval = 1; } + break; + } + if( !header.verify_magic() ) + { + if( first_member ) + { pp( "Bad magic number (file not in lzip format)" ); retval = 2; } + break; + } + if( !header.verify_version() ) + { + if( verbosity >= 0 ) + { pp(); + fprintf( stderr, "Version %d member format not supported.\n", + header.version() ); } + retval = 2; break; + } + if( header.dictionary_size() < min_dictionary_size || + header.dictionary_size() > max_dictionary_size ) + { pp( "Invalid dictionary size in member header" ); retval = 2; break; } + + if( verbosity >= 2 || ( verbosity == 1 && first_member ) ) + { + pp(); + if( verbosity >= 2 ) + fprintf( stderr, "version %d, dictionary size %7sB. ", + header.version(), + format_num( header.dictionary_size() ) ); + } + LZ_decoder decoder( header, rdec, outfd ); + + const int result = decoder.decode_member(); + partial_file_pos += rdec.member_position(); + if( result != 0 ) + { + if( verbosity >= 0 && result <= 2 ) + { + pp(); + if( result == 2 ) + fprintf( stderr, "File ends unexpectedly at pos %lld\n", + partial_file_pos ); + else + fprintf( stderr, "Decoder error at pos %lld\n", + partial_file_pos ); + } + retval = 2; break; + } + if( verbosity >= 2 ) + { if( testing ) fprintf( stderr, "ok\n" ); + else fprintf( stderr, "done\n" ); } + } + if( verbosity == 1 && retval == 0 ) + { if( testing ) fprintf( stderr, "ok\n" ); + else fprintf( stderr, "done\n" ); } + return retval; +} + + +} // end namespace + + +void show_error( const char * const msg, const int errcode, const bool help ) +{ + if( verbosity >= 0 ) + { + if( msg && msg[0] ) + { + fprintf( stderr, "%s: %s", program_name, msg ); + if( errcode > 0 ) + fprintf( stderr, ": %s", strerror( errcode ) ); + fprintf( stderr, "\n" ); + } + if( help && invocation_name && invocation_name[0] ) + fprintf( stderr, "Try `%s --help' for more information.\n", + invocation_name ); + } +} + + +void internal_error( const char * const msg ) +{ + if( verbosity >= 0 ) + fprintf( stderr, "%s: internal error: %s.\n", program_name, msg ); + exit( 3 ); +} + + +int main( const int argc, const char * const argv[] ) +{ + // Mapping from gzip/bzip2 style 1..9 compression modes + // to the corresponding LZMA compression modes. + const Lzma_options option_mapping[] = + { + { 1 << 16, 16 }, // -0 entry values not used + { 1 << 20, 5 }, // -1 + { 3 << 19, 6 }, // -2 + { 1 << 21, 8 }, // -3 + { 3 << 20, 12 }, // -4 + { 1 << 22, 20 }, // -5 + { 1 << 23, 36 }, // -6 + { 1 << 24, 68 }, // -7 + { 3 << 23, 132 }, // -8 + { 1 << 25, 273 } }; // -9 + Lzma_options encoder_options = option_mapping[6]; // default = "-6" + long long member_size = LLONG_MAX; + long long volume_size = LLONG_MAX; + int infd = -1; + Mode program_mode = m_compress; + bool keep_input_files = false; + bool to_stdout = false; + bool zero = false; + invocation_name = argv[0]; + + // Greatly simplified argument parsing + int argind = 1; + for( ; argind < argc; ++argind ) + { + const int code = argv[argind][1]; + switch( code ) + { + case 'c': to_stdout = true; break; + case 'd': program_mode = m_decompress; break; + case 'h': show_help(); return 0; + case 'k': keep_input_files = true; break; + case 'q': verbosity = -1; break; + zero = false; break; + case 'v': if( verbosity < 4 ) ++verbosity; break; + case 'V': show_version(); return 0; + default : internal_error( "uncaught option" ); + } + } // end process options + +#if defined(__MSVCRT__) || defined(__OS2__) + _setmode( STDIN_FILENO, O_BINARY ); + _setmode( STDOUT_FILENO, O_BINARY ); +#endif + + if( program_mode == m_test ) + outfd = -1; +#if !DECODER_ONLY + else if( program_mode == m_compress ) + { + dis_slots.init(); + prob_prices.init(); + } +#endif + + int retval = 0; + { + struct stat in_stats; + + infd = STDIN_FILENO; + outfd = STDOUT_FILENO; + + if( !check_tty( infd, program_mode ) ) return 1; + + const struct stat * const in_statsp = 0; + //pp.set_name( "-" ); + int tmp = 0; +#if !DECODER_ONLY + if( program_mode == m_compress ) + { + if( zero ) + tmp = fcompress( member_size, volume_size, infd, in_statsp ); + else + tmp = compress( member_size, volume_size, encoder_options, infd, + in_statsp ); + } + else +#endif + tmp = decompress( infd, program_mode == m_test ); + if( tmp > retval ) retval = tmp; + //if( tmp && program_mode != m_test ) cleanup_and_fail( retval ); + + if( delete_output_on_interrupt ) + close_and_set_permissions( in_statsp ); + } + if( outfd >= 0 && close( outfd ) != 0 ) + { + show_error( "Can't close stdout", errno ); + if( retval < 1 ) retval = 1; + } + return retval; +} diff --git a/third_party/lzma.js/lzma-decoder.js b/third_party/lzma.js/lzma-decoder.js new file mode 100644 index 00000000..b380c3c4 --- /dev/null +++ b/third_party/lzma.js/lzma-decoder.js @@ -0,0 +1,27 @@ + +// This is lzma.js, powered by lzip (which is GPL, source code at https://github.com/kripken/lzma.js) +var LZMA = { + run: function(data, decompress) { + var inputIndex = 0; + var returnValue = []; + var Module = { + arguments: ['-q'].concat(decompress ? ['-d'] : []), + stdin: function() { return inputIndex < data.length ? data[inputIndex++] : null }, + stdout: function(x) { if (x !== null) returnValue.push(x) } + }; + + +function a(b){throw b}var ca=void 0,j=!0,l=null,m=!1,ka=[],la="object"===typeof process,sa="object"===typeof window,Ca="function"===typeof importScripts,Ka=!sa&&!la&&!Ca;if(la){print=(function(b){process.stdout.write(b+"\n")});printErr=(function(b){process.stderr.write(b+"\n")});var bb=require("fs");read=(function(b){var d=bb.readFileSync(b).toString();!d&&"/"!=b[0]&&(b=__dirname.split("/").slice(0,-1).join("/")+"/src/"+b,d=bb.readFileSync(b).toString());return d});load=(function(b){cb(read(b))});ka=process.argv.slice(2)}else{Ka?(this.read||(this.read=(function(b){snarf(b)})),"undefined"!=typeof scriptArgs?ka=scriptArgs:"undefined"!=typeof arguments&&(ka=arguments)):sa?(this.print=printErr=(function(b){console.log(b)}),this.read=(function(b){var d=new XMLHttpRequest;d.open("GET",b,m);d.send(l);return d.responseText}),this.arguments&&(ka=arguments)):Ca?this.load=importScripts:a("Unknown runtime environment. Where are we?")}function cb(b){eval.call(l,b)}"undefined"==typeof load&&"undefined"!=typeof read&&(this.load=(function(b){cb(read(b))}));"undefined"===typeof printErr&&(this.printErr=(function(){}));"undefined"===typeof print&&(this.print=printErr);try{this.Module=Module}catch(db){this.Module=Module={}}Module.arguments||(Module.arguments=ka);Module.print&&(print=Module.print);function vb(b){if(1==wb){return 1}var d={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+b];d||("*"==b[b.length-1]?d=wb:"i"==b[0]&&(b=parseInt(b.substr(1)),xb(0==b%8),d=b/8));return d}function Hb(b){var d=n;n+=b;n=n+3>>2<<2;return d}function Ib(b){var d=Qb;Qb+=b;Qb=Qb+3>>2<<2;if(Qb>=Rb){for(;Rb<=Qb;){Rb=2*Rb+4095>>12<<12}var b=p,c=new ArrayBuffer(Rb);p=new Int8Array(c);Sb=new Int16Array(c);r=new Int32Array(c);s=new Uint8Array(c);Tb=new Uint16Array(c);z=new Uint32Array(c);Ub=new Float32Array(c);Vb=new Float64Array(c);p.set(b)}return d}var wb=4,Yb={},Zb,B,$b;function bc(b){print(b+":\n"+Error().stack);a("Assertion: "+b)}function xb(b,d){b||bc("Assertion failed: "+d)}var cc=this;Module.ccall=(function(b,d,c,e){try{var f=eval("_"+b)}catch(i){try{f=cc.Module["_"+b]}catch(h){}}xb(f,"Cannot call unknown function "+b+" (perhaps LLVM optimizations or closure removed it?)");var g=0,b=e?e.map((function(b){if("string"==c[g++]){var d=n;Hb(b.length+1);dc(b,d);b=d}return b})):[];return(function(b,c){return"string"==c?ec(b):b})(f.apply(l,b),d)});function fc(b,d,c){c=c||"i8";"*"===c[c.length-1]&&(c="i32");switch(c){case"i1":p[b]=d;break;case"i8":p[b]=d;break;case"i16":Sb[b>>1]=d;break;case"i32":r[b>>2]=d;break;case"i64":r[b>>2]=d;break;case"float":Ub[b>>2]=d;break;case"double":gc[0]=d;r[b>>2]=hc[0];r[b+4>>2]=hc[1];break;default:bc("invalid type for setValue: "+c)}}Module.setValue=fc;Module.getValue=(function(b,d){d=d||"i8";"*"===d[d.length-1]&&(d="i32");switch(d){case"i1":return p[b];case"i8":return p[b];case"i16":return Sb[b>>1];case"i32":return r[b>>2];case"i64":return r[b>>2];case"float":return Ub[b>>2];case"double":return hc[0]=r[b>>2],hc[1]=r[b+4>>2],gc[0];default:bc("invalid type for setValue: "+d)}return l});var ic=1,D=2;Module.ALLOC_NORMAL=0;Module.ALLOC_STACK=ic;Module.ALLOC_STATIC=D;function F(b,d,c){var e,f;"number"===typeof b?(e=j,f=b):(e=m,f=b.length);var i="string"===typeof d?d:l,c=[jc,Hb,Ib][c===ca?D:c](Math.max(f,i?1:d.length));if(e){return kc(c,f),c}e=0;for(var h;e<f;){var g=b[e];"function"===typeof g&&(g=Yb.Ua(g));h=i||d[e];0===h?e++:("i64"==h&&(h="i32"),fc(c+e,g,h),e+=vb(h))}return c}Module.allocate=F;function ec(b,d){for(var c="undefined"==typeof d,e="",f=0,i,h=String.fromCharCode(0);;){i=String.fromCharCode(s[b+f]);if(c&&i==h){break}e+=i;f+=1;if(!c&&f==d){break}}return e}Module.Pointer_stringify=ec;Module.Array_stringify=(function(b){for(var d="",c=0;c<b.length;c++){d+=String.fromCharCode(b[c])}return d});var mc,nc=4096,p,s,Sb,Tb,r,z,Ub,Vb,n,oc,Qb,pc=Module.TOTAL_STACK||5242880,Rb=Module.TOTAL_MEMORY||10485760;xb(!!Int32Array&&!!Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"Cannot fallback to non-typed array case: Code is too specialized");var qc=new ArrayBuffer(Rb);p=new Int8Array(qc);Sb=new Int16Array(qc);r=new Int32Array(qc);s=new Uint8Array(qc);Tb=new Uint16Array(qc);z=new Uint32Array(qc);Ub=new Float32Array(qc);Vb=new Float64Array(qc);r[0]=255;xb(255===s[0]&&0===s[3],"Typed arrays 2 must be run on a little-endian system");var sc=rc("(null)");Qb=sc.length;for(var tc=0;tc<sc.length;tc++){p[tc]=sc[tc]}Module.HEAP=ca;Module.HEAP8=p;Module.HEAP16=Sb;Module.HEAP32=r;Module.HEAPU8=s;Module.HEAPU16=Tb;Module.HEAPU32=z;Module.HEAPF32=Ub;Module.HEAPF64=Vb;oc=(n=4*Math.ceil(Qb/4))+pc;var uc=8*Math.ceil(oc/8);p.subarray(uc);var hc=r.subarray(uc>>2);Ub.subarray(uc>>2);var gc=Vb.subarray(uc>>3);oc=uc+8;Qb=oc+4095>>12<<12;function vc(b){for(;0<b.length;){var d=b.shift(),c=d.l;"number"===typeof c&&(c=mc[c]);c(d.Pa===ca?l:d.Pa)}}var wc=[],zc=[];function Ac(b,d){return Array.prototype.slice.call(p.subarray(b,b+d))}Module.Array_copy=Ac;Module.TypedArray_copy=(function(b,d){for(var c=new Uint8Array(d),e=0;e<d;++e){c[e]=p[b+e]}return c.buffer});function Bc(b){for(var d=0;p[b+d];){d++}return d}Module.String_len=Bc;function Cc(b,d){var c=Bc(b);d&&c++;var e=Ac(b,c);d&&(e[c-1]=0);return e}Module.String_copy=Cc;function rc(b,d){for(var c=[],e=0;e<b.length;){var f=b.charCodeAt(e);255<f&&(f&=255);c.push(f);e+=1}d||c.push(0);return c}Module.intArrayFromString=rc;Module.intArrayToString=(function(b){for(var d=[],c=0;c<b.length;c++){var e=b[c];255<e&&(e&=255);d.push(String.fromCharCode(e))}return d.join("")});function dc(b,d,c){for(var e=0;e<b.length;){var f=b.charCodeAt(e);255<f&&(f&=255);p[d+e]=f;e+=1}c||(p[d+e]=0)}Module.writeStringToMemory=dc;var I=[];function Dc(b,d){return 0<=b?b:32>=d?2*Math.abs(1<<d-1)+b:Math.pow(2,d)+b}function Ec(b,d){if(0>=b){return b}var c=32>=d?Math.abs(1<<d-1):Math.pow(2,d-1);if(b>=c&&(32>=d||b>c)){b=-2*c+b}return b}function Fc(b,d,c){var e=0>(c|0)?-1:0,f=(c>>>0)+4294967296*(e|0)+(b>>>0)+4294967296*(d|0)>>>0,b=Math.min(Math.floor(((c>>>0)+4294967296*(e|0)+(b>>>0)+4294967296*(d|0))/4294967296),4294967295);return[f,b]}function Gc(b,d,c){var e=0>(c|0)?-1:0,f=(c>>>0)+4294967296*(e|0)+(b>>>0)+4294967296*(d|0)>>>0,b=Math.min(Math.floor(((c>>>0)+4294967296*(e|0)+(b>>>0)+4294967296*(d|0))/4294967296),4294967295);return[f,b]}function Hc(b){var d=p[b+11|0],c=p[b+10|0]|d<<8|0,e=p[b+9|0]|c<<8|0,f=p[b+8|0]|e<<8|0,i=p[b+7|0]|f<<8|0,h=p[b+6|0]|i<<8|0,g=p[b+5|0]|h<<8|0;return[p[b+4|0]|g<<8|0,0|((((((0|d>>>24)<<8|c>>>24)<<8|e>>>24)<<8|f>>>24)<<8|i>>>24)<<8|h>>>24)<<8|g>>>24]}Hc.X=1;function Ic(b){var d=p[b+19|0],c=p[b+18|0]|d<<8|0,e=p[b+17|0]|c<<8|0,f=p[b+16|0]|e<<8|0,i=p[b+15|0]|f<<8|0,h=p[b+14|0]|i<<8|0,g=p[b+13|0]|h<<8|0;return[p[b+12|0]|g<<8|0,0|((((((0|d>>>24)<<8|c>>>24)<<8|e>>>24)<<8|f>>>24)<<8|i>>>24)<<8|h>>>24)<<8|g>>>24]}Ic.X=1;function Jc(b){var d,c;c=(b+20|0)>>2;d=(b+24|0)>>2;var e=r[d],f=r[c]-e|0;if(0<(f|0)){var i=b+16|0,h=b+28|0,e=r[i>>2]+e|0,g=0<(f|0);a:do{if(g){for(var k=0,o=r[h>>2];;){if(o=r[Kc+((s[e+k|0]&255^o&255)<<2)>>2]^o>>>8,r[h>>2]=o,k=k+1|0,(k|0)==(f|0)){break a}}}}while(0);h=r[b+32>>2];if(e=-1<(h|0)){i=r[i>>2]+r[d]|0;r[Lc>>2]=0;e=f;a:for(;;){g=i+(f-e)|0;if(0>=(e|0)){var w=0;break}for(;;){r[Lc>>2]=0;var t=Mc(h,g,e);if(0<(t|0)){break}if(0!=(r[Lc>>2]|0)&&4!=(r[Lc>>2]|0)&&11!=(r[Lc>>2]|0)){w=e;break a}}e=e-t|0}e=(f-w|0)!=(f|0)}e&&Nc(-1);f=r[c];(f|0)<(r[b+12>>2]|0)?c=f:(w=0>(f|0)?-1:0,b=(b|0)>>2,i=r[b],h=r[b+1],t=(i>>>0)+4294967296*(h|0)+(f>>>0)+4294967296*(w|0)>>>0,f=Math.min(Math.floor(((i>>>0)+4294967296*(h|0)+(f>>>0)+4294967296*(w|0))/4294967296),4294967295),r[b]=t,r[b+1]=f,c=r[c]=0);r[d]=c}}function Oc(b){var d,c=n;n+=20;var e=b+36|0,f=0<(r[e>>2]|0)?20:12;d=(b+40|0)>>2;for(var i=r[d],h=i|0,i=Fc(r[h>>2],r[h+4>>2],r[i+12>>2]),h=i[0],g=i[1],k=0>(f|0)?-1:0,i=(h>>>0)+4294967296*(g|0)+(f>>>0)+4294967296*(k|0)>>>0,h=Math.min(Math.floor(((h>>>0)+4294967296*(g|0)+(f>>>0)+4294967296*(k|0))/4294967296),4294967295),k=g=0;(g|0)<(f|0);){if(0!=(k&1)<<24>>24){break}if(Pc(r[d])){kc(c+g|0,f-g|0),g=f,k=1}else{var o=Qc(r[d]);p[c+g|0]=o}g=g+1|0}0==(r[e>>2]|0)&&(p[c+12|0]=i&255,p[c+13|0]=(i>>>8|h<<24)&255,p[c+14|0]=(i>>>16|h<<16)&255,p[c+15|0]=(i>>>24|h<<8)&255,p[c+16|0]=h&255,p[c+17|0]=(h>>>8|0)&255,p[c+18|0]=(h>>>16|0)&255,p[c+19|0]=(h>>>24|0)&255);0==(r[r[d]+20>>2]|0)?d=k:(Rc(I.G|0),d=1);e=(s[c|0]&255|(s[c+1|0]&255|(s[c+2|0]&255|(s[c+3|0]&255)<<8)<<8)<<8|0)==(r[b+28>>2]^-1|0);g=Hc(c);f=g[0];g=g[1];k=b|0;b=Gc(r[k>>2],r[k+4>>2],r[b+20>>2]);k=Ic(c);b=(k[0]==i&&k[1]==h)&(f==b[0]&&g==b[1])&e&0==(d&1)<<24>>24;n=c;return b}Oc.X=1;function Pc(b){if((r[b+12>>2]|0)<(r[b+16>>2]|0)){b=0}else{var d=b+32|0;if(0==(p[d]&1)<<24>>24){var c;c=r[b+28>>2];var e=r[b+8>>2];r[Lc>>2]=0;var f=16384;a:for(;;){var i=e+(16384-f)|0;if(0>=(f|0)){var h=0;break}for(;;){r[Lc>>2]=0;var g=Sc(c,i,f);if(0<(g|0)){break}if(0==(g|0)){h=f;break a}if(4!=(r[Lc>>2]|0)&&11!=(r[Lc>>2]|0)){h=f;break a}}f=f-g|0}c=16384-h|0;e=b+16|0;r[e>>2]=c;16384!=(c|0)&&0!=(r[Lc>>2]|0)&&Nc(-1);c=z[e>>2];p[d]=16384>(c|0)&1;d=b+12|0;e=r[d>>2];f=0>(e|0)?-1:0;b=(b|0)>>2;h=r[b];g=r[b+1];i=(h>>>0)+4294967296*(g|0)+(e>>>0)+4294967296*(f|0)>>>0;e=Math.min(Math.floor(((h>>>0)+4294967296*(g|0)+(e>>>0)+4294967296*(f|0))/4294967296),4294967295);r[b]=i;r[b+1]=e;d=r[d>>2]=0;b=c}else{d=r[b+12>>2],b=r[b+16>>2]}b=(d|0)<(b|0)^1}return b}function Qc(b){if(Pc(b)){b=85}else{var d=b+12|0,c=r[d>>2];r[d>>2]=c+1|0;b=p[r[b+8>>2]+c|0]}return b}function Tc(b){var d,c=n;n+=29280;for(var e,f=c+192,i=c+240,h=c+288,g=c+336,k=c+384,o=c+576,w=c+1600,t=c+2060,A=c+2124,y=c+3412,C=c+4700,v=c+29276,u=c+192|0,x=c|0;;){J(x);var q=x+4|0;if((q|0)==(u|0)){break}x=q}J(f|0);J(f+4|0);J(f+8|0);J(f+12|0);J(f+16|0);J(f+20|0);J(f+24|0);J(f+28|0);J(f+32|0);J(f+36|0);J(f+40|0);J(f+44|0);J(i|0);J(i+4|0);J(i+8|0);J(i+12|0);J(i+16|0);J(i+20|0);J(i+24|0);J(i+28|0);J(i+32|0);J(i+36|0);J(i+40|0);J(i+44|0);J(h|0);J(h+4|0);J(h+8|0);J(h+12|0);J(h+16|0);J(h+20|0);J(h+24|0);J(h+28|0);J(h+32|0);J(h+36|0);J(h+40|0);J(h+44|0);J(g|0);J(g+4|0);J(g+8|0);J(g+12|0);J(g+16|0);J(g+20|0);J(g+24|0);J(g+28|0);J(g+32|0);J(g+36|0);J(g+40|0);J(g+44|0);for(var E=k+192|0,G=k|0;;){J(G);var M=G+4|0;if((M|0)==(E|0)){break}G=M}for(var W=o+1024|0,H=o|0;;){J(H);var Q=H+4|0;if((Q|0)==(W|0)){break}H=Q}for(var K=w+460|0,V=w|0;;){J(V);var Da=V+4|0;if((Da|0)==(K|0)){break}V=Da}var qa=t|0;J(qa);J(t+4|0);J(t+8|0);J(t+12|0);J(t+16|0);J(t+20|0);J(t+24|0);J(t+28|0);J(t+32|0);J(t+36|0);J(t+40|0);J(t+44|0);J(t+48|0);J(t+52|0);J(t+56|0);J(t+60|0);Uc(A);Uc(y);for(var yb=C+24576|0,eb=C|0;;){J(eb);var La=eb+4|0;if((La|0)==(yb|0)){break}eb=La}p[v|0]=0;d=(b+40|0)>>2;Vc(r[d]);var Ea=b+8|0,Ma=b+20|0,fb=b|0,zb=v|0,$=0,ma=0,fa=0,S=0;a:for(;;){b:for(;;){if(Pc(r[d])){Jc(b);var na=2;break a}var oa=fb|0,gb=fb+4|0,Na=Gc(r[oa>>2],r[gb>>2],r[Ma>>2])[0]&3,Ab=s[zb],ra=Ab&255;if(0==(Wc(r[d],(ra<<4)+(Na<<2)+c|0)|0)){var Oa,Jb=r[b+20>>2];Oa=p[r[b+16>>2]+((0<(Jb|0)?Jb:r[b+12>>2])-1)|0];var U=r[d];if(7>(Ab&255)){var aa=Xc(U,C+3072*((Oa&255)>>5)|0,8)&255;Yc(b,aa)}else{for(var ta=r[b+20>>2]-$-1|0,Fa=U,Pa=C+3072*((Oa&255)>>5)|0,hb=p[r[b+16>>2]+(0>(ta|0)?r[b+12>>2]+ta|0:ta)|0]&255,ib=ca,Y=7,jb=1;;){if(-1>=(Y|0)){var Qa=jb,ib=7;break}var Ra=hb>>>(Y>>>0)&1,Sa=Wc(Fa,((Ra<<8)+jb+256<<2)+Pa|0),kb=Sa|jb<<1;if((Ra|0)!=(Sa|0)){ib=4;break}Y=Y-1|0;jb=kb}c:do{if(4==ib){if(0<(Y|0)){for(var ua=kb,va=Y;;){var Ta=va-1|0,Bb=ua<<1,lb=Wc(Fa,(ua<<2)+Pa|0)|Bb;if(0>=(Ta|0)){Qa=lb;break c}ua=lb;va=Ta}}else{Qa=kb}}}while(0);Yc(b,Qa&255)}var ga=v|0;p[ga]=p[I.D+(s[ga]&255)|0]}else{var Ga=Wc(r[d],(ra<<2)+f|0),Wb=z[d];if(1==(Ga|0)){var Kb=1==(Wc(Wb,(ra<<2)+i|0)|0),Cb=r[d];do{if(!Kb){if(0!=(Wc(Cb,(ra<<4)+(Na<<2)+k|0)|0)){var mb=$,nb=ma,N=fa,da=S;break}var ba=v|0;p[ba]=p[I.B+(s[ba]&255)|0];var Ha=$,Ua=ma,Va=fa,Wa=S,wa=1;e=37;break b}if(0==(Wc(Cb,(ra<<2)+h|0)|0)){mb=ma,nb=$,N=fa,da=S}else{var Lb=0==(Wc(r[d],(ra<<2)+g|0)|0),Mb=Lb?S:fa,mb=Lb?fa:S,nb=$,N=ma,da=Mb}}while(0);var Nb=v|0;p[Nb]=p[I.C+(s[Nb]&255)|0];var Xb=Zc(y,r[d],Na),Ha=mb,Ua=nb,Va=N,Wa=da,wa=Xb+2|0;e=37;break}var Xa=Zc(A,Wb,Na),ha=Xa+2|0,Z=ha-2|0,xa=Xc(r[d],((3<(Z|0)?3:Z)<<8)+o|0,6);if(4>(xa|0)){var ya=xa;e=33;break}var Db=xa>>1,ob=Db-1|0,Ya=(xa&1|2)<<ob,Eb=r[d];if(14>(xa|0)){ya=$c(Eb,(Ya-xa<<2)+w|0,ob)+Ya|0;e=33;break}var pb=Eb,qb=Db-5|0,ia=ca,za=ca,Aa=0<(qb|0);c:do{if(Aa){for(var za=(pb+24|0)>>2,ia=(pb+20|0)>>2,ja=0,rb=qb,ea=r[za];;){var Za=ja<<1;if(16777216>ea>>>0){r[za]=ea<<7;var Ob=r[ia]<<8,sb=Qc(pb)&255|Ob;r[ia]=sb;var Ia=z[za];if(sb>>>0<Ia>>>0){var Ja=Za,tb=Ia}else{r[ia]=sb-Ia|0,Ja=Za|1,tb=Ia}}else{var $a=ea>>>1;r[za]=$a;var Fb=z[ia];Fb>>>0<$a>>>0?Ja=Za:(r[ia]=Fb-$a|0,Ja=Za|1);tb=$a}var pa=rb-1|0;if(0>=(pa|0)){var Gb=Ja;break c}ja=Ja;rb=pa;ea=tb}}else{Gb=0}}while(0);var ub=Gb<<4,Ba=$c(r[d],qa,4),Pb=ub+Ya+Ba|0;if(-1!=(Pb|0)){ya=Pb;e=33;break}ad(r[d]);Jc(b);if(0==(Xa|0)){na=Oc(b)?0:3;break a}if(3!=(ha|0)){na=4;break a}Vc(r[d])}}do{if(33==e){var ab=v|0;p[ab]=p[I.F+(s[ab]&255)|0];if(ya>>>0<z[Ea>>2]>>>0){if(ya>>>0<z[Ma>>2]>>>0){Ha=ya;Ua=$;Va=ma;Wa=fa;wa=ha;break}oa=fb|0;gb=fb+4|0;if(!(0==r[oa>>2]&&0==r[gb>>2])){Ha=ya;Ua=$;Va=ma;Wa=fa;wa=ha;break}}Jc(b);na=1;break a}}while(0);bd(b,Ha,wa);$=Ha;ma=Ua;fa=Va;S=Wa}n=c;return na}Tc.X=1;function Vc(b){var d;d=(b+20|0)>>2;r[d]=0;r[b+24>>2]=-1;var c=Qc(b)&255;r[d]=c;c=Qc(b)&255|c<<8;r[d]=c;c=Qc(b)&255|c<<8;r[d]=c;c=Qc(b)&255|c<<8;r[d]=c;c<<=8;b=Qc(b);r[d]=b&255|c}function J(b){r[b>>2]=1024}function Wc(b,d){var c,e;ad(b);e=(b+24|0)>>2;var f=z[e];c=(d|0)>>2;var i=(f>>>11)*r[c]|0,h=b+20|0,g=z[h>>2];g>>>0<i>>>0?(r[e]=i,f=z[c],e=0,f=((2048-f|0)>>>5)+f|0):(r[e]=f-i|0,r[h>>2]=g-i|0,f=z[c],e=1,f=f-(f>>>5)|0);r[c]=f;return e}function Yc(b,d){var c;c=(b+20|0)>>2;p[r[b+16>>2]+r[c]|0]=d;var e=r[c]+1|0;r[c]=e;(e|0)<(r[b+12>>2]|0)||Jc(b)}function Zc(b,d,c){return 0==(Wc(d,b|0)|0)?Xc(d,(c<<5)+b+8|0,3):0==(Wc(d,b+4|0)|0)?Xc(d,(c<<5)+b+136|0,3)+8|0:Xc(d,b+264|0,8)+16|0}function Xc(b,d,c){var e=0<(c|0);a:do{if(e){for(var f=1,i=c;;){var h=f<<1,f=Wc(b,(f<<2)+d|0)|h,i=i-1|0;if(0>=(i|0)){var g=f;break a}}}else{g=1}}while(0);return g-(1<<c)|0}function $c(b,d,c){var e=0<(c|0);a:do{if(e){for(var f=1,i=0,h=0;;){var g=Wc(b,(f<<2)+d|0),f=f<<1;0!=(g|0)&&(i|=1<<h,f|=1);h=h+1|0;if((h|0)==(c|0)){var k=i;break a}}}else{k=0}}while(0);return k}function ad(b){var d=b+24|0,c=z[d>>2];16777216>c>>>0&&(r[d>>2]=c<<8,d=b+20|0,c=r[d>>2]<<8,b=Qc(b)&255|c,r[d>>2]=b)}function bd(b,d,c){var e,f;e=(b+20|0)>>2;var i=r[e],h=i-d-1|0,d=(b+12|0)>>2;f=r[d];h=h+(0>(h|0)?f:0)|0;if((f-((i|0)>(h|0)?i:h)|0)>(c|0)){if(f=i-h|0,((-1<(f|0)?f:-f|0)|0)<(c|0)){f=3}else{f=r[b+16>>2];var g=f+i|0,k=f+h|0;f=c;if(20<=f&&k%2==g%2){if(k%4==g%4){for(f=k+f;k%4;){p[g++]=p[k++]}for(var k=k>>2,g=g>>2,o=f>>2;k<o;){r[g++]=r[k++]}k<<=2;for(g<<=2;k<f;){p[g++]=p[k++]}}else{f=k+f;k%2&&(p[g++]=p[k++]);k>>=1;g>>=1;for(o=f>>1;k<o;){Sb[g++]=Sb[k++]}k<<=1;g<<=1;k<f&&(p[g++]=p[k++])}}else{for(;f--;){p[g++]=p[k++]}}r[e]=r[e]+c|0;f=10}}else{f=3}a:do{if(3==f&&0<(c|0)){for(var g=b+16|0,k=c,o=h,w=i;;){var t=r[g>>2];p[t+w|0]=p[t+o|0];w=r[e]+1|0;r[e]=w;t=r[d];(w|0)<(t|0)?w=t:(Jc(b),w=r[d]);o=o+1|0;k=k-1|0;if(0>=(k|0)){break a}o=(o|0)<(w|0)?o:0;w=r[e]}}}while(0)}bd.X=1;function Uc(b){J(b|0);J(b+4|0);J(b+8|0);J(b+12|0);J(b+16|0);J(b+20|0);J(b+24|0);J(b+28|0);J(b+32|0);J(b+36|0);J(b+40|0);J(b+44|0);J(b+48|0);J(b+52|0);J(b+56|0);J(b+60|0);J(b+64|0);J(b+68|0);J(b+72|0);J(b+76|0);J(b+80|0);J(b+84|0);J(b+88|0);J(b+92|0);J(b+96|0);J(b+100|0);J(b+104|0);J(b+108|0);J(b+112|0);J(b+116|0);J(b+120|0);J(b+124|0);J(b+128|0);J(b+132|0);J(b+136|0);J(b+140|0);J(b+144|0);J(b+148|0);J(b+152|0);J(b+156|0);J(b+160|0);J(b+164|0);J(b+168|0);J(b+172|0);J(b+176|0);J(b+180|0);J(b+184|0);J(b+188|0);J(b+192|0);J(b+196|0);J(b+200|0);J(b+204|0);J(b+208|0);J(b+212|0);J(b+216|0);J(b+220|0);J(b+224|0);J(b+228|0);J(b+232|0);J(b+236|0);J(b+240|0);J(b+244|0);J(b+248|0);J(b+252|0);J(b+256|0);J(b+260|0);for(var d=b+1288|0,b=b+264|0;!(J(b),b=b+4|0,(b|0)==(d|0));){}}Uc.X=1;function Rc(b){0!=(b|0)&&Mc(r[r[cd>>2]+12>>2],b,Bc(b))}function dd(b,d,c){if(-1<(r[ed>>2]|0)){if(0!=(b|0)&&0!=p[b]<<24>>24){fd(r[r[cd>>2]+12>>2],I.H|0,(B=n,n+=8,r[B>>2]=I.i|0,r[B+4>>2]=b,B));if(0<(d|0)){var b=r[r[cd>>2]+12>>2],e;gd||(gd=jc(256));e=gd;if(d in hd){if(255<hd[d].length){L(id)}else{for(var d=hd[d],f=0;f<d.length;f++){p[e+f]=d.charCodeAt(f)}p[e+f]=0}}else{L(jd)}e=gd;fd(b,I.K|0,(B=n,n+=4,r[B>>2]=e,B))}kd(r[r[cd>>2]+12>>2])}b=r[ld>>2];0!=(b|0)&c&&0!=p[b]<<24>>24&&fd(r[r[cd>>2]+12>>2],I.aa|0,(B=n,n+=4,r[B>>2]=b,B))}}function md(b,d){r[ld>>2]=r[d>>2];var c=1,e=0;a:for(;;){if((c|0)>=(b|0)){(c=2==(e|0))&&(p[nd]=0);p[nd]=1;var f=ca;if(0==(e|0)&s[nd]){if(0==(od(2)|0)){f=4}else{dd(I.Y|0,0,1);var i=0,f=7}}else{f=4}4==f&&(2>(e-1|0)>>>0?0==(od(1)|0)?i=1:(dd(I.Z|0,0,1),i=0):i=1);if(!i){f=1;break}i=pd(c);i=0<(i|0)?i:0;if(!s[nd]){f=i;break}O[2]?(O[2].Ra&&qd(O[2].Ra),delete O[2],e=0):(L(rd),e=-1);if(0==(e|0)){f=i;break}dd(I.ka|0,r[Lc>>2],0);if(1<=(i|0)){f=i;break}f=1;break}var h=p[r[d+(c<<2)>>2]+1|0]<<24>>24;do{if(99==(h|0)||107==(h|0)){var g=e}else{if(100==(h|0)){g=1}else{if(104==(h|0)){i=n;sd(I.fa|0,(B=n,n+=4,r[B>>2]=I.p|0,B));P(I.na|0);e=r[ld>>2];sd(I.ga|0,(B=n,n+=4,r[B>>2]=e,B));P(I.oa|0);P(I.za|0);P(I.Ia|0);P(I.Ja|0);P(I.Ka|0);P(I.La|0);P(I.Ma|0);P(I.Na|0);P(I.Oa|0);P(I.pa|0);P(I.qa|0);P(I.ra|0);P(I.sa|0);P(I.ta|0);P(I.ua|0);P(I.va|0);P(I.wa|0);P(I.xa|0);P(I.ya|0);sd(I.ja|0,(B=n,n+=4,r[B>>2]=I.i|0,B));P(I.Aa|0);P(I.Ba|0);P(I.Ca|0);P(I.Da|0);P(I.Ea|0);n=i;f=0;break a}else{if(113==(h|0)){r[ed>>2]=-1,g=e}else{if(118==(h|0)){g=r[ed>>2],4>(g|0)&&(r[ed>>2]=g+1|0),g=e}else{if(86==(h|0)){i=n;sd(I.$|0,(B=n,n+=8,r[B>>2]=I.p|0,r[B+4>>2]=I.ba|0,B));sd(I.ca|0,(B=n,n+=4,r[B>>2]=I.da|0,B));P(I.Fa|0);P(I.Ga|0);P(I.Ha|0);n=i;f=0;break a}else{-1<(r[ed>>2]|0)&&fd(r[r[cd>>2]+12>>2],I.ha|0,(B=n,n+=8,r[B>>2]=I.i|0,r[B+4>>2]=I.ia|0,B)),Nc(3),g=e}}}}}}}while(0);c=c+1|0;e=g}return f}Module._main=md;md.X=1;function td(b){var b=b&255,d=1<<(b&31);return 536866816>(d-4097|0)>>>0?d-d/16*(b>>>5)|0:d}function pd(b){var d=n;n+=88;var c,e=d+36,f=d+44,i=d>>2,h=d|0;r[h>>2]=0;r[h+4>>2]=0;var h=d+8|0,g=ud(16384);r[h>>2]=g;r[i+3]=0;r[i+4]=0;r[i+5]=0;r[i+6]=-1;r[i+7]=1;p[d+32|0]=0;for(var h=e+4|0,g=e+5|0,k=d|0,o=d+12|0,i=f+16|0,w=0,t=0,A=1;;){c=-r[d+12>>2]|0;var y=0>(c|0)?-1:0,C=d|0;r[C>>2]=c;r[C+4>>2]=y;for(c=0;6>(c|0);){if(Pc(d)){break}y=Qc(d);p[e+c|0]=y;c=c+1|0}if(Pc(d)){if(!A){c=41;break}Rc(I.la|0);var v=1;c=45;break}a:{c=I.z|0;for(y=0;4>y;y++){var C=p[(e|0)+y],u=p[c+y];if(C!=u){c=C>u?1:-1;break a}}c=0}if(0!=(c|0)){if(!A){c=41;break}Rc(I.ma|0);v=2;c=45;break}y=s[h];if(2<=(y&255)){if(-1>=(r[ed>>2]|0)){v=2;c=45;break}Rc(0);v=y&255;fd(r[r[cd>>2]+12>>2],I.I|0,(B=n,n+=4,r[B>>2]=v,B));v=2;c=45;break}u=td(p[g]);if(536866816<(u-4096|0)>>>0){Rc(I.J|0);v=2;c=45;break}c=r[ed>>2];c=1<(c|0)?25:1!=(c|0)|A^1?27:25;if(25==c&&(Rc(0),1<(r[ed>>2]|0))){for(var A=r[r[cd>>2]+12>>2],C=0>(u|0)?-1:0,x=vd|0,q=0;8>(q|0);){var E=-1<(C|0)||-1==(C|0)&&4294967295<u>>>0,G=0-((u>>>0)+4294967296*(C|0))>>>0,M=Math.min(Math.floor((0-((u>>>0)+4294967296*(C|0)))/4294967296),4294967295),G=E?u:G,E=E?C:M;if(!(0<(E|0)||0==(E|0)&&9999<G>>>0)){if(!((0<(E|0)||0==(E|0)&&1023<G>>>0)&(0==(u&1023)&&0==(C&0)))){break}}x=($b=((u>>>0)+4294967296*(C|0))/1024,0<=$b?Math.floor($b):Math.ceil($b))>>>0;C=Math.min(Math.floor(($b=((u>>>0)+4294967296*(C|0))/1024,0<=$b?Math.floor($b):Math.ceil($b))/4294967296),4294967295);u=x;x=r[wd+(q<<2)>>2];q=q+1|0}q=xd|0;C=(B=n,n+=12,r[B>>2]=u,r[B+4>>2]=C,r[B+8>>2]=x,B);C=yd(I.W|0,C);u=Math.min(C.length,15);for(x=0;x<u;x++){p[q+x]=C[x]}p[q+x]=0;y&=255;fd(A,I.L|0,(B=n,n+=8,r[B>>2]=y,r[B+4>>2]=xd|0,B))}A=f;y=e;C=d;u=s[nd]?2:-1;x=A>>2;q=A|0;r[q>>2]=0;r[q+4>>2]=0;E=td(p[y+5|0]);r[(A+8|0)>>2]=E;q=A+12|0;M=65536>(E|0)?65536:E;r[q>>2]=M;E=A+16|0;M=ud(-1<(M|0)?M:-1);r[E>>2]=M;r[x+5]=0;r[x+6]=0;r[x+7]=-1;r[x+8]=u;r[(A+36|0)>>2]=p[y+4|0]&255;r[x+10]=C;p[M+(r[q>>2]-1)|0]=0;y=Tc(f);A=Fc(r[k>>2],r[k+4>>2],r[o>>2]);C=A[0];u=A[1];A=(C>>>0)+4294967296*(u|0)+(t>>>0)+4294967296*(w|0)>>>0;w=Math.min(Math.floor(((C>>>0)+4294967296*(u|0)+(t>>>0)+4294967296*(w|0))/4294967296),4294967295);t=z[ed>>2];if(0!=(y|0)){-1<(t|0)&3>(y|0)&&(Rc(0),v=r[r[cd>>2]+12>>2],2==(y|0)?fd(v,I.M|0,(B=n,n+=8,r[B>>2]=A,r[B+4>>2]=w,B)):fd(v,I.N|0,(B=n,n+=8,r[B>>2]=A,r[B+4>>2]=w,B)));v=r[i>>2];0!=(v|0)&&zd(v);v=2;c=45;break}1<(t|0)&&(t=r[r[cd>>2]+12>>2],b?Ad(I.n|0,3,1,t):Ad(I.o|0,5,1,t));t=r[i>>2];0!=(t|0)&&zd(t);t=A;A=0}41==c&&(1==(r[ed>>2]|0)&&(v=r[r[cd>>2]+12>>2],b?Ad(I.n|0,3,1,v):Ad(I.o|0,5,1,v)),v=0);b=r[d+8>>2];0!=(b|0)&&zd(b);n=d;return v}pd.X=1;function jc(b){var d,c=245>b>>>0;do{if(c){var e=11>b>>>0?16:b+11&-8,f=e>>>3;d=z[R>>2];var i=d>>>(f>>>0);if(0!=(i&3|0)){var b=(i&1^1)+f|0,e=b<<1,c=(e<<2)+R+40|0,f=(e+2<<2)+R+40|0,h=z[f>>2],e=h+8|0,i=z[e>>2];(c|0)==(i|0)?r[R>>2]=d&(1<<b^-1):(i>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[f>>2]=i,r[i+12>>2]=c);d=b<<3;r[h+4>>2]=d|3;d=h+(d|4)|0;r[d>>2]|=1;h=e;d=38;break}if(e>>>0<=z[R+8>>2]>>>0){var g=e;d=30;break}if(0!=(i|0)){var b=2<<f,b=i<<f&(b|-b),c=(b&-b)-1|0,b=c>>>12&16,h=c>>>(b>>>0),c=h>>>5&8,f=h>>>(c>>>0),h=f>>>2&4,i=f>>>(h>>>0),f=i>>>1&2,i=i>>>(f>>>0),k=i>>>1&1,h=(c|b|h|f|k)+(i>>>(k>>>0))|0,b=h<<1,f=(b<<2)+R+40|0,i=(b+2<<2)+R+40|0,c=z[i>>2],b=c+8|0,k=z[b>>2];(f|0)==(k|0)?r[R>>2]=d&(1<<h^-1):(k>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[i>>2]=k,r[k+12>>2]=f);h<<=3;d=h-e|0;r[c+4>>2]=e|3;f=c;c=f+e|0;r[f+(e|4)>>2]=d|1;r[f+h>>2]=d;k=z[R+8>>2];0!=(k|0)&&(e=r[R+20>>2],f=k>>>2&1073741822,h=(f<<2)+R+40|0,i=z[R>>2],k=1<<(k>>>3),0==(i&k|0)?(r[R>>2]=i|k,i=h,f=(f+2<<2)+R+40|0):(f=(f+2<<2)+R+40|0,i=z[f>>2],i>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"))),r[f>>2]=e,r[i+12>>2]=e,r[(e+8|0)>>2]=i,r[(e+12|0)>>2]=h);r[R+8>>2]=d;r[R+20>>2]=c;h=b;d=38;break}if(0==(r[R+4>>2]|0)){g=e;d=30;break}d=Bd(e);if(0==(d|0)){g=e;d=30;break}h=d}else{if(4294967231<b>>>0){g=-1;d=30;break}d=b+11&-8;if(0==(r[R+4>>2]|0)){g=d;d=30;break}e=Cd(d);if(0==(e|0)){g=d;d=30;break}h=e}d=38}while(0);30==d&&(e=z[R+8>>2],g>>>0>e>>>0?(d=z[R+12>>2],g>>>0<d>>>0?(d=d-g|0,r[R+12>>2]=d,e=z[R+24>>2],r[R+24>>2]=e+g|0,r[g+(e+4)>>2]=d|1,r[e+4>>2]=g|3,h=e+8|0):h=Dd(g)):(b=e-g|0,d=z[R+20>>2],15<b>>>0?(r[R+20>>2]=d+g|0,r[R+8>>2]=b,r[g+(d+4)>>2]=b|1,r[d+e>>2]=b,r[d+4>>2]=g|3):(r[R+8>>2]=0,r[R+20>>2]=0,r[d+4>>2]=e|3,g=e+(d+4)|0,r[g>>2]|=1),h=d+8|0));return h}Module._malloc=jc;jc.X=1;function Bd(b){var d,c,e=r[R+4>>2],f=(e&-e)-1|0,e=f>>>12&16,i=f>>>(e>>>0),f=i>>>5&8;c=i>>>(f>>>0);var i=c>>>2&4,h=c>>>(i>>>0);c=h>>>1&2;var h=h>>>(c>>>0),g=h>>>1&1,e=f=z[R+((f|e|i|c|g)+(h>>>(g>>>0))<<2)+304>>2];c=e>>2;f=(r[f+4>>2]&-8)-b|0;a:for(;;){for(i=e;;){h=r[i+16>>2];if(0==(h|0)){if(i=r[i+20>>2],0==(i|0)){break a}}else{i=h}h=(r[i+4>>2]&-8)-b|0;if(h>>>0<f>>>0){e=i;c=e>>2;f=h;continue a}}}var h=e,k=z[R+16>>2],g=h>>>0<k>>>0;do{if(!g){var o=h+b|0,i=o;if(h>>>0<o>>>0){var g=z[c+6],o=z[c+3],w=(o|0)==(e|0);do{if(w){d=e+20|0;var t=r[d>>2];if(0==(t|0)&&(d=e+16|0,t=r[d>>2],0==(t|0))){t=0;d=t>>2;break}for(;;){var A=t+20|0,y=r[A>>2];if(0==(y|0)&&(A=t+16|0,y=z[A>>2],0==(y|0))){break}d=A;t=y}d>>>0<k>>>0&&(T(),a("Reached an unreachable!"));r[d>>2]=0}else{d=z[c+2],d>>>0<k>>>0&&(T(),a("Reached an unreachable!")),r[d+12>>2]=o,r[o+8>>2]=d,t=o}d=t>>2}while(0);k=0==(g|0);a:do{if(!k){o=e+28|0;w=(r[o>>2]<<2)+R+304|0;A=(e|0)==(r[w>>2]|0);do{if(A){r[w>>2]=t;if(0!=(t|0)){break}r[R+4>>2]&=1<<r[o>>2]^-1;break a}g>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));y=g+16|0;(r[y>>2]|0)==(e|0)?r[y>>2]=t:r[g+20>>2]=t;if(0==(t|0)){break a}}while(0);t>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[d+6]=g;o=z[c+4];0!=(o|0)&&(o>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+4]=o,r[o+24>>2]=t);o=z[c+5];0!=(o|0)&&(o>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+5]=o,r[o+24>>2]=t)}}while(0);16>f>>>0?(b=f+b|0,r[c+1]=b|3,b=b+(h+4)|0,r[b>>2]|=1):(r[c+1]=b|3,r[b+(h+4)>>2]=f|1,r[h+f+b>>2]=f,k=z[R+8>>2],0!=(k|0)&&(b=z[R+20>>2],h=k>>>2&1073741822,c=(h<<2)+R+40|0,g=z[R>>2],k=1<<(k>>>3),0==(g&k|0)?(r[R>>2]=g|k,g=c,h=(h+2<<2)+R+40|0):(h=(h+2<<2)+R+40|0,g=z[h>>2],g>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"))),r[h>>2]=b,r[g+12>>2]=b,r[b+8>>2]=g,r[b+12>>2]=c),r[R+8>>2]=f,r[R+20>>2]=i);return e+8|0}}}while(0);T();a("Reached an unreachable!")}Bd.X=1;function Cd(b){var d,c,e,f,i,h=b>>2,g=-b|0,k=b>>>8;if(0==(k|0)){var o=0}else{if(16777215<b>>>0){o=31}else{var w=(k+1048320|0)>>>16&8,t=k<<w,A=(t+520192|0)>>>16&4,y=t<<A,C=(y+245760|0)>>>16&2,v=14-(A|w|C)+(y<<C>>>15)|0,o=b>>>((v+7|0)>>>0)&1|v<<1}}var u=z[R+(o<<2)+304>>2],x=0==(u|0);a:do{if(x){var q=0,E=g,G=0}else{var M=31==(o|0)?0:25-(o>>>1)|0,W=0,H=g,Q=u;i=Q>>2;for(var K=b<<M,V=0;;){var Da=r[i+1]&-8,qa=Da-b|0;if(qa>>>0<H>>>0){if((Da|0)==(b|0)){q=Q;E=qa;G=Q;break a}var yb=Q,eb=qa}else{yb=W,eb=H}var La=z[i+5],Ea=z[((K>>>31<<2)+16>>2)+i],Ma=0==(La|0)|(La|0)==(Ea|0)?V:La;if(0==(Ea|0)){q=yb;E=eb;G=Ma;break a}W=yb;H=eb;Q=Ea;i=Q>>2;K<<=1;V=Ma}}}while(0);if(0==(G|0)&0==(q|0)){var fb=2<<o,zb=r[R+4>>2]&(fb|-fb);if(0==(zb|0)){var $=G}else{var ma=(zb&-zb)-1|0,fa=ma>>>12&16,S=ma>>>(fa>>>0),na=S>>>5&8,oa=S>>>(na>>>0),gb=oa>>>2&4,Na=oa>>>(gb>>>0),Ab=Na>>>1&2,ra=Na>>>(Ab>>>0),Oa=ra>>>1&1,$=r[R+((na|fa|gb|Ab|Oa)+(ra>>>(Oa>>>0))<<2)+304>>2]}}else{$=G}var Jb=0==($|0);a:do{if(Jb){var U=E,aa=q;f=aa>>2}else{var ta=$;e=ta>>2;for(var Fa=E,Pa=q;;){var hb=(r[e+1]&-8)-b|0,ib=hb>>>0<Fa>>>0,Y=ib?hb:Fa,jb=ib?ta:Pa,Qa=z[e+4];if(0!=(Qa|0)){ta=Qa}else{var Ra=z[e+5];if(0==(Ra|0)){U=Y;aa=jb;f=aa>>2;break a}ta=Ra}e=ta>>2;Fa=Y;Pa=jb}}}while(0);var Sa=0==(aa|0);a:do{if(Sa){var kb=0}else{if(U>>>0<(r[R+8>>2]-b|0)>>>0){var ua=aa;c=ua>>2;var va=z[R+16>>2],Ta=ua>>>0<va>>>0;do{if(!Ta){var Bb=ua+b|0,lb=Bb;if(ua>>>0<Bb>>>0){var ga=z[f+6],Ga=z[f+3],Wb=(Ga|0)==(aa|0);do{if(Wb){var Kb=aa+20|0,Cb=r[Kb>>2];if(0==(Cb|0)){var mb=aa+16|0,nb=r[mb>>2];if(0==(nb|0)){var N=0;d=N>>2;break}var da=mb,ba=nb}else{da=Kb,ba=Cb}for(;;){var Ha=ba+20|0,Ua=r[Ha>>2];if(0!=(Ua|0)){da=Ha,ba=Ua}else{var Va=ba+16|0,Wa=z[Va>>2];if(0==(Wa|0)){break}da=Va;ba=Wa}}da>>>0<va>>>0&&(T(),a("Reached an unreachable!"));r[da>>2]=0;N=ba}else{var wa=z[f+2];wa>>>0<va>>>0&&(T(),a("Reached an unreachable!"));r[wa+12>>2]=Ga;r[Ga+8>>2]=wa;N=Ga}d=N>>2}while(0);var Lb=0==(ga|0);b:do{if(!Lb){var Mb=aa+28|0,Nb=(r[Mb>>2]<<2)+R+304|0,Xb=(aa|0)==(r[Nb>>2]|0);do{if(Xb){r[Nb>>2]=N;if(0!=(N|0)){break}r[R+4>>2]&=1<<r[Mb>>2]^-1;break b}ga>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));var Xa=ga+16|0;(r[Xa>>2]|0)==(aa|0)?r[Xa>>2]=N:r[ga+20>>2]=N;if(0==(N|0)){break b}}while(0);N>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[d+6]=ga;var ha=z[f+4];0!=(ha|0)&&(ha>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+4]=ha,r[ha+24>>2]=N);var Z=z[f+5];0!=(Z|0)&&(Z>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+5]=Z,r[Z+24>>2]=N)}}while(0);var xa=16>U>>>0;b:do{if(xa){var ya=U+b|0;r[f+1]=ya|3;var Db=ya+(ua+4)|0;r[Db>>2]|=1}else{if(r[f+1]=b|3,r[h+(c+1)]=U|1,r[(U>>2)+c+h]=U,256>U>>>0){var ob=U>>>2&1073741822,Ya=(ob<<2)+R+40|0,Eb=z[R>>2],pb=1<<(U>>>3);if(0==(Eb&pb|0)){r[R>>2]=Eb|pb;var qb=Ya,ia=(ob+2<<2)+R+40|0}else{var za=(ob+2<<2)+R+40|0,Aa=z[za>>2];Aa>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));qb=Aa;ia=za}r[ia>>2]=lb;r[qb+12>>2]=lb;r[h+(c+2)]=qb;r[h+(c+3)]=Ya}else{var ja=Bb,rb=U>>>8;if(0==(rb|0)){var ea=0}else{if(16777215<U>>>0){ea=31}else{var Za=(rb+1048320|0)>>>16&8,Ob=rb<<Za,sb=(Ob+520192|0)>>>16&4,Ia=Ob<<sb,Ja=(Ia+245760|0)>>>16&2,tb=14-(sb|Za|Ja)+(Ia<<Ja>>>15)|0,ea=U>>>((tb+7|0)>>>0)&1|tb<<1}}var $a=(ea<<2)+R+304|0;r[h+(c+7)]=ea;var Fb=b+(ua+16)|0;r[h+(c+5)]=0;r[Fb>>2]=0;var pa=r[R+4>>2],Gb=1<<ea;if(0==(pa&Gb|0)){r[R+4>>2]=pa|Gb,r[$a>>2]=ja,r[h+(c+6)]=$a,r[h+(c+3)]=ja,r[h+(c+2)]=ja}else{for(var ub=U<<(31==(ea|0)?0:25-(ea>>>1)|0),Ba=r[$a>>2];;){if((r[Ba+4>>2]&-8|0)==(U|0)){var Pb=Ba+8|0,ab=z[Pb>>2],lc=z[R+16>>2],xc=Ba>>>0<lc>>>0;do{if(!xc&&ab>>>0>=lc>>>0){r[ab+12>>2]=ja;r[Pb>>2]=ja;r[h+(c+2)]=ab;r[h+(c+3)]=Ba;r[h+(c+6)]=0;break b}}while(0);T();a("Reached an unreachable!")}var ac=(ub>>>31<<2)+Ba+16|0,yc=z[ac>>2];if(0==(yc|0)){if(ac>>>0>=z[R+16>>2]>>>0){r[ac>>2]=ja;r[h+(c+6)]=Ba;r[h+(c+3)]=ja;r[h+(c+2)]=ja;break b}T();a("Reached an unreachable!")}ub<<=1;Ba=yc}}}}}while(0);kb=aa+8|0;break a}}}while(0);T();a("Reached an unreachable!")}kb=0}}while(0);return kb}Cd.X=1;function Dd(b){var d,c;0==(r[X>>2]|0)&&Ed();var e=0==(r[R+440>>2]&4|0);do{if(e){c=r[R+24>>2];if(0==(c|0)){c=6}else{if(c=Fd(c),0==(c|0)){c=6}else{var f=r[X+8>>2],f=b+47-r[R+12>>2]+f&-f;if(2147483647>f>>>0){var i=Gd(f);if((i|0)==(r[c>>2]+r[c+4>>2]|0)){var h=i,g=f;d=i;c=13}else{var k=i,o=f;c=15}}else{c=14}}}if(6==c){if(c=Gd(0),-1==(c|0)){c=14}else{var f=r[X+8>>2],f=f+(b+47)&-f,i=c,w=r[X+4>>2],t=w-1|0,f=0==(t&i|0)?f:f-i+(t+i&-w)|0;2147483647>f>>>0?(i=Gd(f),(i|0)==(c|0)?(h=c,g=f,d=i,c=13):(k=i,o=f,c=15)):c=14}}if(13==c){if(-1!=(h|0)){var A=g,y=h;c=26;break}k=d;o=g}else{if(14==c){r[R+440>>2]|=4;c=23;break}}c=-o|0;if(-1!=(k|0)&2147483647>o>>>0){if(o>>>0<(b+48|0)>>>0){f=r[X+8>>2],f=b+47-o+f&-f,2147483647>f>>>0?-1==(Gd(f)|0)?(Gd(c),c=22):(C=f+o|0,c=21):(C=o,c=21)}else{var C=o;c=21}}else{C=o,c=21}21==c&&-1!=(k|0)?(A=C,y=k,c=26):(r[R+440>>2]|=4,c=23)}else{c=23}}while(0);23==c&&(e=r[X+8>>2],e=e+(b+47)&-e,2147483647>e>>>0?(e=Gd(e),h=Gd(0),-1!=(h|0)&-1!=(e|0)&e>>>0<h>>>0?(h=h-e|0,h>>>0<=(b+40|0)>>>0|-1==(e|0)?c=49:(A=h,y=e,c=26)):c=49):c=49);a:do{if(26==c){e=r[R+432>>2]+A|0;r[R+432>>2]=e;e>>>0>z[R+436>>2]>>>0&&(r[R+436>>2]=e);e=z[R+24>>2];h=0==(e|0);b:do{if(h){g=z[R+16>>2];0==(g|0)|y>>>0<g>>>0&&(r[R+16>>2]=y);r[R+444>>2]=y;r[R+448>>2]=A;r[R+456>>2]=0;r[R+36>>2]=r[X>>2];r[R+32>>2]=-1;for(g=0;!(d=g<<1,k=(d<<2)+R+40|0,r[R+(d+3<<2)+40>>2]=k,r[R+(d+2<<2)+40>>2]=k,g=g+1|0,32==(g|0));){}Hd(y,A-40|0)}else{k=R+444|0;for(d=k>>2;0!=(k|0);){g=z[d];k=k+4|0;o=z[k>>2];C=g+o|0;if((y|0)==(C|0)){if(0!=(r[d+3]&8|0)){break}d=e;if(!(d>>>0>=g>>>0&d>>>0<C>>>0)){break}r[k>>2]=o+A|0;Hd(r[R+24>>2],r[R+12>>2]+A|0);break b}k=r[d+2];d=k>>2}y>>>0<z[R+16>>2]>>>0&&(r[R+16>>2]=y);d=y+A|0;for(k=R+444|0;0!=(k|0);){o=k|0;g=z[o>>2];if((g|0)==(d|0)){if(0!=(r[k+12>>2]&8|0)){break}r[o>>2]=y;var v=k+4|0;r[v>>2]=r[v>>2]+A|0;v=Id(y,g,b);c=50;break a}k=r[k+8>>2]}Jd(y,A)}}while(0);e=z[R+12>>2];e>>>0>b>>>0?(v=e-b|0,r[R+12>>2]=v,h=e=z[R+24>>2],r[R+24>>2]=h+b|0,r[b+(h+4)>>2]=v|1,r[e+4>>2]=b|3,v=e+8|0,c=50):c=49}}while(0);49==c&&(r[Lc>>2]=12,v=0);return v}Dd.X=1;function Kd(){var b;0==(r[X>>2]|0)&&Ed();var d=z[R+24>>2],c=0==(d|0);a:do{if(!c){var e=z[R+12>>2],f=40<e>>>0;do{if(f){var i=z[X+8>>2],h=(Math.floor(((e-41+i|0)>>>0)/(i>>>0))-1)*i|0,g=Fd(d);if(0==(r[g+12>>2]&8|0)){var k=Gd(0);b=(g+4|0)>>2;if((k|0)==(r[g>>2]+r[b]|0)&&(h=Gd(-(2147483646<h>>>0?-2147483648-i|0:h)|0),i=Gd(0),-1!=(h|0)&i>>>0<k>>>0&&(h=k-i|0,(k|0)!=(i|0)))){r[b]=r[b]-h|0;r[R+432>>2]=r[R+432>>2]-h|0;Hd(r[R+24>>2],r[R+12>>2]-h|0);break a}}}}while(0);z[R+12>>2]>>>0>z[R+28>>2]>>>0&&(r[R+28>>2]=-1)}}while(0)}Kd.X=1;function qd(b){var d,c,e,f,i,h,g=b>>2,k,o=0==(b|0);a:do{if(!o){var w=b-8|0,t=w,A=z[R+16>>2],y=w>>>0<A>>>0;b:do{if(!y){var C=z[b-4>>2],v=C&3;if(1!=(v|0)){var u=C&-8;h=u>>2;var x=b+(u-8)|0,q=x,E=0==(C&1|0);c:do{if(E){var G=z[w>>2];if(0==(v|0)){break a}var M=-8-G|0;i=M>>2;var W=b+M|0,H=W,Q=G+u|0;if(W>>>0<A>>>0){break b}if((H|0)==(r[R+20>>2]|0)){f=(b+(u-4)|0)>>2;if(3!=(r[f]&3|0)){var K=H;e=K>>2;var V=Q;break}r[R+8>>2]=Q;r[f]&=-2;r[i+(g+1)]=Q|1;r[x>>2]=Q;break a}if(256>G>>>0){var Da=z[i+(g+2)],qa=z[i+(g+3)];if((Da|0)==(qa|0)){r[R>>2]&=1<<(G>>>3)^-1,K=H,e=K>>2,V=Q}else{var yb=((G>>>2&1073741822)<<2)+R+40|0,eb=(Da|0)!=(yb|0)&Da>>>0<A>>>0;do{if(!eb&&(qa|0)==(yb|0)|qa>>>0>=A>>>0){r[Da+12>>2]=qa;r[qa+8>>2]=Da;K=H;e=K>>2;V=Q;break c}}while(0);T();a("Reached an unreachable!")}}else{var La=W,Ea=z[i+(g+6)],Ma=z[i+(g+3)],fb=(Ma|0)==(La|0);do{if(fb){var zb=M+(b+20)|0,$=r[zb>>2];if(0==($|0)){var ma=M+(b+16)|0,fa=r[ma>>2];if(0==(fa|0)){var S=0;c=S>>2;break}var na=ma,oa=fa}else{na=zb,oa=$,k=21}for(;;){var gb=oa+20|0,Na=r[gb>>2];if(0!=(Na|0)){na=gb,oa=Na}else{var Ab=oa+16|0,ra=z[Ab>>2];if(0==(ra|0)){break}na=Ab;oa=ra}}na>>>0<A>>>0&&(T(),a("Reached an unreachable!"));r[na>>2]=0;S=oa}else{var Oa=z[i+(g+2)];Oa>>>0<A>>>0&&(T(),a("Reached an unreachable!"));r[Oa+12>>2]=Ma;r[Ma+8>>2]=Oa;S=Ma}c=S>>2}while(0);if(0!=(Ea|0)){var Jb=M+(b+28)|0,U=(r[Jb>>2]<<2)+R+304|0,aa=(La|0)==(r[U>>2]|0);do{if(aa){r[U>>2]=S;if(0!=(S|0)){break}r[R+4>>2]&=1<<r[Jb>>2]^-1;K=H;e=K>>2;V=Q;break c}Ea>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));var ta=Ea+16|0;(r[ta>>2]|0)==(La|0)?r[ta>>2]=S:r[Ea+20>>2]=S;if(0==(S|0)){K=H;e=K>>2;V=Q;break c}}while(0);S>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[c+6]=Ea;var Fa=z[i+(g+4)];0!=(Fa|0)&&(Fa>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[c+4]=Fa,r[Fa+24>>2]=S);var Pa=z[i+(g+5)];0!=(Pa|0)&&(Pa>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[c+5]=Pa,r[Pa+24>>2]=S)}K=H;e=K>>2;V=Q}}else{K=t,e=K>>2,V=u}}while(0);var hb=K;if(hb>>>0<x>>>0){var ib=b+(u-4)|0,Y=z[ib>>2];if(0!=(Y&1|0)){var jb=0==(Y&2|0);do{if(jb){if((q|0)==(r[R+24>>2]|0)){var Qa=r[R+12>>2]+V|0;r[R+12>>2]=Qa;r[R+24>>2]=K;r[e+1]=Qa|1;(K|0)==(r[R+20>>2]|0)&&(r[R+20>>2]=0,r[R+8>>2]=0);if(Qa>>>0<=z[R+28>>2]>>>0){break a}Kd();break a}if((q|0)==(r[R+20>>2]|0)){var Ra=r[R+8>>2]+V|0;r[R+8>>2]=Ra;r[R+20>>2]=K;r[e+1]=Ra|1;r[(hb+Ra|0)>>2]=Ra;break a}var Sa=(Y&-8)+V|0,kb=Y>>>3,ua=256>Y>>>0;c:do{if(ua){var va=z[g+h],Ta=z[((u|4)>>2)+g];if((va|0)==(Ta|0)){r[R>>2]&=1<<kb^-1}else{var Bb=((Y>>>2&1073741822)<<2)+R+40|0;k=(va|0)==(Bb|0)?63:va>>>0<z[R+16>>2]>>>0?66:63;do{if(63==k&&!((Ta|0)!=(Bb|0)&&Ta>>>0<z[R+16>>2]>>>0)){r[va+12>>2]=Ta;r[Ta+8>>2]=va;break c}}while(0);T();a("Reached an unreachable!")}}else{var lb=x,ga=z[h+(g+4)],Ga=z[((u|4)>>2)+g],Wb=(Ga|0)==(lb|0);do{if(Wb){var Kb=u+(b+12)|0,Cb=r[Kb>>2];if(0==(Cb|0)){var mb=u+(b+8)|0,nb=r[mb>>2];if(0==(nb|0)){var N=0;d=N>>2;break}var da=mb,ba=nb}else{da=Kb,ba=Cb,k=73}for(;;){var Ha=ba+20|0,Ua=r[Ha>>2];if(0!=(Ua|0)){da=Ha,ba=Ua}else{var Va=ba+16|0,Wa=z[Va>>2];if(0==(Wa|0)){break}da=Va;ba=Wa}}da>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[da>>2]=0;N=ba}else{var wa=z[g+h];wa>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[wa+12>>2]=Ga;r[Ga+8>>2]=wa;N=Ga}d=N>>2}while(0);if(0!=(ga|0)){var Lb=u+(b+20)|0,Mb=(r[Lb>>2]<<2)+R+304|0,Nb=(lb|0)==(r[Mb>>2]|0);do{if(Nb){r[Mb>>2]=N;if(0!=(N|0)){break}r[R+4>>2]&=1<<r[Lb>>2]^-1;break c}ga>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));var Xb=ga+16|0;(r[Xb>>2]|0)==(lb|0)?r[Xb>>2]=N:r[ga+20>>2]=N;if(0==(N|0)){break c}}while(0);N>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[d+6]=ga;var Xa=z[h+(g+2)];0!=(Xa|0)&&(Xa>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+4]=Xa,r[Xa+24>>2]=N);var ha=z[h+(g+3)];0!=(ha|0)&&(ha>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[d+5]=ha,r[ha+24>>2]=N)}}}while(0);r[e+1]=Sa|1;r[hb+Sa>>2]=Sa;if((K|0)!=(r[R+20>>2]|0)){var Z=Sa}else{r[R+8>>2]=Sa;break a}}else{r[ib>>2]=Y&-2,r[e+1]=V|1,Z=r[hb+V>>2]=V}}while(0);if(256>Z>>>0){var xa=Z>>>2&1073741822,ya=(xa<<2)+R+40|0,Db=z[R>>2],ob=1<<(Z>>>3);if(0==(Db&ob|0)){r[R>>2]=Db|ob;var Ya=ya,Eb=(xa+2<<2)+R+40|0}else{var pb=(xa+2<<2)+R+40|0,qb=z[pb>>2];qb>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));Ya=qb;Eb=pb}r[Eb>>2]=K;r[Ya+12>>2]=K;r[e+2]=Ya;r[e+3]=ya;break a}var ia=K,za=Z>>>8;if(0==(za|0)){var Aa=0}else{if(16777215<Z>>>0){Aa=31}else{var ja=(za+1048320|0)>>>16&8,rb=za<<ja,ea=(rb+520192|0)>>>16&4,Za=rb<<ea,Ob=(Za+245760|0)>>>16&2,sb=14-(ea|ja|Ob)+(Za<<Ob>>>15)|0,Aa=Z>>>((sb+7|0)>>>0)&1|sb<<1}}var Ia=(Aa<<2)+R+304|0;r[e+7]=Aa;r[e+5]=0;r[e+4]=0;var Ja=r[R+4>>2],tb=1<<Aa,$a=0==(Ja&tb|0);c:do{if($a){r[R+4>>2]=Ja|tb,r[Ia>>2]=ia,r[e+6]=Ia,r[e+3]=K,r[e+2]=K}else{for(var Fb=Z<<(31==(Aa|0)?0:25-(Aa>>>1)|0),pa=r[Ia>>2];;){if((r[pa+4>>2]&-8|0)==(Z|0)){var Gb=pa+8|0,ub=z[Gb>>2],Ba=z[R+16>>2],Pb=pa>>>0<Ba>>>0;do{if(!Pb&&ub>>>0>=Ba>>>0){r[ub+12>>2]=ia;r[Gb>>2]=ia;r[e+2]=ub;r[e+3]=pa;r[e+6]=0;break c}}while(0);T();a("Reached an unreachable!")}var ab=(Fb>>>31<<2)+pa+16|0,lc=z[ab>>2];if(0==(lc|0)){if(ab>>>0>=z[R+16>>2]>>>0){r[ab>>2]=ia;r[e+6]=pa;r[e+3]=K;r[e+2]=K;break c}T();a("Reached an unreachable!")}Fb<<=1;pa=lc}}}while(0);var xc=r[R+32>>2]-1|0;r[R+32>>2]=xc;if(0!=(xc|0)){break a}var ac=r[R+452>>2],yc=0==(ac|0);c:do{if(!yc){for(var Rd=ac;;){var Sd=r[Rd+8>>2];if(0==(Sd|0)){break c}Rd=Sd}}}while(0);r[R+32>>2]=-1;break a}}}}}while(0);T();a("Reached an unreachable!")}}while(0)}Module._free=qd;qd.X=1;function Fd(b){var d,c=R+444|0;for(d=c>>2;;){var e=z[d];if(e>>>0<=b>>>0&&(e+r[d+1]|0)>>>0>b>>>0){var f=c;break}d=z[d+2];if(0==(d|0)){f=0;break}c=d;d=c>>2}return f}function Hd(b,d){var c=b+8|0,c=0==(c&7|0)?0:-c&7,e=d-c|0;r[R+24>>2]=b+c|0;r[R+12>>2]=e;r[c+(b+4)>>2]=e|1;r[d+(b+4)>>2]=40;r[R+28>>2]=r[X+16>>2]}function Ed(){if(0==(r[X>>2]|0)){var b=Ld();0==(b-1&b|0)?(r[X+8>>2]=b,r[X+4>>2]=b,r[X+12>>2]=-1,r[X+16>>2]=2097152,r[X+20>>2]=0,r[R+440>>2]=0,r[X>>2]=Math.floor(Date.now()/1e3)&-16^1431655768):(T(),a("Reached an unreachable!"))}}function Id(b,d,c){var e,f,i,h=d>>2,g=b>>2,k,o=b+8|0,o=0==(o&7|0)?0:-o&7;f=d+8|0;var w=0==(f&7|0)?0:-f&7;i=w>>2;var t=d+w|0,A=o+c|0;f=A>>2;var y=b+A|0,C=t-(b+o)-c|0;r[(o+4>>2)+g]=c|3;c=(t|0)==(r[R+24>>2]|0);a:do{if(c){var v=r[R+12>>2]+C|0;r[R+12>>2]=v;r[R+24>>2]=y;r[f+(g+1)]=v|1}else{if((t|0)==(r[R+20>>2]|0)){v=r[R+8>>2]+C|0,r[R+8>>2]=v,r[R+20>>2]=y,r[f+(g+1)]=v|1,r[(b+v+A|0)>>2]=v}else{var u=z[i+(h+1)];if(1==(u&3|0)){var v=u&-8,x=u>>>3,q=256>u>>>0;b:do{if(q){var E=z[((w|8)>>2)+h],G=z[i+(h+3)];if((E|0)==(G|0)){r[R>>2]&=1<<x^-1}else{var M=((u>>>2&1073741822)<<2)+R+40|0;k=(E|0)==(M|0)?15:E>>>0<z[R+16>>2]>>>0?18:15;do{if(15==k&&!((G|0)!=(M|0)&&G>>>0<z[R+16>>2]>>>0)){r[E+12>>2]=G;r[G+8>>2]=E;break b}}while(0);T();a("Reached an unreachable!")}}else{k=t;E=z[((w|24)>>2)+h];G=z[i+(h+3)];M=(G|0)==(k|0);do{if(M){e=w|16;var W=e+(d+4)|0,H=r[W>>2];if(0==(H|0)){if(e=d+e|0,H=r[e>>2],0==(H|0)){H=0;e=H>>2;break}}else{e=W}for(;;){var W=H+20|0,Q=r[W>>2];if(0==(Q|0)&&(W=H+16|0,Q=z[W>>2],0==(Q|0))){break}e=W;H=Q}e>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[e>>2]=0}else{e=z[((w|8)>>2)+h],e>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[e+12>>2]=G,r[G+8>>2]=e,H=G}e=H>>2}while(0);if(0!=(E|0)){G=w+(d+28)|0;M=(r[G>>2]<<2)+R+304|0;W=(k|0)==(r[M>>2]|0);do{if(W){r[M>>2]=H;if(0!=(H|0)){break}r[R+4>>2]&=1<<r[G>>2]^-1;break b}E>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));Q=E+16|0;(r[Q>>2]|0)==(k|0)?r[Q>>2]=H:r[E+20>>2]=H;if(0==(H|0)){break b}}while(0);H>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"));r[e+6]=E;k=w|16;E=z[(k>>2)+h];0!=(E|0)&&(E>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[e+4]=E,r[E+24>>2]=H);k=z[(k+4>>2)+h];0!=(k|0)&&(k>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!")),r[e+5]=k,r[k+24>>2]=H)}}}while(0);u=d+(v|w)|0;v=v+C|0}else{u=t,v=C}u=u+4|0;r[u>>2]&=-2;r[f+(g+1)]=v|1;r[(v>>2)+g+f]=v;if(256>v>>>0){x=v>>>2&1073741822,u=(x<<2)+R+40|0,q=z[R>>2],v=1<<(v>>>3),0==(q&v|0)?(r[R>>2]=q|v,v=u,x=(x+2<<2)+R+40|0):(x=(x+2<<2)+R+40|0,v=z[x>>2],v>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"))),r[x>>2]=y,r[v+12>>2]=y,r[f+(g+2)]=v,r[f+(g+3)]=u}else{if(u=y,q=v>>>8,0==(q|0)?x=0:16777215<v>>>0?x=31:(x=(q+1048320|0)>>>16&8,k=q<<x,q=(k+520192|0)>>>16&4,k<<=q,E=(k+245760|0)>>>16&2,x=14-(q|x|E)+(k<<E>>>15)|0,x=v>>>((x+7|0)>>>0)&1|x<<1),q=(x<<2)+R+304|0,r[f+(g+7)]=x,k=A+(b+16)|0,r[f+(g+5)]=0,r[k>>2]=0,k=r[R+4>>2],E=1<<x,0==(k&E|0)){r[R+4>>2]=k|E,r[q>>2]=u,r[f+(g+6)]=q,r[f+(g+3)]=u,r[f+(g+2)]=u}else{x=v<<(31==(x|0)?0:25-(x>>>1)|0);for(q=r[q>>2];;){if((r[q+4>>2]&-8|0)==(v|0)){k=q+8|0;E=z[k>>2];G=z[R+16>>2];M=q>>>0<G>>>0;do{if(!M&&E>>>0>=G>>>0){r[E+12>>2]=u;r[k>>2]=u;r[f+(g+2)]=E;r[f+(g+3)]=q;r[f+(g+6)]=0;break a}}while(0);T();a("Reached an unreachable!")}k=(x>>>31<<2)+q+16|0;E=z[k>>2];if(0==(E|0)){if(k>>>0>=z[R+16>>2]>>>0){r[k>>2]=u;r[f+(g+6)]=q;r[f+(g+3)]=u;r[f+(g+2)]=u;break a}T();a("Reached an unreachable!")}x<<=1;q=E}}}}}}while(0);return b+(o|8)|0}Id.X=1;function Jd(b,d){var c,e,f=z[R+24>>2];e=f>>2;var i=Fd(f),h=r[i>>2];c=r[i+4>>2];var i=h+c|0,g=h+(c-39)|0,h=h+(c-47)+(0==(g&7|0)?0:-g&7)|0,h=h>>>0<(f+16|0)>>>0?f:h,g=h+8|0;c=g>>2;Hd(b,d-40|0);r[(h+4|0)>>2]=27;r[c]=r[R+444>>2];r[c+1]=r[R+448>>2];r[c+2]=r[R+452>>2];r[c+3]=r[R+456>>2];r[R+444>>2]=b;r[R+448>>2]=d;r[R+456>>2]=0;r[R+452>>2]=g;c=h+28|0;r[c>>2]=7;g=(h+32|0)>>>0<i>>>0;a:do{if(g){for(var k=c;;){var o=k+4|0;r[o>>2]=7;if((k+8|0)>>>0>=i>>>0){break a}k=o}}}while(0);i=(h|0)==(f|0);a:do{if(!i){if(c=h-f|0,g=f+c|0,k=c+(f+4)|0,r[k>>2]&=-2,r[e+1]=c|1,r[g>>2]=c,256>c>>>0){k=c>>>2&1073741822,g=(k<<2)+R+40|0,o=z[R>>2],c=1<<(c>>>3),0==(o&c|0)?(r[R>>2]=o|c,c=g,k=(k+2<<2)+R+40|0):(k=(k+2<<2)+R+40|0,c=z[k>>2],c>>>0<z[R+16>>2]>>>0&&(T(),a("Reached an unreachable!"))),r[k>>2]=f,r[c+12>>2]=f,r[e+2]=c,r[e+3]=g}else{g=f;o=c>>>8;if(0==(o|0)){k=0}else{if(16777215<c>>>0){k=31}else{var k=(o+1048320|0)>>>16&8,w=o<<k,o=(w+520192|0)>>>16&4,w=w<<o,t=(w+245760|0)>>>16&2,k=14-(o|k|t)+(w<<t>>>15)|0,k=c>>>((k+7|0)>>>0)&1|k<<1}}o=(k<<2)+R+304|0;r[e+7]=k;r[e+5]=0;r[e+4]=0;w=r[R+4>>2];t=1<<k;if(0==(w&t|0)){r[R+4>>2]=w|t,r[o>>2]=g,r[e+6]=o,r[e+3]=f,r[e+2]=f}else{k=c<<(31==(k|0)?0:25-(k>>>1)|0);for(o=r[o>>2];;){if((r[o+4>>2]&-8|0)==(c|0)){var w=o+8|0,t=z[w>>2],A=z[R+16>>2],y=o>>>0<A>>>0;do{if(!y&&t>>>0>=A>>>0){r[t+12>>2]=g;r[w>>2]=g;r[e+2]=t;r[e+3]=o;r[e+6]=0;break a}}while(0);T();a("Reached an unreachable!")}w=(k>>>31<<2)+o+16|0;t=z[w>>2];if(0==(t|0)){if(w>>>0>=z[R+16>>2]>>>0){r[w>>2]=g;r[e+6]=o;r[e+3]=f;r[e+2]=f;break a}T();a("Reached an unreachable!")}k<<=1;o=t}}}}}while(0)}Jd.X=1;function zd(b){0!=(b|0)&&qd(b)}function Md(b){Nd(b|0)}function ud(b){for(b=0==(b|0)?1:b;;){var d=jc(b);if(0==(d|0)){d=(Zb=r[Od>>2],r[Od>>2]=Zb,Zb);if(0==(d|0)){var c=jc(4);r[c>>2]=Pd+8|0;var e=Qd;if(!Td){try{r[__ZTVN10__cxxabiv119__pointer_type_infoE>>2]=0}catch(f){}try{r[__ZTVN10__cxxabiv117__class_type_infoE>>2]=1}catch(i){}try{r[Ud>>2]=2}catch(h){}Td=j}print("Compiled code throwing an exception, "+[c,e,2]+", at "+Error().stack);r[Vd>>2]=c;r[Vd+4>>2]=e;r[Vd+8>>2]=2;"uncaught_exception"in Wd?Wd.w++:Wd.w=1;a(c);a("Reached an unreachable!")}mc[d]()}else{return d}}return l}function L(b){Lc||(Lc=F([0],"i32",D));r[Lc>>2]=b}var Lc,Xd=13,rd=9,jd=22,Yd=5,Zd=21,$d=25,ae=6,id=34,be=0,ce=0,de=0,cd=0,ee=2,O=[l],fe=j;function ge(b,d){if("string"!==typeof b){return l}d===ca&&(d="/");b&&"/"==b[0]&&(d="");for(var c=(d+"/"+b).split("/").reverse(),e=[""];c.length;){var f=c.pop();""==f||"."==f||(".."==f?1<e.length&&e.pop():e.push(f))}return 1==e.length?"/":e.join("/")}function he(b,d,c){var e={Ta:m,k:m,error:0,name:l,path:l,object:l,s:m,u:l,t:l},b=ge(b);if("/"==b){e.Ta=j,e.k=e.s=j,e.name="/",e.path=e.u="/",e.object=e.t=ie}else{if(b!==l){for(var c=c||0,b=b.slice(1).split("/"),f=ie,i=[""];b.length;){1==b.length&&f.c&&(e.s=j,e.u=1==i.length?"/":i.join("/"),e.t=f,e.name=b[0]);var h=b.shift();if(f.c){if(f.v){if(!f.a.hasOwnProperty(h)){e.error=2;break}}else{e.error=Xd;break}}else{e.error=20;break}f=f.a[h];if(f.link&&!(d&&0==b.length)){if(40<c){e.error=40;break}e=ge(f.link,i.join("/"));return he([e].concat(b).join("/"),d,c+1)}i.push(h);0==b.length&&(e.k=j,e.path=i.join("/"),e.object=f)}}}return e}function je(b){ke();b=he(b,ca);if(b.k){return b.object}L(b.error);return l}function le(b,d,c,e,f){b||(b="/");"string"===typeof b&&(b=je(b));b||(L(Xd),a(Error("Parent path must exist.")));b.c||(L(20),a(Error("Parent must be a folder.")));!b.write&&!fe&&(L(Xd),a(Error("Parent folder must be writeable.")));if(!d||"."==d||".."==d){L(2),a(Error("Name must not be empty."))}b.a.hasOwnProperty(d)&&(L(17),a(Error("Can't overwrite object.")));b.a[d]={v:e===ca?j:e,write:f===ca?m:f,timestamp:Date.now(),Sa:ee++};for(var i in c){c.hasOwnProperty(i)&&(b.a[d][i]=c[i])}return b.a[d]}function me(b,d){return le(b,d,{c:j,d:m,a:{}},j,j)}function ne(){var b="dev/shm/tmp",d=je("/");d===l&&a(Error("Invalid parent."));for(b=b.split("/").reverse();b.length;){var c=b.pop();c&&(d.a.hasOwnProperty(c)||me(d,c),d=d.a[c])}}function oe(b,d,c,e){!c&&!e&&a(Error("A device must have at least one callback defined."));var f={d:j,input:c,e:e};f.c=m;return le(b,d,f,Boolean(c),Boolean(e))}function ke(){ie||(ie={v:j,write:j,c:j,d:m,timestamp:Date.now(),Sa:1,a:{}})}function pe(){var b,d,c;function e(b){b===l||10===b?(d.h(d.buffer.join("")),d.buffer=[]):d.buffer.push(String.fromCharCode(b))}xb(!qe,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");qe=j;ke();b=b||Module.stdin;d=d||Module.stdout;c=c||Module.stderr;var f=j,i=j,h=j;b||(f=m,b=(function(){if(!b.j||!b.j.length){var c;"undefined"!=typeof window&&"function"==typeof window.prompt?c=window.prompt("Input: "):"function"==typeof readline&&(c=readline());c||(c="");b.j=rc(c+"\n",j)}return b.j.shift()}));d||(i=m,d=e);d.h||(d.h=print);d.buffer||(d.buffer=[]);c||(h=m,c=e);c.h||(c.h=print);c.buffer||(c.buffer=[]);me("/","tmp");var g=me("/","dev"),k=oe(g,"stdin",b),o=oe(g,"stdout",l,d);c=oe(g,"stderr",l,c);oe(g,"tty",b,d);O[1]={path:"/dev/stdin",object:k,position:0,f:j,g:m,r:m,m:!f,error:m,q:m,b:[]};O[2]={path:"/dev/stdout",object:o,position:0,f:m,g:j,r:m,m:!i,error:m,q:m,b:[]};O[3]={path:"/dev/stderr",object:c,position:0,f:m,g:j,r:m,m:!h,error:m,q:m,b:[]};be=F([1],"void*",D);ce=F([2],"void*",D);de=F([3],"void*",D);ne();O[be]=O[1];O[ce]=O[2];O[de]=O[3];cd=F([F([0,0,0,0,be,0,0,0,ce,0,0,0,de,0,0,0],"void*",D)],"void*",D)}var qe,ie;function re(b,d,c,e){var f=O[b];if(!f||f.object.d){return L(rd),-1}if(f.f){if(f.object.c){return L(Zd),-1}if(0>c||0>e){return L(jd),-1}for(b=0;f.b.length&&0<c;){p[d++]=f.b.pop(),c--,b++}for(var f=f.object.a,c=Math.min(f.length-e,c),i=0;i<c;i++){p[d+i]=f[e+i],b++}return b}L(Xd);return-1}function Sc(b,d,c){var e=O[b];if(e){if(e.f){if(0>c){return L(jd),-1}if(e.object.d){if(e.object.input){for(b=0;e.b.length&&0<c;){p[d++]=e.b.pop(),c--,b++}for(var f=0;f<c;f++){try{var i=e.object.input()}catch(h){return L(Yd),-1}if(i===l||i===ca){break}b++;p[d+f]=i}return b}L(ae);return-1}i=e.b.length;b=re(b,d,c,e.position);-1!=b&&(e.position+=e.b.length-i+b);return b}L(Xd);return-1}L(rd);return-1}function Mc(b,d,c){var e=O[b];if(e){if(e.g){if(0>c){return L(jd),-1}if(e.object.d){if(e.object.e){for(var f=0;f<c;f++){try{e.object.e(p[d+f])}catch(i){return L(Yd),-1}}e.object.timestamp=Date.now();return f}L(ae);return-1}f=e.position;b=O[b];if(!b||b.object.d){L(rd),d=-1}else{if(b.g){if(b.object.c){L(Zd),d=-1}else{if(0>c||0>f){L(jd),d=-1}else{for(var h=b.object.a;h.length<f;){h.push(0)}for(var g=0;g<c;g++){h[f+g]=s[d+g]}b.object.timestamp=Date.now();d=g}}}else{L(Xd),d=-1}}-1!=d&&(e.position+=d);return d}L(Xd);return-1}L(rd);return-1}function Nc(b){vc(zc);a("exit("+b+") called, at "+Error().stack)}function Ad(b,d,c,e){d*=c;0!=d&&-1==Mc(e,b,d)&&O[e]&&(O[e].error=j)}function yd(b,d){function c(b){var c;"double"===b?c=(hc[0]=r[d+f>>2],hc[1]=r[d+f+4>>2],gc[0]):"i64"==b?c=[r[d+f>>2],r[d+f+4>>2]]:(b="i32",c=r[d+f>>2]);f+=Math.max(vb(b),wb);return c}for(var e=b,f=0,i=[],h,g;;){var k=e;h=p[e];if(0===h){break}g=p[e+1];if(37==h){var o=m,w=m,t=m,A=m;a:for(;;){switch(g){case 43:o=j;break;case 45:w=j;break;case 35:t=j;break;case 48:if(A){break a}else{A=j;break};default:break a}e++;g=p[e+1]}var y=0;if(42==g){y=c("i32"),e++,g=p[e+1]}else{for(;48<=g&&57>=g;){y=10*y+(g-48),e++,g=p[e+1]}}var C=m;if(46==g){var v=0,C=j;e++;g=p[e+1];if(42==g){v=c("i32"),e++}else{for(;;){g=p[e+1];if(48>g||57<g){break}v=10*v+(g-48);e++}}g=p[e+1]}else{v=6}var u;switch(String.fromCharCode(g)){case"h":g=p[e+2];104==g?(e++,u=1):u=2;break;case"l":g=p[e+2];108==g?(e++,u=8):u=4;break;case"L":case"q":case"j":u=8;break;case"z":case"t":case"I":u=4;break;default:u=l}u&&e++;g=p[e+1];if(-1!="d,i,u,o,x,X,p".split(",").indexOf(String.fromCharCode(g))){k=100==g||105==g;u=u||4;h=c("i"+8*u);8==u&&(h=117==g?(h[0]>>>0)+4294967296*(h[1]>>>0):(h[0]>>>0)+4294967296*(h[1]|0));4>=u&&(h=(k?Ec:Dc)(h&Math.pow(256,u)-1,8*u));var x=Math.abs(h),q,k="";if(100==g||105==g){q=Ec(h,8*u).toString(10)}else{if(117==g){q=Dc(h,8*u).toString(10),h=Math.abs(h)}else{if(111==g){q=(t?"0":"")+x.toString(8)}else{if(120==g||88==g){k=t?"0x":"";if(0>h){h=-h;q=(x-1).toString(16);t=[];for(x=0;x<q.length;x++){t.push((15-parseInt(q[x],16)).toString(16))}for(q=t.join("");q.length<2*u;){q="f"+q}}else{q=x.toString(16)}88==g&&(k=k.toUpperCase(),q=q.toUpperCase())}else{112==g&&(0===x?q="(nil)":(k="0x",q=x.toString(16)))}}}}if(C){for(;q.length<v;){q="0"+q}}for(o&&(k=0>h?"-"+k:"+"+k);k.length+q.length<y;){w?q+=" ":A?q="0"+q:k=" "+k}q=k+q;q.split("").forEach((function(b){i.push(b.charCodeAt(0))}))}else{if(-1!="f,F,e,E,g,G".split(",").indexOf(String.fromCharCode(g))){h=c("double");if(isNaN(h)){q="nan",A=m}else{if(isFinite(h)){C=m;u=Math.min(v,20);if(103==g||71==g){C=j,v=v||1,u=parseInt(h.toExponential(u).split("e")[1],10),v>u&&-4<=u?(g=(103==g?"f":"F").charCodeAt(0),v-=u+1):(g=(103==g?"e":"E").charCodeAt(0),v--),u=Math.min(v,20)}if(101==g||69==g){q=h.toExponential(u),/[eE][-+]\d$/.test(q)&&(q=q.slice(0,-1)+"0"+q.slice(-1))}else{if(102==g||70==g){q=h.toFixed(u)}}k=q.split("e");if(C&&!t){for(;1<k[0].length&&-1!=k[0].indexOf(".")&&("0"==k[0].slice(-1)||"."==k[0].slice(-1));){k[0]=k[0].slice(0,-1)}}else{for(t&&-1==q.indexOf(".")&&(k[0]+=".");v>u++;){k[0]+="0"}}q=k[0]+(1<k.length?"e"+k[1]:"");69==g&&(q=q.toUpperCase());o&&0<=h&&(q="+"+q)}else{q=(0>h?"-":"")+"inf",A=m}}for(;q.length<y;){q=w?q+" ":A&&("-"==q[0]||"+"==q[0])?q[0]+"0"+q.slice(1):(A?"0":" ")+q}97>g&&(q=q.toUpperCase());q.split("").forEach((function(b){i.push(b.charCodeAt(0))}))}else{if(115==g){(o=c("i8*"))?(o=Cc(o),C&&o.length>v&&(o=o.slice(0,v))):o=rc("(null)",j);if(!w){for(;o.length<y--;){i.push(32)}}i=i.concat(o);if(w){for(;o.length<y--;){i.push(32)}}}else{if(99==g){for(w&&i.push(c("i8"));0<--y;){i.push(32)}w||i.push(c("i8"))}else{if(110==g){w=c("i32*"),r[w>>2]=i.length}else{if(37==g){i.push(h)}else{for(x=k;x<e+2;x++){i.push(p[x])}}}}}}}e+=2}else{i.push(h),e+=1}}return i}function fd(b,d,c){d=yd(d,c);c=n;Ad(F(d,"i8",ic),1,d.length,b);n=c}var hd={1:"Operation not permitted",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"Input/output error",6:"No such device or address",8:"Exec format error",9:"Bad file descriptor",10:"No child processes",11:"Resource temporarily unavailable",12:"Cannot allocate memory",13:"Permission denied",14:"Bad address",16:"Device or resource busy",17:"File exists",18:"Invalid cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Inappropriate ioctl for device",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read-only file system",31:"Too many links",32:"Broken pipe",33:"Numerical argument out of domain",34:"Numerical result out of range",35:"Resource deadlock avoided",36:"File name too long",37:"No locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many levels of symbolic links",42:"No message of desired type",43:"Identifier removed",60:"Device not a stream",61:"No data available",62:"Timer expired",63:"Out of streams resources",67:"Link has been severed",71:"Protocol error",72:"Multihop attempted",74:"Bad message",75:"Value too large for defined data type",84:"Invalid or incomplete multibyte or wide character",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Protocol not supported",95:"Operation not supported",97:"Address family not supported by protocol",98:"Address already in use",99:"Cannot assign requested address",100:"Network is down",101:"Network is unreachable",102:"Network dropped connection on reset",103:"Software caused connection abort",104:"Connection reset by peer",105:"No buffer space available",106:"Transport endpoint is already connected",107:"Transport endpoint is not connected",110:"Connection timed out",111:"Connection refused",113:"No route to host",114:"Operation already in progress",115:"Operation now in progress",116:"Stale NFS file handle",122:"Disk quota exceeded",125:"Operation canceled",130:"Owner died",131:"State not recoverable"},gd;function od(b){if(!O[b]){return L(rd),0}if(O[b].m){return 1}L($d);return 0}function sd(b,d){fd(r[ce>>2],b,d)}function T(){a("ABORT: undefined, at "+Error().stack)}function kc(b,d){var c=0;if(20<=d){for(var e=b+d;b%4;){p[b++]=c}0>c&&(c+=256);for(var f=b>>2,i=e>>2,h=c|c<<8|c<<16|c<<24;f<i;){r[f++]=h}for(b=f<<2;b<e;){p[b++]=c}}else{for(;d--;){p[b++]=c}}}function Ld(){switch(8){case 8:return nc;case 54:case 56:case 21:case 61:case 63:case 22:case 67:case 23:case 24:case 25:case 26:case 27:case 69:case 28:case 101:case 70:case 71:case 29:case 30:case 199:case 75:case 76:case 32:case 43:case 44:case 80:case 46:case 47:case 45:case 48:case 49:case 42:case 82:case 33:case 7:case 108:case 109:case 107:case 112:case 119:case 121:return 200809;case 13:case 104:case 94:case 95:case 34:case 35:case 77:case 81:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 91:case 94:case 95:case 110:case 111:case 113:case 114:case 115:case 116:case 117:case 118:case 120:case 40:case 16:case 79:case 19:return-1;case 92:case 93:case 5:case 72:case 6:case 74:case 92:case 93:case 96:case 97:case 98:case 99:case 102:case 103:case 105:return 1;case 38:case 66:case 50:case 51:case 4:return 1024;case 15:case 64:case 41:return 32;case 55:case 37:case 17:return 2147483647;case 18:case 1:return 47839;case 59:case 57:return 99;case 68:case 58:return 2048;case 0:return 2097152;case 3:return 65536;case 14:return 32768;case 73:return 32767;case 39:return 16384;case 60:return 1e3;case 106:return 700;case 52:return 256;case 62:return 255;case 2:return 100;case 65:return 64;case 36:return 20;case 100:return 16;case 20:return 6;case 53:return 4}L(jd);return-1}function Gd(b){se||(Qb=Qb+4095>>12<<12,se=j);var d=Qb;0!=b&&Ib(b);return d}var se;function Wd(){return!!Wd.w}var Td,Nd;function kd(b){p[te]=Dc(10);-1==Mc(b,te,1)&&b in O&&(O[b].error=j)}function P(b){var d=r[ce>>2];0>Mc(d,b,Bc(b))||kd(d)}L(0);wc.unshift({l:(function(){fe=m;qe||pe()})});zc.push({l:(function(){qe&&(O[2]&&0<O[2].object.e.buffer.length&&O[2].object.e(10),O[3]&&0<O[3].object.e.buffer.length&&O[3].object.e(10))})});var Vd=F(12,"void*",D),te=F([0],"i8",D);Module.Qa=(function(b){function d(){for(var b=0;3>b;b++){e.push(0)}}var c=b.length+1,e=[F(rc("/bin/this.program"),"i8",D)];d();for(var f=0;f<c-1;f+=1){e.push(F(rc(b[f]),"i8",D)),d()}e.push(0);e=F(e,"i32",D);return md(c,e)});var Kc,wc=wc.concat([{l:(function(){for(var b=0;;){var d=b>>>1,d=0==(b&1|0)?d:d^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1,d=0==(d&1|0)?c:c^-306674912,c=d>>>1;r[Kc+(b<<2)>>2]=0==(d&1|0)?c:c^-306674912;b=b+1|0;if(256==(b|0)){break}}})}]),ed,ld,nd,wd,xd,vd,R,X,Od,Pd,Ud,Qd;Kc=F(1024,"i32",D);I.G=F([82,97,110,103,101,32,100,101,99,111,100,101,114,32,102,105,110,97,108,32,99,111,100,101,32,105,115,32,110,111,116,32,122,101,114,111,0],"i8",D);I.F=F([7,7,7,7,7,7,7,10,10,10,10,10],"i8",D);I.C=F([8,8,8,8,8,8,8,11,11,11,11,11],"i8",D);I.B=F([9,9,9,9,9,9,9,11,11,11,11,11],"i8",D);I.D=F([0,0,0,0,1,2,3,4,5,6,4,5],"i8",D);ed=F(1,"i32",D);I.H=F([37,115,58,32,37,115,0],"i8",D);I.K=F([58,32,37,115,0],"i8",D);ld=F(1,"i8*",D);I.aa=F([84,114,121,32,96,37,115,32,45,45,104,101,108,112,39,32,102,111,114,32,109,111,114,101,32,105,110,102,111,114,109,97,116,105,111,110,46,10,0],"i8",D);I.ha=F([37,115,58,32,105,110,116,101,114,110,97,108,32,101,114,114,111,114,58,32,37,115,46,10,0],"i8",D);I.ia=F([117,110,99,97,117,103,104,116,32,111,112,116,105,111,110,0],"i8",D);nd=F(1,"i1",D);I.ka=F([67,97,110,39,116,32,99,108,111,115,101,32,115,116,100,111,117,116,0],"i8",D);I.la=F([69,114,114,111,114,32,114,101,97,100,105,110,103,32,109,101,109,98,101,114,32,104,101,97,100,101,114,0],"i8",D);I.ma=F([66,97,100,32,109,97,103,105,99,32,110,117,109,98,101,114,32,40,102,105,108,101,32,110,111,116,32,105,110,32,108,122,105,112,32,102,111,114,109,97,116,41,0],"i8",D);I.I=F([86,101,114,115,105,111,110,32,37,100,32,109,101,109,98,101,114,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,46,10,0],"i8",D);I.J=F([73,110,118,97,108,105,100,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,105,110,32,109,101,109,98,101,114,32,104,101,97,100,101,114,0],"i8",D);I.L=F([118,101,114,115,105,111,110,32,37,100,44,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,37,55,115,66,46,32,32,0],"i8",D);I.M=F([70,105,108,101,32,101,110,100,115,32,117,110,101,120,112,101,99,116,101,100,108,121,32,97,116,32,112,111,115,32,37,108,108,100,10,0],"i8",D);I.N=F([68,101,99,111,100,101,114,32,101,114,114,111,114,32,97,116,32,112,111,115,32,37,108,108,100,10,0],"i8",D);I.n=F([111,107,10,0],"i8",D);I.o=F([100,111,110,101,10,0],"i8",D);wd=F(32,"*",D);I.O=F([75,105,0],"i8",D);I.P=F([77,105,0],"i8",D);I.Q=F([71,105,0],"i8",D);I.R=F([84,105,0],"i8",D);I.S=F([80,105,0],"i8",D);I.T=F([69,105,0],"i8",D);I.U=F([90,105,0],"i8",D);I.V=F([89,105,0],"i8",D);xd=F(16,"i8",D);vd=F(1,"i8",D);I.W=F([37,108,108,100,32,37,115,0],"i8",D);I.z=F([76,90,73,80],"i8",D);I.Y=F([73,32,119,111,110,39,116,32,119,114,105,116,101,32,99,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,116,111,32,97,32,116,101,114,109,105,110,97,108,46,0],"i8",D);I.Z=F([73,32,119,111,110,39,116,32,114,101,97,100,32,99,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,102,114,111,109,32,97,32,116,101,114,109,105,110,97,108,46,0],"i8",D);I.$=F([37,115,32,37,115,10,0],"i8",D);I.ba=F([49,46,49,50,0],"i8",D);I.ca=F([67,111,112,121,114,105,103,104,116,32,40,67,41,32,37,115,32,65,110,116,111,110,105,111,32,68,105,97,122,32,68,105,97,122,46,10,0],"i8",D);I.da=F([50,48,49,49,0],"i8",D);I.p=F([76,122,105,112,0],"i8",D);I.fa=F([37,115,32,45,32,68,97,116,97,32,99,111,109,112,114,101,115,115,111,114,32,98,97,115,101,100,32,111,110,32,116,104,101,32,76,90,77,65,32,97,108,103,111,114,105,116,104,109,46,10,0],"i8",D);I.ga=F([10,85,115,97,103,101,58,32,37,115,32,91,111,112,116,105,111,110,115,93,32,91,102,105,108,101,115,93,10,0],"i8",D);I.ja=F([73,102,32,110,111,32,102,105,108,101,32,110,97,109,101,115,32,97,114,101,32,103,105,118,101,110,44,32,37,115,32,99,111,109,112,114,101,115,115,101,115,32,111,114,32,100,101,99,111,109,112,114,101,115,115,101,115,10,0],"i8",D);I.i=F([108,122,105,112,0],"i8",D);R=F(468,["i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0],D);X=F(24,"i32",D);Od=F(1,"void ()*",D);Pd=F([0,0,0,0,0,0,0,0,2,0,0,0,4,0,0,0,6,0,0,0],["*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0],D);F(1,"void*",D);I.ea=F([115,116,100,58,58,98,97,100,95,97,108,108,111,99,0],"i8",D);I.A=F([83,116,57,98,97,100,95,97,108,108,111,99,0],"i8",D);Qd=F(12,"*",D);I.na=F([60,60,32,77,111,115,116,32,111,102,32,116,104,101,115,101,32,97,114,101,32,117,110,115,117,112,112,111,114,116,101,100,46,32,67,111,109,112,114,101,115,115,105,110,103,47,100,101,99,111,109,112,114,101,115,115,105,110,103,32,102,114,111,109,32,115,116,100,105,110,32,116,111,32,115,116,100,111,117,116,32,105,115,32,116,104,101,32,114,105,103,104,116,32,119,97,121,33,32,62,62,0],"i8",D);I.oa=F([10,79,112,116,105,111,110,115,58,0],"i8",D);I.za=F([32,32,45,104,44,32,45,45,104,101,108,112,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,100,105,115,112,108,97,121,32,116,104,105,115,32,104,101,108,112,32,97,110,100,32,101,120,105,116,0],"i8",D);I.Ia=F([32,32,45,86,44,32,45,45,118,101,114,115,105,111,110,32,32,32,32,32,32,32,32,32,32,32,32,32,32,111,117,116,112,117,116,32,118,101,114,115,105,111,110,32,105,110,102,111,114,109,97,116,105,111,110,32,97,110,100,32,101,120,105,116,0],"i8",D);I.Ja=F([32,32,45,98,44,32,45,45,109,101,109,98,101,114,45,115,105,122,101,61,60,110,62,32,32,32,32,32,32,115,101,116,32,109,101,109,98,101,114,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,0],"i8",D);I.Ka=F([32,32,45,99,44,32,45,45,115,116,100,111,117,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,101,110,100,32,111,117,116,112,117,116,32,116,111,32,115,116,97,110,100,97,114,100,32,111,117,116,112,117,116,0],"i8",D);I.La=F([32,32,45,100,44,32,45,45,100,101,99,111,109,112,114,101,115,115,32,32,32,32,32,32,32,32,32,32,32,100,101,99,111,109,112,114,101,115,115,0],"i8",D);I.Ma=F([32,32,45,102,44,32,45,45,102,111,114,99,101,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,111,118,101,114,119,114,105,116,101,32,101,120,105,115,116,105,110,103,32,111,117,116,112,117,116,32,102,105,108,101,115,0],"i8",D);I.Na=F([32,32,45,70,44,32,45,45,114,101,99,111,109,112,114,101,115,115,32,32,32,32,32,32,32,32,32,32,32,102,111,114,99,101,32,114,101,99,111,109,112,114,101,115,115,105,111,110,32,111,102,32,99,111,109,112,114,101,115,115,101,100,32,102,105,108,101,115,0],"i8",D);I.Oa=F([32,32,45,107,44,32,45,45,107,101,101,112,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,107,101,101,112,32,40,100,111,110,39,116,32,100,101,108,101,116,101,41,32,105,110,112,117,116,32,102,105,108,101,115,0],"i8",D);I.pa=F([32,32,45,109,44,32,45,45,109,97,116,99,104,45,108,101,110,103,116,104,61,60,110,62,32,32,32,32,32,115,101,116,32,109,97,116,99,104,32,108,101,110,103,116,104,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,32,91,51,54,93,0],"i8",D);I.qa=F([32,32,45,111,44,32,45,45,111,117,116,112,117,116,61,60,102,105,108,101,62,32,32,32,32,32,32,32,32,105,102,32,114,101,97,100,105,110,103,32,115,116,100,105,110,44,32,112,108,97,99,101,32,116,104,101,32,111,117,116,112,117,116,32,105,110,116,111,32,60,102,105,108,101,62,0],"i8",D);I.ra=F([32,32,45,113,44,32,45,45,113,117,105,101,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,117,112,112,114,101,115,115,32,97,108,108,32,109,101,115,115,97,103,101,115,0],"i8",D);I.sa=F([32,32,45,115,44,32,45,45,100,105,99,116,105,111,110,97,114,121,45,115,105,122,101,61,60,110,62,32,32,115,101,116,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,32,91,56,77,105,66,93,0],"i8",D);I.ta=F([32,32,45,83,44,32,45,45,118,111,108,117,109,101,45,115,105,122,101,61,60,110,62,32,32,32,32,32,32,115,101,116,32,118,111,108,117,109,101,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,0],"i8",D);I.ua=F([32,32,45,116,44,32,45,45,116,101,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,116,101,115,116,32,99,111,109,112,114,101,115,115,101,100,32,102,105,108,101,32,105,110,116,101,103,114,105,116,121,0],"i8",D);I.va=F([32,32,45,118,44,32,45,45,118,101,114,98,111,115,101,32,32,32,32,32,32,32,32,32,32,32,32,32,32,98,101,32,118,101,114,98,111,115,101,32,40,97,32,50,110,100,32,45,118,32,103,105,118,101,115,32,109,111,114,101,41,0],"i8",D);I.wa=F([32,32,45,48,32,46,46,32,45,57,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,101,116,32,99,111,109,112,114,101,115,115,105,111,110,32,108,101,118,101,108,32,91,100,101,102,97,117,108,116,32,54,93,0],"i8",D);I.xa=F([32,32,32,32,32,32,45,45,102,97,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,108,105,97,115,32,102,111,114,32,45,48,0],"i8",D);I.ya=F([32,32,32,32,32,32,45,45,98,101,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,108,105,97,115,32,102,111,114,32,45,57,0],"i8",D);I.Aa=F([102,114,111,109,32,115,116,97,110,100,97,114,100,32,105,110,112,117,116,32,116,111,32,115,116,97,110,100,97,114,100,32,111,117,116,112,117,116,46,0],"i8",D);I.Ba=F([78,117,109,98,101,114,115,32,109,97,121,32,98,101,32,102,111,108,108,111,119,101,100,32,98,121,32,97,32,109,117,108,116,105,112,108,105,101,114,58,32,107,32,61,32,107,66,32,61,32,49,48,94,51,32,61,32,49,48,48,48,44,0],"i8",D);I.Ca=F([75,105,32,61,32,75,105,66,32,61,32,50,94,49,48,32,61,32,49,48,50,52,44,32,77,32,61,32,49,48,94,54,44,32,77,105,32,61,32,50,94,50,48,44,32,71,32,61,32,49,48,94,57,44,32,71,105,32,61,32,50,94,51,48,44,32,101,116,99,46,46,46,0],"i8",D);I.Da=F([10,82,101,112,111,114,116,32,98,117,103,115,32,116,111,32,108,122,105,112,45,98,117,103,64,110,111,110,103,110,117,46,111,114,103,0],"i8",D);I.Ea=F([76,122,105,112,32,104,111,109,101,32,112,97,103,101,58,32,104,116,116,112,58,47,47,119,119,119,46,110,111,110,103,110,117,46,111,114,103,47,108,122,105,112,47,108,122,105,112,46,104,116,109,108,0],"i8",D);I.Fa=F([76,105,99,101,110,115,101,32,71,80,76,118,51,43,58,32,71,78,85,32,71,80,76,32,118,101,114,115,105,111,110,32,51,32,111,114,32,108,97,116,101,114,32,60,104,116,116,112,58,47,47,103,110,117,46,111,114,103,47,108,105,99,101,110,115,101,115,47,103,112,108,46,104,116,109,108,62,0],"i8",D);I.Ga=F([84,104,105,115,32,105,115,32,102,114,101,101,32,115,111,102,116,119,97,114,101,58,32,121,111,117,32,97,114,101,32,102,114,101,101,32,116,111,32,99,104,97,110,103,101,32,97,110,100,32,114,101,100,105,115,116,114,105,98,117,116,101,32,105,116,46,0],"i8",D);I.Ha=F([84,104,101,114,101,32,105,115,32,78,79,32,87,65,82,82,65,78,84,89,44,32,116,111,32,116,104,101,32,101,120,116,101,110,116,32,112,101,114,109,105,116,116,101,100,32,98,121,32,108,97,119,46,0],"i8",D);r[wd>>2]=I.O|0;r[wd+4>>2]=I.P|0;r[wd+8>>2]=I.Q|0;r[wd+12>>2]=I.R|0;r[wd+16>>2]=I.S|0;r[wd+20>>2]=I.T|0;r[wd+24>>2]=I.U|0;r[wd+28>>2]=I.V|0;r[Pd+4>>2]=Qd;Ud=F([2,0,0,0,0],["i8*",0,0,0,0],D);r[Qd>>2]=Ud+8|0;r[Qd+4>>2]=I.A|0;r[Qd+8>>2]=ca;mc=[0,0,Md,0,(function(b){Md(b);zd(b)}),0,(function(){return I.ea|0}),0];Module.FUNCTION_TABLE=mc;function ue(b){b=b||Module.arguments;vc(wc);var d=l;Module._main&&(d=Module.Qa(b),Module.noExitRuntime||vc(zc));return d}Module.run=ue;Module.preRun&&Module.preRun();Module.noInitialRun||ue();Module.postRun&&Module.postRun() + + return returnValue; + }, + + compress: function(data) { + return this.run(data); + }, + + decompress: function(data) { + return this.run(data, true); + } +}; + diff --git a/third_party/lzma.js/lzma-full.js b/third_party/lzma.js/lzma-full.js new file mode 100644 index 00000000..db5801c5 --- /dev/null +++ b/third_party/lzma.js/lzma-full.js @@ -0,0 +1,27 @@ + +// This is lzma.js, powered by lzip (which is GPL, source code at https://github.com/kripken/lzma.js) +var LZMA = { + run: function(data, decompress) { + var inputIndex = 0; + var returnValue = []; + var Module = { + arguments: ['-q'].concat(decompress ? ['-d'] : []), + stdin: function() { return inputIndex < data.length ? data[inputIndex++] : null }, + stdout: function(x) { if (x !== null) returnValue.push(x) } + }; + + +function b(a){throw a}var aa=void 0,k=!0,ca=null,l=!1,ea=[],pa="object"===typeof process,ya="object"===typeof window,za="function"===typeof importScripts,Ca=!ya&&!pa&&!za;if(pa){print=(function(a){process.stdout.write(a+"\n")});printErr=(function(a){process.stderr.write(a+"\n")});var Da=require("fs");read=(function(a){var c=Da.readFileSync(a).toString();!c&&"/"!=a[0]&&(a=__dirname.split("/").slice(0,-1).join("/")+"/src/"+a,c=Da.readFileSync(a).toString());return c});load=(function(a){Ra(read(a))});ea=process.argv.slice(2)}else{Ca?(this.read||(this.read=(function(a){snarf(a)})),"undefined"!=typeof scriptArgs?ea=scriptArgs:"undefined"!=typeof arguments&&(ea=arguments)):ya?(this.print=printErr=(function(a){console.log(a)}),this.read=(function(a){var c=new XMLHttpRequest;c.open("GET",a,l);c.send(ca);return c.responseText}),this.arguments&&(ea=arguments)):za?this.load=importScripts:b("Unknown runtime environment. Where are we?")}function Ra(a){eval.call(ca,a)}"undefined"==typeof load&&"undefined"!=typeof read&&(this.load=(function(a){Ra(read(a))}));"undefined"===typeof printErr&&(this.printErr=(function(){}));"undefined"===typeof print&&(this.print=printErr);try{this.Module=Module}catch(ab){this.Module=Module={}}Module.arguments||(Module.arguments=ea);Module.print&&(print=Module.print);function nb(a){if(1==ob){return 1}var c={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+a];c||("*"==a[a.length-1]?c=ob:"i"==a[0]&&(a=parseInt(a.substr(1)),qb(0==a%8),c=a/8));return c}function zb(a){var c=m;m+=a;m=m+3>>2<<2;return c}function Bb(a){var c=Cb;Cb+=a;Cb=Cb+3>>2<<2;if(Cb>=Db){for(;Db<=Cb;){Db=2*Db+4095>>12<<12}var a=n,d=new ArrayBuffer(Db);n=new Int8Array(d);Rb=new Int16Array(d);p=new Int32Array(d);w=new Uint8Array(d);Sb=new Uint16Array(d);x=new Uint32Array(d);Ub=new Float32Array(d);Vb=new Float64Array(d);n.set(a)}return c}var ob=4,Wb={},Xb,z,C,Yb;function ac(a){print(a+":\n"+Error().stack);b("Assertion: "+a)}function qb(a,c){a||ac("Assertion failed: "+c)}var bc=this;Module.ccall=(function(a,c,d,e){try{var f=eval("_"+a)}catch(g){try{f=bc.Module["_"+a]}catch(h){}}qb(f,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)");var i=0,a=e?e.map((function(a){if("string"==d[i++]){var c=m;zb(a.length+1);cc(a,c);a=c}return a})):[];return(function(a,c){return"string"==c?dc(a):a})(f.apply(ca,a),c)});function ec(a,c,d){d=d||"i8";"*"===d[d.length-1]&&(d="i32");switch(d){case"i1":n[a]=c;break;case"i8":n[a]=c;break;case"i16":Rb[a>>1]=c;break;case"i32":p[a>>2]=c;break;case"i64":p[a>>2]=c;break;case"float":Ub[a>>2]=c;break;case"double":fc[0]=c;p[a>>2]=jc[0];p[a+4>>2]=jc[1];break;default:ac("invalid type for setValue: "+d)}}Module.setValue=ec;Module.getValue=(function(a,c){c=c||"i8";"*"===c[c.length-1]&&(c="i32");switch(c){case"i1":return n[a];case"i8":return n[a];case"i16":return Rb[a>>1];case"i32":return p[a>>2];case"i64":return p[a>>2];case"float":return Ub[a>>2];case"double":return jc[0]=p[a>>2],jc[1]=p[a+4>>2],fc[0];default:ac("invalid type for setValue: "+c)}return ca});var kc=1,E=2;Module.ALLOC_NORMAL=0;Module.ALLOC_STACK=kc;Module.ALLOC_STATIC=E;function F(a,c,d){var e,f;"number"===typeof a?(e=k,f=a):(e=l,f=a.length);var g="string"===typeof c?c:ca,d=[nc,zb,Bb][d===aa?E:d](Math.max(f,g?1:c.length));if(e){return oc(d,0,f),d}e=0;for(var h;e<f;){var i=a[e];"function"===typeof i&&(i=Wb.fb(i));h=g||c[e];0===h?e++:("i64"==h&&(h="i32"),ec(d+e,i,h),e+=nb(h))}return d}Module.allocate=F;function dc(a,c){for(var d="undefined"==typeof c,e="",f=0,g,h=String.fromCharCode(0);;){g=String.fromCharCode(w[a+f]);if(d&&g==h){break}e+=g;f+=1;if(!d&&f==c){break}}return e}Module.Pointer_stringify=dc;Module.Array_stringify=(function(a){for(var c="",d=0;d<a.length;d++){c+=String.fromCharCode(a[d])}return c});var pc,qc=4096,n,w,Rb,Sb,p,x,Ub,Vb,m,rc,Cb,sc=Module.TOTAL_STACK||5242880,Db=Module.TOTAL_MEMORY||10485760;qb(!!Int32Array&&!!Float64Array&&!!(new Int32Array(1)).subarray&&!!(new Int32Array(1)).set,"Cannot fallback to non-typed array case: Code is too specialized");var tc=new ArrayBuffer(Db);n=new Int8Array(tc);Rb=new Int16Array(tc);p=new Int32Array(tc);w=new Uint8Array(tc);Sb=new Uint16Array(tc);x=new Uint32Array(tc);Ub=new Float32Array(tc);Vb=new Float64Array(tc);p[0]=255;qb(255===w[0]&&0===w[3],"Typed arrays 2 must be run on a little-endian system");var vc=uc("(null)");Cb=vc.length;for(var wc=0;wc<vc.length;wc++){n[wc]=vc[wc]}Module.HEAP=aa;Module.HEAP8=n;Module.HEAP16=Rb;Module.HEAP32=p;Module.HEAPU8=w;Module.HEAPU16=Sb;Module.HEAPU32=x;Module.HEAPF32=Ub;Module.HEAPF64=Vb;rc=(m=4*Math.ceil(Cb/4))+sc;var xc=8*Math.ceil(rc/8);n.subarray(xc);var jc=p.subarray(xc>>2);Ub.subarray(xc>>2);var fc=Vb.subarray(xc>>3);rc=xc+8;Cb=rc+4095>>12<<12;function yc(a){for(;0<a.length;){var c=a.shift(),d=c.l;"number"===typeof d&&(d=pc[d]);d(c.$a===aa?ca:c.$a)}}var Ac=[],Bc=[];function Cc(a,c){return Array.prototype.slice.call(n.subarray(a,a+c))}Module.Array_copy=Cc;Module.TypedArray_copy=(function(a,c){for(var d=new Uint8Array(c),e=0;e<c;++e){d[e]=n[a+e]}return d.buffer});function Dc(a){for(var c=0;n[a+c];){c++}return c}Module.String_len=Dc;function Ec(a,c){var d=Dc(a);c&&d++;var e=Cc(a,d);c&&(e[d-1]=0);return e}Module.String_copy=Ec;function uc(a,c){for(var d=[],e=0;e<a.length;){var f=a.charCodeAt(e);255<f&&(f&=255);d.push(f);e+=1}c||d.push(0);return d}Module.intArrayFromString=uc;Module.intArrayToString=(function(a){for(var c=[],d=0;d<a.length;d++){var e=a[d];255<e&&(e&=255);c.push(String.fromCharCode(e))}return c.join("")});function cc(a,c,d){for(var e=0;e<a.length;){var f=a.charCodeAt(e);255<f&&(f&=255);n[c+e]=f;e+=1}d||(n[c+e]=0)}Module.writeStringToMemory=cc;var K=[];function Fc(a,c){return 0<=a?a:32>=c?2*Math.abs(1<<c-1)+a:Math.pow(2,c)+a}function Gc(a,c){if(0>=a){return a}var d=32>=c?Math.abs(1<<c-1):Math.pow(2,c-1);if(a>=d&&(32>=c||a>d)){a=-2*d+a}return a}function Hc(a,c,d){var e=0>(d|0)?-1:0,f=(d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0)>>>0,a=Math.min(Math.floor(((d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0))/4294967296),4294967295);return[f,a]}function Ic(a,c,d){var e=0>(d|0)?-1:0,f=(d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0)>>>0,a=Math.min(Math.floor(((d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0))/4294967296),4294967295);return[f,a]}function Jc(a,c,d){var e=0<(d|0);a:do{if(e){for(var f=0,g=p[a>>2];;){if(g=p[Kc+((w[c+f|0]&255^g&255)<<2)>>2]^g>>>8,p[a>>2]=g,f=f+1|0,(f|0)==(d|0)){break a}}}}while(0)}function Lc(a,c,d){n[a+12|0]=c&255;n[a+13|0]=(c>>>8|d<<24)&255;n[a+14|0]=(c>>>16|d<<16)&255;n[a+15|0]=(c>>>24|d<<8)&255;n[a+16|0]=d&255;n[a+17|0]=(d>>>8|0)&255;n[a+18|0]=(d>>>16|0)&255;n[a+19|0]=(d>>>24|0)&255}function Mc(a){var c=n[a+11|0],d=n[a+10|0]|c<<8|0,e=n[a+9|0]|d<<8|0,f=n[a+8|0]|e<<8|0,g=n[a+7|0]|f<<8|0,h=n[a+6|0]|g<<8|0,i=n[a+5|0]|h<<8|0;return[n[a+4|0]|i<<8|0,0|((((((0|c>>>24)<<8|d>>>24)<<8|e>>>24)<<8|f>>>24)<<8|g>>>24)<<8|h>>>24)<<8|i>>>24]}Mc.X=1;function Nc(a){var c=n[a+19|0],d=n[a+18|0]|c<<8|0,e=n[a+17|0]|d<<8|0,f=n[a+16|0]|e<<8|0,g=n[a+15|0]|f<<8|0,h=n[a+14|0]|g<<8|0,i=n[a+13|0]|h<<8|0;return[n[a+12|0]|i<<8|0,0|((((((0|c>>>24)<<8|d>>>24)<<8|e>>>24)<<8|f>>>24)<<8|g>>>24)<<8|h>>>24)<<8|i>>>24]}Nc.X=1;function Oc(a,c,d){p[Pc>>2]=0;var e=d;a:for(;;){var f=c+(d-e)|0;if(0>=(e|0)){var g=0;break}for(;;){p[Pc>>2]=0;var h=Qc(a,f,e);if(0<(h|0)){break}if(0==(h|0)){g=e;break a}if(4!=(p[Pc>>2]|0)&&11!=(p[Pc>>2]|0)){g=e;break a}}e=e-h|0}return d-g|0}function Rc(a,c,d){p[Pc>>2]=0;var e=d;a:for(;;){var f=c+(d-e)|0;if(0>=(e|0)){var g=0;break}for(;;){p[Pc>>2]=0;var h=Sc(a,f,e);if(0<(h|0)){break}if(0!=(p[Pc>>2]|0)&&4!=(p[Pc>>2]|0)&&11!=(p[Pc>>2]|0)){g=e;break a}}e=e-h|0}return d-g|0}function Tc(a){var c,d;d=(a+20|0)>>2;c=(a+24|0)>>2;var e=p[c],f=p[d]-e|0;if(0<(f|0)){var g=a+16|0;Jc(a+28|0,p[g>>2]+e|0,f);e=p[a+32>>2];-1<(e|0)&&(Rc(e,p[g>>2]+p[c]|0,f)|0)!=(f|0)&&Uc(-1);f=p[d];if((f|0)<(p[a+12>>2]|0)){d=f}else{var g=0>(f|0)?-1:0,a=(a|0)>>2,h=p[a],i=p[a+1],e=(h>>>0)+4294967296*(i|0)+(f>>>0)+4294967296*(g|0)>>>0,f=Math.min(Math.floor(((h>>>0)+4294967296*(i|0)+(f>>>0)+4294967296*(g|0))/4294967296),4294967295);p[a]=e;p[a+1]=f;d=p[d]=0}p[c]=d}}function Vc(a){var c,d=m;m+=20;var e=a+36|0,f=0<(p[e>>2]|0)?20:12;c=(a+40|0)>>2;for(var g=p[c],h=g|0,g=Hc(p[h>>2],p[h+4>>2],p[g+12>>2]),h=g[0],i=g[1],j=0>(f|0)?-1:0,g=(h>>>0)+4294967296*(i|0)+(f>>>0)+4294967296*(j|0)>>>0,h=Math.min(Math.floor(((h>>>0)+4294967296*(i|0)+(f>>>0)+4294967296*(j|0))/4294967296),4294967295),j=i=0;(i|0)<(f|0);){if(0!=(j&1)<<24>>24){break}if(Wc(p[c])){oc(d+i|0,0,f-i|0),i=f,j=1}else{var o=Xc(p[c]);n[d+i|0]=o}i=i+1|0}0==(p[e>>2]|0)&&Lc(d,g,h);0==(p[p[c]+20>>2]|0)?c=j:(Yc(K.L|0),c=1);e=(w[d|0]&255|(w[d+1|0]&255|(w[d+2|0]&255|(w[d+3|0]&255)<<8)<<8)<<8|0)==(p[a+28>>2]^-1|0);i=Mc(d);f=i[0];i=i[1];j=a|0;a=Ic(p[j>>2],p[j+4>>2],p[a+20>>2]);j=Nc(d);a=(j[0]==g&&j[1]==h)&(f==a[0]&&i==a[1])&e&0==(c&1)<<24>>24;m=d;return a}Vc.X=1;function Wc(a){var c;if((p[a+12>>2]|0)<(p[a+16>>2]|0)){c=0}else{var d=a+32|0;if(0==(n[d]&1)<<24>>24){c=Oc(p[a+28>>2],p[a+8>>2],16384);var e=a+16|0;p[e>>2]=c;16384!=(c|0)&&0!=(p[Pc>>2]|0)&&Uc(-1);c=x[e>>2];n[d]=16384>(c|0)&1;var d=a+12|0,e=p[d>>2],f=0>(e|0)?-1:0,a=(a|0)>>2,g=p[a],h=p[a+1],i=(g>>>0)+4294967296*(h|0)+(e>>>0)+4294967296*(f|0)>>>0,e=Math.min(Math.floor(((g>>>0)+4294967296*(h|0)+(e>>>0)+4294967296*(f|0))/4294967296),4294967295);p[a]=i;p[a+1]=e;d=p[d>>2]=0}else{d=p[a+12>>2],c=p[a+16>>2]}c=(d|0)<(c|0)^1}return c}function Xc(a){if(Wc(a)){a=85}else{var c=a+12|0,d=p[c>>2];p[c>>2]=d+1|0;a=n[p[a+8>>2]+d|0]}return a}function Zc(a){var c,d=m;m+=29280;for(var e,f=d+192,g=d+240,h=d+288,i=d+336,j=d+384,o=d+576,u=d+1600,q=d+2060,t=d+2124,s=d+3412,B=d+4700,v=d+29276,y=d+192|0,A=d|0;;){T(A);var r=A+4|0;if((r|0)==(y|0)){break}A=r}T(f|0);T(f+4|0);T(f+8|0);T(f+12|0);T(f+16|0);T(f+20|0);T(f+24|0);T(f+28|0);T(f+32|0);T(f+36|0);T(f+40|0);T(f+44|0);T(g|0);T(g+4|0);T(g+8|0);T(g+12|0);T(g+16|0);T(g+20|0);T(g+24|0);T(g+28|0);T(g+32|0);T(g+36|0);T(g+40|0);T(g+44|0);T(h|0);T(h+4|0);T(h+8|0);T(h+12|0);T(h+16|0);T(h+20|0);T(h+24|0);T(h+28|0);T(h+32|0);T(h+36|0);T(h+40|0);T(h+44|0);T(i|0);T(i+4|0);T(i+8|0);T(i+12|0);T(i+16|0);T(i+20|0);T(i+24|0);T(i+28|0);T(i+32|0);T(i+36|0);T(i+40|0);T(i+44|0);for(var D=j+192|0,L=j|0;;){T(L);var H=L+4|0;if((H|0)==(D|0)){break}L=H}for(var P=o+1024|0,J=o|0;;){T(J);var G=J+4|0;if((G|0)==(P|0)){break}J=G}for(var I=u+460|0,M=u|0;;){T(M);var O=M+4|0;if((O|0)==(I|0)){break}M=O}var N=q|0;T(N);T(q+4|0);T(q+8|0);T(q+12|0);T(q+16|0);T(q+20|0);T(q+24|0);T(q+28|0);T(q+32|0);T(q+36|0);T(q+40|0);T(q+44|0);T(q+48|0);T(q+52|0);T(q+56|0);T(q+60|0);$c(t);$c(s);for(var Q=B+24576|0,$=B|0;;){T($);var ha=$+4|0;if((ha|0)==(Q|0)){break}$=ha}n[v|0]=0;c=(a+40|0)>>2;ad(p[c]);var ba=a+8|0,R=a+20|0,Sa=a|0,fa=v|0,U=0,qa=0,Aa=0,da=0;a:for(;;){b:for(;;){if(Wc(p[c])){Tc(a);var Ea=2;break a}var ra=Sa|0,pb=Sa+4|0,bb=Ic(p[ra>>2],p[pb>>2],p[R>>2])[0]&3,Eb=w[fa],sa=Eb&255;if(0==(bd(p[c],(sa<<4)+(bb<<2)+d|0)|0)){var Fa,Zb=p[a+20>>2];Fa=n[p[a+16>>2]+((0<(Zb|0)?Zb:p[a+12>>2])-1)|0];var ga=p[c];if(7>(Eb&255)){var ta=fd(ga,B+3072*((Fa&255)>>5)|0,8)&255;gd(a,ta)}else{for(var ia=p[a+20>>2]-U-1|0,La=ga,cb=B+3072*((Fa&255)>>5)|0,db=n[p[a+16>>2]+(0>(ia|0)?p[a+12>>2]+ia|0:ia)|0]&255,Fb=aa,ja=7,rb=1;;){if(-1>=(ja|0)){var Ga=rb,Fb=7;break}var sb=db>>>(ja>>>0)&1,tb=bd(La,((sb<<8)+rb+256<<2)+cb|0),Ta=tb|rb<<1;if((sb|0)!=(tb|0)){Fb=4;break}ja=ja-1|0;rb=Ta}c:do{if(4==Fb){if(0<(ja|0)){for(var Ma=Ta,Ua=ja;;){var ub=Ua-1|0,eb=Ma<<1,vb=bd(La,(Ma<<2)+cb|0)|eb;if(0>=(ub|0)){Ga=vb;break c}Ma=vb;Ua=ub}}else{Ga=Ta}}}while(0);gd(a,Ga&255)}hd(v)}else{var Na=bd(p[c],(sa<<2)+f|0),Va=x[c];if(1==(Na|0)){var Nb=1==(bd(Va,(sa<<2)+g|0)|0),Gb=p[c];do{if(!Nb){if(0!=(bd(Gb,(sa<<4)+(bb<<2)+j|0)|0)){var Hb=U,Ib=qa,Wa=Aa,Y=da;break}id(v);var na=U,ka=qa,ua=Aa,va=da,fb=1;e=37;break b}if(0==(bd(Gb,(sa<<2)+h|0)|0)){Hb=qa,Ib=U,Wa=Aa,Y=da}else{var Oa=0==(bd(p[c],(sa<<2)+i|0)|0),gb=Oa?da:Aa,Hb=Oa?Aa:da,Ib=U,Wa=qa,Y=gb}}while(0);jd(v);var Ob=kd(s,p[c],bb),na=Hb,ka=Ib,ua=Wa,va=Y,fb=Ob+2|0;e=37;break}var S=kd(t,Va,bb),oa=S+2|0,Xa=fd(p[c],(ld(oa)<<8)+o|0,6);if(4>(Xa|0)){var la=Xa;e=33;break}var wa=Xa>>1,ma=wa-1|0,Ya=(Xa&1|2)<<ma,Jb=p[c];if(14>(Xa|0)){la=md(Jb,(Ya-Xa<<2)+u|0,ma)+Ya|0;e=33;break}var wb=Jb,Za=wa-5|0,Ha=aa,Ia=aa,Pa=0<(Za|0);c:do{if(Pa){for(var Ia=(wb+24|0)>>2,Ha=(wb+20|0)>>2,hb=0,ib=Za,Qa=p[Ia];;){var xa=hb<<1;if(16777216>Qa>>>0){p[Ia]=Qa<<7;var Ja=p[Ha]<<8,jb=Xc(wb)&255|Ja;p[Ha]=jb;var Ba=x[Ia];if(jb>>>0<Ba>>>0){var $a=xa,xb=Ba}else{p[Ha]=jb-Ba|0,$a=xa|1,xb=Ba}}else{var kb=Qa>>>1;p[Ia]=kb;var yb=x[Ha];yb>>>0<kb>>>0?$a=xa:(p[Ha]=yb-kb|0,$a=xa|1);xb=kb}var Kb=ib-1|0;if(0>=(Kb|0)){var Lb=$a;break c}hb=$a;ib=Kb;Qa=xb}}else{Lb=0}}while(0);var Pb=Lb<<4,Qb=md(p[c],N,4),Ka=Pb+Ya+Qb|0;if(-1!=(Ka|0)){la=Ka;e=33;break}nd(p[c]);Tc(a);if(0==(S|0)){Ea=Vc(a)?0:3;break a}if(3!=(oa|0)){Ea=4;break a}ad(p[c])}}do{if(33==e){od(v);if(la>>>0<x[ba>>2]>>>0){if(la>>>0<x[R>>2]>>>0){na=la;ka=U;ua=qa;va=Aa;fb=oa;break}ra=Sa|0;pb=Sa+4|0;if(!(0==p[ra>>2]&&0==p[pb>>2])){na=la;ka=U;ua=qa;va=Aa;fb=oa;break}}Tc(a);Ea=1;break a}}while(0);pd(a,na,fb);U=na;qa=ka;Aa=ua;da=va}m=d;return Ea}Zc.X=1;function ad(a){var c;c=(a+20|0)>>2;p[c]=0;p[a+24>>2]=-1;var d=Xc(a)&255;p[c]=d;d=Xc(a)&255|d<<8;p[c]=d;d=Xc(a)&255|d<<8;p[c]=d;d=Xc(a)&255|d<<8;p[c]=d;d<<=8;a=Xc(a);p[c]=a&255|d}function ld(a){a=a-2|0;return 3<(a|0)?3:a}function hd(a){a|=0;n[a]=n[K.J+(w[a]&255)|0]}function id(a){a|=0;n[a]=n[K.H+(w[a]&255)|0]}function jd(a){a|=0;n[a]=n[K.I+(w[a]&255)|0]}function od(a){a|=0;n[a]=n[K.K+(w[a]&255)|0]}function T(a){p[a>>2]=1024}function bd(a,c){var d,e;nd(a);e=(a+24|0)>>2;var f=x[e];d=(c|0)>>2;var g=(f>>>11)*p[d]|0,h=a+20|0,i=x[h>>2];i>>>0<g>>>0?(p[e]=g,f=x[d],e=0,f=((2048-f|0)>>>5)+f|0):(p[e]=f-g|0,p[h>>2]=i-g|0,f=x[d],e=1,f=f-(f>>>5)|0);p[d]=f;return e}function gd(a,c){var d;d=(a+20|0)>>2;n[p[a+16>>2]+p[d]|0]=c;var e=p[d]+1|0;p[d]=e;(e|0)<(p[a+12>>2]|0)||Tc(a)}function kd(a,c,d){return 0==(bd(c,a|0)|0)?fd(c,(d<<5)+a+8|0,3):0==(bd(c,a+4|0)|0)?fd(c,(d<<5)+a+136|0,3)+8|0:fd(c,a+264|0,8)+16|0}function fd(a,c,d){var e=0<(d|0);a:do{if(e){for(var f=1,g=d;;){var h=f<<1,f=bd(a,(f<<2)+c|0)|h,g=g-1|0;if(0>=(g|0)){var i=f;break a}}}else{i=1}}while(0);return i-(1<<d)|0}function md(a,c,d){var e=0<(d|0);a:do{if(e){for(var f=1,g=0,h=0;;){var i=bd(a,(f<<2)+c|0),f=f<<1;0!=(i|0)&&(g|=1<<h,f|=1);h=h+1|0;if((h|0)==(d|0)){var j=g;break a}}}else{j=0}}while(0);return j}function nd(a){var c=a+24|0,d=x[c>>2];16777216>d>>>0&&(p[c>>2]=d<<8,c=a+20|0,d=p[c>>2]<<8,a=Xc(a)&255|d,p[c>>2]=a)}function pd(a,c,d){var e,f;e=(a+20|0)>>2;var g=p[e],h=g-c-1|0,c=(a+12|0)>>2;f=p[c];h=h+(0>(h|0)?f:0)|0;(f-((g|0)>(h|0)?g:h)|0)>(d|0)?(f=g-h|0,((-1<(f|0)?f:-f|0)|0)<(d|0)?f=3:(f=p[a+16>>2],qd(f+g|0,f+h|0,d),p[e]=p[e]+d|0,f=10)):f=3;a:do{if(3==f&&0<(d|0)){for(var i=a+16|0,j=d,o=h,u=g;;){var q=p[i>>2];n[q+u|0]=n[q+o|0];u=p[e]+1|0;p[e]=u;q=p[c];(u|0)<(q|0)?u=q:(Tc(a),u=p[c]);o=o+1|0;j=j-1|0;if(0>=(j|0)){break a}o=(o|0)<(u|0)?o:0;u=p[e]}}}while(0)}pd.X=1;function $c(a){T(a|0);T(a+4|0);T(a+8|0);T(a+12|0);T(a+16|0);T(a+20|0);T(a+24|0);T(a+28|0);T(a+32|0);T(a+36|0);T(a+40|0);T(a+44|0);T(a+48|0);T(a+52|0);T(a+56|0);T(a+60|0);T(a+64|0);T(a+68|0);T(a+72|0);T(a+76|0);T(a+80|0);T(a+84|0);T(a+88|0);T(a+92|0);T(a+96|0);T(a+100|0);T(a+104|0);T(a+108|0);T(a+112|0);T(a+116|0);T(a+120|0);T(a+124|0);T(a+128|0);T(a+132|0);T(a+136|0);T(a+140|0);T(a+144|0);T(a+148|0);T(a+152|0);T(a+156|0);T(a+160|0);T(a+164|0);T(a+168|0);T(a+172|0);T(a+176|0);T(a+180|0);T(a+184|0);T(a+188|0);T(a+192|0);T(a+196|0);T(a+200|0);T(a+204|0);T(a+208|0);T(a+212|0);T(a+216|0);T(a+220|0);T(a+224|0);T(a+228|0);T(a+232|0);T(a+236|0);T(a+240|0);T(a+244|0);T(a+248|0);T(a+252|0);T(a+256|0);T(a+260|0);for(var c=a+1288|0,a=a+264|0;!(T(a),a=a+4|0,(a|0)==(c|0));){}}$c.X=1;function rd(a,c,d,e){var f,g=a>>2,h=a|0;p[h>>2]=0;p[h+4>>2]=0;var h=a+12|0,i=sd(5505024);p[h>>2]=i;p[g+7]=0;p[g+8]=0;i=a+36|0;p[i>>2]=0;p[g+11]=d;p[g+12]=273>(d|0)?d/2+16|0:256;p[g+13]=e;e=a+56|0;n[e]=0;var j=(c<<1)+4370|0;f=65536>(c|0)?65536:c;d=(a+24|0)>>2;p[d]=f;var o=nc(f);f=(a+8|0)>>2;p[f]=o;0==(o|0)&&Uc(-1);td(a)&&0==(n[e]&1)<<24>>24&&(p[d]|0)<(j|0)&&(p[d]=j,j=0==(p[f]|0)?nc(j):ud(p[f],j),p[f]=j,0==(j|0)&&Uc(-1),td(a));0==(n[e]&1)<<24>>24?(p[g+5]=c,a=p[d]-273|0):(a=p[i>>2],(a|0)<(c|0)&&(c=4096>(a|0)?4096:a),p[g+5]=c,a=p[d]);p[g+10]=a;c=sd(4*(c<<1));p[g+4]=c;for(g=0;!(p[((g<<2)+p[h>>2]|0)>>2]=-1,g=g+1|0,1376256==(g|0));){}}rd.X=1;function td(a){var c,d=a+56|0,e=0==(n[d]&1)<<24>>24;c=(a+36|0)>>2;if(e){var f=p[c],e=p[a+24>>2];if((f|0)<(e|0)){e=e-f|0;f=Oc(p[a+52>>2],p[a+8>>2]+f|0,e);p[c]=p[c]+f|0;if((f|0)!=(e|0)&&0!=(p[Pc>>2]|0)){var g=nc(4);p[g>>2]=K.ea|0;vd(g,wd,0);b("Reached an unreachable!")}n[d]=(f|0)<(e|0)&1}}return(p[a+28>>2]|0)<(p[c]|0)}function xd(a){var c,d,e,f;e=(a+32|0)>>2;var g=p[e]+1|0;p[e]=g;f=(a+20|0)>>2;(g|0)<(p[f]|0)||(p[e]=0);e=(a+28|0)>>2;g=p[e]+1|0;p[e]=g;var h=(g|0)<(p[a+40>>2]|0);do{if(!h&&(d=(a+36|0)>>2,(g|0)>(p[d]|0)&&yd(K.O|0),0==(n[a+56|0]&1)<<24>>24)){var i=p[e]-p[f]-4097|0;c=p[a+8>>2];zd(c,c+i|0,p[d]-i|0);var j=i,o=0>(i|0)?-1:0;c=(a|0)>>2;var u=p[c],q=p[c+1],t=(u>>>0)+4294967296*(q|0)+(j>>>0)+4294967296*(o|0)>>>0,j=Math.min(Math.floor(((u>>>0)+4294967296*(q|0)+(j>>>0)+4294967296*(o|0))/4294967296),4294967295);p[c]=t;p[c+1]=j;p[e]=p[e]-i|0;p[d]=p[d]-i|0;d=a+12|0;for(c=0;!(t=(c<<2)+p[d>>2]|0,j=p[t>>2],-1<(j|0)&&(p[t>>2]=j-i|0),c=c+1|0,1376256==(c|0));){}d=p[f];c=0<(d<<1|0);a:do{if(c){t=a+16|0;j=0;for(o=d;;){if(u=(j<<2)+p[t>>2]|0,q=p[u>>2],-1<(q|0)&&(p[u>>2]=q-i|0,o=p[f]),j=j+1|0,(j|0)>=(o<<1|0)){break a}}}}while(0);td(a)}}while(0)}xd.X=1;function Ad(a,c){var d,e,f,g,h,i=c>>2,j;j=p[a+44>>2];h=(a+28|0)>>2;var o=x[h];g=p[a+36>>2]-o|0;if((j|0)>(g|0)){if(4>(g|0)){var u=0;j=38}else{var q=g;j=3}}else{q=j,j=3}do{if(3==j){u=a+20|0;g=p[u>>2];var t=o+1|0,s=(o|0)<(g|0)?0:t-g|0;g=(a+8|0)>>2;var B=x[g],v=B+o|0,y=w[v],A=w[B+t|0]&255,t=A|(y&255)<<8|1310720,y=p[Kc+((y&255)<<2)>>2]^A^(w[o+(B+2)|0]&255)<<8,A=y&262143|1048576,r=(y^p[Kc+((n[o+(B+3)|0]&255)<<2)>>2]<<5)&1048575,y=0!=(c|0);f=(a+12|0)>>2;if(y){j=p[p[f]+(t<<2)>>2];if((j|0)<(s|0)){p[i+2]=2147483647;var D=1}else{p[i+2]=o-1-j|0,D=2}j=p[p[f]+(A<<2)>>2];if((j|0)<(s|0)){j=10}else{if(n[p[g]+j|0]<<24>>24!=n[v]<<24>>24){j=10}else{p[i+3]=p[h]+(j^-1)|0;var L=3;j=11}}10==j&&(p[i+3]=2147483647,L=D);p[i+4]=2147483647;D=L;v=p[h]}else{D=1,v=o}p[((t<<2)+p[f]|0)>>2]=v;p[((A<<2)+p[f]|0)>>2]=p[h];var t=(r<<2)+p[f]|0,H=p[t>>2];p[t>>2]=p[h];t=a+16|0;e=p[t>>2];var v=a+32|0,P=p[v>>2]<<1,A=p[a+48>>2],J=r=f=0,G=((P|1)<<2)+e|0;e=(P<<2)+e|0;e>>=2;var I=H;a:for(;;){var M=A,H=f,O=D,N=J,P=G;d=P>>2;var Q=I;b:for(;;){var $=(Q|0)<(s|0);do{if(!$){var ha=M-1|0;if(0<=(ha|0)){for(M=p[g];;){var ba=(N|0)<(q|0);if(!ba){break}if(n[M+N+Q|0]<<24>>24!=n[B+N+o|0]<<24>>24){break}N=N+1|0}var $=p[h]-Q|0,R=y&(O|0)<(N|0);c:do{if(R){for(var Sa=$-1|0,fa=O;;){if(fa=fa+1|0,p[(fa<<2>>2)+i]=Sa,(fa|0)==(N|0)){var U=N;break c}}}else{U=O}}while(0);O=x[t>>2];R=p[v>>2];R=R-$+((R|0)<($|0)?p[u>>2]:0)<<1;$=(R<<2)+O|0;if(!ba){p[e]=p[$>>2];p[d]=p[O+((R|1)<<2)>>2];var qa=U;break a}if((w[M+N+Q|0]&255)<(w[B+N+o|0]&255)){p[e]=Q;e=((R|1)<<2)+O|0;d=p[e>>2];if((H|0)>=(N|0)){A=ha;f=H;D=U;J=r=N;G=P;e>>=2;I=d;continue a}A=ha;f=H;D=U;r=N;J=H;G=P;e>>=2;I=d;continue a}p[d]=Q;Q=p[$>>2];if((r|0)>=(N|0)){M=ha;H=N;O=U;P=$;d=P>>2;continue b}M=ha;H=N;O=U;N=r;P=$;d=P>>2;continue b}}}while(0);p[d]=-1;p[e]=-1;qa=O;break a}}y&&(u=c+12|0,g=p[u>>2],s=p[i+4],u=(g|0)>(s|0)?p[u>>2]=s:g,g=c+8|0,(p[g>>2]|0)>(u|0)&&(p[g>>2]=u));u=qa}}while(0);return u}Ad.X=1;function Bd(a,c,d,e){var f=d-2|0,g=a|0;8>(f|0)?(Cd(c,g,0),Dd(c,(e<<5)+a+8|0,f,3)):(Cd(c,g,1),g=a+4|0,16>(f|0)?(Cd(c,g,0),Dd(c,(e<<5)+a+136|0,d-10|0,3)):(Cd(c,g,1),Dd(c,a+264|0,d-18|0,8)));c=(e<<2)+a+5644|0;d=p[c>>2]-1|0;p[c>>2]=d;1>(d|0)&&Ed(a,e)}function Cd(a,c,d){var e;e=(a+24|0)>>2;var f=x[e],c=(c|0)>>2,g=(f>>>11)*p[c]|0;if(0==(d|0)){p[e]=g,f=x[c],f=((2048-f|0)>>>5)+f|0}else{var d=(a|0)>>2,h=p[d],i=p[d+1],j=(h>>>0)+4294967296*(i|0)+(g>>>0)+0>>>0,h=Math.min(Math.floor(((h>>>0)+4294967296*(i|0)+(g>>>0)+0)/4294967296),4294967295);p[d]=j;p[d+1]=h;p[e]=f-g|0;f=x[c];f=f-(f>>>5)|0}p[c]=f;c=x[e];16777216>c>>>0&&(p[e]=c<<8,Fd(a))}function Dd(a,c,d,e){var f=0<(e|0);a:do{if(f){for(var g=1<<e-1,h=1,i=e;;){var j=g&d;Cd(a,(h<<2)+c|0,j);h=0!=(j|0)&1|h<<1;i=i-1|0;if(0>=(i|0)){break a}g>>=1}}}while(0)}function Ed(a,c){var d,e=a>>2,f=a|0,g=Gd(p[f>>2]);d=(a+5640|0)>>2;for(var h=(c<<5)+a+8|0,i=0;8>(i|0);){if((i|0)>=(p[d]|0)){break}p[((i<<2)+1288>>2)+e+(272*c|0)]=Hd(h,i,3)+g|0;i=i+1|0}f=Qd(p[f>>2]);h=(c<<5)+a+136|0;for(g=a+4|0;;){var j=p[d],o=(i|0)<(j|0);if(!(16>(i|0)&o)){break}p[((i<<2)+1288>>2)+e+(272*c|0)]=Gd(p[g>>2])+f+Hd(h,i-8|0,3)|0;i=i+1|0}a:do{if(o){for(var h=a+264|0,u=i;;){var q=Qd(p[g>>2])+f+Hd(h,u-16|0,8)|0;p[((u<<2)+1288>>2)+e]=q;p[((u<<2)+2376>>2)+e]=q;p[((u<<2)+3464>>2)+e]=q;p[((u<<2)+4552>>2)+e]=q;u=u+1|0;q=p[d];if((u|0)>=(q|0)){var t=q;break a}}}else{t=j}}while(0);p[((c<<2)+5644>>2)+e]=t}Ed.X=1;function Rd(a){var c=a>>2,a=a+2068|0;p[c+43305]=Sd(a,0,4);p[c+43306]=Sd(a,1,4);p[c+43307]=Sd(a,2,4);p[c+43308]=Sd(a,3,4);p[c+43309]=Sd(a,4,4);p[c+43310]=Sd(a,5,4);p[c+43311]=Sd(a,6,4);p[c+43312]=Sd(a,7,4);p[c+43313]=Sd(a,8,4);p[c+43314]=Sd(a,9,4);p[c+43315]=Sd(a,10,4);p[c+43316]=Sd(a,11,4);p[c+43317]=Sd(a,12,4);p[c+43318]=Sd(a,13,4);p[c+43319]=Sd(a,14,4);p[c+43320]=Sd(a,15,4);p[c+43321]=16}Rd.X=1;function Sd(a,c,d){var e=0<(d|0);a:do{if(e){for(var f=0,g=1,h=c,i=d;;){var j=h&1,h=h>>1,f=Td((g<<2)+a|0,j)+f|0,i=i-1|0;if(0>=(i|0)){var o=f;break a}g=j|g<<1}}else{o=0}}while(0);return o}function Ud(a){for(var c=a>>2,d=4;;){var e=n[V+d|0]&255,f=(e>>>1)-1|0,g=(e&1|2)<<f,e=Sd((g-e<<2)+a+1608|0,d-g|0,f);p[((d<<2)+171172>>2)+c]=e;p[((d<<2)+171684>>2)+c]=e;p[((d<<2)+172196>>2)+c]=e;p[((d<<2)+172708>>2)+c]=e;d=d+1|0;if(128==(d|0)){break}}d=a+38072|0;for(e=0;;){f=(e<<8)+a+584|0;for(g=0;;){var h=(g|0)<(p[d>>2]|0);if(!(14>(g|0)&h)){break}p[((g<<2)+170244>>2)+c+(58*e|0)]=Hd(f,g,6);g=g+1|0}a:do{if(h){for(var i=g;;){if(p[((i<<2)+170244>>2)+c+(58*e|0)]=Hd(f,i,6)+((i<<5)-320&-64)|0,i=i+1|0,(i|0)>=(p[d>>2]|0)){break a}}}}while(0);p[((e<<9)+171172>>2)+c]=p[c+(58*e|0)+42561];p[((e<<9)+171176>>2)+c]=p[c+(58*e|0)+42562];p[((e<<9)+171180>>2)+c]=p[c+(58*e|0)+42563];p[((e<<9)+171184>>2)+c]=p[c+(58*e|0)+42564];for(f=4;!(g=(e<<9)+(f<<2)+a+171172|0,p[g>>2]=p[g>>2]+p[(((n[V+f|0]&255)<<2)+170244>>2)+c+(58*e|0)]|0,f=f+1|0,128==(f|0));){}e=e+1|0;if(4==(e|0)){break}}}Ud.X=1;function Hd(a,c,d){c|=1<<d;d=1<(c|0);a:do{if(d){for(var e=c,f=0;;){var g=e>>1,f=Td((g<<2)+a|0,e&1)+f|0;if(1>=(g|0)){var h=f;break a}e=g}}else{h=0}}while(0);return h}function Vd(a){var c;c=(a+20|0)>>2;var d=p[c];if(0<(d|0)){var e=p[a+32>>2],f=-1<(e|0);do{if(f){var g=Rc(e,p[a+16>>2],d),h=p[c];if((g|0)==(h|0)){g=h;break}g=nc(4);p[g>>2]=K.W|0;vd(g,wd,0);b("Reached an unreachable!")}g=d}while(0);d=g;e=0>(g|0)?-1:0;a=(a+8|0)>>2;g=p[a];h=p[a+1];f=(g>>>0)+4294967296*(h|0)+(d>>>0)+4294967296*(e|0)>>>0;d=Math.min(Math.floor(((g>>>0)+4294967296*(h|0)+(d>>>0)+4294967296*(e|0))/4294967296),4294967295);p[a]=f;p[a+1]=d;p[c]=0}}function Wd(a,c,d){var e=0>(d|0)?-1:0,f=(d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0)>>>0,a=Math.min(Math.floor(((d>>>0)+4294967296*(e|0)+(a>>>0)+4294967296*(c|0))/4294967296),4294967295);return[f,a]}function Xd(a,c,d,e){var f=a+12|0;(p[f>>2]|0)>(e|0)&&(p[a+4>>2]=c,p[a+8>>2]=d,p[f>>2]=e)}function Yd(a,c,d){return p[((c-2<<2)+a+1288>>2)+(272*d|0)]}function Zd(a,c){var d=(c<<5)+a+39176|0,e=0<(c|0);a:do{if(e){for(var f=c;;){var g=p[a+(f<<5)+39180>>2];p[((g<<5)+a+39184|0)>>2]=f-g|0;var f=p[d>>2],h=(g<<5)+a+39176|0;p[d>>2]=p[h>>2];p[h>>2]=f;if(0>=(g|0)){break a}f=g}}}while(0)}function $d(a,c){var d=c>>2,e=3<(a|0);do{if(e){var f=c+8|0;p[d+3]=p[f>>2];var g=c+4|0;p[f>>2]=p[g>>2];p[g>>2]=p[d];p[d]=a-4|0}else{if(0<(a|0)){f=p[(a<<2>>2)+d];for(g=a;;){var h=g-1|0;p[(g<<2>>2)+d]=p[(h<<2>>2)+d];if(0>=(h|0)){break}g=h}p[d]=f}}}while(0)}function ae(a,c,d){var e,f,g,h,i,j=a>>2,o=m;m+=16;i=o>>2;h=(a|0)>>2;var u=p[h];if(0<(u|0)){p[h]=0;var q=u}else{q=be(a)}g=(a+2132|0)>>2;var t=x[g];f=t>>2;var s=x[c>>2],B=x[f+2],v=x[f+7],y=x[f+9],A=ce(B,v,y,0,s+1|0,273);p[i]=A;var r=c+4|0,D=ce(B,v,y,0,p[r>>2]+1|0,273);p[i+1]=D;var L=(D|0)>(A|0)&1,H=c+8|0,P=ce(B,v,y,0,p[H>>2]+1|0,273);p[i+2]=P;var J=(P|0)>(p[(L<<2>>2)+i]|0)?2:L,G=c+12|0,I=ce(B,v,y,0,p[G>>2]+1|0,273);p[i+3]=I;var M=(I|0)>(p[(J<<2>>2)+i]|0)?3:J,O=x[(M<<2>>2)+i],N=p[f+11],Q=(O|0)<(N|0);a:do{if(Q){if((q|0)<(N|0)){var $=t|0,ha=Wd(p[$>>2],p[$+4>>2],v)[0],ba=n[B+v+ -1|0],R=n[B+v+0|0],Sa=n[B+v+(s^-1)|0],fa=d|0;n[a+39172|0]=n[fa];p[j+9797]=p[c>>2];p[j+9798]=p[r>>2];p[j+9799]=p[H>>2];p[j+9800]=p[G>>2];var U=ha&3,qa=a+39204|0,Aa=a+39208|0;p[Aa>>2]=-1;p[j+9803]=0;var da=Gd(p[(((n[fa]&255)<<4)+(U<<2)+8>>2)+j]),Ea=a+39216|0;p[Ea>>2]=da;var ra=a+13496|0;p[Ea>>2]=(7>(n[fa]&255)?Hd(ra+3072*((ba&255)>>>5)|0,R&255,8):de(ra+3072*((ba&255)>>>5)|0,R&255,Sa&255))+da|0;var pb=w[fa],bb=pb&255,Eb=Qd(p[((bb<<4)+(U<<2)+8>>2)+j]),sa=Qd(p[((bb<<2)+200>>2)+j])+Eb|0;Sa<<24>>24==R<<24>>24&&Xd(qa,0,0,ee(a,pb,U)+sa|0);if(2>(q|0)){p[j+9794]=p[Aa>>2];p[j+9796]=1;xd(p[g]);var Fa=1}else{var Zb=(q|0)>(O|0);b:do{if(Zb){for(var ga=Gd(p[(((n[fa]&255)<<2)+200>>2)+j])+Eb|0,ta=q+1|0,ia=2;;){var La=(ia<<2)+a+38076|0;p[((ia<<5)+39176>>2)+j]=p[La>>2]+4|0;p[((ia<<5)+39180>>2)+j]=0;p[((ia<<5)+39184>>2)+j]=ga+(3>(ia|0)&127<(p[La>>2]|0)?268435455:fe(a,p[La>>2],ld(ia))+Yd(a+2176|0,ia,U)|0)|0;var cb=ia+1|0;if((cb|0)==(ta|0)){var db=q;break b}ia=cb}}else{if(2>(O|0)){db=O}else{for(var Fb=O+1|0,ja=2;;){p[((ja<<5)+39184>>2)+j]=268435455;var rb=ja+1|0;if((rb|0)==(Fb|0)){db=O;break b}ja=rb}}}}while(0);var Ga=a+7836|0,sb=2>(A|0);b:do{if(!sb){for(var tb=ge(a,0,n[fa],U)+sa|0,Ta=2;;){Xd((Ta<<5)+a+39172|0,0,0,tb+Yd(Ga,Ta,U)|0);var Ma=Ta+1|0;if((Ma|0)>(A|0)){break b}Ta=Ma}}}while(0);var Ua=2>(D|0);b:do{if(!Ua){for(var ub=ge(a,1,n[fa],U)+sa|0,eb=2;;){Xd((eb<<5)+a+39172|0,1,0,ub+Yd(Ga,eb,U)|0);var vb=eb+1|0;if((vb|0)>(D|0)){break b}eb=vb}}}while(0);var Na=2>(P|0);b:do{if(!Na){for(var Va=ge(a,2,n[fa],U)+sa|0,Nb=2;;){Xd((Nb<<5)+a+39172|0,2,0,Va+Yd(Ga,Nb,U)|0);var Gb=Nb+1|0;if((Gb|0)>(P|0)){break b}Nb=Gb}}}while(0);var Hb=2>(I|0);b:do{if(!Hb){for(var Ib=ge(a,3,n[fa],U)+sa|0,Wa=2;;){Xd((Wa<<5)+a+39172|0,3,0,Ib+Yd(Ga,Wa,U)|0);var Y=Wa+1|0;if((Y|0)>(I|0)){break b}Wa=Y}}}while(0);xd(p[g]);var na=a+38084|0,ka=a+2176|0,ua=db,va=0;b:for(;;){for(var fb=va+1|0,Oa=va,gb=fb,Ob=0;;){var S=Oa+1|0;if((S|0)>=(ua|0)){Zd(a,S);Fa=S;break a}var oa=be(a);if((oa|0)>=(p[p[g]+44>>2]|0)){p[h]=oa;Zd(a,S);Fa=S;break a}var Xa=(S<<5)+a+39172|0,la=p[((S<<5)+39180>>2)+j],wa=Xa|0;n[wa]=n[(la<<5)+a+39172|0];var ma=(S<<5)+a+39188|0;p[ma>>2]=p[((la<<5)+39188>>2)+j];p[((S<<5)+39192>>2)+j]=p[((la<<5)+39192>>2)+j];p[((S<<5)+39196>>2)+j]=p[((la<<5)+39196>>2)+j];p[((S<<5)+39200>>2)+j]=p[((la<<5)+39200>>2)+j];var Ya=Xa|0,Jb=(S<<5)+a+39176|0,wb=p[Jb>>2];(la|0)==(Oa|0)?0==(wb|0)?id(Ya):hd(Ya):(4>(wb|0)?jd(Ya):od(Ya),$d(p[Jb>>2],ma));var Za=x[g],Ha=Za|0,Ia=p[Za+28>>2],Pa=Wd(p[Ha>>2],p[Ha+4>>2],Ia)[0]&3,hb=p[Za+8>>2],ib=n[hb+Ia+ -1|0],Qa=n[hb+Ia+0|0],xa=n[hb+Ia+(p[ma>>2]^-1)|0],Ja=(S<<5)+a+39184|0,jb=w[wa],Ba=Gd(p[(((jb&255)<<4)+(Pa<<2)+8>>2)+j])+p[Ja>>2]+(7>(jb&255)?Hd(ra+3072*((ib&255)>>>5)|0,Qa&255,8):de(ra+3072*((ib&255)>>>5)|0,Qa&255,xa&255))|0;xd(Za);var $a=Oa+2|0,xb=($a<<5)+a+39172|0;Xd(xb,-1,S,Ba);var kb=w[wa],yb=kb&255,Kb=Qd(p[((yb<<4)+(Pa<<2)+8>>2)+j])+p[Ja>>2]|0,Lb=Kb+Qd(p[((yb<<2)+200>>2)+j])|0;xa<<24>>24==Qa<<24>>24&&0!=(p[(($a<<5)+39176>>2)+j]|0)&&Xd(xb,0,S,ee(a,kb,Pa)+Lb|0);var Pb=4094-Oa|0,Qb=p[g];e=Qb>>2;var Ka=p[e+7],gc=p[e+9]-Ka|0,Tb=(Pb|0)<(gc|0)?Pb:gc,lb=p[e+11],hc=(Tb|0)<(lb|0)?Tb:lb;if(2<=(hc|0)){var mb=ua,Mb=0,lc=Qb,$b=Ka;break}Oa=S;gb=gb+1|0;Ob=Ob+1|0}for(;;){for(var mc=p[lc+8>>2]+$b|0,cd=-2-p[((S<<5)+(Mb<<2)+39188>>2)+j]|0,Ab=0;(Ab|0)<(hc|0);){if(n[mc+(Ab-1)|0]<<24>>24!=n[mc+cd+Ab|0]<<24>>24){break}Ab=Ab+1|0}var fg=1<(Ab|0);c:do{if(fg){var gg=ge(a,Mb,n[wa],Pa),hg=(mb|0)<(Ab+S|0);d:do{if(hg){for(var Ze=Ob+fb+Ab|0,$e=mb;;){var Id=$e+1|0;p[((Id<<5)+39184>>2)+j]=268435455;if((Id|0)==(Ze|0)){var af=Ze;break d}$e=Id}}else{af=mb}}while(0);for(var ig=gg+Lb|0,dd=Ab;;){Xd((dd+S<<5)+a+39172|0,Mb,S,ig+Yd(Ga,dd,Pa)|0);var bf=dd-1|0;if(1>=(bf|0)){var ic=af;break c}dd=bf}}else{ic=mb}}while(0);var cf=Mb+1|0;if(4==(cf|0)){break}var df=x[g],mb=ic,Mb=cf,lc=df,$b=p[df+28>>2]}if((oa|0)>(hc|0)){ua=ic,va=S}else{if(2>=(oa|0)){if(2!=(oa|0)){ua=ic;va=S;continue}if(128<=(p[na>>2]|0)){ua=ic;va=S;continue}}var ef=Gd(p[(((n[wa]&255)<<2)+200>>2)+j])+Kb|0,jg=(ic|0)<(oa+S|0);c:do{if(jg){for(var ff=oa+gb|0,gf=ic;;){var Jd=gf+1|0;p[((Jd<<5)+39184>>2)+j]=268435455;if((Jd|0)==(ff|0)){var Kd=ff;break c}gf=Jd}}else{Kd=ic}}while(0);var ed=x[na>>2],hf=ld(2);128>(ed|0)&&Xd((Oa+3<<5)+a+39172|0,ed+4|0,S,p[((hf<<9)+(ed<<2)+171172>>2)+j]+ef+Yd(ka,2,Pa)|0);if(3>(oa|0)){ua=Kd,va=S}else{for(var kg=oa+1|0,Ld=ed,Md=hf,jf=268435455,zc=3;;){var Nd=p[((zc<<2)+38076>>2)+j];if((Ld|0)!=(Nd|0)|3>(Md|0)){var kf=ld(zc),Od=fe(a,Nd,kf),lf=kf,Pd=Nd}else{Od=jf,lf=Md,Pd=Ld}Xd((zc+S<<5)+a+39172|0,Pd+4|0,S,Od+ef+Yd(ka,zc,Pa)|0);var mf=zc+1|0;if((mf|0)==(kg|0)){ua=Kd;va=S;continue b}Ld=Pd;Md=lf;jf=Od;zc=mf}}}}}}else{p[j+9794]=p[((N<<2)+38076>>2)+j]+4|0,p[j+9796]=q,he(a,q,1),Fa=q}}else{p[j+9794]=M,p[j+9796]=O,he(a,O,1),Fa=O}}while(0);m=o;return Fa}ae.X=1;function be(a){var c;c=a+2132|0;var d=Ad(p[c>>2],a+38076|0);c=p[c>>2]>>2;return(d|0)==(p[c+11]|0)?ce(p[c+2],p[c+7],p[c+9],d,p[a+(d<<2)+38076>>2]+1|0,273-d|0)+d|0:d}function ce(a,c,d,e,f,g){d=d-c|0;g=(g+e|0)>(d|0)?d-e|0:g;c=c+e|0;f=c-f|0;for(e=0;(e|0)<(g|0);){if(n[a+f+e|0]<<24>>24!=n[a+e+c|0]<<24>>24){break}e=e+1|0}return e}function he(a,c,d){var e=0<(c|0);a:do{if(e){for(var f=a+2132|0,g=d&1,h=c;;){if(h=h-1|0,0==(g&1)<<24>>24?Ad(p[f>>2],0):g=0,xd(p[f>>2]),0>=(h|0)){break a}}}}while(0)}function Qd(a){return Gd(2048-a|0)}function ee(a,c,d){c&=255;return Gd(p[a+(c<<4)+(d<<2)+392>>2])+Gd(p[a+(c<<2)+248>>2])|0}function ge(a,c,d,e){var d=d&255,f=x[a+(d<<2)+248>>2];0==(c|0)?a=Qd(p[a+(d<<4)+(e<<2)+392>>2])+Gd(f)|0:(e=Qd(f),f=p[a+(d<<2)+296>>2],a=1==(c|0)?Gd(f)+e|0:Qd(f)+e+Td((d<<2)+a+344|0,c-2|0)|0);return a}function ie(a,c,d,e){var f=0>(d|0)?-1:0,g=0>(e|0)?-1:0,h=(d>>>0)+4294967296*(f|0)+(a>>>0)+4294967296*(c|0)>>>0,c=Math.min(Math.floor(((d>>>0)+4294967296*(f|0)+(a>>>0)+4294967296*(c|0))/4294967296),4294967295),a=(h>>>0)+4294967296*(c|0)+(e>>>0)+4294967296*(g|0)>>>0,e=Math.min(Math.floor(((h>>>0)+4294967296*(c|0)+(e>>>0)+4294967296*(g|0))/4294967296),4294967295);return[a,e]}function je(a){for(var c=1,d=0,e=1;;){var f=0==(e&a|0)?d:c,c=c+1|0;if(32==(c|0)){break}d=f;e<<=1}return f}function ke(a){return 0==(n[a+56|0]&1)<<24>>24?0:(p[a+28>>2]|0)>=(p[a+36>>2]|0)}function le(a,c){var d=x[a>>2];p[a>>2]=p[Kc+((d&255^c&255)<<2)>>2]^d>>>8}function fe(a,c,d){return 128>(c|0)?p[a+(d<<9)+(c<<2)+171172>>2]:p[a+((c&15)<<2)+173220>>2]+p[((me(c)<<2)+a+170244>>2)+(58*d|0)]|0}function ne(a,c){var d=m;m+=20;var e=a+2132|0,f=p[e>>2],g=f|0,g=Wd(p[g>>2],p[g+4>>2],p[f+28>>2])[0]&3,f=a+2136|0,h=c|0;Cd(f,((n[h]&255)<<4)+(g<<2)+a+8|0,1);Cd(f,((n[h]&255)<<2)+a+200|0,0);oe(a,-1,2,g);Fd(f);Fd(f);Fd(f);Fd(f);Fd(f);g=p[a+4>>2]^-1;n[d|0]=g&255;n[d+1|0]=g>>>8&255;n[d+2|0]=g>>>16&255;n[d+3|0]=g>>>24&255;e=p[e>>2];g=e|0;g=Wd(p[g>>2],p[g+4>>2],p[e+28>>2]);e=g[0];g=g[1];n[d+4|0]=e&255;n[d+5|0]=(e>>>8|g<<24)&255;n[d+6|0]=(e>>>16|g<<16)&255;n[d+7|0]=(e>>>24|g<<8)&255;n[d+8|0]=g&255;n[d+9|0]=(g>>>8|0)&255;n[d+10|0]=(g>>>16|0)&255;n[d+11|0]=(g>>>24|0)&255;e=a+2144|0;g=ie(p[e>>2],p[e+4>>2],p[a+2156>>2],p[a+2164>>2]);e=g[0];h=g[1];g=20+(e>>>0)+4294967296*(h|0)>>>0;e=Math.min(Math.floor((20+(e>>>0)+4294967296*(h|0))/4294967296),4294967295);Lc(d,g,e);a:do{for(e=0;;){if(pe(f,n[d+e|0]),e=e+1|0,20==(e|0)){break a}}}while(0);Vd(f);m=d}ne.X=1;function pe(a,c){var d;d=(a+20|0)>>2;n[p[a+16>>2]+p[d]|0]=c;var e=p[d]+1|0;p[d]=e;65535<(e|0)&&Vd(a)}function qe(a,c,d,e){var f;p[a>>2]=0;p[a+4>>2]=-1;f=a+200|0;for(var g=a+8|0;!(T(g),g=g+4|0,(g|0)==(f|0));){}T(a+200|0);T(a+204|0);T(a+208|0);T(a+212|0);T(a+216|0);T(a+220|0);T(a+224|0);T(a+228|0);T(a+232|0);T(a+236|0);T(a+240|0);T(a+244|0);T(a+248|0);T(a+252|0);T(a+256|0);T(a+260|0);T(a+264|0);T(a+268|0);T(a+272|0);T(a+276|0);T(a+280|0);T(a+284|0);T(a+288|0);T(a+292|0);T(a+296|0);T(a+300|0);T(a+304|0);T(a+308|0);T(a+312|0);T(a+316|0);T(a+320|0);T(a+324|0);T(a+328|0);T(a+332|0);T(a+336|0);T(a+340|0);T(a+344|0);T(a+348|0);T(a+352|0);T(a+356|0);T(a+360|0);T(a+364|0);T(a+368|0);T(a+372|0);T(a+376|0);T(a+380|0);T(a+384|0);T(a+388|0);f=a+584|0;for(g=a+392|0;!(T(g),g=g+4|0,(g|0)==(f|0));){}f=a+1608|0;for(g=a+584|0;!(T(g),g=g+4|0,(g|0)==(f|0));){}f=a+2068|0;for(g=a+1608|0;!(T(g),g=g+4|0,(g|0)==(f|0));){}T(a+2068|0);T(a+2072|0);T(a+2076|0);T(a+2080|0);T(a+2084|0);T(a+2088|0);T(a+2092|0);T(a+2096|0);T(a+2100|0);T(a+2104|0);T(a+2108|0);T(a+2112|0);T(a+2116|0);T(a+2120|0);T(a+2124|0);T(a+2128|0);f=(a+2132|0)>>2;p[f]=c;c=a+2136|0;g=c|0;p[g>>2]=0;p[g+4>>2]=0;g=c+8|0;p[g>>2]=0;p[g+4>>2]=0;var g=c+16|0,h=sd(65536);p[g>>2]=h;p[c+20>>2]=0;p[c+24>>2]=-1;p[c+28>>2]=0;p[c+32>>2]=e;n[c+36|0]=0;re(a+2176|0,p[p[f]+44>>2]);re(a+7836|0,p[p[f]+44>>2]);g=a+13496|0;e=g+24576|0;for(g|=0;!(T(g),g=g+4|0,(g|0)==(e|0));){}p[(a+38072|0)>>2]=je(p[p[f]+20>>2]-1|0)<<1;e=a+170244|0;for(f=a+39172|0;!(n[f|0]=0,f=f+32|0,(f|0)==(e|0));){}Rd(a);for(a=0;6>(a|0);){pe(c,n[d+a|0]);a=a+1|0}}qe.X=1;function se(a,c,d){var e,f,g,h=m;m+=16;g=h>>2;var i=m;m+=1;m=m+3>>2<<2;var j=(c>>>0)+4294967296*(d|0)+ -16>>>0,o=Math.min(Math.floor(((c>>>0)+4294967296*(d|0)+ -16)/4294967296),4294967295),c=(a+2132|0)>>2,d=12<(p[p[c]+44>>2]|0);n[i|0]=0;p[g]=0;p[g+1]=0;p[g+2]=0;p[g+3]=0;g=(j>>>0)+4294967296*(o|0)-20>>>0;j=Math.min(Math.floor(((j>>>0)+4294967296*(o|0)-20)/4294967296),4294967295);d=d?512:2048;o=p[c];f=o|0;var u=p[o+28>>2];f=Wd(p[f>>2],p[f+4>>2],u);var q=0==f[0]&&0==f[1];a:do{if(q){var t=a+2136|0;f=(a+2144|0)>>2;var s=a+2156|0,B=a+2164|0,v=ie(p[f],p[f+1],p[s>>2],p[B>>2]);if(6==v[0]&&0==v[1]){if(ke(o)){var v=a+4|0,y=a+13496|0,A=i|0}else{v=n[p[o+8>>2]+u+0|0];A=i|0;Cd(t,((n[A]&255)<<4)+a+8|0,0);y=a+13496|0;Dd(t,y+0|0,v&255,8);var r=a+4|0;le(r,v);he(a,1,0);v=r}var r=h|0,D=a+7836|0,L=0;b:for(;;){if(ke(p[c])){ne(a,i);R=1;break a}1>(L|0)&&(Ud(a),L=d);var H=ae(a,r,i);if(1>(H|0)){R=0;break a}for(var L=L-H|0,P=0;;){var J=p[c],G=J|0,G=Wd(p[G>>2],p[G+4>>2],p[J+28>>2]),J=G[0],G=G[1],I=H,M=(J>>>0)+4294967296*(G|0)-((I>>>0)+0)>>>0;Math.min(Math.floor(((J>>>0)+4294967296*(G|0)-((I>>>0)+0))/4294967296),4294967295);var I=M&3,M=x[a+(P<<5)+39176>>2],J=x[a+(P<<5)+39184>>2],O=1==(J|0),N=0>(M|0)&O,G=w[A],Q=G&255;Cd(t,(Q<<4)+(I<<2)+a+8|0,N&1^1);e=x[c]>>2;if(N){O=H^-1;M=p[e+2];Q=p[e+7];I=n[M+Q+O|0];M=n[M+Q+(-H|0)|0];le(v,M);if(7>(G&255)){Dd(t,y+3072*((I&255)>>>5)|0,M&255,8)}else{Q=p[c];G=t;I=y+3072*((I&255)>>>5)|0;M&=255;e=n[p[Q+8>>2]+p[Q+28>>2]+(O-p[r>>2]|0)|0]&255;O=aa;Q=7;for(N=1;;){if(-1>=(Q|0)){O=7;break}var $=e>>>(Q>>>0)&1,ha=M>>>(Q>>>0)&1;Cd(G,(($<<8)+N+256<<2)+I|0,ha);var ba=ha|N<<1;if(($|0)!=(ha|0)){O=4;break}Q=Q-1|0;N=ba}c:do{if(4==O&&0<(Q|0)){e=ba;for(N=Q;;){N=N-1|0;$=M>>>(N>>>0)&1;Cd(G,(e<<2)+I|0,$);if(0>=(N|0)){break c}e=$|e<<1}}}while(0)}hd(i)}else{Jc(v,(p[e+2]+p[e+7]|0)+ -H|0,J),$d(M,r),G=4>(M|0),Cd(t,(Q<<2)+a+200|0,G&1),G?(G=0==(M|0),Cd(t,(Q<<2)+a+248|0,G&1^1),G?Cd(t,(Q<<4)+(I<<2)+a+392|0,1<(J|0)&1):(G=1<(M|0),Cd(t,(Q<<2)+a+296|0,G&1),G&&Cd(t,(Q<<2)+a+344|0,2<(M|0)&1)),O?id(i):(Bd(D,t,J,I),jd(i))):(oe(a,M-4|0,J,I),od(i))}G=H-J|0;H=ie(p[f],p[f+1],p[s>>2],p[B>>2]);I=H[1];if(!((I|0)<(j|0)||(I|0)==(j|0)&&H[0]>>>0<g>>>0)){break}if(1>(G|0)){continue b}P=J+P|0;H=G}ba=p[c];R=G;c=aa;0>(R|0)?ba=0:(c=ba+28|0,g=p[c>>2],(g|0)<(R|0)?ba=0:(p[c>>2]=g-R|0,c=(ba+32|0)>>2,R=p[c]-R|0,p[c]=R,0>(R|0)&&(p[c]=p[ba+20>>2]+R|0),ba=1));if(!ba){R=0;break a}ne(a,i);R=1;break a}}else{var R=0}}else{R=0}}while(0);m=h;return R}se.X=1;function oe(a,c,d,e){var f=a+2136|0;Bd(a+2176|0,f,d,e);e=me(c);Dd(f,(ld(d)<<8)+a+584|0,e,6);if(3<(e|0)){var d=e>>1,g=d-1|0,h=(e&1|2)<<g,c=c-h|0;if(14>(e|0)){te(f,(h-e<<2)+a+1608|0,c,g)}else{var e=c>>>4,d=d-5|0,i=0<(d|0);a:do{if(i){for(var h=(f+24|0)>>2,g=(f|0)>>2,j=d;;){var j=j-1|0,o=x[h],u=o>>>1;p[h]=u;if(0!=(1<<j&e|0)){var q=u,t=p[g],s=p[g+1],u=(t>>>0)+4294967296*(s|0)+(q>>>0)+0>>>0,q=Math.min(Math.floor(((t>>>0)+4294967296*(s|0)+(q>>>0)+0)/4294967296),4294967295);p[g]=u;p[g+1]=q}33554432>o>>>0&&(p[h]=o<<7&-256,Fd(f));if(0>=(j|0)){break a}}}}while(0);te(f,a+2068|0,c,4);f=a+173284|0;c=p[f>>2]-1|0;p[f>>2]=c;1>(c|0)&&Rd(a)}}}function me(a){return 4096>a>>>0?w[V+a|0]&255:8388608>a>>>0?(w[V+(a>>>11)|0]&255)+22|0:(w[V+(a>>>22)|0]&255)+44|0}function Gd(a){return p[ue+(a>>2<<2)>>2]}function re(a,c){T(a|0);T(a+4|0);T(a+8|0);T(a+12|0);T(a+16|0);T(a+20|0);T(a+24|0);T(a+28|0);T(a+32|0);T(a+36|0);T(a+40|0);T(a+44|0);T(a+48|0);T(a+52|0);T(a+56|0);T(a+60|0);T(a+64|0);T(a+68|0);T(a+72|0);T(a+76|0);T(a+80|0);T(a+84|0);T(a+88|0);T(a+92|0);T(a+96|0);T(a+100|0);T(a+104|0);T(a+108|0);T(a+112|0);T(a+116|0);T(a+120|0);T(a+124|0);T(a+128|0);T(a+132|0);T(a+136|0);T(a+140|0);T(a+144|0);T(a+148|0);T(a+152|0);T(a+156|0);T(a+160|0);T(a+164|0);T(a+168|0);T(a+172|0);T(a+176|0);T(a+180|0);T(a+184|0);T(a+188|0);T(a+192|0);T(a+196|0);T(a+200|0);T(a+204|0);T(a+208|0);T(a+212|0);T(a+216|0);T(a+220|0);T(a+224|0);T(a+228|0);T(a+232|0);T(a+236|0);T(a+240|0);T(a+244|0);T(a+248|0);T(a+252|0);T(a+256|0);T(a+260|0);for(var d=a+1288|0,e=a+264|0;!(T(e),e=e+4|0,(e|0)==(d|0));){}p[a+5640>>2]=c-1|0;Ed(a,0);Ed(a,1);Ed(a,2);Ed(a,3)}re.X=1;function Fd(a){var c,d;d=(a|0)>>2;var e=p[d],f=x[d+1];if((0>f>>>0||0==f>>>0&&4278190080>e>>>0)|1==(f|0)){e=a+36|0;pe(a,(w[e]&255)+f&255);c=(a+28|0)>>2;var g=0<(p[c]|0);a:do{if(g){for(var h=f+255&255;;){pe(a,h);var i=p[c]-1|0;p[c]=i;if(0>=(i|0)){break a}}}}while(0);f=x[d];a=x[d+1];n[e]=(f>>>24|a<<8)&255}else{a=a+28|0,p[a>>2]=p[a>>2]+1|0,a=f,f=e}p[d]=(f<<8|0)&-256;p[d+1]=(a<<8|f>>>24)&0}Fd.X=1;function te(a,c,d,e){var f=0<(e|0);a:do{if(f){for(var g=d,h=1,i=e;;){var j=g&1;Cd(a,(h<<2)+c|0,j);h=h<<1|j;i=i-1|0;if(0>=(i|0)){break a}g>>=1}}}while(0)}function Td(a,c){var d=p[a>>2];return 0==(c|0)?Gd(d):Qd(d)}function de(a,c,d){for(var e,f=7,g=1,h=0;;){if(-1>=(f|0)){var i=h;e=7;break}var j=d>>>(f>>>0)&1,o=c>>>(f>>>0)&1,u=Td(((j<<8)+g+256<<2)+a|0,o)+h|0,q=o|g<<1;if((j|0)!=(o|0)){e=4;break}f=f-1|0;g=q;h=u}a:do{if(4==e){if(0<(f|0)){g=u;d=q;for(h=f;;){h=h-1|0;j=c>>>(h>>>0)&1;g=Td((d<<2)+a|0,j)+g|0;if(0>=(h|0)){i=g;break a}d=j|d<<1}}else{i=u}}}while(0);return i}function Yc(a){0!=(a|0)&&Sc(p[p[ve>>2]+12>>2],a,Dc(a))}function we(a,c,d){if(-1<(p[xe>>2]|0)){if(0!=(a|0)&&0!=n[a]<<24>>24){ye(p[p[ve>>2]+12>>2],K.sa|0,(z=m,m+=8,p[z>>2]=K.i|0,p[z+4>>2]=a,z));if(0<(c|0)){var a=p[p[ve>>2]+12>>2],e;ze||(ze=nc(256));e=ze;if(c in Ae){if(255<Ae[c].length){W(Be)}else{for(var c=Ae[c],f=0;f<c.length;f++){n[e+f]=c.charCodeAt(f)}n[e+f]=0}}else{W(Ce)}e=ze;ye(a,K.S|0,(z=m,m+=4,p[z>>2]=e,z))}De(p[p[ve>>2]+12>>2])}a=p[Ee>>2];0!=(a|0)&d&&0!=n[a]<<24>>24&&ye(p[p[ve>>2]+12>>2],K.na|0,(z=m,m+=4,p[z>>2]=a,z))}}function yd(a){-1<(p[xe>>2]|0)&&ye(p[p[ve>>2]+12>>2],K.oa|0,(z=m,m+=8,p[z>>2]=K.i|0,p[z+4>>2]=a,z));Uc(3)}function Fe(a,c){var d=m;m+=8;p[d>>2]=8388608;p[d+4>>2]=36;p[Ee>>2]=p[c>>2];var e=1,f=0;a:for(;;){if((e|0)>=(a|0)){if(e=2==(f|0)){n[Ge]=0}else{if(0==(f|0)){n[V|0]=0;n[V+1|0]=1;n[V+2|0]=2;n[V+3|0]=3;C=1028;n[V+4|0]=C&255;C>>=8;n[(V+4|0)+1]=C&255;C=1285;n[V+6|0]=C&255;C>>=8;n[(V+6|0)+1]=C&255;C=101058054;n[V+8|0]=C&255;C>>=8;n[(V+8|0)+1]=C&255;C>>=8;n[(V+8|0)+2]=C&255;C>>=8;n[(V+8|0)+3]=C&255;C=117901063;n[V+12|0]=C&255;C>>=8;n[(V+12|0)+1]=C&255;C>>=8;n[(V+12|0)+2]=C&255;C>>=8;n[(V+12|0)+3]=C&255;var g=V+16|0,h=g|0;C=134744072;n[h]=C&255;C>>=8;n[h+1]=C&255;C>>=8;n[h+2]=C&255;C>>=8;n[h+3]=C&255;g=g+4|0;C=134744072;n[g]=C&255;C>>=8;n[g+1]=C&255;C>>=8;n[g+2]=C&255;C>>=8;n[g+3]=C&255;g=V+24|0;h=g|0;C=151587081;n[h]=C&255;C>>=8;n[h+1]=C&255;C>>=8;n[h+2]=C&255;C>>=8;n[h+3]=C&255;g=g+4|0;C=151587081;n[g]=C&255;C>>=8;n[g+1]=C&255;C>>=8;n[g+2]=C&255;C>>=8;n[g+3]=C&255;g=V+32|0;for(h=g+16;g<h;g++){n[g]=10}g=V+48|0;for(h=g+16;g<h;g++){n[g]=11}oc(V+64|0,12,32);oc(V+96|0,13,32);oc(V+128|0,14,64);oc(V+192|0,15,64);oc(V+256|0,16,128);oc(V+384|0,17,128);oc(V+512|0,18,256);oc(V+768|0,19,256);oc(V+1024|0,20,512);oc(V+1536|0,21,512);oc(V+2048|0,22,1024);oc(V+3072|0,23,1024);p[ue>>2]=704;for(var g=1,h=2,i=8;;){var j=(g|0)<(h|0);b:do{if(j){for(var o=i<<6,u=8-i|0,q=g;;){if(p[ue+(q<<2)>>2]=(h-q<<6>>u)+o|0,q=q+1|0,(q|0)==(h|0)){var t=h;break b}}}else{t=g}}while(0);if(0>=(i|0)){break}g=t;h<<=1;i=i-1|0}}}n[Ge]=1;t=f;g=aa;if(0==(t|0)&w[Ge]){if(0==(He(2)|0)){g=4}else{we(K.ha|0,0,1);var s=0,g=7}}else{g=4}4==g&&(2>(t-1|0)>>>0?0==(He(1)|0)?s=1:(we(K.ia|0,0,1),s=0):s=1);if(!s){g=1;break}f=0==(f|0)?Ie(d):Je(e);f=0<(f|0)?f:0;if(!w[Ge]){g=f;break}Ke[2]?(Ke[2].bb&&Le(Ke[2].bb),delete Ke[2],s=0):(W(Me),s=-1);if(0==(s|0)){g=f;break}we(K.ua|0,p[Pc>>2],0);if(1<=(f|0)){g=f;break}g=1;break}h=n[p[c+(e<<2)>>2]+1|0]<<24>>24;do{if(99==(h|0)||107==(h|0)){i=f}else{if(100==(h|0)){i=1}else{if(104==(h|0)){f=m;Ne(K.qa|0,(z=m,m+=4,p[z>>2]=K.p|0,z));Oe(K.ya|0);s=p[Ee>>2];Ne(K.ra|0,(z=m,m+=4,p[z>>2]=s,z));Oe(K.za|0);Oe(K.Ka|0);Oe(K.Ta|0);Oe(K.Ua|0);Oe(K.Va|0);Oe(K.Wa|0);Oe(K.Xa|0);Oe(K.Ya|0);Oe(K.Za|0);Oe(K.Aa|0);Oe(K.Ba|0);Oe(K.Ca|0);Oe(K.Da|0);Oe(K.Ea|0);Oe(K.Fa|0);Oe(K.Ga|0);Oe(K.Ha|0);Oe(K.Ia|0);Oe(K.Ja|0);Ne(K.va|0,(z=m,m+=4,p[z>>2]=K.i|0,z));Oe(K.La|0);Oe(K.Ma|0);Oe(K.Na|0);Oe(K.Oa|0);Oe(K.Pa|0);m=f;g=0;break a}else{if(113==(h|0)){p[xe>>2]=-1,i=f}else{if(118==(h|0)){i=p[xe>>2],4>(i|0)&&(p[xe>>2]=i+1|0),i=f}else{if(86==(h|0)){f=m;Ne(K.ja|0,(z=m,m+=8,p[z>>2]=K.p|0,p[z+4>>2]=K.ka|0,z));Ne(K.la|0,(z=m,m+=4,p[z>>2]=K.pa|0,z));Oe(K.Qa|0);Oe(K.Ra|0);Oe(K.Sa|0);m=f;g=0;break a}else{yd(K.ta|0),i=f}}}}}}}while(0);e=e+1|0;f=i}m=d;return g}Module._main=Fe;Fe.X=1;function Ie(a){var c=m;m+=173356;var d,e=c+8,f=c+68;C=1346984524;n[c]=C&255;C>>=8;n[c+1]=C&255;C>>=8;n[c+2]=C&255;C>>=8;n[c+3]=C&255;n[c+4|0]=1;d=Pe(c,p[a>>2]);a=a+4|0;if(d){if(d=x[a>>2],268<(d-5|0)>>>0){d=3}else{var g=d;d=4}}else{d=3}3==d&&(yd(K.ca|0),g=p[a>>2]);rd(e,Qe(n[c+5|0]),g,1);Pe(c,p[e+20>>2]);for(var g=e|0,a=e+28|0,h=0,i=0,j=0,o=0,u=0,q=0;;){qe(f,e,c,w[Ge]?2:-1);d=4294967295+2147483647*4294967296-((i>>>0)+4294967296*(h|0))>>>0;var t=Math.min(Math.floor((4294967295+2147483647*4294967296-((i>>>0)+4294967296*(h|0)))/4294967296),4294967295);if(!se(f,d,t)){Yc(K.da|0);var s=j,B=o,v=u,y=q,A=1;break}d=Wd(p[g>>2],p[g+4>>2],p[a>>2]);var t=d[0],r=d[1];d=(t>>>0)+4294967296*(r|0)+(q>>>0)+4294967296*(u|0)>>>0;u=Math.min(Math.floor(((t>>>0)+4294967296*(r|0)+(q>>>0)+4294967296*(u|0))/4294967296),4294967295);q=f+2144|0;q=ie(p[q>>2],p[q+4>>2],p[f+2156>>2],p[f+2164>>2]);q=[q[0],q[1]];t=q[0];r=q[1];q=(t>>>0)+4294967296*(r|0)+(o>>>0)+4294967296*(j|0)>>>0;j=Math.min(Math.floor(((t>>>0)+4294967296*(r|0)+(o>>>0)+4294967296*(j|0))/4294967296),4294967295);if(ke(e)){s=j;B=q;v=u;y=d;A=0;break}var o=(t>>>0)+4294967296*(r|0)+(i>>>0)+4294967296*(h|0)>>>0,h=Math.min(Math.floor(((t>>>0)+4294967296*(r|0)+(i>>>0)+4294967296*(h|0))/4294967296),4294967295),i=e,r=t=aa,r=(i+36|0)>>2,D=p[r],t=(i+28|0)>>2,L=p[t],H=D-L|0;0<(H|0)&&(D=p[i+8>>2],zd(D,D+L|0,H),L=p[t],D=p[r]);H=i|0;p[H>>2]=0;p[H+4>>2]=0;p[r]=D-L|0;p[t]=0;p[i+32>>2]=0;t=i+12|0;for(r=0;!(p[((r<<2)+p[t>>2]|0)>>2]=-1,r=r+1|0,1376256==(r|0));){}td(i);o=(i=2147483647<(h|0)||2147483647==(h|0)&&4294963198<o>>>0)?0:o;h=i?0:h;i=p[f+2152>>2];0!=(i|0)&&Re(i);i=o;o=q;q=d}f=p[f+2152>>2];0!=(f|0)&&Re(f);0==(A|0)&0<(p[xe>>2]|0)&&(f=p[p[ve>>2]+12>>2],(0>(v|0)||0==(v|0)&&1>y>>>0)|(0>(s|0)||0==(s|0)&&1>B>>>0)?Se(K.fa|0,20,1,f):(g=y+4294967296*v,a=B+4294967296*s,ye(f,K.ga|0,(z=m,m+=40,fc[0]=g/a,p[z>>2]=jc[0],p[z+4>>2]=jc[1],fc[0]=8*a/g,p[z+8>>2]=jc[0],p[z+12>>2]=jc[1],fc[0]=100*(1-a/g),p[z+16>>2]=jc[0],p[z+20>>2]=jc[1],p[z+24>>2]=y,p[z+28>>2]=v,p[z+32>>2]=B,p[z+36>>2]=s,z))));s=p[e+16>>2];0!=(s|0)&&Re(s);s=p[e+12>>2];0!=(s|0)&&Re(s);Le(p[e+8>>2]);m=c;return A}Ie.X=1;function Qe(a){var a=a&255,c=1<<(a&31);return 536866816>(c-4097|0)>>>0?c-c/16*(a>>>5)|0:c}function Te(a,c,d){var e=a+16|0,f=p[e>>2];0==(f|0)?(p[e>>2]=c,p[a+24>>2]=d,p[a+36>>2]=1):(f|0)==(c|0)?(a=a+24|0,2==(p[a>>2]|0)&&(p[a>>2]=d)):(d=a+36|0,p[d>>2]=p[d>>2]+1|0,p[a+24>>2]=2,n[a+54|0]=1)}function Ue(a,c,d,e){var f=a>>2;n[a+53|0]=1;d=(p[f+1]|0)==(d|0);do{if(d){n[a+52|0]=1;var g=a+16|0,h=p[g>>2];if(0==(h|0)){if(p[g>>2]=c,p[f+6]=e,p[f+9]=1,!(1==(p[f+12]|0)&1==(e|0))){break}}else{if((h|0)==(c|0)){if(g=a+24|0,h=p[g>>2],g=2==(h|0)?p[g>>2]=e:h,!(1==(p[f+12]|0)&1==(g|0))){break}}else{g=a+36|0,p[g>>2]=p[g>>2]+1|0}}n[a+54|0]=1}}while(0)}Ue.X=1;function Ve(a,c,d){(p[a+4>>2]|0)==(c|0)&&(a=a+28|0,1!=(p[a>>2]|0)&&(p[a>>2]=d))}function Je(a){var c=m;m+=88;var d,e=c+36,f=c+44,g=c>>2,h=c|0;p[h>>2]=0;p[h+4>>2]=0;var h=c+8|0,i=sd(16384);p[h>>2]=i;p[g+3]=0;p[g+4]=0;p[g+5]=0;p[g+6]=-1;p[g+7]=1;n[c+32|0]=0;for(var h=e+4|0,i=e+5|0,j=c|0,o=c+12|0,g=f+16|0,u=0,q=0,t=1;;){d=-p[c+12>>2]|0;var s=0>(d|0)?-1:0,B=c|0;p[B>>2]=d;p[B+4>>2]=s;for(d=0;6>(d|0);){if(Wc(c)){break}s=Xc(c);n[e+d|0]=s;d=d+1|0}if(Wc(c)){if(!t){d=41;break}Yc(K.wa|0);var v=1;d=45;break}a:{d=K.z|0;for(s=0;4>s;s++){var B=n[(e|0)+s],y=n[d+s];if(B!=y){d=B>y?1:-1;break a}}d=0}if(0!=(d|0)){if(!t){d=41;break}Yc(K.xa|0);v=2;d=45;break}s=w[h];if(2<=(s&255)){if(-1>=(p[xe>>2]|0)){v=2;d=45;break}Yc(0);v=s&255;ye(p[p[ve>>2]+12>>2],K.M|0,(z=m,m+=4,p[z>>2]=v,z));v=2;d=45;break}y=Qe(n[i]);if(536866816<(y-4096|0)>>>0){Yc(K.N|0);v=2;d=45;break}d=p[xe>>2];d=1<(d|0)?25:1!=(d|0)|t^1?27:25;if(25==d&&(Yc(0),1<(p[xe>>2]|0))){for(var t=p[p[ve>>2]+12>>2],B=0>(y|0)?-1:0,A=We|0,r=0;8>(r|0);){var D=-1<(B|0)||-1==(B|0)&&4294967295<y>>>0,L=0-((y>>>0)+4294967296*(B|0))>>>0,H=Math.min(Math.floor((0-((y>>>0)+4294967296*(B|0)))/4294967296),4294967295),L=D?y:L,D=D?B:H;if(!(0<(D|0)||0==(D|0)&&9999<L>>>0)){if(!((0<(D|0)||0==(D|0)&&1023<L>>>0)&(0==(y&1023)&&0==(B&0)))){break}}A=(Yb=((y>>>0)+4294967296*(B|0))/1024,0<=Yb?Math.floor(Yb):Math.ceil(Yb))>>>0;B=Math.min(Math.floor((Yb=((y>>>0)+4294967296*(B|0))/1024,0<=Yb?Math.floor(Yb):Math.ceil(Yb))/4294967296),4294967295);y=A;A=p[Xe+(r<<2)>>2];r=r+1|0}r=Ye|0;B=(z=m,m+=12,p[z>>2]=y,p[z+4>>2]=B,p[z+8>>2]=A,z);B=nf(K.ba|0,B);y=Math.min(B.length,15);for(A=0;A<y;A++){n[r+A]=B[A]}n[r+A]=0;s&=255;ye(t,K.P|0,(z=m,m+=8,p[z>>2]=s,p[z+4>>2]=Ye|0,z))}t=f;s=e;B=c;y=w[Ge]?2:-1;A=t>>2;r=t|0;p[r>>2]=0;p[r+4>>2]=0;D=Qe(n[s+5|0]);p[(t+8|0)>>2]=D;r=t+12|0;H=65536>(D|0)?65536:D;p[r>>2]=H;D=t+16|0;H=sd(-1<(H|0)?H:-1);p[D>>2]=H;p[A+5]=0;p[A+6]=0;p[A+7]=-1;p[A+8]=y;p[(t+36|0)>>2]=n[s+4|0]&255;p[A+10]=B;n[H+(p[r>>2]-1)|0]=0;s=Zc(f);t=Hc(p[j>>2],p[j+4>>2],p[o>>2]);B=t[0];y=t[1];t=(B>>>0)+4294967296*(y|0)+(q>>>0)+4294967296*(u|0)>>>0;u=Math.min(Math.floor(((B>>>0)+4294967296*(y|0)+(q>>>0)+4294967296*(u|0))/4294967296),4294967295);q=x[xe>>2];if(0!=(s|0)){-1<(q|0)&3>(s|0)&&(Yc(0),v=p[p[ve>>2]+12>>2],2==(s|0)?ye(v,K.Q|0,(z=m,m+=8,p[z>>2]=t,p[z+4>>2]=u,z)):ye(v,K.R|0,(z=m,m+=8,p[z>>2]=t,p[z+4>>2]=u,z)));v=p[g>>2];0!=(v|0)&&Re(v);v=2;d=45;break}1<(q|0)&&(q=p[p[ve>>2]+12>>2],a?Se(K.n|0,3,1,q):Se(K.o|0,5,1,q));q=p[g>>2];0!=(q|0)&&Re(q);q=t;t=0}41==d&&(1==(p[xe>>2]|0)&&(v=p[p[ve>>2]+12>>2],a?Se(K.n|0,3,1,v):Se(K.o|0,5,1,v)),v=0);a=p[c+8>>2];0!=(a|0)&&Re(a);m=c;return v}Je.X=1;function Pe(a,c){var d=536866817>(c-4096|0)>>>0;a:do{if(d){var e=je(c-1|0),f=a+5|0;n[f]=e&255;if(4096<(c|0)){for(var g=1<<(e&255),h=g/16|0,i=7;;){if(0>=(i|0)){e=1;break a}if((g-i*h|0)>=(c|0)){break}i=i-1|0}n[f]=(e|i<<5)&255}e=1}else{e=0}}while(0);return e}function of(a){pf(a|0)}function qf(a,c){var d,e=m;m+=56;d=e>>2;var f=p[a>>2],g=a+p[f-8>>2]|0,f=p[f-4>>2];p[d]=c;p[d+1]=a;p[d+2]=rf;p[d+3]=-1;for(var h=e+16|0,i=e+20|0,j=e+24|0,o=e+28|0,u=e+32|0,q=e+40|0,t=(f|0)==(c|0),s=h>>2,B=s+9;s<B;s++){p[s]=0}Rb[h+36>>1]=0;n[h+38]=0;do{if(t){p[d+12]=1,pc[p[p[f>>2]+12>>2]](f,e,g,g,1),s=1!=(p[j>>2]|0)?0:g}else{if(s=e+36|0,pc[p[p[f>>2]+16>>2]](f,e,g,1),s=p[s>>2],0==(s|0)){s=1!=(p[q>>2]|0)?0:1!=(p[o>>2]|0)?0:1!=(p[u>>2]|0)?0:p[i>>2]}else{if(1==(s|0)){if(1!=(p[j>>2]|0)){if(0!=(p[q>>2]|0)){s=0;break}if(1!=(p[o>>2]|0)){s=0;break}if(1!=(p[u>>2]|0)){s=0;break}}s=p[h>>2]}else{s=0}}}}while(0);m=e;return s}qf.X=1;function sf(a,c,d,e){var f=c>>2,g=a|0,h=(g|0)==(p[f+2]|0);a:do{if(h){Ve(c,d,e)}else{if((g|0)==(p[f]|0)){var i=(p[f+4]|0)==(d|0);do{if(!i){var j=c+20|0;if((p[j>>2]|0)!=(d|0)){p[f+8]=e;e=(c+44|0)>>2;if(4==(p[e]|0)){break a}g=c+52|0;n[g]=0;h=c+53|0;n[h]=0;a=p[a+8>>2];pc[p[p[a>>2]+12>>2]](a,c,d,d,1);if(0==(n[h]&1)<<24>>24){var o=0,a=11}else{0==(n[g]&1)<<24>>24?(o=1,a=11):a=15}b:do{if(11==a){p[j>>2]=d;a=c+40|0;p[a>>2]=p[a>>2]+1|0;g=1==(p[f+9]|0);do{if(g){if(2!=(p[f+6]|0)){a=14}else{n[c+54|0]=1;if(o){break b}a=16}}else{a=14}}while(0);if(!(14==a&&o)){p[e]=4;break a}}}while(0);p[e]=3;break a}}}while(0);1==(e|0)&&(p[f+8]=1)}else{j=p[a+8>>2],pc[p[p[j>>2]+16>>2]](j,c,d,e)}}}while(0)}sf.X=1;function nc(a){var c,d=245>a>>>0;do{if(d){var e=11>a>>>0?16:a+11&-8,f=e>>>3;c=x[X>>2];var g=c>>>(f>>>0);if(0!=(g&3|0)){var a=(g&1^1)+f|0,e=a<<1,d=(e<<2)+X+40|0,f=(e+2<<2)+X+40|0,h=x[f>>2],e=h+8|0,g=x[e>>2];(d|0)==(g|0)?p[X>>2]=c&(1<<a^-1):(g>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[f>>2]=g,p[g+12>>2]=d);c=a<<3;p[h+4>>2]=c|3;c=h+(c|4)|0;p[c>>2]|=1;h=e;c=38;break}if(e>>>0<=x[X+8>>2]>>>0){var i=e;c=30;break}if(0!=(g|0)){var a=2<<f,a=g<<f&(a|-a),d=(a&-a)-1|0,a=d>>>12&16,h=d>>>(a>>>0),d=h>>>5&8,f=h>>>(d>>>0),h=f>>>2&4,g=f>>>(h>>>0),f=g>>>1&2,g=g>>>(f>>>0),j=g>>>1&1,h=(d|a|h|f|j)+(g>>>(j>>>0))|0,a=h<<1,f=(a<<2)+X+40|0,g=(a+2<<2)+X+40|0,d=x[g>>2],a=d+8|0,j=x[a>>2];(f|0)==(j|0)?p[X>>2]=c&(1<<h^-1):(j>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[g>>2]=j,p[j+12>>2]=f);h<<=3;c=h-e|0;p[d+4>>2]=e|3;f=d;d=f+e|0;p[f+(e|4)>>2]=c|1;p[f+h>>2]=c;j=x[X+8>>2];0!=(j|0)&&(e=p[X+20>>2],f=j>>>2&1073741822,h=(f<<2)+X+40|0,g=x[X>>2],j=1<<(j>>>3),0==(g&j|0)?(p[X>>2]=g|j,g=h,f=(f+2<<2)+X+40|0):(f=(f+2<<2)+X+40|0,g=x[f>>2],g>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"))),p[f>>2]=e,p[g+12>>2]=e,p[(e+8|0)>>2]=g,p[(e+12|0)>>2]=h);p[X+8>>2]=c;p[X+20>>2]=d;h=a;c=38;break}if(0==(p[X+4>>2]|0)){i=e;c=30;break}c=tf(e);if(0==(c|0)){i=e;c=30;break}h=c}else{if(4294967231<a>>>0){i=-1;c=30;break}c=a+11&-8;if(0==(p[X+4>>2]|0)){i=c;c=30;break}e=uf(c);if(0==(e|0)){i=c;c=30;break}h=e}c=38}while(0);30==c&&(e=x[X+8>>2],i>>>0>e>>>0?(c=x[X+12>>2],i>>>0<c>>>0?(c=c-i|0,p[X+12>>2]=c,e=x[X+24>>2],p[X+24>>2]=e+i|0,p[i+(e+4)>>2]=c|1,p[e+4>>2]=i|3,h=e+8|0):h=vf(i)):(a=e-i|0,c=x[X+20>>2],15<a>>>0?(p[X+20>>2]=c+i|0,p[X+8>>2]=a,p[i+(c+4)>>2]=a|1,p[c+e>>2]=a,p[c+4>>2]=i|3):(p[X+8>>2]=0,p[X+20>>2]=0,p[c+4>>2]=e|3,i=e+(c+4)|0,p[i>>2]|=1),h=c+8|0));return h}Module._malloc=nc;nc.X=1;function tf(a){var c,d,e=p[X+4>>2],f=(e&-e)-1|0,e=f>>>12&16,g=f>>>(e>>>0),f=g>>>5&8;d=g>>>(f>>>0);var g=d>>>2&4,h=d>>>(g>>>0);d=h>>>1&2;var h=h>>>(d>>>0),i=h>>>1&1,e=f=x[X+((f|e|g|d|i)+(h>>>(i>>>0))<<2)+304>>2];d=e>>2;f=(p[f+4>>2]&-8)-a|0;a:for(;;){for(g=e;;){h=p[g+16>>2];if(0==(h|0)){if(g=p[g+20>>2],0==(g|0)){break a}}else{g=h}h=(p[g+4>>2]&-8)-a|0;if(h>>>0<f>>>0){e=g;d=e>>2;f=h;continue a}}}var h=e,j=x[X+16>>2],i=h>>>0<j>>>0;do{if(!i){var o=h+a|0,g=o;if(h>>>0<o>>>0){var i=x[d+6],o=x[d+3],u=(o|0)==(e|0);do{if(u){c=e+20|0;var q=p[c>>2];if(0==(q|0)&&(c=e+16|0,q=p[c>>2],0==(q|0))){q=0;c=q>>2;break}for(;;){var t=q+20|0,s=p[t>>2];if(0==(s|0)&&(t=q+16|0,s=x[t>>2],0==(s|0))){break}c=t;q=s}c>>>0<j>>>0&&(Z(),b("Reached an unreachable!"));p[c>>2]=0}else{c=x[d+2],c>>>0<j>>>0&&(Z(),b("Reached an unreachable!")),p[c+12>>2]=o,p[o+8>>2]=c,q=o}c=q>>2}while(0);j=0==(i|0);a:do{if(!j){o=e+28|0;u=(p[o>>2]<<2)+X+304|0;t=(e|0)==(p[u>>2]|0);do{if(t){p[u>>2]=q;if(0!=(q|0)){break}p[X+4>>2]&=1<<p[o>>2]^-1;break a}i>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));s=i+16|0;(p[s>>2]|0)==(e|0)?p[s>>2]=q:p[i+20>>2]=q;if(0==(q|0)){break a}}while(0);q>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[c+6]=i;o=x[d+4];0!=(o|0)&&(o>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+4]=o,p[o+24>>2]=q);o=x[d+5];0!=(o|0)&&(o>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+5]=o,p[o+24>>2]=q)}}while(0);16>f>>>0?(a=f+a|0,p[d+1]=a|3,a=a+(h+4)|0,p[a>>2]|=1):(p[d+1]=a|3,p[a+(h+4)>>2]=f|1,p[h+f+a>>2]=f,j=x[X+8>>2],0!=(j|0)&&(a=x[X+20>>2],h=j>>>2&1073741822,d=(h<<2)+X+40|0,i=x[X>>2],j=1<<(j>>>3),0==(i&j|0)?(p[X>>2]=i|j,i=d,h=(h+2<<2)+X+40|0):(h=(h+2<<2)+X+40|0,i=x[h>>2],i>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"))),p[h>>2]=a,p[i+12>>2]=a,p[a+8>>2]=i,p[a+12>>2]=d),p[X+8>>2]=f,p[X+20>>2]=g);return e+8|0}}}while(0);Z();b("Reached an unreachable!")}tf.X=1;function vf(a){var c,d;0==(p[wf>>2]|0)&&xf();var e=0==(p[X+440>>2]&4|0);do{if(e){d=p[X+24>>2];if(0==(d|0)){d=6}else{if(d=yf(d),0==(d|0)){d=6}else{var f=p[wf+8>>2],f=a+47-p[X+12>>2]+f&-f;if(2147483647>f>>>0){var g=zf(f);if((g|0)==(p[d>>2]+p[d+4>>2]|0)){var h=g,i=f;c=g;d=13}else{var j=g,o=f;d=15}}else{d=14}}}if(6==d){if(d=zf(0),-1==(d|0)){d=14}else{var f=p[wf+8>>2],f=f+(a+47)&-f,g=d,u=p[wf+4>>2],q=u-1|0,f=0==(q&g|0)?f:f-g+(q+g&-u)|0;2147483647>f>>>0?(g=zf(f),(g|0)==(d|0)?(h=d,i=f,c=g,d=13):(j=g,o=f,d=15)):d=14}}if(13==d){if(-1!=(h|0)){var t=i,s=h;d=26;break}j=c;o=i}else{if(14==d){p[X+440>>2]|=4;d=23;break}}d=-o|0;if(-1!=(j|0)&2147483647>o>>>0){if(o>>>0<(a+48|0)>>>0){f=p[wf+8>>2],f=a+47-o+f&-f,2147483647>f>>>0?-1==(zf(f)|0)?(zf(d),d=22):(B=f+o|0,d=21):(B=o,d=21)}else{var B=o;d=21}}else{B=o,d=21}21==d&&-1!=(j|0)?(t=B,s=j,d=26):(p[X+440>>2]|=4,d=23)}else{d=23}}while(0);23==d&&(e=p[wf+8>>2],e=e+(a+47)&-e,2147483647>e>>>0?(e=zf(e),h=zf(0),-1!=(h|0)&-1!=(e|0)&e>>>0<h>>>0?(h=h-e|0,h>>>0<=(a+40|0)>>>0|-1==(e|0)?d=49:(t=h,s=e,d=26)):d=49):d=49);a:do{if(26==d){e=p[X+432>>2]+t|0;p[X+432>>2]=e;e>>>0>x[X+436>>2]>>>0&&(p[X+436>>2]=e);e=x[X+24>>2];h=0==(e|0);b:do{if(h){i=x[X+16>>2];0==(i|0)|s>>>0<i>>>0&&(p[X+16>>2]=s);p[X+444>>2]=s;p[X+448>>2]=t;p[X+456>>2]=0;p[X+36>>2]=p[wf>>2];p[X+32>>2]=-1;for(i=0;!(c=i<<1,j=(c<<2)+X+40|0,p[X+(c+3<<2)+40>>2]=j,p[X+(c+2<<2)+40>>2]=j,i=i+1|0,32==(i|0));){}Af(s,t-40|0)}else{j=X+444|0;for(c=j>>2;0!=(j|0);){i=x[c];j=j+4|0;o=x[j>>2];B=i+o|0;if((s|0)==(B|0)){if(0!=(p[c+3]&8|0)){break}c=e;if(!(c>>>0>=i>>>0&c>>>0<B>>>0)){break}p[j>>2]=o+t|0;Af(p[X+24>>2],p[X+12>>2]+t|0);break b}j=p[c+2];c=j>>2}s>>>0<x[X+16>>2]>>>0&&(p[X+16>>2]=s);c=s+t|0;for(j=X+444|0;0!=(j|0);){o=j|0;i=x[o>>2];if((i|0)==(c|0)){if(0!=(p[j+12>>2]&8|0)){break}p[o>>2]=s;var v=j+4|0;p[v>>2]=p[v>>2]+t|0;v=Bf(s,i,a);d=50;break a}j=p[j+8>>2]}Cf(s,t)}}while(0);e=x[X+12>>2];e>>>0>a>>>0?(v=e-a|0,p[X+12>>2]=v,h=e=x[X+24>>2],p[X+24>>2]=h+a|0,p[a+(h+4)>>2]=v|1,p[e+4>>2]=a|3,v=e+8|0,d=50):d=49}}while(0);49==d&&(p[Pc>>2]=12,v=0);return v}vf.X=1;function uf(a){var c,d,e,f,g,h=a>>2,i=-a|0,j=a>>>8;if(0==(j|0)){var o=0}else{if(16777215<a>>>0){o=31}else{var u=(j+1048320|0)>>>16&8,q=j<<u,t=(q+520192|0)>>>16&4,s=q<<t,B=(s+245760|0)>>>16&2,v=14-(t|u|B)+(s<<B>>>15)|0,o=a>>>((v+7|0)>>>0)&1|v<<1}}var y=x[X+(o<<2)+304>>2],A=0==(y|0);a:do{if(A){var r=0,D=i,L=0}else{var H=31==(o|0)?0:25-(o>>>1)|0,P=0,J=i,G=y;g=G>>2;for(var I=a<<H,M=0;;){var O=p[g+1]&-8,N=O-a|0;if(N>>>0<J>>>0){if((O|0)==(a|0)){r=G;D=N;L=G;break a}var Q=G,$=N}else{Q=P,$=J}var ha=x[g+5],ba=x[((I>>>31<<2)+16>>2)+g],R=0==(ha|0)|(ha|0)==(ba|0)?M:ha;if(0==(ba|0)){r=Q;D=$;L=R;break a}P=Q;J=$;G=ba;g=G>>2;I<<=1;M=R}}}while(0);if(0==(L|0)&0==(r|0)){var Sa=2<<o,fa=p[X+4>>2]&(Sa|-Sa);if(0==(fa|0)){var U=L}else{var qa=(fa&-fa)-1|0,Aa=qa>>>12&16,da=qa>>>(Aa>>>0),Ea=da>>>5&8,ra=da>>>(Ea>>>0),pb=ra>>>2&4,bb=ra>>>(pb>>>0),Eb=bb>>>1&2,sa=bb>>>(Eb>>>0),Fa=sa>>>1&1,U=p[X+((Ea|Aa|pb|Eb|Fa)+(sa>>>(Fa>>>0))<<2)+304>>2]}}else{U=L}var Zb=0==(U|0);a:do{if(Zb){var ga=D,ta=r;f=ta>>2}else{var ia=U;e=ia>>2;for(var La=D,cb=r;;){var db=(p[e+1]&-8)-a|0,Fb=db>>>0<La>>>0,ja=Fb?db:La,rb=Fb?ia:cb,Ga=x[e+4];if(0!=(Ga|0)){ia=Ga}else{var sb=x[e+5];if(0==(sb|0)){ga=ja;ta=rb;f=ta>>2;break a}ia=sb}e=ia>>2;La=ja;cb=rb}}}while(0);var tb=0==(ta|0);a:do{if(tb){var Ta=0}else{if(ga>>>0<(p[X+8>>2]-a|0)>>>0){var Ma=ta;d=Ma>>2;var Ua=x[X+16>>2],ub=Ma>>>0<Ua>>>0;do{if(!ub){var eb=Ma+a|0,vb=eb;if(Ma>>>0<eb>>>0){var Na=x[f+6],Va=x[f+3],Nb=(Va|0)==(ta|0);do{if(Nb){var Gb=ta+20|0,Hb=p[Gb>>2];if(0==(Hb|0)){var Ib=ta+16|0,Wa=p[Ib>>2];if(0==(Wa|0)){var Y=0;c=Y>>2;break}var na=Ib,ka=Wa}else{na=Gb,ka=Hb}for(;;){var ua=ka+20|0,va=p[ua>>2];if(0!=(va|0)){na=ua,ka=va}else{var fb=ka+16|0,Oa=x[fb>>2];if(0==(Oa|0)){break}na=fb;ka=Oa}}na>>>0<Ua>>>0&&(Z(),b("Reached an unreachable!"));p[na>>2]=0;Y=ka}else{var gb=x[f+2];gb>>>0<Ua>>>0&&(Z(),b("Reached an unreachable!"));p[gb+12>>2]=Va;p[Va+8>>2]=gb;Y=Va}c=Y>>2}while(0);var Ob=0==(Na|0);b:do{if(!Ob){var S=ta+28|0,oa=(p[S>>2]<<2)+X+304|0,Xa=(ta|0)==(p[oa>>2]|0);do{if(Xa){p[oa>>2]=Y;if(0!=(Y|0)){break}p[X+4>>2]&=1<<p[S>>2]^-1;break b}Na>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));var la=Na+16|0;(p[la>>2]|0)==(ta|0)?p[la>>2]=Y:p[Na+20>>2]=Y;if(0==(Y|0)){break b}}while(0);Y>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[c+6]=Na;var wa=x[f+4];0!=(wa|0)&&(wa>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+4]=wa,p[wa+24>>2]=Y);var ma=x[f+5];0!=(ma|0)&&(ma>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+5]=ma,p[ma+24>>2]=Y)}}while(0);var Ya=16>ga>>>0;b:do{if(Ya){var Jb=ga+a|0;p[f+1]=Jb|3;var wb=Jb+(Ma+4)|0;p[wb>>2]|=1}else{if(p[f+1]=a|3,p[h+(d+1)]=ga|1,p[(ga>>2)+d+h]=ga,256>ga>>>0){var Za=ga>>>2&1073741822,Ha=(Za<<2)+X+40|0,Ia=x[X>>2],Pa=1<<(ga>>>3);if(0==(Ia&Pa|0)){p[X>>2]=Ia|Pa;var hb=Ha,ib=(Za+2<<2)+X+40|0}else{var Qa=(Za+2<<2)+X+40|0,xa=x[Qa>>2];xa>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));hb=xa;ib=Qa}p[ib>>2]=vb;p[hb+12>>2]=vb;p[h+(d+2)]=hb;p[h+(d+3)]=Ha}else{var Ja=eb,jb=ga>>>8;if(0==(jb|0)){var Ba=0}else{if(16777215<ga>>>0){Ba=31}else{var $a=(jb+1048320|0)>>>16&8,xb=jb<<$a,kb=(xb+520192|0)>>>16&4,yb=xb<<kb,Kb=(yb+245760|0)>>>16&2,Lb=14-(kb|$a|Kb)+(yb<<Kb>>>15)|0,Ba=ga>>>((Lb+7|0)>>>0)&1|Lb<<1}}var Pb=(Ba<<2)+X+304|0;p[h+(d+7)]=Ba;var Qb=a+(Ma+16)|0;p[h+(d+5)]=0;p[Qb>>2]=0;var Ka=p[X+4>>2],gc=1<<Ba;if(0==(Ka&gc|0)){p[X+4>>2]=Ka|gc,p[Pb>>2]=Ja,p[h+(d+6)]=Pb,p[h+(d+3)]=Ja,p[h+(d+2)]=Ja}else{for(var Tb=ga<<(31==(Ba|0)?0:25-(Ba>>>1)|0),lb=p[Pb>>2];;){if((p[lb+4>>2]&-8|0)==(ga|0)){var hc=lb+8|0,mb=x[hc>>2],Mb=x[X+16>>2],lc=lb>>>0<Mb>>>0;do{if(!lc&&mb>>>0>=Mb>>>0){p[mb+12>>2]=Ja;p[hc>>2]=Ja;p[h+(d+2)]=mb;p[h+(d+3)]=lb;p[h+(d+6)]=0;break b}}while(0);Z();b("Reached an unreachable!")}var $b=(Tb>>>31<<2)+lb+16|0,mc=x[$b>>2];if(0==(mc|0)){if($b>>>0>=x[X+16>>2]>>>0){p[$b>>2]=Ja;p[h+(d+6)]=lb;p[h+(d+3)]=Ja;p[h+(d+2)]=Ja;break b}Z();b("Reached an unreachable!")}Tb<<=1;lb=mc}}}}}while(0);Ta=ta+8|0;break a}}}while(0);Z();b("Reached an unreachable!")}Ta=0}}while(0);return Ta}uf.X=1;function Df(){var a;0==(p[wf>>2]|0)&&xf();var c=x[X+24>>2],d=0==(c|0);a:do{if(!d){var e=x[X+12>>2],f=40<e>>>0;do{if(f){var g=x[wf+8>>2],h=(Math.floor(((e-41+g|0)>>>0)/(g>>>0))-1)*g|0,i=yf(c);if(0==(p[i+12>>2]&8|0)){var j=zf(0);a=(i+4|0)>>2;if((j|0)==(p[i>>2]+p[a]|0)&&(h=zf(-(2147483646<h>>>0?-2147483648-g|0:h)|0),g=zf(0),-1!=(h|0)&g>>>0<j>>>0&&(h=j-g|0,(j|0)!=(g|0)))){p[a]=p[a]-h|0;p[X+432>>2]=p[X+432>>2]-h|0;Af(p[X+24>>2],p[X+12>>2]-h|0);break a}}}}while(0);x[X+12>>2]>>>0>x[X+28>>2]>>>0&&(p[X+28>>2]=-1)}}while(0)}Df.X=1;function Le(a){var c,d,e,f,g,h,i=a>>2,j,o=0==(a|0);a:do{if(!o){var u=a-8|0,q=u,t=x[X+16>>2],s=u>>>0<t>>>0;b:do{if(!s){var B=x[a-4>>2],v=B&3;if(1!=(v|0)){var y=B&-8;h=y>>2;var A=a+(y-8)|0,r=A,D=0==(B&1|0);c:do{if(D){var L=x[u>>2];if(0==(v|0)){break a}var H=-8-L|0;g=H>>2;var P=a+H|0,J=P,G=L+y|0;if(P>>>0<t>>>0){break b}if((J|0)==(p[X+20>>2]|0)){f=(a+(y-4)|0)>>2;if(3!=(p[f]&3|0)){var I=J;e=I>>2;var M=G;break}p[X+8>>2]=G;p[f]&=-2;p[g+(i+1)]=G|1;p[A>>2]=G;break a}if(256>L>>>0){var O=x[g+(i+2)],N=x[g+(i+3)];if((O|0)==(N|0)){p[X>>2]&=1<<(L>>>3)^-1,I=J,e=I>>2,M=G}else{var Q=((L>>>2&1073741822)<<2)+X+40|0,$=(O|0)!=(Q|0)&O>>>0<t>>>0;do{if(!$&&(N|0)==(Q|0)|N>>>0>=t>>>0){p[O+12>>2]=N;p[N+8>>2]=O;I=J;e=I>>2;M=G;break c}}while(0);Z();b("Reached an unreachable!")}}else{var ha=P,ba=x[g+(i+6)],R=x[g+(i+3)],Sa=(R|0)==(ha|0);do{if(Sa){var fa=H+(a+20)|0,U=p[fa>>2];if(0==(U|0)){var qa=H+(a+16)|0,Aa=p[qa>>2];if(0==(Aa|0)){var da=0;d=da>>2;break}var Ea=qa,ra=Aa}else{Ea=fa,ra=U,j=21}for(;;){var pb=ra+20|0,bb=p[pb>>2];if(0!=(bb|0)){Ea=pb,ra=bb}else{var Eb=ra+16|0,sa=x[Eb>>2];if(0==(sa|0)){break}Ea=Eb;ra=sa}}Ea>>>0<t>>>0&&(Z(),b("Reached an unreachable!"));p[Ea>>2]=0;da=ra}else{var Fa=x[g+(i+2)];Fa>>>0<t>>>0&&(Z(),b("Reached an unreachable!"));p[Fa+12>>2]=R;p[R+8>>2]=Fa;da=R}d=da>>2}while(0);if(0!=(ba|0)){var Zb=H+(a+28)|0,ga=(p[Zb>>2]<<2)+X+304|0,ta=(ha|0)==(p[ga>>2]|0);do{if(ta){p[ga>>2]=da;if(0!=(da|0)){break}p[X+4>>2]&=1<<p[Zb>>2]^-1;I=J;e=I>>2;M=G;break c}ba>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));var ia=ba+16|0;(p[ia>>2]|0)==(ha|0)?p[ia>>2]=da:p[ba+20>>2]=da;if(0==(da|0)){I=J;e=I>>2;M=G;break c}}while(0);da>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[d+6]=ba;var La=x[g+(i+4)];0!=(La|0)&&(La>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[d+4]=La,p[La+24>>2]=da);var cb=x[g+(i+5)];0!=(cb|0)&&(cb>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[d+5]=cb,p[cb+24>>2]=da)}I=J;e=I>>2;M=G}}else{I=q,e=I>>2,M=y}}while(0);var db=I;if(db>>>0<A>>>0){var Fb=a+(y-4)|0,ja=x[Fb>>2];if(0!=(ja&1|0)){var rb=0==(ja&2|0);do{if(rb){if((r|0)==(p[X+24>>2]|0)){var Ga=p[X+12>>2]+M|0;p[X+12>>2]=Ga;p[X+24>>2]=I;p[e+1]=Ga|1;(I|0)==(p[X+20>>2]|0)&&(p[X+20>>2]=0,p[X+8>>2]=0);if(Ga>>>0<=x[X+28>>2]>>>0){break a}Df();break a}if((r|0)==(p[X+20>>2]|0)){var sb=p[X+8>>2]+M|0;p[X+8>>2]=sb;p[X+20>>2]=I;p[e+1]=sb|1;p[(db+sb|0)>>2]=sb;break a}var tb=(ja&-8)+M|0,Ta=ja>>>3,Ma=256>ja>>>0;c:do{if(Ma){var Ua=x[i+h],ub=x[((y|4)>>2)+i];if((Ua|0)==(ub|0)){p[X>>2]&=1<<Ta^-1}else{var eb=((ja>>>2&1073741822)<<2)+X+40|0;j=(Ua|0)==(eb|0)?63:Ua>>>0<x[X+16>>2]>>>0?66:63;do{if(63==j&&!((ub|0)!=(eb|0)&&ub>>>0<x[X+16>>2]>>>0)){p[Ua+12>>2]=ub;p[ub+8>>2]=Ua;break c}}while(0);Z();b("Reached an unreachable!")}}else{var vb=A,Na=x[h+(i+4)],Va=x[((y|4)>>2)+i],Nb=(Va|0)==(vb|0);do{if(Nb){var Gb=y+(a+12)|0,Hb=p[Gb>>2];if(0==(Hb|0)){var Ib=y+(a+8)|0,Wa=p[Ib>>2];if(0==(Wa|0)){var Y=0;c=Y>>2;break}var na=Ib,ka=Wa}else{na=Gb,ka=Hb,j=73}for(;;){var ua=ka+20|0,va=p[ua>>2];if(0!=(va|0)){na=ua,ka=va}else{var fb=ka+16|0,Oa=x[fb>>2];if(0==(Oa|0)){break}na=fb;ka=Oa}}na>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[na>>2]=0;Y=ka}else{var gb=x[i+h];gb>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[gb+12>>2]=Va;p[Va+8>>2]=gb;Y=Va}c=Y>>2}while(0);if(0!=(Na|0)){var Ob=y+(a+20)|0,S=(p[Ob>>2]<<2)+X+304|0,oa=(vb|0)==(p[S>>2]|0);do{if(oa){p[S>>2]=Y;if(0!=(Y|0)){break}p[X+4>>2]&=1<<p[Ob>>2]^-1;break c}Na>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));var Xa=Na+16|0;(p[Xa>>2]|0)==(vb|0)?p[Xa>>2]=Y:p[Na+20>>2]=Y;if(0==(Y|0)){break c}}while(0);Y>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[c+6]=Na;var la=x[h+(i+2)];0!=(la|0)&&(la>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+4]=la,p[la+24>>2]=Y);var wa=x[h+(i+3)];0!=(wa|0)&&(wa>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[c+5]=wa,p[wa+24>>2]=Y)}}}while(0);p[e+1]=tb|1;p[db+tb>>2]=tb;if((I|0)!=(p[X+20>>2]|0)){var ma=tb}else{p[X+8>>2]=tb;break a}}else{p[Fb>>2]=ja&-2,p[e+1]=M|1,ma=p[db+M>>2]=M}}while(0);if(256>ma>>>0){var Ya=ma>>>2&1073741822,Jb=(Ya<<2)+X+40|0,wb=x[X>>2],Za=1<<(ma>>>3);if(0==(wb&Za|0)){p[X>>2]=wb|Za;var Ha=Jb,Ia=(Ya+2<<2)+X+40|0}else{var Pa=(Ya+2<<2)+X+40|0,hb=x[Pa>>2];hb>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));Ha=hb;Ia=Pa}p[Ia>>2]=I;p[Ha+12>>2]=I;p[e+2]=Ha;p[e+3]=Jb;break a}var ib=I,Qa=ma>>>8;if(0==(Qa|0)){var xa=0}else{if(16777215<ma>>>0){xa=31}else{var Ja=(Qa+1048320|0)>>>16&8,jb=Qa<<Ja,Ba=(jb+520192|0)>>>16&4,$a=jb<<Ba,xb=($a+245760|0)>>>16&2,kb=14-(Ba|Ja|xb)+($a<<xb>>>15)|0,xa=ma>>>((kb+7|0)>>>0)&1|kb<<1}}var yb=(xa<<2)+X+304|0;p[e+7]=xa;p[e+5]=0;p[e+4]=0;var Kb=p[X+4>>2],Lb=1<<xa,Pb=0==(Kb&Lb|0);c:do{if(Pb){p[X+4>>2]=Kb|Lb,p[yb>>2]=ib,p[e+6]=yb,p[e+3]=I,p[e+2]=I}else{for(var Qb=ma<<(31==(xa|0)?0:25-(xa>>>1)|0),Ka=p[yb>>2];;){if((p[Ka+4>>2]&-8|0)==(ma|0)){var gc=Ka+8|0,Tb=x[gc>>2],lb=x[X+16>>2],hc=Ka>>>0<lb>>>0;do{if(!hc&&Tb>>>0>=lb>>>0){p[Tb+12>>2]=ib;p[gc>>2]=ib;p[e+2]=Tb;p[e+3]=Ka;p[e+6]=0;break c}}while(0);Z();b("Reached an unreachable!")}var mb=(Qb>>>31<<2)+Ka+16|0,Mb=x[mb>>2];if(0==(Mb|0)){if(mb>>>0>=x[X+16>>2]>>>0){p[mb>>2]=ib;p[e+6]=Ka;p[e+3]=I;p[e+2]=I;break c}Z();b("Reached an unreachable!")}Qb<<=1;Ka=Mb}}}while(0);var lc=p[X+32>>2]-1|0;p[X+32>>2]=lc;if(0!=(lc|0)){break a}var $b=p[X+452>>2],mc=0==($b|0);c:do{if(!mc){for(var cd=$b;;){var Ab=p[cd+8>>2];if(0==(Ab|0)){break c}cd=Ab}}}while(0);p[X+32>>2]=-1;break a}}}}}while(0);Z();b("Reached an unreachable!")}}while(0)}Module._free=Le;Le.X=1;function yf(a){var c,d=X+444|0;for(c=d>>2;;){var e=x[c];if(e>>>0<=a>>>0&&(e+p[c+1]|0)>>>0>a>>>0){var f=d;break}c=x[c+2];if(0==(c|0)){f=0;break}d=c;c=d>>2}return f}function Af(a,c){var d=a+8|0,d=0==(d&7|0)?0:-d&7,e=c-d|0;p[X+24>>2]=a+d|0;p[X+12>>2]=e;p[d+(a+4)>>2]=e|1;p[c+(a+4)>>2]=40;p[X+28>>2]=p[wf+16>>2]}function ud(a,c){var d,e,f,g=4294967231<c>>>0;a:do{if(g){p[Pc>>2]=12;var h=0}else{f=d=a-8|0;e=(a-4|0)>>2;var i=x[e],j=i&-8,o=j-8|0,u=a+o|0,q=d>>>0<x[X+16>>2]>>>0;do{if(!q){var t=i&3;if(1!=(t|0)&-8<(o|0)&&(d=(a+(j-4)|0)>>2,0!=(p[d]&1|0))){g=11>c>>>0?16:c+11&-8;if(0==(t|0)){var s=0,B,i=p[f+4>>2]&-8;B=256>g>>>0?0:i>>>0>=(g+4|0)>>>0&&(i-g|0)>>>0<=p[wf+8>>2]<<1>>>0?f:0;f=17}else{j>>>0<g>>>0?(u|0)!=(p[X+24>>2]|0)?f=21:(d=p[X+12>>2]+j|0,d>>>0>g>>>0?(s=d-g|0,B=a+(g-8)|0,p[e]=g|i&1|2,p[a+(g-4)>>2]=s|1,p[X+24>>2]=B,p[X+12>>2]=s,s=0,B=f,f=17):f=21):(s=j-g|0,15<s>>>0?(p[e]=g|i&1|2,p[a+(g-4)>>2]=s|3,p[d]|=1,s=a+g|0):s=0,B=f,f=17)}do{if(17==f&&0!=(B|0)){0!=(s|0)&&Le(s);h=B+8|0;break a}}while(0);f=nc(c);if(0==(f|0)){h=0;break a}e=j-(0==(p[e]&3|0)?8:4)|0;qd(f,a,e>>>0<c>>>0?e:c);Le(a);h=f;break a}}}while(0);Z();b("Reached an unreachable!")}}while(0);return h}ud.X=1;function xf(){if(0==(p[wf>>2]|0)){var a=Ef();0==(a-1&a|0)?(p[wf+8>>2]=a,p[wf+4>>2]=a,p[wf+12>>2]=-1,p[wf+16>>2]=2097152,p[wf+20>>2]=0,p[X+440>>2]=0,p[wf>>2]=Math.floor(Date.now()/1e3)&-16^1431655768):(Z(),b("Reached an unreachable!"))}}function Bf(a,c,d){var e,f,g,h=c>>2,i=a>>2,j,o=a+8|0,o=0==(o&7|0)?0:-o&7;f=c+8|0;var u=0==(f&7|0)?0:-f&7;g=u>>2;var q=c+u|0,t=o+d|0;f=t>>2;var s=a+t|0,B=q-(a+o)-d|0;p[(o+4>>2)+i]=d|3;d=(q|0)==(p[X+24>>2]|0);a:do{if(d){var v=p[X+12>>2]+B|0;p[X+12>>2]=v;p[X+24>>2]=s;p[f+(i+1)]=v|1}else{if((q|0)==(p[X+20>>2]|0)){v=p[X+8>>2]+B|0,p[X+8>>2]=v,p[X+20>>2]=s,p[f+(i+1)]=v|1,p[(a+v+t|0)>>2]=v}else{var y=x[g+(h+1)];if(1==(y&3|0)){var v=y&-8,A=y>>>3,r=256>y>>>0;b:do{if(r){var D=x[((u|8)>>2)+h],L=x[g+(h+3)];if((D|0)==(L|0)){p[X>>2]&=1<<A^-1}else{var H=((y>>>2&1073741822)<<2)+X+40|0;j=(D|0)==(H|0)?15:D>>>0<x[X+16>>2]>>>0?18:15;do{if(15==j&&!((L|0)!=(H|0)&&L>>>0<x[X+16>>2]>>>0)){p[D+12>>2]=L;p[L+8>>2]=D;break b}}while(0);Z();b("Reached an unreachable!")}}else{j=q;D=x[((u|24)>>2)+h];L=x[g+(h+3)];H=(L|0)==(j|0);do{if(H){e=u|16;var P=e+(c+4)|0,J=p[P>>2];if(0==(J|0)){if(e=c+e|0,J=p[e>>2],0==(J|0)){J=0;e=J>>2;break}}else{e=P}for(;;){var P=J+20|0,G=p[P>>2];if(0==(G|0)&&(P=J+16|0,G=x[P>>2],0==(G|0))){break}e=P;J=G}e>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[e>>2]=0}else{e=x[((u|8)>>2)+h],e>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[e+12>>2]=L,p[L+8>>2]=e,J=L}e=J>>2}while(0);if(0!=(D|0)){L=u+(c+28)|0;H=(p[L>>2]<<2)+X+304|0;P=(j|0)==(p[H>>2]|0);do{if(P){p[H>>2]=J;if(0!=(J|0)){break}p[X+4>>2]&=1<<p[L>>2]^-1;break b}D>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));G=D+16|0;(p[G>>2]|0)==(j|0)?p[G>>2]=J:p[D+20>>2]=J;if(0==(J|0)){break b}}while(0);J>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"));p[e+6]=D;j=u|16;D=x[(j>>2)+h];0!=(D|0)&&(D>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[e+4]=D,p[D+24>>2]=J);j=x[(j+4>>2)+h];0!=(j|0)&&(j>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!")),p[e+5]=j,p[j+24>>2]=J)}}}while(0);y=c+(v|u)|0;v=v+B|0}else{y=q,v=B}y=y+4|0;p[y>>2]&=-2;p[f+(i+1)]=v|1;p[(v>>2)+i+f]=v;if(256>v>>>0){A=v>>>2&1073741822,y=(A<<2)+X+40|0,r=x[X>>2],v=1<<(v>>>3),0==(r&v|0)?(p[X>>2]=r|v,v=y,A=(A+2<<2)+X+40|0):(A=(A+2<<2)+X+40|0,v=x[A>>2],v>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"))),p[A>>2]=s,p[v+12>>2]=s,p[f+(i+2)]=v,p[f+(i+3)]=y}else{if(y=s,r=v>>>8,0==(r|0)?A=0:16777215<v>>>0?A=31:(A=(r+1048320|0)>>>16&8,j=r<<A,r=(j+520192|0)>>>16&4,j<<=r,D=(j+245760|0)>>>16&2,A=14-(r|A|D)+(j<<D>>>15)|0,A=v>>>((A+7|0)>>>0)&1|A<<1),r=(A<<2)+X+304|0,p[f+(i+7)]=A,j=t+(a+16)|0,p[f+(i+5)]=0,p[j>>2]=0,j=p[X+4>>2],D=1<<A,0==(j&D|0)){p[X+4>>2]=j|D,p[r>>2]=y,p[f+(i+6)]=r,p[f+(i+3)]=y,p[f+(i+2)]=y}else{A=v<<(31==(A|0)?0:25-(A>>>1)|0);for(r=p[r>>2];;){if((p[r+4>>2]&-8|0)==(v|0)){j=r+8|0;D=x[j>>2];L=x[X+16>>2];H=r>>>0<L>>>0;do{if(!H&&D>>>0>=L>>>0){p[D+12>>2]=y;p[j>>2]=y;p[f+(i+2)]=D;p[f+(i+3)]=r;p[f+(i+6)]=0;break a}}while(0);Z();b("Reached an unreachable!")}j=(A>>>31<<2)+r+16|0;D=x[j>>2];if(0==(D|0)){if(j>>>0>=x[X+16>>2]>>>0){p[j>>2]=y;p[f+(i+6)]=r;p[f+(i+3)]=y;p[f+(i+2)]=y;break a}Z();b("Reached an unreachable!")}A<<=1;r=D}}}}}}while(0);return a+(o|8)|0}Bf.X=1;function Re(a){0!=(a|0)&&Le(a)}function Ff(a){Gf(a|0)}function Cf(a,c){var d,e,f=x[X+24>>2];e=f>>2;var g=yf(f),h=p[g>>2];d=p[g+4>>2];var g=h+d|0,i=h+(d-39)|0,h=h+(d-47)+(0==(i&7|0)?0:-i&7)|0,h=h>>>0<(f+16|0)>>>0?f:h,i=h+8|0;d=i>>2;Af(a,c-40|0);p[(h+4|0)>>2]=27;p[d]=p[X+444>>2];p[d+1]=p[X+448>>2];p[d+2]=p[X+452>>2];p[d+3]=p[X+456>>2];p[X+444>>2]=a;p[X+448>>2]=c;p[X+456>>2]=0;p[X+452>>2]=i;d=h+28|0;p[d>>2]=7;i=(h+32|0)>>>0<g>>>0;a:do{if(i){for(var j=d;;){var o=j+4|0;p[o>>2]=7;if((j+8|0)>>>0>=g>>>0){break a}j=o}}}while(0);g=(h|0)==(f|0);a:do{if(!g){if(d=h-f|0,i=f+d|0,j=d+(f+4)|0,p[j>>2]&=-2,p[e+1]=d|1,p[i>>2]=d,256>d>>>0){j=d>>>2&1073741822,i=(j<<2)+X+40|0,o=x[X>>2],d=1<<(d>>>3),0==(o&d|0)?(p[X>>2]=o|d,d=i,j=(j+2<<2)+X+40|0):(j=(j+2<<2)+X+40|0,d=x[j>>2],d>>>0<x[X+16>>2]>>>0&&(Z(),b("Reached an unreachable!"))),p[j>>2]=f,p[d+12>>2]=f,p[e+2]=d,p[e+3]=i}else{i=f;o=d>>>8;if(0==(o|0)){j=0}else{if(16777215<d>>>0){j=31}else{var j=(o+1048320|0)>>>16&8,u=o<<j,o=(u+520192|0)>>>16&4,u=u<<o,q=(u+245760|0)>>>16&2,j=14-(o|j|q)+(u<<q>>>15)|0,j=d>>>((j+7|0)>>>0)&1|j<<1}}o=(j<<2)+X+304|0;p[e+7]=j;p[e+5]=0;p[e+4]=0;u=p[X+4>>2];q=1<<j;if(0==(u&q|0)){p[X+4>>2]=u|q,p[o>>2]=i,p[e+6]=o,p[e+3]=f,p[e+2]=f}else{j=d<<(31==(j|0)?0:25-(j>>>1)|0);for(o=p[o>>2];;){if((p[o+4>>2]&-8|0)==(d|0)){var u=o+8|0,q=x[u>>2],t=x[X+16>>2],s=o>>>0<t>>>0;do{if(!s&&q>>>0>=t>>>0){p[q+12>>2]=i;p[u>>2]=i;p[e+2]=q;p[e+3]=o;p[e+6]=0;break a}}while(0);Z();b("Reached an unreachable!")}u=(j>>>31<<2)+o+16|0;q=x[u>>2];if(0==(q|0)){if(u>>>0>=x[X+16>>2]>>>0){p[u>>2]=i;p[e+6]=o;p[e+3]=f;p[e+2]=f;break a}Z();b("Reached an unreachable!")}j<<=1;o=q}}}}}while(0)}Cf.X=1;function sd(a){for(a=0==(a|0)?1:a;;){var c=nc(a);if(0==(c|0)){c=(Xb=p[Hf>>2],p[Hf>>2]=Xb,Xb);if(0==(c|0)){var d=nc(4);p[d>>2]=If+8|0;vd(d,Jf,2);b("Reached an unreachable!")}pc[c]()}else{return c}}return ca}function W(a){Pc||(Pc=F([0],"i32",E));p[Pc>>2]=a}var Pc,Kf=13,Me=9,Ce=22,Lf=5,Mf=21,Nf=25,Of=6,Be=34,Pf=0,Qf=0,Rf=0,ve=0,Sf=2,Ke=[ca],Tf=k;function Uf(a,c){if("string"!==typeof a){return ca}c===aa&&(c="/");a&&"/"==a[0]&&(c="");for(var d=(c+"/"+a).split("/").reverse(),e=[""];d.length;){var f=d.pop();""==f||"."==f||(".."==f?1<e.length&&e.pop():e.push(f))}return 1==e.length?"/":e.join("/")}function Vf(a,c,d){var e={eb:l,k:l,error:0,name:ca,path:ca,object:ca,s:l,u:ca,t:ca},a=Uf(a);if("/"==a){e.eb=k,e.k=e.s=k,e.name="/",e.path=e.u="/",e.object=e.t=Wf}else{if(a!==ca){for(var d=d||0,a=a.slice(1).split("/"),f=Wf,g=[""];a.length;){1==a.length&&f.c&&(e.s=k,e.u=1==g.length?"/":g.join("/"),e.t=f,e.name=a[0]);var h=a.shift();if(f.c){if(f.v){if(!f.a.hasOwnProperty(h)){e.error=2;break}}else{e.error=Kf;break}}else{e.error=20;break}f=f.a[h];if(f.link&&!(c&&0==a.length)){if(40<d){e.error=40;break}e=Uf(f.link,g.join("/"));return Vf([e].concat(a).join("/"),c,d+1)}g.push(h);0==a.length&&(e.k=k,e.path=g.join("/"),e.object=f)}}}return e}function Xf(a){Yf();a=Vf(a,aa);if(a.k){return a.object}W(a.error);return ca}function Zf(a,c,d,e,f){a||(a="/");"string"===typeof a&&(a=Xf(a));a||(W(Kf),b(Error("Parent path must exist.")));a.c||(W(20),b(Error("Parent must be a folder.")));!a.write&&!Tf&&(W(Kf),b(Error("Parent folder must be writeable.")));if(!c||"."==c||".."==c){W(2),b(Error("Name must not be empty."))}a.a.hasOwnProperty(c)&&(W(17),b(Error("Can't overwrite object.")));a.a[c]={v:e===aa?k:e,write:f===aa?l:f,timestamp:Date.now(),cb:Sf++};for(var g in d){d.hasOwnProperty(g)&&(a.a[c][g]=d[g])}return a.a[c]}function $f(a,c){return Zf(a,c,{c:k,d:l,a:{}},k,k)}function ag(){var a="dev/shm/tmp",c=Xf("/");c===ca&&b(Error("Invalid parent."));for(a=a.split("/").reverse();a.length;){var d=a.pop();d&&(c.a.hasOwnProperty(d)||$f(c,d),c=c.a[d])}}function bg(a,c,d,e){!d&&!e&&b(Error("A device must have at least one callback defined."));var f={d:k,input:d,e:e};f.c=l;return Zf(a,c,f,Boolean(d),Boolean(e))}function Yf(){Wf||(Wf={v:k,write:k,c:k,d:l,timestamp:Date.now(),cb:1,a:{}})}function cg(){var a,c,d;function e(a){a===ca||10===a?(c.h(c.buffer.join("")),c.buffer=[]):c.buffer.push(String.fromCharCode(a))}qb(!dg,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");dg=k;Yf();a=a||Module.stdin;c=c||Module.stdout;d=d||Module.stderr;var f=k,g=k,h=k;a||(f=l,a=(function(){if(!a.j||!a.j.length){var c;"undefined"!=typeof window&&"function"==typeof window.prompt?c=window.prompt("Input: "):"function"==typeof readline&&(c=readline());c||(c="");a.j=uc(c+"\n",k)}return a.j.shift()}));c||(g=l,c=e);c.h||(c.h=print);c.buffer||(c.buffer=[]);d||(h=l,d=e);d.h||(d.h=print);d.buffer||(d.buffer=[]);$f("/","tmp");var i=$f("/","dev"),j=bg(i,"stdin",a),o=bg(i,"stdout",ca,c);d=bg(i,"stderr",ca,d);bg(i,"tty",a,c);Ke[1]={path:"/dev/stdin",object:j,position:0,f:k,g:l,r:l,m:!f,error:l,q:l,b:[]};Ke[2]={path:"/dev/stdout",object:o,position:0,f:l,g:k,r:l,m:!g,error:l,q:l,b:[]};Ke[3]={path:"/dev/stderr",object:d,position:0,f:l,g:k,r:l,m:!h,error:l,q:l,b:[]};Pf=F([1],"void*",E);Qf=F([2],"void*",E);Rf=F([3],"void*",E);ag();Ke[Pf]=Ke[1];Ke[Qf]=Ke[2];Ke[Rf]=Ke[3];ve=F([F([0,0,0,0,Pf,0,0,0,Qf,0,0,0,Rf,0,0,0],"void*",E)],"void*",E)}var dg,Wf;function eg(a,c,d,e){var f=Ke[a];if(!f||f.object.d){return W(Me),-1}if(f.f){if(f.object.c){return W(Mf),-1}if(0>d||0>e){return W(Ce),-1}for(a=0;f.b.length&&0<d;){n[c++]=f.b.pop(),d--,a++}for(var f=f.object.a,d=Math.min(f.length-e,d),g=0;g<d;g++){n[c+g]=f[e+g],a++}return a}W(Kf);return-1}function Qc(a,c,d){var e=Ke[a];if(e){if(e.f){if(0>d){return W(Ce),-1}if(e.object.d){if(e.object.input){for(a=0;e.b.length&&0<d;){n[c++]=e.b.pop(),d--,a++}for(var f=0;f<d;f++){try{var g=e.object.input()}catch(h){return W(Lf),-1}if(g===ca||g===aa){break}a++;n[c+f]=g}return a}W(Of);return-1}g=e.b.length;a=eg(a,c,d,e.position);-1!=a&&(e.position+=e.b.length-g+a);return a}W(Kf);return-1}W(Me);return-1}function Sc(a,c,d){var e=Ke[a];if(e){if(e.g){if(0>d){return W(Ce),-1}if(e.object.d){if(e.object.e){for(var f=0;f<d;f++){try{e.object.e(n[c+f])}catch(g){return W(Lf),-1}}e.object.timestamp=Date.now();return f}W(Of);return-1}f=e.position;a=Ke[a];if(!a||a.object.d){W(Me),c=-1}else{if(a.g){if(a.object.c){W(Mf),c=-1}else{if(0>d||0>f){W(Ce),c=-1}else{for(var h=a.object.a;h.length<f;){h.push(0)}for(var i=0;i<d;i++){h[f+i]=w[c+i]}a.object.timestamp=Date.now();c=i}}}else{W(Kf),c=-1}}-1!=c&&(e.position+=c);return c}W(Kf);return-1}W(Me);return-1}function Uc(a){yc(Bc);b("exit("+a+") called, at "+Error().stack)}function qd(a,c,d){if(20<=d&&c%2==a%2){if(c%4==a%4){for(d=c+d;c%4;){n[a++]=n[c++]}for(var c=c>>2,a=a>>2,e=d>>2;c<e;){p[a++]=p[c++]}c<<=2;for(a<<=2;c<d;){n[a++]=n[c++]}}else{d=c+d;c%2&&(n[a++]=n[c++]);c>>=1;a>>=1;for(e=d>>1;c<e;){Rb[a++]=Rb[c++]}c<<=1;a<<=1;c<d&&(n[a++]=n[c++])}}else{for(;d--;){n[a++]=n[c++]}}}function lg(){return!!lg.w}function vd(a,c,d){if(!mg){try{p[__ZTVN10__cxxabiv119__pointer_type_infoE>>2]=0}catch(e){}try{p[ng>>2]=1}catch(f){}try{p[og>>2]=2}catch(g){}mg=k}print("Compiled code throwing an exception, "+[a,c,d]+", at "+Error().stack);p[pg>>2]=a;p[pg+4>>2]=c;p[pg+8>>2]=d;"uncaught_exception"in lg?lg.w++:lg.w=1;b(a)}var mg;function zd(a,c,d){if(c<a&&a<c+d){c+=d;for(a+=d;d--;){a--,c--,n[a]=n[c]}}else{qd(a,c,d)}}function Se(a,c,d,e){c*=d;0!=c&&-1==Sc(e,a,c)&&Ke[e]&&(Ke[e].error=k)}function nf(a,c){function d(a){var d;"double"===a?d=(jc[0]=p[c+f>>2],jc[1]=p[c+f+4>>2],fc[0]):"i64"==a?d=[p[c+f>>2],p[c+f+4>>2]]:(a="i32",d=p[c+f>>2]);f+=Math.max(nb(a),ob);return d}for(var e=a,f=0,g=[],h,i;;){var j=e;h=n[e];if(0===h){break}i=n[e+1];if(37==h){var o=l,u=l,q=l,t=l;a:for(;;){switch(i){case 43:o=k;break;case 45:u=k;break;case 35:q=k;break;case 48:if(t){break a}else{t=k;break};default:break a}e++;i=n[e+1]}var s=0;if(42==i){s=d("i32"),e++,i=n[e+1]}else{for(;48<=i&&57>=i;){s=10*s+(i-48),e++,i=n[e+1]}}var B=l;if(46==i){var v=0,B=k;e++;i=n[e+1];if(42==i){v=d("i32"),e++}else{for(;;){i=n[e+1];if(48>i||57<i){break}v=10*v+(i-48);e++}}i=n[e+1]}else{v=6}var y;switch(String.fromCharCode(i)){case"h":i=n[e+2];104==i?(e++,y=1):y=2;break;case"l":i=n[e+2];108==i?(e++,y=8):y=4;break;case"L":case"q":case"j":y=8;break;case"z":case"t":case"I":y=4;break;default:y=ca}y&&e++;i=n[e+1];if(-1!="d,i,u,o,x,X,p".split(",").indexOf(String.fromCharCode(i))){j=100==i||105==i;y=y||4;h=d("i"+8*y);8==y&&(h=117==i?(h[0]>>>0)+4294967296*(h[1]>>>0):(h[0]>>>0)+4294967296*(h[1]|0));4>=y&&(h=(j?Gc:Fc)(h&Math.pow(256,y)-1,8*y));var A=Math.abs(h),r,j="";if(100==i||105==i){r=Gc(h,8*y).toString(10)}else{if(117==i){r=Fc(h,8*y).toString(10),h=Math.abs(h)}else{if(111==i){r=(q?"0":"")+A.toString(8)}else{if(120==i||88==i){j=q?"0x":"";if(0>h){h=-h;r=(A-1).toString(16);q=[];for(A=0;A<r.length;A++){q.push((15-parseInt(r[A],16)).toString(16))}for(r=q.join("");r.length<2*y;){r="f"+r}}else{r=A.toString(16)}88==i&&(j=j.toUpperCase(),r=r.toUpperCase())}else{112==i&&(0===A?r="(nil)":(j="0x",r=A.toString(16)))}}}}if(B){for(;r.length<v;){r="0"+r}}for(o&&(j=0>h?"-"+j:"+"+j);j.length+r.length<s;){u?r+=" ":t?r="0"+r:j=" "+j}r=j+r;r.split("").forEach((function(a){g.push(a.charCodeAt(0))}))}else{if(-1!="f,F,e,E,g,G".split(",").indexOf(String.fromCharCode(i))){h=d("double");if(isNaN(h)){r="nan",t=l}else{if(isFinite(h)){B=l;y=Math.min(v,20);if(103==i||71==i){B=k,v=v||1,y=parseInt(h.toExponential(y).split("e")[1],10),v>y&&-4<=y?(i=(103==i?"f":"F").charCodeAt(0),v-=y+1):(i=(103==i?"e":"E").charCodeAt(0),v--),y=Math.min(v,20)}if(101==i||69==i){r=h.toExponential(y),/[eE][-+]\d$/.test(r)&&(r=r.slice(0,-1)+"0"+r.slice(-1))}else{if(102==i||70==i){r=h.toFixed(y)}}j=r.split("e");if(B&&!q){for(;1<j[0].length&&-1!=j[0].indexOf(".")&&("0"==j[0].slice(-1)||"."==j[0].slice(-1));){j[0]=j[0].slice(0,-1)}}else{for(q&&-1==r.indexOf(".")&&(j[0]+=".");v>y++;){j[0]+="0"}}r=j[0]+(1<j.length?"e"+j[1]:"");69==i&&(r=r.toUpperCase());o&&0<=h&&(r="+"+r)}else{r=(0>h?"-":"")+"inf",t=l}}for(;r.length<s;){r=u?r+" ":t&&("-"==r[0]||"+"==r[0])?r[0]+"0"+r.slice(1):(t?"0":" ")+r}97>i&&(r=r.toUpperCase());r.split("").forEach((function(a){g.push(a.charCodeAt(0))}))}else{if(115==i){(o=d("i8*"))?(o=Ec(o),B&&o.length>v&&(o=o.slice(0,v))):o=uc("(null)",k);if(!u){for(;o.length<s--;){g.push(32)}}g=g.concat(o);if(u){for(;o.length<s--;){g.push(32)}}}else{if(99==i){for(u&&g.push(d("i8"));0<--s;){g.push(32)}u||g.push(d("i8"))}else{if(110==i){u=d("i32*"),p[u>>2]=g.length}else{if(37==i){g.push(h)}else{for(A=j;A<e+2;A++){g.push(n[A])}}}}}}}e+=2}else{g.push(h),e+=1}}return g}function ye(a,c,d){c=nf(c,d);d=m;Se(F(c,"i8",kc),1,c.length,a);m=d}var Ae={1:"Operation not permitted",2:"No such file or directory",3:"No such process",4:"Interrupted system call",5:"Input/output error",6:"No such device or address",8:"Exec format error",9:"Bad file descriptor",10:"No child processes",11:"Resource temporarily unavailable",12:"Cannot allocate memory",13:"Permission denied",14:"Bad address",16:"Device or resource busy",17:"File exists",18:"Invalid cross-device link",19:"No such device",20:"Not a directory",21:"Is a directory",22:"Invalid argument",23:"Too many open files in system",24:"Too many open files",25:"Inappropriate ioctl for device",26:"Text file busy",27:"File too large",28:"No space left on device",29:"Illegal seek",30:"Read-only file system",31:"Too many links",32:"Broken pipe",33:"Numerical argument out of domain",34:"Numerical result out of range",35:"Resource deadlock avoided",36:"File name too long",37:"No locks available",38:"Function not implemented",39:"Directory not empty",40:"Too many levels of symbolic links",42:"No message of desired type",43:"Identifier removed",60:"Device not a stream",61:"No data available",62:"Timer expired",63:"Out of streams resources",67:"Link has been severed",71:"Protocol error",72:"Multihop attempted",74:"Bad message",75:"Value too large for defined data type",84:"Invalid or incomplete multibyte or wide character",88:"Socket operation on non-socket",89:"Destination address required",90:"Message too long",91:"Protocol wrong type for socket",92:"Protocol not available",93:"Protocol not supported",95:"Operation not supported",97:"Address family not supported by protocol",98:"Address already in use",99:"Cannot assign requested address",100:"Network is down",101:"Network is unreachable",102:"Network dropped connection on reset",103:"Software caused connection abort",104:"Connection reset by peer",105:"No buffer space available",106:"Transport endpoint is already connected",107:"Transport endpoint is not connected",110:"Connection timed out",111:"Connection refused",113:"No route to host",114:"Operation already in progress",115:"Operation now in progress",116:"Stale NFS file handle",122:"Disk quota exceeded",125:"Operation canceled",130:"Owner died",131:"State not recoverable"},ze;function He(a){if(!Ke[a]){return W(Me),0}if(Ke[a].m){return 1}W(Nf);return 0}function oc(a,c,d){if(20<=d){for(d=a+d;a%4;){n[a++]=c}0>c&&(c+=256);for(var a=a>>2,e=d>>2,f=c|c<<8|c<<16|c<<24;a<e;){p[a++]=f}for(a<<=2;a<d;){n[a++]=c}}else{for(;d--;){n[a++]=c}}}function Ne(a,c){ye(p[Qf>>2],a,c)}var pf;function Z(){b("ABORT: undefined, at "+Error().stack)}function Ef(){switch(8){case 8:return qc;case 54:case 56:case 21:case 61:case 63:case 22:case 67:case 23:case 24:case 25:case 26:case 27:case 69:case 28:case 101:case 70:case 71:case 29:case 30:case 199:case 75:case 76:case 32:case 43:case 44:case 80:case 46:case 47:case 45:case 48:case 49:case 42:case 82:case 33:case 7:case 108:case 109:case 107:case 112:case 119:case 121:return 200809;case 13:case 104:case 94:case 95:case 34:case 35:case 77:case 81:case 83:case 84:case 85:case 86:case 87:case 88:case 89:case 90:case 91:case 94:case 95:case 110:case 111:case 113:case 114:case 115:case 116:case 117:case 118:case 120:case 40:case 16:case 79:case 19:return-1;case 92:case 93:case 5:case 72:case 6:case 74:case 92:case 93:case 96:case 97:case 98:case 99:case 102:case 103:case 105:return 1;case 38:case 66:case 50:case 51:case 4:return 1024;case 15:case 64:case 41:return 32;case 55:case 37:case 17:return 2147483647;case 18:case 1:return 47839;case 59:case 57:return 99;case 68:case 58:return 2048;case 0:return 2097152;case 3:return 65536;case 14:return 32768;case 73:return 32767;case 39:return 16384;case 60:return 1e3;case 106:return 700;case 52:return 256;case 62:return 255;case 2:return 100;case 65:return 64;case 36:return 20;case 100:return 16;case 20:return 6;case 53:return 4}W(Ce);return-1}function zf(a){qg||(Cb=Cb+4095>>12<<12,qg=k);var c=Cb;0!=a&&Bb(a);return c}var qg,Gf;function De(a){n[rg]=Fc(10);-1==Sc(a,rg,1)&&a in Ke&&(Ke[a].error=k)}function Oe(a){var c=p[Qf>>2];0>Sc(c,a,Dc(a))||De(c)}W(0);Ac.unshift({l:(function(){Tf=l;dg||cg()})});Bc.push({l:(function(){dg&&(Ke[2]&&0<Ke[2].object.e.buffer.length&&Ke[2].object.e(10),Ke[3]&&0<Ke[3].object.e.buffer.length&&Ke[3].object.e(10))})});var pg=F(12,"void*",E),rg=F([0],"i8",E);Module.ab=(function(a){function c(){for(var a=0;3>a;a++){e.push(0)}}var d=a.length+1,e=[F(uc("/bin/this.program"),"i8",E)];c();for(var f=0;f<d-1;f+=1){e.push(F(uc(a[f]),"i8",E)),c()}e.push(0);e=F(e,"i32",E);return Fe(d,e)});var Kc,Ac=Ac.concat([{l:(function(){for(var a=0;;){var c=a>>>1,c=0==(a&1|0)?c:c^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1,c=0==(c&1|0)?d:d^-306674912,d=c>>>1;p[Kc+(a<<2)>>2]=0==(c&1|0)?d:d^-306674912;a=a+1|0;if(256==(a|0)){break}}})}]),V,ue,wd,xe,Ee,Ge,Xe,Ye,We,rf,sg,ng,og,tg,X,wf,Hf,If,Jf;Kc=F(1024,"i32",E);K.L=F([82,97,110,103,101,32,100,101,99,111,100,101,114,32,102,105,110,97,108,32,99,111,100,101,32,105,115,32,110,111,116,32,122,101,114,111,0],"i8",E);K.K=F([7,7,7,7,7,7,7,10,10,10,10,10],"i8",E);K.I=F([8,8,8,8,8,8,8,11,11,11,11,11],"i8",E);K.H=F([9,9,9,9,9,9,9,11,11,11,11,11],"i8",E);K.J=F([0,0,0,0,1,2,3,4,5,6,4,5],"i8",E);V=F(4096,"i8",E);ue=F(2048,"i32",E);K.A=F([53,69,114,114,111,114,0],"i8",E);wd=F(8,"*",E);K.O=F([112,111,115,32,62,32,115,116,114,101,97,109,95,112,111,115,32,105,110,32,77,97,116,99,104,102,105,110,100,101,114,58,58,109,111,118,101,95,112,111,115,0],"i8",E);K.W=F([87,114,105,116,101,32,101,114,114,111,114,0],"i8",E);K.ea=F([82,101,97,100,32,101,114,114,111,114,0],"i8",E);xe=F(1,"i32",E);K.sa=F([37,115,58,32,37,115,0],"i8",E);K.S=F([58,32,37,115,0],"i8",E);Ee=F(1,"i8*",E);K.na=F([84,114,121,32,96,37,115,32,45,45,104,101,108,112,39,32,102,111,114,32,109,111,114,101,32,105,110,102,111,114,109,97,116,105,111,110,46,10,0],"i8",E);K.oa=F([37,115,58,32,105,110,116,101,114,110,97,108,32,101,114,114,111,114,58,32,37,115,46,10,0],"i8",E);K.ta=F([117,110,99,97,117,103,104,116,32,111,112,116,105,111,110,0],"i8",E);Ge=F(1,"i1",E);K.ua=F([67,97,110,39,116,32,99,108,111,115,101,32,115,116,100,111,117,116,0],"i8",E);K.wa=F([69,114,114,111,114,32,114,101,97,100,105,110,103,32,109,101,109,98,101,114,32,104,101,97,100,101,114,0],"i8",E);K.xa=F([66,97,100,32,109,97,103,105,99,32,110,117,109,98,101,114,32,40,102,105,108,101,32,110,111,116,32,105,110,32,108,122,105,112,32,102,111,114,109,97,116,41,0],"i8",E);K.M=F([86,101,114,115,105,111,110,32,37,100,32,109,101,109,98,101,114,32,102,111,114,109,97,116,32,110,111,116,32,115,117,112,112,111,114,116,101,100,46,10,0],"i8",E);K.N=F([73,110,118,97,108,105,100,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,105,110,32,109,101,109,98,101,114,32,104,101,97,100,101,114,0],"i8",E);K.P=F([118,101,114,115,105,111,110,32,37,100,44,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,37,55,115,66,46,32,32,0],"i8",E);K.Q=F([70,105,108,101,32,101,110,100,115,32,117,110,101,120,112,101,99,116,101,100,108,121,32,97,116,32,112,111,115,32,37,108,108,100,10,0],"i8",E);K.R=F([68,101,99,111,100,101,114,32,101,114,114,111,114,32,97,116,32,112,111,115,32,37,108,108,100,10,0],"i8",E);K.n=F([111,107,10,0],"i8",E);K.o=F([100,111,110,101,10,0],"i8",E);Xe=F(32,"*",E);K.T=F([75,105,0],"i8",E);K.U=F([77,105,0],"i8",E);K.V=F([71,105,0],"i8",E);K.Y=F([84,105,0],"i8",E);K.Z=F([69,105,0],"i8",E);K.$=F([90,105,0],"i8",E);K.aa=F([89,105,0],"i8",E);Ye=F(16,"i8",E);We=F(1,"i8",E);K.ba=F([37,108,108,100,32,37,115,0],"i8",E);K.z=F([76,90,73,80],"i8",E);K.ca=F([105,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,32,116,111,32,101,110,99,111,100,101,114,0],"i8",E);K.da=F([69,110,99,111,100,101,114,32,101,114,114,111,114,0],"i8",E);K.fa=F([78,111,32,100,97,116,97,32,99,111,109,112,114,101,115,115,101,100,46,10,0],"i8",E);K.ga=F([37,54,46,51,102,58,49,44,32,37,54,46,51,102,32,98,105,116,115,47,98,121,116,101,44,32,37,53,46,50,102,37,37,32,115,97,118,101,100,44,32,37,108,108,100,32,105,110,44,32,37,108,108,100,32,111,117,116,46,10,0],"i8",E);K.ha=F([73,32,119,111,110,39,116,32,119,114,105,116,101,32,99,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,116,111,32,97,32,116,101,114,109,105,110,97,108,46,0],"i8",E);K.ia=F([73,32,119,111,110,39,116,32,114,101,97,100,32,99,111,109,112,114,101,115,115,101,100,32,100,97,116,97,32,102,114,111,109,32,97,32,116,101,114,109,105,110,97,108,46,0],"i8",E);K.ja=F([37,115,32,37,115,10,0],"i8",E);K.ka=F([49,46,49,50,0],"i8",E);K.la=F([67,111,112,121,114,105,103,104,116,32,40,67,41,32,37,115,32,65,110,116,111,110,105,111,32,68,105,97,122,32,68,105,97,122,46,10,0],"i8",E);K.pa=F([50,48,49,49,0],"i8",E);K.p=F([76,122,105,112,0],"i8",E);K.qa=F([37,115,32,45,32,68,97,116,97,32,99,111,109,112,114,101,115,115,111,114,32,98,97,115,101,100,32,111,110,32,116,104,101,32,76,90,77,65,32,97,108,103,111,114,105,116,104,109,46,10,0],"i8",E);K.ra=F([10,85,115,97,103,101,58,32,37,115,32,91,111,112,116,105,111,110,115,93,32,91,102,105,108,101,115,93,10,0],"i8",E);K.va=F([73,102,32,110,111,32,102,105,108,101,32,110,97,109,101,115,32,97,114,101,32,103,105,118,101,110,44,32,37,115,32,99,111,109,112,114,101,115,115,101,115,32,111,114,32,100,101,99,111,109,112,114,101,115,115,101,115,10,0],"i8",E);K.i=F([108,122,105,112,0],"i8",E);K.B=F([78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0],"i8",E);rf=F(12,"*",E);K.C=F([78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0],"i8",E);sg=F(12,"*",E);ng=F([0,0,0,0,0,0,0,0,4,0,0,0,6,0,0,0,8,0,0,0,10,0,0,0,12,0,0,0,14,0,0,0],["*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0],E);F(1,"void*",E);K.F=F([80,105,0],"i8",E);og=F([0,0,0,0,0,0,0,0,4,0,0,0,16,0,0,0,8,0,0,0,18,0,0,0,20,0,0,0,22,0,0,0],["*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0],E);F(1,"void*",E);K.D=F([78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0],"i8",E);tg=F(12,"*",E);X=F(468,["i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"i32",0,0,0,"i32",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0,"*",0,0,0,"i32",0,0,0],E);wf=F(24,"i32",E);Hf=F(1,"void ()*",E);If=F([0,0,0,0,0,0,0,0,2,0,0,0,24,0,0,0,26,0,0,0],["*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0,"*",0,0,0],E);F(1,"void*",E);K.ma=F([115,116,100,58,58,98,97,100,95,97,108,108,111,99,0],"i8",E);K.G=F([83,116,57,98,97,100,95,97,108,108,111,99,0],"i8",E);Jf=F(12,"*",E);K.ya=F([60,60,32,77,111,115,116,32,111,102,32,116,104,101,115,101,32,97,114,101,32,117,110,115,117,112,112,111,114,116,101,100,46,32,67,111,109,112,114,101,115,115,105,110,103,47,100,101,99,111,109,112,114,101,115,115,105,110,103,32,102,114,111,109,32,115,116,100,105,110,32,116,111,32,115,116,100,111,117,116,32,105,115,32,116,104,101,32,114,105,103,104,116,32,119,97,121,33,32,62,62,0],"i8",E);K.za=F([10,79,112,116,105,111,110,115,58,0],"i8",E);K.Ka=F([32,32,45,104,44,32,45,45,104,101,108,112,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,100,105,115,112,108,97,121,32,116,104,105,115,32,104,101,108,112,32,97,110,100,32,101,120,105,116,0],"i8",E);K.Ta=F([32,32,45,86,44,32,45,45,118,101,114,115,105,111,110,32,32,32,32,32,32,32,32,32,32,32,32,32,32,111,117,116,112,117,116,32,118,101,114,115,105,111,110,32,105,110,102,111,114,109,97,116,105,111,110,32,97,110,100,32,101,120,105,116,0],"i8",E);K.Ua=F([32,32,45,98,44,32,45,45,109,101,109,98,101,114,45,115,105,122,101,61,60,110,62,32,32,32,32,32,32,115,101,116,32,109,101,109,98,101,114,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,0],"i8",E);K.Va=F([32,32,45,99,44,32,45,45,115,116,100,111,117,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,101,110,100,32,111,117,116,112,117,116,32,116,111,32,115,116,97,110,100,97,114,100,32,111,117,116,112,117,116,0],"i8",E);K.Wa=F([32,32,45,100,44,32,45,45,100,101,99,111,109,112,114,101,115,115,32,32,32,32,32,32,32,32,32,32,32,100,101,99,111,109,112,114,101,115,115,0],"i8",E);K.Xa=F([32,32,45,102,44,32,45,45,102,111,114,99,101,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,111,118,101,114,119,114,105,116,101,32,101,120,105,115,116,105,110,103,32,111,117,116,112,117,116,32,102,105,108,101,115,0],"i8",E);K.Ya=F([32,32,45,70,44,32,45,45,114,101,99,111,109,112,114,101,115,115,32,32,32,32,32,32,32,32,32,32,32,102,111,114,99,101,32,114,101,99,111,109,112,114,101,115,115,105,111,110,32,111,102,32,99,111,109,112,114,101,115,115,101,100,32,102,105,108,101,115,0],"i8",E);K.Za=F([32,32,45,107,44,32,45,45,107,101,101,112,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,107,101,101,112,32,40,100,111,110,39,116,32,100,101,108,101,116,101,41,32,105,110,112,117,116,32,102,105,108,101,115,0],"i8",E);K.Aa=F([32,32,45,109,44,32,45,45,109,97,116,99,104,45,108,101,110,103,116,104,61,60,110,62,32,32,32,32,32,115,101,116,32,109,97,116,99,104,32,108,101,110,103,116,104,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,32,91,51,54,93,0],"i8",E);K.Ba=F([32,32,45,111,44,32,45,45,111,117,116,112,117,116,61,60,102,105,108,101,62,32,32,32,32,32,32,32,32,105,102,32,114,101,97,100,105,110,103,32,115,116,100,105,110,44,32,112,108,97,99,101,32,116,104,101,32,111,117,116,112,117,116,32,105,110,116,111,32,60,102,105,108,101,62,0],"i8",E);K.Ca=F([32,32,45,113,44,32,45,45,113,117,105,101,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,117,112,112,114,101,115,115,32,97,108,108,32,109,101,115,115,97,103,101,115,0],"i8",E);K.Da=F([32,32,45,115,44,32,45,45,100,105,99,116,105,111,110,97,114,121,45,115,105,122,101,61,60,110,62,32,32,115,101,116,32,100,105,99,116,105,111,110,97,114,121,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,32,91,56,77,105,66,93,0],"i8",E);K.Ea=F([32,32,45,83,44,32,45,45,118,111,108,117,109,101,45,115,105,122,101,61,60,110,62,32,32,32,32,32,32,115,101,116,32,118,111,108,117,109,101,32,115,105,122,101,32,108,105,109,105,116,32,105,110,32,98,121,116,101,115,0],"i8",E);K.Fa=F([32,32,45,116,44,32,45,45,116,101,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,116,101,115,116,32,99,111,109,112,114,101,115,115,101,100,32,102,105,108,101,32,105,110,116,101,103,114,105,116,121,0],"i8",E);K.Ga=F([32,32,45,118,44,32,45,45,118,101,114,98,111,115,101,32,32,32,32,32,32,32,32,32,32,32,32,32,32,98,101,32,118,101,114,98,111,115,101,32,40,97,32,50,110,100,32,45,118,32,103,105,118,101,115,32,109,111,114,101,41,0],"i8",E);K.Ha=F([32,32,45,48,32,46,46,32,45,57,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,115,101,116,32,99,111,109,112,114,101,115,115,105,111,110,32,108,101,118,101,108,32,91,100,101,102,97,117,108,116,32,54,93,0],"i8",E);K.Ia=F([32,32,32,32,32,32,45,45,102,97,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,108,105,97,115,32,102,111,114,32,45,48,0],"i8",E);K.Ja=F([32,32,32,32,32,32,45,45,98,101,115,116,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,97,108,105,97,115,32,102,111,114,32,45,57,0],"i8",E);K.La=F([102,114,111,109,32,115,116,97,110,100,97,114,100,32,105,110,112,117,116,32,116,111,32,115,116,97,110,100,97,114,100,32,111,117,116,112,117,116,46,0],"i8",E);K.Ma=F([78,117,109,98,101,114,115,32,109,97,121,32,98,101,32,102,111,108,108,111,119,101,100,32,98,121,32,97,32,109,117,108,116,105,112,108,105,101,114,58,32,107,32,61,32,107,66,32,61,32,49,48,94,51,32,61,32,49,48,48,48,44,0],"i8",E);K.Na=F([75,105,32,61,32,75,105,66,32,61,32,50,94,49,48,32,61,32,49,48,50,52,44,32,77,32,61,32,49,48,94,54,44,32,77,105,32,61,32,50,94,50,48,44,32,71,32,61,32,49,48,94,57,44,32,71,105,32,61,32,50,94,51,48,44,32,101,116,99,46,46,46,0],"i8",E);K.Oa=F([10,82,101,112,111,114,116,32,98,117,103,115,32,116,111,32,108,122,105,112,45,98,117,103,64,110,111,110,103,110,117,46,111,114,103,0],"i8",E);K.Pa=F([76,122,105,112,32,104,111,109,101,32,112,97,103,101,58,32,104,116,116,112,58,47,47,119,119,119,46,110,111,110,103,110,117,46,111,114,103,47,108,122,105,112,47,108,122,105,112,46,104,116,109,108,0],"i8",E);K.Qa=F([76,105,99,101,110,115,101,32,71,80,76,118,51,43,58,32,71,78,85,32,71,80,76,32,118,101,114,115,105,111,110,32,51,32,111,114,32,108,97,116,101,114,32,60,104,116,116,112,58,47,47,103,110,117,46,111,114,103,47,108,105,99,101,110,115,101,115,47,103,112,108,46,104,116,109,108,62,0],"i8",E);K.Ra=F([84,104,105,115,32,105,115,32,102,114,101,101,32,115,111,102,116,119,97,114,101,58,32,121,111,117,32,97,114,101,32,102,114,101,101,32,116,111,32,99,104,97,110,103,101,32,97,110,100,32,114,101,100,105,115,116,114,105,98,117,116,101,32,105,116,46,0],"i8",E);K.Sa=F([84,104,101,114,101,32,105,115,32,78,79,32,87,65,82,82,65,78,84,89,44,32,116,111,32,116,104,101,32,101,120,116,101,110,116,32,112,101,114,109,105,116,116,101,100,32,98,121,32,108,97,119,46,0],"i8",E);p[wd>>2]=ng+8|0;p[wd+4>>2]=K.A|0;p[Xe>>2]=K.T|0;p[Xe+4>>2]=K.U|0;p[Xe+8>>2]=K.V|0;p[Xe+12>>2]=K.Y|0;p[Xe+16>>2]=K.F|0;p[Xe+20>>2]=K.Z|0;p[Xe+24>>2]=K.$|0;p[Xe+28>>2]=K.aa|0;p[rf>>2]=og+8|0;p[rf+4>>2]=K.B|0;p[rf+8>>2]=aa;p[sg>>2]=og+8|0;p[sg+4>>2]=K.C|0;p[sg+8>>2]=rf;p[ng+4>>2]=sg;p[og+4>>2]=tg;p[tg>>2]=og+8|0;p[tg+4>>2]=K.D|0;p[tg+8>>2]=sg;p[If+4>>2]=Jf;p[Jf>>2]=og+8|0;p[Jf+4>>2]=K.G|0;p[Jf+8>>2]=aa;pc=[0,0,Ff,0,of,0,(function(a){of(a|0);Re(a)}),0,(function(a,c,d){var e,f=m;m+=56;e=f>>2;if((a|0)==(c|0)){a=1}else{if(0==(c|0)){a=0}else{if(c=qf(c,sg),0==(c|0)){a=0}else{for(var g=f>>2,h=g+14;g<h;g++){p[g]=0}p[e]=c;p[e+2]=a;p[e+3]=-1;p[e+12]=1;pc[p[p[c>>2]+20>>2]](c,f,p[d>>2],1);1!=(p[e+6]|0)?a=0:(p[d>>2]=p[e+4],a=1)}}}m=f;return a}),0,(function(a,c,d,e,f){(p[c+8>>2]|0)==(a|0)&&Ue(c,d,e,f)}),0,(function(a,c,d,e){var f=c>>2,g=(p[f+2]|0)==(a|0);a:do{if(g){Ve(c,d,e)}else{if((p[f]|0)==(a|0)){var h=(p[f+4]|0)==(d|0);do{if(!h){var i=c+20|0;if((p[i>>2]|0)!=(d|0)){p[f+8]=e;p[i>>2]=d;a=c+40|0;p[a>>2]=p[a>>2]+1|0;1==(p[f+9]|0)&&2==(p[f+6]|0)&&(n[c+54|0]=1);p[f+11]=4;break a}}}while(0);1==(e|0)&&(p[f+8]=1)}}}while(0)}),0,(function(a,c,d,e){(p[c+8>>2]|0)==(a|0)&&Te(c,d,e)}),0,(function(a){of(a|0);Re(a)}),0,(function(a,c,d,e,f){(a|0)==(p[c+8>>2]|0)?Ue(c,d,e,f):(a=p[a+8>>2],pc[p[p[a>>2]+12>>2]](a,c,d,e,f))}),0,sf,0,(function(a,c,d,e){(a|0)==(p[c+8>>2]|0)?Te(c,d,e):(a=p[a+8>>2],pc[p[p[a>>2]+20>>2]](a,c,d,e))}),0,(function(a){Ff(a);Re(a)}),0,(function(){return K.ma|0}),0];Module.FUNCTION_TABLE=pc;function ug(a){a=a||Module.arguments;yc(Ac);var c=ca;Module._main&&(c=Module.ab(a),Module.noExitRuntime||yc(Bc));return c}Module.run=ug;Module.preRun&&Module.preRun();Module.noInitialRun||ug();Module.postRun&&Module.postRun() + + return returnValue; + }, + + compress: function(data) { + return this.run(data); + }, + + decompress: function(data) { + return this.run(data, true); + } +}; + diff --git a/third_party/lzma.js/native_test.sh b/third_party/lzma.js/native_test.sh new file mode 100755 index 00000000..63652340 --- /dev/null +++ b/third_party/lzma.js/native_test.sh @@ -0,0 +1,5 @@ +./lzma-native < lzma-native > lzma-native.lz +./lzma-native -d < lzma-native.lz > lzma-native.post +ls -al lzma-native* +diff lzma-native lzma-native.post + diff --git a/third_party/lzma.js/post.js b/third_party/lzma.js/post.js new file mode 100644 index 00000000..c000e810 --- /dev/null +++ b/third_party/lzma.js/post.js @@ -0,0 +1,13 @@ + + return returnValue; + }, + + compress: function(data) { + return this.run(data); + }, + + decompress: function(data) { + return this.run(data, true); + } +}; + diff --git a/third_party/lzma.js/pre.js b/third_party/lzma.js/pre.js new file mode 100644 index 00000000..c2ec08c6 --- /dev/null +++ b/third_party/lzma.js/pre.js @@ -0,0 +1,13 @@ + +// This is lzma.js, powered by lzip (which is GPL, source code at https://github.com/kripken/lzma.js) +var LZMA = { + run: function(data, decompress) { + var inputIndex = 0; + var returnValue = []; + var Module = { + arguments: ['-q'].concat(decompress ? ['-d'] : []), + stdin: function() { return inputIndex < data.length ? data[inputIndex++] : null }, + stdout: function(x) { if (x !== null) returnValue.push(x) } + }; + + diff --git a/third_party/lzma.js/test-decoder.js b/third_party/lzma.js/test-decoder.js new file mode 100644 index 00000000..4860c3de --- /dev/null +++ b/third_party/lzma.js/test-decoder.js @@ -0,0 +1,39 @@ +// js -m -n -e "load('lzma-decoder.js')" test-decoder.js + +function assertEq(a, b) { + if (a !== b) { + throw 'Should have been equal: ' + a + ' : ' + b; + } + return false; +} + +function assertNeq(a, b) { + try { + assertEq(a, b); + } catch(e) { + return; + } + throw 'Should have not been equal: ' + a + ' : ' + b; +} + +function byteCompare(a, b) { + assertEq(JSON.stringify(new Uint8Array(a)), JSON.stringify(new Uint8Array(b))); +} + +function testSimple() { + print('testing simple..'); + var data = [100, 200, 200, 200, 200, 200, 200, 100, 100, 200, 200, 200, 200, 0, 1]; + var compressed = [76,90,73,80,1,12,0,50,50,28,-1,-1,-1,-1,-16,0,0,0,-34,-10,-9,-43,2,0,0,0,0,0,0,0,38,0,0,0,0,0, + 0,0,76,90,73,80,1,12,0,100,105,61,-1,-1,-1,-1,-32,0,0,0,-46,66,-98,-91,5,0,0,0,0,0,0,0,38, + 0,0,0,0,0,0,0,76,90,73,80,1,12,0,50,100,27,-1,-1,-1,-2,0,0,0,29,25,-105,10,2,0,0,0,0,0,0,0, + 37,0,0,0,0,0,0,0,76,90,73,80,1,12,0,100,104,-67,-1,-1,-1,-1,-32,0,0,0,-55,-55,-99,-101,4,0,0,0, + 0,0,0,0,38,0,0,0,0,0,0,0,76,90,73,80,1,12,0,0,0,121,-128,-83,-1,-1,-20,-57,0,0,105,34,-34,54,2, + 0,0,0,0,0,0,0,38,0,0,0,0,0,0,0]; + var decompressed = LZMA.decompress(compressed); + byteCompare(data, decompressed); +} + +testSimple(); + +print('ok.'); + diff --git a/third_party/lzma.js/test-full.html b/third_party/lzma.js/test-full.html new file mode 100644 index 00000000..64d2be60 --- /dev/null +++ b/third_party/lzma.js/test-full.html @@ -0,0 +1,9 @@ +<body> +<script> + var print = function(x) { console.log(x) }; +</script> +<script src="lzma-full.js"></script> +<script src="test-full.js"></script> +See web console.. +</body> + diff --git a/third_party/lzma.js/test-full.js b/third_party/lzma.js/test-full.js new file mode 100644 index 00000000..c31e6e3a --- /dev/null +++ b/third_party/lzma.js/test-full.js @@ -0,0 +1,78 @@ +// js -m -n -e "load('lzma-full.js')" test-full.js + +function assertEq(a, b) { + if (a !== b) { + throw 'Should have been equal: ' + a + ' : ' + b; + } + return false; +} + +function assertNeq(a, b) { + try { + assertEq(a, b); + } catch(e) { + return; + } + throw 'Should have not been equal: ' + a + ' : ' + b; +} + +function byteCompare(a, b) { + assertEq(a.length, b.length); + for (var i = 0; i < a.length; i++) { + assertEq(a[i]&255, b[i]&255); + } +} + +function testSimple() { + print('testing simple..'); + var data = [100, 200, 200, 200, 200, 200, 200, 100, 100, 200, 200, 200, 200, 0, 1]; + var compressed = LZMA.compress(data); + var decompressed = LZMA.decompress(compressed); + + byteCompare(data, decompressed); + assertNeq(data.length, compressed.length); +} + +function testBig() { + print('testing big..'); + var seed1 = 100; + var seed2 = 200; + var last = 255; + function fakeRandom() { + // numbers from http://triptico.com/docs/sp_random.html + seed1 = ((seed1 * 58321) + 11113) | 0; + var ret = (seed1 >> 16) & 255; + seed2 = ((seed2 * 58321) + 11113) | 0; + if (seed2 % 5) { + return last; + } + last = ret; + return last; + } + print(' ..generating data..'); + var size = 1*1024*1024; + var data = new Array(size); + for (var i = 0; i < size; i++) { + data[i] = fakeRandom(); + } + + print(' ..compressing ' + data.length + ' bytes..'); + var t = Date.now(); + var compressed = LZMA.compress(data); + print(' ..took ' + ((Date.now() - t)/1000).toFixed(2) + ' secs'); + print(' ..decompressing ' + compressed.length + ' bytes..'); + t = Date.now(); + var decompressed = LZMA.decompress(compressed); + print(' ..took ' + ((Date.now() - t)/1000).toFixed(2) + ' secs'); + print(' ..got ' + decompressed.length + ' bytes..'); + + byteCompare(data, decompressed); + assertNeq(data.length, compressed.length); + print(' ..decompressed == original'); +} + +testSimple(); +testBig(); + +print('ok.'); + |