import java.io.File

/**
 * https://adventofcode.com/2020/day/9
 */
fun main() {
    val weakNumber = star1()
    println(weakNumber)         // 85848519
    println(star2(weakNumber))  // 13414198
}

private fun input(): List<String> {
    return File("2020/december09.txt").readLines();
}

private val preambleSize = 25

private fun star1(): Long {
    val lines = input().map(String::toLong)
    for (lineNum in preambleSize until lines.size) {
        val num = lines[lineNum]
        var isWeak = true
        for (i in lineNum - preambleSize until lineNum) {
            val num1 = lines[i]
            for (j in i + 1 until lineNum) {
                val num2 = lines[j];
                if (num1 + num2 == num) {
                    isWeak = false
                }
            }
        }
        if (isWeak) {
            return num
        }
    }
    return -1L
}

private fun star2(weakNumber: Long): Long {
    val lines = input().map(String::toLong)
    var start = 0
    var end = 1
    var sum = lines[0] + lines[1]
    while (start < end && end < lines.size) {
        if (sum < weakNumber) {
            // increase window
            end++
            sum += lines[end]
        } else if (sum > weakNumber) {
            // decrease window
            sum -= lines[start]
            start++
        } else if (sum == weakNumber) {
            // find min + max within window
            var min = lines[start]
            var max = lines[start]
            for (i in start..end) {
                if (lines[i] > max) {
                    max = lines[i]
                } else if (lines[i] < min) {
                    min = lines[i]
                }
            }
            return min + max
        }
    }
    return -1L
}

Compiled from "december09.kt"
public final class December09Kt {
  private static final int preambleSize;

  public static final void main();
    Code:
       0: invokestatic  #10                 // Method star1:()J
       3: lstore_0
       4: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
       7: lload_0
       8: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      11: lload_0
      12: invokestatic  #26                 // Method star2:(J)J
      15: lstore_2
      16: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      19: lload_2
      20: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      23: return

  private static final java.util.List<java.lang.String> input();
    Code:
       0: new           #33                 // class java/io/File
       3: dup
       4: ldc           #35                 // String 2020/december09.txt
       6: invokespecial #39                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #45                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: areturn

  private static final long star1();
    Code:
       0: invokestatic  #47                 // Method input:()Ljava/util/List;
       3: checkcast     #49                 // class java/lang/Iterable
       6: astore_1
       7: iconst_0
       8: istore_2
       9: aload_1
      10: astore_3
      11: new           #51                 // class java/util/ArrayList
      14: dup
      15: aload_1
      16: bipush        10
      18: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #62                 // class java/util/Collection
      27: astore        4
      29: iconst_0
      30: istore        5
      32: aload_3
      33: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        6
      40: aload         6
      42: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          94
      50: aload         6
      52: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        7
      59: aload         4
      61: aload         7
      63: checkcast     #78                 // class java/lang/String
      66: astore        8
      68: astore        12
      70: iconst_0
      71: istore        9
      73: aload         8
      75: invokestatic  #84                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      78: nop
      79: invokestatic  #88                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      82: aload         12
      84: swap
      85: invokeinterface #92,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: goto          40
      94: aload         4
      96: checkcast     #94                 // class java/util/List
      99: nop
     100: astore_0
     101: getstatic     #98                 // Field preambleSize:I
     104: istore_1
     105: aload_0
     106: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
     111: istore_2
     112: iload_1
     113: iload_2
     114: if_icmpge     229
     117: aload_0
     118: iload_1
     119: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     124: checkcast     #108                // class java/lang/Number
     127: invokevirtual #111                // Method java/lang/Number.longValue:()J
     130: lstore_3
     131: iconst_1
     132: istore        5
     134: iload_1
     135: getstatic     #98                 // Field preambleSize:I
     138: isub
     139: istore        6
     141: iload         6
     143: iload_1
     144: if_icmpge     216
     147: aload_0
     148: iload         6
     150: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     155: checkcast     #108                // class java/lang/Number
     158: invokevirtual #111                // Method java/lang/Number.longValue:()J
     161: lstore        7
     163: iload         6
     165: iconst_1
     166: iadd
     167: istore        9
     169: iload         9
     171: iload_1
     172: if_icmpge     210
     175: aload_0
     176: iload         9
     178: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     183: checkcast     #108                // class java/lang/Number
     186: invokevirtual #111                // Method java/lang/Number.longValue:()J
     189: lstore        10
     191: lload         7
     193: lload         10
     195: ladd
     196: lload_3
     197: lcmp
     198: ifne          204
     201: iconst_0
     202: istore        5
     204: iinc          9, 1
     207: goto          169
     210: iinc          6, 1
     213: goto          141
     216: iload         5
     218: ifeq          223
     221: lload_3
     222: lreturn
     223: iinc          1, 1
     226: goto          112
     229: ldc2_w        #112                // long -1l
     232: lreturn

