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

// --- FUN_00410220 at 0x00410220 (size: 122) ---


int FUN_00410220(char *param_1)



{

  char cVar1;

  char *pcVar2;

  int iVar3;

  int iVar4;

  

  iVar3 = 0;

  cVar1 = *param_1;

  pcVar2 = param_1;

  do {

    if (cVar1 == '\0') {

      if (*param_1 != '\0') {

        iVar4 = 0;

        pcVar2 = param_1;

        do {

          pcVar2 = pcVar2 + 1;

          iVar4 = iVar4 + 1;

        } while (*pcVar2 != '\0');

        if (iVar4 != 0) {

          printf("%0.*s",iVar4,param_1);

          iVar3 = iVar3 + iVar4;

        }

      }

      return iVar3;

    }

    if (*pcVar2 == '\x1b') {

      iVar4 = (int)pcVar2 - (int)param_1;

      if (iVar4 != 0) {

        printf("%0.*s",iVar4,param_1);

        iVar3 = iVar3 + iVar4;

      }

      iVar4 = FUN_0040ff80(pcVar2);

      if (iVar4 == 0) goto LAB_00410261;

      param_1 = pcVar2 + iVar4;

      pcVar2 = param_1;

    }

    else {

LAB_00410261:

      pcVar2 = pcVar2 + 1;

    }

    cVar1 = *pcVar2;

  } while( true );

}





// --- FUN_004102a0 at 0x004102A0 (size: 97) ---


int FUN_004102a0(undefined4 param_1)



{

  undefined *puVar1;

  int iVar2;

  LONG LVar3;

  

  puVar1 = PTR_DAT_00818344;

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

  iVar2 = FUN_00402390(param_1,&stack0x00000008);

  if (-1 < iVar2) {

    iVar2 = FUN_00410220(puVar1);

  }

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

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

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

  }

  return iVar2;

}





// --- FUN_00410310 at 0x00410310 (size: 49) ---


void FUN_00410310(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

    if ((*(byte *)(param_2 + 4) & 1) != 0) {

      *puVar1 = *param_1;

      return;

    }

    *param_1 = *puVar1;

  }

  return;

}





// --- FUN_00410350 at 0x00410350 (size: 89) ---


void __fastcall FUN_00410350(int *param_1)



{

  int iVar1;

  int iVar2;

  

  param_1[2] = 0;

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

    if (*param_1 != 0) {

      iVar2 = (param_1[1] & 0x7fffffffU) - 1;

      while (-1 < iVar2) {

        iVar1 = *param_1;

        iVar2 = iVar2 + -1;

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

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

      }

    }

    return;

  }

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_004103f0 at 0x004103F0 (size: 164) ---


undefined4 __thiscall FUN_004103f0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

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

    return 0;

  }

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

    if (param_2 != 0) {

      iVar2 = thunk_FUN_005df0f5(param_2 * 8);

      if (iVar2 == 0) {

        return 0;

      }

      if (*param_1 != 0) {

        iVar3 = param_1[2] + -1;

        while (-1 < iVar3) {

          iVar3 = iVar3 + -1;

          iVar1 = *param_1;

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

          *(undefined4 *)(iVar2 + 0xc + iVar3 * 8) = *(undefined4 *)(iVar1 + 0xc + iVar3 * 8);

        }

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

          operator_delete__((void *)*param_1);

        }

      }

      *param_1 = iVar2;

      param_1[1] = param_2 | 0x80000000;

      return 1;

    }

    FUN_00410350();

  }

  return 1;

}





// --- FUN_004104a0 at 0x004104A0 (size: 93) ---


undefined1 __thiscall FUN_004104a0(int *param_1,uint param_2,char param_3)



{

  int iVar1;

  char cVar2;

  uint uVar3;

  

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

    uVar3 = param_2;

    if (param_3 == '\0') {

      uVar3 = FUN_004077f0(param_2);

    }

    cVar2 = FUN_004103f0(uVar3);

    if (cVar2 == '\0') {

      return 0;

    }

  }

  else {

    uVar3 = param_2;

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

      do {

        iVar1 = *param_1;

        *(undefined4 *)(iVar1 + uVar3 * 8) = 0;

        *(undefined4 *)(iVar1 + 4 + uVar3 * 8) = 0;

        uVar3 = uVar3 + 1;

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

    }

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_00410500 at 0x00410500 (size: 132) ---


bool __thiscall FUN_00410500(int param_1,int param_2,int param_3)



{

  uint uVar1;

  char cVar2;

  uint uVar3;

  undefined4 uVar4;

  int *piVar5;

  

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

  uVar3 = 0;

  if (uVar1 != 0) {

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

    do {

      if (*piVar5 == param_2) {

        if (uVar3 != 0xffffffff) {

          return (*(int **)(param_1 + 4))[uVar3 * 2 + 1] == param_3;

        }

        break;

      }

      uVar3 = uVar3 + 1;

      piVar5 = piVar5 + 2;

    } while (uVar3 < uVar1);

  }

  uVar3 = *(int *)(param_1 + 0xc) + 1;

  if ((*(uint *)(param_1 + 8) & 0x7fffffff) < uVar3) {

    uVar4 = FUN_004077f0(uVar3);

    cVar2 = FUN_004103f0(uVar4);

    if (cVar2 == '\0') goto LAB_00410557;

  }

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

LAB_00410557:

  *(int *)(*(int *)(param_1 + 4) + uVar1 * 8) = param_2;

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

  return true;

}





// --- FUN_00410590 at 0x00410590 (size: 157) ---


void __thiscall FUN_00410590(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  

  uVar3 = *(undefined4 *)(param_1 + 0xc);

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      uVar3 = *puVar1;

    }

    else {

      *puVar1 = uVar3;

    }

  }

  if ((*(uint *)(param_2 + 4) >> 2 & 1) == 0) {

    if ((~*(byte *)(param_2 + 4) & 1) != 0) {

      FUN_004104a0(uVar3,1);

    }

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

    while (iVar4 != 0) {

      iVar4 = iVar4 + -1;

      puVar1 = (undefined4 *)(*(int *)(param_1 + 4) + iVar4 * 8);

      FUN_0040ad10(8);

      puVar2 = (undefined4 *)FUN_0040acf0(8);

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

        if ((*(byte *)(param_2 + 4) & 1) == 0) {

          *puVar1 = *puVar2;

          puVar1[1] = puVar2[1];

        }

        else {

          *puVar2 = *puVar1;

          puVar2[1] = puVar1[1];

        }

      }

    }

  }

  return;

}





// --- FUN_00410630 at 0x00410630 (size: 188) ---


undefined4 FUN_00410630(int param_1)



{

  char cVar1;

  undefined4 uVar2;

  uint *puVar3;

  undefined4 uVar4;

  uint uVar5;

  

  uVar2 = 0xffffffff;

  if ((~(byte)(*(uint *)(param_1 + 4) >> 2) & 1) != 0) {

    uVar2 = FUN_0040a8d0();

    uVar5 = 0x4d676963;

    FUN_0040ad10(4);

    puVar3 = (uint *)FUN_0040acf0(4);

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

      if ((*(byte *)(param_1 + 4) & 1) == 0) {

        uVar5 = *puVar3;

      }

      else {

        *puVar3 = 0x4d676963;

      }

    }

    if ((~*(byte *)(param_1 + 4) & 1) != 0) {

      if ((int)uVar5 < 0) {

        uVar4 = FUN_0040a8d0();

        FUN_0040a8e0(uVar5 & 0x3fffffff);

        FUN_00410590(param_1);

        FUN_0040a8e0(uVar4);

        return uVar2;

      }

      cVar1 = FUN_00410500(0x436f7265,uVar5 & 0x3fffffff);

      if (cVar1 == '\0') {

        FUN_0040aa50();

      }

    }

  }

  return uVar2;

}





// --- FUN_004106f0 at 0x004106F0 (size: 294) ---


uint __thiscall FUN_004106f0(int param_1,uint param_2,int param_3)



{

  int iVar1;

  int iVar2;

  byte bVar3;

  uint *puVar4;

  uint uVar5;

  uint uVar6;

  

  iVar2 = param_3;

  bVar3 = ~(byte)(*(uint *)(param_3 + 4) >> 2);

  uVar6 = CONCAT31((uint3)(*(uint *)(param_3 + 4) >> 10),bVar3);

  if (((bVar3 & 1) == 0) || (uVar6 = param_2, param_2 == 0xffffffff)) {

    return uVar6 & 0xffffff00;

  }

  puVar4 = (uint *)FUN_0040ac70(param_2,4);

  if (puVar4 == (uint *)0x0) goto LAB_00410786;

  if ((~*(byte *)(iVar2 + 4) & 1) == 0) {

    if (*puVar4 == 0x4d676963) {

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

      if ((iVar1 != 0) && ((iVar1 != 1 || (**(int **)(param_1 + 4) == 0x436f7265)))) {

        if (iVar1 == 1) {

          *puVar4 = 0xd676963;

          *puVar4 = *(uint *)(*(int *)(param_1 + 4) + 4) & 0x3fffffff;

          return ~(*(uint *)(iVar2 + 4) >> 2) & 1;

        }

        *puVar4 = 0x8d676963;

        uVar6 = FUN_0040a8d0();

        *puVar4 = *puVar4 ^ (*puVar4 ^ uVar6) & 0x3fffffff;

        FUN_00410590(iVar2);

        return ~(*(uint *)(iVar2 + 4) >> 2) & 1;

      }

    }

  }

  else {

    uVar6 = *puVar4;

    if (-1 < (int)uVar6) goto LAB_00410786;

    uVar5 = FUN_0040a8d0();

    if (uVar5 == (uVar6 & 0x3fffffff)) {

      FUN_00410310(&param_3,iVar2);

      FUN_0040acf0(param_3 * 8);

      return ~(*(uint *)(iVar2 + 4) >> 2) & 1;

    }

    if (-1 < (int)uVar6) goto LAB_00410786;

  }

  FUN_0040aa50();

LAB_00410786:

  return ~(*(uint *)(iVar2 + 4) >> 2) & 1;

}





// --- FUN_00410820 at 0x00410820 (size: 81) ---


void __thiscall FUN_00410820(int *param_1,int *param_2,int *param_3)



{

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

    *param_2 = *param_1;

    if (*param_1 != 0) {

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

      *param_1 = (int)param_2;

      param_2[1] = 0;

      return;

    }

    param_1[1] = (int)param_2;

    *param_1 = (int)param_2;

    param_2[1] = 0;

    return;

  }

  *param_2 = *param_3;

  if (*param_3 != 0) {

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

    *param_3 = (int)param_2;

    param_2[1] = (int)param_3;

    return;

  }

  param_1[1] = (int)param_2;

  *param_3 = (int)param_2;

  param_2[1] = (int)param_3;

  return;

}





// --- FUN_00410880 at 0x00410880 (size: 80) ---


void __thiscall FUN_00410880(int *param_1,int *param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  if ((int *)param_2[1] == (int *)0x0) {

    iVar1 = *(int *)*param_1;

    *param_1 = iVar1;

    if (iVar1 != 0) {

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

    }

  }

  else {

    *(int *)param_2[1] = *param_2;

  }

  if (*param_2 != 0) {

    *(int *)(*param_2 + 4) = param_2[1];

    *param_2 = 0;

    param_2[1] = 0;

    return;

  }

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

  param_1[1] = (int)puVar2;

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

    *puVar2 = 0;

  }

  *param_2 = 0;

  param_2[1] = 0;

  return;

}





// --- FUN_004108d0 at 0x004108D0 (size: 149) ---


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



{

  undefined4 *puVar1;

  int *piVar2;

  undefined4 **ppuVar3;

  undefined4 *local_18;

  undefined4 *local_14 [5];

  

  piVar2 = &DAT_00795700;

  local_18 = &DAT_00795700;

  local_14[0] = (undefined4 *)0x0;

  local_14[1] = &DAT_00795710;

  local_14[2] = (undefined4 *)0x0;

  local_14[3] = (undefined4 *)0x0;

  local_14[4] = (undefined4 *)0x0;

  ppuVar3 = &local_18;

  while ((((*piVar2 != *param_3 || (piVar2[1] != param_3[1])) || (piVar2[2] != param_3[2])) ||

         (piVar2[3] != param_3[3]))) {

    piVar2 = ppuVar3[2];

    ppuVar3 = ppuVar3 + 2;

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

      *param_2 = 0x80004002;

      return;

    }

  }

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

    puVar1 = ppuVar3[1];

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

    *param_4 = (int)puVar1 + param_1;

  }

  *param_2 = 0;

  return;

}





// --- FUN_00410a00 at 0x00410A00 (size: 133) ---


int * __thiscall FUN_00410a00(int *param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  char cVar3;

  undefined4 *puVar4;

  uint uVar5;

  undefined4 *puVar6;

  

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

    param_1[2] = 0;

    cVar3 = FUN_004103f0(param_2[1] & 0x7fffffff);

    if (cVar3 == '\0') {

      return param_1;

    }

  }

  puVar4 = (undefined4 *)*param_2;

  puVar1 = puVar4 + param_2[2] * 2;

  puVar6 = (undefined4 *)*param_1;

  for (; puVar4 < puVar1; puVar4 = puVar4 + 2) {

    *puVar6 = *puVar4;

    puVar6[1] = puVar4[1];

    puVar6 = puVar6 + 2;

  }

  uVar5 = param_2[2];

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

    do {

      iVar2 = *param_1;

      *(undefined4 *)(iVar2 + uVar5 * 8) = 0;

      *(undefined4 *)(iVar2 + 4 + uVar5 * 8) = 0;

      uVar5 = uVar5 + 1;

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

  }

  param_1[2] = param_2[2];

  return param_1;

}





// --- FUN_00410a90 at 0x00410A90 (size: 82) ---


void __fastcall FUN_00410a90(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  uint local_8;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

  local_4 = *(undefined4 *)(param_1 + 0x68);

  local_8 = local_8 & 0xffffff00;

  puVar2 = (undefined4 *)FUN_004064a0(PTR_DAT_00818554,PTR_DAT_00818558,&local_4,local_8,0);

  if ((puVar2 != (undefined4 *)puVar1) || (puVar2 = puVar2 + -1, puVar2 != (undefined4 *)puVar1)) {

    puVar2 = puVar2 + 1;

  }

  FUN_00410b30(*puVar2);

  return;

}





// --- FUN_00410af0 at 0x00410AF0 (size: 58) ---


int __thiscall FUN_00410af0(int param_1,uint param_2,undefined4 *param_3)



{

  uint *puVar1;

  uint3 uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x6c) + (param_2 % *(uint *)(param_1 + 0x74)) * 4);

  uVar2 = (uint3)((uint)*(int *)(param_1 + 0x6c) >> 8);

  do {

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

LAB_00410b11:

      return (uint)uVar2 << 8;

    }

    if (*puVar1 == param_2) {

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

        *param_3 = puVar1 + 4;

        return CONCAT31(uVar2,1);

      }

      goto LAB_00410b11;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00410b30 at 0x00410B30 (size: 234) ---


undefined4 __thiscall FUN_00410b30(int param_1,int param_2)



{

  int iVar1;

  uint *puVar2;

  int *piVar3;

  undefined4 *puVar4;

  uint uVar5;

  uint *puVar6;

  

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

    return 0;

  }

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

  puVar2 = (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_0065ec90(param_2);

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

        puVar6 = (uint *)puVar2[1];

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

          FUN_00410a90();

        }

        uVar5 = *puVar2 % *(uint *)(param_1 + 0x68);

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

        puVar2[1] = *(uint *)(iVar1 + uVar5 * 4);

        *(uint **)(iVar1 + uVar5 * 4) = puVar2;

        uVar5 = iVar1 + uVar5 * 4;

        if (uVar5 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar5;

        }

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

        puVar2 = puVar6;

      }

      return 1;

    }

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

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

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

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

        puVar6 = (uint *)*puVar4;

        goto LAB_00410b7e;

      }

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

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

    }

    puVar4 = (undefined4 *)0x0;

    puVar6 = (uint *)0x0;

LAB_00410b7e:

    FUN_00410d00(param_1,puVar4,puVar6);

    puVar6[1] = (uint)puVar2;

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

    puVar2 = puVar6;

  } while( true );

}





// --- FUN_00410c20 at 0x00410C20 (size: 117) ---


uint __thiscall FUN_00410c20(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

  puVar1 = *(uint **)(*(uint *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

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

LAB_00410c4b:

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

        FUN_00410a90();

      }

      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;

      }

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

      return CONCAT31((int3)(uVar3 >> 8),1);

    }

    if (*puVar1 == *param_2) {

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

        return *(uint *)(param_1 + 0x60) & 0xffffff00;

      }

      goto LAB_00410c4b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00410ca0 at 0x00410CA0 (size: 82) ---


undefined4 __thiscall FUN_00410ca0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

  do {

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

LAB_00410ccb:

      FUN_00410c20(param_2);

      FUN_00410820(param_2 + 2,*(undefined4 *)(param_1 + 0x74));

      return 1;

    }

    if (*puVar1 == *param_2) {

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

        return 0;

      }

      goto LAB_00410ccb;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00410d00 at 0x00410D00 (size: 58) ---


void __thiscall FUN_00410d00(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 + 4);

    } while (iVar2 != param_4);

    if (iVar1 != 0) {

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

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

      return;

    }

  }

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

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

  return;

}





// --- FUN_00410d40 at 0x00410D40 (size: 146) ---


void __thiscall FUN_00410d40(int param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  

  *(int *)(param_1 + 0xe4) = *(int *)(param_1 + 0xe4) + 2;

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

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

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

    FUN_00410ca0((undefined4 *)(param_1 + 0x84));

    *param_2 = uVar1;

    return;

  }

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

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

    *puVar2 = uVar1;

    puVar2[1] = 0;

    puVar2[2] = 0;

    puVar2[3] = 0;

    puVar2[4] = &PTR_LAB_00795430;

    puVar2[5] = puVar2 + 8;

    puVar2[6] = 8;

    puVar2[7] = 0;

    FUN_00410ca0(puVar2);

    *param_2 = uVar1;

    return;

  }

  FUN_00410ca0(0);

  *param_2 = uVar1;

  return;

}





// --- FUN_00410de0 at 0x00410DE0 (size: 136) ---


void __thiscall FUN_00410de0(int param_1,undefined4 *param_2,int param_3)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  

  *(int *)(param_1 + 0xe4) = *(int *)(param_1 + 0xe4) + 2;

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

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

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

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

  }

  else {

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

    puVar3 = (undefined4 *)0x0;

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

      puVar2[1] = 0;

      *puVar2 = uVar1;

      puVar2[2] = 0;

      puVar2[3] = 0;

      puVar2[4] = &PTR_LAB_00795430;

      puVar2[7] = 0;

      puVar2[5] = puVar2 + 8;

      puVar2[6] = 8;

      puVar3 = puVar2;

    }

  }

  FUN_00410a00(param_3 + 4);

  FUN_00410ca0(puVar3);

  *param_2 = uVar1;

  return;

}





// --- FUN_00410e70 at 0x00410E70 (size: 81) ---


uint * __thiscall FUN_00410e70(int param_1,uint *param_2)



{

  uint *puVar1;

  uint uVar2;

  

  uVar2 = *param_2 % *(uint *)(param_1 + 0x68);

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + uVar2 * 4);

  while( true ) {

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

      return (uint *)0x0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return (uint *)0x0;

  }

  FUN_00410d00(param_1,*(int *)(param_1 + 0x60) + uVar2 * 4,puVar1);

  return puVar1;

}





// --- FUN_00410ed0 at 0x00410ED0 (size: 83) ---


uint * __thiscall FUN_00410ed0(int param_1,uint *param_2)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

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

    while (*puVar1 != *param_2) {

      puVar1 = (uint *)puVar1[1];

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

        return (uint *)0x0;

      }

    }

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

      FUN_00410880(puVar1 + 2);

      FUN_00410e70(param_2);

    }

  }

  return puVar1;

}





// --- FUN_00410f30 at 0x00410F30 (size: 85) ---


undefined4 __fastcall FUN_00410f30(int param_1)



{

  void *pvVar1;

  

  pvVar1 = (void *)FUN_00410ed0(&stack0x00000004);

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

    if (pvVar1 != (void *)(param_1 + 0x84)) {

      if ((*(uint *)((int)pvVar1 + 0x18) & 0x80000000) == 0x80000000) {

        operator_delete__(*(void **)((int)pvVar1 + 0x14));

      }

      operator_delete(pvVar1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_00410f90 at 0x00410F90 (size: 289) ---


void __fastcall FUN_00410f90(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  uint *puVar3;

  uint *puVar4;

  uint *puVar5;

  uint *puVar6;

  uint uVar7;

  uint *local_8;

  

  if ((*(int *)(param_1 + 0x78) != 0) && (*(int *)(param_1 + 0x7c) != 0)) {

    local_8 = (uint *)(*(int *)(param_1 + 0x7c) + -8);

joined_r0x00410fb1:

    puVar4 = local_8;

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

      puVar6 = puVar4 + 2;

      if (puVar4[2] == 0) {

        local_8 = (uint *)0x0;

      }

      else {

        local_8 = (uint *)(puVar4[2] - 8);

      }

      if ((uint *)puVar4[3] == (uint *)0x0) {

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

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

        if (iVar1 != 0) {

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

        }

      }

      else {

        *(uint *)puVar4[3] = *puVar6;

      }

      if (*puVar6 == 0) {

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

        *(undefined4 **)(param_1 + 0x80) = puVar2;

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

          *puVar2 = 0;

        }

      }

      else {

        *(uint *)(*puVar6 + 4) = puVar4[3];

      }

      *puVar6 = 0;

      puVar4[3] = 0;

      uVar7 = *puVar4 % *(uint *)(param_1 + 0x74);

      puVar6 = *(uint **)(*(int *)(param_1 + 0x6c) + uVar7 * 4);

      for (puVar3 = puVar6; puVar3 != (uint *)0x0; puVar3 = (uint *)puVar3[1]) {

        if (*puVar3 == *puVar4) {

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

            if (puVar6 != puVar3) goto LAB_00411050;

            goto LAB_0041105d;

          }

          break;

        }

      }

      goto LAB_0041106e;

    }

  }

  return;

LAB_00411050:

  do {

    puVar5 = puVar6;

    puVar6 = (uint *)puVar5[1];

  } while (puVar6 != puVar3);

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

LAB_0041105d:

    *(uint *)(*(int *)(param_1 + 0x6c) + uVar7 * 4) = puVar6[1];

  }

  else {

    puVar5[1] = puVar6[1];

  }

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

LAB_0041106e:

  if (puVar4 != (uint *)(param_1 + 0x84)) {

    if ((puVar4[6] & 0x80000000) == 0x80000000) {

      operator_delete__((void *)puVar4[5]);

    }

    operator_delete(puVar4);

  }

  goto joined_r0x00410fb1;

}





// --- FUN_004110c0 at 0x004110C0 (size: 96) ---


void __fastcall FUN_004110c0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_00795434;

  FUN_00410f90();

  if ((param_1[0x27] & 0x80000000) == 0x80000000) {

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

  }

  param_1[3] = &PTR_FUN_0079542c;

  if ((undefined4 *)param_1[0x1b] != param_1 + 4) {

    operator_delete__((undefined4 *)param_1[0x1b]);

  }

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[1] = &PTR_LAB_00793b6c;

  return;

}





// --- FUN_00411120 at 0x00411120 (size: 25) ---


PVOID __fastcall FUN_00411120(LPCVOID param_1)



{

  _MEMORY_BASIC_INFORMATION local_1c;

  

  VirtualQuery(param_1,&local_1c,0x1c);

  return local_1c.AllocationBase;

}





// --- FUN_00411140 at 0x00411140 (size: 73) ---


void __fastcall FUN_00411140(LONG *param_1)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  iVar1 = InterlockedExchange(param_1,1);

  while (iVar1 != 0) {

    iVar1 = *param_1;

    while (iVar1 != 0) {

      uVar2 = uVar2 + 1;

      if (0x1ff < uVar2) {

        Sleep(0);

        uVar2 = 0;

      }

      iVar1 = *param_1;

    }

    iVar1 = InterlockedExchange(param_1,1);

  }

  return;

}





// --- FUN_00411190 at 0x00411190 (size: 17) ---


void __fastcall FUN_00411190(int param_1)



{

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

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

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

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

  return;

}





// --- FUN_004111b0 at 0x004111B0 (size: 203) ---


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



void __fastcall FUN_004111b0(double *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  BOOL BVar3;

  DWORD DVar4;

  double dVar5;

  LARGE_INTEGER local_8;

  

  BVar3 = QueryPerformanceFrequency(&local_8);

  uVar2 = local_8.s.HighPart;

  uVar1 = local_8.s.LowPart;

  if (BVar3 != 0) {

    dVar5 = (double)__alldiv(local_8.s.LowPart,local_8.s.HighPart,1000,0);

    param_1[1] = dVar5;

    dVar5 = (double)__alldiv(uVar1,uVar2,2,0);

    *param_1 = (double)CONCAT44(local_8.s.HighPart,local_8.s.LowPart);

    param_1[2] = dVar5;

    QueryPerformanceCounter(&local_8);

  }

  FUN_00411140();

  dVar5 = _DAT_00795610;

  if (((ulonglong)param_1[4] & 1) == 0) {

    *(DWORD *)(param_1 + 7) = local_8.s.LowPart;

    *(LONG *)((int)param_1 + 0x3c) = local_8.s.HighPart;

    param_1[3] = dVar5;

    param_1[5] = _DAT_00795610;

    DVar4 = timeGetTime();

    *(DWORD *)(param_1 + 6) = DVar4;

    if (BVar3 != 0) {

      *(uint *)(param_1 + 4) = *(uint *)(param_1 + 4) & 0xfffffffd;

    }

    else {

      *(uint *)(param_1 + 4) = *(uint *)(param_1 + 4) | 2;

    }

    *(uint *)(param_1 + 4) = *(uint *)(param_1 + 4) | 1;

  }

  InterlockedExchange((LONG *)(param_1 + 8),0);

  return;

}





// --- FUN_00411280 at 0x00411280 (size: 489) ---


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



float10 __thiscall FUN_00411280(double *param_1,char param_2)



{

  double dVar1;

  DWORD DVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  uint uVar6;

  double *pdVar7;

  double *pdVar8;

  uint uVar9;

  double *pdVar10;

  undefined8 uVar11;

  LARGE_INTEGER local_38;

  double local_30;

  uint local_28;

  double local_20;

  DWORD local_18;

  uint local_10;

  int local_c;

  

  FUN_00411140();

  pdVar10 = param_1 + 3;

  pdVar7 = pdVar10;

  pdVar8 = &local_30;

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

    *(undefined4 *)pdVar8 = *(undefined4 *)pdVar7;

    pdVar7 = (double *)((int)pdVar7 + 4);

    pdVar8 = (double *)((int)pdVar8 + 4);

  }

  InterlockedExchange((LONG *)(param_1 + 8),0);

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

    DVar2 = timeGetTime();

    uVar4 = DVar2 - local_18;

    if ((local_28 & 2) == 0) {

      QueryPerformanceCounter(&local_38);

      uVar9 = local_38.s.LowPart - local_10;

      uVar6 = (local_38.s.HighPart - local_c) - (uint)(local_38.s.LowPart < local_10);

      uVar11 = __allmul(*(undefined4 *)(param_1 + 1),*(undefined4 *)((int)param_1 + 0xc),uVar4,0);

      uVar5 = (int)((ulonglong)uVar11 >> 0x20) + *(int *)((int)param_1 + 0x14) +

              (uint)CARRY4((uint)uVar11,*(uint *)(param_1 + 2));

      if ((uVar5 < uVar6) || ((uVar5 <= uVar6 && ((uint)uVar11 + *(int *)(param_1 + 2) <= uVar9))))

      {

        dVar1 = (double)(int)uVar4;

        local_28 = local_28 | 2;

        if ((int)uVar4 < 0) {

          dVar1 = dVar1 + _DAT_00795518;

        }

        dVar1 = dVar1 * _DAT_00795720 + local_20;

        if (DAT_008379dd == '\0') {

          DAT_008379dd = '\x01';

        }

        if ((param_2 != '\0') && (DAT_008379dc == '\0')) {

          DAT_008379dc = '\x01';

        }

      }

      else {

        dVar1 = (-(double)(longlong)(((ulonglong)uVar6 & 0x80000000) << 0x20) +

                (double)(CONCAT44(uVar6,uVar9) & 0x7fffffffffffffff)) / *param_1 + local_20;

      }

    }

    else {

      dVar1 = (double)(int)uVar4;

      if ((int)uVar4 < 0) {

        dVar1 = dVar1 + _DAT_00795518;

      }

      dVar1 = dVar1 * _DAT_00795720 + local_20;

    }

    if ((local_30 < dVar1) && (local_30 = dVar1, 9999 < uVar4)) {

      local_10 = local_38.s.LowPart;

      local_c = local_38.s.HighPart;

      local_20 = dVar1;

      local_18 = DVar2;

    }

    FUN_00411140();

    if (local_30 <= *pdVar10) {

      local_30 = *pdVar10;

    }

    else if (param_2 == '\0') {

      *pdVar10 = local_30;

    }

    else {

      pdVar7 = &local_30;

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

        *(undefined4 *)pdVar10 = *(undefined4 *)pdVar7;

        pdVar7 = (double *)((int)pdVar7 + 4);

        pdVar10 = (double *)((int)pdVar10 + 4);

      }

    }

    InterlockedExchange((LONG *)(param_1 + 8),0);

    return (float10)local_30;

  }

  return (float10)_DAT_00795610;

}





// --- FUN_00411470 at 0x00411470 (size: 25) ---


void __fastcall FUN_00411470(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_00795824;

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

    (**(code **)(*DAT_00837ff4 + 0x3c))(param_1);

  }

  return;

}





// --- FUN_00411490 at 0x00411490 (size: 47) ---


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



