package intstar.mcalculus

import java.nio.ByteBuffer.wrap
import java.util.*
import kotlin.math.abs

typealias InputStream = java.io.InputStream

const val INFINITY = Double.POSITIVE_INFINITY

const val NEG_INFINITY = Double.NEGATIVE_INFINITY

fun <T> Iterable<T>.sumsToOne(valueFn: (T) -> Double): Boolean {
    return abs(sumByDouble(valueFn) - 1) < 0.00001
}

fun Double.isDefined(): Boolean {
    return !isNaN() && (-0.0).compareTo(this) != 0
}

fun <T> iteratorOf(vararg elements: T): Iterator<T> {
    return elements.iterator()
}

sealed class Interval {
    abstract fun compareStart(other: Interval): Int

    abstract fun intersectsWith(other: Interval): Boolean

    abstract fun anchors(): List<Double>
}

data class OpenInterval(val low: Double, val high: Double) : Interval() {
    init {
        require(low.isDefined() && high.isDefined()) { "Low and high should have a defined value" }
        require(high > low) { "High should be > low for open interval" }
    }

    override fun compareStart(other: Interval): Int {
        return when (other) {
            is OpenInterval -> low.compareTo(other.low)
            is PointInterval -> low.compareTo(other.value).let { if (it == 0) 1 else it }
        }
    }

    override fun intersectsWith(other: Interval): Boolean {
        return when (other) {
            is OpenInterval -> low >= other.low && low < other.high || other.low >= low && other.low < high
            is PointInterval -> other.value > low && other.value < high
        }
    }

    override fun anchors(): List<Double> {
        return listOf(low, high)
    }
}

data class PointInterval(val value: Double) : Interval() {
    init {
        require(value.isDefined() && value.isFinite()) { "Point interval value should be defined and finite" }
    }

    override fun compareStart(other: Interval): Int {
        return when (other) {
            is OpenInterval -> value.compareTo(other.low).let { if (it == 0) -1 else it }
            is PointInterval -> value.compareTo(other.value)
        }
    }

    override fun intersectsWith(other: Interval): Boolean {
        return when (other) {
            is OpenInterval -> value > other.low && value < other.high
            is PointInterval -> value == other.value
        }
    }

    override fun anchors(): List<Double> {
        return listOf(value)
    }
}

fun Iterable<Interval>.isSortedByStart(): Boolean {
    return zipWithNext { a, b -> a.compareStart(b) <= 0 }.all { it }
}

fun Iterable<Interval>.isDisjoint(allowConnected: Boolean = true): Boolean {
    val map = TreeMap<Double, MutableList<Interval>>()
    for (interval in this) {
        for (anchor in interval.anchors()) {
            val closestIntervals = mutableSetOf<Interval>()
            map.floorEntry(anchor)?.value?.let { closestIntervals.addAll(it) }
            map.ceilingEntry(anchor)?.value?.let { closestIntervals.addAll(it) }
            if (closestIntervals.any { interval.intersectsWith(it) }) {
                return false
            }
        }
        interval.anchors().forEach { map.getOrPut(it, { mutableListOf() }).add(interval) }
    }
    return allowConnected || map.values.none { it.size == 3 }
}

fun Iterable<Interval>.isDisconnected(): Boolean {
    return isDisjoint(false)
}

fun <T> Iterable<T>.isSortedByStart(intervalsFn: (T) -> Iterable<Interval>): Boolean {
    return map { intervalsFn(it).first() }.isSortedByStart()
}

fun <T> Iterable<T>.isDisjoint(intervalsFn: (T) -> Iterable<Interval>): Boolean {
    return flatMap { intervalsFn(it) }.isDisjoint()
}

class ByteString(bytes: ByteArray = EMPTY_BYTE_ARRAY) : Iterable<Byte> {
    private val bytes = if (bytes.isNotEmpty()) bytes.copyOf() else EMPTY_BYTE_ARRAY

    fun byteAt(index: Int): Byte {
        return bytes[index]
    }

    fun size(): Int {
        return bytes.size
    }

    fun toByteArray(): ByteArray {
        return bytes.copyOf()
    }

    fun asString(): String {
        return Charsets.UTF_8.newDecoder().decode(wrap(bytes)).toString()
    }

    override fun equals(other: Any?): Boolean {
        return this === other || (javaClass == other?.javaClass && bytes.contentEquals((other as ByteString).bytes))
    }

    override fun hashCode(): Int {
        return bytes.contentHashCode()
    }

    override fun iterator(): ByteIterator {
        return bytes.iterator()
    }

    override fun toString(): String {
        return bytes.joinToString(" ") { "%02x".format(it) }
    }
}

private val EMPTY_BYTE_ARRAY = ByteArray(0)

Compiled from "Prelude.kt"
public final class intstar.mcalculus.PreludeKt {
  public static final double INFINITY;

  public static final double NEG_INFINITY;

  private static final byte[] EMPTY_BYTE_ARRAY;

  public static final <T> boolean sumsToOne(java.lang.Iterable<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Double>);
    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 valueFn
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: iconst_0
      15: istore_3
      16: dconst_0
      17: dstore        4
      19: aload_2
      20: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      25: astore        6
      27: aload         6
      29: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          68
      37: aload         6
      39: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      44: astore        7
      46: dload         4
      48: aload_1
      49: aload         7
      51: invokeinterface #40,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      56: checkcast     #42                 // class java/lang/Number
      59: invokevirtual #46                 // Method java/lang/Number.doubleValue:()D
      62: dadd
      63: dstore        4
      65: goto          27
      68: dload         4
      70: iconst_1
      71: i2d
      72: dsub
      73: invokestatic  #52                 // Method java/lang/Math.abs:(D)D
      76: ldc2_w        #53                 // double 1.0E-5d
      79: dcmpg
      80: ifge          87
      83: iconst_1
      84: goto          88
      87: iconst_0
      88: ireturn

  public static final boolean isDefined(double);
    Code:
       0: dload_0
       1: invokestatic  #71                 // Method java/lang/Double.isNaN:(D)Z
       4: ifne          21
       7: ldc2_w        #72                 // double -0.0d
      10: dload_0
      11: invokestatic  #77                 // Method java/lang/Double.compare:(DD)I
      14: ifeq          21
      17: iconst_1
      18: goto          22
      21: iconst_0
      22: ireturn

  public static final <T> java.util.Iterator<T> iteratorOf(T...);
    Code:
       0: aload_0
       1: ldc           #83                 // String elements
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #87                 // Method kotlin/jvm/internal/ArrayIteratorKt.iterator:([Ljava/lang/Object;)Ljava/util/Iterator;
      10: areturn

