// Decompiled from acclient.exe — chunk 0x00580000
// Ghidra 12.0.4 + pyghidra headless

// --- FUN_00580b90 at 0x00580B90 (size: 458) ---


undefined4 FUN_00580b90(int *param_1)



{

  int iVar1;

  undefined4 uVar2;

  LONG LVar3;

  undefined4 uVar4;

  undefined4 *puStack_114;

  int *piStack_110;

  int local_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  uVar4 = 1;

  uVar2 = FUN_00404a40(0,*param_1 + 0x14);

  FUN_0042cbe0(uVar2,uVar4);

  LVar3 = InterlockedDecrement((LONG *)(local_10c + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(local_10c + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_10c + -0x14))(1);

  }

  FUN_006823d0();

  puStack_114 = (undefined4 *)0x0;

  piStack_110 = (int *)0x0;

  FUN_0042a2d0(0x8e);

  if (piStack_110 != (int *)0x0) {

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xac))(3);

  }

  local_10c = FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0xc3);

  if (piStack_110 != (int *)0x0) {

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xac))(1);

  }

  local_10c = FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0xc5);

  if (piStack_110 != (int *)0x0) {

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xc4))(local_90);

  }

  local_10c = FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_00478810(local_108);

  if (puStack_114 != (undefined4 *)0x0) {

    iVar1 = puStack_114[1];

    puStack_114[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*puStack_114)(1);

    }

    puStack_114 = (undefined4 *)0x0;

  }

  if (piStack_110 != (int *)0x0) {

    iVar1 = piStack_110[1];

    piStack_110[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*piStack_110)(1);

    }

    piStack_110 = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  return 0;

}





// --- FUN_00581190 at 0x00581190 (size: 697) ---


bool FUN_00581190(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  int *piVar4;

  int iVar5;

  LONG LVar6;

  undefined4 uVar7;

  undefined *puVar8;

  undefined4 *puVar9;

  bool local_131;

  undefined4 *local_130;

  undefined4 *local_12c;

  undefined4 *local_128;

  int *piStack_124;

  int iStack_120;

  undefined4 *local_11c;

  int *apiStack_118 [3];

  undefined4 auStack_10c [64];

  int local_c;

  undefined4 local_8;

  int iStack_4;

  

  local_131 = false;

  piVar4 = (int *)FUN_00415730(7,2,0x11);

  if (piVar4 != (int *)0x0) {

    local_11c = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    local_128 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    local_12c = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_0048c3e0(*param_1);

    iVar5 = FUN_005718a0(&local_130,&local_11c,&local_128,&local_12c);

    puVar9 = local_130;

    LVar6 = InterlockedDecrement(local_130 + 1);

    if ((LVar6 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    puVar9 = local_128;

    if (iVar5 != 0) {

      local_c = 0;

      local_8 = 0;

      iStack_4 = FUN_006b5b60(local_11c + 5);

      local_131 = iStack_4 != 0;

      if (local_131) {

        *(undefined4 *)((int)auStack_10c + local_c) = 1;

        local_c = local_c + 4;

        (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x98))(auStack_10c);

      }

      if (local_12c[2] != 1) {

        local_130 = (undefined4 *)0x1;

        uVar7 = FUN_00485200(apiStack_118,&DAT_007d0eb8);

        FUN_0048bc80(uVar7);

        if (apiStack_118[0] != (int *)0x0) {

          (**(code **)(*apiStack_118[0] + 0x14))();

        }

        piVar2 = piStack_124;

        if ((piStack_124 != (int *)0x0) && (-1 < iStack_120)) {

          FUN_00590c20(0x71,&local_130,0,0);

        }

        puVar8 = &DAT_007e2454;

        if (local_130 != (undefined4 *)0x1) {

          puVar8 = &DAT_007e2450;

        }

        FUN_0048c3e0(puVar8);

        FUN_0048c3e0(&DAT_007e244c);

        FUN_00566d10(apiStack_118,&piStack_124);

        LVar6 = InterlockedDecrement(apiStack_118[0] + 1);

        if ((LVar6 == 0) && (apiStack_118[0] != (int *)0x0)) {

          (**(code **)*apiStack_118[0])(1);

        }

        piVar3 = piStack_124;

        LVar6 = InterlockedDecrement(piStack_124 + 1);

        if ((LVar6 == 0) && (piVar3 != (int *)0x0)) {

          (**(code **)*piVar3)(1);

        }

        FUN_006a5320(&local_12c);

        if (piVar2 != (int *)0x0) {

          (**(code **)(*piVar2 + 0x14))();

        }

      }

      puVar9 = local_128;

      if (local_128[2] != 1) {

        FUN_0048c3e0(&DAT_007e2448);

        FUN_0057ddf0(0,&piStack_124,&local_128);

        LVar6 = InterlockedDecrement(piStack_124 + 1);

        if ((LVar6 == 0) && (piStack_124 != (int *)0x0)) {

          (**(code **)*piStack_124)(1);

        }

      }

    }

    (**(code **)(*piVar4 + 0x14))();

    puVar1 = local_12c;

    LVar6 = InterlockedDecrement(local_12c + 1);

    if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    LVar6 = InterlockedDecrement(puVar9 + 1);

    if ((LVar6 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    puVar9 = local_11c;

    LVar6 = InterlockedDecrement(local_11c + 1);

    if ((LVar6 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    return local_131;

  }

  return false;

}





// --- FUN_00581450 at 0x00581450 (size: 285) ---


void FUN_00581450(void)



{

  LONG LVar1;

  tm *_Tm;

  undefined4 *puVar2;

  int local_40c;

  int local_408;

  undefined4 uStack_404;

  char acStack_400 [1024];

  

  FUN_00401340(&DAT_007938af);

  FUN_00401340(&DAT_00795508);

  FUN_004053a0(&local_408,&local_40c);

  puVar2 = (undefined4 *)(local_408 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_408 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = (undefined4 *)(local_40c + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_40c + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  uStack_404 = FUN_0040fa90();

  _Tm = localtime((time_t *)&uStack_404);

  strftime(acStack_400,0x400,"%Y-%m-%d-%a",_Tm);

  FUN_00401340(acStack_400);

  FUN_00401340("%DATE%");

  FUN_004053a0(&local_40c,&local_408);

  LVar1 = InterlockedDecrement((LONG *)(local_40c + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_40c + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_40c + -0x14))(1);

  }

  LVar1 = InterlockedDecrement((LONG *)(local_408 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_408 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_408 + -0x14))(1);

  }

  return;

}





// --- FUN_00581570 at 0x00581570 (size: 366) ---


undefined4 FUN_00581570(int *param_1,undefined4 param_2)



{

  int *piVar1;

  int *piVar2;

  char cVar3;

  char *pcVar4;

  LONG LVar5;

  int iVar6;

  undefined4 *local_8;

  

  FUN_0048c3e0("[PKDe]");

  piVar1 = param_1;

  pcVar4 = strstr((char *)(*param_1 + 0x14),(char *)(local_8 + 5));

  if (pcVar4 == (char *)0x0) {

    pcVar4 = (char *)0xffffffff;

  }

  else {

    pcVar4 = pcVar4 + (-0x14 - *piVar1);

  }

  LVar5 = InterlockedDecrement(local_8 + 1);

  if ((LVar5 == 0) && (local_8 != (undefined4 *)0x0)) {

    (**(code **)*local_8)(1);

  }

  if (pcVar4 < (char *)0x80000000) {

    iVar6 = FUN_0055e1d0();

    if (iVar6 != 0) {

      FUN_0055e1d0();

      cVar3 = FUN_005d4740();

      if (cVar3 == '\0') {

        return 0;

      }

    }

    FUN_0048c3e0("[PKDe]");

    FUN_00566d10(&param_1,&DAT_008ef120);

    piVar2 = param_1;

    LVar5 = InterlockedDecrement(param_1 + 1);

    if ((LVar5 == 0) && (piVar2 != (int *)0x0)) {

      (**(code **)*piVar2)(1);

    }

  }

  FUN_0048c3e0(&DAT_007938af);

  iVar6 = FUN_0058a000(0,&param_1,param_2);

  piVar2 = param_1;

  LVar5 = InterlockedDecrement(param_1 + 1);

  if ((LVar5 == 0) && (piVar2 != (int *)0x0)) {

    (**(code **)*piVar2)(1);

  }

  if (iVar6 == 0) {

    FUN_0048c3e0(&DAT_00795508);

    piVar2 = param_1;

    if ((param_1[2] != 1) && (param_1 != DAT_008ef11c)) {

      FUN_004910c0(param_1 + 5,param_1[2] + -1);

    }

    LVar5 = InterlockedDecrement(piVar2 + 1);

    if (LVar5 == 0) {

      (**(code **)*piVar2)(1);

    }

    FUN_004882f0(*piVar1 + 0x14,param_2,1,0);

  }

  return 0;

}





// --- FUN_00581e50 at 0x00581E50 (size: 273) ---


void FUN_00581e50(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  char cVar2;

  uint uVar3;

  undefined4 uVar4;

  uint uVar5;

  LONG LVar6;

  undefined4 *puVar7;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  cVar2 = FUN_0040b580(param_2,0);

  if (cVar2 != '\0') {

    iVar1 = param_1[1];

    uVar3 = (**(code **)*param_1)();

    if (uVar3 < iVar1 + 1U) {

      uVar4 = (**(code **)*param_1)();

      param_1[1] = uVar4;

    }

    else {

      param_1[1] = iVar1 + 1U;

    }

    uVar3 = param_1[1];

    cVar2 = FUN_0040b580(param_3,0);

    if (cVar2 != '\0') {

      uVar5 = (**(code **)*param_1)();

      if (uVar5 < uVar3) {

        uVar4 = (**(code **)*param_1)();

        param_1[2] = uVar4;

      }

      else {

        param_1[2] = uVar3;

      }

      cVar2 = FUN_0040bf30(&local_4);

      if ((cVar2 != '\0') && (cVar2 = FUN_00581190(&local_4), cVar2 != '\0')) {

        FUN_0040b1b0(param_1[2] + -1);

        iVar1 = param_1[1];

        uVar3 = (**(code **)*param_1)();

        if (uVar3 < iVar1 + 1U) {

          uVar4 = (**(code **)*param_1)();

          param_1[1] = uVar4;

        }

        else {

          param_1[1] = iVar1 + 1U;

        }

        FUN_0040c9a0(&PTR_DAT_00818344);

        if (param_1[1] == 0) {

          param_1[1] = 0;

        }

        else {

          param_1[1] = param_1[1] + -1;

        }

      }

    }

  }

  puVar7 = (undefined4 *)(local_4 + -0x14);

  LVar6 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar6 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  return;

}





// --- FUN_00581f70 at 0x00581F70 (size: 330) ---


void FUN_00581f70(int *param_1)



{

  char cVar1;

  undefined **ppuVar2;

  LONG LVar3;

  undefined4 *unaff_EBX;

  undefined4 *unaff_retaddr;

  int iVar4;

  undefined **local_10;

  undefined **local_c;

  

  local_10 = &PTR_FUN_0079548c;

  local_c = (undefined **)0x0;

  cVar1 = (*(code *)PTR_FUN_00795494)(0);

  while (cVar1 != '\0') {

    FUN_00581e50(&stack0xffffffec,0x2a,0x2a);

    ppuVar2 = (undefined **)(*(code *)*unaff_EBX)();

    if (ppuVar2 < local_10) {

      local_10 = (undefined **)(*(code *)*unaff_EBX)();

    }

    ppuVar2 = (undefined **)(*(code *)*unaff_EBX)();

    if (ppuVar2 < local_c) {

      (*(code *)*unaff_EBX)();

    }

    FUN_00581e50(&stack0xffffffec,0x3c,0x3e);

    ppuVar2 = (undefined **)(*(code *)*unaff_EBX)();

    if (ppuVar2 < local_10) {

      local_c = (undefined **)(*(code *)*unaff_EBX)();

    }

    else {

      local_c = local_10;

    }

    cVar1 = (*(code *)unaff_EBX[2])(local_10);

  }

  iVar4 = DAT_00837748;

  InterlockedIncrement((LONG *)(DAT_00837748 + -0x10));

  FUN_00435720(1,1,iVar4);

  if (*(int *)(*param_1 + -4) != 1) {

    FUN_0048c3e0(*param_1);

    FUN_006a53e0(&stack0x00000000);

    LVar3 = InterlockedDecrement(unaff_retaddr + 1);

    if ((LVar3 == 0) && (unaff_retaddr != (undefined4 *)0x0)) {

      (**(code **)*unaff_retaddr)(1);

    }

  }

  return;

}





// --- FUN_005821a0 at 0x005821A0 (size: 909) ---


undefined4 __thiscall FUN_005821a0(int param_1,undefined4 *param_2,int param_3)



{

  int iVar1;

  BSTR pOVar2;

  int *piVar3;

  int *piVar4;

  LONG LVar5;

  undefined1 *puVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  undefined4 *puVar9;

  undefined1 auStack_c [4];

  undefined1 auStack_8 [4];

  undefined1 auStack_4 [4];

  

  iVar1 = FUN_0055b0a0();

  if (iVar1 != 0) {

    pOVar2 = SysAllocString((OLECHAR *)*param_2);

    param_2 = (undefined4 *)0x0;

    piVar3 = (int *)FUN_0055a740();

    (**(code **)(*piVar3 + 0x20))(piVar3,pOVar2,&param_2);

    if (param_2 != (undefined4 *)0x0) {

      return 1;

    }

  }

  *(int *)(param_1 + 0x8c) = param_3;

  piVar4 = (int *)FUN_00408fd0(&param_2,0);

  iVar1 = *(int *)(param_1 + 0x84);

  piVar3 = (int *)(param_1 + 0x84);

  if (iVar1 != *piVar4) {

    LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

    if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

    }

    iVar1 = *piVar4;

    *piVar3 = iVar1;

    InterlockedIncrement((LONG *)(iVar1 + -0x10));

  }

  puVar9 = param_2 + -5;

  LVar5 = InterlockedDecrement(param_2 + -4);

  if ((LVar5 == 0) && (puVar9 != (undefined4 *)0x0)) {

    (**(code **)*puVar9)(1);

  }

  iVar1 = DAT_00837748;

  InterlockedIncrement((LONG *)(DAT_00837748 + -0x10));

  FUN_00435720(1,1,iVar1);

  puVar6 = (undefined1 *)*piVar3;

  if (*(int *)(puVar6 + -4) == 0) {

    puVar6 = puVar6 + -1;

  }

  switch(*puVar6) {

  case 0x2f:

    FUN_00408770(0,0x40);

  case 0x40:

    uVar7 = FUN_0057eff0();

    return uVar7;

  case 0x3a:

  case 0x3b:

    FUN_00408770(0,0x20);

    puVar9 = &param_2;

    FUN_00401340("@emote");

    uVar7 = FUN_0040bbc0(puVar9,piVar3);

    FUN_00402070(uVar7);

    puVar9 = param_2 + -5;

    LVar5 = InterlockedDecrement(param_2 + -4);

    if ((LVar5 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    puVar9 = (undefined4 *)(param_3 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_3 + -0x10));

    if ((LVar5 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    uVar7 = FUN_0057eff0();

    return uVar7;

  }

  if ((*(int *)(param_1 + 0x8c) != 1) && (*(int *)(param_1 + 0x8c) != 8)) {

switchD_0058235f_caseD_0:

    FUN_00581f70(piVar3);

    return 1;

  }

  iVar1 = FUN_00589e90();

  switch(iVar1 + -1) {

  case 0:

    goto switchD_0058235f_caseD_0;

  case 1:

    iVar1 = FUN_00589fc0();

    if (iVar1 == 0) {

      return 1;

    }

    FUN_0048c3e0(*piVar3);

    FUN_006a54a0(&param_2,iVar1);

    FUN_005abb30();

    return 1;

  case 2:

    FUN_0048c3e0(*piVar3);

    FUN_006a4e50(0x800,&param_3);

    FUN_005abb30();

    return 1;

  case 3:

    FUN_0048c3e0(*piVar3);

    FUN_006a4e50(0x2000,auStack_c);

    FUN_005abb30();

    return 1;

  case 4:

    FUN_0048c3e0(*piVar3);

    FUN_006a4e50(0x4000,auStack_8);

    FUN_005abb30();

    return 1;

  case 5:

    FUN_0048c3e0(*piVar3);

    FUN_006a4e50(0x1000,auStack_4);

    FUN_005abb30();

    return 1;

  case 6:

    FUN_00589f20();

    uVar7 = FUN_004f1b20();

    break;

  case 7:

    FUN_00589f20();

    uVar7 = FUN_004f8d90();

    break;

  case 8:

    FUN_00589f20();

    uVar7 = FUN_004f8da0();

    break;

  case 9:

    FUN_00589f20();

    uVar7 = FUN_0051df70();

    break;

  case 10:

    FUN_00589f20();

    uVar7 = FUN_004f32b0();

    break;

  case 0xb:

    FUN_00589f20();

    uVar7 = FUN_006bd100();

    break;

  case 0xc:

    FUN_00589f20();

    uVar7 = FUN_004f24e0();

    iVar1 = FUN_00560f80();

    FUN_0057e820(uVar7,10,piVar3,iVar1 != 0);

    return 1;

  default:

    goto switchD_0058235f_default;

  }

  FUN_0055e1d0();

  uVar8 = FUN_005d4560();

  FUN_0057e820(uVar7,1,piVar3,uVar8);

switchD_0058235f_default:

  return 1;

}





// --- FUN_00582590 at 0x00582590 (size: 344) ---


undefined4 __thiscall FUN_00582590(int param_1,undefined4 *param_2)



{

  FILE *_File;

  char *pcVar1;

  undefined4 uVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined *local_40c;

  int local_408;

  int local_404;

  char local_400 [1024];

  

  _File = fopen((char *)*param_2,"rt");

  if (_File == (FILE *)0x0) {

    return 0;

  }

  local_40c = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  pcVar1 = fgets(local_400,0x400,_File);

  while (pcVar1 != (char *)0x0) {

    FUN_00405000(local_400);

    FUN_00581450(&local_40c);

    uVar7 = *(undefined4 *)(param_1 + 0x8c);

    uVar6 = 1;

    uVar5 = 0;

    uVar2 = FUN_00403350(&local_408,0);

    FUN_005649f0(uVar2,uVar5,uVar6,uVar7);

    puVar4 = (undefined4 *)(local_408 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(local_408 + -0x10));

    if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

    uVar7 = *(undefined4 *)(param_1 + 0x8c);

    uVar2 = FUN_00403350(&local_404,0);

    FUN_005821a0(uVar2,uVar7);

    puVar4 = (undefined4 *)(local_404 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(local_404 + -0x10));

    if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

    pcVar1 = fgets(local_400,0x400,_File);

  }

  fclose(_File);

  puVar4 = (undefined4 *)(local_40c + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(local_40c + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return 1;

}





// --- FUN_005827f0 at 0x005827F0 (size: 15280) ---


void FUN_005827f0(void)



{

  int *piVar1;

  LONG LVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 *puVar5;

  bool bVar6;

  int local_20;

  undefined1 *local_1c [2];

  int local_14;

  uint local_10;

  uint local_c;

  undefined4 uStack_8;

  uint local_4;

  

  local_10 = 0;

  local_c = 0;

  local_4 = 0;

  piVar1 = (int *)FUN_005df0f5(0x18);

  bVar6 = piVar1 == (int *)0x0;

  if (bVar6) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007953a4);

    *piVar1 = local_20;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_005806f0;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[4] = 0;

    piVar1[5] = 0;

  }

  bVar6 = !bVar6;

  uVar4 = (uint)bVar6;

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if (bVar6) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = 0;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    local_1c[0] = &LAB_005806f0;

    FUN_00401340(&DAT_007e2954);

    *piVar1 = local_20;

    uVar4 = uVar4 | 2;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[1] = 0;

    piVar1[4] = 0;

    piVar1[2] = (int)local_1c[0];

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 2) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffd;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("commands");

    *piVar1 = local_20;

    uVar4 = uVar4 | 4;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[4] = (int)FUN_0057f500;

    piVar1[1] = 0;

    piVar1[2] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 4) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffb;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("allegiances");

    *piVar1 = local_20;

    uVar4 = uVar4 | 8;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[4] = (int)FUN_0057e1d0;

    piVar1[1] = 0;

    piVar1[2] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 8) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffff7;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("allegiance");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x10;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057e2b0;

    piVar1[4] = (int)&LAB_0057bbe0;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x10) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffef;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    local_1c[0] = &LAB_0057e2b0;

    FUN_00401340(&DAT_007d10f8);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x20;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[4] = (int)&LAB_0057bbe0;

    piVar1[1] = 0;

    piVar1[2] = (int)local_1c[0];

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x20) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffdf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007e292c);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x40;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)FUN_00576fc0;

    piVar1[4] = (int)&LAB_0057bbe0;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x40) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffbf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007e2928);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x80;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0056fce0;

    piVar1[4] = (int)&LAB_0057bbe0;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((char)uVar4 < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffff7f;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    local_1c[0] = &LAB_0056fce0;

    FUN_00401340(&DAT_007e2924);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x100;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[4] = (int)&LAB_0057bbe0;

    piVar1[1] = 0;

    piVar1[2] = (int)local_1c[0];

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x100) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffeff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007e1c9c);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x200;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)FUN_00577f20;

    piVar1[4] = (int)&LAB_00578100;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x200) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffdff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("speaker");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x400;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057e7c0;

    piVar1[4] = (int)&LAB_00578160;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x400) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffbff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("channels");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x800;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[4] = (int)&LAB_005781b0;

    piVar1[1] = 0;

    piVar1[2] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x800) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffff7ff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007db4d4);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x1000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x1000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffefff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("co-vassals");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x2000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x2000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffdfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("covassals");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x4000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x4000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffbfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("covassal");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x8000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((char)(uVar4 >> 8) < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffff7fff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007db4d0);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x10000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x10000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffeffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("fellowship");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x20000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x20000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffdffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("fellows");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x40000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x40000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffbffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("fellow");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x80000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x80000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfff7ffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340(&DAT_007db4c4);

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x100000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x100000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffefffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  piVar1 = (int *)FUN_005df0f5(0x18);

  if (piVar1 == (int *)0x0) {

    piVar1 = (int *)0x0;

  }

  else {

    FUN_00401340("group");

    *piVar1 = local_20;

    uVar4 = uVar4 | 0x200000;

    InterlockedIncrement((LONG *)(local_20 + -0x10));

    piVar1[2] = (int)&LAB_0057bf00;

    piVar1[4] = (int)FUN_00570060;

    piVar1[1] = 0;

    piVar1[3] = 0;

    piVar1[5] = 0;

  }

  FUN_0041aeb0(local_1c,piVar1);

  if (local_14 == 0) {

    FUN_0057d780(piVar1);

  }

  if ((uVar4 & 0x200000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffdfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e28c4);

    uVar4 = uVar4 | 0x400000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffbfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("party");

    uVar4 = uVar4 | 0x800000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xff7fffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("monarch");

    uVar4 = uVar4 | 0x1000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfeffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_00795524);

    uVar4 = uVar4 | 0x2000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfdffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("patron");

    uVar4 = uVar4 | 0x4000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfbffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007db4cc);

    uVar4 = uVar4 | 0x8000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x8000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xf7ffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("vassals");

    uVar4 = uVar4 | 0x10000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xefffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("vassal");

    uVar4 = uVar4 | 0x20000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xdfffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007db4c8);

    uVar4 = uVar4 | 0x40000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057bf00,0,FUN_00570060,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xbfffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2894);

    uVar4 = uVar4 | 0x80000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005702e0,0,&LAB_00578350,0);

  }

  FUN_0057f460(uVar3);

  if ((int)uVar4 < 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_1c[0] = (undefined1 *)FUN_005df0f5(0x18);

  if (local_1c[0] == (undefined1 *)0x0) {

    uVar3 = 0;

    uVar4 = local_10;

  }

  else {

    FUN_00401340("leave");

    uVar3 = FUN_0056fae0(&local_20,&LAB_005705c0,0,&LAB_005783a0,0);

    uVar4 = 1;

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 1) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffe;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("chatting");

    uVar4 = uVar4 | 2;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_0057bf70,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 2) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffd;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e1cdc);

    uVar4 = uVar4 | 4;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005708a0,0,&LAB_00578620,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 4) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffb;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("notell");

    uVar4 = uVar4 | 8;

    uVar3 = FUN_0056fae0(&local_20,&DAT_005709a0,0,&LAB_00578680,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 8) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffff7;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("reply");

    uVar4 = uVar4 | 0x10;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005786e0,0,FUN_00578820,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffef;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007a76f0);

    uVar4 = uVar4 | 0x20;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005786e0,0,FUN_00578820,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffdf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2874);

    uVar4 = uVar4 | 0x40;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005786e0,0,FUN_00578820,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffbf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2870);

    uVar4 = uVar4 | 0x80;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_00578820,0);

  }

  FUN_0057f460(uVar3);

  if ((char)uVar4 < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffff7f;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e286c);

    uVar4 = uVar4 | 0x100;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_00578820,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x100) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffeff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("retell");

    uVar4 = uVar4 | 0x200;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005789a0,0,&LAB_00578b50,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x200) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffdff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e25f8);

    uVar4 = uVar4 | 0x400;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005789a0,0,&LAB_00578b50,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffbff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2860);

    uVar4 = uVar4 | 0x800;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005820c0,0,&LAB_00578bb0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffff7ff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_00795520);

    uVar4 = uVar4 | 0x1000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005820c0,0,&LAB_00578bb0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffefff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2858);

    uVar4 = uVar4 | 0x2000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578c10,0,&LAB_00578dd0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffdfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2854);

    uVar4 = uVar4 | 0x4000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578c10,0,&LAB_00578dd0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffbfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e284c);

    uVar4 = uVar4 | 0x8000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578c10,0,&LAB_00578dd0,0);

  }

  FUN_0057f460(uVar3);

  if ((char)(uVar4 >> 8) < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffff7fff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("whisper");

    uVar4 = uVar4 | 0x10000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578c10,0,&LAB_00578dd0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffeffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007955dc);

    uVar4 = uVar4 | 0x20000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578c10,0,&LAB_00578dd0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffdffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2840);

    uVar4 = uVar4 | 0x40000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057c1c0,0,FUN_00578e30,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffbffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("death");

    uVar4 = uVar4 | 0x80000;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_0057c680,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x80000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfff7ffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("consent");

    uVar4 = uVar4 | 0x100000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057eab0,0,&LAB_00578f90,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x100000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffefffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("corpse");

    uVar4 = uVar4 | 0x200000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578ff0,0,&LAB_00579200,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x200000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffdfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2824);

    uVar4 = uVar4 | 0x400000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00578ff0,0,&LAB_00579200,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffbfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2820);

    uVar4 = uVar4 | 0x800000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00580d60,0,&LAB_00579270,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xff7fffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("lifestone");

    uVar4 = uVar4 | 0x1000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570a40,0,FUN_005792d0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfeffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2810);

    uVar4 = uVar4 | 0x2000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570a40,0,FUN_005792d0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfdffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e280c);

    uVar4 = uVar4 | 0x4000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570a40,0,FUN_005792d0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfbffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("marketplace");

    uVar4 = uVar4 | 0x8000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570ab0,0,FUN_00579320,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x8000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xf7ffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27fc);

    uVar4 = uVar4 | 0x10000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570ab0,0,FUN_00579320,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xefffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27f8);

    uVar4 = uVar4 | 0x20000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570ab0,0,FUN_00579320,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xdfffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("permit");

    uVar4 = uVar4 | 0x40000000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00579370,0,&LAB_00579640,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xbfffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("pkarena");

    uVar4 = uVar4 | 0x80000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005796a0,0,FUN_00579750,0);

  }

  FUN_0057f460(uVar3);

  if ((int)uVar4 < 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_10 = FUN_005df0f5(0x18);

  if (local_10 == 0) {

    uVar3 = 0;

    uVar4 = local_c;

  }

  else {

    FUN_00401340(&DAT_007e27e4);

    uVar3 = FUN_0056fae0(&local_20,&LAB_005796a0,0,FUN_00579750,0);

    uVar4 = 1;

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 1) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffe;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("pklarena");

    uVar4 = uVar4 | 2;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005797a0,0,FUN_00579850,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 2) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffd;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27d4);

    uVar4 = uVar4 | 4;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005797a0,0,FUN_00579850,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 4) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffffb;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27d0);

    uVar4 = uVar4 | 8;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005798a0,0,FUN_00579950,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 8) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffff7;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27cc);

    uVar4 = uVar4 | 0x10;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005798a0,0,FUN_00579950,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffef;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("emote");

    uVar4 = uVar4 | 0x20;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005798a0,0,FUN_00579950,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffdf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e27c0);

    uVar4 = uVar4 | 0x40;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005798a0,0,FUN_00579950,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffffbf;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("emotes");

    uVar4 = uVar4 | 0x80;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057c900,0,&LAB_00579a30,0);

  }

  FUN_0057f460(uVar3);

  if ((char)uVar4 < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffff7f;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("fillcomps");

    uVar4 = uVar4 | 0x100;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00570b20,0,&LAB_00579a80,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x100) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffeff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("loadfile");

    uVar4 = uVar4 | 0x200;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005826f0,0,&LAB_0057b6c0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x200) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffdff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("friends");

    uVar4 = uVar4 | 0x400;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057c9d0,0,&LAB_00579d10,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffffbff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("friends_add");

    uVar4 = uVar4 | 0x800;

    uVar3 = FUN_0056fae0(&local_20,FUN_00579d80,0,&LAB_00579d10,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffff7ff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("friends_remove");

    uVar4 = uVar4 | 0x1000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00579e50,0,&LAB_00579d10,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffefff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("house");

    uVar4 = uVar4 | 0x2000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005816e0,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffdfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2778);

    uVar4 = uVar4 | 0x4000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005816e0,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffffbfff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("hslist");

    uVar4 = uVar4 | 0x8000;

    uVar3 = FUN_0056fae0(&local_20,FUN_005712e0,0,&LAB_0057a910,0);

  }

  FUN_0057f460(uVar3);

  if ((char)(uVar4 >> 8) < '\0') {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffff7fff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e276c);

    uVar4 = uVar4 | 0x10000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571220,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffeffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2768);

    uVar4 = uVar4 | 0x20000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571220,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffdffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2764);

    uVar4 = uVar4 | 0x40000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571280,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfffbffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2760);

    uVar4 = uVar4 | 0x80000;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571280,0,&LAB_0057a8a0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x80000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfff7ffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("squelch");

    uVar4 = uVar4 | 0x100000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057cd20,0,FUN_0057cf60,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x100000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffefffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("unsquelch");

    uVar4 = uVar4 | 0x200000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057ce40,0,FUN_0057cf60,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x200000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffdfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("messagetypes");

    uVar4 = uVar4 | 0x400000;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057ade0,0,&LAB_0056f380,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xffbfffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("message_types");

    uVar4 = uVar4 | 0x800000;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057ade0,0,&LAB_0056f380,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xff7fffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("msgtypes");

    uVar4 = uVar4 | 0x1000000;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057ade0,0,&LAB_0056f380,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfeffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("msg_types");

    uVar4 = uVar4 | 0x2000000;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057ade0,0,&LAB_0056f380,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000000) != 0) {

    puVar5 = (undefined4 *)(local_20 + -0x14);

    uVar4 = uVar4 & 0xfdffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && (puVar5 != (undefined4 *)0x0)) {

      (**(code **)*puVar5)(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("status");

    uVar4 = uVar4 | 0x4000000;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_0057d1e0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000000) != 0) {

    uVar4 = uVar4 & 0xfbffffff;

    LVar2 = InterlockedDecrement((LONG *)(local_20 + -0x10));

    if ((LVar2 == 0) && ((undefined4 *)(local_20 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_20 + -0x14))(1);

    }

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2708);

    uVar4 = uVar4 | 0x8000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057d370,0,FUN_0057ae80,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x8000000) != 0) {

    uVar4 = uVar4 & 0xf7ffffff;

    FUN_004010a0();

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("birth");

    uVar4 = uVar4 | 0x10000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0056f3a0,0,FUN_0057aed0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000000) != 0) {

    uVar4 = uVar4 & 0xefffffff;

    FUN_004010a0();

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e26fc);

    uVar4 = uVar4 | 0x20000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005714c0,0,FUN_0057af20,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000000) != 0) {

    uVar4 = uVar4 & 0xdfffffff;

    FUN_004010a0();

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("endurance");

    uVar4 = uVar4 | 0x40000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057d3c0,0,&LAB_0057af70,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000000) != 0) {

    uVar4 = uVar4 & 0xbfffffff;

    FUN_004010a0();

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("framerate");

    uVar4 = uVar4 | 0x80000000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_005715a0,0,FUN_0057afd0,0);

  }

  FUN_0057f460(uVar3);

  if ((int)uVar4 < 0) {

    FUN_004010a0();

  }

  local_c = FUN_005df0f5(0x18);

  if (local_c == 0) {

    uVar3 = 0;

    uVar4 = local_4;

  }

  else {

    FUN_00401340(&DAT_007e26e0);

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b020,0,&LAB_0057b200,0);

    uVar4 = 1;

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 1) != 0) {

    uVar4 = uVar4 & 0xfffffffe;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("pklite");

    uVar4 = uVar4 | 2;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b260,0,&LAB_0057b310,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 2) != 0) {

    uVar4 = uVar4 & 0xfffffffd;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e26d4);

    uVar4 = uVar4 | 4;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b260,0,&LAB_0057b310,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 4) != 0) {

    uVar4 = uVar4 & 0xfffffffb;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("render");

    uVar4 = uVar4 | 8;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057ee30,0,0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 8) != 0) {

    uVar4 = uVar4 & 0xfffffff7;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("version");

    uVar4 = uVar4 | 0x10;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057eec0,0,FUN_0057b370,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10) != 0) {

    uVar4 = uVar4 & 0xffffffef;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("saveui");

    uVar4 = uVar4 | 0x20;

    uVar3 = FUN_0056fae0(&local_20,FUN_00570dc0,0,&LAB_00579af0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20) != 0) {

    uVar4 = uVar4 & 0xffffffdf;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("loadui");

    uVar4 = uVar4 | 0x40;

    uVar3 = FUN_0056fae0(&local_20,FUN_00570f20,0,&LAB_00579b60,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40) != 0) {

    uVar4 = uVar4 & 0xffffffbf;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("saveautoui");

    uVar4 = uVar4 | 0x80;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571080,0,&LAB_00579bd0,0);

  }

  FUN_0057f460(uVar3);

  if ((char)uVar4 < '\0') {

    uVar4 = uVar4 & 0xffffff7f;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("loadautoui");

    uVar4 = uVar4 | 0x100;

    uVar3 = FUN_0056fae0(&local_20,FUN_00571100,0,&LAB_00579c40,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x100) != 0) {

    uVar4 = uVar4 & 0xfffffeff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("lockui");

    uVar4 = uVar4 | 0x200;

    uVar3 = FUN_0056fae0(&local_20,&LAB_00571180,0,&LAB_00579cb0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x200) != 0) {

    uVar4 = uVar4 & 0xfffffdff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e268c);

    uVar4 = uVar4 | 0x400;

    uVar3 = FUN_0056fae0(&local_20,0,0,FUN_0057d490,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x400) != 0) {

    uVar4 = uVar4 & 0xfffffbff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("clear");

    uVar4 = uVar4 | 0x800;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0056f3b0,0,FUN_0057b3c0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x800) != 0) {

    uVar4 = uVar4 & 0xfffff7ff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("filter");

    uVar4 = uVar4 | 0x1000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057d630,0,&LAB_0057b600,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x1000) != 0) {

    uVar4 = uVar4 & 0xffffefff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("unfilter");

    uVar4 = uVar4 | 0x2000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057d650,0,&LAB_0057b660,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x2000) != 0) {

    uVar4 = uVar4 & 0xffffdfff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007e2674);

    uVar4 = uVar4 | 0x4000;

    uVar3 = FUN_0056fae0(&local_20,FUN_0057f200,0,&LAB_0057b720,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x4000) != 0) {

    uVar4 = uVar4 & 0xffffbfff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("title");

    uVar4 = uVar4 | 0x8000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b410,0,FUN_0057b5b0,0);

  }

  FUN_0057f460(uVar3);

  if ((char)(uVar4 >> 8) < '\0') {

    uVar4 = uVar4 & 0xffff7fff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("index");

    uVar4 = uVar4 | 0x10000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0056f3f0,0,0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x10000) != 0) {

    uVar4 = uVar4 & 0xfffeffff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340("clist");

    uVar4 = uVar4 | 0x20000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b780,0,0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x20000) != 0) {

    uVar4 = uVar4 & 0xfffdffff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    FUN_00401340(&DAT_007d14dc);

    uVar4 = uVar4 | 0x40000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b850,0,0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x40000) != 0) {

    uVar4 = uVar4 & 0xfffbffff;

    FUN_004010a0();

  }

  local_4 = FUN_005df0f5(0x18);

  if (local_4 == 0) {

    uVar3 = 0;

  }

  else {

    uStack_8 = 0;

    FUN_00401340(&DAT_007d14d8);

    uVar4 = uVar4 | 0x80000;

    uVar3 = FUN_0056fae0(&local_20,&LAB_0057b920,0,0,0);

  }

  FUN_0057f460(uVar3);

  if ((uVar4 & 0x80000) != 0) {

    FUN_004010a0();

  }

  return;

}





