vPortGetHeapStats (struct HeapStats_t * pxHeapStats)
{
  size_t xMinSize;
  size_t xMaxSize;
  size_t xBlocks;
  struct BlockLink_t * pxBlock;

  <bb 2> :
  xBlocks = 0;
  xMaxSize = 0;
  xMinSize = 4294967295;
  vTaskSuspendAll ();
  pxBlock = xStart.pxNextFreeBlock;
  if (pxBlock != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 3> :
  xBlocks = xBlocks + 1;
  _1 = pxBlock->xBlockSize;
  if (xMaxSize < _1)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  xMaxSize = pxBlock->xBlockSize;

  <bb 5> :
  _2 = pxBlock->xBlockSize;
  if (xMinSize > _2)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  xMinSize = pxBlock->xBlockSize;

  <bb 7> :
  pxBlock = pxBlock->pxNextFreeBlock;
  pxEnd.32_3 = pxEnd;
  if (pxBlock != pxEnd.32_3)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 8> :
  xTaskResumeAll ();
  pxHeapStats->xSizeOfLargestFreeBlockInBytes = xMaxSize;
  pxHeapStats->xSizeOfSmallestFreeBlockInBytes = xMinSize;
  pxHeapStats->xNumberOfFreeBlocks = xBlocks;
  vPortEnterCritical ();
  xFreeBytesRemaining.33_4 = xFreeBytesRemaining;
  pxHeapStats->xAvailableHeapSpaceInBytes = xFreeBytesRemaining.33_4;
  xNumberOfSuccessfulAllocations.34_5 = xNumberOfSuccessfulAllocations;
  pxHeapStats->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations.34_5;
  xNumberOfSuccessfulFrees.35_6 = xNumberOfSuccessfulFrees;
  pxHeapStats->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees.35_6;
  xMinimumEverFreeBytesRemaining.36_7 = xMinimumEverFreeBytesRemaining;
  pxHeapStats->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining.36_7;
  vPortExitCritical ();
  return;

}


prvInsertBlockIntoFreeList (struct BlockLink_t * pxBlockToInsert)
{
  uint8_t * puc;
  struct BlockLink_t * pxIterator;

  <bb 2> :
  pxIterator = &xStart;
  goto <bb 4>; [INV]

  <bb 3> :
  pxIterator = pxIterator->pxNextFreeBlock;

  <bb 4> :
  _1 = pxIterator->pxNextFreeBlock;
  if (pxBlockToInsert > _1)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  puc = pxIterator;
  _2 = pxIterator->xBlockSize;
  _3 = puc + _2;
  if (pxBlockToInsert == _3)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  _4 = pxIterator->xBlockSize;
  _5 = pxBlockToInsert->xBlockSize;
  _6 = _4 + _5;
  pxIterator->xBlockSize = _6;
  pxBlockToInsert = pxIterator;

  <bb 7> :
  puc = pxBlockToInsert;
  _7 = pxBlockToInsert->xBlockSize;
  _8 = puc + _7;
  _9 = pxIterator->pxNextFreeBlock;
  if (_8 == _9)
    goto <bb 8>; [INV]
  else
    goto <bb 11>; [INV]

  <bb 8> :
  _10 = pxIterator->pxNextFreeBlock;
  pxEnd.30_11 = pxEnd;
  if (_10 != pxEnd.30_11)
    goto <bb 9>; [INV]
  else
    goto <bb 10>; [INV]

  <bb 9> :
  _12 = pxBlockToInsert->xBlockSize;
  _13 = pxIterator->pxNextFreeBlock;
  _14 = _13->xBlockSize;
  _15 = _12 + _14;
  pxBlockToInsert->xBlockSize = _15;
  _16 = pxIterator->pxNextFreeBlock;
  _17 = _16->pxNextFreeBlock;
  pxBlockToInsert->pxNextFreeBlock = _17;
  goto <bb 12>; [INV]

  <bb 10> :
  pxEnd.31_18 = pxEnd;
  pxBlockToInsert->pxNextFreeBlock = pxEnd.31_18;
  goto <bb 12>; [INV]

  <bb 11> :
  _19 = pxIterator->pxNextFreeBlock;
  pxBlockToInsert->pxNextFreeBlock = _19;

  <bb 12> :
  if (pxIterator != pxBlockToInsert)
    goto <bb 13>; [INV]
  else
    goto <bb 14>; [INV]

  <bb 13> :
  pxIterator->pxNextFreeBlock = pxBlockToInsert;

  <bb 14> :
  return;

}


prvHeapInit ()
{
  size_t xTotalHeapSize;
  size_t uxAddress;
  uint8_t * pucAlignedHeap;
  struct BlockLink_t * pxFirstFreeBlock;

  <bb 2> :
  xTotalHeapSize = 8192;
  uxAddress = (size_t) &ucHeap;
  _1 = uxAddress & 7;
  if (_1 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  uxAddress = uxAddress + 7;
  uxAddress = uxAddress & 4294967288;
  _2 = xTotalHeapSize - uxAddress;
  ucHeap.22_3 = (unsigned int) &ucHeap;
  xTotalHeapSize = _2 + ucHeap.22_3;

  <bb 4> :
  pucAlignedHeap = (uint8_t *) uxAddress;
  xStart.pxNextFreeBlock = pucAlignedHeap;
  xStart.xBlockSize = 0;
  pucAlignedHeap.23_4 = (unsigned int) pucAlignedHeap;
  uxAddress = xTotalHeapSize + pucAlignedHeap.23_4;
  xHeapStructSize.24_5 = 8;
  uxAddress = uxAddress - xHeapStructSize.24_5;
  uxAddress = uxAddress & 4294967288;
  uxAddress.25_6 = (struct BlockLink_t *) uxAddress;
  pxEnd = uxAddress.25_6;
  pxEnd.26_7 = pxEnd;
  pxEnd.26_7->xBlockSize = 0;
  pxEnd.27_8 = pxEnd;
  pxEnd.27_8->pxNextFreeBlock = 0B;
  pxFirstFreeBlock = pucAlignedHeap;
  pxFirstFreeBlock.28_9 = (unsigned int) pxFirstFreeBlock;
  _10 = uxAddress - pxFirstFreeBlock.28_9;
  pxFirstFreeBlock->xBlockSize = _10;
  pxEnd.29_11 = pxEnd;
  pxFirstFreeBlock->pxNextFreeBlock = pxEnd.29_11;
  _12 = pxFirstFreeBlock->xBlockSize;
  xMinimumEverFreeBytesRemaining = _12;
  _13 = pxFirstFreeBlock->xBlockSize;
  xFreeBytesRemaining = _13;
  xBlockAllocatedBit = 2147483648;
  return;

}


vPortInitialiseBlocks ()
{
  <bb 2> :
  return;

}


xPortGetMinimumEverFreeHeapSize ()
{
  size_t D.6338;

  <bb 2> :
  D.6338 = xMinimumEverFreeBytesRemaining;

  <bb 3> :
<L0>:
  return D.6338;

}


xPortGetFreeHeapSize ()
{
  size_t D.6336;

  <bb 2> :
  D.6336 = xFreeBytesRemaining;

  <bb 3> :
<L0>:
  return D.6336;

}


vPortFree (void * pv)
{
  struct BlockLink_t * pxLink;
  uint8_t * puc;

  <bb 2> :
  puc = pv;
  if (pv != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 3> :
  xHeapStructSize.16_1 = 8;
  _2 = -xHeapStructSize.16_1;
  puc = puc + _2;
  pxLink = puc;
  _3 = pxLink->xBlockSize;
  xBlockAllocatedBit.17_4 = xBlockAllocatedBit;
  _5 = _3 & xBlockAllocatedBit.17_4;
  if (_5 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 4> :
  vPortRaiseBASEPRI ();

  <bb 5> :
  goto <bb 5>; [INV]

  <bb 6> :
  _6 = pxLink->pxNextFreeBlock;
  if (_6 != 0B)
    goto <bb 7>; [INV]
  else
    goto <bb 9>; [INV]

  <bb 7> :
  vPortRaiseBASEPRI ();

  <bb 8> :
  goto <bb 8>; [INV]

  <bb 9> :
  _7 = pxLink->xBlockSize;
  xBlockAllocatedBit.18_8 = xBlockAllocatedBit;
  _9 = _7 & xBlockAllocatedBit.18_8;
  if (_9 != 0)
    goto <bb 10>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 10> :
  _10 = pxLink->pxNextFreeBlock;
  if (_10 == 0B)
    goto <bb 11>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 11> :
  _11 = pxLink->xBlockSize;
  xBlockAllocatedBit.19_12 = xBlockAllocatedBit;
  _13 = ~xBlockAllocatedBit.19_12;
  _14 = _11 & _13;
  pxLink->xBlockSize = _14;
  vTaskSuspendAll ();
  _15 = pxLink->xBlockSize;
  xFreeBytesRemaining.20_16 = xFreeBytesRemaining;
  _17 = _15 + xFreeBytesRemaining.20_16;
  xFreeBytesRemaining = _17;
  prvInsertBlockIntoFreeList (pxLink);
  xNumberOfSuccessfulFrees.21_18 = xNumberOfSuccessfulFrees;
  _19 = xNumberOfSuccessfulFrees.21_18 + 1;
  xNumberOfSuccessfulFrees = _19;
  xTaskResumeAll ();

  <bb 12> :
  return;

}


pvPortMalloc (size_t xWantedSize)
{
  void * pvReturn;
  struct BlockLink_t * pxNewBlockLink;
  struct BlockLink_t * pxPreviousBlock;
  struct BlockLink_t * pxBlock;
  void * D.6322;

  <bb 2> :
  pvReturn = 0B;
  vTaskSuspendAll ();
  pxEnd.0_1 = pxEnd;
  if (pxEnd.0_1 == 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  prvHeapInit ();

  <bb 4> :
  xBlockAllocatedBit.1_2 = xBlockAllocatedBit;
  _3 = xWantedSize & xBlockAllocatedBit.1_2;
  if (_3 == 0)
    goto <bb 5>; [INV]
  else
    goto <bb 30>; [INV]

  <bb 5> :
  if (xWantedSize != 0)
    goto <bb 6>; [INV]
  else
    goto <bb 14>; [INV]

  <bb 6> :
  xHeapStructSize.2_4 = 8;
  _5 = xWantedSize + xHeapStructSize.2_4;
  if (xWantedSize < _5)
    goto <bb 7>; [INV]
  else
    goto <bb 14>; [INV]

  <bb 7> :
  xHeapStructSize.3_6 = 8;
  xWantedSize = xWantedSize + xHeapStructSize.3_6;
  _7 = xWantedSize & 7;
  if (_7 != 0)
    goto <bb 8>; [INV]
  else
    goto <bb 13>; [INV]

  <bb 8> :
  _8 = xWantedSize & 4294967288;
  _9 = _8 + 8;
  if (xWantedSize < _9)
    goto <bb 9>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 9> :
  _10 = xWantedSize & 4294967288;
  xWantedSize = _10 + 8;
  _11 = xWantedSize & 7;
  if (_11 != 0)
    goto <bb 10>; [INV]
  else
    goto <bb 13>; [INV]

  <bb 10> :
  vPortRaiseBASEPRI ();

  <bb 11> :
  goto <bb 11>; [INV]

  <bb 12> :
  xWantedSize = 0;

  <bb 13> :
  goto <bb 15>; [INV]

  <bb 14> :
  xWantedSize = 0;

  <bb 15> :
  if (xWantedSize != 0)
    goto <bb 16>; [INV]
  else
    goto <bb 30>; [INV]

  <bb 16> :
  xFreeBytesRemaining.4_12 = xFreeBytesRemaining;
  if (xWantedSize <= xFreeBytesRemaining.4_12)
    goto <bb 17>; [INV]
  else
    goto <bb 30>; [INV]

  <bb 17> :
  pxPreviousBlock = &xStart;
  pxBlock = xStart.pxNextFreeBlock;
  goto <bb 19>; [INV]

  <bb 18> :
  pxPreviousBlock = pxBlock;
  pxBlock = pxBlock->pxNextFreeBlock;

  <bb 19> :
  _13 = pxBlock->xBlockSize;
  if (xWantedSize > _13)
    goto <bb 20>; [INV]
  else
    goto <bb 21>; [INV]

  <bb 20> :
  _14 = pxBlock->pxNextFreeBlock;
  if (_14 != 0B)
    goto <bb 18>; [INV]
  else
    goto <bb 21>; [INV]

  <bb 21> :
  pxEnd.5_15 = pxEnd;
  if (pxBlock != pxEnd.5_15)
    goto <bb 22>; [INV]
  else
    goto <bb 30>; [INV]

  <bb 22> :
  _16 = pxPreviousBlock->pxNextFreeBlock;
  xHeapStructSize.6_17 = 8;
  pvReturn = _16 + xHeapStructSize.6_17;
  _18 = pxBlock->pxNextFreeBlock;
  pxPreviousBlock->pxNextFreeBlock = _18;
  _19 = pxBlock->xBlockSize;
  _20 = _19 - xWantedSize;
  xHeapStructSize.7_21 = 8;
  _22 = xHeapStructSize.7_21 << 1;
  if (_20 > _22)
    goto <bb 23>; [INV]
  else
    goto <bb 27>; [INV]

  <bb 23> :
  pxNewBlockLink = pxBlock + xWantedSize;
  pxNewBlockLink.8_23 = (unsigned int) pxNewBlockLink;
  _24 = pxNewBlockLink.8_23 & 7;
  if (_24 != 0)
    goto <bb 24>; [INV]
  else
    goto <bb 26>; [INV]

  <bb 24> :
  vPortRaiseBASEPRI ();

  <bb 25> :
  goto <bb 25>; [INV]

  <bb 26> :
  _25 = pxBlock->xBlockSize;
  _26 = _25 - xWantedSize;
  pxNewBlockLink->xBlockSize = _26;
  pxBlock->xBlockSize = xWantedSize;
  prvInsertBlockIntoFreeList (pxNewBlockLink);

  <bb 27> :
  xFreeBytesRemaining.9_27 = xFreeBytesRemaining;
  _28 = pxBlock->xBlockSize;
  _29 = xFreeBytesRemaining.9_27 - _28;
  xFreeBytesRemaining = _29;
  xFreeBytesRemaining.10_30 = xFreeBytesRemaining;
  xMinimumEverFreeBytesRemaining.11_31 = xMinimumEverFreeBytesRemaining;
  if (xFreeBytesRemaining.10_30 < xMinimumEverFreeBytesRemaining.11_31)
    goto <bb 28>; [INV]
  else
    goto <bb 29>; [INV]

  <bb 28> :
  xFreeBytesRemaining.12_32 = xFreeBytesRemaining;
  xMinimumEverFreeBytesRemaining = xFreeBytesRemaining.12_32;

  <bb 29> :
  _33 = pxBlock->xBlockSize;
  xBlockAllocatedBit.13_34 = xBlockAllocatedBit;
  _35 = _33 | xBlockAllocatedBit.13_34;
  pxBlock->xBlockSize = _35;
  pxBlock->pxNextFreeBlock = 0B;
  xNumberOfSuccessfulAllocations.14_36 = xNumberOfSuccessfulAllocations;
  _37 = xNumberOfSuccessfulAllocations.14_36 + 1;
  xNumberOfSuccessfulAllocations = _37;

  <bb 30> :
  xTaskResumeAll ();
  pvReturn.15_38 = (unsigned int) pvReturn;
  _39 = pvReturn.15_38 & 7;
  if (_39 != 0)
    goto <bb 31>; [INV]
  else
    goto <bb 33>; [INV]

  <bb 31> :
  vPortRaiseBASEPRI ();

  <bb 32> :
  goto <bb 32>; [INV]

  <bb 33> :
  D.6322 = pvReturn;

  <bb 34> :
<L43>:
  return D.6322;

}


__attribute__((always_inline))
vPortRaiseBASEPRI ()
{
  uint32_t ulNewBASEPRI;

  <bb 2> :
  __asm__ __volatile__("	mov %0, %1												
	msr basepri, %0											
	isb														
	dsb														
" : "=r" ulNewBASEPRI : "i" 16 : "memory");
  return;

}


