//Arquivo circDuplList.c
#include <stdio.h>
#include <stdlib.h>
    
typedef struct cdLst{
	int info;
	struct cdLst* ant;
	struct cdLst* prox;
} cdLst;

/*Insert a node to the front of the circular list*/
cdLst* insert_front(cdLst* cdl, int info) {
	cdLst* p = (cdLst*)malloc(sizeof(cdLst));
	p->info = info;
	if (cdl != NULL) {
	    p->prox = cdl;
	    p->ant = cdl->ant;
	    p->ant->prox = p;
	    p->prox->ant = p;
	} else {
		p->prox = p;
		p->ant = p;
	}
	cdl = p;
	return p;
}

/*Print the list*/
void cdl_print(cdLst* cdl) {
    printf("\n%d",cdl->info);
    for (cdLst *p = cdl->prox; p != cdl; p = p->prox) {
        printf("\n%d",p->info);
    }
}

int main(void){
    cdLst* l = NULL;
    l = insert_front(l,3);
    l = insert_front(l,2);
    l = insert_front(l,3);
    l = insert_front(l,8);
    l = insert_front(l,65);
    l = insert_front(l,3);
    cdl_print(l);
}