package com.mindera.skeletoid.utils.versioning

import kotlin.math.sign

object Versioning {
    /**
     * Compares two version strings.
     * Credits to: https://gist.github.com/antalindisguise/d9d462f2defcfd7ae1d4
     *
     * Use this instead of String.compareTo() for a non-lexicographical
     * comparison that works for version strings. e.g. "1.10".compareTo("1.6").
     *
     * @note It does not work if "1.10" is supposed to be equal to "1.10.0".
     *
     * @param str1 a string of ordinal numbers separated by decimal points.
     * @param str2 a string of ordinal numbers separated by decimal points.
     * @return The result is a negative integer if str1 is _numerically_ less than str2.
     *         The result is a positive integer if str1 is _numerically_ greater than str2.
     *         The result is zero if the strings are _numerically_ equal.
     */
    fun compareVersions(str1: String, str2: String): Int {
        if (str1.isBlank() || str2.isBlank()) {
            throw IllegalArgumentException("Invalid Version")
        }

        val vals1 = str1.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
        val vals2 = str2.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()

        var i = 0
        // set index to first non-equal ordinal or length of shortest version string
        while (i < vals1.size && i < vals2.size && vals1[i] == vals2[i]) {
            i++
        }
        // compare first non-equal ordinal number
        return run {
            // compare first non-equal ordinal number
            if (i < vals1.size && i < vals2.size) {
                vals1[i].toInt().compareTo(vals2[i].toInt())
            } else {
                // the strings are equal or one string is a substring of the other
                // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
                vals1.size - vals2.size
            }
        }.sign

    }
}

Compiled from "Versioning.kt"
public final class com.mindera.skeletoid.utils.versioning.Versioning {
  public static final com.mindera.skeletoid.utils.versioning.Versioning INSTANCE;

  private com.mindera.skeletoid.utils.versioning.Versioning();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int compareVersions(java.lang.String, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String str1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String str2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: checkcast     #25                 // class java/lang/CharSequence
      16: invokestatic  #31                 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      19: ifne          32
      22: aload_2
      23: checkcast     #25                 // class java/lang/CharSequence
      26: invokestatic  #31                 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      29: ifeq          42
      32: new           #33                 // class java/lang/IllegalArgumentException
      35: dup
      36: ldc           #35                 // String Invalid Version
      38: invokespecial #38                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      41: athrow
      42: aload_1
      43: checkcast     #25                 // class java/lang/CharSequence
      46: astore        4
      48: new           #40                 // class kotlin/text/Regex
      51: dup
      52: ldc           #42                 // String \\.
      54: invokespecial #43                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      57: astore        5
      59: iconst_0
      60: istore        6
      62: aload         5
      64: aload         4
      66: iload         6
      68: invokevirtual #47                 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
      71: astore        4
      73: nop
      74: iconst_0
      75: istore        5
      77: aload         4
      79: invokeinterface #53,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      84: ifne          170
      87: aload         4
      89: aload         4
      91: invokeinterface #57,  1           // InterfaceMethod java/util/List.size:()I
      96: invokeinterface #61,  2           // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
     101: astore        6
     103: aload         6
     105: invokeinterface #66,  1           // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
     110: ifeq          170
     113: aload         6
     115: invokeinterface #70,  1           // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
     120: checkcast     #72                 // class java/lang/String
     123: astore        7
     125: iconst_0
     126: istore        8
     128: aload         7
     130: checkcast     #25                 // class java/lang/CharSequence
     133: invokeinterface #75,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     138: ifne          145
     141: iconst_1
     142: goto          146
     145: iconst_0
     146: nop
     147: ifne          103
     150: aload         4
     152: checkcast     #77                 // class java/lang/Iterable
     155: aload         6
     157: invokeinterface #80,  1           // InterfaceMethod java/util/ListIterator.nextIndex:()I
     162: iconst_1
     163: iadd
     164: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     167: goto          173
     170: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     173: checkcast     #92                 // class java/util/Collection
     176: astore        4
     178: nop
     179: iconst_0
     180: istore        5
     182: aload         4
     184: astore        6
     186: aload         6
     188: iconst_0
     189: anewarray     #72                 // class java/lang/String
     192: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     197: checkcast     #98                 // class "[Ljava/lang/String;"
     200: astore_3
     201: aload_2
     202: checkcast     #25                 // class java/lang/CharSequence
     205: astore        5
     207: new           #40                 // class kotlin/text/Regex
     210: dup
     211: ldc           #42                 // String \\.
     213: invokespecial #43                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     216: astore        6
     218: iconst_0
     219: istore        7
     221: aload         6
     223: aload         5
     225: iload         7
     227: invokevirtual #47                 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
     230: astore        5
     232: nop
     233: iconst_0
     234: istore        6
     236: aload         5
     238: invokeinterface #53,  1           // InterfaceMethod java/util/List.isEmpty:()Z
     243: ifne          329
     246: aload         5
     248: aload         5
     250: invokeinterface #57,  1           // InterfaceMethod java/util/List.size:()I
     255: invokeinterface #61,  2           // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
     260: astore        7
     262: aload         7
     264: invokeinterface #66,  1           // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
     269: ifeq          329
     272: aload         7
     274: invokeinterface #70,  1           // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
     279: checkcast     #72                 // class java/lang/String
     282: astore        8
     284: iconst_0
     285: istore        9
     287: aload         8
     289: checkcast     #25                 // class java/lang/CharSequence
     292: invokeinterface #75,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     297: ifne          304
     300: iconst_1
     301: goto          305
     304: iconst_0
     305: nop
     306: ifne          262
     309: aload         5
     311: checkcast     #77                 // class java/lang/Iterable
     314: aload         7
     316: invokeinterface #80,  1           // InterfaceMethod java/util/ListIterator.nextIndex:()I
     321: iconst_1
     322: iadd
     323: invokestatic  #86                 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     326: goto          332
     329: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     332: checkcast     #92                 // class java/util/Collection
     335: astore        5
     337: nop
     338: iconst_0
     339: istore        6
     341: aload         5
     343: astore        7
     345: aload         7
     347: iconst_0
     348: anewarray     #72                 // class java/lang/String
     351: invokeinterface #96,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     356: checkcast     #98                 // class "[Ljava/lang/String;"
     359: astore        4
     361: iconst_0
     362: istore        5
     364: iload         5
     366: aload_3
     367: arraylength
     368: if_icmpge     407
     371: iload         5
     373: aload         4
     375: arraylength
     376: if_icmpge     407
     379: aload_3
     380: iload         5
     382: aaload
     383: aload         4
     385: iload         5
     387: aaload
     388: invokestatic  #102                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     391: ifeq          407
     394: iload         5
     396: istore        6
     398: iload         6
     400: iconst_1
     401: iadd
     402: istore        5
     404: goto          364
     407: aload_0
     408: checkcast     #2                  // class com/mindera/skeletoid/utils/versioning/Versioning
     411: astore        7
     413: iconst_0
     414: istore        8
     416: iload         5
     418: aload_3
     419: arraylength
     420: if_icmpge     452
     423: iload         5
     425: aload         4
     427: arraylength
     428: if_icmpge     452
     431: aload_3
     432: iload         5
     434: aaload
     435: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     438: aload         4
     440: iload         5
     442: aaload
     443: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     446: invokestatic  #112                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     449: goto          458
     452: aload_3
     453: arraylength
     454: aload         4
     456: arraylength
     457: isub
     458: nop
     459: nop
     460: invokestatic  #118                // Method kotlin/math/MathKt.getSign:(I)I
     463: ireturn

  static {};
    Code:
       0: new           #2                  // class com/mindera/skeletoid/utils/versioning/Versioning
       3: dup
       4: invokespecial #139                // Method "<init>":()V
       7: putstatic     #142                // Field INSTANCE:Lcom/mindera/skeletoid/utils/versioning/Versioning;
      10: return
}


package palindrome_int

//https://leetcode.com/problems/palindrome-number
object PalindRomeInt {

