#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
# 38 "/opt/msp430/msp430/include/sys/inttypes.h"
typedef signed char int8_t;
typedef unsigned char uint8_t;

typedef int int16_t;
typedef unsigned int uint16_t;

typedef long int32_t;
typedef unsigned long uint32_t;

typedef long long int64_t;
typedef unsigned long long uint64_t;




typedef int16_t intptr_t;
typedef uint16_t uintptr_t;
# 187 "C:/tinyos/cygwin/lib/ncc/nesc_nx.h"
typedef struct { char data[1]; } __attribute__((packed)) nx_int8_t;typedef int8_t  __nesc_nxbase_nx_int8_t;
typedef struct { char data[2]; } __attribute__((packed)) nx_int16_t;typedef int16_t  __nesc_nxbase_nx_int16_t;
typedef struct { char data[4]; } __attribute__((packed)) nx_int32_t;typedef int32_t  __nesc_nxbase_nx_int32_t;
typedef struct { char data[8]; } __attribute__((packed)) nx_int64_t;typedef int64_t  __nesc_nxbase_nx_int64_t;
typedef struct { char data[1]; } __attribute__((packed)) nx_uint8_t;typedef uint8_t  __nesc_nxbase_nx_uint8_t;
typedef struct { char data[2]; } __attribute__((packed)) nx_uint16_t;typedef uint16_t  __nesc_nxbase_nx_uint16_t;
typedef struct { char data[4]; } __attribute__((packed)) nx_uint32_t;typedef uint32_t  __nesc_nxbase_nx_uint32_t;
typedef struct { char data[8]; } __attribute__((packed)) nx_uint64_t;typedef uint64_t  __nesc_nxbase_nx_uint64_t;


typedef struct { char data[1]; } __attribute__((packed)) nxle_int8_t;typedef int8_t  __nesc_nxbase_nxle_int8_t;
typedef struct { char data[2]; } __attribute__((packed)) nxle_int16_t;typedef int16_t  __nesc_nxbase_nxle_int16_t;
typedef struct { char data[4]; } __attribute__((packed)) nxle_int32_t;typedef int32_t  __nesc_nxbase_nxle_int32_t;
typedef struct { char data[8]; } __attribute__((packed)) nxle_int64_t;typedef int64_t  __nesc_nxbase_nxle_int64_t;
typedef struct { char data[1]; } __attribute__((packed)) nxle_uint8_t;typedef uint8_t  __nesc_nxbase_nxle_uint8_t;
typedef struct { char data[2]; } __attribute__((packed)) nxle_uint16_t;typedef uint16_t  __nesc_nxbase_nxle_uint16_t;
typedef struct { char data[4]; } __attribute__((packed)) nxle_uint32_t;typedef uint32_t  __nesc_nxbase_nxle_uint32_t;
typedef struct { char data[8]; } __attribute__((packed)) nxle_uint64_t;typedef uint64_t  __nesc_nxbase_nxle_uint64_t;
# 151 "/opt/msp430/lib/gcc-lib/msp430/3.2.3/include/stddef.h" 3
typedef int ptrdiff_t;
#line 213
typedef unsigned int size_t;
#line 325
typedef int wchar_t;
# 41 "/opt/msp430/msp430/include/sys/types.h"
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;

typedef uint8_t u_int8_t;
typedef uint16_t u_int16_t;
typedef uint32_t u_int32_t;
typedef uint64_t u_int64_t;

typedef u_int64_t u_quad_t;
typedef int64_t quad_t;
typedef quad_t *qaddr_t;

typedef char *caddr_t;
typedef const char *c_caddr_t;
typedef volatile char *v_caddr_t;
typedef u_int32_t fixpt_t;
typedef u_int32_t gid_t;
typedef u_int32_t in_addr_t;
typedef u_int16_t in_port_t;
typedef u_int32_t ino_t;
typedef long key_t;
typedef u_int16_t mode_t;
typedef u_int16_t nlink_t;
typedef quad_t rlim_t;
typedef int32_t segsz_t;
typedef int32_t swblk_t;
typedef int32_t ufs_daddr_t;
typedef int32_t ufs_time_t;
typedef u_int32_t uid_t;
# 43 "/opt/msp430/msp430/include/string.h"
extern char *strcat(char *, const char *);

extern int strcmp(const char *, const char *);
extern char *strcpy(char *, const char *);
extern int strcasecmp(const char *, const char *);
extern size_t strlen(const char *);
#line 64
extern void bzero(void *, size_t );
# 59 "/opt/msp430/msp430/include/stdlib.h"
#line 56
typedef struct __nesc_unnamed4242 {
  int quot;
  int rem;
} div_t;







#line 64
typedef struct __nesc_unnamed4243 {
  long quot;
  long rem;
} ldiv_t;






extern __inline int __attribute((const)) abs(int __x);

#line 75
extern __inline int 
abs(int __x);
#line 95
char *itoa(int num, char *str, int radix);
# 122 "/opt/msp430/msp430/include/sys/config.h" 3
typedef long int __int32_t;
typedef unsigned long int __uint32_t;
# 12 "/opt/msp430/msp430/include/sys/_types.h"
typedef long _off_t;
typedef long _ssize_t;
# 28 "/opt/msp430/msp430/include/sys/reent.h" 3
typedef __uint32_t __ULong;


struct _glue {

  struct _glue *_next;
  int _niobs;
  struct __sFILE *_iobs;
};

struct _Bigint {

  struct _Bigint *_next;
  int _k, _maxwds, _sign, _wds;
  __ULong _x[1];
};


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;
};







struct _atexit {
  struct _atexit *_next;
  int _ind;
  void (*_fns[32])(void );
};








struct __sbuf {
  unsigned char *_base;
  int _size;
};






typedef long _fpos_t;
#line 116
struct __sFILE {
  unsigned char *_p;
  int _r;
  int _w;
  short _flags;
  short _file;
  struct __sbuf _bf;
  int _lbfsize;


  void *_cookie;

  int (*_read)(void *_cookie, char *_buf, int _n);
  int (*_write)(void *_cookie, const char *_buf, int _n);

  _fpos_t (*_seek)(void *_cookie, _fpos_t _offset, int _whence);
  int (*_close)(void *_cookie);


  struct __sbuf _ub;
  unsigned char *_up;
  int _ur;


  unsigned char _ubuf[3];
  unsigned char _nbuf[1];


  struct __sbuf _lb;


  int _blksize;
  int _offset;

  struct _reent *_data;
};
#line 174
struct _rand48 {
  unsigned short _seed[3];
  unsigned short _mult[3];
  unsigned short _add;
};









struct _reent {


  int _errno;




  struct __sFILE *_stdin, *_stdout, *_stderr;

  int _inc;
  char _emergency[25];

  int _current_category;
  const char *_current_locale;

  int __sdidinit;

  void (*__cleanup)(struct _reent *);


  struct _Bigint *_result;
  int _result_k;
  struct _Bigint *_p5s;
  struct _Bigint **_freelist;


  int _cvtlen;
  char *_cvtbuf;

  union __nesc_unnamed4244 {

    struct __nesc_unnamed4245 {

      unsigned int _unused_rand;
      char *_strtok_last;
      char _asctime_buf[26];
      struct __tm _localtime_buf;
      int _gamma_signgam;
      __extension__ unsigned long long _rand_next;
      struct _rand48 _r48;
    } _reent;



    struct __nesc_unnamed4246 {


      unsigned char *_nextf[30];
      unsigned int _nmalloc[30];
    } _unused;
  } _new;


  struct _atexit *_atexit;
  struct _atexit _atexit0;


  void (**_sig_func)(int );




  struct _glue __sglue;
  struct __sFILE __sf[3];
};
#line 273
struct _reent;
# 18 "/opt/msp430/msp430/include/math.h"
union __dmath {

  __uint32_t i[2];
  double d;
};




union __dmath;
#line 208
struct exception {


  int type;
  char *name;
  double arg1;
  double arg2;
  double retval;
  int err;
};
#line 261
enum __fdlibm_version {

  __fdlibm_ieee = -1, 
  __fdlibm_svid, 
  __fdlibm_xopen, 
  __fdlibm_posix
};




enum __fdlibm_version;
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
typedef unsigned char bool;






enum __nesc_unnamed4247 {
  FALSE = 0, 
  TRUE = 1
};

uint16_t TOS_LOCAL_ADDRESS = 1;

enum __nesc_unnamed4248 {
  FAIL = 0, 
  SUCCESS = 1
};


static inline uint8_t rcombine(uint8_t r1, uint8_t r2);
typedef uint8_t  result_t;







static inline result_t rcombine(result_t r1, result_t r2);







static inline result_t rcombine3(result_t r1, result_t r2, result_t r3);




static inline result_t rcombine4(result_t r1, result_t r2, result_t r3, 
result_t r4);





enum __nesc_unnamed4249 {
  NULL = 0x0
};
# 39 "/opt/msp430/msp430/include/msp430/iostructures.h"
#line 27
typedef union port {
  volatile unsigned char reg_p;
  volatile struct __nesc_unnamed4250 {
    unsigned char __p0 : 1, 
    __p1 : 1, 
    __p2 : 1, 
    __p3 : 1, 
    __p4 : 1, 
    __p5 : 1, 
    __p6 : 1, 
    __p7 : 1;
  } __pin;
} __attribute((packed))  ioregister_t;
# 106 "/opt/msp430/msp430/include/msp430/iostructures.h" 3
struct port_full_t {
  ioregister_t in;
  ioregister_t out;
  ioregister_t dir;
  ioregister_t ifg;
  ioregister_t ies;
  ioregister_t ie;
  ioregister_t sel;
};




struct port_simple_t {
  ioregister_t in;
  ioregister_t out;
  ioregister_t dir;
  ioregister_t sel;
};




struct port_full_t;



struct port_full_t;



struct port_simple_t;



struct port_simple_t;



struct port_simple_t;



struct port_simple_t;
# 103 "/opt/msp430/msp430/include/msp430/gpio.h" 3
volatile unsigned char P1OUT __asm ("0x0021");

volatile unsigned char P1DIR __asm ("0x0022");



volatile unsigned char P1IES __asm ("0x0024");

volatile unsigned char P1IE __asm ("0x0025");

volatile unsigned char P1SEL __asm ("0x0026");






volatile unsigned char P2OUT __asm ("0x0029");

volatile unsigned char P2DIR __asm ("0x002A");





volatile unsigned char P2IE __asm ("0x002D");

volatile unsigned char P2SEL __asm ("0x002E");






volatile unsigned char P3OUT __asm ("0x0019");

volatile unsigned char P3DIR __asm ("0x001A");

volatile unsigned char P3SEL __asm ("0x001B");






volatile unsigned char P4OUT __asm ("0x001D");

volatile unsigned char P4DIR __asm ("0x001E");

volatile unsigned char P4SEL __asm ("0x001F");






volatile unsigned char P5OUT __asm ("0x0031");

volatile unsigned char P5DIR __asm ("0x0032");

volatile unsigned char P5SEL __asm ("0x0033");






volatile unsigned char P6OUT __asm ("0x0035");

volatile unsigned char P6DIR __asm ("0x0036");

volatile unsigned char P6SEL __asm ("0x0037");
# 85 "/opt/msp430/msp430/include/msp430/usart.h"
volatile unsigned char U0CTL __asm ("0x0070");

volatile unsigned char U0TCTL __asm ("0x0071");



volatile unsigned char U0MCTL __asm ("0x0073");

volatile unsigned char U0BR0 __asm ("0x0074");

volatile unsigned char U0BR1 __asm ("0x0075");

volatile unsigned char U0RXBUF __asm ("0x0076");
#line 254
volatile unsigned char U1CTL __asm ("0x0078");

volatile unsigned char U1TCTL __asm ("0x0079");

volatile unsigned char U1RCTL __asm ("0x007A");

volatile unsigned char U1MCTL __asm ("0x007B");

volatile unsigned char U1BR0 __asm ("0x007C");

volatile unsigned char U1BR1 __asm ("0x007D");

volatile unsigned char U1RXBUF __asm ("0x007E");
# 22 "/opt/msp430/msp430/include/msp430/flash.h"
volatile unsigned int FCTL3 __asm ("0x012C");
# 22 "/opt/msp430/msp430/include/msp430/timera.h"
volatile unsigned int TA0IV __asm ("0x012E");

volatile unsigned int TA0CTL __asm ("0x0160");







volatile unsigned int TA0R __asm ("0x0170");
# 114 "/opt/msp430/msp430/include/msp430/timera.h" 3
#line 105
typedef struct __nesc_unnamed4251 {
  volatile unsigned 
  taifg : 1, 
  taie : 1, 
  taclr : 1, 
  dummy : 1, 
  tamc : 2, 
  taid : 2, 
  tassel : 2;
} __attribute((packed))  tactl_t;
#line 130
#line 116
typedef struct __nesc_unnamed4252 {
  volatile unsigned 
  ccifg : 1, 
  cov : 1, 
  out : 1, 
  cci : 1, 
  ccie : 1, 
  outmod : 3, 
  cap : 1, 
  dummy : 1, 
  scci : 1, 
  scs : 1, 
  ccis : 2, 
  cm : 2;
} __attribute((packed))  tacctl_t;


struct timera_t {
  tactl_t ctl;
  tacctl_t cctl0;
  tacctl_t cctl1;
  tacctl_t cctl2;
  volatile unsigned dummy[4];
  volatile unsigned tar;
  volatile unsigned taccr0;
  volatile unsigned taccr1;
  volatile unsigned taccr2;
};



struct timera_t;
# 22 "/opt/msp430/msp430/include/msp430/timerb.h"
volatile unsigned int TBIV __asm ("0x011E");

volatile unsigned int TBCTL __asm ("0x0180");

volatile unsigned int TBCCTL0 __asm ("0x0182");





volatile unsigned int TBR __asm ("0x0190");

volatile unsigned int TBCCR0 __asm ("0x0192");
#line 75
#line 63
typedef struct __nesc_unnamed4253 {
  volatile unsigned 
  tbifg : 1, 
  tbie : 1, 
  tbclr : 1, 
  dummy1 : 1, 
  tbmc : 2, 
  tbid : 2, 
  tbssel : 2, 
  dummy2 : 1, 
  tbcntl : 2, 
  tbclgrp : 2;
} __attribute((packed))  tbctl_t;
#line 90
#line 77
typedef struct __nesc_unnamed4254 {
  volatile unsigned 
  ccifg : 1, 
  cov : 1, 
  out : 1, 
  cci : 1, 
  ccie : 1, 
  outmod : 3, 
  cap : 1, 
  clld : 2, 
  scs : 1, 
  ccis : 2, 
  cm : 2;
} __attribute((packed))  tbcctl_t;


struct timerb_t {
  tbctl_t ctl;
  tbcctl_t cctl0;
  tbcctl_t cctl1;
  tbcctl_t cctl2;

  tbcctl_t cctl3;
  tbcctl_t cctl4;
  tbcctl_t cctl5;
  tbcctl_t cctl6;



  volatile unsigned tbr;
  volatile unsigned tbccr0;
  volatile unsigned tbccr1;
  volatile unsigned tbccr2;

  volatile unsigned tbccr3;
  volatile unsigned tbccr4;
  volatile unsigned tbccr5;
  volatile unsigned tbccr6;
};





struct timerb_t;
# 18 "/opt/msp430/msp430/include/msp430/basic_clock.h"
volatile unsigned char DCOCTL __asm ("0x0056");

volatile unsigned char BCSCTL1 __asm ("0x0057");

volatile unsigned char BCSCTL2 __asm ("0x0058");
# 18 "/opt/msp430/msp430/include/msp430/adc12.h"
volatile unsigned int ADC12CTL0 __asm ("0x01A0");

volatile unsigned int ADC12CTL1 __asm ("0x01A2");
#line 42
#line 30
typedef struct __nesc_unnamed4255 {
  volatile unsigned 
  adc12sc : 1, 
  enc : 1, 
  adc12tovie : 1, 
  adc12ovie : 1, 
  adc12on : 1, 
  refon : 1, 
  r2_5v : 1, 
  msc : 1, 
  sht0 : 4, 
  sht1 : 4;
} __attribute((packed))  adc12ctl0_t;
#line 54
#line 44
typedef struct __nesc_unnamed4256 {
  volatile unsigned 
  adc12busy : 1, 
  conseq : 2, 
  adc12ssel : 2, 
  adc12div : 3, 
  issh : 1, 
  shp : 1, 
  shs : 2, 
  cstartadd : 4;
} __attribute((packed))  adc12ctl1_t;
#line 74
#line 56
typedef struct __nesc_unnamed4257 {
  volatile unsigned 
  bit0 : 1, 
  bit1 : 1, 
  bit2 : 1, 
  bit3 : 1, 
  bit4 : 1, 
  bit5 : 1, 
  bit6 : 1, 
  bit7 : 1, 
  bit8 : 1, 
  bit9 : 1, 
  bit10 : 1, 
  bit11 : 1, 
  bit12 : 1, 
  bit13 : 1, 
  bit14 : 1, 
  bit15 : 1;
} __attribute((packed))  adc12xflg_t;


struct adc12_t {
  adc12ctl0_t ctl0;
  adc12ctl1_t ctl1;
  adc12xflg_t ifg;
  adc12xflg_t ie;
  adc12xflg_t iv;
};




struct adc12_t;
# 53 "/opt/msp430/msp430/include/msp430x16x.h"
volatile unsigned char IFG1 __asm ("0x0002");







volatile unsigned char IE2 __asm ("0x0001");









volatile unsigned char ME1 __asm ("0x0004");





volatile unsigned char ME2 __asm ("0x0005");
# 148 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430hardware.h"
 static volatile uint8_t U0CTLnr __asm ("0x0070");
 static volatile uint8_t I2CTCTLnr __asm ("0x0071");
 static volatile uint8_t I2CDCTLnr __asm ("0x0072");










static __inline void TOSH_wait(void );
#line 174
static __inline void TOSH_uwait(uint16_t u);
#line 196
static inline void __nesc_disable_interrupt(void);





static inline void __nesc_enable_interrupt(void);




static inline bool are_interrupts_enabled(void);




typedef bool __nesc_atomic_t;

static inline __nesc_atomic_t __nesc_atomic_start(void );
static inline void __nesc_atomic_end(__nesc_atomic_t oldSreg);



static inline __nesc_atomic_t __nesc_atomic_start(void );






static inline void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts);








 bool LPMode_disabled = FALSE;









static __inline void __nesc_atomic_sleep(void);
# 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12.h"
#line 105
typedef struct __nesc_unnamed4258 {

  unsigned int refVolt2_5 : 1;
  unsigned int clockSourceSHT : 2;
  unsigned int clockSourceSAMPCON : 2;
  unsigned int clockDivSAMPCON : 2;
  unsigned int referenceVoltage : 3;
  unsigned int clockDivSHT : 3;
  unsigned int inputChannel : 4;
  unsigned int sampleHoldTime : 4;
  unsigned int  : 0;
} MSP430ADC12Settings_t;






#line 118
typedef enum __nesc_unnamed4259 {

  MSP430ADC12_FAIL = 0, 
  MSP430ADC12_SUCCESS = 1, 
  MSP430ADC12_DELAYED = 2
} msp430ADCresult_t;

enum refVolt2_5_enum {

  REFVOLT_LEVEL_1_5 = 0, 
  REFVOLT_LEVEL_2_5 = 1
};

enum clockDivSHT_enum {

  SHT_CLOCK_DIV_1 = 0, 
  SHT_CLOCK_DIV_2 = 1, 
  SHT_CLOCK_DIV_3 = 2, 
  SHT_CLOCK_DIV_4 = 3, 
  SHT_CLOCK_DIV_5 = 4, 
  SHT_CLOCK_DIV_6 = 5, 
  SHT_CLOCK_DIV_7 = 6, 
  SHT_CLOCK_DIV_8 = 7
};

enum clockDivSAMPCON_enum {

  SAMPCON_CLOCK_DIV_1 = 0, 
  SAMPCON_CLOCK_DIV_2 = 1, 
  SAMPCON_CLOCK_DIV_3 = 2, 
  SAMPCON_CLOCK_DIV_4 = 3
};

enum clockSourceSAMPCON_enum {

  SAMPCON_SOURCE_TACLK = 0, 
  SAMPCON_SOURCE_ACLK = 1, 
  SAMPCON_SOURCE_SMCLK = 2, 
  SAMPCON_SOURCE_INCLK = 3
};

enum inputChannel_enum {


  INPUT_CHANNEL_A0 = 0, 
  INPUT_CHANNEL_A1 = 1, 
  INPUT_CHANNEL_A2 = 2, 
  INPUT_CHANNEL_A3 = 3, 
  INPUT_CHANNEL_A4 = 4, 
  INPUT_CHANNEL_A5 = 5, 
  INPUT_CHANNEL_A6 = 6, 
  INPUT_CHANNEL_A7 = 7, 
  EXTERNAL_REFERENCE_VOLTAGE = 8, 
  REFERENCE_VOLTAGE_NEGATIVE_TERMINAL = 9, 
  INTERNAL_TEMPERATURE = 10, 
  INTERNAL_VOLTAGE = 11
};

enum referenceVoltage_enum {

  REFERENCE_AVcc_AVss = 0, 
  REFERENCE_VREFplus_AVss = 1, 
  REFERENCE_VeREFplus_AVss = 2, 
  REFERENCE_AVcc_VREFnegterm = 4, 
  REFERENCE_VREFplus_VREFnegterm = 5, 
  REFERENCE_VeREFplus_VREFnegterm = 6
};

enum clockSourceSHT_enum {

  SHT_SOURCE_ADC12OSC = 0, 
  SHT_SOURCE_ACLK = 1, 
  SHT_SOURCE_MCLK = 2, 
  SHT_SOURCE_SMCLK = 3
};

enum sampleHold_enum {

  SAMPLE_HOLD_4_CYCLES = 0, 
  SAMPLE_HOLD_8_CYCLES = 1, 
  SAMPLE_HOLD_16_CYCLES = 2, 
  SAMPLE_HOLD_32_CYCLES = 3, 
  SAMPLE_HOLD_64_CYCLES = 4, 
  SAMPLE_HOLD_96_CYCLES = 5, 
  SAMPLE_HOLD_123_CYCLES = 6, 
  SAMPLE_HOLD_192_CYCLES = 7, 
  SAMPLE_HOLD_256_CYCLES = 8, 
  SAMPLE_HOLD_384_CYCLES = 9, 
  SAMPLE_HOLD_512_CYCLES = 10, 
  SAMPLE_HOLD_768_CYCLES = 11, 
  SAMPLE_HOLD_1024_CYCLES = 12
};









#line 216
typedef union __nesc_unnamed4260 {
  uint32_t i;
  MSP430ADC12Settings_t s;
} MSP430ADC12Settings_ut;


static __inline MSP430ADC12Settings_t int2adcSettings(uint32_t i);





enum __nesc_unnamed4261 {

  ADC_IDLE = 0, 
  SINGLE_CHANNEL = 1, 
  REPEAT_SINGLE_CHANNEL = 2, 
  SEQUENCE_OF_CHANNELS = 4, 
  REPEAT_SEQUENCE_OF_CHANNELS = 8, 
  TIMER_USED = 16, 
  RESERVED = 32, 
  VREF_WAIT = 64
};
#line 261
#line 255
typedef struct __nesc_unnamed4262 {

  volatile unsigned 
  inch : 4, 
  sref : 3, 
  eos : 1;
} __attribute((packed))  adc12memctl_t;
#line 274
#line 263
typedef struct __nesc_unnamed4263 {

  unsigned int refVolt2_5 : 1;
  unsigned int gotRefVolt : 1;
  unsigned int result_16bit : 1;
  unsigned int clockSourceSHT : 2;
  unsigned int clockSourceSAMPCON : 2;
  unsigned int clockDivSAMPCON : 2;
  unsigned int clockDivSHT : 3;
  unsigned int sampleHoldTime : 4;
  adc12memctl_t memctl;
} __attribute((packed))  adc12settings_t;
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420Const.h"
enum __nesc_unnamed4264 {
  CC2420_TIME_BIT = 4, 
  CC2420_TIME_BYTE = CC2420_TIME_BIT << 3, 
  CC2420_TIME_SYMBOL = 16
};










uint8_t CC2420_CHANNEL = 11;
uint8_t CC2420_RFPOWER = 0x1F;

enum __nesc_unnamed4265 {
  CC2420_MIN_CHANNEL = 11, 
  CC2420_MAX_CHANNEL = 26
};
#line 261
enum __nesc_unnamed4266 {
  CP_MAIN = 0, 
  CP_MDMCTRL0, 
  CP_MDMCTRL1, 
  CP_RSSI, 
  CP_SYNCWORD, 
  CP_TXCTRL, 
  CP_RXCTRL0, 
  CP_RXCTRL1, 
  CP_FSCTRL, 
  CP_SECCTRL0, 
  CP_SECCTRL1, 
  CP_BATTMON, 
  CP_IOCFG0, 
  CP_IOCFG1
};
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/AM.h"
enum __nesc_unnamed4267 {
  TOS_BCAST_ADDR = 0xffff, 
  TOS_UART_ADDR = 0x007e
};





enum __nesc_unnamed4268 {
  TOS_DEFAULT_AM_GROUP = 0x7d
};

uint8_t TOS_AM_GROUP = TOS_DEFAULT_AM_GROUP;
#line 96
#line 72
typedef struct TOS_Msg {


  uint8_t length;
  uint8_t fcfhi;
  uint8_t fcflo;
  uint8_t dsn;
  uint16_t destpan;
  uint16_t addr;
  uint8_t type;
  uint8_t group;
  int8_t data[89];







  uint8_t strength;
  uint8_t lqi;
  bool crc;
  bool ack;
  uint16_t time;
} __attribute((packed))  TOS_Msg;

enum __nesc_unnamed4269 {

  MSG_HEADER_SIZE = (size_t )& ((struct TOS_Msg *)0)->data - 1, 

  MSG_FOOTER_SIZE = 2, 

  MSG_DATA_SIZE = (size_t )& ((struct TOS_Msg *)0)->strength + sizeof(uint16_t ), 

  DATA_LENGTH = 89, 

  LENGTH_BYTE_NUMBER = (size_t )& ((struct TOS_Msg *)0)->length + 1
};

typedef TOS_Msg *TOS_MsgPtr;
# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SET_RED_LED_PIN(void);
#line 12
static inline void TOSH_CLR_RED_LED_PIN(void);
static inline void TOSH_SET_GREEN_LED_PIN(void);
#line 13
static inline void TOSH_CLR_GREEN_LED_PIN(void);
static inline void TOSH_SET_YELLOW_LED_PIN(void);
#line 14
static inline void TOSH_CLR_YELLOW_LED_PIN(void);


static inline void TOSH_SET_RADIO_CSN_PIN(void);
#line 17
static inline void TOSH_CLR_RADIO_CSN_PIN(void);
#line 17
static inline void TOSH_MAKE_RADIO_CSN_OUTPUT(void);







static inline uint8_t TOSH_READ_RADIO_CCA_PIN(void);

static inline uint8_t TOSH_READ_CC_FIFOP_PIN(void);
static inline uint8_t TOSH_READ_CC_FIFO_PIN(void);
static inline uint8_t TOSH_READ_CC_SFD_PIN(void);
#line 29
static inline void TOSH_SEL_CC_SFD_MODFUNC(void);
#line 29
static inline void TOSH_SEL_CC_SFD_IOFUNC(void);
static inline void TOSH_SET_CC_VREN_PIN(void);
#line 30
static inline void TOSH_CLR_CC_VREN_PIN(void);
static inline void TOSH_SET_CC_RSTN_PIN(void);
#line 31
static inline void TOSH_CLR_CC_RSTN_PIN(void);


static inline void TOSH_SEL_SOMI0_MODFUNC(void);
#line 34
static inline void TOSH_SEL_SOMI0_IOFUNC(void);
static inline void TOSH_SET_SIMO0_PIN(void);
#line 35
static inline void TOSH_CLR_SIMO0_PIN(void);
#line 35
static inline void TOSH_MAKE_SIMO0_OUTPUT(void);
#line 35
static inline void TOSH_MAKE_SIMO0_INPUT(void);
#line 35
static inline void TOSH_SEL_SIMO0_MODFUNC(void);
#line 35
static inline void TOSH_SEL_SIMO0_IOFUNC(void);
static inline void TOSH_SET_UCLK0_PIN(void);
#line 36
static inline void TOSH_CLR_UCLK0_PIN(void);
#line 36
static inline void TOSH_MAKE_UCLK0_OUTPUT(void);
#line 36
static inline void TOSH_MAKE_UCLK0_INPUT(void);
#line 36
static inline void TOSH_SEL_UCLK0_MODFUNC(void);
#line 36
static inline void TOSH_SEL_UCLK0_IOFUNC(void);
static inline void TOSH_SEL_UTXD0_IOFUNC(void);
#line 37
static inline bool TOSH_IS_UTXD0_MODFUNC(void);
#line 37
static inline bool TOSH_IS_UTXD0_IOFUNC(void);
static inline void TOSH_SEL_URXD0_IOFUNC(void);
#line 38
static inline bool TOSH_IS_URXD0_MODFUNC(void);
#line 38
static inline bool TOSH_IS_URXD0_IOFUNC(void);
static inline void TOSH_SEL_UTXD1_MODFUNC(void);
#line 39
static inline void TOSH_SEL_UTXD1_IOFUNC(void);
#line 39
static inline bool TOSH_IS_UTXD1_MODFUNC(void);
#line 39
static inline bool TOSH_IS_UTXD1_IOFUNC(void);
static inline void TOSH_SEL_URXD1_MODFUNC(void);
#line 40
static inline void TOSH_SEL_URXD1_IOFUNC(void);
#line 40
static inline bool TOSH_IS_URXD1_MODFUNC(void);
#line 40
static inline bool TOSH_IS_URXD1_IOFUNC(void);
static inline void TOSH_SEL_UCLK1_IOFUNC(void);
static inline void TOSH_SEL_SOMI1_IOFUNC(void);
static inline void TOSH_SEL_SIMO1_IOFUNC(void);
#line 71
static inline void TOSH_SET_FLASH_CS_PIN(void);
#line 71
static inline void TOSH_CLR_FLASH_CS_PIN(void);
#line 71
static inline void TOSH_MAKE_FLASH_CS_OUTPUT(void);
static inline void TOSH_SET_FLASH_HOLD_PIN(void);
#line 72
static inline void TOSH_CLR_FLASH_HOLD_PIN(void);
#line 72
static inline void TOSH_MAKE_FLASH_HOLD_OUTPUT(void);










static inline void TOSH_FLASH_M25P_DP_bit(bool set);










static inline void TOSH_FLASH_M25P_DP(void);
#line 129
static inline void TOSH_SET_PIN_DIRECTIONS(void );
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/types/dbg_modes.h"
typedef long long TOS_dbg_mode;



enum __nesc_unnamed4270 {
  DBG_ALL = ~0ULL, 


  DBG_BOOT = 1ULL << 0, 
  DBG_CLOCK = 1ULL << 1, 
  DBG_TASK = 1ULL << 2, 
  DBG_SCHED = 1ULL << 3, 
  DBG_SENSOR = 1ULL << 4, 
  DBG_LED = 1ULL << 5, 
  DBG_CRYPTO = 1ULL << 6, 


  DBG_ROUTE = 1ULL << 7, 
  DBG_AM = 1ULL << 8, 
  DBG_CRC = 1ULL << 9, 
  DBG_PACKET = 1ULL << 10, 
  DBG_ENCODE = 1ULL << 11, 
  DBG_RADIO = 1ULL << 12, 


  DBG_LOG = 1ULL << 13, 
  DBG_ADC = 1ULL << 14, 
  DBG_I2C = 1ULL << 15, 
  DBG_UART = 1ULL << 16, 
  DBG_PROG = 1ULL << 17, 
  DBG_SOUNDER = 1ULL << 18, 
  DBG_TIME = 1ULL << 19, 
  DBG_POWER = 1ULL << 20, 



  DBG_SIM = 1ULL << 21, 
  DBG_QUEUE = 1ULL << 22, 
  DBG_SIMRADIO = 1ULL << 23, 
  DBG_HARD = 1ULL << 24, 
  DBG_MEM = 1ULL << 25, 



  DBG_USR1 = 1ULL << 27, 
  DBG_USR2 = 1ULL << 28, 
  DBG_USR3 = 1ULL << 29, 
  DBG_TEMP = 1ULL << 30, 

  DBG_ERROR = 1ULL << 31, 
  DBG_NONE = 0, 

  DBG_DEFAULT = DBG_ALL
};
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"
#line 59
typedef struct __nesc_unnamed4271 {
  void (*tp)(void);
} TOSH_sched_entry_T;

enum __nesc_unnamed4272 {






  TOSH_MAX_TASKS = 8, 

  TOSH_TASK_BITMASK = TOSH_MAX_TASKS - 1
};

volatile TOSH_sched_entry_T TOSH_queue[TOSH_MAX_TASKS];
uint8_t TOSH_sched_full;
volatile uint8_t TOSH_sched_free;

static inline void TOSH_sched_init(void );








bool TOS_post(void (*tp)(void));
#line 102
bool  TOS_post(void (*tp)(void));
#line 136
static inline bool TOSH_run_next_task(void);
#line 159
static inline void TOSH_run_task(void);
# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static void *nmemcpy(void *to, const void *from, size_t n);









static inline void *nmemset(void *to, int val, size_t n);
# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/Ident.h"
enum __nesc_unnamed4273 {

  IDENT_MAX_PROGRAM_NAME_LENGTH = 16
};






#line 33
typedef struct __nesc_unnamed4274 {

  uint32_t unix_time;
  uint32_t user_hash;
  char program_name[IDENT_MAX_PROGRAM_NAME_LENGTH];
} Ident_t;
# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.h"
enum __nesc_unnamed4275 {
  MSP430TIMER_CM_NONE = 0, 
  MSP430TIMER_CM_RISING = 1, 
  MSP430TIMER_CM_FALLING = 2, 
  MSP430TIMER_CM_BOTH = 3, 

  MSP430TIMER_STOP_MODE = 0, 
  MSP430TIMER_UP_MODE = 1, 
  MSP430TIMER_CONTINUOUS_MODE = 2, 
  MSP430TIMER_UPDOWN_MODE = 3, 

  MSP430TIMER_TACLK = 0, 
  MSP430TIMER_TBCLK = 0, 
  MSP430TIMER_ACLK = 1, 
  MSP430TIMER_SMCLK = 2, 
  MSP430TIMER_INCLK = 3, 

  MSP430TIMER_CLOCKDIV_1 = 0, 
  MSP430TIMER_CLOCKDIV_2 = 1, 
  MSP430TIMER_CLOCKDIV_4 = 2, 
  MSP430TIMER_CLOCKDIV_8 = 3
};
#line 64
#line 51
typedef struct __nesc_unnamed4276 {

  int ccifg : 1;
  int cov : 1;
  int out : 1;
  int cci : 1;
  int ccie : 1;
  int outmod : 3;
  int cap : 1;
  int clld : 2;
  int scs : 1;
  int ccis : 2;
  int cm : 2;
} MSP430CompareControl_t;
#line 76
#line 66
typedef struct __nesc_unnamed4277 {

  int taifg : 1;
  int taie : 1;
  int taclr : 1;
  int _unused0 : 1;
  int mc : 2;
  int id : 2;
  int tassel : 2;
  int _unused1 : 6;
} MSP430TimerAControl_t;
#line 91
#line 78
typedef struct __nesc_unnamed4278 {

  int tbifg : 1;
  int tbie : 1;
  int tbclr : 1;
  int _unused0 : 1;
  int mc : 2;
  int id : 2;
  int tbssel : 2;
  int _unused1 : 1;
  int cntl : 2;
  int tbclgrp : 2;
  int _unused2 : 1;
} MSP430TimerBControl_t;
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SchemaType.h"
#line 48
typedef enum __nesc_unnamed4279 {
  SCHEMA_SUCCESS = 0, 
  SCHEMA_ERROR, 
  SCHEMA_RESULT_READY, 
  SCHEMA_RESULT_NULL, 
  SCHEMA_RESULT_PENDING
} SchemaErrorNo;
#line 68
#line 56
typedef enum __nesc_unnamed4280 {
  VOID = 0, 
  INT8 = 1, 
  UINT8 = 2, 
  INT16 = 3, 
  UINT16 = 4, 
  INT32 = 5, 
  UINT32 = 6, 
  TIMESTAMP = 7, 
  STRING = 8, 
  BYTES = 9, 
  COMPLEX_TYPE = 10
} TOSType;


static 
#line 70
short 
sizeOf(TOSType type);
#line 106
struct CommandMsg {
  short nodeid;
  uint32_t seqNo;
  char data[0];
};
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Attr.h"
enum __nesc_unnamed4281 {

  MAX_ATTRS = 6U, 








  MAX_CONST_LEN = 4, 
  MAX_CONST_ATTRS = 1
};









#line 75
typedef struct __nesc_unnamed4282 {
  TOSType type;
  uint8_t nbytes;
  uint8_t idx;
  uint8_t id;
  int8_t constIdx;
  char *name;
} AttrDesc;

typedef AttrDesc *AttrDescPtr;




#line 86
typedef struct __nesc_unnamed4283 {
  uint8_t numAttrs;
  AttrDesc attrDesc[MAX_ATTRS];
} AttrDescs;

typedef AttrDescs *AttrDescsPtr;
# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.h"
#line 35
typedef enum __nesc_unnamed4284 {
  EvictOldestPolicy = 0
} BufferPolicy;



enum __nesc_unnamed4285 {
  kRADIO_BUFFER = 0, 
  kEEPROM_START_OFFSET = 2000
};










#line 46
typedef enum __nesc_unnamed4286 {
  kRADIO = 0, 
  kRAM = 1, 
  kEEPROM = 2, 
  kCOMMAND = 3, 
  kATTRLIST = 4, 
  kCOMMANDLIST = 5, 
  kEVENTLIST = 6, 
  kQUERYLIST = 7
} BufferType;
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDB.h"
static inline uint8_t combine_tdberr(uint8_t r1, uint8_t r2);
typedef uint8_t  TinyDBError;





enum __nesc_unnamed4287 {
  err_NoError = 1, 
  err_UnknownError = 0, 
  err_OutOfMemory = 2, 
  err_UnknownAllocationState = 3, 
  err_InvalidGetDataCommand = 4, 
  err_InvalidAggregateRecord = 5, 
  err_NoMoreResults = 6, 
  err_MessageBufferInUse = 7, 
  err_MessageSendFailed = 8, 
  err_RemoveFailedRouterBusy = 9, 
  err_MessageBufferFull = 10, 
  err_MSF_DelMsg = 11, 
  err_MSF_DelMsgBusy = 12, 
  err_MSF_ForwardKnownQuery = 13, 
  err_MSF_ForwardKnownQueryBusy = 14, 
  err_MSF_ForwardNewQuery = 15, 
  err_MSF_ForwardNewQueryBusy = 16, 
  err_MSF_SendWaiting = 17, 
  err_MSF_SendWaitingBusy = 18, 
  err_InvalidIndex = 19, 
  err_UnsupportedPolicy = 20, 
  err_ResultBufferInUse = 21, 
  err_ResultBufferBusy = 22, 
  err_UnknownCommand = 23, 
  err_UnsupportedBuffer = 24, 
  err_IndexOutOfBounds = 25, 
  err_InvalidQueryId = 26, 
  err_AlreadyTupleResult = 27, 
  err_InvalidResultType = 29, 
  err_UnknownAttribute = 30, 
  err_Typecheck = 31, 
  err_NoUnnamedEepromBuffers = 32, 
  err_EepromFailure = 33, 
  err_BufferNotOpen = 34, 
  err_BufferOpenForWriting = 35, 
  err_NoMatchbox = 36
};


static inline TinyDBError combine_tdberr(TinyDBError r1, TinyDBError r2);
#line 153
#line 146
typedef struct __nesc_unnamed4288 {
  uint8_t qid;
  char numFields;
  long notNull;


  char fields[0];
} Tuple;
#line 153
#line 146
typedef struct __nesc_unnamed4288 *






TuplePtr;
#line 153
#line 146
typedef struct __nesc_unnamed4288 **






TupleHandle;


enum __nesc_unnamed4289 {
#line 156
  QUERY_FIELD_SIZE = 8, 
  COMMAND_SIZE = 8, 
  STRING_SIZE = 8
};






#line 161
typedef struct __nesc_unnamed4290 {
  char name[QUERY_FIELD_SIZE];
  uint8_t op;
  uint8_t type;
} 
Field;
#line 166
#line 161
typedef struct __nesc_unnamed4290 *




FieldPtr;









#line 172
typedef struct __nesc_unnamed4291 {
  char name[COMMAND_SIZE];
  bool hasParam;
  short param;
} CmdBufInfo;









#line 178
typedef struct __nesc_unnamed4292 {
  bool hasOutput : 1;
  bool hasInput : 1;
  bool create : 1;
  uint16_t numRows : 13;
  char outBufName[STRING_SIZE];
  char inBufName[STRING_SIZE];
  BufferPolicy policy;
} RamBufInfo;




#line 188
typedef union __nesc_unnamed4293 {
  CmdBufInfo cmd;
  RamBufInfo ram;
} BufInfo;





#line 193
typedef struct __nesc_unnamed4294 {
  uint16_t group;

  char *data;
} AggResultRef;

enum __nesc_unnamed4295 {
  kMAX_RESULTS = 4, 
  AGG_DATA_LEN = 68
};
#line 226
#line 206
typedef struct QueryResult {
  uint8_t qid;
  int8_t result_idx;
  uint16_t epoch;
  uint8_t qrType;

  uint8_t timeSyncData[5];
  int16_t clockCount;
  int16_t lastDiff;
  union __nesc_unnamed4296 {
    Tuple t;
    char data[AGG_DATA_LEN];





    AggResultRef buf[kMAX_RESULTS];
  } d;
} 
QueryResult;
#line 226
#line 206
typedef struct QueryResult *
#line 226
QueryResultPtr;









#line 232
typedef struct __nesc_unnamed4297 {
  char *data;
} 

QueryTableInfo;
#line 236
#line 232
typedef struct __nesc_unnamed4297 **



QueryTableHand;
#line 281
#line 244
typedef struct __nesc_unnamed4298 {
  uint8_t qid;
  uint8_t numFields;
  uint8_t numExprs;
  uint16_t epochDuration, savedEpochDur;
  uint16_t numEpochs;
  uint16_t clocksPerSample;
  int16_t clockCount;
  uint16_t currentEpoch;
  bool running : 1;
  bool hasAgg : 1;
  bool needsData : 1;
  bool hasForClause : 1;
  bool hasEvent : 4;

  BufInfo buf;
  char bufferType;
  uint8_t bufferId;

  uint8_t fromCatalogBuffer;
  uint8_t fromBuffer;

  uint16_t curResult;
  uint8_t markedForDeletion;
  uint16_t queryRoot;

  uint8_t eventId;
  uint8_t eventCmdId;

  QueryTableHand tableInfo;



  char queryToSchemaFieldMap[1];
} 


ParsedQuery;
#line 281
#line 244
typedef struct __nesc_unnamed4298 *
#line 281
ParsedQueryPtr;


enum __nesc_unnamed4299 {
  kONE_SHOT = 0x7FFF, 
  NULL_QUERY_FIELD = 0x80, 
  GROUP_FIELD = 0x7F, 

  TYPED_FIELD = 0x7E
};
#line 326
#line 300
typedef struct __nesc_unnamed4300 {
  uint8_t qid;
  uint8_t numFields;
  uint8_t numExprs;
  uint8_t fromCatalogBuffer;
  uint8_t fromBuffer;
  char bufferType;
  uint8_t bufferId;


  short epochDuration;
  short numEpochs;
  short knownFields;
  short knownExprs;
  uint16_t queryRoot;

  bool hasBuf;
  BufInfo buf;

  bool needsEvent;
  bool hasEvent;
  bool hasForClause;
  char eventName[COMMAND_SIZE];

  Field fields[1];
} 
Query;
#line 326
#line 300
typedef struct __nesc_unnamed4300 *
#line 326
QueryPtr;



enum __nesc_unnamed4301 {
  MAX_FIELDS = 16, 
  MAX_EXPRS = 16, 
  kNO_QUERY = 0xFF
};


typedef char Op;

enum __nesc_unnamed4302 {
  EQ = 0, 
  NEQ = 1, 
  GT = 2, 
  GE = 3, 
  LT = 4, 
  LE = 5
};

typedef char Agg;


enum __nesc_unnamed4303 {
  FOP_NOOP = 0, 
  FOP_TIMES = 1, 
  FOP_DIVIDE = 2, 
  FOP_ADD = 3, 
  FOP_SUBTRACT = 4, 
  FOP_MOD = 5, 
  FOP_RSHIFT = 6
};








#line 364
typedef struct __nesc_unnamed4304 {
  short field;
  Op op;
  short value;
} OpValExpr;








#line 370
typedef struct __nesc_unnamed4305 {
  short field;
  short groupingField;
  short groupFieldOp;
  short groupFieldConst;

  Agg op;
} AggregateExpression;





#line 379
typedef struct __nesc_unnamed4306 {
  AggregateExpression agg;

  uint8_t args[4];
} TemporalAggExpr;





#line 385
typedef struct __nesc_unnamed4307 {
  Op op;
  short field;
  char s[STRING_SIZE];
} StringExpr;

enum __nesc_unnamed4308 {
  kNO_GROUPING_FIELD = 0xFFFF
};




typedef char **OperatorStateHandle;

enum __nesc_unnamed4309 {
  kSEL = 0, 
  kAGG = 1, 
  kTEMP_AGG = 2
};
#line 422
#line 406
typedef struct __nesc_unnamed4310 {
  char opType : 6;
  bool isStringExp : 1;
  bool success : 1;
  char idx;

  union __nesc_unnamed4311 {
    OpValExpr opval;
    AggregateExpression agg;
    TemporalAggExpr tagg;
    StringExpr sexp;
  } ex;
  short fieldOp;
  short fieldConst;

  OperatorStateHandle opState;
} Expr;
#line 422
#line 406
typedef struct __nesc_unnamed4310 *
#line 422
ExprPtr;


enum __nesc_unnamed4312 {
  kFIRST_RESULT = 0xFF
};



enum __nesc_unnamed4313 {
  kUNDEFINED = 0, 
  kIS_AGG = 1, 
  kNOT_AGG = 2, 
  kAGG_SINGLE_FIELD = 3
};
#line 452
#line 438
typedef struct __nesc_unnamed4314 {
  uint8_t qid;
  bool isAgg;
  uint16_t epoch;
  TinyDBError error;
  union __nesc_unnamed4315 {
    uint16_t tupleField;
    struct __nesc_unnamed4316 {
      int16_t group;
      uint8_t id;
      uint8_t len;
    } agg;
  } u;
  char *data;
} ResultTuple;









enum __nesc_unnamed4317 {
  kFIELD = 0, 
  kEXPR = 1, 
  kBUF_MSG = 2, 
  kEVENT_MSG = 3, 
  kN_EPOCHS_MSG = 4, 
  kDROP_TABLE_MSG = 5
};


enum __nesc_unnamed4318 {
#line 472
  ADD_MSG = 0, 
  DEL_MSG = 1, 
  MODIFY_MSG = 2, 
  RATE_MSG = 3, 
  DROP_TABLE_MSG = 5
};

enum __nesc_unnamed4319 {
  CRC_FAILURE = 1, 
  ACK_FAILURE = 2, 
  SEND_FAILURE = 3, 
  ENQUEUE_FAILURE = 4, 
  SEND_BUSY_FAILURE = 5
};


enum __nesc_unnamed4320 {
  HIGH_CONTENTION_THRESH = 20, 
  LOW_CONTENTION_THRESH = 10
};
#line 520
#line 494
typedef struct QueryMessage {

  uint8_t qid;
  uint16_t fwdNode;
  char msgType;
  char numFields;
  char numExprs;
  char fromBuffer;
  uint8_t fromCatalogBuffer : 1;
  uint8_t hasEvent : 1;
  uint8_t hasForClause : 1;
  uint8_t bufferType : 5;
  short epochDuration;
  char type;
  char idx;
  uint8_t timeSyncData[5];
  int16_t clockCount;
  union __nesc_unnamed4321 {
    Field field;
    Expr expr;
    BufInfo buf;
    char eventName[COMMAND_SIZE];
    short numEpochs;
    int8_t ttl;
  } u;
} 
QueryMessage;
#line 520
#line 494
typedef struct QueryMessage *
#line 520
QueryMessagePtr;
#line 532
struct UartMsg {
  char data[30];
};
struct RTCMsg {
  uint32_t time_high32;
  uint32_t time_low32;
};


enum __nesc_unnamed4322 {
#line 541
  kMAX_QUERIES = 8
};



#line 542
typedef struct StatusMessage {
  bool fromBase;
  uint8_t numQueries;
  unsigned char queries[kMAX_QUERIES];
} StatusMessage;

typedef bool *BoolPtr;
typedef char *CharPtr;

enum __nesc_unnamed4323 {
  kDATA_MESSAGE_ID = 240, 
  kQUERY_MESSAGE_ID = 101, 

  kQUERY_REQUEST_MESSAGE_ID = 104, 

  kSTATUS_MESSAGE_ID = 106, 
  kDIRECTED_DATA_MESSAGE_ID = 107, 
  kMSG_LEN = DATA_LENGTH, 
  AM_QUERYRESULT = kDATA_MESSAGE_ID, 
  AM_QUERYMESSAGE = kQUERY_MESSAGE_ID, 
  AM_STATUSMESSAGE = kSTATUS_MESSAGE_ID, 
  AM_UARTMSG = 1, 
  AM_RTCMSG = 107
};

enum __nesc_unnamed4324 {
  kTINYDB_SERVICE_ID = 0
};
#line 583
#line 575
typedef struct __nesc_unnamed4325 {
  short senderid;
  short parentid;
  uint8_t level;

  unsigned char timeRemaining;

  uint8_t idx;
} DbMsgHdr;



#line 584
typedef struct NetworkMessage {
  DbMsgHdr hdr;
  char data[0];
} NetworkMessage;
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHop.h"
enum __nesc_unnamed4326 {
  AM_MULTIHOPMSG = 250
};










#line 87
typedef struct TOS_MHopNeighbor {
  uint16_t addr;
  uint16_t recv_count;
  uint16_t fail_count;
  int16_t last_seqno;
  uint8_t goodness;
  uint8_t hopcount;
  uint8_t timeouts;
} TOS_MHopNeighbor;







#line 97
typedef struct MultihopMsg {
  uint16_t sourceaddr;
  uint16_t originaddr;
  int16_t seqno;
  uint8_t hopcount;
  uint8_t data[89 - 7];
} __attribute((packed))  TOS_MHopMsg;
# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.h"
enum __nesc_unnamed4327 {
  TIMER_REPEAT = 0, 
  TIMER_ONE_SHOT = 1, 
  NUM_TIMERS = 4U
};
# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/byteorder.h"
static __inline int is_host_lsb(void);





static __inline uint16_t toLSB16(uint16_t a);




static __inline uint16_t fromLSB16(uint16_t a);
# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430usart.h"
#line 31
typedef enum __nesc_unnamed4328 {

  USART_NONE = 0, 
  USART_UART = 1, 
  USART_UART_TX = 2, 
  USART_UART_RX = 3, 
  USART_SPI = 4, 
  USART_I2C = 5
} msp430_usartmode_t;
# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/crc.h"
uint16_t const ccitt_crc16_table[256] = { 
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 };


static uint16_t crcByte(uint16_t fcs, uint8_t c);
# 19 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430baudrates.h"
enum __nesc_unnamed4329 {

  UBR_ACLK_1200 = 0x001B, UMCTL_ACLK_1200 = 0x94, 
  UBR_ACLK_1800 = 0x0012, UMCTL_ACLK_1800 = 0x84, 
  UBR_ACLK_2400 = 0x000D, UMCTL_ACLK_2400 = 0x6D, 
  UBR_ACLK_4800 = 0x0006, UMCTL_ACLK_4800 = 0x77, 
  UBR_ACLK_9600 = 0x0003, UMCTL_ACLK_9600 = 0x29, 


  UBR_SMCLK_1200 = 0x0369, UMCTL_SMCLK_1200 = 0x7B, 
  UBR_SMCLK_1800 = 0x0246, UMCTL_SMCLK_1800 = 0x55, 
  UBR_SMCLK_2400 = 0x01B4, UMCTL_SMCLK_2400 = 0xDF, 
  UBR_SMCLK_4800 = 0x00DA, UMCTL_SMCLK_4800 = 0xAA, 
  UBR_SMCLK_9600 = 0x006D, UMCTL_SMCLK_9600 = 0x44, 
  UBR_SMCLK_19200 = 0x0036, UMCTL_SMCLK_19200 = 0xB5, 
  UBR_SMCLK_38400 = 0x001B, UMCTL_SMCLK_38400 = 0x94, 
  UBR_SMCLK_57600 = 0x0012, UMCTL_SMCLK_57600 = 0x84, 
  UBR_SMCLK_76800 = 0x000D, UMCTL_SMCLK_76800 = 0x6D, 
  UBR_SMCLK_115200 = 0x0009, UMCTL_SMCLK_115200 = 0x10, 
  UBR_SMCLK_230400 = 0x0004, UMCTL_SMCLK_230400 = 0x55, 
  UBR_SMCLK_262144 = 4, UMCTL_SMCLK_262144 = 0
};
# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.h"
typedef int8_t **Handle;
typedef Handle *HandlePtr;
# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TosTime.h"
#line 33
typedef struct __nesc_unnamed4330 {
  uint32_t high32;
  uint32_t low32;
} tos_time_t;
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TosServiceSchedule.h"
#line 58
typedef struct __nesc_unnamed4331 {
  tos_time_t start_time;
  int32_t on_time;
  int32_t off_time;
  uint8_t flags;
} tos_service_schedule;

enum __nesc_unnamed4332 {
  DISABLED = 0x00, 
  ENABLED = 0x40, 
  STOP = 0x10, 
  START = 0x20
};
# 43 "/opt/msp430/lib/gcc-lib/msp430/3.2.3/include/stdarg.h"
typedef __builtin_va_list __gnuc_va_list;
# 110 "/opt/msp430/lib/gcc-lib/msp430/3.2.3/include/stdarg.h" 3
typedef __gnuc_va_list va_list;
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Params.h"
enum __nesc_unnamed4333 {
  MAX_PARAMS = 4
};




#line 57
typedef struct __nesc_unnamed4334 {
  uint8_t numParams;
  TOSType params[MAX_PARAMS];
} ParamList;





#line 62
typedef struct __nesc_unnamed4335 {
  uint8_t numParams;
  char *paramDataPtr[MAX_PARAMS];
} 
ParamVals;
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Command.h"
enum __nesc_unnamed4336 {

  MAX_COMMANDS = 0U
};




enum __nesc_unnamed4337 {
  AM_COMMANDMSG = 103
};








#line 62
typedef struct __nesc_unnamed4338 {
  uint8_t idx;
  char *name;
  uint8_t id;
  TOSType retType;
  uint8_t retLen;
  ParamList params;
} CommandDesc;

typedef CommandDesc *CommandDescPtr;




#line 73
typedef struct __nesc_unnamed4339 {
  uint8_t numCmds;
  CommandDesc commandDesc[MAX_COMMANDS];
} CommandDescs;

typedef CommandDescs *CommandDescsPtr;
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.h"
enum __nesc_unnamed4340 {

  MAX_NUM_TIMERS = 2U
};
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregates.h"
enum __nesc_unnamed4341 {
  kMAX_SHORT = 0x7FFF, 
  kMIN_SHORT = 0x8000
};
#line 97
#line 77
typedef enum __nesc_unnamed4342 {
  kNOOP = 0, 
  kSUM = 1, 
  kMIN = 2, 
  kMAX = 3, 
  kCOUNT = 4, 
  kAVG = 5, 
  kEXP_AVG = 6, 
  kWIN_AVG = 7, 
  kWIN_SUM = 8, 
  kWIN_MIN = 9, 
  kWIN_MAX = 10, 
  kWIN_COUNT = 11, 
  kDELTA = 12, 
  kTREND = 13, 
  kWIN_RAND = 14, 
  kADP_DELTA = 15, 

  kCONTOUR_MAP = 16
} 
AggregateID;





#line 100
typedef struct __nesc_unnamed4343 {
  int16_t value;
  int16_t id;
} AlgebraicData;
#line 116
#line 105
typedef struct __nesc_unnamed4344 {
  AlgebraicData lastResult;

  uint8_t head;
  uint8_t tail;
  uint8_t size;
  uint8_t nvals;

  uint8_t epochsLeft;

  uint8_t value[1];
} TemporalAlgebraicData;




#line 118
typedef struct __nesc_unnamed4345 {
  int16_t sum;
  uint16_t count;
} AverageData;







#line 125
typedef struct __nesc_unnamed4346 {
  int16_t value;
  uint16_t epoch;
  uint8_t curInd;
} AdpDeltaData;




#line 131
typedef struct __nesc_unnamed4347 {
  int16_t value;
  uint16_t epoch;
} AdpAggData;
#line 147
#line 136
typedef struct __nesc_unnamed4348 {
  AdpDeltaData lastResult;

  uint8_t head;
  uint8_t tail;
  uint8_t size;
  uint8_t nvals;

  uint8_t epochsLeft;

  AdpAggData value[1];
} TemporalAdpDeltaData;
#line 184
static void setParamValues(ParamVals *v, Expr *e);
#line 208
#line 196
typedef enum __nesc_unnamed4349 {
  kEPOCHS_PER_WINDOW = 0, 
  kNEW_BITS_PER_SAMPLE = 0, 
  kSLIDING_DIST = 1, 
  kTREND_THRESHOLD = 1, 
  kCONTENTION_THRESHOLD = 1, 
  kDELTA_THRESHOLD = 2, 
  kCURRENT_EPOCH = 2, 

  kERROR_BOUND = 0, 
  kMERGING_LIMIT = 1
} 
ParamIndex;
#line 237
static inline uint8_t getErrorBound(ParamVals *v);



static inline uint8_t getMergingLimit(ParamVals *v);
# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.h"
enum __nesc_unnamed4350 {
  TOS_ADCSample3750ns = 0, 
  TOS_ADCSample7500ns = 1, 
  TOS_ADCSample15us = 2, 
  TOS_ADCSample30us = 3, 
  TOS_ADCSample60us = 4, 
  TOS_ADCSample120us = 5, 
  TOS_ADCSample240us = 6, 
  TOS_ADCSample480us = 7
};
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTemp.h"
enum __nesc_unnamed4351 {

  TOS_ADC_INTERNAL_TEMP_PORT = 0U, 
  TOSH_ACTUAL_ADC_INTERNAL_TEMPERATURE_PORT = (((REFVOLT_LEVEL_1_5 << 3) + REFERENCE_VREFplus_AVss) << 4) + INTERNAL_TEMPERATURE
};
# 11 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCHIL.h"
#line 6
typedef enum __nesc_unnamed4352 {

  ADC_SUCCESS = 0, 
  ADC_FAIL = 1
} 
adcresult_t;
# 23 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.h"
#line 18
typedef enum __nesc_unnamed4353 {

  REFERENCE_1_5V, 
  REFERENCE_2_5V, 
  REFERENCE_UNSTABLE
} RefVolt_t;
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltage.h"
enum __nesc_unnamed4354 {

  TOS_ADC_INTERNAL_VOLTAGE_PORT = 1U, 
  TOSH_ACTUAL_ADC_INTERNAL_VOLTAGE_PORT = (((REFVOLT_LEVEL_1_5 << 3) + REFERENCE_VREFplus_AVss) << 4) + INTERNAL_VOLTAGE
};
# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
typedef int8_t pq_element;






#line 47
typedef struct __nesc_unnamed4355 {
  char (*compare)(pq_element , pq_element );
  uint8_t size;
  uint8_t n_elements;
  pq_element heap[0];
} pqueue_t;

static inline void pqueue_init(pqueue_t *pq, uint8_t size, char (*compare)(pq_element , pq_element ));





static result_t pqueue_enqueue(pqueue_t *pq, pq_element e);
#line 76
static pq_element pqueue_dequeue_idx(pqueue_t *pq, int8_t i);
#line 101
static inline pq_element pqueue_dequeue(pqueue_t *pq);



static pq_element pqueue_remove(pqueue_t *pq, pq_element e);









static inline pq_element pqueue_peek(pqueue_t *pq);
static  result_t HPLInitM$init(void);
static  void MSP430ClockM$MSP430ClockInit$default$initTimerB(void);
static  void MSP430ClockM$MSP430ClockInit$defaultInitTimerA(void);
static  void MSP430ClockM$MSP430ClockInit$default$initTimerA(void);
static  void MSP430ClockM$MSP430ClockInit$defaultInitTimerB(void);
static  void MSP430ClockM$MSP430ClockInit$default$initClocks(void);
static  void MSP430ClockM$MSP430ClockInit$defaultInitClocks(void);
static  result_t MSP430ClockM$StdControl$init(void);
static  result_t MSP430ClockM$StdControl$start(void);
static   void MSP430DCOCalibM$Timer32khz$overflow(void);
static   void MSP430DCOCalibM$TimerMicro$overflow(void);
static   MSP430CompareControl_t MSP430TimerM$ControlA2$getControl(void);
static   MSP430CompareControl_t MSP430TimerM$ControlB0$getControl(void);
static   uint16_t MSP430TimerM$CaptureA1$getEvent(void);
static   void MSP430TimerM$CaptureA1$default$captured(uint16_t arg_0x162ad18);
static   uint16_t MSP430TimerM$CaptureB3$getEvent(void);
static   void MSP430TimerM$CaptureB3$default$captured(uint16_t arg_0x162ad18);
static   void MSP430TimerM$CompareA1$setEvent(uint16_t arg_0x1615630);
static   void MSP430TimerM$CompareB3$setEventFromNow(uint16_t arg_0x1614010);
static   uint16_t MSP430TimerM$CaptureB6$getEvent(void);
static   void MSP430TimerM$CaptureB6$default$captured(uint16_t arg_0x162ad18);
static   MSP430CompareControl_t MSP430TimerM$ControlB4$getControl(void);
static   void MSP430TimerM$ControlB4$enableEvents(void);
static   void MSP430TimerM$ControlB4$setControlAsCompare(void);
static   void MSP430TimerM$ControlB4$disableEvents(void);
static   void MSP430TimerM$ControlB4$clearPendingInterrupt(void);
static   MSP430CompareControl_t MSP430TimerM$ControlA0$getControl(void);
static   void MSP430TimerM$ControlA0$setControl(MSP430CompareControl_t arg_0x1600560);
static   uint16_t MSP430TimerM$CaptureB1$getEvent(void);
static   void MSP430TimerM$CaptureB1$clearOverflow(void);
static   bool MSP430TimerM$CaptureB1$isOverflowPending(void);
static   void MSP430TimerM$CompareB1$default$fired(void);
static   void MSP430TimerM$ControlB1$setControlAsCapture(bool arg_0x1600d08);
static   MSP430CompareControl_t MSP430TimerM$ControlB1$getControl(void);
static   void MSP430TimerM$ControlB1$enableEvents(void);
static   void MSP430TimerM$ControlB1$disableEvents(void);
static   void MSP430TimerM$ControlB1$clearPendingInterrupt(void);
static   uint16_t MSP430TimerM$CaptureA2$getEvent(void);
static   void MSP430TimerM$CaptureA2$default$captured(uint16_t arg_0x162ad18);
static   uint16_t MSP430TimerM$CaptureB4$getEvent(void);
static   void MSP430TimerM$CaptureB4$default$captured(uint16_t arg_0x162ad18);
static   MSP430CompareControl_t MSP430TimerM$ControlB2$getControl(void);
static   void MSP430TimerM$CompareA2$default$fired(void);
static   void MSP430TimerM$TimerA$clear(void);
static   void MSP430TimerM$TimerA$setClockSource(uint16_t arg_0x15f4db0);
static   void MSP430TimerM$TimerA$disableEvents(void);
static   void MSP430TimerM$TimerA$setMode(int arg_0x15f4010);
static   void MSP430TimerM$TimerA$setInputDivider(uint16_t arg_0x15f2260);
static   void MSP430TimerM$CompareB4$setEventFromNow(uint16_t arg_0x1614010);
static   MSP430CompareControl_t MSP430TimerM$ControlA1$getControl(void);
static   void MSP430TimerM$ControlA1$setControl(MSP430CompareControl_t arg_0x1600560);
static   MSP430CompareControl_t MSP430TimerM$ControlB5$getControl(void);
static   uint16_t MSP430TimerM$CaptureA0$getEvent(void);
static   void MSP430TimerM$CaptureA0$default$captured(uint16_t arg_0x162ad18);
static   uint16_t MSP430TimerM$CaptureB2$getEvent(void);
static   void MSP430TimerM$CaptureB2$default$captured(uint16_t arg_0x162ad18);
static   void MSP430TimerM$CompareA0$setEvent(uint16_t arg_0x1615630);
static   void MSP430TimerM$CompareB2$default$fired(void);
static   uint16_t MSP430TimerM$CaptureB5$getEvent(void);
static   void MSP430TimerM$CaptureB5$default$captured(uint16_t arg_0x162ad18);
static   MSP430CompareControl_t MSP430TimerM$ControlB3$getControl(void);
static   void MSP430TimerM$ControlB3$enableEvents(void);
static   void MSP430TimerM$ControlB3$setControlAsCompare(void);
static   void MSP430TimerM$ControlB3$disableEvents(void);
static   void MSP430TimerM$ControlB3$clearPendingInterrupt(void);
static   uint16_t MSP430TimerM$TimerB$read(void);
static   bool MSP430TimerM$TimerB$isOverflowPending(void);
static   void MSP430TimerM$CompareB5$default$fired(void);
static   uint16_t MSP430TimerM$CaptureB0$getEvent(void);
static   void MSP430TimerM$CaptureB0$default$captured(uint16_t arg_0x162ad18);
static   void MSP430TimerM$CompareB6$default$fired(void);
static   void MSP430TimerM$CompareB0$default$fired(void);
static   MSP430CompareControl_t MSP430TimerM$ControlB6$getControl(void);
static  result_t NetworkMultiHopM$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
static  TOS_MsgPtr NetworkMultiHopM$RcvQueryMsg$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t NetworkMultiHopM$Intercept$intercept(TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
static  result_t NetworkMultiHopM$SendStatusMsg$sendDone(TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  QueryResultPtr NetworkMultiHopM$Network$getDataPayLoad(TOS_MsgPtr arg_0x17baa98);
static  QueryMessagePtr NetworkMultiHopM$Network$getQueryPayLoad(TOS_MsgPtr arg_0x17b7010);
static  TinyDBError NetworkMultiHopM$Network$sendQueryMessage(TOS_MsgPtr arg_0x17b7680);
static  TinyDBError NetworkMultiHopM$Network$sendDataMessage(TOS_MsgPtr arg_0x17b9120);
static  result_t NetworkMultiHopM$Send$sendDone(TOS_MsgPtr arg_0x17c3d68, result_t arg_0x17c3ee8);
static  result_t NetworkMultiHopM$Snoop$intercept(TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
static  result_t NetworkMultiHopM$SendQueryMsg$sendDone(TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  TOS_MsgPtr NetworkMultiHopM$RcvStatusMessage$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t NetworkMultiHopM$StdControl$init(void);
static  result_t NetworkMultiHopM$StdControl$start(void);
static  result_t NetworkMultiHopM$StdControl$stop(void);
static  TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t arg_0x1824870, TOS_MsgPtr arg_0x17efd58);
static  result_t AMStandard$ActivityTimer$fired(void);
static  result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
static  TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t AMStandard$Control$init(void);
static  result_t AMStandard$Control$start(void);
static  result_t AMStandard$Control$stop(void);
static  result_t AMStandard$default$sendDone(void);
static  result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
static  result_t AMStandard$SendMsg$default$sendDone(uint8_t arg_0x1824218, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t CC2420RadioM$SplitControl$default$initDone(void);
static  result_t CC2420RadioM$SplitControl$init(void);
static  result_t CC2420RadioM$SplitControl$default$startDone(void);
static  result_t CC2420RadioM$SplitControl$default$stopDone(void);
static  result_t CC2420RadioM$SplitControl$start(void);
static  result_t CC2420RadioM$SplitControl$stop(void);
static   result_t CC2420RadioM$FIFOP$fired(void);
static   result_t CC2420RadioM$BackoffTimerJiffy$fired(void);
static  result_t CC2420RadioM$Send$send(TOS_MsgPtr arg_0x184d4a8);
static   void CC2420RadioM$RadioReceiveCoordinator$default$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308);
static   result_t CC2420RadioM$SFD$captured(uint16_t arg_0x1926478);
static   void CC2420RadioM$RadioSendCoordinator$default$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308);
static   result_t CC2420RadioM$HPLChipconFIFO$TXFIFODone(uint8_t arg_0x1931a90, uint8_t *arg_0x1931c28);
static   result_t CC2420RadioM$HPLChipconFIFO$RXFIFODone(uint8_t arg_0x1931350, uint8_t *arg_0x19314e8);
static  result_t CC2420RadioM$StdControl$init(void);
static  result_t CC2420RadioM$StdControl$start(void);
static  result_t CC2420RadioM$StdControl$stop(void);
static   int16_t CC2420RadioM$MacBackoff$default$initialBackoff(TOS_MsgPtr arg_0x18c1850);
static   int16_t CC2420RadioM$MacBackoff$default$congestionBackoff(TOS_MsgPtr arg_0x18c1cf0);
static  result_t CC2420RadioM$CC2420SplitControl$initDone(void);
static  result_t CC2420RadioM$CC2420SplitControl$startDone(void);
static  result_t CC2420RadioM$CC2420SplitControl$stopDone(void);
static  result_t CC2420ControlM$SplitControl$init(void);
static  result_t CC2420ControlM$SplitControl$start(void);
static  result_t CC2420ControlM$SplitControl$stop(void);
static   result_t CC2420ControlM$CCA$fired(void);
static   result_t CC2420ControlM$HPLChipconRAM$writeDone(uint16_t arg_0x19c1e18, uint8_t arg_0x19c0010, uint8_t *arg_0x19c01a8);
static   result_t CC2420ControlM$CC2420Control$VREFOn(void);
static   result_t CC2420ControlM$CC2420Control$RxMode(void);
static  result_t CC2420ControlM$CC2420Control$TuneManual(uint16_t arg_0x18cf088);
static  result_t CC2420ControlM$CC2420Control$setShortAddress(uint16_t arg_0x18ca338);
static   result_t CC2420ControlM$CC2420Control$VREFOff(void);
static   result_t CC2420ControlM$CC2420Control$OscillatorOn(void);
static   uint16_t HPLCC2420M$HPLCC2420$read(uint8_t arg_0x1904010);
static   uint8_t HPLCC2420M$HPLCC2420$write(uint8_t arg_0x1906940, uint16_t arg_0x1906ac0);
static   uint8_t HPLCC2420M$HPLCC2420$cmd(uint8_t arg_0x1906450);
static   result_t HPLCC2420M$HPLCC2420FIFO$writeTXFIFO(uint8_t arg_0x1900bc0, uint8_t *arg_0x1900d58);
static   result_t HPLCC2420M$HPLCC2420FIFO$readRXFIFO(uint8_t arg_0x19003d8, uint8_t *arg_0x1900570);
static   result_t HPLCC2420M$HPLCC2420RAM$write(uint16_t arg_0x19c15f0, uint8_t arg_0x19c1768, uint8_t *arg_0x19c1900);
static  result_t HPLCC2420M$StdControl$init(void);
static  result_t HPLCC2420M$StdControl$start(void);
static  result_t HPLCC2420M$StdControl$stop(void);
static  result_t HPLCC2420M$BusArbitration$busFree(void);
static   void HPLUSART0M$HPLI2CInterrupt$default$fired(void);
static   result_t HPLUSART0M$USARTData$default$rxDone(uint8_t arg_0x1af0a38);
static   result_t HPLUSART0M$USARTData$default$txDone(void);
static   result_t HPLUSART0M$USARTControl$isTxEmpty(void);
static   bool HPLUSART0M$USARTControl$isSPI(void);
static   void HPLUSART0M$USARTControl$disableSPI(void);
static   void HPLUSART0M$USARTControl$disableUART(void);
static   bool HPLUSART0M$USARTControl$isUART(void);
static   bool HPLUSART0M$USARTControl$isI2C(void);
static   result_t HPLUSART0M$USARTControl$disableRxIntr(void);
static   result_t HPLUSART0M$USARTControl$disableTxIntr(void);
static   bool HPLUSART0M$USARTControl$isUARTtx(void);
static   void HPLUSART0M$USARTControl$disableI2C(void);
static   void HPLUSART0M$USARTControl$setModeSPI(void);
static   msp430_usartmode_t HPLUSART0M$USARTControl$getMode(void);
static   result_t HPLUSART0M$USARTControl$isTxIntrPending(void);
static   result_t HPLUSART0M$USARTControl$tx(uint8_t arg_0x1a693b8);
static   uint8_t HPLUSART0M$USARTControl$rx(void);
static   result_t HPLUSART0M$USARTControl$isRxIntrPending(void);
static   bool HPLUSART0M$USARTControl$isUARTrx(void);
static   result_t HPLCC2420InterruptM$FIFO$default$fired(void);
static   result_t HPLCC2420InterruptM$FIFOP$disable(void);
static   result_t HPLCC2420InterruptM$FIFOP$startWait(bool arg_0x192c1a0);
static   void HPLCC2420InterruptM$CCAInterrupt$fired(void);
static   void HPLCC2420InterruptM$FIFOInterrupt$fired(void);
static   result_t HPLCC2420InterruptM$CCA$disable(void);
static   result_t HPLCC2420InterruptM$CCA$startWait(bool arg_0x192c1a0);
static   void HPLCC2420InterruptM$SFDCapture$captured(uint16_t arg_0x162ad18);
static   result_t HPLCC2420InterruptM$SFD$disable(void);
static   result_t HPLCC2420InterruptM$SFD$enableCapture(bool arg_0x1927e18);
static   void HPLCC2420InterruptM$FIFOPInterrupt$fired(void);
static   void MSP430InterruptM$Port14$clear(void);
static   void MSP430InterruptM$Port14$disable(void);
static   void MSP430InterruptM$Port14$edge(bool arg_0x1b71710);
static   void MSP430InterruptM$Port14$enable(void);
static   void MSP430InterruptM$Port26$clear(void);
static   void MSP430InterruptM$Port26$default$fired(void);
static   void MSP430InterruptM$Port17$clear(void);
static   void MSP430InterruptM$Port17$default$fired(void);
static   void MSP430InterruptM$Port21$clear(void);
static   void MSP430InterruptM$Port21$default$fired(void);
static   void MSP430InterruptM$Port12$clear(void);
static   void MSP430InterruptM$Port12$default$fired(void);
static   void MSP430InterruptM$Port24$clear(void);
static   void MSP430InterruptM$Port24$default$fired(void);
static   void MSP430InterruptM$ACCV$clear(void);
static   void MSP430InterruptM$ACCV$default$fired(void);
static   void MSP430InterruptM$Port15$clear(void);
static   void MSP430InterruptM$Port15$default$fired(void);
static   void MSP430InterruptM$Port27$clear(void);
static   void MSP430InterruptM$Port27$default$fired(void);
static   void MSP430InterruptM$Port10$clear(void);
static   void MSP430InterruptM$Port10$disable(void);
static   void MSP430InterruptM$Port10$edge(bool arg_0x1b71710);
static   void MSP430InterruptM$Port10$enable(void);
static   void MSP430InterruptM$Port22$clear(void);
static   void MSP430InterruptM$Port22$default$fired(void);
static   void MSP430InterruptM$OF$clear(void);
static   void MSP430InterruptM$OF$default$fired(void);
static   void MSP430InterruptM$Port13$clear(void);
static   void MSP430InterruptM$Port13$disable(void);
static   void MSP430InterruptM$Port25$clear(void);
static   void MSP430InterruptM$Port25$default$fired(void);
static   void MSP430InterruptM$Port16$clear(void);
static   void MSP430InterruptM$Port16$default$fired(void);
static   void MSP430InterruptM$NMI$clear(void);
static   void MSP430InterruptM$NMI$default$fired(void);
static   void MSP430InterruptM$Port20$clear(void);
static   void MSP430InterruptM$Port20$default$fired(void);
static   void MSP430InterruptM$Port11$clear(void);
static   void MSP430InterruptM$Port11$default$fired(void);
static   void MSP430InterruptM$Port23$clear(void);
static   void MSP430InterruptM$Port23$default$fired(void);
static  result_t BusArbitrationM$StdControl$init(void);
static  result_t BusArbitrationM$StdControl$start(void);
static  result_t BusArbitrationM$StdControl$stop(void);
static  result_t BusArbitrationM$BusArbitration$default$busFree(uint8_t arg_0x1c93a50);
static   result_t BusArbitrationM$BusArbitration$releaseBus(uint8_t arg_0x1c93a50);
static   result_t BusArbitrationM$BusArbitration$getBus(uint8_t arg_0x1c93a50);
static   uint16_t RandomLFSR$Random$rand(void);
static   result_t RandomLFSR$Random$init(void);
static   result_t TimerJiffyAsyncM$TimerJiffyAsync$setOneShot(uint32_t arg_0x1921100);
static   bool TimerJiffyAsyncM$TimerJiffyAsync$isSet(void);
static   result_t TimerJiffyAsyncM$TimerJiffyAsync$stop(void);
static   void TimerJiffyAsyncM$AlarmCompare$fired(void);
static  result_t TimerJiffyAsyncM$StdControl$init(void);
static  result_t TimerJiffyAsyncM$StdControl$start(void);
static  result_t TimerJiffyAsyncM$StdControl$stop(void);
static   result_t LedsC$Leds$yellowOff(void);
static   result_t LedsC$Leds$yellowOn(void);
static   result_t LedsC$Leds$greenOff(void);
static   result_t LedsC$Leds$redOff(void);
static   result_t LedsC$Leds$greenToggle(void);
static   result_t LedsC$Leds$yellowToggle(void);
static   result_t LedsC$Leds$redToggle(void);
static   result_t LedsC$Leds$set(uint8_t arg_0x17e65b8);
static   result_t LedsC$Leds$redOn(void);
static   result_t LedsC$Leds$greenOn(void);
static   result_t FramerM$ByteComm$txDone(void);
static   result_t FramerM$ByteComm$txByteReady(bool arg_0x1d2d010);
static   result_t FramerM$ByteComm$rxByteReady(uint8_t arg_0x1d2f648, bool arg_0x1d2f7c0, uint16_t arg_0x1d2f948);
static  result_t FramerM$BareSendMsg$send(TOS_MsgPtr arg_0x184d4a8);
static  result_t FramerM$StdControl$init(void);
static  result_t FramerM$StdControl$start(void);
static  result_t FramerM$StdControl$stop(void);
static  result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t arg_0x1d34598);
static  TOS_MsgPtr FramerAckM$ReceiveMsg$receive(TOS_MsgPtr arg_0x17efd58);
static  TOS_MsgPtr FramerAckM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0x1d35d88, uint8_t arg_0x1d35f00);
static   result_t UARTM$HPLUART$get(uint8_t arg_0x1db5ed0);
static   result_t UARTM$HPLUART$putDone(void);
static   result_t UARTM$ByteComm$txByte(uint8_t arg_0x1d2f118);
static  result_t UARTM$Control$init(void);
static  result_t UARTM$Control$start(void);
static  result_t UARTM$Control$stop(void);
static   result_t HPLUARTM$USARTData$rxDone(uint8_t arg_0x1af0a38);
static   result_t HPLUARTM$USARTData$txDone(void);
static   result_t HPLUARTM$UART$init(void);
static   result_t HPLUARTM$UART$put(uint8_t arg_0x1db5958);
static   result_t HPLUARTM$UART$stop(void);
static   bool HPLUSART1M$USARTControl$isSPI(void);
static   void HPLUSART1M$USARTControl$disableSPI(void);
static   void HPLUSART1M$USARTControl$setClockRate(uint16_t arg_0x1a6c548, uint8_t arg_0x1a6c6c0);
static   void HPLUSART1M$USARTControl$disableUART(void);
static   void HPLUSART1M$USARTControl$setClockSource(uint8_t arg_0x1a6c0b0);
static   bool HPLUSART1M$USARTControl$isUART(void);
static   result_t HPLUSART1M$USARTControl$enableRxIntr(void);
static   bool HPLUSART1M$USARTControl$isI2C(void);
static   result_t HPLUSART1M$USARTControl$disableRxIntr(void);
static   result_t HPLUSART1M$USARTControl$disableTxIntr(void);
static   result_t HPLUSART1M$USARTControl$enableTxIntr(void);
static   bool HPLUSART1M$USARTControl$isUARTtx(void);
static   msp430_usartmode_t HPLUSART1M$USARTControl$getMode(void);
static   result_t HPLUSART1M$USARTControl$tx(uint8_t arg_0x1a693b8);
static   void HPLUSART1M$USARTControl$setModeUART(void);
static   bool HPLUSART1M$USARTControl$isUARTrx(void);
static   result_t NoLeds$Leds$greenToggle(void);
static   result_t NoLeds$Leds$redToggle(void);
static  result_t TimerM$TimerMilli$default$fired(uint8_t arg_0x1e40860);
static  result_t TimerM$TimerMilli$setOneShot(uint8_t arg_0x1e40860, int32_t arg_0x1e4fe38);
static   uint32_t TimerM$LocalTime$read(void);
static   void TimerM$AlarmCompare$fired(void);
static  result_t TimerM$TimerJiffy$default$fired(uint8_t arg_0x1e773e0);
static   void TimerM$AlarmTimer$overflow(void);
static  result_t TimerM$StdControl$init(void);
static  result_t TimerM$StdControl$start(void);
static  result_t TimerM$Timer$default$fired(uint8_t arg_0x1e40118);
static  result_t TimerM$Timer$start(uint8_t arg_0x1e40118, char arg_0x1841820, uint32_t arg_0x18419a8);
static  result_t TimerM$Timer$stop(uint8_t arg_0x1e40118);
static   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
static  TOS_MsgPtr MultiHopEngineM$ReceiveMsg$receive(uint8_t arg_0x1ec5a48, TOS_MsgPtr arg_0x17efd58);
static  result_t MultiHopEngineM$Intercept$default$intercept(uint8_t arg_0x1ec6738, TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
static  result_t MultiHopEngineM$Send$send(uint8_t arg_0x1ec6010, TOS_MsgPtr arg_0x17c4a58, uint16_t arg_0x17c4bd8);
static  void *MultiHopEngineM$Send$getBuffer(uint8_t arg_0x1ec6010, TOS_MsgPtr arg_0x17c3328, uint16_t *arg_0x17c34c8);
static  result_t MultiHopEngineM$Send$default$sendDone(uint8_t arg_0x1ec6010, TOS_MsgPtr arg_0x17c3d68, result_t arg_0x17c3ee8);
static  result_t MultiHopEngineM$SendMsg$sendDone(uint8_t arg_0x1ec4010, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  result_t MultiHopEngineM$StdControl$init(void);
static  result_t MultiHopEngineM$StdControl$start(void);
static  result_t MultiHopEngineM$StdControl$stop(void);
static  uint16_t *MultiHopEngineM$RouteControl$getChildren(void);
static  uint16_t MultiHopEngineM$RouteControl$getParent(void);
static  result_t MultiHopEngineM$RouteControl$manualUpdate(void);
static  result_t MultiHopLEPSM$RouteSelect$selectRoute(TOS_MsgPtr arg_0x1ef6b90, uint8_t arg_0x1ef6d08);
static  result_t MultiHopLEPSM$RouteSelect$initializeFields(TOS_MsgPtr arg_0x1ef5340, uint8_t arg_0x1ef54b8);
static  result_t MultiHopLEPSM$Timer$fired(void);
static  TOS_MsgPtr MultiHopLEPSM$ReceiveMsg$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t MultiHopLEPSM$Snoop$intercept(uint8_t arg_0x1f09870, TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
static  result_t MultiHopLEPSM$SendMsg$sendDone(TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  result_t MultiHopLEPSM$StdControl$init(void);
static  result_t MultiHopLEPSM$StdControl$start(void);
static  result_t MultiHopLEPSM$StdControl$stop(void);
static  uint16_t *MultiHopLEPSM$RouteControl$getChildren(void);
static  uint16_t MultiHopLEPSM$RouteControl$getParent(void);
static  result_t MultiHopLEPSM$RouteControl$manualUpdate(void);
static  result_t QueuedSendM$QueueSendMsg$send(uint8_t arg_0x1f8da10, uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
static  result_t QueuedSendM$StdControl$init(void);
static  result_t QueuedSendM$StdControl$start(void);
static  result_t QueuedSendM$StdControl$stop(void);
static  result_t QueuedSendM$SerialSendMsg$sendDone(uint8_t arg_0x1f8c4d8, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
static  TOS_MsgPtr AMPromiscuous$ReceiveMsg$default$receive(uint8_t arg_0x1fd5010, TOS_MsgPtr arg_0x17efd58);
static  result_t AMPromiscuous$ActivityTimer$fired(void);
static  result_t AMPromiscuous$UARTSend$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
static  TOS_MsgPtr AMPromiscuous$RadioReceive$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t AMPromiscuous$default$sendDone(void);
static  result_t AMPromiscuous$RadioSend$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
static  result_t AMPromiscuous$SendMsg$send(uint8_t arg_0x1fd7930, uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
static  TOS_MsgPtr AMPromiscuous$UARTReceive$receive(TOS_MsgPtr arg_0x17efd58);
static  result_t TupleRouterM$AbsoluteTimer$fired(void);
static  bool TupleRouterM$QueryProcessor$queryProcessorWantsData(QueryResult *arg_0x1773ad0);
static  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryCmd(uint8_t arg_0x17747d0);
static  short TupleRouterM$QueryProcessor$numQueries(void);
static  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryIdx(short arg_0x1773630);
static  TinyDBError TupleRouterM$SelOperator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40);
static  result_t TupleRouterM$Network$sendDataDone(TOS_MsgPtr arg_0x17b96e0, result_t arg_0x17b9860);
static  result_t TupleRouterM$Network$sendQueryDone(TOS_MsgPtr arg_0x17b7c28, result_t arg_0x17b7da8);
static  result_t TupleRouterM$Network$dataSub(QueryResultPtr arg_0x17b6330);
static  result_t TupleRouterM$Network$querySub(QueryMessagePtr arg_0x17b6898);
static  void TupleRouterM$signalError(TinyDBError arg_0x20e85a0, int arg_0x20e8710);
static  void TupleRouterM$statusMessage(CharPtr arg_0x20e8b80);
static  result_t TupleRouterM$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0);
static  result_t TupleRouterM$AttrUse$startAttrDone(uint8_t arg_0x2049670);
static  TinyDBError TupleRouterM$RadioQueue$enqueue(const QueryResultPtr arg_0x20e4678, bool *arg_0x20e4810);
static  TinyDBError TupleRouterM$AggOperator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40);
static  TinyDBError TupleRouterM$AggOperator$processedResult(QueryResultPtr arg_0x2097100, ParsedQueryPtr arg_0x2097280, ExprPtr arg_0x20973f8);
static  result_t TupleRouterM$DBBuffer$putComplete(uint8_t arg_0x20cdb10, QueryResult *arg_0x20cdcb0, TinyDBError arg_0x20cde30);
static  result_t TupleRouterM$DBBuffer$getComplete(uint8_t arg_0x20cd338, QueryResult *arg_0x20cd4d8, TinyDBError arg_0x20cd658);
static  result_t TupleRouterM$DBBuffer$allocComplete(uint8_t arg_0x20cecd0, TinyDBError arg_0x20cee50);
static  result_t TupleRouterM$MemAlloc$compactComplete(void);
static  result_t TupleRouterM$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
static  result_t TupleRouterM$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
static  result_t TupleRouterM$StdControl$init(void);
static  result_t TupleRouterM$StdControl$start(void);
static  result_t TupleRouterM$StdControl$stop(void);
static  result_t SimpleTimeM$AbsoluteTimer$default$fired(uint8_t arg_0x228b658);
static  result_t SimpleTimeM$AbsoluteTimer$cancel(uint8_t arg_0x228b658);
static  result_t SimpleTimeM$AbsoluteTimer$set(uint8_t arg_0x228b658, tos_time_t arg_0x20b7920);
static   void SimpleTimeM$setInterval(uint16_t arg_0x228bdc0);
static  void SimpleTimeM$TimeSet$set(tos_time_t arg_0x20a3068);
static   uint32_t SimpleTimeM$Time$getHigh32(void);
static   tos_time_t SimpleTimeM$Time$get(void);
static   uint32_t SimpleTimeM$Time$getLow32(void);
static  result_t SimpleTimeM$StdControl$init(void);
static  result_t SimpleTimeM$StdControl$start(void);
static  result_t SimpleTimeM$Timer$fired(void);
static   tos_time_t TimeUtilC$TimeUtil$addUint32(tos_time_t arg_0x20b1bd8, uint32_t arg_0x20b1d58);
static   tos_time_t TimeUtilC$TimeUtil$subtract(tos_time_t arg_0x20af7c8, tos_time_t arg_0x20af948);
static   tos_time_t TimeUtilC$TimeUtil$add(tos_time_t arg_0x20af170, tos_time_t arg_0x20af2f0);
static   char TimeUtilC$TimeUtil$compare(tos_time_t arg_0x20b0aa0, tos_time_t arg_0x20b0c20);
static  result_t Tuple$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
static  result_t Tuple$TupleIntf$setFieldNoQuery(TuplePtr arg_0x2042808, uint8_t arg_0x2042998, uint8_t arg_0x2042b28, uint8_t arg_0x2042cd0[], uint8_t arg_0x2042e78[], CharPtr arg_0x2041030);
static  CharPtr Tuple$TupleIntf$getFieldPtrNoQuery(TuplePtr arg_0x2040100, uint8_t arg_0x2040290, uint8_t arg_0x2040420, uint8_t arg_0x20405c8[], uint8_t arg_0x2040770[]);
static  TinyDBError Tuple$TupleIntf$getNextEmptyFieldIdx(ParsedQueryPtr arg_0x2079340, TuplePtr arg_0x20794c0, uint8_t *arg_0x2079660);
static  AttrDescPtr Tuple$TupleIntf$getNextQueryField(ParsedQueryPtr arg_0x207ac38, TuplePtr arg_0x207adb8);
static  CharPtr Tuple$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80);
static  result_t Tuple$TupleIntf$tupleInit(ParsedQueryPtr arg_0x2040f30, TuplePtr arg_0x207a0c8);
static  result_t Tuple$TupleIntf$setField(ParsedQueryPtr arg_0x2044ce8, TuplePtr arg_0x2044e68, uint8_t arg_0x2042010, CharPtr arg_0x2042188);
static  uint16_t Tuple$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0);
static  uint16_t Tuple$TupleIntf$tupleSize(ParsedQueryPtr arg_0x2044190);
static  result_t Tuple$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0);
static  result_t Tuple$AttrUse$startAttrDone(uint8_t arg_0x2049670);
static  result_t Tuple$DBBuffer$putComplete(uint8_t arg_0x20cdb10, QueryResult *arg_0x20cdcb0, TinyDBError arg_0x20cde30);
static  result_t Tuple$DBBuffer$getComplete(uint8_t arg_0x20cd338, QueryResult *arg_0x20cd4d8, TinyDBError arg_0x20cd658);
static  result_t Tuple$DBBuffer$allocComplete(uint8_t arg_0x20cecd0, TinyDBError arg_0x20cee50);
static  Field Query$QueryIntf$getField(QueryPtr arg_0x2074728, uint8_t arg_0x20748a0);
static  short Query$QueryIntf$size(QueryPtr arg_0x2074270);
static  result_t Query$QueryIntf$setExpr(QueryPtr arg_0x2071260, uint8_t arg_0x20713d8, Expr arg_0x2071550);
static  Field *Query$QueryIntf$getFieldPtr(QueryPtr arg_0x2074d58, uint8_t arg_0x2074ed0);
static  bool Query$QueryIntf$fieldsComplete(Query arg_0x2071aa8);
static  result_t Query$QueryIntf$setField(QueryPtr arg_0x20733d8, uint8_t arg_0x2073550, Field arg_0x20736c8);
static  bool Query$QueryIntf$exprsComplete(Query arg_0x2070010);
static  Expr Query$QueryIntf$getExpr(QueryPtr arg_0x2073c10, uint8_t arg_0x2073d88);
static  result_t ParsedQuery$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0);
static  result_t ParsedQuery$AttrUse$startAttrDone(uint8_t arg_0x2049670);
static  bool ParsedQuery$ParsedQueryIntf$queryFieldIsTyped(uint8_t arg_0x206cdd8);
static  bool ParsedQuery$ParsedQueryIntf$queryFieldIsNull(uint8_t arg_0x206c928);
static  short ParsedQuery$ParsedQueryIntf$pqSize(ParsedQueryPtr arg_0x2068828);
static  result_t ParsedQuery$ParsedQueryIntf$getFieldType(ParsedQuery *arg_0x2064308, uint8_t arg_0x2064488, uint8_t *arg_0x2064630);
static  short ParsedQuery$ParsedQueryIntf$baseSize(QueryPtr arg_0x2068328);
static  TinyDBError ParsedQuery$ParsedQueryIntf$getResultField(ParsedQueryPtr arg_0x2067498, QueryResultPtr arg_0x2067618, uint8_t arg_0x2067798, char *arg_0x2067930);
static  TinyDBError ParsedQuery$ParsedQueryIntf$getResultId(ParsedQueryPtr arg_0x20650b0, Field *arg_0x2065248, uint8_t *arg_0x20653e0);
static  uint8_t ParsedQuery$ParsedQueryIntf$getFieldId(ParsedQueryPtr arg_0x2069010, uint8_t arg_0x2069188);
static  result_t ParsedQuery$ParsedQueryIntf$setExpr(ParsedQueryPtr arg_0x2069640, uint8_t arg_0x20697b8, Expr arg_0x2069930);
static  ExprPtr ParsedQuery$ParsedQueryIntf$getExprPtr(ParsedQueryPtr arg_0x206b960, uint8_t arg_0x206bad8);
static  TuplePtr ParsedQuery$ParsedQueryIntf$getTuplePtr(ParsedQueryPtr arg_0x2069df0);
static  bool ParsedQuery$ParsedQueryIntf$typeCheck(ParsedQuery *arg_0x2065a18, ParsedQuery *arg_0x2065bb8);
static  Expr ParsedQuery$ParsedQueryIntf$getExpr(ParsedQueryPtr arg_0x206b328, uint8_t arg_0x206b4a0);
static  TinyDBError ParsedQuery$AggOperator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40);
static  TinyDBError ParsedQuery$AggOperator$processedResult(QueryResultPtr arg_0x2097100, ParsedQueryPtr arg_0x2097280, ExprPtr arg_0x20973f8);
static  result_t ParsedQuery$DBBuffer$putComplete(uint8_t arg_0x20cdb10, QueryResult *arg_0x20cdcb0, TinyDBError arg_0x20cde30);
static  result_t ParsedQuery$DBBuffer$getComplete(uint8_t arg_0x20cd338, QueryResult *arg_0x20cd4d8, TinyDBError arg_0x20cd658);
static  result_t ParsedQuery$DBBuffer$allocComplete(uint8_t arg_0x20cecd0, TinyDBError arg_0x20cee50);
static  TinyDBError SelOperator$Operator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990);
static  TinyDBError QueryResult$QueryResultIntf$initQueryResult(QueryResultPtr arg_0x20913d8);
static  TinyDBError QueryResult$QueryResultIntf$toBytes(QueryResultPtr arg_0x208e200, ParsedQueryPtr arg_0x208e380, CharPtr arg_0x208e4f8);
static  TinyDBError QueryResult$QueryResultIntf$fromBytes(QueryResultPtr arg_0x208ead0, QueryResultPtr arg_0x208ec50, ParsedQueryPtr arg_0x208edd0);
static  ResultTuple QueryResult$QueryResultIntf$getResultTuple(QueryResultPtr arg_0x208c670, short arg_0x208c7e0, ParsedQueryPtr arg_0x208c960);
static  short QueryResult$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0);
static  TinyDBError QueryResult$QueryResultIntf$addAggResult(QueryResultPtr arg_0x208cec8, int16_t arg_0x208a068, char *arg_0x208a1f8, int16_t arg_0x208a370, ParsedQueryPtr arg_0x208a4f0, short arg_0x208a660);
static  TinyDBError QueryResult$QueryResultIntf$fromResultTuple(ResultTuple arg_0x208d398, QueryResultPtr arg_0x208d518, ParsedQueryPtr arg_0x208d698);
static  TinyDBError QueryResult$QueryResultIntf$toTuplePtr(QueryResultPtr arg_0x208f268, ParsedQueryPtr arg_0x208f3e8, TupleHandle arg_0x208f568);
static  uint8_t QueryResult$QueryResultIntf$queryIdFromMsg(QueryResultPtr arg_0x208db50);
static  TinyDBError QueryResult$QueryResultIntf$fromTuple(QueryResultPtr arg_0x20919b8, ParsedQueryPtr arg_0x2091b38, TuplePtr arg_0x2091cb8);
static  result_t QueryResult$MemAlloc$compactComplete(void);
static  result_t QueryResult$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
static  result_t QueryResult$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
static  int16_t TinyAlloc$MemAlloc$size(Handle arg_0x20836d8);
static  result_t TinyAlloc$MemAlloc$unlock(Handle arg_0x2084898);
static  result_t TinyAlloc$MemAlloc$lock(Handle arg_0x2084328);
static  result_t TinyAlloc$MemAlloc$reallocate(Handle arg_0x2085b88, int16_t arg_0x2085d00);
static  result_t TinyAlloc$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638);
static  int16_t TinyAlloc$MemAlloc$free(Handle arg_0x2084dd8);
static  result_t TinyAlloc$StdControl$init(void);
static  result_t TinyAlloc$StdControl$start(void);
static  TinyDBError AggOperator$addResults(QueryResult *arg_0x24919e0, ParsedQuery *arg_0x2491b80, Expr *arg_0x2491d18);
static  short AggOperator$getGroupNoFromQr(QueryResult *arg_0x2490b58);
static  result_t AggOperator$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
static  TinyDBError AggOperator$Operator$processPartialResult(QueryResultPtr arg_0x209af08, ParsedQueryPtr arg_0x20980b0, ExprPtr arg_0x2098228);
static  TinyDBError AggOperator$Operator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990);
static  result_t AggOperator$Operator$endOfEpoch(ParsedQueryPtr arg_0x2098800, ExprPtr arg_0x2098978);
static  bool AggOperator$Operator$resultIsForExpr(QueryResultPtr arg_0x209bf00, ExprPtr arg_0x209a088);
static  TinyDBError AggOperator$finalizeAggExpr(QueryResult *arg_0x24901f8, ParsedQueryPtr arg_0x2490378, Expr *arg_0x2490510, char *arg_0x24906a8);
static  result_t AggOperator$MemAlloc$compactComplete(void);
static  result_t AggOperator$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
static  result_t AggOperator$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
static  short ExprEvalC$ExprEval$evaluateGroupBy(AggregateExpression arg_0x23a7a00, short arg_0x23a7b78);
static  short ExprEvalC$ExprEval$evaluate(Expr *arg_0x23a7408, short arg_0x23a7580);
static  bool AggregateUseM$AggregateUse$hasData(uint8_t arg_0x2480068, char *arg_0x24801f8, ParamList *arg_0x2480398, ParamVals *arg_0x2480540);
static  TinyDBError AggregateUseM$AggregateUse$finalize(uint8_t arg_0x24809d0, char *arg_0x2480b60, char *arg_0x2480cf8, ParamList *arg_0x2480e98, ParamVals *arg_0x24d1068);
static  uint16_t AggregateUseM$AggregateUse$stateSize(uint8_t arg_0x2481878, ParamList *arg_0x2481a18, ParamVals *arg_0x2481bc0);
static  result_t AggregateUseM$AggregateUse$init(uint8_t arg_0x2483c80, char *arg_0x2483e10, ParamList *arg_0x2481010, ParamVals *arg_0x24811b8, bool arg_0x2481338);
static  result_t AggregateUseM$AggregateUse$merge(uint8_t arg_0x2484590, char *arg_0x2484728, char *arg_0x24848c0, ParamList *arg_0x2484a60, ParamVals *arg_0x2484c08);
static  result_t AggregateUseM$AggregateUse$update(uint8_t arg_0x2483188, char *arg_0x2483318, char *arg_0x24834a8, ParamList *arg_0x2483648, ParamVals *arg_0x24837f0);
static  bool AggregateUseM$Agg$default$hasData(uint8_t arg_0x255b358, char *arg_0x2552f30, ParamList *arg_0x25510e8, ParamVals *arg_0x2551290);
static  TinyDBError AggregateUseM$Agg$default$finalize(uint8_t arg_0x255b358, char *arg_0x2554f10, char *arg_0x25520b8, ParamList *arg_0x2552258, ParamVals *arg_0x2552400);
static  uint16_t AggregateUseM$Agg$default$stateSize(uint8_t arg_0x255b358, ParamList *arg_0x25528c8, ParamVals *arg_0x2552a70);
static  result_t AggregateUseM$Agg$default$init(uint8_t arg_0x255b358, char *arg_0x25544e0, ParamList *arg_0x2554680, ParamVals *arg_0x2554828, bool arg_0x25549a8);
static  result_t AggregateUseM$Agg$default$merge(uint8_t arg_0x255b358, char *arg_0x25550a8, char *arg_0x2555240, ParamList *arg_0x25553e0, ParamVals *arg_0x2555588);
static  result_t AggregateUseM$Agg$default$update(uint8_t arg_0x255b358, char *arg_0x2555a68, char *arg_0x2555bf8, ParamList *arg_0x2555d98, ParamVals *arg_0x2554010);
static  bool ContourMapM$Aggregate$hasData(char *arg_0x2552f30, ParamList *arg_0x25510e8, ParamVals *arg_0x2551290);
static  TinyDBError ContourMapM$Aggregate$finalize(char *arg_0x2554f10, char *arg_0x25520b8, ParamList *arg_0x2552258, ParamVals *arg_0x2552400);
static  uint16_t ContourMapM$Aggregate$stateSize(ParamList *arg_0x25528c8, ParamVals *arg_0x2552a70);
static  result_t ContourMapM$Aggregate$init(char *arg_0x25544e0, ParamList *arg_0x2554680, ParamVals *arg_0x2554828, bool arg_0x25549a8);
static  result_t ContourMapM$Aggregate$merge(char *arg_0x25550a8, char *arg_0x2555240, ParamList *arg_0x25553e0, ParamVals *arg_0x2555588);
static  result_t ContourMapM$Aggregate$update(char *arg_0x2555a68, char *arg_0x2555bf8, ParamList *arg_0x2555d98, ParamVals *arg_0x2554010);
static  result_t Attr$Attr$registerAttr(uint8_t arg_0x2621e38, char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
static  result_t Attr$Attr$getAttrDone(uint8_t arg_0x2621e38, char *arg_0x2618638, char *arg_0x26187d0, SchemaErrorNo arg_0x2618950);
static  result_t Attr$Attr$startAttrDone(uint8_t arg_0x2621e38);
static  result_t Attr$Attr$default$getAttr(uint8_t arg_0x2621e38, char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t Attr$Attr$default$startAttr(uint8_t arg_0x2621e38);
static  AttrDescPtr Attr$AttrUse$getAttrById(uint8_t arg_0x204da90);
static  uint8_t Attr$AttrUse$numAttrs(void);
static  AttrDescPtr Attr$AttrUse$getAttr(char *arg_0x204d508);
static  result_t Attr$AttrUse$getAttrValue(char *arg_0x204c7d0, char *arg_0x204c968, SchemaErrorNo *arg_0x204cb08);
static  result_t Attr$AttrUse$startAttr(uint8_t arg_0x2049168);
static  result_t AttrGlobalM$NodeIdAttr$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrGlobalM$NodeIdAttr$startAttr(void);
static  result_t AttrGlobalM$GroupAttr$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrGlobalM$GroupAttr$startAttr(void);
static  result_t AttrGlobalM$StdControl$init(void);
static  result_t AttrGlobalM$StdControl$start(void);
static  result_t AttrGlobalM$StdControl$stop(void);
static  result_t TinyDBAttrM$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
static  result_t TinyDBAttrM$MemAlloc$compactComplete(void);
static  result_t TinyDBAttrM$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
static  result_t TinyDBAttrM$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
static  result_t TinyDBAttrM$StdControl$init(void);
static  result_t TinyDBAttrM$StdControl$start(void);
static  result_t TinyDBAttrM$StdControl$stop(void);
static  result_t AttrTimeM$TimeHighAttr$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrTimeM$TimeHighAttr$startAttr(void);
static  result_t AttrTimeM$TimeLowAttr$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrTimeM$TimeLowAttr$startAttr(void);
static  result_t AttrTimeM$StdControl$init(void);
static  result_t AttrTimeM$StdControl$start(void);
static  result_t AttrTimeM$StdControl$stop(void);
static   result_t InternalTempM$ADCSingle$default$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20);
static   result_t InternalTempM$MSP430ADC12Single$dataReady(uint16_t arg_0x26c5100);
static   uint16_t *InternalTempM$ADCMultiple$default$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0);
static   uint16_t *InternalTempM$MSP430ADC12Multiple$dataReady(uint16_t *arg_0x2712288, uint16_t arg_0x2712408);
static  result_t InternalTempM$StdControl$init(void);
static  result_t InternalTempM$StdControl$start(void);
static  result_t InternalTempM$StdControl$stop(void);
static  result_t ADCM$ADCControl$bindPort(uint8_t arg_0x26d1a70, uint8_t arg_0x26d1be8);
static  result_t ADCM$ADCControl$init(void);
static   result_t ADCM$MSP430ADC12Single$dataReady(uint16_t arg_0x26c5100);
static   result_t ADCM$ADC$getData(uint8_t arg_0x26f2da8);
static   result_t ADCM$ADC$default$dataReady(uint8_t arg_0x26f2da8, uint16_t arg_0x26a91b8);
static  result_t ADCM$StdControl$init(void);
static  result_t ADCM$StdControl$start(void);
static  result_t ADCM$StdControl$stop(void);
static   void MSP430ADC12M$CompareA1$fired(void);
static  void MSP430ADC12M$RefVolt$isStable(RefVolt_t arg_0x2763518);
static   msp430ADCresult_t MSP430ADC12M$ADCSingle$getData(uint8_t arg_0x27269f8);
static  result_t MSP430ADC12M$ADCSingle$bind(uint8_t arg_0x27269f8, MSP430ADC12Settings_t arg_0x26c7d00);
static   msp430ADCresult_t MSP430ADC12M$ADCSingle$getDataRepeat(uint8_t arg_0x27269f8, uint16_t arg_0x26ca958);
static   result_t MSP430ADC12M$ADCSingle$default$dataReady(uint8_t arg_0x27269f8, uint16_t arg_0x26c5100);
static   void MSP430ADC12M$TimerA$overflow(void);
static   msp430ADCresult_t MSP430ADC12M$ADCMultiple$getData(uint8_t arg_0x27254c8, uint16_t *arg_0x26c0068, uint16_t arg_0x26c01e8, uint16_t arg_0x26c0368);
static  result_t MSP430ADC12M$ADCMultiple$bind(uint8_t arg_0x27254c8, MSP430ADC12Settings_t arg_0x26c1980);
static   uint16_t *MSP430ADC12M$ADCMultiple$default$dataReady(uint8_t arg_0x27254c8, uint16_t *arg_0x2712288, uint16_t arg_0x2712408);
static   void MSP430ADC12M$HPLADC12$memOverflow(void);
static   void MSP430ADC12M$HPLADC12$converted(uint8_t arg_0x2770250);
static   void MSP430ADC12M$HPLADC12$timeOverflow(void);
static   void MSP430ADC12M$CompareA0$fired(void);
static  result_t MSP430ADC12M$StdControl$init(void);
static  result_t MSP430ADC12M$StdControl$start(void);
static  result_t MSP430ADC12M$StdControl$stop(void);
static   void HPLADC12M$HPLADC12$setRefOff(void);
static   void HPLADC12M$HPLADC12$resetIFGs(void);
static   bool HPLADC12M$HPLADC12$isBusy(void);
static   void HPLADC12M$HPLADC12$setControl1(adc12ctl1_t arg_0x2776e10);
static   void HPLADC12M$HPLADC12$setRef2_5V(void);
static   void HPLADC12M$HPLADC12$disableConversion(void);
static   void HPLADC12M$HPLADC12$setControl0_IgnoreRef(adc12ctl0_t arg_0x2774988);
static   void HPLADC12M$HPLADC12$setRefOn(void);
static   adc12memctl_t HPLADC12M$HPLADC12$getMemControl(uint8_t arg_0x27734b0);
static   void HPLADC12M$HPLADC12$setRef1_5V(void);
static   void HPLADC12M$HPLADC12$startConversion(void);
static   uint16_t HPLADC12M$HPLADC12$getMem(uint8_t arg_0x2773940);
static   void HPLADC12M$HPLADC12$setIEFlags(uint16_t arg_0x2773dd0);
static   void HPLADC12M$HPLADC12$setSHT(uint8_t arg_0x2770e68);
static   void HPLADC12M$HPLADC12$setMemControl(uint8_t arg_0x2774e10, adc12memctl_t arg_0x2773010);
static   void HPLADC12M$HPLADC12$stopConversion(void);
static  result_t RefVoltM$SwitchOffTimer$fired(void);
static   RefVolt_t RefVoltM$RefVolt$getState(void);
static   result_t RefVoltM$RefVolt$release(void);
static   result_t RefVoltM$RefVolt$get(RefVolt_t arg_0x2760d28);
static   void RefVoltM$HPLADC12$memOverflow(void);
static   void RefVoltM$HPLADC12$converted(uint8_t arg_0x2770250);
static   void RefVoltM$HPLADC12$timeOverflow(void);
static  result_t RefVoltM$SwitchOnTimer$fired(void);
static  result_t AttrTempM$AttrRegister$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrTempM$AttrRegister$startAttr(void);
static   result_t AttrTempM$ADC$dataReady(uint16_t arg_0x26a91b8);
static  result_t AttrTempM$StdControl$init(void);
static  result_t AttrTempM$StdControl$start(void);
static  result_t AttrTempM$StdControl$stop(void);
static   result_t InternalVoltageM$ADCSingle$default$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20);
static   result_t InternalVoltageM$MSP430ADC12Single$dataReady(uint16_t arg_0x26c5100);
static   uint16_t *InternalVoltageM$ADCMultiple$default$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0);
static   uint16_t *InternalVoltageM$MSP430ADC12Multiple$dataReady(uint16_t *arg_0x2712288, uint16_t arg_0x2712408);
static  result_t InternalVoltageM$StdControl$init(void);
static  result_t InternalVoltageM$StdControl$start(void);
static  result_t InternalVoltageM$StdControl$stop(void);
static  result_t AttrVoltageM$AttrRegister$getAttr(char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
static  result_t AttrVoltageM$AttrRegister$startAttr(void);
static   result_t AttrVoltageM$ADC$dataReady(uint16_t arg_0x26a91b8);
static  result_t AttrVoltageM$StdControl$init(void);
static  result_t AttrVoltageM$StdControl$start(void);
static  result_t AttrVoltageM$StdControl$stop(void);
static  result_t DBBufferC$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
static  result_t DBBufferC$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0);
static  result_t DBBufferC$AttrUse$startAttrDone(uint8_t arg_0x2049670);
static  bool DBBufferC$RadioQueue$enqueueDone(void);
static  result_t DBBufferC$MemAlloc$compactComplete(void);
static  result_t DBBufferC$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
static  result_t DBBufferC$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
static  TinyDBError DBBufferC$DBBuffer$getField(uint8_t arg_0x20d6df0, QueryResult *arg_0x20d5010, uint8_t arg_0x20d5188, char *arg_0x20d5320);
static  TinyDBError DBBufferC$DBBuffer$enqueue(uint8_t arg_0x20d9558, QueryResultPtr arg_0x20d96d8, bool *arg_0x20d9870, ParsedQueryPtr arg_0x20d99f0);
static  TinyDBError DBBufferC$DBBuffer$getResult(uint8_t arg_0x20d7b28, uint16_t arg_0x20d7ca8, QueryResult *arg_0x20d7e48, bool *arg_0x20d6010);
static  ParsedQuery **DBBufferC$DBBuffer$getSchema(uint8_t arg_0x20d2890);
static  TinyDBError DBBufferC$DBBuffer$peek(uint8_t arg_0x20d7088, QueryResult *arg_0x20d7228, bool *arg_0x20d73c0);
static  TinyDBError DBBufferC$DBBuffer$getFieldId(uint8_t arg_0x20d64a8, FieldPtr arg_0x20d6628, uint8_t *arg_0x20d67c0);
static  TinyDBError DBBufferC$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650);
static  TinyDBError DBBufferC$DBBuffer$size(uint8_t arg_0x20d2230, uint16_t *arg_0x20d23d0);
static  result_t DBBufferC$StdControl$init(void);
static  result_t DBBufferC$StdControl$start(void);
static  result_t DBBufferC$StdControl$stop(void);
static  uint8_t DBBufferC$CatalogTable$catalogFieldSize(uint8_t arg_0x22c7468, uint8_t arg_0x22c75e0);
static  result_t ServiceSchedulerM$AbsoluteTimer$fired(void);
static  result_t ServiceSchedulerM$Services$default$start(uint8_t arg_0x2903420);
static  result_t ServiceSchedulerM$Services$default$stop(uint8_t arg_0x2903420);
static  result_t ServiceSchedulerM$SchedulerClt$init(void);
static  result_t ServiceSchedulerM$SchedulerClt$start(void);
static  result_t ServiceSchedulerM$SchedulerClt$stop(void);
static  tos_time_t ServiceSchedulerM$ServiceScheduler$getNextEventTime(uint8_t arg_0x20eb168);
static  result_t ServiceSchedulerM$ServiceScheduler$setExtraSleepTime(uint8_t arg_0x20eb5e8, int32_t arg_0x20eb768);
static  result_t ServiceSchedulerM$ServiceScheduler$remove(uint8_t arg_0x20ebbe0);
static  result_t ServiceSchedulerM$ServiceScheduler$reschedule(uint8_t arg_0x20eeab0, tos_service_schedule arg_0x20eec58);
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MainM.nc"
static  result_t MainM$hardwareInit(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t MainM$StdControl$init(void);






static  result_t MainM$StdControl$start(void);
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MainM.nc"
int   main(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t HPLInitM$MSP430ClockControl$init(void);






static  result_t HPLInitM$MSP430ClockControl$start(void);
# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLInitM.nc"
static inline  result_t HPLInitM$init(void);
# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockInit.nc"
static  void MSP430ClockM$MSP430ClockInit$initTimerB(void);
#line 28
static  void MSP430ClockM$MSP430ClockInit$initTimerA(void);
#line 27
static  void MSP430ClockM$MSP430ClockInit$initClocks(void);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
 static volatile uint8_t MSP430ClockM$IE1 __asm ("0x0000");
 static volatile uint16_t MSP430ClockM$TA0CTL __asm ("0x0160");
 static volatile uint16_t MSP430ClockM$TA0IV __asm ("0x012E");
 static volatile uint16_t MSP430ClockM$TBCTL __asm ("0x0180");
 static volatile uint16_t MSP430ClockM$TBIV __asm ("0x011E");

enum MSP430ClockM$__nesc_unnamed4356 {

  MSP430ClockM$ACLK_CALIB_PERIOD = 8, 
  MSP430ClockM$ACLK_KHZ = 32, 
  MSP430ClockM$TARGET_DCO_KHZ = 4096, 
  MSP430ClockM$TARGET_DCO_DELTA = MSP430ClockM$TARGET_DCO_KHZ / MSP430ClockM$ACLK_KHZ * MSP430ClockM$ACLK_CALIB_PERIOD
};

static inline  void MSP430ClockM$MSP430ClockInit$defaultInitClocks(void);
#line 69
static inline  void MSP430ClockM$MSP430ClockInit$defaultInitTimerA(void);
#line 84
static inline  void MSP430ClockM$MSP430ClockInit$defaultInitTimerB(void);
#line 99
static inline   void MSP430ClockM$MSP430ClockInit$default$initClocks(void);




static inline   void MSP430ClockM$MSP430ClockInit$default$initTimerA(void);




static inline   void MSP430ClockM$MSP430ClockInit$default$initTimerB(void);





static inline void MSP430ClockM$startTimerA(void);
#line 127
static inline void MSP430ClockM$startTimerB(void);
#line 139
static void MSP430ClockM$set_dco_calib(int calib);





static inline uint16_t MSP430ClockM$test_calib_busywait_delta(int calib);
#line 168
static inline void MSP430ClockM$busyCalibrateDCO(void);
#line 201
static inline  result_t MSP430ClockM$StdControl$init(void);
#line 220
static inline  result_t MSP430ClockM$StdControl$start(void);
# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
static   uint16_t MSP430DCOCalibM$Timer32khz$read(void);
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430DCOCalibM.nc"
uint16_t MSP430DCOCalibM$m_prev;

enum MSP430DCOCalibM$__nesc_unnamed4357 {

  MSP430DCOCalibM$TARGET_DELTA = 2048, 
  MSP430DCOCalibM$MAX_DEVIATION = 7
};


static inline   void MSP430DCOCalibM$TimerMicro$overflow(void);
#line 75
static inline   void MSP430DCOCalibM$Timer32khz$overflow(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureA1$captured(uint16_t arg_0x162ad18);
#line 74
static   void MSP430TimerM$CaptureB3$captured(uint16_t arg_0x162ad18);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareA1$fired(void);
#line 34
static   void MSP430TimerM$CompareB3$fired(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureB6$captured(uint16_t arg_0x162ad18);
#line 74
static   void MSP430TimerM$CaptureB1$captured(uint16_t arg_0x162ad18);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareB1$fired(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureA2$captured(uint16_t arg_0x162ad18);
#line 74
static   void MSP430TimerM$CaptureB4$captured(uint16_t arg_0x162ad18);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareA2$fired(void);
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
static   void MSP430TimerM$TimerA$overflow(void);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareB4$fired(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureA0$captured(uint16_t arg_0x162ad18);
#line 74
static   void MSP430TimerM$CaptureB2$captured(uint16_t arg_0x162ad18);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareA0$fired(void);
#line 34
static   void MSP430TimerM$CompareB2$fired(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureB5$captured(uint16_t arg_0x162ad18);
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
static   void MSP430TimerM$TimerB$overflow(void);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareB5$fired(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void MSP430TimerM$CaptureB0$captured(uint16_t arg_0x162ad18);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430TimerM$CompareB6$fired(void);
#line 34
static   void MSP430TimerM$CompareB0$fired(void);
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
 static volatile uint16_t MSP430TimerM$TA0CTL __asm ("0x0160");

 static volatile uint16_t MSP430TimerM$TA0CCTL0 __asm ("0x0162");
 static volatile uint16_t MSP430TimerM$TA0CCTL1 __asm ("0x0164");
 static volatile uint16_t MSP430TimerM$TA0CCTL2 __asm ("0x0166");

 static volatile uint16_t MSP430TimerM$TA0CCR0 __asm ("0x0172");
 static volatile uint16_t MSP430TimerM$TA0CCR1 __asm ("0x0174");
 static volatile uint16_t MSP430TimerM$TA0CCR2 __asm ("0x0176");

 static volatile uint16_t MSP430TimerM$TBCCTL0 __asm ("0x0182");
 static volatile uint16_t MSP430TimerM$TBCCTL1 __asm ("0x0184");
 static volatile uint16_t MSP430TimerM$TBCCTL2 __asm ("0x0186");
 static volatile uint16_t MSP430TimerM$TBCCTL3 __asm ("0x0188");
 static volatile uint16_t MSP430TimerM$TBCCTL4 __asm ("0x018A");
 static volatile uint16_t MSP430TimerM$TBCCTL5 __asm ("0x018C");
 static volatile uint16_t MSP430TimerM$TBCCTL6 __asm ("0x018E");

 static volatile uint16_t MSP430TimerM$TBCCR0 __asm ("0x0192");
 static volatile uint16_t MSP430TimerM$TBCCR1 __asm ("0x0194");
 static volatile uint16_t MSP430TimerM$TBCCR2 __asm ("0x0196");
 static volatile uint16_t MSP430TimerM$TBCCR3 __asm ("0x0198");
 static volatile uint16_t MSP430TimerM$TBCCR4 __asm ("0x019A");
 static volatile uint16_t MSP430TimerM$TBCCR5 __asm ("0x019C");
 static volatile uint16_t MSP430TimerM$TBCCR6 __asm ("0x019E");

typedef MSP430CompareControl_t MSP430TimerM$CC_t;

static inline uint16_t MSP430TimerM$CC2int(MSP430TimerM$CC_t x);
static inline MSP430TimerM$CC_t MSP430TimerM$int2CC(uint16_t x);

static inline uint16_t MSP430TimerM$compareControl(void);
#line 110
static inline uint16_t MSP430TimerM$captureControl(uint8_t l_cm);
#line 123
void  __attribute((wakeup)) __attribute((interrupt(12))) sig_TIMERA0_VECTOR(void);







void  __attribute((wakeup)) __attribute((interrupt(10))) sig_TIMERA1_VECTOR(void);
#line 159
static inline    void MSP430TimerM$CompareA2$default$fired(void);
static inline    void MSP430TimerM$CaptureA0$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureA1$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureA2$default$captured(uint16_t time);



static inline   uint16_t MSP430TimerM$TimerB$read(void);


static inline   bool MSP430TimerM$TimerB$isOverflowPending(void);




static inline   void MSP430TimerM$TimerA$setMode(int mode);




static inline   void MSP430TimerM$TimerA$clear(void);


static inline   void MSP430TimerM$TimerA$disableEvents(void);


static inline   void MSP430TimerM$TimerA$setClockSource(uint16_t clockSource);









static inline   void MSP430TimerM$TimerA$setInputDivider(uint16_t inputDivider);









static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA0$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA1$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA2$getControl(void);









static inline   void MSP430TimerM$ControlA0$setControl(MSP430TimerM$CC_t x);
static inline   void MSP430TimerM$ControlA1$setControl(MSP430TimerM$CC_t x);
#line 253
static inline   uint16_t MSP430TimerM$CaptureA0$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureA1$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureA2$getEvent(void);

static inline   void MSP430TimerM$CompareA0$setEvent(uint16_t x);
static inline   void MSP430TimerM$CompareA1$setEvent(uint16_t x);
#line 277
void  __attribute((wakeup)) __attribute((interrupt(26))) sig_TIMERB0_VECTOR(void);







void  __attribute((wakeup)) __attribute((interrupt(24))) sig_TIMERB1_VECTOR(void);
#line 331
static inline    void MSP430TimerM$CompareB0$default$fired(void);
static inline    void MSP430TimerM$CompareB1$default$fired(void);
static inline    void MSP430TimerM$CompareB2$default$fired(void);


static inline    void MSP430TimerM$CompareB5$default$fired(void);
static inline    void MSP430TimerM$CompareB6$default$fired(void);
static inline    void MSP430TimerM$CaptureB0$default$captured(uint16_t time);

static inline    void MSP430TimerM$CaptureB2$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureB3$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureB4$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureB5$default$captured(uint16_t time);
static inline    void MSP430TimerM$CaptureB6$default$captured(uint16_t time);


static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB0$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB1$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB2$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB3$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB4$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB5$getControl(void);
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB6$getControl(void);










static inline   void MSP430TimerM$ControlB1$clearPendingInterrupt(void);

static inline   void MSP430TimerM$ControlB3$clearPendingInterrupt(void);
static inline   void MSP430TimerM$ControlB4$clearPendingInterrupt(void);
#line 382
static inline   void MSP430TimerM$ControlB3$setControlAsCompare(void);
static inline   void MSP430TimerM$ControlB4$setControlAsCompare(void);




static inline   void MSP430TimerM$ControlB1$setControlAsCapture(uint8_t cm);
#line 412
static inline   void MSP430TimerM$ControlB1$enableEvents(void);

static inline   void MSP430TimerM$ControlB3$enableEvents(void);
static inline   void MSP430TimerM$ControlB4$enableEvents(void);




static inline   void MSP430TimerM$ControlB1$disableEvents(void);

static inline   void MSP430TimerM$ControlB3$disableEvents(void);
static inline   void MSP430TimerM$ControlB4$disableEvents(void);
#line 443
static inline   uint16_t MSP430TimerM$CaptureB0$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB1$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB2$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB3$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB4$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB5$getEvent(void);
static inline   uint16_t MSP430TimerM$CaptureB6$getEvent(void);
#line 470
static inline   void MSP430TimerM$CompareB3$setEventFromNow(uint16_t x);
static inline   void MSP430TimerM$CompareB4$setEventFromNow(uint16_t x);




static inline   bool MSP430TimerM$CaptureB1$isOverflowPending(void);







static inline   void MSP430TimerM$CaptureB1$clearOverflow(void);
# 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
static  bool NetworkMultiHopM$QueryProcessor$queryProcessorWantsData(QueryResult *arg_0x1773ad0);
#line 66
static  short NetworkMultiHopM$QueryProcessor$numQueries(void);
static  ParsedQueryPtr NetworkMultiHopM$QueryProcessor$getQueryIdx(short arg_0x1773630);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t NetworkMultiHopM$SendStatusMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
# 112 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
static  result_t NetworkMultiHopM$Network$sendDataDone(TOS_MsgPtr arg_0x17b96e0, result_t arg_0x17b9860);
#line 162
static  result_t NetworkMultiHopM$Network$sendQueryDone(TOS_MsgPtr arg_0x17b7c28, result_t arg_0x17b7da8);





static  result_t NetworkMultiHopM$Network$dataSub(QueryResultPtr arg_0x17b6330);





static  result_t NetworkMultiHopM$Network$querySub(QueryMessagePtr arg_0x17b6898);
# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
static  result_t NetworkMultiHopM$Send$send(TOS_MsgPtr arg_0x17c4a58, uint16_t arg_0x17c4bd8);
#line 106
static  void *NetworkMultiHopM$Send$getBuffer(TOS_MsgPtr arg_0x17c3328, uint16_t *arg_0x17c34c8);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t NetworkMultiHopM$SendQueryMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t NetworkMultiHopM$Leds$greenToggle(void);
#line 81
static   result_t NetworkMultiHopM$Leds$redToggle(void);
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
static  uint16_t NetworkMultiHopM$MultiHopControl$getParent(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t NetworkMultiHopM$MultiHopStdControl$init(void);






static  result_t NetworkMultiHopM$MultiHopStdControl$start(void);







static  result_t NetworkMultiHopM$MultiHopStdControl$stop(void);
# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
TOS_Msg NetworkMultiHopM$mDbg;
bool NetworkMultiHopM$mWasCommand;
uint8_t NetworkMultiHopM$mLastSeqNo;
enum NetworkMultiHopM$__nesc_unnamed4358 {
  NetworkMultiHopM$MAX_MISSED_CMDS = 8
};

static inline  result_t NetworkMultiHopM$StdControl$init(void);






static inline  result_t NetworkMultiHopM$StdControl$start(void);




static inline  result_t NetworkMultiHopM$StdControl$stop(void);




static inline  QueryResultPtr NetworkMultiHopM$Network$getDataPayLoad(TOS_MsgPtr msg);





static inline  TinyDBError NetworkMultiHopM$Network$sendDataMessage(TOS_MsgPtr msg);
#line 209
static inline  result_t NetworkMultiHopM$Send$sendDone(TOS_MsgPtr msg, result_t success);






static inline  QueryMessagePtr NetworkMultiHopM$Network$getQueryPayLoad(TOS_MsgPtr msg);




static  TinyDBError NetworkMultiHopM$Network$sendQueryMessage(TOS_MsgPtr msg);
#line 253
static inline  result_t NetworkMultiHopM$SendQueryMsg$sendDone(TOS_MsgPtr msg, result_t success);
#line 290
static inline  result_t NetworkMultiHopM$SendStatusMsg$sendDone(TOS_MsgPtr msg, result_t success);





static inline  TOS_MsgPtr NetworkMultiHopM$RcvQueryMsg$receive(TOS_MsgPtr msg);
#line 314
static inline  result_t NetworkMultiHopM$Intercept$intercept(TOS_MsgPtr msg, void *payload, uint16_t payloadLen);
#line 331
static inline  result_t NetworkMultiHopM$Snoop$intercept(TOS_MsgPtr msg, void *payload, uint16_t payloadLen);
#line 427
static inline  TOS_MsgPtr NetworkMultiHopM$RcvStatusMessage$receive(TOS_MsgPtr msg);
#line 529
static inline  result_t NetworkMultiHopM$QueryProcessor$queryComplete(ParsedQueryPtr q);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
static  TOS_MsgPtr AMStandard$ReceiveMsg$receive(
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
uint8_t arg_0x1824870, 
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
TOS_MsgPtr arg_0x17efd58);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t AMStandard$ActivityTimer$start(char arg_0x1841820, uint32_t arg_0x18419a8);








static  result_t AMStandard$ActivityTimer$stop(void);
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc"
static   uint8_t AMStandard$PowerManagement$adjustPower(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t AMStandard$RadioControl$init(void);






static  result_t AMStandard$RadioControl$start(void);







static  result_t AMStandard$RadioControl$stop(void);
#line 63
static  result_t AMStandard$TimerControl$init(void);






static  result_t AMStandard$TimerControl$start(void);
#line 63
static  result_t AMStandard$UARTControl$init(void);






static  result_t AMStandard$UARTControl$start(void);







static  result_t AMStandard$UARTControl$stop(void);
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static  result_t AMStandard$sendDone(void);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t AMStandard$SendMsg$sendDone(
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
uint8_t arg_0x1824218, 
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
bool AMStandard$state;

uint16_t AMStandard$lastCount;
uint16_t AMStandard$counter;


static inline  bool AMStandard$Control$init(void);
#line 103
static inline  bool AMStandard$Control$start(void);
#line 119
static inline  bool AMStandard$Control$stop(void);
#line 132
static inline void AMStandard$dbgPacket(TOS_MsgPtr data);










static result_t AMStandard$reportSendDone(TOS_MsgPtr msg, result_t success);







static inline  result_t AMStandard$ActivityTimer$fired(void);





static inline   result_t AMStandard$SendMsg$default$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success);


static inline   result_t AMStandard$default$sendDone(void);
#line 207
static inline  result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr msg, result_t success);


static inline  result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr msg, result_t success);




TOS_MsgPtr   received(TOS_MsgPtr packet);
#line 242
static inline   TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg);



static inline  TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr packet);





static inline  TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr packet);
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
static  result_t CC2420RadioM$SplitControl$initDone(void);
#line 85
static  result_t CC2420RadioM$SplitControl$startDone(void);
#line 99
static  result_t CC2420RadioM$SplitControl$stopDone(void);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
static   result_t CC2420RadioM$FIFOP$disable(void);
#line 43
static   result_t CC2420RadioM$FIFOP$startWait(bool arg_0x192c1a0);
# 6 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
static   result_t CC2420RadioM$BackoffTimerJiffy$setOneShot(uint32_t arg_0x1921100);



static   bool CC2420RadioM$BackoffTimerJiffy$isSet(void);
#line 8
static   result_t CC2420RadioM$BackoffTimerJiffy$stop(void);
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
static  result_t CC2420RadioM$Send$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
static   uint16_t CC2420RadioM$Random$rand(void);
#line 57
static   result_t CC2420RadioM$Random$init(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t CC2420RadioM$TimerControl$init(void);






static  result_t CC2420RadioM$TimerControl$start(void);







static  result_t CC2420RadioM$TimerControl$stop(void);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
static  TOS_MsgPtr CC2420RadioM$Receive$receive(TOS_MsgPtr arg_0x17efd58);
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
static   uint16_t CC2420RadioM$HPLChipcon$read(uint8_t arg_0x1904010);
#line 47
static   uint8_t CC2420RadioM$HPLChipcon$cmd(uint8_t arg_0x1906450);
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
static   void CC2420RadioM$RadioReceiveCoordinator$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308);
# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Capture.nc"
static   result_t CC2420RadioM$SFD$disable(void);
#line 43
static   result_t CC2420RadioM$SFD$enableCapture(bool arg_0x1927e18);
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
static   void CC2420RadioM$RadioSendCoordinator$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308);
# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
static   result_t CC2420RadioM$HPLChipconFIFO$writeTXFIFO(uint8_t arg_0x1900bc0, uint8_t *arg_0x1900d58);
#line 19
static   result_t CC2420RadioM$HPLChipconFIFO$readRXFIFO(uint8_t arg_0x19003d8, uint8_t *arg_0x1900570);
# 163 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420Control.nc"
static   result_t CC2420RadioM$CC2420Control$RxMode(void);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/MacBackoff.nc"
static   int16_t CC2420RadioM$MacBackoff$initialBackoff(TOS_MsgPtr arg_0x18c1850);
static   int16_t CC2420RadioM$MacBackoff$congestionBackoff(TOS_MsgPtr arg_0x18c1cf0);
# 64 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
static  result_t CC2420RadioM$CC2420SplitControl$init(void);
#line 77
static  result_t CC2420RadioM$CC2420SplitControl$start(void);
#line 93
static  result_t CC2420RadioM$CC2420SplitControl$stop(void);
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
enum CC2420RadioM$__nesc_unnamed4359 {
  CC2420RadioM$DISABLED_STATE = 0, 
  CC2420RadioM$DISABLED_STATE_STARTTASK, 
  CC2420RadioM$IDLE_STATE, 
  CC2420RadioM$TX_STATE, 
  CC2420RadioM$TX_WAIT, 
  CC2420RadioM$PRE_TX_STATE, 
  CC2420RadioM$POST_TX_STATE, 
  CC2420RadioM$POST_TX_ACK_STATE, 
  CC2420RadioM$RX_STATE, 
  CC2420RadioM$POWER_DOWN_STATE, 
  CC2420RadioM$WARMUP_STATE, 

  CC2420RadioM$TIMER_INITIAL = 0, 
  CC2420RadioM$TIMER_BACKOFF, 
  CC2420RadioM$TIMER_ACK
};



 uint8_t CC2420RadioM$countRetry;
uint8_t CC2420RadioM$stateRadio;
 uint8_t CC2420RadioM$stateTimer;
 uint8_t CC2420RadioM$currentDSN;
 bool CC2420RadioM$bAckEnable;
bool CC2420RadioM$bPacketReceiving;
uint8_t CC2420RadioM$txlength;
 TOS_MsgPtr CC2420RadioM$txbufptr;
 TOS_MsgPtr CC2420RadioM$rxbufptr;
TOS_Msg CC2420RadioM$RxBuf;

volatile uint16_t CC2420RadioM$LocalAddr;





static void CC2420RadioM$sendFailed(void);





static void CC2420RadioM$flushRXFIFO(void);








static __inline result_t CC2420RadioM$setInitialTimer(uint16_t jiffy);







static __inline result_t CC2420RadioM$setBackoffTimer(uint16_t jiffy);







static __inline result_t CC2420RadioM$setAckTimer(uint16_t jiffy);








static inline  void CC2420RadioM$PacketRcvd(void);
#line 168
static  void CC2420RadioM$PacketSent(void);
#line 186
static inline  result_t CC2420RadioM$StdControl$init(void);




static inline  result_t CC2420RadioM$SplitControl$init(void);
#line 208
static inline  result_t CC2420RadioM$CC2420SplitControl$initDone(void);



static inline   result_t CC2420RadioM$SplitControl$default$initDone(void);




static inline  result_t CC2420RadioM$StdControl$stop(void);




static inline  result_t CC2420RadioM$SplitControl$stop(void);








static inline  result_t CC2420RadioM$CC2420SplitControl$stopDone(void);



static inline   result_t CC2420RadioM$SplitControl$default$stopDone(void);



static inline  void CC2420RadioM$startRadio(void);
#line 253
static inline  result_t CC2420RadioM$StdControl$start(void);
#line 277
static inline  result_t CC2420RadioM$SplitControl$start(void);
#line 294
static inline  result_t CC2420RadioM$CC2420SplitControl$startDone(void);
#line 312
static inline   result_t CC2420RadioM$SplitControl$default$startDone(void);








static inline void CC2420RadioM$sendPacket(void);
#line 344
static inline   result_t CC2420RadioM$SFD$captured(uint16_t time);
#line 393
static  void CC2420RadioM$startSend(void);
#line 410
static void CC2420RadioM$tryToSend(void);
#line 449
static inline   result_t CC2420RadioM$BackoffTimerJiffy$fired(void);
#line 491
static inline  result_t CC2420RadioM$Send$send(TOS_MsgPtr pMsg);
#line 534
static void CC2420RadioM$delayedRXFIFO(void);

static inline  void CC2420RadioM$delayedRXFIFOtask(void);



static void CC2420RadioM$delayedRXFIFO(void);
#line 591
static inline   result_t CC2420RadioM$FIFOP$fired(void);
#line 628
static inline   result_t CC2420RadioM$HPLChipconFIFO$RXFIFODone(uint8_t length, uint8_t *data);
#line 721
static inline   result_t CC2420RadioM$HPLChipconFIFO$TXFIFODone(uint8_t length, uint8_t *data);
#line 744
static inline    int16_t CC2420RadioM$MacBackoff$default$initialBackoff(TOS_MsgPtr m);






static inline    int16_t CC2420RadioM$MacBackoff$default$congestionBackoff(TOS_MsgPtr m);







static inline    void CC2420RadioM$RadioSendCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset, TOS_MsgPtr msgBuff);

static inline    void CC2420RadioM$RadioReceiveCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset, TOS_MsgPtr msgBuff);
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
static  result_t CC2420ControlM$SplitControl$initDone(void);
#line 85
static  result_t CC2420ControlM$SplitControl$startDone(void);
#line 99
static  result_t CC2420ControlM$SplitControl$stopDone(void);
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
static   uint16_t CC2420ControlM$HPLChipcon$read(uint8_t arg_0x1904010);
#line 54
static   uint8_t CC2420ControlM$HPLChipcon$write(uint8_t arg_0x1906940, uint16_t arg_0x1906ac0);
#line 47
static   uint8_t CC2420ControlM$HPLChipcon$cmd(uint8_t arg_0x1906450);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
static   result_t CC2420ControlM$CCA$disable(void);
#line 43
static   result_t CC2420ControlM$CCA$startWait(bool arg_0x192c1a0);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t CC2420ControlM$HPLChipconControl$init(void);






static  result_t CC2420ControlM$HPLChipconControl$start(void);







static  result_t CC2420ControlM$HPLChipconControl$stop(void);
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420RAM.nc"
static   result_t CC2420ControlM$HPLChipconRAM$write(uint16_t arg_0x19c15f0, uint8_t arg_0x19c1768, uint8_t *arg_0x19c1900);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
enum CC2420ControlM$__nesc_unnamed4360 {
  CC2420ControlM$IDLE_STATE = 0, 
  CC2420ControlM$INIT_STATE, 
  CC2420ControlM$INIT_STATE_DONE, 
  CC2420ControlM$START_STATE, 
  CC2420ControlM$START_STATE_DONE, 
  CC2420ControlM$STOP_STATE
};

uint8_t CC2420ControlM$state = 0;
 uint16_t CC2420ControlM$gCurrentParameters[14];






static inline bool CC2420ControlM$SetRegs(void);
#line 108
static inline  void CC2420ControlM$taskInitDone(void);



static inline  void CC2420ControlM$taskStopDone(void);



static inline  void CC2420ControlM$PostOscillatorOn(void);
#line 129
static inline  result_t CC2420ControlM$SplitControl$init(void);
#line 191
static inline  result_t CC2420ControlM$SplitControl$stop(void);
#line 227
static inline  result_t CC2420ControlM$SplitControl$start(void);
#line 286
static inline  result_t CC2420ControlM$CC2420Control$TuneManual(uint16_t DesiredFreq);
#line 343
static inline   result_t CC2420ControlM$CC2420Control$RxMode(void);
#line 368
static inline   result_t CC2420ControlM$CC2420Control$OscillatorOn(void);
#line 400
static inline   result_t CC2420ControlM$CC2420Control$VREFOn(void);






static inline   result_t CC2420ControlM$CC2420Control$VREFOff(void);
#line 432
static inline  result_t CC2420ControlM$CC2420Control$setShortAddress(uint16_t addr);








static inline   result_t CC2420ControlM$HPLChipconRAM$writeDone(uint16_t addr, uint8_t length, uint8_t *buffer);



static inline   result_t CC2420ControlM$CCA$fired(void);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
static   result_t HPLCC2420M$HPLCC2420FIFO$TXFIFODone(uint8_t arg_0x1931a90, uint8_t *arg_0x1931c28);
#line 39
static   result_t HPLCC2420M$HPLCC2420FIFO$RXFIFODone(uint8_t arg_0x1931350, uint8_t *arg_0x19314e8);
# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
static   result_t HPLCC2420M$USARTControl$isTxEmpty(void);
#line 115
static   void HPLCC2420M$USARTControl$disableSPI(void);
#line 172
static   result_t HPLCC2420M$USARTControl$disableRxIntr(void);
static   result_t HPLCC2420M$USARTControl$disableTxIntr(void);
#line 135
static   void HPLCC2420M$USARTControl$setModeSPI(void);
#line 180
static   result_t HPLCC2420M$USARTControl$isTxIntrPending(void);
#line 202
static   result_t HPLCC2420M$USARTControl$tx(uint8_t arg_0x1a693b8);






static   uint8_t HPLCC2420M$USARTControl$rx(void);
#line 185
static   result_t HPLCC2420M$USARTControl$isRxIntrPending(void);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420RAM.nc"
static   result_t HPLCC2420M$HPLCC2420RAM$writeDone(uint16_t arg_0x19c1e18, uint8_t arg_0x19c0010, uint8_t *arg_0x19c01a8);
# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitration.nc"
static   result_t HPLCC2420M$BusArbitration$releaseBus(void);
#line 37
static   result_t HPLCC2420M$BusArbitration$getBus(void);
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
 uint8_t *HPLCC2420M$txbuf;
 uint8_t *HPLCC2420M$rxbuf;
 uint8_t *HPLCC2420M$rambuf;

 uint8_t HPLCC2420M$txlen;
 uint8_t HPLCC2420M$rxlen;
 uint8_t HPLCC2420M$ramlen;
 uint16_t HPLCC2420M$ramaddr;








 
#line 68
struct HPLCC2420M$__nesc_unnamed4361 {
  bool enabled : 1;
  bool busy : 1;
  bool rxbufBusy : 1;
  bool txbufBusy : 1;
} HPLCC2420M$f;





static inline uint8_t HPLCC2420M$adjustStatusByte(uint8_t status);



static inline  result_t HPLCC2420M$StdControl$init(void);
#line 96
static inline  result_t HPLCC2420M$StdControl$start(void);
#line 111
static inline  result_t HPLCC2420M$StdControl$stop(void);
#line 127
static   uint8_t HPLCC2420M$HPLCC2420$cmd(uint8_t addr);
#line 162
static   uint8_t HPLCC2420M$HPLCC2420$write(uint8_t addr, uint16_t data);
#line 205
static   uint16_t HPLCC2420M$HPLCC2420$read(uint8_t addr);
#line 288
static inline  void HPLCC2420M$signalRAMWr(void);



static inline   result_t HPLCC2420M$HPLCC2420RAM$write(uint16_t addr, uint8_t _length, uint8_t *buffer);
#line 322
static inline  void HPLCC2420M$signalRXFIFO(void);
#line 335
static inline   result_t HPLCC2420M$HPLCC2420FIFO$readRXFIFO(uint8_t length, uint8_t *data);
#line 394
static inline  void HPLCC2420M$signalTXFIFO(void);
#line 415
static inline   result_t HPLCC2420M$HPLCC2420FIFO$writeTXFIFO(uint8_t length, uint8_t *data);
#line 461
static inline  result_t HPLCC2420M$BusArbitration$busFree(void);
# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLI2CInterrupt.nc"
static   void HPLUSART0M$HPLI2CInterrupt$fired(void);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
static   result_t HPLUSART0M$USARTData$rxDone(uint8_t arg_0x1af0a38);
#line 46
static   result_t HPLUSART0M$USARTData$txDone(void);
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
 static volatile uint8_t HPLUSART0M$IE1 __asm ("0x0000");
 static volatile uint8_t HPLUSART0M$ME1 __asm ("0x0004");
 static volatile uint8_t HPLUSART0M$IFG1 __asm ("0x0002");
 static volatile uint8_t HPLUSART0M$U0TCTL __asm ("0x0071");
 static volatile uint8_t HPLUSART0M$U0TXBUF __asm ("0x0077");


uint16_t HPLUSART0M$l_br;

uint8_t HPLUSART0M$l_ssel;

void  __attribute((wakeup)) __attribute((interrupt(18))) sig_UART0RX_VECTOR(void);




void  __attribute((wakeup)) __attribute((interrupt(16))) sig_UART0TX_VECTOR(void);






static inline    void HPLUSART0M$HPLI2CInterrupt$default$fired(void);

static inline   bool HPLUSART0M$USARTControl$isSPI(void);








static inline   bool HPLUSART0M$USARTControl$isUART(void);










static inline   bool HPLUSART0M$USARTControl$isUARTtx(void);










static inline   bool HPLUSART0M$USARTControl$isUARTrx(void);










static   bool HPLUSART0M$USARTControl$isI2C(void);










static inline   msp430_usartmode_t HPLUSART0M$USARTControl$getMode(void);
#line 172
static inline   void HPLUSART0M$USARTControl$disableUART(void);
#line 205
static inline   void HPLUSART0M$USARTControl$disableSPI(void);
#line 218
static inline   void HPLUSART0M$USARTControl$disableI2C(void);






static   void HPLUSART0M$USARTControl$setModeSPI(void);
#line 424
static inline   result_t HPLUSART0M$USARTControl$isTxIntrPending(void);







static inline   result_t HPLUSART0M$USARTControl$isTxEmpty(void);






static inline   result_t HPLUSART0M$USARTControl$isRxIntrPending(void);







static inline   result_t HPLUSART0M$USARTControl$disableRxIntr(void);




static inline   result_t HPLUSART0M$USARTControl$disableTxIntr(void);
#line 473
static inline   result_t HPLUSART0M$USARTControl$tx(uint8_t data);




static inline   uint8_t HPLUSART0M$USARTControl$rx(void);







static inline    result_t HPLUSART0M$USARTData$default$txDone(void);

static inline    result_t HPLUSART0M$USARTData$default$rxDone(uint8_t data);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
static   result_t HPLCC2420InterruptM$FIFO$fired(void);
#line 51
static   result_t HPLCC2420InterruptM$FIFOP$fired(void);
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
static   void HPLCC2420InterruptM$CCAInterrupt$clear(void);
#line 35
static   void HPLCC2420InterruptM$CCAInterrupt$disable(void);
#line 54
static   void HPLCC2420InterruptM$CCAInterrupt$edge(bool arg_0x1b71710);
#line 30
static   void HPLCC2420InterruptM$CCAInterrupt$enable(void);
# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
static   void HPLCC2420InterruptM$SFDControl$setControlAsCapture(bool arg_0x1600d08);

static   void HPLCC2420InterruptM$SFDControl$enableEvents(void);
static   void HPLCC2420InterruptM$SFDControl$disableEvents(void);
#line 32
static   void HPLCC2420InterruptM$SFDControl$clearPendingInterrupt(void);
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
static   void HPLCC2420InterruptM$FIFOInterrupt$clear(void);
#line 35
static   void HPLCC2420InterruptM$FIFOInterrupt$disable(void);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
static   result_t HPLCC2420InterruptM$CCA$fired(void);
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
static   void HPLCC2420InterruptM$SFDCapture$clearOverflow(void);
#line 51
static   bool HPLCC2420InterruptM$SFDCapture$isOverflowPending(void);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Capture.nc"
static   result_t HPLCC2420InterruptM$SFD$captured(uint16_t arg_0x1926478);
# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
static   void HPLCC2420InterruptM$FIFOPInterrupt$clear(void);
#line 35
static   void HPLCC2420InterruptM$FIFOPInterrupt$disable(void);
#line 54
static   void HPLCC2420InterruptM$FIFOPInterrupt$edge(bool arg_0x1b71710);
#line 30
static   void HPLCC2420InterruptM$FIFOPInterrupt$enable(void);
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static   result_t HPLCC2420InterruptM$FIFOP$startWait(bool low_to_high);
#line 78
static inline   result_t HPLCC2420InterruptM$FIFOP$disable(void);










static inline   void HPLCC2420InterruptM$FIFOPInterrupt$fired(void);
#line 130
static inline   void HPLCC2420InterruptM$FIFOInterrupt$fired(void);









static inline    result_t HPLCC2420InterruptM$FIFO$default$fired(void);






static inline   result_t HPLCC2420InterruptM$CCA$startWait(bool low_to_high);
#line 160
static inline   result_t HPLCC2420InterruptM$CCA$disable(void);










static inline   void HPLCC2420InterruptM$CCAInterrupt$fired(void);
#line 185
static   result_t HPLCC2420InterruptM$SFD$enableCapture(bool low_to_high);
#line 200
static inline   result_t HPLCC2420InterruptM$SFD$disable(void);








static inline   void HPLCC2420InterruptM$SFDCapture$captured(uint16_t time);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
static   void MSP430InterruptM$Port14$fired(void);
#line 59
static   void MSP430InterruptM$Port26$fired(void);
#line 59
static   void MSP430InterruptM$Port17$fired(void);
#line 59
static   void MSP430InterruptM$Port21$fired(void);
#line 59
static   void MSP430InterruptM$Port12$fired(void);
#line 59
static   void MSP430InterruptM$Port24$fired(void);
#line 59
static   void MSP430InterruptM$ACCV$fired(void);
#line 59
static   void MSP430InterruptM$Port15$fired(void);
#line 59
static   void MSP430InterruptM$Port27$fired(void);
#line 59
static   void MSP430InterruptM$Port10$fired(void);
#line 59
static   void MSP430InterruptM$Port22$fired(void);
#line 59
static   void MSP430InterruptM$OF$fired(void);
#line 59
static   void MSP430InterruptM$Port13$fired(void);
#line 59
static   void MSP430InterruptM$Port25$fired(void);
#line 59
static   void MSP430InterruptM$Port16$fired(void);
#line 59
static   void MSP430InterruptM$NMI$fired(void);
#line 59
static   void MSP430InterruptM$Port20$fired(void);
#line 59
static   void MSP430InterruptM$Port11$fired(void);
#line 59
static   void MSP430InterruptM$Port23$fired(void);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
 static volatile uint8_t MSP430InterruptM$P1IE __asm ("0x0025");
 static volatile uint8_t MSP430InterruptM$P2IE __asm ("0x002D");
 static volatile uint8_t MSP430InterruptM$P1IFG __asm ("0x0023");
 static volatile uint8_t MSP430InterruptM$P2IFG __asm ("0x002B");

void  __attribute((wakeup)) __attribute((interrupt(8))) sig_PORT1_VECTOR(void);
#line 71
void  __attribute((wakeup)) __attribute((interrupt(2))) sig_PORT2_VECTOR(void);
#line 85
void  __attribute((wakeup)) __attribute((interrupt(28))) sig_NMI_VECTOR(void);








static inline    void MSP430InterruptM$Port11$default$fired(void);
static inline    void MSP430InterruptM$Port12$default$fired(void);


static inline    void MSP430InterruptM$Port15$default$fired(void);
static inline    void MSP430InterruptM$Port16$default$fired(void);
static inline    void MSP430InterruptM$Port17$default$fired(void);

static inline    void MSP430InterruptM$Port20$default$fired(void);
static inline    void MSP430InterruptM$Port21$default$fired(void);
static inline    void MSP430InterruptM$Port22$default$fired(void);
static inline    void MSP430InterruptM$Port23$default$fired(void);
static inline    void MSP430InterruptM$Port24$default$fired(void);
static inline    void MSP430InterruptM$Port25$default$fired(void);
static inline    void MSP430InterruptM$Port26$default$fired(void);
static inline    void MSP430InterruptM$Port27$default$fired(void);

static inline    void MSP430InterruptM$NMI$default$fired(void);
static inline    void MSP430InterruptM$OF$default$fired(void);
static inline    void MSP430InterruptM$ACCV$default$fired(void);

static inline   void MSP430InterruptM$Port10$enable(void);



static inline   void MSP430InterruptM$Port14$enable(void);
#line 146
static inline   void MSP430InterruptM$Port10$disable(void);


static inline   void MSP430InterruptM$Port13$disable(void);
static inline   void MSP430InterruptM$Port14$disable(void);
#line 177
static inline   void MSP430InterruptM$Port10$clear(void);
static inline   void MSP430InterruptM$Port11$clear(void);
static inline   void MSP430InterruptM$Port12$clear(void);
static inline   void MSP430InterruptM$Port13$clear(void);
static inline   void MSP430InterruptM$Port14$clear(void);
static inline   void MSP430InterruptM$Port15$clear(void);
static inline   void MSP430InterruptM$Port16$clear(void);
static inline   void MSP430InterruptM$Port17$clear(void);

static inline   void MSP430InterruptM$Port20$clear(void);
static inline   void MSP430InterruptM$Port21$clear(void);
static inline   void MSP430InterruptM$Port22$clear(void);
static inline   void MSP430InterruptM$Port23$clear(void);
static inline   void MSP430InterruptM$Port24$clear(void);
static inline   void MSP430InterruptM$Port25$clear(void);
static inline   void MSP430InterruptM$Port26$clear(void);
static inline   void MSP430InterruptM$Port27$clear(void);

static inline   void MSP430InterruptM$NMI$clear(void);
static inline   void MSP430InterruptM$OF$clear(void);
static inline   void MSP430InterruptM$ACCV$clear(void);
#line 221
static inline   void MSP430InterruptM$Port10$edge(bool l2h);
#line 245
static inline   void MSP430InterruptM$Port14$edge(bool l2h);
# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitration.nc"
static  result_t BusArbitrationM$BusArbitration$busFree(
# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
uint8_t arg_0x1c93a50);





uint8_t BusArbitrationM$state;
uint8_t BusArbitrationM$busid;
bool BusArbitrationM$isBusReleasedPending;
enum BusArbitrationM$__nesc_unnamed4362 {
#line 40
  BusArbitrationM$BUS_IDLE, BusArbitrationM$BUS_BUSY, BusArbitrationM$BUS_OFF
};
static inline  void BusArbitrationM$busReleased(void);
#line 54
static inline  result_t BusArbitrationM$StdControl$init(void);







static inline  result_t BusArbitrationM$StdControl$start(void);
#line 78
static inline  result_t BusArbitrationM$StdControl$stop(void);
#line 94
static   result_t BusArbitrationM$BusArbitration$getBus(uint8_t id);
#line 108
static   result_t BusArbitrationM$BusArbitration$releaseBus(uint8_t id);
#line 125
static inline   result_t BusArbitrationM$BusArbitration$default$busFree(uint8_t id);
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
uint16_t RandomLFSR$shiftReg;
uint16_t RandomLFSR$initSeed;
uint16_t RandomLFSR$mask;


static inline   result_t RandomLFSR$Random$init(void);










static   uint16_t RandomLFSR$Random$rand(void);
# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
static   void TimerJiffyAsyncM$AlarmControl$enableEvents(void);
#line 35
static   void TimerJiffyAsyncM$AlarmControl$setControlAsCompare(void);



static   void TimerJiffyAsyncM$AlarmControl$disableEvents(void);
#line 32
static   void TimerJiffyAsyncM$AlarmControl$clearPendingInterrupt(void);
# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
static   result_t TimerJiffyAsyncM$TimerJiffyAsync$fired(void);
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void TimerJiffyAsyncM$AlarmCompare$setEventFromNow(uint16_t arg_0x1614010);
# 13 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
uint32_t TimerJiffyAsyncM$jiffy;
bool TimerJiffyAsyncM$bSet;

static inline  result_t TimerJiffyAsyncM$StdControl$init(void);






static inline  result_t TimerJiffyAsyncM$StdControl$start(void);








static inline  result_t TimerJiffyAsyncM$StdControl$stop(void);








static inline   void TimerJiffyAsyncM$AlarmCompare$fired(void);
#line 70
static   result_t TimerJiffyAsyncM$TimerJiffyAsync$setOneShot(uint32_t _jiffy);
#line 97
static inline   bool TimerJiffyAsyncM$TimerJiffyAsync$isSet(void);






static inline   result_t TimerJiffyAsyncM$TimerJiffyAsync$stop(void);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
uint8_t LedsC$ledsOn;

enum LedsC$__nesc_unnamed4363 {
  LedsC$RED_BIT = 1, 
  LedsC$GREEN_BIT = 2, 
  LedsC$YELLOW_BIT = 4
};
#line 72
static inline   result_t LedsC$Leds$redOn(void);








static inline   result_t LedsC$Leds$redOff(void);








static   result_t LedsC$Leds$redToggle(void);










static inline   result_t LedsC$Leds$greenOn(void);








static inline   result_t LedsC$Leds$greenOff(void);








static   result_t LedsC$Leds$greenToggle(void);










static inline   result_t LedsC$Leds$yellowOn(void);








static inline   result_t LedsC$Leds$yellowOff(void);








static   result_t LedsC$Leds$yellowToggle(void);
#line 167
static inline   result_t LedsC$Leds$set(uint8_t ledsNum);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
static  TOS_MsgPtr FramerM$ReceiveMsg$receive(TOS_MsgPtr arg_0x17efd58);
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
static   result_t FramerM$ByteComm$txByte(uint8_t arg_0x1d2f118);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t FramerM$ByteControl$init(void);






static  result_t FramerM$ByteControl$start(void);







static  result_t FramerM$ByteControl$stop(void);
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
static  result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
static  TOS_MsgPtr FramerM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0x1d35d88, uint8_t arg_0x1d35f00);
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
enum FramerM$__nesc_unnamed4364 {
  FramerM$HDLC_QUEUESIZE = 2, 
  FramerM$HDLC_MTU = sizeof(TOS_Msg ), 
  FramerM$HDLC_FLAG_BYTE = 0x7e, 
  FramerM$HDLC_CTLESC_BYTE = 0x7d, 
  FramerM$PROTO_ACK = 64, 
  FramerM$PROTO_PACKET_ACK = 65, 
  FramerM$PROTO_PACKET_NOACK = 66, 
  FramerM$PROTO_UNKNOWN = 255
};

enum FramerM$__nesc_unnamed4365 {
  FramerM$RXSTATE_NOSYNC, 
  FramerM$RXSTATE_PROTO, 
  FramerM$RXSTATE_TOKEN, 
  FramerM$RXSTATE_INFO, 
  FramerM$RXSTATE_ESC
};

enum FramerM$__nesc_unnamed4366 {
  FramerM$TXSTATE_IDLE, 
  FramerM$TXSTATE_PROTO, 
  FramerM$TXSTATE_INFO, 
  FramerM$TXSTATE_ESC, 
  FramerM$TXSTATE_FCS1, 
  FramerM$TXSTATE_FCS2, 
  FramerM$TXSTATE_ENDFLAG, 
  FramerM$TXSTATE_FINISH, 
  FramerM$TXSTATE_ERROR
};

enum FramerM$__nesc_unnamed4367 {
  FramerM$FLAGS_TOKENPEND = 0x2, 
  FramerM$FLAGS_DATAPEND = 0x4, 
  FramerM$FLAGS_UNKNOWN = 0x8
};

TOS_Msg FramerM$gMsgRcvBuf[FramerM$HDLC_QUEUESIZE];






#line 121
typedef struct FramerM$_MsgRcvEntry {
  uint8_t Proto;
  uint8_t Token;
  uint16_t Length;
  TOS_MsgPtr pMsg;
} FramerM$MsgRcvEntry_t;

FramerM$MsgRcvEntry_t FramerM$gMsgRcvTbl[FramerM$HDLC_QUEUESIZE];

uint8_t *FramerM$gpRxBuf;
uint8_t *FramerM$gpTxBuf;

uint8_t FramerM$gFlags;


 uint8_t FramerM$gTxState;
 uint8_t FramerM$gPrevTxState;
 uint16_t FramerM$gTxProto;
 uint16_t FramerM$gTxByteCnt;
 uint16_t FramerM$gTxLength;
 uint16_t FramerM$gTxRunningCRC;


uint8_t FramerM$gRxState;
uint8_t FramerM$gRxHeadIndex;
uint8_t FramerM$gRxTailIndex;
uint16_t FramerM$gRxByteCnt;

uint16_t FramerM$gRxRunningCRC;

TOS_MsgPtr FramerM$gpTxMsg;
uint8_t FramerM$gTxTokenBuf;
uint8_t FramerM$gTxUnknownBuf;
 uint8_t FramerM$gTxEscByte;

static  void FramerM$PacketSent(void);

static result_t FramerM$StartTx(void);
#line 202
static inline  void FramerM$PacketUnknown(void);







static inline  void FramerM$PacketRcvd(void);
#line 246
static  void FramerM$PacketSent(void);
#line 268
static void FramerM$HDLCInitialize(void);
#line 291
static inline  result_t FramerM$StdControl$init(void);




static inline  result_t FramerM$StdControl$start(void);




static inline  result_t FramerM$StdControl$stop(void);




static inline  result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg);
#line 328
static inline  result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t Token);
#line 348
static inline   result_t FramerM$ByteComm$rxByteReady(uint8_t data, bool error, uint16_t strength);
#line 469
static result_t FramerM$TxArbitraryByte(uint8_t inByte);
#line 482
static inline   result_t FramerM$ByteComm$txByteReady(bool LastByteSuccess);
#line 552
static inline   result_t FramerM$ByteComm$txDone(void);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
static  TOS_MsgPtr FramerAckM$ReceiveCombined$receive(TOS_MsgPtr arg_0x17efd58);
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
static  result_t FramerAckM$TokenReceiveMsg$ReflectToken(uint8_t arg_0x1d34598);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerAckM.nc"
uint8_t FramerAckM$gTokenBuf;

static inline  void FramerAckM$SendAckTask(void);




static inline  TOS_MsgPtr FramerAckM$TokenReceiveMsg$receive(TOS_MsgPtr Msg, uint8_t token);
#line 91
static inline  TOS_MsgPtr FramerAckM$ReceiveMsg$receive(TOS_MsgPtr Msg);
# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
static   result_t UARTM$HPLUART$init(void);
#line 80
static   result_t UARTM$HPLUART$put(uint8_t arg_0x1db5958);
#line 70
static   result_t UARTM$HPLUART$stop(void);
# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
static   result_t UARTM$ByteComm$txDone(void);
#line 75
static   result_t UARTM$ByteComm$txByteReady(bool arg_0x1d2d010);
#line 66
static   result_t UARTM$ByteComm$rxByteReady(uint8_t arg_0x1d2f648, bool arg_0x1d2f7c0, uint16_t arg_0x1d2f948);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
bool UARTM$state;

static inline  result_t UARTM$Control$init(void);







static inline  result_t UARTM$Control$start(void);



static inline  result_t UARTM$Control$stop(void);




static inline   result_t UARTM$HPLUART$get(uint8_t data);









static inline   result_t UARTM$HPLUART$putDone(void);
#line 110
static   result_t UARTM$ByteComm$txByte(uint8_t data);
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
static   result_t HPLUARTM$UART$get(uint8_t arg_0x1db5ed0);







static   result_t HPLUARTM$UART$putDone(void);
# 169 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
static   void HPLUARTM$USARTControl$setClockRate(uint16_t arg_0x1a6c548, uint8_t arg_0x1a6c6c0);
#line 85
static   void HPLUARTM$USARTControl$disableUART(void);
#line 167
static   void HPLUARTM$USARTControl$setClockSource(uint8_t arg_0x1a6c0b0);






static   result_t HPLUARTM$USARTControl$enableRxIntr(void);
#line 172
static   result_t HPLUARTM$USARTControl$disableRxIntr(void);
static   result_t HPLUARTM$USARTControl$disableTxIntr(void);

static   result_t HPLUARTM$USARTControl$enableTxIntr(void);
#line 202
static   result_t HPLUARTM$USARTControl$tx(uint8_t arg_0x1a693b8);
#line 153
static   void HPLUARTM$USARTControl$setModeUART(void);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$UART$init(void);
#line 82
static inline   result_t HPLUARTM$UART$stop(void);







static inline   result_t HPLUARTM$USARTData$rxDone(uint8_t b);



static inline   result_t HPLUARTM$USARTData$txDone(void);



static inline   result_t HPLUARTM$UART$put(uint8_t data);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
static   result_t HPLUSART1M$USARTData$rxDone(uint8_t arg_0x1af0a38);
#line 46
static   result_t HPLUSART1M$USARTData$txDone(void);
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
 static volatile uint8_t HPLUSART1M$ME2 __asm ("0x0005");
 static volatile uint8_t HPLUSART1M$IFG2 __asm ("0x0003");
 static volatile uint8_t HPLUSART1M$U1TCTL __asm ("0x0079");
 static volatile uint8_t HPLUSART1M$U1TXBUF __asm ("0x007F");

uint16_t HPLUSART1M$l_br;
uint8_t HPLUSART1M$l_mctl;
uint8_t HPLUSART1M$l_ssel;

void  __attribute((wakeup)) __attribute((interrupt(6))) sig_UART1RX_VECTOR(void);




void  __attribute((wakeup)) __attribute((interrupt(4))) sig_UART1TX_VECTOR(void);



static inline   bool HPLUSART1M$USARTControl$isSPI(void);








static inline   bool HPLUSART1M$USARTControl$isUART(void);










static inline   bool HPLUSART1M$USARTControl$isUARTtx(void);










static inline   bool HPLUSART1M$USARTControl$isUARTrx(void);
#line 107
static inline   bool HPLUSART1M$USARTControl$isI2C(void);



static inline   msp430_usartmode_t HPLUSART1M$USARTControl$getMode(void);
#line 158
static inline   void HPLUSART1M$USARTControl$disableUART(void);
#line 191
static inline   void HPLUSART1M$USARTControl$disableSPI(void);
#line 252
static inline void HPLUSART1M$setUARTModeCommon(void);
#line 325
static inline   void HPLUSART1M$USARTControl$setModeUART(void);
#line 341
static inline   void HPLUSART1M$USARTControl$setClockSource(uint8_t source);







static inline   void HPLUSART1M$USARTControl$setClockRate(uint16_t baudrate, uint8_t mctl);
#line 382
static inline   result_t HPLUSART1M$USARTControl$disableRxIntr(void);




static inline   result_t HPLUSART1M$USARTControl$disableTxIntr(void);




static inline   result_t HPLUSART1M$USARTControl$enableRxIntr(void);







static inline   result_t HPLUSART1M$USARTControl$enableTxIntr(void);







static inline   result_t HPLUSART1M$USARTControl$tx(uint8_t data);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/NoLeds.nc"
static inline   result_t NoLeds$Leds$redToggle(void);
#line 75
static inline   result_t NoLeds$Leds$greenToggle(void);
# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
static  result_t TimerM$TimerMilli$fired(
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
uint8_t arg_0x1e40860);
# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
static   void TimerM$AlarmControl$enableEvents(void);
#line 35
static   void TimerM$AlarmControl$setControlAsCompare(void);



static   void TimerM$AlarmControl$disableEvents(void);
#line 32
static   void TimerM$AlarmControl$clearPendingInterrupt(void);
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void TimerM$AlarmCompare$setEventFromNow(uint16_t arg_0x1614010);
# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerJiffy.nc"
static  result_t TimerM$TimerJiffy$fired(
# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
uint8_t arg_0x1e773e0);
# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
static   uint16_t TimerM$AlarmTimer$read(void);
static   bool TimerM$AlarmTimer$isOverflowPending(void);
# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t TimerM$Timer$fired(
# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
uint8_t arg_0x1e40118);








enum TimerM$__nesc_unnamed4368 {

  TimerM$COUNT_TIMER_OLD = 4U, 
  TimerM$COUNT_TIMER_MILLI = 2U, 
  TimerM$COUNT_TIMER_JIFFY = 0U, 

  TimerM$OFFSET_TIMER_OLD = 0, 
  TimerM$OFFSET_TIMER_MILLI = TimerM$OFFSET_TIMER_OLD + TimerM$COUNT_TIMER_OLD, 
  TimerM$OFFSET_TIMER_JIFFY = TimerM$OFFSET_TIMER_MILLI + TimerM$COUNT_TIMER_MILLI, 
  TimerM$NUM_TIMERS = TimerM$OFFSET_TIMER_JIFFY + TimerM$COUNT_TIMER_JIFFY, 

  TimerM$EMPTY_LIST = 255
};










#line 54
typedef struct TimerM$Timer_s {

  uint32_t alarm;
  uint8_t next;
  bool isperiodic : 1;
  bool isset : 1;
  bool isqueued : 1;
  int _reserved_flags : 5;
  uint8_t _reserved_byte;
} TimerM$Timer_t;

TimerM$Timer_t TimerM$m_timers[TimerM$NUM_TIMERS];
int32_t TimerM$m_period[TimerM$NUM_TIMERS];
uint16_t TimerM$m_hinow;
uint8_t TimerM$m_head_short;
uint8_t TimerM$m_head_long;
bool TimerM$m_posted_checkShortTimers;

static  result_t TimerM$StdControl$init(void);
#line 84
static inline  result_t TimerM$StdControl$start(void);









static void TimerM$insertTimer(uint8_t num, bool isshort);
#line 113
static inline void TimerM$removeTimer(uint8_t num);




static inline void TimerM$signal_timer_fired(uint8_t num);
#line 141
static void TimerM$executeTimers(uint8_t head);
#line 184
static inline  void TimerM$checkShortTimers(void);

static inline void TimerM$post_checkShortTimers(void);
#line 198
static void TimerM$setNextShortEvent(void);
#line 257
static inline  void TimerM$checkShortTimers(void);








static inline  void TimerM$checkLongTimers(void);







static   uint32_t TimerM$LocalTime$read(void);
#line 294
static inline   void TimerM$AlarmCompare$fired(void);




static inline   void TimerM$AlarmTimer$overflow(void);





static result_t TimerM$setTimer(uint8_t num, int32_t jiffy, bool isperiodic);
#line 372
static inline   result_t TimerM$TimerJiffy$default$fired(uint8_t num);







static inline uint8_t TimerM$fromNumMilli(uint8_t num);




static inline  result_t TimerM$TimerMilli$setOneShot(uint8_t num, int32_t milli);
#line 421
static inline   result_t TimerM$TimerMilli$default$fired(uint8_t num);







static  result_t TimerM$Timer$start(uint8_t num, char type, uint32_t milli);
#line 443
static inline  result_t TimerM$Timer$stop(uint8_t num);





static inline   result_t TimerM$Timer$default$fired(uint8_t num);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLPowerManagementM.nc"
static inline   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteSelect.nc"
static  result_t MultiHopEngineM$RouteSelect$selectRoute(TOS_MsgPtr arg_0x1ef6b90, uint8_t arg_0x1ef6d08);
#line 86
static  result_t MultiHopEngineM$RouteSelect$initializeFields(TOS_MsgPtr arg_0x1ef5340, uint8_t arg_0x1ef54b8);
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
static  result_t MultiHopEngineM$Intercept$intercept(
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
uint8_t arg_0x1ec6738, 
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
static  result_t MultiHopEngineM$Send$sendDone(
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
uint8_t arg_0x1ec6010, 
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
TOS_MsgPtr arg_0x17c3d68, result_t arg_0x17c3ee8);
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
static  result_t MultiHopEngineM$Snoop$intercept(
# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
uint8_t arg_0x1ec6ce8, 
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758);
# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
static  uint16_t *MultiHopEngineM$RouteSelectCntl$getChildren(void);
#line 84
static  uint16_t MultiHopEngineM$RouteSelectCntl$getParent(void);
#line 144
static  result_t MultiHopEngineM$RouteSelectCntl$manualUpdate(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t MultiHopEngineM$SubControl$init(void);






static  result_t MultiHopEngineM$SubControl$start(void);







static  result_t MultiHopEngineM$SubControl$stop(void);
#line 63
static  result_t MultiHopEngineM$CommStdControl$init(void);






static  result_t MultiHopEngineM$CommStdControl$start(void);







static  result_t MultiHopEngineM$CommStdControl$stop(void);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t MultiHopEngineM$SendMsg$send(
# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
uint8_t arg_0x1ec4010, 
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
enum MultiHopEngineM$__nesc_unnamed4369 {
  MultiHopEngineM$FWD_QUEUE_SIZE = 8, 
  MultiHopEngineM$EMPTY = 0xff
};






struct TOS_Msg MultiHopEngineM$FwdBuffers[MultiHopEngineM$FWD_QUEUE_SIZE];
struct TOS_Msg *MultiHopEngineM$FwdBufList[MultiHopEngineM$FWD_QUEUE_SIZE];

uint8_t MultiHopEngineM$iFwdBufHead;
#line 118
uint8_t MultiHopEngineM$iFwdBufTail;








inline static void MultiHopEngineM$initialize(void);









static inline  result_t MultiHopEngineM$StdControl$init(void);





static inline  result_t MultiHopEngineM$StdControl$start(void);





static inline  result_t MultiHopEngineM$StdControl$stop(void);










static inline  result_t MultiHopEngineM$Send$send(uint8_t id, TOS_MsgPtr pMsg, uint16_t PayloadLen);
#line 186
static  void *MultiHopEngineM$Send$getBuffer(uint8_t id, TOS_MsgPtr pMsg, uint16_t *length);










inline static TOS_MsgPtr MultiHopEngineM$mForward(TOS_MsgPtr pMsg, uint8_t id);
#line 218
static  TOS_MsgPtr MultiHopEngineM$ReceiveMsg$receive(uint8_t id, TOS_MsgPtr pMsg);
#line 248
static  result_t MultiHopEngineM$SendMsg$sendDone(uint8_t id, TOS_MsgPtr pMsg, result_t success);









static inline  uint16_t MultiHopEngineM$RouteControl$getParent(void);







static inline  uint16_t *MultiHopEngineM$RouteControl$getChildren(void);
#line 297
static inline  result_t MultiHopEngineM$RouteControl$manualUpdate(void);



static inline   result_t MultiHopEngineM$Send$default$sendDone(uint8_t id, TOS_MsgPtr pMsg, result_t success);



static inline   result_t MultiHopEngineM$Intercept$default$intercept(uint8_t id, TOS_MsgPtr pMsg, void *payload, 
uint16_t payloadLen);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t MultiHopLEPSM$Timer$start(char arg_0x1841820, uint32_t arg_0x18419a8);








static  result_t MultiHopLEPSM$Timer$stop(void);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t MultiHopLEPSM$SendMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
enum MultiHopLEPSM$__nesc_unnamed4370 {
  MultiHopLEPSM$NBRFLAG_VALID = 0x01, 
  MultiHopLEPSM$NBRFLAG_NEW = 0x02, 
  MultiHopLEPSM$NBRFLAG_EST_INIT = 0x04
};

enum MultiHopLEPSM$__nesc_unnamed4371 {
  MultiHopLEPSM$BASE_STATION_ADDRESS = 0, 
  MultiHopLEPSM$ROUTE_TABLE_SIZE = 16, 
  MultiHopLEPSM$ESTIMATE_TO_ROUTE_RATIO = 5, 
  MultiHopLEPSM$ACCEPTABLE_MISSED = -20, 
  MultiHopLEPSM$DATA_TO_ROUTE_RATIO = 2, 
  MultiHopLEPSM$DATA_FREQ = 10000, 
  MultiHopLEPSM$MAX_ALLOWABLE_LINK_COST = 1536, 
  MultiHopLEPSM$MIN_LIVELINESS = 2
};


enum MultiHopLEPSM$__nesc_unnamed4372 {
  MultiHopLEPSM$ROUTE_INVALID = 0xff
};

struct MultiHopLEPSM$SortEntry {
  uint16_t id;
  uint8_t receiveEst;
};




#line 115
typedef struct MultiHopLEPSM$RPEstEntry {
  uint16_t id;
  uint8_t receiveEst;
} __attribute((packed))  MultiHopLEPSM$RPEstEntry;







#line 120
typedef struct MultiHopLEPSM$RoutePacket {
  uint16_t parent;


  uint8_t estEntries;
  MultiHopLEPSM$RPEstEntry estList[1];
} __attribute((packed))  MultiHopLEPSM$RoutePacket;
#line 139
#line 128
typedef struct MultiHopLEPSM$TableEntry {
  uint16_t id;
  uint16_t parent;
  uint16_t missed;
  uint16_t received;
  int16_t lastSeqno;
  uint8_t flags;
  uint8_t liveliness;
  uint8_t hop;
  uint8_t receiveEst;
  uint8_t sendEst;
} MultiHopLEPSM$TableEntry;

TOS_Msg MultiHopLEPSM$routeMsg;
bool MultiHopLEPSM$gfSendRouteBusy;

MultiHopLEPSM$TableEntry MultiHopLEPSM$BaseStation;
MultiHopLEPSM$TableEntry MultiHopLEPSM$NeighborTbl[MultiHopLEPSM$ROUTE_TABLE_SIZE];
MultiHopLEPSM$TableEntry *MultiHopLEPSM$gpCurrentParent;
uint8_t MultiHopLEPSM$gbCurrentHopCount;
int16_t MultiHopLEPSM$gCurrentSeqNo;
uint16_t MultiHopLEPSM$gwEstTicks;
uint32_t MultiHopLEPSM$gUpdateInterval;










static inline uint8_t MultiHopLEPSM$findEntry(uint8_t id);
#line 179
static inline uint8_t MultiHopLEPSM$findEntryToBeReplaced(void);
#line 203
static void MultiHopLEPSM$newEntry(uint8_t indes, uint16_t id);
#line 229
static inline uint8_t MultiHopLEPSM$findPreparedIndex(uint16_t id);
#line 249
static inline uint32_t MultiHopLEPSM$evaluateCost(uint8_t sendEst, uint8_t receiveEst);










static inline void MultiHopLEPSM$updateEst(MultiHopLEPSM$TableEntry *Nbr);
#line 306
static inline void MultiHopLEPSM$updateTable(void);
#line 322
static bool MultiHopLEPSM$updateNbrCounters(uint16_t saddr, int16_t seqno, uint8_t *NbrIndex);
#line 359
static inline void MultiHopLEPSM$chooseParent(void);
#line 404
static inline  void MultiHopLEPSM$SendRouteTask(void);
#line 450
static  void MultiHopLEPSM$TimerTask(void);
#line 484
static inline  result_t MultiHopLEPSM$StdControl$init(void);
#line 508
static inline  result_t MultiHopLEPSM$StdControl$start(void);





static inline  result_t MultiHopLEPSM$StdControl$stop(void);
#line 533
static  result_t MultiHopLEPSM$RouteSelect$selectRoute(TOS_MsgPtr Msg, uint8_t id);
#line 586
static inline  result_t MultiHopLEPSM$RouteSelect$initializeFields(TOS_MsgPtr Msg, uint8_t id);
#line 599
static inline  uint16_t MultiHopLEPSM$RouteControl$getParent(void);
#line 623
static inline  uint16_t *MultiHopLEPSM$RouteControl$getChildren(void);
#line 684
static inline  result_t MultiHopLEPSM$RouteControl$manualUpdate(void);








static inline  result_t MultiHopLEPSM$Timer$fired(void);




static inline  TOS_MsgPtr MultiHopLEPSM$ReceiveMsg$receive(TOS_MsgPtr Msg);
#line 724
static inline  result_t MultiHopLEPSM$Snoop$intercept(uint8_t id, TOS_MsgPtr Msg, void *Payload, uint16_t Len);









static inline  result_t MultiHopLEPSM$SendMsg$sendDone(TOS_MsgPtr pMsg, result_t success);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t QueuedSendM$QueueSendMsg$sendDone(
# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
uint8_t arg_0x1f8da10, 
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t QueuedSendM$Leds$greenToggle(void);
#line 81
static   result_t QueuedSendM$Leds$redToggle(void);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t QueuedSendM$SerialSendMsg$send(
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
uint8_t arg_0x1f8c4d8, 
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
enum QueuedSendM$__nesc_unnamed4373 {
  QueuedSendM$MESSAGE_QUEUE_SIZE = 8 + 2, 
  QueuedSendM$MAX_RETRANSMIT_COUNT = 5
};







#line 79
struct QueuedSendM$_msgq_entry {
  uint16_t address;
  uint8_t length;
  uint8_t id;
  uint8_t xmit_count;
  TOS_MsgPtr pMsg;
} QueuedSendM$msgqueue[QueuedSendM$MESSAGE_QUEUE_SIZE];

uint16_t QueuedSendM$enqueue_next;
#line 87
uint16_t QueuedSendM$dequeue_next;
bool QueuedSendM$retransmit;
bool QueuedSendM$fQueueIdle;

static inline  result_t QueuedSendM$StdControl$init(void);
#line 106
static inline  result_t QueuedSendM$StdControl$start(void);


static inline  result_t QueuedSendM$StdControl$stop(void);
#line 121
static  void QueuedSendM$QueueServiceTask(void);
#line 143
static  result_t QueuedSendM$QueueSendMsg$send(uint8_t id, uint16_t address, uint8_t length, TOS_MsgPtr msg);
#line 188
static inline  result_t QueuedSendM$SerialSendMsg$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success);
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
static  TOS_MsgPtr AMPromiscuous$ReceiveMsg$receive(
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
uint8_t arg_0x1fd5010, 
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
TOS_MsgPtr arg_0x17efd58);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
static  result_t AMPromiscuous$UARTSend$send(TOS_MsgPtr arg_0x184d4a8);
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t AMPromiscuous$Leds$greenToggle(void);
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static  result_t AMPromiscuous$sendDone(void);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
static  result_t AMPromiscuous$RadioSend$send(TOS_MsgPtr arg_0x184d4a8);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
static  result_t AMPromiscuous$SendMsg$sendDone(
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
uint8_t arg_0x1fd7930, 
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698);
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
bool AMPromiscuous$state;
TOS_MsgPtr AMPromiscuous$buffer;
uint16_t AMPromiscuous$lastCount;
uint16_t AMPromiscuous$counter;
bool AMPromiscuous$promiscuous_mode;
bool AMPromiscuous$crc_check;
#line 159
static inline void AMPromiscuous$dbgPacket(TOS_MsgPtr data);










static result_t AMPromiscuous$reportSendDone(TOS_MsgPtr msg, result_t success);








static inline  result_t AMPromiscuous$ActivityTimer$fired(void);








static inline   result_t AMPromiscuous$default$sendDone(void);




static inline  void AMPromiscuous$sendTask(void);
#line 206
static inline  result_t AMPromiscuous$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data);
#line 236
static inline  result_t AMPromiscuous$UARTSend$sendDone(TOS_MsgPtr msg, result_t success);


static inline  result_t AMPromiscuous$RadioSend$sendDone(TOS_MsgPtr msg, result_t success);




TOS_MsgPtr   prom_received(TOS_MsgPtr packet);
#line 271
static inline   TOS_MsgPtr AMPromiscuous$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg);



static inline  TOS_MsgPtr AMPromiscuous$UARTReceive$receive(TOS_MsgPtr packet);



static inline  TOS_MsgPtr AMPromiscuous$RadioReceive$receive(TOS_MsgPtr packet);
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/NoCRCPacket.nc"
enum NoCRCPacket$__nesc_unnamed4374 {
  NoCRCPacket$IDLE, 
  NoCRCPacket$PACKET, 
  NoCRCPacket$BYTES
};
# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  TinyDBError TupleRouterM$addResults(QueryResult *arg_0x20f1858, ParsedQuery *arg_0x20f19f8, Expr *arg_0x20f1b90);
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
static  result_t TupleRouterM$AbsoluteTimer$cancel(void);
#line 50
static  result_t TupleRouterM$AbsoluteTimer$set(tos_time_t arg_0x20b7920);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
static  result_t TupleRouterM$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8);
# 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  TinyDBError TupleRouterM$TupleIntf$getNextEmptyFieldIdx(ParsedQueryPtr arg_0x2079340, TuplePtr arg_0x20794c0, uint8_t *arg_0x2079660);
#line 114
static  AttrDescPtr TupleRouterM$TupleIntf$getNextQueryField(ParsedQueryPtr arg_0x207ac38, TuplePtr arg_0x207adb8);
#line 86
static  CharPtr TupleRouterM$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80);
#line 106
static  result_t TupleRouterM$TupleIntf$tupleInit(ParsedQueryPtr arg_0x2040f30, TuplePtr arg_0x207a0c8);
#line 60
static  result_t TupleRouterM$TupleIntf$setField(ParsedQueryPtr arg_0x2044ce8, TuplePtr arg_0x2044e68, uint8_t arg_0x2042010, CharPtr arg_0x2042188);
#line 45
static  uint16_t TupleRouterM$TupleIntf$tupleSize(ParsedQueryPtr arg_0x2044190);
# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
static  TinyDBError TupleRouterM$SelOperator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990);
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
static  QueryResultPtr TupleRouterM$Network$getDataPayLoad(TOS_MsgPtr arg_0x17baa98);
#line 148
static  QueryMessagePtr TupleRouterM$Network$getQueryPayLoad(TOS_MsgPtr arg_0x17b7010);






static  TinyDBError TupleRouterM$Network$sendQueryMessage(TOS_MsgPtr arg_0x17b7680);
#line 98
static  TinyDBError TupleRouterM$Network$sendDataMessage(TOS_MsgPtr arg_0x17b9120);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
static   uint16_t TupleRouterM$Random$rand(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t TupleRouterM$TimerControl$init(void);






static  result_t TupleRouterM$TimerControl$start(void);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
static  AttrDescPtr TupleRouterM$AttrUse$getAttrById(uint8_t arg_0x204da90);
#line 66
static  AttrDescPtr TupleRouterM$AttrUse$getAttr(char *arg_0x204d508);
#line 91
static  result_t TupleRouterM$AttrUse$getAttrValue(char *arg_0x204c7d0, char *arg_0x204c968, SchemaErrorNo *arg_0x204cb08);
#line 108
static  result_t TupleRouterM$AttrUse$startAttr(uint8_t arg_0x2049168);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t TupleRouterM$ChildControl$init(void);






static  result_t TupleRouterM$ChildControl$start(void);







static  result_t TupleRouterM$ChildControl$stop(void);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeSet.nc"
static  void TupleRouterM$TimeSet$set(tos_time_t arg_0x20a3068);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/RadioQueue.nc"
static  bool TupleRouterM$RadioQueue$enqueueDone(void);
# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
static  bool TupleRouterM$ParsedQueryIntf$queryFieldIsNull(uint8_t arg_0x206c928);
#line 67
static  short TupleRouterM$ParsedQueryIntf$baseSize(QueryPtr arg_0x2068328);
#line 57
static  uint8_t TupleRouterM$ParsedQueryIntf$getFieldId(ParsedQueryPtr arg_0x2069010, uint8_t arg_0x2069188);


static  result_t TupleRouterM$ParsedQueryIntf$setExpr(ParsedQueryPtr arg_0x2069640, uint8_t arg_0x20697b8, Expr arg_0x2069930);
#line 54
static  ExprPtr TupleRouterM$ParsedQueryIntf$getExprPtr(ParsedQueryPtr arg_0x206b960, uint8_t arg_0x206bad8);








static  TuplePtr TupleRouterM$ParsedQueryIntf$getTuplePtr(ParsedQueryPtr arg_0x2069df0);
#line 110
static  bool TupleRouterM$ParsedQueryIntf$typeCheck(ParsedQuery *arg_0x2065a18, ParsedQuery *arg_0x2065bb8);
#line 51
static  Expr TupleRouterM$ParsedQueryIntf$getExpr(ParsedQueryPtr arg_0x206b328, uint8_t arg_0x206b4a0);
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Time.nc"
static   tos_time_t TupleRouterM$Time$get(void);
# 178 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static   void TupleRouterM$setSimpleTimeInterval(uint16_t arg_0x20f0788);
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
static  TinyDBError TupleRouterM$AggOperator$processPartialResult(QueryResultPtr arg_0x209af08, ParsedQueryPtr arg_0x20980b0, ExprPtr arg_0x2098228);
#line 66
static  TinyDBError TupleRouterM$AggOperator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990);
#line 101
static  result_t TupleRouterM$AggOperator$endOfEpoch(ParsedQueryPtr arg_0x2098800, ExprPtr arg_0x2098978);
# 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t TupleRouterM$Leds$yellowOff(void);
#line 114
static   result_t TupleRouterM$Leds$yellowOn(void);
#line 97
static   result_t TupleRouterM$Leds$greenOff(void);
#line 72
static   result_t TupleRouterM$Leds$redOff(void);
#line 106
static   result_t TupleRouterM$Leds$greenToggle(void);
#line 131
static   result_t TupleRouterM$Leds$yellowToggle(void);
#line 81
static   result_t TupleRouterM$Leds$redToggle(void);
#line 149
static   result_t TupleRouterM$Leds$set(uint8_t arg_0x17e65b8);
#line 89
static   result_t TupleRouterM$Leds$greenOn(void);
# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
static  TinyDBError TupleRouterM$QueryResultIntf$initQueryResult(QueryResultPtr arg_0x20913d8);
#line 120
static  TinyDBError TupleRouterM$QueryResultIntf$fromBytes(QueryResultPtr arg_0x208ead0, QueryResultPtr arg_0x208ec50, ParsedQueryPtr arg_0x208edd0);










static  short TupleRouterM$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0);
#line 127
static  uint8_t TupleRouterM$QueryResultIntf$queryIdFromMsg(QueryResultPtr arg_0x208db50);
#line 91
static  TinyDBError TupleRouterM$QueryResultIntf$fromTuple(QueryResultPtr arg_0x20919b8, ParsedQueryPtr arg_0x2091b38, TuplePtr arg_0x2091cb8);
# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
static  TinyDBError TupleRouterM$DBBuffer$getField(uint8_t arg_0x20d6df0, QueryResult *arg_0x20d5010, uint8_t arg_0x20d5188, char *arg_0x20d5320);
#line 55
static  TinyDBError TupleRouterM$DBBuffer$enqueue(uint8_t arg_0x20d9558, QueryResultPtr arg_0x20d96d8, bool *arg_0x20d9870, ParsedQueryPtr arg_0x20d99f0);
#line 92
static  TinyDBError TupleRouterM$DBBuffer$getResult(uint8_t arg_0x20d7b28, uint16_t arg_0x20d7ca8, QueryResult *arg_0x20d7e48, bool *arg_0x20d6010);
#line 135
static  ParsedQuery **TupleRouterM$DBBuffer$getSchema(uint8_t arg_0x20d2890);
#line 77
static  TinyDBError TupleRouterM$DBBuffer$peek(uint8_t arg_0x20d7088, QueryResult *arg_0x20d7228, bool *arg_0x20d73c0);
#line 101
static  TinyDBError TupleRouterM$DBBuffer$getFieldId(uint8_t arg_0x20d64a8, FieldPtr arg_0x20d6628, uint8_t *arg_0x20d67c0);
#line 151
static  TinyDBError TupleRouterM$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650);
#line 132
static  TinyDBError TupleRouterM$DBBuffer$size(uint8_t arg_0x20d2230, uint16_t *arg_0x20d23d0);
# 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
static  int16_t TupleRouterM$MemAlloc$size(Handle arg_0x20836d8);
#line 94
static  result_t TupleRouterM$MemAlloc$unlock(Handle arg_0x2084898);
#line 84
static  result_t TupleRouterM$MemAlloc$lock(Handle arg_0x2084328);
#line 73
static  result_t TupleRouterM$MemAlloc$reallocate(Handle arg_0x2085b88, int16_t arg_0x2085d00);
#line 61
static  result_t TupleRouterM$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638);
#line 104
static  int16_t TupleRouterM$MemAlloc$free(Handle arg_0x2084dd8);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
static  Field TupleRouterM$QueryIntf$getField(QueryPtr arg_0x2074728, uint8_t arg_0x20748a0);
#line 48
static  short TupleRouterM$QueryIntf$size(QueryPtr arg_0x2074270);
#line 71
static  result_t TupleRouterM$QueryIntf$setExpr(QueryPtr arg_0x2071260, uint8_t arg_0x20713d8, Expr arg_0x2071550);
#line 54
static  Field *TupleRouterM$QueryIntf$getFieldPtr(QueryPtr arg_0x2074d58, uint8_t arg_0x2074ed0);
#line 74
static  bool TupleRouterM$QueryIntf$fieldsComplete(Query arg_0x2071aa8);
#line 61
static  result_t TupleRouterM$QueryIntf$setField(QueryPtr arg_0x20733d8, uint8_t arg_0x2073550, Field arg_0x20736c8);
#line 77
static  bool TupleRouterM$QueryIntf$exprsComplete(Query arg_0x2070010);
#line 64
static  Expr TupleRouterM$QueryIntf$getExpr(QueryPtr arg_0x2073c10, uint8_t arg_0x2073d88);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t TupleRouterM$NetControl$init(void);






static  result_t TupleRouterM$NetControl$start(void);







static  result_t TupleRouterM$NetControl$stop(void);
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ServiceScheduler.nc"
static  tos_time_t TupleRouterM$ServiceScheduler$getNextEventTime(uint8_t arg_0x20eb168);


static  result_t TupleRouterM$ServiceScheduler$setExtraSleepTime(uint8_t arg_0x20eb5e8, int32_t arg_0x20eb768);


static  result_t TupleRouterM$ServiceScheduler$remove(uint8_t arg_0x20ebbe0);
#line 51
static  result_t TupleRouterM$ServiceScheduler$reschedule(uint8_t arg_0x20eeab0, 
tos_service_schedule arg_0x20eec58);
# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
static  result_t TupleRouterM$RouteControl$manualUpdate(void);
# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
enum TupleRouterM$__nesc_unnamed4375 {
#line 202
  TupleRouterM$kMS_PER_CLOCK_EVENT = 64
};
enum TupleRouterM$__nesc_unnamed4376 {
#line 204
  TupleRouterM$UDF_WAIT_LOOP = 100
};
#line 205
enum TupleRouterM$__nesc_unnamed4377 {
#line 205
  TupleRouterM$EPOCHS_TIL_DELETION = 5
};







#line 208
typedef enum TupleRouterM$__nesc_unnamed4378 {
  TupleRouterM$STATE_ALLOC_PARSED_QUERY = 0, 
  TupleRouterM$STATE_ALLOC_IN_FLIGHT_QUERY, 
  TupleRouterM$STATE_RESIZE_QUERY, 
  TupleRouterM$STATE_NOT_ALLOCING, 
  TupleRouterM$STATE_ALLOC_QUERY_RESULT
} TupleRouterM$AllocState;





#line 217
typedef struct TupleRouterM$__nesc_unnamed4379 {
  void **next;
  ParsedQuery q;
} *TupleRouterM$QueryListPtr;
#line 220
#line 217
typedef struct TupleRouterM$__nesc_unnamed4379 **


TupleRouterM$QueryListHandle;
#line 220
#line 217
typedef struct TupleRouterM$__nesc_unnamed4379 


TupleRouterM$QueryListEl;


typedef void (*TupleRouterM$MemoryCallback)(Handle *memory);
#line 236
#line 229
typedef struct TupleRouterM$__nesc_unnamed4380 {
  bool isAttr;
  bool isNull;
  union TupleRouterM$__nesc_unnamed4381 {
    AttrDescPtr attr;
    uint8_t tupleIdx;
  } u;
} TupleRouterM$TupleFieldDesc;


enum TupleRouterM$__nesc_unnamed4382 {
#line 239
  TupleRouterM$READING_BIT = 0x0001, 
  TupleRouterM$PARSING_BIT = 0x0002, 
  TupleRouterM$ALLOCED_BIT = 0x0004, 
  TupleRouterM$FETCHING_BIT = 0x0008, 
  TupleRouterM$ROUTING_BIT = 0x0010, 
  TupleRouterM$DELIVERING_BIT = 0x0020, 
  TupleRouterM$SENDING_BIT = 0x0040, 
  TupleRouterM$AGGREGATING_BIT = 0x0080, 
  TupleRouterM$SENDING_QUERY_BIT = 0x0100, 
  TupleRouterM$IN_QUERY_MSG_BIT = 0x0200, 

  TupleRouterM$SETTING_SAMPLE_RATE_BIT = 0x0400, 
  TupleRouterM$SNOOZING_BIT = 0x0800, 
  TupleRouterM$ATTR_STARTING_BIT = 0x1000, 
  TupleRouterM$OPENING_WRITE_BUF_BIT = 0x2000, 
  TupleRouterM$REMOVING_BIT = 0x4000
};
#line 268
enum TupleRouterM$__nesc_unnamed4383 {
#line 268
  TupleRouterM$WAKING_CLOCKS = 4096 / TupleRouterM$kMS_PER_CLOCK_EVENT
};


enum TupleRouterM$__nesc_unnamed4384 {
#line 272
  TupleRouterM$kBASE_EPOCH_RATE = 10
};
enum TupleRouterM$__nesc_unnamed4385 {
#line 274
  TupleRouterM$kMAX_WAIT_CLOCKS = 16
};
enum TupleRouterM$__nesc_unnamed4386 {
#line 276
  TupleRouterM$kMIN_SLEEP_CLOCKS_PER_SAMPLE = 1024 / TupleRouterM$kMS_PER_CLOCK_EVENT
};









TOS_Msg TupleRouterM$mMsg;
uint16_t TupleRouterM$mPendingMask;
uint8_t TupleRouterM$mCycleToSend;
uint32_t TupleRouterM$mQMsgMask;
TupleRouterM$QueryListHandle TupleRouterM$mQs;
TupleRouterM$QueryListHandle TupleRouterM$mTail;
Query **TupleRouterM$mCurQuery;
Query *TupleRouterM$mCurQueryPtr;

Handle TupleRouterM$mTmpHandle;


TupleRouterM$MemoryCallback TupleRouterM$mAllocCallback;

uint8_t TupleRouterM$mFetchingFieldId;
char TupleRouterM$mCurExpr;
Tuple *TupleRouterM$mCurTuple;


TupleRouterM$QueryListHandle TupleRouterM$mCurRouteQuery;


QueryResult TupleRouterM$mResult;
#line 309
QueryResult TupleRouterM$mEnqResult;
short TupleRouterM$mFetchTries;
TupleRouterM$AllocState TupleRouterM$mAllocState;

short TupleRouterM$mOldRate;

TupleRouterM$QueryListHandle TupleRouterM$mCurSendingQuery;
char TupleRouterM$mCurSendingField;
char TupleRouterM$mCurSendingExpr;
uint32_t TupleRouterM$mCurQMsgMask;
TOS_Msg TupleRouterM$mQmsg;

bool TupleRouterM$mTriedAllocWaiting;





bool TupleRouterM$mAllQueriesSameRate;


bool TupleRouterM$mSendQueryNextClock;

char *TupleRouterM$mResultBuf;

ParsedQuery *TupleRouterM$mLastQuery;
ParsedQuery *TupleRouterM$mTempPQ;

uint8_t TupleRouterM$mCurField;




uint16_t TupleRouterM$mLifetime;
uint8_t TupleRouterM$mCurSampleRateQuery;
uint16_t TupleRouterM$mVoltage;






uint16_t TupleRouterM$mNumBlocked;

uint16_t TupleRouterM$mClockCount;

bool TupleRouterM$mIsRunning;
bool TupleRouterM$mStopped;
bool TupleRouterM$mRadioWaiting;
bool TupleRouterM$mSendingResult;
uint8_t TupleRouterM$mCurTupleIdx;

uint8_t TupleRouterM$mQidToRemove;
bool TupleRouterM$mForceRemove;

uint8_t TupleRouterM$mNumAttrs;





#line 366
typedef enum TupleRouterM$__nesc_unnamed4387 {
  TupleRouterM$TS_NO = 0, 
  TupleRouterM$TS_QUERY_MESSAGE = 1, 
  TupleRouterM$TS_QUERY_RESULT_MESSAGE = 2
} TupleRouterM$TimeStampState;

TupleRouterM$TimeStampState TupleRouterM$mMustTimestamp;
TOS_MsgPtr TupleRouterM$mTimestampMsg;
uint16_t TupleRouterM$mCurSchedTime;
 int16_t TupleRouterM$mLastDiff;



uint16_t TupleRouterM$mLastHeard;

uint8_t TupleRouterM$mSendFailed;


uint8_t TupleRouterM$mStoppedQid;

uint8_t TupleRouterM$mDeliverWait;


bool TupleRouterM$mWaitIsDummy;








static inline void TupleRouterM$SET_READING_QUERY(void);
static inline void TupleRouterM$UNSET_READING_QUERY(void);
static inline bool TupleRouterM$IS_READING_QUERY(void);

static inline void TupleRouterM$SET_PARSING_QUERY(void);
static inline void TupleRouterM$UNSET_PARSING_QUERY(void);


static inline bool TupleRouterM$IS_SPACE_ALLOCED(void);
static inline void TupleRouterM$UNSET_SPACE_ALLOCED(void);
static inline void TupleRouterM$SET_SPACE_ALLOCED(void);

static inline bool TupleRouterM$IS_FETCHING_ATTRIBUTE(void);
static inline void TupleRouterM$UNSET_FETCHING_ATTRIBUTE(void);
static inline void TupleRouterM$SET_FETCHING_ATTRIBUTE(void);

static inline bool TupleRouterM$IS_STARTING_ATTRIBUTE(void);
static inline void TupleRouterM$UNSET_STARTING_ATTRIBUTE(void);
static inline void TupleRouterM$SET_STARTING_ATTRIBUTE(void);

static inline bool TupleRouterM$IS_ROUTING_TUPLES(void);
static inline void TupleRouterM$UNSET_ROUTING_TUPLES(void);
static inline void TupleRouterM$SET_ROUTING_TUPLES(void);

static inline bool TupleRouterM$IS_DELIVERING_TUPLES(void);
static inline void TupleRouterM$UNSET_DELIVERING_TUPLES(void);
static inline void TupleRouterM$SET_DELIVERING_TUPLES(void);

static inline bool TupleRouterM$IS_SENDING_MESSAGE(void);
static inline void TupleRouterM$UNSET_SENDING_MESSAGE(void);
static inline void TupleRouterM$SET_SENDING_MESSAGE(void);

static inline bool TupleRouterM$IS_AGGREGATING_RESULT(void);
static inline void TupleRouterM$UNSET_AGGREGATING_RESULT(void);
static inline void TupleRouterM$SET_AGGREGATING_RESULT(void);

static inline bool TupleRouterM$IS_SENDING_QUERY(void);
static inline void TupleRouterM$UNSET_SENDING_QUERY(void);


static inline bool TupleRouterM$IS_IN_QUERY_MSG(void);
static inline void TupleRouterM$UNSET_IS_IN_QUERY_MSG(void);
static inline void TupleRouterM$SET_IS_IN_QUERY_MSG(void);


static inline void TupleRouterM$UNSET_SETTING_SAMPLE_RATE(void);


static inline bool TupleRouterM$IS_SNOOZING(void);
static inline void TupleRouterM$UNSET_SNOOZING(void);
static inline void TupleRouterM$SET_SNOOZING(void);









static inline void TupleRouterM$continueQuery(Handle *memory);
static bool TupleRouterM$addQueryField(QueryMessagePtr qmsg);
static inline bool TupleRouterM$allocPendingQuery(TupleRouterM$MemoryCallback callback, Query *q);
static inline bool TupleRouterM$allocQuery(TupleRouterM$MemoryCallback callback, Query *q);
static inline void TupleRouterM$parsedCallback(Handle *memory);
static inline bool TupleRouterM$parseQuery(Query *q, ParsedQuery *pq);
static void TupleRouterM$parsedQuery(bool success);
static inline void TupleRouterM$continueParsing(result_t success);
static inline bool TupleRouterM$queryComplete(Query q);
static inline bool TupleRouterM$reallocQueryForTuple(TupleRouterM$MemoryCallback callback, TupleRouterM$QueryListHandle qlh);
static inline void TupleRouterM$resizedCallback(Handle *memory);
static inline void TupleRouterM$setSampleRate(void);


static void TupleRouterM$finishedOpeningWriteBuffer(ParsedQuery *pq);

static inline void TupleRouterM$continueFromBufferFetch(TinyDBError err);

static void TupleRouterM$setRate(uint8_t qid, uint16_t epochDur);


static bool TupleRouterM$fetchNextAttr(void);
static inline TupleRouterM$TupleFieldDesc TupleRouterM$getNextQueryField(ParsedQuery **q);
static TupleRouterM$QueryListHandle TupleRouterM$nextQueryToRoute(TupleRouterM$QueryListHandle curQuery);
static inline bool TupleRouterM$routeToQuery(ParsedQuery *q, Tuple *t);
static Expr *TupleRouterM$nextExpr(ParsedQuery *q);
static bool TupleRouterM$getQuery(uint8_t qid, ParsedQuery **q);
static inline void TupleRouterM$startFetchingTuples(void);
static inline void TupleRouterM$resetTupleState(ParsedQuery *q);
static void TupleRouterM$fillInAttrVal(SchemaErrorNo errorNo);
static void TupleRouterM$aggregateResult(ParsedQuery *q, QueryResult *qr, char exprId);



static  void TupleRouterM$removeQueryTask(void);
static TinyDBError TupleRouterM$forwardQuery(QueryMessagePtr qmsg);

static void TupleRouterM$finishedBufferSetup(ParsedQuery *pq);
static inline void TupleRouterM$keepRouting(void);

static inline void TupleRouterM$initConsts(void);
static inline void TupleRouterM$decrementQueryCounter(void);
static inline void TupleRouterM$failedOpeningWriteBuffer(ParsedQuery *pq);




static inline void TupleRouterM$computeRates(uint32_t lifetimeHoursRem, 
uint32_t curVReading, 
uint32_t ujSampleCost, 
uint32_t ujAggCost, 
uint32_t numMsgs, 
uint32_t numSamples, 
uint32_t *epochDur, 
uint16_t *aggWinSize, 
uint16_t *vPerDay);


static void TupleRouterM$continueSetSampleRate(void);

static inline void TupleRouterM$doTimeSync(uint8_t timeSyncData[5], uint16_t clockCount);
static void TupleRouterM$checkTime(void);

static TinyDBError TupleRouterM$sendTuple(ParsedQuery *pq, QueryResultPtr qr, bool *pending);
static result_t TupleRouterM$outputDone(TOS_MsgPtr msg);





static void TupleRouterM$startQueryAttrs(ParsedQuery *pq);









static inline void TupleRouterM$startAllQueryAttrs(void);
#line 560
static  void TupleRouterM$deliverTuplesTask(void);
static  void TupleRouterM$routeTask(void);
static  void TupleRouterM$sendQuery(void);
static inline  void TupleRouterM$fillInTask(void);
static inline  void TupleRouterM$mainTask(void);
static inline  void TupleRouterM$queryMsgTask(void);






static inline  result_t TupleRouterM$StdControl$init(void);
#line 642
static  result_t TupleRouterM$StdControl$start(void);
#line 711
static  result_t TupleRouterM$StdControl$stop(void);
#line 775
static inline  result_t TupleRouterM$Network$querySub(QueryMessagePtr qmsg);
#line 927
static TinyDBError TupleRouterM$forwardQuery(QueryMessagePtr qmsg);
#line 959
static inline void TupleRouterM$continueQuery(Handle *memory);
#line 1008
static bool TupleRouterM$addQueryField(QueryMessagePtr qmsg);
#line 1057
static void TupleRouterM$finishedBufferSetup(ParsedQuery *pq);
#line 1071
static inline void TupleRouterM$parsedCallback(Handle *memory);
#line 1097
static void TupleRouterM$parsedQuery(bool success);
#line 1139
static inline void TupleRouterM$resizedCallback(Handle *memory);
#line 1248
static inline void TupleRouterM$failedOpeningWriteBuffer(ParsedQuery *pq);
#line 1262
static void TupleRouterM$finishedOpeningWriteBuffer(ParsedQuery *pq);
#line 1291
static  void TupleRouterM$removeQueryTask(void);
#line 1379
static  void TupleRouterM$sendQuery(void);
#line 1581
static inline  void TupleRouterM$queryMsgTask(void);
#line 1686
static inline  TinyDBError TupleRouterM$SelOperator$processedTuple(Tuple *t, 
ParsedQuery *q, 
Expr *e, 
bool passed);
#line 1709
static inline  TinyDBError TupleRouterM$AggOperator$processedTuple(Tuple *t, ParsedQuery *q, 
Expr *e, bool passed);
#line 1723
static inline  TinyDBError TupleRouterM$AggOperator$processedResult(QueryResult *qr, ParsedQuery *q, Expr *e);
#line 1738
static  result_t TupleRouterM$Network$dataSub(QueryResultPtr qrMsg);
#line 1798
static void TupleRouterM$aggregateResult(ParsedQuery *q, QueryResult *qr, char exprId);
#line 1827
static inline void TupleRouterM$setSampleRate(void);
#line 1943
static void TupleRouterM$setRate(uint8_t qid, uint16_t epochDur);
#line 1978
enum TupleRouterM$__nesc_unnamed4388 {
  TupleRouterM$msXmit = 32, 
  TupleRouterM$mahCapacity = 5800, 
  TupleRouterM$maxVReading = 985, 
  TupleRouterM$minVReading = 370, 
  TupleRouterM$Vdraw = 3, 
  TupleRouterM$sPerSample = 1
};



uint32_t TupleRouterM$uaActive;
#line 1989
uint32_t TupleRouterM$uaXmit;
#line 1989
uint32_t TupleRouterM$uaSleep;

static inline void TupleRouterM$initConsts(void);





static inline void TupleRouterM$computeRates(uint32_t lifetimeHoursRem, 
uint32_t curVReading, 
uint32_t ujSampleCost, 
uint32_t ujAggCost, 
uint32_t numMsgs, 
uint32_t numSamples, 
uint32_t *epochDur, 
uint16_t *aggWinSize, 
uint16_t *mvPerDay);
#line 2075
static void TupleRouterM$continueSetSampleRate(void);
#line 2111
static  result_t TupleRouterM$AbsoluteTimer$fired(void);
#line 2176
static inline  void TupleRouterM$mainTask(void);
#line 2318
static  void TupleRouterM$deliverTuplesTask(void);
#line 2461
static result_t TupleRouterM$outputDone(TOS_MsgPtr msg);
#line 2495
static TinyDBError TupleRouterM$sendTuple(ParsedQuery *pq, QueryResultPtr qr, bool *pending);
#line 2518
static inline void TupleRouterM$decrementQueryCounter(void);








static inline  result_t TupleRouterM$Network$sendDataDone(TOS_MsgPtr msg, result_t success);









static inline  result_t TupleRouterM$Network$sendQueryDone(TOS_MsgPtr msg, result_t success);
#line 2569
static inline void TupleRouterM$startFetchingTuples(void);
#line 2664
static inline void TupleRouterM$resetTupleState(ParsedQuery *q);
#line 2706
static bool TupleRouterM$fetchNextAttr(void);
#line 2800
static inline TupleRouterM$TupleFieldDesc TupleRouterM$getNextQueryField(ParsedQuery **pq);
#line 2848
static inline void TupleRouterM$keepRouting(void);
#line 2870
static void TupleRouterM$fillInAttrVal(SchemaErrorNo errorNo);
#line 2935
static inline  void TupleRouterM$fillInTask(void);









static inline  result_t TupleRouterM$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo);
#line 2965
static  void TupleRouterM$routeTask(void);
#line 2984
static TupleRouterM$QueryListHandle TupleRouterM$nextQueryToRoute(TupleRouterM$QueryListHandle curQuery);
#line 3011
static inline bool TupleRouterM$routeToQuery(ParsedQuery *q, Tuple *t);
#line 3041
static Expr *TupleRouterM$nextExpr(ParsedQuery *q);
#line 3059
static bool TupleRouterM$getQuery(uint8_t qid, ParsedQuery **q);
#line 3074
static inline  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryCmd(uint8_t qid);







static inline  short TupleRouterM$QueryProcessor$numQueries(void);
#line 3095
static  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryIdx(short i);
#line 3136
static inline  bool TupleRouterM$QueryProcessor$queryProcessorWantsData(QueryResultPtr qr);
#line 3154
static inline bool TupleRouterM$parseQuery(Query *q, ParsedQuery *pq);
#line 3271
static inline void TupleRouterM$continueFromBufferFetch(TinyDBError err);
#line 3332
static inline void TupleRouterM$continueParsing(result_t success);
#line 3389
static inline bool TupleRouterM$allocPendingQuery(TupleRouterM$MemoryCallback callback, Query *q);
#line 3403
static inline bool TupleRouterM$allocQuery(TupleRouterM$MemoryCallback callback, Query *q);










static inline bool TupleRouterM$reallocQueryForTuple(TupleRouterM$MemoryCallback callback, TupleRouterM$QueryListHandle qlh);
#line 3428
static inline bool TupleRouterM$queryComplete(Query q);










static inline void TupleRouterM$doTimeSync(uint8_t timeSyncData[5], uint16_t clockCount);
#line 3451
static void TupleRouterM$checkTime(void);
#line 3498
static  result_t TupleRouterM$MemAlloc$allocComplete(Handle *handle, result_t complete);
#line 3551
static  result_t TupleRouterM$MemAlloc$reallocComplete(Handle handle, result_t complete);
#line 3573
static inline  result_t TupleRouterM$MemAlloc$compactComplete(void);
#line 3590
static inline  TinyDBError TupleRouterM$RadioQueue$enqueue(const QueryResultPtr qrMsg, bool *pending);
#line 3644
static  void TupleRouterM$signalError(TinyDBError err, int lineNo);
#line 3675
static inline  void TupleRouterM$statusMessage(CharPtr m);
#line 3776
static inline  result_t TupleRouterM$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result);
#line 3793
static inline  result_t TupleRouterM$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err);
#line 3807
static inline  result_t TupleRouterM$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err);
#line 3874
static inline  result_t TupleRouterM$AttrUse$startAttrDone(uint8_t id);
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
static  result_t SimpleTimeM$AbsoluteTimer$fired(
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
uint8_t arg_0x228b658);
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
static   tos_time_t SimpleTimeM$TimeUtil$addUint32(tos_time_t arg_0x20b1bd8, uint32_t arg_0x20b1d58);
#line 92
static   tos_time_t SimpleTimeM$TimeUtil$subtract(tos_time_t arg_0x20af7c8, tos_time_t arg_0x20af948);
#line 87
static   tos_time_t SimpleTimeM$TimeUtil$add(tos_time_t arg_0x20af170, tos_time_t arg_0x20af2f0);
#line 82
static   char SimpleTimeM$TimeUtil$compare(tos_time_t arg_0x20b0aa0, tos_time_t arg_0x20b0c20);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t SimpleTimeM$TimerControl$init(void);






static  result_t SimpleTimeM$TimerControl$start(void);
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t SimpleTimeM$Timer$start(char arg_0x1841820, uint32_t arg_0x18419a8);








static  result_t SimpleTimeM$Timer$stop(void);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
uint16_t SimpleTimeM$interval;
tos_time_t SimpleTimeM$time;
tos_time_t SimpleTimeM$aTimer[MAX_NUM_TIMERS];
bool SimpleTimeM$timingChanged;

static inline  result_t SimpleTimeM$StdControl$init(void);
#line 87
static inline  result_t SimpleTimeM$StdControl$start(void);
#line 111
static inline   void SimpleTimeM$setInterval(uint16_t new_interval);
#line 123
static inline   tos_time_t SimpleTimeM$Time$get(void);






static inline   uint32_t SimpleTimeM$Time$getHigh32(void);







static inline   uint32_t SimpleTimeM$Time$getLow32(void);







static  result_t SimpleTimeM$AbsoluteTimer$set(uint8_t id, tos_time_t in);
#line 164
static  result_t SimpleTimeM$AbsoluteTimer$cancel(uint8_t id);







static inline   result_t SimpleTimeM$AbsoluteTimer$default$fired(uint8_t id);



static inline  result_t SimpleTimeM$Timer$fired(void);
#line 205
static inline  void SimpleTimeM$TimeSet$set(tos_time_t t);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimeUtilC.nc"
static   char TimeUtilC$TimeUtil$compare(tos_time_t a, tos_time_t b);








static inline   tos_time_t TimeUtilC$TimeUtil$subtract(tos_time_t a, tos_time_t b);
#line 75
static inline   tos_time_t TimeUtilC$TimeUtil$add(tos_time_t a, tos_time_t b);
#line 99
static   tos_time_t TimeUtilC$TimeUtil$addUint32(tos_time_t a, uint32_t ms);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
static  AttrDescPtr Tuple$AttrUse$getAttrById(uint8_t arg_0x204da90);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
static  bool Tuple$ParsedQueryIntf$queryFieldIsTyped(uint8_t arg_0x206cdd8);
#line 43
static  bool Tuple$ParsedQueryIntf$queryFieldIsNull(uint8_t arg_0x206c928);
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/CatalogTable.nc"
static  uint8_t Tuple$CatalogTable$catalogFieldSize(uint8_t arg_0x22c7468, uint8_t arg_0x22c75e0);
# 135 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
static  ParsedQuery **Tuple$DBBuffer$getSchema(uint8_t arg_0x20d2890);
#line 151
static  TinyDBError Tuple$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650);
# 102 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline uint16_t Tuple$typeToSize(TOSType type);


static  uint16_t Tuple$TupleIntf$tupleSize(ParsedQueryPtr q);
#line 118
static  uint16_t Tuple$TupleIntf$fieldSize(ParsedQueryPtr q, uint8_t fieldNo);
#line 182
static  result_t Tuple$TupleIntf$setField(ParsedQueryPtr q, TuplePtr t, uint8_t fieldIdx, CharPtr data);
#line 195
static inline  result_t Tuple$TupleIntf$setFieldNoQuery(TuplePtr t, 
uint8_t fieldIdx, 
uint8_t numFields, 
uint8_t sizes[], 
uint8_t types[], 
CharPtr data);
#line 214
static  CharPtr Tuple$TupleIntf$getFieldPtr(ParsedQueryPtr q, TuplePtr t, uint8_t fieldIdx);
#line 231
static  CharPtr Tuple$TupleIntf$getFieldPtrNoQuery(TuplePtr t, 
uint8_t fieldIdx, 
uint8_t numFields, 
uint8_t sizes[], 
uint8_t types[]);










static inline  result_t Tuple$TupleIntf$tupleInit(ParsedQueryPtr q, TuplePtr t);
#line 270
static inline  AttrDescPtr Tuple$TupleIntf$getNextQueryField(ParsedQueryPtr q, TuplePtr t);
#line 284
static  TinyDBError Tuple$TupleIntf$getNextEmptyFieldIdx(ParsedQueryPtr q, TuplePtr t, uint8_t *fieldIdx);
#line 298
static inline uint16_t Tuple$typeToSize(TOSType type);



static inline  result_t Tuple$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo);



static inline  result_t Tuple$AttrUse$startAttrDone(uint8_t id);



static inline  result_t Tuple$QueryProcessor$queryComplete(ParsedQueryPtr q);
#line 326
static inline  result_t Tuple$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result);




static inline  result_t Tuple$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError result);




static inline  result_t Tuple$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err);
# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  short Query$QueryIntf$size(QueryPtr q);



static inline  Field Query$QueryIntf$getField(QueryPtr q, uint8_t idx);



static inline  Field *Query$QueryIntf$getFieldPtr(QueryPtr q, uint8_t idx);



static inline  result_t Query$QueryIntf$setField(QueryPtr q, uint8_t idx, Field f);




static  Expr Query$QueryIntf$getExpr(QueryPtr q, uint8_t idx);





static inline  result_t Query$QueryIntf$setExpr(QueryPtr q, uint8_t idx, Expr e);






static inline  bool Query$QueryIntf$fieldsComplete(Query q);



static inline  bool Query$QueryIntf$exprsComplete(Query q);
# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static  short ParsedQuery$getGroupNoFromQr(QueryResult *arg_0x2346b10);
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  CharPtr ParsedQuery$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80);
#line 50
static  uint16_t ParsedQuery$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
static  AttrDescPtr ParsedQuery$AttrUse$getAttrById(uint8_t arg_0x204da90);
#line 66
static  AttrDescPtr ParsedQuery$AttrUse$getAttr(char *arg_0x204d508);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
static  bool ParsedQuery$AggOperator$resultIsForExpr(QueryResultPtr arg_0x209bf00, ExprPtr arg_0x209a088);
# 137 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
static  ResultTuple ParsedQuery$QueryResultIntf$getResultTuple(QueryResultPtr arg_0x208c670, short arg_0x208c7e0, ParsedQueryPtr arg_0x208c960);
#line 131
static  short ParsedQuery$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0);
#line 124
static  TinyDBError ParsedQuery$QueryResultIntf$fromResultTuple(ResultTuple arg_0x208d398, QueryResultPtr arg_0x208d518, ParsedQueryPtr arg_0x208d698);
#line 100
static  TinyDBError ParsedQuery$QueryResultIntf$toTuplePtr(QueryResultPtr arg_0x208f268, ParsedQueryPtr arg_0x208f3e8, TupleHandle arg_0x208f568);
# 135 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
static  ParsedQuery **ParsedQuery$DBBuffer$getSchema(uint8_t arg_0x20d2890);
#line 151
static  TinyDBError ParsedQuery$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650);
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static  TinyDBError ParsedQuery$finalizeAggExpr(QueryResult *arg_0x23461b0, ParsedQueryPtr arg_0x2346330, Expr *arg_0x23464c8, char *arg_0x2346660);







static inline  bool ParsedQuery$ParsedQueryIntf$queryFieldIsNull(uint8_t field);




static inline  bool ParsedQuery$ParsedQueryIntf$queryFieldIsTyped(uint8_t field);



static  Expr ParsedQuery$ParsedQueryIntf$getExpr(ParsedQueryPtr q, uint8_t n);



static  ExprPtr ParsedQuery$ParsedQueryIntf$getExprPtr(ParsedQueryPtr q, uint8_t n);



static inline  uint8_t ParsedQuery$ParsedQueryIntf$getFieldId(ParsedQueryPtr q, uint8_t n);



static inline  result_t ParsedQuery$ParsedQueryIntf$setExpr(ParsedQueryPtr q, uint8_t n, Expr e);




static  TuplePtr ParsedQuery$ParsedQueryIntf$getTuplePtr(ParsedQueryPtr q);



static inline  short ParsedQuery$ParsedQueryIntf$baseSize(QueryPtr q);




static inline  short ParsedQuery$ParsedQueryIntf$pqSize(ParsedQueryPtr pq);
#line 155
static inline  TinyDBError ParsedQuery$ParsedQueryIntf$getResultField(ParsedQueryPtr q, QueryResultPtr qr, uint8_t resultid, char *result_buf);
#line 217
static inline  TinyDBError ParsedQuery$ParsedQueryIntf$getResultId(ParsedQueryPtr q, Field *f, uint8_t *id);
#line 296
static  result_t ParsedQuery$ParsedQueryIntf$getFieldType(ParsedQuery *pq, uint8_t fieldIdx, 
uint8_t *type);
#line 347
static inline  bool ParsedQuery$ParsedQueryIntf$typeCheck(ParsedQuery *dest, ParsedQuery *select);
#line 385
static inline  result_t ParsedQuery$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo);



static inline  result_t ParsedQuery$AttrUse$startAttrDone(uint8_t id);



static inline  TinyDBError ParsedQuery$AggOperator$processedResult(QueryResultPtr qr, ParsedQueryPtr q, ExprPtr e);



static inline  TinyDBError ParsedQuery$AggOperator$processedTuple(TuplePtr t, ParsedQueryPtr q, ExprPtr e, bool passed);
#line 413
static inline  result_t ParsedQuery$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result);




static inline  result_t ParsedQuery$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError result);




static inline  result_t ParsedQuery$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err);
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  CharPtr SelOperator$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80);
#line 50
static  uint16_t SelOperator$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0);
# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
static  TinyDBError SelOperator$Operator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40);
# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEval.nc"
static  short SelOperator$ExprEval$evaluate(Expr *arg_0x23a7408, short arg_0x23a7580);
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SelOperator.nc"
ParsedQuery *SelOperator$mQs;
Tuple *SelOperator$mT;
Expr *SelOperator$mE;

static inline  void SelOperator$doFilter(void);






static inline  TinyDBError SelOperator$Operator$processTuple(ParsedQueryPtr qs, TuplePtr t, ExprPtr e);
#line 84
static inline  void SelOperator$doFilter(void);
# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  uint16_t QueryResult$TupleIntf$tupleSize(ParsedQueryPtr arg_0x2044190);
# 102 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
enum QueryResult$__nesc_unnamed4389 {
  QueryResult$BUF_SIZE = 80
};



static inline  TinyDBError QueryResult$QueryResultIntf$initQueryResult(QueryResultPtr qr);
#line 121
static inline  TinyDBError QueryResult$QueryResultIntf$fromTuple(QueryResultPtr qr, ParsedQueryPtr pq, TuplePtr t);
#line 139
static inline  TinyDBError QueryResult$QueryResultIntf$toTuplePtr(QueryResultPtr qr, ParsedQueryPtr q, TupleHandle t);









static inline  TinyDBError QueryResult$QueryResultIntf$toBytes(QueryResultPtr qr, ParsedQueryPtr pq, CharPtr bytes);
#line 197
static inline  TinyDBError QueryResult$QueryResultIntf$fromBytes(QueryResultPtr bytes, QueryResultPtr qr, ParsedQueryPtr pq);
#line 230
static  TinyDBError QueryResult$QueryResultIntf$fromResultTuple(ResultTuple r, QueryResultPtr qr, ParsedQueryPtr pq);
#line 251
static inline  uint8_t QueryResult$QueryResultIntf$queryIdFromMsg(QueryResultPtr qr);
#line 282
static  short QueryResult$QueryResultIntf$numRecords(QueryResultPtr qr, ParsedQueryPtr q);
#line 296
static  ResultTuple QueryResult$QueryResultIntf$getResultTuple(QueryResultPtr qr, short i, ParsedQueryPtr q);
#line 346
static inline  TinyDBError QueryResult$QueryResultIntf$addAggResult(QueryResultPtr qr, 
int16_t groupNo, 
char *bytes, 
int16_t size, 
ParsedQueryPtr q, 
short exprIdx);
#line 371
static inline  result_t QueryResult$MemAlloc$allocComplete(HandlePtr handle, result_t success);



static inline  result_t QueryResult$MemAlloc$reallocComplete(Handle handle, result_t success);



static inline  result_t QueryResult$MemAlloc$compactComplete(void);
# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
static  result_t TinyAlloc$MemAlloc$compactComplete(void);
#line 170
static  result_t TinyAlloc$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8);
#line 157
static  result_t TinyAlloc$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0);
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
enum TinyAlloc$__nesc_unnamed4390 {
  TinyAlloc$FRAME_SIZE = 256, 
  TinyAlloc$FREE_SIZE = TinyAlloc$FRAME_SIZE >> 3, 
  TinyAlloc$MAX_SIZE = 32765, 
  TinyAlloc$HEADER_SIZE = 2, 
  TinyAlloc$MAX_HANDLES = 20
};

uint8_t TinyAlloc$mFrame[TinyAlloc$FRAME_SIZE];
uint8_t TinyAlloc$mFree[TinyAlloc$FREE_SIZE];
int8_t TinyAlloc$mAllocing;
int8_t TinyAlloc$mCompacting;
int16_t TinyAlloc$mSize;
int16_t TinyAlloc$mLast;
Handle *TinyAlloc$mHandle;
int8_t **TinyAlloc$mTmpHandle;
Handle TinyAlloc$mOldHandle;
int8_t *TinyAlloc$mHandles[TinyAlloc$MAX_HANDLES];
int8_t TinyAlloc$mReallocing;
int8_t TinyAlloc$mCompacted;
int8_t TinyAlloc$mNeedFree;
int16_t TinyAlloc$mContig;
int16_t TinyAlloc$mStartByte;
uint16_t TinyAlloc$mFreeBytes;






static void TinyAlloc$doAlloc(int16_t startByte, int16_t endByte);
static inline void TinyAlloc$shiftUp(Handle handle, int bytes);
static inline int16_t TinyAlloc$start_offset(int8_t *ptr);
static void TinyAlloc$setFreeBits(int16_t startByte, int16_t endByte, int8_t on);
static void TinyAlloc$remapAddr(int8_t *oldAddr, int8_t *newAddr);
static inline int8_t TinyAlloc$isValid(Handle h);
static inline int16_t TinyAlloc$getSize(int8_t *p);
static inline int8_t TinyAlloc$isLocked(int8_t *ptr);
static int8_t TinyAlloc$finish_realloc(Handle *handle, int8_t success);
static inline Handle TinyAlloc$getH(int8_t *p);
static inline int16_t TinyAlloc$getNewHandleIdx(void);
static void TinyAlloc$markHandleFree(Handle hand);


static __inline int8_t *TinyAlloc$deref(Handle h);

static  void TinyAlloc$compactTask(void);
static  void TinyAlloc$allocTask(void);
static inline  void TinyAlloc$reallocDone(void);








static inline  result_t TinyAlloc$StdControl$init(void);
#line 172
static inline  result_t TinyAlloc$StdControl$start(void);







static  result_t TinyAlloc$MemAlloc$allocate(HandlePtr handlePtr, int16_t size);
#line 198
static  void TinyAlloc$allocTask(void);
#line 285
static void TinyAlloc$doAlloc(int16_t startByte, int16_t endByte);
#line 313
static  void TinyAlloc$compactTask(void);
#line 412
static inline void TinyAlloc$shiftUp(Handle hand, int bytes);
#line 440
static  int16_t TinyAlloc$MemAlloc$free(Handle hand);
#line 476
static  result_t TinyAlloc$MemAlloc$reallocate(Handle hand, int16_t newSize);
#line 519
static inline  void TinyAlloc$reallocDone(void);




static int8_t TinyAlloc$finish_realloc(Handle *hand, int8_t success);
#line 558
static inline  result_t TinyAlloc$MemAlloc$lock(Handle handle);







static inline  result_t TinyAlloc$MemAlloc$unlock(Handle handle);






static inline int8_t TinyAlloc$isLocked(int8_t *ptr);






static inline int8_t TinyAlloc$isLocked(int8_t *ptr);





static inline  int16_t TinyAlloc$MemAlloc$size(Handle h);





static inline int16_t TinyAlloc$getSize(int8_t *ptr);









static inline int8_t TinyAlloc$isValid(Handle h);
#line 617
static void TinyAlloc$remapAddr(int8_t *oldAddr, int8_t *newAddr);










static inline Handle TinyAlloc$getH(int8_t *p);










static inline int16_t TinyAlloc$getNewHandleIdx(void);










static void TinyAlloc$markHandleFree(Handle hand);
#line 668
static void TinyAlloc$setFreeBits(int16_t startByte, int16_t endByte, int8_t on);
#line 709
static inline int16_t TinyAlloc$start_offset(int8_t *ptr);
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  CharPtr AggOperator$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80);
#line 50
static  uint16_t AggOperator$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0);
# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
static  bool AggOperator$AggregateUse$hasData(uint8_t arg_0x2480068, char *arg_0x24801f8, ParamList *arg_0x2480398, ParamVals *arg_0x2480540);

static  TinyDBError AggOperator$AggregateUse$finalize(uint8_t arg_0x24809d0, char *arg_0x2480b60, char *arg_0x2480cf8, ParamList *arg_0x2480e98, ParamVals *arg_0x24d1068);
#line 94
static  uint16_t AggOperator$AggregateUse$stateSize(uint8_t arg_0x2481878, ParamList *arg_0x2481a18, ParamVals *arg_0x2481bc0);
#line 92
static  result_t AggOperator$AggregateUse$init(uint8_t arg_0x2483c80, char *arg_0x2483e10, ParamList *arg_0x2481010, ParamVals *arg_0x24811b8, bool arg_0x2481338);
#line 83
static  result_t AggOperator$AggregateUse$merge(uint8_t arg_0x2484590, char *arg_0x2484728, char *arg_0x24848c0, ParamList *arg_0x2484a60, ParamVals *arg_0x2484c08);


static  result_t AggOperator$AggregateUse$update(uint8_t arg_0x2483188, char *arg_0x2483318, char *arg_0x24834a8, ParamList *arg_0x2483648, ParamVals *arg_0x24837f0);
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static  void AggOperator$signalError(TinyDBError arg_0x24d1be8, int arg_0x24d1d58);
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
static  Expr AggOperator$ParsedQueryIntf$getExpr(ParsedQueryPtr arg_0x206b328, uint8_t arg_0x206b4a0);
# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
static  TinyDBError AggOperator$Operator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40);
#line 105
static  TinyDBError AggOperator$Operator$processedResult(QueryResultPtr arg_0x2097100, ParsedQueryPtr arg_0x2097280, ExprPtr arg_0x20973f8);
# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
static  result_t AggOperator$MemAlloc$reallocate(Handle arg_0x2085b88, int16_t arg_0x2085d00);
#line 61
static  result_t AggOperator$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638);
#line 104
static  int16_t AggOperator$MemAlloc$free(Handle arg_0x2084dd8);
# 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
static  TinyDBError AggOperator$QueryResultIntf$addAggResult(QueryResultPtr arg_0x208cec8, int16_t arg_0x208a068, char *arg_0x208a1f8, int16_t arg_0x208a370, ParsedQueryPtr arg_0x208a4f0, short arg_0x208a660);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEval.nc"
static  short AggOperator$ExprEval$evaluateGroupBy(AggregateExpression arg_0x23a7a00, short arg_0x23a7b78);
#line 45
static  short AggOperator$ExprEval$evaluate(Expr *arg_0x23a7408, short arg_0x23a7580);
# 112 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
#line 108
typedef struct AggOperator$__nesc_unnamed4391 {
  int numGroups;
  int groupSize;
  char groupData[1];
} AggOperator$GroupData;
#line 112
#line 108
typedef struct AggOperator$__nesc_unnamed4391 *



AggOperator$GroupDataPtr;
#line 112
#line 108
typedef struct AggOperator$__nesc_unnamed4391 **



AggOperator$GroupDataHandle;









#line 114
typedef struct AggOperator$__nesc_unnamed4392 {
  short groupNo;
  union AggOperator$__nesc_unnamed4393 {
    bool empty;
    char exprIdx;
  } u;
  char aggdata[1];
} 
__attribute((packed))  AggOperator$GroupRecord;

typedef void (*AggOperator$GroupDataCallback)(AggOperator$GroupRecord *d);

AggOperator$GroupDataCallback AggOperator$mCallback;
ParsedQuery *AggOperator$mCurQuery;
Expr *AggOperator$mCurExpr;
QueryResult *AggOperator$mCurResult;
Tuple *AggOperator$mCurTuple;
short AggOperator$mCurGroup;
Handle AggOperator$mAlloced;
AggOperator$GroupRecord *AggOperator$mGroupRecord;

enum AggOperator$__nesc_unnamed4394 {
  AggOperator$QUERY_DONE_STATE = 0x1010
};



static void AggOperator$getGroupData(ParsedQuery *pq, short groupNo, Expr *e, AggOperator$GroupDataCallback callback);
static inline void AggOperator$updateGroupForTuple(AggOperator$GroupRecord *d);
static short AggOperator$groupSize(Expr *e);
static inline void AggOperator$mergeAggregateValues(AggOperator$GroupRecord *dest, AggOperator$GroupRecord *merge, Expr *e);
static inline void AggOperator$updateAggregateValue(AggOperator$GroupRecord *d, Expr *e, short fieldValue);
static void AggOperator$initAggregateValue(AggOperator$GroupRecord *d, Expr *e, bool isFirstTime);
static inline void AggOperator$updateGroupForPartialResult(AggOperator$GroupRecord *d);
static inline bool AggOperator$aggHasData(AggOperator$GroupRecord *gr, Expr *e);
static inline AggOperator$GroupRecord *AggOperator$findGroup(AggOperator$GroupDataHandle dh, short groupNum);
static AggOperator$GroupRecord *AggOperator$addGroup(AggOperator$GroupDataHandle dh, short groupNum);
static inline bool AggOperator$removeEmptyGroup(AggOperator$GroupDataHandle dh);
static inline short AggOperator$getGroupNo(Tuple *t, ParsedQuery *q, Expr *e);









static inline AggOperator$GroupRecord *AggOperator$GET_GROUP_DATA(AggOperator$GroupDataHandle dHan, uint8_t n);



static void AggOperator$SET_GROUP_DATA(AggOperator$GroupDataHandle dHan, uint8_t n, char *dataptr);
#line 190
static inline  TinyDBError AggOperator$Operator$processPartialResult(QueryResultPtr qr, ParsedQueryPtr qs, ExprPtr e);
#line 210
static inline  bool AggOperator$Operator$resultIsForExpr(QueryResultPtr qr, ExprPtr e);









static inline void AggOperator$updateGroupForPartialResult(AggOperator$GroupRecord *d);
#line 278
static inline  TinyDBError AggOperator$addResults(QueryResult *qr, ParsedQuery *pq, ExprPtr e);
#line 312
static inline  TinyDBError AggOperator$Operator$processTuple(ParsedQueryPtr qs, TuplePtr t, ExprPtr e);
#line 326
static inline  result_t AggOperator$Operator$endOfEpoch(ParsedQueryPtr q, ExprPtr e);
#line 343
static inline  result_t AggOperator$QueryProcessor$queryComplete(ParsedQuery *q);
#line 361
static inline void AggOperator$updateGroupForTuple(AggOperator$GroupRecord *d);
#line 383
static  result_t AggOperator$MemAlloc$allocComplete(HandlePtr h, uint8_t success);
#line 407
static  result_t AggOperator$MemAlloc$reallocComplete(Handle h, uint8_t success);
#line 429
static inline  result_t AggOperator$MemAlloc$compactComplete(void);





static inline AggOperator$GroupRecord *AggOperator$findGroup(AggOperator$GroupDataHandle dh, short groupNum);
#line 460
static inline bool AggOperator$removeEmptyGroup(AggOperator$GroupDataHandle dh);
#line 489
static AggOperator$GroupRecord *AggOperator$addGroup(AggOperator$GroupDataHandle dh, short groupNum);
#line 529
static void AggOperator$getGroupData(ParsedQuery *pq, short groupNo, Expr *e, AggOperator$GroupDataCallback callback);
#line 571
static inline short AggOperator$getGroupNo(Tuple *t, ParsedQuery *q, Expr *e);
#line 593
static inline  short AggOperator$getGroupNoFromQr(QueryResult *qr);
#line 617
static short AggOperator$groupSize(Expr *e);
#line 630
static inline void AggOperator$mergeAggregateValues(AggOperator$GroupRecord *dest, AggOperator$GroupRecord *merge, Expr *e);
#line 645
static inline void AggOperator$updateAggregateValue(AggOperator$GroupRecord *d, Expr *e, short fieldValue);
#line 664
static void AggOperator$initAggregateValue(AggOperator$GroupRecord *d, Expr *e, bool isFirstTime);
#line 679
static inline bool AggOperator$aggHasData(AggOperator$GroupRecord *gr, Expr *e);






static inline  TinyDBError AggOperator$finalizeAggExpr(QueryResult *qr, ParsedQueryPtr q, Expr *e, char *result_buf);
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEvalC.nc"
static short ExprEvalC$evaluateSimpleExpr(short a, short op, short b);

static inline  short ExprEvalC$ExprEval$evaluate(Expr *e, short fieldValue);






static inline  short ExprEvalC$ExprEval$evaluateGroupBy(AggregateExpression a, short grpByFieldValue);
#line 73
static short ExprEvalC$evaluateSimpleExpr(short a, short op, short b);
# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
static  bool AggregateUseM$Agg$hasData(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
char *arg_0x2552f30, ParamList *arg_0x25510e8, ParamVals *arg_0x2551290);
#line 98
static  TinyDBError AggregateUseM$Agg$finalize(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
char *arg_0x2554f10, char *arg_0x25520b8, ParamList *arg_0x2552258, ParamVals *arg_0x2552400);




static  uint16_t AggregateUseM$Agg$stateSize(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
ParamList *arg_0x25528c8, ParamVals *arg_0x2552a70);
#line 93
static  result_t AggregateUseM$Agg$init(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
char *arg_0x25544e0, ParamList *arg_0x2554680, ParamVals *arg_0x2554828, bool arg_0x25549a8);
#line 81
static  result_t AggregateUseM$Agg$merge(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
char *arg_0x25550a8, char *arg_0x2555240, ParamList *arg_0x25553e0, ParamVals *arg_0x2555588);




static  result_t AggregateUseM$Agg$update(
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
uint8_t arg_0x255b358, 
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
char *arg_0x2555a68, char *arg_0x2555bf8, ParamList *arg_0x2555d98, ParamVals *arg_0x2554010);
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  result_t AggregateUseM$AggregateUse$merge(uint8_t id, char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues);




static inline  result_t AggregateUseM$AggregateUse$update(uint8_t id, char *destdata, char *value, ParamList *params, ParamVals *paramValues);




static inline  result_t AggregateUseM$AggregateUse$init(uint8_t id, char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime);



static inline  uint16_t AggregateUseM$AggregateUse$stateSize(uint8_t id, ParamList *params, ParamVals *paramValues);



static inline  bool AggregateUseM$AggregateUse$hasData(uint8_t id, char *data, ParamList *params, ParamVals *paramValues);



static inline  TinyDBError AggregateUseM$AggregateUse$finalize(uint8_t id, char *data, char *result_buf, ParamList *params, ParamVals *paramValues);
#line 121
static inline   
#line 120
result_t AggregateUseM$Agg$default$merge(uint8_t id, 
char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues);




static inline   
#line 125
result_t AggregateUseM$Agg$default$update(uint8_t id, 
char *destdata, char *value, ParamList *params, ParamVals *paramValues);




static inline   
#line 130
result_t AggregateUseM$Agg$default$init(uint8_t id, 
char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime);




static inline   
#line 135
uint16_t AggregateUseM$Agg$default$stateSize(uint8_t id, 
ParamList *params, ParamVals *paramValues);




static inline   
#line 140
bool AggregateUseM$Agg$default$hasData(uint8_t id, 
char *data, ParamList *params, ParamVals *paramValues);




static inline   
#line 145
TinyDBError AggregateUseM$Agg$default$finalize(uint8_t id, 
char *data, char *result_buf, ParamList *params, ParamVals *paramValues);
# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
#line 50
typedef struct ContourMapM$__nesc_unnamed4395 {
  uint8_t x;
  uint8_t y;
} ContourMapM$Vertex;






#line 58
typedef struct ContourMapM$__nesc_unnamed4396 {
  ContourMapM$Vertex vertices[2];
} ContourMapM$ContourRegionBoundary;







#line 64
typedef struct ContourMapM$__nesc_unnamed4397 {

  int8_t A[10];
  int8_t b[6];
} ContourMapM$RegressionModel;





#line 70
typedef struct ContourMapM$__nesc_unnamed4398 {
  ContourMapM$ContourRegionBoundary boundaries[1];
  ContourMapM$RegressionModel regression;
  uint8_t epsilon;
} ContourMapM$ContourRegion;







#line 79
typedef struct ContourMapM$__nesc_unnamed4399 {
  uint8_t regionNum;
  ContourMapM$ContourRegion regions[3];
} ContourMapM$ContourMap;



uint8_t ContourMapM$loc_x = 0;
#line 86
uint8_t ContourMapM$loc_y = 0;
uint8_t ContourMapM$x[3];
#line 87
uint8_t ContourMapM$y[3];
uint8_t ContourMapM$errorBound = 20;
#line 88
uint8_t ContourMapM$mergingLimit = 100;
ContourMapM$ContourMap *ContourMapM$mymap;

static inline void ContourMapM$initializeLocation(void);
#line 129
static void ContourMapM$constructRegressionModel(ContourMapM$RegressionModel *regression, int16_t *w);
#line 162
static inline bool ContourMapM$checkOverlapping(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2);
#line 190
static uint16_t ContourMapM$computeVol(ContourMapM$ContourRegion *region, int16_t *w);





static inline void ContourMapM$computeRegionEpsilon(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2, ContourMapM$ContourRegion *region);
#line 243
static bool ContourMapM$contourRegionMerging(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2);
#line 271
static inline  result_t ContourMapM$Aggregate$update(char *destdata, char *value, ParamList *params, ParamVals *paramValues);
#line 297
static inline  result_t ContourMapM$Aggregate$merge(char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues);
#line 322
static inline  result_t ContourMapM$Aggregate$init(char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime);
#line 363
static inline  uint16_t ContourMapM$Aggregate$stateSize(ParamList *params, ParamVals *paramValues);






static inline  bool ContourMapM$Aggregate$hasData(char *data, ParamList *params, ParamVals *paramValues);



static inline  TinyDBError ContourMapM$Aggregate$finalize(char *data, char *result_buf, ParamList *params, ParamVals *paramValues);
# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t Attr$Attr$getAttr(
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
uint8_t arg_0x2621e38, 
# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880);
#line 97
static  result_t Attr$Attr$startAttr(
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
uint8_t arg_0x2621e38);
# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
static  result_t Attr$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0);








static  result_t Attr$AttrUse$startAttrDone(uint8_t arg_0x2049670);
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
AttrDescs Attr$attrDescs;
bool Attr$addAttrPending;
uint32_t Attr$constAttrs[MAX_CONST_ATTRS];
#line 86
static  result_t Attr$Attr$registerAttr(uint8_t id, char *attrName, TOSType type, uint8_t attrLen);
#line 133
static  AttrDescPtr Attr$AttrUse$getAttr(char *name);
#line 149
static  AttrDescPtr Attr$AttrUse$getAttrById(uint8_t attrIdx);
#line 162
static inline  uint8_t Attr$AttrUse$numAttrs(void);




static inline  result_t Attr$AttrUse$getAttrValue(char *name, char *resultBuf, SchemaErrorNo *errorNo);
#line 185
static inline  result_t Attr$AttrUse$startAttr(uint8_t id);
#line 259
static inline  result_t Attr$Attr$getAttrDone(uint8_t id, char *name, char *resultBuf, SchemaErrorNo errorNo);





static inline  result_t Attr$Attr$startAttrDone(uint8_t id);





static inline   result_t Attr$Attr$default$getAttr(uint8_t id, char *name, char *resultBuf, SchemaErrorNo *errorNo);







static inline   result_t Attr$Attr$default$startAttr(uint8_t id);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t AttrGlobalM$NodeIdAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 101
static  result_t AttrGlobalM$NodeIdAttr$startAttrDone(void);
#line 68
static  result_t AttrGlobalM$GroupAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 101
static  result_t AttrGlobalM$GroupAttr$startAttrDone(void);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$StdControl$init(void);








static inline  result_t AttrGlobalM$StdControl$start(void);




static inline  result_t AttrGlobalM$StdControl$stop(void);




static inline  result_t AttrGlobalM$NodeIdAttr$startAttr(void);




static inline  result_t AttrGlobalM$NodeIdAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
#line 95
static inline  result_t AttrGlobalM$GroupAttr$startAttr(void);




static inline  result_t AttrGlobalM$GroupAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
# 90 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$StdControl$init(void);
#line 106
static inline  result_t TinyDBAttrM$StdControl$start(void);




static inline  result_t TinyDBAttrM$StdControl$stop(void);
#line 171
static inline  result_t TinyDBAttrM$MemAlloc$reallocComplete(Handle handle, result_t success);



static inline  result_t TinyDBAttrM$MemAlloc$compactComplete(void);



static inline  result_t TinyDBAttrM$MemAlloc$allocComplete(HandlePtr handle, result_t success);
#line 307
static inline  result_t TinyDBAttrM$QueryProcessor$queryComplete(ParsedQueryPtr q);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t AttrTimeM$TimeHighAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 101
static  result_t AttrTimeM$TimeHighAttr$startAttrDone(void);
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Time.nc"
static   uint32_t AttrTimeM$Time$getHigh32(void);


static   uint32_t AttrTimeM$Time$getLow32(void);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t AttrTimeM$TimeLowAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 101
static  result_t AttrTimeM$TimeLowAttr$startAttrDone(void);
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$StdControl$init(void);








static inline  result_t AttrTimeM$StdControl$start(void);




static inline  result_t AttrTimeM$StdControl$stop(void);




static inline  result_t AttrTimeM$TimeLowAttr$startAttr(void);




static inline  result_t AttrTimeM$TimeLowAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
#line 93
static inline  result_t AttrTimeM$TimeHighAttr$startAttr(void);




static inline  result_t AttrTimeM$TimeHighAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADCControl.nc"
static  result_t InternalTempM$ADCControl$bindPort(uint8_t arg_0x26d1a70, uint8_t arg_0x26d1be8);
#line 50
static  result_t InternalTempM$ADCControl$init(void);
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCSingle.nc"
static   result_t InternalTempM$ADCSingle$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
static  result_t InternalTempM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00);
# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCMultiple.nc"
static   uint16_t *InternalTempM$ADCMultiple$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0);
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
static   msp430ADCresult_t InternalTempM$MSP430ADC12Multiple$getData(uint16_t *arg_0x26c0068, uint16_t arg_0x26c01e8, uint16_t arg_0x26c0368);
#line 49
static  result_t InternalTempM$MSP430ADC12Multiple$bind(MSP430ADC12Settings_t arg_0x26c1980);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
 bool InternalTempM$contMode;

static inline  result_t InternalTempM$StdControl$init(void);




static  result_t InternalTempM$StdControl$start(void);










static inline  result_t InternalTempM$StdControl$stop(void);
#line 105
static inline   result_t InternalTempM$MSP430ADC12Single$dataReady(uint16_t data);




static inline    result_t InternalTempM$ADCSingle$default$dataReady(adcresult_t result, uint16_t data);
#line 159
static   uint16_t *InternalTempM$MSP430ADC12Multiple$dataReady(uint16_t *buf, uint16_t length);
#line 172
static inline    uint16_t *InternalTempM$ADCMultiple$default$dataReady(adcresult_t result, uint16_t *buf, uint16_t length);
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
static   msp430ADCresult_t ADCM$MSP430ADC12Single$getData(void);
#line 50
static  result_t ADCM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00);
#line 86
static   msp430ADCresult_t ADCM$MSP430ADC12Single$getDataRepeat(uint16_t arg_0x26ca958);
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
static   result_t ADCM$ADC$dataReady(
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
uint8_t arg_0x26f2da8, 
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
uint16_t arg_0x26a91b8);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
enum ADCM$__nesc_unnamed4400 {

  ADCM$TOSH_ADC_PORTMAPSIZE = 2U
};





 uint8_t ADCM$TOSH_adc_portmap[ADCM$TOSH_ADC_PORTMAPSIZE];
 uint8_t ADCM$samplingRate;
 bool ADCM$continuousData;
 uint8_t ADCM$owner;
bool ADCM$initialized;
volatile bool ADCM$busy;

static inline  result_t ADCM$StdControl$init(void);





static inline  result_t ADCM$StdControl$start(void);




static inline  result_t ADCM$StdControl$stop(void);






static inline  result_t ADCM$ADCControl$init(void);
#line 117
static inline  result_t ADCM$ADCControl$bindPort(uint8_t port, uint8_t adcPort);








static inline result_t ADCM$triggerConversion(uint8_t port);
#line 150
static   result_t ADCM$ADC$getData(uint8_t port);
#line 183
static inline    result_t ADCM$ADC$default$dataReady(uint8_t num, uint16_t d);

static   result_t ADCM$MSP430ADC12Single$dataReady(uint16_t d);
# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430ADC12M$CompareA1$setEvent(uint16_t arg_0x1615630);
# 118 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.nc"
static   RefVolt_t MSP430ADC12M$RefVolt$getState(void);
#line 109
static   result_t MSP430ADC12M$RefVolt$release(void);
#line 93
static   result_t MSP430ADC12M$RefVolt$get(RefVolt_t arg_0x2760d28);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
static   void MSP430ADC12M$ControlA0$setControl(MSP430CompareControl_t arg_0x1600560);
# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
static   result_t MSP430ADC12M$ADCSingle$dataReady(
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
uint8_t arg_0x27269f8, 
# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
uint16_t arg_0x26c5100);
# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
static   void MSP430ADC12M$TimerA$clear(void);

static   void MSP430ADC12M$TimerA$setClockSource(uint16_t arg_0x15f4db0);
#line 38
static   void MSP430ADC12M$TimerA$disableEvents(void);
#line 35
static   void MSP430ADC12M$TimerA$setMode(int arg_0x15f4010);




static   void MSP430ADC12M$TimerA$setInputDivider(uint16_t arg_0x15f2260);
# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
static   uint16_t *MSP430ADC12M$ADCMultiple$dataReady(
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
uint8_t arg_0x27254c8, 
# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
uint16_t *arg_0x2712288, uint16_t arg_0x2712408);
# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
static   void MSP430ADC12M$ControlA1$setControl(MSP430CompareControl_t arg_0x1600560);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
static   void MSP430ADC12M$HPLADC12$resetIFGs(void);
#line 43
static   void MSP430ADC12M$HPLADC12$setControl1(adc12ctl1_t arg_0x2776e10);
#line 80
static   void MSP430ADC12M$HPLADC12$disableConversion(void);
#line 48
static   void MSP430ADC12M$HPLADC12$setControl0_IgnoreRef(adc12ctl0_t arg_0x2774988);


static   adc12memctl_t MSP430ADC12M$HPLADC12$getMemControl(uint8_t arg_0x27734b0);
#line 81
static   void MSP430ADC12M$HPLADC12$startConversion(void);
#line 52
static   uint16_t MSP430ADC12M$HPLADC12$getMem(uint8_t arg_0x2773940);


static   void MSP430ADC12M$HPLADC12$setIEFlags(uint16_t arg_0x2773dd0);
#line 69
static   void MSP430ADC12M$HPLADC12$setSHT(uint8_t arg_0x2770e68);
#line 50
static   void MSP430ADC12M$HPLADC12$setMemControl(uint8_t arg_0x2774e10, adc12memctl_t arg_0x2773010);
#line 82
static   void MSP430ADC12M$HPLADC12$stopConversion(void);
# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
static   void MSP430ADC12M$CompareA0$setEvent(uint16_t arg_0x1615630);
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
 uint8_t MSP430ADC12M$cmode;
 uint16_t *MSP430ADC12M$bufPtr;
 uint16_t MSP430ADC12M$bufLength;
 uint16_t MSP430ADC12M$bufOffset;
 uint8_t MSP430ADC12M$owner;
 uint8_t MSP430ADC12M$reserved;
 uint8_t MSP430ADC12M$vrefWait;
 adc12settings_t MSP430ADC12M$adc12settings[5U];

static  result_t MSP430ADC12M$StdControl$init(void);









static inline  result_t MSP430ADC12M$StdControl$start(void);




static inline  result_t MSP430ADC12M$StdControl$stop(void);






static inline void MSP430ADC12M$configureAdcPin(uint8_t inputChannel);







static  result_t MSP430ADC12M$ADCSingle$bind(uint8_t num, MSP430ADC12Settings_t settings);
#line 125
static inline  result_t MSP430ADC12M$ADCMultiple$bind(uint8_t num, MSP430ADC12Settings_t settings);




static inline msp430ADCresult_t MSP430ADC12M$getRefVolt(uint8_t num);
#line 158
static inline result_t MSP430ADC12M$releaseRefVolt(uint8_t num);









static void MSP430ADC12M$prepareTimerA(uint16_t interval, uint16_t csSAMPCON, uint16_t cdSAMPCON);
#line 184
static void MSP430ADC12M$startTimerA(void);
#line 203
static msp430ADCresult_t MSP430ADC12M$newRequest(uint8_t req, uint8_t num, void *dataDest, uint16_t length, uint16_t jiffies);
#line 340
static inline   msp430ADCresult_t MSP430ADC12M$ADCSingle$getData(uint8_t num);




static inline   msp430ADCresult_t MSP430ADC12M$ADCSingle$getDataRepeat(uint8_t num, uint16_t jiffies);
#line 370
static inline   msp430ADCresult_t MSP430ADC12M$ADCMultiple$getData(uint8_t num, uint16_t *buf, 
uint16_t length, uint16_t jiffies);
#line 405
static inline   void MSP430ADC12M$TimerA$overflow(void);
static inline   void MSP430ADC12M$CompareA0$fired(void);
static inline   void MSP430ADC12M$CompareA1$fired(void);

static inline    result_t MSP430ADC12M$ADCSingle$default$dataReady(uint8_t num, uint16_t data);



static inline    uint16_t *MSP430ADC12M$ADCMultiple$default$dataReady(uint8_t num, uint16_t *buf, 
uint16_t length);




static  void MSP430ADC12M$RefVolt$isStable(RefVolt_t vref);










static void MSP430ADC12M$stopConversion(void);










static inline   void MSP430ADC12M$HPLADC12$converted(uint8_t number);
#line 496
static inline   void MSP430ADC12M$HPLADC12$memOverflow(void);
static inline   void MSP430ADC12M$HPLADC12$timeOverflow(void);
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
static   void HPLADC12M$HPLADC12$memOverflow(void);

static   void HPLADC12M$HPLADC12$converted(uint8_t arg_0x2770250);
#line 62
static   void HPLADC12M$HPLADC12$timeOverflow(void);
# 44 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
 static volatile uint16_t HPLADC12M$ADC12CTL0 __asm ("0x01A0");
 static volatile uint16_t HPLADC12M$ADC12CTL1 __asm ("0x01A2");
 static volatile uint16_t HPLADC12M$ADC12IFG __asm ("0x01A4");
 static volatile uint16_t HPLADC12M$ADC12IE __asm ("0x01A6");
 static volatile uint16_t HPLADC12M$ADC12IV __asm ("0x01A8");





static inline   void HPLADC12M$HPLADC12$setControl1(adc12ctl1_t control1);



static inline   void HPLADC12M$HPLADC12$setControl0_IgnoreRef(adc12ctl0_t control0);
#line 73
static   void HPLADC12M$HPLADC12$setMemControl(uint8_t i, adc12memctl_t memControl);







static inline   adc12memctl_t HPLADC12M$HPLADC12$getMemControl(uint8_t i);









static inline   uint16_t HPLADC12M$HPLADC12$getMem(uint8_t i);



static inline   void HPLADC12M$HPLADC12$setIEFlags(uint16_t mask);


static   void HPLADC12M$HPLADC12$resetIFGs(void);
#line 112
static inline   bool HPLADC12M$HPLADC12$isBusy(void);


static inline   void HPLADC12M$HPLADC12$disableConversion(void);
static inline   void HPLADC12M$HPLADC12$startConversion(void);
static inline   void HPLADC12M$HPLADC12$stopConversion(void);
#line 137
static inline   void HPLADC12M$HPLADC12$setRefOn(void);
static inline   void HPLADC12M$HPLADC12$setRefOff(void);

static inline   void HPLADC12M$HPLADC12$setRef1_5V(void);
static inline   void HPLADC12M$HPLADC12$setRef2_5V(void);


static inline   void HPLADC12M$HPLADC12$setSHT(uint8_t sht);
#line 163
void  __attribute((wakeup)) __attribute((interrupt(14))) sig_ADC_VECTOR(void);
# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
static  result_t RefVoltM$SwitchOffTimer$setOneShot(int32_t arg_0x1e4fe38);
# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.nc"
static  void RefVoltM$RefVolt$isStable(RefVolt_t arg_0x2763518);
# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
static   void RefVoltM$HPLADC12$setRefOff(void);
#line 65
static   bool RefVoltM$HPLADC12$isBusy(void);










static   void RefVoltM$HPLADC12$setRef2_5V(void);



static   void RefVoltM$HPLADC12$disableConversion(void);
#line 72
static   void RefVoltM$HPLADC12$setRefOn(void);


static   void RefVoltM$HPLADC12$setRef1_5V(void);
# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
static  result_t RefVoltM$SwitchOnTimer$setOneShot(int32_t arg_0x1e4fe38);
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
enum RefVoltM$__nesc_unnamed4401 {

  RefVoltM$REFERENCE_OFF, 
  RefVoltM$REFERENCE_1_5V_PENDING, 
  RefVoltM$REFERENCE_2_5V_PENDING, 
  RefVoltM$REFERENCE_1_5V_STABLE, 
  RefVoltM$REFERENCE_2_5V_STABLE
};

 uint8_t RefVoltM$semaCount;
 uint8_t RefVoltM$state;
 bool RefVoltM$switchOff;

static __inline void RefVoltM$switchRefOn(uint8_t vref);
static __inline void RefVoltM$switchRefOff(void);
static __inline void RefVoltM$switchToRefStable(uint8_t vref);
static __inline void RefVoltM$switchToRefPending(uint8_t vref);

static inline  void RefVoltM$switchOnDelay(void);
static inline  void RefVoltM$switchOffDelay(void);
static inline  void RefVoltM$switchOffRetry(void);

static   result_t RefVoltM$RefVolt$get(RefVolt_t vref);
#line 140
static __inline void RefVoltM$switchRefOn(uint8_t vref);
#line 154
static __inline void RefVoltM$switchToRefPending(uint8_t vref);



static __inline void RefVoltM$switchToRefStable(uint8_t vref);



static inline  void RefVoltM$switchOnDelay(void);



static inline  result_t RefVoltM$SwitchOnTimer$fired(void);
#line 180
static inline   result_t RefVoltM$RefVolt$release(void);
#line 205
static __inline void RefVoltM$switchRefOff(void);
#line 225
static inline  void RefVoltM$switchOffDelay(void);




static inline  void RefVoltM$switchOffRetry(void);




static inline  result_t RefVoltM$SwitchOffTimer$fired(void);




static inline   RefVolt_t RefVoltM$RefVolt$getState(void);







static inline   void RefVoltM$HPLADC12$memOverflow(void);
static inline   void RefVoltM$HPLADC12$timeOverflow(void);
static inline   void RefVoltM$HPLADC12$converted(uint8_t number);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t AttrTempM$AttrRegister$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 92
static  result_t AttrTempM$AttrRegister$getAttrDone(char *arg_0x2618638, char *arg_0x26187d0, SchemaErrorNo arg_0x2618950);








static  result_t AttrTempM$AttrRegister$startAttrDone(void);
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t AttrTempM$SubControl$init(void);






static  result_t AttrTempM$SubControl$start(void);







static  result_t AttrTempM$SubControl$stop(void);
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
static   result_t AttrTempM$ADC$getData(void);
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
char *AttrTempM$result;
char *AttrTempM$attrName;
static  void AttrTempM$getAttrDone(void);

static inline  result_t AttrTempM$StdControl$init(void);







static inline  result_t AttrTempM$StdControl$start(void);





static inline  result_t AttrTempM$StdControl$stop(void);





static inline  result_t AttrTempM$AttrRegister$startAttr(void);




static inline  result_t AttrTempM$AttrRegister$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
#line 132
static inline   result_t AttrTempM$ADC$dataReady(uint16_t data);






static  void AttrTempM$getAttrDone(void);
# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADCControl.nc"
static  result_t InternalVoltageM$ADCControl$bindPort(uint8_t arg_0x26d1a70, uint8_t arg_0x26d1be8);
#line 50
static  result_t InternalVoltageM$ADCControl$init(void);
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCSingle.nc"
static   result_t InternalVoltageM$ADCSingle$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20);
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
static  result_t InternalVoltageM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00);
# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCMultiple.nc"
static   uint16_t *InternalVoltageM$ADCMultiple$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0);
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
static   msp430ADCresult_t InternalVoltageM$MSP430ADC12Multiple$getData(uint16_t *arg_0x26c0068, uint16_t arg_0x26c01e8, uint16_t arg_0x26c0368);
#line 49
static  result_t InternalVoltageM$MSP430ADC12Multiple$bind(MSP430ADC12Settings_t arg_0x26c1980);
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
 bool InternalVoltageM$contMode;

static inline  result_t InternalVoltageM$StdControl$init(void);




static inline  result_t InternalVoltageM$StdControl$start(void);










static inline  result_t InternalVoltageM$StdControl$stop(void);
#line 105
static inline   result_t InternalVoltageM$MSP430ADC12Single$dataReady(uint16_t data);





static inline    result_t InternalVoltageM$ADCSingle$default$dataReady(adcresult_t result, uint16_t data);
#line 159
static   uint16_t *InternalVoltageM$MSP430ADC12Multiple$dataReady(uint16_t *buf, uint16_t length);
#line 172
static inline    uint16_t *InternalVoltageM$ADCMultiple$default$dataReady(adcresult_t result, uint16_t *buf, uint16_t length);
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
static  result_t AttrVoltageM$AttrRegister$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18);
#line 92
static  result_t AttrVoltageM$AttrRegister$getAttrDone(char *arg_0x2618638, char *arg_0x26187d0, SchemaErrorNo arg_0x2618950);








static  result_t AttrVoltageM$AttrRegister$startAttrDone(void);
# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
static   result_t AttrVoltageM$ADC$getData(void);
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
char *AttrVoltageM$result;
char *AttrVoltageM$attrName;
static inline  void AttrVoltageM$getDoneTask(void);

static inline  result_t AttrVoltageM$StdControl$init(void);
#line 110
static inline  result_t AttrVoltageM$StdControl$start(void);





static inline  result_t AttrVoltageM$StdControl$stop(void);




static inline  result_t AttrVoltageM$AttrRegister$startAttr(void);




static inline  result_t AttrVoltageM$AttrRegister$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo);
#line 148
static inline   result_t AttrVoltageM$ADC$dataReady(uint16_t data);










static inline  void AttrVoltageM$getDoneTask(void);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
static  result_t DBBufferC$TupleIntf$setFieldNoQuery(TuplePtr arg_0x2042808, 
uint8_t arg_0x2042998, 
uint8_t arg_0x2042b28, 
uint8_t arg_0x2042cd0[], 
uint8_t arg_0x2042e78[], 
CharPtr arg_0x2041030);
#line 98
static  CharPtr DBBufferC$TupleIntf$getFieldPtrNoQuery(TuplePtr arg_0x2040100, 
uint8_t arg_0x2040290, 
uint8_t arg_0x2040420, 
uint8_t arg_0x20405c8[], 
uint8_t arg_0x2040770[]);
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
static  AttrDescPtr DBBufferC$AttrUse$getAttrById(uint8_t arg_0x204da90);




static  uint8_t DBBufferC$AttrUse$numAttrs(void);
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/RadioQueue.nc"
static  TinyDBError DBBufferC$RadioQueue$enqueue(const QueryResultPtr arg_0x20e4678, bool *arg_0x20e4810);
# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
static  short DBBufferC$ParsedQueryIntf$pqSize(ParsedQueryPtr arg_0x2068828);
#line 92
static  TinyDBError DBBufferC$ParsedQueryIntf$getResultField(ParsedQueryPtr arg_0x2067498, QueryResultPtr arg_0x2067618, uint8_t arg_0x2067798, char *arg_0x2067930);








static  TinyDBError DBBufferC$ParsedQueryIntf$getResultId(ParsedQueryPtr arg_0x20650b0, Field *arg_0x2065248, uint8_t *arg_0x20653e0);
# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
static  result_t DBBufferC$MemAlloc$unlock(Handle arg_0x2084898);
#line 84
static  result_t DBBufferC$MemAlloc$lock(Handle arg_0x2084328);
#line 61
static  result_t DBBufferC$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638);
#line 104
static  int16_t DBBufferC$MemAlloc$free(Handle arg_0x2084dd8);
# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
static  TinyDBError DBBufferC$QueryResultIntf$toBytes(QueryResultPtr arg_0x208e200, ParsedQueryPtr arg_0x208e380, CharPtr arg_0x208e4f8);
#line 137
static  ResultTuple DBBufferC$QueryResultIntf$getResultTuple(QueryResultPtr arg_0x208c670, short arg_0x208c7e0, ParsedQueryPtr arg_0x208c960);
#line 131
static  short DBBufferC$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0);
#line 124
static  TinyDBError DBBufferC$QueryResultIntf$fromResultTuple(ResultTuple arg_0x208d398, QueryResultPtr arg_0x208d518, ParsedQueryPtr arg_0x208d698);
# 193 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
static  result_t DBBufferC$DBBuffer$putComplete(uint8_t arg_0x20cdb10, QueryResult *arg_0x20cdcb0, TinyDBError arg_0x20cde30);
#line 190
static  result_t DBBufferC$DBBuffer$getComplete(uint8_t arg_0x20cd338, QueryResult *arg_0x20cd4d8, TinyDBError arg_0x20cd658);
#line 187
static  result_t DBBufferC$DBBuffer$allocComplete(uint8_t arg_0x20cecd0, TinyDBError arg_0x20cee50);
# 161 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
enum DBBufferC$__nesc_unnamed4402 {
  DBBufferC$kNUM_BUFS = 2, 
  DBBufferC$kATTR_BUF = DBBufferC$kNUM_BUFS + 1, 
  DBBufferC$kCOMMAND_BUF = DBBufferC$kATTR_BUF + 1, 
  DBBufferC$kEVENT_BUF = DBBufferC$kCOMMAND_BUF + 1, 
  DBBufferC$kQUERY_BUF = DBBufferC$kEVENT_BUF + 1
};
#line 206
#line 169
typedef enum DBBufferC$__nesc_unnamed4403 {
  DBBufferC$kIDLE, 
  DBBufferC$kALLOC_SCHEMA, 
  DBBufferC$kALLOC_BUFFER, 
  DBBufferC$kALLOC_ROW, 
  DBBufferC$kALLOC_NAME, 
  DBBufferC$kREAD_ROW, 


  DBBufferC$kREADING_LENGTH, 
  DBBufferC$kALLOC_FOR_READ, 
  DBBufferC$kREADING_DATA, 
  DBBufferC$kWRITE_BUFFER, 
  DBBufferC$kHEADER_READ, 
  DBBufferC$kWRITE_FILE_COUNT, 
  DBBufferC$kREAD_FILE_COUNT, 
  DBBufferC$kREAD_OPEN, 
  DBBufferC$kREAD_LENGTHS, 
  DBBufferC$kSKIP_BYTES, 
  DBBufferC$kREAD_NAME, 
  DBBufferC$kREAD_FIELD_LEN, 
  DBBufferC$kALLOC_FIELD_DATA, 
  DBBufferC$kREAD_FIELD_DATA, 
  DBBufferC$kALLOC_QUERY, 
  DBBufferC$kREAD_QUERY, 
  DBBufferC$kREAD_BUFFER, 
  DBBufferC$kWRITING_LENGTHS, 
  DBBufferC$kWRITING_NAME, 
  DBBufferC$kWRITING_QUERY, 
  DBBufferC$kWRITING_BUFFER, 
  DBBufferC$kWRITE_FIELD_LEN, 
  DBBufferC$kWRITE_FIELD_DATA, 
  DBBufferC$kWRITE_NEXT_BUFFER, 
  DBBufferC$kNOT_READY, 
  DBBufferC$kOPEN_BUFFER, 
  DBBufferC$kRADIO_ENQUEUE, 
  DBBufferC$kCLEANUP
} DBBufferC$AllocState;
#line 231
#line 209
typedef struct DBBufferC$__nesc_unnamed4404 {
  BufferType type;
  BufferPolicy policy;
  ParsedQuery **qh;
  uint16_t numRows;
  uint16_t nextFree;
  uint16_t nextFull;

  uint16_t len;
  uint16_t rowSize;

  long data;

  char **name;

  union DBBufferC$__nesc_unnamed4405 {
    char **bufdata;
  } 



  u;
} DBBufferC$Buffer;

DBBufferC$Buffer DBBufferC$mBuffers[DBBufferC$kNUM_BUFS];
long DBBufferC$mUsedBufs;
uint8_t DBBufferC$mCurBuffer;
uint16_t DBBufferC$mCurRow;





Handle DBBufferC$mCurRowHandle;

QueryResultPtr DBBufferC$mCurResult;
ParsedQuery *DBBufferC$mAllocSchema;
#line 245
ParsedQuery *DBBufferC$mCurQuery;
uint8_t DBBufferC$mCurResultIdx;
DBBufferC$AllocState DBBufferC$mState;

char *DBBufferC$mNamePtr;
#line 266
enum DBBufferC$__nesc_unnamed4406 {
#line 266
  DBBufferC$NUM_ATTR_FIELDS = 1
};
#line 267
uint8_t DBBufferC$ATTR_TYPES[DBBufferC$NUM_ATTR_FIELDS];
uint8_t DBBufferC$ATTR_SIZES[DBBufferC$NUM_ATTR_FIELDS];
char DBBufferC$ATTR_NAMES[DBBufferC$NUM_ATTR_FIELDS][STRING_SIZE];



static TinyDBError DBBufferC$getBuf(uint8_t bufId, DBBufferC$Buffer **buf);
static void DBBufferC$cleanupBuffer(int i, int lineno);
static inline void DBBufferC$initCatalog(void);

static TinyDBError DBBufferC$getSpecialBufferId(BufferType type, uint8_t *bufferId);
static TinyDBError DBBufferC$continueRadioBufferEnqueue(void);
#line 320
static inline  result_t DBBufferC$StdControl$init(void);
#line 341
static inline  result_t DBBufferC$StdControl$start(void);
#line 394
static inline  result_t DBBufferC$StdControl$stop(void);




static inline void DBBufferC$initCatalog(void);
#line 464
static  TinyDBError DBBufferC$DBBuffer$enqueue(uint8_t bufferId, QueryResultPtr r, bool *pending, ParsedQuery *pq);
#line 634
static TinyDBError DBBufferC$continueRadioBufferEnqueue(void);
#line 721
static inline  TinyDBError DBBufferC$DBBuffer$peek(uint8_t bufferId, QueryResult *qr, bool *pending);
#line 900
static inline  TinyDBError DBBufferC$DBBuffer$getResult(uint8_t bufferId, uint16_t idx, QueryResult *qr, bool *pending);
#line 984
static  TinyDBError DBBufferC$DBBuffer$size(uint8_t bufferId, uint16_t *size);
#line 1118
static  ParsedQuery **DBBufferC$DBBuffer$getSchema(uint8_t bufferId);









static inline  TinyDBError DBBufferC$DBBuffer$getFieldId(uint8_t bufferId, FieldPtr f, uint8_t *id);
#line 1155
static inline  TinyDBError DBBufferC$DBBuffer$getField(uint8_t bufferId, QueryResult *qr, uint8_t idx, char *resultBuf);
#line 1239
static  TinyDBError DBBufferC$DBBuffer$getBufferId(uint8_t bufIdx, bool special, uint8_t *bufferId);
#line 1264
static inline  uint8_t DBBufferC$CatalogTable$catalogFieldSize(uint8_t bufIdx, uint8_t fieldNo);
#line 2191
static  result_t DBBufferC$MemAlloc$allocComplete(HandlePtr handle, result_t success);
#line 2370
static inline  result_t DBBufferC$MemAlloc$compactComplete(void);



static  result_t DBBufferC$MemAlloc$reallocComplete(Handle handle, result_t success);








static inline  result_t DBBufferC$QueryProcessor$queryComplete(ParsedQueryPtr q);
#line 2430
static inline  result_t DBBufferC$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo);



static inline  result_t DBBufferC$AttrUse$startAttrDone(uint8_t id);
#line 2543
static inline  bool DBBufferC$RadioQueue$enqueueDone(void);
#line 2593
static TinyDBError DBBufferC$getBuf(uint8_t bufId, DBBufferC$Buffer **buf);
#line 2607
static void DBBufferC$cleanupBuffer(int b, int lineNo);
#line 2668
static TinyDBError DBBufferC$getSpecialBufferId(BufferType type, uint8_t *bufferId);
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
static  result_t ServiceSchedulerM$AbsoluteTimer$cancel(void);
#line 50
static  result_t ServiceSchedulerM$AbsoluteTimer$set(tos_time_t arg_0x20b7920);
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
static   tos_time_t ServiceSchedulerM$TimeUtil$addUint32(tos_time_t arg_0x20b1bd8, uint32_t arg_0x20b1d58);
#line 82
static   char ServiceSchedulerM$TimeUtil$compare(tos_time_t arg_0x20b0aa0, tos_time_t arg_0x20b0c20);
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t ServiceSchedulerM$Services$start(
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
uint8_t arg_0x2903420);
# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t ServiceSchedulerM$Services$stop(
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
uint8_t arg_0x2903420);









enum ServiceSchedulerM$__nesc_unnamed4407 {
  ServiceSchedulerM$MAX_SERVICES = 2
};






#line 61
struct ServiceSchedulerM$__nesc_unnamed4408 {
  char (*compare)(pq_element e1, pq_element e2);
  uint8_t size;
  uint8_t n_elements;
  pq_element heap[10];
} ServiceSchedulerM$event_q;

int32_t ServiceSchedulerM$extraSleep;








tos_service_schedule ServiceSchedulerM$sched_info[ServiceSchedulerM$MAX_SERVICES];

static inline char ServiceSchedulerM$compare_elts(pq_element i, pq_element j);








static  result_t ServiceSchedulerM$AbsoluteTimer$fired(void);
#line 139
static inline   result_t ServiceSchedulerM$Services$default$start(uint8_t id);



static inline   result_t ServiceSchedulerM$Services$default$stop(uint8_t id);









static inline  result_t ServiceSchedulerM$SchedulerClt$init(void);
#line 170
static inline  result_t ServiceSchedulerM$SchedulerClt$start(void);
#line 182
static inline  result_t ServiceSchedulerM$SchedulerClt$stop(void);






static inline  result_t ServiceSchedulerM$ServiceScheduler$reschedule(uint8_t svc_id, 
tos_service_schedule sched);
#line 232
static inline  tos_time_t ServiceSchedulerM$ServiceScheduler$getNextEventTime(uint8_t svc_id);





static inline  result_t ServiceSchedulerM$ServiceScheduler$setExtraSleepTime(uint8_t svc_id, int32_t extraTime);
#line 267
static inline  result_t ServiceSchedulerM$ServiceScheduler$remove(uint8_t svc_id);
# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static inline void MSP430ClockM$startTimerB(void)
{

  MSP430ClockM$TBCTL = 0x0020 | (MSP430ClockM$TBCTL & ~(0x0020 | 0x0010));
}

#line 115
static inline void MSP430ClockM$startTimerA(void)
{

  MSP430ClockM$TA0CTL = 0x0020 | (MSP430ClockM$TA0CTL & ~(0x0020 | 0x0010));
}

#line 220
static inline  result_t MSP430ClockM$StdControl$start(void)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      MSP430ClockM$startTimerA();
      MSP430ClockM$startTimerB();
    }
#line 226
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t HPLInitM$MSP430ClockControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = MSP430ClockM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static inline  void MSP430ClockM$MSP430ClockInit$defaultInitTimerB(void)
{
  TBR = 0;









  MSP430ClockM$TBCTL = 0x0100 | 0x0002;
}











static inline   void MSP430ClockM$MSP430ClockInit$default$initTimerB(void)
{
  MSP430ClockM$MSP430ClockInit$defaultInitTimerB();
}

# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockInit.nc"
inline static  void MSP430ClockM$MSP430ClockInit$initTimerB(void){
#line 29
  MSP430ClockM$MSP430ClockInit$default$initTimerB();
#line 29
}
#line 29
# 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static inline  void MSP430ClockM$MSP430ClockInit$defaultInitTimerA(void)
{
  TA0R = 0;









  MSP430ClockM$TA0CTL = 0x0200 | 0x0002;
}

#line 104
static inline   void MSP430ClockM$MSP430ClockInit$default$initTimerA(void)
{
  MSP430ClockM$MSP430ClockInit$defaultInitTimerA();
}

# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockInit.nc"
inline static  void MSP430ClockM$MSP430ClockInit$initTimerA(void){
#line 28
  MSP430ClockM$MSP430ClockInit$default$initTimerA();
#line 28
}
#line 28
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static inline  void MSP430ClockM$MSP430ClockInit$defaultInitClocks(void)
{





  BCSCTL1 = 0x80 | (BCSCTL1 & ((0x04 | 0x02) | 0x01));







  BCSCTL2 = 0x04;


  MSP430ClockM$IE1 &= ~(1 << 1);
}

#line 99
static inline   void MSP430ClockM$MSP430ClockInit$default$initClocks(void)
{
  MSP430ClockM$MSP430ClockInit$defaultInitClocks();
}

# 27 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockInit.nc"
inline static  void MSP430ClockM$MSP430ClockInit$initClocks(void){
#line 27
  MSP430ClockM$MSP430ClockInit$default$initClocks();
#line 27
}
#line 27
# 145 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static inline uint16_t MSP430ClockM$test_calib_busywait_delta(int calib)
{
  int8_t aclk_count = 2;
  uint16_t dco_prev = 0;
  uint16_t dco_curr = 0;

  MSP430ClockM$set_dco_calib(calib);

  while (aclk_count-- > 0) 
    {
      TBCCR0 = TBR + MSP430ClockM$ACLK_CALIB_PERIOD;
      TBCCTL0 &= ~0x0001;
      while ((TBCCTL0 & 0x0001) == 0) ;
      dco_prev = dco_curr;
      dco_curr = TA0R;
    }

  return dco_curr - dco_prev;
}




static inline void MSP430ClockM$busyCalibrateDCO(void)
{

  int calib;
  int step;



  MSP430ClockM$TA0CTL = 0x0200 | 0x0020;
  MSP430ClockM$TBCTL = 0x0100 | 0x0020;
  BCSCTL1 = 0x80 | 0x04;
  BCSCTL2 = 0;
  TBCCTL0 = 0x4000;






  for (calib = 0, step = 0x800; step != 0; step >>= 1) 
    {

      if (MSP430ClockM$test_calib_busywait_delta(calib | step) <= MSP430ClockM$TARGET_DCO_DELTA) {
        calib |= step;
        }
    }

  if ((calib & 0x0e0) == 0x0e0) {
    calib &= ~0x01f;
    }
  MSP430ClockM$set_dco_calib(calib);
}

static inline  result_t MSP430ClockM$StdControl$init(void)
{

  MSP430ClockM$TA0CTL = 0x0004;
  MSP430ClockM$TA0IV = 0;
  MSP430ClockM$TBCTL = 0x0004;
  MSP430ClockM$TBIV = 0;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      MSP430ClockM$busyCalibrateDCO();
      MSP430ClockM$MSP430ClockInit$initClocks();
      MSP430ClockM$MSP430ClockInit$initTimerA();
      MSP430ClockM$MSP430ClockInit$initTimerB();
    }
#line 215
    __nesc_atomic_end(__nesc_atomic); }

  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t HPLInitM$MSP430ClockControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = MSP430ClockM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_CLR_FLASH_HOLD_PIN(void)
#line 72
{
#line 72
   static volatile uint8_t r __asm ("0x001D");

#line 72
  r &= ~(1 << 7);
}

#line 36
static inline void TOSH_MAKE_UCLK0_INPUT(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x001A");

#line 36
  r &= ~(1 << 3);
}

#line 35
static inline void TOSH_MAKE_SIMO0_INPUT(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x001A");

#line 35
  r &= ~(1 << 1);
}

#line 35
static inline void TOSH_SET_SIMO0_PIN(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x0019");

#line 35
  r |= 1 << 1;
}

#line 71
static inline void TOSH_SET_FLASH_CS_PIN(void)
#line 71
{
#line 71
   static volatile uint8_t r __asm ("0x001D");

#line 71
  r |= 1 << 4;
}

#line 36
static inline void TOSH_CLR_UCLK0_PIN(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x0019");

#line 36
  r &= ~(1 << 3);
}

#line 36
static inline void TOSH_SET_UCLK0_PIN(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x0019");

#line 36
  r |= 1 << 3;
}

#line 35
static inline void TOSH_CLR_SIMO0_PIN(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x0019");

#line 35
  r &= ~(1 << 1);
}

#line 83
static inline void TOSH_FLASH_M25P_DP_bit(bool set)
#line 83
{
  if (set) {
    TOSH_SET_SIMO0_PIN();
    }
  else {
#line 87
    TOSH_CLR_SIMO0_PIN();
    }
#line 88
  TOSH_SET_UCLK0_PIN();
  TOSH_CLR_UCLK0_PIN();
}

#line 71
static inline void TOSH_CLR_FLASH_CS_PIN(void)
#line 71
{
#line 71
   static volatile uint8_t r __asm ("0x001D");

#line 71
  r &= ~(1 << 4);
}

# 161 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430hardware.h"
static __inline void TOSH_wait(void )
{
   __asm volatile ("nop"); __asm volatile ("nop");}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SET_FLASH_HOLD_PIN(void)
#line 72
{
#line 72
   static volatile uint8_t r __asm ("0x001D");

#line 72
  r |= 1 << 7;
}

#line 71
static inline void TOSH_MAKE_FLASH_CS_OUTPUT(void)
#line 71
{
#line 71
   static volatile uint8_t r __asm ("0x001E");

#line 71
  r |= 1 << 4;
}

#line 72
static inline void TOSH_MAKE_FLASH_HOLD_OUTPUT(void)
#line 72
{
#line 72
   static volatile uint8_t r __asm ("0x001E");

#line 72
  r |= 1 << 7;
}

#line 36
static inline void TOSH_MAKE_UCLK0_OUTPUT(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x001A");

#line 36
  r |= 1 << 3;
}

#line 35
static inline void TOSH_MAKE_SIMO0_OUTPUT(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x001A");

#line 35
  r |= 1 << 1;
}

#line 94
static inline void TOSH_FLASH_M25P_DP(void)
#line 94
{

  TOSH_MAKE_SIMO0_OUTPUT();
  TOSH_MAKE_UCLK0_OUTPUT();
  TOSH_MAKE_FLASH_HOLD_OUTPUT();
  TOSH_MAKE_FLASH_CS_OUTPUT();
  TOSH_SET_FLASH_HOLD_PIN();
  TOSH_SET_FLASH_CS_PIN();

  TOSH_wait();


  TOSH_CLR_FLASH_CS_PIN();
  TOSH_CLR_UCLK0_PIN();

  TOSH_FLASH_M25P_DP_bit(TRUE);
  TOSH_FLASH_M25P_DP_bit(FALSE);
  TOSH_FLASH_M25P_DP_bit(TRUE);
  TOSH_FLASH_M25P_DP_bit(TRUE);
  TOSH_FLASH_M25P_DP_bit(TRUE);
  TOSH_FLASH_M25P_DP_bit(FALSE);
  TOSH_FLASH_M25P_DP_bit(FALSE);
  TOSH_FLASH_M25P_DP_bit(TRUE);

  TOSH_SET_FLASH_CS_PIN();

  TOSH_SET_SIMO0_PIN();
  TOSH_MAKE_SIMO0_INPUT();
  TOSH_MAKE_UCLK0_INPUT();
  TOSH_CLR_FLASH_HOLD_PIN();
}

# 174 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430hardware.h"
static __inline void TOSH_uwait(uint16_t u)
{
  uint16_t i;

#line 177
  if (u < 500) {
    for (i = 2; i < u; i++) {
         __asm volatile ("nop\n\t"
        "nop\n\t"
        "nop\n\t"
        "nop\n\t");}
    }
  else {

    for (i = 0; i < u; i++) {
         __asm volatile ("nop\n\t"
        "nop\n\t"
        "nop\n\t"
        "nop\n\t");}
    }
}

# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SET_PIN_DIRECTIONS(void )
{

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      P1SEL = 0;
      P2SEL = 0;
      P3SEL = 0;
      P4SEL = 0;
      P5SEL = 0;
      P6SEL = 0;

      P1DIR = 0xe0;
      P1OUT = 0x00;

      P2DIR = 0x7b;
      P2OUT = 0x10;

      P3DIR = 0xf1;
      P3OUT = 0x00;

      P4DIR = 0xfd;
      P4OUT = 0xdd;

      P5DIR = 0xff;
      P5OUT = 0xff;

      P6DIR = 0xff;
      P6OUT = 0x00;

      P1IE = 0;
      P2IE = 0;






      TOSH_uwait(1024 * 10);

      TOSH_FLASH_M25P_DP();
    }
#line 170
    __nesc_atomic_end(__nesc_atomic); }
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLInitM.nc"
static inline  result_t HPLInitM$init(void)
{
  TOSH_SET_PIN_DIRECTIONS();
  HPLInitM$MSP430ClockControl$init();
  HPLInitM$MSP430ClockControl$start();
  return SUCCESS;
}

# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MainM.nc"
inline static  result_t MainM$hardwareInit(void){
#line 47
  unsigned char result;
#line 47

#line 47
  result = HPLInitM$init();
#line 47

#line 47
  return result;
#line 47
}
#line 47
# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"
static inline void TOSH_sched_init(void )
{
  int i;

#line 82
  TOSH_sched_free = 0;
  TOSH_sched_full = 0;
  for (i = 0; i < TOSH_MAX_TASKS; i++) 
    TOSH_queue[i].tp = NULL;
}

# 120 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static inline result_t rcombine(result_t r1, result_t r2)



{
  return r1 == FAIL ? FAIL : r2;
}

# 158 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline  result_t TinyAlloc$StdControl$init(void)
#line 158
{
  int16_t i;

#line 160
  TinyAlloc$mAllocing = 0;
  TinyAlloc$mReallocing = 0;
  for (i = 0; i < TinyAlloc$FREE_SIZE >> 4; i++) {
      ((int32_t *)TinyAlloc$mFree)[i] = 0;
    }
  for (i = 0; i < TinyAlloc$MAX_HANDLES; i++) {
      TinyAlloc$mHandles[i] = 0;
    }
  TinyAlloc$mFreeBytes = TinyAlloc$FRAME_SIZE;
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t SimpleTimeM$TimerControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = TimerM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline  result_t SimpleTimeM$StdControl$init(void)
#line 73
{

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 75
    {
      SimpleTimeM$time.high32 = 0;
      SimpleTimeM$time.low32 = 0;
      SimpleTimeM$interval = 32;
      SimpleTimeM$timingChanged = FALSE;
    }
#line 80
    __nesc_atomic_end(__nesc_atomic); }
  SimpleTimeM$TimerControl$init();


  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$TimerControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = SimpleTimeM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 159 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static inline void *nmemset(void *to, int val, size_t n)
{
  char *cto = to;

  while (n--) * cto++ = val;

  return to;
}

# 484 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$StdControl$init(void)
#line 484
{

  nmemset((void *)MultiHopLEPSM$NeighborTbl, 0, sizeof(MultiHopLEPSM$TableEntry ) * MultiHopLEPSM$ROUTE_TABLE_SIZE);
  MultiHopLEPSM$BaseStation.id = TOS_UART_ADDR;
  MultiHopLEPSM$BaseStation.parent = TOS_UART_ADDR;
  MultiHopLEPSM$BaseStation.flags = MultiHopLEPSM$NBRFLAG_VALID;
  MultiHopLEPSM$BaseStation.hop = 0;
  MultiHopLEPSM$gpCurrentParent = NULL;
  MultiHopLEPSM$gbCurrentHopCount = MultiHopLEPSM$ROUTE_INVALID;
  MultiHopLEPSM$gCurrentSeqNo = 0;
  MultiHopLEPSM$gwEstTicks = 0;
  MultiHopLEPSM$gUpdateInterval = MultiHopLEPSM$DATA_TO_ROUTE_RATIO * MultiHopLEPSM$DATA_FREQ;
  MultiHopLEPSM$gfSendRouteBusy = FALSE;

  if (TOS_LOCAL_ADDRESS == MultiHopLEPSM$BASE_STATION_ADDRESS) {

      MultiHopLEPSM$gpCurrentParent = &MultiHopLEPSM$BaseStation;
      MultiHopLEPSM$gbCurrentHopCount = 0;
    }


  return SUCCESS;
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
static inline  result_t QueuedSendM$StdControl$init(void)
#line 91
{
  int i;

#line 93
  for (i = 0; i < QueuedSendM$MESSAGE_QUEUE_SIZE; i++) {
      QueuedSendM$msgqueue[i].length = 0;
      QueuedSendM$msgqueue[i].pMsg = NULL;
    }

  QueuedSendM$retransmit = FALSE;

  QueuedSendM$enqueue_next = 0;
  QueuedSendM$dequeue_next = 0;
  QueuedSendM$fQueueIdle = TRUE;
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$SubControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = QueuedSendM$StdControl$init();
#line 63
  result = rcombine(result, MultiHopLEPSM$StdControl$init());
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 212 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$SplitControl$default$initDone(void)
#line 212
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$SplitControl$initDone(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = CC2420RadioM$SplitControl$default$initDone();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 208 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$CC2420SplitControl$initDone(void)
#line 208
{
  return CC2420RadioM$SplitControl$initDone();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420ControlM$SplitControl$initDone(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = CC2420RadioM$CC2420SplitControl$initDone();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  void CC2420ControlM$taskInitDone(void)
#line 108
{
  CC2420ControlM$SplitControl$initDone();
}

# 452 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$disableTxIntr(void)
#line 452
{
  HPLUSART0M$IE1 &= ~(1 << 7);
  return SUCCESS;
}

# 173 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$disableTxIntr(void){
#line 173
  unsigned char result;
#line 173

#line 173
  result = HPLUSART0M$USARTControl$disableTxIntr();
#line 173

#line 173
  return result;
#line 173
}
#line 173
# 447 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$disableRxIntr(void)
#line 447
{
  HPLUSART0M$IE1 &= ~(1 << 6);
  return SUCCESS;
}

# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$disableRxIntr(void){
#line 172
  unsigned char result;
#line 172

#line 172
  result = HPLUSART0M$USARTControl$disableRxIntr();
#line 172

#line 172
  return result;
#line 172
}
#line 172
#line 135
inline static   void HPLCC2420M$USARTControl$setModeSPI(void){
#line 135
  HPLUSART0M$USARTControl$setModeSPI();
#line 135
}
#line 135
# 17 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_MAKE_RADIO_CSN_OUTPUT(void)
#line 17
{
#line 17
   static volatile uint8_t r __asm ("0x001E");

#line 17
  r |= 1 << 2;
}

#line 17
static inline void TOSH_SET_RADIO_CSN_PIN(void)
#line 17
{
#line 17
   static volatile uint8_t r __asm ("0x001D");

#line 17
  r |= 1 << 2;
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  result_t HPLCC2420M$StdControl$init(void)
#line 83
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 84
    {
      HPLCC2420M$f.busy = HPLCC2420M$f.enabled = HPLCC2420M$f.rxbufBusy = HPLCC2420M$f.txbufBusy = FALSE;
    }
#line 86
    __nesc_atomic_end(__nesc_atomic); }

  TOSH_SET_RADIO_CSN_PIN();
  TOSH_MAKE_RADIO_CSN_OUTPUT();
  HPLCC2420M$USARTControl$setModeSPI();
  HPLCC2420M$USARTControl$disableRxIntr();
  HPLCC2420M$USARTControl$disableTxIntr();
  return SUCCESS;
}

# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static inline  result_t BusArbitrationM$StdControl$init(void)
#line 54
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 55
    {
      BusArbitrationM$state = BusArbitrationM$BUS_OFF;
      BusArbitrationM$isBusReleasedPending = FALSE;
    }
#line 58
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420ControlM$HPLChipconControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = BusArbitrationM$StdControl$init();
#line 63
  result = rcombine(result, HPLCC2420M$StdControl$init());
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  result_t CC2420ControlM$SplitControl$init(void)
#line 129
{

  uint8_t _state = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 133
    {
      if (CC2420ControlM$state == CC2420ControlM$IDLE_STATE) {
          CC2420ControlM$state = CC2420ControlM$INIT_STATE;
          _state = TRUE;
        }
    }
#line 138
    __nesc_atomic_end(__nesc_atomic); }
  if (!_state) {
    return FAIL;
    }
  CC2420ControlM$HPLChipconControl$init();


  CC2420ControlM$gCurrentParameters[CP_MAIN] = 0xf800;
  CC2420ControlM$gCurrentParameters[CP_MDMCTRL0] = ((((0 << 11) | (
  2 << 8)) | (3 << 6)) | (
  1 << 5)) | (2 << 0);

  CC2420ControlM$gCurrentParameters[CP_MDMCTRL1] = 20 << 6;

  CC2420ControlM$gCurrentParameters[CP_RSSI] = 0xE080;
  CC2420ControlM$gCurrentParameters[CP_SYNCWORD] = 0xA70F;
  CC2420ControlM$gCurrentParameters[CP_TXCTRL] = ((((1 << 14) | (
  1 << 13)) | (3 << 6)) | (
  1 << 5)) | (CC2420_RFPOWER << 0);

  CC2420ControlM$gCurrentParameters[CP_RXCTRL0] = (((((1 << 12) | (
  2 << 8)) | (3 << 6)) | (
  2 << 4)) | (1 << 2)) | (
  1 << 0);

  CC2420ControlM$gCurrentParameters[CP_RXCTRL1] = (((((1 << 11) | (
  1 << 9)) | (1 << 6)) | (
  1 << 4)) | (1 << 2)) | (
  2 << 0);

  CC2420ControlM$gCurrentParameters[CP_FSCTRL] = (1 << 14) | ((
  357 + 5 * (CC2420_CHANNEL - 11)) << 0);

  CC2420ControlM$gCurrentParameters[CP_SECCTRL0] = (((1 << 8) | (
  1 << 7)) | (1 << 6)) | (
  1 << 2);

  CC2420ControlM$gCurrentParameters[CP_SECCTRL1] = 0;
  CC2420ControlM$gCurrentParameters[CP_BATTMON] = 0;



  CC2420ControlM$gCurrentParameters[CP_IOCFG0] = (127 << 0) | (
  1 << 9);

  CC2420ControlM$gCurrentParameters[CP_IOCFG1] = 0;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 185
    CC2420ControlM$state = CC2420ControlM$INIT_STATE_DONE;
#line 185
    __nesc_atomic_end(__nesc_atomic); }
  TOS_post(CC2420ControlM$taskInitDone);
  return SUCCESS;
}

# 64 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$CC2420SplitControl$init(void){
#line 64
  unsigned char result;
#line 64

#line 64
  result = CC2420ControlM$SplitControl$init();
#line 64

#line 64
  return result;
#line 64
}
#line 64
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
static inline   result_t RandomLFSR$Random$init(void)
#line 59
{
  {
  }
#line 60
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 61
    {
      RandomLFSR$shiftReg = 119 * 119 * (TOS_LOCAL_ADDRESS + 1);
      RandomLFSR$initSeed = RandomLFSR$shiftReg;
      RandomLFSR$mask = 137 * 29 * (TOS_LOCAL_ADDRESS + 1);
    }
#line 65
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
inline static   result_t CC2420RadioM$Random$init(void){
#line 57
  unsigned char result;
#line 57

#line 57
  result = RandomLFSR$Random$init();
#line 57

#line 57
  return result;
#line 57
}
#line 57
# 423 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB4$disableEvents(void)
#line 423
{
#line 423
  MSP430TimerM$TBCCTL4 &= ~0x0010;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerJiffyAsyncM$AlarmControl$disableEvents(void){
#line 39
  MSP430TimerM$ControlB4$disableEvents();
#line 39
}
#line 39
# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline uint16_t MSP430TimerM$CC2int(MSP430TimerM$CC_t x)
#line 95
{
#line 95
  union __nesc_unnamed4409 {
#line 95
    MSP430TimerM$CC_t f;
#line 95
    uint16_t t;
  } 
#line 95
  c = { .f = x };

#line 95
  return c.t;
}

static inline uint16_t MSP430TimerM$compareControl(void)
{
  MSP430TimerM$CC_t x = { 
  .cm = 1, 
  .ccis = 0, 
  .clld = 0, 
  .cap = 0, 
  .ccie = 0 };

  return MSP430TimerM$CC2int(x);
}

#line 383
static inline   void MSP430TimerM$ControlB4$setControlAsCompare(void)
#line 383
{
#line 383
  MSP430TimerM$TBCCTL4 = MSP430TimerM$compareControl();
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerJiffyAsyncM$AlarmControl$setControlAsCompare(void){
#line 35
  MSP430TimerM$ControlB4$setControlAsCompare();
#line 35
}
#line 35
# 16 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline  result_t TimerJiffyAsyncM$StdControl$init(void)
{
  TimerJiffyAsyncM$AlarmControl$setControlAsCompare();
  TimerJiffyAsyncM$AlarmControl$disableEvents();
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420RadioM$TimerControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = TimerJiffyAsyncM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$SplitControl$init(void)
#line 191
{

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 193
    {
      CC2420RadioM$stateRadio = CC2420RadioM$DISABLED_STATE;
      CC2420RadioM$currentDSN = 0;
      CC2420RadioM$bAckEnable = FALSE;
      CC2420RadioM$bPacketReceiving = FALSE;
      CC2420RadioM$rxbufptr = &CC2420RadioM$RxBuf;
      CC2420RadioM$rxbufptr->length = 0;
    }
#line 200
    __nesc_atomic_end(__nesc_atomic); }

  CC2420RadioM$TimerControl$init();
  CC2420RadioM$Random$init();
  CC2420RadioM$LocalAddr = TOS_LOCAL_ADDRESS;
  return CC2420RadioM$CC2420SplitControl$init();
}

#line 186
static inline  result_t CC2420RadioM$StdControl$init(void)
#line 186
{
  return CC2420RadioM$SplitControl$init();
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$RadioControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = CC2420RadioM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static inline  result_t UARTM$Control$init(void)
#line 60
{
  {
  }
#line 61
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 62
    {
      UARTM$state = FALSE;
    }
#line 64
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t FramerM$ByteControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = UARTM$Control$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 291 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  result_t FramerM$StdControl$init(void)
#line 291
{
  FramerM$HDLCInitialize();
  return FramerM$ByteControl$init();
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$UARTControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = FramerM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
inline static  result_t AMStandard$TimerControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = TimerM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  bool AMStandard$Control$init(void)
#line 87
{
  result_t ok1;
#line 88
  result_t ok2;

  AMStandard$TimerControl$init();
  ok1 = AMStandard$UARTControl$init();
  ok2 = AMStandard$RadioControl$init();

  AMStandard$state = FALSE;
  AMStandard$lastCount = 0;
  AMStandard$counter = 0;
  {
  }
#line 97
  ;

  return rcombine(ok1, ok2);
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$CommStdControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = AMStandard$Control$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
inline static void MultiHopEngineM$initialize(void)
#line 127
{
  int n;

  for (n = 0; n < MultiHopEngineM$FWD_QUEUE_SIZE; n++) {
      MultiHopEngineM$FwdBufList[n] = &MultiHopEngineM$FwdBuffers[n];
    }

  MultiHopEngineM$iFwdBufHead = MultiHopEngineM$iFwdBufTail = 0;
}

static inline  result_t MultiHopEngineM$StdControl$init(void)
#line 137
{
  MultiHopEngineM$initialize();
  MultiHopEngineM$CommStdControl$init();
  return MultiHopEngineM$SubControl$init();
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t NetworkMultiHopM$MultiHopStdControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = MultiHopEngineM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 156 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$StdControl$init(void)
{
  NetworkMultiHopM$mWasCommand = FALSE;
  NetworkMultiHopM$mLastSeqNo = 0;
  return NetworkMultiHopM$MultiHopStdControl$init();
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$NetControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = NetworkMultiHopM$StdControl$init();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
inline static   char ServiceSchedulerM$TimeUtil$compare(tos_time_t arg_0x20b0aa0, tos_time_t arg_0x20b0c20){
#line 82
  char result;
#line 82

#line 82
  result = TimeUtilC$TimeUtil$compare(arg_0x20b0aa0, arg_0x20b0c20);
#line 82

#line 82
  return result;
#line 82
}
#line 82
# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline char ServiceSchedulerM$compare_elts(pq_element i, pq_element j)
#line 79
{
  return ServiceSchedulerM$TimeUtil$compare(ServiceSchedulerM$sched_info[i].start_time, 
  ServiceSchedulerM$sched_info[j].start_time);
}

# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
static inline void pqueue_init(pqueue_t *pq, uint8_t size, char (*compare)(pq_element , pq_element ))
#line 54
{
  pq->size = size;
  pq->n_elements = 0;
  pq->compare = compare;
}

# 153 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$SchedulerClt$init(void)
#line 153
{
  int i;

#line 155
  pqueue_init((pqueue_t *)&ServiceSchedulerM$event_q, ServiceSchedulerM$MAX_SERVICES, ServiceSchedulerM$compare_elts);


  for (i = 0; i < ServiceSchedulerM$MAX_SERVICES; i++) {
      ServiceSchedulerM$sched_info[i].flags = DISABLED;
    }
  return SUCCESS;
}

# 399 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline void DBBufferC$initCatalog(void)
#line 399
{
  DBBufferC$ATTR_TYPES[0] = STRING;
  DBBufferC$ATTR_SIZES[0] = sizeOf(STRING);
  strcpy(DBBufferC$ATTR_NAMES[0], "name");
}

#line 320
static inline  result_t DBBufferC$StdControl$init(void)
#line 320
{
  DBBufferC$mUsedBufs = 1;






  DBBufferC$mState = DBBufferC$kIDLE;




  DBBufferC$initCatalog();




  return SUCCESS;
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTempM$AttrRegister$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(4U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline  result_t ADCM$ADCControl$init(void)
{
  if (!ADCM$initialized) {
      ADCM$samplingRate = 0xFF;
      ADCM$initialized = 1;
    }
  return SUCCESS;
}

#line 74
static inline  result_t ADCM$StdControl$init(void)
{
  ADCM$ADCControl$init();
  return SUCCESS;
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static inline  result_t InternalTempM$StdControl$init(void)
#line 50
{
  InternalTempM$contMode = FALSE;
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AttrTempM$SubControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = InternalTempM$StdControl$init();
#line 63
  result = rcombine(result, ADCM$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline  result_t AttrTempM$StdControl$init(void)
{
  AttrTempM$SubControl$init();
  if (AttrTempM$AttrRegister$registerAttr("temp", UINT16, 2) != SUCCESS) {
    return FAIL;
    }
#line 100
  return SUCCESS;
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrVoltageM$AttrRegister$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(5U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  result_t AttrVoltageM$StdControl$init(void)
{
  if (AttrVoltageM$AttrRegister$registerAttr("voltage", UINT16, 2) != SUCCESS) {
    return FAIL;
    }






  return SUCCESS;
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline  result_t InternalVoltageM$StdControl$init(void)
#line 50
{
  InternalVoltageM$contMode = FALSE;
  return SUCCESS;
}

# 90 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$StdControl$init(void)
{
#line 103
  return SUCCESS;
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTimeM$TimeHighAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(3U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
inline static  result_t AttrTimeM$TimeLowAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(2U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$StdControl$init(void)
{
  if (AttrTimeM$TimeLowAttr$registerAttr("timelo", UINT32, 4) != SUCCESS) {
    return FAIL;
    }
#line 61
  if (AttrTimeM$TimeHighAttr$registerAttr("timehi", UINT32, 4) != SUCCESS) {
    return FAIL;
    }
#line 63
  return SUCCESS;
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrGlobalM$GroupAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(1U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
inline static  result_t AttrGlobalM$NodeIdAttr$registerAttr(char *arg_0x261bc20, TOSType arg_0x261bda0, uint8_t arg_0x261bf18){
#line 68
  unsigned char result;
#line 68

#line 68
  result = Attr$Attr$registerAttr(0U, arg_0x261bc20, arg_0x261bda0, arg_0x261bf18);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$StdControl$init(void)
{
  if (AttrGlobalM$NodeIdAttr$registerAttr("nodeid", UINT16, 2) != SUCCESS) {
    return FAIL;
    }
#line 62
  if (AttrGlobalM$GroupAttr$registerAttr("group", UINT8, 1) != SUCCESS) {
    return FAIL;
    }
#line 64
  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$ChildControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = AttrGlobalM$StdControl$init();
#line 63
  result = rcombine(result, AttrTimeM$StdControl$init());
#line 63
  result = rcombine(result, TinyDBAttrM$StdControl$init());
#line 63
  result = rcombine(result, InternalVoltageM$StdControl$init());
#line 63
  result = rcombine(result, ADCM$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63
  result = rcombine(result, AttrVoltageM$StdControl$init());
#line 63
  result = rcombine(result, InternalTempM$StdControl$init());
#line 63
  result = rcombine(result, ADCM$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63
  result = rcombine(result, MSP430ADC12M$StdControl$init());
#line 63
  result = rcombine(result, AttrTempM$StdControl$init());
#line 63
  result = rcombine(result, DBBufferC$StdControl$init());
#line 63
  result = rcombine(result, ServiceSchedulerM$SchedulerClt$init());
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 1991 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$initConsts(void)
#line 1991
{
  TupleRouterM$uaActive = 16900;
  TupleRouterM$uaXmit = 17320;
  TupleRouterM$uaSleep = 220;
}

#line 572
static inline  result_t TupleRouterM$StdControl$init(void)
#line 572
{






  TupleRouterM$mPendingMask = 0;
  TupleRouterM$mCycleToSend = 0;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 581
    {
      TupleRouterM$mQs = NULL;
    }
#line 583
    __nesc_atomic_end(__nesc_atomic); }
  TupleRouterM$mTail = NULL;
  TupleRouterM$mCurQuery = NULL;

  TupleRouterM$mNumBlocked = 0;

  TupleRouterM$mOldRate = 0;
  TupleRouterM$mFetchTries = 0;

  TupleRouterM$mTriedAllocWaiting = FALSE;




  TupleRouterM$mSendQueryNextClock = FALSE;

  TupleRouterM$mClockCount = 0;

  TupleRouterM$mAllocState = TupleRouterM$STATE_NOT_ALLOCING;

  TupleRouterM$mLastQuery = NULL;

  TupleRouterM$mIsRunning = FALSE;
  TupleRouterM$mRadioWaiting = FALSE;
  TupleRouterM$mSendingResult = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 609
    {
      TupleRouterM$mMustTimestamp = TupleRouterM$TS_NO;
    }
#line 611
    __nesc_atomic_end(__nesc_atomic); }

  TupleRouterM$initConsts();

  TupleRouterM$ChildControl$init();
  TupleRouterM$NetControl$init();
  TupleRouterM$TimerControl$init();










  TupleRouterM$mStopped = TRUE;

  TupleRouterM$mSendFailed = 0;
  TupleRouterM$mCurSchedTime = 0;
  TupleRouterM$mLastDiff = 0;
  TupleRouterM$mLastHeard = 0;

  TupleRouterM$mStoppedQid = 0xFF;



  return SUCCESS;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MainM$StdControl$init(void){
#line 63
  unsigned char result;
#line 63

#line 63
  result = TimerM$StdControl$init();
#line 63
  result = rcombine(result, TupleRouterM$StdControl$init());
#line 63
  result = rcombine(result, TinyAlloc$StdControl$init());
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 382 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB3$setControlAsCompare(void)
#line 382
{
#line 382
  MSP430TimerM$TBCCTL3 = MSP430TimerM$compareControl();
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerM$AlarmControl$setControlAsCompare(void){
#line 35
  MSP430TimerM$ControlB3$setControlAsCompare();
#line 35
}
#line 35
# 422 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB3$disableEvents(void)
#line 422
{
#line 422
  MSP430TimerM$TBCCTL3 &= ~0x0010;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerM$AlarmControl$disableEvents(void){
#line 39
  MSP430TimerM$ControlB3$disableEvents();
#line 39
}
#line 39
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   bool HPLUSART0M$USARTControl$isSPI(void)
#line 72
{
  bool _ret = FALSE;

#line 74
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 74
    {
      if (HPLUSART0M$ME1 & (1 << 6)) {
        _ret = TRUE;
        }
    }
#line 78
    __nesc_atomic_end(__nesc_atomic); }
#line 78
  return _ret;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline bool TOSH_IS_URXD0_IOFUNC(void)
#line 38
{
#line 38
   static volatile uint8_t r __asm ("0x001B");

#line 38
  return r | ~(1 << 5);
}

#line 37
static inline bool TOSH_IS_UTXD0_MODFUNC(void)
#line 37
{
#line 37
   static volatile uint8_t r __asm ("0x001B");

#line 37
  return r & (1 << 4);
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   bool HPLUSART0M$USARTControl$isUARTtx(void)
#line 92
{
  bool _ret = FALSE;

#line 94
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 94
    {

      if (
#line 95
      HPLUSART0M$ME1 & (1 << 7) && 
      TOSH_IS_UTXD0_MODFUNC() && 
      TOSH_IS_URXD0_IOFUNC()) {
        _ret = TRUE;
        }
    }
#line 100
    __nesc_atomic_end(__nesc_atomic); }
#line 100
  return _ret;
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline bool TOSH_IS_UTXD0_IOFUNC(void)
#line 37
{
#line 37
   static volatile uint8_t r __asm ("0x001B");

#line 37
  return r | ~(1 << 4);
}

#line 38
static inline bool TOSH_IS_URXD0_MODFUNC(void)
#line 38
{
#line 38
   static volatile uint8_t r __asm ("0x001B");

#line 38
  return r & (1 << 5);
}

# 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   bool HPLUSART0M$USARTControl$isUARTrx(void)
#line 103
{
  bool _ret = FALSE;

#line 105
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 105
    {

      if (
#line 106
      HPLUSART0M$ME1 & (1 << 6) && 
      TOSH_IS_URXD0_MODFUNC() && 
      TOSH_IS_UTXD0_IOFUNC()) {
        _ret = TRUE;
        }
    }
#line 111
    __nesc_atomic_end(__nesc_atomic); }
#line 111
  return _ret;
}

#line 81
static inline   bool HPLUSART0M$USARTControl$isUART(void)
#line 81
{
  bool _ret = FALSE;

#line 83
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 83
    {

      if (
#line 84
      HPLUSART0M$ME1 & (1 << 7) && HPLUSART0M$ME1 & (1 << 6) && 
      TOSH_IS_URXD0_MODFUNC() && 
      TOSH_IS_UTXD0_MODFUNC()) {
        _ret = TRUE;
        }
    }
#line 89
    __nesc_atomic_end(__nesc_atomic); }
#line 89
  return _ret;
}

#line 125
static inline   msp430_usartmode_t HPLUSART0M$USARTControl$getMode(void)
#line 125
{
  if (HPLUSART0M$USARTControl$isUART()) {
    return USART_UART;
    }
  else {
#line 128
    if (HPLUSART0M$USARTControl$isUARTrx()) {
      return USART_UART_RX;
      }
    else {
#line 130
      if (HPLUSART0M$USARTControl$isUARTtx()) {
        return USART_UART_TX;
        }
      else {
#line 132
        if (HPLUSART0M$USARTControl$isSPI()) {
          return USART_SPI;
          }
        else {
#line 134
          if (HPLUSART0M$USARTControl$isI2C()) {
            return USART_I2C;
            }
          else {
#line 137
            return USART_NONE;
            }
          }
        }
      }
    }
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_URXD0_IOFUNC(void)
#line 38
{
#line 38
   static volatile uint8_t r __asm ("0x001B");

#line 38
  r &= ~(1 << 5);
}

#line 37
static inline void TOSH_SEL_UTXD0_IOFUNC(void)
#line 37
{
#line 37
   static volatile uint8_t r __asm ("0x001B");

#line 37
  r &= ~(1 << 4);
}

# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   void HPLUSART0M$USARTControl$disableUART(void)
#line 172
{
  HPLUSART0M$ME1 &= ~((1 << 7) | (1 << 6));
  TOSH_SEL_UTXD0_IOFUNC();
  TOSH_SEL_URXD0_IOFUNC();
}

#line 218
static inline   void HPLUSART0M$USARTControl$disableI2C(void)
#line 218
{

  if (HPLUSART0M$USARTControl$isI2C()) {
    { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 221
      U0CTL &= ~((0x20 | 0x01) | 0x04);
#line 221
      __nesc_atomic_end(__nesc_atomic); }
    }
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_SIMO0_MODFUNC(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x001B");

#line 35
  r |= 1 << 1;
}

#line 34
static inline void TOSH_SEL_SOMI0_MODFUNC(void)
#line 34
{
#line 34
   static volatile uint8_t r __asm ("0x001B");

#line 34
  r |= 1 << 2;
}

#line 36
static inline void TOSH_SEL_UCLK0_MODFUNC(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x001B");

#line 36
  r |= 1 << 3;
}

# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline  result_t TinyAlloc$StdControl$start(void)
#line 172
{
  return SUCCESS;
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline  result_t TimerM$StdControl$start(void)
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MainM$StdControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = TimerM$StdControl$start();
#line 70
  result = rcombine(result, TupleRouterM$StdControl$start());
#line 70
  result = rcombine(result, TinyAlloc$StdControl$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 419 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_ROUTING_TUPLES(void)
#line 419
{
#line 419
  TupleRouterM$mPendingMask &= TupleRouterM$ROUTING_BIT ^ 0xFFFF;
}










static inline void TupleRouterM$UNSET_AGGREGATING_RESULT(void)
#line 431
{
#line 431
  TupleRouterM$mPendingMask &= TupleRouterM$AGGREGATING_BIT ^ 0xFFFF;
}

#line 446
static inline bool TupleRouterM$IS_SNOOZING(void)
#line 446
{
#line 446
  return (TupleRouterM$mPendingMask & TupleRouterM$SNOOZING_BIT) != 0;
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
inline static  result_t ServiceSchedulerM$AbsoluteTimer$set(tos_time_t arg_0x20b7920){
#line 50
  unsigned char result;
#line 50

#line 50
  result = SimpleTimeM$AbsoluteTimer$set(1U, arg_0x20b7920);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
static inline pq_element pqueue_peek(pqueue_t *pq)
#line 115
{
  if (pq->n_elements == 0) {
      return -1;
    }
  return pq->heap[0];
}

# 170 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$SchedulerClt$start(void)
#line 170
{
  int8_t svc_id;

#line 172
  if ((svc_id = pqueue_peek((pqueue_t *)&ServiceSchedulerM$event_q)) < 0) {
    return SUCCESS;
    }
#line 174
  return ServiceSchedulerM$AbsoluteTimer$set(ServiceSchedulerM$sched_info[svc_id].start_time);
}

# 341 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$StdControl$start(void)
#line 341
{
#line 391
  return SUCCESS;
}

# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline  result_t MSP430ADC12M$StdControl$start(void)
{
  return SUCCESS;
}

# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline  result_t ADCM$StdControl$start(void)
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AttrTempM$SubControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = InternalTempM$StdControl$start();
#line 70
  result = rcombine(result, ADCM$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline  result_t AttrTempM$StdControl$start(void)
{
  AttrTempM$SubControl$start();
  return SUCCESS;
}

# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  result_t AttrVoltageM$StdControl$start(void)
{
  return SUCCESS;
}

# 222 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12.h"
static __inline MSP430ADC12Settings_t int2adcSettings(uint32_t i)
#line 222
{
  MSP430ADC12Settings_ut u;

#line 224
  u.i = i;
  return u.s;
}

# 125 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline  result_t MSP430ADC12M$ADCMultiple$bind(uint8_t num, MSP430ADC12Settings_t settings)
{
  return MSP430ADC12M$ADCSingle$bind(num, settings);
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
inline static  result_t InternalVoltageM$MSP430ADC12Multiple$bind(MSP430ADC12Settings_t arg_0x26c1980){
#line 49
  unsigned char result;
#line 49

#line 49
  result = MSP430ADC12M$ADCMultiple$bind(4U, arg_0x26c1980);
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
inline static  result_t InternalVoltageM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00){
#line 50
  unsigned char result;
#line 50

#line 50
  result = MSP430ADC12M$ADCSingle$bind(3U, arg_0x26c7d00);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 117 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline  result_t ADCM$ADCControl$bindPort(uint8_t port, uint8_t adcPort)
{
  if (port < ADCM$TOSH_ADC_PORTMAPSIZE) {
      ADCM$TOSH_adc_portmap[port] = adcPort;
      return SUCCESS;
    }
  else {
#line 123
    return FAIL;
    }
}

# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADCControl.nc"
inline static  result_t InternalVoltageM$ADCControl$bindPort(uint8_t arg_0x26d1a70, uint8_t arg_0x26d1be8){
#line 89
  unsigned char result;
#line 89

#line 89
  result = ADCM$ADCControl$bindPort(arg_0x26d1a70, arg_0x26d1be8);
#line 89

#line 89
  return result;
#line 89
}
#line 89
#line 50
inline static  result_t InternalVoltageM$ADCControl$init(void){
#line 50
  unsigned char result;
#line 50

#line 50
  result = ADCM$ADCControl$init();
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline  result_t InternalVoltageM$StdControl$start(void)
#line 55
{
  result_t ok1;
#line 56
  result_t ok2;

  ok1 = InternalVoltageM$ADCControl$init();
  ok2 = InternalVoltageM$ADCControl$bindPort(TOS_ADC_INTERNAL_VOLTAGE_PORT, 
  TOSH_ACTUAL_ADC_INTERNAL_VOLTAGE_PORT);
  InternalVoltageM$MSP430ADC12Single$bind(int2adcSettings(((((((((((((((uint32_t )SAMPLE_HOLD_4_CYCLES << 4) + INTERNAL_VOLTAGE) << 3) + SHT_CLOCK_DIV_1) << 3) + REFERENCE_VREFplus_AVss) << 2) + SAMPCON_CLOCK_DIV_1) << 2) + SAMPCON_SOURCE_SMCLK) << 2) + SHT_SOURCE_ACLK) << 1) + REFVOLT_LEVEL_1_5));
  InternalVoltageM$MSP430ADC12Multiple$bind(int2adcSettings(((((((((((((((uint32_t )SAMPLE_HOLD_4_CYCLES << 4) + INTERNAL_VOLTAGE) << 3) + SHT_CLOCK_DIV_1) << 3) + REFERENCE_VREFplus_AVss) << 2) + SAMPCON_CLOCK_DIV_1) << 2) + SAMPCON_SOURCE_SMCLK) << 2) + SHT_SOURCE_ACLK) << 1) + REFVOLT_LEVEL_1_5));
  return SUCCESS;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$StdControl$start(void)
{
  return SUCCESS;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$StdControl$start(void)
{
  return SUCCESS;
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$StdControl$start(void)
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$ChildControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = AttrGlobalM$StdControl$start();
#line 70
  result = rcombine(result, AttrTimeM$StdControl$start());
#line 70
  result = rcombine(result, TinyDBAttrM$StdControl$start());
#line 70
  result = rcombine(result, InternalVoltageM$StdControl$start());
#line 70
  result = rcombine(result, ADCM$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70
  result = rcombine(result, AttrVoltageM$StdControl$start());
#line 70
  result = rcombine(result, InternalTempM$StdControl$start());
#line 70
  result = rcombine(result, ADCM$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70
  result = rcombine(result, MSP430ADC12M$StdControl$start());
#line 70
  result = rcombine(result, AttrTempM$StdControl$start());
#line 70
  result = rcombine(result, DBBufferC$StdControl$start());
#line 70
  result = rcombine(result, ServiceSchedulerM$SchedulerClt$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline void MSP430ADC12M$configureAdcPin(uint8_t inputChannel)
{
  if (inputChannel <= 7) {
      P6SEL |= 1 << inputChannel;
      P6DIR &= ~(1 << inputChannel);
    }
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADCControl.nc"
inline static  result_t InternalTempM$ADCControl$init(void){
#line 50
  unsigned char result;
#line 50

#line 50
  result = ADCM$ADCControl$init();
#line 50

#line 50
  return result;
#line 50
}
#line 50
#line 89
inline static  result_t InternalTempM$ADCControl$bindPort(uint8_t arg_0x26d1a70, uint8_t arg_0x26d1be8){
#line 89
  unsigned char result;
#line 89

#line 89
  result = ADCM$ADCControl$bindPort(arg_0x26d1a70, arg_0x26d1be8);
#line 89

#line 89
  return result;
#line 89
}
#line 89
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
inline static  result_t InternalTempM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00){
#line 50
  unsigned char result;
#line 50

#line 50
  result = MSP430ADC12M$ADCSingle$bind(0U, arg_0x26c7d00);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
inline static  result_t InternalTempM$MSP430ADC12Multiple$bind(MSP430ADC12Settings_t arg_0x26c1980){
#line 49
  unsigned char result;
#line 49

#line 49
  result = MSP430ADC12M$ADCMultiple$bind(1U, arg_0x26c1980);
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t MultiHopLEPSM$Timer$start(char arg_0x1841820, uint32_t arg_0x18419a8){
#line 59
  unsigned char result;
#line 59

#line 59
  result = TimerM$Timer$start(1U, arg_0x1841820, arg_0x18419a8);
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 508 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$StdControl$start(void)
#line 508
{
  TOS_post(MultiHopLEPSM$TimerTask);
  MultiHopLEPSM$Timer$start(TIMER_REPEAT, MultiHopLEPSM$gUpdateInterval);
  return SUCCESS;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
static inline  result_t QueuedSendM$StdControl$start(void)
#line 106
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$SubControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = QueuedSendM$StdControl$start();
#line 70
  result = rcombine(result, MultiHopLEPSM$StdControl$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 133 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static inline result_t rcombine4(result_t r1, result_t r2, result_t r3, 
result_t r4)
{
  return rcombine(r1, rcombine(r2, rcombine(r3, r4)));
}

# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLPowerManagementM.nc"
static inline   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)
#line 53
{
  return SUCCESS;
}

# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/PowerManagement.nc"
inline static   uint8_t AMStandard$PowerManagement$adjustPower(void){
#line 41
  unsigned char result;
#line 41

#line 41
  result = HPLPowerManagementM$PowerManagement$adjustPower();
#line 41

#line 41
  return result;
#line 41
}
#line 41
# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t AMStandard$ActivityTimer$start(char arg_0x1841820, uint32_t arg_0x18419a8){
#line 59
  unsigned char result;
#line 59

#line 59
  result = TimerM$Timer$start(0U, arg_0x1841820, arg_0x18419a8);
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
inline static   uint8_t CC2420ControlM$HPLChipcon$cmd(uint8_t arg_0x1906450){
#line 47
  unsigned char result;
#line 47

#line 47
  result = HPLCC2420M$HPLCC2420$cmd(arg_0x1906450);
#line 47

#line 47
  return result;
#line 47
}
#line 47
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port14$enable(void)
#line 119
{
#line 119
  MSP430InterruptM$P1IE |= 1 << 4;
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$CCAInterrupt$enable(void){
#line 30
  MSP430InterruptM$Port14$enable();
#line 30
}
#line 30
# 245 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port14$edge(bool l2h)
#line 245
{
  {
    if (l2h) {
#line 247
      P1IES &= ~(1 << 4);
      }
    else {
#line 248
      P1IES |= 1 << 4;
      }
  }
}

# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$CCAInterrupt$edge(bool arg_0x1b71710){
#line 54
  MSP430InterruptM$Port14$edge(arg_0x1b71710);
#line 54
}
#line 54
# 181 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port14$clear(void)
#line 181
{
#line 181
  MSP430InterruptM$P1IFG &= ~(1 << 4);
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$CCAInterrupt$clear(void){
#line 40
  MSP430InterruptM$Port14$clear();
#line 40
}
#line 40
# 150 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port14$disable(void)
#line 150
{
#line 150
  MSP430InterruptM$P1IE &= ~(1 << 4);
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$CCAInterrupt$disable(void){
#line 35
  MSP430InterruptM$Port14$disable();
#line 35
}
#line 35
# 147 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   result_t HPLCC2420InterruptM$CCA$startWait(bool low_to_high)
#line 147
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 148
    {
      HPLCC2420InterruptM$CCAInterrupt$disable();
      HPLCC2420InterruptM$CCAInterrupt$clear();
      HPLCC2420InterruptM$CCAInterrupt$edge(low_to_high);
      HPLCC2420InterruptM$CCAInterrupt$enable();
    }
#line 153
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t CC2420ControlM$CCA$startWait(bool arg_0x192c1a0){
#line 43
  unsigned char result;
#line 43

#line 43
  result = HPLCC2420InterruptM$CCA$startWait(arg_0x192c1a0);
#line 43

#line 43
  return result;
#line 43
}
#line 43
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
inline static   uint8_t CC2420ControlM$HPLChipcon$write(uint8_t arg_0x1906940, uint16_t arg_0x1906ac0){
#line 54
  unsigned char result;
#line 54

#line 54
  result = HPLCC2420M$HPLCC2420$write(arg_0x1906940, arg_0x1906ac0);
#line 54

#line 54
  return result;
#line 54
}
#line 54
# 368 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline   result_t CC2420ControlM$CC2420Control$OscillatorOn(void)
#line 368
{
  uint16_t i;
  uint8_t status;

  i = 0;
#line 384
  CC2420ControlM$HPLChipcon$write(0x1D, 24);


  CC2420ControlM$CCA$startWait(TRUE);


  status = CC2420ControlM$HPLChipcon$cmd(0x01);

  return SUCCESS;
}

# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SET_CC_RSTN_PIN(void)
#line 31
{
#line 31
   static volatile uint8_t r __asm ("0x001D");

#line 31
  r |= 1 << 6;
}

#line 31
static inline void TOSH_CLR_CC_RSTN_PIN(void)
#line 31
{
#line 31
   static volatile uint8_t r __asm ("0x001D");

#line 31
  r &= ~(1 << 6);
}

#line 30
static inline void TOSH_SET_CC_VREN_PIN(void)
#line 30
{
#line 30
   static volatile uint8_t r __asm ("0x001D");

#line 30
  r |= 1 << 5;
}

# 400 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline   result_t CC2420ControlM$CC2420Control$VREFOn(void)
#line 400
{
  TOSH_SET_CC_VREN_PIN();

  TOSH_uwait(600);
  return SUCCESS;
}

# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  result_t HPLCC2420M$StdControl$start(void)
#line 96
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 97
    {
      if (! HPLCC2420M$f.busy) {
          TOSH_SET_RADIO_CSN_PIN();
          TOSH_MAKE_RADIO_CSN_OUTPUT();
          HPLCC2420M$USARTControl$setModeSPI();
          HPLCC2420M$USARTControl$disableRxIntr();
          HPLCC2420M$USARTControl$disableTxIntr();
          HPLCC2420M$f.busy = HPLCC2420M$f.rxbufBusy = HPLCC2420M$f.txbufBusy = FALSE;
          HPLCC2420M$f.enabled = TRUE;
        }
    }
#line 107
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static inline  result_t BusArbitrationM$StdControl$start(void)
#line 62
{
  uint8_t _state;

#line 64
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 64
    {
      if (BusArbitrationM$state == BusArbitrationM$BUS_OFF) {
          BusArbitrationM$state = BusArbitrationM$BUS_IDLE;
          BusArbitrationM$isBusReleasedPending = FALSE;
        }
      _state = BusArbitrationM$state;
    }
#line 70
    __nesc_atomic_end(__nesc_atomic); }

  if (_state == BusArbitrationM$BUS_IDLE) {
    return SUCCESS;
    }
  return FAIL;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420ControlM$HPLChipconControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = BusArbitrationM$StdControl$start();
#line 70
  result = rcombine(result, HPLCC2420M$StdControl$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 227 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  result_t CC2420ControlM$SplitControl$start(void)
#line 227
{
  result_t status;
  uint8_t _state = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 231
    {
      if (CC2420ControlM$state == CC2420ControlM$INIT_STATE_DONE) {
          CC2420ControlM$state = CC2420ControlM$START_STATE;
          _state = TRUE;
        }
    }
#line 236
    __nesc_atomic_end(__nesc_atomic); }
  if (!_state) {
    return FAIL;
    }
  CC2420ControlM$HPLChipconControl$start();

  CC2420ControlM$CC2420Control$VREFOn();

  TOSH_CLR_CC_RSTN_PIN();
  TOSH_wait();
  TOSH_SET_CC_RSTN_PIN();
  TOSH_wait();


  status = CC2420ControlM$CC2420Control$OscillatorOn();

  return status;
}

# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$CC2420SplitControl$start(void){
#line 77
  unsigned char result;
#line 77

#line 77
  result = CC2420ControlM$SplitControl$start();
#line 77

#line 77
  return result;
#line 77
}
#line 77
# 23 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline  result_t TimerJiffyAsyncM$StdControl$start(void)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 25
    {
      TimerJiffyAsyncM$bSet = FALSE;
      TimerJiffyAsyncM$AlarmControl$disableEvents();
    }
#line 28
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420RadioM$TimerControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = TimerJiffyAsyncM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 277 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$SplitControl$start(void)
#line 277
{
  uint8_t chkstateRadio;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 280
    chkstateRadio = CC2420RadioM$stateRadio;
#line 280
    __nesc_atomic_end(__nesc_atomic); }

  if (chkstateRadio == CC2420RadioM$DISABLED_STATE) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 283
        {
          CC2420RadioM$stateRadio = CC2420RadioM$WARMUP_STATE;
          CC2420RadioM$countRetry = 0;
          CC2420RadioM$rxbufptr->length = 0;
        }
#line 287
        __nesc_atomic_end(__nesc_atomic); }
      CC2420RadioM$TimerControl$start();
      return CC2420RadioM$CC2420SplitControl$start();
    }
  return FAIL;
}

#line 239
static inline  void CC2420RadioM$startRadio(void)
#line 239
{
  result_t success = FAIL;

#line 241
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 241
    {
      if (CC2420RadioM$stateRadio == CC2420RadioM$DISABLED_STATE_STARTTASK) {
          CC2420RadioM$stateRadio = CC2420RadioM$DISABLED_STATE;
          success = SUCCESS;
        }
    }
#line 246
    __nesc_atomic_end(__nesc_atomic); }

  if (success == SUCCESS) {
    CC2420RadioM$SplitControl$start();
    }
}

static inline  result_t CC2420RadioM$StdControl$start(void)
#line 253
{







  result_t success = FAIL;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 263
    {
      if (CC2420RadioM$stateRadio == CC2420RadioM$DISABLED_STATE) {

          if (TOS_post(CC2420RadioM$startRadio)) {
              success = SUCCESS;
              CC2420RadioM$stateRadio = CC2420RadioM$DISABLED_STATE_STARTTASK;
            }
        }
    }
#line 271
    __nesc_atomic_end(__nesc_atomic); }

  return success;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$RadioControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = CC2420RadioM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 400 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   result_t HPLUSART1M$USARTControl$enableTxIntr(void)
#line 400
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 401
    {
      HPLUSART1M$IFG2 &= ~(1 << 5);
      IE2 |= 1 << 5;
    }
#line 404
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 175 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLUARTM$USARTControl$enableTxIntr(void){
#line 175
  unsigned char result;
#line 175

#line 175
  result = HPLUSART1M$USARTControl$enableTxIntr();
#line 175

#line 175
  return result;
#line 175
}
#line 175
# 392 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   result_t HPLUSART1M$USARTControl$enableRxIntr(void)
#line 392
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 393
    {
      HPLUSART1M$IFG2 &= ~(1 << 4);
      IE2 |= 1 << 4;
    }
#line 396
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 174 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLUARTM$USARTControl$enableRxIntr(void){
#line 174
  unsigned char result;
#line 174

#line 174
  result = HPLUSART1M$USARTControl$enableRxIntr();
#line 174

#line 174
  return result;
#line 174
}
#line 174
# 349 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   void HPLUSART1M$USARTControl$setClockRate(uint16_t baudrate, uint8_t mctl)
#line 349
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 350
    {
      HPLUSART1M$l_br = baudrate;
      HPLUSART1M$l_mctl = mctl;
      U1BR0 = baudrate & 0x0FF;
      U1BR1 = (baudrate >> 8) & 0x0FF;
      U1MCTL = mctl;
    }
#line 356
    __nesc_atomic_end(__nesc_atomic); }
}

# 169 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   void HPLUARTM$USARTControl$setClockRate(uint16_t arg_0x1a6c548, uint8_t arg_0x1a6c6c0){
#line 169
  HPLUSART1M$USARTControl$setClockRate(arg_0x1a6c548, arg_0x1a6c6c0);
#line 169
}
#line 169
# 341 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   void HPLUSART1M$USARTControl$setClockSource(uint8_t source)
#line 341
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 342
    {
      HPLUSART1M$l_ssel = source | 0x80;
      HPLUSART1M$U1TCTL &= ~(((0x00 | 0x10) | 0x20) | 0x30);
      HPLUSART1M$U1TCTL |= HPLUSART1M$l_ssel & 0x7F;
    }
#line 346
    __nesc_atomic_end(__nesc_atomic); }
}

# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   void HPLUARTM$USARTControl$setClockSource(uint8_t arg_0x1a6c0b0){
#line 167
  HPLUSART1M$USARTControl$setClockSource(arg_0x1a6c0b0);
#line 167
}
#line 167
# 252 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline void HPLUSART1M$setUARTModeCommon(void)
#line 252
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 253
    {
      U1CTL = 0x01;
      U1CTL |= 0x10;

      U1RCTL &= ~0x08;

      U1CTL = 0x01;
      U1CTL |= 0x10;

      if (HPLUSART1M$l_ssel & 0x80) {
          HPLUSART1M$U1TCTL &= ~(((0x00 | 0x10) | 0x20) | 0x30);
          HPLUSART1M$U1TCTL |= HPLUSART1M$l_ssel & 0x7F;
        }
      else {
          HPLUSART1M$U1TCTL &= ~(((0x00 | 0x10) | 0x20) | 0x30);
          HPLUSART1M$U1TCTL |= 0x10;
        }

      if (HPLUSART1M$l_mctl != 0 || HPLUSART1M$l_br != 0) {
          U1BR0 = HPLUSART1M$l_br & 0x0FF;
          U1BR1 = (HPLUSART1M$l_br >> 8) & 0x0FF;
          U1MCTL = HPLUSART1M$l_mctl;
        }
      else {
          U1BR0 = 0x03;
          U1BR1 = 0x00;
          U1MCTL = 0x4A;
        }

      HPLUSART1M$ME2 &= ~(1 << 4);
      HPLUSART1M$ME2 |= (1 << 5) | (1 << 4);

      U1CTL &= ~0x01;

      HPLUSART1M$IFG2 &= ~((1 << 5) | (1 << 4));
      IE2 &= ~((1 << 5) | (1 << 4));
    }
#line 289
    __nesc_atomic_end(__nesc_atomic); }
  return;
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_URXD1_MODFUNC(void)
#line 40
{
#line 40
   static volatile uint8_t r __asm ("0x001B");

#line 40
  r |= 1 << 7;
}

#line 39
static inline void TOSH_SEL_UTXD1_MODFUNC(void)
#line 39
{
#line 39
   static volatile uint8_t r __asm ("0x001B");

#line 39
  r |= 1 << 6;
}

#line 40
static inline void TOSH_SEL_URXD1_IOFUNC(void)
#line 40
{
#line 40
   static volatile uint8_t r __asm ("0x001B");

#line 40
  r &= ~(1 << 7);
}

#line 39
static inline void TOSH_SEL_UTXD1_IOFUNC(void)
#line 39
{
#line 39
   static volatile uint8_t r __asm ("0x001B");

#line 39
  r &= ~(1 << 6);
}

# 158 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   void HPLUSART1M$USARTControl$disableUART(void)
#line 158
{
  HPLUSART1M$ME2 &= ~((1 << 5) | (1 << 4));
  TOSH_SEL_UTXD1_IOFUNC();
  TOSH_SEL_URXD1_IOFUNC();
}

# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_UCLK1_IOFUNC(void)
#line 41
{
#line 41
   static volatile uint8_t r __asm ("0x0033");

#line 41
  r &= ~(1 << 3);
}

#line 42
static inline void TOSH_SEL_SOMI1_IOFUNC(void)
#line 42
{
#line 42
   static volatile uint8_t r __asm ("0x0033");

#line 42
  r &= ~(1 << 2);
}

#line 43
static inline void TOSH_SEL_SIMO1_IOFUNC(void)
#line 43
{
#line 43
   static volatile uint8_t r __asm ("0x0033");

#line 43
  r &= ~(1 << 1);
}

# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   void HPLUSART1M$USARTControl$disableSPI(void)
#line 191
{
  HPLUSART1M$ME2 &= ~(1 << 4);
  TOSH_SEL_SIMO1_IOFUNC();
  TOSH_SEL_SOMI1_IOFUNC();
  TOSH_SEL_UCLK1_IOFUNC();
}

#line 107
static inline   bool HPLUSART1M$USARTControl$isI2C(void)
#line 107
{
  return FALSE;
}

#line 64
static inline   bool HPLUSART1M$USARTControl$isSPI(void)
#line 64
{
  bool _ret = FALSE;

#line 66
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 66
    {
      if (HPLUSART1M$ME2 & (1 << 4)) {
        _ret = TRUE;
        }
    }
#line 70
    __nesc_atomic_end(__nesc_atomic); }
#line 70
  return _ret;
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline bool TOSH_IS_URXD1_IOFUNC(void)
#line 40
{
#line 40
   static volatile uint8_t r __asm ("0x001B");

#line 40
  return r | ~(1 << 7);
}

#line 39
static inline bool TOSH_IS_UTXD1_MODFUNC(void)
#line 39
{
#line 39
   static volatile uint8_t r __asm ("0x001B");

#line 39
  return r & (1 << 6);
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   bool HPLUSART1M$USARTControl$isUARTtx(void)
#line 84
{
  bool _ret = FALSE;

#line 86
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 86
    {

      if (
#line 87
      HPLUSART1M$ME2 & (1 << 5) && 
      TOSH_IS_UTXD1_MODFUNC() && 
      TOSH_IS_URXD1_IOFUNC()) {
        _ret = TRUE;
        }
    }
#line 92
    __nesc_atomic_end(__nesc_atomic); }
#line 92
  return _ret;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline bool TOSH_IS_UTXD1_IOFUNC(void)
#line 39
{
#line 39
   static volatile uint8_t r __asm ("0x001B");

#line 39
  return r | ~(1 << 6);
}

#line 40
static inline bool TOSH_IS_URXD1_MODFUNC(void)
#line 40
{
#line 40
   static volatile uint8_t r __asm ("0x001B");

#line 40
  return r & (1 << 7);
}

# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   bool HPLUSART1M$USARTControl$isUARTrx(void)
#line 95
{
  bool _ret = FALSE;

#line 97
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 97
    {

      if (
#line 98
      HPLUSART1M$ME2 & (1 << 4) && 
      TOSH_IS_URXD1_MODFUNC() && 
      TOSH_IS_UTXD1_IOFUNC()) {
        _ret = TRUE;
        }
    }
#line 103
    __nesc_atomic_end(__nesc_atomic); }
#line 103
  return _ret;
}

#line 73
static inline   bool HPLUSART1M$USARTControl$isUART(void)
#line 73
{
  bool _ret = FALSE;

#line 75
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 75
    {

      if (
#line 76
      HPLUSART1M$ME2 & (1 << 5) && HPLUSART1M$ME2 & (1 << 4) && 
      TOSH_IS_URXD1_MODFUNC() && 
      TOSH_IS_UTXD1_MODFUNC()) {
        _ret = TRUE;
        }
    }
#line 81
    __nesc_atomic_end(__nesc_atomic); }
#line 81
  return _ret;
}

#line 111
static inline   msp430_usartmode_t HPLUSART1M$USARTControl$getMode(void)
#line 111
{
  if (HPLUSART1M$USARTControl$isUART()) {
    return USART_UART;
    }
  else {
#line 114
    if (HPLUSART1M$USARTControl$isUARTrx()) {
      return USART_UART_RX;
      }
    else {
#line 116
      if (HPLUSART1M$USARTControl$isUARTtx()) {
        return USART_UART_TX;
        }
      else {
#line 118
        if (HPLUSART1M$USARTControl$isSPI()) {
          return USART_SPI;
          }
        else {
#line 120
          if (HPLUSART1M$USARTControl$isI2C()) {
            return USART_I2C;
            }
          else {
#line 123
            return USART_NONE;
            }
          }
        }
      }
    }
}

#line 325
static inline   void HPLUSART1M$USARTControl$setModeUART(void)
#line 325
{

  if (HPLUSART1M$USARTControl$getMode() == USART_UART) {
    return;
    }
  HPLUSART1M$USARTControl$disableSPI();
  HPLUSART1M$USARTControl$disableUART();

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 333
    {
      TOSH_SEL_UTXD1_MODFUNC();
      TOSH_SEL_URXD1_MODFUNC();
    }
#line 336
    __nesc_atomic_end(__nesc_atomic); }
  HPLUSART1M$setUARTModeCommon();
  return;
}

# 153 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   void HPLUARTM$USARTControl$setModeUART(void){
#line 153
  HPLUSART1M$USARTControl$setModeUART();
#line 153
}
#line 153
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$UART$init(void)
#line 50
{

  HPLUARTM$USARTControl$setModeUART();
#line 64
  HPLUARTM$USARTControl$setClockSource(0x20);
  HPLUARTM$USARTControl$setClockRate(UBR_SMCLK_57600, UMCTL_SMCLK_57600);
#line 77
  HPLUARTM$USARTControl$enableRxIntr();
  HPLUARTM$USARTControl$enableTxIntr();
  return SUCCESS;
}

# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t UARTM$HPLUART$init(void){
#line 62
  unsigned char result;
#line 62

#line 62
  result = HPLUARTM$UART$init();
#line 62

#line 62
  return result;
#line 62
}
#line 62
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static inline  result_t UARTM$Control$start(void)
#line 68
{
  return UARTM$HPLUART$init();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t FramerM$ByteControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = UARTM$Control$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 296 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  result_t FramerM$StdControl$start(void)
#line 296
{
  FramerM$HDLCInitialize();
  return FramerM$ByteControl$start();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$UARTControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = FramerM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
inline static  result_t AMStandard$TimerControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = TimerM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  bool AMStandard$Control$start(void)
#line 103
{
  result_t ok0 = AMStandard$TimerControl$start();
  result_t ok1 = AMStandard$UARTControl$start();
  result_t ok2 = AMStandard$RadioControl$start();
  result_t ok3 = AMStandard$ActivityTimer$start(TIMER_REPEAT, 1000);



  AMStandard$state = FALSE;

  AMStandard$PowerManagement$adjustPower();

  return rcombine4(ok0, ok1, ok2, ok3);
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$CommStdControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = AMStandard$Control$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  result_t MultiHopEngineM$StdControl$start(void)
#line 143
{
  MultiHopEngineM$CommStdControl$start();
  MultiHopEngineM$SubControl$start();
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t NetworkMultiHopM$MultiHopStdControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = MultiHopEngineM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 163 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$StdControl$start(void)
{
  return NetworkMultiHopM$MultiHopStdControl$start();
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$NetControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = NetworkMultiHopM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline uint8_t HPLCC2420M$adjustStatusByte(uint8_t status)
#line 79
{
  return status & 0x7E;
}

#line 461
static inline  result_t HPLCC2420M$BusArbitration$busFree(void)
#line 461
{
  return SUCCESS;
}

# 125 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static inline   result_t BusArbitrationM$BusArbitration$default$busFree(uint8_t id)
#line 125
{
  return SUCCESS;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitration.nc"
inline static  result_t BusArbitrationM$BusArbitration$busFree(uint8_t arg_0x1c93a50){
#line 39
  unsigned char result;
#line 39

#line 39
  switch (arg_0x1c93a50) {
#line 39
    case 0U:
#line 39
      result = HPLCC2420M$BusArbitration$busFree();
#line 39
      break;
#line 39
    default:
#line 39
      result = BusArbitrationM$BusArbitration$default$busFree(arg_0x1c93a50);
#line 39
    }
#line 39

#line 39
  return result;
#line 39
}
#line 39
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static inline  void BusArbitrationM$busReleased(void)
#line 42
{
  uint8_t i;
  uint8_t currentstate;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 46
    BusArbitrationM$isBusReleasedPending = FALSE;
#line 46
    __nesc_atomic_end(__nesc_atomic); }
  for (i = 0; i < 1U; i++) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 48
        currentstate = BusArbitrationM$state;
#line 48
        __nesc_atomic_end(__nesc_atomic); }
      if (currentstate == BusArbitrationM$BUS_IDLE) {
        BusArbitrationM$BusArbitration$busFree(i);
        }
    }
}

# 166 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$TimerB$read(void)
#line 166
{
#line 166
  return TBR;
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   uint16_t TimerM$AlarmTimer$read(void){
#line 30
  unsigned int result;
#line 30

#line 30
  result = MSP430TimerM$TimerB$read();
#line 30

#line 30
  return result;
#line 30
}
#line 30
# 169 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   bool MSP430TimerM$TimerB$isOverflowPending(void)
#line 169
{
#line 169
  return TBCTL & 0x0001;
}

# 31 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   bool TimerM$AlarmTimer$isOverflowPending(void){
#line 31
  unsigned char result;
#line 31

#line 31
  result = MSP430TimerM$TimerB$isOverflowPending();
#line 31

#line 31
  return result;
#line 31
}
#line 31
# 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  result_t AMStandard$ActivityTimer$fired(void)
#line 151
{
  AMStandard$lastCount = AMStandard$counter;
  AMStandard$counter = 0;
  return SUCCESS;
}

# 693 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$Timer$fired(void)
#line 693
{
  TOS_post(MultiHopLEPSM$TimerTask);
  return SUCCESS;
}

# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  result_t AMPromiscuous$ActivityTimer$fired(void)
#line 179
{
  AMPromiscuous$lastCount = AMPromiscuous$counter;
  AMPromiscuous$counter = 0;
  return SUCCESS;
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t SimpleTimeM$Timer$start(char arg_0x1841820, uint32_t arg_0x18419a8){
#line 59
  unsigned char result;
#line 59

#line 59
  result = TimerM$Timer$start(3U, arg_0x1841820, arg_0x18419a8);
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline void TimerM$removeTimer(uint8_t num)
{
  TimerM$m_timers[num].isset = FALSE;
}

#line 443
static inline  result_t TimerM$Timer$stop(uint8_t num)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 445
    TimerM$removeTimer(num);
#line 445
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t SimpleTimeM$Timer$stop(void){
#line 68
  unsigned char result;
#line 68

#line 68
  result = TimerM$Timer$stop(3U);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline   result_t SimpleTimeM$AbsoluteTimer$default$fired(uint8_t id)
#line 172
{
  return SUCCESS;
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
inline static  result_t SimpleTimeM$AbsoluteTimer$fired(uint8_t arg_0x228b658){
#line 61
  unsigned char result;
#line 61

#line 61
  switch (arg_0x228b658) {
#line 61
    case 0U:
#line 61
      result = TupleRouterM$AbsoluteTimer$fired();
#line 61
      break;
#line 61
    case 1U:
#line 61
      result = ServiceSchedulerM$AbsoluteTimer$fired();
#line 61
      break;
#line 61
    default:
#line 61
      result = SimpleTimeM$AbsoluteTimer$default$fired(arg_0x228b658);
#line 61
    }
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
inline static   char SimpleTimeM$TimeUtil$compare(tos_time_t arg_0x20b0aa0, tos_time_t arg_0x20b0c20){
#line 82
  char result;
#line 82

#line 82
  result = TimeUtilC$TimeUtil$compare(arg_0x20b0aa0, arg_0x20b0c20);
#line 82

#line 82
  return result;
#line 82
}
#line 82
#line 65
inline static   tos_time_t SimpleTimeM$TimeUtil$addUint32(tos_time_t arg_0x20b1bd8, uint32_t arg_0x20b1d58){
#line 65
  struct __nesc_unnamed4330 result;
#line 65

#line 65
  result = TimeUtilC$TimeUtil$addUint32(arg_0x20b1bd8, arg_0x20b1d58);
#line 65

#line 65
  return result;
#line 65
}
#line 65
# 176 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline  result_t SimpleTimeM$Timer$fired(void)
#line 176
{
  uint8_t i;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 179
    SimpleTimeM$time = SimpleTimeM$TimeUtil$addUint32(SimpleTimeM$time, SimpleTimeM$interval);
#line 179
    __nesc_atomic_end(__nesc_atomic); }

  for (i = 1; i <= MAX_NUM_TIMERS; i++) 
    if ((SimpleTimeM$aTimer[i - 1].low32 || SimpleTimeM$aTimer[i - 1].high32) && 
    SimpleTimeM$TimeUtil$compare(SimpleTimeM$time, SimpleTimeM$aTimer[i - 1]) >= 0) 
      {
        SimpleTimeM$aTimer[i - 1].high32 = 0;
        SimpleTimeM$aTimer[i - 1].low32 = 0;
        SimpleTimeM$AbsoluteTimer$fired(i - 1);
      }
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 189
    {
      if (SimpleTimeM$timingChanged) {
          SimpleTimeM$timingChanged = FALSE;
          SimpleTimeM$Timer$stop();
          SimpleTimeM$Timer$start(TIMER_REPEAT, SimpleTimeM$interval);
        }
    }
#line 195
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 449 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline   result_t TimerM$Timer$default$fired(uint8_t num)
{
  return SUCCESS;
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t TimerM$Timer$fired(uint8_t arg_0x1e40118){
#line 73
  unsigned char result;
#line 73

#line 73
  switch (arg_0x1e40118) {
#line 73
    case 0U:
#line 73
      result = AMStandard$ActivityTimer$fired();
#line 73
      break;
#line 73
    case 1U:
#line 73
      result = MultiHopLEPSM$Timer$fired();
#line 73
      break;
#line 73
    case 2U:
#line 73
      result = AMPromiscuous$ActivityTimer$fired();
#line 73
      break;
#line 73
    case 3U:
#line 73
      result = SimpleTimeM$Timer$fired();
#line 73
      break;
#line 73
    default:
#line 73
      result = TimerM$Timer$default$fired(arg_0x1e40118);
#line 73
    }
#line 73

#line 73
  return result;
#line 73
}
#line 73
# 380 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline uint8_t TimerM$fromNumMilli(uint8_t num)
{
  return num + TimerM$OFFSET_TIMER_MILLI;
}

static inline  result_t TimerM$TimerMilli$setOneShot(uint8_t num, int32_t milli)
{
  return TimerM$setTimer(TimerM$fromNumMilli(num), milli * 32, FALSE);
}

# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
inline static  result_t RefVoltM$SwitchOffTimer$setOneShot(int32_t arg_0x1e4fe38){
#line 28
  unsigned char result;
#line 28

#line 28
  result = TimerM$TimerMilli$setOneShot(1U, arg_0x1e4fe38);
#line 28

#line 28
  return result;
#line 28
}
#line 28
# 230 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline  void RefVoltM$switchOffRetry(void)
#line 230
{
  if (RefVoltM$switchOff == TRUE) {
    RefVoltM$SwitchOffTimer$setOneShot(5);
    }
}

# 138 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setRefOff(void)
#line 138
{
#line 138
  HPLADC12M$ADC12CTL0 &= ~0x0020;
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void RefVoltM$HPLADC12$setRefOff(void){
#line 73
  HPLADC12M$HPLADC12$setRefOff();
#line 73
}
#line 73
# 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$disableConversion(void)
#line 115
{
#line 115
  HPLADC12M$ADC12CTL0 &= ~0x0002;
}

# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void RefVoltM$HPLADC12$disableConversion(void){
#line 80
  HPLADC12M$HPLADC12$disableConversion();
#line 80
}
#line 80
# 112 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   bool HPLADC12M$HPLADC12$isBusy(void)
#line 112
{
#line 112
  return HPLADC12M$ADC12CTL1 & 0x0001;
}

# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   bool RefVoltM$HPLADC12$isBusy(void){
#line 65
  unsigned char result;
#line 65

#line 65
  result = HPLADC12M$HPLADC12$isBusy();
#line 65

#line 65
  return result;
#line 65
}
#line 65
# 205 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static __inline void RefVoltM$switchRefOff(void)
#line 205
{
  result_t result;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 208
    {
      if (RefVoltM$switchOff == FALSE) {
        result = FAIL;
        }
      else {
#line 211
        if (RefVoltM$HPLADC12$isBusy()) {
            result = FAIL;
          }
        else {
            RefVoltM$HPLADC12$disableConversion();
            RefVoltM$HPLADC12$setRefOff();
            RefVoltM$state = RefVoltM$REFERENCE_OFF;
            result = SUCCESS;
          }
        }
    }
#line 221
    __nesc_atomic_end(__nesc_atomic); }
#line 221
  if (RefVoltM$switchOff == TRUE && result == FAIL) {
    TOS_post(RefVoltM$switchOffRetry);
    }
}










static inline  result_t RefVoltM$SwitchOffTimer$fired(void)
#line 235
{
  RefVoltM$switchRefOff();
  return SUCCESS;
}

# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.nc"
inline static  void RefVoltM$RefVolt$isStable(RefVolt_t arg_0x2763518){
#line 127
  MSP430ADC12M$RefVolt$isStable(arg_0x2763518);
#line 127
}
#line 127
# 166 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline  result_t RefVoltM$SwitchOnTimer$fired(void)
#line 166
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 167
    {
      if (RefVoltM$state == RefVoltM$REFERENCE_1_5V_PENDING) {
        RefVoltM$state = RefVoltM$REFERENCE_1_5V_STABLE;
        }
#line 170
      if (RefVoltM$state == RefVoltM$REFERENCE_2_5V_PENDING) {
        RefVoltM$state = RefVoltM$REFERENCE_2_5V_STABLE;
        }
    }
#line 173
    __nesc_atomic_end(__nesc_atomic); }
#line 173
  if (RefVoltM$state == RefVoltM$REFERENCE_1_5V_STABLE) {
    RefVoltM$RefVolt$isStable(REFERENCE_1_5V);
    }
#line 175
  if (RefVoltM$state == RefVoltM$REFERENCE_2_5V_STABLE) {
    RefVoltM$RefVolt$isStable(REFERENCE_2_5V);
    }
#line 177
  return SUCCESS;
}

# 421 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline   result_t TimerM$TimerMilli$default$fired(uint8_t num)
{
  return SUCCESS;
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
inline static  result_t TimerM$TimerMilli$fired(uint8_t arg_0x1e40860){
#line 37
  unsigned char result;
#line 37

#line 37
  switch (arg_0x1e40860) {
#line 37
    case 0U:
#line 37
      result = RefVoltM$SwitchOnTimer$fired();
#line 37
      break;
#line 37
    case 1U:
#line 37
      result = RefVoltM$SwitchOffTimer$fired();
#line 37
      break;
#line 37
    default:
#line 37
      result = TimerM$TimerMilli$default$fired(arg_0x1e40860);
#line 37
    }
#line 37

#line 37
  return result;
#line 37
}
#line 37
# 372 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline   result_t TimerM$TimerJiffy$default$fired(uint8_t num)
{
  return SUCCESS;
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerJiffy.nc"
inline static  result_t TimerM$TimerJiffy$fired(uint8_t arg_0x1e773e0){
#line 37
  unsigned char result;
#line 37

#line 37
    result = TimerM$TimerJiffy$default$fired(arg_0x1e773e0);
#line 37

#line 37
  return result;
#line 37
}
#line 37
# 118 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline void TimerM$signal_timer_fired(uint8_t num)
{



  const int16_t num16 = num;

  if (TimerM$COUNT_TIMER_JIFFY > 0 && num16 >= TimerM$OFFSET_TIMER_JIFFY) 
    {
      TimerM$TimerJiffy$fired(num - TimerM$OFFSET_TIMER_JIFFY);
    }
  else {
#line 129
    if (TimerM$COUNT_TIMER_MILLI > 0 && num16 >= TimerM$OFFSET_TIMER_MILLI) 
      {
        TimerM$TimerMilli$fired(num - TimerM$OFFSET_TIMER_MILLI);
      }
    else 
      {
        TimerM$Timer$fired(num);
      }
    }
}

# 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$startConversion(void)
#line 116
{
#line 116
  HPLADC12M$ADC12CTL0 |= 0x0001 + 0x0002;
}

# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$startConversion(void){
#line 81
  HPLADC12M$HPLADC12$startConversion();
#line 81
}
#line 81
# 218 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlA1$setControl(MSP430TimerM$CC_t x)
#line 218
{
#line 218
  MSP430TimerM$TA0CCTL1 = MSP430TimerM$CC2int(x);
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void MSP430ADC12M$ControlA1$setControl(MSP430CompareControl_t arg_0x1600560){
#line 34
  MSP430TimerM$ControlA1$setControl(arg_0x1600560);
#line 34
}
#line 34
# 174 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$TimerA$setMode(int mode)
#line 174
{
#line 174
  MSP430TimerM$TA0CTL = (MSP430TimerM$TA0CTL & ~(0x0020 | 0x0010)) | ((mode << 4) & (0x0020 | 0x0010));
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430ADC12M$TimerA$setMode(int arg_0x15f4010){
#line 35
  MSP430TimerM$TimerA$setMode(arg_0x15f4010);
#line 35
}
#line 35
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
static inline pq_element pqueue_dequeue(pqueue_t *pq)
#line 101
{
  return pqueue_dequeue_idx(pq, 0);
}

# 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline   result_t ServiceSchedulerM$Services$default$start(uint8_t id)
#line 139
{
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t ServiceSchedulerM$Services$start(uint8_t arg_0x2903420){
#line 70
  unsigned char result;
#line 70

#line 70
  switch (arg_0x2903420) {
#line 70
    case kTINYDB_SERVICE_ID:
#line 70
      result = TupleRouterM$StdControl$start();
#line 70
      break;
#line 70
    default:
#line 70
      result = ServiceSchedulerM$Services$default$start(arg_0x2903420);
#line 70
    }
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
inline static   tos_time_t ServiceSchedulerM$TimeUtil$addUint32(tos_time_t arg_0x20b1bd8, uint32_t arg_0x20b1d58){
#line 65
  struct __nesc_unnamed4330 result;
#line 65

#line 65
  result = TimeUtilC$TimeUtil$addUint32(arg_0x20b1bd8, arg_0x20b1d58);
#line 65

#line 65
  return result;
#line 65
}
#line 65
# 123 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline   tos_time_t SimpleTimeM$Time$get(void)
#line 123
{
  tos_time_t t;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 126
    t = SimpleTimeM$time;
#line 126
    __nesc_atomic_end(__nesc_atomic); }
  return t;
}

# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Time.nc"
inline static   tos_time_t TupleRouterM$Time$get(void){
#line 46
  struct __nesc_unnamed4330 result;
#line 46

#line 46
  result = SimpleTimeM$Time$get();
#line 46

#line 46
  return result;
#line 46
}
#line 46
# 232 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  tos_time_t ServiceSchedulerM$ServiceScheduler$getNextEventTime(uint8_t svc_id)
#line 232
{
  return ServiceSchedulerM$sched_info[svc_id].start_time;
}

# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ServiceScheduler.nc"
inline static  tos_time_t TupleRouterM$ServiceScheduler$getNextEventTime(uint8_t arg_0x20eb168){
#line 76
  struct __nesc_unnamed4330 result;
#line 76

#line 76
  result = ServiceSchedulerM$ServiceScheduler$getNextEventTime(arg_0x20eb168);
#line 76

#line 76
  return result;
#line 76
}
#line 76
# 76 "/opt/msp430/msp430/include/stdlib.h"
#line 75
extern __inline int 
abs(int __x)
{
  return __x < 0 ? -__x : __x;
}

# 238 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$ServiceScheduler$setExtraSleepTime(uint8_t svc_id, int32_t extraTime)
#line 238
{
  if (extraTime > 0 || extraTime * -1 < ServiceSchedulerM$sched_info[svc_id].off_time) {
    ServiceSchedulerM$extraSleep = extraTime;
    }
#line 241
  if (extraTime < 0 && abs(extraTime) > ServiceSchedulerM$sched_info[svc_id].off_time) {
    ServiceSchedulerM$extraSleep = -1 * (ServiceSchedulerM$sched_info[svc_id].off_time - 1);
    }
#line 243
  return SUCCESS;
}

# 79 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ServiceScheduler.nc"
inline static  result_t TupleRouterM$ServiceScheduler$setExtraSleepTime(uint8_t arg_0x20eb5e8, int32_t arg_0x20eb768){
#line 79
  unsigned char result;
#line 79

#line 79
  result = ServiceSchedulerM$ServiceScheduler$setExtraSleepTime(arg_0x20eb5e8, arg_0x20eb768);
#line 79

#line 79
  return result;
#line 79
}
#line 79
# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SET_RED_LED_PIN(void)
#line 12
{
#line 12
   static volatile uint8_t r __asm ("0x0031");

#line 12
  r |= 1 << 4;
}

#line 12
static inline void TOSH_CLR_RED_LED_PIN(void)
#line 12
{
#line 12
   static volatile uint8_t r __asm ("0x0031");

#line 12
  r &= ~(1 << 4);
}

#line 14
static inline void TOSH_SET_YELLOW_LED_PIN(void)
#line 14
{
#line 14
   static volatile uint8_t r __asm ("0x0031");

#line 14
  r |= 1 << 6;
}

#line 14
static inline void TOSH_CLR_YELLOW_LED_PIN(void)
#line 14
{
#line 14
   static volatile uint8_t r __asm ("0x0031");

#line 14
  r &= ~(1 << 6);
}

#line 13
static inline void TOSH_SET_GREEN_LED_PIN(void)
#line 13
{
#line 13
   static volatile uint8_t r __asm ("0x0031");

#line 13
  r |= 1 << 5;
}

#line 13
static inline void TOSH_CLR_GREEN_LED_PIN(void)
#line 13
{
#line 13
   static volatile uint8_t r __asm ("0x0031");

#line 13
  r &= ~(1 << 5);
}

# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$set(uint8_t ledsNum)
#line 167
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 168
    {
      LedsC$ledsOn = ledsNum & 0x7;
      if (LedsC$ledsOn & LedsC$GREEN_BIT) {
        TOSH_CLR_GREEN_LED_PIN();
        }
      else {
#line 173
        TOSH_SET_GREEN_LED_PIN();
        }
#line 174
      if (LedsC$ledsOn & LedsC$YELLOW_BIT) {
        TOSH_CLR_YELLOW_LED_PIN();
        }
      else {
#line 177
        TOSH_SET_YELLOW_LED_PIN();
        }
#line 178
      if (LedsC$ledsOn & LedsC$RED_BIT) {
        TOSH_CLR_RED_LED_PIN();
        }
      else {
#line 181
        TOSH_SET_RED_LED_PIN();
        }
    }
#line 183
    __nesc_atomic_end(__nesc_atomic); }
#line 183
  return SUCCESS;
}

# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$set(uint8_t arg_0x17e65b8){
#line 149
  unsigned char result;
#line 149

#line 149
  result = LedsC$Leds$set(arg_0x17e65b8);
#line 149

#line 149
  return result;
#line 149
}
#line 149
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
inline static  result_t ServiceSchedulerM$AbsoluteTimer$cancel(void){
#line 56
  unsigned char result;
#line 56

#line 56
  result = SimpleTimeM$AbsoluteTimer$cancel(1U);
#line 56

#line 56
  return result;
#line 56
}
#line 56
# 182 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$SchedulerClt$stop(void)
#line 182
{
  int8_t svc_id;

#line 184
  if ((svc_id = pqueue_peek((pqueue_t *)&ServiceSchedulerM$event_q)) < 0) {
    return SUCCESS;
    }
#line 186
  return ServiceSchedulerM$AbsoluteTimer$cancel();
}

# 394 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$StdControl$stop(void)
#line 394
{
  return SUCCESS;
}

# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setIEFlags(uint16_t mask)
#line 95
{
#line 95
  HPLADC12M$ADC12IE = mask;
}

# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$setIEFlags(uint16_t arg_0x2773dd0){
#line 55
  HPLADC12M$HPLADC12$setIEFlags(arg_0x2773dd0);
#line 55
}
#line 55
#line 80
inline static   void MSP430ADC12M$HPLADC12$disableConversion(void){
#line 80
  HPLADC12M$HPLADC12$disableConversion();
#line 80
}
#line 80
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline  result_t MSP430ADC12M$StdControl$stop(void)
{
  MSP430ADC12M$HPLADC12$disableConversion();
  MSP430ADC12M$HPLADC12$setIEFlags(0x0000);
  return SUCCESS;
}

# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline  result_t ADCM$StdControl$stop(void)
{
  ADCM$continuousData = FALSE;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 88
    ADCM$busy = FALSE;
#line 88
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static inline  result_t InternalTempM$StdControl$stop(void)
#line 66
{
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AttrTempM$SubControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = InternalTempM$StdControl$stop();
#line 78
  result = rcombine(result, ADCM$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline  result_t AttrTempM$StdControl$stop(void)
{
  AttrTempM$SubControl$stop();
  return SUCCESS;
}

# 116 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  result_t AttrVoltageM$StdControl$stop(void)
{
  return SUCCESS;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline  result_t InternalVoltageM$StdControl$stop(void)
#line 66
{
  return SUCCESS;
}

# 111 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$StdControl$stop(void)
{
  return SUCCESS;
}

# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$StdControl$stop(void)
{
  return SUCCESS;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$StdControl$stop(void)
{
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$ChildControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = AttrGlobalM$StdControl$stop();
#line 78
  result = rcombine(result, AttrTimeM$StdControl$stop());
#line 78
  result = rcombine(result, TinyDBAttrM$StdControl$stop());
#line 78
  result = rcombine(result, InternalVoltageM$StdControl$stop());
#line 78
  result = rcombine(result, ADCM$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78
  result = rcombine(result, AttrVoltageM$StdControl$stop());
#line 78
  result = rcombine(result, InternalTempM$StdControl$stop());
#line 78
  result = rcombine(result, ADCM$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78
  result = rcombine(result, MSP430ADC12M$StdControl$stop());
#line 78
  result = rcombine(result, AttrTempM$StdControl$stop());
#line 78
  result = rcombine(result, DBBufferC$StdControl$stop());
#line 78
  result = rcombine(result, ServiceSchedulerM$SchedulerClt$stop());
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 128 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static inline result_t rcombine3(result_t r1, result_t r2, result_t r3)
{
  return rcombine(r1, rcombine(r2, r3));
}

# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t AMStandard$ActivityTimer$stop(void){
#line 68
  unsigned char result;
#line 68

#line 68
  result = TimerM$Timer$stop(0U);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 235 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$SplitControl$default$stopDone(void)
#line 235
{
  return SUCCESS;
}

# 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$SplitControl$stopDone(void){
#line 99
  unsigned char result;
#line 99

#line 99
  result = CC2420RadioM$SplitControl$default$stopDone();
#line 99

#line 99
  return result;
#line 99
}
#line 99
# 231 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$CC2420SplitControl$stopDone(void)
#line 231
{
  return CC2420RadioM$SplitControl$stopDone();
}

# 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420ControlM$SplitControl$stopDone(void){
#line 99
  unsigned char result;
#line 99

#line 99
  result = CC2420RadioM$CC2420SplitControl$stopDone();
#line 99

#line 99
  return result;
#line 99
}
#line 99
# 112 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  void CC2420ControlM$taskStopDone(void)
#line 112
{
  CC2420ControlM$SplitControl$stopDone();
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_CLR_CC_VREN_PIN(void)
#line 30
{
#line 30
   static volatile uint8_t r __asm ("0x001D");

#line 30
  r &= ~(1 << 5);
}

# 407 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline   result_t CC2420ControlM$CC2420Control$VREFOff(void)
#line 407
{
  TOSH_CLR_CC_VREN_PIN();
  return SUCCESS;
}

# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_UCLK0_IOFUNC(void)
#line 36
{
#line 36
   static volatile uint8_t r __asm ("0x001B");

#line 36
  r &= ~(1 << 3);
}

#line 34
static inline void TOSH_SEL_SOMI0_IOFUNC(void)
#line 34
{
#line 34
   static volatile uint8_t r __asm ("0x001B");

#line 34
  r &= ~(1 << 2);
}

#line 35
static inline void TOSH_SEL_SIMO0_IOFUNC(void)
#line 35
{
#line 35
   static volatile uint8_t r __asm ("0x001B");

#line 35
  r &= ~(1 << 1);
}

# 205 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   void HPLUSART0M$USARTControl$disableSPI(void)
#line 205
{
  HPLUSART0M$ME1 &= ~(1 << 6);
  TOSH_SEL_SIMO0_IOFUNC();
  TOSH_SEL_SOMI0_IOFUNC();
  TOSH_SEL_UCLK0_IOFUNC();
}

# 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   void HPLCC2420M$USARTControl$disableSPI(void){
#line 115
  HPLUSART0M$USARTControl$disableSPI();
#line 115
}
#line 115
# 111 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  result_t HPLCC2420M$StdControl$stop(void)
#line 111
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 112
    {


      if (! HPLCC2420M$f.busy) {
        HPLCC2420M$USARTControl$disableSPI();
        }
#line 117
      HPLCC2420M$f.enabled = FALSE;
    }
#line 118
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static inline  result_t BusArbitrationM$StdControl$stop(void)
#line 78
{
  uint8_t _state;

#line 80
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 80
    {
      if (BusArbitrationM$state == BusArbitrationM$BUS_IDLE) {
          BusArbitrationM$state = BusArbitrationM$BUS_OFF;
          BusArbitrationM$isBusReleasedPending = FALSE;
        }
      _state = BusArbitrationM$state;
    }
#line 86
    __nesc_atomic_end(__nesc_atomic); }

  if (_state == BusArbitrationM$BUS_OFF) {
      return SUCCESS;
    }
  return FAIL;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420ControlM$HPLChipconControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = BusArbitrationM$StdControl$stop();
#line 78
  result = rcombine(result, HPLCC2420M$StdControl$stop());
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 160 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   result_t HPLCC2420InterruptM$CCA$disable(void)
#line 160
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 161
    {
      HPLCC2420InterruptM$CCAInterrupt$disable();
      HPLCC2420InterruptM$CCAInterrupt$clear();
    }
#line 164
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t CC2420ControlM$CCA$disable(void){
#line 59
  unsigned char result;
#line 59

#line 59
  result = HPLCC2420InterruptM$CCA$disable();
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  result_t CC2420ControlM$SplitControl$stop(void)
#line 191
{
  result_t ok;
  uint8_t _state = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 195
    {
      if (CC2420ControlM$state == CC2420ControlM$START_STATE_DONE) {
          CC2420ControlM$state = CC2420ControlM$STOP_STATE;
          _state = TRUE;
        }
    }
#line 200
    __nesc_atomic_end(__nesc_atomic); }
  if (!_state) {
    return FAIL;
    }
  CC2420ControlM$HPLChipcon$cmd(0x07);
  ok = CC2420ControlM$CCA$disable();
  ok &= CC2420ControlM$HPLChipconControl$stop();

  TOSH_CLR_CC_RSTN_PIN();
  ok &= CC2420ControlM$CC2420Control$VREFOff();
  TOSH_SET_CC_RSTN_PIN();

  if (ok) {
    TOS_post(CC2420ControlM$taskStopDone);
    }
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 215
    CC2420ControlM$state = CC2420ControlM$INIT_STATE_DONE;
#line 215
    __nesc_atomic_end(__nesc_atomic); }
  return ok;
}

# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$CC2420SplitControl$stop(void){
#line 93
  unsigned char result;
#line 93

#line 93
  result = CC2420ControlM$SplitControl$stop();
#line 93

#line 93
  return result;
#line 93
}
#line 93
# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline  result_t TimerJiffyAsyncM$StdControl$stop(void)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 34
    {
      TimerJiffyAsyncM$bSet = FALSE;
      TimerJiffyAsyncM$AlarmControl$disableEvents();
    }
#line 37
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t CC2420RadioM$TimerControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = TimerJiffyAsyncM$StdControl$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 177 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port10$clear(void)
#line 177
{
#line 177
  MSP430InterruptM$P1IFG &= ~(1 << 0);
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOPInterrupt$clear(void){
#line 40
  MSP430InterruptM$Port10$clear();
#line 40
}
#line 40
# 146 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port10$disable(void)
#line 146
{
#line 146
  MSP430InterruptM$P1IE &= ~(1 << 0);
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOPInterrupt$disable(void){
#line 35
  MSP430InterruptM$Port10$disable();
#line 35
}
#line 35
# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   result_t HPLCC2420InterruptM$FIFOP$disable(void)
#line 78
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 79
    {
      HPLCC2420InterruptM$FIFOPInterrupt$disable();
      HPLCC2420InterruptM$FIFOPInterrupt$clear();
    }
#line 82
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t CC2420RadioM$FIFOP$disable(void){
#line 59
  unsigned char result;
#line 59

#line 59
  result = HPLCC2420InterruptM$FIFOP$disable();
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_CC_SFD_IOFUNC(void)
#line 29
{
#line 29
   static volatile uint8_t r __asm ("0x001F");

#line 29
  r &= ~(1 << 1);
}

# 364 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB1$clearPendingInterrupt(void)
#line 364
{
#line 364
  MSP430TimerM$TBCCTL1 &= ~0x0001;
}

# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void HPLCC2420InterruptM$SFDControl$clearPendingInterrupt(void){
#line 32
  MSP430TimerM$ControlB1$clearPendingInterrupt();
#line 32
}
#line 32
# 420 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB1$disableEvents(void)
#line 420
{
#line 420
  MSP430TimerM$TBCCTL1 &= ~0x0010;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void HPLCC2420InterruptM$SFDControl$disableEvents(void){
#line 39
  MSP430TimerM$ControlB1$disableEvents();
#line 39
}
#line 39
# 200 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   result_t HPLCC2420InterruptM$SFD$disable(void)
#line 200
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 201
    {
      HPLCC2420InterruptM$SFDControl$disableEvents();
      HPLCC2420InterruptM$SFDControl$clearPendingInterrupt();
      TOSH_SEL_CC_SFD_IOFUNC();
    }
#line 205
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Capture.nc"
inline static   result_t CC2420RadioM$SFD$disable(void){
#line 60
  unsigned char result;
#line 60

#line 60
  result = HPLCC2420InterruptM$SFD$disable();
#line 60

#line 60
  return result;
#line 60
}
#line 60
# 222 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$SplitControl$stop(void)
#line 222
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 223
    CC2420RadioM$stateRadio = CC2420RadioM$DISABLED_STATE;
#line 223
    __nesc_atomic_end(__nesc_atomic); }

  CC2420RadioM$SFD$disable();
  CC2420RadioM$FIFOP$disable();
  CC2420RadioM$TimerControl$stop();
  return CC2420RadioM$CC2420SplitControl$stop();
}

#line 217
static inline  result_t CC2420RadioM$StdControl$stop(void)
#line 217
{
  return CC2420RadioM$SplitControl$stop();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$RadioControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = CC2420RadioM$StdControl$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   void HPLUARTM$USARTControl$disableUART(void){
#line 85
  HPLUSART1M$USARTControl$disableUART();
#line 85
}
#line 85
# 387 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   result_t HPLUSART1M$USARTControl$disableTxIntr(void)
#line 387
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 388
    IE2 &= ~(1 << 5);
#line 388
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 173 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLUARTM$USARTControl$disableTxIntr(void){
#line 173
  unsigned char result;
#line 173

#line 173
  result = HPLUSART1M$USARTControl$disableTxIntr();
#line 173

#line 173
  return result;
#line 173
}
#line 173
# 382 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   result_t HPLUSART1M$USARTControl$disableRxIntr(void)
#line 382
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 383
    IE2 &= ~(1 << 4);
#line 383
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLUARTM$USARTControl$disableRxIntr(void){
#line 172
  unsigned char result;
#line 172

#line 172
  result = HPLUSART1M$USARTControl$disableRxIntr();
#line 172

#line 172
  return result;
#line 172
}
#line 172
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$UART$stop(void)
#line 82
{
  HPLUARTM$USARTControl$disableRxIntr();
  HPLUARTM$USARTControl$disableTxIntr();

  HPLUARTM$USARTControl$disableUART();
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t UARTM$HPLUART$stop(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = HPLUARTM$UART$stop();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static inline  result_t UARTM$Control$stop(void)
#line 72
{

  return UARTM$HPLUART$stop();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t FramerM$ByteControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = UARTM$Control$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 301 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  result_t FramerM$StdControl$stop(void)
#line 301
{
  return FramerM$ByteControl$stop();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t AMStandard$UARTControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = FramerM$StdControl$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  bool AMStandard$Control$stop(void)
#line 119
{
  result_t ok1 = AMStandard$UARTControl$stop();
  result_t ok2 = AMStandard$RadioControl$stop();
  result_t ok3 = AMStandard$ActivityTimer$stop();

  AMStandard$PowerManagement$adjustPower();
  return rcombine3(ok1, ok2, ok3);
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$CommStdControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = AMStandard$Control$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t MultiHopLEPSM$Timer$stop(void){
#line 68
  unsigned char result;
#line 68

#line 68
  result = TimerM$Timer$stop(1U);
#line 68

#line 68
  return result;
#line 68
}
#line 68
# 514 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$StdControl$stop(void)
#line 514
{
  MultiHopLEPSM$Timer$stop();
  return SUCCESS;
}

# 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
static inline  result_t QueuedSendM$StdControl$stop(void)
#line 109
{
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t MultiHopEngineM$SubControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = QueuedSendM$StdControl$stop();
#line 78
  result = rcombine(result, MultiHopLEPSM$StdControl$stop());
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  result_t MultiHopEngineM$StdControl$stop(void)
#line 149
{
  MultiHopEngineM$SubControl$stop();

  return MultiHopEngineM$CommStdControl$stop();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t NetworkMultiHopM$MultiHopStdControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = MultiHopEngineM$StdControl$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 168 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$StdControl$stop(void)
{
  return NetworkMultiHopM$MultiHopStdControl$stop();
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$NetControl$stop(void){
#line 78
  unsigned char result;
#line 78

#line 78
  result = NetworkMultiHopM$StdControl$stop();
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 434 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$IS_SENDING_QUERY(void)
#line 434
{
#line 434
  return (TupleRouterM$mPendingMask & TupleRouterM$SENDING_QUERY_BIT) != 0;
}

# 2543 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  bool DBBufferC$RadioQueue$enqueueDone(void)
#line 2543
{
  if (DBBufferC$mState == DBBufferC$kRADIO_ENQUEUE) {
      DBBufferC$continueRadioBufferEnqueue();
      return DBBufferC$mState == DBBufferC$kRADIO_ENQUEUE;
    }
  return FALSE;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/RadioQueue.nc"
inline static  bool TupleRouterM$RadioQueue$enqueueDone(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = DBBufferC$RadioQueue$enqueueDone();
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  short DBBufferC$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0){
#line 131
  short result;
#line 131

#line 131
  result = QueryResult$QueryResultIntf$numRecords(arg_0x208c030, arg_0x208c1b0);
#line 131

#line 131
  return result;
#line 131
}
#line 131






inline static  ResultTuple DBBufferC$QueryResultIntf$getResultTuple(QueryResultPtr arg_0x208c670, short arg_0x208c7e0, ParsedQueryPtr arg_0x208c960){
#line 137
  struct __nesc_unnamed4314 result;
#line 137

#line 137
  result = QueryResult$QueryResultIntf$getResultTuple(arg_0x208c670, arg_0x208c7e0, arg_0x208c960);
#line 137

#line 137
  return result;
#line 137
}
#line 137
#line 124
inline static  TinyDBError DBBufferC$QueryResultIntf$fromResultTuple(ResultTuple arg_0x208d398, QueryResultPtr arg_0x208d518, ParsedQueryPtr arg_0x208d698){
#line 124
  unsigned char result;
#line 124

#line 124
  result = QueryResult$QueryResultIntf$fromResultTuple(arg_0x208d398, arg_0x208d518, arg_0x208d698);
#line 124

#line 124
  return result;
#line 124
}
#line 124
# 1264 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  uint8_t DBBufferC$CatalogTable$catalogFieldSize(uint8_t bufIdx, uint8_t fieldNo)
#line 1264
{
  uint8_t bufferId;
  uint8_t numFields;
  uint8_t *sizes = NULL;

  if (DBBufferC$getSpecialBufferId(bufIdx, &bufferId) != err_NoError) {
    return 0;
    }
#line 1271
  switch (bufferId) {
      case DBBufferC$kATTR_BUF: 
        numFields = DBBufferC$NUM_ATTR_FIELDS;
#line 1273
      sizes = (char *)DBBufferC$ATTR_SIZES;
      break;
#line 1287
      default: 
        return 0;
    }
  if (fieldNo < DBBufferC$NUM_ATTR_FIELDS && sizes != NULL) {
    return sizes[fieldNo];
    }
  else {
#line 1293
    return 0;
    }
}

# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/CatalogTable.nc"
inline static  uint8_t Tuple$CatalogTable$catalogFieldSize(uint8_t arg_0x22c7468, uint8_t arg_0x22c75e0){
#line 41
  unsigned char result;
#line 41

#line 41
  result = DBBufferC$CatalogTable$catalogFieldSize(arg_0x22c7468, arg_0x22c75e0);
#line 41

#line 41
  return result;
#line 41
}
#line 41
# 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError Tuple$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650){
#line 151
  unsigned char result;
#line 151

#line 151
  result = DBBufferC$DBBuffer$getBufferId(arg_0x20d1330, arg_0x20d14b0, arg_0x20d1650);
#line 151

#line 151
  return result;
#line 151
}
#line 151
#line 135
inline static  ParsedQuery **Tuple$DBBuffer$getSchema(uint8_t arg_0x20d2890){
#line 135
  struct __nesc_unnamed4298 **result;
#line 135

#line 135
  result = DBBufferC$DBBuffer$getSchema(arg_0x20d2890);
#line 135

#line 135
  return result;
#line 135
}
#line 135
# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  bool ParsedQuery$ParsedQueryIntf$queryFieldIsNull(uint8_t field)
#line 92
{

  return (field & NULL_QUERY_FIELD) > 0;
}

# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  bool Tuple$ParsedQueryIntf$queryFieldIsNull(uint8_t arg_0x206c928){
#line 43
  unsigned char result;
#line 43

#line 43
  result = ParsedQuery$ParsedQueryIntf$queryFieldIsNull(arg_0x206c928);
#line 43

#line 43
  return result;
#line 43
}
#line 43
# 298 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline uint16_t Tuple$typeToSize(TOSType type)
#line 298
{
  return sizeOf(type);
}

# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  bool ParsedQuery$ParsedQueryIntf$queryFieldIsTyped(uint8_t field)
#line 97
{
  return (field & TYPED_FIELD) == TYPED_FIELD;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  bool Tuple$ParsedQueryIntf$queryFieldIsTyped(uint8_t arg_0x206cdd8){
#line 48
  unsigned char result;
#line 48

#line 48
  result = ParsedQuery$ParsedQueryIntf$queryFieldIsTyped(arg_0x206cdd8);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 427 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_SENDING_MESSAGE(void)
#line 427
{
#line 427
  TupleRouterM$mPendingMask &= TupleRouterM$SENDING_BIT ^ 0xFFFF;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t MultiHopEngineM$SendMsg$send(uint8_t arg_0x1ec4010, uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088){
#line 48
  unsigned char result;
#line 48

#line 48
  result = QueuedSendM$QueueSendMsg$send(arg_0x1ec4010, arg_0x17d4d80, arg_0x17d4ef8, arg_0x17d3088);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteSelect.nc"
inline static  result_t MultiHopEngineM$RouteSelect$selectRoute(TOS_MsgPtr arg_0x1ef6b90, uint8_t arg_0x1ef6d08){
#line 71
  unsigned char result;
#line 71

#line 71
  result = MultiHopLEPSM$RouteSelect$selectRoute(arg_0x1ef6b90, arg_0x1ef6d08);
#line 71

#line 71
  return result;
#line 71
}
#line 71
# 586 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$RouteSelect$initializeFields(TOS_MsgPtr Msg, uint8_t id)
#line 586
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];

  pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
  pMHMsg->hopcount = MultiHopLEPSM$ROUTE_INVALID;

  return SUCCESS;
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteSelect.nc"
inline static  result_t MultiHopEngineM$RouteSelect$initializeFields(TOS_MsgPtr arg_0x1ef5340, uint8_t arg_0x1ef54b8){
#line 86
  unsigned char result;
#line 86

#line 86
  result = MultiHopLEPSM$RouteSelect$initializeFields(arg_0x1ef5340, arg_0x1ef54b8);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 160 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  result_t MultiHopEngineM$Send$send(uint8_t id, TOS_MsgPtr pMsg, uint16_t PayloadLen)
#line 160
{

  uint16_t usMHLength = (size_t )& ((TOS_MHopMsg *)0)->data + PayloadLen;

  if (usMHLength > 89) {
      return FAIL;
    }



  MultiHopEngineM$RouteSelect$initializeFields(pMsg, id);

  if (MultiHopEngineM$RouteSelect$selectRoute(pMsg, id) != SUCCESS) {
      return FAIL;
    }



  if (MultiHopEngineM$SendMsg$send(id, pMsg->addr, usMHLength, pMsg) != SUCCESS) {
      return FAIL;
    }

  return SUCCESS;
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
inline static  result_t NetworkMultiHopM$Send$send(TOS_MsgPtr arg_0x17c4a58, uint16_t arg_0x17c4bd8){
#line 83
  unsigned char result;
#line 83

#line 83
  result = MultiHopEngineM$Send$send(kDATA_MESSAGE_ID, arg_0x17c4a58, arg_0x17c4bd8);
#line 83

#line 83
  return result;
#line 83
}
#line 83
# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  TinyDBError NetworkMultiHopM$Network$sendDataMessage(TOS_MsgPtr msg)
{




  if (NetworkMultiHopM$Send$send(msg, sizeof(QueryResult )) == FAIL) {
    return err_MessageSendFailed;
    }


  return err_NoError;
}

# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  TinyDBError TupleRouterM$Network$sendDataMessage(TOS_MsgPtr arg_0x17b9120){
#line 98
  unsigned char result;
#line 98

#line 98
  result = NetworkMultiHopM$Network$sendDataMessage(arg_0x17b9120);
#line 98

#line 98
  return result;
#line 98
}
#line 98
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
inline static  void *NetworkMultiHopM$Send$getBuffer(TOS_MsgPtr arg_0x17c3328, uint16_t *arg_0x17c34c8){
#line 106
  void *result;
#line 106

#line 106
  result = MultiHopEngineM$Send$getBuffer(kDATA_MESSAGE_ID, arg_0x17c3328, arg_0x17c34c8);
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 173 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  QueryResultPtr NetworkMultiHopM$Network$getDataPayLoad(TOS_MsgPtr msg)
{
  uint16_t len;

#line 176
  return (QueryResultPtr )NetworkMultiHopM$Send$getBuffer(msg, &len);
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  QueryResultPtr TupleRouterM$Network$getDataPayLoad(TOS_MsgPtr arg_0x17baa98){
#line 91
  struct QueryResult *result;
#line 91

#line 91
  result = NetworkMultiHopM$Network$getDataPayLoad(arg_0x17baa98);
#line 91

#line 91
  return result;
#line 91
}
#line 91
# 428 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_SENDING_MESSAGE(void)
#line 428
{
#line 428
  TupleRouterM$mPendingMask |= TupleRouterM$SENDING_BIT;
}

#line 426
static inline bool TupleRouterM$IS_SENDING_MESSAGE(void)
#line 426
{
#line 426
  return (TupleRouterM$mPendingMask & TupleRouterM$SENDING_BIT) != 0;
}

#line 3590
static inline  TinyDBError TupleRouterM$RadioQueue$enqueue(const QueryResultPtr qrMsg, bool *pending)
#line 3590
{



  if (!TupleRouterM$IS_SENDING_MESSAGE()) 
    {
      QueryResultPtr newQrMsg;

#line 3597
      TupleRouterM$SET_SENDING_MESSAGE();

      newQrMsg = TupleRouterM$Network$getDataPayLoad(&TupleRouterM$mMsg);
      *newQrMsg = *qrMsg;
      *pending = TRUE;
      TupleRouterM$mSendingResult = TRUE;

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 3604
        {
          TupleRouterM$mTimestampMsg = &TupleRouterM$mMsg;
          TupleRouterM$mMustTimestamp = TupleRouterM$TS_QUERY_RESULT_MESSAGE;
        }
#line 3607
        __nesc_atomic_end(__nesc_atomic); }
      if (TupleRouterM$Network$sendDataMessage(&TupleRouterM$mMsg) != err_NoError) {

          TupleRouterM$mSendFailed++;
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 3611
            {
              TupleRouterM$mMustTimestamp = TupleRouterM$TS_NO;
            }
#line 3613
            __nesc_atomic_end(__nesc_atomic); }






          *pending = FALSE;

          TupleRouterM$UNSET_SENDING_MESSAGE();
          TupleRouterM$mSendingResult = FALSE;
          return err_MSF_SendWaitingBusy;
        }
      else {
#line 3626
        TupleRouterM$mSendFailed = 0;
        }
    }
  else {
      *pending = FALSE;
      return err_MSF_SendWaitingBusy;
    }

  return err_NoError;
}

# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/RadioQueue.nc"
inline static  TinyDBError DBBufferC$RadioQueue$enqueue(const QueryResultPtr arg_0x20e4678, bool *arg_0x20e4810){
#line 46
  unsigned char result;
#line 46

#line 46
  result = TupleRouterM$RadioQueue$enqueue(arg_0x20e4678, arg_0x20e4810);
#line 46

#line 46
  return result;
#line 46
}
#line 46
# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline uint8_t MultiHopLEPSM$findEntryToBeReplaced(void)
#line 179
{
  uint8_t i = 0;
  uint8_t minSendEst = -1;
  uint8_t minSendEstIndex = MultiHopLEPSM$ROUTE_INVALID;

#line 183
  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
      if ((MultiHopLEPSM$NeighborTbl[i].flags & MultiHopLEPSM$NBRFLAG_VALID) == 0) {
          return i;
        }
      if (minSendEst >= MultiHopLEPSM$NeighborTbl[i].sendEst) {
          minSendEst = MultiHopLEPSM$NeighborTbl[i].sendEst;
          minSendEstIndex = i;
        }
    }
  return minSendEstIndex;
}

#line 161
static inline uint8_t MultiHopLEPSM$findEntry(uint8_t id)
#line 161
{
  uint8_t i = 0;

#line 163
  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
      if (MultiHopLEPSM$NeighborTbl[i].flags & MultiHopLEPSM$NBRFLAG_VALID && MultiHopLEPSM$NeighborTbl[i].id == id) {
          return i;
        }
    }
  return MultiHopLEPSM$ROUTE_INVALID;
}

#line 229
static inline uint8_t MultiHopLEPSM$findPreparedIndex(uint16_t id)
#line 229
{
  uint8_t indes = MultiHopLEPSM$findEntry(id);

#line 231
  if (indes == (uint8_t )MultiHopLEPSM$ROUTE_INVALID) {
      indes = MultiHopLEPSM$findEntryToBeReplaced();
      MultiHopLEPSM$newEntry(indes, id);
    }
  return indes;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/NoLeds.nc"
static inline   result_t NoLeds$Leds$greenToggle(void)
#line 75
{
  return SUCCESS;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t QueuedSendM$Leds$greenToggle(void){
#line 106
  unsigned char result;
#line 106

#line 106
  result = NoLeds$Leds$greenToggle();
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 159 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline void AMPromiscuous$dbgPacket(TOS_MsgPtr data)
#line 159
{
  uint8_t i;

  for (i = 0; i < sizeof(TOS_Msg ); i++) 
    {
      {
      }
#line 164
      ;
    }
  {
  }
#line 166
  ;
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
inline static   uint16_t CC2420RadioM$Random$rand(void){
#line 63
  unsigned int result;
#line 63

#line 63
  result = RandomLFSR$Random$rand();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 744 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline    int16_t CC2420RadioM$MacBackoff$default$initialBackoff(TOS_MsgPtr m)
#line 744
{
  return (CC2420RadioM$Random$rand() & 0xF) + 1;
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/MacBackoff.nc"
inline static   int16_t CC2420RadioM$MacBackoff$initialBackoff(TOS_MsgPtr arg_0x18c1850){
#line 74
  int result;
#line 74

#line 74
  result = CC2420RadioM$MacBackoff$default$initialBackoff(arg_0x18c1850);
#line 74

#line 74
  return result;
#line 74
}
#line 74
# 6 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
inline static   result_t CC2420RadioM$BackoffTimerJiffy$setOneShot(uint32_t arg_0x1921100){
#line 6
  unsigned char result;
#line 6

#line 6
  result = TimerJiffyAsyncM$TimerJiffyAsync$setOneShot(arg_0x1921100);
#line 6

#line 6
  return result;
#line 6
}
#line 6
# 128 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static __inline result_t CC2420RadioM$setInitialTimer(uint16_t jiffy)
#line 128
{
  CC2420RadioM$stateTimer = CC2420RadioM$TIMER_INITIAL;
  if (jiffy == 0) {

    return CC2420RadioM$BackoffTimerJiffy$setOneShot(2);
    }
#line 133
  return CC2420RadioM$BackoffTimerJiffy$setOneShot(jiffy);
}

# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/byteorder.h"
static __inline int is_host_lsb(void)
{
  const uint8_t n[2] = { 1, 0 };

#line 15
  return * (uint16_t *)n == 1;
}

static __inline uint16_t toLSB16(uint16_t a)
{
  return is_host_lsb() ? a : (a << 8) | (a >> 8);
}

# 491 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$Send$send(TOS_MsgPtr pMsg)
#line 491
{
  uint8_t currentstate;

#line 493
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 493
    currentstate = CC2420RadioM$stateRadio;
#line 493
    __nesc_atomic_end(__nesc_atomic); }

  if (currentstate == CC2420RadioM$IDLE_STATE) {

      pMsg->fcflo = 0x08;
      if (CC2420RadioM$bAckEnable) {
        pMsg->fcfhi = 0x21;
        }
      else {
#line 501
        pMsg->fcfhi = 0x01;
        }
      pMsg->destpan = TOS_BCAST_ADDR;

      pMsg->addr = toLSB16(pMsg->addr);

      pMsg->length = pMsg->length + MSG_HEADER_SIZE + MSG_FOOTER_SIZE;

      pMsg->dsn = ++CC2420RadioM$currentDSN;

      pMsg->time = 0;

      CC2420RadioM$txlength = pMsg->length - MSG_FOOTER_SIZE;
      CC2420RadioM$txbufptr = pMsg;
      CC2420RadioM$countRetry = 8;

      if (CC2420RadioM$setInitialTimer(CC2420RadioM$MacBackoff$initialBackoff(CC2420RadioM$txbufptr) * 10)) {
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 518
            CC2420RadioM$stateRadio = CC2420RadioM$PRE_TX_STATE;
#line 518
            __nesc_atomic_end(__nesc_atomic); }
          return SUCCESS;
        }
    }
  return FAIL;
}

# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t AMPromiscuous$RadioSend$send(TOS_MsgPtr arg_0x184d4a8){
#line 58
  unsigned char result;
#line 58

#line 58
  result = CC2420RadioM$Send$send(arg_0x184d4a8);
#line 58

#line 58
  return result;
#line 58
}
#line 58
# 306 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  result_t FramerM$BareSendMsg$send(TOS_MsgPtr pMsg)
#line 306
{
  result_t Result = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 309
    {
      if (!(FramerM$gFlags & FramerM$FLAGS_DATAPEND)) {
          FramerM$gFlags |= FramerM$FLAGS_DATAPEND;
          FramerM$gpTxMsg = pMsg;
        }
      else 

        {
          Result = FAIL;
        }
    }
#line 319
    __nesc_atomic_end(__nesc_atomic); }

  if (Result == SUCCESS) {
      Result = FramerM$StartTx();
    }

  return Result;
}

# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t AMPromiscuous$UARTSend$send(TOS_MsgPtr arg_0x184d4a8){
#line 58
  unsigned char result;
#line 58

#line 58
  result = FramerM$BareSendMsg$send(arg_0x184d4a8);
#line 58

#line 58
  return result;
#line 58
}
#line 58
# 193 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  void AMPromiscuous$sendTask(void)
#line 193
{
  result_t ok;

  if (AMPromiscuous$buffer->addr == TOS_UART_ADDR) {
    ok = AMPromiscuous$UARTSend$send(AMPromiscuous$buffer);
    }
  else {
#line 199
    ok = AMPromiscuous$RadioSend$send(AMPromiscuous$buffer);
    }
  if (ok == FAIL) {
    AMPromiscuous$reportSendDone(AMPromiscuous$buffer, FAIL);
    }
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t AMPromiscuous$Leds$greenToggle(void){
#line 106
  unsigned char result;
#line 106

#line 106
  result = NoLeds$Leds$greenToggle();
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 206 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  result_t AMPromiscuous$SendMsg$send(uint8_t id, uint16_t addr, uint8_t length, TOS_MsgPtr data)
#line 206
{
  if (!AMPromiscuous$state) {
      AMPromiscuous$state = TRUE;
      AMPromiscuous$Leds$greenToggle();

      if (length > DATA_LENGTH) {
          {
          }
#line 212
          ;
          AMPromiscuous$state = FALSE;
          return FAIL;
        }
      if (!TOS_post(AMPromiscuous$sendTask)) {
          {
          }
#line 217
          ;
          AMPromiscuous$state = FALSE;
          return FAIL;
        }
      else {
          AMPromiscuous$buffer = data;
          data->length = length;
          data->addr = addr;
          data->type = id;
          AMPromiscuous$buffer->group = TOS_AM_GROUP;
          AMPromiscuous$dbgPacket(data);
          {
          }
#line 228
          ;
        }
      return SUCCESS;
    }

  return FAIL;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t QueuedSendM$SerialSendMsg$send(uint8_t arg_0x1f8c4d8, uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088){
#line 48
  unsigned char result;
#line 48

#line 48
  result = AMPromiscuous$SendMsg$send(arg_0x1f8c4d8, arg_0x17d4d80, arg_0x17d4ef8, arg_0x17d3088);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 408 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
static inline   result_t HPLUSART1M$USARTControl$tx(uint8_t data)
#line 408
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 409
    {
      HPLUSART1M$U1TXBUF = data;
    }
#line 411
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLUARTM$USARTControl$tx(uint8_t arg_0x1a693b8){
#line 202
  unsigned char result;
#line 202

#line 202
  result = HPLUSART1M$USARTControl$tx(arg_0x1a693b8);
#line 202

#line 202
  return result;
#line 202
}
#line 202
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$UART$put(uint8_t data)
#line 98
{
  return HPLUARTM$USARTControl$tx(data);
}

# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t UARTM$HPLUART$put(uint8_t arg_0x1db5958){
#line 80
  unsigned char result;
#line 80

#line 80
  result = HPLUARTM$UART$put(arg_0x1db5958);
#line 80

#line 80
  return result;
#line 80
}
#line 80
# 207 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  result_t AMStandard$UARTSend$sendDone(TOS_MsgPtr msg, result_t success)
#line 207
{
  return AMStandard$reportSendDone(msg, success);
}

# 236 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  result_t AMPromiscuous$UARTSend$sendDone(TOS_MsgPtr msg, result_t success)
#line 236
{
  return AMPromiscuous$reportSendDone(msg, success);
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t FramerM$BareSendMsg$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0){
#line 67
  unsigned char result;
#line 67

#line 67
  result = AMPromiscuous$UARTSend$sendDone(arg_0x184da30, arg_0x184dbb0);
#line 67
  result = rcombine(result, AMStandard$UARTSend$sendDone(arg_0x184da30, arg_0x184dbb0));
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 290 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$SendStatusMsg$sendDone(TOS_MsgPtr msg, result_t success)
{
  return SUCCESS;
}

# 2537 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$Network$sendQueryDone(TOS_MsgPtr msg, result_t success)
{
  return TupleRouterM$outputDone(msg);
}

# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  result_t NetworkMultiHopM$Network$sendQueryDone(TOS_MsgPtr arg_0x17b7c28, result_t arg_0x17b7da8){
#line 162
  unsigned char result;
#line 162

#line 162
  result = TupleRouterM$Network$sendQueryDone(arg_0x17b7c28, arg_0x17b7da8);
#line 162

#line 162
  return result;
#line 162
}
#line 162
# 253 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$SendQueryMsg$sendDone(TOS_MsgPtr msg, result_t success)
{
  NetworkMultiHopM$Network$sendQueryDone(msg, success);
  return SUCCESS;
}

# 734 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$SendMsg$sendDone(TOS_MsgPtr pMsg, result_t success)
#line 734
{
  MultiHopLEPSM$gfSendRouteBusy = FALSE;

  return SUCCESS;
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t QueuedSendM$QueueSendMsg$sendDone(uint8_t arg_0x1f8da10, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698){
#line 49
  unsigned char result;
#line 49

#line 49
  result = MultiHopEngineM$SendMsg$sendDone(arg_0x1f8da10, arg_0x17d3518, arg_0x17d3698);
#line 49
  switch (arg_0x1f8da10) {
#line 49
    case kQUERY_MESSAGE_ID:
#line 49
      result = rcombine(result, NetworkMultiHopM$SendQueryMsg$sendDone(arg_0x17d3518, arg_0x17d3698));
#line 49
      break;
#line 49
    case kSTATUS_MESSAGE_ID:
#line 49
      result = rcombine(result, NetworkMultiHopM$SendStatusMsg$sendDone(arg_0x17d3518, arg_0x17d3698));
#line 49
      break;
#line 49
    case AM_MULTIHOPMSG:
#line 49
      result = rcombine(result, MultiHopLEPSM$SendMsg$sendDone(arg_0x17d3518, arg_0x17d3698));
#line 49
      break;
#line 49
  }
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/NoLeds.nc"
static inline   result_t NoLeds$Leds$redToggle(void)
#line 63
{
  return SUCCESS;
}

# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t QueuedSendM$Leds$redToggle(void){
#line 81
  unsigned char result;
#line 81

#line 81
  result = NoLeds$Leds$redToggle();
#line 81

#line 81
  return result;
#line 81
}
#line 81
# 188 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
static inline  result_t QueuedSendM$SerialSendMsg$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success)
#line 188
{
  if (msg != QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg) {
      return FAIL;
    }


  if ((!QueuedSendM$retransmit || msg->ack != 0) || QueuedSendM$msgqueue[QueuedSendM$dequeue_next].address == TOS_UART_ADDR) {

      QueuedSendM$QueueSendMsg$sendDone(id, msg, success);
      QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg = NULL;
      {
      }
#line 198
      ;
      QueuedSendM$dequeue_next++;
#line 199
      QueuedSendM$dequeue_next %= QueuedSendM$MESSAGE_QUEUE_SIZE;
    }
  else 







    {
      QueuedSendM$Leds$redToggle();
      if (++ QueuedSendM$msgqueue[QueuedSendM$dequeue_next].xmit_count > QueuedSendM$MAX_RETRANSMIT_COUNT) {


          QueuedSendM$QueueSendMsg$sendDone(id, msg, FAIL);
          QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg = NULL;
          QueuedSendM$dequeue_next++;
#line 216
          QueuedSendM$dequeue_next %= QueuedSendM$MESSAGE_QUEUE_SIZE;
        }
    }


  TOS_post(QueuedSendM$QueueServiceTask);

  return SUCCESS;
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t AMPromiscuous$SendMsg$sendDone(uint8_t arg_0x1fd7930, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698){
#line 49
  unsigned char result;
#line 49

#line 49
  result = QueuedSendM$SerialSendMsg$sendDone(arg_0x1fd7930, arg_0x17d3518, arg_0x17d3698);
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 2527 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$Network$sendDataDone(TOS_MsgPtr msg, result_t success)
{
  return TupleRouterM$outputDone(msg);
}

# 112 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  result_t NetworkMultiHopM$Network$sendDataDone(TOS_MsgPtr arg_0x17b96e0, result_t arg_0x17b9860){
#line 112
  unsigned char result;
#line 112

#line 112
  result = TupleRouterM$Network$sendDataDone(arg_0x17b96e0, arg_0x17b9860);
#line 112

#line 112
  return result;
#line 112
}
#line 112
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t NetworkMultiHopM$Leds$redToggle(void){
#line 81
  unsigned char result;
#line 81

#line 81
  result = LedsC$Leds$redToggle();
#line 81

#line 81
  return result;
#line 81
}
#line 81
# 209 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$Send$sendDone(TOS_MsgPtr msg, result_t success)
{
  if (success == SUCCESS) {
#line 211
    NetworkMultiHopM$Leds$redToggle();
    }
#line 212
  NetworkMultiHopM$Network$sendDataDone(msg, success);
  return SUCCESS;
}

# 301 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline   result_t MultiHopEngineM$Send$default$sendDone(uint8_t id, TOS_MsgPtr pMsg, result_t success)
#line 301
{
  return SUCCESS;
}

# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Send.nc"
inline static  result_t MultiHopEngineM$Send$sendDone(uint8_t arg_0x1ec6010, TOS_MsgPtr arg_0x17c3d68, result_t arg_0x17c3ee8){
#line 119
  unsigned char result;
#line 119

#line 119
  switch (arg_0x1ec6010) {
#line 119
    case kDATA_MESSAGE_ID:
#line 119
      result = NetworkMultiHopM$Send$sendDone(arg_0x17c3d68, arg_0x17c3ee8);
#line 119
      break;
#line 119
    default:
#line 119
      result = MultiHopEngineM$Send$default$sendDone(arg_0x1ec6010, arg_0x17c3d68, arg_0x17c3ee8);
#line 119
    }
#line 119

#line 119
  return result;
#line 119
}
#line 119
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$redOn(void)
#line 72
{
  {
  }
#line 73
  ;
  {
    TOSH_CLR_RED_LED_PIN();
    LedsC$ledsOn |= LedsC$RED_BIT;
  }
  return SUCCESS;
}

# 188 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline   result_t AMPromiscuous$default$sendDone(void)
#line 188
{
  return SUCCESS;
}

#line 67
inline static  result_t AMPromiscuous$sendDone(void){
#line 67
  unsigned char result;
#line 67

#line 67
  result = AMPromiscuous$default$sendDone();
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 157 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline   result_t AMStandard$SendMsg$default$sendDone(uint8_t id, TOS_MsgPtr msg, result_t success)
#line 157
{
  return SUCCESS;
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t AMStandard$SendMsg$sendDone(uint8_t arg_0x1824218, TOS_MsgPtr arg_0x17d3518, result_t arg_0x17d3698){
#line 49
  unsigned char result;
#line 49

#line 49
    result = AMStandard$SendMsg$default$sendDone(arg_0x1824218, arg_0x17d3518, arg_0x17d3698);
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 160 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline   result_t AMStandard$default$sendDone(void)
#line 160
{
  return SUCCESS;
}

#line 65
inline static  result_t AMStandard$sendDone(void){
#line 65
  unsigned char result;
#line 65

#line 65
  result = AMStandard$default$sendDone();
#line 65

#line 65
  return result;
#line 65
}
#line 65
# 424 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_DELIVERING_TUPLES(void)
#line 424
{
#line 424
  TupleRouterM$mPendingMask |= TupleRouterM$DELIVERING_BIT;
}

# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline AggOperator$GroupRecord *AggOperator$GET_GROUP_DATA(AggOperator$GroupDataHandle dHan, uint8_t n)
#line 162
{
  return (AggOperator$GroupRecord *)&(*dHan)->groupData[n * (*dHan)->groupSize];
}

#line 326
static inline  result_t AggOperator$Operator$endOfEpoch(ParsedQueryPtr q, ExprPtr e)
#line 326
{
  AggOperator$GroupDataHandle gdh = (AggOperator$GroupDataHandle )e->opState;
  AggOperator$GroupRecord *gr;

  if (e->opType != kSEL && gdh != NULL) {
      short i;

#line 332
      for (i = 0; i < (*gdh)->numGroups; i++) {
          gr = AggOperator$GET_GROUP_DATA(gdh, i);
          AggOperator$initAggregateValue(gr, e, FALSE);
        }
    }


  return SUCCESS;
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  result_t TupleRouterM$AggOperator$endOfEpoch(ParsedQueryPtr arg_0x2098800, ExprPtr arg_0x2098978){
#line 101
  unsigned char result;
#line 101

#line 101
  result = AggOperator$Operator$endOfEpoch(arg_0x2098800, arg_0x2098978);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  ExprPtr TupleRouterM$ParsedQueryIntf$getExprPtr(ParsedQueryPtr arg_0x206b960, uint8_t arg_0x206bad8){
#line 54
  struct __nesc_unnamed4310 *result;
#line 54

#line 54
  result = ParsedQuery$ParsedQueryIntf$getExprPtr(arg_0x206b960, arg_0x206bad8);
#line 54

#line 54
  return result;
#line 54
}
#line 54









inline static  TuplePtr TupleRouterM$ParsedQueryIntf$getTuplePtr(ParsedQueryPtr arg_0x2069df0){
#line 63
  struct __nesc_unnamed4288 *result;
#line 63

#line 63
  result = ParsedQuery$ParsedQueryIntf$getTuplePtr(arg_0x2069df0);
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 246 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$TupleIntf$tupleInit(ParsedQueryPtr q, TuplePtr t)
#line 246
{
  t->notNull = 0;
  t->qid = q->qid;
  t->numFields = q->numFields;

  return SUCCESS;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  result_t TupleRouterM$TupleIntf$tupleInit(ParsedQueryPtr arg_0x2040f30, TuplePtr arg_0x207a0c8){
#line 106
  unsigned char result;
#line 106

#line 106
  result = Tuple$TupleIntf$tupleInit(arg_0x2040f30, arg_0x207a0c8);
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 2664 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$resetTupleState(ParsedQuery *q)
#line 2664
{
  short i;
  Expr *e;





  TupleRouterM$TupleIntf$tupleInit(q, TupleRouterM$ParsedQueryIntf$getTuplePtr(q));
  for (i = 0; i < q->numExprs; i++) {
      e = TupleRouterM$ParsedQueryIntf$getExprPtr(q, i);
      TupleRouterM$AggOperator$endOfEpoch(q, e);
    }
}

# 241 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregates.h"
static inline uint8_t getMergingLimit(ParamVals *v)
#line 241
{
  return * (uint8_t *)v->paramDataPtr[kMERGING_LIMIT];
}

#line 237
static inline uint8_t getErrorBound(ParamVals *v)
#line 237
{
  return * (uint8_t *)v->paramDataPtr[kERROR_BOUND];
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline void ContourMapM$initializeLocation(void)
#line 91
{
  if (TOS_LOCAL_ADDRESS == 1) 
    {
#line 93
      ContourMapM$loc_x = 10;
#line 93
      ContourMapM$loc_y = 10;
    }
  else {
#line 95
    if (TOS_LOCAL_ADDRESS == 2) 
      {
#line 96
        ContourMapM$loc_x = 30;
#line 96
        ContourMapM$loc_y = 10;
      }
    else {
#line 98
      if (TOS_LOCAL_ADDRESS == 3) 
        {
#line 99
          ContourMapM$loc_x = 10;
#line 99
          ContourMapM$loc_y = 30;
        }
      else {
#line 101
        if (TOS_LOCAL_ADDRESS == 4) 
          {
#line 102
            ContourMapM$loc_x = 30;
#line 102
            ContourMapM$loc_y = 30;
          }
        else {
#line 104
          if (TOS_LOCAL_ADDRESS == 5) 
            {
#line 105
              ContourMapM$loc_x = 50;
#line 105
              ContourMapM$loc_y = 10;
            }
          else {
#line 107
            if (TOS_LOCAL_ADDRESS == 6) 
              {
#line 108
                ContourMapM$loc_x = 50;
#line 108
                ContourMapM$loc_y = 30;
              }
            else {
#line 110
              if (TOS_LOCAL_ADDRESS == 7) 
                {
#line 111
                  ContourMapM$loc_x = 10;
#line 111
                  ContourMapM$loc_y = 50;
                }
              else {
#line 113
                if (TOS_LOCAL_ADDRESS == 8) 
                  {
#line 114
                    ContourMapM$loc_x = 30;
#line 114
                    ContourMapM$loc_y = 50;
                  }
                else {
#line 116
                  if (TOS_LOCAL_ADDRESS == 9) 
                    {
#line 117
                      ContourMapM$loc_x = 50;
#line 117
                      ContourMapM$loc_y = 50;
                    }
                  else {
#line 119
                    if (TOS_LOCAL_ADDRESS == 10) 
                      {
#line 120
                        ContourMapM$loc_x = 70;
#line 120
                        ContourMapM$loc_y = 10;
                      }
                    else {
#line 122
                      if (TOS_LOCAL_ADDRESS == 11) 
                        {
#line 123
                          ContourMapM$loc_x = 70;
#line 123
                          ContourMapM$loc_y = 30;
                        }
                      else {
#line 125
                        if (TOS_LOCAL_ADDRESS == 12) 
                          {
#line 126
                            ContourMapM$loc_x = 70;
#line 126
                            ContourMapM$loc_y = 50;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
}

#line 322
static inline  result_t ContourMapM$Aggregate$init(char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime)
#line 322
{

  int16_t *A;



  ContourMapM$mymap = (ContourMapM$ContourMap *)data;

  if (TOS_LOCAL_ADDRESS == 0) {
    ContourMapM$mymap->regionNum = 0;
    }
  else {
      ContourMapM$initializeLocation();

      ContourMapM$mymap->regions[0].boundaries[0].vertices[0].x = ContourMapM$loc_x - 20 / 2;
      ContourMapM$mymap->regions[0].boundaries[0].vertices[0].y = ContourMapM$loc_y - 20 / 2;
      ContourMapM$mymap->regions[0].boundaries[0].vertices[1].x = ContourMapM$loc_x + 20 / 2;
      ContourMapM$mymap->regions[0].boundaries[0].vertices[1].y = ContourMapM$loc_y + 20 / 2;
      ContourMapM$mymap->regionNum = 1;

      ContourMapM$x[0] = ContourMapM$loc_x;
#line 342
      ContourMapM$y[0] = ContourMapM$loc_y;
      ContourMapM$x[1] = ContourMapM$loc_x;
#line 343
      ContourMapM$y[1] = ContourMapM$loc_y + 5;
      ContourMapM$x[2] = ContourMapM$loc_x + 5;
#line 344
      ContourMapM$y[2] = ContourMapM$loc_y;
      A = (int16_t *)ContourMapM$mymap->regions[0].regression.A;
      A[0] = ContourMapM$x[0] + ContourMapM$x[1] + ContourMapM$x[2];
      A[1] = ContourMapM$y[0] + ContourMapM$y[1] + ContourMapM$y[2];
      A[2] = ContourMapM$x[0] * ContourMapM$x[0] + ContourMapM$x[1] * ContourMapM$x[1] + ContourMapM$x[2] * ContourMapM$x[2];
      A[3] = ContourMapM$x[0] * ContourMapM$y[0] + ContourMapM$x[1] * ContourMapM$y[1] + ContourMapM$x[2] * ContourMapM$y[2];
      A[4] = ContourMapM$y[0] * ContourMapM$y[0] + ContourMapM$y[1] * ContourMapM$y[1] + ContourMapM$y[2] * ContourMapM$y[2];
    }


  if (isFirstTime) 
    {
      ContourMapM$errorBound = getErrorBound(paramValues);
      ContourMapM$mergingLimit = getMergingLimit(paramValues);
    }

  return SUCCESS;
}

# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 130
result_t AggregateUseM$Agg$default$init(uint8_t id, 
char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime)
#line 131
{
  return SUCCESS;
}

# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  result_t AggregateUseM$Agg$init(uint8_t arg_0x255b358, char *arg_0x25544e0, ParamList *arg_0x2554680, ParamVals *arg_0x2554828, bool arg_0x25549a8){
#line 93
  unsigned char result;
#line 93

#line 93
  switch (arg_0x255b358) {
#line 93
    case kCONTOUR_MAP:
#line 93
      result = ContourMapM$Aggregate$init(arg_0x25544e0, arg_0x2554680, arg_0x2554828, arg_0x25549a8);
#line 93
      break;
#line 93
    default:
#line 93
      result = AggregateUseM$Agg$default$init(arg_0x255b358, arg_0x25544e0, arg_0x2554680, arg_0x2554828, arg_0x25549a8);
#line 93
    }
#line 93

#line 93
  return result;
#line 93
}
#line 93
# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  result_t AggregateUseM$AggregateUse$init(uint8_t id, char *data, ParamList *params, ParamVals *paramValues, bool isFirstTime)
#line 97
{
  return AggregateUseM$Agg$init(id, data, params, paramValues, isFirstTime);
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  result_t AggOperator$AggregateUse$init(uint8_t arg_0x2483c80, char *arg_0x2483e10, ParamList *arg_0x2481010, ParamVals *arg_0x24811b8, bool arg_0x2481338){
#line 92
  unsigned char result;
#line 92

#line 92
  result = AggregateUseM$AggregateUse$init(arg_0x2483c80, arg_0x2483e10, arg_0x2481010, arg_0x24811b8, arg_0x2481338);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$initQueryResult(QueryResultPtr qr)
#line 108
{

  qr->qrType = kUNDEFINED;
  qr->result_idx = 0;

  return err_NoError;
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError TupleRouterM$QueryResultIntf$initQueryResult(QueryResultPtr arg_0x20913d8){
#line 83
  unsigned char result;
#line 83

#line 83
  result = QueryResult$QueryResultIntf$initQueryResult(arg_0x20913d8);
#line 83

#line 83
  return result;
#line 83
}
#line 83
# 346 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$addAggResult(QueryResultPtr qr, 
int16_t groupNo, 
char *bytes, 
int16_t size, 
ParsedQueryPtr q, 
short exprIdx)
#line 351
{

  if (size > QueryResult$BUF_SIZE) {
#line 353
    return err_OutOfMemory;
    }
#line 354
  if (qr->qrType == kNOT_AGG) {
#line 354
    return err_AlreadyTupleResult;
    }
  if (qr->qrType == kIS_AGG && qr->qid != q->qid) {
    return err_InvalidQueryId;
    }
  else 
#line 358
    {
      qr->qid = q->qid;
      qr->qrType = kIS_AGG;
    }
  qr->d.buf[(short )qr->result_idx].data = bytes;

  qr->d.buf[(short )qr->result_idx].group = groupNo;

  qr->result_idx++;

  return err_NoError;
}

# 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError AggOperator$QueryResultIntf$addAggResult(QueryResultPtr arg_0x208cec8, int16_t arg_0x208a068, char *arg_0x208a1f8, int16_t arg_0x208a370, ParsedQueryPtr arg_0x208a4f0, short arg_0x208a660){
#line 155
  unsigned char result;
#line 155

#line 155
  result = QueryResult$QueryResultIntf$addAggResult(arg_0x208cec8, arg_0x208a068, arg_0x208a1f8, arg_0x208a370, arg_0x208a4f0, arg_0x208a660);
#line 155

#line 155
  return result;
#line 155
}
#line 155
# 370 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline  bool ContourMapM$Aggregate$hasData(char *data, ParamList *params, ParamVals *paramValues)
#line 370
{
  return TRUE;
}

# 141 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 140
bool AggregateUseM$Agg$default$hasData(uint8_t id, 
char *data, ParamList *params, ParamVals *paramValues)
#line 141
{
  return FALSE;
}

# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  bool AggregateUseM$Agg$hasData(uint8_t arg_0x255b358, char *arg_0x2552f30, ParamList *arg_0x25510e8, ParamVals *arg_0x2551290){
#line 108
  unsigned char result;
#line 108

#line 108
  switch (arg_0x255b358) {
#line 108
    case kCONTOUR_MAP:
#line 108
      result = ContourMapM$Aggregate$hasData(arg_0x2552f30, arg_0x25510e8, arg_0x2551290);
#line 108
      break;
#line 108
    default:
#line 108
      result = AggregateUseM$Agg$default$hasData(arg_0x255b358, arg_0x2552f30, arg_0x25510e8, arg_0x2551290);
#line 108
    }
#line 108

#line 108
  return result;
#line 108
}
#line 108
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  bool AggregateUseM$AggregateUse$hasData(uint8_t id, char *data, ParamList *params, ParamVals *paramValues)
#line 105
{
  return AggregateUseM$Agg$hasData(id, data, params, paramValues);
}

# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  bool AggOperator$AggregateUse$hasData(uint8_t arg_0x2480068, char *arg_0x24801f8, ParamList *arg_0x2480398, ParamVals *arg_0x2480540){
#line 96
  unsigned char result;
#line 96

#line 96
  result = AggregateUseM$AggregateUse$hasData(arg_0x2480068, arg_0x24801f8, arg_0x2480398, arg_0x2480540);
#line 96

#line 96
  return result;
#line 96
}
#line 96
# 679 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline bool AggOperator$aggHasData(AggOperator$GroupRecord *gr, Expr *e)
#line 679
{
  ParamVals paramVals;

#line 681
  setParamValues(&paramVals, e);

  return AggOperator$AggregateUse$hasData(e->ex.agg.op, gr->aggdata, NULL, &paramVals);
}

#line 278
static inline  TinyDBError AggOperator$addResults(QueryResult *qr, ParsedQuery *pq, ExprPtr e)
#line 278
{

  int i = 0;
  AggOperator$GroupRecord *gr;
  AggOperator$GroupDataHandle gdh;
  TinyDBError err;



  gdh = (AggOperator$GroupDataHandle )e->opState;

  if (gdh == NULL) {
#line 289
    return err_NoError;
    }
  for (i = 0; i < (*gdh)->numGroups; i++) {

      gr = AggOperator$GET_GROUP_DATA(gdh, i);
      if (! gr->u.empty && AggOperator$aggHasData(gr, e)) {

          err = AggOperator$QueryResultIntf$addAggResult(qr, gr->groupNo, (char *)gr, (*gdh)->groupSize, pq, e->idx);

          if (err != err_NoError) {
              return err;
            }
          gr->u.exprIdx = e->idx;
        }
    }


  return err_NoError;
}

# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
inline static  TinyDBError TupleRouterM$addResults(QueryResult *arg_0x20f1858, ParsedQuery *arg_0x20f19f8, Expr *arg_0x20f1b90){
#line 167
  unsigned char result;
#line 167

#line 167
  result = AggOperator$addResults(arg_0x20f1858, arg_0x20f19f8, arg_0x20f1b90);
#line 167

#line 167
  return result;
#line 167
}
#line 167
# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  short TupleRouterM$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0){
#line 131
  short result;
#line 131

#line 131
  result = QueryResult$QueryResultIntf$numRecords(arg_0x208c030, arg_0x208c1b0);
#line 131

#line 131
  return result;
#line 131
}
#line 131
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$redToggle(void){
#line 81
  unsigned char result;
#line 81

#line 81
  result = LedsC$Leds$redToggle();
#line 81

#line 81
  return result;
#line 81
}
#line 81
# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Random.nc"
inline static   uint16_t TupleRouterM$Random$rand(void){
#line 63
  unsigned int result;
#line 63

#line 63
  result = RandomLFSR$Random$rand();
#line 63

#line 63
  return result;
#line 63
}
#line 63
# 3675 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  void TupleRouterM$statusMessage(CharPtr m)
#line 3675
{
  if (TOS_LOCAL_ADDRESS != 0) {
    }
}

# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  uint16_t QueryResult$TupleIntf$tupleSize(ParsedQueryPtr arg_0x2044190){
#line 45
  unsigned int result;
#line 45

#line 45
  result = Tuple$TupleIntf$tupleSize(arg_0x2044190);
#line 45

#line 45
  return result;
#line 45
}
#line 45
# 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$fromTuple(QueryResultPtr qr, ParsedQueryPtr pq, TuplePtr t)
#line 121
{
  short size = QueryResult$TupleIntf$tupleSize(pq);
  char *p;
#line 123
  char *q;

  qr->qrType = kNOT_AGG;
  qr->qid = pq->qid;
  qr->result_idx = 0;
  p = (char *)t;
  q = (char *)& qr->d.t;
  while (size--) 
    * q++ = * p++;
  return err_NoError;
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError TupleRouterM$QueryResultIntf$fromTuple(QueryResultPtr arg_0x20919b8, ParsedQueryPtr arg_0x2091b38, TuplePtr arg_0x2091cb8){
#line 91
  unsigned char result;
#line 91

#line 91
  result = QueryResult$QueryResultIntf$fromTuple(arg_0x20919b8, arg_0x2091b38, arg_0x2091cb8);
#line 91

#line 91
  return result;
#line 91
}
#line 91
# 132 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$size(uint8_t arg_0x20d2230, uint16_t *arg_0x20d23d0){
#line 132
  unsigned char result;
#line 132

#line 132
  result = DBBufferC$DBBuffer$size(arg_0x20d2230, arg_0x20d23d0);
#line 132

#line 132
  return result;
#line 132
}
#line 132
# 423 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_DELIVERING_TUPLES(void)
#line 423
{
#line 423
  TupleRouterM$mPendingMask &= TupleRouterM$DELIVERING_BIT ^ 0xFFFF;
}

# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$yellowToggle(void){
#line 131
  unsigned char result;
#line 131

#line 131
  result = LedsC$Leds$yellowToggle();
#line 131

#line 131
  return result;
#line 131
}
#line 131
# 2569 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$startFetchingTuples(void)
#line 2569
{
  TupleRouterM$QueryListHandle qlh = TupleRouterM$mQs;
  bool mustSample = FALSE;
  bool didReset = FALSE;
  bool needsNoData = TRUE;

  while (qlh != NULL) {

      if ((*qlh)->q.clocksPerSample > 0 && ! (*qlh)->q.needsData && (

      (*qlh)->q.clockCount == TupleRouterM$WAKING_CLOCKS || 

      (*qlh)->q.clockCount == (int16_t )(*qlh)->q.clocksPerSample)) 




        {


          didReset = TRUE;

          if (!(TOS_LOCAL_ADDRESS == 0) || (*qlh)->q.hasAgg) {
              (*qlh)->q.needsData = TRUE;
              needsNoData = FALSE;
            }
        }


      if ((*qlh)->q.running && (*qlh)->q.clocksPerSample > 0) {

          if (didReset) {
              didReset = FALSE;
              TupleRouterM$mLastHeard++;
              TupleRouterM$Leds$yellowToggle();


              if ((*qlh)->q.markedForDeletion > 0) {
                  if (-- (*qlh)->q.markedForDeletion == 0) {

                      TupleRouterM$mQidToRemove = (*qlh)->q.qid;
                      TupleRouterM$mForceRemove = TRUE;
                      TOS_post(TupleRouterM$removeQueryTask);
                    }
                  else 
#line 2612
                    {
                      (*qlh)->q.clockCount += (*qlh)->q.clocksPerSample;
                    }
                }
              else 
#line 2615
                {


                  if ((*qlh)->q.queryRoot != TOS_LOCAL_ADDRESS) {

                    mustSample = TRUE;
                    }
#line 2621
                  (*qlh)->q.currentEpoch++;
                }
            }

          (*qlh)->q.clockCount -= TupleRouterM$mClockCount;

          if (!TupleRouterM$mAllQueriesSameRate || (*qlh)->q.clocksPerSample <= TupleRouterM$WAKING_CLOCKS) {

              if ((*qlh)->q.clockCount <= 0) {
                  (*qlh)->q.clockCount = (*qlh)->q.clocksPerSample;
                }
            }
        }



      qlh = (TupleRouterM$QueryListHandle )(*qlh)->next;
    }
  TupleRouterM$mClockCount = 0;

  if (TupleRouterM$mQs) {
      qlh = TupleRouterM$mQs;
      if (TOS_LOCAL_ADDRESS == 0 && needsNoData && (*qlh)->q.clocksPerSample > TupleRouterM$kMIN_SLEEP_CLOCKS_PER_SAMPLE) {
          TupleRouterM$mWaitIsDummy = TRUE;


          if ((*qlh)->q.clocksPerSample >= TupleRouterM$WAKING_CLOCKS) {
            TupleRouterM$mDeliverWait = TupleRouterM$WAKING_CLOCKS / 2;
            }
          else {
            TupleRouterM$mDeliverWait = (*qlh)->q.clocksPerSample / 2;
            }
        }
    }

  if (mustSample) {

      TupleRouterM$fetchNextAttr();
    }
}

#line 447
static inline void TupleRouterM$UNSET_SNOOZING(void)
#line 447
{
#line 447
  TupleRouterM$mPendingMask &= TupleRouterM$SNOOZING_BIT ^ 0xFFFF;
}

# 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline   result_t ServiceSchedulerM$Services$default$stop(uint8_t id)
#line 143
{
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t ServiceSchedulerM$Services$stop(uint8_t arg_0x2903420){
#line 78
  unsigned char result;
#line 78

#line 78
  switch (arg_0x2903420) {
#line 78
    case kTINYDB_SERVICE_ID:
#line 78
      result = TupleRouterM$StdControl$stop();
#line 78
      break;
#line 78
    default:
#line 78
      result = ServiceSchedulerM$Services$default$stop(arg_0x2903420);
#line 78
    }
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 267 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$ServiceScheduler$remove(uint8_t svc_id)
#line 267
{
  result_t res = pqueue_remove((pqueue_t *)&ServiceSchedulerM$event_q, svc_id);

#line 269
  ServiceSchedulerM$Services$stop(svc_id);
  ServiceSchedulerM$sched_info[svc_id].flags = DISABLED;
  return res;
}

# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ServiceScheduler.nc"
inline static  result_t TupleRouterM$ServiceScheduler$remove(uint8_t arg_0x20ebbe0){
#line 82
  unsigned char result;
#line 82

#line 82
  result = ServiceSchedulerM$ServiceScheduler$remove(arg_0x20ebbe0);
#line 82

#line 82
  return result;
#line 82
}
#line 82
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$redOff(void)
#line 81
{
  {
  }
#line 82
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 83
    {
      TOSH_SET_RED_LED_PIN();
      LedsC$ledsOn &= ~LedsC$RED_BIT;
    }
#line 86
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$redOff(void){
#line 72
  unsigned char result;
#line 72

#line 72
  result = LedsC$Leds$redOff();
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$yellowOff(void)
#line 139
{
  {
  }
#line 140
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 141
    {
      TOSH_SET_YELLOW_LED_PIN();
      LedsC$ledsOn &= ~LedsC$YELLOW_BIT;
    }
#line 144
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$yellowOff(void){
#line 122
  unsigned char result;
#line 122

#line 122
  result = LedsC$Leds$yellowOff();
#line 122

#line 122
  return result;
#line 122
}
#line 122
# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$greenOff(void)
#line 110
{
  {
  }
#line 111
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 112
    {
      TOSH_SET_GREEN_LED_PIN();
      LedsC$ledsOn &= ~LedsC$GREEN_BIT;
    }
#line 115
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$greenOff(void){
#line 97
  unsigned char result;
#line 97

#line 97
  result = LedsC$Leds$greenOff();
#line 97

#line 97
  return result;
#line 97
}
#line 97
# 310 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$QueryProcessor$queryComplete(ParsedQueryPtr q)
#line 310
{
  return SUCCESS;
}

# 2383 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$QueryProcessor$queryComplete(ParsedQueryPtr q)
#line 2383
{
  uint8_t bufid;

  if (DBBufferC$DBBuffer$getBufferId(q->qid, FALSE, &bufid) == err_NoError) {
      DBBufferC$cleanupBuffer(bufid, 2387);
    }
  else 
#line 2388
    {
    }
#line 2423
  return SUCCESS;
}

# 529 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$QueryProcessor$queryComplete(ParsedQueryPtr q)
{
  return SUCCESS;
}

# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  int16_t AggOperator$MemAlloc$free(Handle arg_0x2084dd8){
#line 104
  int result;
#line 104

#line 104
  result = TinyAlloc$MemAlloc$free(arg_0x2084dd8);
#line 104

#line 104
  return result;
#line 104
}
#line 104
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  Expr AggOperator$ParsedQueryIntf$getExpr(ParsedQueryPtr arg_0x206b328, uint8_t arg_0x206b4a0){
#line 51
  struct __nesc_unnamed4310 result;
#line 51

#line 51
  result = ParsedQuery$ParsedQueryIntf$getExpr(arg_0x206b328, arg_0x206b4a0);
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 343 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline  result_t AggOperator$QueryProcessor$queryComplete(ParsedQuery *q)
#line 343
{
  short i;

  for (i = 0; i < q->numExprs; i++) {
      Expr e = AggOperator$ParsedQueryIntf$getExpr(q, i);

#line 348
      if (e.opType != kSEL && e.opState != NULL) {
          AggOperator$MemAlloc$free((Handle )e.opState);
          {
          }
#line 350
          ;
          e.opState = (OperatorStateHandle )AggOperator$QUERY_DONE_STATE;
        }
    }
  return SUCCESS;
}

# 307 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$QueryProcessor$queryComplete(ParsedQueryPtr q)
{
  return SUCCESS;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
inline static  result_t TupleRouterM$QueryProcessor$queryComplete(ParsedQueryPtr arg_0x17742f8){
#line 51
  unsigned char result;
#line 51

#line 51
  result = TinyDBAttrM$QueryProcessor$queryComplete(arg_0x17742f8);
#line 51
  result = rcombine(result, AggOperator$QueryProcessor$queryComplete(arg_0x17742f8));
#line 51
  result = rcombine(result, NetworkMultiHopM$QueryProcessor$queryComplete(arg_0x17742f8));
#line 51
  result = rcombine(result, DBBufferC$QueryProcessor$queryComplete(arg_0x17742f8));
#line 51
  result = rcombine(result, Tuple$QueryProcessor$queryComplete(arg_0x17742f8));
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 602 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline int8_t TinyAlloc$isValid(Handle h)
#line 602
{

  if (sizeof(int8_t *) == sizeof(int32_t )) {
      return *h >= (int8_t *)(&TinyAlloc$mFrame)[0] && *h < (int8_t *)&TinyAlloc$mFrame[TinyAlloc$FRAME_SIZE];
    }
  else {
#line 607
    if (sizeof(int8_t *) == sizeof(int16_t )) {
        return *h >= (int8_t *)(&TinyAlloc$mFrame)[0] && *h < (int8_t *)&TinyAlloc$mFrame[TinyAlloc$FRAME_SIZE];
      }
    else {
        return 0;
      }
    }
}

# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  int16_t DBBufferC$MemAlloc$free(Handle arg_0x2084dd8){
#line 104
  int result;
#line 104

#line 104
  result = TinyAlloc$MemAlloc$free(arg_0x2084dd8);
#line 104

#line 104
  return result;
#line 104
}
#line 104
# 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  TinyDBError TupleRouterM$TupleIntf$getNextEmptyFieldIdx(ParsedQueryPtr arg_0x2079340, TuplePtr arg_0x20794c0, uint8_t *arg_0x2079660){
#line 121
  unsigned char result;
#line 121

#line 121
  result = Tuple$TupleIntf$getNextEmptyFieldIdx(arg_0x2079340, arg_0x20794c0, arg_0x2079660);
#line 121

#line 121
  return result;
#line 121
}
#line 121
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr Tuple$AttrUse$getAttrById(uint8_t arg_0x204da90){
#line 72
  struct __nesc_unnamed4282 *result;
#line 72

#line 72
  result = Attr$AttrUse$getAttrById(arg_0x204da90);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 270 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  AttrDescPtr Tuple$TupleIntf$getNextQueryField(ParsedQueryPtr q, TuplePtr t)
#line 270
{
  uint8_t i;
  TinyDBError err;

  err = Tuple$TupleIntf$getNextEmptyFieldIdx(q, t, &i);
  if (err == err_NoError) {
      return Tuple$AttrUse$getAttrById(q->queryToSchemaFieldMap[i]);
    }
  else {
#line 278
    return NULL;
    }
}

# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  AttrDescPtr TupleRouterM$TupleIntf$getNextQueryField(ParsedQueryPtr arg_0x207ac38, TuplePtr arg_0x207adb8){
#line 114
  struct __nesc_unnamed4282 *result;
#line 114

#line 114
  result = Tuple$TupleIntf$getNextQueryField(arg_0x207ac38, arg_0x207adb8);
#line 114

#line 114
  return result;
#line 114
}
#line 114
# 2800 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline TupleRouterM$TupleFieldDesc TupleRouterM$getNextQueryField(ParsedQuery **pq)
#line 2800
{
  TupleRouterM$QueryListHandle qlh = TupleRouterM$mQs;
  AttrDescPtr attr = NULL;
  TupleRouterM$TupleFieldDesc d;
  TinyDBError err;
  uint8_t idx;

  d.isNull = TRUE;

  while (qlh != NULL) {
      if ((*qlh)->q.clocksPerSample > 0 && (*qlh)->q.needsData) {
          Tuple *t = TupleRouterM$ParsedQueryIntf$getTuplePtr(& (*qlh)->q);
          ParsedQuery *q = & (*qlh)->q;

#line 2813
          {
          }
#line 2813
          ;
          {
          }
#line 2814
          ;

          if (q->fromBuffer == kNO_QUERY) {
              attr = TupleRouterM$TupleIntf$getNextQueryField(q, t);
              if (attr != NULL) {
                  d.isAttr = TRUE;
                  d.u.attr = attr;
                  d.isNull = FALSE;
                  break;
                }
            }
          else 
#line 2824
            {

              err = TupleRouterM$TupleIntf$getNextEmptyFieldIdx(q, t, &idx);
              if (err == err_NoError) {
                  d.isAttr = FALSE;
                  d.u.tupleIdx = idx;
                  d.isNull = FALSE;
                  break;
                }
            }
        }
      qlh = (TupleRouterM$QueryListHandle )(*qlh)->next;
    }
  if (qlh == NULL) {
    *pq = NULL;
    }
  else {
#line 2840
    *pq = & (*qlh)->q;
    }
  return d;
}

# 195 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$TupleIntf$setFieldNoQuery(TuplePtr t, 
uint8_t fieldIdx, 
uint8_t numFields, 
uint8_t sizes[], 
uint8_t types[], 
CharPtr data)
#line 200
{
  char *dest = Tuple$TupleIntf$getFieldPtrNoQuery(t, fieldIdx, numFields, sizes, types);

#line 202
  if (dest != data) {
      nmemcpy(dest, data, sizes[fieldIdx]);
    }
  t->notNull |= 1 << fieldIdx;
  return SUCCESS;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  result_t DBBufferC$TupleIntf$setFieldNoQuery(TuplePtr arg_0x2042808, uint8_t arg_0x2042998, uint8_t arg_0x2042b28, uint8_t arg_0x2042cd0[], uint8_t arg_0x2042e78[], CharPtr arg_0x2041030){
#line 72
  unsigned char result;
#line 72

#line 72
  result = Tuple$TupleIntf$setFieldNoQuery(arg_0x2042808, arg_0x2042998, arg_0x2042b28, arg_0x2042cd0, arg_0x2042e78, arg_0x2041030);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr DBBufferC$AttrUse$getAttrById(uint8_t arg_0x204da90){
#line 72
  struct __nesc_unnamed4282 *result;
#line 72

#line 72
  result = Attr$AttrUse$getAttrById(arg_0x204da90);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  CharPtr DBBufferC$TupleIntf$getFieldPtrNoQuery(TuplePtr arg_0x2040100, uint8_t arg_0x2040290, uint8_t arg_0x2040420, uint8_t arg_0x20405c8[], uint8_t arg_0x2040770[]){
#line 98
  char *result;
#line 98

#line 98
  result = Tuple$TupleIntf$getFieldPtrNoQuery(arg_0x2040100, arg_0x2040290, arg_0x2040420, arg_0x20405c8, arg_0x2040770);
#line 98

#line 98
  return result;
#line 98
}
#line 98
# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline  uint8_t Attr$AttrUse$numAttrs(void)
{
  return Attr$attrDescs.numAttrs;
}

# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  uint8_t DBBufferC$AttrUse$numAttrs(void){
#line 77
  unsigned char result;
#line 77

#line 77
  result = Attr$AttrUse$numAttrs();
#line 77

#line 77
  return result;
#line 77
}
#line 77
# 900 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  TinyDBError DBBufferC$DBBuffer$getResult(uint8_t bufferId, uint16_t idx, QueryResult *qr, bool *pending)
#line 900
{
  TinyDBError err = err_NoError;

  if (DBBufferC$mState != DBBufferC$kIDLE) {
      return err_ResultBufferBusy;
    }
  DBBufferC$mState = DBBufferC$kREAD_ROW;

  switch (bufferId) {

      case DBBufferC$kATTR_BUF: {
          TuplePtr t;
          char *field;

          if (idx >= DBBufferC$AttrUse$numAttrs()) {
              err = err_NoMoreResults;
              goto done;
            }


          t = & qr->d.t;
          t->notNull = 0;
          t->numFields = DBBufferC$NUM_ATTR_FIELDS;




          field = DBBufferC$TupleIntf$getFieldPtrNoQuery(t, 0, DBBufferC$NUM_ATTR_FIELDS, DBBufferC$ATTR_SIZES, DBBufferC$ATTR_TYPES);

          if (field != NULL) {
              AttrDescPtr adp = DBBufferC$AttrUse$getAttrById(idx);

#line 931
              DBBufferC$TupleIntf$setFieldNoQuery(t, 0, DBBufferC$NUM_ATTR_FIELDS, DBBufferC$ATTR_SIZES, DBBufferC$ATTR_TYPES, adp->name);
            }
          break;
        }
      default: 
        {
          DBBufferC$Buffer *buf;
          uint16_t size;
          uint16_t row;


          err = DBBufferC$getBuf(bufferId, &buf);
          *pending = FALSE;

          if (err != err_NoError) {
#line 945
            goto done;
            }
          if (buf->nextFull == buf->nextFree && buf->numRows != 1) {
              err = err_NoMoreResults;
              goto done;
            }
          DBBufferC$DBBuffer$size(bufferId, &size);
          if (idx >= size) {
              err = err_NoMoreResults;
              goto done;
            }


          if (buf->nextFull > buf->nextFree) {
              if (idx >= buf->numRows - buf->nextFull) {
                  row = idx - (buf->numRows - buf->nextFull);
                }
              else {
#line 962
                row = buf->nextFull + idx;
                }
            }
          else 
#line 963
            {
              row = buf->nextFull + idx;
            }

          switch (buf->type) {





              default: 
                err = err_UnknownError;
            }
        }
    }
  done: 
    DBBufferC$mState = DBBufferC$kIDLE;
  return err;
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$getResult(uint8_t arg_0x20d7b28, uint16_t arg_0x20d7ca8, QueryResult *arg_0x20d7e48, bool *arg_0x20d6010){
#line 92
  unsigned char result;
#line 92

#line 92
  result = DBBufferC$DBBuffer$getResult(arg_0x20d7b28, arg_0x20d7ca8, arg_0x20d7e48, arg_0x20d6010);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 721 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  TinyDBError DBBufferC$DBBuffer$peek(uint8_t bufferId, QueryResult *qr, bool *pending)
#line 721
{
  DBBufferC$Buffer *buf;
  TinyDBError err;




  if ((((
#line 727
  bufferId == kRADIO || bufferId == DBBufferC$kATTR_BUF) || bufferId == DBBufferC$kCOMMAND_BUF) || 
  bufferId == DBBufferC$kEVENT_BUF) || bufferId == DBBufferC$kQUERY_BUF) {
    return err_UnsupportedBuffer;
    }
#line 730
  if (DBBufferC$mState != DBBufferC$kIDLE) {
      return err_ResultBufferBusy;
    }
  DBBufferC$mState = DBBufferC$kREAD_ROW;

  *pending = FALSE;



  err = DBBufferC$getBuf(bufferId, &buf);
  if (err != err_NoError) {
      DBBufferC$mState = DBBufferC$kIDLE;
      goto done;
    }


  switch (buf->type) {
#line 794
      default: 
        err = err_UnknownError;
      DBBufferC$mState = DBBufferC$kIDLE;
    }

  done: 

    return err;
}

# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$peek(uint8_t arg_0x20d7088, QueryResult *arg_0x20d7228, bool *arg_0x20d73c0){
#line 77
  unsigned char result;
#line 77

#line 77
  result = DBBufferC$DBBuffer$peek(arg_0x20d7088, arg_0x20d7228, arg_0x20d73c0);
#line 77

#line 77
  return result;
#line 77
}
#line 77
# 2935 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  void TupleRouterM$fillInTask(void)
#line 2935
{
  TupleRouterM$fillInAttrVal(SCHEMA_RESULT_READY);
}

# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  result_t TupleRouterM$TupleIntf$setField(ParsedQueryPtr arg_0x2044ce8, TuplePtr arg_0x2044e68, uint8_t arg_0x2042010, CharPtr arg_0x2042188){
#line 60
  unsigned char result;
#line 60

#line 60
  result = Tuple$TupleIntf$setField(arg_0x2044ce8, arg_0x2044e68, arg_0x2042010, arg_0x2042188);
#line 60

#line 60
  return result;
#line 60
}
#line 60
#line 86
inline static  CharPtr TupleRouterM$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80){
#line 86
  char *result;
#line 86

#line 86
  result = Tuple$TupleIntf$getFieldPtr(arg_0x2041780, arg_0x2041900, arg_0x2041a80);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 374 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline  TinyDBError ContourMapM$Aggregate$finalize(char *data, char *result_buf, ParamList *params, ParamVals *paramValues)
#line 374
{

  return err_NoError;
}

# 146 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 145
TinyDBError AggregateUseM$Agg$default$finalize(uint8_t id, 
char *data, char *result_buf, ParamList *params, ParamVals *paramValues)
#line 146
{
  return err_NoError;
}

# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  TinyDBError AggregateUseM$Agg$finalize(uint8_t arg_0x255b358, char *arg_0x2554f10, char *arg_0x25520b8, ParamList *arg_0x2552258, ParamVals *arg_0x2552400){
#line 98
  unsigned char result;
#line 98

#line 98
  switch (arg_0x255b358) {
#line 98
    case kCONTOUR_MAP:
#line 98
      result = ContourMapM$Aggregate$finalize(arg_0x2554f10, arg_0x25520b8, arg_0x2552258, arg_0x2552400);
#line 98
      break;
#line 98
    default:
#line 98
      result = AggregateUseM$Agg$default$finalize(arg_0x255b358, arg_0x2554f10, arg_0x25520b8, arg_0x2552258, arg_0x2552400);
#line 98
    }
#line 98

#line 98
  return result;
#line 98
}
#line 98
# 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  TinyDBError AggregateUseM$AggregateUse$finalize(uint8_t id, char *data, char *result_buf, ParamList *params, ParamVals *paramValues)
#line 109
{
  return AggregateUseM$Agg$finalize(id, data, result_buf, params, paramValues);
}

# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  TinyDBError AggOperator$AggregateUse$finalize(uint8_t arg_0x24809d0, char *arg_0x2480b60, char *arg_0x2480cf8, ParamList *arg_0x2480e98, ParamVals *arg_0x24d1068){
#line 98
  unsigned char result;
#line 98

#line 98
  result = AggregateUseM$AggregateUse$finalize(arg_0x24809d0, arg_0x2480b60, arg_0x2480cf8, arg_0x2480e98, arg_0x24d1068);
#line 98

#line 98
  return result;
#line 98
}
#line 98
# 686 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline  TinyDBError AggOperator$finalizeAggExpr(QueryResult *qr, ParsedQueryPtr q, Expr *e, char *result_buf)
#line 686
{
  AggOperator$GroupRecord *gr = (AggOperator$GroupRecord *)qr->d.data;

  ParamVals paramVals;

#line 690
  setParamValues(&paramVals, e);

  return AggOperator$AggregateUse$finalize(e->ex.agg.op, gr->aggdata, result_buf, NULL, &paramVals);
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
inline static  TinyDBError ParsedQuery$finalizeAggExpr(QueryResult *arg_0x23461b0, ParsedQueryPtr arg_0x2346330, Expr *arg_0x23464c8, char *arg_0x2346660){
#line 84
  unsigned char result;
#line 84

#line 84
  result = AggOperator$finalizeAggExpr(arg_0x23461b0, arg_0x2346330, arg_0x23464c8, arg_0x2346660);
#line 84

#line 84
  return result;
#line 84
}
#line 84
# 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline  bool AggOperator$Operator$resultIsForExpr(QueryResultPtr qr, ExprPtr e)
#line 210
{
  AggOperator$GroupRecord *gr = (AggOperator$GroupRecord *)qr->d.data;
  bool result = TRUE;

#line 213
  if (qr->qrType != kAGG_SINGLE_FIELD) {
#line 213
    result = FALSE;
    }
#line 214
  if (gr->u.exprIdx != e->idx) {
#line 214
    result = FALSE;
    }
  return result;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  bool ParsedQuery$AggOperator$resultIsForExpr(QueryResultPtr arg_0x209bf00, ExprPtr arg_0x209a088){
#line 72
  unsigned char result;
#line 72

#line 72
  result = AggOperator$Operator$resultIsForExpr(arg_0x209bf00, arg_0x209a088);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 593 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline  short AggOperator$getGroupNoFromQr(QueryResult *qr)
#line 593
{
  AggOperator$GroupRecord *gr = (AggOperator$GroupRecord *)qr->d.data;

  return gr->groupNo;
}

# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
inline static  short ParsedQuery$getGroupNoFromQr(QueryResult *arg_0x2346b10){
#line 85
  short result;
#line 85

#line 85
  result = AggOperator$getGroupNoFromQr(arg_0x2346b10);
#line 85

#line 85
  return result;
#line 85
}
#line 85
# 124 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError ParsedQuery$QueryResultIntf$fromResultTuple(ResultTuple arg_0x208d398, QueryResultPtr arg_0x208d518, ParsedQueryPtr arg_0x208d698){
#line 124
  unsigned char result;
#line 124

#line 124
  result = QueryResult$QueryResultIntf$fromResultTuple(arg_0x208d398, arg_0x208d518, arg_0x208d698);
#line 124

#line 124
  return result;
#line 124
}
#line 124
#line 137
inline static  ResultTuple ParsedQuery$QueryResultIntf$getResultTuple(QueryResultPtr arg_0x208c670, short arg_0x208c7e0, ParsedQueryPtr arg_0x208c960){
#line 137
  struct __nesc_unnamed4314 result;
#line 137

#line 137
  result = QueryResult$QueryResultIntf$getResultTuple(arg_0x208c670, arg_0x208c7e0, arg_0x208c960);
#line 137

#line 137
  return result;
#line 137
}
#line 137
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  uint16_t ParsedQuery$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0){
#line 50
  unsigned int result;
#line 50

#line 50
  result = Tuple$TupleIntf$fieldSize(arg_0x2044668, arg_0x20447e0);
#line 50

#line 50
  return result;
#line 50
}
#line 50
#line 86
inline static  CharPtr ParsedQuery$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80){
#line 86
  char *result;
#line 86

#line 86
  result = Tuple$TupleIntf$getFieldPtr(arg_0x2041780, arg_0x2041900, arg_0x2041a80);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$toTuplePtr(QueryResultPtr qr, ParsedQueryPtr q, TupleHandle t)
#line 139
{
  *t = & qr->d.t;
  return err_NoError;
}

# 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError ParsedQuery$QueryResultIntf$toTuplePtr(QueryResultPtr arg_0x208f268, ParsedQueryPtr arg_0x208f3e8, TupleHandle arg_0x208f568){
#line 100
  unsigned char result;
#line 100

#line 100
  result = QueryResult$QueryResultIntf$toTuplePtr(arg_0x208f268, arg_0x208f3e8, arg_0x208f568);
#line 100

#line 100
  return result;
#line 100
}
#line 100
#line 131
inline static  short ParsedQuery$QueryResultIntf$numRecords(QueryResultPtr arg_0x208c030, ParsedQueryPtr arg_0x208c1b0){
#line 131
  short result;
#line 131

#line 131
  result = QueryResult$QueryResultIntf$numRecords(arg_0x208c030, arg_0x208c1b0);
#line 131

#line 131
  return result;
#line 131
}
#line 131
# 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  TinyDBError ParsedQuery$ParsedQueryIntf$getResultField(ParsedQueryPtr q, QueryResultPtr qr, uint8_t resultid, char *result_buf)
#line 155
{
  QueryResult localqr;
  ResultTuple rt;
  short numRecords = ParsedQuery$QueryResultIntf$numRecords(qr, q);
  bool isAgg = qr->qrType != kNOT_AGG;
  uint8_t fieldId = resultid & 0x7F;
  bool isGroupNo = resultid == GROUP_FIELD;
  TinyDBError err;

  if (resultid == NULL_QUERY_FIELD || resultid == TYPED_FIELD) {

      return err_InvalidIndex;
    }

  if (!isAgg) {
      Tuple *t;
      char *data;

      err = ParsedQuery$QueryResultIntf$toTuplePtr(qr, q, &t);
      if (err != err_NoError) {
#line 174
        return err;
        }
      data = ParsedQuery$TupleIntf$getFieldPtr(q, t, fieldId);
      if (data == NULL) {
#line 177
        return err_InvalidIndex;
        }
      nmemcpy(result_buf, data, ParsedQuery$TupleIntf$fieldSize(q, fieldId));

      return err_NoError;
    }
  else 
#line 182
    {
      Expr *e = isGroupNo ? NULL : ParsedQuery$ParsedQueryIntf$getExprPtr(q, fieldId);
      short i;

      for (i = 0; i < numRecords; i++) {

          rt = ParsedQuery$QueryResultIntf$getResultTuple(qr, i, q);
          err = ParsedQuery$QueryResultIntf$fromResultTuple(rt, &localqr, q);
          if (err != err_NoError) {
              return err;
            }
          if (isGroupNo) {
              * (short *)result_buf = ParsedQuery$getGroupNoFromQr(&localqr);
              return err_NoError;
            }
          else 
#line 196
            {
              if (ParsedQuery$AggOperator$resultIsForExpr(&localqr, e)) {
                  err = ParsedQuery$finalizeAggExpr(&localqr, q, e, result_buf);
                  if (err != err_NoError) {
                      return err;
                    }
                  else {
#line 202
                    return err_NoError;
                    }
                }
            }
        }
    }

  return err_InvalidIndex;
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  TinyDBError DBBufferC$ParsedQueryIntf$getResultField(ParsedQueryPtr arg_0x2067498, QueryResultPtr arg_0x2067618, uint8_t arg_0x2067798, char *arg_0x2067930){
#line 92
  unsigned char result;
#line 92

#line 92
  result = ParsedQuery$ParsedQueryIntf$getResultField(arg_0x2067498, arg_0x2067618, arg_0x2067798, arg_0x2067930);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 1155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  TinyDBError DBBufferC$DBBuffer$getField(uint8_t bufferId, QueryResult *qr, uint8_t idx, char *resultBuf)
#line 1155
{
  ParsedQuery **fromPq;
  Tuple *t;
  char *field;
  TinyDBError err = err_NoError;

#line 1160
  switch (bufferId) {
      case DBBufferC$kATTR_BUF: 
        if (idx >= DBBufferC$NUM_ATTR_FIELDS) {
#line 1162
          return err_InvalidIndex;
          }
#line 1163
      t = & qr->d.t;
      field = DBBufferC$TupleIntf$getFieldPtrNoQuery(t, idx, DBBufferC$NUM_ATTR_FIELDS, DBBufferC$ATTR_SIZES, DBBufferC$ATTR_TYPES);
      if (field != NULL) {
          nmemcpy(resultBuf, field, DBBufferC$ATTR_SIZES[idx]);
        }
      else {
#line 1168
        err = err_InvalidIndex;
        }
#line 1169
      break;
      default: 
        fromPq = DBBufferC$DBBuffer$getSchema(bufferId);
      if (fromPq == NULL) {
#line 1172
        return err_UnsupportedBuffer;
        }
#line 1173
      err = DBBufferC$ParsedQueryIntf$getResultField(*fromPq, 
      qr, 
      idx, 
      resultBuf);
    }
  return err;
}

# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$getField(uint8_t arg_0x20d6df0, QueryResult *arg_0x20d5010, uint8_t arg_0x20d5188, char *arg_0x20d5320){
#line 110
  unsigned char result;
#line 110

#line 110
  result = DBBufferC$DBBuffer$getField(arg_0x20d6df0, arg_0x20d5010, arg_0x20d5188, arg_0x20d5320);
#line 110

#line 110
  return result;
#line 110
}
#line 110
# 420 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_ROUTING_TUPLES(void)
#line 420
{
#line 420
  TupleRouterM$mPendingMask |= TupleRouterM$ROUTING_BIT;
}

#line 411
static inline void TupleRouterM$UNSET_FETCHING_ATTRIBUTE(void)
#line 411
{
#line 411
  TupleRouterM$mPendingMask &= TupleRouterM$FETCHING_BIT ^ 0xFFFF;
}

#line 2848
static inline void TupleRouterM$keepRouting(void)
#line 2848
{
  if (!TupleRouterM$fetchNextAttr()) {
      TupleRouterM$UNSET_FETCHING_ATTRIBUTE();
      TupleRouterM$SET_ROUTING_TUPLES();

      TupleRouterM$mCurRouteQuery = TupleRouterM$nextQueryToRoute(NULL);
      TupleRouterM$mCurExpr = -1;

      TOS_post(TupleRouterM$routeTask);
    }
}

#line 1686
static inline  TinyDBError TupleRouterM$SelOperator$processedTuple(Tuple *t, 
ParsedQuery *q, 
Expr *e, 
bool passed)
{
  if (!passed) {
      e->success = FALSE;
      TupleRouterM$mCurRouteQuery = TupleRouterM$nextQueryToRoute(TupleRouterM$mCurRouteQuery);
    }
  TOS_post(TupleRouterM$routeTask);
  return err_NoError;
}

# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError SelOperator$Operator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40){
#line 114
  unsigned char result;
#line 114

#line 114
  result = TupleRouterM$SelOperator$processedTuple(arg_0x20978d0, arg_0x2097a50, arg_0x2097bc8, arg_0x2097d40);
#line 114

#line 114
  return result;
#line 114
}
#line 114
# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  CharPtr SelOperator$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80){
#line 86
  char *result;
#line 86

#line 86
  result = Tuple$TupleIntf$getFieldPtr(arg_0x2041780, arg_0x2041900, arg_0x2041a80);
#line 86

#line 86
  return result;
#line 86
}
#line 86
#line 50
inline static  uint16_t SelOperator$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0){
#line 50
  unsigned int result;
#line 50

#line 50
  result = Tuple$TupleIntf$fieldSize(arg_0x2044668, arg_0x20447e0);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEvalC.nc"
static inline  short ExprEvalC$ExprEval$evaluate(Expr *e, short fieldValue)
#line 54
{
  short fieldOp = e->fieldOp;
  short fieldConst = e->fieldConst;

  return ExprEvalC$evaluateSimpleExpr(fieldValue, fieldOp, fieldConst);
}

# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEval.nc"
inline static  short SelOperator$ExprEval$evaluate(Expr *arg_0x23a7408, short arg_0x23a7580){
#line 45
  short result;
#line 45

#line 45
  result = ExprEvalC$ExprEval$evaluate(arg_0x23a7408, arg_0x23a7580);
#line 45

#line 45
  return result;
#line 45
}
#line 45
# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SelOperator.nc"
static inline  void SelOperator$doFilter(void)
#line 84
{
  ParsedQuery *qs = SelOperator$mQs;
  Tuple *t = SelOperator$mT;
  Expr *e = SelOperator$mE;
  OpValExpr ex;
  short size;
  char *fieldBytes;
  short fieldVal = 0;
  short i;
  bool result = FALSE;


  if (! e->isStringExp) {
      ex = e->ex.opval;
      size = SelOperator$TupleIntf$fieldSize(qs, (char )ex.field);
      fieldBytes = SelOperator$TupleIntf$getFieldPtr(qs, t, (char )ex.field);


      for (i = 0; i < size; i++) {
          unsigned char b = * fieldBytes++;

#line 104
          fieldVal += (unsigned short )b << i * 8;
        }

      fieldVal = SelOperator$ExprEval$evaluate(e, fieldVal);

      switch (ex.op) {
          case EQ: 
            result = fieldVal == ex.value;
          break;
          case NEQ: 
            result = fieldVal != ex.value;
          break;
          case GT: 
            result = fieldVal > ex.value;
          break;
          case GE: 
            result = fieldVal >= ex.value;
          break;
          case LT: 
            result = fieldVal < ex.value;
          break;
          case LE: 
            result = fieldVal <= ex.value;
          break;
        }
    }
  else 
#line 129
    {

      StringExpr sex = e->ex.sexp;
      int strCmpVal;

#line 133
      {
      }
#line 133
      ;
      size = SelOperator$TupleIntf$fieldSize(qs, (char )sex.field);
      fieldBytes = SelOperator$TupleIntf$getFieldPtr(qs, t, (char )ex.field);
      strCmpVal = strcmp(sex.s, fieldBytes);
      if (strCmpVal == 0) {
          result = (sex.op == LE || sex.op == EQ) || sex.op == GE;
        }
      else {
#line 139
        if (strCmpVal < 0) {
            result = (sex.op == GT || sex.op == GE) || sex.op == NEQ;
          }
        else {
#line 141
          result = (sex.op == LT || sex.op == LE) || sex.op == NEQ;
          }
        }
    }
  SelOperator$Operator$processedTuple(t, qs, e, result);
}

#line 72
static inline  TinyDBError SelOperator$Operator$processTuple(ParsedQueryPtr qs, TuplePtr t, ExprPtr e)
#line 72
{
  SelOperator$mQs = qs;
  SelOperator$mT = t;
  SelOperator$mE = e;

  TOS_post(SelOperator$doFilter);

  return err_NoError;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError TupleRouterM$SelOperator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990){
#line 66
  unsigned char result;
#line 66

#line 66
  result = SelOperator$Operator$processTuple(arg_0x209b698, arg_0x209b818, arg_0x209b990);
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 128 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDB.h"
static inline TinyDBError combine_tdberr(TinyDBError r1, TinyDBError r2)
#line 128
{
  if (r1 == err_NoError) {
#line 129
    return r2;
    }
  else {
#line 130
    return r1;
    }
}

# 397 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  TinyDBError ParsedQuery$AggOperator$processedTuple(TuplePtr t, ParsedQueryPtr q, ExprPtr e, bool passed)
#line 397
{
  return err_NoError;
}

# 1709 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  TinyDBError TupleRouterM$AggOperator$processedTuple(Tuple *t, ParsedQuery *q, 
Expr *e, bool passed)
{
  TOS_post(TupleRouterM$routeTask);
  return err_NoError;
}

# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError AggOperator$Operator$processedTuple(TuplePtr arg_0x20978d0, ParsedQueryPtr arg_0x2097a50, ExprPtr arg_0x2097bc8, bool arg_0x2097d40){
#line 114
  unsigned char result;
#line 114

#line 114
  result = TupleRouterM$AggOperator$processedTuple(arg_0x20978d0, arg_0x2097a50, arg_0x2097bc8, arg_0x2097d40);
#line 114
  result = combine_tdberr(result, ParsedQuery$AggOperator$processedTuple(arg_0x20978d0, arg_0x2097a50, arg_0x2097bc8, arg_0x2097d40));
#line 114

#line 114
  return result;
#line 114
}
#line 114
# 271 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline  result_t ContourMapM$Aggregate$update(char *destdata, char *value, ParamList *params, ParamVals *paramValues)
#line 271
{

  int16_t v = * (int16_t *)value;
  int i;
  int16_t *b;
  ContourMapM$ContourMap *currentmap = (ContourMapM$ContourMap *)destdata;

  if (TOS_LOCAL_ADDRESS == 0) {
    return SUCCESS;
    }
  b = (int16_t *)ContourMapM$mymap->regions[0].regression.b;
  b[0] = 3 * v;
  b[1] = v * (ContourMapM$x[0] + ContourMapM$x[1] + ContourMapM$x[2]);
  b[2] = v * (ContourMapM$y[0] + ContourMapM$y[1] + ContourMapM$y[2]);

  for (i = 0; i < currentmap->regionNum; i++) 
    if (ContourMapM$contourRegionMerging(&currentmap->regions[i], &ContourMapM$mymap->regions[0])) {
      break;
      }
#line 289
  if (i == currentmap->regionNum) {
    currentmap->regions[currentmap->regionNum++] = ContourMapM$mymap->regions[0];
    }


  return SUCCESS;
}

# 126 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 125
result_t AggregateUseM$Agg$default$update(uint8_t id, 
char *destdata, char *value, ParamList *params, ParamVals *paramValues)
#line 126
{
  return SUCCESS;
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  result_t AggregateUseM$Agg$update(uint8_t arg_0x255b358, char *arg_0x2555a68, char *arg_0x2555bf8, ParamList *arg_0x2555d98, ParamVals *arg_0x2554010){
#line 86
  unsigned char result;
#line 86

#line 86
  switch (arg_0x255b358) {
#line 86
    case kCONTOUR_MAP:
#line 86
      result = ContourMapM$Aggregate$update(arg_0x2555a68, arg_0x2555bf8, arg_0x2555d98, arg_0x2554010);
#line 86
      break;
#line 86
    default:
#line 86
      result = AggregateUseM$Agg$default$update(arg_0x255b358, arg_0x2555a68, arg_0x2555bf8, arg_0x2555d98, arg_0x2554010);
#line 86
    }
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  result_t AggregateUseM$AggregateUse$update(uint8_t id, char *destdata, char *value, ParamList *params, ParamVals *paramValues)
#line 92
{
  return AggregateUseM$Agg$update(id, destdata, value, params, paramValues);
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  result_t AggOperator$AggregateUse$update(uint8_t arg_0x2483188, char *arg_0x2483318, char *arg_0x24834a8, ParamList *arg_0x2483648, ParamVals *arg_0x24837f0){
#line 86
  unsigned char result;
#line 86

#line 86
  result = AggregateUseM$AggregateUse$update(arg_0x2483188, arg_0x2483318, arg_0x24834a8, arg_0x2483648, arg_0x24837f0);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEval.nc"
inline static  short AggOperator$ExprEval$evaluate(Expr *arg_0x23a7408, short arg_0x23a7580){
#line 45
  short result;
#line 45

#line 45
  result = ExprEvalC$ExprEval$evaluate(arg_0x23a7408, arg_0x23a7580);
#line 45

#line 45
  return result;
#line 45
}
#line 45
# 645 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline void AggOperator$updateAggregateValue(AggOperator$GroupRecord *d, Expr *e, short fieldValue)
#line 645
{
  ParamVals paramVals;

#line 647
  setParamValues(&paramVals, e);



  fieldValue = AggOperator$ExprEval$evaluate(e, fieldValue);
  d->u.empty = FALSE;





  AggOperator$AggregateUse$update(e->ex.agg.op, d->aggdata, (char *)&fieldValue, NULL, &paramVals);
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  uint16_t AggOperator$TupleIntf$fieldSize(ParsedQueryPtr arg_0x2044668, uint8_t arg_0x20447e0){
#line 50
  unsigned int result;
#line 50

#line 50
  result = Tuple$TupleIntf$fieldSize(arg_0x2044668, arg_0x20447e0);
#line 50

#line 50
  return result;
#line 50
}
#line 50
#line 86
inline static  CharPtr AggOperator$TupleIntf$getFieldPtr(ParsedQueryPtr arg_0x2041780, TuplePtr arg_0x2041900, uint8_t arg_0x2041a80){
#line 86
  char *result;
#line 86

#line 86
  result = Tuple$TupleIntf$getFieldPtr(arg_0x2041780, arg_0x2041900, arg_0x2041a80);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 361 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline void AggOperator$updateGroupForTuple(AggOperator$GroupRecord *d)
#line 361
{
  Tuple *t = AggOperator$mCurTuple;
  Expr *e = AggOperator$mCurExpr;
  ParsedQuery *q = AggOperator$mCurQuery;
  char *fieldBytes = AggOperator$TupleIntf$getFieldPtr(q, t, (char )e->ex.agg.field);
  short size = AggOperator$TupleIntf$fieldSize(q, (char )e->ex.agg.field);
  short fieldVal = 0;
  short i;

  for (i = 0; i < size; i++) {
      unsigned char b = * fieldBytes++;

#line 372
      fieldVal += (unsigned short )b << i * 8;
    }

  AggOperator$updateAggregateValue(d, e, fieldVal);

  AggOperator$Operator$processedTuple(t, q, AggOperator$mCurExpr, TRUE);
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEvalC.nc"
static inline  short ExprEvalC$ExprEval$evaluateGroupBy(AggregateExpression a, short grpByFieldValue)
#line 61
{
  short grpByFieldOp = a.groupFieldOp;
  short grpByFieldConst = a.groupFieldConst;

  return ExprEvalC$evaluateSimpleExpr(grpByFieldValue, grpByFieldOp, grpByFieldConst);
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEval.nc"
inline static  short AggOperator$ExprEval$evaluateGroupBy(AggregateExpression arg_0x23a7a00, short arg_0x23a7b78){
#line 48
  short result;
#line 48

#line 48
  result = ExprEvalC$ExprEval$evaluateGroupBy(arg_0x23a7a00, arg_0x23a7b78);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 571 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline short AggOperator$getGroupNo(Tuple *t, ParsedQuery *q, Expr *e)
#line 571
{
  char *fieldBytes;
  short size;
  short fieldVal = 0;
  short i;

#line 576
  if (e->ex.agg.groupingField == (short )kNO_GROUPING_FIELD) {
#line 576
    return 0;
    }

  fieldBytes = AggOperator$TupleIntf$getFieldPtr(q, t, (char )e->ex.agg.groupingField);
  size = AggOperator$TupleIntf$fieldSize(q, (char )e->ex.agg.groupingField);


  for (i = 0; i < size; i++) {
      unsigned char b = * fieldBytes++;

#line 585
      fieldVal += (unsigned short )b << i * 8;
    }

  return AggOperator$ExprEval$evaluateGroupBy(e->ex.agg, fieldVal);
}

#line 312
static inline  TinyDBError AggOperator$Operator$processTuple(ParsedQueryPtr qs, TuplePtr t, ExprPtr e)
#line 312
{
  AggOperator$mCurExpr = e;
  AggOperator$mCurQuery = qs;
  AggOperator$mCurTuple = t;
  {
  }
#line 316
  ;
  if (e->opState == (OperatorStateHandle )AggOperator$QUERY_DONE_STATE) {
#line 317
    return err_NoError;
    }
#line 318
  AggOperator$getGroupData(qs, AggOperator$getGroupNo(t, qs, e), e, &AggOperator$updateGroupForTuple);
  return err_NoError;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError TupleRouterM$AggOperator$processTuple(ParsedQueryPtr arg_0x209b698, TuplePtr arg_0x209b818, ExprPtr arg_0x209b990){
#line 66
  unsigned char result;
#line 66

#line 66
  result = AggOperator$Operator$processTuple(arg_0x209b698, arg_0x209b818, arg_0x209b990);
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 3011 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$routeToQuery(ParsedQuery *q, Tuple *t)
#line 3011
{
  Expr *e = TupleRouterM$nextExpr(q);

  if (e != NULL) {
      e->success = TRUE;
      if (e->opType != kSEL) {
          TupleRouterM$AggOperator$processTuple(q, t, e);
        }
      else 
#line 3018
        {
          TupleRouterM$SelOperator$processTuple(q, t, e);
        }
      return TRUE;
    }
  else 
#line 3022
    {
      return FALSE;
    }
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t AggOperator$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638){
#line 61
  unsigned char result;
#line 61

#line 61
  result = TinyAlloc$MemAlloc$allocate(arg_0x20854c0, arg_0x2085638);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 460 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline bool AggOperator$removeEmptyGroup(AggOperator$GroupDataHandle dh)
#line 460
{
  short i;
#line 461
  short lastEmpty;
  bool found = FALSE;
  AggOperator$GroupRecord *gr;


  for (lastEmpty = (*dh)->numGroups - 1; lastEmpty >= 0; lastEmpty--) {
      gr = AggOperator$GET_GROUP_DATA(dh, lastEmpty);
      if (gr->u.empty) {
          found = TRUE;
          break;
        }
    }

  if (!found) {
#line 474
    return FALSE;
    }
#line 475
  {
  }
#line 475
  ;

  for (i = lastEmpty + 1; i < (*dh)->numGroups; i++) {
      gr = AggOperator$GET_GROUP_DATA(dh, i);
      AggOperator$SET_GROUP_DATA(dh, i - 1, (char *)&gr);
    }

  (*dh)->numGroups--;

  return TRUE;
}

#line 101
inline static  void AggOperator$signalError(TinyDBError arg_0x24d1be8, int arg_0x24d1d58){
#line 101
  TupleRouterM$signalError(arg_0x24d1be8, arg_0x24d1d58);
#line 101
}
#line 101
# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  short ParsedQuery$ParsedQueryIntf$pqSize(ParsedQueryPtr pq)
#line 127
{
  return sizeof(ParsedQuery ) + sizeof(char ) * (pq->numFields - 1) + sizeof(Expr ) * pq->numExprs;
}

# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  short DBBufferC$ParsedQueryIntf$pqSize(ParsedQueryPtr arg_0x2068828){
#line 71
  short result;
#line 71

#line 71
  result = ParsedQuery$ParsedQueryIntf$pqSize(arg_0x2068828);
#line 71

#line 71
  return result;
#line 71
}
#line 71
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t DBBufferC$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638){
#line 61
  unsigned char result;
#line 61

#line 61
  result = TinyAlloc$MemAlloc$allocate(arg_0x20854c0, arg_0x2085638);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 326 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result)
#line 326
{
  return SUCCESS;
}

# 413 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result)
#line 413
{
  return SUCCESS;
}

# 403 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_PARSING_QUERY(void)
#line 403
{
#line 403
  TupleRouterM$mPendingMask &= TupleRouterM$PARSING_BIT ^ 0xFFFF;
}

#line 399
static inline void TupleRouterM$UNSET_READING_QUERY(void)
#line 399
{
#line 399
  TupleRouterM$mPendingMask &= TupleRouterM$READING_BIT ^ 0xFFFF;
#line 399
  TupleRouterM$mQMsgMask = 0x0;
}

#line 1248
static inline void TupleRouterM$failedOpeningWriteBuffer(ParsedQuery *pq)
#line 1248
{



  TupleRouterM$mQidToRemove = pq->qid;
  TupleRouterM$mForceRemove = TRUE;
  TOS_post(TupleRouterM$removeQueryTask);
  TupleRouterM$UNSET_READING_QUERY();
  TupleRouterM$UNSET_PARSING_QUERY();
}

#line 3776
static inline  result_t TupleRouterM$DBBuffer$allocComplete(uint8_t bufferId, TinyDBError result)
#line 3776
{
  if (result != err_NoError) {



      TupleRouterM$failedOpeningWriteBuffer(TupleRouterM$mTempPQ);
    }
  else {



      TupleRouterM$finishedOpeningWriteBuffer(TupleRouterM$mTempPQ);
    }
  return SUCCESS;
}

# 187 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  result_t DBBufferC$DBBuffer$allocComplete(uint8_t arg_0x20cecd0, TinyDBError arg_0x20cee50){
#line 187
  unsigned char result;
#line 187

#line 187
  result = TupleRouterM$DBBuffer$allocComplete(arg_0x20cecd0, arg_0x20cee50);
#line 187
  result = rcombine(result, ParsedQuery$DBBuffer$allocComplete(arg_0x20cecd0, arg_0x20cee50));
#line 187
  result = rcombine(result, Tuple$DBBuffer$allocComplete(arg_0x20cecd0, arg_0x20cee50));
#line 187

#line 187
  return result;
#line 187
}
#line 187
# 347 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  bool ParsedQuery$ParsedQueryIntf$typeCheck(ParsedQuery *dest, ParsedQuery *select)
#line 347
{
  int i;
  uint8_t selType;
#line 349
  uint8_t destType;


  if (dest->buf.ram.create != 1) 
    {

      return FALSE;
    }
  if (dest->numFields != select->numFields) {

      return FALSE;
    }

  for (i = 0; i < dest->numFields; i++) {

      if (ParsedQuery$ParsedQueryIntf$getFieldType(select, i, &selType) == FAIL) {
          return FALSE;
        }
      if (ParsedQuery$ParsedQueryIntf$getFieldType(dest, i, &destType) == FAIL) {
          return FALSE;
        }
      if (selType != destType) {

          return FALSE;
        }
    }
  return TRUE;
}

# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  bool TupleRouterM$ParsedQueryIntf$typeCheck(ParsedQuery *arg_0x2065a18, ParsedQuery *arg_0x2065bb8){
#line 110
  unsigned char result;
#line 110

#line 110
  result = ParsedQuery$ParsedQueryIntf$typeCheck(arg_0x2065a18, arg_0x2065bb8);
#line 110

#line 110
  return result;
#line 110
}
#line 110
# 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError ParsedQuery$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650){
#line 151
  unsigned char result;
#line 151

#line 151
  result = DBBufferC$DBBuffer$getBufferId(arg_0x20d1330, arg_0x20d14b0, arg_0x20d1650);
#line 151

#line 151
  return result;
#line 151
}
#line 151
#line 135
inline static  ParsedQuery **ParsedQuery$DBBuffer$getSchema(uint8_t arg_0x20d2890){
#line 135
  struct __nesc_unnamed4298 **result;
#line 135

#line 135
  result = DBBufferC$DBBuffer$getSchema(arg_0x20d2890);
#line 135

#line 135
  return result;
#line 135
}
#line 135
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr ParsedQuery$AttrUse$getAttrById(uint8_t arg_0x204da90){
#line 72
  struct __nesc_unnamed4282 *result;
#line 72

#line 72
  result = Attr$AttrUse$getAttrById(arg_0x204da90);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 135 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  ParsedQuery **TupleRouterM$DBBuffer$getSchema(uint8_t arg_0x20d2890){
#line 135
  struct __nesc_unnamed4298 **result;
#line 135

#line 135
  result = DBBufferC$DBBuffer$getSchema(arg_0x20d2890);
#line 135

#line 135
  return result;
#line 135
}
#line 135
# 306 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$AttrUse$startAttrDone(uint8_t id)
#line 306
{
  return SUCCESS;
}

# 2434 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$AttrUse$startAttrDone(uint8_t id)
#line 2434
{
  return SUCCESS;
}

# 389 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$AttrUse$startAttrDone(uint8_t id)
#line 389
{
  return SUCCESS;
}

# 415 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_STARTING_ATTRIBUTE(void)
#line 415
{
#line 415
  TupleRouterM$mPendingMask &= TupleRouterM$ATTR_STARTING_BIT ^ 0xFFFF;
}

#line 3874
static inline  result_t TupleRouterM$AttrUse$startAttrDone(uint8_t id)
{
  TupleRouterM$mNumAttrs--;
  if (TupleRouterM$mNumAttrs == 0) {
    TupleRouterM$UNSET_STARTING_ATTRIBUTE();
    }
#line 3879
  return SUCCESS;
}

# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  result_t Attr$AttrUse$startAttrDone(uint8_t arg_0x2049670){
#line 113
  unsigned char result;
#line 113

#line 113
  result = TupleRouterM$AttrUse$startAttrDone(arg_0x2049670);
#line 113
  result = rcombine(result, ParsedQuery$AttrUse$startAttrDone(arg_0x2049670));
#line 113
  result = rcombine(result, DBBufferC$AttrUse$startAttrDone(arg_0x2049670));
#line 113
  result = rcombine(result, Tuple$AttrUse$startAttrDone(arg_0x2049670));
#line 113

#line 113
  return result;
#line 113
}
#line 113
# 265 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline  result_t Attr$Attr$startAttrDone(uint8_t id)
{
  Attr$AttrUse$startAttrDone(id);
  return SUCCESS;
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrGlobalM$GroupAttr$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(1U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 95 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$GroupAttr$startAttr(void)
{
  return AttrGlobalM$GroupAttr$startAttrDone();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrGlobalM$NodeIdAttr$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(0U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$NodeIdAttr$startAttr(void)
{
  return AttrGlobalM$NodeIdAttr$startAttrDone();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTimeM$TimeHighAttr$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(3U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$TimeHighAttr$startAttr(void)
{
  return AttrTimeM$TimeHighAttr$startAttrDone();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTimeM$TimeLowAttr$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(2U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$TimeLowAttr$startAttr(void)
{
  return AttrTimeM$TimeLowAttr$startAttrDone();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTempM$AttrRegister$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(4U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline  result_t AttrTempM$AttrRegister$startAttr(void)
{
  return AttrTempM$AttrRegister$startAttrDone();
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrVoltageM$AttrRegister$startAttrDone(void){
#line 101
  unsigned char result;
#line 101

#line 101
  result = Attr$Attr$startAttrDone(5U);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  result_t AttrVoltageM$AttrRegister$startAttr(void)
{
  return AttrVoltageM$AttrRegister$startAttrDone();
}

# 279 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline   result_t Attr$Attr$default$startAttr(uint8_t id)
#line 279
{
  return SUCCESS;
}

# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t Attr$Attr$startAttr(uint8_t arg_0x2621e38){
#line 97
  unsigned char result;
#line 97

#line 97
  switch (arg_0x2621e38) {
#line 97
    case 0U:
#line 97
      result = AttrGlobalM$NodeIdAttr$startAttr();
#line 97
      break;
#line 97
    case 1U:
#line 97
      result = AttrGlobalM$GroupAttr$startAttr();
#line 97
      break;
#line 97
    case 2U:
#line 97
      result = AttrTimeM$TimeLowAttr$startAttr();
#line 97
      break;
#line 97
    case 3U:
#line 97
      result = AttrTimeM$TimeHighAttr$startAttr();
#line 97
      break;
#line 97
    case 4U:
#line 97
      result = AttrTempM$AttrRegister$startAttr();
#line 97
      break;
#line 97
    case 5U:
#line 97
      result = AttrVoltageM$AttrRegister$startAttr();
#line 97
      break;
#line 97
    default:
#line 97
      result = Attr$Attr$default$startAttr(arg_0x2621e38);
#line 97
    }
#line 97

#line 97
  return result;
#line 97
}
#line 97
# 185 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline  result_t Attr$AttrUse$startAttr(uint8_t id)
{
  if (id >= Attr$attrDescs.numAttrs) {
    return FAIL;
    }
#line 189
  if (Attr$Attr$startAttr(id) != SUCCESS) {
    return FAIL;
    }
#line 191
  return SUCCESS;
}

# 108 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  result_t TupleRouterM$AttrUse$startAttr(uint8_t arg_0x2049168){
#line 108
  unsigned char result;
#line 108

#line 108
  result = Attr$AttrUse$startAttr(arg_0x2049168);
#line 108

#line 108
  return result;
#line 108
}
#line 108
# 1827 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$setSampleRate(void)
#line 1827
{
  TupleRouterM$QueryListHandle qlh;
  short rate = -1;

#line 1852
  rate = TupleRouterM$kMS_PER_CLOCK_EVENT;


  qlh = TupleRouterM$mQs;




  if ((qlh != NULL && (*qlh)->next == NULL) || (
  qlh != NULL && TupleRouterM$mAllQueriesSameRate && (* (TupleRouterM$QueryListHandle )(*qlh)->next)->q.epochDuration == (*qlh)->q.epochDuration)) {
      TupleRouterM$mAllQueriesSameRate = TRUE;
    }
  else {
#line 1864
    TupleRouterM$mAllQueriesSameRate = FALSE;
    }

  while (qlh != NULL) {
      if ((*qlh)->q.epochDuration == kONE_SHOT) {
          (*qlh)->q.clocksPerSample = 16;
          (*qlh)->q.curResult = 0;
        }
      else {
#line 1872
        (*qlh)->q.clocksPerSample = (uint16_t )((uint32_t )(*qlh)->q.epochDuration * TupleRouterM$kBASE_EPOCH_RATE / (uint32_t )rate);
        }

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1875
        {





          if ((*qlh)->q.clocksPerSample > TupleRouterM$WAKING_CLOCKS) {
              (*qlh)->q.clockCount = TupleRouterM$WAKING_CLOCKS;
            }
          else 
#line 1883
            {

              (*qlh)->q.clockCount = (*qlh)->q.clocksPerSample;
            }
        }
#line 1887
        __nesc_atomic_end(__nesc_atomic); }






      qlh = (TupleRouterM$QueryListHandle )(*qlh)->next;
    }



  if (rate != TupleRouterM$mOldRate) {



      TupleRouterM$mOldRate = rate;
      TupleRouterM$mIsRunning = TRUE;


      TupleRouterM$AbsoluteTimer$fired();
    }
}

#line 448
static inline void TupleRouterM$SET_SNOOZING(void)
#line 448
{
#line 448
  TupleRouterM$mPendingMask |= TupleRouterM$SNOOZING_BIT;
}

# 189 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static inline  result_t ServiceSchedulerM$ServiceScheduler$reschedule(uint8_t svc_id, 
tos_service_schedule sched)
{
#line 205
  pqueue_remove((pqueue_t *)&ServiceSchedulerM$event_q, svc_id);

  if (ServiceSchedulerM$sched_info[svc_id].flags & STOP) {
      ServiceSchedulerM$Services$stop(svc_id);
    }
  ServiceSchedulerM$sched_info[svc_id] = sched;

  ServiceSchedulerM$sched_info[svc_id].flags = ENABLED | START;

  if (pqueue_enqueue((pqueue_t *)&ServiceSchedulerM$event_q, svc_id) == FAIL) {
    return FAIL;
    }
#line 216
  if (pqueue_peek((pqueue_t *)&ServiceSchedulerM$event_q) == svc_id) {
      ServiceSchedulerM$AbsoluteTimer$cancel();
      return ServiceSchedulerM$AbsoluteTimer$set(sched.start_time);
    }
  return SUCCESS;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ServiceScheduler.nc"
inline static  result_t TupleRouterM$ServiceScheduler$reschedule(uint8_t arg_0x20eeab0, tos_service_schedule arg_0x20eec58){
#line 51
  unsigned char result;
#line 51

#line 51
  result = ServiceSchedulerM$ServiceScheduler$reschedule(arg_0x20eeab0, arg_0x20eec58);
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
inline static  result_t TupleRouterM$AbsoluteTimer$set(tos_time_t arg_0x20b7920){
#line 50
  unsigned char result;
#line 50

#line 50
  result = SimpleTimeM$AbsoluteTimer$set(0U, arg_0x20b7920);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 2518 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$decrementQueryCounter(void)
#line 2518
{
  TupleRouterM$mClockCount++;
}

#line 430
static inline bool TupleRouterM$IS_AGGREGATING_RESULT(void)
#line 430
{
#line 430
  return (TupleRouterM$mPendingMask & TupleRouterM$AGGREGATING_BIT) != 0;
}

#line 422
static inline bool TupleRouterM$IS_DELIVERING_TUPLES(void)
#line 422
{
#line 422
  return (TupleRouterM$mPendingMask & TupleRouterM$DELIVERING_BIT) != 0;
}

#line 418
static inline bool TupleRouterM$IS_ROUTING_TUPLES(void)
#line 418
{
#line 418
  return (TupleRouterM$mPendingMask & TupleRouterM$ROUTING_BIT) != 0;
}

#line 414
static inline bool TupleRouterM$IS_STARTING_ATTRIBUTE(void)
#line 414
{
#line 414
  return (TupleRouterM$mPendingMask & TupleRouterM$ATTR_STARTING_BIT) != 0;
}

#line 410
static inline bool TupleRouterM$IS_FETCHING_ATTRIBUTE(void)
#line 410
{
#line 410
  return (TupleRouterM$mPendingMask & TupleRouterM$FETCHING_BIT) != 0;
}

# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$enqueue(uint8_t arg_0x20d9558, QueryResultPtr arg_0x20d96d8, bool *arg_0x20d9870, ParsedQueryPtr arg_0x20d99f0){
#line 55
  unsigned char result;
#line 55

#line 55
  result = DBBufferC$DBBuffer$enqueue(arg_0x20d9558, arg_0x20d96d8, arg_0x20d9870, arg_0x20d99f0);
#line 55

#line 55
  return result;
#line 55
}
#line 55
# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AbsoluteTimer.nc"
inline static  result_t TupleRouterM$AbsoluteTimer$cancel(void){
#line 56
  unsigned char result;
#line 56

#line 56
  result = SimpleTimeM$AbsoluteTimer$cancel(0U);
#line 56

#line 56
  return result;
#line 56
}
#line 56
# 2176 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  void TupleRouterM$mainTask(void)
#line 2176
{




  if (TupleRouterM$mStopped) {
      TupleRouterM$AbsoluteTimer$cancel();
      return;
    }


  if (TupleRouterM$IS_SENDING_MESSAGE()) {


      TupleRouterM$mNumBlocked++;
      if (TupleRouterM$mNumBlocked > 32) {
          TupleRouterM$mNumBlocked = 0;
          TupleRouterM$outputDone(&TupleRouterM$mMsg);
        }
      else {

          return;
        }
    }

  TupleRouterM$mNumBlocked = 0;


  if (TupleRouterM$mDeliverWait) {
      TupleRouterM$mDeliverWait--;
      if (TupleRouterM$mDeliverWait == 0) {
          ParsedQuery *pq;
          bool pending = FALSE;
          TinyDBError err;

          if (TOS_LOCAL_ADDRESS == 0 && TupleRouterM$mWaitIsDummy) {
            }
          else {
              if (TupleRouterM$getQuery(TupleRouterM$mEnqResult.qid, &pq)) {



                  err = TupleRouterM$DBBuffer$enqueue(pq->bufferId, &TupleRouterM$mEnqResult, &pending, pq);




                  if (err != err_ResultBufferBusy && err != err_NoError) {
                    TupleRouterM$signalError(err, 2224);
                    }
                }
#line 2226
              if (!pending) {
#line 2226
                TOS_post(TupleRouterM$deliverTuplesTask);
                }
            }
        }
      else {
#line 2230
        return;
        }
    }
  else 
#line 2231
    {

      if (TupleRouterM$mSendQueryNextClock) {
          TupleRouterM$mSendQueryNextClock = FALSE;
          TOS_post(TupleRouterM$sendQuery);
        }
    }




  if (TupleRouterM$IS_FETCHING_ATTRIBUTE() || TupleRouterM$IS_STARTING_ATTRIBUTE()) {

      TupleRouterM$mFetchTries++;

      if (TupleRouterM$mFetchTries < TupleRouterM$UDF_WAIT_LOOP) {
        return;
        }
      else {
          if (TupleRouterM$IS_FETCHING_ATTRIBUTE()) {
            TupleRouterM$UNSET_FETCHING_ATTRIBUTE();
            }
#line 2252
          if (TupleRouterM$IS_STARTING_ATTRIBUTE()) {
            TupleRouterM$UNSET_STARTING_ATTRIBUTE();
            }
        }
    }
  else {
#line 2255
    if (TupleRouterM$IS_ROUTING_TUPLES()) {

        return;
      }
    else {
#line 2258
      if (TupleRouterM$IS_DELIVERING_TUPLES()) {

          return;
        }
      else {
#line 2261
        if (TupleRouterM$IS_AGGREGATING_RESULT()) {

            return;
          }
        }
      }
    }
  TupleRouterM$mFetchTries = 0;



  TupleRouterM$mCurRouteQuery = NULL;
  TupleRouterM$mCurExpr = -1;
  {
  }
#line 2274
  ;
#line 2304
  TOS_post(TupleRouterM$deliverTuplesTask);
}

#line 435
static inline void TupleRouterM$UNSET_SENDING_QUERY(void)
#line 435
{
#line 435
  TupleRouterM$mPendingMask &= TupleRouterM$SENDING_QUERY_BIT ^ 0xFFFF;
}

# 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  uint8_t ParsedQuery$ParsedQueryIntf$getFieldId(ParsedQueryPtr q, uint8_t n)
#line 109
{
  return q->queryToSchemaFieldMap[n];
}

# 57 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  uint8_t TupleRouterM$ParsedQueryIntf$getFieldId(ParsedQueryPtr arg_0x2069010, uint8_t arg_0x2069188){
#line 57
  unsigned char result;
#line 57

#line 57
  result = ParsedQuery$ParsedQueryIntf$getFieldId(arg_0x2069010, arg_0x2069188);
#line 57

#line 57
  return result;
#line 57
}
#line 57
#line 43
inline static  bool TupleRouterM$ParsedQueryIntf$queryFieldIsNull(uint8_t arg_0x206c928){
#line 43
  unsigned char result;
#line 43

#line 43
  result = ParsedQuery$ParsedQueryIntf$queryFieldIsNull(arg_0x206c928);
#line 43

#line 43
  return result;
#line 43
}
#line 43
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr TupleRouterM$AttrUse$getAttrById(uint8_t arg_0x204da90){
#line 72
  struct __nesc_unnamed4282 *result;
#line 72

#line 72
  result = Attr$AttrUse$getAttrById(arg_0x204da90);
#line 72

#line 72
  return result;
#line 72
}
#line 72
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$greenToggle(void){
#line 106
  unsigned char result;
#line 106

#line 106
  result = LedsC$Leds$greenToggle();
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t NetworkMultiHopM$SendQueryMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088){
#line 48
  unsigned char result;
#line 48

#line 48
  result = QueuedSendM$QueueSendMsg$send(kQUERY_MESSAGE_ID, arg_0x17d4d80, arg_0x17d4ef8, arg_0x17d3088);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 145 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static __inline int8_t *TinyAlloc$deref(Handle h)
#line 145
{
#line 145
  return (int8_t *)*h;
}

#line 558
static inline  result_t TinyAlloc$MemAlloc$lock(Handle handle)
#line 558
{

  int8_t *ptr = TinyAlloc$deref(handle);

  (
#line 561
  (int16_t *)(ptr - TinyAlloc$HEADER_SIZE))[0] |= 0x8000;
  return SUCCESS;
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t DBBufferC$MemAlloc$lock(Handle arg_0x2084328){
#line 84
  unsigned char result;
#line 84

#line 84
  result = TinyAlloc$MemAlloc$lock(arg_0x2084328);
#line 84

#line 84
  return result;
#line 84
}
#line 84
# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$toBytes(QueryResultPtr qr, ParsedQueryPtr pq, CharPtr bytes)
#line 149
{
  short size = sizeof(QueryResult ) - sizeof  qr->d;
  char *p;
#line 151
  char *q;



  if (
#line 154
  qr->qrType != kIS_AGG && 
  qr->qrType != kNOT_AGG && 
  qr->qrType != kAGG_SINGLE_FIELD) {
    return err_UnknownError;
    }
  if (qr->qrType != kIS_AGG) {
      size += QueryResult$TupleIntf$tupleSize(pq);
    }

  q = (char *)bytes;
  p = (char *)qr;
  while (size--) 
    * q++ = * p++;

  if (qr->qrType == kIS_AGG) {
      short i;

#line 170
      for (i = 0; i < qr->result_idx; i++) {


          * (int16_t *)q = qr->d.buf[i].group;
          q += sizeof(int16_t );






          size = QueryResult$BUF_SIZE;
          p = qr->d.buf[i].data;
          while (size--) 
            * q++ = * p++;
        }
    }
  return err_NoError;
}

# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError DBBufferC$QueryResultIntf$toBytes(QueryResultPtr arg_0x208e200, ParsedQueryPtr arg_0x208e380, CharPtr arg_0x208e4f8){
#line 113
  unsigned char result;
#line 113

#line 113
  result = QueryResult$QueryResultIntf$toBytes(arg_0x208e200, arg_0x208e380, arg_0x208e4f8);
#line 113

#line 113
  return result;
#line 113
}
#line 113
# 566 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline  result_t TinyAlloc$MemAlloc$unlock(Handle handle)
#line 566
{

  int8_t *ptr = TinyAlloc$deref(handle);

  (
#line 569
  (int16_t *)(ptr - TinyAlloc$HEADER_SIZE))[0] &= 0x7FFF;
  return SUCCESS;
}

# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t DBBufferC$MemAlloc$unlock(Handle arg_0x2084898){
#line 94
  unsigned char result;
#line 94

#line 94
  result = TinyAlloc$MemAlloc$unlock(arg_0x2084898);
#line 94

#line 94
  return result;
#line 94
}
#line 94
# 336 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err)
#line 336
{
  return SUCCESS;
}

# 423 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err)
#line 423
{
  return SUCCESS;
}

# 3807 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$DBBuffer$putComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err)
#line 3807
{








  TOS_post(TupleRouterM$deliverTuplesTask);
  return SUCCESS;
}

# 193 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  result_t DBBufferC$DBBuffer$putComplete(uint8_t arg_0x20cdb10, QueryResult *arg_0x20cdcb0, TinyDBError arg_0x20cde30){
#line 193
  unsigned char result;
#line 193

#line 193
  result = TupleRouterM$DBBuffer$putComplete(arg_0x20cdb10, arg_0x20cdcb0, arg_0x20cde30);
#line 193
  result = rcombine(result, ParsedQuery$DBBuffer$putComplete(arg_0x20cdb10, arg_0x20cdcb0, arg_0x20cde30));
#line 193
  result = rcombine(result, Tuple$DBBuffer$putComplete(arg_0x20cdb10, arg_0x20cdcb0, arg_0x20cde30));
#line 193

#line 193
  return result;
#line 193
}
#line 193
# 331 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError result)
#line 331
{
  return SUCCESS;
}

# 418 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError result)
#line 418
{
  return SUCCESS;
}

# 3793 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$DBBuffer$getComplete(uint8_t bufferId, QueryResult *buf, TinyDBError err)
#line 3793
{

  if (err != err_NoError) {
      TupleRouterM$signalError(err, 3796);
    }
  else 
#line 3797
    {
    }



  TupleRouterM$fillInAttrVal(SCHEMA_RESULT_READY);
  return SUCCESS;
}

# 190 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  result_t DBBufferC$DBBuffer$getComplete(uint8_t arg_0x20cd338, QueryResult *arg_0x20cd4d8, TinyDBError arg_0x20cd658){
#line 190
  unsigned char result;
#line 190

#line 190
  result = TupleRouterM$DBBuffer$getComplete(arg_0x20cd338, arg_0x20cd4d8, arg_0x20cd658);
#line 190
  result = rcombine(result, ParsedQuery$DBBuffer$getComplete(arg_0x20cd338, arg_0x20cd4d8, arg_0x20cd658));
#line 190
  result = rcombine(result, Tuple$DBBuffer$getComplete(arg_0x20cd338, arg_0x20cd4d8, arg_0x20cd658));
#line 190

#line 190
  return result;
#line 190
}
#line 190
# 371 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  result_t QueryResult$MemAlloc$allocComplete(HandlePtr handle, result_t success)
#line 371
{
  return SUCCESS;
}

# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$MemAlloc$allocComplete(HandlePtr handle, result_t success)
{
  return SUCCESS;
}

# 157 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TinyAlloc$MemAlloc$allocComplete(HandlePtr arg_0x2081550, result_t arg_0x20816d0){
#line 157
  unsigned char result;
#line 157

#line 157
  result = TinyDBAttrM$MemAlloc$allocComplete(arg_0x2081550, arg_0x20816d0);
#line 157
  result = rcombine(result, AggOperator$MemAlloc$allocComplete(arg_0x2081550, arg_0x20816d0));
#line 157
  result = rcombine(result, TupleRouterM$MemAlloc$allocComplete(arg_0x2081550, arg_0x20816d0));
#line 157
  result = rcombine(result, DBBufferC$MemAlloc$allocComplete(arg_0x2081550, arg_0x20816d0));
#line 157
  result = rcombine(result, QueryResult$MemAlloc$allocComplete(arg_0x2081550, arg_0x20816d0));
#line 157

#line 157
  return result;
#line 157
}
#line 157
# 363 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline  uint16_t ContourMapM$Aggregate$stateSize(ParamList *params, ParamVals *paramValues)
#line 363
{

  uint16_t size = sizeof(ContourMapM$ContourMap );

  return size;
}

# 136 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 135
uint16_t AggregateUseM$Agg$default$stateSize(uint8_t id, 
ParamList *params, ParamVals *paramValues)
#line 136
{
  return 0;
}

# 103 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  uint16_t AggregateUseM$Agg$stateSize(uint8_t arg_0x255b358, ParamList *arg_0x25528c8, ParamVals *arg_0x2552a70){
#line 103
  unsigned int result;
#line 103

#line 103
  switch (arg_0x255b358) {
#line 103
    case kCONTOUR_MAP:
#line 103
      result = ContourMapM$Aggregate$stateSize(arg_0x25528c8, arg_0x2552a70);
#line 103
      break;
#line 103
    default:
#line 103
      result = AggregateUseM$Agg$default$stateSize(arg_0x255b358, arg_0x25528c8, arg_0x2552a70);
#line 103
    }
#line 103

#line 103
  return result;
#line 103
}
#line 103
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  uint16_t AggregateUseM$AggregateUse$stateSize(uint8_t id, ParamList *params, ParamVals *paramValues)
#line 101
{
  return AggregateUseM$Agg$stateSize(id, params, paramValues);
}

# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  uint16_t AggOperator$AggregateUse$stateSize(uint8_t arg_0x2481878, ParamList *arg_0x2481a18, ParamVals *arg_0x2481bc0){
#line 94
  unsigned int result;
#line 94

#line 94
  result = AggregateUseM$AggregateUse$stateSize(arg_0x2481878, arg_0x2481a18, arg_0x2481bc0);
#line 94

#line 94
  return result;
#line 94
}
#line 94
# 580 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline int8_t TinyAlloc$isLocked(int8_t *ptr)
#line 580
{
  return (((int16_t *)(ptr - TinyAlloc$HEADER_SIZE))[0] & 0x8000) != 0;
}

#line 628
static inline Handle TinyAlloc$getH(int8_t *p)
#line 628
{
  int16_t i;

#line 630
  for (i = 0; i < TinyAlloc$MAX_HANDLES; i++) {
      if (TinyAlloc$mHandles[i] == p) {
          return &TinyAlloc$mHandles[i];
        }
    }
  return 0;
}

#line 592
static inline int16_t TinyAlloc$getSize(int8_t *ptr)
#line 592
{
  return (int16_t )(((int16_t *)(ptr - TinyAlloc$HEADER_SIZE))[0] & 0x7FFF);
}

#line 709
static inline int16_t TinyAlloc$start_offset(int8_t *ptr)
#line 709
{
  if (sizeof(int8_t *) == sizeof(int32_t )) {
      int16_t len = (int16_t )(ptr - (int8_t *)&TinyAlloc$mFrame[0] - TinyAlloc$HEADER_SIZE);

#line 712
      return (int16_t )len;
    }
  else {
#line 714
    if (sizeof(int8_t *) == sizeof(int16_t )) {
        int16_t len = (int16_t )(ptr - (int8_t *)&TinyAlloc$mFrame[0] - TinyAlloc$HEADER_SIZE);

#line 716
        return len;
      }
    else {
        return -1;
      }
    }
}

#line 412
static inline void TinyAlloc$shiftUp(Handle hand, int bytes)
#line 412
{
  int16_t start = TinyAlloc$start_offset(TinyAlloc$deref(hand));
  int16_t end = start + TinyAlloc$getSize(TinyAlloc$deref(hand));
  int16_t newstart;
  int16_t newend;

  int8_t *p = TinyAlloc$deref(hand) - TinyAlloc$HEADER_SIZE;
  int8_t *startp = TinyAlloc$deref(hand) - TinyAlloc$HEADER_SIZE - bytes;
#line 419
  int8_t *q;
  int cnt = TinyAlloc$getSize(TinyAlloc$deref(hand));

  q = startp;
  while (cnt--) {
      * q++ = * p++;
    }

  TinyAlloc$remapAddr(*hand, startp + TinyAlloc$HEADER_SIZE);
  *hand = startp + TinyAlloc$HEADER_SIZE;

  newstart = TinyAlloc$start_offset(TinyAlloc$deref(hand));
  newend = newstart + TinyAlloc$getSize(TinyAlloc$deref(hand));



  TinyAlloc$setFreeBits(start, end, 0);
  TinyAlloc$setFreeBits(newstart, newend, 1);
}

# 379 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  result_t QueryResult$MemAlloc$compactComplete(void)
#line 379
{
  return SUCCESS;
}

# 2370 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$MemAlloc$compactComplete(void)
#line 2370
{
  return SUCCESS;
}

# 3573 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$MemAlloc$compactComplete(void)
#line 3573
{
  return SUCCESS;
}

# 429 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline  result_t AggOperator$MemAlloc$compactComplete(void)
#line 429
{
  return SUCCESS;
}

# 175 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$MemAlloc$compactComplete(void)
{
  return SUCCESS;
}

# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TinyAlloc$MemAlloc$compactComplete(void){
#line 179
  unsigned char result;
#line 179

#line 179
  result = TinyDBAttrM$MemAlloc$compactComplete();
#line 179
  result = rcombine(result, AggOperator$MemAlloc$compactComplete());
#line 179
  result = rcombine(result, TupleRouterM$MemAlloc$compactComplete());
#line 179
  result = rcombine(result, DBBufferC$MemAlloc$compactComplete());
#line 179
  result = rcombine(result, QueryResult$MemAlloc$compactComplete());
#line 179

#line 179
  return result;
#line 179
}
#line 179
# 639 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline int16_t TinyAlloc$getNewHandleIdx(void)
#line 639
{
  int16_t i;

#line 641
  for (i = 0; i < TinyAlloc$MAX_HANDLES; i++) {
      if (TinyAlloc$mHandles[i] == 0) {
#line 642
        return i;
        }
    }
#line 644
  return -1;
}

# 435 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline AggOperator$GroupRecord *AggOperator$findGroup(AggOperator$GroupDataHandle dh, short groupNum)
#line 435
{
  short min = 0;
#line 436
  short max = (*dh)->numGroups - 1;
#line 436
  short mid;
  AggOperator$GroupRecord *gr;


  if ((*dh)->numGroups == 0) {
#line 440
    return NULL;
    }
#line 441
  while (max >= min) {
      mid = (min + max) >> 1;

      gr = AggOperator$GET_GROUP_DATA(dh, mid);

      if (gr->groupNo == groupNum) {
#line 446
        return gr;
        }
      if (gr->groupNo > groupNum) {
        max = mid - 1;
        }
      else {
#line 451
        min = mid + 1;
        }
    }
  return NULL;
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t AggOperator$MemAlloc$reallocate(Handle arg_0x2085b88, int16_t arg_0x2085d00){
#line 73
  unsigned char result;
#line 73

#line 73
  result = TinyAlloc$MemAlloc$reallocate(arg_0x2085b88, arg_0x2085d00);
#line 73

#line 73
  return result;
#line 73
}
#line 73
# 375 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  result_t QueryResult$MemAlloc$reallocComplete(Handle handle, result_t success)
#line 375
{
  return SUCCESS;
}

# 171 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TinyDBAttrM.nc"
static inline  result_t TinyDBAttrM$MemAlloc$reallocComplete(Handle handle, result_t success)
{
  return SUCCESS;
}

# 170 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TinyAlloc$MemAlloc$reallocComplete(Handle arg_0x2081c58, result_t arg_0x2081dd8){
#line 170
  unsigned char result;
#line 170

#line 170
  result = TinyDBAttrM$MemAlloc$reallocComplete(arg_0x2081c58, arg_0x2081dd8);
#line 170
  result = rcombine(result, AggOperator$MemAlloc$reallocComplete(arg_0x2081c58, arg_0x2081dd8));
#line 170
  result = rcombine(result, TupleRouterM$MemAlloc$reallocComplete(arg_0x2081c58, arg_0x2081dd8));
#line 170
  result = rcombine(result, DBBufferC$MemAlloc$reallocComplete(arg_0x2081c58, arg_0x2081dd8));
#line 170
  result = rcombine(result, QueryResult$MemAlloc$reallocComplete(arg_0x2081c58, arg_0x2081dd8));
#line 170

#line 170
  return result;
#line 170
}
#line 170
# 519 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline  void TinyAlloc$reallocDone(void)
#line 519
{
  TinyAlloc$MemAlloc$reallocComplete(TinyAlloc$mOldHandle, SUCCESS);
}

# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline bool ContourMapM$checkOverlapping(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2)
#line 162
{
  if (region2->boundaries[0].vertices[0].y == region1->boundaries[0].vertices[0].y) {
    if (region2->boundaries[0].vertices[1].y == region1->boundaries[0].vertices[1].y) 
      {
        if (region2->boundaries[0].vertices[0].x - region1->boundaries[0].vertices[0].x <= 20) {
          if (region2->boundaries[0].vertices[1].x - region1->boundaries[0].vertices[1].x <= 20) {
            return TRUE;
            }
          }
#line 170
        if (region1->boundaries[0].vertices[0].x - region2->boundaries[0].vertices[0].x <= 20) {
          if (region1->boundaries[0].vertices[1].x - region2->boundaries[0].vertices[1].x <= 20) {
            return TRUE;
            }
          }
      }
    }
#line 175
  if (region2->boundaries[0].vertices[0].x == region1->boundaries[0].vertices[0].x) {
    if (region2->boundaries[0].vertices[1].x == region1->boundaries[0].vertices[1].x) 
      {
        if (region2->boundaries[0].vertices[0].y - region1->boundaries[0].vertices[0].y <= 20) {
          if (region2->boundaries[0].vertices[1].y - region1->boundaries[0].vertices[1].y <= 20) {
            return TRUE;
            }
          }
#line 182
        if (region1->boundaries[0].vertices[0].y - region2->boundaries[0].vertices[0].y <= 20) {
          if (region1->boundaries[0].vertices[1].y - region2->boundaries[0].vertices[1].y <= 20) {
            return TRUE;
            }
          }
      }
    }
#line 187
  return FALSE;
}







static inline void ContourMapM$computeRegionEpsilon(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2, ContourMapM$ContourRegion *region)
#line 196
{
  int i;
  uint16_t vol1;
#line 198
  uint16_t vol2;
  int16_t *A1;
#line 199
  int16_t *A2;
#line 199
  int16_t *A3;
#line 199
  int16_t *b1;
#line 199
  int16_t *b2;
#line 199
  int16_t *b3;
  int16_t w1[3];
#line 200
  int16_t w2[3];
#line 200
  int16_t w[3];
  uint16_t epsilon;

  A1 = (int16_t *)region1->regression.A;
  A2 = (int16_t *)region2->regression.A;
  A3 = (int16_t *)region->regression.A;
  for (i = 0; i < 5; i++) 
    A3[i] = A1[i] + A2[i];

  b1 = (int16_t *)region1->regression.b;
  b2 = (int16_t *)region2->regression.b;
  b3 = (int16_t *)region->regression.b;
  for (i = 0; i < 3; i++) 
    b3[i] = b1[i] + b2[i];

  ContourMapM$constructRegressionModel(& region1->regression, w1);
  ContourMapM$constructRegressionModel(& region2->regression, w2);
  ContourMapM$constructRegressionModel(& region->regression, w);
  epsilon = 0;

  vol1 = ContourMapM$computeVol(region1, w);
  vol2 = ContourMapM$computeVol(region1, w1);
  if (vol1 - vol2 > 0) {
    epsilon += vol1 - vol2;
    }
  else {
#line 225
    epsilon += vol2 - vol1;
    }
#line 226
  vol1 = ContourMapM$computeVol(region2, w);
  vol2 = ContourMapM$computeVol(region2, w2);
  if (vol1 - vol2 > 0) {
    epsilon += vol1 - vol2;
    }
  else {
#line 231
    epsilon += vol2 - vol1;
    }
#line 232
  vol1 = ContourMapM$computeVol(region1, w1);
  vol2 = ContourMapM$computeVol(region2, w2);
  epsilon += region1->epsilon * vol1 + region2->epsilon * vol2;
  epsilon = epsilon * 100;
  epsilon /= vol1 + vol2;
  if (epsilon % (vol1 + vol2) != 0) {
    epsilon += 1;
    }
#line 239
  region->epsilon = epsilon;
}

# 412 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_FETCHING_ATTRIBUTE(void)
#line 412
{
#line 412
  TupleRouterM$mPendingMask |= TupleRouterM$FETCHING_BIT;
}

# 100 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrGlobalM.nc"
static inline  result_t AttrGlobalM$GroupAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  *errorNo = SCHEMA_RESULT_READY;
  * (uint8_t *)resultBuf = TOS_AM_GROUP;
  return SUCCESS;
}

#line 82
static inline  result_t AttrGlobalM$NodeIdAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  *errorNo = SCHEMA_RESULT_READY;
  * (uint16_t *)resultBuf = TOS_LOCAL_ADDRESS;
  return SUCCESS;
}

# 130 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline   uint32_t SimpleTimeM$Time$getHigh32(void)
#line 130
{
  uint32_t rval;

#line 132
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 132
    {
      rval = SimpleTimeM$time.high32;
    }
#line 134
    __nesc_atomic_end(__nesc_atomic); }
  return rval;
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Time.nc"
inline static   uint32_t AttrTimeM$Time$getHigh32(void){
#line 49
  unsigned long result;
#line 49

#line 49
  result = SimpleTimeM$Time$getHigh32();
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$TimeHighAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  * (uint32_t *)resultBuf = AttrTimeM$Time$getHigh32();
  *errorNo = SCHEMA_RESULT_READY;
  return SUCCESS;
}

# 138 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline   uint32_t SimpleTimeM$Time$getLow32(void)
#line 138
{
  uint32_t rval;

#line 140
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 140
    {
      rval = SimpleTimeM$time.low32;
    }
#line 142
    __nesc_atomic_end(__nesc_atomic); }
  return rval;
}

# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Time.nc"
inline static   uint32_t AttrTimeM$Time$getLow32(void){
#line 52
  unsigned long result;
#line 52

#line 52
  result = SimpleTimeM$Time$getLow32();
#line 52

#line 52
  return result;
#line 52
}
#line 52
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTimeM.nc"
static inline  result_t AttrTimeM$TimeLowAttr$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  * (uint32_t *)resultBuf = AttrTimeM$Time$getLow32();
  *errorNo = SCHEMA_RESULT_READY;
  return SUCCESS;
}

# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
inline static   result_t AttrTempM$ADC$getData(void){
#line 52
  unsigned char result;
#line 52

#line 52
  result = ADCM$ADC$getData(TOS_ADC_INTERNAL_TEMP_PORT);
#line 52

#line 52
  return result;
#line 52
}
#line 52
# 120 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline  result_t AttrTempM$AttrRegister$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 122
    {
      AttrTempM$result = resultBuf;
      AttrTempM$attrName = name;
    }
#line 125
    __nesc_atomic_end(__nesc_atomic); }
  if (AttrTempM$ADC$getData() != SUCCESS) {
    return FAIL;
    }
#line 128
  *errorNo = SCHEMA_RESULT_PENDING;
  return SUCCESS;
}

# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
inline static   result_t AttrVoltageM$ADC$getData(void){
#line 52
  unsigned char result;
#line 52

#line 52
  result = ADCM$ADC$getData(TOS_ADC_INTERNAL_VOLTAGE_PORT);
#line 52

#line 52
  return result;
#line 52
}
#line 52
# 126 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  result_t AttrVoltageM$AttrRegister$getAttr(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 128
    {
      AttrVoltageM$result = resultBuf;
      AttrVoltageM$attrName = name;
    }
#line 131
    __nesc_atomic_end(__nesc_atomic); }










  if (AttrVoltageM$ADC$getData() != SUCCESS) {
    return FAIL;
    }
#line 144
  *errorNo = SCHEMA_RESULT_PENDING;
  return SUCCESS;
}

# 271 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline   result_t Attr$Attr$default$getAttr(uint8_t id, char *name, char *resultBuf, SchemaErrorNo *errorNo)
#line 271
{
  return SUCCESS;
}

# 78 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t Attr$Attr$getAttr(uint8_t arg_0x2621e38, char *arg_0x261a548, char *arg_0x261a6e0, SchemaErrorNo *arg_0x261a880){
#line 78
  unsigned char result;
#line 78

#line 78
  switch (arg_0x2621e38) {
#line 78
    case 0U:
#line 78
      result = AttrGlobalM$NodeIdAttr$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    case 1U:
#line 78
      result = AttrGlobalM$GroupAttr$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    case 2U:
#line 78
      result = AttrTimeM$TimeLowAttr$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    case 3U:
#line 78
      result = AttrTimeM$TimeHighAttr$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    case 4U:
#line 78
      result = AttrTempM$AttrRegister$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    case 5U:
#line 78
      result = AttrVoltageM$AttrRegister$getAttr(arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
      break;
#line 78
    default:
#line 78
      result = Attr$Attr$default$getAttr(arg_0x2621e38, arg_0x261a548, arg_0x261a6e0, arg_0x261a880);
#line 78
    }
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline  result_t Attr$AttrUse$getAttrValue(char *name, char *resultBuf, SchemaErrorNo *errorNo)
{
  AttrDescPtr attrDesc = Attr$AttrUse$getAttr(name);

#line 170
  if (attrDesc == NULL) {
    return FAIL;
    }
#line 172
  if (attrDesc->constIdx >= 0) 
    {
      nmemcpy(resultBuf, (char *)&Attr$constAttrs[(short )attrDesc->constIdx], 
      attrDesc->nbytes);
      *errorNo = SCHEMA_RESULT_READY;
    }
  else {
#line 178
    if (Attr$Attr$getAttr(attrDesc->id, name, resultBuf, errorNo) != SUCCESS) {
      return FAIL;
      }
    }
#line 180
  if (*errorNo == SCHEMA_ERROR) {
    return FAIL;
    }
#line 182
  return SUCCESS;
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  result_t TupleRouterM$AttrUse$getAttrValue(char *arg_0x204c7d0, char *arg_0x204c968, SchemaErrorNo *arg_0x204cb08){
#line 91
  unsigned char result;
#line 91

#line 91
  result = Attr$AttrUse$getAttrValue(arg_0x204c7d0, arg_0x204c968, arg_0x204cb08);
#line 91

#line 91
  return result;
#line 91
}
#line 91
# 345 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   msp430ADCresult_t MSP430ADC12M$ADCSingle$getDataRepeat(uint8_t num, uint16_t jiffies)
{
  return MSP430ADC12M$newRequest(REPEAT_SINGLE_CHANNEL, num, 0, 1, jiffies);
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
inline static   msp430ADCresult_t ADCM$MSP430ADC12Single$getDataRepeat(uint16_t arg_0x26ca958){
#line 86
  enum __nesc_unnamed4259 result;
#line 86

#line 86
  result = MSP430ADC12M$ADCSingle$getDataRepeat(2U, arg_0x26ca958);
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 340 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   msp430ADCresult_t MSP430ADC12M$ADCSingle$getData(uint8_t num)
{
  return MSP430ADC12M$newRequest(SINGLE_CHANNEL, num, 0, 1, 0);
}

# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
inline static   msp430ADCresult_t ADCM$MSP430ADC12Single$getData(void){
#line 65
  enum __nesc_unnamed4259 result;
#line 65

#line 65
  result = MSP430ADC12M$ADCSingle$getData(2U);
#line 65

#line 65
  return result;
#line 65
}
#line 65
#line 50
inline static  result_t ADCM$MSP430ADC12Single$bind(MSP430ADC12Settings_t arg_0x26c7d00){
#line 50
  unsigned char result;
#line 50

#line 50
  result = MSP430ADC12M$ADCSingle$bind(2U, arg_0x26c7d00);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 126 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline result_t ADCM$triggerConversion(uint8_t port)
#line 126
{
  MSP430ADC12Settings_t settings;

#line 128
  settings.refVolt2_5 = (ADCM$TOSH_adc_portmap[port] & 0x80) >> 7;
  settings.clockSourceSHT = SHT_SOURCE_SMCLK;
  settings.clockSourceSAMPCON = SAMPCON_SOURCE_SMCLK;
  settings.referenceVoltage = (ADCM$TOSH_adc_portmap[port] & 0x70) >> 4;
  settings.clockDivSAMPCON = SAMPCON_CLOCK_DIV_1;
  settings.clockDivSHT = SHT_CLOCK_DIV_1;
  settings.inputChannel = ADCM$TOSH_adc_portmap[port] & 0x0F;
  settings.sampleHoldTime = ADCM$samplingRate;



  if (ADCM$MSP430ADC12Single$bind(settings) == SUCCESS) {

      if ((
#line 140
      !ADCM$continuousData && ADCM$MSP430ADC12Single$getData() != MSP430ADC12_FAIL)
       || (ADCM$continuousData && ADCM$MSP430ADC12Single$getDataRepeat(0) != MSP430ADC12_FAIL)) {
          ADCM$owner = port;
          return SUCCESS;
        }
    }
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 146
    ADCM$busy = FALSE;
#line 146
    __nesc_atomic_end(__nesc_atomic); }
  return FAIL;
}

# 240 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline   RefVolt_t RefVoltM$RefVolt$getState(void)
#line 240
{
  if (RefVoltM$state == RefVoltM$REFERENCE_2_5V_STABLE) {
    return REFERENCE_2_5V;
    }
#line 243
  if (RefVoltM$state == RefVoltM$REFERENCE_1_5V_STABLE) {
    return REFERENCE_1_5V;
    }
#line 245
  return REFERENCE_UNSTABLE;
}

# 118 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.nc"
inline static   RefVolt_t MSP430ADC12M$RefVolt$getState(void){
#line 118
  enum __nesc_unnamed4353 result;
#line 118

#line 118
  result = RefVoltM$RefVolt$getState();
#line 118

#line 118
  return result;
#line 118
}
#line 118
#line 93
inline static   result_t MSP430ADC12M$RefVolt$get(RefVolt_t arg_0x2760d28){
#line 93
  unsigned char result;
#line 93

#line 93
  result = RefVoltM$RefVolt$get(arg_0x2760d28);
#line 93

#line 93
  return result;
#line 93
}
#line 93
# 130 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline msp430ADCresult_t MSP430ADC12M$getRefVolt(uint8_t num)
{
  msp430ADCresult_t adcResult = MSP430ADC12_SUCCESS;
  result_t vrefResult;
  adc12memctl_t memctl = MSP430ADC12M$adc12settings[num].memctl;

  if (memctl.sref == REFERENCE_VREFplus_AVss || 
  memctl.sref == REFERENCE_VREFplus_VREFnegterm) 
    {
      if (MSP430ADC12M$adc12settings[num].gotRefVolt == 0) {
          if (MSP430ADC12M$adc12settings[num].refVolt2_5) {
            vrefResult = MSP430ADC12M$RefVolt$get(REFERENCE_2_5V);
            }
          else {
#line 143
            vrefResult = MSP430ADC12M$RefVolt$get(REFERENCE_1_5V);
            }
        }
      else {
#line 145
        vrefResult = SUCCESS;
        }
#line 146
      if (vrefResult != SUCCESS) 
        {
          adcResult = MSP430ADC12_FAIL;
        }
      else 
#line 149
        {
          MSP430ADC12M$adc12settings[num].gotRefVolt = 1;
          if (MSP430ADC12M$RefVolt$getState() == REFERENCE_UNSTABLE) {
            adcResult = MSP430ADC12_DELAYED;
            }
        }
    }
#line 155
  return adcResult;
}

# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerMilli.nc"
inline static  result_t RefVoltM$SwitchOnTimer$setOneShot(int32_t arg_0x1e4fe38){
#line 28
  unsigned char result;
#line 28

#line 28
  result = TimerM$TimerMilli$setOneShot(0U, arg_0x1e4fe38);
#line 28

#line 28
  return result;
#line 28
}
#line 28
# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline  void RefVoltM$switchOnDelay(void)
#line 162
{
  RefVoltM$SwitchOnTimer$setOneShot(17);
}

# 141 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setRef2_5V(void)
#line 141
{
#line 141
  HPLADC12M$ADC12CTL0 |= 0x0040;
}

# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void RefVoltM$HPLADC12$setRef2_5V(void){
#line 76
  HPLADC12M$HPLADC12$setRef2_5V();
#line 76
}
#line 76
# 140 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setRef1_5V(void)
#line 140
{
#line 140
  HPLADC12M$ADC12CTL0 &= ~0x0040;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void RefVoltM$HPLADC12$setRef1_5V(void){
#line 75
  HPLADC12M$HPLADC12$setRef1_5V();
#line 75
}
#line 75
# 137 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setRefOn(void)
#line 137
{
#line 137
  HPLADC12M$ADC12CTL0 |= 0x0020;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void RefVoltM$HPLADC12$setRefOn(void){
#line 72
  HPLADC12M$HPLADC12$setRefOn();
#line 72
}
#line 72
# 140 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static __inline void RefVoltM$switchRefOn(uint8_t vref)
#line 140
{
  RefVoltM$HPLADC12$disableConversion();
  RefVoltM$HPLADC12$setRefOn();
  if (vref == REFERENCE_1_5V) {
      RefVoltM$HPLADC12$setRef1_5V();
      RefVoltM$state = RefVoltM$REFERENCE_1_5V_PENDING;
    }
  else {
      RefVoltM$HPLADC12$setRef2_5V();
      RefVoltM$state = RefVoltM$REFERENCE_2_5V_PENDING;
    }
  TOS_post(RefVoltM$switchOnDelay);
}

static __inline void RefVoltM$switchToRefPending(uint8_t vref)
#line 154
{
  RefVoltM$switchRefOn(vref);
}

static __inline void RefVoltM$switchToRefStable(uint8_t vref)
#line 158
{
  RefVoltM$switchRefOn(vref);
}

# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setSHT(uint8_t sht)
#line 144
{
  uint16_t ctl0 = HPLADC12M$ADC12CTL0;
  uint16_t shttemp = sht & 0x0F;

#line 147
  ctl0 &= 0x00FF;
  ctl0 |= shttemp << 8;
  ctl0 |= shttemp << 12;
  HPLADC12M$ADC12CTL0 = ctl0;
}

# 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$setSHT(uint8_t arg_0x2770e68){
#line 69
  HPLADC12M$HPLADC12$setSHT(arg_0x2770e68);
#line 69
}
#line 69
# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setControl0_IgnoreRef(adc12ctl0_t control0)
#line 58
{
  adc12ctl0_t oldControl0 = * (adc12ctl0_t *)&HPLADC12M$ADC12CTL0;

#line 60
  control0.refon = oldControl0.refon;
  control0.r2_5v = oldControl0.r2_5v;
  HPLADC12M$ADC12CTL0 = * (uint16_t *)&control0;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$setControl0_IgnoreRef(adc12ctl0_t arg_0x2774988){
#line 48
  HPLADC12M$HPLADC12$setControl0_IgnoreRef(arg_0x2774988);
#line 48
}
#line 48
# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$setControl1(adc12ctl1_t control1)
#line 54
{
  HPLADC12M$ADC12CTL1 = * (uint16_t *)&control1;
}

# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$setControl1(adc12ctl1_t arg_0x2776e10){
#line 43
  HPLADC12M$HPLADC12$setControl1(arg_0x2776e10);
#line 43
}
#line 43
# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$TimerA$clear(void)
#line 179
{
#line 179
  MSP430TimerM$TA0CTL |= 0x0004;
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430ADC12M$TimerA$clear(void){
#line 37
  MSP430TimerM$TimerA$clear();
#line 37
}
#line 37
# 182 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$TimerA$disableEvents(void)
#line 182
{
#line 182
  MSP430TimerM$TA0CTL &= ~0x0002;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430ADC12M$TimerA$disableEvents(void){
#line 38
  MSP430TimerM$TimerA$disableEvents();
#line 38
}
#line 38
# 185 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$TimerA$setClockSource(uint16_t clockSource)
{
  MSP430TimerM$TA0CTL = (MSP430TimerM$TA0CTL & ~(0x0100 | 0x0200)) | ((clockSource << 8) & (0x0100 | 0x0200));
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430ADC12M$TimerA$setClockSource(uint16_t arg_0x15f4db0){
#line 39
  MSP430TimerM$TimerA$setClockSource(arg_0x15f4db0);
#line 39
}
#line 39
# 195 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$TimerA$setInputDivider(uint16_t inputDivider)
{
  MSP430TimerM$TA0CTL = (MSP430TimerM$TA0CTL & ~((1 << 6) | (3 << 6))) | ((inputDivider << 8) & ((1 << 6) | (3 << 6)));
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430ADC12M$TimerA$setInputDivider(uint16_t arg_0x15f2260){
#line 40
  MSP430TimerM$TimerA$setInputDivider(arg_0x15f2260);
#line 40
}
#line 40
# 217 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlA0$setControl(MSP430TimerM$CC_t x)
#line 217
{
#line 217
  MSP430TimerM$TA0CCTL0 = MSP430TimerM$CC2int(x);
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void MSP430ADC12M$ControlA0$setControl(MSP430CompareControl_t arg_0x1600560){
#line 34
  MSP430TimerM$ControlA0$setControl(arg_0x1600560);
#line 34
}
#line 34
# 257 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$CompareA0$setEvent(uint16_t x)
#line 257
{
#line 257
  MSP430TimerM$TA0CCR0 = x;
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430ADC12M$CompareA0$setEvent(uint16_t arg_0x1615630){
#line 30
  MSP430TimerM$CompareA0$setEvent(arg_0x1615630);
#line 30
}
#line 30
# 258 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$CompareA1$setEvent(uint16_t x)
#line 258
{
#line 258
  MSP430TimerM$TA0CCR1 = x;
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430ADC12M$CompareA1$setEvent(uint16_t arg_0x1615630){
#line 30
  MSP430TimerM$CompareA1$setEvent(arg_0x1615630);
#line 30
}
#line 30
# 260 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline void MultiHopLEPSM$updateEst(MultiHopLEPSM$TableEntry *Nbr)
#line 260
{
  uint16_t usExpTotal;
#line 261
  uint16_t usActTotal;
#line 261
  uint16_t newAve;

  if (Nbr->flags & MultiHopLEPSM$NBRFLAG_NEW) {
    return;
    }
  usExpTotal = MultiHopLEPSM$ESTIMATE_TO_ROUTE_RATIO;



  {
  }
#line 270
  ;


  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 273
    {
      usActTotal = Nbr->received + Nbr->missed;

      if (usActTotal < usExpTotal) {
          usActTotal = usExpTotal;
        }

      newAve = (uint16_t )255 * (uint16_t )Nbr->received / (uint16_t )usActTotal;
      Nbr->missed = 0;
      Nbr->received = 0;



      if (Nbr->liveliness < MultiHopLEPSM$MIN_LIVELINESS) {
          Nbr->sendEst <<= 1;
        }
      Nbr->liveliness = 0;
    }
#line 290
    __nesc_atomic_end(__nesc_atomic); }



  if (Nbr->flags & MultiHopLEPSM$NBRFLAG_EST_INIT) {
      uint16_t tmp;

#line 296
      tmp = (2 * (uint16_t )Nbr->receiveEst + (uint16_t )newAve * 6) / 8;
      Nbr->receiveEst = (uint8_t )tmp;
    }
  else {
      Nbr->receiveEst = (uint8_t )newAve;
      Nbr->flags ^= MultiHopLEPSM$NBRFLAG_EST_INIT;
    }
}


static inline void MultiHopLEPSM$updateTable(void)
#line 306
{
  MultiHopLEPSM$TableEntry *pNbr;
  uint8_t i = 0;

  MultiHopLEPSM$gwEstTicks++;
  MultiHopLEPSM$gwEstTicks %= MultiHopLEPSM$ESTIMATE_TO_ROUTE_RATIO;

  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
      pNbr = &MultiHopLEPSM$NeighborTbl[i];
      if (pNbr->flags & MultiHopLEPSM$NBRFLAG_VALID) {
          if (MultiHopLEPSM$gwEstTicks == 0) {
            MultiHopLEPSM$updateEst(pNbr);
            }
        }
    }
}

#line 249
static inline uint32_t MultiHopLEPSM$evaluateCost(uint8_t sendEst, uint8_t receiveEst)
#line 249
{
  uint32_t transEst = (uint32_t )sendEst * (uint32_t )receiveEst;
  uint32_t immed = (uint32_t )1 << 24;

  if (transEst == 0) {
#line 253
    return (uint32_t )1 << (uint32_t )16;
    }
  immed = immed / transEst;
  return immed;
}

#line 359
static inline void MultiHopLEPSM$chooseParent(void)
#line 359
{
  MultiHopLEPSM$TableEntry *pNbr;
  uint32_t ulNbrLinkCost = (uint32_t )-1;
  uint32_t ulMinLinkCost = (uint32_t )-1;
  MultiHopLEPSM$TableEntry *pNewParent = NULL;
  uint8_t bNewHopCount = MultiHopLEPSM$ROUTE_INVALID;
  uint8_t i;

  if (TOS_LOCAL_ADDRESS == MultiHopLEPSM$BASE_STATION_ADDRESS) {
#line 367
    return;
    }




  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
      pNbr = &MultiHopLEPSM$NeighborTbl[i];

      if (!(pNbr->flags & MultiHopLEPSM$NBRFLAG_VALID)) {
#line 376
        continue;
        }
#line 377
      if (pNbr->parent == TOS_LOCAL_ADDRESS) {
#line 377
        continue;
        }
#line 378
      if (pNbr->parent == MultiHopLEPSM$ROUTE_INVALID) {
#line 378
        continue;
        }
#line 379
      if (pNbr->hop == MultiHopLEPSM$ROUTE_INVALID) {
#line 379
        continue;
        }
#line 380
      if (pNbr->sendEst < 25) {
#line 380
        continue;
        }
#line 381
      if (pNbr->hop != 0 && pNbr->receiveEst < 25) {
#line 381
        continue;
        }
      ulNbrLinkCost = MultiHopLEPSM$evaluateCost(pNbr->sendEst, pNbr->receiveEst);

      if (pNbr->hop != 0 && ulNbrLinkCost > MultiHopLEPSM$MAX_ALLOWABLE_LINK_COST) {
#line 385
        continue;
        }
      if (pNbr->hop < bNewHopCount || (
      pNbr->hop == bNewHopCount && ulMinLinkCost > ulNbrLinkCost)) {
          ulMinLinkCost = ulNbrLinkCost;
          pNewParent = pNbr;
          bNewHopCount = pNbr->hop;
        }
    }


  if (pNewParent) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 397
        {
          MultiHopLEPSM$gpCurrentParent = pNewParent;
          MultiHopLEPSM$gbCurrentHopCount = bNewHopCount + 1;
        }
#line 400
        __nesc_atomic_end(__nesc_atomic); }
    }
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t MultiHopLEPSM$SendMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088){
#line 48
  unsigned char result;
#line 48

#line 48
  result = QueuedSendM$QueueSendMsg$send(AM_MULTIHOPMSG, arg_0x17d4d80, arg_0x17d4ef8, arg_0x17d3088);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 404 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  void MultiHopLEPSM$SendRouteTask(void)
#line 404
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&MultiHopLEPSM$routeMsg.data[0];
  MultiHopLEPSM$RoutePacket *pRP = (MultiHopLEPSM$RoutePacket *)&pMHMsg->data[0];
  struct MultiHopLEPSM$SortEntry sortTbl[MultiHopLEPSM$ROUTE_TABLE_SIZE];
  uint8_t length = (size_t )& ((TOS_MHopMsg *)0)->data + (size_t )& ((MultiHopLEPSM$RoutePacket *)0)->estList;
  uint8_t maxEstEntries;
  uint8_t i;
#line 410
  uint8_t j;

  if (MultiHopLEPSM$gfSendRouteBusy) {
      return;
    }

  {
  }
#line 416
  ;

  maxEstEntries = 89 - length;
  maxEstEntries = maxEstEntries / sizeof(MultiHopLEPSM$RPEstEntry );

  for (i = 0, j = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
      if (MultiHopLEPSM$NeighborTbl[i].flags & MultiHopLEPSM$NBRFLAG_VALID) {
          sortTbl[j].id = MultiHopLEPSM$NeighborTbl[i].id;
          sortTbl[j].receiveEst = MultiHopLEPSM$NeighborTbl[i].receiveEst;
          j++;
        }
    }


  pRP->parent = MultiHopLEPSM$gpCurrentParent ? MultiHopLEPSM$gpCurrentParent->id : MultiHopLEPSM$ROUTE_INVALID;


  pRP->estEntries = j > maxEstEntries ? maxEstEntries : j;
  for (i = 0; i < pRP->estEntries; i++) {
      pRP->estList[i].id = sortTbl[i].id;
      pRP->estList[i].receiveEst = sortTbl[i].receiveEst;
      length += sizeof(MultiHopLEPSM$RPEstEntry );
    }

  pMHMsg->sourceaddr = pMHMsg->originaddr = TOS_LOCAL_ADDRESS;
  pMHMsg->hopcount = MultiHopLEPSM$gbCurrentHopCount;
  pMHMsg->seqno = MultiHopLEPSM$gCurrentSeqNo++;

  if (MultiHopLEPSM$SendMsg$send(TOS_BCAST_ADDR, length, &MultiHopLEPSM$routeMsg) == SUCCESS) {
      MultiHopLEPSM$gfSendRouteBusy = TRUE;
    }
}

# 470 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$CompareB3$setEventFromNow(uint16_t x)
#line 470
{
#line 470
  MSP430TimerM$TBCCR3 = TBR + x;
}

# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void TimerM$AlarmCompare$setEventFromNow(uint16_t arg_0x1614010){
#line 32
  MSP430TimerM$CompareB3$setEventFromNow(arg_0x1614010);
#line 32
}
#line 32
# 366 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB3$clearPendingInterrupt(void)
#line 366
{
#line 366
  MSP430TimerM$TBCCTL3 &= ~0x0001;
}

# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerM$AlarmControl$clearPendingInterrupt(void){
#line 32
  MSP430TimerM$ControlB3$clearPendingInterrupt();
#line 32
}
#line 32
# 414 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB3$enableEvents(void)
#line 414
{
#line 414
  MSP430TimerM$TBCCTL3 |= 0x0010;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerM$AlarmControl$enableEvents(void){
#line 38
  MSP430TimerM$ControlB3$enableEvents();
#line 38
}
#line 38
# 416 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_STARTING_ATTRIBUTE(void)
#line 416
{
#line 416
  TupleRouterM$mPendingMask |= TupleRouterM$ATTR_STARTING_BIT;
}

#line 538
static inline void TupleRouterM$startAllQueryAttrs(void)
{
  TupleRouterM$QueryListHandle curq;

  TupleRouterM$SET_STARTING_ATTRIBUTE();

  for (curq = TupleRouterM$mQs; curq != NULL; curq = (TupleRouterM$QueryListHandle )(*curq)->next) 
    {
      if ((*curq)->q.clocksPerSample > 0) {
        TupleRouterM$mNumAttrs += (*curq)->q.numFields;
        }
    }
#line 549
  for (curq = TupleRouterM$mQs; curq != NULL; curq = (TupleRouterM$QueryListHandle )(*curq)->next) 
    {
      if ((*curq)->q.clocksPerSample > 0) {
        TupleRouterM$startQueryAttrs(& (*curq)->q);
        }
    }
}

# 684 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$RouteControl$manualUpdate(void)
#line 684
{
  result_t Result;

  Result = TOS_post(MultiHopLEPSM$TimerTask);
  return Result;
}

# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
inline static  result_t MultiHopEngineM$RouteSelectCntl$manualUpdate(void){
#line 144
  unsigned char result;
#line 144

#line 144
  result = MultiHopLEPSM$RouteControl$manualUpdate();
#line 144

#line 144
  return result;
#line 144
}
#line 144
# 297 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  result_t MultiHopEngineM$RouteControl$manualUpdate(void)
#line 297
{
  return MultiHopEngineM$RouteSelectCntl$manualUpdate();
}

# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
inline static  result_t TupleRouterM$RouteControl$manualUpdate(void){
#line 144
  unsigned char result;
#line 144

#line 144
  result = MultiHopEngineM$RouteControl$manualUpdate();
#line 144

#line 144
  return result;
#line 144
}
#line 144
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t SimpleTimeM$TimerControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = TimerM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline  result_t SimpleTimeM$StdControl$start(void)
#line 87
{
  uint16_t cur_interval;

  SimpleTimeM$TimerControl$start();
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 91
    {
#line 91
      cur_interval = SimpleTimeM$interval;
    }
#line 92
    __nesc_atomic_end(__nesc_atomic); }
#line 92
  SimpleTimeM$Timer$start(TIMER_REPEAT, cur_interval);
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t TupleRouterM$TimerControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = SimpleTimeM$StdControl$start();
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 111 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline   void SimpleTimeM$setInterval(uint16_t new_interval)
#line 111
{

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 113
    {
      SimpleTimeM$interval = new_interval;
      SimpleTimeM$timingChanged = TRUE;
    }
#line 116
    __nesc_atomic_end(__nesc_atomic); }
}

# 178 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
inline static   void TupleRouterM$setSimpleTimeInterval(uint16_t arg_0x20f0788){
#line 178
  SimpleTimeM$setInterval(arg_0x20f0788);
#line 178
}
#line 178
# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/msp430hardware.h"
static inline void __nesc_enable_interrupt(void)
{
   __asm volatile ("eint");}

#line 226
static inline void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts)
{
  if (reenable_interrupts) {
    __nesc_enable_interrupt();
    }
}

#line 245
static __inline void __nesc_atomic_sleep(void)
#line 245
{








  uint16_t LPMode_bits = 0;

  if (LPMode_disabled) {
      __nesc_enable_interrupt();
      return;
    }
  else 
#line 259
    {
      LPMode_bits = 0x0080 + 0x0040 + 0x0010;






      if (((((
#line 262
      TA0CTL & (3 << 4)) != 0 << 4 && (TA0CTL & (3 << 8)) == 2 << 8)
       || (ME1 & ((1 << 7) | (1 << 6)) && U0TCTL & 0x20))
       || (ME2 & ((1 << 5) | (1 << 4)) && U1TCTL & 0x20))


       || (U0CTLnr & 0x01 && I2CTCTLnr & 0x20 && 
      I2CDCTLnr & 0x20 && U0CTLnr & 0x04 && U0CTLnr & 0x20)) {


        LPMode_bits = 0x0040 + 0x0010;
        }

      if (ADC12CTL1 & 0x0001) {
          if (!(ADC12CTL0 & 0x0080) && (TA0CTL & (3 << 8)) == 2 << 8) {
            LPMode_bits = 0x0040 + 0x0010;
            }
          else {
#line 278
            switch (ADC12CTL1 & (3 << 3)) {
                case 2 << 3: LPMode_bits = 0;
#line 279
                break;
                case 3 << 3: LPMode_bits = 0x0040 + 0x0010;
#line 280
                break;
              }
            }
        }
      LPMode_bits |= 0x0008;
       __asm volatile ("bis  %0, r2" :  : "m"((uint16_t )LPMode_bits));}
}

#line 196
static inline void __nesc_disable_interrupt(void)
{
   __asm volatile ("dint");
   __asm volatile ("nop");}







static inline bool are_interrupts_enabled(void)
{
  return (({
#line 209
    uint16_t __x;

#line 209
     __asm volatile ("mov	r2, %0" : "=r"((uint16_t )__x));__x;
  }
  )
#line 209
   & 0x0008) != 0;
}








static inline __nesc_atomic_t __nesc_atomic_start(void )
{
  __nesc_atomic_t result = are_interrupts_enabled();

#line 222
  __nesc_disable_interrupt();
  return result;
}

# 136 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"
static inline bool TOSH_run_next_task(void)
{
  __nesc_atomic_t fInterruptFlags;
  uint8_t old_full;
  void (*func)(void );

  fInterruptFlags = __nesc_atomic_start();
  old_full = TOSH_sched_full;
  func = TOSH_queue[old_full].tp;
  if (func == NULL) 
    {
      __nesc_atomic_sleep();
      return 0;
    }

  TOSH_queue[old_full].tp = NULL;
  TOSH_sched_full = (old_full + 1) & TOSH_TASK_BITMASK;
  __nesc_atomic_end(fInterruptFlags);
  func();

  return 1;
}

static inline void TOSH_run_task(void)
#line 159
{
  for (; ; ) 
    TOSH_run_next_task();
}

# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline MSP430TimerM$CC_t MSP430TimerM$int2CC(uint16_t x)
#line 96
{
#line 96
  union __nesc_unnamed4410 {
#line 96
    uint16_t f;
#line 96
    MSP430TimerM$CC_t t;
  } 
#line 96
  c = { .f = x };

#line 96
  return c.t;
}

#line 205
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA0$getControl(void)
#line 205
{
#line 205
  return MSP430TimerM$int2CC(MSP430TimerM$TA0CCTL0);
}

#line 160
static inline    void MSP430TimerM$CaptureA0$default$captured(uint16_t time)
#line 160
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureA0$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureA0$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 253 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureA0$getEvent(void)
#line 253
{
#line 253
  return MSP430TimerM$TA0CCR0;
}

# 406 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$CompareA0$fired(void)
#line 406
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareA0$fired(void){
#line 34
  MSP430ADC12M$CompareA0$fired();
#line 34
}
#line 34
# 206 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA1$getControl(void)
#line 206
{
#line 206
  return MSP430TimerM$int2CC(MSP430TimerM$TA0CCTL1);
}

#line 161
static inline    void MSP430TimerM$CaptureA1$default$captured(uint16_t time)
#line 161
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureA1$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureA1$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 254 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureA1$getEvent(void)
#line 254
{
#line 254
  return MSP430TimerM$TA0CCR1;
}

# 407 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$CompareA1$fired(void)
#line 407
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareA1$fired(void){
#line 34
  MSP430ADC12M$CompareA1$fired();
#line 34
}
#line 34
# 207 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlA2$getControl(void)
#line 207
{
#line 207
  return MSP430TimerM$int2CC(MSP430TimerM$TA0CCTL2);
}

#line 162
static inline    void MSP430TimerM$CaptureA2$default$captured(uint16_t time)
#line 162
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureA2$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureA2$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 255 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureA2$getEvent(void)
#line 255
{
#line 255
  return MSP430TimerM$TA0CCR2;
}

#line 159
static inline    void MSP430TimerM$CompareA2$default$fired(void)
#line 159
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareA2$fired(void){
#line 34
  MSP430TimerM$CompareA2$default$fired();
#line 34
}
#line 34
# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   uint16_t MSP430DCOCalibM$Timer32khz$read(void){
#line 30
  unsigned int result;
#line 30

#line 30
  result = MSP430TimerM$TimerB$read();
#line 30

#line 30
  return result;
#line 30
}
#line 30
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430DCOCalibM.nc"
static inline   void MSP430DCOCalibM$TimerMicro$overflow(void)
{
  uint16_t now = MSP430DCOCalibM$Timer32khz$read();
  uint16_t delta = now - MSP430DCOCalibM$m_prev;

#line 45
  MSP430DCOCalibM$m_prev = now;

  if (delta > MSP430DCOCalibM$TARGET_DELTA + MSP430DCOCalibM$MAX_DEVIATION) 
    {

      if (DCOCTL < 0xe0) 
        {
          DCOCTL++;
        }
      else {
#line 54
        if ((BCSCTL1 & 7) < 7) 
          {
            BCSCTL1++;
            DCOCTL = 96;
          }
        }
    }
  else {
#line 60
    if (delta < MSP430DCOCalibM$TARGET_DELTA - MSP430DCOCalibM$MAX_DEVIATION) 
      {

        if (DCOCTL > 0) 
          {
            DCOCTL--;
          }
        else {
#line 67
          if ((BCSCTL1 & 7) > 0) 
            {
              BCSCTL1--;
              DCOCTL = 128;
            }
          }
      }
    }
}

# 405 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$TimerA$overflow(void)
#line 405
{
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430TimerM$TimerA$overflow(void){
#line 33
  MSP430ADC12M$TimerA$overflow();
#line 33
  MSP430DCOCalibM$TimerMicro$overflow();
#line 33
}
#line 33
# 347 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB0$getControl(void)
#line 347
{
#line 347
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL0);
}

#line 338
static inline    void MSP430TimerM$CaptureB0$default$captured(uint16_t time)
#line 338
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB0$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB0$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 443 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB0$getEvent(void)
#line 443
{
#line 443
  return MSP430TimerM$TBCCR0;
}

#line 331
static inline    void MSP430TimerM$CompareB0$default$fired(void)
#line 331
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB0$fired(void){
#line 34
  MSP430TimerM$CompareB0$default$fired();
#line 34
}
#line 34
# 348 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB1$getControl(void)
#line 348
{
#line 348
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL1);
}

#line 484
static inline   void MSP430TimerM$CaptureB1$clearOverflow(void)
#line 484
{
#line 484
  MSP430TimerM$TBCCTL1 &= ~0x0002;
}

# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void HPLCC2420InterruptM$SFDCapture$clearOverflow(void){
#line 56
  MSP430TimerM$CaptureB1$clearOverflow();
#line 56
}
#line 56
# 476 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   bool MSP430TimerM$CaptureB1$isOverflowPending(void)
#line 476
{
#line 476
  return MSP430TimerM$TBCCTL1 & 0x0002;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   bool HPLCC2420InterruptM$SFDCapture$isOverflowPending(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = MSP430TimerM$CaptureB1$isOverflowPending();
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 761 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline    void CC2420RadioM$RadioReceiveCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset, TOS_MsgPtr msgBuff)
#line 761
{
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void CC2420RadioM$RadioReceiveCoordinator$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308){
#line 33
  CC2420RadioM$RadioReceiveCoordinator$default$startSymbol(arg_0x18ec010, arg_0x18ec188, arg_0x18ec308);
#line 33
}
#line 33
# 144 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static __inline result_t CC2420RadioM$setAckTimer(uint16_t jiffy)
#line 144
{
  CC2420RadioM$stateTimer = CC2420RadioM$TIMER_ACK;
  return CC2420RadioM$BackoffTimerJiffy$setOneShot(jiffy);
}

# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Capture.nc"
inline static   result_t CC2420RadioM$SFD$enableCapture(bool arg_0x1927e18){
#line 43
  unsigned char result;
#line 43

#line 43
  result = HPLCC2420InterruptM$SFD$enableCapture(arg_0x1927e18);
#line 43

#line 43
  return result;
#line 43
}
#line 43
# 759 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline    void CC2420RadioM$RadioSendCoordinator$default$startSymbol(uint8_t bitsPerBlock, uint8_t offset, TOS_MsgPtr msgBuff)
#line 759
{
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RadioCoordinator.nc"
inline static   void CC2420RadioM$RadioSendCoordinator$startSymbol(uint8_t arg_0x18ec010, uint8_t arg_0x18ec188, TOS_MsgPtr arg_0x18ec308){
#line 33
  CC2420RadioM$RadioSendCoordinator$default$startSymbol(arg_0x18ec010, arg_0x18ec188, arg_0x18ec308);
#line 33
}
#line 33
# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline uint8_t TOSH_READ_CC_SFD_PIN(void)
#line 29
{
#line 29
   static volatile uint8_t r __asm ("0x001C");

#line 29
  return r & (1 << 1);
}

# 344 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$SFD$captured(uint16_t time)
#line 344
{
  switch (CC2420RadioM$stateRadio) {
      case CC2420RadioM$TX_STATE: 

        CC2420RadioM$SFD$enableCapture(FALSE);


      if (!TOSH_READ_CC_SFD_PIN()) {
          CC2420RadioM$SFD$disable();
        }
      else {
          CC2420RadioM$stateRadio = CC2420RadioM$TX_WAIT;
        }

      CC2420RadioM$txbufptr->time = time;
      CC2420RadioM$RadioSendCoordinator$startSymbol(8, 0, CC2420RadioM$txbufptr);


      if (CC2420RadioM$stateRadio == CC2420RadioM$TX_WAIT) {
          break;
        }
      case CC2420RadioM$TX_WAIT: 

        CC2420RadioM$stateRadio = CC2420RadioM$POST_TX_STATE;
      CC2420RadioM$SFD$disable();

      CC2420RadioM$SFD$enableCapture(TRUE);

      if (CC2420RadioM$bAckEnable && CC2420RadioM$txbufptr->addr != TOS_BCAST_ADDR) {
          if (!CC2420RadioM$setAckTimer(75)) {
            CC2420RadioM$sendFailed();
            }
        }
      else {
          if (!TOS_post(CC2420RadioM$PacketSent)) {
            CC2420RadioM$sendFailed();
            }
        }
#line 381
      break;
      default: 

        CC2420RadioM$rxbufptr->time = time;
      CC2420RadioM$RadioReceiveCoordinator$startSymbol(8, 0, CC2420RadioM$rxbufptr);
    }
  return SUCCESS;
}

# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Capture.nc"
inline static   result_t HPLCC2420InterruptM$SFD$captured(uint16_t arg_0x1926478){
#line 53
  unsigned char result;
#line 53

#line 53
  result = CC2420RadioM$SFD$captured(arg_0x1926478);
#line 53

#line 53
  return result;
#line 53
}
#line 53
# 209 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   void HPLCC2420InterruptM$SFDCapture$captured(uint16_t time)
#line 209
{
  result_t val = SUCCESS;

#line 211
  HPLCC2420InterruptM$SFDControl$clearPendingInterrupt();
  val = HPLCC2420InterruptM$SFD$captured(time);
  if (val == FAIL) {
      HPLCC2420InterruptM$SFDControl$disableEvents();
      HPLCC2420InterruptM$SFDControl$clearPendingInterrupt();
    }
  else {
      if (HPLCC2420InterruptM$SFDCapture$isOverflowPending()) {
        HPLCC2420InterruptM$SFDCapture$clearOverflow();
        }
    }
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB1$captured(uint16_t arg_0x162ad18){
#line 74
  HPLCC2420InterruptM$SFDCapture$captured(arg_0x162ad18);
#line 74
}
#line 74
# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_SEL_CC_SFD_MODFUNC(void)
#line 29
{
#line 29
   static volatile uint8_t r __asm ("0x001F");

#line 29
  r |= 1 << 1;
}

# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline uint16_t MSP430TimerM$captureControl(uint8_t l_cm)
{
  MSP430TimerM$CC_t x = { 
  .cm = l_cm & 0x03, 
  .ccis = 0, 
  .clld = 0, 
  .cap = 1, 
  .scs = 1, 
  .ccie = 0 };

  return MSP430TimerM$CC2int(x);
}

#line 388
static inline   void MSP430TimerM$ControlB1$setControlAsCapture(uint8_t cm)
#line 388
{
#line 388
  MSP430TimerM$TBCCTL1 = MSP430TimerM$captureControl(cm);
}

# 36 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void HPLCC2420InterruptM$SFDControl$setControlAsCapture(bool arg_0x1600d08){
#line 36
  MSP430TimerM$ControlB1$setControlAsCapture(arg_0x1600d08);
#line 36
}
#line 36
# 412 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB1$enableEvents(void)
#line 412
{
#line 412
  MSP430TimerM$TBCCTL1 |= 0x0010;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void HPLCC2420InterruptM$SFDControl$enableEvents(void){
#line 38
  MSP430TimerM$ControlB1$enableEvents();
#line 38
}
#line 38
# 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  result_t AMStandard$RadioSend$sendDone(TOS_MsgPtr msg, result_t success)
#line 210
{
  return AMStandard$reportSendDone(msg, success);
}

# 239 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  result_t AMPromiscuous$RadioSend$sendDone(TOS_MsgPtr msg, result_t success)
#line 239
{
  return AMPromiscuous$reportSendDone(msg, success);
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/BareSendMsg.nc"
inline static  result_t CC2420RadioM$Send$sendDone(TOS_MsgPtr arg_0x184da30, result_t arg_0x184dbb0){
#line 67
  unsigned char result;
#line 67

#line 67
  result = AMPromiscuous$RadioSend$sendDone(arg_0x184da30, arg_0x184dbb0);
#line 67
  result = rcombine(result, AMStandard$RadioSend$sendDone(arg_0x184da30, arg_0x184dbb0));
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 444 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB1$getEvent(void)
#line 444
{
#line 444
  return MSP430TimerM$TBCCR1;
}

#line 332
static inline    void MSP430TimerM$CompareB1$default$fired(void)
#line 332
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB1$fired(void){
#line 34
  MSP430TimerM$CompareB1$default$fired();
#line 34
}
#line 34
# 349 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB2$getControl(void)
#line 349
{
#line 349
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL2);
}

#line 340
static inline    void MSP430TimerM$CaptureB2$default$captured(uint16_t time)
#line 340
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB2$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB2$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 445 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB2$getEvent(void)
#line 445
{
#line 445
  return MSP430TimerM$TBCCR2;
}

#line 333
static inline    void MSP430TimerM$CompareB2$default$fired(void)
#line 333
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB2$fired(void){
#line 34
  MSP430TimerM$CompareB2$default$fired();
#line 34
}
#line 34
# 350 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB3$getControl(void)
#line 350
{
#line 350
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL3);
}

#line 341
static inline    void MSP430TimerM$CaptureB3$default$captured(uint16_t time)
#line 341
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB3$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB3$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 446 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB3$getEvent(void)
#line 446
{
#line 446
  return MSP430TimerM$TBCCR3;
}

# 257 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline  void TimerM$checkShortTimers(void)
{
  uint8_t head = TimerM$m_head_short;

#line 260
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 260
    TimerM$m_posted_checkShortTimers = FALSE;
#line 260
    __nesc_atomic_end(__nesc_atomic); }
  TimerM$m_head_short = TimerM$EMPTY_LIST;
  TimerM$executeTimers(head);
  TimerM$setNextShortEvent();
}

#line 186
static inline void TimerM$post_checkShortTimers(void)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      if (!TimerM$m_posted_checkShortTimers) 
        {
          if (TOS_post(TimerM$checkShortTimers)) {
            TimerM$m_posted_checkShortTimers = TRUE;
            }
        }
    }
#line 196
    __nesc_atomic_end(__nesc_atomic); }
}

#line 294
static inline   void TimerM$AlarmCompare$fired(void)
{
  TimerM$post_checkShortTimers();
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB3$fired(void){
#line 34
  TimerM$AlarmCompare$fired();
#line 34
}
#line 34
# 351 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB4$getControl(void)
#line 351
{
#line 351
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL4);
}

#line 342
static inline    void MSP430TimerM$CaptureB4$default$captured(uint16_t time)
#line 342
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB4$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB4$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 447 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB4$getEvent(void)
#line 447
{
#line 447
  return MSP430TimerM$TBCCR4;
}

#line 415
static inline   void MSP430TimerM$ControlB4$enableEvents(void)
#line 415
{
#line 415
  MSP430TimerM$TBCCTL4 |= 0x0010;
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerJiffyAsyncM$AlarmControl$enableEvents(void){
#line 38
  MSP430TimerM$ControlB4$enableEvents();
#line 38
}
#line 38
# 367 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$ControlB4$clearPendingInterrupt(void)
#line 367
{
#line 367
  MSP430TimerM$TBCCTL4 &= ~0x0001;
}

# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerControl.nc"
inline static   void TimerJiffyAsyncM$AlarmControl$clearPendingInterrupt(void){
#line 32
  MSP430TimerM$ControlB4$clearPendingInterrupt();
#line 32
}
#line 32
# 471 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   void MSP430TimerM$CompareB4$setEventFromNow(uint16_t x)
#line 471
{
#line 471
  MSP430TimerM$TBCCR4 = TBR + x;
}

# 32 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void TimerJiffyAsyncM$AlarmCompare$setEventFromNow(uint16_t arg_0x1614010){
#line 32
  MSP430TimerM$CompareB4$setEventFromNow(arg_0x1614010);
#line 32
}
#line 32
# 449 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$BackoffTimerJiffy$fired(void)
#line 449
{
  uint8_t currentstate;

#line 451
  currentstate = CC2420RadioM$stateRadio;

  switch (CC2420RadioM$stateTimer) {
      case CC2420RadioM$TIMER_INITIAL: 
        if (!TOS_post(CC2420RadioM$startSend)) {
            CC2420RadioM$sendFailed();
          }
      break;
      case CC2420RadioM$TIMER_BACKOFF: 
        CC2420RadioM$tryToSend();
      break;
      case CC2420RadioM$TIMER_ACK: 
        if (currentstate == CC2420RadioM$POST_TX_STATE) {





            {
              CC2420RadioM$txbufptr->ack = 0;
              CC2420RadioM$stateRadio = CC2420RadioM$POST_TX_ACK_STATE;
            }
            if (!TOS_post(CC2420RadioM$PacketSent)) {
              CC2420RadioM$sendFailed();
              }
          }
#line 476
      break;
    }
  return SUCCESS;
}

# 12 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
inline static   result_t TimerJiffyAsyncM$TimerJiffyAsync$fired(void){
#line 12
  unsigned char result;
#line 12

#line 12
  result = CC2420RadioM$BackoffTimerJiffy$fired();
#line 12

#line 12
  return result;
#line 12
}
#line 12
# 41 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline   void TimerJiffyAsyncM$AlarmCompare$fired(void)
{
  if (TimerJiffyAsyncM$jiffy < 0xFFFF) {
      TimerJiffyAsyncM$AlarmControl$disableEvents();
      TimerJiffyAsyncM$bSet = FALSE;
      TimerJiffyAsyncM$TimerJiffyAsync$fired();
    }
  else {
      TimerJiffyAsyncM$jiffy = TimerJiffyAsyncM$jiffy - 0xFFFF;
      if (TimerJiffyAsyncM$jiffy > 0xFFFF) {
        TimerJiffyAsyncM$AlarmCompare$setEventFromNow(0xFFFF);
        }
      else 
#line 52
        {
          {




            if (TimerJiffyAsyncM$jiffy > 2) {
              TimerJiffyAsyncM$AlarmCompare$setEventFromNow(TimerJiffyAsyncM$jiffy);
              }
            else {
#line 61
              TimerJiffyAsyncM$AlarmCompare$setEventFromNow(2);
              }
          }
        }
      TimerJiffyAsyncM$AlarmControl$clearPendingInterrupt();
      TimerJiffyAsyncM$AlarmControl$enableEvents();
    }
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB4$fired(void){
#line 34
  TimerJiffyAsyncM$AlarmCompare$fired();
#line 34
}
#line 34
# 721 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$HPLChipconFIFO$TXFIFODone(uint8_t length, uint8_t *data)
#line 721
{
  CC2420RadioM$tryToSend();
  return SUCCESS;
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
inline static   result_t HPLCC2420M$HPLCC2420FIFO$TXFIFODone(uint8_t arg_0x1931a90, uint8_t *arg_0x1931c28){
#line 50
  unsigned char result;
#line 50

#line 50
  result = CC2420RadioM$HPLChipconFIFO$TXFIFODone(arg_0x1931a90, arg_0x1931c28);
#line 50

#line 50
  return result;
#line 50
}
#line 50
# 394 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  void HPLCC2420M$signalTXFIFO(void)
#line 394
{
  uint8_t _txlen;
  uint8_t *_txbuf;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 398
    {
      _txlen = HPLCC2420M$txlen;
      _txbuf = HPLCC2420M$txbuf;
      HPLCC2420M$f.txbufBusy = FALSE;
    }
#line 402
    __nesc_atomic_end(__nesc_atomic); }

  HPLCC2420M$HPLCC2420FIFO$TXFIFODone(_txlen, _txbuf);
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitration.nc"
inline static   result_t HPLCC2420M$BusArbitration$releaseBus(void){
#line 38
  unsigned char result;
#line 38

#line 38
  result = BusArbitrationM$BusArbitration$releaseBus(0U);
#line 38

#line 38
  return result;
#line 38
}
#line 38
# 432 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$isTxEmpty(void)
#line 432
{
  if (HPLUSART0M$U0TCTL & 0x01) {
      return SUCCESS;
    }
  return FAIL;
}

# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$isTxEmpty(void){
#line 191
  unsigned char result;
#line 191

#line 191
  result = HPLUSART0M$USARTControl$isTxEmpty();
#line 191

#line 191
  return result;
#line 191
}
#line 191
# 424 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$isTxIntrPending(void)
#line 424
{
  if (HPLUSART0M$IFG1 & (1 << 7)) {
      HPLUSART0M$IFG1 &= ~(1 << 7);
      return SUCCESS;
    }
  return FAIL;
}

# 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$isTxIntrPending(void){
#line 180
  unsigned char result;
#line 180

#line 180
  result = HPLUSART0M$USARTControl$isTxIntrPending();
#line 180

#line 180
  return result;
#line 180
}
#line 180
# 473 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$tx(uint8_t data)
#line 473
{
  HPLUSART0M$U0TXBUF = data;
  return SUCCESS;
}

# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$tx(uint8_t arg_0x1a693b8){
#line 202
  unsigned char result;
#line 202

#line 202
  result = HPLUSART0M$USARTControl$tx(arg_0x1a693b8);
#line 202

#line 202
  return result;
#line 202
}
#line 202
# 478 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   uint8_t HPLUSART0M$USARTControl$rx(void)
#line 478
{
  uint8_t value;

#line 480
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 480
    {
      value = U0RXBUF;
    }
#line 482
    __nesc_atomic_end(__nesc_atomic); }
  return value;
}

# 209 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   uint8_t HPLCC2420M$USARTControl$rx(void){
#line 209
  unsigned char result;
#line 209

#line 209
  result = HPLUSART0M$USARTControl$rx();
#line 209

#line 209
  return result;
#line 209
}
#line 209
# 17 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline void TOSH_CLR_RADIO_CSN_PIN(void)
#line 17
{
#line 17
   static volatile uint8_t r __asm ("0x001D");

#line 17
  r &= ~(1 << 2);
}

# 37 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitration.nc"
inline static   result_t HPLCC2420M$BusArbitration$getBus(void){
#line 37
  unsigned char result;
#line 37

#line 37
  result = BusArbitrationM$BusArbitration$getBus(0U);
#line 37

#line 37
  return result;
#line 37
}
#line 37
# 415 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline   result_t HPLCC2420M$HPLCC2420FIFO$writeTXFIFO(uint8_t length, uint8_t *data)
#line 415
{
  uint8_t i = 0;
  bool returnFail = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 419
    {
      if (HPLCC2420M$f.txbufBusy) {
        returnFail = TRUE;
        }
      else {
#line 423
        HPLCC2420M$f.txbufBusy = TRUE;
        }
    }
#line 425
    __nesc_atomic_end(__nesc_atomic); }
  if (returnFail) {
    return FAIL;
    }
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 430
        {
          HPLCC2420M$f.busy = TRUE;
          HPLCC2420M$txlen = length;
          HPLCC2420M$txbuf = data;
        }
#line 434
        __nesc_atomic_end(__nesc_atomic); }
      TOSH_CLR_RADIO_CSN_PIN();

      HPLCC2420M$USARTControl$isTxIntrPending();
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx(0x3E);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
      for (i = 0; i < HPLCC2420M$txlen; i++) {
          HPLCC2420M$USARTControl$tx(HPLCC2420M$txbuf[i]);
          while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
        }
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxEmpty()) ;
      TOSH_SET_RADIO_CSN_PIN();
      HPLCC2420M$BusArbitration$releaseBus();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 448
        HPLCC2420M$f.busy = FALSE;
#line 448
        __nesc_atomic_end(__nesc_atomic); }
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 451
        HPLCC2420M$f.txbufBusy = FALSE;
#line 451
        __nesc_atomic_end(__nesc_atomic); }
      return FAIL;
    }
  if (TOS_post(HPLCC2420M$signalTXFIFO) == FAIL) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 455
        HPLCC2420M$f.txbufBusy = FALSE;
#line 455
        __nesc_atomic_end(__nesc_atomic); }
      return FAIL;
    }
  return SUCCESS;
}

# 29 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
inline static   result_t CC2420RadioM$HPLChipconFIFO$writeTXFIFO(uint8_t arg_0x1900bc0, uint8_t *arg_0x1900d58){
#line 29
  unsigned char result;
#line 29

#line 29
  result = HPLCC2420M$HPLCC2420FIFO$writeTXFIFO(arg_0x1900bc0, arg_0x1900d58);
#line 29

#line 29
  return result;
#line 29
}
#line 29
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
inline static   uint16_t CC2420RadioM$HPLChipcon$read(uint8_t arg_0x1904010){
#line 61
  unsigned int result;
#line 61

#line 61
  result = HPLCC2420M$HPLCC2420$read(arg_0x1904010);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 221 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port10$edge(bool l2h)
#line 221
{
  {
    if (l2h) {
#line 223
      P1IES &= ~(1 << 0);
      }
    else {
#line 224
      P1IES |= 1 << 0;
      }
  }
}

# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOPInterrupt$edge(bool arg_0x1b71710){
#line 54
  MSP430InterruptM$Port10$edge(arg_0x1b71710);
#line 54
}
#line 54
# 115 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port10$enable(void)
#line 115
{
#line 115
  MSP430InterruptM$P1IE |= 1 << 0;
}

# 30 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOPInterrupt$enable(void){
#line 30
  MSP430InterruptM$Port10$enable();
#line 30
}
#line 30
# 25 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline uint8_t TOSH_READ_RADIO_CCA_PIN(void)
#line 25
{
#line 25
   static volatile uint8_t r __asm ("0x0020");

#line 25
  return r & (1 << 4);
}

# 751 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline    int16_t CC2420RadioM$MacBackoff$default$congestionBackoff(TOS_MsgPtr m)
#line 751
{
  return (CC2420RadioM$Random$rand() & 0x3F) + 1;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/MacBackoff.nc"
inline static   int16_t CC2420RadioM$MacBackoff$congestionBackoff(TOS_MsgPtr arg_0x18c1cf0){
#line 75
  int result;
#line 75

#line 75
  result = CC2420RadioM$MacBackoff$default$congestionBackoff(arg_0x18c1cf0);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 136 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static __inline result_t CC2420RadioM$setBackoffTimer(uint16_t jiffy)
#line 136
{
  CC2420RadioM$stateTimer = CC2420RadioM$TIMER_BACKOFF;
  if (jiffy == 0) {

    return CC2420RadioM$BackoffTimerJiffy$setOneShot(2);
    }
#line 141
  return CC2420RadioM$BackoffTimerJiffy$setOneShot(jiffy);
}

# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
inline static   uint8_t CC2420RadioM$HPLChipcon$cmd(uint8_t arg_0x1906450){
#line 47
  unsigned char result;
#line 47

#line 47
  result = HPLCC2420M$HPLCC2420$cmd(arg_0x1906450);
#line 47

#line 47
  return result;
#line 47
}
#line 47
# 321 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline void CC2420RadioM$sendPacket(void)
#line 321
{
  uint8_t status;

  CC2420RadioM$HPLChipcon$cmd(0x05);
  status = CC2420RadioM$HPLChipcon$cmd(0x00);
  if ((status >> 3) & 0x01) {

      CC2420RadioM$SFD$enableCapture(TRUE);
    }
  else {

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 332
        CC2420RadioM$stateRadio = CC2420RadioM$PRE_TX_STATE;
#line 332
        __nesc_atomic_end(__nesc_atomic); }
      if (!CC2420RadioM$setBackoffTimer(CC2420RadioM$MacBackoff$congestionBackoff(CC2420RadioM$txbufptr) * 10)) {
          CC2420RadioM$sendFailed();
        }
    }
}

# 352 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB5$getControl(void)
#line 352
{
#line 352
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL5);
}

#line 343
static inline    void MSP430TimerM$CaptureB5$default$captured(uint16_t time)
#line 343
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB5$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB5$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 448 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB5$getEvent(void)
#line 448
{
#line 448
  return MSP430TimerM$TBCCR5;
}

#line 336
static inline    void MSP430TimerM$CompareB5$default$fired(void)
#line 336
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB5$fired(void){
#line 34
  MSP430TimerM$CompareB5$default$fired();
#line 34
}
#line 34
# 353 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   MSP430TimerM$CC_t MSP430TimerM$ControlB6$getControl(void)
#line 353
{
#line 353
  return MSP430TimerM$int2CC(MSP430TimerM$TBCCTL6);
}

#line 344
static inline    void MSP430TimerM$CaptureB6$default$captured(uint16_t time)
#line 344
{
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Capture.nc"
inline static   void MSP430TimerM$CaptureB6$captured(uint16_t arg_0x162ad18){
#line 74
  MSP430TimerM$CaptureB6$default$captured(arg_0x162ad18);
#line 74
}
#line 74
# 449 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
static inline   uint16_t MSP430TimerM$CaptureB6$getEvent(void)
#line 449
{
#line 449
  return MSP430TimerM$TBCCR6;
}

#line 337
static inline    void MSP430TimerM$CompareB6$default$fired(void)
#line 337
{
}

# 34 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Compare.nc"
inline static   void MSP430TimerM$CompareB6$fired(void){
#line 34
  MSP430TimerM$CompareB6$default$fired();
#line 34
}
#line 34
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430DCOCalibM.nc"
static inline   void MSP430DCOCalibM$Timer32khz$overflow(void)
{
}

# 266 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static inline  void TimerM$checkLongTimers(void)
{
  uint8_t head = TimerM$m_head_long;

#line 269
  TimerM$m_head_long = TimerM$EMPTY_LIST;
  TimerM$executeTimers(head);
  TimerM$setNextShortEvent();
}

#line 299
static inline   void TimerM$AlarmTimer$overflow(void)
{
  TimerM$m_hinow++;
  TOS_post(TimerM$checkLongTimers);
}

# 33 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Timer.nc"
inline static   void MSP430TimerM$TimerB$overflow(void){
#line 33
  TimerM$AlarmTimer$overflow();
#line 33
  MSP430DCOCalibM$Timer32khz$overflow();
#line 33
}
#line 33
# 132 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline void AMStandard$dbgPacket(TOS_MsgPtr data)
#line 132
{
  uint8_t i;

  for (i = 0; i < sizeof(TOS_Msg ); i++) 
    {
      {
      }
#line 137
      ;
    }
  {
  }
#line 139
  ;
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SendMsg.nc"
inline static  result_t NetworkMultiHopM$SendStatusMsg$send(uint16_t arg_0x17d4d80, uint8_t arg_0x17d4ef8, TOS_MsgPtr arg_0x17d3088){
#line 48
  unsigned char result;
#line 48

#line 48
  result = QueuedSendM$QueueSendMsg$send(kSTATUS_MESSAGE_ID, arg_0x17d4d80, arg_0x17d4ef8, arg_0x17d3088);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 599 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  uint16_t MultiHopLEPSM$RouteControl$getParent(void)
#line 599
{

  uint16_t addr;

  addr = MultiHopLEPSM$gpCurrentParent != NULL ? MultiHopLEPSM$gpCurrentParent->id : 0xffff;

  return addr;
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
inline static  uint16_t MultiHopEngineM$RouteSelectCntl$getParent(void){
#line 84
  unsigned int result;
#line 84

#line 84
  result = MultiHopLEPSM$RouteControl$getParent();
#line 84

#line 84
  return result;
#line 84
}
#line 84
# 258 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  uint16_t MultiHopEngineM$RouteControl$getParent(void)
#line 258
{
  return MultiHopEngineM$RouteSelectCntl$getParent();
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
inline static  uint16_t NetworkMultiHopM$MultiHopControl$getParent(void){
#line 84
  unsigned int result;
#line 84

#line 84
  result = MultiHopEngineM$RouteControl$getParent();
#line 84

#line 84
  return result;
#line 84
}
#line 84
# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
inline static  ParsedQueryPtr NetworkMultiHopM$QueryProcessor$getQueryIdx(short arg_0x1773630){
#line 67
  struct __nesc_unnamed4298 *result;
#line 67

#line 67
  result = TupleRouterM$QueryProcessor$getQueryIdx(arg_0x1773630);
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 3082 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  short TupleRouterM$QueryProcessor$numQueries(void)
#line 3082
{
  TupleRouterM$QueryListHandle curq;
  short count = 0;

  curq = TupleRouterM$mQs;
  while (curq != NULL) {
      count++;
      curq = (TupleRouterM$QueryListHandle )(*curq)->next;
    }
  return count;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
inline static  short NetworkMultiHopM$QueryProcessor$numQueries(void){
#line 66
  short result;
#line 66

#line 66
  result = TupleRouterM$QueryProcessor$numQueries();
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 427 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  TOS_MsgPtr NetworkMultiHopM$RcvStatusMessage$receive(TOS_MsgPtr msg)
{
  if (((StatusMessage *)msg->data)->fromBase) 
    {
      short numqs;
#line 431
      short i;
      StatusMessage *smsg;

      smsg = (StatusMessage *)& NetworkMultiHopM$mDbg.data;
      smsg->fromBase = FALSE;
      numqs = NetworkMultiHopM$QueryProcessor$numQueries();
      if (numqs > kMAX_QUERIES) {
        numqs = kMAX_QUERIES;
        }
#line 439
      smsg->numQueries = numqs;
      for (i = 0; i < numqs; i++) 
        {
          uint8_t qid = (uint8_t )NetworkMultiHopM$QueryProcessor$getQueryIdx(i)->qid;

#line 443
          {
          }
#line 443
          ;
          smsg->queries[i] = qid;
        }
      if (NetworkMultiHopM$MultiHopControl$getParent() == TOS_UART_ADDR) {
        NetworkMultiHopM$SendStatusMsg$send(TOS_UART_ADDR, kMSG_LEN, &NetworkMultiHopM$mDbg);
        }
      else {
#line 449
        NetworkMultiHopM$SendStatusMsg$send(TOS_BCAST_ADDR, kMSG_LEN, &NetworkMultiHopM$mDbg);
        }
    }
#line 451
  return msg;
}

# 439 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$UNSET_IS_IN_QUERY_MSG(void)
#line 439
{
#line 439
  TupleRouterM$mPendingMask &= TupleRouterM$IN_QUERY_MSG_BIT ^ 0xFFFF;
}

#line 408
static inline void TupleRouterM$SET_SPACE_ALLOCED(void)
#line 408
{
#line 408
  TupleRouterM$mPendingMask |= TupleRouterM$ALLOCED_BIT;
}

# 216 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  QueryMessagePtr NetworkMultiHopM$Network$getQueryPayLoad(TOS_MsgPtr msg)
{
  return (QueryMessagePtr )msg->data;
}

# 148 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  QueryMessagePtr TupleRouterM$Network$getQueryPayLoad(TOS_MsgPtr arg_0x17b7010){
#line 148
  struct QueryMessage *result;
#line 148

#line 148
  result = NetworkMultiHopM$Network$getQueryPayLoad(arg_0x17b7010);
#line 148

#line 148
  return result;
#line 148
}
#line 148
# 959 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$continueQuery(Handle *memory)
#line 959
{
  QueryMessage *qmsg = TupleRouterM$Network$getQueryPayLoad(&TupleRouterM$mMsg);
  short i;

  TupleRouterM$mCurQuery = (Query **)*memory;
  (*TupleRouterM$mCurQuery)->qid = qmsg->qid;
  (*TupleRouterM$mCurQuery)->numFields = qmsg->numFields;
  (*TupleRouterM$mCurQuery)->numExprs = qmsg->numExprs;
  (*TupleRouterM$mCurQuery)->epochDuration = qmsg->epochDuration;
  (*TupleRouterM$mCurQuery)->fromBuffer = qmsg->fromBuffer;
  (*TupleRouterM$mCurQuery)->fromCatalogBuffer = qmsg->fromCatalogBuffer;
  (*TupleRouterM$mCurQuery)->bufferType = qmsg->bufferType;
  (*TupleRouterM$mCurQuery)->queryRoot = 0;
  (*TupleRouterM$mCurQuery)->knownFields = 0;
  (*TupleRouterM$mCurQuery)->knownExprs = 0;
  (*TupleRouterM$mCurQuery)->needsEvent = qmsg->hasEvent;
  {
  }
#line 975
  ;
  (*TupleRouterM$mCurQuery)->hasForClause = qmsg->hasForClause;

  if ((*TupleRouterM$mCurQuery)->bufferType != kRADIO) {

      (*TupleRouterM$mCurQuery)->hasBuf = FALSE;
      (*TupleRouterM$mCurQuery)->buf.cmd.hasParam = FALSE;
    }

  (*TupleRouterM$mCurQuery)->hasEvent = FALSE;

  {
  }
#line 986
  ;

  for (i = qmsg->numFields; i < MAX_FIELDS; i++) 
    (*TupleRouterM$mCurQuery)->knownFields |= 1 << i;
  for (i = qmsg->numExprs; i < MAX_EXPRS; i++) 
    (*TupleRouterM$mCurQuery)->knownExprs |= 1 << i;

  {
  }
#line 993
  ;

  TupleRouterM$SET_SPACE_ALLOCED();
  TupleRouterM$addQueryField(qmsg);


  TupleRouterM$forwardQuery(qmsg);
}

# 38 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  short Query$QueryIntf$size(QueryPtr q)
#line 38
{
  return sizeof(Query ) + (q->numFields - 1) * sizeof(Field ) + q->numExprs * sizeof(Expr );
}

# 48 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  short TupleRouterM$QueryIntf$size(QueryPtr arg_0x2074270){
#line 48
  short result;
#line 48

#line 48
  result = Query$QueryIntf$size(arg_0x2074270);
#line 48

#line 48
  return result;
#line 48
}
#line 48
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TupleRouterM$MemAlloc$allocate(HandlePtr arg_0x20854c0, int16_t arg_0x2085638){
#line 61
  unsigned char result;
#line 61

#line 61
  result = TinyAlloc$MemAlloc$allocate(arg_0x20854c0, arg_0x2085638);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 3389 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$allocPendingQuery(TupleRouterM$MemoryCallback callback, Query *q)
#line 3389
{
  TupleRouterM$mAllocState = TupleRouterM$STATE_ALLOC_IN_FLIGHT_QUERY;
  TupleRouterM$mAllocCallback = callback;
  return TupleRouterM$MemAlloc$allocate(&TupleRouterM$mTmpHandle, TupleRouterM$QueryIntf$size(q));
}

#line 407
static inline void TupleRouterM$UNSET_SPACE_ALLOCED(void)
#line 407
{
#line 407
  TupleRouterM$mPendingMask &= TupleRouterM$ALLOCED_BIT ^ 0xFFFF;
}

#line 398
static inline void TupleRouterM$SET_READING_QUERY(void)
#line 398
{
#line 398
  TupleRouterM$mPendingMask |= TupleRouterM$READING_BIT;
#line 398
  TupleRouterM$mQMsgMask = 0x0;
}

#line 400
static inline bool TupleRouterM$IS_READING_QUERY(void)
#line 400
{
#line 400
  return (TupleRouterM$mPendingMask & TupleRouterM$READING_BIT) != 0;
}




static inline bool TupleRouterM$IS_SPACE_ALLOCED(void)
#line 406
{
#line 406
  return (TupleRouterM$mPendingMask & TupleRouterM$ALLOCED_BIT) != 0;
}

# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  int16_t TupleRouterM$MemAlloc$free(Handle arg_0x2084dd8){
#line 104
  int result;
#line 104

#line 104
  result = TinyAlloc$MemAlloc$free(arg_0x2084dd8);
#line 104

#line 104
  return result;
#line 104
}
#line 104
# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimeUtilC.nc"
static inline   tos_time_t TimeUtilC$TimeUtil$add(tos_time_t a, tos_time_t b)
#line 75
{
  tos_time_t result;

#line 77
  result.low32 = a.low32 + b.low32;
  result.high32 = a.high32 + b.high32;
  if (result.low32 < a.low32) {
      result.high32++;
    }
  return result;
}

# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
inline static   tos_time_t SimpleTimeM$TimeUtil$add(tos_time_t arg_0x20af170, tos_time_t arg_0x20af2f0){
#line 87
  struct __nesc_unnamed4330 result;
#line 87

#line 87
  result = TimeUtilC$TimeUtil$add(arg_0x20af170, arg_0x20af2f0);
#line 87

#line 87
  return result;
#line 87
}
#line 87
# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimeUtilC.nc"
static inline   tos_time_t TimeUtilC$TimeUtil$subtract(tos_time_t a, tos_time_t b)
#line 62
{
  tos_time_t result;

  result.low32 = a.low32 - b.low32;
  result.high32 = a.high32 - b.high32;
  if (b.low32 > a.low32) {
      result.high32--;
    }
  return result;
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeUtil.nc"
inline static   tos_time_t SimpleTimeM$TimeUtil$subtract(tos_time_t arg_0x20af7c8, tos_time_t arg_0x20af948){
#line 92
  struct __nesc_unnamed4330 result;
#line 92

#line 92
  result = TimeUtilC$TimeUtil$subtract(arg_0x20af7c8, arg_0x20af948);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 205 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static inline  void SimpleTimeM$TimeSet$set(tos_time_t t)
#line 205
{
  tos_time_t change = SimpleTimeM$TimeUtil$subtract(t, SimpleTimeM$time);
  uint8_t i;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 209
    {
      SimpleTimeM$time = t;
    }
#line 211
    __nesc_atomic_end(__nesc_atomic); }



  for (i = 0; i < MAX_NUM_TIMERS; i++) 
    if (SimpleTimeM$aTimer[i].low32 || SimpleTimeM$aTimer[i].high32) {
      SimpleTimeM$aTimer[i] = SimpleTimeM$TimeUtil$add(SimpleTimeM$aTimer[i], change);
      }
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TimeSet.nc"
inline static  void TupleRouterM$TimeSet$set(tos_time_t arg_0x20a3068){
#line 51
  SimpleTimeM$TimeSet$set(arg_0x20a3068);
#line 51
}
#line 51
# 3439 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$doTimeSync(uint8_t timeSyncData[5], uint16_t clockCount)
#line 3439
{
  tos_time_t mytime;


  mytime.high32 = timeSyncData[0] & 0x000000FF;
  mytime.low32 = * (uint32_t *)&timeSyncData[1];
  TupleRouterM$TimeSet$set(mytime);

  TupleRouterM$checkTime();
}

#line 440
static inline void TupleRouterM$SET_IS_IN_QUERY_MSG(void)
#line 440
{
#line 440
  TupleRouterM$mPendingMask |= TupleRouterM$IN_QUERY_MSG_BIT;
}

#line 438
static inline bool TupleRouterM$IS_IN_QUERY_MSG(void)
#line 438
{
#line 438
  return (TupleRouterM$mPendingMask & TupleRouterM$IN_QUERY_MSG_BIT) != 0;
}

# 130 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$yellowOn(void)
#line 130
{
  {
  }
#line 131
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 132
    {
      TOSH_CLR_YELLOW_LED_PIN();
      LedsC$ledsOn |= LedsC$YELLOW_BIT;
    }
#line 135
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 114 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$yellowOn(void){
#line 114
  unsigned char result;
#line 114

#line 114
  result = LedsC$Leds$yellowOn();
#line 114

#line 114
  return result;
#line 114
}
#line 114
# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$greenOn(void)
#line 101
{
  {
  }
#line 102
  ;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 103
    {
      TOSH_CLR_GREEN_LED_PIN();
      LedsC$ledsOn |= LedsC$GREEN_BIT;
    }
#line 106
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t TupleRouterM$Leds$greenOn(void){
#line 89
  unsigned char result;
#line 89

#line 89
  result = LedsC$Leds$greenOn();
#line 89

#line 89
  return result;
#line 89
}
#line 89
# 775 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$Network$querySub(QueryMessagePtr qmsg)
#line 775
{
  ParsedQuery *q;
  bool oldField = TRUE;

  if (qmsg->msgType == DROP_TABLE_MSG) {
      if (TupleRouterM$IS_IN_QUERY_MSG()) {
        return FAIL;
        }
#line 782
      TupleRouterM$SET_IS_IN_QUERY_MSG();




      if (qmsg->u.ttl-- > 0) {
        TupleRouterM$forwardQuery(qmsg);
        }
#line 789
      TupleRouterM$UNSET_IS_IN_QUERY_MSG();
      return FAIL;
    }
  else {
#line 792
    if (qmsg->msgType == RATE_MSG) {


        if (TupleRouterM$IS_IN_QUERY_MSG()) {
          return SUCCESS;
          }
        TupleRouterM$SET_IS_IN_QUERY_MSG();



        if (!TupleRouterM$getQuery(qmsg->qid, &q)) {
            goto done_rate;
          }
        if (qmsg->fwdNode == TOS_UART_ADDR) {
            TupleRouterM$forwardQuery(qmsg);
          }
        {
        }
#line 808
        ;
        TupleRouterM$setRate(qmsg->qid, qmsg->epochDuration);
        done_rate: 
          TupleRouterM$UNSET_IS_IN_QUERY_MSG();
        return SUCCESS;
      }
    else {
      if (qmsg->msgType == DEL_MSG) {

          ParsedQuery *pq;
          bool isKnown;

          TupleRouterM$Leds$yellowToggle();


          if (TupleRouterM$IS_IN_QUERY_MSG()) {
            return SUCCESS;
            }
          TupleRouterM$SET_IS_IN_QUERY_MSG();

          if (TupleRouterM$getQuery(qmsg->qid, &pq)) {
            isKnown = TRUE;
            }
          else {
#line 831
            isKnown = FALSE;
            }

          TupleRouterM$Leds$greenOn();
          TupleRouterM$Leds$yellowOn();

          TupleRouterM$mQidToRemove = qmsg->qid;
          TupleRouterM$mForceRemove = FALSE;
          TOS_post(TupleRouterM$removeQueryTask);



          if (isKnown) {
              TupleRouterM$forwardQuery(qmsg);
            }
          TupleRouterM$mStoppedQid = qmsg->qid;

          TupleRouterM$UNSET_IS_IN_QUERY_MSG();
          return SUCCESS;
        }
      }
    }
  if (!TupleRouterM$IS_IN_QUERY_MSG()) {


      if (!TupleRouterM$getQuery(qmsg->qid, &q)) {
          TupleRouterM$SET_IS_IN_QUERY_MSG();
          TupleRouterM$mStoppedQid = 0xFF;

          TupleRouterM$doTimeSync(qmsg->timeSyncData, qmsg->clockCount);

          if (TupleRouterM$IS_READING_QUERY()) {
              if (qmsg->qid != (*TupleRouterM$mCurQuery)->qid) {
                  if (TupleRouterM$IS_SPACE_ALLOCED() || TupleRouterM$mTriedAllocWaiting) {


                      if (TupleRouterM$IS_SPACE_ALLOCED()) {
                          TupleRouterM$UNSET_SPACE_ALLOCED();
                          {
                          }
#line 869
                          ;
                          TupleRouterM$MemAlloc$free((Handle )TupleRouterM$mCurQuery);
                        }


                      TupleRouterM$UNSET_READING_QUERY();
                    }
                  else 
#line 875
                    {
                      TupleRouterM$mTriedAllocWaiting = TRUE;
                      TupleRouterM$UNSET_IS_IN_QUERY_MSG();
                      return SUCCESS;
                    }
                }
              else {
#line 880
                if (!TupleRouterM$IS_SPACE_ALLOCED()) {
                    TupleRouterM$UNSET_IS_IN_QUERY_MSG();
                    return SUCCESS;
                  }
                else 
#line 883
                  {
                    oldField = TupleRouterM$addQueryField(qmsg);
                  }
                }

              if (!oldField || qmsg->fwdNode == TOS_UART_ADDR) {
                TupleRouterM$forwardQuery(qmsg);
                }
            }

          if (!TupleRouterM$IS_READING_QUERY()) {

              Query pq;
              QueryMessagePtr qmsgCopy = TupleRouterM$Network$getQueryPayLoad(&TupleRouterM$mMsg);


              TupleRouterM$SET_READING_QUERY();
              TupleRouterM$UNSET_SPACE_ALLOCED();
              TupleRouterM$mTriedAllocWaiting = FALSE;
              pq.qid = qmsg->qid;
              pq.numFields = qmsg->numFields;
              pq.numExprs = qmsg->numExprs;

              *qmsgCopy = *qmsg;

              if (!TupleRouterM$allocPendingQuery(&TupleRouterM$continueQuery, &pq)) {
                  TupleRouterM$UNSET_READING_QUERY();
                }
            }
        }
      else {
#line 912
        if (qmsg->fwdNode == TOS_UART_ADDR) {
          TupleRouterM$forwardQuery(qmsg);
          }
        }
#line 914
      TupleRouterM$UNSET_IS_IN_QUERY_MSG();
    }

  return SUCCESS;
}

# 174 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  result_t NetworkMultiHopM$Network$querySub(QueryMessagePtr arg_0x17b6898){
#line 174
  unsigned char result;
#line 174

#line 174
  result = TupleRouterM$Network$querySub(arg_0x17b6898);
#line 174

#line 174
  return result;
#line 174
}
#line 174
# 296 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  TOS_MsgPtr NetworkMultiHopM$RcvQueryMsg$receive(TOS_MsgPtr msg)
{
  QueryMessagePtr qMsg = NetworkMultiHopM$Network$getQueryPayLoad(msg);

#line 299
  NetworkMultiHopM$Network$querySub(qMsg);
  return msg;
}

# 698 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  TOS_MsgPtr MultiHopLEPSM$ReceiveMsg$receive(TOS_MsgPtr Msg)
#line 698
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
  MultiHopLEPSM$RoutePacket *pRP = (MultiHopLEPSM$RoutePacket *)&pMHMsg->data[0];
  uint16_t saddr;
  uint8_t i;
#line 702
  uint8_t iNbr;

  saddr = pMHMsg->sourceaddr;

  MultiHopLEPSM$updateNbrCounters(saddr, pMHMsg->seqno, &iNbr);


  MultiHopLEPSM$NeighborTbl[iNbr].parent = pRP->parent;
  MultiHopLEPSM$NeighborTbl[iNbr].hop = pMHMsg->hopcount;



  for (i = 0; i < pRP->estEntries; i++) {
      if (pRP->estList[i].id == TOS_LOCAL_ADDRESS) {
          MultiHopLEPSM$NeighborTbl[iNbr].sendEst = pRP->estList[i].receiveEst;
          MultiHopLEPSM$NeighborTbl[iNbr].liveliness++;
        }
    }

  return Msg;
}

# 242 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline   TOS_MsgPtr AMStandard$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg)
#line 242
{
  return msg;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr AMStandard$ReceiveMsg$receive(uint8_t arg_0x1824870, TOS_MsgPtr arg_0x17efd58){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  switch (arg_0x1824870) {
#line 75
    case kQUERY_MESSAGE_ID:
#line 75
      result = NetworkMultiHopM$RcvQueryMsg$receive(arg_0x17efd58);
#line 75
      break;
#line 75
    case kSTATUS_MESSAGE_ID:
#line 75
      result = NetworkMultiHopM$RcvStatusMessage$receive(arg_0x17efd58);
#line 75
      break;
#line 75
    case kDATA_MESSAGE_ID:
#line 75
      result = MultiHopEngineM$ReceiveMsg$receive(kDATA_MESSAGE_ID, arg_0x17efd58);
#line 75
      break;
#line 75
    case AM_MULTIHOPMSG:
#line 75
      result = MultiHopLEPSM$ReceiveMsg$receive(arg_0x17efd58);
#line 75
      result = MultiHopEngineM$ReceiveMsg$receive(AM_MULTIHOPMSG, arg_0x17efd58);
#line 75
      break;
#line 75
    default:
#line 75
      result = AMStandard$ReceiveMsg$default$receive(arg_0x1824870, arg_0x17efd58);
#line 75
    }
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 155 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  TinyDBError TupleRouterM$Network$sendQueryMessage(TOS_MsgPtr arg_0x17b7680){
#line 155
  unsigned char result;
#line 155

#line 155
  result = NetworkMultiHopM$Network$sendQueryMessage(arg_0x17b7680);
#line 155

#line 155
  return result;
#line 155
}
#line 155
# 1581 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  void TupleRouterM$queryMsgTask(void)
#line 1581
{
  if (TupleRouterM$Network$sendQueryMessage(&TupleRouterM$mMsg) != err_NoError) {
      TupleRouterM$UNSET_SENDING_MESSAGE();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1584
        {
          TupleRouterM$mMustTimestamp = TupleRouterM$TS_NO;
        }
#line 1586
        __nesc_atomic_end(__nesc_atomic); }
    }
}

# 50 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  result_t Query$QueryIntf$setField(QueryPtr q, uint8_t idx, Field f)
#line 50
{
  q->fields[idx] = f;
  return SUCCESS;
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  result_t TupleRouterM$QueryIntf$setField(QueryPtr arg_0x20733d8, uint8_t arg_0x2073550, Field arg_0x20736c8){
#line 61
  unsigned char result;
#line 61

#line 61
  result = Query$QueryIntf$setField(arg_0x20733d8, arg_0x2073550, arg_0x20736c8);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  result_t Query$QueryIntf$setExpr(QueryPtr q, uint8_t idx, Expr e)
#line 61
{
  * (Expr *)(char *)((char *)q + sizeof(Query ) + (
  q->numFields - 1) * sizeof(Field ) + 
  idx * sizeof(Expr )) = e;
  return SUCCESS;
}

# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  result_t TupleRouterM$QueryIntf$setExpr(QueryPtr arg_0x2071260, uint8_t arg_0x20713d8, Expr arg_0x2071550){
#line 71
  unsigned char result;
#line 71

#line 71
  result = Query$QueryIntf$setExpr(arg_0x2071260, arg_0x20713d8, arg_0x2071550);
#line 71

#line 71
  return result;
#line 71
}
#line 71
# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  bool Query$QueryIntf$exprsComplete(Query q)
#line 72
{
  return (q.knownExprs & 0xFFFF) == 0xFFFF;
}

# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  bool TupleRouterM$QueryIntf$exprsComplete(Query arg_0x2070010){
#line 77
  unsigned char result;
#line 77

#line 77
  result = Query$QueryIntf$exprsComplete(arg_0x2070010);
#line 77

#line 77
  return result;
#line 77
}
#line 77
# 68 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  bool Query$QueryIntf$fieldsComplete(Query q)
#line 68
{
  return (q.knownFields & 0xFFFF) == 0xFFFF;
}

# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  bool TupleRouterM$QueryIntf$fieldsComplete(Query arg_0x2071aa8){
#line 74
  unsigned char result;
#line 74

#line 74
  result = Query$QueryIntf$fieldsComplete(arg_0x2071aa8);
#line 74

#line 74
  return result;
#line 74
}
#line 74
# 3428 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$queryComplete(Query q)
#line 3428
{



  if (q.bufferType != kRADIO && ! q.hasBuf) {
#line 3432
    return FALSE;
    }
#line 3433
  if (! q.hasEvent && q.needsEvent) {
#line 3433
    return FALSE;
    }
#line 3434
  if (q.hasForClause && q.numEpochs == 0) {
#line 3434
    return FALSE;
    }
#line 3435
  return TupleRouterM$QueryIntf$fieldsComplete(q) && TupleRouterM$QueryIntf$exprsComplete(q);
}

#line 402
static inline void TupleRouterM$SET_PARSING_QUERY(void)
#line 402
{
#line 402
  TupleRouterM$mPendingMask |= TupleRouterM$PARSING_BIT;
}

# 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  short ParsedQuery$ParsedQueryIntf$baseSize(QueryPtr q)
#line 122
{
  return sizeof(ParsedQuery ) + sizeof(char ) * (q->numFields - 1) + sizeof(Expr ) * q->numExprs;
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  short TupleRouterM$ParsedQueryIntf$baseSize(QueryPtr arg_0x2068328){
#line 67
  short result;
#line 67

#line 67
  result = ParsedQuery$ParsedQueryIntf$baseSize(arg_0x2068328);
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 3403 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$allocQuery(TupleRouterM$MemoryCallback callback, Query *q)
#line 3403
{
  short size = sizeof(TupleRouterM$QueryListEl ) - sizeof(ParsedQuery ) + TupleRouterM$ParsedQueryIntf$baseSize(q);

  TupleRouterM$mAllocState = TupleRouterM$STATE_ALLOC_PARSED_QUERY;
  TupleRouterM$mAllocCallback = callback;

  return TupleRouterM$MemAlloc$allocate((Handle *)&TupleRouterM$mTmpHandle, size);
}

# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TupleRouterM$MemAlloc$unlock(Handle arg_0x2084898){
#line 94
  unsigned char result;
#line 94

#line 94
  result = TinyAlloc$MemAlloc$unlock(arg_0x2084898);
#line 94

#line 94
  return result;
#line 94
}
#line 94
# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  Expr TupleRouterM$ParsedQueryIntf$getExpr(ParsedQueryPtr arg_0x206b328, uint8_t arg_0x206b4a0){
#line 51
  struct __nesc_unnamed4310 result;
#line 51

#line 51
  result = ParsedQuery$ParsedQueryIntf$getExpr(arg_0x206b328, arg_0x206b4a0);
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$ParsedQueryIntf$setExpr(ParsedQueryPtr q, uint8_t n, Expr e)
#line 113
{
  * (Expr *)&((char *)q)[sizeof(ParsedQuery ) + (q->numFields - 1) * sizeof(char ) + n * sizeof(Expr )] = e;
  return SUCCESS;
}

# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  result_t TupleRouterM$ParsedQueryIntf$setExpr(ParsedQueryPtr arg_0x2069640, uint8_t arg_0x20697b8, Expr arg_0x2069930){
#line 60
  unsigned char result;
#line 60

#line 60
  result = ParsedQuery$ParsedQueryIntf$setExpr(arg_0x2069640, arg_0x20697b8, arg_0x2069930);
#line 60

#line 60
  return result;
#line 60
}
#line 60
# 64 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  Expr TupleRouterM$QueryIntf$getExpr(QueryPtr arg_0x2073c10, uint8_t arg_0x2073d88){
#line 64
  struct __nesc_unnamed4310 result;
#line 64

#line 64
  result = Query$QueryIntf$getExpr(arg_0x2073c10, arg_0x2073d88);
#line 64

#line 64
  return result;
#line 64
}
#line 64
# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr TupleRouterM$AttrUse$getAttr(char *arg_0x204d508){
#line 66
  struct __nesc_unnamed4282 *result;
#line 66

#line 66
  result = Attr$AttrUse$getAttr(arg_0x204d508);
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  Field *Query$QueryIntf$getFieldPtr(QueryPtr q, uint8_t idx)
#line 46
{
  return &q->fields[idx];
}

# 54 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  Field *TupleRouterM$QueryIntf$getFieldPtr(QueryPtr arg_0x2074d58, uint8_t arg_0x2074ed0){
#line 54
  struct __nesc_unnamed4290 *result;
#line 54

#line 54
  result = Query$QueryIntf$getFieldPtr(arg_0x2074d58, arg_0x2074ed0);
#line 54

#line 54
  return result;
#line 54
}
#line 54
# 3332 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$continueParsing(result_t success)
#line 3332
{
  int i;
  ParsedQuery *pq = TupleRouterM$mTempPQ;
  Query *q = TupleRouterM$mCurQueryPtr;
  AttrDesc *attr;

  if (!success) {
#line 3338
    TupleRouterM$parsedQuery(FALSE);
    }
  if (pq->fromBuffer == kNO_QUERY) {
      while (TupleRouterM$mCurField < q->numFields) {
          Field *f = TupleRouterM$QueryIntf$getFieldPtr(q, TupleRouterM$mCurField);








          {
            attr = TupleRouterM$AttrUse$getAttr(f->name);
            if (attr != NULL) {
                pq->queryToSchemaFieldMap[TupleRouterM$mCurField] = attr->idx;
              }
            else 
#line 3355
              {
                pq->queryToSchemaFieldMap[TupleRouterM$mCurField] = NULL_QUERY_FIELD;
              }
            TupleRouterM$mCurField++;
          }
        }
    }

  for (i = 0; i < q->numExprs; i++) {
      Expr e = TupleRouterM$QueryIntf$getExpr(q, i);

      e.idx = i;


      TupleRouterM$ParsedQueryIntf$setExpr(pq, i, e);
      e = TupleRouterM$ParsedQueryIntf$getExpr(pq, i);


      if (e.opType != kSEL) {
        pq->hasAgg = TRUE;
        }
    }



  TupleRouterM$parsedQuery(TRUE);
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  AttrDescPtr ParsedQuery$AttrUse$getAttr(char *arg_0x204d508){
#line 66
  struct __nesc_unnamed4282 *result;
#line 66

#line 66
  result = Attr$AttrUse$getAttr(arg_0x204d508);
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 217 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  TinyDBError ParsedQuery$ParsedQueryIntf$getResultId(ParsedQueryPtr q, Field *f, uint8_t *id)
#line 217
{
  AttrDescPtr attr = ParsedQuery$AttrUse$getAttr(f->name);
  uint8_t i;
  uint8_t fid = 0xFF;





  if (attr != NULL) {




      for (i = 0; i < q->numFields; i++) {




          if (q->queryToSchemaFieldMap[i] == attr->idx) {
              fid = i;
            }
        }
    }




  if (fid == 0xFF) {


      if (q->tableInfo != NULL) {
        }
    }




  if (fid == 0xFF) {
#line 255
    return err_InvalidIndex;
    }




  for (i = 0; i < q->numExprs; i++) {
      Expr *e = ParsedQuery$ParsedQueryIntf$getExprPtr(q, i);

#line 263
      if (e->opType != kSEL && e->ex.agg.groupingField == fid) {
          *id = GROUP_FIELD;
          return err_NoError;
        }
    }

  if (f->op == kNOOP) {
      *id = fid;
      return err_NoError;
    }
  else 
#line 272
    {
      for (i = 0; i < q->numExprs; i++) {
          Expr *e = ParsedQuery$ParsedQueryIntf$getExprPtr(q, i);

#line 275
          if (e->opType != kSEL && e->ex.agg.field == fid && e->ex.agg.op == f->op) {

              *id = e->idx;
              return err_NoError;
            }
        }
    }


  return err_InvalidIndex;
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQueryIntf.nc"
inline static  TinyDBError DBBufferC$ParsedQueryIntf$getResultId(ParsedQueryPtr arg_0x20650b0, Field *arg_0x2065248, uint8_t *arg_0x20653e0){
#line 101
  unsigned char result;
#line 101

#line 101
  result = ParsedQuery$ParsedQueryIntf$getResultId(arg_0x20650b0, arg_0x2065248, arg_0x20653e0);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 1128 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  TinyDBError DBBufferC$DBBuffer$getFieldId(uint8_t bufferId, FieldPtr f, uint8_t *id)
#line 1128
{
  TinyDBError err = err_NoError;
  ParsedQuery **fromPq;
  int i;

#line 1132
  switch (bufferId) {
      case DBBufferC$kATTR_BUF: 
        *id = NULL_QUERY_FIELD;
      for (i = 0; i < DBBufferC$NUM_ATTR_FIELDS; i++) {
          if (strcmp(f->name, DBBufferC$ATTR_NAMES[i]) == 0) {
            *id = i;
            }
        }
#line 1139
      break;
      default: 
        fromPq = DBBufferC$DBBuffer$getSchema(bufferId);
      if (fromPq == NULL) {
#line 1142
        return err_UnsupportedBuffer;
        }
#line 1143
      err = DBBufferC$ParsedQueryIntf$getResultId(*fromPq, f, id);
      if (err != err_NoError) {
          *id = NULL_QUERY_FIELD;
        }
      return err;
    }
  return err_NoError;
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$getFieldId(uint8_t arg_0x20d64a8, FieldPtr arg_0x20d6628, uint8_t *arg_0x20d67c0){
#line 101
  unsigned char result;
#line 101

#line 101
  result = DBBufferC$DBBuffer$getFieldId(arg_0x20d64a8, arg_0x20d6628, arg_0x20d67c0);
#line 101

#line 101
  return result;
#line 101
}
#line 101
# 42 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static inline  Field Query$QueryIntf$getField(QueryPtr q, uint8_t idx)
#line 42
{
  return q->fields[idx];
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryIntf.nc"
inline static  Field TupleRouterM$QueryIntf$getField(QueryPtr arg_0x2074728, uint8_t arg_0x20748a0){
#line 51
  struct __nesc_unnamed4290 result;
#line 51

#line 51
  result = Query$QueryIntf$getField(arg_0x2074728, arg_0x20748a0);
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 151 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBuffer.nc"
inline static  TinyDBError TupleRouterM$DBBuffer$getBufferId(uint8_t arg_0x20d1330, bool arg_0x20d14b0, uint8_t *arg_0x20d1650){
#line 151
  unsigned char result;
#line 151

#line 151
  result = DBBufferC$DBBuffer$getBufferId(arg_0x20d1330, arg_0x20d14b0, arg_0x20d1650);
#line 151

#line 151
  return result;
#line 151
}
#line 151
# 3271 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$continueFromBufferFetch(TinyDBError err)
#line 3271
{
  ParsedQuery *pq = TupleRouterM$mTempPQ;

  uint8_t bufferId;
  uint8_t i;

  if (err != err_NoError) {

      TupleRouterM$parsedQuery(FALSE);
      return;
    }
#line 3302
  TupleRouterM$mCurField = 0;

  if ((uint8_t )pq->fromBuffer != kNO_QUERY) {
      err = TupleRouterM$DBBuffer$getBufferId(pq->fromBuffer, pq->fromCatalogBuffer, &bufferId);
      if (err != err_NoError) {
          TupleRouterM$signalError(err, 3307);
          TupleRouterM$parsedQuery(FALSE);
          return;
        }



      for (i = 0; i < pq->numFields; i++) {
          Field f = TupleRouterM$QueryIntf$getField(TupleRouterM$mCurQueryPtr, i);

#line 3316
          err = TupleRouterM$DBBuffer$getFieldId(bufferId, &f, &pq->queryToSchemaFieldMap[i]);
          if (err != err_NoError) {
            TupleRouterM$signalError(err, 3318);
            }
        }
    }



  TupleRouterM$continueParsing(SUCCESS);
}

#line 3154
static inline bool TupleRouterM$parseQuery(Query *q, ParsedQuery *pq)
#line 3154
{


  bool pending = FALSE;

  {
  }
#line 3159
  ;


  pq->qid = q->qid;
  pq->numFields = q->numFields;
  pq->numExprs = q->numExprs;
  pq->epochDuration = q->epochDuration;
  pq->savedEpochDur = q->epochDuration;
  pq->numEpochs = q->numEpochs;
  pq->fromBuffer = q->fromBuffer;
  pq->bufferType = q->bufferType;
  pq->bufferId = q->bufferId;
  pq->markedForDeletion = 0;
  pq->currentEpoch = 0;
  pq->buf = q->buf;
  pq->queryRoot = q->queryRoot;
  pq->hasEvent = q->hasEvent;
  pq->tableInfo = NULL;
  pq->hasAgg = FALSE;

  pq->fromCatalogBuffer = q->fromCatalogBuffer;

  TupleRouterM$mCurQueryPtr = q;
  TupleRouterM$mTempPQ = pq;

  if (q->hasEvent) {
#line 3217
      pq->running = FALSE;
    }
  else 
#line 3218
    {





      pq->running = TRUE;
    }
#line 3265
  if (!pending) {
#line 3265
    TupleRouterM$continueFromBufferFetch(err_NoError);
    }
  return TRUE;
}

# 84 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TupleRouterM$MemAlloc$lock(Handle arg_0x2084328){
#line 84
  unsigned char result;
#line 84

#line 84
  result = TinyAlloc$MemAlloc$lock(arg_0x2084328);
#line 84

#line 84
  return result;
#line 84
}
#line 84
# 1071 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$parsedCallback(Handle *memory)
#line 1071
{
  TupleRouterM$QueryListHandle h = (TupleRouterM$QueryListHandle )*memory;
  Expr e;



  e = TupleRouterM$QueryIntf$getExpr(*TupleRouterM$mCurQuery, 0);
  TupleRouterM$MemAlloc$lock((Handle )h);
  {
  }
#line 1079
  ;
  TupleRouterM$mTmpHandle = (Handle )h;
  if (!TupleRouterM$parseQuery(*TupleRouterM$mCurQuery, & (*h)->q)) {
      (*h)->q.qid = (*TupleRouterM$mCurQuery)->qid;

      TupleRouterM$mQidToRemove = (*h)->q.qid;
      TupleRouterM$mForceRemove = TRUE;
      TOS_post(TupleRouterM$removeQueryTask);
      TupleRouterM$MemAlloc$unlock((Handle )h);
      TupleRouterM$MemAlloc$unlock((Handle )TupleRouterM$mCurQuery);
      TupleRouterM$MemAlloc$free((Handle )TupleRouterM$mCurQuery);
      TupleRouterM$UNSET_READING_QUERY();
      TupleRouterM$UNSET_PARSING_QUERY();
      return;
    }
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  result_t TupleRouterM$MemAlloc$reallocate(Handle arg_0x2085b88, int16_t arg_0x2085d00){
#line 73
  unsigned char result;
#line 73

#line 73
  result = TinyAlloc$MemAlloc$reallocate(arg_0x2085b88, arg_0x2085d00);
#line 73

#line 73
  return result;
#line 73
}
#line 73
# 45 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleIntf.nc"
inline static  uint16_t TupleRouterM$TupleIntf$tupleSize(ParsedQueryPtr arg_0x2044190){
#line 45
  unsigned int result;
#line 45

#line 45
  result = Tuple$TupleIntf$tupleSize(arg_0x2044190);
#line 45

#line 45
  return result;
#line 45
}
#line 45
# 586 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static inline  int16_t TinyAlloc$MemAlloc$size(Handle h)
#line 586
{
  return TinyAlloc$getSize(*h) - TinyAlloc$HEADER_SIZE;
}

# 122 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/MemAlloc.nc"
inline static  int16_t TupleRouterM$MemAlloc$size(Handle arg_0x20836d8){
#line 122
  int result;
#line 122

#line 122
  result = TinyAlloc$MemAlloc$size(arg_0x20836d8);
#line 122

#line 122
  return result;
#line 122
}
#line 122
# 3414 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline bool TupleRouterM$reallocQueryForTuple(TupleRouterM$MemoryCallback callback, TupleRouterM$QueryListHandle qlh)
#line 3414
{
  ParsedQuery *q = & (*qlh)->q;
  short size = TupleRouterM$MemAlloc$size((Handle )qlh) + TupleRouterM$TupleIntf$tupleSize(q);



  TupleRouterM$mAllocState = TupleRouterM$STATE_RESIZE_QUERY;
  TupleRouterM$mAllocCallback = callback;

  return TupleRouterM$MemAlloc$reallocate((Handle )qlh, size);
}

#line 1139
static inline void TupleRouterM$resizedCallback(Handle *memory)
#line 1139
{
  TupleRouterM$QueryListHandle h = (TupleRouterM$QueryListHandle )*memory;
  ParsedQuery *pq = & (*h)->q;
  bool pending = FALSE;


  {
  }
#line 1145
  ;




  switch (pq->bufferType) {
      case kRADIO: 
        pq->bufferId = kRADIO_BUFFER;
      break;
#line 1234
      default: 
        TupleRouterM$signalError(err_UnknownError, 1235);
      goto fail;
    }

  if (!pending) {
#line 1239
    TupleRouterM$finishedBufferSetup(pq);
    }
#line 1240
  return;

  fail: 
    TupleRouterM$failedOpeningWriteBuffer(pq);
  return;
}

# 623 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  uint16_t *MultiHopLEPSM$RouteControl$getChildren(void)
#line 623
{

  int parents[MultiHopLEPSM$ROUTE_TABLE_SIZE];
  int i;
#line 626
  int count = 0;

  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) 
    parents[i] = -1;

  for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) 
    if (MultiHopLEPSM$gbCurrentHopCount == MultiHopLEPSM$NeighborTbl[i].hop - 1) {
      parents[count++] = MultiHopLEPSM$NeighborTbl[i].id;
      }
  return parents;
}

# 93 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/RouteControl.nc"
inline static  uint16_t *MultiHopEngineM$RouteSelectCntl$getChildren(void){
#line 93
  unsigned int *result;
#line 93

#line 93
  result = MultiHopLEPSM$RouteControl$getChildren();
#line 93

#line 93
  return result;
#line 93
}
#line 93
# 266 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline  uint16_t *MultiHopEngineM$RouteControl$getChildren(void)
#line 266
{
  return MultiHopEngineM$RouteSelectCntl$getChildren();
}

# 168 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Network.nc"
inline static  result_t NetworkMultiHopM$Network$dataSub(QueryResultPtr arg_0x17b6330){
#line 168
  unsigned char result;
#line 168

#line 168
  result = TupleRouterM$Network$dataSub(arg_0x17b6330);
#line 168

#line 168
  return result;
#line 168
}
#line 168
# 3074 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryCmd(uint8_t qid)
#line 3074
{
  ParsedQueryPtr pq;

#line 3076
  if (TupleRouterM$getQuery(qid, &pq)) {
    return pq;
    }
  else {
#line 3079
    return NULL;
    }
}

#line 3136
static inline  bool TupleRouterM$QueryProcessor$queryProcessorWantsData(QueryResultPtr qr)
#line 3136
{
  uint8_t qid = qr->qid;
  ParsedQuery *pq = TupleRouterM$QueryProcessor$getQueryCmd(qid);

  if (pq == NULL) {
      return FALSE;
    }
  else 
#line 3142
    {
      return pq->hasAgg;
    }
  return FALSE;
}

# 69 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryProcessor.nc"
inline static  bool NetworkMultiHopM$QueryProcessor$queryProcessorWantsData(QueryResult *arg_0x1773ad0){
#line 69
  unsigned char result;
#line 69

#line 69
  result = TupleRouterM$QueryProcessor$queryProcessorWantsData(arg_0x1773ad0);
#line 69

#line 69
  return result;
#line 69
}
#line 69
# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t NetworkMultiHopM$Leds$greenToggle(void){
#line 106
  unsigned char result;
#line 106

#line 106
  result = LedsC$Leds$greenToggle();
#line 106

#line 106
  return result;
#line 106
}
#line 106
# 314 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$Intercept$intercept(TOS_MsgPtr msg, void *payload, uint16_t payloadLen)
{
  QueryResultPtr qr = (QueryResultPtr )payload;



  NetworkMultiHopM$Leds$greenToggle();

  if (NetworkMultiHopM$QueryProcessor$queryProcessorWantsData(qr)) {
      NetworkMultiHopM$Network$dataSub(qr);
      return FAIL;
    }
  else 
#line 325
    {

      return SUCCESS;
    }
}

# 305 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static inline   result_t MultiHopEngineM$Intercept$default$intercept(uint8_t id, TOS_MsgPtr pMsg, void *payload, 
uint16_t payloadLen)
#line 306
{
  return SUCCESS;
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
inline static  result_t MultiHopEngineM$Intercept$intercept(uint8_t arg_0x1ec6738, TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758){
#line 86
  unsigned char result;
#line 86

#line 86
  switch (arg_0x1ec6738) {
#line 86
    case kDATA_MESSAGE_ID:
#line 86
      result = NetworkMultiHopM$Intercept$intercept(arg_0x17de440, arg_0x17de5d0, arg_0x17de758);
#line 86
      break;
#line 86
    default:
#line 86
      result = MultiHopEngineM$Intercept$default$intercept(arg_0x1ec6738, arg_0x17de440, arg_0x17de5d0, arg_0x17de758);
#line 86
    }
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 251 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  uint8_t QueryResult$QueryResultIntf$queryIdFromMsg(QueryResultPtr qr)
#line 251
{
  return qr->qid;
}

# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  uint8_t TupleRouterM$QueryResultIntf$queryIdFromMsg(QueryResultPtr arg_0x208db50){
#line 127
  unsigned char result;
#line 127

#line 127
  result = QueryResult$QueryResultIntf$queryIdFromMsg(arg_0x208db50);
#line 127

#line 127
  return result;
#line 127
}
#line 127
# 197 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static inline  TinyDBError QueryResult$QueryResultIntf$fromBytes(QueryResultPtr bytes, QueryResultPtr qr, ParsedQueryPtr pq)
#line 197
{
  short size = sizeof(QueryResult ) - sizeof  qr->d;
  char *p;
#line 199
  char *q;

  q = (char *)qr;
  p = (char *)bytes;
  while (size--) 
    * q++ = * p++;

  if (qr->qrType == kIS_AGG) {
      short i;

      for (i = 0; i < qr->result_idx; i++) {
          qr->d.buf[i].group = * (uint16_t *)p;
          p += sizeof(uint16_t );



          qr->d.buf[i].data = p;
          p += QueryResult$BUF_SIZE;
        }
    }
  else {
      size = qr->qrType == kAGG_SINGLE_FIELD ? sizeof  qr->d : QueryResult$TupleIntf$tupleSize(pq);
      while (size--) 
        * q++ = * p++;
    }

  return err_NoError;
}

# 120 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResultIntf.nc"
inline static  TinyDBError TupleRouterM$QueryResultIntf$fromBytes(QueryResultPtr arg_0x208ead0, QueryResultPtr arg_0x208ec50, ParsedQueryPtr arg_0x208edd0){
#line 120
  unsigned char result;
#line 120

#line 120
  result = QueryResult$QueryResultIntf$fromBytes(arg_0x208ead0, arg_0x208ec50, arg_0x208edd0);
#line 120

#line 120
  return result;
#line 120
}
#line 120
# 432 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$SET_AGGREGATING_RESULT(void)
#line 432
{
#line 432
  TupleRouterM$mPendingMask |= TupleRouterM$AGGREGATING_BIT;
}

# 393 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  TinyDBError ParsedQuery$AggOperator$processedResult(QueryResultPtr qr, ParsedQueryPtr q, ExprPtr e)
#line 393
{
  return err_NoError;
}

# 1723 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  TinyDBError TupleRouterM$AggOperator$processedResult(QueryResult *qr, ParsedQuery *q, Expr *e)
#line 1723
{

  TupleRouterM$aggregateResult(q, qr, e->idx + 1);
  return err_NoError;
}

# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError AggOperator$Operator$processedResult(QueryResultPtr arg_0x2097100, ParsedQueryPtr arg_0x2097280, ExprPtr arg_0x20973f8){
#line 105
  unsigned char result;
#line 105

#line 105
  result = TupleRouterM$AggOperator$processedResult(arg_0x2097100, arg_0x2097280, arg_0x20973f8);
#line 105
  result = combine_tdberr(result, ParsedQuery$AggOperator$processedResult(arg_0x2097100, arg_0x2097280, arg_0x20973f8));
#line 105

#line 105
  return result;
#line 105
}
#line 105
# 297 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static inline  result_t ContourMapM$Aggregate$merge(char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues)
#line 297
{

  ContourMapM$ContourMap *currentmap = (ContourMapM$ContourMap *)destdata;
  ContourMapM$ContourMap *newmap = (ContourMapM$ContourMap *)mergedata;
  int i;
#line 301
  int j;
  bool merged[newmap->regionNum];

  for (i = 0; i < 3; i++) 
    merged[i] = FALSE;

  for (i = 0; i < currentmap->regionNum; i++) 
    for (j = 0; j < newmap->regionNum; j++) 
      if (ContourMapM$contourRegionMerging(&currentmap->regions[i], &newmap->regions[j])) 
        {
#line 310
          merged[j] = TRUE;
#line 310
          break;
        }
  for (i = 0; i < newmap->regionNum; i++) 
    if (merged[i] == FALSE) {
      currentmap->regions[currentmap->regionNum++] = newmap->regions[i];
      }


  return SUCCESS;
}

# 121 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline   
#line 120
result_t AggregateUseM$Agg$default$merge(uint8_t id, 
char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues)
#line 121
{
  return SUCCESS;
}

# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregate.nc"
inline static  result_t AggregateUseM$Agg$merge(uint8_t arg_0x255b358, char *arg_0x25550a8, char *arg_0x2555240, ParamList *arg_0x25553e0, ParamVals *arg_0x2555588){
#line 81
  unsigned char result;
#line 81

#line 81
  switch (arg_0x255b358) {
#line 81
    case kCONTOUR_MAP:
#line 81
      result = ContourMapM$Aggregate$merge(arg_0x25550a8, arg_0x2555240, arg_0x25553e0, arg_0x2555588);
#line 81
      break;
#line 81
    default:
#line 81
      result = AggregateUseM$Agg$default$merge(arg_0x255b358, arg_0x25550a8, arg_0x2555240, arg_0x25553e0, arg_0x2555588);
#line 81
    }
#line 81

#line 81
  return result;
#line 81
}
#line 81
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUseM.nc"
static inline  result_t AggregateUseM$AggregateUse$merge(uint8_t id, char *destdata, char *mergedata, ParamList *params, ParamVals *paramValues)
#line 87
{
  return AggregateUseM$Agg$merge(id, destdata, mergedata, params, paramValues);
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/AggregateUse.nc"
inline static  result_t AggOperator$AggregateUse$merge(uint8_t arg_0x2484590, char *arg_0x2484728, char *arg_0x24848c0, ParamList *arg_0x2484a60, ParamVals *arg_0x2484c08){
#line 83
  unsigned char result;
#line 83

#line 83
  result = AggregateUseM$AggregateUse$merge(arg_0x2484590, arg_0x2484728, arg_0x24848c0, arg_0x2484a60, arg_0x2484c08);
#line 83

#line 83
  return result;
#line 83
}
#line 83
# 630 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static inline void AggOperator$mergeAggregateValues(AggOperator$GroupRecord *dest, AggOperator$GroupRecord *merge, Expr *e)
#line 630
{
  ParamVals paramVals;

#line 632
  setParamValues(&paramVals, e);

  dest->u.empty = FALSE;





  AggOperator$AggregateUse$merge(e->ex.agg.op, dest->aggdata, merge->aggdata, NULL, &paramVals);
}

#line 220
static inline void AggOperator$updateGroupForPartialResult(AggOperator$GroupRecord *d)
#line 220
{
  AggOperator$GroupRecord *gr = (AggOperator$GroupRecord *)((QueryResult *)AggOperator$mCurResult)->d.data;

  {
  }
#line 223
  ;

  AggOperator$mergeAggregateValues(d, gr, AggOperator$mCurExpr);
  AggOperator$Operator$processedResult(AggOperator$mCurResult, AggOperator$mCurQuery, AggOperator$mCurExpr);
}

#line 190
static inline  TinyDBError AggOperator$Operator$processPartialResult(QueryResultPtr qr, ParsedQueryPtr qs, ExprPtr e)
#line 190
{
  AggOperator$GroupRecord *gr = (AggOperator$GroupRecord *)qr->d.data;

  if (qr->qrType != kAGG_SINGLE_FIELD) {
#line 193
    return err_InvalidAggregateRecord;
    }
  if (gr->u.exprIdx != e->idx) {
    return err_InvalidAggregateRecord;
    }
  if (e->opState == (OperatorStateHandle )AggOperator$QUERY_DONE_STATE) {
#line 198
    return err_NoError;
    }
  AggOperator$mCurExpr = e;
  AggOperator$mCurQuery = qs;
  AggOperator$mCurResult = qr;
  {
  }
#line 203
  ;

  AggOperator$getGroupData(qs, gr->groupNo, e, &AggOperator$updateGroupForPartialResult);
  return err_NoError;
}

# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Operator.nc"
inline static  TinyDBError TupleRouterM$AggOperator$processPartialResult(QueryResultPtr arg_0x209af08, ParsedQueryPtr arg_0x20980b0, ExprPtr arg_0x2098228){
#line 91
  unsigned char result;
#line 91

#line 91
  result = AggOperator$Operator$processPartialResult(arg_0x209af08, arg_0x20980b0, arg_0x2098228);
#line 91

#line 91
  return result;
#line 91
}
#line 91
# 197 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
inline static TOS_MsgPtr MultiHopEngineM$mForward(TOS_MsgPtr pMsg, uint8_t id)
#line 197
{
  TOS_MsgPtr pNewBuf = pMsg;

  if ((MultiHopEngineM$iFwdBufHead + 1) % MultiHopEngineM$FWD_QUEUE_SIZE == MultiHopEngineM$iFwdBufTail) {
    return pNewBuf;
    }
  if (MultiHopEngineM$RouteSelect$selectRoute(pMsg, id) != SUCCESS) {
    return pNewBuf;
    }


  if (MultiHopEngineM$SendMsg$send(id, pMsg->addr, pMsg->length, pMsg) == SUCCESS) {
      pNewBuf = MultiHopEngineM$FwdBufList[MultiHopEngineM$iFwdBufHead];
      MultiHopEngineM$FwdBufList[MultiHopEngineM$iFwdBufHead] = pMsg;
      MultiHopEngineM$iFwdBufHead++;
#line 211
      MultiHopEngineM$iFwdBufHead %= MultiHopEngineM$FWD_QUEUE_SIZE;
    }

  return pNewBuf;
}

# 331 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static inline  result_t NetworkMultiHopM$Snoop$intercept(TOS_MsgPtr msg, void *payload, uint16_t payloadLen)
{
  QueryResultPtr qr = (QueryResultPtr )payload;

#line 351
  if (TOS_LOCAL_ADDRESS == 0 && msg->addr == TOS_BCAST_ADDR) 
    {
      NetworkMultiHopM$Network$dataSub(qr);
      return FAIL;
    }
  return SUCCESS;
}

# 724 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static inline  result_t MultiHopLEPSM$Snoop$intercept(uint8_t id, TOS_MsgPtr Msg, void *Payload, uint16_t Len)
#line 724
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];
  uint8_t iNbr;

  MultiHopLEPSM$updateNbrCounters(pMHMsg->sourceaddr, pMHMsg->seqno, &iNbr);

  return SUCCESS;
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/Intercept.nc"
inline static  result_t MultiHopEngineM$Snoop$intercept(uint8_t arg_0x1ec6ce8, TOS_MsgPtr arg_0x17de440, void *arg_0x17de5d0, uint16_t arg_0x17de758){
#line 86
  unsigned char result;
#line 86

#line 86
  result = MultiHopLEPSM$Snoop$intercept(arg_0x1ec6ce8, arg_0x17de440, arg_0x17de5d0, arg_0x17de758);
#line 86
  switch (arg_0x1ec6ce8) {
#line 86
    case kDATA_MESSAGE_ID:
#line 86
      result = rcombine(result, NetworkMultiHopM$Snoop$intercept(arg_0x17de440, arg_0x17de5d0, arg_0x17de758));
#line 86
      break;
#line 86
  }
#line 86

#line 86
  return result;
#line 86
}
#line 86
# 488 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline    result_t HPLUSART0M$USARTData$default$rxDone(uint8_t data)
#line 488
{
#line 488
  return SUCCESS;
}

# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
inline static   result_t HPLUSART0M$USARTData$rxDone(uint8_t arg_0x1af0a38){
#line 53
  unsigned char result;
#line 53

#line 53
  result = HPLUSART0M$USARTData$default$rxDone(arg_0x1af0a38);
#line 53

#line 53
  return result;
#line 53
}
#line 53
# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline    void HPLUSART0M$HPLI2CInterrupt$default$fired(void)
#line 70
{
}

# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLI2CInterrupt.nc"
inline static   void HPLUSART0M$HPLI2CInterrupt$fired(void){
#line 43
  HPLUSART0M$HPLI2CInterrupt$default$fired();
#line 43
}
#line 43
# 486 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline    result_t HPLUSART0M$USARTData$default$txDone(void)
#line 486
{
#line 486
  return SUCCESS;
}

# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
inline static   result_t HPLUSART0M$USARTData$txDone(void){
#line 46
  unsigned char result;
#line 46

#line 46
  result = HPLUSART0M$USARTData$default$txDone();
#line 46

#line 46
  return result;
#line 46
}
#line 46
# 536 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  void CC2420RadioM$delayedRXFIFOtask(void)
#line 536
{
  CC2420RadioM$delayedRXFIFO();
}

# 28 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline uint8_t TOSH_READ_CC_FIFO_PIN(void)
#line 28
{
#line 28
   static volatile uint8_t r __asm ("0x0020");

#line 28
  return r & (1 << 3);
}

# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline   result_t TimerJiffyAsyncM$TimerJiffyAsync$stop(void)
{
  {
    TimerJiffyAsyncM$bSet = FALSE;
    TimerJiffyAsyncM$AlarmControl$disableEvents();
  }
  return SUCCESS;
}

# 8 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
inline static   result_t CC2420RadioM$BackoffTimerJiffy$stop(void){
#line 8
  unsigned char result;
#line 8

#line 8
  result = TimerJiffyAsyncM$TimerJiffyAsync$stop();
#line 8

#line 8
  return result;
#line 8
}
#line 8
# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static inline   bool TimerJiffyAsyncM$TimerJiffyAsync$isSet(void)
{
  bool _isSet;

#line 100
  _isSet = TimerJiffyAsyncM$bSet;
  return _isSet;
}

# 10 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/TimerJiffyAsync.nc"
inline static   bool CC2420RadioM$BackoffTimerJiffy$isSet(void){
#line 10
  unsigned char result;
#line 10

#line 10
  result = TimerJiffyAsyncM$TimerJiffyAsync$isSet();
#line 10

#line 10
  return result;
#line 10
}
#line 10
# 591 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$FIFOP$fired(void)
#line 591
{






  if (CC2420RadioM$bAckEnable && CC2420RadioM$stateRadio == CC2420RadioM$PRE_TX_STATE) {
      if (CC2420RadioM$BackoffTimerJiffy$isSet()) {
          CC2420RadioM$BackoffTimerJiffy$stop();
          CC2420RadioM$BackoffTimerJiffy$setOneShot(CC2420RadioM$MacBackoff$congestionBackoff(CC2420RadioM$txbufptr) * 10 + 75);
        }
    }


  if (!TOSH_READ_CC_FIFO_PIN()) {
      CC2420RadioM$flushRXFIFO();
      return SUCCESS;
    }

  {
    if (TOS_post(CC2420RadioM$delayedRXFIFOtask)) {
        CC2420RadioM$FIFOP$disable();
      }
    else {
        CC2420RadioM$flushRXFIFO();
      }
  }


  return SUCCESS;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t HPLCC2420InterruptM$FIFOP$fired(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = CC2420RadioM$FIFOP$fired();
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 89 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   void HPLCC2420InterruptM$FIFOPInterrupt$fired(void)
#line 89
{
  result_t val = SUCCESS;

#line 91
  HPLCC2420InterruptM$FIFOPInterrupt$clear();
  val = HPLCC2420InterruptM$FIFOP$fired();
  if (val == FAIL) {
      HPLCC2420InterruptM$FIFOPInterrupt$disable();
      HPLCC2420InterruptM$FIFOPInterrupt$clear();
    }
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port10$fired(void){
#line 59
  HPLCC2420InterruptM$FIFOPInterrupt$fired();
#line 59
}
#line 59
# 27 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telosb/hardware.h"
static inline uint8_t TOSH_READ_CC_FIFOP_PIN(void)
#line 27
{
#line 27
   static volatile uint8_t r __asm ("0x0020");

#line 27
  return r & (1 << 0);
}

# 252 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  TOS_MsgPtr AMStandard$RadioReceive$receive(TOS_MsgPtr packet)
#line 252
{
  return received(packet);
}

# 279 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  TOS_MsgPtr AMPromiscuous$RadioReceive$receive(TOS_MsgPtr packet)
#line 279
{
  return prom_received(packet);
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr CC2420RadioM$Receive$receive(TOS_MsgPtr arg_0x17efd58){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = AMPromiscuous$RadioReceive$receive(arg_0x17efd58);
#line 75
  result = AMStandard$RadioReceive$receive(arg_0x17efd58);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 153 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  void CC2420RadioM$PacketRcvd(void)
#line 153
{
  TOS_MsgPtr pBuf;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 156
    {
      pBuf = CC2420RadioM$rxbufptr;
    }
#line 158
    __nesc_atomic_end(__nesc_atomic); }
  pBuf = CC2420RadioM$Receive$receive((TOS_MsgPtr )pBuf);
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 160
    {
      if (pBuf) {
#line 161
        CC2420RadioM$rxbufptr = pBuf;
        }
#line 162
      CC2420RadioM$rxbufptr->length = 0;
      CC2420RadioM$bPacketReceiving = FALSE;
    }
#line 164
    __nesc_atomic_end(__nesc_atomic); }
}

# 23 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/byteorder.h"
static __inline uint16_t fromLSB16(uint16_t a)
{
  return is_host_lsb() ? a : (a << 8) | (a >> 8);
}

# 628 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$HPLChipconFIFO$RXFIFODone(uint8_t length, uint8_t *data)
#line 628
{





  uint8_t currentstate;

#line 635
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 635
    {
      currentstate = CC2420RadioM$stateRadio;
    }
#line 637
    __nesc_atomic_end(__nesc_atomic); }




  if (((
#line 641
  !TOSH_READ_CC_FIFO_PIN() && !TOSH_READ_CC_FIFOP_PIN())
   || length == 0) || length > MSG_DATA_SIZE) {
      CC2420RadioM$flushRXFIFO();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 644
        CC2420RadioM$bPacketReceiving = FALSE;
#line 644
        __nesc_atomic_end(__nesc_atomic); }
      return SUCCESS;
    }

  CC2420RadioM$rxbufptr = (TOS_MsgPtr )data;




  if (
#line 651
  CC2420RadioM$bAckEnable && currentstate == CC2420RadioM$POST_TX_STATE && (
  CC2420RadioM$rxbufptr->fcfhi & 0x07) == 0x02 && 
  CC2420RadioM$rxbufptr->dsn == CC2420RadioM$currentDSN && 
  data[length - 1] >> 7 == 1) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 655
        {
          CC2420RadioM$txbufptr->ack = 1;
          CC2420RadioM$txbufptr->strength = data[length - 2];
          CC2420RadioM$txbufptr->lqi = data[length - 1] & 0x7F;

          CC2420RadioM$stateRadio = CC2420RadioM$POST_TX_ACK_STATE;
          CC2420RadioM$bPacketReceiving = FALSE;
        }
#line 662
        __nesc_atomic_end(__nesc_atomic); }
      if (!TOS_post(CC2420RadioM$PacketSent)) {
        CC2420RadioM$sendFailed();
        }
#line 665
      return SUCCESS;
    }




  if ((CC2420RadioM$rxbufptr->fcfhi & 0x07) != 0x01 || 
  CC2420RadioM$rxbufptr->fcflo != 0x08) {
      CC2420RadioM$flushRXFIFO();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 674
        CC2420RadioM$bPacketReceiving = FALSE;
#line 674
        __nesc_atomic_end(__nesc_atomic); }
      return SUCCESS;
    }

  CC2420RadioM$rxbufptr->length = CC2420RadioM$rxbufptr->length - MSG_HEADER_SIZE - MSG_FOOTER_SIZE;

  if (CC2420RadioM$rxbufptr->length > 89) {
      CC2420RadioM$flushRXFIFO();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 682
        CC2420RadioM$bPacketReceiving = FALSE;
#line 682
        __nesc_atomic_end(__nesc_atomic); }
      return SUCCESS;
    }


  CC2420RadioM$rxbufptr->addr = fromLSB16(CC2420RadioM$rxbufptr->addr);


  CC2420RadioM$rxbufptr->crc = data[length - 1] >> 7;

  CC2420RadioM$rxbufptr->strength = data[length - 2];

  CC2420RadioM$rxbufptr->lqi = data[length - 1] & 0x7F;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 696
    {
      if (!TOS_post(CC2420RadioM$PacketRcvd)) {
          CC2420RadioM$bPacketReceiving = FALSE;
        }
    }
#line 700
    __nesc_atomic_end(__nesc_atomic); }

  if (!TOSH_READ_CC_FIFO_PIN() && !TOSH_READ_CC_FIFOP_PIN()) {
      CC2420RadioM$flushRXFIFO();
      return SUCCESS;
    }

  if (!TOSH_READ_CC_FIFOP_PIN()) {
      if (TOS_post(CC2420RadioM$delayedRXFIFOtask)) {
        return SUCCESS;
        }
    }
#line 711
  CC2420RadioM$flushRXFIFO();


  return SUCCESS;
}

# 39 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
inline static   result_t HPLCC2420M$HPLCC2420FIFO$RXFIFODone(uint8_t arg_0x1931350, uint8_t *arg_0x19314e8){
#line 39
  unsigned char result;
#line 39

#line 39
  result = CC2420RadioM$HPLChipconFIFO$RXFIFODone(arg_0x1931350, arg_0x19314e8);
#line 39

#line 39
  return result;
#line 39
}
#line 39
# 322 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  void HPLCC2420M$signalRXFIFO(void)
#line 322
{
  uint8_t _rxlen;
  uint8_t *_rxbuf;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 326
    {
      _rxlen = HPLCC2420M$rxlen;
      _rxbuf = HPLCC2420M$rxbuf;
      HPLCC2420M$f.rxbufBusy = FALSE;
    }
#line 330
    __nesc_atomic_end(__nesc_atomic); }

  HPLCC2420M$HPLCC2420FIFO$RXFIFODone(_rxlen, _rxbuf);
}

# 439 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static inline   result_t HPLUSART0M$USARTControl$isRxIntrPending(void)
#line 439
{
  if (HPLUSART0M$IFG1 & (1 << 6)) {
      HPLUSART0M$IFG1 &= ~(1 << 6);
      return SUCCESS;
    }
  return FAIL;
}

# 185 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTControl.nc"
inline static   result_t HPLCC2420M$USARTControl$isRxIntrPending(void){
#line 185
  unsigned char result;
#line 185

#line 185
  result = HPLUSART0M$USARTControl$isRxIntrPending();
#line 185

#line 185
  return result;
#line 185
}
#line 185
# 335 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline   result_t HPLCC2420M$HPLCC2420FIFO$readRXFIFO(uint8_t length, uint8_t *data)
#line 335
{
  uint8_t i;
  bool returnFail = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 339
    {
      if (HPLCC2420M$f.rxbufBusy) {
        returnFail = TRUE;
        }
      else {
#line 343
        HPLCC2420M$f.rxbufBusy = TRUE;
        }
    }
#line 345
    __nesc_atomic_end(__nesc_atomic); }
  if (returnFail) {
    return FAIL;
    }
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 350
        {
          HPLCC2420M$f.busy = TRUE;
          HPLCC2420M$rxbuf = data;
          TOSH_CLR_RADIO_CSN_PIN();

          HPLCC2420M$USARTControl$isTxIntrPending();
          HPLCC2420M$USARTControl$rx();
          HPLCC2420M$USARTControl$tx(0x3F | 0x40);
          while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
          HPLCC2420M$rxlen = HPLCC2420M$USARTControl$rx();
          HPLCC2420M$USARTControl$tx(0);
          while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;

          HPLCC2420M$rxlen = HPLCC2420M$USARTControl$rx();
        }
#line 364
        __nesc_atomic_end(__nesc_atomic); }
      if (HPLCC2420M$rxlen > 0) {
          HPLCC2420M$rxbuf[0] = HPLCC2420M$rxlen;

          HPLCC2420M$rxlen++;

          if (HPLCC2420M$rxlen > length) {
#line 370
            HPLCC2420M$rxlen = length;
            }
#line 371
          for (i = 1; i < HPLCC2420M$rxlen; i++) {
              { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 372
                {
                  HPLCC2420M$USARTControl$tx(0);
                  while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
                  HPLCC2420M$rxbuf[i] = HPLCC2420M$USARTControl$rx();
                }
#line 376
                __nesc_atomic_end(__nesc_atomic); }
            }
        }
      TOSH_SET_RADIO_CSN_PIN();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 380
        HPLCC2420M$f.busy = FALSE;
#line 380
        __nesc_atomic_end(__nesc_atomic); }
      HPLCC2420M$BusArbitration$releaseBus();
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 384
        HPLCC2420M$f.rxbufBusy = FALSE;
#line 384
        __nesc_atomic_end(__nesc_atomic); }
      return FAIL;
    }
  if (TOS_post(HPLCC2420M$signalRXFIFO) == FAIL) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 388
        HPLCC2420M$f.rxbufBusy = FALSE;
#line 388
        __nesc_atomic_end(__nesc_atomic); }
      return FAIL;
    }
  return SUCCESS;
}

# 19 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420FIFO.nc"
inline static   result_t CC2420RadioM$HPLChipconFIFO$readRXFIFO(uint8_t arg_0x19003d8, uint8_t *arg_0x1900570){
#line 19
  unsigned char result;
#line 19

#line 19
  result = HPLCC2420M$HPLCC2420FIFO$readRXFIFO(arg_0x19003d8, arg_0x1900570);
#line 19

#line 19
  return result;
#line 19
}
#line 19
# 271 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline   TOS_MsgPtr AMPromiscuous$ReceiveMsg$default$receive(uint8_t id, TOS_MsgPtr msg)
#line 271
{
  return msg;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr AMPromiscuous$ReceiveMsg$receive(uint8_t arg_0x1fd5010, TOS_MsgPtr arg_0x17efd58){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
    result = AMPromiscuous$ReceiveMsg$default$receive(arg_0x1fd5010, arg_0x17efd58);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 178 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port11$clear(void)
#line 178
{
#line 178
  MSP430InterruptM$P1IFG &= ~(1 << 1);
}

#line 94
static inline    void MSP430InterruptM$Port11$default$fired(void)
#line 94
{
#line 94
  MSP430InterruptM$Port11$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port11$fired(void){
#line 59
  MSP430InterruptM$Port11$default$fired();
#line 59
}
#line 59
# 179 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port12$clear(void)
#line 179
{
#line 179
  MSP430InterruptM$P1IFG &= ~(1 << 2);
}

#line 95
static inline    void MSP430InterruptM$Port12$default$fired(void)
#line 95
{
#line 95
  MSP430InterruptM$Port12$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port12$fired(void){
#line 59
  MSP430InterruptM$Port12$default$fired();
#line 59
}
#line 59
# 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port13$clear(void)
#line 180
{
#line 180
  MSP430InterruptM$P1IFG &= ~(1 << 3);
}

# 40 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOInterrupt$clear(void){
#line 40
  MSP430InterruptM$Port13$clear();
#line 40
}
#line 40
# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port13$disable(void)
#line 149
{
#line 149
  MSP430InterruptM$P1IE &= ~(1 << 3);
}

# 35 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void HPLCC2420InterruptM$FIFOInterrupt$disable(void){
#line 35
  MSP430InterruptM$Port13$disable();
#line 35
}
#line 35
# 140 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline    result_t HPLCC2420InterruptM$FIFO$default$fired(void)
#line 140
{
#line 140
  return FAIL;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t HPLCC2420InterruptM$FIFO$fired(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = HPLCC2420InterruptM$FIFO$default$fired();
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 130 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   void HPLCC2420InterruptM$FIFOInterrupt$fired(void)
#line 130
{
  result_t val = SUCCESS;

#line 132
  HPLCC2420InterruptM$FIFOInterrupt$clear();
  val = HPLCC2420InterruptM$FIFO$fired();
  if (val == FAIL) {
      HPLCC2420InterruptM$FIFOInterrupt$disable();
      HPLCC2420InterruptM$FIFOInterrupt$clear();
    }
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port13$fired(void){
#line 59
  HPLCC2420InterruptM$FIFOInterrupt$fired();
#line 59
}
#line 59
# 312 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline   result_t CC2420RadioM$SplitControl$default$startDone(void)
#line 312
{
  return SUCCESS;
}

# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420RadioM$SplitControl$startDone(void){
#line 85
  unsigned char result;
#line 85

#line 85
  result = CC2420RadioM$SplitControl$default$startDone();
#line 85

#line 85
  return result;
#line 85
}
#line 85
# 43 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t CC2420RadioM$FIFOP$startWait(bool arg_0x192c1a0){
#line 43
  unsigned char result;
#line 43

#line 43
  result = HPLCC2420InterruptM$FIFOP$startWait(arg_0x192c1a0);
#line 43

#line 43
  return result;
#line 43
}
#line 43
# 343 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline   result_t CC2420ControlM$CC2420Control$RxMode(void)
#line 343
{
  CC2420ControlM$HPLChipcon$cmd(0x03);
  return SUCCESS;
}

# 163 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420Control.nc"
inline static   result_t CC2420RadioM$CC2420Control$RxMode(void){
#line 163
  unsigned char result;
#line 163

#line 163
  result = CC2420ControlM$CC2420Control$RxMode();
#line 163

#line 163
  return result;
#line 163
}
#line 163
# 294 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static inline  result_t CC2420RadioM$CC2420SplitControl$startDone(void)
#line 294
{
  uint8_t chkstateRadio;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 297
    chkstateRadio = CC2420RadioM$stateRadio;
#line 297
    __nesc_atomic_end(__nesc_atomic); }

  if (chkstateRadio == CC2420RadioM$WARMUP_STATE) {
      CC2420RadioM$CC2420Control$RxMode();

      CC2420RadioM$FIFOP$startWait(FALSE);

      CC2420RadioM$SFD$enableCapture(TRUE);

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 306
        CC2420RadioM$stateRadio = CC2420RadioM$IDLE_STATE;
#line 306
        __nesc_atomic_end(__nesc_atomic); }
    }
  CC2420RadioM$SplitControl$startDone();
  return SUCCESS;
}

# 85 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SplitControl.nc"
inline static  result_t CC2420ControlM$SplitControl$startDone(void){
#line 85
  unsigned char result;
#line 85

#line 85
  result = CC2420RadioM$CC2420SplitControl$startDone();
#line 85

#line 85
  return result;
#line 85
}
#line 85
# 286 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  result_t CC2420ControlM$CC2420Control$TuneManual(uint16_t DesiredFreq)
#line 286
{
  int fsctrl;
  uint8_t status;

  fsctrl = DesiredFreq - 2048;
  CC2420ControlM$gCurrentParameters[CP_FSCTRL] = (CC2420ControlM$gCurrentParameters[CP_FSCTRL] & 0xfc00) | (fsctrl << 0);
  status = CC2420ControlM$HPLChipcon$write(0x18, CC2420ControlM$gCurrentParameters[CP_FSCTRL]);


  if (status & (1 << 6)) {
    CC2420ControlM$HPLChipcon$cmd(0x03);
    }
#line 297
  return SUCCESS;
}

#line 441
static inline   result_t CC2420ControlM$HPLChipconRAM$writeDone(uint16_t addr, uint8_t length, uint8_t *buffer)
#line 441
{
  return SUCCESS;
}

# 49 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420RAM.nc"
inline static   result_t HPLCC2420M$HPLCC2420RAM$writeDone(uint16_t arg_0x19c1e18, uint8_t arg_0x19c0010, uint8_t *arg_0x19c01a8){
#line 49
  unsigned char result;
#line 49

#line 49
  result = CC2420ControlM$HPLChipconRAM$writeDone(arg_0x19c1e18, arg_0x19c0010, arg_0x19c01a8);
#line 49

#line 49
  return result;
#line 49
}
#line 49
# 288 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static inline  void HPLCC2420M$signalRAMWr(void)
#line 288
{
  HPLCC2420M$HPLCC2420RAM$writeDone(HPLCC2420M$ramaddr, HPLCC2420M$ramlen, HPLCC2420M$rambuf);
}

static inline   result_t HPLCC2420M$HPLCC2420RAM$write(uint16_t addr, uint8_t _length, uint8_t *buffer)
#line 292
{
  uint8_t i = 0;

#line 294
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 295
        {
          HPLCC2420M$f.busy = TRUE;
          HPLCC2420M$ramaddr = addr;
          HPLCC2420M$ramlen = _length;
          HPLCC2420M$rambuf = buffer;
        }
#line 300
        __nesc_atomic_end(__nesc_atomic); }
      TOSH_CLR_RADIO_CSN_PIN();

      HPLCC2420M$USARTControl$isTxIntrPending();
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx((HPLCC2420M$ramaddr & 0x7F) | 0x80);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
      HPLCC2420M$USARTControl$tx((HPLCC2420M$ramaddr >> 1) & 0xC0);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
      for (i = 0; i < HPLCC2420M$ramlen; i++) {
          HPLCC2420M$USARTControl$tx(HPLCC2420M$rambuf[i]);
          while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
        }
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxEmpty()) ;
      TOSH_SET_RADIO_CSN_PIN();
      HPLCC2420M$BusArbitration$releaseBus();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 316
        HPLCC2420M$f.busy = FALSE;
#line 316
        __nesc_atomic_end(__nesc_atomic); }
      return TOS_post(HPLCC2420M$signalRAMWr);
    }
  return FAIL;
}

# 47 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420RAM.nc"
inline static   result_t CC2420ControlM$HPLChipconRAM$write(uint16_t arg_0x19c15f0, uint8_t arg_0x19c1768, uint8_t *arg_0x19c1900){
#line 47
  unsigned char result;
#line 47

#line 47
  result = HPLCC2420M$HPLCC2420RAM$write(arg_0x19c15f0, arg_0x19c1768, arg_0x19c1900);
#line 47

#line 47
  return result;
#line 47
}
#line 47
# 432 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline  result_t CC2420ControlM$CC2420Control$setShortAddress(uint16_t addr)
#line 432
{
  addr = toLSB16(addr);
  return CC2420ControlM$HPLChipconRAM$write(0x16A, 2, (uint8_t *)&addr);
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420.nc"
inline static   uint16_t CC2420ControlM$HPLChipcon$read(uint8_t arg_0x1904010){
#line 61
  unsigned int result;
#line 61

#line 61
  result = HPLCC2420M$HPLCC2420$read(arg_0x1904010);
#line 61

#line 61
  return result;
#line 61
}
#line 61
# 80 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420ControlM.nc"
static inline bool CC2420ControlM$SetRegs(void)
#line 80
{
  uint16_t data;

  CC2420ControlM$HPLChipcon$write(0x10, CC2420ControlM$gCurrentParameters[CP_MAIN]);
  CC2420ControlM$HPLChipcon$write(0x11, CC2420ControlM$gCurrentParameters[CP_MDMCTRL0]);
  data = CC2420ControlM$HPLChipcon$read(0x11);
  if (data != CC2420ControlM$gCurrentParameters[CP_MDMCTRL0]) {
#line 86
    return FALSE;
    }
  CC2420ControlM$HPLChipcon$write(0x12, CC2420ControlM$gCurrentParameters[CP_MDMCTRL1]);
  CC2420ControlM$HPLChipcon$write(0x13, CC2420ControlM$gCurrentParameters[CP_RSSI]);
  CC2420ControlM$HPLChipcon$write(0x14, CC2420ControlM$gCurrentParameters[CP_SYNCWORD]);
  CC2420ControlM$HPLChipcon$write(0x15, CC2420ControlM$gCurrentParameters[CP_TXCTRL]);
  CC2420ControlM$HPLChipcon$write(0x16, CC2420ControlM$gCurrentParameters[CP_RXCTRL0]);
  CC2420ControlM$HPLChipcon$write(0x17, CC2420ControlM$gCurrentParameters[CP_RXCTRL1]);
  CC2420ControlM$HPLChipcon$write(0x18, CC2420ControlM$gCurrentParameters[CP_FSCTRL]);

  CC2420ControlM$HPLChipcon$write(0x19, CC2420ControlM$gCurrentParameters[CP_SECCTRL0]);
  CC2420ControlM$HPLChipcon$write(0x1A, CC2420ControlM$gCurrentParameters[CP_SECCTRL1]);
  CC2420ControlM$HPLChipcon$write(0x1C, CC2420ControlM$gCurrentParameters[CP_IOCFG0]);
  CC2420ControlM$HPLChipcon$write(0x1D, CC2420ControlM$gCurrentParameters[CP_IOCFG1]);

  CC2420ControlM$HPLChipcon$cmd(0x09);
  CC2420ControlM$HPLChipcon$cmd(0x08);

  return TRUE;
}










static inline  void CC2420ControlM$PostOscillatorOn(void)
#line 116
{

  CC2420ControlM$SetRegs();
  CC2420ControlM$CC2420Control$setShortAddress(TOS_LOCAL_ADDRESS);
  CC2420ControlM$CC2420Control$TuneManual(((CC2420ControlM$gCurrentParameters[CP_FSCTRL] << 0) & 0x1FF) + 2048);
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 121
    CC2420ControlM$state = CC2420ControlM$START_STATE_DONE;
#line 121
    __nesc_atomic_end(__nesc_atomic); }
  CC2420ControlM$SplitControl$startDone();
}

#line 445
static inline   result_t CC2420ControlM$CCA$fired(void)
#line 445
{

  CC2420ControlM$HPLChipcon$write(0x1D, 0);
  TOS_post(CC2420ControlM$PostOscillatorOn);
  return FAIL;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/HPLCC2420Interrupt.nc"
inline static   result_t HPLCC2420InterruptM$CCA$fired(void){
#line 51
  unsigned char result;
#line 51

#line 51
  result = CC2420ControlM$CCA$fired();
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 171 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static inline   void HPLCC2420InterruptM$CCAInterrupt$fired(void)
#line 171
{
  result_t val = SUCCESS;

#line 173
  HPLCC2420InterruptM$CCAInterrupt$clear();
  val = HPLCC2420InterruptM$CCA$fired();
  if (val == FAIL) {
      HPLCC2420InterruptM$CCAInterrupt$disable();
      HPLCC2420InterruptM$CCAInterrupt$clear();
    }
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port14$fired(void){
#line 59
  HPLCC2420InterruptM$CCAInterrupt$fired();
#line 59
}
#line 59
# 182 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port15$clear(void)
#line 182
{
#line 182
  MSP430InterruptM$P1IFG &= ~(1 << 5);
}

#line 98
static inline    void MSP430InterruptM$Port15$default$fired(void)
#line 98
{
#line 98
  MSP430InterruptM$Port15$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port15$fired(void){
#line 59
  MSP430InterruptM$Port15$default$fired();
#line 59
}
#line 59
# 183 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port16$clear(void)
#line 183
{
#line 183
  MSP430InterruptM$P1IFG &= ~(1 << 6);
}

#line 99
static inline    void MSP430InterruptM$Port16$default$fired(void)
#line 99
{
#line 99
  MSP430InterruptM$Port16$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port16$fired(void){
#line 59
  MSP430InterruptM$Port16$default$fired();
#line 59
}
#line 59
# 184 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port17$clear(void)
#line 184
{
#line 184
  MSP430InterruptM$P1IFG &= ~(1 << 7);
}

#line 100
static inline    void MSP430InterruptM$Port17$default$fired(void)
#line 100
{
#line 100
  MSP430InterruptM$Port17$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port17$fired(void){
#line 59
  MSP430InterruptM$Port17$default$fired();
#line 59
}
#line 59
# 186 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port20$clear(void)
#line 186
{
#line 186
  MSP430InterruptM$P2IFG &= ~(1 << 0);
}

#line 102
static inline    void MSP430InterruptM$Port20$default$fired(void)
#line 102
{
#line 102
  MSP430InterruptM$Port20$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port20$fired(void){
#line 59
  MSP430InterruptM$Port20$default$fired();
#line 59
}
#line 59
# 187 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port21$clear(void)
#line 187
{
#line 187
  MSP430InterruptM$P2IFG &= ~(1 << 1);
}

#line 103
static inline    void MSP430InterruptM$Port21$default$fired(void)
#line 103
{
#line 103
  MSP430InterruptM$Port21$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port21$fired(void){
#line 59
  MSP430InterruptM$Port21$default$fired();
#line 59
}
#line 59
# 188 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port22$clear(void)
#line 188
{
#line 188
  MSP430InterruptM$P2IFG &= ~(1 << 2);
}

#line 104
static inline    void MSP430InterruptM$Port22$default$fired(void)
#line 104
{
#line 104
  MSP430InterruptM$Port22$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port22$fired(void){
#line 59
  MSP430InterruptM$Port22$default$fired();
#line 59
}
#line 59
# 189 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port23$clear(void)
#line 189
{
#line 189
  MSP430InterruptM$P2IFG &= ~(1 << 3);
}

#line 105
static inline    void MSP430InterruptM$Port23$default$fired(void)
#line 105
{
#line 105
  MSP430InterruptM$Port23$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port23$fired(void){
#line 59
  MSP430InterruptM$Port23$default$fired();
#line 59
}
#line 59
# 190 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port24$clear(void)
#line 190
{
#line 190
  MSP430InterruptM$P2IFG &= ~(1 << 4);
}

#line 106
static inline    void MSP430InterruptM$Port24$default$fired(void)
#line 106
{
#line 106
  MSP430InterruptM$Port24$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port24$fired(void){
#line 59
  MSP430InterruptM$Port24$default$fired();
#line 59
}
#line 59
# 191 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port25$clear(void)
#line 191
{
#line 191
  MSP430InterruptM$P2IFG &= ~(1 << 5);
}

#line 107
static inline    void MSP430InterruptM$Port25$default$fired(void)
#line 107
{
#line 107
  MSP430InterruptM$Port25$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port25$fired(void){
#line 59
  MSP430InterruptM$Port25$default$fired();
#line 59
}
#line 59
# 192 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port26$clear(void)
#line 192
{
#line 192
  MSP430InterruptM$P2IFG &= ~(1 << 6);
}

#line 108
static inline    void MSP430InterruptM$Port26$default$fired(void)
#line 108
{
#line 108
  MSP430InterruptM$Port26$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port26$fired(void){
#line 59
  MSP430InterruptM$Port26$default$fired();
#line 59
}
#line 59
# 193 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$Port27$clear(void)
#line 193
{
#line 193
  MSP430InterruptM$P2IFG &= ~(1 << 7);
}

#line 109
static inline    void MSP430InterruptM$Port27$default$fired(void)
#line 109
{
#line 109
  MSP430InterruptM$Port27$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$Port27$fired(void){
#line 59
  MSP430InterruptM$Port27$default$fired();
#line 59
}
#line 59
# 195 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$NMI$clear(void)
#line 195
{
#line 195
  IFG1 &= ~(1 << 4);
}

#line 111
static inline    void MSP430InterruptM$NMI$default$fired(void)
#line 111
{
#line 111
  MSP430InterruptM$NMI$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$NMI$fired(void){
#line 59
  MSP430InterruptM$NMI$default$fired();
#line 59
}
#line 59
# 196 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$OF$clear(void)
#line 196
{
#line 196
  IFG1 &= ~(1 << 1);
}

#line 112
static inline    void MSP430InterruptM$OF$default$fired(void)
#line 112
{
#line 112
  MSP430InterruptM$OF$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$OF$fired(void){
#line 59
  MSP430InterruptM$OF$default$fired();
#line 59
}
#line 59
# 197 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
static inline   void MSP430InterruptM$ACCV$clear(void)
#line 197
{
#line 197
  FCTL3 &= ~0x0004;
}

#line 113
static inline    void MSP430InterruptM$ACCV$default$fired(void)
#line 113
{
#line 113
  MSP430InterruptM$ACCV$clear();
}

# 59 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430Interrupt.nc"
inline static   void MSP430InterruptM$ACCV$fired(void){
#line 59
  MSP430InterruptM$ACCV$default$fired();
#line 59
}
#line 59
# 202 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  void FramerM$PacketUnknown(void)
#line 202
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 203
    {
      FramerM$gFlags |= FramerM$FLAGS_UNKNOWN;
    }
#line 205
    __nesc_atomic_end(__nesc_atomic); }

  FramerM$StartTx();
}

# 246 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static inline  TOS_MsgPtr AMStandard$UARTReceive$receive(TOS_MsgPtr packet)
#line 246
{


  packet->group = TOS_AM_GROUP;
  return received(packet);
}

# 275 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static inline  TOS_MsgPtr AMPromiscuous$UARTReceive$receive(TOS_MsgPtr packet)
#line 275
{
  packet->group = TOS_AM_GROUP;
  return prom_received(packet);
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr FramerAckM$ReceiveCombined$receive(TOS_MsgPtr arg_0x17efd58){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = AMPromiscuous$UARTReceive$receive(arg_0x17efd58);
#line 75
  result = AMStandard$UARTReceive$receive(arg_0x17efd58);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerAckM.nc"
static inline  TOS_MsgPtr FramerAckM$ReceiveMsg$receive(TOS_MsgPtr Msg)
#line 91
{
  TOS_MsgPtr pBuf;

  pBuf = FramerAckM$ReceiveCombined$receive(Msg);

  return pBuf;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ReceiveMsg.nc"
inline static  TOS_MsgPtr FramerM$ReceiveMsg$receive(TOS_MsgPtr arg_0x17efd58){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = FramerAckM$ReceiveMsg$receive(arg_0x17efd58);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 328 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  result_t FramerM$TokenReceiveMsg$ReflectToken(uint8_t Token)
#line 328
{
  result_t Result = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 331
    {
      if (!(FramerM$gFlags & FramerM$FLAGS_TOKENPEND)) {
          FramerM$gFlags |= FramerM$FLAGS_TOKENPEND;
          FramerM$gTxTokenBuf = Token;
        }
      else {
          Result = FAIL;
        }
    }
#line 339
    __nesc_atomic_end(__nesc_atomic); }

  if (Result == SUCCESS) {
      Result = FramerM$StartTx();
    }

  return Result;
}

# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
inline static  result_t FramerAckM$TokenReceiveMsg$ReflectToken(uint8_t arg_0x1d34598){
#line 88
  unsigned char result;
#line 88

#line 88
  result = FramerM$TokenReceiveMsg$ReflectToken(arg_0x1d34598);
#line 88

#line 88
  return result;
#line 88
}
#line 88
# 74 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerAckM.nc"
static inline  void FramerAckM$SendAckTask(void)
#line 74
{

  FramerAckM$TokenReceiveMsg$ReflectToken(FramerAckM$gTokenBuf);
}

static inline  TOS_MsgPtr FramerAckM$TokenReceiveMsg$receive(TOS_MsgPtr Msg, uint8_t token)
#line 79
{
  TOS_MsgPtr pBuf;

  FramerAckM$gTokenBuf = token;

  TOS_post(FramerAckM$SendAckTask);

  pBuf = FramerAckM$ReceiveCombined$receive(Msg);

  return pBuf;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/TokenReceiveMsg.nc"
inline static  TOS_MsgPtr FramerM$TokenReceiveMsg$receive(TOS_MsgPtr arg_0x1d35d88, uint8_t arg_0x1d35f00){
#line 75
  struct TOS_Msg *result;
#line 75

#line 75
  result = FramerAckM$TokenReceiveMsg$receive(arg_0x1d35d88, arg_0x1d35f00);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 210 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline  void FramerM$PacketRcvd(void)
#line 210
{
  FramerM$MsgRcvEntry_t *pRcv = &FramerM$gMsgRcvTbl[FramerM$gRxTailIndex];
  TOS_MsgPtr pBuf = pRcv->pMsg;


  if (pRcv->Length >= (size_t )& ((TOS_Msg *)0)->data) {

      switch (pRcv->Proto) {
          case FramerM$PROTO_ACK: 
            break;
          case FramerM$PROTO_PACKET_ACK: 
            pBuf->crc = 1;
          pBuf = FramerM$TokenReceiveMsg$receive(pBuf, pRcv->Token);
          break;
          case FramerM$PROTO_PACKET_NOACK: 
            pBuf->crc = 1;
          pBuf = FramerM$ReceiveMsg$receive(pBuf);
          break;
          default: 
            FramerM$gTxUnknownBuf = pRcv->Proto;
          TOS_post(FramerM$PacketUnknown);
          break;
        }
    }

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 235
    {
      if (pBuf) {
          pRcv->pMsg = pBuf;
        }
      pRcv->Length = 0;
      pRcv->Token = 0;
      FramerM$gRxTailIndex++;
      FramerM$gRxTailIndex %= FramerM$HDLC_QUEUESIZE;
    }
#line 243
    __nesc_atomic_end(__nesc_atomic); }
}

#line 348
static inline   result_t FramerM$ByteComm$rxByteReady(uint8_t data, bool error, uint16_t strength)
#line 348
{

  switch (FramerM$gRxState) {

      case FramerM$RXSTATE_NOSYNC: 
        if (data == FramerM$HDLC_FLAG_BYTE && FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
            FramerM$gRxState = FramerM$RXSTATE_PROTO;
          }
      break;

      case FramerM$RXSTATE_PROTO: 
        if (data == FramerM$HDLC_FLAG_BYTE) {
            break;
          }
      FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Proto = data;
      FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, data);
      switch (data) {
          case FramerM$PROTO_PACKET_ACK: 
            FramerM$gRxState = FramerM$RXSTATE_TOKEN;
          break;
          case FramerM$PROTO_PACKET_NOACK: 
            FramerM$gRxState = FramerM$RXSTATE_INFO;
          break;
          default: 
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          break;
        }
      break;

      case FramerM$RXSTATE_TOKEN: 
        if (data == FramerM$HDLC_FLAG_BYTE) {
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
#line 384
          if (data == FramerM$HDLC_CTLESC_BYTE) {
              FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0x20;
            }
          else {
              FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token ^= data;
              FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token);
              FramerM$gRxState = FramerM$RXSTATE_INFO;
            }
          }
#line 392
      break;


      case FramerM$RXSTATE_INFO: 
        if (FramerM$gRxByteCnt > FramerM$HDLC_MTU) {
            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
#line 402
          if (data == FramerM$HDLC_CTLESC_BYTE) {
              FramerM$gRxState = FramerM$RXSTATE_ESC;
            }
          else {
#line 405
            if (data == FramerM$HDLC_FLAG_BYTE) {
                if (FramerM$gRxByteCnt >= 2) {
                    uint16_t usRcvdCRC = FramerM$gpRxBuf[FramerM$gRxByteCnt - 1] & 0xff;

#line 408
                    usRcvdCRC = (usRcvdCRC << 8) | (FramerM$gpRxBuf[FramerM$gRxByteCnt - 2] & 0xff);
                    if (usRcvdCRC == FramerM$gRxRunningCRC) {
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = FramerM$gRxByteCnt - 2;
                        TOS_post(FramerM$PacketRcvd);
                        FramerM$gRxHeadIndex++;
#line 412
                        FramerM$gRxHeadIndex %= FramerM$HDLC_QUEUESIZE;
                      }
                    else {
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
                        FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
                      }
                    if (FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length == 0) {
                        FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
                        FramerM$gRxState = FramerM$RXSTATE_PROTO;
                      }
                    else {
                        FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
                      }
                  }
                else {
                    FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
                    FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
                    FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
                  }
                FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
              }
            else {
                FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
                if (FramerM$gRxByteCnt >= 2) {
                    FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
                  }
                FramerM$gRxByteCnt++;
              }
            }
          }
#line 440
      break;

      case FramerM$RXSTATE_ESC: 
        if (data == FramerM$HDLC_FLAG_BYTE) {

            FramerM$gRxByteCnt = FramerM$gRxRunningCRC = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Length = 0;
            FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].Token = 0;
            FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
          }
        else {
            data = data ^ 0x20;
            FramerM$gpRxBuf[FramerM$gRxByteCnt] = data;
            if (FramerM$gRxByteCnt >= 2) {
                FramerM$gRxRunningCRC = crcByte(FramerM$gRxRunningCRC, FramerM$gpRxBuf[FramerM$gRxByteCnt - 2]);
              }
            FramerM$gRxByteCnt++;
            FramerM$gRxState = FramerM$RXSTATE_INFO;
          }
      break;

      default: 
        FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
      break;
    }

  return SUCCESS;
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$rxByteReady(uint8_t arg_0x1d2f648, bool arg_0x1d2f7c0, uint16_t arg_0x1d2f948){
#line 66
  unsigned char result;
#line 66

#line 66
  result = FramerM$ByteComm$rxByteReady(arg_0x1d2f648, arg_0x1d2f7c0, arg_0x1d2f948);
#line 66

#line 66
  return result;
#line 66
}
#line 66
# 77 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static inline   result_t UARTM$HPLUART$get(uint8_t data)
#line 77
{




  UARTM$ByteComm$rxByteReady(data, FALSE, 0);
  {
  }
#line 83
  ;
  return SUCCESS;
}

# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t HPLUARTM$UART$get(uint8_t arg_0x1db5ed0){
#line 88
  unsigned char result;
#line 88

#line 88
  result = UARTM$HPLUART$get(arg_0x1db5ed0);
#line 88

#line 88
  return result;
#line 88
}
#line 88
# 90 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$USARTData$rxDone(uint8_t b)
#line 90
{
  return HPLUARTM$UART$get(b);
}

# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
inline static   result_t HPLUSART1M$USARTData$rxDone(uint8_t arg_0x1af0a38){
#line 53
  unsigned char result;
#line 53

#line 53
  result = HPLUARTM$USARTData$rxDone(arg_0x1af0a38);
#line 53

#line 53
  return result;
#line 53
}
#line 53
# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t FramerM$ByteComm$txByte(uint8_t arg_0x1d2f118){
#line 55
  unsigned char result;
#line 55

#line 55
  result = UARTM$ByteComm$txByte(arg_0x1d2f118);
#line 55

#line 55
  return result;
#line 55
}
#line 55
# 482 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline   result_t FramerM$ByteComm$txByteReady(bool LastByteSuccess)
#line 482
{
  result_t TxResult = SUCCESS;
  uint8_t nextByte;

  if (LastByteSuccess != TRUE) {
      FramerM$gTxState = FramerM$TXSTATE_ERROR;
      TOS_post(FramerM$PacketSent);
      return SUCCESS;
    }

  switch (FramerM$gTxState) {

      case FramerM$TXSTATE_PROTO: 
        FramerM$gTxState = FramerM$TXSTATE_INFO;
      FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, (uint8_t )(FramerM$gTxProto & 0x0FF));
      TxResult = FramerM$ByteComm$txByte((uint8_t )(FramerM$gTxProto & 0x0FF));
      break;

      case FramerM$TXSTATE_INFO: 
        nextByte = FramerM$gpTxBuf[FramerM$gTxByteCnt];

      FramerM$gTxRunningCRC = crcByte(FramerM$gTxRunningCRC, nextByte);
      FramerM$gTxByteCnt++;
      if (FramerM$gTxByteCnt >= FramerM$gTxLength) {
          FramerM$gTxState = FramerM$TXSTATE_FCS1;
        }

      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_ESC: 

        TxResult = FramerM$ByteComm$txByte(FramerM$gTxEscByte ^ 0x20);
      FramerM$gTxState = FramerM$gPrevTxState;
      break;

      case FramerM$TXSTATE_FCS1: 
        nextByte = (uint8_t )(FramerM$gTxRunningCRC & 0xff);
      FramerM$gTxState = FramerM$TXSTATE_FCS2;
      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_FCS2: 
        nextByte = (uint8_t )((FramerM$gTxRunningCRC >> 8) & 0xff);
      FramerM$gTxState = FramerM$TXSTATE_ENDFLAG;
      TxResult = FramerM$TxArbitraryByte(nextByte);
      break;

      case FramerM$TXSTATE_ENDFLAG: 
        FramerM$gTxState = FramerM$TXSTATE_FINISH;
      TxResult = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);

      break;

      case FramerM$TXSTATE_FINISH: 
        case FramerM$TXSTATE_ERROR: 

          default: 
            break;
    }


  if (TxResult != SUCCESS) {
      FramerM$gTxState = FramerM$TXSTATE_ERROR;
      TOS_post(FramerM$PacketSent);
    }

  return SUCCESS;
}

# 75 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$txByteReady(bool arg_0x1d2d010){
#line 75
  unsigned char result;
#line 75

#line 75
  result = FramerM$ByteComm$txByteReady(arg_0x1d2d010);
#line 75

#line 75
  return result;
#line 75
}
#line 75
# 552 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static inline   result_t FramerM$ByteComm$txDone(void)
#line 552
{

  if (FramerM$gTxState == FramerM$TXSTATE_FINISH) {
      FramerM$gTxState = FramerM$TXSTATE_IDLE;
      TOS_post(FramerM$PacketSent);
    }

  return SUCCESS;
}

# 83 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ByteComm.nc"
inline static   result_t UARTM$ByteComm$txDone(void){
#line 83
  unsigned char result;
#line 83

#line 83
  result = FramerM$ByteComm$txDone();
#line 83

#line 83
  return result;
#line 83
}
#line 83
# 87 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static inline   result_t UARTM$HPLUART$putDone(void)
#line 87
{
  bool oldState;

  {
    {
    }
#line 91
    ;
    oldState = UARTM$state;
    UARTM$state = FALSE;
  }








  if (oldState) {
      UARTM$ByteComm$txDone();
      UARTM$ByteComm$txByteReady(TRUE);
    }
  return SUCCESS;
}

# 96 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/HPLUART.nc"
inline static   result_t HPLUARTM$UART$putDone(void){
#line 96
  unsigned char result;
#line 96

#line 96
  result = UARTM$HPLUART$putDone();
#line 96

#line 96
  return result;
#line 96
}
#line 96
# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUARTM.nc"
static inline   result_t HPLUARTM$USARTData$txDone(void)
#line 94
{
  return HPLUARTM$UART$putDone();
}

# 46 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSARTFeedback.nc"
inline static   result_t HPLUSART1M$USARTData$txDone(void){
#line 46
  unsigned char result;
#line 46

#line 46
  result = HPLUARTM$USARTData$txDone();
#line 46

#line 46
  return result;
#line 46
}
#line 46
# 496 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$HPLADC12$memOverflow(void)
#line 496
{
}

# 248 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline   void RefVoltM$HPLADC12$memOverflow(void)
#line 248
{
}

# 61 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void HPLADC12M$HPLADC12$memOverflow(void){
#line 61
  RefVoltM$HPLADC12$memOverflow();
#line 61
  MSP430ADC12M$HPLADC12$memOverflow();
#line 61
}
#line 61
# 497 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$HPLADC12$timeOverflow(void)
#line 497
{
}

# 249 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline   void RefVoltM$HPLADC12$timeOverflow(void)
#line 249
{
}

# 62 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void HPLADC12M$HPLADC12$timeOverflow(void){
#line 62
  RefVoltM$HPLADC12$timeOverflow();
#line 62
  MSP430ADC12M$HPLADC12$timeOverflow();
#line 62
}
#line 62
#line 58
inline static   void MSP430ADC12M$HPLADC12$resetIFGs(void){
#line 58
  HPLADC12M$HPLADC12$resetIFGs();
#line 58
}
#line 58
# 413 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline    uint16_t *MSP430ADC12M$ADCMultiple$default$dataReady(uint8_t num, uint16_t *buf, 
uint16_t length)
{
  return (uint16_t *)0;
}

# 167 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
inline static   uint16_t *MSP430ADC12M$ADCMultiple$dataReady(uint8_t arg_0x27254c8, uint16_t *arg_0x2712288, uint16_t arg_0x2712408){
#line 167
  unsigned int *result;
#line 167

#line 167
  switch (arg_0x27254c8) {
#line 167
    case 1U:
#line 167
      result = InternalTempM$MSP430ADC12Multiple$dataReady(arg_0x2712288, arg_0x2712408);
#line 167
      break;
#line 167
    case 4U:
#line 167
      result = InternalVoltageM$MSP430ADC12Multiple$dataReady(arg_0x2712288, arg_0x2712408);
#line 167
      break;
#line 167
    default:
#line 167
      result = MSP430ADC12M$ADCMultiple$default$dataReady(arg_0x27254c8, arg_0x2712288, arg_0x2712408);
#line 167
    }
#line 167

#line 167
  return result;
#line 167
}
#line 167
# 91 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   uint16_t HPLADC12M$HPLADC12$getMem(uint8_t i)
#line 91
{
  return *((uint16_t *)(int *)0x0140 + i);
}

# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   uint16_t MSP430ADC12M$HPLADC12$getMem(uint8_t arg_0x2773940){
#line 52
  unsigned int result;
#line 52

#line 52
  result = HPLADC12M$HPLADC12$getMem(arg_0x2773940);
#line 52

#line 52
  return result;
#line 52
}
#line 52
#line 50
inline static   void MSP430ADC12M$HPLADC12$setMemControl(uint8_t arg_0x2774e10, adc12memctl_t arg_0x2773010){
#line 50
  HPLADC12M$HPLADC12$setMemControl(arg_0x2774e10, arg_0x2773010);
#line 50
}
#line 50
# 81 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   adc12memctl_t HPLADC12M$HPLADC12$getMemControl(uint8_t i)
#line 81
{
  adc12memctl_t x = { .inch = 0, .sref = 0, .eos = 0 };
  uint8_t *memCtlPtr = (uint8_t *)(char *)0x0080;

#line 84
  if (i < 16) {
      memCtlPtr += i;
      x = * (adc12memctl_t *)memCtlPtr;
    }
  return x;
}

# 51 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   adc12memctl_t MSP430ADC12M$HPLADC12$getMemControl(uint8_t arg_0x27734b0){
#line 51
  struct __nesc_unnamed4262 result;
#line 51

#line 51
  result = HPLADC12M$HPLADC12$getMemControl(arg_0x27734b0);
#line 51

#line 51
  return result;
#line 51
}
#line 51
# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static inline    result_t InternalTempM$ADCSingle$default$dataReady(adcresult_t result, uint16_t data)
{
  return FAIL;
}

# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCSingle.nc"
inline static   result_t InternalTempM$ADCSingle$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20){
#line 105
  unsigned char result;
#line 105

#line 105
  result = InternalTempM$ADCSingle$default$dataReady(arg_0x2694da0, arg_0x2694f20);
#line 105

#line 105
  return result;
#line 105
}
#line 105
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static inline   result_t InternalTempM$MSP430ADC12Single$dataReady(uint16_t data)
{
  return InternalTempM$ADCSingle$dataReady(ADC_SUCCESS, data);
}

# 111 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline    result_t InternalVoltageM$ADCSingle$default$dataReady(adcresult_t result, uint16_t data)
{
  return FAIL;
}

# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCSingle.nc"
inline static   result_t InternalVoltageM$ADCSingle$dataReady(adcresult_t arg_0x2694da0, uint16_t arg_0x2694f20){
#line 105
  unsigned char result;
#line 105

#line 105
  result = InternalVoltageM$ADCSingle$default$dataReady(arg_0x2694da0, arg_0x2694f20);
#line 105

#line 105
  return result;
#line 105
}
#line 105
# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline   result_t InternalVoltageM$MSP430ADC12Single$dataReady(uint16_t data)
{
  return InternalVoltageM$ADCSingle$dataReady(ADC_SUCCESS, data);
}

# 409 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline    result_t MSP430ADC12M$ADCSingle$default$dataReady(uint8_t num, uint16_t data)
{
  return FAIL;
}

# 131 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Single.nc"
inline static   result_t MSP430ADC12M$ADCSingle$dataReady(uint8_t arg_0x27269f8, uint16_t arg_0x26c5100){
#line 131
  unsigned char result;
#line 131

#line 131
  switch (arg_0x27269f8) {
#line 131
    case 0U:
#line 131
      result = InternalTempM$MSP430ADC12Single$dataReady(arg_0x26c5100);
#line 131
      break;
#line 131
    case 2U:
#line 131
      result = ADCM$MSP430ADC12Single$dataReady(arg_0x26c5100);
#line 131
      break;
#line 131
    case 3U:
#line 131
      result = InternalVoltageM$MSP430ADC12Single$dataReady(arg_0x26c5100);
#line 131
      break;
#line 131
    default:
#line 131
      result = MSP430ADC12M$ADCSingle$default$dataReady(arg_0x27269f8, arg_0x26c5100);
#line 131
    }
#line 131

#line 131
  return result;
#line 131
}
#line 131
# 441 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   void MSP430ADC12M$HPLADC12$converted(uint8_t number)
#line 441
{
  switch (MSP430ADC12M$cmode) 
    {
      case SINGLE_CHANNEL: 
        {
          volatile uint8_t ownerTmp = MSP430ADC12M$owner;

#line 447
          MSP430ADC12M$stopConversion();
          MSP430ADC12M$ADCSingle$dataReady(ownerTmp, MSP430ADC12M$HPLADC12$getMem(0));
        }
      break;
      case REPEAT_SINGLE_CHANNEL: 
        if (MSP430ADC12M$ADCSingle$dataReady(MSP430ADC12M$owner, MSP430ADC12M$HPLADC12$getMem(0)) == FAIL) {
          MSP430ADC12M$stopConversion();
          }
#line 454
      break;
      case SEQUENCE_OF_CHANNELS: 
        {
          uint16_t i = 0;
#line 457
          uint16_t length = MSP430ADC12M$bufLength - MSP430ADC12M$bufOffset > 16 ? 16 : MSP430ADC12M$bufLength - MSP430ADC12M$bufOffset;

#line 458
          do {
              * MSP430ADC12M$bufPtr++ = MSP430ADC12M$HPLADC12$getMem(i);
            }
          while (
#line 460
          ++i < length);

          MSP430ADC12M$bufOffset += length;

          if (MSP430ADC12M$bufLength - MSP430ADC12M$bufOffset > 15) {
            return;
            }
          else {
#line 466
            if (MSP430ADC12M$bufLength - MSP430ADC12M$bufOffset > 0) {
                adc12memctl_t memctl = MSP430ADC12M$HPLADC12$getMemControl(0);

#line 468
                memctl.eos = 1;
                MSP430ADC12M$HPLADC12$setMemControl(MSP430ADC12M$bufLength - MSP430ADC12M$bufOffset, memctl);
              }
            else 
#line 470
              {
                MSP430ADC12M$stopConversion();
                MSP430ADC12M$ADCMultiple$dataReady(MSP430ADC12M$owner, MSP430ADC12M$bufPtr - MSP430ADC12M$bufLength, MSP430ADC12M$bufLength);
              }
            }
        }
#line 475
      break;
      case REPEAT_SEQUENCE_OF_CHANNELS: 
        {
          uint8_t i = 0;

#line 479
          do {
              * MSP430ADC12M$bufPtr++ = MSP430ADC12M$HPLADC12$getMem(i);
            }
          while (
#line 481
          ++i < MSP430ADC12M$bufLength);

          if ((
#line 482
          MSP430ADC12M$bufPtr = MSP430ADC12M$ADCMultiple$dataReady(MSP430ADC12M$owner, MSP430ADC12M$bufPtr - MSP430ADC12M$bufLength, 
          MSP430ADC12M$bufLength)) == 0) {
            MSP430ADC12M$stopConversion();
            }
#line 485
          break;
        }
      default: 
        {

          MSP430ADC12M$HPLADC12$resetIFGs();
        }
      break;
    }
}

# 250 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline   void RefVoltM$HPLADC12$converted(uint8_t number)
#line 250
{
}

# 63 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void HPLADC12M$HPLADC12$converted(uint8_t arg_0x2770250){
#line 63
  RefVoltM$HPLADC12$converted(arg_0x2770250);
#line 63
  MSP430ADC12M$HPLADC12$converted(arg_0x2770250);
#line 63
}
#line 63
# 117 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static inline   void HPLADC12M$HPLADC12$stopConversion(void)
#line 117
{
  HPLADC12M$ADC12CTL1 &= ~((1 << 1) | (3 << 1));
  HPLADC12M$ADC12CTL0 &= ~0x0002;
}

# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12.nc"
inline static   void MSP430ADC12M$HPLADC12$stopConversion(void){
#line 82
  HPLADC12M$HPLADC12$stopConversion();
#line 82
}
#line 82
# 225 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static inline  void RefVoltM$switchOffDelay(void)
#line 225
{
  if (RefVoltM$switchOff == TRUE) {
    RefVoltM$SwitchOffTimer$setOneShot(100);
    }
}

#line 180
static inline   result_t RefVoltM$RefVolt$release(void)
#line 180
{
  result_t result = FAIL;

  {
    if (RefVoltM$semaCount <= 0) {
      result = FAIL;
      }
    else 
#line 186
      {
        RefVoltM$semaCount--;
        if (RefVoltM$semaCount == 0) {
            if (RefVoltM$state == RefVoltM$REFERENCE_1_5V_PENDING || 
            RefVoltM$state == RefVoltM$REFERENCE_2_5V_PENDING) {
                RefVoltM$switchOff = TRUE;
                RefVoltM$switchRefOff();
              }
            else {
                RefVoltM$switchOff = TRUE;
                TOS_post(RefVoltM$switchOffDelay);
              }
            result = SUCCESS;
          }
      }
  }
  return result;
}

# 109 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVolt.nc"
inline static   result_t MSP430ADC12M$RefVolt$release(void){
#line 109
  unsigned char result;
#line 109

#line 109
  result = RefVoltM$RefVolt$release();
#line 109

#line 109
  return result;
#line 109
}
#line 109
# 158 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline result_t MSP430ADC12M$releaseRefVolt(uint8_t num)
{
  if (MSP430ADC12M$adc12settings[num].gotRefVolt == 1) {
      MSP430ADC12M$RefVolt$release();
      MSP430ADC12M$adc12settings[num].gotRefVolt = 0;
      return SUCCESS;
    }
  return FAIL;
}

# 132 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static inline   result_t AttrTempM$ADC$dataReady(uint16_t data)
{
  * (uint16_t *)AttrTempM$result = data;
  TOS_post(AttrTempM$getAttrDone);
  return SUCCESS;
}

# 302 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static inline  result_t Tuple$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo)
#line 302
{
  return SUCCESS;
}

# 2430 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static inline  result_t DBBufferC$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo)
#line 2430
{
  return SUCCESS;
}

# 385 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static inline  result_t ParsedQuery$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo)
#line 385
{
  return SUCCESS;
}

# 2945 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline  result_t TupleRouterM$AttrUse$getAttrDone(char *name, char *resultBuf, SchemaErrorNo errorNo)
{
  if (resultBuf == (char *)&TupleRouterM$mVoltage) {
    TupleRouterM$continueSetSampleRate();
    }
  else {
#line 2950
    TupleRouterM$fillInAttrVal(errorNo);
    }
#line 2951
  return SUCCESS;
}

# 104 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrUse.nc"
inline static  result_t Attr$AttrUse$getAttrDone(char *arg_0x204a898, char *arg_0x204aa30, SchemaErrorNo arg_0x204abb0){
#line 104
  unsigned char result;
#line 104

#line 104
  result = TupleRouterM$AttrUse$getAttrDone(arg_0x204a898, arg_0x204aa30, arg_0x204abb0);
#line 104
  result = rcombine(result, ParsedQuery$AttrUse$getAttrDone(arg_0x204a898, arg_0x204aa30, arg_0x204abb0));
#line 104
  result = rcombine(result, DBBufferC$AttrUse$getAttrDone(arg_0x204a898, arg_0x204aa30, arg_0x204abb0));
#line 104
  result = rcombine(result, Tuple$AttrUse$getAttrDone(arg_0x204a898, arg_0x204aa30, arg_0x204abb0));
#line 104

#line 104
  return result;
#line 104
}
#line 104
# 259 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static inline  result_t Attr$Attr$getAttrDone(uint8_t id, char *name, char *resultBuf, SchemaErrorNo errorNo)
{
  Attr$AttrUse$getAttrDone(name, resultBuf, errorNo);
  return SUCCESS;
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrVoltageM$AttrRegister$getAttrDone(char *arg_0x2618638, char *arg_0x26187d0, SchemaErrorNo arg_0x2618950){
#line 92
  unsigned char result;
#line 92

#line 92
  result = Attr$Attr$getAttrDone(5U, arg_0x2618638, arg_0x26187d0, arg_0x2618950);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 159 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrVoltageM.nc"
static inline  void AttrVoltageM$getDoneTask(void)
#line 159
{
  AttrVoltageM$AttrRegister$getAttrDone(AttrVoltageM$attrName, AttrVoltageM$result, SCHEMA_RESULT_READY);
}

#line 148
static inline   result_t AttrVoltageM$ADC$dataReady(uint16_t data)
{
  * (uint16_t *)AttrVoltageM$result = data;




  TOS_post(AttrVoltageM$getDoneTask);
  return SUCCESS;
}

# 183 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static inline    result_t ADCM$ADC$default$dataReady(uint8_t num, uint16_t d)
#line 183
{
#line 183
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/ADC.nc"
inline static   result_t ADCM$ADC$dataReady(uint8_t arg_0x26f2da8, uint16_t arg_0x26a91b8){
#line 70
  unsigned char result;
#line 70

#line 70
  switch (arg_0x26f2da8) {
#line 70
    case TOS_ADC_INTERNAL_TEMP_PORT:
#line 70
      result = AttrTempM$ADC$dataReady(arg_0x26a91b8);
#line 70
      break;
#line 70
    case TOS_ADC_INTERNAL_VOLTAGE_PORT:
#line 70
      result = AttrVoltageM$ADC$dataReady(arg_0x26a91b8);
#line 70
      break;
#line 70
    default:
#line 70
      result = ADCM$ADC$default$dataReady(arg_0x26f2da8, arg_0x26a91b8);
#line 70
    }
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 1997 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static inline void TupleRouterM$computeRates(uint32_t lifetimeHoursRem, 
uint32_t curVReading, 
uint32_t ujSampleCost, 
uint32_t ujAggCost, 
uint32_t numMsgs, 
uint32_t numSamples, 
uint32_t *epochDur, 
uint16_t *aggWinSize, 
uint16_t *mvPerDay)
{

  uint32_t ujXmitCost = TupleRouterM$uaXmit * TupleRouterM$msXmit * TupleRouterM$Vdraw / 1000;
  uint32_t mahRemaining = (curVReading - TupleRouterM$minVReading) * TupleRouterM$mahCapacity / (TupleRouterM$maxVReading - TupleRouterM$minVReading);
  uint32_t uaAvg = mahRemaining * 1000 / lifetimeHoursRem;
  uint32_t uaAvgActive = (ujSampleCost * numSamples + ujXmitCost * numMsgs + ujAggCost * numSamples) / (TupleRouterM$Vdraw * TupleRouterM$sPerSample) + TupleRouterM$uaActive;
  uint32_t dutyCycle = (uaAvg - TupleRouterM$uaSleep) * 100000 / (uaAvgActive - TupleRouterM$uaSleep);

  if (uaAvg < TupleRouterM$uaSleep) {
    *epochDur = -1;
    }
  else 
#line 2016
    {
      *epochDur = TupleRouterM$sPerSample * 100000 * 1000 / dutyCycle;
      if (*epochDur < TupleRouterM$sPerSample * 1000) {
        *epochDur = TupleRouterM$sPerSample * 1000;
        }
    }
#line 2021
  {
  }
#line 2021
  ;
  *aggWinSize = 1;
  *mvPerDay = (curVReading - TupleRouterM$minVReading) * 24 * 1000 / lifetimeHoursRem;
}

#line 443
static inline void TupleRouterM$UNSET_SETTING_SAMPLE_RATE(void)
#line 443
{
#line 443
  TupleRouterM$mPendingMask &= TupleRouterM$SETTING_SAMPLE_RATE_BIT ^ 0xFFFF;
}

# 92 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/AttrRegister.nc"
inline static  result_t AttrTempM$AttrRegister$getAttrDone(char *arg_0x2618638, char *arg_0x26187d0, SchemaErrorNo arg_0x2618950){
#line 92
  unsigned char result;
#line 92

#line 92
  result = Attr$Attr$getAttrDone(4U, arg_0x2618638, arg_0x26187d0, arg_0x2618950);
#line 92

#line 92
  return result;
#line 92
}
#line 92
# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static inline    uint16_t *InternalVoltageM$ADCMultiple$default$dataReady(adcresult_t result, uint16_t *buf, uint16_t length)
{
  return 0;
}

# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCMultiple.nc"
inline static   uint16_t *InternalVoltageM$ADCMultiple$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0){
#line 129
  unsigned int *result;
#line 129

#line 129
  result = InternalVoltageM$ADCMultiple$default$dataReady(arg_0x26dfe68, arg_0x26de030, arg_0x26de1b0);
#line 129

#line 129
  return result;
#line 129
}
#line 129
# 370 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static inline   msp430ADCresult_t MSP430ADC12M$ADCMultiple$getData(uint8_t num, uint16_t *buf, 
uint16_t length, uint16_t jiffies)
{
  return MSP430ADC12M$newRequest(SEQUENCE_OF_CHANNELS, num, buf, length, jiffies);
}

# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
inline static   msp430ADCresult_t InternalVoltageM$MSP430ADC12Multiple$getData(uint16_t *arg_0x26c0068, uint16_t arg_0x26c01e8, uint16_t arg_0x26c0368){
#line 82
  enum __nesc_unnamed4259 result;
#line 82

#line 82
  result = MSP430ADC12M$ADCMultiple$getData(4U, arg_0x26c0068, arg_0x26c01e8, arg_0x26c0368);
#line 82

#line 82
  return result;
#line 82
}
#line 82
# 172 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static inline    uint16_t *InternalTempM$ADCMultiple$default$dataReady(adcresult_t result, uint16_t *buf, uint16_t length)
{
  return 0;
}

# 129 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCMultiple.nc"
inline static   uint16_t *InternalTempM$ADCMultiple$dataReady(adcresult_t arg_0x26dfe68, uint16_t *arg_0x26de030, uint16_t arg_0x26de1b0){
#line 129
  unsigned int *result;
#line 129

#line 129
  result = InternalTempM$ADCMultiple$default$dataReady(arg_0x26dfe68, arg_0x26de030, arg_0x26de1b0);
#line 129

#line 129
  return result;
#line 129
}
#line 129
# 82 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12Multiple.nc"
inline static   msp430ADCresult_t InternalTempM$MSP430ADC12Multiple$getData(uint16_t *arg_0x26c0068, uint16_t arg_0x26c01e8, uint16_t arg_0x26c0368){
#line 82
  enum __nesc_unnamed4259 result;
#line 82

#line 82
  result = MSP430ADC12M$ADCMultiple$getData(1U, arg_0x26c0068, arg_0x26c01e8, arg_0x26c0368);
#line 82

#line 82
  return result;
#line 82
}
#line 82
# 102 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/sched.c"
bool  TOS_post(void (*tp)(void))
#line 102
{
  __nesc_atomic_t fInterruptFlags;
  uint8_t tmp;



  fInterruptFlags = __nesc_atomic_start();

  tmp = TOSH_sched_free;

  if (TOSH_queue[tmp].tp == NULL) {
      TOSH_sched_free = (tmp + 1) & TOSH_TASK_BITMASK;
      TOSH_queue[tmp].tp = tp;
      __nesc_atomic_end(fInterruptFlags);

      return TRUE;
    }
  else {
      __nesc_atomic_end(fInterruptFlags);

      return FALSE;
    }
}

# 52 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MainM.nc"
int   main(void)
{
  MainM$hardwareInit();
  TOSH_sched_init();

  MainM$StdControl$init();
  MainM$StdControl$start();
  __nesc_enable_interrupt();

  for (; ; ) {
#line 61
      TOSH_run_task();
    }
}

# 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ClockM.nc"
static void MSP430ClockM$set_dco_calib(int calib)
{
  BCSCTL1 = (BCSCTL1 & ~0x07) | ((calib >> 8) & 0x07);
  DCOCTL = calib & 0xff;
}

# 72 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static  result_t TimerM$StdControl$init(void)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 74
    TimerM$m_hinow = 0;
#line 74
    __nesc_atomic_end(__nesc_atomic); }
  TimerM$m_head_short = TimerM$EMPTY_LIST;
  TimerM$m_head_long = TimerM$EMPTY_LIST;
  bzero(TimerM$m_timers, sizeof TimerM$m_timers);
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 78
    TimerM$m_posted_checkShortTimers = FALSE;
#line 78
    __nesc_atomic_end(__nesc_atomic); }
  TimerM$AlarmControl$setControlAsCompare();
  TimerM$AlarmControl$disableEvents();
  return SUCCESS;
}

# 86 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static  result_t Attr$Attr$registerAttr(uint8_t id, char *attrName, TOSType type, uint8_t attrLen)
{
  short attrIdx;
  AttrDescPtr attrDesc;
  bool attrExists = FALSE;
  short len;

#line 92
  if (Attr$addAttrPending) {
    return FAIL;
    }
  else {
#line 95
    Attr$addAttrPending = TRUE;
    }

  for (attrIdx = 0; attrIdx < Attr$attrDescs.numAttrs; attrIdx++) 
    if (strcasecmp(Attr$attrDescs.attrDesc[(int )attrIdx].name, attrName) == 0) 
      {
        attrExists = TRUE;
        break;
      }
  if (!attrExists) 
    {
      if (Attr$attrDescs.numAttrs < MAX_ATTRS) {
        Attr$attrDescs.numAttrs++;
        }
      else {
          Attr$addAttrPending = FALSE;
          return FAIL;
        }
    }
  attrDesc = &Attr$attrDescs.attrDesc[(int )attrIdx];
  attrDesc->type = type;
  attrDesc->idx = attrIdx;
  len = sizeOf(type);
  if (len < 0) {

    attrDesc->nbytes = attrLen;
    }
  else {
#line 122
    attrDesc->nbytes = (uint8_t )len;
    }
#line 123
  attrDesc->id = id;
  attrDesc->constIdx = -1;
  attrDesc->name = attrName;
  Attr$addAttrPending = FALSE;
  return SUCCESS;
}

# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/SchemaType.h"
static 
#line 70
short 
sizeOf(TOSType type)
{
  switch (type) {
      case VOID: 
        return 0;
      case INT8: 
        case UINT8: 
          return 1;
      case INT16: 
        case UINT16: 
          return 2;
      case INT32: 
        case UINT32: 
          return 4;
      case TIMESTAMP: 
        return 4;
      case STRING: 
        return 8;
      case BYTES: 
        return 8;
      default: 
        break;
    }
  return -1;
}

# 67 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static  result_t MSP430ADC12M$StdControl$init(void)
{
  MSP430ADC12M$cmode = ADC_IDLE;
  MSP430ADC12M$reserved = ADC_IDLE;
  MSP430ADC12M$vrefWait = FALSE;
  MSP430ADC12M$HPLADC12$disableConversion();
  MSP430ADC12M$HPLADC12$setIEFlags(0x0000);
  return SUCCESS;
}

# 53 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimeUtilC.nc"
static   char TimeUtilC$TimeUtil$compare(tos_time_t a, tos_time_t b)
#line 53
{
  if (a.high32 > b.high32) {
#line 54
    return 1;
    }
#line 55
  if (a.high32 < b.high32) {
#line 55
    return -1;
    }
#line 56
  if (a.low32 > b.low32) {
#line 56
    return 1;
    }
#line 57
  if (a.low32 < b.low32) {
#line 57
    return -1;
    }
#line 58
  return 0;
}

# 268 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static void FramerM$HDLCInitialize(void)
#line 268
{
  int i;

#line 270
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 270
    {
      for (i = 0; i < FramerM$HDLC_QUEUESIZE; i++) {
          FramerM$gMsgRcvTbl[i].pMsg = &FramerM$gMsgRcvBuf[i];
          FramerM$gMsgRcvTbl[i].Length = 0;
          FramerM$gMsgRcvTbl[i].Token = 0;
        }
      FramerM$gTxState = FramerM$TXSTATE_IDLE;
      FramerM$gTxByteCnt = 0;
      FramerM$gTxLength = 0;
      FramerM$gTxRunningCRC = 0;
      FramerM$gpTxMsg = NULL;

      FramerM$gRxState = FramerM$RXSTATE_NOSYNC;
      FramerM$gRxHeadIndex = 0;
      FramerM$gRxTailIndex = 0;
      FramerM$gRxByteCnt = 0;
      FramerM$gRxRunningCRC = 0;
      FramerM$gpRxBuf = (uint8_t *)FramerM$gMsgRcvTbl[FramerM$gRxHeadIndex].pMsg;
    }
#line 288
    __nesc_atomic_end(__nesc_atomic); }
}

# 225 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
static   void HPLUSART0M$USARTControl$setModeSPI(void)
#line 225
{

  if (HPLUSART0M$USARTControl$getMode() == USART_SPI) {
    return;
    }
  HPLUSART0M$USARTControl$disableUART();
  HPLUSART0M$USARTControl$disableI2C();

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 233
    {
      TOSH_SEL_SIMO0_MODFUNC();
      TOSH_SEL_SOMI0_MODFUNC();
      TOSH_SEL_UCLK0_MODFUNC();

      HPLUSART0M$IE1 &= ~((1 << 7) | (1 << 6));

      U0CTL = 0x01;
      U0CTL |= (0x10 | 0x04) | 0x02;
      U0CTL &= ~0x20;

      HPLUSART0M$U0TCTL = 0x02;
      HPLUSART0M$U0TCTL |= 0x80;

      if (HPLUSART0M$l_ssel & 0x80) {
          HPLUSART0M$U0TCTL &= ~(((0x00 | 0x10) | 0x20) | 0x30);
          HPLUSART0M$U0TCTL |= HPLUSART0M$l_ssel & 0x7F;
        }
      else {
          HPLUSART0M$U0TCTL &= ~(((0x00 | 0x10) | 0x20) | 0x30);
          HPLUSART0M$U0TCTL |= 0x20;
        }

      if (HPLUSART0M$l_br != 0) {
          U0BR0 = HPLUSART0M$l_br & 0x0FF;
          U0BR1 = (HPLUSART0M$l_br >> 8) & 0x0FF;
        }
      else {
          U0BR0 = 0x02;
          U0BR1 = 0x00;
        }
      U0MCTL = 0;

      HPLUSART0M$ME1 &= ~((1 << 7) | (1 << 6));
      HPLUSART0M$ME1 |= 1 << 6;
      U0CTL &= ~0x01;

      HPLUSART0M$IFG1 &= ~((1 << 7) | (1 << 6));
      HPLUSART0M$IE1 &= ~((1 << 7) | (1 << 6));
    }
#line 272
    __nesc_atomic_end(__nesc_atomic); }
  return;
}

#line 114
static   bool HPLUSART0M$USARTControl$isI2C(void)
#line 114
{
  bool _ret = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 117
    {
      if (U0CTL & 0x20 && U0CTL & 0x04 && U0CTL & 0x01) {
        _ret = TRUE;
        }
    }
#line 121
    __nesc_atomic_end(__nesc_atomic); }
  return _ret;
}

# 642 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  result_t TupleRouterM$StdControl$start(void)
#line 642
{

  TupleRouterM$mNumAttrs = 0;



  TupleRouterM$mDeliverWait = 0;
  TupleRouterM$mWaitIsDummy = FALSE;
  TupleRouterM$UNSET_FETCHING_ATTRIBUTE();
  TupleRouterM$UNSET_STARTING_ATTRIBUTE();
  TupleRouterM$UNSET_ROUTING_TUPLES();
  TupleRouterM$UNSET_AGGREGATING_RESULT();






  if (!(TOS_LOCAL_ADDRESS == 0) || !TupleRouterM$IS_SNOOZING()) {

      TupleRouterM$ChildControl$start();
      TupleRouterM$NetControl$start();








      TupleRouterM$startAllQueryAttrs();
    }
  else {

    TupleRouterM$RouteControl$manualUpdate();
    }



  if (TupleRouterM$IS_SNOOZING()) {

      TupleRouterM$mStopped = FALSE;

      TupleRouterM$AbsoluteTimer$fired();
    }
  else 
#line 686
    {



      TupleRouterM$TimerControl$start();

      if (TupleRouterM$kMS_PER_CLOCK_EVENT > 64) {
        TupleRouterM$setSimpleTimeInterval(TupleRouterM$kMS_PER_CLOCK_EVENT / 2);
        }
    }
#line 708
  return SUCCESS;
}

# 97 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static  result_t MSP430ADC12M$ADCSingle$bind(uint8_t num, MSP430ADC12Settings_t settings)
{
  result_t res = FAIL;
  adc12memctl_t memctl = { .inch = settings.inputChannel, 
  .sref = settings.referenceVoltage, 
  .eos = 0 };

  if (num >= 5U) {
    return FAIL;
    }
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      if (MSP430ADC12M$cmode == ADC_IDLE || MSP430ADC12M$owner != num) {
          MSP430ADC12M$configureAdcPin(settings.inputChannel);
          MSP430ADC12M$adc12settings[num].refVolt2_5 = settings.refVolt2_5;
          MSP430ADC12M$adc12settings[num].gotRefVolt = 0;
          MSP430ADC12M$adc12settings[num].clockSourceSHT = settings.clockSourceSHT;
          MSP430ADC12M$adc12settings[num].clockSourceSAMPCON = settings.clockSourceSAMPCON;
          MSP430ADC12M$adc12settings[num].clockDivSAMPCON = settings.clockDivSAMPCON;
          MSP430ADC12M$adc12settings[num].clockDivSHT = settings.clockDivSHT;
          MSP430ADC12M$adc12settings[num].sampleHoldTime = settings.sampleHoldTime;
          MSP430ADC12M$adc12settings[num].memctl = memctl;
          res = SUCCESS;
        }
    }
#line 121
    __nesc_atomic_end(__nesc_atomic); }
  return res;
}

# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static  result_t InternalTempM$StdControl$start(void)
#line 55
{
  result_t ok1;
#line 56
  result_t ok2;

  ok1 = InternalTempM$ADCControl$init();
  ok2 = InternalTempM$ADCControl$bindPort(TOS_ADC_INTERNAL_TEMP_PORT, 
  TOSH_ACTUAL_ADC_INTERNAL_TEMPERATURE_PORT);
  InternalTempM$MSP430ADC12Single$bind(int2adcSettings(((((((((((((((uint32_t )SAMPLE_HOLD_4_CYCLES << 4) + INTERNAL_TEMPERATURE) << 3) + SHT_CLOCK_DIV_1) << 3) + REFERENCE_VREFplus_AVss) << 2) + SAMPCON_CLOCK_DIV_1) << 2) + SAMPCON_SOURCE_SMCLK) << 2) + SHT_SOURCE_ACLK) << 1) + REFVOLT_LEVEL_1_5));
  InternalTempM$MSP430ADC12Multiple$bind(int2adcSettings(((((((((((((((uint32_t )SAMPLE_HOLD_4_CYCLES << 4) + INTERNAL_TEMPERATURE) << 3) + SHT_CLOCK_DIV_1) << 3) + REFERENCE_VREFplus_AVss) << 2) + SAMPCON_CLOCK_DIV_1) << 2) + SAMPCON_SOURCE_SMCLK) << 2) + SHT_SOURCE_ACLK) << 1) + REFVOLT_LEVEL_1_5));
  return SUCCESS;
}

# 146 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static  result_t SimpleTimeM$AbsoluteTimer$set(uint8_t id, tos_time_t in)
#line 146
{
  if (id >= MAX_NUM_TIMERS) {
      {
      }
#line 148
      ;
      return FAIL;
    }

  if (SimpleTimeM$TimeUtil$compare(SimpleTimeM$Time$get(), in) > 0) 
    {
      {
      }
#line 154
      ;

      return FAIL;
    }
  SimpleTimeM$aTimer[id] = in;

  return SUCCESS;
}

# 162 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static   uint8_t HPLCC2420M$HPLCC2420$write(uint8_t addr, uint16_t data)
#line 162
{
  uint8_t status = 0;

#line 164
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 166
        HPLCC2420M$f.busy = TRUE;
#line 166
        __nesc_atomic_end(__nesc_atomic); }
      TOSH_CLR_RADIO_CSN_PIN();

      HPLCC2420M$USARTControl$isTxIntrPending();
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx(addr);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
      status = HPLCC2420M$adjustStatusByte(HPLCC2420M$USARTControl$rx());
      HPLCC2420M$USARTControl$tx((data >> 8) & 0x0FF);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxIntrPending()) ;
      HPLCC2420M$USARTControl$tx(data & 0x0FF);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isTxEmpty()) ;
      TOSH_SET_RADIO_CSN_PIN();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 179
        HPLCC2420M$f.busy = FALSE;
#line 179
        __nesc_atomic_end(__nesc_atomic); }
#line 195
      HPLCC2420M$BusArbitration$releaseBus();
    }
  return status;
}

# 94 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/BusArbitrationM.nc"
static   result_t BusArbitrationM$BusArbitration$getBus(uint8_t id)
#line 94
{
  bool gotbus = FALSE;

#line 96
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 96
    {
      if (BusArbitrationM$state == BusArbitrationM$BUS_IDLE) {
          BusArbitrationM$state = BusArbitrationM$BUS_BUSY;
          gotbus = TRUE;
          BusArbitrationM$busid = id;
        }
    }
#line 102
    __nesc_atomic_end(__nesc_atomic); }
  if (gotbus) {
    return SUCCESS;
    }
#line 105
  return FAIL;
}

static   result_t BusArbitrationM$BusArbitration$releaseBus(uint8_t id)
#line 108
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 109
    {
      if (BusArbitrationM$state == BusArbitrationM$BUS_BUSY && BusArbitrationM$busid == id) {
          BusArbitrationM$state = BusArbitrationM$BUS_IDLE;





          if (BusArbitrationM$isBusReleasedPending == FALSE && TOS_post(BusArbitrationM$busReleased) == TRUE) {
            BusArbitrationM$isBusReleasedPending = TRUE;
            }
        }
    }
#line 121
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 127 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static   uint8_t HPLCC2420M$HPLCC2420$cmd(uint8_t addr)
#line 127
{
  uint8_t status = 0;

#line 129
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 131
        HPLCC2420M$f.busy = TRUE;
#line 131
        __nesc_atomic_end(__nesc_atomic); }
      TOSH_CLR_RADIO_CSN_PIN();

      HPLCC2420M$USARTControl$isTxIntrPending();
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx(addr);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
      status = HPLCC2420M$adjustStatusByte(HPLCC2420M$USARTControl$rx());
      TOSH_SET_RADIO_CSN_PIN();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 140
        HPLCC2420M$f.busy = FALSE;
#line 140
        __nesc_atomic_end(__nesc_atomic); }
#line 152
      HPLCC2420M$BusArbitration$releaseBus();
    }
  return status;
}

# 429 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/TimerM.nc"
static  result_t TimerM$Timer$start(uint8_t num, char type, uint32_t milli)
{
  switch (type) 
    {
      case TIMER_REPEAT: 
        return TimerM$setTimer(num, milli * 32, TRUE);

      case TIMER_ONE_SHOT: 
        return TimerM$setTimer(num, milli * 32, FALSE);
    }

  return FAIL;
}

#line 305
static result_t TimerM$setTimer(uint8_t num, int32_t jiffy, bool isperiodic)
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {
      TimerM$Timer_t *timer = &TimerM$m_timers[num];
      int32_t now;

#line 311
      if (timer->isset) {
        TimerM$removeTimer(num);
        }
#line 313
      TimerM$m_period[num] = jiffy;
      timer->isperiodic = isperiodic;
      now = TimerM$LocalTime$read();
      timer->alarm = now + jiffy;
      TimerM$insertTimer(num, jiffy <= 0xffffL);
      TimerM$setNextShortEvent();
    }
#line 319
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

#line 274
static   uint32_t TimerM$LocalTime$read(void)
{
  uint32_t now;

#line 277
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
    {



      uint16_t hinow = TimerM$m_hinow;
      uint16_t lonow = TimerM$AlarmTimer$read();

#line 284
      if (TimerM$AlarmTimer$isOverflowPending()) 
        {
          hinow++;
          lonow = TimerM$AlarmTimer$read();
        }
      now = ((uint32_t )TimerM$m_hinow << 16) | lonow;
    }
#line 290
    __nesc_atomic_end(__nesc_atomic); }
  return now;
}

#line 94
static void TimerM$insertTimer(uint8_t num, bool isshort)
{
  if (TimerM$m_timers[num].isqueued == FALSE) 
    {
      if (isshort) 
        {
          TimerM$m_timers[num].next = TimerM$m_head_short;
          TimerM$m_head_short = num;
        }
      else 
        {
          TimerM$m_timers[num].next = TimerM$m_head_long;
          TimerM$m_head_long = num;
        }
      TimerM$m_timers[num].isqueued = TRUE;
    }
  TimerM$m_timers[num].isset = TRUE;
}

#line 198
static void TimerM$setNextShortEvent(void)
{
  uint32_t now = TimerM$LocalTime$read();

#line 201
  if (TimerM$m_head_short != TimerM$EMPTY_LIST) 
    {
      uint8_t head = TimerM$m_head_short;
      uint8_t soon = head;
      int32_t remaining = TimerM$m_timers[head].alarm - now;

#line 206
      head = TimerM$m_timers[head].next;
      while (head != TimerM$EMPTY_LIST) 
        {
          int32_t dt = TimerM$m_timers[head].alarm - now;

#line 210
          if (dt < remaining) 
            {
              remaining = dt;
              soon = head;
            }
          head = TimerM$m_timers[head].next;
        }

      now = TimerM$LocalTime$read();
      remaining = TimerM$m_timers[soon].alarm - now;

      if (remaining <= 0) 
        {

          TimerM$AlarmControl$disableEvents();
          TimerM$post_checkShortTimers();
        }
      else 
        {


          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
            {




              if (remaining > 2) {
                TimerM$AlarmCompare$setEventFromNow(remaining);
                }
              else {
#line 240
                TimerM$AlarmCompare$setEventFromNow(2);
                }
#line 241
              TimerM$AlarmControl$clearPendingInterrupt();
              TimerM$AlarmControl$enableEvents();
            }
#line 243
            __nesc_atomic_end(__nesc_atomic); }
        }
    }
  else 
    {

      TimerM$AlarmControl$disableEvents();
    }
}

#line 141
static void TimerM$executeTimers(uint8_t head)
{
  uint32_t now = TimerM$LocalTime$read();

#line 144
  while (head != TimerM$EMPTY_LIST) 
    {
      uint8_t num = head;
      bool signal_timer = FALSE;

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
        {
          TimerM$Timer_t *timer = &TimerM$m_timers[num];

#line 152
          head = timer->next;

          timer->isqueued = FALSE;

          if (timer->isset) 
            {
              int32_t remaining = timer->alarm - now;

#line 159
              timer->isset = FALSE;
              if (remaining <= 0) 
                {


                  if (timer->isperiodic) 
                    {
                      timer->alarm += TimerM$m_period[num];
                      TimerM$insertTimer(num, (int32_t )(timer->alarm - now) <= 0xffffL);
                    }
                  signal_timer = TRUE;
                }
              else 
                {

                  TimerM$insertTimer(num, remaining <= 0xffffL);
                }
            }
        }
#line 177
        __nesc_atomic_end(__nesc_atomic); }

      if (signal_timer) {
        TimerM$signal_timer_fired(num);
        }
    }
}

# 419 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static  void MSP430ADC12M$RefVolt$isStable(RefVolt_t vref)
{
  if (MSP430ADC12M$vrefWait) {
      MSP430ADC12M$HPLADC12$startConversion();
      if (MSP430ADC12M$reserved & TIMER_USED) {
        MSP430ADC12M$startTimerA();
        }
#line 425
      MSP430ADC12M$reserved = ADC_IDLE;
      MSP430ADC12M$vrefWait = FALSE;
    }
}

#line 184
static void MSP430ADC12M$startTimerA(void)
{
  MSP430CompareControl_t ccSetSHI = { 
  .ccifg = 0, .cov = 0, .out = 1, .cci = 0, .ccie = 0, 
  .outmod = 0, .cap = 0, .clld = 0, .scs = 0, .ccis = 0, .cm = 0 };
  MSP430CompareControl_t ccResetSHI = { 
  .ccifg = 0, .cov = 0, .out = 0, .cci = 0, .ccie = 0, 
  .outmod = 0, .cap = 0, .clld = 0, .scs = 0, .ccis = 0, .cm = 0 };
  MSP430CompareControl_t ccRSOutmod = { 
  .ccifg = 0, .cov = 0, .out = 0, .cci = 0, .ccie = 0, 
  .outmod = 7, .cap = 0, .clld = 0, .scs = 0, .ccis = 0, .cm = 0 };

  MSP430ADC12M$ControlA1$setControl(ccResetSHI);
  MSP430ADC12M$ControlA1$setControl(ccSetSHI);

  MSP430ADC12M$ControlA1$setControl(ccRSOutmod);
  MSP430ADC12M$TimerA$setMode(MSP430TIMER_UP_MODE);
}

# 99 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/TimeUtilC.nc"
static   tos_time_t TimeUtilC$TimeUtil$addUint32(tos_time_t a, uint32_t ms)
#line 99
{
  tos_time_t result = a;

#line 101
  result.low32 += ms;
  if (result.low32 < a.low32) {
      result.high32++;
    }

  return result;
}

# 88 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/ServiceSchedulerM.nc"
static  result_t ServiceSchedulerM$AbsoluteTimer$fired(void)
#line 88
{
  uint32_t increment;
  pq_element svcidx = pqueue_dequeue((pqueue_t *)&ServiceSchedulerM$event_q);
  tos_time_t now;


  if (svcidx < 0) {
    return FAIL;
    }
  now = ServiceSchedulerM$sched_info[svcidx].start_time;

  if (ServiceSchedulerM$sched_info[svcidx].flags & START) {
      ServiceSchedulerM$Services$start(svcidx);


      ServiceSchedulerM$sched_info[svcidx].flags ^= START | STOP;
      increment = ServiceSchedulerM$sched_info[svcidx].on_time;
      ServiceSchedulerM$sched_info[svcidx].start_time = 
      ServiceSchedulerM$TimeUtil$addUint32(ServiceSchedulerM$sched_info[svcidx].start_time, increment);
      pqueue_enqueue((pqueue_t *)&ServiceSchedulerM$event_q, svcidx);
    }
  else {
#line 108
    if (ServiceSchedulerM$sched_info[svcidx].flags & STOP) {
        ServiceSchedulerM$Services$stop(svcidx);


        ServiceSchedulerM$sched_info[svcidx].flags ^= START | STOP;
        if (ServiceSchedulerM$sched_info[svcidx].off_time > 0) {
            increment = ServiceSchedulerM$sched_info[svcidx].off_time + ServiceSchedulerM$extraSleep;
            ServiceSchedulerM$extraSleep = 0;
            ServiceSchedulerM$sched_info[svcidx].start_time = 
            ServiceSchedulerM$TimeUtil$addUint32(ServiceSchedulerM$sched_info[svcidx].start_time, increment);
            pqueue_enqueue((pqueue_t *)&ServiceSchedulerM$event_q, svcidx);
          }
      }
    }
#line 121
  svcidx = pqueue_peek((pqueue_t *)&ServiceSchedulerM$event_q);
  if (svcidx < 0) {
    return SUCCESS;
    }


  if (ServiceSchedulerM$TimeUtil$compare(ServiceSchedulerM$sched_info[svcidx].start_time, now) == 0) {
      return ServiceSchedulerM$AbsoluteTimer$fired();
    }
  else {
      return ServiceSchedulerM$AbsoluteTimer$set(ServiceSchedulerM$sched_info[svcidx].start_time);
    }
}

# 76 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
static pq_element pqueue_dequeue_idx(pqueue_t *pq, int8_t i)
#line 76
{
  pq_element ret;
#line 77
  pq_element tmp;
  int8_t left_child;

#line 79
  if (pq->n_elements == 0) {
      return -1;
    }
  ret = pq->heap[0];
  pq->n_elements--;
  tmp = pq->heap[pq->n_elements];
  while (i < pq->n_elements >> 1) {
      left_child = (i << 1) + 1;

      if (left_child < pq->n_elements - 1 && 
      pq->compare(pq->heap[left_child], pq->heap[left_child + 1]) > 0) {
          left_child++;
        }
      if (pq->compare(pq->heap[left_child], tmp) >= 0) {
        break;
        }
#line 94
      pq->heap[i] = pq->heap[left_child];
      i = left_child;
    }
  pq->heap[i] = tmp;
  return ret;
}

#line 60
static result_t pqueue_enqueue(pqueue_t *pq, pq_element e)
#line 60
{
  int8_t ind;
#line 61
  int8_t parent;

#line 62
  if (pq->size <= pq->n_elements) {
    return FAIL;
    }
#line 64
  ind = pq->n_elements++;
  parent = (ind - 1) >> 1;
  while (ind > 0 && 
  pq->compare(e, pq->heap[parent]) < 0) {
      pq->heap[ind] = pq->heap[parent];
      ind = parent;
      parent = (ind - 1) >> 1;
    }
  pq->heap[ind] = e;
  return SUCCESS;
}

# 711 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  result_t TupleRouterM$StdControl$stop(void)
#line 711
{
  TupleRouterM$QueryListHandle qlh = TupleRouterM$mQs;

  TupleRouterM$mStopped = TRUE;
  TupleRouterM$AbsoluteTimer$cancel();
  TupleRouterM$checkTime();


  if (!(TOS_LOCAL_ADDRESS == 0)) {







      TupleRouterM$Leds$set(0);

      TupleRouterM$ChildControl$stop();


      if (TupleRouterM$mQs != NULL && !TupleRouterM$IS_SENDING_MESSAGE() && TupleRouterM$mLastHeard
       <= 10) {
          TupleRouterM$NetControl$stop();
        }

      if (TupleRouterM$IS_SENDING_MESSAGE()) {

          TupleRouterM$outputDone(&TupleRouterM$mMsg);
        }

      if (TupleRouterM$IS_DELIVERING_TUPLES()) {
        TupleRouterM$UNSET_DELIVERING_TUPLES();
        }
    }
  if (TupleRouterM$mLastHeard > 10) {
    TupleRouterM$mLastHeard -= 2;
    }
#line 760
  while (qlh != NULL) {
      (*qlh)->q.clockCount = TupleRouterM$WAKING_CLOCKS;
      qlh = (TupleRouterM$QueryListHandle )(*qlh)->next;
    }




  return SUCCESS;
}

# 164 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/SimpleTimeM.nc"
static  result_t SimpleTimeM$AbsoluteTimer$cancel(uint8_t id)
#line 164
{
  if (id >= MAX_NUM_TIMERS || (SimpleTimeM$aTimer[id].high32 == 0 && SimpleTimeM$aTimer[id].low32 == 0)) {
    return FAIL;
    }
#line 167
  SimpleTimeM$aTimer[id].high32 = 0;
  SimpleTimeM$aTimer[id].low32 = 0;
  return SUCCESS;
}

# 3451 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$checkTime(void)
#line 3451
{




  if (
#line 3454
  TupleRouterM$mAllQueriesSameRate && 

  TupleRouterM$IS_SNOOZING() && 
  TupleRouterM$mQs != NULL) {


      tos_time_t epoch_end;
#line 3460
      tos_time_t mytime = TupleRouterM$Time$get();
      int32_t diff;
#line 3461
      int32_t st;
#line 3461
      int32_t soe;
      ParsedQuery *pq = & (*TupleRouterM$mQs)->q;
      int32_t epochMs = (int32_t )pq->clocksPerSample * TupleRouterM$kMS_PER_CLOCK_EVENT;

#line 3477
      epoch_end = TupleRouterM$ServiceScheduler$getNextEventTime(kTINYDB_SERVICE_ID);
      soe = mytime.low32 - mytime.low32 % epochMs;

      st = soe + TupleRouterM$WAKING_CLOCKS * TupleRouterM$kMS_PER_CLOCK_EVENT;



      diff = st - (int32_t )epoch_end.low32;
      if (abs(diff) > 32) {

          if (abs(diff) > epochMs >> 1) {
              diff = diff < 0 ? diff + epochMs : diff - epochMs;
            }
          TupleRouterM$ServiceScheduler$setExtraSleepTime(kTINYDB_SERVICE_ID, diff);
          if (diff != 0) {
#line 3491
            TupleRouterM$mLastDiff = (int16_t )diff;
            }
        }
    }
}

#line 2461
static result_t TupleRouterM$outputDone(TOS_MsgPtr msg)
#line 2461
{



  if (TupleRouterM$IS_SENDING_MESSAGE()) {
      TupleRouterM$UNSET_SENDING_MESSAGE();



      if (TupleRouterM$IS_SENDING_QUERY()) {
          TupleRouterM$mSendQueryNextClock = TRUE;
        }
    }



  if (TupleRouterM$mRadioWaiting) {
      TupleRouterM$mRadioWaiting = FALSE;
    }

  if (TupleRouterM$mSendingResult) {
      TupleRouterM$mSendingResult = FALSE;
      if (!TupleRouterM$RadioQueue$enqueueDone()) {
        TOS_post(TupleRouterM$deliverTuplesTask);
        }
    }

  return SUCCESS;
}

# 634 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static TinyDBError DBBufferC$continueRadioBufferEnqueue(void)
#line 634
{
  ParsedQuery *pq = DBBufferC$mCurQuery;
  QueryResult *r = DBBufferC$mCurResult;
  int numResults = DBBufferC$QueryResultIntf$numRecords(r, pq);
  QueryResult newqr;
  TinyDBError err = err_NoError;
  bool pending = FALSE;
  ResultTuple rtup;

  DBBufferC$mState = DBBufferC$kRADIO_ENQUEUE;



  if (DBBufferC$mCurResultIdx >= numResults) {
      DBBufferC$mState = DBBufferC$kIDLE;
      return err_NoError;
    }

  rtup = DBBufferC$QueryResultIntf$getResultTuple(r, DBBufferC$mCurResultIdx++, pq);
  if (rtup.error != err_NoError) {
      DBBufferC$mState = DBBufferC$kIDLE;
      return rtup.error;
    }

  err = DBBufferC$QueryResultIntf$fromResultTuple(rtup, &newqr, pq);
  if (err != err_NoError) {
      DBBufferC$mState = DBBufferC$kIDLE;
      return err;
    }


  err = DBBufferC$RadioQueue$enqueue((QueryResultPtr )&newqr, &pending);
  if (err != err_NoError) {
    DBBufferC$mState = DBBufferC$kIDLE;
    }
  if (pending) {
    return err;
    }
  else 
#line 671
    {
      if (err != err_NoError) {
          return err;
        }
      else {
#line 675
        return DBBufferC$continueRadioBufferEnqueue();
        }
    }
}

# 282 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/QueryResult.nc"
static  short QueryResult$QueryResultIntf$numRecords(QueryResultPtr qr, ParsedQueryPtr q)
#line 282
{
  if (qr->qrType == kIS_AGG) {
      return qr->result_idx;
    }
  else {
#line 285
    if (qr->qrType == kAGG_SINGLE_FIELD) {
        return 1;
      }
    else {
#line 287
      if (qr->qrType == kNOT_AGG) {

          return 1;
        }
      else {
#line 291
        return 0;
        }
      }
    }
}

#line 296
static  ResultTuple QueryResult$QueryResultIntf$getResultTuple(QueryResultPtr qr, short i, ParsedQueryPtr q)
#line 296
{
  ResultTuple rf;

  rf.error = err_NoError;


  if (i >= QueryResult$QueryResultIntf$numRecords(qr, q)) {
      rf.error = err_IndexOutOfBounds;
    }

  rf.qid = qr->qid;
  rf.isAgg = qr->qrType == kIS_AGG;
  rf.epoch = qr->epoch;

  if (qr->qrType == kIS_AGG) {
      rf.u.agg.group = qr->d.buf[i].group;
      rf.u.agg.id = i;
      rf.u.agg.len = QueryResult$BUF_SIZE;
      rf.data = qr->d.buf[i].data;
    }
  else {
#line 315
    if (qr->qrType == kAGG_SINGLE_FIELD) {
        rf.u.agg.id = 0;
        rf.u.agg.group = kNO_GROUPING_FIELD;
        rf.u.agg.len = QueryResult$BUF_SIZE;
        rf.data = (char *)qr->d.data;
      }
    else 
#line 320
      {
        rf.u.tupleField = i;
        rf.data = (char *)& qr->d.t;
      }
    }
  return rf;
}

#line 230
static  TinyDBError QueryResult$QueryResultIntf$fromResultTuple(ResultTuple r, QueryResultPtr qr, ParsedQueryPtr pq)
#line 230
{
  qr->qid = r.qid;
  qr->qrType = r.isAgg ? kAGG_SINGLE_FIELD : kNOT_AGG;
  qr->epoch = r.epoch;

  if (r.isAgg) {
      qr->result_idx = r.u.agg.id;
      nmemcpy(qr->d.data, r.data, QueryResult$BUF_SIZE);
    }
  else 
#line 238
    {
      qr->result_idx = 0;
      nmemcpy((char *)& qr->d.t, r.data, QueryResult$TupleIntf$tupleSize(pq));
    }

  return err_NoError;
}

# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/tos.h"
static void *nmemcpy(void *to, const void *from, size_t n)
{
  char *cto = to;
  const char *cfrom = from;

  while (n--) * cto++ = * cfrom++;

  return to;
}

# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static  uint16_t Tuple$TupleIntf$tupleSize(ParsedQueryPtr q)
#line 105
{
  short i;
  short size = sizeof(Tuple );

  for (i = 0; i < q->numFields; i++) {
      size += Tuple$TupleIntf$fieldSize(q, (uint8_t )i);
    }

  return size;
}



static  uint16_t Tuple$TupleIntf$fieldSize(ParsedQueryPtr q, uint8_t fieldNo)
#line 118
{
  if (q->fromCatalogBuffer) {
      uint8_t from_fieldNo = q->queryToSchemaFieldMap[(short )fieldNo];

#line 121
      return Tuple$CatalogTable$catalogFieldSize(q->fromBuffer, from_fieldNo);
    }
  else {
#line 122
    if (q->fromBuffer != kNO_QUERY) {
        int8_t bufferId;
        ParsedQuery *fromq;
        uint8_t from_fieldNo = q->queryToSchemaFieldMap[(short )fieldNo];

        Tuple$DBBuffer$getBufferId(q->fromBuffer, FALSE, &bufferId);
        fromq = *Tuple$DBBuffer$getSchema(bufferId);

        if (fromq == NULL) {



            return 0;
          }

        if (!Tuple$ParsedQueryIntf$queryFieldIsNull(fromq->queryToSchemaFieldMap[(short )from_fieldNo])) {
            if (fromq->queryToSchemaFieldMap[(short )from_fieldNo] == GROUP_FIELD) {
              return Tuple$typeToSize(UINT16);
              }
            else 
#line 140
              {
                AttrDescPtr attr = NULL;

#line 142
                if (Tuple$ParsedQueryIntf$queryFieldIsTyped(fromq->queryToSchemaFieldMap[(short )from_fieldNo])) {
                  }
                else {




                  attr = Tuple$AttrUse$getAttrById(fromq->queryToSchemaFieldMap[(short )from_fieldNo]);
                  }
#line 150
                if (attr != NULL) {
                  return Tuple$typeToSize(attr->type);
                  }
                else {
#line 153
                  return 0;
                  }
              }
          }
        else {
#line 157
          return 0;
          }
      }
    else 
#line 158
      {
        if (!Tuple$ParsedQueryIntf$queryFieldIsNull(q->queryToSchemaFieldMap[(short )fieldNo])) {
            if (Tuple$ParsedQueryIntf$queryFieldIsTyped(q->queryToSchemaFieldMap[(short )fieldNo])) {
                if (q->tableInfo == NULL) {
                  return 0;
                  }
              }
            else 


              {
                AttrDescPtr attr = Tuple$AttrUse$getAttrById(q->queryToSchemaFieldMap[(short )fieldNo]);

#line 170
                if (attr != NULL) {
                  return Tuple$typeToSize(attr->type);
                  }
                else {
#line 173
                  return 0;
                  }
              }
          }
        else {
#line 176
          return 0;
          }
      }
    }
#line 178
  return 0;
}

# 2668 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static TinyDBError DBBufferC$getSpecialBufferId(BufferType type, uint8_t *bufferId)
#line 2668
{
  switch (type) {
      case kRADIO: 
        *bufferId = kRADIO_BUFFER;
      break;
      case kATTRLIST: 
        *bufferId = DBBufferC$kATTR_BUF;
      break;
      case kQUERYLIST: 
        *bufferId = DBBufferC$kQUERY_BUF;
      break;






      default: 
        return err_UnsupportedBuffer;
    }
  return err_NoError;
}

#line 1239
static  TinyDBError DBBufferC$DBBuffer$getBufferId(uint8_t bufIdx, bool special, uint8_t *bufferId)
#line 1239
{
  int i;
  int qid;

  if (special) {
    return DBBufferC$getSpecialBufferId(bufIdx, bufferId);
    }
  qid = bufIdx;

  for (i = 1; i < DBBufferC$kNUM_BUFS; i++) {
      if (DBBufferC$mUsedBufs & (1 << i)) {
          if ((* DBBufferC$mBuffers[i].qh)->qid == qid) {
              *bufferId = i;
              return err_NoError;
            }
        }
    }

  return err_InvalidIndex;
}

#line 1118
static  ParsedQuery **DBBufferC$DBBuffer$getSchema(uint8_t bufferId)
#line 1118
{
  DBBufferC$Buffer *buf;
  TinyDBError err = DBBufferC$getBuf(bufferId, &buf);

#line 1121
  if (err != err_NoError) {
#line 1121
    return NULL;
    }
#line 1122
  return buf->qh;
}

#line 2593
static TinyDBError DBBufferC$getBuf(uint8_t bufId, DBBufferC$Buffer **buf)
#line 2593
{
  if (bufId >= DBBufferC$kNUM_BUFS) {
    return err_IndexOutOfBounds;
    }
#line 2596
  if ((DBBufferC$mUsedBufs & (1 << bufId)) == 0) {
    return err_InvalidIndex;
    }
#line 2598
  *buf = &DBBufferC$mBuffers[bufId];
  return err_NoError;
}

# 149 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static  AttrDescPtr Attr$AttrUse$getAttrById(uint8_t attrIdx)
{
  short numAttrs = Attr$attrDescs.numAttrs;

#line 152
  if (attrIdx >= numAttrs) {
    return NULL;
    }
#line 154
  return &Attr$attrDescs.attrDesc[(short )attrIdx];
}

# 186 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static  void *MultiHopEngineM$Send$getBuffer(uint8_t id, TOS_MsgPtr pMsg, uint16_t *length)
#line 186
{

  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)pMsg->data;

  *length = 89 - (size_t )& ((TOS_MHopMsg *)0)->data;

  return &pMHMsg->data[0];
}

# 533 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static  result_t MultiHopLEPSM$RouteSelect$selectRoute(TOS_MsgPtr Msg, uint8_t id)
#line 533
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)&Msg->data[0];

  uint8_t iNbr;
  bool fIsDuplicate;
  result_t Result = SUCCESS;


  if (MultiHopLEPSM$gpCurrentParent == NULL) {


      if (pMHMsg->sourceaddr == TOS_LOCAL_ADDRESS && 
      pMHMsg->originaddr == TOS_LOCAL_ADDRESS) {
          pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
          pMHMsg->hopcount = MultiHopLEPSM$gbCurrentHopCount;
          pMHMsg->seqno = MultiHopLEPSM$gCurrentSeqNo++;
          Msg->addr = TOS_BCAST_ADDR;
          return SUCCESS;
        }
      else {
          return FAIL;
        }
    }

  if (MultiHopLEPSM$gbCurrentHopCount >= pMHMsg->hopcount) {

      return FAIL;
    }

  if (pMHMsg->sourceaddr == TOS_LOCAL_ADDRESS && 
  pMHMsg->originaddr == TOS_LOCAL_ADDRESS) {
      fIsDuplicate = FALSE;
    }
  else {
      fIsDuplicate = MultiHopLEPSM$updateNbrCounters(pMHMsg->sourceaddr, pMHMsg->seqno, &iNbr);
    }

  if (!fIsDuplicate) {
      pMHMsg->sourceaddr = TOS_LOCAL_ADDRESS;
      pMHMsg->hopcount = MultiHopLEPSM$gbCurrentHopCount;
      if (MultiHopLEPSM$gpCurrentParent->id != TOS_UART_ADDR) {
          pMHMsg->seqno = MultiHopLEPSM$gCurrentSeqNo++;
        }
      Msg->addr = MultiHopLEPSM$gpCurrentParent->id;
    }
  else {
      Result = FAIL;
    }

  return Result;
}

#line 322
static bool MultiHopLEPSM$updateNbrCounters(uint16_t saddr, int16_t seqno, uint8_t *NbrIndex)
#line 322
{
  MultiHopLEPSM$TableEntry *pNbr;
  int16_t sDelta;
  uint8_t iNbr;
  bool Result = FALSE;

  iNbr = MultiHopLEPSM$findPreparedIndex(saddr);
  pNbr = &MultiHopLEPSM$NeighborTbl[iNbr];

  sDelta = seqno - MultiHopLEPSM$NeighborTbl[iNbr].lastSeqno - 1;

  if (pNbr->flags & MultiHopLEPSM$NBRFLAG_NEW) {
      pNbr->received++;
      pNbr->lastSeqno = seqno;
      pNbr->flags ^= MultiHopLEPSM$NBRFLAG_NEW;
    }
  else {
#line 338
    if (sDelta >= 0) {
        pNbr->missed += sDelta;
        pNbr->received++;
        pNbr->lastSeqno = seqno;
      }
    else {
#line 343
      if (sDelta < MultiHopLEPSM$ACCEPTABLE_MISSED) {

          MultiHopLEPSM$newEntry(iNbr, saddr);
          pNbr->received++;
          pNbr->lastSeqno = seqno;
          pNbr->flags ^= MultiHopLEPSM$NBRFLAG_NEW;
        }
      else {
          Result = TRUE;
        }
      }
    }
#line 354
  *NbrIndex = iNbr;
  return Result;
}

#line 203
static void MultiHopLEPSM$newEntry(uint8_t indes, uint16_t id)
#line 203
{
  MultiHopLEPSM$NeighborTbl[indes].id = id;
  MultiHopLEPSM$NeighborTbl[indes].flags = MultiHopLEPSM$NBRFLAG_VALID | MultiHopLEPSM$NBRFLAG_NEW;
  MultiHopLEPSM$NeighborTbl[indes].liveliness = 0;
  MultiHopLEPSM$NeighborTbl[indes].parent = MultiHopLEPSM$ROUTE_INVALID;
  MultiHopLEPSM$NeighborTbl[indes].hop = MultiHopLEPSM$ROUTE_INVALID;
  MultiHopLEPSM$NeighborTbl[indes].missed = 0;
  MultiHopLEPSM$NeighborTbl[indes].received = 0;
  MultiHopLEPSM$NeighborTbl[indes].receiveEst = 0;
  MultiHopLEPSM$NeighborTbl[indes].sendEst = 0;
}

# 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Queue/QueuedSendM.nc"
static  result_t QueuedSendM$QueueSendMsg$send(uint8_t id, uint16_t address, uint8_t length, TOS_MsgPtr msg)
#line 143
{
  {
  }
#line 144
  ;

  if ((QueuedSendM$enqueue_next + 1) % QueuedSendM$MESSAGE_QUEUE_SIZE == QueuedSendM$dequeue_next) {

      {
      }
#line 148
      ;
      return FAIL;
    }

  if (length > 89) {
      {
      }
#line 153
      ;
      return FAIL;
    }

  if (msg == NULL) {
      {
      }
#line 158
      ;
      return FAIL;
    }

  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].address = address;
  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].length = length;
  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].id = id;
  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].pMsg = msg;
  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].xmit_count = 0;
  QueuedSendM$msgqueue[QueuedSendM$enqueue_next].pMsg->ack = 0;

  QueuedSendM$enqueue_next++;
#line 169
  QueuedSendM$enqueue_next %= QueuedSendM$MESSAGE_QUEUE_SIZE;

  {
  }
#line 171
  ;








  if (QueuedSendM$fQueueIdle) {
      QueuedSendM$fQueueIdle = FALSE;
      TOS_post(QueuedSendM$QueueServiceTask);
    }
  return SUCCESS;
}

#line 121
static  void QueuedSendM$QueueServiceTask(void)
#line 121
{
  uint8_t id;

  if (QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg != NULL) {
      QueuedSendM$Leds$greenToggle();
      {
      }
#line 126
      ;
      id = QueuedSendM$msgqueue[QueuedSendM$dequeue_next].id;

      if (!QueuedSendM$SerialSendMsg$send(id, QueuedSendM$msgqueue[QueuedSendM$dequeue_next].address, 
      QueuedSendM$msgqueue[QueuedSendM$dequeue_next].length, 
      QueuedSendM$msgqueue[QueuedSendM$dequeue_next].pMsg)) {

          TOS_post(QueuedSendM$QueueServiceTask);

          {
          }
#line 135
          ;
        }
    }
  else {
      QueuedSendM$fQueueIdle = TRUE;
    }
}

# 158 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static result_t FramerM$StartTx(void)
#line 158
{
  result_t Result = SUCCESS;
  bool fInitiate = FALSE;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 162
    {
      if (FramerM$gTxState == FramerM$TXSTATE_IDLE) {
          if (FramerM$gFlags & FramerM$FLAGS_TOKENPEND) {
              FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxTokenBuf;
              FramerM$gTxProto = FramerM$PROTO_ACK;
              FramerM$gTxLength = sizeof FramerM$gTxTokenBuf;
              fInitiate = TRUE;
              FramerM$gTxState = FramerM$TXSTATE_PROTO;
            }
          else {
#line 171
            if (FramerM$gFlags & FramerM$FLAGS_DATAPEND) {
                FramerM$gpTxBuf = (uint8_t *)FramerM$gpTxMsg;
                FramerM$gTxProto = FramerM$PROTO_PACKET_NOACK;
                FramerM$gTxLength = FramerM$gpTxMsg->length + (MSG_DATA_SIZE - DATA_LENGTH - 2);
                fInitiate = TRUE;
                FramerM$gTxState = FramerM$TXSTATE_PROTO;
              }
            else {
#line 178
              if (FramerM$gFlags & FramerM$FLAGS_UNKNOWN) {
                  FramerM$gpTxBuf = (uint8_t *)&FramerM$gTxUnknownBuf;
                  FramerM$gTxProto = FramerM$PROTO_UNKNOWN;
                  FramerM$gTxLength = sizeof FramerM$gTxUnknownBuf;
                  fInitiate = TRUE;
                  FramerM$gTxState = FramerM$TXSTATE_PROTO;
                }
              }
            }
        }
    }
#line 188
    __nesc_atomic_end(__nesc_atomic); }
#line 188
  if (fInitiate) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 189
        {
          FramerM$gTxRunningCRC = 0;
#line 190
          FramerM$gTxByteCnt = 0;
        }
#line 191
        __nesc_atomic_end(__nesc_atomic); }
      Result = FramerM$ByteComm$txByte(FramerM$HDLC_FLAG_BYTE);
      if (Result != SUCCESS) {
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 194
            FramerM$gTxState = FramerM$TXSTATE_ERROR;
#line 194
            __nesc_atomic_end(__nesc_atomic); }
          TOS_post(FramerM$PacketSent);
        }
    }

  return Result;
}

# 110 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/UARTM.nc"
static   result_t UARTM$ByteComm$txByte(uint8_t data)
#line 110
{
  bool oldState;

  {
  }
#line 113
  ;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 115
    {
      oldState = UARTM$state;
      UARTM$state = TRUE;
    }
#line 118
    __nesc_atomic_end(__nesc_atomic); }
  if (oldState) {
    return FAIL;
    }
  UARTM$HPLUART$put(data);

  return SUCCESS;
}

# 246 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static  void FramerM$PacketSent(void)
#line 246
{
  result_t TxResult = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 249
    {
      if (FramerM$gTxState == FramerM$TXSTATE_ERROR) {
          TxResult = FAIL;
          FramerM$gTxState = FramerM$TXSTATE_IDLE;
        }
    }
#line 254
    __nesc_atomic_end(__nesc_atomic); }
  if (FramerM$gTxProto == FramerM$PROTO_ACK) {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 256
        FramerM$gFlags ^= FramerM$FLAGS_TOKENPEND;
#line 256
        __nesc_atomic_end(__nesc_atomic); }
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 259
        FramerM$gFlags ^= FramerM$FLAGS_DATAPEND;
#line 259
        __nesc_atomic_end(__nesc_atomic); }
      FramerM$BareSendMsg$sendDone((TOS_MsgPtr )FramerM$gpTxMsg, TxResult);
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 261
        FramerM$gpTxMsg = NULL;
#line 261
        __nesc_atomic_end(__nesc_atomic); }
    }


  FramerM$StartTx();
}

# 170 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
static result_t AMPromiscuous$reportSendDone(TOS_MsgPtr msg, result_t success)
#line 170
{
  {
  }
#line 171
  ;
  AMPromiscuous$state = FALSE;
  AMPromiscuous$SendMsg$sendDone(msg->type, msg, success);
  AMPromiscuous$sendDone();

  return SUCCESS;
}

# 248 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static  result_t MultiHopEngineM$SendMsg$sendDone(uint8_t id, TOS_MsgPtr pMsg, result_t success)
#line 248
{

  if (pMsg == MultiHopEngineM$FwdBufList[MultiHopEngineM$iFwdBufTail]) {
      MultiHopEngineM$iFwdBufTail++;
#line 251
      MultiHopEngineM$iFwdBufTail %= MultiHopEngineM$FWD_QUEUE_SIZE;
    }
  else 
#line 252
    {
      MultiHopEngineM$Send$sendDone(id, pMsg, success);
    }
  return SUCCESS;
}

# 90 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static   result_t LedsC$Leds$redToggle(void)
#line 90
{
  result_t rval;

#line 92
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 92
    {
      if (LedsC$ledsOn & LedsC$RED_BIT) {
        rval = LedsC$Leds$redOff();
        }
      else {
#line 96
        rval = LedsC$Leds$redOn();
        }
    }
#line 98
    __nesc_atomic_end(__nesc_atomic); }
#line 98
  return rval;
}

# 143 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
static result_t AMStandard$reportSendDone(TOS_MsgPtr msg, result_t success)
#line 143
{
  AMStandard$state = FALSE;
  AMStandard$SendMsg$sendDone(msg->type, msg, success);
  AMStandard$sendDone();

  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/TimerJiffyAsyncM.nc"
static   result_t TimerJiffyAsyncM$TimerJiffyAsync$setOneShot(uint32_t _jiffy)
{
  TimerJiffyAsyncM$AlarmControl$disableEvents();
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 73
    {
      TimerJiffyAsyncM$jiffy = _jiffy;
      TimerJiffyAsyncM$bSet = TRUE;
    }
#line 76
    __nesc_atomic_end(__nesc_atomic); }
  if (_jiffy > 0xFFFF) {
      TimerJiffyAsyncM$AlarmCompare$setEventFromNow(0xFFFF);
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 81
        {




          if (_jiffy > 2) {
            TimerJiffyAsyncM$AlarmCompare$setEventFromNow(_jiffy);
            }
          else {
#line 89
            TimerJiffyAsyncM$AlarmCompare$setEventFromNow(2);
            }
        }
#line 91
        __nesc_atomic_end(__nesc_atomic); }
    }
#line 92
  TimerJiffyAsyncM$AlarmControl$clearPendingInterrupt();
  TimerJiffyAsyncM$AlarmControl$enableEvents();
  return SUCCESS;
}

# 70 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/RandomLFSR.nc"
static   uint16_t RandomLFSR$Random$rand(void)
#line 70
{
  bool endbit;
  uint16_t tmpShiftReg;

#line 73
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 73
    {
      tmpShiftReg = RandomLFSR$shiftReg;
      endbit = (tmpShiftReg & 0x8000) != 0;
      tmpShiftReg <<= 1;
      if (endbit) {
        tmpShiftReg ^= 0x100b;
        }
#line 79
      tmpShiftReg++;
      RandomLFSR$shiftReg = tmpShiftReg;
      tmpShiftReg = tmpShiftReg ^ RandomLFSR$mask;
    }
#line 82
    __nesc_atomic_end(__nesc_atomic); }
  return tmpShiftReg;
}

# 2318 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  void TupleRouterM$deliverTuplesTask(void)
#line 2318
{
  bool success;
  bool didAgg = FALSE;
  bool pending = FALSE;


  {
  }
#line 2324
  ;
  TupleRouterM$SET_DELIVERING_TUPLES();

  if (TupleRouterM$mCurRouteQuery != NULL) {
      if (!pending) {
#line 2328
        TupleRouterM$resetTupleState(& (*TupleRouterM$mCurRouteQuery)->q);
        }
    }
  TupleRouterM$mCurRouteQuery = TupleRouterM$nextQueryToRoute(TupleRouterM$mCurRouteQuery);

  if (TupleRouterM$mCurRouteQuery != NULL) {

      ParsedQuery *pq = & (*TupleRouterM$mCurRouteQuery)->q;
      Expr *e = TupleRouterM$nextExpr(pq);
      TinyDBError err = err_NoError;
      QueryResult qr;
      uint16_t size;



      success = TOS_LOCAL_ADDRESS == pq->queryRoot ? FALSE : TRUE;



      pq->needsData = FALSE;
      TupleRouterM$QueryResultIntf$initQueryResult(&qr);

      {
      }
#line 2350
      ;
      qr.epoch = pq->currentEpoch;
      qr.qid = pq->qid;




      while (e != NULL) {
          if (e->opType != kSEL) {


              err = TupleRouterM$addResults(&qr, pq, e);


              didAgg = TRUE;
            }
          else {
              if (! e->success) {
#line 2367
                success = FALSE;
                }
            }
#line 2369
          e = TupleRouterM$nextExpr(pq);
        }







      if (didAgg && err == err_NoError && TupleRouterM$QueryResultIntf$numRecords(&qr, pq) > 0) {


          TupleRouterM$mEnqResult = qr;
          TupleRouterM$mWaitIsDummy = FALSE;
          TupleRouterM$Leds$redToggle();
          err = TupleRouterM$sendTuple(pq, &TupleRouterM$mEnqResult, &pending);
        }
      else {
#line 2386
        if (success && !didAgg) {


            TupleRouterM$mEnqResult = qr;

            TupleRouterM$QueryResultIntf$fromTuple(&TupleRouterM$mEnqResult, pq, TupleRouterM$ParsedQueryIntf$getTuplePtr(pq));


            TupleRouterM$mWaitIsDummy = FALSE;

            err = TupleRouterM$sendTuple(pq, &TupleRouterM$mEnqResult, &pending);
          }
        }
#line 2417
      if (pq->fromBuffer != kNO_QUERY && pq->epochDuration == kONE_SHOT) 
        {
          uint8_t fromBuf;

#line 2420
          err = TupleRouterM$DBBuffer$getBufferId(pq->fromBuffer, pq->fromCatalogBuffer, &fromBuf);

          err = TupleRouterM$DBBuffer$size(fromBuf, &size);
          if (err != err_NoError || pq->curResult++ >= size) 
            {


              if (pq->hasEvent) 
                {
                  pq->running = FALSE;
                  pq->curResult = 0;
                }
              else 
                {


                  pq->markedForDeletion = TupleRouterM$EPOCHS_TIL_DELETION;
                }
            }
        }
      else {
        if (pq->hasForClause && pq->numEpochs > 0 && pq->currentEpoch > pq->numEpochs) 
          {


            pq->markedForDeletion = TupleRouterM$EPOCHS_TIL_DELETION;
          }
        }
      if (!pending) {
#line 2448
        TOS_post(TupleRouterM$deliverTuplesTask);
        }
#line 2449
      TupleRouterM$mCurExpr = -1;
    }
  else {
      TupleRouterM$UNSET_DELIVERING_TUPLES();

      {
      }
#line 2454
      ;

      TupleRouterM$startFetchingTuples();
    }
}

# 118 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static  TuplePtr ParsedQuery$ParsedQueryIntf$getTuplePtr(ParsedQueryPtr q)
#line 118
{
  return (Tuple *)&((char *)q)[sizeof(ParsedQuery ) + (q->numFields - 1) * sizeof(char ) + q->numExprs * sizeof(Expr )];
}

#line 105
static  ExprPtr ParsedQuery$ParsedQueryIntf$getExprPtr(ParsedQueryPtr q, uint8_t n)
#line 105
{
  return (Expr *)&((char *)q)[sizeof(ParsedQuery ) + (q->numFields - 1) * sizeof(char ) + n * sizeof(Expr )];
}

# 664 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static void AggOperator$initAggregateValue(AggOperator$GroupRecord *d, Expr *e, bool isFirstTime)
#line 664
{
  ParamVals paramVals;

#line 666
  setParamValues(&paramVals, e);


  d->u.empty = TRUE;

  AggOperator$AggregateUse$init(e->ex.agg.op, d->aggdata, NULL, &paramVals, isFirstTime);
}

# 184 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/Aggregates.h"
static void setParamValues(ParamVals *v, Expr *e)
#line 184
{
  v->numParams = 4;
  v->paramDataPtr[0] = (char *)&e->ex.tagg.args[0];
  v->paramDataPtr[1] = (char *)&e->ex.tagg.args[1];
  v->paramDataPtr[2] = (char *)&e->ex.tagg.args[2];
}

# 2984 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static TupleRouterM$QueryListHandle TupleRouterM$nextQueryToRoute(TupleRouterM$QueryListHandle curQuery)
#line 2984
{
  TupleRouterM$mCurTuple = NULL;
  if (curQuery == NULL) {
      curQuery = TupleRouterM$mQs;
    }
  else {
#line 2989
    curQuery = (TupleRouterM$QueryListHandle )(*curQuery)->next;
    }
  while (curQuery != NULL) {
      if ((*curQuery)->q.clocksPerSample > 0 && (*curQuery)->q.needsData) {
          TupleRouterM$mCurTuple = TupleRouterM$ParsedQueryIntf$getTuplePtr(& (*curQuery)->q);

          break;
        }
      else 
#line 2996
        {
          curQuery = (TupleRouterM$QueryListHandle )(*curQuery)->next;
        }
    }

  return curQuery;
}

#line 3041
static Expr *TupleRouterM$nextExpr(ParsedQuery *q)
#line 3041
{
  if (++TupleRouterM$mCurExpr >= q->numExprs) {
      TupleRouterM$mCurExpr = -1;
      return NULL;
    }
  else 
#line 3045
    {
      Expr *e;

#line 3047
      e = TupleRouterM$ParsedQueryIntf$getExprPtr(q, TupleRouterM$mCurExpr);
      return e;
    }
}

#line 2495
static TinyDBError TupleRouterM$sendTuple(ParsedQuery *pq, QueryResultPtr qr, bool *pending)
#line 2495
{
  TinyDBError err = err_NoError;



  if (pq->clocksPerSample > TupleRouterM$kMIN_SLEEP_CLOCKS_PER_SAMPLE) {
      TupleRouterM$mDeliverWait = TupleRouterM$Random$rand() % TupleRouterM$kMAX_WAIT_CLOCKS + 1;
      *pending = TRUE;
    }
  else 
#line 2503
    {
      err = TupleRouterM$DBBuffer$enqueue(pq->bufferId, qr, pending, pq);




      if (err != err_ResultBufferBusy && err != err_NoError) {
        TupleRouterM$signalError(err, 2510);
        }
    }
  return err;
}

# 464 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static  TinyDBError DBBufferC$DBBuffer$enqueue(uint8_t bufferId, QueryResultPtr r, bool *pending, ParsedQuery *pq)
#line 464
{
  DBBufferC$Buffer *buf;

  TinyDBError err = err_NoError;


  *pending = FALSE;



  switch (bufferId) {
      case kRADIO_BUFFER: {
          if (DBBufferC$mState != DBBufferC$kIDLE) {
#line 476
            return err_ResultBufferBusy;
            }

          DBBufferC$mCurResult = r;
          DBBufferC$mCurQuery = pq;
          DBBufferC$mCurResultIdx = 0;

          err = DBBufferC$continueRadioBufferEnqueue();
          if (DBBufferC$mState != DBBufferC$kIDLE) {
#line 484
            *pending = TRUE;
            }
#line 485
          return err;
        }
      case DBBufferC$kATTR_BUF: 
        case DBBufferC$kEVENT_BUF: 
          case DBBufferC$kCOMMAND_BUF: 
            case DBBufferC$kQUERY_BUF: 
              return err_UnsupportedBuffer;
      default: 
        err = DBBufferC$getBuf(bufferId, &buf);
      if (err != err_NoError) {
#line 494
        return err;
        }
#line 495
      break;
    }

  switch (buf->type) {
#line 619
      default: 
        return err_UnknownError;
    }

  return err_NoError;
}

# 3644 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  void TupleRouterM$signalError(TinyDBError err, int lineNo)
#line 3644
{
  char errStr[sizeof(TOS_Msg )];
  char errNo[10];
#line 3646
  char lineNoStr[10];




  errStr[0] = 0;







  itoa(err, errNo, 10);
  itoa(lineNo, lineNoStr, 10);


  strcat(errStr, "Err: ");
  strcat(errStr, errNo);
  strcat(errStr, "(L:");
  strcat(errStr, lineNoStr);
  strcat(errStr, ")");
  strcat(errStr, "\0");

  TupleRouterM$statusMessage(errStr);
}

# 984 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static  TinyDBError DBBufferC$DBBuffer$size(uint8_t bufferId, uint16_t *size)
#line 984
{
  DBBufferC$Buffer *buf;
  TinyDBError err = err_NoError;

  switch (bufferId) {
      case DBBufferC$kATTR_BUF: 
        *size = DBBufferC$AttrUse$numAttrs();
      return err_NoError;
      default: 
        err = DBBufferC$getBuf(bufferId, &buf);

      if (err != err_NoError) {
#line 995
        return err;
        }

      if (buf->nextFull == buf->nextFree) {
        *size = 0;
        }
      else {
#line 1000
        if (buf->nextFull > buf->nextFree) {
            *size = buf->numRows - buf->nextFull + buf->nextFree;
          }
        else 
#line 1002
          {
            *size = buf->nextFree - buf->nextFull;
          }
        }
#line 1005
      break;
    }
  return err_NoError;
}

# 148 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static   result_t LedsC$Leds$yellowToggle(void)
#line 148
{
  result_t rval;

#line 150
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 150
    {
      if (LedsC$ledsOn & LedsC$YELLOW_BIT) {
        rval = LedsC$Leds$yellowOff();
        }
      else {
#line 154
        rval = LedsC$Leds$yellowOn();
        }
    }
#line 156
    __nesc_atomic_end(__nesc_atomic); }
#line 156
  return rval;
}

# 1291 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  void TupleRouterM$removeQueryTask(void)
#line 1291
{

  TupleRouterM$QueryListHandle curq;
  TupleRouterM$QueryListHandle last = NULL;


  if ((
#line 1296
  !TupleRouterM$mForceRemove && (((TupleRouterM$IS_FETCHING_ATTRIBUTE() || TupleRouterM$IS_ROUTING_TUPLES()) || 
  TupleRouterM$IS_DELIVERING_TUPLES()) || TupleRouterM$IS_SENDING_MESSAGE())) || TupleRouterM$IS_STARTING_ATTRIBUTE()) {
      TupleRouterM$signalError(err_RemoveFailedRouterBusy, 1298);
    }



  curq = TupleRouterM$mQs;
  while (curq != NULL) {
      if ((*curq)->q.qid == TupleRouterM$mQidToRemove) {

          if (TupleRouterM$IS_SENDING_QUERY() && (*TupleRouterM$mCurSendingQuery)->q.qid == (*curq)->q.qid) {
              TupleRouterM$signalError(err_RemoveFailedRouterBusy, 1308);
              return;
            }
          if (last != NULL) {
              (*last)->next = (*curq)->next;
            }
          else 
#line 1313
            {
              { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1314
                {
                  TupleRouterM$mQs = (TupleRouterM$QueryListHandle )(*curq)->next;
                }
#line 1316
                __nesc_atomic_end(__nesc_atomic); }
            }

          if (TupleRouterM$mTail == curq) {
            TupleRouterM$mTail = last;
            }
#line 1321
          if (TupleRouterM$mQs == NULL) {
              TupleRouterM$mIsRunning = FALSE;

              TupleRouterM$UNSET_SNOOZING();


              TupleRouterM$ServiceScheduler$remove(kTINYDB_SERVICE_ID);
              TupleRouterM$AbsoluteTimer$cancel();

              TupleRouterM$mOldRate = 0;

              if (TupleRouterM$mStopped) {
                  TupleRouterM$StdControl$start();
                }

              TupleRouterM$mStopped = TRUE;

              TupleRouterM$Leds$redOff();
              TupleRouterM$Leds$yellowOff();
              TupleRouterM$Leds$greenOff();
            }
#line 1360
          {
          }
#line 1360
          ;
          TupleRouterM$QueryProcessor$queryComplete(& (*curq)->q);



          if (curq == TupleRouterM$mCurRouteQuery) {
            TupleRouterM$mCurRouteQuery = NULL;
            }
#line 1367
          TupleRouterM$MemAlloc$free((Handle )curq);
          return;
        }
      else 
#line 1369
        {
          last = curq;
          curq = (TupleRouterM$QueryListHandle )(*curq)->next;
        }
    }
}

# 105 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/interfaces/pqueue.h"
static pq_element pqueue_remove(pqueue_t *pq, pq_element e)
#line 105
{
  int8_t i;

#line 107
  for (i = 0; i < pq->n_elements; i++) {
      if (pq->heap[i] == e) {
          return pqueue_dequeue_idx(pq, i);
        }
    }
  return -1;
}

# 101 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static  Expr ParsedQuery$ParsedQueryIntf$getExpr(ParsedQueryPtr q, uint8_t n)
#line 101
{
  return * (Expr *)&((char *)q)[sizeof(ParsedQuery ) + (q->numFields - 1) * sizeof(char ) + n * sizeof(Expr )];
}

# 440 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static  int16_t TinyAlloc$MemAlloc$free(Handle hand)
#line 440
{
  int8_t *startPtr;
  int16_t start;
  int16_t end;

  if (TinyAlloc$mAllocing) {
#line 445
    return FAIL;
    }
  if (!TinyAlloc$isValid(hand)) {
#line 447
    return FAIL;
    }

  if (sizeof(int8_t *) == sizeof(int16_t )) {
      startPtr = TinyAlloc$deref(hand) - TinyAlloc$HEADER_SIZE;
      start = (int16_t )(startPtr - (int8_t *)&TinyAlloc$mFrame);
      end = start + TinyAlloc$getSize(TinyAlloc$deref(hand));
    }
  else {
    if (sizeof(int8_t *) == sizeof(int32_t )) {
        startPtr = TinyAlloc$deref(hand) - TinyAlloc$HEADER_SIZE;
        start = (int16_t )(startPtr - (int8_t *)&TinyAlloc$mFrame);
        end = start + TinyAlloc$getSize(TinyAlloc$deref(hand));
      }
    else 
      {
        return FAIL;
      }
    }

  TinyAlloc$mFreeBytes += TinyAlloc$getSize(TinyAlloc$deref(hand));

  TinyAlloc$setFreeBits(start, end, 0);

  TinyAlloc$markHandleFree(hand);

  return end - start;
}

#line 668
static void TinyAlloc$setFreeBits(int16_t startByte, int16_t endByte, int8_t on)
#line 668
{
  int16_t leadInBits = startByte - ((startByte >> 3) << 3);
  int16_t leadOutBits = endByte - ((endByte >> 3) << 3);
  int16_t i;
  int16_t startFree = startByte >> 3;
  int16_t endFree = endByte >> 3;

  {
  }
#line 675
  ;
  if (startFree == endFree) {
      leadInBits = 8;
    }


  if (on) {
      for (i = leadInBits; i < 8; i++) {
          TinyAlloc$mFree[startFree] |= 1 << i;
        }
      for (i = 0; i < leadOutBits; i++) {
          TinyAlloc$mFree[endFree] |= 1 << i;
        }
      startFree++;
      for (i = startFree; i < endFree; i++) {
          TinyAlloc$mFree[i] = 0xFF;
        }
    }
  else 
#line 692
    {
      for (i = leadInBits; i < 8; i++) {
          TinyAlloc$mFree[startFree] &= 0xFF ^ (1 << i);
        }
      for (i = 0; i < leadOutBits; i++) {
          TinyAlloc$mFree[endFree] &= 0xFF ^ (1 << i);
        }
      startFree++;
      for (i = startFree; i < endFree; i++) {
          TinyAlloc$mFree[i] = 0x00;
        }
    }
}

#line 650
static void TinyAlloc$markHandleFree(Handle hand)
#line 650
{
  int i;

#line 652
  for (i = 0; i < TinyAlloc$MAX_HANDLES; i++) {
      if (&TinyAlloc$mHandles[i] == hand) {





          TinyAlloc$mHandles[i] = 0;
          break;
        }
    }
}

# 2607 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static void DBBufferC$cleanupBuffer(int b, int lineNo)
#line 2607
{

  DBBufferC$Buffer *buf = &DBBufferC$mBuffers[b];

  {
  }
#line 2611
  ;










  DBBufferC$mUsedBufs &= 0xFFFFFFFF ^ (1 << b);
#line 2653
  if (buf->qh != NULL) {
      DBBufferC$MemAlloc$free((Handle )buf->qh);
    }

  if (buf->name != NULL) {
      DBBufferC$MemAlloc$free((Handle )buf->name);
    }
}

# 2706 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static bool TupleRouterM$fetchNextAttr(void)
#line 2706
{
  AttrDescPtr queryField;
  TupleRouterM$TupleFieldDesc fieldDesc;
  SchemaErrorNo errorNo;
  ParsedQuery *q;
  short i;
#line 2711
  short fieldId = -1;
  bool pending;
  TinyDBError tdberr;
  uint8_t bufId;

  {
  }
#line 2716
  ;


  fieldDesc = TupleRouterM$getNextQueryField(&q);
  if (fieldDesc.isNull == FALSE) {



      if (q->fromBuffer != kNO_QUERY) {
          TupleRouterM$mCurTupleIdx = fieldDesc.u.tupleIdx;

          if (TupleRouterM$mLastQuery == NULL || TupleRouterM$mLastQuery != q) {
              TupleRouterM$mLastQuery = q;


              tdberr = TupleRouterM$DBBuffer$getBufferId(q->fromBuffer, q->fromCatalogBuffer, &bufId);
              if (tdberr != err_NoError) {
                  TupleRouterM$signalError(tdberr, 2733);
                  return FALSE;
                }
              if (q->epochDuration == kONE_SHOT) {
                  tdberr = TupleRouterM$DBBuffer$getResult(bufId, q->curResult, &TupleRouterM$mResult, &pending);
                }
              else 
#line 2738
                {

                  tdberr = TupleRouterM$DBBuffer$peek(bufId, &TupleRouterM$mResult, &pending);
                }
              if (tdberr == err_ResultBufferBusy) {
                  TupleRouterM$signalError(tdberr, 2743);
                  return TRUE;
                }
              if (tdberr != err_NoError) {
                  TupleRouterM$signalError(tdberr, 2747);
                  return FALSE;
                }

              if (!pending) {
#line 2751
                TOS_post(TupleRouterM$fillInTask);
                }
            }
          else 
#line 2753
            {
              TOS_post(TupleRouterM$fillInTask);
            }
          return TRUE;
        }
      else {
#line 2757
        if (q->fromBuffer == kNO_QUERY) {

            queryField = fieldDesc.u.attr;
            TupleRouterM$mFetchingFieldId = queryField->idx;







            TupleRouterM$SET_FETCHING_ATTRIBUTE();

            TupleRouterM$mLastQuery = q;

            for (i = 0; i < q->numFields; i++) {
                if (q->queryToSchemaFieldMap[i] == queryField->idx) {
                  fieldId = i;
                  }
              }
#line 2776
            if (fieldId != -1) {

                TupleRouterM$mResultBuf = TupleRouterM$TupleIntf$getFieldPtr(q, TupleRouterM$ParsedQueryIntf$getTuplePtr(q), fieldId);

                if (
#line 2779
                TupleRouterM$AttrUse$getAttrValue(queryField->name, TupleRouterM$mResultBuf, 
                &errorNo) == SUCCESS) {
                    if (errorNo != SCHEMA_RESULT_PENDING) {

                        TOS_post(TupleRouterM$fillInTask);
                      }
                    if (errorNo != SCHEMA_ERROR) {
                      return TRUE;
                      }
                  }
              }
          }
        }
    }
  else 
#line 2791
    {
    }


  TupleRouterM$mLastQuery = NULL;
  return FALSE;
}

# 284 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static  TinyDBError Tuple$TupleIntf$getNextEmptyFieldIdx(ParsedQueryPtr q, TuplePtr t, uint8_t *fieldIdx)
#line 284
{
  short i;

  for (i = 0; i < q->numFields; i++) {
      if (!Tuple$ParsedQueryIntf$queryFieldIsNull(q->queryToSchemaFieldMap[i]) && (
      t->notNull & (1 << i)) == 0) {
          *fieldIdx = i;
          return err_NoError;
        }
    }
  return err_NoMoreResults;
}

#line 231
static  CharPtr Tuple$TupleIntf$getFieldPtrNoQuery(TuplePtr t, 
uint8_t fieldIdx, 
uint8_t numFields, 
uint8_t sizes[], 
uint8_t types[])
#line 235
{
  short i;
  short offset = 0;

#line 238
  for (i = 0; i < fieldIdx; i++) {
      offset += Tuple$typeToSize(types[i]);
    }
  return (char *)&t->fields[offset];
}

# 2870 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$fillInAttrVal(SchemaErrorNo errorNo)
{
  ParsedQuery *pq = TupleRouterM$mLastQuery;
  char *resultBuf;
  TinyDBError err;

  if (pq->fromBuffer == kNO_QUERY) {
      short id = TupleRouterM$mFetchingFieldId;
      short i;
      TupleRouterM$QueryListHandle qlh = TupleRouterM$mQs;

      resultBuf = TupleRouterM$mResultBuf;



      while (qlh != NULL) {
          ParsedQuery *q = & (*qlh)->q;

#line 2887
          if (q->clocksPerSample > 0 && q->needsData && 
          q->fromBuffer == kNO_QUERY) {
              Tuple *t = TupleRouterM$ParsedQueryIntf$getTuplePtr(q);

#line 2890
              for (i = 0; i < q->numFields; i++) {
                  if (q->queryToSchemaFieldMap[i] == id) {
                      TupleRouterM$TupleIntf$setField(q, t, i, resultBuf);
                    }
                }
            }


          qlh = (TupleRouterM$QueryListHandle )(*qlh)->next;
        }
    }
  else {
      Tuple *t = TupleRouterM$ParsedQueryIntf$getTuplePtr(pq);
      uint8_t bufId;

      resultBuf = TupleRouterM$TupleIntf$getFieldPtr(pq, t, TupleRouterM$mCurTupleIdx);

      if (resultBuf == NULL) {


          return;
        }
      err = TupleRouterM$DBBuffer$getBufferId(pq->fromBuffer, pq->fromCatalogBuffer, &bufId);
      if (err != err_NoError) {
          TupleRouterM$signalError(err, 2914);
          return;
        }

      err = TupleRouterM$DBBuffer$getField(bufId, 
      &TupleRouterM$mResult, 
      pq->queryToSchemaFieldMap[TupleRouterM$mCurTupleIdx], 
      resultBuf);
      if (err != err_NoError) {
          TupleRouterM$signalError(err, 2923);
          return;
        }


      TupleRouterM$TupleIntf$setField(pq, t, TupleRouterM$mCurTupleIdx, resultBuf);
    }

  TupleRouterM$keepRouting();
}

# 182 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Tuple.nc"
static  result_t Tuple$TupleIntf$setField(ParsedQueryPtr q, TuplePtr t, uint8_t fieldIdx, CharPtr data)
#line 182
{
  char *dest = Tuple$TupleIntf$getFieldPtr(q, t, fieldIdx);

#line 184
  if (dest == NULL) {
#line 184
    return FAIL;
    }
#line 185
  if (dest != data) {
    nmemcpy(dest, data, Tuple$TupleIntf$fieldSize(q, fieldIdx));
    }
#line 187
  t->notNull |= 1 << fieldIdx;
  return SUCCESS;
}

#line 214
static  CharPtr Tuple$TupleIntf$getFieldPtr(ParsedQueryPtr q, TuplePtr t, uint8_t fieldIdx)
#line 214
{
  short i;
  short offset = 0;


  if (Tuple$TupleIntf$fieldSize(q, fieldIdx) == 0) {
#line 219
    return NULL;
    }
#line 220
  for (i = 0; i < fieldIdx; i++) {
      offset += Tuple$TupleIntf$fieldSize(q, i);
    }
  return (char *)&t->fields[offset];
}

# 2965 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  void TupleRouterM$routeTask(void)
#line 2965
{
  if (TupleRouterM$mCurRouteQuery != NULL) {
      ParsedQuery *q = & (*TupleRouterM$mCurRouteQuery)->q;

#line 2968
      if (!TupleRouterM$routeToQuery(q, TupleRouterM$mCurTuple)) {

          TupleRouterM$mCurRouteQuery = TupleRouterM$nextQueryToRoute(TupleRouterM$mCurRouteQuery);
          TOS_post(TupleRouterM$routeTask);
        }
    }
  else 
#line 2973
    {

      TupleRouterM$UNSET_ROUTING_TUPLES();
    }
}

# 529 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static void AggOperator$getGroupData(ParsedQuery *pq, short groupNo, Expr *e, AggOperator$GroupDataCallback callback)
#line 529
{
  AggOperator$GroupDataHandle dh = (AggOperator$GroupDataHandle )e->opState;

  AggOperator$mCallback = callback;

  AggOperator$mCurExpr = e;
  AggOperator$mCurQuery = pq;
  AggOperator$mCurGroup = groupNo;
  {
  }
#line 537
  ;
  if (dh == NULL) {

      AggOperator$mAlloced = (Handle )& e->opState;
      if (AggOperator$MemAlloc$allocate((HandlePtr )& e->opState, AggOperator$groupSize(e) + sizeof(AggOperator$GroupData )) == FAIL) 
        {
          AggOperator$MemAlloc$allocComplete((Handle *)& e->opState, FALSE);
        }
    }
  else 
#line 545
    {
      AggOperator$GroupRecord *gr;


      gr = AggOperator$findGroup(dh, groupNo);
      AggOperator$mGroupRecord = gr;

      if (gr != NULL) {
#line 552
        (*callback)(gr);
        }
      else 
#line 553
        {

          AggOperator$mAlloced = (Handle )e->opState;

          if (AggOperator$MemAlloc$reallocate((Handle )e->opState, AggOperator$groupSize(e) * ((*dh)->numGroups + 1) + sizeof(AggOperator$GroupData )) == FAIL) 
            {
              AggOperator$MemAlloc$reallocComplete((Handle )e->opState, FALSE);
            }
        }
    }
}

# 180 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static  result_t TinyAlloc$MemAlloc$allocate(HandlePtr handlePtr, int16_t size)
#line 180
{
  if (size > TinyAlloc$MAX_SIZE || TinyAlloc$mAllocing) {

      return FAIL;
    }
  TinyAlloc$mAllocing = 1;
  TinyAlloc$mSize = size + TinyAlloc$HEADER_SIZE;
  TinyAlloc$mHandle = handlePtr;
  TinyAlloc$mCompacted = 0;
  TinyAlloc$mNeedFree = 0;
  TinyAlloc$mContig = 0;
  TinyAlloc$mLast = 0;
  TinyAlloc$mStartByte = 0;
  TinyAlloc$mFreeBytes -= TinyAlloc$mSize;
  TOS_post(TinyAlloc$allocTask);
  return SUCCESS;
}

static  void TinyAlloc$allocTask(void)
#line 198
{
  int16_t endByte;
  int16_t i;
#line 200
  int16_t j;

  i = TinyAlloc$mLast++;
  if (i == TinyAlloc$FREE_SIZE) {
      if (TinyAlloc$mCompacted) {

          TinyAlloc$mAllocing = 0;
          if (TinyAlloc$mReallocing) {
              TinyAlloc$finish_realloc(TinyAlloc$mHandle, 0);
            }
          else {
              TinyAlloc$MemAlloc$allocComplete(TinyAlloc$mHandle, FAIL);
            }
        }
      else {
          TinyAlloc$mCompacted = 1;


          TOS_post(TinyAlloc$compactTask);
        }
      return;
    }

  if (TinyAlloc$mNeedFree && TinyAlloc$mFree[i] != 0xFF) {
      TinyAlloc$mStartByte = i << 3;
      for (j = 0; j < 8; j++) {
          if (TinyAlloc$mFree[i] & (1 << j)) {
              if (TinyAlloc$mContig >= TinyAlloc$mSize) {

                  endByte = TinyAlloc$mStartByte + TinyAlloc$mSize;
                  TinyAlloc$doAlloc(TinyAlloc$mStartByte, endByte);
                  return;
                }
              else {
                  TinyAlloc$mStartByte += TinyAlloc$mContig + 1;
                  TinyAlloc$mContig = 0;
                }
            }
          else {
              TinyAlloc$mContig++;
            }
        }

      if (TinyAlloc$mContig >= TinyAlloc$mSize) {
          endByte = TinyAlloc$mStartByte + TinyAlloc$mSize;
          TinyAlloc$doAlloc(TinyAlloc$mStartByte, endByte);

          return;
        }
      else {

          TinyAlloc$mNeedFree = 0;
        }
    }
  else {
#line 254
    if (TinyAlloc$mNeedFree == 0) {


        if (TinyAlloc$mFree[i] == 0) {
            TinyAlloc$mContig += 8;
          }
        else {
            for (j = 0; j < 8; j++) {
                if ((TinyAlloc$mFree[i] & (1 << j)) == 0) {
                    TinyAlloc$mContig++;
                  }
                else {
                    break;
                  }
              }
          }
        if (TinyAlloc$mContig >= TinyAlloc$mSize) {
            endByte = TinyAlloc$mStartByte + TinyAlloc$mSize;
            TinyAlloc$doAlloc(TinyAlloc$mStartByte, endByte);

            return;
          }
        else {
#line 276
          if (TinyAlloc$mFree[i] != 0) {
              TinyAlloc$mContig = 0;
              TinyAlloc$mNeedFree = 1;
              TinyAlloc$mLast--;
            }
          }
      }
    }
#line 282
  TOS_post(TinyAlloc$allocTask);
}

#line 524
static int8_t TinyAlloc$finish_realloc(Handle *hand, int8_t success)
#line 524
{


  if (success) {
      int8_t *p = * *hand;
      int8_t *q = *TinyAlloc$mOldHandle;
      int16_t cnt = TinyAlloc$getSize(*TinyAlloc$mOldHandle);

      while (cnt--) {
          * p++ = * q++;
        }

      TinyAlloc$setFreeBits(TinyAlloc$start_offset(*TinyAlloc$mOldHandle), 
      TinyAlloc$start_offset(*TinyAlloc$mOldHandle) + TinyAlloc$getSize(*TinyAlloc$mOldHandle), 0);

      TinyAlloc$remapAddr(*TinyAlloc$mOldHandle, * *hand);



      TinyAlloc$markHandleFree(*hand);

      TinyAlloc$mReallocing = 0;
      TinyAlloc$MemAlloc$reallocComplete(TinyAlloc$mOldHandle, SUCCESS);
    }
  else {
      TinyAlloc$mReallocing = 0;
      TinyAlloc$MemAlloc$reallocComplete(TinyAlloc$mOldHandle, FAIL);
      return FAIL;
    }
  return SUCCESS;
}

#line 617
static void TinyAlloc$remapAddr(int8_t *oldAddr, int8_t *newAddr)
#line 617
{
  int16_t i;

#line 619
  for (i = 0; i < TinyAlloc$MAX_HANDLES; i++) {
      if (TinyAlloc$mHandles[i] == oldAddr) {
          TinyAlloc$mHandles[i] = newAddr;
        }
    }
}

# 407 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static  result_t AggOperator$MemAlloc$reallocComplete(Handle h, uint8_t success)
#line 407
{
  AggOperator$GroupRecord *newGroup;


  if (h != (Handle )AggOperator$mAlloced) {
#line 411
    return SUCCESS;
    }
#line 412
  AggOperator$mAlloced = NULL;
  {
  }
#line 413
  ;
  if (!success) {
      if (!AggOperator$removeEmptyGroup((AggOperator$GroupDataHandle )h)) {

          {
          }
#line 417
          ;
          AggOperator$signalError(err_OutOfMemory, 418);
        }
    }


  newGroup = AggOperator$addGroup((AggOperator$GroupDataHandle )h, AggOperator$mCurGroup);
  AggOperator$initAggregateValue(newGroup, AggOperator$mCurExpr, TRUE);
  (*AggOperator$mCallback)(newGroup);
  return SUCCESS;
}

#line 166
static void AggOperator$SET_GROUP_DATA(AggOperator$GroupDataHandle dHan, uint8_t n, char *dataptr)
#line 166
{
  nmemcpy(AggOperator$GET_GROUP_DATA(dHan, n), (const char *)dataptr, (*dHan)->groupSize);
}

#line 489
static AggOperator$GroupRecord *AggOperator$addGroup(AggOperator$GroupDataHandle dh, short groupNum)
#line 489
{
  short i;
  bool shift = FALSE;
#line 491
  bool first = FALSE;
  AggOperator$GroupRecord *gr;
#line 492
  AggOperator$GroupRecord lastgr;
#line 492
  AggOperator$GroupRecord newgr;
#line 492
  AggOperator$GroupRecord tempgr;
#line 492
  AggOperator$GroupRecord *ret = NULL;

  newgr.groupNo = groupNum;


  (*dh)->numGroups++;

  for (i = 0; i < (*dh)->numGroups; i++) {

      gr = AggOperator$GET_GROUP_DATA(dh, i);


      if (!shift && (gr->groupNo > groupNum || i + 1 == (*dh)->numGroups)) {
          lastgr = newgr;
          shift = TRUE;
          first = TRUE;
        }

      if (shift) {
          tempgr = *gr;
          AggOperator$SET_GROUP_DATA(dh, i, (char *)&lastgr);
          lastgr = tempgr;
          if (first) {
              first = FALSE;
              ret = AggOperator$GET_GROUP_DATA(dh, i);
            }
        }
    }

  if (ret == NULL) {
      {
      }
#line 522
      ;
    }
  return ret;
}

# 3551 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  result_t TupleRouterM$MemAlloc$reallocComplete(Handle handle, result_t complete)
#line 3551
{


  if (TupleRouterM$mAllocState == TupleRouterM$STATE_NOT_ALLOCING) {
#line 3554
    return SUCCESS;
    }
#line 3555
  if (TupleRouterM$mAllocState == TupleRouterM$STATE_RESIZE_QUERY) {
      TupleRouterM$mAllocState = TupleRouterM$STATE_NOT_ALLOCING;





      TupleRouterM$mTmpHandle = handle;
      if (complete) {
        (*TupleRouterM$mAllocCallback)(&TupleRouterM$mTmpHandle);
        }
      else {
#line 3566
        TupleRouterM$signalError(err_OutOfMemory, 3566);
        }
    }
  else {
#line 3569
    TupleRouterM$signalError(err_UnknownAllocationState, 3569);
    }
#line 3570
  return SUCCESS;
}

# 2374 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/DBBufferC.nc"
static  result_t DBBufferC$MemAlloc$reallocComplete(Handle handle, result_t success)
#line 2374
{
  if (DBBufferC$mState != DBBufferC$kIDLE && handle == DBBufferC$mCurRowHandle) {
    return DBBufferC$MemAlloc$allocComplete(&DBBufferC$mCurRowHandle, success);
    }
  else {
#line 2378
    return SUCCESS;
    }
}

#line 2191
static  result_t DBBufferC$MemAlloc$allocComplete(HandlePtr handle, result_t success)
#line 2191
{
  Handle *bufList;



  if (DBBufferC$mState == DBBufferC$kIDLE || DBBufferC$mState == DBBufferC$kREAD_ROW) {
    return SUCCESS;
    }


  if (success) {
      switch (DBBufferC$mState) {
          case DBBufferC$kALLOC_SCHEMA: 

            nmemcpy(* *handle, (char *)DBBufferC$mAllocSchema, DBBufferC$ParsedQueryIntf$pqSize(DBBufferC$mAllocSchema));

          DBBufferC$mState = DBBufferC$kALLOC_BUFFER;
          switch (DBBufferC$mBuffers[DBBufferC$mCurBuffer].type) {
#line 2246
              default: 

                break;
            }
          break;
#line 2273
          case DBBufferC$kALLOC_BUFFER: 

            nmemset(* *handle, 0, DBBufferC$mBuffers[DBBufferC$mCurBuffer].len);
          if (DBBufferC$mNamePtr != NULL) {
              DBBufferC$mState = DBBufferC$kALLOC_NAME;
              if (DBBufferC$MemAlloc$allocate((HandlePtr )& DBBufferC$mBuffers[DBBufferC$mCurBuffer].name, strlen(DBBufferC$mNamePtr) + 1) == FAIL) {
                  DBBufferC$mState = DBBufferC$kIDLE;
                  DBBufferC$cleanupBuffer(DBBufferC$mCurBuffer, 2280);
                  DBBufferC$DBBuffer$allocComplete(DBBufferC$mCurBuffer, err_UnknownError);
                }
            }
          else 
#line 2283
            {
              DBBufferC$mState = DBBufferC$kIDLE;



              DBBufferC$mUsedBufs |= 1 << DBBufferC$mCurBuffer;
              DBBufferC$DBBuffer$allocComplete(DBBufferC$mCurBuffer, err_NoError);
            }
          break;
          case DBBufferC$kALLOC_NAME: 
            DBBufferC$mUsedBufs |= 1 << DBBufferC$mCurBuffer;
          strcpy(* DBBufferC$mBuffers[DBBufferC$mCurBuffer].name, DBBufferC$mNamePtr);
          DBBufferC$mState = DBBufferC$kIDLE;






          DBBufferC$DBBuffer$allocComplete(DBBufferC$mCurBuffer, err_NoError);
          break;
          case DBBufferC$kALLOC_ROW: {

              DBBufferC$Buffer *buf = &DBBufferC$mBuffers[DBBufferC$mCurBuffer];

#line 2307
              bufList = (Handle *)* buf->u.bufdata;
              bufList[DBBufferC$mCurRow] = *handle;
              DBBufferC$MemAlloc$lock(*handle);
              DBBufferC$QueryResultIntf$toBytes(DBBufferC$mCurResult, * buf->qh, (char *)* *handle);
              DBBufferC$MemAlloc$unlock(*handle);
              DBBufferC$mState = DBBufferC$kIDLE;





              DBBufferC$DBBuffer$putComplete(DBBufferC$mCurBuffer, DBBufferC$mCurResult, err_NoError);
            }
          break;
#line 2334
          default: 
            break;
        }
    }
  else 
#line 2337
    {

      switch (DBBufferC$mState) {
          case DBBufferC$kALLOC_BUFFER: 
            case DBBufferC$kALLOC_SCHEMA: 
              case DBBufferC$kALLOC_NAME: 
                DBBufferC$cleanupBuffer(DBBufferC$mCurBuffer, 2343);
          DBBufferC$DBBuffer$allocComplete(DBBufferC$mCurBuffer, err_UnknownError);
          break;
          case DBBufferC$kALLOC_ROW: 


            DBBufferC$cleanupBuffer(DBBufferC$mCurBuffer, 2349);
          DBBufferC$DBBuffer$putComplete(DBBufferC$mCurBuffer, DBBufferC$mCurResult, err_UnknownError);
          break;
          case DBBufferC$kALLOC_FOR_READ: 
            DBBufferC$DBBuffer$getComplete(DBBufferC$mCurBuffer, DBBufferC$mCurResult, err_OutOfMemory);
          break;






          default: 
            break;
        }
      DBBufferC$mState = DBBufferC$kIDLE;
    }

  return SUCCESS;
}

# 1262 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$finishedOpeningWriteBuffer(ParsedQuery *pq)
#line 1262
{

  {
  }
#line 1264
  ;

  if (!TupleRouterM$ParsedQueryIntf$typeCheck(*TupleRouterM$DBBuffer$getSchema(pq->bufferId), pq)) {

      goto fail;
    }
  else 
#line 1269
    {
    }

  {
  }
#line 1272
  ;

  TupleRouterM$finishedBufferSetup(pq);

  return;
  fail: 
    TupleRouterM$failedOpeningWriteBuffer(pq);
  return;
}

# 296 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ParsedQuery.nc"
static  result_t ParsedQuery$ParsedQueryIntf$getFieldType(ParsedQuery *pq, uint8_t fieldIdx, 
uint8_t *type)
#line 297
{
  AttrDescPtr attr;

  if (fieldIdx >= pq->numFields || 
  ParsedQuery$ParsedQueryIntf$queryFieldIsNull(pq->queryToSchemaFieldMap[fieldIdx])) {
#line 301
    return FAIL;
    }










  if (pq->fromBuffer != kNO_QUERY) {
      uint8_t bufId;
      uint8_t fid = pq->queryToSchemaFieldMap[fieldIdx];


      TinyDBError err = ParsedQuery$DBBuffer$getBufferId(pq->fromBuffer, 
      pq->fromCatalogBuffer, 
      &bufId);
      ParsedQuery **fromSchema;

#line 322
      if (err != err_NoError) {
#line 322
        return FAIL;
        }
#line 323
      fromSchema = ParsedQuery$DBBuffer$getSchema(bufId);
      if (ParsedQuery$ParsedQueryIntf$queryFieldIsNull((*fromSchema)->queryToSchemaFieldMap[fid])) {
#line 324
        return FAIL;
        }

      attr = ParsedQuery$AttrUse$getAttrById((*fromSchema)->queryToSchemaFieldMap[fid]);
    }
  else {
      attr = ParsedQuery$AttrUse$getAttrById(pq->queryToSchemaFieldMap[fieldIdx]);
    }
  if (attr != NULL) {
      *type = attr->type;
      return SUCCESS;
    }
  else {
#line 336
    return FAIL;
    }
}

# 1057 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$finishedBufferSetup(ParsedQuery *pq)
#line 1057
{
  TupleRouterM$SET_STARTING_ATTRIBUTE();
  TupleRouterM$mNumAttrs += pq->numFields;
  TupleRouterM$startQueryAttrs(pq);
  TupleRouterM$setSampleRate();

  TupleRouterM$UNSET_READING_QUERY();
  TupleRouterM$UNSET_PARSING_QUERY();
}

#line 528
static void TupleRouterM$startQueryAttrs(ParsedQuery *pq)
{
  short i;

#line 531
  for (i = 0; i < pq->numFields; i++) 
    {
      if (TupleRouterM$AttrUse$startAttr(pq->queryToSchemaFieldMap[i]) == FAIL) {
        TupleRouterM$mNumAttrs--;
        }
    }
}

#line 2111
static  result_t TupleRouterM$AbsoluteTimer$fired(void)
#line 2111
{

  if (TupleRouterM$mIsRunning) {



      if (
#line 2116
      TupleRouterM$mAllQueriesSameRate && 
      !TupleRouterM$IS_SNOOZING() && 
      TupleRouterM$mQs != NULL) {
          result_t r;

          ParsedQueryPtr pq = & (*TupleRouterM$mQs)->q;
          tos_time_t t = TupleRouterM$Time$get();
          tos_service_schedule sched;
          short sleepClocks = pq->clocksPerSample;



          if (pq->clocksPerSample <= TupleRouterM$WAKING_CLOCKS) {
              TupleRouterM$mStopped = FALSE;
              goto dontSleep;
            }



          t.low32 += (int32_t )pq->clocksPerSample * TupleRouterM$kMS_PER_CLOCK_EVENT - t.low32 % ((int32_t )pq->clocksPerSample * TupleRouterM$kMS_PER_CLOCK_EVENT);

          sched.start_time = t;
          sched.on_time = ((uint32_t )TupleRouterM$WAKING_CLOCKS + 1) * (uint32_t )TupleRouterM$mOldRate;
          sched.off_time = ((uint32_t )sleepClocks - ((uint32_t )TupleRouterM$WAKING_CLOCKS + 1)) * (uint32_t )TupleRouterM$mOldRate;

          TupleRouterM$SET_SNOOZING();
          r = TupleRouterM$ServiceScheduler$reschedule(kTINYDB_SERVICE_ID, sched);
        }
      else 






        {

          dontSleep: 

            if (!TupleRouterM$mStopped) {

                tos_time_t cur_time = TupleRouterM$Time$get();
                uint32_t rateUs = (uint32_t )TupleRouterM$mOldRate;


                cur_time.low32 -= cur_time.low32 % rateUs;
                cur_time.low32 += rateUs;
                { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 2163
                  {
                    TupleRouterM$AbsoluteTimer$set(cur_time);
                  }
#line 2165
                  __nesc_atomic_end(__nesc_atomic); }
                TupleRouterM$decrementQueryCounter();
                TOS_post(TupleRouterM$mainTask);
              }
        }
    }


  return SUCCESS;
}

#line 3059
static bool TupleRouterM$getQuery(uint8_t qid, ParsedQuery **q)
#line 3059
{
  TupleRouterM$QueryListHandle curq;

  curq = TupleRouterM$mQs;
  while (curq != NULL) {
      if ((*curq)->q.qid == qid) {
          *q = & (*curq)->q;
          return TRUE;
        }
      else {
#line 3068
        curq = (TupleRouterM$QueryListHandle )(*curq)->next;
        }
    }
#line 3070
  *q = NULL;
  return FALSE;
}

#line 1379
static  void TupleRouterM$sendQuery(void)
#line 1379
{



  TupleRouterM$QueryListHandle curq = TupleRouterM$mCurSendingQuery;
  QueryMessage *qmsg = TupleRouterM$Network$getQueryPayLoad(&TupleRouterM$mQmsg);

  if (curq == NULL) {
      TupleRouterM$UNSET_SENDING_QUERY();
      return;
    }



  if ((*curq)->q.fromBuffer != kNO_QUERY) {
      TupleRouterM$UNSET_SENDING_QUERY();
      return;
    }


  while (TupleRouterM$mCurSendingField < (*curq)->q.numFields && 
  TupleRouterM$mCurQMsgMask & (1 << TupleRouterM$mCurSendingField)) 
    TupleRouterM$mCurSendingField++;
  if (TupleRouterM$mCurSendingField < (*curq)->q.numFields) {
      char fieldId = TupleRouterM$ParsedQueryIntf$getFieldId(& (*curq)->q, (short )TupleRouterM$mCurSendingField);

      qmsg->msgType = ADD_MSG;
      qmsg->qid = (*curq)->q.qid;

      qmsg->numFields = (*curq)->q.numFields;
      qmsg->numExprs = (*curq)->q.numExprs;
      qmsg->fromBuffer = (*curq)->q.fromBuffer;
      qmsg->fromCatalogBuffer = (*curq)->q.fromCatalogBuffer;
      qmsg->hasForClause = (*curq)->q.hasForClause;
      qmsg->epochDuration = (*curq)->q.epochDuration;
      qmsg->bufferType = (*curq)->q.bufferType;
      qmsg->fwdNode = TOS_LOCAL_ADDRESS;

      TupleRouterM$mCurSendingField++;
      if (!TupleRouterM$ParsedQueryIntf$queryFieldIsNull(fieldId)) {
          AttrDescPtr attr = TupleRouterM$AttrUse$getAttrById(fieldId);

          qmsg->type = kFIELD;
          qmsg->idx = TupleRouterM$mCurSendingField - 1;
          strcpy(qmsg->u.field.name, attr->name);

          TupleRouterM$Leds$greenToggle();

          if (!TupleRouterM$IS_SENDING_MESSAGE()) {
              TupleRouterM$SET_SENDING_MESSAGE();

              { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1430
                {
                  TupleRouterM$mMustTimestamp = TupleRouterM$TS_QUERY_MESSAGE;
                  TupleRouterM$mTimestampMsg = &TupleRouterM$mQmsg;
                }
#line 1433
                __nesc_atomic_end(__nesc_atomic); }
              if (TupleRouterM$Network$sendQueryMessage(&TupleRouterM$mQmsg) != err_NoError) {
                  TupleRouterM$UNSET_SENDING_MESSAGE();
                  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1436
                    {
                      TupleRouterM$mMustTimestamp = TupleRouterM$TS_NO;
                    }
#line 1438
                    __nesc_atomic_end(__nesc_atomic); }
                }
            }
        }
      else {

          TOS_post(TupleRouterM$sendQuery);
        }
    }
  else 
    {

      while (TupleRouterM$mCurSendingExpr < (*curq)->q.numExprs && 
      TupleRouterM$mCurQMsgMask & ((1 << (*curq)->q.numFields) + TupleRouterM$mCurSendingExpr)) 
        TupleRouterM$mCurSendingExpr++;
      if (TupleRouterM$mCurSendingExpr < (*curq)->q.numExprs) {
          Expr e = TupleRouterM$ParsedQueryIntf$getExpr(& (*curq)->q, TupleRouterM$mCurSendingExpr);

#line 1455
          TupleRouterM$mCurSendingExpr++;

          qmsg->type = kEXPR;
          qmsg->idx = TupleRouterM$mCurSendingExpr - 1;
          qmsg->u.expr = e;



          if (!TupleRouterM$IS_SENDING_MESSAGE()) {
              TupleRouterM$SET_SENDING_MESSAGE();
              { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1465
                {
                  TupleRouterM$mMustTimestamp = TupleRouterM$TS_QUERY_MESSAGE;
                  TupleRouterM$mTimestampMsg = &TupleRouterM$mQmsg;
                }
#line 1468
                __nesc_atomic_end(__nesc_atomic); }
              if (TupleRouterM$Network$sendQueryMessage(&TupleRouterM$mQmsg) != err_NoError) {
                  TupleRouterM$UNSET_SENDING_MESSAGE();
                  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 1471
                    {
                      TupleRouterM$mMustTimestamp = TupleRouterM$TS_NO;
                    }
#line 1473
                    __nesc_atomic_end(__nesc_atomic); }
                }
            }
        }
      else {
        if (
#line 1477
        (*curq)->q.bufferType != kRADIO && 
        TupleRouterM$mCurSendingExpr == (*curq)->q.numExprs && 
        !(TupleRouterM$mCurQMsgMask & (1 << ((*curq)->q.numFields + (*curq)->q.numExprs)))) {
            qmsg->type = kBUF_MSG;
            qmsg->u.buf = (*curq)->q.buf;
            TupleRouterM$mCurSendingExpr++;

            TupleRouterM$Leds$yellowToggle();

            if (!TupleRouterM$IS_SENDING_MESSAGE()) {
                TupleRouterM$SET_SENDING_MESSAGE();

                if (TupleRouterM$Network$sendQueryMessage(&TupleRouterM$mQmsg) != err_NoError) {
                  TupleRouterM$UNSET_SENDING_MESSAGE();
                  }
              }
          }
        else 
          {
            TupleRouterM$UNSET_SENDING_QUERY();
          }
        }
    }
}

# 119 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/LedsC.nc"
static   result_t LedsC$Leds$greenToggle(void)
#line 119
{
  result_t rval;

#line 121
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 121
    {
      if (LedsC$ledsOn & LedsC$GREEN_BIT) {
        rval = LedsC$Leds$greenOff();
        }
      else {
#line 125
        rval = LedsC$Leds$greenOn();
        }
    }
#line 127
    __nesc_atomic_end(__nesc_atomic); }
#line 127
  return rval;
}

# 221 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/NetworkMultiHopM.nc"
static  TinyDBError NetworkMultiHopM$Network$sendQueryMessage(TOS_MsgPtr msg)
{
  QueryMessagePtr qmsg = NetworkMultiHopM$Network$getQueryPayLoad(msg);

#line 224
  qmsg->fwdNode = TOS_LOCAL_ADDRESS;
  if (NetworkMultiHopM$SendQueryMsg$send(TOS_BCAST_ADDR, kMSG_LEN, msg) == SUCCESS) 
    {
      NetworkMultiHopM$Leds$greenToggle();
      return err_NoError;
    }
  return err_MessageSendFailed;
}

# 383 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/AggOperator.nc"
static  result_t AggOperator$MemAlloc$allocComplete(HandlePtr h, uint8_t success)
#line 383
{
  AggOperator$GroupDataHandle dh = (AggOperator$GroupDataHandle )*h;
  AggOperator$GroupRecord *newGroup;

  if (h != (Handle *)AggOperator$mAlloced) {
#line 387
    return SUCCESS;
    }
#line 388
  AggOperator$mAlloced = NULL;
  {
  }
#line 389
  ;
  if (!success) {
      {
      }
#line 391
      ;
      AggOperator$signalError(err_OutOfMemory, 392);
      return FAIL;
    }
  {
  }
#line 395
  ;
  (*dh)->groupSize = AggOperator$groupSize(AggOperator$mCurExpr);
  (*dh)->numGroups = 0;
  newGroup = AggOperator$addGroup(dh, AggOperator$mCurGroup);
  AggOperator$initAggregateValue(newGroup, AggOperator$mCurExpr, TRUE);
  (*AggOperator$mCallback)(newGroup);
  return SUCCESS;
}

#line 617
static short AggOperator$groupSize(Expr *e)
#line 617
{
  AggOperator$GroupRecord g;
  short base;

  ParamVals paramVals;

#line 622
  setParamValues(&paramVals, e);

  base = sizeof g - sizeof g.aggdata[0];
  return base + AggOperator$AggregateUse$stateSize(e->ex.agg.op, NULL, &paramVals);
}

# 3498 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  result_t TupleRouterM$MemAlloc$allocComplete(Handle *handle, result_t complete)
#line 3498
{

  {
  }
#line 3500
  ;
  if (TupleRouterM$mAllocState == TupleRouterM$STATE_NOT_ALLOCING) {
#line 3501
    return SUCCESS;
    }
  switch (TupleRouterM$mAllocState) {
      case TupleRouterM$STATE_ALLOC_PARSED_QUERY: 
        TupleRouterM$mAllocState = TupleRouterM$STATE_NOT_ALLOCING;
      if (complete) {

          TupleRouterM$QueryListHandle qlh = (TupleRouterM$QueryListHandle )*handle;

#line 3509
          {
          }
#line 3509
          ;
          (*qlh)->next = NULL;
          (*qlh)->q.clocksPerSample = 0;
          (*qlh)->q.needsData = FALSE;


          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 3515
            {
              if (TupleRouterM$mTail == NULL) {
                  TupleRouterM$mTail = qlh;
                  TupleRouterM$mQs = qlh;
                }
              else 
#line 3519
                {
                  (*TupleRouterM$mTail)->next = (void **)qlh;
                  TupleRouterM$mTail = qlh;
                }
            }
#line 3523
            __nesc_atomic_end(__nesc_atomic); }




          TupleRouterM$mAllocCallback((Handle *)&TupleRouterM$mTail);
        }
      else {
#line 3530
        TupleRouterM$signalError(err_OutOfMemory, 3530);
        }
#line 3531
      break;
      case TupleRouterM$STATE_ALLOC_IN_FLIGHT_QUERY: 
        TupleRouterM$mAllocState = TupleRouterM$STATE_NOT_ALLOCING;
      if (complete) {

          {
          }
#line 3536
          ;

          (*TupleRouterM$mAllocCallback)(handle);
        }
      else 
#line 3539
        {
          TupleRouterM$signalError(err_OutOfMemory, 3540);
          TupleRouterM$UNSET_READING_QUERY();
        }
      break;
      default: 
        TupleRouterM$signalError(err_UnknownAllocationState, 3545);
      break;
    }
  return SUCCESS;
}

# 313 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Util/TinyAlloc.nc"
static  void TinyAlloc$compactTask(void)
#line 313
{
  int16_t i;
  uint8_t c;
  int8_t *p;
  int8_t endFree = 0;

  if (TinyAlloc$mCompacting == 0) {
      TinyAlloc$mContig = 0;
      TinyAlloc$mLast = 0;
      TinyAlloc$mCompacting = 1;
      TinyAlloc$mStartByte = 0;
    }
  c = TinyAlloc$mFree[TinyAlloc$mLast++];
  if (TinyAlloc$mLast == TinyAlloc$FREE_SIZE) {
    goto done_compact;
    }




  if (c == 0) {
      TinyAlloc$mContig += 8;
    }
  else {
      if (c != 0xFF) {
          for (i = 0; i < 8; i++) {
              if ((c & (1 << i)) == 0) {
                  TinyAlloc$mContig++;
                  endFree = 1;
                }
              else {
#line 343
                if (TinyAlloc$mContig == 0) {
                    TinyAlloc$mStartByte++;
                    endFree = 0;
                  }
                else {
                    endFree = 0;
                    break;
                  }
                }
            }
        }
      if (TinyAlloc$mContig > 0 && !endFree) {
          p = (int8_t *)&TinyAlloc$mFrame[TinyAlloc$mStartByte + TinyAlloc$mContig + TinyAlloc$HEADER_SIZE];
          if (!TinyAlloc$isLocked(p)) {
              Handle h = TinyAlloc$getH(p);

              if (h == NULL) {
                  {
                  }
#line 360
                  ;
                  goto done_compact;
                }
              {
              }
#line 363
              ;
              TinyAlloc$shiftUp((Handle )h, TinyAlloc$mContig);
              TinyAlloc$mStartByte += (TinyAlloc$getSize(*h) >> 3) << 3;
            }
          else 
#line 366
            {


              TinyAlloc$mStartByte += ((TinyAlloc$getSize(p) + TinyAlloc$mContig) >> 3) << 3;




              if (TinyAlloc$mStartByte >> 3 == TinyAlloc$mLast - 1) {
                  TinyAlloc$mStartByte += 8;
                }
            }

          TinyAlloc$mLast = TinyAlloc$mStartByte >> 3;
          TinyAlloc$mStartByte = TinyAlloc$mLast << 3;

          TinyAlloc$mContig = 0;
        }
      else {
#line 384
        if (!endFree) {
            TinyAlloc$mStartByte += 8;
            TinyAlloc$mContig = 0;
          }
        }
    }
  done_compact: 

    if (TinyAlloc$mLast >= TinyAlloc$FREE_SIZE) {
        TinyAlloc$mCompacting = 0;
        TinyAlloc$mLast = 0;
        TinyAlloc$mContig = 0;
        TinyAlloc$mNeedFree = 0;
        TinyAlloc$mStartByte = 0;
        if (TinyAlloc$mAllocing) {
            TOS_post(TinyAlloc$allocTask);
          }
        else {
            TinyAlloc$MemAlloc$compactComplete();
          }
      }
    else {


        TOS_post(TinyAlloc$compactTask);
      }
}

#line 285
static void TinyAlloc$doAlloc(int16_t startByte, int16_t endByte)
#line 285
{
  int16_t newIdx = TinyAlloc$getNewHandleIdx();

#line 287
  if (newIdx == -1) {
      TinyAlloc$mAllocing = 0;
      TinyAlloc$MemAlloc$allocComplete(TinyAlloc$mHandle, FAIL);
      return;
    }


  * (int16_t *)&TinyAlloc$mFrame[startByte] = (endByte - startByte) & 0x7FFF;



  TinyAlloc$mHandles[newIdx] = (int8_t *)(&TinyAlloc$mFrame[startByte] + TinyAlloc$HEADER_SIZE);
  *TinyAlloc$mHandle = &TinyAlloc$mHandles[newIdx];


  TinyAlloc$setFreeBits(startByte, endByte, 1);

  TinyAlloc$mAllocing = 0;
  if (TinyAlloc$mReallocing) {
      TinyAlloc$finish_realloc(TinyAlloc$mHandle, 1);
    }
  else {
      TinyAlloc$MemAlloc$allocComplete(TinyAlloc$mHandle, SUCCESS);
    }
}

#line 476
static  result_t TinyAlloc$MemAlloc$reallocate(Handle hand, int16_t newSize)
#line 476
{
  int16_t neededBytes = newSize + TinyAlloc$HEADER_SIZE;
  int8_t *p = *hand;

  if (TinyAlloc$mAllocing) {
#line 480
    return FAIL;
    }
#line 481
  if (neededBytes > TinyAlloc$MAX_SIZE) {
#line 481
    return FAIL;
    }
  TinyAlloc$mOldHandle = hand;

  if (neededBytes == TinyAlloc$getSize(*hand)) {
      TOS_post(TinyAlloc$reallocDone);
      return SUCCESS;
    }


  if (neededBytes < TinyAlloc$getSize(*hand)) {
      int16_t oldSize = TinyAlloc$getSize(*hand);

      (
      (int16_t *)(p - TinyAlloc$HEADER_SIZE))[0] = neededBytes & 0x7FFF;


      TinyAlloc$setFreeBits(TinyAlloc$start_offset(p) + neededBytes, TinyAlloc$start_offset(p) + oldSize, 0);

      TinyAlloc$mFreeBytes -= neededBytes;
      TinyAlloc$mFreeBytes += TinyAlloc$getSize(*hand);

      TOS_post(TinyAlloc$reallocDone);
      return SUCCESS;
    }
  else {
#line 506
    if (neededBytes > TinyAlloc$getSize(*hand) && !TinyAlloc$isLocked(*hand)) {


        TinyAlloc$mReallocing = 1;

        TinyAlloc$mFreeBytes += TinyAlloc$getSize(*hand);

        return TinyAlloc$MemAlloc$allocate(&TinyAlloc$mTmpHandle, newSize);
      }
    }
#line 515
  return FAIL;
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/ExprEvalC.nc"
static short ExprEvalC$evaluateSimpleExpr(short a, short op, short b)
#line 73
{


  switch (op) {
      case FOP_NOOP: 
        break;
      case FOP_TIMES: 
        return a * b;
      case FOP_DIVIDE: 
        return a / b;
      case FOP_ADD: 
        return a + b;
      case FOP_SUBTRACT: 
        return a - b;
      case FOP_MOD: 
        return a % b;
      case FOP_RSHIFT: 
        return a >> b;
    }

  return a;
}

# 243 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Aggregates/ContourMapM.nc"
static bool ContourMapM$contourRegionMerging(ContourMapM$ContourRegion *region1, ContourMapM$ContourRegion *region2)
#line 243
{

  ContourMapM$ContourRegion region;

  if (ContourMapM$checkOverlapping(region1, region2) == FALSE) {
    return FALSE;
    }
  ContourMapM$computeRegionEpsilon(region1, region2, &region);
  if (region.epsilon > ContourMapM$errorBound) {
    return FALSE;
    }
#line 253
  region.boundaries[0].vertices[0] = region1->boundaries[0].vertices[0];
  region.boundaries[0].vertices[1] = region1->boundaries[0].vertices[1];
  if (region.boundaries[0].vertices[0].x > region2->boundaries[0].vertices[0].x) {
    region.boundaries[0].vertices[0].x = region2->boundaries[0].vertices[0].x;
    }
#line 257
  if (region.boundaries[0].vertices[0].y > region2->boundaries[0].vertices[0].y) {
    region.boundaries[0].vertices[0].y = region2->boundaries[0].vertices[0].y;
    }
#line 259
  if (region.boundaries[0].vertices[1].x < region2->boundaries[0].vertices[1].x) {
    region.boundaries[0].vertices[1].x = region2->boundaries[0].vertices[1].x;
    }
#line 261
  if (region.boundaries[0].vertices[1].y < region2->boundaries[0].vertices[1].y) {
    region.boundaries[0].vertices[1].y = region2->boundaries[0].vertices[1].y;
    }

  *region1 = region;

  return TRUE;
}

#line 129
static void ContourMapM$constructRegressionModel(ContourMapM$RegressionModel *regression, int16_t *w)
#line 129
{
  int16_t d;
#line 130
  int16_t d1;
#line 130
  int16_t d2;
  int16_t *A;
#line 131
  int16_t *b;

  A = (int16_t *)regression->A;
  b = (int16_t *)regression->b;

  d = 1 * A[2] - A[0] * A[0];
  d1 = b[2] * d + b[0] * A[0] * A[3] - b[1] * 1 * A[3] - b[0] * A[2] * A[1] + b[1] * A[0] * A[1];
  d2 = A[0] * A[3] * A[1] - A[1] * A[2] * A[1] - 1 * A[3] * A[3] + A[1] * A[0] * A[3] + A[4] * d;

  w[2] = d1;
  if (d2 != 0) {
    w[2] /= d2;
    }
  else {
#line 144
    w[2] = 0;
    }
  w[0] = w[2] * (A[0] * A[3] - A[1] * A[2]) + (b[0] * A[2] - b[1] * A[0]);
  if (d != 0) {
    w[0] /= d;
    }
  else {
#line 150
    w[0] = 0;
    }
  w[1] = w[2] * (1 * A[3] - A[1] * A[0]) + (b[0] * A[0] - b[1] * 1);
  if (d != 0) {
    w[1] /= -d;
    }
  else {
#line 156
    w[1] = 0;
    }
  if (w[1] == -0) {
    w[1] = 0;
    }
}

#line 190
static uint16_t ContourMapM$computeVol(ContourMapM$ContourRegion *region, int16_t *w)
#line 190
{
  int32_t d = w[0] + w[1] * (region->boundaries[0].vertices[0].x + region->boundaries[0].vertices[1].x) + w[2] * (region->boundaries[0].vertices[0].y + region->boundaries[0].vertices[1].y);

#line 192
  if (d < 0) {
#line 192
    d = -d;
    }
#line 193
  return 20 * 20 * d;
}

# 133 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/Attr.nc"
static  AttrDescPtr Attr$AttrUse$getAttr(char *name)
{

  short numAttrs = Attr$attrDescs.numAttrs;
  short i;

#line 138
  for (i = 0; i < numAttrs; i++) 
    {
      if (strcasecmp(Attr$attrDescs.attrDesc[i].name, name) == 0) {
        return &Attr$attrDescs.attrDesc[i];
        }
    }
#line 143
  return NULL;
}

# 150 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static   result_t ADCM$ADC$getData(uint8_t port)
{
  bool oldBusy;

#line 153
  if (port >= ADCM$TOSH_ADC_PORTMAPSIZE) {
    return FAIL;
    }
#line 155
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 155
    {
      oldBusy = ADCM$busy;
      ADCM$busy = TRUE;
    }
#line 158
    __nesc_atomic_end(__nesc_atomic); }
  if (!oldBusy) {
      ADCM$continuousData = FALSE;
      return ADCM$triggerConversion(port);
    }
  return FAIL;
}

# 203 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static msp430ADCresult_t MSP430ADC12M$newRequest(uint8_t req, uint8_t num, void *dataDest, uint16_t length, uint16_t jiffies)
{
  bool access = FALSE;
  msp430ADCresult_t res = MSP430ADC12_FAIL;




  const int16_t num16 = num;


  if (num16 >= 5U || (!MSP430ADC12M$reserved && (
  !length || (req == REPEAT_SEQUENCE_OF_CHANNELS && length > 16)))) {
    return MSP430ADC12_FAIL;
    }






  if (jiffies == 1 || jiffies == 2) {
    return MSP430ADC12_FAIL;
    }

  if (MSP430ADC12M$reserved & RESERVED) {
    if (!(MSP430ADC12M$reserved & VREF_WAIT) && MSP430ADC12M$owner == num16 && MSP430ADC12M$cmode == req) {
        MSP430ADC12M$HPLADC12$startConversion();
        if (MSP430ADC12M$reserved & TIMER_USED) {
          MSP430ADC12M$startTimerA();
          }
#line 233
        MSP430ADC12M$reserved = ADC_IDLE;
        return MSP430ADC12_SUCCESS;
      }
    else {
#line 236
      return MSP430ADC12_FAIL;
      }
    }
#line 238
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 238
    {
      if (MSP430ADC12M$cmode == ADC_IDLE) {
          MSP430ADC12M$owner = num16;
          MSP430ADC12M$cmode = SEQUENCE_OF_CHANNELS;
          access = TRUE;
        }
    }
#line 244
    __nesc_atomic_end(__nesc_atomic); }

  if (access) {
      res = MSP430ADC12_SUCCESS;
      switch (MSP430ADC12M$getRefVolt(num16)) 
        {
          case MSP430ADC12_FAIL: 
            MSP430ADC12M$cmode = ADC_IDLE;
          res = MSP430ADC12_FAIL;
          break;
          case MSP430ADC12_DELAYED: 


            req |= RESERVED | VREF_WAIT;
          res = MSP430ADC12_DELAYED;
          MSP430ADC12M$vrefWait = TRUE;

          case MSP430ADC12_SUCCESS: 
            {
              int8_t i;
#line 263
              int8_t memctlsUsed = length;
              uint16_t mask = 1;
              adc12memctl_t lastMemctl = MSP430ADC12M$adc12settings[num16].memctl;
              uint16_t ctl0 = (0x0000 | 0x0010) & ~0x0080;
              adc12ctl1_t ctl1 = { .adc12busy = 0, .conseq = 1, 
              .adc12ssel = MSP430ADC12M$adc12settings[num16].clockSourceSHT, 
              .adc12div = MSP430ADC12M$adc12settings[num16].clockDivSHT, .issh = 0, .shp = 1, 
              .shs = 1, .cstartadd = 0 };

#line 271
              if (length > 16) {
                  ctl1.conseq = 3;
                  memctlsUsed = 16;
                }
              MSP430ADC12M$bufPtr = dataDest;
              MSP430ADC12M$bufLength = length;
              MSP430ADC12M$bufOffset = 0;


              MSP430ADC12M$HPLADC12$disableConversion();
              if (jiffies == 0) {
                  ctl0 = (0x0000 | 0x0010) | 0x0080;
                  ctl1.shs = 0;
                }
              for (i = 0; i < memctlsUsed - 1; i++) 
                MSP430ADC12M$HPLADC12$setMemControl(i, MSP430ADC12M$adc12settings[num16].memctl);
              lastMemctl.eos = 1;
              MSP430ADC12M$HPLADC12$setMemControl(i, lastMemctl);
              MSP430ADC12M$HPLADC12$setSHT(MSP430ADC12M$adc12settings[num16].sampleHoldTime);
              MSP430ADC12M$HPLADC12$setIEFlags(mask << i);
              MSP430ADC12M$HPLADC12$setControl0_IgnoreRef(* (adc12ctl0_t *)&ctl0);

              if (req & SINGLE_CHANNEL) {
                  ctl1.conseq = 0;
                  MSP430ADC12M$cmode = SINGLE_CHANNEL;
                }
              else {
#line 296
                if (req & REPEAT_SINGLE_CHANNEL) {
                    ctl1.conseq = 2;
                    MSP430ADC12M$cmode = REPEAT_SINGLE_CHANNEL;
                  }
                else {
#line 299
                  if (req & REPEAT_SEQUENCE_OF_CHANNELS) {
                      ctl1.conseq = 3;
                      MSP430ADC12M$cmode = REPEAT_SEQUENCE_OF_CHANNELS;
                    }
                  }
                }
#line 303
              MSP430ADC12M$HPLADC12$setControl1(ctl1);

              if (req & RESERVED) {

                  MSP430ADC12M$reserved = req;
                  if (jiffies != 0) {
                      MSP430ADC12M$prepareTimerA(jiffies, MSP430ADC12M$adc12settings[num16].clockSourceSAMPCON, 
                      MSP430ADC12M$adc12settings[num16].clockDivSAMPCON);
                      MSP430ADC12M$reserved |= TIMER_USED;
                    }
                }
              else 
#line 313
                {

                  MSP430ADC12M$HPLADC12$startConversion();
                  if (jiffies != 0) {
                      MSP430ADC12M$prepareTimerA(jiffies, MSP430ADC12M$adc12settings[num16].clockSourceSAMPCON, 
                      MSP430ADC12M$adc12settings[num16].clockDivSAMPCON);
                      MSP430ADC12M$startTimerA();
                    }
                }
              res = MSP430ADC12_SUCCESS;
              break;
            }
        }
    }
  return res;
}

# 106 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/RefVoltM.nc"
static   result_t RefVoltM$RefVolt$get(RefVolt_t vref)
#line 106
{
  result_t result = SUCCESS;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 109
    {
      if (RefVoltM$semaCount == 0) {
          if (RefVoltM$HPLADC12$isBusy()) {
            result = FAIL;
            }
          else 
#line 113
            {
              if (RefVoltM$state == RefVoltM$REFERENCE_OFF) {
                RefVoltM$switchRefOn(vref);
                }
              else {
#line 116
                if ((RefVoltM$state == RefVoltM$REFERENCE_1_5V_PENDING && vref == REFERENCE_2_5V) || (
                RefVoltM$state == RefVoltM$REFERENCE_2_5V_PENDING && vref == REFERENCE_1_5V)) {
                  RefVoltM$switchToRefPending(vref);
                  }
                else {
#line 119
                  if ((RefVoltM$state == RefVoltM$REFERENCE_1_5V_STABLE && vref == REFERENCE_2_5V) || (
                  RefVoltM$state == RefVoltM$REFERENCE_2_5V_STABLE && vref == REFERENCE_1_5V)) {
                    RefVoltM$switchToRefStable(vref);
                    }
                  }
                }
#line 122
              RefVoltM$semaCount++;
              RefVoltM$switchOff = FALSE;
              result = SUCCESS;
            }
        }
      else {

        if ((((
#line 127
        RefVoltM$state == RefVoltM$REFERENCE_1_5V_PENDING && vref == REFERENCE_1_5V) || (
        RefVoltM$state == RefVoltM$REFERENCE_2_5V_PENDING && vref == REFERENCE_2_5V)) || (
        RefVoltM$state == RefVoltM$REFERENCE_1_5V_STABLE && vref == REFERENCE_1_5V)) || (
        RefVoltM$state == RefVoltM$REFERENCE_2_5V_STABLE && vref == REFERENCE_2_5V)) {
            RefVoltM$semaCount++;
            RefVoltM$switchOff = FALSE;
            result = SUCCESS;
          }
        else {
#line 135
          result = FAIL;
          }
        }
    }
#line 138
    __nesc_atomic_end(__nesc_atomic); }
#line 137
  return result;
}

# 73 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static   void HPLADC12M$HPLADC12$setMemControl(uint8_t i, adc12memctl_t memControl)
#line 73
{
  uint8_t *memCtlPtr = (uint8_t *)(char *)0x0080;

#line 75
  if (i < 16) {
      memCtlPtr += i;
      *memCtlPtr = * (uint8_t *)&memControl;
    }
}

# 168 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static void MSP430ADC12M$prepareTimerA(uint16_t interval, uint16_t csSAMPCON, uint16_t cdSAMPCON)
{
  MSP430CompareControl_t ccResetSHI = { 
  .ccifg = 0, .cov = 0, .out = 0, .cci = 0, .ccie = 0, 
  .outmod = 0, .cap = 0, .clld = 0, .scs = 0, .ccis = 0, .cm = 0 };

  MSP430ADC12M$TimerA$setMode(MSP430TIMER_STOP_MODE);
  MSP430ADC12M$TimerA$clear();
  MSP430ADC12M$TimerA$disableEvents();
  MSP430ADC12M$TimerA$setClockSource(csSAMPCON);
  MSP430ADC12M$TimerA$setInputDivider(cdSAMPCON);
  MSP430ADC12M$ControlA0$setControl(ccResetSHI);
  MSP430ADC12M$CompareA0$setEvent(interval - 1);
  MSP430ADC12M$CompareA1$setEvent((interval - 1) / 2);
}

# 450 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopLEPSM.nc"
static  void MultiHopLEPSM$TimerTask(void)
#line 450
{

  {
  }
#line 452
  ;
  MultiHopLEPSM$updateTable();


  {
    int i;

#line 458
    {
    }
#line 458
    ;
    for (i = 0; i < MultiHopLEPSM$ROUTE_TABLE_SIZE; i++) {
        if (MultiHopLEPSM$NeighborTbl[i].flags) {
            {
            }
#line 461
            ;
          }
      }








    if (MultiHopLEPSM$gpCurrentParent) {
        {
        }
#line 473
        ;
      }
  }

  MultiHopLEPSM$chooseParent();

  TOS_post(MultiHopLEPSM$SendRouteTask);
}

# 123 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430TimerM.nc"
void  __attribute((wakeup)) __attribute((interrupt(12))) sig_TIMERA0_VECTOR(void)
{
  if (MSP430TimerM$ControlA0$getControl().cap) {
    MSP430TimerM$CaptureA0$captured(MSP430TimerM$CaptureA0$getEvent());
    }
  else {
#line 128
    MSP430TimerM$CompareA0$fired();
    }
}

#line 131
void  __attribute((wakeup)) __attribute((interrupt(10))) sig_TIMERA1_VECTOR(void)
{
  int n = TA0IV;

#line 134
  switch (n) 
    {
      case 0: break;
      case 2: 
        if (MSP430TimerM$ControlA1$getControl().cap) {
          MSP430TimerM$CaptureA1$captured(MSP430TimerM$CaptureA1$getEvent());
          }
        else {
#line 141
          MSP430TimerM$CompareA1$fired();
          }
#line 142
      break;
      case 4: 
        if (MSP430TimerM$ControlA2$getControl().cap) {
          MSP430TimerM$CaptureA2$captured(MSP430TimerM$CaptureA2$getEvent());
          }
        else {
#line 147
          MSP430TimerM$CompareA2$fired();
          }
#line 148
      break;
      case 6: break;
      case 8: break;
      case 10: MSP430TimerM$TimerA$overflow();
#line 151
      break;
      case 12: break;
      case 14: break;
    }
}

#line 277
void  __attribute((wakeup)) __attribute((interrupt(26))) sig_TIMERB0_VECTOR(void)
{
  if (MSP430TimerM$ControlB0$getControl().cap) {
    MSP430TimerM$CaptureB0$captured(MSP430TimerM$CaptureB0$getEvent());
    }
  else {
#line 282
    MSP430TimerM$CompareB0$fired();
    }
}

#line 285
void  __attribute((wakeup)) __attribute((interrupt(24))) sig_TIMERB1_VECTOR(void)
{
  int n = TBIV;

#line 288
  switch (n) 
    {
      case 0: break;
      case 2: 
        if (MSP430TimerM$ControlB1$getControl().cap) {
          MSP430TimerM$CaptureB1$captured(MSP430TimerM$CaptureB1$getEvent());
          }
        else {
#line 295
          MSP430TimerM$CompareB1$fired();
          }
#line 296
      break;
      case 4: 
        if (MSP430TimerM$ControlB2$getControl().cap) {
          MSP430TimerM$CaptureB2$captured(MSP430TimerM$CaptureB2$getEvent());
          }
        else {
#line 301
          MSP430TimerM$CompareB2$fired();
          }
#line 302
      break;
      case 6: 
        if (MSP430TimerM$ControlB3$getControl().cap) {
          MSP430TimerM$CaptureB3$captured(MSP430TimerM$CaptureB3$getEvent());
          }
        else {
#line 307
          MSP430TimerM$CompareB3$fired();
          }
#line 308
      break;
      case 8: 
        if (MSP430TimerM$ControlB4$getControl().cap) {
          MSP430TimerM$CaptureB4$captured(MSP430TimerM$CaptureB4$getEvent());
          }
        else {
#line 313
          MSP430TimerM$CompareB4$fired();
          }
#line 314
      break;
      case 10: 
        if (MSP430TimerM$ControlB5$getControl().cap) {
          MSP430TimerM$CaptureB5$captured(MSP430TimerM$CaptureB5$getEvent());
          }
        else {
#line 319
          MSP430TimerM$CompareB5$fired();
          }
#line 320
      break;
      case 12: 
        if (MSP430TimerM$ControlB6$getControl().cap) {
          MSP430TimerM$CaptureB6$captured(MSP430TimerM$CaptureB6$getEvent());
          }
        else {
#line 325
          MSP430TimerM$CompareB6$fired();
          }
#line 326
      break;
      case 14: MSP430TimerM$TimerB$overflow();
#line 327
      break;
    }
}

# 185 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static   result_t HPLCC2420InterruptM$SFD$enableCapture(bool low_to_high)
#line 185
{
  uint8_t _direction;

#line 187
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 187
    {
      TOSH_SEL_CC_SFD_MODFUNC();
      HPLCC2420InterruptM$SFDControl$disableEvents();
      if (low_to_high) {
#line 190
        _direction = MSP430TIMER_CM_RISING;
        }
      else {
#line 191
        _direction = MSP430TIMER_CM_FALLING;
        }
#line 192
      HPLCC2420InterruptM$SFDControl$setControlAsCapture(_direction);
      HPLCC2420InterruptM$SFDCapture$clearOverflow();
      HPLCC2420InterruptM$SFDControl$clearPendingInterrupt();
      HPLCC2420InterruptM$SFDControl$enableEvents();
    }
#line 196
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 113 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static void CC2420RadioM$sendFailed(void)
#line 113
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 114
    CC2420RadioM$stateRadio = CC2420RadioM$IDLE_STATE;
#line 114
    __nesc_atomic_end(__nesc_atomic); }
  CC2420RadioM$txbufptr->length = CC2420RadioM$txbufptr->length - MSG_HEADER_SIZE - MSG_FOOTER_SIZE;
  CC2420RadioM$Send$sendDone(CC2420RadioM$txbufptr, FAIL);
}

#line 168
static  void CC2420RadioM$PacketSent(void)
#line 168
{
  TOS_MsgPtr pBuf;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 171
    {
      CC2420RadioM$stateRadio = CC2420RadioM$IDLE_STATE;
      pBuf = CC2420RadioM$txbufptr;
      pBuf->length = pBuf->length - MSG_HEADER_SIZE - MSG_FOOTER_SIZE;
    }
#line 175
    __nesc_atomic_end(__nesc_atomic); }

  CC2420RadioM$Send$sendDone(pBuf, SUCCESS);
}

#line 393
static  void CC2420RadioM$startSend(void)
#line 393
{

  if (!CC2420RadioM$HPLChipcon$cmd(0x09)) {
      CC2420RadioM$sendFailed();
      return;
    }

  if (!CC2420RadioM$HPLChipconFIFO$writeTXFIFO(CC2420RadioM$txlength + 1, (uint8_t *)CC2420RadioM$txbufptr)) {
      CC2420RadioM$sendFailed();
      return;
    }
}





static void CC2420RadioM$tryToSend(void)
#line 410
{
  uint8_t currentstate;

#line 412
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 412
    currentstate = CC2420RadioM$stateRadio;
#line 412
    __nesc_atomic_end(__nesc_atomic); }


  if (currentstate == CC2420RadioM$PRE_TX_STATE) {



      if (!TOSH_READ_CC_FIFO_PIN() && !TOSH_READ_CC_FIFOP_PIN()) {
          CC2420RadioM$flushRXFIFO();
        }

      if (TOSH_READ_RADIO_CCA_PIN()) {
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 424
            CC2420RadioM$stateRadio = CC2420RadioM$TX_STATE;
#line 424
            __nesc_atomic_end(__nesc_atomic); }
          CC2420RadioM$sendPacket();
        }
      else {



          if (CC2420RadioM$countRetry-- <= 0) {
              CC2420RadioM$flushRXFIFO();
              CC2420RadioM$countRetry = 8;
              if (!TOS_post(CC2420RadioM$startSend)) {
                CC2420RadioM$sendFailed();
                }
#line 436
              return;
            }
          if (!CC2420RadioM$setBackoffTimer(CC2420RadioM$MacBackoff$congestionBackoff(CC2420RadioM$txbufptr) * 10)) {
              CC2420RadioM$sendFailed();
            }
        }
    }
}

#line 119
static void CC2420RadioM$flushRXFIFO(void)
#line 119
{
  CC2420RadioM$FIFOP$disable();
  CC2420RadioM$HPLChipcon$read(0x3F);
  CC2420RadioM$HPLChipcon$cmd(0x08);
  CC2420RadioM$HPLChipcon$cmd(0x08);
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 124
    CC2420RadioM$bPacketReceiving = FALSE;
#line 124
    __nesc_atomic_end(__nesc_atomic); }
  CC2420RadioM$FIFOP$startWait(FALSE);
}

# 205 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420M.nc"
static   uint16_t HPLCC2420M$HPLCC2420$read(uint8_t addr)
#line 205
{
  uint16_t data = 0;

#line 207
  if (HPLCC2420M$BusArbitration$getBus() == SUCCESS) {

      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 209
        HPLCC2420M$f.busy = TRUE;
#line 209
        __nesc_atomic_end(__nesc_atomic); }
      TOSH_CLR_RADIO_CSN_PIN();

      HPLCC2420M$USARTControl$isTxIntrPending();
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx(addr | 0x40);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
      HPLCC2420M$USARTControl$rx();
      HPLCC2420M$USARTControl$tx(0);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
      data = (HPLCC2420M$USARTControl$rx() << 8) & 0xFF00;
      HPLCC2420M$USARTControl$tx(0);
      while (HPLCC2420M$f.enabled && !HPLCC2420M$USARTControl$isRxIntrPending()) ;
      data = data | (HPLCC2420M$USARTControl$rx() & 0x0FF);
      TOSH_SET_RADIO_CSN_PIN();
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 224
        HPLCC2420M$f.busy = FALSE;
#line 224
        __nesc_atomic_end(__nesc_atomic); }
#line 242
      HPLCC2420M$BusArbitration$releaseBus();
    }
  return data;
}

# 65 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/telos/HPLCC2420InterruptM.nc"
static   result_t HPLCC2420InterruptM$FIFOP$startWait(bool low_to_high)
#line 65
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 66
    {
      HPLCC2420InterruptM$FIFOPInterrupt$disable();
      HPLCC2420InterruptM$FIFOPInterrupt$clear();
      HPLCC2420InterruptM$FIFOPInterrupt$edge(low_to_high);
      HPLCC2420InterruptM$FIFOPInterrupt$enable();
    }
#line 71
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 215 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMStandard.nc"
TOS_MsgPtr   received(TOS_MsgPtr packet)
#line 215
{
  uint16_t addr = TOS_LOCAL_ADDRESS;

#line 217
  AMStandard$counter++;
  {
  }
#line 218
  ;


  if (
#line 220
  packet->crc == 1 && 
  packet->group == TOS_AM_GROUP && (
  packet->addr == TOS_BCAST_ADDR || 
  packet->addr == addr)) 
    {

      uint8_t type = packet->type;
      TOS_MsgPtr tmp;

      {
      }
#line 229
      ;
      AMStandard$dbgPacket(packet);
      {
      }
#line 231
      ;


      tmp = AMStandard$ReceiveMsg$receive(type, packet);
      if (tmp) {
        packet = tmp;
        }
    }
#line 238
  return packet;
}

# 927 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static TinyDBError TupleRouterM$forwardQuery(QueryMessagePtr qmsg)
#line 927
{
  TinyDBError err = err_NoError;

  if (!TupleRouterM$IS_SENDING_MESSAGE()) {
      QueryMessagePtr qmsgCopy;

#line 932
      TupleRouterM$SET_SENDING_MESSAGE();
      qmsgCopy = TupleRouterM$Network$getQueryPayLoad(&TupleRouterM$mMsg);
      *qmsgCopy = *qmsg;
      qmsgCopy->fwdNode = TOS_LOCAL_ADDRESS;
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 936
        TupleRouterM$mMustTimestamp = TupleRouterM$TS_QUERY_MESSAGE;
#line 936
        __nesc_atomic_end(__nesc_atomic); }
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 937
        TupleRouterM$mTimestampMsg = &TupleRouterM$mMsg;
#line 937
        __nesc_atomic_end(__nesc_atomic); }
      TOS_post(TupleRouterM$queryMsgTask);
    }
  else {








    err = err_MSF_ForwardKnownQueryBusy;
    }
  if (err != err_NoError) {
    TupleRouterM$signalError(err, 952);
    }
#line 953
  return err;
}

#line 1943
static void TupleRouterM$setRate(uint8_t qid, uint16_t epochDur)
#line 1943
{
  ParsedQuery *q;

#line 1945
  if (TupleRouterM$getQuery(qid, &q)) {
      q->clocksPerSample = (uint16_t )((uint32_t )epochDur * TupleRouterM$kBASE_EPOCH_RATE / (uint32_t )TupleRouterM$mOldRate);
    }
}

#line 1008
static bool TupleRouterM$addQueryField(QueryMessagePtr qmsg)
#line 1008
{
  bool knewAbout = FALSE;

  if (qmsg->type == kFIELD) {
      TupleRouterM$QueryIntf$setField(*TupleRouterM$mCurQuery, (short )qmsg->idx, qmsg->u.field);
      knewAbout = (*TupleRouterM$mCurQuery)->knownFields & (1 << qmsg->idx);
      (*TupleRouterM$mCurQuery)->knownFields |= 1 << qmsg->idx;
    }
  else {
#line 1016
    if (qmsg->type == kEXPR) {
        qmsg->u.expr.opState = NULL;
        TupleRouterM$QueryIntf$setExpr(*TupleRouterM$mCurQuery, qmsg->idx, qmsg->u.expr);


        knewAbout = (*TupleRouterM$mCurQuery)->knownExprs & (1 << qmsg->idx);
        (*TupleRouterM$mCurQuery)->knownExprs |= 1 << qmsg->idx;
      }
    else {
#line 1023
      if (qmsg->type == kBUF_MSG) {
          knewAbout = (*TupleRouterM$mCurQuery)->hasBuf;
          (*TupleRouterM$mCurQuery)->hasBuf = TRUE;
          (*TupleRouterM$mCurQuery)->buf = qmsg->u.buf;
        }
      else {
#line 1027
        if (qmsg->type == kEVENT_MSG) {

            knewAbout = (*TupleRouterM$mCurQuery)->hasEvent;
            (*TupleRouterM$mCurQuery)->hasEvent = TRUE;
            strcpy((*TupleRouterM$mCurQuery)->eventName, 
            qmsg->u.eventName);
            {
            }
#line 1033
            ;
          }
        else {
#line 1034
          if (qmsg->type == kN_EPOCHS_MSG) 
            {
              knewAbout = (*TupleRouterM$mCurQuery)->hasForClause;
              (*TupleRouterM$mCurQuery)->hasForClause = TRUE;
              (*TupleRouterM$mCurQuery)->numEpochs = qmsg->u.numEpochs;
              {
              }
#line 1039
              ;
            }
          }
        }
      }
    }
#line 1042
  if (TupleRouterM$queryComplete(* *TupleRouterM$mCurQuery)) {
      TupleRouterM$SET_PARSING_QUERY();


      {
      }
#line 1046
      ;


      TupleRouterM$MemAlloc$lock((Handle )TupleRouterM$mCurQuery);

      TupleRouterM$allocQuery(&TupleRouterM$parsedCallback, *TupleRouterM$mCurQuery);
    }
  return knewAbout;
}

# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/Query.nc"
static  Expr Query$QueryIntf$getExpr(QueryPtr q, uint8_t idx)
#line 55
{
  return * (Expr *)(char *)((char *)q + sizeof(Query ) + (
  q->numFields - 1) * sizeof(Field ) + 
  idx * sizeof(Expr ));
}

# 1097 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$parsedQuery(bool success)
#line 1097
{
  TupleRouterM$QueryListHandle h = (TupleRouterM$QueryListHandle )TupleRouterM$mTmpHandle;
  int qid = (*TupleRouterM$mCurQuery)->qid;
  TinyDBError err = err_NoError;


  TupleRouterM$MemAlloc$unlock((Handle )h);

  TupleRouterM$MemAlloc$unlock((Handle )TupleRouterM$mCurQuery);
  TupleRouterM$MemAlloc$free((Handle )TupleRouterM$mCurQuery);
  TupleRouterM$mCurQuery = NULL;
  if (success) {
      {
      }
#line 1109
      ;
      if (TupleRouterM$reallocQueryForTuple(&TupleRouterM$resizedCallback, (TupleRouterM$QueryListHandle )h) == FALSE) {
          err = err_OutOfMemory;
          goto fail;
        }
    }
  else 
#line 1114
    {
      err = err_UnknownError;
      goto fail;
    }

  return;

  fail: 
    if (err != err_UnknownError) {
#line 1122
      TupleRouterM$signalError(err, 1122);
      }
  (*h)->q.qid = qid;


  TupleRouterM$mQidToRemove = qid;
  TupleRouterM$mForceRemove = TRUE;
  TOS_post(TupleRouterM$removeQueryTask);

  TupleRouterM$UNSET_READING_QUERY();
  TupleRouterM$UNSET_PARSING_QUERY();
}

#line 3095
static  ParsedQueryPtr TupleRouterM$QueryProcessor$getQueryIdx(short i)
#line 3095
{
  TupleRouterM$QueryListHandle curq;

  curq = TupleRouterM$mQs;
  while (curq != NULL) {
      if (i-- == 0) {
#line 3100
        return & (*curq)->q;
        }
#line 3101
      curq = (TupleRouterM$QueryListHandle )(*curq)->next;
    }
  return NULL;
}

# 218 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Route/MultiHopEngineM.nc"
static  TOS_MsgPtr MultiHopEngineM$ReceiveMsg$receive(uint8_t id, TOS_MsgPtr pMsg)
#line 218
{
  TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)pMsg->data;
  uint16_t PayloadLen = pMsg->length - (size_t )& ((TOS_MHopMsg *)0)->data;
  bool fromChildren = FALSE;
  int i;
  uint16_t *children = MultiHopEngineM$RouteControl$getChildren();

  for (i = 0; i < 16; i++) 
    if (children[i] == pMHMsg->sourceaddr) {
      fromChildren = TRUE;
      }






  if (pMsg->addr == TOS_LOCAL_ADDRESS || fromChildren) {
      if (MultiHopEngineM$Intercept$intercept(id, pMsg, &pMHMsg->data[0], PayloadLen) == SUCCESS) {
          pMsg = MultiHopEngineM$mForward(pMsg, id);
        }
    }
  else {

      MultiHopEngineM$Snoop$intercept(id, pMsg, &pMHMsg->data[0], PayloadLen);
    }

  return pMsg;
}

# 1738 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static  result_t TupleRouterM$Network$dataSub(QueryResultPtr qrMsg)
#line 1738
{
  QueryResult qr;
  ParsedQuery *q;
  bool gotAgg = FALSE;
  bool pending;





  if (TupleRouterM$getQuery(TupleRouterM$QueryResultIntf$queryIdFromMsg(qrMsg), &q)) {


      {
      }
#line 1751
      ;

      if (q->markedForDeletion) {
          q->markedForDeletion = TupleRouterM$EPOCHS_TIL_DELETION;
        }
      TupleRouterM$QueryResultIntf$fromBytes(qrMsg, &qr, q);



      gotAgg = q->hasAgg;

      if (!gotAgg) {
          TinyDBError err;

#line 1764
          {
          }
#line 1764
          ;

          TupleRouterM$mEnqResult = * (QueryResultPtr )qrMsg;
          err = TupleRouterM$DBBuffer$enqueue(q->bufferId, &TupleRouterM$mEnqResult, &pending, q);






          if (err != err_ResultBufferBusy && err != err_NoError) {
#line 1774
            TupleRouterM$signalError(err, 1774);
            }
        }
      else 
#line 1775
        {
          TupleRouterM$mResult = qr;



          if (!TupleRouterM$IS_AGGREGATING_RESULT()) {
            TupleRouterM$aggregateResult(q, &TupleRouterM$mResult, 0);
            }
        }
    }
  return SUCCESS;
}











static void TupleRouterM$aggregateResult(ParsedQuery *q, QueryResult *qr, char exprId)
#line 1798
{
  Expr *e;

  if (exprId >= q->numExprs) {
      TupleRouterM$UNSET_AGGREGATING_RESULT();
      return;
    }



  e = TupleRouterM$ParsedQueryIntf$getExprPtr(q, exprId);
  if (e->opType != kSEL) {
      TupleRouterM$SET_AGGREGATING_RESULT();
      if (TupleRouterM$AggOperator$processPartialResult(qr, q, e) != err_NoError) {
          TupleRouterM$UNSET_AGGREGATING_RESULT();

          TupleRouterM$aggregateResult(q, qr, exprId + 1);
        }
    }
  else {
#line 1817
    TupleRouterM$aggregateResult(q, qr, exprId + 1);
    }
}

# 58 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART0M.nc"
void  __attribute((wakeup)) __attribute((interrupt(18))) sig_UART0RX_VECTOR(void)
#line 58
{
  uint8_t temp = U0RXBUF;

#line 60
  HPLUSART0M$USARTData$rxDone(temp);
}

void  __attribute((wakeup)) __attribute((interrupt(16))) sig_UART0TX_VECTOR(void)
#line 63
{
  if (HPLUSART0M$USARTControl$isI2C()) {
    HPLUSART0M$HPLI2CInterrupt$fired();
    }
  else {
#line 67
    HPLUSART0M$USARTData$txDone();
    }
}

# 56 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
void  __attribute((wakeup)) __attribute((interrupt(8))) sig_PORT1_VECTOR(void)
{
  volatile int n = MSP430InterruptM$P1IFG & MSP430InterruptM$P1IE;

  if (n & (1 << 0)) {
#line 60
      MSP430InterruptM$Port10$fired();
#line 60
      return;
    }
#line 61
  if (n & (1 << 1)) {
#line 61
      MSP430InterruptM$Port11$fired();
#line 61
      return;
    }
#line 62
  if (n & (1 << 2)) {
#line 62
      MSP430InterruptM$Port12$fired();
#line 62
      return;
    }
#line 63
  if (n & (1 << 3)) {
#line 63
      MSP430InterruptM$Port13$fired();
#line 63
      return;
    }
#line 64
  if (n & (1 << 4)) {
#line 64
      MSP430InterruptM$Port14$fired();
#line 64
      return;
    }
#line 65
  if (n & (1 << 5)) {
#line 65
      MSP430InterruptM$Port15$fired();
#line 65
      return;
    }
#line 66
  if (n & (1 << 6)) {
#line 66
      MSP430InterruptM$Port16$fired();
#line 66
      return;
    }
#line 67
  if (n & (1 << 7)) {
#line 67
      MSP430InterruptM$Port17$fired();
#line 67
      return;
    }
}

# 540 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/CC2420Radio/CC2420RadioM.nc"
static void CC2420RadioM$delayedRXFIFO(void)
#line 540
{
  uint8_t len = MSG_DATA_SIZE;
  uint8_t _bPacketReceiving;

  if (!TOSH_READ_CC_FIFO_PIN() && !TOSH_READ_CC_FIFOP_PIN()) {
      CC2420RadioM$flushRXFIFO();
      return;
    }

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 549
    {
      _bPacketReceiving = CC2420RadioM$bPacketReceiving;

      if (_bPacketReceiving) {
          if (!TOS_post(CC2420RadioM$delayedRXFIFOtask)) {
            CC2420RadioM$flushRXFIFO();
            }
        }
      else 
#line 555
        {
          CC2420RadioM$bPacketReceiving = TRUE;
        }
    }
#line 558
    __nesc_atomic_end(__nesc_atomic); }





  if (!_bPacketReceiving) {
      if (!CC2420RadioM$HPLChipconFIFO$readRXFIFO(len, (uint8_t *)CC2420RadioM$rxbufptr)) {
          { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 566
            CC2420RadioM$bPacketReceiving = FALSE;
#line 566
            __nesc_atomic_end(__nesc_atomic); }
          if (!TOS_post(CC2420RadioM$delayedRXFIFOtask)) {
              CC2420RadioM$flushRXFIFO();
            }
          return;
        }
    }
  CC2420RadioM$flushRXFIFO();
}

# 244 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/AMPromiscuous.nc"
TOS_MsgPtr   prom_received(TOS_MsgPtr packet)
#line 244
{
  AMPromiscuous$counter++;
  {
  }
#line 246
  ;




  if (
#line 248
  packet->group == TOS_AM_GROUP && ((
  AMPromiscuous$promiscuous_mode == TRUE || 
  packet->addr == TOS_BCAST_ADDR) || 
  packet->addr == TOS_LOCAL_ADDRESS) && (
  AMPromiscuous$crc_check == FALSE || packet->crc == 1)) 
    {
      uint8_t type = packet->type;
      TOS_MsgPtr tmp;


      {
      }
#line 258
      ;
      AMPromiscuous$dbgPacket(packet);
      {
      }
#line 260
      ;


      tmp = AMPromiscuous$ReceiveMsg$receive(type, packet);
      if (tmp) {
        packet = tmp;
        }
    }
#line 267
  return packet;
}

# 71 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430InterruptM.nc"
void  __attribute((wakeup)) __attribute((interrupt(2))) sig_PORT2_VECTOR(void)
{
  volatile int n = MSP430InterruptM$P2IFG & MSP430InterruptM$P2IE;

  if (n & (1 << 0)) {
#line 75
      MSP430InterruptM$Port20$fired();
#line 75
      return;
    }
#line 76
  if (n & (1 << 1)) {
#line 76
      MSP430InterruptM$Port21$fired();
#line 76
      return;
    }
#line 77
  if (n & (1 << 2)) {
#line 77
      MSP430InterruptM$Port22$fired();
#line 77
      return;
    }
#line 78
  if (n & (1 << 3)) {
#line 78
      MSP430InterruptM$Port23$fired();
#line 78
      return;
    }
#line 79
  if (n & (1 << 4)) {
#line 79
      MSP430InterruptM$Port24$fired();
#line 79
      return;
    }
#line 80
  if (n & (1 << 5)) {
#line 80
      MSP430InterruptM$Port25$fired();
#line 80
      return;
    }
#line 81
  if (n & (1 << 6)) {
#line 81
      MSP430InterruptM$Port26$fired();
#line 81
      return;
    }
#line 82
  if (n & (1 << 7)) {
#line 82
      MSP430InterruptM$Port27$fired();
#line 82
      return;
    }
}

#line 85
void  __attribute((wakeup)) __attribute((interrupt(28))) sig_NMI_VECTOR(void)
{
  volatile int n = IFG1;

#line 88
  if (n & (1 << 4)) {
#line 88
      MSP430InterruptM$NMI$fired();
#line 88
      return;
    }
#line 89
  if (n & (1 << 1)) {
#line 89
      MSP430InterruptM$OF$fired();
#line 89
      return;
    }
#line 90
  if (FCTL3 & 0x0004) {
#line 90
      MSP430InterruptM$ACCV$fired();
#line 90
      return;
    }
}

# 55 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
void  __attribute((wakeup)) __attribute((interrupt(6))) sig_UART1RX_VECTOR(void)
#line 55
{
  uint8_t temp = U1RXBUF;

#line 57
  HPLUSART1M$USARTData$rxDone(temp);
}

# 66 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/crc.h"
static uint16_t crcByte(uint16_t fcs, uint8_t c)
{
  fcs = ccitt_crc16_table[((fcs >> 8) ^ c) & 0xffU] ^ (fcs << 8);
  return fcs;
}

# 60 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLUSART1M.nc"
void  __attribute((wakeup)) __attribute((interrupt(4))) sig_UART1TX_VECTOR(void)
#line 60
{
  HPLUSART1M$USARTData$txDone();
}

# 469 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/system/FramerM.nc"
static result_t FramerM$TxArbitraryByte(uint8_t inByte)
#line 469
{
  if (inByte == FramerM$HDLC_FLAG_BYTE || inByte == FramerM$HDLC_CTLESC_BYTE) {
      {
        FramerM$gPrevTxState = FramerM$gTxState;
        FramerM$gTxState = FramerM$TXSTATE_ESC;
        FramerM$gTxEscByte = inByte;
      }
      inByte = FramerM$HDLC_CTLESC_BYTE;
    }

  return FramerM$ByteComm$txByte(inByte);
}

# 163 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
void  __attribute((wakeup)) __attribute((interrupt(14))) sig_ADC_VECTOR(void)
#line 163
{
  uint16_t iv = HPLADC12M$ADC12IV;

#line 165
  switch (iv) 
    {
      case 2: HPLADC12M$HPLADC12$memOverflow();
#line 167
      return;
      case 4: HPLADC12M$HPLADC12$timeOverflow();
#line 168
      return;
    }
  iv >>= 1;
  if (iv && iv < 19) {
    HPLADC12M$HPLADC12$converted(iv - 3);
    }
}

# 430 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/MSP430ADC12M.nc"
static void MSP430ADC12M$stopConversion(void)
{
  MSP430ADC12M$TimerA$setMode(MSP430TIMER_STOP_MODE);
  MSP430ADC12M$HPLADC12$stopConversion();
  MSP430ADC12M$HPLADC12$setIEFlags(0);
  MSP430ADC12M$HPLADC12$resetIFGs();
  if (MSP430ADC12M$adc12settings[MSP430ADC12M$owner].gotRefVolt) {
    MSP430ADC12M$releaseRefVolt(MSP430ADC12M$owner);
    }
#line 438
  MSP430ADC12M$cmode = ADC_IDLE;
}

# 98 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/HPLADC12M.nc"
static   void HPLADC12M$HPLADC12$resetIFGs(void)
#line 98
{

  if (!HPLADC12M$ADC12IFG) {
    return;
    }
  else 
#line 102
    {
      uint8_t i;
      volatile uint16_t mud;

#line 105
      for (i = 0; i < 16; i++) 
        mud = HPLADC12M$HPLADC12$getMem(i);
    }
}

# 185 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/ADCM.nc"
static   result_t ADCM$MSP430ADC12Single$dataReady(uint16_t d)
{
  if (!ADCM$continuousData) {
      ADCM$busy = FALSE;
      return ADCM$ADC$dataReady(ADCM$owner, d);
    }
  else {
#line 190
    if (ADCM$ADC$dataReady(ADCM$owner, d) == FAIL) {
        ADCM$busy = FALSE;
        return FAIL;
      }
    }
#line 194
  return SUCCESS;
}

# 2075 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/TinyDB/TupleRouterM.nc"
static void TupleRouterM$continueSetSampleRate(void)
#line 2075
{
  uint32_t epochDur;
  uint16_t aggWinSize;
  uint16_t mvPerDay;

#line 2079
  TupleRouterM$computeRates(TupleRouterM$mLifetime, TupleRouterM$mVoltage, 0, 0, 1, 1, &epochDur, &aggWinSize, &mvPerDay);
  {
  }
#line 2080
  ;
  TupleRouterM$setRate(TupleRouterM$mCurSampleRateQuery, (short )(epochDur & 0x00007FFF));
  TupleRouterM$UNSET_SETTING_SAMPLE_RATE();
}

# 139 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/lib/Attributes/AttrTempM.nc"
static  void AttrTempM$getAttrDone(void)
#line 139
{
  AttrTempM$AttrRegister$getAttrDone(AttrTempM$attrName, AttrTempM$result, SCHEMA_RESULT_READY);
}

# 159 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalVoltageM.nc"
static   uint16_t *InternalVoltageM$MSP430ADC12Multiple$dataReady(uint16_t *buf, uint16_t length)
{
  uint16_t *nextbuf;

#line 162
  if (!InternalVoltageM$contMode) {
    nextbuf = InternalVoltageM$ADCMultiple$dataReady(SUCCESS, buf, length);
    }
  else {
#line 165
    if ((nextbuf = InternalVoltageM$ADCMultiple$dataReady(SUCCESS, buf, length))) {
      InternalVoltageM$MSP430ADC12Multiple$getData(nextbuf, length, 0);
      }
    else {
#line 168
      InternalVoltageM$contMode = FALSE;
      }
    }
#line 169
  return nextbuf;
}

# 159 "C:/tinyos/cygwin/opt/tinyos-1.x/tos/platform/msp430/InternalTempM.nc"
static   uint16_t *InternalTempM$MSP430ADC12Multiple$dataReady(uint16_t *buf, uint16_t length)
{
  uint16_t *nextbuf;

#line 162
  if (!InternalTempM$contMode) {
    nextbuf = InternalTempM$ADCMultiple$dataReady(SUCCESS, buf, length);
    }
  else {
#line 165
    if ((nextbuf = InternalTempM$ADCMultiple$dataReady(SUCCESS, buf, length))) {
      InternalTempM$MSP430ADC12Multiple$getData(nextbuf, length, 0);
      }
    else {
#line 168
      InternalTempM$contMode = FALSE;
      }
    }
#line 169
  return nextbuf;
}

