#ifndef _SPASS_MISC_
#define _SPASS_MISC_ 
#define __USE_FIXED_PROTOTYPES__ 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <inttypes.h>
#if defined(TRUE)
#undef TRUE
#endif
#if defined(FALSE)
#undef FALSE
#endif
#ifndef SEEK_END
#define SEEK_END 2
#endif
#define misc_ERROROUT stderr
#define misc_USERERROROUT stderr
#define SPASS_CHECK_INPUT 0x1
#define SPASS_CHECK_NTWFO 0x2
#undef BOOL
typedef enum { FALSE=0, TRUE=1 } BOOL;
typedef void* POINTER;
typedef uintptr_t NAT;
typedef uint64_t LNAT;
typedef unsigned PRIOR_T;
extern const PRIOR_T PRIOR_MAX;
#define misc_STRINGIFY(x) #x
#define misc_DEF_AS_STRING(x) misc_STRINGIFY(x)
#define NAT_MAX UINT_MAX
#define LNAT_MAX UINT64_MAX
typedef int (*COMPARE_FUNC)(const void *, const void * , void*) ;
typedef struct misc_func {
    void(*func)(void);
} misc_func;
void misc_Error(void) __attribute__ ((noreturn));
BOOL misc_SmallerThan(int, int);
int misc_IntCmp(const void *, const void *);
int misc_IntptrCmp(const void *, const void *);
int misc_UIntptrCmp(const void *, const void *);
BOOL misc_IntEqual(int, int);
BOOL misc_PtrEqual(intptr_t, intptr_t);
int misc_Ident(int);
#ifdef SPASS_CHECK
  #define misc_ASSERT(test) misc_Assert(test,__FILE__,__LINE__)
#else
  #define misc_ASSERT(test)
#endif
#define VERBOSITY_SILENT 0
#define VERBOSITY_INFO 1
#define VERBOSITY_ERROR 2
#define VERBOSITY_WARNING 3
#define VERBOSITY_DEBUG 4
#ifndef VERBOSE
    #ifdef _DEBUG
        #define VERBOSE VERBOSITY_DEBUG
    #else
        #define VERBOSE VERBOSITY_WARNING
    #endif
#endif
#if VERBOSE >= VERBOSITY_INFO
    #define INFO_PRINT(file, ...) do { fprintf(file, "\n[INFO] " __VA_ARGS__); } while(0)
    #define INFO_PRINT_CONT(file, ...) do { fprintf(file, __VA_ARGS__); } while(0)
    #define INFO_ONLY(x) do { (x); } while(0)
#else
    #define INFO_PRINT(file, ...)
    #define INFO_PRINT_CONT(file, ...)
    #define INFO_ONLY(x)
#endif
#if VERBOSE >= VERBOSITY_ERROR
    #define ERR_PRINT(file, ...) do { fprintf(file, "\n[ERROR] " __VA_ARGS__); } while(0)
    #define ERR_PRINT_CONT(file, ...) do { fprintf(file, __VA_ARGS__); } while(0)
    #define ERR_ONLY(x) do { (x); } while(0)
#else
    #define ERR_PRINT(file, ...)
    #define ERR_PRINT_CONT(file, ...)
    #define ERR_ONLY(x)
#endif
#if VERBOSE >= VERBOSITY_WARNING
    #define WARN_PRINT(file, ...) do { fprintf(file, "\n[WARNING] " __VA_ARGS__); } while(0)
    #define WARN_PRINT_CONT(file, ...) do { fprintf(file, __VA_ARGS__); } while(0)
    #define WARN_ONLY(x) do { (x); } while(0)
#else
    #define WARN_PRINT(file, ...)
    #define WARN_PRINT_CONT(file, ...)
    #define WARN_ONLY(x)
#endif
#if _DEBUG && VERBOSE >= VERBOSITY_DEBUG
    #define DBG_PRINT(file, ...) do { fprintf(file, "\n[DEBUG] " __VA_ARGS__); } while(0)
    #define DBG_PRINT_CONT(file, ...) do { fprintf(file, __VA_ARGS__); } while(0)
    #define DBG_ONLY(x) do { (x); } while(0)
#else
    #define DBG_PRINT(file, ...)
    #define DBG_PRINT_CONT(file, ...)
    #define DBG_ONLY(x)
#endif
#define misc_StartErrorReport() misc_StartErrorReporting(__FILE__,__LINE__)
#define misc_StartUserErrorReport() fflush(stdout)
#define misc_FinishUserErrorReport() misc_Error()
void misc_Assert(BOOL,const char*, int);
void misc_StartErrorReporting(const char*, int);
void misc_FinishErrorReport(void);
void misc_ErrorReport(const char * , ...);
void misc_UserWarning(const char * , ...);
void misc_UserErrorReport(const char * , ...);
void misc_PrintChar(NAT, char);
void misc_PrintBitmap(unsigned long);
void misc_DumpCore(void);
void misc_DumpCoreOut(const char*);
int misc_ReturnValue(void);
int misc_Max(int, int);
int misc_Min(int, int);
BOOL misc_TestForNull(intptr_t);
BOOL misc_NotNull(intptr_t);
BOOL misc_True(intptr_t ptr);
int misc_Sgn(intptr_t);
#endif
