text: #define nx_struct struct
  #define nx_union union
  #define dbg(mode, format, ...) ((void)0)
  #define dbg_clear(mode, format, ...) ((void)0)
  #define dbg_active(mode) 0
  # 150 "/usr/lib/gcc/x86_64-linux-gnu/4.6/include/stddef.h" 3
  typedef long int ptrdiff_t;
  #line 212
  typedef long unsigned int size_t;
  #line 324
  typedef int wchar_t;
  # 8 "/usr/lib/ncc/deputy_nodeputy.h"
  struct __nesc_attr_nonnull {
  #line 8
    int dummy;
  }  ;
  #line 9
  struct __nesc_attr_bnd {
  #line 9
    void *lo, *hi;
  }  ;
  #line 10
  struct __nesc_attr_bnd_nok {
  #line 10
    void *lo, *hi;
  }  ;
  #line 11
  struct __nesc_attr_count {
  #line 11
    int n;
  }  ;
  #line 12
  struct __nesc_attr_count_nok {
  #line 12
    int n;
  }  ;
  #line 13
  struct __nesc_attr_one {
  #line 13
    int dummy;
  }  ;
  #line 14
  struct __nesc_attr_one_nok {
  #line 14
    int dummy;
  }  ;
  #line 15
  struct __nesc_attr_dmemset {
  #line 15
    int a1, a2, a3;
  }  ;
  #line 16
  struct __nesc_attr_dmemcpy {
  #line 16
    int a1, a2, a3;
  }  ;
  #line 17
  struct __nesc_attr_nts {
  #line 17
    int dummy;
  }  ;
  # 37 "/usr/include/stdint.h" 3
  typedef signed char int8_t;
  typedef short int int16_t;
  typedef int int32_t;
  
  typedef long int int64_t;
  
  
  
  
  
  
  
  typedef unsigned char uint8_t;
  typedef unsigned short int uint16_t;
  
  typedef unsigned int uint32_t;
  
  
  
  typedef unsigned long int uint64_t;
  
  
  
  
  
  
  
  
  
  typedef signed char int_least8_t;
  typedef short int int_least16_t;
  typedef int int_least32_t;
  
  typedef long int int_least64_t;
  
  
  
  
  
  
  typedef unsigned char uint_least8_t;
  typedef unsigned short int uint_least16_t;
  typedef unsigned int uint_least32_t;
  
  typedef unsigned long int uint_least64_t;
  
  
  
  
  
  
  
  
  
  typedef signed char int_fast8_t;
  
  typedef long int int_fast16_t;
  typedef long int int_fast32_t;
  typedef long int int_fast64_t;
  
  
  
  
  
  
  
  
  typedef unsigned char uint_fast8_t;
  
  typedef unsigned long int uint_fast16_t;
  typedef unsigned long int uint_fast32_t;
  typedef unsigned long int uint_fast64_t;
  #line 120
  typedef long int intptr_t;
  
  
  typedef unsigned long int uintptr_t;
  #line 135
  typedef long int intmax_t;
  typedef unsigned long int uintmax_t;
  # 35 "/usr/include/inttypes.h" 3
  typedef int __gwchar_t;
  #line 283
  #line 279
  typedef struct __nesc_unnamed4242 {
  
    long int quot;
    long int rem;
  } imaxdiv_t;
  # 281 "/usr/lib/ncc/nesc_nx.h"
  static __inline uint8_t __nesc_ntoh_uint8(const void * source)  ;
  
  
  
  
  static __inline uint8_t __nesc_hton_uint8(void * target, uint8_t value)  ;
  #line 303
  static __inline int8_t __nesc_ntoh_int8(const void * source)  ;
  #line 303
  static __inline int8_t __nesc_hton_int8(void * target, int8_t value)  ;
  
  
  
  
  
  
  static __inline uint16_t __nesc_ntoh_uint16(const void * source)  ;
  
  
  
  
  static __inline uint16_t __nesc_hton_uint16(void * target, uint16_t value)  ;
  #line 340
  static __inline uint32_t __nesc_ntoh_uint32(const void * source)  ;
  
  
  
  
  
  
  static __inline uint32_t __nesc_hton_uint32(void * target, uint32_t value)  ;
  #line 431
  typedef struct { unsigned char nxdata[1]; } __attribute__((packed)) nx_int8_t;typedef int8_t __nesc_nxbase_nx_int8_t  ;
  typedef struct { unsigned char nxdata[2]; } __attribute__((packed)) nx_int16_t;typedef int16_t __nesc_nxbase_nx_int16_t  ;
  typedef struct { unsigned char nxdata[4]; } __attribute__((packed)) nx_int32_t;typedef int32_t __nesc_nxbase_nx_int32_t  ;
  typedef struct { unsigned char nxdata[8]; } __attribute__((packed)) nx_int64_t;typedef int64_t __nesc_nxbase_nx_int64_t  ;
  typedef struct { unsigned char nxdata[1]; } __attribute__((packed)) nx_uint8_t;typedef uint8_t __nesc_nxbase_nx_uint8_t  ;
  typedef struct { unsigned char nxdata[2]; } __attribute__((packed)) nx_uint16_t;typedef uint16_t __nesc_nxbase_nx_uint16_t  ;
  typedef struct { unsigned char nxdata[4]; } __attribute__((packed)) nx_uint32_t;typedef uint32_t __nesc_nxbase_nx_uint32_t  ;
  typedef struct { unsigned char nxdata[8]; } __attribute__((packed)) nx_uint64_t;typedef uint64_t __nesc_nxbase_nx_uint64_t  ;
  
  
  typedef struct { unsigned char nxdata[1]; } __attribute__((packed)) nxle_int8_t;typedef int8_t __nesc_nxbase_nxle_int8_t  ;
  typedef struct { unsigned char nxdata[2]; } __attribute__((packed)) nxle_int16_t;typedef int16_t __nesc_nxbase_nxle_int16_t  ;
  typedef struct { unsigned char nxdata[4]; } __attribute__((packed)) nxle_int32_t;typedef int32_t __nesc_nxbase_nxle_int32_t  ;
  typedef struct { unsigned char nxdata[8]; } __attribute__((packed)) nxle_int64_t;typedef int64_t __nesc_nxbase_nxle_int64_t  ;
  typedef struct { unsigned char nxdata[1]; } __attribute__((packed)) nxle_uint8_t;typedef uint8_t __nesc_nxbase_nxle_uint8_t  ;
  typedef struct { unsigned char nxdata[2]; } __attribute__((packed)) nxle_uint16_t;typedef uint16_t __nesc_nxbase_nxle_uint16_t  ;
  typedef struct { unsigned char nxdata[4]; } __attribute__((packed)) nxle_uint32_t;typedef uint32_t __nesc_nxbase_nxle_uint32_t  ;
  typedef struct { unsigned char nxdata[8]; } __attribute__((packed)) nxle_uint64_t;typedef uint64_t __nesc_nxbase_nxle_uint64_t  ;
  # 44 "/usr/include/string.h" 3
  extern void *memcpy(void *__restrict __dest, 
  const void *__restrict __src, size_t __n) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__nonnull__(1, 2))) ;
  #line 65
  extern void *memset(void *__s, int __c, size_t __n) __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__nonnull__(1))) ;
  
  
  extern int memcmp(const void *__s1, const void *__s2, size_t __n) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__pure__)) __attribute((__nonnull__(1, 2))) ;
  #line 128
  extern char *strcpy(char *__restrict __dest, const char *__restrict __src) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__nonnull__(1, 2))) ;
  #line 143
  extern int strcmp(const char *__s1, const char *__s2) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__pure__)) __attribute((__nonnull__(1, 2))) ;
  # 40 "/usr/include/xlocale.h" 3
  #line 28
  typedef struct __locale_struct {
  
  
    struct __locale_data *__locales[13];
  
  
    const unsigned short int *__ctype_b;
    const int *__ctype_tolower;
    const int *__ctype_toupper;
  
  
    const char *__names[13];
  } *__locale_t;
  
  
  typedef __locale_t locale_t;
  # 262 "/usr/include/string.h"
  extern char *strrchr(const char *__s, int __c) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__pure__)) __attribute((__nonnull__(1))) ;
  #line 399
  extern size_t strlen(const char *__s) 
  __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__pure__)) __attribute((__nonnull__(1))) ;
  # 67 "/usr/include/x86_64-linux-gnu/bits/waitstatus.h" 3
  union wait {
  
    int w_status;
    struct __nesc_unnamed4243 {
  
  
      unsigned int __w_termsig : 7;
      unsigned int __w_coredump : 1;
      unsigned int __w_retcode : 8;
      unsigned int  : 16;
    } 
  
  
  
  
  
  
    __wait_terminated;
    struct __nesc_unnamed4244 {
  
  
      unsigned int __w_stopval : 8;
      unsigned int __w_stopsig : 8;
      unsigned int  : 16;
    } 
  
  
  
  
  
    __wait_stopped;
  };
  # 72 "/usr/include/stdlib.h" 3
  #line 68
  typedef union __nesc_unnamed4245 {
  
    union wait *__uptr;
    int *__iptr;
  } __WAIT_STATUS __attribute((__transparent_union__)) ;
  #line 102
  #line 98
  typedef struct __nesc_unnamed4246 {
  
    int quot;
    int rem;
  } div_t;
  
  
  
  
  
  
  
  #line 106
  typedef struct __nesc_unnamed4247 {
  
    long int quot;
    long int rem;
  } ldiv_t;
  
  
  
  
  
  
  
  __extension__ 
  
  
  
  #line 118
  typedef struct __nesc_unnamed4248 {
  
    long long int quot;
    long long int rem;
  } lldiv_t;
  #line 158
  __extension__ 
  #line 195
  __extension__ 
  
  
  
  
  __extension__ 
  
  
  
  
  
  
  
  
  __extension__ 
  
  
  
  
  __extension__ 
  # 31 "/usr/include/x86_64-linux-gnu/bits/types.h" 3
  typedef unsigned char __u_char;
  typedef unsigned short int __u_short;
  typedef unsigned int __u_int;
  typedef unsigned long int __u_long;
  
  
  typedef signed char __int8_t;
  typedef unsigned char __uint8_t;
  typedef signed short int __int16_t;
  typedef unsigned short int __uint16_t;
  typedef signed int __int32_t;
  typedef unsigned int __uint32_t;
  
  typedef signed long int __int64_t;
  typedef unsigned long int __uint64_t;
  
  
  
  
  
  
  
  typedef long int __quad_t;
  typedef unsigned long int __u_quad_t;
  #line 134
  typedef unsigned long int __dev_t;
  typedef unsigned int __uid_t;
  typedef unsigned int __gid_t;
  typedef unsigned long int __ino_t;
  typedef unsigned long int __ino64_t;
  typedef unsigned int __mode_t;
  typedef unsigned long int __nlink_t;
  typedef long int __off_t;
  typedef long int __off64_t;
  typedef int __pid_t;
  typedef struct __nesc_unnamed4249 {
  #line 144
    int __val[2];
  } 
  #line 144
  __fsid_t;
  typedef long int __clock_t;
  typedef unsigned long int __rlim_t;
  typedef unsigned long int __rlim64_t;
  typedef unsigned int __id_t;
  typedef long int __time_t;
  typedef unsigned int __useconds_t;
  typedef long int __suseconds_t;
  
  typedef int __daddr_t;
  typedef long int __swblk_t;
  typedef int __key_t;
  
  
  typedef int __clockid_t;
  
  
  typedef void *__timer_t;
  
  
  typedef long int __blksize_t;
  
  
  
  
  typedef long int __blkcnt_t;
  typedef long int __blkcnt64_t;
  
  
  typedef unsigned long int __fsblkcnt_t;
  typedef unsigned long int __fsblkcnt64_t;
  
  
  typedef unsigned long int __fsfilcnt_t;
  typedef unsigned long int __fsfilcnt64_t;
  
  typedef long int __ssize_t;
  
  
  
  typedef __off64_t __loff_t;
  typedef __quad_t *__qaddr_t;
  typedef char *__caddr_t;
  
  
  typedef long int __intptr_t;
  
  
  typedef unsigned int __socklen_t;
  # 34 "/usr/include/x86_64-linux-gnu/sys/types.h" 3
  typedef __u_char u_char;
  typedef __u_short u_short;
  typedef __u_int u_int;
  typedef __u_long u_long;
  typedef __quad_t quad_t;
  typedef __u_quad_t u_quad_t;
  typedef __fsid_t fsid_t;
  
  
  
  
  typedef __loff_t loff_t;
  
  
  
  typedef __ino_t ino_t;
  #line 61
  typedef __dev_t dev_t;
  
  
  
  
  typedef __gid_t gid_t;
  
  
  
  
  typedef __mode_t mode_t;
  
  
  
  
  typedef __nlink_t nlink_t;
  
  
  
  
  typedef __uid_t uid_t;
  
  
  
  
  
  typedef __off_t off_t;
  #line 99
  typedef __pid_t pid_t;
  
  
  
  
  
  typedef __id_t id_t;
  
  
  
  
  typedef __ssize_t ssize_t;
  
  
  
  
  
  typedef __daddr_t daddr_t;
  typedef __caddr_t caddr_t;
  
  
  
  
  
  typedef __key_t key_t;
  # 60 "/usr/include/time.h" 3
  typedef __clock_t clock_t;
  #line 76
  typedef __time_t time_t;
  #line 92
  typedef __clockid_t clockid_t;
  #line 104
  typedef __timer_t timer_t;
  # 151 "/usr/include/x86_64-linux-gnu/sys/types.h" 3
  typedef unsigned long int ulong;
  typedef unsigned short int ushort;
  typedef unsigned int uint;
  #line 201
  typedef unsigned int u_int8_t __attribute((__mode__(__QI__))) ;
  typedef unsigned int u_int16_t __attribute((__mode__(__HI__))) ;
  typedef unsigned int u_int32_t __attribute((__mode__(__SI__))) ;
  typedef unsigned int u_int64_t __attribute((__mode__(__DI__))) ;
  
  typedef int register_t __attribute((__mode__(__word__))) ;
  # 24 "/usr/include/x86_64-linux-gnu/bits/sigset.h" 3
  typedef int __sig_atomic_t;
  
  
  
  
  
  
  
  #line 29
  typedef struct __nesc_unnamed4250 {
  
    unsigned long int __val[1024 / (8 * sizeof(unsigned long int ))];
  } __sigset_t;
  # 38 "/usr/include/x86_64-linux-gnu/sys/select.h" 3
  typedef __sigset_t sigset_t;
  # 120 "/usr/include/time.h" 3
  struct timespec {
  
    __time_t tv_sec;
    long int tv_nsec;
  };
  # 31 "/usr/include/x86_64-linux-gnu/bits/time.h" 3
  struct timeval {
  
    __time_t tv_sec;
    __suseconds_t tv_usec;
  };
  # 49 "/usr/include/x86_64-linux-gnu/sys/select.h" 3
  typedef __suseconds_t suseconds_t;
  
  
  
  
  
  typedef long int __fd_mask;
  #line 76
  #line 65
  typedef struct __nesc_unnamed4251 {
  
  
  
  
  
  
  
    __fd_mask __fds_bits[1024 / (8 * (int )sizeof(__fd_mask ))];
  } 
  
  fd_set;
  
  
  
  
  
  
  typedef __fd_mask fd_mask;
  # 32 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3
  __extension__ 
  
  
  __extension__ 
  
  
  __extension__ 
  # 229 "/usr/include/x86_64-linux-gnu/sys/types.h" 3
  typedef __blksize_t blksize_t;
  
  
  
  
  
  
  typedef __blkcnt_t blkcnt_t;
  
  
  
  typedef __fsblkcnt_t fsblkcnt_t;
  
  
  
  typedef __fsfilcnt_t fsfilcnt_t;
  # 50 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3
  typedef unsigned long int pthread_t;
  
  
  
  
  
  
  #line 53
  typedef union __nesc_unnamed4252 {
  
    char __size[56];
    long int __align;
  } pthread_attr_t;
  
  
  
  
  
  
  
  #line 61
  typedef struct __pthread_internal_list {
  
    struct __pthread_internal_list *__prev;
    struct __pthread_internal_list *__next;
  } __pthread_list_t;
  #line 104
  #line 76
  typedef union __nesc_unnamed4253 {
  
    struct __pthread_mutex_s {
  
      int __lock;
      unsigned int __count;
      int __owner;
  
      unsigned int __nusers;
  
  
  
      int __kind;
  
      int __spins;
      __pthread_list_t __list;
    } 
  
  
  
  
  
  
  
  
    __data;
    char __size[40];
    long int __align;
  } pthread_mutex_t;
  
  
  
  
  
  #line 106
  typedef union __nesc_unnamed4254 {
  
    char __size[4];
    int __align;
  } pthread_mutexattr_t;
  #line 130
  #line 115
  typedef union __nesc_unnamed4255 {
  
    struct __nesc_unnamed4256 {
  
      int __lock;
      unsigned int __futex;
      __extension__ unsigned long long int __total_seq;
      __extension__ unsigned long long int __wakeup_seq;
      __extension__ unsigned long long int __woken_seq;
      void *__mutex;
      unsigned int __nwaiters;
      unsigned int __broadcast_seq;
    } __data;
    char __size[48];
    __extension__ long long int __align;
  } pthread_cond_t;
  
  
  
  
  
  #line 132
  typedef union __nesc_unnamed4257 {
  
    char __size[4];
    int __align;
  } pthread_condattr_t;
  
  
  
  typedef unsigned int pthread_key_t;
  
  
  
  typedef int pthread_once_t;
  #line 189
  #line 150
  typedef union __nesc_unnamed4258 {
  
  
    struct __nesc_unnamed4259 {
  
      int __lock;
      unsigned int __nr_readers;
      unsigned int __readers_wakeup;
      unsigned int __writer_wakeup;
      unsigned int __nr_readers_queued;
      unsigned int __nr_writers_queued;
      int __writer;
      int __shared;
      unsigned long int __pad1;
      unsigned long int __pad2;
  
  
      unsigned int __flags;
    } __data;
  #line 187
    char __size[56];
    long int __align;
  } pthread_rwlock_t;
  
  
  
  
  
  #line 191
  typedef union __nesc_unnamed4260 {
  
    char __size[8];
    long int __align;
  } pthread_rwlockattr_t;
  
  
  
  
  
  typedef volatile int pthread_spinlock_t;
  
  
  
  
  
  
  
  
  #line 206
  typedef union __nesc_unnamed4261 {
  
    char __size[32];
    long int __align;
  } pthread_barrier_t;
  
  
  
  
  
  #line 212
  typedef union __nesc_unnamed4262 {
  
    char __size[4];
    int __align;
  } pthread_barrierattr_t;
  # 349 "/usr/include/stdlib.h" 3
  struct random_data {
  
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };
  #line 418
  struct drand48_data {
  
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    unsigned long long int __a;
  };
  #line 471
  extern void *malloc(size_t __size) __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__malloc__)) ;
  #line 488
  extern void free(void *__ptr) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  #line 742
  typedef int (*__compar_fn_t)(const void *arg_0x2b37c12941f0, const void *arg_0x2b37c12944c8);
  #line 776
  __extension__ 
  #line 793
  __extension__ 
  # 31 "/usr/include/x86_64-linux-gnu/bits/mathdef.h" 3
  typedef float float_t;
  typedef double double_t;
  # 110 "/usr/include/x86_64-linux-gnu/bits/mathcalls.h" 3
  extern double log(double __x) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  #line 155
  extern double pow(double __x, double __y) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  
  
  extern double sqrt(double __x) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  #line 183
  extern double fabs(double __x) __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((const)) ;
  
  
  extern double floor(double __x) __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((const)) ;
  #line 252
  extern double erfc(double arg_0x2b37c13169c8) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  # 203 "/usr/include/math.h" 3
  enum __nesc_unnamed4263 {
  
    FP_NAN, 
  
    FP_INFINITE, 
  
    FP_ZERO, 
  
    FP_SUBNORMAL, 
  
    FP_NORMAL
  };
  #line 303
  #line 296
  typedef enum __nesc_unnamed4264 {
  
    _IEEE_ = -1, 
    _SVID_, 
    _XOPEN_, 
    _POSIX_, 
    _ISOC_
  } _LIB_VERSION_TYPE;
  #line 321
  struct exception {
  
  
    int type;
    char *name;
    double arg1;
    double arg2;
    double retval;
  };
  # 48 "/usr/include/ctype.h" 3
  enum __nesc_unnamed4265 {
  
    _ISupper = 0 < 8 ? (1 << 0) << 8 : (1 << 0) >> 8, 
    _ISlower = 1 < 8 ? (1 << 1) << 8 : (1 << 1) >> 8, 
    _ISalpha = 2 < 8 ? (1 << 2) << 8 : (1 << 2) >> 8, 
    _ISdigit = 3 < 8 ? (1 << 3) << 8 : (1 << 3) >> 8, 
    _ISxdigit = 4 < 8 ? (1 << 4) << 8 : (1 << 4) >> 8, 
    _ISspace = 5 < 8 ? (1 << 5) << 8 : (1 << 5) >> 8, 
    _ISprint = 6 < 8 ? (1 << 6) << 8 : (1 << 6) >> 8, 
    _ISgraph = 7 < 8 ? (1 << 7) << 8 : (1 << 7) >> 8, 
    _ISblank = 8 < 8 ? (1 << 8) << 8 : (1 << 8) >> 8, 
    _IScntrl = 9 < 8 ? (1 << 9) << 8 : (1 << 9) >> 8, 
    _ISpunct = 10 < 8 ? (1 << 10) << 8 : (1 << 10) >> 8, 
    _ISalnum = 11 < 8 ? (1 << 11) << 8 : (1 << 11) >> 8
  };
  # 45 "/usr/include/stdio.h" 3
  struct _IO_FILE;
  
  
  
  typedef struct _IO_FILE FILE;
  #line 65
  typedef struct _IO_FILE __FILE;
  # 95 "/usr/include/wchar.h" 3
  #line 83
  typedef struct __nesc_unnamed4266 {
  
    int __count;
    union __nesc_unnamed4267 {
  
  
      unsigned int __wch;
  
  
  
      char __wchb[4];
    } __value;
  } __mbstate_t;
  # 26 "/usr/include/_G_config.h" 3
  #line 22
  typedef struct __nesc_unnamed4268 {
  
    __off_t __pos;
    __mbstate_t __state;
  } _G_fpos_t;
  
  
  
  
  #line 27
  typedef struct __nesc_unnamed4269 {
  
    __off64_t __pos;
    __mbstate_t __state;
  } _G_fpos64_t;
  #line 53
  typedef int _G_int16_t __attribute((__mode__(__HI__))) ;
  typedef int _G_int32_t __attribute((__mode__(__SI__))) ;
  typedef unsigned int _G_uint16_t __attribute((__mode__(__HI__))) ;
  typedef unsigned int _G_uint32_t __attribute((__mode__(__SI__))) ;
  # 40 "/usr/lib/gcc/x86_64-linux-gnu/4.6/include/stdarg.h" 3
  typedef __builtin_va_list __gnuc_va_list;
  # 172 "/usr/include/libio.h" 3
  struct _IO_jump_t;
  #line 172
  struct _IO_FILE;
  
  
  
  
  
  
  
  
  
  typedef void _IO_lock_t;
  
  
  
  
  
  struct _IO_marker {
    struct _IO_marker *_next;
    struct _IO_FILE *_sbuf;
  
  
  
    int _pos;
  };
  #line 208
  enum __codecvt_result {
  
    __codecvt_ok, 
    __codecvt_partial, 
    __codecvt_error, 
    __codecvt_noconv
  };
  #line 273
  struct _IO_FILE {
    int _flags;
  
  
  
  
    char *_IO_read_ptr;
    char *_IO_read_end;
    char *_IO_read_base;
    char *_IO_write_base;
    char *_IO_write_ptr;
    char *_IO_write_end;
    char *_IO_buf_base;
    char *_IO_buf_end;
  
    char *_IO_save_base;
    char *_IO_backup_base;
    char *_IO_save_end;
  
    struct _IO_marker *_markers;
  
    struct _IO_FILE *_chain;
  
    int _fileno;
  
  
  
    int _flags2;
  
    __off_t _old_offset;
  
  
  
    unsigned short _cur_column;
    signed char _vtable_offset;
    char _shortbuf[1];
  
  
  
    _IO_lock_t *_lock;
  
  
  
  
  
  
  
  
    __off64_t _offset;
  
  
  
  
  
  
  
  
    void *__pad1;
    void *__pad2;
    void *__pad3;
    void *__pad4;
    size_t __pad5;
  
    int _mode;
  
    char _unused2[15 * sizeof(int ) - 4 * sizeof(void *) - sizeof(size_t )];
  };
  
  
  
  typedef struct _IO_FILE _IO_FILE;
  
  
  struct _IO_FILE_plus;
  
  struct _IO_FILE_plus;
  struct _IO_FILE_plus;
  struct _IO_FILE_plus;
  #line 366
  typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __nbytes);
  
  
  
  
  
  
  
  typedef __ssize_t __io_write_fn(void *__cookie, const char *__buf, 
  size_t __n);
  
  
  
  
  
  
  
  typedef int __io_seek_fn(void *__cookie, __off64_t *__pos, int __w);
  
  
  typedef int __io_close_fn(void *__cookie);
  # 80 "/usr/include/stdio.h" 3
  typedef __gnuc_va_list va_list;
  #line 111
  typedef _G_fpos_t fpos_t;
  #line 169
  struct _IO_FILE;
  struct _IO_FILE;
  struct _IO_FILE;
  #line 243
  extern int fflush(FILE *__stream);
  #line 307
  extern FILE *fdopen(int __fd, const char *__modes) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  #line 357
  extern int fprintf(FILE *__restrict __stream, 
  const char *__restrict __format, ...);
  
  
  
  
  extern int printf(const char *__restrict __format, ...);
  
  
  
  
  
  
  
  
  extern int vfprintf(FILE *__restrict __s, const char *__restrict __format, 
  __gnuc_va_list __arg);
  #line 387
  extern int snprintf(char *__restrict __s, size_t __maxlen, 
  const char *__restrict __format, ...) 
  __attribute((__nothrow__)) __attribute((__format__(__printf__, 3, 4))) ;
  #line 855
  extern int fileno(FILE *__stream) __attribute((__leaf__)) __attribute((__nothrow__)) ;
  # 57 "/opt/tinyos-2.1.0/tos/lib/tossim/tos.h"
  typedef uint8_t bool;
  
  
  
  
  
  
  
  
  
  
  enum __nesc_unnamed4270 {
  #line 68
    FALSE = 0, TRUE = 1
  };
  extern uint16_t TOS_NODE_ID;
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.h"
  typedef long long int sim_time_t;
  
  void sim_init();
  
  void sim_end();
  
  void sim_random_seed(int seed);
  int sim_random();
  
  sim_time_t sim_time();
  void sim_set_time(sim_time_t time);
  sim_time_t sim_ticks_per_sec();
  
  unsigned long sim_node();
  void sim_set_node(unsigned long node);
  
  int sim_print_time(char *buf, int bufLen, sim_time_t time);
  int sim_print_now(char *buf, int bufLen);
  char *sim_time_string();
  
  void sim_add_channel(char *channel, FILE *file);
  bool sim_remove_channel(char *channel, FILE *file);
  
  bool sim_run_next_event();
  # 42 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.h"
  struct sim_event;
  typedef struct sim_event sim_event_t;
  
  struct sim_event {
    sim_time_t time;
    unsigned long mote;
    bool force;
  
    bool cancelled;
    void *data;
  
    void (*handle)(sim_event_t *e);
    void (*cleanup)(sim_event_t *e);
  };
  
  static sim_event_t *sim_queue_allocate_event();
  
  void sim_queue_init();
  void sim_queue_insert(sim_event_t *event);
  bool sim_queue_is_empty();
  long long int sim_queue_peek_time();
  sim_event_t *sim_queue_pop();
  
  void sim_queue_cleanup_none(sim_event_t *e);
  void sim_queue_cleanup_event(sim_event_t *e);
  void sim_queue_cleanup_data(sim_event_t *e);
  void sim_queue_cleanup_total(sim_event_t *e);
  # 45 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_mote.h"
  long long int sim_mote_euid(int mote);
  void sim_mote_set_euid(int mote, long long int euid);
  
  long long int sim_mote_start_time(int mote);
  void sim_mote_set_start_time(int mote, long long int t);
  
  bool sim_mote_is_on(int mote);
  void sim_mote_turn_on(int mote);
  void sim_mote_turn_off(int mote);
  int sim_mote_get_variable_info(int mote, char *name, void **addr, size_t *len);
  void sim_mote_enqueue_boot_event(int mote);
  # 57 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.h"
  static inline void sim_log_init();
  static inline void sim_log_add_channel(char *output, FILE *file);
  static inline bool sim_log_remove_channel(char *output, FILE *file);
  static void sim_log_commit_change();
  
  static void sim_log_debug(uint16_t id, char *string, const char *format, ...);
  static void sim_log_error(uint16_t id, char *string, const char *format, ...);
  static void sim_log_debug_clear(uint16_t id, char *string, const char *format, ...);
  # 89 "/opt/tinyos-2.1.0/tos/lib/tossim/tos.h"
  struct __nesc_attr_atmostonce {
  };
  #line 90
  struct __nesc_attr_atleastonce {
  };
  #line 91
  struct __nesc_attr_exactlyonce {
  };
  # 9 "/opt/tinyos-2.1.0/tos/lib/tossim/hashtable.h"
  struct hashtable;
  typedef struct hashtable hashtable_t;
  #line 78
  struct hashtable *
  create_hashtable(unsigned int minsize, 
  unsigned int (*hashfunction)(void *arg_0x2b37c1564868), 
  int (*key_eq_fn)(void *arg_0x2b37c1563020, void *arg_0x2b37c15632c0));
  #line 103
  #line 102
  int 
  hashtable_insert(struct hashtable *h, void *k, void *v);
  #line 120
  void *
  hashtable_search(struct hashtable *h, void *k);
  # 39 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  enum __nesc_unnamed4271 {
    DEFAULT_CHANNEL_SIZE = 8
  };
  
  
  
  
  #line 43
  typedef struct sim_log_output {
    int num;
    FILE **files;
  } sim_log_output_t;
  
  
  
  
  
  
  #line 48
  typedef struct sim_log_channel {
    const char *name;
    int numOutputs;
    int size;
    FILE **outputs;
  } sim_log_channel_t;
  
  enum __nesc_unnamed4272 {
    SIM_LOG_OUTPUT_COUNT = 212U
  };
  
  sim_log_output_t outputs[SIM_LOG_OUTPUT_COUNT];
  struct hashtable *channelTable = (void *)0;
  
  
  inline static unsigned int sim_log_hash(void *key);
  inline static int sim_log_eq(void *key1, void *key2);
  #line 76
  static void fillInOutput(int id, char *name);
  #line 151
  static inline void sim_log_init();
  #line 164
  static inline void sim_log_add_channel(char *name, FILE *file);
  #line 204
  static inline bool sim_log_remove_channel(char *output, FILE *file);
  #line 226
  static void sim_log_commit_change();
  #line 238
  static void sim_log_debug(uint16_t id, char *string, const char *format, ...);
  #line 253
  static void sim_log_error(uint16_t id, char *string, const char *format, ...);
  #line 268
  static void sim_log_debug_clear(uint16_t id, char *string, const char *format, ...);
  #line 298
  inline static unsigned int sim_log_hash(void *key);
  
  
  
  
  
  
  
  
  
  
  inline static int sim_log_eq(void *key1, void *key2);
  # 54 "/opt/tinyos-2.1.0/tos/lib/tossim/heap.h"
  #line 50
  typedef struct heap {
    int size;
    void *data;
    int private_size;
  } heap_t;
  
  static inline void init_heap(heap_t *heap);
  
  static inline int heap_is_empty(heap_t *heap);
  
  static inline long long int heap_get_min_key(heap_t *heap);
  
  static void *heap_pop_min_data(heap_t *heap, long long int *key);
  static inline void heap_insert(heap_t *heap, void *data, long long int key);
  # 47 "/opt/tinyos-2.1.0/tos/lib/tossim/heap.c"
  const int STARTING_SIZE = 511;
  
  
  
  
  
  
  #line 51
  typedef struct node {
    void *data;
    long long int key;
  } node_t;
  
  static void down_heap(heap_t *heap, int findex);
  static void up_heap(heap_t *heap, int findex);
  static void swap(node_t *first, node_t *second);
  
  
  
  
  
  
  
  
  static inline void init_heap(heap_t *heap);
  
  
  
  
  
  
  
  
  
  static inline int is_empty(heap_t *heap);
  
  
  
  static inline int heap_is_empty(heap_t *heap);
  
  
  
  static inline long long int heap_get_min_key(heap_t *heap);
  #line 103
  static void *heap_pop_min_data(heap_t *heap, long long int *key);
  #line 119
  static inline void expand_heap(heap_t *heap);
  #line 133
  static inline void heap_insert(heap_t *heap, void *data, long long int key);
  #line 147
  static void swap(node_t *first, node_t *second);
  #line 160
  static void down_heap(heap_t *heap, int findex);
  #line 186
  static void up_heap(heap_t *heap, int findex);
  # 36 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.c"
  static heap_t eventHeap;
  
  void sim_queue_init()   ;
  
  
  
  void sim_queue_insert(sim_event_t *event)   ;
  
  
  
  
  sim_event_t *sim_queue_pop()   ;
  
  
  
  
  bool sim_queue_is_empty()   ;
  
  
  
  long long int sim_queue_peek_time()   ;
  
  
  
  
  
  
  
  
  
  void sim_queue_cleanup_none(sim_event_t *event)   ;
  
  
  
  
  void sim_queue_cleanup_event(sim_event_t *event)   ;
  
  
  
  
  void sim_queue_cleanup_data(sim_event_t *event)   ;
  
  
  
  
  
  void sim_queue_cleanup_total(sim_event_t *event)   ;
  
  
  
  
  
  
  static sim_event_t *sim_queue_allocate_event();
  # 57 "/usr/include/x86_64-linux-gnu/sys/time.h" 3
  struct timezone {
  
    int tz_minuteswest;
    int tz_dsttime;
  };
  
  typedef struct timezone *__restrict __timezone_ptr_t;
  
  
  
  
  
  
  
  
  
  extern int gettimeofday(struct timeval *__restrict __tv, 
  __timezone_ptr_t __tz) __attribute((__leaf__)) __attribute((__nothrow__)) __attribute((__nonnull__(1))) ;
  #line 93
  enum __itimer_which {
  
  
    ITIMER_REAL = 0, 
  
  
    ITIMER_VIRTUAL = 1, 
  
  
  
    ITIMER_PROF = 2
  };
  
  
  
  
  struct itimerval {
  
  
    struct timeval it_interval;
  
    struct timeval it_value;
  };
  
  
  
  
  
  
  typedef int __itimer_which_t;
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.h"
  enum __nesc_unnamed4273 {
    NOISE_MIN = -115, 
    NOISE_MAX = -5, 
    NOISE_MIN_QUANTIZE = -115, 
    NOISE_QUANTIZE_INTERVAL = 5, 
    NOISE_BIN_SIZE = (NOISE_MAX - NOISE_MIN) / NOISE_QUANTIZE_INTERVAL + 1, 
    NOISE_HISTORY = 20, 
    NOISE_DEFAULT_ELEMENT_SIZE = 8, 
    NOISE_HASHTABLE_SIZE = 128, 
    NOISE_MIN_TRACE = 128, 
    NOISE_NUM_VALUES = NOISE_MAX - NOISE_MIN + 1
  };
  
  
  
  
  
  
  
  
  #line 56
  typedef struct sim_noise_hash_t {
    char key[NOISE_HISTORY];
    int numElements;
    int size;
    char *elements;
    char flag;
    float dist[NOISE_NUM_VALUES];
  } sim_noise_hash_t;
  #line 75
  #line 65
  typedef struct sim_noise_node_t {
    char key[NOISE_HISTORY];
    char freqKey[NOISE_HISTORY];
    char lastNoiseVal;
    uint32_t noiseGenTime;
    struct hashtable *noiseTable;
    char *noiseTrace;
    uint32_t noiseTraceLen;
    uint32_t noiseTraceIndex;
    bool generated;
  } sim_noise_node_t;
  
  void sim_noise_init();
  
  char sim_noise_generate(uint16_t node_id, uint32_t cur_t);
  void sim_noise_trace_add(uint16_t node_id, char val);
  void sim_noise_create_model(uint16_t node_id);
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.c"
  static sim_time_t sim_ticks;
  static unsigned long current_node;
  static int sim_seed;
  
  static int __nesc_nido_resolve(int mote, char *varname, uintptr_t *addr, size_t *size);
  
  void sim_init()   ;
  #line 72
  void sim_end()   ;
  
  
  
  
  
  int sim_random()   ;
  #line 94
  void sim_random_seed(int seed)   ;
  
  
  
  
  
  
  
  sim_time_t sim_time()   ;
  
  
  void sim_set_time(sim_time_t t)   ;
  
  
  
  sim_time_t sim_ticks_per_sec()   ;
  
  
  
  unsigned long sim_node()   ;
  
  
  void sim_set_node(unsigned long node)   ;
  
  
  
  
  bool sim_run_next_event()   ;
  #line 148
  int sim_print_time(char *buf, int len, sim_time_t ftime)   ;
  #line 171
  int sim_print_now(char *buf, int len)   ;
  
  
  
  char simTimeBuf[128];
  char *sim_time_string()   ;
  
  
  
  
  void sim_add_channel(char *channel, FILE *file)   ;
  
  
  
  bool sim_remove_channel(char *channel, FILE *file)   ;
  # 91 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_csma.h"
  int sim_csma_init_high();
  int sim_csma_init_low();
  int sim_csma_high();
  int sim_csma_low();
  int sim_csma_symbols_per_sec();
  int sim_csma_bits_per_symbol();
  int sim_csma_preamble_length();
  int sim_csma_exponent_base();
  int sim_csma_max_iterations();
  int sim_csma_min_free_samples();
  int sim_csma_rxtx_delay();
  int sim_csma_ack_time();
  
  void sim_csma_set_init_high(int val);
  void sim_csma_set_init_low(int val);
  void sim_csma_set_high(int val);
  void sim_csma_set_low(int val);
  void sim_csma_set_symbols_per_sec(int val);
  void sim_csma_set_bits_per_symbol(int val);
  void sim_csma_set_preamble_length(int val);
  void sim_csma_set_exponent_base(int val);
  void sim_csma_set_max_iterations(int val);
  void sim_csma_set_min_free_samples(int val);
  void sim_csma_set_rxtx_delay(int val);
  void sim_csma_set_ack_time(int val);
  # 36 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_csma.c"
  int csmaInitHigh = 640;
  int csmaInitLow = 20;
  int csmaHigh = 160;
  int csmaLow = 20;
  int csmaSymbolsPerSec = 65536;
  int csmaBitsPerSymbol = 4;
  int csmaPreambleLength = 12;
  int csmaExponentBase = 1;
  int csmaMaxIterations = 0;
  int csmaMinFreeSamples = 1;
  int csmaRxTxDelay = 11;
  int csmaAckTime = 34;
  
  int sim_csma_init_high()   ;
  
  
  int sim_csma_init_low()   ;
  
  
  int sim_csma_high()   ;
  
  
  int sim_csma_low()   ;
  
  
  int sim_csma_symbols_per_sec()   ;
  
  
  int sim_csma_bits_per_symbol()   ;
  
  
  int sim_csma_preamble_length()   ;
  
  
  int sim_csma_exponent_base()   ;
  
  
  int sim_csma_max_iterations()   ;
  
  
  int sim_csma_min_free_samples()   ;
  
  
  int sim_csma_rxtx_delay()   ;
  
  
  int sim_csma_ack_time()   ;
  
  
  
  
  
  void sim_csma_set_init_high(int val)   ;
  
  
  void sim_csma_set_init_low(int val)   ;
  
  
  void sim_csma_set_high(int val)   ;
  
  
  void sim_csma_set_low(int val)   ;
  
  
  void sim_csma_set_symbols_per_sec(int val)   ;
  
  
  void sim_csma_set_bits_per_symbol(int val)   ;
  
  
  void sim_csma_set_preamble_length(int val)   ;
  
  
  void sim_csma_set_exponent_base(int val)   ;
  
  
  void sim_csma_set_max_iterations(int val)   ;
  
  
  void sim_csma_set_min_free_samples(int val)   ;
  
  
  void sim_csma_set_rxtx_delay(int val)   ;
  
  
  void sim_csma_set_ack_time(int val)   ;
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_gain.h"
  #line 45
  typedef struct gain_entry {
    int mote;
    double gain;
    struct gain_entry *next;
  } gain_entry_t;
  
  void sim_gain_add(int src, int dest, double gain);
  double sim_gain_value(int src, int dest);
  bool sim_gain_connected(int src, int dest);
  void sim_gain_remove(int src, int dest);
  void sim_gain_set_noise_floor(int node, double mean, double range);
  double sim_gain_sample_noise(int node);
  
  
  
  void sim_gain_set_sensitivity(double value);
  double sim_gain_sensitivity();
  
  gain_entry_t *sim_gain_first(int src);
  gain_entry_t *sim_gain_next(gain_entry_t *e);
  # 6 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_gain.c"
  #line 3
  typedef struct sim_gain_noise {
    double mean;
    double range;
  } sim_gain_noise_t;
  
  
  gain_entry_t *connectivity[1000 + 1];
  sim_gain_noise_t localNoise[1000 + 1];
  double sensitivity = 4.0;
  
  static inline gain_entry_t *sim_gain_allocate_link(int mote);
  void sim_gain_deallocate_link(gain_entry_t *linkToDelete);
  
  gain_entry_t *sim_gain_first(int src)   ;
  
  
  
  
  
  
  gain_entry_t *sim_gain_next(gain_entry_t *currentLink)   ;
  
  
  
  void sim_gain_add(int src, int dest, double gain)   ;
  #line 55
  double sim_gain_value(int src, int dest)   ;
  #line 73
  bool sim_gain_connected(int src, int dest)   ;
  #line 89
  void sim_gain_remove(int src, int dest)   ;
  #line 124
  void sim_gain_set_noise_floor(int node, double mean, double range)   ;
  #line 148
  double sim_gain_sample_noise(int node)   ;
  #line 161
  static inline gain_entry_t *sim_gain_allocate_link(int mote);
  
  
  
  
  
  
  
  void sim_gain_deallocate_link(gain_entry_t *linkToDelete)   ;
  
  
  
  void sim_gain_set_sensitivity(double s)   ;
  
  
  
  double sim_gain_sensitivity()   ;
  # 39 "/opt/tinyos-2.1.0/tos/lib/tossim/randomlib.c"
  static double randU[97];
  #line 39
  static double randC;
  #line 39
  static double randCD;
  #line 39
  static double randCM;
  static int i97;
  #line 40
  static int j97;
  static int test = FALSE;
  #line 55
  static inline void RandomInitialise(int ij, int kl);
  #line 103
  static double RandomUniform(void );
  # 133 "/usr/include/time.h" 3
  struct tm {
  
    int tm_sec;
    int tm_min;
    int tm_hour;
    int tm_mday;
    int tm_mon;
    int tm_year;
    int tm_wday;
    int tm_yday;
    int tm_isdst;
  
  
    long int tm_gmtoff;
    const char *tm_zone;
  };
  #line 161
  struct itimerspec {
  
    struct timespec it_interval;
    struct timespec it_value;
  };
  
  
  struct sigevent;
  # 233 "/usr/include/time.h"
  struct tm;
  
  
  
  struct tm;
  
  
  
  
  
  struct tm;
  
  
  
  
  struct tm;
  # 46 "/opt/tinyos-2.1.0/tos/lib/tossim/randomlib.h"
  static inline void RandomInitialise(int arg_0x2b37c1753288, int arg_0x2b37c17534f0);
  static double RandomUniform(void );
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
  int numCase1 = 0;
  int numCase2 = 0;
  int numTotal = 0;
  
  
  uint32_t FreqKeyNum = 0;
  
  sim_noise_node_t noiseData[1000];
  
  inline static unsigned int sim_noise_hash(void *key);
  inline static int sim_noise_eq(void *key1, void *key2);
  
  void makeNoiseModel(uint16_t node_id);
  void makePmfDistr(uint16_t node_id);
  uint8_t search_bin_num(char noise);
  
  void sim_noise_init()   ;
  #line 76
  void sim_noise_create_model(uint16_t node_id)   ;
  #line 89
  void sim_noise_trace_add(uint16_t node_id, char noiseVal)   ;
  #line 105
  uint8_t search_bin_num(char noise)   ;
  
  
  
  
  
  
  
  
  
  char search_noise_from_bin_num(int i)   ;
  
  
  
  
  
  
  inline static unsigned int sim_noise_hash(void *key);
  
  
  
  
  
  
  
  
  
  inline static int sim_noise_eq(void *key1, void *key2);
  
  
  
  void sim_noise_add(uint16_t node_id, char noise)   ;
  #line 184
  void sim_noise_dist(uint16_t node_id)   ;
  #line 237
  void arrangeKey(uint16_t node_id)   ;
  
  
  
  
  
  
  
  
  
  void makePmfDistr(uint16_t node_id)   ;
  #line 275
  int dummy;
  static inline void sim_noise_alarm();
  
  
  
  char sim_noise_gen(uint16_t node_id)   ;
  #line 356
  char sim_noise_generate(uint16_t node_id, uint32_t cur_t)   ;
  #line 411
  void makeNoiseModel(uint16_t node_id)   ;
  # 51 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_packet.h"
  typedef struct sim_packet {
  } 
  #line 51
  sim_packet_t;
  
  void sim_packet_set_source(sim_packet_t *msg, uint16_t src);
  uint16_t sim_packet_source(sim_packet_t *msg);
  
  void sim_packet_set_destination(sim_packet_t *msg, uint16_t dest);
  uint16_t sim_packet_destination(sim_packet_t *msg);
  
  void sim_packet_set_length(sim_packet_t *msg, uint8_t len);
  uint16_t sim_packet_length(sim_packet_t *msg);
  
  void sim_packet_set_type(sim_packet_t *msg, uint8_t type);
  uint8_t sim_packet_type(sim_packet_t *msg);
  
  uint8_t *sim_packet_data(sim_packet_t *msg);
  void sim_packet_set_strength(sim_packet_t *msg, uint16_t str);
  
  void sim_packet_deliver(int node, sim_packet_t *msg, sim_time_t t);
  uint8_t sim_packet_max_length(sim_packet_t *msg);
  
  sim_packet_t *sim_packet_allocate();
  void sim_packet_free(sim_packet_t *m);
  # 6 "/opt/tinyos-2.1.0/tos/types/AM.h"
  typedef nx_uint8_t nx_am_id_t;
  typedef nx_uint8_t nx_am_group_t;
  typedef nx_uint16_t nx_am_addr_t;
  
  typedef uint8_t am_id_t;
  typedef uint8_t am_group_t;
  typedef uint16_t am_addr_t;
  
  enum __nesc_unnamed4274 {
    AM_BROADCAST_ADDR = 0xffff
  };
  
  
  
  
  
  
  
  
  
  enum __nesc_unnamed4275 {
    TOS_AM_GROUP = 0x22, 
    TOS_AM_ADDRESS = 1
  };
  # 12 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimRadioMsg.h"
  #line 6
  typedef nx_struct tossim_header {
    nx_am_addr_t dest;
    nx_am_addr_t src;
    nx_uint8_t length;
    nx_am_group_t group;
    nx_am_id_t type;
  } __attribute__((packed)) tossim_header_t;
  
  
  
  #line 14
  typedef nx_struct tossim_footer {
    nxle_uint16_t crc;
  } __attribute__((packed)) tossim_footer_t;
  
  
  
  
  
  #line 18
  typedef nx_struct tossim_metadata {
    nx_int8_t strength;
    nx_uint8_t ack;
    nx_uint16_t time;
  } __attribute__((packed)) tossim_metadata_t;
  # 72 "/opt/tinyos-2.1.0/tos/lib/serial/Serial.h"
  typedef uint8_t uart_id_t;
  
  
  
  enum __nesc_unnamed4276 {
    HDLC_FLAG_BYTE = 0x7e, 
    HDLC_CTLESC_BYTE = 0x7d
  };
  
  
  
  enum __nesc_unnamed4277 {
    TOS_SERIAL_ACTIVE_MESSAGE_ID = 0, 
    TOS_SERIAL_CC1000_ID = 1, 
    TOS_SERIAL_802_15_4_ID = 2, 
    TOS_SERIAL_UNKNOWN_ID = 255
  };
  
  
  enum __nesc_unnamed4278 {
    SERIAL_PROTO_ACK = 67, 
    SERIAL_PROTO_PACKET_ACK = 68, 
    SERIAL_PROTO_PACKET_NOACK = 69, 
    SERIAL_PROTO_PACKET_UNKNOWN = 255
  };
  #line 110
  #line 98
  typedef struct radio_stats {
    uint8_t version;
    uint8_t flags;
    uint8_t reserved;
    uint8_t platform;
    uint16_t MTU;
    uint16_t radio_crc_fail;
    uint16_t radio_queue_drops;
    uint16_t serial_crc_fail;
    uint16_t serial_tx_fail;
    uint16_t serial_short_packets;
    uint16_t serial_proto_drops;
  } radio_stats_t;
  
  
  
  
  
  
  
  #line 112
  typedef nx_struct serial_header {
    nx_am_addr_t dest;
    nx_am_addr_t src;
    nx_uint8_t length;
    nx_am_group_t group;
    nx_am_id_t type;
  } __attribute__((packed)) serial_header_t;
  
  
  
  
  #line 120
  typedef nx_struct serial_packet {
    serial_header_t header;
    nx_uint8_t data[];
  } __attribute__((packed)) serial_packet_t;
  
  
  
  #line 125
  typedef nx_struct serial_metadata {
    nx_uint8_t ack;
  } __attribute__((packed)) serial_metadata_t;
  # 44 "/opt/tinyos-2.1.0/tos/lib/tossim/platform_message.h"
  #line 41
  typedef union message_header {
    tossim_header_t tossim;
    serial_header_t serial;
  } message_header_t;
  
  
  
  #line 46
  typedef union message_footer {
    tossim_footer_t tossim;
  } message_footer_t;
  
  
  
  #line 50
  typedef union message_metadata {
    tossim_metadata_t tossim;
  } message_metadata_t;
  # 19 "/opt/tinyos-2.1.0/tos/types/message.h"
  #line 14
  typedef nx_struct message_t {
    nx_uint8_t header[sizeof(message_header_t )];
    nx_uint8_t data[28];
    nx_uint8_t footer[sizeof(message_footer_t )];
    nx_uint8_t metadata[sizeof(message_metadata_t )];
  } __attribute__((packed)) message_t;
  # 40 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_packet.c"
  void active_message_deliver(int node, message_t *m, sim_time_t t);
  
  inline static tossim_header_t *getHeader(message_t *msg);
  
  
  
  void sim_packet_set_source(sim_packet_t *msg, uint16_t src)   ;
  
  
  
  
  uint16_t sim_packet_source(sim_packet_t *msg)   ;
  
  
  
  
  void sim_packet_set_destination(sim_packet_t *msg, uint16_t dest)   ;
  
  
  
  
  uint16_t sim_packet_destination(sim_packet_t *msg)   ;
  
  
  
  
  void sim_packet_set_length(sim_packet_t *msg, uint8_t length)   ;
  
  
  
  uint16_t sim_packet_length(sim_packet_t *msg)   ;
  
  
  
  
  void sim_packet_set_type(sim_packet_t *msg, uint8_t type)   ;
  
  
  
  
  uint8_t sim_packet_type(sim_packet_t *msg)   ;
  
  
  
  
  uint8_t *sim_packet_data(sim_packet_t *p)   ;
  
  
  
  void sim_packet_set_strength(sim_packet_t *p, uint16_t str)   ;
  
  
  
  
  void sim_packet_deliver(int node, sim_packet_t *msg, sim_time_t t)   ;
  
  
  
  
  
  
  
  uint8_t sim_packet_max_length(sim_packet_t *msg)   ;
  
  
  
  sim_packet_t *sim_packet_allocate()   ;
  
  
  
  void sim_packet_free(sim_packet_t *p)   ;
  # 40 "/opt/tinyos-2.1.0/tos/types/TinyError.h"
  enum __nesc_unnamed4279 {
    SUCCESS = 0, 
    FAIL = 1, 
    ESIZE = 2, 
    ECANCEL = 3, 
    EOFF = 4, 
    EBUSY = 5, 
    EINVAL = 6, 
    ERETRY = 7, 
    ERESERVE = 8, 
    EALREADY = 9, 
    ENOMEM = 10, 
    ENOACK = 11, 
    ELAST = 11
  };
  
  typedef uint8_t error_t  ;
  
  static inline error_t ecombine(error_t r1, error_t r2)  ;
  # 51 "Rout.h"
  #line 44
  typedef nx_struct rout_msg {
    nx_uint8_t type;
    nx_uint16_t from;
    nx_uint32_t seq;
    nx_uint16_t content;
    nx_uint8_t batteryLevel;
    nx_int8_t clHead;
  } __attribute__((packed)) rout_msg_t;
  # 29 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.h"
  typedef struct __nesc_unnamed4280 {
  #line 29
    int notUsed;
  } 
  #line 29
  TMilli;
  typedef struct __nesc_unnamed4281 {
  #line 30
    int notUsed;
  } 
  #line 30
  T32khz;
  typedef struct __nesc_unnamed4282 {
  #line 31
    int notUsed;
  } 
  #line 31
  TMicro;
  # 25 "/opt/tinyos-2.1.0/tos/chips/atm128/sim/atm128_sim.h"
  enum __nesc_unnamed4283 {
  
    ATM128_PINF = 0x00, 
  
  
    ATM128_PINE = 0x01, 
  
  
    ATM128_DDRE = 0x02, 
  
  
    ATM128_PORTE = 0x03, 
  
  
    ATM128_ADCW = 0x04, 
  
    ATM128_ADC = 0x04, 
  
    ATM128_ADCL = 0x04, 
    ATM128_ADCH = 0x05, 
  
  
    ATM128_ADCSR = 0x06, 
    ATM128_ADCSRA = 0x06, 
  
  
    ATM128_ADMUX = 0x07, 
  
  
    ATM128_ACSR = 0x08, 
  
  
    ATM128_UBRR0L = 0x09, 
  
  
    ATM128_UCSR0B = 0x0A, 
  
  
    ATM128_UCSR0A = 0x0B, 
  
  
    ATM128_UDR0 = 0x0C, 
  
  
    ATM128_SPCR = 0x0D, 
  
  
    ATM128_SPSR = 0x0E, 
  
  
    ATM128_SPDR = 0x0F, 
  
  
    ATM128_PIND = 0x10, 
  
  
    ATM128_DDRD = 0x11, 
  
  
    ATM128_PORTD = 0x12, 
  
  
    ATM128_PINC = 0x13, 
  
  
    ATM128_DDRC = 0x14, 
  
  
    ATM128_PORTC = 0x15, 
  
  
    ATM128_PINB = 0x16, 
  
  
    ATM128_DDRB = 0x17, 
  
  
    ATM128_PORTB = 0x18, 
  
  
    ATM128_PINA = 0x19, 
  
  
    ATM128_DDRA = 0x1A, 
  
  
    ATM128_PORTA = 0x1B, 
  
  
  
  
    ATM128_SFIOR = 0x20, 
  
  
    ATM128_WDTCR = 0x21, 
  
  
    ATM128_OCDR = 0x22, 
  
  
    ATM128_OCR2 = 0x23, 
  
  
    ATM128_TCNT2 = 0x24, 
  
  
    ATM128_TCCR2 = 0x25, 
  
  
    ATM128_ICR1 = 0x26, 
    ATM128_ICR1L = 0x26, 
    ATM128_ICR1H = 0x27, 
  
  
    ATM128_OCR1B = 0x28, 
    ATM128_OCR1BL = 0x28, 
    ATM128_OCR1BH = 0x29, 
  
  
    ATM128_OCR1A = 0x2A, 
    ATM128_OCR1AL = 0x2A, 
    ATM128_OCR1AH = 0x2B, 
  
  
    ATM128_TCNT1 = 0x2C, 
    ATM128_TCNT1L = 0x2C, 
    ATM128_TCNT1H = 0x2D, 
  
  
    ATM128_TCCR1B = 0x2E, 
  
  
    ATM128_TCCR1A = 0x2F, 
  
  
    ATM128_ASSR = 0x30, 
  
  
    ATM128_OCR0 = 0x31, 
  
  
    ATM128_TCNT0 = 0x32, 
  
  
    ATM128_TCCR0 = 0x33, 
  
  
    ATM128_MCUSR = 0x34, 
    ATM128_MCUCSR = 0x34, 
  
  
    ATM128_MCUCR = 0x35, 
  
  
    ATM128_TIFR = 0x36, 
  
  
    ATM128_TIMSK = 0x37, 
  
  
    ATM128_EIFR = 0x38, 
  
  
    ATM128_EIMSK = 0x39, 
  
  
    ATM128_EICRB = 0x3A, 
  
  
    ATM128_RAMPZ = 0x3B, 
  
  
    ATM128_XDIV = 0x3C, 
  
  
  
  
    ATM128_SREG = 0x3F, 
  
  
  
  
    ATM128_DDRF = 0x61, 
  
  
    ATM128_PORTF = 0x62, 
  
  
    ATM128_PING = 0x63, 
  
  
    ATM128_DDRG = 0x64, 
  
  
    ATM128_PORTG = 0x65, 
  
  
    ATM128_SPMCR = 0x68, 
    ATM128_SPMCSR = 0x68, 
  
  
    ATM128_EICRA = 0x6A, 
  
  
    ATM128_XMCRB = 0x6C, 
  
  
    ATM128_XMCRA = 0x6D, 
  
  
    ATM128_OSCCAL = 0x6F, 
  
  
    ATM128_TWBR = 0x70, 
  
  
    ATM128_TWSR = 0x71, 
  
  
    ATM128_TWAR = 0x72, 
  
  
    ATM128_TWDR = 0x73, 
  
  
    ATM128_TWCR = 0x74, 
  
  
    ATM128_OCR1C = 0x78, 
    ATM128_OCR1CL = 0x78, 
    ATM128_OCR1CH = 0x79, 
  
  
    ATM128_TCCR1C = 0x7A, 
  
  
    ATM128_ETIFR = 0x7C, 
  
  
    ATM128_ETIMSK = 0x7D, 
  
  
    ATM128_ICR3 = 0x80, 
    ATM128_ICR3L = 0x80, 
    ATM128_ICR3H = 0x81, 
  
  
    ATM128_OCR3C = 0x82, 
    ATM128_OCR3CL = 0x82, 
    ATM128_OCR3CH = 0x83, 
  
  
    ATM128_OCR3B = 0x84, 
    ATM128_OCR3BL = 0x84, 
    ATM128_OCR3BH = 0x85, 
  
  
    ATM128_OCR3A = 0x86, 
    ATM128_OCR3AL = 0x86, 
    ATM128_OCR3AH = 0x87, 
  
  
    ATM128_TCNT3 = 0x88, 
    ATM128_TCNT3L = 0x88, 
    ATM128_TCNT3H = 0x89, 
  
  
    ATM128_TCCR3B = 0x8A, 
  
  
    ATM128_TCCR3A = 0x8B, 
  
  
    ATM128_TCCR3C = 0x8C, 
  
  
    ATM128_UBRR0H = 0x90, 
  
  
    ATM128_UCSR0C = 0x95, 
  
  
    ATM128_UBRR1H = 0x98, 
  
  
    ATM128_UBRR1L = 0x99, 
  
  
    ATM128_UCSR1B = 0x9A, 
  
  
    ATM128_UCSR1A = 0x9B, 
  
  
    ATM128_UDR1 = 0x9C, 
  
  
    ATM128_UCSR1C = 0x9D
  };
  #line 673
  enum __nesc_unnamed4284 {
  
    TWINT = 7, 
    TWEA = 6, 
    TWSTA = 5, 
    TWSTO = 4, 
    TWWC = 3, 
    TWEN = 2, 
    TWIE = 0, 
  
  
    TWA6 = 7, 
    TWA5 = 6, 
    TWA4 = 5, 
    TWA3 = 4, 
    TWA2 = 3, 
    TWA1 = 2, 
    TWA0 = 1, 
    TWGCE = 0, 
  
  
    TWS7 = 7, 
    TWS6 = 6, 
    TWS5 = 5, 
    TWS4 = 4, 
    TWS3 = 3, 
    TWPS1 = 1, 
    TWPS0 = 0, 
  
  
    SRL2 = 6, 
    SRL1 = 5, 
    SRL0 = 4, 
    SRW01 = 3, 
    SRW00 = 2, 
    SRW11 = 1, 
  
  
    XMBK = 7, 
    XMM2 = 2, 
    XMM1 = 1, 
    XMM0 = 0, 
  
  
    XDIVEN = 7, 
    XDIV6 = 6, 
    XDIV5 = 5, 
    XDIV4 = 4, 
    XDIV3 = 3, 
    XDIV2 = 2, 
    XDIV1 = 1, 
    XDIV0 = 0, 
  
  
    RAMPZ0 = 0, 
  
  
    ISC31 = 7, 
    ISC30 = 6, 
    ISC21 = 5, 
    ISC20 = 4, 
    ISC11 = 3, 
    ISC10 = 2, 
    ISC01 = 1, 
    ISC00 = 0, 
  
  
    ISC71 = 7, 
    ISC70 = 6, 
    ISC61 = 5, 
    ISC60 = 4, 
    ISC51 = 3, 
    ISC50 = 2, 
    ISC41 = 1, 
    ISC40 = 0, 
  
  
    SPMIE = 7, 
    RWWSB = 6, 
    RWWSRE = 4, 
    BLBSET = 3, 
    PGWRT = 2, 
    PGERS = 1, 
    SPMEN = 0, 
  
  
    INT7 = 7, 
    INT6 = 6, 
    INT5 = 5, 
    INT4 = 4, 
    INT3 = 3, 
    INT2 = 2, 
    INT1 = 1, 
    INT0 = 0, 
  
  
    INTF7 = 7, 
    INTF6 = 6, 
    INTF5 = 5, 
    INTF4 = 4, 
    INTF3 = 3, 
    INTF2 = 2, 
    INTF1 = 1, 
    INTF0 = 0, 
  
  
    OCIE2 = 7, 
    TOIE2 = 6, 
    TICIE1 = 5, 
    OCIE1A = 4, 
    OCIE1B = 3, 
    TOIE1 = 2, 
    OCIE0 = 1, 
    TOIE0 = 0, 
  
  
    OCF2 = 7, 
    TOV2 = 6, 
    ICF1 = 5, 
    OCF1A = 4, 
    OCF1B = 3, 
    TOV1 = 2, 
    OCF0 = 1, 
    TOV0 = 0, 
  
  
    TICIE3 = 5, 
    OCIE3A = 4, 
    OCIE3B = 3, 
    TOIE3 = 2, 
    OCIE3C = 1, 
    OCIE1C = 0, 
  
  
    ICF3 = 5, 
    OCF3A = 4, 
    OCF3B = 3, 
    TOV3 = 2, 
    OCF3C = 1, 
    OCF1C = 0, 
  
  
    SRE = 7, 
    SRW = 6, 
    SRW10 = 6, 
    SE = 5, 
    SM1 = 4, 
    SM0 = 3, 
    SM2 = 2, 
    IVSEL = 1, 
    IVCE = 0, 
  
  
    JTD = 7, 
    JTRF = 4, 
    WDRF = 3, 
    BORF = 2, 
    EXTRF = 1, 
    PORF = 0, 
  
  
    FOC = 7, 
    WGM0 = 6, 
    COM1 = 5, 
    COM0 = 4, 
    WGM1 = 3, 
    CS2 = 2, 
    CS1 = 1, 
    CS0 = 0, 
  
  
    FOC0 = 7, 
    WGM00 = 6, 
    COM01 = 5, 
    COM00 = 4, 
    WGM01 = 3, 
    CS02 = 2, 
    CS01 = 1, 
    CS00 = 0, 
  
  
    FOC2 = 7, 
    WGM20 = 6, 
    COM21 = 5, 
    COM20 = 4, 
    WGM21 = 3, 
    CS22 = 2, 
    CS21 = 1, 
    CS20 = 0, 
  
  
    AS0 = 3, 
    TCN0UB = 2, 
    OCR0UB = 1, 
    TCR0UB = 0, 
  
  
    COMA1 = 7, 
    COMA0 = 6, 
    COMB1 = 5, 
    COMB0 = 4, 
    COMC1 = 3, 
    COMC0 = 2, 
    WGMA1 = 1, 
    WGMA0 = 0, 
  
  
    COM1A1 = 7, 
    COM1A0 = 6, 
    COM1B1 = 5, 
    COM1B0 = 4, 
    COM1C1 = 3, 
    COM1C0 = 2, 
    WGM11 = 1, 
    WGM10 = 0, 
  
  
    COM3A1 = 7, 
    COM3A0 = 6, 
    COM3B1 = 5, 
    COM3B0 = 4, 
    COM3C1 = 3, 
    COM3C0 = 2, 
    WGM31 = 1, 
    WGM30 = 0, 
  
  
    ICNC = 7, 
    ICES = 6, 
    WGMB3 = 4, 
    WGMB2 = 3, 
    CSB2 = 2, 
    CSB1 = 1, 
    CSB0 = 0, 
  
  
    ICNC1 = 7, 
    ICES1 = 6, 
    WGM13 = 4, 
    WGM12 = 3, 
    CS12 = 2, 
    CS11 = 1, 
    CS10 = 0, 
  
  
    ICNC3 = 7, 
    ICES3 = 6, 
    WGM33 = 4, 
    WGM32 = 3, 
    CS32 = 2, 
    CS31 = 1, 
    CS30 = 0, 
  
  
    FOCA = 7, 
    FOCB = 6, 
    FOCC = 5, 
  
  
    FOC3A = 7, 
    FOC3B = 6, 
    FOC3C = 5, 
  
  
    FOC1A = 7, 
    FOC1B = 6, 
    FOC1C = 5, 
  
  
    IDRD = 7, 
    OCDR7 = 7, 
    OCDR6 = 6, 
    OCDR5 = 5, 
    OCDR4 = 4, 
    OCDR3 = 3, 
    OCDR2 = 2, 
    OCDR1 = 1, 
    OCDR0 = 0, 
  
  
    WDCE = 4, 
    WDE = 3, 
    WDP2 = 2, 
    WDP1 = 1, 
    WDP0 = 0, 
  
  
    TSM = 7, 
    ADHSM = 4, 
    ACME = 3, 
    PUD = 2, 
    PSR0 = 1, 
    PSR321 = 0, 
  
  
    SPIF = 7, 
    WCOL = 6, 
    SPI2X = 0, 
  
  
    SPIE = 7, 
    SPE = 6, 
    DORD = 5, 
    MSTR = 4, 
    CPOL = 3, 
    CPHA = 2, 
    SPR1 = 1, 
    SPR0 = 0, 
  
  
    UMSEL = 6, 
    UPM1 = 5, 
    UPM0 = 4, 
    USBS = 3, 
    UCSZ1 = 2, 
    UCSZ0 = 1, 
    UCPOL = 0, 
  
  
    UMSEL1 = 6, 
    UPM11 = 5, 
    UPM10 = 4, 
    USBS1 = 3, 
    UCSZ11 = 2, 
    UCSZ10 = 1, 
    UCPOL1 = 0, 
  
  
    UMSEL0 = 6, 
    UPM01 = 5, 
    UPM00 = 4, 
    USBS0 = 3, 
    UCSZ01 = 2, 
    UCSZ00 = 1, 
    UCPOL0 = 0, 
  
  
    RXC = 7, 
    TXC = 6, 
    UDRE = 5, 
    FE = 4, 
    DOR = 3, 
    UPE = 2, 
    U2X = 1, 
    MPCM = 0, 
  
  
    RXC1 = 7, 
    TXC1 = 6, 
    UDRE1 = 5, 
    FE1 = 4, 
    DOR1 = 3, 
    UPE1 = 2, 
    U2X1 = 1, 
    MPCM1 = 0, 
  
  
    RXC0 = 7, 
    TXC0 = 6, 
    UDRE0 = 5, 
    FE0 = 4, 
    DOR0 = 3, 
    UPE0 = 2, 
    U2X0 = 1, 
    MPCM0 = 0, 
  
  
    RXCIE = 7, 
    TXCIE = 6, 
    UDRIE = 5, 
    RXEN = 4, 
    TXEN = 3, 
    UCSZ = 2, 
    UCSZ2 = 2, 
    RXB8 = 1, 
    TXB8 = 0, 
  
  
    RXCIE1 = 7, 
    TXCIE1 = 6, 
    UDRIE1 = 5, 
    RXEN1 = 4, 
    TXEN1 = 3, 
    UCSZ12 = 2, 
    RXB81 = 1, 
    TXB81 = 0, 
  
  
    RXCIE0 = 7, 
    TXCIE0 = 6, 
    UDRIE0 = 5, 
    RXEN0 = 4, 
    TXEN0 = 3, 
    UCSZ02 = 2, 
    RXB80 = 1, 
    TXB80 = 0, 
  
  
    ACD = 7, 
    ACBG = 6, 
    ACO = 5, 
    ACI = 4, 
    ACIE = 3, 
    ACIC = 2, 
    ACIS1 = 1, 
    ACIS0 = 0, 
  
  
    ADEN = 7, 
    ADSC = 6, 
    ADFR = 5, 
    ADIF = 4, 
    ADIE = 3, 
    ADPS2 = 2, 
    ADPS1 = 1, 
    ADPS0 = 0, 
  
  
    REFS1 = 7, 
    REFS0 = 6, 
    ADLAR = 5, 
    MUX4 = 4, 
    MUX3 = 3, 
    MUX2 = 2, 
    MUX1 = 1, 
    MUX0 = 0, 
  
  
    PA7 = 7, 
    PA6 = 6, 
    PA5 = 5, 
    PA4 = 4, 
    PA3 = 3, 
    PA2 = 2, 
    PA1 = 1, 
    PA0 = 0, 
  
  
    DDA7 = 7, 
    DDA6 = 6, 
    DDA5 = 5, 
    DDA4 = 4, 
    DDA3 = 3, 
    DDA2 = 2, 
    DDA1 = 1, 
    DDA0 = 0, 
  
  
    PINA7 = 7, 
    PINA6 = 6, 
    PINA5 = 5, 
    PINA4 = 4, 
    PINA3 = 3, 
    PINA2 = 2, 
    PINA1 = 1, 
    PINA0 = 0, 
  
  
    PB7 = 7, 
    PB6 = 6, 
    PB5 = 5, 
    PB4 = 4, 
    PB3 = 3, 
    PB2 = 2, 
    PB1 = 1, 
    PB0 = 0, 
  
  
    DDB7 = 7, 
    DDB6 = 6, 
    DDB5 = 5, 
    DDB4 = 4, 
    DDB3 = 3, 
    DDB2 = 2, 
    DDB1 = 1, 
    DDB0 = 0, 
  
  
    PINB7 = 7, 
    PINB6 = 6, 
    PINB5 = 5, 
    PINB4 = 4, 
    PINB3 = 3, 
    PINB2 = 2, 
    PINB1 = 1, 
    PINB0 = 0, 
  
  
    PC7 = 7, 
    PC6 = 6, 
    PC5 = 5, 
    PC4 = 4, 
    PC3 = 3, 
    PC2 = 2, 
    PC1 = 1, 
    PC0 = 0, 
  
  
    DDC7 = 7, 
    DDC6 = 6, 
    DDC5 = 5, 
    DDC4 = 4, 
    DDC3 = 3, 
    DDC2 = 2, 
    DDC1 = 1, 
    DDC0 = 0, 
  
  
    PINC7 = 7, 
    PINC6 = 6, 
    PINC5 = 5, 
    PINC4 = 4, 
    PINC3 = 3, 
    PINC2 = 2, 
    PINC1 = 1, 
    PINC0 = 0, 
  
  
    PD7 = 7, 
    PD6 = 6, 
    PD5 = 5, 
    PD4 = 4, 
    PD3 = 3, 
    PD2 = 2, 
    PD1 = 1, 
    PD0 = 0, 
  
  
    DDD7 = 7, 
    DDD6 = 6, 
    DDD5 = 5, 
    DDD4 = 4, 
    DDD3 = 3, 
    DDD2 = 2, 
    DDD1 = 1, 
    DDD0 = 0, 
  
  
    PIND7 = 7, 
    PIND6 = 6, 
    PIND5 = 5, 
    PIND4 = 4, 
    PIND3 = 3, 
    PIND2 = 2, 
    PIND1 = 1, 
    PIND0 = 0, 
  
  
    PE7 = 7, 
    PE6 = 6, 
    PE5 = 5, 
    PE4 = 4, 
    PE3 = 3, 
    PE2 = 2, 
    PE1 = 1, 
    PE0 = 0, 
  
  
    DDE7 = 7, 
    DDE6 = 6, 
    DDE5 = 5, 
    DDE4 = 4, 
    DDE3 = 3, 
    DDE2 = 2, 
    DDE1 = 1, 
    DDE0 = 0, 
  
  
    PINE7 = 7, 
    PINE6 = 6, 
    PINE5 = 5, 
    PINE4 = 4, 
    PINE3 = 3, 
    PINE2 = 2, 
    PINE1 = 1, 
    PINE0 = 0, 
  
  
    PF7 = 7, 
    PF6 = 6, 
    PF5 = 5, 
    PF4 = 4, 
    PF3 = 3, 
    PF2 = 2, 
    PF1 = 1, 
    PF0 = 0, 
  
  
    DDF7 = 7, 
    DDF6 = 6, 
    DDF5 = 5, 
    DDF4 = 4, 
    DDF3 = 3, 
    DDF2 = 2, 
    DDF1 = 1, 
    DDF0 = 0, 
  
  
    PINF7 = 7, 
    PINF6 = 6, 
    PINF5 = 5, 
    PINF4 = 4, 
    PINF3 = 3, 
    PINF2 = 2, 
    PINF1 = 1, 
    PINF0 = 0, 
  
  
    PG4 = 4, 
    PG3 = 3, 
    PG2 = 2, 
    PG1 = 1, 
    PG0 = 0, 
  
  
    DDG4 = 4, 
    DDG3 = 3, 
    DDG2 = 2, 
    DDG1 = 1, 
    DDG0 = 0, 
  
  
    PING4 = 4, 
    PING3 = 3, 
    PING2 = 2, 
    PING1 = 1, 
    PING0 = 0
  };
  # 45 "/opt/tinyos-2.1.0/tos/chips/atm128/sim/atm128hardware.h"
  uint8_t atm128RegFile[1000][0xa0];
  #line 79
  static __inline void __nesc_enable_interrupt();
  
  
  
  static __inline void __nesc_disable_interrupt();
  
  
  
  
  typedef uint8_t __nesc_atomic_t;
  
  
  
  #line 91
  __inline __nesc_atomic_t 
  __nesc_atomic_start(void )  ;
  
  
  
  
  
  
  
  
  #line 100
  __inline void 
  __nesc_atomic_end(__nesc_atomic_t original_SREG)  ;
  #line 114
  typedef uint8_t mcu_power_t  ;
  
  
  
  
  
  enum __nesc_unnamed4285 {
    ATM128_POWER_IDLE = 0, 
    ATM128_POWER_ADC_NR = 1, 
    ATM128_POWER_EXT_STANDBY = 2, 
    ATM128_POWER_SAVE = 3, 
    ATM128_POWER_STANDBY = 4, 
    ATM128_POWER_DOWN = 5
  };
  # 34 "/opt/tinyos-2.1.0/tos/chips/atm128/adc/Atm128Adc.h"
  enum __nesc_unnamed4286 {
    ATM128_ADC_VREF_OFF = 0, 
    ATM128_ADC_VREF_AVCC = 1, 
    ATM128_ADC_VREF_RSVD, 
    ATM128_ADC_VREF_2_56 = 3
  };
  
  
  enum __nesc_unnamed4287 {
    ATM128_ADC_RIGHT_ADJUST = 0, 
    ATM128_ADC_LEFT_ADJUST = 1
  };
  
  
  
  enum __nesc_unnamed4288 {
    ATM128_ADC_SNGL_ADC0 = 0, 
    ATM128_ADC_SNGL_ADC1, 
    ATM128_ADC_SNGL_ADC2, 
    ATM128_ADC_SNGL_ADC3, 
    ATM128_ADC_SNGL_ADC4, 
    ATM128_ADC_SNGL_ADC5, 
    ATM128_ADC_SNGL_ADC6, 
    ATM128_ADC_SNGL_ADC7, 
    ATM128_ADC_DIFF_ADC00_10x, 
    ATM128_ADC_DIFF_ADC10_10x, 
    ATM128_ADC_DIFF_ADC00_200x, 
    ATM128_ADC_DIFF_ADC10_200x, 
    ATM128_ADC_DIFF_ADC22_10x, 
    ATM128_ADC_DIFF_ADC32_10x, 
    ATM128_ADC_DIFF_ADC22_200x, 
    ATM128_ADC_DIFF_ADC32_200x, 
    ATM128_ADC_DIFF_ADC01_1x, 
    ATM128_ADC_DIFF_ADC11_1x, 
    ATM128_ADC_DIFF_ADC21_1x, 
    ATM128_ADC_DIFF_ADC31_1x, 
    ATM128_ADC_DIFF_ADC41_1x, 
    ATM128_ADC_DIFF_ADC51_1x, 
    ATM128_ADC_DIFF_ADC61_1x, 
    ATM128_ADC_DIFF_ADC71_1x, 
    ATM128_ADC_DIFF_ADC02_1x, 
    ATM128_ADC_DIFF_ADC12_1x, 
    ATM128_ADC_DIFF_ADC22_1x, 
    ATM128_ADC_DIFF_ADC32_1x, 
    ATM128_ADC_DIFF_ADC42_1x, 
    ATM128_ADC_DIFF_ADC52_1x, 
    ATM128_ADC_SNGL_1_23, 
    ATM128_ADC_SNGL_GND
  };
  
  
  
  
  
  
  
  #line 85
  typedef struct __nesc_unnamed4289 {
  
    uint8_t mux : 5;
    uint8_t adlar : 1;
    uint8_t refs : 2;
  } Atm128Admux_t;
  
  
  
  
  enum __nesc_unnamed4290 {
    ATM128_ADC_PRESCALE_2 = 0, 
    ATM128_ADC_PRESCALE_2b, 
    ATM128_ADC_PRESCALE_4, 
    ATM128_ADC_PRESCALE_8, 
    ATM128_ADC_PRESCALE_16, 
    ATM128_ADC_PRESCALE_32, 
    ATM128_ADC_PRESCALE_64, 
    ATM128_ADC_PRESCALE_128, 
  
  
  
    ATM128_ADC_PRESCALE
  };
  
  
  enum __nesc_unnamed4291 {
    ATM128_ADC_ENABLE_OFF = 0, 
    ATM128_ADC_ENABLE_ON
  };
  
  
  enum __nesc_unnamed4292 {
    ATM128_ADC_START_CONVERSION_OFF = 0, 
    ATM128_ADC_START_CONVERSION_ON
  };
  
  
  enum __nesc_unnamed4293 {
    ATM128_ADC_FREE_RUNNING_OFF = 0, 
    ATM128_ADC_FREE_RUNNING_ON
  };
  
  
  enum __nesc_unnamed4294 {
    ATM128_ADC_INT_FLAG_OFF = 0, 
    ATM128_ADC_INT_FLAG_ON
  };
  
  
  enum __nesc_unnamed4295 {
    ATM128_ADC_INT_ENABLE_OFF = 0, 
    ATM128_ADC_INT_ENABLE_ON
  };
  
  
  
  
  
  
  
  
  
  
  #line 141
  typedef struct __nesc_unnamed4296 {
  
    uint8_t adps : 3;
    uint8_t adie : 1;
    uint8_t adif : 1;
    uint8_t adfr : 1;
    uint8_t adsc : 1;
    uint8_t aden : 1;
  } Atm128Adcsra_t;
  
  typedef uint8_t Atm128_ADCH_t;
  typedef uint8_t Atm128_ADCL_t;
  # 48 "/opt/tinyos-2.1.0/tos/platforms/micaz/sim/platform_hardware.h"
  enum __nesc_unnamed4297 {
    CHANNEL_RSSI = ATM128_ADC_SNGL_ADC0, 
    CHANNEL_THERMISTOR = ATM128_ADC_SNGL_ADC1, 
    CHANNEL_BATTERY = ATM128_ADC_SNGL_ADC7, 
    CHANNEL_BANDGAP = 30, 
    CHANNEL_GND = 31, 
  
    ATM128_TIMER0_TICKSPPS = 32768
  };
  # 33 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMainP.nc"
  static void __nesc_nido_initialise(int node);
  # 43 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128Timer.h"
  enum __nesc_unnamed4298 {
    ATM128_CLK8_OFF = 0x0, 
    ATM128_CLK8_NORMAL = 0x1, 
    ATM128_CLK8_DIVIDE_8 = 0x2, 
    ATM128_CLK8_DIVIDE_32 = 0x3, 
    ATM128_CLK8_DIVIDE_64 = 0x4, 
    ATM128_CLK8_DIVIDE_128 = 0x5, 
    ATM128_CLK8_DIVIDE_256 = 0x6, 
    ATM128_CLK8_DIVIDE_1024 = 0x7
  };
  
  enum __nesc_unnamed4299 {
    ATM128_CLK16_OFF = 0x0, 
    ATM128_CLK16_NORMAL = 0x1, 
    ATM128_CLK16_DIVIDE_8 = 0x2, 
    ATM128_CLK16_DIVIDE_64 = 0x3, 
    ATM128_CLK16_DIVIDE_256 = 0x4, 
    ATM128_CLK16_DIVIDE_1024 = 0x5, 
    ATM128_CLK16_EXTERNAL_FALL = 0x6, 
    ATM128_CLK16_EXTERNAL_RISE = 0x7
  };
  
  
  enum __nesc_unnamed4300 {
    AVR_CLOCK_OFF = 0, 
    AVR_CLOCK_ON = 1, 
    AVR_CLOCK_DIVIDE_8 = 2
  };
  
  
  enum __nesc_unnamed4301 {
    ATM128_WAVE8_NORMAL = 0, 
    ATM128_WAVE8_PWM, 
    ATM128_WAVE8_CTC, 
    ATM128_WAVE8_PWM_FAST
  };
  
  
  enum __nesc_unnamed4302 {
    ATM128_COMPARE_OFF = 0, 
    ATM128_COMPARE_TOGGLE, 
    ATM128_COMPARE_CLEAR, 
    ATM128_COMPARE_SET
  };
  #line 99
  #line 89
  typedef union __nesc_unnamed4303 {
  
    uint8_t flat;
    struct __nesc_unnamed4304 {
      uint8_t cs : 3;
      uint8_t wgm1 : 1;
      uint8_t com : 2;
      uint8_t wgm0 : 1;
      uint8_t foc : 1;
    } bits;
  } Atm128TimerControl_t;
  
  typedef Atm128TimerControl_t Atm128_TCCR0_t;
  typedef uint8_t Atm128_TCNT0_t;
  typedef uint8_t Atm128_OCR0_t;
  
  typedef Atm128TimerControl_t Atm128_TCCR2_t;
  typedef uint8_t Atm128_TCNT2_t;
  typedef uint8_t Atm128_OCR2_t;
  #line 121
  #line 111
  typedef union __nesc_unnamed4305 {
  
    uint8_t flat;
    struct __nesc_unnamed4306 {
      uint8_t tcr0ub : 1;
      uint8_t ocr0ub : 1;
      uint8_t tcn0ub : 1;
      uint8_t as0 : 1;
      uint8_t rsvd : 4;
    } bits;
  } Atm128Assr_t;
  #line 137
  #line 124
  typedef union __nesc_unnamed4307 {
  
    uint8_t flat;
    struct __nesc_unnamed4308 {
      uint8_t toie0 : 1;
      uint8_t ocie0 : 1;
      uint8_t toie1 : 1;
      uint8_t ocie1b : 1;
      uint8_t ocie1a : 1;
      uint8_t ticie1 : 1;
      uint8_t toie2 : 1;
      uint8_t ocie2 : 1;
    } bits;
  } Atm128_TIMSK_t;
  #line 154
  #line 141
  typedef union __nesc_unnamed4309 {
  
    uint8_t flat;
    struct __nesc_unnamed4310 {
      uint8_t tov0 : 1;
      uint8_t ocf0 : 1;
      uint8_t tov1 : 1;
      uint8_t ocf1b : 1;
      uint8_t ocf1a : 1;
      uint8_t icf1 : 1;
      uint8_t tov2 : 1;
      uint8_t ocf2 : 1;
    } bits;
  } Atm128_TIFR_t;
  #line 169
  #line 158
  typedef union __nesc_unnamed4311 {
  
    uint8_t flat;
    struct __nesc_unnamed4312 {
      uint8_t psr321 : 1;
      uint8_t psr0 : 1;
      uint8_t pud : 1;
      uint8_t acme : 1;
      uint8_t rsvd : 3;
      uint8_t tsm : 1;
    } bits;
  } Atm128_SFIOR_t;
  
  
  
  
  
  
  enum __nesc_unnamed4313 {
    ATM128_TIMER_COMPARE_NORMAL = 0, 
    ATM128_TIMER_COMPARE_TOGGLE, 
    ATM128_TIMER_COMPARE_CLEAR, 
    ATM128_TIMER_COMPARE_SET
  };
  #line 193
  #line 184
  typedef union __nesc_unnamed4314 {
  
    uint8_t flat;
    struct __nesc_unnamed4315 {
      uint8_t wgm10 : 2;
      uint8_t comC : 2;
      uint8_t comB : 2;
      uint8_t comA : 2;
    } bits;
  } Atm128TimerCtrlCompare_t;
  
  
  typedef Atm128TimerCtrlCompare_t Atm128_TCCR1A_t;
  
  
  typedef Atm128TimerCtrlCompare_t Atm128_TCCR3A_t;
  
  
  enum __nesc_unnamed4316 {
    ATM128_WAVE16_NORMAL = 0, 
    ATM128_WAVE16_PWM_8BIT, 
    ATM128_WAVE16_PWM_9BIT, 
    ATM128_WAVE16_PWM_10BIT, 
    ATM128_WAVE16_CTC_COMPARE, 
    ATM128_WAVE16_PWM_FAST_8BIT, 
    ATM128_WAVE16_PWM_FAST_9BIT, 
    ATM128_WAVE16_PWM_FAST_10BIT, 
    ATM128_WAVE16_PWM_CAPTURE_LOW, 
    ATM128_WAVE16_PWM_COMPARE_LOW, 
    ATM128_WAVE16_PWM_CAPTURE_HIGH, 
    ATM128_WAVE16_PWM_COMPARE_HIGH, 
    ATM128_WAVE16_CTC_CAPTURE, 
    ATM128_WAVE16_RESERVED, 
    ATM128_WAVE16_PWM_FAST_CAPTURE, 
    ATM128_WAVE16_PWM_FAST_COMPARE
  };
  #line 232
  #line 222
  typedef union __nesc_unnamed4317 {
  
    uint8_t flat;
    struct __nesc_unnamed4318 {
      uint8_t cs : 3;
      uint8_t wgm32 : 2;
      uint8_t rsvd : 1;
      uint8_t ices1 : 1;
      uint8_t icnc1 : 1;
    } bits;
  } Atm128TimerCtrlCapture_t;
  
  
  typedef Atm128TimerCtrlCapture_t Atm128_TCCR1B_t;
  
  
  typedef Atm128TimerCtrlCapture_t Atm128_TCCR3B_t;
  #line 250
  #line 241
  typedef union __nesc_unnamed4319 {
  
    uint8_t flat;
    struct __nesc_unnamed4320 {
      uint8_t rsvd : 5;
      uint8_t focC : 1;
      uint8_t focB : 1;
      uint8_t focA : 1;
    } bits;
  } Atm128TimerCtrlClock_t;
  
  
  typedef Atm128TimerCtrlClock_t Atm128_TCCR1C_t;
  
  
  typedef Atm128TimerCtrlClock_t Atm128_TCCR3C_t;
  
  
  
  typedef uint8_t Atm128_TCNT1H_t;
  typedef uint8_t Atm128_TCNT1L_t;
  typedef uint8_t Atm128_TCNT3H_t;
  typedef uint8_t Atm128_TCNT3L_t;
  
  
  typedef uint8_t Atm128_OCR1AH_t;
  typedef uint8_t Atm128_OCR1AL_t;
  typedef uint8_t Atm128_OCR1BH_t;
  typedef uint8_t Atm128_OCR1BL_t;
  typedef uint8_t Atm128_OCR1CH_t;
  typedef uint8_t Atm128_OCR1CL_t;
  
  
  typedef uint8_t Atm128_OCR3AH_t;
  typedef uint8_t Atm128_OCR3AL_t;
  typedef uint8_t Atm128_OCR3BH_t;
  typedef uint8_t Atm128_OCR3BL_t;
  typedef uint8_t Atm128_OCR3CH_t;
  typedef uint8_t Atm128_OCR3CL_t;
  
  
  typedef uint8_t Atm128_ICR1H_t;
  typedef uint8_t Atm128_ICR1L_t;
  typedef uint8_t Atm128_ICR3H_t;
  typedef uint8_t Atm128_ICR3L_t;
  #line 300
  #line 288
  typedef union __nesc_unnamed4321 {
  
    uint8_t flat;
    struct __nesc_unnamed4322 {
      uint8_t ocie1c : 1;
      uint8_t ocie3c : 1;
      uint8_t toie3 : 1;
      uint8_t ocie3b : 1;
      uint8_t ocie3a : 1;
      uint8_t ticie3 : 1;
      uint8_t rsvd : 2;
    } bits;
  } Atm128_ETIMSK_t;
  #line 315
  #line 303
  typedef union __nesc_unnamed4323 {
  
    uint8_t flat;
    struct __nesc_unnamed4324 {
      uint8_t ocf1c : 1;
      uint8_t ocf3c : 1;
      uint8_t tov3 : 1;
      uint8_t ocf3b : 1;
      uint8_t ocf3a : 1;
      uint8_t icf3 : 1;
      uint8_t rsvd : 2;
    } bits;
  } Atm128_ETIFR_t;
  typedef uint16_t RoutC$RandomSeed$parameter;
  typedef rout_msg_t RoutC$RouterQueue$t;
  typedef TMilli RoutC$PeriodTimer$precision_tag;
  typedef TMilli /*AlarmCounterMilliP.Atm128AlarmAsyncC*/Atm128AlarmAsyncC$0$precision;
  typedef /*AlarmCounterMilliP.Atm128AlarmAsyncC*/Atm128AlarmAsyncC$0$precision /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$precision;
  typedef /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$precision /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$precision_tag;
  typedef uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$size_type;
  typedef /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$precision /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$precision_tag;
  typedef uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$size_type;
  typedef uint8_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$size_type;
  typedef uint8_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$timer_size;
  typedef uint8_t HplAtm128Timer0AsyncP$Timer0$timer_size;
  typedef uint8_t HplAtm128Timer0AsyncP$Compare$size_type;
  typedef TMilli /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$precision_tag;
  typedef /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$precision_tag /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$precision_tag;
  typedef uint32_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type;
  typedef /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$precision_tag /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$precision_tag;
  typedef TMilli /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$precision_tag;
  typedef /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$precision_tag /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$precision_tag;
  typedef /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$precision_tag /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$precision_tag;
  typedef TMilli /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$precision_tag;
  typedef /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$precision_tag /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$LocalTime$precision_tag;
  typedef /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$precision_tag /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$precision_tag;
  typedef uint32_t /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$size_type;
  typedef uint16_t RandomMlcgC$SeedInit$parameter;
  typedef rout_msg_t /*RoutAppC.Queue*/QueueC$0$queue_t;
  typedef /*RoutAppC.Queue*/QueueC$0$queue_t /*RoutAppC.Queue*/QueueC$0$Queue$t;
  enum AMQueueP$__nesc_unnamed4325 {
    AMQueueP$NUM_CLIENTS = 1U
  };
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static void RoutC$MessageSend$sendDone(
  #line 92
  message_t * msg, 
  
  
  
  
  
  
  error_t error);
  # 49 "/opt/tinyos-2.1.0/tos/interfaces/Boot.nc"
  static void RoutC$Boot$booted(void );
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  static void RoutC$MessageControl$startDone(error_t error);
  #line 117
  static void RoutC$MessageControl$stopDone(error_t error);
  # 72 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static void RoutC$PeriodTimer$fired(void );
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  static 
  #line 63
  message_t * 
  
  
  
  RoutC$MessageReceive$receive(
  #line 60
  message_t * msg, 
  void * payload, 
  
  
  
  
  
  uint8_t len);
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t PlatformP$Init$init(void );
  #line 51
  static error_t MotePlatformP$SubInit$default$init(void );
  #line 51
  static error_t MotePlatformP$PlatformInit$init(void );
  # 33 "/opt/tinyos-2.1.0/tos/interfaces/GeneralIO.nc"
  static void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$makeInput(void );
  #line 30
  static void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$clr(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t MeasureClockC$Init$init(void );
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static error_t SimSchedulerBasicP$TaskBasic$postTask(
  # 41 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  uint8_t arg_0x2b37c1875ab0);
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void SimSchedulerBasicP$TaskBasic$default$runTask(
  # 41 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  uint8_t arg_0x2b37c1875ab0);
  # 46 "/opt/tinyos-2.1.0/tos/interfaces/Scheduler.nc"
  static void SimSchedulerBasicP$Scheduler$init(void );
  
  
  
  
  
  
  
  static bool SimSchedulerBasicP$Scheduler$runNextTask(void );
  # 36 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMote.nc"
  static void SimMoteP$SimMote$setEuid(long long int euid);
  
  
  static int SimMoteP$SimMote$getVariableInfo(char *name, void **ptr, size_t *len);
  
  static void SimMoteP$SimMote$turnOff(void );
  #line 40
  static void SimMoteP$SimMote$turnOn(void );
  #line 35
  static long long int SimMoteP$SimMote$getEuid(void );
  
  
  static bool SimMoteP$SimMote$isOn(void );
  #line 37
  static long long int SimMoteP$SimMote$getStartTime(void );
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static error_t TossimActiveMessageC$AMSend$send(
  # 39 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c07328, 
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  am_addr_t addr, 
  #line 60
  message_t * msg, 
  
  
  
  
  
  
  
  
  uint8_t len);
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  static 
  #line 63
  message_t * 
  
  
  
  TossimActiveMessageC$Snoop$default$receive(
  # 41 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c05020, 
  # 60 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  message_t * msg, 
  void * payload, 
  
  
  
  
  
  uint8_t len);
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  static uint8_t TossimActiveMessageC$Packet$payloadLength(
  #line 63
  message_t * msg);
  #line 115
  static 
  #line 112
  void * 
  
  
  TossimActiveMessageC$Packet$getPayload(
  #line 110
  message_t * msg, 
  
  
  
  
  uint8_t len);
  #line 95
  static uint8_t TossimActiveMessageC$Packet$maxPayloadLength(void );
  #line 83
  static void TossimActiveMessageC$Packet$setPayloadLength(
  #line 79
  message_t * msg, 
  
  
  
  uint8_t len);
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  static 
  #line 63
  message_t * 
  
  
  
  TossimActiveMessageC$Receive$default$receive(
  # 40 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c06450, 
  # 60 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  message_t * msg, 
  void * payload, 
  
  
  
  
  
  uint8_t len);
  # 77 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  static void TossimActiveMessageC$Model$receive(message_t *msg);
  #line 68
  static void TossimActiveMessageC$Model$sendDone(message_t *msg, error_t error);
  
  
  
  
  
  
  
  
  
  
  static bool TossimActiveMessageC$Model$shouldAck(message_t *msg);
  # 57 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  static am_addr_t TossimActiveMessageC$AMPacket$address(void );
  
  
  
  
  
  
  
  
  
  static am_addr_t TossimActiveMessageC$AMPacket$destination(
  #line 63
  message_t * amsg);
  #line 92
  static void TossimActiveMessageC$AMPacket$setDestination(
  #line 88
  message_t * amsg, 
  
  
  
  am_addr_t addr);
  #line 136
  static am_id_t TossimActiveMessageC$AMPacket$type(
  #line 132
  message_t * amsg);
  #line 151
  static void TossimActiveMessageC$AMPacket$setType(
  #line 147
  message_t * amsg, 
  
  
  
  am_id_t t);
  #line 125
  static bool TossimActiveMessageC$AMPacket$isForMe(
  #line 122
  message_t * amsg);
  # 98 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$size_type /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getNow(void );
  #line 92
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$startAt(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$size_type t0, /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$size_type dt);
  #line 105
  static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$size_type /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getAlarm(void );
  #line 62
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$stop(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Init$init(void );
  # 53 "/opt/tinyos-2.1.0/tos/lib/timer/Counter.nc"
  static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$size_type /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$get(void );
  # 49 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$fired(void );
  # 61 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Timer.nc"
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$overflow(void );
  #line 52
  static HplAtm128Timer0AsyncP$Timer0$timer_size HplAtm128Timer0AsyncP$Timer0$get(void );
  #line 101
  static uint8_t HplAtm128Timer0AsyncP$Timer0$getScale(void );
  #line 58
  static void HplAtm128Timer0AsyncP$Timer0$set(HplAtm128Timer0AsyncP$Timer0$timer_size t);
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerAsync.nc"
  static int HplAtm128Timer0AsyncP$TimerAsync$compareBusy(void );
  #line 32
  static void HplAtm128Timer0AsyncP$TimerAsync$setTimer0Asynchronous(void );
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerCtrl8.nc"
  static Atm128_TIFR_t HplAtm128Timer0AsyncP$Timer0Ctrl$getInterruptFlag(void );
  #line 37
  static void HplAtm128Timer0AsyncP$Timer0Ctrl$setControl(Atm128TimerControl_t control);
  # 39 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  static HplAtm128Timer0AsyncP$Compare$size_type HplAtm128Timer0AsyncP$Compare$get(void );
  
  
  
  
  
  static void HplAtm128Timer0AsyncP$Compare$set(HplAtm128Timer0AsyncP$Compare$size_type t);
  
  
  
  
  
  
  
  
  
  
  static void HplAtm128Timer0AsyncP$Compare$start(void );
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$runTask(void );
  # 67 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$fired(void );
  # 125 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static uint32_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$getNow(void );
  #line 118
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$startOneShotAt(uint32_t t0, uint32_t dt);
  #line 67
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$stop(void );
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$runTask(void );
  # 72 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$fired(void );
  #line 72
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$default$fired(
  # 37 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  uint8_t arg_0x2b37c1eb72f8);
  # 53 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$startPeriodic(
  # 37 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  uint8_t arg_0x2b37c1eb72f8, 
  # 53 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  uint32_t dt);
  #line 67
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$stop(
  # 37 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  uint8_t arg_0x2b37c1eb72f8);
  # 71 "/opt/tinyos-2.1.0/tos/lib/timer/Counter.nc"
  static void /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$overflow(void );
  # 41 "/opt/tinyos-2.1.0/tos/interfaces/Random.nc"
  static uint16_t RandomMlcgC$Random$rand16(void );
  #line 35
  static uint32_t RandomMlcgC$Random$rand32(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t RandomMlcgC$Init$init(void );
  # 73 "/opt/tinyos-2.1.0/tos/interfaces/Queue.nc"
  static 
  #line 71
  /*RoutAppC.Queue*/QueueC$0$Queue$t  
  
  /*RoutAppC.Queue*/QueueC$0$Queue$head(void );
  #line 90
  static error_t /*RoutAppC.Queue*/QueueC$0$Queue$enqueue(
  #line 86
  /*RoutAppC.Queue*/QueueC$0$Queue$t  newVal);
  #line 65
  static uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$maxSize(void );
  #line 81
  static 
  #line 79
  /*RoutAppC.Queue*/QueueC$0$Queue$t  
  
  /*RoutAppC.Queue*/QueueC$0$Queue$dequeue(void );
  #line 50
  static bool /*RoutAppC.Queue*/QueueC$0$Queue$empty(void );
  
  
  
  
  
  
  
  static uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$size(void );
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void TossimPacketModelC$stopDoneTask$runTask(void );
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  static error_t TossimPacketModelC$Packet$send(int node, message_t *msg, uint8_t len);
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void TossimPacketModelC$sendDoneTask$runTask(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t TossimPacketModelC$Init$init(void );
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void TossimPacketModelC$startDoneTask$runTask(void );
  # 83 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  static error_t TossimPacketModelC$Control$start(void );
  # 51 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  static void TossimPacketModelC$GainRadioModel$receive(message_t *msg);
  #line 50
  static void TossimPacketModelC$GainRadioModel$acked(message_t *msg);
  
  static bool TossimPacketModelC$GainRadioModel$shouldAck(message_t *msg);
  #line 40
  static void CpmModelC$Model$putOnAirTo(int dest, 
  message_t *msg, 
  bool ack, 
  sim_time_t endTime, 
  double gain, 
  double reverseGain);
  
  
  static bool CpmModelC$Model$clearChannel(void );
  # 46 "/opt/tinyos-2.1.0/tos/lib/tossim/ActiveMessageAddressC.nc"
  static am_addr_t ActiveMessageAddressC$amAddress(void );
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static error_t /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$send(am_addr_t addr, 
  #line 60
  message_t * msg, 
  
  
  
  
  
  
  
  
  uint8_t len);
  # 89 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$sendDone(
  #line 85
  message_t * msg, 
  
  
  
  error_t error);
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$sendDone(
  # 40 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  am_id_t arg_0x2b37c20e5020, 
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  message_t * msg, 
  
  
  
  
  
  
  error_t error);
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  static error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$send(
  # 38 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  uint8_t arg_0x2b37c20e7e18, 
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  message_t * msg, 
  
  
  
  
  
  
  
  uint8_t len);
  #line 89
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$default$sendDone(
  # 38 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  uint8_t arg_0x2b37c20e7e18, 
  # 85 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  message_t * msg, 
  
  
  
  error_t error);
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$runTask(void );
  #line 64
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask$runTask(void );
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static error_t RoutC$MessageSend$send(am_addr_t addr, 
  #line 60
  message_t * msg, 
  
  
  
  
  
  
  
  
  uint8_t len);
  # 41 "/opt/tinyos-2.1.0/tos/interfaces/Random.nc"
  static uint16_t RoutC$Random$rand16(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t RoutC$RandomInit$init(void );
  # 73 "/opt/tinyos-2.1.0/tos/interfaces/Queue.nc"
  static 
  #line 71
  RoutC$RouterQueue$t  
  
  RoutC$RouterQueue$head(void );
  #line 90
  static error_t RoutC$RouterQueue$enqueue(
  #line 86
  RoutC$RouterQueue$t  newVal);
  #line 81
  static 
  #line 79
  RoutC$RouterQueue$t  
  
  RoutC$RouterQueue$dequeue(void );
  #line 50
  static bool RoutC$RouterQueue$empty(void );
  # 83 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  static error_t RoutC$MessageControl$start(void );
  # 53 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static void RoutC$PeriodTimer$startPeriodic(uint32_t dt);
  #line 67
  static void RoutC$PeriodTimer$stop(void );
  # 115 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  static 
  #line 112
  void * 
  
  
  RoutC$MessagePacket$getPayload(
  #line 110
  message_t * msg, 
  
  
  
  
  uint8_t len);
  # 35 "RoutC.nc"
  message_t RoutC$packet[1000];
  rout_msg_t *RoutC$message[1000];
  
  
  int16_t RoutC$router[1000];
  int16_t RoutC$clusterHead[1000];
  bool RoutC$routerlessreported[1000];
  
  
  bool RoutC$switchrouter[1000];
  
  
  bool RoutC$locked[1000];
  
  
  uint16_t RoutC$battery[1000];
  
  
  bool RoutC$isCluster[1000];
  uint16_t RoutC$clusterElec[1000];
  
  
  static uint16_t RoutC$msgcount[1000];
  
  
  
  
  static inline uint16_t RoutC$random(uint16_t n);
  
  
  
  
  static inline bool RoutC$isSink(void );
  
  
  
  static inline int16_t RoutC$distanceBetweenXY(int16_t ax, int16_t ay, int16_t bx, int16_t by);
  
  
  
  static int16_t RoutC$distanceBetween(int16_t aid, uint16_t bid);
  
  
  
  
  
  
  
  static inline int16_t RoutC$distance(int16_t id);
  
  
  
  static inline char *RoutC$messageTypeString(int16_t type);
  #line 103
  static inline void RoutC$startnode(void );
  
  
  
  
  
  
  
  
  
  static inline void RoutC$stopnode(void );
  
  
  
  
  static inline void RoutC$Boot$booted(void );
  
  
  
  
  
  static inline void RoutC$MessageControl$startDone(error_t err);
  
  
  
  
  
  
  
  
  static inline void RoutC$MessageControl$stopDone(error_t err);
  
  
  
  
  
  
  static inline uint16_t RoutC$batteryEmpty(void );
  
  
  
  
  static void RoutC$batteryCheck(void );
  
  
  
  
  
  
  
  
  
  
  static inline bool RoutC$batteryUse(uint16_t use);
  #line 172
  static uint16_t RoutC$batteryRequiredForSend(am_addr_t receiver);
  
  
  
  
  
  
  
  
  
  static inline bool RoutC$batteryUseForSend(am_addr_t receiver);
  
  
  
  
  
  
  
  
  
  static inline void RoutC$sendMessage(am_addr_t receiver);
  #line 217
  static void RoutC$rout(void );
  #line 265
  static void RoutC$routMessage(void );
  #line 286
  static inline void RoutC$sendAnnounce(uint32_t rounds);
  #line 305
  static inline void RoutC$announceReceive(rout_msg_t *mess);
  #line 379
  static inline void RoutC$sendContent(void );
  #line 391
  static inline void RoutC$contentReceive(rout_msg_t *mess);
  #line 404
  static inline void RoutC$contentCollect(rout_msg_t *mess);
  #line 417
  static inline void RoutC$PeriodTimer$fired(void );
  #line 442
  static inline message_t *RoutC$MessageReceive$receive(message_t *bufPtr, void *payload, uint8_t len);
  #line 482
  static void RoutC$MessageSend$sendDone(message_t *bufPtr, error_t error);
  #line 380
  static uint32_t RoutC$sendContent$sequence[1000];
  #line 405
  static uint16_t RoutC$contentCollect$collected[1000];
  #line 418
  static uint32_t RoutC$PeriodTimer$fired$roundcounter[1000];
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t PlatformP$MoteInit$init(void );
  #line 51
  static error_t PlatformP$MeasureClock$init(void );
  # 42 "/opt/tinyos-2.1.0/tos/platforms/mica/PlatformP.nc"
  static inline void PlatformP$power_init(void );
  
  
  
  
  
  
  static inline error_t PlatformP$Init$init(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t MotePlatformP$SubInit$init(void );
  # 33 "/opt/tinyos-2.1.0/tos/interfaces/GeneralIO.nc"
  static void MotePlatformP$SerialIdPin$makeInput(void );
  #line 30
  static void MotePlatformP$SerialIdPin$clr(void );
  # 26 "/opt/tinyos-2.1.0/tos/platforms/micaz/MotePlatformP.nc"
  static inline error_t MotePlatformP$PlatformInit$init(void );
  #line 38
  static inline error_t MotePlatformP$SubInit$default$init(void );
  # 50 "/opt/tinyos-2.1.0/tos/chips/atm128/pins/sim/HplAtm128GeneralIOPinP.nc"
  static __inline void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$clr(void );
  
  
  static __inline void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$makeInput(void );
  # 21 "/opt/tinyos-2.1.0/tos/platforms/mica/sim/MeasureClockC.nc"
  static inline error_t MeasureClockC$Init$init(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t SimMainP$SoftwareInit$init(void );
  # 49 "/opt/tinyos-2.1.0/tos/interfaces/Boot.nc"
  static void SimMainP$Boot$booted(void );
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  static error_t SimMainP$PlatformInit$init(void );
  # 46 "/opt/tinyos-2.1.0/tos/interfaces/Scheduler.nc"
  static void SimMainP$Scheduler$init(void );
  
  
  
  
  
  
  
  static bool SimMainP$Scheduler$runNextTask(void );
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMainP.nc"
  int sim_main_start_mote(void )   ;
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static void SimSchedulerBasicP$TaskBasic$runTask(
  # 41 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  uint8_t arg_0x2b37c1875ab0);
  
  
  
  enum SimSchedulerBasicP$__nesc_unnamed4326 {
  
    SimSchedulerBasicP$NUM_TASKS = 7U, 
    SimSchedulerBasicP$NO_TASK = 255
  };
  
  uint8_t SimSchedulerBasicP$m_head[1000];
  uint8_t SimSchedulerBasicP$m_tail[1000];
  uint8_t SimSchedulerBasicP$m_next[1000][SimSchedulerBasicP$NUM_TASKS];
  
  
  
  
  bool SimSchedulerBasicP$sim_scheduler_event_pending[1000];
  sim_event_t SimSchedulerBasicP$sim_scheduler_event[1000];
  
  static inline int SimSchedulerBasicP$sim_config_task_latency(void );
  
  
  
  
  
  
  
  static void SimSchedulerBasicP$sim_scheduler_submit_event(void );
  
  
  
  
  
  
  
  static inline void SimSchedulerBasicP$sim_scheduler_event_handle(sim_event_t *e);
  #line 95
  static inline void SimSchedulerBasicP$sim_scheduler_event_init(sim_event_t *e);
  #line 112
  static inline uint8_t SimSchedulerBasicP$popTask(void );
  #line 131
  static inline bool SimSchedulerBasicP$isWaiting(uint8_t id);
  
  
  
  
  static inline bool SimSchedulerBasicP$pushTask(uint8_t id);
  #line 158
  static inline void SimSchedulerBasicP$Scheduler$init(void );
  #line 172
  static bool SimSchedulerBasicP$Scheduler$runNextTask(void );
  #line 197
  static error_t SimSchedulerBasicP$TaskBasic$postTask(uint8_t id);
  #line 213
  static inline void SimSchedulerBasicP$TaskBasic$default$runTask(uint8_t id);
  # 42 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
  long long int SimMoteP$euid[1000];
  long long int SimMoteP$startTime[1000];
  bool SimMoteP$isOn[1000];
  sim_event_t *SimMoteP$bootEvent[1000];
  
  static inline long long int SimMoteP$SimMote$getEuid(void );
  
  
  static inline void SimMoteP$SimMote$setEuid(long long int e);
  
  
  static inline long long int SimMoteP$SimMote$getStartTime(void );
  
  
  static inline bool SimMoteP$SimMote$isOn(void );
  
  
  
  static inline int SimMoteP$SimMote$getVariableInfo(char *name, void **addr, size_t *size);
  
  
  
  static void SimMoteP$SimMote$turnOn(void );
  #line 77
  static inline void SimMoteP$SimMote$turnOff(void );
  
  
  
  
  long long int sim_mote_euid(int mote)   ;
  
  
  
  
  
  
  
  
  void sim_mote_set_euid(int mote, long long int id)   ;
  
  
  
  
  
  
  long long int sim_mote_start_time(int mote)   ;
  
  
  
  
  
  
  
  
  int sim_mote_get_variable_info(int mote, char *name, void **ptr, size_t *len)   ;
  
  
  
  
  
  
  
  
  
  void sim_mote_set_start_time(int mote, long long int t)   ;
  
  
  
  
  
  
  
  
  bool sim_mote_is_on(int mote)   ;
  
  
  
  
  
  
  
  
  void sim_mote_turn_on(int mote)   ;
  
  
  
  
  
  
  void sim_mote_turn_off(int mote)   ;
  
  
  
  
  
  
  static inline void SimMoteP$sim_mote_boot_handle(sim_event_t *e);
  
  
  
  
  
  
  
  
  void sim_mote_enqueue_boot_event(int mote)   ;
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static am_addr_t TossimActiveMessageC$amAddress(void );
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static void TossimActiveMessageC$AMSend$sendDone(
  # 39 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c07328, 
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  message_t * msg, 
  
  
  
  
  
  
  error_t error);
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  static 
  #line 63
  message_t * 
  
  
  
  TossimActiveMessageC$Snoop$receive(
  # 41 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c05020, 
  # 60 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  message_t * msg, 
  void * payload, 
  
  
  
  
  
  uint8_t len);
  #line 67
  static 
  #line 63
  message_t * 
  
  
  
  TossimActiveMessageC$Receive$receive(
  # 40 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  am_id_t arg_0x2b37c1c06450, 
  # 60 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  message_t * msg, 
  void * payload, 
  
  
  
  
  
  uint8_t len);
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  static error_t TossimActiveMessageC$Model$send(int node, message_t *msg, uint8_t len);
  # 54 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  message_t TossimActiveMessageC$buffer[1000];
  message_t *TossimActiveMessageC$bufferPointer[1000];
  
  static inline tossim_header_t *TossimActiveMessageC$getHeader(message_t *amsg);
  
  
  
  
  
  
  
  static error_t TossimActiveMessageC$AMSend$send(am_id_t id, am_addr_t addr, 
  message_t *amsg, 
  uint8_t len);
  #line 95
  static inline void TossimActiveMessageC$Model$sendDone(message_t *msg, error_t result);
  
  
  
  
  
  static void TossimActiveMessageC$Model$receive(message_t *msg);
  #line 119
  static inline bool TossimActiveMessageC$Model$shouldAck(message_t *msg);
  
  
  
  
  
  
  
  
  static inline am_addr_t TossimActiveMessageC$AMPacket$address(void );
  
  
  
  static am_addr_t TossimActiveMessageC$AMPacket$destination(message_t *amsg);
  
  
  
  
  static inline void TossimActiveMessageC$AMPacket$setDestination(message_t *amsg, am_addr_t addr);
  #line 152
  static inline bool TossimActiveMessageC$AMPacket$isForMe(message_t *amsg);
  
  
  
  
  static am_id_t TossimActiveMessageC$AMPacket$type(message_t *amsg);
  
  
  
  
  static inline void TossimActiveMessageC$AMPacket$setType(message_t *amsg, am_id_t t);
  
  
  
  
  
  
  static inline uint8_t TossimActiveMessageC$Packet$payloadLength(message_t *msg);
  
  
  
  static inline void TossimActiveMessageC$Packet$setPayloadLength(message_t *msg, uint8_t len);
  
  
  
  static inline uint8_t TossimActiveMessageC$Packet$maxPayloadLength(void );
  
  
  
  static inline void *TossimActiveMessageC$Packet$getPayload(message_t *msg, uint8_t len);
  #line 204
  static inline message_t *TossimActiveMessageC$Receive$default$receive(am_id_t id, message_t *msg, void *payload, uint8_t len);
  
  
  
  static inline message_t *TossimActiveMessageC$Snoop$default$receive(am_id_t id, message_t *msg, void *payload, uint8_t len);
  #line 228
  static inline void TossimActiveMessageC$active_message_deliver_handle(sim_event_t *evt);
  
  
  
  
  
  static inline sim_event_t *TossimActiveMessageC$allocate_deliver_event(int node, message_t *msg, sim_time_t t);
  #line 246
  void active_message_deliver(int node, message_t *msg, sim_time_t t)   ;
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerCtrl8.nc"
  static Atm128_TIFR_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$getInterruptFlag(void );
  #line 37
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$setControl(Atm128TimerControl_t control);
  # 67 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$fired(void );
  # 71 "/opt/tinyos-2.1.0/tos/lib/timer/Counter.nc"
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$overflow(void );
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerAsync.nc"
  static int /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$compareBusy(void );
  #line 32
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$setTimer0Asynchronous(void );
  # 39 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$size_type /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$get(void );
  
  
  
  
  
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$set(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$size_type t);
  
  
  
  
  
  
  
  
  
  
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$start(void );
  # 52 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Timer.nc"
  static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$timer_size /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get(void );
  # 38 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  uint8_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[1000];
  uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[1000];
  #line 39
  uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[1000];
  uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[1000];
  
  
  
  enum /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$__nesc_unnamed4327 {
    Atm128AlarmAsyncP$0$MINDT = 2, 
    Atm128AlarmAsyncP$0$MAXT = 230
  };
  
  
  
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt(void );
  
  
  static inline error_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Init$init(void );
  #line 74
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setOcr0(uint8_t n);
  #line 90
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt(void );
  #line 149
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$fired(void );
  #line 161
  static uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$get(void );
  #line 204
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$stop(void );
  
  
  
  
  
  
  
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$startAt(uint32_t nt0, uint32_t ndt);
  
  
  
  
  
  
  
  
  
  static inline uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getNow(void );
  
  
  
  static inline uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getAlarm(void );
  
  
  
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$overflow(void );
  # 61 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Timer.nc"
  static void HplAtm128Timer0AsyncP$Timer0$overflow(void );
  # 49 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  static void HplAtm128Timer0AsyncP$Compare$fired(void );
  # 49 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  bool HplAtm128Timer0AsyncP$inOverflow[1000];
  
  
  
  
  static inline void HplAtm128Timer0AsyncP$cancel_overflow(void );
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_overflow(void );
  static void HplAtm128Timer0AsyncP$configure_overflow(sim_event_t *e);
  static inline void HplAtm128Timer0AsyncP$schedule_new_overflow(void );
  
  static inline sim_time_t HplAtm128Timer0AsyncP$clock_to_sim(sim_time_t t);
  static inline sim_time_t HplAtm128Timer0AsyncP$sim_to_clock(sim_time_t t);
  static uint16_t HplAtm128Timer0AsyncP$shiftFromScale(void );
  
  
  
  
  sim_time_t HplAtm128Timer0AsyncP$lastZero[1000];
  
  
  
  
  
  uint8_t HplAtm128Timer0AsyncP$oldScale[1000];
  
  
  
  static inline void HplAtm128Timer0AsyncP$cancel_compare(void );
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_compare(void );
  static void HplAtm128Timer0AsyncP$configure_compare(sim_event_t *e);
  static void HplAtm128Timer0AsyncP$schedule_new_compare(void );
  
  static inline sim_time_t HplAtm128Timer0AsyncP$clock_to_sim(sim_time_t t);
  static inline sim_time_t HplAtm128Timer0AsyncP$sim_to_clock(sim_time_t t);
  static uint16_t HplAtm128Timer0AsyncP$shiftFromScale(void );
  
  
  void INTERRUPT_15(void )   ;
  
  
  
  
  
  void INTERRUPT_16(void )   ;
  
  
  
  
  
  
  
  static sim_time_t HplAtm128Timer0AsyncP$last_zero(void );
  
  
  
  
  
  
  
  static inline void HplAtm128Timer0AsyncP$notify_changed(void );
  
  
  
  
  
  
  
  
  
  
  static inline sim_time_t HplAtm128Timer0AsyncP$notify_clockTicksPerSec(void );
  #line 140
  static inline sim_time_t HplAtm128Timer0AsyncP$clock_to_sim(sim_time_t t);
  
  
  
  
  
  static inline sim_time_t HplAtm128Timer0AsyncP$sim_to_clock(sim_time_t t);
  
  
  
  
  
  static uint16_t HplAtm128Timer0AsyncP$shiftFromScale(void );
  #line 177
  sim_event_t *HplAtm128Timer0AsyncP$compare[1000];
  
  static inline void HplAtm128Timer0AsyncP$timer0_compare_handle(sim_event_t *evt);
  #line 215
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_compare(void );
  
  
  
  
  
  
  
  static void HplAtm128Timer0AsyncP$configure_compare(sim_event_t *evt);
  #line 259
  static void HplAtm128Timer0AsyncP$schedule_new_compare(void );
  #line 274
  static uint8_t HplAtm128Timer0AsyncP$Timer0$get(void );
  #line 289
  static inline void HplAtm128Timer0AsyncP$Timer0$set(uint8_t newVal);
  #line 313
  static uint8_t HplAtm128Timer0AsyncP$Timer0$getScale(void );
  #line 356
  static inline void HplAtm128Timer0AsyncP$Timer0Ctrl$setControl(Atm128TimerControl_t x);
  #line 375
  static Atm128_TIFR_t HplAtm128Timer0AsyncP$Timer0Ctrl$getInterruptFlag(void );
  #line 439
  static inline void HplAtm128Timer0AsyncP$Compare$start(void );
  
  
  
  
  
  
  
  
  
  static uint8_t HplAtm128Timer0AsyncP$Compare$get(void );
  
  
  
  
  
  static void HplAtm128Timer0AsyncP$Compare$set(uint8_t t);
  #line 472
  sim_event_t *HplAtm128Timer0AsyncP$overflow[1000];
  static inline void HplAtm128Timer0AsyncP$timer0_overflow_handle(sim_event_t *evt);
  #line 492
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_overflow(void );
  
  
  
  
  
  
  
  static void HplAtm128Timer0AsyncP$configure_overflow(sim_event_t *evt);
  #line 526
  static inline void HplAtm128Timer0AsyncP$schedule_new_overflow(void );
  
  
  
  
  
  
  
  
  
  
  static inline void HplAtm128Timer0AsyncP$cancel_overflow(void );
  #line 553
  static inline void HplAtm128Timer0AsyncP$TimerAsync$setTimer0Asynchronous(void );
  
  
  
  
  
  
  
  static inline int HplAtm128Timer0AsyncP$TimerAsync$compareBusy(void );
  
  
  
  
  
  
  
  static inline void HplAtm128Timer0AsyncP$cancel_compare(void );
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static error_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$postTask(void );
  # 98 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  static /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getNow(void );
  #line 92
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$startAt(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type t0, /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type dt);
  #line 105
  static /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getAlarm(void );
  #line 62
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$stop(void );
  # 72 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$fired(void );
  # 63 "/opt/tinyos-2.1.0/tos/lib/timer/AlarmToTimerC.nc"
  enum /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$__nesc_unnamed4328 {
  #line 63
    AlarmToTimerC$0$fired = 0U
  };
  #line 63
  typedef int /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$__nesc_sillytask_fired[/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired];
  #line 44
  uint32_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[1000];
  bool /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[1000];
  
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$start(uint32_t t0, uint32_t dt, bool oneshot);
  #line 60
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$stop(void );
  
  
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$runTask(void );
  
  
  
  
  
  
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$fired(void );
  #line 82
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$startOneShotAt(uint32_t t0, uint32_t dt);
  
  
  static inline uint32_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$getNow(void );
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static error_t /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$postTask(void );
  # 125 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  static uint32_t /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$getNow(void );
  #line 118
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$startOneShotAt(uint32_t t0, uint32_t dt);
  #line 67
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$stop(void );
  
  
  
  
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$fired(
  # 37 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  uint8_t arg_0x2b37c1eb72f8);
  #line 60
  enum /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$__nesc_unnamed4329 {
  #line 60
    VirtualizeTimerC$0$updateFromTimer = 1U
  };
  #line 60
  typedef int /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$__nesc_sillytask_updateFromTimer[/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer];
  #line 42
  enum /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$__nesc_unnamed4330 {
  
    VirtualizeTimerC$0$NUM_TIMERS = 2U, 
    VirtualizeTimerC$0$END_OF_LIST = 255
  };
  
  
  
  
  
  
  
  
  #line 48
  typedef struct /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$__nesc_unnamed4331 {
  
    uint32_t t0;
    uint32_t dt;
    bool isoneshot : 1;
    bool isrunning : 1;
    bool _reserved : 6;
  } /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer_t;
  
  /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer_t /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[1000][/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$NUM_TIMERS];
  
  
  
  
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$fireTimers(uint32_t now);
  #line 89
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$runTask(void );
  #line 128
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$fired(void );
  
  
  
  
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$startTimer(uint8_t num, uint32_t t0, uint32_t dt, bool isoneshot);
  
  
  
  
  
  
  
  
  
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$startPeriodic(uint8_t num, uint32_t dt);
  
  
  
  
  
  
  
  
  
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$stop(uint8_t num);
  #line 193
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$default$fired(uint8_t num);
  # 47 "/opt/tinyos-2.1.0/tos/lib/timer/CounterToLocalTimeC.nc"
  static inline void /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$overflow(void );
  # 41 "RandomMlcgC.nc"
  uint32_t RandomMlcgC$seed[1000];
  
  
  static error_t RandomMlcgC$Init$init(void );
  #line 58
  static uint32_t RandomMlcgC$Random$rand32(void );
  #line 78
  static inline uint16_t RandomMlcgC$Random$rand16(void );
  # 48 "/opt/tinyos-2.1.0/tos/system/QueueC.nc"
  /*RoutAppC.Queue*/QueueC$0$queue_t  /*RoutAppC.Queue*/QueueC$0$queue[1000][100];
  uint8_t /*RoutAppC.Queue*/QueueC$0$head[1000];
  uint8_t /*RoutAppC.Queue*/QueueC$0$tail[1000];
  uint8_t /*RoutAppC.Queue*/QueueC$0$size[1000];
  
  static inline bool /*RoutAppC.Queue*/QueueC$0$Queue$empty(void );
  
  
  
  static inline uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$size(void );
  
  
  
  static inline uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$maxSize(void );
  
  
  
  static inline /*RoutAppC.Queue*/QueueC$0$queue_t /*RoutAppC.Queue*/QueueC$0$Queue$head(void );
  
  
  
  static void /*RoutAppC.Queue*/QueueC$0$printQueue(void );
  #line 85
  static /*RoutAppC.Queue*/QueueC$0$queue_t /*RoutAppC.Queue*/QueueC$0$Queue$dequeue(void );
  #line 97
  static error_t /*RoutAppC.Queue*/QueueC$0$Queue$enqueue(/*RoutAppC.Queue*/QueueC$0$queue_t newVal);
  # 77 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  static void TossimPacketModelC$Packet$receive(message_t *msg);
  #line 68
  static void TossimPacketModelC$Packet$sendDone(message_t *msg, error_t error);
  
  
  
  
  
  
  
  
  
  
  static bool TossimPacketModelC$Packet$shouldAck(message_t *msg);
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static error_t TossimPacketModelC$startDoneTask$postTask(void );
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  static void TossimPacketModelC$Control$startDone(error_t error);
  #line 117
  static void TossimPacketModelC$Control$stopDone(error_t error);
  # 40 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  static void TossimPacketModelC$GainRadioModel$putOnAirTo(int dest, 
  message_t *msg, 
  bool ack, 
  sim_time_t endTime, 
  double gain, 
  double reverseGain);
  
  
  static bool TossimPacketModelC$GainRadioModel$clearChannel(void );
  # 94 "TossimPacketModelC.nc"
  enum TossimPacketModelC$__nesc_unnamed4332 {
  #line 94
    TossimPacketModelC$startDoneTask = 2U
  };
  #line 94
  typedef int TossimPacketModelC$__nesc_sillytask_startDoneTask[TossimPacketModelC$startDoneTask];
  
  
  
  
  enum TossimPacketModelC$__nesc_unnamed4333 {
  #line 99
    TossimPacketModelC$stopDoneTask = 3U
  };
  #line 99
  typedef int TossimPacketModelC$__nesc_sillytask_stopDoneTask[TossimPacketModelC$stopDoneTask];
  #line 143
  enum TossimPacketModelC$__nesc_unnamed4334 {
  #line 143
    TossimPacketModelC$sendDoneTask = 4U
  };
  #line 143
  typedef int TossimPacketModelC$__nesc_sillytask_sendDoneTask[TossimPacketModelC$sendDoneTask];
  #line 68
  bool TossimPacketModelC$initialized[1000];
  bool TossimPacketModelC$running[1000];
  uint8_t TossimPacketModelC$backoffCount[1000];
  uint8_t TossimPacketModelC$neededFreeSamples[1000];
  message_t *TossimPacketModelC$sending[1000];
  bool TossimPacketModelC$transmitting[1000];
  uint8_t TossimPacketModelC$sendingLength[1000];
  int TossimPacketModelC$destNode[1000];
  sim_event_t TossimPacketModelC$sendEvent[1000];
  
  
  
  static inline tossim_metadata_t *TossimPacketModelC$getMetadata(message_t *msg);
  
  
  
  static inline error_t TossimPacketModelC$Init$init(void );
  
  
  
  
  
  
  
  
  
  static inline void TossimPacketModelC$startDoneTask$runTask(void );
  
  
  
  
  static inline void TossimPacketModelC$stopDoneTask$runTask(void );
  
  
  
  
  static error_t TossimPacketModelC$Control$start(void );
  #line 143
  static inline void TossimPacketModelC$sendDoneTask$runTask(void );
  #line 157
  static inline void TossimPacketModelC$start_csma(void );
  
  static inline error_t TossimPacketModelC$Packet$send(int dest, message_t *msg, uint8_t len);
  #line 181
  static inline void TossimPacketModelC$send_backoff(sim_event_t *evt);
  static inline void TossimPacketModelC$send_transmit(sim_event_t *evt);
  static inline void TossimPacketModelC$send_transmit_done(sim_event_t *evt);
  
  static inline void TossimPacketModelC$start_csma(void );
  #line 209
  static inline void TossimPacketModelC$send_backoff(sim_event_t *evt);
  #line 246
  static inline int TossimPacketModelC$sim_packet_header_length(void );
  
  
  
  static inline void TossimPacketModelC$send_transmit(sim_event_t *evt);
  #line 277
  static inline void TossimPacketModelC$send_transmit_done(sim_event_t *evt);
  
  
  
  
  
  
  
  static inline void TossimPacketModelC$GainRadioModel$receive(message_t *msg);
  
  
  
  
  
  
  
  
  uint8_t TossimPacketModelC$error[1000];
  
  static inline void TossimPacketModelC$GainRadioModel$acked(message_t *msg);
  
  
  
  
  
  
  
  
  
  
  static bool TossimPacketModelC$GainRadioModel$shouldAck(message_t *msg);
  # 51 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  static void CpmModelC$Model$receive(message_t *msg);
  #line 50
  static void CpmModelC$Model$acked(message_t *msg);
  
  static bool CpmModelC$Model$shouldAck(message_t *msg);
  # 50 "CpmModelC.nc"
  message_t *CpmModelC$outgoing[1000];
  bool CpmModelC$requestAck[1000];
  bool CpmModelC$receiving[1000];
  struct CpmModelC$receive_message;
  typedef struct CpmModelC$receive_message CpmModelC$receive_message_t;
  
  struct CpmModelC$receive_message {
    int source;
    sim_time_t start;
    sim_time_t end;
    double power;
    double reversePower;
    int8_t strength;
    bool lost;
    bool ack;
    message_t *msg;
    CpmModelC$receive_message_t *next;
  };
  
  CpmModelC$receive_message_t *CpmModelC$outstandingReceptionHead[1000];
  
  static inline CpmModelC$receive_message_t *CpmModelC$allocate_receive_message(void );
  static inline void CpmModelC$free_receive_message(CpmModelC$receive_message_t *msg);
  static inline sim_event_t *CpmModelC$allocate_receive_event(sim_time_t t, CpmModelC$receive_message_t *m);
  
  static bool CpmModelC$shouldReceive(double SNR);
  
  static double CpmModelC$packetNoise(CpmModelC$receive_message_t *msg);
  
  
  static inline double CpmModelC$timeInMs(void );
  #line 116
  static inline double CpmModelC$noise_hash_generation(void );
  #line 141
  static inline double CpmModelC$arr_estimate_from_snr(double SNR);
  #line 157
  static inline int CpmModelC$shouldAckReceive(double snr);
  #line 169
  static inline void CpmModelC$sim_gain_ack_handle(sim_event_t *evt);
  #line 191
  double CpmModelC$clearThreshold[1000];
  
  
  
  
  
  
  
  
  
  
  static inline bool CpmModelC$Model$clearChannel(void );
  
  
  
  
  static void CpmModelC$sim_gain_schedule_ack(int source, sim_time_t t, CpmModelC$receive_message_t *r);
  #line 221
  static inline double CpmModelC$prr_estimate_from_snr(double SNR);
  #line 237
  static bool CpmModelC$shouldReceive(double SNR);
  #line 263
  static double CpmModelC$packetNoise(CpmModelC$receive_message_t *msg);
  #line 285
  static inline void CpmModelC$sim_gain_receive_handle(sim_event_t *evt);
  #line 363
  static inline void CpmModelC$enqueue_receive_event(int source, sim_time_t endTime, message_t *msg, bool receive, double power, double reversePower);
  #line 418
  static inline void CpmModelC$sim_gain_put(int dest, message_t *msg, sim_time_t endTime, bool receive, double power, double reversePower);
  
  
  
  
  
  
  
  static inline void CpmModelC$Model$putOnAirTo(int dest, message_t *msg, bool ack, sim_time_t endTime, double power, double reversePower);
  #line 444
  static inline sim_event_t *CpmModelC$allocate_receive_event(sim_time_t endTime, CpmModelC$receive_message_t *msg);
  #line 456
  static inline CpmModelC$receive_message_t *CpmModelC$allocate_receive_message(void );
  
  
  
  static inline void CpmModelC$free_receive_message(CpmModelC$receive_message_t *msg);
  # 50 "/opt/tinyos-2.1.0/tos/lib/tossim/ActiveMessageAddressC.nc"
  bool ActiveMessageAddressC$set[1000];
  am_addr_t ActiveMessageAddressC$addr[1000];
  
  static am_addr_t ActiveMessageAddressC$amAddress(void );
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$sendDone(
  #line 92
  message_t * msg, 
  
  
  
  
  
  
  error_t error);
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  static error_t /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$send(
  #line 56
  message_t * msg, 
  
  
  
  
  
  
  
  uint8_t len);
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setDestination(
  #line 88
  message_t * amsg, 
  
  
  
  am_addr_t addr);
  #line 151
  static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setType(
  #line 147
  message_t * amsg, 
  
  
  
  am_id_t t);
  # 45 "/opt/tinyos-2.1.0/tos/system/AMQueueEntryP.nc"
  static inline error_t /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$send(am_addr_t dest, 
  message_t *msg, 
  uint8_t len);
  
  
  
  
  
  
  
  
  
  static inline void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$sendDone(message_t *m, error_t err);
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  static error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$send(
  # 40 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  am_id_t arg_0x2b37c20e5020, 
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  am_addr_t addr, 
  #line 60
  message_t * msg, 
  
  
  
  
  
  
  
  
  uint8_t len);
  # 89 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$sendDone(
  # 38 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  uint8_t arg_0x2b37c20e7e18, 
  # 85 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  message_t * msg, 
  
  
  
  error_t error);
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  static uint8_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$payloadLength(
  #line 63
  message_t * msg);
  #line 83
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$setPayloadLength(
  #line 79
  message_t * msg, 
  
  
  
  uint8_t len);
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  static error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$postTask(void );
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  static am_addr_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$destination(
  #line 63
  message_t * amsg);
  #line 136
  static am_id_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$type(
  #line 132
  message_t * amsg);
  # 118 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  enum /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$__nesc_unnamed4335 {
  #line 118
    AMQueueImplP$0$CancelTask = 5U
  };
  #line 118
  typedef int /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$__nesc_sillytask_CancelTask[/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask];
  #line 161
  enum /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$__nesc_unnamed4336 {
  #line 161
    AMQueueImplP$0$errorTask = 6U
  };
  #line 161
  typedef int /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$__nesc_sillytask_errorTask[/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask];
  #line 49
  #line 47
  typedef struct /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$__nesc_unnamed4337 {
    message_t * msg;
  } /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue_entry_t;
  
  uint8_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[1000];
  /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue_entry_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[1000][1];
  uint8_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[1000][1 / 8 + 1];
  
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$tryToSend(void );
  
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$nextPacket(void );
  #line 82
  static inline error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$send(uint8_t clientId, message_t *msg, 
  uint8_t len);
  #line 118
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask$runTask(void );
  #line 155
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$sendDone(uint8_t last, message_t * msg, error_t err);
  
  
  
  
  
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$runTask(void );
  
  
  
  
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$tryToSend(void );
  #line 181
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$sendDone(am_id_t id, message_t *msg, error_t err);
  #line 207
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$default$sendDone(uint8_t id, message_t *msg, error_t err);
  # 67 "/opt/tinyos-2.1.0/tos/lib/tossim/heap.c"
  static inline void init_heap(heap_t *heap)
  #line 67
  {
    heap->size = 0;
    heap->private_size = STARTING_SIZE;
    heap->data = malloc(sizeof(node_t ) * heap->private_size);
  }
  
  #line 119
  static inline void expand_heap(heap_t *heap)
  #line 119
  {
    int new_size = heap->private_size * 2 + 1;
    void *new_data = malloc(sizeof(node_t ) * new_size);
  
  
  
    memcpy(new_data, heap->data, sizeof(node_t ) * heap->private_size);
    free(heap->data);
  
    heap->data = new_data;
    heap->private_size = new_size;
  }
  
  
  static inline void heap_insert(heap_t *heap, void *data, long long int key)
  #line 133
  {
    int findex = heap->size;
  
  #line 135
    if (findex == heap->private_size) {
        expand_heap(heap);
      }
  
    findex = heap->size;
    ((node_t *)heap->data)[findex].key = key;
    ((node_t *)heap->data)[findex].data = data;
    up_heap(heap, findex);
  
    heap->size++;
  }
  
  #line 77
  static inline int is_empty(heap_t *heap)
  #line 77
  {
    return heap->size == 0;
  }
  
  static inline int heap_is_empty(heap_t *heap)
  #line 81
  {
    return is_empty(heap);
  }
  
  static inline long long int heap_get_min_key(heap_t *heap)
  #line 85
  {
    if (is_empty(heap)) {
        return -1;
      }
    else {
        return ((node_t *)heap->data)[0].key;
      }
  }
  
  # 309 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  inline static int sim_log_eq(void *key1, void *key2)
  #line 309
  {
    return strcmp((char *)key1, (char *)key2) == 0;
  }
  
  #line 298
  inline static unsigned int sim_log_hash(void *key)
  #line 298
  {
    char *str = (char *)key;
    unsigned int hashVal = 0;
    int hashChar;
  
    while ((hashChar = * str++)) 
      hashVal = hashChar + (hashVal << 6) + (hashVal << 16) - hashVal;
  
    return hashVal;
  }
  
  #line 151
  static inline void sim_log_init()
  #line 151
  {
    int i;
  
    channelTable = create_hashtable(128, sim_log_hash, sim_log_eq);
  
    for (i = 0; i < SIM_LOG_OUTPUT_COUNT; i++) {
        outputs[i].num = 1;
        outputs[i].files = (FILE **)malloc(sizeof(FILE *));
        outputs[i].files[0] = fdopen(1, "w");
      }
  }
  
  # 122 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
  inline static unsigned int sim_noise_hash(void *key)
  #line 122
  {
    char *pt = (char *)key;
    unsigned int hashVal = 0;
    int i;
  
  #line 126
    for (i = 0; i < NOISE_HISTORY; i++) {
        hashVal = pt[i] + (hashVal << 6) + (hashVal << 16) - hashVal;
      }
    return hashVal;
  }
  
  inline static int sim_noise_eq(void *key1, void *key2)
  #line 132
  {
    return memcmp((void *)key1, (void *)key2, NOISE_HISTORY) == 0;
  }
  
  # 56 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
  static inline bool SimMoteP$SimMote$isOn(void )
  #line 56
  {
    return SimMoteP$isOn[sim_node()];
  }
  
  # 164 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  static inline void sim_log_add_channel(char *name, FILE *file)
  #line 164
  {
    sim_log_channel_t *channel;
  
  #line 166
    channel = (sim_log_channel_t *)hashtable_search(channelTable, name);
  
  
  
    if (channel == (void *)0) {
        char *newName = (char *)malloc(strlen(name) + 1);
  
  #line 172
        strcpy(newName, name);
        newName[strlen(name)] = 0;
  
        channel = (sim_log_channel_t *)malloc(sizeof(sim_log_channel_t ));
        channel->name = newName;
        channel->numOutputs = 0;
        channel->size = DEFAULT_CHANNEL_SIZE;
        channel->outputs = (FILE **)malloc(sizeof(FILE *) * channel->size);
        memset(channel->outputs, 0, sizeof(FILE *) * channel->size);
        hashtable_insert(channelTable, newName, channel);
      }
  
  
  
    if (channel->numOutputs == channel->size) {
        FILE **newOutputs;
        int newSize = channel->size * 2;
  
        newOutputs = (FILE **)malloc(sizeof(FILE *) * newSize);
        memcpy(newOutputs, channel->outputs, channel->size * sizeof(FILE **));
  
        free(channel->outputs);
  
        channel->outputs = newOutputs;
        channel->size = newSize;
      }
  
    channel->outputs[channel->numOutputs] = file;
    channel->numOutputs++;
    sim_log_commit_change();
  }
  
  static inline bool sim_log_remove_channel(char *output, FILE *file)
  #line 204
  {
    sim_log_channel_t *channel;
    int i;
  
  #line 207
    channel = (sim_log_channel_t *)hashtable_search(channelTable, output);
  
    if (channel == (void *)0) {
        return FALSE;
      }
  
  
    for (i = 0; i < channel->numOutputs; i++) {
        FILE *f = channel->outputs[i];
  
  #line 216
        if (file == f) {
            memcpy(&channel->outputs[i], &channel->outputs[i + 1], channel->numOutputs - (i + 1));
            channel->outputs[channel->numOutputs - 1] = (void *)0;
            channel->numOutputs--;
          }
      }
  
    return TRUE;
  }
  
  # 161 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_gain.c"
  static inline gain_entry_t *sim_gain_allocate_link(int mote)
  #line 161
  {
    gain_entry_t *newLink = (gain_entry_t *)malloc(sizeof(gain_entry_t ));
  
  #line 163
    newLink->next = (void *)0;
    newLink->mote = mote;
    newLink->gain = -10000000.0;
    return newLink;
  }
  
  # 55 "/opt/tinyos-2.1.0/tos/lib/tossim/randomlib.c"
  static inline void RandomInitialise(int ij, int kl)
  {
    double s;
  #line 57
    double t;
    int ii;
  #line 58
    int i;
  #line 58
    int j;
  #line 58
    int k;
  #line 58
    int l;
  #line 58
    int jj;
  #line 58
    int m;
  
  
  
  
  
  
    if (((ij < 0 || ij > 31328) || kl < 0) || kl > 30081) {
        ij = 1802;
        kl = 9373;
      }
  
    i = ij / 177 % 177 + 2;
    j = ij % 177 + 2;
    k = kl / 169 % 178 + 1;
    l = kl % 169;
  
    for (ii = 0; ii < 97; ii++) {
        s = 0.0;
        t = 0.5;
        for (jj = 0; jj < 24; jj++) {
            m = i * j % 179 * k % 179;
            i = j;
            j = k;
            k = m;
            l = (53 * l + 1) % 169;
            if (l * m % 64 >= 32) {
              s += t;
              }
  #line 86
            t *= 0.5;
          }
        randU[ii] = s;
      }
  
    randC = 362436.0 / 16777216.0;
    randCD = 7654321.0 / 16777216.0;
    randCM = 16777213.0 / 16777216.0;
    i97 = 97;
    j97 = 33;
    test = TRUE;
  }
  
  # 276 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
  static inline void sim_noise_alarm()
  #line 276
  {
    dummy = 5;
  }
  
  # 42 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_packet.c"
  inline static tossim_header_t *getHeader(message_t *msg)
  #line 42
  {
    return (tossim_header_t *)(msg->data - sizeof(tossim_header_t ));
  }
  
  # 228 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline void TossimActiveMessageC$active_message_deliver_handle(sim_event_t *evt)
  #line 228
  {
    message_t *m = (message_t *)evt->data;
  
  #line 230
    sim_log_debug(137U, "Packet", "Delivering packet to %i at %s\n", (int )sim_node(), sim_time_string());
    TossimActiveMessageC$Model$receive(m);
  }
  
  static inline sim_event_t *TossimActiveMessageC$allocate_deliver_event(int node, message_t *msg, sim_time_t t)
  #line 234
  {
    sim_event_t *evt = (sim_event_t *)malloc(sizeof(sim_event_t ));
  
  #line 236
    evt->mote = node;
    evt->time = t;
    evt->handle = TossimActiveMessageC$active_message_deliver_handle;
    evt->cleanup = sim_queue_cleanup_event;
    evt->cancelled = 0;
    evt->force = 0;
    evt->data = msg;
    return evt;
  }
  
  #line 177
  static inline uint8_t TossimActiveMessageC$Packet$maxPayloadLength(void )
  #line 177
  {
    return 28;
  }
  
  #line 49
  inline static am_addr_t TossimActiveMessageC$amAddress(void ){
  #line 49
    unsigned short __nesc_result;
  #line 49
  
  #line 49
    __nesc_result = ActiveMessageAddressC$amAddress();
  #line 49
  
  #line 49
    return __nesc_result;
  #line 49
  }
  #line 49
  #line 128
  static inline am_addr_t TossimActiveMessageC$AMPacket$address(void )
  #line 128
  {
    return TossimActiveMessageC$amAddress();
  }
  
  #line 152
  static inline bool TossimActiveMessageC$AMPacket$isForMe(message_t *amsg)
  #line 152
  {
    return TossimActiveMessageC$AMPacket$destination(amsg) == TossimActiveMessageC$AMPacket$address() || 
    TossimActiveMessageC$AMPacket$destination(amsg) == AM_BROADCAST_ADDR;
  }
  
  # 281 "/usr/lib/ncc/nesc_nx.h"
  static __inline  uint8_t __nesc_ntoh_uint8(const void * source)
  #line 281
  {
    const uint8_t *base = source;
  
  #line 283
    return base[0];
  }
  
  #line 340
  static __inline  uint32_t __nesc_ntoh_uint32(const void * source)
  #line 340
  {
    const uint8_t *base = source;
  
  #line 342
    return ((((uint32_t )base[0] << 24) | (
    (uint32_t )base[1] << 16)) | (
    (uint32_t )base[2] << 8)) | base[3];
  }
  
  #line 310
  static __inline  uint16_t __nesc_ntoh_uint16(const void * source)
  #line 310
  {
    const uint8_t *base = source;
  
  #line 312
    return ((uint16_t )base[0] << 8) | base[1];
  }
  
  # 87 "RoutC.nc"
  static inline char *RoutC$messageTypeString(int16_t type)
  #line 87
  {
    switch (type) {
        case 11: 
          return "ANNOUNCEMENT";
        case 12: 
          return "CONTENT";
        default: 
          return "Unknown";
      }
  }
  
  # 90 "/opt/tinyos-2.1.0/tos/interfaces/Queue.nc"
  inline static error_t RoutC$RouterQueue$enqueue(RoutC$RouterQueue$t  newVal){
  #line 90
    unsigned char __nesc_result;
  #line 90
  
  #line 90
    __nesc_result = /*RoutAppC.Queue*/QueueC$0$Queue$enqueue(newVal);
  #line 90
  
  #line 90
    return __nesc_result;
  #line 90
  }
  #line 90
  # 391 "RoutC.nc"
  static inline void RoutC$contentReceive(rout_msg_t *mess)
  #line 391
  {
    if (RoutC$RouterQueue$enqueue(*mess) == SUCCESS) {
        sim_log_debug(62U, "RoutDetail", "Rout: Message from %d enqueued\n", __nesc_ntoh_uint16(mess->from.nxdata));
      }
    else 
  #line 394
      {
        sim_log_debug(63U, "Rout", "%s{%d, %s, %d}\n", "Rout: queue full, message dropped:", __nesc_ntoh_uint16(mess->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(mess->type.nxdata)), __nesc_ntoh_uint32(mess->seq.nxdata));
  #line 395
        ;
      }
    RoutC$rout();
  }
  
  
  
  
  
  static inline void RoutC$contentCollect(rout_msg_t *mess)
  #line 404
  {
  
    if (__nesc_ntoh_uint16(mess->content.nxdata) > 0) {
        RoutC$contentCollect$collected[sim_node()] = RoutC$contentCollect$collected[sim_node()] + __nesc_ntoh_uint16(mess->content.nxdata);
      }
    sim_log_debug(64U, "Sink", "Sink: Have now collected %d pieces of information\n", RoutC$contentCollect$collected[sim_node()]);
  }
  
  #line 67
  static inline bool RoutC$isSink(void )
  #line 67
  {
    return TOS_NODE_ID == 0;
  }
  
  # 303 "/usr/lib/ncc/nesc_nx.h"
  static __inline  int8_t __nesc_ntoh_int8(const void * source)
  #line 303
  {
  #line 303
    return __nesc_ntoh_uint8(source);
  }
  
  # 83 "RoutC.nc"
  static inline int16_t RoutC$distance(int16_t id)
  #line 83
  {
    return RoutC$distanceBetween(0, id);
  }
  
  #line 305
  static inline void RoutC$announceReceive(rout_msg_t *mess)
  #line 305
  {
    if (RoutC$switchrouter[sim_node()]) {
  
        RoutC$switchrouter[sim_node()] = FALSE;
        RoutC$router[sim_node()] = -1;
      }
  
  
    if (0) {
        int16_t myd = RoutC$distance(TOS_NODE_ID);
        int16_t d = RoutC$distance(__nesc_ntoh_uint16(mess->from.nxdata));
  
  #line 316
        if (RoutC$router[sim_node()] == -1 && myd > d) {
            RoutC$router[sim_node()] = __nesc_ntoh_uint16(mess->from.nxdata);
          }
      }
    else 
  
  
  
  
  
  
      {
        int16_t myd = RoutC$distance(TOS_NODE_ID);
        int16_t d = RoutC$distance(__nesc_ntoh_uint16(mess->from.nxdata));
  
  
        if (RoutC$router[sim_node()] == -1 && myd > d) {
            RoutC$router[sim_node()] = __nesc_ntoh_uint16(mess->from.nxdata);
  
            if (__nesc_ntoh_int8(RoutC$message[sim_node()]->clHead.nxdata) == -1) {
                if (RoutC$clusterHead[sim_node()] == 0 && myd > d) {
                    RoutC$clusterHead[sim_node()] = __nesc_ntoh_uint16(mess->from.nxdata);
                  }
              }
          }
        else {
          if (RoutC$router[sim_node()] != -1) {
  
  
              int16_t battery_toOld = RoutC$batteryRequiredForSend(RoutC$router[sim_node()]);
  
              int16_t router_distance_to_sink = RoutC$distance(RoutC$router[sim_node()]);
  
  
              int16_t battery_toOldC = RoutC$batteryRequiredForSend(RoutC$clusterHead[sim_node()]);
  
              int16_t cluster_distance_to_sink = RoutC$distance(RoutC$clusterHead[sim_node()]);
  
  
              int16_t battery_toNew = RoutC$batteryRequiredForSend(__nesc_ntoh_uint16(mess->from.nxdata));
  
              int16_t sender_distance = RoutC$distance(__nesc_ntoh_uint16(mess->from.nxdata));
  
  
  
              if (router_distance_to_sink + battery_toOld > sender_distance + battery_toNew) {
                  RoutC$router[sim_node()] = __nesc_ntoh_uint16(mess->from.nxdata);
                }
  
              if (__nesc_ntoh_int8(RoutC$message[sim_node()]->clHead.nxdata) == -1 && !RoutC$isCluster[sim_node()]) {
                  if (cluster_distance_to_sink + battery_toOldC > sender_distance + battery_toNew) {
                      RoutC$clusterHead[sim_node()] = __nesc_ntoh_int8(RoutC$message[sim_node()]->clHead.nxdata);
                    }
                  if (__nesc_ntoh_uint32(RoutC$message[sim_node()]->seq.nxdata) > 1 && RoutC$clusterHead[sim_node()] == -2) {
                      RoutC$isCluster[sim_node()] = TRUE;
                    }
                }
            }
          }
      }
  }
  
  #line 140
  static inline uint16_t RoutC$batteryEmpty(void )
  #line 140
  {
    return 1 && RoutC$battery[sim_node()] == 0;
  }
  
  #line 442
  static inline message_t *RoutC$MessageReceive$receive(message_t *bufPtr, void *payload, uint8_t len)
  #line 442
  {
    rout_msg_t *mess = (rout_msg_t *)payload;
  
  #line 444
    if (RoutC$batteryEmpty()) {
        return bufPtr;
      }
  
    sim_log_debug(68U, "Event", "%s{%d, %s, %d}\n", "--- EVENT ---: Received ", __nesc_ntoh_uint16(mess->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(mess->type.nxdata)), __nesc_ntoh_uint32(mess->seq.nxdata));
  #line 448
    ;
    switch (__nesc_ntoh_uint8(mess->type.nxdata)) {
        case 11: 
          sim_log_debug(69U, "Announcement", "%s{%d, %s, %d}\n", "Announcement: Received ", __nesc_ntoh_uint16(mess->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(mess->type.nxdata)), __nesc_ntoh_uint32(mess->seq.nxdata));
  #line 451
        ;
        RoutC$announceReceive(mess);
        break;
        case 12: 
          sim_log_debug(70U, "Content", "%s{%d, %s, %d}\n", "Content: Received ", __nesc_ntoh_uint16(mess->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(mess->type.nxdata)), __nesc_ntoh_uint32(mess->seq.nxdata));
  #line 455
        ;
        if (RoutC$isSink()) {
            RoutC$contentCollect(mess);
          }
        else {
  
          if (RoutC$isCluster[sim_node()]) {
              RoutC$msgcount[sim_node()]++;
              sim_log_debug(71U, "Sink", "Sink: MESSAGE COUNT IS YEAH %d\n", RoutC$msgcount[sim_node()]);
            }
          else {
              RoutC$contentReceive(mess);
            }
          }
  #line 468
        break;
        default: 
          sim_log_debug(72U, "Error", "ERROR: Unknown message type %d\n", __nesc_ntoh_uint8(mess->type.nxdata));
      }
  
  
  
  
  
  
    return bufPtr;
  }
  
  # 204 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline message_t *TossimActiveMessageC$Receive$default$receive(am_id_t id, message_t *msg, void *payload, uint8_t len)
  #line 204
  {
    return msg;
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  inline static message_t * TossimActiveMessageC$Receive$receive(am_id_t arg_0x2b37c1c06450, message_t * msg, void * payload, uint8_t len){
  #line 67
    nx_struct message_t *__nesc_result;
  #line 67
  
  #line 67
    switch (arg_0x2b37c1c06450) {
  #line 67
      case 7:
  #line 67
        __nesc_result = RoutC$MessageReceive$receive(msg, payload, len);
  #line 67
        break;
  #line 67
      default:
  #line 67
        __nesc_result = TossimActiveMessageC$Receive$default$receive(arg_0x2b37c1c06450, msg, payload, len);
  #line 67
        break;
  #line 67
      }
  #line 67
  
  #line 67
    return __nesc_result;
  #line 67
  }
  #line 67
  # 71 "RoutC.nc"
  static inline int16_t RoutC$distanceBetweenXY(int16_t ax, int16_t ay, int16_t bx, int16_t by)
  #line 71
  {
    return (bx - ax) * (bx - ax) + (by - ay) * (by - ay);
  }
  
  # 57 "/opt/tinyos-2.1.0/tos/system/QueueC.nc"
  static inline uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$size(void )
  #line 57
  {
    return /*RoutAppC.Queue*/QueueC$0$size[sim_node()];
  }
  
  static inline uint8_t /*RoutAppC.Queue*/QueueC$0$Queue$maxSize(void )
  #line 61
  {
    return 100;
  }
  
  #line 53
  static inline bool /*RoutAppC.Queue*/QueueC$0$Queue$empty(void )
  #line 53
  {
    return /*RoutAppC.Queue*/QueueC$0$size[sim_node()] == 0;
  }
  
  # 50 "/opt/tinyos-2.1.0/tos/interfaces/Queue.nc"
  inline static bool RoutC$RouterQueue$empty(void ){
  #line 50
    unsigned char __nesc_result;
  #line 50
  
  #line 50
    __nesc_result = /*RoutAppC.Queue*/QueueC$0$Queue$empty();
  #line 50
  
  #line 50
    return __nesc_result;
  #line 50
  }
  #line 50
  # 65 "/opt/tinyos-2.1.0/tos/system/QueueC.nc"
  static inline /*RoutAppC.Queue*/QueueC$0$queue_t /*RoutAppC.Queue*/QueueC$0$Queue$head(void )
  #line 65
  {
    return /*RoutAppC.Queue*/QueueC$0$queue[sim_node()][/*RoutAppC.Queue*/QueueC$0$head[sim_node()]];
  }
  
  # 73 "/opt/tinyos-2.1.0/tos/interfaces/Queue.nc"
  inline static RoutC$RouterQueue$t  RoutC$RouterQueue$head(void ){
  #line 73
    nx_struct rout_msg __nesc_result;
  #line 73
  
  #line 73
    __nesc_result = /*RoutAppC.Queue*/QueueC$0$Queue$head();
  #line 73
  
  #line 73
    return __nesc_result;
  #line 73
  }
  #line 73
  
  
  
  
  
  
  
  
  inline static RoutC$RouterQueue$t  RoutC$RouterQueue$dequeue(void ){
  #line 81
    nx_struct rout_msg __nesc_result;
  #line 81
  
  #line 81
    __nesc_result = /*RoutAppC.Queue*/QueueC$0$Queue$dequeue();
  #line 81
  
  #line 81
    return __nesc_result;
  #line 81
  }
  #line 81
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  inline static error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$send(am_id_t arg_0x2b37c20e5020, am_addr_t addr, message_t * msg, uint8_t len){
  #line 69
    unsigned char __nesc_result;
  #line 69
  
  #line 69
    __nesc_result = TossimActiveMessageC$AMSend$send(arg_0x2b37c20e5020, addr, msg, len);
  #line 69
  
  #line 69
    return __nesc_result;
  #line 69
  }
  #line 69
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  inline static am_addr_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$destination(message_t * amsg){
  #line 67
    unsigned short __nesc_result;
  #line 67
  
  #line 67
    __nesc_result = TossimActiveMessageC$AMPacket$destination(amsg);
  #line 67
  
  #line 67
    return __nesc_result;
  #line 67
  }
  #line 67
  #line 136
  inline static am_id_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$type(message_t * amsg){
  #line 136
    unsigned char __nesc_result;
  #line 136
  
  #line 136
    __nesc_result = TossimActiveMessageC$AMPacket$type(amsg);
  #line 136
  
  #line 136
    return __nesc_result;
  #line 136
  }
  #line 136
  # 286 "/usr/lib/ncc/nesc_nx.h"
  static __inline  uint8_t __nesc_hton_uint8(void * target, uint8_t value)
  #line 286
  {
    uint8_t *base = target;
  
  #line 288
    base[0] = value;
    return value;
  }
  
  # 57 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline tossim_header_t *TossimActiveMessageC$getHeader(message_t *amsg)
  #line 57
  {
    return (tossim_header_t *)(amsg->data - sizeof(tossim_header_t ));
  }
  
  #line 173
  static inline void TossimActiveMessageC$Packet$setPayloadLength(message_t *msg, uint8_t len)
  #line 173
  {
    __nesc_hton_uint8(TossimActiveMessageC$getHeader(msg)->length.nxdata, len);
  }
  
  # 83 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  inline static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$setPayloadLength(message_t * msg, uint8_t len){
  #line 83
    TossimActiveMessageC$Packet$setPayloadLength(msg, len);
  #line 83
  }
  #line 83
  # 82 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  static inline error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$send(uint8_t clientId, message_t *msg, 
  uint8_t len)
  #line 83
  {
    if (clientId >= 1) {
        return FAIL;
      }
    if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][clientId].msg != (void *)0) {
        return EBUSY;
      }
    sim_log_debug(207U, "AMQueue", "AMQueue: request to send from %hhu (%p): passed checks\n", clientId, msg);
  
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][clientId].msg = msg;
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$setPayloadLength(msg, len);
  
    if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] >= 1) {
        error_t err;
        am_id_t amId = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$type(msg);
        am_addr_t dest = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$destination(msg);
  
        sim_log_debug(208U, "AMQueue", "%s: request to send from %hhu (%p): queue empty\n", __FUNCTION__, clientId, msg);
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] = clientId;
  
        err = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$send(amId, dest, msg, len);
        if (err != SUCCESS) {
            sim_log_debug(209U, "AMQueue", "%s: underlying send failed.\n", __FUNCTION__);
            /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] = 1;
            /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][clientId].msg = (void *)0;
          }
  
        return err;
      }
    else {
        sim_log_debug(210U, "AMQueue", "AMQueue: request to send from %hhu (%p): queue not empty\n", clientId, msg);
      }
    return SUCCESS;
  }
  
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  inline static error_t /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$send(message_t * msg, uint8_t len){
  #line 64
    unsigned char __nesc_result;
  #line 64
  
  #line 64
    __nesc_result = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$send(0U, msg, len);
  #line 64
  
  #line 64
    return __nesc_result;
  #line 64
  }
  #line 64
  # 162 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline void TossimActiveMessageC$AMPacket$setType(message_t *amsg, am_id_t t)
  #line 162
  {
    tossim_header_t *header = TossimActiveMessageC$getHeader(amsg);
  
  #line 164
    __nesc_hton_uint8(header->type.nxdata, t);
  }
  
  # 151 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  inline static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setType(message_t * amsg, am_id_t t){
  #line 151
    TossimActiveMessageC$AMPacket$setType(amsg, t);
  #line 151
  }
  #line 151
  # 315 "/usr/lib/ncc/nesc_nx.h"
  static __inline  uint16_t __nesc_hton_uint16(void * target, uint16_t value)
  #line 315
  {
    uint8_t *base = target;
  
  #line 317
    base[1] = value;
    base[0] = value >> 8;
    return value;
  }
  
  # 137 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline void TossimActiveMessageC$AMPacket$setDestination(message_t *amsg, am_addr_t addr)
  #line 137
  {
    tossim_header_t *header = TossimActiveMessageC$getHeader(amsg);
  
  #line 139
    __nesc_hton_uint16(header->dest.nxdata, addr);
  }
  
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/AMPacket.nc"
  inline static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setDestination(message_t * amsg, am_addr_t addr){
  #line 92
    TossimActiveMessageC$AMPacket$setDestination(amsg, addr);
  #line 92
  }
  #line 92
  # 45 "/opt/tinyos-2.1.0/tos/system/AMQueueEntryP.nc"
  static inline error_t /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$send(am_addr_t dest, 
  message_t *msg, 
  uint8_t len)
  #line 47
  {
    /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setDestination(msg, dest);
    /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMPacket$setType(msg, 7);
    return /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$send(msg, len);
  }
  
  # 69 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  inline static error_t RoutC$MessageSend$send(am_addr_t addr, message_t * msg, uint8_t len){
  #line 69
    unsigned char __nesc_result;
  #line 69
  
  #line 69
    __nesc_result = /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$send(addr, msg, len);
  #line 69
  
  #line 69
    return __nesc_result;
  #line 69
  }
  #line 69
  # 156 "RoutC.nc"
  static inline bool RoutC$batteryUse(uint16_t use)
  #line 156
  {
    bool send = use <= RoutC$battery[sim_node()];
  
  #line 158
    if (RoutC$battery[sim_node()] == 0) {
        return FALSE;
      }
    if (send) {
        RoutC$battery[sim_node()] -= use;
        sim_log_debug(48U, "BatteryUse", "BatteryUse: Decreased by %d down to %d\n", use, RoutC$battery[sim_node()]);
      }
    else 
  #line 164
      {
        RoutC$battery[sim_node()] = 0;
        RoutC$batteryCheck();
        sim_log_debug(49U, "BatteryUse", "BatteryUse: Ran out when trying to send\n");
      }
    return send;
  }
  
  
  
  
  
  
  
  
  
  
  
  static inline bool RoutC$batteryUseForSend(am_addr_t receiver)
  #line 182
  {
    if (1) {
        return RoutC$batteryUse(RoutC$batteryRequiredForSend(receiver));
      }
    else 
  #line 185
      {
        return TRUE;
      }
  }
  
  
  
  static inline void RoutC$sendMessage(am_addr_t receiver)
  #line 192
  {
    if (!RoutC$batteryUseForSend(receiver)) {
        return;
      }
    if (RoutC$MessageSend$send(receiver, &RoutC$packet[sim_node()], sizeof(rout_msg_t )) == SUCCESS) {
        RoutC$locked[sim_node()] = TRUE;
  
        switch (__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata)) {
            case 11: 
              sim_log_debug(50U, "Announcement", "%s{%d, %s, %d}\n", "Announcement: Sending message ", __nesc_ntoh_uint16(RoutC$message[sim_node()]->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata)), __nesc_ntoh_uint32(RoutC$message[sim_node()]->seq.nxdata));
  #line 201
            ;
            break;
            case 12: 
              sim_log_debug(51U, "Content", "%s{%d, %s, %d}%s%d\n", "Content: Sending message ", __nesc_ntoh_uint16(RoutC$message[sim_node()]->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata)), __nesc_ntoh_uint32(RoutC$message[sim_node()]->seq.nxdata), " via ", receiver);
  #line 204
            ;
  
            RoutC$msgcount[sim_node()] = 1;
            break;
            default: 
              sim_log_debug(52U, "Error", "ERROR: Unknown message type");
          }
      }
    else 
  #line 211
      {
        sim_log_debug(53U, "Error", "ERROR: MessageSend failed");
      }
    RoutC$batteryCheck();
  }
  
  # 153 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$stop(uint8_t num)
  {
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[sim_node()][num].isrunning = FALSE;
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void RoutC$PeriodTimer$stop(void ){
  #line 67
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$stop(0U);
  #line 67
  }
  #line 67
  # 113 "RoutC.nc"
  static inline void RoutC$stopnode(void )
  #line 113
  {
    RoutC$battery[sim_node()] = 0;
    RoutC$PeriodTimer$stop();
  }
  
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  inline static void TossimActiveMessageC$AMSend$sendDone(am_id_t arg_0x2b37c1c07328, message_t * msg, error_t error){
  #line 99
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$sendDone(arg_0x2b37c1c07328, msg, error);
  #line 99
  }
  #line 99
  # 95 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline void TossimActiveMessageC$Model$sendDone(message_t *msg, error_t result)
  #line 95
  {
    TossimActiveMessageC$AMSend$sendDone(TossimActiveMessageC$AMPacket$type(msg), msg, result);
  }
  
  # 68 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  inline static void TossimPacketModelC$Packet$sendDone(message_t *msg, error_t error){
  #line 68
    TossimActiveMessageC$Model$sendDone(msg, error);
  #line 68
  }
  #line 68
  # 303 "/usr/lib/ncc/nesc_nx.h"
  static __inline  int8_t __nesc_hton_int8(void * target, int8_t value)
  #line 303
  {
  #line 303
    __nesc_hton_uint8(target, value);
  #line 303
    return value;
  }
  
  # 460 "CpmModelC.nc"
  static inline void CpmModelC$free_receive_message(CpmModelC$receive_message_t *msg)
  #line 460
  {
    free(msg);
  }
  
  # 52 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  inline static bool CpmModelC$Model$shouldAck(message_t *msg){
  #line 52
    unsigned char __nesc_result;
  #line 52
  
  #line 52
    __nesc_result = TossimPacketModelC$GainRadioModel$shouldAck(msg);
  #line 52
  
  #line 52
    return __nesc_result;
  #line 52
  }
  #line 52
  # 77 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  inline static void TossimPacketModelC$Packet$receive(message_t *msg){
  #line 77
    TossimActiveMessageC$Model$receive(msg);
  #line 77
  }
  #line 77
  # 285 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$GainRadioModel$receive(message_t *msg)
  #line 285
  {
  
  
  
    if (TossimPacketModelC$running[sim_node()]) {
        TossimPacketModelC$Packet$receive(msg);
      }
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  inline static void CpmModelC$Model$receive(message_t *msg){
  #line 51
    TossimPacketModelC$GainRadioModel$receive(msg);
  #line 51
  }
  #line 51
  # 285 "CpmModelC.nc"
  static inline void CpmModelC$sim_gain_receive_handle(sim_event_t *evt)
  #line 285
  {
    CpmModelC$receive_message_t *mine = (CpmModelC$receive_message_t *)evt->data;
    CpmModelC$receive_message_t *predecessor = (void *)0;
    CpmModelC$receive_message_t *list = CpmModelC$outstandingReceptionHead[sim_node()];
  
    sim_log_debug(191U, "CpmModelC", "Handling reception event @ %s.\n", sim_time_string());
    while (list != (void *)0) {
        if (list->next == mine) {
            predecessor = list;
          }
        list = list->next;
      }
    if (predecessor) {
        predecessor->next = mine->next;
      }
    else {
  #line 300
      if (mine == CpmModelC$outstandingReceptionHead[sim_node()]) {
          CpmModelC$outstandingReceptionHead[sim_node()] = mine->next;
        }
      else {
          sim_log_error(192U, "CpmModelC", "Incoming packet list structure is corrupted: entry is not the head and no entry points to it.\n");
        }
      }
  #line 306
    sim_log_debug(193U, "CpmModelC,SNRLoss", "Packet from %i to %i\n", (int )mine->source, (int )sim_node());
  
  
  
  
  
  
  
  
  
    if (TRUE || ! mine->lost) {
  
  
  
        tossim_metadata_t *meta = (tossim_metadata_t *)& mine->msg->metadata;
  
  #line 321
        __nesc_hton_int8(meta->strength.nxdata, mine->strength);
  
        sim_log_debug_clear(194U, "CpmModelC,SNRLoss", "  -signaling reception\n");
        CpmModelC$Model$receive(mine->msg);
        if (mine->ack) {
            sim_log_debug_clear(195U, "CpmModelC", " acknowledgment requested, ");
          }
        else {
            sim_log_debug_clear(196U, "CpmModelC", " no acknowledgment requested.\n");
          }
  
        if (mine->ack && CpmModelC$Model$shouldAck(mine->msg)) {
            sim_log_debug_clear(197U, "CpmModelC", " scheduling ack.\n");
            CpmModelC$sim_gain_schedule_ack(mine->source, sim_time() + 1, mine);
          }
        else {
            CpmModelC$free_receive_message(mine);
          }
  
        CpmModelC$receiving[sim_node()] = 0;
      }
    else {
        if (RandomUniform() < 0.001) {
            sim_log_debug(198U, "CpmModelC,SNRLoss", "Packet was technically lost, but TOSSIM introduces an ack false positive rate.\n");
            if (mine->ack && CpmModelC$Model$shouldAck(mine->msg)) {
                sim_log_debug_clear(199U, "CpmModelC", " scheduling ack.\n");
                CpmModelC$sim_gain_schedule_ack(mine->source, sim_time() + 1, mine);
              }
            else {
                CpmModelC$free_receive_message(mine);
              }
          }
        else {
            CpmModelC$free_receive_message(mine);
          }
        CpmModelC$receiving[sim_node()] = 0;
        sim_log_debug_clear(200U, "CpmModelC,SNRLoss", "  -packet was lost.\n");
      }
  }
  
  #line 444
  static inline sim_event_t *CpmModelC$allocate_receive_event(sim_time_t endTime, CpmModelC$receive_message_t *msg)
  #line 444
  {
    sim_event_t *evt = (sim_event_t *)malloc(sizeof(sim_event_t ));
  
  #line 446
    evt->mote = sim_node();
    evt->time = endTime;
    evt->handle = CpmModelC$sim_gain_receive_handle;
    evt->cleanup = sim_queue_cleanup_event;
    evt->cancelled = 0;
    evt->force = 1;
    evt->data = msg;
    return evt;
  }
  
  static inline CpmModelC$receive_message_t *CpmModelC$allocate_receive_message(void )
  #line 456
  {
    return (CpmModelC$receive_message_t *)malloc(sizeof(CpmModelC$receive_message_t ));
  }
  
  #line 363
  static inline void CpmModelC$enqueue_receive_event(int source, sim_time_t endTime, message_t *msg, bool receive, double power, double reversePower)
  #line 363
  {
    sim_event_t *evt;
    CpmModelC$receive_message_t *list;
    CpmModelC$receive_message_t *rcv = CpmModelC$allocate_receive_message();
    double noiseStr = CpmModelC$packetNoise(rcv);
  
  #line 368
    rcv->source = source;
    rcv->start = sim_time();
    rcv->end = endTime;
    rcv->power = power;
    rcv->reversePower = reversePower;
  
  
  
  
    rcv->strength = (int8_t )floor(10.0 * log(pow(10.0, power / 10.0) + pow(10.0, noiseStr / 10.0)) / log(10.0));
    rcv->msg = msg;
    rcv->lost = 0;
    rcv->ack = receive;
  
  
  
  
  
    if (!sim_mote_is_on(sim_node())) {
        sim_log_debug(201U, "CpmModelC", "Lost packet from %i due to %i being off\n", source, sim_node());
        rcv->lost = 1;
      }
    else {
  #line 390
      if (!CpmModelC$shouldReceive(power - noiseStr)) {
          sim_log_debug(202U, "CpmModelC,SNRLoss", "Lost packet from %i to %i due to SNR being too low (%i)\n", source, sim_node(), (int )(power - noiseStr));
          rcv->lost = 1;
        }
      else {
  #line 394
        if (CpmModelC$receiving[sim_node()]) {
            sim_log_debug(203U, "CpmModelC,SNRLoss", "Lost packet from %i due to %i being mid-reception\n", source, sim_node());
            rcv->lost = 1;
          }
        else {
            CpmModelC$receiving[sim_node()] = 1;
          }
        }
      }
  #line 402
    list = CpmModelC$outstandingReceptionHead[sim_node()];
    while (list != (void *)0) {
        if (!CpmModelC$shouldReceive(list->power - rcv->power)) {
            sim_log_debug(204U, "Gain,SNRLoss", "Going to lose packet from %i with signal %lf as am receiving a packet from %i with signal %lf\n", list->source, list->power, source, rcv->power);
            list->lost = 1;
          }
        list = list->next;
      }
  
    rcv->next = CpmModelC$outstandingReceptionHead[sim_node()];
    CpmModelC$outstandingReceptionHead[sim_node()] = rcv;
    evt = CpmModelC$allocate_receive_event(endTime, rcv);
    sim_queue_insert(evt);
  }
  
  
  static inline void CpmModelC$sim_gain_put(int dest, message_t *msg, sim_time_t endTime, bool receive, double power, double reversePower)
  #line 418
  {
    int prevNode = sim_node();
  
  #line 420
    sim_log_debug(205U, "CpmModelC", "Enqueing reception event for %i at %llu with power %lf.\n", dest, endTime, power);
    sim_set_node(dest);
    CpmModelC$enqueue_receive_event(prevNode, endTime, msg, receive, power, reversePower);
    sim_set_node(prevNode);
  }
  
  static inline void CpmModelC$Model$putOnAirTo(int dest, message_t *msg, bool ack, sim_time_t endTime, double power, double reversePower)
  #line 426
  {
    gain_entry_t *neighborEntry = sim_gain_first(sim_node());
  
  #line 428
    CpmModelC$requestAck[sim_node()] = ack;
    CpmModelC$outgoing[sim_node()] = msg;
    sim_log_debug(206U, "CpmModelC", "Node %i transmitting to %i, finishes at %llu.\n", sim_node(), dest, endTime);
  
    while (neighborEntry != (void *)0) {
        int other = neighborEntry->mote;
  
  #line 434
        CpmModelC$sim_gain_put(other, msg, endTime, ack && other == dest, power + sim_gain_value(sim_node(), other), reversePower + sim_gain_value(other, sim_node()));
        neighborEntry = sim_gain_next(neighborEntry);
      }
  }
  
  # 40 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  inline static void TossimPacketModelC$GainRadioModel$putOnAirTo(int dest, message_t *msg, bool ack, sim_time_t endTime, double gain, double reverseGain){
  #line 40
    CpmModelC$Model$putOnAirTo(dest, msg, ack, endTime, gain, reverseGain);
  #line 40
  }
  #line 40
  # 277 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$send_transmit_done(sim_event_t *evt)
  #line 277
  {
    message_t *rval = TossimPacketModelC$sending[sim_node()];
  
  #line 279
    TossimPacketModelC$sending[sim_node()] = (void *)0;
    TossimPacketModelC$transmitting[sim_node()] = FALSE;
    sim_log_debug(183U, "TossimPacketModelC", "PACKET: Signaling send done at %llu.\n", sim_time());
    TossimPacketModelC$Packet$sendDone(rval, TossimPacketModelC$running[sim_node()] ? SUCCESS : EOFF);
  }
  
  #line 246
  static inline int TossimPacketModelC$sim_packet_header_length(void )
  #line 246
  {
    return sizeof(tossim_header_t );
  }
  
  #line 80
  static inline tossim_metadata_t *TossimPacketModelC$getMetadata(message_t *msg)
  #line 80
  {
    return (tossim_metadata_t *)& msg->metadata;
  }
  
  #line 250
  static inline void TossimPacketModelC$send_transmit(sim_event_t *evt)
  #line 250
  {
    sim_time_t duration;
    tossim_metadata_t *metadata = TossimPacketModelC$getMetadata(TossimPacketModelC$sending[sim_node()]);
  
    duration = 8 * (TossimPacketModelC$sendingLength[sim_node()] + TossimPacketModelC$sim_packet_header_length());
    duration /= sim_csma_bits_per_symbol();
    duration += sim_csma_preamble_length();
  
    if (__nesc_ntoh_uint8(metadata->ack.nxdata)) {
        duration += sim_csma_ack_time();
      }
    duration *= sim_ticks_per_sec() / sim_csma_symbols_per_sec();
  
    evt->time += duration;
    evt->handle = TossimPacketModelC$send_transmit_done;
  
    sim_log_debug(181U, "TossimPacketModelC", "PACKET: Broadcasting packet to everyone.\n");
    TossimPacketModelC$GainRadioModel$putOnAirTo(TossimPacketModelC$destNode[sim_node()], TossimPacketModelC$sending[sim_node()], __nesc_ntoh_uint8(metadata->ack.nxdata), evt->time, 0.0, 0.0);
    __nesc_hton_uint8(metadata->ack.nxdata, 0);
  
    evt->time += sim_csma_rxtx_delay() * (sim_ticks_per_sec() / sim_csma_symbols_per_sec());
  
    sim_log_debug(182U, "TossimPacketModelC", "PACKET: Send done at %llu.\n", evt->time);
  
    sim_queue_insert(evt);
  }
  
  # 202 "CpmModelC.nc"
  static inline bool CpmModelC$Model$clearChannel(void )
  #line 202
  {
    sim_log_debug(189U, "CpmModelC", "Checking clear channel @ %s: %f <= %f \n", sim_time_string(), (double )CpmModelC$packetNoise((void *)0), CpmModelC$clearThreshold[sim_node()]);
    return CpmModelC$packetNoise((void *)0) < CpmModelC$clearThreshold[sim_node()];
  }
  
  # 48 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  inline static bool TossimPacketModelC$GainRadioModel$clearChannel(void ){
  #line 48
    unsigned char __nesc_result;
  #line 48
  
  #line 48
    __nesc_result = CpmModelC$Model$clearChannel();
  #line 48
  
  #line 48
    return __nesc_result;
  #line 48
  }
  #line 48
  # 209 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$send_backoff(sim_event_t *evt)
  #line 209
  {
    TossimPacketModelC$backoffCount[sim_node()]++;
    if (TossimPacketModelC$GainRadioModel$clearChannel()) {
        TossimPacketModelC$neededFreeSamples[sim_node()]--;
      }
    else {
        TossimPacketModelC$neededFreeSamples[sim_node()] = sim_csma_min_free_samples();
      }
    if (TossimPacketModelC$neededFreeSamples[sim_node()] == 0) {
        sim_time_t delay;
  
  #line 219
        delay = sim_csma_rxtx_delay();
        delay *= sim_ticks_per_sec() / sim_csma_symbols_per_sec();
        evt->time += delay;
        TossimPacketModelC$transmitting[sim_node()] = TRUE;
        evt->handle = TossimPacketModelC$send_transmit;
        sim_queue_insert(evt);
      }
    else {
  #line 226
      if (sim_csma_max_iterations() == 0 || 
      TossimPacketModelC$backoffCount[sim_node()] <= sim_csma_max_iterations()) {
          sim_time_t backoff = sim_random();
          sim_time_t modulo = sim_csma_high() - sim_csma_low();
  
  #line 230
          modulo *= pow(sim_csma_exponent_base(), TossimPacketModelC$backoffCount[sim_node()]);
          backoff %= modulo;
  
          backoff += sim_csma_init_low();
          backoff *= sim_ticks_per_sec() / sim_csma_symbols_per_sec();
          evt->time += backoff;
          sim_queue_insert(evt);
        }
      else {
          message_t *rval = TossimPacketModelC$sending[sim_node()];
  
  #line 240
          TossimPacketModelC$sending[sim_node()] = (void *)0;
          sim_log_debug(180U, "TossimPacketModelC", "PACKET: Failed to send packet due to busy channel.\n");
          TossimPacketModelC$Packet$sendDone(rval, EBUSY);
        }
      }
  }
  
  #line 185
  static inline void TossimPacketModelC$start_csma(void )
  #line 185
  {
    sim_time_t first_sample;
  
  
  
  
    sim_time_t backoff = sim_random();
  
  #line 192
    backoff %= sim_csma_init_high() - sim_csma_init_low();
    backoff += sim_csma_init_low();
    backoff *= sim_ticks_per_sec() / sim_csma_symbols_per_sec();
    sim_log_debug(179U, "TossimPacketModelC", "Starting CMSA with %lli.\n", backoff);
    first_sample = sim_time() + backoff;
  
    TossimPacketModelC$sendEvent[sim_node()].mote = sim_node();
    TossimPacketModelC$sendEvent[sim_node()].time = first_sample;
    TossimPacketModelC$sendEvent[sim_node()].force = 0;
    TossimPacketModelC$sendEvent[sim_node()].cancelled = 0;
  
    TossimPacketModelC$sendEvent[sim_node()].handle = TossimPacketModelC$send_backoff;
    TossimPacketModelC$sendEvent[sim_node()].cleanup = sim_queue_cleanup_none;
    sim_queue_insert(&TossimPacketModelC$sendEvent[sim_node()]);
  }
  
  #line 159
  static inline error_t TossimPacketModelC$Packet$send(int dest, message_t *msg, uint8_t len)
  #line 159
  {
    if (!TossimPacketModelC$initialized[sim_node()]) {
        sim_log_error(177U, "TossimPacketModelC", "TossimPacketModelC: Send.send() called, but not initialized!\n");
        return EOFF;
      }
    if (!TossimPacketModelC$running[sim_node()]) {
        sim_log_error(178U, "TossimPacketModelC", "TossimPacketModelC: Send.send() called, but not running!\n");
        return EOFF;
      }
  
    if (TossimPacketModelC$sending[sim_node()] != (void *)0) {
        return EBUSY;
      }
    TossimPacketModelC$sendingLength[sim_node()] = len;
    TossimPacketModelC$sending[sim_node()] = msg;
    TossimPacketModelC$destNode[sim_node()] = dest;
    TossimPacketModelC$backoffCount[sim_node()] = 0;
    TossimPacketModelC$neededFreeSamples[sim_node()] = sim_csma_min_free_samples();
    TossimPacketModelC$start_csma();
    return SUCCESS;
  }
  
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  inline static error_t TossimActiveMessageC$Model$send(int node, message_t *msg, uint8_t len){
  #line 49
    unsigned char __nesc_result;
  #line 49
  
  #line 49
    __nesc_result = TossimPacketModelC$Packet$send(node, msg, len);
  #line 49
  
  #line 49
    return __nesc_result;
  #line 49
  }
  #line 49
  # 80 "CpmModelC.nc"
  static inline double CpmModelC$timeInMs(void )
  #line 80
  {
    sim_time_t ftime = sim_time();
    int hours;
  #line 82
    int minutes;
  #line 82
    int seconds;
    sim_time_t secondBillionths;
    int temp_time;
    double ms_time;
  
    secondBillionths = ftime % sim_ticks_per_sec();
    if (sim_ticks_per_sec() > (sim_time_t )1000000000) {
        secondBillionths /= sim_ticks_per_sec() / (sim_time_t )1000000000;
      }
    else {
        secondBillionths *= (sim_time_t )1000000000 / sim_ticks_per_sec();
      }
    temp_time = (int )(secondBillionths / 10000);
  
    if (temp_time % 10 >= 5) {
        temp_time += 10 - temp_time % 10;
      }
    else {
        temp_time -= temp_time % 10;
      }
    ms_time = (float )(temp_time / 100.0);
  
    seconds = (int )(ftime / sim_ticks_per_sec());
    minutes = seconds / 60;
    hours = minutes / 60;
    seconds %= 60;
    minutes %= 60;
  
    ms_time += (hours * 3600 + minutes * 60 + seconds) * 1000;
  
    return ms_time;
  }
  
  
  static inline double CpmModelC$noise_hash_generation(void )
  #line 116
  {
    double CT = CpmModelC$timeInMs();
    uint32_t quotient = (sim_time_t )(CT * 10) / 10;
    uint8_t remain = (uint8_t )((sim_time_t )(CT * 10) % 10);
    double noise_val;
    uint16_t node_id = sim_node();
  
    sim_log_debug(185U, "CpmModelC", "IN: noise_hash_generation()\n");
    if (5 <= remain && remain < 10) {
        noise_val = (double )sim_noise_generate(node_id, quotient + 1);
      }
    else {
        noise_val = (double )sim_noise_generate(node_id, quotient);
      }
    sim_log_debug(186U, "CpmModelC,Tal", "%s: OUT: noise_hash_generation(): %lf\n", sim_time_string(), noise_val);
  
    return noise_val;
  }
  
  # 57 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$nextPacket(void )
  #line 57
  {
    uint8_t i;
  
  #line 59
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] = (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] + 1) % 1;
    for (i = 0; i < 1; i++) {
        if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()]].msg == (void *)0 || 
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] / 8] & (1 << /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] % 8)) 
          {
            /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] = (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] + 1) % 1;
          }
        else {
            break;
          }
      }
    if (i >= 1) {
  #line 70
      /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] = 1;
      }
  }
  
  # 169 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline uint8_t TossimActiveMessageC$Packet$payloadLength(message_t *msg)
  #line 169
  {
    return __nesc_ntoh_uint8(TossimActiveMessageC$getHeader(msg)->length.nxdata);
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  inline static uint8_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$payloadLength(message_t * msg){
  #line 67
    unsigned char __nesc_result;
  #line 67
  
  #line 67
    __nesc_result = TossimActiveMessageC$Packet$payloadLength(msg);
  #line 67
  
  #line 67
    return __nesc_result;
  #line 67
  }
  #line 67
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  inline static error_t /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$postTask(void ){
  #line 56
    unsigned char __nesc_result;
  #line 56
  
  #line 56
    __nesc_result = SimSchedulerBasicP$TaskBasic$postTask(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask);
  #line 56
  
  #line 56
    return __nesc_result;
  #line 56
  }
  #line 56
  # 131 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static inline bool SimSchedulerBasicP$isWaiting(uint8_t id)
  {
    return SimSchedulerBasicP$m_next[sim_node()][id] != SimSchedulerBasicP$NO_TASK || SimSchedulerBasicP$m_tail[sim_node()] == id;
  }
  
  static inline bool SimSchedulerBasicP$pushTask(uint8_t id)
  {
    if (!SimSchedulerBasicP$isWaiting(id)) 
      {
        if (SimSchedulerBasicP$m_head[sim_node()] == SimSchedulerBasicP$NO_TASK) 
          {
            SimSchedulerBasicP$m_head[sim_node()] = id;
            SimSchedulerBasicP$m_tail[sim_node()] = id;
          }
        else 
          {
            SimSchedulerBasicP$m_next[sim_node()][SimSchedulerBasicP$m_tail[sim_node()]] = id;
            SimSchedulerBasicP$m_tail[sim_node()] = id;
          }
        return TRUE;
      }
    else 
      {
        return FALSE;
      }
  }
  
  #line 61
  static inline int SimSchedulerBasicP$sim_config_task_latency(void )
  #line 61
  {
  #line 61
    return 100;
  }
  
  # 221 "CpmModelC.nc"
  static inline double CpmModelC$prr_estimate_from_snr(double SNR)
  #line 221
  {
    double beta1 = 1.3687;
    double beta2 = 0.9187;
    double SNR_lin = pow(10.0, SNR / 10.0);
    double X = fabs(SNR_lin - beta2);
    double PSE = 0.5 * erfc(beta1 * sqrt(X / 2));
    double prr_hat = pow(1 - PSE, 23 * 2);
  
  #line 228
    sim_log_debug(190U, "CpmModelC,SNR", "SNR is %lf, PRR is %lf\n", SNR, prr_hat);
    if (prr_hat > 1) {
      prr_hat = 1;
      }
    else {
  #line 231
      if (prr_hat < 0) {
        prr_hat = 0;
        }
      }
  #line 234
    return prr_hat;
  }
  
  # 119 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline bool TossimActiveMessageC$Model$shouldAck(message_t *msg)
  #line 119
  {
    tossim_header_t *header = TossimActiveMessageC$getHeader(msg);
  
  #line 121
    if (__nesc_ntoh_uint16(header->dest.nxdata) == TossimActiveMessageC$amAddress()) {
        sim_log_debug(136U, "Acks", "Received packet addressed to me so ack it\n");
        return TRUE;
      }
    return FALSE;
  }
  
  # 79 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimPacketModel.nc"
  inline static bool TossimPacketModelC$Packet$shouldAck(message_t *msg){
  #line 79
    unsigned char __nesc_result;
  #line 79
  
  #line 79
    __nesc_result = TossimActiveMessageC$Model$shouldAck(msg);
  #line 79
  
  #line 79
    return __nesc_result;
  #line 79
  }
  #line 79
  # 296 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$GainRadioModel$acked(message_t *msg)
  #line 296
  {
    if (TossimPacketModelC$running[sim_node()]) {
        tossim_metadata_t *metadata = TossimPacketModelC$getMetadata(TossimPacketModelC$sending[sim_node()]);
  
  #line 299
        __nesc_hton_uint8(metadata->ack.nxdata, 1);
        if (msg != TossimPacketModelC$sending[sim_node()]) {
            TossimPacketModelC$error[sim_node()] = 1;
            sim_log_debug(184U, "TossimPacketModelC", "Requested ack for 0x%x, but outgoing packet is 0x%x.\n", msg, TossimPacketModelC$sending[sim_node()]);
          }
      }
  }
  
  # 50 "/opt/tinyos-2.1.0/tos/lib/tossim/GainRadioModel.nc"
  inline static void CpmModelC$Model$acked(message_t *msg){
  #line 50
    TossimPacketModelC$GainRadioModel$acked(msg);
  #line 50
  }
  #line 50
  # 141 "CpmModelC.nc"
  static inline double CpmModelC$arr_estimate_from_snr(double SNR)
  #line 141
  {
    double beta1 = 1.3687;
    double beta2 = 0.9187;
    double SNR_lin = pow(10.0, SNR / 10.0);
    double X = fabs(SNR_lin - beta2);
    double PSE = 0.5 * erfc(beta1 * sqrt(X / 2));
    double prr_hat = pow(1 - PSE, 23 * 2);
  
  #line 148
    sim_log_debug(187U, "CpmModelC,SNRLoss", "SNR is %lf, ARR is %lf\n", SNR, prr_hat);
    if (prr_hat > 1) {
      prr_hat = 1;
      }
    else {
  #line 151
      if (prr_hat < 0) {
        prr_hat = 0;
        }
      }
  #line 154
    return prr_hat;
  }
  
  static inline int CpmModelC$shouldAckReceive(double snr)
  #line 157
  {
    double prr = CpmModelC$arr_estimate_from_snr(snr);
    double coin = RandomUniform();
  
  #line 160
    if (prr != 0 && prr != 1) {
        if (coin < prr) {
          prr = 1.0;
          }
        else {
  #line 164
          prr = 0.0;
          }
      }
  #line 166
    return (int )prr;
  }
  
  static inline void CpmModelC$sim_gain_ack_handle(sim_event_t *evt)
  #line 169
  {
  
  
  
  
  
  
    if (
  #line 175
    CpmModelC$requestAck[sim_node()] && 
    CpmModelC$outgoing[sim_node()] != (void *)0 && 
    sim_mote_is_on(sim_node())) {
        CpmModelC$receive_message_t *rcv = (CpmModelC$receive_message_t *)evt->data;
        double power = rcv->reversePower;
        double noise = CpmModelC$packetNoise(rcv);
        double snr = power - noise;
  
  #line 182
        if (CpmModelC$shouldAckReceive(snr)) {
            CpmModelC$Model$acked(CpmModelC$outgoing[sim_node()]);
          }
      }
    CpmModelC$free_receive_message((CpmModelC$receive_message_t *)evt->data);
  }
  
  # 208 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline message_t *TossimActiveMessageC$Snoop$default$receive(am_id_t id, message_t *msg, void *payload, uint8_t len)
  #line 208
  {
    return msg;
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/interfaces/Receive.nc"
  inline static message_t * TossimActiveMessageC$Snoop$receive(am_id_t arg_0x2b37c1c05020, message_t * msg, void * payload, uint8_t len){
  #line 67
    nx_struct message_t *__nesc_result;
  #line 67
  
  #line 67
      __nesc_result = TossimActiveMessageC$Snoop$default$receive(arg_0x2b37c1c05020, msg, payload, len);
  #line 67
  
  #line 67
    return __nesc_result;
  #line 67
  }
  #line 67
  # 83 "/opt/tinyos-2.1.0/tos/chips/atm128/sim/atm128hardware.h"
  static __inline void __nesc_disable_interrupt()
  #line 83
  {
    atm128RegFile[sim_node()][* (volatile uint8_t *)&atm128RegFile[sim_node()][0x3F]] &= ~(1 << 7);
  }
  
  
  
  
  
  
  #line 91
  __inline  __nesc_atomic_t 
  __nesc_atomic_start(void )
  {
    __nesc_atomic_t result = * (volatile uint8_t *)&atm128RegFile[sim_node()][0x3F];
  
  #line 95
    __nesc_disable_interrupt();
    return result;
  }
  
  
  
  #line 100
  __inline  void 
  __nesc_atomic_end(__nesc_atomic_t original_SREG)
  {
    * (volatile uint8_t *)&atm128RegFile[sim_node()][0x3F] = original_SREG;
  }
  
  # 77 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static inline void SimSchedulerBasicP$sim_scheduler_event_handle(sim_event_t *e)
  #line 77
  {
    SimSchedulerBasicP$sim_scheduler_event_pending[sim_node()] = FALSE;
  
  
  
  
  
  
  
  
    if (SimSchedulerBasicP$Scheduler$runNextTask()) {
        SimSchedulerBasicP$sim_scheduler_submit_event();
      }
  }
  
  
  
  
  static inline void SimSchedulerBasicP$sim_scheduler_event_init(sim_event_t *e)
  #line 95
  {
    e->mote = sim_node();
    e->force = 0;
    e->data = (void *)0;
    e->handle = SimSchedulerBasicP$sim_scheduler_event_handle;
    e->cleanup = sim_queue_cleanup_none;
  }
  
  #line 158
  static inline void SimSchedulerBasicP$Scheduler$init(void )
  {
    sim_log_debug(124U, "Scheduler", "Initializing scheduler.\n");
    /* atomic removed: atomic calls only */
    {
      memset(SimSchedulerBasicP$m_next[sim_node()], SimSchedulerBasicP$NO_TASK, sizeof SimSchedulerBasicP$m_next[sim_node()]);
      SimSchedulerBasicP$m_head[sim_node()] = SimSchedulerBasicP$NO_TASK;
      SimSchedulerBasicP$m_tail[sim_node()] = SimSchedulerBasicP$NO_TASK;
  
      SimSchedulerBasicP$sim_scheduler_event_pending[sim_node()] = FALSE;
      SimSchedulerBasicP$sim_scheduler_event_init(&SimSchedulerBasicP$sim_scheduler_event[sim_node()]);
    }
  }
  
  # 46 "/opt/tinyos-2.1.0/tos/interfaces/Scheduler.nc"
  inline static void SimMainP$Scheduler$init(void ){
  #line 46
    SimSchedulerBasicP$Scheduler$init();
  #line 46
  }
  #line 46
  # 112 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static inline uint8_t SimSchedulerBasicP$popTask(void )
  {
    if (SimSchedulerBasicP$m_head[sim_node()] != SimSchedulerBasicP$NO_TASK) 
      {
        uint8_t id = SimSchedulerBasicP$m_head[sim_node()];
  
  #line 117
        SimSchedulerBasicP$m_head[sim_node()] = SimSchedulerBasicP$m_next[sim_node()][SimSchedulerBasicP$m_head[sim_node()]];
        if (SimSchedulerBasicP$m_head[sim_node()] == SimSchedulerBasicP$NO_TASK) 
          {
            SimSchedulerBasicP$m_tail[sim_node()] = SimSchedulerBasicP$NO_TASK;
          }
        SimSchedulerBasicP$m_next[sim_node()][id] = SimSchedulerBasicP$NO_TASK;
        return id;
      }
    else 
      {
        return SimSchedulerBasicP$NO_TASK;
      }
  }
  
  # 222 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getNow(void )
  #line 222
  {
    return /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$get();
  }
  
  # 98 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  inline static /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getNow(void ){
  #line 98
    unsigned int __nesc_result;
  #line 98
  
  #line 98
    __nesc_result = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getNow();
  #line 98
  
  #line 98
    return __nesc_result;
  #line 98
  }
  #line 98
  # 85 "/opt/tinyos-2.1.0/tos/lib/timer/AlarmToTimerC.nc"
  static inline uint32_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$getNow(void )
  {
  #line 86
    return /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getNow();
  }
  
  # 125 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static uint32_t /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$getNow(void ){
  #line 125
    unsigned int __nesc_result;
  #line 125
  
  #line 125
    __nesc_result = /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$getNow();
  #line 125
  
  #line 125
    return __nesc_result;
  #line 125
  }
  #line 125
  # 128 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$fired(void )
  {
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$fireTimers(/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$getNow());
  }
  
  # 72 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$fired(void ){
  #line 72
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$fired();
  #line 72
  }
  #line 72
  # 226 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getAlarm(void )
  #line 226
  {
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  #line 227
      {
        unsigned int __nesc_temp = 
  #line 227
        /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[sim_node()] + /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[sim_node()];
  
        {
  #line 227
          __nesc_atomic_end(__nesc_atomic); 
  #line 227
          return __nesc_temp;
        }
      }
  #line 229
      __nesc_atomic_end(__nesc_atomic); }
  }
  
  # 105 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  inline static /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getAlarm(void ){
  #line 105
    unsigned int __nesc_result;
  #line 105
  
  #line 105
    __nesc_result = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$getAlarm();
  #line 105
  
  #line 105
    return __nesc_result;
  #line 105
  }
  #line 105
  #line 92
  inline static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$startAt(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type t0, /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$size_type dt){
  #line 92
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$startAt(t0, dt);
  #line 92
  }
  #line 92
  # 47 "/opt/tinyos-2.1.0/tos/lib/timer/AlarmToTimerC.nc"
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$start(uint32_t t0, uint32_t dt, bool oneshot)
  {
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[sim_node()] = dt;
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[sim_node()] = oneshot;
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$startAt(t0, dt);
  }
  
  
  
  
  
  
  
  
  
  
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$runTask(void )
  {
    if (/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[sim_node()] == FALSE) {
      /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$start(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$getAlarm(), /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[sim_node()], FALSE);
      }
  #line 67
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$fired();
  }
  
  #line 82
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$startOneShotAt(uint32_t t0, uint32_t dt)
  {
  #line 83
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$start(t0, dt, TRUE);
  }
  
  # 118 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$startOneShotAt(uint32_t t0, uint32_t dt){
  #line 118
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$startOneShotAt(t0, dt);
  #line 118
  }
  #line 118
  # 204 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$stop(void )
  #line 204
  {
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  #line 205
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[sim_node()] = FALSE;
  #line 205
      __nesc_atomic_end(__nesc_atomic); }
  }
  
  # 62 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  inline static void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$stop(void ){
  #line 62
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$stop();
  #line 62
  }
  #line 62
  # 60 "/opt/tinyos-2.1.0/tos/lib/timer/AlarmToTimerC.nc"
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$stop(void )
  {
  #line 61
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$stop();
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$stop(void ){
  #line 67
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Timer$stop();
  #line 67
  }
  #line 67
  # 89 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$runTask(void )
  {
  
  
  
  
    uint32_t now = /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$getNow();
    int32_t min_remaining = (1UL << 31) - 1;
    bool min_remaining_isset = FALSE;
    uint8_t num;
  
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$stop();
  
    for (num = 0; num < /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$NUM_TIMERS; num++) 
      {
        /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer_t *timer = &/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[sim_node()][num];
  
        if (timer->isrunning) 
          {
            uint32_t elapsed = now - timer->t0;
            int32_t remaining = timer->dt - elapsed;
  
            if (remaining < min_remaining) 
              {
                min_remaining = remaining;
                min_remaining_isset = TRUE;
              }
          }
      }
  
    if (min_remaining_isset) 
      {
        if (min_remaining <= 0) {
          /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$fireTimers(now);
          }
        else {
  #line 124
          /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$startOneShotAt(now, min_remaining);
          }
      }
  }
  
  # 83 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  inline static error_t RoutC$MessageControl$start(void ){
  #line 83
    unsigned char __nesc_result;
  #line 83
  
  #line 83
    __nesc_result = TossimPacketModelC$Control$start();
  #line 83
  
  #line 83
    return __nesc_result;
  #line 83
  }
  #line 83
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  inline static error_t /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$postTask(void ){
  #line 56
    unsigned char __nesc_result;
  #line 56
  
  #line 56
    __nesc_result = SimSchedulerBasicP$TaskBasic$postTask(/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer);
  #line 56
  
  #line 56
    return __nesc_result;
  #line 56
  }
  #line 56
  # 133 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$startTimer(uint8_t num, uint32_t t0, uint32_t dt, bool isoneshot)
  {
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer_t *timer = &/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[sim_node()][num];
  
  #line 136
    timer->t0 = t0;
    timer->dt = dt;
    timer->isoneshot = isoneshot;
    timer->isrunning = TRUE;
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$postTask();
  }
  
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$startPeriodic(uint8_t num, uint32_t dt)
  {
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$startTimer(num, /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$TimerFrom$getNow(), dt, FALSE);
  }
  
  # 53 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void RoutC$PeriodTimer$startPeriodic(uint32_t dt){
  #line 53
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$startPeriodic(0U, dt);
  #line 53
  }
  #line 53
  # 78 "RandomMlcgC.nc"
  static inline uint16_t RandomMlcgC$Random$rand16(void )
  #line 78
  {
    return (uint16_t )RandomMlcgC$Random$rand32();
  }
  
  # 41 "/opt/tinyos-2.1.0/tos/interfaces/Random.nc"
  inline static uint16_t RoutC$Random$rand16(void ){
  #line 41
    unsigned short __nesc_result;
  #line 41
  
  #line 41
    __nesc_result = RandomMlcgC$Random$rand16();
  #line 41
  
  #line 41
    return __nesc_result;
  #line 41
  }
  #line 41
  # 62 "RoutC.nc"
  static inline uint16_t RoutC$random(uint16_t n)
  #line 62
  {
  
    return RoutC$Random$rand16() % n;
  }
  
  #line 103
  static inline void RoutC$startnode(void )
  #line 103
  {
    RoutC$battery[sim_node()] = 100;
    RoutC$clusterElec[sim_node()] = RoutC$random(4 + 1);
    if (RoutC$clusterElec[sim_node()] == 2) {
        RoutC$isCluster[sim_node()] = TRUE;
        sim_log_debug(46U, "Sink", "Sink: Have now collected %d pieces of information\n", 100);
      }
    RoutC$PeriodTimer$startPeriodic(1000);
  }
  
  #line 124
  static inline void RoutC$MessageControl$startDone(error_t err)
  #line 124
  {
    if (err == SUCCESS) {
        RoutC$startnode();
      }
    else {
        RoutC$MessageControl$start();
      }
  }
  
  # 92 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  inline static void TossimPacketModelC$Control$startDone(error_t error){
  #line 92
    RoutC$MessageControl$startDone(error);
  #line 92
  }
  #line 92
  # 94 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$startDoneTask$runTask(void )
  #line 94
  {
    TossimPacketModelC$running[sim_node()] = TRUE;
    TossimPacketModelC$Control$startDone(SUCCESS);
  }
  
  # 133 "RoutC.nc"
  static inline void RoutC$MessageControl$stopDone(error_t err)
  #line 133
  {
    ;
  }
  
  # 117 "/opt/tinyos-2.1.0/tos/interfaces/SplitControl.nc"
  inline static void TossimPacketModelC$Control$stopDone(error_t error){
  #line 117
    RoutC$MessageControl$stopDone(error);
  #line 117
  }
  #line 117
  # 99 "TossimPacketModelC.nc"
  static inline void TossimPacketModelC$stopDoneTask$runTask(void )
  #line 99
  {
    TossimPacketModelC$running[sim_node()] = FALSE;
    TossimPacketModelC$Control$stopDone(SUCCESS);
  }
  
  #line 143
  static inline void TossimPacketModelC$sendDoneTask$runTask(void )
  #line 143
  {
    message_t *msg = TossimPacketModelC$sending[sim_node()];
    tossim_metadata_t *meta = TossimPacketModelC$getMetadata(msg);
  
  #line 146
    __nesc_hton_uint8(meta->ack.nxdata, 0);
    __nesc_hton_int8(meta->strength.nxdata, 0);
    __nesc_hton_uint16(meta->time.nxdata, 0);
    TossimPacketModelC$sending[sim_node()] = FALSE;
    TossimPacketModelC$Packet$sendDone(msg, TossimPacketModelC$running[sim_node()] ? SUCCESS : EOFF);
  }
  
  # 99 "/opt/tinyos-2.1.0/tos/interfaces/AMSend.nc"
  inline static void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$sendDone(message_t * msg, error_t error){
  #line 99
    RoutC$MessageSend$sendDone(msg, error);
  #line 99
  }
  #line 99
  # 57 "/opt/tinyos-2.1.0/tos/system/AMQueueEntryP.nc"
  static inline void /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$sendDone(message_t *m, error_t err)
  #line 57
  {
    /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$AMSend$sendDone(m, err);
  }
  
  # 207 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$default$sendDone(uint8_t id, message_t *msg, error_t err)
  #line 207
  {
  }
  
  # 89 "/opt/tinyos-2.1.0/tos/interfaces/Send.nc"
  inline static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$sendDone(uint8_t arg_0x2b37c20e7e18, message_t * msg, error_t error){
  #line 89
    switch (arg_0x2b37c20e7e18) {
  #line 89
      case 0U:
  #line 89
        /*RoutAppC.MessageSender.AMQueueEntryP*/AMQueueEntryP$0$Send$sendDone(msg, error);
  #line 89
        break;
  #line 89
      default:
  #line 89
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$default$sendDone(arg_0x2b37c20e7e18, msg, error);
  #line 89
        break;
  #line 89
      }
  #line 89
  }
  #line 89
  # 155 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$sendDone(uint8_t last, message_t * msg, error_t err)
  #line 155
  {
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][last].msg = (void *)0;
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$tryToSend();
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$sendDone(last, msg, err);
  }
  
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$runTask(void )
  #line 161
  {
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$sendDone(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()], /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()]].msg, FAIL);
  }
  
  #line 118
  static inline void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask$runTask(void )
  #line 118
  {
    uint8_t i;
  #line 119
    uint8_t j;
  #line 119
    uint8_t mask;
  #line 119
    uint8_t last;
    message_t *msg;
  
  #line 121
    for (i = 0; i < 1 / 8 + 1; i++) {
        if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[sim_node()][i]) {
            for (mask = 1, j = 0; j < 8; j++) {
                if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[sim_node()][i] & mask) {
                    last = i * 8 + j;
                    msg = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][last].msg;
                    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][last].msg = (void *)0;
                    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[sim_node()][i] &= ~mask;
                    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Send$sendDone(last, msg, ECANCEL);
                  }
                mask <<= 1;
              }
          }
      }
  }
  
  # 213 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static inline void SimSchedulerBasicP$TaskBasic$default$runTask(uint8_t id)
  {
  }
  
  # 64 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  inline static void SimSchedulerBasicP$TaskBasic$runTask(uint8_t arg_0x2b37c1875ab0){
  #line 64
    switch (arg_0x2b37c1875ab0) {
  #line 64
      case /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired:
  #line 64
        /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$runTask();
  #line 64
        break;
  #line 64
      case /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer:
  #line 64
        /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$runTask();
  #line 64
        break;
  #line 64
      case TossimPacketModelC$startDoneTask:
  #line 64
        TossimPacketModelC$startDoneTask$runTask();
  #line 64
        break;
  #line 64
      case TossimPacketModelC$stopDoneTask:
  #line 64
        TossimPacketModelC$stopDoneTask$runTask();
  #line 64
        break;
  #line 64
      case TossimPacketModelC$sendDoneTask:
  #line 64
        TossimPacketModelC$sendDoneTask$runTask();
  #line 64
        break;
  #line 64
      case /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask:
  #line 64
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$CancelTask$runTask();
  #line 64
        break;
  #line 64
      case /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask:
  #line 64
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$runTask();
  #line 64
        break;
  #line 64
      default:
  #line 64
        SimSchedulerBasicP$TaskBasic$default$runTask(arg_0x2b37c1875ab0);
  #line 64
        break;
  #line 64
      }
  #line 64
  }
  #line 64
  # 53 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
  static inline long long int SimMoteP$SimMote$getStartTime(void )
  #line 53
  {
    return SimMoteP$startTime[sim_node()];
  }
  
  # 119 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline sim_time_t HplAtm128Timer0AsyncP$notify_clockTicksPerSec(void )
  #line 119
  {
    return ATM128_TIMER0_TICKSPPS;
  }
  
  #line 146
  static inline sim_time_t HplAtm128Timer0AsyncP$sim_to_clock(sim_time_t t)
  #line 146
  {
    t *= HplAtm128Timer0AsyncP$notify_clockTicksPerSec();
    t /= sim_ticks_per_sec();
    return t;
  }
  
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerCtrl8.nc"
  inline static Atm128_TIFR_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$getInterruptFlag(void ){
  #line 44
    union __nesc_unnamed4309 __nesc_result;
  #line 44
  
  #line 44
    __nesc_result = HplAtm128Timer0AsyncP$Timer0Ctrl$getInterruptFlag();
  #line 44
  
  #line 44
    return __nesc_result;
  #line 44
  }
  #line 44
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  inline static error_t TossimPacketModelC$startDoneTask$postTask(void ){
  #line 56
    unsigned char __nesc_result;
  #line 56
  
  #line 56
    __nesc_result = SimSchedulerBasicP$TaskBasic$postTask(TossimPacketModelC$startDoneTask);
  #line 56
  
  #line 56
    return __nesc_result;
  #line 56
  }
  #line 56
  # 347 "/usr/lib/ncc/nesc_nx.h"
  static __inline  uint32_t __nesc_hton_uint32(void * target, uint32_t value)
  #line 347
  {
    uint8_t *base = target;
  
  #line 349
    base[3] = value;
    base[2] = value >> 8;
    base[1] = value >> 16;
    base[0] = value >> 24;
    return value;
  }
  
  # 379 "RoutC.nc"
  static inline void RoutC$sendContent(void )
  #line 379
  {
  
    __nesc_hton_uint16(RoutC$message[sim_node()]->from.nxdata, TOS_NODE_ID);
    __nesc_hton_uint8(RoutC$message[sim_node()]->type.nxdata, 12);
    __nesc_hton_uint16(RoutC$message[sim_node()]->content.nxdata, RoutC$msgcount[sim_node()]);
    __nesc_hton_uint32(RoutC$message[sim_node()]->seq.nxdata, RoutC$sendContent$sequence[sim_node()]++);
    __nesc_hton_uint8(RoutC$message[sim_node()]->batteryLevel.nxdata, RoutC$battery[sim_node()]);
    RoutC$routMessage();
    RoutC$switchrouter[sim_node()] = TRUE;
  }
  
  #line 286
  static inline void RoutC$sendAnnounce(uint32_t rounds)
  #line 286
  {
    __nesc_hton_uint16(RoutC$message[sim_node()]->from.nxdata, TOS_NODE_ID);
    __nesc_hton_uint8(RoutC$message[sim_node()]->type.nxdata, 11);
    if (RoutC$isCluster[sim_node()]) {
        __nesc_hton_int8(RoutC$message[sim_node()]->clHead.nxdata, -1);
      }
    else {
        __nesc_hton_int8(RoutC$message[sim_node()]->clHead.nxdata, RoutC$clusterHead[sim_node()]);
      }
    __nesc_hton_uint8(RoutC$message[sim_node()]->batteryLevel.nxdata, RoutC$battery[sim_node()]);
    __nesc_hton_uint32(RoutC$message[sim_node()]->seq.nxdata, rounds);
    RoutC$routMessage();
  }
  
  #line 417
  static inline void RoutC$PeriodTimer$fired(void )
  #line 417
  {
  
    if (RoutC$batteryEmpty()) {
        return;
      }
  
    sim_log_debug(65U, "Event", "--- EVENT ---: Timer @ round %d\n", RoutC$PeriodTimer$fired$roundcounter[sim_node()]);
    switch (RoutC$PeriodTimer$fired$roundcounter[sim_node()] % 2) {
        case 0: 
          if (RoutC$isSink()) {
              sim_log_debug(66U, "Round", "========== Round %d ==========\n", RoutC$PeriodTimer$fired$roundcounter[sim_node()] / 2);
            }
        RoutC$sendAnnounce(RoutC$PeriodTimer$fired$roundcounter[sim_node()]);
        break;
        case 1: 
          if (!RoutC$isSink()) {
              RoutC$sendContent();
            }
        break;
        default: 
          sim_log_debug(67U, "Error", "ERROR: Unknown round %d\n", RoutC$PeriodTimer$fired$roundcounter[sim_node()]);
      }
    RoutC$PeriodTimer$fired$roundcounter[sim_node()]++;
  }
  
  # 193 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static inline void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$default$fired(uint8_t num)
  {
  }
  
  # 72 "/opt/tinyos-2.1.0/tos/lib/timer/Timer.nc"
  inline static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$fired(uint8_t arg_0x2b37c1eb72f8){
  #line 72
    switch (arg_0x2b37c1eb72f8) {
  #line 72
      case 0U:
  #line 72
        RoutC$PeriodTimer$fired();
  #line 72
        break;
  #line 72
      default:
  #line 72
        /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$default$fired(arg_0x2b37c1eb72f8);
  #line 72
        break;
  #line 72
      }
  #line 72
  }
  #line 72
  # 45 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$set(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$size_type t){
  #line 45
    HplAtm128Timer0AsyncP$Compare$set(t);
  #line 45
  }
  #line 45
  # 52 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Timer.nc"
  inline static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$timer_size /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get(void ){
  #line 52
    unsigned char __nesc_result;
  #line 52
  
  #line 52
    __nesc_result = HplAtm128Timer0AsyncP$Timer0$get();
  #line 52
  
  #line 52
    return __nesc_result;
  #line 52
  }
  #line 52
  # 561 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline int HplAtm128Timer0AsyncP$TimerAsync$compareBusy(void )
  #line 561
  {
    return (* (volatile uint8_t *)&atm128RegFile[sim_node()][0x30] & (1 << OCR0UB)) != 0;
  }
  
  # 44 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerAsync.nc"
  inline static int /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$compareBusy(void ){
  #line 44
    int __nesc_result;
  #line 44
  
  #line 44
    __nesc_result = HplAtm128Timer0AsyncP$TimerAsync$compareBusy();
  #line 44
  
  #line 44
    return __nesc_result;
  #line 44
  }
  #line 44
  # 74 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setOcr0(uint8_t n)
  #line 74
  {
    while (/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$compareBusy()) 
      ;
    if (n == /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get()) {
      n++;
      }
  
  
    if (/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()] + n + 1 < /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()]) {
      n = -/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()] - 1;
      }
  #line 84
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$set(n);
  }
  
  # 569 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline void HplAtm128Timer0AsyncP$cancel_compare(void )
  #line 569
  {
    sim_log_debug(164U, "HplAtm128CompareC", "Cancelling compare at 0x%p\n", HplAtm128Timer0AsyncP$compare[sim_node()]);
    if (HplAtm128Timer0AsyncP$compare[sim_node()] != (void *)0) {
        HplAtm128Timer0AsyncP$compare[sim_node()]->cancelled = 1;
        HplAtm128Timer0AsyncP$compare[sim_node()]->cleanup = sim_queue_cleanup_total;
      }
  }
  
  #line 108
  static inline void HplAtm128Timer0AsyncP$notify_changed(void )
  #line 108
  {
    uint8_t newScale = HplAtm128Timer0AsyncP$Timer0$getScale();
  
  #line 110
    if (newScale != AVR_CLOCK_OFF && 
    HplAtm128Timer0AsyncP$oldScale[sim_node()] == AVR_CLOCK_OFF) {
        HplAtm128Timer0AsyncP$lastZero[sim_node()] = sim_time();
      }
    HplAtm128Timer0AsyncP$oldScale[sim_node()] = newScale;
  
    HplAtm128Timer0AsyncP$schedule_new_compare();
  }
  
  #line 537
  static inline void HplAtm128Timer0AsyncP$cancel_overflow(void )
  #line 537
  {
    if (HplAtm128Timer0AsyncP$overflow[sim_node()] != (void *)0) {
        HplAtm128Timer0AsyncP$overflow[sim_node()]->cancelled = 1;
        sim_log_debug(163U, "HplAtm128Timer0AsyncP", "Cancelling overflow %p.\n", HplAtm128Timer0AsyncP$overflow[sim_node()]);
        HplAtm128Timer0AsyncP$overflow[sim_node()]->cleanup = sim_queue_cleanup_total;
      }
  }
  
  #line 473
  static inline void HplAtm128Timer0AsyncP$timer0_overflow_handle(sim_event_t *evt)
  #line 473
  {
    if (evt->cancelled) {
        return;
      }
    else {
        if ((atm128RegFile[sim_node()][ATM128_TIMSK] & (1 << TOIE0)) != 0) {
            atm128RegFile[sim_node()][ATM128_TIFR] &= ~(1 << TOV0);
            sim_log_debug(160U, "HplAtm128Timer0AsyncP", "Overflow interrupt at %s\n", sim_time_string());
            INTERRUPT_16();
          }
        else {
            sim_log_debug(161U, "HplAtm128Timer0AsyncP", "Setting overflow bit at %s\n", sim_time_string());
            atm128RegFile[sim_node()][ATM128_TIFR] |= 1 << TOV0;
          }
        HplAtm128Timer0AsyncP$configure_overflow(evt);
        sim_queue_insert(evt);
      }
  }
  
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_overflow(void )
  #line 492
  {
    sim_event_t *newEvent = sim_queue_allocate_event();
  
    newEvent->handle = HplAtm128Timer0AsyncP$timer0_overflow_handle;
    newEvent->cleanup = sim_queue_cleanup_none;
    return newEvent;
  }
  
  #line 526
  static inline void HplAtm128Timer0AsyncP$schedule_new_overflow(void )
  #line 526
  {
    sim_event_t *newEvent = HplAtm128Timer0AsyncP$allocate_overflow();
  
  #line 528
    HplAtm128Timer0AsyncP$configure_overflow(newEvent);
  
    if (HplAtm128Timer0AsyncP$overflow[sim_node()] != (void *)0) {
        HplAtm128Timer0AsyncP$cancel_overflow();
      }
    HplAtm128Timer0AsyncP$overflow[sim_node()] = newEvent;
    sim_queue_insert(newEvent);
  }
  
  #line 140
  static inline sim_time_t HplAtm128Timer0AsyncP$clock_to_sim(sim_time_t t)
  #line 140
  {
    t *= sim_ticks_per_sec();
    t /= HplAtm128Timer0AsyncP$notify_clockTicksPerSec();
    return t;
  }
  
  #line 289
  static inline void HplAtm128Timer0AsyncP$Timer0$set(uint8_t newVal)
  #line 289
  {
    uint8_t curVal = HplAtm128Timer0AsyncP$Timer0$get();
  
  #line 291
    sim_log_debug(153U, "HplAtm128Timer0AsyncP", "HplAtm128Timer0AsyncP: Setting timer: %hhu\n", newVal);
    if (newVal == curVal) {
        return;
      }
    else {
        sim_time_t adjustment = curVal - newVal;
  
  #line 297
        adjustment = adjustment << HplAtm128Timer0AsyncP$shiftFromScale();
        adjustment = HplAtm128Timer0AsyncP$clock_to_sim(adjustment);
  
        if (newVal < curVal) {
            HplAtm128Timer0AsyncP$lastZero[sim_node()] += adjustment;
          }
        else {
            HplAtm128Timer0AsyncP$lastZero[sim_node()] -= adjustment;
          }
  
        HplAtm128Timer0AsyncP$schedule_new_overflow();
        HplAtm128Timer0AsyncP$notify_changed();
      }
  }
  
  #line 179
  static inline void HplAtm128Timer0AsyncP$timer0_compare_handle(sim_event_t *evt)
  #line 179
  {
    sim_log_debug(143U, "HplAtm128Timer0AsyncP", "Beginning compare 0x%p at %s\n", evt, sim_time_string());
    if (evt->cancelled) {
        return;
      }
    else {
        char timeStr[128];
  
  #line 186
        sim_print_now(timeStr, 128);
        sim_log_debug(144U, "HplAtm128Timer0AsyncP", "Handling compare at 0x%p @ %s\n", evt, sim_time_string());
  
        if ((atm128RegFile[sim_node()][ATM128_TCCR0] & (1 << WGM01)) != 0 && !((atm128RegFile[sim_node()][ATM128_TCCR0] & (1 << WGM00)) != 0)) {
            sim_log_debug(145U, "HplAtm128Timer0AsyncP", "%s: CTC is set, clear timer.\n", __FUNCTION__);
            HplAtm128Timer0AsyncP$Timer0$set(0);
          }
        else {
            sim_log_debug(146U, "HplAtm128Timer0AsyncP", "%s: TCCR is 0x%hhx, %i, %i\n", __FUNCTION__, * (volatile uint8_t *)&atm128RegFile[sim_node()][0x33], (int )((atm128RegFile[sim_node()][ATM128_TCCR0] & (1 << WGM01)) != 0), (int )((atm128RegFile[sim_node()][ATM128_TCCR0] & (1 << WGM00)) != 0));
          }
  
        if ((atm128RegFile[sim_node()][ATM128_TIMSK] & (1 << OCIE0)) != 0) {
            sim_log_debug(147U, "HplAtm128Timer0AsyncP", "TIFR is %hhx\n", * (volatile uint8_t *)&atm128RegFile[sim_node()][0x36]);
            atm128RegFile[sim_node()][ATM128_TIFR] &= ~(1 << OCF0);
            sim_log_debug(148U, "HplAtm128Timer0AsyncP", "TIFR is %hhx\n", * (volatile uint8_t *)&atm128RegFile[sim_node()][0x36]);
            sim_log_debug(149U, "HplAtm128Timer0AsyncP", "Compare interrupt @ %s\n", timeStr);
            INTERRUPT_15();
          }
        else {
            atm128RegFile[sim_node()][ATM128_TIFR] |= 1 << OCF0;
          }
  
        if (! evt->cancelled) {
            HplAtm128Timer0AsyncP$configure_compare(evt);
            sim_queue_insert(evt);
          }
      }
  }
  
  static inline sim_event_t *HplAtm128Timer0AsyncP$allocate_compare(void )
  #line 215
  {
    sim_event_t *newEvent = sim_queue_allocate_event();
  
  #line 217
    sim_log_debug(150U, "HplAtm128Timer0AsyncP", "Allocated compare at 0x%p\n", newEvent);
    newEvent->handle = HplAtm128Timer0AsyncP$timer0_compare_handle;
    newEvent->cleanup = sim_queue_cleanup_none;
    return newEvent;
  }
  
  # 230 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$overflow(void )
  #line 230
  {
  }
  
  # 61 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Timer.nc"
  inline static void HplAtm128Timer0AsyncP$Timer0$overflow(void ){
  #line 61
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$overflow();
  #line 61
  }
  #line 61
  # 47 "/opt/tinyos-2.1.0/tos/lib/timer/CounterToLocalTimeC.nc"
  static inline void /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$overflow(void )
  {
  }
  
  # 71 "/opt/tinyos-2.1.0/tos/lib/timer/Counter.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$overflow(void ){
  #line 71
    /*HilTimerMilliC.CounterToLocalTimeC*/CounterToLocalTimeC$0$Counter$overflow();
  #line 71
  }
  #line 71
  # 79 "/opt/tinyos-2.1.0/tos/chips/atm128/sim/atm128hardware.h"
  static __inline void __nesc_enable_interrupt()
  #line 79
  {
    atm128RegFile[sim_node()][* (volatile uint8_t *)&atm128RegFile[sim_node()][0x3F]] |= 1 << 7;
  }
  
  # 39 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  inline static /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$size_type /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$get(void ){
  #line 39
    unsigned char __nesc_result;
  #line 39
  
  #line 39
    __nesc_result = HplAtm128Timer0AsyncP$Compare$get();
  #line 39
  
  #line 39
    return __nesc_result;
  #line 39
  }
  #line 39
  # 149 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$fired(void )
  #line 149
  {
    int overflowed;
  
  
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()] += /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$get() + 1U;
    overflowed = !/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()];
    __nesc_enable_interrupt();
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt();
    if (overflowed) {
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$overflow();
      }
  }
  
  # 49 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  inline static void HplAtm128Timer0AsyncP$Compare$fired(void ){
  #line 49
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$fired();
  #line 49
  }
  #line 49
  # 56 "/opt/tinyos-2.1.0/tos/interfaces/TaskBasic.nc"
  inline static error_t /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$postTask(void ){
  #line 56
    unsigned char __nesc_result;
  #line 56
  
  #line 56
    __nesc_result = SimSchedulerBasicP$TaskBasic$postTask(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired);
  #line 56
  
  #line 56
    return __nesc_result;
  #line 56
  }
  #line 56
  # 70 "/opt/tinyos-2.1.0/tos/lib/timer/AlarmToTimerC.nc"
  static inline void /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$fired(void )
  {
  #line 71
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$fired$postTask();
  }
  
  # 67 "/opt/tinyos-2.1.0/tos/lib/timer/Alarm.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$fired(void ){
  #line 67
    /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$Alarm$fired();
  #line 67
  }
  #line 67
  # 42 "/opt/tinyos-2.1.0/tos/platforms/mica/PlatformP.nc"
  static inline void PlatformP$power_init(void )
  #line 42
  {
    /* atomic removed: atomic calls only */
  #line 43
    {
      * (volatile uint8_t *)&atm128RegFile[sim_node()][0x35] = 1 << SE;
    }
  }
  
  # 38 "/opt/tinyos-2.1.0/tos/platforms/micaz/MotePlatformP.nc"
  static inline error_t MotePlatformP$SubInit$default$init(void )
  #line 38
  {
    return SUCCESS;
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t MotePlatformP$SubInit$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = MotePlatformP$SubInit$default$init();
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 50 "/opt/tinyos-2.1.0/tos/chips/atm128/pins/sim/HplAtm128GeneralIOPinP.nc"
  static __inline void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$clr(void )
  #line 50
  {
  #line 50
    atm128RegFile[sim_node()][27U] &= ~(1 << 4);
  }
  
  # 30 "/opt/tinyos-2.1.0/tos/interfaces/GeneralIO.nc"
  inline static void MotePlatformP$SerialIdPin$clr(void ){
  #line 30
    /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$clr();
  #line 30
  }
  #line 30
  # 53 "/opt/tinyos-2.1.0/tos/chips/atm128/pins/sim/HplAtm128GeneralIOPinP.nc"
  static __inline void /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$makeInput(void )
  #line 53
  {
  #line 53
    atm128RegFile[sim_node()][26U] &= ~(1 << 4);
  }
  
  # 33 "/opt/tinyos-2.1.0/tos/interfaces/GeneralIO.nc"
  inline static void MotePlatformP$SerialIdPin$makeInput(void ){
  #line 33
    /*HplAtm128GeneralIOC.PortA.Bit4*/HplAtm128GeneralIOPinP$4$IO$makeInput();
  #line 33
  }
  #line 33
  # 26 "/opt/tinyos-2.1.0/tos/platforms/micaz/MotePlatformP.nc"
  static inline error_t MotePlatformP$PlatformInit$init(void )
  #line 26
  {
  
    * (volatile uint8_t *)&atm128RegFile[sim_node()][0x15] = 0;
    * (volatile uint8_t *)&atm128RegFile[sim_node()][0x14] = 0xff;
  
  
    MotePlatformP$SerialIdPin$makeInput();
    MotePlatformP$SerialIdPin$clr();
  
    return MotePlatformP$SubInit$init();
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t PlatformP$MoteInit$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = MotePlatformP$PlatformInit$init();
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 58 "/opt/tinyos-2.1.0/tos/types/TinyError.h"
  static inline  error_t ecombine(error_t r1, error_t r2)
  
  
  
  
  {
    return r1 == r2 ? r1 : FAIL;
  }
  
  # 21 "/opt/tinyos-2.1.0/tos/platforms/mica/sim/MeasureClockC.nc"
  static inline error_t MeasureClockC$Init$init(void )
  #line 21
  {
    return SUCCESS;
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t PlatformP$MeasureClock$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = MeasureClockC$Init$init();
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 49 "/opt/tinyos-2.1.0/tos/platforms/mica/PlatformP.nc"
  static inline error_t PlatformP$Init$init(void )
  {
    error_t ok;
  
  
    ok = PlatformP$MeasureClock$init();
    ok = ecombine(ok, PlatformP$MoteInit$init());
  
    if (ok != SUCCESS) {
      return ok;
      }
    PlatformP$power_init();
  
    return SUCCESS;
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t SimMainP$PlatformInit$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = PlatformP$Init$init();
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 54 "/opt/tinyos-2.1.0/tos/interfaces/Scheduler.nc"
  inline static bool SimMainP$Scheduler$runNextTask(void ){
  #line 54
    unsigned char __nesc_result;
  #line 54
  
  #line 54
    __nesc_result = SimSchedulerBasicP$Scheduler$runNextTask();
  #line 54
  
  #line 54
    return __nesc_result;
  #line 54
  }
  #line 54
  # 439 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline void HplAtm128Timer0AsyncP$Compare$start(void )
  #line 439
  {
  #line 439
    atm128RegFile[sim_node()][ATM128_TIMSK] |= 1 << OCIE0;
  }
  
  # 56 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128Compare.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$start(void ){
  #line 56
    HplAtm128Timer0AsyncP$Compare$start();
  #line 56
  }
  #line 56
  # 356 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline void HplAtm128Timer0AsyncP$Timer0Ctrl$setControl(Atm128TimerControl_t x)
  #line 356
  {
    sim_log_debug(155U, "HplAtm128Timer0AsyncP", "Setting control to be 0x%hhx\n", x.flat);
    * (volatile uint8_t *)&atm128RegFile[sim_node()][0x33] = x.flat;
  }
  
  # 37 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerCtrl8.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$setControl(Atm128TimerControl_t control){
  #line 37
    HplAtm128Timer0AsyncP$Timer0Ctrl$setControl(control);
  #line 37
  }
  #line 37
  # 553 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static inline void HplAtm128Timer0AsyncP$TimerAsync$setTimer0Asynchronous(void )
  #line 553
  {
    * (volatile uint8_t *)&atm128RegFile[sim_node()][0x30] |= 1 << AS0;
  }
  
  # 32 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/HplAtm128TimerAsync.nc"
  inline static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$setTimer0Asynchronous(void ){
  #line 32
    HplAtm128Timer0AsyncP$TimerAsync$setTimer0Asynchronous();
  #line 32
  }
  #line 32
  # 54 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static inline error_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Init$init(void )
  #line 54
  {
    /* atomic removed: atomic calls only */
    {
      Atm128TimerControl_t x;
  
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerAsync$setTimer0Asynchronous();
      x.flat = 0;
      x.bits.cs = 3;
      x.bits.wgm1 = 1;
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$setControl(x);
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$set(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MAXT);
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$start();
    }
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt();
    return SUCCESS;
  }
  
  # 84 "TossimPacketModelC.nc"
  static inline error_t TossimPacketModelC$Init$init(void )
  #line 84
  {
    sim_log_debug(172U, "TossimPacketModelC", "TossimPacketModelC: Init.init() called\n");
    TossimPacketModelC$initialized[sim_node()] = TRUE;
  
  
  
    TossimPacketModelC$sendEvent[sim_node()].cancelled = 1;
    return SUCCESS;
  }
  
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t SimMainP$SoftwareInit$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = TossimPacketModelC$Init$init();
  #line 51
    __nesc_result = ecombine(__nesc_result, RandomMlcgC$Init$init());
  #line 51
    __nesc_result = ecombine(__nesc_result, /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Init$init());
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 181 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static inline void *TossimActiveMessageC$Packet$getPayload(message_t *msg, uint8_t len)
  #line 181
  {
    if (len <= 28) {
        return msg->data;
      }
    else {
        return (void *)0;
      }
  }
  
  # 115 "/opt/tinyos-2.1.0/tos/interfaces/Packet.nc"
  inline static void * RoutC$MessagePacket$getPayload(message_t * msg, uint8_t len){
  #line 115
    void *__nesc_result;
  #line 115
  
  #line 115
    __nesc_result = TossimActiveMessageC$Packet$getPayload(msg, len);
  #line 115
  
  #line 115
    return __nesc_result;
  #line 115
  }
  #line 115
  # 51 "/opt/tinyos-2.1.0/tos/interfaces/Init.nc"
  inline static error_t RoutC$RandomInit$init(void ){
  #line 51
    unsigned char __nesc_result;
  #line 51
  
  #line 51
    __nesc_result = RandomMlcgC$Init$init();
  #line 51
  
  #line 51
    return __nesc_result;
  #line 51
  }
  #line 51
  # 118 "RoutC.nc"
  static inline void RoutC$Boot$booted(void )
  #line 118
  {
    RoutC$RandomInit$init();
    RoutC$MessageControl$start();
    RoutC$message[sim_node()] = (rout_msg_t *)RoutC$MessagePacket$getPayload(&RoutC$packet[sim_node()], sizeof(rout_msg_t ));
  }
  
  # 49 "/opt/tinyos-2.1.0/tos/interfaces/Boot.nc"
  inline static void SimMainP$Boot$booted(void ){
  #line 49
    RoutC$Boot$booted();
  #line 49
  }
  #line 49
  # 47 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
  static inline long long int SimMoteP$SimMote$getEuid(void )
  #line 47
  {
    return SimMoteP$euid[sim_node()];
  }
  
  #line 50
  static inline void SimMoteP$SimMote$setEuid(long long int e)
  #line 50
  {
    SimMoteP$euid[sim_node()] = e;
  }
  
  
  
  
  
  
  
  static inline int SimMoteP$SimMote$getVariableInfo(char *name, void **addr, size_t *size)
  #line 60
  {
    return __nesc_nido_resolve(sim_node(), name, (uintptr_t *)addr, (size_t *)size);
  }
  
  #line 77
  static inline void SimMoteP$SimMote$turnOff(void )
  #line 77
  {
    SimMoteP$isOn[sim_node()] = FALSE;
  }
  
  #line 149
  static inline void SimMoteP$sim_mote_boot_handle(sim_event_t *e)
  #line 149
  {
    char buf[128];
  
  #line 151
    sim_print_now(buf, 128);
  
    SimMoteP$bootEvent[sim_node()] = (sim_event_t *)(void *)0;
    sim_log_debug(132U, "SimMoteP", "Turning on mote %i at time %s.\n", (int )sim_node(), buf);
    SimMoteP$SimMote$turnOn();
  }
  
  # 38 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.c"
    void sim_queue_init()
  #line 38
  {
    init_heap(&eventHeap);
  }
  
    void sim_queue_insert(sim_event_t *event)
  #line 42
  {
    sim_log_debug(0U, "Queue", "Inserting 0x%p\n", event);
    heap_insert(&eventHeap, event, event->time);
  }
  
  # 238 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  static void sim_log_debug(uint16_t id, char *string, const char *format, ...)
  #line 238
  {
    va_list args;
    int i;
  
  #line 241
    if (outputs[id].files == (void *)0) {
        fillInOutput(id, string);
      }
    for (i = 0; i < outputs[id].num; i++) {
        FILE *file = outputs[id].files[i];
  
  #line 246
        __builtin_va_start(args, format);
        fprintf(file, "DEBUG (%i): ", (int )sim_node());
        vfprintf(file, format, args);
        fflush(file);
      }
  }
  
  #line 76
  static void fillInOutput(int id, char *name)
  #line 76
  {
    char *termination = name;
    char *namePos = name;
    int count = 0;
    char *newName = (char *)malloc(strlen(name) + 1);
  
  #line 81
    memset(newName, 0, strlen(name) + 1);
  
    while (termination != (void *)0) {
        sim_log_channel_t *channel;
  
        termination = strrchr(namePos, ',');
  
        if (termination == (void *)0) {
            strcpy(newName, namePos);
          }
        else 
          {
            memcpy(newName, namePos, termination - namePos);
            newName[termination - namePos] = 0;
          }
  
        channel = hashtable_search(channelTable, namePos);
        if (channel != (void *)0) {
            count += channel->numOutputs;
          }
  
        namePos = termination + 1;
      }
  
    termination = name;
    namePos = name;
  
  
    outputs[id].files = (FILE **)malloc(sizeof(FILE *) * count);
    outputs[id].num = 0;
  
  
    while (termination != (void *)0) {
        sim_log_channel_t *channel;
  
        termination = strrchr(namePos, ',');
  
        if (termination == (void *)0) {
            strcpy(newName, namePos);
          }
        else 
          {
            memcpy(newName, namePos, termination - namePos);
            newName[termination - namePos] = 0;
          }
  
        channel = hashtable_search(channelTable, namePos);
        if (channel != (void *)0) {
            int i;
  #line 129
            int j;
  
  #line 130
            for (i = 0; i < channel->numOutputs; i++) {
                int duplicate = 0;
                int outputCount = outputs[id].num;
  
  
                for (j = 0; j < outputCount; j++) {
                    if (fileno(outputs[id].files[j]) == fileno(channel->outputs[i])) {
                        duplicate = 1;
                        j = outputCount;
                      }
                  }
                if (!duplicate) {
                    outputs[id].files[outputCount] = channel->outputs[i];
                    outputs[id].num++;
                  }
              }
          }
        namePos = termination + 1;
      }
  }
  
  # 113 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.c"
    unsigned long sim_node()
  #line 113
  {
    return current_node;
  }
  
  # 186 "/opt/tinyos-2.1.0/tos/lib/tossim/heap.c"
  static void up_heap(heap_t *heap, int findex)
  #line 186
  {
    int parent_index;
  
  #line 188
    if (findex == 0) {
        return;
      }
  
    parent_index = (findex - 1) / 2;
  
    if (((node_t *)heap->data)[parent_index].key > ((node_t *)heap->data)[findex].key) {
        swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[parent_index]);
        up_heap(heap, parent_index);
      }
  }
  
  #line 147
  static void swap(node_t *first, node_t *second)
  #line 147
  {
    long long int key;
    void *data;
  
    key = first->key;
    first->key = second->key;
    second->key = key;
  
    data = first->data;
    first->data = second->data;
    second->data = data;
  }
  
  # 47 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.c"
    sim_event_t *sim_queue_pop()
  #line 47
  {
    long long int key;
  
  #line 49
    return (sim_event_t *)heap_pop_min_data(&eventHeap, &key);
  }
  
  # 103 "/opt/tinyos-2.1.0/tos/lib/tossim/heap.c"
  static void *heap_pop_min_data(heap_t *heap, long long int *key)
  #line 103
  {
    int last_index = heap->size - 1;
    void *data = ((node_t *)heap->data)[0].data;
  
  #line 106
    if (key != (void *)0) {
        *key = ((node_t *)heap->data)[0].key;
      }
    ((node_t *)heap->data)[0].data = ((node_t *)heap->data)[last_index].data;
    ((node_t *)heap->data)[0].key = ((node_t *)heap->data)[last_index].key;
  
    heap->size--;
  
    down_heap(heap, 0);
  
    return data;
  }
  
  #line 160
  static void down_heap(heap_t *heap, int findex)
  #line 160
  {
    int right_index = (findex + 1) * 2;
    int left_index = findex * 2 + 1;
  
    if (right_index < heap->size) {
        long long int left_key = ((node_t *)heap->data)[left_index].key;
        long long int right_key = ((node_t *)heap->data)[right_index].key;
        int min_key_index = left_key < right_key ? left_index : right_index;
  
        if (((node_t *)heap->data)[min_key_index].key < ((node_t *)heap->data)[findex].key) {
            swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[min_key_index]);
            down_heap(heap, min_key_index);
          }
      }
    else {
  #line 174
      if (left_index >= heap->size) {
          return;
        }
      else {
          long long int left_key = ((node_t *)heap->data)[left_index].key;
  
  #line 179
          if (left_key < ((node_t *)heap->data)[findex].key) {
              swap(&((node_t *)heap->data)[findex], &((node_t *)heap->data)[left_index]);
              return;
            }
        }
      }
  }
  
  # 52 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.c"
    bool sim_queue_is_empty()
  #line 52
  {
    return heap_is_empty(&eventHeap);
  }
  
    long long int sim_queue_peek_time()
  #line 56
  {
    if (heap_is_empty(&eventHeap)) {
        return -1;
      }
    else {
        return heap_get_min_key(&eventHeap);
      }
  }
  
  
    void sim_queue_cleanup_none(sim_event_t *event)
  #line 66
  {
    sim_log_debug(1U, "Queue", "cleanup_none: 0x%p\n", event);
  }
  
  
    void sim_queue_cleanup_event(sim_event_t *event)
  #line 71
  {
    sim_log_debug(2U, "Queue", "cleanup_event: 0x%p\n", event);
    free(event);
  }
  
    void sim_queue_cleanup_data(sim_event_t *event)
  #line 76
  {
    sim_log_debug(3U, "Queue", "cleanup_data: 0x%p\n", event);
    free(event->data);
    event->data = (void *)0;
  }
  
    void sim_queue_cleanup_total(sim_event_t *event)
  #line 82
  {
    sim_log_debug(4U, "Queue", "cleanup_total: 0x%p\n", event);
    free(event->data);
    event->data = (void *)0;
    free(event);
  }
  
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.c"
    void sim_init()
  #line 49
  {
    sim_queue_init();
    sim_log_init();
    sim_log_commit_change();
    sim_noise_init();
  
    {
      struct timeval tv;
  
  #line 57
      gettimeofday(&tv, (void *)0);
  
  
  
  
  
      if (tv.tv_usec != 0) {
          sim_random_seed(tv.tv_usec);
        }
      else {
          sim_random_seed(tv.tv_sec);
        }
    }
  }
  
  # 226 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  static void sim_log_commit_change()
  #line 226
  {
    int i;
  
  #line 228
    for (i = 0; i < SIM_LOG_OUTPUT_COUNT; i++) {
        if (outputs[i].files != (void *)0) {
            outputs[i].num = 0;
            free(outputs[i].files);
            outputs[i].files = (void *)0;
          }
      }
  }
  
  # 59 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
    void sim_noise_init()
  {
    int j;
  
  
  
    for (j = 0; j < 1000; j++) {
        noiseData[j].noiseTable = create_hashtable(NOISE_HASHTABLE_SIZE, sim_noise_hash, sim_noise_eq);
        noiseData[j].noiseGenTime = 0;
        noiseData[j].noiseTrace = (char *)malloc(sizeof(char ) * NOISE_MIN_TRACE);
        noiseData[j].noiseTraceLen = NOISE_MIN_TRACE;
        noiseData[j].noiseTraceIndex = 0;
      }
  }
  
  # 94 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.c"
    void sim_random_seed(int seed)
  #line 94
  {
  
    if (seed == 0) {
        seed = 1;
      }
    sim_seed = seed;
  }
  
  #line 72
    void sim_end()
  #line 72
  {
    sim_queue_init();
  }
  
  
  
    int sim_random()
  #line 78
  {
    uint32_t mlcg;
  #line 79
    uint32_t p;
  #line 79
    uint32_t q;
    uint64_t tmpseed;
  
  #line 81
    tmpseed = (uint64_t )33614U * (uint64_t )sim_seed;
    q = tmpseed;
    q = q >> 1;
    p = tmpseed >> 32;
    mlcg = p + q;
    if (mlcg & 0x80000000) {
        mlcg = mlcg & 0x7FFFFFFF;
        mlcg++;
      }
    sim_seed = mlcg;
    return mlcg;
  }
  
  
  
  
  
  
  
  
  
    sim_time_t sim_time()
  #line 102
  {
    return sim_ticks;
  }
  
  #line 105
    void sim_set_time(sim_time_t t)
  #line 105
  {
    sim_ticks = t;
  }
  
    sim_time_t sim_ticks_per_sec()
  #line 109
  {
    return 10000000000ULL;
  }
  
  
  
  
    void sim_set_node(unsigned long node)
  #line 116
  {
    current_node = node;
    TOS_NODE_ID = node;
  }
  
    bool sim_run_next_event()
  #line 121
  {
    bool result = FALSE;
  
  #line 123
    if (!sim_queue_is_empty()) {
        sim_event_t *event = sim_queue_pop();
  
  #line 125
        sim_set_time(event->time);
        sim_set_node(event->mote);
  
  
  
        sim_log_debug(5U, "Tossim", "CORE: popping event 0x%p for %i at %llu with handler %p... ", event, sim_node(), sim_time(), event->handle);
        if ((sim_mote_is_on(event->mote) || event->force) && 
        event->handle != (void *)0) {
            result = TRUE;
            sim_log_debug_clear(6U, "Tossim", " mote is on (or forced event), run it.\n");
            event->handle(event);
          }
        else {
            sim_log_debug_clear(7U, "Tossim", "\n");
          }
        if (event->cleanup != (void *)0) {
            event->cleanup(event);
          }
      }
  
    return result;
  }
  
  # 126 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
    bool sim_mote_is_on(int mote)
  #line 126
  {
    bool result;
    int tmp = sim_node();
  
  #line 129
    sim_set_node(mote);
    result = SimMoteP$SimMote$isOn();
    sim_set_node(tmp);
    return result;
  }
  
  # 268 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  static void sim_log_debug_clear(uint16_t id, char *string, const char *format, ...)
  #line 268
  {
    va_list args;
    int i;
  
  #line 271
    if (outputs[id].files == (void *)0) {
        fillInOutput(id, string);
      }
    for (i = 0; i < outputs[id].num; i++) {
        FILE *file = outputs[id].files[i];
  
  #line 276
        __builtin_va_start(args, format);
        vfprintf(file, format, args);
        fflush(file);
      }
  }
  
  # 148 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_tossim.c"
    int sim_print_time(char *buf, int len, sim_time_t ftime)
  #line 148
  {
    int hours;
    int minutes;
    int seconds;
    sim_time_t secondBillionths;
  
    secondBillionths = ftime % sim_ticks_per_sec();
    if (sim_ticks_per_sec() > (sim_time_t )1000000000) {
        secondBillionths /= sim_ticks_per_sec() / (sim_time_t )1000000000;
      }
    else {
        secondBillionths *= (sim_time_t )1000000000 / sim_ticks_per_sec();
      }
  
    seconds = (int )(ftime / sim_ticks_per_sec());
    minutes = seconds / 60;
    hours = minutes / 60;
    seconds %= 60;
    minutes %= 60;
    buf[len - 1] = 0;
    return snprintf(buf, len - 1, "%i:%i:%i.%09llu", hours, minutes, seconds, secondBillionths);
  }
  
    int sim_print_now(char *buf, int len)
  #line 171
  {
    return sim_print_time(buf, len, sim_time());
  }
  
  
    char *sim_time_string()
  #line 176
  {
    sim_print_now(simTimeBuf, 128);
    return simTimeBuf;
  }
  
    void sim_add_channel(char *channel, FILE *file)
  #line 181
  {
    sim_log_add_channel(channel, file);
  }
  
    bool sim_remove_channel(char *channel, FILE *file)
  #line 185
  {
    return sim_log_remove_channel(channel, file);
  }
  
  # 49 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_csma.c"
    int sim_csma_init_high()
  #line 49
  {
    return csmaInitHigh;
  }
  
  #line 52
    int sim_csma_init_low()
  #line 52
  {
    return csmaInitLow;
  }
  
  #line 55
    int sim_csma_high()
  #line 55
  {
    return csmaHigh;
  }
  
  #line 58
    int sim_csma_low()
  #line 58
  {
    return csmaLow;
  }
  
  #line 61
    int sim_csma_symbols_per_sec()
  #line 61
  {
    return csmaSymbolsPerSec;
  }
  
  #line 64
    int sim_csma_bits_per_symbol()
  #line 64
  {
    return csmaBitsPerSymbol;
  }
  
  #line 67
    int sim_csma_preamble_length()
  #line 67
  {
    return csmaPreambleLength;
  }
  
  #line 70
    int sim_csma_exponent_base()
  #line 70
  {
    return csmaExponentBase;
  #line 71
    ;
  }
  
  #line 73
    int sim_csma_max_iterations()
  #line 73
  {
    return csmaMaxIterations;
  }
  
  #line 76
    int sim_csma_min_free_samples()
  #line 76
  {
    return csmaMinFreeSamples;
  }
  
  #line 79
    int sim_csma_rxtx_delay()
  #line 79
  {
    return csmaRxTxDelay;
  }
  
  #line 82
    int sim_csma_ack_time()
  #line 82
  {
    return csmaAckTime;
  }
  
  
  
    void sim_csma_set_init_high(int val)
  #line 88
  {
    csmaInitHigh = val;
  }
  
  #line 91
    void sim_csma_set_init_low(int val)
  #line 91
  {
    csmaInitLow = val;
  }
  
  #line 94
    void sim_csma_set_high(int val)
  #line 94
  {
    csmaHigh = val;
  }
  
  #line 97
    void sim_csma_set_low(int val)
  #line 97
  {
    csmaLow = val;
  }
  
  #line 100
    void sim_csma_set_symbols_per_sec(int val)
  #line 100
  {
    csmaSymbolsPerSec = val;
  }
  
  #line 103
    void sim_csma_set_bits_per_symbol(int val)
  #line 103
  {
    csmaBitsPerSymbol = val;
  }
  
  #line 106
    void sim_csma_set_preamble_length(int val)
  #line 106
  {
    csmaPreambleLength = val;
  }
  
  #line 109
    void sim_csma_set_exponent_base(int val)
  #line 109
  {
    csmaExponentBase = val;
  }
  
  #line 112
    void sim_csma_set_max_iterations(int val)
  #line 112
  {
    csmaMaxIterations = val;
  }
  
  #line 115
    void sim_csma_set_min_free_samples(int val)
  #line 115
  {
    csmaMinFreeSamples = val;
  }
  
  #line 118
    void sim_csma_set_rxtx_delay(int val)
  #line 118
  {
    csmaRxTxDelay = val;
  }
  
  #line 121
    void sim_csma_set_ack_time(int val)
  #line 121
  {
    csmaAckTime = val;
  }
  
  # 16 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_gain.c"
    gain_entry_t *sim_gain_first(int src)
  #line 16
  {
    if (src > 1000) {
        return connectivity[1000];
      }
    return connectivity[src];
  }
  
    gain_entry_t *sim_gain_next(gain_entry_t *currentLink)
  #line 23
  {
    return currentLink->next;
  }
  
    void sim_gain_add(int src, int dest, double gain)
  #line 27
  {
    gain_entry_t *current;
    int temp = sim_node();
  
  #line 30
    if (src > 1000) {
        src = 1000;
      }
    sim_set_node(src);
  
    current = sim_gain_first(src);
    while (current != (void *)0) {
        if (current->mote == dest) {
            sim_set_node(temp);
            break;
          }
        current = current->next;
      }
  
    if (current == (void *)0) {
        current = sim_gain_allocate_link(dest);
        current->next = connectivity[src];
        connectivity[src] = current;
      }
    current->mote = dest;
    current->gain = gain;
    sim_log_debug(8U, "Gain", "Adding link from %i to %i with gain %f\n", src, dest, gain);
    sim_set_node(temp);
  }
  
    double sim_gain_value(int src, int dest)
  #line 55
  {
    gain_entry_t *current;
    int temp = sim_node();
  
  #line 58
    sim_set_node(src);
    current = sim_gain_first(src);
    while (current != (void *)0) {
        if (current->mote == dest) {
            sim_set_node(temp);
            sim_log_debug(9U, "Gain", "Getting link from %i to %i with gain %f\n", src, dest, current->gain);
            return current->gain;
          }
        current = current->next;
      }
    sim_set_node(temp);
    sim_log_debug(10U, "Gain", "Getting default link from %i to %i with gain %f\n", src, dest, 1.0);
    return 1.0;
  }
  
    bool sim_gain_connected(int src, int dest)
  #line 73
  {
    gain_entry_t *current;
    int temp = sim_node();
  
  #line 76
    sim_set_node(src);
    current = sim_gain_first(src);
    while (current != (void *)0) {
        if (current->mote == dest) {
            sim_set_node(temp);
            return TRUE;
          }
        current = current->next;
      }
    sim_set_node(temp);
    return FALSE;
  }
  
    void sim_gain_remove(int src, int dest)
  #line 89
  {
    gain_entry_t *current;
    gain_entry_t *prevLink;
    int temp = sim_node();
  
    if (src > 1000) {
        src = 1000;
      }
  
    sim_set_node(src);
  
    current = sim_gain_first(src);
    prevLink = (void *)0;
  
    while (current != (void *)0) {
        gain_entry_t *tmp;
  
  #line 105
        if (current->mote == dest) {
            if (prevLink == (void *)0) {
                connectivity[src] = current->next;
              }
            else {
                prevLink->next = current->next;
              }
            tmp = current->next;
            sim_gain_deallocate_link(current);
            current = tmp;
          }
        else {
            prevLink = current;
            current = current->next;
          }
      }
    sim_set_node(temp);
  }
  
  #line 169
    void sim_gain_deallocate_link(gain_entry_t *linkToDelete)
  #line 169
  {
    free(linkToDelete);
  }
  
  #line 124
    void sim_gain_set_noise_floor(int node, double mean, double range)
  #line 124
  {
    if (node > 1000) {
        node = 1000;
      }
    localNoise[node].mean = mean;
    localNoise[node].range = range;
  }
  
  #line 148
    double sim_gain_sample_noise(int node)
  #line 148
  {
    double val;
  #line 149
    double adjust;
  
  #line 150
    if (node > 1000) {
        node = 1000;
      }
    val = localNoise[node].mean;
    adjust = sim_random() % 2000000;
    adjust /= 1000000.0;
    adjust -= 1.0;
    adjust *= localNoise[node].range;
    return val + adjust;
  }
  
  #line 173
    void sim_gain_set_sensitivity(double s)
  #line 173
  {
    sensitivity = s;
  }
  
    double sim_gain_sensitivity()
  #line 177
  {
    return sensitivity;
  }
  
  # 76 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
    void sim_noise_create_model(uint16_t node_id)
  #line 76
  {
    makeNoiseModel(node_id);
    makePmfDistr(node_id);
  }
  
  #line 411
    void makeNoiseModel(uint16_t node_id)
  #line 411
  {
    int i;
  
  #line 413
    for (i = 0; i < NOISE_HISTORY; i++) {
        noiseData[node_id].key[i] = search_bin_num(noiseData[node_id].noiseTrace[i]);
        sim_log_debug(44U, "Insert", "Setting history %i to be %i\n", (int )i, (int )noiseData[node_id].key[i]);
      }
  
  
  
  
    for (i = NOISE_HISTORY; i < noiseData[node_id].noiseTraceIndex; i++) {
        sim_noise_add(node_id, noiseData[node_id].noiseTrace[i]);
        arrangeKey(node_id);
        noiseData[node_id].key[NOISE_HISTORY - 1] = search_bin_num(noiseData[node_id].noiseTrace[i]);
      }
    noiseData[node_id].generated = 1;
  }
  
  #line 105
    uint8_t search_bin_num(char noise)
  {
    uint8_t bin;
  
  #line 108
    if (noise > NOISE_MAX || noise < NOISE_MIN) {
        noise = NOISE_MIN;
      }
    bin = (noise - NOISE_MIN) / NOISE_QUANTIZE_INTERVAL + 1;
    return bin;
  }
  
  #line 136
    void sim_noise_add(uint16_t node_id, char noise)
  {
    int i;
    struct hashtable *pnoiseTable = noiseData[node_id].noiseTable;
    char *key = noiseData[node_id].key;
    sim_noise_hash_t *noise_hash;
  
  #line 142
    noise_hash = (sim_noise_hash_t *)hashtable_search(pnoiseTable, key);
    sim_log_debug(13U, "Insert", "Adding noise value %hhi\n", noise);
    if (noise_hash == (void *)0) {
        noise_hash = (sim_noise_hash_t *)malloc(sizeof(sim_noise_hash_t ));
        memcpy((void *)noise_hash->key, (void *)key, NOISE_HISTORY);
  
        noise_hash->numElements = 0;
        noise_hash->size = NOISE_DEFAULT_ELEMENT_SIZE;
        noise_hash->elements = (char *)malloc(sizeof(char ) * noise_hash->size);
        memset((void *)noise_hash->elements, 0, sizeof(char ) * noise_hash->size);
  
        noise_hash->flag = 0;
        for (i = 0; i < NOISE_NUM_VALUES; i++) {
            noise_hash->dist[i] = 0;
          }
        hashtable_insert(pnoiseTable, key, noise_hash);
        sim_log_debug(14U, "Insert", "Inserting %p into table %p with key ", noise_hash, pnoiseTable);
        {
          int ctr;
  
  #line 161
          for (ctr = 0; ctr < NOISE_HISTORY; ctr++) 
            sim_log_debug_clear(15U, "Insert", "%0.3hhi ", key[ctr]);
        }
        sim_log_debug_clear(16U, "Insert", "\n");
      }
  
    if (noise_hash->numElements == noise_hash->size) 
      {
        char *newElements;
        int newSize = noise_hash->size * 2;
  
        newElements = (char *)malloc(sizeof(char ) * newSize);
        memcpy(newElements, noise_hash->elements, noise_hash->size);
        free(noise_hash->elements);
        noise_hash->elements = newElements;
        noise_hash->size = newSize;
      }
  
    noise_hash->elements[noise_hash->numElements] = noise;
  
    noise_hash->numElements++;
  }
  
  #line 237
    void arrangeKey(uint16_t node_id)
  {
    char *pKey = noiseData[node_id].key;
  
  #line 240
    memcpy(pKey, pKey + 1, NOISE_HISTORY - 1);
  }
  
  
  
  
  
    void makePmfDistr(uint16_t node_id)
  {
    int i;
    char *pKey = noiseData[node_id].key;
    char *fKey = noiseData[node_id].freqKey;
  
    FreqKeyNum = 0;
    for (i = 0; i < NOISE_HISTORY; i++) {
        pKey[i] = search_bin_num(noiseData[node_id].noiseTrace[i]);
      }
  
    for (i = NOISE_HISTORY; i < noiseData[node_id].noiseTraceIndex; i++) {
        if (i == NOISE_HISTORY) {
          }
  
        sim_noise_dist(node_id);
        arrangeKey(node_id);
        pKey[NOISE_HISTORY - 1] = search_bin_num(noiseData[node_id].noiseTrace[i]);
      }
  
    sim_log_debug_clear(21U, "HASH", "FreqKey = ");
    for (i = 0; i < NOISE_HISTORY; i++) 
      {
        sim_log_debug_clear(22U, "HASH", "%d,", fKey[i]);
      }
    sim_log_debug_clear(23U, "HASH", "\n");
  }
  
  #line 184
    void sim_noise_dist(uint16_t node_id)
  {
    int i;
    uint8_t bin;
    float cmf = 0;
    struct hashtable *pnoiseTable = noiseData[node_id].noiseTable;
    char *key = noiseData[node_id].key;
    char *freqKey = noiseData[node_id].freqKey;
    sim_noise_hash_t *noise_hash;
  
  #line 193
    noise_hash = (sim_noise_hash_t *)hashtable_search(pnoiseTable, key);
  
  
  
    if (noise_hash->flag == 1) {
      return;
      }
    for (i = 0; i < NOISE_NUM_VALUES; i++) {
        noise_hash->dist[i] = 0.0;
      }
  
    for (i = 0; i < noise_hash->numElements; i++) 
      {
        float val;
  
  #line 207
        sim_log_debug(17U, "Noise_output", "Noise is found to be %i\n", noise_hash->elements[i]);
        bin = noise_hash->elements[i] - NOISE_MIN_QUANTIZE;
  
        val = noise_hash->dist[bin];
        val += (float )1.0;
        noise_hash->dist[bin] = val;
      }
  
    for (i = 0; i < NOISE_NUM_VALUES; i++) 
      {
        noise_hash->dist[i] = noise_hash->dist[i] / noise_hash->numElements;
        cmf += noise_hash->dist[i];
        noise_hash->dist[i] = cmf;
      }
    noise_hash->flag = 1;
  
  
    if (noise_hash->numElements > FreqKeyNum) 
      {
        int j;
  
  #line 227
        FreqKeyNum = noise_hash->numElements;
        memcpy((void *)freqKey, (void *)key, NOISE_HISTORY);
        sim_log_debug(18U, "HashZeroDebug", "Setting most frequent key (%i): ", (int )FreqKeyNum);
        for (j = 0; j < NOISE_HISTORY; j++) {
            sim_log_debug_clear(19U, "HashZeroDebug", "[%hhu] ", key[j]);
          }
        sim_log_debug_clear(20U, "HashZeroDebug", "\n");
      }
  }
  
  #line 89
    void sim_noise_trace_add(uint16_t node_id, char noiseVal)
  #line 89
  {
  
    if (noiseData[node_id].noiseTraceIndex == 
    noiseData[node_id].noiseTraceLen) {
        char *data = (char *)malloc(sizeof(char ) * noiseData[node_id].noiseTraceLen * 2);
  
  #line 94
        memcpy(data, noiseData[node_id].noiseTrace, noiseData[node_id].noiseTraceLen);
        free(noiseData[node_id].noiseTrace);
        noiseData[node_id].noiseTraceLen *= 2;
        noiseData[node_id].noiseTrace = data;
      }
    noiseData[node_id].noiseTrace[noiseData[node_id].noiseTraceIndex] = noiseVal;
    noiseData[node_id].noiseTraceIndex++;
    sim_log_debug(12U, "Insert", "Adding noise value %i for %i of %i\n", (int )noiseData[node_id].noiseTraceIndex, (int )node_id, (int )noiseVal);
  }
  
  #line 115
    char search_noise_from_bin_num(int i)
  {
    char noise;
  
  #line 118
    noise = NOISE_MIN + (i - 1) * NOISE_QUANTIZE_INTERVAL;
    return noise;
  }
  
  #line 280
    char sim_noise_gen(uint16_t node_id)
  {
    int i;
    int noiseIndex = 0;
    char noise;
    struct hashtable *pnoiseTable = noiseData[node_id].noiseTable;
    char *pKey = noiseData[node_id].key;
    char *fKey = noiseData[node_id].freqKey;
    double ranNum = RandomUniform();
    sim_noise_hash_t *noise_hash;
  
  #line 290
    noise_hash = (sim_noise_hash_t *)hashtable_search(pnoiseTable, pKey);
  
    if (noise_hash == (void *)0) {
  
        sim_log_debug(24U, "Noise_c", "Did not pattern match");
  
        sim_noise_alarm();
        noise = 0;
        sim_log_debug_clear(25U, "HASH", "(N)Noise\n");
        sim_log_debug(26U, "HashZeroDebug", "Defaulting to common hash.\n");
        memcpy((void *)pKey, (void *)fKey, NOISE_HISTORY);
        noise_hash = (sim_noise_hash_t *)hashtable_search(pnoiseTable, pKey);
      }
  
    sim_log_debug_clear(27U, "HASH", "Key = ");
    for (i = 0; i < NOISE_HISTORY; i++) {
        sim_log_debug_clear(28U, "HASH", "%d,", pKey[i]);
      }
    sim_log_debug_clear(29U, "HASH", "\n");
  
    sim_log_debug(30U, "HASH", "Printing Key\n");
    sim_log_debug(31U, "HASH", "noise_hash->numElements=%d\n", noise_hash->numElements);
  
  
    numTotal++;
  
  
    if (noise_hash->numElements == 1) {
        noise = noise_hash->elements[0];
        sim_log_debug_clear(32U, "HASH", "(E)Noise = %d\n", noise);
  
        numCase1++;
        sim_log_debug(33U, "Noise_c", "In case 1: %i of %i\n", numCase1, numTotal);
  
        sim_log_debug(34U, "NoiseAudit", "Noise: %i\n", noise);
        return noise;
      }
  
  
    numCase2++;
    sim_log_debug(35U, "Noise_c", "In case 2: %i of %i\n", numCase2, numTotal);
  
  
    for (i = 0; i < NOISE_NUM_VALUES - 1; i++) {
        sim_log_debug(36U, "HASH", "IN:for i=%d\n", i);
        if (i == 0) {
            if (ranNum <= noise_hash->dist[i]) {
                noiseIndex = i;
                sim_log_debug_clear(37U, "HASH", "Selected Bin = %d -> ", i + 1);
                break;
              }
          }
        else {
  #line 342
          if (noise_hash->dist[i - 1] < ranNum && 
          ranNum <= noise_hash->dist[i]) {
              noiseIndex = i;
              sim_log_debug_clear(38U, "HASH", "Selected Bin = %d -> ", i + 1);
              break;
            }
          }
      }
  #line 349
    sim_log_debug(39U, "HASH", "OUT:for i=%d\n", i);
  
    noise = NOISE_MIN_QUANTIZE + i;
    sim_log_debug(40U, "NoiseAudit", "Noise: %i\n", noise);
    return noise;
  }
  
  # 103 "/opt/tinyos-2.1.0/tos/lib/tossim/randomlib.c"
  static double RandomUniform(void )
  {
    double uni;
    int seed1;
  #line 106
    int seed2;
  
  
    if (!test) 
      {
  
  
  
        seed1 = sim_random() % 31329;
        seed2 = sim_random() % 30082;
        RandomInitialise(seed1, seed2);
      }
  
    uni = randU[i97 - 1] - randU[j97 - 1];
    if (uni <= 0.0) {
      uni++;
      }
  #line 122
    randU[i97 - 1] = uni;
    i97--;
    if (i97 == 0) {
      i97 = 97;
      }
  #line 126
    j97--;
    if (j97 == 0) {
      j97 = 97;
      }
  #line 129
    randC -= randCD;
    if (randC < 0.0) {
      randC += randCM;
      }
  #line 132
    uni -= randC;
    if (uni < 0.0) {
      uni++;
      }
    return uni;
  }
  
  # 356 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_noise.c"
    char sim_noise_generate(uint16_t node_id, uint32_t cur_t)
  #line 356
  {
    uint32_t i;
    uint32_t prev_t;
    uint32_t delta_t;
    char *noiseG;
    char noise;
  
    prev_t = noiseData[node_id].noiseGenTime;
  
    if (noiseData[node_id].generated == 0) {
        sim_log_error(41U, "TOSSIM", "Tried to generate noise from an uninitialized radio model of node %hu.\n", node_id);
        return 127;
      }
  
    if (0 <= cur_t && cur_t < NOISE_HISTORY) {
        noiseData[node_id].noiseGenTime = cur_t;
        noiseData[node_id].key[cur_t] = search_bin_num(noiseData[node_id].noiseTrace[cur_t]);
        noiseData[node_id].lastNoiseVal = noiseData[node_id].noiseTrace[cur_t];
        return noiseData[node_id].noiseTrace[cur_t];
      }
  
    if (prev_t == 0) {
      delta_t = cur_t - (NOISE_HISTORY - 1);
      }
    else {
  #line 380
      delta_t = cur_t - prev_t;
      }
    sim_log_debug_clear(42U, "HASH", "delta_t = %d\n", delta_t);
  
    if (delta_t == 0) {
      noise = noiseData[node_id].lastNoiseVal;
      }
    else 
  #line 386
      {
        noiseG = (char *)malloc(sizeof(char ) * delta_t);
  
        for (i = 0; i < delta_t; i++) {
            noiseG[i] = sim_noise_gen(node_id);
            arrangeKey(node_id);
            noiseData[node_id].key[NOISE_HISTORY - 1] = search_bin_num(noiseG[i]);
          }
        noise = noiseG[delta_t - 1];
        noiseData[node_id].lastNoiseVal = noise;
  
        free(noiseG);
      }
    noiseData[node_id].noiseGenTime = cur_t;
    if (noise == 0) {
        sim_log_debug(43U, "HashZeroDebug", "Generated noise of zero.\n");
      }
  
    return noise;
  }
  
  # 253 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_log.c"
  static void sim_log_error(uint16_t id, char *string, const char *format, ...)
  #line 253
  {
    va_list args;
    int i;
  
  #line 256
    if (outputs[id].files == (void *)0) {
        fillInOutput(id, string);
      }
    for (i = 0; i < outputs[id].num; i++) {
        FILE *file = outputs[id].files[i];
  
  #line 261
        __builtin_va_start(args, format);
        fprintf(file, "ERROR (%i): ", (int )sim_node());
        vfprintf(file, format, args);
        fflush(file);
      }
  }
  
  # 46 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_packet.c"
    void sim_packet_set_source(sim_packet_t *msg, uint16_t src)
  #line 46
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 48
    __nesc_hton_uint16(hdr->src.nxdata, src);
  }
  
    uint16_t sim_packet_source(sim_packet_t *msg)
  #line 51
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 53
    return __nesc_ntoh_uint16(hdr->src.nxdata);
  }
  
    void sim_packet_set_destination(sim_packet_t *msg, uint16_t dest)
  #line 56
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 58
    __nesc_hton_uint16(hdr->dest.nxdata, dest);
  }
  
    uint16_t sim_packet_destination(sim_packet_t *msg)
  #line 61
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 63
    return __nesc_ntoh_uint16(hdr->dest.nxdata);
  }
  
    void sim_packet_set_length(sim_packet_t *msg, uint8_t length)
  #line 66
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 68
    __nesc_hton_uint8(hdr->length.nxdata, length);
  }
  
  #line 70
    uint16_t sim_packet_length(sim_packet_t *msg)
  #line 70
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 72
    return __nesc_ntoh_uint8(hdr->length.nxdata);
  }
  
    void sim_packet_set_type(sim_packet_t *msg, uint8_t type)
  #line 75
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 77
    __nesc_hton_uint8(hdr->type.nxdata, type);
  }
  
    uint8_t sim_packet_type(sim_packet_t *msg)
  #line 80
  {
    tossim_header_t *hdr = getHeader((message_t *)msg);
  
  #line 82
    return __nesc_ntoh_uint8(hdr->type.nxdata);
  }
  
    uint8_t *sim_packet_data(sim_packet_t *p)
  #line 85
  {
    message_t *msg = (message_t *)p;
  
  #line 87
    return (uint8_t *)& msg->data;
  }
  
  #line 89
    void sim_packet_set_strength(sim_packet_t *p, uint16_t str)
  #line 89
  {
    message_t *msg = (message_t *)p;
    tossim_metadata_t *md = (tossim_metadata_t *)& msg->metadata;
  
  #line 92
    __nesc_hton_int8(md->strength.nxdata, str);
  }
  
  #line 94
    void sim_packet_deliver(int node, sim_packet_t *msg, sim_time_t t)
  #line 94
  {
    if (t < sim_time()) {
        t = sim_time();
      }
    sim_log_debug(45U, "Packet", "sim_packet.c: Delivering packet %p to %i at %llu\n", msg, node, t);
    active_message_deliver(node, (message_t *)msg, t);
  }
  
  # 246 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
    void active_message_deliver(int node, message_t *msg, sim_time_t t)
  #line 246
  {
    sim_event_t *evt = TossimActiveMessageC$allocate_deliver_event(node, msg, t);
  
  #line 248
    sim_queue_insert(evt);
  }
  
  #line 101
  static void TossimActiveMessageC$Model$receive(message_t *msg)
  #line 101
  {
    uint8_t len;
    void *payload;
  
    memcpy(TossimActiveMessageC$bufferPointer[sim_node()], msg, sizeof(message_t ));
    len = TossimActiveMessageC$Packet$payloadLength(TossimActiveMessageC$bufferPointer[sim_node()]);
    payload = TossimActiveMessageC$Packet$getPayload(TossimActiveMessageC$bufferPointer[sim_node()], TossimActiveMessageC$Packet$maxPayloadLength());
  
    if (TossimActiveMessageC$AMPacket$isForMe(msg)) {
        sim_log_debug(134U, "AM", "Received active message (%p) of type %hhu and length %hhu for me @ %s.\n", TossimActiveMessageC$bufferPointer[sim_node()], TossimActiveMessageC$AMPacket$type(TossimActiveMessageC$bufferPointer[sim_node()]), len, sim_time_string());
        TossimActiveMessageC$bufferPointer[sim_node()] = TossimActiveMessageC$Receive$receive(TossimActiveMessageC$AMPacket$type(TossimActiveMessageC$bufferPointer[sim_node()]), TossimActiveMessageC$bufferPointer[sim_node()], payload, len);
      }
    else {
        sim_log_debug(135U, "AM", "Snooped on active message of type %hhu and length %hhu for %hu @ %s.\n", TossimActiveMessageC$AMPacket$type(TossimActiveMessageC$bufferPointer[sim_node()]), len, TossimActiveMessageC$AMPacket$destination(TossimActiveMessageC$bufferPointer[sim_node()]), sim_time_string());
        TossimActiveMessageC$bufferPointer[sim_node()] = TossimActiveMessageC$Snoop$receive(TossimActiveMessageC$AMPacket$type(TossimActiveMessageC$bufferPointer[sim_node()]), TossimActiveMessageC$bufferPointer[sim_node()], payload, len);
      }
  }
  
  #line 132
  static am_addr_t TossimActiveMessageC$AMPacket$destination(message_t *amsg)
  #line 132
  {
    tossim_header_t *header = TossimActiveMessageC$getHeader(amsg);
  
  #line 134
    return __nesc_ntoh_uint16(header->dest.nxdata);
  }
  
  # 53 "/opt/tinyos-2.1.0/tos/lib/tossim/ActiveMessageAddressC.nc"
  static am_addr_t ActiveMessageAddressC$amAddress(void )
  #line 53
  {
    if (!ActiveMessageAddressC$set[sim_node()]) {
        ActiveMessageAddressC$addr[sim_node()] = TOS_NODE_ID;
        ActiveMessageAddressC$set[sim_node()] = TRUE;
      }
    return ActiveMessageAddressC$addr[sim_node()];
  }
  
  # 157 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static am_id_t TossimActiveMessageC$AMPacket$type(message_t *amsg)
  #line 157
  {
    tossim_header_t *header = TossimActiveMessageC$getHeader(amsg);
  
  #line 159
    return __nesc_ntoh_uint8(header->type.nxdata);
  }
  
  # 75 "RoutC.nc"
  static int16_t RoutC$distanceBetween(int16_t aid, uint16_t bid)
  #line 75
  {
    int16_t ax = aid % 4;
    int16_t ay = aid / 4;
    int16_t bx = bid % 4;
    int16_t by = bid / 4;
  
  #line 80
    return RoutC$distanceBetweenXY(ax, ay, bx, by);
  }
  
  #line 172
  static uint16_t RoutC$batteryRequiredForSend(am_addr_t receiver)
  #line 172
  {
    if (receiver == AM_BROADCAST_ADDR) {
        return 5;
      }
    else 
  #line 175
      {
        return RoutC$distanceBetween(TOS_NODE_ID, receiver);
      }
  }
  
  # 97 "/opt/tinyos-2.1.0/tos/system/QueueC.nc"
  static error_t /*RoutAppC.Queue*/QueueC$0$Queue$enqueue(/*RoutAppC.Queue*/QueueC$0$queue_t newVal)
  #line 97
  {
    if (/*RoutAppC.Queue*/QueueC$0$Queue$size() < /*RoutAppC.Queue*/QueueC$0$Queue$maxSize()) {
        sim_log_debug(171U, "QueueC", "%s: size is %hhu\n", __FUNCTION__, /*RoutAppC.Queue*/QueueC$0$size[sim_node()]);
        /*RoutAppC.Queue*/QueueC$0$queue[sim_node()][/*RoutAppC.Queue*/QueueC$0$tail[sim_node()]] = newVal;
        /*RoutAppC.Queue*/QueueC$0$tail[sim_node()]++;
        if (/*RoutAppC.Queue*/QueueC$0$tail[sim_node()] == 100) {
  #line 102
          /*RoutAppC.Queue*/QueueC$0$tail[sim_node()] = 0;
          }
  #line 103
        /*RoutAppC.Queue*/QueueC$0$size[sim_node()]++;
        /*RoutAppC.Queue*/QueueC$0$printQueue();
        return SUCCESS;
      }
    else {
        return FAIL;
      }
  }
  
  #line 69
  static void /*RoutAppC.Queue*/QueueC$0$printQueue(void )
  #line 69
  {
  
    int i;
  #line 71
    int j;
  
  #line 72
    sim_log_debug(165U, "QueueC", "head <-");
    for (i = /*RoutAppC.Queue*/QueueC$0$head[sim_node()]; i < /*RoutAppC.Queue*/QueueC$0$head[sim_node()] + /*RoutAppC.Queue*/QueueC$0$size[sim_node()]; i++) {
        sim_log_debug_clear(166U, "QueueC", "[");
        for (j = 0; j < sizeof(/*RoutAppC.Queue*/QueueC$0$queue_t ); j++) {
            uint8_t v = ((uint8_t *)&/*RoutAppC.Queue*/QueueC$0$queue[sim_node()][i % 100])[j];
  
  #line 77
            sim_log_debug_clear(167U, "QueueC", "%0.2hhx", v);
          }
        sim_log_debug_clear(168U, "QueueC", "] ");
      }
    sim_log_debug_clear(169U, "QueueC", "<- tail\n");
  }
  
  # 217 "RoutC.nc"
  static void RoutC$rout(void )
  #line 217
  {
    if (RoutC$RouterQueue$empty()) {
        sim_log_debug(54U, "RoutDetail", "Rout: Rout called with empty queue\n");
      }
    else {
  #line 220
      if (RoutC$locked[sim_node()]) {
          sim_log_debug(55U, "RoutDetail", "Rout: Message is locked.\n");
        }
      else {
  #line 222
        if (RoutC$batteryEmpty()) {
            sim_log_debug(56U, "RoutDetail", "Rout: Battery is empty.\n");
          }
        else 
  #line 224
          {
            am_addr_t receiver;
            bool send = FALSE;
            rout_msg_t m = RoutC$RouterQueue$head();
            uint8_t type = __nesc_ntoh_uint8(m.type.nxdata);
  
  #line 229
            sim_log_debug(57U, "RoutDetail", "Rout: Message will be sent.\n");
            switch (type) {
                case 11: 
                  receiver = AM_BROADCAST_ADDR;
                send = TRUE;
                break;
                case 12: 
                  if (RoutC$router[sim_node()] == -1) {
                      sim_log_debug(58U, "RoutDetail", "Rout: No router.\n");
                      if (!RoutC$routerlessreported[sim_node()]) {
                          sim_log_debug(59U, "Rout", "Rout: No router to send to\n");
                          RoutC$routerlessreported[sim_node()] = TRUE;
                        }
                    }
                  else {
  
                      if (__nesc_ntoh_uint16(m.content.nxdata) == 1 && RoutC$clusterHead[sim_node()] != -1) {
                          receiver = RoutC$clusterHead[sim_node()];
                          send = TRUE;
                        }
                      else {
                          receiver = RoutC$router[sim_node()];
                          send = TRUE;
                        }
                    }
                break;
                default: 
                  sim_log_debug(60U, "Error", "ERROR: Unknown message type %d\n", type);
              }
            if (send) {
                *RoutC$message[sim_node()] = RoutC$RouterQueue$dequeue();
                RoutC$sendMessage(receiver);
              }
          }
        }
      }
  }
  
  # 85 "/opt/tinyos-2.1.0/tos/system/QueueC.nc"
  static /*RoutAppC.Queue*/QueueC$0$queue_t /*RoutAppC.Queue*/QueueC$0$Queue$dequeue(void )
  #line 85
  {
    /*RoutAppC.Queue*/QueueC$0$queue_t t = /*RoutAppC.Queue*/QueueC$0$Queue$head();
  
  #line 87
    sim_log_debug(170U, "QueueC", "%s: size is %hhu\n", __FUNCTION__, /*RoutAppC.Queue*/QueueC$0$size[sim_node()]);
    if (!/*RoutAppC.Queue*/QueueC$0$Queue$empty()) {
        /*RoutAppC.Queue*/QueueC$0$head[sim_node()]++;
        if (/*RoutAppC.Queue*/QueueC$0$head[sim_node()] == 100) {
  #line 90
          /*RoutAppC.Queue*/QueueC$0$head[sim_node()] = 0;
          }
  #line 91
        /*RoutAppC.Queue*/QueueC$0$size[sim_node()]--;
        /*RoutAppC.Queue*/QueueC$0$printQueue();
      }
    return t;
  }
  
  # 145 "RoutC.nc"
  static void RoutC$batteryCheck(void )
  #line 145
  {
    if (RoutC$batteryEmpty()) {
        sim_log_debug(47U, "Battery", "Battery: Node ran out of battery\n");
        RoutC$stopnode();
      }
  }
  
  # 65 "/opt/tinyos-2.1.0/tos/lib/tossim/TossimActiveMessageC.nc"
  static error_t TossimActiveMessageC$AMSend$send(am_id_t id, am_addr_t addr, 
  message_t *amsg, 
  uint8_t len)
  #line 67
  {
    error_t err;
    tossim_header_t *header = TossimActiveMessageC$getHeader(amsg);
  
  #line 70
    sim_log_debug(133U, "AM", "AM: Sending packet (id=%hhu, len=%hhu) to %hu\n", id, len, addr);
    __nesc_hton_uint8(header->type.nxdata, id);
    __nesc_hton_uint16(header->dest.nxdata, addr);
    __nesc_hton_uint16(header->src.nxdata, TossimActiveMessageC$AMPacket$address());
    __nesc_hton_uint8(header->length.nxdata, len);
    err = TossimActiveMessageC$Model$send((int )addr, amsg, len + sizeof(tossim_header_t ));
    return err;
  }
  
  # 263 "CpmModelC.nc"
  static double CpmModelC$packetNoise(CpmModelC$receive_message_t *msg)
  #line 263
  {
    double noise = CpmModelC$noise_hash_generation();
    CpmModelC$receive_message_t *list = CpmModelC$outstandingReceptionHead[sim_node()];
  
  #line 266
    noise = pow(10.0, noise / 10.0);
    while (list != (void *)0) {
        if (list != msg) {
            noise += pow(10.0, list->power / 10.0);
          }
        list = list->next;
      }
    noise = 10.0 * log(noise) / log(10.0);
    return noise;
  }
  
  # 181 "/opt/tinyos-2.1.0/tos/system/AMQueueImplP.nc"
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$sendDone(am_id_t id, message_t *msg, error_t err)
  #line 181
  {
  
  
  
  
  
    if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] >= 1) {
        return;
      }
    if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()]].msg == msg) {
        /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$sendDone(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()], msg, err);
      }
    else {
        sim_log_debug(211U, "PointerBug", "%s received send done for %p, signaling for %p.\n", __FUNCTION__, msg, /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()]].msg);
      }
  }
  
  #line 166
  static void /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$tryToSend(void )
  #line 166
  {
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$nextPacket();
    if (/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()] < 1) {
        error_t nextErr;
        message_t *nextMsg = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[sim_node()][/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[sim_node()]].msg;
        am_id_t nextId = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$type(nextMsg);
        am_addr_t nextDest = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMPacket$destination(nextMsg);
        uint8_t len = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$Packet$payloadLength(nextMsg);
  
  #line 174
        nextErr = /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$AMSend$send(nextId, nextDest, nextMsg, len);
        if (nextErr != SUCCESS) {
            /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$errorTask$postTask();
          }
      }
  }
  
  # 197 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static error_t SimSchedulerBasicP$TaskBasic$postTask(uint8_t id)
  {
    error_t result;
  
  #line 200
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  #line 200
      {
        result = SimSchedulerBasicP$pushTask(id) ? SUCCESS : EBUSY;
      }
  #line 202
      __nesc_atomic_end(__nesc_atomic); }
    if (result == SUCCESS) {
        sim_log_debug(127U, "Scheduler", "Posting task %hhu.\n", id);
        SimSchedulerBasicP$sim_scheduler_submit_event();
      }
    else {
        sim_log_debug(128U, "Scheduler", "Posting task %hhu, but already posted.\n", id);
      }
    return result;
  }
  
  #line 69
  static void SimSchedulerBasicP$sim_scheduler_submit_event(void )
  #line 69
  {
    if (SimSchedulerBasicP$sim_scheduler_event_pending[sim_node()] == FALSE) {
        SimSchedulerBasicP$sim_scheduler_event[sim_node()].time = sim_time() + SimSchedulerBasicP$sim_config_task_latency();
        sim_queue_insert(&SimSchedulerBasicP$sim_scheduler_event[sim_node()]);
        SimSchedulerBasicP$sim_scheduler_event_pending[sim_node()] = TRUE;
      }
  }
  
  # 482 "RoutC.nc"
  static void RoutC$MessageSend$sendDone(message_t *bufPtr, error_t error)
  #line 482
  {
    sim_log_debug(73U, "Event", "%s{%d, %s, %d}\n", "--- EVENT ---: sendDone ", __nesc_ntoh_uint16(RoutC$message[sim_node()]->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata)), __nesc_ntoh_uint32(RoutC$message[sim_node()]->seq.nxdata));
  #line 483
    ;
    if (&RoutC$packet[sim_node()] == bufPtr) {
        RoutC$locked[sim_node()] = FALSE;
        RoutC$rout();
      }
    else 
  #line 487
      {
        sim_log_debug(74U, "Error", "ERROR: Got sendDone for another message\n");
      }
  }
  
  # 237 "CpmModelC.nc"
  static bool CpmModelC$shouldReceive(double SNR)
  #line 237
  {
    double prr = CpmModelC$prr_estimate_from_snr(SNR);
    double coin = RandomUniform();
  
  #line 240
    if (prr != 0 && prr != 1) {
        if (coin < prr) {
          prr = 1.0;
          }
        else {
  #line 244
          prr = 0.0;
          }
      }
  #line 246
    return prr;
  }
  
  # 307 "TossimPacketModelC.nc"
  static bool TossimPacketModelC$GainRadioModel$shouldAck(message_t *msg)
  #line 307
  {
    if (TossimPacketModelC$running[sim_node()] && !TossimPacketModelC$transmitting[sim_node()]) {
        return TossimPacketModelC$Packet$shouldAck(msg);
      }
    else {
        return FALSE;
      }
  }
  
  # 207 "CpmModelC.nc"
  static void CpmModelC$sim_gain_schedule_ack(int source, sim_time_t t, CpmModelC$receive_message_t *r)
  #line 207
  {
    sim_event_t *ackEvent = (sim_event_t *)malloc(sizeof(sim_event_t ));
  
    ackEvent->mote = source;
    ackEvent->force = 1;
    ackEvent->cancelled = 0;
    ackEvent->time = t;
    ackEvent->handle = CpmModelC$sim_gain_ack_handle;
    ackEvent->cleanup = sim_queue_cleanup_event;
    ackEvent->data = r;
  
    sim_queue_insert(ackEvent);
  }
  
  # 102 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_packet.c"
    uint8_t sim_packet_max_length(sim_packet_t *msg)
  #line 102
  {
    return 28;
  }
  
    sim_packet_t *sim_packet_allocate()
  #line 106
  {
    return (sim_packet_t *)malloc(sizeof(message_t ));
  }
  
    void sim_packet_free(sim_packet_t *p)
  #line 110
  {
    printf("sim_packet.c: Freeing packet %p\n", p);
    free(p);
  }
  
  # 43 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMainP.nc"
    int sim_main_start_mote(void )
  #line 43
  {
    char timeBuf[128];
  
  #line 45
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  #line 45
      {
  
  
  
  
  
  
        SimMainP$Scheduler$init();
  
  
  
  
  
        SimMainP$PlatformInit$init();
        while (SimMainP$Scheduler$runNextTask()) ;
  
  
  
  
  
        SimMainP$SoftwareInit$init();
        while (SimMainP$Scheduler$runNextTask()) ;
      }
  #line 67
      __nesc_atomic_end(__nesc_atomic); }
  
  
    __nesc_enable_interrupt();
  
    sim_print_now(timeBuf, 128);
    sim_log_debug(123U, "SimMainP", "Mote %li signaling boot at time %s.\n", sim_node(), timeBuf);
    SimMainP$Boot$booted();
  
  
  
  
  
    return 0;
  }
  
  # 172 "/opt/tinyos-2.1.0/tos/lib/tossim/SimSchedulerBasicP.nc"
  static bool SimSchedulerBasicP$Scheduler$runNextTask(void )
  {
    uint8_t nextTask;
  
  #line 175
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
      {
        nextTask = SimSchedulerBasicP$popTask();
        if (nextTask == SimSchedulerBasicP$NO_TASK) 
          {
            sim_log_debug(125U, "Scheduler", "Told to run next task, but no task to run.\n");
            {
              unsigned char __nesc_temp = 
  #line 181
              FALSE;
  
              {
  #line 181
                __nesc_atomic_end(__nesc_atomic); 
  #line 181
                return __nesc_temp;
              }
            }
          }
      }
  #line 185
      __nesc_atomic_end(__nesc_atomic); }
  #line 184
    sim_log_debug(126U, "Scheduler", "Running task %hhu.\n", nextTask);
    SimSchedulerBasicP$TaskBasic$runTask(nextTask);
    return TRUE;
  }
  
  # 58 "RandomMlcgC.nc"
  static uint32_t RandomMlcgC$Random$rand32(void )
  #line 58
  {
    uint32_t mlcg;
  #line 59
    uint32_t p;
  #line 59
    uint32_t q;
    uint64_t tmpseed;
  
  #line 61
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
      {
        tmpseed = (uint64_t )33614U * (uint64_t )RandomMlcgC$seed[sim_node()];
        q = tmpseed;
        q = q >> 1;
        p = tmpseed >> 32;
        mlcg = p + q;
        if (mlcg & 0x80000000) {
            mlcg = mlcg & 0x7FFFFFFF;
            mlcg++;
          }
        RandomMlcgC$seed[sim_node()] = mlcg;
      }
  #line 73
      __nesc_atomic_end(__nesc_atomic); }
    return mlcg;
  }
  
  # 161 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static uint32_t /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$get(void )
  #line 161
  {
    uint32_t now;
  
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
      {
  
  
        uint8_t now8 = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get();
  
        if (/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$getInterruptFlag().bits.ocf0) {
  
  
          now = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()] + /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$get() + 1 + /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get();
          }
        else {
  
          now = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()] + now8;
          }
      }
  #line 179
      __nesc_atomic_end(__nesc_atomic); }
  #line 179
    return now;
  }
  
  # 274 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static uint8_t HplAtm128Timer0AsyncP$Timer0$get(void )
  #line 274
  {
    uint8_t rval;
    sim_time_t elapsed = sim_time() - HplAtm128Timer0AsyncP$last_zero();
  
  #line 277
    elapsed = HplAtm128Timer0AsyncP$sim_to_clock(elapsed);
    elapsed = elapsed >> HplAtm128Timer0AsyncP$shiftFromScale();
    rval = (uint8_t )(elapsed & 0xff);
    sim_log_debug(152U, "HplAtm128Timer0AsyncP", "HplAtm128Timer0AsyncP: Getting timer: %hhu\n", rval);
    return rval;
  }
  
  #line 100
  static sim_time_t HplAtm128Timer0AsyncP$last_zero(void )
  #line 100
  {
    if (HplAtm128Timer0AsyncP$lastZero[sim_node()] == 0) {
        HplAtm128Timer0AsyncP$lastZero[sim_node()] = sim_mote_start_time(sim_node());
      }
    return HplAtm128Timer0AsyncP$lastZero[sim_node()];
  }
  
  # 98 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
    long long int sim_mote_start_time(int mote)
  #line 98
  {
    long long int result;
    int tmp = sim_node();
  
  #line 101
    sim_set_node(mote);
    result = SimMoteP$SimMote$getStartTime();
    sim_set_node(tmp);
    return result;
  }
  
  # 152 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static uint16_t HplAtm128Timer0AsyncP$shiftFromScale(void )
  #line 152
  {
    uint8_t scale = HplAtm128Timer0AsyncP$Timer0$getScale();
  
  #line 154
    switch (scale) {
        case 0: 
          return 0;
        case 1: 
          return 0;
        case 2: 
          return 3;
        case 3: 
          return 5;
        case 4: 
          return 6;
        case 5: 
          return 7;
        case 6: 
          return 8;
        case 7: 
          return 10;
        default: 
          return 255;
      }
  }
  
  #line 313
  static uint8_t HplAtm128Timer0AsyncP$Timer0$getScale(void )
  #line 313
  {
    return * (volatile uint8_t *)&atm128RegFile[sim_node()][0x33] & 0x7;
  }
  
  #line 375
  static Atm128_TIFR_t HplAtm128Timer0AsyncP$Timer0Ctrl$getInterruptFlag(void )
  #line 375
  {
    Atm128_TIFR_t at;
  
  #line 377
    at.flat = * (volatile uint8_t *)&atm128RegFile[sim_node()][0x36];
    return at;
  }
  
  #line 449
  static uint8_t HplAtm128Timer0AsyncP$Compare$get(void )
  #line 449
  {
    sim_log_debug(158U, "HplAtm128Timer0AsyncP", "HplAtm128Timer0AsyncP: Getting compare: %hhu\n", * (volatile uint8_t *)&atm128RegFile[sim_node()][0x31]);
    return * (volatile uint8_t *)&atm128RegFile[sim_node()][0x31];
  }
  
  # 104 "TossimPacketModelC.nc"
  static error_t TossimPacketModelC$Control$start(void )
  #line 104
  {
    if (!TossimPacketModelC$initialized[sim_node()]) {
        sim_log_error(173U, "TossimPacketModelC", "TossimPacketModelC: Control.start() called before initialization!\n");
        return FAIL;
      }
    sim_log_debug(174U, "TossimPacketModelC", "TossimPacketModelC: Control.start() called.\n");
    TossimPacketModelC$startDoneTask$postTask();
    return SUCCESS;
  }
  
  # 62 "/opt/tinyos-2.1.0/tos/lib/timer/VirtualizeTimerC.nc"
  static void /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$fireTimers(uint32_t now)
  {
    uint8_t num;
  
    for (num = 0; num < /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$NUM_TIMERS; num++) 
      {
        /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer_t *timer = &/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[sim_node()][num];
  
        if (timer->isrunning) 
          {
            uint32_t elapsed = now - timer->t0;
  
            if (elapsed >= timer->dt) 
              {
                if (timer->isoneshot) {
                  timer->isrunning = FALSE;
                  }
                else {
  #line 79
                  timer->t0 += timer->dt;
                  }
                /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$Timer$fired(num);
                break;
              }
          }
      }
    /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$updateFromTimer$postTask();
  }
  
  # 265 "RoutC.nc"
  static void RoutC$routMessage(void )
  #line 265
  {
    if (RoutC$RouterQueue$enqueue(*RoutC$message[sim_node()]) != SUCCESS) {
        sim_log_debug(61U, "Rout", "%s{%d, %s, %d}\n", "Rout: queue full, message dropped:", __nesc_ntoh_uint16(RoutC$message[sim_node()]->from.nxdata), RoutC$messageTypeString(__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata)), __nesc_ntoh_uint32(RoutC$message[sim_node()]->seq.nxdata));
  #line 267
        ;
      }
  
    if (__nesc_ntoh_uint8(RoutC$message[sim_node()]->type.nxdata) == 11) {
        rout_msg_t m = RoutC$RouterQueue$head();
  
  #line 272
        while (__nesc_ntoh_uint8(m.type.nxdata) != 11) {
            m = RoutC$RouterQueue$dequeue();
            RoutC$RouterQueue$enqueue(m);
            m = RoutC$RouterQueue$head();
          }
      }
    RoutC$rout();
  }
  
  # 212 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/Atm128AlarmAsyncP.nc"
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$startAt(uint32_t nt0, uint32_t ndt)
  #line 212
  {
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
      {
        /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[sim_node()] = TRUE;
        /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[sim_node()] = nt0;
        /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[sim_node()] = ndt;
      }
  #line 218
      __nesc_atomic_end(__nesc_atomic); }
    /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt();
  }
  
  #line 90
  static void /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setInterrupt(void )
  #line 90
  {
    bool fired = FALSE;
  
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
      {
  
  
  
        uint8_t interrupt_in = 1 + /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Compare$get() - /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Timer$get();
        uint8_t newOcr0;
        uint8_t tifr = (uint8_t )/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$TimerCtrl$getInterruptFlag().flat;
  
  #line 101
        sim_log_debug(138U, "Atm128AlarmAsyncP", "Atm128AlarmAsyncP: TIFR is %hhx\n", tifr);
        if ((interrupt_in != 0 && interrupt_in < /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MINDT) || tifr & (1 << OCF0)) {
            if (interrupt_in < /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MINDT) {
                sim_log_debug(139U, "Atm128AlarmAsyncP", "Atm128AlarmAsyncP: under min: %hhu.\n", interrupt_in);
              }
            else {
                sim_log_debug(140U, "Atm128AlarmAsyncP", "Atm128AlarmAsyncP: OCF set.\n");
              }
            {
  #line 109
              __nesc_atomic_end(__nesc_atomic); 
  #line 109
              return;
            }
          }
  
        if (!/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[sim_node()]) {
            newOcr0 = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MAXT;
            sim_log_debug(141U, "Atm128AlarmAsyncP", "Atm128AlarmAsyncP: no alarm set, set at max.\n");
          }
        else 
          {
            uint32_t now = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Counter$get();
  
  #line 120
            sim_log_debug(142U, "Atm128AlarmAsyncP", "Atm128AlarmAsyncP: now-t0 = %llu, dt = %llu\n", now - /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[sim_node()], /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[sim_node()]);
  
            if ((uint32_t )(now - /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[sim_node()]) >= /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[sim_node()]) 
              {
                /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[sim_node()] = FALSE;
                fired = TRUE;
                newOcr0 = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MAXT;
              }
            else 
              {
  
  
                uint32_t alarm_in = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[sim_node()] + /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[sim_node()] - /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[sim_node()];
  
                if (alarm_in > /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MAXT) {
                  newOcr0 = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MAXT;
                  }
                else {
  #line 136
                  if ((uint8_t )alarm_in < /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MINDT) {
                    newOcr0 = /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$MINDT;
                    }
                  else {
  #line 139
                    newOcr0 = alarm_in;
                    }
                  }
              }
          }
  #line 142
        newOcr0--;
        /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$setOcr0(newOcr0);
      }
  #line 144
      __nesc_atomic_end(__nesc_atomic); }
    if (fired) {
      /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$Alarm$fired();
      }
  }
  
  # 455 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
  static void HplAtm128Timer0AsyncP$Compare$set(uint8_t t)
  #line 455
  {
    sim_log_debug(159U, "HplAtm128Timer0AsyncP", "HplAtm128Timer0AsyncP: Setting compare: %hhu\n", t);
    /* atomic removed: atomic calls only */
  #line 457
    {
  
  
  
  
      if (t == 0 || t >= 0xfe) {
        t = 1;
        }
      if (t != * (volatile uint8_t *)&atm128RegFile[sim_node()][0x31]) {
          * (volatile uint8_t *)&atm128RegFile[sim_node()][0x31] = t;
          HplAtm128Timer0AsyncP$schedule_new_compare();
        }
    }
  }
  
  #line 259
  static void HplAtm128Timer0AsyncP$schedule_new_compare(void )
  #line 259
  {
    if (HplAtm128Timer0AsyncP$compare[sim_node()] != (void *)0) {
        HplAtm128Timer0AsyncP$cancel_compare();
      }
    if (HplAtm128Timer0AsyncP$Timer0$getScale() != AVR_CLOCK_OFF) {
        sim_event_t *newEvent = HplAtm128Timer0AsyncP$allocate_compare();
  
  #line 265
        HplAtm128Timer0AsyncP$configure_compare(newEvent);
  
        HplAtm128Timer0AsyncP$compare[sim_node()] = newEvent;
        sim_queue_insert(newEvent);
      }
  }
  
  # 89 "/opt/tinyos-2.1.0/tos/lib/tossim/sim_event_queue.c"
  static sim_event_t *sim_queue_allocate_event()
  #line 89
  {
    sim_event_t *evt = (sim_event_t *)malloc(sizeof(sim_event_t ));
  
  #line 91
    memset(evt, 0, sizeof(sim_event_t ));
    evt->mote = sim_node();
    return evt;
  }
  
  # 92 "/opt/tinyos-2.1.0/tos/chips/atm128/timer/sim/HplAtm128Timer0AsyncP.nc"
    void INTERRUPT_16(void )
  #line 92
  {
    HplAtm128Timer0AsyncP$inOverflow[sim_node()] = TRUE;
    HplAtm128Timer0AsyncP$Timer0$overflow();
    HplAtm128Timer0AsyncP$inOverflow[sim_node()] = FALSE;
  }
  
  #line 500
  static void HplAtm128Timer0AsyncP$configure_overflow(sim_event_t *evt)
  #line 500
  {
    sim_time_t overflowTime = 0;
    uint8_t timerVal = HplAtm128Timer0AsyncP$Timer0$get();
    uint8_t overflowVal = 0;
  
  
  
  
    overflowTime = (overflowVal - timerVal) & 0xff;
    if (overflowTime == 0) {
        overflowTime = 256;
      }
  
  
  
  
    overflowTime = overflowTime << HplAtm128Timer0AsyncP$shiftFromScale();
    overflowTime = HplAtm128Timer0AsyncP$clock_to_sim(overflowTime);
    overflowTime += sim_time();
    overflowTime -= (sim_time() - HplAtm128Timer0AsyncP$last_zero()) % (1 << HplAtm128Timer0AsyncP$shiftFromScale());
  
    sim_log_debug(162U, "HplAtm128Timer0AsyncP", "Scheduling new overflow for %i at time %llu\n", sim_node(), overflowTime);
  
    evt->time = overflowTime;
  }
  
  #line 86
    void INTERRUPT_15(void )
  #line 86
  {
  
    HplAtm128Timer0AsyncP$Compare$fired();
  }
  
  #line 223
  static void HplAtm128Timer0AsyncP$configure_compare(sim_event_t *evt)
  #line 223
  {
    sim_time_t compareTime = 0;
    sim_time_t phaseOffset = 0;
    uint8_t timerVal = HplAtm128Timer0AsyncP$Timer0$get();
    uint8_t compareVal = HplAtm128Timer0AsyncP$Compare$get();
  
  
  
  
    compareTime = (compareVal - timerVal) & 0xff;
    if (compareTime == 0) {
        compareTime = 256;
      }
  
  
  
  
  
  
    compareTime = (compareTime + 1) << HplAtm128Timer0AsyncP$shiftFromScale();
    compareTime = HplAtm128Timer0AsyncP$clock_to_sim(compareTime);
    compareTime += sim_time();
  
  
  
  
    phaseOffset = sim_time();
    phaseOffset -= HplAtm128Timer0AsyncP$last_zero();
    phaseOffset %= HplAtm128Timer0AsyncP$clock_to_sim(1 << HplAtm128Timer0AsyncP$shiftFromScale());
    compareTime -= phaseOffset;
  
    sim_log_debug(151U, "HplAtm128Timer0AsyncP", "Configuring new compare of %i for %i at time %llu  (@ %llu)\n", (int )compareVal, sim_node(), compareTime, sim_time());
  
    evt->time = compareTime;
  }
  
  # 44 "RandomMlcgC.nc"
  static error_t RandomMlcgC$Init$init(void )
  #line 44
  {
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
  #line 45
      RandomMlcgC$seed[sim_node()] = (uint32_t )(TOS_NODE_ID + 1 + sim_time());
  #line 45
      __nesc_atomic_end(__nesc_atomic); }
  
    return SUCCESS;
  }
  
  # 82 "/opt/tinyos-2.1.0/tos/lib/tossim/SimMoteP.nc"
    long long int sim_mote_euid(int mote)
  #line 82
  {
    long long int result;
    int tmp = sim_node();
  
  #line 85
    sim_set_node(mote);
    result = SimMoteP$SimMote$getEuid();
    sim_set_node(tmp);
    return result;
  }
  
    void sim_mote_set_euid(int mote, long long int id)
  #line 91
  {
    int tmp = sim_node();
  
  #line 93
    sim_set_node(mote);
    SimMoteP$SimMote$setEuid(id);
    sim_set_node(tmp);
  }
  
  
  
  
  
  
  
  
  
  
    int sim_mote_get_variable_info(int mote, char *name, void **ptr, size_t *len)
  #line 107
  {
    int result;
    int tmpID = sim_node();
  
  #line 110
    sim_set_node(mote);
    result = SimMoteP$SimMote$getVariableInfo(name, ptr, len);
    sim_log_debug(130U, "SimMoteP", "Fetched %s of %i to be %p with len %i (result %i)\n", name, mote, *ptr, *len, result);
    sim_set_node(tmpID);
    return result;
  }
  
    void sim_mote_set_start_time(int mote, long long int t)
  #line 117
  {
    int tmpID = sim_node();
  
  #line 119
    sim_set_node(mote);
    SimMoteP$startTime[sim_node()] = t;
    sim_log_debug(131U, "SimMoteP", "Setting start time to %llu\n", SimMoteP$startTime[sim_node()]);
    sim_set_node(tmpID);
    return;
  }
  
  
  
  
  
  
  
  
  
  
    void sim_mote_turn_on(int mote)
  #line 135
  {
    int tmp = sim_node();
  
  #line 137
    sim_set_node(mote);
    SimMoteP$SimMote$turnOn();
    sim_set_node(tmp);
  }
  
  #line 64
  static void SimMoteP$SimMote$turnOn(void )
  #line 64
  {
    if (!SimMoteP$isOn[sim_node()]) {
        if (SimMoteP$bootEvent[sim_node()] != (void *)0) {
            SimMoteP$bootEvent[sim_node()]->cancelled = TRUE;
          }
        __nesc_nido_initialise(sim_node());
        SimMoteP$startTime[sim_node()] = sim_time();
        sim_log_debug(129U, "SimMoteP", "Setting start time to %llu\n", SimMoteP$startTime[sim_node()]);
        SimMoteP$isOn[sim_node()] = TRUE;
        sim_main_start_mote();
      }
  }
  
  #line 142
    void sim_mote_turn_off(int mote)
  #line 142
  {
    int tmp = sim_node();
  
  #line 144
    sim_set_node(mote);
    SimMoteP$SimMote$turnOff();
    sim_set_node(tmp);
  }
  
  
  
  
  
  
  
  
  
  
    void sim_mote_enqueue_boot_event(int mote)
  #line 158
  {
    int tmp = sim_node();
  
  #line 160
    sim_set_node(mote);
  
    if (SimMoteP$bootEvent[sim_node()] != (void *)0) {
        if (SimMoteP$bootEvent[sim_node()]->time == SimMoteP$startTime[sim_node()]) {
  
            SimMoteP$bootEvent[sim_node()]->cancelled = FALSE;
            return;
          }
        else {
            SimMoteP$bootEvent[sim_node()]->cancelled = TRUE;
          }
      }
  
    SimMoteP$bootEvent[sim_node()] = (sim_event_t *)malloc(sizeof(sim_event_t ));
    SimMoteP$bootEvent[sim_node()]->time = SimMoteP$startTime[sim_node()];
    SimMoteP$bootEvent[sim_node()]->mote = mote;
    SimMoteP$bootEvent[sim_node()]->force = TRUE;
    SimMoteP$bootEvent[sim_node()]->data = (void *)0;
    SimMoteP$bootEvent[sim_node()]->handle = SimMoteP$sim_mote_boot_handle;
    SimMoteP$bootEvent[sim_node()]->cleanup = sim_queue_cleanup_event;
    sim_queue_insert(SimMoteP$bootEvent[sim_node()]);
  
    sim_set_node(tmp);
  }
  
  /* Nido variable resolver function */
  
  static int __nesc_nido_resolve(int __nesc_mote,
                                 char* varname,
                                 uintptr_t* addr, size_t* size)
  {
    /* Module RoutC */
    if (!strcmp(varname, "RoutC$packet"))
    {
      *addr = (uintptr_t)&RoutC$packet[__nesc_mote];
      *size = sizeof(RoutC$packet[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$message"))
    {
      *addr = (uintptr_t)&RoutC$message[__nesc_mote];
      *size = sizeof(RoutC$message[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$router"))
    {
      *addr = (uintptr_t)&RoutC$router[__nesc_mote];
      *size = sizeof(RoutC$router[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$clusterHead"))
    {
      *addr = (uintptr_t)&RoutC$clusterHead[__nesc_mote];
      *size = sizeof(RoutC$clusterHead[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$routerlessreported"))
    {
      *addr = (uintptr_t)&RoutC$routerlessreported[__nesc_mote];
      *size = sizeof(RoutC$routerlessreported[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$switchrouter"))
    {
      *addr = (uintptr_t)&RoutC$switchrouter[__nesc_mote];
      *size = sizeof(RoutC$switchrouter[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$locked"))
    {
      *addr = (uintptr_t)&RoutC$locked[__nesc_mote];
      *size = sizeof(RoutC$locked[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$battery"))
    {
      *addr = (uintptr_t)&RoutC$battery[__nesc_mote];
      *size = sizeof(RoutC$battery[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$isCluster"))
    {
      *addr = (uintptr_t)&RoutC$isCluster[__nesc_mote];
      *size = sizeof(RoutC$isCluster[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$clusterElec"))
    {
      *addr = (uintptr_t)&RoutC$clusterElec[__nesc_mote];
      *size = sizeof(RoutC$clusterElec[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "RoutC$msgcount"))
    {
      *addr = (uintptr_t)&RoutC$msgcount[__nesc_mote];
      *size = sizeof(RoutC$msgcount[__nesc_mote]);
      return 0;
    }
  
    /* Module PlatformP */
  
    /* Module MotePlatformP */
  
    /* Module HplAtm128GeneralIOPinP$0 */
  
    /* Module HplAtm128GeneralIOPinP$1 */
  
    /* Module HplAtm128GeneralIOPinP$2 */
  
    /* Module HplAtm128GeneralIOPinP$3 */
  
    /* Module HplAtm128GeneralIOPinP$4 */
  
    /* Module HplAtm128GeneralIOPinP$5 */
  
    /* Module HplAtm128GeneralIOPinP$6 */
  
    /* Module HplAtm128GeneralIOPinP$7 */
  
    /* Module HplAtm128GeneralIOPinP$8 */
  
    /* Module HplAtm128GeneralIOPinP$9 */
  
    /* Module HplAtm128GeneralIOPinP$10 */
  
    /* Module HplAtm128GeneralIOPinP$11 */
  
    /* Module HplAtm128GeneralIOPinP$12 */
  
    /* Module HplAtm128GeneralIOPinP$13 */
  
    /* Module HplAtm128GeneralIOPinP$14 */
  
    /* Module HplAtm128GeneralIOPinP$15 */
  
    /* Module HplAtm128GeneralIOPinP$16 */
  
    /* Module HplAtm128GeneralIOPinP$17 */
  
    /* Module HplAtm128GeneralIOPinP$18 */
  
    /* Module HplAtm128GeneralIOPinP$19 */
  
    /* Module HplAtm128GeneralIOPinP$20 */
  
    /* Module HplAtm128GeneralIOPinP$21 */
  
    /* Module HplAtm128GeneralIOPinP$22 */
  
    /* Module HplAtm128GeneralIOPinP$23 */
  
    /* Module HplAtm128GeneralIOPinP$24 */
  
    /* Module HplAtm128GeneralIOPinP$25 */
  
    /* Module HplAtm128GeneralIOPinP$26 */
  
    /* Module HplAtm128GeneralIOPinP$27 */
  
    /* Module HplAtm128GeneralIOPinP$28 */
  
    /* Module HplAtm128GeneralIOPinP$29 */
  
    /* Module HplAtm128GeneralIOPinP$30 */
  
    /* Module HplAtm128GeneralIOPinP$31 */
  
    /* Module HplAtm128GeneralIOPinP$32 */
  
    /* Module HplAtm128GeneralIOPinP$33 */
  
    /* Module HplAtm128GeneralIOPinP$34 */
  
    /* Module HplAtm128GeneralIOPinP$35 */
  
    /* Module HplAtm128GeneralIOPinP$36 */
  
    /* Module HplAtm128GeneralIOPinP$37 */
  
    /* Module HplAtm128GeneralIOPinP$38 */
  
    /* Module HplAtm128GeneralIOPinP$39 */
  
    /* Module HplAtm128GeneralIOPinP$40 */
  
    /* Module HplAtm128GeneralIOPinP$41 */
  
    /* Module HplAtm128GeneralIOPinP$42 */
  
    /* Module HplAtm128GeneralIOPinP$43 */
  
    /* Module HplAtm128GeneralIOPinP$44 */
  
    /* Module HplAtm128GeneralIOPinP$45 */
  
    /* Module HplAtm128GeneralIOPinP$46 */
  
    /* Module HplAtm128GeneralIOPinP$47 */
  
    /* Module HplAtm128GeneralIOSlowPinP$0 */
  
    /* Module HplAtm128GeneralIOSlowPinP$1 */
  
    /* Module HplAtm128GeneralIOSlowPinP$2 */
  
    /* Module HplAtm128GeneralIOSlowPinP$3 */
  
    /* Module HplAtm128GeneralIOSlowPinP$4 */
  
    /* Module HplAtm128GeneralIOSlowPinP$5 */
  
    /* Module HplAtm128GeneralIOSlowPinP$6 */
  
    /* Module HplAtm128GeneralIOSlowPinP$7 */
  
    /* Module HplAtm128GeneralIOSlowPinP$8 */
  
    /* Module HplAtm128GeneralIOSlowPinP$9 */
  
    /* Module HplAtm128GeneralIOSlowPinP$10 */
  
    /* Module HplAtm128GeneralIOSlowPinP$11 */
  
    /* Module HplAtm128GeneralIOSlowPinP$12 */
  
    /* Module MeasureClockC */
  
    /* Module SimMainP */
  
    /* Module SimSchedulerBasicP */
    if (!strcmp(varname, "SimSchedulerBasicP$m_head"))
    {
      *addr = (uintptr_t)&SimSchedulerBasicP$m_head[__nesc_mote];
      *size = sizeof(SimSchedulerBasicP$m_head[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimSchedulerBasicP$m_tail"))
    {
      *addr = (uintptr_t)&SimSchedulerBasicP$m_tail[__nesc_mote];
      *size = sizeof(SimSchedulerBasicP$m_tail[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimSchedulerBasicP$m_next"))
    {
      *addr = (uintptr_t)&SimSchedulerBasicP$m_next[__nesc_mote];
      *size = sizeof(SimSchedulerBasicP$m_next[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimSchedulerBasicP$sim_scheduler_event_pending"))
    {
      *addr = (uintptr_t)&SimSchedulerBasicP$sim_scheduler_event_pending[__nesc_mote];
      *size = sizeof(SimSchedulerBasicP$sim_scheduler_event_pending[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimSchedulerBasicP$sim_scheduler_event"))
    {
      *addr = (uintptr_t)&SimSchedulerBasicP$sim_scheduler_event[__nesc_mote];
      *size = sizeof(SimSchedulerBasicP$sim_scheduler_event[__nesc_mote]);
      return 0;
    }
  
    /* Module SimMoteP */
    if (!strcmp(varname, "SimMoteP$euid"))
    {
      *addr = (uintptr_t)&SimMoteP$euid[__nesc_mote];
      *size = sizeof(SimMoteP$euid[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimMoteP$startTime"))
    {
      *addr = (uintptr_t)&SimMoteP$startTime[__nesc_mote];
      *size = sizeof(SimMoteP$startTime[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimMoteP$isOn"))
    {
      *addr = (uintptr_t)&SimMoteP$isOn[__nesc_mote];
      *size = sizeof(SimMoteP$isOn[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "SimMoteP$bootEvent"))
    {
      *addr = (uintptr_t)&SimMoteP$bootEvent[__nesc_mote];
      *size = sizeof(SimMoteP$bootEvent[__nesc_mote]);
      return 0;
    }
  
    /* Module TossimActiveMessageC */
    if (!strcmp(varname, "TossimActiveMessageC$buffer"))
    {
      *addr = (uintptr_t)&TossimActiveMessageC$buffer[__nesc_mote];
      *size = sizeof(TossimActiveMessageC$buffer[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimActiveMessageC$bufferPointer"))
    {
      *addr = (uintptr_t)&TossimActiveMessageC$bufferPointer[__nesc_mote];
      *size = sizeof(TossimActiveMessageC$bufferPointer[__nesc_mote]);
      return 0;
    }
  
    /* Module Atm128AlarmAsyncP$0 */
    if (!strcmp(varname, "/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set"))
    {
      *addr = (uintptr_t)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[__nesc_mote];
      *size = sizeof(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0"))
    {
      *addr = (uintptr_t)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[__nesc_mote];
      *size = sizeof(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt"))
    {
      *addr = (uintptr_t)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[__nesc_mote];
      *size = sizeof(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base"))
    {
      *addr = (uintptr_t)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[__nesc_mote];
      *size = sizeof(/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[__nesc_mote]);
      return 0;
    }
  
    /* Module HplAtm128Timer0AsyncP */
    if (!strcmp(varname, "HplAtm128Timer0AsyncP$inOverflow"))
    {
      *addr = (uintptr_t)&HplAtm128Timer0AsyncP$inOverflow[__nesc_mote];
      *size = sizeof(HplAtm128Timer0AsyncP$inOverflow[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "HplAtm128Timer0AsyncP$lastZero"))
    {
      *addr = (uintptr_t)&HplAtm128Timer0AsyncP$lastZero[__nesc_mote];
      *size = sizeof(HplAtm128Timer0AsyncP$lastZero[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "HplAtm128Timer0AsyncP$oldScale"))
    {
      *addr = (uintptr_t)&HplAtm128Timer0AsyncP$oldScale[__nesc_mote];
      *size = sizeof(HplAtm128Timer0AsyncP$oldScale[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "HplAtm128Timer0AsyncP$compare"))
    {
      *addr = (uintptr_t)&HplAtm128Timer0AsyncP$compare[__nesc_mote];
      *size = sizeof(HplAtm128Timer0AsyncP$compare[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "HplAtm128Timer0AsyncP$overflow"))
    {
      *addr = (uintptr_t)&HplAtm128Timer0AsyncP$overflow[__nesc_mote];
      *size = sizeof(HplAtm128Timer0AsyncP$overflow[__nesc_mote]);
      return 0;
    }
  
    /* Module AlarmToTimerC$0 */
    if (!strcmp(varname, "/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt"))
    {
      *addr = (uintptr_t)&/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[__nesc_mote];
      *size = sizeof(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot"))
    {
      *addr = (uintptr_t)&/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[__nesc_mote];
      *size = sizeof(/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[__nesc_mote]);
      return 0;
    }
  
    /* Module VirtualizeTimerC$0 */
    if (!strcmp(varname, "/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers"))
    {
      *addr = (uintptr_t)&/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[__nesc_mote];
      *size = sizeof(/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[__nesc_mote]);
      return 0;
    }
  
    /* Module CounterToLocalTimeC$0 */
  
    /* Module RandomMlcgC */
    if (!strcmp(varname, "RandomMlcgC$seed"))
    {
      *addr = (uintptr_t)&RandomMlcgC$seed[__nesc_mote];
      *size = sizeof(RandomMlcgC$seed[__nesc_mote]);
      return 0;
    }
  
    /* Module QueueC$0 */
    if (!strcmp(varname, "/*RoutAppC.Queue*/QueueC$0$queue"))
    {
      *addr = (uintptr_t)&/*RoutAppC.Queue*/QueueC$0$queue[__nesc_mote];
      *size = sizeof(/*RoutAppC.Queue*/QueueC$0$queue[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*RoutAppC.Queue*/QueueC$0$head"))
    {
      *addr = (uintptr_t)&/*RoutAppC.Queue*/QueueC$0$head[__nesc_mote];
      *size = sizeof(/*RoutAppC.Queue*/QueueC$0$head[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*RoutAppC.Queue*/QueueC$0$tail"))
    {
      *addr = (uintptr_t)&/*RoutAppC.Queue*/QueueC$0$tail[__nesc_mote];
      *size = sizeof(/*RoutAppC.Queue*/QueueC$0$tail[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*RoutAppC.Queue*/QueueC$0$size"))
    {
      *addr = (uintptr_t)&/*RoutAppC.Queue*/QueueC$0$size[__nesc_mote];
      *size = sizeof(/*RoutAppC.Queue*/QueueC$0$size[__nesc_mote]);
      return 0;
    }
  
    /* Module TossimPacketModelC */
    if (!strcmp(varname, "TossimPacketModelC$initialized"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$initialized[__nesc_mote];
      *size = sizeof(TossimPacketModelC$initialized[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$running"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$running[__nesc_mote];
      *size = sizeof(TossimPacketModelC$running[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$backoffCount"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$backoffCount[__nesc_mote];
      *size = sizeof(TossimPacketModelC$backoffCount[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$neededFreeSamples"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$neededFreeSamples[__nesc_mote];
      *size = sizeof(TossimPacketModelC$neededFreeSamples[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$sending"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$sending[__nesc_mote];
      *size = sizeof(TossimPacketModelC$sending[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$transmitting"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$transmitting[__nesc_mote];
      *size = sizeof(TossimPacketModelC$transmitting[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$sendingLength"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$sendingLength[__nesc_mote];
      *size = sizeof(TossimPacketModelC$sendingLength[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$destNode"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$destNode[__nesc_mote];
      *size = sizeof(TossimPacketModelC$destNode[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$sendEvent"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$sendEvent[__nesc_mote];
      *size = sizeof(TossimPacketModelC$sendEvent[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "TossimPacketModelC$error"))
    {
      *addr = (uintptr_t)&TossimPacketModelC$error[__nesc_mote];
      *size = sizeof(TossimPacketModelC$error[__nesc_mote]);
      return 0;
    }
  
    /* Module CpmModelC */
    if (!strcmp(varname, "CpmModelC$outgoing"))
    {
      *addr = (uintptr_t)&CpmModelC$outgoing[__nesc_mote];
      *size = sizeof(CpmModelC$outgoing[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "CpmModelC$requestAck"))
    {
      *addr = (uintptr_t)&CpmModelC$requestAck[__nesc_mote];
      *size = sizeof(CpmModelC$requestAck[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "CpmModelC$receiving"))
    {
      *addr = (uintptr_t)&CpmModelC$receiving[__nesc_mote];
      *size = sizeof(CpmModelC$receiving[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "CpmModelC$outstandingReceptionHead"))
    {
      *addr = (uintptr_t)&CpmModelC$outstandingReceptionHead[__nesc_mote];
      *size = sizeof(CpmModelC$outstandingReceptionHead[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "CpmModelC$clearThreshold"))
    {
      *addr = (uintptr_t)&CpmModelC$clearThreshold[__nesc_mote];
      *size = sizeof(CpmModelC$clearThreshold[__nesc_mote]);
      return 0;
    }
  
    /* Module ActiveMessageAddressC */
    if (!strcmp(varname, "ActiveMessageAddressC$set"))
    {
      *addr = (uintptr_t)&ActiveMessageAddressC$set[__nesc_mote];
      *size = sizeof(ActiveMessageAddressC$set[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "ActiveMessageAddressC$addr"))
    {
      *addr = (uintptr_t)&ActiveMessageAddressC$addr[__nesc_mote];
      *size = sizeof(ActiveMessageAddressC$addr[__nesc_mote]);
      return 0;
    }
  
    /* Module AMQueueEntryP$0 */
  
    /* Module AMQueueImplP$0 */
    if (!strcmp(varname, "/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current"))
    {
      *addr = (uintptr_t)&/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[__nesc_mote];
      *size = sizeof(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue"))
    {
      *addr = (uintptr_t)&/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[__nesc_mote];
      *size = sizeof(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[__nesc_mote]);
      return 0;
    }
    if (!strcmp(varname, "/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask"))
    {
      *addr = (uintptr_t)&/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[__nesc_mote];
      *size = sizeof(/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[__nesc_mote]);
      return 0;
    }
  
    return -1;
  }
  /* Invoke static initialisers for mote '__nesc_mote' */
  
  static void __nesc_nido_initialise(int __nesc_mote)
  {
    /* Module RoutC */
    memset((void *)&RoutC$packet[__nesc_mote], 0, sizeof RoutC$packet[__nesc_mote]);
    memset((void *)&RoutC$message[__nesc_mote], 0, sizeof RoutC$message[__nesc_mote]);
    RoutC$router[__nesc_mote] = -1;
    RoutC$clusterHead[__nesc_mote] = -1;
    RoutC$routerlessreported[__nesc_mote] = FALSE;
    RoutC$switchrouter[__nesc_mote] = TRUE;
    RoutC$locked[__nesc_mote] = FALSE;
    RoutC$battery[__nesc_mote] = 0;
    RoutC$isCluster[__nesc_mote] = FALSE;
    RoutC$clusterElec[__nesc_mote] = 7;
    RoutC$msgcount[__nesc_mote] = 1;
    RoutC$sendContent$sequence[__nesc_mote] = 0;
    RoutC$contentCollect$collected[__nesc_mote] = 0;
    RoutC$PeriodTimer$fired$roundcounter[__nesc_mote] = 0;
  
    /* Module PlatformP */
  
    /* Module MotePlatformP */
  
    /* Module HplAtm128GeneralIOPinP$0 */
  
    /* Module HplAtm128GeneralIOPinP$1 */
  
    /* Module HplAtm128GeneralIOPinP$2 */
  
    /* Module HplAtm128GeneralIOPinP$3 */
  
    /* Module HplAtm128GeneralIOPinP$4 */
  
    /* Module HplAtm128GeneralIOPinP$5 */
  
    /* Module HplAtm128GeneralIOPinP$6 */
  
    /* Module HplAtm128GeneralIOPinP$7 */
  
    /* Module HplAtm128GeneralIOPinP$8 */
  
    /* Module HplAtm128GeneralIOPinP$9 */
  
    /* Module HplAtm128GeneralIOPinP$10 */
  
    /* Module HplAtm128GeneralIOPinP$11 */
  
    /* Module HplAtm128GeneralIOPinP$12 */
  
    /* Module HplAtm128GeneralIOPinP$13 */
  
    /* Module HplAtm128GeneralIOPinP$14 */
  
    /* Module HplAtm128GeneralIOPinP$15 */
  
    /* Module HplAtm128GeneralIOPinP$16 */
  
    /* Module HplAtm128GeneralIOPinP$17 */
  
    /* Module HplAtm128GeneralIOPinP$18 */
  
    /* Module HplAtm128GeneralIOPinP$19 */
  
    /* Module HplAtm128GeneralIOPinP$20 */
  
    /* Module HplAtm128GeneralIOPinP$21 */
  
    /* Module HplAtm128GeneralIOPinP$22 */
  
    /* Module HplAtm128GeneralIOPinP$23 */
  
    /* Module HplAtm128GeneralIOPinP$24 */
  
    /* Module HplAtm128GeneralIOPinP$25 */
  
    /* Module HplAtm128GeneralIOPinP$26 */
  
    /* Module HplAtm128GeneralIOPinP$27 */
  
    /* Module HplAtm128GeneralIOPinP$28 */
  
    /* Module HplAtm128GeneralIOPinP$29 */
  
    /* Module HplAtm128GeneralIOPinP$30 */
  
    /* Module HplAtm128GeneralIOPinP$31 */
  
    /* Module HplAtm128GeneralIOPinP$32 */
  
    /* Module HplAtm128GeneralIOPinP$33 */
  
    /* Module HplAtm128GeneralIOPinP$34 */
  
    /* Module HplAtm128GeneralIOPinP$35 */
  
    /* Module HplAtm128GeneralIOPinP$36 */
  
    /* Module HplAtm128GeneralIOPinP$37 */
  
    /* Module HplAtm128GeneralIOPinP$38 */
  
    /* Module HplAtm128GeneralIOPinP$39 */
  
    /* Module HplAtm128GeneralIOPinP$40 */
  
    /* Module HplAtm128GeneralIOPinP$41 */
  
    /* Module HplAtm128GeneralIOPinP$42 */
  
    /* Module HplAtm128GeneralIOPinP$43 */
  
    /* Module HplAtm128GeneralIOPinP$44 */
  
    /* Module HplAtm128GeneralIOPinP$45 */
  
    /* Module HplAtm128GeneralIOPinP$46 */
  
    /* Module HplAtm128GeneralIOPinP$47 */
  
    /* Module HplAtm128GeneralIOSlowPinP$0 */
  
    /* Module HplAtm128GeneralIOSlowPinP$1 */
  
    /* Module HplAtm128GeneralIOSlowPinP$2 */
  
    /* Module HplAtm128GeneralIOSlowPinP$3 */
  
    /* Module HplAtm128GeneralIOSlowPinP$4 */
  
    /* Module HplAtm128GeneralIOSlowPinP$5 */
  
    /* Module HplAtm128GeneralIOSlowPinP$6 */
  
    /* Module HplAtm128GeneralIOSlowPinP$7 */
  
    /* Module HplAtm128GeneralIOSlowPinP$8 */
  
    /* Module HplAtm128GeneralIOSlowPinP$9 */
  
    /* Module HplAtm128GeneralIOSlowPinP$10 */
  
    /* Module HplAtm128GeneralIOSlowPinP$11 */
  
    /* Module HplAtm128GeneralIOSlowPinP$12 */
  
    /* Module MeasureClockC */
  
    /* Module SimMainP */
  
    /* Module SimSchedulerBasicP */
    memset((void *)&SimSchedulerBasicP$m_head[__nesc_mote], 0, sizeof SimSchedulerBasicP$m_head[__nesc_mote]);
    memset((void *)&SimSchedulerBasicP$m_tail[__nesc_mote], 0, sizeof SimSchedulerBasicP$m_tail[__nesc_mote]);
    memset((void *)&SimSchedulerBasicP$m_next[__nesc_mote], 0, sizeof SimSchedulerBasicP$m_next[__nesc_mote]);
    SimSchedulerBasicP$sim_scheduler_event_pending[__nesc_mote] = FALSE;
    memset((void *)&SimSchedulerBasicP$sim_scheduler_event[__nesc_mote], 0, sizeof SimSchedulerBasicP$sim_scheduler_event[__nesc_mote]);
  
    /* Module SimMoteP */
    memset((void *)&SimMoteP$euid[__nesc_mote], 0, sizeof SimMoteP$euid[__nesc_mote]);
    memset((void *)&SimMoteP$startTime[__nesc_mote], 0, sizeof SimMoteP$startTime[__nesc_mote]);
    memset((void *)&SimMoteP$isOn[__nesc_mote], 0, sizeof SimMoteP$isOn[__nesc_mote]);
    memset((void *)&SimMoteP$bootEvent[__nesc_mote], 0, sizeof SimMoteP$bootEvent[__nesc_mote]);
  
    /* Module TossimActiveMessageC */
    memset((void *)&TossimActiveMessageC$buffer[__nesc_mote], 0, sizeof TossimActiveMessageC$buffer[__nesc_mote]);
    TossimActiveMessageC$bufferPointer[__nesc_mote] = &TossimActiveMessageC$buffer[__nesc_mote];
  
    /* Module Atm128AlarmAsyncP$0 */
    memset((void *)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[__nesc_mote], 0, sizeof /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$set[__nesc_mote]);
    memset((void *)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[__nesc_mote], 0, sizeof /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$t0[__nesc_mote]);
    memset((void *)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[__nesc_mote], 0, sizeof /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$dt[__nesc_mote]);
    memset((void *)&/*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[__nesc_mote], 0, sizeof /*AlarmCounterMilliP.Atm128AlarmAsyncC.Atm128AlarmAsyncP*/Atm128AlarmAsyncP$0$base[__nesc_mote]);
  
    /* Module HplAtm128Timer0AsyncP */
    HplAtm128Timer0AsyncP$inOverflow[__nesc_mote] = 0;
    HplAtm128Timer0AsyncP$lastZero[__nesc_mote] = 0;
    HplAtm128Timer0AsyncP$oldScale[__nesc_mote] = AVR_CLOCK_OFF;
    memset((void *)&HplAtm128Timer0AsyncP$compare[__nesc_mote], 0, sizeof HplAtm128Timer0AsyncP$compare[__nesc_mote]);
    memset((void *)&HplAtm128Timer0AsyncP$overflow[__nesc_mote], 0, sizeof HplAtm128Timer0AsyncP$overflow[__nesc_mote]);
  
    /* Module AlarmToTimerC$0 */
    memset((void *)&/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[__nesc_mote], 0, sizeof /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_dt[__nesc_mote]);
    memset((void *)&/*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[__nesc_mote], 0, sizeof /*HilTimerMilliC.AlarmToTimerC*/AlarmToTimerC$0$m_oneshot[__nesc_mote]);
  
    /* Module VirtualizeTimerC$0 */
    memset((void *)&/*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[__nesc_mote], 0, sizeof /*HilTimerMilliC.VirtualizeTimerC*/VirtualizeTimerC$0$m_timers[__nesc_mote]);
  
    /* Module CounterToLocalTimeC$0 */
  
    /* Module RandomMlcgC */
    memset((void *)&RandomMlcgC$seed[__nesc_mote], 0, sizeof RandomMlcgC$seed[__nesc_mote]);
  
    /* Module QueueC$0 */
    memset((void *)&/*RoutAppC.Queue*/QueueC$0$queue[__nesc_mote], 0, sizeof /*RoutAppC.Queue*/QueueC$0$queue[__nesc_mote]);
    /*RoutAppC.Queue*/QueueC$0$head[__nesc_mote] = 0;
    /*RoutAppC.Queue*/QueueC$0$tail[__nesc_mote] = 0;
    /*RoutAppC.Queue*/QueueC$0$size[__nesc_mote] = 0;
  
    /* Module TossimPacketModelC */
    TossimPacketModelC$initialized[__nesc_mote] = FALSE;
    TossimPacketModelC$running[__nesc_mote] = FALSE;
    memset((void *)&TossimPacketModelC$backoffCount[__nesc_mote], 0, sizeof TossimPacketModelC$backoffCount[__nesc_mote]);
    memset((void *)&TossimPacketModelC$neededFreeSamples[__nesc_mote], 0, sizeof TossimPacketModelC$neededFreeSamples[__nesc_mote]);
    TossimPacketModelC$sending[__nesc_mote] = (void *)0;
    TossimPacketModelC$transmitting[__nesc_mote] = FALSE;
    TossimPacketModelC$sendingLength[__nesc_mote] = 0;
    memset((void *)&TossimPacketModelC$destNode[__nesc_mote], 0, sizeof TossimPacketModelC$destNode[__nesc_mote]);
    memset((void *)&TossimPacketModelC$sendEvent[__nesc_mote], 0, sizeof TossimPacketModelC$sendEvent[__nesc_mote]);
    TossimPacketModelC$error[__nesc_mote] = 0;
  
    /* Module CpmModelC */
    memset((void *)&CpmModelC$outgoing[__nesc_mote], 0, sizeof CpmModelC$outgoing[__nesc_mote]);
    memset((void *)&CpmModelC$requestAck[__nesc_mote], 0, sizeof CpmModelC$requestAck[__nesc_mote]);
    CpmModelC$receiving[__nesc_mote] = 0;
    CpmModelC$outstandingReceptionHead[__nesc_mote] = (void *)0;
    CpmModelC$clearThreshold[__nesc_mote] = -72.0;
  
    /* Module ActiveMessageAddressC */
    ActiveMessageAddressC$set[__nesc_mote] = FALSE;
    memset((void *)&ActiveMessageAddressC$addr[__nesc_mote], 0, sizeof ActiveMessageAddressC$addr[__nesc_mote]);
  
    /* Module AMQueueEntryP$0 */
  
    /* Module AMQueueImplP$0 */
    /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$current[__nesc_mote] = 1;
    memset((void *)&/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[__nesc_mote], 0, sizeof /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$queue[__nesc_mote]);
    memset((void *)&/*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[__nesc_mote], 0, sizeof /*AMQueueP.AMQueueImplP*/AMQueueImplP$0$cancelMask[__nesc_mote]);
  
  }
  