#define true 1
#define false 0

bool ain,bin;
bool lock;

inline swap(k){
  atomic{
   int tmp;
   tmp = k;
   k = lock;
   lock = tmp;
  }
}

proctype A()
{
 int key;
 
 :: true ->
   key = true;
   do
    :: key ->
        (!lock);
        swap(key);
    :: !key -> break;
   od;
progress:
   ain=true;
   assert(bin==false);
   ain=false;
   swap(key);
od;
}

proctype B()
{
   int key;

   key = true;
   do
    :: key ->
        (!lock);
        swap(key); 
        !key -> break;
   od;
progress:

   bin=true;
   assert(ain==false);
   bin=false;
   swap(key);
}



init
{
  lock = false;
  atomic{
    run A(); 
    run B();
  }
}
