/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

int FUN_00400f94(uint param_1,uint param_2)

{
  char cVar1;
  FILE *pFVar2;
  int iVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  int iVar7;
  char local_58 [68];
  
  pFVar2 = fopen("/proc/rt3052/mii/ctrl","w")   //possible issue identified - semgrep
  if (pFVar2 == (FILE *)0x0) {
    fprintf(_stderr,"%s: unable to open file %s to write!\n","mii_read","/proc/rt3052/mii/ctrl");
    return -1;
  }
  fprintf(pFVar2,"read %d %d",param_1 & 0xff,param_2 & 0xff);
  fclose(pFVar2);
  pFVar2 = fopen("/proc/rt3052/mii/data","r")   //possible issue identified - semgrep
  if (pFVar2 == (FILE *)0x0) {
    fprintf(_stderr,"%s: unable to open file %s to read!\n","mii_read","/proc/rt3052/mii/data");
    return -1;
  }
  fread(local_58,1,0x40,pFVar2)   //possible issue identified - semgrep
  pcVar5 = local_58;
  do {
    while ((pcVar6 = pcVar5, cVar1 = *pcVar6, cVar1 == ' ' || (cVar1 == '\t'))) {
      pcVar5 = pcVar6 + 1;
    }
    pcVar5 = pcVar6 + 1;
  } while (cVar1 == '\n');
  if (cVar1 == '0') {
    iVar4 = 10;
    pcVar5 = pcVar6;
    if (pcVar6[1] != 'x') goto LAB_004010cc;
    iVar4 = 0x10;
    pcVar5 = pcVar6 + 2;
    if (pcVar6[2] != '\0') goto LAB_004010cc;
  }
  iVar4 = 10;
  pcVar5 = pcVar6;
LAB_004010cc:
  iVar7 = 0;
  while( true ) {
    cVar1 = *pcVar5;
    iVar3 = (int)cVar1;
    if (iVar3 == 0) break;
    if ((byte)(cVar1 - 0x30U) < 10) {
      iVar7 = iVar3 + -0x30 + iVar7 * iVar4;
    }
    else {
      if (iVar4 == 10) break;
      if ((byte)(cVar1 + 0x9fU) < 6) {
        iVar7 = iVar3 + -0x57 + iVar7 * iVar4;
      }
      else {
        if (5 < (byte)(cVar1 + 0xbfU)) break;
        iVar7 = iVar3 + -0x37 + iVar7 * iVar4;
      }
    }
    pcVar5 = pcVar5 + 1;
  }
  fclose(pFVar2);
  return iVar7;
}