int main() {

  {
    list* l2 = cons(2,NULL);
    show(l2);
    list* l1 = cons(1,l2);
    show(l1);
    show(l2);
    destroy(l1);
  }

  {
    list* l = cons(1,cons(2,cons(3,NULL)));
    printf("%d\n",nth(1,l));
    printf("%d\n",nth_rec(1,l));
    destroy(l);
    printf("%d\n",nth(0,l));
  }

  /* {
    list* l1 = cons(1,cons(2,cons(3,NULL)));
    list* l2 = cons(4,cons(5,NULL));
    glue(l1,l2);
    show(l1);
    destroy(l1);
  } */

  /* {
    list* l1 = cons(1,cons(2,cons(3,NULL)));
    list* l2 = cons(4,cons(5,NULL));
    list* l3 = cons(1,cons(2,cons(3,cons(4,cons(5,NULL)))));
    glue(l1,l2);
    assert(equals(l1,l3));
    assert(!equals(l2,l3));
    assert(!equals(l1,l2));
    assert(!equals(l1,NULL));
    destroy(l1);
    destroy(l3);
  } */


  /* {
    list* l1 = cons(1,cons(2,cons(3,NULL)));
    list* l2 = cons(4,cons(5,NULL));
    glue(l1,l2);
    tie(l2);
    show_max(l1,20);
    // untie(l2);
    // destroy(l1);
  } */

  /* {
    list* l1 = cons(1,cons(2,cons(3,NULL)));
    list* l2 = cons(4,cons(5,NULL));
    list* l3 = cons(7,NULL);
    assert(!is_circular(l1));
    assert(!is_circular(l2));
    assert(!is_circular(l3));
    assert(!is_circular(NULL));
    glue(l3,l1);
    printf("l1 circular: %d\n",is_circular(l1));
    glue(l1,l2);
    tie(l2);
    assert(is_circular(l1));
    assert(is_circular(l2));
    assert(is_circular(l3));
    printf("l1 circular: %d\n",is_circular(l1));
    untie(l2);
    destroy(l3);
  } */

  /* {
    list* l1 = cons(1,cons(2,cons(3,NULL)));
    list* l2 = cons(4,cons(5,NULL));
    list* m1 = cons(1,cons(2,cons(3,cons(4,cons(5,NULL)))));
    list* m2 = cons(4,cons(5,cons(4,cons(5,NULL))));
    glue(l1,l2);
    glue(m1,m2);
    tie(l2);
    tie(m2);
    assert(equals_circular(l1,m1));
    assert(!equals_circular(l1,l1->next));
    assert(!equals_circular(l1,m1->next));
    assert(!equals_circular(l2,l2->next));
    assert(!equals_circular(l1,l1->next));
    assert(!equals_circular(m2,m2->next));
    assert(!equals_circular(m1,m1->next));
    assert(equals_circular(m2,m2->next->next));
    untie(l2);
    untie(m2);
    destroy(l1);
    destroy(m1);
  } */

}