vPortGetHeapStats (struct HeapStats_t * pxHeapStats)
{
  size_t xMinSize;
  size_t xMaxSize;
  size_t xBlocks;
  struct BlockLink_t * pxBlock;
  unsigned int _1;
  unsigned int _2;
  struct BlockLink_t * pxEnd.32_3;
  unsigned int xFreeBytesRemaining.33_4;
  unsigned int xNumberOfSuccessfulAllocations.34_5;
  unsigned int xNumberOfSuccessfulFrees.35_6;
  unsigned int xMinimumEverFreeBytesRemaining.36_7;

  <bb 2> :
  xBlocks_17 = 0;
  xMaxSize_18 = 0;
  xMinSize_19 = 4294967295;
  vTaskSuspendAll ();
  pxBlock_22 = xStart.pxNextFreeBlock;
  if (pxBlock_22 != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 3> :
  # pxBlock_8 = PHI <pxBlock_22(2), pxBlock_26(7)>
  # xBlocks_9 = PHI <xBlocks_17(2), xBlocks_23(7)>
  # xMaxSize_11 = PHI <xMaxSize_18(2), xMaxSize_12(7)>
  # xMinSize_14 = PHI <xMinSize_19(2), xMinSize_15(7)>
  xBlocks_23 = xBlocks_9 + 1;
  _1 = pxBlock_8->xBlockSize;
  if (xMaxSize_11 < _1)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  xMaxSize_24 = pxBlock_8->xBlockSize;

  <bb 5> :
  # xMaxSize_12 = PHI <xMaxSize_11(3), xMaxSize_24(4)>
  _2 = pxBlock_8->xBlockSize;
  if (xMinSize_14 > _2)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  xMinSize_25 = pxBlock_8->xBlockSize;

  <bb 7> :
  # xMinSize_15 = PHI <xMinSize_14(5), xMinSize_25(6)>
  pxBlock_26 = pxBlock_8->pxNextFreeBlock;
  pxEnd.32_3 = pxEnd;
  if (pxBlock_26 != pxEnd.32_3)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 8> :
  # xBlocks_10 = PHI <xBlocks_17(2), xBlocks_23(7)>
  # xMaxSize_13 = PHI <xMaxSize_18(2), xMaxSize_12(7)>
  # xMinSize_16 = PHI <xMinSize_19(2), xMinSize_15(7)>
  xTaskResumeAll ();
  pxHeapStats_28(D)->xSizeOfLargestFreeBlockInBytes = xMaxSize_13;
  pxHeapStats_28(D)->xSizeOfSmallestFreeBlockInBytes = xMinSize_16;
  pxHeapStats_28(D)->xNumberOfFreeBlocks = xBlocks_10;
  vPortEnterCritical ();
  xFreeBytesRemaining.33_4 = xFreeBytesRemaining;
  pxHeapStats_28(D)->xAvailableHeapSpaceInBytes = xFreeBytesRemaining.33_4;
  xNumberOfSuccessfulAllocations.34_5 = xNumberOfSuccessfulAllocations;
  pxHeapStats_28(D)->xNumberOfSuccessfulAllocations = xNumberOfSuccessfulAllocations.34_5;
  xNumberOfSuccessfulFrees.35_6 = xNumberOfSuccessfulFrees;
  pxHeapStats_28(D)->xNumberOfSuccessfulFrees = xNumberOfSuccessfulFrees.35_6;
  xMinimumEverFreeBytesRemaining.36_7 = xMinimumEverFreeBytesRemaining;
  pxHeapStats_28(D)->xMinimumEverFreeBytesRemaining = xMinimumEverFreeBytesRemaining.36_7;
  vPortExitCritical ();
  return;

}


prvInsertBlockIntoFreeList (struct BlockLink_t * pxBlockToInsert)
{
  uint8_t * puc;
  struct BlockLink_t * pxIterator;
  struct A_BLOCK_LINK * _1;
  unsigned int _2;
  uint8_t * _3;
  unsigned int _4;
  unsigned int _5;
  unsigned int _6;
  unsigned int _7;
  uint8_t * _8;
  struct A_BLOCK_LINK * _9;
  struct A_BLOCK_LINK * _10;
  struct BlockLink_t * pxEnd.30_11;
  unsigned int _12;
  struct A_BLOCK_LINK * _13;
  unsigned int _14;
  unsigned int _15;
  struct A_BLOCK_LINK * _16;
  struct A_BLOCK_LINK * _17;
  struct BlockLink_t * pxEnd.31_18;
  struct A_BLOCK_LINK * _19;

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

  <bb 3> :
  pxIterator_37 = pxIterator_21->pxNextFreeBlock;

  <bb 4> :
  # pxIterator_21 = PHI <pxIterator_25(2), pxIterator_37(3)>
  _1 = pxIterator_21->pxNextFreeBlock;
  if (pxBlockToInsert_27(D) > _1)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  puc_28 = pxIterator_21;
  _2 = pxIterator_21->xBlockSize;
  _3 = puc_28 + _2;
  if (pxBlockToInsert_27(D) == _3)
    goto <bb 6>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 6> :
  _4 = pxIterator_21->xBlockSize;
  _5 = pxBlockToInsert_27(D)->xBlockSize;
  _6 = _4 + _5;
  pxIterator_21->xBlockSize = _6;
  pxBlockToInsert_30 = pxIterator_21;

  <bb 7> :
  # pxBlockToInsert_20 = PHI <pxBlockToInsert_27(D)(5), pxBlockToInsert_30(6)>
  puc_31 = pxBlockToInsert_20;
  _7 = pxBlockToInsert_20->xBlockSize;
  _8 = puc_31 + _7;
  _9 = pxIterator_21->pxNextFreeBlock;
  if (_8 == _9)
    goto <bb 8>; [INV]
  else
    goto <bb 11>; [INV]

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

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

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

  <bb 11> :
  _19 = pxIterator_21->pxNextFreeBlock;
  pxBlockToInsert_20->pxNextFreeBlock = _19;

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

  <bb 13> :
  pxIterator_21->pxNextFreeBlock = pxBlockToInsert_20;

  <bb 14> :
  return;

}


prvHeapInit ()
{
  size_t xTotalHeapSize;
  size_t uxAddress;
  uint8_t * pucAlignedHeap;
  struct BlockLink_t * pxFirstFreeBlock;
  unsigned int _1;
  unsigned int _2;
  unsigned int ucHeap.22_3;
  unsigned int pucAlignedHeap.23_4;
  unsigned int xHeapStructSize.24_5;
  struct BlockLink_t * uxAddress.25_6;
  struct BlockLink_t * pxEnd.26_7;
  struct BlockLink_t * pxEnd.27_8;
  unsigned int pxFirstFreeBlock.28_9;
  unsigned int _10;
  struct BlockLink_t * pxEnd.29_11;
  unsigned int _12;
  unsigned int _13;

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

  <bb 3> :
  uxAddress_18 = uxAddress_17 + 7;
  uxAddress_19 = uxAddress_18 & 4294967288;
  _2 = xTotalHeapSize_16 - uxAddress_19;
  ucHeap.22_3 = (unsigned int) &ucHeap;
  xTotalHeapSize_20 = _2 + ucHeap.22_3;

  <bb 4> :
  # uxAddress_14 = PHI <uxAddress_17(2), uxAddress_19(3)>
  # xTotalHeapSize_15 = PHI <xTotalHeapSize_16(2), xTotalHeapSize_20(3)>
  pucAlignedHeap_21 = (uint8_t *) uxAddress_14;
  xStart.pxNextFreeBlock = pucAlignedHeap_21;
  xStart.xBlockSize = 0;
  pucAlignedHeap.23_4 = (unsigned int) pucAlignedHeap_21;
  uxAddress_25 = xTotalHeapSize_15 + pucAlignedHeap.23_4;
  xHeapStructSize.24_5 = 8;
  uxAddress_26 = uxAddress_25 - xHeapStructSize.24_5;
  uxAddress_27 = uxAddress_26 & 4294967288;
  uxAddress.25_6 = (struct BlockLink_t *) uxAddress_27;
  pxEnd = uxAddress.25_6;
  pxEnd.26_7 = pxEnd;
  pxEnd.26_7->xBlockSize = 0;
  pxEnd.27_8 = pxEnd;
  pxEnd.27_8->pxNextFreeBlock = 0B;
  pxFirstFreeBlock_31 = pucAlignedHeap_21;
  pxFirstFreeBlock.28_9 = (unsigned int) pxFirstFreeBlock_31;
  _10 = uxAddress_27 - pxFirstFreeBlock.28_9;
  pxFirstFreeBlock_31->xBlockSize = _10;
  pxEnd.29_11 = pxEnd;
  pxFirstFreeBlock_31->pxNextFreeBlock = pxEnd.29_11;
  _12 = pxFirstFreeBlock_31->xBlockSize;
  xMinimumEverFreeBytesRemaining = _12;
  _13 = pxFirstFreeBlock_31->xBlockSize;
  xFreeBytesRemaining = _13;
  xBlockAllocatedBit = 2147483648;
  return;

}


vPortInitialiseBlocks ()
{
  <bb 2> :
  return;

}


xPortGetMinimumEverFreeHeapSize ()
{
  size_t D.6338;
  size_t _2;

  <bb 2> :
  _2 = xMinimumEverFreeBytesRemaining;

  <bb 3> :
<L0>:
  return _2;

}


xPortGetFreeHeapSize ()
{
  size_t D.6336;
  size_t _2;

  <bb 2> :
  _2 = xFreeBytesRemaining;

  <bb 3> :
<L0>:
  return _2;

}


vPortFree (void * pv)
{
  uint32_t ulNewBASEPRI;
  uint32_t ulNewBASEPRI;
  struct BlockLink_t * pxLink;
  uint8_t * puc;
  unsigned int xHeapStructSize.16_1;
  sizetype _2;
  unsigned int _3;
  unsigned int xBlockAllocatedBit.17_4;
  unsigned int _5;
  struct A_BLOCK_LINK * _6;
  unsigned int _7;
  unsigned int xBlockAllocatedBit.18_8;
  unsigned int _9;
  struct A_BLOCK_LINK * _10;
  unsigned int _11;
  unsigned int xBlockAllocatedBit.19_12;
  unsigned int _13;
  unsigned int _14;
  unsigned int _15;
  unsigned int xFreeBytesRemaining.20_16;
  unsigned int _17;
  unsigned int xNumberOfSuccessfulFrees.21_18;
  unsigned int _19;

  <bb 2> :
  puc_22 = pv_21(D);
  if (pv_21(D) != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 14>; [INV]

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

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

  <bb 5> :

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

  <bb 7> :
  _6 = pxLink_25->pxNextFreeBlock;
  if (_6 != 0B)
    goto <bb 8>; [INV]
  else
    goto <bb 11>; [INV]

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

  <bb 9> :

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

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

  <bb 12> :
  _10 = pxLink_25->pxNextFreeBlock;
  if (_10 == 0B)
    goto <bb 13>; [INV]
  else
    goto <bb 14>; [INV]

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

  <bb 14> :
  return;

}


pvPortMalloc (size_t xWantedSize)
{
  uint32_t ulNewBASEPRI;
  uint32_t ulNewBASEPRI;
  uint32_t ulNewBASEPRI;
  void * pvReturn;
  struct BlockLink_t * pxNewBlockLink;
  struct BlockLink_t * pxPreviousBlock;
  struct BlockLink_t * pxBlock;
  void * D.6322;
  struct BlockLink_t * pxEnd.0_1;
  unsigned int xBlockAllocatedBit.1_2;
  unsigned int _3;
  unsigned int xHeapStructSize.2_4;
  unsigned int _5;
  unsigned int xHeapStructSize.3_6;
  unsigned int _7;
  unsigned int _8;
  unsigned int _9;
  unsigned int _10;
  unsigned int _11;
  unsigned int xFreeBytesRemaining.4_12;
  unsigned int _13;
  struct A_BLOCK_LINK * _14;
  struct BlockLink_t * pxEnd.5_15;
  struct A_BLOCK_LINK * _16;
  unsigned int xHeapStructSize.6_17;
  struct A_BLOCK_LINK * _18;
  unsigned int _19;
  unsigned int _20;
  unsigned int xHeapStructSize.7_21;
  unsigned int _22;
  unsigned int pxNewBlockLink.8_23;
  unsigned int _24;
  unsigned int _25;
  unsigned int _26;
  unsigned int xFreeBytesRemaining.9_27;
  unsigned int _28;
  unsigned int _29;
  unsigned int xFreeBytesRemaining.10_30;
  unsigned int xMinimumEverFreeBytesRemaining.11_31;
  unsigned int xFreeBytesRemaining.12_32;
  unsigned int _33;
  unsigned int xBlockAllocatedBit.13_34;
  unsigned int _35;
  unsigned int xNumberOfSuccessfulAllocations.14_36;
  unsigned int _37;
  unsigned int pvReturn.15_38;
  unsigned int _39;
  void * _74;

  <bb 2> :
  pvReturn_49 = 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_53(D) & xBlockAllocatedBit.1_2;
  if (_3 == 0)
    goto <bb 5>; [INV]
  else
    goto <bb 32>; [INV]

  <bb 5> :
  if (xWantedSize_53(D) != 0)
    goto <bb 6>; [INV]
  else
    goto <bb 15>; [INV]

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

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

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

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

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

  <bb 11> :

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

  <bb 13> :
  xWantedSize_55 = 0;

  <bb 14> :
  # xWantedSize_40 = PHI <xWantedSize_54(7), xWantedSize_55(13), xWantedSize_56(9)>
  goto <bb 16>; [INV]

  <bb 15> :
  xWantedSize_57 = 0;

  <bb 16> :
  # xWantedSize_41 = PHI <xWantedSize_40(14), xWantedSize_57(15)>
  if (xWantedSize_41 != 0)
    goto <bb 17>; [INV]
  else
    goto <bb 32>; [INV]

  <bb 17> :
  xFreeBytesRemaining.4_12 = xFreeBytesRemaining;
  if (xWantedSize_41 <= xFreeBytesRemaining.4_12)
    goto <bb 18>; [INV]
  else
    goto <bb 32>; [INV]

  <bb 18> :
  pxPreviousBlock_58 = &xStart;
  pxBlock_59 = xStart.pxNextFreeBlock;
  goto <bb 20>; [INV]

  <bb 19> :
  pxPreviousBlock_60 = pxBlock_42;
  pxBlock_61 = pxBlock_42->pxNextFreeBlock;

  <bb 20> :
  # pxBlock_42 = PHI <pxBlock_59(18), pxBlock_61(19)>
  # pxPreviousBlock_43 = PHI <pxPreviousBlock_58(18), pxPreviousBlock_60(19)>
  _13 = pxBlock_42->xBlockSize;
  if (xWantedSize_41 > _13)
    goto <bb 21>; [INV]
  else
    goto <bb 22>; [INV]

  <bb 21> :
  _14 = pxBlock_42->pxNextFreeBlock;
  if (_14 != 0B)
    goto <bb 19>; [INV]
  else
    goto <bb 22>; [INV]

  <bb 22> :
  pxEnd.5_15 = pxEnd;
  if (pxBlock_42 != pxEnd.5_15)
    goto <bb 23>; [INV]
  else
    goto <bb 32>; [INV]

  <bb 23> :
  _16 = pxPreviousBlock_43->pxNextFreeBlock;
  xHeapStructSize.6_17 = 8;
  pvReturn_62 = _16 + xHeapStructSize.6_17;
  _18 = pxBlock_42->pxNextFreeBlock;
  pxPreviousBlock_43->pxNextFreeBlock = _18;
  _19 = pxBlock_42->xBlockSize;
  _20 = _19 - xWantedSize_41;
  xHeapStructSize.7_21 = 8;
  _22 = xHeapStructSize.7_21 << 1;
  if (_20 > _22)
    goto <bb 24>; [INV]
  else
    goto <bb 29>; [INV]

  <bb 24> :
  pxNewBlockLink_64 = pxBlock_42 + xWantedSize_41;
  pxNewBlockLink.8_23 = (unsigned int) pxNewBlockLink_64;
  _24 = pxNewBlockLink.8_23 & 7;
  if (_24 != 0)
    goto <bb 25>; [INV]
  else
    goto <bb 28>; [INV]

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

  <bb 26> :

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

  <bb 28> :
  _25 = pxBlock_42->xBlockSize;
  _26 = _25 - xWantedSize_41;
  pxNewBlockLink_64->xBlockSize = _26;
  pxBlock_42->xBlockSize = xWantedSize_41;
  prvInsertBlockIntoFreeList (pxNewBlockLink_64);

  <bb 29> :
  xFreeBytesRemaining.9_27 = xFreeBytesRemaining;
  _28 = pxBlock_42->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 30>; [INV]
  else
    goto <bb 31>; [INV]

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

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

  <bb 32> :
  # pvReturn_44 = PHI <pvReturn_49(4), pvReturn_49(17), pvReturn_49(16), pvReturn_49(22), pvReturn_62(31)>
  xTaskResumeAll ();
  pvReturn.15_38 = (unsigned int) pvReturn_44;
  _39 = pvReturn.15_38 & 7;
  if (_39 != 0)
    goto <bb 33>; [INV]
  else
    goto <bb 36>; [INV]

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

  <bb 34> :

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

  <bb 36> :
  _74 = pvReturn_44;

  <bb 37> :
<L43>:
  return _74;

}


