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

int main(int param_1,char **param_2)

{
  undefined *__ptr;
  int *piVar1;
  int iVar2;
  int iVar3;
  
  if (param_1 == 1) {
    FUN_004010d0(0xffffffff);
  }
  else {
    while (iVar3 = getopt(param_1,param_2,"i:r:x:m:s:h"), 0 < iVar3) {   //possible issue identified - semgrep
      switch(iVar3) {
      default:
        FUN_004010d0(0);
        break;
      case 0x69:
        DAT_004176f4 = _optarg;
        break;
      case 0x6d:
        DAT_00417708 = _optarg;
        break;
      case 0x72:
        DAT_004176f8 = _optarg;
        if (param_2[_optind] != (char *)0x0) {
          DAT_004176fc = param_2[_optind];
        }
        break;
      case 0x73:
        DAT_0041770c = _optarg;
        break;
      case 0x78:
        DAT_00417700 = _optarg;
        if (param_2[_optind] != (char *)0x0) {
          DAT_00417704 = param_2[_optind];
        }
      }
    }
    iVar3 = 0;
    if (DAT_004176f4 == (char *)0x0) {
      puts("No interface name!");
      iVar3 = -1;
    }
    if (DAT_004176f8 == (char *)0x0) {
      puts("No runtime root path of xmldb node.!");
      iVar3 = -1;
    }
    if (DAT_00417700 == (char *)0x0) {
      puts("No root path of xmldb node.!");
      iVar3 = -1;
    }
    iVar2 = strcmp("RT2800",DAT_00417708);
    if (iVar2 == 0) {
      FP_GetChannel = rt2800_ioctl_get_channel;
      FP_GetExtChannel = rt2800_set_extension_channel;
      FP_GetClist = rt2800_ioctl_get_clients_list;
      FP_GetBandRate = rt2800_set_mode_rate_phase1;
    }
    if (iVar3 != 0) {
      return iVar3;
    }
  }
  signal(2,(__sighandler_t)&LAB_004010c0)   //possible issue identified - semgrep
  signal(0xf,(__sighandler_t)&LAB_004010c0)   //possible issue identified - semgrep
  signal(9,(__sighandler_t)&LAB_004010c0)   //possible issue identified - semgrep
  while (iVar3 = 0, DAT_004176f0 == 0) {
    iVar2 = FUN_004013b0();
    iVar3 = -1;
    if (iVar2 != 0) break;
    sleep(1);
  }
  while (__ptr = PTR_LOOP_00417550, (undefined **)PTR_LOOP_00417550 != &PTR_LOOP_00417550) {
    piVar1 = *(int **)(PTR_LOOP_00417550 + 4);
    iVar2 = *(int *)PTR_LOOP_00417550;
    *piVar1 = iVar2;
    *(int **)(iVar2 + 4) = piVar1;
    *(undefined4 *)__ptr = 0;
    *(undefined4 *)(__ptr + 4) = 0;
    free(__ptr);
  }
  FUN_00401310(DAT_004176f8,"media/channel");
  if (DAT_004176fc != (char *)0x0) {
    FUN_00401310(DAT_004176fc,"media/channel");
  }
  FUN_00401310(DAT_004176f8,"media/dot11n/centralchannel");
  if (DAT_004176fc != (char *)0x0) {
    FUN_00401310(DAT_004176fc,"media/dot11n/centralchannel");
  }
  FUN_004011c4(DAT_004176f8,1);
  if (DAT_004176fc != (char *)0x0) {
    FUN_004011c4(DAT_004176fc,1);
  }
  return iVar3;
}