Language: C

#include <stdint.h>
#include <stdlib.h>

#define UTIL_PRINT_ARRAY(arr, size)                                                                                                        \
  do {                                                                                                                                     \
    int32_t _i;                                                                                                                            \
    for (_i = 0; _i < (size); _i++) {                                                                                                      \
      if (_i != 0) printf(" ");                                                                                                            \
      printf("%d", arr[_i]);                                                                                                               \
    }                                                                                                                                      \
    printf("\n");                                                                                                                          \
  } while (0)

struct double_linked_list_tag {
  double_linked_list_t *prev;
  double_linked_list_t *next;
  int32_t data;
};

tyepdef struct double_linked_list_tag double_linked_list_t;

double_linked_list_t *double_linked_list_create(void)
{
  double_linked_list_t *l = (double_linked_list_t *)malloc(sizeof(double_linked_list_t));

  if (l == NULL) {
    perror("memory is full\n");
    exit(1);
  }

  l->prev = l;
  l->next = l;

  return l;
}

void double_linked_list_destroy(double_linked_list_t *const l)
{
  if (l == NULL) return;

  double_linked_list_t *list = l->next;

  while (l != list) {
    double_linked_list_t *next = list->next;
    free(list);
    list = next;
  }

  free(l);

  return;
}

bool double_linked_list_insert(double_linked_list_t *const l, int32_t data)
{
  if (l == NULL) return false;

  double_linked_list_t *new = (double_linked_list_t *)malloc(sizeof(double_linked_list_t));

  if (new == NULL) {
    perror("memory is full\n");
    exit(1);
  }

  l->next->prev = new;
  new->next = l->next;
  l->next = new;
  new->prev = l;
  new->data = data;

  return true;
}

static bool check_arguments(double_linked_list_t *const l, int32_t buf[], const size_t size)
{
  if (l == NULL) return false;

  if (size < 1) return false;

  if (buf == NULL) return false;

  return true;
}

size_t double_linked_list_to_array(double_linked_list_t *const l, int32_t buf[], const size_t size)
{
  if (!check_arguments(l, buf, size)) {
    return 0;
  }

  size_t count = 0;

  double_linked_list_t *list = l->next;
  while (list != l) {
    buf[count] = list->data;
    count++;
    if (size <= count) break;
    list = list->next;
  }

  return count;
}

bool double_linked_list_delete(double_linked_list_t *const l, int32_t data)
{
  if (l == NULL) return false;

  double_linked_list_t *list = l->next;

  while (list != l) {
    if (list->data == data) {
      double_linked_list_t *next = list->next;
      double_linked_list_t *prev = list->prev;
      next->prev = list->prev;
      prev->next = list->next;
      free(list);
      return true;
    }
    list = list->next;
  }

  return false;
}

bool double_linked_list_delete_first(double_linked_list_t *const l)
{
  if (l == NULL) return false;

  if (l == l->next) return false;

  double_linked_list_t *head = l->next;
  double_linked_list_t *new_head = head->next;

  l->next = new_head;
  new_head->prev = l;

  free(head);

  return true;
}

bool double_linked_list_delete_last(double_linked_list_t *const l)
{
  if (l == NULL) return false;

  if (l == l->prev) return false;

  double_linked_list_t *last = l->prev;
  double_linked_list_t *new_last = last->prev;

  new_last->next = l;
  l->prev = new_last;

  return true;
}

#if !defined(TEST)
#include <stdio.h>
#include <string.h>

#include "util.h"

int32_t main(void)
{
  double_linked_list_t *l = double_linked_list_create();

  int32_t num = 0;
  scanf("%d", &num);

  int32_t i;
  for (i = 0; i < num; i++) {
    char buf[128];
    int32_t val;
    int32_t ret = scanf("%s %d", buf, &val);
    if (ret == 2) {
      switch (buf[0]) {
      case 'i':
        double_linked_list_insert(l, val);
        break;
      case 'd':
        double_linked_list_delete(l, val);
        break;
      }
    } else {
      if (!strcmp(buf, "deleteFirst")) {
        double_linked_list_delete_first(l);
      } else {
        double_linked_list_delete_last(l);
      }
    }
  }

  int32_t result[1024];
  size_t size = double_linked_list_to_array(l, result, UTIL_ARRAY_SIZE(result));
  UTIL_PRINT_ARRAY(result, size);

  double_linked_list_destroy(l);

  return 0;
}
#endif