{

  *param_1 = &PTR_FUN_00795824;

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

    (**(code **)(*DAT_00837ff4 + 0x3c))(param_1);

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004114c0 at 0x004114C0 (size: 6) ---


undefined4 FUN_004114c0(void)



{

  return DAT_008379e4;

}





// --- FUN_004114d0 at 0x004114D0 (size: 143) ---


void __fastcall FUN_004114d0(int param_1)



{

  if (*(int **)(param_1 + 0xb0) != (int *)0x0) {

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

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

  }

  if (DAT_0083e03c != 0) {

    FUN_0045f200();

    FUN_00459310();

  }

  if (*(int **)(param_1 + 0x118) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0x118) + 0x1c))();

    if (*(int **)(param_1 + 0x118) != (int *)0x0) {

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

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

    }

  }

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

    FUN_004538e0(*(int *)(param_1 + 0x120));

  }

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

    (**(code **)(*DAT_00837ff4 + 0x3c))(param_1 + 0x24);

  }

  FUN_0043a370();

  FUN_00557ba0();

                    /* WARNING: Could not recover jumptable at 0x00411559. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  CoUninitialize();

  return;

}





// --- FUN_00411560 at 0x00411560 (size: 30) ---


void __fastcall FUN_00411560(int param_1)



{

  if (*(int **)(param_1 + 0xac) != (int *)0x0) {

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

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

  }

  return;

}





// --- FUN_004115d0 at 0x004115D0 (size: 24) ---


undefined4 __fastcall FUN_004115d0(int param_1)



{

  FUN_00541640(1,param_1 + 0x74,0,0);

  return 1;

}





// --- FUN_004115f0 at 0x004115F0 (size: 50) ---


undefined4 __fastcall FUN_004115f0(int param_1)



{

  undefined4 in_EAX;

  undefined3 uVar1;

  undefined3 extraout_var;

  

  uVar1 = (undefined3)((uint)in_EAX >> 8);

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

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

      FUN_00544ab0();

    }

    (**(code **)(**(int **)(param_1 + 0xac) + 0x20))();

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

    uVar1 = extraout_var;

  }

  return CONCAT31(uVar1,1);

}





// --- FUN_00411630 at 0x00411630 (size: 107) ---


void __fastcall FUN_00411630(int param_1)



{

  char cVar1;

  

  FUN_0040fbd0();

  cVar1 = FUN_00439e50();

  if (cVar1 != '\0') {

    FUN_00543fc0();

    return;

  }

  FUN_00543440();

  (**(code **)(*(int *)(*(int *)(param_1 + 0xac) + 4) + 0x48))();

  FUN_0045d0b0();

  FUN_004554b0();

  FUN_0043e690();

  thunk_FUN_0043dc70();

  FUN_00455610();

  FUN_0043fcd0(1);

  FUN_004392b0();

  return;

}





// --- FUN_004116d0 at 0x004116D0 (size: 4) ---


float10 __fastcall FUN_004116d0(int param_1)



{

  return (float10)*(float *)(param_1 + 0x1c);

}





// --- FUN_004116e0 at 0x004116E0 (size: 69) ---


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



float10 __thiscall FUN_004116e0(int param_1,uint *param_2)



{

  uint uVar1;

  float10 fVar2;

  

  uVar1 = (uint)(*(int *)(param_1 + 8) == 3);

  *param_2 = uVar1;

  if (uVar1 == 0) {

    fVar2 = (float10)_DAT_00795610;

  }

  else {

    fVar2 = (float10)_DAT_008379a8 - (float10)*(double *)(param_1 + 0x10);

  }

  if ((*(int *)(param_1 + 0x2c) != 0) && ((float10)_DAT_00795870 < fVar2)) {

    fVar2 = (float10)_DAT_00795870;

  }

  return fVar2;

}





// --- FUN_00411760 at 0x00411760 (size: 67) ---


uint FUN_00411760(undefined4 param_1)



{

  int *piVar1;

  undefined *puVar2;

  undefined4 uVar3;

  uint *puVar4;

  uint local_8;

  int local_4;

  

  puVar4 = &local_8;

  uVar3 = 0;

  puVar2 = &DAT_00795814;

  piVar1 = &local_4;

  local_8 = 0;

  FUN_00406d10(piVar1,param_1,&DAT_00795814,0,&local_8);

  FUN_00406650(piVar1,param_1,puVar2,uVar3,puVar4);

  return (local_4 < 0) - 1 & local_8;

}





// --- FUN_004117b0 at 0x004117B0 (size: 68) ---


void __thiscall FUN_004117b0(int *param_1,int *param_2,uint param_3)



{

  int iVar1;

  uint uVar2;

  

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

  if ((uVar2 <= param_3) && (3 < param_3)) {

    *(int *)*param_2 = param_1[1];

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    if (3 < param_3 - 4) {

      *(int *)(iVar1 + 4) = param_1[2];

      *param_2 = *param_2 + 4;

    }

  }

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

  return;

}





// --- FUN_00411800 at 0x00411800 (size: 70) ---


undefined4 __thiscall FUN_00411800(int *param_1,int *param_2,uint param_3)



{

  int iVar1;

  uint uVar2;

  

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

  if (param_3 < uVar2) {

    return 0;

  }

  if (3 < param_3) {

    param_1[1] = *(int *)*param_2;

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    if (3 < param_3 - 4) {

      param_1[2] = *(int *)(iVar1 + 4);

      *param_2 = *param_2 + 4;

    }

  }

  return 1;

}





// --- FUN_00411850 at 0x00411850 (size: 26) ---


int * __fastcall FUN_00411850(int *param_1)



{

  LONG *lpAddend;

  

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

  *param_1 = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  return param_1;

}





// --- FUN_00411870 at 0x00411870 (size: 90) ---


void __fastcall FUN_00411870(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  uint uVar3;

  uint uVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  puVar1 = (undefined4 *)*param_1;

  if (puVar1[1] == 1) {

    puVar1[4] = 0xffffffff;

    return;

  }

  FUN_00403560(puVar1[2] + -1);

  uVar4 = *(uint *)(*param_1 + 8);

  puVar5 = puVar1 + 5;

  puVar6 = (undefined4 *)(*param_1 + 0x14);

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

    *puVar6 = *puVar5;

    puVar5 = puVar5 + 1;

    puVar6 = puVar6 + 1;

  }

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

    *(undefined1 *)puVar6 = *(undefined1 *)puVar5;

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

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

  }

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return;

}





// --- FUN_004118d0 at 0x004118D0 (size: 163) ---


void __fastcall FUN_004118d0(int *param_1)



{

  void *pvVar1;

  

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

  FUN_00557170();

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

  FUN_00422210();

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

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

  if ((undefined4 *)param_1[0x42] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[0x42])(1);

  }

  param_1[0x42] = 0;

  if ((undefined4 *)param_1[0x41] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[0x41])(1);

  }

  param_1[0x41] = 0;

  FUN_00406d10();

  pvVar1 = DAT_00837740;

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

    FUN_00406bf0();

    operator_delete(pvVar1);

    DAT_00837740 = (void *)0x0;

    DAT_00837744 = 1;

  }

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

  thunk_FUN_00550ec0();

  return;

}





// --- FUN_00411aa0 at 0x00411AA0 (size: 102) ---


undefined4 __thiscall FUN_00411aa0(int param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)FUN_005df0f5(8);

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

    puVar1 = (undefined4 *)0x0;

  }

  else {

    *puVar1 = 0;

    puVar1[1] = 0;

  }

  iVar2 = (short)param_2 * 4;

  *(undefined4 **)(iVar2 + *(int *)(param_1 + 300)) = puVar1;

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

  if (iVar2 != 0) {

    iVar2 = FUN_00541780(param_2,iVar2);

    if (iVar2 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00411b50 at 0x00411B50 (size: 77) ---


void __thiscall FUN_00411b50(int param_1,int *param_2)



{

  int iVar1;

  LONG LVar2;

  

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

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

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

                    /* WARNING: Could not recover jumptable at 0x00411b92. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

    return;

  }

  return;

}





// --- FUN_00411c20 at 0x00411C20 (size: 156) ---


void __fastcall FUN_00411c20(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  int *piVar4;

  LONG LVar5;

  undefined4 *puVar6;

  

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

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

    iVar2 = *piVar1;

    while (iVar2 != 0) {

      puVar3 = (undefined4 *)*piVar1;

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

        puVar6 = (undefined4 *)0x0;

      }

      else {

        iVar2 = puVar3[1];

        *piVar1 = iVar2;

        if (iVar2 == 0) {

          piVar1[1] = 0;

        }

        puVar6 = (undefined4 *)*puVar3;

        operator_delete(puVar3);

      }

      piVar1 = (int *)puVar6[0xb];

      if (((piVar1 != (int *)0x0) && (3 < (uint)puVar6[0xc])) && (*piVar1 == 0xf7de)) {

        iVar2 = piVar1[1];

        FUN_00556f40();

        piVar4 = (int *)FUN_00557440();

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

          (**(code **)(*piVar4 + 0xc))(piVar4,iVar2,piVar1 + 2);

        }

      }

      LVar5 = InterlockedDecrement(puVar6 + 1);

      if (LVar5 == 0) {

        (**(code **)*puVar6)(1);

      }

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

      iVar2 = *piVar1;

    }

  }

  return;

}





// --- FUN_00411d90 at 0x00411D90 (size: 126) ---


void __thiscall

FUN_00411d90(int param_1,int *param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5,

            undefined4 param_6,undefined4 param_7)



{

  int *piVar1;

  char cVar2;

  int iVar3;

  

  piVar1 = param_2;

  if (param_1 != 0) {

    FUN_004369a0(param_1,2,param_2,param_3,param_4,param_5,param_6,param_7);

  }

  if (DAT_008380c8 == 0) {

    iVar3 = FUN_005df0f5(0x8100);

    if (iVar3 == 0) {

      DAT_008380c8 = 0;

    }

    else {

      DAT_008380c8 = FUN_00433d20();

    }

  }

  cVar2 = FUN_00433710(piVar1,&param_2);

  if ((cVar2 != '\0') && (iVar3 = (**(code **)(*param_2 + 0x44))(), iVar3 != 0)) {

    *(undefined1 *)(iVar3 + 0x28) = 1;

  }

  return;

}





// --- FUN_00411e10 at 0x00411E10 (size: 106) ---


void __fastcall FUN_00411e10(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

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

  param_1[0xf] = 0;

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

  param_1[0xc] = 0;

  puVar1 = (undefined4 *)param_1[8];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[4];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00411fa0 at 0x00411FA0 (size: 126) ---


undefined4 __fastcall FUN_00411fa0(int param_1)



{

  char cVar1;

  

  FUN_0040fbd0();

  cVar1 = FUN_00439e50();

  if (cVar1 != '\0') {

    return 0;

  }

  FUN_00543440();

  FUN_00411c20();

  FUN_00541cb0();

  (**(code **)(*(int *)(*(int *)(param_1 + 0xac) + 4) + 0x48))();

  FUN_0045d0b0();

  FUN_004554b0();

  FUN_0043e690();

  thunk_FUN_0043dc70();

  FUN_00455610();

  FUN_0043fcd0(1);

  FUN_004392b0();

  return 1;

}





// --- FUN_00412020 at 0x00412020 (size: 51) ---


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



{

  *param_1 = &PTR_FUN_00795538;

  if (param_1[1] != 0) {

    FUN_0040e340(param_1);

    param_1[1] = 0;

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00412180 at 0x00412180 (size: 288) ---


bool __thiscall FUN_00412180(int *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  char cVar1;

  BOOL BVar2;

  HMODULE hLibModule;

  int iVar3;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  _OSVERSIONINFOA *p_Var4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  _OSVERSIONINFOA _Stack_a0;

  

  _set_new_handler((_func_int_uint *)&LAB_00411580);

  cVar1 = (**(code **)(*param_1 + 0x80))();

  if (cVar1 == '\0') {

    p_Var4 = &_Stack_a0;

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

      p_Var4->dwOSVersionInfoSize = 0;

      p_Var4 = (_OSVERSIONINFOA *)&p_Var4->dwMajorVersion;

    }

    _Stack_a0.dwOSVersionInfoSize = 0x94;

    BVar2 = GetVersionExA(&_Stack_a0);

    if ((BVar2 == 0) || (_Stack_a0.dwPlatformId == 1)) {

      hLibModule = LoadLibraryA("unicows.dll");

      if (hLibModule == (HMODULE)0x0) {

        uVar7 = extraout_ECX;

        FUN_00402730(&DAT_00795320);

        uVar6 = extraout_ECX_00;

        FUN_00402730(&DAT_00795320);

        uVar5 = extraout_ECX_01;

        FUN_00402730(L"UnicoWS.dll");

        FUN_0043d090(0x6d,uVar5,uVar6,uVar7,hLibModule);

        return false;

      }

      FreeLibrary(hLibModule);

    }

    FUN_0040fcd0();

    FUN_0042c800();

    iVar3 = FUN_0054bb50();

    param_1[0x41] = iVar3;

    if (iVar3 != 0) {

      iVar3 = FUN_0054bb70();

      param_1[0x42] = iVar3;

      if (iVar3 != 0) {

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

        cVar1 = (**(code **)(*param_1 + 0x70))();

        if (((cVar1 != '\0') &&

            (cVar1 = (**(code **)(*param_1 + 0x74))(param_3,param_4,param_1[0x1c] != 0),

            cVar1 != '\0')) && (cVar1 = FUN_004221c0(), cVar1 != '\0')) {

          cVar1 = (**(code **)(*param_1 + 0x7c))(param_2);

          return cVar1 != '\0';

        }

      }

    }

  }

  return false;

}





// --- FUN_00412310 at 0x00412310 (size: 259) ---


undefined4 __fastcall FUN_00412310(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_4;

  

  local_4 = param_1;

  FUN_00438fe0(0,param_1 + 100);

  FUN_00438940();

  FUN_00401340("Network Bind Interface");

  FUN_004020e0(&DAT_00837a10,&local_4,0,0,0,0);

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

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

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

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

  }

  FUN_00401340("Flag to compute a unique port");

  FUN_00411d90(&DAT_00837a14,&local_4,0,0,0,0);

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

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

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

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

  }

  FUN_00401340("The user specified port");

  FUN_00402160(&DAT_00837a18,&local_4,0,0,0,0);

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

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

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

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

  }

  FUN_00430d80();

  return 1;

}





// --- FUN_00412420 at 0x00412420 (size: 1070) ---


void __thiscall FUN_00412420(int param_1,int param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_8;

  int local_4;

  

  FUN_00401340("<string>: Specifies the account name to logon with.");

  FUN_00401340("account");

  FUN_00402660(2,0x61,&local_8,&local_4,0,0,0);

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("<32 bitfield>: Controls what kinds of debug outputs are enabled.");

  FUN_00401340("debug");

  FUN_00402660(2,0,&param_2,&local_4,0,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("[host/IP]:Specifies where to find the server to talk to.");

  FUN_00401340(&DAT_00795b68);

  FUN_00402660(0x32,0x68,&param_2,&local_4,param_1 + 0x88,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("<string>: Language to run the client in.");

  FUN_00401340("language");

  FUN_00402660(0x32,0,&param_2,&local_4,param_1 + 0x84,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("<1-65535>: Specify the outgoing network port to use.");

  FUN_00401340("outport");

  FUN_00402660(0x22,0x71,&param_2,&local_4,param_1 + 0x94,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("<1-65535>: Specify the server port to contact. See \'host\'");

  FUN_00401340(&DAT_00795aac);

  FUN_00402660(0x22,0x70,&param_2,&local_4,param_1 + 0x90,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("<string>: Specify the preferences file to use.");

  FUN_00401340("prefs");

  FUN_00402660(0x32,0,&param_2,&local_4,param_1 + 0x60,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("Opens the DAT files readonly");

  FUN_00401340("rodat");

  FUN_00402660(3,0,&param_2,&local_4,0,0,0);

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

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

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

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

  }

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

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

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

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

  }

  FUN_00401340("Enables the use of the memory manager.");

  FUN_00401340("usemem");

  FUN_00402660(0x11,0,&param_2,&local_4,param_1 + 0x68,1,0);

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

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

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

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

  }

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

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

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

  }

  return;

}





// --- FUN_00412850 at 0x00412850 (size: 546) ---


char __thiscall FUN_00412850(int *param_1,undefined4 param_2,int *param_3)



{

  char *_Str;

  char cVar1;

  char cVar2;

  char cVar3;

  LONG LVar4;

  int *piVar5;

  ulong uVar6;

  undefined4 *puVar7;

  int local_4;

  

  cVar1 = FUN_004083f0(param_2,param_3);

  cVar2 = '\0';

  if (cVar1 != '\0') {

    FUN_00401340("account");

    cVar2 = FUN_00401920(&local_4);

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

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

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

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

    }

    if (cVar2 != '\0') {

      FUN_004034c0(*param_3);

      FUN_00411870();

      _strlwr((char *)(param_1[0x1c] + 0x14));

      return cVar1;

    }

    FUN_00401340("debug");

    cVar2 = FUN_00401920(&local_4);

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

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

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

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

    }

    if (cVar2 != '\0') {

      _Str = (char *)*param_3;

      piVar5 = _errno();

      *piVar5 = 0;

      uVar6 = strtoul(_Str,(char **)0x0,0);

      FUN_00405e60(uVar6,1);

      FUN_00405e60(~uVar6,0);

      return cVar1;

    }

    FUN_00401340("logfile");

    cVar3 = FUN_00401920(&local_4);

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

    if ((LVar4 == 0) && ((undefined4 *)(local_4 + -0x14) != (undefined4 *)0x0)) {

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

    }

    cVar2 = cVar1;

    if (cVar3 == '\0') {

      FUN_00401340("outport");

      cVar1 = FUN_00401920(&local_4);

      FUN_004011b0();

      if (cVar1 == '\0') {

        FUN_00401340("rodat");

        cVar1 = FUN_00401920(&local_4);

        FUN_004011b0();

        if (cVar1 != '\0') {

          param_1[0x1b] = (uint)(*(int *)(*param_3 + -4) == 1);

        }

      }

      else if ((param_1[0x25] < 1) || (0xffff < param_1[0x25])) {

        FUN_00401340("Client port must be between 1 and 65535\n");

        (**(code **)(*param_1 + 0x20))(&param_3);

        FUN_004011b0();

        return '\0';

      }

    }

  }

  return cVar2;

}





// --- FUN_00412ae0 at 0x00412AE0 (size: 120) ---


undefined4 __thiscall FUN_00412ae0(int param_1,undefined4 param_2)



{

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

    FUN_0042dc80();

    FUN_0042c9c0(*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_1 + 8));

    FUN_0042e740(param_2,1);

    FUN_0042e590();

    return param_2;

  }

  FUN_00402730(L"unknown");

  return param_2;

}





// --- FUN_00412b70 at 0x00412B70 (size: 515) ---


void __fastcall FUN_00412b70(undefined4 *param_1)



{

  int iVar1;

  LONG LVar2;

  uint uVar3;

  undefined4 *puVar4;

  

  param_1[-7] = &PTR_LAB_00795d48;

  param_1[-6] = &PTR_LAB_00795cf8;

  *param_1 = &PTR_FUN_00795ce8;

  param_1[2] = &PTR_LAB_00795cdc;

  param_1[3] = &PTR_LAB_00795ccc;

  DAT_008379e4 = 0;

  if ((HANDLE)param_1[0x45] != (HANDLE)0x0) {

    CloseHandle((HANDLE)param_1[0x45]);

    param_1[0x45] = 0;

  }

  puVar4 = (undefined4 *)(param_1[0x3c] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x3c] + -0x10));

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

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

  }

  FUN_00411e10();

  puVar4 = (undefined4 *)(param_1[0x23] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x23] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)(param_1[0x1c] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x1c] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)(param_1[0x1b] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x1b] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)(param_1[0x1a] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x1a] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)param_1[0x16];

  LVar2 = InterlockedDecrement(puVar4 + 1);

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

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

  }

  puVar4 = (undefined4 *)(param_1[0x12] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x12] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)(param_1[0x11] + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_1[0x11] + -0x10));

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

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

  }

  puVar4 = (undefined4 *)(-(uint)(param_1 != (undefined4 *)0x1c) & (uint)(param_1 + 3));

  param_1[0xf] = &PTR_LAB_00793b6c;

  puVar4[8] = &PTR_FUN_0079385c;

  *puVar4 = &PTR_FUN_00795538;

  if (puVar4[1] != 0) {

    FUN_0040e340(puVar4);

    puVar4[1] = 0;

  }

  puVar4 = (undefined4 *)(-(uint)(param_1 != (undefined4 *)0x1c) & (uint)(param_1 + 2));

  *puVar4 = &PTR_FUN_00795824;

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

    (**(code **)(*DAT_00837ff4 + 0x3c))(puVar4);

  }

  puVar4 = (undefined4 *)(-(uint)(param_1 != (undefined4 *)0x1c) & (uint)param_1);

  *puVar4 = &PTR_FUN_00795538;

  if (puVar4[1] != 0) {

    FUN_0040e340(puVar4);

    puVar4[1] = 0;

  }

  uVar3 = -(uint)(param_1 != (undefined4 *)0x1c) & (uint)(param_1 + -6);

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

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

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

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

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

  }

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

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

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

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

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

  }

  return;

}





// --- FUN_00412e10 at 0x00412E10 (size: 58) ---


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



{

  param_1[8] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_00795538;

  if (param_1[1] != 0) {

    FUN_0040e340(param_1);

    param_1[1] = 0;

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00412e50 at 0x00412E50 (size: 494) ---


undefined4 * __fastcall FUN_00412e50(undefined4 *param_1)



{

  LONG *pLVar1;

  

  param_1[1] = &PTR_LAB_00795c80;

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[2] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  FUN_00401340(&DAT_00795c7c);

  param_1[7] = &PTR_FUN_007959a8;

  param_1[8] = 0;

  param_1[9] = &PTR_FUN_00795824;

  param_1[0xb] = 0;

  param_1[10] = &PTR_FUN_00795dd8;

  param_1[0xc] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0x3f800000;

  param_1[0x12] = &PTR_FUN_00795878;

  param_1[0x15] = 0;

  *param_1 = &PTR_LAB_00795d48;

  param_1[1] = &PTR_LAB_00795cf8;

  param_1[7] = &PTR_FUN_00795ce8;

  param_1[9] = &PTR_LAB_00795cdc;

  param_1[10] = &PTR_LAB_00795ccc;

  param_1[0x17] = 1;

  param_1[0x16] = &PTR_LAB_00793b6c;

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x18] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x19] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  param_1[0x1a] = 1;

  param_1[0x1b] = 0;

  param_1[0x1c] = 1;

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

  param_1[0x1d] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x21] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x22] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x23] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  param_1[0x24] = 0;

  param_1[0x25] = 0x1c88;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  param_1[0x29] = 1;

  pLVar1 = (LONG *)(PTR_DAT_00818340 + -0x10);

  param_1[0x2a] = PTR_DAT_00818340;

  InterlockedIncrement(pLVar1);

  param_1[0x2b] = 0;

  param_1[0x2c] = 0;

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

  FUN_005414a0();

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  pLVar1 = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[0x43] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

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

  param_1[0x45] = 0;

  param_1[0x46] = 0;

  param_1[0x48] = 0;

  param_1[0x49] = 0;

  param_1[0x4a] = 0;

  param_1[0x4b] = 0;

  param_1[0x4c] = 0;

  DAT_008379e4 = param_1;

  FUN_00556eb0();

  FUN_00405e60(0x100,1);

  return param_1;

}





// --- FUN_00413040 at 0x00413040 (size: 34) ---


int __thiscall FUN_00413040(int param_1,byte param_2)



{

  FUN_00412b70();

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

    operator_delete((void *)(param_1 + -0x1c));

  }

  return param_1 + -0x1c;

}





// --- FUN_00413180 at 0x00413180 (size: 714) ---


undefined4 * __thiscall FUN_00413180(int *param_1,undefined4 *param_2)



{

  int iVar1;

  undefined *puVar2;

  HMODULE pHVar3;

  LONG LVar4;

  undefined4 *puVar5;

  int iStack_1fc;

  undefined *puStack_1f8;

  undefined **ppuStack_1f4;

  int iStack_1f0;

  int iStack_1ec;

  int iStack_1e8;

  undefined4 uStack_1e4;

  undefined4 uStack_1e0;

  undefined4 uStack_1dc;

  undefined4 uStack_1d8;

  undefined4 uStack_1d4;

  undefined4 *puStack_1d0;

  int iStack_1cc;

  uint uStack_1c8;

  undefined1 auStack_1c4 [24];

  undefined4 uStack_1ac;

  undefined4 uStack_1a8;

  undefined1 auStack_120 [144];

  undefined1 auStack_90 [144];

  

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

  iStack_1cc = param_1[0x26];

  iStack_1fc = param_1[0x25];

  iVar1 = param_1[0x23];

  if (iStack_1cc == 0) {

    iStack_1cc = param_1[0x45];

  }

  FUN_0040e4e0(param_1 + 10);

  puStack_1d0 = DAT_008ef11c;

  uStack_1e4 = 0;

  uStack_1e0 = 0;

  uStack_1dc = 0;

  uStack_1d8 = 0;

  uStack_1d4 = 0;

  InterlockedIncrement(DAT_008ef11c + 1);

  uStack_1c8 = (uint)*(byte *)(param_1 + 0x44);

  FUN_004034c0(param_1[0x43]);

  pHVar3 = LoadLibraryA("acpl.dll");

  if ((pHVar3 != (HMODULE)0x0) || (pHVar3 = LoadLibraryA("pl.dll"), pHVar3 != (HMODULE)0x0)) {

    puVar2 = PTR_FUN_00837388;

    iStack_1ec = (*(code *)PTR_FUN_00837388)(pHVar3,"LogWireDataReceived");

    uStack_1e0 = (*(code *)puVar2)(pHVar3,"LogWireDataSent");

  }

  FUN_00413980();

  FUN_00545bd0(&ppuStack_1f4,iStack_1fc,iVar1,auStack_1c4,param_1 + 0x2e,&uStack_1e4);

  if (iStack_1f0 == DAT_00822344) {

    if (iStack_1ec == DAT_00822348) {

      iVar1 = param_1[0xc];

      while (iVar1 < 3) {

        FUN_00411630();

        iVar1 = param_1[0xc];

      }

      iStack_1f0 = param_1[0x13];

      iStack_1ec = param_1[0x14];

    }

    if ((iStack_1f0 == DAT_00822344) && (iStack_1ec == DAT_00822348)) {

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

      goto LAB_004133fd;

    }

  }

  FUN_0042dc80();

  FUN_0042c9c0(iStack_1f0,iStack_1ec);

  FUN_0042e510(auStack_120);

  FUN_0042e590();

  FUN_0042e510(auStack_90);

  FUN_0042e590();

  FUN_00412ae0(&iStack_1fc);

  FUN_00408fd0(&iStack_1e8,0);

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

  LVar4 = InterlockedDecrement((LONG *)(iStack_1fc + -0x10));

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

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

  }

  puStack_1f8 = PTR_DAT_00818344;

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

  FUN_00402710(&puStack_1f8,"Failed to establish connection to the server: %s (%8X:%08X)",iStack_1e8

               ,uStack_1a8,uStack_1ac);

  FUN_00555860(puStack_1f8);

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

  LVar4 = InterlockedDecrement((LONG *)(puStack_1f8 + -0x10));

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

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

  }

  LVar4 = InterlockedDecrement((LONG *)(iStack_1e8 + -0x10));

  if ((LVar4 == 0) && ((undefined4 *)(iStack_1e8 + -0x14) != (undefined4 *)0x0)) {

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

  }

  FUN_0042e590();

LAB_004133fd:

  param_2[2] = iStack_1ec;

  *param_2 = &PTR_FUN_00795878;

  param_2[1] = iStack_1f0;

  ppuStack_1f4 = &PTR_FUN_0079385c;

  FUN_00695670();

  puVar5 = puStack_1d0;

  LVar4 = InterlockedDecrement(puStack_1d0 + 1);

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

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

  }

  return param_2;

}





// --- FUN_00413470 at 0x00413470 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795ef8;

  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_004134b0 at 0x004134B0 (size: 25) ---


void __fastcall FUN_004134b0(int *param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = *param_1;

  if (*(int *)(iVar1 + -8) == -1) {

    uVar2 = FUN_004016b0(iVar1);

    *(undefined4 *)(iVar1 + -8) = uVar2;

  }

  return;

}





// --- FUN_004134d0 at 0x004134D0 (size: 16) ---


int FUN_004134d0(int *param_1,int *param_2)



{

  return *param_2 - *param_1 >> 2;

}





// --- FUN_004134e0 at 0x004134E0 (size: 18) ---


void FUN_004134e0(int *param_1,int param_2)



{

  *param_1 = *param_1 + param_2 * 4;

  return;

}





// --- FUN_00413500 at 0x00413500 (size: 102) ---


undefined4 * FUN_00413500(undefined4 *param_1,undefined4 param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

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

  FUN_00402710(&local_4,"\'<unknowable file>\' (did=0x%08X)",param_2);

  *param_1 = local_4;

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

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

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

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

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

  }

  return param_1;

}





// --- FUN_00413570 at 0x00413570 (size: 213) ---


void FUN_00413570(undefined4 param_1,undefined4 param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined *local_c;

  undefined *local_8;

  int local_4;

  

  FUN_00413500(&local_4,param_1);

  local_8 = PTR_DAT_00818344;

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

  FUN_00402390(param_2,&stack0x0000000c);

  local_c = PTR_DAT_00818344;

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

  FUN_00402710(&local_c,"Error in file \"%s\": %s\n",local_4,local_8);

  FUN_0065af70(&local_c);

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

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

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

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

  }

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

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

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

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

  }

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

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

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

  }

  return;

}





// --- FUN_00413650 at 0x00413650 (size: 143) ---


undefined4 * __thiscall FUN_00413650(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_00795ef8;

  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_004136e0 at 0x004136E0 (size: 58) ---


void __fastcall FUN_004136e0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_00795f38;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_00795ef8;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  return;

}





// --- FUN_00413720 at 0x00413720 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00795f38;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_00795ef8;

  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_004137f0 at 0x004137F0 (size: 95) ---


undefined4 * FUN_004137f0(void)



{

  undefined4 *puVar1;

  

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

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

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

      DAT_00837b9c = (undefined4 *)0x0;

    }

    else {

      puVar1[1] = 1;

      *puVar1 = &PTR_FUN_00795f3c;

      *(undefined1 *)(puVar1 + 2) = 0;

      *(undefined1 *)((int)puVar1 + 9) = 0;

      puVar1[3] = &PTR_FUN_00795f38;

      FUN_00413650(0x17);

      DAT_00837b9c = puVar1;

    }

  }

  InterlockedIncrement(DAT_00837b9c + 1);

  return DAT_00837b9c;

}





// --- FUN_00413850 at 0x00413850 (size: 210) ---


void FUN_00413850(int param_1,int *param_2)



{

  undefined4 *puVar1;

  LONG LVar2;

  int iVar3;

  undefined4 uVar4;

  

  puVar1 = (undefined4 *)FUN_0040f4c0();

  FUN_0065af30(puVar1);

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  if (param_1 != 0) {

    if (param_1 == 1) {

      puVar1 = (undefined4 *)FUN_0040eb60();

    }

    else {

      if (param_1 != 2) {

        return;

      }

      puVar1 = (undefined4 *)FUN_0040eb40();

    }

    FUN_0065af30(puVar1);

    LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    return;

  }

  if (*(int *)(*param_2 + -4) == 1) {

    uVar4 = FUN_004137f0();

    FUN_0065af30(uVar4);

    FUN_00405f70();

    return;

  }

  iVar3 = FUN_005df0f5(0x18);

  if (iVar3 == 0) {

    FUN_0065af30(0);

    FUN_00405f70();

    return;

  }

  uVar4 = FUN_0040f020(*param_2);

  FUN_0065af30(uVar4);

  FUN_00405f70();

  return;

}





// --- FUN_00413930 at 0x00413930 (size: 39) ---


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



{

  FUN_004136e0();

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00413960 at 0x00413960 (size: 19) ---


void __fastcall FUN_00413960(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  return;

}





// --- FUN_00413980 at 0x00413980 (size: 21) ---


void __fastcall FUN_00413980(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  return;

}





// --- FUN_004139a0 at 0x004139A0 (size: 45) ---


void __thiscall FUN_004139a0(undefined4 *param_1,undefined4 *param_2)



{

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  param_1[3] = param_2[3];

  param_1[4] = param_2[4];

  return;

}





// --- FUN_004139d0 at 0x004139D0 (size: 46) ---


void __fastcall FUN_004139d0(int param_1)



{

  if (DAT_00837bac != 0) {

    (**(code **)(*(int *)(DAT_00837bac + 4) + 0x34))(DAT_00818684);

  }

  DAT_00818684 = DAT_00837c20;

                    /* WARNING: Could not recover jumptable at 0x004139fb. Too many branches */

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*(int *)(param_1 + 4) + 0x58))();

  return;

}





// --- FUN_00413a00 at 0x00413A00 (size: 34) ---


undefined4 FUN_00413a00(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

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

    uVar1 = (**(code **)(*DAT_00837bac + 0x24))(param_1,param_2,param_3);

    return uVar1;

  }

  return 0;

}





// --- FUN_00413a30 at 0x00413A30 (size: 24) ---


undefined4 FUN_00413a30(undefined4 param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = (**(code **)(*DAT_00837bac + 0x2c))(param_1);

    return uVar1;

  }

  return 0;

}





// --- FUN_00413a50 at 0x00413A50 (size: 27) ---


undefined4 FUN_00413a50(undefined4 *param_1)



{

  undefined4 uVar1;

  

  if (DAT_00837bac != 0) {

    uVar1 = *(undefined4 *)(DAT_00837bac + 0x120);

    *param_1 = uVar1;

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

  }

  return 0;

}





// --- FUN_00413a70 at 0x00413A70 (size: 19) ---


undefined4 FUN_00413a70(void)



{

  if (DAT_00837bac != 0) {

    return CONCAT31((int3)((uint)DAT_00837bac >> 8),*(undefined1 *)(DAT_00837bac + 0x128));

  }

  return 0;

}





// --- FUN_00413a90 at 0x00413A90 (size: 19) ---


undefined4 FUN_00413a90(void)



{

  if (DAT_00837bac != 0) {

    return CONCAT31((int3)((uint)DAT_00837bac >> 8),*(undefined1 *)(DAT_00837bac + 0x129));

  }

  return 0;

}





// --- FUN_00413ab0 at 0x00413AB0 (size: 19) ---


undefined4 FUN_00413ab0(void)



{

  if (DAT_00837bac != 0) {

    return CONCAT31((int3)((uint)DAT_00837bac >> 8),*(undefined1 *)(DAT_00837bac + 0x12a));

  }

  return 0;

}





// --- FUN_00413ad0 at 0x00413AD0 (size: 15) ---


undefined4 __thiscall FUN_00413ad0(int param_1,undefined4 param_2)



{

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

  return 1;

}





// --- FUN_00413ae0 at 0x00413AE0 (size: 29) ---


uint FUN_00413ae0(undefined4 param_1,undefined4 param_2)



{

  uint in_EAX;

  uint uVar1;

  

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

    uVar1 = (**(code **)(*DAT_00837bac + 0x4c))(param_1,param_2);

    return uVar1;

  }

  return in_EAX & 0xffffff00;

}





// --- FUN_00413b00 at 0x00413B00 (size: 19) ---


undefined4 FUN_00413b00(void)



{

  if (DAT_00837bac != 0) {

    return *(undefined4 *)(DAT_00837bac + 0x124);

  }

  return 0;

}





// --- FUN_00413b30 at 0x00413B30 (size: 47) ---


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



