#include<stdio.h>
#include<stdlib.h>
struct dll{
int data;
struct dll* previous;
struct dll* next;
};
struct dll* insertAtBeginning(int a, struct dll* head){
if(head == NULL){
head->data = a;
head->previous = NULL;
head->next = NULL;
return head;
}
else{
struct dll *first;
first = (struct dll*) malloc( sizeof(struct dll));
first->data = a;
first->next = head;
head->previous = first;
first->previous = NULL;
head = first;
return head;
}
}
void display_from_first(struct dll* head){
struct dll *temp;
temp = head;
printf("\nThe linked list contains: ");
while(temp != NULL) {
printf("%d------>",temp->data);
temp = temp->next;
}
printf("NULL\n");
free(temp);
}
int main(){
int i = 0;
struct dll *head1, *tail1;
head1 = (struct dll*) malloc( sizeof(struct dll));
head1->next = NULL;
head1->previous = NULL;
display_from_first(head1);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CgpzdHJ1Y3QgZGxsewogICAgaW50IGRhdGE7CiAgICBzdHJ1Y3QgZGxsKiBwcmV2aW91czsKICAgIHN0cnVjdCBkbGwqIG5leHQ7Cn07CgoKc3RydWN0IGRsbCogaW5zZXJ0QXRCZWdpbm5pbmcoaW50IGEsIHN0cnVjdCBkbGwqIGhlYWQpewoKICAgIGlmKGhlYWQgPT0gTlVMTCl7CiAgICAgICAgaGVhZC0+ZGF0YSA9IGE7CiAgICAgICAgaGVhZC0+cHJldmlvdXMgPSBOVUxMOwogICAgICAgIGhlYWQtPm5leHQgPSBOVUxMOwogICAgICAgIHJldHVybiBoZWFkOwogICAgfQogICAgZWxzZXsKICAgICAgICBzdHJ1Y3QgZGxsICpmaXJzdDsKICAgICAgICBmaXJzdCA9IChzdHJ1Y3QgZGxsKikgbWFsbG9jKCBzaXplb2Yoc3RydWN0IGRsbCkpOwogICAgICAgIGZpcnN0LT5kYXRhID0gYTsKICAgICAgICBmaXJzdC0+bmV4dCA9IGhlYWQ7CiAgICAgICAgaGVhZC0+cHJldmlvdXMgPSBmaXJzdDsKICAgICAgICBmaXJzdC0+cHJldmlvdXMgPSB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