Technically a comparison operator would be a form of branching, because you have comparisons and jumps based off flags, same as what happens when you compile an if statement.
It becomes more evident when you see the generated code. https://godbolt.org/g/Mu9KBY
e.g:
cmp rax, QWORD PTR [rbp-24] ; compare a and b
ja .L2 ; is a above b?, if so jump to .L2, otherwise proceed
In fact this statement: size_t ret = (haystack[4] <= needle) * 4;
...is 100% equivalent to this once compiled: register size_t ret;
if (haystack[4] <= needle) {
ret = 4;
} else {
ret = 0;
}
So the code is not really branchless, just if-less.