//#include "Unix.h"
#include "stdafx.h"   //MS Windows
#include "Strawberry.h"

//#include "string.h"
//#include "commdlg.h"

#include "StrawberryDoc.h"
#include "Thread.h"
#include "Call.h"

DWORD call(DWORD goal_fl)
// buf_3, buf_4 term_1 and term_2, buf_6 administrator,
// buf_3 only for k - p(X1, ... Xk), buf_7 only for accurancy check
{
  DWORD  i, r, s, j, t, k, m, n, p, q;
  DWORD  durty_min, buf1_min, buf1_All, salam_br, durty_br, pointer, pointer2;
  DWORD  minimum, sv_subv2;
  
#if TR
  if (status_fl&16)
    MitiText("Conflict! c1\r\n", &cf_red);
#endif
  while(status_fl&16); //  MitiText("Conflict! ");
  switch(goal_fl)
  {
   case 1:
    m=Link[j=Ekler[ekler_br]];
    a1=Link[sv_subv-1];
    sv_subv-=Atoms[m]+1;
    Steps_br++; // Answer is a Step
    goto fail3;     // ?
   case 2:
    m=my_gl2;
    goto MX;
   case 3:
    m=my_gl2;
    goto MX2;
   case 0:
    ;
  }
  pInfo2->m_Settings&=M1^4;
  ch_set=(pInfo2->m_Settings&0x7e0000)/0x20000;
  default_char=(pInfo2->m_Settings&0x10000)?'#':'?';

  if (Atoms[0]==0)    // ?
    return(1);
  for (i=max(buda_br, a1); i; Buda1[--i]=TT_VAR);
  for (i=global_br; i<global_br2; j=global2[i++], Link[j]=j);
#if !CONSOLE
  my_strcpy(string3, namef);
  for (i=my_strlen(string3); string3[--i]!='\\' && i!=0; );
  string3[i]=0;
  SetCurrentDirectory(string3);
  pMain_Frame=NUL;
  pMainWindow=NUL;
  MainMenu=NUL;
  if (hSavePen)
    DeleteObject(hSavePen);
  if (hSaveBrush)
    DeleteObject(hSaveBrush);
  if (hSaveFont)
    DeleteObject(hSaveFont);
  hPen=hSavePen=CreatePen(PS_INSIDEFRAME, 3, RGB(255, 0, 0));
  hBrush=hSaveBrush=CreateSolidBrush(RGB(255, 255, 255));
  hFont=hSaveFont=NULL;
  pFontMask=&cf_black;
#endif
  lSteps_br=0;
  if (pInfo2->m_Settings&2) // Active Break Point
    Corection=Steps_br=(WORD)(0x10000-(pInfo2->m_Break_point&0xffff));
  else
    Corection=Steps_br=0;

  buda_br_up=ekler_br=Wait=Wait_d=0;
  buda_br=a1=global_br2=global_br;
  stack_br=4;
  Stack[0]=HALF;                     /* Tati */
  Stack[3]=Stack[4]=0;
  Link[Stack[2]=Atoms[0]+4*FIRST_ROWS]=Link[4*FIRST_ROWS]=0;
  sv_subv=(Stack[5]=Atoms[0])+4*FIRST_ROWS+1;  /* Where are the variables */
  Ekler[0]=0;
  term_1=Prog_fild[i=Program[0]+2*Atoms[0]];
  if ((j=Prog_fild[i+1])&HALF)
  { // if we need to make substitution
    a1+=Chfil_v[term_1-MEMORY_c256];
    q=Prog_fild[j&=MASKA2];
    do
    {
      Buda1[q]=Prog_fild[j+1];
      Buda2[q]=Prog_fild[j+2];
      q=Prog_fild[j+=3];
    }
    while (q!=M1);
  }
  else
    a1+=j;
R16:
  if (!++Steps_br)
  {
    ++lSteps_br;
    if (Trace&3)     // Not tracing and Step over
      goto R17;
    if ((pInfo2->m_Settings&2) && lSteps_br-1==(pInfo2->m_Break_point>>16))
    {
      //MessageBeep(0);
      Trace=1;
      theApp.m_pMainWnd->SetWindowText(_T("StrProlog is TRACING."));
      goto R17;
    }
    else if (Trace==4)
      goto R18;
  }
  else if (Trace)
  {
    if (Trace==4)
    {
R18:  for (i=0, j=stack_br; j!=0; j=(Stack[j]&MASKA2), i++);
      if (StepOver<i)
        goto R20;
      else
        Trace=1;
    }
R17:Stack[stack_br+2]=Stack[stack_br+3]=0;  // for better view
    status_fl|=8;
    MitiRedraw();
    if (Trace==2)
    {
      status_fl&=M1^8;
      return (10);
    }
    pThread->SuspendThread();
    status_fl&=M1^8;
#if TR
    if (status_fl&16)
      MitiText("Conflict! c2\r\n", &cf_red);
#endif
    while(status_fl&16); //  MitiText("Conflict! ");
    if (Trace==2)
      return (10);
  }
R20:
        /* Unify */
  // Use the buffers from create - bufu1, 2, ...  // Must be

#if 0 //MY_DEBUG   // only in debug mode
  if (main_h1)  // if there are heads-variables
  {
    Ekler[++ekler_br]=sv_subv;
    Link[sv_subv]=Pointers[TT_VAR] & MASKA2;
    Link[sv_subv+1]=Link[sv_subv+2]=Link[sv_subv+3]=0;
    sv_subv+=4;
  }
#endif
  // if (Pointers[term_1] & QUARTER) // preduvkano
  pointer=salam_br=buf1_min=durty_min=durty_br=br_buf1=0;
  sv_subv2=sv_subv;
  if (term_1<TT_START) // constant or variable
  {
    if (term_1==TT_VAR)
    {
      for (i=buda_br; Buda1[i]==TT_LINK; i=Buda2[i]);
      if ((term_1=Buda1[i])>=TT_START)
      {
        buf_4[0]=i;
        buf_6[0]=2;
        if (Chfil_c[term_1-TT_START]==1)  // large built_in
        {
          if (Pointers[term_1=Ufil_c1[term_1-TT_START]]&OBSEG1)
          {
            if (term_1==TT_VAR)
            {
              for (i=Link[Buda2[i]]; Buda1[i]==TT_LINK; i=Buda2[i]);  // !!!
              if (!(Pointers[Buda1[i]]&OBSEG1) || Buda1[i]==TT_VAR)
              {
                pointer=Mtree[0][1];
                goto x12p;
              }
              term_1=Buda1[i];
            }
            i=D_field[(Pointers[term_1]&MASKA3)+2];
            buf_4[1]=term_1=Ufil_c2[Buda1[buf_4[0]]-TT_START];  // !!!
            goto e1;
          }
          pointer=Mtree[0][1]; // it is made OK, otherwise error
          goto x12p;
        }
        if (Pointers[term_1] & OBSEG2)
          goto e2;
        goto x3;
      }
      else if (Buda1[i]<TT_VAR)
        goto x2;
      else if (Buda1[i]==TT_VAR)
      {
        sprintf(string2,"Runtime Error at step %d:\r\n",0x10000*lSteps_br+Steps_br-Corection);
        MitiText(string2, &cf_red);
        MitiText("Call of not-instantiated variable.\r\n");
        Wait=Wait_d=0;
        return(ret_fl=10);  
      }
      else if (main_h1)
      {
        if (ekler_br++>EKLER && correct_EKLER() )
        {
FULLek:   MitiText("Small EKLER!\r\n", &cf_red);
          goto FULL;
        }
        Ekler[ekler_br]=sv_subv+3;
        Link[sv_subv+3]=D_field[Pointers[TT_VAR]&MASKA3];
        Link[sv_subv]=buda_br+1; Link[sv_subv+1]=128; Link[sv_subv+2]=buda_br;
        Link[sv_subv+4]=Link[sv_subv+5]=0; Link[sv_subv+6]=1;
        sv_subv+=7;
        goto eOKp; //OK
      }
      else
        goto fail;
    }
x2: if (Pointers[term_1] & OBSEG2)
      goto e2;
    if (Pointers[term_1] & HALF)
    {  
      if (ekler_br++>EKLER && correct_EKLER() )
        goto FULLek;
      Ekler[ekler_br]=sv_subv;
      Link[sv_subv]=D_field[Pointers[term_1]&MASKA3];
      Link[sv_subv+1]=Link[sv_subv+2]=Link[sv_subv+3]=0;
      sv_subv+=4;
      goto eOKp; //OK
    }
    goto fail;
  }
  buf_4[0]=term_1;
  buf_6[0]=0;

#include "is.h"

  while (pointer & OBSEG1)
  {
    pointer&=MASKA;
    if (term_1>=TT_START)
    {
x5:   if (Mtree[pointer][0]&HALF) // if there are heads with variable here
      {
        if (Mtree[pointer][0]&OBSEG2)
        {
          if (Ch_tree[pointer]>=TT_VAR)
          {
            if (Mtree[pointer][Chfil_c[term_1-TT_START]]&HALF)
            {
              WRITE_IN_STACK;// write "var subtree" with a path (holded by main tree)
              Salam[salam_br-5]=sv_subv2;
              Salam[salam_br-6]=Mtree[pointer][0] & MASKA;
              Salam[salam_br-7]=4*buf_6[br_buf1]; // status==0
              Salam[salam_br-8]=Ch_tree[pointer]; // first variable
              pointer=Mtree[pointer][Chfil_c[term_1-TT_START]];
              goto x12;
            }
            else if ((k=Blocks_next[(p=Mtree[pointer][0] & MASKA)+Ch_tree[pointer]])>=TT_VAR && k!=SM1 && (Blocks[p+k]&HALF))
            {
              WRITE_IN_STACK; // write "var subtree" with two paths
              Salam[salam_br-5]=sv_subv2;
              Salam[salam_br-6]=p;
              Salam[salam_br-7]=4*buf_6[br_buf1];  // status==0
              Salam[salam_br-8]=k;                 // first variable
            }
            t=a1+Ch_tree[pointer]-TT_VAR;
            pointer=Blocks[p+Ch_tree[pointer]];
x15:        for ( ; Buda1[t]==TT_LINK; t=Buda2[t]);
            if (Buda1[t]==TT_VAR)
            {
              if (term_1>=MEMORY_c256)
              {
                if (buf_6[br_buf1]&2)
                {
                  p=i=0;
                  j=buf_4[br_buf1];
x34:              buf_7[p++]=i;
                  buf_7[p++]=j;
                  i=Chfil_v[Buda1[j]-MEMORY_c256];
x35:              for (j=Link[Buda2[j]+ --i]; Buda1[j]==TT_LINK; j=Buda2[j]);   /* if X=f(X) */
                  if (j==t)
                    goto back;
                  else if (Buda1[j]>=MEMORY_c256)
                    goto x34;
x36:              if (i)
                  {
                    j=buf_7[p-1];
                    goto x35;
                  }
                  if (p)
                  {
                    j=buf_7[--p];
                    i=buf_7[--p];
                    goto x36;
                  }
                  Durty[durty_br++]=t;
                  Buda1[t]=TT_LINK;
                  Buda2[t]=j;
                  goto x8;
                }
                buf1_All=br_buf1;
                goto x17;
              }
              Durty[durty_br++]=t;
              if (buf_6[br_buf1]&2)
              {
                Buda1[t]=TT_LINK;
                Buda2[t]=buf_4[br_buf1];
              }
              else
                Buda1[t]=term_1;
            }
            else if (term_1>=MEMORY_c256 || Buda1[t]>=MEMORY_c256) // unify furder
            {
              buf1_All=br_buf1;
              term_2=Buda1[t];
              buf_5[br_buf1]=t;
              buf_6[br_buf1]+=4;
              goto E3;
            }
            else if (Buda1[t]!=term_1)
              goto back;
            goto x8;
          }
        }
        else  // OBSEG1    or head
          if (Ch_tree[pointer]>TT_LIST)
          {
            if (Mtree[pointer][Chfil_c[term_1-TT_START]]&HALF)
            {
              WRITE_IN_STACK;// write in stack
              Salam[salam_br-5]=sv_subv2;
              Salam[salam_br-6]=Mtree[pointer][0];
              Salam[salam_br-7]=16*Ch_tree[pointer]-(16*TT_VAR-5)+4*buf_6[br_buf1]; // status==5
              pointer=Mtree[pointer][Chfil_c[term_1-TT_START]];
              goto x12;
            }
            else
            {
              t=a1+Ch_tree[pointer]-TT_VAR;
              pointer=Mtree[pointer][0];
              goto x15;
            }
          }
      }
x3:   if (!((pointer=Mtree[pointer][Chfil_c[term_1-TT_START]])&HALF))
        goto back;
x12:  term_1=Ufil_c1[term_1-TT_START];
x12p: buf_4[++br_buf1]=term_1;
      buf_6[br_buf1]=0;
    }
    else if (term_1==TT_VAR)
    {
      for (j=0, i=br_buf1; i>0; ) // calc. var num
        if ( buf_6[--i]&2 )   /* 2,3  (6,7,10 are impossible) */
        {
          if (buf_6[i]&1)
          {
            m=Buda1[buf_4[i]]-TT_START;
            if (Ufil_vs[m-MEMORY_C]!=M1)
              j=Substi[Ufil_vs[m-MEMORY_C]+j];
            else if (Ufil_c1[m]>=MEMORY_c256)
              j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
            else if (Ufil_c1[m]==TT_VAR)
              j++;
          }
          j=Link[Buda2[buf_4[i]]+j];
          goto x4;
        }
        else if (buf_6[i]&1)
        {
          if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
            j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
          else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
            j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
          else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR)
            j++;
        }
      j+=buda_br;
x4:   for (; Buda1[j]==TT_LINK; j=Buda2[j]);
      if (Buda1[j]!=TT_VAR)
      {
        buf_4[br_buf1]=j;
        buf_6[br_buf1]=2;
        if ((term_1=Buda1[j])>=TT_START)
          goto x5;
        else
        {
          if (term_1<TT_VAR)
            goto x6;
          else if (!(Mtree[pointer][0]&HALF)) // new type
            goto back;
          if (Mtree[pointer][0]&OBSEG2)
          {
            if (Ch_tree[pointer]>=TT_VAR)
            {
              if ((k=Blocks_next[(p=Mtree[pointer][0] & MASKA)+Ch_tree[pointer]])>=TT_VAR && k!=SM1 && (Blocks[p+k]&HALF))
              {
                WRITE_IN_STACK; // write "var subtree" with two paths
                Salam[salam_br-5]=sv_subv2;
                Salam[salam_br-6]=p;
                Salam[salam_br-7]=4*buf_6[br_buf1];  // status==0
                Salam[salam_br-8]=k;                 // first variable
              }
              i=a1+Ch_tree[pointer]-TT_VAR;
              pointer=Blocks[p+Ch_tree[pointer]];
              
              for ( ; Buda1[i]==TT_LINK; i=Buda2[i]);
              if (Buda1[i]==TT_VAR)
              {
                Durty[durty_br++]=i;
                Buda1[i]=TT_LINK;
                Buda2[i]=j;
                goto x8;
              }
              else if (Buda1[i]==term_1) // term_1 is a new type
              {
                if (Buda2[i]==Buda2[j])
                  goto x8;
                if (term_1==TT_STR)
                {
                  for ( r=Buda2[i], s=Buda2[j];
                          StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
                  if (StringStore[r]==StringStore[s])
                    goto x8;
                }// back
              }
            }
            goto back;
          }
          else if (Ch_tree[pointer]>TT_LIST) // variable
          {
            for ( i=a1+Ch_tree[pointer]-TT_VAR; Buda1[i]==TT_LINK; i=Buda2[i]);
            if (Buda1[i]==TT_VAR)
            {
              Durty[durty_br++]=i;
              Buda1[i]=TT_LINK;
              Buda2[i]=j;
              goto x8p;
            }
            else if (Buda1[i]==term_1) // new type
            {
              if (Buda2[i]==Buda2[j])
                goto x8p;
              if (term_1==TT_STR)
              {
                for ( r=Buda2[i], s=Buda2[j];
                       StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
                if (StringStore[r]==StringStore[s])
                  goto x8p;
              }// back
            }
          }
          goto back;
        }
      }
      else
      {
        Durty[durty_br]=j;  // unbounded variable! - create term for it
        Buda2[j]=sv_subv2;  // j keeps its value
        pointer2=OBSEG1;
        buf1_All=br_buf1; // br_buf1
x16:    if (Mtree[pointer][3]&HALF)
        {
          if ((Mtree[pointer][0]&HALF) || (Mtree[pointer][1]&HALF) || (Mtree[pointer][2]&HALF))
          {
            WRITE_IN_STACK;// write All tree
            Salam[salam_br-5]=sv_subv2-Buda2[j];
            Salam[salam_br-6]=pointer;
            Salam[salam_br-8]=pointer2;
            if (Mtree[pointer][2]&HALF)       // from 2
              Salam[salam_br-7]=8*buf1_All+1; // buf1_All + status==1
            else if (Mtree[pointer][1]&HALF)  // from 1
              Salam[salam_br-7]=8*buf1_All+2;
            else                              // only 0
              Salam[salam_br-7]=8*buf1_All+3;
          }
          buf_6[++br_buf1]=0;
          if (pointer2 & OBSEG1)
            pointer2=Mtree[pointer2 & MASKA][3];
          if ((pointer=Mtree[pointer][3]) & OBSEG1)
          {
            pointer&=MASKA;
            goto x16;
          }
x19:      br_buf1=buf1_All;
          for (buf1_All=i=0, buf_5[0]=(pointer & MASKA)+TT_START; i<br_buf1; i++)// concreate unify
            buf_5[i+1]=(buf_6[i]&1)?Ufil_c2[buf_5[i]-TT_START]:Ufil_c1[buf_5[i]-TT_START];
          term_2=buf_5[i];
          buf_6[i]=0;
          if (term_2>=MEMORY_c256) // not equal
          {
            q=Chfil_v[term_2-MEMORY_c256];
            t=k=sv_subv2-Buda2[j];
            if (k<q) // i==br_buf1
              goto x18;
          }
          durty_br++;
          Buda1[j]=term_2;
          goto E5;
        }
        else if (Mtree[pointer][2]&HALF)
        {
          if ((Mtree[pointer][0]&HALF) || (Mtree[pointer][1]&HALF))
          {
            WRITE_IN_STACK;// write All tree
            Salam[salam_br-5]=sv_subv2-Buda2[j];
            Salam[salam_br-6]=pointer;
            Salam[salam_br-8]=pointer2;
            if (Mtree[pointer][1]&HALF)       // from 1
              Salam[salam_br-7]=8*buf1_All+2;
            else                              // only 0
              Salam[salam_br-7]=8*buf1_All+3;
          }
in2:      buf_6[++br_buf1]=0;
          if (pointer2 & OBSEG1)
            pointer2=Mtree[pointer2 & MASKA][2];
          if ((pointer=Mtree[pointer][2]) & OBSEG1)
          {
            pointer&=MASKA;
            goto x16;
          }
          goto x19;
        }
        else if (Mtree[pointer][1]&HALF)
        {
          if (Mtree[pointer][0]&HALF)
          {
            WRITE_IN_STACK;// write All tree
            Salam[salam_br-5]=sv_subv2-Buda2[j];
            Salam[salam_br-6]=pointer;
            Salam[salam_br-7]=8*buf1_All+3; // only 0
            Salam[salam_br-8]=pointer2;
          }
in1:      buf_6[++br_buf1]=0;
          if (pointer2 & OBSEG1)
            pointer2=Mtree[pointer2 & MASKA][1];
          if ((pointer=Mtree[pointer][1]) & OBSEG1)
          {
            pointer&=MASKA;
            goto x16;
          }
          goto x19;  // concrete unify 
        }
        else if (Mtree[pointer][0]&OBSEG2)
        {
          p=Mtree[pointer][0] & MASKA;
          q=Ch_tree[pointer];
          if ((t=Blocks_next[p+q])!=SM1 && (Blocks[p+t]&HALF))
          {  // status==6  q, Blocks[p+q]
            WRITE_IN_STACK;// write All tree
            Salam[salam_br-6]=p;
            if (pointer2==OBSEG1) // krupka
            {
              Salam[salam_br-5]=sv_subv2;
              Salam[salam_br-8]=HALF|j;
            }
            else
            {
              Salam[salam_br-5]=sv_subv2-Buda2[j];
              Salam[salam_br-8]=pointer2&HALFM;
            }
            Salam[salam_br-7]=8*(BLOCK*buf1_All+t)+4; // status==4
          }
          pointer=Blocks[p+q];
in0:      if (pointer2==OBSEG1) // substitution with constant
          {
            if (q>TT_LIST)
            {
              for (t=a1+q-TT_VAR; Buda1[t]==TT_LINK; t=Buda2[t]);
              if (t==j)
                goto x8;
              if (Buda1[t]==TT_VAR)
              {
                Buda1[t]=TT_LINK;
                Buda2[t]=j;
                Durty[durty_br++]=t; // The older has priority
                goto x8;
              }
              else
              {
                if (Buda1[t]>=MEMORY_c256)
                {
                  p=i=0;
x37:              buf_7[p++]=i;
                  buf_7[p++]=t;
                  i=Chfil_v[Buda1[t]-MEMORY_c256];
x38:              for (t=Link[Buda2[t]+ --i]; Buda1[t]==TT_LINK; t=Buda2[t]);  /* if Y=f(Y) */
                  if (t==j)
                    goto back;
                  else if (Buda1[t]>=MEMORY_c256)
                    goto x37;
x39:              if (i)
                  {
                    t=buf_7[p-1];
                    goto x38;
                  }
                  if (p)
                  {
                    t=buf_7[--p];
                    i=buf_7[--p];
                    goto x39;
                  }
                }
                Buda1[j]=TT_LINK;
                Buda2[j]=t;
                durty_br++;
                goto x8;
              }
            }
            Buda1[j]=q;
            durty_br++;
            goto x8;
          }
          if (q>TT_LIST)
          {
            t=a1+q-TT_VAR; //for (; Buda1[t]==TT_LINK; t=Buda2[t]); wrong
            for (i=Buda2[j]; i<sv_subv2 && Link[i]!=t; i++);
            q=TT_VAR+i-Buda2[j];
            if (i==sv_subv2)
            {
              Link[sv_subv2++]=t;
              for (; Buda1[t]==TT_LINK; t=Buda2[t]);
              p=i=0;
x20:          if (t==j) // if Y=f(Y)
                goto back;
              else if (Buda1[t]>=MEMORY_c256)
              {
                buf_7[p++]=i;
                buf_7[p++]=t;
                i=Chfil_v[Buda1[t]-MEMORY_c256];
x21:            for (t=Link[Buda2[t]+ --i]; Buda1[t]==TT_LINK; t=Buda2[t]);
                goto x20;
              }
x22:          if (i)
              {
                t=buf_7[p-1];
                goto x21;
              }
              if (p)
              {
                t=buf_7[--p];
                i=buf_7[--p];
                goto x22;
              }
            }
          }
          if (pointer2 & OBSEG1)
          {
            if (Mtree[pointer2&=MASKA][0] & OBSEG2)
              pointer2=Blocks[(Mtree[pointer2][0] & MASKA)+q];
            else
              pointer2=Mtree[pointer2][0];
          }
          while (buf_6[--br_buf1]&1)
            if (br_buf1==0)       // trace
            {
#if TR
              if ((pointer & (OBSEG1 | OBSEG2)) || (pointer2 & (OBSEG1 | OBSEG2))) // trace
                MitiText("A-uuuuu!\r\n");
#endif
              durty_br++;
              Buda1[j]=TT_START + (pointer2 & MASKA);
              buf_5[0]=(pointer & MASKA)+TT_START;
              goto E5p;
            }
          if (br_buf1 < buf1_min)
            buf1_min=br_buf1;
          buf_6[br_buf1++]++;
          buf_6[br_buf1]=0;
          if (br_buf1<=buf1_All)
          {
            if (buf_6[br_buf1-1]&2)
              term_1=Ufil_c2[Buda1[buf_4[br_buf1-1]]-TT_START];
            else
              term_1=Ufil_c2[buf_4[br_buf1-1]-TT_START];
            buf_4[br_buf1]=term_1;
#if TR
            if (pointer2 & (OBSEG1 | OBSEG2)) // trace
              MitiText("A-uuu!\r\n");
#endif
            durty_br++;
            Buda1[j]=TT_START + (pointer2 & MASKA);
            continue;
          }
          if (pointer & OBSEG1)
          {
            pointer&=MASKA;
            goto x16;
          }
          goto x19;  // concrete unify 
        }
        else  // OBSEG1    or head
        {
          q=Ch_tree[pointer];
          pointer=Mtree[pointer][0];
          goto in0;
        }
      }
    }
    else  // term_1 is a constant
    {
x6:   if (!(Mtree[pointer][0]&HALF))
        goto back;
      if (Mtree[pointer][0]&OBSEG2)
      {
        if (Ch_tree[pointer]>=TT_VAR)
        {
          if (Blocks_val[(p=Mtree[pointer][0] & MASKA)+term_1]==term_1 && (Blocks[p+term_1]&HALF))
          {
            WRITE_IN_STACK;// write "var subtree" with a path (holded by main tree)
            Salam[salam_br-5]=sv_subv2;
            Salam[salam_br-6]=p;
            Salam[salam_br-7]=4*buf_6[br_buf1];  // status==0
            Salam[salam_br-8]=Ch_tree[pointer]; // first variable
            pointer=Blocks[p+term_1];
            goto x8;
          }
          else if ((k=Blocks_next[p+Ch_tree[pointer]])>=TT_VAR && k!=SM1 && (Blocks[p+k]&HALF))
          {
            WRITE_IN_STACK; // write "var subtree" with two paths
            Salam[salam_br-5]=sv_subv2;
            Salam[salam_br-6]=p;
            Salam[salam_br-7]=4*buf_6[br_buf1];  // status==0
            Salam[salam_br-8]=k;                 // first variable
          }
          i=a1+Ch_tree[pointer]-TT_VAR;
          pointer=Blocks[p+Ch_tree[pointer]];
          for ( ; Buda1[i]==TT_LINK; i=Buda2[i]);
          if (Buda1[i]==TT_VAR)
          {
            Durty[durty_br++]=i;
            if (buf_6[br_buf1])
            {
              Buda1[i]=TT_LINK;
              Buda2[i]=buf_4[br_buf1];
            }
            else
              Buda1[i]=term_1;
          }
          else if (Buda1[i]!=term_1) // term_1 is a constant
            goto back;
          goto x8;
        }
        else if (Blocks_val[(p=Mtree[pointer][0] & MASKA)+term_1]==term_1 && (Blocks[p+term_1]&HALF))
        {
          pointer=Blocks[p+term_1];
          goto x8;
        }
        else
        {
back:     if (salam_br==0)
          {
            for (; durty_br; Buda1[Durty[--durty_br]]=TT_VAR);
            switch (ekler_br-(i=Stack[stack_br-1]&MASKA2))
            {
             case 0:       /* back traking */
fail:         for (q=buda_br; q<a1; Buda1[q++]=TT_VAR); // clean substitutions
failp:        m=Link[j=Ekler[ekler_br]];
              a1=Link[sv_subv-1]; // buda_br - later
              sv_subv-=Atoms[m]+1;
              if ((Program[m]&HALF) || (Prog_fild[Program[m]+1]&HALF))
              {  //clean standard types by the head or system call (1 or 2 or 3)
                if (m<FIRST_ROWS-1)
                {
                  ekler_br--;
                  Stack[stack_br-1]--;
                  if (m<FIRST_ROWS-3) // m=/=0
                    for (q=m; q--; Buda1[--buda_br]=TT_VAR);
                  else if (m==FIRST_ROWS-3) // Class::method
                    for (q=2; q--; Buda1[--buda_br]=TT_VAR);
                  Buda1[--buda_br]=TT_VAR;
                }
                else
                  for (p=Link[--sv_subv]; p; p--, Buda1[Link[--sv_subv]]=TT_VAR);
              }
              if (Stack[stack_br-=4]&THREE_Q)
              {
                if (Stack[stack_br]&HALF)
                {
                  m=stack_br; // ?
                  br_buf1=0;  // ?
                  a1=buda_br;
                  return(0);
                }
                else if (ProgTail[m]==M1 || (Stack[stack_br+3]&HALF)) // || Cut!
                {
ex8:              if ((Stack[stack_br]&MASKA2)==stack_br-4)
                  {
                    stack_br-=4;
                    a1=Link[Stack[stack_br+2]];
                    ekler_br=Stack[stack_br-1]&MASKA2;
                    goto ex5;
                  }
                  ekler_br=Stack[stack_br-1]&MASKA2;
                  sv_subv=Stack[stack_br-2]+1;
                  goto failp;
                }
                else
                {                  
                  a1=Ekler[Stack[stack_br+1]-1];
                  goto ex4;
                }
              }
fail3:        if (Stack[stack_br+3]&HALF) // Cut!
              {
                if (Stack[stack_br+3]&QUARTER) // No Cut!
                  goto fail4;
fail2p:         ekler_br=Stack[stack_br-1]&MASKA2;
fail2:          i=Link[j+3];  // durty_br
                do
                {
                  k=Link[j+2]; // > 0 or ==0
                  n=Link[j+1];
                  for (j-=3*(Link[j+3]-i); i>k; i--, Buda1[Link[j-=3]]=TT_VAR);
                }
                while (j=n);
ex5:            sv_subv=Stack[stack_br-2]+1;
                buda_br=Link[Stack[Stack[stack_br]+2]-Stack[stack_br+1]];
                goto fail;
              }
              else
fail4:         if (ProgTail[m]==M1)
              {
fail4p:         if (--ekler_br==(Stack[stack_br-1]&MASKA2))
                  goto fail2;
                else
                  Stack[stack_br+3]--;
              }
              else
              {
ex4:            m=Link[j]=ProgTail[m];
                if (Program[m]&HALF) // built-in
                {
                  if((Stack[stack_br]&QUARTER)==0)
                  {
                    if (execute(Program[m]&HALFM, a1, M1)==0)  // fail
                    {
                      a1=buda_br;
                      if (ProgTail[m]==m)
                        goto fail4p;
                      else
                        goto fail4;
                    }
                  }
                  else if (Stack[stack_br+1]
                            <(Stack[(Stack[stack_br]&MASKA2)+7]&MASKA2)-1) // Function
                  {
                    if (execute(Program[m]&HALFM, a1+1, Buda2[a1])==0)  // fail
                      goto ex8;
                  }
                  else
                  {
                    if (execute(Program[m]&HALFM, a1, M1)==0)  // fail
                      goto ex8;
                  }
                  //buda_br=Link[Stack[Stack[stack_br]+2]-Stack[stack_br+1]];
                  Link[sv_subv++]=my_gl;       
                  goto MX;
                }
                for (p=Stack[stack_br-1]&MASKA2, q=ekler_br; p<q-1; )
                  if (Link[Ekler[minimum=(p+q)/2]]>m)
                    p=minimum;
                  else
                    q=minimum;
                if ((q=ekler_br-1)==p) // every thing is OK
                {
                  //buda_br=Link[Stack[Stack[stack_br]+2]-Stack[stack_br+1]];
                  goto eOK2;
                }
                do
                  Ekler[q+1]=Ekler[q];
                while (--q>p);
                Ekler[p+1]=j;
              }
              i=Link[j+3];  // durty_br
              do
              {
                k=Link[j+2]; // > 0 or ==0
                n=Link[j+1];
                for (j-=3*(Link[j+3]-i); i>k; i--, Buda1[Link[j-=3]]=TT_VAR);
              }
              while (j=n);
              buda_br=Link[Stack[Stack[stack_br]+2]-Stack[stack_br+1]];
              goto eOK;
             case 1:
              break;
             case 2:
              i++;
              if (Link[Ekler[i]]<Link[Ekler[i+1]])
              {
                k=Ekler[i];
                Ekler[i]=Ekler[i+1];
                Ekler[i+1]=k;
              }
              break;
             case 3:
              i++;
              if (Link[Ekler[i]]<Link[Ekler[i+2]])
              {
                k=Ekler[i];
                Ekler[i]=Ekler[i+2];
                Ekler[i+2]=k;
              }
              if (Link[Ekler[i]]<Link[Ekler[i+1]])
              {
                k=Ekler[i];
                Ekler[i]=Ekler[i+1];
                Ekler[i+1]=k;
              }
              else if (Link[Ekler[i+1]]<Link[Ekler[i+2]])
              {
                k=Ekler[i+1];
                Ekler[i+1]=Ekler[i+2];
                Ekler[i+2]=k;
              }
              break;
             default:
              if (Link[Ekler[++i]]<Link[Ekler[j=ekler_br]])// first change
              {
                k=Ekler[i];
                Ekler[i]=Ekler[j];
                Ekler[j]=k;
              }
              m=i+1;  // i <p m (k,t-for change) n <q j
              n=j-1;
              do
              {
                if (Link[Ekler[m]]<Link[Ekler[n]])// if we need - change the midle two
                {
                  k=Ekler[n];
                  Ekler[n]=Ekler[m];
                  Ekler[m]=k;
                }
                if (Link[Ekler[m]]<Link[Ekler[n+1]])
                { // if big is less than smallest
                  k=Ekler[m];
                  Ekler[m]=Ekler[n-1];
                  t=Ekler[n];
                  for (p=n+1, q=j+1; p<q-1; )
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[k])
                      p=minimum;
                    else
                      q=minimum;
                  for (q=n+1; q<=p; Ekler[q-2]=Ekler[q], q++);
                  Ekler[p-1]=k;
                  for (k=q, q=j+1; p<q-1; )  // p=p
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[t])
                      p=minimum;
                    else
                      q=minimum;
                  for (; k<q; Ekler[k-1]=Ekler[k], k++);
                  Ekler[p]=t;
                  n-=2;
                }
                else if (Link[Ekler[n]]>Link[Ekler[m-1]])
                { // if small is bigger than bigest
                  k=Ekler[n];
                  Ekler[n]=Ekler[m+1];
                  t=Ekler[m];
                  for (p=i-1, q=m-1; p<q-1; )
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[k])
                      p=minimum;
                    else
                      q=minimum;
                  for (p=m-1; p>=q; Ekler[p+2]=Ekler[p], p--);
                  Ekler[q+1]=k;
                  for (k=p, p=i-1; p<q-1; )  // q=q
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[t])
                      p=minimum;
                    else
                      q=minimum;
                  for (; k>p; Ekler[k+1]=Ekler[k], k--);
                  Ekler[q]=t;
                  m+=2;
                }
                else
                { // if normal
                  k=Ekler[n]; // first
                  for (p=n, q=j+1; p<q-1; )
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[k])
                      p=minimum;
                    else
                      q=minimum;
                  for (p=n+1; p<q; Ekler[p-1]=Ekler[p], p++);
                  Ekler[q-1]=k;
                  t=Ekler[m]; // second
                  for (p=i-1, q=m; p<q-1; )
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[t])
                      p=minimum;
                    else
                      q=minimum;
                  for (q=m-1; q>p; Ekler[q+1]=Ekler[q], q--);
                  Ekler[p+1]=t;
                  n--;
                  m++;
                }
              }
              while (m<n);
              if (m==n)
              {
                if (Link[Ekler[n]]<Link[Ekler[n+1]])
                {
                  k=Ekler[n]; // first
                  for (p=n+1, q=j+1; p<q-1; ) // n+1 - for first we know!
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[k])
                      p=minimum;
                    else
                      q=minimum;
                  for (p=n+1; p<q; Ekler[p-1]=Ekler[p], p++);
                  Ekler[q-1]=k;
                }
                else
                {
                  t=Ekler[m]; // second
                  for (p=i-1, q=m; p<q-1; )
                    if (Link[Ekler[minimum=(p+q)/2]]>Link[t])
                      p=minimum;
                    else
                      q=minimum;
                  for (q=m-1; q>p; Ekler[q+1]=Ekler[q], q--);
                  Ekler[p+1]=t;
                }
              } 
            }
