/* TM_lib_internal::RECV_ReadPackets */
void RECV_ReadPackets_TM_lib_internal(
  /* TM_lib_internal::RECV_ReadPackets::Packets */ CompressedPackets_T_Common_Types_Pkg *Packets,
  /* TM_lib_internal::RECV_ReadPackets::PacketID */ kcg_int PacketID,
  /* TM_lib_internal::RECV_ReadPackets::F_version */ kcg_bool F_version,
  /* TM_lib_internal::RECV_ReadPackets::F_id */ kcg_bool F_id,
  /* TM_lib_internal::RECV_ReadPackets::Data */ CompressedPacketData_T_Common_Types_Pkg *Data,
  /* TM_lib_internal::RECV_ReadPackets::Metadata */ MetadataElement_T_Common_Types_Pkg *Metadata,
  /* TM_lib_internal::RECV_ReadPackets::received */ kcg_bool *received)
{
  /* TM_lib_internal::RECV_ReadPackets::_L2 */
  static kcg_int _L2;
  
  /* 1 */
  RECV_LookupPacket_TM_lib_internal(
    PacketID,
    &(*Packets).PacketHeaders,
    F_version,
    F_id,
    received,
    &_L2,
    Metadata);
  /* ck_received */ if (*received) {
    /* 1 */
    RECV_ReadPacketKernel_TM_lib_internal(
      Metadata,
      &(*Packets).PacketData,
      Data);
  }
  else {
    kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
      Data,
      (CompressedPacketData_T_Common_Types_Pkg *)
        &DEFAULT_CompressedPackets_TM);
  }
}
/* TM_lib_internal::RECV_ReadPackets */
void RECV_ReadPackets_TM_lib_internal(
  /* TM_lib_internal::RECV_ReadPackets::Packets */CompressedPackets_T_Common_Types_Pkg *Packets,
  /* TM_lib_internal::RECV_ReadPackets::PacketID */kcg_int PacketID,
  /* TM_lib_internal::RECV_ReadPackets::F_version */kcg_bool F_version,
  /* TM_lib_internal::RECV_ReadPackets::F_id */kcg_bool F_id,
  outC_RECV_ReadPackets_TM_lib_internal *outC)
{
  array_int_500 tmp;
  kcg_int noname;
  
  kcg_copy_CompressedPackets_T_Common_Types_Pkg(&outC->_L46, Packets);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L48,
    &outC->_L46.PacketData);
  outC->_L45 = PacketID;
  kcg_copy_Metadata_T_Common_Types_Pkg(&outC->_L47, &outC->_L46.PacketHeaders);
  outC->_L49 = F_version;
  outC->_L50 = F_id;
  /* 1 */
  RECV_LookupPacket_TM_lib_internal(
    outC->_L45,
    &outC->_L47,
    outC->_L49,
    outC->_L50,
    &outC->Context_1);
  outC->_L1 = outC->Context_1.Found;
  outC->_L2 = outC->Context_1.Index;
  kcg_copy_MetadataElement_T_Common_Types_Pkg(
    &outC->_L3,
    &outC->Context_1.HeaderFound);
  outC->received = outC->_L1;
  kcg_copy_MetadataElement_T_Common_Types_Pkg(&outC->Metadata, &outC->_L3);
  outC->tmp = outC->_L1;
  if (outC->tmp) {
    /* 1 */
    RECV_ReadPacketKernel_TM_lib_internal(
      &outC->_L3,
      &outC->_L48,
      &outC->_1_Context_1);
    kcg_copy_array_int_500(&tmp, &outC->_1_Context_1.PacketOut);
  }
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->_L44,
    (CompressedPacketData_T_Common_Types_Pkg *) &DEFAULT_CompressedPackets_TM);
  if (outC->tmp) {
    kcg_copy_array_int_500(&outC->_L4, &tmp);
  }
  else {
    kcg_copy_CompressedPacketData_T_Common_Types_Pkg(&outC->_L4, &outC->_L44);
  }
  kcg_copy_array_int_500(&outC->Data, &outC->_L4);
  noname = outC->_L2;
}