#ifndef UTILS_H #define UTILS_H #include #include #define MAX(a, b) ({ \ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a > _b ? _a : _b; \ }) #define MIN(a, b) ({ \ typeof (a) _a = (a); \ typeof (b) _b = (b); \ _a < _b ? _a : _b; \ }) #define SWAP(a, b) ({ \ typeof (a) tmp = (a); \ (a) = (b); \ (b) = tmp; \ }) #define CLZ(X) __builtin_clz (X) #define CTZ(X) __builtin_ctz (X) #define POPCOUNT(X) __builtin_popcount (X) #define NEWLINE() putchar ('\n') #define PAGEBREAK() putchar ('\n'); #define SUCCESS(MSG, ...) fprintf (stdout, "[+] SUCCESS: "MSG"\n", ##__VA_ARGS__) #define INFO(MSG, ...) fprintf (stdout, "[*] INFO: " MSG"\n", ##__VA_ARGS__) #define ERROR(MSG, ...) fprintf (stderr, "[-] ERROR: " MSG"\n", ##__VA_ARGS__) #define DIE(EXIT_CODE, MSG, ...) ({ ERROR (MSG, ##__VA_ARGS__); exit (EXIT_CODE); }) typedef unsigned int uint; typedef uint8_t u8; typedef int8_t s8; typedef uint32_t u32; typedef int32_t s32; typedef uint64_t u64; int input (const char *message, const char *regex, const char *template, ...); uint log10ui (uint ui); #endif