1 /* Generated by CIL v. 1.3.6 */
   2 /* print_CIL_Input is true */
   3 
   4 typedef unsigned int size_t;
   5 typedef long long __quad_t;
   6 typedef unsigned long long __u_quad_t;
   7 typedef __u_quad_t __dev_t;
   8 typedef unsigned int __uid_t;
   9 typedef unsigned int __gid_t;
  10 typedef unsigned long __ino_t;
  11 typedef unsigned int __mode_t;
  12 typedef unsigned int __nlink_t;
  13 typedef long __off_t;
  14 typedef __quad_t __off64_t;
  15 typedef long __time_t;
  16 typedef long __blksize_t;
  17 typedef long __blkcnt_t;
  18 typedef int __ssize_t;
  19 struct timespec {
  20    __time_t tv_sec ;
  21    long tv_nsec ;
  22 };
  23 struct __pthread_internal_slist {
  24    struct __pthread_internal_slist *__next ;
  25 };
  26 typedef struct __pthread_internal_slist __pthread_slist_t;
  27 union __anonunion____missing_field_name_6 {
  28    int __spins ;
  29    __pthread_slist_t __list ;
  30 };
  31 struct __pthread_mutex_s {
  32    int __lock ;
  33    unsigned int __count ;
  34    int __owner ;
  35    int __kind ;
  36    unsigned int __nusers ;
  37    union __anonunion____missing_field_name_6 __annonCompField1 ;
  38 };
  39 union __anonunion_pthread_mutex_t_5 {
  40    struct __pthread_mutex_s __data ;
  41    char __size[24] ;
  42    long __align ;
  43 };
  44 typedef union __anonunion_pthread_mutex_t_5 pthread_mutex_t;
  45 union __anonunion_pthread_mutexattr_t_7 {
  46    char __size[4] ;
  47    long __align ;
  48 };
  49 typedef union __anonunion_pthread_mutexattr_t_7 pthread_mutexattr_t;
  50 typedef __ssize_t ssize_t;
  51 struct _IO_FILE;
  52 typedef struct _IO_FILE FILE;
  53 typedef void _IO_lock_t;
  54 struct _IO_marker {
  55    struct _IO_marker *_next ;
  56    struct _IO_FILE *_sbuf ;
  57    int _pos ;
  58 };
  59 struct _IO_FILE {
  60    int _flags ;
  61    char *_IO_read_ptr ;
  62    char *_IO_read_end ;
  63    char *_IO_read_base ;
  64    char *_IO_write_base ;
  65    char *_IO_write_ptr ;
  66    char *_IO_write_end ;
  67    char *_IO_buf_base ;
  68    char *_IO_buf_end ;
  69    char *_IO_save_base ;
  70    char *_IO_backup_base ;
  71    char *_IO_save_end ;
  72    struct _IO_marker *_markers ;
  73    struct _IO_FILE *_chain ;
  74    int _fileno ;
  75    int _flags2 ;
  76    __off_t _old_offset ;
  77    unsigned short _cur_column ;
  78    signed char _vtable_offset ;
  79    char _shortbuf[1] ;
  80    _IO_lock_t *_lock ;
  81    __off64_t _offset ;
  82    void *__pad1 ;
  83    void *__pad2 ;
  84    void *__pad3 ;
  85    void *__pad4 ;
  86    size_t __pad5 ;
  87    int _mode ;
  88    char _unused2[(15U * sizeof(int ) - 4U * sizeof(void *)) - sizeof(size_t )] ;
  89 };
  90 struct stat {
  91    __dev_t st_dev ;
  92    unsigned short __pad1 ;
  93    __ino_t st_ino ;
  94    __mode_t st_mode ;
  95    __nlink_t st_nlink ;
  96    __uid_t st_uid ;
  97    __gid_t st_gid ;
  98    __dev_t st_rdev ;
  99    unsigned short __pad2 ;
 100    __off_t st_size ;
 101    __blksize_t st_blksize ;
 102    __blkcnt_t st_blocks ;
 103    struct timespec st_atim ;
 104    struct timespec st_mtim ;
 105    struct timespec st_ctim ;
 106    unsigned long __unused4 ;
 107    unsigned long __unused5 ;
 108 };
 109 struct cache_entry;
 110 typedef struct cache_entry cache_entry;
 111 struct cache_entry {
 112    char *filename ;
 113    char *data ;
 114    ssize_t total ;
 115    int refs ;
 116    pthread_mutex_t refs_mutex ;
 117    cache_entry *next ;
 118    cache_entry *prev ;
 119 };
 120 typedef unsigned int PRUint32;
 121 typedef unsigned int PRUintn;
 122 typedef int PRIntn;
 123 typedef ssize_t PRSize;
 124 typedef int PRBool;
 125 struct PLHashEntry;
 126 typedef struct PLHashEntry PLHashEntry;
 127 struct PLHashTable;
 128 typedef struct PLHashTable PLHashTable;
 129 typedef PRUint32 PLHashNumber;
 130 struct PLHashAllocOps {
 131    void *(*allocTable)(void *pool , PRSize size ) ;
 132    void (*freeTable)(void *pool , void *item ) ;
 133    PLHashEntry *(*allocEntry)(void *pool , void const   *key ) ;
 134    void (*freeEntry)(void *pool , PLHashEntry *he , PRUintn flag ) ;
 135 };
 136 typedef struct PLHashAllocOps PLHashAllocOps;
 137 struct PLHashEntry {
 138    PLHashEntry *next ;
 139    PLHashNumber keyHash ;
 140    void const   *key ;
 141    void *value ;
 142 };
 143 struct PLHashTable {
 144    PLHashEntry **buckets ;
 145    PRUint32 nentries ;
 146    PRUint32 shift ;
 147    PLHashNumber (*keyHash)(void const   *key ) ;
 148    PRIntn (*keyCompare)(void const   *v1 , void const   *v2 ) ;
 149    PRIntn (*valueCompare)(void const   *v1 , void const   *v2 ) ;
 150    PLHashAllocOps const   *allocOps ;
 151    void *allocPriv ;
 152 };
 153 struct input_state;
 154 typedef struct input_state input_state;
 155 struct input_state {
 156    char buf[512] ;
 157    int used ;
 158    int valid ;
 159    int socket ;
 160 };
 161 enum http_version;
 162 typedef enum http_version http_version;
 163 enum http_version {
 164     HTTP_VERSION_1_0 = 0,
 165     HTTP_VERSION_1_1 = 1
 166 } ;
 167 struct http_request;
 168 typedef struct http_request http_request;
 169 struct http_request {
 170    char url[80] ;
 171    http_version version ;
 172    int socket ;
 173    int closed ;
 174 };
 175 typedef unsigned int __socklen_t;
 176 typedef unsigned long pthread_t;
 177 union __anonunion_pthread_attr_t_4 {
 178    char __size[36] ;
 179    long __align ;
 180 };
 181 typedef union __anonunion_pthread_attr_t_4 pthread_attr_t;
 182 typedef unsigned short uint16_t;
 183 typedef unsigned int uint32_t;
 184 typedef __socklen_t socklen_t;
 185 typedef unsigned short sa_family_t;
 186 struct sockaddr {
 187    sa_family_t sa_family ;
 188    char sa_data[14] ;
 189 };
 190 typedef uint16_t in_port_t;
 191 typedef uint32_t in_addr_t;
 192 struct in_addr {
 193    in_addr_t s_addr ;
 194 };
 195 struct sockaddr_in {
 196    sa_family_t sin_family ;
 197    in_port_t sin_port ;
 198    struct in_addr sin_addr ;
 199    unsigned char sin_zero[((sizeof(struct sockaddr ) - sizeof(unsigned short )) - sizeof(in_port_t )) - sizeof(struct in_addr )] ;
 200 };
 201 enum http_version;
 202 typedef long long cpu_tick_t;
 203 struct thread_args;
 204 typedef struct thread_args thread_args;
 205 struct thread_args {
 206    int id ;
 207    int s ;
 208 };
 209 typedef __builtin_va_list __gnuc_va_list;
 210 typedef __gnuc_va_list va_list;
 211 typedef long __suseconds_t;
 212 struct timeval {
 213    __time_t tv_sec ;
 214    __suseconds_t tv_usec ;
 215 };
 216 struct timezone {
 217    int tz_minuteswest ;
 218    int tz_dsttime ;
 219 };
 220 typedef struct timezone * __restrict  __timezone_ptr_t;
 221 typedef unsigned char PRUint8;
 222 #pragma merger(0,"/tmp/cil-oSwcmw7z.i","")
 223 extern  __attribute__((__nothrow__)) int pthread_mutex_init(pthread_mutex_t *__mutex ,
 224                                                             pthread_mutexattr_t const   *__mutexattr )  __attribute__((__nonnull__(1))) ;
 225 extern  __attribute__((__nothrow__)) int pthread_mutex_destroy(pthread_mutex_t *__mutex )  __attribute__((__nonnull__(1))) ;
 226 extern  __attribute__((__nothrow__)) int pthread_mutex_lock(pthread_mutex_t *__mutex )  __attribute__((__nonnull__(1))) ;
 227 extern  __attribute__((__nothrow__)) int pthread_mutex_unlock(pthread_mutex_t *__mutex )  __attribute__((__nonnull__(1))) ;
 228 extern int open(char const   *__file , int __oflag  , ...)  __attribute__((__nonnull__(1))) ;
 229 extern  __attribute__((__nothrow__)) void *malloc(size_t __size )  __attribute__((__malloc__)) ;
 230 extern  __attribute__((__nothrow__)) void free(void *__ptr ) ;
 231 extern  __attribute__((__nothrow__, __noreturn__)) void exit(int __status ) ;
 232 extern struct _IO_FILE *stderr ;
 233 extern int fprintf(FILE * __restrict  __stream , char const   * __restrict  __format 
 234                    , ...) ;
 235 extern  __attribute__((__nothrow__)) int ( /* format attribute */  snprintf)(char * __restrict  __s ,
 236                                                                              size_t __maxlen ,
 237                                                                              char const   * __restrict  __format 
 238                                                                              , ...) ;
 239 extern void perror(char const   *__s ) ;
 240 extern  __attribute__((__nothrow__)) char *strdup(char const   *__s )  __attribute__((__nonnull__(1),
 241 __malloc__)) ;
 242 __inline static  __attribute__((__nothrow__)) int fstat(int __fd , struct stat *__statbuf )  __attribute__((__nonnull__(2))) ;
 243 extern  __attribute__((__nothrow__)) int __fxstat(int __ver , int __fildes , struct stat *__stat_buf )  __attribute__((__nonnull__(3))) ;
 244 __inline static  __attribute__((__nothrow__)) int fstat(int __fd , struct stat *__statbuf )  __attribute__((__nonnull__(2))) ;
 245 __inline static int fstat(int __fd , struct stat *__statbuf ) 
 246 { int tmp ;
 247 
 248   {
 249   tmp = __fxstat(3, __fd, __statbuf);
 250   return (tmp);
 251 }
 252 }
 253 extern int close(int __fd ) ;
 254 extern ssize_t read(int __fd , void *__buf , size_t __nbytes ) ;
 255 void cache_init(void) ;
 256 cache_entry *cache_get(char *filename ) ;
 257 void cache_entry_addref(cache_entry *entry ) ;
 258 void cache_entry_release(cache_entry *entry ) ;
 259 PLHashTable *PL_NewHashTable(PRUint32 n , PLHashNumber (*keyHash)(void const   *key ) ,
 260                              PRIntn (*keyCompare)(void const   *v1 , void const   *v2 ) ,
 261                              PRIntn (*valueCompare)(void const   *v1 , void const   *v2 ) ,
 262                              PLHashAllocOps const   *allocOps , void *allocPriv ) ;
 263 PLHashEntry *PL_HashTableAdd(PLHashTable *ht , void const   *key , void *value ) ;
 264 PRBool PL_HashTableRemove(PLHashTable *ht , void const   *key ) ;
 265 void *PL_HashTableLookup(PLHashTable *ht , void const   *key ) ;
 266 PLHashNumber PL_HashString(void const   *key ) ;
 267 int PL_CompareStrings(void const   *v1 , void const   *v2 ) ;
 268 int PL_CompareValues(void const   *v1 , void const   *v2 ) ;
 269 void assert_failed(char *file , unsigned int line , char const   *func , char *expr ) ;
 270 pthread_mutex_t g_cache_mutex ;
 271 int g_cache_hits ;
 272 int g_cache_misses ;
 273 static PLHashTable *g_hash  =    (PLHashTable *)((void *)0);
 274 static cache_entry *g_cache  =    (cache_entry *)((void *)0);
 275 static cache_entry *g_cache_tail  =    (cache_entry *)((void *)0);
 276 static ssize_t g_cache_max  =    536870912;
 277 static ssize_t g_cache_cur  =    0;
 278 static cache_entry *cache_new(char *filename ) 
 279 { cache_entry *result ;
 280   int fd ;
 281   int tmp ;
 282   int ret ;
 283   struct stat fd_stat ;
 284   char *data ;
 285   size_t length ;
 286   int hdrlen ;
 287   int tmp___0 ;
 288   void *tmp___1 ;
 289   void *tmp___2 ;
 290 
 291   {
 292   result = (cache_entry *)((void *)0);
 293   tmp = open((char const   *)filename, 0);
 294   fd = tmp;
 295   if (fd >= 0) {
 296     data = (char *)((void *)0);
 297     length = (size_t )0;
 298     hdrlen = 0;
 299     tmp___0 = fstat(fd, & fd_stat);
 300     if (tmp___0 < 0) {
 301       perror("fstat");
 302       exit(1);
 303     }
 304     if (! ((fd_stat.st_mode & 61440U) == 32768U)) {
 305       return ((cache_entry *)((void *)0));
 306     }
 307     length = (unsigned int )fd_stat.st_size;
 308     tmp___1 = malloc(length + 128U);
 309     data = (char *)tmp___1;
 310     if (! ((unsigned int )data != (unsigned int )((void *)0))) {
 311       assert_failed((char *)"cache.c", 69U, "cache_new", (char *)"data != ((void *)0)");
 312     }
 313     hdrlen = snprintf((char * __restrict  )data, 128U, (char const   * __restrict  )"HTTP/1.1 200 OK\r\nContent-Type: %s\r\nContent-Length: %d\r\n\r\n",
 314                       "text/html", length);
 315     if (hdrlen < 0) {
 316       fprintf((FILE * __restrict  )stderr, (char const   * __restrict  )"header buffer exceeded\n");
 317       exit(1);
 318     } else {
 319       if (hdrlen >= 128) {
 320         fprintf((FILE * __restrict  )stderr, (char const   * __restrict  )"header buffer exceeded\n");
 321         exit(1);
 322       }
 323     }
 324     ret = read(fd, (void *)(data + hdrlen), length);
 325     if ((unsigned int )ret != length) {
 326       perror("read");
 327       fprintf((FILE * __restrict  )stderr, (char const   * __restrict  )"read failed - expected %d, but got %d\n",
 328               length, ret);
 329       close(fd);
 330       return ((cache_entry *)((void *)0));
 331     }
 332     tmp___2 = malloc(sizeof(*result));
 333     result = (cache_entry *)tmp___2;
 334     if (! ((unsigned int )result != (unsigned int )((void *)0))) {
 335       assert_failed((char *)"cache.c", 90U, "cache_new", (char *)"result != ((void *)0)");
 336     }
 337     result->filename = strdup((char const   *)filename);
 338     if (! ((unsigned int )result->filename != (unsigned int )((void *)0))) {
 339       assert_failed((char *)"cache.c", 93U, "cache_new", (char *)"result->filename != ((void *)0)");
 340     }
 341     result->data = data;
 342     result->total = (int )(length + (size_t )hdrlen);
 343     result->refs = 1;
 344     pthread_mutex_init(& result->refs_mutex, (pthread_mutexattr_t const   *)((void *)0));
 345     result->next = (cache_entry *)((void *)0);
 346     result->prev = (cache_entry *)((void *)0);
 347     close(fd);
 348   }
 349   return (result);
 350 }
 351 }
 352 static void cache_add(cache_entry *entry ) 
 353 { 
 354 
 355   {
 356   if (! ((unsigned int )entry != (unsigned int )((void *)0))) {
 357     assert_failed((char *)"cache.c", 114U, "cache_add", (char *)"entry != ((void *)0)");
 358   }
 359   if ((unsigned int )g_cache != (unsigned int )((void *)0)) {
 360     if (! ((unsigned int )entry->next == (unsigned int )((void *)0))) {
 361       assert_failed((char *)"cache.c", 118U, "cache_add", (char *)"entry->next == ((void *)0)");
 362     }
 363     if (! ((unsigned int )entry->prev == (unsigned int )((void *)0))) {
 364       assert_failed((char *)"cache.c", 119U, "cache_add", (char *)"entry->prev == ((void *)0)");
 365     }
 366     if (! ((unsigned int )g_cache->prev == (unsigned int )((void *)0))) {
 367       assert_failed((char *)"cache.c", 120U, "cache_add", (char *)"g_cache->prev == ((void *)0)");
 368     }
 369     entry->next = g_cache;
 370     entry->prev = (cache_entry *)((void *)0);
 371     g_cache->prev = entry;
 372   }
 373   if ((unsigned int )g_cache_tail == (unsigned int )((void *)0)) {
 374     g_cache_tail = entry;
 375   }
 376   g_cache = entry;
 377   g_cache_cur += entry->total;
 378   PL_HashTableAdd(g_hash, (void const   *)entry->filename, (void *)entry);
 379   return;
 380 }
 381 }
 382 static void cache_remove(cache_entry *entry ) 
 383 { 
 384 
 385   {
 386   if (! ((unsigned int )entry != (unsigned int )((void *)0))) {
 387     assert_failed((char *)"cache.c", 145U, "cache_remove", (char *)"entry != ((void *)0)");
 388   }
 389   if ((unsigned int )g_cache == (unsigned int )entry) {
 390     g_cache_cur -= entry->total;
 391   } else {
 392     if ((unsigned int )entry->prev != (unsigned int )((void *)0)) {
 393       g_cache_cur -= entry->total;
 394     }
 395   }
 396   if ((unsigned int )g_cache == (unsigned int )entry) {
 397     if (! ((unsigned int )g_cache->prev == (unsigned int )((void *)0))) {
 398       assert_failed((char *)"cache.c", 155U, "cache_remove", (char *)"g_cache->prev == ((void *)0)");
 399     }
 400     g_cache = g_cache->next;
 401   }
 402   if ((unsigned int )g_cache_tail == (unsigned int )entry) {
 403     if (! ((unsigned int )g_cache_tail->next == (unsigned int )((void *)0))) {
 404       assert_failed((char *)"cache.c", 161U, "cache_remove", (char *)"g_cache_tail->next == ((void *)0)");
 405     }
 406     g_cache_tail = g_cache_tail->prev;
 407   }
 408   if ((unsigned int )entry->prev != (unsigned int )((void *)0)) {
 409     (entry->prev)->next = entry->next;
 410   }
 411   if ((unsigned int )entry->next != (unsigned int )((void *)0)) {
 412     (entry->next)->prev = entry->prev;
 413   }
 414   entry->prev = (cache_entry *)((void *)0);
 415   entry->next = (cache_entry *)((void *)0);
 416   PL_HashTableRemove(g_hash, (void const   *)entry->filename);
 417   return;
 418 }
 419 }
 420 static void cache_evict(void) 
 421 { cache_entry *remove___0 ;
 422 
 423   {
 424   while (g_cache_cur > g_cache_max) {
 425     remove___0 = g_cache_tail;
 426     if (! ((unsigned int )remove___0 != (unsigned int )((void *)0))) {
 427       assert_failed((char *)"cache.c", 189U, "cache_evict", (char *)"remove != ((void *)0)");
 428     }
 429     cache_remove(remove___0);
 430     cache_entry_release(remove___0);
 431   }
 432   return;
 433 }
 434 }
 435 static cache_entry *cache_find(char *filename ) 
 436 { void *tmp ;
 437 
 438   {
 439   tmp = PL_HashTableLookup(g_hash, (void const   *)filename);
 440   return ((cache_entry *)tmp);
 441 }
 442 }
 443 static void cache_use(cache_entry *entry ) 
 444 { 
 445 
 446   {
 447   if ((unsigned int )g_cache != (unsigned int )entry) {
 448     cache_remove(entry);
 449     cache_add(entry);
 450   }
 451   return;
 452 }
 453 }
 454 static void cache_finish_get(cache_entry *entry ) 
 455 { 
 456 
 457   {
 458   cache_use(entry);
 459   cache_entry_addref(entry);
 460   cache_evict();
 461   return;
 462 }
 463 }
 464 void cache_init(void) 
 465 { 
 466 
 467   {
 468   g_hash = PL_NewHashTable(100U, & PL_HashString, & PL_CompareStrings, & PL_CompareValues,
 469                            (PLHashAllocOps const   *)((void *)0), (void *)0);
 470   if (! ((unsigned int )g_hash != (unsigned int )((void *)0))) {
 471     assert_failed((char *)"cache.c", 230U, "cache_init", (char *)"g_hash != ((void *)0)");
 472   }
 473   return;
 474 }
 475 }
 476 cache_entry *cache_get(char *filename ) 
 477 { cache_entry *result ;
 478 
 479   {
 480   result = (cache_entry *)((void *)0);
 481   pthread_mutex_lock(& g_cache_mutex);
 482   result = cache_find(filename);
 483   if ((unsigned int )result != (unsigned int )((void *)0)) {
 484     g_cache_hits ++;
 485     cache_finish_get(result);
 486   } else {
 487     g_cache_misses ++;
 488   }
 489   pthread_mutex_unlock(& g_cache_mutex);
 490   if ((unsigned int )result == (unsigned int )((void *)0)) {
 491     result = cache_new(filename);
 492     if ((unsigned int )result != (unsigned int )((void *)0)) {
 493       pthread_mutex_lock(& g_cache_mutex);
 494       cache_add(result);
 495       cache_finish_get(result);
 496       pthread_mutex_unlock(& g_cache_mutex);
 497     }
 498   }
 499   return (result);
 500 }
 501 }
 502 void cache_entry_addref(cache_entry *entry ) 
 503 { 
 504 
 505   {
 506   if ((unsigned int )entry != (unsigned int )((void *)0)) {
 507     pthread_mutex_lock(& entry->refs_mutex);
 508     (entry->refs) ++;
 509     pthread_mutex_unlock(& entry->refs_mutex);
 510   }
 511   return;
 512 }
 513 }
 514 void cache_entry_release(cache_entry *entry ) 
 515 { int refs ;
 516 
 517   {
 518   refs = 0;
 519   if ((unsigned int )entry != (unsigned int )((void *)0)) {
 520     pthread_mutex_lock(& entry->refs_mutex);
 521     (entry->refs) --;
 522     refs = entry->refs;
 523     pthread_mutex_unlock(& entry->refs_mutex);
 524     if (refs == 0) {
 525       pthread_mutex_destroy(& entry->refs_mutex);
 526       free((void *)entry->filename);
 527       free((void *)entry->data);
 528       free((void *)entry);
 529       entry = (cache_entry *)((void *)0);
 530     }
 531   }
 532   return;
 533 }
 534 }
 535 #pragma merger(0,"/tmp/cil-OrJKQtWj.i","")
 536 extern  __attribute__((__nothrow__, __noreturn__)) void __assert_fail(char const   *__assertion ,
 537                                                                       char const   *__file ,
 538                                                                       unsigned int __line ,
 539                                                                       char const   *__function ) ;
 540 extern  __attribute__((__nothrow__)) char *strcpy(char * __restrict  __dest , char const   * __restrict  __src )  __attribute__((__nonnull__(1,2))) ;
 541 extern  __attribute__((__nothrow__)) int strcmp(char const   *__s1 , char const   *__s2 )  __attribute__((__pure__,
 542 __nonnull__(1,2))) ;
 543 extern  __attribute__((__nothrow__)) char *strchr(char const   *__s , int __c )  __attribute__((__pure__,
 544 __nonnull__(1))) ;
 545 extern  __attribute__((__nothrow__)) size_t strlen(char const   *__s )  __attribute__((__pure__,
 546 __nonnull__(1))) ;
 547 void input_init(input_state *state , int socket___0 ) ;
 548 char *input_get_line(input_state *state ) ;
 549 void http_init(http_request *request , int socket___0 ) ;
 550 int http_parse(http_request *request ) ;
 551 void http_init(http_request *request , int socket___0 ) 
 552 { 
 553 
 554   {
 555   request->url[0] = (char)0;
 556   request->version = 0;
 557   request->closed = 0;
 558   request->socket = socket___0;
 559   return;
 560 }
 561 }
 562 int http_parse(http_request *request ) 
 563 { int result ;
 564   int done ;
 565   input_state state ;
 566   char *line ;
 567   char *tmp ;
 568   char *method ;
 569   char *url ;
 570   char *protocol ;
 571   http_version version ;
 572   int valid ;
 573   char *tmp___0 ;
 574   char *tmp___1 ;
 575   int tmp___2 ;
 576   int tmp___3 ;
 577   int tmp___4 ;
 578   size_t tmp___5 ;
 579 
 580   {
 581   result = 0;
 582   done = 0;
 583   input_init(& state, request->socket);
 584   request->url[0] = (char)0;
 585   request->version = 0;
 586   while (! done) {
 587     tmp = input_get_line(& state);
 588     line = tmp;
 589     if ((unsigned int )line == (unsigned int )((void *)0)) {
 590       request->closed = 1;
 591       result = 0;
 592       done = 1;
 593     } else {
 594       if ((int )*(line + 0) == 0) {
 595         result = (int )request->url[0] != 0;
 596         done = 1;
 597       } else {
 598         if ((int )request->url[0] == 0) {
 599           version = 0;
 600           valid = 0;
 601           method = line;
 602           url = strchr((char const   *)line, ' ');
 603           if ((unsigned int )url != (unsigned int )((void *)0)) {
 604             tmp___0 = url;
 605             url ++;
 606             *tmp___0 = (char)0;
 607             protocol = strchr((char const   *)url, ' ');
 608             if ((unsigned int )protocol != (unsigned int )((void *)0)) {
 609               tmp___1 = protocol;
 610               protocol ++;
 611               *tmp___1 = (char)0;
 612               tmp___4 = strcmp((char const   *)method, "GET");
 613               if (tmp___4 == 0) {
 614                 tmp___3 = strcmp((char const   *)protocol, "HTTP/1.1");
 615                 if (tmp___3 == 0) {
 616                   version = 1;
 617                   valid = 1;
 618                 } else {
 619                   tmp___2 = strcmp((char const   *)protocol, "HTTP/1.0");
 620                   if (tmp___2 == 0) {
 621                     version = 0;
 622                     valid = 1;
 623                   }
 624                 }
 625               }
 626             }
 627           }
 628           if (valid) {
 629             url --;
 630             if (! ((unsigned int )line <= (unsigned int )url)) {
 631               __assert_fail("line <= url", "http.c", 95U, "http_parse");
 632             }
 633             *(url + 0) = (char )'.';
 634             tmp___5 = strlen((char const   *)url);
 635             if (! (tmp___5 < sizeof(request->url))) {
 636               __assert_fail("strlen(url) < sizeof(request->url)", "http.c", 101U,
 637                             "http_parse");
 638             }
 639             strcpy((char * __restrict  )(request->url), (char const   * __restrict  )url);
 640             if (! ((int )request->url[0] == 46)) {
 641               __assert_fail("request->url[0] == \'.\'", "http.c", 103U, "http_parse");
 642             }
 643             request->version = version;
 644           } else {
 645             result = 0;
 646             done = 1;
 647           }
 648         }
 649       }
 650     }
 651   }
 652   return (result);
 653 }
 654 }
 655 #pragma merger(0,"/tmp/cil-Ms76eN5O.i","")
 656 extern  __attribute__((__nothrow__)) void *memmove(void *__dest , void const   *__src ,
 657                                                    size_t __n )  __attribute__((__nonnull__(1,2))) ;
 658 extern  __attribute__((__nothrow__)) char *strstr(char const   *__haystack , char const   *__needle )  __attribute__((__pure__,
 659 __nonnull__(1,2))) ;
 660 void input_init(input_state *state , int socket___0 ) 
 661 { 
 662 
 663   {
 664   if (! ((unsigned int )state != (unsigned int )((void *)0))) {
 665     __assert_fail("state != ((void *)0)", "input.c", 18U, "input_init");
 666   }
 667   state->used = 0;
 668   state->valid = 0;
 669   state->socket = socket___0;
 670   return;
 671 }
 672 }
 673 char *input_get_line(input_state *state ) 
 674 { char *result ;
 675   int done ;
 676   char *start ;
 677   char *newline ;
 678   char *empty ;
 679   int n ;
 680   ssize_t tmp ;
 681 
 682   {
 683   result = (char *)((void *)0);
 684   done = 0;
 685   while (! done) {
 686     if (! (0 <= state->used)) {
 687       __assert_fail("0 <= state->used", "input.c", 38U, "input_get_line");
 688     }
 689     if (! (state->used <= state->valid)) {
 690       __assert_fail("state->used <= state->valid", "input.c", 39U, "input_get_line");
 691     }
 692     if (! (state->valid <= 511)) {
 693       __assert_fail("state->valid <= 511", "input.c", 40U, "input_get_line");
 694     }
 695     state->buf[state->valid] = (char)0;
 696     start = & state->buf[state->used];
 697     newline = strstr((char const   *)start, "\r\n");
 698     if ((unsigned int )newline != (unsigned int )((void *)0)) {
 699       *newline = (char)0;
 700       result = start;
 701       done = 1;
 702       state->used = (newline - state->buf) + 2;
 703       if (state->used == state->valid) {
 704         state->used = 0;
 705         state->valid = 0;
 706       }
 707     } else {
 708       if (state->valid < 511) {
 709         empty = & state->buf[state->valid];
 710         tmp = read(state->socket, (void *)empty, (unsigned int )(511 - state->valid));
 711         n = tmp;
 712         if (n <= 0) {
 713           result = (char *)((void *)0);
 714           done = 1;
 715         } else {
 716           state->valid += n;
 717         }
 718       } else {
 719         if (state->used > 0) {
 720           memmove((void *)(& state->buf[0]), (void const   *)(& state->buf[state->used]),
 721                   (unsigned int )(state->valid - state->used));
 722           state->valid -= state->used;
 723           state->used = 0;
 724         } else {
 725           result = (char *)((void *)0);
 726           done = 1;
 727         }
 728       }
 729     }
 730   }
 731   return (result);
 732 }
 733 }
 734 #pragma merger(0,"/tmp/cil-yY6bFgIx.i","")
 735 extern  __attribute__((__nothrow__)) int sched_yield(void) ;
 736 extern  __attribute__((__nothrow__)) int pthread_create(pthread_t * __restrict  __newthread ,
 737                                                         pthread_attr_t const   * __restrict  __attr ,
 738                                                         void *(*__start_routine)(void * ) ,
 739                                                         void * __restrict  __arg )  __attribute__((__nonnull__(1,3))) ;
 740 extern  __attribute__((__noreturn__)) void pthread_exit(void *__retval ) ;
 741 extern  __attribute__((__nothrow__)) int pthread_attr_init(pthread_attr_t *__attr )  __attribute__((__nonnull__(1))) ;
 742 extern  __attribute__((__nothrow__)) int pthread_attr_setdetachstate(pthread_attr_t *__attr ,
 743                                                                      int __detachstate )  __attribute__((__nonnull__(1))) ;
 744 extern  __attribute__((__nothrow__)) int socket(int __domain , int __type , int __protocol ) ;
 745 extern  __attribute__((__nothrow__)) int bind(int __fd , struct sockaddr  const  *__addr ,
 746                                               socklen_t __len ) ;
 747 extern  __attribute__((__nothrow__)) int setsockopt(int __fd , int __level , int __optname ,
 748                                                     void const   *__optval , socklen_t __optlen ) ;
 749 extern  __attribute__((__nothrow__)) int listen(int __fd , int __n ) ;
 750 extern int accept(int __fd , struct sockaddr * __restrict  __addr , socklen_t * __restrict  __addr_len ) ;
 751 extern  __attribute__((__nothrow__)) uint16_t htons(uint16_t __hostshort )  __attribute__((__const__)) ;
 752 extern int printf(char const   * __restrict  __format  , ...) ;
 753 extern  __attribute__((__nothrow__)) int atoi(char const   *__nptr )  __attribute__((__pure__,
 754 __nonnull__(1))) ;
 755 extern ssize_t write(int __fd , void const   *__buf , size_t __n ) ;
 756 extern unsigned int sleep(unsigned int __seconds ) ;
 757 extern  __attribute__((__nothrow__)) int chdir(char const   *__path )  __attribute__((__nonnull__(1))) ;
 758 extern  __attribute__((__nothrow__)) int *__errno_location(void)  __attribute__((__const__)) ;
 759 cpu_tick_t ticks_per_microsecond ;
 760 __inline static long long current_usecs(void) 
 761 { register cpu_tick_t ret ;
 762 
 763   {
 764   __asm__  volatile   ("rdtsc": "=A" (ret));
 765   return (ret / ticks_per_microsecond);
 766 }
 767 }
 768 int g_use_timer  =    1;
 769 int g_spawn_on_demand  =    0;
 770 static int g_use_cache  =    0;
 771 static int g_force_thrashing  =    0;
 772 pthread_mutex_t g_cache_mutex  ;
 773 static int g_conn_open  =    0;
 774 static int g_conn_fail  =    0;
 775 static int g_conn_succeed  =    0;
 776 static int g_conn_active  =    0;
 777 int g_cache_hits  =    0;
 778 int g_cache_misses  =    0;
 779 long long g_bytes_sent  =    0LL;
 780 static unsigned int g_timer_interval  =    5U;
 781 int allow_file(char *file ) 
 782 { char *p ;
 783   int allow ;
 784   char *tmp ;
 785   char *tmp___0 ;
 786 
 787   {
 788   p = file;
 789   allow = 1;
 790   if ((int )*(file + 0) != 47) {
 791     allow = 0;
 792   }
 793   while (1) {
 794     if (allow) {
 795       if (! ((int )*p != 0)) {
 796         break;
 797       }
 798     } else {
 799       break;
 800     }
 801     if (97 <= (int )*p) {
 802       if (! ((int )*p <= 122)) {
 803         goto _L___1;
 804       }
 805     } else {
 806       _L___1: /* CIL Label */ 
 807       if (65 <= (int )*p) {
 808         if (! ((int )*p <= 90)) {
 809           goto _L___0;
 810         }
 811       } else {
 812         _L___0: /* CIL Label */ 
 813         if (48 <= (int )*p) {
 814           if (! ((int )*p <= 57)) {
 815             goto _L;
 816           }
 817         } else {
 818           _L: /* CIL Label */ 
 819           tmp = strchr("/._", (int )*p);
 820           if (! ((unsigned int )tmp != (unsigned int )((void *)0))) {
 821             allow = 0;
 822           }
 823         }
 824       }
 825     }
 826     p ++;
 827   }
 828   if (allow) {
 829     tmp___0 = strstr((char const   *)file, "/.");
 830     if ((unsigned int )tmp___0 != (unsigned int )((void *)0)) {
 831       allow = 0;
 832     }
 833   }
 834   return (allow);
 835 }
 836 }
 837 char *get_request_filename(http_request *request ) 
 838 { char *result ;
 839   int tmp ;
 840   int tmp___0 ;
 841 
 842   {
 843   result = (char *)((void *)0);
 844   tmp___0 = http_parse(request);
 845   if (tmp___0) {
 846     if (! request->closed) {
 847       if (! ((int )request->url[0] == 46)) {
 848         assert_failed((char *)"knot.c", 131U, "get_request_filename", (char *)"request->url[0] == \'.\'");
 849       }
 850       tmp = allow_file(request->url + 1);
 851       if (tmp) {
 852         result = request->url;
 853       }
 854     }
 855   }
 856   return (result);
 857 }
 858 }
 859 int get_request_fd(http_request *request ) 
 860 { char *filename ;
 861   char *tmp ;
 862   int fd ;
 863 
 864   {
 865   tmp = get_request_filename(request);
 866   filename = tmp;
 867   fd = -1;
 868   if ((unsigned int )filename != (unsigned int )((void *)0)) {
 869     fd = open((char const   *)filename, 0);
 870   }
 871   return (fd);
 872 }
 873 }
 874 int process_client_nocache(http_request *request , int client ) 
 875 { int fd ;
 876   int tmp ;
 877   int success ;
 878   char buf[8192] ;
 879   char *pos ;
 880   int n ;
 881   int ret ;
 882   int written ;
 883 
 884   {
 885   tmp = get_request_fd(request);
 886   fd = tmp;
 887   success = 1;
 888   if (fd >= 0) {
 889     n = 1;
 890     written = 0;
 891     while (n > 0) {
 892       n = read(fd, (void *)(buf), sizeof(buf));
 893       if (n < 0) {
 894         perror("read");
 895         success = 0;
 896         break;
 897       }
 898       pos = buf;
 899       while (n > 0) {
 900         ret = write(client, (void const   *)pos, (unsigned int )n);
 901         if (ret < 0) {
 902           perror("write");
 903           success = 0;
 904           break;
 905         } else {
 906           if (ret == 0) {
 907             n = 0;
 908             break;
 909           } else {
 910             written += ret;
 911             pos += ret;
 912             n -= ret;
 913           }
 914         }
 915       }
 916     }
 917     if (g_use_timer) {
 918       g_bytes_sent += (long long )written;
 919     }
 920     close(fd);
 921   }
 922   return (success);
 923 }
 924 }
 925 cache_entry *get_request_entry(http_request *request ) 
 926 { char *filename ;
 927   char *tmp ;
 928   cache_entry *tmp___0 ;
 929 
 930   {
 931   tmp = get_request_filename(request);
 932   filename = tmp;
 933   if ((unsigned int )filename == (unsigned int )((void *)0)) {
 934     return ((cache_entry *)((void *)0));
 935   }
 936   tmp___0 = cache_get(filename);
 937   return (tmp___0);
 938 }
 939 }
 940 int process_client_cache(http_request *request , int client ) 
 941 { int success ;
 942   cache_entry *entry ;
 943   ssize_t written ;
 944   int n ;
 945   char *p ;
 946   char *bigstuff ;
 947   void *tmp ;
 948   int *tmp___0 ;
 949   int *tmp___1 ;
 950 
 951   {
 952   success = 0;
 953   entry = get_request_entry(request);
 954   if ((unsigned int )entry != (unsigned int )((void *)0)) {
 955     written = 0;
 956     n = 0;
 957     bigstuff = (char *)((void *)0);
 958     if (g_force_thrashing) {
 959       tmp = malloc(734003200U);
 960       bigstuff = (char *)tmp;
 961       if (! bigstuff) {
 962         return (0);
 963       }
 964       p = (bigstuff + 734003200) - 3;
 965       while ((unsigned int )p > (unsigned int )bigstuff) {
 966         *p = (char)10;
 967         p -= 4096;
 968       }
 969       sched_yield();
 970       free((void *)bigstuff);
 971       bigstuff = (char *)((void *)0);
 972     }
 973     while (1) {
 974       n = write(client, (void const   *)(entry->data + written), (unsigned int )(entry->total - written));
 975       if (n > 0) {
 976         written += n;
 977         g_bytes_sent += (long long )n;
 978       }
 979       if (n > 0) {
 980         if (! (written < entry->total)) {
 981           break;
 982         }
 983       } else {
 984         break;
 985       }
 986     }
 987     if (n < 0) {
 988       tmp___0 = __errno_location();
 989       if (*tmp___0 != 32) {
 990         tmp___1 = __errno_location();
 991         if (*tmp___1 != 104) {
 992           perror("warning: write");
 993         }
 994       }
 995     }
 996     if (g_force_thrashing) {
 997       if (bigstuff) {
 998         free((void *)bigstuff);
 999       }
1000     }
1001     success = 1;
1002   }
1003   cache_entry_release(entry);
1004   return (success);
1005 }
1006 }
1007 void process_client(int client ) 
1008 { http_request request ;
1009   int done ;
1010   int numrequests ;
1011   int success ;
1012   int tmp ;
1013   int tmp___0 ;
1014   int tmp___1 ;
1015   int len ;
1016   size_t tmp___2 ;
1017   ssize_t tmp___3 ;
1018 
1019   {
1020   done = 0;
1021   numrequests = 0;
1022   http_init(& request, client);
1023   while (! done) {
1024     if (g_use_cache) {
1025       tmp = process_client_cache(& request, client);
1026       tmp___1 = tmp;
1027     } else {
1028       tmp___0 = process_client_nocache(& request, client);
1029       tmp___1 = tmp___0;
1030     }
1031     success = tmp___1;
1032     if (success) {
1033       g_conn_succeed ++;
1034     } else {
1035       g_conn_fail ++;
1036     }
1037     numrequests ++;
1038     if (! success) {
1039       if (! request.closed) {
1040         tmp___2 = strlen("HTTP/1.1 404 Not Found\r\nConnection: close\r\n");
1041         len = (int )tmp___2;
1042         tmp___3 = write(client, (void const   *)"HTTP/1.1 404 Not Found\r\nConnection: close\r\n",
1043                         (unsigned int )len);
1044         if (! (tmp___3 != len)) {
1045           g_bytes_sent += (long long )len;
1046         }
1047       }
1048     }
1049     if (! success) {
1050       done = 1;
1051     } else {
1052       if ((int )request.version == 0) {
1053         done = 1;
1054       }
1055     }
1056   }
1057   if (numrequests > 1) {
1058     g_conn_fail --;
1059   }
1060   return;
1061 }
1062 }
1063 void *thread_process_client(void *arg ) 
1064 { int c ;
1065 
1066   {
1067   c = (int )arg;
1068   process_client(c);
1069   g_conn_active --;
1070   close(c);
1071   return ((void *)0);
1072 }
1073 }
1074 void accept_loop(int id , int s ) ;
1075 static int attr_init_done  =    0;
1076 static pthread_attr_t attr  ;
1077 static pthread_t thread  ;
1078 void accept_loop(int id , int s ) 
1079 { struct sockaddr_in caddr ;
1080   int len ;
1081   int c ;
1082   int optval ;
1083   int tmp ;
1084   int rv ;
1085   int tmp___0 ;
1086 
1087   {
1088   while (1) {
1089     len = (int )sizeof(caddr);
1090     c = 0;
1091     c = accept(s, (struct sockaddr * __restrict  )((struct sockaddr *)(& caddr)),
1092                (socklen_t * __restrict  )(& len));
1093     if (c < 0) {
1094       perror("accept");
1095       continue;
1096     }
1097     g_conn_open ++;
1098     g_conn_active ++;
1099     optval = 1;
1100     tmp = setsockopt(c, 6, 1, (void const   *)(& optval), sizeof(optval));
1101     if (tmp < 0) {
1102       perror("setsockopt");
1103       continue;
1104     }
1105     if (g_spawn_on_demand) {
1106       if (! attr_init_done) {
1107         pthread_attr_init(& attr);
1108         rv = pthread_attr_setdetachstate(& attr, 1);
1109         if (! (rv == 0)) {
1110           assert_failed((char *)"knot.c", 472U, "accept_loop", (char *)"rv == 0");
1111         }
1112         attr_init_done = 1;
1113       }
1114       tmp___0 = pthread_create((pthread_t * __restrict  )(& thread), (pthread_attr_t const   * __restrict  )(& attr),
1115                                & thread_process_client, (void * __restrict  )((void *)c));
1116       if (tmp___0 < 0) {
1117         g_conn_fail ++;
1118         g_conn_active --;
1119         close(c);
1120       }
1121     } else {
1122       process_client(c);
1123       close(c);
1124       g_conn_active --;
1125     }
1126   }
1127 }
1128 }
1129 void *thread_main_autospawn(void *arg ) 
1130 { int s ;
1131 
1132   {
1133   s = (int )arg;
1134   accept_loop(-1, s);
1135   return ((void *)0);
1136 }
1137 }
1138 void *thread_main(void *arg ) ;
1139 void *thread_main(void *arg ) 
1140 { thread_args *targs ;
1141   int id ;
1142   int s ;
1143 
1144   {
1145   targs = (thread_args *)arg;
1146   id = targs->id;
1147   s = targs->s;
1148   free((void *)targs);
1149   accept_loop(id, s);
1150   return ((void *)0);
1151 }
1152 }
1153 int main(int argc , char **argv ) 
1154 { struct sockaddr_in saddr ;
1155   int s ;
1156   int nthreads ;
1157   int i ;
1158   int val ;
1159   int tmp ;
1160   int tmp___0 ;
1161   int tmp___1 ;
1162   int tmp___2 ;
1163   int tmp___3 ;
1164   int tmp___4 ;
1165   pthread_t thread___0 ;
1166   int tmp___5 ;
1167   thread_args *targs ;
1168   pthread_t thread___1 ;
1169   void *tmp___6 ;
1170   int tmp___7 ;
1171   unsigned long long start ;
1172   unsigned long long now ;
1173   long long tmp___8 ;
1174   long long bytes_sent ;
1175   int conn_open ;
1176   int conn_succeed ;
1177   int conn_fail ;
1178   int conn_active ;
1179   int cache_hits ;
1180   int cache_misses ;
1181   long long tmp___9 ;
1182 
1183   {
1184   s = 0;
1185   nthreads = 0;
1186   i = 0;
1187   val = 1;
1188   if (argc != 3) {
1189     if (argc != 4) {
1190       fprintf((FILE * __restrict  )stderr, (char const   * __restrict  )"usage: %s port threads [root]\n",
1191               *(argv + 0));
1192       exit(1);
1193     }
1194   }
1195   if (argc == 4) {
1196     printf((char const   * __restrict  )"setting root directory to [%s]\n", *(argv + 3));
1197     tmp = chdir((char const   *)*(argv + 3));
1198     if (tmp < 0) {
1199       perror("chdir");
1200       exit(1);
1201     }
1202   }
1203   pthread_mutex_init(& g_cache_mutex, (pthread_mutexattr_t const   *)((void *)0));
1204   cache_init();
1205   tmp___0 = strcmp((char const   *)*(argv + 2), "auto");
1206   if (tmp___0) {
1207     nthreads = atoi((char const   *)*(argv + 2));
1208     if (nthreads <= 0) {
1209       fprintf((FILE * __restrict  )stderr, (char const   * __restrict  )"nthreads should be > 0 or \'auto\'\n");
1210       exit(1);
1211     }
1212   } else {
1213     g_spawn_on_demand = 1;
1214   }
1215   s = socket(2, 1, 0);
1216   if (s < 0) {
1217     perror("socket");
1218     exit(1);
1219   }
1220   val = 1;
1221   tmp___1 = setsockopt(s, 1, 2, (void const   *)(& val), sizeof(val));
1222   if (tmp___1 < 0) {
1223     perror("setsockopt");
1224     exit(1);
1225   }
1226   saddr.sin_family = (unsigned short)2;
1227   tmp___2 = atoi((char const   *)*(argv + 1));
1228   saddr.sin_port = htons((unsigned short )tmp___2);
1229   saddr.sin_addr.s_addr = 0U;
1230   tmp___3 = bind(s, (struct sockaddr  const  *)((struct sockaddr *)(& saddr)), sizeof(saddr));
1231   if (tmp___3 < 0) {
1232     perror("bind");
1233     exit(1);
1234   }
1235   tmp___4 = listen(s, 50000);
1236   if (tmp___4 < 0) {
1237     perror("listen");
1238     exit(1);
1239   }
1240   if (g_spawn_on_demand) {
1241     tmp___5 = pthread_create((pthread_t * __restrict  )(& thread___0), (pthread_attr_t const   * __restrict  )((void *)0),
1242                              & thread_main_autospawn, (void * __restrict  )((void *)s));
1243     if (tmp___5 < 0) {
1244       perror("pthread_create");
1245     }
1246   } else {
1247     printf((char const   * __restrict  )"Spawning %d threads....\n", nthreads);
1248     i = 0;
1249     while (i < nthreads) {
1250       targs = (thread_args *)((void *)0);
1251       tmp___6 = malloc(sizeof(*targs));
1252       targs = (thread_args *)tmp___6;
1253       if (! ((unsigned int )targs != (unsigned int )((void *)0))) {
1254         assert_failed((char *)"knot.c", 623U, "main", (char *)"targs != ((void *)0)");
1255       }
1256       targs->id = i;
1257       targs->s = s;
1258       tmp___7 = pthread_create((pthread_t * __restrict  )(& thread___1), (pthread_attr_t const   * __restrict  )((void *)0),
1259                                & thread_main, (void * __restrict  )((void *)targs));
1260       if (tmp___7 < 0) {
1261         perror("pthread_create");
1262       }
1263       i ++;
1264     }
1265     printf((char const   * __restrict  )"done\n");
1266   }
1267   if (g_use_timer) {
1268     tmp___8 = current_usecs();
1269     start = (unsigned long long )tmp___8;
1270     sleep(g_timer_interval);
1271     while (1) {
1272       tmp___9 = current_usecs();
1273       now = (unsigned long long )tmp___9;
1274       bytes_sent = g_bytes_sent;
1275       g_bytes_sent = 0LL;
1276       conn_open = g_conn_open;
1277       g_conn_open = 0;
1278       conn_succeed = g_conn_succeed;
1279       g_conn_succeed = 0;
1280       conn_fail = g_conn_fail;
1281       g_conn_fail = 0;
1282       conn_active = g_conn_active;
1283       cache_hits = g_cache_hits;
1284       g_cache_hits = 0;
1285       cache_misses = g_cache_misses;
1286       g_cache_misses = 0;
1287       printf((char const   * __restrict  )"rate: %.3g Mbits/sec   %.0f open/sec   %.0f succ/sec   %.0f fail/sec   active: %d   misses: %d   hitrate: %.1f%%   ",
1288              (((double )bytes_sent * (double )8) * (double )1000000) / ((double )(now - start) * (double )1048576),
1289              ((double )conn_open * (double )1000000) / (double )(now - start), ((double )conn_succeed * (double )1000000) / (double )(now - start),
1290              ((double )conn_fail * (double )1000000) / (double )(now - start), conn_active,
1291              cache_misses, ((double )100 * (double )cache_hits) / (double )(cache_hits + cache_misses));
1292       printf((char const   * __restrict  )"\n");
1293       start = now;
1294       sleep(g_timer_interval);
1295     }
1296   }
1297   pthread_exit((void *)0);
1298   return (0);
1299 }
1300 }
1301 /* compiler builtin: 
1302    void __builtin_va_end(__builtin_va_list  ) ;  */
1303 /* compiler builtin: 
1304    void __builtin_va_start(__builtin_va_list  ) ;  */
1305 #pragma merger(0,"/tmp/cil-Ps5u9k6i.i","")
1306 extern  __attribute__((__nothrow__)) long syscall(long __sysno  , ...) ;
1307 extern  __attribute__((__nothrow__)) int ( /* format attribute */  vsnprintf)(char * __restrict  __s ,
1308                                                                               size_t __maxlen ,
1309                                                                               char const   * __restrict  __format ,
1310                                                                               __gnuc_va_list __arg ) ;
1311 extern  __attribute__((__nothrow__, __noreturn__)) void abort(void) ;
1312 cpu_tick_t real_start_ticks ;
1313 cpu_tick_t virtual_start_ticks ;
1314 void init_cycle_clock(void)  __attribute__((__constructor__)) ;
1315 void ( /* format attribute */  real_debug)(char const   *func , char const   *fmt 
1316                                            , ...) ;
1317 void ( /* format attribute */  real_toutput)(int tid , char const   *func , char const   *fmt 
1318                                              , ...) ;
1319 void ( /* format attribute */  output)(char *fmt  , ...) ;
1320 void ( /* format attribute */  warning)(char *fmt  , ...) ;
1321 void ( /* format attribute */  fatal)(char *fmt  , ...) ;
1322 cpu_tick_t ticks_diff ;
1323 cpu_tick_t ticks_rdiff ;
1324 void init_debug(void)  __attribute__((__constructor__)) ;
1325 int conf_no_debug ;
1326 cpu_tick_t ticks_diff  =    (cpu_tick_t )0;
1327 cpu_tick_t ticks_rdiff  =    (cpu_tick_t )0;
1328 static cpu_tick_t vnow_prev  =    (cpu_tick_t )0;
1329 static cpu_tick_t vrnow_prev  =    (cpu_tick_t )0;
1330 void init_debug(void)  __attribute__((__constructor__)) ;
1331 void init_debug(void) 
1332 { 
1333 
1334   {
1335   init_cycle_clock();
1336   vnow_prev = virtual_start_ticks;
1337   vrnow_prev = real_start_ticks;
1338   return;
1339 }
1340 }
1341 __inline static void output_aux(int tid , char const   *func , char const   *fmt ,
1342                                 va_list ap ) 
1343 { char str[200] ;
1344   int len ;
1345   int ret ;
1346   cpu_tick_t rnow ;
1347   cpu_tick_t vrnow ;
1348   cpu_tick_t rafter ;
1349 
1350   {
1351   len = 0;
1352   __asm__  volatile   ("rdtsc": "=A" (rnow));
1353   vrnow = rnow - ticks_rdiff;
1354   if (tid != -12312) {
1355     ret = snprintf((char * __restrict  )(str + len), (sizeof(str) - 1U) - (unsigned int )len,
1356                    (char const   * __restrict  )"%5d %12lld us (%+8lld cyc): ", tid,
1357                    (vrnow - real_start_ticks) / ticks_per_microsecond, vrnow - vrnow_prev);
1358     if (! (ret > 0)) {
1359       assert_failed((char *)"../../util/debug.c", 67U, "output_aux", (char *)"ret > 0");
1360     }
1361     len += ret;
1362   }
1363   if (func) {
1364     ret = snprintf((char * __restrict  )(str + len), (sizeof(str) - 1U) - (unsigned int )len,
1365                    (char const   * __restrict  )"%s() - ", func);
1366     if (! (ret > 0)) {
1367       assert_failed((char *)"../../util/debug.c", 74U, "output_aux", (char *)"ret > 0");
1368     }
1369     len += ret;
1370   }
1371   ret = vsnprintf((char * __restrict  )(str + len), (sizeof(str) - 1U) - (unsigned int )len,
1372                   (char const   * __restrict  )fmt, ap);
1373   if (! (ret > 0)) {
1374     assert_failed((char *)"../../util/debug.c", 80U, "output_aux", (char *)"ret > 0");
1375   }
1376   len += ret;
1377   syscall(4L, 2, str, len);
1378   vrnow_prev = vrnow;
1379   __asm__  volatile   ("rdtsc": "=A" (rafter));
1380   ticks_rdiff += rafter - rnow;
1381   return;
1382 }
1383 }
1384 void ( /* format attribute */  real_toutput)(int tid , char const   *func , char const   *fmt 
1385                                              , ...) 
1386 { va_list ap ;
1387 
1388   {
1389   if (conf_no_debug) {
1390     return;
1391   }
1392   __builtin_va_start(ap, fmt);
1393   output_aux(tid, func, fmt, ap);
1394   __builtin_va_end(ap);
1395   return;
1396 }
1397 }
1398 void ( /* format attribute */  real_debug)(char const   *func , char const   *fmt 
1399                                            , ...) 
1400 { va_list ap ;
1401 
1402   {
1403   if (conf_no_debug) {
1404     return;
1405   }
1406   __builtin_va_start(ap, fmt);
1407   output_aux(-12312, func, fmt, ap);
1408   __builtin_va_end(ap);
1409   return;
1410 }
1411 }
1412 void ( /* format attribute */  output)(char *fmt  , ...) 
1413 { va_list ap ;
1414 
1415   {
1416   __builtin_va_start(ap, fmt);
1417   output_aux(-12312, (char const   *)((void *)0), (char const   *)fmt, ap);
1418   __builtin_va_end(ap);
1419   return;
1420 }
1421 }
1422 void ( /* format attribute */  warning)(char *fmt  , ...) 
1423 { va_list ap ;
1424 
1425   {
1426   __builtin_va_start(ap, fmt);
1427   output_aux(-12312, (char const   *)((void *)0), (char const   *)fmt, ap);
1428   __builtin_va_end(ap);
1429   return;
1430 }
1431 }
1432 void ( /* format attribute */  fatal)(char *fmt  , ...) 
1433 { va_list ap ;
1434 
1435   {
1436   __builtin_va_start(ap, fmt);
1437   output_aux(-12312, (char const   *)((void *)0), (char const   *)fmt, ap);
1438   __builtin_va_end(ap);
1439   abort();
1440 }
1441 }
1442 extern char const   *__progname ;
1443 void assert_failed(char *file , unsigned int line , char const   *func , char *expr ) 
1444 { char const   *tmp ;
1445   char const   *tmp___0 ;
1446 
1447   {
1448   if (__progname) {
1449     tmp = ": ";
1450   } else {
1451     tmp = "";
1452   }
1453   if (__progname) {
1454     tmp___0 = __progname;
1455   } else {
1456     tmp___0 = "";
1457   }
1458   fatal((char *)"%s%s%s:%u: %s:  Assertion `%s\' failed.\n", tmp___0, tmp, file, line,
1459         func, expr);
1460   abort();
1461 }
1462 }
1463 #pragma merger(0,"/tmp/cil-jfY5An30.i","")
1464 extern  __attribute__((__nothrow__)) int gettimeofday(struct timeval * __restrict  __tv ,
1465                                                       __timezone_ptr_t __tz )  __attribute__((__nonnull__(1))) ;
1466 cpu_tick_t ticks_per_second ;
1467 cpu_tick_t ticks_per_millisecond ;
1468 cpu_tick_t ticks_per_nanosecond ;
1469 cpu_tick_t ticks_per_nanosecond  =    (cpu_tick_t )((double )6 * 10e2);
1470 cpu_tick_t ticks_per_microsecond  =    (cpu_tick_t )((double )6 * 10e5);
1471 cpu_tick_t ticks_per_millisecond  =    (cpu_tick_t )((double )6 * 10e8);
1472 cpu_tick_t ticks_per_second  =    (cpu_tick_t )((double )6 * 10e11);
1473 cpu_tick_t real_start_ticks  =    (cpu_tick_t )0;
1474 cpu_tick_t virtual_start_ticks  =    (cpu_tick_t )0;
1475 static long long timing_loop(void) 
1476 { struct timeval start_tv ;
1477   struct timeval end_tv ;
1478   long usec ;
1479   cpu_tick_t start_ticks ;
1480   cpu_tick_t end_ticks ;
1481 
1482   {
1483   while (1) {
1484     gettimeofday((struct timeval * __restrict  )(& start_tv), (struct timezone * __restrict  )((void *)0));
1485     usec = start_tv.tv_usec;
1486     while (1) {
1487       gettimeofday((struct timeval * __restrict  )(& start_tv), (struct timezone * __restrict  )((void *)0));
1488       __asm__  volatile   ("rdtsc": "=A" (start_ticks));
1489       if (! (start_tv.tv_usec == usec)) {
1490         break;
1491       }
1492     }
1493     while (1) {
1494       gettimeofday((struct timeval * __restrict  )(& end_tv), (struct timezone * __restrict  )((void *)0));
1495       __asm__  volatile   ("rdtsc": "=A" (end_ticks));
1496       if (! (1e6 * (double )((long long )end_tv.tv_sec) + (double )end_tv.tv_usec < (1e6 * (double )((long long )start_tv.tv_sec) + (double )start_tv.tv_usec) + (double )1000)) {
1497         break;
1498       }
1499     }
1500     if (1e6 * (double )((long long )end_tv.tv_sec) + (double )end_tv.tv_usec == (1e6 * (double )((long long )start_tv.tv_sec) + (double )start_tv.tv_usec) + (double )1000) {
1501       break;
1502     }
1503   }
1504   return (end_ticks - start_ticks);
1505 }
1506 }
1507 static int init_done  =    0;
1508 void init_cycle_clock(void)  __attribute__((__constructor__)) ;
1509 void init_cycle_clock(void) 
1510 { int i ;
1511   long long val ;
1512   long long tmp ;
1513 
1514   {
1515   val = 0LL;
1516   if (init_done) {
1517     return;
1518   }
1519   init_done = 1;
1520   i = 0;
1521   while (i < 10) {
1522     tmp = timing_loop();
1523     val += tmp;
1524     i ++;
1525   }
1526   val /= 10LL;
1527   ticks_per_second = (long long )((double )val * 1e3);
1528   ticks_per_millisecond = (long long )((double )val * 1e0);
1529   ticks_per_microsecond = (long long )((double )val / 1e3);
1530   ticks_per_nanosecond = (long long )((double )val / 1e6);
1531   __asm__  volatile   ("rdtsc": "=A" (real_start_ticks));
1532   __asm__  volatile   ("rdtsc": "=A" (virtual_start_ticks));
1533   return;
1534 }
1535 }
1536 #pragma merger(0,"/tmp/cil-rxsNrgMK.i","")
1537 void PL_HashTableDestroy(PLHashTable *ht ) ;
1538 void *PL_HashTableLookupConst(PLHashTable *ht , void const   *key ) ;
1539 int PL_HashTableEnumerateEntries(PLHashTable *ht , PRIntn (*f)(PLHashEntry *he , PRIntn i ,
1540                                                                void *arg ) , void *arg ) ;
1541 PLHashEntry **PL_HashTableRawLookup(PLHashTable *ht , PLHashNumber keyHash , void const   *key ) ;
1542 PLHashEntry **PL_HashTableRawLookupConst(PLHashTable *ht , PLHashNumber keyHash ,
1543                                          void const   *key ) ;
1544 PLHashEntry *PL_HashTableRawAdd(PLHashTable *ht , PLHashEntry **hep , PLHashNumber keyHash ,
1545                                 void const   *key , void *value ) ;
1546 void PL_HashTableRawRemove(PLHashTable *ht , PLHashEntry **hep , PLHashEntry *he ) ;
1547 int PL_HashTableDump(PLHashTable *ht , PRIntn (*dump)(PLHashEntry *he , PRIntn i ,
1548                                                       void *arg ) , FILE *fp ) ;
1549 extern  __attribute__((__nothrow__)) void *memset(void *__s , int __c , size_t __n )  __attribute__((__nonnull__(1))) ;
1550 PRIntn PR_CeilingLog2(PRUint32 n ) 
1551 { PRIntn log2 ;
1552 
1553   {
1554   log2 = 0;
1555   if (n & (n - 1U)) {
1556     log2 ++;
1557   }
1558   if (n >> 16) {
1559     log2 += 16;
1560     n >>= 16;
1561   }
1562   if (n >> 8) {
1563     log2 += 8;
1564     n >>= 8;
1565   }
1566   if (n >> 4) {
1567     log2 += 4;
1568     n >>= 4;
1569   }
1570   if (n >> 2) {
1571     log2 += 2;
1572     n >>= 2;
1573   }
1574   if (n >> 1) {
1575     log2 ++;
1576   }
1577   return (log2);
1578 }
1579 }
1580 static void *DefaultAllocTable(void *pool , PRSize size ) 
1581 { void *tmp ;
1582 
1583   {
1584   tmp = malloc((unsigned int )size);
1585   return (tmp);
1586 }
1587 }
1588 static void DefaultFreeTable(void *pool , void *item ) 
1589 { 
1590 
1591   {
1592   free(item);
1593   return;
1594 }
1595 }
1596 static PLHashEntry *DefaultAllocEntry(void *pool , void const   *key ) 
1597 { void *tmp ;
1598 
1599   {
1600   tmp = malloc(sizeof(PLHashEntry ));
1601   return ((PLHashEntry *)tmp);
1602 }
1603 }
1604 static void DefaultFreeEntry(void *pool , PLHashEntry *he , PRUintn flag ) 
1605 { 
1606 
1607   {
1608   if (flag == 1U) {
1609     free((void *)he);
1610   }
1611   return;
1612 }
1613 }
1614 static PLHashAllocOps defaultHashAllocOps  =    {& DefaultAllocTable, & DefaultFreeTable, & DefaultAllocEntry, & DefaultFreeEntry};
1615 PLHashTable *PL_NewHashTable(PRUint32 n ,
1616                              PLHashNumber (*keyHash)(void const   *key ) , PRIntn (*keyCompare)(void const   *v1 ,
1617                                                                                                 void const   *v2 ) ,
1618                              PRIntn (*valueCompare)(void const   *v1 , void const   *v2 ) ,
1619                              PLHashAllocOps const   *allocOps , void *allocPriv ) 
1620 { PLHashTable *ht ;
1621   PRSize nb ;
1622   PRIntn tmp ;
1623   void *tmp___0 ;
1624   void *tmp___1 ;
1625 
1626   {
1627   if (n <= (PRUint32 )(1 << 4)) {
1628     n = 4U;
1629   } else {
1630     tmp = PR_CeilingLog2(n);
1631     n = (unsigned int )tmp;
1632     if ((int )n < 0) {
1633       return ((PLHashTable *)0);
1634     }
1635   }
1636   if (! allocOps) {
1637     allocOps = (PLHashAllocOps const   *)(& defaultHashAllocOps);
1638   }
1639   tmp___0 = (*(allocOps->allocTable))(allocPriv, (int )sizeof(*ht));
1640   ht = (PLHashTable *)tmp___0;
1641   if (! ht) {
1642     return ((PLHashTable *)0);
1643   }
1644   memset((void *)ht, 0, sizeof(*ht));
1645   ht->shift = 32U - n;
1646   n = (unsigned int )(1 << n);
1647   nb = (int )(n * sizeof(PLHashEntry *));
1648   tmp___1 = (*(allocOps->allocTable))(allocPriv, nb);
1649   ht->buckets = (PLHashEntry **)tmp___1;
1650   if (! ht->buckets) {
1651     (*(allocOps->freeTable))(allocPriv, (void *)ht);
1652     return ((PLHashTable *)0);
1653   }
1654   memset((void *)ht->buckets, 0, (unsigned int )nb);
1655   ht->keyHash = keyHash;
1656   ht->keyCompare = keyCompare;
1657   ht->valueCompare = valueCompare;
1658   ht->allocOps = allocOps;
1659   ht->allocPriv = allocPriv;
1660   return (ht);
1661 }
1662 }
1663 void PL_HashTableDestroy(PLHashTable *ht ) 
1664 { PRUint32 i ;
1665   PRUint32 n ;
1666   PLHashEntry *he ;
1667   PLHashEntry *next ;
1668   PLHashAllocOps const   *allocOps ;
1669   void *allocPriv ;
1670 
1671   {
1672   allocOps = ht->allocOps;
1673   allocPriv = ht->allocPriv;
1674   n = (unsigned int )(1 << (32U - ht->shift));
1675   i = 0U;
1676   while (i < n) {
1677     he = *(ht->buckets + i);
1678     while (he) {
1679       next = he->next;
1680       (*(allocOps->freeEntry))(allocPriv, he, 1U);
1681       he = next;
1682     }
1683     i ++;
1684   }
1685   (*(allocOps->freeTable))(allocPriv, (void *)ht->buckets);
1686   (*(allocOps->freeTable))(allocPriv, (void *)ht);
1687   return;
1688 }
1689 }
1690 PLHashEntry **PL_HashTableRawLookup(PLHashTable *ht , PLHashNumber keyHash , void const   *key ) 
1691 { PLHashEntry *he ;
1692   PLHashEntry **hep ;
1693   PLHashEntry **hep0 ;
1694   PLHashNumber h ;
1695   PRIntn tmp ;
1696 
1697   {
1698   h = keyHash * 2654435769U;
1699   h >>= ht->shift;
1700   hep0 = ht->buckets + h;
1701   hep = hep0;
1702   while (1) {
1703     he = *hep;
1704     if (! ((unsigned int )he != (unsigned int )((PLHashEntry *)0))) {
1705       break;
1706     }
1707     if (he->keyHash == keyHash) {
1708       tmp = (*(ht->keyCompare))(key, he->key);
1709       if (tmp) {
1710         if ((unsigned int )hep != (unsigned int )hep0) {
1711           *hep = he->next;
1712           he->next = *hep0;
1713           *hep0 = he;
1714         }
1715         return (hep0);
1716       }
1717     }
1718     hep = & he->next;
1719   }
1720   return (hep);
1721 }
1722 }
1723 PLHashEntry **PL_HashTableRawLookupConst(PLHashTable *ht , PLHashNumber keyHash ,
1724                                          void const   *key ) 
1725 { PLHashEntry *he ;
1726   PLHashEntry **hep ;
1727   PLHashNumber h ;
1728   PRIntn tmp ;
1729 
1730   {
1731   h = keyHash * 2654435769U;
1732   h >>= ht->shift;
1733   hep = ht->buckets + h;
1734   while (1) {
1735     he = *hep;
1736     if (! ((unsigned int )he != (unsigned int )((PLHashEntry *)0))) {
1737       break;
1738     }
1739     if (he->keyHash == keyHash) {
1740       tmp = (*(ht->keyCompare))(key, he->key);
1741       if (tmp) {
1742         break;
1743       }
1744     }
1745     hep = & he->next;
1746   }
1747   return (hep);
1748 }
1749 }
1750 PLHashEntry *PL_HashTableRawAdd(PLHashTable *ht , PLHashEntry **hep , PLHashNumber keyHash ,
1751                                 void const   *key , void *value ) 
1752 { PRUint32 i ;
1753   PRUint32 n ;
1754   PLHashEntry *he ;
1755   PLHashEntry *next ;
1756   PLHashEntry **oldbuckets ;
1757   PRSize nb ;
1758   void *tmp ;
1759 
1760   {
1761   n = (unsigned int )(1 << (32U - ht->shift));
1762   if (ht->nentries >= n - (n >> 3)) {
1763     oldbuckets = ht->buckets;
1764     nb = (int )((2U * n) * sizeof(PLHashEntry *));
1765     tmp = (*((ht->allocOps)->allocTable))(ht->allocPriv, nb);
1766     ht->buckets = (PLHashEntry **)tmp;
1767     if (! ht->buckets) {
1768       ht->buckets = oldbuckets;
1769       return ((PLHashEntry *)0);
1770     }
1771     memset((void *)ht->buckets, 0, (unsigned int )nb);
1772     (ht->shift) --;
1773     i = 0U;
1774     while (i < n) {
1775       he = *(oldbuckets + i);
1776       while (he) {
1777         next = he->next;
1778         hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
1779         while (1) {
1780           break;
1781         }
1782         he->next = (PLHashEntry *)0;
1783         *hep = he;
1784         he = next;
1785       }
1786       i ++;
1787     }
1788     (*((ht->allocOps)->freeTable))(ht->allocPriv, (void *)oldbuckets);
1789     hep = PL_HashTableRawLookup(ht, keyHash, key);
1790   }
1791   he = (*((ht->allocOps)->allocEntry))(ht->allocPriv, key);
1792   if (! he) {
1793     return ((PLHashEntry *)0);
1794   }
1795   he->keyHash = keyHash;
1796   he->key = key;
1797   he->value = value;
1798   he->next = *hep;
1799   *hep = he;
1800   (ht->nentries) ++;
1801   return (he);
1802 }
1803 }
1804 PLHashEntry *PL_HashTableAdd(PLHashTable *ht , void const   *key , void *value ) 
1805 { PLHashNumber keyHash ;
1806   PLHashEntry *he ;
1807   PLHashEntry **hep ;
1808   PRIntn tmp ;
1809   PLHashEntry *tmp___0 ;
1810 
1811   {
1812   keyHash = (*(ht->keyHash))(key);
1813   hep = PL_HashTableRawLookup(ht, keyHash, key);
1814   he = *hep;
1815   if ((unsigned int )he != (unsigned int )((PLHashEntry *)0)) {
1816     tmp = (*(ht->valueCompare))((void const   *)he->value, (void const   *)value);
1817     if (tmp) {
1818       return (he);
1819     }
1820     if (he->value) {
1821       (*((ht->allocOps)->freeEntry))(ht->allocPriv, he, 0U);
1822     }
1823     he->value = value;
1824     return (he);
1825   }
1826   tmp___0 = PL_HashTableRawAdd(ht, hep, keyHash, key, value);
1827   return (tmp___0);
1828 }
1829 }
1830 void PL_HashTableRawRemove(PLHashTable *ht , PLHashEntry **hep , PLHashEntry *he ) 
1831 { PRUint32 i ;
1832   PRUint32 n ;
1833   PLHashEntry *next ;
1834   PLHashEntry **oldbuckets ;
1835   PRSize nb ;
1836   void *tmp ;
1837   PRUint32 tmp___0 ;
1838 
1839   {
1840   *hep = he->next;
1841   (*((ht->allocOps)->freeEntry))(ht->allocPriv, he, 1U);
1842   n = (unsigned int )(1 << (32U - ht->shift));
1843   (ht->nentries) --;
1844   if (n > (PRUint32 )(1 << 4)) {
1845     tmp___0 = n >> 2;
1846   } else {
1847     tmp___0 = 0U;
1848   }
1849   if (ht->nentries < tmp___0) {
1850     oldbuckets = ht->buckets;
1851     nb = (int )((n * sizeof(PLHashEntry *)) / 2U);
1852     tmp = (*((ht->allocOps)->allocTable))(ht->allocPriv, nb);
1853     ht->buckets = (PLHashEntry **)tmp;
1854     if (! ht->buckets) {
1855       ht->buckets = oldbuckets;
1856       return;
1857     }
1858     memset((void *)ht->buckets, 0, (unsigned int )nb);
1859     (ht->shift) ++;
1860     i = 0U;
1861     while (i < n) {
1862       he = *(oldbuckets + i);
1863       while (he) {
1864         next = he->next;
1865         hep = PL_HashTableRawLookup(ht, he->keyHash, he->key);
1866         while (1) {
1867           break;
1868         }
1869         he->next = (PLHashEntry *)0;
1870         *hep = he;
1871         he = next;
1872       }
1873       i ++;
1874     }
1875     (*((ht->allocOps)->freeTable))(ht->allocPriv, (void *)oldbuckets);
1876   }
1877   return;
1878 }
1879 }
1880 PRBool PL_HashTableRemove(PLHashTable *ht , void const   *key ) 
1881 { PLHashNumber keyHash ;
1882   PLHashEntry *he ;
1883   PLHashEntry **hep ;
1884 
1885   {
1886   keyHash = (*(ht->keyHash))(key);
1887   hep = PL_HashTableRawLookup(ht, keyHash, key);
1888   he = *hep;
1889   if ((unsigned int )he == (unsigned int )((PLHashEntry *)0)) {
1890     return (0);
1891   }
1892   PL_HashTableRawRemove(ht, hep, he);
1893   return (1);
1894 }
1895 }
1896 void *PL_HashTableLookup(PLHashTable *ht , void const   *key ) 
1897 { PLHashNumber keyHash ;
1898   PLHashEntry *he ;
1899   PLHashEntry **hep ;
1900 
1901   {
1902   keyHash = (*(ht->keyHash))(key);
1903   hep = PL_HashTableRawLookup(ht, keyHash, key);
1904   he = *hep;
1905   if ((unsigned int )he != (unsigned int )((PLHashEntry *)0)) {
1906     return (he->value);
1907   }
1908   return ((void *)0);
1909 }
1910 }
1911 void *PL_HashTableLookupConst(PLHashTable *ht , void const   *key ) 
1912 { PLHashNumber keyHash ;
1913   PLHashEntry *he ;
1914   PLHashEntry **hep ;
1915 
1916   {
1917   keyHash = (*(ht->keyHash))(key);
1918   hep = PL_HashTableRawLookupConst(ht, keyHash, key);
1919   he = *hep;
1920   if ((unsigned int )he != (unsigned int )((PLHashEntry *)0)) {
1921     return (he->value);
1922   }
1923   return ((void *)0);
1924 }
1925 }
1926 int PL_HashTableEnumerateEntries(PLHashTable *ht , PRIntn (*f)(PLHashEntry *he , PRIntn i ,
1927                                                                void *arg ) , void *arg ) 
1928 { PLHashEntry *he ;
1929   PLHashEntry **hep ;
1930   PRUint32 i ;
1931   PRUint32 nbuckets ;
1932   int rv ;
1933   int n ;
1934   PLHashEntry *todo ;
1935 
1936   {
1937   n = 0;
1938   todo = (PLHashEntry *)0;
1939   nbuckets = (unsigned int )(1 << (32U - ht->shift));
1940   i = 0U;
1941   while (i < nbuckets) {
1942     hep = ht->buckets + i;
1943     while (1) {
1944       he = *hep;
1945       if (! ((unsigned int )he != (unsigned int )((PLHashEntry *)0))) {
1946         break;
1947       }
1948       rv = (*f)(he, n, arg);
1949       n ++;
1950       if (rv & 6) {
1951         *hep = he->next;
1952         if (rv & 2) {
1953           he->next = todo;
1954           todo = he;
1955         }
1956       } else {
1957         hep = & he->next;
1958       }
1959       if (rv & 1) {
1960         goto out;
1961       }
1962     }
1963     i ++;
1964   }
1965   out: 
1966   hep = & todo;
1967   while (1) {
1968     he = *hep;
1969     if (! ((unsigned int )he != (unsigned int )((PLHashEntry *)0))) {
1970       break;
1971     }
1972     PL_HashTableRawRemove(ht, hep, he);
1973   }
1974   return (n);
1975 }
1976 }
1977 int PL_HashTableDump(PLHashTable *ht , PRIntn (*dump)(PLHashEntry *he , PRIntn i ,
1978                                                       void *arg ) , FILE *fp ) 
1979 { int count ;
1980 
1981   {
1982   count = PL_HashTableEnumerateEntries(ht, dump, (void *)fp);
1983   return (count);
1984 }
1985 }
1986 PLHashNumber PL_HashString(void const   *key ) 
1987 { PLHashNumber h ;
1988   PRUint8 const   *s ;
1989 
1990   {
1991   h = 0U;
1992   s = (PRUint8 const   *)key;
1993   while (*s) {
1994     h = ((h >> 28) ^ (h << 4)) ^ (unsigned int )*s;
1995     s ++;
1996   }
1997   return (h);
1998 }
1999 }
2000 int PL_CompareStrings(void const   *v1 , void const   *v2 ) 
2001 { int tmp ;
2002 
2003   {
2004   tmp = strcmp((char const   *)v1, (char const   *)v2);
2005   return (tmp == 0);
2006 }
2007 }
2008 int PL_CompareValues(void const   *v1 , void const   *v2 ) 
2009 { 
2010 
2011   {
2012   return ((unsigned int )v1 == (unsigned int )v2);
2013 }
2014 }
2015 #pragma merger(0,"/tmp/cil-14RurMIC.i","")
2016 extern unsigned short const   **__ctype_b_loc(void)  __attribute__((__const__)) ;
2017 extern  __attribute__((__nothrow__)) long strtol(char const   * __restrict  __nptr ,
2018                                                  char ** __restrict  __endptr , int __base )  __attribute__((__nonnull__(1))) ;
2019 extern  __attribute__((__nothrow__)) char *getenv(char const   *__name )  __attribute__((__nonnull__(1))) ;
2020 extern  __attribute__((__nothrow__)) int strcasecmp(char const   *__s1 , char const   *__s2 )  __attribute__((__pure__,
2021 __nonnull__(1,2))) ;
2022 int conf_no_init_messages ;
2023 int conf_dump_blocking_graph ;
2024 int conf_dump_timing_info ;
2025 int conf_show_thread_stacks ;
2026 int conf_show_thread_details ;
2027 int conf_no_stacktrace ;
2028 int conf_no_statcollect ;
2029 long conf_new_stack_size ;
2030 int conf_new_stack_kb_log2 ;
2031 void read_config(void)  __attribute__((__constructor__)) ;
2032 int conf_no_init_messages  =    0;
2033 int conf_dump_blocking_graph  =    0;
2034 int conf_dump_timing_info  =    0;
2035 int conf_show_thread_stacks  =    0;
2036 int conf_show_thread_details  =    0;
2037 int conf_no_debug  =    0;
2038 int conf_no_stacktrace  =    0;
2039 int conf_no_statcollect  =    0;
2040 long conf_new_stack_size  =    131072L;
2041 int conf_new_stack_kb_log2  =    7;
2042 __inline static int bool_value(char *str ) 
2043 { int tmp ;
2044   int tmp___0 ;
2045   int tmp___1 ;
2046   int tmp___2 ;
2047 
2048   {
2049   if ((unsigned int )str == (unsigned int )((void *)0)) {
2050     return (0);
2051   }
2052   tmp = atoi((char const   *)str);
2053   if (tmp) {
2054     return (1);
2055   }
2056   tmp___0 = strcasecmp((char const   *)str, "true");
2057   if (! tmp___0) {
2058     return (1);
2059   }
2060   tmp___1 = strcasecmp((char const   *)str, "yes");
2061   if (! tmp___1) {
2062     return (1);
2063   }
2064   tmp___2 = strcasecmp((char const   *)str, "y");
2065   if (! tmp___2) {
2066     return (1);
2067   }
2068   return (0);
2069 }
2070 }
2071 static int read_config_done  =    0;
2072 void read_config(void)  __attribute__((__constructor__)) ;
2073 void read_config(void) 
2074 { char *tmp ;
2075   char const   *tmp___0 ;
2076   char *tmp___1 ;
2077   char const   *tmp___2 ;
2078   char *tmp___3 ;
2079   char const   *tmp___4 ;
2080   char *tmp___5 ;
2081   char const   *tmp___6 ;
2082   char *tmp___7 ;
2083   char const   *tmp___8 ;
2084   char *tmp___9 ;
2085   char const   *tmp___10 ;
2086   char *tmp___11 ;
2087   char const   *tmp___12 ;
2088   char *tmp___13 ;
2089   char const   *tmp___14 ;
2090   char *str ;
2091   char *p ;
2092   int mult ;
2093   long val ;
2094   unsigned short const   **tmp___15 ;
2095 
2096   {
2097   if (read_config_done) {
2098     return;
2099   }
2100   read_config_done = 1;
2101   tmp = getenv("CAPRICCIO_NO_INIT_MESSAGES");
2102   conf_no_init_messages = bool_value(tmp);
2103   if (! conf_no_init_messages) {
2104     if (conf_no_init_messages) {
2105       tmp___0 = "yes";
2106     } else {
2107       tmp___0 = "no";
2108     }
2109     output((char *)"%s=%s\n", "CAPRICCIO_NO_INIT_MESSAGES", tmp___0);
2110   }
2111   tmp___1 = getenv("CAPRICCIO_NO_DEBUG");
2112   conf_no_debug = bool_value(tmp___1);
2113   if (! conf_no_init_messages) {
2114     if (conf_no_debug) {
2115       tmp___2 = "yes";
2116     } else {
2117       tmp___2 = "no";
2118     }
2119     output((char *)"%s=%s\n", "CAPRICCIO_NO_DEBUG", tmp___2);
2120   }
2121   tmp___3 = getenv("CAPRICCIO_NO_STACKTRACE");
2122   conf_no_stacktrace = bool_value(tmp___3);
2123   if (! conf_no_init_messages) {
2124     if (conf_no_stacktrace) {
2125       tmp___4 = "yes";
2126     } else {
2127       tmp___4 = "no";
2128     }
2129     output((char *)"%s=%s\n", "CAPRICCIO_NO_STACKTRACE", tmp___4);
2130   }
2131   tmp___5 = getenv("CAPRICCIO_NO_STATCOLLECT");
2132   conf_no_statcollect = bool_value(tmp___5);
2133   if (! conf_no_init_messages) {
2134     if (conf_no_statcollect) {
2135       tmp___6 = "yes";
2136     } else {
2137       tmp___6 = "no";
2138     }
2139     output((char *)"%s=%s\n", "CAPRICCIO_NO_STATCOLLECT", tmp___6);
2140   }
2141   tmp___7 = getenv("CAPRICCIO_DUMP_BLOCKING_GRAPH");
2142   conf_dump_blocking_graph = bool_value(tmp___7);
2143   if (! conf_no_init_messages) {
2144     if (conf_dump_blocking_graph) {
2145       tmp___8 = "yes";
2146     } else {
2147       tmp___8 = "no";
2148     }
2149     output((char *)"%s=%s\n", "CAPRICCIO_DUMP_BLOCKING_GRAPH", tmp___8);
2150   }
2151   tmp___9 = getenv("CAPRICCIO_DUMP_TIMING_INFO");
2152   conf_dump_timing_info = bool_value(tmp___9);
2153   if (! conf_no_init_messages) {
2154     if (conf_dump_timing_info) {
2155       tmp___10 = "yes";
2156     } else {
2157       tmp___10 = "no";
2158     }
2159     output((char *)"%s=%s\n", "CAPRICCIO_DUMP_TIMING_INFO", tmp___10);
2160   }
2161   tmp___11 = getenv("CAPRICCIO_SHOW_THREAD_DETAILS");
2162   conf_show_thread_details = bool_value(tmp___11);
2163   if (! conf_no_init_messages) {
2164     if (conf_show_thread_details) {
2165       tmp___12 = "yes";
2166     } else {
2167       tmp___12 = "no";
2168     }
2169     output((char *)"%s=%s\n", "CAPRICCIO_SHOW_THREAD_DETAILS", tmp___12);
2170   }
2171   tmp___13 = getenv("CAPRICCIO_SHOW_THREAD_STACKS");
2172   conf_show_thread_stacks = bool_value(tmp___13);
2173   if (! conf_no_init_messages) {
2174     if (conf_show_thread_stacks) {
2175       tmp___14 = "yes";
2176     } else {
2177       tmp___14 = "no";
2178     }
2179     output((char *)"%s=%s\n", "CAPRICCIO_SHOW_THREAD_STACKS", tmp___14);
2180   }
2181   str = getenv("CAPRICCIO_DEFAULT_STACK_SIZE");
2182   if ((unsigned int )str != (unsigned int )((void *)0)) {
2183     mult = 0;
2184     val = strtol((char const   * __restrict  )str, (char ** __restrict  )(& p), 0);
2185     if ((unsigned int )p == (unsigned int )str) {
2186       fatal((char *)"Bad number format for CAPRICCIO_DEFAULT_STACK_SIZE: \'%s\'\n",
2187             str);
2188     }
2189     while (1) {
2190       tmp___15 = __ctype_b_loc();
2191       if (! ((int const   )*(*tmp___15 + (int )*p) & 8192)) {
2192         break;
2193       }
2194       p ++;
2195     }
2196     if ((int )*p == 0) {
2197       mult = 1024;
2198     } else {
2199       if ((int )*p == 98) {
2200         mult = 1;
2201       } else {
2202         if ((int )*p == 66) {
2203           mult = 1;
2204         } else {
2205           if ((int )*p == 107) {
2206             mult = 1024;
2207           } else {
2208             if ((int )*p == 75) {
2209               mult = 1024;
2210             } else {
2211               if ((int )*p == 109) {
2212                 mult = 1048576;
2213               } else {
2214                 if ((int )*p == 77) {
2215                   mult = 1048576;
2216                 } else {
2217                   fatal((char *)"Bad units for CAPRICCIO_DEFAULT_STACK_SIZE: \'%s\'\n",
2218                         str);
2219                 }
2220               }
2221             }
2222           }
2223         }
2224       }
2225     }
2226     conf_new_stack_size = 1024L;
2227     conf_new_stack_kb_log2 = 0;
2228     while (conf_new_stack_size < (long )mult * val) {
2229       conf_new_stack_kb_log2 ++;
2230       conf_new_stack_size <<= 1;
2231     }
2232   }
2233   if (! conf_no_init_messages) {
2234     if (conf_new_stack_size > 1048576L) {
2235       if (! (conf_new_stack_size & 1048575L)) {
2236         output((char *)"CAPRICCIO_DEFAULT_STACKSIZE=%ldM\n", (conf_new_stack_size / 1024L) / 1024L);
2237       } else {
2238         goto _L;
2239       }
2240     } else {
2241       _L: /* CIL Label */ 
2242       if (conf_new_stack_size > 1024L) {
2243         if (! (conf_new_stack_size & 1023L)) {
2244           output((char *)"CAPRICCIO_DEFAULT_STACKSIZE=%ldK\n", conf_new_stack_size / 1024L);
2245         } else {
2246           output((char *)"CAPRICCIO_DEFAULT_STACKSIZE=%ldb\n", conf_new_stack_size);
2247         }
2248       } else {
2249         output((char *)"CAPRICCIO_DEFAULT_STACKSIZE=%ldb\n", conf_new_stack_size);
2250       }
2251     }
2252   }
2253   return;
2254 }
2255 }


syntax highlighted by Code2HTML, v. 0.9.1