fun testSimple(x: Double): Int {
  return { // BLOCK
    val tmp0_subject: Double = x
    when {
      ieee754equals(arg0 = tmp0_subject, arg1 = 0.0) -> 0
      else -> 1
    }
  }
}

fun testSmartCastInWhenSubject(x: Any): Int {
  when {
    x !is Double -> return -1
  }
  return { // BLOCK
    val tmp0_subject: Any = x
    when {
      ieee754equals(arg0 = tmp0_subject /*as Double */, arg1 = 0.0) -> 0
      else -> 1
    }
  }
}

fun testSmartCastInWhenCondition(x: Double, y: Any): Int {
  when {
    y !is Double -> return -1
  }
  return { // BLOCK
    val tmp0_subject: Double = x
    when {
      ieee754equals(arg0 = tmp0_subject, arg1 = y /*as Double */) -> 0
      else -> 1
    }
  }
}

fun testSmartCastInWhenConditionInBranch(x: Any): Int {
  return { // BLOCK
    val tmp0_subject: Any = x
    when {
      tmp0_subject is Double.not() -> -1
      ieee754equals(arg0 = tmp0_subject /*as Double */, arg1 = 0.0) -> 0
      else -> 1
    }
  }
}

fun testSmartCastToDifferentTypes(x: Any, y: Any): Int {
  when {
    x !is Double -> return -1
  }
  when {
    y !is Float -> return -1
  }
  return { // BLOCK
    val tmp0_subject: Any = x
    when {
      ieee754equals(arg0 = tmp0_subject /*as Double */, arg1 = y /*as Float */.toDouble()) -> 0
      else -> 1
    }
  }
}

fun foo(x: Double): Double {
  return x
}

fun testWithPrematureExitInConditionSubexpression(x: Any): Int {
  return { // BLOCK
    val tmp0_subject: Any = x
    when {
      EQEQ(arg0 = tmp0_subject, arg1 = foo(x = when {
        x !is Double -> return 42
        else -> x /*as Double */
      })) -> 0
      else -> 1
    }
  }
}
