package com.arya.matrixcalculator.logic

object InverseOperation {
    //    const val N = 3
    // Function to get cofactor of A[p][q] in temp[][]. n is current
    // dimension of A[][]
    private fun getCofactor(A: Array<Array<Float>>, temp: Array<Array<Float>>, p: Int, q: Int, n: Int) {
        var i = 0
        var j = 0
        // Looping for each element of the matrix
        for (row in 0 until n) {
            for (col in 0 until n) { // Copying into temporary matrix only those element
                // which are not in given row and column
                if (row != p && col != q) {
                    temp[i][j++] = A[row][col]
                    // Row is filled, so increase row index and
                    // reset col index
                    if (j == n - 1) {
                        j = 0
                        i++
                    }
                }
            }
        }
    }

    /* Recursive function for finding determinant of matrix.
    n is current dimension of A[][]. */
    private fun determinant(A: Array<Array<Float>>, n: Int): Float {

        val x = A.size

        var d = 0F // Initialize result
        // Base case : if matrix contains single element
        if (n == 1) return A[0][0]
        val temp: Array<Array<Float>>  // To store cofactors
        temp = Array(x) {Array(x) {0f} } //Array(N) { FloatArray(N) }
        var sign = 1 // To store sign multiplier
        // Iterate for each element of first row
        for (f in 0 until n) { // Getting Cofactor of A[0][f]
            getCofactor(
                A,
                temp,
                0,
                f,
                n
            )
            d += sign * A[0][f] * determinant(
                temp,
                n - 1
            )
            // terms are to be added with alternate sign
            sign = -sign
        }
        return d
    }

    // Function to get adjoint of A[N][N] in adj[N][N].
    private fun adjoint(A: Array<Array<Float>>, adj: Array<Array<Float>>) {

        val n = A.size

        if (n == 1) {
            adj[0][0] = 1F
            return
        }
        // temp is used to store cofactors of A[][]
        var sign: Int
        val temp = Array(n) {Array(n) {0f} }
        for (i in 0 until n) {
            for (j in 0 until n) { // Get cofactor of A[i][j]
                getCofactor(
                    A,
                    temp,
                    i,
                    j,
                    n
                )
                // sign of adj[j][i] positive if sum of row
                // and column indexes is even.
                sign = if ((i + j) % 2 == 0) 1 else -1
                // Interchanging rows and columns to get the
                // transpose of the cofactor matrix
                adj[j][i] = sign * determinant(
                    temp,
                    n - 1
                )
            }
        }
    }

    // Function to calculate and store inverse, returns false if
    // matrix is singular
    private fun inverse(
        A: Array<Array<Float>>,
        inverse: Array<Array<Float>>
    ): Boolean { // Find determinant of A[][]

        val n = A.size

        val det =
            determinant(A, n)
        if (det == 0F) {
            print("Singular matrix, can't find its inverse")
            return false
        }
        // Find adjoint
        val adj = Array(n) {Array(n) {0f} }//Array(N) { IntArray(N) }
        adjoint(A, adj)
        // Find Inverse using formula "inverse(A) = adj(A)/det(A)"
        for (i in 0 until n) for (j in 0 until n) inverse[i][j] =
            adj[i][j] / det
        return true
    }

    fun mainInverse(
        matrix1: Array<Array<Float>>,
        matrixResult: Array<Array<Float>>
    ) {
        val n = matrix1.size

        val adj =
            Array(n) {Array(n) {0f} } // To store adjoint of A[][]
        val inv =
            Array(n) {Array(n) {0f} } // To store inverse of A[][]

        adjoint(matrix1, adj)

        if (inverse(
                matrix1,
                inv
            )
        )
            for (i: Int in inv.indices)
                for (j: Int in inv[0].indices)
                    matrixResult[i][j] = inv[i][j]
    }
}

Compiled from "InverseOperation.kt"
public final class com.arya.matrixcalculator.logic.InverseOperation {
  public static final com.arya.matrixcalculator.logic.InverseOperation INSTANCE;

  private com.arya.matrixcalculator.logic.InverseOperation();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final void getCofactor(java.lang.Float[][], java.lang.Float[][], int, int, int);
    Code:
       0: iconst_0
       1: istore        6
       3: iconst_0
       4: istore        7
       6: iconst_0
       7: istore        8
       9: iload         8
      11: iload         5
      13: if_icmpge     83
      16: iconst_0
      17: istore        9
      19: iload         9
      21: iload         5
      23: if_icmpge     77
      26: iload         8
      28: iload_3
      29: if_icmpeq     71
      32: iload         9
      34: iload         4
      36: if_icmpeq     71
      39: aload_2
      40: iload         6
      42: aaload
      43: iload         7
      45: iinc          7, 1
      48: aload_1
      49: iload         8
      51: aaload
      52: iload         9
      54: aaload
      55: aastore
      56: iload         7
      58: iload         5
      60: iconst_1
      61: isub
      62: if_icmpne     71
      65: iconst_0
      66: istore        7
      68: iinc          6, 1
      71: iinc          9, 1
      74: goto          19
      77: iinc          8, 1
      80: goto          9
      83: return

  private final float determinant(java.lang.Float[][], int);
    Code:
       0: aload_1
       1: checkcast     #27                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore_3
       6: fconst_0
       7: fstore        4
       9: iload_2
      10: iconst_1
      11: if_icmpne     23
      14: aload_1
      15: iconst_0
      16: aaload
      17: iconst_0
      18: aaload
      19: invokevirtual #33                 // Method java/lang/Float.floatValue:()F
      22: freturn
      23: aconst_null
      24: astore        5
      26: iconst_0
      27: istore        6
      29: iload_3
      30: anewarray     #35                 // class "[Ljava/lang/Float;"
      33: astore        7
      35: iload         6
      37: iload_3
      38: if_icmpge     100
      41: iload         6
      43: istore        8
      45: aload         7
      47: iload         8
      49: iconst_0
      50: istore        9
      52: iload_3
      53: anewarray     #29                 // class java/lang/Float
      56: astore        10
      58: istore        13
      60: astore        12
      62: iload         9
      64: iload_3
      65: if_icmpge     87
      68: iload         9
      70: istore        11
      72: aload         10
      74: iload         11
      76: fconst_0
      77: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      80: aastore
      81: iinc          9, 1
      84: goto          62
      87: aload         12
      89: iload         13
      91: aload         10
      93: aastore
      94: iinc          6, 1
      97: goto          35
     100: aload         7
     102: astore        5
     104: iconst_1
     105: istore        6
     107: iconst_0
     108: istore        7
     110: iload         7
     112: iload_2
     113: if_icmpge     166
     116: aload_0
     117: aload_1
     118: aload         5
     120: iconst_0
     121: iload         7
     123: iload_2
     124: invokespecial #41                 // Method getCofactor:([[Ljava/lang/Float;[[Ljava/lang/Float;III)V
     127: fload         4
     129: iload         6
     131: i2f
     132: aload_1
     133: iconst_0
     134: aaload
     135: iload         7
     137: aaload
     138: invokevirtual #33                 // Method java/lang/Float.floatValue:()F
     141: fmul
     142: aload_0
     143: aload         5
     145: iload_2
     146: iconst_1
     147: isub
     148: invokespecial #43                 // Method determinant:([[Ljava/lang/Float;I)F
     151: fmul
     152: fadd
     153: fstore        4
     155: iload         6
     157: ineg
     158: istore        6
     160: iinc          7, 1
     163: goto          110
     166: fload         4
     168: freturn

