aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/call-ar-st.c
blob: d903f0d3f6bff0ff79f934e213c6df230d08b559 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/**************************************************************************
 * TESTS :
 *   -- function arguments that are enumerated types
 *   -- small structure arguments ( <= 64 bits ) 
 *            -- stored in registers
 *            -- stored on the stack
 *   -- large structure arguments ( > 64 bits )
 *            -- stored in registers
 *            -- stored on the stack
 *   -- array arguments
 *   -- caller is a leaf routine :
 *            -- use the call command from within an init routine (i.e.
 *               init_bit_flags, init_bit_flags_combo, init_array_rep)
 *   -- caller doesn't have enough space for all the function arguments :
 *            -- call print_long_arg_list from inside print_small_structs
 ***************************************************************************/

/* Some enumerated types -- used to test that the structureal data type is
 * retrieved for function arguments with typedef data types.
 */
typedef int id_int;

typedef enum { 
	      BLACK,
	      BLUE,
	      BROWN,
	      ECRUE,
	      GOLD,
	      GRAY,
	      GREEN,
	      IVORY,
	      MAUVE,
	      ORANGE,
	      PINK,
	      PURPLE,
	      RED,
	      SILVER,
	      TAN,
	      VIOLET,
	      WHITE,
	      YELLOW} colors;

/* A large structure (> 64 bits) used to test passing large structures as
 * parameters
 */

struct array_rep_info_t {
   int   next_index[10]; 
   int   values[10];
   int   head;
};

/*****************************************************************************
 * Small structures ( <= 64 bits). These are used to test passing small 
 * structures as parameters and test argument size promotion.
 *****************************************************************************/

 /* 64 bits
  */
struct small_rep_info_t {
   int   value;
   int   head;
};

/* 6 bits : really fits in 8 bits and is promoted to 32 bits
 */
struct bit_flags_t {
       unsigned alpha   :1;
       unsigned beta    :1;
       unsigned gamma   :1;
       unsigned delta   :1;
       unsigned epsilon :1;
       unsigned omega   :1;
};

/* 22 bits : really fits in 40 bits and is promoted to 64 bits
 */
struct bit_flags_combo_t {
       unsigned alpha   :1;
       unsigned beta    :1;
       char     ch1;
       unsigned gamma   :1;
       unsigned delta   :1;
       char     ch2;
       unsigned epsilon :1;
       unsigned omega   :1;
};

/* 64 bits
 */
struct one_double_t {
       double double1;
};

/* 64 bits
 */
struct two_floats_t {
       float float1;
       float float2;
};

/* 16 bits : promoted to 32 bits
 */
struct two_char_t {
       char ch1;
       char ch2;
};

/* 24 bits : promoted to 32 bits
 */
struct three_char_t {
       char ch1;
       char ch2;
       char ch3;
};

/* 40 bits : promoted to 64 bits
 */
struct five_char_t {
       char ch1;
       char ch2;
       char ch3;
       char ch4;
       char ch5;
};

/* 40 bits : promoted to 64 bits
 */
struct int_char_combo_t {
       int  int1;
       char ch1;
};

/*****************************************************************
 * PRINT_STUDENT_ID_SHIRT_COLOR : 
 * IN     id_int student       -- enumerated type
 * IN     colors shirt         -- enumerated type
 *****************************************************************/
#ifdef PROTOTYPES
void print_student_id_shirt_color (id_int student, colors shirt)
#else
void print_student_id_shirt_color ( student, shirt ) 
 id_int student;
 colors shirt;
#endif
{

 printf("student id : %d\t", student);
 printf("shirt color : ");
 switch (shirt) {
   case BLACK :  printf("BLACK\n"); 
		 break;
   case BLUE :   printf("BLUE\n");
		 break;
   case BROWN :  printf("BROWN\n");
		 break;
   case ECRUE :  printf("ECRUE\n");
		 break;
   case GOLD :   printf("GOLD\n");
		 break;
   case GRAY :   printf("GRAY\n");
		 break;
   case GREEN :  printf("GREEN\n");
		 break;
   case IVORY :  printf("IVORY\n");
		 break;
   case MAUVE :  printf("MAUVE\n");
		 break;
   case ORANGE : printf("ORANGE\n");
		 break;
   case PINK :   printf("PINK\n");
		 break;
   case PURPLE : printf("PURPLE\n");
		 break;
   case RED :    printf("RED\n");
		 break;
   case SILVER : printf("SILVER\n");
		 break;
   case TAN :    printf("TAN\n");
		 break;
   case VIOLET : printf("VIOLET\n");
		 break;
   case WHITE :  printf("WHITE\n");
		 break;
   case YELLOW : printf("YELLOW\n");
		 break;
 }
}

/*****************************************************************
 * PRINT_CHAR_ARRAY : 
 * IN     char  array_c[]      -- character array 
 *****************************************************************/
#ifdef PROTOTYPES
void print_char_array (char array_c[])
#else
void print_char_array ( array_c ) 
     char    array_c[];