eOKp:       Stack[stack_br+3]=ekler_br;
eOK:        j=Ekler[ekler_br];
            i=Link[j+3];  // durty_br
            do
            {
              k=Link[j+2]; // > 0 or ==0
              n=Link[j+1];
              for (j-=3*(Link[j+3]-i); i>k; i--, j-=3, t=Link[j], Buda1[t]=Link[j+1], Buda2[t]=Link[j+2]);
            }
            while (j=n);
eOK2:       if ((t=Prog_fild[(i=Program[m=Link[Ekler[ekler_br]]])+1])&(THREE_Q|OBSEG1))
            { // if standard types are in the head
              if (t&(QUARTER|OBSEG1)) // built-in
              {
                if (t&OBSEG1) // if this clause is already out
                {
                  j=Ekler[ekler_br];
                  goto fail4;
                }
                else // built-in
                  // no standard types
                  //buda_br=Link[Stack[Stack[stack_br]+2]-Stack[stack_br+1]];
                  goto MX;
              }
              else
              {
                j=t&MASKA1; // was MASKA2, bug correction // can be returned bag
                t=(Prog_fild[i]==TT_VAR)?1:Chfil_v[Prog_fild[i]-MEMORY_c256];//? heads are not variables
              }
              p=0; q=Prog_fild[j];
              do
              {
                for (q+=a1; Buda1[q]==TT_LINK; q=Buda2[q]);
                if (Buda1[q]==TT_VAR)
                {
                  Buda1[q]=Prog_fild[j+1];
                  Buda2[q]=Prog_fild[j+2];
                  Link[sv_subv++]=q;
                  p++;
                }
                else if (Buda1[q]==Prog_fild[j+1])
                {
                  if (Buda2[q]!=Prog_fild[j+2])
                  {
                    if (Buda1[q]!=TT_STR) // for str
                      goto fail5;
                    for ( r=Buda2[q], s=Prog_fild[j+2];
                            StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
                    if (StringStore[r]!=StringStore[s])
                      goto fail5;
                  }
                }
                else
                {
fail5:            for ( ; p; p--, Buda1[Link[--sv_subv]]=TT_VAR);
                  j=Ekler[ekler_br];
                  goto fail4;
                }
                q=Prog_fild[j+=3];
              }
              while (q!=M1);
              Link[sv_subv++]=p;
            }
            buda_br=a1+t;
MX:         if (stack_br>=STACK2)
            {
              if (status_fl&32)    // Making a retract
              {
                my_gl2=m;
                return(1);
              }
              if (pInfo2->m_Settings&4) // Stack is Full as Fail
              {
                j=Ekler[ekler_br];
                goto fail2p;
              }
              if(correct_Stack())
              {
                Wait=Wait_d=0;
                return(ret_fl=2);
              }
            }  
MX2:        if (BUDA3<buda_br && correct_BUDA() ) // ? ||
            {
FULL:         Wait=Wait_d=0;
              return(ret_fl=3);
            }
            if (Atoms[m])          /* not aksiom */
            {
              Link[sv_subv]=buda_br;
              sv_subv+=Atoms[m];
              Link[sv_subv]=a1;
              Stack[stack_br+2]=sv_subv++;  // sv_subv-1
              stack_br+=4;
              Stack[stack_br]=stack_br-4;
              Stack[stack_br+1]=Atoms[m];
              term_1=Prog_fild[(i=Program[m]+2*Atoms[m])];
              if ((t=Prog_fild[i+1])&HALF)
              { // if we need to make substitution
                j=t&MASKA2;
                t=(term_1==TT_VAR)?1:Chfil_v[term_1-MEMORY_c256];
                q=Prog_fild[j];
                do
                {
                  q+=buda_br;
                  if (Prog_fild[j+1]&HALF)
                  {
                    Buda1[q]=TT_LINK;
                    Buda2[q]=a1+Prog_fild[j+2];
                  }
                  else
                  {
                    Buda1[q]=Prog_fild[j+1];
                    Buda2[q]=Prog_fild[j+2];
                  }
                  q=Prog_fild[j+=3];
                }
                while (q!=M1);
              }
              a1=buda_br+t;
              goto R16;
            }
            Link[sv_subv]=a1;
            Stack[stack_br+2]=sv_subv++;  // sv_subv-1
            j=stack_br;
ex3:        while (Stack[j+1]==1)    /* go up */
              if(Stack[j=Stack[j]]&THREE_Q)
              {
                if (Stack[j]&HALF)
                {
                  a1=buda_br;
                  return(1);
                }
                else
ex7:              if (Stack[j+1]>=(Stack[(Stack[j]&MASKA2)+7]&MASKA2)-1) // ready
                {
                  j=Stack[j]&MASKA2;
                  goto ex3;
                }
                else
                {
                  k=Stack[j+1];
                  t=Buda1[Buda2[Ekler[k-1]]]-TT_VAR;
                  if (t>K_SP_TYPES)
                    t=1;
                  if ((Ekler[k-2]&(TP_VAR>>t))==0) // error
                  {
                    error_func2(t, k);
                    j=Ekler[ekler_br];
                    goto fail2p;
                  }
                  stack_br+=4;
                  k+=3; // pointer
                  Stack[stack_br]=Stack[j];  // QUARTER inside
                  j=Stack[j]&MASKA2;

ex6:              i=sv_subv; //save
                  sv_subv+=4;
ex2:              m=Ekler[k];
                  a1=Ekler[k-1];
                  while (Program[m]&HALF)
                  {
                    if (k<(Stack[j+7]&MASKA2)-1) // Function
                    {
                      DWORD Return=Buda2[a1]; // scan changes a1
                      if (execute(Program[m]&HALFM, a1+1, Return))
                      {
                        t=Buda1[Return]-TT_VAR;
                        if (t>K_SP_TYPES)
                          t=1;
                        if ((Ekler[k-2]&(TP_VAR>>t))==0) // error
                          error_func2(t, k);
                        else if (ProgTail[m]==M1)
                        {
                          k+=3;
                          goto ex2;
                        }
                        else
                        {
                          Stack[stack_br+1]=k;
                          if (ekler_br++>EKLER && correct_EKLER() )
                            goto FULLek;
                          Ekler[ekler_br]=i;
                          Link[i]=m;
                          Link[i+1]=Link[i+2]=Link[i+3]=0;
                          Stack[stack_br+3]=ekler_br;
                          k+=3;
                          Link[sv_subv++]=0; // for clean
                          Link[sv_subv]=a1;
                          Stack[stack_br+2]=sv_subv++;  // sv_subv-1
                          Stack[stack_br+4]=Stack[stack_br];  // QUARTER inside
                          stack_br+=4;
                          goto ex6;
                        }
                      }
                    }
                    else
                    {
                      if (execute(Program[m]&HALFM, a1, M1))
                      {
                        Stack[stack_br+1]=k;
                        if (ekler_br++>EKLER && correct_EKLER() )
                          goto FULLek;
                        if (ProgTail[m]==M1)
                          Ekler[ekler_br]=4*FIRST_ROWS-4; // 9
                        else
                        {
                          Ekler[ekler_br]=i;
                          Link[i]=m;
                          Link[i+1]=Link[i+2]=Link[i+3]=0;
                        }
                        Stack[stack_br+3]=ekler_br;
                        Link[sv_subv++]=my_gl; // for clean
                        goto MX;
                      }
                    }
                    if (ProgTail[m]==M1 || ProgTail[m]==m)
                      goto ex8;
                    m=ProgTail[m];
                  }
                  Stack[stack_br+1]=k;
                  if (ekler_br++>EKLER && correct_EKLER() )
                    goto FULLek;
                  Ekler[ekler_br]=i;
                  Link[i]=m;
                  Link[i+1]=Link[i+2]=Link[i+3]=0;
                  Stack[stack_br+3]=ekler_br;
                  //Link[sv_subv++]=my_gl; // for clean ???? do we need here
                  goto MX;
                }
              }
            if (Stack[j]&QUARTER)
              goto ex7;
            stack_br+=4;
            Stack[stack_br]=i=Stack[j];                  // Tati
            Stack[stack_br+1]=Stack[j+1]-1;            // Atom in the Clause
            Link[(k=Stack[i+2])-Stack[stack_br+1]]=buda_br;
            term_1=Prog_fild[i=Program[Link[Ekler[Stack[i+3]&MASKA2]]]+2*Stack[stack_br+1]];
            if ((t=Prog_fild[i+1])&HALF)
            { // if we need to make substitution
              j=t&MASKA2;
              t=(term_1==TT_VAR)?1:Chfil_v[term_1-MEMORY_c256];
              q=Prog_fild[j];
              do
              {
                q+=buda_br;
                if (Prog_fild[j+1]&HALF)
                {
                  Buda1[q]=TT_LINK;
                  Buda2[q]=Link[k-(Prog_fild[j+1]&MASKA2)]+Prog_fild[j+2];
                }
                else
                {
                  Buda1[q]=Prog_fild[j+1];
                  Buda2[q]=Prog_fild[j+2];
                }
                q=Prog_fild[j+=3];
              }
              while (q!=M1);
            }
            a1=buda_br+t;
            goto R16;
          }
          j=salam_br-8;
          i=Salam[j+5];  // br_buf1
          do
          {
            if (Salam[j+6]>buf1_min)
            {
              k=Salam[j+6];
              n=Salam[j+7];
            }
            else
            {
              k=buf1_min;
              n=0;
            }
            for (j-=2*(Salam[j+5]-i); i>k; j-=2, buf_4[i]=Salam[j+1], buf_6[--i]=Salam[j]);
          }
          while (j=n);
          buf1_min=Salam[salam_br-2];
          br_buf1=Salam[salam_br-3];
          i=Salam[salam_br-4]; // durty_br
          sv_subv2=Salam[salam_br-5];
          pointer=Salam[salam_br-6];
          t=Salam[salam_br-7]; // status
          pointer2=Salam[salam_br-8];
          if (durty_min>i)
            durty_min=i;
          for (; durty_br>i; Buda1[Durty[--durty_br]]=TT_VAR);
          buf_6[br_buf1]=0;
          switch (t&7)
          {
           case 0:  // "var subtree" with a path
            if (sv_subv2<sv_subv)
              sv_subv2=sv_subv;
            if (t&8)
            {
              term_1=Buda1[buf_4[br_buf1]];
              buf_6[br_buf1]=2;
            }
            else
              term_1=buf_4[br_buf1];
                        
            if ((i=Blocks_next[pointer+pointer2])>=TT_VAR && i!=SM1 && (Blocks[pointer+i]&HALF))
              Salam[salam_br-8]=i; // next var
            else
              salam_br-=8+2*(br_buf1-buf1_min);

            pointer=Blocks[pointer+pointer2];
            if (term_1<TT_START)
            {
              for ( t=a1+pointer2-TT_VAR; Buda1[t]==TT_LINK; t=Buda2[t]);
              if (!buf_6[br_buf1])
              {
                if (Buda1[t]==TT_VAR)
                {
                  Durty[durty_br++]=t;
                  Buda1[t]=term_1;
                }
                else if (Buda1[t]!=term_1)
                  goto back;
                goto x8;
              }
              if (Buda1[t]==TT_VAR)
              {
                Durty[durty_br++]=t;
                Buda1[t]=TT_LINK;
                Buda2[t]=buf_4[br_buf1];
                goto x8;
              }                                          // new type
              else if (Buda1[t]==term_1)
              {
                if (term_1<TT_VAR || Buda2[t]==Buda2[buf_4[br_buf1]])
                  goto x8;
                if (term_1==TT_STR)
                {
                  for ( r=Buda2[t], s=Buda2[buf_4[br_buf1]];
                        StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
                  if (StringStore[r]==StringStore[s])
                    goto x8;
                }// back
              }
              goto back;
            }
            t=a1+pointer2-TT_VAR;
            goto x15;
           case 1: // start from 2
            if (Mtree[pointer][1]&HALF)
              Salam[salam_br-7]++; // next time - next status
            else if (Mtree[pointer][0]&HALF)
              Salam[salam_br-7]+=2;
            else
              salam_br-=8+2*(br_buf1-buf1_min);
            buf1_All=t/8;
            j=Durty[durty_br];
            if (Buda2[j]<sv_subv)
            {
              //MitiText("Maje\r\n");
              for ( i=sv_subv2; i-->0; Link[sv_subv+i]=Link[Buda2[j]+i]);
              Buda2[j]=sv_subv;
            }
            sv_subv2+=Buda2[j];
            goto in2;
           case 2: // start from 1
            if (Mtree[pointer][0]&HALF)
              Salam[salam_br-7]++; // next time - next status
            else
              salam_br-=8+2*(br_buf1-buf1_min);
            buf1_All=t/8;
            j=Durty[durty_br];
            if (Buda2[j]<sv_subv)
            {
              //MitiText("Maje\r\n");
              for ( i=sv_subv2; i-->0; Link[sv_subv+i]=Link[Buda2[j]+i]);
              Buda2[j]=sv_subv;
            }
            sv_subv2+=Buda2[j];
            goto in1;
           case 3: // start from 0
            buf1_All=t/8;
            j=Durty[durty_br];
            if (Buda2[j]<sv_subv)
            {
              //MitiText("Maje\r\n");
              for ( i=sv_subv2; i-->0; Link[sv_subv+i]=Link[Buda2[j]+i]);
              Buda2[j]=sv_subv;
            }
            sv_subv2+=Buda2[j];
            if (!(Mtree[pointer][0] & OBSEG2))
            {
              salam_br-=8+2*(br_buf1-buf1_min);
              q=Ch_tree[pointer];
              pointer=Mtree[pointer][0];
              goto in0;
            }
            p=Mtree[pointer][0] & MASKA;
            q=Ch_tree[pointer];
            if ((i=Blocks_next[p+q])!=SM1 && (Blocks[p+i]&HALF))
            {
              Salam[salam_br-6]=p;
              if (pointer2==OBSEG1) // krupka
              {
                Salam[salam_br-5]=sv_subv2;
                Salam[salam_br-8]=HALF|j;
              }
              else
                Salam[salam_br-8]&=HALFM;
              Salam[salam_br-7]=8*(BLOCK*buf1_All+i)+4;
            }
            else
              salam_br-=8+2*(br_buf1-buf1_min);
            pointer=Blocks[p+q];
            goto in0;
           case 4: // with var (all content of the block)
            buf1_All=t/(8*BLOCK);
            q=(t/8)&(BLOCK-1);
            if (pointer2&HALF) // krupka
            {
#if TR
              //MitiText("k"); // krupkata raboti
#endif
              j=pointer2&HALFM;
              Durty[durty_br]=j;
              pointer2=OBSEG1;
              if (sv_subv2<sv_subv)
                Buda2[j]=sv_subv2=sv_subv;
              else
                Buda2[j]=sv_subv2;
            }
            else
            {
              j=Durty[durty_br];
              if (Buda2[j]<sv_subv)
              {
                //MitiText("Maje\r\n");
                for ( i=sv_subv2; i-->0; Link[sv_subv+i]=Link[Buda2[j]+i]);
                Buda2[j]=sv_subv;
              }
              sv_subv2+=Buda2[j];
            }
            if ((i=Blocks_next[pointer+q])!=SM1 && (Blocks[pointer+i]&HALF))
              Salam[salam_br-7]+=8*(i-q); // status
            else
              salam_br-=8+2*(br_buf1-buf1_min);
            pointer=Blocks[pointer+q];
            goto in0;
           case 5:  // one var (not in block)
            if (sv_subv2<sv_subv)
              sv_subv2=sv_subv;
            if (t&8)
            {
              term_1=Buda1[buf_4[br_buf1]];
              buf_6[br_buf1]=2;
            }
            else
              term_1=buf_4[br_buf1];
            salam_br-=8+2*(br_buf1-buf1_min);
            t=a1+t/16;
            goto x15;
          }
        }
      }
      else if (Ch_tree[pointer]>=TT_VAR) // variable
      {
        for ( i=a1+Ch_tree[pointer]-TT_VAR; Buda1[i]==TT_LINK; i=Buda2[i]);
        if (Buda1[i]==TT_VAR)
        {
           Durty[durty_br++]=i;
           if (buf_6[br_buf1])
           {
             Buda1[i]=TT_LINK;
             Buda2[i]=buf_4[br_buf1];
           }
           else
             Buda1[i]=term_1;
         }
         else if (Buda1[i]!=term_1) // term_1 is a constant
           goto back;
      }
      else if (term_1!=Ch_tree[pointer])
        goto back;
