## fmax instruction count
32 instructions are required in SFFS to emulate fmax.
-<https://gcc.godbolt.org/z/6xba61To6>
+```
+#include <stdint.h>
+#include <string.h>
+
+inline uint64_t asuint64(double f) {
+ union {
+ double f;
+ uint64_t i;
+ } u = {f};
+ return u.i;
+}
+
+inline int issignaling(double v) {
+ // copied from glibc:
+ // https://github.com/bminor/glibc/blob/e2756903329365134089d23548e9083d23bc3dd9/sysdeps/ieee754/dbl-64/math_config.h#L101
+ uint64_t ix = asuint64(v);
+ return 2 * (ix ^ 0x0008000000000000) > 2 * 0x7ff8000000000000ULL;
+}
+
+double fmax(double x, double y) {
+ // copied from glibc:
+ // https://github.com/bminor/glibc/blob/e2756903329365134089d23548e9083d23bc3dd9/math/s_fmax_template.c
+ if(__builtin_isgreaterequal(x, y))
+ return x;
+ else if(__builtin_isless(x, y))
+ return y;
+ else if(issignaling(x) || issignaling(y))
+ return x + y;
+ else
+ return __builtin_isnan(y) ? x : y;
+}
+```
+
+Assembly listing:
```
fmax(double, double):