Compiler output:
main.c:15:3: error: unknown type name 'double_linked_list_t'
   15 |   double_linked_list_t *prev;
      |   ^~~~~~~~~~~~~~~~~~~~
main.c:16:3: error: unknown type name 'double_linked_list_t'
   16 |   double_linked_list_t *next;
      |   ^~~~~~~~~~~~~~~~~~~~
main.c:20:8: error: expected ';' before 'struct'
   20 | tyepdef struct double_linked_list_tag double_linked_list_t;
      |        ^~~~~~~
      |        ;
main.c:22:1: error: unknown type name 'double_linked_list_t'
   22 | double_linked_list_t *double_linked_list_create(void)
      | ^~~~~~~~~~~~~~~~~~~~
main.c: In function 'double_linked_list_create':
main.c:24:25: error: 'l' undeclared (first use in this function)
   24 |   double_linked_list_t *l = (double_linked_list_t *)malloc(sizeof(double_linked_list_t));
      |                         ^
main.c:24:25: note: each undeclared identifier is reported only once for each function it appears in
main.c:24:52: error: expected expression before ')' token
   24 |   double_linked_list_t *l = (double_linked_list_t *)malloc(sizeof(double_linked_list_t));
      |                                                    ^
main.c:27:5: error: implicit declaration of function 'perror' [-Wimplicit-function-declaration]
   27 |     perror("memory is full\n");
      |     ^~~~~~
main.c: At top level:
main.c:37:33: error: expected declaration specifiers or '...' before 'double_linked_list_t'
   37 | void double_linked_list_destroy(double_linked_list_t *const l)
      |                                 ^~~~~~~~~~~~~~~~~~~~
main.c:54:1: error: unknown type name 'bool'
   54 | bool double_linked_list_insert(double_linked_list_t *const l, int32_t data)
      | ^~~~
main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include <stdlib.h>
  +++ |+#include <stdbool.h>
    3 | 
main.c:54:32: error: expected declaration specifiers or '...' before 'double_linked_list_t'
   54 | bool double_linked_list_insert(double_linked_list_t *const l, int32_t data)
      |                                ^~~~~~~~~~~~~~~~~~~~
main.c:74:8: error: unknown type name 'bool'
   74 | static bool check_arguments(double_linked_list_t *const l, int32_t buf[], const size_t size)
      |        ^~~~
main.c:74:8: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:74:29: error: expected declaration specifiers or '...' before 'double_linked_list_t'
   74 | static bool check_arguments(double_linked_list_t *const l, int32_t buf[], const size_t size)
      |                             ^~~~~~~~~~~~~~~~~~~~
main.c:85:36: error: expected declaration specifiers or '...' before 'double_linked_list_t'
   85 | size_t double_linked_list_to_array(double_linked_list_t *const l, int32_t buf[], const size_t size)
      |                                    ^~~~~~~~~~~~~~~~~~~~
main.c:104:1: error: unknown type name 'bool'
  104 | bool double_linked_list_delete(double_linked_list_t *const l, int32_t data)
      | ^~~~
main.c:104:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:104:32: error: expected declaration specifiers or '...' before 'double_linked_list_t'
  104 | bool double_linked_list_delete(double_linked_list_t *const l, int32_t data)
      |                                ^~~~~~~~~~~~~~~~~~~~
main.c:125:1: error: unknown type name 'bool'
  125 | bool double_linked_list_delete_first(double_linked_list_t *const l)
      | ^~~~
main.c:125:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:125:38: error: expected declaration specifiers or '...' before 'double_linked_list_t'
  125 | bool double_linked_list_delete_first(double_linked_list_t *const l)
      |                                      ^~~~~~~~~~~~~~~~~~~~
main.c:142:1: error: unknown type name 'bool'
  142 | bool double_linked_list_delete_last(double_linked_list_t *const l)
      | ^~~~
main.c:142:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:142:37: error: expected declaration specifiers or '...' before 'double_linked_list_t'
  142 | bool double_linked_list_delete_last(double_linked_list_t *const l)
      |                                     ^~~~~~~~~~~~~~~~~~~~
main.c:161:10: fatal error: util.h: No such file or directory
  161 | #include "util.h"
      |          ^~~~~~~~
compilation terminated.