package gen

import java.io.File
import java.util.*
import kotlin.math.abs

fun main(args: Array<String>) {
	require(args.size == 1) { "Please pass a file as the first argument" }
	val source = File(args[0]).readText()
	println(gen(source))
}

fun gen(input: String): String {
	val ast = readAST(input.lineSequence().filterNot(String::isBlank))

	return (ast.compile() + "halt").print()
}

fun readAST(lines: Sequence<String>): AST {

	fun Sequence<String>.recurse(): Pair<AST, Sequence<String>> {
		val split = first().split("\\s+".toRegex(), 2)
		val (type, value) = if (split.size == 2) split else split + ""

		val tail = drop(1)
		return when (type) {
			";" -> AST.EMPTY to tail
			in listOf(
				"Sequence",
				"Prts",
				"Prti",
				"Prtc",
				"Assign",
				"While",
				"Less",
				"LessEqual",
				"NotEqual",
				"Add",
				"Negate",
				"Greater",
				"Divide",
				"Multiply",
				"Mod",
				"If", //TODO check
				"Subtract"
			) -> {
				val (first, firstLines) = tail.recurse()
				val (second, secondLines) = firstLines.recurse()
				AST.Binary(type, first, second) to secondLines
			}
			in listOf(
				"String",
				"Identifier",
				"Integer"
			) -> AST.Terminal(type, value) to tail
			else -> error("Unknown type $type")
		}
	}

	return lines.recurse().also { (_, lines) ->
		require(lines.toList().isEmpty()) { "Not everything was parsed: ${lines.toList()}" }
	}.first
}

sealed class AST {
	object EMPTY : AST()
	data class Binary(val name: String, val left: AST, val right: AST): AST()
	data class Terminal(val name: String, val value: String): AST()
}

data class Instruction(val address: Int, var name: String)

data class Assembly(
	val variables: Map<String, Int>,
	val constantStrings: List<String>,
	val code: List<Instruction>
) {

	val pc: Int get() = code.size

	fun print(): String =
		"Datasize: ${variables.size} Strings: ${constantStrings.size}\n" +
		(if (constantStrings.isNotEmpty()) constantStrings.joinToString(separator = "\n", postfix = "\n") else "") +
		code.joinToString(transform = { "%4d %-4s".format(it.address, it.name).trimEnd() }, separator = "\n")

	fun addConstantString(string: String): Assembly =
		if (constantStrings.contains(string)) this
		else this.copy(constantStrings = constantStrings + string)

	fun addVariable(string: String): Assembly =
		if (variables.contains(string)) this
		else this.copy(variables = variables + (string to variables.size))

	operator fun plus(name: String): Assembly = this.copy(
		code = code + Instruction(code.size, name)
	)

}

fun AST.compile(state: Assembly = Assembly(emptyMap(), emptyList(), emptyList())): Assembly = when(this) {
	AST.EMPTY -> state
	is AST.Binary -> when (name) {
		"Sequence" -> left.compile(state).let { right.compile(it) }
		//TODO merge all the cases of compiler right, compile left, do instruction
		"Prts" -> left.compile(state) + "prts"
		"Prti" -> left.compile(state) + "prti"
		"Prtc" -> left.compile(state) + "prtc"
		"Assign" -> (left as AST.Terminal).value.let { id ->
			right.compile(state).addVariable(id).let {
				it + "store [${it.variables[id]}]"
			}
		}
		"While" -> {
			val start = state.pc
			lateinit var jzPlaceholder: Instruction
			// test
			(left.compile(state) +
					// jz to end
					"jz placeholder"
					).let {
				jzPlaceholder = it.code.last()
				// body
				right.compile(it)
			}.let {
				// jmp back
				jzPlaceholder.name = "jz ${jumpDescriptor(jzPlaceholder.address, it.pc + 1)}"
				it + "jmp ${jumpDescriptor(it.pc, start)}"
			}
		}
		"If" -> {
			lateinit var jzPlaceholder: Instruction
			(left.compile(state) + "jz placeholder").let {
				jzPlaceholder = it.code.last()
				val (_, ifBody, elseBody) = right as AST.Binary
				ifBody.compile(it).let {
					jzPlaceholder.name = "jz ${jumpDescriptor(jzPlaceholder.address, it.pc)}"
					it //TODO else
				}
			}
		}
		"Less" -> left.compile(state).let { right.compile(it) + "lt" }
		"LessEqual" -> left.compile(state).let { right.compile(it) + "le" }
		"Equal" -> left.compile(state).let { right.compile(it) + "eq" }
		"NotEqual" -> left.compile(state).let { right.compile(it) + "ne" }

		"Greater" -> left.compile(state).let { right.compile(it) + "gt" }
		"Add" -> left.compile(state).let { right.compile(it) + "add" }
		"Subtract" -> left.compile(state).let { right.compile(it) + "sub" }
		"Divide" -> left.compile(state).let { right.compile(it) + "div" }
		"Multiply" -> left.compile(state).let { right.compile(it) + "mul" }
		"Mod" -> left.compile(state).let { right.compile(it) + "mod" }
		"Negate" -> left.compile(state) + "neg"

		else -> TODO(name)
	}
	is AST.Terminal -> when(name) {
		"String" -> state.addConstantString(value).let {
			it + "push ${it.constantStrings.indexOf(value)}"
		}
		"Integer" -> state + "push $value"
		"Identifier" -> state + "fetch [${state.variables[value]}]"
		else -> TODO(this.toString())
	}
}

private fun jumpDescriptor(from: Int, to: Int) = if (from > to) {
	"(${to - from + 1}) $to"
} else {
	"(${to - from - 1}) $to"
}

Compiled from "CodeGen.kt"
public final class gen.CodeGenKt {
  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: aload_0
       7: arraylength
       8: iconst_1
       9: if_icmpne     16
      12: iconst_1
      13: goto          17
      16: iconst_0
      17: ifne          37
      20: iconst_0
      21: istore_2
      22: ldc           #17                 // String Please pass a file as the first argument
      24: astore_2
      25: new           #19                 // class java/lang/IllegalArgumentException
      28: dup
      29: aload_2
      30: invokevirtual #23                 // Method java/lang/Object.toString:()Ljava/lang/String;
      33: invokespecial #27                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      36: athrow
      37: new           #29                 // class java/io/File
      40: dup
      41: aload_0
      42: iconst_0
      43: aaload
      44: invokespecial #30                 // Method java/io/File."<init>":(Ljava/lang/String;)V
      47: aconst_null
      48: iconst_1
      49: aconst_null
      50: invokestatic  #36                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      53: astore_1
      54: aload_1
      55: invokestatic  #40                 // Method gen:(Ljava/lang/String;)Ljava/lang/String;
      58: getstatic     #46                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: swap
      62: invokevirtual #52                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: return

