#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
# 65 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/stdint.h"
typedef signed char int8_t;




typedef unsigned char uint8_t;
# 104 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/stdint.h" 3
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;
#line 155
typedef int16_t intptr_t;




typedef uint16_t uintptr_t;
# 290 "/home/coop/embed_home/local//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  ;
# 213 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/include/stddef.h" 3
typedef unsigned int size_t;
#line 325
typedef int wchar_t;
# 69 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/stdlib.h"
#line 66
typedef struct __nesc_unnamed4242 {
  int quot;
  int rem;
} div_t;





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


typedef int (*__compar_fn_t)(const void *, const void *);
# 151 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/include/stddef.h" 3
typedef int ptrdiff_t;
# 91 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/tos.h"
typedef unsigned char bool;






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



enum __nesc_unnamed4245 {
  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);
#line 140
enum __nesc_unnamed4246 {
  NULL = 0x0
};
# 90 "/home/coop/local/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/pgmspace.h"
typedef void prog_void __attribute((__progmem__)) ;
typedef char prog_char __attribute((__progmem__)) ;
typedef unsigned char prog_uchar __attribute((__progmem__)) ;

typedef int8_t prog_int8_t __attribute((__progmem__)) ;
typedef uint8_t prog_uint8_t __attribute((__progmem__)) ;
typedef int16_t prog_int16_t __attribute((__progmem__)) ;
typedef uint16_t prog_uint16_t __attribute((__progmem__)) ;

typedef int32_t prog_int32_t __attribute((__progmem__)) ;
typedef uint32_t prog_uint32_t __attribute((__progmem__)) ;


typedef int64_t prog_int64_t __attribute((__progmem__)) ;
typedef uint64_t prog_uint64_t __attribute((__progmem__)) ;
# 138 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
enum __nesc_unnamed4247 {
  TOSH_period16 = 0x00, 
  TOSH_period32 = 0x01, 
  TOSH_period64 = 0x02, 
  TOSH_period128 = 0x03, 
  TOSH_period256 = 0x04, 
  TOSH_period512 = 0x05, 
  TOSH_period1024 = 0x06, 
  TOSH_period2048 = 0x07
};

static inline void TOSH_wait(void);







typedef uint8_t __nesc_atomic_t;

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



__inline __nesc_atomic_t __nesc_atomic_start(void )  ;






__inline void __nesc_atomic_end(__nesc_atomic_t oldSreg)  ;






static __inline void __nesc_atomic_sleep(void);







static __inline void __nesc_enable_interrupt(void);



static __inline void __nesc_disable_interrupt(void);
# 116 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/hardware.h"
static __inline void TOSH_SET_RED_LED_PIN(void);
#line 116
static __inline void TOSH_CLR_RED_LED_PIN(void);
#line 116
static __inline void TOSH_MAKE_RED_LED_OUTPUT(void);
static __inline void TOSH_SET_GREEN_LED_PIN(void);
#line 117
static __inline void TOSH_MAKE_GREEN_LED_OUTPUT(void);
static __inline void TOSH_SET_YELLOW_LED_PIN(void);
#line 118
static __inline void TOSH_MAKE_YELLOW_LED_OUTPUT(void);

static __inline void TOSH_CLR_SERIAL_ID_PIN(void);
#line 120
static __inline void TOSH_MAKE_SERIAL_ID_INPUT(void);




static __inline void TOSH_MAKE_CC_CHP_OUT_INPUT(void);
static __inline void TOSH_MAKE_CC_PDATA_OUTPUT(void);
static __inline void TOSH_MAKE_CC_PCLK_OUTPUT(void);
static __inline void TOSH_MAKE_CC_PALE_OUTPUT(void);
#line 144
static __inline void TOSH_MAKE_MISO_INPUT(void);
static __inline void TOSH_MAKE_SPI_OC1C_INPUT(void);



static __inline void TOSH_MAKE_PW0_OUTPUT(void);
static __inline void TOSH_MAKE_PW1_OUTPUT(void);
static __inline void TOSH_MAKE_PW2_OUTPUT(void);
static __inline void TOSH_MAKE_PW3_OUTPUT(void);
static __inline void TOSH_MAKE_PW4_OUTPUT(void);
static __inline void TOSH_MAKE_PW5_OUTPUT(void);
static __inline void TOSH_MAKE_PW6_OUTPUT(void);
static __inline void TOSH_MAKE_PW7_OUTPUT(void);
#line 176
static inline void TOSH_SET_PIN_DIRECTIONS(void );
#line 206
enum __nesc_unnamed4248 {
  TOSH_ADC_PORTMAPSIZE = 12
};

enum __nesc_unnamed4249 {

  TOSH_ACTUAL_CC_RSSI_PORT = 0, 
  TOSH_ACTUAL_BANDGAP_PORT = 30, 
  TOSH_ACTUAL_GND_PORT = 31
};

enum __nesc_unnamed4250 {