    private fun isPalindrome(input: Int): Boolean {
        if (input < 0 || input >= Int.MAX_VALUE) return false
        if (input in 0..9) return true

        var original = input
        var reversed = 0

        while (original != 0) {
            reversed = (reversed * 10) + original % 10
            original /= 10
        }
        return input == reversed
    }

    @JvmStatic
    fun main(args: Array<String>) {
        println(isPalindrome(121))
        println(isPalindrome(-121))
        println(isPalindrome(10))
    }
}
/**
 * Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.

Example 1:

Input: x = 121
Output: true
Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:

Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3:

Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Constraints:

-231 <= x <= 231 - 1

Follow up: Could you solve it without converting the integer to a string?
 **/

Compiled from "PalindRomeInt.kt"
public final class palindrome_int.PalindRomeInt {
  public static final palindrome_int.PalindRomeInt INSTANCE;

  private palindrome_int.PalindRomeInt();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final boolean isPalindrome(int);
    Code:
       0: iload_1
       1: iflt          10
       4: iload_1
       5: ldc           #13                 // int 2147483647
       7: if_icmplt     12
      10: iconst_0
      11: ireturn
      12: iconst_0
      13: iload_1
      14: if_icmpgt     31
      17: iload_1
      18: bipush        10
      20: if_icmpge     27
      23: iconst_1
      24: goto          32
      27: iconst_0
      28: goto          32
      31: iconst_0
      32: ifeq          37
      35: iconst_1
      36: ireturn
      37: iload_1
      38: istore_2
      39: iconst_0
      40: istore_3
      41: iload_2
      42: ifeq          63
      45: iload_3
      46: bipush        10
      48: imul
      49: iload_2
      50: bipush        10
      52: irem
      53: iadd
      54: istore_3
      55: iload_2
      56: bipush        10
      58: idiv
      59: istore_2
      60: goto          41
      63: iload_1
      64: iload_3
      65: if_icmpne     72
      68: iconst_1
      69: goto          73
      72: iconst_0
      73: ireturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #23                 // String args
       3: invokestatic  #29                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #32                 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;
       9: bipush        121
      11: invokespecial #34                 // Method isPalindrome:(I)Z
      14: istore_1
      15: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      18: iload_1
      19: invokevirtual #46                 // Method java/io/PrintStream.println:(Z)V
      22: getstatic     #32                 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;
      25: bipush        -121
      27: invokespecial #34                 // Method isPalindrome:(I)Z
      30: istore_1
      31: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      34: iload_1
      35: invokevirtual #46                 // Method java/io/PrintStream.println:(Z)V
      38: getstatic     #32                 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;
      41: bipush        10
      43: invokespecial #34                 // Method isPalindrome:(I)Z
      46: istore_1
      47: getstatic     #40                 // Field java/lang/System.out:Ljava/io/PrintStream;
      50: iload_1
      51: invokevirtual #46                 // Method java/io/PrintStream.println:(Z)V
      54: return

  static {};
    Code:
       0: new           #2                  // class palindrome_int/PalindRomeInt
       3: dup
       4: invokespecial #49                 // Method "<init>":()V
       7: putstatic     #32                 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;
      10: return
}


package palindrome_int

//https://leetcode.com/problems/palindrome-number
object PalindRomeString {

    private fun isPalindrome(input: Int): Boolean {
        if (input < 0 || input >= Int.MAX_VALUE) return false
        if (input in 0..9) return true

        val original = input.toString()
        original.forEachIndexed { index, num ->
            if (num != original[original.length - (index+1)])
                return false
        }
        return true
    }

    @JvmStatic
    fun main(args: Array<String>) {
        println(isPalindrome(121))
        println(isPalindrome(-121))
        println(isPalindrome(10))
    }
}
/**
 * Given an integer x, return true if x is palindrome integer.

An integer is a palindrome when it reads the same backward as forward.

For example, 121 is a palindrome while 123 is not.

Example 1:

Input: x = 121
Output: true
Explanation: 121 reads as 121 from left to right and from right to left.
Example 2:

Input: x = -121
Output: false
Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.
Example 3:

Input: x = 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.

Constraints:

-231 <= x <= 231 - 1

Follow up: Could you solve it without converting the integer to a string?
 **/

Compiled from "PalindRomeString.kt"
public final class palindrome_int.PalindRomeString {
  public static final palindrome_int.PalindRomeString INSTANCE;

