1  extern void exit (int);
       2  extern void abort (void);
       3  
       4  typedef struct T
       5  {
       6    char val;
       7    const __as struct T *l, *r;
       8  } tree;
       9  
      10  /*
      11                      abcd   
      12                     /    \
      13                   ab      cd
      14                  /  \    /  \
      15                 a    b  c    d
      16  */
      17  
      18  const __as tree a = { 'a', 0, 0 };
      19  const __as tree b = { 'b', 0, 0 };
      20  const __as tree c = { 'c', 0, 0 };
      21  const __as tree d = { 'd', 0, 0 };
      22  
      23  const __as tree ab = { 'A', &a, &b };
      24  const __as tree cd = { 'C', &c, &d };
      25  
      26  const __as tree abcd = { '*', &ab, &cd };
      27  
      28  static void
      29  test1 (void)
      30  {
      31    if (abcd.val != '*')
      32      abort();
      33  
      34    if (abcd.l->val != 'A')
      35      abort();
      36    if (abcd.r->val != 'C')
      37      abort();
      38  
      39    if (abcd.l->l->val != 'a')
      40      abort();
      41    if (abcd.l->r->val != 'b')
      42      abort();
      43    if (abcd.r->l->val != 'c')
      44      abort();
      45    if (abcd.r->r->val != 'd')
      46      abort();
      47  }
      48  
      49  static void
      50  test2 (const __as tree *t)
      51  {
      52    if (t->val != '*')
      53      abort();
      54  
      55    if (t->l->val != 'A')
      56      abort();
      57    if (t->r->val != 'C')
      58      abort();
      59  
      60    if (t->l->l->val != 'a')
      61      abort();
      62    if (t->l->r->val != 'b')
      63      abort();
      64    if (t->r->l->val != 'c')
      65      abort();
      66    if (t->r->r->val != 'd')
      67      abort();
      68  }
      69  
      70  static void
      71  test3 (const __as tree *pt)
      72  {
      73    tree t = *pt;
      74    
      75    if (t.val != '*')
      76      abort();
      77  
      78    if (t.l->val != 'A')
      79      abort();
      80    if (t.r->val != 'C')
      81      abort();
      82  
      83    if (t.l->l->val != 'a')
      84      abort();
      85    if (t.l->r->val != 'b')
      86      abort();
      87    if (t.r->l->val != 'c')
      88      abort();
      89    if (t.r->r->val != 'd')
      90      abort();
      91  }
      92  
      93  int main (void)
      94  {
      95    const __as tree *t = &abcd;
      96    test1();
      97    test2 (&abcd);
      98    test3 (&abcd);
      99  
     100    __asm ("" : "+r" (t));
     101    test2 (t);
     102    test3 (t);
     103    
     104    exit (0);
     105    return 0;
     106  }