reformatted/improved some testapps
[libfirm] / ir / be / test / Do.c
index 43b826e..9a6135f 100644 (file)
 typedef struct Node Node;
 
 typedef struct Data {
-    const char *name;
-    const char *addr;
-    int    account1;
-    int    account2;
-    int    account3;
-    Node   *found;
+       const char *name;
+       const char *addr;
+       int    account1;
+       int    account2;
+       int    account3;
+       Node   *found;
 } Data;
 
 struct Node {
-    Data mydata;
-    int  mykey;
-    Node *son1;
-    Node *son2;
-    Node *son3;
-    Node *son4;
+       Data mydata;
+       int  mykey;
+       Node *son1;
+       Node *son2;
+       Node *son3;
+       Node *son4;
 };
 
 static int Node_count;
 
 static Node *new_node(int depth) {
-    Node *res;
-
-    res = (void *)malloc(sizeof(*res));
-    res->mykey = Node_count++;       /* @@@ Want Random number */
-
-    if (depth > 1) {
-       res->son1 = new_node(depth-1);
-       res->son2 = new_node(depth-1);
-       /*res->son3 = new_node(depth-1);
-         res->son4 = new_node(depth-1);*/
-    } else {
-       res->son1 = NULL;
-       res->son2 = NULL;
-       res->son3 = NULL;
-       res->son4 = NULL;
-    }
-    return res;
+       Node *res;
+
+       res = (void *)malloc(sizeof(*res));
+       res->mykey = Node_count++;       /* @@@ Want Random number */
+
+       if (depth > 1) {
+               res->son1 = new_node(depth-1);
+               res->son2 = new_node(depth-1);
+               res->son3 = new_node(depth-1);
+               res->son4 = new_node(depth-1);
+       } else {
+               res->son1 = NULL;
+               res->son2 = NULL;
+               res->son3 = NULL;
+               res->son4 = NULL;
+       }
+       return res;
 }
 
 static int find_max(Node *n) {
-  if (n->son1 == NULL) {
-    return n->mykey;
-  } else {
-    int max = find_max(n->son1);
-    int max2 = find_max(n->son2);
-    if (max2 > max) max = max2;
-    /*max2 = find_max(n->son3);
-    if (max2 > max) max = max2;
-    max2 = find_max(n->son4);
-    if (max2 > max) max = max2;*/
-    return max;
-  }
+       if (n->son1 == NULL) {
+               return n->mykey;
+       } else {
+               int max = find_max(n->son1);
+               int max2 = find_max(n->son2);
+               if (max2 > max) max = max2;
+               /*max2 = find_max(n->son3);
+                 if (max2 > max) max = max2;
+                 max2 = find_max(n->son4);
+                 if (max2 > max) max = max2;*/
+               return max;
+       }
 }
 
 
@@ -71,26 +71,26 @@ static int find_max(Node *n) {
 static Node *root;     /* root of the tree to search */
 
 static void alloc (int depth) {
-    root = new_node(depth);
+       root = new_node(depth);
 }
 static void search (void) {
-    printf(" Max = %d\n", find_max(root));
+       printf(" Max = %d\n", find_max(root));
 }
 
 int main(int argc, char *argv[]) {
-    int depth;
-
-    printf("Do.c:\n");
-    if (argc <= 1) {
-       printf("Usage: Do n\nGive search tree depth!\n");
-       printf("10 is a good value, 12 too much.\n");
-       printf("Continuing with default value 9.\n");
-       depth = 9;
-    } else {
-       depth = atoi(argv[1]);
-    }
-    alloc(depth);
-    search();
-
-    return 0;
+       int depth;
+
+       printf("Do.c:\n");
+       if (argc <= 1) {
+               printf("Usage: Do n\nGive search tree depth!\n");
+               printf("10 is a good value, 12 too much.\n");
+               printf("Continuing with default value 9.\n");
+               depth = 9;
+       } else {
+               depth = atoi(argv[1]);
+       }
+       alloc(depth);
+       search();
+
+       return 0;
 }