//
// Source
// ------------------------------------------

import androidx.compose.runtime.*


interface Test {
    @Composable fun Int.foo(param: Int = remember { 0 })
}

class TestImpl : Test {
    @Composable override fun Int.foo(param: Int) {}
}

@Composable fun CallWithDefaults(test: Test) {
    with(test) {
        42.foo()
        42.foo(0)
    }
}

//
// Transformed IR
// ------------------------------------------

interface Test {
  @Composable
  @FunctionKeyMeta(key = -1445649412, startOffset = 69, endOffset = 109)
  abstract fun Int.foo(param: Int, %composer: Composer?, %changed: Int)
  class ComposeDefaultImpls {
    @Composable
    fun foo%default(param: Int, %this%: Test, %this%: Int, %composer: Composer?, %changed: Int, %default: Int) {
      %composer = %composer.startRestartGroup(<>)
      sourceInformation(%composer, "C(foo%default)N(param)<rememb...>:Test.kt")
      val %dirty = %changed
      if (%default and 0b0001 != 0) {
        %dirty = %dirty or 0b0110
      } else if (%changed and 0b0110 == 0) {
        %dirty = %dirty or if (%composer.changed(param)) 0b0100 else 0b0010
      }
      if (%changed and 0b00110000 == 0) {
        %dirty = %dirty or if (if (%changed and 0b01000000 == 0) {
          %composer.changed(%this%)
        } else {
          %composer.changedInstance(%this%)
        }
        ) 0b00100000 else 0b00010000
      }
      if (%changed and 0b000110000000 == 0) {
        %dirty = %dirty or if (%composer.changed(%this%)) 0b000100000000 else 0b10000000
      }
      if (%composer.shouldExecute(%dirty and 0b10010011 != 0b10010010, %dirty and 0b0001)) {
        if (%default and 0b0001 != 0) {
          param = <block>{
            sourceInformationMarkerStart(%composer, <>, "CC(remember):Test.kt#9igjgp")
            val tmp0_group = %composer.cache(false) {
              0
            }
            sourceInformationMarkerEnd(%composer)
            tmp0_group
          }
        }
        if (isTraceInProgress()) {
          traceEventStart(<>, %dirty, -1, <>)
        }
        %this%.foo(param, %composer, 0b1110 and %dirty shr 0b0110 or 0b01110000 and %dirty shl 0b0011 or 0b001110000000 and %dirty shl 0b0011)
        if (isTraceInProgress()) {
          traceEventEnd()
        }
      } else {
        %composer.skipToGroupEnd()
      }
      %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
        foo%default(param, %this%, %this%, %composer, updateChangedFlags(%changed or 0b0001), %default)
      }
    }
  }
}
@StabilityInferred(parameters = 1)
class TestImpl : Test {
  @Composable
  @FunctionKeyMeta(key = -638804548, startOffset = 162, endOffset = 188)
  override fun Int.foo(param: Int, %composer: Composer?, %changed: Int) {
    %composer.startReplaceGroup(<>)
    sourceInformation(%composer, "C(foo)N(param):Test.kt")
    if (isTraceInProgress()) {
      traceEventStart(<>, %changed, -1, <>)
    }
    if (isTraceInProgress()) {
      traceEventEnd()
    }
    %composer.endReplaceGroup()
  }
  static val %stable: Int = 0
}
@Composable
@FunctionKeyMeta(key = 53166890, startOffset = 204, endOffset = 298)
fun CallWithDefaults(test: Test, %composer: Composer?, %changed: Int) {
  %composer = %composer.startRestartGroup(<>)
  sourceInformation(%composer, "C(CallWithDefaults)N(test)*<foo()>,<foo(0)>:Test.kt")
  val %dirty = %changed
  if (%changed and 0b0110 == 0) {
    %dirty = %dirty or if (if (%changed and 0b1000 == 0) {
      %composer.changed(test)
    } else {
      %composer.changedInstance(test)
    }
    ) 0b0100 else 0b0010
  }
  if (%composer.shouldExecute(%dirty and 0b0011 != 0b0010, %dirty and 0b0001)) {
    if (isTraceInProgress()) {
      traceEventStart(<>, %dirty, -1, <>)
    }
    with(test) {
      foo%default(0, %this%with, 42, %composer, 0b000110000000, 0b0001)
      foo%default(0, %this%with, 42, %composer, 0b000110000110, 0)
    }
    if (isTraceInProgress()) {
      traceEventEnd()
    }
  } else {
    %composer.skipToGroupEnd()
  }
  %composer.endRestartGroup()?.updateScope { %composer: Composer?, %force: Int ->
    CallWithDefaults(test, %composer, updateChangedFlags(%changed or 0b0001))
  }
}