  private palindrome_int.PalindRomeString();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final boolean isPalindrome(int);
    Code:
       0: iload_1
       1: iflt          10
       4: iload_1
       5: ldc           #13                 // int 2147483647
       7: if_icmplt     12
      10: iconst_0
      11: ireturn
      12: iconst_0
      13: iload_1
      14: if_icmpgt     31
      17: iload_1
      18: bipush        10
      20: if_icmpge     27
      23: iconst_1
      24: goto          32
      27: iconst_0
      28: goto          32
      31: iconst_0
      32: ifeq          37
      35: iconst_1
      36: ireturn
      37: iload_1
      38: invokestatic  #19                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      41: astore_2
      42: aload_2
      43: checkcast     #21                 // class java/lang/CharSequence
      46: astore_3
      47: iconst_0
      48: istore        4
      50: iconst_0
      51: istore        5
      53: iconst_0
      54: istore        6
      56: iload         6
      58: aload_3
      59: invokeinterface #25,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      64: if_icmpge     119
      67: aload_3
      68: iload         6
      70: invokeinterface #29,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      75: istore        7
      77: iload         5
      79: iinc          5, 1
      82: iload         7
      84: istore        8
      86: istore        9
      88: iconst_0
      89: istore        10
      91: iload         8
      93: aload_2
      94: aload_2
      95: invokevirtual #30                 // Method java/lang/String.length:()I
      98: iload         9
     100: iconst_1
     101: iadd
     102: isub
     103: invokevirtual #31                 // Method java/lang/String.charAt:(I)C
     106: if_icmpeq     111
     109: iconst_0
     110: ireturn
     111: nop
     112: nop
     113: iinc          6, 1
     116: goto          56
     119: nop
     120: iconst_1
     121: ireturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #50                 // String args
       3: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #59                 // Field INSTANCE:Lpalindrome_int/PalindRomeString;
       9: bipush        121
      11: invokespecial #61                 // Method isPalindrome:(I)Z
      14: istore_1
      15: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      18: iload_1
      19: invokevirtual #73                 // Method java/io/PrintStream.println:(Z)V
      22: getstatic     #59                 // Field INSTANCE:Lpalindrome_int/PalindRomeString;
      25: bipush        -121
      27: invokespecial #61                 // Method isPalindrome:(I)Z
      30: istore_1
      31: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      34: iload_1
      35: invokevirtual #73                 // Method java/io/PrintStream.println:(Z)V
      38: getstatic     #59                 // Field INSTANCE:Lpalindrome_int/PalindRomeString;
      41: bipush        10
      43: invokespecial #61                 // Method isPalindrome:(I)Z
      46: istore_1
      47: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      50: iload_1
      51: invokevirtual #73                 // Method java/io/PrintStream.println:(Z)V
      54: return

  static {};
    Code:
       0: new           #2                  // class palindrome_int/PalindRomeString
       3: dup
       4: invokespecial #76                 // Method "<init>":()V
       7: putstatic     #59                 // Field INSTANCE:Lpalindrome_int/PalindRomeString;
      10: return
}


package common_prefix

//https://leetcode.com/problems/longest-common-prefix/
object CommonPrefix {

    private fun longestCommonPrefix(list: Array<String>): String {
        if (list.isEmpty()) return ""
        var prefix = list[0]

        list.forEach {
            while (it.indexOf(prefix) != 0) {
                prefix = prefix.substring(0, prefix.length - 1)
            }
        }
        return prefix
    }

    @JvmStatic
    fun main(args: Array<String>) {
        println(longestCommonPrefix(arrayOf("flower", "flow", "flight")))
        println(longestCommonPrefix(arrayOf("dog", "racecar", "car")))
        println(longestCommonPrefix(arrayOf("ahmed", "sahm", "wassbah")))
    }
}
/*
 * Write a function to find the longest common prefix string amongst an array of strings.

If there is no common prefix, return an empty string "".

Example 1:

Input: strs = ["flower","flow","flight"]
Output: "fl"
Example 2:

Input: strs = ["dog","racecar","car"]
Output: ""
Explanation: There is no common prefix among the input strings.

Constraints:

1 <= strs.length <= 200
0 <= strs[i].length <= 200
strs[i] consists of only lower-case English letters.
 **/

Compiled from "CommonPrefix.kt"
public final class common_prefix.CommonPrefix {
  public static final common_prefix.CommonPrefix INSTANCE;

  private common_prefix.CommonPrefix();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final java.lang.String longestCommonPrefix(java.lang.String[]);
    Code:
       0: aload_1
       1: arraylength
       2: ifne          9
       5: iconst_1
       6: goto          10
       9: iconst_0
      10: ifeq          16
      13: ldc           #14                 // String
      15: areturn
      16: aconst_null
      17: astore_2
      18: aload_1
      19: iconst_0
      20: aaload
      21: astore_2
      22: aload_1
      23: astore_3
      24: iconst_0
      25: istore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: arraylength
      32: istore        6
      34: iload         5
      36: iload         6
      38: if_icmpge     100
      41: aload_3
      42: iload         5
      44: aaload
      45: astore        7
      47: aload         7
      49: astore        8
      51: iconst_0
      52: istore        9
      54: aload         8
      56: checkcast     #16                 // class java/lang/CharSequence
      59: aload_2
      60: iconst_0
      61: iconst_0
      62: bipush        6
      64: aconst_null
      65: invokestatic  #22                 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I
      68: ifeq          92
      71: aload_2
      72: iconst_0
      73: aload_2
      74: invokevirtual #28                 // Method java/lang/String.length:()I
      77: iconst_1
      78: isub
      79: invokevirtual #32                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      82: dup
      83: ldc           #34                 // String substring(...)
      85: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      88: astore_2
      89: goto          54
      92: nop
      93: nop
      94: iinc          5, 1
      97: goto          34
     100: nop
     101: aload_2
     102: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #59                 // String args
       3: invokestatic  #62                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #65                 // Field INSTANCE:Lcommon_prefix/CommonPrefix;
       9: iconst_3
      10: anewarray     #24                 // class java/lang/String
      13: astore_1
      14: aload_1
      15: iconst_0
      16: ldc           #67                 // String flower
      18: aastore
      19: aload_1
      20: iconst_1
      21: ldc           #69                 // String flow
      23: aastore
      24: aload_1
      25: iconst_2
      26: ldc           #71                 // String flight
      28: aastore
      29: aload_1
      30: invokespecial #73                 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;
      33: getstatic     #79                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: swap
      37: invokevirtual #85                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      40: getstatic     #65                 // Field INSTANCE:Lcommon_prefix/CommonPrefix;
      43: iconst_3
      44: anewarray     #24                 // class java/lang/String
      47: astore_1
      48: aload_1
      49: iconst_0
      50: ldc           #87                 // String dog
      52: aastore
      53: aload_1
      54: iconst_1
      55: ldc           #89                 // String racecar
      57: aastore
      58: aload_1
      59: iconst_2
      60: ldc           #91                 // String car
      62: aastore
      63: aload_1
      64: invokespecial #73                 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;
      67: getstatic     #79                 // Field java/lang/System.out:Ljava/io/PrintStream;
      70: swap
      71: invokevirtual #85                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      74: getstatic     #65                 // Field INSTANCE:Lcommon_prefix/CommonPrefix;
      77: iconst_3
      78: anewarray     #24                 // class java/lang/String
      81: astore_1
      82: aload_1
      83: iconst_0
      84: ldc           #93                 // String ahmed
      86: aastore
      87: aload_1
      88: iconst_1
      89: ldc           #95                 // String sahm
      91: aastore
      92: aload_1
      93: iconst_2
      94: ldc           #97                 // String wassbah
      96: aastore
      97: aload_1
      98: invokespecial #73                 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;
     101: getstatic     #79                 // Field java/lang/System.out:Ljava/io/PrintStream;
     104: swap
     105: invokevirtual #85                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     108: return