#endif
{

  int index;

  printf("array_c :\n");
  printf("=========\n\n");
  for (index = 0; index < 120; index++) {
      printf("%1c", array_c[index]); 
      if ((index%50) == 0) printf("\n");
  }
  printf("\n\n");
}

/*****************************************************************
 * PRINT_DOUBLE_ARRAY : 
 * IN     double array_d[]      -- array of doubles
 *****************************************************************/
#ifdef PROTOTYPES
void print_double_array (double  array_d[])
#else
void print_double_array (array_d) 
     double  array_d[];
#endif
{

  int index;

  printf("array_d :\n");
  printf("=========\n\n");
  for (index = 0; index < 9; index++) {
      printf("%f  ", array_d[index]); 
      if ((index%8) == 0) printf("\n");
  }
  printf("\n\n");
}

/*****************************************************************
 * PRINT_FLOAT_ARRAY: 
 * IN     float array_f[]      -- array of floats 
 *****************************************************************/
#ifdef PROTOTYPES
void print_float_array (float array_f[])
#else
void print_float_array ( array_f )
     float array_f[];
#endif
{

  int index;

  printf("array_f :\n");
  printf("=========\n\n");
  for (index = 0; index < 15; index++) {
      printf("%f  ", array_f[index]); 
      if ((index%8) == 0) printf("\n");

  }
  printf("\n\n");
}

/*****************************************************************
 * PRINT_INT_ARRAY: 
 * IN     int  array_i[]      -- array of integers 
 *****************************************************************/
#ifdef PROTOTYPES
void print_int_array (int array_i[])
#else
void print_int_array ( array_i )
     int array_i[];
#endif
{

  int index;

  printf("array_i :\n");
  printf("=========\n\n");
  for (index = 0; index < 50; index++) {
      printf("%d  ", array_i[index]); 
      if ((index%8) == 0) printf("\n");
  }
  printf("\n\n");

}

/*****************************************************************
 * PRINT_ALL_ARRAYS: 
 * IN     int  array_i[]      -- array of integers 
 * IN     char array_c[]      -- array of characters 
 * IN     float array_f[]      -- array of floats 
 * IN     double array_d[]      -- array of doubles 
 *****************************************************************/
#ifdef PROTOTYPES
void print_all_arrays(int array_i[], char array_c[], float array_f[], double array_d[])
#else
void print_all_arrays( array_i, array_c, array_f, array_d )
     int array_i[];
     char array_c[];
     float array_f[];
     double array_d[];
#endif
{
  print_int_array(array_i);
  print_char_array(array_c);
  print_float_array(array_f);
  print_double_array(array_d);
}

/*****************************************************************
 * LOOP_COUNT : 
 * A do nothing function. Used to provide a point at which calls can be made.  
 *****************************************************************/
void loop_count () {

     int index;

     for (index=0; index<4; index++);
}

/*****************************************************************
 * COMPUTE_WITH_SMALL_STRUCTS : 
 * A do nothing function. Used to provide a point at which calls can be made.  
 * IN  int seed
 *****************************************************************/
#ifdef PROTOTYPES
void compute_with_small_structs (int seed)
#else
void compute_with_small_structs ( seed ) 
 int seed;
#endif
{

     struct small_rep_info_t array[4];
     int index;

     for (index = 0; index < 4; index++) {
         array[index].value = index*seed;
	 array[index].head = (index+1)*seed;
     }

     for (index = 1; index < 4; index++) {
	 array[index].value = array[index].value + array[index-1].value;
	 array[index].head = array[index].head + array[index-1].head;
     }
}

/*****************************************************************
 * INIT_BIT_FLAGS :
 * Initializes a bit_flags_t structure. Can call this function see
 * the call command behavior when integer arguments do not fit into
 * registers and must be placed on the stack.
 * OUT struct bit_flags_t *bit_flags -- structure to be filled
 * IN  unsigned a  -- 0 or 1 
 * IN  unsigned b  -- 0 or 1 
 * IN  unsigned g  -- 0 or 1 
 * IN  unsigned d  -- 0 or 1 
 * IN  unsigned e  -- 0 or 1 
 * IN  unsigned o  -- 0 or 1 
 *****************************************************************/
#ifdef PROTOTYPES
void init_bit_flags (struct bit_flags_t *bit_flags, unsigned a, unsigned b, unsigned g, unsigned d, unsigned e, unsigned o)
#else
void init_bit_flags ( bit_flags, a, b, g, d, e, o )
struct bit_flags_t *bit_flags;
unsigned a;
unsigned b;
unsigned g;
unsigned d;
unsigned e;
unsigned o; 
#endif
{

   bit_flags->alpha = a;
   bit_flags->beta = b;
   bit_flags->gamma = g;
   bit_flags->delta = d;
   bit_flags->epsilon = e;
   bit_flags->omega = o;
}

/*****************************************************************
 * INIT_BIT_FLAGS_COMBO :
 * Initializes a bit_flags_combo_t structure. Can call this function
 * to see the call command behavior when integer and character arguments
 * do not fit into registers and must be placed on the stack.
 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
 * IN  unsigned a  -- 0 or 1 
 * IN  unsigned b  -- 0 or 1 
 * IN  char     ch1
 * IN  unsigned g  -- 0 or 1 
 * IN  unsigned d  -- 0 or 1 
 * IN  char     ch2
 * IN  unsigned e  -- 0 or 1 
 * IN  unsigned o  -- 0 or 1 
 *****************************************************************/
