//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) {
for (cdLst *p = cdl->prox; p != cdl; p = p->prox) {
}
}
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);
}
Ly9BcnF1aXZvIGNpcmNEdXBsTGlzdC5jCiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RkbGliLmg+CiAgICAKdHlwZWRlZiBzdHJ1Y3QgY2RMc3R7CglpbnQgaW5mbzsKCXN0cnVjdCBjZExzdCogYW50OwoJc3RydWN0IGNkTHN0KiBwcm94Owp9IGNkTHN0OwoKLypJbnNlcnQgYSBub2RlIHRvIHRoZSBmcm9udCBvZiB0aGUgY2lyY3VsYXIgbGlzdCovCmNkTHN0KiBpbnNlcnRfZnJvbnQoY2RMc3QqIGNkbCwgaW50IGluZm8pIHsKCWNkTHN0KiBwID0gKGNkTHN0KiltYWxsb2Moc2l6ZW9mKGNkTHN0KSk7CglwLT5pbmZvID0gaW5mbzsKCWlmIChjZGwgIT0gTlVMTCkgewoJICAgIHAtPnByb3ggPSBjZGw7CgkgICAgcC0+YW50ID0gY2RsLT5hbnQ7CgkgICAgcC0+YW50LT5wcm94ID0gcDsKCSAgICBwLT5wcm94LT5hbnQgPSBwOwoJfSBlbHNlIHsKCQlwLT5wcm94ID0gcDsKCQlwLT5hbnQgPSBwOwoJfQoJY2RsID0gcDsKCXJldHVybi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