Language: C

#include <stdio.h>
#include <string.h>
#define MaxSize 100000
int neighbour[MaxSize][MaxSize];
char visited[MaxSize];
char nbCount[MaxSize];
int startPath[MaxSize];
int endPath[MaxSize];
int startPathLen = 0;
int endPathLen = 0;

void searchEnd(int end, int pathArr[], int * pLength) {
    char allNbSearched = 0;
    char foundNew = 0;
    while(!allNbSearched) {
        for(int i = 0; i < nbCount[end]; i++) {
            int newEnd = neighbour[end][i];
            if(!visited[newEnd]) {
                end = newEnd;
                visited[newEnd] = 1;
                foundNew = 1;
                allNbSearched = 0;
                pathArr[*pLength] = newEnd;
                (*pLength)++;
                break; //for
            }
            allNbSearched = 1;
        }
    }
}
int main(int argc, const char * argv[]) {
    int N, M;
//    memset(neighbour, 0, MaxSize * MaxSize);
    memset(visited, 0, MaxSize);
    memset(nbCount, 0, MaxSize);
    scanf("%d%d", &N, &M);
//    N = MaxSize;
//    M = MaxSize ;
    int start = 0, end = 0;
    for(int i = 1; i <= M; i++) {
        scanf("%d%d", &start, &end);
//        start = i;
//        end = i+1;
//        end %= (N + 1);
//        if (end == 0) end = 1;
        neighbour[start][nbCount[start]] = end;
        neighbour[end][nbCount[end]] = start;
        nbCount[start]++;
        nbCount[end]++;
    }
    
    visited[start] = visited[end] = 1;
    searchEnd(start, startPath, &startPathLen);
    searchEnd(end, endPath, &endPathLen);
    
    printf("%d\n", startPathLen + endPathLen + 2);
    for(int i = 0; i < startPathLen; i++)
        printf("%d ", startPath[i]);
    printf("%d %d ", start, end);
    for(int i = 0; i < endPathLen; i++)
        printf("%d ", endPath[i]);
    printf("\n");
    return 0;
}

Compiler output:
/tmp/cc3KCKww.o: in function `searchEnd':
main.c:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
/tmp/cc3KCKww.o: in function `main':
main.c:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x21d): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o
main.c:(.text+0x22f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status