#ifdef PROTOTYPES
void init_bit_flags_combo (struct bit_flags_combo_t *bit_flags_combo, unsigned a, unsigned b, char ch1, unsigned g, unsigned d, char ch2, unsigned e, unsigned o)
#else
void init_bit_flags_combo ( bit_flags_combo, a, b, ch1, g, d, ch2, e, o )
     struct bit_flags_combo_t *bit_flags_combo;
     unsigned a;
     unsigned b;
     char     ch1;
     unsigned g;
     unsigned d;
     char     ch2;
     unsigned e;
     unsigned o; 
#endif
{

   bit_flags_combo->alpha = a;
   bit_flags_combo->beta = b;
   bit_flags_combo->ch1 = ch1;
   bit_flags_combo->gamma = g;
   bit_flags_combo->delta = d;
   bit_flags_combo->ch2 = ch2;
   bit_flags_combo->epsilon = e;
   bit_flags_combo->omega = o;
}


/*****************************************************************
 * INIT_ONE_DOUBLE : 
 * OUT  struct one_double_t *one_double  -- structure to fill 
 * IN   double init_val
 *****************************************************************/
#ifdef PROTOTYPES
void init_one_double (struct one_double_t *one_double, double init_val)
#else
void init_one_double ( one_double, init_val )
     struct one_double_t *one_double;
     double init_val; 
#endif
{

     one_double->double1  = init_val;
}

/*****************************************************************
 * INIT_TWO_FLOATS : 
 * OUT struct two_floats_t *two_floats -- structure to be filled
 * IN  float init_val1 
 * IN  float init_val2 
 *****************************************************************/
#ifdef PROTOTYPES
void init_two_floats (struct two_floats_t *two_floats, float init_val1, float init_val2)
#else
void init_two_floats ( two_floats, init_val1, init_val2 )
     struct two_floats_t *two_floats; 
     float init_val1;
     float init_val2;
#endif
{
     two_floats->float1 = init_val1;
     two_floats->float2 = init_val2;
}

/*****************************************************************
 * INIT_TWO_CHARS : 
 * OUT struct two_char_t *two_char -- structure to be filled
 * IN  char init_val1 
 * IN  char init_val2 
 *****************************************************************/
#ifdef PROTOTYPES
void init_two_chars (struct two_char_t *two_char, char init_val1, char init_val2)
#else
void init_two_chars ( two_char, init_val1, init_val2 )
     struct two_char_t *two_char;
     char init_val1;
     char init_val2; 
#endif
{

     two_char->ch1 = init_val1;
     two_char->ch2 = init_val2;
}

/*****************************************************************
 * INIT_THREE_CHARS : 
 * OUT struct three_char_t *three_char -- structure to be filled
 * IN  char init_val1 
 * IN  char init_val2 
 * IN  char init_val3 
 *****************************************************************/
#ifdef PROTOTYPES
void init_three_chars (struct three_char_t *three_char, char init_val1, char init_val2, char init_val3)
#else
void init_three_chars ( three_char, init_val1, init_val2, init_val3 )  
     struct three_char_t *three_char; 
     char init_val1;
     char init_val2;
     char init_val3;
#endif
{

     three_char->ch1 = init_val1;
     three_char->ch2 = init_val2;
     three_char->ch3 = init_val3;
}

/*****************************************************************
 * INIT_FIVE_CHARS : 
 * OUT struct five_char_t *five_char -- structure to be filled
 * IN  char init_val1 
 * IN  char init_val2 
 * IN  char init_val3 
 * IN  char init_val4 
 * IN  char init_val5 
 *****************************************************************/
#ifdef PROTOTYPES
void init_five_chars (struct five_char_t *five_char, char init_val1, char init_val2, char init_val3, char init_val4, char init_val5)
#else
void init_five_chars ( five_char, init_val1, init_val2, init_val3,init_val4,init_val5 )
     struct five_char_t *five_char;
     char init_val1;
     char init_val2;
     char init_val3;
     char init_val4;
     char init_val5;
#endif
{
     five_char->ch1 = init_val1;
     five_char->ch2 = init_val2;
     five_char->ch3 = init_val3;
     five_char->ch4 = init_val4;
     five_char->ch5 = init_val5;
}

/*****************************************************************
 * INIT_INT_CHAR_COMBO : 
 * OUT struct int_char_combo_t *combo -- structure to be filled
 * IN  int  init_val1 
 * IN  char init_val2 
 *****************************************************************/
#ifdef PROTOTYPES
void init_int_char_combo (struct int_char_combo_t *combo, int init_val1, char init_val2)
#else
void init_int_char_combo ( combo, init_val1, init_val2 )
     struct int_char_combo_t *combo;
     int init_val1; 
     char init_val2; 