  private static final long star2(long);
    Code:
       0: invokestatic  #47                 // Method input:()Ljava/util/List;
       3: checkcast     #49                 // class java/lang/Iterable
       6: astore_3
       7: iconst_0
       8: istore        4
      10: aload_3
      11: astore        5
      13: new           #51                 // class java/util/ArrayList
      16: dup
      17: aload_3
      18: bipush        10
      20: invokestatic  #57                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #62                 // class java/util/Collection
      29: astore        6
      31: iconst_0
      32: istore        7
      34: aload         5
      36: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          97
      53: aload         8
      55: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        9
      62: aload         6
      64: aload         9
      66: checkcast     #78                 // class java/lang/String
      69: astore        10
      71: astore        13
      73: iconst_0
      74: istore        11
      76: aload         10
      78: invokestatic  #84                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      81: nop
      82: invokestatic  #88                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      85: aload         13
      87: swap
      88: invokeinterface #92,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          43
      97: aload         6
      99: checkcast     #94                 // class java/util/List
     102: nop
     103: astore_2
     104: iconst_0
     105: istore_3
     106: iconst_1
     107: istore        4
     109: aload_2
     110: iconst_0
     111: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     116: checkcast     #108                // class java/lang/Number
     119: invokevirtual #111                // Method java/lang/Number.longValue:()J
     122: aload_2
     123: iconst_1
     124: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #108                // class java/lang/Number
     132: invokevirtual #111                // Method java/lang/Number.longValue:()J
     135: ladd
     136: lstore        5
     138: iload_3
     139: iload         4
     141: if_icmpge     363
     144: iload         4
     146: aload_2
     147: invokeinterface #102,  1          // InterfaceMethod java/util/List.size:()I
     152: if_icmpge     363
     155: lload         5
     157: lload_0
     158: lcmp
     159: ifge          187
     162: iinc          4, 1
     165: lload         5
     167: aload_2
     168: iload         4
     170: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     175: checkcast     #108                // class java/lang/Number
     178: invokevirtual #111                // Method java/lang/Number.longValue:()J
     181: ladd
     182: lstore        5
     184: goto          138
     187: lload         5
     189: lload_0
     190: lcmp
     191: ifle          218
     194: lload         5
     196: aload_2
     197: iload_3
     198: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     203: checkcast     #108                // class java/lang/Number
     206: invokevirtual #111                // Method java/lang/Number.longValue:()J
     209: lsub
     210: lstore        5
     212: iinc          3, 1
     215: goto          138
     218: lload         5
     220: lload_0
     221: lcmp
     222: ifne          138
     225: aload_2
     226: iload_3
     227: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     232: checkcast     #108                // class java/lang/Number
     235: invokevirtual #111                // Method java/lang/Number.longValue:()J
     238: lstore        7
     240: aload_2
     241: iload_3
     242: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     247: checkcast     #108                // class java/lang/Number
     250: invokevirtual #111                // Method java/lang/Number.longValue:()J
     253: lstore        9
     255: iload_3
     256: istore        11
     258: iload         4
     260: istore        12
     262: iload         11
     264: iload         12
     266: if_icmpgt     357
     269: aload_2
     270: iload         11
     272: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     277: checkcast     #108                // class java/lang/Number
     280: invokevirtual #111                // Method java/lang/Number.longValue:()J
     283: lload         9
     285: lcmp
     286: ifle          308
     289: aload_2
     290: iload         11
     292: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     297: checkcast     #108                // class java/lang/Number
     300: invokevirtual #111                // Method java/lang/Number.longValue:()J
     303: lstore        9
     305: goto          344
     308: aload_2
     309: iload         11
     311: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     316: checkcast     #108                // class java/lang/Number
     319: invokevirtual #111                // Method java/lang/Number.longValue:()J
     322: lload         7
     324: lcmp
     325: ifge          344
     328: aload_2
     329: iload         11
     331: invokeinterface #106,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     336: checkcast     #108                // class java/lang/Number
     339: invokevirtual #111                // Method java/lang/Number.longValue:()J
     342: lstore        7
     344: iload         11
     346: iload         12
     348: if_icmpeq     357
     351: iinc          11, 1
     354: goto          269
     357: lload         7
     359: lload         9
     361: ladd
     362: lreturn
     363: ldc2_w        #112                // long -1l
     366: lreturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #144                // Method main:()V
       3: return

  static {};
    Code:
       0: bipush        25
       2: putstatic     #98                 // Field preambleSize:I
       5: return
}


import java.io.File

/**
 * https://adventofcode.com/2020/day/10
 */
fun main() {
    println(star1()) // 1998
    println(star2()) // 347250213298688
}

private fun input(): List<String> {
    return File("2020/december10.txt").readLines();
}

private fun star1(): Int {
    val adapters = input().map(String::toLong).sorted()
    var prev = 0L
    var ones = 0
    var threes = 0
    for (curr in adapters) {
        if (curr - prev == 3L) {
            threes++
        } else if (curr - prev == 1L) {
            ones++
        }
        prev = curr
    }
    // your device's built-in adapter is always 3 higher than the highest adapter
    threes++

    //println("${ones} * ${threes}")
    return ones * threes
}

private fun star2(): Long {
    val adapters = input().map(String::toLong).sorted()
    var prev1 = 0L
    var prev1paths = 1L
    var prev2 = -99L
    var prev2paths = 1L
    var prev3 = -99L
    var prev3paths = 1L

    for (curr in adapters) {
        var pathsToCurr = 0L
        if (curr - prev1 <= 3L) {
            pathsToCurr += prev1paths
        }
        if (curr - prev2 <= 3L) {
            pathsToCurr += prev2paths
        }
        if (curr - prev3 <= 3L) {
            pathsToCurr += prev3paths
        }
        prev3 = prev2
        prev2 = prev1
        prev1 = curr
        prev3paths = prev2paths
        prev2paths = prev1paths
        prev1paths = pathsToCurr
    }
    return prev1paths
}

