# NOTICE

NOGAR is distributed in binary form under the NOGAR Software License Agreement
(see `LICENSE.txt`). It reproduces the on-disk output of
several third-party Android tools byte-for-byte, and in doing so ports or
derives logic from their source code. This file records that provenance and
the license terms that attach to it.

## smali / baksmali / dexlib2 — BSD-3-Clause

Copyright (c) 2010 Ben Gruver (JesusFreke). All rights reserved.
Project: https://github.com/google/smali (`com.android.tools.smali`, v3.0.9)

> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
> 1. Redistributions of source code must retain the above copyright notice,
>    this list of conditions and the following disclaimer.
> 2. Redistributions in binary form must reproduce the above copyright notice,
>    this list of conditions and the following disclaimer in the documentation
>    and/or other materials provided with the distribution.
> 3. The name of the author may not be used to endorse or promote products
>    derived from this software without specific prior written permission.
>
> THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
> WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
> EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
> PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
> OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
> WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
> OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
> ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Some later contributions to the same upstream project are copyrighted by
Google LLC (2011-) under an equivalent 3-clause license; the port here targets
the original Ben Gruver code paths (baksmali's dump/writer/smali internals).

Files in this repository that port or are derived from smali/baksmali/dexlib2
(a lower bound: this lists the files whose own comments name the upstream
symbol, and attribution here lives in prose, not a machine-readable header):
- `src/Stau.Nogar.Dalvik/Dump/ClassDefDumper.cs`
- `src/Stau.Nogar.Dalvik/Dump/CodeItemDumper.cs`
- `src/Stau.Nogar.Dalvik/Dump/DataItemDumpers.cs`
- `src/Stau.Nogar.Dalvik/Dump/DumpReferences.cs`
- `src/Stau.Nogar.Dalvik/Dump/IdTableDumpers.cs`
- `src/Stau.Nogar.Dalvik/Smali/ClassFileNameHandler.cs` (ports `com.android.tools.smali.util.ClassFileNameHandler`)
- `src/Stau.Nogar.Dalvik/Smali/ClassHeaderEmitter.cs`
- `src/Stau.Nogar.Dalvik/Smali/DisassemblyOptions.cs` (defaults read from `BaksmaliOptions` via `javap`, both the 3.0.9 and the `org.jf` 2.5.2 fork APKEditor embeds)
- `src/Stau.Nogar.Dalvik/Smali/InstructionFormatter.cs`
- `src/Stau.Nogar.Dalvik/Smali/LabelTable.cs`
- `src/Stau.Nogar.Dalvik/Smali/SmaliFormat.cs`
- `src/Stau.Nogar.Dalvik/Smali/SyntheticAccessorFSM.cs`
- `src/Stau.Nogar.Dalvik/Smali/SyntheticAccessorResolver.cs`
- `src/Stau.Nogar.Dalvik/Writer/DebugInfoEmitter.cs`
- `src/Stau.Nogar.Dalvik/Writer/DexFileWriter.cs`
- `src/Stau.Nogar.Dalvik/Writer/EncodedValueWriter.cs`
- `src/Stau.Nogar.Dalvik/Writer/JavaPoolHash.cs`
- `src/Stau.Nogar.Dalvik/Writer/SmaliDialect.cs` (the six measured differences between smali/dexlib2 3.0.9 and the `org.jf` fork APKEditor 1.4.3 embeds — same BSD-3-Clause lineage, an older namespace of the same project)
- `src/Stau.Nogar.Dalvik/Writer/TryListBuilder.cs`
- `src/Stau.Nogar.Cli/Verbs/ListVerb.cs` (mirrors baksmali's `list` subcommand family, by decompiling `com.android.tools.smali.dexlib2.formatter.DexFormattedWriter`)
- `src/Stau.Nogar.Resources/Decode/PublicXmlResourceIds.cs` (ports `BaksmaliOptions.loadResourceIds`)

## apksig / apksigner — Apache-2.0 (AOSP)

Copyright (C) The Android Open Source Project.
Project: https://android.googlesource.com/platform/tools/apksig/
(`com.android.apksig`, as shipped inside Android build-tools' `apksigner.jar`)

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

Upstream NOTICE check (Apache License 2.0 §4(d)): `platform/tools/apksig`
ships no NOTICE file. Checked `https://android.googlesource.com/platform/tools/apksig/+/refs/heads/main/`
and the `refs/tags/android-15.0.0_r1` release tag; both list only `.gitignore`,
`Android.bp`, `LICENSE`, `OWNERS`, `PREUPLOAD.cfg`, `README.md`,
`android_plugin_for_gradle.gradle`, `build.gradle`, `etc/`, `gradle/`,
`gradlew`, `gradlew.bat`, `src/`.

`src/Stau.Nogar.Resources/Signing/` (all 31 files) reproduces apksig's own
v1/v2/v3/v3.1/v4 signature schemes, the `SigningCertificateLineage` format and
the fsverity Merkle tree; every file in it names a `com.android.apksig`
class, or an `apksigner`/`ApkSignerTool` behavior, as what it reproduces:
- `ApkSignerEngine.cs`, `ApkSigningBlockUtilsLite.cs`, `ApkSigningBlockWriter.cs`,
  `ApkVerifier.cs`, `Asn1DerWriter.cs`, `ContentDigests.cs`,
  `JarManifestWriter.cs`, `LengthPrefixedReader.cs`, `LineageRotation.cs`,
  `ManifestParser.cs`, `NoSupportedSignaturesException.cs`,
  `Pkcs7SignatureBlockWriter.cs`, `Pkcs7SignedData.cs`, `SignatureAlgorithm.cs`,
  `SignatureAlgorithmSigner.cs`, `SignatureInfo.cs`, `SignerZipModel.cs`,
  `SignerZipWriter.cs`, `SigningCertificateLineage.cs`, `SigningZipReader.cs`,
  `SourceStampVerifier.cs`, `V1JarVerifier.cs`, `V1SchemeSigner.cs`,
  `V2SchemeSigner.cs`, `V2Verifier.cs`, `V3SchemeSigner.cs`,
  `V3SignerConfigSplit.cs`, `V3Verifier.cs`, `V4SchemeSigner.cs`,
  `V4Verifier.cs`, `VerityTreeBuilder.cs`
- `src/Stau.Nogar.Cli/Verbs/SigningSupport.cs` (ports `ApkSignerTool.printCertificate`)
- `src/Stau.Nogar.Resources/Archive/ApkSigningBlock.cs` — only its `ReadInfo` method, which ports
  `apksigner`'s `ApkUtilsLite.findApkSigningBlock`/`ApkSigningBlockUtilsLite`. The other method in
  the same file, `Read`, ports APKEditor/ARSCLib instead — see that section below.

Test resources copied verbatim (byte-identical, Apache-2.0) from apksig's
`src/test/resources/com/android/apksig/` at `refs/heads/main`, kept in
`tests/Fixtures/inputs/signing/apksig/` with their sha256 pinned in
`tools/fixtures/tools.lock.json` (`inputs`):
- `v31-rsa-2048_2-tgt-10000-dev-release.apk`
- `v31-rsa-2048_2-tgt-10000-dev-release.apk.idsig`
- `v41-digest-mismatched-with-v31.apk`
- `v41-digest-mismatched-with-v31.apk.idsig`

## ARSCLib / APKEditor — Apache-2.0 (REAndroid)

Copyright (C) REAndroid and the ARSCLib/APKEditor contributors.
Projects:
- https://github.com/REAndroid/APKEditor — 1.4.3
- https://github.com/REAndroid/ARSCLib — `com.reandroid`, 1.3.6 (embedded in APKEditor 1.4.3)

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

Upstream NOTICE check (Apache License 2.0 §4(d)): neither repo ships a NOTICE
file. APKEditor — checked `https://github.com/REAndroid/APKEditor` at `main`
and at the `V1.4.3` tag (the version this project derives from); both list
only `.github/`, `.gitignore`, `CODE_OF_CONDUCT.md`, `CONTRIBUTING.md`,
`LICENSE`, `README.md`, `SECURITY.md`, `build.gradle`, `gradle/`, `gradlew`,
`gradlew.bat`, `libs/`, `settings.gradle`, `src/`. ARSCLib — checked
`https://github.com/REAndroid/ARSCLib` at `main`; the repo's tag history has
no `1.3.6` tag (it jumps from `V1.3.5` to `V1.3.7`), so both of those
neighboring tags were checked too — all three list only `.github/`,
`.gitignore`, `LICENSE`, `README.md`, `build.gradle`, `gradle/`, `gradlew`,
`gradlew.bat`, `settings.gradle`, `src/`.

`ngr info`, `decode`, `build`, `refactor`, `merge` and `protect` reproduce
APKEditor's own resource-table, binary-XML and zip-layout logic. The files
below name a `com.reandroid.*` class or an APKEditor class as what they port
(again a lower bound, for the same reason as the dexlib2 list above):

`Arsc/`, `ArscWrite/`:
- `src/Stau.Nogar.Resources/Arsc/AndroidFrameworks.cs`
- `src/Stau.Nogar.Resources/Arsc/ArscStringPool.cs`
- `src/Stau.Nogar.Resources/Arsc/AttributeDataFormat.cs`
- `src/Stau.Nogar.Resources/Arsc/AttributeType.cs`
- `src/Stau.Nogar.Resources/Arsc/BagItem.cs`
- `src/Stau.Nogar.Resources/Arsc/ComplexUtil.cs`
- `src/Stau.Nogar.Resources/Arsc/Entry.cs`
- `src/Stau.Nogar.Resources/Arsc/PackageBlock.cs`
- `src/Stau.Nogar.Resources/Arsc/ReferenceString.cs`
- `src/Stau.Nogar.Resources/Arsc/ResConfig.cs`
- `src/Stau.Nogar.Resources/Arsc/ResourceNames.cs`
- `src/Stau.Nogar.Resources/Arsc/TableBlock.cs`
- `src/Stau.Nogar.Resources/Arsc/TypeBlock.cs`
- `src/Stau.Nogar.Resources/Arsc/ValueCoder.cs`
- `src/Stau.Nogar.Resources/Arsc/ValueEncoder.cs`
- `src/Stau.Nogar.Resources/Arsc/XmlAttributeValueDecoder.cs`
- `src/Stau.Nogar.Resources/Arsc/XmlSanitizer.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscAttributeBags.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscFilePathEncoder.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscGlobalStringPool.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscResourceIndex.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscSkeletonEncoder.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscTableEncoder.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscModel.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscTableWriter.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ArscValuesEncoder.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ResConfigQualifierParser.cs`
- `src/Stau.Nogar.Resources/ArscWrite/ValuesXmlDocument.cs`

`Archive/`:
- `src/Stau.Nogar.Resources/Archive/ApkAliasComparer.cs`
- `src/Stau.Nogar.Resources/Archive/ApkEntryOrder.cs`
- `src/Stau.Nogar.Resources/Archive/ApkSignatureBlockBuilder.cs` (ports `ApkModuleEncoder.restoreSignatures` + `ApkSignatureBlock.{scanSplitFiles, sortSignatures, updatePadding}`)
- `src/Stau.Nogar.Resources/Archive/ApkSigningBlock.cs` — only its `Read` method (the `com.reandroid.archive.block` oracle); its `ReadInfo` method ports apksig instead, see above
- `src/Stau.Nogar.Resources/Archive/ApkTreeEncoder.cs`
- `src/Stau.Nogar.Resources/Archive/ApkZipWriter.cs`
- `src/Stau.Nogar.Resources/Archive/ArscLibSorter.cs`
- `src/Stau.Nogar.Resources/Archive/ProtectedApk.cs` (the shared port of `com.reandroid.apkeditor.Util.isProtected`, read via `javap`; the single copy that `info`, the `decode`/`refactor` guards and `merge`'s `ModuleOrder` all consult)
- `src/Stau.Nogar.Resources/Archive/RawZipArchive.cs`
- `src/Stau.Nogar.Resources/Archive/RefactorZipWriter.cs`
- `src/Stau.Nogar.Resources/Archive/UncompressedFilesRule.cs`

`Decode/`:
- `src/Stau.Nogar.Resources/Decode/ApkDecoder.cs`
- `src/Stau.Nogar.Resources/Decode/DecodeJsonEncoder.cs` (see the org.json note below)
- `src/Stau.Nogar.Resources/Decode/DecodePathSanitizer.cs`
- `src/Stau.Nogar.Resources/Decode/DecodePublicXmlWriter.cs`
- `src/Stau.Nogar.Resources/Decode/DecodeValuesWriter.cs`
- `src/Stau.Nogar.Resources/Decode/DecodeXmlNamespaces.cs`
- `src/Stau.Nogar.Resources/Decode/ResourceCommentProvider.cs`

`Info/`:
- `src/Stau.Nogar.Resources/Info/ApkInfoPrinter.cs`
- `src/Stau.Nogar.Resources/Info/IInfoWriter.cs`
- `src/Stau.Nogar.Resources/Info/InfoWriterJson.cs`
- `src/Stau.Nogar.Resources/Info/InfoWriterText.cs`
- `src/Stau.Nogar.Resources/Info/InfoWriterXml.cs`
- `src/Stau.Nogar.Resources/Info/InfoXmlTree.cs`

`Merge/`:
- `src/Stau.Nogar.Resources/Merge/ApkMerger.cs`
- `src/Stau.Nogar.Resources/Merge/BundleReader.cs`
- `src/Stau.Nogar.Resources/Merge/MergeManifest.cs`
- `src/Stau.Nogar.Resources/Merge/ModuleOrder.cs`
- `src/Stau.Nogar.Resources/Merge/ResourcesRootDir.cs`
- `src/Stau.Nogar.Resources/Merge/SanitizeManifest.cs`
- `src/Stau.Nogar.Resources/Merge/TableMerge.cs`
- `src/Stau.Nogar.Resources/Merge/ValidateResourcesDir.cs`

`Protect/`:
- `src/Stau.Nogar.Resources/Protect/ApkProtector.cs` (ports `com.reandroid.apkeditor.protect.Protector.runCommand`)
- `src/Stau.Nogar.Resources/Protect/Confuser.cs`
- `src/Stau.Nogar.Resources/Protect/ConfuseDictionary.cs`
- `src/Stau.Nogar.Resources/Protect/DirectoryConfuser.cs` (ports `com.reandroid.apkeditor.protect.DirectoryConfuser`)
- `src/Stau.Nogar.Resources/Protect/FileNameConfuser.cs` (ports `com.reandroid.apkeditor.protect.FileNameConfuser`)
- `src/Stau.Nogar.Resources/Protect/ManifestConfuser.cs` (ports `com.reandroid.apkeditor.protect.ManifestConfuser`)
- `src/Stau.Nogar.Resources/Protect/ProtectedFileWriter.cs` (ports `com.reandroid.apkeditor.protect.ProtectedFileWriter`)
- `src/Stau.Nogar.Resources/Protect/TableConfuser.cs` (ports `com.reandroid.apkeditor.protect.TableConfuser`)
- `src/Stau.Nogar.Resources/Protect/UncompressedFiles.cs` (ports `com.reandroid.apk.UncompressedFiles`)

`Refactor/`:
- `src/Stau.Nogar.Resources/Refactor/ApkRefactor.cs` (ports `com.reandroid.apkeditor.refactor.Refactor.runCommand`)
- `src/Stau.Nogar.Resources/Refactor/ArscRefresh.cs` (ports `TableBlock.refreshFull()`)
- `src/Stau.Nogar.Resources/Refactor/CleanMeta.cs` (ports `com.reandroid.apkeditor.CommandExecutor.clearMeta`)
- `src/Stau.Nogar.Resources/Refactor/SpecNames.cs`
- `src/Stau.Nogar.Resources/Refactor/StringValueNames.cs`
- `src/Stau.Nogar.Resources/Refactor/TypeNameRefactor.cs`

`ResXml/`:
- `src/Stau.Nogar.Resources/ResXml/AndroidManifestBlock.cs`
- `src/Stau.Nogar.Resources/ResXml/AxmlTableContext.cs`
- `src/Stau.Nogar.Resources/ResXml/KXmlPullParser.cs`
- `src/Stau.Nogar.Resources/ResXml/ResXmlElement.cs`
- `src/Stau.Nogar.Resources/ResXml/ResXmlEncoder.cs`

`Cli/`:
- `src/Stau.Nogar.Cli/Verbs/DecodeVerb.cs` (ports `APKEditor decode`)
- `src/Stau.Nogar.Cli/Verbs/InfoVerb.cs` (ports `APKEditor info`; the `Util.isProtected` predicate it
  consults is `ProtectedApk`, credited above)
- `src/Stau.Nogar.Cli/Verbs/ProtectVerb.cs` (ports `APKEditor p`'s CLI surface)

Test fixtures:
- `tests/Fixtures/inputs/app/apkeditor/protect_dic_dir_name.txt` and
  `protect_dic_file_name.txt` are the `protect_dic_dir_name.txt` and
  `protect_dic_file_name.txt` resources of `APKEditor-1.4.3.jar`, extracted byte
  for byte by `tools/fixtures/regen` (the same texts `ConfuseDictionary.cs` embeds).
- `tests/Fixtures/inputs/app/protected/*.apk` and `tests/Fixtures/inputs/app/editor.apk`
  are outputs of `APKEditor-1.4.3.jar` (`p` and `b`) over this project's own fixture apps.

### kXML2, embedded in APKEditor

`src/Stau.Nogar.Resources/ResXml/KXmlPullParser.cs` and the XML-escaping code
in `src/Stau.Nogar.Resources/Info/InfoWriterXml.cs` port `com.reandroid.xml.kxml2.*`
(`KXmlParser`/`KXmlSerializer`), APKEditor's own repackaged copy of the kXML2
parser. The port is of that repackaged, Apache-2.0-licensed copy, not of the
original kXML2 project directly.

### org.json, embedded in APKEditor

APKEditor 1.4.3 embeds a copy of `org.json`'s classic `JSONObject.quote`
(`com.reandroid.json.JSONItem.quote`). NOGAR contains no code of `org.json` or
of that copy. The JSON string escaping in
`src/Stau.Nogar.Resources/Text/JsonQuote.cs`, used by
`src/Stau.Nogar.Resources/Info/InfoWriterJson.cs` and, through
`src/Stau.Nogar.Resources/Decode/DecodeJsonEncoder.cs`, by `decode`, was
written again from a specification of the JSON string syntax and of the output
it has to reproduce, without reading or copying the `org.json` source. It is
part of NOGAR and is distributed under the NOGAR Software License Agreement
(see `LICENSE.txt`).

## jadx — Apache-2.0

Copyright 2015, Skylot, and the jadx contributors.
Project: https://github.com/skylot/jadx (tag `v1.5.6`).

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

Upstream NOTICE check (Apache License 2.0 §4(d)): `skylot/jadx` ships a `NOTICE`
file at `v1.5.6`. Its own copyright block for `jadx-core` (the module ported
from here) reads:

> The majority of jadx is written and copyrighted by me (Skylot)
> and released under the Apache 2.0 license (see LICENSE file for full license text):
>
> Copyright 2015, Skylot

The rest of that upstream `NOTICE` file covers third-party libraries bundled
into `jadx-gui` and `jadx-cli` (JCommander, SLF4J, Logback, ASM, RSyntaxTextArea,
Concurrent Trees, Image Viewer, bundled icon sets); none of those are ported
here, since only `jadx-core`'s own decompiler logic is a source.

The phase-1 decompiler rewrite ports type-inference and region-structuring
logic from `jadx-core` at tag `v1.5.6`. Per project policy, jadx is never
cloned: its sources are read only over HTTPS, one file at a time, at
`https://raw.githubusercontent.com/skylot/jadx/v1.5.6/<path>`. Each file ported
or derived from jadx gets an entry below as it lands, jadx file → nogar file:

- `jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeInferenceVisitor.java`
  → `src/Stau.Nogar.Decompiler/Typing/TypeInferencer.cs`: derived from (reimplemented, not
  translated) its type classes from phi webs, its immutable parameter types applied before any
  other bound, and its choice of one type per variable from its assign and use bounds.
- `jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java`
  → `src/Stau.Nogar.Decompiler/Typing/TypeInferencer.cs`: derived from (reimplemented, not
  translated) its bound check, where assign bounds are lower bounds and use bounds are upper
  bounds, and its MOVE, AGET/APUT and IF listeners, which propagate types through copies, array
  elements and compared operands.
- `jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeUpdate.java`
  → `src/Stau.Nogar.Decompiler/Typing/TypeInferencer.cs`: derived from (reimplemented, not
  translated) its ARITH listener, where a boolean `and`/`or`/`xor` makes the result and every
  operand boolean.
- `jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/TypeCompare.java`
  → `src/Stau.Nogar.Decompiler/Typing/TypeInferencer.cs`: derived from (reimplemented, not
  translated) its comparator, where the narrowest candidate that satisfies every bound wins.
- `jadx-core/src/main/java/jadx/core/dex/visitors/typeinference/FixTypesVisitor.java`
  → `src/Stau.Nogar.Decompiler/Typing/ConflictResolver.cs` and
  `src/Stau.Nogar.Decompiler/Typing/TypeInferencer.cs`: derived from (reimplemented, not
  translated) its fixes for unresolved types and their order: `trySplitConstInsns` (a constant
  whose uses need different types gets one literal per use, and one per phi only when it feeds
  more than one phi), `tryInsertAdditionalMove` (a conflicting phi has its operands decoupled by
  copies on their edges), `tryToFixIncompatiblePrimitives` (a boolean used as a number is
  converted as `b ? 1 : 0`) and `tryInsertCasts` (a cast at the use).
- `jadx-core/src/main/java/jadx/core/dex/visitors/ConstInlineVisitor.java`
  → `src/Stau.Nogar.Decompiler/Typing/ConflictResolver.cs`: derived from (reimplemented, not
  translated) its treatment of a `move` of a constant as that constant, so a chain of copies of
  a constant is rematerialised with it.
- `jadx-core/src/main/java/jadx/core/dex/visitors/shrink/ArgsInfo.java`
  → `src/Stau.Nogar.Decompiler/Translation/FoldPlanner.cs`: derived from (reimplemented, not
  translated) its inline border, where an instruction's operands are folded from the last to the
  first and each earlier operand must come from before the one folded after it.
- `jadx-core/src/main/java/jadx/core/dex/visitors/shrink/CodeShrinkVisitor.java`
  → `src/Stau.Nogar.Decompiler/Translation/FoldPlanner.cs`: derived from (reimplemented, not
  translated) its single-use rule and `canMoveBetweenBlocks`, where a value moves to a use in
  another block only if every instruction on the paths between them lets it pass.
- `jadx-core/src/main/java/jadx/core/codegen/InsnGen.java`
  → `src/Stau.Nogar.Decompiler/Translation/BlockTranslator.cs`: derived from (reimplemented, not
  translated) its Java form for each instruction: static calls and static fields qualified by their
  owner and instance members by their receiver, `super.m()` or `I.super.m()` for a super call,
  `super(...)` or `this(...)` for constructor chaining, `!` for the NOT of a boolean and `~`
  otherwise, `new T[n]`, array literals, array accesses and lengths, casts and `instanceof`. Its
  comparisons used as values are not taken: here they keep the NaN bias of `cmpl` and `cmpg`.
- `jadx-core/src/main/java/jadx/core/dex/visitors/regions/maker/SwitchRegionMaker.java`
  → `src/Stau.Nogar.Decompiler/Structure/SwitchStructurer.cs` and
  `src/Stau.Nogar.Decompiler/Structure/RegionCleanup.cs`: derived from (reimplemented, not
  translated) its keys grouped by target, its code after the switch taken from the union of the
  dominance frontiers of the case targets (`calcSwitchOut`), its fall-through into a case target
  found in the dominance frontier of another case (`addCases`), and its removal of an empty
  `default` together with the cases that only lead where the default does (`removeEmptyCases`).
- `jadx-core/src/main/java/jadx/core/dex/visitors/finaly/MarkFinallyVisitor.java`
  → `src/Stau.Nogar.Decompiler/Structure/FinallyMatcher.cs` (with its partial files
  `FinallyMatcher.Lockstep.cs`, `FinallyMatcher.Apply.cs` and `FinallyMatcher.View.cs`): derived from
  (reimplemented, not translated) its nomination of the catch-all handler of a try as the candidate
  finally, its cut of that handler's `move-exception` and of the `throw` of what it caught, and its
  walk of the handler and of each duplicate side by side to match them, after which the duplicates
  are not generated. Its intersection of the instructions common to all exits is not taken: here
  every exit must hold a whole copy, or the catch-all stays a visible catch.
- `jadx-core/src/main/java/jadx/core/dex/visitors/regions/TernaryMod.java`
  → `src/Stau.Nogar.Decompiler/Building/Idioms.Ternary.cs`: derived from (reimplemented, not
  translated) its ternary from an `if` whose two branches each hold a single assignment to the same
  variable, its ternary return from an `if` whose two branches each return, its one-branch form
  that takes the other value from the assignment just before the `if`, and its refusal to nest a
  ternary inside another. The typing checks are not taken: here a ternary is made only when Java's
  numeric promotion, boxing and constant narrowing give each branch the value it had.
- `jadx-core/src/main/java/jadx/core/dex/visitors/regions/LoopRegionVisitor.java`
  → `src/Stau.Nogar.Decompiler/Building/Idioms.Loops.cs`: derived from (reimplemented, not
  translated) its indexed `for` loop, whose update is the last statement of the loop body, whose
  initialisation is the assignment just before the loop and whose variable the condition reads.
  Its use of the SSA phi of the loop variable is not taken: here the update must lie on every path
  to the next turn, so no `continue` may skip it.
- `jadx-core/src/main/java/jadx/core/dex/visitors/SimplifyVisitor.java`
  → `src/Stau.Nogar.Decompiler/Building/Idioms.Compound.cs`: derived from (reimplemented, not
  translated) its compound assignment for `obj.f = obj.f op v` on the same field and the same
  object. It is extended to local variables and array elements, to the narrowing cast that the
  compound form implies, and to `++`/`--` for a step of one.

## Android framework resource tables — Apache-2.0 (AOSP), redistributed by APKEditor

Copyright (C) The Android Open Source Project.

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

`src/Stau.Nogar.Resources/Frameworks/android/android-{23..36}.apk` (14 files)
are the framework resource tables APKEditor 1.4.3 carries embedded in its own
jar (`frameworks/android/`), copied byte for byte. Each contains only
`resources.arsc` + `AndroidManifest.xml` and derives from AOSP's
`framework-res.apk` (Apache-2.0). `ngr info --resources` needs them to resolve
package-`0x01` framework resource ids.

Upstream NOTICE check (Apache License 2.0 §4(d)): `platform/frameworks/base`
does ship a NOTICE file — checked
`https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/NOTICE`.
That file covers several components bundled elsewhere in `frameworks/base`
(Apache Commons, Jakarta Commons Logging, Nuance, PacketVideo media codecs,
Apple's mDnsResponder, TagSoup, VisualOn, NXP audio effects, and Unicode data
files); the section that applies to the resource-table schema reproduced here
is the one for AOSP's own code:

> =========================================================================
> ==  NOTICE file corresponding to the section 4 d of                    ==
> ==  the Apache License, Version 2.0,                                   ==
> ==  in this case for the Android-specific code.                        ==
> =========================================================================
>
> Android Code
> Copyright 2005-2008 The Android Open Source Project
>
> This product includes software developed as part of
> The Android Open Source Project (http://source.android.com).

`src/Stau.Nogar.Resources/Archive/ZipalignVerifier.cs` reproduces six literal
`printf`-style format strings (`"Verifying alignment of %s (%d)..."` and five
others) extracted verbatim from the `zipalign` binary itself (`strings -a
tools/zipalign`, part of Android build-tools, Apache-2.0/AOSP) — there is no
`zipalign` source available to port from, only the strings surviving in the
compiled Mach-O binary.

## Android API model — Apache-2.0 (AOSP)

Android API model (`src/Stau.Nogar.Decompiler/Platform/android-api.bin`): signatures, hierarchy,
flags and API levels extracted from the Android SDK's `android.jar` 26–36.1 and from
`api-versions.xml` (AOSP). Apache License 2.0. Contains no code, only declarations.

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

## ZLibDotNet 0.1.1 (zlib 1.3.1 in C#) — zlib license

`src/Stau.Nogar.Zlib/ZLibDotNet/` is vendored unchanged from upstream ZLibDotNet
0.1.1 (Magnus Montin's C# port of zlib 1.3.1 by Jean-loup Gailly and Mark
Adler), except for one marked patch. The full license text ships with the
vendored code at `src/Stau.Nogar.Zlib/ZLibDotNet/LICENSE.md`; the hashes that
pin the vendored tree are at `src/Stau.Nogar.Zlib/zlibdotnet-0.1.1.sha256`,
and `tests/Stau.Nogar.Resources.Tests/ZlibVendorPatchShapeTests.cs` checks
that only the one marked patch differs from upstream.

```
Copyright (c) 2022-2024 Magnus Montin
Copyright (c) 1995-2024 Jean-loup Gailly and Mark Adler

This software is provided 'as-is', without any express or implied
warranty.  In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
```

The one marked alteration is in `Deflate/Tree.cs`'s `GenBitLen`: it zeroes
`(MaxBits + 1) * sizeof(ushort)` bytes of `bl_count`, matching the C zlib's
`0..MAX_BITS` range, instead of upstream ZLibDotNet's `MaxBits * sizeof(ushort)`.

## Float/double formatting (`Schubfach.cs`) — clean-room, no OpenJDK code

`src/Stau.Nogar.Dalvik/Smali/Schubfach.cs` was implemented from the public
mathematics of Raffaello Giulietti's paper "The Schubfach way to render
doubles," without reading, copying, or consulting OpenJDK/`jdk.internal.math`
source. It is part of NOGAR and is distributed under the NOGAR Software License Agreement (see `LICENSE.txt`).

## Clean-room reimplementations — no OpenJDK code

`src/Stau.Nogar.Dalvik/Writer/JavaConcurrentHashMap.cs`,
`src/Stau.Nogar.Dalvik/Writer/JavaHashMapOrder.cs`,
`src/Stau.Nogar.Dalvik/Writer/JavaHash.cs`,
`src/Stau.Nogar.Resources/Decode/DecodePathOrder.cs`,
`src/Stau.Nogar.Resources/Protect/ProtectRandom.cs` and
`src/Stau.Nogar.Resources/Signing/JavaDistinguishedName.cs` reproduce the
observable behavior of JDK classes (`String`/`List`/`Set` hash codes,
`java.util.HashMap` and `java.util.concurrent.ConcurrentHashMap` iteration
order, the bounds consumed from `java.util.Random.nextInt`, and the text of an
X.500 distinguished name as `apksigner` prints it). Earlier versions of these
files were deleted and rewritten in a clean room, in two separate steps:

1. One agent wrote a functional specification from this repository's tests,
   their frozen fixtures and the callers of these types, plus public
   documentation only (the Java SE 21 Javadoc, JEP 180, and RFC 1779, 2253 and
   4514), without opening the previous implementations or any OpenJDK source.
2. A different agent implemented the six files from that specification, the
   tests and the same public documentation, without access to the previous
   implementations (on disk or in git history) or to OpenJDK source or
   bytecode.

The specification's behavioral rules were derived from general knowledge of
these classes' observable behavior and then checked against the frozen JVM
outputs this repository keeps under `tests/Fixtures/`. The specification and
the implementation were each written by a separate AI agent.

They are part of NOGAR and are distributed under the NOGAR Software License Agreement (see `LICENSE.txt`).

## Kotlin metadata schema — Apache-2.0 (JetBrains)

Copyright 2010-2015 JetBrains s.r.o. (the two schema files); Kotlin Compiler,
Copyright 2010-2024 JetBrains s.r.o and respective authors and developers.
Project: https://github.com/JetBrains/kotlin (tag `v2.4.20`).

License text: [`licenses/Apache-2.0.txt`](licenses/Apache-2.0.txt).

Upstream NOTICE check (Apache License 2.0 §4(d)): `JetBrains/kotlin` ships no
`NOTICE` file at its root at `v2.4.20`; it keeps one at `license/NOTICE.txt`,
whose whole attribution reads:

> Kotlin Compiler
> Copyright 2010-2024 JetBrains s.r.o and respective authors and developers

The decompiler's reader of the `kotlin.Metadata` annotation is written from
Kotlin's published protobuf schemas and from the description of the `d1`
string encoding, read over HTTPS at
`https://raw.githubusercontent.com/JetBrains/kotlin/v2.4.20/<path>`. What is
used:
- the field numbers and the message structure of
  `core/metadata/src/metadata.proto` (`Class`, `Package`, `Constructor`,
  `Function`, `ValueParameter`) and of `core/metadata.jvm/src/jvm_metadata.proto`
  (`StringTableTypes` and its `Record`, `JvmMethodSignature`, and the
  `constructor_signature` and `method_signature` extensions);
- the description of how `d1` turns into bytes (the UTF-8 mode marker, the
  7-to-8 bit packing with or without its marker), from
  `core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/BitEncoding.java`
  and `utfEncoding.kt` in the same directory.

No code of the Kotlin compiler, of `kotlinx-metadata` or of the protobuf
runtime is copied or translated: the wire-format reader, the bit decoding and
the name resolution are this project's own. Kotlin's predefined-string table
is not embedded. The files that implement it (`src/Stau.Nogar.Decompiler/Kotlin/*.cs`),
part of NOGAR and distributed under the NOGAR Software License Agreement (see `LICENSE.txt`):
- `src/Stau.Nogar.Decompiler/Kotlin/BitDecoding.cs`
- `src/Stau.Nogar.Decompiler/Kotlin/MetadataReader.cs`
- `src/Stau.Nogar.Decompiler/Kotlin/ProtoReader.cs`

## .NET runtime and libraries — MIT (.NET Foundation and Contributors)

`ngr` is compiled ahead of time with .NET 10 (Native AOT), so the binary holds
the .NET runtime and the parts of the .NET class libraries it uses, with the
native libraries they link (among them zlib-ng and Brotli).

Copyright (c) .NET Foundation and Contributors.
Project: https://github.com/dotnet/runtime
License: MIT, https://github.com/dotnet/runtime/blob/main/LICENSE.TXT

License text: [`licenses/MIT-dotnet.txt`](licenses/MIT-dotnet.txt).

The .NET runtime carries the notices of the third-party code it includes, in
https://github.com/dotnet/runtime/blob/main/THIRD-PARTY-NOTICES.TXT. The copy
that ships with the version used to build `ngr` (10.0.14) is
[`licenses/dotnet-THIRD-PARTY-NOTICES.txt`](licenses/dotnet-THIRD-PARTY-NOTICES.txt).

## System.CommandLine 2.0.12 — MIT

`ngr` reads its command line with System.CommandLine 2.0.12, compiled into the
binary.

Copyright (c) Microsoft Corporation. All rights reserved.
Project: https://github.com/dotnet/command-line-api
License: MIT, https://licenses.nuget.org/MIT

License text: [`licenses/MIT-dotnet.txt`](licenses/MIT-dotnet.txt), the same
MIT terms.