x8p:  pointer=Mtree[pointer][0];
x8:   while (buf_6[--br_buf1]&1)
        if (br_buf1==0)       // trace
        {
#if TR
          if (pointer & (OBSEG1 | OBSEG2)) // trace
            MitiText("A-u!\r\n");
#endif
          buf_5[0]=(pointer & MASKA)+TT_START;
          goto E5p;
        }
      if (br_buf1 < buf1_min)
        buf1_min=br_buf1;
      if (buf_6[br_buf1]) // &2
        term_1=Ufil_c2[Buda1[buf_4[br_buf1]]-TT_START];
      else
        term_1=Ufil_c2[buf_4[br_buf1]-TT_START];
      buf_6[br_buf1++]++;
      buf_4[br_buf1]=term_1;
      buf_6[br_buf1]=0;
    }
  }
#if TR
  if (pointer & OBSEG2) // absolutely useless
    MitiText("That was impossible!\r\n");
#endif
  for (buf1_All=i=0, buf_5[0]=(pointer & MASKA)+TT_START; i<br_buf1; i++) // concreate unify
    buf_5[i+1]=(buf_6[i]&1)?Ufil_c2[buf_5[i]-TT_START]:Ufil_c1[buf_5[i]-TT_START];
  term_2=buf_5[i];