Compiled from "december10.kt"
public final class December10Kt {
  public static final void main();
    Code:
       0: invokestatic  #10                 // Method star1:()I
       3: istore_0
       4: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
       7: iload_0
       8: invokevirtual #22                 // Method java/io/PrintStream.println:(I)V
      11: invokestatic  #26                 // Method star2:()J
      14: lstore_0
      15: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      18: lload_0
      19: invokevirtual #29                 // Method java/io/PrintStream.println:(J)V
      22: return

  private static final java.util.List<java.lang.String> input();
    Code:
       0: new           #34                 // class java/io/File
       3: dup
       4: ldc           #36                 // String 2020/december10.txt
       6: invokespecial #40                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #46                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: areturn

  private static final int star1();
    Code:
       0: invokestatic  #48                 // Method input:()Ljava/util/List;
       3: checkcast     #50                 // class java/lang/Iterable
       6: astore_1
       7: iconst_0
       8: istore_2
       9: aload_1
      10: astore_3
      11: new           #52                 // class java/util/ArrayList
      14: dup
      15: aload_1
      16: bipush        10
      18: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #62                 // class java/util/Collection
      27: astore        4
      29: iconst_0
      30: istore        5
      32: aload_3
      33: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        6
      40: aload         6
      42: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          94
      50: aload         6
      52: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        7
      59: aload         4
      61: aload         7
      63: checkcast     #78                 // class java/lang/String
      66: astore        8
      68: astore        10
      70: iconst_0
      71: istore        9
      73: aload         8
      75: invokestatic  #84                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      78: nop
      79: invokestatic  #88                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      82: aload         10
      84: swap
      85: invokeinterface #92,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: goto          40
      94: aload         4
      96: checkcast     #94                 // class java/util/List
      99: nop
     100: checkcast     #50                 // class java/lang/Iterable
     103: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     106: astore_0
     107: lconst_0
     108: lstore_1
     109: iconst_0
     110: istore_3
     111: iconst_0
     112: istore        4
     114: aload_0
     115: invokeinterface #99,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     120: astore        5
     122: aload         5
     124: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     129: ifeq          182
     132: aload         5
     134: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     139: checkcast     #101                // class java/lang/Number
     142: invokevirtual #104                // Method java/lang/Number.longValue:()J
     145: lstore        6
     147: lload         6
     149: lload_1
     150: lsub
     151: ldc2_w        #105                // long 3l
     154: lcmp
     155: ifne          164
     158: iinc          4, 1
     161: goto          176
     164: lload         6
     166: lload_1
     167: lsub
     168: lconst_1
     169: lcmp
     170: ifne          176
     173: iinc          3, 1
     176: lload         6
     178: lstore_1
     179: goto          122
     182: iinc          4, 1
     185: iload_3
     186: iload         4
     188: imul
     189: ireturn

  private static final long star2();
    Code:
       0: invokestatic  #48                 // Method input:()Ljava/util/List;
       3: checkcast     #50                 // class java/lang/Iterable
       6: astore_1
       7: iconst_0
       8: istore_2
       9: aload_1
      10: astore_3
      11: new           #52                 // class java/util/ArrayList
      14: dup
      15: aload_1
      16: bipush        10
      18: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      21: invokespecial #60                 // Method java/util/ArrayList."<init>":(I)V
      24: checkcast     #62                 // class java/util/Collection
      27: astore        4
      29: iconst_0
      30: istore        5
      32: aload_3
      33: invokeinterface #66,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        6
      40: aload         6
      42: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          94
      50: aload         6
      52: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        7
      59: aload         4
      61: aload         7
      63: checkcast     #78                 // class java/lang/String
      66: astore        8
      68: astore        18
      70: iconst_0
      71: istore        9
      73: aload         8
      75: invokestatic  #84                 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      78: nop
      79: invokestatic  #88                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      82: aload         18
      84: swap
      85: invokeinterface #92,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      90: pop
      91: goto          40
      94: aload         4
      96: checkcast     #94                 // class java/util/List
      99: nop
     100: checkcast     #50                 // class java/lang/Iterable
     103: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     106: astore_0
     107: lconst_0
     108: lstore_1
     109: lconst_1
     110: lstore_3
     111: ldc2_w        #127                // long -99l
     114: lstore        5
     116: lconst_1
     117: lstore        7
     119: ldc2_w        #127                // long -99l
     122: lstore        9
     124: lconst_1
     125: lstore        11
     127: aload_0
     128: invokeinterface #99,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     133: astore        13
     135: aload         13
     137: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     142: ifeq          241
     145: aload         13
     147: invokeinterface #76,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     152: checkcast     #101                // class java/lang/Number
     155: invokevirtual #104                // Method java/lang/Number.longValue:()J
     158: lstore        14
     160: lconst_0
     161: lstore        16
     163: lload         14
     165: lload_1
     166: lsub
     167: ldc2_w        #105                // long 3l
     170: lcmp
     171: ifgt          180
     174: lload         16
     176: lload_3
     177: ladd
     178: lstore        16
     180: lload         14
     182: lload         5
     184: lsub
     185: ldc2_w        #105                // long 3l
     188: lcmp
     189: ifgt          199
     192: lload         16
     194: lload         7
     196: ladd
     197: lstore        16
     199: lload         14
     201: lload         9
     203: lsub
     204: ldc2_w        #105                // long 3l
     207: lcmp
     208: ifgt          218
     211: lload         16
     213: lload         11
     215: ladd
     216: lstore        16
     218: lload         5
     220: lstore        9
     222: lload_1
     223: lstore        5
     225: lload         14
     227: lstore_1
     228: lload         7
     230: lstore        11
     232: lload_3
     233: lstore        7
     235: lload         16
     237: lstore_3
     238: goto          135
     241: lload_3
     242: lreturn

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #139                // Method main:()V
       3: return
}