#endif
{

     combo->int1 = init_val1;
     combo->ch1 = init_val2;
}

/*****************************************************************
 * INIT_STRUCT_REP : 
 * OUT struct small_rep_into_t *small_struct -- structure to be filled
 * IN  int  seed 
 *****************************************************************/
#ifdef PROTOTYPES
void init_struct_rep(struct small_rep_info_t *small_struct, int seed)
#else
void init_struct_rep( small_struct, seed )
     struct small_rep_info_t *small_struct;
     int    seed;
#endif
{

      small_struct->value = 2 + (seed*2); 
      small_struct->head = 0; 
}

/*****************************************************************
 * INIT_SMALL_STRUCTS : 
 * Takes all the small structures as input and calls the appropriate
 * initialization routine for each structure
 *****************************************************************/
#ifdef PROTOTYPES
void init_small_structs (
     struct small_rep_info_t  *struct1,
     struct small_rep_info_t  *struct2,
     struct small_rep_info_t  *struct3,
     struct small_rep_info_t  *struct4,
     struct bit_flags_t       *flags,
     struct bit_flags_combo_t *flags_combo,
     struct three_char_t      *three_char,
     struct five_char_t       *five_char,
     struct int_char_combo_t  *int_char_combo,
     struct one_double_t      *d1,
     struct one_double_t      *d2,
     struct one_double_t      *d3,
     struct two_floats_t      *f1,
     struct two_floats_t      *f2,
     struct two_floats_t      *f3)
#else
void init_small_structs (struct1, struct2, struct3,struct4,flags,flags_combo,
three_char, five_char,int_char_combo, d1, d2,d3,f1,f2,f3)
     struct small_rep_info_t  *struct1;
     struct small_rep_info_t  *struct2;
     struct small_rep_info_t  *struct3;
     struct small_rep_info_t  *struct4;
     struct bit_flags_t       *flags;
     struct bit_flags_combo_t *flags_combo;
     struct three_char_t      *three_char;
     struct five_char_t       *five_char;
     struct int_char_combo_t  *int_char_combo;
     struct one_double_t      *d1;
     struct one_double_t      *d2;
     struct one_double_t      *d3;
     struct two_floats_t      *f1;
     struct two_floats_t      *f2;
     struct two_floats_t      *f3;
#endif
{

     init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, 
		           (unsigned)0, (unsigned)1, (unsigned)0 ); 
     init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
				       (unsigned)1, (unsigned)0, 'n',
                    		       (unsigned)1, (unsigned)0 ); 
     init_three_chars(three_char, 'a', 'b', 'c');
     init_five_chars(five_char, 'l', 'm', 'n', 'o', 'p');
     init_int_char_combo(int_char_combo, 123, 'z');
     init_struct_rep(struct1, 2);
     init_struct_rep(struct2, 4);
     init_struct_rep(struct3, 5);
     init_struct_rep(struct4, 6);
     init_one_double ( d1, 10.5); 
     init_one_double ( d2, -3.375); 
     init_one_double ( d3, 675.09375); 
     init_two_floats ( f1, 45.234, 43.6); 
     init_two_floats ( f2, 78.01, 122.10); 
     init_two_floats ( f3, -1232.345, -199.21); 
}

/*****************************************************************
 * PRINT_TEN_DOUBLES : 
 * ?????????????????????????????
 ****************************************************************/
#ifdef PROTOTYPES
void print_ten_doubles (
     double d1,
     double d2,
     double d3,
     double d4,
     double d5,
     double d6,
     double d7,
     double d8,
     double d9,
     double d10)
#else
void print_ten_doubles ( d1, d2, d3, d4, d5, d6, d7, d8, d9, d10 )
     double d1;
     double d2;
     double d3;
     double d4;
     double d5;
     double d6;
     double d7;
     double d8;
     double d9;
     double d10; 
#endif
{

  printf("Two Doubles : %f\t%f\n", d1, d2);
  printf("Two Doubles : %f\t%f\n", d3, d4);
  printf("Two Doubles : %f\t%f\n", d5, d6);
  printf("Two Doubles : %f\t%f\n", d7, d8);
  printf("Two Doubles : %f\t%f\n", d9, d10);
}

/*****************************************************************
 * PRINT_BIT_FLAGS : 
 * IN struct bit_flags_t bit_flags 
 ****************************************************************/
#ifdef PROTOTYPES
void print_bit_flags (struct bit_flags_t bit_flags)
#else
void print_bit_flags ( bit_flags )
struct bit_flags_t bit_flags;
#endif
{

     if (bit_flags.alpha) printf("alpha\n");
     if (bit_flags.beta) printf("beta\n");
     if (bit_flags.gamma) printf("gamma\n");
     if (bit_flags.delta) printf("delta\n");
     if (bit_flags.epsilon) printf("epsilon\n");
     if (bit_flags.omega) printf("omega\n");
}

/*****************************************************************
 * PRINT_BIT_FLAGS_COMBO : 
 * IN struct bit_flags_combo_t bit_flags_combo 
 ****************************************************************/
