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

void main(int param_1,char **param_2)

{
  FILE *pFVar1;
  undefined **ppuVar2;
  int iVar3;
  char *pcVar4;
  size_t sVar5;
  int iVar6;
  int *piVar7;
  undefined4 uVar8;
  undefined **ppuVar9;
  sockaddr local_1098 [7];
  char acStack_1028 [4096];
  
  sloop_init(0);
LAB_00401348:
  while( true ) {
    while( true ) {
      iVar3 = getopt(param_1,param_2,"hvl:p:")   //possible issue identified - semgrep
      pcVar4 = _optarg;
      if (iVar3 < 1) {
        sloop_register_signal(2,FUN_004019b0,0);
        sloop_register_signal(0xf,FUN_004019b0,0);
        sloop_register_signal(9,FUN_004019b0,0);
        sloop_register_signal(0xd,&LAB_00401040,0);
        sloop_register_signal(0xe,FUN_004019b0,0);
        sloop_register_signal(0x10,FUN_0040196c,0);
        sloop_register_signal(0x11,FUN_0040196c,0);
        pcVar4 = realpath("/dev/log",acStack_1028)   //possible issue identified - semgrep
        if (pcVar4 != (char *)0x0) {
          unlink(acStack_1028)   //possible issue identified - semgrep
        }
        memset(local_1098,0,0x6e)   //possible issue identified - semgrep
        local_1098[0].sa_family = 1;
        strncpy(local_1098[0].sa_data,acStack_1028,0x6c)   //possible issue identified - semgrep
        iVar3 = socket(1,1,0);
        pFVar1 = _stderr;
        if (iVar3 < 0) {
          piVar7 = __errno_location();
          pcVar4 = strerror(*piVar7);
          fprintf(pFVar1,"%s: socket(): %s\n","open_unixsock",pcVar4);
        }
        else {
          sVar5 = strlen(local_1098[0].sa_data)   //possible issue identified - semgrep
          iVar6 = bind(iVar3,local_1098,sVar5 + 2)   //possible issue identified - semgrep
          pFVar1 = _stderr;
          if (iVar6 < 0) {
            piVar7 = __errno_location();
            pcVar4 = strerror(*piVar7);
            fprintf(pFVar1,"%s: unable to bind() : %s\n","open_unixsock",pcVar4);
          }
          else {
            sloop_register_read_sock(iVar3,&DAT_0040161c,0);
            sloop_run();
          }
          close(iVar3);
        }
        FUN_00401048("%s exit with code %d\n",&DAT_00406294,0);
                    /* WARNING: Subroutine does not return */
        exit(0);
      }
      if (iVar3 != 0x6c) break;
      PTR_s__etc_services_LOG_logd_helper_ph_004171b0 = _optarg;
    }
    if (iVar3 < 0x6d) {
      uVar8 = 0;
      if (iVar3 == 0x68) break;
      goto LAB_00401334;
    }
    if (iVar3 == 0x70) goto LAB_004012a4;
    uVar8 = 9;
    if (iVar3 != 0x76) break;
    DAT_00417350 = DAT_00417350 + 1;
  }
  goto LAB_00401338;
LAB_004012a4:
  ppuVar2 = &PTR_s_alert_00417040;
  if ((*(ushort *)(___ctype_b + *_optarg * 2) & 8) == 0) {
    do {
      ppuVar9 = ppuVar2;
      if (*ppuVar9 == (char *)0x0) {
        DAT_00417030 = (undefined *)0xffffffff;
        goto LAB_0040132c;
      }
      iVar3 = strcasecmp(pcVar4,*ppuVar9);
      ppuVar2 = ppuVar9 + 2;
    } while (iVar3 != 0);
    DAT_00417030 = ppuVar9[1];
  }
  else {
    DAT_00417030 = (undefined *)atoi(_optarg);
  }
LAB_0040132c:
  if ((int)DAT_00417030 < 0) {
LAB_00401334:
    uVar8 = 9;
LAB_00401338:
    FUN_004010a4(uVar8);
  }
  goto LAB_00401348;
}