  public static final boolean isSortedByStart(java.lang.Iterable<? extends intstar.mcalculus.Interval>);
    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: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifne          32
      26: invokestatic  #97                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      29: goto          126
      32: new           #99                 // class java/util/ArrayList
      35: dup
      36: invokespecial #103                // Method java/util/ArrayList."<init>":()V
      39: checkcast     #105                // class java/util/List
      42: astore        4
      44: aload_3
      45: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: astore        5
      52: aload_3
      53: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          124
      61: aload_3
      62: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        6
      69: aload         4
      71: aload         5
      73: aload         6
      75: checkcast     #107                // class intstar/mcalculus/Interval
      78: astore        7
      80: checkcast     #107                // class intstar/mcalculus/Interval
      83: astore        8
      85: astore        10
      87: iconst_0
      88: istore        9
      90: aload         8
      92: aload         7
      94: invokevirtual #111                // Method intstar/mcalculus/Interval.compareStart:(Lintstar/mcalculus/Interval;)I
      97: ifgt          104
     100: iconst_1
     101: goto          105
     104: iconst_0
     105: invokestatic  #117                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     108: aload         10
     110: swap
     111: invokeinterface #121,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     116: pop
     117: aload         6
     119: astore        5
     121: goto          52
     124: aload         4
     126: checkcast     #20                 // class java/lang/Iterable
     129: astore_1
     130: nop
     131: iconst_0
     132: istore_2
     133: aload_1
     134: instanceof    #123                // class java/util/Collection
     137: ifeq          156
     140: aload_1
     141: checkcast     #123                // class java/util/Collection
     144: invokeinterface #126,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     149: ifeq          156
     152: iconst_1
     153: goto          203
     156: aload_1
     157: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     162: astore_3
     163: aload_3
     164: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     169: ifeq          202
     172: aload_3
     173: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: astore        4
     180: aload         4
     182: checkcast     #113                // class java/lang/Boolean
     185: invokevirtual #129                // Method java/lang/Boolean.booleanValue:()Z
     188: istore        5
     190: iconst_0
     191: istore        6
     193: iload         5
     195: ifne          163
     198: iconst_0
     199: goto          203
     202: iconst_1
     203: ireturn

  public static final boolean isDisjoint(java.lang.Iterable<? extends intstar.mcalculus.Interval>, boolean);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #152                // class java/util/TreeMap
       9: dup
      10: invokespecial #153                // Method java/util/TreeMap."<init>":()V
      13: astore_2
      14: aload_0
      15: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      20: astore_3
      21: aload_3
      22: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      27: ifeq          420
      30: aload_3
      31: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      36: checkcast     #107                // class intstar/mcalculus/Interval
      39: astore        4
      41: aload         4
      43: invokevirtual #156                // Method intstar/mcalculus/Interval.anchors:()Ljava/util/List;
      46: invokeinterface #157,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      51: astore        5
      53: aload         5
      55: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      60: ifeq          279
      63: aload         5
      65: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      70: checkcast     #42                 // class java/lang/Number
      73: invokevirtual #46                 // Method java/lang/Number.doubleValue:()D
      76: dstore        6
      78: new           #159                // class java/util/LinkedHashSet
      81: dup
      82: invokespecial #160                // Method java/util/LinkedHashSet."<init>":()V
      85: checkcast     #162                // class java/util/Set
      88: astore        8
      90: aload_2
      91: dload         6
      93: invokestatic  #165                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
      96: invokevirtual #169                // Method java/util/TreeMap.floorEntry:(Ljava/lang/Object;)Ljava/util/Map$Entry;
      99: dup
     100: ifnull        136
     103: invokeinterface #174,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     108: checkcast     #105                // class java/util/List
     111: dup
     112: ifnull        136
     115: astore        12
     117: iconst_0
     118: istore        13
     120: aload         8
     122: aload         12
     124: checkcast     #123                // class java/util/Collection
     127: invokeinterface #178,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     132: pop
     133: goto          138
     136: pop
     137: nop
     138: aload_2
     139: dload         6
     141: invokestatic  #165                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     144: invokevirtual #181                // Method java/util/TreeMap.ceilingEntry:(Ljava/lang/Object;)Ljava/util/Map$Entry;
     147: dup
     148: ifnull        184
     151: invokeinterface #174,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     156: checkcast     #105                // class java/util/List
     159: dup
     160: ifnull        184
     163: astore        12
     165: iconst_0
     166: istore        13
     168: aload         8
     170: aload         12
     172: checkcast     #123                // class java/util/Collection
     175: invokeinterface #178,  2          // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z
     180: pop
     181: goto          186
     184: pop
     185: nop
     186: aload         8
     188: checkcast     #20                 // class java/lang/Iterable
     191: astore        9
     193: iconst_0
     194: istore        10
     196: aload         9
     198: instanceof    #123                // class java/util/Collection
     201: ifeq          221
     204: aload         9
     206: checkcast     #123                // class java/util/Collection
     209: invokeinterface #126,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     214: ifeq          221
     217: iconst_0
     218: goto          274
     221: aload         9
     223: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     228: astore        11
     230: aload         11
     232: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     237: ifeq          273
     240: aload         11
     242: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     247: astore        12
     249: aload         12
     251: checkcast     #107                // class intstar/mcalculus/Interval
     254: astore        13
     256: iconst_0
     257: istore        14
     259: aload         4
     261: aload         13
     263: invokevirtual #185                // Method intstar/mcalculus/Interval.intersectsWith:(Lintstar/mcalculus/Interval;)Z
     266: ifeq          230
     269: iconst_1
     270: goto          274
     273: iconst_0
     274: ifeq          53
     277: iconst_0
     278: ireturn
     279: aload         4
     281: invokevirtual #156                // Method intstar/mcalculus/Interval.anchors:()Ljava/util/List;
     284: checkcast     #20                 // class java/lang/Iterable
     287: astore        5
     289: iconst_0
     290: istore        6
     292: aload         5
     294: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     299: astore        7
     301: aload         7
     303: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     308: ifeq          416
     311: aload         7
     313: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     318: astore        8
     320: aload         8
     322: checkcast     #42                 // class java/lang/Number
     325: invokevirtual #46                 // Method java/lang/Number.doubleValue:()D
     328: dstore        9
     330: iconst_0
     331: istore        11
     333: aload_2
     334: checkcast     #187                // class java/util/Map
     337: astore        12
     339: dload         9
     341: invokestatic  #165                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     344: astore        13
     346: iconst_0
     347: istore        14
     349: aload         12
     351: aload         13
     353: invokeinterface #190,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     358: astore        15
     360: aload         15
     362: ifnonnull     398
     365: iconst_0
     366: istore        16
     368: new           #99                 // class java/util/ArrayList
     371: dup
     372: invokespecial #103                // Method java/util/ArrayList."<init>":()V
     375: checkcast     #105                // class java/util/List
     378: nop
     379: astore        16
     381: aload         12
     383: aload         13
     385: aload         16
     387: invokeinterface #194,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     392: pop
     393: aload         16
     395: goto          400
     398: aload         15
     400: nop
     401: checkcast     #105                // class java/util/List
     404: aload         4
     406: invokeinterface #121,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     411: pop
     412: nop
     413: goto          301
     416: nop
     417: goto          21
     420: iload_1
     421: ifne          521
     424: aload_2
     425: invokevirtual #198                // Method java/util/TreeMap.values:()Ljava/util/Collection;
     428: dup
     429: ldc           #200                // String <get-values>(...)
     431: invokestatic  #203                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     434: checkcast     #20                 // class java/lang/Iterable
     437: astore_3
     438: iconst_0
     439: istore        4
     441: aload_3
     442: checkcast     #123                // class java/util/Collection
     445: invokeinterface #126,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     450: ifeq          457
     453: iconst_1
     454: goto          518
     457: aload_3
     458: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     463: astore        5
     465: aload         5
     467: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     472: ifeq          517
     475: aload         5
     477: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     482: astore        6
     484: aload         6
     486: checkcast     #105                // class java/util/List
     489: astore        7
     491: iconst_0
     492: istore        8
     494: aload         7
     496: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
     501: iconst_3
     502: if_icmpne     509
     505: iconst_1
     506: goto          510
     509: iconst_0
     510: ifeq          465
     513: iconst_0
     514: goto          518
     517: iconst_1
     518: ifeq          525
     521: iconst_1
     522: goto          526
     525: iconst_0
     526: ireturn

