/* InfraLib::Balise_Localisation */
void Balise_Localisation_InfraLib(
  /* InfraLib::Balise_Localisation::B_data_in */B_data_internal_T_InfraLib *B_data_in,
  /* InfraLib::Balise_Localisation::Header */BaliseTelegramHeader_int_T_TM *Header,
  /* InfraLib::Balise_Localisation::PIG_nom */kcg_int PIG_nom,
  /* InfraLib::Balise_Localisation::PIG_0_out */kcg_int *PIG_0_out,
  /* InfraLib::Balise_Localisation::TrainPass */kcg_bool *TrainPass)
{
  /* InfraLib::Balise_Localisation::_L76 */
  static kcg_real _L76;
  /* InfraLib::Balise_Localisation::_L93 */
  static kcg_real _L93;
  
  if (PIG_nom == 0) {
    *PIG_0_out = (*Header).n_pig;
  }
  else {
    *PIG_0_out = (*B_data_in).pig_nom_0;
  }
  _L76 = /* 1 */ Balise_Interdistance_InfraLib(*PIG_0_out, (*Header).n_pig) +
    /* 1 */
    TOOLS_convert_engineering_location_TM_conversions(
      (*B_data_in).engineering_BG_location);
  if (Half_Distance_Balises_in_BG_InfraLib <= ReleaseDelta_InfraLib) {
    _L93 = Half_Distance_Balises_in_BG_InfraLib;
  }
  else {
    _L93 = ReleaseDelta_InfraLib;
  }
  *TrainPass = (_L76 + _L93 > (*B_data_in).TrainPos) & (_L76 - _L93 <=
      (*B_data_in).TrainPos);
}
/* InfraLib::Balise_Localisation */
void Balise_Localisation_InfraLib(
  inC_Balise_Localisation_InfraLib *inC,
  outC_Balise_Localisation_InfraLib *outC)
{
  kcg_int noname;
  
  outC->_L92 = ReleaseDelta_InfraLib;
  outC->I2_1 = outC->_L92;
  outC->_L48 = inC->PIG_nom;
  outC->_L51 = 0;
  outC->_L50 = outC->_L48 == outC->_L51;
  kcg_copy_BaliseTelegramHeader_int_T_TM(&outC->_L16, &inC->Header);
  outC->_L47 = outC->_L16.n_pig;
  kcg_copy_B_data_internal_T_InfraLib(&outC->_L65, &inC->B_data_in);
  outC->_L66 = outC->_L65.pig_nom_0;
  if (outC->_L50) {
    outC->_L52 = outC->_L47;
  }
  else {
    outC->_L52 = outC->_L66;
  }
  /* 1 */
  Balise_Interdistance_InfraLib(outC->_L52, outC->_L47, &outC->Context_1);
  outC->_L75 = outC->Context_1.distance_BB;
  kcg_copy_B_data_internal_T_InfraLib(&outC->_L71, &inC->B_data_in);
  outC->_L68 = outC->_L71.engineering_BG_location;
  /* 1 */
  TOOLS_convert_engineering_TM_conversions(outC->_L68, &outC->_1_Context_1);
  outC->_L77 = outC->_1_Context_1.Loc_real;
  outC->_L76 = outC->_L75 + outC->_L77;
  outC->_L82 = Half_Distance_Balises_in_BG_InfraLib;
  outC->I1_1 = outC->_L82;
  outC->_L21_1 = outC->I1_1;
  outC->_L22_1 = outC->I2_1;
  outC->_L25_1 = outC->_L21_1 <= outC->_L22_1;
  if (outC->_L25_1) {
    outC->_L24_1 = outC->_L21_1;
  }
  else {
    outC->_L24_1 = outC->_L22_1;
  }
  outC->Mi_Output_1 = outC->_L24_1;
  outC->_L93 = outC->Mi_Output_1;
  outC->_L90 = outC->_L76 + outC->_L93;
  outC->_L73 = outC->_L71.TrainPos;
  outC->_L95 = outC->_L90 > outC->_L73;
  outC->_L91 = outC->_L76 - outC->_L93;
  outC->_L94 = outC->_L91 <= outC->_L73;
  outC->_L96 = outC->_L95 & outC->_L94;
  outC->TrainPass = outC->_L96;
  outC->PIG_0_out = outC->_L52;
  outC->_L15 = 0;
  noname = outC->_L15;
}