#include <mem.cvh>
#include <seq.cvh>

int main() {
  struct {
    int a;
    union UT {
      int b_seq[];
      int b_arr[10];
    } b;
  } s;

  $write_set_push();

  s.a = 0;

  $mem m = $write_set_pop();

  $assert($mem_contains(m, ($mem)&s.a) &&
	  $mem_contains(($mem)&s.a, m));

  $write_set_push();

  s.b.b_arr[9] = 0;

  m = $write_set_pop();

  $assert($mem_contains(m, ($mem)&s.b.b_arr[9]) &&
	  $mem_contains(($mem)&s.b.b_arr[9], m));

  $seq_init(&s.b.b_seq, 10, &s.a);

  $write_set_push();

  s.b.b_seq[9] = 0;
  s.b.b_arr[9] = 0;

  m = $write_set_pop();

  $assert($mem_contains(m, $mem_union(($mem)&s.b.b_seq,
				      ($mem)&s.b.b_arr[9])) &&
	  $mem_contains($mem_union(($mem)&s.b.b_seq,
				   ($mem)&s.b.b_arr[9]),
			m));
  
}