  static {};
    Code:
       0: new           #2                  // class common_prefix/CommonPrefix
       3: dup
       4: invokespecial #99                 // Method "<init>":()V
       7: putstatic     #65                 // Field INSTANCE:Lcommon_prefix/CommonPrefix;
      10: return
}


package com.gildedrose

data class Item(val name: String, val sellIn: Int, val quality: Int) {
    override fun toString(): String {
        return this.name + ", " + this.sellIn + ", " + this.quality
    }
}

fun Item.ageBy(days: Int): Item {
    return copy(
        sellIn = remainingSellInAfter(days),
        quality = qualityIn(days)
    )
}

private fun Item.remainingSellInAfter(days: Int): Int {
    return when (name) {
        "Sulfuras, Hand of Ragnaros" -> sellIn
        else -> sellIn - days
    }
}

private fun Item.qualityIn(days: Int): Int {
    return when {
        name == "Backstage passes to a TAFKAL80ETC concert" ->
            boundedQuality(quality + this.incrementQualityFor(days))
        name == "Sulfuras, Hand of Ragnaros" ->
            quality
        name == "Aged Brie" ->
            boundedQuality(quality + days)
        name.startsWith("Conjured") ->
            boundedQuality(quality + -2 * days)
        else -> boundedQuality(quality + -1 * days)
    }
}

private fun boundedQuality(rawQuality: Int): Int {
    return Integer.min(50, Integer.max(0, rawQuality))
}

private fun Item.incrementQualityFor(days: Int): Int {
    val daysToSell = sellIn
    return (1 until days + 1)
        .fold(0) { total, e -> total + accelerateQualityWhenExpiring(daysToSell - e, quality) }
}

private fun accelerateQualityWhenExpiring(sellIn: Int, startingQuality: Int): Int {
    return when {
        sellIn < 0 -> -startingQuality
        sellIn <= 5 -> 3
        sellIn <= 10 -> 2
        else -> 1
    }
}

Compiled from "Item.kt"
public final class com.gildedrose.Item {
  private final java.lang.String name;

  private final int sellIn;

  private final int quality;