#ifdef PROTOTYPES
void print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo)
#else
void print_bit_flags_combo ( bit_flags_combo )
     struct bit_flags_combo_t bit_flags_combo;
#endif
{

     if (bit_flags_combo.alpha) printf("alpha\n");
     if (bit_flags_combo.beta) printf("beta\n");
     if (bit_flags_combo.gamma) printf("gamma\n");
     if (bit_flags_combo.delta) printf("delta\n");
     if (bit_flags_combo.epsilon) printf("epsilon\n");
     if (bit_flags_combo.omega) printf("omega\n");
     printf("ch1: %c\tch2: %c\n", bit_flags_combo.ch1, bit_flags_combo.ch2);
}

/*****************************************************************
 * PRINT_ONE_DOUBLE : 
 * IN struct one_double_t one_double 
 ****************************************************************/
#ifdef PROTOTYPES
void print_one_double (struct one_double_t one_double)
#else
void print_one_double ( one_double )
struct one_double_t one_double;
#endif
{

     printf("Contents of one_double_t: \n\n");
     printf("%f\n", one_double.double1);
}

/*****************************************************************
 * PRINT_TWO_FLOATS : 
 * IN struct two_floats_t two_floats 
 ****************************************************************/
#ifdef PROTOTYPES
void print_two_floats (struct two_floats_t two_floats)
#else
void print_two_floats ( two_floats )
struct two_floats_t two_floats; 
#endif
{

     printf("Contents of two_floats_t: \n\n");
     printf("%f\t%f\n", two_floats.float1, two_floats.float2);
}

/*****************************************************************
 * PRINT_TWO_CHARS : 
 * IN struct two_char_t two_char
 ****************************************************************/
#ifdef PROTOTYPES
void print_two_chars (struct two_char_t two_char)
#else
void print_two_chars ( two_char )
struct two_char_t two_char; 
#endif
{

     printf("Contents of two_char_t: \n\n");
     printf("%c\t%c\n", two_char.ch1, two_char.ch2);
}

/*****************************************************************
 * PRINT_THREE_CHARS : 
 * IN struct three_char_t three_char
 ****************************************************************/
#ifdef PROTOTYPES
void print_three_chars (struct three_char_t three_char)
#else
void print_three_chars ( three_char )
struct three_char_t three_char;
#endif
{

     printf("Contents of three_char_t: \n\n");
     printf("%c\t%c\t%c\n", three_char.ch1, three_char.ch2, three_char.ch3);
}

/*****************************************************************
 * PRINT_FIVE_CHARS : 
 * IN struct five_char_t five_char
 ****************************************************************/
#ifdef PROTOTYPES
void print_five_chars (struct five_char_t five_char)
#else
void print_five_chars ( five_char ) 
struct five_char_t five_char; 
#endif
{

     printf("Contents of five_char_t: \n\n");
     printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2, 
				    five_char.ch3, five_char.ch4, 
				    five_char.ch5);
}

/*****************************************************************
 * PRINT_INT_CHAR_COMBO : 
 * IN struct int_char_combo_t int_char_combo
 ****************************************************************/
#ifdef PROTOTYPES
void print_int_char_combo (struct int_char_combo_t int_char_combo)
#else
void print_int_char_combo ( int_char_combo )
struct int_char_combo_t int_char_combo;
#endif
{

     printf("Contents of int_char_combo_t: \n\n");
     printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1);
}     

/*****************************************************************
 * PRINT_STRUCT_REP : 
 * The last parameter must go onto the stack rather than into a register.
 * This is a good function to call to test small structures.
 * IN struct small_rep_info_t  struct1
 * IN struct small_rep_info_t  struct2
 * IN struct small_rep_info_t  struct3
 ****************************************************************/
#ifdef PROTOTYPES
void print_struct_rep(
     struct small_rep_info_t struct1,
     struct small_rep_info_t struct2,
     struct small_rep_info_t struct3)
#else
void print_struct_rep( struct1, struct2, struct3)
     struct small_rep_info_t struct1;
     struct small_rep_info_t struct2;
     struct small_rep_info_t struct3;
#endif
{


  printf("Contents of struct1: \n\n");
  printf("%10d%10d\n", struct1.value, struct1.head); 
  printf("Contents of struct2: \n\n");
  printf("%10d%10d\n", struct2.value, struct2.head); 
  printf("Contents of struct3: \n\n");
  printf("%10d%10d\n", struct3.value, struct3.head); 

}

/*****************************************************************
 * SUM_STRUCT_PRINT : 
 * The last two parameters must go onto the stack rather than into a register.
 * This is a good function to call to test small structures.
 * IN struct small_rep_info_t  struct1
 * IN struct small_rep_info_t  struct2
 * IN struct small_rep_info_t  struct3
 * IN struct small_rep_info_t  struct4
 ****************************************************************/
#ifdef PROTOTYPES
void sum_struct_print (
     int seed,
     struct small_rep_info_t struct1,
     struct small_rep_info_t struct2, 
     struct small_rep_info_t struct3,
     struct small_rep_info_t struct4)