  TOS_ADC_CC_RSSI_PORT = 0, 
  TOS_ADC_BANDGAP_PORT = 10, 
  TOS_ADC_GND_PORT = 11
};
# 54 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/types/dbg_modes.h"
typedef long long TOS_dbg_mode;



enum __nesc_unnamed4251 {
  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 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/sched.c"
#line 59
typedef struct __nesc_unnamed4252 {
  void (*tp)(void);
} TOSH_sched_entry_T;

enum __nesc_unnamed4253 {






  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);
# 28 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/Ident.h"
enum __nesc_unnamed4254 {

  IDENT_MAX_PROGRAM_NAME_LENGTH = 16
};






#line 33
typedef struct __nesc_unnamed4255 {

  uint32_t unix_time;
  uint32_t user_hash;
  char program_name[IDENT_MAX_PROGRAM_NAME_LENGTH];
} Ident_t;
# 39 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.h"
enum __nesc_unnamed4256 {
  TIMER_REPEAT = 0, 
  TIMER_ONE_SHOT = 1, 
  NUM_TIMERS = 1U
};
# 33 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica128/Clock.h"
enum __nesc_unnamed4257 {
  TOS_I1000PS = 32, TOS_S1000PS = 1, 
  TOS_I100PS = 40, TOS_S100PS = 2, 
  TOS_I10PS = 101, TOS_S10PS = 3, 
  TOS_I1024PS = 0, TOS_S1024PS = 3, 
  TOS_I512PS = 1, TOS_S512PS = 3, 
  TOS_I256PS = 3, TOS_S256PS = 3, 
  TOS_I128PS = 7, TOS_S128PS = 3, 
  TOS_I64PS = 15, TOS_S64PS = 3, 
  TOS_I32PS = 31, TOS_S32PS = 3, 
  TOS_I16PS = 63, TOS_S16PS = 3, 
  TOS_I8PS = 127, TOS_S8PS = 3, 
  TOS_I4PS = 255, TOS_S4PS = 3, 
  TOS_I2PS = 15, TOS_S2PS = 7, 
  TOS_I1PS = 31, TOS_S1PS = 7, 
  TOS_I0PS = 0, TOS_S0PS = 0
};
enum __nesc_unnamed4258 {
  DEFAULT_SCALE = 3, DEFAULT_INTERVAL = 127
};
# 78 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Pot.nc"
static  result_t PotM$Pot$init(uint8_t arg_0x4035db98);
# 74 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/HPLPot.nc"
static  result_t HPLPotC$Pot$finalise(void);
#line 59
static  result_t HPLPotC$Pot$decrease(void);







static  result_t HPLPotC$Pot$increase(void);
# 52 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/HPLInit.nc"
static  result_t HPLInit$init(void);
# 63 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t BlinkM$StdControl$init(void);






static  result_t BlinkM$StdControl$start(void);
# 73 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t BlinkM$Timer$fired(void);
# 180 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
static   result_t TimerM$Clock$fire(void);
# 63 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t TimerM$StdControl$init(void);






static  result_t TimerM$StdControl$start(void);
# 73 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t TimerM$Timer$default$fired(
# 49 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
uint8_t arg_0x40387f20);
# 59 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t TimerM$Timer$start(
# 49 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
uint8_t arg_0x40387f20, 
# 59 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
char arg_0x40378290, uint32_t arg_0x40378420);
# 105 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
static   void HPLClock$Clock$setInterval(uint8_t arg_0x40395918);
#line 153
static   uint8_t HPLClock$Clock$readCounter(void);
#line 96
static   result_t HPLClock$Clock$setRate(char arg_0x4039cc68, char arg_0x4039cde0);
#line 121
static   uint8_t HPLClock$Clock$getInterval(void);
# 41 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/PowerManagement.nc"
static   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
# 56 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t LedsC$Leds$init(void);
#line 72
static   result_t LedsC$Leds$redOff(void);








static   result_t LedsC$Leds$redToggle(void);
#line 64
static   result_t LedsC$Leds$redOn(void);
# 47 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/RealMain.nc"
static  result_t RealMain$hardwareInit(void);
# 78 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Pot.nc"
static  result_t RealMain$Pot$init(uint8_t arg_0x4035db98);
# 63 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/StdControl.nc"
static  result_t RealMain$StdControl$init(void);






static  result_t RealMain$StdControl$start(void);
# 54 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/RealMain.nc"
int main(void)   ;
# 74 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/HPLPot.nc"
static  result_t PotM$HPLPot$finalise(void);
#line 59
static  result_t PotM$HPLPot$decrease(void);







static  result_t PotM$HPLPot$increase(void);
# 91 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/PotM.nc"
uint8_t PotM$potSetting;

static inline void PotM$setPot(uint8_t value);
#line 106
static inline  result_t PotM$Pot$init(uint8_t initialSetting);
# 57 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"
static inline  result_t HPLPotC$Pot$decrease(void);








static inline  result_t HPLPotC$Pot$increase(void);








