https://godbolt.org/z/av7vTE7as
```c++
#include <cstdint>
#include <numeric>
typedef uint32_t u32;
u32 midpoint_u32(u32 a, u32 b) { return std::midpoint(a, b); }
```
Generated code:
```asm
_Z12midpoint_u32jj: // @_Z12midpoint_u32jj
cmp w0, w1
csel w8, w0, w1, lo
csel w9, w0, w1, hi
cmp w0, w1
sub w8, w9, w8
lsr w8, w8, #1
cneg w8, w8, hi
add w0, w8, w0
ret
```
The 2nd `cmp` is unnecessary: the flags register still contains the result of the first `cmp` instruction
https://godbolt.org/z/av7vTE7as
Generated code:
The 2nd
cmp
is unnecessary: the flags register still contains the result of the firstcmp
instruction