+#include "irflag_t.h"
+#include "irprintf.h"
+#include "irgwalk.h"
+#include "typewalk.h"
+
+static const char *firm_vrfy_failure_msg;
+
+#ifdef NDEBUG
+/*
+ * in RELEASE mode, returns ret if the expression expr evaluates to zero
+ * in ASSERT mode, asserts the expression expr (and the string string).
+ */
+#define ASSERT_AND_RET(expr, string, ret) if (!(expr)) return (ret)
+
+/*
+ * in RELEASE mode, returns ret if the expression expr evaluates to zero
+ * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
+ */
+#define ASSERT_AND_RET_DBG(expr, string, ret, blk) if (!(expr)) return (ret)
+#else
+#define ASSERT_AND_RET(expr, string, ret) \
+do { \
+ if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
+ assert((expr) && string); } \
+ if (!(expr)) { \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
+ fprintf(stderr, #expr " : " string "\n"); \
+ firm_vrfy_failure_msg = #expr " && " string; \
+ return (ret); \
+ } \
+} while(0)
+
+#define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
+do { \
+ if (!(expr)) { \
+ firm_vrfy_failure_msg = #expr " && " string; \
+ if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
+ fprintf(stderr, #expr " : " string "\n"); \
+ else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
+ assert((expr) && string); \
+ } \
+ return (ret); \
+ } \
+} while(0)
+
+#endif /* NDEBUG */