{

  *param_1 = &PTR_FUN_00795f70;

  if ((void *)param_1[1] != (void *)0x0) {

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

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00413b60 at 0x00413B60 (size: 25) ---


void __thiscall FUN_00413b60(int param_1,undefined4 *param_2,undefined4 param_3)



{

  undefined4 uVar1;

  

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

  *(undefined4 *)(param_1 + 0x11c) = param_3;

  *param_2 = uVar1;

  return;

}





// --- FUN_00413b80 at 0x00413B80 (size: 49) ---


void FUN_00413b80(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  

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

  uVar2 = FUN_004220b0(param_1,param_2);

  (*(code *)*puVar1)(2,uVar2);

  return;

}





// --- FUN_00413bc0 at 0x00413BC0 (size: 48) ---


undefined4 * FUN_00413bc0(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

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

    (**(code **)(*DAT_00837bac + 0x28))(param_1,param_2,param_3);

    return param_1;

  }

  *param_1 = DAT_00837bb0;

  return param_1;

}





// --- FUN_00413d20 at 0x00413D20 (size: 185) ---


char __thiscall FUN_00413d20(int param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  char cVar2;

  int *piVar3;

  int *piVar4;

  char unaff_BP;

  undefined4 unaff_ESI;

  undefined1 local_8 [4];

  char cStack_4;

  

  FUN_004220b0(param_2,param_3);

  piVar3 = (int *)(**(code **)(*(int *)(param_1 + 4) + 0x38))(local_8);

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

    return '\0';

  }

  piVar4 = (int *)(**(code **)(*(int *)(param_1 + 4) + 0x84))(&stack0xfffffff4,piVar3);

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

    return '\0';

  }

  cStack_4 = (char)piVar4[2];

  if (cStack_4 != '\0') {

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

  }

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

  cVar1 = (**(code **)(*(int *)(param_1 + 4) + 0x7c))(piVar4,&stack0xffffffec,piVar3);

  cVar2 = '\0';

  if ((cVar1 != '\0') && (cVar2 = (**(code **)(*piVar4 + 0x24))(), cVar2 != '\0')) {

    if (unaff_BP != '\0') {

      cVar2 = (**(code **)(*piVar4 + 0x28))();

    }

    if (cVar2 != '\0') goto LAB_00413dc6;

  }

  (**(code **)(*piVar3 + 0x1c))(unaff_ESI);

LAB_00413dc6:

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

  return cVar2;

}





// --- FUN_00413de0 at 0x00413DE0 (size: 108) ---


void FUN_00413de0(int *param_1)



{

  char cVar1;

  undefined4 uVar2;

  

  if (DAT_00837bac != 0) {

    if ((param_1[10] != DAT_00837bb0) && (*(int *)(DAT_00837bac + 300) != 0)) {

      uVar2 = (**(code **)(*param_1 + 0x48))();

      cVar1 = FUN_0041c4a0(uVar2);

      if (cVar1 == '\0') {

        uVar2 = (**(code **)(*param_1 + 0x48))();

        switch(uVar2) {

        case 0x15:

        case 0x1c:

        case 0x24:

        case 0x26:

        case 0x28:

        case 0x2d:

          break;

        default:

          (**(code **)(*param_1 + 0x40))(*(undefined4 *)(DAT_00837bac + 300));

        }

      }

    }

  }

  return;

}





// --- FUN_00413e70 at 0x00413E70 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795f84;

  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_00413eb0 at 0x00413EB0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795f88;

  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_00413ef0 at 0x00413EF0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795f8c;

  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_00413f30 at 0x00413F30 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795f90;

  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_00413f70 at 0x00413F70 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00795f94;

  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_00413fb0 at 0x00413FB0 (size: 160) ---


int __thiscall FUN_00413fb0(int param_1,undefined4 *param_2)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  

  if (*(int *)(param_1 + 0x10) == *(int *)(param_1 + 0x14)) {

    iVar1 = thunk_FUN_005df0f5((*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0x14)) * 4);

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

      uVar3 = *(uint *)(param_1 + 8);

      uVar2 = 0;

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

        do {

          *(undefined4 *)(iVar1 + uVar2 * 4) = *(undefined4 *)(*(int *)(param_1 + 4) + uVar3 * 4);

          uVar3 = (uVar3 + 1) % *(uint *)(param_1 + 0x14);

          uVar2 = uVar2 + 1;

        } while (uVar2 < *(uint *)(param_1 + 0x10));

      }

      operator_delete__(*(void **)(param_1 + 4));

    }

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

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

    *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_1 + 0x10);

    *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + *(int *)(param_1 + 0x18);

  }

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

  *(uint *)(param_1 + 0xc) = (*(int *)(param_1 + 0xc) + 1U) % *(uint *)(param_1 + 0x14);

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

  *(int *)(param_1 + 0x10) = iVar1 + 1;

  return iVar1;

}





// --- FUN_00414050 at 0x00414050 (size: 130) ---


uint __thiscall FUN_00414050(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

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

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

  if (param_2 == 0) {

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

    *(uint *)(param_1 + 8) = uVar2 % uVar1;

    return uVar2 / uVar1;

  }

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

  uVar3 = uVar2 / uVar1;

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

  if (param_2 != *(int *)(param_1 + 0x10)) {

    uVar1 = *(uint *)(param_1 + 8);

    uVar2 = (uVar1 + param_2) % *(uint *)(param_1 + 0x14);

    if ((*(uint *)(param_1 + 0xc) < uVar1) && (uVar1 < uVar2)) {

      iVar4 = *(uint *)(param_1 + 0x14) - 1;

      FUN_004140e0(uVar2,uVar2 + 1,iVar4 - uVar2);

      (*(undefined4 **)(param_1 + 4))[iVar4] = **(undefined4 **)(param_1 + 4);

      uVar2 = 0;

    }

    uVar3 = FUN_004140e0(uVar2,uVar2 + 1,*(int *)(param_1 + 0xc) - uVar2);

  }

  return uVar3;

}





// --- FUN_004140e0 at 0x004140E0 (size: 120) ---


void __thiscall FUN_004140e0(int param_1,uint param_2,uint param_3,int param_4)



{

  int iVar1;

  int iVar2;

  

  if (param_4 != 0) {

    if (param_2 < param_3) {

      if (param_4 != 0) {

        iVar2 = param_2 * 4;

        iVar1 = param_3 * 4;

        do {

          *(undefined4 *)(iVar2 + *(int *)(param_1 + 4)) =

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

          iVar1 = iVar1 + 4;

          iVar2 = iVar2 + 4;

          param_4 = param_4 + -1;

        } while (param_4 != 0);

        return;

      }

    }

    else if (param_4 != 0) {

      iVar1 = ((param_2 - 1) + param_4) * 4;

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

      do {

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

             *(undefined4 *)(iVar2 + *(int *)(param_1 + 4));

        iVar2 = iVar2 + -4;

        iVar1 = iVar1 + -4;

        param_4 = param_4 + -1;

      } while (param_4 != 0);

    }

  }

  return;

}





// --- FUN_00414190 at 0x00414190 (size: 66) ---


void __thiscall FUN_00414190(int param_1,int *param_2,int *param_3)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = (undefined4 *)

           (*(int *)(param_1 + 0x60) +

           ((uint)(*param_3 + param_3[1]) % *(uint *)(param_1 + 0x68)) * 4);

  for (piVar2 = (int *)*puVar1;

      (piVar2 != (int *)0x0 && ((*piVar2 != *param_3 || (piVar2[1] != param_3[1]))));

      piVar2 = (int *)piVar2[2]) {

  }

  param_2[1] = (int)puVar1;

  *param_2 = param_1;

  param_2[2] = (int)piVar2;

  return;

}





// --- FUN_004141e0 at 0x004141E0 (size: 424) ---


undefined1 FUN_004141e0(void)



{

  char cVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int *piVar4;

  int *piVar5;

  int local_10;

  int local_c;

  int local_8;

  int iStack_4;

  

  if (DAT_00837c68 == 0) {

    puVar2 = (undefined4 *)FUN_005df0f5(4);

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

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = &PTR_FUN_00795f5c;

    }

    cVar1 = FUN_0041c220(puVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  piVar5 = &local_10;

  FUN_00401340(&DAT_007954ac);

  piVar4 = &local_c;

  FUN_00423430(&local_8,&DAT_00837be4,&local_10,piVar4);

  FUN_0040bbc0(piVar5,piVar4);

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

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

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

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

  }

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

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

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

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

  }

  FUN_0041c2e0(&local_10);

  FUN_00401340(&DAT_007954ac);

  piVar4 = &local_c;

  piVar5 = &local_8;

  FUN_00423430(&iStack_4,&DAT_00837be8,piVar5,piVar4);

  piVar4 = (int *)FUN_0040bbc0(piVar5,piVar4);

  if (local_10 != *piVar4) {

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

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

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

    }

    local_10 = *piVar4;

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

  FUN_0041c330(&local_10);

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

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

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

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

  }

  return 1;

}





// --- FUN_00414390 at 0x00414390 (size: 92) ---


void FUN_00414390(void)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined1 auStack_c [12];

  

  FUN_00417710();

  piVar2 = (int *)FUN_0052dcf0(auStack_c);

  iVar3 = piVar2[2];

  iVar1 = *piVar2;

  piVar2 = (int *)piVar2[1];

  do {

    if (iVar3 == 0) {

      return;

    }

    do {

      if (*(int *)(iVar3 + 8) != 0) {

        FUN_00416ac0();

      }

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

    } while (iVar3 != 0);

    do {

      piVar2 = piVar2 + 1;

      if (piVar2 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return;

      }

      iVar3 = *piVar2;

    } while (iVar3 == 0);

  } while( true );

}





// --- FUN_004144e0 at 0x004144E0 (size: 82) ---


void FUN_004144e0(uint param_1)



{

  int iVar1;

  uint *puVar2;

  int *piVar3;

  int iVar4;

  undefined1 auStack_c [12];

  

  if (param_1 == 0) {

    piVar3 = (int *)FUN_0052dcf0(auStack_c);

    iVar4 = piVar3[2];

    iVar1 = *piVar3;

    piVar3 = (int *)piVar3[1];

    while (iVar4 != 0) {

      do {

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

          (**(code **)(**(int **)(iVar4 + 8) + 0x28))();

        }

        iVar4 = *(int *)(iVar4 + 4);

      } while (iVar4 != 0);

      do {

        piVar3 = piVar3 + 1;

        if (piVar3 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

          return;

        }

        iVar4 = *piVar3;

      } while (iVar4 == 0);

    }

  }

  else {

    puVar2 = *(uint **)(DAT_0081866c + (param_1 % DAT_00818674) * 4);

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

      while (*puVar2 != param_1) {

        puVar2 = (uint *)puVar2[1];

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

          return;

        }

      }

      if ((puVar2 != (uint *)0x0) && (puVar2 + 2 != (uint *)0x0)) {

        (**(code **)(*(int *)puVar2[2] + 0x28))();

        return;

      }

    }

  }

  return;

}





// --- FUN_00414532 at 0x00414532 (size: 90) ---


void FUN_00414532(void)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  

  piVar2 = (int *)FUN_0052dcf0(&stack0x00000000);

  iVar3 = piVar2[2];

  iVar1 = *piVar2;

  piVar2 = (int *)piVar2[1];

  do {

    if (iVar3 == 0) {

      return;

    }

    do {

      if (*(int **)(iVar3 + 8) != (int *)0x0) {

        (**(code **)(**(int **)(iVar3 + 8) + 0x28))();

      }

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

    } while (iVar3 != 0);

    do {

      piVar2 = piVar2 + 1;

      if (piVar2 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

        return;

      }

      iVar3 = *piVar2;

    } while (iVar3 == 0);

  } while( true );

}





// --- FUN_00414590 at 0x00414590 (size: 61) ---


uint FUN_00414590(uint param_1)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(DAT_0081866c + (param_1 % DAT_00818674) * 4);

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

    while (*puVar1 != param_1) {

      puVar1 = (uint *)puVar1[1];

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

        return 0;

      }

    }

    if ((puVar1 != (uint *)0x0) && (puVar1 + 2 != (uint *)0x0)) {

      return puVar1[2];

    }

  }

  return 0;

}





// --- FUN_004145d0 at 0x004145D0 (size: 73) ---


void __fastcall FUN_004145d0(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_004148b0(*puVar2);

  return;

}





// --- FUN_00414620 at 0x00414620 (size: 143) ---


undefined4 FUN_00414620(undefined4 param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined1 local_c [12];

  

  if (param_2 == 0) {

    piVar2 = (int *)FUN_0052dcf0(local_c);

    iVar3 = piVar2[2];

    iVar1 = *piVar2;

    piVar2 = (int *)piVar2[1];

    while (iVar3 != 0) {

      do {

        if (*(int *)(iVar3 + 8) != 0) {

          FUN_00416970(param_1);

        }

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

      } while (iVar3 != 0);

      do {

        piVar2 = piVar2 + 1;

        if (piVar2 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) {

          return 1;

        }

        iVar3 = *piVar2;

      } while (iVar3 == 0);

    }

  }

  else {

    iVar1 = FUN_00414590(param_2);

    if (iVar1 != 0) {

      FUN_00416970(param_1);

      return 1;

    }

  }

  return 1;

}





// --- FUN_00414700 at 0x00414700 (size: 143) ---


undefined4 * __thiscall FUN_00414700(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_00795f84;

  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_00414790 at 0x00414790 (size: 143) ---


undefined4 * __thiscall FUN_00414790(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_00795f90;

  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_00414820 at 0x00414820 (size: 143) ---


undefined4 * __thiscall FUN_00414820(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_00795f94;

  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_004148b0 at 0x004148B0 (size: 319) ---


undefined4 __thiscall FUN_004148b0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  int *piVar5;

  int *piVar6;

  undefined4 *puVar7;

  int *piVar8;

  uint uVar9;

  int *piVar10;

  

  iVar2 = param_2;

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

    return 0;

  }

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

  piVar3 = (int *)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 (piVar3 != (int *)0x0) {

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

        piVar10 = (int *)piVar3[2];

        PTR_DAT_00818558 = (undefined *)puVar4;

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

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

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

            puVar7 = puVar7 + 1;

          }

          FUN_004148b0(*puVar7);

        }

        uVar9 = (uint)(piVar3[1] + *piVar3) % *(uint *)(param_1 + 0x68);

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

        piVar3[2] = *(int *)(iVar2 + uVar9 * 4);

        *(int **)(iVar2 + uVar9 * 4) = piVar3;

        uVar9 = iVar2 + uVar9 * 4;

        if (uVar9 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar9;

        }

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

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        piVar3 = piVar10;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

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

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

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

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

        piVar8 = (int *)*piVar10;

        goto LAB_004148ff;

      }

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

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

    }

    piVar10 = (int *)0x0;

    piVar8 = (int *)0x0;

LAB_004148ff:

    piVar6 = (int *)*piVar10;

    if (piVar6 == piVar8) {

LAB_00414912:

      *piVar10 = piVar6[2];

    }

    else {

      do {

        piVar5 = piVar6;

        piVar6 = (int *)piVar5[2];

      } while (piVar6 != piVar8);

      if (piVar5 == (int *)0x0) goto LAB_00414912;

      piVar5[2] = piVar6[2];

    }

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

    piVar8[2] = (int)piVar3;

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

    piVar3 = piVar8;

  } while( true );

}





// --- FUN_004149f0 at 0x004149F0 (size: 52) ---


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



{

  FUN_00414700(param_2);

  *param_1 = &PTR_FUN_00795f98;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0xffffffff;

  param_1[0x1e] = 0;

  param_1[0x1d] = 0;

  param_1[0x1c] = param_1;

  return param_1;

}





// --- FUN_00414a30 at 0x00414A30 (size: 30) ---


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



{

  FUN_0041a410();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00414a50 at 0x00414A50 (size: 110) ---


uint __thiscall FUN_00414a50(int param_1,int *param_2)



{

  int iVar1;

  uint uVar2;

  undefined1 local_c [8];

  uint local_4;

  

  FUN_00414190(local_c,param_2);

  if (local_4 != 0) {

    return local_4 & 0xffffff00;

  }

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

    FUN_004145d0();

  }

  uVar2 = (uint)(param_2[1] + *param_2) % *(uint *)(param_1 + 0x68);

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

  param_2[2] = *(int *)(iVar1 + uVar2 * 4);

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

  uVar2 = iVar1 + uVar2 * 4;

  if (uVar2 < *(uint *)(param_1 + 100)) {

    *(uint *)(param_1 + 100) = uVar2;

  }

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

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_00414ac0 at 0x00414AC0 (size: 269) ---


undefined4 __thiscall FUN_00414ac0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  int *piVar4;

  undefined4 uVar5;

  int *piVar6;

  uint uVar7;

  int *piVar8;

  

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

    return 0;

  }

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

  piVar2 = (int *)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(param_2);

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

        piVar8 = (int *)piVar2[2];

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

          uVar5 = FUN_004184d0(*(int *)(param_1 + 0x68));

          FUN_00414ac0(uVar5);

        }

        uVar7 = (uint)(piVar2[1] + *piVar2) % *(uint *)(param_1 + 0x68);

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

        piVar2[2] = *(int *)(iVar1 + uVar7 * 4);

        *(int **)(iVar1 + uVar7 * 4) = piVar2;

        uVar7 = iVar1 + uVar7 * 4;

        if (uVar7 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar7;

        }

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

        piVar2 = piVar8;

      }

      return 1;

    }

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

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

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

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

        piVar6 = (int *)*piVar8;

        goto LAB_00414b0e;

      }

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

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

    }

    piVar8 = (int *)0x0;

    piVar6 = (int *)0x0;

LAB_00414b0e:

    piVar4 = (int *)*piVar8;

    if (piVar4 == piVar6) {

LAB_00414b21:

      *piVar8 = piVar4[2];

    }

    else {

      do {

        piVar3 = piVar4;

        piVar4 = (int *)piVar3[2];

      } while (piVar4 != piVar6);

      if (piVar3 == (int *)0x0) goto LAB_00414b21;

      piVar3[2] = piVar4[2];

    }

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

    piVar6[2] = (int)piVar2;

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

    piVar2 = piVar6;

  } while( true );

}





// --- FUN_00414bd0 at 0x00414BD0 (size: 264) ---


undefined4 __thiscall FUN_00414bd0(int param_1,int param_2)



{

  int iVar1;

  uint *puVar2;

  int *piVar3;

  uint *puVar4;

  uint *puVar5;

  undefined4 uVar6;

  uint *puVar7;

  uint uVar8;

  uint *puVar9;

  

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

    return 0;

  }

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

  puVar2 = (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(param_2);

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

        puVar9 = (uint *)puVar2[1];

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

          uVar6 = FUN_004184d0(*(int *)(param_1 + 0x68));

          FUN_00414bd0(uVar6);

        }

        uVar8 = *puVar2 % *(uint *)(param_1 + 0x68);

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

        puVar2[1] = *(uint *)(iVar1 + uVar8 * 4);

        *(uint **)(iVar1 + uVar8 * 4) = puVar2;

        uVar8 = iVar1 + uVar8 * 4;

        if (uVar8 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar8;

        }

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

        puVar2 = puVar9;

      }

      return 1;

    }

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

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

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

        puVar9 = *(uint **)(param_1 + 100);

        puVar7 = (uint *)*puVar9;

        goto LAB_00414c1e;

      }

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

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

    }

    puVar9 = (uint *)0x0;

    puVar7 = (uint *)0x0;

LAB_00414c1e:

    puVar5 = (uint *)*puVar9;

    if (puVar5 == puVar7) {

LAB_00414c31:

      *puVar9 = puVar5[1];

    }

    else {

      do {

        puVar4 = puVar5;

        puVar5 = (uint *)puVar4[1];

      } while (puVar5 != puVar7);

      if (puVar4 == (uint *)0x0) goto LAB_00414c31;

      puVar4[1] = puVar5[1];

    }

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

    puVar7[1] = (uint)puVar2;

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

    puVar2 = puVar7;

  } while( true );

}





// --- FUN_00414ce0 at 0x00414CE0 (size: 73) ---


void __fastcall FUN_00414ce0(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_00414ac0(*puVar2);

  return;

}





// --- FUN_00414d30 at 0x00414D30 (size: 73) ---


void __fastcall FUN_00414d30(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_00414bd0(*puVar2);

  return;

}





// --- FUN_00414d80 at 0x00414D80 (size: 112) ---


undefined4 FUN_00414d80(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined1 local_c [8];

  int local_4;

  

  FUN_00414190(local_c,param_1);

  if (local_4 != 0) {

    return 0;

  }

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

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

    *puVar1 = *param_1;

    puVar1[1] = param_1[1];

    puVar1[2] = 0;

    FUN_00414a50(puVar1);

    return 1;

  }

  FUN_00414a50(0);

  return 1;

}





// --- FUN_00414df0 at 0x00414DF0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00795fa0;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_00795f94;

  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_00414e90 at 0x00414E90 (size: 160) ---


void __thiscall FUN_00414e90(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined1 local_90 [4];

  undefined1 local_8c [12];

  undefined1 local_80 [128];

  

  iVar2 = FUN_00414190(local_8c,param_2);

  iVar1 = DAT_00837bac;

  if ((*(int *)(iVar2 + 8) == 0) && (DAT_00837bac != 0)) {

    if (DAT_00837c20 == *(int *)(param_1 + 4)) {

      puVar3 = (undefined4 *)

               (**(code **)(*(int *)(DAT_00837bac + 4) + 0x14))(local_90,3,param_2,param_1,0);

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

    }

    else {

      FUN_004149f0(0x20);

      FUN_0041a4e0(param_2,0);

      (**(code **)(*(int *)(iVar1 + 4) + 0x30))(*(undefined4 *)(param_1 + 4),3,local_80);

      FUN_0041a410();

    }

    FUN_00414d80(param_2);

  }

  return;

}





// --- FUN_00414f80 at 0x00414F80 (size: 85) ---


int FUN_00414f80(undefined4 param_1)



{

  undefined4 local_c;

  undefined4 local_8;

  int local_4;

  

  FUN_00414190(&local_c,param_1);

  if (local_4 != 0) {

    FUN_00540830(local_c,local_8,local_4);

    return local_4;

  }

  return 0;

}





// --- FUN_00415040 at 0x00415040 (size: 105) ---


void __fastcall FUN_00415040(int *param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  

  (**(code **)(*param_1 + 0x38))(1);

  piVar2 = (int *)FUN_0052dcf0(&stack0xfffffff0);

  iVar3 = piVar2[2];

  iVar1 = *piVar2;

  piVar2 = (int *)piVar2[1];

  while (iVar3 != 0) {

    do {

      if (*(undefined4 **)(iVar3 + 8) != (undefined4 *)0x0) {

        (**(code **)**(undefined4 **)(iVar3 + 8))(1);

      }

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

    } while (iVar3 != 0);

    do {

      piVar2 = piVar2 + 1;

      if (piVar2 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) goto LAB_00415098;

      iVar3 = *piVar2;

    } while (iVar3 == 0);

  }

LAB_00415098:

  FUN_005870f0();

  return;

}





// --- FUN_004150b0 at 0x004150B0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00795f9c;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00795f90;

  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_00415110 at 0x00415110 (size: 148) ---


void __fastcall FUN_00415110(int param_1)



{

  *(undefined ***)(param_1 + 0x94) = &PTR_FUN_007963a4;

  FUN_005870f0();

  *(undefined ***)(param_1 + 0x98) = &PTR_FUN_00795f8c;

  if (*(void **)(param_1 + 0xf8) != (void *)(param_1 + 0x9c)) {

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

  }

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

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

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

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

  *(undefined ***)(param_1 + 0x20) = &PTR_FUN_007963a8;

  FUN_0041a390();

  *(undefined ***)(param_1 + 0x24) = &PTR_FUN_00795f88;

  if (*(void **)(param_1 + 0x84) != (void *)(param_1 + 0x28)) {

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

  }

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

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

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

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

  *(undefined ***)(param_1 + 4) = &PTR_FUN_00795f70;

  if (*(void **)(param_1 + 8) != (void *)0x0) {

    operator_delete__(*(void **)(param_1 + 8));

  }

  return;

}





// --- FUN_004151b0 at 0x004151B0 (size: 94) ---


void __fastcall FUN_004151b0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_00796058;

  param_1[1] = &PTR_FUN_00795fb0;

  FUN_0041c240();

  if (DAT_00837bac != 0) {

    (**(code **)(*(int *)(DAT_00837bac + 4) + 0x34))(DAT_00818684);

  }

  DAT_00818684 = DAT_00837c20;

  DAT_00837bac = 0;

  DAT_00837ba8 = 0;

  param_1[0x45] = &PTR_LAB_00793b6c;

  FUN_00415110();

  return;

}





// --- FUN_00415210 at 0x00415210 (size: 86) ---


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



{

  if ((((*param_3 == -0x21524111) && (param_3[1] == DAT_00795f50)) && (param_3[2] == DAT_00795f54))

     && ((param_3[3] == DAT_00795f58 && (param_1 != (int *)0x0)))) {

    *param_4 = param_1;

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

    *param_2 = 0;

    return;

  }

  *param_2 = 0x80004002;

  return;

}





// --- FUN_00415280 at 0x00415280 (size: 39) ---


int __fastcall FUN_00415280(int *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (int *)0x0)) {

    (**(code **)(*param_1 + 0x18))(1);

  }

  return iVar1;

}





// --- FUN_00415320 at 0x00415320 (size: 123) ---


undefined4 * __fastcall FUN_00415320(undefined4 *param_1)



{

  FUN_0041a210();

  *param_1 = &PTR_LAB_00796058;

  param_1[1] = &PTR_FUN_00795fb0;

  param_1[0x45] = &PTR_LAB_00793b6c;

  param_1[0x46] = 1;

  param_1[0x47] = DAT_00837bb0;

  param_1[0x48] = 0;

  param_1[0x49] = 0;

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

  *(undefined1 *)((int)param_1 + 0x129) = 0;

  *(undefined1 *)((int)param_1 + 0x12a) = 0;

  param_1[0x4b] = 0;

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

    (**(code **)(*DAT_00837bac + 0x18))(1);

  }

  DAT_00837bac = param_1;

  return param_1;

}





// --- FUN_004153a0 at 0x004153A0 (size: 30) ---


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



{

  FUN_004151b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004153c0 at 0x004153C0 (size: 8) ---


void __fastcall FUN_004153c0(undefined4 param_1)



{

  FUN_00413de0(param_1);

  return;

}





// --- FUN_004153d0 at 0x004153D0 (size: 33) ---


int __fastcall FUN_004153d0(int param_1)



{

  int iVar1;

  

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

    FUN_00416f40(*(undefined4 *)(param_1 + 0x28));

    return *(int *)(param_1 + 0x24);

  }

  iVar1 = *(int *)(param_1 + 0x24) + 1;

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

  return iVar1;

}





// --- FUN_00415400 at 0x00415400 (size: 38) ---


int __fastcall FUN_00415400(int *param_1)



{

  int iVar1;

  

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

    iVar1 = (**(code **)(*(int *)param_1[8] + 0x14))(param_1[10]);

    return iVar1;

  }

  iVar1 = param_1[9] + -1;

  param_1[9] = iVar1;

  if (iVar1 == 0) {

    (**(code **)(*param_1 + 0x18))(1);

    iVar1 = 0;

  }

  return iVar1;

}





// --- FUN_00415430 at 0x00415430 (size: 27) ---


undefined4 FUN_00415430(undefined4 param_1)



{

  undefined4 uVar1;

  

  if (DAT_00837bac != 0) {

    uVar1 = (*(code *)**(undefined4 **)(DAT_00837bac + 4))(2,param_1);

    return uVar1;

  }

  return 0;

}





// --- thunk_FUN_00413a30 at 0x00415450 (size: 5) ---


undefined4 thunk_FUN_00413a30(undefined4 param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = (**(code **)(*DAT_00837bac + 0x2c))(param_1);

    return uVar1;

  }

  return 0;

}





// --- FUN_00415460 at 0x00415460 (size: 52) ---


void __thiscall FUN_00415460(undefined4 *param_1,undefined4 param_2)



{

  param_1[1] = 0;

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

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007961e0;

  param_1[9] = 1;

  param_1[10] = param_2;

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

  return;

}





// --- FUN_004154a0 at 0x004154A0 (size: 3) ---


undefined1 FUN_004154a0(void)



{

  return 1;

}





// --- FUN_004154b0 at 0x004154B0 (size: 7) ---


void __fastcall FUN_004154b0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007961e0;

  return;

}





// --- FUN_00415520 at 0x00415520 (size: 45) ---


undefined4 __fastcall FUN_00415520(int *param_1)



{

  undefined4 uVar1;

  int *piVar2;

  

  if (param_1[10] != 0) {

    uVar1 = (**(code **)(*param_1 + 0x48))();

    piVar2 = (int *)FUN_00414590(uVar1);

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

      uVar1 = (**(code **)(*piVar2 + 0x30))(param_1[10]);

      return uVar1;

    }

  }

  return 0;

}





// --- FUN_00415550 at 0x00415550 (size: 51) ---


undefined4 __thiscall FUN_00415550(int *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int *piVar2;

  

  if (param_1[10] != 0) {

    uVar1 = (**(code **)(*param_1 + 0x48))();

    piVar2 = (int *)FUN_00414590(uVar1);

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

      uVar1 = (**(code **)(*piVar2 + 0x2c))(param_2,param_1);

      return uVar1;

    }

  }

  return 0;

}





// --- FUN_00415590 at 0x00415590 (size: 116) ---


void __thiscall FUN_00415590(int *param_1,int param_2)



{

  char cVar1;

  int *piVar2;

  undefined4 uVar3;

  

  FUN_0040ad10(4);

  piVar2 = (int *)FUN_0040acf0(4);

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

    if ((*(byte *)(param_2 + 4) & 1) == 0) {

      param_1[10] = *piVar2;

    }

    else {

      *piVar2 = param_1[10];

    }

  }

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

  cVar1 = FUN_0041c4e0(uVar3);

  if (cVar1 != '\0') {

    FUN_0040ad10(4);

    piVar2 = (int *)FUN_0040acf0(4);

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

      if ((*(byte *)(param_2 + 4) & 1) != 0) {

        *piVar2 = param_1[1];

        return;

      }

      param_1[1] = *piVar2;

    }

  }

  return;

}





// --- FUN_00415610 at 0x00415610 (size: 45) ---


void FUN_00415610(int *param_1)



{

  int iVar1;

  undefined4 uVar2;

  int *piVar3;

  

  iVar1 = (**(code **)(*param_1 + 0x48))();

  if (iVar1 != 0) {

    uVar2 = (**(code **)(*param_1 + 0x48))();

    piVar3 = (int *)FUN_00414590(uVar2);

    (**(code **)(*piVar3 + 0x1c))(param_1[10]);

  }

  return;

}





// --- FUN_00415640 at 0x00415640 (size: 28) ---


undefined4 FUN_00415640(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00413bc0(param_1,param_2,param_3);

  return param_1;

}





// --- FUN_00415660 at 0x00415660 (size: 55) ---


void __fastcall FUN_00415660(int *param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  iVar1 = *(int *)(param_1[2] + 8);

  param_1[2] = iVar1;

  if (iVar1 == 0) {

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

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

    do {

      piVar3 = (int *)(param_1[1] + 4);

      param_1[1] = (int)piVar3;

      if (piVar3 == (int *)(iVar2 + iVar1 * 4)) {

        return;

      }

    } while (*piVar3 == 0);

    param_1[2] = *piVar3;

  }

  return;

}





// --- FUN_004156a0 at 0x004156A0 (size: 112) ---


undefined * __thiscall FUN_004156a0(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined1 local_c [12];

  

  if (param_2 == 0) {

    puVar1 = (undefined4 *)FUN_0052dcf0(local_c);

    *(undefined4 *)(param_1 + 0x70) = *puVar1;

    *(undefined4 *)(param_1 + 0x78) = puVar1[2];

    *(undefined4 *)(param_1 + 0x74) = puVar1[1];

  }

  else if (param_2 != *(int *)(param_1 + 0x7c)) {

    if ((*(int *)(param_1 + 0x78) == 0) || (param_2 != *(int *)(param_1 + 0x7c) + 1)) {

      FUN_0041a2a0(param_2);

    }

    else {

      FUN_00415660();

    }

  }

  if (*(undefined **)(param_1 + 0x78) != (undefined *)0x0) {

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

    return *(undefined **)(param_1 + 0x78);

  }

  return &DAT_00837cbc;

}





// --- FUN_00415730 at 0x00415730 (size: 40) ---


void FUN_00415730(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 local_4;

  

  FUN_00413bc0(&local_4,param_1,param_2);

  FUN_00413b80(local_4,param_3);

  return;

}





// --- FUN_00415830 at 0x00415830 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00796294;

  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_00415870 at 0x00415870 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00796298;

  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_004158b0 at 0x004158B0 (size: 93) ---


void __fastcall FUN_004158b0(int *param_1)



{

  int iVar1;

  

  param_1[2] = 0;

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

    if (*param_1 != 0) {

      operator_delete__((void *)(*param_1 + -4));

    }

    *param_1 = 0;

    param_1[1] = 0;

    return;

  }

  if (*param_1 != 0) {

    iVar1 = (param_1[1] & 0x7fffffffU) - 1;

    while (-1 < iVar1) {

      iVar1 = iVar1 + -1;

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

    }

  }

  return;

}





// --- FUN_00415910 at 0x00415910 (size: 184) ---


