pfe_class_rtable_lookup_disable (const struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_rtable_lookup_disable (_1);
  return;

}


pfe_class_rtable_lookup_enable (const struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_rtable_lookup_enable (_1);
  return;

}


pfe_class_get_fw_version (const struct pfe_class_t * class, struct pfe_ct_version_t * ver)
{
  errno_t ret;
  union pfe_ct_pe_mmap_t pfe_pe_mmap;
  errno_t D.13391;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->pe_num;
  if (_1 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 3>; [INV]

  <bb 3> :
  _2 = &class->pe[0];
  _3 = pfe_pe_get_mmap (_2, &pfe_pe_mmap);
  if (_3 != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  ret = 22;
  goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  MEM[(char * {ref-all})ver] = MEM[(char * {ref-all})&pfe_pe_mmap + 4B];
  # DEBUG BEGIN_STMT
  ret = 0;

  <bb 6> :
  # DEBUG BEGIN_STMT
  D.13391 = ret;
  pfe_pe_mmap = {CLOBBER};
  return D.13391;

}


pfe_class_put_data (struct pfe_class_t * class, struct pfe_ct_buffer_t * buf)
{
  errno_t ret;
  uint32_t tries;
  uint32_t ii;
  errno_t D.13385;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ii = 0;
  goto <bb 11>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = &class->pe[ii];
  _2 = pfe_pe_lock (_1);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  tries = 0;

  <bb 4> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _3 = &class->pe[ii];
  ret = pfe_pe_put_data_nolock (_3, buf);
  # DEBUG BEGIN_STMT
  if (ret == 118)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  tries = tries + 1;
  # DEBUG BEGIN_STMT
  oal_time_usleep (200);

  <bb 6> :
  # DEBUG BEGIN_STMT
  if (ret == 118)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 7> :
  if (tries <= 9)
    goto <bb 4>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 8> :
  # DEBUG BEGIN_STMT
  _4 = &class->pe[ii];
  _5 = pfe_pe_unlock (_4);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  if (ret != 0)
    goto <bb 9>; [INV]
  else
    goto <bb 10>; [INV]

  <bb 9> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ret = 111;
  # DEBUG BEGIN_STMT
  goto <bb 12>; [INV]

  <bb 10> :
  # DEBUG BEGIN_STMT
  ii = ii + 1;

  <bb 11> :
  # DEBUG BEGIN_STMT
  _6 = class->pe_num;
  if (ii < _6)
    goto <bb 3>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 12> :
  # DEBUG BEGIN_STMT
  D.13385 = ret;
  return D.13385;

}


pfe_class_get_feature_next (struct pfe_class_t * class, struct pfe_fw_feature_t * * feature)
{
  errno_t ret;
  errno_t D.13374;

  <bb 2> :
  # DEBUG BEGIN_STMT
  ret = 2;
  # DEBUG BEGIN_STMT
  _1 = class->fw_features_count;
  if (_1 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _2 = class->current_feature;
  _3 = _2 + 1;
  _4 = class->fw_features_count;
  if (_3 < _4)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _5 = class->current_feature;
  _6 = _5 + 1;
  class->current_feature = _6;
  # DEBUG BEGIN_STMT
  _7 = class->current_feature;
  _8 = &class->fw_features[_7];
  *feature = _8;
  # DEBUG BEGIN_STMT
  ret = 0;

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13374 = ret;
  return D.13374;

}


pfe_class_get_feature_first (struct pfe_class_t * class, struct pfe_fw_feature_t * * feature)
{
  errno_t ret;
  errno_t D.13368;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->fw_features_count;
  if (_1 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  class->current_feature = 0;
  # DEBUG BEGIN_STMT
  _2 = class->current_feature;
  _3 = &class->fw_features[_2];
  *feature = _3;
  # DEBUG BEGIN_STMT
  ret = 0;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  ret = 2;

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13368 = ret;
  return D.13368;

}


pfe_class_get_feature (struct pfe_class_t * class, struct pfe_fw_feature_t * * feature, const char * name)
{
  errno_t ret_val;
  errno_t ret;
  const char * fname;
  uint32_t i;
  errno_t D.13362;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ret = 2;
  # DEBUG BEGIN_STMT
  ret_val = 0;
  # DEBUG BEGIN_STMT
  i = 0;
  goto <bb 7>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = &class->fw_features[i];
  ret_val = pfe_fw_feature_get_name (_1, &fname);
  # DEBUG BEGIN_STMT
  if (ret_val == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  fname.3_2 = fname;
  _3 = strcmp (fname.3_2, name);
  if (_3 == 0)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  _4 = &class->fw_features[i];
  *feature = _4;
  # DEBUG BEGIN_STMT
  ret = 0;
  # DEBUG BEGIN_STMT
  goto <bb 8>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  i = i + 1;

  <bb 7> :
  # DEBUG BEGIN_STMT
  _5 = class->fw_features_count;
  if (i < _5)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 8> :
  # DEBUG BEGIN_STMT
  D.13362 = ret;
  fname = {CLOBBER};
  return D.13362;

}


pfe_class_get_num_of_pes (const struct pfe_class_t * class)
{
  uint32_t pe_num;
  uint32_t D.13356;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  pe_num = class->pe_num;
  # DEBUG BEGIN_STMT
  D.13356 = pe_num;
  return D.13356;

}


pfe_class_set_default_vlan (const struct pfe_class_t * class, uint16_t vlan)
{
  errno_t ret;
  errno_t D.13354;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_set_def_vlan (_1, vlan);
  # DEBUG BEGIN_STMT
  ret = 0;
  # DEBUG BEGIN_STMT
  D.13354 = ret;
  return D.13354;

}


pfe_class_set_rtable (struct pfe_class_t * class, addr_t rtable_pa, uint32_t rtable_len, uint32_t entry_size)
{
  errno_t ret;
  errno_t D.13352;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->enabled;
  if (_1 != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  ret = 111;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _2 = class->cbus_base_va;
  ret = pfe_class_cfg_set_rtable (_2, rtable_pa, rtable_len, entry_size);

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13352 = ret;
  return D.13352;

}


pfe_class_destroy (struct pfe_class_t * class)
{
  uint32_t ii;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  if (class != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  pfe_class_disable (class);
  # DEBUG BEGIN_STMT
  _1 = &class->pe;
  _2 = class->pe_num;
  pfe_pe_destroy (_1, _2);
  # DEBUG BEGIN_STMT
  ii = 0;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _3 = &class->fw_features[ii];
  pfe_fw_feature_destroy (_3);
  # DEBUG BEGIN_STMT
  ii = ii + 1;

  <bb 5> :
  # DEBUG BEGIN_STMT
  _4 = class->fw_features_count;
  if (ii < _4)
    goto <bb 4>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  class->fw_features_count = 0;
  # DEBUG BEGIN_STMT
  class->pe_num = 0;
  # DEBUG BEGIN_STMT
  _5 = class->heap_context;
  if (_5 != 0B)
    goto <bb 7>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  _6 = class->heap_context;
  blalloc_destroy (_6);
  # DEBUG BEGIN_STMT
  class->heap_context = 0B;

  <bb 8> :
  return;

}


pfe_class_gather_read_dmem (struct pfe_class_t * class, void * dst_ptr, addr_t src_addr, uint32_t buffer_len, uint32_t read_len)
{
  errno_t ret;
  errno_t D.13343;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = &class->pe;
  _2 = class->pe_num;
  _3 = (long int) _2;
  ret = pfe_pe_gather_memcpy_from_dmem_to_host_32 (_1, _3, dst_ptr, src_addr, buffer_len, read_len);
  # DEBUG BEGIN_STMT
  D.13343 = ret;
  return D.13343;

}


pfe_class_read_dmem (void * class_p, int32_t pe_idx, void * dst_ptr, addr_t src_addr, uint32_t len)
{
  errno_t ret;
  struct pfe_class_t * class;
  errno_t D.13341;

  <bb 2> :
  # DEBUG BEGIN_STMT
  class = class_p;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->pe_num;
  _2 = (long int) _1;
  if (pe_idx >= _2)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ret = 22;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _3 = &class->pe[pe_idx];
  pfe_pe_memcpy_from_dmem_to_host_32 (_3, dst_ptr, src_addr, len);
  # DEBUG BEGIN_STMT
  ret = 0;

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13341 = ret;
  return D.13341;

}


pfe_class_write_dmem (void * class_p, int32_t pe_idx, addr_t dst_addr, const void * src_ptr, uint32_t len)
{
  errno_t ret;
  struct pfe_class_t * class;
  uint32_t ii;
  errno_t D.13336;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  class = class_p;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->pe_num;
  _2 = (long int) _1;
  if (pe_idx >= _2)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  ret = 22;
  goto <bb 10>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  if (pe_idx >= 0)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  _3 = &class->pe[pe_idx];
  pfe_pe_memcpy_from_host_to_dmem_32 (_3, dst_addr, src_ptr, len);
  goto <bb 9>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  ii = 0;
  goto <bb 8>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  _4 = &class->pe[ii];
  pfe_pe_memcpy_from_host_to_dmem_32 (_4, dst_addr, src_ptr, len);
  # DEBUG BEGIN_STMT
  ii = ii + 1;

  <bb 8> :
  # DEBUG BEGIN_STMT
  _5 = class->pe_num;
  if (ii < _5)
    goto <bb 7>; [INV]
  else
    goto <bb 9>; [INV]

  <bb 9> :
  # DEBUG BEGIN_STMT
  ret = 0;

  <bb 10> :
  # DEBUG BEGIN_STMT
  D.13336 = ret;
  return D.13336;

}


pfe_class_get_mmap (struct pfe_class_t * class, int32_t pe_idx, struct pfe_ct_class_mmap_t * mmap)
{
  union pfe_ct_pe_mmap_t mmap_tmp;
  errno_t ret;
  errno_t D.13327;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  mmap_tmp = {};
  # DEBUG BEGIN_STMT
  _1 = class->pe_num;
  _2 = (long int) _1;
  if (pe_idx >= _2)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  ret = 22;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _3 = &class->pe[pe_idx];
  ret = pfe_pe_get_mmap (_3, &mmap_tmp);
  # DEBUG BEGIN_STMT
  memcpy (mmap, &mmap_tmp.class_pe, 188);

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13327 = ret;
  mmap_tmp = {CLOBBER};
  return D.13327;

}


pfe_class_load_fw_features (struct pfe_class_t * class)
{
  errno_t ret;
  union pfe_ct_pe_mmap_t mmap;
  errno_t D.13306;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = &class->pe[0];
  ret = pfe_pe_get_mmap (_1, &mmap);
  # DEBUG BEGIN_STMT
  if (ret == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _2 = mmap.common.version.features_count;
  _3 = _2 >> 24;
  _4 = mmap.common.version.features_count;
  _5 = _4 >> 8;
  _6 = _5 & 65280;
  _7 = _3 | _6;
  _8 = mmap.common.version.features_count;
  _9 = _8 << 8;
  _10 = _9 & 16711680;
  _11 = _7 | _10;
  _12 = mmap.common.version.features_count;
  _13 = _12 << 24;
  _14 = _11 | _13;
  class->fw_features_count = _14;
  # DEBUG BEGIN_STMT
  _15 = class->fw_features_count;
  if (_15 != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _16 = class->fw_features_count;
  if (_16 > 22)
    goto <bb 5>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  class->fw_features_count = 0;
  # DEBUG BEGIN_STMT
  ret = 11;
  goto <bb 7>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  ret = pfe_class_load_fw_process (class);
  # DEBUG BEGIN_STMT

  <bb 7> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  D.13306 = ret;
  mmap = {CLOBBER};
  return D.13306;

}


pfe_class_load_fw_process (struct pfe_class_t * class)
{
  struct pfe_fw_feature_t * fw_features;
  bool_t val_break;
  struct pfe_ct_feature_desc_t * entry;
  uint32_t j;
  uint32_t i;
  errno_t ret;
  errno_t D.13321;

  <bb 2> :
  # DEBUG BEGIN_STMT
  ret = 22;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  val_break = 0;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  class->current_feature = 0;
  # DEBUG BEGIN_STMT
  i = 0;
  goto <bb 21>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = &class->fw_features[i];
  fw_features = pfe_fw_feature_create (_1);
  # DEBUG BEGIN_STMT
  if (fw_features == 0B)
    goto <bb 4>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  j = 0;
  goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  _2 = &class->fw_features[j];
  pfe_fw_feature_destroy (_2);
  # DEBUG BEGIN_STMT
  j = j + 1;

  <bb 6> :
  # DEBUG BEGIN_STMT
  if (j < i)
    goto <bb 5>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  ret = 11;
  # DEBUG BEGIN_STMT
  val_break = 1;
  goto <bb 19>; [INV]

  <bb 8> :
  # DEBUG BEGIN_STMT
  _3 = &class->pe[0];
  ret = pfe_pe_get_fw_feature_entry (_3, i, &entry);
  # DEBUG BEGIN_STMT
  if (ret != 0)
    goto <bb 9>; [INV]
  else
    goto <bb 13>; [INV]

  <bb 9> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  j = 0;
  goto <bb 11>; [INV]

  <bb 10> :
  # DEBUG BEGIN_STMT
  _4 = &class->fw_features[j];
  pfe_fw_feature_destroy (_4);
  # DEBUG BEGIN_STMT
  j = j + 1;

  <bb 11> :
  # DEBUG BEGIN_STMT
  if (j < i)
    goto <bb 10>; [INV]
  else
    goto <bb 12>; [INV]

  <bb 12> :
  # DEBUG BEGIN_STMT
  ret = 22;
  # DEBUG BEGIN_STMT
  val_break = 1;
  goto <bb 19>; [INV]

  <bb 13> :
  # DEBUG BEGIN_STMT
  entry.2_5 = entry;
  pfe_fw_feature_set_ll_data (fw_features, entry.2_5);
  # DEBUG BEGIN_STMT
  _6 = &class->pe[0];
  _7 = pfe_pe_get_fw_feature_str_base (_6);
  ret = pfe_fw_feature_set_string_base (fw_features, _7);
  # DEBUG BEGIN_STMT
  if (ret != 0)
    goto <bb 14>; [INV]
  else
    goto <bb 18>; [INV]

  <bb 14> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  j = 0;
  goto <bb 16>; [INV]

  <bb 15> :
  # DEBUG BEGIN_STMT
  _8 = &class->fw_features[j];
  pfe_fw_feature_destroy (_8);
  # DEBUG BEGIN_STMT
  j = j + 1;

  <bb 16> :
  # DEBUG BEGIN_STMT
  if (j < i)
    goto <bb 15>; [INV]
  else
    goto <bb 17>; [INV]

  <bb 17> :
  # DEBUG BEGIN_STMT
  ret = 22;
  # DEBUG BEGIN_STMT
  val_break = 1;
  goto <bb 19>; [INV]

  <bb 18> :
  # DEBUG BEGIN_STMT
  pfe_fw_feature_set_dmem_funcs (fw_features, pfe_class_read_dmem, pfe_class_write_dmem, class);

  <bb 19> :
  # DEBUG BEGIN_STMT
  if (val_break == 1)
    goto <bb 22>; [INV]
  else
    goto <bb 20>; [INV]

  <bb 20> :
  # DEBUG BEGIN_STMT
  i = i + 1;

  <bb 21> :
  # DEBUG BEGIN_STMT
  _9 = class->fw_features_count;
  if (i < _9)
    goto <bb 3>; [INV]
  else
    goto <bb 22>; [INV]

  <bb 22> :
  # DEBUG BEGIN_STMT
  if (ret != 0)
    goto <bb 23>; [INV]
  else
    goto <bb 24>; [INV]

  <bb 23> :
  # DEBUG BEGIN_STMT
  class->fw_features_count = 0;

  <bb 24> :
  # DEBUG BEGIN_STMT
  D.13321 = ret;
  entry = {CLOBBER};
  return D.13321;

}


pfe_class_load_firmware (struct pfe_class_t * class, const void * elf)
{
  errno_t ret;
  errno_t D.13287;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = &class->pe;
  _2 = class->pe_num;
  ret = pfe_pe_load_firmware (_1, _2, elf);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  if (ret == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  class->is_fw_loaded = 1;
  # DEBUG BEGIN_STMT
  _3 = &class->pe[0];
  ret = pfe_pe_check_mmap (_3);
  # DEBUG BEGIN_STMT
  if (ret == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  ret = pfe_class_dmem_heap_init (class);
  # DEBUG BEGIN_STMT

  <bb 5> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ret = pfe_class_load_fw_features (class);
  # DEBUG BEGIN_STMT

  <bb 6> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  D.13287 = ret;
  return D.13287;

}


pfe_class_disable (struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_disable (_1);
  return;

}


pfe_class_enable (struct pfe_class_t * class)
{
  pfe_ct_pe_sw_state_t state;
  uint16_t timeout;

  <bb 2> :
  # DEBUG BEGIN_STMT
  timeout = 50;
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->is_fw_loaded;
  _2 = _1 == 0;
  _3 = (long int) _2;
  _4 = __builtin_expect (_3, 0);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _5 = class->cbus_base_va;
  pfe_class_cfg_enable (_5);

  <bb 3> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  oal_time_usleep (5);
  # DEBUG BEGIN_STMT
  timeout.1_6 = timeout;
  timeout = timeout.1_6 + 65535;
  # DEBUG BEGIN_STMT
  _7 = &class->pe[0];
  state = pfe_pe_get_fw_state (_7);
  # DEBUG BEGIN_STMT
  if (state == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  if (timeout != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  if (timeout == 0)
    goto <bb 7>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  class->enabled = 1;

  <bb 7> :
  return;

}


pfe_class_reset (struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  pfe_class_disable (class);
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_reset (_1);
  # DEBUG BEGIN_STMT
  class->enabled = 0;
  return;

}


pfe_class_dmem_heap_free (const struct pfe_class_t * class, addr_t addr)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  if (addr == 0)
    goto <bb 5>; [INV]
  else
    goto <bb 3>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = class->dmem_heap_base;
  if (addr < _1)
    goto <bb 5>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  _2 = class->heap_context;
  _3 = class->dmem_heap_base;
  _4 = addr - _3;
  blalloc_free_offs (_2, _4);

  <bb 5> :
  return;

}


pfe_class_dmem_heap_alloc (const struct pfe_class_t * class, uint32_t size)
{
  errno_t ret;
  addr_t addr;
  addr_t D.13262;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = class->heap_context;
  ret = blalloc_alloc_offs (_1, size, 0, &addr);
  # DEBUG BEGIN_STMT
  if (ret == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _2 = class->dmem_heap_base;
  addr.0_3 = addr;
  _4 = _2 + addr.0_3;
  addr = _4;
  goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  addr = 0;

  <bb 5> :
  # DEBUG BEGIN_STMT
  D.13262 = addr;
  addr = {CLOBBER};
  return D.13262;

}


pfe_class_dmem_heap_init (struct pfe_class_t * class)
{
  errno_t ret;
  union pfe_ct_pe_mmap_t mmap;
  errno_t D.13294;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _1 = &class->pe[0];
  ret = pfe_pe_get_mmap (_1, &mmap);
  # DEBUG BEGIN_STMT
  if (ret == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _2 = mmap.class_pe.dmem_heap_size;
  _3 = _2 >> 24;
  _4 = mmap.class_pe.dmem_heap_size;
  _5 = _4 >> 8;
  _6 = _5 & 65280;
  _7 = _3 | _6;
  _8 = mmap.class_pe.dmem_heap_size;
  _9 = _8 << 8;
  _10 = _9 & 16711680;
  _11 = _7 | _10;
  _12 = mmap.class_pe.dmem_heap_size;
  _13 = _12 << 24;
  _14 = _11 | _13;
  _15 = blalloc_create (_14, 4);
  class->heap_context = _15;
  # DEBUG BEGIN_STMT
  _16 = class->heap_context;
  if (_16 == 0B)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  ret = 11;
  goto <bb 6>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  _17 = mmap.class_pe.dmem_heap_base;
  _18 = _17 >> 24;
  _19 = mmap.class_pe.dmem_heap_base;
  _20 = _19 >> 8;
  _21 = _20 & 65280;
  _22 = _18 | _21;
  _23 = mmap.class_pe.dmem_heap_base;
  _24 = _23 << 8;
  _25 = _24 & 16711680;
  _26 = _22 | _25;
  _27 = mmap.class_pe.dmem_heap_base;
  _28 = _27 << 24;
  _29 = _26 | _28;
  class->dmem_heap_base = _29;
  # DEBUG BEGIN_STMT
  ret = 0;

  <bb 6> :
  # DEBUG BEGIN_STMT
  D.13294 = ret;
  mmap = {CLOBBER};
  return D.13294;

}


pfe_class_create (addr_t cbus_base_va, uint32_t pe_num, const struct pfe_class_cfg_t * cfg)
{
  errno_t ret;
  struct pfe_class_t * class;
  struct pfe_class_t * D.13253;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  class = &classifier_instance;
  # DEBUG BEGIN_STMT
  memset (class, 0, 1364);
  # DEBUG BEGIN_STMT
  class->cbus_base_va = cbus_base_va;
  # DEBUG BEGIN_STMT
  if (pe_num != 0)
    goto <bb 3>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  ret = pfe_class_create_pe (class, cbus_base_va, pe_num);
  # DEBUG BEGIN_STMT
  if (ret != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  pfe_class_destroy (class);
  # DEBUG BEGIN_STMT
  class = 0B;

  <bb 5> :
  # DEBUG BEGIN_STMT
  if (class != 0B)
    goto <bb 6>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 6> :
  # DEBUG BEGIN_STMT
  pfe_class_reset (class);
  # DEBUG BEGIN_STMT
  oal_time_usleep (10);
  # DEBUG BEGIN_STMT
  pfe_class_disable (class);
  # DEBUG BEGIN_STMT
  _1 = class->cbus_base_va;
  pfe_class_cfg_set_config (_1, cfg);
  goto <bb 8>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  class = 0B;

  <bb 8> :
  # DEBUG BEGIN_STMT
  D.13253 = class;
  return D.13253;

}


pfe_class_create_pe (struct pfe_class_t * class, addr_t cbus_base_va, uint32_t pe_num)
{
  errno_t ret;
  uint32_t ii;
  struct pfe_pe_t * pe;
  errno_t D.13257;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  ret = 0;
  # DEBUG BEGIN_STMT
  ii = 0;
  goto <bb 6>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = (unsigned char) ii;
  _2 = &class->pe[ii];
  pe = pfe_pe_create (cbus_base_va, 1, _1, _2);
  # DEBUG BEGIN_STMT
  if (pe == 0B)
    goto <bb 4>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  ret = 2;
  # DEBUG BEGIN_STMT
  goto <bb 7>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  pfe_pe_set_iaccess (pe, 590084, 590088, 590080);
  # DEBUG BEGIN_STMT
  pfe_pe_set_dmem (pe, 536870912, 16384);
  # DEBUG BEGIN_STMT
  pfe_pe_set_imem (pe, 2680160256, 32768);
  # DEBUG BEGIN_STMT
  pfe_pe_set_lmem (pe, 3221356544, 0);
  # DEBUG BEGIN_STMT
  _3 = class->pe_num;
  _4 = _3 + 1;
  class->pe_num = _4;
  # DEBUG BEGIN_STMT
  ret = 0;
  # DEBUG BEGIN_STMT
  ii = ii + 1;

  <bb 6> :
  # DEBUG BEGIN_STMT
  if (ii < pe_num)
    goto <bb 3>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 7> :
  # DEBUG BEGIN_STMT
  D.13257 = ret;
  return D.13257;

}


pfe_class_irq_unmask (const struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  return;

}


pfe_class_irq_mask (const struct pfe_class_t * class)
{
  <bb 2> :
  # DEBUG BEGIN_STMT
  return;

}


pfe_class_isr (struct pfe_class_t * class)
{
  struct fci_msg_t msg;
  struct pfe_ct_buffer_t buf;
  errno_t ret;
  uint32_t i;
  errno_t D.13243;

  <bb 2> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  i = 0;
  goto <bb 7>; [INV]

  <bb 3> :
  # DEBUG BEGIN_STMT
  _1 = &class->pe[i];
  _2 = pfe_pe_lock (_1);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _3 = &class->pe[i];
  pfe_pe_get_fw_messages_nolock (_3);
  # DEBUG BEGIN_STMT
  _4 = &class->pe[i];
  pfe_pe_check_stalled_nolock (_4);
  # DEBUG BEGIN_STMT
  _5 = &class->pe[i];
  _6 = pfe_pe_get_data_nolock (_5, &buf);
  if (_6 == 0)
    goto <bb 4>; [INV]
  else
    goto <bb 6>; [INV]

  <bb 4> :
  # DEBUG BEGIN_STMT
  msg.msg_cmd.code = 62209;
  # DEBUG BEGIN_STMT
  _7 = buf.len;
  _8 = (long unsigned int) _7;
  msg.msg_cmd.length = _8;
  # DEBUG BEGIN_STMT
  _9 = msg.msg_cmd.length;
  if (_9 > 256)
    goto <bb 6>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  # DEBUG BEGIN_STMT
  _10 = buf.len;
  _11 = (unsigned int) _10;
  memcpy (&msg.msg_cmd.payload, &buf.payload, _11);
  # DEBUG BEGIN_STMT
  ret = fci_core_client_send_broadcast (&msg, 0B);
  # DEBUG BEGIN_STMT

  <bb 6> :
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  _12 = &class->pe[i];
  _13 = pfe_pe_unlock (_12);
  # DEBUG BEGIN_STMT
  # DEBUG BEGIN_STMT
  i = i + 1;

  <bb 7> :
  # DEBUG BEGIN_STMT
  _14 = class->pe_num;
  if (i < _14)
    goto <bb 3>; [INV]
  else
    goto <bb 8>; [INV]

  <bb 8> :
  # DEBUG BEGIN_STMT
  ret = 0;
  # DEBUG BEGIN_STMT
  D.13243 = ret;
  buf = {CLOBBER};
  msg = {CLOBBER};
  return D.13243;

}