static inline  result_t HPLPotC$Pot$finalise(void);
# 57 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/HPLInit.nc"
static inline  result_t HPLInit$init(void);
# 56 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Leds.nc"
static   result_t BlinkM$Leds$init(void);
#line 81
static   result_t BlinkM$Leds$redToggle(void);
# 59 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t BlinkM$Timer$start(char arg_0x40378290, uint32_t arg_0x40378420);
# 52 "BlinkM.nc"
static inline  result_t BlinkM$StdControl$init(void);










static inline  result_t BlinkM$StdControl$start(void);
#line 84
static inline  result_t BlinkM$Timer$fired(void);
# 41 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/PowerManagement.nc"
static   uint8_t TimerM$PowerManagement$adjustPower(void);
# 105 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
static   void TimerM$Clock$setInterval(uint8_t arg_0x40395918);
#line 153
static   uint8_t TimerM$Clock$readCounter(void);
#line 96
static   result_t TimerM$Clock$setRate(char arg_0x4039cc68, char arg_0x4039cde0);
#line 121
static   uint8_t TimerM$Clock$getInterval(void);
# 73 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
static  result_t TimerM$Timer$fired(
# 49 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
uint8_t arg_0x40387f20);









uint32_t TimerM$mState;
uint8_t TimerM$setIntervalFlag;
uint8_t TimerM$mScale;
#line 61
uint8_t TimerM$mInterval;
int8_t TimerM$queue_head;
int8_t TimerM$queue_tail;
uint8_t TimerM$queue_size;
uint8_t TimerM$queue[NUM_TIMERS];
volatile uint16_t TimerM$interval_outstanding;





#line 68
struct TimerM$timer_s {
  uint8_t type;
  int32_t ticks;
  int32_t ticksLeft;
} TimerM$mTimerList[NUM_TIMERS];

enum TimerM$__nesc_unnamed4259 {
  TimerM$maxTimerInterval = 230
};
static inline  result_t TimerM$StdControl$init(void);









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










static inline  result_t TimerM$Timer$start(uint8_t id, char type, 
uint32_t interval);
#line 129
inline static void TimerM$adjustInterval(void);
#line 182
static inline   result_t TimerM$Timer$default$fired(uint8_t id);



static inline void TimerM$enqueue(uint8_t value);







static inline uint8_t TimerM$dequeue(void);









static inline  void TimerM$signalOneTimer(void);





static inline  void TimerM$HandleFire(void);
#line 253
static inline   result_t TimerM$Clock$fire(void);
# 180 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
static   result_t HPLClock$Clock$fire(void);
# 54 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
uint8_t HPLClock$set_flag;
uint8_t HPLClock$mscale;
#line 55
uint8_t HPLClock$nextScale;
#line 55
uint8_t HPLClock$minterval;
#line 87
static inline   void HPLClock$Clock$setInterval(uint8_t value);









static inline   uint8_t HPLClock$Clock$getInterval(void);
#line 134
static inline   uint8_t HPLClock$Clock$readCounter(void);
#line 149
static inline   result_t HPLClock$Clock$setRate(char interval, char scale);
#line 167
void __vector_15(void)   __attribute((interrupt)) ;
# 51 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPowerManagementM.nc"
int8_t HPLPowerManagementM$disableCount = 1;
uint8_t HPLPowerManagementM$powerLevel;

enum HPLPowerManagementM$__nesc_unnamed4260 {
  HPLPowerManagementM$IDLE = 0, 
  HPLPowerManagementM$ADC_NR = 1 << 3, 
  HPLPowerManagementM$POWER_DOWN = 1 << 4, 
  HPLPowerManagementM$POWER_SAVE = (1 << 3) + (1 << 4), 
  HPLPowerManagementM$STANDBY = (1 << 2) + (1 << 4), 
  HPLPowerManagementM$EXT_STANDBY = (1 << 3) + (1 << 4) + (1 << 2)
};


static inline uint8_t HPLPowerManagementM$getPowerLevel(void);
#line 85
static inline  void HPLPowerManagementM$doAdjustment(void);
#line 102
static   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void);
# 50 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/LedsC.nc"
uint8_t LedsC$ledsOn;

enum LedsC$__nesc_unnamed4261 {
  LedsC$RED_BIT = 1, 
  LedsC$GREEN_BIT = 2, 
  LedsC$YELLOW_BIT = 4
};

static inline   result_t LedsC$Leds$init(void);
#line 72
static inline   result_t LedsC$Leds$redOn(void);








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








static inline   result_t LedsC$Leds$redToggle(void);
# 120 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/hardware.h"
static __inline void TOSH_CLR_SERIAL_ID_PIN(void)
#line 120
{
#line 120
  * (volatile uint8_t *)(0x1B + 0x20) &= ~(1 << 4);
}

#line 120
static __inline void TOSH_MAKE_SERIAL_ID_INPUT(void)
#line 120
{
#line 120
  * (volatile uint8_t *)(0x1A + 0x20) &= ~(1 << 4);
}