  public static boolean isDisjoint$default(java.lang.Iterable, boolean, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          8
       6: iconst_1
       7: istore_1
       8: aload_0
       9: iload_1
      10: invokestatic  #237                // Method isDisjoint:(Ljava/lang/Iterable;Z)Z
      13: ireturn

  public static final boolean isDisconnected(java.lang.Iterable<? extends intstar.mcalculus.Interval>);
    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: iconst_0
       8: invokestatic  #237                // Method isDisjoint:(Ljava/lang/Iterable;Z)Z
      11: ireturn

  public static final <T> boolean isSortedByStart(java.lang.Iterable<? extends T>, kotlin.jvm.functions.Function1<? super T, ? extends java.lang.Iterable<? extends intstar.mcalculus.Interval>>);
    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           #242                // String intervalsFn
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: astore        4
      19: new           #99                 // class java/util/ArrayList
      22: dup
      23: aload_2
      24: bipush        10
      26: invokestatic  #246                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #249                // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #123                // class java/util/Collection
      35: astore        5
      37: iconst_0
      38: istore        6
      40: aload         4
      42: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      47: astore        7
      49: aload         7
      51: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      56: ifeq          108
      59: aload         7
      61: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      66: astore        8
      68: aload         5
      70: aload         8
      72: astore        9
      74: astore        11
      76: iconst_0
      77: istore        10
      79: aload_1
      80: aload         9
      82: invokeinterface #40,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      87: checkcast     #20                 // class java/lang/Iterable
      90: invokestatic  #253                // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;
      93: checkcast     #107                // class intstar/mcalculus/Interval
      96: aload         11
      98: swap
      99: invokeinterface #254,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     104: pop
     105: goto          49
     108: aload         5
     110: checkcast     #105                // class java/util/List
     113: nop
     114: checkcast     #20                 // class java/lang/Iterable
     117: invokestatic  #256                // Method isSortedByStart:(Ljava/lang/Iterable;)Z
     120: ireturn

  public static final <T> boolean isDisjoint(java.lang.Iterable<? extends T>, kotlin.jvm.functions.Function1<? super T, ? extends java.lang.Iterable<? extends intstar.mcalculus.Interval>>);
    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           #242                // String intervalsFn
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: iconst_0
      15: istore_3
      16: aload_2
      17: astore        4
      19: new           #99                 // class java/util/ArrayList
      22: dup
      23: invokespecial #103                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #123                // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #24,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #30,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          93
      53: aload         7
      55: invokeinterface #34,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         8
      64: astore        9
      66: iconst_0
      67: istore        10
      69: aload_1
      70: aload         9
      72: invokeinterface #40,  2           // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      77: checkcast     #20                 // class java/lang/Iterable
      80: astore        9
      82: aload         5
      84: aload         9
      86: invokestatic  #267                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
      89: pop
      90: goto          43
      93: aload         5
      95: checkcast     #105                // class java/util/List
      98: nop
      99: checkcast     #20                 // class java/lang/Iterable
     102: iconst_0
     103: iconst_1
     104: aconst_null
     105: invokestatic  #269                // Method isDisjoint$default:(Ljava/lang/Iterable;ZILjava/lang/Object;)Z
     108: ireturn

  public static final byte[] access$getEMPTY_BYTE_ARRAY$p();
    Code:
       0: getstatic     #282                // Field EMPTY_BYTE_ARRAY:[B
       3: areturn

  static {};
    Code:
       0: iconst_0
       1: newarray       byte
       3: putstatic     #282                // Field EMPTY_BYTE_ARRAY:[B
       6: return
}


package intstar.mcalculus

data class Measurement(
        val left: DerivedMeasure,
        val comparison: Comparison,
        val right: Measure,
        val confidence: List<ConfidenceValue>
) {
    init {
        require(confidence.sumsToOne { it.value }) { "Total confidence should be 1" }
        require(confidence.isDisjoint { it.intervals }) { "Intervals should be disjoint" }
        require(confidence.isSortedByStart { it.intervals }) { "Confidence values should be sorted by interval starts" }
    }
}

data class ConfidenceValue(val intervals: List<Interval>, val value: Double) {
    init {
        require(value > 0 && value <= 1) { "Confidence value should be > 0 and <= 1" }
        require(intervals.isNotEmpty()) { "Intervals within a confidence value should not be empty" }
        require(intervals.isDisconnected()) { "Intervals within a confidence value should be disconnected" }
        require(intervals.isSortedByStart()) { "Intervals within a confidence value should be sorted by their starts" }
    }
}

enum class Comparison(val symbol: String) {
    EQUALS("="),
    LESS_THAN("<"),
    GREATER_THAN(">"),
    LESS_THAN_EQUALS("<="),
    GREATER_THAN_EQUALS(">=")
}

sealed class Measure

data class ConstantMeasure(val value: Double) : Measure() {
    init {
        require(value.isDefined()) { "Constant measure should have a defined value" }
    }
}

data class DerivedMeasure(val concept: Concept, val measurable: IdEntityConcept) : Measure()

sealed class Concept

data class RelationConcept(val left: EntityConcept, val right: EntityConcept) : Concept()

sealed class EntityConcept : Concept()

data class IdEntityConcept(val value: String) : EntityConcept()

data class ByteEntityConcept(val value: ByteString) : EntityConcept()

data class MeasurementEntityConcept(val value: List<Measurement>) : EntityConcept()

Compiled from "Measurement.kt"
public final class intstar.mcalculus.Measurement {
  private final intstar.mcalculus.DerivedMeasure left;

  private final intstar.mcalculus.Comparison comparison;

  private final intstar.mcalculus.Measure right;

  private final java.util.List<intstar.mcalculus.ConfidenceValue> confidence;

