.ino is compiled as C++. your test is C code. put the C code in a .c file and the declaration in .h file and include the .h in .ino
I created a test.c, copied the content of your main.c into it and renamed the main function to test().
The I created a test.h with
#ifndef test_h
#define test_h
extern "C" void test();
#endif
and in ino setup() I call test();
it compiles. It runs.