I don't think you can ever depend on an optimization happening.
Why not do it like this, if you really want to avoid an extra variable:
void send_str(const char *data)
{
for(size_t i = strlen(data); i != 0; --i)
send_byte(*data++);
}
Or, less silly, and more like an actual production-quality C program:
void send_str(const char *data)
{
while(*data != '\0')
send_byte(*data++);
}
There's no point at all in iterating over the characters twice, so don't call strlen()
at all, detect the end-of-string yourself.