I'm not sure what you mean by helpers, I think this is currently reasonably readable and I'm not sure duplication matters much.
I mean that they should be wrapped inside static functions, so that compiler won't generate essentially same code multiple times.
```c static SIZE_T block_bin_size( UINT bin ) { return BLOCK_BIN_SIZE( bin ); }
static UINT block_size_bin( SIZE_T size ) { return BLOCK_SIZE_BIN( size ); } ```
There are a total of 7 invocations of `BLOCK_BIN_SIZE` in the code, each of which will be expanded to unique machine code. In addition, `heap_allocate_block_lfh` and `heap_resize_in_place` have 2 invocations of `BLOCK_BIN_SIZE` each.
Haven't tried removing branches, I'm hoping the compiler will do some magic as it's all static comparison. Readability is important I think but if you have a suggestion go ahead.
It's possible to write mostly-branch-free version for `BLOCK_BIN_SIZE`[^note], which is the one invoked in the majority of cases. I'm not sure that the bitwise ops are more performant than branching, though, so I'm not really suggesting to use that version. Also, writing the arithmetic counterpart for `BLOCK_SIZE_BIN` is not really feasible, so the asymmetry isn't exactly beautiful.
[^note]: https://godbolt.org/z/PMPbbsY6a