undefined4 __thiscall FUN_00415910(int *param_1,uint param_2)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  

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

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

      return 1;

    }

    if (param_2 == 0) {

      FUN_004158b0();

      return 1;

    }

    puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 4 + 4);

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

      puVar1 = puVar3 + 1;

      *puVar3 = param_2;

      FUN_00401000(puVar1,4,param_2,FUN_0050a140);

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

        if (*param_1 != 0) {

          iVar2 = param_1[2] + -1;

          while (-1 < iVar2) {

            puVar3[iVar2 + 1] = *(uint *)(*param_1 + 4 + (iVar2 + -1) * 4);

            iVar2 = iVar2 + -1;

          }

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

            operator_delete__((void *)(*param_1 + -4));

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = param_2 | 0x80000000;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004159d0 at 0x004159D0 (size: 291) ---


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



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined1 local_c [12];

  

  piVar1 = (int *)FUN_0052dcf0(local_c);

  puVar4 = (undefined4 *)piVar1[2];

  iVar3 = *piVar1;

  piVar1 = (int *)piVar1[1];

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

    do {

      iVar2 = _stricmp((char *)*param_2,(char *)puVar4[2]);

      if (iVar2 == 0) {

        *param_3 = *puVar4;

        return 1;

      }

      puVar4 = (undefined4 *)puVar4[1];

    } while (puVar4 != (undefined4 *)0x0);

    do {

      piVar1 = piVar1 + 1;

      if (piVar1 == (int *)(*(int *)(iVar3 + 0x60) + *(int *)(iVar3 + 0x68) * 4)) goto LAB_00415a33;

      puVar4 = (undefined4 *)*piVar1;

    } while (puVar4 == (undefined4 *)0x0);

  }

LAB_00415a33:

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

  do {

    if (piVar1 == (int *)(*(int *)(param_1 + 0x1f0) + *(int *)(param_1 + 0x1f8) * 4)) {

      piVar1 = (int *)0x0;

      puVar4 = (undefined4 *)0x0;

joined_r0x00415a8e:

      do {

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

          return 0;

        }

        do {

          iVar3 = _stricmp((char *)*param_2,(char *)puVar4[2]);

          if (iVar3 == 0) {

            *param_3 = *puVar4;

            return 1;

          }

          puVar4 = (undefined4 *)puVar4[1];

        } while (puVar4 != (undefined4 *)0x0);

        do {

          piVar1 = piVar1 + 1;

          if (piVar1 == (int *)(*(int *)(param_1 + 0x1f0) + *(int *)(param_1 + 0x1f8) * 4)) {

            return 0;

          }

          puVar4 = (undefined4 *)*piVar1;

        } while (puVar4 == (undefined4 *)0x0);

      } while( true );

    }

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

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

      puVar4 = (undefined4 *)*piVar1;

      goto joined_r0x00415a8e;

    }

    piVar1 = *(int **)(param_1 + 500) + 1;

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

  } while( true );

}





// --- FUN_00415b00 at 0x00415B00 (size: 265) ---


void __fastcall FUN_00415b00(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 uVar4;

  undefined1 local_20 [12];

  int local_14;

  

  piVar1 = (int *)FUN_0052dcf0(local_20);

  iVar3 = piVar1[2];

  local_14 = *piVar1;

  piVar1 = (int *)piVar1[1];

  while (iVar3 != 0) {

    do {

      uVar4 = 0;

      uVar2 = FUN_004220b0(*(undefined4 *)(iVar3 + 8),0);

      FUN_0041a4e0(uVar2,uVar4);

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

    } while (iVar3 != 0);

    do {

      piVar1 = piVar1 + 1;

      if (piVar1 == (int *)(*(int *)(local_14 + 0x60) + *(int *)(local_14 + 0x68) * 4))

      goto LAB_00415b73;

      iVar3 = *piVar1;

    } while (iVar3 == 0);

  }

LAB_00415b73:

  piVar1 = *(int **)(param_1 + 0x10c);

  do {

    if (piVar1 == (int *)(*(int *)(param_1 + 0x108) + *(int *)(param_1 + 0x110) * 4)) {

      piVar1 = (int *)0x0;

      iVar3 = 0;

joined_r0x00415bba:

      do {

        if (iVar3 == 0) {

          return;

        }

        do {

          uVar4 = 2;

          uVar2 = FUN_004220b0(*(undefined4 *)(iVar3 + 8),0);

          FUN_0041a4e0(uVar2,uVar4);

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

        } while (iVar3 != 0);

        do {

          piVar1 = piVar1 + 1;

          if (piVar1 == (int *)(*(int *)(param_1 + 0x108) + *(int *)(param_1 + 0x110) * 4)) {

            return;

          }

          iVar3 = *piVar1;

        } while (iVar3 == 0);

      } while( true );

    }

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

      piVar1 = *(int **)(param_1 + 0x10c);

      iVar3 = *piVar1;

      goto joined_r0x00415bba;

    }

    piVar1 = *(int **)(param_1 + 0x10c) + 1;

    *(int **)(param_1 + 0x10c) = piVar1;

  } while( true );

}





// --- FUN_00415c10 at 0x00415C10 (size: 119) ---


undefined4 __thiscall FUN_00415c10(int param_1,uint param_2,uint *param_3)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x94) + (param_2 % *(uint *)(param_1 + 0x9c)) * 4);

  do {

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

LAB_00415c41:

      puVar1 = *(uint **)(*(int *)(param_1 + 0x108) + (param_2 % *(uint *)(param_1 + 0x110)) * 4);

      while( true ) {

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

          return 0;

        }

        if (*puVar1 == param_2) break;

        puVar1 = (uint *)puVar1[1];

      }

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

        return 0;

      }

LAB_00415c75:

      *param_3 = puVar1[2];

      return 1;

    }

    if (*puVar1 == param_2) {

      if (puVar1 != (uint *)0x0) goto LAB_00415c75;

      goto LAB_00415c41;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00415c90 at 0x00415C90 (size: 67) ---


undefined4 FUN_00415c90(undefined4 param_1,undefined4 param_2)



{

  undefined4 uVar1;

  char cVar2;

  

  uVar1 = param_2;

  cVar2 = FUN_0041ae30(&param_1,param_2);

  if (cVar2 == '\0') {

    cVar2 = FUN_0041ae30(&param_1,uVar1);

    if (cVar2 == '\0') {

      return 0;

    }

  }

  return 1;

}





// --- FUN_00415ce0 at 0x00415CE0 (size: 68) ---


undefined4 __thiscall FUN_00415ce0(int param_1,uint param_2,uint *param_3)



{

  uint *puVar1;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x264) + (param_2 % *(uint *)(param_1 + 0x26c)) * 4);

  while( true ) {

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

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return 0;

  }

  *param_3 = puVar1[2];

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

}





// --- FUN_00415d30 at 0x00415D30 (size: 143) ---


undefined4 * __thiscall FUN_00415d30(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_00796294;

  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_00415dc0 at 0x00415DC0 (size: 143) ---


undefined4 * __thiscall FUN_00415dc0(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_00796298;

  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_00415e50 at 0x00415E50 (size: 170) ---


void __fastcall FUN_00415e50(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  LONG LVar4;

  int *piVar5;

  void *pvVar6;

  undefined4 *puVar7;

  

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

  do {

    if (iVar1 == 0) {

      return;

    }

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

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

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

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

        pvVar6 = (void *)*piVar5;

        goto LAB_00415e94;

      }

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

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

    }

    piVar5 = (int *)0x0;

    pvVar6 = (void *)0x0;

LAB_00415e94:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar6) {

LAB_00415ead:

      *piVar5 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar6);

      if (pvVar2 == (void *)0x0) goto LAB_00415ead;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

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

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

      puVar7 = (undefined4 *)(*(int *)((int)pvVar6 + 8) + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(*(int *)((int)pvVar6 + 8) + -0x10));

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

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

      }

      operator_delete(pvVar6);

    }

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

  } while( true );

}





// --- FUN_00415f00 at 0x00415F00 (size: 581) ---


void FUN_00415f00(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0042ab60(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_00416006:

    puVar10 = puVar9;

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

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

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

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

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

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            puVar10[2] = *puVar9;

          }

          else {

            *puVar9 = puVar10[2];

          }

        }

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_00416006;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_00416136:

      FUN_0040aa50();

    }

    else {

      uVar11 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar10 = (undefined4 *)FUN_005df0f5(0xc);

          puVar9 = (undefined4 *)0x0;

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

            puVar10[1] = 0;

            puVar9 = puVar10;

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

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

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

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

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              puVar9[2] = *puVar10;

            }

            else {

              *puVar10 = puVar9[2];

            }

          }

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_00416136;

          uVar11 = uVar11 + 1;

          puVar12 = puVar9;

          if (param_3 <= uVar11) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00416150 at 0x00416150 (size: 45) ---


void FUN_00416150(void)



{

  FUN_005870f0();

  FUN_00415e50();

  FUN_005870f0();

  FUN_00415e50();

  return;

}





// --- FUN_004163b0 at 0x004163B0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_0079629c;

  FUN_00415e50();

  param_1[1] = &PTR_FUN_00796294;

  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_00416410 at 0x00416410 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007962a0;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00796298;

  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_00416470 at 0x00416470 (size: 542) ---


void FUN_00416470(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  LONG *lpAddend;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0042ab60(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_00416572:

    puVar10 = puVar9;

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

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

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

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        FUN_00402400(uVar4);

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_00416572;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_0041667f:

      FUN_0040aa50();

    }

    else {

      uVar11 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar9 = (undefined4 *)FUN_005df0f5(0xc);

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

            puVar9 = (undefined4 *)0x0;

          }

          else {

            puVar9[1] = 0;

            lpAddend = (LONG *)(PTR_DAT_00818344 + -0x10);

            puVar9[2] = PTR_DAT_00818344;

            InterlockedIncrement(lpAddend);

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

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

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          FUN_00402400(uVar4);

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_0041667f;

          uVar11 = uVar11 + 1;

          puVar12 = puVar9;

          if (param_3 <= uVar11) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_00416690 at 0x00416690 (size: 110) ---


undefined4 * __fastcall FUN_00416690(undefined4 *param_1)



{

  FUN_00415460(DAT_00837c40);

  *param_1 = &PTR_LAB_007962c8;

  param_1[0xc] = &PTR_FUN_007962a0;

  FUN_00415dc0(0x10);

  param_1[0x29] = &PTR_FUN_007962a0;

  FUN_00415dc0(0x10);

  param_1[0x46] = &PTR_FUN_0079629c;

  FUN_00415d30(0x10);

  param_1[99] = &PTR_FUN_0079629c;

  FUN_00415d30(0x10);

  return param_1;

}





// --- FUN_00416710 at 0x00416710 (size: 298) ---


void __fastcall FUN_00416710(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007962c8;

  FUN_005870f0();

  FUN_00415e50();

  FUN_005870f0();

  FUN_00415e50();

  param_1[99] = &PTR_FUN_0079629c;

  FUN_00415e50();

  param_1[100] = &PTR_FUN_00796294;

  if ((undefined4 *)param_1[0x7c] != param_1 + 0x65) {

    operator_delete__((undefined4 *)param_1[0x7c]);

  }

  param_1[0x7c] = 0;

  param_1[0x7d] = 0;

  param_1[0x7e] = 0;

  param_1[0x7f] = 0;

  param_1[0x46] = &PTR_FUN_0079629c;

  FUN_00415e50();

  param_1[0x47] = &PTR_FUN_00796294;

  if ((undefined4 *)param_1[0x5f] != param_1 + 0x48) {

    operator_delete__((undefined4 *)param_1[0x5f]);

  }

  param_1[0x5f] = 0;

  param_1[0x60] = 0;

  param_1[0x61] = 0;

  param_1[0x62] = 0;

  param_1[0x29] = &PTR_FUN_007962a0;

  FUN_005870f0();

  param_1[0x2a] = &PTR_FUN_00796298;

  if ((undefined4 *)param_1[0x42] != param_1 + 0x2b) {

    operator_delete__((undefined4 *)param_1[0x42]);

  }

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  param_1[0x44] = 0;

  param_1[0x45] = 0;

  param_1[0xc] = &PTR_FUN_007962a0;

  FUN_005870f0();

  param_1[0xd] = &PTR_FUN_00796298;

  if ((undefined4 *)param_1[0x25] != param_1 + 0xe) {

    operator_delete__((undefined4 *)param_1[0x25]);

  }

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  FUN_004154b0();

  return;

}





// --- FUN_00416870 at 0x00416870 (size: 30) ---


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



{

  FUN_00416710();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00416890 at 0x00416890 (size: 177) ---


void __thiscall FUN_00416890(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_2;

  FUN_00415590(param_2);

  if ((~*(byte *)(iVar1 + 4) & 1) != 0) {

    FUN_005870f0();

  }

  FUN_00415f00(&param_2,param_1 + 0x34,iVar1);

  if ((~*(byte *)(iVar1 + 4) & 1) != 0) {

    FUN_00415e50();

  }

  FUN_00416470(&param_2,param_1 + 0x11c,iVar1);

  if ((~*(byte *)(iVar1 + 4) & 1) != 0) {

    FUN_005870f0();

  }

  FUN_00415f00(&param_2,param_1 + 0xa8,iVar1);

  if ((~*(byte *)(iVar1 + 4) & 1) != 0) {

    FUN_00415e50();

  }

  FUN_00416470(&param_2,param_1 + 400,iVar1);

  return;

}





// --- FUN_00416970 at 0x00416970 (size: 46) ---


undefined4 __thiscall FUN_00416970(int *param_1,char param_2)



{

  char cVar1;

  undefined4 in_EAX;

  undefined3 uVar2;

  undefined3 extraout_var;

  

  uVar2 = (undefined3)((uint)in_EAX >> 8);

  cVar1 = *(char *)((int)param_1 + 0xf1);

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

    *(char *)((int)param_1 + 0xf1) = param_2;

    if ((cVar1 != '\0') && (param_2 == '\0')) {

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

      uVar2 = extraout_var;

    }

  }

  return CONCAT31(uVar2,cVar1);

}





// --- FUN_004169a0 at 0x004169A0 (size: 76) ---


void __thiscall FUN_004169a0(int *param_1,int *param_2)



{

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

    (**(code **)(*param_2 + 0x2c))();

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

    if ((*(char *)((int)param_1 + 0xf1) == '\0') || ((char)param_2[0xb] == '\0')) {

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

    }

    else if (*(char *)((int)param_1 + 0xf2) != '\0') {

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

      return;

    }

  }

  return;

}





// --- FUN_00416a70 at 0x00416A70 (size: 70) ---


int * __fastcall FUN_00416a70(int *param_1)



{

  int *piVar1;

  

  if (((char)param_1[0x3d] != '\0') && ((uint)param_1[0x3e] < (uint)param_1[0x42])) {

    piVar1 = (int *)(**(code **)(*param_1 + 0x50))();

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

      (**(code **)(*param_1 + 0x3c))(piVar1);

      (**(code **)(*piVar1 + 0x3c))();

      return piVar1;

    }

  }

  piVar1 = (int *)(*(code *)param_1[0x44])();

  return piVar1;

}





// --- FUN_00416ac0 at 0x00416AC0 (size: 69) ---


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



void __fastcall FUN_00416ac0(int *param_1)



{

  int iVar1;

  

  if ((((uint)param_1[0x3e] < (uint)param_1[0x42]) && (iVar1 = param_1[0x40], iVar1 != 0)) &&

     (*(double *)(iVar1 + 0x10) + _DAT_00796330 < _DAT_008379a8)) {

    (**(code **)(*param_1 + 0x4c))(iVar1);

    (**(code **)(*param_1 + 0x44))(iVar1);

  }

  return;

}





// --- FUN_00416b10 at 0x00416B10 (size: 32) ---


void __fastcall FUN_00416b10(int *param_1)



{

  undefined4 uVar1;

  

  while (param_1[0x42] != 0) {

    uVar1 = (**(code **)(*param_1 + 0x50))();

    (**(code **)(*param_1 + 0x44))(uVar1);

  }

  return;

}





// --- FUN_00416bd0 at 0x00416BD0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00796338;

  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_00416c10 at 0x00416C10 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_0079633c;

  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_00416c50 at 0x00416C50 (size: 44) ---


undefined4 __thiscall FUN_00416c50(int param_1,uint param_2)



{

  uint *puVar1;

  bool bVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x68) + (param_2 % *(uint *)(param_1 + 0x70)) * 4);

  bVar2 = puVar1 == (uint *)0x0;

  if (!bVar2) {

    do {

      if (*puVar1 == param_2) break;

      puVar1 = (uint *)puVar1[1];

    } while (puVar1 != (uint *)0x0);

    bVar2 = puVar1 == (uint *)0x0;

  }

  return CONCAT31((int3)((uint)puVar1 >> 8),!bVar2);

}





// --- FUN_00416cd0 at 0x00416CD0 (size: 143) ---


undefined4 * __thiscall FUN_00416cd0(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_0079633c;

  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_00416d60 at 0x00416D60 (size: 143) ---


undefined4 * __thiscall FUN_00416d60(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_00796338;

  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_00416df0 at 0x00416DF0 (size: 73) ---


void __fastcall FUN_00416df0(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_00417020(*puVar2);

  return;

}





// --- FUN_00416e40 at 0x00416E40 (size: 100) ---


bool __thiscall FUN_00416e40(int *param_1,uint param_2)



{

  int *piVar1;

  uint *puVar2;

  int *piVar3;

  

  piVar3 = (int *)0x0;

  puVar2 = *(uint **)(param_1[0x1a] + (param_2 % (uint)param_1[0x1c]) * 4);

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

    while (*puVar2 != param_2) {

      puVar2 = (uint *)puVar2[1];

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

        return false;

      }

    }

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

      piVar3 = (int *)puVar2[2];

      (**(code **)(*param_1 + 0x4c))(piVar3);

      (**(code **)(*param_1 + 0x3c))(piVar3);

      piVar1 = piVar3 + 9;

      *piVar1 = *piVar1 + -1;

      if (*piVar1 == 0) {

        (**(code **)(*piVar3 + 0x18))(1);

      }

    }

  }

  return piVar3 != (int *)0x0;

}





// --- FUN_00416eb0 at 0x00416EB0 (size: 133) ---


int * __thiscall FUN_00416eb0(int *param_1,uint param_2,char param_3)



{

  uint *puVar1;

  int *piVar2;

  char cVar3;

  

  puVar1 = *(uint **)(param_1[0x1a] + (param_2 % (uint)param_1[0x1c]) * 4);

  while( true ) {

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

      return (int *)0x0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return (int *)0x0;

  }

  piVar2 = (int *)puVar1[2];

  if ((piVar2 == (int *)0x0) || (piVar2[9] < 2)) {

    (**(code **)(*param_1 + 0x4c))(piVar2);

  }

  piVar2[9] = piVar2[9] + 1;

  if (((char)piVar2[2] == '\0') && (param_3 != '\0')) {

    cVar3 = (**(code **)(*piVar2 + 0x28))();

    if (cVar3 == '\0') {

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

      return (int *)0x0;

    }

    *(undefined1 *)(piVar2 + 2) = 1;

  }

  return piVar2;

}





// --- FUN_00416f40 at 0x00416F40 (size: 87) ---


uint __thiscall FUN_00416f40(int param_1,uint param_2)



{

  uint *puVar1;

  uint uVar2;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x68) + (param_2 % *(uint *)(param_1 + 0x70)) * 4);

  while( true ) {

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

      return 0;

    }

    if (*puVar1 == param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return 0;

  }

  uVar2 = puVar1[2];

  if ((uVar2 != 0) && (1 < *(int *)(uVar2 + 0x24))) {

    *(int *)(uVar2 + 0x24) = *(int *)(uVar2 + 0x24) + 1;

    return uVar2;

  }

  return 0;

}





// --- FUN_00417020 at 0x00417020 (size: 310) ---


undefined4 __thiscall FUN_00417020(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_00417020(*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_0041706f;

      }

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

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

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_0041706f:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_00417082:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

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

      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_00417160 at 0x00417160 (size: 120) ---


uint __thiscall FUN_00417160(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_0041718b:

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

        FUN_00416df0();

      }

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

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_004171e0 at 0x004171E0 (size: 81) ---


uint * __thiscall FUN_004171e0(int param_1,uint *param_2)



{

  uint *puVar1;

  uint uVar2;

  

  uVar2 = *param_2 % *(uint *)(param_1 + 0x68);

  puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + uVar2 * 4);

  while( true ) {

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

      return (uint *)0x0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return (uint *)0x0;

  }

  FUN_00428ba0(param_1,*(int *)(param_1 + 0x60) + uVar2 * 4,puVar1);

  return puVar1;

}





// --- FUN_00417240 at 0x00417240 (size: 88) ---


undefined4 FUN_00417240(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

  }

  cVar1 = FUN_00417160(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_004172a0 at 0x004172A0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00796348;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00796338;

  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_00417300 at 0x00417300 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00796340;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_0079633c;

  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_00417360 at 0x00417360 (size: 212) ---


void __fastcall FUN_00417360(undefined4 *param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 *puVar3;

  undefined1 local_c [12];

  

  *param_1 = &PTR_FUN_007c6a98;

  iVar1 = FUN_0052dcf0(local_c);

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

joined_r0x00417384:

  do {

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

      param_1[0x1f] = &PTR_FUN_00796340;

      FUN_005870f0();

      param_1[0x20] = &PTR_FUN_0079633c;

      if ((undefined4 *)param_1[0x38] != param_1 + 0x21) {

        operator_delete__((undefined4 *)param_1[0x38]);

      }

      param_1[0x38] = 0;

      param_1[0x39] = 0;

      param_1[0x3a] = 0;

      param_1[0x3b] = 0;

      param_1[1] = &PTR_FUN_00796348;

      FUN_005870f0();

      param_1[2] = &PTR_FUN_00796338;

      if ((undefined4 *)param_1[0x1a] != param_1 + 3) {

        operator_delete__((undefined4 *)param_1[0x1a]);

      }

      param_1[0x1a] = 0;

      param_1[0x1b] = 0;

      param_1[0x1c] = 0;

      param_1[0x1d] = 0;

      return;

    }

    FUN_00416e40(*puVar3);

    piVar2 = (int *)param_1[0x1b];

    while (piVar2 != (int *)(param_1[0x1a] + param_1[0x1c] * 4)) {

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

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

        goto joined_r0x00417384;

      }

      piVar2 = (int *)param_1[0x1b] + 1;

      param_1[0x1b] = piVar2;

    }

    puVar3 = (undefined4 *)0x0;

  } while( true );

}





// --- FUN_00417510 at 0x00417510 (size: 192) ---


undefined4 * __thiscall FUN_00417510(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  

  *param_1 = &PTR_FUN_007c6a98;

  param_1[1] = &PTR_FUN_00796348;

  FUN_00416d60(0x80);

  param_1[1] = &PTR_FUN_00796348;

  param_1[0x1e] = param_3;

  param_1[0x1f] = &PTR_FUN_00796340;

  FUN_00416cd0(0x17);

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

  *(undefined1 *)((int)param_1 + 0xf1) = 1;

  *(undefined1 *)((int)param_1 + 0xf2) = 1;

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

  *(undefined1 *)((int)param_1 + 0xf5) = 0;

  param_1[0x3e] = 0x10;

  param_1[0x3f] = 0x10;

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  param_1[0x44] = param_2;

  puVar1 = (undefined4 *)FUN_0041c500(param_1[0x1e]);

  param_1[0x3d] = *puVar1;

  param_1[0x3e] = puVar1[1];

  param_1[0x3f] = puVar1[2];

  return param_1;

}





// --- FUN_004175d0 at 0x004175D0 (size: 30) ---


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



{

  FUN_00417360();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00417600 at 0x00417600 (size: 28) ---


undefined4 * __fastcall FUN_00417600(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  FUN_00406d60();

  return param_1;

}





// --- FUN_00417620 at 0x00417620 (size: 27) ---


int FUN_00417620(void)



{

  int iVar1;

  

  FUN_004074b0(4,1);

  iVar1 = FUN_00406d80();

  return iVar1 + 4;

}





// --- FUN_00417640 at 0x00417640 (size: 32) ---


int FUN_00417640(void)



{

  uint uVar1;

  int iVar2;

  

  uVar1 = FUN_00406db0();

  if (4 < uVar1) {

    iVar2 = FUN_00406db0();

    return iVar2 + -4;

  }

  return 0;

}





// --- FUN_00417660 at 0x00417660 (size: 19) ---


void __thiscall FUN_00417660(int *param_1,int param_2)



{

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

  param_1[9] = param_2;

  return;

}





// --- FUN_00417680 at 0x00417680 (size: 24) ---


void __fastcall FUN_00417680(int param_1)



{

  if (*(int **)(param_1 + 0x24) != (int *)0x0) {

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

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

  }

  return;

}





// --- FUN_004176a0 at 0x004176A0 (size: 35) ---


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



{

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  FUN_004070d0(param_2 + 2);

  return param_1;

}





// --- FUN_004176d0 at 0x004176D0 (size: 48) ---


void __thiscall FUN_004176d0(int *param_1,int param_2)



{

  int iVar1;

  

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

  if (iVar1 == 0) {

                    /* WARNING: Could not recover jumptable at 0x004176fa. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

    return;

  }

  if (iVar1 != 1) {

    if (iVar1 == 2) {

                    /* WARNING: Could not recover jumptable at 0x004176e8. Too many branches */

                    /* WARNING: Treating indirect jump as call */

      (**(code **)(*param_1 + 100))();

      return;

    }

    return;

  }

                    /* WARNING: Could not recover jumptable at 0x004176f1. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

  return;

}





// --- FUN_00417710 at 0x00417710 (size: 5) ---


void __fastcall FUN_00417710(int *param_1)



{

                    /* WARNING: Could not recover jumptable at 0x00417712. Too many branches */

                    /* WARNING: Treating indirect jump as call */

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

  return;

}





// --- FUN_004178a0 at 0x004178A0 (size: 19) ---


void FUN_004178a0(void)



{

  FUN_00406f90();

  FUN_00406f90();

  return;

}





// --- FUN_004178c0 at 0x004178C0 (size: 79) ---


undefined4 __fastcall FUN_004178c0(int param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  LONG LVar3;

  uint uVar4;

  

  uVar4 = 0;

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

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

    return 1;

  }

  do {

    puVar1 = *(undefined4 **)(*(int *)(param_1 + 0x18) + uVar4 * 8);

    LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    uVar2 = *(uint *)(param_1 + 0x20);

    uVar4 = uVar4 + 1;

  } while (uVar4 < uVar2);

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

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_00417910 at 0x00417910 (size: 78) ---


void __fastcall FUN_00417910(int param_1)



{

  char cVar1;

  undefined4 uVar2;

  int *piVar3;

  

  if (*(int **)(param_1 + 0x24) != (int *)0x0) {

    if ((*(byte *)(param_1 + 0x60) & 4) == 0) {

      cVar1 = (**(code **)(**(int **)(param_1 + 0x24) + 0x24))();

      if (cVar1 == '\0') goto LAB_00417949;

    }

    uVar2 = (**(code **)(**(int **)(param_1 + 0x24) + 0x48))();

    piVar3 = (int *)FUN_00414590(uVar2);

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

      (**(code **)(*piVar3 + 0x18))(*(undefined4 *)(param_1 + 0x24));

    }

  }

LAB_00417949:

  if (*(int **)(param_1 + 0x24) != (int *)0x0) {

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

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

  }

  return;

}





// --- FUN_00417960 at 0x00417960 (size: 202) ---


void __thiscall FUN_00417960(int *param_1,int *param_2)



{

  char cVar1;

  int iVar2;

  

  if (param_2[5] == DAT_00837c50) {

    param_2[2] = 3;

  }

  else {

    iVar2 = param_2[3];

    if (iVar2 == 0) {

      iVar2 = (**(code **)*param_1)(param_2[10],param_2 + 4);

      (**(code **)(*param_2 + 0xc))();

      param_2[9] = iVar2;

      param_2[2] = 3;

      if (iVar2 != 0) {

        param_2[2] = 1;

        param_2[0x18] = param_2[0x18] | 4;

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

        return;

      }

    }

    else {

      if (iVar2 == 1) {

        cVar1 = (**(code **)(*param_1 + 4))(param_2 + 4);

        param_2[2] = (-(uint)(cVar1 != '\0') & 0xfffffffe) + 3;

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

        return;

      }

      if (iVar2 == 2) {

        cVar1 = (**(code **)(*param_1 + 8))(param_2 + 4,param_2 + 10);

        param_2[2] = (-(uint)(cVar1 != '\0') & 0xfffffffe) + 3;

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

        return;

      }

    }

  }

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

  return;

}





// --- FUN_00417cf0 at 0x00417CF0 (size: 109) ---


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



{

  char cVar1;

  int *piVar2;

  

  piVar2 = (int *)0x0;

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

    piVar2 = (int *)(**(code **)(*param_1 + 0x88))(param_2,param_3);

  }

  cVar1 = (**(code **)(*param_1 + 0x7c))(piVar2,param_2,param_3);

  if ((cVar1 != '\0') && (cVar1 = (**(code **)(*piVar2 + 0x24))(), cVar1 != '\0')) {

    (**(code **)(*param_1 + 0x94))(piVar2,param_3);

    return piVar2;

  }

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

    return (int *)0x0;

  }

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

  return (int *)0x0;

}





// --- FUN_00417d60 at 0x00417D60 (size: 80) ---


void __fastcall FUN_00417d60(int *param_1)



{

  int iVar1;

  int iVar2;

  

  param_1[2] = 0;

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

    operator_delete__((void *)*param_1);

    *param_1 = 0;

    param_1[1] = 0;

    return;

  }

  if (*param_1 != 0) {

    iVar2 = (param_1[1] & 0x7fffffffU) - 1;

    while (-1 < iVar2) {

      iVar2 = iVar2 + -1;

      iVar1 = *param_1;

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

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

    }

  }

  return;

}





// --- FUN_00417db0 at 0x00417DB0 (size: 124) ---


undefined4 __thiscall FUN_00417db0(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  LONG LVar5;

  int *piVar6;

  

  uVar4 = 0;

  if (*(uint *)(param_1 + 0x20) != 0) {

    piVar6 = *(int **)(param_1 + 0x18);

    do {

      if ((undefined4 *)*piVar6 == param_2) {

        if (uVar4 < *(uint *)(param_1 + 0x20)) {

          uVar1 = *(uint *)(param_1 + 0x20) - 1;

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

          if (uVar4 != uVar1) {

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

            *(undefined4 *)(iVar2 + uVar4 * 8) = *(undefined4 *)(iVar2 + uVar1 * 8);

            *(undefined4 *)(iVar2 + 4 + uVar4 * 8) = *(undefined4 *)(iVar2 + 4 + uVar1 * 8);

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

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

            *(undefined4 *)(iVar3 + iVar2 * 8) = 0;

            *(undefined4 *)(iVar3 + 4 + iVar2 * 8) = 0;

          }

        }

        LVar5 = InterlockedDecrement(param_2 + 1);

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

          (**(code **)*param_2)(1);

        }

        return 1;

      }

      uVar4 = uVar4 + 1;

      piVar6 = piVar6 + 2;

    } while (uVar4 < *(uint *)(param_1 + 0x20));

  }

  return 0;

}





// --- FUN_00417e30 at 0x00417E30 (size: 109) ---


void __fastcall FUN_00417e30(int param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    do {

      FUN_00417db0(param_1);

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

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

        LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        *(undefined4 *)(*(int *)(param_1 + 0x18) + uVar3 * 4) = 0;

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 0x20));

  }

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

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

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

  return;

}





// --- FUN_00417ea0 at 0x00417EA0 (size: 185) ---


void __thiscall

FUN_00417ea0(int *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,uint param_5,

            undefined4 param_6)



{

  uint uVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  LONG LVar5;

  int *unaff_ESI;

  uint uVar6;

  

  uVar1 = param_1[5];

  piVar3 = (int *)(**(code **)(*param_1 + 0x10))(&param_6,param_3,param_4,param_5,param_6);

  iVar2 = *piVar3;

  *unaff_ESI = iVar2;

  if (((char)param_1[0x43] == '\0') && (uVar6 = param_1[5], uVar1 < uVar6)) {

    while (uVar6 = uVar6 - 1,

          *(int *)(*(int *)(param_1[2] + ((param_1[3] + uVar6) % (uint)param_1[6]) * 4) + 0x24) !=

          iVar2) {

      if (uVar6 <= param_5) {

        return;

      }

    }

    puVar4 = (undefined4 *)(**(code **)(param_1[1] + 0xc))(uVar6);

    if (((undefined4 *)puVar4[3] != (undefined4 *)0x0) && (puVar4[9] != DAT_00837c54)) {

      (*(code *)**(undefined4 **)puVar4[3])(puVar4[9],puVar4[4],puVar4[5]);

    }

    LVar5 = InterlockedDecrement(puVar4 + 1);

    if (LVar5 == 0) {

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

    }

  }

  return;

}





// --- FUN_00417ff0 at 0x00417FF0 (size: 172) ---