E3:                    /* equal */
  if (term_1==term_2)
  {
    if (term_1>=MEMORY_c256)
    {
      k=Chfil_v[term_1-MEMORY_c256];
E12:  while( k-->0 )
      {
        j=t=k;
        if (buf_6[i=br_buf1]&2)
          goto S1p;
        while (i>0) // calc. var num
          if ( buf_6[--i]&2 )   /* 2,3,6,7,10 */
          {
            if (buf_6[i]&1)
            {
              m=Buda1[buf_4[i]]-TT_START;
              if (Ufil_vs[m-MEMORY_C]!=M1)
                j=Substi[Ufil_vs[m-MEMORY_C]+j];
              else if (Ufil_c1[m]>=MEMORY_c256)
                j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
              else if (Ufil_c1[m]==TT_VAR)
                j++;
            }
S1p:        j=Link[Buda2[buf_4[i]]+j];
            goto S1;
          }
          else if (buf_6[i]&1)
          {
            if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
              j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
            else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
              j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
            else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR) 
              j++;
          }
        j+=buda_br;
S1:     for (; Buda1[j]==TT_LINK; j=Buda2[j]);
        if (buf_6[i=br_buf1]>3)
          goto E16p;
        while (i>0) // calc. var num
          if (buf_6[--i]>3)
          {
            if (buf_6[i]&1)
            {
              m=Buda1[buf_5[i]]-TT_START;
              if (Ufil_vs[m-MEMORY_C]!=M1)
                t=Substi[Ufil_vs[m-MEMORY_C]+t];
              else if (Ufil_c1[m]>=MEMORY_c256)
                t+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
              else if (Ufil_c1[m]==TT_VAR)
                t++;
            }
E16p:       t=Link[Buda2[buf_5[i]]+t];
            goto E16;
          }
          else if (buf_6[i]&1)
          {
            if (Ufil_vs[buf_5[i]-MEMORY_c256]!=M1)
              t=Substi[Ufil_vs[buf_5[i]-MEMORY_c256]+t];
            else if (Ufil_c1[buf_5[i]-TT_START]>=MEMORY_c256)
              t+=Chfil_v[Ufil_c1[buf_5[i]-TT_START]-MEMORY_c256];
            else if (Ufil_c1[buf_5[i]-TT_START]==TT_VAR)
              t++;
          }
        t+=a1;
E16:    for (; Buda1[t]==TT_LINK; t=Buda2[t]);
        if (t==j)
          continue;
        if (Buda1[t]==TT_VAR)
        {
          if (Buda1[j]>=MEMORY_c256)
          {
            p=i=0;
E34:        buf_7[p++]=i;
            buf_7[p++]=j;
            i=Chfil_v[Buda1[j]-MEMORY_c256];
E35:        for (j=Link[Buda2[j]+ --i]; Buda1[j]==TT_LINK; j=Buda2[j]);   /* if X=f(X) */
            if (j==t)
              goto back;
            else if (Buda1[j]>=MEMORY_c256)
              goto E34;
E36:        if (i)
            {
              j=buf_7[p-1];
              goto E35;
            }
            if (p)
            {
              j=buf_7[--p];
              i=buf_7[--p];
              goto E36;
            }
          }
          Durty[durty_br++]=t;
          Buda1[t]=TT_LINK;
          Buda2[t]=j;
        }
        else if (Buda1[j]==TT_VAR)
        {
          if (Buda1[t]>=MEMORY_c256)
          {
            p=i=0;
E37:        buf_7[p++]=i;
            buf_7[p++]=t;
            i=Chfil_v[Buda1[t]-MEMORY_c256];
E38:        for (t=Link[Buda2[t]+ --i]; Buda1[t]==TT_LINK; t=Buda2[t]);  /* if Y=f(Y) */
            if (t==j)
              goto back;
            else if (Buda1[t]>=MEMORY_c256)
              goto E37;
E39:        if (i)
            {
              t=buf_7[p-1];
              goto E38;
            }
            if (p)
            {
              t=buf_7[--p];
              i=buf_7[--p];
              goto E39;
            }
          }
          Durty[durty_br++]=j;
          Buda1[j]=TT_LINK;
          Buda2[j]=t;
        }
        else
        {
          if (Buda1[j]<TT_START && Buda1[j]>TT_LINK)   // New Obj
          {
            switch(Buda1[j])
            {
             case TT_STR:
              if (Buda1[t]==TT_STR)
              {
                if ((r=Buda2[j])==(s=Buda2[t]))
                  continue;
                for ( ; StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
                if (StringStore[r]==StringStore[s])
                  continue;
                else
                  goto back;          
              }  
              else
                goto back;
             case TT_INT:
              if (Buda1[t]==TT_INT && Buda2[j]==Buda2[t])
                continue;
              else
                goto back;
             case TT_FLOAT:
              if (Buda1[t]==TT_FLOAT && Buda2[j]==Buda2[t])
                continue;
              else
                goto back;
             case TT_OBJ:
              if (Buda1[t]==TT_OBJ && Buda2[j]==Buda2[t])
                continue;
              else
                goto back;
             default:
              MitiText("Unnown New Object!.\r\n");
              goto back;
            } 
          }
      //  else if (Buda1[t]<TT_START && Buda1[t]>TT_LINK)   // we will not need this
          else
          {
            term_1=Buda1[j];
            term_2=Buda1[t];
            buf_6[br_buf1]+=10;
            buf_3[br_buf1]=k;
            buf_6[++br_buf1]=6;
            buf_4[br_buf1]=j;
            buf_5[br_buf1]=t;
            goto E3;
          }
        }
      }
      goto E5;
    }
    else if (term_1==TT_VAR)
    {
      for (j=t=0, i=br_buf1; i>0; ) // calc. var num
        if ( buf_6[--i]&2 )   /* 2,3,6,7,10 */
        {
          if (buf_6[i]&1)
          {
            m=Buda1[buf_4[i]]-TT_START;
            if (Ufil_vs[m-MEMORY_C]!=M1)
              j=Substi[Ufil_vs[m-MEMORY_C]+j];
            else if (Ufil_c1[m]>=MEMORY_c256)
              j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
            else if (Ufil_c1[m]==TT_VAR)
              j++;
          }
          j=Link[Buda2[buf_4[i]]+j];
          goto S2;
        }
        else if (buf_6[i]&1)
        {
          if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
            j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
          else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
            j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
          else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR)
            j++;
        }
      j+=buda_br;
S2:   for (; Buda1[j]==TT_LINK; j=Buda2[j]);
      for (i=br_buf1; i>0; ) // calc. var num
        if (buf_6[--i]>3)
        {
          if (buf_6[i]&1)
          {
            m=Buda1[buf_5[i]]-TT_START;
            if (Ufil_vs[m-MEMORY_C]!=M1)
              t=Substi[Ufil_vs[m-MEMORY_C]+t];
            else if (Ufil_c1[m]>=MEMORY_c256)
              t+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
            else if (Ufil_c1[m]==TT_VAR)
              t++;
          }
          t=Link[Buda2[buf_5[i]]+t];
          goto E9;
        }
        else if (buf_6[i]&1)
        {
          if (Ufil_vs[buf_5[i]-MEMORY_c256]!=M1)
            t=Substi[Ufil_vs[buf_5[i]-MEMORY_c256]+t];
          else if (Ufil_c1[buf_5[i]-TT_START]>=MEMORY_c256)
            t+=Chfil_v[Ufil_c1[buf_5[i]-TT_START]-MEMORY_c256];
          else if (Ufil_c1[buf_5[i]-TT_START]==TT_VAR)
            t++;
        }
      t+=a1;
E9:   for (; Buda1[t]==TT_LINK; t=Buda2[t]);
      if (j==t)
        goto E5;
      if (Buda1[t]==TT_VAR)
      {
        if (Buda1[j]>=MEMORY_c256)
        {
          p=i=0;
E27:      buf_7[p++]=i;
          buf_7[p++]=j;
          i=Chfil_v[Buda1[j]-MEMORY_c256];
E28:      for (j=Link[Buda2[j]+ --i]; Buda1[j]==TT_LINK; j=Buda2[j]); /* if X=f(X) */
          if (j==t)
            goto back;
          else if (Buda1[j]>=MEMORY_c256)
            goto E27;
E29:      if (i)
          {
            j=buf_7[p-1];
            goto E28;
          }
          if (p)
          {
            j=buf_7[--p];
            i=buf_7[--p];
            goto E29;
          }
        }
        Durty[durty_br++]=t;
        Buda1[t]=TT_LINK;
        Buda2[t]=j;
      }
      else if (Buda1[j]==TT_VAR)
      {
        if (Buda1[t]>=MEMORY_c256)
        {
          p=i=0;
E30:      buf_7[p++]=i;
          buf_7[p++]=t;
          i=Chfil_v[Buda1[t]-MEMORY_c256];
E31:      for (t=Link[Buda2[t]+ --i]; Buda1[t]==TT_LINK; t=Buda2[t]);  /* if Y=f(Y) */
          if (t==j)
            goto back;
          else if (Buda1[t]>=MEMORY_c256)
            goto E30;
E32:      if (i)
          {
            t=buf_7[p-1];
            goto E31;
          }
          if (p)
          {
            t=buf_7[--p];
            i=buf_7[--p];
            goto E32;
          }
        }
        Durty[durty_br++]=j;
        Buda1[j]=TT_LINK;
        Buda2[j]=t;
      }
      else
      {
        if (Buda1[j]<TT_START && Buda1[j]>TT_LINK)   // New Obj
        {
          switch(Buda1[j])
          {
           case TT_STR:
            if (Buda1[t]==TT_STR)
            {
              if ((r=Buda2[j])==(s=Buda2[t]))
                goto E5;
              for ( ; StringStore[r]==StringStore[s] && StringStore[r]!=0; r++, s++);
              if (StringStore[r]==StringStore[s])
                goto E5;
              else
                goto back;          
            }  
            else
              goto back;
           case TT_INT:
            if (Buda1[t]==TT_INT && Buda2[j]==Buda2[t])
              goto E5;
            else
              goto back;
           case TT_FLOAT:
            if (Buda1[t]==TT_FLOAT && Buda2[j]==Buda2[t])
              goto E5;
            else
              goto back;
           case TT_OBJ:
            if (Buda1[t]==TT_OBJ && Buda2[j]==Buda2[t])
              goto E5;
            else
              goto back;
           default:
            MitiText("Unnown New Object!.\n");
            goto back;
          } 
        }
    //  else if (Buda1[t]<TT_START && Buda1[t]>TT_LINK)   // we will not need this!
        else
        {
          term_1=Buda1[j];
          term_2=Buda1[t];
          buf_4[br_buf1]=j;                  /* ? */
          buf_5[br_buf1]=t;
          buf_6[br_buf1]=6;
          goto E3;
        }
      }
      goto E5;
    }
    else
      goto E5;
  }
  else                          /* not equal */
  {
    if (term_2>=MEMORY_c256)
    {
        if (term_1>=TT_START)
        {
          if (Chfil_c[term_2-TT_START]==Chfil_c[term_1-TT_START])
            goto E6;
         else
            goto back;
        }
        else if (term_1==TT_VAR)
        {
          for (j=0, i=br_buf1; i>0; ) // calc. var num
            if ( buf_6[--i]&2 )   /* 2,3,6,7,10 */
            {
              if (buf_6[i]&1)
              {
                m=Buda1[buf_4[i]]-TT_START;
                if (Ufil_vs[m-MEMORY_C]!=M1)
                  j=Substi[Ufil_vs[m-MEMORY_C]+j];
                else if (Ufil_c1[m]>=MEMORY_c256)
                  j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
                else if (Ufil_c1[m]==TT_VAR)
                  j++;
              }
              j=Link[Buda2[buf_4[i]]+j];
              goto S3;
            }
            else if (buf_6[i]&1)
            {
              if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
                j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
              else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
                j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
              else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR)
                j++;
            }
          j+=buda_br;
S3:       for (; Buda1[j]==TT_LINK; j=Buda2[j]);
          if (Buda1[j]==TT_VAR)
          {
            Buda2[j]=sv_subv2;
            q=Chfil_v[term_2-MEMORY_c256];
            for (k=0; k<q; k++)
            {
x18:          for (t=k, i=br_buf1; i>0; ) // calc. var num
                if (buf_6[--i]>3)
                {
                  if (buf_6[i]&1)
                  {
                    m=Buda1[buf_5[i]]-TT_START;
                    if (Ufil_vs[m-MEMORY_C]!=M1)
                      t=Substi[Ufil_vs[m-MEMORY_C]+t];
                    else if (Ufil_c1[m]>=MEMORY_c256)
                      t+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
                    else if (Ufil_c1[m]==TT_VAR)
                      t++;
                  }
                  t=Link[Buda2[buf_5[i]]+t];
                  goto E18;
                }
                else if (buf_6[i]&1)
                {
                  if (Ufil_vs[buf_5[i]-MEMORY_c256]!=M1)
                    t=Substi[Ufil_vs[buf_5[i]-MEMORY_c256]+t];
                  else if (Ufil_c1[buf_5[i]-TT_START]>=MEMORY_c256)
                    t+=Chfil_v[Ufil_c1[buf_5[i]-TT_START]-MEMORY_c256];
                  else if (Ufil_c1[buf_5[i]-TT_START]==TT_VAR)
                    t++;
                }
              t+=a1;
E18:          p=i=0;
E25:          for (; Buda1[t]==TT_LINK; t=Buda2[t]);    /* if Y=f(Y) */
              if (t==j)
                goto back;
              else if (Buda1[t]>=MEMORY_c256)
              {
                buf_7[p++]=i;
                buf_7[p++]=t;
                i=Chfil_v[Buda1[t]-MEMORY_c256];
E24:            t=Link[Buda2[t]+ --i];
                goto E25;
              }
E23:          if (i)
              {
                t=buf_7[p-1];
                goto E24;
              }
              if (p)
              {
                t=buf_7[--p];
                i=buf_7[--p];
                goto E23;
              }
              Link[sv_subv2++]=t;
            }
            Durty[durty_br++]=j; // for x18 we need only ++
            Buda1[j]=term_2;
          }
          else
          {
            term_1=Buda1[j];
            buf_4[br_buf1]=j;
            buf_6[br_buf1]=2;
            goto E3;
          }
          goto E5;
        }
        else
          goto back;
    }
    else if (term_2==TT_VAR)
    {
      for (t=0, i=br_buf1; i>0; ) // calc. var num
        if (buf_6[--i]>3)
        {
          if (buf_6[i]&1)
          {
            m=Buda1[buf_5[i]]-TT_START;
            if (Ufil_vs[m-MEMORY_C]!=M1)
              t=Substi[Ufil_vs[m-MEMORY_C]+t];
            else if (Ufil_c1[m]>=MEMORY_c256)
              t+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
            else if (Ufil_c1[m]==TT_VAR)
              t++;
          }
          t=Link[Buda2[buf_5[i]]+t];
          goto E17;
        }
        else if (buf_6[i]&1)
        {
          if (Ufil_vs[buf_5[i]-MEMORY_c256]!=M1)
            t=Substi[Ufil_vs[buf_5[i]-MEMORY_c256]+t];
          else if (Ufil_c1[buf_5[i]-TT_START]>=MEMORY_c256)
            t+=Chfil_v[Ufil_c1[buf_5[i]-TT_START]-MEMORY_c256];
          else if (Ufil_c1[buf_5[i]-TT_START]==TT_VAR)
            t++;
        }
      t+=a1;
E17:  for (; Buda1[t]==TT_LINK; t=Buda2[t]);
      if (Buda1[t]==TT_VAR)
      {
        if (term_1>=MEMORY_c256)
        {
x17:      Buda2[t]=sv_subv2;
          q=Chfil_v[term_1-MEMORY_c256];
          for (k=0; k<q; k++)
          {
            for (j=k, i=br_buf1; i>0; ) // calc. var num
              if ( buf_6[--i]&2 )   /* 2,3,6,7,10 */
              {
                if (buf_6[i]&1)
                {
                  m=Buda1[buf_4[i]]-TT_START;
                  if (Ufil_vs[m-MEMORY_C]!=M1)
                    j=Substi[Ufil_vs[m-MEMORY_C]+j];
                  else if (Ufil_c1[m]>=MEMORY_c256)
                    j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
                  else if (Ufil_c1[m]==TT_VAR)
                    j++;
                }
                j=Link[Buda2[buf_4[i]]+j];
                goto S4;
              }
              else if (buf_6[i]&1)
              {
                if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
                  j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
                else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
                  j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
                else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR)
                  j++;
              }
            j+=buda_br;
S4:         p=i=0;
E19:        for (; Buda1[j]==TT_LINK; j=Buda2[j]);       /* if X=f(X) */
            if (j==t)
              goto back;
            else if (Buda1[j]>=MEMORY_c256)
            {
              buf_7[p++]=i;
              buf_7[p++]=j;
              i=Chfil_v[Buda1[j]-MEMORY_c256];
E20:          j=Link[Buda2[j]+--i];
              goto E19;
            }
E21:        if (i)
            {
              j=buf_7[p-1];
              goto E20;
            }
            if (p)
            {
              j=buf_7[--p];
              i=buf_7[--p];
              goto E21;
            }
            Link[sv_subv2++]=j;
          }
        }
        Durty[durty_br++]=t;                    /* else term_1!=TT_VAR */
        Buda1[t]=term_1;
      }
      else
      {
        term_2=Buda1[t];
        buf_5[br_buf1]=t;
        buf_6[br_buf1]=4;
        goto E3;
      }