  public intstar.mcalculus.Measurement(intstar.mcalculus.DerivedMeasure, intstar.mcalculus.Comparison, intstar.mcalculus.Measure, java.util.List<intstar.mcalculus.ConfidenceValue>);
    Code:
       0: aload_1
       1: ldc           #10                 // String left
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #18                 // String comparison
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #20                 // String right
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload         4
      20: ldc           #22                 // String confidence
      22: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      25: aload_0
      26: invokespecial #25                 // Method java/lang/Object."<init>":()V
      29: aload_0
      30: aload_1
      31: putfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
      34: aload_0
      35: aload_2
      36: putfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      39: aload_0
      40: aload_3
      41: putfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      44: aload_0
      45: aload         4
      47: putfield      #37                 // Field confidence:Ljava/util/List;
      50: nop
      51: aload_0
      52: getfield      #37                 // Field confidence:Ljava/util/List;
      55: checkcast     #39                 // class java/lang/Iterable
      58: invokedynamic #59,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      63: invokestatic  #65                 // Method intstar/mcalculus/PreludeKt.sumsToOne:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Z
      66: ifne          89
      69: iconst_0
      70: istore        5
      72: ldc           #67                 // String Total confidence should be 1
      74: astore        5
      76: new           #69                 // class java/lang/IllegalArgumentException
      79: dup
      80: aload         5
      82: invokevirtual #73                 // Method java/lang/Object.toString:()Ljava/lang/String;
      85: invokespecial #76                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      88: athrow
      89: aload_0
      90: getfield      #37                 // Field confidence:Ljava/util/List;
      93: checkcast     #39                 // class java/lang/Iterable
      96: invokedynamic #83,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     101: invokestatic  #86                 // Method intstar/mcalculus/PreludeKt.isDisjoint:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Z
     104: ifne          127
     107: iconst_0
     108: istore        5
     110: ldc           #88                 // String Intervals should be disjoint
     112: astore        5
     114: new           #69                 // class java/lang/IllegalArgumentException
     117: dup
     118: aload         5
     120: invokevirtual #73                 // Method java/lang/Object.toString:()Ljava/lang/String;
     123: invokespecial #76                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     126: athrow
     127: aload_0
     128: getfield      #37                 // Field confidence:Ljava/util/List;
     131: checkcast     #39                 // class java/lang/Iterable
     134: invokedynamic #93,  0             // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;
     139: invokestatic  #96                 // Method intstar/mcalculus/PreludeKt.isSortedByStart:(Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Z
     142: ifne          165
     145: iconst_0
     146: istore        5
     148: ldc           #98                 // String Confidence values should be sorted by interval starts
     150: astore        5
     152: new           #69                 // class java/lang/IllegalArgumentException
     155: dup
     156: aload         5
     158: invokevirtual #73                 // Method java/lang/Object.toString:()Ljava/lang/String;
     161: invokespecial #76                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     164: athrow
     165: nop
     166: return

  public final intstar.mcalculus.DerivedMeasure getLeft();
    Code:
       0: aload_0
       1: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
       4: areturn

  public final intstar.mcalculus.Comparison getComparison();
    Code:
       0: aload_0
       1: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
       4: areturn

  public final intstar.mcalculus.Measure getRight();
    Code:
       0: aload_0
       1: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
       4: areturn

  public final java.util.List<intstar.mcalculus.ConfidenceValue> getConfidence();
    Code:
       0: aload_0
       1: getfield      #37                 // Field confidence:Ljava/util/List;
       4: areturn

  public final intstar.mcalculus.DerivedMeasure component1();
    Code:
       0: aload_0
       1: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
       4: areturn

  public final intstar.mcalculus.Comparison component2();
    Code:
       0: aload_0
       1: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
       4: areturn

  public final intstar.mcalculus.Measure component3();
    Code:
       0: aload_0
       1: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
       4: areturn

  public final java.util.List<intstar.mcalculus.ConfidenceValue> component4();
    Code:
       0: aload_0
       1: getfield      #37                 // Field confidence:Ljava/util/List;
       4: areturn

  public final intstar.mcalculus.Measurement copy(intstar.mcalculus.DerivedMeasure, intstar.mcalculus.Comparison, intstar.mcalculus.Measure, java.util.List<intstar.mcalculus.ConfidenceValue>);
    Code:
       0: aload_1
       1: ldc           #10                 // String left
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #18                 // String comparison
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #20                 // String right
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload         4
      20: ldc           #22                 // String confidence
      22: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      25: new           #2                  // class intstar/mcalculus/Measurement
      28: dup
      29: aload_1
      30: aload_2
      31: aload_3
      32: aload         4
      34: invokespecial #130                // Method "<init>":(Lintstar/mcalculus/DerivedMeasure;Lintstar/mcalculus/Comparison;Lintstar/mcalculus/Measure;Ljava/util/List;)V
      37: areturn

  public static intstar.mcalculus.Measurement copy$default(intstar.mcalculus.Measurement, intstar.mcalculus.DerivedMeasure, intstar.mcalculus.Comparison, intstar.mcalculus.Measure, java.util.List, int, java.lang.Object);
    Code:
       0: iload         5
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
      11: astore_1
      12: iload         5
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      23: astore_2
      24: iload         5
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      35: astore_3
      36: iload         5
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #37                 // Field confidence:Ljava/util/List;
      48: astore        4
      50: aload_0
      51: aload_1
      52: aload_2
      53: aload_3
      54: aload         4
      56: invokevirtual #134                // Method copy:(Lintstar/mcalculus/DerivedMeasure;Lintstar/mcalculus/Comparison;Lintstar/mcalculus/Measure;Ljava/util/List;)Lintstar/mcalculus/Measurement;
      59: areturn

  public java.lang.String toString();
    Code:
       0: new           #136                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #137                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #139                // String Measurement(left=
       9: invokevirtual #143                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
      16: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #148                // String , comparison=
      21: invokevirtual #143                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      28: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #150                // String , right=
      33: invokevirtual #143                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      40: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: ldc           #152                // String , confidence=
      45: invokevirtual #143                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #37                 // Field confidence:Ljava/util/List;
      52: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      55: bipush        41
      57: invokevirtual #155                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      60: invokevirtual #156                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
       4: invokevirtual #160                // Method intstar/mcalculus/DerivedMeasure.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      16: invokevirtual #161                // Method intstar/mcalculus/Comparison.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      29: invokevirtual #162                // Method intstar/mcalculus/Measure.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #37                 // Field confidence:Ljava/util/List;
      42: invokevirtual #163                // Method java/lang/Object.hashCode:()I
      45: iadd
      46: istore_1
      47: iload_1
      48: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class intstar/mcalculus/Measurement
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class intstar/mcalculus/Measurement
      20: astore_2
      21: aload_0
      22: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
      25: aload_2
      26: getfield      #28                 // Field left:Lintstar/mcalculus/DerivedMeasure;
      29: invokestatic  #171                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      41: aload_2
      42: getfield      #31                 // Field comparison:Lintstar/mcalculus/Comparison;
      45: if_acmpeq     50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      54: aload_2
      55: getfield      #34                 // Field right:Lintstar/mcalculus/Measure;
      58: invokestatic  #171                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      61: ifne          66
      64: iconst_0
      65: ireturn
      66: aload_0
      67: getfield      #37                 // Field confidence:Ljava/util/List;
      70: aload_2
      71: getfield      #37                 // Field confidence:Ljava/util/List;
      74: invokestatic  #171                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      77: ifne          82
      80: iconst_0
      81: ireturn
      82: iconst_1
      83: ireturn