// --- FUN_005863a0 at 0x005863A0 (size: 300) ---


undefined4 * __fastcall FUN_005863a0(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int *piVar4;

  LONG *pLVar5;

  

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_LAB_007a6af4;

  puVar1 = param_1 + 1;

  *param_1 = &PTR_LAB_007d13b0;

  *puVar1 = &PTR_FUN_007d1108;

  param_1[2] = &PTR_LAB_007d1100;

  param_1[4] = 1;

  param_1[3] = &PTR_LAB_00793b6c;

  FUN_0057d6f0(100);

  pLVar5 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x21] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar5);

  pLVar5 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x22] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar5);

  param_1[0x23] = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  pLVar5 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x26] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar5);

  puVar2 = DAT_008718dc;

  if (DAT_008718dc != DAT_008ef11c) {

    LVar3 = InterlockedDecrement(DAT_008718dc + 1);

    if ((LVar3 == 0) && (puVar2 != (undefined4 *)0x0)) {

      (**(code **)*puVar2)(1);

    }

    DAT_008718dc = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

  }

  DAT_008717fc = param_1;

  InterlockedIncrement(param_1 + 4);

  FUN_005827f0();

  piVar4 = (int *)FUN_0043c680();

  if (piVar4 != (int *)0x0) {

    (**(code **)(*piVar4 + 4))(0x186a5,puVar1);

    (**(code **)(*piVar4 + 4))(0x186b7,puVar1);

    (**(code **)(*piVar4 + 4))(0x4dd1f0,puVar1);

    (**(code **)(*piVar4 + 4))(0x4dd21f,puVar1);

  }

  return param_1;

}





// --- FUN_005864d0 at 0x005864D0 (size: 35) ---


void __fastcall FUN_005864d0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007e2b3c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_00586520 at 0x00586520 (size: 23) ---


undefined4 FUN_00586520(undefined4 param_1,undefined4 param_2)



{

  FUN_006a9f60(param_1,param_2);

  return 0;

}





// --- FUN_00586540 at 0x00586540 (size: 23) ---


undefined4 FUN_00586540(undefined4 param_1,undefined4 param_2)



{

  FUN_006aa0e0(param_1,param_2);

  return 0;

}





// --- FUN_00586560 at 0x00586560 (size: 23) ---


undefined4 FUN_00586560(undefined4 param_1,undefined4 param_2)



{

  FUN_006a9fc0(param_1,param_2);

  return 0;

}





// --- FUN_00586580 at 0x00586580 (size: 28) ---


undefined4 FUN_00586580(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_006aa080(param_1,param_2,param_3);

  return 0;

}





// --- FUN_005865a0 at 0x005865A0 (size: 28) ---


undefined4 FUN_005865a0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_006aa020(param_1,param_2,param_3);

  return 0;

}





// --- FUN_005865c0 at 0x005865C0 (size: 23) ---


undefined4 FUN_005865c0(undefined4 param_1,undefined4 param_2)



{

  FUN_006a9f00(param_1,param_2);

  return 0;

}





// --- FUN_005866b0 at 0x005866B0 (size: 43) ---


int __fastcall FUN_005866b0(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_005864d0();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_005866e0 at 0x005866E0 (size: 57) ---


undefined4 * __fastcall FUN_005866e0(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007e2b3c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  DAT_0087190c = param_1;

  InterlockedIncrement(param_1 + 3);

  return param_1;

}





// --- FUN_00586720 at 0x00586720 (size: 70) ---


void __thiscall FUN_00586720(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x118) != 0) {

    FUN_005affb0();

    return;

  }

  iVar1 = FUN_005df0f5(0x84);

  if (iVar1 != 0) {

    uVar2 = FUN_005b0060(param_2);

    *(undefined4 *)(param_1 + 0x118) = uVar2;

    return;

  }

  *(undefined4 *)(param_1 + 0x118) = 0;

  return;

}





// --- FUN_00586770 at 0x00586770 (size: 35) ---


