+/* Return the original state of inexact math. */
+bool ac_disable_inexact_math(LLVMBuilderRef builder)
+{
+ auto *b = llvm::unwrap(builder);
+ llvm::FastMathFlags flags = b->getFastMathFlags();
+
+ if (!flags.allowContract())
+ return false;
+
+ flags.setAllowContract(false);
+ b->setFastMathFlags(flags);
+ return true;
+}
+
+void ac_restore_inexact_math(LLVMBuilderRef builder, bool value)
+{
+ auto *b = llvm::unwrap(builder);
+ llvm::FastMathFlags flags = b->getFastMathFlags();
+
+ if (flags.allowContract() == value)
+ return;
+
+ flags.setAllowContract(value);
+ b->setFastMathFlags(flags);
+}
+