#line 145
static __inline void TOSH_MAKE_SPI_OC1C_INPUT(void)
#line 145
{
#line 145
  * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 7);
}

#line 144
static __inline void TOSH_MAKE_MISO_INPUT(void)
#line 144
{
#line 144
  * (volatile uint8_t *)(0x17 + 0x20) &= ~(1 << 3);
}

#line 127
static __inline void TOSH_MAKE_CC_PCLK_OUTPUT(void)
#line 127
{
#line 127
  * (volatile uint8_t *)(0x11 + 0x20) |= 1 << 6;
}

#line 126
static __inline void TOSH_MAKE_CC_PDATA_OUTPUT(void)
#line 126
{
#line 126
  * (volatile uint8_t *)(0x11 + 0x20) |= 1 << 7;
}

#line 128
static __inline void TOSH_MAKE_CC_PALE_OUTPUT(void)
#line 128
{
#line 128
  * (volatile uint8_t *)(0x11 + 0x20) |= 1 << 4;
}

#line 149
static __inline void TOSH_MAKE_PW0_OUTPUT(void)
#line 149
{
#line 149
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 0;
}

#line 150
static __inline void TOSH_MAKE_PW1_OUTPUT(void)
#line 150
{
#line 150
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 1;
}

#line 151
static __inline void TOSH_MAKE_PW2_OUTPUT(void)
#line 151
{
#line 151
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 2;
}

#line 152
static __inline void TOSH_MAKE_PW3_OUTPUT(void)
#line 152
{
#line 152
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 3;
}

#line 153
static __inline void TOSH_MAKE_PW4_OUTPUT(void)
#line 153
{
#line 153
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 4;
}

#line 154
static __inline void TOSH_MAKE_PW5_OUTPUT(void)
#line 154
{
#line 154
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 5;
}

#line 155
static __inline void TOSH_MAKE_PW6_OUTPUT(void)
#line 155
{
#line 155
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 6;
}

#line 156
static __inline void TOSH_MAKE_PW7_OUTPUT(void)
#line 156
{
#line 156
  * (volatile uint8_t *)(0x14 + 0x20) |= 1 << 7;
}

#line 125
static __inline void TOSH_MAKE_CC_CHP_OUT_INPUT(void)
#line 125
{
#line 125
  * (volatile uint8_t *)(0x1A + 0x20) &= ~(1 << 6);
}

#line 176
static inline void TOSH_SET_PIN_DIRECTIONS(void )
{







  TOSH_MAKE_CC_CHP_OUT_INPUT();

  TOSH_MAKE_PW7_OUTPUT();
  TOSH_MAKE_PW6_OUTPUT();
  TOSH_MAKE_PW5_OUTPUT();
  TOSH_MAKE_PW4_OUTPUT();
  TOSH_MAKE_PW3_OUTPUT();
  TOSH_MAKE_PW2_OUTPUT();
  TOSH_MAKE_PW1_OUTPUT();
  TOSH_MAKE_PW0_OUTPUT();

  TOSH_MAKE_CC_PALE_OUTPUT();
  TOSH_MAKE_CC_PDATA_OUTPUT();
  TOSH_MAKE_CC_PCLK_OUTPUT();
  TOSH_MAKE_MISO_INPUT();
  TOSH_MAKE_SPI_OC1C_INPUT();

  TOSH_MAKE_SERIAL_ID_INPUT();
  TOSH_CLR_SERIAL_ID_PIN();
}

# 57 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/HPLInit.nc"
static inline  result_t HPLInit$init(void)
#line 57
{
  TOSH_SET_PIN_DIRECTIONS();
  return SUCCESS;
}

# 47 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/RealMain.nc"
inline static  result_t RealMain$hardwareInit(void){
#line 47
  unsigned char result;
#line 47

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

#line 47
  return result;
#line 47
}
#line 47
# 75 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"
static inline  result_t HPLPotC$Pot$finalise(void)
#line 75
{


  return SUCCESS;
}

# 74 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/HPLPot.nc"
inline static  result_t PotM$HPLPot$finalise(void){
#line 74
  unsigned char result;
#line 74

#line 74
  result = HPLPotC$Pot$finalise();
#line 74

#line 74
  return result;
#line 74
}
#line 74
# 66 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"
static inline  result_t HPLPotC$Pot$increase(void)
#line 66
{





  return SUCCESS;
}

# 67 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/HPLPot.nc"
inline static  result_t PotM$HPLPot$increase(void){
#line 67
  unsigned char result;
#line 67

#line 67
  result = HPLPotC$Pot$increase();
#line 67

#line 67
  return result;
#line 67
}
#line 67
# 57 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPotC.nc"
static inline  result_t HPLPotC$Pot$decrease(void)
#line 57
{





  return SUCCESS;
}

