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

undefined4 FUN_0040bba0(undefined4 param_1)

{
  char *pcVar1;
  char *pcVar2;
  char *pcVar3;
  char *__s1;
  char *__s1_00;
  char *pcVar4;
  int iVar5;
  size_t sVar6;
  __pid_t _Var7;
  undefined4 uVar8;
  int iVar9;
  char acStack_228 [516];
  
  pcVar1 = getenv("SERVER_ID")   //possible issue identified - semgrep
  pcVar2 = getenv("HTTP_SID")   //possible issue identified - semgrep
  pcVar3 = getenv("HTTP_CALLBACK")   //possible issue identified - semgrep
  __s1 = getenv("HTTP_TIMEOUT")   //possible issue identified - semgrep
  __s1_00 = getenv("HTTP_NT")   //possible issue identified - semgrep
  pcVar4 = getenv("REMOTE_ADDR")   //possible issue identified - semgrep
  if (pcVar2 == (char *)0x0) {
    iVar5 = strcmp(__s1_00,"upnp:event");
    uVar8 = 0x19c;
    if ((iVar5 == 0) && (pcVar3 != (char *)0x0)) {
      iVar5 = strcasecmp(__s1,"Second-infinite");
      iVar9 = 0;
      if (iVar5 != 0) {
        iVar5 = strncasecmp(__s1,"Second-",7);
        uVar8 = 400;
        if (iVar5 != 0) goto LAB_0040bf44;
        iVar9 = atoi(__s1 + 7);
      }
      sVar6 = strlen(pcVar3);
      if (pcVar3[sVar6 - 1] == '>') {   //possible issue identified - semgrep
        pcVar3[sVar6 - 1] = '\0'   //possible issue identified - semgrep
      }
      pcVar3 = pcVar3 + (*pcVar3 == '<');
      iVar5 = strncmp(pcVar3,"http://",7);
      uVar8 = 0x19c;
      if (iVar5 == 0) {
        pcVar2 = strchr(pcVar3 + 7,0x2f);
        if (pcVar2 != (char *)0x0) {
          *pcVar2 = '\0';
          _Var7 = getpid();
          sprintf(acStack_228,
                  "%s\nMETHOD=SUBSCRIBE\nINF_UID=%s\nSERVICE=%s\nHOST=%s\nURI=/%s\nTIMEOUT=%d\nREMOTE=%s\nSHELL_FILE=%s/%s_%d.sh"
                  ,"/htdocs/upnp/run.NOTIFY.php",pcVar1,param_1,pcVar3 + 7,pcVar2 + 1,iVar9,pcVar4,
                  "/var/run",param_1,_Var7)   //possible issue identified - semgrep
          xmldbc_ephp(0,0,acStack_228,_stdout);
          fflush(_stdout);
          _Var7 = getpid();
          sprintf(acStack_228,"NOTIFY:0:sh %s/%s_%d.sh","/var/run",param_1,_Var7)   //possible issue identified - semgrep
          xmldbc_timer(0,0,acStack_228);
          return 0;
        }
        uVar8 = 0x19c;
      }
    }
  }
  else {
    uVar8 = 400;
    if ((pcVar3 == (char *)0x0) && (__s1_00 == (char *)0x0)) {
      iVar5 = strcasecmp(__s1,"Second-infinite");
      iVar9 = 0;
      if (iVar5 != 0) {
        iVar5 = strncasecmp(__s1,"Second-",7);
        uVar8 = 400;
        if (iVar5 != 0) goto LAB_0040bf44;
        iVar9 = atoi(__s1 + 7);
      }
      sprintf(acStack_228,
              "%s\nMETHOD=SUBSCRIBE\nINF_UID=%s\nSERVICE=%s\nSID=%s\nTIMEOUT=%d\nSHELL_FILE=%s/%s.sh"
              ,"/htdocs/upnp/run.NOTIFY.php",pcVar1,param_1,pcVar2,iVar9,"/var/run",param_1)   //possible issue identified - semgrep
      xmldbc_ephp(0,0,acStack_228,_stdout);
      return 0;
    }
  }
LAB_0040bf44:
  cgibin_print_http_status(uVar8,"","");
  return 0;
}