public class SuiteTraduite {
  // v:main memoire de 0
  // reste pile des appels à U avec
  // (ar,n,vr,v)...
  public static int memoire[] = new int[1000];
  public static int insC = 1;
  public static int sommetDePile = 1;
  public static void main(String []a) {
    while (true) {
      switch(insC) {
      case 1:
        memoire[sommetDePile] = insC+1;
        memoire[sommetDePile+1] = 100; // param = 100
        sommetDePile += 4;
        insC = 1000; // premier ins. de U
        break;
      case 2:
        sommetDePile -= 4;
        // récupère la valeur de retour
        memoire[0] = memoire[sommetDePile+2];
        insC++;
        break;
      case 3:
        System.out.println("U(100)="+memoire[0]);
        insC++;
        break;
      case 4:
        System.exit(0);

        // traduction de U
      case 1000:
        System.out.println("appel à U avec n="+memoire[sommetDePile-3]);
        System.out.println("sommetDePile="+sommetDePile);
        if (memoire[sommetDePile-3]==0) {
          insC++;
        } else {
          insC = 1002;
        }
        break;
      case 1001: // return 5
        memoire[sommetDePile-2] = 5;
        insC = memoire[sommetDePile-4];
        break;
      case 1002: // else
        memoire[sommetDePile] = insC+1;
        memoire[sommetDePile+1] = memoire[sommetDePile-3]-1;
        sommetDePile += 4;
        insC = 1000;
        break;
      case 1003:
        sommetDePile -= 4;
        memoire[sommetDePile-1] = memoire[sommetDePile+2];
        insC++;
      case 1004:
        memoire[sommetDePile-1] = memoire[sommetDePile-1]+7;
        insC++;
        break;
      case 1005: // return v;
        memoire[sommetDePile-2] = memoire[sommetDePile-1];
        insC = memoire[sommetDePile-4];
        break;
      }
    }
  }
}