# 59 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/HPLPot.nc"
inline static  result_t PotM$HPLPot$decrease(void){
#line 59
  unsigned char result;
#line 59

#line 59
  result = HPLPotC$Pot$decrease();
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 93 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/PotM.nc"
static inline void PotM$setPot(uint8_t value)
#line 93
{
  uint8_t i;

#line 95
  for (i = 0; i < 151; i++) 
    PotM$HPLPot$decrease();

  for (i = 0; i < value; i++) 
    PotM$HPLPot$increase();

  PotM$HPLPot$finalise();

  PotM$potSetting = value;
}

static inline  result_t PotM$Pot$init(uint8_t initialSetting)
#line 106
{
  PotM$setPot(initialSetting);
  return SUCCESS;
}

# 78 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Pot.nc"
inline static  result_t RealMain$Pot$init(uint8_t arg_0x4035db98){
#line 78
  unsigned char result;
#line 78

#line 78
  result = PotM$Pot$init(arg_0x4035db98);
#line 78

#line 78
  return result;
#line 78
}
#line 78
# 79 "/uusoc/res/embed/users/coop/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 = (void *)0;
}

# 120 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/tos.h"
static inline result_t rcombine(result_t r1, result_t r2)



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

# 117 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/hardware.h"
static __inline void TOSH_SET_GREEN_LED_PIN(void)
#line 117
{
#line 117
  * (volatile uint8_t *)(0x1B + 0x20) |= 1 << 1;
}

#line 118
static __inline void TOSH_SET_YELLOW_LED_PIN(void)
#line 118
{
#line 118
  * (volatile uint8_t *)(0x1B + 0x20) |= 1 << 0;
}

#line 116
static __inline void TOSH_SET_RED_LED_PIN(void)
#line 116
{
#line 116
  * (volatile uint8_t *)(0x1B + 0x20) |= 1 << 2;
}

#line 117
static __inline void TOSH_MAKE_GREEN_LED_OUTPUT(void)
#line 117
{
#line 117
  * (volatile uint8_t *)(0x1A + 0x20) |= 1 << 1;
}

#line 118
static __inline void TOSH_MAKE_YELLOW_LED_OUTPUT(void)
#line 118
{
#line 118
  * (volatile uint8_t *)(0x1A + 0x20) |= 1 << 0;
}

#line 116
static __inline void TOSH_MAKE_RED_LED_OUTPUT(void)
#line 116
{
#line 116
  * (volatile uint8_t *)(0x1A + 0x20) |= 1 << 2;
}

# 58 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$init(void)
#line 58
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 59
    {
      LedsC$ledsOn = 0;
      {
      }
#line 61
      ;
      TOSH_MAKE_RED_LED_OUTPUT();
      TOSH_MAKE_YELLOW_LED_OUTPUT();
      TOSH_MAKE_GREEN_LED_OUTPUT();
      TOSH_SET_RED_LED_PIN();
      TOSH_SET_YELLOW_LED_PIN();
      TOSH_SET_GREEN_LED_PIN();
    }
#line 68
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 56 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t BlinkM$Leds$init(void){
#line 56
  unsigned char result;
#line 56

#line 56
  result = LedsC$Leds$init();
#line 56

#line 56
  return result;
#line 56
}
#line 56
# 52 "BlinkM.nc"
static inline  result_t BlinkM$StdControl$init(void)
#line 52
{
  BlinkM$Leds$init();
  return SUCCESS;
}

# 149 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
static inline   result_t HPLClock$Clock$setRate(char interval, char scale)
#line 149
{
  scale &= 0x7;
  scale |= 0x8;
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 152
    {
      * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 0);
      * (volatile uint8_t *)(0x37 + 0x20) &= ~(1 << 1);
      * (volatile uint8_t *)(0x30 + 0x20) |= 1 << 3;


      * (volatile uint8_t *)(0x33 + 0x20) = scale;
      * (volatile uint8_t *)(0x32 + 0x20) = 0;
      * (volatile uint8_t *)(0x31 + 0x20) = interval;
      * (volatile uint8_t *)(0x37 + 0x20) |= 1 << 1;
    }
#line 162
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 96 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
inline static   result_t TimerM$Clock$setRate(char arg_0x4039cc68, char arg_0x4039cde0){
#line 96
  unsigned char result;
#line 96

#line 96
  result = HPLClock$Clock$setRate(arg_0x4039cc68, arg_0x4039cde0);
#line 96

#line 96
  return result;
#line 96
}
#line 96
# 77 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
static inline  result_t TimerM$StdControl$init(void)
#line 77
{
  TimerM$mState = 0;
  TimerM$setIntervalFlag = 0;
  TimerM$queue_head = TimerM$queue_tail = -1;
  TimerM$queue_size = 0;
  TimerM$mScale = 3;
  TimerM$mInterval = TimerM$maxTimerInterval;
  return TimerM$Clock$setRate(TimerM$mInterval, TimerM$mScale);
}

# 63 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t RealMain$StdControl$init(void){
#line 63
  unsigned char result;
#line 63

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

#line 63
  return result;
