This line creates an array body of size [(strlen(template) - 2 - ((int) log10(code) + 1) - 2 + strlen(phrase)) * 2 + 1].
// render template
char body[(strlen(template) - 2 - ((int) log10(code) + 1) - 2 + strlen(phrase)) * 2 + 1];
int length = sprintf(body, template, code, phrase, code, phrase);
But, I am unable to understand why "(strlen(template) - 2 - ((int) log10(code) + 1) - 2 + strlen(phrase))" has been multiplied by 2.
According to me, it should have been as
char body[strlen(template) + (-2 + ((int) log10(code) + 1) - 2 + strlen(phrase)) * 2 + 1];