Well, the curves are nice, the idea behind seems to work, BUT,

I am still lacking some dev skills.

How would I transfer the

optimize(10, 1, 55, 1)
and
optimize(1, 1, Cycle, 1)

to the function traincycles???

Second question, how would I pass back two values to the calling function.

Or, is it possible to directly modify them in the function traincycles?
I know that is not (if possible in C) good practice, to modify global variables inside a function instead of handing them back out.