  private final void adjoint(java.lang.Float[][], java.lang.Float[][]);
    Code:
       0: aload_1
       1: checkcast     #27                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore_3
       6: iload_3
       7: iconst_1
       8: if_icmpne     21
      11: aload_2
      12: iconst_0
      13: aaload
      14: iconst_0
      15: fconst_1
      16: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      19: aastore
      20: return
      21: iconst_0
      22: istore        4
      24: iconst_0
      25: istore        6
      27: iload_3
      28: anewarray     #35                 // class "[Ljava/lang/Float;"
      31: astore        7
      33: iload         6
      35: iload_3
      36: if_icmpge     98
      39: iload         6
      41: istore        8
      43: aload         7
      45: iload         8
      47: iconst_0
      48: istore        9
      50: iload_3
      51: anewarray     #29                 // class java/lang/Float
      54: astore        10
      56: istore        13
      58: astore        12
      60: iload         9
      62: iload_3
      63: if_icmpge     85
      66: iload         9
      68: istore        11
      70: aload         10
      72: iload         11
      74: fconst_0
      75: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      78: aastore
      79: iinc          9, 1
      82: goto          60
      85: aload         12
      87: iload         13
      89: aload         10
      91: aastore
      92: iinc          6, 1
      95: goto          33
      98: aload         7
     100: astore        5
     102: iconst_0
     103: istore        6
     105: iload         6
     107: iload_3
     108: if_icmpge     184
     111: iconst_0
     112: istore        7
     114: iload         7
     116: iload_3
     117: if_icmpge     178
     120: aload_0
     121: aload_1
     122: aload         5
     124: iload         6
     126: iload         7
     128: iload_3
     129: invokespecial #41                 // Method getCofactor:([[Ljava/lang/Float;[[Ljava/lang/Float;III)V
     132: iload         6
     134: iload         7
     136: iadd
     137: iconst_2
     138: irem
     139: ifne          146
     142: iconst_1
     143: goto          147
     146: iconst_m1
     147: istore        4
     149: aload_2
     150: iload         7
     152: aaload
     153: iload         6
     155: iload         4
     157: i2f
     158: aload_0
     159: aload         5
     161: iload_3
     162: iconst_1
     163: isub
     164: invokespecial #43                 // Method determinant:([[Ljava/lang/Float;I)F
     167: fmul
     168: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
     171: aastore
     172: iinc          7, 1
     175: goto          114
     178: iinc          6, 1
     181: goto          105
     184: return

  private final boolean inverse(java.lang.Float[][], java.lang.Float[][]);
    Code:
       0: aload_1
       1: checkcast     #27                 // class "[Ljava/lang/Object;"
       4: arraylength
       5: istore_3
       6: aload_0
       7: aload_1
       8: iload_3
       9: invokespecial #43                 // Method determinant:([[Ljava/lang/Float;I)F
      12: fstore        4
      14: fload         4
      16: fconst_0
      17: fcmpg
      18: ifne          25
      21: iconst_1
      22: goto          26
      25: iconst_0
      26: ifeq          40
      29: ldc           #56                 // String Singular matrix, can\'t find its inverse
      31: getstatic     #62                 // Field java/lang/System.out:Ljava/io/PrintStream;
      34: swap
      35: invokevirtual #68                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      38: iconst_0
      39: ireturn
      40: iconst_0
      41: istore        6
      43: iload_3
      44: anewarray     #35                 // class "[Ljava/lang/Float;"
      47: astore        7
      49: iload         6
      51: iload_3
      52: if_icmpge     114
      55: iload         6
      57: istore        8
      59: aload         7
      61: iload         8
      63: iconst_0
      64: istore        9
      66: iload_3
      67: anewarray     #29                 // class java/lang/Float
      70: astore        10
      72: istore        13
      74: astore        12
      76: iload         9
      78: iload_3
      79: if_icmpge     101
      82: iload         9
      84: istore        11
      86: aload         10
      88: iload         11
      90: fconst_0
      91: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      94: aastore
      95: iinc          9, 1
      98: goto          76
     101: aload         12
     103: iload         13
     105: aload         10
     107: aastore
     108: iinc          6, 1
     111: goto          49
     114: aload         7
     116: astore        5
     118: aload_0
     119: aload_1
     120: aload         5
     122: invokespecial #70                 // Method adjoint:([[Ljava/lang/Float;[[Ljava/lang/Float;)V
     125: iconst_0
     126: istore        6
     128: iload         6
     130: iload_3
     131: if_icmpge     179
     134: iconst_0
     135: istore        7
     137: iload         7
     139: iload_3
     140: if_icmpge     173
     143: aload_2
     144: iload         6
     146: aaload
     147: iload         7
     149: aload         5
     151: iload         6
     153: aaload
     154: iload         7
     156: aaload
     157: invokevirtual #33                 // Method java/lang/Float.floatValue:()F
     160: fload         4
     162: fdiv
     163: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
     166: aastore
     167: iinc          7, 1
     170: goto          137
     173: iinc          6, 1
     176: goto          128
     179: iconst_1
     180: ireturn

  public final void mainInverse(java.lang.Float[][], java.lang.Float[][]);
    Code:
       0: aload_1
       1: ldc           #75                 // String matrix1
       3: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #83                 // String matrixResult
       9: invokestatic  #81                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: checkcast     #27                 // class "[Ljava/lang/Object;"
      16: arraylength
      17: istore_3
      18: iconst_0
      19: istore        5
      21: iload_3
      22: anewarray     #35                 // class "[Ljava/lang/Float;"
      25: astore        6
      27: iload         5
      29: iload_3
      30: if_icmpge     92
      33: iload         5
      35: istore        7
      37: aload         6
      39: iload         7
      41: iconst_0
      42: istore        8
      44: iload_3
      45: anewarray     #29                 // class java/lang/Float
      48: astore        9
      50: istore        13
      52: astore        12
      54: iload         8
      56: iload_3
      57: if_icmpge     79
      60: iload         8
      62: istore        10
      64: aload         9
      66: iload         10
      68: fconst_0
      69: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
      72: aastore
      73: iinc          8, 1
      76: goto          54
      79: aload         12
      81: iload         13
      83: aload         9
      85: aastore
      86: iinc          5, 1
      89: goto          27
      92: aload         6
      94: astore        4
      96: iconst_0
      97: istore        6
      99: iload_3
     100: anewarray     #35                 // class "[Ljava/lang/Float;"
     103: astore        7
     105: iload         6
     107: iload_3
     108: if_icmpge     170
     111: iload         6
     113: istore        8
     115: aload         7
     117: iload         8
     119: iconst_0
     120: istore        9
     122: iload_3
     123: anewarray     #29                 // class java/lang/Float
     126: astore        10
     128: istore        13
     130: astore        12
     132: iload         9
     134: iload_3
     135: if_icmpge     157
     138: iload         9
     140: istore        11
     142: aload         10
     144: iload         11
     146: fconst_0
     147: invokestatic  #39                 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;
     150: aastore
     151: iinc          9, 1
     154: goto          132
     157: aload         12
     159: iload         13
     161: aload         10
     163: aastore
     164: iinc          6, 1
     167: goto          105
     170: aload         7
     172: astore        5
     174: aload_0
     175: aload_1
     176: aload         4
     178: invokespecial #70                 // Method adjoint:([[Ljava/lang/Float;[[Ljava/lang/Float;)V
     181: aload_0
     182: aload_1
     183: aload         5
     185: invokespecial #85                 // Method inverse:([[Ljava/lang/Float;[[Ljava/lang/Float;)Z
     188: ifeq          253
     191: iconst_0
     192: istore        6
     194: aload         5
     196: checkcast     #27                 // class "[Ljava/lang/Object;"
     199: arraylength
     200: istore        7
     202: iload         6
     204: iload         7
     206: if_icmpge     253
     209: iconst_0
     210: istore        8
     212: aload         5
     214: iconst_0
     215: aaload
     216: arraylength
     217: istore        9
     219: iload         8
     221: iload         9
     223: if_icmpge     247
     226: aload_2
     227: iload         6
     229: aaload
     230: iload         8
     232: aload         5
     234: iload         6
     236: aaload
     237: iload         8
     239: aaload
     240: aastore
     241: iinc          8, 1
     244: goto          219
     247: iinc          6, 1
     250: goto          202
     253: return

  static {};
    Code:
       0: new           #2                  // class com/arya/matrixcalculator/logic/InverseOperation
       3: dup
       4: invokespecial #88                 // Method "<init>":()V
       7: putstatic     #91                 // Field INSTANCE:Lcom/arya/matrixcalculator/logic/InverseOperation;
      10: return
}


