package org.aoc2021

import java.nio.file.Files
import java.nio.file.Path
import kotlin.math.max
import kotlin.math.min

private fun IntRange.size(): Int {
    return if (this.last >= this.first) {
        this.last - this.first + 1
    } else {
        0
    }
}

object Day22 {
    data class Cube(val x: IntRange, val y: IntRange, val z: IntRange) {
        fun volume(): Long {
            return x.size().toLong() * y.size() * z.size()
        }

        fun intersect(other: Cube): Cube {
            if (x.first > other.x.last ||
                    x.last < other.x.first ||
                    y.first > other.y.last ||
                    y.last < other.y.first ||
                    z.first > other.z.last ||
                    z.last < other.z.first) {
                return Cube(IntRange.EMPTY, IntRange.EMPTY, IntRange.EMPTY)
            }

            val minX = max(x.first, other.x.first)
            val maxX = min(x.last, other.x.last)
            val minY = max(y.first, other.y.first)
            val maxY = min(y.last, other.y.last)
            val minZ = max(z.first, other.z.first)
            val maxZ = min(z.last, other.z.last)

            return Cube(minX..maxX, minY..maxY, minZ..maxZ)
        }
    }

    data class Step(val on: Boolean, val cube: Cube)

    private fun solve(lines: List<String>, shouldBound: Boolean): Long {
        val steps = parseSteps(lines).let { if (shouldBound) boundCubes(it) else it }
        val cubes = steps.map(Step::cube)

        var totalVolume = 0L
        steps.forEachIndexed { i, step ->
            val flippedVolume = computeFlippedVolume(steps.subList(0, i), step)
            if (step.on) {
                totalVolume += flippedVolume
                totalVolume += computeNonIntersectingVolume(cubes.subList(0, i), step.cube)
            } else {
                totalVolume -= flippedVolume
            }
        }

        return totalVolume
    }

    private fun parseSteps(lines: List<String>): List<Step> {
        return lines.map { line ->
            val (onString, rest) = line.split(" ")
            val (xRange, yRange, zRange) = rest.split(",").map { rangeString ->
                rangeString.substring(2).split("..").let { it[0].toInt()..it[1].toInt() }
            }
            Step(onString == "on", Cube(xRange, yRange, zRange))
        }
    }

    private fun boundCubes(steps: List<Step>): List<Step> {
        return steps.map { step ->
            val (x, y, z) = step.cube
            Step(step.on, Cube(
                max(x.first, -50)..min(x.last, 50),
                max(y.first, -50)..min(y.last, 50),
                max(z.first, -50)..min(z.last, 50),
            ))
        }
    }

    private fun computeFlippedVolume(previousSteps: List<Step>, step: Step): Long {
        val overlappingSteps = previousSteps.filter { it.cube.intersect(step.cube).volume() > 0 }

        var totalFlippedVolume = 0L
        overlappingSteps.indices.filter { j -> overlappingSteps[j].on != step.on }.forEach { j ->
            val otherStep = overlappingSteps[j]
            val laterCubes = overlappingSteps.subList(j + 1, overlappingSteps.size).map(Step::cube)

            val offOnIntersect = step.cube.intersect(otherStep.cube)

            totalFlippedVolume += computeNonIntersectingVolume(laterCubes, offOnIntersect)
        }

        return totalFlippedVolume
    }

    private fun computeNonIntersectingVolume(previousCubes: List<Cube>, cube: Cube): Long {
        val overlappingCubes = previousCubes.filter { it.intersect(cube).volume() > 0 }

        var newVolume = cube.volume()
        var sign = -1
        for (cubeCount in 1..overlappingCubes.size) {
            val cubeCombinations = combinations(overlappingCubes, cubeCount)

            cubeCombinations.forEach { cubeCombination ->
                newVolume += sign * cubeCombination.fold(cube) { a, b -> a.intersect(b) }.volume()
            }

            sign *= -1
        }
        return newVolume
    }

    private fun <T> combinations(list: List<T>, count: Int): List<List<T>> {
        if (count == 1) {
            return list.map { listOf(it) }
        }

        return list.flatMapIndexed { i, elem ->
            val subCombinations = combinations(list.subList(i + 1, list.size), count - 1)
            subCombinations.map { listOf(elem).plus(it) }
        }
    }

    @JvmStatic
    fun main(args: Array<String>) {
        val lines = Files.readAllLines(Path.of("input22.txt"), Charsets.UTF_8)
        val solution1 = solve(lines, true)
        println(solution1)
        val solution2 = solve(lines, false)
        println(solution2)
    }
}

