#include <stdlib.h>

	static struct node
	{ int key; struct node *next; };
	static struct node *head, *z, *t;

void stackinit_();
void stackinit();

        void stackinit_() {stackinit();}
        void stackinit() 
	   {
	     head = (struct node *) malloc(sizeof *head);
	     z = (struct node *) malloc(sizeof *z);
	     head->next = z; head->key=0;
	     z->next = z;
	     z->key = 0;
	   }

void push_();
void push();

        void push_(p) int *p; {push(p);}
	void push(p)
           int *p;
	   {
	     int v;
	     v = *p;
	     t = (struct node *) malloc(sizeof *t);	
	     t->key = v; t->next = head->next;	
	     head->next =t;	
	   }

void pop();
void pop_();

        void pop_(x) int *x; {pop(x);}
	void pop(x)
           int *x;
	   {
	     t = head->next; head->next = t->next;
	     *x = t->key;
	     free(t);
	   }

void stackempty();
void stackempty_();

        void stackempty_(i) int *i; {stackempty(i);}
	void stackempty(i)
          int *i;
	  { 
	    *i = 0;
            if(head->next == z) *i = 1;
          }

void stackflush_();
void stackflush();

        void stackflush_() {stackflush();}
        void stackflush()
           {
             free(head);
             free(z);
           }