#include<mem.cvh>
#include<stdlib.h>

struct T {
  int (*x)[100];
} ** a;

int main() {
  a = (struct T **)malloc(sizeof(struct T*));
  *a = (struct T*)malloc(sizeof(struct T));
  (*a)->x = (int (*)[100])malloc(sizeof(int[100]) * 10);

  $assert($mem_contains((*a)->x, &(*a)->x[0][0 .. 10]));    // (*a)->x refers to the array (*a)->x[0], type of int[100]
  $assert(!$mem_contains((*a)->x, &(*a)->x[1][0 .. 10]));   // (*a)->x does NOT points to array (*a)->x[1]
  $assert($mem_contains(*a, &(*a)->x));  // (*a) refers the whole struct, &(*a)->x refers to the only field
  $assert(!$mem_contains(*a, (*a)->x));  // (*a) refers the whole struct, (*a)->x refers to array pointed by the field

  free((*a)->x);
  free(*a);
  free(a);
}