package com.example.SecretService

/**
 * Created by menta on 29/03/2018.
 */
import java.lang.Math.pow

fun List<Int>.innerProduct(B:List<Int>): Int {
    return zip(B)
            .map { it.first * it.second }
            .sum()
}

fun List<Int>.vandermond(): List<List<Int>> {
    return map { xval -> List<Int>(size, {it:Int -> pow(xval.toDouble(), it.toDouble()).toInt()}) }
}

fun List<Int>.polyeval(input: Int): Int {
    return foldIndexed(0, {index:Int, soFar:Int, next:Int -> soFar + next*pow(input.toDouble(), index.toDouble()).toInt()})

    //foldRight(0, { soFar, alpha -> alpha + soFar * input })
}

fun List<Int>.polyAdd(summand:List<Int>): List<Int> {
    return mapIndexed{index, next -> next + summand.get(index)}
}

fun List<Int>.polyMult(multipland: List<Int>): List<Int> {
    return foldIndexed( multipland , { index, soFar, next -> soFar
            .polyAdd(List<Int>( index,{0}) + multipland.map{it*next} )
    })
}

fun List<List<Int>>.transpose(): List<List<Int>> {
    return mapIndexed{ rownum, row -> row.mapIndexed{ colnum, col -> get(colnum)[rownum] }
    }
}

fun List<List<Int>>.submatrix( droprow: Int, dropcol: Int ): List<List<Int>> {
    return filterIndexed { index, _ -> index != droprow }
            .map { it.filterIndexed { index, _ -> index != dropcol } }
            .fold( listOf(), { current, next -> current.plusElement(next) } )
}

fun List<List<Int>>.det(): Int {
    return if (size > 1) mapIndexed { colnum, _ -> submatrix(0, colnum).det() }
            .mapIndexed { index, entry -> entry * pow(-1.0, index.toDouble()).toInt() }
            .innerProduct( get(0) ) else get(0)[0]
}

fun List<List<Int>>.cofactor(): List<List<Int>> {
    return mapIndexed { rownum: Int, row: List<Int> -> row.mapIndexed { colnum, _ -> submatrix(rownum, colnum).det()* pow(-1.0, (colnum+rownum).toDouble()).toInt()  }
    }
}

fun List<List<Int>>.invert(): List<List<Int>>{
    return cofactor()
            .transpose()
            .map{ row -> row
                    .map{ entry -> entry }} //divide det()
}

fun List<List<Int>>.matrixMultiplyRight( B: List<List<Int>> ): List<List<Int>> {
    return mapIndexed { rownum:Int, brow -> brow
            .mapIndexed { colnum:Int, _ -> brow
                    .innerProduct( B.transpose()[colnum] )
            }
    }
}

