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

// --- FUN_00540030 at 0x00540030 (size: 44) ---


void FUN_00540030(undefined4 *param_1,int param_2,int param_3,int param_4)



{

  if (param_4 == 0) {

    param_2 = param_2 * param_3;

    if (param_2 != 0) {

      for (; param_2 != 0; param_2 = param_2 + -1) {

        *param_1 = 0xff00;

        param_1 = param_1 + 1;

      }

    }

    return;

  }

  FUN_0053f4a0();

  return;

}





// --- FUN_00540060 at 0x00540060 (size: 149) ---


undefined4 __thiscall FUN_00540060(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  char cVar3;

  int iVar4;

  int iVar5;

  

  piVar1 = *(int **)(param_1 + 100);

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

    iVar5 = 0;

  }

  else {

    iVar5 = piVar1[0x37];

  }

  iVar2 = *(int *)(param_2 + 100);

  if (iVar2 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = *(int *)(iVar2 + 0xdc);

  }

  if (iVar5 == iVar4) {

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

      iVar5 = 0;

    }

    else {

      iVar5 = piVar1[0x28];

    }

    if (iVar2 == 0) {

      iVar4 = 0;

    }

    else {

      iVar4 = *(int *)(iVar2 + 0xa0);

    }

    if (iVar5 == iVar4) {

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

        iVar5 = 0;

      }

      else {

        iVar5 = piVar1[0x29];

      }

      if (iVar2 == 0) {

        iVar4 = 0;

      }

      else {

        iVar4 = *(int *)(iVar2 + 0xa4);

      }

      if (((iVar5 == iVar4) && (piVar1 != (int *)0x0)) && (iVar2 != 0)) {

        cVar3 = (**(code **)(*piVar1 + 0x68))(iVar2);

        if (cVar3 != '\0') {

          FUN_0053fb10();

          return 1;

        }

      }

    }

  }

  return 0;

}





// --- FUN_00540160 at 0x00540160 (size: 91) ---


undefined1 __thiscall FUN_00540160(int *param_1,uint param_2,undefined4 param_3)



{

  char cVar1;

  uint uVar2;

  

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    uVar2 = param_2;

    if ((char)param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_00415910(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else {

    uVar2 = param_2;

    if (param_2 < (uint)param_1[2]) {

      do {

        *(undefined4 *)(*param_1 + uVar2 * 4) = param_3;

        uVar2 = uVar2 + 1;

      } while (uVar2 < (uint)param_1[2]);

    }

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_005401c0 at 0x005401C0 (size: 100) ---


undefined4 * __thiscall FUN_005401c0(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(DAT_008467e8);

  FUN_00447220();

  *param_1 = &PTR_LAB_007cab18;

  param_1[0xc] = &PTR_LAB_007cab04;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  *(undefined1 *)(param_1 + 0x21) = 0;

  FUN_0053ffd0(param_2);

  return param_1;

}





// --- FUN_00540240 at 0x00540240 (size: 80) ---


undefined4 FUN_00540240(void)



{

  char cVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int *piVar4;

  undefined1 local_c [12];

  

  cVar1 = FUN_00413a70();

  if (cVar1 != '\0') {

    puVar2 = (undefined4 *)FUN_0053fe40(local_c);

    uVar3 = FUN_004220b0(*puVar2,0xc);

    piVar4 = (int *)FUN_00415430(uVar3);

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

      FUN_0053ffd0(piVar4);

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

    }

  }

  return 1;

}





// --- FUN_00540390 at 0x00540390 (size: 73) ---


void __fastcall FUN_00540390(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_00540670(*puVar2);

  return;

}





// --- FUN_005403e0 at 0x005403E0 (size: 143) ---


undefined4 * __thiscall FUN_005403e0(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_007caaf8;

  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_00540470 at 0x00540470 (size: 143) ---


undefined4 * __thiscall FUN_00540470(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_007caafc;

  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_00540500 at 0x00540500 (size: 143) ---


undefined4 * __thiscall FUN_00540500(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_007cab00;

  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_00540590 at 0x00540590 (size: 143) ---


undefined4 * __thiscall FUN_00540590(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_007caaf4;

  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_00540620 at 0x00540620 (size: 73) ---


void __fastcall FUN_00540620(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_005408c0(*puVar2);

  return;

}





// --- FUN_00540670 at 0x00540670 (size: 310) ---


undefined4 __thiscall FUN_00540670(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_00540670(*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_005406bf;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_005406bf:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_005406d2:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

      if (puVar6 == (uint *)0x0) goto LAB_005406d2;

      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_005407b0 at 0x005407B0 (size: 120) ---


uint __thiscall FUN_005407b0(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_005407db:

      if ((int)(*(uint *)(param_1 + 0x68) * 2) < *(int *)(param_1 + 0x6c) + 1) {

        FUN_00540390();

      }

      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_005407db;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00540830 at 0x00540830 (size: 64) ---


void __thiscall FUN_00540830(int param_1,undefined4 param_2,int *param_3,int param_4)



{

  int iVar1;

  int iVar2;

  

  iVar2 = *param_3;

  if (iVar2 != param_4) {

    do {

      iVar1 = iVar2;

      iVar2 = *(int *)(iVar1 + 8);

    } while (iVar2 != param_4);

    if (iVar1 != 0) {

      *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar2 + 8);

      *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

      return;

    }

  }

  *param_3 = *(int *)(iVar2 + 8);

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

  return;

}





// --- FUN_00540870 at 0x00540870 (size: 76) ---


void __thiscall FUN_00540870(int param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_00540620();

  }

  iVar2 = __aullrem(*param_2,param_2[1],*(undefined4 *)(param_1 + 0x68),0);

  puVar1 = (undefined4 *)(*(int *)(param_1 + 0x60) + iVar2 * 4);

  param_2[2] = *(undefined4 *)(*(int *)(param_1 + 0x60) + iVar2 * 4);

  *puVar1 = param_2;

  if (puVar1 < *(undefined4 **)(param_1 + 100)) {

    *(undefined4 **)(param_1 + 100) = puVar1;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return;

}





// --- FUN_005408c0 at 0x005408C0 (size: 321) ---


undefined4 __thiscall FUN_005408c0(int param_1,int param_2)



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  int iVar5;

  undefined4 *puVar6;

  int *piVar7;

  

  iVar5 = param_2;

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

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

  puVar2 = (undefined4 *)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(iVar5);

      puVar6 = (undefined4 *)PTR_DAT_00818558;

      iVar5 = param_2;

      while (puVar2 != (undefined4 *)0x0) {

        param_2 = *(int *)(param_1 + 0x68);

        puVar3 = (undefined4 *)puVar2[2];

        PTR_DAT_00818558 = (undefined *)puVar6;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar4 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar6,&param_2,param_2,0);

          if ((puVar4 != puVar6) || (puVar4 = puVar4 + -1, puVar4 != puVar6)) {

            puVar4 = puVar4 + 1;

          }

          FUN_005408c0(*puVar4);

          iVar5 = param_2;

        }

        param_2 = iVar5;

        iVar5 = __aullrem(*puVar2,puVar2[1],*(undefined4 *)(param_1 + 0x68),0);

        puVar6 = (undefined4 *)(*(int *)(param_1 + 0x60) + iVar5 * 4);

        puVar2[2] = *(undefined4 *)(*(int *)(param_1 + 0x60) + iVar5 * 4);

        *puVar6 = puVar2;

        if (puVar6 < *(undefined4 **)(param_1 + 100)) {

          *(undefined4 **)(param_1 + 100) = puVar6;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar6 = (undefined4 *)PTR_DAT_00818558;

        iVar5 = param_2;

        puVar2 = puVar3;

      }

      PTR_DAT_00818558 = (undefined *)puVar6;

      return 1;

    }

    piVar7 = *(int **)(param_1 + 100);

    while (piVar7 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar7 = *(int **)(param_1 + 100);

        puVar6 = (undefined4 *)*piVar7;

        goto LAB_0054090f;

      }

      piVar7 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar7;

    }

    piVar7 = (int *)0x0;

    puVar6 = (undefined4 *)0x0;

LAB_0054090f:

    puVar3 = (undefined4 *)*piVar7;

    if (puVar3 == puVar6) {

LAB_00540922:

      *piVar7 = puVar3[2];

    }

    else {

      do {

        puVar4 = puVar3;

        puVar3 = (undefined4 *)puVar4[2];

      } while (puVar3 != puVar6);

      if (puVar4 == (undefined4 *)0x0) goto LAB_00540922;

      puVar4[2] = puVar3[2];

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    puVar6[2] = puVar2;

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

    puVar2 = puVar6;

  } while( true );

}





// --- FUN_00540a10 at 0x00540A10 (size: 111) ---


undefined4 __thiscall FUN_00540a10(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_00540a3b:

      puVar1 = (uint *)FUN_005df0f5(8);

      if (puVar1 != (uint *)0x0) {

        *puVar1 = *param_2;

        puVar1[1] = 0;

        FUN_005407b0(puVar1);

        return 1;

      }

      FUN_005407b0(0);

      return 1;

    }

    if (*puVar1 == *param_2) {

      if (puVar1 != (uint *)0x0) {

        return 0;

      }

      goto LAB_00540a3b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00540a80 at 0x00540A80 (size: 82) ---


undefined4 * __thiscall FUN_00540a80(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cab70;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007caaf8;

  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_00540ae0 at 0x00540AE0 (size: 82) ---


undefined4 * __thiscall FUN_00540ae0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cab74;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007caafc;

  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_00540b40 at 0x00540B40 (size: 50) ---


undefined4 * __thiscall FUN_00540b40(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cab78;

  FUN_005870f0();

  FUN_0053fea0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00540b80 at 0x00540B80 (size: 124) ---


int * FUN_00540b80(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  int *piVar3;

  int *piVar4;

  int *local_4;

  

  iVar2 = FUN_005df0f5(0x88);

  if (iVar2 == 0) {

    piVar3 = (int *)0x0;

  }

  else {

    piVar3 = (int *)FUN_005401c0(0);

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

      return (int *)0x0;

    }

    local_4 = piVar3;

    FUN_00540a10(&local_4);

  }

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

    return (int *)0x0;

  }

  piVar4 = (int *)(**(code **)(*DAT_00870340 + 0xc))();

  piVar3[0x19] = (int)piVar4;

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

     (cVar1 = (**(code **)(*piVar4 + 0x58))(param_1,param_2,param_3,1), cVar1 != '\0')) {

    return piVar3;

  }

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

  return (int *)0x0;

}





// --- FUN_00540c00 at 0x00540C00 (size: 122) ---


undefined4 FUN_00540c00(undefined4 *param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  undefined1 local_c [8];

  int local_4;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x18);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    *puVar1 = *param_1;

    puVar1[1] = param_1[1];

    puVar1[2] = 0;

    puVar1[4] = *param_2;

  }

  FUN_0054b460(local_c,puVar1);

  if (local_4 == 0) {

    FUN_00540870(puVar1);

    return 1;

  }

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

    operator_delete(puVar1);

  }

  return 0;

}





// --- FUN_00540c80 at 0x00540C80 (size: 82) ---


undefined4 * __thiscall FUN_00540c80(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cab7c;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_007caaf4;

  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_00540ce0 at 0x00540CE0 (size: 216) ---


void __fastcall FUN_00540ce0(undefined4 *param_1)



{

  int *piVar1;

  void *pvVar2;

  undefined4 *puStack_4;

  

  *param_1 = &PTR_LAB_007cab18;

  param_1[0xc] = &PTR_LAB_007cab04;

  puStack_4 = param_1;

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

    (**(code **)(*(int *)param_1[0x19] + 0x14))();

    param_1[0x19] = 0;

  }

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

    (**(code **)(*(int *)param_1[0x1a] + 0x14))();

    param_1[0x1a] = 0;

  }

  piVar1 = (int *)param_1[0x1e];

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

    (**(code **)(*piVar1 + 8))(piVar1);

    param_1[0x1e] = 0;

  }

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

    (**(code **)(*(int *)param_1[0x1f] + 0x14))();

    param_1[0x1f] = 0;

  }

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

    (**(code **)(*(int *)param_1[0x20] + 0x14))();

    param_1[0x20] = 0;

  }

  if (param_1[0x1c] == 0 && param_1[0x1d] == 0) {

    puStack_4 = param_1;

    pvVar2 = (void *)FUN_004171e0(&puStack_4);

  }

  else {

    pvVar2 = (void *)FUN_0054b540(param_1 + 0x1c);

  }

  if (pvVar2 != (void *)0x0) {

    operator_delete(pvVar2);

  }

  if (((param_1[0x17] & 0x80000000) == 0x80000000) && (param_1[0x16] != 0)) {

    operator_delete__((void *)(param_1[0x16] + -4));

  }

  FUN_00446f00();

  FUN_004154b0();

  return;

}





// --- FUN_00540dc0 at 0x00540DC0 (size: 251) ---


uint FUN_00540dc0(int param_1,uint param_2,uint param_3)



{

  uint *puVar1;

  undefined4 *puVar2;

  uint uVar3;

  undefined4 *local_4;

  

  uVar3 = param_3;

  for (puVar1 = *(uint **)(DAT_0081f9f4 + (param_3 % DAT_0081f9fc) * 4); puVar1 != (uint *)0x0;

      puVar1 = (uint *)puVar1[1]) {

    if (*puVar1 == param_3) {

      if (puVar1 != (uint *)0x0) {

        puVar2 = (undefined4 *)puVar1[2];

        goto LAB_00540e2b;

      }

      break;

    }

  }

  puVar2 = (undefined4 *)FUN_005df0f5(0x74);

  if (puVar2 == (undefined4 *)0x0) {

    return 0;

  }

  *puVar2 = &PTR_FUN_007cab78;

  FUN_00540500(8);

  local_4 = puVar2;

  FUN_006891f0(&param_3,&local_4);

LAB_00540e2b:

  local_4 = (undefined4 *)(param_1 << 0x10 | param_2 & 0xffff);

  puVar1 = *(uint **)(puVar2[0x19] + ((uint)local_4 % (uint)puVar2[0x1b]) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_00540e6b:

      uVar3 = FUN_00540b80(param_1,param_2,uVar3);

      if (uVar3 != 0) {

        param_3 = uVar3;

        FUN_006891f0(&local_4,&param_3);

      }

      return uVar3;

    }

    if ((undefined4 *)*puVar1 == local_4) {

      if (puVar1 != (uint *)0x0) {

        return puVar1[2];

      }

      goto LAB_00540e6b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00540ec0 at 0x00540EC0 (size: 30) ---


void * __thiscall FUN_00540ec0(void *param_1,byte param_2)



{

  FUN_00540ce0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00540ee0 at 0x00540EE0 (size: 257) ---


undefined4 __thiscall FUN_00540ee0(int param_1,int param_2,undefined4 param_3,undefined4 param_4)



{

  char cVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  undefined4 uVar6;

  

  iVar5 = *(int *)(param_2 + 100);

  if ((iVar5 == 0) ||

     ((*(int *)(iVar5 + 0xdc) != 0x29 && ((iVar5 == 0 || (*(int *)(iVar5 + 0xdc) != 0x65)))))) {

    return 0;

  }

  uVar6 = *(undefined4 *)(iVar5 + 0xa4);

  uVar3 = *(undefined4 *)(iVar5 + 0xa0);

  iVar5 = 0x16 - (uint)((char)param_4 != '\0');

  piVar2 = (int *)(**(code **)(*DAT_00870340 + 0x10))();

  *(int **)(param_1 + 100) = piVar2;

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

     (cVar1 = (**(code **)(*piVar2 + 0x58))(uVar3,uVar6,iVar5,1), cVar1 != '\0')) {

    iVar4 = *(int *)(param_2 + 100);

    if (iVar4 == 0) {

      uVar6 = 0;

      uVar3 = 0;

    }

    else {

      uVar6 = *(undefined4 *)(iVar4 + 0xa4);

      uVar3 = *(undefined4 *)(iVar4 + 0xa0);

    }

    iVar5 = FUN_00540dc0(uVar3,uVar6,iVar5);

    if (iVar5 != 0) {

      iVar4 = FUN_0053f270();

      if (iVar4 != 0) {

        FUN_0053f9c0(iVar4,*(undefined4 *)(iVar5 + 0x6c),param_2,param_3,param_4);

        if (*(int **)(iVar5 + 100) != (int *)0x0) {

          *(undefined4 *)(iVar5 + 0x6c) = 0;

          (**(code **)(**(int **)(iVar5 + 100) + 100))();

          *(undefined1 *)(iVar5 + 0x84) = 0;

        }

        cVar1 = FUN_00540060(iVar5);

        if (cVar1 != '\0') {

          return 1;

        }

      }

    }

  }

  return 0;

}





// --- FUN_00540ff0 at 0x00540FF0 (size: 219) ---


undefined4 __thiscall

FUN_00540ff0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  char cVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 unaff_EBP;

  

  piVar3 = (int *)(**(code **)(*DAT_00870340 + 0x10))();

  *(int **)(param_1 + 100) = piVar3;

  if (((piVar3 == (int *)0x0) ||

      (cVar2 = (**(code **)(*piVar3 + 0x58))(param_3,param_4,0x16,1), cVar2 == '\0')) ||

     (iVar4 = FUN_00540dc0(param_3,param_4,0x16), iVar4 == 0)) {

    return 0;

  }

  iVar5 = FUN_0053f270();

  if (iVar5 != 0) {

    iVar1 = *(int *)(iVar4 + 100);

    if (iVar1 == 0) {

      uVar7 = 0;

      uVar6 = 0;

    }

    else {

      uVar7 = *(undefined4 *)(iVar1 + 0xa4);

      uVar6 = *(undefined4 *)(iVar1 + 0xa0);

    }

    FUN_0053f230(unaff_EBP,param_3,param_4,iVar5,uVar6,uVar7,*(undefined4 *)(iVar4 + 0x6c));

    if (*(int **)(iVar4 + 100) != (int *)0x0) {

      *(undefined4 *)(iVar4 + 0x6c) = 0;

      (**(code **)(**(int **)(iVar4 + 100) + 100))();

      *(undefined1 *)(iVar4 + 0x84) = 0;

    }

    cVar2 = FUN_00540060(iVar4);

    if (cVar2 != '\0') {

      return 1;

    }

  }

  return 0;

}





// --- FUN_005410d0 at 0x005410D0 (size: 241) ---


int * FUN_005410d0(int param_1,int *param_2,undefined4 param_3)



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int *piVar6;

  int local_1c;

  int local_18;

  int local_14;

  int local_10;

  undefined1 local_c [8];

  int local_4;

  

  iVar1 = (int)param_2;

  iVar5 = 0;

  iVar4 = 0;

  if (*(int *)((int)param_2 + 0x20) != 0) {

    iVar5 = *(int *)((int)param_2 + 0x28);

    iVar4 = *(int *)(param_1 + 0x28);

  }

  piVar6 = (int *)0x0;

  local_1c = iVar5;

  local_18 = iVar4;

  local_14 = iVar5;

  local_10 = iVar4;

  FUN_0054b460(local_c,&local_1c);

  if (local_4 != 0) {

    piVar6 = *(int **)(local_4 + 0x10);

    (**(code **)(*piVar6 + 0x10))();

  }

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

    iVar3 = FUN_005df0f5(0x88);

    if (iVar3 == 0) {

      return (int *)0x0;

    }

    piVar6 = (int *)FUN_005401c0(0);

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

      param_2 = piVar6;

      cVar2 = FUN_00540ee0(param_1,iVar1,param_3);

      if (cVar2 == '\0') {

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

        return (int *)0x0;

      }

      if (iVar5 == 0 && iVar4 == 0) {

        FUN_00540a10(&param_2);

        return piVar6;

      }

      piVar6[0x1c] = iVar5;

      piVar6[0x1d] = iVar4;

      FUN_00540c00(&local_14,&param_2);

    }

  }

  return piVar6;

}





// --- FUN_005411d0 at 0x005411D0 (size: 110) ---


int * FUN_005411d0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  int *piVar3;

  int *local_4;

  

  iVar2 = FUN_005df0f5(0x88);

  if (iVar2 == 0) {

    return (int *)0x0;

  }

  piVar3 = (int *)FUN_005401c0(0);

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

    DAT_00846784 = 0;

    local_4 = piVar3;

    cVar1 = FUN_00540ff0(param_1,param_2,param_3);

    if (cVar1 == '\0') {

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

      return (int *)0x0;

    }

    FUN_00540a10(&local_4);

  }

  return piVar3;

}





// --- FUN_00541240 at 0x00541240 (size: 54) ---


bool __thiscall FUN_00541240(int *param_1,uint param_2)



{

  int iVar1;

  

  if ((uint)param_1[1] < param_2) {

    operator_delete__((void *)*param_1);

    param_1[1] = param_2;

    iVar1 = thunk_FUN_005df0f5(param_2);

    *param_1 = iVar1;

  }

  param_1[2] = param_2;

  return *param_1 != 0;

}





// --- FUN_00541280 at 0x00541280 (size: 130) ---


undefined4 FUN_00541280(int param_1,undefined4 *param_2,uint param_3,int *param_4,int *param_5)



{

  uint uVar1;

  undefined4 *puVar2;

  

  if (param_3 == 0) {

    return 0;

  }

  if (param_1 != 0) {

    if (param_1 == 1) {

      puVar2 = (undefined4 *)*param_4;

      for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {

        *puVar2 = *param_2;

        param_2 = param_2 + 1;

        puVar2 = puVar2 + 1;

      }

      for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {

        *(undefined1 *)puVar2 = *(undefined1 *)param_2;

        param_2 = (undefined4 *)((int)param_2 + 1);

        puVar2 = (undefined4 *)((int)puVar2 + 1);

      }

      *param_4 = *param_4 + param_3;

      *param_5 = *param_5 - param_3;

      return 1;

    }

    if (param_1 != 2) {

      return 0;

    }

    puVar2 = (undefined4 *)*param_4;

    for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {

      *param_2 = *puVar2;

      puVar2 = puVar2 + 1;

      param_2 = param_2 + 1;

    }

    for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {

      *(undefined1 *)param_2 = *(undefined1 *)puVar2;

      puVar2 = (undefined4 *)((int)puVar2 + 1);

      param_2 = (undefined4 *)((int)param_2 + 1);

    }

    *param_4 = *param_4 + param_3;

  }

  *param_5 = *param_5 - param_3;

  return 1;

}





// --- FUN_00541380 at 0x00541380 (size: 20) ---


void __thiscall FUN_00541380(int *param_1,undefined4 param_2)



{

  (**(code **)(*param_1 + 0x14))(2,param_2,&stack0x00000008);

  return;

}





// --- FUN_005413a0 at 0x005413A0 (size: 130) ---


undefined4 FUN_005413a0(int param_1,undefined4 *param_2,int *param_3,uint *param_4)



{

  undefined4 *puVar1;

  

  if (param_1 == 0) {

    *param_4 = *param_4 - 4;

    return 1;

  }

  if (param_1 == 1) {

    if (3 < *param_4) {

      *(undefined4 *)*param_3 = *param_2;

      *param_3 = *param_3 + 4;

    }

    *param_4 = *param_4 - 4;

    return 1;

  }

  if (param_1 != 2) {

    return 0;

  }

  puVar1 = (undefined4 *)*param_3;

  if (*param_4 < 4) {

    *param_4 = *param_4;

    return 0;

  }

  *param_2 = *puVar1;

  *param_3 = *param_3 + 4;

  *param_4 = (int)puVar1 + (*param_4 - *param_3);

  return 1;

}





// --- FUN_00541430 at 0x00541430 (size: 106) ---


undefined4 __thiscall FUN_00541430(undefined4 *param_1,int param_2,undefined4 param_3,uint *param_4)



{

  uint *puVar1;

  int iVar2;

  

  puVar1 = param_1 + 2;

  iVar2 = FUN_005413a0(param_2,puVar1,param_3,param_4);

  if (iVar2 == 0) {

    return 0;

  }

  if (param_2 == 2) {

    if (*param_4 < *puVar1) {

      return 0;

    }

    FUN_00541240(*puVar1);

  }

  if ((*puVar1 != 0) && (iVar2 = FUN_00541280(param_2,*param_1,*puVar1,param_3,param_4), iVar2 == 0)

     ) {

    return 0;

  }

  return 1;

}





// --- FUN_005414a0 at 0x005414A0 (size: 103) ---


undefined4 * __fastcall FUN_005414a0(undefined4 *param_1)



{

  LONG *pLVar1;

  

  *param_1 = &PTR_FUN_007cab98;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[4] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[8] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  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;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  return param_1;

}





// --- FUN_00541550 at 0x00541550 (size: 25) ---


void FUN_00541550(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  FUN_00541430(param_1,param_3,param_4);

  return;

}





// --- FUN_00541570 at 0x00541570 (size: 30) ---


void * __thiscall FUN_00541570(void *param_1,byte param_2)



{

  FUN_00411e10();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00541590 at 0x00541590 (size: 163) ---


undefined4 FUN_00541590(int param_1,int *param_2,int *param_3,int *param_4)



{

  undefined4 uVar1;

  int iVar2;

  uint uVar3;

  

  if (param_1 == 0) {

    uVar3 = *(int *)(*param_2 + 8) - 1;

    iVar2 = 0;

    if (0xfffe < uVar3) {

      iVar2 = 4;

    }

    uVar3 = iVar2 + 2 + uVar3;

    if ((uVar3 & 3) != 0) {

      *param_4 = *param_4 - ((4 - (uVar3 & 3)) + uVar3);

      return 1;

    }

    *param_4 = *param_4 - uVar3;

    return 1;

  }

  if (param_1 == 1) {

    iVar2 = FUN_004fd290(param_3,*param_4);

    *param_4 = *param_4 - iVar2;

    return 1;

  }

  if (param_1 != 2) {

    return 0;

  }

  iVar2 = *param_3;

  uVar1 = FUN_004fd460(param_3,*param_4);

  *param_4 = *param_4 + (iVar2 - *param_3);

  return uVar1;

}





// --- FUN_00541640 at 0x00541640 (size: 121) ---


undefined4 __thiscall

FUN_00541640(int param_1,undefined4 param_2,int *param_3,uint param_4,undefined4 *param_5)



{

  undefined4 uVar1;

  uint uVar2;

  undefined4 *puVar3;

  

  *(undefined4 *)(param_1 + 4) = param_2;

  FUN_004034c0(*param_3 + 0x14);

  *(int *)(param_1 + 0x14) = param_3[1];

  *(int *)(param_1 + 0x18) = param_3[2];

  *(int *)(param_1 + 0x1c) = param_3[3];

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

    if (*(uint *)(param_1 + 0x40) < param_4) {

      operator_delete__(*(void **)(param_1 + 0x3c));

      *(uint *)(param_1 + 0x40) = param_4;

      uVar1 = thunk_FUN_005df0f5(param_4);

      *(undefined4 *)(param_1 + 0x3c) = uVar1;

    }

    *(uint *)(param_1 + 0x44) = param_4;

    puVar3 = *(undefined4 **)(param_1 + 0x3c);

    for (uVar2 = param_4 >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

      *puVar3 = *param_5;

      param_5 = param_5 + 1;

      puVar3 = puVar3 + 1;

    }

    for (param_4 = param_4 & 3; param_4 != 0; param_4 = param_4 - 1) {

      *(undefined1 *)puVar3 = *(undefined1 *)param_5;

      param_5 = (undefined4 *)((int)param_5 + 1);

      puVar3 = (undefined4 *)((int)puVar3 + 1);

    }

  }

  return 1;

}





// --- FUN_005416c0 at 0x005416C0 (size: 171) ---


bool __thiscall FUN_005416c0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  

  iVar1 = FUN_005413a0(param_2,param_1 + 4,param_3,param_4);

  if ((((iVar1 != 0) && (iVar1 = FUN_005413a0(param_2,param_1 + 8,param_3,param_4), iVar1 != 0)) &&

      (iVar1 = FUN_005413a0(param_2,param_1 + 0xc,param_3,param_4), iVar1 != 0)) &&

     (iVar1 = FUN_00541590(param_2,param_1 + 0x10,param_3,param_4), iVar1 != 0)) {

    if (((*(byte *)(param_1 + 8) & 2) != 0) &&

       (iVar1 = FUN_00541590(param_2,param_1 + 0x20,param_3,param_4), iVar1 == 0)) {

      return false;

    }

    iVar1 = FUN_00541430(param_2,param_3,param_4);

    if (iVar1 != 0) {

      iVar1 = FUN_00541550(param_2,param_1 + 0x3c,param_3,param_4);

      return iVar1 != 0;

    }

  }

  return false;

}





// --- FUN_00541770 at 0x00541770 (size: 6) ---


undefined4 FUN_00541770(void)



{

  return DAT_00846f08;

}





// --- FUN_00541780 at 0x00541780 (size: 21) ---


undefined4 __thiscall FUN_00541780(int param_1,ushort param_2,undefined4 param_3)



{

  *(undefined4 *)(param_1 + 0x10 + (uint)param_2 * 4) = param_3;

  return 1;

}





// --- FUN_005417a0 at 0x005417A0 (size: 39) ---


void __thiscall FUN_005417a0(int param_1,int param_2)



{

  if (*(int *)(param_2 + 0x380) == 0) {

    *(undefined4 *)(param_2 + 0x380) = 1;

    *(undefined4 *)(param_2 + 0x378) = *(undefined4 *)(param_1 + 0x40);

    *(int *)(param_1 + 0x40) = param_2;

  }

  return;

}





// --- FUN_005417d0 at 0x005417D0 (size: 48) ---


bool __thiscall FUN_005417d0(int param_1,undefined4 param_2,ushort param_3)



{

  bool bVar1;

  

  (**(code **)(**(int **)(param_1 + 0x6c) + 0xc))();

  bVar1 = *(int *)(*(int *)(param_1 + 0xc) + (uint)param_3 * 4) != 0;

  if (bVar1) {

    FUN_005479e0(param_2);

  }

  return bVar1;

}





// --- FUN_00541800 at 0x00541800 (size: 14) ---


undefined4 __thiscall FUN_00541800(int param_1,ushort param_2)



{

  return *(undefined4 *)(*(int *)(param_1 + 0xc) + (uint)param_2 * 4);

}





// --- FUN_00541810 at 0x00541810 (size: 44) ---


undefined4 * __thiscall FUN_00541810(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cabd8;

  operator_delete__((void *)param_1[1]);

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00541840 at 0x00541840 (size: 224) ---


void __thiscall FUN_00541840(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  int iVar8;

  int iVar9;

  

  iVar9 = *(int *)(param_1 + 4) + -0x10;

  while( true ) {

    iVar3 = param_2 * 2 + 1;

    if ((*(int *)(param_1 + 8) < param_2 * 2) ||

       (iVar8 = param_2 * 2,

       *(double *)(param_2 * 0x10 + iVar9) <= *(double *)(param_2 * 0x20 + iVar9))) {

      iVar8 = param_2;

    }

    if ((iVar3 <= *(int *)(param_1 + 8)) &&

       (*(double *)(iVar3 * 0x10 + iVar9) < *(double *)(iVar8 * 0x10 + iVar9))) {

      iVar8 = iVar3;

    }

    if (iVar8 == param_2) break;

    puVar1 = (undefined4 *)(param_2 * 0x10 + iVar9);

    uVar4 = *puVar1;

    uVar5 = puVar1[1];

    uVar6 = puVar1[2];

    uVar7 = puVar1[3];

    puVar2 = (undefined4 *)(iVar8 * 0x10 + iVar9);

    *puVar1 = *puVar2;

    puVar1[1] = puVar2[1];

    puVar1[2] = puVar2[2];

    puVar1[3] = puVar2[3];

    *puVar2 = uVar4;

    puVar2[1] = uVar5;

    puVar2[2] = uVar6;

    puVar2[3] = uVar7;

    param_2 = iVar8;

  }

  return;

}





// --- FUN_00541920 at 0x00541920 (size: 134) ---


void __fastcall FUN_00541920(undefined4 *param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int iVar4;

  

  *param_1 = &PTR_LAB_007cabdc;

  iVar4 = 0;

  do {

    pvVar1 = *(void **)(iVar4 + param_1[3]);

    if (pvVar1 != (void *)0x0) {

      FUN_00547b00();

      operator_delete(pvVar1);

    }

    iVar4 = iVar4 + 4;

  } while (iVar4 < 0x400);

  operator_delete__((void *)param_1[3]);

  DAT_00846f08 = 0;

  puVar2 = (undefined4 *)param_1[0x1b];

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  param_1[0x1b] = 0;

  param_1[0x11] = &PTR_FUN_007cabd8;

  operator_delete__((void *)param_1[0x12]);

  return;

}





// --- FUN_005419f0 at 0x005419F0 (size: 56) ---


bool FUN_005419f0(ushort param_1,undefined4 param_2)



{

  bool bVar1;

  

  bVar1 = *(int *)((uint)param_1 * 4 + *(int *)(DAT_00846f08 + 0xc)) != 0;

  if (bVar1) {

    FUN_00548230(param_2);

  }

  return bVar1;

}





// --- FUN_00541a30 at 0x00541A30 (size: 121) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if ((0 < *(int *)(param_1 + 8)) &&

     (puVar1 = *(undefined4 **)(param_1 + 4), puVar1 != (undefined4 *)0x0)) {

    *param_2 = *puVar1;

    param_2[1] = puVar1[1];

    *param_3 = *(undefined4 *)(*(int *)(param_1 + 4) + 8);

    if (1 < *(int *)(param_1 + 8)) {

      puVar1 = *(undefined4 **)(param_1 + 4);

      iVar2 = *(int *)(param_1 + 8) + -1;

      *(int *)(param_1 + 8) = iVar2;

      puVar3 = puVar1 + iVar2 * 4;

      *puVar1 = *puVar3;

      puVar1[1] = puVar3[1];

      puVar1[2] = puVar3[2];

      puVar1[3] = puVar3[3];

      FUN_00541840(1);

      return 1;

    }

    *(undefined4 *)(param_1 + 8) = 0;

    FUN_00541840(1);

    return 1;

  }

  return 0;

}





// --- FUN_00541ab0 at 0x00541AB0 (size: 273) ---


undefined4 __thiscall FUN_00541ab0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  int iVar8;

  

  iVar5 = *(int *)(param_1 + 8);

  iVar1 = iVar5 + -1;

  if (-1 < iVar1) {

    piVar3 = (int *)(iVar1 * 0x10 + 8 + *(int *)(param_1 + 4));

    do {

      if (*piVar3 == param_2) {

        iVar1 = iVar1 + 1;

        iVar4 = iVar1 >> 1;

        iVar8 = *(int *)(param_1 + 4) + -0x10;

        if ((iVar4 < 1) ||

           (iVar2 = iVar4 * 0x10, *(double *)(iVar2 + iVar8) <= *(double *)(iVar5 * 0x10 + iVar8)))

        {

          puVar7 = (undefined4 *)(iVar5 * 0x10 + iVar8);

          puVar6 = (undefined4 *)(iVar1 * 0x10 + iVar8);

          *puVar6 = *puVar7;

          puVar6[1] = puVar7[1];

          puVar6[2] = puVar7[2];

          puVar6[3] = puVar7[3];

          iVar5 = *(int *)(param_1 + 8) + -1;

          *(int *)(param_1 + 8) = iVar5;

          if (iVar1 < iVar5) {

            FUN_00541840(iVar1);

          }

          return 1;

        }

        goto LAB_00541b11;

      }

      iVar1 = iVar1 + -1;

      piVar3 = piVar3 + -4;

    } while (-1 < iVar1);

  }

  return 0;

  while (iVar2 = iVar4 * 0x10, iVar1 = iVar5,

        *(double *)(*(int *)(param_1 + 8) * 0x10 + iVar8) < *(double *)(iVar2 + iVar8)) {

LAB_00541b11:

    iVar5 = iVar4;

    puVar7 = (undefined4 *)(iVar2 + iVar8);

    puVar6 = (undefined4 *)(iVar1 * 0x10 + iVar8);

    *puVar6 = *puVar7;

    puVar6[1] = puVar7[1];

    puVar6[2] = puVar7[2];

    puVar6[3] = puVar7[3];

    iVar4 = iVar5 >> 1;

    if (iVar4 < 1) break;

  }

  puVar6 = (undefined4 *)(*(int *)(param_1 + 8) * 0x10 + iVar8);

  puVar7 = (undefined4 *)(iVar5 * 0x10 + iVar8);

  *puVar7 = *puVar6;

  puVar7[1] = puVar6[1];

  puVar7[2] = puVar6[2];

  puVar7[3] = puVar6[3];

  *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + -1;

  return 1;

}





// --- FUN_00541bd0 at 0x00541BD0 (size: 217) ---


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



void __fastcall FUN_00541bd0(int param_1)



{

  int iVar1;

  int local_20;

  int local_1c;

  double local_18;

  undefined4 local_10;

  undefined4 uStack_c;

  

  local_10 = DAT_008379a8;

  uStack_c = DAT_008379ac;

  while ((0 < *(int *)(param_1 + 0x4c) && (*(double **)(param_1 + 0x48) != (double *)0x0))) {

    local_18 = **(double **)(param_1 + 0x48);

    if ((double)CONCAT44(uStack_c,local_10) < local_18) {

      return;

    }

    FUN_00541a30(&local_18,&local_20);

    iVar1 = local_20;

    if (*(int *)(local_20 + 0x380) == 0) {

      *(undefined4 *)(local_20 + 0x380) = 1;

      *(undefined4 *)(local_20 + 0x378) = *(undefined4 *)(param_1 + 0x40);

      *(int *)(param_1 + 0x40) = local_20;

    }

    local_1c = FUN_005df4c4();

    local_1c = 1 - local_1c;

    local_18 = (double)local_1c * _DAT_00799088 + local_18;

    FUN_00508470(local_18,iVar1);

  }

  return;

}





// --- FUN_00541cb0 at 0x00541CB0 (size: 85) ---


void __fastcall FUN_00541cb0(int param_1)



{

  ushort uVar1;

  int iVar2;

  

  FUN_00541bd0();

  while( true ) {

    iVar2 = *(int *)(param_1 + 0x40);

    if (iVar2 == 0) {

      return;

    }

    uVar1 = *(ushort *)(iVar2 + 0x37c);

    *(undefined4 *)(iVar2 + 0x380) = 0;

    *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(*(int *)(param_1 + 0x40) + 0x378);

    if (uVar1 == 0) break;

    if (*(int *)((uint)uVar1 * 4 + *(int *)(DAT_00846f08 + 0xc)) != 0) {

      FUN_00547a00();

    }

  }

  return;

}





// --- FUN_00541d10 at 0x00541D10 (size: 355) ---


undefined4 __thiscall

FUN_00541d10(int param_1,uint param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5,

            undefined4 param_6,int param_7,float param_8,undefined4 param_9,int param_10)



{

  int iVar1;

  undefined4 *puVar2;

  char *pcVar3;

  int iVar4;

  undefined4 uVar5;

  LONG LVar6;

  char *pcVar7;

  uint uVar8;

  undefined4 *local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_c = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_005ab580(&param_3,&local_c,0);

  iVar1 = param_7;

  pcVar7 = "TRUE";

  if (param_10 == 0) {

    pcVar7 = "FALSE";

  }

  pcVar3 = "TRUE";

  if (param_7 == 0) {

    pcVar3 = "FALSE";

  }

  uVar8 = param_2 & 0xffff;

  local_8 = 5;

  local_4 = 0;

  FUN_0040f4a0(&local_8,"PacketController::AddRecipient(%ld %s %f 0x%08X admin=%s) %s\n",uVar8,

               pcVar3,(double)param_8,param_9,pcVar7,local_c + 5);

  puVar2 = local_c;

  if (*(int *)(*(int *)(param_1 + 0xc) + uVar8 * 4) == 0) {

    iVar4 = FUN_005df0f5(0x390);

    if (iVar4 == 0) {

      uVar5 = 0;

    }

    else {

      uVar5 = FUN_00547a40(param_2,param_3,param_4,param_5,param_6,iVar1,param_8);

    }

    *(undefined4 *)(*(int *)(param_1 + 0xc) + uVar8 * 4) = uVar5;

    FUN_00508470(DAT_008379a8,DAT_008379ac,*(undefined4 *)(*(int *)(param_1 + 0xc) + uVar8 * 4));

    puVar2 = local_c;

    LVar6 = InterlockedDecrement(local_c + 1);

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

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

    }

    return 1;

  }

  LVar6 = InterlockedDecrement(local_c + 1);

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

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

  }

  return 0;

}





// --- FUN_00541e80 at 0x00541E80 (size: 182) ---


undefined4 __thiscall FUN_00541e80(int param_1,ushort param_2)



{

  int iVar1;

  void *pvVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  

  if (*(int *)(DAT_00846f08 + 8) == 0) {

    return 0;

  }

  iVar6 = (uint)param_2 * 4;

  if (*(int *)(iVar6 + *(int *)(DAT_00846f08 + 0xc)) != 0) {

    iVar1 = *(int *)(iVar6 + *(int *)(param_1 + 0xc));

    FUN_00541ab0(iVar1);

    if (*(int *)(iVar1 + 0x380) != 0) {

      iVar5 = *(int *)(param_1 + 0x40);

      iVar4 = 0;

      while (iVar3 = iVar5, iVar3 != 0) {

        if (iVar3 == iVar1) {

          if (iVar4 == 0) {

            *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(iVar3 + 0x378);

          }

          else {

            *(undefined4 *)(iVar4 + 0x378) = *(undefined4 *)(iVar3 + 0x378);

          }

          break;

        }

        iVar4 = iVar3;

        iVar5 = *(int *)(iVar3 + 0x378);

      }

      *(undefined4 *)(iVar1 + 0x380) = 0;

    }

    pvVar2 = *(void **)(iVar6 + *(int *)(param_1 + 0xc));

    if (pvVar2 != (void *)0x0) {

      FUN_00547b00();

      operator_delete(pvVar2);

    }

    *(undefined4 *)(iVar6 + *(int *)(param_1 + 0xc)) = 0;

  }

  return 1;

}





// --- FUN_00541f40 at 0x00541F40 (size: 71) ---


void __fastcall FUN_00541f40(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)(*(int *)(param_1 + 8) + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*(int *)(param_1 + 8) + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(*(int *)(param_1 + 4) + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(*(int *)(param_1 + 4) + -0x10));

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

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

  }

  return;

}





// --- FUN_00541f90 at 0x00541F90 (size: 129) ---


undefined2 * __thiscall FUN_00541f90(undefined2 *param_1,undefined2 *param_2)



{

  int iVar1;

  LONG LVar2;

  

  *param_1 = *param_2;

  iVar1 = *(int *)(param_1 + 2);

  if (iVar1 != *(int *)(param_2 + 2)) {

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

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

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

    }

    iVar1 = *(int *)(param_2 + 2);

    *(int *)(param_1 + 2) = iVar1;

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

  }

  iVar1 = *(int *)(param_1 + 4);

  if (iVar1 != *(int *)(param_2 + 4)) {

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

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

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

    }

    iVar1 = *(int *)(param_2 + 4);

    *(int *)(param_1 + 4) = iVar1;

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

  }

  return param_1;

}





// --- FUN_00542020 at 0x00542020 (size: 67) ---


void FUN_00542020(ushort param_1)



{

  short *psVar1;

  

  if (((param_1 < 0x100) &&

      (psVar1 = (short *)((uint)param_1 * 0x88 + 0x20 + DAT_00846f18), psVar1 != (short *)0x0)) &&

     (*psVar1 != 0)) {

    FUN_005ab580();

    return;

  }

  FUN_004034c0("(No ReceiverData for that RecipientID)");

  return;

}





// --- FUN_00542070 at 0x00542070 (size: 255) ---


undefined4 __thiscall FUN_00542070(int param_1,undefined4 *param_2)



{

  short *psVar1;

  ushort uVar2;

  int iVar3;

  undefined4 *puVar4;

  LONG LVar5;

  

  iVar3 = (int)param_2;

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

    uVar2 = *(ushort *)((int)param_2 + 0x3e);

    if ((uVar2 < 0xc) && (uVar2 != 0)) {

      if (*(int *)(param_1 + 0x10 + (uint)uVar2 * 4) == 0) {

        param_2 = DAT_008ef11c;

        InterlockedIncrement(DAT_008ef11c + 1);

        FUN_00542020(*(undefined2 *)(iVar3 + 0x3c),&param_2,0);

        FUN_005abb30();

        return 0;

      }

      InterlockedIncrement((LONG *)((int)param_2 + 4));

      FUN_00453800(iVar3);

      return 1;

    }

    param_2 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    if ((*(ushort *)(iVar3 + 0x3c) < 0x100) &&

       ((psVar1 = (short *)((uint)*(ushort *)(iVar3 + 0x3c) * 0x88 + 0x20 + DAT_00846f18),

        psVar1 != (short *)0x0 && (*psVar1 != 0)))) {

      FUN_005ab580(psVar1 + 0x18,&param_2,0);

    }

    else {

      FUN_004034c0("(No ReceiverData for that RecipientID)");

    }

    puVar4 = param_2;

    LVar5 = InterlockedDecrement(param_2 + 1);

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

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

    }

  }

  return 0;

}





// --- FUN_00542170 at 0x00542170 (size: 142) ---


uint __fastcall FUN_00542170(int param_1)



{

  void *pvVar1;

  uint in_EAX;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  

  pvVar1 = *(void **)(param_1 + 4);

  if (pvVar1 == (void *)0x0) {

    return in_EAX & 0xffffff00;

  }

  iVar3 = *(int *)((int)pvVar1 + 0xc);

  *(int *)(param_1 + 4) = iVar3;

  if (iVar3 == 0) {

    *(undefined4 *)(param_1 + 8) = 0;

  }

  else {

    *(undefined4 *)(iVar3 + 0x10) = 0;

  }

  FUN_00541f90(pvVar1);

  if (pvVar1 != (void *)0x0) {

    puVar4 = (undefined4 *)(*(int *)((int)pvVar1 + 8) + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(*(int *)((int)pvVar1 + 8) + -0x10));

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

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

    }

    puVar4 = (undefined4 *)(*(int *)((int)pvVar1 + 4) + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(*(int *)((int)pvVar1 + 4) + -0x10));

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

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

    }

    operator_delete(pvVar1);

  }

  iVar3 = *(int *)(param_1 + 0xc) + -1;

  *(int *)(param_1 + 0xc) = iVar3;

  return CONCAT31((int3)((uint)iVar3 >> 8),1);

}





// --- FUN_00542200 at 0x00542200 (size: 138) ---


undefined1 FUN_00542200(void)



{

  undefined1 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined2 local_c [2];

  undefined *local_8;

  undefined *local_4;

  

  local_8 = PTR_DAT_00818340;

  local_c[0] = 0;

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

  local_4 = PTR_DAT_00818340;

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

  uVar1 = FUN_00542170(local_c);

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

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

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

    (**(code **)*puVar3)(1);

  }

  puVar3 = (undefined4 *)(local_8 + -0x14);

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

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

    (**(code **)*puVar3)(1);

  }

  return uVar1;

}





// --- FUN_00542290 at 0x00542290 (size: 34) ---


void __fastcall FUN_00542290(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cac50;

  while (param_1[1] != 0) {

    FUN_00542200();

  }

  return;

}





// --- FUN_005422c0 at 0x005422C0 (size: 54) ---


undefined4 * __thiscall FUN_005422c0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cac50;

  while (param_1[1] != 0) {

    FUN_00542200();

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00542300 at 0x00542300 (size: 41) ---


void __fastcall FUN_00542300(undefined4 *param_1)



{

  param_1[3] = &PTR_FUN_007cac50;

  while (param_1[4] != 0) {

    FUN_00542200();

  }

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_00542360 at 0x00542360 (size: 30) ---


void * __thiscall FUN_00542360(void *param_1,byte param_2)



{

  FUN_00542300();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00542380 at 0x00542380 (size: 387) ---


undefined4 * __thiscall FUN_00542380(undefined4 *param_1,wchar_t *param_2)



{

  undefined4 uVar1;

  uint uVar2;

  undefined4 *puVar3;

  size_t sVar4;

  LONG LVar5;

  int iVar6;

  wchar_t *pwVar7;

  bool bVar8;

  undefined8 uVar9;

  wchar_t *local_4;

  

  local_4 = (wchar_t *)0x0;

  *param_1 = &PTR_LAB_007cabdc;

  param_1[2] = param_2;

  param_1[0x10] = 0;

  param_1[0x11] = &PTR_FUN_007cabd8;

  param_1[0x13] = 0;

  uVar1 = thunk_FUN_005df0f5(0x400);

  param_1[0x12] = uVar1;

  param_1[0x15] = 0x40;

  param_1[0x14] = 0x40;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  FUN_005497a0();

  param_1[0x1b] = 0;

  uVar9 = FUN_005ab3f0(0);

  *(undefined8 *)(param_1 + 0x18) = uVar9;

  uVar1 = thunk_FUN_005df0f5(0x400);

  param_1[3] = uVar1;

  uVar2 = 0;

  DAT_00846f08 = param_1;

  do {

    *(undefined4 *)(uVar2 + param_1[3]) = 0;

    uVar2 = uVar2 + 4;

  } while (uVar2 < 0x400);

  puVar3 = param_1 + 4;

  for (iVar6 = 0xc; iVar6 != 0; iVar6 = iVar6 + -1) {

    *puVar3 = 0;

    puVar3 = puVar3 + 1;

  }

  puVar3 = (undefined4 *)FUN_005df0f5(0x28);

  bVar8 = puVar3 == (undefined4 *)0x0;

  if (bVar8) {

    puVar3 = (undefined4 *)0x0;

  }

  else {

    sVar4 = wcslen(L"Number of NetBlobs that have passed through PacketController::SendBlob.");

    FUN_004022d0(sVar4);

    wcscpy(local_4,L"Number of NetBlobs that have passed through PacketController::SendBlob.");

    sVar4 = wcslen(L"Net - PacketController::SendBlob calls");

    FUN_004022d0(sVar4);

    wcscpy(param_2,L"Net - PacketController::SendBlob calls");

    FUN_00683e60(0,&param_2,&local_4,9);

    *puVar3 = &PTR_FUN_007cac54;

    puVar3[8] = 0;

    puVar3[9] = 0;

  }

  param_1[0x1b] = puVar3;

  if (!bVar8) {

    pwVar7 = param_2 + -10;

    LVar5 = InterlockedDecrement((LONG *)(param_2 + -8));

    if ((LVar5 == 0) && (pwVar7 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)pwVar7)(1);

    }

  }

  if (!bVar8) {

    pwVar7 = local_4 + -10;

    LVar5 = InterlockedDecrement((LONG *)(local_4 + -8));

    if ((LVar5 == 0) && (pwVar7 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)pwVar7)(1);

    }

  }

  return param_1;

}





// --- FUN_00542510 at 0x00542510 (size: 93) ---


void FUN_00542510(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  iVar2 = *(int *)(param_1 + 0x124);

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

  if ((*(byte *)(param_1 + 0x128) & 2) == 0) {

    iVar2 = iVar2 + 1;

  }

  iVar3 = *(int *)(iVar1 + 4) + 1;

  if (iVar3 != iVar2) {

    do {

      if (iVar3 != 0) {

        FUN_00549da0(iVar3,0);

      }

      iVar3 = iVar3 + 1;

    } while (iVar3 != iVar2);

    *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(param_1 + 0x124);

    return;

  }

  *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(param_1 + 0x124);

  return;

}





// --- FUN_00542570 at 0x00542570 (size: 82) ---


void FUN_00542570(undefined4 *param_1)



{

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined2 local_8;

  undefined2 local_6;

  undefined2 local_4;

  undefined2 local_2;

  

  local_14 = *param_1;

  local_10 = param_1[1];

  local_8 = *(undefined2 *)(param_1 + 3);

  local_6 = *(undefined2 *)((int)param_1 + 0xe);

  local_2 = *(undefined2 *)((int)param_1 + 0x12);

  local_4 = *(undefined2 *)(param_1 + 4);

  local_c = 0xbadd70dd;

  FUN_00660640(&local_14,0x14);

  return;

}





// --- FUN_00542650 at 0x00542650 (size: 301) ---


/* WARNING: Function: __chkstk replaced with injection: alloca_probe */



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



{

  int iVar1;

  int iVar2;

  uint uVar3;

  uint uVar4;

  char *pcVar5;

  char *pcVar6;

  char *pcVar7;

  int iStack_10014;

  SOCKET SStack_10010;

  undefined4 *puStack_1000c;

  int iStack_10008;

  undefined1 *puStack_10004;

  int *piStack_10000;

  undefined4 uStack_fffc;

  undefined4 uStack_fff8;

  undefined4 uStack_fff4;

  int iStack_fff0;

  undefined1 *puStack_ffec;

  undefined1 auStack_ffe8 [8];

  char local_ffe0 [65500];

  undefined4 uStack_4;

  

  uStack_4 = 0x54265a;

  SStack_10010 = param_1[4];

  iVar2 = 0;

  iVar1 = 0;

  iStack_10014 = 0;

  if (0 < param_3) {

    do {

      iVar2 = iVar2 + *(int *)(param_2 + iVar1 * 8);

      iVar1 = iVar1 + 1;

      iStack_10014 = iVar2;

    } while (iVar1 < param_3);

  }

  iVar1 = 0;

  pcVar5 = local_ffe0;

  if (0 < param_3) {

    do {

      uVar4 = *(uint *)(param_2 + iVar1 * 8);

      pcVar6 = *(char **)(param_2 + 4 + iVar1 * 8);

      pcVar7 = pcVar5;

      for (uVar3 = uVar4 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {

        *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;

        pcVar6 = pcVar6 + 4;

        pcVar7 = pcVar7 + 4;

      }

      for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {

        *pcVar7 = *pcVar6;

        pcVar6 = pcVar6 + 1;

        pcVar7 = pcVar7 + 1;

      }

      pcVar5 = pcVar5 + *(int *)(param_2 + iVar1 * 8);

      iVar1 = iVar1 + 1;

    } while (iVar1 < param_3);

  }

  puStack_1000c = param_1;

  iVar1 = sendto(SStack_10010,local_ffe0,iStack_10014,0,(sockaddr *)&stack0x0000000c,0x10);

  if (iVar1 != -1) {

    (**(code **)*param_1)(0,iVar1);

    if ((code *)param_1[0x221c] != (code *)0x0) {

      puStack_1000c = &param_2;

      puStack_10004 = auStack_ffe8;

      piStack_10000 = &iStack_fff0;

      puStack_ffec = auStack_ffe8;

      SStack_10010 = 0x28;

      uStack_fffc = 1;

      uStack_fff8 = 0x10;

      uStack_fff4 = 2;

      iStack_10008 = iVar1;

      iStack_fff0 = iVar1;

      (*(code *)param_1[0x221c])(&SStack_10010,param_1[0x221f]);

    }

    return iVar1;

  }

  return 0;

}





// --- FUN_00542780 at 0x00542780 (size: 281) ---


undefined4 __thiscall FUN_00542780(int *param_1,int param_2,int param_3,undefined4 *param_4)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  int *piVar5;

  int iVar6;

  int local_2d8 [182];

  

  iVar2 = FUN_00542570(param_3);

  *(int *)(param_3 + 8) = *(int *)(param_3 + 8) + iVar2;

  iVar2 = *(int *)(param_2 + 0x8c) + 1 + *(int *)(param_2 + 0x104) * 2;

  local_2d8[1] = param_3;

  uVar3 = 1;

  uVar1 = *(int *)(param_2 + 0x8c) + 1;

  local_2d8[0] = 0x14;

  if (1 < uVar1) {

    piVar5 = (int *)(param_2 + 0xc);

    do {

      iVar4 = *piVar5;

      local_2d8[uVar3 * 2 + 1] = *(int *)(iVar4 + 0x10);

      local_2d8[uVar3 * 2] = *(int *)(iVar4 + 0x14);

      uVar3 = uVar3 + 1;

      piVar5 = piVar5 + 1;

    } while (uVar3 < uVar1);

  }

  if ((int)uVar3 < iVar2) {

    piVar5 = (int *)(param_2 + 0x90);

    do {

      iVar4 = *piVar5;

      local_2d8[uVar3 * 2 + 1] = *(int *)(iVar4 + 0x10);

      local_2d8[uVar3 * 2] = 0x10;

      local_2d8[uVar3 * 2 + 3] = *(int *)(iVar4 + 0x28);

      local_2d8[uVar3 * 2 + 2] = *(ushort *)(*(int *)(iVar4 + 0x10) + 10) - 0x10;

      uVar3 = uVar3 + 2;

      piVar5 = piVar5 + 1;

    } while ((int)uVar3 < iVar2);

  }

  iVar6 = 0;

  iVar4 = 0;

  if (0 < iVar2) {

    do {

      iVar6 = iVar6 + local_2d8[iVar4 * 2];

      iVar4 = iVar4 + 1;

    } while (iVar4 < iVar2);

  }

  iVar2 = (**(code **)(*param_1 + 4))(local_2d8,iVar2,*param_4,param_4[1],param_4[2],param_4[3]);

  if (iVar6 <= iVar2) {

    (**(code **)*param_1)(9,1);

    return 1;

  }

  return 0;

}





// --- FUN_005428a0 at 0x005428A0 (size: 65) ---


void FUN_005428a0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  FUN_005498d0(param_2);

  FUN_00541770(param_1);

  iVar1 = FUN_00541800(param_1);

  if (iVar1 != 0) {

    *(undefined4 *)(iVar1 + 0x10) = param_2;

  }

  return;

}





// --- FUN_005428f0 at 0x005428F0 (size: 182) ---


undefined4 FUN_005428f0(int *param_1,u_long *param_2)



{

  int iVar1;

  char *pcVar2;

  u_long uVar3;

  int iVar4;

  int local_8;

  uint local_4;

  

  iVar4 = 0;

  iVar1 = sscanf((char *)*param_1,"%d%n",&local_4,&local_8);

  if (iVar1 != 0) {

    do {

      if ((int)local_4 < 0) {

        return 0;

      }

      if (0xff < (int)local_4) {

        return 0;

      }

      iVar4 = iVar4 + 1;

      if (4 < iVar4) break;

      *param_2 = *param_2 << 8 | local_4;

      pcVar2 = (char *)(*param_1 + local_8);

      *param_1 = (int)pcVar2;

      if (*pcVar2 != '.') break;

      *param_1 = (int)(pcVar2 + 1);

      iVar1 = sscanf((char *)*param_1,"%d%n",&local_4,&local_8);

    } while (iVar1 != 0);

    if ((0 < iVar4) && (iVar4 < 5)) {

      uVar3 = *param_2 << (('\x04' - (char)iVar4) * '\b' & 0x1fU);

      *param_2 = uVar3;

      uVar3 = htonl(uVar3);

      *param_2 = uVar3;

      return 1;

    }

  }

  return 0;

}





// --- FUN_005429d0 at 0x005429D0 (size: 8) ---


void __fastcall FUN_005429d0(int param_1)



{

  *(undefined1 *)(param_1 + 0x8a85) = 1;

  return;

}





// --- FUN_005429e0 at 0x005429E0 (size: 131) ---


void __fastcall FUN_005429e0(int param_1)



{

  short sVar1;

  short *psVar2;

  int iVar3;

  short *psVar4;

  

  if (*(char *)(param_1 + 0x8a85) != '\0') {

    *(undefined1 *)(param_1 + 0x8a85) = 0;

  }

  *(undefined2 *)(param_1 + 0x8a6e) = *(undefined2 *)(param_1 + 0x8a6c);

  psVar4 = *(short **)(param_1 + 0x8820);

  while (psVar4 != (short *)0x0) {

    psVar2 = *(short **)(psVar4 + 4);

    sVar1 = *psVar4;

    psVar4 = psVar2;

    if (sVar1 != *(short *)(param_1 + 0x8a6c)) {

      FUN_00545f80(sVar1);

    }

  }

  iVar3 = *(int *)(param_1 + 0x8820);

  if (iVar3 != 0) {

    *(undefined2 *)(param_1 + 0x18) = *(undefined2 *)(iVar3 + 0x2c);

    *(undefined4 *)(iVar3 + 0x44) = 2;

    *(undefined1 *)(param_1 + 0x8a78) = 0;

    FUN_005473c0(0);

    return;

  }

  *(undefined2 *)(param_1 + 0x8a6c) = 0;

  return;

}





// --- FUN_00542ad0 at 0x00542AD0 (size: 32) ---


void __thiscall FUN_00542ad0(int param_1,undefined4 *param_2)



{

  *param_2 = *(undefined4 *)(param_1 + 0x18);

  param_2[1] = *(undefined4 *)(param_1 + 0x1c);

  param_2[2] = *(undefined4 *)(param_1 + 0x20);

  param_2[3] = *(undefined4 *)(param_1 + 0x24);

  return;

}





// --- FUN_00542af0 at 0x00542AF0 (size: 30) ---


void * __thiscall FUN_00542af0(void *param_1,byte param_2)



{

  FUN_00542b10();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00542b10 at 0x00542B10 (size: 65) ---


void __fastcall FUN_00542b10(undefined4 *param_1)



{

  void *pvVar1;

  

  pvVar1 = (void *)*param_1;

  if (pvVar1 != (void *)0x0) {

    FUN_00542b10();

    operator_delete(pvVar1);

  }

  pvVar1 = (void *)param_1[1];

  if (pvVar1 != (void *)0x0) {

    FUN_00542b10();

    operator_delete(pvVar1);

  }

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_00542b60 at 0x00542B60 (size: 182) ---


void __thiscall FUN_00542b60(undefined4 *param_1,int *param_2,int *param_3,int param_4)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  

  puVar1 = (undefined4 *)param_2[2];

  param_2[1] = param_4;

  *param_3 = (int)param_2;

  param_3[2] = (int)puVar1;

  if (puVar1 == (undefined4 *)0x0) {

    *param_1 = param_3;

  }

  else if ((char)param_2[8] == '\0') {

    puVar1[1] = param_3;

    *(undefined1 *)(param_3 + 8) = 0;

  }

  else {

    *puVar1 = param_3;

    *(undefined1 *)(param_3 + 8) = 1;

  }

  param_2[2] = (int)param_3;

  *(undefined1 *)(param_2 + 8) = 1;

  if (param_4 != 0) {

    *(int **)(param_4 + 8) = param_2;

    *(undefined1 *)(param_4 + 0x20) = 0;

  }

  if (*param_2 == 0) {

    iVar3 = 1;

  }

  else {

    iVar3 = *(int *)(*param_2 + 0x14) + 1;

  }

  param_2[3] = iVar3;

  if (param_2[1] == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(param_2[1] + 0x14) + 1;

  }

  param_2[4] = iVar2;

  if (iVar2 <= iVar3) {

    iVar2 = iVar3;

  }

  param_2[5] = iVar2;

  if (*param_3 == 0) {

    iVar3 = 1;

  }

  else {

    iVar3 = *(int *)(*param_3 + 0x14) + 1;

  }

  param_3[3] = iVar3;

  if (param_3[1] == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(param_3[1] + 0x14) + 1;

  }

  param_3[4] = iVar2;

  if (iVar2 <= iVar3) {

    param_3[5] = iVar3;

    return;

  }

  param_3[5] = iVar2;

  return;

}





// --- FUN_00542c20 at 0x00542C20 (size: 182) ---


void __thiscall FUN_00542c20(undefined4 *param_1,int *param_2,int *param_3,int param_4)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  

  puVar1 = (undefined4 *)param_2[2];

  *param_2 = param_4;

  param_3[1] = (int)param_2;

  param_3[2] = (int)puVar1;

  if (puVar1 == (undefined4 *)0x0) {

    *param_1 = param_3;

  }

  else if ((char)param_2[8] == '\0') {

    puVar1[1] = param_3;

    *(undefined1 *)(param_3 + 8) = 0;

  }

  else {

    *puVar1 = param_3;

    *(undefined1 *)(param_3 + 8) = 1;

  }

  param_2[2] = (int)param_3;

  *(undefined1 *)(param_2 + 8) = 0;

  if (param_4 != 0) {

    *(int **)(param_4 + 8) = param_2;

    *(undefined1 *)(param_4 + 0x20) = 1;

  }

  if (*param_2 == 0) {

    iVar3 = 1;

  }

  else {

    iVar3 = *(int *)(*param_2 + 0x14) + 1;

  }

  param_2[3] = iVar3;

  if (param_2[1] == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(param_2[1] + 0x14) + 1;

  }

  param_2[4] = iVar2;

  if (iVar2 <= iVar3) {

    iVar2 = iVar3;

  }

  param_2[5] = iVar2;

  if (*param_3 == 0) {

    iVar3 = 1;

  }

  else {

    iVar3 = *(int *)(*param_3 + 0x14) + 1;

  }

  param_3[3] = iVar3;

  if (param_3[1] == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(param_3[1] + 0x14) + 1;

  }

  param_3[4] = iVar2;

  if (iVar2 <= iVar3) {

    param_3[5] = iVar3;

    return;

  }

  param_3[5] = iVar2;

  return;

}





// --- FUN_00542ce0 at 0x00542CE0 (size: 211) ---


int * FUN_00542ce0(int *param_1,int *param_2,int *param_3)



{

  int iVar1;

  int iVar2;

  

  FUN_00542b60(param_2,param_3,*param_3);

  FUN_00542c20(param_1,param_3,param_3[1]);

  if (*param_1 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_1 + 0x14) + 1;

  }

  param_1[3] = iVar2;

  if (param_1[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_1[1] + 0x14) + 1;

  }

  param_1[4] = iVar1;

  if (iVar1 <= iVar2) {

    iVar1 = iVar2;

  }

  param_1[5] = iVar1;

  if (*param_2 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_2 + 0x14) + 1;

  }

  param_2[3] = iVar2;

  if (param_2[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_2[1] + 0x14) + 1;

  }

  param_2[4] = iVar1;

  if (iVar1 <= iVar2) {

    iVar1 = iVar2;

  }

  param_2[5] = iVar1;

  if (*param_3 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_3 + 0x14) + 1;

  }

  param_3[3] = iVar2;

  if (param_3[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_3[1] + 0x14) + 1;

  }

  param_3[4] = iVar1;

  if (iVar1 <= iVar2) {

    param_3[5] = iVar2;

    return param_3;

  }

  param_3[5] = iVar1;

  return param_3;

}





// --- FUN_00542dc0 at 0x00542DC0 (size: 211) ---


int * FUN_00542dc0(int *param_1,int *param_2,int *param_3)



{

  int iVar1;

  int iVar2;

  

  FUN_00542c20(param_2,param_3,param_3[1]);

  FUN_00542b60(param_1,param_3,*param_3);

  if (*param_1 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_1 + 0x14) + 1;

  }

  param_1[3] = iVar2;

  if (param_1[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_1[1] + 0x14) + 1;

  }

  param_1[4] = iVar1;

  if (iVar1 <= iVar2) {

    iVar1 = iVar2;

  }

  param_1[5] = iVar1;

  if (*param_2 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_2 + 0x14) + 1;

  }

  param_2[3] = iVar2;

  if (param_2[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_2[1] + 0x14) + 1;

  }

  param_2[4] = iVar1;

  if (iVar1 <= iVar2) {

    iVar1 = iVar2;

  }

  param_2[5] = iVar1;

  if (*param_3 == 0) {

    iVar2 = 1;

  }

  else {

    iVar2 = *(int *)(*param_3 + 0x14) + 1;

  }

  param_3[3] = iVar2;

  if (param_3[1] == 0) {

    iVar1 = 1;

  }

  else {

    iVar1 = *(int *)(param_3[1] + 0x14) + 1;

  }

  param_3[4] = iVar1;

  if (iVar1 <= iVar2) {

    param_3[5] = iVar2;

    return param_3;

  }

  param_3[5] = iVar1;

  return param_3;

}





// --- FUN_00542ea0 at 0x00542EA0 (size: 48) ---


char * __thiscall FUN_00542ea0(int *param_1,int *param_2)



{

  char *pcVar1;

  

  pcVar1 = strstr((char *)(*param_1 + 0x14),(char *)(*param_2 + 0x14));

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

    return (char *)0xffffffff;

  }

  return pcVar1 + (-0x14 - *param_1);

}





// --- FUN_00542ed0 at 0x00542ED0 (size: 87) ---


undefined4 __thiscall FUN_00542ed0(int *param_1,uint param_2)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined4 local_28 [10];

  

  if ((uint)param_1[2] <= param_2) {

    return 0;

  }

  uVar1 = param_1[2] - 1;

  param_1[2] = uVar1;

  if (param_2 != uVar1) {

    puVar3 = (undefined4 *)(*param_1 + uVar1 * 0x28);

    puVar4 = (undefined4 *)(*param_1 + param_2 * 0x28);

    for (iVar2 = 10; iVar2 != 0; iVar2 = iVar2 + -1) {

      *puVar4 = *puVar3;

      puVar3 = puVar3 + 1;

      puVar4 = puVar4 + 1;

    }

    puVar3 = local_28;

    puVar4 = (undefined4 *)(*param_1 + param_1[2] * 0x28);

    for (iVar2 = 10; iVar2 != 0; iVar2 = iVar2 + -1) {

      *puVar4 = *puVar3;

      puVar3 = puVar3 + 1;

      puVar4 = puVar4 + 1;

    }

  }

  return 1;

}





// --- FUN_00542f40 at 0x00542F40 (size: 207) ---


void __fastcall FUN_00542f40(int param_1)



{

  *(undefined4 *)(param_1 + 0x20) = 0;

  *(undefined4 *)(param_1 + 0x24) = 0;

  *(undefined4 *)(param_1 + 0x38) = 0;

  *(undefined4 *)(param_1 + 0x3c) = 0;

  *(undefined2 *)(param_1 + 0x40) = 0;

  *(undefined2 *)(param_1 + 0x42) = 0;

  *(undefined4 *)(param_1 + 0x98) = 0;

  *(undefined4 *)(param_1 + 0x9c) = 0;

  *(undefined2 *)(param_1 + 0xa0) = 0;

  *(undefined2 *)(param_1 + 0xa2) = 0;

  *(undefined4 *)(param_1 + 0xf8) = 0;

  *(undefined4 *)(param_1 + 0xfc) = 0;

  *(undefined2 *)(param_1 + 0x100) = 0;

  *(undefined2 *)(param_1 + 0x102) = 0;

  *(undefined4 *)(param_1 + 0x158) = 0;

  *(undefined4 *)(param_1 + 0x15c) = 0;

  *(undefined2 *)(param_1 + 0x160) = 0;

  *(undefined2 *)(param_1 + 0x162) = 0;

  *(undefined4 *)(param_1 + 0x1b8) = 0;

  *(undefined4 *)(param_1 + 0x1bc) = 0;

  *(undefined2 *)(param_1 + 0x1c0) = 0;

  *(undefined2 *)(param_1 + 0x1c2) = 0;

  *(undefined4 *)(param_1 + 0x1d0) = 0;

  *(undefined4 *)(param_1 + 0x1d4) = 0;

  *(undefined2 *)(param_1 + 0x1d8) = 0;

  *(undefined2 *)(param_1 + 0x1da) = 0;

  *(undefined4 *)(param_1 + 0x1e8) = 0;

  *(undefined4 *)(param_1 + 0x1ec) = 0;

  *(undefined2 *)(param_1 + 0x1f0) = 0;

  *(undefined2 *)(param_1 + 0x1f2) = 0;

  *(undefined4 *)(param_1 + 0x208) = 0;

  *(undefined4 *)(param_1 + 0x20c) = 0;

  *(undefined2 *)(param_1 + 0x210) = 0;

  *(undefined2 *)(param_1 + 0x212) = 0;

  return;

}





// --- FUN_00543010 at 0x00543010 (size: 30) ---


void * __thiscall FUN_00543010(void *param_1,byte param_2)



{

  FUN_006605b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00543030 at 0x00543030 (size: 135) ---


undefined1 __fastcall FUN_00543030(int *param_1)



{

  int iVar1;

  int iVar2;

  undefined1 uVar3;

  DWORD DVar4;

  int iVar5;

  int *piVar6;

  

  piVar6 = param_1 + 0x220e;

  for (iVar5 = 8; iVar2 = DAT_008379ac, iVar1 = DAT_008379a8, iVar5 != 0; iVar5 = iVar5 + -1) {

    *piVar6 = 0;

    piVar6 = piVar6 + 1;

  }

  DVar4 = GetTickCount();

  param_1[0x220c] = DVar4;

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

  uVar3 = (**(code **)(*param_1 + 0x18))();

  (**(code **)(*param_1 + 8))();

  DVar4 = GetTickCount();

  if ((uint)param_1[0x220d] <= DVar4 - param_1[0x220c]) {

    (**(code **)(*param_1 + 0x10))();

  }

  param_1[0x220a] = iVar1;

  param_1[0x220b] = iVar2;

  return uVar3;

}





// --- FUN_005432d0 at 0x005432D0 (size: 72) ---


undefined4 __fastcall FUN_005432d0(int *param_1)



{

  short *psVar1;

  short *psVar2;

  DWORD DVar3;

  

  psVar1 = (short *)param_1[0x2208];

  while ((psVar2 = psVar1, psVar2 != (short *)0x0 &&

         (DVar3 = GetTickCount(), DVar3 - param_1[0x220c] < (uint)param_1[0x220d]))) {

    psVar1 = *(short **)(psVar2 + 4);

    if (*psVar2 != 0) {

      (**(code **)(*param_1 + 0xc))(psVar2);

    }

  }

  return 1;

}





// --- FUN_00543320 at 0x00543320 (size: 41) ---


undefined4 FUN_00543320(int param_1)



{

  if (*(int *)(param_1 + 0x50) == 0) {

    *(undefined4 *)(param_1 + 0x44) = 2;

    return 2;

  }

  *(undefined4 *)(param_1 + 0x44) = 1;

  return 1;

}





// --- FUN_00543440 at 0x00543440 (size: 26) ---


void __fastcall FUN_00543440(int *param_1)



{

  if ((char)param_1[0x2237] != '\0') {

    (**(code **)(*param_1 + 0x5c))();

  }

  FUN_00543030();

  return;

}





// --- FUN_00543520 at 0x00543520 (size: 64) ---


undefined4 * __thiscall FUN_00543520(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cae44;

  operator_delete((void *)param_1[6]);

  param_1[6] = 0;

  param_1[8] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00543560 at 0x00543560 (size: 109) ---


void FUN_00543560(int *param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

  if (param_1[4] - param_1[3] != 2) {

    iVar2 = *param_1;

    if (*(int *)(iVar2 + 0x10) - *(int *)(iVar2 + 0xc) == 1) {

      FUN_00542ce0(param_1,iVar2,*(undefined4 *)(iVar2 + 4));

      return;

    }

    FUN_00542c20(param_1,iVar2,*(undefined4 *)(iVar2 + 4));

    return;

  }

  puVar1 = (undefined4 *)param_1[1];

  if ((puVar1[4] - puVar1[3] != 1) && (puVar1[4] - puVar1[3] == -1)) {

    FUN_00542dc0(param_1,puVar1,*puVar1);

    return;

  }

  FUN_00542b60(param_1,puVar1,*puVar1);

  return;

}





// --- FUN_005435d0 at 0x005435D0 (size: 50) ---


int FUN_005435d0(ushort param_1,ushort param_2)



{

  int iVar1;

  ushort uVar2;

  

  if (param_1 == param_2) {

    return 0;

  }

  uVar2 = param_1 - param_2;

  iVar1 = 1;

  if (param_1 < param_2) {

    uVar2 = param_2 - param_1;

    iVar1 = -1;

  }

  if (0x7fff < uVar2) {

    iVar1 = -iVar1;

  }

  return iVar1;

}





// --- FUN_00543610 at 0x00543610 (size: 108) ---


void __fastcall FUN_00543610(int *param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined4 local_28 [10];

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      uVar1 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(uVar1 - 1)) {

        iVar2 = (uVar1 - 1) * 0x28;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          iVar2 = iVar2 + -0x28;

          uVar1 = uVar1 - 1;

          puVar4 = local_28;

          for (iVar3 = 10; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar5 = *puVar4;

            puVar4 = puVar4 + 1;

            puVar5 = puVar5 + 1;

          }

        } while (uVar1 != 0);

      }

    }

    return;

  }

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_00543680 at 0x00543680 (size: 117) ---


void __thiscall FUN_00543680(int *param_1,uint param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  uint uVar3;

  

  uVar2 = 1;

  do {

    uVar3 = uVar2;

    uVar2 = uVar3 * 2;

  } while (uVar2 < param_2);

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(uVar3 * 4 + 0x18);

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

    puVar1[1] = 1;

    *puVar1 = &PTR_LAB_007cae34;

    puVar1[2] = 1;

    puVar1[3] = 1;

    puVar1[4] = 0xffffffff;

    *(undefined2 *)(puVar1 + 5) = 0;

    *param_1 = (int)puVar1;

    puVar1[2] = param_2 + 1;

    *(uint *)(*param_1 + 0xc) = uVar2 + 1;

    return;

  }

  *param_1 = 0;

  iRam00000008 = param_2 + 1;

  *(uint *)(*param_1 + 0xc) = uVar2 + 1;

  return;

}





// --- FUN_00543700 at 0x00543700 (size: 91) ---


undefined4 * FUN_00543700(undefined4 param_1)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)FUN_005df0f5(0x28);

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

    puVar2[1] = 1;

    puVar2[2] = 0x4000000;

    puVar2[3] = 0x18;

    puVar2[4] = puVar2 + 6;

    puVar2[5] = 8;

    *puVar2 = &PTR_FUN_007cae38;

    uVar1 = DAT_008379b4;

    puVar2[8] = DAT_008379b0;

    puVar2[9] = uVar1;

    puVar2[6] = param_1;

    puVar2[7] = 0;

    return puVar2;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00543760 at 0x00543760 (size: 118) ---


void FUN_00543760(undefined2 param_1)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x124);

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

    puVar1[2] = 0;

    puVar1[0x23] = 0;

    puVar1[0x41] = 0;

    *(undefined2 *)(puVar1 + 0x42) = 0;

    puVar1[0x43] = 0;

    puVar1[0x44] = 0;

    puVar1[0x45] = 0;

    puVar1[0x46] = 0;

    puVar1[0x47] = 0;

    puVar1[0x48] = 0;

    puVar1[1] = 1;

    *puVar1 = &PTR_FUN_007cae40;

    *(undefined2 *)(puVar1 + 0x42) = param_1;

    return;

  }

  uRam00000108 = param_1;

  return;

}





// --- FUN_005437e0 at 0x005437E0 (size: 30) ---


void * __thiscall FUN_005437e0(void *param_1,byte param_2)



{

  FUN_00543800();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00543800 at 0x00543800 (size: 146) ---


void __fastcall FUN_00543800(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  uint uVar3;

  int *piVar4;

  

  uVar3 = 0;

  *param_1 = &PTR_FUN_007cae40;

  if (param_1[0x23] != 0) {

    piVar4 = param_1 + 3;

    do {

      puVar1 = (undefined4 *)*piVar4;

      LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

      }

      uVar3 = uVar3 + 1;

      piVar4 = piVar4 + 1;

    } while (uVar3 < (uint)param_1[0x23]);

  }

  uVar3 = 0;

  if (param_1[0x41] != 0) {

    piVar4 = param_1 + 0x24;

    do {

      puVar1 = (undefined4 *)*piVar4;

      LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

      }

      uVar3 = uVar3 + 1;

      piVar4 = piVar4 + 1;

    } while (uVar3 < (uint)param_1[0x41]);

  }

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_005438a0 at 0x005438A0 (size: 323) ---


void __fastcall FUN_005438a0(undefined4 *param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int iVar4;

  

  pvVar1 = (void *)param_1[5];

  *param_1 = &PTR_LAB_007cae50;

  if (pvVar1 != (void *)0x0) {

    FUN_005b19d0();

    FUN_005b19d0();

    operator_delete(pvVar1);

  }

  puVar2 = (undefined4 *)param_1[0x2220];

  param_1[5] = 0;

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x2220] = 0;

  }

  puVar2 = (undefined4 *)param_1[0x2216];

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x2216] = 0;

  }

  puVar2 = (undefined4 *)param_1[0x2217];

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x2217] = 0;

  }

  puVar2 = (undefined4 *)param_1[0x2218];

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x2218] = 0;

  }

  puVar2 = (undefined4 *)param_1[0x2219];

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x2219] = 0;

  }

  puVar2 = (undefined4 *)param_1[0x221a];

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

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    param_1[0x221a] = 0;

  }

  iVar4 = 0x100;

  do {

    FUN_005499d0();

    iVar4 = iVar4 + -1;

  } while (iVar4 != 0);

  FUN_005ab800();

  return;

}





// --- FUN_00543c30 at 0x00543C30 (size: 226) ---


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



{

  undefined4 uVar1;

  uint uVar2;

  

  uVar2 = *(uint *)(param_2 + 8);

  if (0x200000 < uVar2) {

    if (uVar2 == 0x1000000) {

      (**(code **)(*param_1 + 0x40))(param_2,param_3);

    }

    else {

      if (uVar2 == 0x2000000) {

        uVar1 = FUN_00543700(*(undefined4 *)(param_2 + 0x18));

        uVar2 = (uint)*(ushort *)(param_3 + 0x108);

        FUN_00541770(uVar2,uVar1);

        FUN_005419f0(uVar2,uVar1);

        FUN_00405f70();

        return 1;

      }

      if (uVar2 != 0x4000000) {

        return 0;

      }

    }

    return 1;

  }

  if (uVar2 == 0x200000) {

    (**(code **)(*param_1 + 0x3c))(*(undefined2 *)(param_3 + 0x130),6);

    return 1;

  }

  if (uVar2 == 0x1000) {

    (**(code **)(*param_1 + 0x44))(param_2,param_3);

    return 1;

  }

  if (uVar2 == 0x2000) {

    (**(code **)(*param_1 + 0x4c))(param_2,param_3);

    return 1;

  }

  if (uVar2 != 0x4000) {

    return 0;

  }

  (**(code **)(*param_1 + 0x48))(param_2,param_3);

  return 1;

}





// --- FUN_00543d20 at 0x00543D20 (size: 234) ---


undefined1 FUN_00543d20(int param_1,undefined4 param_2,int param_3)



{

  uint uVar1;

  undefined1 uVar2;

  int iVar3;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined2 local_8;

  undefined2 local_6;

  undefined2 local_4;

  undefined2 local_2;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  uVar2 = 0;

  if (((((uVar1 & 0x10) == 0) && ((uVar1 & 1) != 0)) && ((uVar1 & 2) != 0)) &&

     (((uVar1 & 8) == 0 && (((uVar1 & 4) != 0 || (param_3 != 0)))))) {

    iVar3 = FUN_00543760(0);

    FUN_00549fc0(param_1);

    local_10 = *(undefined4 *)(param_1 + 8);

    local_6 = 0;

    local_4 = *(undefined2 *)(iVar3 + 0x110);

    local_c = *(undefined4 *)(iVar3 + 0x11c);

    local_14 = 0;

    if (param_3 == 0) {

      local_8 = 0;

      local_2 = 0;

    }

    else {

      local_8 = *(undefined2 *)(param_3 + 0x2c);

      local_2 = *(undefined2 *)(param_3 + 2);

    }

    uVar2 = FUN_00542780(iVar3,&local_14,param_2);

    FUN_00405f70();

  }

  return uVar2;

}





// --- FUN_00543e10 at 0x00543E10 (size: 292) ---


undefined4 FUN_00543e10(undefined4 *param_1,undefined4 *param_2,u_long *param_3)



{

  char cVar1;

  char *pcVar2;

  LONG LVar3;

  u_long uVar4;

  uint uVar5;

  uint uVar6;

  char *local_4;

  

  local_4 = (char *)(param_1 + 5);

  *param_3 = 0;

  *param_2 = 0;

  cVar1 = FUN_005428f0(&local_4,param_2);

  if (cVar1 != '\0') {

    if (*local_4 != '/') {

      LVar3 = InterlockedDecrement(param_1 + 1);

      if (LVar3 != 0) {

        return 0;

      }

      if (param_1 == (undefined4 *)0x0) {

        return 0;

      }

      (**(code **)*param_1)(1);

      return 0;

    }

    local_4 = local_4 + 1;

    pcVar2 = strchr(local_4,0x2e);

    cVar1 = FUN_005428f0(&local_4,param_3);

    if (cVar1 != '\0') {

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

        uVar4 = ntohl(*param_3);

        uVar5 = uVar4 >> 0x18;

        if (0x20 < uVar5) {

          FUN_005abb30();

          return 0;

        }

        *param_3 = 0;

        if (uVar5 != 0) {

          uVar6 = 0;

          do {

            uVar6 = uVar6 >> 1 | 0x80000000;

            uVar5 = uVar5 - 1;

          } while (uVar5 != 0);

          *param_3 = uVar6;

        }

        uVar4 = htonl(*param_3);

        *param_3 = uVar4;

      }

      LVar3 = InterlockedDecrement(param_1 + 1);

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

        (**(code **)*param_1)(1);

      }

      return 1;

    }

  }

  LVar3 = InterlockedDecrement(param_1 + 1);

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

    (**(code **)*param_1)(1);

    return 0;

  }

  return 0;

}





// --- FUN_00543f40 at 0x00543F40 (size: 119) ---


void __thiscall FUN_00543f40(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = FUN_0065f230(*(undefined4 *)(param_1 + 0x88bc),*(undefined4 *)(param_1 + 0x88ac));

  *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(param_2 + 4);

  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(param_2 + 8);

  *(undefined1 *)(param_1 + 0x88dc) = 0;

  if ((*(int *)(param_2 + 4) == DAT_00822344) && (*(int *)(param_2 + 8) == DAT_00822348)) {

    FUN_0065eb50(*(undefined4 *)(param_1 + 0x88bc),0x7ffffffe);

    return;

  }

  FUN_0065eb60(*(undefined4 *)(param_1 + 0x88bc));

  return;

}





// --- FUN_00543fc0 at 0x00543FC0 (size: 25) ---


void __fastcall FUN_00543fc0(int param_1)



{

  if (*(int *)(param_1 + 0x88bc) != DAT_00846f24) {

    FUN_00543f40(&DAT_008eeef4);

  }

  return;

}





// --- FUN_00544190 at 0x00544190 (size: 60) ---


void __thiscall FUN_00544190(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  

  for (iVar1 = *(int *)(param_1 + 35000); iVar1 != 0; iVar1 = iVar1 + -1) {

    (**(code **)(**(int **)(*(int *)(param_1 + 0x88b0) + -4 + iVar1 * 4) + 0xc))

              (param_2,param_3,param_4);

  }

  return;

}





// --- FUN_005441e0 at 0x005441E0 (size: 48) ---


void __fastcall FUN_005441e0(int param_1)



{

  int iVar1;

  int iVar2;

  

  iVar2 = *(int *)(param_1 + 35000);

  if (iVar2 != 0) {

    do {

      iVar1 = iVar2 * 4;

      iVar2 = iVar2 + -1;

      (**(code **)(**(int **)(*(int *)(param_1 + 0x88b0) + -4 + iVar1) + 8))(param_1 + 0x8ab8);

    } while (iVar2 != 0);

  }

  return;

}





// --- FUN_00544220 at 0x00544220 (size: 73) ---


undefined4 * FUN_00544220(undefined4 param_1,undefined2 param_2)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x20);

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

    puVar1[6] = param_1;

    puVar1[1] = 1;

    puVar1[2] = 0x8000000;

    puVar1[3] = 0x10;

    puVar1[4] = puVar1 + 6;

    puVar1[5] = 6;

    *puVar1 = &PTR_FUN_007e70f0;

    *(undefined2 *)(puVar1 + 7) = param_2;

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00544270 at 0x00544270 (size: 127) ---


undefined4 * FUN_00544270(int *param_1)



{

  int *piVar1;

  int iVar2;

  void *pvVar3;

  int iVar4;

  undefined4 *puVar5;

  

  piVar1 = param_1;

  iVar2 = (**(code **)(*param_1 + 8))();

  pvVar3 = (void *)thunk_FUN_005df0f5(iVar2);

  param_1 = pvVar3;

  iVar4 = (**(code **)(*piVar1 + 0xc))(&param_1,iVar2);

  if (iVar4 == iVar2) {

    puVar5 = (undefined4 *)FUN_005df0f5(0x30);

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

      puVar5[4] = pvVar3;

      puVar5[6] = pvVar3;

      puVar5[5] = iVar2;

      puVar5[7] = iVar2;

      puVar5[1] = 1;

      puVar5[2] = 0x100000;

      puVar5[3] = 7;

      *puVar5 = &PTR_FUN_007cae44;

      puVar5[8] = &PTR_FUN_00795878;

      return puVar5;

    }

  }

  else {

    operator_delete(pvVar3);

  }

  return (undefined4 *)0x0;

}





// --- FUN_005442f0 at 0x005442F0 (size: 73) ---


undefined4 * FUN_005442f0(void)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x38);

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

    puVar1[4] = puVar1 + 6;

    puVar3 = puVar1 + 6;

    for (iVar2 = 8; register0x00000010 = (BADSPACEBASE *)((int)register0x00000010 + 4), iVar2 != 0;

        iVar2 = iVar2 + -1) {

      *puVar3 = *(undefined4 *)register0x00000010;

      puVar3 = puVar3 + 1;

    }

    puVar1[1] = 1;

    puVar1[2] = 0x800;

    puVar1[3] = 0x40000062;

    puVar1[5] = 0x20;

    *puVar1 = &PTR_FUN_007e70f0;

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00544340 at 0x00544340 (size: 102) ---


void FUN_00544340(int *param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  

  for (; param_1 != param_2; param_1 = (int *)param_1[2]) {

    if (*param_1 == 0) {

      iVar2 = 1;

    }

    else {

      iVar2 = *(int *)(*param_1 + 0x14) + 1;

    }

    param_1[3] = iVar2;

    if (param_1[1] == 0) {

      iVar1 = 1;

    }

    else {

      iVar1 = *(int *)(param_1[1] + 0x14) + 1;

    }

    param_1[4] = iVar1;

    iVar3 = iVar2;

    if (iVar2 < iVar1) {

      iVar3 = iVar1;

    }

    param_1[5] = iVar3;

    uVar4 = iVar1 - iVar2 >> 0x1f;

    if ((iVar1 - iVar2 ^ uVar4) - uVar4 == 2) {

      FUN_00543560(param_1);

    }

  }

  return;

}





// --- FUN_005443b0 at 0x005443B0 (size: 143) ---


undefined4 * FUN_005443b0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  

  puVar3 = (undefined4 *)*param_2;

  while (puVar2 = param_2, param_2 = puVar3, param_2 != (undefined4 *)0x0) {

    puVar3 = (undefined4 *)*param_2;

    param_1 = puVar2;

  }

  if (puVar2[1] != 0) {

    cVar1 = *(char *)(puVar2 + 8);

    *(undefined4 **)(puVar2[1] + 8) = param_1;

    if (cVar1 != '\0') {

      *param_1 = puVar2[1];

      *(undefined1 *)(puVar2[1] + 0x20) = 1;

      FUN_00544340(param_1,0);

      return puVar2;

    }

    param_1[1] = puVar2[1];

    *(undefined1 *)(puVar2[1] + 0x20) = 0;

    FUN_00544340(param_1,0);

    return puVar2;

  }

  if (*(char *)(puVar2 + 8) != '\0') {

    *param_1 = 0;

    FUN_00544340(param_1,0);

    return puVar2;

  }

  param_1[1] = 0;

  FUN_00544340(param_1,0);

  return puVar2;

}





// --- FUN_00544450 at 0x00544450 (size: 63) ---


bool FUN_00544450(uint param_1,uint param_2)



{

  uint uVar1;

  int iVar2;

  

  if (param_1 == param_2) {

    return false;

  }

  uVar1 = param_1 - param_2;

  iVar2 = 1;

  if (param_1 < param_2) {

    uVar1 = param_2 - param_1;

    iVar2 = -1;

  }

  if (0x7fffffff < uVar1) {

    iVar2 = -iVar2;

  }

  return 0 < iVar2;

}





// --- FUN_00544490 at 0x00544490 (size: 64) ---


bool FUN_00544490(ushort param_1,ushort param_2)



{

  ushort uVar1;

  int iVar2;

  

  if (param_1 == param_2) {

    return false;

  }

  uVar1 = param_1 - param_2;

  iVar2 = 1;

  if (param_1 < param_2) {

    uVar1 = param_2 - param_1;

    iVar2 = -1;

  }

  if (0x7fff < uVar1) {

    iVar2 = -iVar2;

  }

  return 0 < iVar2;

}





// --- FUN_005444d0 at 0x005444D0 (size: 86) ---


int * __thiscall FUN_005444d0(int *param_1,wchar_t *param_2)



{

  size_t sVar1;

  LONG *lpAddend;

  

  if ((param_2 != (wchar_t *)0x0) && (*param_2 != L'\0')) {

    sVar1 = wcslen(param_2);

    FUN_00543680(sVar1);

    wcscpy((wchar_t *)(*param_1 + 0x14),param_2);

    return param_1;

  }

  lpAddend = (LONG *)(DAT_008ef12c + 4);

  *param_1 = DAT_008ef12c;

  InterlockedIncrement(lpAddend);

  return param_1;

}





// --- FUN_00544530 at 0x00544530 (size: 176) ---


undefined4 __thiscall FUN_00544530(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_00543610();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 0x28);

    if (iVar1 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        iVar2 = (iVar4 + -1) * 0x28;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          puVar6 = (undefined4 *)(iVar2 + iVar1);

          iVar2 = iVar2 + -0x28;

          iVar4 = iVar4 + -1;

          for (iVar3 = 10; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar6 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar6 = puVar6 + 1;

          }

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_005445e0 at 0x005445E0 (size: 89) ---


uint FUN_005445e0(int param_1)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  uVar1 = *(uint *)(param_1 + 0x124);

  uVar2 = *(int *)(*(int *)(param_1 + 0x10124) + 4) + 0x7fff;

  if (uVar1 != uVar2) {

    iVar4 = 1;

    uVar3 = uVar1 - uVar2;

    if (uVar1 < uVar2) {

      uVar2 = uVar2 - uVar1;

      iVar4 = -1;

      uVar3 = uVar2;

    }

    if (0x7fffffff < uVar3) {

      iVar4 = -iVar4;

    }

    if (0 < iVar4) {

      return uVar2 & 0xffffff00;

    }

  }

  return CONCAT31(0x9c,'\x01' - (40000 < *(uint *)(*(int *)(param_1 + 0x10124) + 0x50)));

}





// --- FUN_005446d0 at 0x005446D0 (size: 180) ---


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



void FUN_005446d0(ushort *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  uint uVar5;

  LONG LVar6;

  undefined4 *puVar7;

  

  uVar3 = DAT_008379ac;

  uVar2 = DAT_008379a8;

  if (_DAT_00795ee0 <= (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(param_1 + 8)) {

    uVar1 = *(undefined4 *)(param_1 + 2);

    puVar4 = (undefined4 *)FUN_005df0f5(0x1c);

    if (puVar4 == (undefined4 *)0x0) {

      puVar4 = (undefined4 *)0x0;

    }

    else {

      puVar4[6] = uVar1;

      puVar4[1] = 1;

      puVar4[2] = 0x4000;

      puVar4[3] = 1;

      puVar4[4] = puVar4 + 6;

      puVar4[5] = 4;

      *puVar4 = &PTR_FUN_007e70f0;

    }

    uVar5 = (uint)*param_1;

    puVar7 = puVar4;

    FUN_00541770(uVar5,puVar4);

    FUN_005419f0(uVar5,puVar7);

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

      LVar6 = InterlockedDecrement(puVar4 + 1);

      if (LVar6 == 0) {

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

      }

    }

    *(undefined4 *)(param_1 + 8) = uVar2;

    *(undefined4 *)(param_1 + 10) = uVar3;

  }

  return;

}





// --- FUN_00544790 at 0x00544790 (size: 236) ---


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



void FUN_00544790(ushort *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  uint uVar3;

  undefined4 *puVar4;

  LONG LVar5;

  int iVar6;

  undefined4 *puVar7;

  undefined4 *puVar8;

  undefined4 local_1cc [115];

  

  uVar2 = DAT_008379ac;

  uVar1 = DAT_008379a8;

  if (_DAT_007caea0 < (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(param_1 + 8)) {

    uVar3 = FUN_00549c20(local_1cc);

    puVar4 = (undefined4 *)FUN_005df0f5(0x1e4);

    if (puVar4 == (undefined4 *)0x0) {

      puVar4 = (undefined4 *)0x0;

    }

    else {

      puVar4[6] = uVar3;

      puVar4[4] = puVar4 + 6;

      puVar4[5] = uVar3 * 4 + 4;

      puVar4[1] = 1;

      puVar4[2] = 0x1000;

      puVar4[3] = 0x21;

      *puVar4 = &PTR_FUN_007e70f0;

      puVar7 = local_1cc;

      puVar8 = puVar4 + 7;

      for (uVar3 = uVar3 & 0x3fffffff; uVar3 != 0; uVar3 = uVar3 - 1) {

        *puVar8 = *puVar7;

        puVar7 = puVar7 + 1;

        puVar8 = puVar8 + 1;

      }

      for (iVar6 = 0; iVar6 != 0; iVar6 = iVar6 + -1) {

        *(undefined1 *)puVar8 = *(undefined1 *)puVar7;

        puVar7 = (undefined4 *)((int)puVar7 + 1);

        puVar8 = (undefined4 *)((int)puVar8 + 1);

      }

    }

    uVar3 = (uint)*param_1;

    puVar7 = puVar4;

    FUN_00541770(uVar3,puVar4);

    FUN_005419f0(uVar3,puVar7);

    if ((puVar4 != (undefined4 *)0x0) && (LVar5 = InterlockedDecrement(puVar4 + 1), LVar5 == 0)) {

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

    }

    *(undefined4 *)(param_1 + 8) = uVar1;

    *(undefined4 *)(param_1 + 10) = uVar2;

  }

  return;

}





// --- FUN_00544880 at 0x00544880 (size: 106) ---


void __thiscall FUN_00544880(int param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_0065f230(param_2,*(undefined4 *)(param_1 + 0x24));

  *(undefined4 *)(param_1 + 0x5c) = *(undefined4 *)(iVar1 + 4);

  *(undefined4 *)(param_1 + 0x60) = *(undefined4 *)(iVar1 + 8);

  *(undefined4 *)(param_1 + 0x34) = DAT_00846f24;

  if ((*(int *)(param_1 + 0x5c) == DAT_00822344) && (*(int *)(param_1 + 0x60) == DAT_00822348)) {

    FUN_00544190(3,0,0);

    return;

  }

  FUN_00544190(4,param_1 + 0x58,0);

  return;

}





// --- FUN_005448f0 at 0x005448F0 (size: 232) ---


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



void __thiscall FUN_005448f0(int param_1,int param_2,int param_3)



{

  int iVar1;

  double dVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 local_18;

  undefined4 uStack_14;

  undefined4 local_10;

  undefined4 uStack_c;

  

  local_18 = *(undefined4 *)(param_2 + 0x18);

  iVar1 = *(int *)(param_3 + 0x10128);

  uStack_14 = *(undefined4 *)(param_2 + 0x1c);

  local_10 = DAT_008379a8;

  uStack_c = DAT_008379ac;

  FUN_0040fb00(&local_18);

  dVar2 = (double)CONCAT44(uStack_c,local_10);

  if (dVar2 <= (double)CONCAT44(uStack_14,local_18) + _DAT_007b2440) {

    *(undefined4 *)(param_1 + 0x8a88) = 0;

    *(undefined4 *)(param_1 + 0x8a8c) = 0;

  }

  else {

    if (*(double *)(param_1 + 0x8a88) == _DAT_00795610) {

      *(double *)(param_1 + 0x8a88) = dVar2;

      return;

    }

    if ((*(double *)(param_1 + 0x8a88) + _DAT_007b2440 < dVar2) && (iVar1 != 0)) {

      uVar3 = FUN_00544270(&DAT_008eef00);

      uVar4 = (uint)*(ushort *)(iVar1 + 0x37c);

      FUN_00541770(uVar4,uVar3);

      FUN_005419f0(uVar4,uVar3);

      FUN_00405f70();

      return;

    }

  }

  return;

}





// --- FUN_00544ab0 at 0x00544AB0 (size: 153) ---


void __fastcall FUN_00544ab0(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

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

  puVar2 = (undefined4 *)FUN_005df0f5(0x1c);

  if (puVar2 == (undefined4 *)0x0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    puVar2[1] = 1;

    puVar2[2] = 0x8000;

    puVar2[3] = 3;

    puVar2[4] = puVar2 + 6;

    puVar2[5] = 0;

    *puVar2 = &PTR_FUN_007e70f0;

    puVar2[6] = 0;

  }

  for (; iVar1 != 0; iVar1 = *(int *)(iVar1 + 8)) {

    FUN_00543d20(puVar2,iVar1 + 0x30,iVar1);

  }

  if ((puVar2 != (undefined4 *)0x0) && (LVar3 = InterlockedDecrement(puVar2 + 1), LVar3 == 0)) {

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

  }

  *(undefined1 *)(param_1 + 0x8a84) = 1;

  *(undefined2 *)(param_1 + 0x8a6c) = 0;

  FUN_005429e0();

  return;

}





// --- FUN_00544b50 at 0x00544B50 (size: 351) ---


uint FUN_00544b50(undefined4 *param_1,uint param_2)



{

  uint uVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined1 uVar4;

  uint uVar5;

  undefined4 *puVar6;

  LONG LVar7;

  int iVar8;

  undefined4 *local_1c [2];

  undefined4 uStack_14;

  undefined4 uStack_10;

  undefined4 uStack_c;

  undefined2 uStack_8;

  undefined2 uStack_6;

  undefined2 uStack_4;

  undefined2 uStack_2;

  

  uVar1 = param_2;

  uVar5 = 0;

  if (param_2 != 0) {

    local_1c[0] = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    puVar2 = param_1;

    FUN_005ab580(param_1,local_1c,0);

    FUN_0048c3e0(&DAT_007caea8);

    puVar6 = (undefined4 *)FUN_005ac3a0(&param_1,uVar1);

    puVar3 = param_1;

    LVar7 = InterlockedDecrement(param_1 + 1);

    if ((LVar7 == 0) && (puVar3 != (undefined4 *)0x0)) {

      (**(code **)*puVar3)(1);

    }

    uVar1 = puVar6[3];

    param_2 = param_2 & 0xffffff00;

    if (((((uVar1 & 0x10) == 0) && ((uVar1 & 1) != 0)) && ((uVar1 & 2) != 0)) &&

       (((uVar1 & 8) == 0 && ((uVar1 & 4) != 0)))) {

      iVar8 = FUN_00543760(0);

      FUN_00549fc0(puVar6);

      uStack_10 = puVar6[2];

      uStack_6 = 0;

      uStack_4 = *(undefined2 *)(iVar8 + 0x110);

      uStack_c = *(undefined4 *)(iVar8 + 0x11c);

      uStack_14 = 0;

      uStack_8 = 0;

      uStack_2 = 0;

      uVar4 = FUN_00542780(iVar8,&uStack_14,puVar2);

      param_2 = CONCAT31(param_2._1_3_,uVar4);

      FUN_00405f70();

    }

    LVar7 = InterlockedDecrement(puVar6 + 1);

    if (LVar7 == 0) {

      (**(code **)*puVar6)(1);

    }

    puVar2 = local_1c[0];

    LVar7 = InterlockedDecrement(local_1c[0] + 1);

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

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

    }

    uVar5 = param_2 & 0xff;

  }

  return uVar5;

}





// --- FUN_00544cb0 at 0x00544CB0 (size: 246) ---


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



bool FUN_00544cb0(int param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  char cVar3;

  u_short uVar4;

  undefined4 *puVar5;

  int iVar6;

  LONG LVar7;

  undefined2 local_10;

  u_short uStack_e;

  undefined2 local_c;

  undefined2 uStack_a;

  undefined4 local_8;

  undefined4 local_4;

  

  *(undefined8 *)(param_1 + 0x60) = _DAT_008379b0;

  local_10 = (undefined2)*(undefined4 *)(param_1 + 0x30);

  uStack_e = (u_short)((uint)*(undefined4 *)(param_1 + 0x30) >> 0x10);

  local_8 = *(undefined4 *)(param_1 + 0x38);

  local_c = (undefined2)*(undefined4 *)(param_1 + 0x34);

  uStack_a = (undefined2)((uint)*(undefined4 *)(param_1 + 0x34) >> 0x10);

  local_4 = *(undefined4 *)(param_1 + 0x3c);

  uVar4 = ntohs(uStack_e);

  uStack_e = htons(uVar4 + 1);

  uVar1 = *(undefined4 *)(param_1 + 0x70);

  uVar2 = *(undefined4 *)(param_1 + 0x74);

  puVar5 = (undefined4 *)FUN_005df0f5(0x20);

  if (puVar5 == (undefined4 *)0x0) {

    puVar5 = (undefined4 *)0x0;

  }

  else {

    puVar5[6] = uVar1;

    puVar5[1] = 1;

    puVar5[2] = 0x80000;

    puVar5[3] = 0x20000007;

    puVar5[4] = puVar5 + 6;

    puVar5[5] = 8;

    *puVar5 = &PTR_FUN_007e70f0;

    puVar5[7] = uVar2;

  }

  cVar3 = FUN_00543d20(puVar5,&local_10,param_1);

  if (cVar3 != '\0') {

    FUN_005498f0();

    iVar6 = FUN_005df4c4();

    FUN_00544190(2,iVar6 + 1,0);

  }

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

    LVar7 = InterlockedDecrement(puVar5 + 1);

    if (LVar7 == 0) {

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

    }

  }

  return cVar3 != '\0';

}





// --- FUN_00544db0 at 0x00544DB0 (size: 539) ---


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



void __fastcall FUN_00544db0(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  int iVar4;

  double dVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 *puVar8;

  int iVar9;

  LONG LVar10;

  uint uVar11;

  int iVar12;

  int iVar13;

  uint uVar14;

  undefined4 *puVar15;

  undefined4 local_30 [3];

  undefined2 local_24;

  undefined2 local_22;

  undefined2 local_20;

  undefined2 local_1e;

  

  uVar7 = DAT_008379b4;

  uVar6 = DAT_008379b0;

  uVar14 = *(uint *)(param_1 + 0x8a68);

  if (uVar14 != 0) {

    iVar12 = uVar14 * 0x28;

    do {

      iVar13 = iVar12 + -0x28;

      piVar1 = (int *)(iVar13 + *(int *)(param_1 + 0x8a60));

      uVar14 = uVar14 - 1;

      if (*(double *)(iVar12 + -0x20 + *(int *)(param_1 + 0x8a60)) < (double)CONCAT44(uVar7,uVar6))

      {

        dVar5 = (double)*piVar1;

        if (*piVar1 < 0) {

          dVar5 = dVar5 + _DAT_00795518;

        }

        if (_DAT_007caeb0 / _DAT_007cad78 <= dVar5) {

          if (uVar14 < *(uint *)(param_1 + 0x8a68)) {

            uVar11 = *(uint *)(param_1 + 0x8a68) - 1;

            *(uint *)(param_1 + 0x8a68) = uVar11;

            if (uVar14 != uVar11) {

              puVar8 = (undefined4 *)(*(int *)(param_1 + 0x8a60) + uVar11 * 0x28);

              puVar15 = (undefined4 *)(iVar13 + *(int *)(param_1 + 0x8a60));

              for (iVar12 = 10; iVar12 != 0; iVar12 = iVar12 + -1) {

                *puVar15 = *puVar8;

                puVar8 = puVar8 + 1;

                puVar15 = puVar15 + 1;

              }

              puVar8 = local_30;

              puVar15 = (undefined4 *)

                        (*(int *)(param_1 + 0x8a60) + *(int *)(param_1 + 0x8a68) * 0x28);

              for (iVar12 = 10; iVar12 != 0; iVar12 = iVar12 + -1) {

                *puVar15 = *puVar8;

                puVar8 = puVar8 + 1;

                puVar15 = puVar15 + 1;

              }

            }

          }

          FUN_00544190(5,0,0);

        }

        else {

          dVar5 = _DAT_007cad78 + (double)CONCAT44(uVar7,uVar6);

          *piVar1 = *piVar1 + 1;

          *(double *)(iVar12 + -0x20 + *(int *)(param_1 + 0x8a60)) = dVar5;

          uVar2 = *(undefined4 *)(iVar12 + -8 + *(int *)(param_1 + 0x8a60));

          uVar3 = *(undefined4 *)(iVar12 + -4 + *(int *)(param_1 + 0x8a60));

          puVar8 = (undefined4 *)FUN_005df0f5(0x20);

          if (puVar8 == (undefined4 *)0x0) {

            puVar8 = (undefined4 *)0x0;

          }

          else {

            puVar8[6] = uVar2;

            puVar8[1] = 1;

            puVar8[2] = 0x20000;

            puVar8[3] = 7;

            puVar8[4] = puVar8 + 6;

            puVar8[5] = 8;

            *puVar8 = &PTR_FUN_007e70f0;

            puVar8[7] = uVar3;

          }

          iVar4 = *(int *)(param_1 + 0x8a60);

          uVar11 = puVar8[3];

          if (((((uVar11 & 0x10) == 0) && ((uVar11 & 1) != 0)) && ((uVar11 & 2) != 0)) &&

             (((uVar11 & 8) == 0 && ((uVar11 & 4) != 0)))) {

            iVar9 = FUN_00543760(0);

            FUN_00549fc0(puVar8);

            local_30[1] = puVar8[2];

            local_22 = 0;

            local_20 = *(undefined2 *)(iVar9 + 0x110);

            local_30[2] = *(undefined4 *)(iVar9 + 0x11c);

            local_30[0] = 0;

            local_24 = 0;

            local_1e = 0;

            FUN_00542780(iVar9,local_30,iVar12 + -0x18 + iVar4);

            FUN_00405f70();

          }

          LVar10 = InterlockedDecrement(puVar8 + 1);

          if (LVar10 == 0) {

            (**(code **)*puVar8)(1);

          }

        }

      }

      iVar12 = iVar13;

    } while (uVar14 != 0);

  }

  return;

}





// --- FUN_00544fe0 at 0x00544FE0 (size: 357) ---


/* WARNING: Removing unreachable block (ram,0x0054504c) */



int __thiscall FUN_00544fe0(int *param_1,uint param_2)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  int *piVar5;

  int *piVar6;

  

  piVar6 = (int *)*param_1;

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

    uVar1 = piVar6[6];

    piVar5 = (int *)0x0;

    while( true ) {

      piVar4 = piVar6;

      if (uVar1 == param_2) {

        iVar2 = piVar4[7];

        iVar3 = piVar4[1];

        if ((iVar3 == 0) && (*piVar4 == 0)) {

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

            *param_1 = 0;

          }

          else if ((char)piVar4[8] == '\0') {

            piVar5[1] = 0;

          }

          else {

            *piVar5 = 0;

          }

          *piVar4 = 0;

          piVar4[1] = 0;

          if (piVar4[1] != 0) {

            FUN_00542af0(1);

          }

          *piVar4 = 0;

          piVar4[1] = 0;

          operator_delete(piVar4);

          FUN_00544340(piVar5,0);

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

          return iVar2;

        }

        if (iVar3 == 0) {

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

            *param_1 = *piVar4;

          }

          else if ((char)piVar4[8] == '\0') {

            piVar5[1] = *piVar4;

            *(undefined1 *)(*piVar4 + 0x20) = 0;

            *(int **)(*piVar4 + 8) = piVar5;

          }

          else {

            *piVar5 = *piVar4;

            *(undefined1 *)(*piVar4 + 0x20) = 1;

            *(int **)(*piVar4 + 8) = piVar5;

          }

          *(undefined4 *)(*param_1 + 8) = 0;

          piVar6 = piVar4;

        }

        else {

          piVar6 = (int *)FUN_005443b0(piVar4,iVar3);

        }

        piVar4[7] = piVar6[7];

        piVar4[6] = piVar6[6];

        *piVar6 = 0;

        piVar6[1] = 0;

        if (*piVar6 != 0) {

          FUN_00542af0(1);

        }

        if (piVar6[1] != 0) {

          FUN_00542af0(1);

        }

        *piVar6 = 0;

        piVar6[1] = 0;

        operator_delete(piVar6);

        FUN_00544340(piVar5,0);

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

        return iVar2;

      }

      if (param_2 < (uint)piVar4[6]) {

        piVar6 = (int *)*piVar4;

      }

      else {

        piVar6 = (int *)piVar4[1];

      }

      if (piVar6 == (int *)0x0) break;

      uVar1 = piVar6[6];

      piVar5 = piVar4;

    }

  }

  return 0;

}





// --- FUN_00545250 at 0x00545250 (size: 256) ---


undefined4 __thiscall FUN_00545250(undefined4 *param_1,int param_2)



{

  short *psVar1;

  int iVar2;

  int iVar3;

  char cVar4;

  undefined4 uVar5;

  undefined4 *local_4;

  

  iVar3 = param_2;

  psVar1 = *(short **)(param_2 + 0x10124);

  *(undefined4 *)(param_2 + 0x118) = 0;

  iVar2 = *(int *)(param_2 + 0x124);

  if ((psVar1 != (short *)0x0) && ((iVar2 == 0 || (*psVar1 != 0)))) {

    cVar4 = FUN_005445e0(param_2);

    if (cVar4 == '\0') {

      (**(code **)*param_1)(2,1);

      return 0;

    }

    local_4 = (undefined4 *)0x0;

    param_2 = 0;

    if (((*(byte *)(iVar3 + 0x128) & 2) != 0) &&

       (cVar4 = FUN_00544450(iVar2,*(undefined4 *)(psVar1 + 2)), cVar4 == '\0')) {

      param_2 = FUN_00544fe0(iVar2);

      if (param_2 == 0) {

        return 0;

      }

      local_4 = &param_2;

      FUN_00543320(psVar1);

    }

    cVar4 = FUN_00544450(iVar2,*(undefined4 *)(psVar1 + 2));

    if (cVar4 != '\0') {

      FUN_00542510(iVar3);

    }

    if ((*(byte *)(iVar3 + 0x128) & 2) != 0) {

      uVar5 = FUN_00549880(*(undefined4 *)(iVar3 + 0x124),iVar3 + 300,4,local_4);

      *(undefined4 *)(iVar3 + 0x118) = uVar5;

    }

    return 1;

  }

  (**(code **)*param_1)(2,1);

  return 0;

}





// --- FUN_00545350 at 0x00545350 (size: 347) ---


byte __thiscall FUN_00545350(int *param_1,int param_2)



{

  short sVar1;

  int iVar2;

  char cVar3;

  byte bVar4;

  byte bVar5;

  uint uVar6;

  undefined4 uVar7;

  

  cVar3 = (**(code **)(*param_1 + 0x24))(param_2);

  if (cVar3 == '\0') {

    return 0;

  }

  *(int **)(param_2 + 0x10124) = param_1 + (uint)*(ushort *)(param_2 + 0x130) * 0x22 + 8;

  uVar6 = (uint)*(ushort *)(param_2 + 0x130);

  FUN_00541770(uVar6);

  uVar7 = FUN_00541800(uVar6);

  *(undefined4 *)(param_2 + 0x10128) = uVar7;

  if (*(int *)(param_2 + 0x124) == 0) {

    if ((*(byte *)(param_2 + 0x128) & 2) != 0) {

      return 0;

    }

  }

  else {

    cVar3 = FUN_00545250(param_2);

    if (cVar3 == '\0') {

      return 0;

    }

  }

  bVar4 = (**(code **)(*param_1 + 0x28))(param_2);

  if (bVar4 != 0) {

    sVar1 = *(short *)(*(int *)(param_2 + 0x10124) + 0x40);

    if ((sVar1 == 0) ||

       (cVar3 = FUN_00544490(*(undefined2 *)(param_2 + 0x132),sVar1), cVar3 != '\0')) {

      bVar5 = (**(code **)(*param_1 + 0x2c))(param_2);

      bVar4 = bVar4 | bVar5;

    }

    *(int *)(*(int *)(param_2 + 0x10124) + 0x68) =

         *(int *)(*(int *)(param_2 + 0x10124) + 0x68) + *(int *)(param_2 + 0x110) + 0x14;

    if ((*(int *)(param_2 + 0x8c) != 0) &&

       (cVar3 = (**(code **)(*param_1 + 0x30))(param_2), cVar3 == '\0')) {

      bVar4 = 0;

    }

    uVar7 = DAT_008379b4;

    iVar2 = *(int *)(param_2 + 0x10124);

    if (iVar2 != 0) {

      *(undefined4 *)(iVar2 + 0x18) = DAT_008379b0;

      *(undefined4 *)(iVar2 + 0x1c) = uVar7;

      if ((*(int *)(param_2 + 0x104) != 0) &&

         (cVar3 = (**(code **)(*param_1 + 0x38))(param_2), cVar3 == '\0')) {

        bVar4 = 0;

      }

    }

    return bVar4;

  }

  if (*(int *)(param_2 + 0x10124) == 0) {

    return 0;

  }

  if (*(int *)(param_2 + 0x124) == 0) {

    return 0;

  }

  if ((*(byte *)(param_2 + 0x128) & 2) == 0) {

    return 0;

  }

  FUN_00549da0(*(int *)(param_2 + 0x124),&stack0xfffffffc);

  return 0;

}





// --- FUN_005456c0 at 0x005456C0 (size: 1287) ---


undefined4 * __thiscall

FUN_005456c0(int param_1,undefined4 *param_2,undefined4 *param_3,ulong param_4,undefined4 *param_5,

            int param_6)



{

  char cVar1;

  u_short uVar2;

  char *pcVar3;

  LONG LVar4;

  char *pcVar5;

  int *piVar6;

  ulong uVar7;

  SOCKET SVar8;

  int iVar9;

  u_long *puVar10;

  int iVar11;

  u_long uVar12;

  undefined4 uVar13;

  undefined4 *puVar14;

  uint uVar15;

  uint uVar16;

  undefined4 *puVar17;

  undefined4 *local_30;

  int iStack_28;

  int aiStack_24 [5];

  sockaddr sStack_10;

  

  puVar14 = param_3;

  FUN_0048c3e0(param_3);

  FUN_0048c3e0(&DAT_0079552c);

  puVar17 = param_3;

  pcVar3 = strstr((char *)(local_30 + 5),(char *)(param_3 + 5));

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

    pcVar3 = (char *)0xffffffff;

  }

  else {

    pcVar3 = pcVar3 + (-0x14 - (int)local_30);

  }

  LVar4 = InterlockedDecrement(puVar17 + 1);

  if ((LVar4 == 0) && (puVar17 != (undefined4 *)0x0)) {

    (**(code **)*puVar17)(1);

  }

  if (pcVar3 != (char *)0xffffffff) {

    param_3 = (undefined4 *)((uint)param_3 & 0xffffff00);

    if ((pcVar3 < (char *)local_30[2]) && ((pcVar3 + 0x14)[(int)local_30] != '\0')) {

      if (pcVar3 == (char *)local_30[2] + -1) {

        FUN_004910c0(&param_3,1);

      }

      else {

        FUN_00411870();

        (pcVar3 + 0x14)[(int)local_30] = (char)param_3;

        if ((char)param_3 == '\0') {

          pcVar3 = (char *)(local_30 + 5);

          do {

            cVar1 = *pcVar3;

            pcVar3 = pcVar3 + 1;

          } while (cVar1 != '\0');

          local_30[2] = pcVar3 + (1 - ((int)local_30 + 0x15));

        }

      }

    }

    puVar14 = local_30 + 5;

  }

  FUN_0048c3e0(&DAT_007caef4);

  puVar17 = param_3;

  pcVar3 = strstr((char *)(local_30 + 5),(char *)(param_3 + 5));

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

    pcVar3 = (char *)0xffffffff;

  }

  else {

    pcVar3 = pcVar3 + (-0x14 - (int)local_30);

  }

  LVar4 = InterlockedDecrement(puVar17 + 1);

  if ((LVar4 == 0) && (puVar17 != (undefined4 *)0x0)) {

    (**(code **)*puVar17)(1);

  }

  uVar7 = param_4;

  if (pcVar3 != (char *)0xffffffff) {

    param_3 = (undefined4 *)((uint)param_3 & 0xffffff00);

    if ((pcVar3 < (char *)local_30[2]) && ((pcVar3 + 0x14)[(int)local_30] != '\0')) {

      if (pcVar3 == (char *)local_30[2] + -1) {

        FUN_004910c0(&param_3,1);

      }

      else {

        FUN_00411870();

        (pcVar3 + 0x14)[(int)local_30] = (char)param_3;

        if ((char)param_3 == '\0') {

          pcVar5 = (char *)(local_30 + 5);

          do {

            cVar1 = *pcVar5;

            pcVar5 = pcVar5 + 1;

          } while (cVar1 != '\0');

          local_30[2] = pcVar5 + (1 - ((int)local_30 + 0x15));

        }

      }

    }

    puVar14 = local_30 + 5;

    FUN_0048c3e0(pcVar3 + 1 + (int)puVar14);

    puVar17 = param_3;

    pcVar3 = (char *)(param_3 + 5);

    piVar6 = _errno();

    *piVar6 = 0;

    uVar7 = strtoul(pcVar3,(char **)0x0,0);

    if (uVar7 == 0) {

      uVar7 = 0x1c88;

    }

    LVar4 = InterlockedDecrement(puVar17 + 1);

    if ((LVar4 == 0) && (puVar17 != (undefined4 *)0x0)) {

      (**(code **)*puVar17)(1);

    }

  }

  puVar17 = param_5;

  *param_5 = 0;

  param_5[1] = 0;

  param_5[2] = 0;

  param_5[3] = 0;

  *(undefined2 *)param_5 = 2;

  uVar2 = htons((u_short)uVar7);

  *(u_short *)((int)puVar17 + 2) = uVar2;

  cVar1 = FUN_005ab500(puVar14,puVar17 + 1);

  if (cVar1 == '\0') {

    *param_2 = &PTR_FUN_00795878;

    param_2[1] = DAT_008eeec8;

    uVar13 = DAT_008eeecc;

  }

  else {

    SVar8 = socket(2,2,0);

    *(SOCKET *)(param_1 + 0xc) = SVar8;

    *(SOCKET *)(param_1 + 0x10) = SVar8;

    sStack_10.sa_data[2] = '\0';

    sStack_10.sa_data[3] = '\0';

    sStack_10.sa_data[4] = '\0';

    sStack_10.sa_data[5] = '\0';

    sStack_10.sa_data[6] = '\0';

    sStack_10.sa_data[7] = '\0';

    sStack_10.sa_data[8] = '\0';

    sStack_10.sa_data[9] = '\0';

    sStack_10.sa_data[10] = '\0';

    sStack_10.sa_data[0xb] = '\0';

    sStack_10.sa_data[0xc] = '\0';

    sStack_10.sa_data[0xd] = '\0';

    sStack_10.sa_family = 2;

    sStack_10.sa_data[0] = '\0';

    sStack_10.sa_data[1] = '\0';

    sStack_10.sa_data._2_4_ = htonl(0);

    FUN_005ac5f0();

    iVar9 = FUN_004f1b20();

    puVar10 = (u_long *)FUN_004f8d90();

    uVar12 = 0;

    if (iVar9 != 0) {

      iVar11 = *(int *)(param_6 + 0x14);

      if (*(int *)(iVar11 + 8) != 1) {

        puVar14 = &param_3;

        puVar17 = &param_4;

        InterlockedIncrement((LONG *)(iVar11 + 4));

        cVar1 = FUN_00543e10(iVar11,puVar17,puVar14);

        if ((cVar1 != '\0') && (iVar11 = 0, 0 < iVar9)) {

          do {

            if ((puVar10[iVar11] & (uint)param_3) == param_4) {

              uVar12 = puVar10[iVar11];

              sStack_10.sa_data._2_4_ = uVar12;

              goto LAB_005459aa;

            }

            iVar11 = iVar11 + 1;

          } while (iVar11 < iVar9);

        }

      }

      uVar12 = *puVar10;

    }

LAB_005459aa:

    FUN_005ac690();

    cVar1 = '\0';

    if (*(int *)(param_6 + 0x1c) == 0) {

      uVar2 = htons((u_short)*(undefined4 *)(param_6 + 0x18));

      sStack_10.sa_data._0_2_ = uVar2;

      iVar9 = bind(*(SOCKET *)(param_1 + 0xc),&sStack_10,0x10);

      cVar1 = '\x01' - (iVar9 != 0);

LAB_00545b05:

      if (cVar1 == '\0') {

        *param_2 = &PTR_FUN_00795878;

        param_2[1] = DAT_008eeed4;

        param_2[2] = DAT_008eeed8;

        LVar4 = InterlockedDecrement(local_30 + 1);

        if (LVar4 != 0) {

          return param_2;

        }

        if (local_30 == (undefined4 *)0x0) {

          return param_2;

        }

        (**(code **)*local_30)(1);

        return param_2;

      }

    }

    else {

      uVar12 = htonl(uVar12);

      uVar16 = uVar12 % 0xfa07;

      do {

        uVar15 = uVar16 + 0x100;

        uVar16 = uVar15 & 0xffff;

        if (uVar16 == uVar12 % 0xfa07) goto LAB_00545b05;

        if (0x3ff < uVar16) {

          uVar2 = htons((u_short)uVar15);

          sStack_10.sa_data._0_2_ = uVar2;

          iVar9 = bind(*(SOCKET *)(param_1 + 0xc),&sStack_10,0x10);

          cVar1 = '\x01' - (iVar9 != 0);

        }

      } while (cVar1 == '\0');

    }

    iStack_28 = 4;

    getsockopt(*(SOCKET *)(param_1 + 0xc),0xffff,0x1002,(char *)aiStack_24,&iStack_28);

    iVar9 = 0x20000;

    if (aiStack_24[0] < 0x20000) {

      do {

        iVar11 = (iVar9 + aiStack_24[0]) / 2 + (iVar9 + aiStack_24[0]) % 2;

        param_6 = iVar11;

        setsockopt(*(SOCKET *)(param_1 + 0xc),0xffff,0x1002,(char *)&param_6,4);

        iStack_28 = 4;

        getsockopt(*(SOCKET *)(param_1 + 0xc),0xffff,0x1002,(char *)&param_6,&iStack_28);

        if (param_6 < iVar11) {

          iVar9 = iVar11 + -1;

          iVar11 = aiStack_24[0];

        }

        aiStack_24[0] = iVar11;

      } while (aiStack_24[0] < iVar9);

    }

    aiStack_24[1] = 1;

    ioctlsocket(*(SOCKET *)(param_1 + 0xc),-0x7ffb9982,(u_long *)(aiStack_24 + 1));

    *param_2 = &PTR_FUN_00795878;

    param_2[1] = DAT_00822344;

    uVar13 = DAT_00822348;

  }

  param_2[2] = uVar13;

  LVar4 = InterlockedDecrement(local_30 + 1);

  if ((LVar4 == 0) && (local_30 != (undefined4 *)0x0)) {

    (**(code **)*local_30)(1);

  }

  return param_2;

}





// --- FUN_00545bd0 at 0x00545BD0 (size: 232) ---


void __thiscall

FUN_00545bd0(int param_1,undefined4 *param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,int param_6,undefined4 *param_7)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  undefined1 local_c [4];

  undefined4 local_8;

  undefined4 local_4;

  

  puVar1 = param_7;

  local_4 = DAT_008eefb0;

  local_8 = DAT_008eefac;

  puVar5 = (undefined4 *)(param_1 + 0x8a98);

  for (iVar4 = 7; iVar4 != 0; iVar4 = iVar4 + -1) {

    *puVar5 = 0;

    puVar5 = puVar5 + 1;

  }

  puVar5 = param_7;

  puVar6 = (undefined4 *)(param_1 + 0x886c);

  for (iVar4 = 5; iVar4 != 0; iVar4 = iVar4 + -1) {

    *puVar6 = *puVar5;

    puVar5 = puVar5 + 1;

    puVar6 = puVar6 + 1;

  }

  uVar2 = FUN_0040fa90();

  *(undefined4 *)(param_1 + 0x8a70) = uVar2;

  *(undefined1 *)(param_1 + 0x8a78) = 0;

  *(undefined1 *)(param_1 + 0x8a80) = 0;

  if (param_6 == 0) {

    param_2[1] = local_8;

    param_2[2] = local_4;

    *param_2 = &PTR_FUN_00795878;

    return;

  }

  *(undefined4 *)(param_6 + 0xc) = uVar2;

  iVar3 = FUN_005456c0(local_c,param_4,param_3,param_1 + 0x88c4,puVar1);

  iVar4 = *(int *)(iVar3 + 4);

  iVar3 = *(int *)(iVar3 + 8);

  if ((DAT_00822344 == iVar4) && (DAT_00822348 == iVar3)) {

    *(int *)(param_1 + 0x88d4) = param_6;

    FUN_0065f250(&param_7);

  }

  param_2[1] = iVar4;

  param_2[2] = iVar3;

  *param_2 = &PTR_FUN_00795878;

  return;

}





// --- FUN_00545f80 at 0x00545F80 (size: 118) ---


void __thiscall FUN_00545f80(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_00541770();

  if (iVar1 != 0) {

    uVar2 = param_2;

    FUN_00541770(param_2);

    FUN_00541e80(uVar2);

  }

  FUN_005497f0(param_1 + 0x8820,param_1 + 0x8824);

  FUN_00549b60();

  if ((((short)param_2 == *(short *)(param_1 + 0x8a6c)) ||

      ((short)param_2 == *(short *)(param_1 + 0x8a6e))) && (*(char *)(param_1 + 0x8a84) == '\0')) {

    FUN_00544ab0();

    FUN_00693a20();

  }

  return;

}





// --- FUN_00546000 at 0x00546000 (size: 16) ---


void FUN_00546000(void)



{

  FUN_00544db0();

  FUN_005432d0();

  return;

}





// --- FUN_00546230 at 0x00546230 (size: 82) ---


undefined4 __thiscall FUN_00546230(int *param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if ((param_1[1] & 0x7fffffffU) <= (uint)param_1[2]) {

    uVar1 = FUN_00453850((param_1[1] & 0x7fffffffU) + 1);

    uVar1 = FUN_00544530(uVar1);

    if ((char)uVar1 == '\0') {

      return uVar1;

    }

  }

  puVar3 = (undefined4 *)(*param_1 + param_1[2] * 0x28);

  for (iVar2 = 10; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = *param_2;

    param_2 = param_2 + 1;

    puVar3 = puVar3 + 1;

  }

  iVar2 = param_1[2];

  param_1[2] = iVar2 + 1;

  return CONCAT31((int3)((uint)(iVar2 + 1) >> 8),1);

}





// --- FUN_00546290 at 0x00546290 (size: 738) ---


/* WARNING: Removing unreachable block (ram,0x005463a8) */

/* WARNING: Removing unreachable block (ram,0x005464a6) */

/* WARNING: Heritage AFTER dead removal. Example location: r0x00000000 : 0x00546564 */

/* WARNING: Restarted to delay deadcode elimination for space: ram */



undefined4 * __thiscall FUN_00546290(int *param_1,undefined4 *param_2,ushort param_3)



{

  LONG *pLVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  int iVar5;

  ushort *puVar6;

  DWORD DVar7;

  DWORD DVar8;

  int *piVar9;

  undefined *puVar10;

  undefined4 *unaff_ESI;

  uint uVar11;

  undefined4 *puStack_50;

  undefined1 *puStack_4c;

  char *pcStack_48;

  int iStack_28;

  int local_c [2];

  int *local_4;

  

  puVar3 = DAT_008ef11c;

  pLVar1 = DAT_008ef11c + 1;

  local_4 = param_1;

  InterlockedIncrement(pLVar1);

  if (*(int *)(*param_1 + 8) == 1) {

    *param_2 = puVar3;

    InterlockedIncrement(pLVar1);

    LVar4 = InterlockedDecrement(pLVar1);

    if (LVar4 != 0) {

      return param_2;

    }

    if (puVar3 == (undefined4 *)0x0) {

      return param_2;

    }

    (**(code **)*puVar3)();

    return param_2;

  }

  local_c[0] = 0;

  puVar10 = &DAT_007953a4;

  piVar9 = local_c;

  if (param_3 < 0xcec9) {

    if (param_3 != 0xcec8) {

      switch(param_3) {

      case 0xc42c:

      case 0xc42d:

      case 0xc42e:

      case 0xc431:

      case 0xc433:

      case 0xc435:

        break;

      default:

        goto switchD_00546321_caseD_c42f;

      }

    }

  }

  else if (param_3 < 0xdeb4) {

    if ((param_3 < 0xdeaa) && (param_3 != 0xd698)) goto switchD_00546321_caseD_c42f;

  }

  else if ((param_3 < 65000) || (0xfde9 < param_3)) goto switchD_00546321_caseD_c42f;

  piVar9 = (int *)0x0;

  puVar10 = (undefined *)0x0;

switchD_00546321_caseD_c42f:

  iVar5 = (*(code *)PTR_FUN_00837398)();

  if (iVar5 == 0) {

    iVar5 = *(int *)(*piVar9 + 8) + -1;

    pcStack_48 = (char *)0x54639c;

    InterlockedDecrement((LONG *)0x4);

    pcStack_48 = (char *)0x5463b8;

    FUN_00403560();

    uVar11 = 0;

    iRam00000008 = 1;

    if (0 < iVar5) {

      iStack_28 = 0x14;

      do {

        puVar3 = DAT_008ef11c;

        iVar2 = *piVar9;

        if (uVar11 < *(uint *)(iVar2 + 8)) {

          puVar6 = (ushort *)(iVar2 + iStack_28);

        }

        else {

          puVar6 = (ushort *)(iVar2 + 0x12 + *(uint *)(iVar2 + 8) * 2);

        }

        if (*puVar6 < 0x80) {

          pcStack_48 = &stack0xffffffe8;

          puStack_4c = (undefined1 *)0x54646f;

          FUN_004910c0();

        }

        else {

          pcStack_48 = (char *)0x54640a;

          InterlockedIncrement(DAT_008ef11c + 1);

          puStack_4c = &stack0xffffffe8;

          pcStack_48 = "<%04x>";

          puStack_50 = (undefined4 *)0x54641d;

          FUN_00487620();

          if (puVar3 != DAT_008ef11c) {

            pcStack_48 = (char *)(puVar3 + 5);

            puStack_4c = (undefined1 *)0x54643f;

            FUN_004910c0();

          }

          pcStack_48 = (char *)0x546449;

          LVar4 = InterlockedDecrement(puVar3 + 1);

          if ((LVar4 == 0) && (puVar3 != (undefined4 *)0x0)) {

            pcStack_48 = (char *)0x546459;

            (**(code **)*puVar3)();

          }

        }

        uVar11 = uVar11 + 1;

        iStack_28 = iStack_28 + 2;

      } while ((int)uVar11 < iVar5);

    }

    *unaff_ESI = 0;

    pcStack_48 = (char *)0x546497;

    InterlockedIncrement((LONG *)0x4);

    pcStack_48 = (char *)0x54649e;

    InterlockedDecrement((LONG *)0x4);

    return unaff_ESI;

  }

  pcStack_48 = (char *)0x5464c4;

  FUN_00403560();

  puStack_50 = (undefined4 *)0x14;

  puStack_4c = (undefined1 *)iVar5;

  pcStack_48 = puVar10;

  iVar5 = (*(code *)PTR_FUN_00837398)(param_3,0,*piVar9 + 0x14,*(undefined4 *)(*piVar9 + 8));

  if (iVar5 == 0) {

    DVar7 = GetLastError();

    DVar8 = GetLastError();

    FUN_00487620(&puStack_50,"Failed conversion to codepage %hu! GetLastError %d (0x%08x)\n",param_3

                 ,DVar8,DVar7);

    puVar3 = puStack_50;

    pLVar1 = puStack_50 + 1;

    puRam00000000 = puStack_50;

    InterlockedIncrement(pLVar1);

    LVar4 = InterlockedDecrement(pLVar1);

    if ((LVar4 == 0) && (puVar3 != (undefined4 *)0x0)) {

      (**(code **)*puVar3)(1);

      return (undefined4 *)0x0;

    }

  }

  else {

    puRam00000000 = (undefined4 *)0x0;

    iRam00000008 = iVar5;

    InterlockedIncrement((LONG *)0x4);

    LVar4 = InterlockedDecrement((LONG *)0x4);

    if (LVar4 == 0) {

      (*(code *)0x0)(1);

    }

  }

  return (undefined4 *)0x0;

}





// --- FUN_00546590 at 0x00546590 (size: 231) ---


void __fastcall FUN_00546590(undefined4 *param_1)



{

  int *piVar1;

  uint uVar2;

  short *psVar3;

  int iVar4;

  

  param_1[-0x2222] = &PTR_LAB_007caf20;

  *param_1 = &PTR_FUN_007caf00;

  iVar4 = 0;

  psVar3 = (short *)(param_1 + -0x221a);

  do {

    if (*psVar3 != 0) {

      FUN_00545f80(iVar4);

    }

    iVar4 = iVar4 + 1;

    psVar3 = psVar3 + 0x44;

  } while (iVar4 < 0x100);

  closesocket(param_1[-0x221f]);

  FUN_00547e70();

  if ((param_1[0x77] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)param_1[0x76]);

  }

  FUN_006602c0();

  param_1[0x16] = &PTR_FUN_0079385c;

  if (param_1 == (undefined4 *)0x8888) {

    piVar1 = (int *)0x0;

  }

  else {

    piVar1 = param_1 + 10;

  }

  uVar2 = 0;

  if (piVar1[2] != 0) {

    do {

      *(undefined4 *)(*(int *)(*piVar1 + uVar2 * 4) + 4) = 0;

      uVar2 = uVar2 + 1;

    } while (uVar2 < (uint)piVar1[2]);

  }

  piVar1[2] = 0;

  if ((piVar1[1] & 0x80000000U) == 0x80000000) {

    operator_delete__((void *)*piVar1);

  }

  FUN_006605b0();

  FUN_005438a0();

  return;

}





// --- FUN_005468c0 at 0x005468C0 (size: 40) ---


int __thiscall FUN_005468c0(int param_1,byte param_2)



{

  FUN_00546590();

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

    operator_delete((void *)(param_1 + -0x8888));

  }

  return param_1 + -0x8888;

}





// --- FUN_005469e0 at 0x005469E0 (size: 92) ---


bool FUN_005469e0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

                 undefined4 param_5)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x28);

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

    FUN_00683e60(param_2,param_3,param_4,param_5);

    *puVar1 = &PTR_FUN_007cac54;

    puVar1[8] = 0;

    puVar1[9] = 0;

    *param_1 = puVar1;

    return puVar1 != (undefined4 *)0x0;

  }

  *param_1 = 0;

  return false;

}





// --- FUN_00546a40 at 0x00546A40 (size: 1245) ---


undefined4 * __thiscall FUN_00546a40(undefined4 *param_1,wchar_t *param_2)



{

  DWORD DVar1;

  undefined4 uVar2;

  size_t sVar3;

  LONG LVar4;

  int iVar5;

  wchar_t *pwVar6;

  undefined4 *puVar7;

  wchar_t *local_1c;

  undefined1 local_18 [12];

  undefined1 local_c [12];

  

  *param_1 = &PTR_LAB_007cae50;

  FUN_005ab7c0();

  param_1[3] = 0xffffffff;

  param_1[4] = 0xffffffff;

  *(undefined2 *)(param_1 + 6) = param_2._0_2_;

  iVar5 = 0x100;

  do {

    FUN_00549990();

    iVar5 = iVar5 + -1;

  } while (iVar5 != 0);

  param_1[0x2208] = 0;

  param_1[0x2209] = 0;

  param_1[0x220a] = 0;

  param_1[0x220b] = 0;

  param_1[0x220d] = 0x32;

  DVar1 = GetTickCount();

  param_1[0x220c] = DVar1;

  param_1[0x221b] = 0;

  param_1[0x221c] = 0;

  param_1[0x221d] = 0;

  param_1[0x221e] = 0;

  param_1[0x221f] = 0;

  DAT_00846f18 = param_1;

  FUN_005b1900(0);

  FUN_005b1900(0);

  iVar5 = FUN_005df0f5(0x18);

  if (iVar5 == 0) {

    iVar5 = 0;

  }

  else {

    FUN_005b1900(0);

    FUN_005b1900(0);

  }

  param_1[5] = iVar5;

  FUN_005b1bc0("dd80c2e508b630998076a9f7319c930d954f2866f53932baa2938467f25ed069");

  FUN_005b1bc0("dd80c2e508b630998076a9f7319c930d954f2866f53932baa2938467f2602bfb");

  FUN_005b1300(local_c,local_18);

  FUN_005b19d0();

  FUN_005b19d0();

  puVar7 = param_1 + 0x220e;

  for (iVar5 = 8; iVar5 != 0; iVar5 = iVar5 + -1) {

    *puVar7 = 0;

    puVar7 = puVar7 + 1;

  }

  uVar2 = FUN_005ab6a0();

  param_1[0x2220] = uVar2;

  sVar3 = wcslen(L"Bytes sent via \'sendto\' calls.");

  FUN_004022d0(sVar3);

  wcscpy(local_1c,L"Bytes sent via \'sendto\' calls.");

  sVar3 = wcslen(L"Net - Bytes sent/sec");

  FUN_004022d0(sVar3);

  wcscpy(param_2,L"Net - Bytes sent/sec");

  iVar5 = FUN_00683a80(&param_2,9);

  if (iVar5 == 0) {

    FUN_005469e0(param_1 + 0x2216,2,&param_2,&local_1c,9);

  }

  else {

    param_1[0x2216] = iVar5;

  }

  pwVar6 = param_2 + -10;

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  pwVar6 = local_1c + -10;

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  sVar3 = wcslen(L"Bytes received.");

  FUN_004022d0(sVar3);

  wcscpy(local_1c,L"Bytes received.");

  sVar3 = wcslen(L"Net - Bytes received/sec");

  FUN_004022d0(sVar3);

  wcscpy(param_2,L"Net - Bytes received/sec");

  iVar5 = FUN_00683a80(&param_2,9);

  if (iVar5 == 0) {

    FUN_005469e0(param_1 + 0x2217,2,&param_2,&local_1c,9);

  }

  else {

    param_1[0x2217] = iVar5;

  }

  pwVar6 = param_2 + -10;

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  pwVar6 = local_1c + -10;

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  sVar3 = wcslen(L"Packet rejection rate.");

  FUN_004022d0(sVar3);

  wcscpy(local_1c,L"Packet rejection rate.");

  sVar3 = wcslen(L"Net - Bad packets received/sec");

  FUN_004022d0(sVar3);

  wcscpy(param_2,L"Net - Bad packets received/sec");

  iVar5 = FUN_00683a80(&param_2,9);

  if (iVar5 == 0) {

    FUN_005469e0(param_1 + 0x2218,2,&param_2,&local_1c,9);

  }

  else {

    param_1[0x2218] = iVar5;

  }

  pwVar6 = param_2 + -10;

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  pwVar6 = local_1c + -10;

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  sVar3 = wcslen(L"Total rejected packets.");

  FUN_004022d0(sVar3);

  wcscpy(local_1c,L"Total rejected packets.");

  sVar3 = wcslen(L"Net - Total bad packets received");

  FUN_004022d0(sVar3);

  wcscpy(param_2,L"Net - Total bad packets received");

  iVar5 = FUN_00683a80(&param_2,9);

  if (iVar5 == 0) {

    FUN_005469e0(param_1 + 0x2219,0,&param_2,&local_1c,9);

  }

  else {

    param_1[0x2219] = iVar5;

  }

  pwVar6 = param_2 + -10;

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  pwVar6 = local_1c + -10;

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  sVar3 = wcslen(L"Rate at which we have had to re-send a packet.");

  FUN_004022d0(sVar3);

  wcscpy(local_1c,L"Rate at which we have had to re-send a packet.");

  sVar3 = wcslen(L"Net - Packets retransmitted/sec");

  FUN_004022d0(sVar3);

  wcscpy(param_2,L"Net - Packets retransmitted/sec");

  iVar5 = FUN_00683a80(&param_2,9);

  if (iVar5 == 0) {

    FUN_005469e0(param_1 + 0x221a,2,&param_2,&local_1c,9);

  }

  else {

    param_1[0x221a] = iVar5;

  }

  pwVar6 = param_2 + -10;

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -8));

  if ((LVar4 == 0) && (pwVar6 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar6)(1);

  }

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((LVar4 == 0) && (local_1c + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_1c + -10))(1);

  }

  return param_1;

}





// --- FUN_00546f20 at 0x00546F20 (size: 213) ---


undefined4 * __fastcall FUN_00546f20(undefined4 *param_1)



{

  undefined4 *puVar1;

  uint _Seed;

  int iVar2;

  undefined4 *puVar3;

  

  FUN_00546a40(0);

  puVar1 = param_1 + 0x2222;

  FUN_0065ece0(0);

  *puVar1 = &PTR_FUN_007cae14;

  param_1[0x222c] = 0;

  param_1[0x222d] = 0;

  param_1[0x222e] = 0;

  *param_1 = &PTR_LAB_007caf20;

  *puVar1 = &PTR_FUN_007caf00;

  param_1[0x222f] = 0;

  param_1[0x2238] = &PTR_FUN_00795878;

  FUN_00660220();

  param_1[0x2298] = 0;

  param_1[0x2299] = 0;

  param_1[0x229a] = 0;

  *(undefined2 *)(param_1 + 0x229b) = 0;

  *(undefined2 *)((int)param_1 + 0x8a6e) = 0;

  param_1[0x229c] = 0;

  param_1[0x229d] = 0;

  param_1[0x229f] = 0;

  *(undefined1 *)(param_1 + 0x22a1) = 0;

  *(undefined1 *)((int)param_1 + 0x8a85) = 0;

  FUN_00542f40();

  puVar3 = param_1 + 0x222f;

  for (iVar2 = 0xc; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = 0;

    puVar3 = puVar3 + 1;

  }

  _Seed = FUN_0040fa90();

  srand(_Seed);

  FUN_005496d0();

  FUN_0065fc60(puVar1);

  return param_1;

}





// --- FUN_00547000 at 0x00547000 (size: 98) ---


/* WARNING: Removing unreachable block (ram,0x00547031) */



void __thiscall FUN_00547000(int param_1,float param_2)



{

  if (*(ushort *)(param_1 + 0x18) != 4) {

    *(float *)(param_1 + (uint)*(ushort *)(param_1 + 0x18) * 4) = param_2;

    *(short *)(param_1 + 0x18) = *(short *)(param_1 + 0x18) + 1;

    *(double *)(param_1 + 0x10) = (double)(param_2 + (float)*(double *)(param_1 + 0x10));

    return;

  }

  *(double *)(param_1 + 0x10) =

       (double)((float)*(double *)(param_1 + 0x10) -

               *(float *)(param_1 + (uint)*(ushort *)(param_1 + 0x1a) * 4));

  *(float *)(param_1 + (uint)*(ushort *)(param_1 + 0x1a) * 4) = param_2;

  *(ushort *)(param_1 + 0x1a) = *(short *)(param_1 + 0x1a) + 1U & 3;

  *(double *)(param_1 + 0x10) = (double)(param_2 + (float)*(double *)(param_1 + 0x10));

  return;

}





// --- FUN_00547070 at 0x00547070 (size: 103) ---


void __thiscall FUN_00547070(int param_1,ushort param_2)



{

  if (*(ushort *)(param_1 + 0x58) == 0x28) {

    *(double *)(param_1 + 0x50) =

         *(double *)(param_1 + 0x50) -

         (double)*(ushort *)(param_1 + (uint)*(ushort *)(param_1 + 0x5a) * 2);

    *(ushort *)(param_1 + (uint)*(ushort *)(param_1 + 0x5a) * 2) = param_2;

    *(ushort *)(param_1 + 0x5a) = (ushort)(*(short *)(param_1 + 0x5a) + 1U) % 0x28;

  }

  else {

    *(ushort *)(param_1 + (uint)*(ushort *)(param_1 + 0x58) * 2) = param_2;

    *(short *)(param_1 + 0x58) = *(short *)(param_1 + 0x58) + 1;

  }

  *(double *)(param_1 + 0x50) = (double)param_2 + *(double *)(param_1 + 0x50);

  return;

}





// --- FUN_005470e0 at 0x005470E0 (size: 115) ---


/* WARNING: Removing unreachable block (ram,0x0054711e) */

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



void __thiscall FUN_005470e0(int param_1,int param_2)



{

  double dVar1;

  uint uVar2;

  

  if (*(ushort *)(param_1 + 0x10) == 2) {

    uVar2 = (uint)*(ushort *)(param_1 + 0x12);

    dVar1 = (double)*(int *)(param_1 + uVar2 * 4);

    if (*(int *)(param_1 + uVar2 * 4) < 0) {

      dVar1 = dVar1 + _DAT_00795518;

    }

    *(double *)(param_1 + 8) = *(double *)(param_1 + 8) - dVar1;

    *(int *)(param_1 + uVar2 * 4) = param_2;

    *(ushort *)(param_1 + 0x12) = *(short *)(param_1 + 0x12) + 1U & 1;

  }

  else {

    *(int *)(param_1 + (uint)*(ushort *)(param_1 + 0x10) * 4) = param_2;

    *(short *)(param_1 + 0x10) = *(short *)(param_1 + 0x10) + 1;

  }

  dVar1 = (double)param_2;

  if (param_2 < 0) {

    dVar1 = dVar1 + _DAT_00795518;

  }

  *(double *)(param_1 + 8) = dVar1 + *(double *)(param_1 + 8);

  return;

}





// --- FUN_00547160 at 0x00547160 (size: 107) ---


/* WARNING: Removing unreachable block (ram,0x00547199) */



void __thiscall FUN_00547160(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  

  if (*(ushort *)(param_1 + 0x18) != 2) {

    *(ulonglong *)(param_1 + (uint)*(ushort *)(param_1 + 0x18) * 8) = CONCAT44(param_3,param_2);

    *(short *)(param_1 + 0x18) = *(short *)(param_1 + 0x18) + 1;

    *(double *)(param_1 + 0x10) = (double)CONCAT44(param_3,param_2) + *(double *)(param_1 + 0x10);

    return;

  }

  puVar1 = (undefined4 *)(param_1 + (uint)*(ushort *)(param_1 + 0x1a) * 8);

  *(double *)(param_1 + 0x10) =

       *(double *)(param_1 + 0x10) - *(double *)(param_1 + (uint)*(ushort *)(param_1 + 0x1a) * 8);

  *puVar1 = param_2;

  puVar1[1] = param_3;

  *(ushort *)(param_1 + 0x1a) = *(short *)(param_1 + 0x1a) + 1U & 1;

  *(double *)(param_1 + 0x10) = (double)CONCAT44(param_3,param_2) + *(double *)(param_1 + 0x10);

  return;

}





// --- FUN_005471d0 at 0x005471D0 (size: 51) ---


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



float10 __fastcall FUN_005471d0(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)*(double *)(param_1 + 0x158) + (float10)*(double *)(param_1 + 0x98);

  if (fVar1 < (float10)_DAT_00795610 != (fVar1 == (float10)_DAT_00795610)) {

    return (float10)_DAT_00795610;

  }

  fVar1 = ((float10)*(double *)(param_1 + 0x1b8) + (float10)*(double *)(param_1 + 0xf8)) / fVar1;

  return fVar1 + fVar1;

}





// --- FUN_00547210 at 0x00547210 (size: 219) ---


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



void __thiscall FUN_00547210(undefined4 *param_1,undefined4 *param_2)



{

  float fVar1;

  undefined8 uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined8 local_8;

  

  uVar2 = _DAT_008379b0;

  fVar1 = (float)param_2[6];

  local_8 = (double)fVar1;

  if ((*(double *)(param_1 + 8) == _DAT_00795610) ||

     (fVar1 < (float)_DAT_00795610 != (fVar1 == (float)_DAT_00795610))) {

    local_8 = 1.0;

  }

  puVar4 = param_2;

  puVar5 = param_1;

  for (iVar3 = 7; iVar3 != 0; iVar3 = iVar3 + -1) {

    *puVar5 = *puVar4;

    puVar4 = puVar4 + 1;

    puVar5 = puVar5 + 1;

  }

  *(undefined8 *)(param_1 + 8) = uVar2;

  FUN_00547070(*(undefined2 *)(param_2 + 1));

  FUN_00547070(*(undefined2 *)((int)param_2 + 6));

  FUN_00547070(*(undefined2 *)(param_2 + 2));

  FUN_00547070(*(undefined2 *)((int)param_2 + 10));

  FUN_005470e0(param_2[3]);

  FUN_005470e0(param_2[4]);

  FUN_00547160((undefined4)local_8,local_8._4_4_);

  return;

}





// --- FUN_005472f0 at 0x005472F0 (size: 8) ---


void FUN_005472f0(void)



{

  FUN_00547000();

  return;

}





// --- FUN_00547300 at 0x00547300 (size: 156) ---


undefined1 FUN_00547300(int param_1)



{

  ushort uVar1;

  bool bVar2;

  undefined1 uVar3;

  int iVar4;

  undefined4 uVar5;

  undefined2 uVar6;

  undefined8 uVar7;

  

  iVar4 = FUN_00541770();

  if ((iVar4 != 0) && (param_1 != 0)) {

    uVar1 = *(ushort *)(param_1 + 0x3e);

    bVar2 = false;

    uVar6 = *(undefined2 *)(DAT_00846f18 + 0x8a6e);

    if ((3 < uVar1) && ((uVar1 < 6 || (uVar1 == 8)))) {

      uVar6 = *(undefined2 *)(DAT_00846f18 + 0x8a6c);

      bVar2 = true;

    }

    if (*(int *)(param_1 + 0x20) == 0 && *(int *)(param_1 + 0x24) == 0) {

      uVar5 = 0x23000000;

      if (!bVar2) {

        uVar5 = 0x3000000;

      }

      uVar7 = FUN_005497b0();

      uVar7 = FUN_005ab420(0,uVar5,DAT_00846f3c,uVar7);

      DAT_00846f3c = DAT_00846f3c + 1;

      *(undefined8 *)(param_1 + 0x20) = uVar7;

    }

    uVar3 = FUN_0054a6a0(uVar6,5);

    return uVar3;

  }

  return 0;

}





// --- FUN_005473a0 at 0x005473A0 (size: 12) ---


void FUN_005473a0(void)



{

  DAT_00846f38 = DAT_00846f38 + 1;

  return;

}





// --- FUN_005473b0 at 0x005473B0 (size: 7) ---


void FUN_005473b0(void)



{

  DAT_00846f38 = DAT_00846f38 + -1;

  return;

}





// --- FUN_005473c0 at 0x005473C0 (size: 10) ---


void FUN_005473c0(undefined4 param_1)



{

  DAT_00846f38 = param_1;

  return;

}





// --- FUN_005473d0 at 0x005473D0 (size: 97) ---


bool FUN_005473d0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  bool bVar4;

  

  bVar4 = false;

  iVar1 = FUN_00541770();

  if (iVar1 != 0) {

    iVar1 = FUN_005df0f5(0x50);

    if (iVar1 == 0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      puVar2 = (undefined4 *)FUN_0054a6f0(param_1,param_2,3);

    }

    iVar1 = FUN_00547300(puVar2);

    bVar4 = iVar1 != 0;

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

  }

  return bVar4;

}





// --- FUN_00547440 at 0x00547440 (size: 98) ---


bool FUN_00547440(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  iVar1 = FUN_00541770();

  if (iVar1 == 0) {

    return false;

  }

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 == 0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    puVar2 = (undefined4 *)FUN_0054a6f0(param_1,param_2,2);

  }

  iVar1 = FUN_00547300(puVar2);

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  return iVar1 != 0;

}





// --- FUN_005474b0 at 0x005474B0 (size: 98) ---


bool FUN_005474b0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  iVar1 = FUN_00541770();

  if (iVar1 == 0) {

    return false;

  }

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 == 0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    puVar2 = (undefined4 *)FUN_0054a6f0(param_1,param_2,4);

  }

  iVar1 = FUN_00547300(puVar2);

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  return iVar1 != 0;

}





// --- FUN_00547520 at 0x00547520 (size: 98) ---


bool FUN_00547520(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  iVar1 = FUN_00541770();

  if (iVar1 == 0) {

    return false;

  }

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 == 0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    puVar2 = (undefined4 *)FUN_0054a6f0(param_1,param_2,5);

  }

  iVar1 = FUN_00547300(puVar2);

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  return iVar1 != 0;

}





// --- FUN_00547590 at 0x00547590 (size: 35) ---


undefined1 FUN_00547590(undefined4 param_1)



{

  undefined1 uVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(8);

  *puVar2 = 0xf6ea;

  puVar2[1] = param_1;

  uVar1 = FUN_00547440(puVar2,8);

  return uVar1;

}





// --- FUN_005475c0 at 0x005475C0 (size: 28) ---


undefined1 FUN_005475c0(void)



{

  undefined1 uVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(4);

  *puVar2 = 0xf7c8;

  uVar1 = FUN_005474b0(puVar2,4);

  return uVar1;

}





// --- FUN_005475e0 at 0x005475E0 (size: 35) ---


undefined1 FUN_005475e0(undefined4 param_1)



{

  undefined1 uVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(8);

  *puVar2 = 0xf653;

  puVar2[1] = param_1;

  uVar1 = FUN_005474b0(puVar2,8);

  return uVar1;

}





// --- FUN_00547610 at 0x00547610 (size: 28) ---


undefined1 FUN_00547610(void)



{

  undefined1 uVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(4);

  *puVar2 = 0xf7cc;

  uVar1 = FUN_00547440(puVar2,4);

  return uVar1;

}





// --- FUN_00547630 at 0x00547630 (size: 188) ---


undefined1 FUN_00547630(int *param_1,undefined4 param_2,undefined4 param_3,int param_4)



{

  undefined1 uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  LONG LVar5;

  undefined4 *unaff_retaddr;

  undefined4 *puStack_8;

  undefined4 local_4;

  

  local_4 = 0;

  iVar2 = FUN_004fd290(&local_4,0);

  iVar3 = (**(code **)(*param_1 + 8))();

  iVar3 = iVar2 + 4 + iVar3;

  puVar4 = (undefined4 *)thunk_FUN_005df0f5(iVar3);

  *puVar4 = 0xf656;

  puStack_8 = puVar4 + 1;

  FUN_004fd290(&puStack_8,iVar3);

  (**(code **)(*param_1 + 0xc))(&puStack_8,iVar3);

  if (param_4 == 0) {

    uVar1 = FUN_005474b0(puVar4,iVar3);

  }

  else {

    uVar1 = FUN_005474b0(puVar4,iVar3);

  }

  LVar5 = InterlockedDecrement(unaff_retaddr + 1);

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

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

  }

  return uVar1;

}





// --- FUN_005476f0 at 0x005476F0 (size: 130) ---


undefined1 FUN_005476f0(undefined4 *param_1)



{

  undefined1 uVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  undefined4 in_stack_00000014;

  undefined4 *local_4;

  

  local_4 = (undefined4 *)0x0;

  iVar2 = FUN_004fd290(&local_4,0);

  iVar2 = iVar2 + 8;

  puVar3 = (undefined4 *)thunk_FUN_005df0f5(iVar2);

  local_4 = puVar3 + 1;

  *puVar3 = 0xf655;

  FUN_004fd290(&local_4,iVar2);

  *local_4 = in_stack_00000014;

  uVar1 = FUN_005474b0(puVar3,iVar2);

  LVar4 = InterlockedDecrement(param_1 + 1);

  if ((LVar4 == 0) && (param_1 != (undefined4 *)0x0)) {

    (**(code **)*param_1)(1);

  }

  return uVar1;

}





// --- FUN_00547780 at 0x00547780 (size: 129) ---


undefined1 FUN_00547780(undefined4 *param_1,undefined4 *param_2)



{

  undefined1 uVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  undefined4 local_4;

  

  local_4 = 0;

  iVar2 = FUN_004fd290(&local_4,0);

  iVar2 = iVar2 + 8;

  puVar3 = (undefined4 *)thunk_FUN_005df0f5(iVar2);

  *puVar3 = 0xf657;

  puVar3[1] = param_1;

  param_1 = puVar3 + 2;

  FUN_004fd290(&param_1,iVar2);

  uVar1 = FUN_005474b0(puVar3,iVar2);

  puVar3 = param_2;

  LVar4 = InterlockedDecrement(param_2 + 1);

  if ((LVar4 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return uVar1;

}





// --- FUN_00547810 at 0x00547810 (size: 147) ---


undefined1 __thiscall FUN_00547810(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  undefined1 uVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  

  FUN_0048c3e0(*param_3);

  param_3 = (undefined4 *)0x0;

  iVar2 = FUN_004fd290(&param_3,0);

  puVar3 = (undefined4 *)thunk_FUN_005df0f5(iVar2 + 8);

  *puVar3 = 0xf7cd;

  puVar3[1] = param_2;

  param_3 = puVar3 + 2;

  FUN_004fd290(&param_3,iVar2);

  uVar1 = FUN_00547440(puVar3,iVar2 + 8);

  LVar4 = InterlockedDecrement(param_1 + 1);

  if ((LVar4 == 0) && (param_1 != (undefined4 *)0x0)) {

    (**(code **)*param_1)(1);

  }

  return uVar1;

}





// --- FUN_005478b0 at 0x005478B0 (size: 223) ---


undefined1 __thiscall

FUN_005478b0(undefined4 *param_1,undefined4 param_2,undefined4 *param_3,undefined4 *param_4)



{

  undefined1 uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  LONG LVar5;

  

  FUN_0048c3e0(*param_3);

  FUN_0048c3e0(*param_4);

  param_3 = (undefined4 *)0x0;

  iVar2 = FUN_004fd290(&param_3,0);

  iVar3 = FUN_004fd290(&param_3,0);

  iVar3 = iVar2 + 8 + iVar3;

  puVar4 = (undefined4 *)thunk_FUN_005df0f5(iVar3);

  *puVar4 = 0xf7d9;

  puVar4[1] = param_2;

  param_3 = puVar4 + 2;

  FUN_004fd290(&param_3,iVar3);

  FUN_004fd290(&param_3,iVar3);

  uVar1 = FUN_00547440(puVar4,iVar3);

  puVar4 = param_4;

  LVar5 = InterlockedDecrement(param_4 + 1);

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

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

  }

  LVar5 = InterlockedDecrement(param_1 + 1);

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

    (**(code **)*param_1)(1);

  }

  return uVar1;

}





// --- FUN_00547990 at 0x00547990 (size: 22) ---


void __fastcall FUN_00547990(double *param_1)



{

  int iVar1;

  

  iVar1 = FUN_0040fa90();

  *param_1 = (double)iVar1;

  return;

}





// --- FUN_005479b0 at 0x005479B0 (size: 34) ---


undefined4 FUN_005479b0(int param_1)



{

  FUN_0054b340(param_1,*(undefined2 *)(param_1 + 0x108));

  return 1;

}





// --- FUN_005479e0 at 0x005479E0 (size: 26) ---


void __fastcall FUN_005479e0(int param_1)



{

  int iVar1;

  

  iVar1 = param_1;

  FUN_00541770(param_1);

  FUN_005417a0(iVar1);

                    /* WARNING: Could not recover jumptable at 0x005479f7. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*(int *)(param_1 + 0x20) + 4))();

  return;

}





// --- FUN_00547a00 at 0x00547A00 (size: 57) ---


void __fastcall FUN_00547a00(int param_1)



{

  FUN_00549580();

  if (*(int *)(param_1 + 0x38c) != 0) {

    FUN_00548280(*(int *)(param_1 + 0x38c),0);

    *(undefined4 *)(param_1 + 0x38c) = 0;

  }

  FUN_0054af30();

  return;

}





// --- FUN_00547a40 at 0x00547A40 (size: 183) ---


double * __thiscall

FUN_00547a40(double *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8)



{

  int iVar1;

  undefined4 uVar2;

  

  *(undefined4 *)param_1 = 0;

  *(undefined4 *)((int)param_1 + 4) = 0;

  *(undefined4 *)((int)param_1 + 0x14) = 0;

  *(undefined4 *)(param_1 + 3) = 0;

  FUN_00549260(param_3,param_4,param_5,param_6,param_2,param_8);

  *(undefined4 *)(param_1 + 0x6f) = 0;

  *(short *)((int)param_1 + 0x37c) = (short)param_2;

  *(undefined4 *)(param_1 + 0x70) = 0;

  *(undefined4 *)((int)param_1 + 900) = 0;

  *(undefined4 *)(param_1 + 0x71) = 0;

  *(undefined4 *)((int)param_1 + 0x38c) = 0;

  uVar2 = DAT_008379ac;

  *(undefined4 *)(param_1 + 1) = DAT_008379a8;

  *(undefined4 *)((int)param_1 + 0xc) = uVar2;

  iVar1 = FUN_005df0f5(0x58);

  if (iVar1 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_0054adb0();

  }

  *(undefined4 *)((int)param_1 + 900) = uVar2;

  *(double **)(param_1 + 100) = param_1;

  iVar1 = FUN_0040fa90();

  *param_1 = (double)iVar1;

  return param_1;

}





// --- FUN_00547b00 at 0x00547B00 (size: 140) ---


void __fastcall FUN_00547b00(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  undefined4 *puVar4;

  

  while( true ) {

    puVar1 = *(undefined4 **)(param_1 + 0x14);

    if (puVar1 == (undefined4 *)0x0) {

      puVar4 = (undefined4 *)0x0;

    }

    else {

      iVar2 = puVar1[1];

      *(int *)(param_1 + 0x14) = iVar2;

      if (iVar2 == 0) {

        *(undefined4 *)(param_1 + 0x18) = 0;

      }

      puVar4 = (undefined4 *)*puVar1;

      operator_delete(puVar1);

    }

    if (puVar4 == (undefined4 *)0x0) break;

    LVar3 = InterlockedDecrement(puVar4 + 1);

    if (LVar3 == 0) {

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

    }

  }

  FUN_00549340();

  *(undefined4 *)(param_1 + 0x38c) = 0;

  FUN_00548280(0,1);

  *(undefined4 *)(param_1 + 0x38c) = 0;

  if (*(undefined4 **)(param_1 + 900) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 900))(1);

  }

  FUN_00549650();

  FUN_004c65a0();

  return;

}





// --- FUN_00547b90 at 0x00547B90 (size: 61) ---


void __thiscall FUN_00547b90(int param_1,uint param_2)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  

  uVar1 = *(uint *)(param_1 + 0x38c);

  if (param_2 != uVar1) {

    uVar2 = param_2 - uVar1;

    iVar3 = 1;

    if (param_2 < uVar1) {

      uVar2 = uVar1 - param_2;

      iVar3 = -1;

    }

    if (0x7fffffff < uVar2) {

      iVar3 = -iVar3;

    }

    if (0 < iVar3) {

      *(uint *)(param_1 + 0x38c) = param_2;

    }

  }

  return;

}





// --- FUN_00547c70 at 0x00547C70 (size: 70) ---


void FUN_00547c70(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

  iVar1 = param_1;

  param_1 = *(undefined4 *)(param_1 + 0x11c);

  uVar3 = 4;

  uVar2 = FUN_00549870(param_2,&param_1,4,param_3);

  *(undefined4 *)(iVar1 + 0x11c) = uVar3;

  *(uint *)(iVar1 + 0x120) = *(uint *)(iVar1 + 0x120) | 1;

  *(undefined4 *)(iVar1 + 0x118) = uVar2;

  return;

}





// --- FUN_00547cf0 at 0x00547CF0 (size: 97) ---


void __fastcall FUN_00547cf0(int *param_1)



{

  void *pvVar1;

  int iVar2;

  

  if (param_1[2] == 0) {

    param_1[1] = *(int *)(param_1[1] + 4);

    param_1 = (int *)*param_1;

    pvVar1 = (void *)*param_1;

    if (pvVar1 != (void *)0x0) {

      iVar2 = *(int *)((int)pvVar1 + 4);

      *param_1 = iVar2;

      if (iVar2 == 0) {

        param_1[1] = 0;

      }

      operator_delete(pvVar1);

      return;

    }

  }

  else {

    *(undefined4 *)(param_1[2] + 4) = *(undefined4 *)(param_1[1] + 4);

    if (*(int *)(param_1[2] + 4) == 0) {

      *(int *)(*param_1 + 4) = param_1[2];

    }

    operator_delete((void *)param_1[1]);

    param_1[1] = *(int *)(param_1[2] + 4);

  }

  return;

}





// --- FUN_00547d60 at 0x00547D60 (size: 44) ---


undefined4 * __thiscall FUN_00547d60(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb2a8;

  operator_delete__((void *)param_1[1]);

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00547d90 at 0x00547D90 (size: 73) ---


void __fastcall FUN_00547d90(int param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(*(int *)(param_1 + 0xc) << 4);

  puVar4 = *(undefined4 **)(param_1 + 4);

  puVar5 = puVar1;

  for (uVar2 = (uint)(*(int *)(param_1 + 0xc) << 3) >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar5 = *puVar4;

    puVar4 = puVar4 + 1;

    puVar5 = puVar5 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar5 = *(undefined1 *)puVar4;

    puVar4 = (undefined4 *)((int)puVar4 + 1);

    puVar5 = (undefined4 *)((int)puVar5 + 1);

  }

  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) << 1;

  operator_delete__(*(void **)(param_1 + 4));

  *(undefined4 **)(param_1 + 4) = puVar1;

  return;

}





// --- FUN_00547de0 at 0x00547DE0 (size: 97) ---


void __thiscall FUN_00547de0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  

  iVar2 = *(int *)(param_1 + 4);

  iVar5 = iVar2 + -8;

  while( true ) {

    iVar1 = param_2 * 2 + 1;

    if ((*(int *)(param_1 + 8) < param_2 * 2) ||

       (iVar6 = param_2 * 2, *(uint *)(iVar5 + param_2 * 8) <= *(uint *)(iVar5 + param_2 * 0x10))) {

      iVar6 = param_2;

    }

    if ((iVar1 <= *(int *)(param_1 + 8)) &&

       (*(uint *)(iVar5 + iVar1 * 8) < *(uint *)(iVar5 + iVar6 * 8))) {

      iVar6 = iVar1;

    }

    if (iVar6 == param_2) break;

    uVar3 = *(undefined4 *)(iVar5 + param_2 * 8);

    uVar4 = *(undefined4 *)(iVar2 + -4 + param_2 * 8);

    *(undefined4 *)(iVar5 + param_2 * 8) = *(undefined4 *)(iVar5 + iVar6 * 8);

    *(undefined4 *)(iVar2 + -4 + param_2 * 8) = *(undefined4 *)(iVar2 + -4 + iVar6 * 8);

    *(undefined4 *)(iVar5 + iVar6 * 8) = uVar3;

    *(undefined4 *)(iVar2 + -4 + iVar6 * 8) = uVar4;

    param_2 = iVar6;

  }

  return;

}





// --- FUN_00547e50 at 0x00547E50 (size: 13) ---


void __fastcall FUN_00547e50(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0040faa0();

  *(double *)(param_1 + 0x18) = (double)fVar1;

  return;

}





// --- FUN_00547e70 at 0x00547E70 (size: 49) ---


void FUN_00547e70(void)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = DAT_00846f64;

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

    LVar2 = InterlockedDecrement(DAT_00846f64 + 1);

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

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

    }

    DAT_00846f64 = (undefined4 *)0x0;

  }

  return;

}





// --- FUN_00547eb0 at 0x00547EB0 (size: 179) ---


int __fastcall FUN_00547eb0(int *param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  int *piStack_4;

  

  puVar1 = (undefined4 *)param_1[4];

  if (puVar1 == (undefined4 *)0x0) {

    return 0;

  }

  if (puVar1 == (undefined4 *)0x0) {

    uVar5 = 0;

  }

  else {

    uVar5 = *puVar1;

  }

  piStack_4 = param_1;

  iVar3 = FUN_0054b430(uVar5);

  if (*(int *)(iVar3 + 0x110) != 0) {

    iVar4 = (**(code **)(*param_1 + 0x10))(*(int *)(iVar3 + 0x110));

    if (iVar4 == 0) {

      FUN_00405f70();

      return 0;

    }

    FUN_0054a130();

    if (*(int *)(iVar3 + 0x11c) == 0) {

      FUN_00549e10();

    }

    if (((*(byte *)(iVar3 + 0x120) & 1) == 0) && ((*(uint *)(iVar3 + 0x120) >> 2 & 1) != 0)) {

      piStack_4 = *(int **)(iVar3 + 0x118);

      FUN_00547c70(iVar3,uVar5,&piStack_4);

    }

  }

  pvVar2 = (void *)param_1[4];

  if (pvVar2 != (void *)0x0) {

    iVar4 = *(int *)((int)pvVar2 + 4);

    param_1[4] = iVar4;

    if (iVar4 == 0) {

      param_1[5] = 0;

    }

    operator_delete(pvVar2);

  }

  return iVar3;

}





// --- FUN_00547f70 at 0x00547F70 (size: 104) ---


void __thiscall FUN_00547f70(int *param_1,int param_2,undefined4 param_3,undefined4 param_4)



{

  if (param_2 != 0) {

    InterlockedIncrement((LONG *)(param_2 + 4));

    if (*(int *)(param_2 + 0x8c) != 0) {

      FUN_00549f30(param_3,param_4);

      (**(code **)(*param_1 + 0x1c))(*(undefined4 *)(param_2 + 0x110));

      return;

    }

    FUN_00549f00(param_3,param_4);

    (**(code **)(*param_1 + 0x1c))(*(undefined4 *)(param_2 + 0x110));

  }

  return;

}





// --- FUN_00547fe0 at 0x00547FE0 (size: 90) ---


void __thiscall FUN_00547fe0(int param_1,uint param_2,undefined4 param_3)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  

  if (*(int *)(param_1 + 8) == *(int *)(param_1 + 0xc)) {

    FUN_00547d90();

  }

  iVar1 = *(int *)(param_1 + 4);

  iVar3 = iVar1 + -8;

  iVar5 = *(int *)(param_1 + 8) + 1;

  *(int *)(param_1 + 8) = iVar5;

  while (1 < iVar5) {

    iVar4 = iVar5 >> 1;

    uVar2 = *(uint *)(iVar3 + iVar4 * 8);

    if (uVar2 <= param_2) break;

    *(uint *)(iVar3 + iVar5 * 8) = uVar2;

    *(undefined4 *)(iVar1 + -4 + iVar5 * 8) = *(undefined4 *)(iVar1 + -4 + iVar4 * 8);

    iVar5 = iVar4;

  }

  *(uint *)(iVar3 + iVar5 * 8) = param_2;

  *(undefined4 *)(iVar1 + -4 + iVar5 * 8) = param_3;

  return;

}





// --- FUN_00548040 at 0x00548040 (size: 101) ---


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



{

  int iVar1;

  undefined4 *puVar2;

  

  if ((0 < *(int *)(param_1 + 8)) && (*(undefined4 **)(param_1 + 4) != (undefined4 *)0x0)) {

    *param_2 = **(undefined4 **)(param_1 + 4);

    *param_3 = *(undefined4 *)(*(int *)(param_1 + 4) + 4);

    if (1 < *(int *)(param_1 + 8)) {

      iVar1 = *(int *)(param_1 + 8) + -1;

      puVar2 = *(undefined4 **)(param_1 + 4);

      *(int *)(param_1 + 8) = iVar1;

      *puVar2 = puVar2[iVar1 * 2];

      puVar2[1] = puVar2[iVar1 * 2 + 1];

      FUN_00547de0(1);

      return 1;

    }

    *(undefined4 *)(param_1 + 8) = 0;

    FUN_00547de0(1);

    return 1;

  }

  return 0;

}





// --- FUN_005480b0 at 0x005480B0 (size: 64) ---


undefined4 * __thiscall FUN_005480b0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb2bc;

  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_005480f0 at 0x005480F0 (size: 64) ---


undefined4 * __thiscall FUN_005480f0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb2c0;

  operator_delete((void *)param_1[6]);

  param_1[6] = 0;

  param_1[8] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00548130 at 0x00548130 (size: 82) ---


void __thiscall FUN_00548130(undefined4 *param_1,undefined4 *param_2,uint param_3)



{

  int iVar1;

  undefined4 *puVar2;

  

  param_1[6] = param_3;

  param_1[4] = param_1 + 6;

  param_1[5] = param_3 * 4 + 4;

  param_3 = param_3 & 0x3fffffff;

  param_1[1] = 1;

  param_1[2] = 0x2000;

  param_1[3] = 0x21;

  *param_1 = &PTR_FUN_007e70f0;

  puVar2 = param_1 + 7;

  for (; param_3 != 0; param_3 = param_3 - 1) {

    *puVar2 = *param_2;

    param_2 = param_2 + 1;

    puVar2 = puVar2 + 1;

  }

  for (iVar1 = 0; iVar1 != 0; iVar1 = iVar1 + -1) {

    *(undefined1 *)puVar2 = *(undefined1 *)param_2;

    param_2 = (undefined4 *)((int)param_2 + 1);

    puVar2 = (undefined4 *)((int)puVar2 + 1);

  }

  return;

}





// --- FUN_00548190 at 0x00548190 (size: 73) ---


undefined4 * FUN_00548190(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x20);

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

    puVar1[7] = param_2;

    puVar1[1] = 1;

    puVar1[2] = 0x1000000;

    puVar1[3] = 0x18;

    puVar1[4] = puVar1 + 6;

    puVar1[5] = 8;

    *puVar1 = &PTR_FUN_007cb2ac;

    puVar1[6] = param_1;

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_005481e0 at 0x005481E0 (size: 66) ---


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



undefined4 * FUN_005481e0(void)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x1c);

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

    puVar1[6] = (float)_DAT_008379b0;

    puVar1[1] = 1;

    puVar1[2] = 0x2000000;

    puVar1[3] = 0x18;

    puVar1[4] = puVar1 + 6;

    puVar1[5] = 4;

    *puVar1 = &PTR_FUN_007cb2b4;

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00548230 at 0x00548230 (size: 75) ---


void __thiscall FUN_00548230(int param_1,int param_2)



{

  undefined4 uVar1;

  

  InterlockedIncrement((LONG *)(param_2 + 4));

  FUN_00547fe0(*(undefined4 *)(param_2 + 8),param_2);

  uVar1 = *(undefined4 *)(param_1 + 0x300);

  FUN_00541770(uVar1);

  FUN_005417a0(uVar1);

  if ((*(byte *)(param_2 + 0xc) & 0x40) != 0) {

    FUN_00547990();

  }

  return;

}





// --- FUN_00548280 at 0x00548280 (size: 126) ---


void __thiscall FUN_00548280(int param_1,uint param_2,int param_3)



{

  void *pvVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  iVar4 = *(int *)(param_1 + 0x10);

  while (iVar4 != 0) {

    if (param_3 == 0) {

      if (*(uint **)(param_1 + 0x10) == (uint *)0x0) {

        uVar3 = 0;

      }

      else {

        uVar3 = **(uint **)(param_1 + 0x10);

      }

      if (uVar3 == param_2) break;

      uVar2 = uVar3 - param_2;

      iVar4 = 1;

      if (uVar3 < param_2) {

        uVar2 = param_2 - uVar3;

        iVar4 = -1;

      }

      if (0x7fffffff < uVar2) {

        iVar4 = -iVar4;

      }

      if (-1 < iVar4) break;

    }

    pvVar1 = *(void **)(param_1 + 0x10);

    if (pvVar1 != (void *)0x0) {

      iVar4 = *(int *)((int)pvVar1 + 4);

      *(int *)(param_1 + 0x10) = iVar4;

      if (iVar4 == 0) {

        *(undefined4 *)(param_1 + 0x14) = 0;

      }

      operator_delete(pvVar1);

    }

    iVar4 = *(int *)(param_1 + 0x10);

  }

  FUN_0054b8e0(param_2,param_3);

  return;

}





// --- FUN_00548300 at 0x00548300 (size: 778) ---


/* WARNING: Removing unreachable block (ram,0x00548347) */

/* WARNING: Removing unreachable block (ram,0x00548350) */

/* WARNING: Removing unreachable block (ram,0x0054835e) */

/* WARNING: Removing unreachable block (ram,0x00548361) */

/* WARNING: Removing unreachable block (ram,0x00548365) */

/* WARNING: Removing unreachable block (ram,0x00548379) */

/* WARNING: Removing unreachable block (ram,0x0054838a) */

/* WARNING: Removing unreachable block (ram,0x0054838f) */

/* WARNING: Removing unreachable block (ram,0x00548398) */

/* WARNING: Removing unreachable block (ram,0x005483be) */

/* WARNING: Removing unreachable block (ram,0x005483a1) */

/* WARNING: Removing unreachable block (ram,0x005483c1) */

/* WARNING: Removing unreachable block (ram,0x005483c5) */

/* WARNING: Removing unreachable block (ram,0x005483d5) */

/* WARNING: Removing unreachable block (ram,0x005483dd) */

/* WARNING: Removing unreachable block (ram,0x0054841d) */

/* WARNING: Removing unreachable block (ram,0x00548421) */

/* WARNING: Removing unreachable block (ram,0x005483cb) */

/* WARNING: Removing unreachable block (ram,0x005483d3) */

/* WARNING: Removing unreachable block (ram,0x0054842a) */

/* WARNING: Removing unreachable block (ram,0x00548444) */

/* WARNING: Removing unreachable block (ram,0x0054844c) */

/* WARNING: Removing unreachable block (ram,0x00548450) */

/* WARNING: Removing unreachable block (ram,0x00548460) */

/* WARNING: Removing unreachable block (ram,0x00548467) */

/* WARNING: Removing unreachable block (ram,0x00548481) */

/* WARNING: Removing unreachable block (ram,0x0054846f) */

/* WARNING: Removing unreachable block (ram,0x00548488) */

/* WARNING: Removing unreachable block (ram,0x00548499) */

/* WARNING: Removing unreachable block (ram,0x0054849f) */

/* WARNING: Removing unreachable block (ram,0x005484e3) */

/* WARNING: Removing unreachable block (ram,0x005484e6) */

/* WARNING: Removing unreachable block (ram,0x005484e8) */

/* WARNING: Removing unreachable block (ram,0x005484ec) */

/* WARNING: Removing unreachable block (ram,0x005484f5) */

/* WARNING: Removing unreachable block (ram,0x0054850a) */

/* WARNING: Removing unreachable block (ram,0x00548513) */

/* WARNING: Removing unreachable block (ram,0x00548521) */

/* WARNING: Removing unreachable block (ram,0x0054851c) */

/* WARNING: Removing unreachable block (ram,0x00548551) */

/* WARNING: Removing unreachable block (ram,0x005485a5) */

/* WARNING: Removing unreachable block (ram,0x005485a9) */

/* WARNING: Removing unreachable block (ram,0x005485b1) */

/* WARNING: Removing unreachable block (ram,0x005485c6) */

/* WARNING: Removing unreachable block (ram,0x005485ce) */

/* WARNING: Removing unreachable block (ram,0x005485da) */



void __fastcall FUN_00548300(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined1 auStack_8 [8];

  

  puVar1 = (undefined4 *)(**(code **)(*param_1 + 8))(0);

  FUN_00548040(auStack_8,&stack0xfffffff0);

  while (puVar1 != (undefined4 *)0x0) {

    (**(code **)(*DAT_00846f64 + 0xc))();

    FUN_0054a850(&stack0xfffffff0);

    LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    puVar1 = (undefined4 *)(**(code **)(*param_1 + 8))(0);

  }

  return;

}





// --- FUN_00548620 at 0x00548620 (size: 611) ---


undefined1 __fastcall FUN_00548620(int *param_1)



{

  int *piVar1;

  byte bVar2;

  int iVar3;

  char cVar4;

  int iVar5;

  undefined4 uVar6;

  LONG LVar7;

  undefined4 *puVar8;

  undefined1 local_1d;

  undefined4 uStack_1c;

  undefined4 uStack_18;

  uint local_14;

  uint local_10;

  undefined4 local_c;

  undefined2 local_8;

  undefined2 local_6;

  undefined2 local_4;

  undefined2 local_2;

  

  local_1d = 0;

  FUN_00548300();

  local_2 = *(undefined2 *)(param_1[0xc1] + 2);

  local_8 = (undefined2)param_1[0xc2];

  local_6 = (undefined2)param_1[0xc3];

  local_14 = 0;

  local_10 = 0;

  local_c = 0;

  local_4 = 0;

  while( true ) {

    iVar3 = param_1[2];

    if (iVar3 == 0) {

      return local_1d;

    }

    bVar2 = *(byte *)(iVar3 + 0x120);

    iVar5 = (**(code **)(*param_1 + 0x10))(*(undefined4 *)(iVar3 + 0x110));

    if ((iVar5 == 0) && ((*(uint *)(iVar3 + 0x120) >> 3 & 1) == 0)) {

      return local_1d;

    }

    local_10 = 0;

    if (*(int *)(iVar3 + 0x104) != 0) {

      local_10 = 4;

      FUN_00547990();

    }

    FUN_00549ed0(&local_14);

    if (((local_10 & 0xffffff) == 0) && (*(int *)(iVar3 + 8) == 0)) {

      return local_1d;

    }

    FUN_0054a130();

    if (*(int *)(iVar3 + 0x11c) == 0) {

      FUN_00549e10();

    }

    if ((*(uint *)(iVar3 + 0x120) >> 2 & 1) == 0) {

      *(int *)(iVar3 + 0x114) = param_1[0xbb];

    }

    else {

      if ((*(byte *)(iVar3 + 0x120) & 1) == 0) {

        uStack_18 = *(undefined4 *)(iVar3 + 0x118);

        puVar8 = (undefined4 *)0x0;

        if ((*(int *)(iVar3 + 0x114) == 0) || ((bVar2 & 1) == 0)) {

          piVar1 = param_1 + 0xbb;

          *piVar1 = *piVar1 + 1;

          if (*piVar1 == 0) {

            param_1[0xbb] = 1;

          }

          *(int *)(iVar3 + 0x114) = param_1[0xbb];

        }

        else {

          puVar8 = &uStack_18;

        }

        uStack_1c = *(undefined4 *)(iVar3 + 0x11c);

        uVar6 = FUN_00549870(*(undefined4 *)(iVar3 + 0x114),&uStack_1c,4,puVar8);

        *(undefined4 *)(iVar3 + 0x11c) = uStack_1c;

        *(uint *)(iVar3 + 0x120) = *(uint *)(iVar3 + 0x120) | 1;

        *(undefined4 *)(iVar3 + 0x118) = uVar6;

      }

      local_10 = local_10 | 2;

    }

    local_14 = *(uint *)(iVar3 + 0x114);

    local_c = *(undefined4 *)(iVar3 + 0x11c);

    local_4 = *(undefined2 *)(iVar3 + 0x110);

    FUN_00541770();

    cVar4 = FUN_00542780(iVar3,&local_14,param_1 + 0xbc);

    if (cVar4 == '\0') break;

    (**(code **)(*param_1 + 0x18))(*(int *)(iVar3 + 0x110) + 0x14);

    param_1[0xb9] = param_1[0xb9] + 1;

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

      *(undefined4 *)(param_1[0xc0] + 0x10) = 7;

    }

    puVar8 = (undefined4 *)(**(code **)(*param_1 + 0x28))(param_1 + 2,param_1 + 3);

    if ((*(uint *)(iVar3 + 0x120) >> 2 & 1) != 0) {

      FUN_0054b710(iVar3);

    }

    LVar7 = InterlockedDecrement(puVar8 + 1);

    if ((LVar7 == 0) && (puVar8 != (undefined4 *)0x0)) {

      (**(code **)*puVar8)(1);

    }

    local_1d = 1;

  }

  return local_1d;

}





// --- FUN_00548910 at 0x00548910 (size: 151) ---


void __thiscall FUN_00548910(int *param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if (param_1[2] == 0) {

    piVar1 = (int *)*param_1;

    puVar3 = (undefined4 *)FUN_005df0f5(8);

    if (puVar3 == (undefined4 *)0x0) {

      puVar3 = (undefined4 *)0x0;

    }

    else {

      iVar2 = *piVar1;

      *puVar3 = param_2;

      puVar3[1] = iVar2;

    }

    *piVar1 = (int)puVar3;

    if (piVar1[1] == 0) {

      piVar1[1] = (int)puVar3;

    }

    param_1[2] = *(int *)*param_1;

    return;

  }

  if (param_1[1] == 0) {

    FUN_00453800(param_2);

    param_1[2] = *(int *)(*param_1 + 4);

    return;

  }

  puVar3 = (undefined4 *)FUN_005df0f5(8);

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

    iVar2 = param_1[1];

    *puVar3 = param_2;

    puVar3[1] = iVar2;

    *(undefined4 **)(param_1[2] + 4) = puVar3;

    param_1[2] = (int)puVar3;

    return;

  }

  *(undefined4 *)(param_1[2] + 4) = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_005489b0 at 0x005489B0 (size: 127) ---


undefined4 * FUN_005489b0(int *param_1)



{

  int *piVar1;

  int iVar2;

  void *pvVar3;

  int iVar4;

  undefined4 *puVar5;

  

  piVar1 = param_1;

  iVar2 = (**(code **)(*param_1 + 8))();

  pvVar3 = (void *)thunk_FUN_005df0f5(iVar2);

  param_1 = pvVar3;

  iVar4 = (**(code **)(*piVar1 + 0xc))(&param_1,iVar2);

  if (iVar4 == iVar2) {

    puVar5 = (undefined4 *)FUN_005df0f5(0x30);

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

      puVar5[4] = pvVar3;

      puVar5[6] = pvVar3;

      puVar5[5] = iVar2;

      puVar5[7] = iVar2;

      puVar5[1] = 1;

      puVar5[2] = 0x200000;

      puVar5[3] = 2;

      *puVar5 = &PTR_FUN_007cb2c0;

      puVar5[8] = &PTR_FUN_00795878;

      return puVar5;

    }

  }

  else {

    operator_delete(pvVar3);

  }

  return (undefined4 *)0x0;

}





// --- FUN_00548a30 at 0x00548A30 (size: 71) ---


undefined4 * FUN_00548a30(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x20);

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

    puVar1[6] = param_1;

    puVar1[1] = 1;

    puVar1[2] = 0x400000;

    puVar1[3] = 7;

    puVar1[4] = puVar1 + 6;

    puVar1[5] = 8;

    *puVar1 = &PTR_FUN_007e70f0;

    puVar1[7] = param_2;

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00548c50 at 0x00548C50 (size: 143) ---


undefined4 * __thiscall FUN_00548c50(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_007cb2bc;

  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_00548ce0 at 0x00548CE0 (size: 82) ---


undefined4 * __thiscall FUN_00548ce0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb2c8;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007cb2bc;

  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_00548d40 at 0x00548D40 (size: 273) ---


undefined4 * __thiscall

FUN_00548d40(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,ushort param_6)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 uVar3;

  

  *param_1 = &PTR_FUN_007cb2cc;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  FUN_0054b690();

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = &PTR_FUN_007cb2c8;

  FUN_00548c50(0x20);

  param_1[0xbc] = param_2;

  param_1[0xbd] = param_3;

  param_1[0xbe] = param_4;

  param_1[0xb8] = 0;

  param_1[0xb9] = 0;

  param_1[0xba] = 0;

  param_1[0xbb] = 1;

  param_1[0xbf] = param_5;

  param_1[0xc0] = 0;

  iVar2 = FUN_00541770();

  if (param_6 < 0x100) {

    iVar2 = (uint)param_6 * 0x88 + 0x20 + *(int *)(iVar2 + 8);

  }

  else {

    iVar2 = 0;

  }

  param_1[0xc1] = iVar2;

  *(ushort *)(param_1 + 0xc2) = param_6;

  param_1[199] = &PTR_FUN_007cb2a8;

  param_1[0xc9] = 0;

  uVar3 = thunk_FUN_005df0f5(0x200);

  param_1[200] = uVar3;

  param_1[0xcb] = 0x40;

  param_1[0xca] = 0x40;

  uVar1 = DAT_008379b4;

  uVar3 = DAT_008379b0;

  *(undefined2 *)(param_1 + 0xce) = 0;

  param_1[0xcc] = uVar3;

  param_1[0xcd] = uVar1;

  return param_1;

}





// --- FUN_00548e60 at 0x00548E60 (size: 126) ---


void __fastcall FUN_00548e60(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cb2cc;

  param_1[199] = &PTR_FUN_007cb2a8;

  operator_delete__((void *)param_1[200]);

  param_1[0x27] = &PTR_FUN_007cb2c8;

  FUN_005870f0();

  param_1[0x28] = &PTR_FUN_007cb2bc;

  if ((undefined4 *)param_1[0x40] != param_1 + 0x29) {

    operator_delete__((undefined4 *)param_1[0x40]);

  }

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  FUN_004c65a0();

  FUN_0054b6c0();

  FUN_004c65a0();

  return;

}





// --- FUN_00548ee0 at 0x00548EE0 (size: 188) ---


void __thiscall FUN_00548ee0(int param_1,uint param_2)



{

  uint uVar1;

  uint *puVar2;

  int local_4;

  

  uVar1 = param_2;

  puVar2 = *(uint **)(*(int *)(param_1 + 0x100) + (param_2 % *(uint *)(param_1 + 0x108)) * 4);

  do {

    if (puVar2 == (uint *)0x0) {

LAB_00548f1a:

      *(int *)(param_1 + 0x2e0) = *(int *)(param_1 + 0x2e0) + 1;

      local_4 = param_1;

      puVar2 = (uint *)FUN_005df0f5(8);

      if (puVar2 == (uint *)0x0) {

        puVar2 = (uint *)0x0;

      }

      else {

        *puVar2 = uVar1;

        puVar2[1] = 0;

      }

      if (*(int *)(param_1 + 0x98) == 0) {

        *(uint **)(param_1 + 0x94) = puVar2;

        *(uint **)(param_1 + 0x98) = puVar2;

      }

      else {

        *(uint **)(*(int *)(param_1 + 0x98) + 4) = puVar2;

        *(undefined4 *)(param_1 + 0x98) = *(undefined4 *)(*(int *)(param_1 + 0x98) + 4);

      }

      *(int *)(param_1 + 0x2e8) = *(int *)(param_1 + 0x2e8) + 1;

      local_4 = 0;

      FUN_006891f0(&param_2,&local_4);

      return;

    }

    if (*puVar2 == param_2) {

      if ((puVar2 != (uint *)0x0) && (puVar2 != (uint *)0xfffffff8)) {

        return;

      }

      goto LAB_00548f1a;

    }

    puVar2 = (uint *)puVar2[1];

  } while( true );

}





// --- FUN_00548fa0 at 0x00548FA0 (size: 122) ---


undefined4 __thiscall FUN_00548fa0(int param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  void *pvVar3;

  undefined4 uVar4;

  

  puVar1 = *(undefined4 **)(param_1 + 0x94);

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

    *(int *)(param_1 + 0x2e0) = *(int *)(param_1 + 0x2e0) + -1;

    if (puVar1 == (undefined4 *)0x0) {

      uVar4 = 0;

    }

    else {

      iVar2 = puVar1[1];

      *(int *)(param_1 + 0x94) = iVar2;

      if (iVar2 == 0) {

        *(undefined4 *)(param_1 + 0x98) = 0;

      }

      uVar4 = *puVar1;

      operator_delete(puVar1);

    }

    *param_2 = uVar4;

    pvVar3 = (void *)FUN_004171e0(param_2);

    if (pvVar3 != (void *)0x0) {

      operator_delete(pvVar3);

    }

    return 1;

  }

  *param_2 = 0;

  return 0;

}





// --- FUN_00549020 at 0x00549020 (size: 116) ---


void __fastcall FUN_00549020(int param_1)



{

  int iVar1;

  int *piVar2;

  uint uVar3;

  int iVar4;

  int local_4;

  

  uVar3 = *(uint *)(param_1 + 0x2e0);

  if ((uVar3 == 0) || (*(int *)(param_1 + 0x110) != 0)) {

    *(undefined4 *)(param_1 + 0x110) = 0;

  }

  else {

    if (0x72 < uVar3) {

      uVar3 = 0x72;

    }

    iVar4 = 1;

    *(uint *)(param_1 + 0x110) = uVar3;

    if (0 < (int)uVar3) {

      piVar2 = (int *)(param_1 + 0x114);

      local_4 = param_1;

      while( true ) {

        iVar1 = FUN_00548fa0(&local_4);

        if (iVar1 == 0) break;

        *piVar2 = local_4;

        iVar4 = iVar4 + 1;

        piVar2 = piVar2 + 1;

        if ((int)uVar3 < iVar4) {

          return;

        }

      }

    }

  }

  return;

}





// --- FUN_005490a0 at 0x005490A0 (size: 106) ---


undefined4 __fastcall FUN_005490a0(int param_1)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  

  FUN_00549020();

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

  if (iVar1 != 0) {

    iVar2 = FUN_005df0f5(0x1e4);

    if (iVar2 == 0) {

      puVar3 = (undefined4 *)0x0;

    }

    else {

      puVar3 = (undefined4 *)FUN_00548130(param_1 + 0x114,iVar1);

    }

    FUN_00548230(puVar3);

    LVar4 = InterlockedDecrement(puVar3 + 1);

    if ((LVar4 == 0) && (puVar3 != (undefined4 *)0x0)) {

      (**(code **)*puVar3)(1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_00549110 at 0x00549110 (size: 336) ---


bool __fastcall FUN_00549110(int *param_1)



{

  char cVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int iVar4;

  int iVar5;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined2 local_8;

  undefined2 local_6;

  undefined2 local_4;

  undefined2 local_2;

  

  local_2 = *(undefined2 *)(param_1[0xc1] + 2);

  local_8 = (undefined2)param_1[0xc2];

  local_6 = (undefined2)param_1[0xc3];

  local_14 = 0;

  local_10 = 3;

  local_c = 0;

  local_4 = 0;

  iVar5 = 0;

  puVar2 = (undefined4 *)FUN_00547eb0();

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

    do {

      if ((puVar2[0x41] == 0) && (puVar2[0x23] == 0)) {

        FUN_00548ee0(puVar2[0x45]);

      }

      else {

        local_10 = 3;

        if (puVar2[0x41] != 0) {

          local_10 = 7;

        }

        FUN_00549ed0(&local_14);

        local_14 = puVar2[0x45];

        local_c = puVar2[0x47];

        local_4 = *(undefined2 *)(puVar2 + 0x44);

        FUN_00541770();

        cVar1 = FUN_00542780(puVar2,&local_14,param_1 + 0xbc);

        if (cVar1 != '\0') {

          (**(code **)(*param_1 + 0x18))(puVar2[0x44] + 0x14);

          param_1[0xb9] = param_1[0xb9] + 1;

        }

        iVar5 = iVar5 + 1;

      }

      LVar3 = InterlockedDecrement(puVar2 + 1);

      if (LVar3 == 0) {

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

      }

      puVar2 = (undefined4 *)FUN_00547eb0();

    } while (puVar2 != (undefined4 *)0x0);

    if (iVar5 != 0) {

      iVar4 = FUN_00541770();

      (**(code **)**(undefined4 **)(iVar4 + 8))(10,iVar5);

    }

  }

  return 0 < iVar5;

}





// --- FUN_00549260 at 0x00549260 (size: 187) ---


undefined4 * __thiscall

FUN_00549260(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,uint param_6,undefined4 param_7)



{

  undefined4 uVar1;

  

  FUN_00548d40(param_2,param_3,param_4,param_5,param_6,param_7);

  *param_1 = &PTR_FUN_007cb2f8;

  param_1[0xd0] = &PTR_FUN_007cb2a8;

  param_1[0xd2] = 0;

  uVar1 = thunk_FUN_005df0f5(0x200);

  param_1[0xd1] = uVar1;

  param_1[0xd4] = 0x40;

  param_1[0xd3] = 0x40;

  *(undefined2 *)(param_1 + 0xc2) = *(undefined2 *)((param_6 & 0xffff) * 0x88 + 0x4c + DAT_00846f18)

  ;

  param_1[0xc5] = 1;

  *(undefined2 *)(param_1 + 0xc3) = 1;

  param_1[0xc4] = 0;

  param_1[0xc6] = 0;

  return param_1;

}





// --- FUN_00549320 at 0x00549320 (size: 30) ---


void * __thiscall FUN_00549320(void *param_1,byte param_2)



{

  FUN_00548e60();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00549340 at 0x00549340 (size: 242) ---


void __fastcall FUN_00549340(int *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int iVar4;

  

  puVar2 = (undefined4 *)(**(code **)(*param_1 + 8))(1);

  while (puVar2 != (undefined4 *)0x0) {

    LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

    }

    puVar2 = (undefined4 *)(**(code **)(*param_1 + 8))(1);

  }

  do {

    iVar4 = FUN_00548fa0(&stack0xfffffff8);

  } while (iVar4 != 0);

  FUN_004c65a0();

  if (param_1[2] != 0) {

    do {

      puVar2 = (undefined4 *)(**(code **)(*param_1 + 0x28))(param_1 + 2,param_1 + 3);

      LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

      }

    } while (param_1[2] != 0);

  }

  while( true ) {

    iVar4 = param_1[0xc9];

    if ((iVar4 < 1) || (puVar2 = (undefined4 *)param_1[200], puVar2 == (undefined4 *)0x0)) {

      return;

    }

    puVar1 = (undefined4 *)puVar2[1];

    if (iVar4 < 2) {

      param_1[0xc9] = 0;

    }

    else {

      iVar4 = iVar4 + -1;

      param_1[0xc9] = iVar4;

      *puVar2 = puVar2[iVar4 * 2];

      puVar2[1] = puVar2[iVar4 * 2 + 1];

    }

    FUN_00547de0(1);

    if (puVar1 == (undefined4 *)0x0) break;

    LVar3 = InterlockedDecrement(puVar1 + 1);

    if (LVar3 == 0) {

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

    }

  }

  return;

}





// --- FUN_00549440 at 0x00549440 (size: 315) ---


void __thiscall FUN_00549440(int param_1,int param_2,int param_3)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  uint *puVar4;

  int iVar5;

  int iVar6;

  uint *local_8;

  

  puVar4 = *(uint **)(param_1 + 0x10);

  iVar6 = 0;

  local_8 = puVar4;

  if (0 < param_3) {

    while (puVar4 != (uint *)0x0) {

      uVar1 = *puVar4;

      uVar2 = *(uint *)(param_2 + iVar6 * 4);

      if (uVar2 == uVar1) goto LAB_0054950e;

      uVar3 = uVar2 - uVar1;

      iVar5 = 1;

      if (uVar2 < uVar1) {

        uVar3 = uVar1 - uVar2;

        iVar5 = -1;

      }

      if (0x7fffffff < uVar3) {

        iVar5 = -iVar5;

      }

      if (iVar5 < 0) {

        iVar5 = FUN_0054b400(uVar2);

        if (iVar5 == 0) {

          FUN_00548ee0(*(undefined4 *)(param_2 + iVar6 * 4));

        }

        else {

          FUN_00548910(*(undefined4 *)(param_2 + iVar6 * 4));

          puVar4 = local_8;

        }

LAB_00549519:

        iVar6 = iVar6 + 1;

      }

      else {

        if (uVar2 == uVar1) {

LAB_0054950e:

          puVar4 = (uint *)puVar4[1];

          local_8 = puVar4;

          goto LAB_00549519;

        }

        uVar3 = uVar2 - uVar1;

        iVar5 = 1;

        if (uVar2 < uVar1) {

          uVar3 = uVar1 - uVar2;

          iVar5 = -1;

        }

        if (0x7fffffff < uVar3) {

          iVar5 = -iVar5;

        }

        if (iVar5 < 1) goto LAB_0054950e;

        FUN_00547cf0();

        puVar4 = local_8;

      }

      if (param_3 <= iVar6) {

        return;

      }

    }

    for (; iVar6 < param_3; iVar6 = iVar6 + 1) {

      iVar5 = FUN_0054b400(*(undefined4 *)(param_2 + iVar6 * 4));

      if (iVar5 == 0) {

        FUN_00548ee0(*(undefined4 *)(param_2 + iVar6 * 4));

      }

      else {

        FUN_00548910(*(undefined4 *)(param_2 + iVar6 * 4));

      }

    }

  }

  return;

}





// --- FUN_00549580 at 0x00549580 (size: 198) ---


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



void __fastcall FUN_00549580(int *param_1)



{

  double dVar1;

  undefined4 uVar2;

  int iVar3;

  float10 fVar4;

  

  if ((param_1[0xbd] != 0) && (param_1[0xc1] != 0)) {

    FUN_005490a0();

    FUN_00549110();

    FUN_00548620();

    if ((*(int *)(param_1[0xc0] + 0x10) == 6) &&

       ((param_1[2] == 0 || (fVar4 = (float10)FUN_005498f0(), (float10)_DAT_0079cac8 < fVar4)))) {

      uVar2 = FUN_005489b0(&PTR_PTR_00822340);

      FUN_00548230(uVar2);

      FUN_00405f70();

    }

    iVar3 = 0;

    if (*(double *)(param_1 + 0xcc) < _DAT_008379b0) {

      dVar1 = *(double *)(param_1 + 0xcc);

      do {

        dVar1 = dVar1 + _DAT_00799088;

        iVar3 = iVar3 + 1;

      } while (dVar1 < _DAT_008379b0);

      *(double *)(param_1 + 0xcc) = dVar1;

      if (iVar3 != 0) {

        (**(code **)(*param_1 + 0xc))(iVar3);

        return;

      }

    }

  }

  return;

}





// --- FUN_00549650 at 0x00549650 (size: 47) ---


void __fastcall FUN_00549650(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cb2f8;

  FUN_00549340();

  param_1[0xd0] = &PTR_FUN_007cb2a8;

  operator_delete__((void *)param_1[0xd1]);

  FUN_00548e60();

  return;

}





// --- FUN_00549680 at 0x00549680 (size: 68) ---


undefined4 * __thiscall FUN_00549680(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb2f8;

  FUN_00549340();

  param_1[0xd0] = &PTR_FUN_007cb2a8;

  operator_delete__((void *)param_1[0xd1]);

  FUN_00548e60();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005496d0 at 0x005496D0 (size: 204) ---


void FUN_005496d0(void)



{

  size_t sVar1;

  int iVar2;

  LONG LVar3;

  wchar_t *local_8;

  wchar_t *local_4;

  

  sVar1 = wcslen(

                L"The rate of NetBlobs released from all FlowQueues and given to the lower level net code."

                );

  FUN_004022d0(sVar1);

  wcscpy(local_4,

         L"The rate of NetBlobs released from all FlowQueues and given to the lower level net code."

        );

  sVar1 = wcslen(L"Net - NetBlobs FlowQueue dequeued/sec");

  FUN_004022d0(sVar1);

  wcscpy(local_8,L"Net - NetBlobs FlowQueue dequeued/sec");

  iVar2 = FUN_00683a80(&local_8,9);

  if (iVar2 == 0) {

    FUN_005469e0(&DAT_00846f64,2,&local_8,&local_4,9);

    iVar2 = DAT_00846f64;

  }

  DAT_00846f64 = iVar2;

  LVar3 = InterlockedDecrement((LONG *)(local_8 + -8));

  if ((LVar3 == 0) && (local_8 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -10))(1);

  }

  LVar3 = InterlockedDecrement((LONG *)(local_4 + -8));

  if ((LVar3 == 0) && (local_4 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -10))(1);

  }

  return;

}





// --- FUN_005497a0 at 0x005497A0 (size: 8) ---


void __fastcall FUN_005497a0(undefined4 param_1)



{

  DAT_00846f74 = param_1;

  return;

}





// --- FUN_005497b0 at 0x005497B0 (size: 11) ---


void FUN_005497b0(void)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_00541770();

                    /* WARNING: Could not recover jumptable at 0x005497b9. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

  return;

}





// --- FUN_005497c0 at 0x005497C0 (size: 39) ---


void __thiscall FUN_005497c0(int param_1,int *param_2,int *param_3)



{

  if (*param_2 == 0) {

    *param_2 = param_1;

    *param_3 = param_1;

    return;

  }

  *(int *)(*param_3 + 8) = param_1;

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

  *param_3 = param_1;

  return;

}





// --- FUN_005497f0 at 0x005497F0 (size: 116) ---


void __thiscall FUN_005497f0(int param_1,undefined4 *param_2,undefined4 *param_3)



{

  int iVar1;

  

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

  if (iVar1 != 0) {

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

      *(int *)(iVar1 + 8) = *(int *)(param_1 + 8);

      *(undefined4 *)(*(int *)(param_1 + 8) + 0xc) = *(undefined4 *)(param_1 + 0xc);

      *(undefined4 *)(param_1 + 0xc) = 0;

      *(undefined4 *)(param_1 + 8) = 0;

      return;

    }

    if (iVar1 != 0) {

      *(undefined4 *)(iVar1 + 8) = 0;

      *param_3 = *(undefined4 *)(param_1 + 0xc);

      *(undefined4 *)(param_1 + 0xc) = 0;

      *(undefined4 *)(param_1 + 8) = 0;

      return;

    }

  }

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

    *(undefined4 *)(*(int *)(param_1 + 8) + 0xc) = 0;

    *param_2 = *(undefined4 *)(param_1 + 8);

    *(undefined4 *)(param_1 + 0xc) = 0;

    *(undefined4 *)(param_1 + 8) = 0;

    return;

  }

  *param_2 = 0;

  *param_3 = 0;

  *(undefined4 *)(param_1 + 0xc) = 0;

  *(undefined4 *)(param_1 + 8) = 0;

  return;

}





// --- FUN_00549870 at 0x00549870 (size: 8) ---


void FUN_00549870(void)



{

  FUN_00660ee0();

  return;

}





// --- FUN_00549880 at 0x00549880 (size: 8) ---


void FUN_00549880(void)



{

  FUN_00660ee0();

  return;

}





// --- FUN_00549890 at 0x00549890 (size: 56) ---


void __thiscall

FUN_00549890(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  param_1[2] = param_4;

  param_1[6] = param_2;

  *param_1 = 0;

  param_1[1] = 0;

  param_1[3] = 1;

  param_1[4] = 1;

  param_1[5] = 1;

  param_1[7] = param_3;

  *(undefined1 *)(param_1 + 8) = 1;

  return;

}





// --- FUN_005498d0 at 0x005498D0 (size: 27) ---


void __thiscall FUN_005498d0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  uVar1 = DAT_008379b4;

  *(undefined4 *)(param_1 + 0x58) = DAT_008379b0;

  *(undefined4 *)(param_1 + 0x5c) = uVar1;

  *(undefined4 *)(param_1 + 0x48) = param_2;

  return;

}





// --- FUN_005498f0 at 0x005498F0 (size: 10) ---


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



float10 __fastcall FUN_005498f0(int param_1)



{

  return (float10)_DAT_008379b0 - (float10)*(double *)(param_1 + 0x58);

}





// --- FUN_00549900 at 0x00549900 (size: 141) ---


void __thiscall FUN_00549900(int param_1,undefined4 param_2,undefined4 param_3)



{

  void *pvVar1;

  int iVar2;

  undefined4 uVar3;

  

  pvVar1 = *(void **)(param_1 + 0x24);

  if (pvVar1 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar1);

  }

  pvVar1 = *(void **)(param_1 + 0x20);

  *(undefined4 *)(param_1 + 0x24) = 0;

  if (pvVar1 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar1);

  }

  *(undefined4 *)(param_1 + 0x20) = 0;

  iVar2 = FUN_005df0f5(0xc);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_00660bb0(param_2);

  }

  *(undefined4 *)(param_1 + 0x24) = uVar3;

  iVar2 = FUN_005df0f5(0xc);

  if (iVar2 != 0) {

    uVar3 = FUN_00660bb0(param_3);

    *(undefined4 *)(param_1 + 0x20) = uVar3;

    return;

  }

  *(undefined4 *)(param_1 + 0x20) = 0;

  return;

}





// --- FUN_00549990 at 0x00549990 (size: 57) ---


void __fastcall FUN_00549990(undefined2 *param_1)



{

  *param_1 = 0;

  *(undefined4 *)(param_1 + 2) = 0;

  *(undefined4 *)(param_1 + 4) = 0;

  *(undefined4 *)(param_1 + 6) = 0;

  *(undefined4 *)(param_1 + 8) = 0;

  *(undefined4 *)(param_1 + 10) = 0;

  *(undefined4 *)(param_1 + 0x10) = 0;

  *(undefined4 *)(param_1 + 0x12) = 0;

  *(undefined4 *)(param_1 + 0x14) = 0;

  param_1[0x16] = 0;

  *(undefined4 *)(param_1 + 0x22) = 0;

  *(undefined4 *)(param_1 + 0x24) = 0;

  *(undefined4 *)(param_1 + 0x26) = 0;

  *(undefined4 *)(param_1 + 0x28) = 0;

  *(undefined4 *)(param_1 + 0x2c) = 0;

  *(undefined4 *)(param_1 + 0x2e) = 0;

  *(undefined4 *)(param_1 + 0x34) = 0;

  return;

}





// --- FUN_005499d0 at 0x005499D0 (size: 123) ---


void __fastcall FUN_005499d0(int param_1)



{

  void *pvVar1;

  int *piVar2;

  

  pvVar1 = *(void **)(param_1 + 0x24);

  if (pvVar1 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar1);

  }

  pvVar1 = *(void **)(param_1 + 0x20);

  *(undefined4 *)(param_1 + 0x24) = 0;

  if (pvVar1 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar1);

  }

  *(undefined4 *)(param_1 + 0x20) = 0;

  piVar2 = *(int **)(param_1 + 0x4c);

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

    if (*piVar2 != 0) {

      FUN_00542af0(1);

    }

    if (piVar2[1] != 0) {

      FUN_00542af0(1);

    }

    *piVar2 = 0;

    piVar2[1] = 0;

    operator_delete(piVar2);

  }

  return;

}





// --- FUN_00549a50 at 0x00549A50 (size: 163) ---


void __thiscall

FUN_00549a50(undefined2 *param_1,undefined4 *param_2,undefined4 param_3,undefined2 param_4,

            undefined2 param_5,undefined2 param_6,undefined2 param_7,undefined4 param_8,

            undefined4 param_9,undefined4 param_10)



{

  undefined4 uVar1;

  

  if (*(undefined4 **)(param_1 + 0x14) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x14))(1);

  }

  *(undefined4 *)(param_1 + 0x14) = param_8;

  *(undefined4 *)(param_1 + 0x18) = *param_2;

  *(undefined4 *)(param_1 + 0x1a) = param_2[1];

  *(undefined4 *)(param_1 + 0x1c) = param_2[2];

  *(undefined4 *)(param_1 + 0x1e) = param_2[3];

  *(undefined4 *)(param_1 + 2) = param_3;

  *param_1 = param_4;

  uVar1 = DAT_008379a8;

  *(undefined4 *)(param_1 + 10) = DAT_008379ac;

  *(undefined4 *)(param_1 + 8) = uVar1;

  uVar1 = DAT_008379b4;

  *(undefined4 *)(param_1 + 0x2c) = DAT_008379b0;

  param_1[0x16] = param_5;

  param_1[0x20] = param_7;

  *(undefined4 *)(param_1 + 0x2e) = uVar1;

  *(undefined4 *)(param_1 + 0x38) = 0;

  *(undefined4 *)(param_1 + 0x3a) = 0;

  param_1[1] = param_6;

  FUN_00549900(param_9,param_10);

  return;

}





// --- FUN_00549b00 at 0x00549B00 (size: 89) ---


void __thiscall FUN_00549b00(int param_1)



{

  undefined4 uVar1;

  undefined4 in_stack_00000014;

  undefined4 in_stack_00000018;

  undefined4 in_stack_0000001c;

  undefined4 in_stack_00000020;

  undefined4 in_stack_00000024;

  undefined4 in_stack_00000028;

  undefined4 in_stack_0000002c;

  undefined4 in_stack_00000030;

  

  *(undefined4 *)(param_1 + 0x78) = 0;

  FUN_00549a50(&stack0x00000004,in_stack_00000014,in_stack_00000018,in_stack_0000001c,

               in_stack_00000020,in_stack_00000024,in_stack_00000028,in_stack_0000002c,

               in_stack_00000030);

  uVar1 = DAT_008379b4;

  *(undefined4 *)(param_1 + 0x80) = DAT_008379b0;

  *(undefined4 *)(param_1 + 0x84) = uVar1;

  return;

}





// --- FUN_00549b60 at 0x00549B60 (size: 178) ---


void __fastcall FUN_00549b60(undefined2 *param_1)



{

  int *piVar1;

  void *pvVar2;

  undefined4 uVar3;

  

  *(undefined4 *)(param_1 + 4) = 0;

  *(undefined4 *)(param_1 + 6) = 0;

  *(undefined4 *)(param_1 + 2) = 0;

  *param_1 = 0;

  param_1[0x16] = 0;

  uVar3 = DAT_008379b4;

  *(undefined4 *)(param_1 + 0x2c) = DAT_008379b0;

  *(undefined4 *)(param_1 + 0x2e) = uVar3;

  piVar1 = *(int **)(param_1 + 0x26);

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

    if (*piVar1 != 0) {

      FUN_00542af0(1);

    }

    if (piVar1[1] != 0) {

      FUN_00542af0(1);

    }

    *piVar1 = 0;

    piVar1[1] = 0;

    operator_delete(piVar1);

  }

  *(undefined4 *)(param_1 + 0x26) = 0;

  *(undefined4 *)(param_1 + 0x28) = 0;

  pvVar2 = *(void **)(param_1 + 0x12);

  *(undefined4 *)(param_1 + 0x22) = 0;

  *(undefined4 *)(param_1 + 0x24) = 0;

  *(undefined4 *)(param_1 + 8) = 0;

  *(undefined4 *)(param_1 + 10) = 0;

  if (pvVar2 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar2);

  }

  pvVar2 = *(void **)(param_1 + 0x10);

  *(undefined4 *)(param_1 + 0x12) = 0;

  if (pvVar2 != (void *)0x0) {

    FUN_006606a0();

    operator_delete(pvVar2);

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  if (*(undefined4 **)(param_1 + 0x14) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x14))(1);

  }

  *(undefined4 *)(param_1 + 0x14) = 0;

  return;

}





// --- FUN_00549c20 at 0x00549C20 (size: 125) ---


uint __thiscall FUN_00549c20(int param_1,int param_2)



{

  char *pcVar1;

  undefined4 *puVar2;

  uint uVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  uint uVar6;

  

  uVar3 = *(uint *)(param_1 + 0x50);

  if (0x72 < uVar3) {

    uVar3 = 0x72;

  }

  puVar5 = *(undefined4 **)(param_1 + 0x4c);

  uVar6 = 0;

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

    for (puVar4 = (undefined4 *)*puVar5; puVar4 != (undefined4 *)0x0; puVar4 = (undefined4 *)*puVar4

        ) {

      puVar5 = puVar4;

    }

    while ((puVar5 != (undefined4 *)0x0 && (uVar6 < 0x73))) {

      *(undefined4 *)(param_2 + uVar6 * 4) = puVar5[6];

      puVar4 = (undefined4 *)puVar5[1];

      uVar6 = uVar6 + 1;

      if (puVar4 == (undefined4 *)0x0) {

        while (pcVar1 = (char *)(puVar5 + 8), puVar5 = (undefined4 *)puVar5[2], *pcVar1 == '\0') {

          if (puVar5 == (undefined4 *)0x0) {

            return uVar3;

          }

        }

      }

      else {

        if (puVar4 == (undefined4 *)0x0) {

          return uVar3;

        }

        while (puVar2 = (undefined4 *)*puVar4, puVar5 = puVar4, puVar2 != (undefined4 *)0x0) {

          puVar4 = puVar2;

          if (puVar2 == (undefined4 *)0x0) {

            return uVar3;

          }

        }

      }

    }

  }

  return uVar3;

}





// --- FUN_00549ca0 at 0x00549CA0 (size: 245) ---


undefined4 __thiscall FUN_00549ca0(undefined4 *param_1,uint param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  int iVar4;

  

  piVar3 = (int *)*param_1;

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

    do {

      piVar2 = piVar3;

      if ((uint)piVar2[6] <= param_2) {

        piVar3 = (int *)piVar2[1];

      }

      else {

        piVar3 = (int *)*piVar2;

      }

    } while (piVar3 != (int *)0x0);

    if ((uint)piVar2[6] <= param_2) {

      iVar4 = FUN_005df0f5(0x24);

      if (iVar4 == 0) {

        iVar4 = 0;

      }

      else {

        iVar4 = FUN_00549890(param_2,param_3,piVar2);

      }

      piVar2[1] = iVar4;

      *(undefined1 *)(iVar4 + 0x20) = 0;

    }

    else {

      iVar4 = FUN_005df0f5(0x24);

      if (iVar4 == 0) {

        *piVar2 = 0;

        uRam00000020 = 1;

      }

      else {

        iVar4 = FUN_00549890(param_2,param_3,piVar2);

        *piVar2 = iVar4;

        *(undefined1 *)(iVar4 + 0x20) = 1;

      }

    }

    FUN_00544340(piVar2,0);

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

    return param_3;

  }

  puVar1 = (undefined4 *)FUN_005df0f5(0x24);

  if (puVar1 == (undefined4 *)0x0) {

    *param_1 = 0;

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

    return param_3;

  }

  *puVar1 = 0;

  puVar1[1] = 0;

  puVar1[2] = 0;

  puVar1[6] = param_2;

  puVar1[3] = 1;

  puVar1[4] = 1;

  puVar1[5] = 1;

  puVar1[7] = param_3;

  *(undefined1 *)(puVar1 + 8) = 1;

  *param_1 = puVar1;

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

  return param_3;

}





// --- FUN_00549da0 at 0x00549DA0 (size: 110) ---


void __thiscall FUN_00549da0(int param_1,uint param_2,undefined4 *param_3)



{

  uint uVar1;

  undefined4 *puVar2;

  

  uVar1 = param_2;

  if (*(int *)(param_1 + 0x44) == 2) {

    *(undefined4 *)(param_1 + 0x44) = 1;

  }

  puVar2 = *(undefined4 **)(param_1 + 0x4c);

  do {

    if (puVar2 == (undefined4 *)0x0) {

LAB_00549ddd:

      param_2 = 0;

      puVar2 = param_3;

      if (param_3 == (undefined4 *)0x0) {

        param_2 = FUN_00660ea0(uVar1);

        puVar2 = &param_2;

      }

      FUN_00549ca0(uVar1,*puVar2);

      return;

    }

    if (param_2 == puVar2[6]) {

      if (puVar2[7] != 0) {

        return;

      }

      goto LAB_00549ddd;

    }

    if (param_2 < (uint)puVar2[6]) {

      puVar2 = (undefined4 *)*puVar2;

    }

    else {

      puVar2 = (undefined4 *)puVar2[1];

    }

  } while( true );

}





// --- FUN_00549e10 at 0x00549E10 (size: 191) ---


void __fastcall FUN_00549e10(int param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  uint uVar4;

  

  *(undefined4 *)(param_1 + 0x11c) = 0;

  *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) & 0xfffffffe;

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

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

    uVar4 = 0;

    do {

      iVar1 = FUN_00660640(*(undefined4 *)(*piVar3 + 0x10),*(undefined4 *)(*piVar3 + 0x14));

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

      uVar4 = uVar4 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0x8c));

  }

  uVar4 = 0;

  if (*(int *)(param_1 + 0x104) != 0) {

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

    do {

      iVar1 = *piVar3;

      iVar2 = FUN_00660640(*(undefined4 *)(iVar1 + 0x10),0x10);

      *(int *)(param_1 + 0x11c) = *(int *)(param_1 + 0x11c) + iVar2;

      iVar1 = FUN_00660640(*(undefined4 *)(iVar1 + 0x28),

                           *(ushort *)(*(int *)(iVar1 + 0x10) + 10) - 0x10);

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

      uVar4 = uVar4 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0x104));

  }

  return;

}





// --- FUN_00549ed0 at 0x00549ED0 (size: 42) ---


void __thiscall FUN_00549ed0(int param_1,int param_2)



{

  uint uVar1;

  int *piVar2;

  int iVar3;

  

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

  uVar1 = 0;

  if (iVar3 != 0) {

    piVar2 = (int *)(param_1 + 0xc);

    do {

      uVar1 = uVar1 | *(uint *)(*piVar2 + 8);

      piVar2 = piVar2 + 1;

      iVar3 = iVar3 + -1;

    } while (iVar3 != 0);

  }

  if (param_2 != 0) {

    *(uint *)(param_2 + 4) = *(uint *)(param_2 + 4) | uVar1;

  }

  return;

}





// --- FUN_00549f00 at 0x00549F00 (size: 34) ---


void __thiscall FUN_00549f00(int param_1,int *param_2,int *param_3)



{

  if (*param_2 == 0) {

    *param_2 = param_1;

    *param_3 = param_1;

    return;

  }

  *(int *)(*param_3 + 8) = param_1;

  *param_3 = param_1;

  return;

}





// --- FUN_00549f30 at 0x00549F30 (size: 78) ---


void __thiscall FUN_00549f30(int param_1,int *param_2,int *param_3)



{

  int iVar1;

  

  iVar1 = *param_2;

  if (iVar1 == 0) {

    *param_3 = param_1;

    *param_2 = param_1;

    *(undefined4 *)(param_1 + 8) = 0;

    return;

  }

  if ((*(byte *)(iVar1 + 0x120) & 1) == 0) {

    *(int *)(param_1 + 8) = iVar1;

    *param_2 = param_1;

  }

  else {

    *(undefined4 *)(param_1 + 8) = *(undefined4 *)(iVar1 + 8);

    *(int *)(*param_2 + 8) = param_1;

    if (*param_3 == *param_2) {

      *param_3 = param_1;

      return;

    }

  }

  return;

}





// --- FUN_00549f80 at 0x00549F80 (size: 53) ---


void __thiscall FUN_00549f80(int param_1,int param_2,undefined4 *param_3,int *param_4)



{

  if (param_2 == 0) {

    *param_3 = *(undefined4 *)(param_1 + 8);

    if (*param_4 == param_1) {

      *param_4 = 0;

      return;

    }

  }

  else {

    *(undefined4 *)(param_2 + 8) = *(undefined4 *)(param_1 + 8);

    if (*param_4 == param_1) {

      *param_4 = param_2;

    }

  }

  return;

}





// --- FUN_00549fc0 at 0x00549FC0 (size: 162) ---


void __thiscall FUN_00549fc0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  

  InterlockedIncrement((LONG *)(param_2 + 4));

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

  if (0 < iVar1) {

    piVar2 = (int *)(param_1 + 8 + iVar1 * 4);

    do {

      if (*(uint *)(*piVar2 + 8) <= *(uint *)(param_2 + 8)) break;

      piVar2[1] = *piVar2;

      iVar1 = iVar1 + -1;

      piVar2 = piVar2 + -1;

    } while (0 < iVar1);

  }

  *(int *)(param_1 + 0xc + iVar1 * 4) = param_2;

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

  *(int *)(param_1 + 0x110) = *(int *)(param_1 + 0x110) + *(int *)(param_2 + 0x14);

  iVar1 = FUN_00660640(*(undefined4 *)(param_2 + 0x10),*(undefined4 *)(param_2 + 0x14));

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

  if ((*(byte *)(param_2 + 0xc) & 8) != 0) {

    *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) | 2;

  }

  if ((*(byte *)(param_2 + 0xc) & 1) == 0) {

    *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) | 4;

  }

  if ((*(byte *)(param_2 + 0xc) & 0x20) != 0) {

    *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) | 8;

  }

  return;

}





// --- FUN_0054a070 at 0x0054A070 (size: 187) ---


undefined4 __fastcall FUN_0054a070(int param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  uint uVar3;

  int *piVar4;

  uint uVar5;

  int *local_8;

  uint local_4;

  

  uVar5 = 0;

  local_4 = 0;

  uVar3 = 0;

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

    piVar4 = (int *)(param_1 + 0xc);

    local_8 = piVar4;

    do {

      puVar1 = (undefined4 *)*local_8;

      if ((*(byte *)(puVar1 + 3) & 1) == 0) {

        local_4 = local_4 + 1;

        *piVar4 = (int)puVar1;

        piVar4 = piVar4 + 1;

      }

      else {

        *(int *)(param_1 + 0x110) = *(int *)(param_1 + 0x110) - puVar1[5];

        LVar2 = InterlockedDecrement(puVar1 + 1);

        if (LVar2 == 0) {

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

        }

      }

      uVar5 = uVar5 + 1;

      local_8 = local_8 + 1;

    } while (uVar5 < *(uint *)(param_1 + 0x8c));

    uVar3 = local_4;

    if (uVar5 != local_4) {

      *(uint *)(param_1 + 0x8c) = *(int *)(param_1 + 0x8c) + (local_4 - uVar5);

      *(undefined4 *)(param_1 + 0x11c) = 0;

      *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) & 0xfffffffe;

    }

  }

  return CONCAT31((int3)(uVar3 >> 8),uVar5 != uVar3);

}





// --- FUN_0054a130 at 0x0054A130 (size: 101) ---


undefined4 __fastcall FUN_0054a130(int param_1)



{

  bool bVar1;

  int *piVar2;

  uint uVar3;

  

  if ((*(byte *)(param_1 + 0x120) & 2) != 0) {

    bVar1 = false;

    uVar3 = 0;

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

      piVar2 = (int *)(param_1 + 0xc);

      do {

        if ((*(byte *)((int *)*piVar2 + 3) & 8) != 0) {

          (**(code **)(*(int *)*piVar2 + 4))();

          bVar1 = true;

        }

        uVar3 = uVar3 + 1;

        piVar2 = piVar2 + 1;

      } while (uVar3 < *(uint *)(param_1 + 0x8c));

      if (bVar1) {

        *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) & 0xfffffffe;

        *(undefined4 *)(param_1 + 0x11c) = 0;

        return 1;

      }

    }

    *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) & 0xfffffffd;

  }

  return 1;

}





// --- FUN_0054a1a0 at 0x0054A1A0 (size: 167) ---


void __thiscall FUN_0054a1a0(int param_1,int param_2,undefined2 param_3,uint param_4)



{

  int iVar1;

  

  if (*(short *)(param_1 + 0x108) == 0) {

    *(undefined2 *)(param_1 + 0x108) = param_3;

  }

  if (*(uint *)(param_1 + 0x10c) < param_4) {

    *(uint *)(param_1 + 0x10c) = param_4;

  }

  InterlockedIncrement((LONG *)(param_2 + 4));

  *(int *)(param_1 + 0x90 + *(int *)(param_1 + 0x104) * 4) = param_2;

  *(int *)(param_1 + 0x104) = *(int *)(param_1 + 0x104) + 1;

  *(int *)(param_1 + 0x110) =

       *(int *)(param_1 + 0x110) + (uint)*(ushort *)(*(int *)(param_2 + 0x10) + 10);

  iVar1 = FUN_00660640(*(undefined4 *)(param_2 + 0x10),0x10);

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

  iVar1 = FUN_00660640(*(undefined4 *)(param_2 + 0x28),

                       *(ushort *)(*(int *)(param_2 + 0x10) + 10) - 0x10);

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

  *(uint *)(param_1 + 0x120) = *(uint *)(param_1 + 0x120) | 4;

  return;

}





// --- FUN_0054a250 at 0x0054A250 (size: 131) ---


undefined4 * __thiscall

FUN_0054a250(undefined4 *param_1,int param_2,undefined2 param_3,undefined2 param_4,

            undefined4 param_5,short param_6)



{

  undefined4 *puVar1;

  

  param_1[2] = 0;

  param_1[0xb] = 0;

  param_1[1] = 1;

  *param_1 = &PTR_FUN_007cb4cc;

  param_1[10] = param_5;

  param_1[3] = param_1 + 6;

  param_1[4] = param_1 + 6;

  InterlockedIncrement((LONG *)(param_2 + 4));

  puVar1 = (undefined4 *)param_1[3];

  param_1[0xb] = param_2;

  *puVar1 = *(undefined4 *)(param_2 + 0x20);

  puVar1[1] = *(undefined4 *)(param_2 + 0x24);

  *(undefined2 *)(param_1[3] + 0xe) = *(undefined2 *)(param_1[0xb] + 0x3e);

  *(short *)(param_1[3] + 10) = param_6 + 0x10;

  *(undefined2 *)(param_1[3] + 8) = param_4;

  *(undefined2 *)(param_1[3] + 0xc) = param_3;

  return param_1;

}





// --- FUN_0054a2e0 at 0x0054A2E0 (size: 49) ---


undefined4 * __thiscall FUN_0054a2e0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb4cc;

  if (param_1[0xb] != 0) {

    FUN_00405f70();

  }

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0054a320 at 0x0054A320 (size: 94) ---


void __thiscall FUN_0054a320(undefined4 *param_1,int param_2,uint param_3,uint *param_4)



{

  ushort uVar1;

  

  param_1[2] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[3] = 0;

  param_1[4] = param_2;

  param_1[1] = 1;

  *param_1 = &PTR_FUN_007cb4cc;

  *param_4 = 0;

  uVar1 = *(ushort *)(param_1[4] + 10);

  if (((0xf < uVar1) && (uVar1 < 0x1d1)) && (uVar1 <= param_3)) {

    param_1[10] = param_2 + 0x10;

    *param_4 = (uint)*(ushort *)(param_1[4] + 10);

  }

  return;

}





// --- FUN_0054a380 at 0x0054A380 (size: 50) ---


undefined4

FUN_0054a380(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x30);

  if (iVar1 != 0) {

    uVar2 = FUN_0054a250(param_1,param_2,param_3,param_4,param_5);

    return uVar2;

  }

  return 0;

}





// --- FUN_0054a3c0 at 0x0054A3C0 (size: 118) ---


undefined4 * FUN_0054a3c0(int *param_1)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  int local_4;

  

  local_4 = 0;

  iVar2 = FUN_005df0f5(0x30);

  if (iVar2 == 0) {

    return (undefined4 *)0x0;

  }

  uVar1 = param_1[1];

  if (uVar1 < (uint)param_1[2]) {

    iVar2 = param_1[2] - uVar1;

  }

  else {

    iVar2 = 0;

  }

  puVar3 = (undefined4 *)FUN_0054a320(*param_1 + uVar1,iVar2,&local_4);

  if (local_4 == 0) {

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

      LVar4 = InterlockedDecrement(puVar3 + 1);

      if (LVar4 == 0) {

        (**(code **)*puVar3)(1);

      }

      return (undefined4 *)0x0;

    }

  }

  else {

    param_1[1] = param_1[1] + local_4;

  }

  return puVar3;

}





// --- FUN_0054a440 at 0x0054A440 (size: 27) ---


void __thiscall FUN_0054a440(int param_1,undefined4 param_2)



{

  FUN_005b1970(param_2);

  *(undefined4 *)(param_1 + 0x14) = 1;

  return;

}





// --- FUN_0054a4f0 at 0x0054A4F0 (size: 39) ---


undefined4 * __thiscall FUN_0054a4f0(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = &PTR_FUN_007cb4d0;

  param_1[1] = param_2;

  FUN_005b1900(0);

  param_1[5] = 0;

  return param_1;

}





// --- FUN_0054a540 at 0x0054A540 (size: 53) ---


undefined4 * __thiscall FUN_0054a540(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb4d0;

  param_1[5] = 0;

  param_1[1] = 0;

  FUN_005b19d0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0054a580 at 0x0054A580 (size: 259) ---


void __thiscall FUN_0054a580(int param_1,int param_2)



{

  int iVar1;

  uint uVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (*(int *)(param_1 + 0x38) == 0) {

    iVar1 = *(int *)(param_2 + 0x10);

    uVar2 = (uint)*(ushort *)(iVar1 + 8);

    if (*(ushort *)(iVar1 + 0xc) + 1 == uVar2) {

      *(uint *)(param_1 + 0x30) = (uVar2 - 1) * 0x1c0 + -0x10 + (uint)*(ushort *)(iVar1 + 10);

    }

    else {

      *(uint *)(param_1 + 0x30) = uVar2 * 0x1c0;

    }

    uVar3 = thunk_FUN_005df0f5(*(undefined4 *)(param_1 + 0x30));

    *(undefined4 *)(param_1 + 0x2c) = uVar3;

    puVar6 = *(undefined4 **)(param_2 + 0x10);

    *(undefined4 *)(param_1 + 0x20) = *puVar6;

    *(undefined4 *)(param_1 + 0x24) = puVar6[1];

    *(uint *)(param_1 + 0x34) = (uint)*(ushort *)(*(int *)(param_2 + 0x10) + 8);

    *(undefined2 *)(param_1 + 0x3e) = *(undefined2 *)(*(int *)(param_2 + 0x10) + 0xe);

  }

  iVar1 = *(int *)(param_2 + 0x10);

  uVar2 = *(ushort *)(iVar1 + 10) - 0x10;

  puVar6 = (undefined4 *)((uint)*(ushort *)(iVar1 + 0xc) * 0x1c0 + *(int *)(param_1 + 0x2c));

  if (((((uint)*(ushort *)(iVar1 + 8) == *(uint *)(param_1 + 0x34)) &&

       (*(short *)(iVar1 + 0xe) == *(short *)(param_1 + 0x3e))) &&

      ((uint)*(ushort *)(iVar1 + 0xc) < *(uint *)(param_1 + 0x34))) &&

     ((uVar2 < 0x1c1 &&

      ((undefined1 *)((int)puVar6 + uVar2) <=

       (undefined1 *)(*(int *)(param_1 + 0x30) + *(int *)(param_1 + 0x2c)))))) {

    puVar5 = *(undefined4 **)(param_2 + 0x28);

    for (uVar4 = uVar2 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {

      *puVar6 = *puVar5;

      puVar5 = puVar5 + 1;

      puVar6 = puVar6 + 1;

    }

    for (uVar4 = uVar2 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {

      *(undefined1 *)puVar6 = *(undefined1 *)puVar5;

      puVar5 = (undefined4 *)((int)puVar5 + 1);

      puVar6 = (undefined4 *)((int)puVar6 + 1);

    }

    uVar4 = *(uint *)(param_1 + 0x34);

    *(int *)(param_1 + 0x38) = *(int *)(param_1 + 0x38) + 1;

    if ((1 < uVar4) && (uVar4 == *(ushort *)(*(int *)(param_2 + 0x10) + 0xc) + 1)) {

      *(uint *)(param_1 + 0x30) = (uVar4 - 1) * 0x1c0 + uVar2;

    }

  }

  return;

}





// --- FUN_0054a690 at 0x0054A690 (size: 8) ---


void __fastcall FUN_0054a690(int param_1)



{

  *(undefined4 *)(param_1 + 0x28) = 3;

  return;

}





// --- FUN_0054a6a0 at 0x0054A6A0 (size: 67) ---


uint __thiscall FUN_0054a6a0(int param_1,undefined4 param_2,int param_3)



{

  uint uVar1;

  

  if (*(short *)(DAT_00846f18 + 0x8a6e) == 0) {

    return DAT_00846f18 & 0xffffff00;

  }

  if (param_3 == -0x32323233) {

    param_3 = 1;

  }

  *(undefined4 *)(param_1 + 0x28) = 1;

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

  FUN_00541770(param_1,param_2);

  uVar1 = FUN_005417d0(param_1,param_2);

  return uVar1;

}





// --- FUN_0054a6f0 at 0x0054A6F0 (size: 123) ---


undefined4 * __thiscall

FUN_0054a6f0(undefined4 *param_1,undefined4 param_2,uint param_3,undefined2 param_4)



{

  uint uVar1;

  

  param_1[1] = 1;

  param_1[2] = &PTR_FUN_0079385c;

  param_1[6] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[4] = &PTR_LAB_007cb50c;

  param_1[0xb] = param_2;

  *(undefined2 *)((int)param_1 + 0x3e) = param_4;

  param_1[0xc] = param_3;

  uVar1 = param_3 / 0x1c0;

  param_1[10] = 0;

  param_1[0xe] = 0;

  *(undefined2 *)(param_1 + 0xf) = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  *param_1 = &PTR_FUN_007cb528;

  param_1[2] = &PTR_LAB_007cb514;

  param_1[4] = &PTR_LAB_007cb510;

  if (param_3 % 0x1c0 != 0) {

    uVar1 = uVar1 + 1;

  }

  param_1[0xd] = uVar1;

  return param_1;

}





// --- FUN_0054a7a0 at 0x0054A7A0 (size: 94) ---


void __fastcall FUN_0054a7a0(undefined4 *param_1)



{

  param_1[1] = 1;

  param_1[2] = &PTR_FUN_0079385c;

  param_1[6] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[4] = &PTR_LAB_007cb50c;

  *param_1 = &PTR_FUN_007cb528;

  param_1[2] = &PTR_LAB_007cb514;

  param_1[4] = &PTR_LAB_007cb510;

  param_1[10] = 2;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  *(undefined2 *)(param_1 + 0xf) = 0;

  *(undefined2 *)((int)param_1 + 0x3e) = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  return;

}





// --- FUN_0054a800 at 0x0054A800 (size: 68) ---


void __fastcall FUN_0054a800(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cb528;

  param_1[2] = &PTR_LAB_007cb514;

  param_1[4] = &PTR_LAB_007cb510;

  operator_delete__((void *)param_1[0xb]);

  param_1[4] = &PTR_LAB_007cb50c;

  param_1[6] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[2] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_0054a850 at 0x0054A850 (size: 164) ---


int __thiscall FUN_0054a850(int param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  uint uVar6;

  uint local_c;

  

  *param_2 = 0;

  uVar4 = *(uint *)(param_1 + 0x30);

  local_c = uVar4 / 0x1c0;

  *(undefined4 *)(param_1 + 0x28) = 4;

  if (uVar4 % 0x1c0 != 0) {

    local_c = local_c + 1;

  }

  iVar3 = *(int *)(param_1 + 0x2c);

  iVar5 = 0;

  iVar1 = 0;

  for (; uVar4 != 0; uVar4 = uVar4 - uVar6) {

    uVar6 = 0x1c0;

    if (uVar4 < 0x1c1) {

      uVar6 = uVar4;

    }

    iVar2 = FUN_0054a380(param_1,iVar5,local_c,iVar3,uVar6);

    iVar5 = iVar5 + 1;

    if (*param_2 == 0) {

      *param_2 = iVar2;

    }

    if (iVar1 != 0) {

      *(int *)(iVar1 + 8) = iVar2;

    }

    iVar3 = iVar3 + uVar6;

    iVar1 = iVar2;

  }

  return iVar5;

}





// --- FUN_0054a9d0 at 0x0054A9D0 (size: 199) ---


undefined4 __thiscall FUN_0054a9d0(int param_1,int *param_2)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  uint uVar5;

  uint uVar6;

  

  puVar3 = (undefined4 *)*param_2;

  *(undefined4 *)(param_1 + 0x18) = *puVar3;

  *(undefined4 *)(param_1 + 0x1c) = puVar3[1];

  iVar1 = *param_2;

  puVar3 = (undefined4 *)(iVar1 + 8);

  *param_2 = (int)puVar3;

  uVar2 = *puVar3;

  *param_2 = iVar1 + 0xc;

  *(undefined4 *)(param_1 + 0x20) = uVar2;

  *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)*param_2;

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined2 *)(param_1 + 0x34) = *(undefined2 *)(iVar1 + 4);

  iVar1 = *param_2;

  *param_2 = iVar1 + 2;

  *(undefined2 *)(param_1 + 0x36) = *(undefined2 *)(iVar1 + 2);

  iVar1 = *param_2;

  *param_2 = iVar1 + 2;

  *(undefined4 *)(param_1 + 0x38) = *(undefined4 *)(iVar1 + 2);

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined4 *)(param_1 + 0x30) = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined4 *)(param_1 + 0x2c) = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  puVar3 = (undefined4 *)(iVar1 + 4);

  *param_2 = (int)puVar3;

  *(undefined4 *)(param_1 + 0x40) = *puVar3;

  *(undefined4 *)(param_1 + 0x44) = *(undefined4 *)(iVar1 + 8);

  *param_2 = *param_2 + 8;

  puVar4 = (undefined4 *)thunk_FUN_005df0f5(*(undefined4 *)(param_1 + 0x28));

  uVar6 = *(uint *)(param_1 + 0x28);

  *(undefined4 **)(param_1 + 0x24) = puVar4;

  puVar3 = (undefined4 *)*param_2;

  for (uVar5 = uVar6 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {

    *puVar4 = *puVar3;

    puVar3 = puVar3 + 1;

    puVar4 = puVar4 + 1;

  }

  for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {

    *(undefined1 *)puVar4 = *(undefined1 *)puVar3;

    puVar3 = (undefined4 *)((int)puVar3 + 1);

    puVar4 = (undefined4 *)((int)puVar4 + 1);

  }

  *param_2 = *param_2 + *(int *)(param_1 + 0x28);

  return 1;

}





// --- FUN_0054aaa0 at 0x0054AAA0 (size: 89) ---


undefined4 * __thiscall FUN_0054aaa0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb528;

  param_1[2] = &PTR_LAB_007cb514;

  param_1[4] = &PTR_LAB_007cb510;

  operator_delete__((void *)param_1[0xb]);

  param_1[6] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[4] = &PTR_LAB_007cb50c;

  param_1[2] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0054ab00 at 0x0054AB00 (size: 50) ---


undefined4 * __thiscall FUN_0054ab00(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb554;

  if (param_1[7] == 0) {

    operator_delete__((void *)param_1[5]);

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0054ab40 at 0x0054AB40 (size: 136) ---


void __fastcall FUN_0054ab40(int *param_1)



{

  uint uVar1;

  int iVar2;

  

  if (param_1[4] == 0) {

    if (param_1[3] == 0) {

      *(undefined4 *)(*(int *)(*param_1 + 0x14) + param_1[1] * 4) = *(undefined4 *)(param_1[2] + 8);

      iVar2 = *(int *)(*(int *)(*param_1 + 0x14) + param_1[1] * 4);

    }

    else {

      *(undefined4 *)(param_1[3] + 8) = *(undefined4 *)(param_1[2] + 8);

      iVar2 = *(int *)(param_1[3] + 8);

    }

    if ((undefined4 *)param_1[2] != (undefined4 *)0x0) {

      (*(code *)**(undefined4 **)param_1[2])(1);

    }

    if (iVar2 == 0) {

      do {

        uVar1 = param_1[1] + 1;

        param_1[3] = 0;

        param_1[1] = uVar1;

        if (*(uint *)(*param_1 + 0x18) <= uVar1) {

          param_1[4] = 1;

          param_1[2] = 0;

          return;

        }

        iVar2 = *(int *)(*(int *)(*param_1 + 0x14) + uVar1 * 4);

      } while (iVar2 == 0);

    }

    param_1[2] = iVar2;

  }

  return;

}





// --- FUN_0054abd0 at 0x0054ABD0 (size: 75) ---


void __fastcall FUN_0054abd0(int *param_1)



{

  int iVar1;

  uint uVar2;

  

  iVar1 = param_1[2];

  if (iVar1 != 0) {

    param_1[3] = iVar1;

    param_1[2] = *(int *)(iVar1 + 8);

  }

  if (param_1[2] == 0) {

    while( true ) {

      uVar2 = param_1[1] + 1;

      param_1[3] = 0;

      param_1[1] = uVar2;

      if (*(uint *)(*param_1 + 0x18) <= uVar2) break;

      iVar1 = *(int *)(*(int *)(*param_1 + 0x14) + uVar2 * 4);

      param_1[2] = iVar1;

      if (iVar1 != 0) {

        return;

      }

    }

    param_1[4] = 1;

  }

  return;

}





// --- FUN_0054ac20 at 0x0054AC20 (size: 138) ---


int __thiscall FUN_0054ac20(int param_1,uint param_2,int param_3)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  

  uVar5 = __aullshr();

  piVar1 = (int *)(*(int *)(param_1 + 0x14) + ((uVar5 ^ param_2) & *(uint *)(param_1 + 8)) * 4);

  iVar2 = *piVar1;

  if (iVar2 != 0) {

    if ((*(uint *)(iVar2 + 0x10) == param_2) && (*(int *)(iVar2 + 0x14) == param_3)) {

      *piVar1 = *(int *)(iVar2 + 8);

      return iVar2;

    }

    iVar3 = *(int *)(iVar2 + 8);

    while (iVar3 != 0) {

      iVar4 = *(int *)(iVar2 + 8);

      if ((*(uint *)(iVar4 + 0x10) == param_2) && (*(int *)(iVar4 + 0x14) == param_3)) {

        iVar3 = *(int *)(iVar2 + 8);

        *(undefined4 *)(iVar2 + 8) = *(undefined4 *)(iVar3 + 8);

        return iVar3;

      }

      iVar2 = iVar4;

      iVar3 = *(int *)(iVar4 + 8);

    }

  }

  return 0;

}





// --- FUN_0054acb0 at 0x0054ACB0 (size: 73) ---


int __thiscall FUN_0054acb0(int param_1,uint param_2,int param_3)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = __aullshr();

  iVar1 = *(int *)(*(int *)(param_1 + 0x14) + ((uVar2 ^ param_2) & *(uint *)(param_1 + 8)) * 4);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if ((param_2 == *(uint *)(iVar1 + 0x10)) && (param_3 == *(int *)(iVar1 + 0x14))) break;

    iVar1 = *(int *)(iVar1 + 8);

  }

  return iVar1;

}





// --- FUN_0054ad00 at 0x0054AD00 (size: 85) ---


void __thiscall FUN_0054ad00(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  

  if (param_2 == 0) {

    param_2 = 0;

  }

  else {

    param_2 = param_2 + 0x10;

  }

  uVar2 = *(uint *)(param_2 + 0x10);

  uVar1 = __aullshr();

  uVar2 = (uVar1 ^ uVar2) & *(uint *)(param_1 + 8);

  *(undefined4 *)(param_2 + 8) = *(undefined4 *)(*(int *)(param_1 + 0x14) + uVar2 * 4);

  *(int *)(*(int *)(param_1 + 0x14) + uVar2 * 4) = param_2;

  return;

}





// --- FUN_0054ad60 at 0x0054AD60 (size: 79) ---


void FUN_0054ad60(undefined4 *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  FUN_0054ac20(param_1[8],param_1[9]);

  param_1[9] = param_1[0x13];

  param_1[8] = param_1[0x12];

  FUN_0054a690();

  puVar2 = param_1;

  FUN_00541770(param_1);

  FUN_00542070(puVar2);

  LVar1 = InterlockedDecrement(param_1 + 1);

  if (LVar1 == 0) {

    (**(code **)*param_1)(1);

  }

  return;

}





// --- FUN_0054adb0 at 0x0054ADB0 (size: 269) ---


undefined4 * __fastcall FUN_0054adb0(undefined4 *param_1)



{

  undefined4 uVar1;

  uint uVar2;

  uint uVar3;

  uint uVar4;

  uint uVar5;

  

  *param_1 = &PTR_FUN_007cb558;

  param_1[2] = &PTR_FUN_007cb554;

  param_1[9] = 0;

  uVar1 = thunk_FUN_005df0f5(0x200);

  param_1[7] = uVar1;

  param_1[8] = 0x80;

  param_1[6] = 0x10;

  param_1[4] = 0;

  param_1[5] = 0;

  uVar2 = 1;

  uVar3 = 0;

  do {

    uVar5 = param_1[4] | uVar2;

    uVar4 = param_1[5] | uVar3;

    uVar3 = uVar3 << 1 | uVar2 >> 0x1f;

    uVar2 = uVar2 << 1;

    param_1[5] = uVar4;

    param_1[4] = uVar5;

    if (uVar4 != 0 || uVar3 != 0) break;

  } while ((uVar5 | uVar2) < (uint)param_1[8]);

  uVar2 = 0;

  do {

    *(undefined4 *)(param_1[7] + uVar2 * 4) = 0;

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[8]);

  param_1[2] = &PTR_FUN_007cb554;

  param_1[10] = &PTR_FUN_007cb554;

  param_1[0x11] = 0;

  uVar1 = thunk_FUN_005df0f5(0x80);

  param_1[0xf] = uVar1;

  param_1[0x10] = 0x20;

  param_1[0xe] = 0x10;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  uVar2 = 1;

  uVar3 = 0;

  do {

    uVar5 = param_1[0xc] | uVar2;

    uVar4 = param_1[0xd] | uVar3;

    uVar3 = uVar3 << 1 | uVar2 >> 0x1f;

    uVar2 = uVar2 << 1;

    param_1[0xd] = uVar4;

    param_1[0xc] = uVar5;

    if (uVar4 != 0 || uVar3 != 0) break;

  } while ((uVar5 | uVar2) < (uint)param_1[0x10]);

  uVar2 = 0;

  do {

    *(undefined4 *)(param_1[0xf] + uVar2 * 4) = 0;

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[0x10]);

  param_1[10] = &PTR_FUN_007cb554;

  param_1[0x12] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  return param_1;

}





// --- FUN_0054aed0 at 0x0054AED0 (size: 85) ---


void __thiscall FUN_0054aed0(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  

  uVar2 = *(uint *)(param_2 + 0x10);

  uVar1 = __aullshr();

  uVar2 = (uVar1 ^ uVar2) & *(uint *)(param_1 + 0x30);

  *(undefined4 *)(param_2 + 8) = *(undefined4 *)(*(int *)(param_1 + 0x3c) + uVar2 * 4);

  *(int *)(*(int *)(param_1 + 0x3c) + uVar2 * 4) = param_2;

  if (*(int *)(param_1 + 0x48) != 0) {

    *(int *)(param_2 + 0x18) = *(int *)(param_1 + 0x48);

  }

  *(int *)(param_1 + 0x48) = param_2;

  return;

}





// --- FUN_0054af30 at 0x0054AF30 (size: 119) ---


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



void __fastcall FUN_0054af30(int param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  char cVar5;

  

  uVar3 = DAT_008379ac;

  if (_DAT_0079a1b0 <= (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(param_1 + 0x50)) {

    *(undefined4 *)(param_1 + 0x50) = DAT_008379a8;

    *(undefined4 *)(param_1 + 0x54) = uVar3;

    puVar1 = *(undefined4 **)(param_1 + 0x48);

    puVar4 = (undefined4 *)0x0;

    while (puVar2 = puVar4, puVar4 = puVar1, puVar4 != (undefined4 *)0x0) {

      puVar1 = (undefined4 *)puVar4[6];

      cVar5 = FUN_0054ba40();

      if (cVar5 != '\0') {

        if (puVar2 == (undefined4 *)0x0) {

          *(undefined4 **)(param_1 + 0x48) = puVar1;

        }

        else {

          puVar2[6] = puVar1;

        }

        FUN_0054ac20(puVar4[4],puVar4[5]);

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

        puVar4 = puVar2;

      }

    }

  }

  return;

}





// --- FUN_0054afb0 at 0x0054AFB0 (size: 207) ---


undefined4 FUN_0054afb0(int param_1,int param_2)



{

  char cVar1;

  int iVar2;

  undefined4 uVar3;

  undefined8 uVar4;

  

  cVar1 = FUN_005ab3b0(param_1,param_2);

  if (cVar1 == '\0') {

    return 0;

  }

  uVar4 = FUN_005ab3e0(param_1,param_2);

  iVar2 = FUN_0054acb0(uVar4);

  if (iVar2 == 0) {

    iVar2 = FUN_005df0f5(0x30);

    if (iVar2 != 0) {

      uVar3 = FUN_0054b9c0(uVar4,param_1,param_2);

      FUN_0054aed0(uVar3);

      return 0;

    }

    FUN_0054aed0(0);

    return 0;

  }

  if ((param_1 != *(int *)(iVar2 + 0x20)) || (param_2 != *(int *)(iVar2 + 0x24))) {

    cVar1 = FUN_005ab4b0(*(int *)(iVar2 + 0x20),*(int *)(iVar2 + 0x24),param_1,param_2);

    if (cVar1 != '\0') {

      return 1;

    }

    FUN_0054ba10(param_1,param_2);

  }

  return 0;

}





// --- FUN_0054b080 at 0x0054B080 (size: 86) ---


void __fastcall FUN_0054b080(int param_1)



{

  if (param_1 == 0) {

    return;

  }

  if (**(int **)(param_1 + 0x14) == 0) {

    FUN_0054abd0(param_1,0,0,0);

  }

  do {

    FUN_0054ab40();

  } while( true );

}





// --- FUN_0054b0e0 at 0x0054B0E0 (size: 184) ---


void __fastcall FUN_0054b0e0(int param_1)



{

  int iVar1;

  LONG LVar2;

  undefined4 *puVar3;

  

  if (param_1 == -8) {

    return;

  }

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

  if (iVar1 == 0) {

    FUN_0054abd0();

  }

  do {

    if (iVar1 == 0) {

      puVar3 = (undefined4 *)0x0;

      goto LAB_0054b13d;

    }

    do {

      puVar3 = (undefined4 *)(iVar1 + -0x10);

LAB_0054b13d:

      FUN_0054ac20(puVar3[8],puVar3[9]);

      LVar2 = InterlockedDecrement(puVar3 + 1);

      if (LVar2 == 0) {

        (**(code **)*puVar3)(1);

      }

      if (param_1 == -8) {

        return;

      }

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

    } while (iVar1 != 0);

    FUN_0054abd0();

  } while( true );

}





// --- FUN_0054b1a0 at 0x0054B1A0 (size: 322) ---


void FUN_0054b1a0(int param_1,undefined2 param_2)



{

  undefined8 *puVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  char cVar7;

  int iVar8;

  undefined4 *puVar9;

  LONG LVar10;

  LONG *lpAddend;

  undefined8 uVar11;

  

  puVar1 = *(undefined8 **)(param_1 + 0x10);

  uVar2 = *(undefined4 *)puVar1;

  uVar3 = *(undefined4 *)((int)puVar1 + 4);

  uVar11 = *puVar1;

  cVar7 = FUN_005ab3b0(uVar2,uVar3);

  if (cVar7 != '\0') {

    uVar11 = FUN_005ab3e0(uVar2,uVar3);

  }

  iVar8 = FUN_0054acb0(uVar11);

  if ((iVar8 != 0) && (puVar9 = (undefined4 *)(iVar8 + -0x10), puVar9 != (undefined4 *)0x0)) {

    iVar4 = **(int **)(param_1 + 0x10);

    iVar5 = (*(int **)(param_1 + 0x10))[1];

    if ((*(int *)(iVar8 + 0x38) == iVar4) && (*(int *)(iVar8 + 0x3c) == iVar5)) {

      lpAddend = (LONG *)(iVar8 + -0xc);

      InterlockedIncrement(lpAddend);

      goto LAB_0054b2a3;

    }

    cVar7 = FUN_005ab4b0(*(int *)(iVar8 + 0x38),*(int *)(iVar8 + 0x3c),iVar4,iVar5);

    if (cVar7 == '\0') {

      return;

    }

    FUN_0054ac20(uVar11);

    LVar10 = InterlockedDecrement((LONG *)(iVar8 + -0xc));

    if (LVar10 == 0) {

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

    }

  }

  iVar8 = FUN_005df0f5(0x50);

  if (iVar8 == 0) {

    puVar9 = (undefined4 *)0x0;

  }

  else {

    puVar9 = (undefined4 *)FUN_0054a7a0();

  }

  *(undefined2 *)(puVar9 + 0xf) = param_2;

  *(undefined2 *)((int)puVar9 + 0x3e) = *(undefined2 *)(*(int *)(param_1 + 0x10) + 0xe);

  puVar6 = *(undefined4 **)(param_1 + 0x10);

  puVar9[0x12] = *puVar6;

  lpAddend = puVar9 + 1;

  puVar9[0x13] = puVar6[1];

  *(undefined8 *)(puVar9 + 8) = uVar11;

  InterlockedIncrement(lpAddend);

  FUN_0054ad00(puVar9);

LAB_0054b2a3:

  FUN_0054a580(param_1);

  *(undefined8 *)(puVar9 + 8) = uVar11;

  if (puVar9[0xe] == puVar9[0xd]) {

    FUN_0054ad60(puVar9);

  }

  LVar10 = InterlockedDecrement(lpAddend);

  if (LVar10 == 0) {

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

  }

  return;

}





// --- FUN_0054b2f0 at 0x0054B2F0 (size: 79) ---


void __fastcall FUN_0054b2f0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cb558;

  FUN_0054b0e0();

  FUN_0054b080();

  param_1[10] = &PTR_FUN_007cb554;

  if (param_1[0x11] == 0) {

    operator_delete__((void *)param_1[0xf]);

  }

  param_1[2] = &PTR_FUN_007cb554;

  if (param_1[9] == 0) {

    operator_delete__((void *)param_1[7]);

  }

  return;

}





// --- FUN_0054b340 at 0x0054B340 (size: 81) ---


void FUN_0054b340(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  

  iVar4 = *(int *)(param_1 + 0x104);

  if (0 < iVar4) {

    piVar5 = (int *)(param_1 + 0x90);

    do {

      iVar1 = *piVar5;

      puVar2 = *(undefined4 **)(iVar1 + 0x10);

      iVar3 = FUN_0054afb0(*puVar2,puVar2[1]);

      if (iVar3 == 0) {

        FUN_0054b1a0(iVar1,param_2);

      }

      piVar5 = piVar5 + 1;

      iVar4 = iVar4 + -1;

    } while (iVar4 != 0);

  }

  return;

}





// --- FUN_0054b3a0 at 0x0054B3A0 (size: 30) ---


void * __thiscall FUN_0054b3a0(void *param_1,byte param_2)



{

  FUN_0054b2f0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0054b3c0 at 0x0054B3C0 (size: 64) ---


undefined4 * __thiscall FUN_0054b3c0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb584;

  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_0054b400 at 0x0054B400 (size: 38) ---


undefined4 __thiscall FUN_0054b400(undefined4 *param_1,int param_2)



{

  int *piVar1;

  

  piVar1 = (int *)*param_1;

  while( true ) {

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

      return 0;

    }

    if (*(int *)(*piVar1 + 0x114) == param_2) break;

    piVar1 = (int *)piVar1[1];

  }

  return 1;

}





// --- FUN_0054b430 at 0x0054B430 (size: 48) ---


int __thiscall FUN_0054b430(undefined4 *param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  

  piVar2 = (int *)*param_1;

  while( true ) {

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

      return 0;

    }

    iVar1 = *piVar2;

    if (*(int *)(iVar1 + 0x114) == param_2) break;

    piVar2 = (int *)piVar2[1];

  }

  InterlockedIncrement((LONG *)(iVar1 + 4));

  return iVar1;

}





// --- FUN_0054b460 at 0x0054B460 (size: 77) ---


void __thiscall FUN_0054b460(int param_1,int *param_2,int *param_3)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  int iVar5;

  

  iVar2 = param_3[1];

  iVar3 = *param_3;

  iVar5 = __aullrem(iVar3,iVar2,*(undefined4 *)(param_1 + 0x68),0);

  puVar1 = (undefined4 *)(*(int *)(param_1 + 0x60) + iVar5 * 4);

  for (piVar4 = (int *)*puVar1;

      (piVar4 != (int *)0x0 && ((*piVar4 != iVar3 || (piVar4[1] != iVar2))));

      piVar4 = (int *)piVar4[2]) {

  }

  *param_2 = param_1;

  param_2[1] = (int)puVar1;

  param_2[2] = (int)piVar4;

  return;

}





// --- FUN_0054b4b0 at 0x0054B4B0 (size: 143) ---


undefined4 * __thiscall FUN_0054b4b0(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_007cb584;

  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_0054b540 at 0x0054B540 (size: 85) ---


int FUN_0054b540(undefined4 param_1)



{

  undefined4 local_c;

  undefined4 local_8;

  int local_4;

  

  FUN_0054b460(&local_c,param_1);

  if (local_4 != 0) {

    FUN_00540830(local_c,local_8,local_4);

    return local_4;

  }

  return 0;

}





// --- FUN_0054b5a0 at 0x0054B5A0 (size: 142) ---


undefined4 FUN_0054b5a0(undefined4 *param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  undefined1 local_c [8];

  int local_4;

  

  FUN_0054b460(local_c,param_1);

  if (local_4 != 0) {

    *(undefined4 *)(local_4 + 0x10) = *param_2;

    *(undefined4 *)(local_4 + 0x14) = param_2[1];

    return 1;

  }

  puVar1 = (undefined4 *)FUN_005df0f5(0x18);

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

    *puVar1 = *param_1;

    puVar1[1] = param_1[1];

    puVar1[2] = 0;

    puVar1[4] = *param_2;

    puVar1[5] = param_2[1];

    FUN_00694410(puVar1);

    return 1;

  }

  FUN_00694410(0);

  return 1;

}





// --- FUN_0054b630 at 0x0054B630 (size: 82) ---


undefined4 * __thiscall FUN_0054b630(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007cb588;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_007cb584;

  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_0054b690 at 0x0054B690 (size: 37) ---


undefined4 * __fastcall FUN_0054b690(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = &PTR_FUN_007cb588;

  FUN_0054b4b0(0x40);

  return param_1;

}





// --- FUN_0054b6c0 at 0x0054B6C0 (size: 69) ---


void __fastcall FUN_0054b6c0(int param_1)



{

  *(undefined ***)(param_1 + 8) = &PTR_FUN_007cb588;

  FUN_0041a390();

  *(undefined ***)(param_1 + 0xc) = &PTR_FUN_007cb584;

  if (*(void **)(param_1 + 0x6c) != (void *)(param_1 + 0x10)) {

    operator_delete__(*(void **)(param_1 + 0x6c));

  }

  *(undefined4 *)(param_1 + 0x6c) = 0;

  *(undefined4 *)(param_1 + 0x70) = 0;

  *(undefined4 *)(param_1 + 0x74) = 0;

  *(undefined4 *)(param_1 + 0x78) = 0;

  FUN_004c65a0();

  return;

}





// --- FUN_0054b710 at 0x0054B710 (size: 331) ---


undefined4 __thiscall FUN_0054b710(int *param_1,int param_2)



{

  undefined4 uVar1;

  undefined4 uVar2;

  char cVar3;

  int *piVar4;

  int iVar5;

  undefined8 uVar6;

  int *local_18;

  uint local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined8 local_8;

  

  InterlockedIncrement((LONG *)(param_2 + 4));

  piVar4 = (int *)FUN_005df0f5(8);

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

    piVar4 = (int *)0x0;

  }

  else {

    *piVar4 = param_2;

    piVar4[1] = 0;

  }

  if (param_1[1] == 0) {

    *param_1 = (int)piVar4;

    param_1[1] = (int)piVar4;

  }

  else {

    *(int **)(param_1[1] + 4) = piVar4;

    param_1[1] = *(int *)(param_1[1] + 4);

  }

  FUN_0054a070();

  local_14 = 0;

  if (*(int *)(param_2 + 0x104) != 0) {

    local_18 = (int *)(param_2 + 0x90);

    do {

      uVar1 = **(undefined4 **)(*local_18 + 0x10);

      uVar2 = (*(undefined4 **)(*local_18 + 0x10))[1];

      local_10 = uVar1;

      local_c = uVar2;

      cVar3 = FUN_005ab3b0(uVar1,uVar2);

      if (cVar3 != '\0') {

        uVar6 = FUN_005ab3e0(uVar1,uVar2);

        local_8 = uVar6;

        iVar5 = __aullrem(uVar6,param_1[0x1d],0);

        for (piVar4 = *(int **)(param_1[0x1b] + iVar5 * 4); piVar4 != (int *)0x0;

            piVar4 = (int *)piVar4[2]) {

          if ((*piVar4 == (int)uVar6) && (piVar4[1] == (int)((ulonglong)uVar6 >> 0x20))) {

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

              cVar3 = FUN_005ab4b0(uVar1,uVar2,piVar4[4],piVar4[5]);

              if (cVar3 == '\0') goto LAB_0054b82a;

            }

            break;

          }

        }

        FUN_0054b5a0(&local_8,&local_10);

      }

LAB_0054b82a:

      local_14 = local_14 + 1;

      local_18 = local_18 + 1;

    } while (local_14 < *(uint *)(param_2 + 0x104));

  }

  return 1;

}





// --- FUN_0054b860 at 0x0054B860 (size: 124) ---


void FUN_0054b860(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  char cVar3;

  void *pvVar4;

  undefined1 local_c [8];

  int local_4;

  

  iVar2 = param_2;

  iVar1 = param_1;

  cVar3 = FUN_005ab3b0(param_1,param_2);

  if (cVar3 != '\0') {

    _param_1 = FUN_005ab3e0(iVar1,iVar2);

    FUN_0054b460(local_c,&param_1);

    if (((local_4 != 0) && (iVar1 == *(int *)(local_4 + 0x10))) &&

       (iVar2 == *(int *)(local_4 + 0x14))) {

      pvVar4 = (void *)FUN_0054b540(&param_1);

      if (pvVar4 != (void *)0x0) {

        operator_delete(pvVar4);

      }

    }

  }

  return;

}





// --- FUN_0054b8e0 at 0x0054B8E0 (size: 223) ---


undefined4 __thiscall FUN_0054b8e0(int *param_1,uint param_2,int param_3)



{

  undefined4 *puVar1;

  void *pvVar2;

  uint uVar3;

  LONG LVar4;

  int iVar5;

  uint uVar6;

  int *piVar7;

  int *piVar8;

  

  piVar7 = (int *)*param_1;

  do {

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

      return 1;

    }

    puVar1 = (undefined4 *)*piVar7;

    if (param_3 == 0) {

      uVar6 = puVar1[0x45];

      if (uVar6 == param_2) {

        return 1;

      }

      uVar3 = uVar6 - param_2;

      iVar5 = 1;

      if (uVar6 < param_2) {

        uVar3 = param_2 - uVar6;

        iVar5 = -1;

      }

      if (0x7fffffff < uVar3) {

        iVar5 = -iVar5;

      }

      if (-1 < iVar5) {

        return 1;

      }

    }

    pvVar2 = (void *)*param_1;

    piVar7 = (int *)piVar7[1];

    if (pvVar2 != (void *)0x0) {

      iVar5 = *(int *)((int)pvVar2 + 4);

      *param_1 = iVar5;

      if (iVar5 == 0) {

        param_1[1] = 0;

      }

      operator_delete(pvVar2);

    }

    uVar6 = 0;

    if (puVar1[0x41] != 0) {

      piVar8 = puVar1 + 0x24;

      do {

        FUN_0054b860(**(undefined4 **)(*piVar8 + 0x10),(*(undefined4 **)(*piVar8 + 0x10))[1]);

        uVar6 = uVar6 + 1;

        piVar8 = piVar8 + 1;

      } while (uVar6 < (uint)puVar1[0x41]);

    }

    LVar4 = InterlockedDecrement(puVar1 + 1);

    if (LVar4 == 0) {

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

    }

  } while( true );

}





// --- FUN_0054b9c0 at 0x0054B9C0 (size: 65) ---


void __thiscall

FUN_0054b9c0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  undefined4 uVar1;

  

  param_1[4] = param_2;

  param_1[2] = 0;

  param_1[5] = param_3;

  param_1[6] = 0;

  *param_1 = &PTR_LAB_007cb50c;

  param_1[8] = param_4;

  param_1[9] = param_5;

  uVar1 = DAT_008379ac;

  param_1[10] = DAT_008379a8;

  param_1[0xb] = uVar1;

  return;

}





// --- FUN_0054ba10 at 0x0054BA10 (size: 34) ---


void __thiscall FUN_0054ba10(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

  *(undefined4 *)(param_1 + 0x20) = param_2;

  *(undefined4 *)(param_1 + 0x24) = param_3;

  uVar1 = DAT_008379ac;

  *(undefined4 *)(param_1 + 0x28) = DAT_008379a8;

  *(undefined4 *)(param_1 + 0x2c) = uVar1;

  return;

}





// --- FUN_0054ba40 at 0x0054BA40 (size: 31) ---


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



undefined4 __fastcall FUN_0054ba40(int param_1)



{

  if (_DAT_007cb5b8 < _DAT_008379a8 - *(double *)(param_1 + 0x28)) {

    return 1;

  }

  return 0;

}





// --- FUN_0054ba90 at 0x0054BA90 (size: 27) ---


void FUN_0054ba90(void)



{

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

    (**(code **)*DAT_00846fd4)(1);

  }

  DAT_00846fd4 = (undefined4 *)0x0;

  return;

}





// --- FUN_0054bad0 at 0x0054BAD0 (size: 18) ---


undefined4 FUN_0054bad0(void)



{

  undefined4 uVar1;

  

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

                    /* WARNING: Could not recover jumptable at 0x0054badc. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    uVar1 = (**(code **)(*DAT_00846fd4 + 4))();

    return uVar1;

  }

  return 0;

}





// --- FUN_0054baf0 at 0x0054BAF0 (size: 18) ---


undefined4 FUN_0054baf0(void)



{

  undefined4 uVar1;

  

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

                    /* WARNING: Could not recover jumptable at 0x0054bafe. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    uVar1 = (**(code **)(*DAT_00846fd4 + 8))();

    return uVar1;

  }

  return 0;

}





// --- FUN_0054bb30 at 0x0054BB30 (size: 23) ---


undefined4 FUN_0054bb30(undefined4 param_1)



{

  undefined4 uVar1;

  

  uVar1 = 0;

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

    uVar1 = (**(code **)(*DAT_00846fd4 + 0xc))(param_1);

  }

  return uVar1;

}





// --- FUN_0054bb50 at 0x0054BB50 (size: 18) ---


undefined4 FUN_0054bb50(void)



{

  undefined4 uVar1;

  

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

    return 0;

  }

                    /* WARNING: Could not recover jumptable at 0x0054bb5f. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  uVar1 = (**(code **)(*DAT_00846fd4 + 0x10))();

  return uVar1;

}





// --- FUN_0054bb70 at 0x0054BB70 (size: 18) ---


undefined4 FUN_0054bb70(void)



{

  undefined4 uVar1;

  

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

    return 0;

  }

                    /* WARNING: Could not recover jumptable at 0x0054bb7f. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  uVar1 = (**(code **)(*DAT_00846fd4 + 0x14))();

  return uVar1;

}





// --- FUN_0054bbb0 at 0x0054BBB0 (size: 18) ---


undefined4 FUN_0054bbb0(void)



{

  undefined4 uVar1;

  

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

    return 0;

  }

                    /* WARNING: Could not recover jumptable at 0x0054bbbf. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  uVar1 = (**(code **)(*DAT_00846fd4 + 0x18))();

  return uVar1;

}





// --- FUN_0054bbf0 at 0x0054BBF0 (size: 24) ---


undefined4 FUN_0054bbf0(undefined4 param_1)



{

  undefined4 uVar1;

  

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

    return 0;

  }

  uVar1 = (**(code **)(*DAT_00846fd4 + 0x1c))(param_1);

  return uVar1;

}





// --- FUN_0054bc30 at 0x0054BC30 (size: 315) ---


void FUN_0054bc30(undefined4 param_1)



{

  switch(param_1) {

  case 1:

    DAT_0081ffa0 = 0;

    DAT_0081ffa5 = 0;

    DAT_0081ffa6 = 0;

    DAT_0081ffa8 = 4;

    DAT_0081ffb0 = 0;

    DAT_0081ffb4 = 3;

    DAT_0081ffa4 = 0;

    DAT_0081ffac = 4;

    return;

  case 2:

    DAT_0081ffa0 = 0;

    DAT_0081ffa4 = 0;

    DAT_0081ffa5 = 0;

    DAT_0081ffa6 = 0;

    DAT_0081ffa8 = 3;

    DAT_0081ffac = 3;

    DAT_0081ffb0 = 1;

    DAT_0081ffb4 = 5;

    return;

  case 3:

    DAT_0081ffa0 = 0;

    DAT_0081ffa4 = 0;

    DAT_0081ffa5 = 0;

    DAT_0081ffa6 = 0;

    DAT_0081ffa8 = 2;

    DAT_0081ffac = 2;

    DAT_0081ffb0 = 1;

    DAT_0081ffb4 = 8;

    return;

  case 4:

    DAT_0081ffa0 = 1;

    DAT_0081ffa4 = 0;

    DAT_0081ffa5 = 1;

    DAT_0081ffa6 = 1;

    DAT_0081ffa8 = 2;

    DAT_0081ffb0 = 2;

    DAT_0081ffb4 = 0xb;

    DAT_0081ffac = 1;

    return;

  case 5:

    DAT_0081ffa0 = 1;

    DAT_0081ffa5 = 1;

    DAT_0081ffa6 = 1;

    DAT_0081ffa8 = 0;

    DAT_0081ffb0 = 2;

    DAT_0081ffb4 = 0xf;

    DAT_0081ffa4 = 0;

    DAT_0081ffac = 1;

  }

  return;

}





// --- FUN_0054bd80 at 0x0054BD80 (size: 152) ---


uint FUN_0054bd80(void)



{

  uint uVar1;

  int iVar2;

  bool bVar3;

  

  uVar1 = 1;

  iVar2 = 0;

  do {

    switch(iVar2) {

    case 0:

      if (((DAT_0081ffa0 == 0) && (DAT_0081ffa5 == '\0')) &&

         ((DAT_0081ffa6 == '\0' &&

          (((DAT_0081ffa8 == 4 && (DAT_0081ffac == 4)) && (DAT_0081ffb0 == 0)))))) {

        bVar3 = DAT_0081ffb4 == 3;

LAB_0054be08:

        if (bVar3) {

          return uVar1;

        }

      }

      break;

    case 1:

      if ((((DAT_0081ffa0 == 0) && (DAT_0081ffa5 == '\0')) && (DAT_0081ffa6 == '\0')) &&

         (((DAT_0081ffa8 == 3 && (DAT_0081ffac == 3)) && (DAT_0081ffb0 == 1)))) {

        bVar3 = DAT_0081ffb4 == 5;

        goto LAB_0054be08;

      }

      break;

    case 2:

    case 3:

    case 4:

      break;

    default:

      goto switchD_0054bdae_default;

    }

    uVar1 = uVar1 + 1;

    iVar2 = iVar2 + 1;

  } while (uVar1 < 6);

  uVar1 = 0;

switchD_0054bdae_default:

  return uVar1;

}





// --- FUN_0054be30 at 0x0054BE30 (size: 32) ---


void FUN_0054be30(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  (**(code **)(*DAT_0086734c + 0x18))(param_1,param_2,param_3,param_4);

  return;

}





// --- FUN_0054be50 at 0x0054BE50 (size: 133) ---


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



void FUN_0054be50(float param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)fpatan((float10)_DAT_007938c0,(float10)param_1);

  fVar1 = fVar1 + fVar1;

  if (_DAT_007cb7a8 <= param_1) {

    DAT_0081fc94 = 0.1;

  }

  else {

    DAT_0081fc94 = param_1 * _DAT_007c97cc;

  }

  if (fVar1 < (float10)_DAT_00795720) {

    (**(code **)(*DAT_0086734c + 0x1c))((float)_DAT_00795720);

    return;

  }

  if ((float10)_DAT_007beea0 < fVar1) {

    fVar1 = (float10)_DAT_007beea0;

  }

  (**(code **)(*DAT_0086734c + 0x1c))((float)fVar1);

  return;

}





// --- FUN_0054bee0 at 0x0054BEE0 (size: 69) ---


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



undefined4 FUN_0054bee0(float param_1)



{

  if ((param_1 < DAT_00796344 == (param_1 == DAT_00796344)) && (param_1 < (float)_DAT_007beea0)) {

    DAT_0081fc94 = 0x3dcccccd;

    (**(code **)(*DAT_0086734c + 0x1c))(param_1);

    return 1;

  }

  return 0;

}





// --- FUN_0054bf30 at 0x0054BF30 (size: 27) ---


void FUN_0054bf30(undefined4 param_1)



{

  DAT_0081fc98 = param_1;

  (**(code **)(*DAT_0086734c + 0x1c))(DAT_0081fc88);

  return;

}





// --- FUN_0054bf50 at 0x0054BF50 (size: 185) ---


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



void FUN_0054bf50(float param_1)



{

  float fVar1;

  float10 fVar2;

  

  fVar1 = (float)*(int *)(DAT_00870340 + 0x94);

  if (*(int *)(DAT_00870340 + 0x94) < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  _DAT_008672f8 = (double)fVar1;

  fVar1 = (float)*(int *)(DAT_00870340 + 0x98);

  if (*(int *)(DAT_00870340 + 0x98) < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  _DAT_008672e0 = (double)fVar1;

  DAT_0081fc88 = param_1;

  _DAT_008672d8 = (double)((float)_DAT_007938c0 / _DAT_0081fc8c);

  _DAT_008672f0 = (double)((float)_DAT_007938c0 / _DAT_0081fc8c);

  _DAT_00847058 = (_DAT_008672f8 - _DAT_007938c0) * _DAT_00799088 * _DAT_008672d8;

  _DAT_00867310 = (_DAT_008672e0 - _DAT_007938c0) * _DAT_00799088 * _DAT_008672f0;

  fVar2 = (float10)fptan((float10)param_1 * (float10)_DAT_00799088);

  _DAT_0081fc90 = (float)((float10)_DAT_00867310 / fVar2);

  return;

}





// --- FUN_0054c010 at 0x0054C010 (size: 519) ---


void FUN_0054c010(float *param_1,float *param_2,float *param_3)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  

  fVar5 = DAT_0086c1d0 * *(float *)(DAT_00867334 + 0x34) +

          DAT_0086c1d8 * *(float *)(DAT_00867334 + 0x3c) +

          DAT_0086c1d4 * *(float *)(DAT_00867334 + 0x38);

  fVar6 = DAT_0086c1d0 * *(float *)(DAT_00867334 + 0x40) +

          DAT_0086c1d8 * *(float *)(DAT_00867334 + 0x48) +

          DAT_0086c1d4 * *(float *)(DAT_00867334 + 0x44);

  fVar7 = DAT_0086c1d0 * *(float *)(DAT_00867334 + 0x4c) +

          DAT_0086c1d8 * *(float *)(DAT_00867334 + 0x54) +

          DAT_0086c1d4 * *(float *)(DAT_00867334 + 0x50);

  fVar8 = DAT_00867438 * *(float *)(DAT_00867334 + 0x34) +

          DAT_00867440 * *(float *)(DAT_00867334 + 0x3c) +

          DAT_0086743c * *(float *)(DAT_00867334 + 0x38);

  fVar9 = DAT_00867438 * *(float *)(DAT_00867334 + 0x40) +

          DAT_00867440 * *(float *)(DAT_00867334 + 0x48) +

          DAT_0086743c * *(float *)(DAT_00867334 + 0x44);

  fVar10 = DAT_00867438 * *(float *)(DAT_00867334 + 0x4c) +

           DAT_00867440 * *(float *)(DAT_00867334 + 0x54) +

           DAT_0086743c * *(float *)(DAT_00867334 + 0x50);

  fVar1 = param_1[3];

  fVar2 = param_1[3];

  fVar3 = param_1[1];

  fVar4 = param_1[2];

  *param_2 = (*param_1 - fVar5 * fVar1) + fVar8 * fVar2;

  param_2[1] = (fVar3 - fVar6 * fVar1) + fVar9 * fVar2;

  param_2[2] = (fVar4 - fVar7 * fVar1) + fVar10 * fVar2;

  fVar3 = param_1[3];

  fVar1 = param_1[1];

  fVar2 = param_1[2];

  *param_3 = (fVar3 * fVar5 + *param_1) - fVar3 * fVar8;

  param_3[1] = (fVar6 * fVar3 + fVar1) - fVar9 * fVar3;

  param_3[2] = (fVar7 * fVar3 + fVar2) - fVar10 * fVar3;

  return;

}





// --- FUN_0054c220 at 0x0054C220 (size: 307) ---


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



void FUN_0054c220(float *param_1,int param_2,int param_3)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  

  fVar2 = (float)param_3 * (float)_DAT_008672f0 - (float)_DAT_00867310;

  fVar3 = (float)param_2 * (float)_DAT_008672d8 - (float)_DAT_00847058;

  fVar1 = (DAT_0086c1d0 * fVar3 + DAT_0086c18c * _DAT_0081fc90) - DAT_00867438 * fVar2;

  fVar4 = (DAT_0086c1d4 * fVar3 + DAT_0086c190 * _DAT_0081fc90) - DAT_0086743c * fVar2;

  fVar3 = (DAT_0086c1d8 * fVar3 + DAT_0086c194 * _DAT_0081fc90) - DAT_00867440 * fVar2;

  fVar2 = _DAT_007938b0 / SQRT(fVar1 * fVar1 + fVar4 * fVar4 + fVar3 * fVar3);

  *param_1 = fVar2 * fVar1;

  param_1[1] = fVar4 * fVar2;

  param_1[2] = fVar3 * fVar2;

  return;

}





// --- FUN_0054c360 at 0x0054C360 (size: 49) ---


void FUN_0054c360(undefined4 param_1,undefined4 param_2,undefined1 param_3)



{

  DAT_00867324 = param_1;

  DAT_00867328 = param_2;

  DAT_0086734a = 1;

  DAT_00867349 = param_3;

  DAT_0086c1a0 = 0;

  DAT_0086c1b8 = 0;

  return;

}





// --- FUN_0054c3a0 at 0x0054C3A0 (size: 23) ---


void FUN_0054c3a0(void)



{

  DAT_0086734a = 0;

  DAT_00867349 = 0;

  DAT_0086c1a0 = 0;

  DAT_0086c1b8 = 0;

  return;

}





// --- FUN_0054c3c0 at 0x0054C3C0 (size: 10) ---


void FUN_0054c3c0(undefined4 param_1)



{

  DAT_0086737c = param_1;

  return;

}





// --- FUN_0054c3d0 at 0x0054C3D0 (size: 10) ---


void FUN_0054c3d0(undefined4 param_1)



{

  DAT_00867364 = param_1;

  return;

}





// --- FUN_0054c3e0 at 0x0054C3E0 (size: 10) ---


void FUN_0054c3e0(undefined4 param_1)



{

  DAT_00867368 = param_1;

  return;

}





// --- FUN_0054c3f0 at 0x0054C3F0 (size: 10) ---


void FUN_0054c3f0(undefined4 param_1)



{

  DAT_0086736c = param_1;

  return;

}





// --- FUN_0054c400 at 0x0054C400 (size: 10) ---


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



void FUN_0054c400(undefined4 param_1)



{

  _DAT_00867370 = param_1;

  return;

}





// --- FUN_0054c410 at 0x0054C410 (size: 10) ---


void FUN_0054c410(undefined4 param_1)



{

  DAT_0081fcb8 = param_1;

  return;

}





// --- FUN_0054c420 at 0x0054C420 (size: 10) ---


void FUN_0054c420(undefined4 param_1)



{

  DAT_0081fcbc = param_1;

  return;

}





// --- FUN_0054c430 at 0x0054C430 (size: 10) ---


void FUN_0054c430(undefined4 param_1)



{

  DAT_0081fcc0 = param_1;

  return;

}





// --- FUN_0054c440 at 0x0054C440 (size: 10) ---


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



void FUN_0054c440(undefined4 param_1)



{

  _DAT_0081fcc4 = param_1;

  return;

}





// --- FUN_0054c450 at 0x0054C450 (size: 240) ---


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



float10 FUN_0054c450(float param_1,float param_2,float *param_3)



{

  float fVar1;

  int iVar2;

  float10 fVar3;

  float local_c;

  float local_8;

  undefined4 local_4;

  

  if (param_3[2] <= DAT_007cb6a8) {

    if (param_3[2] < -DAT_007cb6a8) {

      fVar3 = -(((float10)param_1 * (float10)*param_3 + (float10)param_2 * (float10)param_3[1] +

                (float10)param_3[3]) / (float10)param_3[2]);

      if (fVar3 < (float10)DAT_00796344 == (fVar3 == (float10)DAT_00796344)) {

        if (fVar3 < (float10)_DAT_007cb6f0) {

          return fVar3;

        }

        return (float10)_DAT_007cb6f4;

      }

    }

    else {

      local_c = param_1;

      local_8 = param_2;

      local_4 = 0;

      iVar2 = FUN_00444880(&local_c,DAT_007cb6a8);

      if (iVar2 != 1) goto LAB_0054c536;

    }

  }

  else {

    fVar1 = -((param_1 * *param_3 + param_2 * param_3[1] + param_3[3]) / param_3[2]);

    if (fVar1 < _DAT_007cb6f0) {

      if (fVar1 < DAT_00796344 == (fVar1 == DAT_00796344)) {

        return -(float10)fVar1;

      }

LAB_0054c536:

      return (float10)_DAT_007cb6f4;

    }

  }

  return (float10)_DAT_0086c130;

}





// --- FUN_0054c540 at 0x0054C540 (size: 122) ---


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



undefined4 FUN_0054c540(float param_1,float param_2,float param_3)



{

  if (param_1 == _DAT_0086c130) {

    return 0;

  }

  if (param_1 != _DAT_007cb6f4) {

    if (param_1 <= DAT_00796344) {

      param_1 = -param_1;

      if (param_1 < param_2 == (param_1 == param_2)) {

        if (param_3 <= param_1) {

          return 0;

        }

        return 1;

      }

    }

    else if (param_1 < param_3) {

      if (param_1 <= param_2) {

        return 0;

      }

      return 1;

    }

  }

  return 2;

}





// --- FUN_0054c5c0 at 0x0054C5C0 (size: 1009) ---


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



void FUN_0054c5c0(void)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  float fVar11;

  float fVar12;

  float fVar13;

  float fVar14;

  float fVar15;

  float fVar16;

  float fVar17;

  float fVar18;

  float fVar19;

  uint uVar20;

  int iVar21;

  float *pfVar22;

  float *pfVar23;

  uint uVar24;

  int iVar25;

  uint local_10;

  

  iVar21 = DAT_00867334;

  uVar20 = DAT_00847060;

  uVar24 = 0;

  if (3 < (int)DAT_00847060) {

    local_10 = 3;

    pfVar22 = (float *)(DAT_00847050 + 0xc);

    pfVar23 = (float *)&DAT_008700a4;

    do {

      fVar1 = *(float *)(iVar21 + 100);

      fVar2 = *(float *)(iVar21 + 0x68);

      fVar3 = *(float *)(iVar21 + 0x6c);

      fVar4 = pfVar22[1];

      fVar5 = *(float *)(iVar21 + 0x48);

      fVar6 = *pfVar22;

      fVar7 = *(float *)(iVar21 + 0x44);

      fVar8 = pfVar22[-1];

      fVar9 = *(float *)(iVar21 + 0x40);

      fVar10 = pfVar22[-1];

      fVar11 = *(float *)(iVar21 + 0x4c);

      fVar12 = *(float *)(iVar21 + 0x54);

      fVar13 = pfVar22[1];

      fVar14 = *(float *)(iVar21 + 0x50);

      fVar15 = *pfVar22;

      fVar16 = *pfVar22;

      fVar17 = pfVar22[-1];

      fVar18 = pfVar22[1];

      fVar19 = pfVar22[2];

      pfVar23[-7] = pfVar22[1] * *(float *)(iVar21 + 0x3c) +

                    pfVar22[-1] * *(float *)(iVar21 + 0x34) + *pfVar22 * *(float *)(iVar21 + 0x38);

      pfVar23[-6] = fVar8 * fVar9 + fVar6 * fVar7 + fVar4 * fVar5;

      pfVar23[-4] = fVar3 * fVar18 + fVar1 * fVar17 + fVar2 * fVar16 + fVar19;

      pfVar23[-5] = fVar14 * fVar15 + fVar12 * fVar13 + fVar10 * fVar11;

      fVar1 = *(float *)(iVar21 + 100);

      fVar2 = *(float *)(iVar21 + 0x68);

      fVar3 = *(float *)(iVar21 + 0x6c);

      fVar4 = pfVar22[7];

      fVar5 = *(float *)(iVar21 + 0x48);

      fVar6 = pfVar22[6];

      fVar7 = *(float *)(iVar21 + 0x44);

      fVar8 = pfVar22[5];

      fVar9 = *(float *)(iVar21 + 0x40);

      fVar10 = pfVar22[5];

      fVar11 = *(float *)(iVar21 + 0x4c);

      fVar12 = *(float *)(iVar21 + 0x54);

      fVar13 = pfVar22[7];

      fVar14 = *(float *)(iVar21 + 0x50);

      fVar15 = pfVar22[6];

      fVar16 = pfVar22[6];

      fVar17 = pfVar22[5];

      fVar18 = pfVar22[7];

      fVar19 = pfVar22[8];

      pfVar23[-3] = pfVar22[7] * *(float *)(iVar21 + 0x3c) +

                    pfVar22[5] * *(float *)(iVar21 + 0x34) + pfVar22[6] * *(float *)(iVar21 + 0x38);

      pfVar23[-2] = fVar8 * fVar9 + fVar6 * fVar7 + fVar4 * fVar5;

      *pfVar23 = fVar3 * fVar18 + fVar1 * fVar17 + fVar2 * fVar16 + fVar19;

      pfVar23[-1] = fVar14 * fVar15 + fVar12 * fVar13 + fVar10 * fVar11;

      fVar1 = *(float *)(iVar21 + 100);

      fVar2 = *(float *)(iVar21 + 0x68);

      fVar3 = *(float *)(iVar21 + 0x6c);

      fVar4 = pfVar22[0xd];

      fVar5 = *(float *)(iVar21 + 0x48);

      fVar6 = pfVar22[0xc];

      fVar7 = *(float *)(iVar21 + 0x44);

      fVar8 = pfVar22[0xb];

      fVar9 = *(float *)(iVar21 + 0x40);

      fVar10 = pfVar22[0xb];

      fVar11 = *(float *)(iVar21 + 0x4c);

      fVar12 = *(float *)(iVar21 + 0x54);

      fVar13 = pfVar22[0xd];

      fVar14 = *(float *)(iVar21 + 0x50);

      fVar15 = pfVar22[0xc];

      fVar16 = pfVar22[0xc];

      fVar17 = pfVar22[0xb];

      fVar18 = pfVar22[0xd];

      fVar19 = pfVar22[0xe];

      pfVar23[1] = pfVar22[0xd] * *(float *)(iVar21 + 0x3c) +

                   pfVar22[0xb] * *(float *)(iVar21 + 0x34) +

                   pfVar22[0xc] * *(float *)(iVar21 + 0x38);

      pfVar23[2] = fVar8 * fVar9 + fVar6 * fVar7 + fVar4 * fVar5;

      pfVar23[4] = fVar3 * fVar18 + fVar1 * fVar17 + fVar2 * fVar16 + fVar19;

      pfVar23[3] = fVar14 * fVar15 + fVar12 * fVar13 + fVar10 * fVar11;

      fVar1 = *(float *)(iVar21 + 100);

      fVar2 = *(float *)(iVar21 + 0x68);

      fVar3 = *(float *)(iVar21 + 0x6c);

      uVar24 = uVar24 + 4;

      fVar4 = pfVar22[0x13];

      fVar5 = *(float *)(iVar21 + 0x48);

      fVar6 = pfVar22[0x12];

      fVar7 = *(float *)(iVar21 + 0x44);

      fVar8 = pfVar22[0x11];

      fVar9 = *(float *)(iVar21 + 0x40);

      fVar10 = pfVar22[0x11];

      fVar11 = *(float *)(iVar21 + 0x4c);

      fVar12 = *(float *)(iVar21 + 0x54);

      fVar13 = pfVar22[0x13];

      fVar14 = *(float *)(iVar21 + 0x50);

      fVar15 = pfVar22[0x12];

      fVar16 = pfVar22[0x12];

      fVar17 = pfVar22[0x11];

      fVar18 = pfVar22[0x13];

      fVar19 = pfVar22[0x14];

      pfVar23[5] = pfVar22[0x13] * *(float *)(iVar21 + 0x3c) +

                   pfVar22[0x11] * *(float *)(iVar21 + 0x34) +

                   pfVar22[0x12] * *(float *)(iVar21 + 0x38);

      pfVar23[6] = fVar8 * fVar9 + fVar6 * fVar7 + fVar4 * fVar5;

      pfVar23[8] = fVar3 * fVar18 + fVar1 * fVar17 + fVar2 * fVar16 + fVar19;

      pfVar23[7] = fVar14 * fVar15 + fVar12 * fVar13 + fVar10 * fVar11;

      local_10 = local_10 + 4;

      pfVar22 = pfVar22 + 0x18;

      pfVar23 = pfVar23 + 0x10;

    } while (local_10 < uVar20);

  }

  if (uVar24 < uVar20) {

    iVar25 = uVar20 - uVar24;

    pfVar22 = (float *)(DAT_00847050 + 0xc + uVar24 * 0x18);

    pfVar23 = (float *)(&DAT_00870088 + uVar24 * 4);

    do {

      fVar1 = *(float *)(iVar21 + 100);

      fVar2 = *(float *)(iVar21 + 0x68);

      fVar3 = *(float *)(iVar21 + 0x6c);

      iVar25 = iVar25 + -1;

      fVar4 = *(float *)(iVar21 + 0x40);

      fVar5 = pfVar22[-1];

      fVar6 = pfVar22[1];

      fVar7 = *(float *)(iVar21 + 0x48);

      fVar8 = *(float *)(iVar21 + 0x44);

      fVar9 = *pfVar22;

      fVar10 = *(float *)(iVar21 + 0x50);

      fVar11 = *pfVar22;

      fVar12 = pfVar22[-1];

      fVar13 = *(float *)(iVar21 + 0x4c);

      fVar14 = *(float *)(iVar21 + 0x54);

      fVar15 = pfVar22[1];

      fVar16 = pfVar22[1];

      fVar17 = pfVar22[-1];

      fVar18 = *pfVar22;

      fVar19 = pfVar22[2];

      *pfVar23 = *pfVar22 * *(float *)(iVar21 + 0x38) +

                 *(float *)(iVar21 + 0x34) * pfVar22[-1] + pfVar22[1] * *(float *)(iVar21 + 0x3c);

      pfVar23[1] = fVar8 * fVar9 + fVar6 * fVar7 + fVar4 * fVar5;

      pfVar23[3] = fVar2 * fVar18 + fVar1 * fVar17 + fVar3 * fVar16 + fVar19;

      pfVar23[2] = fVar14 * fVar15 + fVar12 * fVar13 + fVar10 * fVar11;

      pfVar22 = pfVar22 + 6;

      pfVar23 = pfVar23 + 4;

    } while (iVar25 != 0);

  }

  fVar2 = _DAT_0086742c * *(float *)(iVar21 + 0x44);

  fVar4 = _DAT_00867430 * *(float *)(iVar21 + 0x48);

  fVar3 = _DAT_00867428 * *(float *)(iVar21 + 0x40);

  fVar5 = _DAT_0086742c * *(float *)(iVar21 + 0x50);

  fVar7 = _DAT_00867430 * *(float *)(iVar21 + 0x54);

  fVar6 = _DAT_00867428 * *(float *)(iVar21 + 0x4c);

  fVar1 = _DAT_00867428 * *(float *)(iVar21 + 100) +

          *(float *)(iVar21 + 0x6c) * _DAT_00867430 + *(float *)(iVar21 + 0x68) * _DAT_0086742c +

          _DAT_00867434;

  *(float *)(iVar21 + 0xc) =

       _DAT_00867428 * *(float *)(iVar21 + 0x34) +

       _DAT_00867430 * *(float *)(iVar21 + 0x3c) + _DAT_0086742c * *(float *)(iVar21 + 0x38);

  *(float *)(iVar21 + 0x10) = fVar3 + fVar4 + fVar2;

  *(float *)(iVar21 + 0x18) = fVar1;

  *(float *)(iVar21 + 0x14) = fVar6 + fVar7 + fVar5;

  return;

}





// --- FUN_0054c9c0 at 0x0054C9C0 (size: 22) ---


void FUN_0054c9c0(undefined4 param_1,undefined4 param_2)



{

  (**(code **)(*DAT_0086734c + 0x30))(param_1,param_2);

  return;

}





// --- FUN_0054c9e0 at 0x0054C9E0 (size: 11) ---


void FUN_0054c9e0(void)



{

                    /* WARNING: Could not recover jumptable at 0x0054c9e8. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*DAT_0086734c + 0x34))();

  return;

}





// --- FUN_0054c9f0 at 0x0054C9F0 (size: 11) ---


void FUN_0054c9f0(void)



{

                    /* WARNING: Could not recover jumptable at 0x0054c9f8. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*DAT_0086734c + 0x38))();

  return;

}





// --- FUN_0054ca00 at 0x0054CA00 (size: 11) ---


void FUN_0054ca00(void)



{

                    /* WARNING: Could not recover jumptable at 0x0054ca08. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*DAT_0086734c + 0x3c))();

  return;

}





// --- FUN_0054ca10 at 0x0054CA10 (size: 420) ---


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



void FUN_0054ca10(void)



{

  DAT_00867280 = DAT_00847070;

  _DAT_00867284 = _DAT_00847074;

  DAT_00867288 = DAT_00847078;

  DAT_0086728c = DAT_0084707c;

  _DAT_00867290 = DAT_00847080;

  _DAT_00867294 = DAT_00847084;

  _DAT_00867298 = DAT_00847088;

  _DAT_0086729c = DAT_0084708c;

  _DAT_008672a0 = DAT_00847090;

  _DAT_008672a4 = DAT_00847094;

  _DAT_008672a8 = DAT_00847098;

  _DAT_008672ac = DAT_0084709c;

  _DAT_008672b0 = DAT_008470a0;

  _DAT_008672b4 = DAT_008470a4;

  _DAT_008672b8 = DAT_008470a8;

  _DAT_008672bc = DAT_008470ac;

  _DAT_008672c0 = DAT_008470b0;

  _DAT_008672c4 = DAT_008470b4;

  _DAT_008672c8 = DAT_008470b8;

  _DAT_008672cc = DAT_008470bc;

  _DAT_00867278 = _DAT_00847068;

  DAT_0086727c = DAT_0084706c;

  _DAT_008672d0 = DAT_008470c0;

  _DAT_00847068 = _DAT_00847068 & 0xffffff00;

  DAT_0084706c = 0xffffffff;

  DAT_00847070 = 0xffffffff;

  _DAT_00847074 = _DAT_00847074 & 0xffffff00;

  DAT_00847078 = 0xffffffff;

  DAT_0084707c = 0xffffffff;

  DAT_00847080 = DAT_00847080 & 0xffffff00;

  DAT_00847084 = 0xffffffff;

  DAT_00847088 = 0xffffffff;

  DAT_0084708c = DAT_0084708c & 0xffffff00;

  DAT_00847090 = 0xffffffff;

  DAT_00847094 = 0xffffffff;

  DAT_00847098 = DAT_00847098 & 0xffffff00;

  DAT_0084709c = 0xffffffff;

  DAT_008470a0 = 0xffffffff;

  DAT_008470a4 = DAT_008470a4 & 0xffffff00;

  DAT_008470a8 = 0xffffffff;

  DAT_008470ac = 0xffffffff;

  DAT_008470b0 = DAT_008470b0 & 0xffffff00;

  DAT_008470b4 = 0xffffffff;

  DAT_008470b8 = 0xffffffff;

  _DAT_008672d4 = DAT_008470c4;

  DAT_008470bc = DAT_008470bc & 0xffffff00;

  DAT_008470c0 = 0xffffffff;

  DAT_008470c4 = 0xffffffff;

  return;

}





// --- FUN_0054cbc0 at 0x0054CBC0 (size: 196) ---


void FUN_0054cbc0(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  

  iVar2 = 0;

  piVar1 = &DAT_00867280;

  while ((piVar1[-1] != param_2 || (*piVar1 != param_1))) {

    piVar1 = piVar1 + 3;

    iVar2 = iVar2 + 1;

    if (0x8672df < (int)piVar1) {

      iVar2 = 0;

      piVar1 = &DAT_00847070;

      do {

        if (*piVar1 == -1) {

          (&DAT_0084706c)[iVar2 * 3] = param_2;

          (&DAT_00847070)[iVar2 * 3] = param_1;

          (&DAT_00847068)[iVar2 * 0xc] = 0;

          return;

        }

        piVar1 = piVar1 + 3;

        iVar2 = iVar2 + 1;

      } while ((int)piVar1 < 0x8470d0);

      return;

    }

  }

  if ((&DAT_0084706c)[iVar2 * 3] != -1) {

    iVar3 = 0;

    piVar1 = &DAT_0084706c;

    do {

      if (*piVar1 == -1) {

        (&DAT_0084706c)[iVar3 * 3] = (&DAT_0084706c)[iVar2 * 3];

        (&DAT_00847068)[iVar3 * 0xc] = 0;

        (&DAT_00847070)[iVar3 * 3] = (&DAT_00847070)[iVar2 * 3];

        break;

      }

      piVar1 = piVar1 + 3;

      iVar3 = iVar3 + 1;

    } while ((int)piVar1 < 0x8470cc);

  }

  (&DAT_0084706c)[iVar2 * 3] = param_2;

  (&DAT_00847070)[iVar2 * 3] = param_1;

  (&DAT_00847068)[iVar2 * 0xc] = 1;

  return;

}





// --- FUN_0054cc90 at 0x0054CC90 (size: 230) ---


void FUN_0054cc90(void)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  undefined4 uVar4;

  

  iVar2 = 0;

  piVar3 = &DAT_0084706c;

  do {

    iVar1 = *piVar3;

    if (iVar1 == -1) {

      uVar4 = 0;

LAB_0054cd57:

      FUN_005a4230(iVar2,uVar4);

    }

    else {

      if ((DAT_0081ffe8 != 0) && ((char)piVar3[-1] != '\0')) {

        uVar4 = 1;

        goto LAB_0054cd57;

      }

      if ((DAT_0081ffe4 != 0) && (iVar1 == 2)) {

        (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xcc))

                  (*(int **)(DAT_00870340 + 0x468),iVar2,(&DAT_0086c0d4)[piVar3[1]]);

        uVar4 = 1;

        goto LAB_0054cd57;

      }

      if ((DAT_0081ffe0 != 0) && (iVar1 == 1)) {

        (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xcc))

                  (*(int **)(DAT_00870340 + 0x468),iVar2,(&DAT_0086b748)[piVar3[1]]);

        uVar4 = 1;

        goto LAB_0054cd57;

      }

      if ((DAT_0081ffdc != 0) && (iVar1 == 0)) {

        (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xcc))

                  (*(int **)(DAT_00870340 + 0x468),iVar2,&DAT_008682d8);

        uVar4 = 1;

        goto LAB_0054cd57;

      }

    }

    piVar3 = piVar3 + 3;

    iVar2 = iVar2 + 1;

    if (0x8470cb < (int)piVar3) {

      return;

    }

  } while( true );

}





// --- FUN_0054cd80 at 0x0054CD80 (size: 58) ---


void FUN_0054cd80(void)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  

  FUN_0054ca10();

  iVar1 = DAT_0086b838;

  iVar3 = 0;

  if (0 < DAT_0086b838) {

    puVar4 = &DAT_00867248;

    for (iVar2 = DAT_0086b838; iVar2 != 0; iVar2 = iVar2 + -1) {

      *puVar4 = 1;

      puVar4 = puVar4 + 1;

    }

    do {

      FUN_0054cbc0(iVar3,2);

      iVar3 = iVar3 + 1;

    } while (iVar3 < iVar1);

  }

  FUN_0054cc90();

  return;

}





// --- FUN_0054cdc0 at 0x0054CDC0 (size: 97) ---


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



undefined4 FUN_0054cdc0(int *param_1)



{

  if ((*param_1 == 0) &&

     (DAT_007cb6a8 <=

      (((float)param_1[0x11] - _DAT_0086c124) * ((float)param_1[0x11] - _DAT_0086c124) +

      ((float)param_1[0x12] - _DAT_0086c128) * ((float)param_1[0x12] - _DAT_0086c128) +

      ((float)param_1[0x13] - _DAT_0086c12c) * ((float)param_1[0x13] - _DAT_0086c12c)) -

      ((float)param_1[0x18] + _DAT_00867270) * ((float)param_1[0x18] + _DAT_00867270))) {

    return 1;

  }

  return 0;

}





// --- FUN_0054ce30 at 0x0054CE30 (size: 47) ---


void FUN_0054ce30(void)



{

  int iVar1;

  undefined4 *puVar2;

  

  if (0 < DAT_008683b4) {

    puVar2 = &DAT_008470d8;

    for (iVar1 = DAT_008683b4; iVar1 != 0; iVar1 = iVar1 + -1) {

      *puVar2 = 1;

      puVar2 = puVar2 + 1;

    }

  }

  if (0 < DAT_0086b838) {

    puVar2 = &DAT_00867248;

    for (iVar1 = DAT_0086b838; iVar1 != 0; iVar1 = iVar1 + -1) {

      *puVar2 = 1;

      puVar2 = puVar2 + 1;

    }

  }

  return;

}





// --- FUN_0054ce60 at 0x0054CE60 (size: 366) ---


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



char FUN_0054ce60(float *param_1)



{

  bool bVar1;

  float fVar2;

  float fVar3;

  float *pfVar4;

  int iVar5;

  float local_18;

  float local_14;

  float local_10;

  float local_c;

  float local_8;

  float local_4;

  

  local_c = DAT_0081fc84 * *param_1;

  local_8 = DAT_0081fc84 * param_1[1];

  local_10 = DAT_0081fc84 * param_1[2];

  local_4 = local_10;

  FUN_004562a0(&local_18,DAT_00867334 + 0x1c,&local_c);

  fVar3 = DAT_0081fc84 * param_1[3];

  FUN_004526c0(&local_c,&local_18);

  _DAT_0086c124 = local_c;

  _DAT_00867270 = fVar3;

  _DAT_0086c128 = local_8;

  _DAT_0086c12c = local_4;

  fVar2 = _DAT_00867428 * local_18 + local_14 * _DAT_0086742c + local_10 * _DAT_00867430 +

          _DAT_00867434;

  if (fVar2 < -fVar3) {

    return '\0';

  }

  bVar1 = fVar2 < fVar3 != (fVar2 == fVar3);

  iVar5 = 0;

  if (0 < DAT_00847060) {

    pfVar4 = (float *)(DAT_00847050 + 0xc);

    do {

      fVar2 = local_14 * *pfVar4 + local_18 * pfVar4[-1] + local_10 * pfVar4[1] + pfVar4[2];

      if (fVar2 < -fVar3) {

        return '\0';

      }

      if ((bVar1) || (fVar2 < fVar3 != (fVar2 == fVar3))) {

        bVar1 = true;

      }

      iVar5 = iVar5 + 1;

      pfVar4 = pfVar4 + 6;

    } while (iVar5 < DAT_00847060);

  }

  return !bVar1 + '\x01';

}





// --- FUN_0054cfd0 at 0x0054CFD0 (size: 225) ---


undefined4 FUN_0054cfd0(float param_1)



{

  float10 extraout_ST0;

  float10 extraout_ST1;

  

  DAT_0086731c = param_1;

  if (DAT_00796344 <= param_1) {

    DAT_0081fca4 = FUN_005df4c4();

  }

  else {

    DAT_0081fca4 = FUN_005df4c4();

  }

  DAT_0081fca8 = FUN_005df4c4();

  DAT_00867414 = (float)(extraout_ST1 * extraout_ST1);

  DAT_0086c208 = (float)(extraout_ST0 * extraout_ST0);

  return 1;

}





// --- FUN_0054d0c0 at 0x0054D0C0 (size: 79) ---


undefined4 FUN_0054d0c0(int *param_1)



{

  char cVar1;

  

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

    if (*param_1 == 1) {

      DAT_0086734c = (int *)FUN_0058bf30();

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

        cVar1 = (**(code **)(*DAT_0086734c + 4))(param_1);

        if (cVar1 != '\0') {

          return 1;

        }

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

          (**(code **)*DAT_0086734c)(1);

        }

        DAT_0086734c = (int *)0x0;

      }

    }

  }

  return 0;

}





// --- FUN_0054d110 at 0x0054D110 (size: 78) ---


undefined4 FUN_0054d110(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  

  DAT_00870340 = (int *)(**(code **)(*DAT_0086734c + 0xc))();

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

    cVar1 = (**(code **)(*DAT_00870340 + 4))(param_1,param_2,param_3);

    if (cVar1 != '\0') {

      return 1;

    }

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

      (**(code **)*DAT_00870340)(1);

    }

    DAT_00870340 = (int *)0x0;

  }

  return 0;

}





// --- FUN_0054d160 at 0x0054D160 (size: 47) ---


void FUN_0054d160(void)



{

  FUN_00446d30();

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

    (**(code **)(*DAT_00870340 + 8))();

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

      (**(code **)*DAT_00870340)(1);

    }

  }

  DAT_00870340 = (int *)0x0;

  return;

}





// --- FUN_0054d190 at 0x0054D190 (size: 104) ---


void FUN_0054d190(void)



{

  FUN_00448ea0();

  FUN_00557b50();

  FUN_00446d30();

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

    (**(code **)(*DAT_00870340 + 8))();

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

      (**(code **)*DAT_00870340)(1);

    }

  }

  DAT_00870340 = (int *)0x0;

  FUN_0044b820();

  FUN_00446ff0();

  (**(code **)(*DAT_0086734c + 8))();

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

    (**(code **)*DAT_0086734c)(1);

  }

  DAT_0086734c = (int *)0x0;

  return;

}





// --- FUN_0054d200 at 0x0054D200 (size: 146) ---


/* WARNING: Type propagation algorithm not settling */



undefined4 FUN_0054d200(undefined4 param_1,int *param_2,int *param_3)



{

  char cVar1;

  int iVar2;

  int iVar3;

  int unaff_EBX;

  int *piVar4;

  int *piVar5;

  int *unaff_retaddr;

  int aiStack_24 [9];

  

  aiStack_24[1] = param_3[1];

  iVar3 = *param_3;

  piVar4 = param_2;

  piVar5 = aiStack_24 + 2;

  for (iVar2 = 7; iVar2 != 0; iVar2 = iVar2 + -1) {

    *piVar5 = *piVar4;

    piVar4 = piVar4 + 1;

    piVar5 = piVar5 + 1;

  }

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

    piVar5 = aiStack_24 + 2;

    piVar4 = DAT_00870340;

    for (iVar3 = 7; piVar4 = piVar4 + 1, iVar3 != 0; iVar3 = iVar3 + -1) {

      *piVar5 = *piVar4;

      piVar5 = piVar5 + 1;

    }

    aiStack_24[1] = DAT_00870340[9];

    iVar3 = DAT_00870340[8];

  }

  cVar1 = (**(code **)(*DAT_00870340 + 0x38))(param_2);

  if (cVar1 == '\0') {

    cVar1 = (**(code **)(*DAT_00870340 + 0x38))(aiStack_24 + 1);

    if (cVar1 == '\0') {

      return 0;

    }

    piVar4 = aiStack_24;

    for (iVar2 = 7; iVar2 != 0; iVar2 = iVar2 + -1) {

      *unaff_retaddr = *piVar4;

      piVar4 = piVar4 + 1;

      unaff_retaddr = unaff_retaddr + 1;

    }

    *param_3 = iVar3;

    param_3[1] = unaff_EBX;

  }

  return 1;

}





// --- FUN_0054d2a0 at 0x0054D2A0 (size: 58) ---


undefined4 * FUN_0054d2a0(void)



{

  undefined4 *puVar1;

  

  if (DAT_0086734c != 0) {

                    /* WARNING: Could not recover jumptable at 0x0054d2b1. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    puVar1 = (undefined4 *)(**(code **)(*DAT_00870340 + 0x18))();

    return puVar1;

  }

  puVar1 = (undefined4 *)FUN_005df0f5(0x28);

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

    *puVar1 = &PTR_FUN_0079c26c;

    FUN_0044ca60();

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_0054d2e0 at 0x0054D2E0 (size: 24) ---


void FUN_0054d2e0(int *param_1)



{

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

    (**(code **)(*(int *)*param_1 + 0x14))();

    *param_1 = 0;

  }

  return;

}





// --- FUN_0054d310 at 0x0054D310 (size: 44) ---


undefined4 FUN_0054d310(void)



{

  char cVar1;

  

  cVar1 = (**(code **)(*(int *)(DAT_00837bac + 4) + 0x44))(0x69466948,1);

  if ((cVar1 != '\0') && (DAT_0081ffac == 0)) {

    return 0;

  }

  return 1;

}





// --- FUN_0054d340 at 0x0054D340 (size: 7) ---


float10 FUN_0054d340(void)



{

  return (float10)DAT_00838418;

}





// --- FUN_0054d350 at 0x0054D350 (size: 511) ---


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



undefined4 FUN_0054d350(int param_1)



{

  float fVar1;

  undefined4 *puVar2;

  int iVar3;

  char cVar4;

  int iVar5;

  uint uVar6;

  undefined4 local_40;

  undefined4 uStack_3c;

  float local_38;

  float fStack_34;

  float local_30;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  float local_18;

  float local_14;

  float local_10;

  undefined4 local_c;

  

  iVar3 = DAT_008ee3d8;

  puVar2 = DAT_00867334;

  if (((DAT_0086734a == '\0') || (DAT_00867348 == '\0')) || (DAT_008ee3d8 == 0)) {

    return 0;

  }

  FUN_00452590(&local_38,&DAT_008673fc);

  local_24 = *puVar2;

  local_20 = puVar2[1];

  local_1c = puVar2[2];

  local_c = DAT_007cb714;

  fVar1 = _DAT_007938b0 /

          SQRT(*(float *)(iVar3 + 0x2c) * *(float *)(iVar3 + 0x2c) +

               *(float *)(iVar3 + 0x28) * *(float *)(iVar3 + 0x28) +

               *(float *)(iVar3 + 0x24) * *(float *)(iVar3 + 0x24));

  local_18 = local_38 * fVar1;

  local_14 = fStack_34 * fVar1;

  local_30 = local_30 * fVar1;

  local_10 = local_30;

  cVar4 = FUN_005384e0(&local_24,&local_40);

  if (cVar4 == '\0') {

    return 0;

  }

  if ((DAT_0086c1a0 != '\0') &&

     ((double)CONCAT44(_DAT_0086c1ac,_DAT_0086c1a8) < (double)CONCAT44(uStack_3c,local_40))) {

    return 0;

  }

  if ((DAT_0086c1b8 == '\0') ||

     ((double)CONCAT44(uStack_3c,local_40) < (double)CONCAT44(_DAT_0086c1c4,_DAT_0086c1c0))) {

    _DAT_0086c1c4 = uStack_3c;

    DAT_0086c1b8 = '\x01';

    _DAT_0086c1c0 = local_40;

    DAT_0086c1c8 = FUN_0050df60();

    DAT_0086c1cc = *(undefined4 *)(iVar3 + 0xe4);

  }

  if ((DAT_00867349 != '\0') && (uVar6 = 0, *(int *)(param_1 + 0x88) != 0)) {

    while (iVar5 = FUN_0053a320(&local_24,&local_38), iVar5 == 0) {

      uVar6 = uVar6 + 1;

      if (*(uint *)(param_1 + 0x88) <= uVar6) {

        return 1;

      }

    }

    if ((DAT_0086c1a0 != '\0') &&

       ((double)CONCAT44(_DAT_0086c1ac,_DAT_0086c1a8) <= (double)CONCAT44(fStack_34,local_38))) {

      return 1;

    }

    _DAT_0086c1ac = fStack_34;

    DAT_0086c1a0 = '\x01';

    _DAT_0086c1a8 = local_38;

    DAT_0086c1b0 = FUN_0050df60();

    DAT_0086c1b4 = *(undefined4 *)(iVar3 + 0xe4);

  }

  return 1;

}





// --- FUN_0054d560 at 0x0054D560 (size: 33) ---


uint FUN_0054d560(void)



{

  if (DAT_0086c1a0 != '\0') {

    return DAT_0086c1b0;

  }

  return -(uint)(DAT_0086c1b8 != '\0') & DAT_0086c1c8;

}





// --- FUN_0054d590 at 0x0054D590 (size: 33) ---


uint FUN_0054d590(void)



{

  if (DAT_0086c1a0 != '\0') {

    return DAT_0086c1b4;

  }

  return -(uint)(DAT_0086c1b8 != '\0') & DAT_0086c1cc;

}





// --- FUN_0054d5c0 at 0x0054D5C0 (size: 108) ---


void __thiscall FUN_0054d5c0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if ((uint)param_1[3] < param_2) {

    iVar1 = thunk_FUN_005df0f5(param_2 * 0x18);

    uVar4 = 0;

    if (param_1[3] != 0) {

      iVar2 = 0;

      do {

        puVar5 = (undefined4 *)(*param_1 + iVar2);

        puVar6 = (undefined4 *)(iVar2 + iVar1);

        for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

          *puVar6 = *puVar5;

          puVar5 = puVar5 + 1;

          puVar6 = puVar6 + 1;

        }

        uVar4 = uVar4 + 1;

        iVar2 = iVar2 + 0x18;

      } while (uVar4 < (uint)param_1[3]);

    }

    operator_delete__((void *)*param_1);

    *param_1 = iVar1;

    param_1[3] = param_2;

    return;

  }

  FUN_0054d640(param_2);

  return;

}





// --- FUN_0054d630 at 0x0054D630 (size: 12) ---


undefined4 __fastcall FUN_0054d630(undefined4 param_1)



{

  FUN_0050a140();

  return param_1;

}





// --- FUN_0054d640 at 0x0054D640 (size: 143) ---


void __thiscall FUN_0054d640(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (param_2 <= (uint)param_1[3]) {

    if (param_2 == 0) {

      param_1[3] = 0;

      operator_delete__((void *)*param_1);

      *param_1 = 0;

    }

    else {

      iVar1 = thunk_FUN_005df0f5(param_2 * 0x18);

      uVar4 = 0;

      param_1[3] = param_2;

      if (param_2 != 0) {

        iVar2 = 0;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          puVar6 = (undefined4 *)(iVar2 + iVar1);

          for (iVar3 = 6; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar6 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar6 = puVar6 + 1;

          }

          uVar4 = uVar4 + 1;

          iVar2 = iVar2 + 0x18;

        } while (uVar4 < (uint)param_1[3]);

      }

      operator_delete__((void *)*param_1);

      *param_1 = iVar1;

    }

    if (param_2 < (uint)param_1[2]) {

      param_1[2] = param_2;

    }

    return;

  }

  FUN_0054d5c0(param_2);

  return;

}





// --- FUN_0054d700 at 0x0054D700 (size: 733) ---


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



void FUN_0054d700(void)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  int iVar8;

  float *pfVar9;

  undefined4 *puVar10;

  undefined4 *puVar11;

  bool bVar12;

  float local_28;

  

  bVar12 = DAT_0081fc78 != '\0';

  puVar10 = &DAT_008671d4;

  puVar11 = &DAT_008671d0;

  for (iVar8 = 0x1d; iVar8 != 0; iVar8 = iVar8 + -1) {

    *puVar11 = *puVar10;

    puVar10 = puVar10 + 1;

    puVar11 = puVar11 + 1;

  }

  if (bVar12) {

    fVar1 = DAT_0081fc70 * _DAT_0079c6dc;

    fVar5 = DAT_0081fc70 * _DAT_007c97cc + _DAT_0081fc74 * _DAT_0079c6dc;

    fVar4 = DAT_0081fc70 * _DAT_007938b8 + _DAT_0081fc74 * _DAT_007938b8;

    fVar6 = DAT_0081fc6c * _DAT_007938b8 + _DAT_0081fc74 * _DAT_007938b8;

    fVar3 = DAT_0081fc6c * _DAT_007c97cc + _DAT_0081fc74 * _DAT_0079c6dc;

    fVar7 = DAT_0081fc6c * _DAT_007cb7cc;

    fVar2 = _DAT_007938b0;

    if ((fVar1 <= DAT_00838418) &&

       (fVar2 = _DAT_007938b0 - ABS(DAT_00838418 - fVar1) / (fVar4 - fVar1), fVar2 < DAT_00796344))

    {

      fVar2 = DAT_00796344;

    }

    fVar1 = DAT_00838418 + DAT_00838418;

    fVar5 = (float)_DAT_007938c0 - ABS(fVar1 - (fVar5 + DAT_0081fc70)) / (fVar5 - DAT_0081fc70);

    if (fVar5 < DAT_00796344) {

      fVar5 = DAT_00796344;

    }

    fVar4 = (float)_DAT_007938c0 - ABS(fVar1 - (fVar6 + fVar4)) / (fVar6 - fVar4);

    if (fVar4 < DAT_00796344) {

      fVar4 = DAT_00796344;

    }

    fVar1 = (float)_DAT_007938c0 - ABS(fVar1 - (DAT_0081fc6c + fVar3)) / (DAT_0081fc6c - fVar3);

    if (fVar1 < DAT_00796344) {

      fVar1 = DAT_00796344;

    }

    fVar3 = _DAT_007938b0;

    if ((DAT_00838418 <= fVar7) &&

       (fVar3 = _DAT_007938b0 - ABS(DAT_00838418 - fVar7) / (fVar7 - fVar6), fVar3 < DAT_00796344))

    {

      fVar3 = DAT_00796344;

    }

    local_28 = (_DAT_007958cc * fVar3 +

               _DAT_007a1870 * fVar1 +

               DAT_00796344 * fVar4 + (_DAT_007cb7c8 * fVar2 - _DAT_007c78f4 * fVar5)) /

               (fVar3 + fVar1 + fVar4 + fVar5 + fVar2) + DAT_0086731c;

    if (local_28 <= _DAT_007938b0) {

      if (local_28 < _DAT_0079a1a0) {

        local_28 = -1.0;

      }

    }

    else {

      local_28 = 1.0;

    }

    pfVar9 = (float *)&DAT_008671d0;

    do {

      if (ABS(*pfVar9 - local_28) < (float)_DAT_007cb7c0) {

        _DAT_00867244 = DAT_0086731c;

        return;

      }

      pfVar9 = pfVar9 + 1;

    } while ((int)pfVar9 < 0x867244);

    FUN_0054cfd0(local_28);

    _DAT_00867244 = DAT_0086731c;

    return;

  }

  _DAT_00867244 = DAT_0086731c;

  return;

}





// --- FUN_0054d9e0 at 0x0054D9E0 (size: 532) ---


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



void FUN_0054d9e0(int param_1)



{

  undefined4 *puVar1;

  undefined4 local_58;

  undefined4 local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_3c;

  float local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  float local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  float local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  DAT_0081ff14 = *(undefined4 *)(param_1 + 4);

  FUN_00425f10(param_1 + 8);

  DAT_0086c1d0 = DAT_0081ff28;

  DAT_0086c1d4 = DAT_0081ff2c;

  DAT_0086c1d8 = DAT_0081ff30;

  DAT_0086c18c = DAT_0081ff34;

  DAT_0086c190 = DAT_0081ff38;

  DAT_0086c194 = DAT_0081ff3c;

  _DAT_00867434 =

       -(DAT_0081ff4c * DAT_0081ff34 + DAT_0081ff50 * DAT_0081ff38 + DAT_0081ff54 * DAT_0081ff3c) -

       DAT_0081fc94;

  DAT_00867438 = DAT_0081ff40;

  DAT_0086743c = DAT_0081ff44;

  DAT_00867440 = DAT_0081ff48;

  _DAT_0086741c = DAT_0081ff4c;

  _DAT_00867420 = DAT_0081ff50;

  _DAT_00867424 = DAT_0081ff54;

  _DAT_00867428 = DAT_0081ff34;

  _DAT_0086742c = DAT_0081ff38;

  _DAT_00867430 = DAT_0081ff3c;

  local_58 = 0;

  local_54 = 0;

  local_50 = 0;

  FUN_004526c0(&local_4c,&local_58);

  local_40 = DAT_0086c1d0;

  local_30 = DAT_0086c1d8;

  local_20 = DAT_0086c1d4;

  local_10 = local_4c;

  local_3c = DAT_00867438;

  local_2c = DAT_00867440;

  local_1c = DAT_0086743c;

  local_c = local_44;

  local_38 = DAT_0086c18c;

  local_28 = DAT_0086c194;

  local_18 = DAT_0086c190;

  local_8 = local_48;

  local_34 = 0;

  local_24 = 0;

  local_14 = 0;

  local_4 = 0x3f800000;

  FUN_005a4860(&local_40);

  (**(code **)(*DAT_0086734c + 0x28))();

  if (DAT_0086734a != '\0') {

    puVar1 = (undefined4 *)FUN_0054c220(&local_4c,DAT_00867324,DAT_00867328);

    _DAT_008673fc = *puVar1;

    _DAT_00867400 = puVar1[1];

    _DAT_00867404 = puVar1[2];

  }

  return;

}





// --- FUN_0054dc00 at 0x0054DC00 (size: 98) ---


void FUN_0054dc00(undefined4 param_1,undefined4 param_2,float *param_3)



{

  int iVar1;

  int iVar2;

  float10 fVar3;

  

  fVar3 = (float10)FUN_0054c450(param_1,param_2,&DAT_00867428);

  *param_3 = (float)fVar3;

  iVar1 = 1;

  if (0 < DAT_00847060) {

    iVar2 = 0x18;

    do {

      fVar3 = (float10)FUN_0054c450(param_1,param_2,iVar2 + -0x10 + DAT_00847050);

      param_3[iVar1] = (float)fVar3;

      iVar1 = iVar1 + 1;

      iVar2 = iVar2 + 0x18;

    } while (iVar1 <= DAT_00847060);

  }

  return;

}





// --- FUN_0054dc70 at 0x0054DC70 (size: 116) ---


undefined4

FUN_0054dc70(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,undefined4 param_6)



{

  int iVar1;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  undefined8 uVar2;

  undefined8 uVar3;

  undefined8 uVar4;

  

  uVar2 = FUN_0054c540(param_1,param_5,param_6);

  uVar3 = FUN_0054c540(param_2,(int)((ulonglong)uVar2 >> 0x20),extraout_ECX);

  uVar4 = FUN_0054c540(param_3,(int)((ulonglong)uVar3 >> 0x20),extraout_ECX_00);

  iVar1 = FUN_0054c540(param_4,(int)((ulonglong)uVar4 >> 0x20),extraout_ECX_01);

  if ((int)uVar2 == 0) {

    if ((((int)uVar3 == 0) && ((int)uVar4 == 0)) && (iVar1 == 0)) {

      return 0;

    }

  }

  else if (((((int)uVar2 == 2) && ((int)uVar3 == 2)) && ((int)uVar4 == 2)) && (iVar1 == 2)) {

    return 2;

  }

  return 1;

}





// --- FUN_0054dcf0 at 0x0054DCF0 (size: 107) ---


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



void FUN_0054dcf0(int param_1,int param_2)



{

  undefined4 *puVar1;

  

  DAT_008672ec = param_2;

  DAT_00847054 = param_1;

  puVar1 = (undefined4 *)(*(int *)(param_1 + 4) + param_2 * 0x18);

  DAT_00847060 = *puVar1;

  _DAT_008671c8 = (1 << ((char)*puVar1 + 1U & 0x1f)) + -1;

  DAT_00847050 = *(int *)(param_1 + 0x14) + puVar1[1] * 0x18;

  _DAT_00867304 = puVar1[2];

  _DAT_008470d0 = puVar1[3];

  _DAT_008470cc = puVar1[4];

  _DAT_00867300 = puVar1[5];

  return;

}





// --- FUN_0054dd60 at 0x0054DD60 (size: 84) ---


void FUN_0054dd60(undefined4 param_1,int param_2)



{

  undefined **local_48;

  undefined4 local_44;

  

  if (param_2 != 0) {

    local_48 = &PTR_LAB_00797910;

    local_44 = 0;

    FUN_00425f10(param_2);

    (**(code **)(*DAT_0086734c + 0x30))(param_1,&local_48);

    return;

  }

  (**(code **)(*DAT_0086734c + 0x30))(param_1,0);

  return;

}





// --- FUN_0054ddc0 at 0x0054DDC0 (size: 551) ---


/* WARNING: Removing unreachable block (ram,0x0054df51) */

/* WARNING: Removing unreachable block (ram,0x0054df28) */

/* WARNING: Removing unreachable block (ram,0x0054df75) */

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



void FUN_0054ddc0(int param_1,int *param_2,int param_3,int param_4,int *param_5,undefined4 param_6,

                 int param_7,int param_8)



{

  undefined4 uVar1;

  float fVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  int iVar6;

  undefined4 uVar7;

  float local_1c;

  float local_18;

  float local_14;

  float local_10;

  float local_4;

  

  local_1c = 0.0;

  if (*param_5 == 0) {

    FUN_0043e7d0(&local_18,DAT_0081ff5c,param_6);

    local_4 = local_10 + *(float *)(param_7 + 0x3c);

    local_18 = (local_18 + *(float *)(param_7 + 0x34)) - _DAT_0081ff94;

    fVar2 = (local_14 + *(float *)(param_7 + 0x38)) - _DAT_0081ff98;

    local_1c = local_18 * local_18 +

               fVar2 * fVar2 + (local_4 - _DAT_0081ff9c) * (local_4 - _DAT_0081ff9c);

  }

  iVar3 = *param_2;

  if (iVar3 == 0) {

    iVar6 = 0;

    *param_2 = 1;

  }

  else {

    iVar6 = 0;

    if (0 < iVar3) {

      do {

        if (local_1c < *(float *)(*(int *)(param_4 + iVar6 * 4) + 0xd8)) break;

        iVar6 = iVar6 + 1;

      } while (iVar6 < *param_2);

    }

    if (iVar3 == param_1) {

      if (iVar6 == iVar3) {

        return;

      }

    }

    else {

      *param_2 = iVar3 + 1;

    }

    uVar7 = *(undefined4 *)(param_4 + iVar6 * 4);

    *(undefined4 *)(param_4 + iVar6 * 4) = *(undefined4 *)(param_4 + -4 + *param_2 * 4);

    iVar3 = iVar6 + 1;

    if (iVar3 < *param_2) {

      do {

        uVar1 = *(undefined4 *)(param_4 + iVar3 * 4);

        *(undefined4 *)(param_4 + iVar3 * 4) = uVar7;

        iVar3 = iVar3 + 1;

        uVar7 = uVar1;

      } while (iVar3 < *param_2);

    }

  }

  iVar6 = *(int *)(param_4 + iVar6 * 4);

  *(int *)(iVar6 + 0x70) = *param_5;

  FUN_00512de0(param_7,param_5 + 1);

  iVar3 = FUN_005df4c4();

  uVar4 = FUN_005df4c4();

  uVar5 = FUN_005df4c4();

  uVar4 = (iVar3 << 8 | uVar4) << 8 | uVar5;

  *(float *)(iVar6 + 0xc0) = (float)(uVar4 >> 0x10 & 0xff) * _DAT_00799208;

  *(float *)(iVar6 + 0xc4) = (float)(uVar4 >> 8 & 0xff) * _DAT_00799208;

  *(float *)(iVar6 + 200) = (float)(uVar5 & 0xff) * _DAT_00799208;

  *(int *)(iVar6 + 0xcc) = param_5[0x17];

  *(int *)(iVar6 + 0xd0) = param_5[0x18];

  iVar3 = param_5[0x19];

  *(float *)(iVar6 + 0xd8) = local_1c;

  param_8 = (iVar6 - param_3) / 0xdc + param_8;

  *(int *)(iVar6 + 0xd4) = iVar3;

  *(undefined4 *)(iVar6 + 0x6c) = param_6;

  *(int *)(iVar6 + 0x68) = param_8;

  FUN_0059bd40(param_8,iVar6,param_6,(int *)(iVar6 + 0x70));

  return;

}





// --- FUN_0054dff0 at 0x0054DFF0 (size: 53) ---


void FUN_0054dff0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_0054ddc0(DAT_0081fca4,&DAT_008683b4,&DAT_008683b8,&DAT_0086b748,param_1,param_2,param_3,

               DAT_0081fca8 + 1);

  return;

}





// --- FUN_0054e030 at 0x0054E030 (size: 47) ---


void FUN_0054e030(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_0054ddc0(DAT_0081fca8,&DAT_0086b838,&DAT_0086b83c,&DAT_0086c0d4,param_1,param_2,param_3,1);

  return;

}





// --- FUN_0054e060 at 0x0054E060 (size: 39) ---


void FUN_0054e060(int param_1)



{

  DAT_00867344 = param_1;

  FUN_0054ca10();

  if (param_1 != 0) {

    FUN_0054cbc0(0xffffffff,0);

    FUN_0054cc90();

    return;

  }

  return;

}





// --- FUN_0054e090 at 0x0054E090 (size: 261) ---


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



void FUN_0054e090(void)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  

  iVar8 = 0;

  FUN_0054ca10();

  iVar5 = DAT_0086b838;

  iVar7 = 0;

  if (0 < DAT_0086b838) {

    do {

      if ((iVar8 < 8) && (iVar6 = FUN_0054cdc0((&DAT_0086c0d4)[iVar7] + 0x70), iVar6 == 0)) {

        (&DAT_00867248)[iVar7] = 1;

        FUN_0054cbc0(iVar7,2);

        iVar8 = iVar8 + 1;

      }

      else {

        (&DAT_00867248)[iVar7] = 0;

      }

      iVar7 = iVar7 + 1;

    } while (iVar7 < iVar5);

  }

  iVar5 = DAT_008683b4;

  iVar7 = 0;

  if (0 < DAT_008683b4) {

    do {

      iVar6 = (&DAT_0086b748)[iVar7];

      if ((7 < iVar8) ||

         ((*(int *)(iVar6 + 0x70) == 0 &&

          (fVar1 = *(float *)(iVar6 + 0xb4) - _DAT_0086c124,

          fVar4 = *(float *)(iVar6 + 0xb8) - _DAT_0086c128,

          fVar3 = *(float *)(iVar6 + 0xbc) - _DAT_0086c12c,

          fVar2 = *(float *)(iVar6 + 0xd0) + _DAT_00867270,

          DAT_007cb6a8 <= (fVar1 * fVar1 + fVar4 * fVar4 + fVar3 * fVar3) - fVar2 * fVar2)))) {

        (&DAT_008470d8)[iVar7] = 0;

      }

      else {

        (&DAT_008470d8)[iVar7] = 1;

        FUN_0054cbc0(iVar7,1);

        iVar8 = iVar8 + 1;

      }

      iVar7 = iVar7 + 1;

    } while (iVar7 < iVar5);

  }

  FUN_0054cc90();

  return;

}





// --- FUN_0054e1a0 at 0x0054E1A0 (size: 177) ---


undefined4 FUN_0054e1a0(undefined4 param_1,undefined4 param_2)



{

  char cVar1;

  

  cVar1 = FUN_004154a0();

  if (cVar1 != '\0') {

    cVar1 = FUN_0044b810();

    if (cVar1 == '\0') {

      FUN_00446d30();

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

        (**(code **)(*DAT_00870340 + 8))();

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

          (**(code **)*DAT_00870340)(1);

        }

      }

      DAT_00870340 = (int *)0x0;

    }

    else {

      cVar1 = FUN_0054d110(DAT_0086734c[2],param_1,param_2);

      if (cVar1 != '\0') {

        FUN_00557850();

        cVar1 = FUN_00448810();

        if (cVar1 != '\0') {

          return 1;

        }

        FUN_00557b50();

        FUN_0044b820();

        FUN_0054d160();

      }

    }

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

      (**(code **)(*DAT_0086734c + 8))();

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

        (**(code **)*DAT_0086734c)(1);

      }

      DAT_0086734c = (int *)0x0;

    }

  }

  return 0;

}





// --- FUN_0054e260 at 0x0054E260 (size: 95) ---


undefined4 FUN_0054e260(void)



{

  code *pcVar1;

  uint uVar2;

  

  if (DAT_0086734c == 0) {

    return 0;

  }

  uVar2 = 0;

  do {

    FUN_005a47d0(uVar2,0);

    uVar2 = uVar2 + 1;

  } while (uVar2 < 8);

  FUN_00446d30();

  FUN_00446d80();

  uVar2 = 0;

  if (DAT_0086c214 != 0) {

    do {

      pcVar1 = *(code **)(DAT_0086c20c + uVar2 * 4);

      if (pcVar1 != (code *)0x0) {

        (*pcVar1)();

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < DAT_0086c214);

  }

  return 1;

}





// --- FUN_0054e2c0 at 0x0054E2C0 (size: 83) ---


undefined4 FUN_0054e2c0(undefined4 param_1,undefined4 param_2)



{

  code *pcVar1;

  char cVar2;

  uint uVar3;

  

  if (DAT_0086734c != 0) {

    cVar2 = FUN_0054d200(*(undefined4 *)(DAT_0086734c + 8),param_1,param_2);

    if (cVar2 != '\0') {

      FUN_00446d80();

      uVar3 = 0;

      if (DAT_0086c214 != 0) {

        do {

          pcVar1 = *(code **)(DAT_0086c20c + uVar3 * 4);

          if (pcVar1 != (code *)0x0) {

            (*pcVar1)();

          }

          uVar3 = uVar3 + 1;

        } while (uVar3 < DAT_0086c214);

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_0054e320 at 0x0054E320 (size: 77) ---


undefined4 FUN_0054e320(void)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c [7];

  

  if (DAT_0086734c != 0) {

    puVar4 = local_1c;

    puVar3 = DAT_00870340;

    for (iVar2 = 7; puVar3 = puVar3 + 1, iVar2 != 0; iVar2 = iVar2 + -1) {

      *puVar4 = *puVar3;

      puVar4 = puVar4 + 1;

    }

    local_24 = DAT_00870340[8];

    local_20 = DAT_00870340[9];

    uVar1 = FUN_0054e2c0(local_1c,&local_24);

    return uVar1;

  }

  return 0;

}





// --- FUN_0054e370 at 0x0054E370 (size: 57) ---


void FUN_0054e370(int param_1)



{

  uint uVar1;

  

  uVar1 = 0;

  if (DAT_0086c214 != 0) {

    while (*(int *)(DAT_0086c20c + uVar1 * 4) != param_1) {

      uVar1 = uVar1 + 1;

      if (DAT_0086c214 <= uVar1) {

        return;

      }

    }

    if (uVar1 != 0xffffffff) {

      FUN_00693b70(&param_1);

    }

  }

  return;

}





// --- FUN_0054e3b0 at 0x0054E3B0 (size: 154) ---


int __fastcall FUN_0054e3b0(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  

  *(undefined4 *)(param_1 + 0x9c) = 0x3f800000;

  *(undefined4 *)(param_1 + 0xa0) = 0;

  *(undefined4 *)(param_1 + 0xa4) = 0;

  *(undefined4 *)(param_1 + 0xa8) = 0;

  *(undefined4 *)(param_1 + 0xd0) = 0;

  *(undefined4 *)(param_1 + 0xd4) = 0;

  *(undefined4 *)(param_1 + 0xd8) = 0;

  FUN_00535b30();

  puVar2 = (undefined4 *)(param_1 + 0x1b8);

  iVar1 = 0x3c;

  do {

    puVar2[-0xf] = 0x3f800000;

    puVar2[-0xe] = 0;

    puVar2[-0xd] = 0;

    puVar2[-0xc] = 0;

    puVar2[-2] = 0;

    puVar2[-1] = 0;

    *puVar2 = 0;

    FUN_00535b30();

    puVar2 = puVar2 + 0x37;

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  puVar2 = (undefined4 *)(param_1 + 0x363c);

  iVar1 = 10;

  do {

    puVar2[-0xf] = 0x3f800000;

    puVar2[-0xe] = 0;

    puVar2[-0xd] = 0;

    puVar2[-0xc] = 0;

    puVar2[-2] = 0;

    puVar2[-1] = 0;

    *puVar2 = 0;

    FUN_00535b30();

    puVar2 = puVar2 + 0x37;

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_1;

}





// --- FUN_0054e460 at 0x0054E460 (size: 561) ---


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



void FUN_0054e460(void)



{

  bool bVar1;

  bool bVar2;

  bool bVar3;

  bool bVar4;

  bool bVar5;

  bool bVar6;

  

  if (DAT_00870340 == 0) {

    return;

  }

  bVar5 = false;

  bVar1 = false;

  bVar6 = false;

  if (DAT_00838196 != '\0') {

    bVar2 = DAT_008702ec != DAT_00818b64;

    if (bVar2) {

      DAT_008702ec = DAT_00818b64;

    }

    bVar3 = DAT_008702e8 != DAT_00818b68;

    if (bVar3) {

      DAT_008702e8 = DAT_00818b68;

    }

    bVar4 = DAT_008702e4 != DAT_00818b6c;

    if (bVar4) {

      DAT_008702e4 = DAT_00818b6c;

    }

    bVar5 = DAT_008702e1 != DAT_00818b71;

    if (bVar5) {

      DAT_008702e1 = DAT_00818b71;

    }

    bVar5 = bVar5 || (bVar4 || (bVar3 || bVar2));

    if (DAT_008702e0 != DAT_00818b72) {

      bVar5 = true;

      DAT_008702e0 = DAT_00818b72;

    }

  }

  if (DAT_0081fff4 != DAT_0081ffa8) {

    bVar1 = true;

    DAT_0081fff4 = DAT_0081ffa8;

    if (DAT_0081ffa8 == 0) {

      DAT_00846774 = 0;

    }

    else {

      DAT_00846774 = DAT_0081ffa8 + -1;

    }

  }

  if (DAT_0081fff0 != DAT_0081ffac) {

    bVar1 = true;

    DAT_0081fff0 = DAT_0081ffac;

    if (DAT_0081ffac == 0) {

      DAT_00846778 = 0;

      DAT_0084677c = DAT_00846778;

      DAT_00846780 = DAT_00846778;

    }

    else {

      DAT_00846778 = DAT_0081ffac + -1;

      DAT_0084677c = DAT_00846778;

      DAT_00846780 = DAT_00846778;

    }

  }

  bVar2 = _DAT_008702dc != DAT_0081ffc4;

  if (bVar2) {

    _DAT_008702dc = DAT_0081ffc4;

  }

  bVar3 = DAT_008702d8 != DAT_0081ffb8;

  if (bVar3) {

    DAT_008702d8 = DAT_0081ffb8;

  }

  if (_DAT_008702d4 != DAT_0081ffc8) {

    _DAT_008702d4 = DAT_0081ffc8;

    FUN_00451ea0(DAT_0081ffc8);

  }

  if (DAT_0083da58 != 0) {

    bVar6 = DAT_008702d0 != DAT_0081ffb4;

    if (bVar6) {

      DAT_008702d0 = DAT_0081ffb4;

    }

    bVar4 = DAT_008702cd != '\0';

    if (bVar4) {

      DAT_008702cd = '\0';

    }

    if (DAT_008702cc == DAT_0081ffa5) {

      if (!bVar4) goto LAB_0054e608;

    }

    else {

      DAT_008702cc = DAT_0081ffa5;

    }

    FUN_00451e30(0,DAT_0081ffa5);

  }

LAB_0054e608:

  if (bVar2) {

    FUN_005a1c80(DAT_0081ffc4,0);

  }

  if (DAT_0081ffec == '\0') {

    if ((DAT_00838196 != '\0') && (bVar5)) {

      FUN_0043a510();

    }

    if (bVar6) {

      FUN_004531c0(DAT_0081ffb4);

    }

    if ((bVar1) && ((DAT_00838196 == '\0' || (!bVar5)))) {

      FUN_0054e260();

    }

    if (bVar3) {

      FUN_005a0ce0();

    }

  }

  DAT_0081ffec = 0;

  return;

}





// --- FUN_0054e6a0 at 0x0054E6A0 (size: 390) ---


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



undefined4 FUN_0054e6a0(void)



{

  int iVar1;

  undefined4 *puVar2;

  int iVar3;

  

  iVar1 = (**(code **)(*DAT_0086734c + 0x10))();

  if (iVar1 == 0) {

    return 1;

  }

  iVar1 = 0;

  iVar3 = 0;

  do {

    *(undefined **)((int)&DAT_0086b748 + iVar3) = &DAT_008683b8 + iVar1;

    *(undefined **)((int)&DAT_0086f6d0 + iVar3) = &DAT_0086c340 + iVar1;

    iVar1 = iVar1 + 0xdc;

    iVar3 = iVar3 + 4;

  } while (iVar1 < 0x3390);

  DAT_0086c0d4 = &DAT_0086b83c;

  _DAT_0087005c = &DAT_0086f7c4;

  DAT_0086c0d8 = &DAT_0086b918;

  _DAT_00870060 = &DAT_0086f8a0;

  _DAT_0086c0dc = &DAT_0086b9f4;

  _DAT_00870064 = &DAT_0086f97c;

  _DAT_0086c0e0 = &DAT_0086bad0;

  _DAT_00870068 = &DAT_0086fa58;

  _DAT_0086c0e4 = &DAT_0086bbac;

  _DAT_0087006c = &DAT_0086fb34;

  _DAT_0086c0e8 = &DAT_0086bc88;

  _DAT_00870070 = &DAT_0086fc10;

  _DAT_0086c0ec = &DAT_0086bd64;

  _DAT_00870074 = &DAT_0086fcec;

  _DAT_0086c0f0 = &DAT_0086be40;

  _DAT_00870078 = &DAT_0086fdc8;

  _DAT_0086c0f4 = &DAT_0086bf1c;

  _DAT_0087007c = &DAT_0086fea4;

  _DAT_0086c0f8 = &DAT_0086bff8;

  _DAT_00870080 = &DAT_0086ff80;

  DAT_008672e8 = &DAT_008471c8;

  puVar2 = &DAT_00868278;

  do {

    *puVar2 = 0;

    puVar2 = puVar2 + -0x5a;

  } while (0x8675cf < (int)puVar2);

  _DAT_00870288 = 1;

  FUN_0052dae0(1);

  *DAT_0087028c = 0;

  DAT_0087028c[1] = 0;

  DAT_008683b4 = 0;

  DAT_0086b838 = 0;

  FUN_004154a0();

  _DAT_00867360 = 1;

  return 0;

}





// --- FUN_0054e830 at 0x0054E830 (size: 47) ---


void FUN_0054e830(undefined4 param_1)



{

  undefined **local_48;

  undefined4 local_44;

  

  local_48 = &PTR_LAB_00797910;

  local_44 = 0;

  FUN_00425f10(param_1);

  FUN_0054d9e0(&local_48);

  return;

}





// --- FUN_0054e860 at 0x0054E860 (size: 202) ---


int FUN_0054e860(undefined4 *param_1,undefined4 *param_2,undefined4 *param_3,undefined4 *param_4,

                undefined4 param_5,undefined4 param_6)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int local_c;

  int local_8;

  

  local_8 = FUN_0054dc70(*param_1,*param_2,*param_3,*param_4,param_6,param_5);

  if (local_8 == 0) {

    return 0;

  }

  local_c = 1;

  if (0 < DAT_00847060) {

    iVar3 = (int)param_4 - (int)param_3;

    iVar4 = (int)param_2 - (int)param_3;

    iVar1 = (int)param_1 - (int)param_3;

    while( true ) {

      param_3 = param_3 + 1;

      iVar2 = FUN_0054dc70(*(undefined4 *)(iVar1 + (int)param_3),

                           *(undefined4 *)((int)param_3 + iVar4),*param_3,

                           *(undefined4 *)(iVar3 + (int)param_3),param_6,param_5);

      if (iVar2 == 0) break;

      if (iVar2 == 1) {

        local_8 = 1;

      }

      local_c = local_c + 1;

      if (DAT_00847060 < local_c) {

        return local_8;

      }

    }

    local_8 = 0;

  }

  return local_8;

}





// --- FUN_0054e930 at 0x0054E930 (size: 269) ---


void __thiscall FUN_0054e930(int *param_1,uint param_2)



{

  int iVar1;

  uint *puVar2;

  uint uVar3;

  int iVar4;

  uint *local_8;

  

  if ((uint)param_1[3] < param_2) {

    puVar2 = (uint *)thunk_FUN_005df0f5(param_2 * 0x18 + 4);

    if (puVar2 == (uint *)0x0) {

      local_8 = (uint *)0x0;

    }

    else {

      local_8 = puVar2 + 1;

      *puVar2 = param_2;

      FUN_00401000(local_8,0x18,param_2,FUN_0054d630);

    }

    uVar3 = 0;

    if (param_1[3] != 0) {

      puVar2 = local_8 + 2;

      do {

        iVar1 = *param_1 + (-8 - (int)local_8);

        puVar2[-2] = *(uint *)((int)puVar2 + *param_1 + (-8 - (int)local_8));

        puVar2[-1] = *(uint *)((int)puVar2 + iVar1 + 4);

        *puVar2 = *(uint *)((int)puVar2 + iVar1 + 8);

        puVar2[1] = *(uint *)((int)puVar2 + iVar1 + 0xc);

        puVar2[2] = *(uint *)((int)puVar2 + iVar1 + 0x10);

        puVar2[3] = *(uint *)((int)puVar2 + iVar1 + 0x14);

        uVar3 = uVar3 + 1;

        puVar2 = puVar2 + 6;

      } while (uVar3 < (uint)param_1[3]);

    }

    iVar1 = *param_1;

    if (iVar1 != 0) {

      iVar4 = *(int *)(iVar1 + -4);

      if (-1 < iVar4 + -1) {

        do {

          FUN_00695670();

          iVar4 = iVar4 + -1;

        } while (iVar4 != 0);

      }

      operator_delete__((void *)(iVar1 + -4));

    }

    param_1[3] = param_2;

    *param_1 = (int)local_8;

    return;

  }

  FUN_0054ea40(param_2);

  return;

}





// --- FUN_0054ea40 at 0x0054EA40 (size: 347) ---


void __thiscall FUN_0054ea40(int *param_1,uint param_2)



{

  int iVar1;

  uint *puVar2;

  uint uVar3;

  int iVar4;

  uint *local_8;

  

  if (param_2 <= (uint)param_1[3]) {

    if (param_2 == 0) {

      iVar1 = *param_1;

      param_1[3] = 0;

      if (iVar1 != 0) {

        iVar4 = *(int *)(iVar1 + -4);

        if (-1 < iVar4 + -1) {

          do {

            FUN_00695670();

            iVar4 = iVar4 + -1;

          } while (iVar4 != 0);

        }

        operator_delete__((void *)(iVar1 + -4));

      }

      *param_1 = 0;

    }

    else {

      puVar2 = (uint *)thunk_FUN_005df0f5(param_2 * 0x18 + 4);

      if (puVar2 == (uint *)0x0) {

        local_8 = (uint *)0x0;

      }

      else {

        local_8 = puVar2 + 1;

        *puVar2 = param_2;

        FUN_00401000(local_8,0x18,param_2,FUN_0054d630);

      }

      uVar3 = 0;

      param_1[3] = param_2;

      if (param_2 != 0) {

        puVar2 = local_8 + 2;

        do {

          iVar1 = *param_1 + (-8 - (int)local_8);

          puVar2[-2] = *(uint *)((int)puVar2 + *param_1 + (-8 - (int)local_8));

          puVar2[-1] = *(uint *)((int)puVar2 + iVar1 + 4);

          *puVar2 = *(uint *)((int)puVar2 + iVar1 + 8);

          puVar2[1] = *(uint *)((int)puVar2 + iVar1 + 0xc);

          puVar2[2] = *(uint *)((int)puVar2 + iVar1 + 0x10);

          puVar2[3] = *(uint *)((int)puVar2 + iVar1 + 0x14);

          uVar3 = uVar3 + 1;

          puVar2 = puVar2 + 6;

        } while (uVar3 < (uint)param_1[3]);

      }

      iVar1 = *param_1;

      if (iVar1 != 0) {

        iVar4 = *(int *)(iVar1 + -4);

        if (-1 < iVar4 + -1) {

          do {

            FUN_00695670();

            iVar4 = iVar4 + -1;

          } while (iVar4 != 0);

        }

        operator_delete__((void *)(iVar1 + -4));

      }

      *param_1 = (int)local_8;

    }

    if (param_2 < (uint)param_1[2]) {

      param_1[2] = param_2;

    }

    return;

  }

  FUN_0054e930(param_2);

  return;

}





// --- FUN_0054ebb0 at 0x0054EBB0 (size: 15) ---


void __fastcall FUN_0054ebb0(int param_1)



{

  *(undefined4 *)(param_1 + 8) = 0;

  FUN_00439640();

  return;

}





// --- FUN_0054ebc0 at 0x0054EBC0 (size: 8) ---


void FUN_0054ebc0(void)



{

  FUN_00439640();

  return;

}





// --- FUN_0054ebd0 at 0x0054EBD0 (size: 1998) ---


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



undefined4 FUN_0054ebd0(int param_1,undefined4 *param_2,int param_3)



{

  uint uVar1;

  float fVar2;

  int iVar3;

  float fVar4;

  bool bVar5;

  float fVar6;

  float fVar7;

  float *pfVar8;

  int iVar9;

  float *pfVar10;

  float *pfVar11;

  float fVar12;

  int iVar13;

  int iVar14;

  int iVar15;

  int local_228;

  int local_220;

  float local_21c;

  float local_218;

  float local_214;

  float local_210;

  float local_20c;

  int local_204;

  char local_1cc [64];

  float local_18c [99];

  

  iVar15 = *(int *)(param_1 + 0x38);

  if (iVar15 == 0) {

    iVar14 = 0;

  }

  else {

    iVar14 = *(int *)(param_1 + 0x10);

  }

  if (*(int *)(param_1 + 0x20) <= iVar15) {

    FUN_0054d5c0(iVar15 + 0x10);

  }

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

    local_228 = 4;

    *(uint *)(param_1 + 0x10) = iVar14 + 5U;

    if (*(uint *)(param_1 + 0x30) <= iVar14 + 5U) {

      FUN_0054e930(iVar14 + 0x15);

    }

    *(undefined4 *)(iVar15 * 0x18 + *(int *)(param_1 + 0x14)) = 4;

    *(int *)(*(int *)(param_1 + 0x14) + 4 + iVar15 * 0x18) = iVar14;

    pfVar11 = (float *)(*(int *)(param_1 + 0x24) + iVar14 * 0x18);

    *pfVar11 = 0.0;

    fVar12 = (float)*(int *)(DAT_00870340 + 0x98);

    if (*(int *)(DAT_00870340 + 0x98) < 0) {

      fVar12 = fVar12 + _DAT_0079920c;

    }

    pfVar11[1] = fVar12;

    fVar12 = (float)*(int *)(DAT_00870340 + 0x94);

    if (*(int *)(DAT_00870340 + 0x94) < 0) {

      fVar12 = fVar12 + _DAT_0079920c;

    }

    pfVar11[6] = fVar12;

    fVar12 = (float)*(int *)(DAT_00870340 + 0x98);

    if (*(int *)(DAT_00870340 + 0x98) < 0) {

      fVar12 = fVar12 + _DAT_0079920c;

    }

    pfVar11[7] = fVar12;

    fVar12 = (float)*(int *)(DAT_00870340 + 0x94);

    if (*(int *)(DAT_00870340 + 0x94) < 0) {

      fVar12 = fVar12 + _DAT_0079920c;

    }

    pfVar11[0xc] = fVar12;

    pfVar11[0xd] = 0.0;

    pfVar11[0x12] = 0.0;

    pfVar11[0x13] = 0.0;

    pfVar11[0x18] = 0.0;

    fVar12 = (float)*(int *)(DAT_00870340 + 0x98);

    if (*(int *)(DAT_00870340 + 0x98) < 0) {

      fVar12 = fVar12 + _DAT_0079920c;

    }

    pfVar11[0x19] = fVar12;

    goto LAB_0054f03d;

  }

  iVar9 = 0;

  fVar12 = 0.0;

  local_228 = 1;

  local_210 = 0.0;

  local_220 = 0;

  local_1cc[0] = '\x01';

  if (0 < param_3) {

    local_204 = 0;

    iVar13 = (int)fVar12;

    do {

      pfVar11 = (float *)param_2[iVar9];

      if (pfVar11[3] != (float)_DAT_007938c0) {

        *pfVar11 = *pfVar11 / pfVar11[3];

        iVar3 = param_2[iVar9];

        *(float *)(iVar3 + 4) = *(float *)(iVar3 + 4) / *(float *)(iVar3 + 0xc);

        *(undefined4 *)(param_2[iVar9] + 0xc) = 0x3f800000;

      }

      fVar12 = (float)iVar13;

      if (0 < iVar9) {

        pfVar11 = (float *)param_2[iVar9];

        pfVar8 = (float *)param_2[iVar13];

        if (((float)_DAT_007938c0 < ABS(*pfVar11 - *pfVar8)) ||

           ((float)_DAT_007938c0 < ABS(pfVar11[1] - pfVar8[1]))) {

          bVar5 = true;

        }

        else {

          bVar5 = false;

        }

        local_1cc[iVar9] = bVar5;

        if (bVar5) {

          fVar12 = (float)iVar9;

          if (iVar13 < 1) {

            local_228 = local_228 + 1;

LAB_0054ee44:

            local_220 = iVar9;

          }

          else {

            pfVar10 = *(float **)(local_204 + (int)param_2);

            fVar6 = ABS(*pfVar10 - *pfVar11);

            if (ABS(*pfVar10 - *pfVar11) < ABS(pfVar10[1] - pfVar11[1])) {

              fVar6 = ABS(pfVar10[1] - pfVar11[1]);

            }

            if (fVar6 <= ABS((*pfVar10 - *pfVar8) * (pfVar8[1] - pfVar11[1]) -

                             (pfVar10[1] - pfVar8[1]) * (*pfVar8 - *pfVar11))) {

              local_228 = local_228 + 1;

              local_210 = (float)iVar13;

              local_204 = iVar13 * 4;

            }

            else {

              local_1cc[iVar13] = '\0';

              if (local_220 == iVar13) goto LAB_0054ee44;

            }

          }

        }

      }

      iVar9 = iVar9 + 1;

      iVar13 = (int)fVar12;

    } while (iVar9 < param_3);

  }

  pfVar11 = (float *)*param_2;

  if (((float)_DAT_007938c0 < ABS(*pfVar11 - *(float *)param_2[(int)fVar12])) ||

     ((float)_DAT_007938c0 < ABS(pfVar11[1] - ((float *)param_2[(int)fVar12])[1]))) {

    bVar5 = true;

  }

  else {

    bVar5 = false;

  }

  local_1cc[(int)fVar12] = bVar5;

  if (bVar5) {

    pfVar8 = (float *)param_2[(int)local_210];

    fVar6 = ABS(*pfVar8 - *pfVar11);

    if (ABS(*pfVar8 - *pfVar11) < ABS(pfVar8[1] - pfVar11[1])) {

      fVar6 = ABS(pfVar8[1] - pfVar11[1]);

    }

    pfVar10 = (float *)param_2[(int)fVar12];

    if (ABS((*pfVar8 - *pfVar10) * (pfVar10[1] - pfVar11[1]) -

            (*pfVar10 - *pfVar11) * (pfVar8[1] - pfVar10[1])) < fVar6) {

      local_1cc[(int)fVar12] = '\0';

      goto LAB_0054ef09;

    }

  }

  else {

LAB_0054ef09:

    local_228 = local_228 + -1;

    fVar12 = local_210;

  }

  local_210 = fVar12;

  if (0 < local_220) {

    pfVar8 = (float *)param_2[(int)local_210];

    pfVar10 = (float *)param_2[local_220];

    fVar12 = ABS(*pfVar8 - *pfVar10);

    if (ABS(*pfVar8 - *pfVar10) < ABS(pfVar8[1] - pfVar10[1])) {

      fVar12 = ABS(pfVar8[1] - pfVar10[1]);

    }

    if (ABS((pfVar11[1] - pfVar10[1]) * (*pfVar8 - *pfVar11) -

            (*pfVar11 - *pfVar10) * (pfVar8[1] - pfVar11[1])) < fVar12) {

      local_228 = local_228 + -1;

      local_1cc[0] = '\0';

    }

  }

  if (local_228 < 3) {

    return 0;

  }

  if (0x1f < local_228) {

    local_228 = 0x1f;

  }

  uVar1 = local_228 + 1 + iVar14;

  *(uint *)(param_1 + 0x10) = uVar1;

  if (*(uint *)(param_1 + 0x30) <= uVar1) {

    FUN_0054e930(uVar1 + 0x10);

  }

  *(int *)(iVar15 * 0x18 + *(int *)(param_1 + 0x14)) = local_228;

  *(int *)(*(int *)(param_1 + 0x14) + 4 + iVar15 * 0x18) = iVar14;

  pfVar11 = (float *)(*(int *)(param_1 + 0x24) + iVar14 * 0x18);

  iVar14 = 0;

  pfVar8 = pfVar11;

  if (0 < param_3) {

    do {

      pfVar10 = pfVar8;

      if (local_1cc[iVar14] != '\0') {

        pfVar10 = pfVar8 + 6;

        *pfVar8 = ABS(*(float *)param_2[iVar14]);

        pfVar8[1] = ABS(*(float *)(param_2[iVar14] + 4));

      }

      iVar14 = iVar14 + 1;

      pfVar8 = pfVar10;

    } while (iVar14 < param_3);

  }

  pfVar11[local_228 * 6] = *pfVar11;

  (pfVar11 + local_228 * 6)[1] = pfVar11[1];

LAB_0054f03d:

  iVar15 = iVar15 * 0x18;

  local_210 = pfVar11[local_228 * 6 + -6];

  fVar12 = (pfVar11 + local_228 * 6 + -6)[1];

  fVar6 = local_210;

  fVar2 = fVar12;

  pfVar8 = pfVar11 + local_228 * 6 + -6;

  while (fVar7 = fVar2, pfVar10 = pfVar8 + -6, pfVar11 <= pfVar10) {

    fVar2 = *pfVar10;

    fVar4 = pfVar8[-5];

    local_20c = fVar2;

    if ((fVar6 <= fVar2) && (local_20c = fVar6, local_210 < fVar2)) {

      local_210 = fVar2;

    }

    fVar6 = local_20c;

    fVar2 = fVar4;

    pfVar8 = pfVar10;

    if ((fVar7 <= fVar4) && (fVar2 = fVar7, fVar12 < fVar4)) {

      fVar12 = fVar4;

    }

  }

  *(float *)(*(int *)(param_1 + 0x14) + 8 + iVar15) = fVar6;

  *(float *)(*(int *)(param_1 + 0x14) + 0xc + iVar15) = local_210;

  *(float *)(*(int *)(param_1 + 0x14) + 0x10 + iVar15) = fVar7;

  *(float *)(*(int *)(param_1 + 0x14) + 0x14 + iVar15) = fVar12;

  iVar15 = local_228 + -1;

  if (DAT_0081fff8 == 1) {

    if (-1 < iVar15) {

      pfVar10 = local_18c + iVar15 * 3;

      pfVar8 = pfVar11 + iVar15 * 6;

      local_204 = local_228;

      do {

        FUN_0059ba50(pfVar10,*pfVar8,pfVar8[1]);

        pfVar8 = pfVar8 + -6;

        pfVar10 = pfVar10 + -3;

        local_204 = local_204 + -1;

      } while (local_204 != 0);

    }

  }

  else if (-1 < iVar15) {

    pfVar8 = pfVar11 + iVar15 * 6;

    pfVar10 = local_18c + iVar15 * 3;

    iVar14 = local_228;

    do {

      fVar6 = pfVar8[1] * (float)_DAT_008672f0 - (float)_DAT_00867310;

      fVar12 = *pfVar8 * (float)_DAT_008672d8 - (float)_DAT_00847058;

      *pfVar10 = (DAT_0086c1d0 * fVar12 + DAT_0086c18c * _DAT_0081fc90) - DAT_00867438 * fVar6;

      pfVar10[1] = (fVar12 * DAT_0086c1d4 + DAT_0086c190 * _DAT_0081fc90) - DAT_0086743c * fVar6;

      iVar14 = iVar14 + -1;

      pfVar10[2] = (DAT_0086c1d8 * fVar12 + DAT_0086c194 * _DAT_0081fc90) - fVar6 * DAT_00867440;

      pfVar8 = pfVar8 + -6;

      pfVar10 = pfVar10 + -3;

    } while (iVar14 != 0);

  }

  fVar12 = DAT_007cb6a8;

  local_18c[local_228 * 3] = local_18c[0];

  local_18c[local_228 * 3 + 1] = local_18c[1];

  local_18c[local_228 * 3 + 2] = local_18c[2];

  if (-1 < iVar15) {

    pfVar8 = local_18c + iVar15 * 3 + 2;

    pfVar11 = pfVar11 + iVar15 * 6 + 2;

    do {

      local_21c = *pfVar8 * pfVar8[2] - pfVar8[-1] * pfVar8[3];

      local_218 = pfVar8[3] * pfVar8[-2] - *pfVar8 * pfVar8[1];

      local_214 = pfVar8[-1] * pfVar8[1] - pfVar8[2] * pfVar8[-2];

      if (((fVar12 <= ABS(local_21c)) || (fVar12 <= ABS(local_218))) || (fVar12 <= ABS(local_214)))

      {

        fVar6 = _DAT_007938b0 /

                SQRT(local_21c * local_21c + local_218 * local_218 + local_214 * local_214);

        local_21c = local_21c * fVar6;

        local_218 = local_218 * fVar6;

        local_214 = local_214 * fVar6;

      }

      fVar6 = _DAT_00867424 * local_214;

      pfVar8 = pfVar8 + -3;

      fVar7 = _DAT_00867420 * local_218;

      local_228 = local_228 + -1;

      fVar2 = local_21c * _DAT_0086741c;

      *pfVar11 = local_21c;

      pfVar11[1] = local_218;

      pfVar11[2] = local_214;

      pfVar11[3] = -(fVar2 + fVar7 + fVar6);

      pfVar11 = pfVar11 + -6;

    } while (local_228 != 0);

  }

  *(int *)(param_1 + 0x38) = *(int *)(param_1 + 0x38) + 1;

  return 1;

}





// --- FUN_0054f3b0 at 0x0054F3B0 (size: 236) ---


void __fastcall FUN_0054f3b0(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_4;

  

  local_4 = param_1;

  thunk_FUN_00436cf0(&DAT_00867460);

  thunk_FUN_00436cf0(&DAT_00867444);

  thunk_FUN_00436cf0(&DAT_008682ac);

  thunk_FUN_00436cf0(&DAT_00867450);

  thunk_FUN_00436cf0(&DAT_0086c1dc);

  thunk_FUN_00436cf0(&DAT_00868294);

  thunk_FUN_00436cf0(&DAT_008702a0);

  thunk_FUN_00436cf0(&DAT_0086c108);

  thunk_FUN_00436cf0(&DAT_00867458);

  thunk_FUN_00436cf0(&DAT_00867448);

  thunk_FUN_00436cf0(&DAT_0086744c);

  thunk_FUN_00436cf0(&DAT_0086745c);

  thunk_FUN_00436cf0(&DAT_0086c10c);

  thunk_FUN_00436cf0(&DAT_0086c1f8);

  FUN_00401340("SetGraphicsQuality");

  FUN_00436830(&local_4);

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

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

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

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

  }

  FUN_00439640();

  *(undefined4 *)(param_1 + 8) = 0;

  FUN_00439640();

  return;

}





// --- FUN_0054f4a0 at 0x0054F4A0 (size: 101) ---


void FUN_0054f4a0(void)



{

  char cVar1;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  

  if ((DAT_00870340 != (int *)0x0) && (*(char *)((int)DAT_00870340 + 0xad) != '\0')) {

    cVar1 = (**(code **)(*DAT_00870340 + 0x30))();

    if (cVar1 != '\0') {

      cVar1 = FUN_0054e320();

      if (cVar1 == '\0') {

        uVar5 = 0;

        uVar4 = extraout_ECX;

        FUN_00402730(&DAT_00795320);

        uVar3 = extraout_ECX_00;

        FUN_00402730(&DAT_00795320);

        uVar2 = extraout_ECX_01;

        FUN_00402730(&DAT_00795320);

        FUN_0043d090(0x80,uVar2,uVar3,uVar4,uVar5);

                    /* WARNING: Subroutine does not return */

        exit(1);

      }

    }

  }

  return;

}





// --- FUN_0054f5c0 at 0x0054F5C0 (size: 1432) ---


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



undefined4 __thiscall FUN_0054f5c0(int param_1,undefined4 *param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_8;

  int local_4;

  

  *(undefined4 *)(param_1 + 4) = *param_2;

  *(undefined4 *)(param_1 + 8) = 0;

  FUN_00439640();

  _DAT_00867350 = 3;

  FUN_0054bc30(3);

  FUN_00401340("SetGraphicsQuality <1-5>");

  FUN_00401340("Sets rendering options to the preset configuration for the specified quality level")

  ;

  FUN_00401340("SetGraphicsQuality");

  FUN_004366d0(&LAB_0054f510,&param_2,&local_8,&local_4);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

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

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

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

  }

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

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

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

  }

  FUN_00401340("Texture filtering quality.  Bilinear is fastest.  Anisoptric is highest quality.");

  FUN_00402160(&DAT_00867460,&param_2,&LAB_0054d300,4,&DAT_008702a4,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Landscape Detail Textures");

  FUN_00411d90(&DAT_00867444,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Environment Detail Textures");

  FUN_00411d90(&DAT_008682ac,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Multiple pass alpha renders all clipmapped textures twice for softer edges.");

  FUN_00411d90(&DAT_00867450,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Landscape texture detail level");

  FUN_00402160(&DAT_0086c1dc,&param_2,&LAB_0054d300,5,&DAT_0086c220,&DAT_007cb718);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Environment texture detail level");

  FUN_00402160(&DAT_00868294,&param_2,&LAB_0054d300,5,&DAT_00868280,&DAT_007cb72c);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Distance to draw characters, scenery and other objects");

  FUN_00402160(&DAT_008702a0,&param_2,&LAB_0054d300,3,&DAT_0086c118,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("How far out to generate landscape topology");

  FUN_00402160(&DAT_0086c108,&param_2,&LAB_0054d300,6,&DAT_008702b4,&DAT_007cb740);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Screen brightness adjustment");

  FUN_00431090(&DAT_00867458,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340(

              "Display aspect ratio; use \'Normal\' for square 4:3 displays or \'Wide\' for 16:9 widescreen displays"

              );

  FUN_00402160(&DAT_00867448,&param_2,&LAB_0054d300,3,&DAT_0086c174,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Feild of View");

  FUN_00431090(&DAT_0086744c,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Automatic degrades; adjustes the adaptive degrade bias based on framerate.");

  FUN_00411d90(&DAT_0086745c,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340(

              "Adaptive Degrade Bias; manually sets the degrade biad, overwritten by Automatic Degrades."

              );

  FUN_00431090(&DAT_0086c10c,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Degrade Distance; scales the distance at which degrades occure.");

  FUN_00431090(&DAT_0086c1f8,&param_2,&LAB_0054d300,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  FUN_00401340("Prefer a specific display adapter index (0 = automatic selection.)");

  FUN_00402160(&DAT_0086c0fc,&param_2,0,0,0,0);

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  if (DAT_00867354 != '\0') {

    DAT_0081ffa8 = 2;

    DAT_0081ffac = 2;

    DAT_0081ffa0 = 0;

    DAT_0081ffa4 = 0;

    DAT_0081ffa5 = 0;

    DAT_0081ffa6 = 0;

    DAT_0081ffb0 = 1;

    DAT_0081ffb4 = 8;

    DAT_0081ffc4 = 0;

    DAT_0081ffbc = 0;

    DAT_0081ffb8 = 1;

    DAT_00867354 = '\0';

  }

  thunk_FUN_00436cf0(&DAT_0086c0fc);

  return 1;

}





// --- FUN_0054fb60 at 0x0054FB60 (size: 175) ---


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



void FUN_0054fb60(void)



{

  if ((DAT_00870338 & 1) == 0) {

    DAT_00870338 = DAT_00870338 | 1;

    DAT_008702f0 = 0;

    _DAT_008702fc = 0;

    _DAT_008702f8 = 0;

    _DAT_008702f4 = 0x80;

    DAT_00870304 = 0;

    _DAT_00870310 = 0;

    _DAT_0087030c = 0;

    _DAT_00870308 = 0x80;

    _DAT_00870314 = 0;

    _DAT_00870320 = 0;

    _DAT_0087031c = 0;

    _DAT_00870318 = 0x80;

    _DAT_00870330 = 0;

    _atexit((_func_4879 *)&LAB_00772950);

  }

  _DAT_00870328 = 0;

  _DAT_00870300 = 0;

  FUN_0054ebd0(&DAT_008702f0,0,0);

  DAT_00867330 = &DAT_008702f0;

  FUN_0054dcf0(&DAT_00870300,0);

  return;

}





// --- FUN_0054fc10 at 0x0054FC10 (size: 106) ---


undefined4 FUN_0054fc10(int param_1)



{

  char cVar1;

  uint uVar2;

  undefined4 uVar3;

  

  uVar2 = 0;

  if (DAT_0086c214 != 0) {

    do {

      if (*(int *)(DAT_0086c20c + uVar2 * 4) == param_1) {

        if (uVar2 != 0xffffffff) {

          return 1;

        }

        break;

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < DAT_0086c214);

  }

  if ((DAT_0086c210 & 0x7fffffff) <= DAT_0086c214) {

    uVar3 = FUN_00453850((DAT_0086c210 & 0x7fffffff) + 1);

    cVar1 = FUN_004180a0(uVar3);

    if (cVar1 == '\0') {

      return 1;

    }

  }

  *(int *)(DAT_0086c20c + DAT_0086c214 * 4) = param_1;

  DAT_0086c214 = DAT_0086c214 + 1;

  return 1;

}





// --- FUN_0054fcc0 at 0x0054FCC0 (size: 93) ---


void __fastcall FUN_0054fcc0(int param_1)



{

  if (*(int **)(param_1 + 0xc0) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0xc0) + 0x14))();

    *(undefined4 *)(param_1 + 0xc0) = 0;

  }

  if (*(int **)(param_1 + 0xbc) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0xbc) + 0x14))();

    *(undefined4 *)(param_1 + 0xbc) = 0;

  }

  if (*(int **)(param_1 + 0xb8) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0xb8) + 0x14))();

    *(undefined4 *)(param_1 + 0xb8) = 0;

  }

  if (*(int **)(param_1 + 0xb4) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0xb4) + 0x14))();

    *(undefined4 *)(param_1 + 0xb4) = 0;

  }

  return;

}





// --- FUN_0054fd20 at 0x0054FD20 (size: 13) ---


undefined4 __fastcall FUN_0054fd20(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0xb4) + 0xa0);

}





// --- FUN_0054fd30 at 0x0054FD30 (size: 13) ---


undefined4 __fastcall FUN_0054fd30(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0xb4) + 0xa4);

}





// --- FUN_0054fd60 at 0x0054FD60 (size: 98) ---


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



float10 __thiscall

FUN_0054fd60(int param_1,undefined4 param_2,undefined4 param_3,int param_4,int param_5,char param_6)



{

  float10 fVar1;

  float10 fVar2;

  

  fVar1 = (float10)param_4;

  if (param_6 != '\0') {

    if (param_4 < 0) {

      fVar1 = fVar1 + (float10)_DAT_0079920c;

    }

    fVar2 = (float10)param_5;

    if (param_5 < 0) {

      fVar2 = fVar2 + (float10)_DAT_0079920c;

    }

    return fVar1 / fVar2;

  }

  if (param_4 < 0) {

    fVar1 = fVar1 + (float10)_DAT_0079920c;

  }

  fVar2 = (float10)param_5;

  if (param_5 < 0) {

    fVar2 = fVar2 + (float10)_DAT_0079920c;

  }

  return (fVar1 / fVar2) * (float10)*(float *)(param_1 + 0xa4) * (float10)_DAT_0079c6dc;

}





// --- FUN_0054fdd0 at 0x0054FDD0 (size: 123) ---


void __thiscall

FUN_0054fdd0(int param_1,uint param_2,uint param_3,int param_4,int param_5,undefined4 param_6)



{

  uint uVar1;

  uint uVar2;

  float10 fVar3;

  

  uVar1 = *(uint *)(param_1 + 0x9c);

  if (uVar1 <= param_2) {

    param_2 = uVar1 - 1;

  }

  uVar2 = *(uint *)(param_1 + 0xa0);

  if (uVar2 <= param_3) {

    param_3 = uVar2 - 1;

  }

  if (uVar1 < param_2 + param_4) {

    param_4 = uVar1 - param_2;

  }

  if (uVar2 < param_3 + param_5) {

    param_5 = uVar2 - param_3;

  }

  *(int *)(param_1 + 0x98) = param_5;

  *(uint *)(param_1 + 0x8c) = param_2;

  *(uint *)(param_1 + 0x90) = param_3;

  *(int *)(param_1 + 0x94) = param_4;

  fVar3 = (float10)FUN_0054fd60(param_2,param_3,param_4,param_5,param_6);

  *(float *)(param_1 + 0xa8) = (float)fVar3;

  return;

}





// --- FUN_0054fe50 at 0x0054FE50 (size: 38) ---


undefined4 __thiscall

FUN_0054fe50(undefined4 *param_1,undefined4 param_2,undefined4 *param_3,undefined4 *param_4)



{

  undefined4 uVar1;

  int iVar2;

  

  param_1[8] = *param_4;

  uVar1 = param_4[1];

  param_1[9] = uVar1;

  for (iVar2 = 7; param_1 = param_1 + 1, iVar2 != 0; iVar2 = iVar2 + -1) {

    *param_1 = *param_3;

    param_3 = param_3 + 1;

  }

  return CONCAT31((int3)((uint)uVar1 >> 8),1);

}





// --- FUN_0054fe80 at 0x0054FE80 (size: 4) ---


undefined4 __fastcall FUN_0054fe80(int param_1)



{

  return *(undefined4 *)(param_1 + 0x78);

}





// --- FUN_0054fe90 at 0x0054FE90 (size: 93) ---


undefined4 * __thiscall FUN_0054fe90(undefined4 *param_1,undefined4 *param_2)



{

  *param_1 = *param_2;

  FUN_00425f10(param_2 + 1);

  param_1[0x11] = param_2[0x11];

  param_1[0x12] = param_2[0x12];

  param_1[0x13] = param_2[0x13];

  param_1[0x14] = param_2[0x14];

  param_1[0x15] = param_2[0x15];

  param_1[0x16] = param_2[0x16];

  param_1[0x17] = param_2[0x17];

  param_1[0x18] = param_2[0x18];

  param_1[0x19] = param_2[0x19];

  return param_1;

}





// --- FUN_0054fef0 at 0x0054FEF0 (size: 66) ---


undefined4 * __thiscall FUN_0054fef0(undefined4 *param_1,undefined4 *param_2)



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  

  puVar2 = param_2;

  puVar3 = param_1;

  for (iVar1 = 0x1a; iVar1 != 0; iVar1 = iVar1 + -1) {

    *puVar3 = *puVar2;

    puVar2 = puVar2 + 1;

    puVar3 = puVar3 + 1;

  }

  param_1[0x1a] = param_2[0x1a];

  param_1[0x1b] = param_2[0x1b];

  FUN_0054fe90(param_2 + 0x1c);

  param_1[0x36] = param_2[0x36];

  return param_1;

}





// --- FUN_0054ff40 at 0x0054FF40 (size: 299) ---


void __fastcall FUN_0054ff40(int *param_1)



{

  int iVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  uint local_e4;

  undefined4 local_dc [26];

  undefined4 local_74;

  undefined4 local_70;

  undefined1 local_6c [4];

  undefined4 local_68;

  undefined4 local_64;

  undefined4 local_60;

  undefined4 local_5c;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  undefined4 local_4;

  

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000U) != 0x80000000) {

    if (*param_1 != 0) {

      local_e4 = param_1[1] & 0x7fffffff;

      if (-1 < (int)(local_e4 - 1)) {

        iVar3 = (local_e4 - 1) * 0xdc;

        do {

          local_68 = 0x3f800000;

          local_64 = 0;

          local_60 = 0;

          local_5c = 0;

          local_34 = 0;

          local_30 = 0;

          local_2c = 0;

          FUN_00535b30();

          puVar2 = (undefined4 *)(*param_1 + iVar3);

          puVar4 = local_dc;

          puVar5 = puVar2;

          for (iVar1 = 0x1a; iVar1 != 0; iVar1 = iVar1 + -1) {

            *puVar5 = *puVar4;

            puVar4 = puVar4 + 1;

            puVar5 = puVar5 + 1;

          }

          puVar2[0x1a] = local_74;

          puVar2[0x1b] = local_70;

          FUN_0054fe90(local_6c);

          iVar3 = iVar3 + -0xdc;

          local_e4 = local_e4 - 1;

          puVar2[0x36] = local_4;

        } while (local_e4 != 0);

      }

    }

    return;

  }

  if (*param_1 != 0) {

    operator_delete__((void *)(*param_1 + -4));

  }

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