void __fastcall FUN_00586770(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007e2d4c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_005867c0 at 0x005867C0 (size: 23) ---


undefined4 FUN_005867c0(undefined4 param_1,undefined4 param_2)



{

  FUN_006ac0c0(param_1,param_2);

  return 0;

}





// --- FUN_005867e0 at 0x005867E0 (size: 18) ---


undefined4 FUN_005867e0(undefined4 param_1)



{

  FUN_006ac020(param_1);

  return 0;

}





// --- FUN_00586800 at 0x00586800 (size: 18) ---


undefined4 FUN_00586800(undefined4 param_1)



{

  FUN_006ac070(param_1);

  return 0;

}





// --- FUN_00586820 at 0x00586820 (size: 18) ---


undefined4 FUN_00586820(undefined4 param_1)



{

  FUN_006ac170(param_1);

  return 0;

}





// --- FUN_00586840 at 0x00586840 (size: 18) ---


undefined4 FUN_00586840(undefined4 param_1)



{

  FUN_006ac120(param_1);

  return 0;

}





// --- FUN_00586860 at 0x00586860 (size: 81) ---


undefined4 FUN_00586860(undefined4 param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  

  if (param_2 != 0) {

    if (DAT_0083da58 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_2 != iVar1) {

      iVar1 = FUN_005583f0(param_2);

      if (iVar1 != 0) {

        iVar1 = FUN_0058d980(param_1);

        if (iVar1 != 0) {

          FUN_00586720(param_3);

        }

      }

    }

  }

  return 0;

}





// --- FUN_00586990 at 0x00586990 (size: 43) ---


int __fastcall FUN_00586990(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_00586770();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_005869c0 at 0x005869C0 (size: 57) ---


undefined4 * __fastcall FUN_005869c0(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007e2d4c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  DAT_008719bc = param_1;

  InterlockedIncrement(param_1 + 3);

  return param_1;

}





// --- FUN_00586a00 at 0x00586A00 (size: 146) ---


undefined4 FUN_00586a00(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined4 *local_4;

  

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_005b06f0(&local_4,0);

  FUN_00404a40(0,local_4 + 5);

  FUN_005649f0(&param_1,0,1,0);

  puVar2 = (undefined4 *)(param_1 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = local_4;

  LVar1 = InterlockedDecrement(local_4 + 1);

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  return 0;

}





// --- FUN_00586aa0 at 0x00586AA0 (size: 298) ---


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



void __thiscall FUN_00586aa0(undefined4 param_1,int param_2)



{

  undefined *puVar1;

  LONG LVar2;

  undefined *puVar3;

  undefined4 *puVar4;

  int local_8c;

  int local_88;

  int local_84;

  int local_80;

  undefined4 local_7c;

  undefined4 *local_74;

  char local_70 [108];

  

  local_7c = param_1;

  for (local_74 = *(undefined4 **)(param_2 + 4); local_74 != (undefined4 *)0x0;

      local_74 = (undefined4 *)local_74[1]) {

    FUN_00497d70(*local_74,&local_88,&local_84);

    puVar3 = &DAT_007ac7b8;

    if (local_88 < 0x400) {

      puVar3 = &DAT_007ac7b4;

    }

    puVar1 = &DAT_0079ab78;

    if (local_84 < 0x400) {

      puVar1 = &DAT_007ac7b0;

    }

    local_80 = local_84 + -0x400;

    _snprintf(local_70,99,"     %.1f%s, %.1f%s\n",

              ABS((double)local_80 * _DAT_007a7e00 + _DAT_00799088),puVar1,

              ABS((double)(local_88 + -0x400) * _DAT_007a7e00 + _DAT_00799088),puVar3);

    FUN_00404a40();

    FUN_005649f0(&local_8c,0,1,0);

    puVar4 = (undefined4 *)(local_8c + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(local_8c + -0x10));

    if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

  }

  return;

}





// --- FUN_00586bd0 at 0x00586BD0 (size: 305) ---


undefined4 FUN_00586bd0(int param_1,undefined4 param_2,int param_3)



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  char *pcVar5;

  undefined4 *local_4;

  

  puVar4 = DAT_008ef11c;

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  switch(param_1) {

  case 1:

    pcVar5 = "cottages";

    break;

  case 2:

    pcVar5 = "villas";

    break;

  case 3:

    pcVar5 = "mansions";

    break;

  case 4:

    pcVar5 = "apartments";

    break;

  default:

    goto switchD_00586bf7_default;

  }

  FUN_004034c0(pcVar5);

  puVar4 = local_4;

switchD_00586bf7_default:

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_00487620(&local_4,"There are %d %s available.\n",param_3,puVar4 + 5);

  puVar1 = local_4;

  FUN_00404a40(0,local_4 + 5);

  FUN_005649f0(&local_4,0,1,0);

  puVar3 = local_4 + -5;

  LVar2 = InterlockedDecrement(local_4 + -4);

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  if ((param_1 != 4) && (FUN_00586aa0(param_2), 400 < param_3)) {

    FUN_004882f0("There were too many houses to display all the locations. Only the first 400 locations are displayed here."

                 ,0,1,0);

  }

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  LVar2 = InterlockedDecrement(puVar4 + 1);

  if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return 0;

}





// --- FUN_00586d20 at 0x00586D20 (size: 64) ---


undefined4 * __thiscall FUN_00586d20(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e2f1c;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00586d60 at 0x00586D60 (size: 25) ---


undefined4 FUN_00586d60(void)



{

  int iVar1;

  undefined1 local_c [12];

  

  iVar1 = FUN_0052dcf0(local_c);

  return **(undefined4 **)(iVar1 + 8);

}





// --- FUN_00586d80 at 0x00586D80 (size: 136) ---


undefined4 FUN_00586d80(undefined4 param_1)



{

  undefined4 uVar1;

  int iVar2;

  undefined **local_24;

  int local_20;

  undefined4 local_1c;

  int local_8;

  

  uVar1 = FUN_005bd310(param_1);

  local_20 = DAT_008ef11c;

  local_24 = &PTR_LAB_007a441c;

  InterlockedIncrement((LONG *)(DAT_008ef11c + 4));

  local_8 = DAT_008ef11c;

  InterlockedIncrement((LONG *)(DAT_008ef11c + 4));

  FUN_005bcf60();

  iVar2 = FUN_0048a1f0(uVar1,&local_24);

  if (iVar2 == 0) {

    FUN_00489f20();

    return 8;

  }

  FUN_00489f20();

  return local_1c;

}





// --- FUN_00586e10 at 0x00586E10 (size: 175) ---


void __thiscall FUN_00586e10(int param_1,int param_2,undefined4 *param_3)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  undefined **local_24;

  int local_20;

  int local_1c;

  int local_8;

  

  uVar2 = FUN_005bd310(param_2);

  local_20 = DAT_008ef11c;

  local_24 = &PTR_LAB_007a441c;

  InterlockedIncrement((LONG *)(DAT_008ef11c + 4));

  local_8 = DAT_008ef11c;

  InterlockedIncrement((LONG *)(DAT_008ef11c + 4));

  FUN_005bcf60();

  FUN_0048a1f0(uVar2,&local_24);

  puVar1 = (undefined4 *)**(undefined4 **)(param_1 + 4 + local_1c * 4);

  while( true ) {

    if (puVar1 == (undefined4 *)0x0) {

      *param_3 = 0;

      FUN_00489f20();

      return;

    }

    if (puVar1[2] == param_2) break;

    puVar1 = (undefined4 *)*puVar1;

  }

  *param_3 = puVar1[0x22];

  FUN_00489f20();

  return;

}





// --- FUN_00586ec0 at 0x00586EC0 (size: 248) ---


void FUN_00586ec0(undefined4 *param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  undefined4 uVar4;

  int *piVar5;

  LONG LVar6;

  undefined **local_24;

  undefined4 *local_20;

  undefined4 *local_8;

  

  uVar4 = FUN_005bd310(param_1);

  local_20 = DAT_008ef11c;

  local_24 = &PTR_LAB_007a441c;

  InterlockedIncrement(DAT_008ef11c + 1);

  local_8 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_005bcf60();

  FUN_0048a1f0(uVar4,&local_24);

  piVar5 = (int *)FUN_00597d40(&param_1);

  piVar3 = param_2;

  puVar1 = (undefined4 *)*param_2;

  if (puVar1 != (undefined4 *)*piVar5) {

    LVar6 = InterlockedDecrement(puVar1 + 1);

    if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    iVar2 = *piVar5;

    *piVar3 = iVar2;

    InterlockedIncrement((LONG *)(iVar2 + 4));

  }

  puVar1 = param_1;

  LVar6 = InterlockedDecrement(param_1 + 1);

  if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = local_8;

  LVar6 = InterlockedDecrement(local_8 + 1);

  if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = local_20;

  LVar6 = InterlockedDecrement(local_20 + 1);

  if ((LVar6 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return;

}





// --- FUN_00586fc0 at 0x00586FC0 (size: 73) ---


void __fastcall FUN_00586fc0(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_4,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_00587170(*puVar2);

  return;

}





// --- FUN_00587010 at 0x00587010 (size: 74) ---


undefined4 __thiscall FUN_00587010(int param_1,uint param_2,uint *param_3)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x84) + (param_2 % *(uint *)(param_1 + 0x8c)) * 4);

  while( true ) {

    if (puVar1 == (uint *)0x0) {

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  *param_3 = puVar1[2];

  return 1;

}





// --- FUN_00587060 at 0x00587060 (size: 143) ---


undefined4 * __thiscall FUN_00587060(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007e2f1c;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_005870f0 at 0x005870F0 (size: 122) ---


void __fastcall FUN_005870f0(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  void *pvVar4;

  int *piVar5;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        pvVar4 = (void *)*piVar5;

        goto LAB_0058712f;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    pvVar4 = (void *)0x0;

LAB_0058712f:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar4) {

LAB_00587142:

      *piVar5 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar4);

      if (pvVar2 == (void *)0x0) goto LAB_00587142;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar4 != (void *)0x0) {

      operator_delete(pvVar4);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00587170 at 0x00587170 (size: 310) ---


undefined4 __thiscall FUN_00587170(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  int *piVar5;

  uint *puVar6;

  uint *puVar7;

  undefined4 *puVar8;

  uint *puVar9;

  uint uVar10;

  uint *puVar11;

  

  iVar2 = param_2;

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar1 = *(int *)(param_1 + 0x6c);

  puVar3 = (uint *)0x0;

  do {

    if (iVar1 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

        operator_delete__(*(void **)(param_1 + 0x60));

      }

      *(undefined4 *)(param_1 + 0x60) = 0;

      *(undefined4 *)(param_1 + 100) = 0;

      *(undefined4 *)(param_1 + 0x68) = 0;

      *(undefined4 *)(param_1 + 0x6c) = 0;

      FUN_00693b20(iVar2);

      puVar4 = (undefined4 *)PTR_DAT_00818558;

      while (puVar3 != (uint *)0x0) {

        param_2 = *(int *)(param_1 + 0x68);

        puVar11 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar4;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar8 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar4,&param_2,param_2,0);

          if ((puVar8 != puVar4) || (puVar8 = puVar8 + -1, puVar8 != puVar4)) {

            puVar8 = puVar8 + 1;

          }

          FUN_00587170(*puVar8);

        }

        uVar10 = *puVar3 % *(uint *)(param_1 + 0x68);

        iVar2 = *(int *)(param_1 + 0x60);

        puVar3[1] = *(uint *)(iVar2 + uVar10 * 4);

        *(uint **)(iVar2 + uVar10 * 4) = puVar3;

        uVar10 = iVar2 + uVar10 * 4;

        if (uVar10 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar10;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar11;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        puVar11 = *(uint **)(param_1 + 100);

        puVar9 = (uint *)*puVar11;

        goto LAB_005871bf;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_005871bf:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_005871d2:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

      if (puVar6 == (uint *)0x0) goto LAB_005871d2;

      puVar6[1] = puVar7[1];

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    puVar9[1] = (uint)puVar3;

    iVar1 = *(int *)(param_1 + 0x6c);

    puVar3 = puVar9;

  } while( true );

}





// --- FUN_005872b0 at 0x005872B0 (size: 55) ---


bool __thiscall FUN_005872b0(int param_1,uint param_2)



{

  uint *puVar1;

  bool bVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xf8) + (param_2 % *(uint *)(param_1 + 0x100)) * 4);

  bVar2 = puVar1 == (uint *)0x0;

  if (!bVar2) {

    do {

      if (*puVar1 == param_2) break;

      puVar1 = (uint *)puVar1[1];

    } while (puVar1 != (uint *)0x0);

    bVar2 = puVar1 == (uint *)0x0;

  }

  return !bVar2;

}





// --- FUN_005872f0 at 0x005872F0 (size: 120) ---


uint __thiscall FUN_005872f0(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0058731b:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_00586fc0();

      }

      uVar3 = *param_2 % *(uint *)(param_1 + 0x68);

      iVar2 = *(int *)(param_1 + 0x60);

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

      if (uVar3 < *(uint *)(param_1 + 100)) {

        *(uint *)(param_1 + 100) = uVar3;

      }

      iVar2 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar2;

      return CONCAT31((int3)((uint)iVar2 >> 8),1);

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_0058731b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00587370 at 0x00587370 (size: 111) ---


undefined4 __thiscall FUN_00587370(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 100) + (*param_2 % *(uint *)(param_1 + 0x6c)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0058739b:

      puVar1 = (uint *)FUN_005df0f5(8);

      if (puVar1 != (uint *)0x0) {

        *puVar1 = *param_2;

        puVar1[1] = 0;

        FUN_005872f0(puVar1);

        return 1;

      }

      FUN_005872f0(0);

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return 0;

      }

      goto LAB_0058739b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_005873e0 at 0x005873E0 (size: 82) ---


undefined4 * __thiscall FUN_005873e0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e2f20;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007e2f1c;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00587440 at 0x00587440 (size: 111) ---


void __thiscall FUN_00587440(int param_1,int param_2)



{

  int iVar1;

  undefined4 local_4;

  

  iVar1 = param_2;

  param_2 = *(int *)(param_2 + 0xf8);

  if (param_2 == 0) {

    param_2 = 1;

  }

  local_4 = *(undefined4 *)(iVar1 + 8);

  FUN_006891f0(&local_4,&param_2);

  iVar1 = *(int *)(iVar1 + 0xf8);

  if (iVar1 != 0) {

    *(int *)(param_1 + 0x88) = *(int *)(param_1 + 0x88) + iVar1;

    return;

  }

  *(int *)(param_1 + 0x88) = *(int *)(param_1 + 0x88) + 1;

  return;

}





// --- FUN_005874b0 at 0x005874B0 (size: 75) ---


void __thiscall FUN_005874b0(int param_1,int param_2)



{

  void *pvVar1;

  int iVar2;

  

  iVar2 = param_2;

  param_2 = *(undefined4 *)(param_2 + 8);

  pvVar1 = (void *)FUN_004171e0(&param_2);

  if (pvVar1 != (void *)0x0) {

    operator_delete(pvVar1);

  }

  iVar2 = *(int *)(iVar2 + 0xf8);

  if (iVar2 == 0) {

    iVar2 = 1;

  }

  *(int *)(param_1 + 0x88) = *(int *)(param_1 + 0x88) - iVar2;

  return;

}





// --- FUN_00587500 at 0x00587500 (size: 150) ---


void __thiscall FUN_00587500(int param_1,int *param_2,int *param_3)



{

  uint *puVar1;

  int *piVar2;

  int *piVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x78) +

                     (*(uint *)((int)param_2 + 8) % *(uint *)(param_1 + 0x80)) * 4);

  do {

    piVar3 = param_3;

    if (puVar1 == (uint *)0x0) {

LAB_0058752f:

      piVar2 = *(int **)((int)param_2 + 0xf8);

      if (piVar2 == (int *)0x0) {

        piVar2 = (int *)0x1;

      }

      if (piVar3 == piVar2) {

        *param_3 = 0;

        return;

      }

      *param_3 = (piVar2 < piVar3) + 1;

      *(int *)(param_1 + 0x88) = (int)piVar2 + (*(int *)(param_1 + 0x88) - (int)piVar3);

      param_3 = *(int **)((int)param_2 + 8);

      param_2 = piVar2;

      FUN_0042d9a0(&param_3,&param_2);

      return;

    }

    if (*puVar1 == *(uint *)((int)param_2 + 8)) {

      if (puVar1 != (uint *)0x0) {

        piVar3 = (int *)puVar1[2];

      }

      goto LAB_0058752f;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_005875a0 at 0x005875A0 (size: 108) ---


undefined4 * __thiscall FUN_005875a0(undefined4 *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

  *param_1 = param_2;

  param_1[8] = &PTR_FUN_007962a0;

  FUN_00415dc0(0x20);

  param_1[0x25] = &PTR_FUN_007e2f20;

  FUN_00587060(0x20);

  iVar2 = 7;

  puVar3 = param_1;

  do {

    puVar3 = puVar3 + 1;

    puVar1 = (undefined4 *)FUN_005df0f5(8);

    if (puVar1 == (undefined4 *)0x0) {

      puVar1 = (undefined4 *)0x0;

    }

    else {

      *puVar1 = 0;

      puVar1[1] = 0;

    }

    *puVar3 = puVar1;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  return param_1;

}





// --- FUN_00587610 at 0x00587610 (size: 68) ---


void __thiscall FUN_00587610(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int *piVar2;

  

  iVar1 = FUN_00586d80(*(undefined4 *)(param_2 + 0xa4));

  piVar2 = (int *)**(int **)(param_1 + 4 + iVar1 * 4);

  if (piVar2 != (int *)0x0) {

    while (piVar2[2] != *(int *)(param_2 + 0xa4)) {

      piVar2 = (int *)*piVar2;

      if (piVar2 == (int *)0x0) {

        return;

      }

    }

    FUN_00587500(param_2,param_3);

  }

  return;

}





// --- FUN_00587660 at 0x00587660 (size: 301) ---


undefined4 * __thiscall FUN_00587660(undefined4 *param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  LONG LVar5;

  LONG *lpAddend;

  

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = DAT_00871a84;

  lpAddend = (LONG *)(DAT_008ef11c + 4);

  param_1[3] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[4] = DAT_00871a84;

  param_1[5] = &PTR_FUN_0079da04;

  FUN_0046c1f0(4);

  piVar3 = param_2;

  param_1[0x22] = 0;

  param_1[2] = param_2[0x29];

  puVar4 = (undefined4 *)(**(code **)(*param_2 + 100))(&param_2);

  param_1[4] = *puVar4;

  puVar4 = (undefined4 *)piVar3[0x27];

  InterlockedIncrement(puVar4 + 1);

  puVar1 = (undefined4 *)param_1[3];

  if (puVar1 != puVar4) {

    LVar5 = InterlockedDecrement(puVar1 + 1);

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    param_1[3] = puVar4;

    InterlockedIncrement(puVar4 + 1);

  }

  LVar5 = InterlockedDecrement(puVar4 + 1);

  if ((LVar5 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  FUN_006891f0(&stack0xfffffff8,&stack0x00000000);

  iVar2 = piVar3[0x3e];

  if (iVar2 != 0) {

    param_1[0x22] = param_1[0x22] + iVar2;

    return param_1;

  }

  param_1[0x22] = param_1[0x22] + 1;

  return param_1;

}





// --- FUN_00587790 at 0x00587790 (size: 94) ---


void __fastcall FUN_00587790(int param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  *(undefined ***)(param_1 + 0x14) = &PTR_FUN_0079da04;

  FUN_005870f0();

  *(undefined ***)(param_1 + 0x18) = &PTR_FUN_0079da00;

  if (*(void **)(param_1 + 0x78) != (void *)(param_1 + 0x1c)) {

    operator_delete__(*(void **)(param_1 + 0x78));

  }

  *(undefined4 *)(param_1 + 0x78) = 0;

  *(undefined4 *)(param_1 + 0x7c) = 0;

  *(undefined4 *)(param_1 + 0x80) = 0;

  *(undefined4 *)(param_1 + 0x84) = 0;

  puVar1 = *(undefined4 **)(param_1 + 0xc);

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return;

}





// --- FUN_005877f0 at 0x005877F0 (size: 83) ---


void FUN_005877f0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  

  iVar2 = FUN_005df0f5(0x8c);

  iVar1 = param_1;

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_00587660(param_1);

  }

  FUN_00410820(uVar3,param_3);

  param_1 = *(undefined4 *)(iVar1 + 0xa4);

  FUN_00587370(&param_1);

  return;

}





// --- FUN_00587850 at 0x00587850 (size: 301) ---


void __thiscall FUN_00587850(int param_1,int param_2)



{

  byte bVar1;

  undefined4 *puVar2;

  int *piVar3;

  int *piVar4;

  int iVar5;

  byte *pbVar6;

  LONG LVar7;

  byte *pbVar8;

  bool bVar9;

  int *local_c;

  int *local_8;

  int local_4;

  

  local_c = *(int **)(param_2 + 8);

  local_8 = *(int **)(param_2 + 0xa4);

  local_4 = param_1;

  FUN_006891f0(&local_c,&local_8);

  iVar5 = FUN_00586d80(*(undefined4 *)(param_2 + 0xa4));

  local_8 = *(int **)(param_1 + 4 + iVar5 * 4);

  local_c = (int *)0x0;

  piVar4 = (int *)*local_8;

  do {

    piVar3 = piVar4;

    if (piVar3 == (int *)0x0) {

      FUN_005877f0(param_2,local_8,local_c);

      return;

    }

    puVar2 = *(undefined4 **)(param_2 + 0x9c);

    InterlockedIncrement(puVar2 + 1);

    pbVar6 = (byte *)(piVar3[3] + 0x14);

    pbVar8 = (byte *)(puVar2 + 5);

    do {

      bVar1 = *pbVar8;

      bVar9 = bVar1 < *pbVar6;

      if (bVar1 != *pbVar6) {

LAB_005878f4:

        iVar5 = (1 - (uint)bVar9) - (uint)(bVar9 != 0);

        goto LAB_005878f9;

      }

      if (bVar1 == 0) break;

      bVar1 = pbVar8[1];

      bVar9 = bVar1 < pbVar6[1];

      if (bVar1 != pbVar6[1]) goto LAB_005878f4;

      pbVar8 = pbVar8 + 2;

      pbVar6 = pbVar6 + 2;

    } while (bVar1 != 0);

    iVar5 = 0;

LAB_005878f9:

    LVar7 = InterlockedDecrement(puVar2 + 1);

    if ((LVar7 == 0) && (puVar2 != (undefined4 *)0x0)) {

      (**(code **)*puVar2)(1);

    }

    if (iVar5 == 0) {

      FUN_00587440(param_2);

      return;

    }

    if (iVar5 < 0) {

      FUN_005877f0(param_2,local_8,local_c);

      return;

    }

    piVar4 = (int *)*piVar3;

    local_c = piVar3;

  } while( true );

}





// --- FUN_00587980 at 0x00587980 (size: 183) ---


void __thiscall FUN_00587980(int param_1,int param_2)



{

  int iVar1;

  void *pvVar2;

  int iVar3;

  int *piVar4;

  

  iVar1 = param_2;

  param_2 = *(undefined4 *)(param_2 + 8);

  pvVar2 = (void *)FUN_004171e0(&param_2);

  if (pvVar2 != (void *)0x0) {

    operator_delete(pvVar2);

  }

  iVar3 = FUN_00586d80(*(undefined4 *)(iVar1 + 0xa4));

  piVar4 = (int *)**(int **)(param_1 + 4 + iVar3 * 4);

  if (piVar4 != (int *)0x0) {

    while (piVar4[2] != *(int *)(iVar1 + 0xa4)) {

      piVar4 = (int *)*piVar4;

      if (piVar4 == (int *)0x0) {

        return;

      }

    }

    FUN_005874b0(iVar1);

    if (piVar4[0x22] == 0) {

      param_2 = piVar4[2];

      pvVar2 = (void *)FUN_004171e0(&param_2);

      if (pvVar2 != (void *)0x0) {

        operator_delete(pvVar2);

      }

      FUN_00410880(piVar4);

      FUN_00587790();

      operator_delete(piVar4);

    }

  }

  return;

}





// --- FUN_00587a40 at 0x00587A40 (size: 449) ---


void __fastcall FUN_00587a40(undefined4 *param_1)



{

  int *piVar1;

  int *piVar2;

  undefined4 *puVar3;

  int iVar4;

  LONG LVar5;

  undefined4 *puVar6;

  int local_8;

  

  local_8 = 7;

  puVar6 = param_1;

  do {

    puVar6 = puVar6 + 1;

    piVar1 = (int *)*puVar6;

    piVar2 = (int *)*piVar1;

    if (piVar2 != (int *)0x0) {

      if ((int *)piVar2[1] == (int *)0x0) {

        iVar4 = *piVar2;

        *piVar1 = iVar4;

        if (iVar4 != 0) {

          *(undefined4 *)(iVar4 + 4) = 0;

        }

      }

      else {

        *(int *)piVar2[1] = *piVar2;

      }

      if (*piVar2 == 0) {

        puVar3 = *(undefined4 **)(piVar1[1] + 4);

        piVar1[1] = (int)puVar3;

        if (puVar3 != (undefined4 *)0x0) {

          *puVar3 = 0;

        }

      }

      else {

        *(int *)(*piVar2 + 4) = piVar2[1];

      }

      *piVar2 = 0;

      piVar2[1] = 0;

      while (piVar2 != (int *)0x0) {

        if (piVar2 != (int *)0x0) {

          piVar2[5] = (int)&PTR_FUN_0079da04;

          FUN_005870f0();

          piVar2[6] = (int)&PTR_FUN_0079da00;

          if ((int *)piVar2[0x1e] != piVar2 + 7) {

            operator_delete__((int *)piVar2[0x1e]);

          }

          piVar2[0x1e] = 0;

          piVar2[0x1f] = 0;

          piVar2[0x20] = 0;

          piVar2[0x21] = 0;

          puVar3 = (undefined4 *)piVar2[3];

          LVar5 = InterlockedDecrement(puVar3 + 1);

          if ((LVar5 == 0) && (puVar3 != (undefined4 *)0x0)) {

            (**(code **)*puVar3)(1);

          }

          operator_delete(piVar2);

        }

        piVar1 = (int *)*puVar6;

        piVar2 = (int *)*piVar1;

        if (piVar2 != (int *)0x0) {

          if ((int *)piVar2[1] == (int *)0x0) {

            iVar4 = *piVar2;

            *piVar1 = iVar4;

            if (iVar4 != 0) {

              *(undefined4 *)(iVar4 + 4) = 0;

            }

          }

          else {

            *(int *)piVar2[1] = *piVar2;

          }

          if (*piVar2 == 0) {

            puVar3 = *(undefined4 **)(piVar1[1] + 4);

            piVar1[1] = (int)puVar3;

            if (puVar3 != (undefined4 *)0x0) {

              *puVar3 = 0;

            }

          }

          else {

            *(int *)(*piVar2 + 4) = piVar2[1];

          }

          *piVar2 = 0;

          piVar2[1] = 0;

        }

      }

    }

    if ((void *)*puVar6 != (void *)0x0) {

      operator_delete((void *)*puVar6);

    }

    local_8 = local_8 + -1;

  } while (local_8 != 0);

  param_1[0x25] = &PTR_FUN_007e2f20;

  FUN_005870f0();

  param_1[0x26] = &PTR_FUN_007e2f1c;

  if ((undefined4 *)param_1[0x3e] != param_1 + 0x27) {

    operator_delete__((undefined4 *)param_1[0x3e]);

  }

  param_1[0x3e] = 0;

  param_1[0x3f] = 0;

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[8] = &PTR_FUN_007962a0;

  FUN_005870f0();

  param_1[9] = &PTR_FUN_00796298;

  if ((undefined4 *)param_1[0x21] != param_1 + 10) {

    operator_delete__((undefined4 *)param_1[0x21]);

  }

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  param_1[0x24] = 0;

  return;

}





// --- FUN_00587c10 at 0x00587C10 (size: 165) ---


void __thiscall FUN_00587c10(int param_1,int param_2,undefined4 *param_3)



{

  uint *puVar1;

  bool bVar2;

  int iVar3;

  

  iVar3 = FUN_0058df90();

  puVar1 = *(uint **)(*(int *)(param_1 + 0x84) +

                     (*(uint *)(param_2 + 8) % *(uint *)(param_1 + 0x8c)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_00587c4b:

      bVar2 = false;

LAB_00587c4d:

      if (iVar3 == 0) {

        if (bVar2) {

          FUN_00587980(param_2);

          *param_3 = 2;

          return;

        }

        *param_3 = 0;

        return;

      }

      if (!bVar2) {

        FUN_00587850(param_2);

        *param_3 = 1;

        return;

      }

      FUN_00587610(param_2,param_3);

      return;

    }

    if (*puVar1 == *(uint *)(param_2 + 8)) {

      if (puVar1 != (uint *)0x0) {

        bVar2 = true;

        goto LAB_00587c4d;

      }

      goto LAB_00587c4b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00587cc0 at 0x00587CC0 (size: 109) ---


bool FUN_00587cc0(int *param_1,int param_2,undefined4 *param_3)



{

  uint uVar1;

  uint uVar2;

  

  *param_3 = 0;

  if ((param_1 != (int *)0x0) && (param_2 != 0)) {

    uVar1 = *(uint *)(param_2 + 0x124);

    if ((*(uint *)(param_2 + 0x120) == 0) || (uVar1 == 0)) {

      return true;

    }

    if (*(int *)(param_2 + 0x114) == 0) {

      *param_3 = 1;

    }

    else if ((param_1[0x48] != 0) && ((*(uint *)(param_2 + 0x120) & param_1[0x48]) != 0)) {

      uVar2 = (**(code **)(*param_1 + 0x18))();

      return (uVar2 & uVar1) != 0;

    }

  }

  return false;

}





// --- FUN_00587d30 at 0x00587D30 (size: 37) ---


int FUN_00587d30(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 8) == DAT_00871e54) {

    return DAT_0081d7ec;

  }

  iVar1 = *(int *)(param_1 + 0xf8);

  if (iVar1 == 0) {

    iVar1 = 1;

  }

  return iVar1;

}





// --- FUN_00587d60 at 0x00587D60 (size: 391) ---


undefined4 FUN_00587d60(int param_1,int param_2,int param_3)



{

  int iVar1;

  int iVar2;

  undefined1 local_94 [4];

  undefined1 local_90 [144];

  

  iVar1 = FUN_0058de80(param_3);

  if (iVar1 == 0) {

    return 0;

  }

  if (param_1 != param_2) {

    iVar1 = FUN_005583f0(param_1);

    iVar2 = FUN_005583f0(param_2);

    if ((((iVar1 != 0) && (iVar2 != 0)) && (1 < *(uint *)(iVar1 + 0xfc))) &&

       (1 < *(uint *)(iVar2 + 0xfc))) {

      if ((*(int *)(iVar1 + 0x78) == 1) || (*(int *)(iVar2 + 0x78) == 1)) {

        if (param_3 != 0) {

          return 0;

        }

        FUN_0042dc80();

        FUN_00402730(L"You cannot merge items while they are being traded.");

        FUN_0042cbe0(local_94,1);

        FUN_004011b0();

      }

      else if (*(int *)(iVar1 + 0xa4) == *(int *)(iVar2 + 0xa4)) {

        if (*(uint *)(iVar2 + 0xf8) < *(uint *)(iVar2 + 0xfc)) {

          return 1;

        }

        if (param_3 != 0) {

          return 0;

        }

        FUN_0042dc80();

        FUN_00402730(L"The destination stack is already full.");

        FUN_0042cbe0(local_94,1);

        FUN_004011b0();

      }

      else {

        if (param_3 != 0) {

          return 0;

        }

        FUN_0042dc80();

        FUN_00402730(L"You cannot merge different types of items.");

        FUN_0042cbe0(local_94,1);

        FUN_004011b0();

      }

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

    }

  }

  return 0;

}





// --- FUN_00587ef0 at 0x00587EF0 (size: 771) ---


undefined4 FUN_00587ef0(int param_1,int param_2)



{

  int *piVar1;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  int local_98;

  undefined1 auStack_94 [4];

  undefined1 local_90 [144];

  

  piVar1 = (int *)FUN_005583f0(param_1);

  if (piVar1 == (int *)0x0) {

    if (param_2 == 0) {

      FUN_0042dc80();

      FUN_00402730(L"That item is not valid!");

      FUN_0042cbe0(&local_98,1);

      LVar2 = InterlockedDecrement((LONG *)(local_98 + -0x10));

      if ((LVar2 == 0) && ((undefined4 *)(local_98 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(local_98 + -0x14))(1);

      }

LAB_00587f6a:

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

      return 0;

    }

  }

  else {

    if (DAT_0083da58 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_1 == iVar3) {

      if (param_2 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You cannot place yourself within a container!");

        FUN_0042cbe0(&local_98,1);

        LVar2 = InterlockedDecrement((LONG *)(local_98 + -0x10));

        if ((LVar2 == 0) && ((undefined4 *)(local_98 + -0x14) != (undefined4 *)0x0)) {

          (*(code *)**(undefined4 **)(local_98 + -0x14))(1);

        }

        goto LAB_00587f6a;

      }

    }

    else {

      iVar3 = (**(code **)(*piVar1 + 0x18))();

      if (iVar3 == 0x10) {

        if (param_2 == 0) {

          FUN_0042dc80();

          FUN_00402730(L"You cannot pick up creatures!");

          FUN_0042cbe0(&local_98,1);

          FUN_004011b0();

          goto LAB_00587f6a;

        }

      }

      else {

        if ((((*(byte *)(piVar1 + 0x40) & 4) == 0) || (piVar1[0x2d] != 0)) || (piVar1[0x2e] != 0)) {

          iVar3 = FUN_0058df90();

          if ((iVar3 == 0) && (piVar1[0x31] != 0)) {

            if (param_2 != 0) {

              return 0;

            }

            puVar4 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

            FUN_00480980(&local_98,0,L"The %s is being wielded by someone else!",*puVar4);

            FUN_004011b0();

            FUN_0042dc80();

            FUN_0042cbe0(&local_98,1);

          }

          else {

            iVar3 = FUN_004a48a0();

            if ((iVar3 == 0) || (piVar1[0x33] == 0)) {

              return 1;

            }

            if (param_2 != 0) {

              return 0;

            }

            puVar4 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

            FUN_00480980(&local_98,0,L"The %s can\'t be picked up!",*puVar4);

            FUN_004011b0();

            FUN_0042dc80();

            FUN_0042cbe0(&local_98,1);

          }

        }

        else {

          if (param_2 != 0) {

            return 0;

          }

          puVar4 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

          FUN_00480980(&local_98,0,L"The %s cannot be picked up!",*puVar4);

          FUN_004011b0();

          FUN_0042dc80();

          FUN_0042cbe0(&local_98,1);

        }

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

        FUN_004011b0();

      }

    }

  }

  return 0;

}





// --- FUN_00588200 at 0x00588200 (size: 329) ---


undefined4 FUN_00588200(undefined4 param_1)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  int local_98;

  undefined1 auStack_94 [4];

  undefined1 local_90 [144];

  

  iVar1 = FUN_00564d30();

  if (iVar1 == 0) {

    return 0;

  }

  piVar2 = (int *)FUN_005583f0(param_1);

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    if (piVar2 != (int *)0x0) {

      if ((*(byte *)(piVar2 + 0x40) & 1) == 0) {

        iVar1 = (**(code **)(*piVar2 + 0x2c))();

        if (iVar1 == 0) {

          puVar4 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

          FUN_00480980(&local_98,0,L"The %s is locked",*puVar4);

          FUN_004011b0();

          FUN_0042dc80();

          FUN_0042cbe0(&local_98,1);

          FUN_00693500(0x1a,local_90);

          FUN_0042e590();

          FUN_004011b0();

        }

        return 0;

      }

      uVar5 = 1;

      FUN_00564d30(param_1,1);

      FUN_005652b0(param_1,uVar5);

      return 1;

    }

    FUN_0042dc80();

    FUN_00402730(L"The object has no representation on the client.");

    FUN_0042cbe0(&local_98,1);

    LVar3 = InterlockedDecrement((LONG *)(local_98 + -0x10));

    if ((LVar3 == 0) && ((undefined4 *)(local_98 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_98 + -0x14))(1);

    }

    FUN_00693500(0x1a,local_90);

    FUN_0042e590();

  }

  return 0;

}





// --- FUN_00588350 at 0x00588350 (size: 971) ---


uint FUN_00588350(int param_1,int param_2,char param_3,char param_4)



{

  int *in_EAX;

  int iVar1;

  uint uVar2;

  undefined3 uVar9;

  undefined4 *puVar3;

  int iVar4;

  int iVar5;

  uint uVar6;

  undefined4 *puVar7;

  undefined4 uVar8;

  undefined3 extraout_var;

  wchar_t *pwVar10;

  undefined1 local_a0 [4];

  undefined1 local_9c [4];

  undefined1 auStack_98 [8];

  undefined1 local_90 [144];

  

  if ((param_1 == 0) || (in_EAX = (int *)0x0, param_2 == 0)) goto LAB_005885dd;

  iVar1 = FUN_005583f0(param_2);

  in_EAX = (int *)FUN_005583f0(param_1);

  if ((iVar1 == 0) || (in_EAX == (int *)0x0)) goto LAB_005885dd;

  FUN_004fd850(*(undefined4 *)(iVar1 + 0xd8));

  uVar2 = FUN_0058df90();

  if (uVar2 == 0) {

    uVar2 = FUN_004fd870();

    uVar9 = (undefined3)(uVar2 >> 8);

    if ((uVar2 & 8) == 0) {

      if ((uVar2 & 4) == 0) goto LAB_0058848e;

      in_EAX = (int *)CONCAT31(uVar9,param_3);

      if (param_3 != '\0') goto LAB_005885dd;

      puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

      uVar8 = *puVar3;

      pwVar10 = L"You must wield the %s to use it";

LAB_00588453:

      FUN_00480980(local_a0,0,pwVar10,uVar8);

      FUN_004011b0();

      FUN_0042dc80();

      FUN_0042cbe0(local_a0,1);

    }

    else {

      in_EAX = (int *)CONCAT31(uVar9,param_3);

      if (param_3 != '\0') goto LAB_005885dd;

      puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

      uVar8 = *puVar3;

      pwVar10 = L"You must own the %s to use it";

LAB_005883ed:

      FUN_00480980(local_a0,0,pwVar10,uVar8);

      FUN_004011b0();

      FUN_0042dc80();

      FUN_0042cbe0(local_a0,1);

    }

  }

  else {

LAB_0058848e:

    if (in_EAX[0x1e] == 1) {

      in_EAX = (int *)CONCAT31((int3)(uVar2 >> 8),param_3);

      if (param_3 != '\0') goto LAB_005885dd;

      puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

      uVar8 = *puVar3;

      pwVar10 = L"You can\'t use the %s on an item you are trading";

LAB_0058858b:

      FUN_00480980(local_a0,0,pwVar10,uVar8);

    }

    else {

      iVar4 = FUN_0058df90();

      if (iVar4 == 0) {

        uVar2 = FUN_004fd8f0();

        if ((uVar2 & 8) != 0) {

          iVar4 = FUN_0048e5f0();

          if (param_1 == iVar4) {

            iVar5 = FUN_004fd8d0();

            iVar4 = 0;

            if (iVar5 != 0) goto LAB_0058854a;

          }

          in_EAX = (int *)CONCAT31((int3)((uint)iVar4 >> 8),param_3);

          if (param_3 != '\0') goto LAB_005885dd;

          puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

          uVar8 = *puVar3;

          pwVar10 = L"You can\'t use the %s on what you don\'t own";

          goto LAB_005883ed;

        }

        if ((uVar2 & 4) != 0) {

          in_EAX = (int *)CONCAT31((int3)(uVar2 >> 8),param_3);

          if (param_3 != '\0') goto LAB_005885dd;

          puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

          uVar8 = *puVar3;

          pwVar10 = L"You can\'t use the %s on what you aren\'t wielding";

          goto LAB_00588453;

        }

      }

LAB_0058854a:

      iVar4 = FUN_0048e5f0();

      if (param_1 == iVar4) {

        iVar4 = FUN_004fd8d0();

        if (iVar4 == 0) {

          in_EAX = (int *)0x0;

          if (param_3 != '\0') goto LAB_005885dd;

          puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

          uVar8 = *puVar3;

          pwVar10 = L"Cannot use the %s on yourself";

          goto LAB_0058858b;

        }

      }

      uVar2 = *(uint *)(iVar1 + 0xe0);

      uVar6 = (**(code **)(*in_EAX + 0x18))();

      uVar9 = (undefined3)(uVar6 >> 8);

      if ((uVar2 & uVar6) != 0) {

        if (param_4 != '\0') {

          puVar3 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

          FUN_00480980(local_a0,0,L"Using the %s",*puVar3);

          FUN_004011b0();

          iVar1 = (**(code **)(*in_EAX + 0x10))();

          if (iVar1 == 0) {

            pwVar10 = L" with the ";

          }

          else {

            pwVar10 = L" on ";

          }

          FUN_0040b8f0(pwVar10);

          uVar8 = FUN_0058f8b0(auStack_98,2,0);

          FUN_00402790(uVar8);

          FUN_004011b0();

          FUN_0042dc80();

          FUN_0042cbe0(local_a0,1);

          FUN_00693500(0x1a,local_90);

          FUN_0042e590();

          FUN_004011b0();

          uVar9 = extraout_var;

        }

        return CONCAT31(uVar9,1);

      }

      in_EAX = (int *)CONCAT31(uVar9,param_3);

      if (param_3 != '\0') goto LAB_005885dd;

      puVar3 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

      puVar7 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

      FUN_00480980(local_a0,0,L"Cannot use the %s with the %s",*puVar7,*puVar3);

      FUN_004011b0();

    }

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(local_a0,1);

  }

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  in_EAX = (int *)FUN_004011b0();

LAB_005885dd:

  return (uint)in_EAX & 0xffffff00;

}





// --- FUN_00588720 at 0x00588720 (size: 177) ---


undefined4 FUN_00588720(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint *puVar4;

  uint local_8;

  uint local_4;

  

  iVar1 = FUN_005583f0(param_1);

  iVar2 = FUN_005583f0(param_2);

  iVar3 = FUN_00587d60(param_1,param_2,param_3);

  if (iVar3 != 0) {

    local_8 = DAT_0081d7ec;

    if ((*(int *)(iVar1 + 8) != DAT_00871e54) &&

       (local_8 = *(uint *)(iVar1 + 0xf8), *(uint *)(iVar1 + 0xf8) == 0)) {

      local_8 = 1;

    }

    iVar1 = *(int *)(iVar2 + 0xf8);

    if (iVar1 == 0) {

      iVar1 = 1;

    }

    local_4 = *(int *)(iVar2 + 0xfc) - iVar1;

    puVar4 = &local_8;

    if (local_4 <= local_8) {

      puVar4 = &local_4;

    }

    FUN_0058e5a0(param_2,*puVar4);

    FUN_0047a050(param_1,param_2);

    FUN_0058d110(param_2,0);

    return 1;

  }

  return 0;

}





// --- FUN_005887e0 at 0x005887E0 (size: 650) ---


undefined4 FUN_005887e0(int param_1,int param_2,int param_3)



{

  int iVar1;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  int local_98;

  int local_94;

  undefined1 local_90 [144];

  

  iVar1 = FUN_005583f0(param_2);

  if (iVar1 == 0) {

    if (param_3 != 0) {

      return 0;

    }

    FUN_0042dc80();

    FUN_00402730(L"The destination container is not valid!");

    FUN_0042cbe0(&local_98,1);

    LVar2 = InterlockedDecrement((LONG *)(local_98 + -0x10));

    if ((LVar2 == 0) && ((undefined4 *)(local_98 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_98 + -0x14))(1);

    }

LAB_0058885a:

    FUN_00693500(0x1a,local_90);

    FUN_0042e590();

    return 0;

  }

  if (param_1 == param_2) {

    if (param_3 != 0) {

      return 0;

    }

    FUN_0042dc80();

    FUN_00402730(L"You cannot place an object within itself!");

    FUN_0042cbe0(&local_98,1);

    LVar2 = InterlockedDecrement((LONG *)(local_98 + -0x10));

    if ((LVar2 == 0) && ((undefined4 *)(local_98 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_98 + -0x14))(1);

    }

    goto LAB_0058885a;

  }

  if ((*(byte *)(iVar1 + 0x100) & 1) == 0) {

    if (DAT_0083da58 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_2 != iVar3) {

      if (param_3 != 0) {

        return 0;

      }

      puVar4 = (undefined4 *)FUN_0058f8b0(&local_94,2,0);

      FUN_00480980(&local_98,0,L"The %s is locked",*puVar4);

      FUN_004011b0();

      FUN_0042dc80();

      FUN_0042cbe0(&local_98,1);

      goto LAB_00588a35;

    }

  }

  if (*(int *)(iVar1 + 0x78) == 1) {

    if (param_3 != 0) {

      return 0;

    }

    puVar4 = (undefined4 *)FUN_0058f8b0(&local_94,2,0);

    FUN_00480980(&local_98,0,L"The %s is being traded",*puVar4);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(&local_98,1);

  }

  else {

    uVar5 = FUN_005583f0(param_1);

    iVar1 = FUN_00587cc0(uVar5,iVar1,&local_94);

    if (iVar1 != 0) {

      return 1;

    }

    if (param_3 != 0) {

      return 0;

    }

    FUN_00402730(L"That item cannot be placed on the hook.");

    if (local_94 != 0) {

      FUN_004300a0(&local_98,L" You must own the house to manipulate the hook.");

    }

    FUN_0042dc80();

    FUN_0042cbe0(&local_98,1);

  }

LAB_00588a35:

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  FUN_004011b0();

  return 0;

}





// --- FUN_00588a70 at 0x00588A70 (size: 271) ---


undefined4 FUN_00588a70(int param_1,undefined4 param_2,int param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  undefined4 uVar6;

  undefined1 local_18 [16];

  int local_8;

  

  iVar1 = FUN_005583f0(param_1);

  iVar2 = FUN_005583f0(param_2);

  iVar3 = FUN_005583f0(param_3);

  if ((((iVar1 != 0) && (iVar2 != 0)) && ((param_3 == 0 || (iVar3 != 0)))) &&

     (1 < *(uint *)(iVar1 + 0xfc))) {

    FUN_0058cd40(local_18);

    iVar1 = 0;

    if (0 < local_8) {

      do {

        iVar2 = FUN_005aeef0(iVar1);

        iVar4 = FUN_005583f0(iVar2);

        if (((iVar4 != 0) && (param_1 != iVar2)) &&

           (iVar5 = FUN_00587d60(param_1,iVar2,1), iVar5 != 0)) {

          iVar5 = *(int *)(iVar4 + 0xf8);

          if (iVar5 == 0) {

            iVar5 = 1;

          }

          if (DAT_0081d7ec <= (uint)(*(int *)(iVar4 + 0xfc) - iVar5)) {

            if (iVar3 != 0) {

              iVar1 = iVar2;

              FUN_0058cd20(iVar2);

              FUN_005aec80(iVar1);

            }

            uVar6 = FUN_00588720(param_1,iVar2,0);

            FUN_005af120();

            return uVar6;

          }

        }

        iVar1 = iVar1 + 1;

      } while (iVar1 < local_8);

    }

    FUN_005af120();

  }

  return 0;

}





// --- FUN_00588b90 at 0x00588B90 (size: 296) ---


undefined4 FUN_00588b90(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  undefined1 local_4 [4];

  

  iVar1 = FUN_005583f0(param_2);

  if ((iVar1 != 0) && (param_1 != param_2)) {

    if ((*(byte *)(iVar1 + 0x100) & 1) == 0) {

      if (DAT_0083da58 == 0) {

        iVar3 = 0;

      }

      else {

        iVar3 = *(int *)(DAT_0083da58 + 0xf4);

      }

      if (param_2 != iVar3) {

        return 0;

      }

    }

    if (*(int *)(iVar1 + 0x78) != 1) {

      uVar2 = FUN_005583f0(param_1);

      iVar1 = FUN_00587cc0(uVar2,iVar1,local_4);

      if (iVar1 != 0) {

        iVar1 = FUN_005583f0(param_1);

        iVar3 = FUN_005583f0(param_2);

        if (iVar1 == 0) {

          return 0;

        }

        if (iVar3 == 0) {

          return 0;

        }

        iVar1 = FUN_004a48a0();

        if (iVar1 == 0) {

          iVar1 = *(int *)(iVar3 + 200);

          if ((iVar1 != -1) && (iVar3 = FUN_0058cce0(), iVar1 <= iVar3)) {

            if (DAT_0081d7ec != DAT_0081d7f0) {

              return 0;

            }

            iVar1 = FUN_0058cd20();

            if (iVar1 == 0) {

              return 0;

            }

            FUN_0058cd20(param_1);

            iVar1 = FUN_005aec80(param_1);

            if (iVar1 == 0) {

              return 0;

            }

            return 1;

          }

        }

        else {

          iVar1 = *(int *)(iVar3 + 0xcc);

          if ((iVar1 != -1) && (iVar3 = FUN_0058ccf0(), iVar1 <= iVar3)) {

            iVar1 = FUN_0058cd30();

            if (iVar1 != 0) {

              FUN_0058cd30(param_1);

              iVar1 = FUN_005aec80(param_1);

              if (iVar1 != 0) {

                return 1;

              }

            }

            return 0;

          }

        }

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_00588cc0 at 0x00588CC0 (size: 470) ---


undefined4 FUN_00588cc0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  undefined1 auStack_4 [4];

  

  iVar1 = FUN_0058de80(1);

  if (iVar1 == 0) {

    return 0;

  }

  piVar2 = (int *)FUN_005583f0(param_1);

  if (piVar2 != (int *)0x0) {

    if (DAT_0083da58 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (((((param_1 != iVar1) && (iVar1 = (**(code **)(*piVar2 + 0x18))(), iVar1 != 0x10)) &&

         (((*(byte *)(piVar2 + 0x40) & 4) == 0 || ((piVar2[0x2d] != 0 || (piVar2[0x2e] != 0)))))) &&

        ((iVar1 = FUN_0058df90(), iVar1 != 0 || (piVar2[0x31] == 0)))) &&

       ((((iVar1 = FUN_004a48a0(), iVar1 == 0 || (piVar2[0x33] == 0)) &&

         (iVar1 = FUN_005583f0(param_2), iVar1 != 0)) && (param_1 != param_2)))) {

      if ((*(byte *)(iVar1 + 0x100) & 1) == 0) {

        if (DAT_0083da58 == 0) {

          iVar4 = 0;

        }

        else {

          iVar4 = *(int *)(DAT_0083da58 + 0xf4);

        }

        if (param_2 != iVar4) {

          return 0;

        }

      }

      if (*(int *)(iVar1 + 0x78) != 1) {

        uVar3 = FUN_005583f0(param_1);

        iVar1 = FUN_00587cc0(uVar3,iVar1,auStack_4);

        if (iVar1 != 0) {

          iVar1 = FUN_005583f0(param_1);

          iVar4 = FUN_005583f0(param_2);

          if ((iVar1 != 0) && (iVar4 != 0)) {

            iVar1 = FUN_004a48a0();

            if ((iVar1 != 0) &&

               ((iVar1 = *(int *)(iVar4 + 0xcc), iVar1 != -1 &&

                (iVar5 = FUN_0058ccf0(), iVar1 <= iVar5)))) {

              iVar1 = FUN_0058cd30();

              if (iVar1 == 0) {

                return 0;

              }

              iVar1 = param_1;

              FUN_0058cd30(param_1);

              iVar1 = FUN_005aec80(iVar1);

              if (iVar1 == 0) {

                return 0;

              }

            }

            iVar1 = FUN_004a48a0();

            if (((iVar1 != 0) || (iVar1 = *(int *)(iVar4 + 200), iVar1 == -1)) ||

               (iVar4 = FUN_0058cce0(), iVar4 < iVar1)) {

              return 1;

            }

            if (DAT_0081d7ec != DAT_0081d7f0) {

              return 0;

            }

            iVar1 = FUN_0058cd20();

            if (iVar1 == 0) {

              return 0;

            }

            FUN_0058cd20(param_1);

            iVar1 = FUN_005aec80(param_1);

            if (iVar1 == 0) {

              return 0;

            }

            return 1;

          }

        }

      }

    }

  }

  return 0;

}





// --- FUN_00588ea0 at 0x00588EA0 (size: 201) ---


bool FUN_00588ea0(int param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  

  if ((param_1 != 0) && (DAT_00871ae4 != 0)) {

    iVar1 = FUN_005583f0(DAT_00871ae4);

    piVar2 = (int *)FUN_005583f0(param_1);

    if ((iVar1 != 0) && (piVar2 != (int *)0x0)) {

      FUN_004fd850(*(undefined4 *)(iVar1 + 0xd8));

      iVar3 = FUN_0058df90();

      if (iVar3 == 0) {

        uVar4 = FUN_004fd870();

        if ((uVar4 & 8) != 0) {

          return false;

        }

        if ((uVar4 & 4) != 0) {

          return false;

        }

      }

      if (piVar2[0x1e] != 1) {

        iVar3 = FUN_0058df90();

        if (iVar3 == 0) {

          uVar4 = FUN_004fd8f0();

          if ((uVar4 & 8) == 0) {

            if ((uVar4 & 4) != 0) {

              return false;

            }

          }

          else {

            iVar3 = FUN_0048e5f0();

            if (param_1 != iVar3) {

              return false;

            }

            iVar3 = FUN_004fd8d0();

            if (iVar3 == 0) {

              return false;

            }

          }

        }

        iVar3 = FUN_0048e5f0();

        if ((param_1 == iVar3) && (iVar3 = FUN_004fd8d0(), iVar3 == 0)) {

          return false;

        }

        uVar4 = *(uint *)(iVar1 + 0xe0);

        uVar5 = (**(code **)(*piVar2 + 0x18))();

        return (uVar4 & uVar5) != 0;

      }

    }

  }

  return false;

}





// --- FUN_00588f70 at 0x00588F70 (size: 695) ---


undefined4 FUN_00588f70(int param_1,int param_2,int param_3,int param_4,undefined4 param_5)



{

  int iVar1;

  undefined4 uVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  int iVar7;

  wchar_t *pwVar8;

  int *local_98;

  int local_94;

  undefined1 auStack_90 [144];

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 == 0) {

    return 0;

  }

  iVar1 = FUN_00587ef0(param_1,0);

  if (iVar1 == 0) {

    return 0;

  }

  iVar1 = FUN_005887e0(param_1,param_2,0);

  if (iVar1 == 0) {

    return 0;

  }

  iVar1 = FUN_005583f0(param_3);

  if ((iVar1 != 0) && (param_1 != param_3)) {

    if ((*(byte *)(iVar1 + 0x100) & 1) == 0) {

      if (DAT_0083da58 == 0) {

        iVar7 = 0;

      }

      else {

        iVar7 = *(int *)(DAT_0083da58 + 0xf4);

      }

      if (param_3 != iVar7) goto LAB_0058901d;

    }

    if (*(int *)(iVar1 + 0x78) != 1) {

      uVar2 = FUN_005583f0(param_1);

      iVar1 = FUN_00587cc0(uVar2,iVar1,&local_98);

      if (iVar1 != 0) goto LAB_0058901f;

    }

  }

LAB_0058901d:

  param_3 = 0;

LAB_0058901f:

  if ((param_4 != 0) && (iVar1 = FUN_00588a70(param_1,param_2,param_3), iVar1 != 0)) {

    return 1;

  }

  iVar1 = FUN_005583f0(param_1);

  local_94 = iVar1;

  piVar3 = (int *)FUN_005583f0(param_2);

  if ((iVar1 != 0) && (piVar3 != (int *)0x0)) {

    local_98 = piVar3;

    iVar1 = FUN_00588b90(param_1,param_3);

    if ((iVar1 == 0) && (iVar1 = FUN_00588b90(param_1,param_2), param_3 = param_2, iVar1 == 0)) {

      iVar1 = FUN_0058cd30();

      if ((iVar1 != 0) && (iVar7 = 0, piVar3 = local_98, 0 < *(int *)(iVar1 + 0x10))) {

        do {

          uVar2 = FUN_005aeef0(iVar7);

          iVar4 = FUN_005583f0(uVar2);

          if ((iVar4 != 0) && (iVar5 = FUN_00588b90(param_1,*(undefined4 *)(iVar4 + 8)), iVar5 != 0)

             ) {

            param_3 = *(int *)(iVar4 + 8);

            piVar3 = local_98;

            goto LAB_00589130;

          }

          iVar7 = iVar7 + 1;

          piVar3 = local_98;

        } while (iVar7 < *(int *)(iVar1 + 0x10));

      }

    }

    else {

LAB_00589130:

      if (param_3 != 0) {

        if (DAT_0081d7f0 <= DAT_0081d7ec) {

          FUN_0058e4b0(param_3,param_5);

          return 1;

        }

        FUN_0058e600(param_3,param_5,DAT_0081d7ec);

        return 1;

      }

    }

    FUN_00401a60();

    iVar1 = (**(code **)(*piVar3 + 0x10))();

    if (iVar1 == 0) {

      iVar1 = FUN_004a48a0();

      if (iVar1 == 0) {

        puVar6 = (undefined4 *)FUN_0058f8b0(&local_98,2,0);

        uVar2 = *puVar6;

        pwVar8 = L"The %s is completely full!";

      }

      else {

        puVar6 = (undefined4 *)FUN_0058f8b0(&local_98,2,0);

        uVar2 = *puVar6;

        pwVar8 = L"The %s can fit no more containers!";

      }

    }

    else {

      iVar1 = FUN_004a48a0();

      if (iVar1 == 0) {

        puVar6 = (undefined4 *)FUN_0058f8b0(&local_98,2,1);

        uVar2 = *puVar6;

        pwVar8 = L"%s is completely full!";

      }

      else {

        puVar6 = (undefined4 *)FUN_0058f8b0(&local_98,2,0);

        uVar2 = *puVar6;

        pwVar8 = L"%s can carry no more containers!";

      }

    }

    FUN_004027b0(&local_94,pwVar8,uVar2);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(&local_94,1);

    FUN_00693500(0x1a,auStack_90);

    FUN_0042e590();

    FUN_004011b0();

  }

  return 0;

}





// --- FUN_00589230 at 0x00589230 (size: 85) ---


bool __fastcall FUN_00589230(int param_1)



{

  int *piVar1;

  uint *puVar2;

  bool bVar3;

  

  piVar1 = (int *)FUN_00415730(5,0x10000001,0x28);

  puVar2 = *(uint **)(piVar1[0x99] + (*(uint *)(param_1 + 0xa4) % (uint)piVar1[0x9b]) * 4);

  bVar3 = puVar2 == (uint *)0x0;

  if (!bVar3) {

    do {

      if (*puVar2 == *(uint *)(param_1 + 0xa4)) break;

      puVar2 = (uint *)puVar2[1];

    } while (puVar2 != (uint *)0x0);

    bVar3 = puVar2 == (uint *)0x0;

  }

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 0x14))();

  }

  return !bVar3;

}





// --- FUN_00589290 at 0x00589290 (size: 414) ---


char FUN_00589290(int *param_1)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  

  if ((param_1[0x2d] != 0) || ((*(byte *)(param_1 + 0x40) & 4) != 0)) {

    iVar3 = FUN_00564d30();

    if (*(int *)(iVar3 + 0x18) == 0) goto LAB_00589318;

    iVar3 = param_1[0x2d];

    iVar4 = FUN_00564d30();

    if (iVar3 != *(int *)(iVar4 + 0x18)) goto LAB_00589318;

  }

  if (param_1[0x2e] != 0) {

    if (DAT_0083da58 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_1[0x2e] != iVar3) goto LAB_00589318;

  }

  if ((((param_1[0x40] & 0x800000U) != 0) || (param_1[0x32] != 0)) || (param_1[0x33] != 0)) {

    iVar3 = FUN_00589230();

    if (iVar3 == 0) {

LAB_00589318:

      uVar5 = (**(code **)(*param_1 + 0x18))();

      iVar3 = FUN_0058df90();

      if (iVar3 == 0) {

        if ((int)uVar5 < 0) {

          return '\a';

        }

      }

      else {

        if (((param_1[0x3b] != 0) || ((uVar5 & 0x8000) != 0)) ||

           ((param_1[0x40] & 0x20000000U) != 0)) {

          if (DAT_0083da58 == 0) {

            iVar3 = 0;

          }

          else {

            iVar3 = *(int *)(DAT_0083da58 + 0xf4);

          }

          if (param_1[0x2e] != iVar3) {

            return (-((param_1[0x40] & 0x40000000U) != 0) & 5U) + 3;

          }

        }

        uVar1 = param_1[0x30];

        uVar2 = param_1[0x31];

        if ((((uVar1 & 0x7e00) != 0) && ((uVar2 & 0x7e00) == 0)) ||

           ((((uVar1 & 0x80001ff) != 0 && ((uVar2 & 0x80001ff) == 0)) ||

            (((uVar1 & 0x7c0f8000) != 0 && ((uVar2 & 0x7c0f8000) == 0)))))) {

          return '\x04';

        }

        if ((uVar5 & 0x20000000) != 0) {

          return '\x06';

        }

      }

      FUN_004fd850(param_1[0x36]);

      iVar3 = FUN_004fd860();

      if (iVar3 != 0) {

        return '\x01';

      }

      iVar3 = (**(code **)(*param_1 + 0x10))();

      if (iVar3 != 0) {

        if (DAT_0083da58 == 0) {

          iVar3 = 0;

        }

        else {

          iVar3 = *(int *)(DAT_0083da58 + 0xf4);

        }

        if (param_1[2] != iVar3) {

          return '\x05';

        }

      }

      return '\0';

    }

  }

  return '\x02';

}





// --- FUN_00589430 at 0x00589430 (size: 27) ---


uint FUN_00589430(undefined4 param_1,int param_2,int param_3)



{

  char cVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  undefined4 *puVar5;

  int *piVar6;

  undefined4 *puVar7;

  wchar_t *pwVar8;

  undefined4 uVar9;

  undefined1 auStack_9c [4];

  undefined1 auStack_98 [4];

  undefined1 auStack_94 [4];

  undefined1 auStack_90 [144];

  

  iVar2 = FUN_0058de80(0);

  if (iVar2 == 0) {

    return 0;

  }

  iVar2 = FUN_005583f0(param_1);

  if (iVar2 == 0) {

    return 0;

  }

  if (DAT_0083da58 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (param_2 == iVar4) {

    uVar9 = 0;

    FUN_0055e1d0(param_1,0);

    uVar3 = FUN_0055e5e0(param_1,uVar9);

    return uVar3 & 0xff;

  }

  iVar4 = FUN_0058df90();

  if (iVar4 == 0) {

    puVar5 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

    uVar9 = *puVar5;

    pwVar8 = L"You must first pick up the %s";

LAB_005894c8:

    FUN_00480980(auStack_9c,0,pwVar8,uVar9);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(auStack_9c,1);

LAB_005894fe:

    FUN_00693500(0x1a,auStack_90);

    FUN_0042e590();

    FUN_004011b0();

    return 0;

  }

  if (*(int *)(iVar2 + 0x78) != 0) {

    puVar5 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

    uVar9 = *puVar5;

    pwVar8 = L"You are trading the %s, it cannot be dropped";

LAB_005896b4:

    FUN_00480980(auStack_9c,0,pwVar8,uVar9);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(auStack_9c,1);

    goto LAB_005894fe;

  }

  if (param_2 != 0) {

    uVar3 = FUN_00588720(param_1,param_2,0);

    if (uVar3 != 0) {

      return uVar3;

    }

    piVar6 = (int *)FUN_005583f0(param_2);

    uVar3 = 0;

    if (piVar6 != (int *)0x0) {

      if ((piVar6[0x40] & 0x200U) != 0) {

        if (DAT_0081d7ec == DAT_0081d7f0) {

          FUN_00564d30(param_2,param_1);

          FUN_00564db0(param_2,param_1);

          return 0;

        }

        FUN_0042dc80();

        FUN_00402730(L"You must split the stack before selling it.");

        FUN_0042cbe0(auStack_9c,1);

        FUN_004011b0();

        goto LAB_00589887;

      }

      FUN_0055e1d0();

      cVar1 = FUN_005d41b0();

      if ((cVar1 != '\0') && (iVar4 = (**(code **)(*piVar6 + 0x10))(), iVar4 != 0)) {

        FUN_0056e6b0(param_2,param_1);

        FUN_0056ed30(param_2,param_1);

        return 0;

      }

      iVar4 = (**(code **)(*piVar6 + 0x18))();

      if (iVar4 == 0x10) {

        uVar9 = FUN_00587d30(iVar2);

        FUN_0058e450(param_2,uVar9);

        return 1;

      }

      iVar4 = FUN_004a48a0();

      if (iVar4 != 0) {

        if ((*(byte *)(piVar6 + 0x40) & 1) == 0) {

          puVar5 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

          uVar9 = *puVar5;

          pwVar8 = L"The %s is locked";

          goto LAB_005894c8;

        }

        iVar4 = FUN_00564d30();

        if (*(int *)(iVar4 + 0x18) != param_2) {

          puVar5 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

          uVar9 = *puVar5;

          pwVar8 = L"You must open the %s first";

          goto LAB_005896b4;

        }

        uVar3 = FUN_00588f70(param_1,param_2,0,1,0);

      }

      if (param_3 == 0) {

        puVar5 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

        puVar7 = (undefined4 *)FUN_0058f8b0(auStack_98,2,0);

        FUN_00480980(auStack_9c,0,L"Cannot give %s to %s",*puVar7,*puVar5);

        FUN_004011b0();

        FUN_004011b0();

        FUN_0042dc80();

        FUN_0042cbe0(auStack_9c,1);

        goto LAB_005894fe;

      }

    }

    if (uVar3 != 0) {

      return uVar3;

    }

  }

  if (param_3 == 0) {

    return 0;

  }

  uVar9 = FUN_0048e5f0();

  iVar4 = FUN_00558410(uVar9);

  if ((iVar4 != 0) && (iVar4 = FUN_00528730(), iVar4 != 0)) {

    if (DAT_0081d7ec < DAT_0081d7f0) {

      FUN_0058e680(DAT_0081d7ec);

      return 1;

    }

    if (*(int *)(iVar2 + 0x68) == 0) {

      FUN_0042dc80();

      FUN_00402730(L"Move cancelled");

      FUN_0042cbe0(auStack_9c,1);

      FUN_004011b0();

      FUN_00693500(0x1a,auStack_90);

      FUN_0042e590();

      return 0;

    }

    FUN_0058e530();

    return 1;

  }

  FUN_0042dc80();

  FUN_00402730(L"You cannot do that in mid air");

  FUN_0042cbe0(auStack_9c,1);

  FUN_004011b0();

LAB_00589887:

  FUN_00693500(0x1a,auStack_90);

  FUN_0042e590();

  return 0;

}





// --- FUN_0058944b at 0x0058944B (size: 1116) ---


uint FUN_0058944b(void)



{

  char cVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  undefined4 *puVar5;

  int *piVar6;

  undefined4 uVar7;

  undefined4 *puVar8;

  int iVar9;

  undefined4 in_stack_000000a0;

  int in_stack_000000a4;

  int in_stack_000000a8;

  wchar_t *pwVar10;

  undefined4 uVar11;

  

  uVar7 = in_stack_000000a0;

  iVar2 = FUN_005583f0(in_stack_000000a0);

  iVar9 = in_stack_000000a4;

  if (iVar2 == 0) {

    return 0;

  }

  if (DAT_0083da58 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (in_stack_000000a4 == iVar4) {

    uVar11 = 0;

    FUN_0055e1d0(uVar7,0);

    uVar3 = FUN_0055e5e0(uVar7,uVar11);

    return uVar3 & 0xff;

  }

  iVar4 = FUN_0058df90();

  if (iVar4 == 0) {

    puVar5 = (undefined4 *)FUN_0058f8b0(&stack0x00000004,2,0);

    uVar7 = *puVar5;

    pwVar10 = L"You must first pick up the %s";

LAB_005894c8:

    FUN_00480980(&stack0x00000000,0,pwVar10,uVar7);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(&stack0x00000000,1);

LAB_005894fe:

    FUN_00693500(0x1a,&stack0x0000000c);

    FUN_0042e590();

    FUN_004011b0();

    return 0;

  }

  if (*(int *)(iVar2 + 0x78) != 0) {

    puVar5 = (undefined4 *)FUN_0058f8b0(&stack0x00000004,2,0);

    uVar7 = *puVar5;

    pwVar10 = L"You are trading the %s, it cannot be dropped";

LAB_005896b4:

    FUN_00480980(&stack0x00000000,0,pwVar10,uVar7);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(&stack0x00000000,1);

    goto LAB_005894fe;

  }

  if (iVar9 != 0) {

    uVar3 = FUN_00588720(uVar7,iVar9,0);

    if (uVar3 != 0) {

      return uVar3;

    }

    piVar6 = (int *)FUN_005583f0(iVar9);

    uVar3 = 0;

    if (piVar6 != (int *)0x0) {

      if ((piVar6[0x40] & 0x200U) != 0) {

        if (DAT_0081d7ec == DAT_0081d7f0) {

          uVar7 = in_stack_000000a0;

          FUN_00564d30(iVar9,in_stack_000000a0);

          FUN_00564db0(iVar9,uVar7);

          return 0;

        }

        FUN_0042dc80();

        FUN_00402730(L"You must split the stack before selling it.");

        FUN_0042cbe0(&stack0x00000000,1);

        FUN_004011b0();

        goto LAB_00589887;

      }

      FUN_0055e1d0();

      cVar1 = FUN_005d41b0();

      if ((cVar1 != '\0') && (iVar4 = (**(code **)(*piVar6 + 0x10))(), iVar4 != 0)) {

        uVar7 = in_stack_000000a0;

        FUN_0056e6b0(iVar9,in_stack_000000a0);

        FUN_0056ed30(iVar9,uVar7);

        return 0;

      }

      iVar4 = (**(code **)(*piVar6 + 0x18))();

      if (iVar4 == 0x10) {

        uVar7 = FUN_00587d30(iVar2);

        FUN_0058e450(iVar9,uVar7);

        return 1;

      }

      iVar4 = FUN_004a48a0();

      if (iVar4 != 0) {

        if ((*(byte *)(piVar6 + 0x40) & 1) == 0) {

          puVar5 = (undefined4 *)FUN_0058f8b0(&stack0x00000004,2,0);

          uVar7 = *puVar5;

          pwVar10 = L"The %s is locked";

          goto LAB_005894c8;

        }

        iVar4 = FUN_00564d30();

        if (*(int *)(iVar4 + 0x18) != iVar9) {

          puVar5 = (undefined4 *)FUN_0058f8b0(&stack0x00000004,2,0);

          uVar7 = *puVar5;

          pwVar10 = L"You must open the %s first";

          goto LAB_005896b4;

        }

        uVar3 = FUN_00588f70(in_stack_000000a0,iVar9,0,1,0);

      }

      if (in_stack_000000a8 == 0) {

        puVar5 = (undefined4 *)FUN_0058f8b0(&stack0x00000008,2,0);

        puVar8 = (undefined4 *)FUN_0058f8b0(&stack0x00000004,2,0);

        FUN_00480980(&stack0x00000000,0,L"Cannot give %s to %s",*puVar8,*puVar5);

        FUN_004011b0();

        FUN_004011b0();

        FUN_0042dc80();

        FUN_0042cbe0(&stack0x00000000,1);

        goto LAB_005894fe;

      }

    }

    if (uVar3 != 0) {

      return uVar3;

    }

  }

  if (in_stack_000000a8 == 0) {

    return 0;

  }

  uVar7 = FUN_0048e5f0();

  iVar9 = FUN_00558410(uVar7);

  if ((iVar9 != 0) && (iVar9 = FUN_00528730(), iVar9 != 0)) {

    if (DAT_0081d7ec < DAT_0081d7f0) {

      FUN_0058e680(DAT_0081d7ec);

      return 1;

    }

    if (*(int *)(iVar2 + 0x68) == 0) {

      FUN_0042dc80();

      FUN_00402730(L"Move cancelled");

      FUN_0042cbe0(&stack0x00000000,1);

      FUN_004011b0();

      FUN_00693500(0x1a,&stack0x0000000c);

      FUN_0042e590();

      return 0;

    }

    FUN_0058e530();

    return 1;

  }

  FUN_0042dc80();

  FUN_00402730(L"You cannot do that in mid air");

  FUN_0042cbe0(&stack0x00000000,1);

  FUN_004011b0();

LAB_00589887:

  FUN_00693500(0x1a,&stack0x0000000c);

  FUN_0042e590();

  return 0;

}





// --- FUN_005898b0 at 0x005898B0 (size: 1136) ---


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



void FUN_005898b0(int param_1,int param_2,int param_3)



{

  bool bVar1;

  char cVar2;

  ushort uVar3;

  int iVar4;

  int *piVar5;

  int iVar6;

  undefined4 *puVar7;

  uint uVar8;

  wchar_t *pwVar9;

  undefined4 uVar10;

  undefined1 local_9c [4];

  undefined1 local_98 [8];

  undefined1 local_90 [144];

  

  iVar4 = FUN_00564d30();

  if (((iVar4 == 0) || (piVar5 = (int *)FUN_005583f0(param_1), piVar5 == (int *)0x0)) ||

     (_DAT_008379a8 < _DAT_00871ae8 + _DAT_007e3c88)) {

    return;

  }

  _DAT_00871ae8 = _DAT_008379a8;

  iVar4 = FUN_0058de80(0);

  if (iVar4 == 0) {

    return;

  }

  iVar4 = FUN_00564d30();

  if ((*(int *)(iVar4 + 0x20) != 0) &&

     (iVar4 = piVar5[0x2d], iVar6 = FUN_00564d30(), iVar4 == *(int *)(iVar6 + 0x20))) {

    return;

  }

  bVar1 = false;

  if (((param_3 == 0) && (uVar3 = FUN_00589290(piVar5), 1 < uVar3)) && (uVar3 < 8)) {

    bVar1 = true;

  }

  FUN_004fd850(piVar5[0x36]);

  if (bVar1) {

LAB_00589ac2:

    uVar10 = 1;

    FUN_0055e1d0(param_1,1,param_3);

    FUN_00563d10(param_1,uVar10,param_3);

    return;

  }

  if (piVar5[0x1e] == 1) {

    puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

    uVar10 = *puVar7;

    pwVar9 = L"You cannot use the %s because you are trading it";

  }

  else {

    if ((piVar5[0x31] == 0) && (uVar8 = FUN_004fd870(), (uVar8 & 4) != 0)) {

      puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

      uVar10 = *puVar7;

      pwVar9 = L"You must wield the %s to use it";

LAB_00589cd9:

      FUN_00480980(local_9c,0,pwVar9,uVar10);

      FUN_004011b0();

      FUN_0042dc80();

      FUN_0042cbe0(local_9c,1);

      goto LAB_005899d3;

    }

    iVar6 = FUN_004fd8b0();

    iVar4 = DAT_00871e54;

    if (iVar6 == 0) {

      iVar4 = FUN_004fd860();

      if (iVar4 == 0) {

        uVar10 = 0;

        iVar4 = param_1;

        FUN_0055e1d0(param_1,0,param_3);

        FUN_00563d10(iVar4,uVar10,param_3);

        iVar4 = FUN_0048e5f0();

        if (param_1 == iVar4) {

          return;

        }

        if ((piVar5[0x40] & 0x1000U) != 0) {

          puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

          FUN_00480980(local_9c,0,L"You can\'t open or close this %s that way",*puVar7);

          FUN_004011b0();

          FUN_0042dc80();

          goto LAB_00589c56;

        }

        iVar4 = param_1;

        FUN_0056b210(param_1);

        cVar2 = FUN_0056b340(iVar4);

        if ((cVar2 == '\0') || (iVar4 = FUN_0056b210(), *(int *)(iVar4 + 0x1c) != 1)) {

          FUN_0056b210(param_1);

          cVar2 = FUN_0056b340(param_1);

          if ((cVar2 != '\0') && (iVar4 = FUN_0056b210(), *(int *)(iVar4 + 0x1c) != 1)) {

            return;

          }

          puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

          uVar10 = *puVar7;

          pwVar9 = L"The %s cannot be used";

          goto LAB_00589cd9;

        }

        puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

        uVar10 = *puVar7;

        pwVar9 = L"To attack %s, click on the dove icon first";

      }

      else {

        uVar8 = piVar5[0x40];

        if ((uVar8 & 0x400) != 0) {

          FUN_00564d30(param_1);

          FUN_005671c0(param_1);

          return;

        }

        if ((uVar8 & 0x800) != 0) {

          FUN_00564d30(param_1);

          FUN_005673b0(param_1);

          return;

        }

        if ((uVar8 & 0x10000000) != 0) {

          FUN_0055e1d0();

          cVar2 = FUN_005d4510();

          if (cVar2 != '\0') {

            FUN_00564d30(param_1);

            FUN_005675a0(param_1);

            return;

          }

        }

        FUN_006ad310(param_1);

        FUN_00564d30();

        FUN_00565610();

        uVar10 = 1;

        FUN_0055e1d0(param_1,1,param_3);

        FUN_00563d10(param_1,uVar10,param_3);

        uVar8 = (**(code **)(*piVar5 + 0x18))();

        if ((uVar8 & 0x10) == 0) {

          puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

          uVar10 = *puVar7;

          pwVar9 = L"Using the %s";

          goto LAB_00589cd9;

        }

        puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

        uVar10 = *puVar7;

        pwVar9 = L"Approaching %s";

      }

    }

    else {

      if (param_2 != 0) {

        if (DAT_00871e54 != 0) {

          cVar2 = FUN_00588350(DAT_00871e54,param_1,0,1);

          if (cVar2 == '\0') {

            return;

          }

          FUN_006ad3e0(param_1,iVar4);

          FUN_00564d30();

          FUN_00565610();

          goto LAB_00589ac2;

        }

        puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

        FUN_00480980(local_9c,0,L"Select your target before using the %s",*puVar7);

        FUN_004011b0();

        FUN_0042dc80();

LAB_00589c56:

        FUN_0042cbe0(local_9c,1);

        goto LAB_005899d3;

      }

      uVar10 = 3;

      DAT_00871ae4 = param_1;

      FUN_00564d30(3);

      FUN_005656e0(uVar10);

      puVar7 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

      uVar10 = *puVar7;

      pwVar9 = L"Choose a target for the %s";

    }

  }

  FUN_00480980(local_9c,0,pwVar9,uVar10);

  FUN_004011b0();

  FUN_0042dc80();

  FUN_0042cbe0(local_9c,1);

LAB_005899d3:

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  FUN_004011b0();

  return;

}





// --- FUN_00589d20 at 0x00589D20 (size: 261) ---


void FUN_00589d20(undefined4 param_1)



{

  char cVar1;

  int *piVar2;

  int iVar3;

  uint uVar4;

  char *pcVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  

  uVar6 = DAT_00871ae4;

  DAT_00871ae4 = 0;

  cVar1 = FUN_00588350(param_1,uVar6,0,1);

  if (cVar1 != '\0') {

    piVar2 = (int *)FUN_005583f0(uVar6);

    iVar3 = FUN_005583f0(param_1);

    if ((piVar2 != (int *)0x0) && (iVar3 != 0)) {

      uVar4 = (**(code **)(*piVar2 + 0x18))();

      if (((uVar4 & 0x80000) != 0) && ((*(byte *)(piVar2 + 0x39) & 1) == 0)) {

        if ((*(byte *)(iVar3 + 0x103) & 1) != 0) {

          uVar8 = 0;

          uVar7 = 1;

          uVar6 = 0;

          pcVar5 = "You cannot drain the mana of this item because it is \"Retained\".\n";

          FUN_00564d30("You cannot drain the mana of this item because it is \"Retained\".\n",0,1,0)

          ;

          FUN_004882f0(pcVar5,uVar6,uVar7,uVar8);

          return;

        }

        FUN_00564d30(uVar6,param_1);

        FUN_00566ee0(uVar6,param_1);

        return;

      }

      FUN_0055e1d0();

      cVar1 = FUN_005d44c0();

      if (cVar1 == '\0') {

        uVar4 = (**(code **)(*piVar2 + 0x18))();

        if ((uVar4 & 0x40000000) != 0) {

          FUN_00564d30(uVar6,param_1);

          FUN_00567790(uVar6,param_1);

          return;

        }

      }

      (**(code **)(*piVar2 + 0x18))();

    }

    FUN_006ad3e0(uVar6,param_1);

    FUN_00564d30();

    FUN_00565610();

    uVar8 = 0;

    uVar7 = 1;

    FUN_0055e1d0(uVar6,1,0);

    FUN_00563d10(uVar6,uVar7,uVar8);

  }

  return;

}





// --- FUN_00589e70 at 0x00589E70 (size: 17) ---


void FUN_00589e70(undefined4 param_1)



{

  if (DAT_00870be4 != 0) {

    *(undefined4 *)(DAT_00870be4 + 0x14) = param_1;

  }

  return;

}





// --- FUN_00589e90 at 0x00589E90 (size: 19) ---


undefined4 FUN_00589e90(void)



{

  if (DAT_00870be4 == 0) {

    return 1;

  }

  return *(undefined4 *)(DAT_00870be4 + 0x14);

}





// --- FUN_00589eb0 at 0x00589EB0 (size: 71) ---


void FUN_00589eb0(byte param_1,char param_2)



{

  uint uVar1;

  

  uVar1 = 1 << (param_1 & 0x1f);

  if (param_2 != '\0') {

    *(uint *)(DAT_00870be4 + 0x18) = *(uint *)(DAT_00870be4 + 0x18) | uVar1;

    FUN_00479ee0();

    return;

  }

  *(uint *)(DAT_00870be4 + 0x18) = *(uint *)(DAT_00870be4 + 0x18) & ~uVar1;

  FUN_00479ee0();

  return;

}





// --- FUN_00589f00 at 0x00589F00 (size: 24) ---


undefined4 FUN_00589f00(byte param_1)



{

  uint uVar1;

  

  uVar1 = 1 << (param_1 & 0x1f);

  return CONCAT31((int3)(uVar1 >> 8),(*(uint *)(DAT_00870be4 + 0x18) & uVar1) != 0);

}





// --- FUN_00589f20 at 0x00589F20 (size: 17) ---


undefined4 FUN_00589f20(void)



{

  if (DAT_00870be4 == 0) {

    return 0;

  }

  return *(undefined4 *)(DAT_00870be4 + 0x80);

}





// --- FUN_00589f40 at 0x00589F40 (size: 32) ---


undefined4 FUN_00589f40(undefined4 param_1)



{

  if (DAT_00870be4 == 0) {

    return 0;

  }

  FUN_005ce550(param_1);

  return 1;

}





// --- FUN_00589f60 at 0x00589F60 (size: 20) ---


void FUN_00589f60(undefined4 param_1)



{

  if (DAT_00870be4 != 0) {

    *(undefined4 *)(DAT_00870be4 + 0x84) = param_1;

  }

  return;

}





// --- FUN_00589f80 at 0x00589F80 (size: 17) ---


undefined4 FUN_00589f80(void)



{

  if (DAT_00870be4 == 0) {

    return 0;

  }

  return *(undefined4 *)(DAT_00870be4 + 0x84);

}





// --- FUN_00589fa0 at 0x00589FA0 (size: 17) ---


void FUN_00589fa0(undefined4 param_1)



{

  if (DAT_00870be4 != 0) {

    *(undefined4 *)(DAT_00870be4 + 100) = param_1;

  }

  return;

}





// --- FUN_00589fc0 at 0x00589FC0 (size: 14) ---


undefined4 FUN_00589fc0(void)



{

  if (DAT_00870be4 == 0) {

    return 0;

  }

  return *(undefined4 *)(DAT_00870be4 + 100);

}





// --- FUN_00589fd0 at 0x00589FD0 (size: 17) ---


void FUN_00589fd0(undefined4 param_1)



{

  if (DAT_00870be4 != 0) {

    *(undefined4 *)(DAT_00870be4 + 0x6c) = param_1;

  }

  return;

}





// --- FUN_00589ff0 at 0x00589FF0 (size: 14) ---


undefined4 FUN_00589ff0(void)



{

  if (DAT_00870be4 == 0) {

    return 0;

  }

  return *(undefined4 *)(DAT_00870be4 + 0x6c);

}





// --- FUN_0058a000 at 0x0058A000 (size: 67) ---


undefined4 FUN_0058a000(undefined4 param_1,undefined4 param_2,int param_3)



{

  int iVar1;

  undefined4 uVar2;

  

  if (DAT_00870be4 == 0) {

    return 1;

  }

  if (param_3 != 1) {

    iVar1 = FUN_006b0e10(param_3);

    if (iVar1 == 0) {

      return 0;

    }

  }

  uVar2 = FUN_006b2360(param_1,param_2,param_3);

  return uVar2;

}





// --- FUN_0058a050 at 0x0058A050 (size: 28) ---


void FUN_0058a050(undefined4 param_1)



{

  if (DAT_00870be4 != 0) {

    FUN_006b2be0(param_1);

    FUN_0047a6a0();

    return;

  }

  return;

}





// --- FUN_0058a070 at 0x0058A070 (size: 23) ---


void FUN_0058a070(void)



{

  if (DAT_00870be4 != 0) {

    FUN_006b27b0();

    FUN_0047a6a0();

    return;

  }

  return;

}





// --- FUN_0058a0d0 at 0x0058A0D0 (size: 87) ---


void __thiscall FUN_0058a0d0(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  uVar5 = 0;

  if (uVar1 != 0) {

    piVar2 = *(int **)(param_1 + 8);

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007e3efc;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

  uVar3 = *(undefined4 *)(param_1 + 8);

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007e3efc;

  param_2[3] = uVar1;

  return;

}





// --- FUN_0058a130 at 0x0058A130 (size: 66) ---


void __fastcall FUN_0058a130(int param_1)



{

  int iVar1;

  uint uVar2;

  int *piVar3;

  

  iVar1 = *(int *)(*(int *)(param_1 + 4) + 0x1c);

  if (iVar1 != 0) {

    *(int *)(param_1 + 4) = iVar1;

    return;

  }

  uVar2 = *(int *)(*(int *)(param_1 + 4) + 0x20) + 1;

  if (uVar2 < *(uint *)(param_1 + 0xc)) {

    piVar3 = (int *)(*(int *)(param_1 + 8) + uVar2 * 4);

    do {

      if (*piVar3 != 0) {

        *(undefined4 *)(param_1 + 4) = *(undefined4 *)(*(int *)(param_1 + 8) + uVar2 * 4);

        return;

      }

      uVar2 = uVar2 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar2 < *(uint *)(param_1 + 0xc));

  }

  *(undefined4 *)(param_1 + 4) = 0;

  return;

}





// --- FUN_0058a180 at 0x0058A180 (size: 69) ---


void __thiscall FUN_0058a180(int param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  

  puVar1 = (undefined4 *)*param_2;

  if (puVar1 != *(undefined4 **)(param_1 + 0x14)) {

    LVar3 = InterlockedDecrement(puVar1 + 1);

    if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    iVar2 = *(int *)(param_1 + 0x14);

    *param_2 = iVar2;

                    /* WARNING: Could not recover jumptable at 0x0058a1b9. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    InterlockedIncrement((LONG *)(iVar2 + 4));

    return;

  }

  return;

}





// --- FUN_0058a1d0 at 0x0058A1D0 (size: 30) ---


void * __thiscall FUN_0058a1d0(void *param_1,byte param_2)



{

  FUN_006b1fe0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058a1f0 at 0x0058A1F0 (size: 189) ---


undefined4 * __fastcall FUN_0058a1f0(undefined4 *param_1)



{

  int iVar1;

  undefined4 uVar2;

  LONG *pLVar3;

  

  FUN_00557300();

  *param_1 = &PTR_LAB_007e3f14;

  param_1[5] = 1;

  param_1[6] = 2;

  FUN_006b2a90();

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  pLVar3 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x1a] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar3);

  param_1[0x1b] = 0;

  pLVar3 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x1c] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar3);

  pLVar3 = (LONG *)(DAT_008ef11c + 4);

  param_1[0x1d] = DAT_008ef11c;

  InterlockedIncrement(pLVar3);

  pLVar3 = (LONG *)(DAT_008ef11c + 4);

  param_1[0x1e] = DAT_008ef11c;

  InterlockedIncrement(pLVar3);

  pLVar3 = (LONG *)(DAT_008ef11c + 4);

  param_1[0x1f] = DAT_008ef11c;

  InterlockedIncrement(pLVar3);

  param_1[0x21] = 0;

  iVar1 = FUN_005df0f5(0x2c);

  if (iVar1 != 0) {

    uVar2 = FUN_005ce520();

    param_1[0x20] = uVar2;

    return param_1;

  }

  param_1[0x20] = 0;

  return param_1;

}





// --- FUN_0058a2b0 at 0x0058A2B0 (size: 118) ---


void FUN_0058a2b0(int param_1)



{

  int *piVar1;

  int iVar2;

  LONG LVar3;

  

  if (DAT_00870be4 == 0) {

    iVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  }

  else {

    piVar1 = (int *)(DAT_00870be4 + 0x68);

    iVar2 = *piVar1;

    if (iVar2 != param_1) {

      LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar3 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

      }

      *piVar1 = param_1;

      InterlockedIncrement((LONG *)(param_1 + -0x10));

    }

    iVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  }

  if ((iVar2 == 0) && ((undefined4 *)(param_1 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  return;

}





// --- FUN_0058a330 at 0x0058A330 (size: 74) ---


void FUN_0058a330(int *param_1)



{

  int *piVar1;

  int iVar2;

  LONG LVar3;

  

  if (DAT_00870be4 != 0) {

    piVar1 = (int *)(DAT_00870be4 + 0x70);

    iVar2 = *piVar1;

    if (iVar2 != *param_1) {

      LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar3 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

      }

      iVar2 = *param_1;

      *piVar1 = iVar2;

      InterlockedIncrement((LONG *)(iVar2 + -0x10));

    }

  }

  return;

}





// --- FUN_0058a380 at 0x0058A380 (size: 56) ---


int * FUN_0058a380(int *param_1)



{

  int iVar1;

  LONG *lpAddend;

  

  if (DAT_00870be4 == 0) {

    lpAddend = (LONG *)(PTR_DAT_008183b4 + -0x10);

    *param_1 = (int)PTR_DAT_008183b4;

    InterlockedIncrement(lpAddend);

    return param_1;

  }

  iVar1 = *(int *)(DAT_00870be4 + 0x70);

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  return param_1;

}





// --- FUN_0058a3c0 at 0x0058A3C0 (size: 126) ---


void FUN_0058a3c0(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  if (DAT_00870be4 == 0) {

    LVar3 = InterlockedDecrement(param_1 + 1);

    if ((LVar3 == 0) && (param_1 != (undefined4 *)0x0)) {

      (**(code **)*param_1)(1);

      return;

    }

  }

  else {

    puVar2 = *(undefined4 **)(DAT_00870be4 + 0x74);

    puVar1 = (undefined4 *)(DAT_00870be4 + 0x74);

    if (puVar2 != param_1) {

      LVar3 = InterlockedDecrement(puVar2 + 1);

      if ((LVar3 == 0) && (puVar2 != (undefined4 *)0x0)) {

        (**(code **)*puVar2)(1);

      }

      *puVar1 = param_1;

      InterlockedIncrement(param_1 + 1);

    }

    LVar3 = InterlockedDecrement(param_1 + 1);

    if ((LVar3 == 0) && (param_1 != (undefined4 *)0x0)) {

      (**(code **)*param_1)(1);

    }

  }

  return;

}





// --- FUN_0058a440 at 0x0058A440 (size: 56) ---


int * FUN_0058a440(int *param_1)



{

  int iVar1;

  LONG *lpAddend;

  

  if (DAT_00870be4 == 0) {

    lpAddend = (LONG *)(DAT_008ef120 + 4);

    *param_1 = DAT_008ef120;

    InterlockedIncrement(lpAddend);

    return param_1;

  }

  iVar1 = *(int *)(DAT_00870be4 + 0x74);

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  return param_1;

}





// --- FUN_0058a480 at 0x0058A480 (size: 126) ---


void FUN_0058a480(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  if (DAT_00870be4 == 0) {

    LVar3 = InterlockedDecrement(param_1 + 1);

    if ((LVar3 == 0) && (param_1 != (undefined4 *)0x0)) {

      (**(code **)*param_1)(1);

      return;

    }

  }

  else {

    puVar2 = *(undefined4 **)(DAT_00870be4 + 0x78);

    puVar1 = (undefined4 *)(DAT_00870be4 + 0x78);

    if (puVar2 != param_1) {

      LVar3 = InterlockedDecrement(puVar2 + 1);

      if ((LVar3 == 0) && (puVar2 != (undefined4 *)0x0)) {

        (**(code **)*puVar2)(1);

      }

      *puVar1 = param_1;

      InterlockedIncrement(param_1 + 1);

    }

    LVar3 = InterlockedDecrement(param_1 + 1);

    if ((LVar3 == 0) && (param_1 != (undefined4 *)0x0)) {

      (**(code **)*param_1)(1);

    }

  }

  return;

}





// --- FUN_0058a500 at 0x0058A500 (size: 56) ---


int * FUN_0058a500(int *param_1)



{

  int iVar1;

  LONG *lpAddend;

  

  if (DAT_00870be4 == 0) {

    lpAddend = (LONG *)(DAT_008ef120 + 4);

    *param_1 = DAT_008ef120;

    InterlockedIncrement(lpAddend);

    return param_1;

  }

  iVar1 = *(int *)(DAT_00870be4 + 0x78);

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  return param_1;

}





// --- FUN_0058a540 at 0x0058A540 (size: 55) ---


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



void FUN_0058a540(void)



{

  undefined1 local_10 [4];

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_0058a0d0(local_10);

  DAT_00821500 = local_c;

  _DAT_00821508 = local_4;

  _DAT_00821504 = local_8;

  return;

}





// --- FUN_0058a5f0 at 0x0058A5F0 (size: 30) ---


void * __thiscall FUN_0058a5f0(void *param_1,byte param_2)



{

  FUN_0058a610();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058a610 at 0x0058A610 (size: 35) ---


void __fastcall FUN_0058a610(undefined4 *param_1)



{

  param_1[3] = &PTR_LAB_007e3f1c;

  param_1[3] = &PTR_FUN_007952f4;

  *param_1 = &PTR_LAB_007e3ee4;

  param_1[1] = &PTR_LAB_007e3ed4;

  param_1[2] = &PTR_LAB_007e3eb8;

  return;

}





// --- FUN_0058a690 at 0x0058A690 (size: 252) ---


undefined4 FUN_0058a690(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  LONG LVar4;

  int iVar5;

  float10 fVar6;

  float10 fVar7;

  float fStack_c;

  float fStack_8;

  

  puVar1 = param_1;

  if (param_1 == (undefined4 *)0x0) {

    return 1;

  }

  FUN_0048c3e0(&DAT_007938af);

  iVar5 = param_2;

  if (DAT_00870be4 == 0) {

    iVar5 = 1;

  }

  else if ((param_2 == 1) || (iVar3 = FUN_006b0e10(param_2), iVar3 != 0)) {

    iVar5 = FUN_006b2360(puVar1,&param_1,iVar5);

  }

  else {

    iVar5 = 0;

  }

  puVar2 = param_1;

  LVar4 = InterlockedDecrement(param_1 + 1);

  if ((LVar4 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  if (iVar5 == 0) {

    iVar5 = FUN_00558410(puVar1);

    if (iVar5 != 0) {

      FUN_0055e1d0();

      FUN_00452de0(iVar5,&fStack_c);

      fVar6 = (float10)FUN_0055e5a0();

      param_1 = (undefined4 *)(float)fVar6;

      fVar7 = (float10)FUN_0055e5a0();

      fVar6 = (float10)(fStack_c * fStack_c + fStack_8 * fStack_8);

      if (fVar7 * (float10)(float)param_1 < fVar6 != (fVar7 * (float10)(float)param_1 == fVar6)) {

        return 0;

      }

    }

    return 1;

  }

  return 0;

}





// --- FUN_0058a790 at 0x0058A790 (size: 147) ---


undefined4 FUN_0058a790(undefined4 param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined **ppuVar3;

  

  iVar2 = DAT_00821500;

  if ((DAT_00870be4 != 0) && (DAT_00821500 != 0)) {

    ppuVar3 = &PTR_FUN_007e3f00;

    FUN_005b1950(DAT_00821500 + 8);

    uVar1 = *(undefined4 *)(iVar2 + 0x14);

    InterlockedIncrement((LONG *)(*(int *)(iVar2 + 0x18) + 4));

    iVar2 = FUN_006b1af0();

    if (iVar2 == 0) {

      FUN_0058a180(param_1);

      *param_2 = uVar1;

      FUN_0058a130(ppuVar3);

      FUN_006b1fe0();

      return 1;

    }

    FUN_006b1fe0();

  }

  return 0;

}





// --- FUN_0058a870 at 0x0058A870 (size: 56) ---


int * FUN_0058a870(int *param_1)



{

  int iVar1;

  LONG *lpAddend;

  

  if (DAT_00870be4 == 0) {

    lpAddend = (LONG *)(PTR_DAT_00818344 + -0x10);

    *param_1 = (int)PTR_DAT_00818344;

    InterlockedIncrement(lpAddend);

    return param_1;

  }

  iVar1 = *(int *)(DAT_00870be4 + 0x68);

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  return param_1;

}





// --- FUN_0058a8b0 at 0x0058A8B0 (size: 929) ---


void FUN_0058a8b0(int param_1,undefined4 param_2,int param_3)



{

  LONG *lpAddend;

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  undefined4 uVar4;

  int *piVar5;

  int *piVar6;

  undefined4 *puVar7;

  uint uVar8;

  undefined4 **ppuVar9;

  undefined4 **ppuVar10;

  undefined4 **ppuVar11;

  undefined4 **ppuVar12;

  undefined4 **ppuVar13;

  undefined4 *puStack_41c;

  undefined4 *local_418;

  undefined4 *puStack_414;

  undefined4 *puStack_410;

  undefined4 *local_40c;

  undefined4 *puStack_408;

  undefined4 *puStack_404;

  undefined1 auStack_400 [1024];

  

  FUN_004034c0(&DAT_007938af);

  iVar2 = FUN_006b1af0();

  puVar7 = DAT_008ef11c;

  if (iVar2 == 0) {

    lpAddend = DAT_008ef11c + 1;

    local_418 = DAT_008ef11c;

    InterlockedIncrement(lpAddend);

    if (puVar7 != *(undefined4 **)(param_1 + 0x14)) {

      LVar3 = InterlockedDecrement(lpAddend);

      if ((LVar3 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

      local_418 = *(undefined4 **)(param_1 + 0x14);

      InterlockedIncrement(local_418 + 1);

      puVar7 = local_418;

    }

    local_40c = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    if (*(int *)(param_1 + 0x10) != 0) {

      FUN_004034c0(" (account) ");

    }

    if (puVar7[2] != 1) {

      uVar4 = FUN_0048c3e0(&DAT_00795098);

      ppuVar13 = &puStack_414;

      ppuVar12 = &local_40c;

      ppuVar11 = &puStack_410;

      ppuVar10 = &local_418;

      ppuVar9 = &puStack_404;

      FUN_0048c3e0("Name: ");

      FUN_004a2b90(ppuVar9,ppuVar10);

      FUN_004a2b90(ppuVar11,ppuVar12);

      piVar5 = (int *)FUN_004a2b90(ppuVar13,uVar4);

      puVar1 = (undefined4 *)*piVar5;

      if ((puVar1[2] != 1) && (puVar1 != DAT_008ef11c)) {

        FUN_004910c0(puVar1 + 5,puVar1[2] + -1);

      }

      puVar1 = puStack_414;

      LVar3 = InterlockedDecrement(puStack_414 + 1);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

      puVar1 = puStack_410;

      LVar3 = InterlockedDecrement(puStack_410 + 1);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

      puVar1 = puStack_404;

      LVar3 = InterlockedDecrement(puStack_404 + 1);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

      puVar1 = puStack_408;

      LVar3 = InterlockedDecrement(puStack_408 + 1);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

      LVar3 = InterlockedDecrement(puStack_41c + 1);

      if ((LVar3 == 0) && (puStack_41c != (undefined4 *)0x0)) {

        (**(code **)*puStack_41c)(1);

      }

    }

    if ((param_3 == 0) && (iVar2 = FUN_006b1b20(1), iVar2 != 0)) {

      FUN_0048c3e0("All message types");

      if ((puStack_41c[2] != 1) && (puStack_41c != DAT_008ef11c)) {

        FUN_004910c0(puStack_41c + 5,puStack_41c[2] + -1);

      }

      LVar3 = InterlockedDecrement(puStack_41c + 1);

      if (LVar3 == 0) {

        (**(code **)*puStack_41c)(1);

      }

    }

    else {

      puStack_410 = (undefined4 *)0x1;

      uVar8 = 0;

      do {

        iVar2 = FUN_006b1b20(uVar8);

        if ((iVar2 != 0) && (iVar2 = FUN_006b0e10(uVar8), iVar2 != 0)) {

          FUN_006b0e60(uVar8,auStack_400,0x400);

          piVar5 = (int *)FUN_0048c3e0("Unknown");

          piVar6 = (int *)FUN_0048c3e0(auStack_400);

          iVar2 = _stricmp((char *)(*piVar6 + 0x14),(char *)(*piVar5 + 0x14));

          LVar3 = InterlockedDecrement(puStack_41c + 1);

          if ((LVar3 == 0) && (puStack_41c != (undefined4 *)0x0)) {

            (**(code **)*puStack_41c)(1);

          }

          puVar7 = puStack_408;

          LVar3 = InterlockedDecrement(puStack_408 + 1);

          if ((LVar3 == 0) && (puVar7 != (undefined4 *)0x0)) {

            (**(code **)*puVar7)(1);

          }

          puVar7 = local_418;

          if (iVar2 != 0) {

            if (puStack_410 == (undefined4 *)0x0) {

              FUN_0048c3e0(&DAT_00795334);

              FUN_004914f0(&puStack_414);

              puVar7 = puStack_414;

              LVar3 = InterlockedDecrement(puStack_414 + 1);

              if ((LVar3 == 0) && (puVar7 != (undefined4 *)0x0)) {

                (**(code **)*puVar7)(1);

              }

            }

            else {

              puStack_410 = (undefined4 *)0x0;

            }

            FUN_0048c3e0(auStack_400);

            puVar1 = puStack_404;

            if ((puStack_404[2] != 1) && (puStack_404 != DAT_008ef11c)) {

              FUN_004910c0(puStack_404 + 5,puStack_404[2] + -1);

            }

            LVar3 = InterlockedDecrement(puVar1 + 1);

            puVar7 = local_418;

            if (LVar3 == 0) {

              (**(code **)*puVar1)(1);

              puVar7 = local_418;

            }

          }

        }

        uVar8 = uVar8 + 1;

      } while (uVar8 < 0x22);

    }

    puVar1 = local_40c;

    LVar3 = InterlockedDecrement(local_40c + 1);

    if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    LVar3 = InterlockedDecrement(puVar7 + 1);

    if (LVar3 == 0) {

      (**(code **)*puVar7)(1);

    }

  }

  return;

}





// --- FUN_0058ace0 at 0x0058ACE0 (size: 171) ---


undefined4 FUN_0058ace0(undefined4 param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 *local_1c;

  undefined1 local_18 [24];

  

  FUN_0048c3e0(&DAT_007938af);

  FUN_006b1f40(&local_1c,1);

  LVar2 = InterlockedDecrement(local_1c + 1);

  if ((LVar2 == 0) && (local_1c != (undefined4 *)0x0)) {

    (**(code **)*local_1c)(1);

  }

  local_1c = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_0058a8b0(local_18,&local_1c,1);

  puVar1 = local_1c;

  FUN_00402710(param_1,"Squelch channels are as follows:\n  %s\n",local_1c + 5);

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  FUN_006b1fe0();

  return 1;

}





// --- FUN_0058ad90 at 0x0058AD90 (size: 307) ---


void FUN_0058ad90(int *param_1,int *param_2,uint param_3,float param_4,undefined4 param_5)



{

  int iVar1;

  LONG LVar2;

  undefined8 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 *local_4;

  

  if ((*(int *)(DAT_0083da58 + 0xf8) != 0) && (param_3 != 0)) {

    FUN_0048c3e0(&DAT_007938af);

    iVar1 = FUN_0058a000();

    LVar2 = InterlockedDecrement(local_4 + 1);

    if ((LVar2 == 0) && (local_4 != (undefined4 *)0x0)) {

      (**(code **)*local_4)(1);

    }

    if ((iVar1 == 0) &&

       (iVar1 = FUN_0058cfd0(*(undefined4 *)(DAT_0083da58 + 0xf4),param_3,(double)param_4,0,0),

       iVar1 != 0)) {

      local_4 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      if ((param_3 < 0x50000001) || (0x6fffffff < param_3)) {

        FUN_00487620(&local_4,"%s says, \"%s\"\n",*param_2 + 0x14,*param_1 + 0x14);

      }

      else {

        FUN_00487620(&local_4,"<Tell:IIDString:%d:%s>%s<\\Tell> says, \"%s\"\n",param_3,

                     *param_2 + 0x14,*param_2 + 0x14,*param_1 + 0x14);

      }

      uVar5 = 0;

      uVar4 = 1;

      uVar3 = CONCAT44(param_5,local_4 + 5);

      FUN_00564d30(local_4 + 5,param_5,1,0);

      FUN_004882f0(uVar3,uVar4,uVar5);

      FUN_005abb30();

    }

  }

  return;

}





// --- FUN_0058aed0 at 0x0058AED0 (size: 530) ---


undefined4 FUN_0058aed0(void)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  int *piVar4;

  code *pcVar5;

  int unaff_ESI;

  undefined4 *puVar6;

  undefined1 *puVar7;

  undefined4 uVar8;

  undefined4 uVar9;

  undefined4 uVar10;

  int local_20;

  undefined4 *local_1c;

  undefined **local_18 [4];

  undefined4 local_8;

  int local_4;

  

  if (DAT_00870be4 != 0) {

    FUN_00402730(L"The following types of messages are currently being filtered globally:\n");

    iVar2 = DAT_00870be4;

    local_18[0] = &PTR_FUN_007e3f00;

    FUN_005b1950(DAT_00870be4 + 0x4c);

    local_8 = *(undefined4 *)(iVar2 + 0x58);

    local_4 = *(int *)(iVar2 + 0x5c);

    InterlockedIncrement((LONG *)(local_4 + 4));

    iVar2 = FUN_006b1af0();

    if (iVar2 == 0) {

      local_1c = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      FUN_0058a8b0(local_18,&local_1c,0);

      puVar1 = local_1c;

      piVar4 = (int *)FUN_00404a40(0,local_1c + 5);

      iVar2 = *(int *)(*piVar4 + -4);

      if (iVar2 != 1) {

        FUN_00402490(*piVar4,iVar2 + -1);

      }

      pcVar5 = InterlockedDecrement_exref;

      puVar6 = local_1c + -5;

      LVar3 = InterlockedDecrement(local_1c + -4);

      if ((LVar3 == 0) && (puVar6 != (undefined4 *)0x0)) {

        (**(code **)*puVar6)(1);

      }

      LVar3 = InterlockedDecrement(puVar1 + 1);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

    }

    else {

      FUN_00402730(L"none");

      if (local_1c[-1] != 1) {

        FUN_00402490(local_1c,local_1c[-1] + -1);

      }

      pcVar5 = InterlockedDecrement_exref;

      puVar1 = local_1c + -5;

      LVar3 = InterlockedDecrement(local_1c + -4);

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

    }

    FUN_00402730(&DAT_0079d2e0);

    if (local_1c[-1] != 1) {

      FUN_00402490(local_1c,local_1c[-1] + -1);

    }

    puVar1 = local_1c + -5;

    iVar2 = (*pcVar5)(local_1c + -4);

    if ((iVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    FUN_00402730(L"(For a list of filter options, type @help filter)\n");

    if (*(int *)(local_20 + -4) != 1) {

      FUN_00402490(local_20,*(int *)(local_20 + -4) + -1);

    }

    iVar2 = (*pcVar5)(local_20 + -0x10);

    if ((iVar2 == 0) && ((undefined4 *)(local_20 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_20 + -0x14))(1);

    }

    uVar10 = 0;

    uVar9 = 1;

    puVar7 = &stack0xffffffd8;

    uVar8 = 0;

    FUN_00564d30(puVar7,0,1,0);

    FUN_005649f0(puVar7,uVar8,uVar9,uVar10);

    FUN_006b1fe0();

    iVar2 = (*pcVar5)(unaff_ESI + -0x10);

    if ((iVar2 == 0) && ((undefined4 *)(unaff_ESI + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(unaff_ESI + -0x14))(1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_0058b0f0 at 0x0058B0F0 (size: 18) ---


undefined4 FUN_0058b0f0(void)



{

  uint uVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  LONG LVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 uVar7;

  int iVar8;

  undefined4 *unaff_EBP;

  code *pcVar9;

  undefined4 **ppuVar10;

  undefined4 **ppuVar11;

  undefined4 uVar12;

  undefined4 **ppuVar13;

  undefined4 uVar14;

  undefined4 uVar15;

  undefined4 *puStack_28;

  undefined4 *puStack_24;

  undefined4 *puStack_20;

  undefined4 *puStack_1c;

  undefined4 *puStack_18;

  undefined4 *puStack_14;

  undefined1 auStack_10 [4];

  int iStack_c;

  int iStack_8;

  uint uStack_4;

  

  if (DAT_00870be4 == 0) {

    return 0;

  }

  FUN_0048c3e0(

              "(account) denotes a character whose account has also been squelched.\nFormat: Name : List of squelched message types.\n--------\n"

              );

  puVar2 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  puVar5 = DAT_008ef11c;

  puStack_28 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_0058a0d0(auStack_10);

  if (iStack_c == 0) {

    FUN_0048c3e0("none\n");

    puVar3 = puStack_28;

    if ((puStack_28[2] != 1) && (puStack_28 != DAT_008ef11c)) {

      FUN_004910c0(puStack_28 + 5,puStack_28[2] + -1);

    }

    pcVar9 = InterlockedDecrement_exref;

    LVar4 = InterlockedDecrement(puVar3 + 1);

    if (LVar4 == 0) {

      (**(code **)*puVar3)(1);

    }

  }

  else {

    FUN_0048c3e0(&DAT_00795508);

    puVar5 = puStack_20;

    if ((puStack_20[2] != 1) && (puStack_20 != DAT_008ef11c)) {

      FUN_004910c0(puStack_20 + 5,puStack_20[2] + -1);

    }

    pcVar9 = InterlockedDecrement_exref;

    LVar4 = InterlockedDecrement(puVar5 + 1);

    iVar8 = iStack_c;

    if (LVar4 == 0) {

      (**(code **)*puVar5)(1);

    }

    do {

      FUN_0058a8b0(iVar8 + 4,&puStack_28,0);

      uVar7 = FUN_0048c3e0(&DAT_00795508);

      ppuVar13 = &puStack_20;

      ppuVar11 = &puStack_28;

      ppuVar10 = &puStack_1c;

      FUN_0048c3e0(&DAT_00795338);

      FUN_004a2b90(ppuVar10,ppuVar11);

      puVar5 = (undefined4 *)FUN_004a2b90(ppuVar13,uVar7);

      puVar5 = (undefined4 *)*puVar5;

      if ((puVar5[2] != 1) && (puVar5 != DAT_008ef11c)) {

        FUN_004910c0(puVar5 + 5,puVar5[2] + -1);

      }

      puVar5 = puStack_20;

      LVar4 = InterlockedDecrement(puStack_20 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = puStack_1c;

      LVar4 = InterlockedDecrement(puStack_1c + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = puStack_18;

      LVar4 = InterlockedDecrement(puStack_18 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = puStack_14;

      LVar4 = InterlockedDecrement(puStack_14 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      iVar6 = *(int *)(iVar8 + 0x1c);

      if (iVar6 == 0) {

        uVar1 = *(uint *)(iVar8 + 0x20);

        do {

          uVar1 = uVar1 + 1;

          if (uStack_4 <= uVar1) {

            iVar6 = 0;

            goto LAB_0058b2f1;

          }

        } while (*(int *)(iStack_8 + uVar1 * 4) == 0);

        iVar6 = *(int *)(iStack_8 + uVar1 * 4);

      }

LAB_0058b2f1:

      puVar5 = puStack_28;

      iVar8 = iVar6;

    } while (iVar6 != 0);

  }

  if ((puVar2[2] != 1) && (puVar2 != DAT_008ef11c)) {

    FUN_004910c0(puVar2 + 5,puVar2[2] + -1);

  }

  uVar15 = 0;

  uVar14 = 1;

  uVar12 = 0;

  uVar7 = FUN_00404a40(0,puStack_24 + 5);

  FUN_00564d30(uVar7,uVar12,uVar14,uVar15);

  FUN_005649f0(uVar7,uVar12,uVar14,uVar15);

  iVar8 = (*pcVar9)(puStack_14 + -4);

  if ((iVar8 == 0) && (puStack_14 + -5 != (undefined4 *)0x0)) {

    (**(code **)puStack_14[-5])(1);

  }

  iVar8 = (*pcVar9)(puVar5 + 1);

  if ((iVar8 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  iVar8 = (*pcVar9)(unaff_EBP + 1);

  if (iVar8 == 0) {

    (**(code **)*unaff_EBP)(1);

  }

  iVar8 = (*pcVar9)(puStack_24 + 1);

  if ((iVar8 == 0) && (puStack_24 != (undefined4 *)0x0)) {

    (**(code **)*puStack_24)(1);

  }

  return 1;

}





// --- FUN_0058b102 at 0x0058B102 (size: 698) ---


undefined4

FUN_0058b102(undefined4 *param_1,undefined4 *param_2,undefined4 *param_3,undefined4 *param_4,

            undefined4 *param_5,undefined4 *param_6,undefined4 param_7,int param_8,int param_9,

            uint param_10)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 uVar7;

  int iVar8;

  undefined4 *unaff_EBP;

  code *pcVar9;

  undefined4 *puVar10;

  undefined4 *puVar11;

  undefined4 uVar12;

  undefined4 uVar13;

  undefined4 uVar14;

  

  FUN_0048c3e0(

              "(account) denotes a character whose account has also been squelched.\nFormat: Name : List of squelched message types.\n--------\n"

              );

  puVar3 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  puVar5 = DAT_008ef11c;

  param_1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_0058a0d0(&param_7);

  iVar8 = param_8;

  if (param_8 == 0) {

    FUN_0048c3e0("none\n");

    puVar11 = param_1;

    if ((param_1[2] != 1) && (param_1 != DAT_008ef11c)) {

      FUN_004910c0(param_1 + 5,param_1[2] + -1);

    }

    pcVar9 = InterlockedDecrement_exref;

    LVar4 = InterlockedDecrement(puVar11 + 1);

    if (LVar4 == 0) {

      (**(code **)*puVar11)(1);

    }

  }

  else {

    FUN_0048c3e0(&DAT_00795508);

    puVar5 = param_3;

    if ((param_3[2] != 1) && (param_3 != DAT_008ef11c)) {

      FUN_004910c0(param_3 + 5,param_3[2] + -1);

    }

    pcVar9 = InterlockedDecrement_exref;

    LVar4 = InterlockedDecrement(puVar5 + 1);

    iVar2 = param_9;

    if (LVar4 == 0) {

      (**(code **)*puVar5)(1);

      iVar2 = param_9;

    }

    do {

      FUN_0058a8b0(iVar8 + 4,&param_1,0);

      uVar7 = FUN_0048c3e0(&DAT_00795508);

      puVar5 = &param_3;

      puVar11 = &param_1;

      puVar10 = &param_4;

      FUN_0048c3e0(&DAT_00795338);

      FUN_004a2b90(puVar10,puVar11);

      puVar5 = (undefined4 *)FUN_004a2b90(puVar5,uVar7);

      puVar5 = (undefined4 *)*puVar5;

      if ((puVar5[2] != 1) && (puVar5 != DAT_008ef11c)) {

        FUN_004910c0(puVar5 + 5,puVar5[2] + -1);

      }

      puVar5 = param_3;

      LVar4 = InterlockedDecrement(param_3 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = param_4;

      LVar4 = InterlockedDecrement(param_4 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = param_5;

      LVar4 = InterlockedDecrement(param_5 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      puVar5 = param_6;

      LVar4 = InterlockedDecrement(param_6 + 1);

      if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      iVar6 = *(int *)(iVar8 + 0x1c);

      if (iVar6 == 0) {

        uVar1 = *(uint *)(iVar8 + 0x20);

        do {

          uVar1 = uVar1 + 1;

          if (param_10 <= uVar1) {

            iVar6 = 0;

            goto LAB_0058b2f1;

          }

        } while (*(int *)(iVar2 + uVar1 * 4) == 0);

        iVar6 = *(int *)(iVar2 + uVar1 * 4);

      }

LAB_0058b2f1:

      puVar5 = param_1;

      iVar8 = iVar6;

    } while (iVar6 != 0);

  }

  if ((puVar3[2] != 1) && (puVar3 != DAT_008ef11c)) {

    FUN_004910c0(puVar3 + 5,puVar3[2] + -1);

  }

  puVar3 = param_2;

  uVar14 = 0;

  uVar13 = 1;

  uVar12 = 0;

  uVar7 = FUN_00404a40(0,param_2 + 5);

  FUN_00564d30(uVar7,uVar12,uVar13,uVar14);

  FUN_005649f0(uVar7,uVar12,uVar13,uVar14);

  puVar11 = param_6 + -5;

  iVar8 = (*pcVar9)(param_6 + -4);

  if ((iVar8 == 0) && (puVar11 != (undefined4 *)0x0)) {

    (**(code **)*puVar11)(1);

  }

  iVar8 = (*pcVar9)(puVar5 + 1);

  if ((iVar8 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  iVar8 = (*pcVar9)(unaff_EBP + 1);

  if (iVar8 == 0) {

    (**(code **)*unaff_EBP)(1);

  }

  iVar8 = (*pcVar9)(puVar3 + 1);

  if ((iVar8 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return 1;

}





// --- FUN_0058b6b0 at 0x0058B6B0 (size: 35) ---


undefined4 FUN_0058b6b0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x98);

  if (iVar1 != 0) {

    uVar2 = FUN_005cc420(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b6e0 at 0x0058B6E0 (size: 32) ---


undefined4 FUN_0058b6e0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_005ccaa0(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b730 at 0x0058B730 (size: 32) ---


undefined4 FUN_0058b730(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_005bd840(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b750 at 0x0058B750 (size: 32) ---


undefined4 FUN_0058b750(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x68);

  if (iVar1 != 0) {

    uVar2 = FUN_005caff0(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b790 at 0x0058B790 (size: 32) ---


undefined4 FUN_0058b790(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x68);

  if (iVar1 != 0) {

    uVar2 = FUN_005cce30(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b7b0 at 0x0058B7B0 (size: 32) ---


undefined4 FUN_0058b7b0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x40);

  if (iVar1 != 0) {

    uVar2 = FUN_005cb640(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b7d0 at 0x0058B7D0 (size: 32) ---


undefined4 FUN_0058b7d0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_0059af30(DAT_00871c80);

    return uVar2;

  }

  return 0;

}





// --- FUN_0058b7f0 at 0x0058B7F0 (size: 35) ---


undefined4 * __fastcall FUN_0058b7f0(undefined4 *param_1)



{

  FUN_004fcf90();

  *param_1 = &PTR_LAB_007e4300;

  param_1[1] = &PTR_LAB_007e4258;

  param_1[0x4c] = &PTR_LAB_007e4244;

  return param_1;

}





// --- FUN_0058b830 at 0x0058B830 (size: 53) ---


undefined4 * __thiscall FUN_0058b830(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_LAB_007e4300;

  param_1[1] = &PTR_LAB_007e4258;

  param_1[0x4c] = &PTR_LAB_007e4244;

  FUN_004fc9d0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058bcf0 at 0x0058BCF0 (size: 64) ---


undefined4 * __thiscall FUN_0058bcf0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e43cc;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058bd40 at 0x0058BD40 (size: 63) ---


undefined4 * __thiscall FUN_0058bd40(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e43d0;

  FUN_0054ebc0();

  if ((param_1[4] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)param_1[3]);

  }

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058bd90 at 0x0058BD90 (size: 43) ---


void __fastcall FUN_0058bd90(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e43d0;

  FUN_0054ebc0();

  if ((param_1[4] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)param_1[3]);

  }

  return;

}





// --- FUN_0058bdc0 at 0x0058BDC0 (size: 143) ---


undefined4 * __thiscall FUN_0058bdc0(undefined4 *param_1,undefined4 param_2)



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007e43cc;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

    puVar6 = (undefined4 *)((int)puVar6 + 1);

  }

  return param_1;

}





// --- FUN_0058be50 at 0x0058BE50 (size: 58) ---


void __fastcall FUN_0058be50(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e4418;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007e43cc;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  return;

}





// --- FUN_0058be90 at 0x0058BE90 (size: 82) ---


undefined4 * __thiscall FUN_0058be90(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e4418;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007e43cc;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058bef0 at 0x0058BEF0 (size: 51) ---


undefined4 * __thiscall FUN_0058bef0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e4420;

  FUN_0059fe00();

  FUN_0058be50();

  FUN_0058bd90();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058bf30 at 0x0058BF30 (size: 85) ---


undefined4 * FUN_0058bf30(void)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x9c);

  puVar2 = (undefined4 *)0x0;

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = &PTR_FUN_007e43d0;

    puVar1[1] = 1;

    puVar1[3] = 0;

    puVar1[4] = 0;

    puVar1[5] = 0;

    FUN_0054ebb0();

    *puVar1 = &PTR_FUN_007e4420;

    puVar1[8] = &PTR_FUN_007e4418;

    FUN_0058bdc0(0x17);

    FUN_0059fbe0();

    puVar2 = puVar1;

  }

  return puVar2;

}





// --- FUN_0058bf90 at 0x0058BF90 (size: 32) ---


void FUN_0058bf90(void)



{

  int iVar1;

  

  iVar1 = FUN_0056b210();

  if (iVar1 != 0) {

    FUN_0056b210();

    FUN_0056bbd0();

  }

  FUN_006b4210();

  return;

}





// --- FUN_0058bfd0 at 0x0058BFD0 (size: 23) ---


void FUN_0058bfd0(void)



{

  FUN_0056b210();

  FUN_0056bcd0();

  FUN_00695670();

  return;

}





// --- FUN_0058c000 at 0x0058C000 (size: 27) ---


void FUN_0058c000(void)



{

  int iVar1;

  

  iVar1 = FUN_0056b210();

  if (iVar1 != 0) {

    FUN_0056b6f0();

  }

  FUN_00695670();

  return;

}





// --- FUN_0058c020 at 0x0058C020 (size: 32) ---


void FUN_0058c020(void)



{

  int iVar1;

  

  iVar1 = FUN_0056b210();

  if (iVar1 != 0) {

    FUN_0056b210();

    FUN_0056bbd0();

  }

  FUN_006b4ca0();

  return;

}





// --- FUN_0058c140 at 0x0058C140 (size: 95) ---


void __thiscall FUN_0058c140(int param_1,undefined4 param_2,byte param_3)



{

  uint local_10c [64];

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (*(int *)(param_1 + 8) != 0) {

    local_10c[0] = (uint)param_3;

    local_8 = 0;

    local_4 = param_2;

    local_c = 4;

    (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x98))(local_10c);

  }

  return;

}





// --- FUN_0058c1a0 at 0x0058C1A0 (size: 106) ---


undefined4 __thiscall FUN_0058c1a0(int *param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  

  iVar2 = (**(code **)(*param_1 + 0x90))();

  if (iVar2 == 0) {

    return 1;

  }

  switch(*param_2) {

  case 0x29:

    FUN_0058c140(0x45000005,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x2a:

    FUN_0058c140(0x45000006,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x2b:

    FUN_0058c140(0x41000003,1);

    return 1;

  case 0x2c:

    FUN_0058c140(0x6500000f,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x2d:

    FUN_0058c140(0x65000010,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x2e:

    FUN_0058c140(0x6500000d,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x2f:

    FUN_0058c140(0x6500000e,*(undefined1 *)(param_2 + 8));

    return 1;

  case 0x30:

    FUN_0058c140(0x90000c7,1);

    return 1;

  case 0x31:

    break;

  case 0x32:

    (**(code **)(*param_1 + 0x20))(*(undefined1 *)(param_2 + 8));

    return 1;

  default:

    cVar1 = FUN_004636c0(param_2);

    if (cVar1 != '\0') {

      puVar3 = (undefined4 *)FUN_00477380(param_2);

      if (puVar3 != (undefined4 *)0x0) {

        FUN_0058c140(*puVar3,1);

        return 1;

      }

    }

    return 0;

  }

  if (*(char *)(param_2 + 8) == '\0') {

    (**(code **)(*param_1 + 0x44))(1);

    return 1;

  }

  (**(code **)(*param_1 + 0x40))();

  return 1;

}





// --- FUN_0058c340 at 0x0058C340 (size: 1556) ---


void FUN_0058c340(void)



{

  FUN_006891f0(&DAT_007e462c,&DAT_007e44a8);

  FUN_006891f0(&DAT_007e4630,&DAT_007e44ac);

  FUN_006891f0(&DAT_007e4634,&DAT_007e44b0);

  FUN_006891f0(&DAT_007e4638,&DAT_007e44b4);

  FUN_006891f0(&DAT_007e4718,&DAT_007e4554);

  FUN_006891f0(&DAT_007e46f8,&DAT_007e4558);

  FUN_006891f0(&DAT_007e4660,&DAT_007e455c);

  FUN_006891f0(&DAT_007e466c,&DAT_007e4560);

  FUN_006891f0(&DAT_007e4674,&DAT_007e4564);

  FUN_006891f0(&DAT_007e4724,&DAT_007e4568);

  FUN_006891f0(&DAT_007e46d4,&DAT_007e456c);

  FUN_006891f0(&DAT_007e4774,&DAT_007e4570);

  FUN_006891f0(&DAT_007e4648,&DAT_007e4574);

  FUN_006891f0(&DAT_007e4704,&DAT_007e4578);

  FUN_006891f0(&DAT_007e4710,&DAT_007e457c);

  FUN_006891f0(&DAT_007e4760,&DAT_007e4580);

  FUN_006891f0(&DAT_007e46a8,&DAT_007e4584);

  FUN_006891f0(&DAT_007e469c,&DAT_007e4588);

  FUN_006891f0(&DAT_007e46cc,&DAT_007e458c);

  FUN_006891f0(&DAT_007e4644,&DAT_007e4590);

  FUN_006891f0(&DAT_007e4740,&DAT_007e4594);

  FUN_006891f0(&DAT_007e4754,&DAT_007e4598);

  FUN_006891f0(&DAT_007e478c,&DAT_007e459c);

  FUN_006891f0(&DAT_007e4784,&DAT_007e45a0);

  FUN_006891f0(&DAT_007e4748,&DAT_007e45a4);

  FUN_006891f0(&DAT_007e467c,&DAT_007e45ac);

  FUN_006891f0(&DAT_007e463c,&DAT_007e45b0);

  FUN_006891f0(&DAT_007e46ac,&DAT_007e45b4);

  FUN_006891f0(&DAT_007e4730,&DAT_007e45bc);

  FUN_006891f0(&DAT_007e4738,&DAT_007e45c0);

  FUN_006891f0(&DAT_007e4734,&DAT_007e45c4);

  FUN_006891f0(&DAT_007e46e4,&DAT_007e45c8);

  FUN_006891f0(&DAT_007e46ec,&DAT_007e45cc);

  FUN_006891f0(&DAT_007e4758,&DAT_007e45d0);

  FUN_006891f0(&DAT_007e46dc,&DAT_007e45d4);

  FUN_006891f0(&DAT_007e4684,&DAT_007e45d8);

  FUN_006891f0(&DAT_007e46f0,&DAT_007e45dc);

  FUN_006891f0(&DAT_007e46fc,&DAT_007e45e0);

  FUN_006891f0(&DAT_007e4768,&DAT_007e45e4);

  FUN_006891f0(&DAT_007e468c,&DAT_007e45e8);

  FUN_006891f0(&DAT_007e464c,&DAT_007e45ec);

  FUN_006891f0(&DAT_007e4664,&DAT_007e44b8);

  FUN_006891f0(&DAT_007e4678,&DAT_007e44d4);

  FUN_006891f0(&DAT_007e4714,&DAT_007e44bc);

  FUN_006891f0(&DAT_007e4650,&DAT_007e44c0);

  FUN_006891f0(&DAT_007e4654,&DAT_007e44c4);

  FUN_006891f0(&DAT_007e4658,&DAT_007e44c8);

  FUN_006891f0(&DAT_007e465c,&DAT_007e44cc);

  FUN_006891f0(&DAT_007e4668,&DAT_007e44d0);

  FUN_006891f0(&DAT_007e46a4,&DAT_007e44d8);

  FUN_006891f0(&DAT_007e46b4,&DAT_007e44dc);

  FUN_006891f0(&DAT_007e46b0,&DAT_007e44e0);

  FUN_006891f0(&DAT_007e46bc,&DAT_007e44e4);

  FUN_006891f0(&DAT_007e46d0,&DAT_007e44e8);

  FUN_006891f0(&DAT_007e471c,&DAT_007e44ec);

  FUN_006891f0(&DAT_007e472c,&DAT_007e44f0);

  FUN_006891f0(&DAT_007e4770,&DAT_007e44f4);

  FUN_006891f0(&DAT_007e4640,&DAT_007e44f8);

  FUN_006891f0(&DAT_007e4690,&DAT_007e44fc);

  FUN_006891f0(&DAT_007e4700,&DAT_007e4500);

  FUN_006891f0(&DAT_007e470c,&DAT_007e4504);

  FUN_006891f0(&DAT_007e4744,&DAT_007e4508);

  FUN_006891f0(&DAT_007e475c,&DAT_007e450c);

  FUN_006891f0(&DAT_007e477c,&DAT_007e4510);

  FUN_006891f0(&DAT_007e4778,&DAT_007e4514);

  FUN_006891f0(&DAT_007e4790,&DAT_007e4518);

  FUN_006891f0(&DAT_007e4670,&DAT_007e451c);

  FUN_006891f0(&DAT_007e4698,&DAT_007e4520);

  FUN_006891f0(&DAT_007e46c8,&DAT_007e4524);

  FUN_006891f0(&DAT_007e4720,&DAT_007e4528);

  FUN_006891f0(&DAT_007e4728,&DAT_007e452c);

  FUN_006891f0(&DAT_007e473c,&DAT_007e4530);

  FUN_006891f0(&DAT_007e474c,&DAT_007e4534);

  FUN_006891f0(&DAT_007e4750,&DAT_007e4538);

  FUN_006891f0(&DAT_007e4788,&DAT_007e453c);

  FUN_006891f0(&DAT_007e4780,&DAT_007e4540);

  FUN_006891f0(&DAT_007e4794,&DAT_007e4544);

  FUN_006891f0(&DAT_007e46f4,&DAT_007e4548);

  FUN_006891f0(&DAT_007e46b8,&DAT_007e454c);

  FUN_006891f0(&DAT_007e4764,&DAT_007e4550);

  FUN_006891f0(&DAT_007e476c,&DAT_007e45a8);

  FUN_006891f0(&DAT_007e46c0,&DAT_007e45f0);

  FUN_006891f0(&DAT_007e46c4,&DAT_007e45f4);

  FUN_006891f0(&DAT_007e46e0,&DAT_007e45f8);

  FUN_006891f0(&DAT_007e46e8,&DAT_007e45fc);

  FUN_006891f0(&DAT_007e46d8,&DAT_007e4600);

  FUN_006891f0(&DAT_007e46a0,&DAT_007e4604);

  FUN_006891f0(&DAT_007e4708,&DAT_007e4608);

  FUN_006891f0(&DAT_007e4680,&DAT_007e460c);

  FUN_006891f0(&DAT_007e4688,&DAT_007e4610);

  FUN_006891f0(&DAT_007e4694,&DAT_007e45b8);

  return;

}





// --- FUN_0058c960 at 0x0058C960 (size: 93) ---


undefined4 * __fastcall FUN_0058c960(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  FUN_006b4d80();

  puVar1 = param_1 + 0x32;

  *puVar1 = &PTR_FUN_007ccb60;

  *param_1 = &PTR_FUN_007e4bd0;

  *puVar1 = &PTR_FUN_007e4928;

  param_1[0x33] = &PTR_FUN_0079da04;

  FUN_0046c1f0(0x80);

  FUN_0058c340();

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 4))(0x4dd21f,puVar1);

  }

  return param_1;

}





// --- FUN_0058ca10 at 0x0058CA10 (size: 150) ---


void __fastcall FUN_0058ca10(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x32;

  *param_1 = &PTR_FUN_007e4bd0;

  *puVar1 = &PTR_FUN_007e4928;

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

  param_1[0x33] = &PTR_FUN_0079da04;

  FUN_005870f0();

  param_1[0x34] = &PTR_FUN_0079da00;

  if ((undefined4 *)param_1[0x4c] != param_1 + 0x35) {

    operator_delete__((undefined4 *)param_1[0x4c]);

  }

  param_1[0x4c] = 0;

  param_1[0x4d] = 0;

  param_1[0x4e] = 0;

  param_1[0x4f] = 0;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  param_1[0x1a] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_00795824;

  if (DAT_00837ff4 != (int *)0x0) {

    (**(code **)(*DAT_00837ff4 + 0x3c))(param_1);

  }

  return;

}





// --- FUN_0058cab0 at 0x0058CAB0 (size: 30) ---


void * __thiscall FUN_0058cab0(void *param_1,byte param_2)



{

  FUN_0058ca10();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058cad0 at 0x0058CAD0 (size: 38) ---


void __thiscall FUN_0058cad0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 1;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xfffffffe;

  return;

}





// --- FUN_0058cb00 at 0x0058CB00 (size: 38) ---


void __thiscall FUN_0058cb00(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 4;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xfffffffb;

  return;

}





// --- FUN_0058cb30 at 0x0058CB30 (size: 38) ---


void __thiscall FUN_0058cb30(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 2;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xfffffffd;

  return;

}





// --- FUN_0058cb60 at 0x0058CB60 (size: 38) ---


void __thiscall FUN_0058cb60(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 0x40;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xffffffbf;

  return;

}





// --- FUN_0058cb90 at 0x0058CB90 (size: 42) ---


void __thiscall FUN_0058cb90(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 0x80;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xffffff7f;

  return;

}





// --- FUN_0058cbc0 at 0x0058CBC0 (size: 42) ---


void __thiscall FUN_0058cbc0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) | 0x400000;

    return;

  }

  *(uint *)(param_1 + 0x100) = *(uint *)(param_1 + 0x100) & 0xffbfffff;

  return;

}





// --- FUN_0058cbf0 at 0x0058CBF0 (size: 70) ---


void __fastcall FUN_0058cbf0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int **)(param_1 + 0x14c) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0x14c) + 0x14))();

    *(undefined4 *)(param_1 + 0x14c) = 0;

  }

  iVar1 = FUN_005df0f5(0x90);

  if (iVar1 != 0) {

    uVar2 = FUN_00594620();

    *(undefined4 *)(param_1 + 0x14c) = uVar2;

    return;

  }

  *(undefined4 *)(param_1 + 0x14c) = 0;

  return;

}





// --- FUN_0058cc70 at 0x0058CC70 (size: 37) ---


void __fastcall FUN_0058cc70(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    FUN_005aedd0();

    return;

  }

  return;

}





// --- FUN_0058cca0 at 0x0058CCA0 (size: 50) ---


void __fastcall FUN_0058cca0(int param_1)



{

  if (*(int *)(param_1 + 100) != 0) {

    *(undefined4 *)(param_1 + 0x68) = 3;

    return;

  }

  if (*(int *)(param_1 + 0xb4) != 0) {

    *(undefined4 *)(param_1 + 0x68) = 2;

    return;

  }

  *(uint *)(param_1 + 0x68) = (uint)(*(int *)(param_1 + 0xc4) != 0);

  return;

}





// --- FUN_0058cce0 at 0x0058CCE0 (size: 14) ---


undefined4 __fastcall FUN_0058cce0(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    return *(undefined4 *)(*(int *)(param_1 + 0x50) + 0x1c);

  }

  return 0;

}





// --- FUN_0058ccf0 at 0x0058CCF0 (size: 14) ---


undefined4 __fastcall FUN_0058ccf0(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    return *(undefined4 *)(*(int *)(param_1 + 0x50) + 0x34);

  }

  return 0;

}





// --- FUN_0058cd00 at 0x0058CD00 (size: 32) ---


int __fastcall FUN_0058cd00(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(param_1 + 200);

  if (iVar1 == -1) {

    return -1;

  }

  if (*(int *)(param_1 + 0x50) != 0) {

    return iVar1 - *(int *)(*(int *)(param_1 + 0x50) + 0x1c);

  }

  return iVar1;

}





// --- FUN_0058cd20 at 0x0058CD20 (size: 14) ---


int __fastcall FUN_0058cd20(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    return *(int *)(param_1 + 0x50) + 0xc;

  }

  return 0;

}





// --- FUN_0058cd30 at 0x0058CD30 (size: 14) ---


int __fastcall FUN_0058cd30(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    return *(int *)(param_1 + 0x50) + 0x24;

  }

  return 0;

}





// --- FUN_0058cd40 at 0x0058CD40 (size: 215) ---


undefined4 __thiscall FUN_0058cd40(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  undefined1 local_18 [24];

  

  FUN_005aedb0();

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0xc)) && (iVar4 = 0, 0 < *(int *)(iVar1 + 0x1c))) {

    do {

      uVar2 = FUN_005aeef0(iVar4);

      FUN_005aec00(uVar2);

      iVar4 = iVar4 + 1;

    } while (iVar4 < *(int *)(iVar1 + 0x1c));

  }

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0x24)) && (iVar4 = 0, 0 < *(int *)(iVar1 + 0x34))) {

    do {

      uVar2 = FUN_005aeef0(iVar4);

      iVar3 = FUN_005583f0(uVar2);

      if (((iVar3 != 0) && (iVar3 = *(int *)(iVar3 + 0x50), iVar3 != 0)) &&

         ((iVar3 != -0xc && (iVar5 = 0, 0 < *(int *)(iVar3 + 0x1c))))) {

        do {

          uVar2 = FUN_005aeef0(iVar5);

          FUN_005aec00(uVar2);

          iVar5 = iVar5 + 1;

        } while (iVar5 < *(int *)(iVar3 + 0x1c));

      }

      iVar4 = iVar4 + 1;

    } while (iVar4 < *(int *)(iVar1 + 0x34));

  }

  FUN_005af210(local_18);

  FUN_005af120();

  return param_2;

}





// --- FUN_0058ce20 at 0x0058CE20 (size: 14) ---


int __fastcall FUN_0058ce20(int param_1)



{

  if (*(int *)(param_1 + 0x50) != 0) {

    return *(int *)(param_1 + 0x50) + 0x3c;

  }

  return 0;

}





// --- FUN_0058ce30 at 0x0058CE30 (size: 140) ---


undefined4 __fastcall FUN_0058ce30(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  uint uVar4;

  

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0x24)) && (uVar4 = 0, *(int *)(iVar1 + 0x34) != 0)) {

    do {

      uVar2 = FUN_005aeef0(uVar4);

      iVar3 = FUN_005583f0(uVar2);

      if (iVar3 == 0) {

        return 0;

      }

      iVar3 = FUN_0058ce30();

      if (iVar3 == 0) {

        return 0;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(iVar1 + 0x34));

  }

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0xc)) && (uVar4 = 0, *(int *)(iVar1 + 0x1c) != 0)) {

    do {

      uVar2 = FUN_005aeef0(uVar4);

      iVar3 = FUN_005583f0(uVar2);

      if (iVar3 == 0) {

        return 0;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(iVar1 + 0x1c));

  }

  return 1;

}





// --- FUN_0058cec0 at 0x0058CEC0 (size: 20) ---


undefined4 __fastcall FUN_0058cec0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x50) != 0) {

    uVar1 = FUN_005aec50();

    return uVar1;

  }

  return 0;

}





// --- FUN_0058cee0 at 0x0058CEE0 (size: 20) ---


undefined4 __fastcall FUN_0058cee0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x50) != 0) {

    uVar1 = FUN_005aec50();

    return uVar1;

  }

  return 0;

}





// --- FUN_0058cf00 at 0x0058CF00 (size: 36) ---


void __thiscall FUN_0058cf00(int param_1,int param_2)



{

  if ((param_2 != *(int *)(param_1 + 0x70)) &&

     (*(int *)(param_1 + 0x70) = param_2, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  return;

}





// --- FUN_0058cf30 at 0x0058CF30 (size: 56) ---


void __thiscall FUN_0058cf30(int param_1,int param_2,char param_3)



{

  if ((param_2 != *(int *)(param_1 + 0x7c)) || (param_3 != *(char *)(param_1 + 0x80))) {

    *(int *)(param_1 + 0x7c) = param_2;

    *(char *)(param_1 + 0x80) = param_3;

    if (*(int *)(param_1 + 0x54) != 0) {

      thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

    }

  }

  return;

}





// --- FUN_0058cf70 at 0x0058CF70 (size: 36) ---


void __thiscall FUN_0058cf70(int param_1,int param_2)



{

  if ((param_2 != *(int *)(param_1 + 0x78)) &&

     (*(int *)(param_1 + 0x78) = param_2, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  return;

}





// --- FUN_0058cfa0 at 0x0058CFA0 (size: 36) ---


void __thiscall FUN_0058cfa0(int param_1,int param_2)



{

  if ((param_2 != *(int *)(param_1 + 0x74)) &&

     (*(int *)(param_1 + 0x74) = param_2, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  return;

}





// --- FUN_0058cfd0 at 0x0058CFD0 (size: 117) ---


undefined4

FUN_0058cfd0(undefined4 param_1,undefined4 param_2,double param_3,undefined1 param_4,char param_5)



{

  int iVar1;

  int iVar2;

  float10 fVar3;

  

  iVar1 = FUN_00508890(param_1);

  iVar2 = FUN_00508890(param_2);

  if ((iVar1 != 0) && (iVar2 != 0)) {

    if (param_5 == '\0') {

      fVar3 = (float10)FUN_00510270(iVar2,param_4);

      if (fVar3 < (float10)param_3 != (fVar3 == (float10)param_3)) {

        return 1;

      }

    }

    else {

      fVar3 = (float10)FUN_005aa5a0(iVar2 + 0x48);

      if (fVar3 < (float10)param_3 != (fVar3 == (float10)param_3)) {

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_0058d050 at 0x0058D050 (size: 42) ---


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



void FUN_0058d050(undefined4 param_1,undefined4 param_2)



{

  DAT_00871ed4 = param_1;

  DAT_00871ed0 = param_2;

  _DAT_00871ed8 = DAT_008379a8;

  _DAT_00871edc = DAT_008379ac;

  return;

}





// --- FUN_0058d080 at 0x0058D080 (size: 44) ---


undefined4 __fastcall FUN_0058d080(int param_1)



{

  int iVar1;

  

  if ((*(int *)(param_1 + 0x94) != 0) &&

     (((iVar1 = *(int *)(param_1 + 0x108), iVar1 == 2 || (iVar1 == 4)) || (iVar1 == 3)))) {

    return 1;

  }

  return 0;

}





// --- FUN_0058d0b0 at 0x0058D0B0 (size: 27) ---


void __thiscall FUN_0058d0b0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xf0) = param_2;

  thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  return;

}





// --- FUN_0058d0d0 at 0x0058D0D0 (size: 27) ---


void __thiscall FUN_0058d0d0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xf4) = param_2;

  thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  return;

}





// --- FUN_0058d0f0 at 0x0058D0F0 (size: 27) ---


void __thiscall FUN_0058d0f0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xf8) = param_2;

  thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  return;

}





// --- FUN_0058d110 at 0x0058D110 (size: 150) ---


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



void FUN_0058d110(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  iVar1 = DAT_00871e54;

  if ((param_2 != 0) || (DAT_00871e54 != param_1)) {

    if (DAT_00871e54 != 0) {

      iVar2 = FUN_005583f0(DAT_00871e54);

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 0x6c) = 0;

      }

    }

    DAT_00871e54 = param_1;

    if (param_1 != 0) {

      iVar2 = FUN_005583f0(param_1);

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 0x6c) = 1;

      }

    }

    if (iVar1 != param_1) {

      DAT_00871e58 = iVar1;

      if (iVar1 != 0) {

        _DAT_00871e5c = iVar1;

      }

      FUN_0047a350();

    }

    thunk_FUN_00693910(iVar1,DAT_00871e54);

    iVar2 = FUN_0055b0a0();

    if (iVar2 != 0) {

      piVar3 = (int *)FUN_0055a740();

      (**(code **)(*piVar3 + 0x28))(piVar3,iVar1,DAT_00871e54);

    }

  }

  return;

}





// --- FUN_0058d1b0 at 0x0058D1B0 (size: 10) ---


void FUN_0058d1b0(undefined4 param_1)



{

  DAT_00871e58 = param_1;

  return;

}





// --- FUN_0058d1c0 at 0x0058D1C0 (size: 10) ---


void FUN_0058d1c0(undefined4 param_1)



{

  DAT_00871e54 = param_1;

  return;

}





// --- FUN_0058d230 at 0x0058D230 (size: 51) ---


bool __thiscall FUN_0058d230(int *param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 0x14))();

  if ((iVar1 != 0) && (param_1[0x53] != 0)) {

    iVar1 = (**(code **)(*(int *)(param_1[0x53] + 0x38) + 0x1c))(param_2);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_0058d270 at 0x0058D270 (size: 56) ---


bool __thiscall FUN_0058d270(int *param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 0x14))();

  if ((iVar1 != 0) && (param_1[0x53] != 0)) {

    iVar1 = (**(code **)(*(int *)(param_1[0x53] + 0x38) + 0x20))(param_2,param_3);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_0058d350 at 0x0058D350 (size: 56) ---


bool __thiscall FUN_0058d350(int *param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 0x14))();

  if ((iVar1 != 0) && (param_1[0x53] != 0)) {

    iVar1 = (**(code **)(*(int *)(param_1[0x53] + 0x38) + 0x18))(param_2,param_3);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_0058d390 at 0x0058D390 (size: 51) ---


bool __thiscall FUN_0058d390(int *param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 0x14))();

  if ((iVar1 != 0) && (param_1[0x53] != 0)) {

    iVar1 = (**(code **)(*(int *)(param_1[0x53] + 0x38) + 0x10))(param_2);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_0058d3d0 at 0x0058D3D0 (size: 51) ---


bool __thiscall FUN_0058d3d0(int *param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = (**(code **)(*param_1 + 0x14))();

  if ((iVar1 != 0) && (param_1[0x53] != 0)) {

    iVar1 = (**(code **)(*(int *)(param_1[0x53] + 0x38) + 0x14))(param_2);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_0058d410 at 0x0058D410 (size: 80) ---


bool __fastcall FUN_0058d410(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x148) != 0) {

    return true;

  }

  iVar1 = FUN_005df0f5(0x80);

  if (iVar1 != 0) {

    iVar1 = FUN_005be470();

    *(int *)(param_1 + 0x148) = iVar1;

    return iVar1 != 0;

  }

  *(undefined4 *)(param_1 + 0x148) = 0;

  return false;

}





// --- FUN_0058d460 at 0x0058D460 (size: 43) ---


bool __thiscall FUN_0058d460(int param_1,int param_2)



{

  if ((param_2 != 0) && (*(int *)(param_1 + 0x128) != 0)) {

    return *(int *)(param_1 + 0x128) == *(int *)(param_2 + 0x128);

  }

  return false;

}





// --- FUN_0058d4b0 at 0x0058D4B0 (size: 109) ---


void FUN_0058d4b0(undefined4 param_1,int param_2)



{

  switch(param_1) {

  case 1:

    FUN_0058cb00(param_2);

    return;

  case 3:

    FUN_0058cad0(param_2 == 0);

    return;

  case 0x16:

    FUN_0058cb30(param_2);

    return;

  case 0x18:

    FUN_0058cb90(param_2);

    return;

  case 0x19:

    FUN_0058cbc0(param_2);

    break;

  case 0x1a:

    FUN_0058cb60(param_2);

    return;

  }

  return;

}





// --- FUN_0058d570 at 0x0058D570 (size: 71) ---


undefined4 * __thiscall FUN_0058d570(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e4ed8;

  param_1[3] = &PTR_LAB_007e4ec4;

  FUN_005b0ff0();

  FUN_0043c850();

  param_1[1] = 0;

  param_1[2] = 0;

  *param_1 = &PTR_LAB_007c78e0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058d760 at 0x0058D760 (size: 106) ---


void __fastcall FUN_0058d760(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e4f70;

  param_1[3] = &PTR_LAB_007e4f58;

  if (param_1[0x53] != 0) {

    FUN_00594710();

    (**(code **)(*(int *)param_1[0x53] + 0x14))();

  }

  FUN_005ada90();

  *param_1 = &PTR_FUN_007e4ed8;

  param_1[3] = &PTR_LAB_007e4ec4;

  FUN_005b0ff0();

  FUN_0043c850();

  *param_1 = &PTR_LAB_007c78e0;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_0058d7d0 at 0x0058D7D0 (size: 115) ---


void __fastcall FUN_0058d7d0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0x24)) && (iVar3 = 0, 0 < *(int *)(iVar1 + 0x34))) {

    do {

      uVar2 = FUN_005aeef0(iVar3);

      FUN_00509a40(uVar2);

      iVar3 = iVar3 + 1;

    } while (iVar3 < *(int *)(iVar1 + 0x34));

  }

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0xc)) && (iVar3 = 0, 0 < *(int *)(iVar1 + 0x1c))) {

    do {

      uVar2 = FUN_005aeef0(iVar3);

      FUN_00509a40(uVar2);

      iVar3 = iVar3 + 1;

    } while (iVar3 < *(int *)(iVar1 + 0x1c));

  }

  return;

}





// --- FUN_0058d850 at 0x0058D850 (size: 144) ---


void __fastcall FUN_0058d850(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0x24)) && (iVar4 = 0, 0 < *(int *)(iVar1 + 0x34))) {

    do {

      uVar2 = FUN_005aeef0(iVar4);

      FUN_00508f10(uVar2);

      iVar3 = FUN_005583f0(uVar2);

      if (iVar3 != 0) {

        FUN_0058d850();

      }

      iVar4 = iVar4 + 1;

    } while (iVar4 < *(int *)(iVar1 + 0x34));

  }

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0xc)) && (iVar4 = 0, 0 < *(int *)(iVar1 + 0x1c))) {

    do {

      uVar2 = FUN_005aeef0(iVar4);

      FUN_00508f10(uVar2);

      iVar4 = iVar4 + 1;

    } while (iVar4 < *(int *)(iVar1 + 0x1c));

  }

  return;

}





// --- FUN_0058d8e0 at 0x0058D8E0 (size: 35) ---


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



void FUN_0058d8e0(int param_1)



{

  if (param_1 == DAT_00871ed4) {

    DAT_00871ed4 = 0;

    DAT_00871ed0 = 0;

    _DAT_00871ed8 = 0;

    _DAT_00871edc = 0;

  }

  return;

}





// --- FUN_0058d910 at 0x0058D910 (size: 105) ---


undefined4 __thiscall FUN_0058d910(int *param_1,int param_2)



{

  undefined4 uVar1;

  

  *(int *)(param_2 + 0x10) = param_1[0x29];

  uVar1 = (**(code **)(*param_1 + 0x18))();

  *(undefined4 *)(param_2 + 0x14) = uVar1;

  uVar1 = (**(code **)(*param_1 + 0x2c))();

  FUN_0051c470(uVar1);

  uVar1 = (**(code **)(*param_1 + 0x10))();

  FUN_0051c490(uVar1);

  FUN_0051c4d0((uint)param_1[0x40] >> 4 & 1);

  FUN_0051c4b0((uint)param_1[0x40] >> 0xc & 1);

  return 1;

}





// --- FUN_0058d980 at 0x0058D980 (size: 36) ---


void FUN_0058d980(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0058d410();

  if (iVar1 == 0) {

    return;

  }

  FUN_006b3860(param_1);

  return;

}





// --- FUN_0058d9b0 at 0x0058D9B0 (size: 88) ---


undefined4 __thiscall FUN_0058d9b0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  

  iVar1 = *(int *)(param_1 + 0x50);

  if (((iVar1 != 0) && (iVar1 != -0x24)) && (0 < *(int *)(iVar1 + 0x34))) {

    iVar4 = 0;

    do {

      uVar2 = FUN_005aeef0(iVar4);

      iVar3 = FUN_005583f0(uVar2);

      if ((iVar3 != 0) && (*(int *)(iVar3 + 0xa4) == param_2)) {

        return 1;

      }

      iVar4 = iVar4 + 1;

    } while (iVar4 < *(int *)(iVar1 + 0x34));

  }

  return 0;

}





// --- FUN_0058da50 at 0x0058DA50 (size: 30) ---


void * __thiscall FUN_0058da50(void *param_1,byte param_2)



{

  FUN_0058d760();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058da70 at 0x0058DA70 (size: 155) ---


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



void __thiscall FUN_0058da70(int param_1,undefined4 param_2,undefined4 param_3)



{

  *(undefined4 *)(param_1 + 0xf8) = param_2;

  thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  *(undefined4 *)(param_1 + 0xd4) = param_3;

  if ((*(int *)(param_1 + 0x70) != 0) &&

     (*(undefined4 *)(param_1 + 0x70) = 0, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  if (*(int *)(param_1 + 8) == DAT_00871ed4) {

    DAT_00871ed4 = 0;

    DAT_00871ed0 = 0;

    _DAT_00871ed8 = 0;

    _DAT_00871edc = 0;

  }

  if (*(int *)(param_1 + 0x5c) != 0) {

    *(undefined4 *)(param_1 + 0x60) = 1;

  }

  thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  return;

}





// --- FUN_0058db10 at 0x0058DB10 (size: 129) ---


void __thiscall FUN_0058db10(int param_1,int param_2,int param_3)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  int iVar4;

  

  if ((param_2 != 0) && (iVar2 = *(int *)(param_1 + 0x50), iVar2 != 0)) {

    uVar1 = *(undefined4 *)(param_2 + 8);

    iVar4 = iVar2 + 0xc;

    if (((*(uint *)(param_2 + 0x100) & 0x800000) != 0) ||

       ((*(int *)(param_2 + 200) != 0 || (*(int *)(param_2 + 0xcc) != 0)))) {

      iVar4 = iVar2 + 0x24;

    }

    iVar2 = FUN_005aec80(uVar1);

    if (iVar2 == 0) {

      param_2 = *(int *)(iVar4 + 0x10);

      puVar3 = &param_2;

      if (param_3 <= *(int *)(iVar4 + 0x10)) {

        puVar3 = &param_3;

      }

      FUN_005aedd0(uVar1,*puVar3,1);

      thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

    }

  }

  return;

}





// --- FUN_0058dba0 at 0x0058DBA0 (size: 87) ---


void __thiscall FUN_0058dba0(int param_1,int param_2)



{

  if ((param_2 != 0) && (*(int *)(param_1 + 0x50) != 0)) {

    FUN_005aeea0(*(undefined4 *)(param_2 + 8));

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  return;

}





// --- FUN_0058dc00 at 0x0058DC00 (size: 45) ---


undefined4 __thiscall FUN_0058dc00(int param_1,int param_2)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x50) == 0) {

    return 0;

  }

  iVar1 = *(int *)(*(int *)(param_1 + 0x50) + 0x40);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if (*(int *)(iVar1 + 4) == param_2) break;

    iVar1 = *(int *)(iVar1 + 0x10);

  }

  return *(undefined4 *)(iVar1 + 8);

}





// --- FUN_0058dc30 at 0x0058DC30 (size: 62) ---


undefined4 __thiscall FUN_0058dc30(int param_1,uint param_2,uint param_3)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x50) == 0) {

    return 0;

  }

  iVar1 = *(int *)(*(int *)(param_1 + 0x50) + 0x40);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if ((((*(uint *)(iVar1 + 0xc) & param_3) != 0) || (param_3 == 0)) &&

       ((param_2 & *(uint *)(iVar1 + 8)) != 0)) break;

    iVar1 = *(int *)(iVar1 + 0x10);

  }

  return *(undefined4 *)(iVar1 + 4);

}





// --- FUN_0058dc80 at 0x0058DC80 (size: 81) ---


bool __thiscall FUN_0058dc80(int param_1,int param_2)



{

  int iVar1;

  

  if (param_2 != 0) {

    if (((*(int *)(param_1 + 8) == param_2) || (*(int *)(param_1 + 0xb4) == param_2)) ||

       (*(int *)(param_1 + 0xb8) == param_2)) {

      return true;

    }

    iVar1 = FUN_005583f0(param_2);

    if (iVar1 != 0) {

      iVar1 = FUN_0058dc00(*(undefined4 *)(param_1 + 8));

      return iVar1 != 0;

    }

  }

  return false;

}





// --- FUN_0058dce0 at 0x0058DCE0 (size: 121) ---


bool __thiscall FUN_0058dce0(int param_1,int param_2)



{

  int iVar1;

  

  if (param_2 == 0) {

    return false;

  }

  if (((*(int *)(param_1 + 8) != param_2) && (*(int *)(param_1 + 0xb4) != param_2)) &&

     (*(int *)(param_1 + 0xb8) != param_2)) {

    iVar1 = FUN_005583f0(param_2);

    if (iVar1 == 0) {

      return false;

    }

    if (*(int *)(param_1 + 0xb4) != 0) {

      iVar1 = FUN_0058cee0(*(int *)(param_1 + 0xb4));

      if (iVar1 != -1) {

        return true;

      }

    }

    iVar1 = FUN_0058dc00(*(undefined4 *)(param_1 + 8));

    return iVar1 != 0;

  }

  return true;

}





// --- FUN_0058dd60 at 0x0058DD60 (size: 79) ---


undefined4 * __thiscall FUN_0058dd60(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e4ff4;

  if ((undefined4 *)param_1[8] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[8])(1);

  }

  param_1[8] = 0;

  if ((undefined4 *)param_1[9] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[9])(1);

  }

  param_1[9] = 0;

  *param_1 = &PTR_LAB_007c78e0;

  param_1[1] = 0;

  param_1[2] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0058ddb0 at 0x0058DDB0 (size: 16) ---


int __fastcall FUN_0058ddb0(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(param_1 + 0xf8);

  if (iVar1 == 0) {

    iVar1 = 1;

  }

  return iVar1;

}





// --- FUN_0058ddc0 at 0x0058DDC0 (size: 178) ---


int __thiscall FUN_0058ddc0(int param_1,int param_2,int param_3)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  

  puVar3 = (undefined4 *)FUN_005df0f5(0x18);

  if (puVar3 == (undefined4 *)0x0) {

    puVar3 = (undefined4 *)0x0;

  }

  else {

    *puVar3 = &PTR_FUN_007acafc;

    puVar3[1] = *(undefined4 *)(param_3 + 4);

    puVar3[2] = *(undefined4 *)(param_3 + 8);

    puVar3[3] = *(undefined4 *)(param_3 + 0xc);

    puVar3[4] = 0;

    puVar3[5] = 0;

  }

  iVar1 = *(int *)(param_1 + 4);

  iVar2 = param_2;

  if (iVar1 == 0) {

    *(undefined4 **)(param_1 + 4) = puVar3;

    *(undefined4 **)(param_1 + 8) = puVar3;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return 0;

  }

  for (; iVar2 != 0; iVar2 = iVar2 + -1) {

    if (iVar1 == 0) goto LAB_0058de31;

    iVar1 = *(int *)(iVar1 + 0x10);

  }

  if (iVar1 != 0) {

    if (*(int *)(iVar1 + 0x14) == 0) {

      *(undefined4 **)(param_1 + 4) = puVar3;

    }

    else {

      *(undefined4 **)(*(int *)(iVar1 + 0x14) + 0x10) = puVar3;

    }

    puVar3[5] = *(undefined4 *)(iVar1 + 0x14);

    puVar3[4] = iVar1;

    *(undefined4 **)(iVar1 + 0x14) = puVar3;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return param_2;

  }

LAB_0058de31:

  iVar1 = *(int *)(param_1 + 8);

  *(undefined4 **)(iVar1 + 0x10) = puVar3;

  puVar3[5] = iVar1;

  *(undefined4 **)(param_1 + 8) = puVar3;

  iVar1 = *(int *)(param_1 + 0xc);

  *(int *)(param_1 + 0xc) = iVar1 + 1;

  return iVar1;

}





// --- FUN_0058de80 at 0x0058DE80 (size: 259) ---


undefined4 FUN_0058de80(int param_1)



{

  int iVar1;

  LONG LVar2;

  int local_94;

  undefined1 local_90 [144];

  

  iVar1 = FUN_00564d30();

  if (iVar1 != 0) {

    if (DAT_00871ed0 != 0) {

      if (param_1 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You can only move or use one item at a time");

        FUN_0042cbe0(&local_94,1);

        LVar2 = InterlockedDecrement((LONG *)(local_94 + -0x10));

        if ((LVar2 == 0) && ((undefined4 *)(local_94 + -0x14) != (undefined4 *)0x0)) {

          (*(code *)**(undefined4 **)(local_94 + -0x14))(1);

        }

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

      return 0;

    }

    if (DAT_00871ee0 == 0) {

      return 1;

    }

    if (param_1 == 0) {

      FUN_0042dc80();

      FUN_00402730(L"You cannot move or use an item while attacking");

      FUN_0042cbe0(&local_94,1);

      FUN_004011b0();

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

    }

  }

  return 0;

}





// --- FUN_0058df90 at 0x0058DF90 (size: 18) ---


void FUN_0058df90(void)



{

  FUN_0058dce0(*(undefined4 *)(DAT_0083da58 + 0xf4));

  return;

}





// --- FUN_0058dfb0 at 0x0058DFB0 (size: 792) ---


void __thiscall FUN_0058dfb0(int param_1,int *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  int *piVar5;

  int *piVar6;

  int *piVar7;

  int *piVar8;

  int *piVar9;

  int *piVar10;

  int iVar11;

  int *piVar12;

  int *unaff_EBP;

  int iVar13;

  undefined4 uStack_24;

  undefined4 uStack_20;

  undefined4 uStack_1c;

  undefined4 uStack_18;

  int iStack_10;

  

  puVar2 = (undefined4 *)(**(code **)(*param_2 + 100))();

  *(undefined4 *)(param_1 + 0xc) = *puVar2;

  *(int *)(param_1 + 0x10) = param_2[0x2b];

  *(int *)(param_1 + 0x14) = param_2[0x2c];

  uVar3 = (**(code **)(*param_2 + 0x18))();

  *(undefined4 *)(param_1 + 0x18) = uVar3;

  *(int *)(param_1 + 0x1c) = param_2[0x39];

  if (*(undefined4 **)(param_1 + 0x20) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x20))(1);

  }

  *(undefined4 *)(param_1 + 0x20) = 0;

  if (*(undefined4 **)(param_1 + 0x24) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x24))(1);

  }

  *(undefined4 *)(param_1 + 0x24) = 0;

  iVar4 = (**(code **)(*param_2 + 0x14))();

  if (iVar4 != 0) {

    puVar2 = (undefined4 *)FUN_00415640(&stack0x00000000,0x10000004,7);

    *(undefined4 *)(param_1 + 0xc) = *puVar2;

    *(undefined4 *)(param_1 + 0x18) = 0x200;

  }

  iVar4 = FUN_00685460(*(undefined4 *)(param_1 + 0x18));

  iVar4 = iVar4 + 1;

  if (iVar4 == 0) {

    iVar4 = 0x21;

  }

  piVar5 = (int *)FUN_00415730(iVar4,0x10000004,0xc);

  iVar4 = FUN_00685460(*(undefined4 *)(param_1 + 0x1c));

  piVar6 = (int *)FUN_00415730(iVar4 + 1,0x10000005,0xc);

  if (piVar6 == (int *)0x0) {

    piVar6 = (int *)FUN_00415730(0x21,0x10000005,0xc);

  }

  uVar3 = FUN_004220b0(*(undefined4 *)(param_1 + 0x14),0xc);

  piVar7 = (int *)FUN_00415430(uVar3);

  uVar3 = FUN_004220b0(*(undefined4 *)(param_1 + 0xc),0xc);

  piVar8 = (int *)FUN_00415430(uVar3);

  uVar3 = FUN_004220b0(*(undefined4 *)(param_1 + 0x10),0xc);

  piVar9 = (int *)FUN_00415430(uVar3);

  piVar10 = (int *)(**(code **)(*DAT_00870340 + 0xc))();

  if (piVar10 != (int *)0x0) {

    iVar4 = *piVar10;

    iVar11 = FUN_0054fe80(1);

    iVar13 = 0x20;

    cVar1 = (**(code **)(iVar4 + 0x58))(0x20);

    if (cVar1 != '\0') {

      if (piVar8 != (int *)0x0) {

        FUN_00442c70(piVar8 + 0x2b,0,0x3f800000);

      }

      if (&stack0x00000000 != (undefined1 *)0xfffffffc) {

        FUN_00442c70(&stack0x000000b0,2,0x3f800000);

      }

      if (iStack_10 != 0) {

        uStack_24 = 0x3f800000;

        uStack_20 = 0x3f800000;

        uStack_1c = 0x3f800000;

        uStack_18 = 0x3f800000;

        FUN_00441750(&uStack_24,iStack_10 + 0xac);

      }

      iVar4 = FUN_005df0f5(0xc);

      if (iVar4 == 0) {

        uVar3 = 0;

      }

      else {

        uVar3 = FUN_00694d80(piVar10);

      }

      *(undefined4 *)(param_1 + 0x24) = uVar3;

      piVar12 = (int *)(**(code **)(*DAT_00870340 + 0xc))();

      if (piVar12 != (int *)0x0) {

        iVar4 = *piVar12;

        uVar3 = FUN_0054fe80(1);

        cVar1 = (**(code **)(iVar4 + 0x58))(0x20,0x20,uVar3);

        if (cVar1 != '\0') {

          if (iVar11 != 0) {

            FUN_00442c70(iVar11 + 0xac,0,0x3f800000);

          }

          if (iVar13 != 0) {

            FUN_00442c70(iVar13 + 0xac,1,0x3f800000);

          }

          FUN_00442c70(piVar10 + 0x2b,1,0x3f800000);

          iVar4 = FUN_005df0f5(0xc);

          if (iVar4 == 0) {

            uVar3 = 0;

          }

          else {

            uVar3 = FUN_00694d80(piVar12);

          }

          *(undefined4 *)(param_1 + 0x20) = uVar3;

        }

        (**(code **)(*piVar12 + 0x14))();

        piVar8 = unaff_EBP;

      }

    }

    (**(code **)(*piVar10 + 0x14))();

  }

  if (piVar9 != (int *)0x0) {

    (**(code **)(*piVar9 + 0x14))();

  }

  if (piVar8 != (int *)0x0) {

    (**(code **)(*piVar8 + 0x14))();

  }

  if (piVar7 != (int *)0x0) {

    (**(code **)(*piVar7 + 0x14))();

  }

  if (piVar6 != (int *)0x0) {

    (**(code **)(*piVar6 + 0x14))();

  }

  if (piVar5 != (int *)0x0) {

    (**(code **)(*piVar5 + 0x14))();

  }

  return;

}





// --- FUN_0058e2d0 at 0x0058E2D0 (size: 237) ---


undefined4 __thiscall FUN_0058e2d0(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

  puVar1 = *(undefined4 **)(param_1 + 4);

  if (puVar1 == (undefined4 *)0x0) {

    return 0;

  }

  if ((puVar1[1] == *(int *)(param_2 + 4)) && (puVar1[2] == *(int *)(param_2 + 8))) {

    *(undefined4 *)(param_2 + 4) = puVar1[1];

    *(undefined4 *)(param_2 + 8) = puVar1[2];

    *(undefined4 *)(param_2 + 0xc) = puVar1[3];

    iVar2 = *(int *)(*(int *)(param_1 + 4) + 0x10);

    *(int *)(param_1 + 4) = iVar2;

    if (iVar2 == 0) {

      *(undefined4 *)(param_1 + 8) = 0;

    }

    else {

      *(undefined4 *)(iVar2 + 0x14) = 0;

    }

    if (puVar1 != (undefined4 *)0x0) {

      *puVar1 = &PTR_FUN_0079385c;

      operator_delete(puVar1);

    }

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + -1;

    return 1;

  }

  iVar2 = puVar1[4];

  while( true ) {

    if (iVar2 == 0) {

      return 0;

    }

    puVar3 = (undefined4 *)puVar1[4];

    if ((puVar3[1] == *(int *)(param_2 + 4)) && (puVar3[2] == *(int *)(param_2 + 8))) break;

    iVar2 = puVar3[4];

    puVar1 = puVar3;

  }

  iVar2 = puVar1[4];

  *(undefined4 *)(param_2 + 4) = *(undefined4 *)(iVar2 + 4);

  *(undefined4 *)(param_2 + 8) = *(undefined4 *)(iVar2 + 8);

  *(undefined4 *)(param_2 + 0xc) = *(undefined4 *)(iVar2 + 0xc);

  puVar3 = (undefined4 *)puVar1[4];

  iVar2 = puVar3[4];

  puVar1[4] = iVar2;

  if (iVar2 == 0) {

    *(undefined4 **)(param_1 + 8) = puVar1;

  }

  else {

    *(undefined4 **)(iVar2 + 0x14) = puVar1;

  }

  *puVar3 = &PTR_FUN_0079385c;

  operator_delete(puVar3);

  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + -1;

  return 1;

}





// --- FUN_0058e3c0 at 0x0058E3C0 (size: 129) ---


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



void __thiscall FUN_0058e3c0(int param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    if (((*(uint *)(param_1 + 0xf8) != 0) && (1 < *(uint *)(param_1 + 0xf8))) &&

       (DAT_0081d7ec != DAT_0081d7f0)) {

      FUN_006ad1c0(*(undefined4 *)(param_1 + 8),param_2,DAT_0081d7ec);

      return;

    }

    FUN_006ac950(*(undefined4 *)(param_1 + 8),param_2);

    DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

    DAT_00871ed0 = 7;

    _DAT_00871ed8 = DAT_008379a8;

    _DAT_00871edc = DAT_008379ac;

  }

  return;

}





// --- FUN_0058e450 at 0x0058E450 (size: 85) ---


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



void __thiscall FUN_0058e450(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006aca60(param_2,*(undefined4 *)(param_1 + 8),param_3);

    DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

    DAT_00871ed0 = 9;

    _DAT_00871ed8 = DAT_008379a8;

    _DAT_00871edc = DAT_008379ac;

  }

  return;

}





// --- FUN_0058e4b0 at 0x0058E4B0 (size: 116) ---


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



void __thiscall FUN_0058e4b0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006acc80(*(undefined4 *)(param_1 + 8),param_2,param_3);

    iVar1 = *(int *)(param_1 + 0x68);

    if (iVar1 == 0) {

      DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

      DAT_00871ed0 = 4;

      _DAT_00871ed8 = DAT_008379a8;

      _DAT_00871edc = DAT_008379ac;

    }

    else if ((0 < iVar1) && (iVar1 < 3)) {

      FUN_0058d050(*(undefined4 *)(param_1 + 8),5);

      return;

    }

  }

  return;

}





// --- FUN_0058e530 at 0x0058E530 (size: 102) ---


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



void __fastcall FUN_0058e530(int param_1)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006ac880(*(undefined4 *)(param_1 + 8));

    iVar1 = *(int *)(param_1 + 0x68);

    if (iVar1 == 0) {

      DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

      DAT_00871ed0 = 3;

      _DAT_00871ed8 = DAT_008379a8;

      _DAT_00871edc = DAT_008379ac;

    }

    else if ((0 < iVar1) && (iVar1 < 3)) {

      FUN_0058d050(*(undefined4 *)(param_1 + 8),6);

      return;

    }

  }

  return;

}





// --- FUN_0058e5a0 at 0x0058E5A0 (size: 85) ---


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



void __thiscall FUN_0058e5a0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006acdd0(*(undefined4 *)(param_1 + 8),param_2,param_3);

    DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

    DAT_00871ed0 = 1;

    _DAT_00871ed8 = DAT_008379a8;

    _DAT_00871edc = DAT_008379ac;

  }

  return;

}





// --- FUN_0058e600 at 0x0058E600 (size: 121) ---


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



void __thiscall FUN_0058e600(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006ad030(*(undefined4 *)(param_1 + 8),param_2,param_3,param_4);

    DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

    DAT_00871ed0 = 2;

    _DAT_00871ed8 = DAT_008379a8;

    _DAT_00871edc = DAT_008379ac;

    DAT_00871f88 = *(undefined4 *)(param_1 + 0xa4);

    DAT_00871ec4 = param_4;

    _DAT_00871ec8 = DAT_008379a8;

    _DAT_00871ecc = DAT_008379ac;

  }

  return;

}





// --- FUN_0058e680 at 0x0058E680 (size: 110) ---


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



void __thiscall FUN_0058e680(int param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_0058de80(0);

  if (iVar1 != 0) {

    FUN_006acf20(*(undefined4 *)(param_1 + 8),param_2);

    DAT_00871ed4 = *(undefined4 *)(param_1 + 8);

    DAT_00871ed0 = 2;

    _DAT_00871ed8 = DAT_008379a8;

    _DAT_00871edc = DAT_008379ac;

    DAT_00871f88 = *(undefined4 *)(param_1 + 0xa4);

    DAT_00871ec4 = param_2;

    _DAT_00871ec8 = DAT_008379a8;

    _DAT_00871ecc = DAT_008379ac;

  }

  return;

}





// --- FUN_0058e6f0 at 0x0058E6F0 (size: 184) ---


void __thiscall FUN_0058e6f0(int param_1,int param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined **local_10;

  undefined4 local_c;

  int local_8;

  undefined4 local_4;

  

  iVar2 = FUN_005583f0(*(undefined4 *)(DAT_0083da58 + 0xf4));

  if (((iVar2 != 0) && (*(int *)(iVar2 + 0x50) != 0)) && (*(int *)(iVar2 + 0x50) != -0x3c)) {

    uVar1 = *(undefined4 *)(param_1 + 8);

    local_8 = FUN_0058dc00(uVar1);

    if (local_8 != 0) {

      local_4 = *(undefined4 *)(param_1 + 0xbc);

      local_10 = &PTR_FUN_007acafc;

      local_c = uVar1;

      FUN_0058e2d0(&local_10);

      if (*(int *)(param_1 + 0x94) != 0) {

        FUN_00512190(0);

      }

    }

    if (param_2 != 0) {

      local_c = *(undefined4 *)(param_1 + 8);

      local_4 = *(undefined4 *)(param_1 + 0xbc);

      local_8 = param_2;

      local_10 = &PTR_FUN_007acafc;

      FUN_0058ddc0(0,&local_10);

    }

  }

  return;

}





// --- FUN_0058e7b0 at 0x0058E7B0 (size: 78) ---


undefined4 * __thiscall FUN_0058e7b0(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

  param_1[1] = 0;

  param_1[2] = param_3;

  *param_1 = &PTR_FUN_007e4ff4;

  param_1[3] = DAT_00871f1c;

  param_1[4] = DAT_00871f1c;

  uVar1 = DAT_00871f1c;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[5] = uVar1;

  FUN_0058dfb0(param_2);

  return param_1;

}





// --- FUN_0058e800 at 0x0058E800 (size: 97) ---


undefined4 __thiscall FUN_0058e800(int param_1,int *param_2)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  

  piVar1 = param_2;

  piVar2 = (int *)(**(code **)(*param_2 + 100))(&param_2);

  if (((*(int *)(param_1 + 0xc) == *piVar2) && (*(int *)(param_1 + 0x10) == piVar1[0x2b])) &&

     (*(int *)(param_1 + 0x14) == piVar1[0x2c])) {

    iVar3 = (**(code **)(*piVar1 + 0x18))();

    if ((*(int *)(param_1 + 0x18) == iVar3) && (*(int *)(param_1 + 0x1c) == piVar1[0x39])) {

      return 0;

    }

  }

  FUN_0058dfb0(piVar1);

  return 1;

}





// --- FUN_0058e9a0 at 0x0058E9A0 (size: 52) ---


bool FUN_0058e9a0(uint param_1)



{

  uint *puVar1;

  bool bVar2;

  

  puVar1 = *(uint **)(DAT_0082174c + (param_1 % DAT_00821754) * 4);

  bVar2 = puVar1 == (uint *)0x0;

  if (!bVar2) {

    do {

      if (*puVar1 == param_1) break;

      puVar1 = (uint *)puVar1[1];

    } while (puVar1 != (uint *)0x0);

    bVar2 = puVar1 == (uint *)0x0;

  }

  return !bVar2;

}





// --- FUN_0058e9e0 at 0x0058E9E0 (size: 360) ---


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



void __thiscall

FUN_0058e9e0(int param_1,int param_2,undefined4 param_3,int param_4,int param_5,int param_6)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  int iVar4;

  

  iVar1 = *(int *)(param_1 + 0xb4);

  iVar2 = *(int *)(param_1 + 0xb8);

  uVar3 = *(undefined4 *)(param_1 + 0xc4);

  if (iVar1 != 0) {

    iVar4 = FUN_005583f0(iVar1);

    if (iVar4 != 0) {

      FUN_0058dba0(param_1);

    }

  }

  *(int *)(param_1 + 0xb4) = param_2;

  if (param_2 != 0) {

    iVar4 = FUN_005583f0(param_2);

    if (iVar4 != 0) {

      FUN_0058db10(param_1,param_3);

    }

  }

  if (param_4 == *(int *)(DAT_0083da58 + 0xf4)) {

    FUN_0058e6f0(param_5);

    *(undefined4 *)(param_1 + 0xb8) = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  else if (iVar2 == *(int *)(DAT_0083da58 + 0xf4)) {

    FUN_0058e6f0(0);

    *(undefined4 *)(param_1 + 0xb8) = 0;

  }

  *(int *)(param_1 + 0xc4) = param_5;

  if (*(int *)(param_1 + 100) == 0) {

    if (*(int *)(param_1 + 0xb4) == 0) {

      *(uint *)(param_1 + 0x68) = (uint)(param_5 != 0);

    }

    else {

      *(undefined4 *)(param_1 + 0x68) = 2;

    }

  }

  else {

    *(undefined4 *)(param_1 + 0x68) = 3;

  }

  if ((*(int *)(param_1 + 0x70) != 0) &&

     (*(undefined4 *)(param_1 + 0x70) = 0, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  if (*(int *)(param_1 + 8) == DAT_00871ed4) {

    DAT_00871ed4 = 0;

    DAT_00871ed0 = 0;

    _DAT_00871ed8 = 0;

    _DAT_00871edc = 0;

  }

  if (*(int *)(param_1 + 0x5c) != 0) {

    *(undefined4 *)(param_1 + 0x60) = 1;

  }

  if (param_6 != 0) {

    FUN_004fd0f0(*(undefined4 *)(param_1 + 8),iVar1,iVar2,uVar3,param_2,param_3,param_4,param_5);

  }

  return;

}





// --- FUN_0058eb50 at 0x0058EB50 (size: 174) ---


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



void __fastcall FUN_0058eb50(int param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(param_1 + 0xb8);

  *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(param_1 + 0xb4);

  *(undefined4 *)(param_1 + 0x8c) = *(undefined4 *)(param_1 + 0xc4);

  *(undefined4 *)(param_1 + 0x90) = 0;

  *(undefined4 *)(param_1 + 100) = 1;

  FUN_0058e9e0(0,0,0,0,1);

  iVar1 = DAT_00871e54;

  if ((*(int *)(param_1 + 8) == DAT_00871e54) && (DAT_00871e54 != 0)) {

    iVar2 = FUN_005583f0(DAT_00871e54);

    if (iVar2 != 0) {

      *(undefined4 *)(iVar2 + 0x6c) = 0;

    }

    DAT_00871e54 = 0;

    DAT_00871e58 = iVar1;

    _DAT_00871e5c = iVar1;

    FUN_0047a350();

    thunk_FUN_00693910(iVar1,DAT_00871e54);

    iVar2 = FUN_0055b0a0();

    if (iVar2 != 0) {

      piVar3 = (int *)FUN_0055a740();

      (**(code **)(*piVar3 + 0x28))(piVar3,iVar1,DAT_00871e54);

    }

  }

  *(undefined4 *)(param_1 + 100) = 0;

  return;

}





// --- FUN_0058ec00 at 0x0058EC00 (size: 83) ---


void __fastcall FUN_0058ec00(int param_1)



{

  uint uVar1;

  int iVar2;

  

  uVar1 = *(uint *)(param_1 + 8);

  iVar2 = *(int *)(DAT_008216d8 +

                  ((uVar1 >> ((byte)DAT_008216d4 & 0x1f) ^ uVar1) & DAT_008216d0) * 4);

  if (iVar2 != 0) {

    while (uVar1 != *(uint *)(iVar2 + 8)) {

      iVar2 = *(int *)(iVar2 + 4);

      if (iVar2 == 0) {

        return;

      }

    }

    if (iVar2 != 0) {

      iVar2 = FUN_0058e800(param_1);

      if (iVar2 != 0) {

        thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),2);

      }

    }

  }

  return;

}





// --- FUN_0058ec60 at 0x0058EC60 (size: 133) ---


void __fastcall FUN_0058ec60(int param_1)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = *(uint *)(param_1 + 8);

  for (iVar1 = *(int *)(DAT_008216d8 +

                       ((uVar2 >> ((byte)DAT_008216d4 & 0x1f) ^ uVar2) & DAT_008216d0) * 4);

      iVar1 != 0; iVar1 = *(int *)(iVar1 + 4)) {

    if (uVar2 == *(uint *)(iVar1 + 8)) goto LAB_0058ec95;

  }

  iVar1 = 0;

LAB_0058ec95:

  if (iVar1 == 0) {

    iVar1 = FUN_005df0f5(0x28);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_0058e7b0(param_1,*(undefined4 *)(param_1 + 8));

    }

    uVar2 = (*(uint *)(iVar1 + 8) >> ((byte)DAT_008216d4 & 0x1f) ^ *(uint *)(iVar1 + 8)) &

            DAT_008216d0;

    *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(DAT_008216d8 + uVar2 * 4);

    *(int *)(DAT_008216d8 + uVar2 * 4) = iVar1;

  }

  return;

}





// --- FUN_0058ecf0 at 0x0058ECF0 (size: 25) ---


void __thiscall FUN_0058ecf0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xd0) = param_2;

  if (*(int *)(param_1 + 0x54) != 0) {

    FUN_0058ec00();

  }

  return;

}





// --- FUN_0058ed10 at 0x0058ED10 (size: 25) ---


void __thiscall FUN_0058ed10(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xd8) = param_2;

  if (*(int *)(param_1 + 0x54) != 0) {

    FUN_0058ec00();

  }

  return;

}





// --- FUN_0058ed30 at 0x0058ED30 (size: 25) ---


void __thiscall FUN_0058ed30(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0xe4) = param_2;

  if (*(int *)(param_1 + 0x54) != 0) {

    FUN_0058ec00();

  }

  return;

}





// --- FUN_0058ed50 at 0x0058ED50 (size: 360) ---


void __thiscall FUN_0058ed50(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  switch(param_2) {

  case 1:

    FUN_0058ecf0(param_3);

    return;

  case 4:

    *(undefined4 *)(param_1 + 0xbc) = param_3;

    return;

  case 6:

    *(undefined4 *)(param_1 + 200) = param_3;

    return;

  case 7:

    *(undefined4 *)(param_1 + 0xcc) = param_3;

    return;

  case 9:

    *(undefined4 *)(param_1 + 0xc0) = param_3;

    return;

  case 10:

    if ((DAT_00871ed4 != *(int *)(param_1 + 8)) && (iVar1 = FUN_0058df90(), iVar1 == 0)) {

      *(undefined4 *)(param_1 + 0xc4) = param_3;

      return;

    }

    break;

  case 0xb:

    *(undefined4 *)(param_1 + 0xfc) = param_3;

    return;

  case 0xc:

    FUN_0058d0f0(param_3);

    return;

  case 0x10:

    FUN_0058ed10(param_3);

    return;

  case 0x12:

    FUN_0058ed30(param_3);

    return;

  case 0x13:

    *(undefined4 *)(param_1 + 0xd4) = param_3;

    return;

  case 0x32:

    *(undefined4 *)(param_1 + 0xe8) = param_3;

    return;

  case 0x33:

    *(undefined4 *)(param_1 + 0xec) = param_3;

    return;

  case 0x5b:

    FUN_0058d0d0(param_3);

    return;

  case 0x5c:

    FUN_0058d0b0(param_3);

    return;

  case 0x5f:

    *(undefined4 *)(param_1 + 0x104) = param_3;

    return;

  case 0x85:

    *(undefined4 *)(param_1 + 0x108) = param_3;

    return;

  case 0x86:

    FUN_005ad870(param_3);

    break;

  case 0x97:

    *(undefined4 *)(param_1 + 0x120) = param_3;

    return;

  case 0x98:

    *(undefined4 *)(param_1 + 0x124) = param_3;

    return;

  }

  return;

}





// --- FUN_0058efb0 at 0x0058EFB0 (size: 88) ---


void __thiscall FUN_0058efb0(int param_1,undefined4 param_2,undefined4 param_3)



{

  switch(param_2) {

  case 8:

    *(undefined4 *)(param_1 + 0xa8) = param_3;

    break;

  default:

    goto switchD_0058efc3_caseD_9;

  case 0x2c:

    *(undefined4 *)(param_1 + 0x11c) = param_3;

    return;

  case 0x32:

    *(undefined4 *)(param_1 + 0xac) = param_3;

    break;

  case 0x34:

    *(undefined4 *)(param_1 + 0xb0) = param_3;

  }

  if (*(int *)(param_1 + 0x54) != 0) {

    FUN_0058ec00();

    return;

  }

switchD_0058efc3_caseD_9:

  return;

}





// --- FUN_0058f050 at 0x0058F050 (size: 213) ---


void __thiscall FUN_0058f050(int param_1,undefined4 param_2,int param_3)



{

  int iVar1;

  

  switch(param_2) {

  case 2:

    if ((DAT_00871ed4 != *(int *)(param_1 + 8)) &&

       (iVar1 = FUN_0058dce0(*(undefined4 *)(DAT_0083da58 + 0xf4)), iVar1 == 0)) {

      iVar1 = FUN_0048e5f0();

      if ((param_3 == iVar1) && (iVar1 != 0)) {

        FUN_0058e9e0(param_3,0,0,0,1);

        return;

      }

      *(int *)(param_1 + 0xb4) = param_3;

      return;

    }

    break;

  case 3:

    if ((DAT_00871ed4 != *(int *)(param_1 + 8)) &&

       (iVar1 = FUN_0058dce0(*(undefined4 *)(DAT_0083da58 + 0xf4)), iVar1 == 0)) {

      *(int *)(param_1 + 0xb8) = param_3;

      return;

    }

    break;

  case 0x1a:

    *(int *)(param_1 + 0x128) = param_3;

    return;

  case 0x20:

    *(int *)(param_1 + 0x114) = param_3;

    return;

  case 0x2c:

    *(int *)(param_1 + 0x140) = param_3;

  }

  return;

}





// --- FUN_0058f170 at 0x0058F170 (size: 380) ---


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



void __fastcall FUN_0058f170(int *param_1)



{

  uint uVar1;

  undefined4 uVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  int *local_4;

  

  param_1[0x15] = 1;

  local_4 = param_1;

  if (param_1[0x14] != 0) {

    iVar5 = 0;

    if (0 < *(int *)(param_1[0x14] + 0x1c)) {

      do {

        uVar2 = FUN_005aeef0(iVar5);

        FUN_00508f10(uVar2);

        iVar5 = iVar5 + 1;

      } while (iVar5 < *(int *)(param_1[0x14] + 0x1c));

    }

    iVar5 = 0;

    if (0 < *(int *)(param_1[0x14] + 0x34)) {

      do {

        uVar2 = FUN_005aeef0(iVar5);

        FUN_00508f10(uVar2);

        iVar5 = iVar5 + 1;

      } while (iVar5 < *(int *)(param_1[0x14] + 0x34));

    }

  }

  uVar1 = param_1[2];

  iVar5 = *(int *)(DAT_008216d8 +

                  ((uVar1 >> ((byte)DAT_008216d4 & 0x1f) ^ uVar1) & DAT_008216d0) * 4);

  do {

    if (iVar5 == 0) {

LAB_0058f26f:

      thunk_FUN_00693810(param_1[2],1);

      if (DAT_00871f88 != DAT_00871f1c) {

        if (DAT_00871f88 == param_1[0x29]) {

          iVar5 = param_1[0x3e];

          if (iVar5 == 0) {

            iVar5 = 1;

          }

          if (DAT_00871ec4 == iVar5) {

            FUN_0058d110(param_1[2],0);

            DAT_00871f88 = DAT_00871f1c;

            return;

          }

        }

        if (_DAT_0079cac8 < _DAT_008379a8 - _DAT_00871ec8) {

          DAT_00871f88 = DAT_00871f1c;

        }

      }

      return;

    }

    if (uVar1 == *(uint *)(iVar5 + 8)) {

      if ((iVar5 != 0) &&

         ((((piVar3 = (int *)(**(code **)(*param_1 + 100))(&local_4),

            *(int *)(iVar5 + 0xc) != *piVar3 || (*(int *)(iVar5 + 0x10) != param_1[0x2b])) ||

           (*(int *)(iVar5 + 0x14) != param_1[0x2c])) ||

          ((iVar4 = (**(code **)(*param_1 + 0x18))(), *(int *)(iVar5 + 0x18) != iVar4 ||

           (*(int *)(iVar5 + 0x1c) != param_1[0x39])))))) {

        FUN_0058dfb0(param_1);

        thunk_FUN_00693810(param_1[2],2);

      }

      goto LAB_0058f26f;

    }

    iVar5 = *(int *)(iVar5 + 4);

  } while( true );

}





// --- thunk_FUN_0058eb50 at 0x0058F2F0 (size: 5) ---


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



void __fastcall thunk_FUN_0058eb50(int param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(param_1 + 0xb8);

  *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(param_1 + 0xb4);

  *(undefined4 *)(param_1 + 0x8c) = *(undefined4 *)(param_1 + 0xc4);

  *(undefined4 *)(param_1 + 0x90) = 0;

  *(undefined4 *)(param_1 + 100) = 1;

  FUN_0058e9e0(0,0,0,0,1);

  iVar1 = DAT_00871e54;

  if ((*(int *)(param_1 + 8) == DAT_00871e54) && (DAT_00871e54 != 0)) {

    iVar2 = FUN_005583f0(DAT_00871e54);

    if (iVar2 != 0) {

      *(undefined4 *)(iVar2 + 0x6c) = 0;

    }

    DAT_00871e54 = 0;

    DAT_00871e58 = iVar1;

    _DAT_00871e5c = iVar1;

    FUN_0047a350();

    thunk_FUN_00693910(iVar1,DAT_00871e54);

    iVar2 = FUN_0055b0a0();

    if (iVar2 != 0) {

      piVar3 = (int *)FUN_0055a740();

      (**(code **)(*piVar3 + 0x28))(piVar3,iVar1,DAT_00871e54);

    }

  }

  *(undefined4 *)(param_1 + 100) = 0;

  return;

}





// --- FUN_0058f300 at 0x0058F300 (size: 374) ---


void __fastcall FUN_0058f300(int param_1)



{

  uint uVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  uint uVar7;

  int iVar8;

  

  iVar8 = 0;

  *(undefined4 *)(param_1 + 0x94) = 0;

  if ((*(int *)(param_1 + 0x5c) == 0) || (*(int *)(param_1 + 0x60) != 0)) {

    FUN_0058eb50();

  }

  if (*(int *)(param_1 + 0x50) != 0) {

    if (0 < *(int *)(*(int *)(param_1 + 0x50) + 0x1c)) {

      do {

        uVar3 = FUN_005aeef0(iVar8);

        iVar4 = FUN_00508890(uVar3);

        iVar5 = FUN_005583f0(uVar3);

        if (((iVar5 == 0) || (*(int *)(iVar5 + 0xb4) == *(int *)(param_1 + 8))) &&

           ((iVar4 == 0 || (*(int *)(iVar4 + 0x90) == 0)))) {

          FUN_00509a40(uVar3);

        }

        iVar8 = iVar8 + 1;

      } while (iVar8 < *(int *)(*(int *)(param_1 + 0x50) + 0x1c));

    }

    iVar8 = 0;

    if (0 < *(int *)(*(int *)(param_1 + 0x50) + 0x34)) {

      do {

        uVar3 = FUN_005aeef0(iVar8);

        iVar4 = FUN_00508890(uVar3);

        iVar5 = FUN_005583f0(uVar3);

        if (((iVar5 == 0) || (*(int *)(iVar5 + 0xb4) == *(int *)(param_1 + 8))) &&

           ((iVar4 == 0 || (*(int *)(iVar4 + 0x90) == 0)))) {

          FUN_00509a40(uVar3);

        }

        iVar8 = iVar8 + 1;

      } while (iVar8 < *(int *)(*(int *)(param_1 + 0x50) + 0x34));

    }

  }

  uVar1 = *(uint *)(param_1 + 8);

  uVar7 = (uVar1 >> ((byte)DAT_008216d4 & 0x1f) ^ uVar1) & DAT_008216d0;

  puVar6 = *(undefined4 **)(DAT_008216d8 + uVar7 * 4);

  if (puVar6 != (undefined4 *)0x0) {

    if (puVar6[2] == uVar1) {

      *(undefined4 *)(DAT_008216d8 + uVar7 * 4) = puVar6[1];

LAB_0058f445:

      if (puVar6 != (undefined4 *)0x0) {

        (**(code **)*puVar6)(1);

      }

    }

    else {

      iVar8 = puVar6[1];

      puVar2 = puVar6;

      while (iVar8 != 0) {

        puVar6 = (undefined4 *)puVar2[1];

        if (puVar6[2] == uVar1) {

          puVar6 = (undefined4 *)puVar2[1];

          puVar2[1] = puVar6[1];

          goto LAB_0058f445;

        }

        puVar2 = puVar6;

        iVar8 = puVar6[1];

      }

    }

  }

  if (*(undefined4 **)(param_1 + 0x148) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x148))(1);

    *(undefined4 *)(param_1 + 0x148) = 0;

  }

  FUN_0050a0b0();

  return;

}





// --- FUN_0058f480 at 0x0058F480 (size: 9) ---


undefined4 FUN_0058f480(void)



{

  int iVar1;

  

  iVar1 = FUN_0058ec60();

  return *(undefined4 *)(iVar1 + 0x20);

}





// --- FUN_0058f490 at 0x0058F490 (size: 9) ---


undefined4 FUN_0058f490(void)



{

  int iVar1;

  

  iVar1 = FUN_0058ec60();

  return *(undefined4 *)(iVar1 + 0x24);

}





// --- FUN_0058f4a0 at 0x0058F4A0 (size: 79) ---


void FUN_0058f4a0(uint param_1)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(DAT_0082174c + (param_1 % DAT_00821754) * 4);

  if (puVar1 != (uint *)0x0) {

    while (*puVar1 != param_1) {

      puVar1 = (uint *)puVar1[1];

      if (puVar1 == (uint *)0x0) {

        FUN_0045ce60(&param_1);

        return;

      }

    }

    if (puVar1 != (uint *)0x0) {

      return;

    }

  }

  FUN_0045ce60(&param_1);

  return;

}





// --- FUN_0058f4f0 at 0x0058F4F0 (size: 29) ---


void FUN_0058f4f0(void *param_1)



{

  param_1 = (void *)FUN_004171e0(&stack0x00000004);

  if (param_1 != (void *)0x0) {

    operator_delete(param_1);

    return;

  }

  return;

}





// --- FUN_0058f510 at 0x0058F510 (size: 805) ---


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



undefined1 * __thiscall FUN_0058f510(int *param_1,int param_2,undefined *param_3)



{

  char cVar1;

  undefined1 uVar2;

  int iVar3;

  LONG LVar4;

  char *pcVar5;

  char *pcVar6;

  int iVar7;

  code *pcVar8;

  undefined4 *puVar9;

  undefined2 *puVar10;

  undefined2 *puVar11;

  int unaff_retaddr;

  undefined4 *puStack_8;

  undefined4 *puStack_4;

  

  if ((param_3 != (undefined *)0x0) && (iVar3 = (**(code **)(*param_1 + 0x14))(), iVar3 != 0)) {

    DAT_00871e68 = s_Backpack_007e50bc[8];

    DAT_00871e60 = s_Backpack_007e50bc[0];

    DAT_00871e61 = s_Backpack_007e50bc[1];

    DAT_00871e62 = s_Backpack_007e50bc[2];

    DAT_00871e63 = s_Backpack_007e50bc[3];

    DAT_00871e64 = s_Backpack_007e50bc[4];

    DAT_00871e64_1._0_1_ = s_Backpack_007e50bc[5];

    DAT_00871e64_1._1_1_ = s_Backpack_007e50bc[6];

    DAT_00871e64_1._2_1_ = s_Backpack_007e50bc[7];

    return &DAT_00871e60;

  }

  _DAT_00871e60 = _DAT_00871e60 & 0xffffff00;

  if (param_2 == 2) {

    if ((param_1[0x3e] == 0) || ((uint)param_1[0x3e] < 2)) goto LAB_0058f618;

    param_2 = 1;

LAB_0058f59b:

    puVar9 = (undefined4 *)param_1[0x28];

    InterlockedIncrement(puVar9 + 1);

    iVar3 = puVar9[2];

    LVar4 = InterlockedDecrement(puVar9 + 1);

    if (LVar4 == 0) {

      (**(code **)*puVar9)(1);

    }

    if (iVar3 == 1) goto LAB_0058f618;

    puVar9 = (undefined4 *)param_1[0x28];

    InterlockedIncrement(puVar9 + 1);

    pcVar5 = (char *)(puVar9 + 5);

    iVar3 = (int)&DAT_00871e60 - (int)pcVar5;

    do {

      cVar1 = *pcVar5;

      pcVar5[iVar3] = cVar1;

      pcVar8 = InterlockedDecrement_exref;

      pcVar5 = pcVar5 + 1;

    } while (cVar1 != '\0');

    LVar4 = InterlockedDecrement(puVar9 + 1);

    if ((LVar4 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

  }

  else {

    if (param_2 == 1) goto LAB_0058f59b;

LAB_0058f618:

    puVar9 = (undefined4 *)param_1[0x27];

    InterlockedIncrement(puVar9 + 1);

    pcVar5 = (char *)(puVar9 + 5);

    iVar3 = (int)&DAT_00871e60 - (int)pcVar5;

    do {

      cVar1 = *pcVar5;

      pcVar5[iVar3] = cVar1;

      pcVar5 = pcVar5 + 1;

    } while (cVar1 != '\0');

    LVar4 = InterlockedDecrement(puVar9 + 1);

    if ((LVar4 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    uVar2 = DAT_007e50ba;

    pcVar8 = InterlockedDecrement_exref;

    if (param_2 == 1) {

      pcVar5 = &DAT_00871e60;

      do {

        pcVar6 = pcVar5;

        pcVar5 = pcVar6 + 1;

      } while (*pcVar6 != '\0');

      if ((int)(pcVar6 + -0x871e60) < 1) goto LAB_0058f827;

      puVar10 = (undefined2 *)&DAT_00871e5f;

      if (pcVar6[-1] == 's') {

        do {

          puVar11 = puVar10;

          puVar10 = (undefined2 *)((int)puVar11 + 1);

        } while (*(char *)((int)puVar11 + 1) != '\0');

        *(undefined2 *)((int)puVar11 + 1) = DAT_007e50b8;

        *(undefined1 *)((int)puVar11 + 3) = uVar2;

        pcVar8 = InterlockedDecrement_exref;

      }

      else {

        do {

          pcVar5 = (char *)((int)puVar10 + 1);

          puVar10 = (undefined2 *)((int)puVar10 + 1);

        } while (*pcVar5 != '\0');

        *puVar10 = DAT_00795520;

        pcVar8 = InterlockedDecrement_exref;

      }

    }

  }

  puVar9 = DAT_008ef11c;

  puStack_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  iVar3 = param_1[0x4b];

  if (0 < iVar3) {

    param_3 = PTR_DAT_00818344;

    InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

    FUN_00401340(&DAT_00871e60);

    FUN_005b5690(iVar3,&param_3);

    FUN_00401340(&DAT_007938af);

    iVar3 = FUN_004053a0(&param_3,&puStack_8);

    puVar9 = puStack_8 + -5;

    iVar7 = (*pcVar8)(puStack_8 + -4);

    if ((iVar7 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    if (iVar3 != 0) {

      iVar3 = DAT_00837748;

      InterlockedIncrement((LONG *)(DAT_00837748 + -0x10));

      FUN_00435720(1,1,iVar3);

    }

    FUN_00487620(&puStack_8,"%s %s",param_2,unaff_retaddr);

    pcVar5 = (char *)(puStack_8 + 5);

    iVar3 = (int)&DAT_00871e60 - (int)pcVar5;

    do {

      cVar1 = *pcVar5;

      pcVar5[iVar3] = cVar1;

      pcVar5 = pcVar5 + 1;

    } while (cVar1 != '\0');

    iVar3 = (*pcVar8)(unaff_retaddr + -0x10);

    if ((iVar3 == 0) && ((undefined4 *)(unaff_retaddr + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(unaff_retaddr + -0x14))(1);

    }

    iVar3 = (*pcVar8)(unaff_retaddr + -0x10);

    puVar9 = puStack_8;

    if ((iVar3 == 0) && ((undefined4 *)(unaff_retaddr + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(unaff_retaddr + -0x14))(1);

    }

  }

  if ((DAT_00871e60 == '+') && ((*(byte *)(param_1 + 0x40) & 0x40) != 0)) {

    iVar3 = (*pcVar8)(puVar9 + 1);

    if ((iVar3 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    return &DAT_00871e61;

  }

  iVar3 = (*pcVar8)(puVar9 + 1);

  if ((iVar3 == 0) && (puVar9 != (undefined4 *)0x0)) {

    (**(code **)*puVar9)(1);

  }

LAB_0058f827:

  return &DAT_00871e60;

}





// --- FUN_0058f840 at 0x0058F840 (size: 107) ---


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



undefined1 * FUN_0058f840(int param_1,undefined4 param_2,int param_3)



{

  int iVar1;

  undefined1 *puVar2;

  

  if ((param_3 != 0) && (param_1 == *(int *)(DAT_0083da58 + 0xf4))) {

    _DAT_00871e64 = s_Backpack_007e50bc._4_4_;

    _DAT_00871e60 = s_Backpack_007e50bc._0_4_;

    DAT_00871e68 = s_Backpack_007e50bc[8];

    return &DAT_00871e60;

  }

  iVar1 = FUN_005583f0(param_1);

  if (iVar1 != 0) {

    puVar2 = (undefined1 *)FUN_0058f510(param_2,0);

    return puVar2;

  }

  _DAT_00871e60 = _DAT_00871e60 & 0xffffff00;

  return &DAT_00871e60;

}





// --- FUN_0058f8b0 at 0x0058F8B0 (size: 36) ---


undefined4 FUN_0058f8b0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

  uVar1 = FUN_0058f510(param_2,param_3);

  FUN_00404a40(0,uVar1);

  return param_1;

}





// --- FUN_0058f8e0 at 0x0058F8E0 (size: 42) ---


undefined4 FUN_0058f8e0(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 uVar1;

  

  uVar1 = FUN_0058f840(param_2,param_3,param_4);

  FUN_00404a40(0,uVar1);

  return param_1;

}





// --- FUN_0058f910 at 0x0058F910 (size: 931) ---


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



void __thiscall FUN_0058f910(int param_1,uint param_2,int param_3)



{

  int iVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined *local_b4;

  int local_b0;

  undefined1 local_ac [4];

  undefined1 local_a8 [4];

  undefined1 local_a4 [4];

  undefined1 local_a0 [4];

  undefined1 local_9c [4];

  undefined1 local_98 [4];

  undefined1 local_94 [4];

  undefined1 local_90 [144];

  

  if ((*(int *)(param_1 + 0x70) != 0) &&

     (*(undefined4 *)(param_1 + 0x70) = 0, *(int *)(param_1 + 0x54) != 0)) {

    thunk_FUN_00693810(*(undefined4 *)(param_1 + 8),0);

  }

  iVar1 = FUN_00564d30();

  if (iVar1 == 0) {

    return;

  }

  if (param_3 == 0) goto LAB_0058fc6a;

  local_b4 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  switch(DAT_00871ed0) {

  case 1:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_a0,1,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be merged",*puVar3);

    break;

  case 2:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_a8,1,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be split",*puVar3);

    break;

  case 3:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_ac,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be moved",*puVar3);

    break;

  case 4:

    puVar3 = (undefined4 *)FUN_0058f8b0(&local_b0,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be picked up",*puVar3);

    break;

  case 5:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_a4,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be put in the container",*puVar3);

    break;

  case 6:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_9c,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be dropped",*puVar3);

    break;

  case 7:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_98,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be wielded",*puVar3);

    break;

  default:

    goto switchD_0058f97a_caseD_8;

  case 9:

    puVar3 = (undefined4 *)FUN_0058f8b0(local_94,2,0);

    FUN_004027b0(&local_b4,L"The %s can\'t be given",*puVar3);

  }

  FUN_004011b0();

switchD_0058f97a_caseD_8:

  if (param_2 < 0x2b) {

    if (param_2 == 0x2a) {

      FUN_00402730(L" - you are too encumbered");

      if (*(int *)(local_b0 + -4) != 1) {

        FUN_00402490(local_b0,*(int *)(local_b0 + -4) + -1);

      }

    }

    else if (param_2 == 0x1d) {

      FUN_00402730(L" - you\'re too busy");

      FUN_00408800(local_a4);

    }

    else if (param_2 == 0x20) {

      FUN_00402730(L" - you must control both objects");

      FUN_00408800(local_9c);

    }

    else {

      if (param_2 != 0x28) goto LAB_0058fc16;

      FUN_00402730(L" - the item is under someone else\'s control");

      FUN_00408800(local_98);

    }

LAB_0058fc11:

    FUN_004011b0();

  }

  else {

    if (param_2 < 0x3a) {

      if (param_2 < 0x37) {

        if (param_2 != 0x36) goto LAB_0058fc16;

        FUN_00402730(L" - action cancelled");

        FUN_00408800(local_ac);

      }

      else {

        FUN_00402730(L" - unable to move to object");

        FUN_00408800(local_a8);

      }

      goto LAB_0058fc11;

    }

    if (param_2 == 0x3ee) {

      FUN_00402730(L" - the container is closed");

      FUN_00408800(local_a0);

      goto LAB_0058fc11;

    }

  }

LAB_0058fc16:

  FUN_0042dc80();

  FUN_0042cbe0(&local_b4,1);

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  puVar3 = (undefined4 *)(local_b4 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_b4 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

LAB_0058fc6a:

  if (*(int *)(param_1 + 8) == DAT_00871ed4) {

    DAT_00871ed4 = 0;

    DAT_00871ed0 = 0;

    _DAT_00871ed8 = 0;

    _DAT_00871edc = 0;

  }

  thunk_FUN_00693860(*(undefined4 *)(param_1 + 8));

  return;

}





// --- FUN_0058fce0 at 0x0058FCE0 (size: 11) ---


bool __fastcall FUN_0058fce0(int param_1)



{

  return *(int *)(param_1 + 0x6c) != 0;

}





// --- FUN_0058fcf0 at 0x0058FCF0 (size: 17) ---


undefined4 __fastcall FUN_0058fcf0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x6c) != 0) {

    uVar1 = FUN_00596420();

    return uVar1;

  }

  return 0;

}





// --- FUN_0058fd10 at 0x0058FD10 (size: 17) ---


undefined4 __fastcall FUN_0058fd10(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x6c) != 0) {

    uVar1 = FUN_00596470();

    return uVar1;

  }

  return 0;

}





// --- FUN_0058fd30 at 0x0058FD30 (size: 11) ---


bool __fastcall FUN_0058fd30(int param_1)



{

  return *(int *)(param_1 + 0x70) != 0;

}





// --- FUN_0058fd40 at 0x0058FD40 (size: 17) ---


undefined4 __fastcall FUN_0058fd40(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) != 0) {

    uVar1 = FUN_00594df0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0058fd60 at 0x0058FD60 (size: 15) ---


undefined4 __fastcall FUN_0058fd60(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_00595c50();

  return uVar1;

}





// --- FUN_0058fd70 at 0x0058FD70 (size: 15) ---


undefined4 __fastcall FUN_0058fd70(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_00595c70();

  return uVar1;

}





// --- FUN_0058fd80 at 0x0058FD80 (size: 17) ---


undefined4 __fastcall FUN_0058fd80(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_005953b0();

  return uVar1;

}





// --- FUN_0058fda0 at 0x0058FDA0 (size: 17) ---


undefined4 __fastcall FUN_0058fda0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_00595350();

  return uVar1;

}





// --- FUN_0058fdc0 at 0x0058FDC0 (size: 17) ---


undefined4 __fastcall FUN_0058fdc0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_005959b0();

  return uVar1;

}





// --- FUN_0058fde0 at 0x0058FDE0 (size: 63) ---


void __thiscall FUN_0058fde0(int param_1,undefined4 param_2)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    iVar1 = FUN_005df0f5(0x1c);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_00594820();

    }

    *(int *)(param_1 + 0x70) = iVar1;

    if (iVar1 == 0) {

      return;

    }

  }

  FUN_00594ce0(param_2);

  return;

}





// --- FUN_0058fe20 at 0x0058FE20 (size: 63) ---


void __thiscall FUN_0058fe20(int param_1,undefined4 param_2)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    iVar1 = FUN_005df0f5(0x1c);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_00594820();

    }

    *(int *)(param_1 + 0x70) = iVar1;

    if (iVar1 == 0) {

      return;

    }

  }

  FUN_00594dc0(param_2);

  return;

}





// --- FUN_0058fe60 at 0x0058FE60 (size: 17) ---


undefined4 __fastcall FUN_0058fe60(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_00594770();

  return uVar1;

}





// --- FUN_0058fe80 at 0x0058FE80 (size: 19) ---


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



float10 __fastcall FUN_0058fe80(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return (float10)_DAT_007938b0;

  }

  fVar1 = (float10)FUN_00594790();

  return fVar1;

}





// --- FUN_0058fea0 at 0x0058FEA0 (size: 17) ---


undefined4 __fastcall FUN_0058fea0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_005953e0();

  return uVar1;

}





// --- FUN_0058fec0 at 0x0058FEC0 (size: 17) ---


undefined4 __fastcall FUN_0058fec0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_005954e0();

  return uVar1;

}





// --- FUN_0058fee0 at 0x0058FEE0 (size: 17) ---


undefined4 __fastcall FUN_0058fee0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x70) == 0) {

    return 0;

  }

  uVar1 = FUN_00595620();

  return uVar1;

}





// --- FUN_0058ff60 at 0x0058FF60 (size: 144) ---


uint FUN_0058ff60(float *param_1)



{

  uint uVar1;

  undefined4 uVar2;

  float10 fVar3;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_8 = 10;

  local_4 = 0;

  uVar1 = FUN_00592700(1,&local_8,0);

  local_c = 0;

  FUN_00590c20(0xe6,&local_c,0,0);

  uVar2 = FUN_004fd7a0(local_8,local_c);

  FUN_00590c20(5,&local_4,0,0);

  fVar3 = (float10)FUN_004fd7e0(uVar2,local_4);

  *param_1 = (float)fVar3;

  return uVar1 | 1;

}





// --- FUN_0058fff0 at 0x0058FFF0 (size: 60) ---


void __fastcall FUN_0058fff0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5450;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = &PTR_FUN_007e543c;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  return;

}