#line 63
}
#line 63
# 41 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/PowerManagement.nc"
inline static   uint8_t TimerM$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
# 87 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
static inline   void HPLClock$Clock$setInterval(uint8_t value)
#line 87
{
  * (volatile uint8_t *)(0x31 + 0x20) = value;
}

# 105 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
inline static   void TimerM$Clock$setInterval(uint8_t arg_0x40395918){
#line 105
  HPLClock$Clock$setInterval(arg_0x40395918);
#line 105
}
#line 105
# 134 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
static inline   uint8_t HPLClock$Clock$readCounter(void)
#line 134
{
  return * (volatile uint8_t *)(0x32 + 0x20);
}

# 153 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
inline static   uint8_t TimerM$Clock$readCounter(void){
#line 153
  unsigned char result;
#line 153

#line 153
  result = HPLClock$Clock$readCounter();
#line 153

#line 153
  return result;
#line 153
}
#line 153
# 98 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
static inline  result_t TimerM$Timer$start(uint8_t id, char type, 
uint32_t interval)
#line 99
{
  uint8_t diff;

#line 101
  if (id >= NUM_TIMERS) {
#line 101
    return FAIL;
    }
#line 102
  if (type > TIMER_ONE_SHOT) {
#line 102
    return FAIL;
    }





  if (type == TIMER_REPEAT && interval <= 2) {
#line 109
    return FAIL;
    }
  TimerM$mTimerList[id].ticks = interval;
  TimerM$mTimerList[id].type = type;

  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 114
    {
      diff = TimerM$Clock$readCounter();
      interval += diff;
      TimerM$mTimerList[id].ticksLeft = interval;
      TimerM$mState |= 0x1L << id;
      if (interval < TimerM$mInterval) {
          TimerM$mInterval = interval;
          TimerM$Clock$setInterval(TimerM$mInterval);
          TimerM$setIntervalFlag = 0;
          TimerM$PowerManagement$adjustPower();
        }
    }
#line 125
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 59 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t BlinkM$Timer$start(char arg_0x40378290, uint32_t arg_0x40378420){
#line 59
  unsigned char result;
#line 59

#line 59
  result = TimerM$Timer$start(0U, arg_0x40378290, arg_0x40378420);
#line 59

#line 59
  return result;
#line 59
}
#line 59
# 63 "BlinkM.nc"
static inline  result_t BlinkM$StdControl$start(void)
#line 63
{

  return BlinkM$Timer$start(TIMER_REPEAT, 1000);
}

# 87 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
static inline  result_t TimerM$StdControl$start(void)
#line 87
{
  return SUCCESS;
}

# 70 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/StdControl.nc"
inline static  result_t RealMain$StdControl$start(void){
#line 70
  unsigned char result;
#line 70

#line 70
  result = TimerM$StdControl$start();
#line 70
  result = rcombine(result, BlinkM$StdControl$start());
#line 70

#line 70
  return result;
#line 70
}
#line 70
# 64 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPowerManagementM.nc"
static inline uint8_t HPLPowerManagementM$getPowerLevel(void)
#line 64
{
  uint8_t diff;

#line 66
  if (* (volatile uint8_t *)(0x37 + 0x20) & ~((1 << 1) | (1 << 0))) {

      return HPLPowerManagementM$IDLE;
    }
  else {
#line 69
    if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x0D + 0x20) & (1 << 7)) {
        return HPLPowerManagementM$IDLE;
      }
    else {
      if (* (volatile uint8_t *)(uint16_t )& * (volatile uint8_t *)(0x06 + 0x20) & (1 << 7)) {
          return HPLPowerManagementM$ADC_NR;
        }
      else {
#line 75
        if (* (volatile uint8_t *)(0x37 + 0x20) & ((1 << 1) | (1 << 0))) {
            diff = * (volatile uint8_t *)(0x31 + 0x20) - * (volatile uint8_t *)(0x32 + 0x20);
            if (diff < 16) {
              return HPLPowerManagementM$EXT_STANDBY;
              }
#line 79
            return HPLPowerManagementM$POWER_SAVE;
          }
        else 
#line 80
          {
            return HPLPowerManagementM$POWER_DOWN;
          }
        }
      }
    }
}

#line 85
static inline  void HPLPowerManagementM$doAdjustment(void)
#line 85
{
  uint8_t foo;
#line 86
  uint8_t mcu;

#line 87
  HPLPowerManagementM$powerLevel = foo = HPLPowerManagementM$getPowerLevel();
  mcu = * (volatile uint8_t *)(0x35 + 0x20);
  mcu &= 0xe3;
  if (foo == HPLPowerManagementM$EXT_STANDBY || foo == HPLPowerManagementM$POWER_SAVE) {
      mcu |= HPLPowerManagementM$IDLE;
      while ((* (volatile uint8_t *)(0x30 + 0x20) & 0x7) != 0) {
           __asm volatile ("nop");}

      mcu &= 0xe3;
    }
  mcu |= foo;
  * (volatile uint8_t *)(0x35 + 0x20) = mcu;
  * (volatile uint8_t *)(0x35 + 0x20) |= 1 << 5;
}