#else
void sum_struct_print ( seed, struct1, struct2, struct3, struct4) 
     int seed;
     struct small_rep_info_t struct1;
     struct small_rep_info_t struct2; 
     struct small_rep_info_t struct3; 
     struct small_rep_info_t struct4; 
#endif
{
     int sum;

     printf("Sum of the 4 struct values and seed : \n\n");
     sum = seed + struct1.value + struct2.value + struct3.value + struct4.value;
     printf("%10d\n", sum);
}

/*****************************************************************
 * PRINT_SMALL_STRUCTS : 
 * This is a good function to call to test small structures.
 * All of the small structures of odd sizes (40 bits, 8bits, etc.)
 * are pushed onto the stack.
 ****************************************************************/
#ifdef PROTOTYPES
void print_small_structs (
     struct small_rep_info_t  struct1,
     struct small_rep_info_t  struct2,
     struct small_rep_info_t  struct3,
     struct small_rep_info_t  struct4,
     struct bit_flags_t       flags,
     struct bit_flags_combo_t flags_combo,
     struct three_char_t      three_char,
     struct five_char_t       five_char,
     struct int_char_combo_t  int_char_combo,
     struct one_double_t      d1,
     struct one_double_t      d2,
     struct one_double_t      d3,
     struct two_floats_t      f1,
     struct two_floats_t      f2,
     struct two_floats_t      f3)
#else
void print_small_structs ( struct1, struct2, struct3,  struct4, flags, 
flags_combo, three_char, five_char, int_char_combo, d1, d2,d3,f1,f2,f3)
     struct small_rep_info_t  struct1;
     struct small_rep_info_t  struct2;
     struct small_rep_info_t  struct3;
     struct small_rep_info_t  struct4;
     struct bit_flags_t       flags;
     struct bit_flags_combo_t flags_combo;
     struct three_char_t      three_char;
     struct five_char_t       five_char;
     struct int_char_combo_t  int_char_combo;
     struct one_double_t      d1;
     struct one_double_t      d2;
     struct one_double_t      d3;
     struct two_floats_t      f1;
     struct two_floats_t      f2;
     struct two_floats_t      f3;
#endif
{
   print_bit_flags(flags);
   print_bit_flags_combo(flags_combo);
   print_three_chars(three_char);
   print_five_chars(five_char);
   print_int_char_combo(int_char_combo);
   sum_struct_print(10, struct1, struct2, struct3, struct4);
   print_struct_rep(struct1, struct2, struct3);
   print_one_double(d1);
   print_one_double(d2);
   print_one_double(d3);
   print_two_floats(f1);
   print_two_floats(f2);
   print_two_floats(f3);
}

/*****************************************************************
 * PRINT_LONG_ARG_LIST : 
 * This is a good function to call to test small structures.
 * The first two parameters ( the doubles ) go into registers. The
 * remaining arguments are pushed onto the stack. Depending on where
 * print_long_arg_list is called from, the size of the argument list 
 * may force more space to be pushed onto the stack as part of the callers
 * frame.
 ****************************************************************/
#ifdef PROTOTYPES
void print_long_arg_list (
     double a,
     double b,
     int c,
     int d,
     int e,
     int f,
     struct small_rep_info_t  struct1,
     struct small_rep_info_t  struct2,
     struct small_rep_info_t  struct3,
     struct small_rep_info_t  struct4,
     struct bit_flags_t       flags,
     struct bit_flags_combo_t flags_combo,
     struct three_char_t      three_char,
     struct five_char_t       five_char,
     struct int_char_combo_t  int_char_combo,
     struct one_double_t      d1,
     struct one_double_t      d2,
     struct one_double_t      d3,
     struct two_floats_t      f1,
     struct two_floats_t      f2,
     struct two_floats_t      f3)
#else
void print_long_arg_list ( a, b, c, d, e, f, struct1, struct2, struct3, 
struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1,d2,d3,
f1, f2, f3 )
     double a;
     double b;
     int c;
     int d;
     int e;
     int f;
     struct small_rep_info_t  struct1;
     struct small_rep_info_t  struct2;
     struct small_rep_info_t  struct3;
     struct small_rep_info_t  struct4;
     struct bit_flags_t       flags;
     struct bit_flags_combo_t flags_combo;
     struct three_char_t      three_char;
     struct five_char_t       five_char;
     struct int_char_combo_t  int_char_combo;
     struct one_double_t      d1;
     struct one_double_t      d2;
     struct one_double_t      d3;
     struct two_floats_t      f1;
     struct two_floats_t      f2;
     struct two_floats_t      f3;
#endif
{
    printf("double : %f\n", a);
    printf("double : %f\n", b);
    printf("int : %d\n", c);
    printf("int : %d\n", d);
    printf("int : %d\n", e);
    printf("int : %d\n", f);
    print_small_structs( struct1, struct2, struct3, struct4, flags, flags_combo,
			 three_char, five_char, int_char_combo, d1, d2, d3, 
			 f1, f2, f3);
}


#ifdef PROTOTYPES
void print_one_large_struct (struct array_rep_info_t linked_list1)
#else
void print_one_large_struct( linked_list1 )
     struct array_rep_info_t linked_list1;