undefined4 __thiscall FUN_00417ff0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

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

    return 0;

  }

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

    if (param_2 == 0) {

      FUN_00417d60();

      return 1;

    }

    iVar2 = thunk_FUN_005df0f5(param_2 * 8);

    if (iVar2 == 0) {

      return 0;

    }

    FUN_00401000(iVar2,8,param_2,&LAB_004175f0);

    if (*param_1 != 0) {

      iVar3 = param_1[2] + -1;

      while (-1 < iVar3) {

        iVar3 = iVar3 + -1;

        iVar1 = *param_1;

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

        *(undefined4 *)(iVar2 + 0xc + iVar3 * 8) = *(undefined4 *)(iVar1 + 0xc + iVar3 * 8);

      }

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

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar2;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_004180a0 at 0x004180A0 (size: 148) ---


undefined4 __thiscall FUN_004180a0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  

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

    return 0;

  }

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

    if (param_2 == 0) {

      FUN_0044dcb0();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 4);

    if (iVar1 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      iVar2 = param_1[2] + -1;

      while (-1 < iVar2) {

        iVar2 = iVar2 + -1;

        *(undefined4 *)(iVar1 + 4 + iVar2 * 4) = *(undefined4 *)(*param_1 + 4 + iVar2 * 4);

      }

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

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_00418150 at 0x00418150 (size: 65) ---


void __fastcall FUN_00418150(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_00796360;

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

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

    param_1[9] = 0;

  }

  if ((param_1[7] & 0x80000000) == 0x80000000) {

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

  }

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_004181a0 at 0x004181A0 (size: 322) ---


void __fastcall FUN_004181a0(undefined4 *param_1)



{

  undefined4 *puVar1;

  char cVar2;

  LONG LVar3;

  undefined4 uVar4;

  int *piVar5;

  uint uVar6;

  

  uVar6 = 0;

  *param_1 = &PTR_FUN_00796374;

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

    do {

      puVar1 = *(undefined4 **)(param_1[0xe] + uVar6 * 4);

      LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

      }

      uVar6 = uVar6 + 1;

    } while (uVar6 < (uint)param_1[0x10]);

  }

  uVar6 = 0;

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

    do {

      puVar1 = *(undefined4 **)(param_1[0xb] + uVar6 * 4);

      LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

      }

      uVar6 = uVar6 + 1;

    } while (uVar6 < (uint)param_1[0xd]);

  }

  if (((int *)param_1[9] != (int *)0x0) &&

     (((*(byte *)(param_1 + 0x18) & 4) != 0 ||

      (cVar2 = (**(code **)(*(int *)param_1[9] + 0x24))(), cVar2 != '\0')))) {

    uVar4 = (**(code **)(*(int *)param_1[9] + 0x48))();

    piVar5 = (int *)FUN_00414590(uVar4);

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

      (**(code **)(*piVar5 + 0x18))(param_1[9]);

    }

  }

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

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

    param_1[9] = 0;

  }

  FUN_00406f90();

  FUN_00406f90();

  if ((param_1[0xf] & 0x80000000) == 0x80000000) {

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

  }

  if ((param_1[0xc] & 0x80000000) == 0x80000000) {

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

  }

  *param_1 = &PTR_FUN_00796360;

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

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

    param_1[9] = 0;

  }

  if ((param_1[7] & 0x80000000) == 0x80000000) {

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

  }

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_00418300 at 0x00418300 (size: 131) ---


void __fastcall FUN_00418300(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  uint uVar3;

  

  uVar3 = 0;

  *param_1 = &PTR_FUN_00796370;

  if (param_1[8] != 0) {

    do {

      FUN_00417db0(param_1);

      puVar1 = *(undefined4 **)(param_1[6] + uVar3 * 4);

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

        LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        *(undefined4 *)(param_1[6] + uVar3 * 4) = 0;

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < (uint)param_1[8]);

  }

  if ((param_1[7] & 0x80000000) == 0x80000000) {

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

  }

  *param_1 = &PTR_FUN_007952f4;

  return;

}





// --- FUN_00418390 at 0x00418390 (size: 85) ---


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



{

  *param_1 = &PTR_FUN_00796360;

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

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

    param_1[9] = 0;

  }

  if ((param_1[7] & 0x80000000) == 0x80000000) {

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

  }

  *param_1 = &PTR_FUN_007952f4;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004183f0 at 0x004183F0 (size: 30) ---


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



{

  FUN_00418300();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00418410 at 0x00418410 (size: 74) ---


undefined4 * __fastcall FUN_00418410(undefined4 *param_1)



{

  param_1[1] = 1;

  param_1[2] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  *param_1 = &PTR_FUN_00796374;

  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;

  param_1[0x12] = 0;

  FUN_00406d60();

  param_1[0x18] = 0;

  return param_1;

}





// --- FUN_00418460 at 0x00418460 (size: 30) ---


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



{

  FUN_004181a0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00418480 at 0x00418480 (size: 30) ---


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



{

  FUN_00418150();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004184a0 at 0x004184A0 (size: 40) ---


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



{

  FUN_004178a0();

  FUN_00418150();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004184d0 at 0x004184D0 (size: 61) ---


undefined4 FUN_004184d0(undefined4 param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  bool bVar3;

  

  puVar1 = PTR_DAT_00818558;

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_1,param_1,0);

  bVar3 = false;

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

    puVar2 = puVar2 + -1;

    bVar3 = puVar2 == (undefined4 *)puVar1;

  }

  if (!bVar3) {

    return puVar2[1];

  }

  return *puVar2;

}





// --- FUN_00418510 at 0x00418510 (size: 335) ---


void __thiscall FUN_00418510(int param_1,int *param_2)



{

  int *piVar1;

  int iVar2;

  uint *puVar3;

  int *piVar4;

  char cVar5;

  uint uVar6;

  

  piVar4 = param_2;

  if ((param_2[3] == 0) && (uVar6 = 0, param_2[8] != 0)) {

    do {

      piVar1 = (int *)(piVar4[6] + uVar6 * 8);

      iVar2 = *piVar1;

      if ((iVar2 != 0) && (*(char *)(iVar2 + 0x28) == '\0')) {

        piVar1 = piVar1 + 1;

        *piVar1 = *piVar1 + 1;

        if (*(int **)(iVar2 + 0xc) != (int *)0x0) {

          (**(code **)(**(int **)(iVar2 + 0xc) + 4))

                    (*(undefined4 *)(iVar2 + 0x24),piVar4[4],piVar4[5],piVar4[2],

                     *(undefined4 *)(iVar2 + 0x14),*(undefined4 *)(piVar4[6] + 4 + uVar6 * 8),piVar4

                    );

        }

      }

      uVar6 = uVar6 + 1;

    } while (uVar6 < (uint)piVar4[8]);

  }

  cVar5 = (**(code **)(*piVar4 + 4))();

  if (cVar5 != '\0') {

    uVar6 = 0;

    if (piVar4[8] != 0) {

      do {

        param_2 = *(int **)(piVar4[6] + uVar6 * 8);

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

          param_2[2] = param_2[2] + -1;

          if (piVar4[2] == 1) {

            if (param_2[4] == 3) {

              param_2[4] = 2;

            }

            else if (param_2[4] == 0) {

              param_2[4] = 1;

            }

          }

          else if (param_2[4] == 1) {

            param_2[4] = 2;

          }

          else if (param_2[4] == 0) {

            param_2[4] = piVar4[2];

          }

          if ((param_2[2] == 0) && ((char)param_2[10] == '\0')) {

            for (puVar3 = *(uint **)(*(int *)(param_1 + 0xf8) +

                                    ((uint)param_2[9] % *(uint *)(param_1 + 0x100)) * 4);

                puVar3 != (uint *)0x0; puVar3 = (uint *)puVar3[1]) {

              if (*puVar3 == param_2[9]) {

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

                  InterlockedIncrement(param_2 + 1);

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

                  (**(code **)(*(int *)(param_1 + 4) + 4))(&param_2);

                }

                break;

              }

            }

          }

        }

        uVar6 = uVar6 + 1;

      } while (uVar6 < (uint)piVar4[8]);

    }

    FUN_004178c0();

  }

  return;

}





// --- FUN_00418660 at 0x00418660 (size: 54) ---


undefined4 FUN_00418660(undefined4 param_1,undefined4 *param_2)



{

  undefined4 uVar1;

  undefined1 local_c [8];

  int local_4;

  

  FUN_00414190(local_c,param_1);

  if (local_4 != 0) {

    uVar1 = *(undefined4 *)(local_4 + 0xc);

    *param_2 = uVar1;

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

  }

  return 0;

}





// --- FUN_004186a0 at 0x004186A0 (size: 81) ---


void __thiscall FUN_004186a0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  char cVar3;

  uint uVar4;

  undefined4 uVar5;

  

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

  uVar4 = *(uint *)(param_1 + 0x1c) & 0x7fffffff;

  if (uVar4 <= *(uint *)(param_1 + 0x20)) {

    uVar5 = FUN_00453850(uVar4 + 1);

    cVar3 = FUN_00417ff0(uVar5);

    if (cVar3 == '\0') {

      return;

    }

  }

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

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

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

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

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

  return;

}





// --- FUN_00418700 at 0x00418700 (size: 146) ---


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



{

  int iVar1;

  undefined4 uVar2;

  undefined1 local_c [8];

  int local_4;

  

  FUN_00414190(local_c,param_4);

  if (local_4 != 0) {

    iVar1 = *(int *)(local_4 + 0xc);

    InterlockedIncrement((LONG *)(iVar1 + 4));

    return iVar1;

  }

  iVar1 = FUN_005df0f5(100);

  if (iVar1 == 0) {

    iVar1 = 0;

  }

  else {

    iVar1 = FUN_00418410();

  }

  uVar2 = (**(code **)(*param_1 + 0x38))(param_4);

  *(undefined4 *)(iVar1 + 0x5c) = uVar2;

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

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

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

  *(undefined4 *)(iVar1 + 0x14) = param_4[1];

  *(undefined4 *)(iVar1 + 0x58) = 1;

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

  return iVar1;

}





// --- FUN_004187a0 at 0x004187A0 (size: 152) ---


void __thiscall FUN_004187a0(int *param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined1 local_c [8];

  int local_4;

  

  FUN_00414190(local_c,param_2 + 0x10);

  if (((local_4 != 0) && (iVar1 = *(int *)(local_4 + 0xc), *(int *)(iVar1 + 8) == 0)) &&

     ((*(byte *)(iVar1 + 0x60) & 2) == 0)) {

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

    if (*(int *)(param_2 + 8) == 1) {

      iVar2 = FUN_00417620();

      if ((iVar2 == 0) || (iVar2 = FUN_00417640(), iVar2 == 0)) {

        (**(code **)(*param_1 + 0x9c))(param_2 + 0x10,param_2 + 0x28,0,0);

      }

      FUN_004176a0(param_2 + 0x28);

    }

    (**(code **)(*param_1 + 0x60))(iVar1);

  }

  (**(code **)(*param_1 + 0x6c))(param_2);

  return;

}





// --- FUN_004188d0 at 0x004188D0 (size: 250) ---


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



{

  char cVar1;

  int *piVar2;

  int *piVar3;

  int *piVar4;

  int unaff_EDI;

  bool bVar5;

  

  if (*(int *)(param_3 + 4) == DAT_00837c50) {

    return (int *)0x0;

  }

  piVar2 = (int *)(**(code **)(*param_1 + 0x38))(param_3);

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

    return (int *)0x0;

  }

  piVar3 = (int *)(**(code **)(*param_1 + 0x84))(param_3,piVar2);

  bVar5 = false;

  piVar4 = piVar3;

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

    cVar1 = FUN_00418660(param_3,&stack0xfffffffc);

    piVar4 = piRam00000024;

    if ((cVar1 == '\0') || (piVar3 = piRam00000024, piRam00000024 == (int *)0x0)) {

      piVar4 = piVar3;

      cVar1 = (**(code **)(*piVar2 + 0x20))();

      if (cVar1 != '\0') {

        piVar4 = (int *)(**(code **)(*param_1 + 0x78))(param_3,piVar2);

      }

    }

    else {

      if (((uRam00000060 & 4) == 0) &&

         (cVar1 = (**(code **)(*piRam00000024 + 0x24))(), cVar1 == '\0')) {

        return (int *)0x0;

      }

      uRam00000060 = uRam00000060 | 4;

      (**(code **)(*param_1 + 0x94))(piVar4,piVar2);

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

    }

    bVar5 = piVar4 == (int *)0x0;

  }

  if (!bVar5) {

    if ((char)piVar4[2] != '\0') {

      return piVar4;

    }

    if (unaff_EDI == 1) {

      return piVar4;

    }

    cVar1 = (**(code **)(*piVar4 + 0x28))();

    if (cVar1 != '\0') {

      *(undefined1 *)(piVar4 + 2) = 1;

      return piVar4;

    }

  }

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

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

  }

  return (int *)0x0;

}





// --- FUN_00418a10 at 0x00418A10 (size: 143) ---


undefined4 * __thiscall FUN_00418a10(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_00795f88;

  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_00418aa0 at 0x00418AA0 (size: 143) ---


undefined4 * __thiscall FUN_00418aa0(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_00795f8c;

  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_00418b30 at 0x00418B30 (size: 269) ---


undefined4 __thiscall FUN_00418b30(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  int *piVar4;

  undefined4 uVar5;

  int *piVar6;

  uint uVar7;

  int *piVar8;

  

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

    return 0;

  }

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

  piVar2 = (int *)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(param_2);

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

        piVar8 = (int *)piVar2[2];

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

          uVar5 = FUN_004184d0(*(int *)(param_1 + 0x68));

          FUN_00418b30(uVar5);

        }

        uVar7 = (uint)(piVar2[1] + *piVar2) % *(uint *)(param_1 + 0x68);

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

        piVar2[2] = *(int *)(iVar1 + uVar7 * 4);

        *(int **)(iVar1 + uVar7 * 4) = piVar2;

        uVar7 = iVar1 + uVar7 * 4;

        if (uVar7 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar7;

        }

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

        piVar2 = piVar8;

      }

      return 1;

    }

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

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

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

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

        piVar6 = (int *)*piVar8;

        goto LAB_00418b7e;

      }

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

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

    }

    piVar8 = (int *)0x0;

    piVar6 = (int *)0x0;

LAB_00418b7e:

    piVar4 = (int *)*piVar8;

    if (piVar4 == piVar6) {

LAB_00418b91:

      *piVar8 = piVar4[2];

    }

    else {

      do {

        piVar3 = piVar4;

        piVar4 = (int *)piVar3[2];

      } while (piVar4 != piVar6);

      if (piVar3 == (int *)0x0) goto LAB_00418b91;

      piVar3[2] = piVar4[2];

    }

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

    piVar6[2] = (int)piVar2;

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

    piVar2 = piVar6;

  } while( true );

}





// --- FUN_00418c40 at 0x00418C40 (size: 73) ---


void __fastcall FUN_00418c40(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_00418b30(*puVar2);

  return;

}





// --- FUN_00418c90 at 0x00418C90 (size: 83) ---


void __thiscall FUN_00418c90(int param_1,int param_2)



{

  char cVar1;

  uint uVar2;

  undefined4 uVar3;

  

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

  uVar2 = *(uint *)(param_1 + 0x1c) & 0x7fffffff;

  if (uVar2 <= *(uint *)(param_1 + 0x20)) {

    uVar3 = FUN_00453850(uVar2 + 1);

    cVar1 = FUN_004180a0(uVar3);

    if (cVar1 == '\0') goto LAB_00418cd5;

  }

  *(int *)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0x20) * 4) = param_2;

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

LAB_00418cd5:

  FUN_004186a0(param_1);

  return;

}





// --- FUN_00419170 at 0x00419170 (size: 207) ---


void FUN_00419170(undefined4 param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  int local_c;

  int *local_8;

  int local_4;

  

  FUN_0052dcf0(&local_c);

joined_r0x00419187:

  do {

    if (local_4 == 0) {

      return;

    }

    do {

      if ((param_2 == 1) ||

         ((param_2 != 2 && ((param_2 != 3 || ((~(byte)(*(uint *)(local_4 + 0xc) >> 3) & 1) == 0)))))

         ) {

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

        piVar3 = local_8;

        iVar4 = iVar2;

        if (iVar2 != 0) goto LAB_004191df;

        goto LAB_004191d0;

      }

      local_4 = *(int *)(local_4 + 8);

    } while (local_4 != 0);

    do {

      local_8 = local_8 + 1;

      if (local_8 == (int *)(*(int *)(local_c + 0x60) + *(int *)(local_c + 0x68) * 4)) {

        return;

      }

      local_4 = *local_8;

    } while (local_4 == 0);

  } while( true );

  while (iVar4 = *piVar3, iVar4 == 0) {

LAB_004191d0:

    piVar3 = piVar3 + 1;

    iVar4 = iVar2;

    if (piVar3 == (int *)(*(int *)(local_c + 0x60) + *(int *)(local_c + 0x68) * 4)) break;

  }

LAB_004191df:

  iVar2 = *local_8;

  if (iVar2 != local_4) {

    do {

      iVar1 = iVar2;

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

    } while (iVar2 != local_4);

    if (iVar1 != 0) {

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

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

      local_8 = piVar3;

      local_4 = iVar4;

      goto joined_r0x00419187;

    }

  }

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

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

  local_8 = piVar3;

  local_4 = iVar4;

  goto joined_r0x00419187;

}





// --- FUN_00419240 at 0x00419240 (size: 110) ---


uint __thiscall FUN_00419240(int param_1,int *param_2)



{

  int iVar1;

  uint uVar2;

  undefined1 local_c [8];

  uint local_4;

  

  FUN_00414190(local_c,param_2);

  if (local_4 != 0) {

    return local_4 & 0xffffff00;

  }

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

    FUN_00414ce0();

  }

  uVar2 = (uint)(param_2[1] + *param_2) % *(uint *)(param_1 + 0x68);

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

  param_2[2] = *(int *)(iVar1 + uVar2 * 4);

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

  uVar2 = iVar1 + uVar2 * 4;

  if (uVar2 < *(uint *)(param_1 + 100)) {

    *(uint *)(param_1 + 100) = uVar2;

  }

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

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_004192b0 at 0x004192B0 (size: 120) ---


uint __thiscall FUN_004192b0(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_004192db:

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

        FUN_00414d30();

      }

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

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00419470 at 0x00419470 (size: 94) ---


undefined4 FUN_00419470(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = param_1[1];

    puVar2[2] = 0;

    puVar2[3] = *param_2;

  }

  cVar1 = FUN_00419240(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_004194d0 at 0x004194D0 (size: 88) ---


undefined4 FUN_004194d0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

  }

  cVar1 = FUN_004192b0(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_00419530 at 0x00419530 (size: 188) ---


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



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  

  iVar2 = (int)param_2;

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

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

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

    }

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

    *(int *)(param_1 + 0x108) = iVar1 + 1;

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

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      puVar3[1] = 1;

      *puVar3 = &PTR_FUN_00796370;

      puVar3[2] = 0;

      puVar3[3] = iVar2;

      puVar3[4] = 0;

      puVar3[5] = param_3;

      puVar3[6] = 0;

      puVar3[7] = 0;

      puVar3[8] = 0;

      puVar3[9] = iVar1;

      *(undefined1 *)(puVar3 + 10) = 0;

    }

    puVar3[2] = puVar3[2] + param_4;

    param_2 = puVar3;

    InterlockedIncrement(puVar3 + 1);

    param_3 = puVar3[9];

    FUN_004194d0(&param_3,&param_2);

    return puVar3;

  }

  return (undefined4 *)0x0;

}





// --- FUN_00419aa0 at 0x00419AA0 (size: 69) ---


void __thiscall FUN_00419aa0(int *param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  char cVar3;

  

  iVar2 = param_2;

  cVar3 = FUN_00419470(param_2 + 0x10,&param_2);

  if (cVar3 != '\0') {

    InterlockedIncrement((LONG *)(iVar2 + 4));

    uVar1 = *(uint *)(iVar2 + 0x60);

    *(uint *)(iVar2 + 0x60) = uVar1 | 1;

    *(uint *)(iVar2 + 0x60) = uVar1 | 3;

    (**(code **)(*param_1 + 0x50))(iVar2);

  }

  return;

}





// --- FUN_00419d10 at 0x00419D10 (size: 633) ---


/* WARNING: Removing unreachable block (ram,0x00419edd) */

/* WARNING: Removing unreachable block (ram,0x00419e3a) */

/* WARNING: Removing unreachable block (ram,0x00419e56) */

/* WARNING: Removing unreachable block (ram,0x00419e5f) */

/* WARNING: Removing unreachable block (ram,0x00419e71) */

/* WARNING: Removing unreachable block (ram,0x00419e42) */

/* WARNING: Removing unreachable block (ram,0x00419e4b) */

/* WARNING: Removing unreachable block (ram,0x00419f3c) */



undefined4 FUN_00419d10(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  char cVar5;

  undefined4 uVar6;

  uint uVar7;

  uint local_80;

  undefined1 local_6c [92];

  undefined1 *local_10;

  uint local_8;

  

  FUN_00414820(0x17);

  uVar6 = FUN_00453850(1);

  cVar5 = FUN_004180a0(uVar6);

  if (cVar5 != '\0') {

    iRam00000000 = param_1;

  }

  local_80 = (uint)(cVar5 != '\0');

  FUN_00414d80(param_1 + 0x10);

  do {

    do {

      if (local_80 == 0) {

        FUN_0041a390();

        if (local_10 != local_6c) {

          operator_delete__(local_10);

        }

        return 0;

      }

      uVar7 = 0;

      local_80 = local_80 - 1;

      iVar2 = *(int *)(local_80 * 4);

      *(undefined4 *)(local_80 * 4) = 0;

    } while (*(int *)(iVar2 + 0x40) == 0);

    do {

      piVar1 = (int *)(*(int *)(iVar2 + 0x38) + uVar7 * 4);

      iVar3 = *piVar1;

      if ((iVar3 == param_2) ||

         ((*(int *)(param_2 + 0x10) == *(int *)(iVar3 + 0x10) &&

          (*(int *)(param_2 + 0x14) == *(int *)(iVar3 + 0x14))))) {

        FUN_0041a390();

        if (local_10 != local_6c) {

          operator_delete__(local_10);

        }

        return 1;

      }

      for (piVar4 = *(int **)(local_10 +

                             ((uint)(*(int *)(iVar3 + 0x10) + *(int *)(iVar3 + 0x14)) % local_8) * 4

                             ); piVar4 != (int *)0x0; piVar4 = (int *)piVar4[2]) {

        if ((*piVar4 == *(int *)(iVar3 + 0x10)) && (piVar4[1] == *(int *)(iVar3 + 0x14))) {

          if (piVar4 != (int *)0x0) goto LAB_00419eb1;

          break;

        }

      }

      cVar5 = FUN_004180a0(8);

      if (cVar5 != '\0') {

        *(int *)(local_80 * 4) = *piVar1;

        local_80 = local_80 + 1;

      }

      FUN_00414d80(*(int *)(*(int *)(iVar2 + 0x38) + uVar7 * 4) + 0x10);

LAB_00419eb1:

      uVar7 = uVar7 + 1;

    } while (uVar7 < *(uint *)(iVar2 + 0x40));

  } while( true );

}





// --- FUN_00419f90 at 0x00419F90 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007963a4;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_00795f8c;

  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_0041a1b0 at 0x0041A1B0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007963a8;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_00795f88;

  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_0041a210 at 0x0041A210 (size: 137) ---


undefined4 * __fastcall FUN_0041a210(undefined4 *param_1)



{

  undefined4 uVar1;

  

  *param_1 = &PTR_FUN_007963b0;

  param_1[1] = &PTR_FUN_00795f70;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0x100;

  uVar1 = thunk_FUN_005df0f5(0x4000);

  param_1[2] = uVar1;

  param_1[6] = 0x1000;

  param_1[8] = &PTR_FUN_007963a8;

  FUN_00418a10(0);

  param_1[8] = &PTR_FUN_007963a8;

  param_1[0x25] = &PTR_FUN_007963a4;

  FUN_00418aa0(0);

  param_1[0x25] = &PTR_FUN_007963a4;

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

  param_1[0x42] = 1;

  return param_1;

}





// --- FUN_0041a2a0 at 0x0041A2A0 (size: 120) ---


void __thiscall FUN_0041a2a0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  int *piVar4;

  undefined1 local_c [12];

  

  puVar3 = (undefined4 *)FUN_0052dcf0(local_c);

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

  iVar1 = puVar3[2];

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

  *(undefined4 *)(param_1 + 0x74) = puVar3[1];

  do {

    if ((iVar1 == 0) || (param_2 == 0)) {

      return;

    }

    iVar1 = *(int *)(*(int *)(param_1 + 0x78) + 8);

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

    if (iVar1 == 0) {

      iVar1 = *(int *)(*(int *)(param_1 + 0x70) + 0x68);

      iVar2 = *(int *)(*(int *)(param_1 + 0x70) + 0x60);

      do {

        piVar4 = (int *)(*(int *)(param_1 + 0x74) + 4);

        *(int **)(param_1 + 0x74) = piVar4;

        if (piVar4 == (int *)(iVar2 + iVar1 * 4)) goto LAB_0041a307;

      } while (*piVar4 == 0);

      *(int *)(param_1 + 0x78) = *piVar4;

    }

LAB_0041a307:

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

    param_2 = param_2 + -1;

  } while( true );

}





// --- FUN_0041a320 at 0x0041A320 (size: 110) ---


uint __thiscall FUN_0041a320(int param_1,int *param_2)



{

  int iVar1;

  uint uVar2;

  undefined1 local_c [8];

  uint local_4;

  

  FUN_00414190(local_c,param_2);

  if (local_4 != 0) {

    return local_4 & 0xffffff00;

  }

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

    FUN_00418c40();

  }

  uVar2 = (uint)(param_2[1] + *param_2) % *(uint *)(param_1 + 0x68);

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

  param_2[2] = *(int *)(iVar1 + uVar2 * 4);

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

  uVar2 = iVar1 + uVar2 * 4;

  if (uVar2 < *(uint *)(param_1 + 100)) {

    *(uint *)(param_1 + 100) = uVar2;

  }

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

  return CONCAT31((int3)(uVar2 >> 8),1);

}





// --- FUN_0041a390 at 0x0041A390 (size: 122) ---


void __fastcall FUN_0041a390(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  void *pvVar4;

  int *piVar5;

  

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

  do {

    if (iVar1 == 0) {

      return;

    }

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

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

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

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

        pvVar4 = (void *)*piVar5;

        goto LAB_0041a3cf;

      }

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

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

    }

    piVar5 = (int *)0x0;

    pvVar4 = (void *)0x0;

LAB_0041a3cf:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar4) {

LAB_0041a3e2:

      *piVar5 = *(int *)((int)pvVar3 + 8);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 8);

      } while (pvVar3 != pvVar4);

      if (pvVar2 == (void *)0x0) goto LAB_0041a3e2;

      *(undefined4 *)((int)pvVar2 + 8) = *(undefined4 *)((int)pvVar3 + 8);

    }

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

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

      operator_delete(pvVar4);

    }

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

  } while( true );

}





// --- FUN_0041a410 at 0x0041A410 (size: 55) ---


void __fastcall FUN_0041a410(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_00795f98;

  FUN_0041a390();

  *param_1 = &PTR_FUN_00795f84;

  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;

  return;

}





// --- FUN_0041a450 at 0x0041A450 (size: 131) ---


char __thiscall FUN_0041a450(int param_1,void *param_2)



{

  uint uVar1;

  char cVar2;

  uint uVar3;

  undefined1 local_c [8];

  int local_4;

  

  cVar2 = '\0';

  if ((*(int *)((int)param_2 + 4) == DAT_00837c5c) || (cVar2 = FUN_0041a320(param_2), cVar2 == '\0')

     ) {

    FUN_00414190(local_c,param_2);

    if (local_4 != 0) {

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

      uVar3 = (uVar1 | *(uint *)((int)param_2 + 0xc)) & DAT_00837c58 |

              uVar1 & *(uint *)((int)param_2 + 0xc);

      cVar2 = uVar3 != uVar1;

      *(uint *)(local_4 + 0xc) = uVar3;

    }

    operator_delete(param_2);

    if (cVar2 == '\0') {

      return '\0';

    }

  }

  *(int *)(param_1 + 0x70) = param_1;

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

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

  return cVar2;

}





// --- FUN_0041a4e0 at 0x0041A4E0 (size: 170) ---


uint FUN_0041a4e0(undefined4 *param_1,uint param_2)



{

  undefined4 uVar1;

  uint uVar2;

  undefined4 *puVar3;

  uint uVar4;

  undefined1 local_c [8];

  int local_4;

  

  if (param_1[1] == DAT_00837c5c) {

    return param_1[1] & 0xffffff00;

  }

  FUN_00414190(local_c,param_1);

  if (local_4 != 0) {

    uVar4 = *(uint *)(local_4 + 0xc);

    uVar2 = (uVar4 | param_2) & DAT_00837c58 | uVar4 & param_2;

    *(uint *)(local_4 + 0xc) = uVar2;

    return CONCAT31((int3)(uVar2 >> 8),uVar2 != uVar4);

  }

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

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

    *puVar3 = *param_1;

    uVar1 = param_1[1];

    puVar3[3] = param_2;

    puVar3[1] = uVar1;

    puVar3[2] = 0;

    uVar4 = FUN_0041a450(puVar3);

    return uVar4;

  }

  uVar4 = FUN_0041a450(0);

  return uVar4;

}





// --- FUN_0041a590 at 0x0041A590 (size: 78) ---


undefined4 FUN_0041a590(int *param_1,undefined4 param_2)



{

  byte bVar1;

  undefined4 uVar2;

  uint uVar3;

  byte bVar4;

  uint uVar5;

  undefined4 uVar6;

  

  bVar4 = 0;

  uVar5 = 0;

  uVar3 = 0;

  if (param_1[2] != 0) {

    do {

      uVar6 = param_2;

      uVar2 = FUN_004220b0(*(undefined4 *)(*param_1 + uVar5 * 4),0);

      bVar1 = FUN_0041a4e0(uVar2,uVar6);

      bVar4 = bVar4 | bVar1;

      uVar3 = param_1[2];

      uVar5 = uVar5 + 1;

    } while (uVar5 < uVar3);

  }

  return CONCAT31((int3)(uVar3 >> 8),bVar4);

}





// --- FUN_0041a5f0 at 0x0041A5F0 (size: 11) ---


int FUN_0041a5f0(uint param_1)



{

  return 2 - (uint)(param_1 < 2);

}





// --- FUN_0041a600 at 0x0041A600 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_0079645c;

  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_0041a640 at 0x0041A640 (size: 143) ---


undefined4 * __thiscall FUN_0041a640(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_0079645c;

  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_0041a6d0 at 0x0041A6D0 (size: 156) ---


void __fastcall FUN_0041a6d0(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

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

  do {

    if (iVar1 == 0) {

      return;

    }

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

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

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

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

        pvVar5 = (void *)*piVar4;

        goto LAB_0041a70f;

      }

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

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

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_0041a70f:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_0041a722:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_0041a722;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

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

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

      if ((*(uint *)((int)pvVar5 + 0x10) & 0x80000000) == 0x80000000) {

        operator_delete__(*(void **)((int)pvVar5 + 0xc));

      }

      operator_delete(pvVar5);

    }

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

  } while( true );

}





// --- FUN_0041a770 at 0x0041A770 (size: 150) ---