# 186 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
static __inline void __nesc_enable_interrupt(void)
#line 186
{
   __asm volatile ("sei");}

#line 171
 __inline void __nesc_atomic_end(__nesc_atomic_t oldSreg)
{
  * (volatile uint8_t *)(0x3F + 0x20) = oldSreg;
}

#line 149
static inline void TOSH_wait(void)
{
   __asm volatile ("nop");
   __asm volatile ("nop");}

#line 178
static __inline void __nesc_atomic_sleep(void)
{

   __asm volatile ("sei");
   __asm volatile ("sleep");
  TOSH_wait();
}

#line 164
 __inline __nesc_atomic_t __nesc_atomic_start(void )
{
  __nesc_atomic_t result = * (volatile uint8_t *)(0x3F + 0x20);

#line 167
   __asm volatile ("cli");
  return result;
}

# 136 "/uusoc/res/embed/users/coop/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 == (void *)0) 
    {
      __nesc_atomic_sleep();
      return 0;
    }

  TOSH_queue[old_full].tp = (void *)0;
  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();
}

# 97 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
static inline   uint8_t HPLClock$Clock$getInterval(void)
#line 97
{
  return * (volatile uint8_t *)(0x31 + 0x20);
}

# 121 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
inline static   uint8_t TimerM$Clock$getInterval(void){
#line 121
  unsigned char result;
#line 121

#line 121
  result = HPLClock$Clock$getInterval();
#line 121

#line 121
  return result;
#line 121
}
#line 121
# 129 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
inline static void TimerM$adjustInterval(void)
#line 129
{
  uint8_t i;
#line 130
  uint8_t val = TimerM$maxTimerInterval;

#line 131
  if (TimerM$mState) {
      for (i = 0; i < NUM_TIMERS; i++) {
          if (TimerM$mState & (0x1L << i) && TimerM$mTimerList[i].ticksLeft < val) {
              val = TimerM$mTimerList[i].ticksLeft;
            }
        }
#line 148
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 148
        {
          i = TimerM$Clock$readCounter() + 3;
          if (val < i) {
              val = i;
            }
          TimerM$mInterval = val;
          TimerM$Clock$setInterval(TimerM$mInterval);
          TimerM$setIntervalFlag = 0;
        }
#line 156
        __nesc_atomic_end(__nesc_atomic); }
    }
  else {
      { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 159
        {
          TimerM$mInterval = TimerM$maxTimerInterval;
          TimerM$Clock$setInterval(TimerM$mInterval);
          TimerM$setIntervalFlag = 0;
        }
#line 163
        __nesc_atomic_end(__nesc_atomic); }
    }
  TimerM$PowerManagement$adjustPower();
}

#line 186
static inline void TimerM$enqueue(uint8_t value)
#line 186
{
  if (TimerM$queue_tail == NUM_TIMERS - 1) {
    TimerM$queue_tail = -1;
    }
#line 189
  TimerM$queue_tail++;
  TimerM$queue_size++;
  TimerM$queue[(uint8_t )TimerM$queue_tail] = value;
}

# 116 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/hardware.h"
static __inline void TOSH_CLR_RED_LED_PIN(void)
#line 116
{
#line 116
  * (volatile uint8_t *)(0x1B + 0x20) &= ~(1 << 2);
}

# 72 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/LedsC.nc"
static inline   result_t LedsC$Leds$redOn(void)
#line 72
{
  {
  }
#line 73
  ;
  /* atomic removed: atomic calls only */
#line 74
  {
    TOSH_CLR_RED_LED_PIN();
    LedsC$ledsOn |= LedsC$RED_BIT;
  }
  return SUCCESS;
}

static inline   result_t LedsC$Leds$redOff(void)
#line 81
{
  {
  }
#line 82
  ;
  /* atomic removed: atomic calls only */
#line 83
  {
    TOSH_SET_RED_LED_PIN();
    LedsC$ledsOn &= ~LedsC$RED_BIT;
  }
  return SUCCESS;
}

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

# 81 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Leds.nc"
inline static   result_t BlinkM$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
# 84 "BlinkM.nc"
static inline  result_t BlinkM$Timer$fired(void)
{
  BlinkM$Leds$redToggle();
  return SUCCESS;
}

# 182 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
static inline   result_t TimerM$Timer$default$fired(uint8_t id)
#line 182
{
  return SUCCESS;
}

# 73 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Timer.nc"
inline static  result_t TimerM$Timer$fired(uint8_t arg_0x40387f20){
#line 73
  unsigned char result;
#line 73

#line 73
  switch (arg_0x40387f20) {
#line 73
    case 0U:
#line 73
      result = BlinkM$Timer$fired();
#line 73
      break;
#line 73
    default:
#line 73
      result = TimerM$Timer$default$fired(arg_0x40387f20);
#line 73
      break;
#line 73
    }
#line 73

#line 73
  return result;
#line 73
}
#line 73
# 194 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/TimerM.nc"
static inline uint8_t TimerM$dequeue(void)
#line 194
{
  if (TimerM$queue_size == 0) {
    return NUM_TIMERS;
    }
#line 197
  if (TimerM$queue_head == NUM_TIMERS - 1) {
    TimerM$queue_head = -1;
    }
#line 199
  TimerM$queue_head++;
  TimerM$queue_size--;
  return TimerM$queue[(uint8_t )TimerM$queue_head];
}