#endif
{

 /* printf("Contents of linked list1: \n\n");
  printf("Element Value | Index of Next Element\n");
  printf("-------------------------------------\n");
  printf("              |                      \n");*/
  /*for (index = 0; index < 10; index++) {*/

      printf("%10d%10d\n", linked_list1.values[0], 
			   linked_list1.next_index[0]); 
  /*}*/
}

/*****************************************************************
 * PRINT_ARRAY_REP : 
 * The three structure parameters should fit into registers. 
 * IN struct array_rep_info_t linked_list1
 * IN struct array_rep_info_t linked_list2
 * IN struct array_rep_info_t linked_list3
 ****************************************************************/
#ifdef PROTOTYPES
void print_array_rep(
     struct array_rep_info_t linked_list1,
     struct array_rep_info_t linked_list2,
     struct array_rep_info_t linked_list3)
#else
void print_array_rep( linked_list1, linked_list2, linked_list3 )
     struct array_rep_info_t linked_list1;
     struct array_rep_info_t linked_list2;
     struct array_rep_info_t linked_list3;
#endif
{

  int index;

  printf("Contents of linked list1: \n\n");
  printf("Element Value | Index of Next Element\n");
  printf("-------------------------------------\n");
  printf("              |                      \n");
  for (index = 0; index < 10; index++) {

      printf("%10d%10d\n", linked_list1.values[index], 
			   linked_list1.next_index[index]); 
  }

  printf("Contents of linked list2: \n\n");
  printf("Element Value | Index of Next Element\n");
  printf("-------------------------------------\n");
  printf("              |                      \n");
  for (index = 0; index < 10; index++) {

      printf("%10d%10d\n", linked_list2.values[index], 
			   linked_list2.next_index[index]); 
  }

  printf("Contents of linked list3: \n\n");
  printf("Element Value | Index of Next Element\n");
  printf("-------------------------------------\n");
  printf("              |                      \n");
  for (index = 0; index < 10; index++) {

      printf("%10d%10d\n", linked_list3.values[index], 
			   linked_list3.next_index[index]); 
  }

}

/*****************************************************************
 * SUM_ARRAY_PRINT : 
 * The last structure parameter must be pushed onto the stack 
 * IN int    seed
 * IN struct array_rep_info_t linked_list1
 * IN struct array_rep_info_t linked_list2
 * IN struct array_rep_info_t linked_list3
 * IN struct array_rep_info_t linked_list4
 ****************************************************************/
#ifdef PROTOTYPES
void sum_array_print (
     int seed,
     struct array_rep_info_t linked_list1,
     struct array_rep_info_t linked_list2,
     struct array_rep_info_t linked_list3,
     struct array_rep_info_t linked_list4)
#else
void sum_array_print ( seed, linked_list1, linked_list2, linked_list3,linked_list4)
     int seed;
     struct array_rep_info_t linked_list1;
     struct array_rep_info_t linked_list2;
     struct array_rep_info_t linked_list3;
     struct array_rep_info_t linked_list4;
#endif
{
     int index;
     int sum;

     printf("Sum of 4 arrays, by element (add in seed as well): \n\n");
     printf("Seed: %d\n", seed);
     printf("Element Index | Sum \n");
     printf("-------------------------\n");
     printf("              |          \n");

     for (index = 0; index < 10; index++) {

         sum = seed + linked_list1.values[index] + linked_list2.values[index] +
	       linked_list3.values[index] + linked_list4.values[index];
         printf("%10d%10d\n", index, sum);
     }
}

/*****************************************************************
 * INIT_ARRAY_REP : 
 * IN struct array_rep_info_t *linked_list
 * IN int    seed
 ****************************************************************/
#ifdef PROTOTYPES
void init_array_rep(
     struct array_rep_info_t *linked_list,
     int    seed)
#else
void init_array_rep( linked_list, seed )
     struct array_rep_info_t *linked_list;
     int    seed;
#endif
{

  int index;

  for (index = 0; index < 10; index++) {

      linked_list->values[index] = (2*index) + (seed*2); 
      linked_list->next_index[index] = index + 1;
  }
  linked_list->head = 0; 
}