E5:   do
      {
        if (br_buf1==buf1_All)
        {
          if (buf1_All)
            goto x8;
E5p:      sv_subv=sv_subv2;
          if (durty_min)  // && ekler_br
            for (n=Ekler[i=ekler_br]; Link[n+2]>=durty_min; n=Ekler[--i]);
          else
            n=0;
          for (i=durty_min; i<durty_br; j=Link[sv_subv]=Durty[i++],
                Link[sv_subv+1]=Buda1[j], Link[sv_subv+2]=Buda2[j], sv_subv+=3);
          if (ekler_br++>EKLER && correct_EKLER() )
            goto FULLek;
          if (BUDA_S2<sv_subv && correct_LINK() ) // MAX_VARS is the reserve 
            goto FULL;
          Ekler[ekler_br]=sv_subv;
          Link[sv_subv]=D_field[Pointers[buf_5[0]]&MASKA3];
          Link[sv_subv+1]=n;
          Link[sv_subv+2]=durty_min;
          Link[sv_subv+3]=durty_min=durty_br;
          sv_subv+=4;
          goto back;
        }
      }
      while (buf_6[--br_buf1]&1);
      if (br_buf1 < buf1_min)
        buf1_min=br_buf1;
      if (buf_6[br_buf1]>=10)
      {
        buf_6[br_buf1]-=10;
        k=buf_3[br_buf1];
        goto E12;
      }
      if (buf_6[br_buf1]&2)    /* 2,6 */
        term_1=Ufil_c2[Buda1[buf_4[br_buf1]]-TT_START];
      else
        term_1=Ufil_c2[buf_4[br_buf1]-TT_START];
      if (buf_6[br_buf1]>3)
        term_2=Ufil_c2[Buda1[buf_5[br_buf1]]-TT_START];
      else
        term_2=Ufil_c2[buf_5[br_buf1]-TT_START];
      buf_6[br_buf1++]++;
      buf_4[br_buf1]=term_1;
      buf_5[br_buf1]=term_2;
      buf_6[br_buf1]=0;
      goto E3;
    }
    else                 /* term_2 is closed */
    {
      if (term_1>=MEMORY_c256)
      {
        if (term_2>=TT_START && Chfil_c[term_2-TT_START]==Chfil_c[term_1-TT_START])
        {
E6:       term_1=Ufil_c1[term_1-TT_START];
          term_2=Ufil_c1[term_2-TT_START];
          buf_4[++br_buf1]=term_1;
          buf_5[br_buf1]=term_2;
          buf_6[br_buf1]=0;
          goto E3;
        }
        else
          goto back;
      }
      else if (term_1==TT_VAR)
      {
        for (j=0, i=br_buf1; i>0; ) // calc. var num
          if ( buf_6[--i]&2 )   /* 2,3,6,7,10 */
          {
            if (buf_6[i]&1)
            {
              m=Buda1[buf_4[i]]-TT_START;
              if (Ufil_vs[m-MEMORY_C]!=M1)
                j=Substi[Ufil_vs[m-MEMORY_C]+j];
              else if (Ufil_c1[m]>=MEMORY_c256)
                j+=Chfil_v[Ufil_c1[m]-MEMORY_c256];
              else if (Ufil_c1[m]==TT_VAR)
                j++;
            }
            j=Link[Buda2[buf_4[i]]+j];
            goto S5;
          }
          else if (buf_6[i]&1)
          {
            if (Ufil_vs[buf_4[i]-MEMORY_c256]!=M1)
              j=Substi[Ufil_vs[buf_4[i]-MEMORY_c256]+j];
            else if (Ufil_c1[buf_4[i]-TT_START]>=MEMORY_c256)
              j+=Chfil_v[Ufil_c1[buf_4[i]-TT_START]-MEMORY_c256];
            else if (Ufil_c1[buf_4[i]-TT_START]==TT_VAR)
              j++;
          }
        j+=buda_br;
S5:     for (; Buda1[j]==TT_LINK; j=Buda2[j]);
        if (Buda1[j]==TT_VAR)
        {
          Durty[durty_br++]=j;
          Buda1[j]=term_2;
        }
        else
        {
          term_1=Buda1[j];
          buf_4[br_buf1]=j;
          buf_6[br_buf1]=2;
          goto E3;
        }
        goto E5;
      }
      else
        goto back;
    }
  }

}