  public static final java.lang.String gen(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #59                 // String input
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #61                 // class java/lang/CharSequence
      10: invokestatic  #67                 // Method kotlin/text/StringsKt.lineSequence:(Ljava/lang/CharSequence;)Lkotlin/sequences/Sequence;
      13: getstatic     #73                 // Field gen/CodeGenKt$gen$ast$1.INSTANCE:Lgen/CodeGenKt$gen$ast$1;
      16: checkcast     #75                 // class kotlin/jvm/functions/Function1
      19: invokestatic  #81                 // Method kotlin/sequences/SequencesKt.filterNot:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      22: invokestatic  #85                 // Method readAST:(Lkotlin/sequences/Sequence;)Lgen/AST;
      25: astore_1
      26: aload_1
      27: aconst_null
      28: iconst_1
      29: aconst_null
      30: invokestatic  #89                 // Method compile$default:(Lgen/AST;Lgen/Assembly;ILjava/lang/Object;)Lgen/Assembly;
      33: ldc           #91                 // String halt
      35: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
      38: invokevirtual #100                // Method gen/Assembly.print:()Ljava/lang/String;
      41: areturn

  public static final gen.AST readAST(kotlin.sequences.Sequence<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #105                // String lines
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #109                // Method readAST$recurse:(Lkotlin/sequences/Sequence;)Lkotlin/Pair;
      10: astore_1
      11: aload_1
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_2
      16: invokevirtual #115                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      19: checkcast     #117                // class kotlin/sequences/Sequence
      22: astore        4
      24: aload         4
      26: invokestatic  #121                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      29: invokeinterface #127,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      34: ifne          78
      37: iconst_0
      38: istore        5
      40: new           #129                // class java/lang/StringBuilder
      43: dup
      44: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
      47: ldc           #134                // String Not everything was parsed:
      49: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      52: aload         4
      54: invokestatic  #121                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      57: invokevirtual #141                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      60: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: astore        5
      65: new           #19                 // class java/lang/IllegalArgumentException
      68: dup
      69: aload         5
      71: invokevirtual #23                 // Method java/lang/Object.toString:()Ljava/lang/String;
      74: invokespecial #27                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      77: athrow
      78: nop
      79: aload_1
      80: invokevirtual #145                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      83: checkcast     #147                // class gen/AST
      86: areturn

  public static final gen.Assembly compile(gen.AST, gen.Assembly);
    Code:
       0: aload_0
       1: ldc           #154                // String <this>
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #156                // String state
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: astore_2
      14: aload_2
      15: getstatic     #161                // Field gen/AST$EMPTY.INSTANCE:Lgen/AST$EMPTY;
      18: invokestatic  #165                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      21: ifeq          28
      24: aload_1
      25: goto          1610
      28: aload_2
      29: instanceof    #167                // class gen/AST$Binary
      32: ifeq          1335
      35: aload_0
      36: checkcast     #167                // class gen/AST$Binary
      39: invokevirtual #170                // Method gen/AST$Binary.getName:()Ljava/lang/String;
      42: astore_3
      43: aload_3
      44: invokevirtual #176                // Method java/lang/String.hashCode:()I
      47: lookupswitch  { // 18
           -1995604172: 344
           -1965452510: 380
           -1949102853: 248
                  2365: 392
                 65665: 200
                 77538: 224
               2364857: 404
               2496529: 320
               2496535: 284
               2496545: 236
              67204884: 308
              83548945: 272
             718473796: 332
            1414192097: 260
            1617099841: 212
            1948255194: 368
            1970629903: 356
            2047371417: 296
               default: 1297
          }
     200: aload_3
     201: ldc           #178                // String Add
     203: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     206: ifne          1092
     209: goto          1297
     212: aload_3
     213: ldc           #184                // String NotEqual
     215: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     218: ifne          1018
     221: goto          1297
     224: aload_3
     225: ldc           #186                // String Mod
     227: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     230: ifne          1240
     233: goto          1297
     236: aload_3
     237: ldc           #188                // String Prts
     239: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     242: ifne          447
     245: goto          1297
     248: aload_3
     249: ldc           #190                // String LessEqual
     251: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     254: ifne          944
     257: goto          1297
     260: aload_3
     261: ldc           #192                // String Sequence
     263: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     266: ifne          416
     269: goto          1297
     272: aload_3
     273: ldc           #194                // String While
     275: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     278: ifne          599
     281: goto          1297
     284: aload_3
     285: ldc           #196                // String Prti
     287: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     290: ifne          466
     293: goto          1297
     296: aload_3
     297: ldc           #198                // String Divide
     299: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     302: ifne          1166
     305: goto          1297
     308: aload_3
     309: ldc           #200                // String Equal
     311: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     314: ifne          981
     317: goto          1297
     320: aload_3
     321: ldc           #202                // String Prtc
     323: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     326: ifne          485
     329: goto          1297
     332: aload_3
     333: ldc           #204                // String Multiply
     335: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     338: ifne          1203
     341: goto          1297
     344: aload_3
     345: ldc           #206                // String Subtract
     347: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     350: ifne          1129
     353: goto          1297
     356: aload_3
     357: ldc           #208                // String Assign
     359: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     362: ifne          504
     365: goto          1297
     368: aload_3
     369: ldc           #210                // String Greater
     371: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     374: ifne          1055
     377: goto          1297
     380: aload_3
     381: ldc           #212                // String Negate
     383: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     386: ifne          1277
     389: goto          1297
     392: aload_3
     393: ldc           #214                // String If
     395: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     398: ifne          756
     401: goto          1297
     404: aload_3
     405: ldc           #216                // String Less
     407: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     410: ifne          907
     413: goto          1297
     416: aload_0
     417: checkcast     #167                // class gen/AST$Binary
     420: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     423: aload_1
     424: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     427: astore        5
     429: iconst_0
     430: istore        6
     432: aload_0
     433: checkcast     #167                // class gen/AST$Binary
     436: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     439: aload         5
     441: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     444: goto          1610
     447: aload_0
     448: checkcast     #167                // class gen/AST$Binary
     451: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     454: aload_1
     455: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     458: ldc           #227                // String prts
     460: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     463: goto          1610
     466: aload_0
     467: checkcast     #167                // class gen/AST$Binary
     470: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     473: aload_1
     474: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     477: ldc           #229                // String prti
     479: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     482: goto          1610
     485: aload_0
     486: checkcast     #167                // class gen/AST$Binary
     489: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     492: aload_1
     493: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     496: ldc           #231                // String prtc
     498: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     501: goto          1610
     504: aload_0
     505: checkcast     #167                // class gen/AST$Binary
     508: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     511: astore        4
     513: aload         4
     515: ldc           #233                // String null cannot be cast to non-null type gen.AST.Terminal
     517: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     520: aload         4
     522: checkcast     #238                // class gen/AST$Terminal
     525: invokevirtual #241                // Method gen/AST$Terminal.getValue:()Ljava/lang/String;
     528: astore        5
     530: iconst_0
     531: istore        6
     533: aload_0
     534: checkcast     #167                // class gen/AST$Binary
     537: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     540: aload_1
     541: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     544: aload         5
     546: invokevirtual #244                // Method gen/Assembly.addVariable:(Ljava/lang/String;)Lgen/Assembly;
     549: astore        7
     551: iconst_0
     552: istore        8
     554: aload         7
     556: new           #129                // class java/lang/StringBuilder
     559: dup
     560: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     563: ldc           #246                // String store [
     565: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     568: aload         7
     570: invokevirtual #250                // Method gen/Assembly.getVariables:()Ljava/util/Map;
     573: aload         5
     575: invokeinterface #256,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     580: invokevirtual #141                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     583: bipush        93
     585: invokevirtual #259                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     588: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     591: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     594: nop
     595: nop
     596: goto          1610
     599: aload_1
     600: invokevirtual #262                // Method gen/Assembly.getPc:()I
     603: istore        4
     605: aconst_null
     606: astore        5
     608: aload_0
     609: checkcast     #167                // class gen/AST$Binary
     612: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     615: aload_1
     616: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     619: ldc_w         #264                // String jz placeholder
     622: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     625: astore        7
     627: iconst_0
     628: istore        8
     630: aload         7
     632: invokevirtual #268                // Method gen/Assembly.getCode:()Ljava/util/List;
     635: invokestatic  #274                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     638: astore        5
     640: aload_0
     641: checkcast     #167                // class gen/AST$Binary
     644: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     647: aload         7
     649: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     652: nop
     653: astore        7
     655: iconst_0
     656: istore        8
     658: aload         5
     660: dup
     661: ifnonnull     675
     664: pop
     665: ldc_w         #276                // String jzPlaceholder
     668: invokestatic  #279                // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
     671: aconst_null
     672: goto          678
     675: checkcast     #281                // class gen/Instruction
     678: new           #129                // class java/lang/StringBuilder
     681: dup
     682: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     685: ldc_w         #283                // String jz
     688: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     691: aload         5
     693: checkcast     #281                // class gen/Instruction
     696: invokevirtual #286                // Method gen/Instruction.getAddress:()I
     699: aload         7
     701: invokevirtual #262                // Method gen/Assembly.getPc:()I
     704: iconst_1
     705: iadd
     706: invokestatic  #290                // Method jumpDescriptor:(II)Ljava/lang/String;
     709: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     712: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     715: invokevirtual #293                // Method gen/Instruction.setName:(Ljava/lang/String;)V
     718: aload         7
     720: new           #129                // class java/lang/StringBuilder
     723: dup
     724: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     727: ldc_w         #295                // String jmp
     730: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     733: aload         7
     735: invokevirtual #262                // Method gen/Assembly.getPc:()I
     738: iload         4
     740: invokestatic  #290                // Method jumpDescriptor:(II)Ljava/lang/String;
     743: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     746: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     749: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     752: nop
     753: goto          1610
     756: aconst_null
     757: astore        4
     759: aload_0
     760: checkcast     #167                // class gen/AST$Binary
     763: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     766: aload_1
     767: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     770: ldc_w         #264                // String jz placeholder
     773: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     776: astore        6
     778: iconst_0
     779: istore        7
     781: aload         6
     783: invokevirtual #268                // Method gen/Assembly.getCode:()Ljava/util/List;
     786: invokestatic  #274                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     789: astore        4
     791: aload_0
     792: checkcast     #167                // class gen/AST$Binary
     795: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     798: astore        8
     800: aload         8
     802: ldc_w         #297                // String null cannot be cast to non-null type gen.AST.Binary
     805: invokestatic  #236                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V
     808: aload         8
     810: checkcast     #167                // class gen/AST$Binary
     813: astore        9
     815: aload         9
     817: invokevirtual #299                // Method gen/AST$Binary.component2:()Lgen/AST;
     820: astore        8
     822: aload         9
     824: invokevirtual #302                // Method gen/AST$Binary.component3:()Lgen/AST;
     827: astore        10
     829: aload         8
     831: aload         6
     833: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     836: astore        11
     838: iconst_0
     839: istore        12
     841: aload         4
     843: dup
     844: ifnonnull     858
     847: pop
     848: ldc_w         #276                // String jzPlaceholder
     851: invokestatic  #279                // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V
     854: aconst_null
     855: goto          861
     858: checkcast     #281                // class gen/Instruction
     861: new           #129                // class java/lang/StringBuilder
     864: dup
     865: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     868: ldc_w         #283                // String jz
     871: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     874: aload         4
     876: checkcast     #281                // class gen/Instruction
     879: invokevirtual #286                // Method gen/Instruction.getAddress:()I
     882: aload         11
     884: invokevirtual #262                // Method gen/Assembly.getPc:()I
     887: invokestatic  #290                // Method jumpDescriptor:(II)Ljava/lang/String;
     890: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     893: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     896: invokevirtual #293                // Method gen/Instruction.setName:(Ljava/lang/String;)V
     899: aload         11
     901: nop
     902: nop
     903: nop
     904: goto          1610
     907: aload_0
     908: checkcast     #167                // class gen/AST$Binary
     911: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     914: aload_1
     915: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     918: astore        5
     920: iconst_0
     921: istore        6
     923: aload_0
     924: checkcast     #167                // class gen/AST$Binary
     927: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     930: aload         5
     932: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     935: ldc_w         #304                // String lt
     938: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     941: goto          1610
     944: aload_0
     945: checkcast     #167                // class gen/AST$Binary
     948: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     951: aload_1
     952: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     955: astore        5
     957: iconst_0
     958: istore        6
     960: aload_0
     961: checkcast     #167                // class gen/AST$Binary
     964: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
     967: aload         5
     969: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     972: ldc_w         #306                // String le
     975: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
     978: goto          1610
     981: aload_0
     982: checkcast     #167                // class gen/AST$Binary
     985: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
     988: aload_1
     989: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
     992: astore        5
     994: iconst_0
     995: istore        6
     997: aload_0
     998: checkcast     #167                // class gen/AST$Binary
    1001: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1004: aload         5
    1006: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1009: ldc_w         #308                // String eq
    1012: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1015: goto          1610
    1018: aload_0
    1019: checkcast     #167                // class gen/AST$Binary
    1022: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1025: aload_1
    1026: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1029: astore        5
    1031: iconst_0
    1032: istore        6
    1034: aload_0
    1035: checkcast     #167                // class gen/AST$Binary
    1038: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1041: aload         5
    1043: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1046: ldc_w         #310                // String ne
    1049: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1052: goto          1610
    1055: aload_0
    1056: checkcast     #167                // class gen/AST$Binary
    1059: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1062: aload_1
    1063: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1066: astore        5
    1068: iconst_0
    1069: istore        6
    1071: aload_0
    1072: checkcast     #167                // class gen/AST$Binary
    1075: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1078: aload         5
    1080: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1083: ldc_w         #312                // String gt
    1086: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1089: goto          1610
    1092: aload_0
    1093: checkcast     #167                // class gen/AST$Binary
    1096: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1099: aload_1
    1100: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1103: astore        5
    1105: iconst_0
    1106: istore        6
    1108: aload_0
    1109: checkcast     #167                // class gen/AST$Binary
    1112: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1115: aload         5
    1117: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1120: ldc_w         #314                // String add
    1123: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1126: goto          1610
    1129: aload_0
    1130: checkcast     #167                // class gen/AST$Binary
    1133: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1136: aload_1
    1137: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1140: astore        5
    1142: iconst_0
    1143: istore        6
    1145: aload_0
    1146: checkcast     #167                // class gen/AST$Binary
    1149: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1152: aload         5
    1154: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1157: ldc_w         #316                // String sub
    1160: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1163: goto          1610
    1166: aload_0
    1167: checkcast     #167                // class gen/AST$Binary
    1170: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1173: aload_1
    1174: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1177: astore        5
    1179: iconst_0
    1180: istore        6
    1182: aload_0
    1183: checkcast     #167                // class gen/AST$Binary
    1186: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1189: aload         5
    1191: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1194: ldc_w         #318                // String div
    1197: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1200: goto          1610
    1203: aload_0
    1204: checkcast     #167                // class gen/AST$Binary
    1207: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1210: aload_1
    1211: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1214: astore        5
    1216: iconst_0
    1217: istore        6
    1219: aload_0
    1220: checkcast     #167                // class gen/AST$Binary
    1223: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1226: aload         5
    1228: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1231: ldc_w         #320                // String mul
    1234: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1237: goto          1610
    1240: aload_0
    1241: checkcast     #167                // class gen/AST$Binary
    1244: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1247: aload_1
    1248: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1251: astore        5
    1253: iconst_0
    1254: istore        6
    1256: aload_0
    1257: checkcast     #167                // class gen/AST$Binary
    1260: invokevirtual #225                // Method gen/AST$Binary.getRight:()Lgen/AST;
    1263: aload         5
    1265: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1268: ldc_w         #322                // String mod
    1271: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1274: goto          1610
    1277: aload_0
    1278: checkcast     #167                // class gen/AST$Binary
    1281: invokevirtual #220                // Method gen/AST$Binary.getLeft:()Lgen/AST;
    1284: aload_1
    1285: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
    1288: ldc_w         #324                // String neg
    1291: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1294: goto          1610
    1297: aload_0
    1298: checkcast     #167                // class gen/AST$Binary
    1301: invokevirtual #170                // Method gen/AST$Binary.getName:()Ljava/lang/String;
    1304: astore        4
    1306: new           #326                // class kotlin/NotImplementedError
    1309: dup
    1310: new           #129                // class java/lang/StringBuilder
    1313: dup
    1314: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
    1317: ldc_w         #328                // String An operation is not implemented:
    1320: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1323: aload         4
    1325: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1328: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1331: invokespecial #329                // Method kotlin/NotImplementedError."<init>":(Ljava/lang/String;)V
    1334: athrow
    1335: aload_2
    1336: instanceof    #238                // class gen/AST$Terminal
    1339: ifeq          1602
    1342: aload_0
    1343: checkcast     #238                // class gen/AST$Terminal
    1346: invokevirtual #330                // Method gen/AST$Terminal.getName:()Ljava/lang/String;
    1349: astore_3
    1350: aload_3
    1351: invokevirtual #176                // Method java/lang/String.hashCode:()I
    1354: lookupswitch  { // 3
           -1808118735: 1414
            -672261858: 1388
             375032009: 1401
               default: 1564
          }
    1388: aload_3
    1389: ldc_w         #332                // String Integer
    1392: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
    1395: ifne          1484
    1398: goto          1564
    1401: aload_3
    1402: ldc_w         #334                // String Identifier
    1405: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
    1408: ifne          1517
    1411: goto          1564
    1414: aload_3
    1415: ldc_w         #336                // String String
    1418: invokevirtual #182                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
    1421: ifeq          1564
    1424: aload_1
    1425: aload_0
    1426: checkcast     #238                // class gen/AST$Terminal
    1429: invokevirtual #241                // Method gen/AST$Terminal.getValue:()Ljava/lang/String;
    1432: invokevirtual #339                // Method gen/Assembly.addConstantString:(Ljava/lang/String;)Lgen/Assembly;
    1435: astore        5
    1437: iconst_0
    1438: istore        6
    1440: aload         5
    1442: new           #129                // class java/lang/StringBuilder
    1445: dup
    1446: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
    1449: ldc_w         #341                // String push
    1452: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1455: aload         5
    1457: invokevirtual #344                // Method gen/Assembly.getConstantStrings:()Ljava/util/List;
    1460: aload_0
    1461: checkcast     #238                // class gen/AST$Terminal
    1464: invokevirtual #241                // Method gen/AST$Terminal.getValue:()Ljava/lang/String;
    1467: invokeinterface #348,  2          // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I
    1472: invokevirtual #351                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1475: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1478: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1481: goto          1610
    1484: aload_1
    1485: new           #129                // class java/lang/StringBuilder
    1488: dup
    1489: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
    1492: ldc_w         #341                // String push
    1495: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1498: aload_0
    1499: checkcast     #238                // class gen/AST$Terminal
    1502: invokevirtual #241                // Method gen/AST$Terminal.getValue:()Ljava/lang/String;
    1505: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1508: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1511: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1514: goto          1610
    1517: aload_1
    1518: new           #129                // class java/lang/StringBuilder
    1521: dup
    1522: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
    1525: ldc_w         #353                // String fetch [
    1528: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1531: aload_1
    1532: invokevirtual #250                // Method gen/Assembly.getVariables:()Ljava/util/Map;
    1535: aload_0
    1536: checkcast     #238                // class gen/AST$Terminal
    1539: invokevirtual #241                // Method gen/AST$Terminal.getValue:()Ljava/lang/String;
    1542: invokeinterface #256,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
    1547: invokevirtual #141                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1550: bipush        93
    1552: invokevirtual #259                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1555: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1558: invokevirtual #97                 // Method gen/Assembly.plus:(Ljava/lang/String;)Lgen/Assembly;
    1561: goto          1610
    1564: aload_0
    1565: checkcast     #238                // class gen/AST$Terminal
    1568: invokevirtual #354                // Method gen/AST$Terminal.toString:()Ljava/lang/String;
    1571: astore        4
    1573: new           #326                // class kotlin/NotImplementedError
    1576: dup
    1577: new           #129                // class java/lang/StringBuilder
    1580: dup
    1581: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
    1584: ldc_w         #328                // String An operation is not implemented:
    1587: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1590: aload         4
    1592: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1595: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1598: invokespecial #329                // Method kotlin/NotImplementedError."<init>":(Ljava/lang/String;)V
    1601: athrow
    1602: new           #356                // class kotlin/NoWhenBranchMatchedException
    1605: dup
    1606: invokespecial #357                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
    1609: athrow
    1610: areturn

  public static gen.Assembly compile$default(gen.AST, gen.Assembly, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          23
       6: new           #93                 // class gen/Assembly
       9: dup
      10: invokestatic  #388                // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;
      13: invokestatic  #391                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      16: invokestatic  #391                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      19: invokespecial #394                // Method gen/Assembly."<init>":(Ljava/util/Map;Ljava/util/List;Ljava/util/List;)V
      22: astore_1
      23: aload_0
      24: aload_1
      25: invokestatic  #222                // Method compile:(Lgen/AST;Lgen/Assembly;)Lgen/Assembly;
      28: areturn

  private static final java.lang.String jumpDescriptor(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: if_icmple     41
       5: new           #129                // class java/lang/StringBuilder
       8: dup
       9: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
      12: bipush        40
      14: invokevirtual #259                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      17: iload_1
      18: iload_0
      19: isub
      20: iconst_1
      21: iadd
      22: invokevirtual #351                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      25: ldc_w         #396                // String )
      28: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      31: iload_1
      32: invokevirtual #351                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      35: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      38: goto          74
      41: new           #129                // class java/lang/StringBuilder
      44: dup
      45: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
      48: bipush        40
      50: invokevirtual #259                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      53: iload_1
      54: iload_0
      55: isub
      56: iconst_1
      57: isub
      58: invokevirtual #351                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      61: ldc_w         #396                // String )
      64: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      67: iload_1
      68: invokevirtual #351                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      71: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      74: areturn

  private static final kotlin.Pair<gen.AST, kotlin.sequences.Sequence<java.lang.String>> readAST$recurse(kotlin.sequences.Sequence<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #403                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
       4: checkcast     #61                 // class java/lang/CharSequence
       7: astore_2
       8: new           #405                // class kotlin/text/Regex
      11: dup
      12: ldc_w         #407                // String \\s+
      15: invokespecial #408                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      18: astore_3
      19: iconst_2
      20: istore        4
      22: aload_3
      23: aload_2
      24: iload         4
      26: invokevirtual #412                // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
      29: astore_1
      30: aload_1
      31: invokeinterface #415,  1          // InterfaceMethod java/util/List.size:()I
      36: iconst_2
      37: if_icmpne     44
      40: aload_1
      41: goto          54
      44: aload_1
      45: checkcast     #417                // class java/util/Collection
      48: ldc_w         #419                // String
      51: invokestatic  #422                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
      54: astore_2
      55: aload_2
      56: iconst_0
      57: invokeinterface #425,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      62: checkcast     #172                // class java/lang/String
      65: astore_3
      66: aload_2
      67: iconst_1
      68: invokeinterface #425,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      73: checkcast     #172                // class java/lang/String
      76: astore        4
      78: aload_0
      79: iconst_1
      80: invokestatic  #429                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
      83: astore        5
      85: aload_3
      86: astore        6
      88: aload         6
      90: ldc_w         #431                // String ;
      93: invokestatic  #165                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      96: ifeq          110
      99: getstatic     #161                // Field gen/AST$EMPTY.INSTANCE:Lgen/AST$EMPTY;
     102: aload         5
     104: invokestatic  #436                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     107: goto          410
     110: bipush        17
     112: anewarray     #172                // class java/lang/String
     115: astore        7
     117: aload         7
     119: iconst_0
     120: ldc           #192                // String Sequence
     122: aastore
     123: aload         7
     125: iconst_1
     126: ldc           #188                // String Prts
     128: aastore
     129: aload         7
     131: iconst_2
     132: ldc           #196                // String Prti
     134: aastore
     135: aload         7
     137: iconst_3
     138: ldc           #202                // String Prtc
     140: aastore
     141: aload         7
     143: iconst_4
     144: ldc           #208                // String Assign
     146: aastore
     147: aload         7
     149: iconst_5
     150: ldc           #194                // String While
     152: aastore
     153: aload         7
     155: bipush        6
     157: ldc           #216                // String Less
     159: aastore
     160: aload         7
     162: bipush        7
     164: ldc           #190                // String LessEqual
     166: aastore
     167: aload         7
     169: bipush        8
     171: ldc           #184                // String NotEqual
     173: aastore
     174: aload         7
     176: bipush        9
     178: ldc           #178                // String Add
     180: aastore
     181: aload         7
     183: bipush        10
     185: ldc           #212                // String Negate
     187: aastore
     188: aload         7
     190: bipush        11
     192: ldc           #210                // String Greater
     194: aastore
     195: aload         7
     197: bipush        12
     199: ldc           #198                // String Divide
     201: aastore
     202: aload         7
     204: bipush        13
     206: ldc           #204                // String Multiply
     208: aastore
     209: aload         7
     211: bipush        14
     213: ldc           #186                // String Mod
     215: aastore
     216: aload         7
     218: bipush        15
     220: ldc           #214                // String If
     222: aastore
     223: aload         7
     225: bipush        16
     227: ldc           #206                // String Subtract
     229: aastore
     230: aload         7
     232: invokestatic  #440                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     235: aload         6
     237: invokeinterface #443,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     242: ifeq          319
     245: aload         5
     247: invokestatic  #109                // Method readAST$recurse:(Lkotlin/sequences/Sequence;)Lkotlin/Pair;
     250: astore        7
     252: aload         7
     254: invokevirtual #446                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     257: checkcast     #147                // class gen/AST
     260: astore        8
     262: aload         7
     264: invokevirtual #115                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     267: checkcast     #117                // class kotlin/sequences/Sequence
     270: astore        9
     272: aload         9
     274: invokestatic  #109                // Method readAST$recurse:(Lkotlin/sequences/Sequence;)Lkotlin/Pair;
     277: astore        10
     279: aload         10
     281: invokevirtual #446                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     284: checkcast     #147                // class gen/AST
     287: astore        11
     289: aload         10
     291: invokevirtual #115                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     294: checkcast     #117                // class kotlin/sequences/Sequence
     297: astore        12
     299: new           #167                // class gen/AST$Binary
     302: dup
     303: aload_3
     304: aload         8
     306: aload         11
     308: invokespecial #449                // Method gen/AST$Binary."<init>":(Ljava/lang/String;Lgen/AST;Lgen/AST;)V
     311: aload         12
     313: invokestatic  #436                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     316: goto          410
     319: iconst_3
     320: anewarray     #172                // class java/lang/String
     323: astore        7
     325: aload         7
     327: iconst_0
     328: ldc_w         #336                // String String
     331: aastore
     332: aload         7
     334: iconst_1
     335: ldc_w         #334                // String Identifier
     338: aastore
     339: aload         7
     341: iconst_2
     342: ldc_w         #332                // String Integer
     345: aastore
     346: aload         7
     348: invokestatic  #440                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     351: aload         6
     353: invokeinterface #443,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     358: ifeq          379
     361: new           #238                // class gen/AST$Terminal
     364: dup
     365: aload_3
     366: aload         4
     368: invokespecial #452                // Method gen/AST$Terminal."<init>":(Ljava/lang/String;Ljava/lang/String;)V
     371: aload         5
     373: invokestatic  #436                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     376: goto          410
     379: new           #454                // class java/lang/IllegalStateException
     382: dup
     383: new           #129                // class java/lang/StringBuilder
     386: dup
     387: invokespecial #132                // Method java/lang/StringBuilder."<init>":()V
     390: ldc_w         #456                // String Unknown type
     393: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     396: aload_3
     397: invokevirtual #138                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     400: invokevirtual #142                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     403: invokevirtual #23                 // Method java/lang/Object.toString:()Ljava/lang/String;
     406: invokespecial #457                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     409: athrow
     410: areturn
}

Compiled from "CodeGen.kt"
final class gen.CodeGenKt$gen$ast$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Boolean> {
  public static final gen.CodeGenKt$gen$ast$1 INSTANCE;

  gen.CodeGenKt$gen$ast$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/text/StringsKt
       4: ldc           #13                 // String isBlank
       6: ldc           #15                 // String isBlank(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: invokestatic  #35                 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      13: invokestatic  #41                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      16: areturn

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

  static {};
    Code:
       0: new           #2                  // class gen/CodeGenKt$gen$ast$1
       3: dup
       4: invokespecial #52                 // Method "<init>":()V
       7: putstatic     #55                 // Field INSTANCE:Lgen/CodeGenKt$gen$ast$1;
      10: return
}


package cinema

const val SEATSLIMIT = 60
const val VIPRICE = 10
const val POORPRICE = 8

fun inputRoom(): String {
    println("Enter the number of rows:")
    val r = readLine()!!
    println("Enter the number of seats in each row:")
    val s = readLine()!!
    return "$r $s"
}

fun scheme(cinema: MutableList<MutableList<Char>>) {
    print("\nCinema:\n ")
    for (i in 1..cinema[0].size) print(" $i")
    println()
    for (i in 0 until cinema.size) println("${i + 1} ${cinema[i].joinToString(" ")}")
}

fun inputSeat(): String {
    println("\nEnter a row number:")
    val r = readLine()!!
    println("Enter a seat number in that row:")
    val s = readLine()!!
    return "$r $s"
}

fun smallRoom() = VIPRICE

fun bigRoom(rows: Int, seatR: Int) = if (seatR <= rows / 2) VIPRICE else POORPRICE

fun calculateSeat(cinema: MutableList<MutableList<Char>>, seatR: Int): Int {
    if (cinema.size * cinema[0].size <= SEATSLIMIT) {
        return smallRoom()
    }
    return bigRoom(cinema.size, seatR)
}

fun shopping(cinema: MutableList<MutableList<Char>>) {
    val (seatR, seatS) = inputSeat().split(" ").map { it.toInt() }
    println()
    if (seatR < 1 || seatR > cinema.size || seatS < 1 || seatS > cinema[0].size) {
        println("Wrong input!")
        shopping(cinema)
        return
    }
    when (cinema[seatR - 1][seatS - 1]) {
        'S' -> {
            cinema[seatR - 1][seatS - 1] = 'B'
            println("Ticket price: \$${calculateSeat(cinema, seatR)}")
        }
        'B' -> {
            println("That ticket has already been purchased!")
            shopping(cinema)
        }
    }
}

fun calculateAll(cinema: MutableList<MutableList<Char>>): Int {
    var result = 0
    for (row in 0 until  cinema.size) for (seat in cinema[row]) result += calculateSeat(cinema, row + 1)
    return result
}

fun stats(cinema: MutableList<MutableList<Char>>) {
    var bought = 0
    var income = 0
    for (row in cinema) for (seat in row) bought += if (seat == 'B') 1 else 0
    println("\nNumber of purchased tickets: $bought")
    var notPrc = bought * 100000 / (cinema.size * cinema[0].size)
    notPrc = (notPrc + if (notPrc % 10 > 4) 10 else 0) / 10
    val prc = (notPrc / 100).toString() + "." + (notPrc % 100 / 10).toString() + (notPrc % 10).toString()
    println("Percentage: ${prc}%")
    for (row in 0 until  cinema.size) for (seat in cinema[row]) income += if (seat == 'B') calculateSeat(cinema, row + 1) else 0
    println("Current income: \$$income")
    println("Total income: \$${calculateAll(cinema)}")
}

fun main() {
    val (rows, seats) = inputRoom().split(" ").map { it.toInt() }
    val cinema = MutableList(rows) { MutableList(seats) { 'S' } }
    var choice = -1
    while (choice != 0) {
        println()
        println("""
            1. Show the seats
            2. Buy a ticket
            3. Statistics
            0. Exit
        """.trimIndent())
        choice = readLine()!!.toInt()
        when (choice) {
            1 -> scheme(cinema)
            2 -> shopping(cinema)
            3 -> stats(cinema)
        }
    }
}

Compiled from "Cinema.kt"
public final class cinema.CinemaKt {
  public static final int SEATSLIMIT;

  public static final int VIPRICE;

  public static final int POORPRICE;

  public static final java.lang.String inputRoom();
    Code:
       0: ldc           #9                  // String Enter the number of rows:
       2: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      12: dup
      13: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      16: astore_0
      17: ldc           #33                 // String Enter the number of seats in each row:
      19: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
      22: swap
      23: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      26: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      29: dup
      30: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      33: astore_1
      34: new           #35                 // class java/lang/StringBuilder
      37: dup
      38: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
      41: aload_0
      42: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      45: bipush        32
      47: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      50: aload_1
      51: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      54: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: areturn

  public static final void scheme(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #57                 // String cinema
       3: invokestatic  #61                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #63                 // String \nCinema:\n
       8: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #66                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      15: iconst_1
      16: istore_1
      17: aload_0
      18: iconst_0
      19: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      24: checkcast     #68                 // class java/util/List
      27: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      32: istore_2
      33: iload_1
      34: iload_2
      35: if_icmpgt     75
      38: new           #35                 // class java/lang/StringBuilder
      41: dup
      42: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
      45: bipush        32
      47: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      50: iload_1
      51: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      54: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
      60: swap
      61: invokevirtual #66                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      64: iload_1
      65: iload_2
      66: if_icmpeq     75
      69: iinc          1, 1
      72: goto          38
      75: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
      78: invokevirtual #81                 // Method java/io/PrintStream.println:()V
      81: iconst_0
      82: istore_1
      83: aload_0
      84: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      89: istore_2
      90: iload_1
      91: iload_2
      92: if_icmpge     158
      95: new           #35                 // class java/lang/StringBuilder
      98: dup
      99: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     102: iload_1
     103: iconst_1
     104: iadd
     105: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     108: bipush        32
     110: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     113: aload_0
     114: iload_1
     115: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     120: checkcast     #83                 // class java/lang/Iterable
     123: ldc           #85                 // String
     125: checkcast     #87                 // class java/lang/CharSequence
     128: aconst_null
     129: aconst_null
     130: iconst_0
     131: aconst_null
     132: aconst_null
     133: bipush        62
     135: aconst_null
     136: invokestatic  #93                 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     139: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     142: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     145: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     148: swap
     149: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     152: iinc          1, 1
     155: goto          90
     158: return

  public static final java.lang.String inputSeat();
    Code:
       0: ldc           #99                 // String \nEnter a row number:
       2: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      12: dup
      13: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      16: astore_0
      17: ldc           #101                // String Enter a seat number in that row:
      19: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
      22: swap
      23: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      26: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      29: dup
      30: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      33: astore_1
      34: new           #35                 // class java/lang/StringBuilder
      37: dup
      38: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
      41: aload_0
      42: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      45: bipush        32
      47: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      50: aload_1
      51: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      54: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      57: areturn

  public static final int smallRoom();
    Code:
       0: bipush        10
       2: ireturn

  public static final int bigRoom(int, int);
    Code:
       0: iload_1
       1: iload_0
       2: iconst_2
       3: idiv
       4: if_icmpgt     12
       7: bipush        10
       9: goto          14
      12: bipush        8
      14: ireturn

  public static final int calculateSeat(java.util.List<java.util.List<java.lang.Character>>, int);
    Code:
       0: aload_0
       1: ldc           #57                 // String cinema
       3: invokestatic  #61                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      12: aload_0
      13: iconst_0
      14: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      19: checkcast     #68                 // class java/util/List
      22: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      27: imul
      28: bipush        60
      30: if_icmpgt     37
      33: invokestatic  #111                // Method smallRoom:()I
      36: ireturn
      37: aload_0
      38: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      43: iload_1
      44: invokestatic  #113                // Method bigRoom:(II)I
      47: ireturn

  public static final void shopping(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #57                 // String cinema
       3: invokestatic  #61                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #116                // Method inputSeat:()Ljava/lang/String;
       9: checkcast     #87                 // class java/lang/CharSequence
      12: iconst_1
      13: anewarray     #118                // class java/lang/String
      16: astore_2
      17: aload_2
      18: iconst_0
      19: ldc           #85                 // String
      21: aastore
      22: aload_2
      23: iconst_0
      24: iconst_0
      25: bipush        6
      27: aconst_null
      28: invokestatic  #124                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      31: checkcast     #83                 // class java/lang/Iterable
      34: astore_2
      35: iconst_0
      36: istore_3
      37: aload_2
      38: astore        4
      40: new           #126                // class java/util/ArrayList
      43: dup
      44: aload_2
      45: bipush        10
      47: invokestatic  #130                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      50: invokespecial #133                // Method java/util/ArrayList."<init>":(I)V
      53: checkcast     #135                // class java/util/Collection
      56: astore        5
      58: iconst_0
      59: istore        6
      61: aload         4
      63: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        7
      70: aload         7
      72: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          124
      80: aload         7
      82: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: astore        8
      89: aload         5
      91: aload         8
      93: checkcast     #118                // class java/lang/String
      96: astore        9
      98: astore        11
     100: iconst_0
     101: istore        10
     103: aload         9
     105: invokestatic  #155                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     108: nop
     109: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     112: aload         11
     114: swap
     115: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     120: pop
     121: goto          70
     124: aload         5
     126: checkcast     #68                 // class java/util/List
     129: nop
     130: astore_1
     131: aload_1
     132: iconst_0
     133: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     138: checkcast     #165                // class java/lang/Number
     141: invokevirtual #168                // Method java/lang/Number.intValue:()I
     144: istore_2
     145: aload_1
     146: iconst_1
     147: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     152: checkcast     #165                // class java/lang/Number
     155: invokevirtual #168                // Method java/lang/Number.intValue:()I
     158: istore_3
     159: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     162: invokevirtual #81                 // Method java/io/PrintStream.println:()V
     165: iload_2
     166: iconst_1
     167: if_icmplt     204
     170: iload_2
     171: aload_0
     172: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
     177: if_icmpgt     204
     180: iload_3
     181: iconst_1
     182: if_icmplt     204
     185: iload_3
     186: aload_0
     187: iconst_0
     188: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     193: checkcast     #68                 // class java/util/List
     196: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
     201: if_icmple     218
     204: ldc           #170                // String Wrong input!
     206: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     209: swap
     210: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     213: aload_0
     214: invokestatic  #172                // Method shopping:(Ljava/util/List;)V
     217: return
     218: aload_0
     219: iload_2
     220: iconst_1
     221: isub
     222: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     227: checkcast     #68                 // class java/util/List
     230: iload_3
     231: iconst_1
     232: isub
     233: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     238: checkcast     #174                // class java/lang/Character
     241: invokevirtual #178                // Method java/lang/Character.charValue:()C
     244: lookupswitch  { // 2
                    66: 331
                    83: 272
               default: 344
          }
     272: aload_0
     273: iload_2
     274: iconst_1
     275: isub
     276: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     281: checkcast     #68                 // class java/util/List
     284: iload_3
     285: iconst_1
     286: isub
     287: bipush        66
     289: invokestatic  #181                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     292: invokeinterface #185,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     297: pop
     298: new           #35                 // class java/lang/StringBuilder
     301: dup
     302: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     305: ldc           #187                // String Ticket price: $
     307: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     310: aload_0
     311: iload_2
     312: invokestatic  #189                // Method calculateSeat:(Ljava/util/List;I)I
     315: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     318: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     321: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     324: swap
     325: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     328: goto          344
     331: ldc           #191                // String That ticket has already been purchased!
     333: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     336: swap
     337: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     340: aload_0
     341: invokestatic  #172                // Method shopping:(Ljava/util/List;)V
     344: return

  public static final int calculateAll(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #57                 // String cinema
       3: invokestatic  #61                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iconst_0
       9: istore_2
      10: aload_0
      11: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
      16: istore_3
      17: iload_2
      18: iload_3
      19: if_icmpge     83
      22: aload_0
      23: iload_2
      24: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #68                 // class java/util/List
      32: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      37: astore        4
      39: aload         4
      41: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          77
      49: aload         4
      51: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: checkcast     #174                // class java/lang/Character
      59: invokevirtual #178                // Method java/lang/Character.charValue:()C
      62: istore        5
      64: iload_1
      65: aload_0
      66: iload_2
      67: iconst_1
      68: iadd
      69: invokestatic  #189                // Method calculateSeat:(Ljava/util/List;I)I
      72: iadd
      73: istore_1
      74: goto          39
      77: iinc          2, 1
      80: goto          17
      83: iload_1
      84: ireturn

  public static final void stats(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #57                 // String cinema
       3: invokestatic  #61                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: iconst_0
       9: istore_2
      10: aload_0
      11: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          89
      26: aload_3
      27: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: checkcast     #68                 // class java/util/List
      35: astore        4
      37: aload         4
      39: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      44: astore        5
      46: aload         5
      48: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          17
      56: aload         5
      58: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: checkcast     #174                // class java/lang/Character
      66: invokevirtual #178                // Method java/lang/Character.charValue:()C
      69: istore        6
      71: iload_1
      72: iload         6
      74: bipush        66
      76: if_icmpne     83
      79: iconst_1
      80: goto          84
      83: iconst_0
      84: iadd
      85: istore_1
      86: goto          46
      89: new           #35                 // class java/lang/StringBuilder
      92: dup
      93: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
      96: ldc           #214                // String \nNumber of purchased tickets:
      98: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     101: iload_1
     102: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     105: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     108: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     111: swap
     112: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     115: iload_1
     116: ldc           #215                // int 100000
     118: imul
     119: aload_0
     120: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
     125: aload_0
     126: iconst_0
     127: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     132: checkcast     #68                 // class java/util/List
     135: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
     140: imul
     141: idiv
     142: istore_3
     143: iload_3
     144: iload_3
     145: bipush        10
     147: irem
     148: iconst_4
     149: if_icmple     157
     152: bipush        10
     154: goto          158
     157: iconst_0
     158: iadd
     159: bipush        10
     161: idiv
     162: istore_3
     163: new           #35                 // class java/lang/StringBuilder
     166: dup
     167: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     170: iload_3
     171: bipush        100
     173: idiv
     174: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     177: bipush        46
     179: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     182: iload_3
     183: bipush        100
     185: irem
     186: bipush        10
     188: idiv
     189: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     192: iload_3
     193: bipush        10
     195: irem
     196: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     199: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     202: astore        4
     204: new           #35                 // class java/lang/StringBuilder
     207: dup
     208: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     211: ldc           #217                // String Percentage:
     213: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     216: aload         4
     218: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     221: bipush        37
     223: invokevirtual #46                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     226: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     229: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     232: swap
     233: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     236: iconst_0
     237: istore        5
     239: aload_0
     240: invokeinterface #76,  1           // InterfaceMethod java/util/List.size:()I
     245: istore        6
     247: iload         5
     249: iload         6
     251: if_icmpge     328
     254: aload_0
     255: iload         5
     257: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     262: checkcast     #68                 // class java/util/List
     265: invokeinterface #207,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     270: astore        7
     272: aload         7
     274: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     279: ifeq          322
     282: aload         7
     284: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     289: checkcast     #174                // class java/lang/Character
     292: invokevirtual #178                // Method java/lang/Character.charValue:()C
     295: istore        8
     297: iload_2
     298: iload         8
     300: bipush        66
     302: if_icmpne     316
     305: aload_0
     306: iload         5
     308: iconst_1
     309: iadd
     310: invokestatic  #189                // Method calculateSeat:(Ljava/util/List;I)I
     313: goto          317
     316: iconst_0
     317: iadd
     318: istore_2
     319: goto          272
     322: iinc          5, 1
     325: goto          247
     328: new           #35                 // class java/lang/StringBuilder
     331: dup
     332: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     335: ldc           #219                // String Current income: $
     337: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     340: iload_2
     341: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     344: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     347: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     350: swap
     351: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     354: new           #35                 // class java/lang/StringBuilder
     357: dup
     358: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     361: ldc           #221                // String Total income: $
     363: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     366: aload_0
     367: invokestatic  #223                // Method calculateAll:(Ljava/util/List;)I
     370: invokevirtual #79                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     373: invokevirtual #49                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     376: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     379: swap
     380: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     383: return

  public static final void main();
    Code:
       0: invokestatic  #230                // Method inputRoom:()Ljava/lang/String;
       3: checkcast     #87                 // class java/lang/CharSequence
       6: iconst_1
       7: anewarray     #118                // class java/lang/String
      10: astore_1
      11: aload_1
      12: iconst_0
      13: ldc           #85                 // String
      15: aastore
      16: aload_1
      17: iconst_0
      18: iconst_0
      19: bipush        6
      21: aconst_null
      22: invokestatic  #124                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      25: checkcast     #83                 // class java/lang/Iterable
      28: astore_1
      29: iconst_0
      30: istore_2
      31: aload_1
      32: astore_3
      33: new           #126                // class java/util/ArrayList
      36: dup
      37: aload_1
      38: bipush        10
      40: invokestatic  #130                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #133                // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #135                // class java/util/Collection
      49: astore        4
      51: iconst_0
      52: istore        5
      54: aload_3
      55: invokeinterface #139,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      60: astore        6
      62: aload         6
      64: invokeinterface #145,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      69: ifeq          116
      72: aload         6
      74: invokeinterface #149,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      79: astore        7
      81: aload         4
      83: aload         7
      85: checkcast     #118                // class java/lang/String
      88: astore        8
      90: astore        15
      92: iconst_0
      93: istore        9
      95: aload         8
      97: invokestatic  #155                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     100: nop
     101: invokestatic  #159                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     104: aload         15
     106: swap
     107: invokeinterface #163,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     112: pop
     113: goto          62
     116: aload         4
     118: checkcast     #68                 // class java/util/List
     121: nop
     122: astore_0
     123: aload_0
     124: iconst_0
     125: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #165                // class java/lang/Number
     133: invokevirtual #168                // Method java/lang/Number.intValue:()I
     136: istore_1
     137: aload_0
     138: iconst_1
     139: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     144: checkcast     #165                // class java/lang/Number
     147: invokevirtual #168                // Method java/lang/Number.intValue:()I
     150: istore_2
     151: new           #126                // class java/util/ArrayList
     154: dup
     155: iload_1
     156: invokespecial #133                // Method java/util/ArrayList."<init>":(I)V
     159: astore        4
     161: iconst_0
     162: istore        5
     164: iload         5
     166: iload_1
     167: if_icmpge     256
     170: iload         5
     172: istore        6
     174: aload         4
     176: iload         6
     178: istore        7
     180: astore        15
     182: iconst_0
     183: istore        8
     185: new           #126                // class java/util/ArrayList
     188: dup
     189: iload_2
     190: invokespecial #133                // Method java/util/ArrayList."<init>":(I)V
     193: astore        9
     195: iconst_0
     196: istore        10
     198: iload         10
     200: iload_2
     201: if_icmpge     237
     204: iload         10
     206: istore        11
     208: aload         9
     210: iload         11
     212: istore        12
     214: astore        13
     216: iconst_0
     217: istore        14
     219: bipush        83
     221: invokestatic  #181                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     224: aload         13
     226: swap
     227: invokevirtual #231                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     230: pop
     231: iinc          10, 1
     234: goto          198
     237: aload         9
     239: checkcast     #68                 // class java/util/List
     242: nop
     243: aload         15
     245: swap
     246: invokevirtual #231                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     249: pop
     250: iinc          5, 1
     253: goto          164
     256: aload         4
     258: checkcast     #68                 // class java/util/List
     261: astore_3
     262: iconst_m1
     263: istore        4
     265: iload         4
     267: ifeq          349
     270: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     273: invokevirtual #81                 // Method java/io/PrintStream.println:()V
     276: ldc           #233                // String 1. Show the seats\n2. Buy a ticket\n3. Statistics\n0. Exit
     278: astore        5
     280: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;
     283: aload         5
     285: invokevirtual #21                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     288: invokestatic  #26                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
     291: dup
     292: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     295: invokestatic  #155                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     298: istore        4
     300: iload         4
     302: tableswitch   { // 1 to 3
                     1: 328
                     2: 335
                     3: 342
               default: 346
          }
     328: aload_3
     329: invokestatic  #235                // Method scheme:(Ljava/util/List;)V
     332: goto          265
     335: aload_3
     336: invokestatic  #172                // Method shopping:(Ljava/util/List;)V
     339: goto          265
     342: aload_3
     343: invokestatic  #237                // Method stats:(Ljava/util/List;)V
     346: goto          265
     349: return

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