fun <T, C : MutableCollection<T>> Collection<T>.partitionTo(
    first: C,
    second: C,
    predicate: (T) -> Boolean
): Pair<C, C> {
    this.forEach { if (predicate(it)) first.add(it) else second.add(it) }
    return Pair(first, second)
}

fun partitionWordsAndLines() {
    val (words, lines) = listOf("a", "a b", "c", "d e")
        .partitionTo(ArrayList(), ArrayList()) { s -> !s.contains(" ") }
    check(words == listOf("a", "c"))
    check(lines == listOf("a b", "d e"))
}

fun partitionLettersAndOtherSymbols() {
    val (letters, other) = setOf('a', '%', 'r', '}')
        .partitionTo(HashSet(), HashSet()) { c -> c in 'a'..'z' || c in 'A'..'Z' }
    check(letters == setOf('a', 'r'))
    check(other == setOf('%', '}'))
}

Compiled from "Task.kt"
public final class TaskKt {
  public static final <T, C extends java.util.Collection<T>> kotlin.Pair<C, C> partitionTo(java.util.Collection<? extends T>, C, C, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String first
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #20                 // String second
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_3
      19: ldc           #22                 // String predicate
      21: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      24: aload_0
      25: checkcast     #24                 // class java/lang/Iterable
      28: astore        4
      30: iconst_0
      31: istore        5
      33: aload         4
      35: invokeinterface #28,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      40: astore        6
      42: aload         6
      44: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      49: ifeq          109
      52: aload         6
      54: invokeinterface #38,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        7
      61: aload         7
      63: astore        8
      65: iconst_0
      66: istore        9
      68: aload_3
      69: aload         8
      71: invokeinterface #44,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      76: checkcast     #46                 // class java/lang/Boolean
      79: invokevirtual #49                 // Method java/lang/Boolean.booleanValue:()Z
      82: ifeq          96
      85: aload_1
      86: aload         8
      88: invokeinterface #55,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: goto          104
      96: aload_2
      97: aload         8
      99: invokeinterface #55,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: nop
     106: goto          42
     109: nop
     110: new           #57                 // class kotlin/Pair
     113: dup
     114: aload_1
     115: aload_2
     116: invokespecial #61                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     119: areturn

  public static final void partitionWordsAndLines();
    Code:
       0: iconst_4
       1: anewarray     #76                 // class java/lang/String
       4: astore_1
       5: aload_1
       6: iconst_0
       7: ldc           #78                 // String a
       9: aastore
      10: aload_1
      11: iconst_1
      12: ldc           #80                 // String a b
      14: aastore
      15: aload_1
      16: iconst_2
      17: ldc           #82                 // String c
      19: aastore
      20: aload_1
      21: iconst_3
      22: ldc           #84                 // String d e
      24: aastore
      25: aload_1
      26: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      29: checkcast     #51                 // class java/util/Collection
      32: new           #92                 // class java/util/ArrayList
      35: dup
      36: invokespecial #94                 // Method java/util/ArrayList."<init>":()V
      39: checkcast     #51                 // class java/util/Collection
      42: new           #92                 // class java/util/ArrayList
      45: dup
      46: invokespecial #94                 // Method java/util/ArrayList."<init>":()V
      49: checkcast     #51                 // class java/util/Collection
      52: invokedynamic #112,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      57: invokestatic  #114                // Method partitionTo:(Ljava/util/Collection;Ljava/util/Collection;Ljava/util/Collection;Lkotlin/jvm/functions/Function1;)Lkotlin/Pair;
      60: astore_0
      61: aload_0
      62: invokevirtual #117                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      65: checkcast     #92                 // class java/util/ArrayList
      68: astore_1
      69: aload_0
      70: invokevirtual #120                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      73: checkcast     #92                 // class java/util/ArrayList
      76: astore_2
      77: aload_1
      78: iconst_2
      79: anewarray     #76                 // class java/lang/String
      82: astore_3
      83: aload_3
      84: iconst_0
      85: ldc           #78                 // String a
      87: aastore
      88: aload_3
      89: iconst_1
      90: ldc           #82                 // String c
      92: aastore
      93: aload_3
      94: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      97: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     100: ifne          113
     103: new           #126                // class java/lang/IllegalStateException
     106: dup
     107: ldc           #128                // String Check failed.
     109: invokespecial #131                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     112: athrow
     113: aload_2
     114: iconst_2
     115: anewarray     #76                 // class java/lang/String
     118: astore_3
     119: aload_3
     120: iconst_0
     121: ldc           #80                 // String a b
     123: aastore
     124: aload_3
     125: iconst_1
     126: ldc           #84                 // String d e
     128: aastore
     129: aload_3
     130: invokestatic  #90                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     133: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     136: ifne          149
     139: new           #126                // class java/lang/IllegalStateException
     142: dup
     143: ldc           #128                // String Check failed.
     145: invokespecial #131                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     148: athrow
     149: return

  public static final void partitionLettersAndOtherSymbols();
    Code:
       0: iconst_4
       1: anewarray     #139                // class java/lang/Character
       4: astore_1
       5: aload_1
       6: iconst_0
       7: bipush        97
       9: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      12: aastore
      13: aload_1
      14: iconst_1
      15: bipush        37
      17: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      20: aastore
      21: aload_1
      22: iconst_2
      23: bipush        114
      25: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      28: aastore
      29: aload_1
      30: iconst_3
      31: bipush        125
      33: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      36: aastore
      37: aload_1
      38: invokestatic  #149                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
      41: checkcast     #51                 // class java/util/Collection
      44: new           #151                // class java/util/HashSet
      47: dup
      48: invokespecial #152                // Method java/util/HashSet."<init>":()V
      51: checkcast     #51                 // class java/util/Collection
      54: new           #151                // class java/util/HashSet
      57: dup
      58: invokespecial #152                // Method java/util/HashSet."<init>":()V
      61: checkcast     #51                 // class java/util/Collection
      64: invokedynamic #160,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      69: invokestatic  #114                // Method partitionTo:(Ljava/util/Collection;Ljava/util/Collection;Ljava/util/Collection;Lkotlin/jvm/functions/Function1;)Lkotlin/Pair;
      72: astore_0
      73: aload_0
      74: invokevirtual #117                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      77: checkcast     #151                // class java/util/HashSet
      80: astore_1
      81: aload_0
      82: invokevirtual #120                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      85: checkcast     #151                // class java/util/HashSet
      88: astore_2
      89: aload_1
      90: iconst_2
      91: anewarray     #139                // class java/lang/Character
      94: astore_3
      95: aload_3
      96: iconst_0
      97: bipush        97
      99: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     102: aastore
     103: aload_3
     104: iconst_1
     105: bipush        114
     107: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     110: aastore
     111: aload_3
     112: invokestatic  #149                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
     115: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     118: ifne          131
     121: new           #126                // class java/lang/IllegalStateException
     124: dup
     125: ldc           #128                // String Check failed.
     127: invokespecial #131                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     130: athrow
     131: aload_2
     132: iconst_2
     133: anewarray     #139                // class java/lang/Character
     136: astore_3
     137: aload_3
     138: iconst_0
     139: bipush        37
     141: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     144: aastore
     145: aload_3
     146: iconst_1
     147: bipush        125
     149: invokestatic  #143                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     152: aastore
     153: aload_3
     154: invokestatic  #149                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
     157: invokestatic  #124                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     160: ifne          173
     163: new           #126                // class java/lang/IllegalStateException
     166: dup
     167: ldc           #128                // String Check failed.
     169: invokespecial #131                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     172: athrow
     173: return

  private static final boolean partitionWordsAndLines$lambda$1(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #167                // String s
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #169                // class java/lang/CharSequence
      10: ldc           #171                // String
      12: checkcast     #169                // class java/lang/CharSequence
      15: iconst_0
      16: iconst_2
      17: aconst_null
      18: invokestatic  #177                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z
      21: ifne          28
      24: iconst_1
      25: goto          29
      28: iconst_0
      29: ireturn

  private static final boolean partitionLettersAndOtherSymbols$lambda$2(char);
    Code:
       0: bipush        97
       2: iload_0
       3: if_icmpgt     20
       6: iload_0
       7: bipush        123
       9: if_icmpge     16
      12: iconst_1
      13: goto          21
      16: iconst_0
      17: goto          21
      20: iconst_0
      21: ifne          48
      24: bipush        65
      26: iload_0
      27: if_icmpgt     44
      30: iload_0
      31: bipush        91
      33: if_icmpge     40
      36: iconst_1
      37: goto          45
      40: iconst_0
      41: goto          45
      44: iconst_0
      45: ifeq          52
      48: iconst_1
      49: goto          53
      52: iconst_0
      53: ireturn
}


fun <T> swap(array: Array<T>, fstIndex: Int, sndIndex: Int) {
    val fstValue = array[fstIndex]
    array[fstIndex] = array[sndIndex]
    array[sndIndex] = fstValue
}

/** Selection sort: Find the smallest -> insert it to next position */
fun <T : Comparable<T>> selectionSort(array: Array<T>) {

    for (i in array.indices) {
        var curMinIndex = i
        for (j in (i + 1) until array.size) {
            if (array[j] < array[curMinIndex]) {
                curMinIndex = j
            }
        }
        swap(array, i, curMinIndex)
    }
}

/** Insertion sort: Assume everything before i is sorted.
 * Add another element to sorted part -> swap elements until current element is in it's correct place */
fun <T : Comparable<T>> insertionSort(array: Array<T>) {
    for (i in array.indices) {
        for (j in i downTo 1) {
            if (array[j] < array[j - 1]) {
                swap(array, j, j - 1)
            } else {
                break
            }
        }
    }
}

/** h-sort with sequence 3x+1 */
fun <T : Comparable<T>> shellSort(array: Array<T>) {
    var h = 1
    while (h < array.size / 3) {
        h = 3 * h + 1 // 1, 4, 13, 40...
    }

    while (h >= 1) {
        // h-sort array here with step == h
        for (i in h until array.size) {
            for (j in i downTo h step h) {
                if (array[j] < array[j - h]) {
                    swap(array, j, j - h)
                } else {
                    continue
                }
            }
        }

        h /= 3
    }
}

fun <T : Comparable<T>> mergeSort(array: Array<T>) {

    fun sort(array: Array<T>, auxArray: Array<T>, startIndex: Int, endIndex: Int) {

        if (endIndex <= startIndex) return
        val middle = startIndex + ((endIndex - startIndex) / 2)
        sort(array, auxArray, startIndex = 0, endIndex = middle)
        sort(array, auxArray, startIndex = middle + 1, endIndex = endIndex)

        merge(array, auxArray, leftStart = 0, leftEnd = middle, rightStart = middle + 1, rightEnd = endIndex)
    }

    val aux = array.copyOf()
    sort(array, aux, startIndex = 0, endIndex = array.lastIndex)
}

fun <T : Comparable<T>> bottomUpMergeSort(array: Array<T>) {
    val aux = array.copyOf()

    val n = array.size
    var step = 1
    while (step < n) { // this will iterate over arrays of 2, than 4, than 8, until the end

        var index = 0
        while (index < n - step) {
            merge(
                array,
                aux,
                leftStart = index,
                leftEnd = index + step - 1,
                rightStart = index + step,
                rightEnd = minOf(n - 1, index + step + step - 1)
            )
            index += step + step
        }
        step += step
    }

    /*
     * Implementation can be much shorter for language which support 3 part for-loops. It will be as simpel as
     * for (step = 1; step < n; step = step + step) {
     *     for (i = 0; i < n - step; i += step + step) {
     *         merge (array, aux, i, i + step - 1, i + step, minOf(n - 1, i + step + step - 1)
     *     }
     * }
     */
}

fun <T : Comparable<T>> merge(
    array: Array<T>,
    auxArray: Array<T>,
    leftStart: Int,
    leftEnd: Int,
    rightStart: Int,
    rightEnd: Int
) {
    for (i in leftStart..rightEnd) {
        auxArray[i] = array[i]
    }

    var left = leftStart
    var right = rightStart

    for (index in leftStart..rightEnd) {
        when {
            left > leftEnd -> {
                array[index] = auxArray[right]
                right++
            }
            right > rightEnd -> {
                array[index] = auxArray[left]
                left++
            }
            auxArray[left] <= auxArray[right] -> {
                array[index] = auxArray[left];
                left++
            }
            else -> {
                array[index] = auxArray[right];
                right++
            }
        }
    }
}

fun <T : Comparable<T>> quickSort(array: Array<T>) {

    fun partition(array: Array<T>, startLeft: Int, startRight: Int): Int {

        /*
        First element is used as partition element
        After outer while(true) loop completes, all element to the left of startLeft will be
        lower and all element to right of it will be higher.

        Here we start with startLeft and startRight + 1 because the first thing we do before comparing
        is ++left and --right
        */

        var left = startLeft
        var right = startRight + 1

        while (true) {

            while (array[++left] < array[startLeft]) {
                if (left == startRight) {
                    break
                }
            }

            while (array[startLeft] < array[--right]) {
                if (right == startLeft) {
                    break
                }
            }

            if (left >= right) break
            swap(array, left, right)
        }

        swap(array, startLeft, right)
        return right // right is now in place
    }

    fun sort(array: Array<T>, startLeft: Int, startRight: Int) {
        if (startRight <= startLeft) return

        val inCorrectPlaceIndex = partition(array, startLeft, startRight)

        sort(array, startLeft, inCorrectPlaceIndex - 1)
        sort(array, inCorrectPlaceIndex + 1, startRight)
    }

    array.shuffle()
    sort(array, 0, array.lastIndex)
}

Compiled from "sorts.kt"
public final class SortsKt {
  public static final <T> void swap(T[], int, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_1
       8: aaload
       9: astore_3
      10: aload_0
      11: iload_1
      12: aload_0
      13: iload_2
      14: aaload
      15: aastore
      16: aload_0
      17: iload_2
      18: aload_3
      19: aastore
      20: return

  public static final <T extends java.lang.Comparable<? super T>> void selectionSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: arraylength
      10: istore_2
      11: iload_1
      12: iload_2
      13: if_icmpge     70
      16: iload_1
      17: istore_3
      18: iload_1
      19: iconst_1
      20: iadd
      21: istore        4
      23: aload_0
      24: arraylength
      25: istore        5
      27: iload         4
      29: iload         5
      31: if_icmpge     58
      34: aload_0
      35: iload         4
      37: aaload
      38: aload_0
      39: iload_3
      40: aaload
      41: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      46: ifge          52
      49: iload         4
      51: istore_3
      52: iinc          4, 1
      55: goto          27
      58: aload_0
      59: iload_1
      60: iload_3
      61: invokestatic  #33                 // Method swap:([Ljava/lang/Object;II)V
      64: iinc          1, 1
      67: goto          11
      70: return

  public static final <T extends java.lang.Comparable<? super T>> void insertionSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: arraylength
      10: istore_2
      11: iload_1
      12: iload_2
      13: if_icmpge     65
      16: iload_1
      17: istore_3
      18: iconst_0
      19: iload_3
      20: if_icmpge     59
      23: aload_0
      24: iload_3
      25: aaload
      26: aload_0
      27: iload_3
      28: iconst_1
      29: isub
      30: aaload
      31: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      36: ifge          50
      39: aload_0
      40: iload_3
      41: iload_3
      42: iconst_1
      43: isub
      44: invokestatic  #33                 // Method swap:([Ljava/lang/Object;II)V
      47: goto          53
      50: goto          59
      53: iinc          3, -1
      56: goto          18
      59: iinc          1, 1
      62: goto          11
      65: return

  public static final <T extends java.lang.Comparable<? super T>> void shellSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore_1
       8: iload_1
       9: aload_0
      10: arraylength
      11: iconst_3
      12: idiv
      13: if_icmpge     25
      16: iconst_3
      17: iload_1
      18: imul
      19: iconst_1
      20: iadd
      21: istore_1
      22: goto          8
      25: iload_1
      26: iconst_1
      27: if_icmplt     175
      30: iload_1
      31: istore_2
      32: aload_0
      33: arraylength
      34: istore_3
      35: iload_2
      36: iload_3
      37: if_icmpge     168
      40: iload_1
      41: istore        4
      43: iload_1
      44: istore        5
      46: iload         5
      48: ifgt          84
      51: new           #41                 // class java/lang/IllegalArgumentException
      54: dup
      55: new           #43                 // class java/lang/StringBuilder
      58: dup
      59: invokespecial #47                 // Method java/lang/StringBuilder."<init>":()V
      62: ldc           #49                 // String Step must be positive, was:
      64: invokevirtual #53                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      67: iload         5
      69: invokevirtual #56                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      72: bipush        46
      74: invokevirtual #59                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      77: invokevirtual #63                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      80: invokespecial #66                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      83: athrow
      84: iload         5
      86: ineg
      87: istore        5
      89: iload_2
      90: istore        6
      92: iload_2
      93: iload         4
      95: iload         5
      97: invokestatic  #72                 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I
     100: istore        7
     102: iload         5
     104: istore        8
     106: iload         7
     108: iload         6
     110: if_icmpgt     162
     113: aload_0
     114: iload         6
     116: aaload
     117: aload_0
     118: iload         6
     120: iload_1
     121: isub
     122: aaload
     123: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     128: ifge          144
     131: aload_0
     132: iload         6
     134: iload         6
     136: iload_1
     137: isub
     138: invokestatic  #33                 // Method swap:([Ljava/lang/Object;II)V
     141: goto          145
     144: nop
     145: iload         6
     147: iload         7
     149: if_icmpeq     162
     152: iload         6
     154: iload         8
     156: iadd
     157: istore        6
     159: goto          113
     162: iinc          2, 1
     165: goto          35
     168: iload_1
     169: iconst_3
     170: idiv
     171: istore_1
     172: goto          25
     175: return

  public static final <T extends java.lang.Comparable<? super T>> void mergeSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: dup
       8: arraylength
       9: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
      12: dup
      13: ldc           #83                 // String copyOf(...)
      15: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: checkcast     #74                 // class "[Ljava/lang/Comparable;"
      21: astore_1
      22: aload_0
      23: aload_1
      24: iconst_0
      25: aload_0
      26: invokestatic  #92                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      29: invokestatic  #96                 // Method mergeSort$sort:([Ljava/lang/Comparable;[Ljava/lang/Comparable;II)V
      32: return

  public static final <T extends java.lang.Comparable<? super T>> void bottomUpMergeSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: dup
       8: arraylength
       9: invokestatic  #81                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
      12: dup
      13: ldc           #83                 // String copyOf(...)
      15: invokestatic  #86                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: checkcast     #74                 // class "[Ljava/lang/Comparable;"
      21: astore_1
      22: aload_0
      23: arraylength
      24: istore_2
      25: iconst_1
      26: istore_3
      27: iload_3
      28: iload_2
      29: if_icmpge     92
      32: iconst_0
      33: istore        4
      35: iload         4
      37: iload_2
      38: iload_3
      39: isub
      40: if_icmpge     85
      43: aload_0
      44: aload_1
      45: iload         4
      47: iload         4
      49: iload_3
      50: iadd
      51: iconst_1
      52: isub
      53: iload         4
      55: iload_3
      56: iadd
      57: iload_2
      58: iconst_1
      59: isub
      60: iload         4
      62: iload_3
      63: iadd
      64: iload_3
      65: iadd
      66: iconst_1
      67: isub
      68: invokestatic  #104                // Method java/lang/Math.min:(II)I
      71: invokestatic  #108                // Method merge:([Ljava/lang/Comparable;[Ljava/lang/Comparable;IIII)V
      74: iload         4
      76: iload_3
      77: iload_3
      78: iadd
      79: iadd
      80: istore        4
      82: goto          35
      85: iload_3
      86: iload_3
      87: iadd
      88: istore_3
      89: goto          27
      92: return

  public static final <T extends java.lang.Comparable<? super T>> void merge(T[], T[], int, int, int, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #114                // String auxArray
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: istore        6
      15: iload         6
      17: iload         5
      19: if_icmpgt     43
      22: aload_1
      23: iload         6
      25: aload_0
      26: iload         6
      28: aaload
      29: aastore
      30: iload         6
      32: iload         5
      34: if_icmpeq     43
      37: iinc          6, 1
      40: goto          22
      43: iload_2
      44: istore        6
      46: iload         4
      48: istore        7
      50: iload_2
      51: istore        8
      53: iload         8
      55: iload         5
      57: if_icmpgt     156
      60: nop
      61: iload         6
      63: iload_3
      64: if_icmple     81
      67: aload_0
      68: iload         8
      70: aload_1
      71: iload         7
      73: aaload
      74: aastore
      75: iinc          7, 1
      78: goto          143
      81: iload         7
      83: iload         5
      85: if_icmple     102
      88: aload_0
      89: iload         8
      91: aload_1
      92: iload         6
      94: aaload
      95: aastore
      96: iinc          6, 1
      99: goto          143
     102: aload_1
     103: iload         6
     105: aaload
     106: aload_1
     107: iload         7
     109: aaload
     110: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     115: ifgt          132
     118: aload_0
     119: iload         8
     121: aload_1
     122: iload         6
     124: aaload
     125: aastore
     126: iinc          6, 1
     129: goto          143
     132: aload_0
     133: iload         8
     135: aload_1
     136: iload         7
     138: aaload
     139: aastore
     140: iinc          7, 1
     143: iload         8
     145: iload         5
     147: if_icmpeq     156
     150: iinc          8, 1
     153: goto          60
     156: return

  public static final <T extends java.lang.Comparable<? super T>> void quickSort(T[]);
    Code:
       0: aload_0
       1: ldc           #10                 // String array
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #125                // Method kotlin/collections/ArraysKt.shuffle:([Ljava/lang/Object;)V
      10: aload_0
      11: iconst_0
      12: aload_0
      13: invokestatic  #92                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      16: invokestatic  #129                // Method quickSort$sort$0:([Ljava/lang/Comparable;II)V
      19: return

  private static final <T extends java.lang.Comparable<? super T>> void mergeSort$sort(T[], T[], int, int);
    Code:
       0: iload_3
       1: iload_2
       2: if_icmpgt     6
       5: return
       6: iload_2
       7: iload_3
       8: iload_2
       9: isub
      10: iconst_2
      11: idiv
      12: iadd
      13: istore        4
      15: aload_0
      16: aload_1
      17: iconst_0
      18: iload         4
      20: invokestatic  #96                 // Method mergeSort$sort:([Ljava/lang/Comparable;[Ljava/lang/Comparable;II)V
      23: aload_0
      24: aload_1
      25: iload         4
      27: iconst_1
      28: iadd
      29: iload_3
      30: invokestatic  #96                 // Method mergeSort$sort:([Ljava/lang/Comparable;[Ljava/lang/Comparable;II)V
      33: aload_0
      34: aload_1
      35: iconst_0
      36: iload         4
      38: iload         4
      40: iconst_1
      41: iadd
      42: iload_3
      43: invokestatic  #108                // Method merge:([Ljava/lang/Comparable;[Ljava/lang/Comparable;IIII)V
      46: return

  private static final <T extends java.lang.Comparable<? super T>> int quickSort$partition(T[], int, int);
    Code:
       0: iload_1
       1: istore_3
       2: iload_2
       3: iconst_1
       4: iadd
       5: istore        4
       7: nop
       8: aload_0
       9: iinc          3, 1
      12: iload_3
      13: aaload
      14: aload_0
      15: iload_1
      16: aaload
      17: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      22: ifge          33
      25: iload_3
      26: iload_2
      27: if_icmpne     8
      30: goto          33
      33: aload_0
      34: iload_1
      35: aaload
      36: aload_0
      37: iinc          4, -1
      40: iload         4
      42: aaload
      43: invokeinterface #31,  2           // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      48: ifge          60
      51: iload         4
      53: iload_1
      54: if_icmpne     33
      57: goto          60
      60: iload_3
      61: iload         4
      63: if_icmpge     76
      66: aload_0
      67: iload_3
      68: iload         4
      70: invokestatic  #33                 // Method swap:([Ljava/lang/Object;II)V
      73: goto          7
      76: aload_0
      77: iload_1
      78: iload         4
      80: invokestatic  #33                 // Method swap:([Ljava/lang/Object;II)V
      83: iload         4
      85: ireturn

  private static final <T extends java.lang.Comparable<? super T>> void quickSort$sort$0(T[], int, int);
    Code:
       0: iload_2
       1: iload_1
       2: if_icmpgt     6
       5: return
       6: aload_0
       7: iload_1
       8: iload_2
       9: invokestatic  #141                // Method quickSort$partition:([Ljava/lang/Comparable;II)I
      12: istore_3
      13: aload_0
      14: iload_1
      15: iload_3
      16: iconst_1
      17: isub
      18: invokestatic  #129                // Method quickSort$sort$0:([Ljava/lang/Comparable;II)V
      21: aload_0
      22: iload_3
      23: iconst_1
      24: iadd
      25: iload_2
      26: invokestatic  #129                // Method quickSort$sort$0:([Ljava/lang/Comparable;II)V
      29: return
}