int main ()  {

  /* variables for array and enumerated type testing
   */
  static char     char_array[121];
  static double   double_array[9];
  static float    float_array[15];
  static int      integer_array[50]; 
  static int      index;
  static id_int   student_id = 23;
  static colors   my_shirt = YELLOW;
    
  /* variables for large structure testing
   */
  static int number = 10;
  static struct array_rep_info_t *list1;
  static struct array_rep_info_t *list2;
  static struct array_rep_info_t *list3;
  static struct array_rep_info_t *list4;

  /* variables for testing a very long argument list
   */
   static double                    a;
   static double                    b;
   static int                       c;
   static int                       d;
   static int                       e;
   static int                       f;

  /* variables for testing a small structures and a very long argument list
   */
   static struct small_rep_info_t  *struct1;
   static struct small_rep_info_t  *struct2;
   static struct small_rep_info_t  *struct3;
   static struct small_rep_info_t  *struct4;
   static struct bit_flags_t       *flags;
   static struct bit_flags_combo_t *flags_combo;
   static struct three_char_t      *three_char;
   static struct five_char_t       *five_char;
   static struct int_char_combo_t  *int_char_combo;
   static struct one_double_t      *d1;
   static struct one_double_t      *d2;
   static struct one_double_t      *d3;
   static struct two_floats_t      *f1;
   static struct two_floats_t      *f2;
   static struct two_floats_t      *f3;

  /* Initialize arrays
   */
  for (index = 0; index < 120; index++) {
      if ((index%2) == 0) char_array[index] = 'Z';
	 else char_array[index] = 'a';
  }
  char_array[120] = '\0';

  for (index = 0; index < 9; index++) {
      double_array[index] = index*23.4567;
  }

  for (index = 0; index < 15; index++) {
      float_array[index] = index/7.02;
  }

  for (index = 0; index < 50; index++) {
      integer_array[index] = -index;
  }

  /* Print arrays
   */
  print_char_array(char_array);
  print_double_array(double_array);
  print_float_array(float_array);
  print_student_id_shirt_color(student_id, my_shirt); 
  print_int_array(integer_array);
  print_all_arrays(integer_array, char_array, float_array, double_array);

  /* Allocate space for large structures 
   */
  list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
  list2 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
  list3 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
  list4 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));

  /* Initialize large structures 
   */
  init_array_rep(list1, 2);
  init_array_rep(list2, 4);
  init_array_rep(list3, 5);
  init_array_rep(list4, 10);
  printf("HELLO WORLD\n");
  printf("BYE BYE FOR NOW\n");
  printf("VERY GREEN GRASS\n");

  /* Print large structures 
   */
  sum_array_print(10, *list1, *list2, *list3, *list4);
  print_array_rep(*list1, *list2, *list3);
  print_one_large_struct(*list1);

  /* Allocate space for small structures 
   */
  struct1     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
  struct2     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
  struct3     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
  struct4     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
  flags       = (struct bit_flags_t *)malloc(sizeof(struct bit_flags_t));
  flags_combo = (struct bit_flags_combo_t *)malloc(sizeof(struct bit_flags_combo_t));
  three_char  = (struct three_char_t *)malloc(sizeof(struct three_char_t));
  five_char   = (struct five_char_t *)malloc(sizeof(struct five_char_t));
  int_char_combo = (struct int_char_combo_t *)malloc(sizeof(struct int_char_combo_t));

  d1 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
  d2 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
  d3 = (struct one_double_t *)malloc(sizeof(struct one_double_t));

  f1 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
  f2 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
  f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));

  /* Initialize small structures 
   */
  init_small_structs ( struct1, struct2, struct3, struct4, flags, 
		       flags_combo, three_char, five_char, int_char_combo,
		       d1, d2, d3, f1, f2, f3);

  /* Print small structures 
   */
  print_small_structs ( *struct1, *struct2, *struct3, *struct4, *flags, 
			*flags_combo, *three_char, *five_char, *int_char_combo,
			*d1, *d2, *d3, *f1, *f2, *f3);

  /* Print a very long arg list 
   */
  a = 22.25;
  b = 33.375;
  c = 0;
  d = -25;
  e = 100;
  f = 2345;

  print_long_arg_list ( a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, 
			*flags, *flags_combo, *three_char, *five_char, *int_char_combo,
			*d1, *d2, *d3, *f1, *f2, *f3);

  /* Initialize small structures 
   */
  init_one_double ( d1, 1.11111); 
  init_one_double ( d2, -345.34); 
  init_one_double ( d3, 546464.2); 
  init_two_floats ( f1, 0.234, 453.1); 
  init_two_floats ( f2, 78.345, 23.09); 
  init_two_floats ( f3, -2.345, 1.0); 
  init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, 
		 (unsigned)0, (unsigned)1, (unsigned)0 ); 
  init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
				     (unsigned)1, (unsigned)0, 'n',
				     (unsigned)1, (unsigned)0 ); 
  init_three_chars(three_char, 'x', 'y', 'z');
  init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o');
  init_int_char_combo(int_char_combo, 13, '!');
  init_struct_rep(struct1, 10);
  init_struct_rep(struct2, 20);
  init_struct_rep(struct3, 30);
  init_struct_rep(struct4, 40);

  compute_with_small_structs(35);
  loop_count();
  printf("HELLO WORLD\n");
  printf("BYE BYE FOR NOW\n");
  printf("VERY GREEN GRASS\n");

  /* Print small structures 
   */
  print_one_double(*d1);
  print_one_double(*d2);
  print_one_double(*d3);
  print_two_floats(*f1);
  print_two_floats(*f2);
  print_two_floats(*f3);
  print_bit_flags(*flags);
  print_bit_flags_combo(*flags_combo);
  print_three_chars(*three_char);
  print_five_chars(*five_char);
  print_int_char_combo(*int_char_combo);
  sum_struct_print(10, *struct1, *struct2, *struct3, *struct4);
  print_struct_rep(*struct1, *struct2, *struct3);

  return 0;
}