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

undefined4 wfanotify_main(int param_1,char **param_2)

{
  int iVar1;
  FILE *pFVar2;
  int iVar3;
  undefined4 uVar4;
  char *pcVar5;
  int iVar6;
  size_t sVar7;
  char *local_9b0;
  char acStack_9ac [128];
  char acStack_92c [256];
  char local_82c;
  char acStack_82b [17];
  undefined1 auStack_81a [2034];
  
  local_9b0 = (char *)0x0;
LAB_0040dbf0:
  iVar1 = getopt(param_1,param_2,"hr:m:t:f:o:")   //possible issue identified - semgrep
  if (0 < iVar1) {
    uVar4 = 0xffffffff;
    switch(iVar1) {
    case 0x66:
      DAT_004322f0 = _optarg;
      goto LAB_0040dbf0;
    case 0x67:
    case 0x69:
    case 0x6a:
    case 0x6b:
    case 0x6c:
    case 0x6e:
    case 0x70:
    case 0x71:
    case 0x73:
      uVar4 = 0xffffffff;
      break;
    case 0x68:
      uVar4 = 0;
      break;
    case 0x6d:
      DAT_004322f4 = _optarg;
      goto LAB_0040dbf0;
    case 0x6f:
      DAT_004322fc = _optarg;
      goto LAB_0040dbf0;
    case 0x72:
      DAT_004322f8 = _optarg;
      goto LAB_0040dbf0;
    case 0x74:
      goto switchD_0040db80_caseD_74;
    }
    FUN_0040d310(uVar4);
    goto LAB_0040dbf0;
  }
  iVar1 = 0;
  if (DAT_004322f4 == (char *)0x0) {
    puts("No MAC address string specified!");
    iVar1 = -1;
  }
  if (DAT_00430460 < '\0') {
    puts("No type specified!");
  }
  else if (iVar1 == 0) goto LAB_0040dc80;
  FUN_0040d310(0xffffffff);
LAB_0040dc80:
  pFVar2 = _stdin;
  if (DAT_004322f0 != (char *)0x0) {
    pFVar2 = fopen(DAT_004322f0,"r")   //possible issue identified - semgrep
  }
  local_82c = DAT_00430460;
  strcpy(acStack_82b,DAT_004322f4)   //possible issue identified - semgrep
  sVar7 = 0;
  if ((pFVar2 != (FILE *)0x0) &&
     (sVar7 = fread(auStack_81a,1,0x7ee,pFVar2), DAT_004322f0 != (char *)0x0)) {   //possible issue identified - semgrep
    fclose(pFVar2);
  }
  base64encode(&local_82c,sVar7 + 0x12,&local_9b0);
  pcVar5 = local_9b0;
  if (local_9b0 == (char *)0x0) {
    pcVar5 = "";
  }
  snprintf(&local_82c,0x800,
           "<?xml version=\"1.0\"?>\r\n<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\r\n\t<e:property>\r\n\t\t<WLANEvent>%s</WLANEvent>\r\n\t</e:property>\r\n\t<e:property><APStatus>0</APStatus></e:property>\r\n\t<e:property><STAStatus>0</STAStatus></e:property>\r\n</e:propertyset>\r\n"
           ,pcVar5)   //possible issue identified - semgrep
  if (local_9b0 != (char *)0x0) {
    free(local_9b0);
  }
  if (DAT_004322f8 == (char *)0x0) {
    snprintf(acStack_92c,0x100,"/runtime/services/upnp/inf#")   //possible issue identified - semgrep
    xmldbc_get_wb(0,0,acStack_92c,acStack_9ac,0x80);
    iVar1 = 0;
    for (iVar6 = 1; iVar3 = atoi(acStack_9ac), iVar6 <= iVar3; iVar6 = iVar6 + 1) {
      snprintf(acStack_92c,0x100,"/runtime/services/upnp/inf:%d/WFAWLANConfig1",iVar6)   //possible issue identified - semgrep
      iVar3 = FUN_0040d89c(acStack_92c,&local_82c);
      iVar1 = iVar1 + iVar3;
    }
  }
  else {
    iVar1 = FUN_0040d89c(DAT_004322f8,&local_82c);
  }
  if ((DAT_004322fc != (char *)0x0) && (pFVar2 = fopen(DAT_004322fc,"w"), pFVar2 != (FILE *)0x0)) {   //possible issue identified - semgrep
    fprintf(pFVar2,"%d\n",iVar1);
    fclose(pFVar2);
  }
  return 0;
switchD_0040db80_caseD_74:
  iVar1 = atoi(_optarg);
  DAT_00430460 = (char)iVar1;
  goto LAB_0040dbf0;
}