undefined4 FUN_0041a770(undefined4 *param_1,int param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = &PTR_LAB_00795430;

    puVar2[3] = puVar2 + 6;

    puVar2[4] = 8;

    puVar2[5] = 0;

    FUN_00410a00(param_2 + 4);

  }

  cVar1 = FUN_0042bd40(puVar2);

  if (cVar1 == '\0') {

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

      if ((puVar2[4] & 0x80000000) == 0x80000000) {

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

      }

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_0041a810 at 0x0041A810 (size: 247) ---


uint * FUN_0041a810(uint param_1)



{

  uint *puVar1;

  uint uVar2;

  uint *puVar3;

  undefined **local_50;

  undefined1 *local_4c;

  uint local_48;

  undefined4 local_44;

  undefined1 local_40 [64];

  

  uVar2 = param_1;

  puVar3 = (uint *)0x0;

  for (puVar1 = *(uint **)(DAT_00818794 + (param_1 % DAT_0081879c) * 4); puVar1 != (uint *)0x0;

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

    if (*puVar1 == param_1) {

      if ((puVar1 != (uint *)0x0) && (puVar1 + 2 != (uint *)0x0)) {

        return puVar1 + 2;

      }

      break;

    }

  }

  local_4c = local_40;

  local_50 = &PTR_LAB_00795430;

  local_48 = 8;

  local_44 = 0;

  FUN_0041a770(&param_1,&local_50);

  if ((local_48 & 0x80000000) == 0x80000000) {

    operator_delete__(local_4c);

  }

  puVar1 = *(uint **)(DAT_00818794 + (uVar2 % DAT_0081879c) * 4);

  do {

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

LAB_0041a8ca:

      FUN_00410500(0x436f7265,2 - (uint)(uVar2 < 2));

      FUN_00410500(0x444f626a,uVar2);

      FUN_00410500(0x55494c20,2 < uVar2);

      return puVar3;

    }

    if (*puVar1 == uVar2) {

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

        puVar3 = puVar1 + 2;

      }

      goto LAB_0041a8ca;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_0041a910 at 0x0041A910 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_00796460;

  FUN_0041a6d0();

  param_1[1] = &PTR_FUN_0079645c;

  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_0041a970 at 0x0041A970 (size: 26) ---


undefined4 __fastcall FUN_0041a970(int param_1)



{

  if (*(int **)(param_1 + 0x34) != (int *)0x0) {

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

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

  }

  return 1;

}





// --- FUN_0041a9d0 at 0x0041A9D0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00796464;

  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_0041aa10 at 0x0041AA10 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_00796468;

  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_0041aa50 at 0x0041AA50 (size: 71) ---


uint __fastcall FUN_0041aa50(undefined4 *param_1)



{

  char *pcVar1;

  char cVar2;

  int iVar3;

  uint uVar4;

  char *pcVar5;

  

  pcVar5 = (char *)*param_1;

  uVar4 = 0;

  cVar2 = *pcVar5;

  while (cVar2 != '\0') {

    iVar3 = tolower((int)cVar2);

    uVar4 = uVar4 * 0x10 + (int)(char)iVar3;

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

      uVar4 = ((uVar4 & 0xf0000000) >> 0x18 ^ uVar4) & 0xfffffff;

    }

    pcVar1 = pcVar5 + 1;

    pcVar5 = pcVar5 + 1;

    cVar2 = *pcVar1;

  }

  return uVar4;

}





// --- FUN_0041aaa0 at 0x0041AAA0 (size: 42) ---


void FUN_0041aaa0(undefined4 param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  uVar1 = FUN_004220b0(param_1,0);

  FUN_0041a4e0(uVar1,param_2);

  return;

}





// --- FUN_0041ab00 at 0x0041AB00 (size: 72) ---


bool __thiscall FUN_0041ab00(int *param_1,int *param_2)



{

  if (*param_1 == 0) {

    return *param_2 != 0;

  }

  if ((*param_1 == *param_2) && (param_1[3] == param_2[3])) {

    return false;

  }

  return true;

}





// --- FUN_0041ab50 at 0x0041AB50 (size: 6) ---


undefined4 __fastcall FUN_0041ab50(int param_1)



{

  return **(undefined4 **)(param_1 + 0xc);

}





// --- FUN_0041ab60 at 0x0041AB60 (size: 29) ---


int * __thiscall FUN_0041ab60(int param_1,int *param_2)



{

  int iVar1;

  

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

  *param_2 = iVar1;

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

  return param_2;

}





// --- FUN_0041ab80 at 0x0041AB80 (size: 27) ---


int * __thiscall FUN_0041ab80(int *param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = *param_2;

  *param_1 = iVar1;

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

  return param_1;

}





// --- FUN_0041aba0 at 0x0041ABA0 (size: 48) ---


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



{

  undefined4 uVar1;

  

  *param_1 = 0;

  uVar1 = FUN_004220b0(param_2,0x24);

  uVar1 = FUN_00415430(uVar1);

  *param_1 = uVar1;

  return param_1;

}





// --- FUN_0041abd0 at 0x0041ABD0 (size: 48) ---


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



{

  undefined4 uVar1;

  

  *param_1 = 0;

  uVar1 = FUN_004220b0(param_2,0x26);

  uVar1 = FUN_00415430(uVar1);

  *param_1 = uVar1;

  return param_1;

}





// --- FUN_0041ac00 at 0x0041AC00 (size: 48) ---


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



{

  undefined4 uVar1;

  

  *param_1 = 0;

  uVar1 = FUN_004220b0(param_2,0x28);

  uVar1 = FUN_00415430(uVar1);

  *param_1 = uVar1;

  return param_1;

}





// --- FUN_0041ac30 at 0x0041AC30 (size: 47) ---


undefined4 __thiscall FUN_0041ac30(int param_1,undefined4 param_2)



{

  int local_c [3];

  

  local_c[0] = param_1 + 0x3c;

  local_c[1] = 0;

  local_c[2] = 0;

  FUN_0041ac60(0,local_c);

  return param_2;

}





// --- FUN_0041ac60 at 0x0041AC60 (size: 157) ---


int * __thiscall FUN_0041ac60(int *param_1,int param_2,int *param_3)



{

  int iVar1;

  undefined4 uVar2;

  int local_38 [3];

  undefined1 local_2c [16];

  int local_1c;

  int local_18;

  int local_14;

  int local_4;

  

  *param_1 = param_2;

  param_1[1] = *param_3;

  param_1[2] = param_3[1];

  param_1[3] = param_3[2];

  iVar1 = *param_1;

  while( true ) {

    if (iVar1 == 0) {

      return param_1;

    }

    local_38[0] = *param_1 + 0x3c;

    local_38[1] = 0;

    local_38[2] = 0;

    FUN_0041ac60(0,local_38);

    if (param_1[3] != local_4) break;

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

    *param_1 = iVar1;

    if (iVar1 != 0) {

      uVar2 = FUN_00429c70(local_2c);

      FUN_0041ac60(iVar1,uVar2);

      param_1[1] = local_1c;

      param_1[3] = local_14;

      param_1[2] = local_18;

    }

    iVar1 = *param_1;

  }

  return param_1;

}





// --- FUN_0041ad00 at 0x0041AD00 (size: 65) ---


undefined4 __thiscall FUN_0041ad00(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined1 local_c [12];

  

  puVar1 = (undefined4 *)FUN_0052dcf0(local_c);

  local_18 = *puVar1;

  local_14 = puVar1[1];

  local_10 = puVar1[2];

  FUN_0041ac60(param_1,&local_18);

  return param_2;

}





// --- FUN_0041ad50 at 0x0041AD50 (size: 212) ---


int * __fastcall FUN_0041ad50(int *param_1)



{

  int iVar1;

  int *piVar2;

  int local_38 [4];

  undefined4 *local_28;

  undefined4 local_24;

  int local_1c;

  int local_18;

  int local_14;

  int local_4;

  

  FUN_0042cb20(local_38 + 3,0);

  if (*param_1 != 0) {

    local_38[1] = 0;

    local_38[2] = 0;

    do {

      local_38[0] = *param_1 + 0x3c;

      FUN_0041ac60(0,local_38);

      if (param_1[3] != local_4) {

        return param_1;

      }

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

      *param_1 = iVar1;

      if (iVar1 != 0) {

        local_38[3] = iVar1 + 0x3c;

        piVar2 = *(int **)(iVar1 + 0xa0);

        while (piVar2 != (int *)(*(int *)(iVar1 + 0x9c) + *(int *)(iVar1 + 0xa4) * 4)) {

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

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

            local_24 = *local_28;

            goto LAB_0041ade3;

          }

          piVar2 = *(int **)(iVar1 + 0xa0) + 1;

          *(int **)(iVar1 + 0xa0) = piVar2;

        }

        local_28 = (undefined4 *)0x0;

        local_24 = 0;

LAB_0041ade3:

        FUN_0041ac60(iVar1,local_38 + 3);

        param_1[1] = local_1c;

        param_1[3] = local_14;

        param_1[2] = local_18;

      }

    } while (*param_1 != 0);

  }

  return param_1;

}





// --- FUN_0041ae30 at 0x0041AE30 (size: 120) ---


undefined4 __thiscall FUN_0041ae30(int param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  uint uVar2;

  LONG LVar3;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 100) + (*param_2 % *(uint *)(param_1 + 0x6c)) * 4);

  while( true ) {

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

      return 0;

    }

    if (*puVar1 == *param_2) break;

    puVar1 = (uint *)puVar1[1];

  }

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

    return 0;

  }

  uVar2 = *param_3;

  if (uVar2 != puVar1[2]) {

    LVar3 = InterlockedDecrement((LONG *)(uVar2 - 0x10));

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

      (*(code *)**(undefined4 **)(uVar2 - 0x14))(1);

    }

    uVar2 = puVar1[2];

    *param_3 = uVar2;

    InterlockedIncrement((LONG *)(uVar2 - 0x10));

  }

  return 1;

}





// --- FUN_0041aeb0 at 0x0041AEB0 (size: 93) ---


void __thiscall FUN_0041aeb0(int param_1,int *param_2,undefined4 *param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  uint uVar4;

  int iVar5;

  

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

  uVar4 = FUN_0041aa50();

  uVar4 = uVar4 % uVar1;

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

  puVar3 = *(undefined4 **)(iVar2 + uVar4 * 4);

  while ((puVar3 != (undefined4 *)0x0 &&

         (iVar5 = _stricmp((char *)*puVar3,(char *)*param_3), iVar5 != 0))) {

    puVar3 = (undefined4 *)puVar3[1];

  }

  param_2[2] = (int)puVar3;

  *param_2 = param_1;

  param_2[1] = iVar2 + uVar4 * 4;

  return;

}





// --- FUN_0041af10 at 0x0041AF10 (size: 73) ---


void __fastcall FUN_0041af10(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_0041b570(*puVar2);

  return;

}





// --- FUN_0041af60 at 0x0041AF60 (size: 246) ---


undefined1 __thiscall FUN_0041af60(int param_1,undefined4 param_2,int *param_3)



{

  undefined *puVar1;

  int *piVar2;

  undefined *puVar3;

  char cVar4;

  undefined1 uVar5;

  LONG LVar6;

  undefined4 *puVar7;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818344;

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

  cVar4 = FUN_0041ae30(&param_2,&local_4);

  puVar3 = local_4;

  piVar2 = param_3;

  if (cVar4 != '\0') {

    puVar1 = (undefined *)*param_3;

    if (puVar1 != local_4) {

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

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

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

      }

      *piVar2 = (int)puVar3;

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

    }

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

    if ((LVar6 == 0) && ((undefined4 *)(puVar3 + -0x14) != (undefined4 *)0x0)) {

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

    }

    return 1;

  }

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

    uVar5 = FUN_0041af60(param_2,param_3);

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

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

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

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

    }

    return uVar5;

  }

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

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

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

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

  }

  return 0;

}





// --- FUN_0041b060 at 0x0041B060 (size: 241) ---


bool FUN_0041b060(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  uint local_8;

  int *local_4;

  

  FUN_00415640(&local_8,param_1,1);

  if (local_8 == DAT_00837c64) {

    return false;

  }

  iVar2 = FUN_0041c280(local_8);

  if (iVar2 == 0x24) {

    FUN_0041aba0(local_8);

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

      return false;

    }

    cVar1 = FUN_0041af60(param_2,param_3);

  }

  else {

    if (iVar2 == 0x26) {

      FUN_0041abd0(local_8);

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

        return false;

      }

      cVar1 = FUN_00415c90(param_2,param_3);

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

      return cVar1 != '\0';

    }

    if (iVar2 != 0x28) {

      return false;

    }

    FUN_0041ac00(local_8);

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

      return false;

    }

    cVar1 = FUN_00415c90(param_2,param_3);

  }

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

  return cVar1 != '\0';

}





// --- FUN_0041b160 at 0x0041B160 (size: 190) ---


undefined1 FUN_0041b160(undefined4 param_1,undefined4 param_2,int *param_3)



{

  int iVar1;

  undefined1 uVar2;

  int *piVar3;

  LONG LVar4;

  int local_8;

  int local_4;

  

  FUN_0040d810(&local_8,param_3);

  uVar2 = FUN_0041b060(param_1,param_2,&local_8);

  piVar3 = (int *)FUN_0040d200(&local_4,&local_8);

  iVar1 = *param_3;

  if (iVar1 != *piVar3) {

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

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

      (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

    }

    iVar1 = *piVar3;

    *param_3 = iVar1;

    InterlockedIncrement((LONG *)(iVar1 + -0x10));

  }

  LVar4 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar4 == 0) && ((undefined4 *)(local_4 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -0x14))(1);

  }

  LVar4 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar4 == 0) && ((undefined4 *)(local_8 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

  }

  return uVar2;

}





// --- FUN_0041b220 at 0x0041B220 (size: 150) ---


bool FUN_0041b220(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  int *piVar3;

  undefined4 uVar4;

  

  iVar2 = FUN_0041c280(param_1);

  if (iVar2 == 0x24) {

    uVar4 = FUN_004220b0(param_1,0x24);

    piVar3 = (int *)FUN_00415430(uVar4);

    if (piVar3 == (int *)0x0) {

      return false;

    }

    cVar1 = FUN_0041af60(param_2,param_3);

  }

  else {

    if (iVar2 == 0x26) {

      uVar4 = 0x26;

    }

    else {

      if (iVar2 != 0x28) {

        return false;

      }

      uVar4 = 0x28;

    }

    uVar4 = FUN_004220b0(param_1,uVar4);

    piVar3 = (int *)FUN_00415430(uVar4);

    if (piVar3 == (int *)0x0) {

      return false;

    }

    cVar1 = FUN_00415c90(param_2,param_3);

  }

  (**(code **)(*piVar3 + 0x14))();

  return cVar1 != '\0';

}





// --- FUN_0041b2c0 at 0x0041B2C0 (size: 82) ---


undefined4 * __thiscall FUN_0041b2c0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_0079646c;

  FUN_00433a10();

  param_1[1] = &PTR_FUN_00796468;

  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_0041b320 at 0x0041B320 (size: 143) ---


undefined4 * __thiscall FUN_0041b320(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_00796464;

  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_0041b3b0 at 0x0041B3B0 (size: 143) ---


undefined4 * __thiscall FUN_0041b3b0(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_00796468;

  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_0041b440 at 0x0041B440 (size: 77) ---


void __thiscall FUN_0041b440(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  if (*(int *)(param_1 + 0x68) * 2 < *(int *)(param_1 + 0x6c) + 1) {

    FUN_0041af10();

  }

  uVar1 = *(uint *)(param_1 + 0x68);

  uVar3 = FUN_0041aa50();

  uVar3 = uVar3 % uVar1;

  iVar2 = *(int *)(param_1 + 0x60);

  *(undefined4 *)(param_2 + 4) = *(undefined4 *)(iVar2 + uVar3 * 4);

  *(int *)(iVar2 + uVar3 * 4) = param_2;

  uVar1 = iVar2 + uVar3 * 4;

  if (uVar1 < *(uint *)(param_1 + 100)) {

    *(uint *)(param_1 + 100) = uVar1;

  }

  *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

  return;

}





// --- FUN_0041b490 at 0x0041B490 (size: 221) ---


undefined4 __thiscall FUN_0041b490(int param_1,undefined4 *param_2)



{

  LONG *lpAddend;

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  undefined4 uVar4;

  int iVar5;

  undefined1 local_c [8];

  int local_4;

  

  iVar2 = (int)param_2;

  lpAddend = (LONG *)((int)param_2 + -0x10);

  InterlockedIncrement(lpAddend);

  FUN_0041aeb0(local_c,&param_2);

  if (local_4 == 0) {

    param_2 = (undefined4 *)0x0;

  }

  else {

    param_2 = (undefined4 *)(local_4 + 8);

  }

  puVar1 = (undefined4 *)(iVar2 + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  if (param_2 == (undefined4 *)0x0) {

    if (*(int *)(param_1 + 0x34) == 0) {

      LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

      return 0;

    }

    iVar5 = iVar2;

    InterlockedIncrement(lpAddend);

    uVar4 = FUN_0041b490(iVar5);

  }

  else {

    uVar4 = *param_2;

  }

  LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return uVar4;

}





// --- FUN_0041b570 at 0x0041B570 (size: 320) ---


undefined4 __thiscall FUN_0041b570(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  int iVar5;

  int iVar6;

  undefined4 *puVar7;

  uint uVar8;

  int iVar9;

  int *piVar10;

  

  iVar2 = param_2;

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar6 = *(int *)(param_1 + 0x6c);

  iVar3 = 0;

  do {

    if (iVar6 == 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;

      iVar2 = param_2;

      while (iVar3 != 0) {

        param_2 = *(int *)(param_1 + 0x68);

        iVar6 = *(int *)(iVar3 + 4);

        PTR_DAT_00818558 = (undefined *)puVar4;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar7 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar4,&param_2,param_2,0);

          if ((puVar7 != puVar4) || (puVar7 = puVar7 + -1, puVar7 != puVar4)) {

            puVar7 = puVar7 + 1;

          }

          FUN_0041b570(*puVar7);

          iVar2 = param_2;

        }

        param_2 = iVar2;

        uVar1 = *(uint *)(param_1 + 0x68);

        uVar8 = FUN_0041aa50();

        uVar8 = uVar8 % uVar1;

        iVar2 = *(int *)(param_1 + 0x60);

        *(undefined4 *)(iVar3 + 4) = *(undefined4 *)(iVar2 + uVar8 * 4);

        *(int *)(iVar2 + uVar8 * 4) = iVar3;

        uVar1 = iVar2 + uVar8 * 4;

        if (uVar1 < *(uint *)(param_1 + 100)) {

          *(uint *)(param_1 + 100) = uVar1;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        iVar2 = param_2;

        iVar3 = iVar6;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

    piVar10 = *(int **)(param_1 + 100);

    while (piVar10 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar10 = *(int **)(param_1 + 100);

        iVar9 = *piVar10;

        goto LAB_0041b5bf;

      }

      piVar10 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar10;

    }

    piVar10 = (int *)0x0;

    iVar9 = 0;

LAB_0041b5bf:

    iVar6 = *piVar10;

    if (iVar6 == iVar9) {

LAB_0041b5d2:

      *piVar10 = *(int *)(iVar6 + 4);

    }

    else {

      do {

        iVar5 = iVar6;

        iVar6 = *(int *)(iVar5 + 4);

      } while (iVar6 != iVar9);

      if (iVar5 == 0) goto LAB_0041b5d2;

      *(undefined4 *)(iVar5 + 4) = *(undefined4 *)(iVar6 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    *(int *)(iVar9 + 4) = iVar3;

    iVar6 = *(int *)(param_1 + 0x6c);

    iVar3 = iVar9;

  } while( true );

}





// --- FUN_0041b6b0 at 0x0041B6B0 (size: 289) ---


undefined4 __thiscall FUN_0041b6b0(int param_1,int param_2)



{

  uint *puVar1;

  int iVar2;

  uint *puVar3;

  int *piVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  uint *puVar7;

  

  if (param_2 == *(int *)(param_1 + 0x68)) {

    return 0;

  }

  iVar2 = *(int *)(param_1 + 0x6c);

  puVar3 = (uint *)0x0;

  do {

    if (iVar2 == 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(param_2);

      puVar6 = (undefined4 *)PTR_DAT_00818558;

      while (puVar3 != (uint *)0x0) {

        param_2 = *(int *)(param_1 + 0x68);

        puVar7 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar6;

        if (param_2 * 2 < *(int *)(param_1 + 0x6c) + 1) {

          puVar5 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,puVar6,&param_2,param_2,0);

          if ((puVar5 != puVar6) || (puVar5 = puVar5 + -1, puVar5 != puVar6)) {

            puVar5 = puVar5 + 1;

          }

          FUN_0041b6b0(*puVar5);

        }

        puVar1 = (uint *)(*(int *)(param_1 + 0x60) + (*puVar3 % *(uint *)(param_1 + 0x68)) * 4);

        puVar3[1] = *puVar1;

        *puVar1 = (uint)puVar3;

        if (puVar1 < *(uint **)(param_1 + 100)) {

          *(uint **)(param_1 + 100) = puVar1;

        }

        *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + 1;

        puVar6 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar7;

      }

      PTR_DAT_00818558 = (undefined *)puVar6;

      return 1;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        puVar6 = *(undefined4 **)(param_1 + 100);

        puVar7 = (uint *)*puVar6;

        goto LAB_0041b701;

      }

      piVar4 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar4;

    }

    puVar6 = (undefined4 *)0x0;

    puVar7 = (uint *)0x0;

LAB_0041b701:

    FUN_00428ba0(param_1,puVar6,puVar7);

    puVar7[1] = (uint)puVar3;

    iVar2 = *(int *)(param_1 + 0x6c);

    puVar3 = puVar7;

  } while( true );

}





// --- FUN_0041b7e0 at 0x0041B7E0 (size: 259) ---


uint __thiscall FUN_0041b7e0(int param_1,int param_2,undefined4 *param_3)



{

  undefined4 *puVar1;

  int iVar2;

  undefined1 uVar3;

  LONG LVar4;

  int iVar5;

  undefined4 *puVar6;

  undefined1 local_c [8];

  int local_4;

  

  iVar2 = param_2;

  puVar1 = (undefined4 *)(param_2 + -0x14);

  InterlockedIncrement((LONG *)(param_2 + -0x10));

  FUN_0041aeb0(local_c,&param_2);

  if (local_4 == 0) {

    param_2 = (uint)param_2._1_3_ << 8;

  }

  else {

    *param_3 = *(undefined4 *)(local_4 + 8);

    param_2 = CONCAT31(param_2._1_3_,1);

  }

  LVar4 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  if ((char)param_2 != '\0') {

    LVar4 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

    if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    return 1;

  }

  if (*(int *)(param_1 + 0x34) != 0) {

    iVar5 = iVar2;

    puVar6 = param_3;

    InterlockedIncrement((LONG *)(iVar2 + -0x10));

    uVar3 = FUN_0041b7e0(iVar5,puVar6);

    param_3 = (undefined4 *)CONCAT31(param_3._1_3_,uVar3);

    LVar4 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

    if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    return (uint)param_3 & 0xff;

  }

  LVar4 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return 0;

}





// --- FUN_0041b8f0 at 0x0041B8F0 (size: 320) ---


bool FUN_0041b8f0(undefined4 param_1,int param_2,undefined4 param_3)



{

  char cVar1;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  bool bVar5;

  undefined4 uVar6;

  int local_8;

  int *local_4;

  

  bVar5 = false;

  FUN_00415640(&local_8,param_1,1);

  if (local_8 == DAT_00837c64) {

    puVar4 = (undefined4 *)(param_2 + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(param_2 + -0x10));

    if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

    }

    return false;

  }

  iVar3 = FUN_0041c280(local_8);

  if (iVar3 == 0x24) {

    FUN_0041aba0(local_8);

    if (local_4 == (int *)0x0) goto LAB_0041ba07;

    iVar3 = param_2;

    uVar6 = param_3;

    InterlockedIncrement((LONG *)(param_2 + -0x10));

    cVar1 = FUN_0041b7e0(iVar3,uVar6);

  }

  else {

    if (iVar3 != 0x26) {

      if ((iVar3 == 0x28) && (FUN_0041ac00(local_8), local_4 != (int *)0x0)) {

        cVar1 = FUN_004159d0(&param_2,param_3);

        bVar5 = cVar1 != '\0';

        (**(code **)(*local_4 + 0x14))();

      }

      goto LAB_0041ba07;

    }

    FUN_0041abd0(local_8);

    if (local_4 == (int *)0x0) goto LAB_0041ba07;

    cVar1 = FUN_004159d0(&param_2,param_3);

  }

  bVar5 = cVar1 != '\0';

  (**(code **)(*local_4 + 0x14))();

LAB_0041ba07:

  puVar4 = (undefined4 *)(param_2 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar2 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return bVar5;

}





// --- FUN_0041ba30 at 0x0041BA30 (size: 136) ---


undefined1 FUN_0041ba30(undefined4 param_1,int param_2,undefined4 param_3)



{

  undefined1 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  int iVar4;

  undefined4 uVar5;

  int local_4;

  

  FUN_0040d810(&local_4,&param_2);

  iVar4 = local_4;

  uVar5 = param_3;

  InterlockedIncrement((LONG *)(local_4 + -0x10));

  uVar1 = FUN_0041b8f0(param_1,iVar4,uVar5);

  LVar2 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar2 == 0) && ((undefined4 *)(local_4 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -0x14))(1);

  }

  puVar3 = (undefined4 *)(param_2 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return uVar1;

}





// --- FUN_0041bac0 at 0x0041BAC0 (size: 284) ---


bool FUN_0041bac0(undefined4 param_1,int param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  undefined4 uVar3;

  int *piVar4;

  LONG LVar5;

  undefined4 *puVar6;

  bool bVar7;

  

  bVar7 = false;

  iVar2 = FUN_0041c280(param_1);

  if (iVar2 == 0x24) {

    uVar3 = FUN_004220b0(param_1,0x24);

    piVar4 = (int *)FUN_00415430(uVar3);

    if (piVar4 != (int *)0x0) {

      iVar2 = param_2;

      uVar3 = param_3;

      InterlockedIncrement((LONG *)(param_2 + -0x10));

      cVar1 = FUN_0041b7e0(iVar2,uVar3);

      bVar7 = cVar1 != '\0';

      (**(code **)(*piVar4 + 0x14))();

    }

  }

  else if (iVar2 == 0x26) {

    uVar3 = FUN_004220b0(param_1,0x26);

    piVar4 = (int *)FUN_00415430(uVar3);

    if (piVar4 != (int *)0x0) {

      cVar1 = FUN_004159d0(&param_2,param_3);

      bVar7 = cVar1 != '\0';

      (**(code **)(*piVar4 + 0x14))();

    }

  }

  else if (iVar2 == 0x28) {

    uVar3 = FUN_004220b0(param_1,0x28);

    piVar4 = (int *)FUN_00415430(uVar3);

    if (piVar4 != (int *)0x0) {

      cVar1 = FUN_004159d0(&param_2,param_3);

      bVar7 = cVar1 != '\0';

      (**(code **)(*piVar4 + 0x14))();

    }

  }

  puVar6 = (undefined4 *)(param_2 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar5 == 0) && (puVar6 != (undefined4 *)0x0)) {

    (**(code **)*puVar6)(1);

  }

  return bVar7;

}





// --- FUN_0041bbe0 at 0x0041BBE0 (size: 143) ---


undefined4 FUN_0041bbe0(int *param_1,int *param_2)



{

  int iVar1;

  int *piVar2;

  undefined1 local_c [8];

  int local_4;

  

  FUN_0041aeb0(local_c,param_1);

  if (local_4 != 0) {

    *(int *)(local_4 + 8) = *param_2;

    return 1;

  }

  piVar2 = (int *)FUN_005df0f5(0xc);

  if (piVar2 == (int *)0x0) {

    piVar2 = (int *)0x0;

  }

  else {

    iVar1 = *param_1;

    *piVar2 = iVar1;

    InterlockedIncrement((LONG *)(iVar1 + -0x10));

    piVar2[1] = 0;

    piVar2[2] = *param_2;

  }

  FUN_0041aeb0(local_c,piVar2);

  if (local_4 == 0) {

    FUN_0041b440(piVar2);

  }

  return 1;

}





// --- FUN_0041bc70 at 0x0041BC70 (size: 67) ---


void FUN_0041bc70(undefined4 param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  

  puVar1 = PTR_DAT_00818558;

  puVar2 = (undefined4 *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_1,param_1,0);

  if (puVar2 == (undefined4 *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  FUN_0041b6b0(*puVar2);

  return;

}





// --- FUN_0041bcc0 at 0x0041BCC0 (size: 542) ---


void FUN_0041bcc0(undefined4 param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined *puVar2;

  undefined *puVar3;

  uint uVar4;

  char cVar5;

  undefined *puVar6;

  byte *pbVar7;

  int *piVar8;

  undefined4 *puVar9;

  LONG *lpAddend;

  undefined4 *puVar10;

  uint uVar11;

  undefined4 *puVar12;

  undefined1 local_c [12];

  

  uVar4 = param_3;

  if ((~*(byte *)(param_3 + 4) & 1) != 0) {

    FUN_005c2c80();

  }

  puVar3 = PTR_DAT_00818558;

  puVar2 = PTR_DAT_00818554;

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x68);

    puVar6 = (undefined *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_3,param_3,0);

    if (puVar6 == puVar3) {

      puVar6 = puVar6 + -4;

    }

    uVar11 = (int)puVar6 - (int)puVar2 >> 2;

  }

  else {

    uVar11 = param_3 & 0xff;

  }

  FUN_0040ad10(1);

  pbVar7 = (byte *)FUN_0040acf0(1);

  if (pbVar7 != (byte *)0x0) {

    if ((*(byte *)(uVar4 + 4) & 1) == 0) {

      uVar11 = (uint)*pbVar7;

    }

    else {

      *pbVar7 = (byte)uVar11;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    if ((uVar11 & 0xff) < DAT_007956cc) {

      FUN_0041bc70(*(undefined4 *)(PTR_DAT_00818554 + (uVar11 & 0xff) * 4));

    }

    else {

      FUN_0040aa50();

    }

  }

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    param_3 = *(uint *)(param_2 + 0x6c);

  }

  FUN_00401a80(&param_3,&param_3,uVar4);

  if (((byte)*(undefined4 *)(uVar4 + 4) & 5) == 1) {

    piVar8 = (int *)FUN_0052dcf0(local_c);

    iVar1 = *piVar8;

    puVar12 = (undefined4 *)piVar8[1];

    puVar9 = (undefined4 *)piVar8[2];

LAB_0041bdc2:

    puVar10 = puVar9;

    if (puVar9 != (undefined4 *)0x0) {

      do {

        FUN_0040ad10(4);

        puVar9 = (undefined4 *)FUN_0040acf0(4);

        if (puVar9 != (undefined4 *)0x0) {

          if ((*(byte *)(uVar4 + 4) & 1) == 0) {

            *puVar10 = *puVar9;

          }

          else {

            *puVar9 = *puVar10;

          }

        }

        FUN_00402400(uVar4);

        puVar10 = (undefined4 *)puVar10[1];

      } while (puVar10 != (undefined4 *)0x0);

      do {

        puVar12 = puVar12 + 1;

        puVar9 = puVar10;

        if (puVar12 == (undefined4 *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) break;

        puVar9 = (undefined4 *)*puVar12;

      } while (puVar9 == (undefined4 *)0x0);

      goto LAB_0041bdc2;

    }

  }

  if ((*(byte *)(uVar4 + 4) & 5) == 0) {

    uVar11 = FUN_0040a8f0();

    if (uVar11 < param_3) {

LAB_0041becf:

      FUN_0040aa50();

    }

    else {

      uVar11 = 0;

      puVar12 = (undefined4 *)0x0;

      if (param_3 != 0) {

        while( true ) {

          puVar9 = (undefined4 *)FUN_005df0f5(0xc);

          if (puVar9 == (undefined4 *)0x0) {

            puVar9 = (undefined4 *)0x0;

          }

          else {

            puVar9[1] = 0;

            lpAddend = (LONG *)(PTR_DAT_00818344 + -0x10);

            puVar9[2] = PTR_DAT_00818344;

            InterlockedIncrement(lpAddend);

          }

          FUN_0040ad10(4);

          puVar10 = (undefined4 *)FUN_0040acf0(4);

          if (puVar10 != (undefined4 *)0x0) {

            if ((*(byte *)(uVar4 + 4) & 1) == 0) {

              *puVar9 = *puVar10;

            }

            else {

              *puVar10 = *puVar9;

            }

          }

          FUN_00402400(uVar4);

          if ((*(uint *)(uVar4 + 4) >> 2 & 1) != 0) break;

          cVar5 = FUN_00599310(puVar9,puVar12);

          if (cVar5 == '\0') goto LAB_0041becf;

          uVar11 = uVar11 + 1;

          puVar12 = puVar9;

          if (param_3 <= uVar11) {

            return;

          }

        }

      }

    }

  }

  return;

}





// --- FUN_0041bee0 at 0x0041BEE0 (size: 63) ---


void __fastcall FUN_0041bee0(int param_1)



{

  FUN_00433a10();

  FUN_00415e50();

  if (*(int **)(param_1 + 0x34) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0x34) + 0x14))();

    *(undefined4 *)(param_1 + 0x34) = 0;

    *(undefined4 *)(param_1 + 0x30) = DAT_00837c64;

    return;

  }

  *(undefined4 *)(param_1 + 0x30) = DAT_00837c64;

  return;

}





// --- FUN_0041bf20 at 0x0041BF20 (size: 82) ---