Compiled from "Day22.kt"
public final class org.aoc2021.Day22Kt {
  private static final int size(kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: invokevirtual #12                 // Method kotlin/ranges/IntRange.getLast:()I
       4: aload_0
       5: invokevirtual #15                 // Method kotlin/ranges/IntRange.getFirst:()I
       8: if_icmplt     25
      11: aload_0
      12: invokevirtual #12                 // Method kotlin/ranges/IntRange.getLast:()I
      15: aload_0
      16: invokevirtual #15                 // Method kotlin/ranges/IntRange.getFirst:()I
      19: isub
      20: iconst_1
      21: iadd
      22: goto          26
      25: iconst_0
      26: ireturn

  public static final int access$size(kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: invokestatic  #20                 // Method size:(Lkotlin/ranges/IntRange;)I
       4: ireturn
}

Compiled from "Day22.kt"
public final class org.aoc2021.Day22$Step {
  private final boolean on;

  private final org.aoc2021.Day22$Cube cube;

  public org.aoc2021.Day22$Step(boolean, org.aoc2021.Day22$Cube);
    Code:
       0: aload_2
       1: ldc           #9                  // String cube
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #18                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: iload_1
      12: putfield      #22                 // Field on:Z
      15: aload_0
      16: aload_2
      17: putfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      20: return

  public final boolean getOn();
    Code:
       0: aload_0
       1: getfield      #22                 // Field on:Z
       4: ireturn

  public final org.aoc2021.Day22$Cube getCube();
    Code:
       0: aload_0
       1: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
       4: areturn

  public final boolean component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field on:Z
       4: ireturn

  public final org.aoc2021.Day22$Cube component2();
    Code:
       0: aload_0
       1: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
       4: areturn

  public final org.aoc2021.Day22$Step copy(boolean, org.aoc2021.Day22$Cube);
    Code:
       0: aload_2
       1: ldc           #9                  // String cube
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class org/aoc2021/Day22$Step
       9: dup
      10: iload_1
      11: aload_2
      12: invokespecial #37                 // Method "<init>":(ZLorg/aoc2021/Day22$Cube;)V
      15: areturn

  public static org.aoc2021.Day22$Step copy$default(org.aoc2021.Day22$Step, boolean, org.aoc2021.Day22$Cube, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field on:Z
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      21: astore_2
      22: aload_0
      23: iload_1
      24: aload_2
      25: invokevirtual #41                 // Method copy:(ZLorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Step;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #45                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #46                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #48                 // String Step(on=
       9: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field on:Z
      16: invokevirtual #55                 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;
      19: ldc           #57                 // String , cube=
      21: invokevirtual #52                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      28: invokevirtual #60                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #63                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #65                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field on:Z
       4: invokestatic  #72                 // Method java/lang/Boolean.hashCode:(Z)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      16: invokevirtual #76                 // Method org/aoc2021/Day22$Cube.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class org/aoc2021/Day22$Step
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class org/aoc2021/Day22$Step
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field on:Z
      25: aload_2
      26: getfield      #22                 // Field on:Z
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      38: aload_2
      39: getfield      #25                 // Field cube:Lorg/aoc2021/Day22$Cube;
      42: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: iconst_1
      51: ireturn
}

Compiled from "Day22.kt"
public final class org.aoc2021.Day22$Cube {
  private final kotlin.ranges.IntRange x;

  private final kotlin.ranges.IntRange y;

  private final kotlin.ranges.IntRange z;

  public org.aoc2021.Day22$Cube(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: ldc           #9                  // String x
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String y
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #19                 // String z
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: invokespecial #22                 // Method java/lang/Object."<init>":()V
      22: aload_0
      23: aload_1
      24: putfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      27: aload_0
      28: aload_2
      29: putfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      32: aload_0
      33: aload_3
      34: putfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      37: return

  public final kotlin.ranges.IntRange getX();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
       4: areturn

  public final kotlin.ranges.IntRange getY();
    Code:
       0: aload_0
       1: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
       4: areturn

  public final kotlin.ranges.IntRange getZ();
    Code:
       0: aload_0
       1: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
       4: areturn

  public final long volume();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
       4: invokestatic  #43                 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I
       7: i2l
       8: aload_0
       9: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      12: invokestatic  #43                 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I
      15: i2l
      16: lmul
      17: aload_0
      18: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      21: invokestatic  #43                 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I
      24: i2l
      25: lmul
      26: lreturn

  public final org.aoc2021.Day22$Cube intersect(org.aoc2021.Day22$Cube);
    Code:
       0: aload_1
       1: ldc           #47                 // String other
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      10: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
      13: aload_1
      14: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      17: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      20: if_icmpgt     108
      23: aload_0
      24: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      27: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      30: aload_1
      31: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      34: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
      37: if_icmplt     108
      40: aload_0
      41: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      44: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
      47: aload_1
      48: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      51: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      54: if_icmpgt     108
      57: aload_0
      58: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      61: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      64: aload_1
      65: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      68: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
      71: if_icmplt     108
      74: aload_0
      75: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      78: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
      81: aload_1
      82: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      85: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      88: if_icmpgt     108
      91: aload_0
      92: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      95: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
      98: aload_1
      99: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
     102: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     105: if_icmpge     134
     108: new           #2                  // class org/aoc2021/Day22$Cube
     111: dup
     112: getstatic     #60                 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;
     115: invokevirtual #65                 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;
     118: getstatic     #60                 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;
     121: invokevirtual #65                 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;
     124: getstatic     #60                 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;
     127: invokevirtual #65                 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;
     130: invokespecial #67                 // Method "<init>":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V
     133: areturn
     134: aload_0
     135: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
     138: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     141: aload_1
     142: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
     145: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     148: invokestatic  #73                 // Method java/lang/Math.max:(II)I
     151: istore_2
     152: aload_0
     153: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
     156: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     159: aload_1
     160: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
     163: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     166: invokestatic  #76                 // Method java/lang/Math.min:(II)I
     169: istore_3
     170: aload_0
     171: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
     174: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     177: aload_1
     178: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
     181: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     184: invokestatic  #73                 // Method java/lang/Math.max:(II)I
     187: istore        4
     189: aload_0
     190: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
     193: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     196: aload_1
     197: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
     200: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     203: invokestatic  #76                 // Method java/lang/Math.min:(II)I
     206: istore        5
     208: aload_0
     209: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
     212: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     215: aload_1
     216: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
     219: invokevirtual #53                 // Method kotlin/ranges/IntRange.getFirst:()I
     222: invokestatic  #73                 // Method java/lang/Math.max:(II)I
     225: istore        6
     227: aload_0
     228: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
     231: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     234: aload_1
     235: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
     238: invokevirtual #56                 // Method kotlin/ranges/IntRange.getLast:()I
     241: invokestatic  #76                 // Method java/lang/Math.min:(II)I
     244: istore        7
     246: new           #2                  // class org/aoc2021/Day22$Cube
     249: dup
     250: new           #49                 // class kotlin/ranges/IntRange
     253: dup
     254: iload_2
     255: iload_3
     256: invokespecial #79                 // Method kotlin/ranges/IntRange."<init>":(II)V
     259: new           #49                 // class kotlin/ranges/IntRange
     262: dup
     263: iload         4
     265: iload         5
     267: invokespecial #79                 // Method kotlin/ranges/IntRange."<init>":(II)V
     270: new           #49                 // class kotlin/ranges/IntRange
     273: dup
     274: iload         6
     276: iload         7
     278: invokespecial #79                 // Method kotlin/ranges/IntRange."<init>":(II)V
     281: invokespecial #67                 // Method "<init>":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V
     284: areturn

  public final kotlin.ranges.IntRange component1();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
       4: areturn

  public final kotlin.ranges.IntRange component2();
    Code:
       0: aload_0
       1: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
       4: areturn

  public final kotlin.ranges.IntRange component3();
    Code:
       0: aload_0
       1: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
       4: areturn

  public final org.aoc2021.Day22$Cube copy(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: ldc           #9                  // String x
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #17                 // String y
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #19                 // String z
      15: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: new           #2                  // class org/aoc2021/Day22$Cube
      21: dup
      22: aload_1
      23: aload_2
      24: aload_3
      25: invokespecial #67                 // Method "<init>":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V
      28: areturn

  public static org.aoc2021.Day22$Cube copy$default(org.aoc2021.Day22$Cube, kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      11: astore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      35: astore_3
      36: aload_0
      37: aload_1
      38: aload_2
      39: aload_3
      40: invokevirtual #95                 // Method copy:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Lorg/aoc2021/Day22$Cube;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #99                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #100                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #102                // String Cube(x=
       9: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      16: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #111                // String , y=
      21: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      28: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #113                // String , z=
      33: invokevirtual #106                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      40: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #116                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #118                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
       4: invokevirtual #121                // Method kotlin/ranges/IntRange.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      16: invokevirtual #121                // Method kotlin/ranges/IntRange.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      29: invokevirtual #121                // Method kotlin/ranges/IntRange.hashCode:()I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class org/aoc2021/Day22$Cube
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class org/aoc2021/Day22$Cube
      20: astore_2
      21: aload_0
      22: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      25: aload_2
      26: getfield      #25                 // Field x:Lkotlin/ranges/IntRange;
      29: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      41: aload_2
      42: getfield      #27                 // Field y:Lkotlin/ranges/IntRange;
      45: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: aload_0
      54: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      57: aload_2
      58: getfield      #29                 // Field z:Lkotlin/ranges/IntRange;
      61: invokestatic  #129                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      64: ifne          69
      67: iconst_0
      68: ireturn
      69: iconst_1
      70: ireturn
}

Compiled from "Day22.kt"
public final class org.aoc2021.Day22 {
  public static final org.aoc2021.Day22 INSTANCE;

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

  private final long solve(java.util.List<java.lang.String>, boolean);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #17                 // Method parseSteps:(Ljava/util/List;)Ljava/util/List;
       5: astore        5
       7: iconst_0
       8: istore        6
      10: iload_2
      11: ifeq          25
      14: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
      17: aload         5
      19: invokespecial #23                 // Method boundCubes:(Ljava/util/List;)Ljava/util/List;
      22: goto          27
      25: aload         5
      27: nop
      28: astore_3
      29: aload_3
      30: checkcast     #25                 // class java/lang/Iterable
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         5
      40: astore        7
      42: new           #27                 // class java/util/ArrayList
      45: dup
      46: aload         5
      48: bipush        10
      50: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      53: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      56: checkcast     #38                 // class java/util/Collection
      59: astore        8
      61: iconst_0
      62: istore        9
      64: aload         7
      66: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      71: astore        10
      73: aload         10
      75: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      80: ifeq          123
      83: aload         10
      85: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      90: astore        11
      92: aload         8
      94: aload         11
      96: checkcast     #54                 // class org/aoc2021/Day22$Step
      99: astore        12
     101: astore        17
     103: iconst_0
     104: istore        13
     106: aload         12
     108: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
     111: aload         17
     113: swap
     114: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          73
     123: aload         8
     125: checkcast     #64                 // class java/util/List
     128: nop
     129: astore        4
     131: lconst_0
     132: lstore        18
     134: aload_3
     135: checkcast     #25                 // class java/lang/Iterable
     138: astore        6
     140: iconst_0
     141: istore        7
     143: iconst_0
     144: istore        8
     146: aload         6
     148: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     153: astore        9
     155: aload         9
     157: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     162: ifeq          278
     165: aload         9
     167: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     172: astore        10
     174: iload         8
     176: iinc          8, 1
     179: istore        11
     181: iload         11
     183: ifge          189
     186: invokestatic  #67                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     189: iload         11
     191: aload         10
     193: checkcast     #54                 // class org/aoc2021/Day22$Step
     196: astore        12
     198: istore        13
     200: iconst_0
     201: istore        14
     203: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
     206: aload_3
     207: iconst_0
     208: iload         13
     210: invokeinterface #71,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     215: aload         12
     217: invokespecial #75                 // Method computeFlippedVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Step;)J
     220: lstore        15
     222: aload         12
     224: invokevirtual #78                 // Method org/aoc2021/Day22$Step.getOn:()Z
     227: ifeq          266
     230: lload         18
     232: lload         15
     234: ladd
     235: lstore        18
     237: lload         18
     239: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
     242: aload         4
     244: iconst_0
     245: iload         13
     247: invokeinterface #71,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     252: aload         12
     254: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
     257: invokespecial #82                 // Method computeNonIntersectingVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Cube;)J
     260: ladd
     261: lstore        18
     263: goto          273
     266: lload         18
     268: lload         15
     270: lsub
     271: lstore        18
     273: nop
     274: nop
     275: goto          155
     278: nop
     279: lload         18
     281: lreturn

  private final java.util.List<org.aoc2021.Day22$Step> parseSteps(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #25                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #27                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #38                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          408
      50: aload         7
      52: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #116                // class java/lang/String
      66: astore        9
      68: astore        28
      70: iconst_0
      71: istore        10
      73: aload         9
      75: checkcast     #118                // class java/lang/CharSequence
      78: iconst_1
      79: anewarray     #116                // class java/lang/String
      82: astore        11
      84: aload         11
      86: iconst_0
      87: ldc           #120                // String
      89: aastore
      90: aload         11
      92: iconst_0
      93: iconst_0
      94: bipush        6
      96: aconst_null
      97: invokestatic  #126                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     100: astore        12
     102: aload         12
     104: iconst_0
     105: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     110: checkcast     #116                // class java/lang/String
     113: astore        11
     115: aload         12
     117: iconst_1
     118: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     123: checkcast     #116                // class java/lang/String
     126: astore        13
     128: aload         13
     130: checkcast     #118                // class java/lang/CharSequence
     133: iconst_1
     134: anewarray     #116                // class java/lang/String
     137: astore        14
     139: aload         14
     141: iconst_0
     142: ldc           #132                // String ,
     144: aastore
     145: aload         14
     147: iconst_0
     148: iconst_0
     149: bipush        6
     151: aconst_null
     152: invokestatic  #126                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     155: checkcast     #25                 // class java/lang/Iterable
     158: astore        14
     160: iconst_0
     161: istore        15
     163: aload         14
     165: astore        16
     167: new           #27                 // class java/util/ArrayList
     170: dup
     171: aload         14
     173: bipush        10
     175: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     178: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     181: checkcast     #38                 // class java/util/Collection
     184: astore        17
     186: iconst_0
     187: istore        18
     189: aload         16
     191: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     196: astore        19
     198: aload         19
     200: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     205: ifeq          322
     208: aload         19
     210: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     215: astore        20
     217: aload         17
     219: aload         20
     221: checkcast     #116                // class java/lang/String
     224: astore        21
     226: astore        22
     228: iconst_0
     229: istore        23
     231: aload         21
     233: iconst_2
     234: invokevirtual #136                // Method java/lang/String.substring:(I)Ljava/lang/String;
     237: dup
     238: ldc           #138                // String substring(...)
     240: invokestatic  #144                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     243: checkcast     #118                // class java/lang/CharSequence
     246: iconst_1
     247: anewarray     #116                // class java/lang/String
     250: astore        24
     252: aload         24
     254: iconst_0
     255: ldc           #146                // String ..
     257: aastore
     258: aload         24
     260: iconst_0
     261: iconst_0
     262: bipush        6
     264: aconst_null
     265: invokestatic  #126                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     268: astore        25
     270: iconst_0
     271: istore        26
     273: new           #148                // class kotlin/ranges/IntRange
     276: dup
     277: aload         25
     279: iconst_0
     280: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     285: checkcast     #116                // class java/lang/String
     288: invokestatic  #154                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     291: aload         25
     293: iconst_1
     294: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     299: checkcast     #116                // class java/lang/String
     302: invokestatic  #154                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     305: invokespecial #157                // Method kotlin/ranges/IntRange."<init>":(II)V
     308: nop
     309: nop
     310: aload         22
     312: swap
     313: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     318: pop
     319: goto          198
     322: aload         17
     324: checkcast     #64                 // class java/util/List
     327: nop
     328: astore        27
     330: aload         27
     332: iconst_0
     333: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     338: checkcast     #148                // class kotlin/ranges/IntRange
     341: astore        14
     343: aload         27
     345: iconst_1
     346: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     351: checkcast     #148                // class kotlin/ranges/IntRange
     354: astore        15
     356: aload         27
     358: iconst_2
     359: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     364: checkcast     #148                // class kotlin/ranges/IntRange
     367: astore        16
     369: new           #54                 // class org/aoc2021/Day22$Step
     372: dup
     373: aload         11
     375: ldc           #159                // String on
     377: invokestatic  #163                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     380: new           #165                // class org/aoc2021/Day22$Cube
     383: dup
     384: aload         14
     386: aload         15
     388: aload         16
     390: invokespecial #168                // Method org/aoc2021/Day22$Cube."<init>":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V
     393: invokespecial #171                // Method org/aoc2021/Day22$Step."<init>":(ZLorg/aoc2021/Day22$Cube;)V
     396: aload         28
     398: swap
     399: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     404: pop
     405: goto          40
     408: aload         5
     410: checkcast     #64                 // class java/util/List
     413: nop
     414: areturn

  private final java.util.List<org.aoc2021.Day22$Step> boundCubes(java.util.List<org.aoc2021.Day22$Step>);
    Code:
       0: aload_1
       1: checkcast     #25                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: astore        4
      10: new           #27                 // class java/util/ArrayList
      13: dup
      14: aload_2
      15: bipush        10
      17: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      20: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      23: checkcast     #38                 // class java/util/Collection
      26: astore        5
      28: iconst_0
      29: istore        6
      31: aload         4
      33: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      38: astore        7
      40: aload         7
      42: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      47: ifeq          214
      50: aload         7
      52: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      57: astore        8
      59: aload         5
      61: aload         8
      63: checkcast     #54                 // class org/aoc2021/Day22$Step
      66: astore        9
      68: astore        15
      70: iconst_0
      71: istore        10
      73: aload         9
      75: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
      78: astore        11
      80: aload         11
      82: invokevirtual #188                // Method org/aoc2021/Day22$Cube.component1:()Lkotlin/ranges/IntRange;
      85: astore        12
      87: aload         11
      89: invokevirtual #191                // Method org/aoc2021/Day22$Cube.component2:()Lkotlin/ranges/IntRange;
      92: astore        13
      94: aload         11
      96: invokevirtual #194                // Method org/aoc2021/Day22$Cube.component3:()Lkotlin/ranges/IntRange;
      99: astore        14
     101: new           #54                 // class org/aoc2021/Day22$Step
     104: dup
     105: aload         9
     107: invokevirtual #78                 // Method org/aoc2021/Day22$Step.getOn:()Z
     110: new           #165                // class org/aoc2021/Day22$Cube
     113: dup
     114: new           #148                // class kotlin/ranges/IntRange
     117: dup
     118: aload         12
     120: invokevirtual #198                // Method kotlin/ranges/IntRange.getFirst:()I
     123: bipush        -50
     125: invokestatic  #204                // Method java/lang/Math.max:(II)I
     128: aload         12
     130: invokevirtual #207                // Method kotlin/ranges/IntRange.getLast:()I
     133: bipush        50
     135: invokestatic  #210                // Method java/lang/Math.min:(II)I
     138: invokespecial #157                // Method kotlin/ranges/IntRange."<init>":(II)V
     141: new           #148                // class kotlin/ranges/IntRange
     144: dup
     145: aload         13
     147: invokevirtual #198                // Method kotlin/ranges/IntRange.getFirst:()I
     150: bipush        -50
     152: invokestatic  #204                // Method java/lang/Math.max:(II)I
     155: aload         13
     157: invokevirtual #207                // Method kotlin/ranges/IntRange.getLast:()I
     160: bipush        50
     162: invokestatic  #210                // Method java/lang/Math.min:(II)I
     165: invokespecial #157                // Method kotlin/ranges/IntRange."<init>":(II)V
     168: new           #148                // class kotlin/ranges/IntRange
     171: dup
     172: aload         14
     174: invokevirtual #198                // Method kotlin/ranges/IntRange.getFirst:()I
     177: bipush        -50
     179: invokestatic  #204                // Method java/lang/Math.max:(II)I
     182: aload         14
     184: invokevirtual #207                // Method kotlin/ranges/IntRange.getLast:()I
     187: bipush        50
     189: invokestatic  #210                // Method java/lang/Math.min:(II)I
     192: invokespecial #157                // Method kotlin/ranges/IntRange."<init>":(II)V
     195: invokespecial #168                // Method org/aoc2021/Day22$Cube."<init>":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V
     198: invokespecial #171                // Method org/aoc2021/Day22$Step."<init>":(ZLorg/aoc2021/Day22$Cube;)V
     201: nop
     202: aload         15
     204: swap
     205: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          40
     214: aload         5
     216: checkcast     #64                 // class java/util/List
     219: nop
     220: areturn

  private final long computeFlippedVolume(java.util.List<org.aoc2021.Day22$Step>, org.aoc2021.Day22$Step);
    Code:
       0: aload_1
       1: checkcast     #25                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: astore        6
      13: new           #27                 // class java/util/ArrayList
      16: dup
      17: invokespecial #216                // Method java/util/ArrayList."<init>":()V
      20: checkcast     #38                 // class java/util/Collection
      23: astore        7
      25: iconst_0
      26: istore        8
      28: aload         6
      30: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      35: astore        9
      37: aload         9
      39: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      44: ifeq          107
      47: aload         9
      49: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      54: astore        10
      56: aload         10
      58: checkcast     #54                 // class org/aoc2021/Day22$Step
      61: astore        11
      63: iconst_0
      64: istore        12
      66: aload         11
      68: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
      71: aload_2
      72: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
      75: invokevirtual #220                // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;
      78: invokevirtual #224                // Method org/aoc2021/Day22$Cube.volume:()J
      81: lconst_0
      82: lcmp
      83: ifle          90
      86: iconst_1
      87: goto          91
      90: iconst_0
      91: ifeq          37
      94: aload         7
      96: aload         10
      98: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: goto          37
     107: aload         7
     109: checkcast     #64                 // class java/util/List
     112: nop
     113: astore_3
     114: lconst_0
     115: lstore        23
     117: aload_3
     118: checkcast     #38                 // class java/util/Collection
     121: invokestatic  #228                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     124: checkcast     #25                 // class java/lang/Iterable
     127: astore        5
     129: iconst_0
     130: istore        6
     132: aload         5
     134: astore        7
     136: new           #27                 // class java/util/ArrayList
     139: dup
     140: invokespecial #216                // Method java/util/ArrayList."<init>":()V
     143: checkcast     #38                 // class java/util/Collection
     146: astore        8
     148: iconst_0
     149: istore        9
     151: aload         7
     153: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     158: astore        10
     160: aload         10
     162: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     167: ifeq          234
     170: aload         10
     172: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     177: astore        11
     179: aload         11
     181: checkcast     #230                // class java/lang/Number
     184: invokevirtual #233                // Method java/lang/Number.intValue:()I
     187: istore        12
     189: iconst_0
     190: istore        13
     192: aload_3
     193: iload         12
     195: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     200: checkcast     #54                 // class org/aoc2021/Day22$Step
     203: invokevirtual #78                 // Method org/aoc2021/Day22$Step.getOn:()Z
     206: aload_2
     207: invokevirtual #78                 // Method org/aoc2021/Day22$Step.getOn:()Z
     210: if_icmpeq     217
     213: iconst_1
     214: goto          218
     217: iconst_0
     218: ifeq          160
     221: aload         8
     223: aload         11
     225: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     230: pop
     231: goto          160
     234: aload         8
     236: checkcast     #64                 // class java/util/List
     239: nop
     240: checkcast     #25                 // class java/lang/Iterable
     243: astore        5
     245: nop
     246: iconst_0
     247: istore        6
     249: aload         5
     251: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     256: astore        7
     258: aload         7
     260: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     265: ifeq          454
     268: aload         7
     270: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     275: astore        8
     277: aload         8
     279: checkcast     #230                // class java/lang/Number
     282: invokevirtual #233                // Method java/lang/Number.intValue:()I
     285: istore        9
     287: iconst_0
     288: istore        10
     290: aload_3
     291: iload         9
     293: invokeinterface #130,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     298: checkcast     #54                 // class org/aoc2021/Day22$Step
     301: astore        11
     303: aload_3
     304: iload         9
     306: iconst_1
     307: iadd
     308: aload_3
     309: invokeinterface #236,  1          // InterfaceMethod java/util/List.size:()I
     314: invokeinterface #71,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     319: checkcast     #25                 // class java/lang/Iterable
     322: astore        12
     324: iconst_0
     325: istore        13
     327: aload         12
     329: astore        14
     331: new           #27                 // class java/util/ArrayList
     334: dup
     335: aload         12
     337: bipush        10
     339: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     342: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     345: checkcast     #38                 // class java/util/Collection
     348: astore        15
     350: iconst_0
     351: istore        16
     353: aload         14
     355: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     360: astore        17
     362: aload         17
     364: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     369: ifeq          412
     372: aload         17
     374: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     379: astore        18
     381: aload         15
     383: aload         18
     385: checkcast     #54                 // class org/aoc2021/Day22$Step
     388: astore        19
     390: astore        20
     392: iconst_0
     393: istore        21
     395: aload         19
     397: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
     400: aload         20
     402: swap
     403: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     408: pop
     409: goto          362
     412: aload         15
     414: checkcast     #64                 // class java/util/List
     417: nop
     418: astore        22
     420: aload_2
     421: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
     424: aload         11
     426: invokevirtual #58                 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;
     429: invokevirtual #220                // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;
     432: astore        12
     434: lload         23
     436: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
     439: aload         22
     441: aload         12
     443: invokespecial #82                 // Method computeNonIntersectingVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Cube;)J
     446: ladd
     447: lstore        23
     449: nop
     450: nop
     451: goto          258
     454: nop
     455: lload         23
     457: lreturn

  private final long computeNonIntersectingVolume(java.util.List<org.aoc2021.Day22$Cube>, org.aoc2021.Day22$Cube);
    Code:
       0: aload_1
       1: checkcast     #25                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: astore        6
      13: new           #27                 // class java/util/ArrayList
      16: dup
      17: invokespecial #216                // Method java/util/ArrayList."<init>":()V
      20: checkcast     #38                 // class java/util/Collection
      23: astore        7
      25: iconst_0
      26: istore        8
      28: aload         6
      30: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      35: astore        9
      37: aload         9
      39: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      44: ifeq          101
      47: aload         9
      49: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      54: astore        10
      56: aload         10
      58: checkcast     #165                // class org/aoc2021/Day22$Cube
      61: astore        11
      63: iconst_0
      64: istore        12
      66: aload         11
      68: aload_2
      69: invokevirtual #220                // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;
      72: invokevirtual #224                // Method org/aoc2021/Day22$Cube.volume:()J
      75: lconst_0
      76: lcmp
      77: ifle          84
      80: iconst_1
      81: goto          85
      84: iconst_0
      85: ifeq          37
      88: aload         7
      90: aload         10
      92: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      97: pop
      98: goto          37
     101: aload         7
     103: checkcast     #64                 // class java/util/List
     106: nop
     107: astore_3
     108: lconst_0
     109: lstore        28
     111: aload_2
     112: invokevirtual #224                // Method org/aoc2021/Day22$Cube.volume:()J
     115: lstore        28
     117: iconst_0
     118: istore        5
     120: iconst_m1
     121: istore        5
     123: iconst_1
     124: istore        6
     126: aload_3
     127: invokeinterface #236,  1          // InterfaceMethod java/util/List.size:()I
     132: istore        7
     134: iload         6
     136: iload         7
     138: if_icmpgt     316
     141: aload_0
     142: aload_3
     143: iload         6
     145: invokespecial #261                // Method combinations:(Ljava/util/List;I)Ljava/util/List;
     148: astore        8
     150: aload         8
     152: checkcast     #25                 // class java/lang/Iterable
     155: astore        9
     157: iconst_0
     158: istore        10
     160: aload         9
     162: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     167: astore        11
     169: aload         11
     171: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     176: ifeq          296
     179: aload         11
     181: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: astore        12
     188: aload         12
     190: checkcast     #64                 // class java/util/List
     193: astore        13
     195: iconst_0
     196: istore        14
     198: lload         28
     200: iload         5
     202: i2l
     203: aload         13
     205: checkcast     #25                 // class java/lang/Iterable
     208: astore        15
     210: lstore        16
     212: lstore        18
     214: iconst_0
     215: istore        20
     217: aload_2
     218: astore        21
     220: aload         15
     222: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     227: astore        22
     229: aload         22
     231: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     236: ifeq          274
     239: aload         22
     241: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     246: astore        23
     248: aload         21
     250: aload         23
     252: checkcast     #165                // class org/aoc2021/Day22$Cube
     255: astore        24
     257: astore        25
     259: iconst_0
     260: istore        26
     262: aload         25
     264: aload         24
     266: invokevirtual #220                // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;
     269: astore        21
     271: goto          229
     274: aload         21
     276: astore        27
     278: lload         18
     280: lload         16
     282: aload         27
     284: invokevirtual #224                // Method org/aoc2021/Day22$Cube.volume:()J
     287: lmul
     288: ladd
     289: lstore        28
     291: nop
     292: nop
     293: goto          169
     296: nop
     297: iload         5
     299: iconst_m1
     300: imul
     301: istore        5
     303: iload         6
     305: iload         7
     307: if_icmpeq     316
     310: iinc          6, 1
     313: goto          141
     316: lload         28
     318: lreturn

  private final <T> java.util.List<java.util.List<T>> combinations(java.util.List<? extends T>, int);
    Code:
       0: iload_2
       1: iconst_1
       2: if_icmpne     100
       5: aload_1
       6: checkcast     #25                 // class java/lang/Iterable
       9: astore_3
      10: iconst_0
      11: istore        4
      13: aload_3
      14: astore        5
      16: new           #27                 // class java/util/ArrayList
      19: dup
      20: aload_3
      21: bipush        10
      23: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #38                 // class java/util/Collection
      32: astore        6
      34: iconst_0
      35: istore        7
      37: aload         5
      39: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        8
      46: aload         8
      48: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          93
      56: aload         8
      58: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        9
      65: aload         6
      67: aload         9
      69: astore        10
      71: astore        24
      73: iconst_0
      74: istore        11
      76: aload         10
      78: invokestatic  #282                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      81: aload         24
      83: swap
      84: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      89: pop
      90: goto          46
      93: aload         6
      95: checkcast     #64                 // class java/util/List
      98: nop
      99: areturn
     100: aload_1
     101: checkcast     #25                 // class java/lang/Iterable
     104: astore        4
     106: new           #27                 // class java/util/ArrayList
     109: dup
     110: invokespecial #216                // Method java/util/ArrayList."<init>":()V
     113: checkcast     #38                 // class java/util/Collection
     116: astore        5
     118: iconst_0
     119: istore        6
     121: aload         4
     123: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     128: astore        7
     130: aload         7
     132: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     137: ifeq          328
     140: aload         7
     142: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     147: astore        8
     149: iload         6
     151: iinc          6, 1
     154: istore        9
     156: iload         9
     158: ifge          164
     161: invokestatic  #67                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     164: iload         9
     166: aload         8
     168: astore        10
     170: istore        11
     172: iconst_0
     173: istore        12
     175: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
     178: aload_1
     179: iload         11
     181: iconst_1
     182: iadd
     183: aload_1
     184: invokeinterface #236,  1          // InterfaceMethod java/util/List.size:()I
     189: invokeinterface #71,  3           // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;
     194: iload_2
     195: iconst_1
     196: isub
     197: invokespecial #261                // Method combinations:(Ljava/util/List;I)Ljava/util/List;
     200: astore        13
     202: aload         13
     204: checkcast     #25                 // class java/lang/Iterable
     207: astore        14
     209: iconst_0
     210: istore        15
     212: aload         14
     214: astore        16
     216: new           #27                 // class java/util/ArrayList
     219: dup
     220: aload         14
     222: bipush        10
     224: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     227: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     230: checkcast     #38                 // class java/util/Collection
     233: astore        17
     235: iconst_0
     236: istore        18
     238: aload         16
     240: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     245: astore        19
     247: aload         19
     249: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     254: ifeq          308
     257: aload         19
     259: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     264: astore        20
     266: aload         17
     268: aload         20
     270: checkcast     #64                 // class java/util/List
     273: astore        21
     275: astore        22
     277: iconst_0
     278: istore        23
     280: aload         10
     282: invokestatic  #282                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     285: checkcast     #38                 // class java/util/Collection
     288: aload         21
     290: checkcast     #25                 // class java/lang/Iterable
     293: invokestatic  #286                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     296: aload         22
     298: swap
     299: invokeinterface #62,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     304: pop
     305: goto          247
     308: aload         17
     310: checkcast     #64                 // class java/util/List
     313: nop
     314: checkcast     #25                 // class java/lang/Iterable
     317: nop
     318: aload         5
     320: swap
     321: invokestatic  #290                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     324: pop
     325: goto          130
     328: aload         5
     330: checkcast     #64                 // class java/util/List
     333: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc_w         #303                // String args
       4: invokestatic  #306                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: ldc_w         #308                // String input22.txt
      10: iconst_0
      11: anewarray     #116                // class java/lang/String
      14: invokestatic  #314                // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      17: getstatic     #320                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      20: invokestatic  #326                // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;
      23: astore_1
      24: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
      27: aload_1
      28: invokestatic  #330                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      31: aload_1
      32: iconst_1
      33: invokespecial #332                // Method solve:(Ljava/util/List;Z)J
      36: lstore_2
      37: getstatic     #338                // Field java/lang/System.out:Ljava/io/PrintStream;
      40: lload_2
      41: invokevirtual #344                // Method java/io/PrintStream.println:(J)V
      44: getstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
      47: aload_1
      48: iconst_0
      49: invokespecial #332                // Method solve:(Ljava/util/List;Z)J
      52: lstore        4
      54: getstatic     #338                // Field java/lang/System.out:Ljava/io/PrintStream;
      57: lload         4
      59: invokevirtual #344                // Method java/io/PrintStream.println:(J)V
      62: return

  static {};
    Code:
       0: new           #2                  // class org/aoc2021/Day22
       3: dup
       4: invokespecial #349                // Method "<init>":()V
       7: putstatic     #20                 // Field INSTANCE:Lorg/aoc2021/Day22;
      10: return
}