Compiled from "KylesMathPack.kt"
public final class com.example.SecretService.KylesMathPackKt {
  public static final int innerProduct(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    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 B
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #20                 // class java/lang/Iterable
      16: aload_1
      17: checkcast     #20                 // class java/lang/Iterable
      20: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;
      23: checkcast     #20                 // class java/lang/Iterable
      26: astore_2
      27: nop
      28: iconst_0
      29: istore_3
      30: aload_2
      31: astore        4
      33: new           #28                 // class java/util/ArrayList
      36: dup
      37: aload_2
      38: bipush        10
      40: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #38                 // class java/util/Collection
      49: astore        5
      51: iconst_0
      52: istore        6
      54: aload         4
      56: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        7
      63: aload         7
      65: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          134
      73: aload         7
      75: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        8
      82: aload         5
      84: aload         8
      86: checkcast     #54                 // class kotlin/Pair
      89: astore        9
      91: astore        11
      93: iconst_0
      94: istore        10
      96: aload         9
      98: invokevirtual #57                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     101: checkcast     #59                 // class java/lang/Number
     104: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     107: aload         9
     109: invokevirtual #66                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     112: checkcast     #59                 // class java/lang/Number
     115: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     118: imul
     119: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     122: aload         11
     124: swap
     125: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     130: pop
     131: goto          63
     134: aload         5
     136: checkcast     #78                 // class java/util/List
     139: nop
     140: checkcast     #20                 // class java/lang/Iterable
     143: invokestatic  #82                 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     146: ireturn

  public static final java.util.List<java.util.List<java.lang.Integer>> vandermond(java.util.List<java.lang.Integer>);
    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_0
       7: checkcast     #20                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #28                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #38                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          168
      54: aload         6
      56: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #59                 // class java/lang/Number
      70: invokevirtual #63                 // Method java/lang/Number.intValue:()I
      73: istore        8
      75: astore        17
      77: iconst_0
      78: istore        9
      80: aload_0
      81: invokeinterface #103,  1          // InterfaceMethod java/util/List.size:()I
      86: istore        10
      88: new           #28                 // class java/util/ArrayList
      91: dup
      92: iload         10
      94: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      97: astore        11
      99: iconst_0
     100: istore        12
     102: iload         12
     104: iload         10
     106: if_icmpge     150
     109: iload         12
     111: istore        13
     113: aload         11
     115: iload         13
     117: istore        14
     119: astore        15
     121: iconst_0
     122: istore        16
     124: iload         8
     126: i2d
     127: iload         14
     129: i2d
     130: invokestatic  #109                // Method java/lang/Math.pow:(DD)D
     133: d2i
     134: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     137: aload         15
     139: swap
     140: invokevirtual #110                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     143: pop
     144: iinc          12, 1
     147: goto          102
     150: aload         11
     152: checkcast     #78                 // class java/util/List
     155: nop
     156: aload         17
     158: swap
     159: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     164: pop
     165: goto          44
     168: aload         4
     170: checkcast     #78                 // class java/util/List
     173: nop
     174: areturn

  public static final int polyeval(java.util.List<java.lang.Integer>, int);
    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_0
       7: checkcast     #20                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: iconst_0
      14: istore        4
      16: iconst_0
      17: istore        5
      19: iload_3
      20: istore        6
      22: aload_2
      23: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      28: astore        7
      30: aload         7
      32: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      37: ifeq          105
      40: aload         7
      42: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      47: astore        8
      49: iload         5
      51: iinc          5, 1
      54: istore        9
      56: iload         9
      58: ifge          64
      61: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      64: iload         9
      66: iload         6
      68: aload         8
      70: checkcast     #59                 // class java/lang/Number
      73: invokevirtual #63                 // Method java/lang/Number.intValue:()I
      76: istore        10
      78: istore        11
      80: istore        12
      82: iconst_0
      83: istore        13
      85: iload         11
      87: iload         10
      89: iload_1
      90: i2d
      91: iload         12
      93: i2d
      94: invokestatic  #109                // Method java/lang/Math.pow:(DD)D
      97: d2i
      98: imul
      99: iadd
     100: istore        6
     102: goto          30
     105: iload         6
     107: ireturn

  public static final java.util.List<java.lang.Integer> polyAdd(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    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           #137                // String summand
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #20                 // class java/lang/Iterable
      16: astore_2
      17: iconst_0
      18: istore_3
      19: aload_2
      20: astore        4
      22: new           #28                 // class java/util/ArrayList
      25: dup
      26: aload_2
      27: bipush        10
      29: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #38                 // class java/util/Collection
      38: astore        5
      40: iconst_0
      41: istore        6
      43: iconst_0
      44: istore        7
      46: aload         4
      48: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      53: astore        8
      55: aload         8
      57: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          142
      65: aload         8
      67: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: astore        9
      74: aload         5
      76: iload         7
      78: iinc          7, 1
      81: istore        10
      83: iload         10
      85: ifge          91
      88: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      91: iload         10
      93: aload         9
      95: checkcast     #59                 // class java/lang/Number
      98: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     101: istore        11
     103: istore        12
     105: astore        14
     107: iconst_0
     108: istore        13
     110: iload         11
     112: aload_1
     113: iload         12
     115: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     120: checkcast     #59                 // class java/lang/Number
     123: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     126: iadd
     127: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     130: aload         14
     132: swap
     133: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     138: pop
     139: goto          55
     142: aload         5
     144: checkcast     #78                 // class java/util/List
     147: nop
     148: areturn

  public static final java.util.List<java.lang.Integer> polyMult(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);
    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           #151                // String multipland
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #20                 // class java/lang/Iterable
      16: astore_2
      17: iconst_0
      18: istore_3
      19: iconst_0
      20: istore        4
      22: aload_1
      23: astore        5
      25: aload_2
      26: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore        6
      33: aload         6
      35: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          288
      43: aload         6
      45: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        7
      52: iload         4
      54: iinc          4, 1
      57: istore        8
      59: iload         8
      61: ifge          67
      64: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      67: iload         8
      69: aload         5
      71: aload         7
      73: checkcast     #59                 // class java/lang/Number
      76: invokevirtual #63                 // Method java/lang/Number.intValue:()I
      79: istore        9
      81: astore        10
      83: istore        11
      85: iconst_0
      86: istore        12
      88: aload         10
      90: astore        13
      92: new           #28                 // class java/util/ArrayList
      95: dup
      96: iload         11
      98: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     101: astore        14
     103: iconst_0
     104: istore        15
     106: iload         15
     108: iload         11
     110: if_icmpge     145
     113: iload         15
     115: istore        16
     117: aload         14
     119: iload         16
     121: istore        17
     123: astore        18
     125: iconst_0
     126: istore        19
     128: iconst_0
     129: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: aload         18
     134: swap
     135: invokevirtual #110                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     138: pop
     139: iinc          15, 1
     142: goto          106
     145: aload         14
     147: checkcast     #78                 // class java/util/List
     150: aload         13
     152: swap
     153: checkcast     #38                 // class java/util/Collection
     156: aload_1
     157: checkcast     #20                 // class java/lang/Iterable
     160: astore        14
     162: astore        18
     164: astore        13
     166: iconst_0
     167: istore        15
     169: aload         14
     171: astore        16
     173: new           #28                 // class java/util/ArrayList
     176: dup
     177: aload         14
     179: bipush        10
     181: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     184: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     187: checkcast     #38                 // class java/util/Collection
     190: astore        17
     192: iconst_0
     193: istore        19
     195: aload         16
     197: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     202: astore        20
     204: aload         20
     206: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     211: ifeq          260
     214: aload         20
     216: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     221: astore        21
     223: aload         17
     225: aload         21
     227: checkcast     #59                 // class java/lang/Number
     230: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     233: istore        22
     235: astore        23
     237: iconst_0
     238: istore        24
     240: iload         22
     242: iload         9
     244: imul
     245: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     248: aload         23
     250: swap
     251: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     256: pop
     257: goto          204
     260: aload         17
     262: checkcast     #78                 // class java/util/List
     265: nop
     266: astore        23
     268: aload         13
     270: aload         18
     272: aload         23
     274: checkcast     #20                 // class java/lang/Iterable
     277: invokestatic  #155                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     280: invokestatic  #157                // Method polyAdd:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;
     283: astore        5
     285: goto          33
     288: aload         5
     290: areturn

  public static final java.util.List<java.util.List<java.lang.Integer>> transpose(java.util.List<? extends java.util.List<java.lang.Integer>>);
    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_0
       7: checkcast     #20                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #28                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #38                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: iconst_0
      37: istore        6
      39: aload_3
      40: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          260
      57: aload         7
      59: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         4
      68: iload         6
      70: iinc          6, 1
      73: istore        9
      75: iload         9
      77: ifge          83
      80: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      83: iload         9
      85: aload         8
      87: checkcast     #78                 // class java/util/List
      90: astore        10
      92: istore        11
      94: astore        26
      96: iconst_0
      97: istore        12
      99: aload         10
     101: checkcast     #20                 // class java/lang/Iterable
     104: astore        13
     106: iconst_0
     107: istore        14
     109: aload         13
     111: astore        15
     113: new           #28                 // class java/util/ArrayList
     116: dup
     117: aload         13
     119: bipush        10
     121: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     124: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     127: checkcast     #38                 // class java/util/Collection
     130: astore        16
     132: iconst_0
     133: istore        17
     135: iconst_0
     136: istore        18
     138: aload         15
     140: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        19
     147: aload         19
     149: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          241
     157: aload         19
     159: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        20
     166: aload         16
     168: iload         18
     170: iinc          18, 1
     173: istore        21
     175: iload         21
     177: ifge          183
     180: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     183: iload         21
     185: aload         20
     187: checkcast     #59                 // class java/lang/Number
     190: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     193: istore        22
     195: istore        23
     197: astore        24
     199: iconst_0
     200: istore        25
     202: aload_0
     203: iload         23
     205: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     210: checkcast     #78                 // class java/util/List
     213: iload         11
     215: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     220: checkcast     #59                 // class java/lang/Number
     223: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     226: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     229: aload         24
     231: swap
     232: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     237: pop
     238: goto          147
     241: aload         16
     243: checkcast     #78                 // class java/util/List
     246: nop
     247: nop
     248: aload         26
     250: swap
     251: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     256: pop
     257: goto          47
     260: aload         4
     262: checkcast     #78                 // class java/util/List
     265: nop
     266: areturn

  public static final java.util.List<java.util.List<java.lang.Integer>> submatrix(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);
    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_0
       7: checkcast     #20                 // class java/lang/Iterable
      10: astore_3
      11: iconst_0
      12: istore        4
      14: aload_3
      15: astore        5
      17: new           #28                 // class java/util/ArrayList
      20: dup
      21: invokespecial #175                // Method java/util/ArrayList."<init>":()V
      24: checkcast     #38                 // class java/util/Collection
      27: astore        6
      29: iconst_0
      30: istore        7
      32: aload         5
      34: astore        8
      36: iconst_0
      37: istore        9
      39: iconst_0
      40: istore        10
      42: aload         8
      44: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        11
      51: aload         11
      53: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          138
      61: aload         11
      63: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        12
      70: iload         10
      72: iinc          10, 1
      75: istore        13
      77: iload         13
      79: ifge          85
      82: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      85: iload         13
      87: aload         12
      89: astore        14
      91: istore        15
      93: iconst_0
      94: istore        16
      96: iload         15
      98: aload         14
     100: checkcast     #78                 // class java/util/List
     103: pop
     104: istore        18
     106: iconst_0
     107: istore        19
     109: iload         18
     111: iload_1
     112: if_icmpeq     119
     115: iconst_1
     116: goto          120
     119: iconst_0
     120: ifeq          133
     123: aload         6
     125: aload         14
     127: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     132: pop
     133: nop
     134: nop
     135: goto          51
     138: nop
     139: aload         6
     141: checkcast     #78                 // class java/util/List
     144: nop
     145: checkcast     #20                 // class java/lang/Iterable
     148: astore_3
     149: nop
     150: iconst_0
     151: istore        4
     153: aload_3
     154: astore        5
     156: new           #28                 // class java/util/ArrayList
     159: dup
     160: aload_3
     161: bipush        10
     163: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     166: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     169: checkcast     #38                 // class java/util/Collection
     172: astore        6
     174: iconst_0
     175: istore        7
     177: aload         5
     179: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     184: astore        8
     186: aload         8
     188: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     193: ifeq          377
     196: aload         8
     198: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     203: astore        9
     205: aload         6
     207: aload         9
     209: checkcast     #78                 // class java/util/List
     212: astore        10
     214: astore        28
     216: iconst_0
     217: istore        11
     219: aload         10
     221: checkcast     #20                 // class java/lang/Iterable
     224: astore        12
     226: iconst_0
     227: istore        13
     229: aload         12
     231: astore        14
     233: new           #28                 // class java/util/ArrayList
     236: dup
     237: invokespecial #175                // Method java/util/ArrayList."<init>":()V
     240: checkcast     #38                 // class java/util/Collection
     243: astore        15
     245: iconst_0
     246: istore        16
     248: aload         14
     250: astore        17
     252: iconst_0
     253: istore        18
     255: iconst_0
     256: istore        19
     258: aload         17
     260: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     265: astore        20
     267: aload         20
     269: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     274: ifeq          357
     277: aload         20
     279: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        21
     286: iload         19
     288: iinc          19, 1
     291: istore        22
     293: iload         22
     295: ifge          301
     298: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     301: iload         22
     303: aload         21
     305: astore        23
     307: istore        24
     309: iconst_0
     310: istore        25
     312: iload         24
     314: aload         23
     316: checkcast     #59                 // class java/lang/Number
     319: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     322: pop
     323: istore        26
     325: iconst_0
     326: istore        27
     328: iload         26
     330: iload_2
     331: if_icmpeq     338
     334: iconst_1
     335: goto          339
     338: iconst_0
     339: ifeq          352
     342: aload         15
     344: aload         23
     346: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     351: pop
     352: nop
     353: nop
     354: goto          267
     357: nop
     358: aload         15
     360: checkcast     #78                 // class java/util/List
     363: nop
     364: nop
     365: aload         28
     367: swap
     368: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     373: pop
     374: goto          186
     377: aload         6
     379: checkcast     #78                 // class java/util/List
     382: nop
     383: checkcast     #20                 // class java/lang/Iterable
     386: astore_3
     387: invokestatic  #179                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     390: astore        4
     392: nop
     393: iconst_0
     394: istore        5
     396: aload         4
     398: astore        6
     400: aload_3
     401: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     406: astore        7
     408: aload         7
     410: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     415: ifeq          457
     418: aload         7
     420: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     425: astore        8
     427: aload         6
     429: aload         8
     431: checkcast     #78                 // class java/util/List
     434: astore        9
     436: astore        10
     438: iconst_0
     439: istore        11
     441: aload         10
     443: checkcast     #38                 // class java/util/Collection
     446: aload         9
     448: invokestatic  #182                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     451: nop
     452: astore        6
     454: goto          408
     457: aload         6
     459: areturn

  public static final int det(java.util.List<? extends java.util.List<java.lang.Integer>>);
    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_0
       7: invokeinterface #103,  1          // InterfaceMethod java/util/List.size:()I
      12: iconst_1
      13: if_icmple     285
      16: aload_0
      17: checkcast     #20                 // class java/lang/Iterable
      20: astore_1
      21: iconst_0
      22: istore_2
      23: aload_1
      24: astore_3
      25: new           #28                 // class java/util/ArrayList
      28: dup
      29: aload_1
      30: bipush        10
      32: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      35: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      38: checkcast     #38                 // class java/util/Collection
      41: astore        4
      43: iconst_0
      44: istore        5
      46: iconst_0
      47: istore        6
      49: aload_3
      50: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        7
      57: aload         7
      59: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifeq          133
      67: aload         7
      69: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      74: astore        8
      76: aload         4
      78: iload         6
      80: iinc          6, 1
      83: istore        9
      85: iload         9
      87: ifge          93
      90: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      93: iload         9
      95: aload         8
      97: checkcast     #78                 // class java/util/List
     100: pop
     101: istore        11
     103: astore        13
     105: iconst_0
     106: istore        12
     108: aload_0
     109: iconst_0
     110: iload         11
     112: invokestatic  #207                // Method submatrix:(Ljava/util/List;II)Ljava/util/List;
     115: invokestatic  #209                // Method det:(Ljava/util/List;)I
     118: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     121: aload         13
     123: swap
     124: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     129: pop
     130: goto          57
     133: aload         4
     135: checkcast     #78                 // class java/util/List
     138: nop
     139: checkcast     #20                 // class java/lang/Iterable
     142: astore_1
     143: nop
     144: iconst_0
     145: istore_2
     146: aload_1
     147: astore_3
     148: new           #28                 // class java/util/ArrayList
     151: dup
     152: aload_1
     153: bipush        10
     155: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     158: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     161: checkcast     #38                 // class java/util/Collection
     164: astore        4
     166: iconst_0
     167: istore        5
     169: iconst_0
     170: istore        6
     172: aload_3
     173: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        7
     180: aload         7
     182: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifeq          263
     190: aload         7
     192: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     197: astore        8
     199: aload         4
     201: iload         6
     203: iinc          6, 1
     206: istore        9
     208: iload         9
     210: ifge          216
     213: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     216: iload         9
     218: aload         8
     220: checkcast     #59                 // class java/lang/Number
     223: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     226: istore        10
     228: istore        11
     230: astore        13
     232: iconst_0
     233: istore        12
     235: iload         10
     237: ldc2_w        #210                // double -1.0d
     240: iload         11
     242: i2d
     243: invokestatic  #109                // Method java/lang/Math.pow:(DD)D
     246: d2i
     247: imul
     248: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     251: aload         13
     253: swap
     254: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     259: pop
     260: goto          180
     263: aload         4
     265: checkcast     #78                 // class java/util/List
     268: nop
     269: aload_0
     270: iconst_0
     271: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     276: checkcast     #78                 // class java/util/List
     279: invokestatic  #213                // Method innerProduct:(Ljava/util/List;Ljava/util/List;)I
     282: goto          307
     285: aload_0
     286: iconst_0
     287: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     292: checkcast     #78                 // class java/util/List
     295: iconst_0
     296: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     301: checkcast     #59                 // class java/lang/Number
     304: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     307: ireturn

  public static final java.util.List<java.util.List<java.lang.Integer>> cofactor(java.util.List<? extends java.util.List<java.lang.Integer>>);
    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_0
       7: checkcast     #20                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #28                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #38                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: iconst_0
      37: istore        6
      39: aload_3
      40: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          260
      57: aload         7
      59: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         4
      68: iload         6
      70: iinc          6, 1
      73: istore        9
      75: iload         9
      77: ifge          83
      80: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      83: iload         9
      85: aload         8
      87: checkcast     #78                 // class java/util/List
      90: astore        10
      92: istore        11
      94: astore        25
      96: iconst_0
      97: istore        12
      99: aload         10
     101: checkcast     #20                 // class java/lang/Iterable
     104: astore        13
     106: iconst_0
     107: istore        14
     109: aload         13
     111: astore        15
     113: new           #28                 // class java/util/ArrayList
     116: dup
     117: aload         13
     119: bipush        10
     121: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     124: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     127: checkcast     #38                 // class java/util/Collection
     130: astore        16
     132: iconst_0
     133: istore        17
     135: iconst_0
     136: istore        18
     138: aload         15
     140: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     145: astore        19
     147: aload         19
     149: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     154: ifeq          241
     157: aload         19
     159: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     164: astore        20
     166: aload         16
     168: iload         18
     170: iinc          18, 1
     173: istore        21
     175: iload         21
     177: ifge          183
     180: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     183: iload         21
     185: aload         20
     187: checkcast     #59                 // class java/lang/Number
     190: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     193: pop
     194: istore        22
     196: astore        23
     198: iconst_0
     199: istore        24
     201: aload_0
     202: iload         11
     204: iload         22
     206: invokestatic  #207                // Method submatrix:(Ljava/util/List;II)Ljava/util/List;
     209: invokestatic  #209                // Method det:(Ljava/util/List;)I
     212: ldc2_w        #210                // double -1.0d
     215: iload         22
     217: iload         11
     219: iadd
     220: i2d
     221: invokestatic  #109                // Method java/lang/Math.pow:(DD)D
     224: d2i
     225: imul
     226: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     229: aload         23
     231: swap
     232: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     237: pop
     238: goto          147
     241: aload         16
     243: checkcast     #78                 // class java/util/List
     246: nop
     247: nop
     248: aload         25
     250: swap
     251: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     256: pop
     257: goto          47
     260: aload         4
     262: checkcast     #78                 // class java/util/List
     265: nop
     266: areturn

  public static final java.util.List<java.util.List<java.lang.Integer>> invert(java.util.List<? extends java.util.List<java.lang.Integer>>);
    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_0
       7: invokestatic  #224                // Method cofactor:(Ljava/util/List;)Ljava/util/List;
      10: invokestatic  #226                // Method transpose:(Ljava/util/List;)Ljava/util/List;
      13: checkcast     #20                 // class java/lang/Iterable
      16: astore_1
      17: nop
      18: iconst_0
      19: istore_2
      20: aload_1
      21: astore_3
      22: new           #28                 // class java/util/ArrayList
      25: dup
      26: aload_1
      27: bipush        10
      29: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #38                 // class java/util/Collection
      38: astore        4
      40: iconst_0
      41: istore        5
      43: aload_3
      44: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      49: astore        6
      51: aload         6
      53: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          202
      61: aload         6
      63: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      68: astore        7
      70: aload         4
      72: aload         7
      74: checkcast     #78                 // class java/util/List
      77: astore        8
      79: astore        20
      81: iconst_0
      82: istore        9
      84: aload         8
      86: checkcast     #20                 // class java/lang/Iterable
      89: astore        10
      91: nop
      92: iconst_0
      93: istore        11
      95: aload         10
      97: astore        12
      99: new           #28                 // class java/util/ArrayList
     102: dup
     103: aload         10
     105: bipush        10
     107: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     110: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     113: checkcast     #38                 // class java/util/Collection
     116: astore        13
     118: iconst_0
     119: istore        14
     121: aload         12
     123: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     128: astore        15
     130: aload         15
     132: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     137: ifeq          183
     140: aload         15
     142: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     147: astore        16
     149: aload         13
     151: aload         16
     153: checkcast     #59                 // class java/lang/Number
     156: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     159: istore        17
     161: astore        18
     163: iconst_0
     164: istore        19
     166: iload         17
     168: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     171: aload         18
     173: swap
     174: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     179: pop
     180: goto          130
     183: aload         13
     185: checkcast     #78                 // class java/util/List
     188: nop
     189: nop
     190: aload         20
     192: swap
     193: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     198: pop
     199: goto          51
     202: aload         4
     204: checkcast     #78                 // class java/util/List
     207: nop
     208: areturn

  public static final java.util.List<java.util.List<java.lang.Integer>> matrixMultiplyRight(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);
    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 B
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #20                 // class java/lang/Iterable
      16: astore_2
      17: iconst_0
      18: istore_3
      19: aload_2
      20: astore        4
      22: new           #28                 // class java/util/ArrayList
      25: dup
      26: aload_2
      27: bipush        10
      29: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      32: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      35: checkcast     #38                 // class java/util/Collection
      38: astore        5
      40: iconst_0
      41: istore        6
      43: iconst_0
      44: istore        7
      46: aload         4
      48: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      53: astore        8
      55: aload         8
      57: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          263
      65: aload         8
      67: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: astore        9
      74: aload         5
      76: iload         7
      78: iinc          7, 1
      81: istore        10
      83: iload         10
      85: ifge          91
      88: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      91: iload         10
      93: aload         9
      95: checkcast     #78                 // class java/util/List
      98: astore        11
     100: istore        12
     102: astore        26
     104: iconst_0
     105: istore        13
     107: aload         11
     109: checkcast     #20                 // class java/lang/Iterable
     112: astore        14
     114: nop
     115: iconst_0
     116: istore        15
     118: aload         14
     120: astore        16
     122: new           #28                 // class java/util/ArrayList
     125: dup
     126: aload         14
     128: bipush        10
     130: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     133: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     136: checkcast     #38                 // class java/util/Collection
     139: astore        17
     141: iconst_0
     142: istore        18
     144: iconst_0
     145: istore        19
     147: aload         16
     149: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     154: astore        20
     156: aload         20
     158: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     163: ifeq          244
     166: aload         20
     168: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: astore        21
     175: aload         17
     177: iload         19
     179: iinc          19, 1
     182: istore        22
     184: iload         22
     186: ifge          192
     189: invokestatic  #121                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     192: iload         22
     194: aload         21
     196: checkcast     #59                 // class java/lang/Number
     199: invokevirtual #63                 // Method java/lang/Number.intValue:()I
     202: pop
     203: istore        23
     205: astore        24
     207: iconst_0
     208: istore        25
     210: aload         11
     212: aload_1
     213: invokestatic  #226                // Method transpose:(Ljava/util/List;)Ljava/util/List;
     216: iload         23
     218: invokeinterface #141,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     223: checkcast     #78                 // class java/util/List
     226: invokestatic  #213                // Method innerProduct:(Ljava/util/List;Ljava/util/List;)I
     229: invokestatic  #72                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: aload         24
     234: swap
     235: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     240: pop
     241: goto          156
     244: aload         17
     246: checkcast     #78                 // class java/util/List
     249: nop
     250: nop
     251: aload         26
     253: swap
     254: invokeinterface #76,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     259: pop
     260: goto          55
     263: aload         5
     265: checkcast     #78                 // class java/util/List
     268: nop
     269: areturn
}


package info.benjaminhill.fm.chopper

import java.time.Duration
import java.time.Instant

/**
 * A timed event is a pair of "stuff (state) that happened at time (ts)"
 * The idea is to keep a collection (ArrayDeque?) of these to record when things first happened.
 */
data class InstantState<T>(
    val ts: Instant,
    val state: T,
)

data class DurationState<T>(
    val duration: Duration,
    val state: T,
)

fun <T> List<InstantState<T>>.toDurations(
    contiguous: Boolean = false,
    maxTtl: Duration
) = if (contiguous) {
    maxContiguousDurations(maxTtl)
} else {
    sumDurations(maxTtl)
}

private fun <T> List<InstantState<T>>.sumDurations(
    maxTtl: Duration,
): List<DurationState<T>> =
    this.asSequence().zipWithNext().map { (is0, is1) ->
        DurationState(
            state = is0.state,
            duration = Duration.between(is0.ts, is1.ts).coerceAtMost(maxTtl),
        )
    }.groupingBy { it.state }
        .fold(Duration.ZERO) { acc, elt ->
            acc + elt.duration
        }.map {
            DurationState(
                duration = it.value,
                state = it.key
            )
        }.toList()

/**
 * Longest contiguous duration
 */
private fun <T> List<InstantState<T>>.maxContiguousDurations(
    maxTtl: Duration,
): List<DurationState<T>> {
    val maxContiguous = mutableMapOf<T, Duration>()
    this.distinctBy { it.state }.forEach {
        maxContiguous[it.state] = Duration.ZERO
    }
    var currentState: T? = null
    var currentDuration: Duration = Duration.ZERO
    this.zipWithNext().forEach { (event0, event1): Pair<InstantState<T>, InstantState<T>> ->
        val (ts0, state0) = event0
        val (ts1, _) = event1
        if (currentState != state0) {
            currentState = state0
            currentDuration = Duration.ZERO
        }
        currentDuration += Duration.between(ts0, ts1).coerceAtMost(maxTtl)
        if (currentDuration > maxContiguous[currentState]) {
            maxContiguous[currentState!!] = currentDuration
        }
    }
    return maxContiguous.map {
        DurationState(
            duration = it.value,
            state = it.key
        )
    }
}

Compiled from "_Sequences.kt"
public final class info.benjaminhill.fm.chopper.TimedEventKt$sumDurations$$inlined$groupingBy$1 implements kotlin.collections.Grouping<info.benjaminhill.fm.chopper.DurationState<T>, T> {
  final kotlin.sequences.Sequence $this_groupingBy;

  public info.benjaminhill.fm.chopper.TimedEventKt$sumDurations$$inlined$groupingBy$1(kotlin.sequences.Sequence);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Lkotlin/sequences/Sequence;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<info.benjaminhill.fm.chopper.DurationState<T>> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Lkotlin/sequences/Sequence;
       4: invokeinterface #32,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
       9: areturn

  public T keyOf(info.benjaminhill.fm.chopper.DurationState<T>);
    Code:
       0: aload_1
       1: checkcast     #37                 // class info/benjaminhill/fm/chopper/DurationState
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: invokevirtual #41                 // Method info/benjaminhill/fm/chopper/DurationState.getState:()Ljava/lang/Object;
      11: areturn
}

Compiled from "TimedEvent.kt"
public final class info.benjaminhill.fm.chopper.TimedEventKt {
  public static final <T> java.util.List<info.benjaminhill.fm.chopper.DurationState<T>> toDurations(java.util.List<info.benjaminhill.fm.chopper.InstantState<T>>, boolean, java.time.Duration);
    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_2
       7: ldc           #18                 // String maxTtl
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_1
      13: ifeq          24
      16: aload_0
      17: aload_2
      18: invokestatic  #22                 // Method maxContiguousDurations:(Ljava/util/List;Ljava/time/Duration;)Ljava/util/List;
      21: goto          29
      24: aload_0
      25: aload_2
      26: invokestatic  #25                 // Method sumDurations:(Ljava/util/List;Ljava/time/Duration;)Ljava/util/List;
      29: areturn

  public static java.util.List toDurations$default(java.util.List, boolean, java.time.Duration, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_0
       7: istore_1
       8: aload_0
       9: iload_1
      10: aload_2
      11: invokestatic  #36                 // Method toDurations:(Ljava/util/List;ZLjava/time/Duration;)Ljava/util/List;
      14: areturn

  private static final <T> java.util.List<info.benjaminhill.fm.chopper.DurationState<T>> sumDurations(java.util.List<info.benjaminhill.fm.chopper.InstantState<T>>, java.time.Duration);
    Code:
       0: aload_0
       1: checkcast     #39                 // class java/lang/Iterable
       4: invokestatic  #45                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
       7: invokestatic  #51                 // Method kotlin/sequences/SequencesKt.zipWithNext:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
      10: aload_1
      11: invokedynamic #71,  0             // InvokeDynamic #0:invoke:(Ljava/time/Duration;)Lkotlin/jvm/functions/Function1;
      16: invokestatic  #75                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      19: astore_2
      20: nop
      21: iconst_0
      22: istore_3
      23: new           #77                 // class info/benjaminhill/fm/chopper/TimedEventKt$sumDurations$$inlined$groupingBy$1
      26: dup
      27: aload_2
      28: invokespecial #81                 // Method info/benjaminhill/fm/chopper/TimedEventKt$sumDurations$$inlined$groupingBy$1."<init>":(Lkotlin/sequences/Sequence;)V
      31: checkcast     #83                 // class kotlin/collections/Grouping
      34: astore_2
      35: getstatic     #88                 // Field java/time/Duration.ZERO:Ljava/time/Duration;
      38: astore_3
      39: iconst_0
      40: istore        4
      42: aload_2
      43: astore        5
      45: iconst_0
      46: istore        6
      48: aload         5
      50: astore        7
      52: new           #90                 // class java/util/LinkedHashMap
      55: dup
      56: invokespecial #93                 // Method java/util/LinkedHashMap."<init>":()V
      59: checkcast     #95                 // class java/util/Map
      62: astore        8
      64: nop
      65: iconst_0
      66: istore        9
      68: aload         7
      70: invokeinterface #99,  1           // InterfaceMethod kotlin/collections/Grouping.sourceIterator:()Ljava/util/Iterator;
      75: astore        10
      77: aload         10
      79: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      84: ifeq          214
      87: aload         10
      89: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      94: astore        11
      96: aload         7
      98: aload         11
     100: invokeinterface #112,  2          // InterfaceMethod kotlin/collections/Grouping.keyOf:(Ljava/lang/Object;)Ljava/lang/Object;
     105: astore        12
     107: aload         8
     109: aload         12
     111: invokeinterface #115,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     116: astore        13
     118: aload         8
     120: aload         12
     122: aload         13
     124: aload         11
     126: aload         13
     128: ifnonnull     147
     131: aload         8
     133: aload         12
     135: invokeinterface #119,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     140: ifne          147
     143: iconst_1
     144: goto          148
     147: iconst_0
     148: istore        14
     150: astore        15
     152: astore        16
     154: astore        17
     156: astore        18
     158: iconst_0
     159: istore        19
     161: iload         14
     163: ifeq          170
     166: aload_3
     167: goto          172
     170: aload         16
     172: aload         15
     174: checkcast     #121                // class info/benjaminhill/fm/chopper/DurationState
     177: astore        20
     179: checkcast     #85                 // class java/time/Duration
     182: astore        21
     184: iconst_0
     185: istore        22
     187: aload         21
     189: aload         20
     191: invokevirtual #125                // Method info/benjaminhill/fm/chopper/DurationState.getDuration:()Ljava/time/Duration;
     194: invokevirtual #129                // Method java/time/Duration.plus:(Ljava/time/Duration;)Ljava/time/Duration;
     197: astore        21
     199: aload         18
     201: aload         17
     203: aload         21
     205: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     210: pop
     211: goto          77
     214: aload         8
     216: nop
     217: nop
     218: astore_2
     219: nop
     220: iconst_0
     221: istore_3
     222: aload_2
     223: astore        4
     225: new           #135                // class java/util/ArrayList
     228: dup
     229: aload_2
     230: invokeinterface #139,  1          // InterfaceMethod java/util/Map.size:()I
     235: invokespecial #142                // Method java/util/ArrayList."<init>":(I)V
     238: checkcast     #144                // class java/util/Collection
     241: astore        5
     243: iconst_0
     244: istore        6
     246: aload         4
     248: invokeinterface #148,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     253: invokeinterface #153,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     258: astore        7
     260: aload         7
     262: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     267: ifeq          336
     270: aload         7
     272: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     277: checkcast     #155                // class java/util/Map$Entry
     280: astore        8
     282: aload         5
     284: aload         8
     286: astore        9
     288: astore        23
     290: iconst_0
     291: istore        10
     293: new           #121                // class info/benjaminhill/fm/chopper/DurationState
     296: dup
     297: aload         9
     299: invokeinterface #158,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     304: dup
     305: ldc           #160                // String <get-value>(...)
     307: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     310: checkcast     #85                 // class java/time/Duration
     313: aload         9
     315: invokeinterface #166,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     320: invokespecial #169                // Method info/benjaminhill/fm/chopper/DurationState."<init>":(Ljava/time/Duration;Ljava/lang/Object;)V
     323: nop
     324: aload         23
     326: swap
     327: invokeinterface #172,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     332: pop
     333: goto          260
     336: aload         5
     338: checkcast     #32                 // class java/util/List
     341: nop
     342: checkcast     #39                 // class java/lang/Iterable
     345: invokestatic  #176                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     348: areturn

  private static final <T> java.util.List<info.benjaminhill.fm.chopper.DurationState<T>> maxContiguousDurations(java.util.List<info.benjaminhill.fm.chopper.InstantState<T>>, java.time.Duration);
    Code:
       0: new           #90                 // class java/util/LinkedHashMap
       3: dup
       4: invokespecial #93                 // Method java/util/LinkedHashMap."<init>":()V
       7: checkcast     #95                 // class java/util/Map
      10: astore_2
      11: aload_0
      12: checkcast     #39                 // class java/lang/Iterable
      15: astore_3
      16: iconst_0
      17: istore        4
      19: new           #215                // class java/util/HashSet
      22: dup
      23: invokespecial #216                // Method java/util/HashSet."<init>":()V
      26: astore        5
      28: new           #135                // class java/util/ArrayList
      31: dup
      32: invokespecial #217                // Method java/util/ArrayList."<init>":()V
      35: astore        6
      37: aload_3
      38: invokeinterface #218,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore        7
      45: aload         7
      47: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      52: ifeq          102
      55: aload         7
      57: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      62: astore        8
      64: aload         8
      66: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
      69: astore        9
      71: iconst_0
      72: istore        10
      74: aload         9
      76: invokevirtual #223                // Method info/benjaminhill/fm/chopper/InstantState.getState:()Ljava/lang/Object;
      79: astore        9
      81: aload         5
      83: aload         9
      85: invokevirtual #224                // Method java/util/HashSet.add:(Ljava/lang/Object;)Z
      88: ifeq          45
      91: aload         6
      93: aload         8
      95: invokevirtual #225                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      98: pop
      99: goto          45
     102: aload         6
     104: checkcast     #32                 // class java/util/List
     107: checkcast     #39                 // class java/lang/Iterable
     110: astore_3
     111: nop
     112: iconst_0
     113: istore        4
     115: aload_3
     116: invokeinterface #218,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     121: astore        5
     123: aload         5
     125: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     130: ifeq          172
     133: aload         5
     135: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     140: astore        6
     142: aload         6
     144: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
     147: astore        7
     149: iconst_0
     150: istore        8
     152: aload_2
     153: aload         7
     155: invokevirtual #223                // Method info/benjaminhill/fm/chopper/InstantState.getState:()Ljava/lang/Object;
     158: getstatic     #88                 // Field java/time/Duration.ZERO:Ljava/time/Duration;
     161: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     166: pop
     167: nop
     168: nop
     169: goto          123
     172: nop
     173: aconst_null
     174: astore_3
     175: aconst_null
     176: astore        4
     178: getstatic     #88                 // Field java/time/Duration.ZERO:Ljava/time/Duration;
     181: dup
     182: ldc           #226                // String ZERO
     184: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     187: astore        4
     189: aload_0
     190: checkcast     #39                 // class java/lang/Iterable
     193: invokestatic  #228                // Method kotlin/collections/CollectionsKt.zipWithNext:(Ljava/lang/Iterable;)Ljava/util/List;
     196: checkcast     #39                 // class java/lang/Iterable
     199: astore        5
     201: iconst_0
     202: istore        6
     204: aload         5
     206: invokeinterface #218,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     211: astore        7
     213: aload         7
     215: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     220: ifeq          383
     223: aload         7
     225: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     230: astore        8
     232: aload         8
     234: checkcast     #230                // class kotlin/Pair
     237: astore        9
     239: iconst_0
     240: istore        10
     242: aload         9
     244: invokevirtual #233                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     247: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
     250: astore        11
     252: aload         9
     254: invokevirtual #236                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     257: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
     260: astore        12
     262: aload         11
     264: invokevirtual #239                // Method info/benjaminhill/fm/chopper/InstantState.component1:()Ljava/time/Instant;
     267: astore        13
     269: aload         11
     271: invokevirtual #240                // Method info/benjaminhill/fm/chopper/InstantState.component2:()Ljava/lang/Object;
     274: astore        14
     276: aload         12
     278: invokevirtual #239                // Method info/benjaminhill/fm/chopper/InstantState.component1:()Ljava/time/Instant;
     281: astore        15
     283: aload_3
     284: aload         14
     286: invokestatic  #244                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     289: ifne          306
     292: aload         14
     294: astore_3
     295: getstatic     #88                 // Field java/time/Duration.ZERO:Ljava/time/Duration;
     298: dup
     299: ldc           #226                // String ZERO
     301: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     304: astore        4
     306: aload         4
     308: aload         13
     310: checkcast     #246                // class java/time/temporal/Temporal
     313: aload         15
     315: checkcast     #246                // class java/time/temporal/Temporal
     318: invokestatic  #250                // Method java/time/Duration.between:(Ljava/time/temporal/Temporal;Ljava/time/temporal/Temporal;)Ljava/time/Duration;
     321: checkcast     #252                // class java/lang/Comparable
     324: aload_1
     325: checkcast     #252                // class java/lang/Comparable
     328: invokestatic  #258                // Method kotlin/ranges/RangesKt.coerceAtMost:(Ljava/lang/Comparable;Ljava/lang/Comparable;)Ljava/lang/Comparable;
     331: checkcast     #85                 // class java/time/Duration
     334: invokevirtual #129                // Method java/time/Duration.plus:(Ljava/time/Duration;)Ljava/time/Duration;
     337: dup
     338: ldc_w         #260                // String plus(...)
     341: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     344: astore        4
     346: aload         4
     348: aload_2
     349: aload_3
     350: invokeinterface #115,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     355: checkcast     #85                 // class java/time/Duration
     358: invokevirtual #264                // Method java/time/Duration.compareTo:(Ljava/time/Duration;)I
     361: ifle          378
     364: aload_2
     365: aload_3
     366: dup
     367: invokestatic  #268                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     370: aload         4
     372: invokeinterface #133,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     377: pop
     378: nop
     379: nop
     380: goto          213
     383: nop
     384: aload_2
     385: astore        5
     387: iconst_0
     388: istore        6
     390: aload         5
     392: astore        7
     394: new           #135                // class java/util/ArrayList
     397: dup
     398: aload         5
     400: invokeinterface #139,  1          // InterfaceMethod java/util/Map.size:()I
     405: invokespecial #142                // Method java/util/ArrayList."<init>":(I)V
     408: checkcast     #144                // class java/util/Collection
     411: astore        8
     413: iconst_0
     414: istore        9
     416: aload         7
     418: invokeinterface #148,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     423: invokeinterface #153,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     428: astore        10
     430: aload         10
     432: invokeinterface #105,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     437: ifeq          500
     440: aload         10
     442: invokeinterface #109,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     447: checkcast     #155                // class java/util/Map$Entry
     450: astore        11
     452: aload         8
     454: aload         11
     456: astore        12
     458: astore        16
     460: iconst_0
     461: istore        13
     463: new           #121                // class info/benjaminhill/fm/chopper/DurationState
     466: dup
     467: aload         12
     469: invokeinterface #158,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     474: checkcast     #85                 // class java/time/Duration
     477: aload         12
     479: invokeinterface #166,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     484: invokespecial #169                // Method info/benjaminhill/fm/chopper/DurationState."<init>":(Ljava/time/Duration;Ljava/lang/Object;)V
     487: nop
     488: aload         16
     490: swap
     491: invokeinterface #172,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     496: pop
     497: goto          430
     500: aload         8
     502: checkcast     #32                 // class java/util/List
     505: nop
     506: areturn

  private static final info.benjaminhill.fm.chopper.DurationState sumDurations$lambda$0(java.time.Duration, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc_w         #298                // String <destruct>
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: invokevirtual #233                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      11: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
      14: astore_2
      15: aload_1
      16: invokevirtual #236                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      19: checkcast     #220                // class info/benjaminhill/fm/chopper/InstantState
      22: astore_3
      23: aload_2
      24: invokevirtual #223                // Method info/benjaminhill/fm/chopper/InstantState.getState:()Ljava/lang/Object;
      27: astore        4
      29: aload_2
      30: invokevirtual #301                // Method info/benjaminhill/fm/chopper/InstantState.getTs:()Ljava/time/Instant;
      33: checkcast     #246                // class java/time/temporal/Temporal
      36: aload_3
      37: invokevirtual #301                // Method info/benjaminhill/fm/chopper/InstantState.getTs:()Ljava/time/Instant;
      40: checkcast     #246                // class java/time/temporal/Temporal
      43: invokestatic  #250                // Method java/time/Duration.between:(Ljava/time/temporal/Temporal;Ljava/time/temporal/Temporal;)Ljava/time/Duration;
      46: checkcast     #252                // class java/lang/Comparable
      49: aload_0
      50: checkcast     #252                // class java/lang/Comparable
      53: invokestatic  #258                // Method kotlin/ranges/RangesKt.coerceAtMost:(Ljava/lang/Comparable;Ljava/lang/Comparable;)Ljava/lang/Comparable;
      56: dup
      57: ldc_w         #303                // String coerceAtMost(...)
      60: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      63: checkcast     #85                 // class java/time/Duration
      66: astore        5
      68: new           #121                // class info/benjaminhill/fm/chopper/DurationState
      71: dup
      72: aload         5
      74: aload         4
      76: invokespecial #169                // Method info/benjaminhill/fm/chopper/DurationState."<init>":(Ljava/time/Duration;Ljava/lang/Object;)V
      79: areturn
}