undefined4 * __thiscall FUN_0041bf20(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007964c8;

  FUN_00415e50();

  param_1[1] = &PTR_FUN_00796464;

  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_0041bf80 at 0x0041BF80 (size: 180) ---


void __fastcall FUN_0041bf80(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_00796470;

  FUN_00433a10();

  FUN_00415e50();

  if ((int *)param_1[0xd] != (int *)0x0) {

    (**(code **)(*(int *)param_1[0xd] + 0x14))();

    param_1[0xd] = 0;

  }

  param_1[0xc] = DAT_00837c64;

  param_1[0x2b] = &PTR_FUN_0079646c;

  FUN_00433a10();

  param_1[0x2c] = &PTR_FUN_00796468;

  if ((undefined4 *)param_1[0x44] != param_1 + 0x2d) {

    operator_delete__((undefined4 *)param_1[0x44]);

  }

  param_1[0x44] = 0;

  param_1[0x45] = 0;

  param_1[0x46] = 0;

  param_1[0x47] = 0;

  param_1[0xe] = &PTR_FUN_007964c8;

  FUN_00415e50();

  param_1[0xf] = &PTR_FUN_00796464;

  if ((undefined4 *)param_1[0x27] != param_1 + 0x10) {

    operator_delete__((undefined4 *)param_1[0x27]);

  }

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  param_1[0x29] = 0;

  param_1[0x2a] = 0;

  FUN_004154b0();

  return;

}





// --- FUN_0041c050 at 0x0041C050 (size: 97) ---


undefined4 * __fastcall FUN_0041c050(undefined4 *param_1)



{

  FUN_00415460(DAT_00837c64);

  *param_1 = &PTR_LAB_00796470;

  param_1[0xc] = DAT_00837c64;

  param_1[0xd] = 0;

  param_1[0xe] = &PTR_FUN_007964c8;

  FUN_0041b320(0);

  param_1[0xe] = &PTR_FUN_007964c8;

  param_1[0x2b] = &PTR_FUN_0079646c;

  FUN_0041b3b0(0);

  param_1[0x2b] = &PTR_FUN_0079646c;

  return param_1;

}





// --- FUN_0041c0c0 at 0x0041C0C0 (size: 30) ---


void * __thiscall FUN_0041c0c0(void *param_1,byte param_2)



{

  FUN_0041bf80();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0041c220 at 0x0041C220 (size: 30) ---


uint FUN_0041c220(undefined4 *param_1)



{

  uint in_EAX;

  uint uVar1;

  

  if ((param_1 != (undefined4 *)0x0) &&

     (in_EAX = (uint)DAT_00837c68, DAT_00837c68 == (undefined4 *)0x0)) {

    DAT_00837c68 = param_1;

                    /* WARNING: Could not recover jumptable at 0x0041c239. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    uVar1 = (**(code **)*param_1)();

    return uVar1;

  }

  return in_EAX & 0xffffff00;

}





// --- FUN_0041c240 at 0x0041C240 (size: 27) ---


undefined4 FUN_0041c240(void)



{

  operator_delete(DAT_00837c68);

  DAT_00837c68 = (void *)0x0;

  return 1;

}





// --- FUN_0041c260 at 0x0041C260 (size: 24) ---


undefined4 FUN_0041c260(undefined4 param_1)



{

  undefined4 uVar1;

  

  if (DAT_00837c68 != (int *)0x0) {

    uVar1 = (**(code **)(*DAT_00837c68 + 4))(param_1);

    return uVar1;

  }

  return 0;

}





// --- FUN_0041c280 at 0x0041C280 (size: 24) ---


undefined4 FUN_0041c280(undefined4 param_1)



{

  undefined4 uVar1;

  

  if (DAT_00837c68 != (int *)0x0) {

    uVar1 = (**(code **)(*DAT_00837c68 + 8))(param_1);

    return uVar1;

  }

  return 0;

}





// --- FUN_0041c2a0 at 0x0041C2A0 (size: 64) ---


undefined4 * __thiscall FUN_0041c2a0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007964cc;

  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_0041c2e0 at 0x0041C2E0 (size: 79) ---


void FUN_0041c2e0(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  if (DAT_00837c70 != *param_1) {

    puVar1 = (undefined4 *)(DAT_00837c70 + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(DAT_00837c70 + -0x10));

    if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    DAT_00837c70 = *param_1;

    InterlockedIncrement((LONG *)(DAT_00837c70 + -0x10));

  }

  thunk_FUN_0040deb0(&DAT_00837c70,0);

  return;

}





// --- FUN_0041c330 at 0x0041C330 (size: 79) ---


void FUN_0041c330(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  if (DAT_00837c74 != *param_1) {

    puVar1 = (undefined4 *)(DAT_00837c74 + -0x14);

    LVar2 = InterlockedDecrement((LONG *)(DAT_00837c74 + -0x10));

    if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    DAT_00837c74 = *param_1;

    InterlockedIncrement((LONG *)(DAT_00837c74 + -0x10));

  }

  thunk_FUN_0040deb0(&DAT_00837c74,0);

  return;

}





// --- FUN_0041c380 at 0x0041C380 (size: 116) ---


undefined4 * __fastcall FUN_0041c380(undefined4 *param_1)



{

  LONG *lpAddend;

  

  *param_1 = DAT_00837c6c;

  param_1[1] = DAT_00837c6c;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  *(undefined1 *)(param_1 + 7) = 0;

  *(undefined1 *)((int)param_1 + 0x1d) = 0;

  *(undefined1 *)((int)param_1 + 0x1e) = 0;

  *(undefined1 *)((int)param_1 + 0x1f) = 0;

  lpAddend = (LONG *)(PTR_DAT_00818344 + -0x10);

  param_1[8] = PTR_DAT_00818344;

  InterlockedIncrement(lpAddend);

  *(undefined1 *)(param_1 + 9) = 0;

  *(undefined1 *)((int)param_1 + 0x25) = 0;

  *(undefined1 *)((int)param_1 + 0x26) = 0;

  *(undefined1 *)((int)param_1 + 0x27) = 0;

  *(undefined1 *)(param_1 + 10) = 0;

  *(undefined1 *)((int)param_1 + 0x29) = 0;

  *(undefined1 *)((int)param_1 + 0x2a) = 0;

  *(undefined1 *)(param_1 + 0xb) = 0;

  *(undefined1 *)((int)param_1 + 0x2d) = 0;

  param_1[0xc] = 0x10;

  param_1[0xd] = 0x10;

  return param_1;

}





// --- FUN_0041c400 at 0x0041C400 (size: 114) ---


uint * FUN_0041c400(uint param_1)



{

  uint *puVar1;

  

  if ((DAT_00837cb0 & 1) == 0) {

    DAT_00837cb0 = DAT_00837cb0 | 1;

    FUN_0041c380();

    _atexit((_func_4879 *)&LAB_00727fc0);

  }

  puVar1 = *(uint **)(DAT_0081880c + (param_1 % DAT_00818814) * 4);

  if (puVar1 != (uint *)0x0) {

    while (*puVar1 != param_1) {

      puVar1 = (uint *)puVar1[1];

      if (puVar1 == (uint *)0x0) {

        return (uint *)&DAT_00837c78;

      }

    }

    if ((puVar1 != (uint *)0x0) && (puVar1 + 2 != (uint *)0x0)) {

      return puVar1 + 2;

    }

  }

  return (uint *)&DAT_00837c78;

}





// --- FUN_0041c480 at 0x0041C480 (size: 17) ---


undefined1 FUN_0041c480(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0041c400(param_1);

  return *(undefined1 *)(iVar1 + 0x1d);

}





// --- FUN_0041c4a0 at 0x0041C4A0 (size: 17) ---


undefined1 FUN_0041c4a0(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0041c400(param_1);

  return *(undefined1 *)(iVar1 + 0x1e);

}





// --- FUN_0041c4c0 at 0x0041C4C0 (size: 17) ---


undefined1 FUN_0041c4c0(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0041c400(param_1);

  return *(undefined1 *)(iVar1 + 0x1f);

}





// --- FUN_0041c4e0 at 0x0041C4E0 (size: 17) ---


undefined1 FUN_0041c4e0(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0041c400(param_1);

  return *(undefined1 *)(iVar1 + 0x29);

}





// --- FUN_0041c500 at 0x0041C500 (size: 17) ---


int FUN_0041c500(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_0041c400(param_1);

  return iVar1 + 0x2c;

}





// --- FUN_0041c520 at 0x0041C520 (size: 332) ---


undefined1 FUN_0041c520(char *param_1,undefined4 param_2)



{

  int iVar1;

  LONG LVar2;

  char *_Str1;

  char *_Str1_00;

  char *pcVar3;

  undefined1 local_9;

  char *local_8;

  char *local_4;

  

  iVar1 = FUN_0041c400(param_2);

  _Str1 = *(char **)(iVar1 + 0x20);

  if (*(int *)(_Str1 + -4) == 1) {

    InterlockedIncrement((LONG *)(_Str1 + -0x10));

  }

  else {

    FUN_0040bbc0(&local_4,(int *)(iVar1 + 0x20));

    _Str1 = local_4;

  }

  iVar1 = FUN_0041c400(param_2);

  _Str1_00 = *(char **)(iVar1 + 0x20);

  if (*(int *)(_Str1_00 + -4) == 1) {

    InterlockedIncrement((LONG *)(_Str1_00 + -0x10));

  }

  else {

    FUN_0040bbc0(&local_4,(int *)(iVar1 + 0x20));

    _Str1_00 = local_4;

  }

  local_8 = param_1;

  InterlockedIncrement((LONG *)(param_1 + -0x10));

  thunk_FUN_0040deb0(&local_8,0);

  iVar1 = _strnicmp(_Str1,local_8,*(int *)(_Str1 + -4) - 1);

  if (iVar1 != 0) {

    iVar1 = _strnicmp(_Str1_00,local_8,*(int *)(_Str1_00 + -4) - 1);

    local_9 = 0;

    if (iVar1 != 0) goto LAB_0041c5ee;

  }

  local_9 = 1;

LAB_0041c5ee:

  pcVar3 = local_8 + -0x14;

  LVar2 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar2 == 0) && (pcVar3 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar3)(1);

  }

  LVar2 = InterlockedDecrement((LONG *)(_Str1_00 + -0x10));

  if ((LVar2 == 0) && (_Str1_00 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(_Str1_00 + -0x14))(1);

  }

  LVar2 = InterlockedDecrement((LONG *)(_Str1 + -0x10));

  if ((LVar2 == 0) && (_Str1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(_Str1 + -0x14))(1);

  }

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  return local_9;

}





// --- FUN_0041c670 at 0x0041C670 (size: 143) ---


undefined4 * __thiscall FUN_0041c670(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_007964cc;

  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_0041c700 at 0x0041C700 (size: 271) ---


void __fastcall FUN_0041c700(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  LONG LVar4;

  int *piVar5;

  void *pvVar6;

  undefined4 *puVar7;

  int iVar8;

  int local_8;

  

  iVar1 = *(int *)(param_1 + 0x6c);

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar5 = *(int **)(param_1 + 100);

    while (piVar5 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

      if (**(int **)(param_1 + 100) != 0) {

        piVar5 = *(int **)(param_1 + 100);

        pvVar6 = (void *)*piVar5;

        goto LAB_0041c741;

      }

      piVar5 = *(int **)(param_1 + 100) + 1;

      *(int **)(param_1 + 100) = piVar5;

    }

    piVar5 = (int *)0x0;

    pvVar6 = (void *)0x0;

LAB_0041c741:

    pvVar3 = (void *)*piVar5;

    if (pvVar3 == pvVar6) {

LAB_0041c754:

      *piVar5 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar6);

      if (pvVar2 == (void *)0x0) goto LAB_0041c754;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar6 != (void *)0x0) {

      puVar7 = (undefined4 *)(*(int *)((int)pvVar6 + 0x28) + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(*(int *)((int)pvVar6 + 0x28) + -0x10));

      if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

      if (((*(uint *)((int)pvVar6 + 0x14) & 0x80000000) == 0x80000000) &&

         (iVar1 = *(int *)((int)pvVar6 + 0x10), iVar1 != 0)) {

        local_8 = *(int *)(iVar1 + -4);

        iVar8 = iVar1 + local_8 * 4;

        if (-1 < local_8 + -1) {

          do {

            piVar5 = (int *)(iVar8 + -4);

            iVar8 = iVar8 + -4;

            puVar7 = (undefined4 *)(*piVar5 + -0x14);

            LVar4 = InterlockedDecrement((LONG *)(*piVar5 + -0x10));

            if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

              (**(code **)*puVar7)(1);

            }

            local_8 = local_8 + -1;

          } while (local_8 != 0);

        }

        operator_delete__((void *)(iVar1 + -4));

      }

      operator_delete(pvVar6);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_0041c820 at 0x0041C820 (size: 82) ---


undefined4 * __thiscall FUN_0041c820(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007964d0;

  FUN_0041c700();

  param_1[1] = &PTR_FUN_007964cc;

  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_0041c880 at 0x0041C880 (size: 1087) ---


int FUN_0041c880(uint param_1)



{

  if (param_1 < 0x14010000) {

    if (0x13ffffff < param_1) {

      return 0x1d;

    }

    if (param_1 < 0xe00000e) {

      if (0xe00000c < param_1) {

        return 0x12;

      }

      if (param_1 < 0x8000000) {

        if (0x5ffffff < param_1) {

          return 0xc;

        }

        if (param_1 < 0x3010000) {

          if (0x2ffffff < param_1) {

            return 8;

          }

          if (param_1 < 0x2010000) {

            if (0x1ffffff < param_1) {

              return 7;

            }

            if (param_1 < 0x1010000) {

              return (-(uint)(param_1 < 0x1000000) & 0xfffffffa) + 6;

            }

          }

        }

        else if (param_1 < 0x6000000) {

          if (0x4ffffff < param_1) {

            return 0xb;

          }

          if (param_1 < 0x4010000) {

            return (-(uint)(param_1 < 0x4000000) & 0xfffffff6) + 10;

          }

        }

      }

      else if (param_1 < 0xa010000) {

        if (0x9ffffff < param_1) {

          return 0xf;

        }

        if (param_1 < 0x9010000) {

          if (0x8ffffff < param_1) {

            return 0xe;

          }

          if (param_1 < 0x8010000) {

            return (-(uint)(param_1 < 0x8000000) & 0xfffffff3) + 0xd;

          }

        }

      }

      else if (param_1 < 0xe000008) {

        if (0xe000006 < param_1) {

          return 0x11;

        }

        if (param_1 < 0xd010000) {

          return (-(uint)(param_1 < 0xd000000) & 0xfffffff0) + 0x10;

        }

      }

    }

    else if (param_1 < 0xf010000) {

      if (0xeffffff < param_1) {

        return 0x18;

      }

      if (param_1 < 0xe000020) {

        if (0xe00001e < param_1) {

          return 0x15;

        }

        if (param_1 < 0xe00001f) {

          if (0xe00001d < param_1) {

            return 0x14;

          }

          if (param_1 < 0xe00001b) {

            return (-(uint)(param_1 < 0xe00001a) & 0xffffffed) + 0x13;

          }

        }

      }

      else if (param_1 < 0xe030000) {

        if (0xe01ffff < param_1) {

          return 0x17;

        }

        if (param_1 < 0xe000021) {

          return (-(uint)(param_1 < 0xe000020) & 0xffffffea) + 0x16;

        }

      }

    }

    else if (param_1 < 0x12010000) {

      if (0x11ffffff < param_1) {

        return 0x1b;

      }

      if (param_1 < 0x11010000) {

        if (0x10ffffff < param_1) {

          return 0x1a;

        }

        if (param_1 < 0x10010000) {

          return (-(uint)(param_1 < 0x10000000) & 0xffffffe7) + 0x19;

        }

      }

    }

    else if (param_1 < 0x13010000) {

      return (-(uint)(param_1 < 0x13000000) & 0xffffffe4) + 0x1c;

    }

  }

  else if (param_1 < 0x26010000) {

    if (0x25ffffff < param_1) {

      return 0x27;

    }

    if (param_1 < 0x20010000) {

      if (0x1fffffff < param_1) {

        return 0x22;

      }

      if (param_1 < 0x18000000) {

        if (0x16ffffff < param_1) {

          return 0x20;

        }

        if (param_1 < 0x17000000) {

          if (0x15ffffff < param_1) {

            return 0x1f;

          }

          if (param_1 < 0x16000000) {

            return (-(uint)(param_1 < 0x15000000) & 0xffffffe2) + 0x1e;

          }

        }

      }

      else if (param_1 < 0x1a000000) {

        if (0x18ffffff < param_1) {

          return 0x43;

        }

        if (param_1 < 0x19000000) {

          return (-(uint)(param_1 < 0x18000000) & 0xffffffdf) + 0x21;

        }

      }

    }

    else if (param_1 < 0x25000000) {

      if (0x22ffffff < param_1) {

        return 0x25;

      }

      if (param_1 < 0x23000000) {

        if (0x21ffffff < param_1) {

          return 0x24;

        }

        if (param_1 < 0x22000000) {

          return (-(uint)(param_1 < 0x21000000) & 0xffffffdd) + 0x23;

        }

      }

    }

    else if (param_1 < 0x26000000) {

      return (-(uint)(param_1 < 0x25000000) & 0xffffffda) + 0x26;

    }

  }

  else if (param_1 < 0x3a000000) {

    if (0x38ffffff < param_1) {

      return 0x2d;

    }

    if (param_1 < 0x32010000) {

      if (0x31ffffff < param_1) {

        return 0x2a;

      }

      if (param_1 < 0x31010000) {

        if (0x30ffffff < param_1) {

          return 0x29;

        }

        if (param_1 < 0x28000000) {

          return (-(uint)(param_1 < 0x27000000) & 0xffffffd8) + 0x28;

        }

      }

    }

    else if (param_1 < 0x34010000) {

      if (0x33ffffff < param_1) {

        return 0x2c;

      }

      if (param_1 < 0x33010000) {

        return (-(uint)(param_1 < 0x33000000) & 0xffffffd5) + 0x2b;

      }

    }

  }

  else if (param_1 < 0x42000000) {

    if (0x40ffffff < param_1) {

      return 0x30;

    }

    if (param_1 < 0x41000000) {

      if (0x40000fff < param_1) {

        return 0x2f;

      }

      if (param_1 < 0x40001000) {

        return (-(uint)(param_1 < 0x40000000) & 0xffffffd2) + 0x2e;

      }

    }

  }

  else if (param_1 < 0x80000000) {

    return (-(uint)(param_1 < 0x78000000) & 0xffffffcf) + 0x31;

  }

  return 0;

}





// --- FUN_0041ccc0 at 0x0041CCC0 (size: 22) ---


void __fastcall FUN_0041ccc0(undefined4 *param_1)



{

  FUN_004080c0();

  _strlwr((char *)*param_1);

  return;

}





// --- FUN_0041cce0 at 0x0041CCE0 (size: 5085) ---


undefined4 FUN_0041cce0(undefined4 param_1)



{

  char *pcVar1;

  uint uVar2;

  int iVar3;

  LONG LVar4;

  char *local_e4;

  char *local_e0;

  char *local_dc;

  char *local_d8;

  char *local_d4;

  char *local_d0;

  char *local_cc;

  char *local_c8;

  char *local_c4;

  char *local_c0;

  char *local_bc;

  char *local_b8;

  char *local_b4;

  char *local_b0;

  char *local_ac;

  char *local_a8;

  char *local_a4;

  char *local_a0;

  char *local_9c;

  char *local_98;

  char *local_94;

  char *local_90;

  char *local_8c;

  char *local_88;

  char *local_84;

  char *local_80;

  char *local_7c;

  char *local_78;

  char *local_74;

  char *local_70;

  char *local_6c;

  char *local_68;

  char *local_64;

  char *local_60;

  char *local_5c;

  char *local_58;

  char *local_54;

  char *local_50;

  char *local_4c;

  char *local_48;

  char *local_44;

  char *local_40;

  char *local_3c;

  char *local_38;

  char *local_34;

  char *local_30;

  char *local_2c;

  char *local_28;

  char *local_24;

  char *local_20;

  char *local_1c;

  char *local_18;

  char *local_14;

  char *local_10;

  char *local_c;

  char *local_8;

  char *local_4;

  

  FUN_0040ce00(&local_e4,param_1);

  FUN_004080c0();

  _strlwr(local_e4);

  pcVar1 = local_e4;

  uVar2 = *(uint *)(local_e4 + -8);

  if (uVar2 == 0xffffffff) {

    uVar2 = FUN_004016b0(local_e4);

    *(uint *)(pcVar1 + -8) = uVar2;

  }

  if (uVar2 < 0x356c4) {

    if (uVar2 == 0x356c3) {

      FUN_00401340(&DAT_00796734);

      iVar3 = _stricmp(local_e4,local_dc);

      LVar4 = InterlockedDecrement((LONG *)(local_dc + -0x10));

      if ((LVar4 == 0) && (local_dc + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(local_dc + -0x14))(1);

      }

      if (iVar3 == 0) {

        LVar4 = InterlockedDecrement((LONG *)(local_e4 + -0x10));

        if ((LVar4 == 0) && (local_e4 + -0x14 != (char *)0x0)) {

          (*(code *)**(undefined4 **)(local_e4 + -0x14))(1);

        }

        return 0x2b;

      }

      goto LAB_0041e096;

    }

    if (uVar2 < 0x34c45) {

      if (uVar2 == 0x34c44) {

        FUN_00401340(&DAT_0079672c);

        iVar3 = _stricmp(local_e4,local_18);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 0x2a;

        }

        goto LAB_0041e096;

      }

      if (uVar2 < 0x34a30) {

        if (uVar2 == 0x34a2f) {

          FUN_00401340(&DAT_00796680);

          iVar3 = _stricmp(local_e4,local_c0);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x19;

          }

          goto LAB_0041e096;

        }

        if (uVar2 < 0x347ec) {

          if (uVar2 == 0x347eb) {

            FUN_00401340(&DAT_007965cc);

            iVar3 = _stricmp(local_e4,local_d0);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 9;

            }

            goto LAB_0041e096;

          }

          if (uVar2 == 0x3539) {

            FUN_00401340(&DAT_007966c0);

            iVar3 = _stricmp(local_e4,local_38);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x21;

            }

            goto LAB_0041e096;

          }

          if (uVar2 == 0x353d) {

            FUN_00401340(&DAT_007966bc);

            iVar3 = _stricmp(local_e4,local_d8);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x20;

            }

            goto LAB_0041e096;

          }

          if (uVar2 != 0x31586) goto LAB_0041e096;

          FUN_00401340(&DAT_00796608);

          iVar3 = _stricmp(local_e4,local_70);

        }

        else {

          if (uVar2 != 0x34830) {

            if (uVar2 == 0x3484d) {

              FUN_00401340(&DAT_007965c4);

              iVar3 = _stricmp(local_e4,local_c8);

              FUN_004011b0();

              if (iVar3 == 0) {

                FUN_004011b0();

                return 8;

              }

            }

            else if (uVar2 == 0x34874) {

              FUN_00401340(&DAT_00796654);

              iVar3 = _stricmp(local_e4,local_68);

              FUN_004011b0();

              if (iVar3 == 0) {

                FUN_004011b0();

                return 0x13;

              }

            }

            goto LAB_0041e096;

          }

          FUN_00401340(&DAT_00796618);

          iVar3 = _stricmp(local_e4,local_10);

        }

      }

      else {

        if (0x34ab7 < uVar2) {

          if (uVar2 == 0x34b93) {

            FUN_00401340(&DAT_0079662c);

            iVar3 = _stricmp(local_e4,local_a8);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0xe;

            }

          }

          else if (uVar2 == 0x34c40) {

            FUN_00401340(&DAT_007966e0);

            iVar3 = _stricmp(local_e4,local_58);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x24;

            }

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0x34ab7) {

          FUN_00401340(&DAT_00796688);

          iVar3 = _stricmp(local_e4,local_b0);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x1a;

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0x34a73) {

          FUN_00401340(&DAT_00796644);

          iVar3 = _stricmp(local_e4,local_30);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x11;

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0x34a99) {

          FUN_00401340(&DAT_00796610);

          iVar3 = _stricmp(local_e4,local_b8);

        }

        else {

          if (uVar2 != 0x34ab3) goto LAB_0041e096;

          FUN_00401340(&DAT_007965f0);

          iVar3 = _stricmp(local_e4,local_60);

        }

      }

    }

    else {

      if (0x35289 < uVar2) {

        if (uVar2 < 0x354d5) {

          if (uVar2 == 0x354d4) {

            FUN_00401340(&DAT_00796664);

            iVar3 = _stricmp(local_e4,local_78);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x16;

            }

          }

          else if (uVar2 == 0x3528f) {

            FUN_00401340(&DAT_007965a4);

            iVar3 = _stricmp(local_e4,local_40);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 4;

            }

          }

          else if (uVar2 == 0x35384) {

            FUN_00401340(&DAT_007966b4);

            iVar3 = _stricmp(local_e4,local_80);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x1f;

            }

          }

          else if (uVar2 == 0x35472) {

            FUN_00401340(&DAT_00796744);

            iVar3 = _stricmp(local_e4,local_8);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x2d;

            }

          }

        }

        else if (uVar2 == 0x3558a) {

          FUN_00401340(&DAT_007965b4);

          iVar3 = _stricmp(local_e4,local_e0);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 6;

          }

        }

        else if (uVar2 == 0x3567c) {

          FUN_00401340(&DAT_007965d4);

          iVar3 = _stricmp(local_e4,local_20);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 10;

          }

        }

        goto LAB_0041e096;

      }

      if (uVar2 == 0x35289) {

        FUN_00401340(&DAT_0079659c);

        iVar3 = _stricmp(local_e4,local_88);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 2;

        }

        goto LAB_0041e096;

      }

      if (uVar2 < 0x35041) {

        if (uVar2 == 0x35040) {

          FUN_00401340(&DAT_00796708);

          iVar3 = _stricmp(local_e4,local_28);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x26;

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0x34c56) {

          FUN_00401340(&DAT_0079663c);

          iVar3 = _stricmp(local_e4,local_98);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x10;

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0x34f83) {

          FUN_00401340(&DAT_0079664c);

          iVar3 = _stricmp(local_e4,local_50);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x12;

          }

          goto LAB_0041e096;

        }

        if (uVar2 != 0x34fc6) goto LAB_0041e096;

        FUN_00401340(&DAT_00796600);

        iVar3 = _stricmp(local_e4,local_a0);

      }

      else {

        if (uVar2 == 0x35053) {

          FUN_00401340(&DAT_007965ac);

          iVar3 = _stricmp(local_e4,local_48);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 5;

          }

          goto LAB_0041e096;

        }

        if (uVar2 != 0x35167) goto LAB_0041e096;

        FUN_00401340(&DAT_007965e8);

        iVar3 = _stricmp(local_e4,local_90);

      }

    }

  }

  else {

    if (0x34b040 < uVar2) {

      if (uVar2 < 0xaba5baf) {

        if (uVar2 != 0xaba5bae) {

          if (0x4657c30 < uVar2) {

            if (uVar2 == 0x51d03b0) {

              FUN_00401340(".keymap");

              iVar3 = _stricmp(local_e4,local_3c);

              FUN_004011b0();

              if (iVar3 == 0) {

                FUN_004011b0();

                return 0x1d;

              }

            }

            else if (uVar2 == 0xa778f2c) {

              FUN_00401340(".font_local");

              iVar3 = _stricmp(local_e4,local_44);

              FUN_004011b0();

              if (iVar3 == 0) {

                FUN_004011b0();

                return 0x2f;

              }

            }

            goto LAB_0041e096;

          }

          if (uVar2 == 0x4657c30) {

            FUN_00401340(".monprop");

            iVar3 = _stricmp(local_e4,local_4c);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x17;

            }

            goto LAB_0041e096;

          }

          if (uVar2 == 0x34d654) {

            FUN_00401340(".font");

            iVar3 = _stricmp(local_e4,local_54);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x2e;

            }

            goto LAB_0041e096;

          }

          if (uVar2 != 0x357384) {

            if (uVar2 == 0x35a795f) {

              FUN_00401340(".taboo");

              iVar3 = _stricmp(local_e4,local_64);

              FUN_004011b0();

              if (iVar3 == 0) {

                FUN_004011b0();

                return 0x14;

              }

            }

            goto LAB_0041e096;

          }

          FUN_00401340(".pmat");

          iVar3 = _stricmp(local_e4,local_5c);

LAB_0041dc86:

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x31;

          }

          goto LAB_0041e096;

        }

        FUN_00401340(".stt_bin");

        iVar3 = _stricmp(local_e4,local_34);

      }

      else {

        if (uVar2 < 0xafeb0d9) {

          if (uVar2 == 0xafeb0d8) {

            FUN_00401340(".rendermesh");

            iVar3 = _stricmp(local_e4,local_14);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x43;

            }

          }

          else if (uVar2 == 0xac8c4c5) {

            FUN_00401340(".surface");

            iVar3 = _stricmp(local_e4,local_1c);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0xd;

            }

          }

          else if (uVar2 == 0xacf8915) {

            FUN_00401340(".rtexture");

            iVar3 = _stricmp(local_e4,local_24);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0x1e;

            }

          }

          else if (uVar2 == 0xacfbfd5) {

            FUN_00401340(".texture");

            iVar3 = _stricmp(local_e4,local_2c);

            FUN_004011b0();

            if (iVar3 == 0) {

              FUN_004011b0();

              return 0xb;

            }

          }

          goto LAB_0041e096;

        }

        if (uVar2 == 0xb071420) {

          FUN_00401340(".actionmap");

          iVar3 = _stricmp(local_e4,local_4);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x27;

          }

          goto LAB_0041e096;

        }

        if (uVar2 != 0xba55039) goto LAB_0041e096;

        FUN_00401340(".stt_ansi");

        iVar3 = _stricmp(local_e4,local_c);

      }

LAB_0041e017:

      FUN_004011b0();

      if (iVar3 == 0) {

        FUN_004011b0();

        return 0x25;

      }

      goto LAB_0041e096;

    }

    if (uVar2 == 0x34b040) {

      FUN_00401340(".dimp");

      iVar3 = _stricmp(local_e4,local_6c);

      LVar4 = InterlockedDecrement((LONG *)(local_6c + -0x10));

      if ((LVar4 == 0) && (local_6c + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(local_6c + -0x14))(1);

      }

      if (iVar3 == 0) {

        FUN_004011b0();

        return 0x28;

      }

      goto LAB_0041e096;

    }

    if (uVar2 < 0x35aaa) {

      if (uVar2 == 0x35aa9) {

        FUN_00401340(&DAT_00796760);

        iVar3 = _stricmp(local_e4,local_a4);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 0x30;

        }

      }

      else if (uVar2 < 0x3599f) {

        if (uVar2 == 0x3599e) {

          FUN_00401340(&DAT_00796690);

          iVar3 = _stricmp(local_e4,local_bc);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x1b;

          }

        }

        else if (uVar2 == 0x356c4) {

          FUN_00401340(&DAT_0079673c);

          iVar3 = _stricmp(local_e4,local_c4);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x2c;

          }

        }

        else if (uVar2 == 0x357a4) {

          FUN_00401340(&DAT_00796678);

          iVar3 = _stricmp(local_e4,local_cc);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x18;

          }

        }

        else if (uVar2 == 0x358de) {

          FUN_00401340(&DAT_00796698);

          iVar3 = _stricmp(local_e4,local_d4);

          FUN_004011b0();

          if (iVar3 == 0) {

            FUN_004011b0();

            return 0x1c;

          }

        }

      }

      else if (uVar2 == 0x359c4) {

        FUN_00401340(&DAT_007965bc);

        iVar3 = _stricmp(local_e4,local_ac);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 7;

        }

      }

      else if (uVar2 == 0x35aa2) {

        FUN_00401340(&DAT_007966d0);

        iVar3 = _stricmp(local_e4,local_b4);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 0x22;

        }

      }

      goto LAB_0041e096;

    }

    if (0x35bfc < uVar2) {

      if (uVar2 == 0x35d86) {

        FUN_00401340(&DAT_00796634);

        iVar3 = _stricmp(local_e4,local_74);

        FUN_004011b0();

        if (iVar3 == 0) {

          FUN_004011b0();

          return 0xf;

        }

        goto LAB_0041e096;

      }

      if (uVar2 != 0x34a963) goto LAB_0041e096;

      FUN_00401340(".dbpc");

      iVar3 = _stricmp(local_e4,local_7c);

      goto LAB_0041dc86;

    }

    if (uVar2 == 0x35bfc) {

      FUN_00401340(&DAT_007966d8);

      iVar3 = _stricmp(local_e4,local_84);

      FUN_004011b0();

      if (iVar3 == 0) {

        FUN_004011b0();

        return 0x23;

      }

      goto LAB_0041e096;

    }

    if (uVar2 == 0x35ab2) {

      FUN_00401340(&DAT_00796724);

      iVar3 = _stricmp(local_e4,local_8c);

      FUN_004011b0();

      if (iVar3 == 0) {

        FUN_004011b0();

        return 0x29;

      }

      goto LAB_0041e096;

    }

    if (uVar2 == 0x35ab4) {

      FUN_00401340(&DAT_007966e8);

      iVar3 = _stricmp(local_e4,local_94);

      goto LAB_0041e017;

    }

    if (uVar2 != 0x35ad1) goto LAB_0041e096;

    FUN_00401340(&DAT_007965f8);

    iVar3 = _stricmp(local_e4,local_9c);

  }

  FUN_004011b0();

  if (iVar3 == 0) {

    FUN_004011b0();

    return 0xc;

  }

LAB_0041e096:

  LVar4 = InterlockedDecrement((LONG *)(local_e4 + -0x10));

  if ((LVar4 == 0) && (local_e4 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(local_e4 + -0x14))(1);

  }

  return 0;

}





// --- FUN_0041e0c0 at 0x0041E0C0 (size: 4464) ---


undefined1 FUN_0041e0c0(undefined4 *param_1,undefined4 *param_2)



{

  char *_String;

  undefined *puVar1;

  int iVar2;

  LONG LVar3;

  undefined1 uVar4;

  char *local_c8;

  char *local_c4;

  char *local_c0;

  char *local_bc;

  char *local_b8;

  char *local_b4;

  char *local_b0;

  char *local_ac;

  char *local_a8;

  char *local_a4;

  char *local_a0;

  char *local_9c;

  char *local_98;

  char *local_94;

  char *local_90;

  char *local_8c;

  char *local_88;

  char *local_84;

  char *local_80;

  char *local_7c;

  char *local_78;

  char *local_74;

  char *local_70;

  char *local_6c;

  char *local_68;

  char *local_64;

  char *local_60;

  char *local_5c;

  char *local_58;

  char *local_54;

  char *local_50;

  char *local_4c;

  char *local_48;

  char *local_44;

  char *local_40;

  char *local_3c;

  char *local_38;

  char *local_34;

  char *local_30;

  char *local_2c;

  char *local_28;

  char *local_24;

  char *local_20;

  char *local_1c;

  char *local_18;

  char *local_14;

  char *local_10;

  char *local_c;

  char *local_8;

  char *local_4;

  

  _String = (char *)*param_1;

  uVar4 = 0;

  InterlockedIncrement((LONG *)(_String + -0x10));

  FUN_004080c0();

  _strlwr(_String);

  puVar1 = *(undefined **)(_String + -8);

  if (puVar1 == (undefined *)0xffffffff) {

    puVar1 = (undefined *)FUN_004016b0(_String);

    *(undefined **)(_String + -8) = puVar1;

  }

  if (puVar1 < (undefined *)0x6779a50) {

    if (puVar1 == (undefined *)0x6779a4f) {

      FUN_00401340("DEGRADEINFO");

      iVar2 = _stricmp(_String,local_c4);

      LVar3 = InterlockedDecrement((LONG *)(local_c4 + -0x10));

      if ((LVar3 == 0) && (local_c4 + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(local_c4 + -0x14))(1);

      }

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x1a;

    }

    else if (puVar1 < (undefined *)0x29374e5) {

      if (puVar1 == (undefined *)0x29374e4) {

        FUN_00401340("PHYSICS_SCRIPT");

        iVar2 = _stricmp(_String,local_28);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x2b;

      }

      else if (&DAT_006209de < puVar1) {

        if (puVar1 < (undefined *)0xe658ad) {

          if (puVar1 == (undefined *)0xe658ac) {

            FUN_00401340("RENDERMATERIAL");

            iVar2 = _stricmp(_String,local_a0);

            FUN_004011b0();

            if (iVar2 != 0) goto LAB_0041f205;

            *param_2 = 0x1f;

          }

          else if (puVar1 == (undefined *)0xc26824) {

            FUN_00401340("PAL_SET");

            iVar2 = _stricmp(_String,local_18);

            FUN_004011b0();

            if (iVar2 != 0) goto LAB_0041f205;

            *param_2 = 0x18;

          }

          else {

            if (puVar1 != (undefined *)0xc2ca45) goto LAB_0041f205;

            FUN_00401340("PALETTE");

            iVar2 = _stricmp(_String,local_a8);

            FUN_004011b0();

            if (iVar2 != 0) goto LAB_0041f205;

            *param_2 = 10;

          }

        }

        else if (puVar1 == (undefined *)0x1ef0bc0) {

          FUN_00401340("SETUP");

          iVar2 = _stricmp(_String,local_98);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 7;

        }

        else {

          if (puVar1 != (undefined *)0x1ef5c45) goto LAB_0041f205;

          FUN_00401340("SCENE");

          iVar2 = _stricmp(_String,local_50);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x1b;

        }

      }

      else if (puVar1 == &DAT_006209de) {

        FUN_00401340("INSTANTIATION");

        iVar2 = _stricmp(_String,local_58);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 5;

      }

      else if (puVar1 < (undefined *)0x1dba55) {

        if (puVar1 == (undefined *)0x1dba54) {

          FUN_00401340(&DAT_007969dc);

          iVar2 = _stricmp(_String,local_b8);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x2e;

        }

        else if (puVar1 == (undefined *)0x1e449) {

          FUN_00401340(&DAT_007969e4);

          iVar2 = _stricmp(_String,local_60);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 2;

        }

        else if (puVar1 == (undefined *)0x1e44f) {

          FUN_00401340(&DAT_007969e8);

          iVar2 = _stricmp(_String,local_c0);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 4;

        }

        else {

          if (puVar1 != (undefined *)0x1d28fd) goto LAB_0041f205;

          FUN_00401340(&DAT_007969ec);

          iVar2 = _stricmp(_String,local_68);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 8;

        }

      }

      else if (puVar1 == (undefined *)0x1df82c) {

        FUN_00401340(&DAT_007969cc);

        iVar2 = _stricmp(_String,local_b0);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 3;

      }

      else {

        if (puVar1 != (undefined *)0x1eb4c5) goto LAB_0041f205;

        FUN_00401340(&DAT_007969d4);

        iVar2 = _stricmp(_String,local_30);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0xf;

      }

    }

    else if (puVar1 < (undefined *)0x4448256) {

      if (puVar1 == (undefined *)0x4448255) {

        FUN_00401340("NAME_FILTER_TABLE");

        iVar2 = _stricmp(_String,local_78);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x16;

      }

      else if (puVar1 < (undefined *)0x3cb6a8a) {

        if (puVar1 == (undefined *)0x3cb6a89) {

          FUN_00401340("MASTER_PROPERTY");

          iVar2 = _stricmp(_String,local_8);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x2d;

        }

        else if (puVar1 == (undefined *)0x2e89502) {

          FUN_00401340("PARTICLE_EMITTER");

          iVar2 = _stricmp(_String,local_88);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x2a;

        }

        else if (puVar1 == (undefined *)0x3ad38f5) {

          FUN_00401340("STRING_STATE");

          iVar2 = _stricmp(_String,local_48);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x30;

        }

        else {

          if (puVar1 != (undefined *)0x3ade975) goto LAB_0041f205;

          FUN_00401340("STRING_TABLE");

          iVar2 = _stricmp(_String,local_90);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x25;

        }

      }

      else if (puVar1 == (undefined *)0x3cdb295) {

        FUN_00401340("CHAT_POSE_TABLE");

        iVar2 = _stricmp(_String,local_40);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x11;

      }

      else {

        if (puVar1 != (undefined *)0x428f205) goto LAB_0041f205;

        FUN_00401340("FILE2ID_TABLE");

        iVar2 = _stricmp(_String,local_80);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x15;

      }

    }

    else if (puVar1 < (undefined *)0x5e6eaf3) {

      if (puVar1 == (undefined *)0x5e6eaf2) {

        FUN_00401340("ENUM_MAPPER");

        iVar2 = _stricmp(_String,local_38);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x24;

      }

      else if (puVar1 == (undefined *)0x44b11f5) {

        FUN_00401340("RENDERTEXTURE");

        iVar2 = _stricmp(_String,local_70);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x1e;

      }

      else {

        if (puVar1 != (undefined *)0x44c6ae5) goto LAB_0041f205;

        FUN_00401340("RENDERSURFACE");

        iVar2 = _stricmp(_String,local_20);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0xc;

      }

    }

    else if (puVar1 == (undefined *)0x625b562) {

      FUN_00401340("DID_MAPPER");

      iVar2 = _stricmp(_String,local_10);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x26;

    }

    else {

      if (puVar1 != (undefined *)0x6292bf4) goto LAB_0041f205;

      FUN_00401340("UI_LAYOUT");

      iVar2 = _stricmp(_String,local_c8);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x23;

    }

  }

  else if (puVar1 < (undefined *)0xcf90dc6) {

    if (puVar1 == (undefined *)0xcf90dc5) {

      FUN_00401340("PHYSICS_SCRIPT_TABLE");

      iVar2 = _stricmp(_String,local_5c);

      LVar3 = InterlockedDecrement((LONG *)(local_5c + -0x10));

      if ((LVar3 == 0) && (local_5c + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(local_5c + -0x14))(1);

      }

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x2c;

    }

    else if (puVar1 < (undefined *)0xa4779dc) {

      if (puVar1 == (undefined *)0xa4779db) {

        FUN_00401340("LAND_BLOCK");

        iVar2 = _stricmp(_String,local_8c);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 1;

      }

      else if (puVar1 < (undefined *)0x93b52f6) {

        if (puVar1 == (undefined *)0x93b52f5) {

          FUN_00401340("MATERIALINSTANCE");

          iVar2 = _stricmp(_String,local_a4);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x21;

        }

        else if (puVar1 == (undefined *)0x686c245) {

          FUN_00401340("TABOO_TABLE");

          iVar2 = _stricmp(_String,local_ac);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x14;

        }

        else if (puVar1 == (undefined *)0x730e209) {

          FUN_00401340("OBJECT_HIERARCHY");

          iVar2 = _stricmp(_String,local_b4);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x12;

        }

        else {

          if (puVar1 != (undefined *)0x8d7da23) goto LAB_0041f205;

          FUN_00401340("MONITOREDPROPERTIES");

          iVar2 = _stricmp(_String,local_bc);

          FUN_004011b0();

          if (iVar2 != 0) goto LAB_0041f205;

          *param_2 = 0x17;

        }

      }

      else if (puVar1 == (undefined *)0x93ef862) {

        FUN_00401340("MATERIALMODIFIER");

        iVar2 = _stricmp(_String,local_94);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x20;

      }

      else {

        if (puVar1 != (undefined *)0xa43db85) goto LAB_0041f205;

        FUN_00401340("SURFACETEXTURE");

        iVar2 = _stricmp(_String,local_9c);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0xb;

      }

    }

    else if (puVar1 < (undefined *)0xb05a2e1) {

      if (puVar1 == (undefined *)0xb05a2e0) {

        FUN_00401340("ACTIONMAP");

        iVar2 = _stricmp(_String,local_74);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x27;

      }

      else if (puVar1 == (undefined *)0xa60e32c) {

        FUN_00401340("FONT_LOCAL");

        iVar2 = _stricmp(_String,local_7c);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x2f;

      }

      else {

        if (puVar1 != (undefined *)0xa9ba754) goto LAB_0041f205;

        FUN_00401340("ENVIRONMENT");

        iVar2 = _stricmp(_String,local_84);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x10;

      }

    }

    else if (puVar1 == (undefined *)0xb0cd6b3) {

      FUN_00401340("DBPROPERTIES");

      iVar2 = _stricmp(_String,local_64);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x31;

    }

    else {

      if (puVar1 != (undefined *)0xc08c675) goto LAB_0041f205;

      FUN_00401340("SURFACE");

      iVar2 = _stricmp(_String,local_6c);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0xd;

    }

  }

  else if (puVar1 < (undefined *)0xe710391) {

    if (puVar1 == (undefined *)0xe710390) {

      FUN_00401340("KEYMAP");

      iVar2 = _stricmp(_String,local_2c);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x1d;

    }

    else if (puVar1 < (undefined *)0xdb1f59b) {

      if (puVar1 == (undefined *)0xdb1f59a) {

        FUN_00401340("GFXOBJ");

        iVar2 = _stricmp(_String,local_44);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 6;

      }

      else if (puVar1 == (undefined *)0xd4683bb) {

        FUN_00401340("ANIMATION_HOOK");

        iVar2 = _stricmp(_String,local_4c);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 9;

      }

      else {

        if (puVar1 != (undefined *)0xdacb838) goto LAB_0041f205;

        FUN_00401340("RENDER_MESH");

        iVar2 = _stricmp(_String,local_54);

        FUN_004011b0();

        if (iVar2 != 0) goto LAB_0041f205;

        *param_2 = 0x43;

      }

    }

    else if (puVar1 == (undefined *)0xe1c0432) {

      FUN_00401340("DUAL_DID_MAPPER");

      iVar2 = _stricmp(_String,local_34);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x28;

    }

    else {

      if (puVar1 != (undefined *)0xe267935) goto LAB_0041f205;

      FUN_00401340("MTABLE");

      iVar2 = _stricmp(_String,local_3c);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0xe;

    }

  }

  else if (puVar1 < (undefined *)0xec79058) {

    if (puVar1 == (undefined *)0xec79057) {

      FUN_00401340("STRING");

      iVar2 = _stricmp(_String,local_14);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x29;

    }

    else if (puVar1 == (undefined *)0xebaa971) {

      FUN_00401340("BADDATA");

      iVar2 = _stricmp(_String,local_1c);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x13;

    }

    else {

      if (puVar1 != (undefined *)0xec67935) goto LAB_0041f205;

      FUN_00401340("STABLE");

      iVar2 = _stricmp(_String,local_24);

      FUN_004011b0();

      if (iVar2 != 0) goto LAB_0041f205;

      *param_2 = 0x22;

    }

  }

  else if (puVar1 == (undefined *)0xee7e04e) {

    FUN_00401340("REGION");

    iVar2 = _stricmp(_String,local_4);

    FUN_004011b0();

    if (iVar2 != 0) goto LAB_0041f205;

    *param_2 = 0x1c;

  }

  else {

    if (puVar1 != (undefined *)0xf6af247) goto LAB_0041f205;

    FUN_00401340("CLOTHING");

    iVar2 = _stricmp(_String,local_c);

    FUN_004011b0();

    if (iVar2 != 0) goto LAB_0041f205;

    *param_2 = 0x19;

  }

  uVar4 = 1;

LAB_0041f205:

  LVar3 = InterlockedDecrement((LONG *)(_String + -0x10));

  if ((LVar3 == 0) && (_String + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(_String + -0x14))(1);

  }

  return uVar4;

}





// --- FUN_0041f230 at 0x0041F230 (size: 319) ---


int * __thiscall FUN_0041f230(int *param_1,undefined4 *param_2)



{

  LONG *lpAddend;

  int *piVar1;

  int iVar2;

  undefined *puVar3;

  undefined *puVar4;

  char cVar5;

  LONG LVar6;

  uint uVar7;

  int *piVar8;

  int *piVar9;

  

  if ((param_1[1] & 0x7fffffffU) < (param_2[1] & 0x7fffffff)) {

    param_1[2] = 0;

    cVar5 = FUN_004082c0(param_2[1] & 0x7fffffff);

    if (cVar5 == '\0') {

      return param_1;

    }

  }

  piVar8 = (int *)*param_1;

  piVar9 = (int *)*param_2;

  piVar1 = piVar9 + param_2[2];

  for (; piVar9 < piVar1; piVar9 = piVar9 + 1) {

    iVar2 = *piVar8;

    if (iVar2 != *piVar9) {

      LVar6 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar6 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

      }

      iVar2 = *piVar9;

      *piVar8 = iVar2;

      InterlockedIncrement((LONG *)(iVar2 + -0x10));

    }

    piVar8 = piVar8 + 1;

  }

  uVar7 = param_2[2];

  if (uVar7 < (uint)param_1[2]) {

    do {

      puVar4 = PTR_DAT_00818344;

      lpAddend = (LONG *)(PTR_DAT_00818344 + -0x10);

      InterlockedIncrement(lpAddend);

      piVar1 = (int *)(*param_1 + uVar7 * 4);

      puVar3 = (undefined *)*piVar1;

      if (puVar3 != puVar4) {

        LVar6 = InterlockedDecrement((LONG *)(puVar3 + -0x10));

        if ((LVar6 == 0) && ((undefined4 *)(puVar3 + -0x14) != (undefined4 *)0x0)) {

          (*(code *)**(undefined4 **)(puVar3 + -0x14))(1);

        }

        *piVar1 = (int)puVar4;

        InterlockedIncrement(lpAddend);

      }

      LVar6 = InterlockedDecrement((LONG *)(puVar4 + -0x10));

      if ((LVar6 == 0) && ((undefined4 *)(puVar4 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(puVar4 + -0x14))(1);

      }

      uVar7 = uVar7 + 1;

    } while (uVar7 < (uint)param_1[2]);

  }

  param_1[2] = param_2[2];

  return param_1;

}





// --- FUN_0041f370 at 0x0041F370 (size: 973) ---


undefined1 FUN_0041f370(undefined4 param_1)



{

  undefined1 uVar1;

  

  uVar1 = 0;

  switch(param_1) {

  case 1:

    FUN_00405000("LAND_BLOCK");

    return 1;

  case 2:

    FUN_00405000(&DAT_007969e4);

    return 1;

  case 3:

    FUN_00405000(&DAT_007969cc);

    return 1;

  case 4:

    FUN_00405000(&DAT_007969e8);

    return 1;

  case 5:

    FUN_00405000("INSTANTIATION");

    return 1;

  case 6:

    FUN_00405000("GFXOBJ");

    return 1;

  case 7:

    FUN_00405000("SETUP");

    return 1;

  case 8:

    FUN_00405000(&DAT_007969ec);

    return 1;

  case 9:

    FUN_00405000("ANIMATION_HOOK");

    return 1;

  case 10:

    FUN_00405000("PALETTE");

    return 1;

  case 0xb:

    FUN_00405000("SURFACETEXTURE");

    return 1;

  case 0xc:

    FUN_00405000("RENDERSURFACE");

    return 1;

  case 0xd:

    FUN_00405000("SURFACE");

    return 1;

  case 0xe:

    FUN_00405000("MTABLE");

    return 1;

  case 0xf:

    FUN_00405000(&DAT_007969d4);

    return 1;

  case 0x10:

    FUN_00405000("ENVIRONMENT");

    return 1;

  case 0x11:

    FUN_00405000("CHAT_POSE_TABLE");

    return 1;

  case 0x12:

    FUN_00405000("OBJECT_HIERARCHY");

    return 1;

  case 0x13:

    FUN_00405000("BADDATA");

    return 1;

  case 0x14:

    FUN_00405000("TABOO_TABLE");

    return 1;

  case 0x15:

    FUN_00405000("FILE2ID_TABLE");

    return 1;

  case 0x16:

    FUN_00405000("NAME_FILTER_TABLE");

    return 1;

  case 0x17:

    FUN_00405000("MONITOREDPROPERTIES");

    return 1;

  case 0x18:

    FUN_00405000("PAL_SET");

    return 1;

  case 0x19:

    FUN_00405000("CLOTHING");

    return 1;

  case 0x1a:

    FUN_00405000("DEGRADEINFO");

    return 1;

  case 0x1b:

    FUN_00405000("SCENE");

    return 1;

  case 0x1c:

    FUN_00405000("REGION");

    return 1;

  case 0x1d:

    FUN_00405000("KEYMAP");

    return 1;

  case 0x1e:

    FUN_00405000("RENDERTEXTURE");

    return 1;

  case 0x1f:

    FUN_00405000("RENDERMATERIAL");

    return 1;

  case 0x20:

    FUN_00405000("MATERIALMODIFIER");

    return 1;

  case 0x21:

    FUN_00405000("MATERIALINSTANCE");

    return 1;

  case 0x22:

    FUN_00405000("STABLE");

    return 1;

  case 0x23:

    FUN_00405000("UI_LAYOUT");

    return 1;

  case 0x24:

    FUN_00405000("ENUM_MAPPER");

    return 1;

  case 0x25:

    FUN_00405000("STRING_TABLE");

    return 1;

  case 0x26:

    FUN_00405000("DID_MAPPER");

    return 1;

  case 0x27:

    FUN_00405000("ACTIONMAP");

    return 1;

  case 0x28:

    FUN_00405000("DUAL_DID_MAPPER");

    return 1;

  case 0x29:

    FUN_00405000("STRING");

    return 1;

  case 0x2a:

    FUN_00405000("PARTICLE_EMITTER");

    return 1;

  case 0x2b:

    FUN_00405000("PHYSICS_SCRIPT");

    return 1;

  case 0x2c:

    FUN_00405000("PHYSICS_SCRIPT_TABLE");

    return 1;

  case 0x2d:

    FUN_00405000("MASTER_PROPERTY");

    return 1;

  case 0x2e:

    FUN_00405000(&DAT_007969dc);

    return 1;

  case 0x2f:

    FUN_00405000("FONT_LOCAL");

    return 1;

  case 0x30:

    FUN_00405000("STRING_STATE");

    return 1;

  case 0x31:

    FUN_00405000("DBPROPERTIES");

    uVar1 = 1;

    break;

  case 0x43:

    FUN_00405000("RENDER_MESH");

    return 1;

  }

  return uVar1;

}





// --- FUN_0041f850 at 0x0041F850 (size: 163) ---


undefined4 * __thiscall FUN_0041f850(undefined4 *param_1,undefined4 *param_2)



{

  int iVar1;

  

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  FUN_0041f230(param_2 + 2);

  param_1[5] = param_2[5];

  param_1[6] = param_2[6];

  *(undefined1 *)(param_1 + 7) = *(undefined1 *)(param_2 + 7);

  *(undefined1 *)((int)param_1 + 0x1d) = *(undefined1 *)((int)param_2 + 0x1d);

  *(undefined1 *)((int)param_1 + 0x1e) = *(undefined1 *)((int)param_2 + 0x1e);

  *(undefined1 *)((int)param_1 + 0x1f) = *(undefined1 *)((int)param_2 + 0x1f);

  iVar1 = param_2[8];

  param_1[8] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  *(undefined1 *)(param_1 + 9) = *(undefined1 *)(param_2 + 9);

  *(undefined1 *)((int)param_1 + 0x25) = *(undefined1 *)((int)param_2 + 0x25);

  *(undefined1 *)((int)param_1 + 0x26) = *(undefined1 *)((int)param_2 + 0x26);

  *(undefined1 *)((int)param_1 + 0x27) = *(undefined1 *)((int)param_2 + 0x27);

  *(undefined1 *)(param_1 + 10) = *(undefined1 *)(param_2 + 10);

  *(undefined1 *)((int)param_1 + 0x29) = *(undefined1 *)((int)param_2 + 0x29);

  *(undefined1 *)((int)param_1 + 0x2a) = *(undefined1 *)((int)param_2 + 0x2a);

  param_1[0xb] = param_2[0xb];

  param_1[0xc] = param_2[0xc];

  param_1[0xd] = param_2[0xd];

  return param_1;

}





// --- FUN_0041f900 at 0x0041F900 (size: 153) ---


undefined4 FUN_0041f900(undefined4 *param_1,undefined4 param_2)



{

  char cVar1;

  undefined4 *puVar2;

  LONG LVar3;

  undefined4 *puVar4;

  

  puVar2 = (undefined4 *)FUN_005df0f5(0x40);

  if (puVar2 == (undefined4 *)0x0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    FUN_0041f850(param_2);

  }

  cVar1 = FUN_0042bd40(puVar2);

  if (cVar1 == '\0') {

    if (puVar2 != (undefined4 *)0x0) {

      puVar4 = (undefined4 *)(puVar2[10] + -0x14);

      LVar3 = InterlockedDecrement((LONG *)(puVar2[10] + -0x10));

      if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

        (**(code **)*puVar4)(1);

      }

      if (((puVar2[5] & 0x80000000) == 0x80000000) && (puVar2[4] != 0)) {

        FUN_00407920(3);

      }

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_0041f9a0 at 0x0041F9A0 (size: 9998) ---


/* WARNING: Type propagation algorithm not settling */



undefined4 FUN_0041f9a0(void)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_3c [4];

  uint uStack_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined1 local_1c;

  undefined1 local_1b;

  undefined1 local_1a;

  undefined1 local_19;

  int local_18;

  undefined1 local_14;

  undefined1 local_13;

  undefined1 local_12;

  undefined1 local_11;

  undefined1 local_10;

  undefined1 local_f;

  undefined1 local_e;

  undefined1 local_c;

  undefined1 local_b;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_0041c380();

  local_3c[1] = 0;

  local_3c[2] = 0;

  local_24 = 1;

  local_20 = 2;

  local_1c = 0;

  local_1b = 0;

  local_1a = 1;

  local_19 = 0;

  FUN_00405000(&DAT_007938af);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x15;

  local_4 = 0x90;

  local_e = 0;

  FUN_0041f900(&DAT_007964d4,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0;

  local_3c[2] = 0;

  FUN_00401340(&DAT_0079659c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 2;

  local_1c = 1;

  local_1b = 0;

  local_1a = 1;

  local_19 = 0;

  FUN_00405000(&DAT_00796b18);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x15;

  local_4 = 0x90;

  local_e = 0;

  FUN_0041f900(&DAT_007964d8,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0;

  local_3c[2] = 0;

  local_24 = 1;

  local_20 = 2;

  local_1c = 0;

  local_1b = 0;

  local_1a = 1;

  local_19 = 0;

  FUN_00405000(&DAT_007938af);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x14;

  local_4 = 0x90;

  local_e = 0;

  FUN_0041f900(&DAT_007964dc,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0;

  local_3c[2] = 0;

  FUN_00401340(&DAT_007965a4);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 2;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796b14);

  local_14 = 0;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_007964e0,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0;

  local_3c[2] = 0;

  FUN_00401340(&DAT_007965ac);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 2;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796b10);

  local_14 = 0;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_007964e4,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x1000000;

  local_3c[2] = 0x100ffff;

  FUN_00401340(&DAT_007965b4);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("gfxobj");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 100;

  local_4 = 200;

  local_e = 0;

  FUN_0041f900(&DAT_007964e8,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x2000000;

  local_3c[2] = 0x200ffff;

  FUN_00401340(&DAT_007965bc);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("setup");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x19;

  local_4 = 100;

  local_e = 0;

  FUN_0041f900(&DAT_007964ec,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x3000000;

  local_3c[2] = 0x300ffff;

  FUN_00401340(&DAT_007965c4);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796af8);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x14;

  local_4 = 0x50;

  local_e = 0;

  FUN_0041f900(&DAT_007964f0,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0;

  local_3c[2] = 0;

  FUN_00401340(&DAT_007965cc);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796af4);

  local_14 = 0;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_007964f4,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x4000000;

  local_3c[2] = 0x400ffff;

  FUN_00401340(&DAT_007965d4);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("palette");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x3c;

  local_4 = 100;

  local_e = 0;

  FUN_0041f900(&DAT_007964f8,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x5000000;

  local_3c[2] = 0x5ffffff;

  FUN_00401340(".texture");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("textures");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 1;

  local_c = 0;

  local_b = 1;

  local_8 = 100;

  local_4 = 400;

  local_e = 0;

  FUN_0041f900(&DAT_007964fc,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x6000000;

  local_3c[2] = 0x7ffffff;

  FUN_00401340(&DAT_007965e8);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_007965f0);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_007965f8);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_00796600);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_00796608);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_00796610);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(&DAT_00796618);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("surfaces");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 1;

  local_c = 0;

  local_b = 1;

  local_8 = 100;

  local_4 = 400;

  local_e = 0;

  FUN_0041f900(&DAT_00796500,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x8000000;

  local_3c[2] = 0x800ffff;

  FUN_00401340(".surface");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("materials");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x32;

  local_4 = 200;

  local_e = 0;

  FUN_0041f900(&DAT_00796504,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x9000000;

  local_3c[2] = 0x900ffff;

  FUN_00401340(&DAT_0079662c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796ac4);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796508,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xa000000;

  local_3c[2] = 0xa00ffff;

  FUN_00401340(&DAT_00796634);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("sound");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_0079650c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xd000000;

  local_3c[2] = 0xd00ffff;

  FUN_00401340(&DAT_0079663c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796ab8);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796510,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe000007;

  local_3c[2] = 0xe000007;

  FUN_00401340(&DAT_00796644);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796ab4);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 0;

  local_8 = 1;

  local_4 = 1;

  local_e = 0;

  FUN_0041f900(&DAT_00796514,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe00000d;

  local_3c[2] = 0xe00000d;

  FUN_00401340(&DAT_0079664c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("DungeonCfgs");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796518,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe00001a;

  local_3c[2] = 0xe00001a;

  FUN_00401340(&DAT_00796654);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("weenie");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 0;

  local_8 = 1;

  local_4 = 1;

  local_e = 0;

  FUN_0041f900(&DAT_0079651c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe00001e;

  local_3c[2] = 0xe00001e;

  FUN_00401340(".taboo");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("weenie");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796520,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe00001f;

  local_3c[2] = 0xe00001f;

  local_24 = 1;

  local_20 = 1;

  local_1c = 0;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_007938af);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796524,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe000020;

  local_3c[2] = 0xe000020;

  FUN_00401340(&DAT_00796664);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("namefilter");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796528,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xe020000;

  local_3c[2] = 0xe02ffff;

  FUN_00401340(".monprop");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("properties");

  local_14 = 0;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_0079652c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0xf000000;

  local_3c[2] = 0xf00ffff;

  FUN_00401340(&DAT_00796678);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("palset");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 10;

  local_4 = 0x28;

  local_e = 0;

  FUN_0041f900(&DAT_00796530,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x10000000;

  local_3c[2] = 0x1000ffff;

  FUN_00401340(&DAT_00796680);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("clothing");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x14;

  local_4 = 0x28;

  local_e = 0;

  FUN_0041f900(&DAT_00796534,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x11000000;

  local_3c[2] = 0x1100ffff;

  FUN_00401340(&DAT_00796688);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a70);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x50;

  local_4 = 200;

  local_e = 0;

  FUN_0041f900(&DAT_00796538,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x12000000;

  local_3c[2] = 0x1200ffff;

  FUN_00401340(&DAT_00796690);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a6c);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x19;

  local_4 = 100;

  local_e = 0;

  FUN_0041f900(&DAT_0079653c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x13000000;

  local_3c[2] = 0x1300ffff;

  FUN_00401340(&DAT_00796698);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("landscape");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_00796540,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x14000000;

  local_3c[2] = 0x1400ffff;

  FUN_00401340(".keymap");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("keymap");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796544,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x15000000;

  local_3c[2] = 0x15ffffff;

  FUN_00401340(".rtexture");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("textures");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 1;

  local_c = 0;

  local_b = 1;

  local_8 = 0x80;

  local_4 = 0x100;

  local_e = 0;

  FUN_0041f900(&DAT_00796548,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x16000000;

  local_3c[2] = 0x16ffffff;

  FUN_00401340(&DAT_007966b4);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("materials");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 1;

  FUN_0041f900(&DAT_0079654c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x17000000;

  local_3c[2] = 0x17ffffff;

  FUN_00401340(&DAT_007966bc);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("materials");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 0;

  FUN_0041f900(&DAT_00796550,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x18000000;

  local_3c[2] = 0x18ffffff;

  FUN_00401340(&DAT_007966c0);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("materials");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 0;

  FUN_0041f900(&DAT_00796554,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x19000000;

  local_3c[2] = 0x19ffffff;

  FUN_00401340(".rendermesh");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a58);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x10;

  local_4 = 0x20;

  local_e = 0;

  FUN_0041f900(&DAT_00796598,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x20000000;

  local_3c[2] = 0x2000ffff;

  FUN_00401340(&DAT_007966d0);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a54);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 2;

  local_4 = 6;

  local_e = 0;

  FUN_0041f900(&DAT_00796558,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x21000000;

  local_3c[2] = 0x21ffffff;

  FUN_00401340(&DAT_007966d8);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 3;

  local_20 = 1;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 1;

  FUN_00405000("ui/layout");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_0079655c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x22000000;

  local_3c[2] = 0x22ffffff;

  FUN_00401340(&DAT_007966e0);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a44);

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 1;

  FUN_0041f900(&DAT_00796560,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x23000000;

  local_3c[2] = 0x24ffffff;

  FUN_00401340(&DAT_007966e8);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(".stt_ansi");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(".stt_bin");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 1;

  FUN_00405000("stringtable");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_00796564,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x25000000;

  local_3c[2] = 0x25ffffff;

  FUN_00401340(&DAT_00796708);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("emp/idmap");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 1;

  FUN_0041f900(&DAT_00796568,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x26000000;

  local_3c[2] = 0x2600ffff;

  FUN_00401340(".actionmap");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("actionmap");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_0079656c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x27000000;

  local_3c[2] = 0x27ffffff;

  FUN_00401340(".dimp");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("emp/idmap");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 0x40;

  local_4 = 0x80;

  local_e = 1;

  FUN_0041f900(&DAT_00796570,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x31000000;

  local_3c[2] = 0x3100ffff;

  FUN_00401340(&DAT_00796724);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("string");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796574,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x32000000;

  local_3c[2] = 0x3200ffff;

  FUN_00401340(&DAT_0079672c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a14);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796578,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x33000000;

  local_3c[2] = 0x3300ffff;

  FUN_00401340(&DAT_00796734);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a10);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_0079657c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x34000000;

  local_3c[2] = 0x3400ffff;

  FUN_00401340(&DAT_0079673c);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000(&DAT_00796a0c);

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796580,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x39000000;

  local_3c[2] = 0x39ffffff;

  FUN_00401340(&DAT_00796744);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("emp/property");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_00796584,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x40000000;

  local_3c[2] = 0x40000fff;

  FUN_00401340(".font");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("fonts");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796588,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x40001000;

  local_3c[2] = 0x40ffffff;

  FUN_00401340(".font_local");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 1;

  FUN_00405000("fonts");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_0079658c,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x41000000;

  local_3c[2] = 0x41ffffff;

  FUN_00401340(&DAT_00796760);

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 0;

  local_1a = 0;

  local_19 = 1;

  FUN_00405000("stringtable");

  local_14 = 1;

  local_13 = 0;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 1;

  FUN_0041f900(&DAT_00796590,local_3c + 1);

  local_28 = 0;

  local_3c[1] = 0x78000000;

  local_3c[2] = 0x7fffffff;

  FUN_00401340(".dbpc");

  FUN_0040c440(local_3c);

  puVar2 = (undefined4 *)(local_3c[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(".pmat");

  FUN_0040c440(local_3c);

  LVar1 = InterlockedDecrement((LONG *)(local_3c[0] + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_3c[0] + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_3c[0] + -0x14))(1);

  }

  local_24 = 1;

  local_20 = 1;

  local_1c = 1;

  local_1b = 1;

  local_1a = 0;

  local_19 = 0;

  FUN_00405000("properties");

  local_14 = 1;

  local_13 = 1;

  local_12 = 1;

  local_11 = 0;

  local_10 = 0;

  local_f = 0;

  local_c = 0;

  local_b = 1;

  local_8 = 3;

  local_4 = 0xf;

  local_e = 0;

  FUN_0041f900(&DAT_00796594,local_3c + 1);

  local_28 = 0;

  LVar1 = InterlockedDecrement((LONG *)(local_18 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_18 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_18 + -0x14))(1);

  }

  if (((uStack_2c & 0x80000000) == 0x80000000) && (local_3c[3] != 0)) {

    FUN_00407920(3);

  }

  return 1;

}