  private static final double _init_$lambda$0(intstar.mcalculus.ConfidenceValue);
    Code:
       0: aload_0
       1: ldc           #175                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #181                // Method intstar/mcalculus/ConfidenceValue.getValue:()D
      10: dreturn

  private static final java.lang.Iterable _init_$lambda$2(intstar.mcalculus.ConfidenceValue);
    Code:
       0: aload_0
       1: ldc           #175                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #185                // Method intstar/mcalculus/ConfidenceValue.getIntervals:()Ljava/util/List;
      10: checkcast     #39                 // class java/lang/Iterable
      13: areturn

  private static final java.lang.Iterable _init_$lambda$4(intstar.mcalculus.ConfidenceValue);
    Code:
       0: aload_0
       1: ldc           #175                // String it
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #185                // Method intstar/mcalculus/ConfidenceValue.getIntervals:()Ljava/util/List;
      10: checkcast     #39                 // class java/lang/Iterable
      13: areturn
}


package com.kotlin.pocs.predicates

fun main(args: Array<String>): Unit {

//    val n = listOf(1,2,3,4,5,6,7,8);
//    val pred = { value: Int -> value > 5 }
//
//    println(n.all(pred))
//    println(n.any(pred))
//    println(n.count { it > 5 })
//
//    println(n.find(pred))

    val players = listOf(
        Player(1, "AAA", listOf(Point(1,1), Point(1,2))),
        Player(2, "BBB", listOf(Point(1,1), Point(11,22))),
        Player(3, "CCC", listOf(Point(1,1), Point(111,222)))
    )
    val p1 = players
        .asSequence()
        .filter {
            println("filter($it)")
            it.id > 1
        }
        .map {
            println("map($it)");
            "${it.id} + ${it.name}"
        }
//    val p2 = players
//                    //.asSequence()
//                    .flatMap { it -> it.points }
//                    .distinct()

    // println(p1)
    for(player in p1) {
        println(player);
    }

    // println(p2)

    /**
            filter(com.kotlin.pocs.predicates.Player@7eda2dbb)
            filter(com.kotlin.pocs.predicates.Player@6576fe71)
            filter(com.kotlin.pocs.predicates.Player@76fb509a)
            map(com.kotlin.pocs.predicates.Player@6576fe71)
            map(com.kotlin.pocs.predicates.Player@76fb509a)
            2 + BBB
            3 + CCC
     */

    /**
            kotlin.sequences.TransformingSequence@2b71fc7e

            filter(com.kotlin.pocs.predicates.Player@4b85612c)
            filter(com.kotlin.pocs.predicates.Player@277050dc)
            map(com.kotlin.pocs.predicates.Player@277050dc)
            2 + BBB
            filter(com.kotlin.pocs.predicates.Player@5c29bfd)
            map(com.kotlin.pocs.predicates.Player@5c29bfd)
            3 + CCC
     */

}

class Player(var id: Int = 0, var name: String = "", var points: List<Point>) {

}

data class Point(var x: Int = 0, var y: Int = 0) {

}

Compiled from "Predicates.kt"
public final class com.kotlin.pocs.predicates.PredicatesKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_3
       7: anewarray     #17                 // class com/kotlin/pocs/predicates/Player
      10: astore_2
      11: aload_2
      12: iconst_0
      13: new           #17                 // class com/kotlin/pocs/predicates/Player
      16: dup
      17: iconst_1
      18: ldc           #19                 // String AAA
      20: iconst_2
      21: anewarray     #21                 // class com/kotlin/pocs/predicates/Point
      24: astore_3
      25: aload_3
      26: iconst_0
      27: new           #21                 // class com/kotlin/pocs/predicates/Point
      30: dup
      31: iconst_1
      32: iconst_1
      33: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
      36: aastore
      37: aload_3
      38: iconst_1
      39: new           #21                 // class com/kotlin/pocs/predicates/Point
      42: dup
      43: iconst_1
      44: iconst_2
      45: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
      48: aastore
      49: aload_3
      50: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      53: invokespecial #34                 // Method com/kotlin/pocs/predicates/Player."<init>":(ILjava/lang/String;Ljava/util/List;)V
      56: aastore
      57: aload_2
      58: iconst_1
      59: new           #17                 // class com/kotlin/pocs/predicates/Player
      62: dup
      63: iconst_2
      64: ldc           #36                 // String BBB
      66: iconst_2
      67: anewarray     #21                 // class com/kotlin/pocs/predicates/Point
      70: astore_3
      71: aload_3
      72: iconst_0
      73: new           #21                 // class com/kotlin/pocs/predicates/Point
      76: dup
      77: iconst_1
      78: iconst_1
      79: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
      82: aastore
      83: aload_3
      84: iconst_1
      85: new           #21                 // class com/kotlin/pocs/predicates/Point
      88: dup
      89: bipush        11
      91: bipush        22
      93: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
      96: aastore
      97: aload_3
      98: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     101: invokespecial #34                 // Method com/kotlin/pocs/predicates/Player."<init>":(ILjava/lang/String;Ljava/util/List;)V
     104: aastore
     105: aload_2
     106: iconst_2
     107: new           #17                 // class com/kotlin/pocs/predicates/Player
     110: dup
     111: iconst_3
     112: ldc           #38                 // String CCC
     114: iconst_2
     115: anewarray     #21                 // class com/kotlin/pocs/predicates/Point
     118: astore_3
     119: aload_3
     120: iconst_0
     121: new           #21                 // class com/kotlin/pocs/predicates/Point
     124: dup
     125: iconst_1
     126: iconst_1
     127: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
     130: aastore
     131: aload_3
     132: iconst_1
     133: new           #21                 // class com/kotlin/pocs/predicates/Point
     136: dup
     137: bipush        111
     139: sipush        222
     142: invokespecial #25                 // Method com/kotlin/pocs/predicates/Point."<init>":(II)V
     145: aastore
     146: aload_3
     147: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     150: invokespecial #34                 // Method com/kotlin/pocs/predicates/Player."<init>":(ILjava/lang/String;Ljava/util/List;)V
     153: aastore
     154: aload_2
     155: invokestatic  #31                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     158: astore_1
     159: aload_1
     160: checkcast     #40                 // class java/lang/Iterable
     163: invokestatic  #44                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     166: invokedynamic #64,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     171: invokestatic  #70                 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     174: invokedynamic #77,  0             // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
     179: invokestatic  #80                 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     182: astore_2
     183: aload_2
     184: invokeinterface #86,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     189: astore_3
     190: aload_3
     191: invokeinterface #92,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     196: ifeq          221
     199: aload_3
     200: invokeinterface #96,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     205: checkcast     #98                 // class java/lang/String
     208: astore        4
     210: getstatic     #104                // Field java/lang/System.out:Ljava/io/PrintStream;
     213: aload         4
     215: invokevirtual #110                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     218: goto          190
     221: return

