/* TM_conversions::C_P255_tracksim_compr */
void C_P255_tracksim_compr_TM_conversions(
  /* TM_conversions::C_P255_tracksim_compr::P255_from_track */P255_trackside_int_T_TM *P255_from_track,
  outC_C_P255_tracksim_compr_TM_conversions *outC)
{
  static kcg_int i;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR _10_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool _9_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR _8_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool _7_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool _6_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR _5_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool _4_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR _3_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR _2_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool _1_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */
  static Q_DIR q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */
  static kcg_bool error_1;
  static kcg_bool noname_1;
  
  kcg_copy_P255_trackside_int_T_TM(&outC->_L1, P255_from_track);
  outC->_L387 = outC->_L1.NID_PACKET;
  outC->_L389 = INT_Q_DIR_both_TM;
  /* 1 */
  T_Build_Metadata_Packet_ID_TM_lib_internal(
    outC->_L387,
    outC->_L389,
    0,
    1,
    INT_M_VERSION_2_0_TM,
    &outC->Context_1);
  outC->_L390 = outC->Context_1.nid_packet_meta;
  outC->_L388 = DIM_MaxElementsPacket255_TM;
  outC->_L373[0] = outC->_L387;
  outC->_L336 = 0;
  for (i = 0; i < 499; i++) {
    outC->_L209[i] = outC->_L336;
  }
  kcg_copy_array_int_1(&outC->_L383[0], &outC->_L373);
  kcg_copy_array_int_499(&outC->_L383[1], &outC->_L209);
  outC->q_dir_int_1 = outC->_L389;
  outC->_L12_1 = outC->q_dir_int_1;
  outC->q_dir_in_1 = outC->_L12_1;
  outC->IfBlock1_clock_1 = outC->q_dir_in_1 ==
    INT_Q_DIR_nomiinal_TM_conversions;
  if (outC->IfBlock1_clock_1) {
    outC->_L4_13_IfBlock1 = ENUM_Q_DIR_nominal_TM_conversions;
    _10_q_dir_1 = outC->_L4_13_IfBlock1;
    outC->q_dir_1 = _10_q_dir_1;
  }
  else {
    outC->_2_else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
      INT_Q_DIR_reverse_TM_conversions;
    if (outC->_2_else_clock_1_IfBlock1) {
      outC->_L3_1_IfBlock1 = ENUM_Q_DIR_reverse_TM_conversions;
      q_dir_1 = outC->_L3_1_IfBlock1;
      _8_q_dir_1 = q_dir_1;
    }
    else {
      outC->else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
        INT_Q_DIR_both_TM_conversions;
      if (outC->else_clock_1_IfBlock1) {
        outC->_L2_11_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _5_q_dir_1 = outC->_L2_11_IfBlock1;
        _2_q_dir_1 = _5_q_dir_1;
      }
      else {
        outC->_L2_1_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _3_q_dir_1 = outC->_L2_1_IfBlock1;
        _2_q_dir_1 = _3_q_dir_1;
      }
      _8_q_dir_1 = _2_q_dir_1;
    }
    outC->q_dir_1 = _8_q_dir_1;
  }
  outC->_L356 = outC->q_dir_1;
  outC->_L214 = outC->_L1.valid;
  outC->_L213 = 1;
  outC->_L212 = outC->_L388 - outC->_L213;
  outC->_L206 = 0;
  outC->_L204.nid_packet = outC->_L390;
  outC->_L204.q_dir = outC->_L356;
  outC->_L204.valid = outC->_L214;
  outC->_L204.startAddress = outC->_L206;
  outC->_L204.endAddress = outC->_L212;
  kcg_copy_MetadataElement_T_Common_Types_Pkg(&outC->Header, &outC->_L204);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->P005_compressed,
    &outC->_L383);
  if (outC->IfBlock1_clock_1) {
    outC->_L5_14_IfBlock1 = kcg_false;
    _9_error_1 = outC->_L5_14_IfBlock1;
    outC->error_1 = _9_error_1;
  }
  else {
    if (outC->_2_else_clock_1_IfBlock1) {
      outC->_L5_1_IfBlock1 = kcg_false;
      error_1 = outC->_L5_1_IfBlock1;
      _7_error_1 = error_1;
    }
    else {
      if (outC->else_clock_1_IfBlock1) {
        outC->_L4_1_IfBlock1 = kcg_false;
        _6_error_1 = outC->_L4_1_IfBlock1;
        _1_error_1 = _6_error_1;
      }
      else {
        outC->_L1_1_IfBlock1 = kcg_true;
        _4_error_1 = outC->_L1_1_IfBlock1;
        _1_error_1 = _4_error_1;
      }
      _7_error_1 = _1_error_1;
    }
    outC->error_1 = _7_error_1;
  }
  outC->_L13_1 = outC->error_1;
  noname_1 = outC->_L13_1;
}
/* TM_conversions::C_P041_tracksim_compr */
void C_P041_tracksim_compr_TM_conversions(
  /* TM_conversions::C_P041_tracksim_compr::P041_from_track */P041_trackside_int_T_TM *P041_from_track,
  outC_C_P041_tracksim_compr_TM_conversions *outC)
{
  kcg_int i2;
  kcg_int i1;
  kcg_int i;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _12_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _11_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _10_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _9_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _8_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _7_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _6_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _5_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _4_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _3_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool error_1;
  kcg_bool noname_1;
  
  kcg_copy_P041_trackside_int_T_TM(&outC->_L1, P041_from_track);
  kcg_copy_P041_trackide_sectionlist_T_TM(&outC->_L368, &outC->_L1.SECTIONS);
  outC->_L369 = outC->_L1.N_ITER;
  outC->_L370 = outC->_L1.L_ACKLEVELTR;
  outC->_L371 = outC->_L1.NID_NTC;
  outC->_L219 = outC->_L1.M_LEVELTR;
  outC->_L218 = outC->_L1.D_LEVELTR;
  outC->_L217 = outC->_L1.Q_SCALE;
  outC->_L216 = outC->_L1.L_PACKET;
  outC->_L215 = outC->_L1.Q_DIR;
  outC->_L387 = outC->_L1.NID_PACKET;
  /* 1 */
  T_Build_Metadata_Packet_ID_TM_lib_internal(
    outC->_L387,
    outC->_L215,
    0,
    41,
    INT_M_VERSION_2_0_TM,
    &outC->Context_1);
  outC->_L388 = outC->Context_1.nid_packet_meta;
  outC->_L375.M_LEVELTR = outC->_L219;
  outC->_L375.NID_NTC = outC->_L371;
  outC->_L375.L_ACKLEVELTR = outC->_L370;
  for (i2 = 0; i2 < 1; i2++) {
    kcg_copy_P041_section_int_T_TM(&outC->_L386[i2], &outC->_L375);
  }
  kcg_copy_array__9919(&outC->_L385[0], &outC->_L386);
  kcg_copy_P041_trackide_sectionlist_T_TM(&outC->_L385[1], &outC->_L368);
  outC->_L373[0] = outC->_L387;
  outC->_L373[1] = outC->_L215;
  outC->_L373[2] = outC->_L216;
  outC->_L373[3] = outC->_L217;
  outC->_L373[4] = outC->_L218;
  for (i1 = 0; i1 < 1; i1++) {
    outC->_L376[i1] = outC->_L369;
  }
  kcg_copy_array_int_5(&outC->_L381[0], &outC->_L373);
  kcg_copy_array_int_1(&outC->_L381[5], &outC->_L376);
  /* 1 */
  C_P041_flatten_sections_TM_lib_internal(&outC->_L385, &outC->_1_Context_1);
  kcg_copy_P041_sections_array_flat_T_TM(
    &outC->_L380,
    &outC->_1_Context_1.Flattened);
  kcg_copy_array_int_6(&outC->_L384[0], &outC->_L381);
  kcg_copy_P041_sections_array_flat_T_TM(&outC->_L384[6], &outC->_L380);
  outC->_L336 = 0;
  for (i = 0; i < 395; i++) {
    outC->_L209[i] = outC->_L336;
  }
  kcg_copy_array_int_105(&outC->_L383[0], &outC->_L384);
  kcg_copy_array_int_395(&outC->_L383[105], &outC->_L209);
  /* 1 */
  T_DeterminePacketSizeInt_TM_lib_internal(
    outC->_L369,
    5 + 1 + 3,
    3,
    &outC->_2_Context_1);
  outC->_L379 = outC->_2_Context_1.p_size;
  outC->p_size = outC->_L379;
  outC->_L378 = outC->p_size;
  outC->q_dir_int_1 = outC->_L215;
  outC->_L12_1 = outC->q_dir_int_1;
  outC->q_dir_in_1 = outC->_L12_1;
  outC->IfBlock1_clock_1 = outC->q_dir_in_1 ==
    INT_Q_DIR_nomiinal_TM_conversions;
  if (outC->IfBlock1_clock_1) {
    outC->_L4_15_IfBlock1 = ENUM_Q_DIR_nominal_TM_conversions;
    _12_q_dir_1 = outC->_L4_15_IfBlock1;
    outC->q_dir_1 = _12_q_dir_1;
  }
  else {
    outC->_4_else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
      INT_Q_DIR_reverse_TM_conversions;
    if (outC->_4_else_clock_1_IfBlock1) {
      outC->_L3_1_IfBlock1 = ENUM_Q_DIR_reverse_TM_conversions;
      q_dir_1 = outC->_L3_1_IfBlock1;
      _10_q_dir_1 = q_dir_1;
    }
    else {
      outC->else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
        INT_Q_DIR_both_TM_conversions;
      if (outC->else_clock_1_IfBlock1) {
        outC->_L2_13_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _7_q_dir_1 = outC->_L2_13_IfBlock1;
        _4_q_dir_1 = _7_q_dir_1;
      }
      else {
        outC->_L2_1_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _5_q_dir_1 = outC->_L2_1_IfBlock1;
        _4_q_dir_1 = _5_q_dir_1;
      }
      _10_q_dir_1 = _4_q_dir_1;
    }
    outC->q_dir_1 = _10_q_dir_1;
  }
  outC->_L356 = outC->q_dir_1;
  outC->_L214 = outC->_L1.valid;
  outC->_L213 = 1;
  outC->_L212 = outC->_L378 - outC->_L213;
  outC->_L206 = 0;
  outC->_L204.nid_packet = outC->_L388;
  outC->_L204.q_dir = outC->_L356;
  outC->_L204.valid = outC->_L214;
  outC->_L204.startAddress = outC->_L206;
  outC->_L204.endAddress = outC->_L212;
  kcg_copy_MetadataElement_T_Common_Types_Pkg(&outC->Header, &outC->_L204);
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(
    &outC->P005_compressed,
    &outC->_L383);
  if (outC->IfBlock1_clock_1) {
    outC->_L5_16_IfBlock1 = kcg_false;
    _11_error_1 = outC->_L5_16_IfBlock1;
    outC->error_1 = _11_error_1;
  }
  else {
    if (outC->_4_else_clock_1_IfBlock1) {
      outC->_L5_1_IfBlock1 = kcg_false;
      error_1 = outC->_L5_1_IfBlock1;
      _9_error_1 = error_1;
    }
    else {
      if (outC->else_clock_1_IfBlock1) {
        outC->_L4_1_IfBlock1 = kcg_false;
        _8_error_1 = outC->_L4_1_IfBlock1;
        _3_error_1 = _8_error_1;
      }
      else {
        outC->_L1_1_IfBlock1 = kcg_true;
        _6_error_1 = outC->_L1_1_IfBlock1;
        _3_error_1 = _6_error_1;
      }
      _9_error_1 = _3_error_1;
    }
    outC->error_1 = _9_error_1;
  }
  outC->_L13_1 = outC->error_1;
  noname_1 = outC->_L13_1;
}
/* TM_conversions::C_P005_compr_onboard */
void C_P005_compr_onboard_TM_conversions(
  /* TM_conversions::C_P005_compr_onboard::PacketData */CompressedPacketData_T_Common_Types_Pkg *PacketData,
  /* TM_conversions::C_P005_compr_onboard::Metadata_Element */MetadataElement_T_Common_Types_Pkg *Metadata_Element,
  outC_C_P005_compr_onboard_TM_conversions *outC)
{
  kcg_bool _28_noname_1;
  kcg_bool _27_noname_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _26_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _25_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _24_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _23_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _22_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _21_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _20_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _19_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR _18_q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _17_error_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::q_dir */ Q_DIR q_dir_1;
  /* TM_conversions::CAST_Int_to_Q_DIR::error */ kcg_bool _16_error_1;
  kcg_bool _15_noname_1;
  kcg_bool _14_noname_1;
  kcg_bool _13_noname_1;
  kcg_bool _12_noname_1;
  kcg_bool _11_noname_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE _10_q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool _9_error_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE _8_q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool _7_error_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool _6_error_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE _5_q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool _4_error_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE _3_q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE _2_q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool _1_error_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::q_scale */ Q_SCALE q_scale_1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::error */ kcg_bool error_1;
  kcg_bool noname_1;
  MetadataElement_T_Common_Types_Pkg noname;
  
  kcg_copy_CompressedPacketData_T_Common_Types_Pkg(&outC->_L9, PacketData);
  kcg_copy_array_int_3(&outC->_L6, (array_int_3 *) &outC->_L9[1]);
  outC->_L16 = outC->_L6[2];
  outC->_L15 = outC->_L6[1];
  kcg_copy_array_int_1(&outC->_L1, (array_int_1 *) &outC->_L9[0]);
  outC->_L18 = outC->_L1[0];
  outC->nid_packet_int_1 = outC->_L18;
  outC->_L1_124 = outC->nid_packet_int_1;
  outC->nid_packet_1 = outC->_L1_124;
  outC->_L12 = outC->nid_packet_1;
  outC->_L21 = 5;
  outC->_L22 = outC->_L12 == outC->_L21;
  kcg_copy_MetadataElement_T_Common_Types_Pkg(&outC->_L20, Metadata_Element);
  kcg_copy_MetadataElement_T_Common_Types_Pkg(&noname, &outC->_L20);
  kcg_copy_array_int_1(&outC->_L2, (array_int_1 *) &outC->_L9[4]);
  outC->_L17 = outC->_L2[0];
  outC->_L14 = outC->_L6[0];
  kcg_copy_array_int_231(&outC->_L13, (array_int_231 *) &outC->_L9[5]);
  outC->q_dir_int_1 = outC->_L14;
  outC->_9__L12_1 = outC->q_dir_int_1;
  outC->q_dir_in_1 = outC->_9__L12_1;
  outC->_12_IfBlock1_clock_1 = outC->q_dir_in_1 ==
    INT_Q_DIR_nomiinal_TM_conversions;
  if (outC->_12_IfBlock1_clock_1) {
    outC->_L4_120_IfBlock1 = ENUM_Q_DIR_nominal_TM_conversions;
    _26_q_dir_1 = outC->_L4_120_IfBlock1;
    outC->q_dir_1 = _26_q_dir_1;
  }
  else {
    outC->_19_else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
      INT_Q_DIR_reverse_TM_conversions;
    if (outC->_19_else_clock_1_IfBlock1) {
      outC->_L3_113_IfBlock1 = ENUM_Q_DIR_reverse_TM_conversions;
      q_dir_1 = outC->_L3_113_IfBlock1;
      _24_q_dir_1 = q_dir_1;
    }
    else {
      outC->_14_else_clock_1_IfBlock1 = outC->q_dir_in_1 ==
        INT_Q_DIR_both_TM_conversions;
      if (outC->_14_else_clock_1_IfBlock1) {
        outC->_L2_117_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _21_q_dir_1 = outC->_L2_117_IfBlock1;
        _18_q_dir_1 = _21_q_dir_1;
      }
      else {
        outC->_L2_115_IfBlock1 = ENUM_Q_DIR_both_TM_conversions;
        _19_q_dir_1 = outC->_L2_115_IfBlock1;
        _18_q_dir_1 = _19_q_dir_1;
      }
      _24_q_dir_1 = _18_q_dir_1;
    }
    outC->q_dir_1 = _24_q_dir_1;
  }
  outC->_L11 = outC->q_dir_1;
  outC->l_packet_int_1 = outC->_L15;
  outC->_L1_18 = outC->l_packet_int_1;
  outC->l_packet_1 = outC->_L1_18;
  outC->_L8 = outC->l_packet_1;
  outC->q_scale_int_1 = outC->_L16;
  outC->_L2_1 = outC->q_scale_int_1;
  outC->q_scale_in_1 = outC->_L2_1;
  outC->IfBlock1_clock_1 = outC->q_scale_in_1 ==
    INT_Q_SCALE_10cm_TM_conversions;
  if (outC->IfBlock1_clock_1) {
    outC->_L2_14_IfBlock1 = ENUM_Q_SCALE_10cm_TM_conversions;
    _10_q_scale_1 = outC->_L2_14_IfBlock1;
    outC->q_scale_1 = _10_q_scale_1;
  }
  else {
    outC->_3_else_clock_1_IfBlock1 = outC->q_scale_in_1 ==
      INT_Q_SCALE_1m_TM_conversions;
    if (outC->_3_else_clock_1_IfBlock1) {
      outC->_L1_1_IfBlock1 = ENUM_Q_SCALE_1m_TM_conversions;
      q_scale_1 = outC->_L1_1_IfBlock1;
      _8_q_scale_1 = q_scale_1;
    }
    else {
      outC->else_clock_1_IfBlock1 = outC->q_scale_in_1 ==
        INT_Q_SCALE_10m_TM_conversions;
      if (outC->else_clock_1_IfBlock1) {
        outC->_L1_12_IfBlock1 = ENUM_Q_SCALE_10m_TM_conversions;
        _5_q_scale_1 = outC->_L1_12_IfBlock1;
        _2_q_scale_1 = _5_q_scale_1;
      }
      else {
        outC->_L1_11_IfBlock1 = ENUM_Q_SCALE_10cm_TM_conversions;
        _3_q_scale_1 = outC->_L1_11_IfBlock1;
        _2_q_scale_1 = _3_q_scale_1;
      }
      _8_q_scale_1 = _2_q_scale_1;
    }
    outC->q_scale_1 = _8_q_scale_1;
  }
  outC->_L4 = outC->q_scale_1;
  outC->n_iter_int_1 = outC->_L17;
  outC->_L1_1 = outC->n_iter_int_1;
  outC->n_iter_1 = outC->_L1_1;
  outC->_L7 = outC->n_iter_1;
  /* 1 */
  C_P005_unflatten_sections_TM_lib_internal(
    outC->_L22,
    outC->_L7,
    &outC->_L13,
    &outC->Context_1);
  kcg_copy_P005_OBU_sectionlist_enum_T_TM(
    &outC->_L5,
    &outC->Context_1.sections);
  outC->_L10.valid = outC->_L22;
  outC->_L10.q_dir = outC->_L11;
  outC->_L10.l_packet = outC->_L8;
  outC->_L10.q_scale = outC->_L4;
  outC->_L10.n_iter = outC->_L7;
  kcg_copy_P005_OBU_sectionlist_enum_T_TM(&outC->_L10.sections, &outC->_L5);
  kcg_copy_P005_OBU_T_TM(&outC->P005_onboard, &outC->_L10);
  if (outC->IfBlock1_clock_1) {
    outC->_L3_15_IfBlock1 = kcg_false;
    _9_error_1 = outC->_L3_15_IfBlock1;
    outC->error_1 = _9_error_1;
  }
  else {
    if (outC->_3_else_clock_1_IfBlock1) {
      outC->_L3_1_IfBlock1 = kcg_false;
      error_1 = outC->_L3_1_IfBlock1;
      _7_error_1 = error_1;
    }
    else {
      if (outC->else_clock_1_IfBlock1) {
        outC->_L4_1_IfBlock1 = kcg_false;
        _6_error_1 = outC->_L4_1_IfBlock1;
        _1_error_1 = _6_error_1;
      }
      else {
        outC->_L2_1_IfBlock1 = kcg_true;
        _4_error_1 = outC->_L2_1_IfBlock1;
        _1_error_1 = _4_error_1;
      }
      _7_error_1 = _1_error_1;
    }
    outC->error_1 = _7_error_1;
  }
  outC->_L4_1 = outC->error_1;
  noname_1 = outC->_L4_1;
  outC->_L11_1 = 0;
  outC->_L10_1 = outC->_L1_1 < outC->_L11_1;
  _11_noname_1 = outC->_L10_1;
  outC->_L9_1 = 31;
  outC->_L12_1 = outC->_L1_1 > outC->_L9_1;
  _12_noname_1 = outC->_L12_1;
  outC->_L13_1 = 8191;
  outC->_6__L12_1 = 0;
  outC->_L9_17 = outC->_L1_18 > outC->_L13_1;
  outC->_L8_1 = outC->_L1_18 < outC->_6__L12_1;
  _13_noname_1 = outC->_L8_1;
  _14_noname_1 = outC->_L9_17;
  if (outC->_12_IfBlock1_clock_1) {
    outC->_L5_121_IfBlock1 = kcg_false;
    _25_error_1 = outC->_L5_121_IfBlock1;
    outC->_11_error_1 = _25_error_1;
  }
  else {
    if (outC->_19_else_clock_1_IfBlock1) {
      outC->_L5_1_IfBlock1 = kcg_false;
      _16_error_1 = outC->_L5_1_IfBlock1;
      _23_error_1 = _16_error_1;
    }
    else {
      if (outC->_14_else_clock_1_IfBlock1) {
        outC->_L4_118_IfBlock1 = kcg_false;
        _22_error_1 = outC->_L4_118_IfBlock1;
        _17_error_1 = _22_error_1;
      }
      else {
        outC->_L1_116_IfBlock1 = kcg_true;
        _20_error_1 = outC->_L1_116_IfBlock1;
        _17_error_1 = _20_error_1;
      }
      _23_error_1 = _17_error_1;
    }
    outC->_11_error_1 = _23_error_1;
  }
  outC->_10__L13_1 = outC->_11_error_1;
  _15_noname_1 = outC->_10__L13_1;
  outC->_L5_1 = 0;
  outC->_L4_123 = outC->_L1_124 < outC->_L5_1;
  outC->_L3_1 = 256;
  outC->_L2_122 = outC->_L1_124 > outC->_L3_1;
  _27_noname_1 = outC->_L2_122;
  _28_noname_1 = outC->_L4_123;
}
/* TM_conversions::C_P005_compr_onboard */
void C_P005_compr_onboard_TM_conversions(
  /* TM_conversions::C_P005_compr_onboard::PacketData */CompressedPacketData_T_Common_Types_Pkg *PacketData,
  /* TM_conversions::C_P005_compr_onboard::Metadata_Element */MetadataElement_T_Common_Types_Pkg *Metadata_Element,
  /* TM_conversions::C_P005_compr_onboard::P005_onboard */P005_OBU_T_TM *P005_onboard)
{
  /* TM_conversions::CAST_Int_to_Q_DIR::IfBlock1::else */
  static kcg_bool _2_else_clock_1_IfBlock1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::IfBlock1::else */
  static kcg_bool _1_else_clock_1_IfBlock1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::IfBlock1::else::else */
  static kcg_bool else_clock_1_IfBlock1;
  /* TM_conversions::CAST_Int_to_Q_SCALE::IfBlock1 */
  static kcg_bool IfBlock1_clock_1;
  /* TM_conversions::C_P005_compr_onboard::_L6 */
  static array_int_3 _L6;
  /* TM_conversions::C_P005_compr_onboard::_L2 */
  static array_int_1 _L2;
  /* TM_conversions::C_P005_compr_onboard::_L22 */
  static kcg_bool _L22;
  
  _L22 = (*PacketData)[0] == 5;
  (*P005_onboard).valid = _L22;
  kcg_copy_array_int_3(&_L6, (array_int_3 *) &(*PacketData)[1]);
  (*P005_onboard).l_packet = _L6[1];
  else_clock_1_IfBlock1 = _L6[0] == INT_Q_DIR_nomiinal_TM_conversions;
  IfBlock1_clock_1 = _L6[2] == INT_Q_SCALE_10cm_TM_conversions;
  kcg_copy_array_int_1(&_L2, (array_int_1 *) &(*PacketData)[4]);
  (*P005_onboard).n_iter = _L2[0];
  if (else_clock_1_IfBlock1) {
    (*P005_onboard).q_dir = ENUM_Q_DIR_nominal_TM_conversions;
  }
  else {
    _2_else_clock_1_IfBlock1 = _L6[0] == INT_Q_DIR_reverse_TM_conversions;
    if (_2_else_clock_1_IfBlock1) {
      (*P005_onboard).q_dir = ENUM_Q_DIR_reverse_TM_conversions;
    }
    else {
      _1_else_clock_1_IfBlock1 = _L6[0] == INT_Q_DIR_both_TM_conversions;
      if (_1_else_clock_1_IfBlock1) {
        (*P005_onboard).q_dir = ENUM_Q_DIR_both_TM_conversions;
      }
      else {
        (*P005_onboard).q_dir = ENUM_Q_DIR_both_TM_conversions;
      }
    }
  }
  if (IfBlock1_clock_1) {
    (*P005_onboard).q_scale = ENUM_Q_SCALE_10cm_TM_conversions;
  }
  else {
    _1_else_clock_1_IfBlock1 = _L6[2] == INT_Q_SCALE_1m_TM_conversions;
    if (_1_else_clock_1_IfBlock1) {
      (*P005_onboard).q_scale = ENUM_Q_SCALE_1m_TM_conversions;
    }
    else {
      else_clock_1_IfBlock1 = _L6[2] == INT_Q_SCALE_10m_TM_conversions;
      if (else_clock_1_IfBlock1) {
        (*P005_onboard).q_scale = ENUM_Q_SCALE_10m_TM_conversions;
      }
      else {
        (*P005_onboard).q_scale = ENUM_Q_SCALE_10cm_TM_conversions;
      }
    }
  }
  /* 1 */
  C_P005_unflatten_sections_TM_lib_internal(
    _L22,
    _L2[0],
    (P005_sections_array_flat_T_TM *) &(*PacketData)[5],
    &(*P005_onboard).sections);
}