static inline  void TimerM$signalOneTimer(void)
#line 204
{
  uint8_t itimer = TimerM$dequeue();

#line 206
  if (itimer < NUM_TIMERS) {
    TimerM$Timer$fired(itimer);
    }
}

#line 210
static inline  void TimerM$HandleFire(void)
#line 210
{
  uint8_t i;
  uint16_t int_out;

#line 213
  TimerM$setIntervalFlag = 1;


  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 216
    {
      int_out = TimerM$interval_outstanding;
      TimerM$interval_outstanding = 0;
    }
#line 219
    __nesc_atomic_end(__nesc_atomic); }
  if (TimerM$mState) {
      for (i = 0; i < NUM_TIMERS; i++) {
          if (TimerM$mState & (0x1L << i)) {
              TimerM$mTimerList[i].ticksLeft -= int_out;
              if (TimerM$mTimerList[i].ticksLeft <= 2) {


                  if (TOS_post(TimerM$signalOneTimer)) {
                      if (TimerM$mTimerList[i].type == TIMER_REPEAT) {
                          TimerM$mTimerList[i].ticksLeft += TimerM$mTimerList[i].ticks;
                        }
                      else 
#line 230
                        {
                          TimerM$mState &= ~(0x1L << i);
                        }
                      TimerM$enqueue(i);
                    }
                  else {
                      {
                      }
#line 236
                      ;


                      TimerM$mTimerList[i].ticksLeft = TimerM$mInterval;
                    }
                }
            }
        }
    }


  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 247
    int_out = TimerM$interval_outstanding;
#line 247
    __nesc_atomic_end(__nesc_atomic); }
  if (int_out == 0) {
    TimerM$adjustInterval();
    }
}

static inline   result_t TimerM$Clock$fire(void)
#line 253
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 254
    {



      if (TimerM$interval_outstanding == 0) {
        TOS_post(TimerM$HandleFire);
        }
      else {
        }
#line 261
      ;

      TimerM$interval_outstanding += TimerM$Clock$getInterval() + 1;
    }
#line 264
    __nesc_atomic_end(__nesc_atomic); }
  return SUCCESS;
}

# 180 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/interfaces/Clock.nc"
inline static   result_t HPLClock$Clock$fire(void){
#line 180
  unsigned char result;
#line 180

#line 180
  result = TimerM$Clock$fire();
#line 180

#line 180
  return result;
#line 180
}
#line 180
# 190 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/avrmote/avrhardware.h"
static __inline void __nesc_disable_interrupt(void)
#line 190
{
   __asm volatile ("cli");}

# 102 "/uusoc/res/embed/users/coop/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 == (void *)0) {
      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;
    }
}

# 54 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/system/RealMain.nc"
  int main(void)
#line 54
{
  RealMain$hardwareInit();
  RealMain$Pot$init(10);
  TOSH_sched_init();

  RealMain$StdControl$init();
  RealMain$StdControl$start();
  __nesc_enable_interrupt();

  while (1) {
      TOSH_run_task();
    }
}

# 102 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica2/HPLPowerManagementM.nc"
static   uint8_t HPLPowerManagementM$PowerManagement$adjustPower(void)
#line 102
{
  uint8_t mcu;

#line 104
  if (HPLPowerManagementM$disableCount <= 0) {
    TOS_post(HPLPowerManagementM$doAdjustment);
    }
  else 
#line 106
    {
      mcu = * (volatile uint8_t *)(0x35 + 0x20);
      mcu &= 0xe3;
      mcu |= HPLPowerManagementM$IDLE;
      * (volatile uint8_t *)(0x35 + 0x20) = mcu;
      * (volatile uint8_t *)(0x35 + 0x20) |= 1 << 5;
    }
  return 0;
}

# 167 "/uusoc/res/embed/users/coop/tinyos-1.x/tos/platform/mica/HPLClock.nc"
  __attribute((interrupt)) void __vector_15(void)
#line 167
{
  { __nesc_atomic_t __nesc_atomic = __nesc_atomic_start();
#line 168
    {
      if (HPLClock$set_flag) {
          HPLClock$mscale = HPLClock$nextScale;
          HPLClock$nextScale |= 0x8;
          * (volatile uint8_t *)(0x33 + 0x20) = HPLClock$nextScale;

          * (volatile uint8_t *)(0x31 + 0x20) = HPLClock$minterval;
          HPLClock$set_flag = 0;
        }
    }
#line 177
    __nesc_atomic_end(__nesc_atomic); }
  HPLClock$Clock$fire();
}