  private static final boolean main$lambda$0(com.kotlin.pocs.predicates.Player);
    Code:
       0: aload_0
       1: ldc           #121                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #123                // class java/lang/StringBuilder
       9: dup
      10: invokespecial #126                // Method java/lang/StringBuilder."<init>":()V
      13: ldc           #128                // String filter(
      15: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: aload_0
      19: invokevirtual #135                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      22: bipush        41
      24: invokevirtual #138                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      27: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      30: getstatic     #104                // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #110                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      37: aload_0
      38: invokevirtual #146                // Method com/kotlin/pocs/predicates/Player.getId:()I
      41: iconst_1
      42: if_icmple     49
      45: iconst_1
      46: goto          50
      49: iconst_0
      50: ireturn

  private static final java.lang.String main$lambda$1(com.kotlin.pocs.predicates.Player);
    Code:
       0: aload_0
       1: ldc           #121                // String it
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #123                // class java/lang/StringBuilder
       9: dup
      10: invokespecial #126                // Method java/lang/StringBuilder."<init>":()V
      13: ldc           #149                // String map(
      15: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      18: aload_0
      19: invokevirtual #135                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      22: bipush        41
      24: invokevirtual #138                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      27: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      30: getstatic     #104                // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #110                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      37: new           #123                // class java/lang/StringBuilder
      40: dup
      41: invokespecial #126                // Method java/lang/StringBuilder."<init>":()V
      44: aload_0
      45: invokevirtual #146                // Method com/kotlin/pocs/predicates/Player.getId:()I
      48: invokevirtual #152                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      51: ldc           #154                // String  +
      53: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      56: aload_0
      57: invokevirtual #157                // Method com/kotlin/pocs/predicates/Player.getName:()Ljava/lang/String;
      60: invokevirtual #132                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      63: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      66: areturn
}


package net.sinceat.aoc2020.day5

fun main() {
    val testCodes = listOf(
        "FBFBBFFRLR",
        "BFFFBBFRRR",
        "FFFBBBFRRR",
        "BBFFBBFRLL"
    )
    testCodes.forEach { testCode ->
        println(SeatCoordinates.ofSeatCode(testCode))
    }

    ClassLoader.getSystemResourceAsStream("input.txt")!!.bufferedReader().useLines { lines ->
        val maxSeatId = lines.filterNot(String::isEmpty)
            .map(SeatCoordinates.Companion::ofSeatCode)
            .map(SeatCoordinates::seatId)
            .maxOrNull()
        println("max seat id: $maxSeatId")
    }

    ClassLoader.getSystemResourceAsStream("input.txt")!!.bufferedReader().useLines { lines ->
        val emptySeatId = lines.filterNot(String::isEmpty)
            .map(SeatCoordinates.Companion::ofSeatCode)
            .map(SeatCoordinates::seatId)
            .sorted()
            .windowed(2, 1)
            .first { (a, b) -> b - a == 2 }[0] + 1
        println("empty seat id: $emptySeatId")
    }
}

data class SeatCoordinates(val row: Int, val column: Int, val seatId: Int = row * 8 + column) {

    companion object {
        private fun codeToNumber(code: String, highChar: Char): Int {
            return code.map { c -> if (c == highChar) 1 else 0 }.reduce { a, b -> a * 2 + b }
        }

        fun ofSeatCode(code: String): SeatCoordinates {
            val (rowCode, columnCode) = code.chunked(7)
            return SeatCoordinates(codeToNumber(rowCode, 'B'), codeToNumber(columnCode, 'R'))
        }
    }
}