  public com.gildedrose.Item(java.lang.String, int, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String name
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #21                 // Field name:Ljava/lang/String;
      15: aload_0
      16: iload_2
      17: putfield      #25                 // Field sellIn:I
      20: aload_0
      21: iload_3
      22: putfield      #28                 // Field quality:I
      25: return

  public final java.lang.String getName();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: areturn

  public final int getSellIn();
    Code:
       0: aload_0
       1: getfield      #25                 // Field sellIn:I
       4: ireturn

  public final int getQuality();
    Code:
       0: aload_0
       1: getfield      #28                 // Field quality:I
       4: ireturn

  public java.lang.String toString();
    Code:
       0: new           #38                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
       7: aload_0
       8: getfield      #21                 // Field name:Ljava/lang/String;
      11: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      14: ldc           #45                 // String ,
      16: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      19: aload_0
      20: getfield      #25                 // Field sellIn:I
      23: invokevirtual #48                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      26: ldc           #45                 // String ,
      28: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      31: aload_0
      32: getfield      #28                 // Field quality:I
      35: invokevirtual #48                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      38: invokevirtual #50                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      41: areturn

  public final java.lang.String component1();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: areturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field sellIn:I
       4: ireturn

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #28                 // Field quality:I
       4: ireturn

  public final com.gildedrose.Item copy(java.lang.String, int, int);
    Code:
       0: aload_1
       1: ldc           #9                  // String name
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class com/gildedrose/Item
       9: dup
      10: aload_1
      11: iload_2
      12: iload_3
      13: invokespecial #57                 // Method "<init>":(Ljava/lang/String;II)V
      16: areturn

  public static com.gildedrose.Item copy$default(com.gildedrose.Item, java.lang.String, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #21                 // Field name:Ljava/lang/String;
      11: astore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #25                 // Field sellIn:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #28                 // Field quality:I
      35: istore_3
      36: aload_0
      37: aload_1
      38: iload_2
      39: iload_3
      40: invokevirtual #61                 // Method copy:(Ljava/lang/String;II)Lcom/gildedrose/Item;
      43: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #21                 // Field name:Ljava/lang/String;
       4: invokevirtual #66                 // Method java/lang/String.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #25                 // Field sellIn:I
      16: invokestatic  #71                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #28                 // Field quality:I
      29: invokestatic  #71                 // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class com/gildedrose/Item
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class com/gildedrose/Item
      20: astore_2
      21: aload_0
      22: getfield      #21                 // Field name:Ljava/lang/String;
      25: aload_2
      26: getfield      #21                 // Field name:Ljava/lang/String;
      29: invokestatic  #79                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #25                 // Field sellIn:I
      41: aload_2
      42: getfield      #25                 // Field sellIn:I
      45: if_icmpeq     50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #28                 // Field quality:I
      54: aload_2
      55: getfield      #28                 // Field quality:I
      58: if_icmpeq     63
      61: iconst_0
      62: ireturn
      63: iconst_1
      64: ireturn
}

Compiled from "Item.kt"
public final class com.gildedrose.ItemKt {
  public static final com.gildedrose.Item ageBy(com.gildedrose.Item, int);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aconst_null
       8: aload_0
       9: iload_1
      10: invokestatic  #19                 // Method remainingSellInAfter:(Lcom/gildedrose/Item;I)I
      13: aload_0
      14: iload_1
      15: invokestatic  #22                 // Method qualityIn:(Lcom/gildedrose/Item;I)I
      18: iconst_1
      19: aconst_null
      20: invokestatic  #28                 // Method com/gildedrose/Item.copy$default:(Lcom/gildedrose/Item;Ljava/lang/String;IIILjava/lang/Object;)Lcom/gildedrose/Item;
      23: areturn

  private static final int remainingSellInAfter(com.gildedrose.Item, int);
    Code:
       0: aload_0
       1: invokevirtual #36                 // Method com/gildedrose/Item.getName:()Ljava/lang/String;
       4: ldc           #38                 // String Sulfuras, Hand of Ragnaros
       6: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       9: ifeq          19
      12: aload_0
      13: invokevirtual #46                 // Method com/gildedrose/Item.getSellIn:()I
      16: goto          25
      19: aload_0
      20: invokevirtual #46                 // Method com/gildedrose/Item.getSellIn:()I
      23: iload_1
      24: isub
      25: ireturn

  private static final int qualityIn(com.gildedrose.Item, int);
    Code:
       0: nop
       1: aload_0
       2: invokevirtual #36                 // Method com/gildedrose/Item.getName:()Ljava/lang/String;
       5: ldc           #49                 // String Backstage passes to a TAFKAL80ETC concert
       7: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      10: ifeq          29
      13: aload_0
      14: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
      17: aload_0
      18: iload_1
      19: invokestatic  #55                 // Method incrementQualityFor:(Lcom/gildedrose/Item;I)I
      22: iadd
      23: invokestatic  #59                 // Method boundedQuality:(I)I
      26: goto          113
      29: aload_0
      30: invokevirtual #36                 // Method com/gildedrose/Item.getName:()Ljava/lang/String;
      33: ldc           #38                 // String Sulfuras, Hand of Ragnaros
      35: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      38: ifeq          48
      41: aload_0
      42: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
      45: goto          113
      48: aload_0
      49: invokevirtual #36                 // Method com/gildedrose/Item.getName:()Ljava/lang/String;
      52: ldc           #61                 // String Aged Brie
      54: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      57: ifeq          72
      60: aload_0
      61: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
      64: iload_1
      65: iadd
      66: invokestatic  #59                 // Method boundedQuality:(I)I
      69: goto          113
      72: aload_0
      73: invokevirtual #36                 // Method com/gildedrose/Item.getName:()Ljava/lang/String;
      76: ldc           #63                 // String Conjured
      78: iconst_0
      79: iconst_2
      80: aconst_null
      81: invokestatic  #69                 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      84: ifeq          102
      87: aload_0
      88: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
      91: bipush        -2
      93: iload_1
      94: imul
      95: iadd
      96: invokestatic  #59                 // Method boundedQuality:(I)I
      99: goto          113
     102: aload_0
     103: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
     106: iconst_m1
     107: iload_1
     108: imul
     109: iadd
     110: invokestatic  #59                 // Method boundedQuality:(I)I
     113: ireturn

  private static final int boundedQuality(int);
    Code:
       0: bipush        50
       2: iconst_0
       3: iload_0
       4: invokestatic  #76                 // Method java/lang/Integer.max:(II)I
       7: invokestatic  #79                 // Method java/lang/Integer.min:(II)I
      10: ireturn

  private static final int incrementQualityFor(com.gildedrose.Item, int);
    Code:
       0: aload_0
       1: invokevirtual #46                 // Method com/gildedrose/Item.getSellIn:()I
       4: istore_2
       5: iconst_1
       6: iload_1
       7: iconst_1
       8: iadd
       9: invokestatic  #86                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      12: checkcast     #88                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: iconst_0
      20: istore        5
      22: iload         4
      24: istore        6
      26: aload_3
      27: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      32: astore        7
      34: aload         7
      36: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          84
      44: aload         7
      46: checkcast     #100                // class kotlin/collections/IntIterator
      49: invokevirtual #103                // Method kotlin/collections/IntIterator.nextInt:()I
      52: istore        8
      54: iload         6
      56: iload         8
      58: istore        9
      60: istore        10
      62: iconst_0
      63: istore        11
      65: iload         10
      67: iload_2
      68: iload         9
      70: isub
      71: aload_0
      72: invokevirtual #52                 // Method com/gildedrose/Item.getQuality:()I
      75: invokestatic  #106                // Method accelerateQualityWhenExpiring:(II)I
      78: iadd
      79: istore        6
      81: goto          34
      84: iload         6
      86: ireturn

  private static final int accelerateQualityWhenExpiring(int, int);
    Code:
       0: nop
       1: iload_0
       2: ifge          10
       5: iload_1
       6: ineg
       7: goto          30
      10: iload_0
      11: iconst_5
      12: if_icmpgt     19
      15: iconst_3
      16: goto          30
      19: iload_0
      20: bipush        10
      22: if_icmpgt     29
      25: iconst_2
      26: goto          30
      29: iconst_1
      30: ireturn
}


package it.unipd.stage.sl.lib.rsa

import java.math.BigInteger

/*
The following functions come from
https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation
 */

/**
 * @return true is a big integer is probably prime with certainty 15
 */
fun BigInteger.isPrime(): Boolean {
    // not 100% correct, but error is very low and for this type of application it's good enough
    return this.isProbablePrime(15)
}

/**
 * @param n1 a non null positive big integer
 * @param n2 a non null positive big integer
 * @return true if n1 and n2 are coprime
 */
fun areCoprime(n1: BigInteger, n2: BigInteger): Boolean {
    return gcd(n1, n2) == BigInteger.ONE
}

/**
 * from https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/
 * @param a a non null positive big integer
 * @param b a non null positive big integer
 * @return greatest common divisor between a and b
 */
fun gcd(a: BigInteger, b: BigInteger): BigInteger {
    return if (a == BigInteger.ZERO) b else gcd(b % a, a)
}

/**
 * @param n1 a non null positive big integer
 * @param n2 a non null positive big integer
 * @return least common multiple between n1 and n2
 */
fun lcm(n1: BigInteger, n2: BigInteger): BigInteger {
    return n1.multiply(n2).divide(gcd(n1, n2))
}

/**
 * Returns modulo inverse of 'a' with respect to 'm' using extended Euclid
 * Algorithm Assumption: 'a' and 'm' are coprimes
 * from https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
 *
 * @param a non null positive big integer
 * @param m non null positive big integer
 */
fun modInverse(a: BigInteger, m: BigInteger): BigInteger {
    // note: mapping to rsa: a = e, m= y, result = d
    var a1 = a
    var m1 = m
    val m0 = m1
    var y = BigInteger.ZERO
    var x = BigInteger.ONE
    if (m1 == BigInteger.ONE) return BigInteger.ZERO
    while (a1 > BigInteger.ONE) {
        // q is the quotient
        val q = a1 / m1
        var t = m1
        // m is the remainder now, process same as Euclid's algo
        m1 = a1 % m1
        a1 = t
        t = y
        // Update x and y
        y = x - q * y
        x = t
    }
    // Make x positive
    if (x < BigInteger.ZERO) x += m0
    return x
}

/**
 * Naive approach to factorize a number.
 * Note that this does not always return all factors, but a set such that
 * each element of the set may be a factor multiple times
 * and/or the last factor is obtained from the set as n/prod(set)
 *
 * @param n non null positive big integer
 * @return set of factors
 */
fun factorize(n: BigInteger): Set<BigInteger> {
    val set = mutableSetOf<BigInteger>()
    // first test 2 and 3
    if (n % BigInteger("2") == BigInteger.ZERO) set.add(BigInteger("2")) // for some reason BigInteger.TWO does not work with shadowjar
    if (n % BigInteger("3") == BigInteger.ZERO) set.add(BigInteger("3"))
    // use 6k+1 rule
    var i = BigInteger("5")
    while (i*i <= n) {
        if (n%i == BigInteger.ZERO) {
            set.add(i)
        }
        if (n%(i+ BigInteger("2")) == BigInteger.ZERO) {
            set.add(i+ BigInteger("2"))
        }
        i += BigInteger("6")
    }
    return set
}

/**
 * Return a list of all the prime factors of n
 *
 * @param n non null positive big integer
 * @return list of prime factors (may be repated)
 */
fun factorizeFull(n: BigInteger): List<BigInteger> {
    val list = mutableListOf<BigInteger>()
    val set = factorize(n)
    list.addAll(set)
    val prod = set.reduce { acc, bigInteger -> acc*bigInteger }
    var residual = n / prod
    while (residual > BigInteger.ONE) {
        set.forEach{
            while (residual % it == BigInteger.ZERO) {
                list.add(it)
                residual /= it
            }
        }
        if (residual.isPrime()) {
            list.add(residual)
            break
        }
    }
    return list
}

Compiled from "RsaUtils.kt"
public final class it.unipd.stage.sl.lib.rsa.RsaUtilsKt {
  public static final boolean isPrime(java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #9                  // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: bipush        15
       9: invokevirtual #21                 // Method java/math/BigInteger.isProbablePrime:(I)Z
      12: ireturn

  public static final boolean areCoprime(java.math.BigInteger, java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #27                 // String n1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #29                 // String n2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokestatic  #33                 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
      17: getstatic     #36                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      20: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      23: ireturn

  public static final java.math.BigInteger gcd(java.math.BigInteger, java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #42                 // String a
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #44                 // String b
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      16: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      19: ifeq          26
      22: aload_1
      23: goto          41
      26: aload_1
      27: aload_0
      28: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      31: dup
      32: ldc           #53                 // String remainder(...)
      34: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      37: aload_0
      38: invokestatic  #33                 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
      41: areturn

  public static final java.math.BigInteger lcm(java.math.BigInteger, java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #27                 // String n1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #29                 // String n2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokevirtual #60                 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      17: aload_0
      18: aload_1
      19: invokestatic  #33                 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;
      22: invokevirtual #63                 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      25: dup
      26: ldc           #65                 // String divide(...)
      28: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      31: areturn

  public static final java.math.BigInteger modInverse(java.math.BigInteger, java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #42                 // String a
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #68                 // String m
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: aload_1
      15: astore_3
      16: aload_3
      17: astore        4
      19: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      22: astore        5
      24: getstatic     #36                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      27: astore        6
      29: aload_3
      30: getstatic     #36                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      33: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      36: ifeq          49
      39: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      42: dup
      43: ldc           #69                 // String ZERO
      45: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      48: areturn
      49: aload_2
      50: getstatic     #36                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      53: invokevirtual #73                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
      56: ifle          166
      59: aload_2
      60: aload_3
      61: invokevirtual #63                 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      64: dup
      65: ldc           #65                 // String divide(...)
      67: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      70: astore        7
      72: aload_3
      73: astore        8
      75: aload_2
      76: aload_3
      77: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      80: dup
      81: ldc           #53                 // String remainder(...)
      83: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      86: astore_3
      87: aload         8
      89: astore_2
      90: aload         5
      92: astore        9
      94: aload         9
      96: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      99: aload         9
     101: astore        8
     103: aload         6
     105: astore        9
     107: aload         9
     109: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     112: aload         9
     114: astore        9
     116: aload         7
     118: astore        10
     120: aload         5
     122: astore        11
     124: aload         11
     126: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     129: aload         10
     131: aload         11
     133: invokevirtual #60                 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     136: dup
     137: ldc           #79                 // String multiply(...)
     139: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     142: astore        10
     144: aload         9
     146: aload         10
     148: invokevirtual #82                 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     151: dup
     152: ldc           #84                 // String subtract(...)
     154: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     157: astore        5
     159: aload         8
     161: astore        6
     163: goto          49
     166: aload         6
     168: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     171: invokevirtual #73                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
     174: ifge          201
     177: aload         6
     179: astore        7
     181: aload         7
     183: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     186: aload         7
     188: aload         4
     190: invokevirtual #87                 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     193: dup
     194: ldc           #89                 // String add(...)
     196: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     199: astore        6
     201: aload         6
     203: astore        7
     205: aload         7
     207: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     210: aload         7
     212: areturn

  public static final java.util.Set<java.math.BigInteger> factorize(java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #101                // String n
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #103                // class java/util/LinkedHashSet
       9: dup
      10: invokespecial #107                // Method java/util/LinkedHashSet."<init>":()V
      13: checkcast     #109                // class java/util/Set
      16: astore_1
      17: aload_0
      18: new           #17                 // class java/math/BigInteger
      21: dup
      22: ldc           #111                // String 2
      24: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      27: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      30: dup
      31: ldc           #53                 // String remainder(...)
      33: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      36: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      39: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      42: ifeq          61
      45: aload_1
      46: new           #17                 // class java/math/BigInteger
      49: dup
      50: ldc           #111                // String 2
      52: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      55: invokeinterface #117,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
      60: pop
      61: aload_0
      62: new           #17                 // class java/math/BigInteger
      65: dup
      66: ldc           #119                // String 3
      68: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      71: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
      74: dup
      75: ldc           #53                 // String remainder(...)
      77: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      80: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      83: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      86: ifeq          105
      89: aload_1
      90: new           #17                 // class java/math/BigInteger
      93: dup
      94: ldc           #119                // String 3
      96: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
      99: invokeinterface #117,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     104: pop
     105: new           #17                 // class java/math/BigInteger
     108: dup
     109: ldc           #121                // String 5
     111: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
     114: astore_2
     115: aload_2
     116: aload_2
     117: invokevirtual #60                 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     120: dup
     121: ldc           #79                 // String multiply(...)
     123: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     126: aload_0
     127: invokevirtual #73                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
     130: ifgt          248
     133: aload_0
     134: aload_2
     135: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     138: dup
     139: ldc           #53                 // String remainder(...)
     141: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     144: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     147: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     150: ifeq          161
     153: aload_1
     154: aload_2
     155: invokeinterface #117,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     160: pop
     161: aload_0
     162: aload_2
     163: new           #17                 // class java/math/BigInteger
     166: dup
     167: ldc           #111                // String 2
     169: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
     172: invokevirtual #87                 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     175: dup
     176: ldc           #89                 // String add(...)
     178: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     181: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     184: dup
     185: ldc           #53                 // String remainder(...)
     187: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     190: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     193: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     196: ifeq          225
     199: aload_1
     200: aload_2
     201: new           #17                 // class java/math/BigInteger
     204: dup
     205: ldc           #111                // String 2
     207: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
     210: invokevirtual #87                 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     213: dup
     214: ldc           #89                 // String add(...)
     216: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     219: invokeinterface #117,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     224: pop
     225: aload_2
     226: new           #17                 // class java/math/BigInteger
     229: dup
     230: ldc           #123                // String 6
     232: invokespecial #114                // Method java/math/BigInteger."<init>":(Ljava/lang/String;)V
     235: invokevirtual #87                 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     238: dup
     239: ldc           #89                 // String add(...)
     241: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     244: astore_2
     245: goto          115
     248: aload_1
     249: areturn

  public static final java.util.List<java.math.BigInteger> factorizeFull(java.math.BigInteger);
    Code:
       0: aload_0
       1: ldc           #101                // String n
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #131                // class java/util/ArrayList
       9: dup
      10: invokespecial #132                // Method java/util/ArrayList."<init>":()V
      13: checkcast     #134                // class java/util/List
      16: astore_1
      17: aload_0
      18: invokestatic  #136                // Method factorize:(Ljava/math/BigInteger;)Ljava/util/Set;
      21: astore_2
      22: aload_1
      23: aload_2
      24: checkcast     #138                // class java/util/Collection
      27: invokeinterface #142,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
      32: pop
      33: aload_2
      34: checkcast     #144                // class java/lang/Iterable
      37: astore        4
      39: iconst_0
      40: istore        5
      42: aload         4
      44: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        6
      51: aload         6
      53: invokeinterface #154,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifne          71
      61: new           #156                // class java/lang/UnsupportedOperationException
      64: dup
      65: ldc           #158                // String Empty collection can\'t be reduced.
      67: invokespecial #159                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      70: athrow
      71: aload         6
      73: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      78: astore        7
      80: aload         6
      82: invokeinterface #154,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          131
      90: aload         7
      92: aload         6
      94: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      99: checkcast     #17                 // class java/math/BigInteger
     102: astore        8
     104: checkcast     #17                 // class java/math/BigInteger
     107: astore        9
     109: iconst_0
     110: istore        10
     112: aload         9
     114: aload         8
     116: invokevirtual #60                 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     119: dup
     120: ldc           #79                 // String multiply(...)
     122: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     125: nop
     126: astore        7
     128: goto          80
     131: aload         7
     133: checkcast     #17                 // class java/math/BigInteger
     136: astore_3
     137: aconst_null
     138: astore        4
     140: aload_0
     141: aload_3
     142: invokevirtual #63                 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     145: dup
     146: ldc           #65                 // String divide(...)
     148: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     151: astore        4
     153: aload         4
     155: getstatic     #36                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
     158: invokevirtual #73                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
     161: ifle          286
     164: aload_2
     165: checkcast     #144                // class java/lang/Iterable
     168: astore        5
     170: iconst_0
     171: istore        6
     173: aload         5
     175: invokeinterface #148,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     180: astore        7
     182: aload         7
     184: invokeinterface #154,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     189: ifeq          265
     192: aload         7
     194: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     199: astore        8
     201: aload         8
     203: checkcast     #17                 // class java/math/BigInteger
     206: astore        9
     208: iconst_0
     209: istore        10
     211: aload         4
     213: aload         9
     215: invokevirtual #51                 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     218: dup
     219: ldc           #53                 // String remainder(...)
     221: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     224: getstatic     #47                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     227: invokestatic  #40                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     230: ifeq          260
     233: aload_1
     234: aload         9
     236: invokeinterface #164,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     241: pop
     242: aload         4
     244: aload         9
     246: invokevirtual #63                 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     249: dup
     250: ldc           #65                 // String divide(...)
     252: invokestatic  #56                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     255: astore        4
     257: goto          211
     260: nop
     261: nop
     262: goto          182
     265: nop
     266: aload         4
     268: invokestatic  #166                // Method isPrime:(Ljava/math/BigInteger;)Z
     271: ifeq          153
     274: aload_1
     275: aload         4
     277: invokeinterface #164,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     282: pop
     283: goto          286
     286: aload_1
     287: areturn
}


package coil3.test.utils

import kotlin.math.pow
import kotlin.math.roundToInt
import kotlin.math.sqrt

/**
 * Returns the cross correlation between two arrays.
 *
 * https://en.wikipedia.org/wiki/Cross-correlation
 */
fun crossCorrelation(x: IntArray, y: IntArray): Double {
    require(x.count() == y.count()) { "Input arrays must be of equal size." }

    val xVar = x.variance()
    val yVar = y.variance()
    val squaredVariance = sqrt(xVar * yVar)

    val xAvg = x.average()
    val yAvg = y.average()
    val count = x.count()

    var sum = 0.0
    for (index in 0 until count) {
        sum += (x[index] - xAvg) * (y[index] - yAvg)
    }
    return sum / count / squaredVariance
}

/**
 * Returns the cross correlation between two arrays.
 *
 * https://en.wikipedia.org/wiki/Cross-correlation
 */
fun crossCorrelation(x: ByteArray, y: ByteArray): Double {
    require(x.count() == y.count()) { "Input arrays must be of equal size." }

    val xVar = x.variance()
    val yVar = y.variance()
    val squaredVariance = sqrt(xVar * yVar)

    val xAvg = x.average()
    val yAvg = y.average()
    val count = x.count()

    var sum = 0.0
    for (index in 0 until count) {
        sum += (x[index] - xAvg) * (y[index] - yAvg)
    }
    return sum / count / squaredVariance
}

/**
 * Returns an average value of elements in the array.
 */
fun IntArray.variance(): Double {
    if (isEmpty()) return Double.NaN
    val average = average()
    return sumOf { (it - average).pow(2) } / count()
}

/**
 * Returns an average value of elements in the array.
 */
fun ByteArray.variance(): Double {
    if (isEmpty()) return Double.NaN
    val average = average()
    return sumOf { (it - average).pow(2) } / count()
}

/**
 * Round the given value to the nearest [Double] with [precision] number of decimal places.
 */
fun Double.round(precision: Int): Double {
    val multiplier = 10.0.pow(precision)
    return (this * multiplier).roundToInt() / multiplier
}

Compiled from "maths.kt"
public final class coil3.test.utils.MathsKt {
  public static final double crossCorrelation(int[], int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String x
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String y
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: arraylength
      14: aload_1
      15: arraylength
      16: if_icmpne     23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: ifne          44
      27: iconst_0
      28: istore_3
      29: ldc           #19                 // String Input arrays must be of equal size.
      31: astore_3
      32: new           #21                 // class java/lang/IllegalArgumentException
      35: dup
      36: aload_3
      37: invokevirtual #25                 // Method java/lang/Object.toString:()Ljava/lang/String;
      40: invokespecial #29                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      43: athrow
      44: aload_0
      45: invokestatic  #33                 // Method variance:([I)D
      48: dstore_2
      49: aload_1
      50: invokestatic  #33                 // Method variance:([I)D
      53: dstore        4
      55: dload_2
      56: dload         4
      58: dmul
      59: invokestatic  #39                 // Method java/lang/Math.sqrt:(D)D
      62: dstore        6
      64: aload_0
      65: invokestatic  #44                 // Method kotlin/collections/ArraysKt.average:([I)D
      68: dstore        8
      70: aload_1
      71: invokestatic  #44                 // Method kotlin/collections/ArraysKt.average:([I)D
      74: dstore        10
      76: aload_0
      77: arraylength
      78: istore        12
      80: dconst_0
      81: dstore        13
      83: iconst_0
      84: istore        15
      86: iload         15
      88: iload         12
      90: if_icmpge     121
      93: dload         13
      95: aload_0
      96: iload         15
      98: iaload
      99: i2d
     100: dload         8
     102: dsub
     103: aload_1
     104: iload         15
     106: iaload
     107: i2d
     108: dload         10
     110: dsub
     111: dmul
     112: dadd
     113: dstore        13
     115: iinc          15, 1
     118: goto          86
     121: dload         13
     123: iload         12
     125: i2d
     126: ddiv
     127: dload         6
     129: ddiv
     130: dreturn

  public static final double crossCorrelation(byte[], byte[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String x
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String y
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: arraylength
      14: aload_1
      15: arraylength
      16: if_icmpne     23
      19: iconst_1
      20: goto          24
      23: iconst_0
      24: ifne          44
      27: iconst_0
      28: istore_3
      29: ldc           #19                 // String Input arrays must be of equal size.
      31: astore_3
      32: new           #21                 // class java/lang/IllegalArgumentException
      35: dup
      36: aload_3
      37: invokevirtual #25                 // Method java/lang/Object.toString:()Ljava/lang/String;
      40: invokespecial #29                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      43: athrow
      44: aload_0
      45: invokestatic  #61                 // Method variance:([B)D
      48: dstore_2
      49: aload_1
      50: invokestatic  #61                 // Method variance:([B)D
      53: dstore        4
      55: dload_2
      56: dload         4
      58: dmul
      59: invokestatic  #39                 // Method java/lang/Math.sqrt:(D)D
      62: dstore        6
      64: aload_0
      65: invokestatic  #63                 // Method kotlin/collections/ArraysKt.average:([B)D
      68: dstore        8
      70: aload_1
      71: invokestatic  #63                 // Method kotlin/collections/ArraysKt.average:([B)D
      74: dstore        10
      76: aload_0
      77: arraylength
      78: istore        12
      80: dconst_0
      81: dstore        13
      83: iconst_0
      84: istore        15
      86: iload         15
      88: iload         12
      90: if_icmpge     121
      93: dload         13
      95: aload_0
      96: iload         15
      98: baload
      99: i2d
     100: dload         8
     102: dsub
     103: aload_1
     104: iload         15
     106: baload
     107: i2d
     108: dload         10
     110: dsub
     111: dmul
     112: dadd
     113: dstore        13
     115: iinc          15, 1
     118: goto          86
     121: dload         13
     123: iload         12
     125: i2d
     126: ddiv
     127: dload         6
     129: ddiv
     130: dreturn

  public static final double variance(int[]);
    Code:
       0: aload_0
       1: ldc           #68                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: arraylength
       8: ifne          15
      11: iconst_1
      12: goto          16
      15: iconst_0
      16: ifeq          23
      19: ldc2_w        #69                 // double NaNd
      22: dreturn
      23: aload_0
      24: invokestatic  #44                 // Method kotlin/collections/ArraysKt.average:([I)D
      27: dstore_1
      28: aload_0
      29: astore_3
      30: dconst_0
      31: dstore        4
      33: iconst_0
      34: istore        6
      36: aload_3
      37: arraylength
      38: istore        7
      40: iload         6
      42: iload         7
      44: if_icmpge     90
      47: aload_3
      48: iload         6
      50: iaload
      51: istore        8
      53: dload         4
      55: iload         8
      57: istore        9
      59: dstore        11
      61: iconst_0
      62: istore        10
      64: iload         9
      66: i2d
      67: dload_1
      68: dsub
      69: iconst_2
      70: i2d
      71: invokestatic  #74                 // Method java/lang/Math.pow:(DD)D
      74: nop
      75: dstore        13
      77: dload         11
      79: dload         13
      81: dadd
      82: dstore        4
      84: iinc          6, 1
      87: goto          40
      90: dload         4
      92: aload_0
      93: arraylength
      94: i2d
      95: ddiv
      96: dreturn

  public static final double variance(byte[]);
    Code:
       0: aload_0
       1: ldc           #68                 // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: arraylength
       8: ifne          15
      11: iconst_1
      12: goto          16
      15: iconst_0
      16: ifeq          23
      19: ldc2_w        #69                 // double NaNd
      22: dreturn
      23: aload_0
      24: invokestatic  #63                 // Method kotlin/collections/ArraysKt.average:([B)D
      27: dstore_1
      28: aload_0
      29: astore_3
      30: dconst_0
      31: dstore        4
      33: iconst_0
      34: istore        6
      36: aload_3
      37: arraylength
      38: istore        7
      40: iload         6
      42: iload         7
      44: if_icmpge     90
      47: aload_3
      48: iload         6
      50: baload
      51: istore        8
      53: dload         4
      55: iload         8
      57: istore        9
      59: dstore        11
      61: iconst_0
      62: istore        10
      64: iload         9
      66: i2d
      67: dload_1
      68: dsub
      69: iconst_2
      70: i2d
      71: invokestatic  #74                 // Method java/lang/Math.pow:(DD)D
      74: nop
      75: dstore        13
      77: dload         11
      79: dload         13
      81: dadd
      82: dstore        4
      84: iinc          6, 1
      87: goto          40
      90: dload         4
      92: aload_0
      93: arraylength
      94: i2d
      95: ddiv
      96: dreturn

  public static final double round(double, int);
    Code:
       0: ldc2_w        #82                 // double 10.0d
       3: iload_2
       4: i2d
       5: invokestatic  #74                 // Method java/lang/Math.pow:(DD)D
       8: dstore_3
       9: dload_0
      10: dload_3
      11: dmul
      12: invokestatic  #89                 // Method kotlin/math/MathKt.roundToInt:(D)I
      15: i2d
      16: dload_3
      17: ddiv
      18: dreturn
}