public static Cons yieldCastedTypecaseClauseTrees(Symbol testvariable, StandardObject clausetype, Cons clausetrees) {
    { StandardObject testvariabletype = Symbol.lookupVariableType(testvariable);
      boolean needrealcastP = !(((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_COMMON_LISP);
      Symbol auxvariable = (((!(((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_JAVA)) &&
          needrealcastP) ? Stella.localGensym(testvariable.symbolName) : ((Symbol)(null)));
      Cons castedclausetrees = null;

      if (!needrealcastP) {
        Symbol.pushVariableBinding(testvariable, clausetype);
        castedclausetrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_VOID_SYS, Cons.cons(Cons.cons(Stella.SYM_STELLA_PROGN, Cons.walkListOfStatements(clausetrees).concatenate(Stella.NIL, Stella.NIL)), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL);
        Stella.popVariableBinding();
      }
      else {
        if (auxvariable != null) {
          Symbol.pushVariableBinding(auxvariable, testvariabletype);
        }
        castedclausetrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_LET, Cons.cons(((auxvariable != null) ? Cons.list$(Cons.cons(Cons.cons(auxvariable, Cons.cons(testvariable, Stella.NIL)), Cons.cons(Cons.cons(testvariable, Cons.cons(clausetype, Cons.cons(auxvariable, Stella.NIL))), Cons.cons(Stella.NIL, Stella.NIL)))) : Cons.cons(Cons.cons(testvariable, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SAFE_CAST, Cons.cons(Stella_Object.sysTree(Stella_Object.walkWithoutTypeTree(testvariable), clausetype, new Object[1]), Cons.cons(Cons.cons(clausetype, Stella.NIL), Stella.NIL)))), Stella.NIL)), Stella.NIL)), Cons.cons(clausetrees.concatenate(Stella.NIL, Stella.NIL), Stella.NIL)))), Stella.NIL);
        if (auxvariable != null) {
          Stella.popVariableBinding();
        }
      }
      return (castedclausetrees);
    }
  }