Compiled from "App.kt"
public final class net.sinceat.aoc2020.day5.AppKt {
  public static final void main();
    Code:
       0: iconst_4
       1: anewarray     #10                 // class java/lang/String
       4: astore_1
       5: aload_1
       6: iconst_0
       7: ldc           #12                 // String FBFBBFFRLR
       9: aastore
      10: aload_1
      11: iconst_1
      12: ldc           #14                 // String BFFFBBFRRR
      14: aastore
      15: aload_1
      16: iconst_2
      17: ldc           #16                 // String FFFBBBFRRR
      19: aastore
      20: aload_1
      21: iconst_3
      22: ldc           #18                 // String BBFFBBFRLL
      24: aastore
      25: aload_1
      26: invokestatic  #24                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      29: astore_0
      30: aload_0
      31: checkcast     #26                 // class java/lang/Iterable
      34: astore_1
      35: iconst_0
      36: istore_2
      37: aload_1
      38: invokeinterface #30,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      43: astore_3
      44: aload_3
      45: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          91
      53: aload_3
      54: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      59: astore        4
      61: aload         4
      63: checkcast     #10                 // class java/lang/String
      66: astore        5
      68: iconst_0
      69: istore        6
      71: getstatic     #46                 // Field net/sinceat/aoc2020/day5/SeatCoordinates.Companion:Lnet/sinceat/aoc2020/day5/SeatCoordinates$Companion;
      74: aload         5
      76: invokevirtual #52                 // Method net/sinceat/aoc2020/day5/SeatCoordinates$Companion.ofSeatCode:(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
      79: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
      82: swap
      83: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      86: nop
      87: nop
      88: goto          44
      91: nop
      92: ldc           #66                 // String input.txt
      94: invokestatic  #72                 // Method java/lang/ClassLoader.getSystemResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
      97: dup
      98: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     101: astore_1
     102: getstatic     #83                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     105: astore_2
     106: new           #85                 // class java/io/InputStreamReader
     109: dup
     110: aload_1
     111: aload_2
     112: invokespecial #89                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
     115: checkcast     #91                 // class java/io/Reader
     118: astore_3
     119: sipush        8192
     122: istore        4
     124: aload_3
     125: instanceof    #93                 // class java/io/BufferedReader
     128: ifeq          138
     131: aload_3
     132: checkcast     #93                 // class java/io/BufferedReader
     135: goto          148
     138: new           #93                 // class java/io/BufferedReader
     141: dup
     142: aload_3
     143: iload         4
     145: invokespecial #96                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     148: checkcast     #91                 // class java/io/Reader
     151: astore_1
     152: nop
     153: iconst_0
     154: istore_2
     155: aload_1
     156: astore_3
     157: sipush        8192
     160: istore        4
     162: aload_3
     163: instanceof    #93                 // class java/io/BufferedReader
     166: ifeq          176
     169: aload_3
     170: checkcast     #93                 // class java/io/BufferedReader
     173: goto          186
     176: new           #93                 // class java/io/BufferedReader
     179: dup
     180: aload_3
     181: iload         4
     183: invokespecial #96                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     186: checkcast     #98                 // class java/io/Closeable
     189: astore_3
     190: aconst_null
     191: astore        4
     193: nop
     194: aload_3
     195: checkcast     #93                 // class java/io/BufferedReader
     198: astore        5
     200: iconst_0
     201: istore        6
     203: aload         5
     205: invokestatic  #104                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     208: astore        7
     210: iconst_0
     211: istore        8
     213: aload         7
     215: getstatic     #110                // Field net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$1.INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$1;
     218: checkcast     #112                // class kotlin/jvm/functions/Function1
     221: invokestatic  #118                // Method kotlin/sequences/SequencesKt.filterNot:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     224: new           #120                // class net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$2
     227: dup
     228: getstatic     #46                 // Field net/sinceat/aoc2020/day5/SeatCoordinates.Companion:Lnet/sinceat/aoc2020/day5/SeatCoordinates$Companion;
     231: invokespecial #122                // Method net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$2."<init>":(Ljava/lang/Object;)V
     234: checkcast     #112                // class kotlin/jvm/functions/Function1
     237: invokestatic  #125                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     240: getstatic     #130                // Field net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$3.INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$3;
     243: checkcast     #112                // class kotlin/jvm/functions/Function1
     246: invokestatic  #125                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     249: invokestatic  #134                // Method kotlin/sequences/SequencesKt.maxOrNull:(Lkotlin/sequences/Sequence;)Ljava/lang/Comparable;
     252: checkcast     #136                // class java/lang/Integer
     255: astore        9
     257: new           #138                // class java/lang/StringBuilder
     260: dup
     261: invokespecial #140                // Method java/lang/StringBuilder."<init>":()V
     264: ldc           #142                // String max seat id:
     266: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     269: aload         9
     271: invokevirtual #149                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     274: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     277: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     280: swap
     281: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     284: nop
     285: getstatic     #158                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     288: astore        5
     290: aload_3
     291: aload         4
     293: invokestatic  #164                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     296: goto          319
     299: astore        6
     301: aload         6
     303: astore        4
     305: aload         6
     307: athrow
     308: astore        6
     310: aload_3
     311: aload         4
     313: invokestatic  #164                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     316: aload         6
     318: athrow
     319: nop
     320: ldc           #66                 // String input.txt
     322: invokestatic  #72                 // Method java/lang/ClassLoader.getSystemResourceAsStream:(Ljava/lang/String;)Ljava/io/InputStream;
     325: dup
     326: invokestatic  #77                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     329: astore_1
     330: getstatic     #83                 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
     333: astore_2
     334: new           #85                 // class java/io/InputStreamReader
     337: dup
     338: aload_1
     339: aload_2
     340: invokespecial #89                 // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
     343: checkcast     #91                 // class java/io/Reader
     346: astore_3
     347: sipush        8192
     350: istore        4
     352: aload_3
     353: instanceof    #93                 // class java/io/BufferedReader
     356: ifeq          366
     359: aload_3
     360: checkcast     #93                 // class java/io/BufferedReader
     363: goto          376
     366: new           #93                 // class java/io/BufferedReader
     369: dup
     370: aload_3
     371: iload         4
     373: invokespecial #96                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     376: checkcast     #91                 // class java/io/Reader
     379: astore_1
     380: nop
     381: iconst_0
     382: istore_2
     383: aload_1
     384: astore_3
     385: sipush        8192
     388: istore        4
     390: aload_3
     391: instanceof    #93                 // class java/io/BufferedReader
     394: ifeq          404
     397: aload_3
     398: checkcast     #93                 // class java/io/BufferedReader
     401: goto          414
     404: new           #93                 // class java/io/BufferedReader
     407: dup
     408: aload_3
     409: iload         4
     411: invokespecial #96                 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
     414: checkcast     #98                 // class java/io/Closeable
     417: astore_3
     418: aconst_null
     419: astore        4
     421: nop
     422: aload_3
     423: checkcast     #93                 // class java/io/BufferedReader
     426: astore        5
     428: iconst_0
     429: istore        6
     431: aload         5
     433: invokestatic  #104                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     436: astore        7
     438: iconst_0
     439: istore        8
     441: aload         7
     443: getstatic     #169                // Field net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$1.INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$1;
     446: checkcast     #112                // class kotlin/jvm/functions/Function1
     449: invokestatic  #118                // Method kotlin/sequences/SequencesKt.filterNot:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     452: new           #171                // class net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$2
     455: dup
     456: getstatic     #46                 // Field net/sinceat/aoc2020/day5/SeatCoordinates.Companion:Lnet/sinceat/aoc2020/day5/SeatCoordinates$Companion;
     459: invokespecial #172                // Method net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$2."<init>":(Ljava/lang/Object;)V
     462: checkcast     #112                // class kotlin/jvm/functions/Function1
     465: invokestatic  #125                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     468: getstatic     #177                // Field net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$3.INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$3;
     471: checkcast     #112                // class kotlin/jvm/functions/Function1
     474: invokestatic  #125                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     477: invokestatic  #181                // Method kotlin/sequences/SequencesKt.sorted:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
     480: iconst_2
     481: iconst_1
     482: iconst_0
     483: iconst_4
     484: aconst_null
     485: invokestatic  #185                // Method kotlin/sequences/SequencesKt.windowed$default:(Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;
     488: astore        9
     490: nop
     491: iconst_0
     492: istore        10
     494: aload         9
     496: invokeinterface #188,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     501: astore        11
     503: aload         11
     505: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     510: ifeq          586
     513: aload         11
     515: invokeinterface #40,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     520: astore        12
     522: aload         12
     524: checkcast     #190                // class java/util/List
     527: astore        13
     529: iconst_0
     530: istore        14
     532: aload         13
     534: iconst_0
     535: invokeinterface #194,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     540: checkcast     #196                // class java/lang/Number
     543: invokevirtual #200                // Method java/lang/Number.intValue:()I
     546: istore        15
     548: aload         13
     550: iconst_1
     551: invokeinterface #194,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     556: checkcast     #196                // class java/lang/Number
     559: invokevirtual #200                // Method java/lang/Number.intValue:()I
     562: istore        16
     564: iload         16
     566: iload         15
     568: isub
     569: iconst_2
     570: if_icmpne     577
     573: iconst_1
     574: goto          578
     577: iconst_0
     578: ifeq          503
     581: aload         12
     583: goto          596
     586: new           #202                // class java/util/NoSuchElementException
     589: dup
     590: ldc           #204                // String Sequence contains no element matching the predicate.
     592: invokespecial #207                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     595: athrow
     596: checkcast     #190                // class java/util/List
     599: iconst_0
     600: invokeinterface #194,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     605: checkcast     #196                // class java/lang/Number
     608: invokevirtual #200                // Method java/lang/Number.intValue:()I
     611: iconst_1
     612: iadd
     613: istore        17
     615: new           #138                // class java/lang/StringBuilder
     618: dup
     619: invokespecial #140                // Method java/lang/StringBuilder."<init>":()V
     622: ldc           #209                // String empty seat id:
     624: invokevirtual #146                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     627: iload         17
     629: invokevirtual #212                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     632: invokevirtual #153                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     635: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     638: swap
     639: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     642: nop
     643: getstatic     #158                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     646: astore        5
     648: aload_3
     649: aload         4
     651: invokestatic  #164                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     654: goto          677
     657: astore        6
     659: aload         6
     661: astore        4
     663: aload         6
     665: athrow
     666: astore        6
     668: aload_3
     669: aload         4
     671: invokestatic  #164                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     674: aload         6
     676: athrow
     677: nop
     678: return
    Exception table:
       from    to  target type
         193   290   299   Class java/lang/Throwable
         193   290   308   any
         299   308   308   any
         308   310   308   any
         421   648   657   Class java/lang/Throwable
         421   648   666   any
         657   666   666   any
         666   668   666   any

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

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$3 extends kotlin.jvm.internal.PropertyReference1Impl {
  public static final net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$3 INSTANCE;

  net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$3();
    Code:
       0: aload_0
       1: ldc           #8                  // class net/sinceat/aoc2020/day5/SeatCoordinates
       3: ldc           #10                 // String seatId
       5: ldc           #12                 // String getSeatId()I
       7: iconst_0
       8: invokespecial #15                 // Method kotlin/jvm/internal/PropertyReference1Impl."<init>":(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      11: return

  public java.lang.Object get(java.lang.Object);
    Code:
       0: aload_1
       1: checkcast     #8                  // class net/sinceat/aoc2020/day5/SeatCoordinates
       4: invokevirtual #23                 // Method net/sinceat/aoc2020/day5/SeatCoordinates.getSeatId:()I
       7: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      10: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$3
       3: dup
       4: invokespecial #34                 // Method "<init>":()V
       7: putstatic     #37                 // Field INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$3;
      10: return
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> {
  public static final net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$1 INSTANCE;

  net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/text/StringsKt
       4: ldc           #13                 // String isEmpty
       6: ldc           #15                 // String isEmpty(Ljava/lang/CharSequence;)Z
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Boolean invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #32                 // class java/lang/CharSequence
      10: invokeinterface #36,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      15: ifne          22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: invokestatic  #42                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      26: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #46                 // class java/lang/String
       5: invokevirtual #48                 // Method invoke:(Ljava/lang/String;)Ljava/lang/Boolean;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$1
       3: dup
       4: invokespecial #53                 // Method "<init>":()V
       7: putstatic     #56                 // Field INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$3$emptySeatId$1;
      10: return
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, net.sinceat.aoc2020.day5.SeatCoordinates> {
  net.sinceat.aoc2020.day5.AppKt$main$3$emptySeatId$2(java.lang.Object);
    Code:
       0: aload_0
       1: iconst_1
       2: aload_1
       3: ldc           #11                 // class net/sinceat/aoc2020/day5/SeatCoordinates$Companion
       5: ldc           #13                 // String ofSeatCode
       7: ldc           #15                 // String ofSeatCode(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
       9: iconst_0
      10: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final net.sinceat.aoc2020.day5.SeatCoordinates invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #26                 // String p0
       3: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #34                 // Field receiver:Ljava/lang/Object;
      10: checkcast     #11                 // class net/sinceat/aoc2020/day5/SeatCoordinates$Companion
      13: aload_1
      14: invokevirtual #36                 // Method net/sinceat/aoc2020/day5/SeatCoordinates$Companion.ofSeatCode:(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/String
       5: invokevirtual #42                 // Method invoke:(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
       8: areturn
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, net.sinceat.aoc2020.day5.SeatCoordinates> {
  net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$2(java.lang.Object);
    Code:
       0: aload_0
       1: iconst_1
       2: aload_1
       3: ldc           #11                 // class net/sinceat/aoc2020/day5/SeatCoordinates$Companion
       5: ldc           #13                 // String ofSeatCode
       7: ldc           #15                 // String ofSeatCode(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
       9: iconst_0
      10: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      13: return

  public final net.sinceat.aoc2020.day5.SeatCoordinates invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #26                 // String p0
       3: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #34                 // Field receiver:Ljava/lang/Object;
      10: checkcast     #11                 // class net/sinceat/aoc2020/day5/SeatCoordinates$Companion
      13: aload_1
      14: invokevirtual #36                 // Method net/sinceat/aoc2020/day5/SeatCoordinates$Companion.ofSeatCode:(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
      17: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #40                 // class java/lang/String
       5: invokevirtual #42                 // Method invoke:(Ljava/lang/String;)Lnet/sinceat/aoc2020/day5/SeatCoordinates;
       8: areturn
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> {
  public static final net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$1 INSTANCE;

  net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/text/StringsKt
       4: ldc           #13                 // String isEmpty
       6: ldc           #15                 // String isEmpty(Ljava/lang/CharSequence;)Z
       8: iconst_1
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Boolean invoke(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #24                 // String p0
       3: invokestatic  #30                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #32                 // class java/lang/CharSequence
      10: invokeinterface #36,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      15: ifne          22
      18: iconst_1
      19: goto          23
      22: iconst_0
      23: invokestatic  #42                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      26: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #46                 // class java/lang/String
       5: invokevirtual #48                 // Method invoke:(Ljava/lang/String;)Ljava/lang/Boolean;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$1
       3: dup
       4: invokespecial #53                 // Method "<init>":()V
       7: putstatic     #56                 // Field INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$1;
      10: return
}

Compiled from "App.kt"
final class net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$3 extends kotlin.jvm.internal.PropertyReference1Impl {
  public static final net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$3 INSTANCE;

  net.sinceat.aoc2020.day5.AppKt$main$2$maxSeatId$3();
    Code:
       0: aload_0
       1: ldc           #8                  // class net/sinceat/aoc2020/day5/SeatCoordinates
       3: ldc           #10                 // String seatId
       5: ldc           #12                 // String getSeatId()I
       7: iconst_0
       8: invokespecial #15                 // Method kotlin/jvm/internal/PropertyReference1Impl."<init>":(Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      11: return

  public java.lang.Object get(java.lang.Object);
    Code:
       0: aload_1
       1: checkcast     #8                  // class net/sinceat/aoc2020/day5/SeatCoordinates
       4: invokevirtual #23                 // Method net/sinceat/aoc2020/day5/SeatCoordinates.getSeatId:()I
       7: invokestatic  #29                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      10: areturn

  static {};
    Code:
       0: new           #2                  // class net/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$3
       3: dup
       4: invokespecial #34                 // Method "<init>":()V
       7: putstatic     #37                 // Field INSTANCE:Lnet/sinceat/aoc2020/day5/AppKt$main$2$maxSeatId$3;
      10: return
}