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

// --- FUN_004f0010 at 0x004F0010 (size: 83) ---


bool __thiscall FUN_004f0010(int *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  

  if (*param_1 == 0) {

    piVar3 = (int *)0x0;

  }

  else {

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

  }

  uVar1 = FUN_004220b0(param_2,0x31);

  iVar2 = FUN_00415430(uVar1);

  if (iVar2 == 0) {

    iVar2 = 0;

  }

  else {

    iVar2 = iVar2 + -0x78;

  }

  *param_1 = iVar2;

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

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

  }

  return *param_1 != 0;

}





// --- FUN_004f0160 at 0x004F0160 (size: 629) ---


/* WARNING: Removing unreachable block (ram,0x004f019d) */

/* WARNING: Removing unreachable block (ram,0x004f01bb) */

/* WARNING: Removing unreachable block (ram,0x004f01c0) */

/* WARNING: Removing unreachable block (ram,0x004f01e3) */

/* WARNING: Removing unreachable block (ram,0x004f01e7) */

/* WARNING: Removing unreachable block (ram,0x004f0200) */

/* WARNING: Removing unreachable block (ram,0x004f0211) */

/* WARNING: Removing unreachable block (ram,0x004f0229) */

/* WARNING: Removing unreachable block (ram,0x004f0230) */

/* WARNING: Removing unreachable block (ram,0x004f0238) */

/* WARNING: Removing unreachable block (ram,0x004f024e) */

/* WARNING: Removing unreachable block (ram,0x004f025e) */

/* WARNING: Removing unreachable block (ram,0x004f027a) */

/* WARNING: Removing unreachable block (ram,0x004f027e) */

/* WARNING: Removing unreachable block (ram,0x004f028f) */

/* WARNING: Removing unreachable block (ram,0x004f0398) */

/* WARNING: Removing unreachable block (ram,0x004f0299) */

/* WARNING: Removing unreachable block (ram,0x004f02a1) */

/* WARNING: Removing unreachable block (ram,0x004f02b0) */

/* WARNING: Removing unreachable block (ram,0x004f02b6) */

/* WARNING: Removing unreachable block (ram,0x004f02be) */

/* WARNING: Removing unreachable block (ram,0x004f02c2) */

/* WARNING: Removing unreachable block (ram,0x004f02cf) */

/* WARNING: Removing unreachable block (ram,0x004f02d5) */

/* WARNING: Removing unreachable block (ram,0x004f02d9) */

/* WARNING: Removing unreachable block (ram,0x004f02dd) */

/* WARNING: Removing unreachable block (ram,0x004f02e1) */

/* WARNING: Removing unreachable block (ram,0x004f02ee) */

/* WARNING: Removing unreachable block (ram,0x004f02f6) */

/* WARNING: Removing unreachable block (ram,0x004f0307) */

/* WARNING: Removing unreachable block (ram,0x004f030d) */

/* WARNING: Removing unreachable block (ram,0x004f0319) */

/* WARNING: Removing unreachable block (ram,0x004f031d) */

/* WARNING: Removing unreachable block (ram,0x004f032e) */

/* WARNING: Removing unreachable block (ram,0x004f0334) */

/* WARNING: Removing unreachable block (ram,0x004f033c) */

/* WARNING: Removing unreachable block (ram,0x004f0340) */

/* WARNING: Removing unreachable block (ram,0x004f0348) */

/* WARNING: Removing unreachable block (ram,0x004f0359) */

/* WARNING: Removing unreachable block (ram,0x004f035f) */

/* WARNING: Removing unreachable block (ram,0x004f0367) */

/* WARNING: Removing unreachable block (ram,0x004f036b) */

/* WARNING: Removing unreachable block (ram,0x004f037a) */

/* WARNING: Removing unreachable block (ram,0x004f0380) */

/* WARNING: Removing unreachable block (ram,0x004f0384) */

/* WARNING: Removing unreachable block (ram,0x004f01c8) */

/* WARNING: Removing unreachable block (ram,0x004f01cf) */



uint FUN_004f0160(void)



{

  uint uVar1;

  undefined4 local_28 [9];

  

  FUN_00413bc0(local_28,0x15,2);

  uVar1 = FUN_004f0010(local_28[0]);

  return uVar1 & 0xffffff00;

}





// --- FUN_004f03e0 at 0x004F03E0 (size: 382) ---


undefined1 FUN_004f03e0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  char cVar2;

  undefined1 local_11;

  undefined4 *local_10;

  int *local_c;

  undefined4 *local_8;

  int *local_4;

  

  local_11 = 1;

  local_8 = (undefined4 *)0x0;

  local_4 = (int *)0x0;

  cVar2 = FUN_004f0160(param_1,&local_8);

  if (cVar2 == '\0') {

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

      iVar1 = local_8[1];

      local_8[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

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

      }

      local_8 = (undefined4 *)0x0;

    }

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

      iVar1 = local_4[1];

      local_4[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_4)(1);

      }

    }

    return 0;

  }

  local_10 = (undefined4 *)0x0;

  local_c = (int *)0x0;

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

LAB_004f0492:

    local_11 = 0;

  }

  else {

    cVar2 = (**(code **)(*local_4 + 0x118))(0xd4,&local_10);

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

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

      (**(code **)(*local_c + 0xc0))(param_2);

    }

  }

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

    cVar2 = (**(code **)(*local_4 + 0x118))(0xd5,&local_10);

    if (cVar2 != '\0') {

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

        (**(code **)(*local_c + 0xc0))(param_3);

      }

      goto LAB_004f04d5;

    }

  }

  local_11 = 0;

LAB_004f04d5:

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

    iVar1 = local_10[1];

    local_10[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*local_10)(1);

    }

    local_10 = (undefined4 *)0x0;

  }

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

    iVar1 = local_c[1];

    local_c[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*local_c)(1);

    }

    local_c = (int *)0x0;

  }

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

    iVar1 = local_8[1];

    local_8[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

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

    }

    local_8 = (undefined4 *)0x0;

  }

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

    iVar1 = local_4[1];

    local_4[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*local_4)(1);

    }

  }

  return local_11;

}





// --- FUN_004f0560 at 0x004F0560 (size: 108) ---


/* WARNING: Removing unreachable block (ram,0x004f059c) */



uint FUN_004f0560(void)



{

  uint uVar1;

  undefined4 local_4;

  

  FUN_00413bc0(&local_4,0x16,2);

  uVar1 = FUN_004f0010(local_4);

  return uVar1 & 0xffffff00;

}





// --- FUN_004f05d0 at 0x004F05D0 (size: 582) ---


void __fastcall FUN_004f05d0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 *local_11c;

  int *local_118;

  undefined4 uStack_114;

  undefined1 local_110 [120];

  undefined1 auStack_98 [148];

  

  FUN_006823d0();

  local_11c = (undefined4 *)0x0;

  local_118 = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  uStack_114 = FUN_00429a00();

  FUN_0042c290(&uStack_114,&local_11c);

  FUN_0042a2d0(0xc3);

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

    FUN_00429b10();

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

  }

  uStack_114 = FUN_00429a00();

  FUN_0042c290(&uStack_114,&local_11c);

  FUN_0042dc80();

  uVar3 = 0x10000004;

  uVar2 = FUN_004016b0("ID_Option_ConfirmChange",0x10000004);

  FUN_0042c9c0(uVar2,uVar3);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

    (**(code **)(*local_118 + 0xc4))(auStack_98);

  }

  uStack_114 = FUN_00429a00();

  FUN_0042c290(&uStack_114,&local_11c);

  FUN_0042a2d0(0xc6);

  uStack_114 = DAT_007c46f8;

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

    FUN_00429b10();

    (**(code **)(*local_118 + 0x8c))(uStack_114);

  }

  uStack_114 = FUN_00429a00();

  FUN_0042c290(&uStack_114,&local_11c);

  FUN_0042a2d0(0xac);

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

    FUN_00429b10();

    (**(code **)(*local_118 + 0x74))(1);

  }

  uStack_114 = FUN_00429a00();

  FUN_0042c290(&uStack_114,&local_11c);

  uVar2 = FUN_00478810(local_110);

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

  FUN_0042e590();

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

    iVar1 = local_11c[1];

    local_11c[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*local_11c)(1);

    }

    local_11c = (undefined4 *)0x0;

  }

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

    iVar1 = local_118[1];

    local_118[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*local_118)(1);

    }

    local_118 = (int *)0x0;

  }

  FUN_00681f60();

  return;

}





// --- FUN_004f0820 at 0x004F0820 (size: 78) ---


void __thiscall FUN_004f0820(int param_1,char param_2)



{

  if ((*(char *)(param_1 + 4) != '\0') && (param_2 != '\0')) {

    FUN_004f05d0();

  }

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

    FUN_006a3680();

  }

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

    FUN_0047a2b0();

  }

  if (*(code **)(param_1 + 0x10) != (code *)0x0) {

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

  }

  if ((*(undefined4 **)(param_1 + 0x14) != (undefined4 *)0x0) && (param_2 != '\0')) {

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

  }

  return;

}





// --- FUN_004f0a20 at 0x004F0A20 (size: 647) ---


void __fastcall FUN_004f0a20(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  

  FUN_004639a0();

  piVar2 = (int *)FUN_00463c00(0x10000231);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x10000232);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x10000233);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x1000023b);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x10000235);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x10000238);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x100005c5);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x100005c6);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_00463c00(0x10000236);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(7);

  }

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

  piVar2 = (int *)FUN_00463c00(0x1000023d);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(5);

  }

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

  piVar2 = (int *)FUN_0043c680();

  iVar1 = param_1 + 0x5f8;

  (**(code **)(*piVar2 + 4))(0x4dd1f0,iVar1);

  (**(code **)(*piVar2 + 4))(0x4dd201,iVar1);

  (**(code **)(*piVar2 + 4))(0x4dd277,iVar1);

  (**(code **)(*piVar2 + 4))(0x4dd278,iVar1);

  param_1 = param_1 + 0x5fc;

  (**(code **)(*DAT_008f958c + 8))(1,0x19,param_1);

  (**(code **)(*DAT_008f958c + 8))(1,0x18,param_1);

  (**(code **)(*DAT_008f958c + 8))(1,0x1e,param_1);

  (**(code **)(*DAT_008f958c + 8))(1,0x86,param_1);

  (**(code **)(*DAT_008f958c + 8))(1,0xbc,param_1);

  (**(code **)(*DAT_008f958c + 8))(1,0x71,param_1);

  (**(code **)(*DAT_008f958c + 8))(0xe,1,param_1);

  (**(code **)(*DAT_008f958c + 8))(0xe,2,param_1);

  (**(code **)(*DAT_008f958c + 8))(0xe,6,param_1);

  (**(code **)(*DAT_008f958c + 8))(0xe,7,param_1);

  (**(code **)(*DAT_008f958c + 8))(5,1,param_1);

  return;

}





// --- FUN_004f0cb0 at 0x004F0CB0 (size: 118) ---


undefined4 __thiscall FUN_004f0cb0(int *param_1,undefined4 param_2)



{

  uint uVar1;

  

  if (((uint)param_1[0x29] >> 1 & 1) != 0) {

    (**(code **)(*param_1 + 0x140))(param_2);

    (**(code **)(*param_1 + 0x144))(param_2);

    (**(code **)(*param_1 + 0x148))(param_2);

    uVar1 = 0;

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

      do {

        (**(code **)(**(int **)(param_1[0x18a] + uVar1 * 4) + 0x20))(param_2);

        uVar1 = uVar1 + 1;

      } while (uVar1 < (uint)param_1[0x18c]);

    }

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

    return 1;

  }

  return 0;

}





// --- FUN_004f0e00 at 0x004F0E00 (size: 76) ---


undefined4 __fastcall FUN_004f0e00(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x1000024e);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0e50 at 0x004F0E50 (size: 76) ---


undefined4 __fastcall FUN_004f0e50(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000242);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0ea0 at 0x004F0EA0 (size: 76) ---


undefined4 __fastcall FUN_004f0ea0(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000243);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0ef0 at 0x004F0EF0 (size: 76) ---


undefined4 __fastcall FUN_004f0ef0(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000247);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(7);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0f40 at 0x004F0F40 (size: 76) ---


undefined4 __fastcall FUN_004f0f40(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000244);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0f90 at 0x004F0F90 (size: 76) ---


undefined4 __fastcall FUN_004f0f90(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000245);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f0fe0 at 0x004F0FE0 (size: 76) ---


undefined4 __fastcall FUN_004f0fe0(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x10000246);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(1);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f1030 at 0x004F1030 (size: 76) ---


undefined4 __fastcall FUN_004f1030(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x400) == 0x10000012) {

    uVar2 = 0x10000241;

  }

  else if (*(int *)(param_1 + 0x400) == 0x10000013) {

    uVar2 = 0x10000247;

  }

  else {

    uVar2 = 0x10000240;

  }

  FUN_00463c00(uVar2);

  piVar1 = (int *)FUN_00463c00(0x100005eb);

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

    uVar2 = (**(code **)(*piVar1 + 0x94))(1);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f1080 at 0x004F1080 (size: 164) ---


undefined4 * __thiscall FUN_004f1080(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = &PTR_LAB_007a6af4;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  param_1[0x183] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  param_1[0x186] = 0;

  param_1[0x187] = 0;

  param_1[0x188] = 0;

  param_1[0x189] = 0;

  *param_1 = &PTR_FUN_007c4b18;

  param_1[0x17e] = &PTR_FUN_007a8ba0;

  param_1[0x17f] = &PTR_LAB_007c4b0c;

  param_1[0x18a] = 0;

  param_1[0x18b] = 0;

  param_1[0x18c] = 0;

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

  param_1[0x18e] = 0;

  return param_1;

}





// --- FUN_004f11e0 at 0x004F11E0 (size: 133) ---


undefined4 __fastcall FUN_004f11e0(int param_1)



{

  int *piVar1;

  uint uVar2;

  

  FUN_0046e460();

  uVar2 = 0;

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

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x628) + uVar2 * 4);

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

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

      }

      *(undefined4 *)(*(int *)(param_1 + 0x628) + uVar2 * 4) = 0;

      uVar2 = uVar2 + 1;

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

  }

  uVar2 = 0;

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

    do {

      *(undefined4 *)(*(int *)(param_1 + 0x628) + uVar2 * 4) = 0;

      uVar2 = uVar2 + 1;

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

  }

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

  return CONCAT31((int3)((uint)(param_1 + 0x628) >> 8),1);

}





// --- FUN_004f1270 at 0x004F1270 (size: 363) ---


void __fastcall FUN_004f1270(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int *piVar3;

  

  puVar1 = param_1 + 0x17e;

  puVar2 = param_1 + 0x17f;

  *param_1 = &PTR_FUN_007c4b18;

  *puVar1 = &PTR_FUN_007a8ba0;

  *puVar2 = &PTR_LAB_007c4b0c;

  FUN_004f11e0();

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  param_1[0x183] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  param_1[0x186] = 0;

  param_1[0x187] = 0;

  param_1[0x188] = 0;

  param_1[0x189] = 0;

  piVar3 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar3 + 0xc))(puVar1);

  }

  (**(code **)(*DAT_008f958c + 0x10))(1,0x19,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(1,0x18,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(1,0x1e,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(1,0x86,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(1,0xbc,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(1,0x71,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(0xe,1,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(0xe,2,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(0xe,6,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(0xe,7,puVar2);

  (**(code **)(*DAT_008f958c + 0x10))(5,1,puVar2);

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004f13e0 at 0x004F13E0 (size: 30) ---


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



{

  FUN_004f1270();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f1b00 at 0x004F1B00 (size: 21) ---


void __fastcall FUN_004f1b00(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c4ea0;

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

  return;

}





// --- FUN_004f1b20 at 0x004F1B20 (size: 4) ---


undefined4 __fastcall FUN_004f1b20(int param_1)



{

  return *(undefined4 *)(param_1 + 4);

}





// --- FUN_004f1b30 at 0x004F1B30 (size: 5) ---


undefined4 FUN_004f1b30(void)



{

  return 0;

}





// --- FUN_004f1b40 at 0x004F1B40 (size: 37) ---


void __fastcall FUN_004f1b40(int *param_1)



{

  undefined4 uVar1;

  

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

  FUN_00460410(0x10000004,param_1[1],uVar1);

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

  return;

}





// --- FUN_004f1cc0 at 0x004F1CC0 (size: 43) ---


undefined4 * __fastcall FUN_004f1cc0(undefined4 *param_1)



{

  byte unaff_retaddr;

  

  *param_1 = &PTR_FUN_007c4ea0;

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

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f1cf0 at 0x004F1CF0 (size: 160) ---


void __thiscall FUN_004f1cf0(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *unaff_ESI;

  undefined4 *local_8;

  int *local_4;

  

  local_8 = (undefined4 *)0x0;

  local_4 = (int *)0x0;

  FUN_0042a2d0(0x1000003a);

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

    FUN_00429b10();

    (**(code **)(*local_4 + 0x7c))(param_2);

  }

  (**(code **)(**(int **)(param_1 + 8) + 0xd4))(&local_8);

  if ((unaff_ESI != (undefined4 *)0x0) &&

     (iVar1 = unaff_ESI[1], unaff_ESI[1] = iVar1 + -1, iVar1 + -1 == 0)) {

    (**(code **)*unaff_ESI)(1);

  }

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

     (iVar1 = local_8[1], local_8[1] = iVar1 + -1, iVar1 + -1 == 0)) {

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

  }

  return;

}





// --- FUN_004f1d90 at 0x004F1D90 (size: 154) ---


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



int __fastcall FUN_004f1d90(int param_1)



{

  int iVar1;

  int local_58;

  float local_54;

  undefined1 local_50 [76];

  float local_4;

  

  FUN_005cbdd0();

  iVar1 = FUN_0058fe60(local_50);

  if ((iVar1 != 0) && (local_4 < (float)_DAT_007938c0)) {

    local_58 = 0;

    FUN_00592d20(*(undefined4 *)(param_1 + 0x18),&local_58,1);

    local_54 = (float)local_58;

    if (local_58 < 0) {

      local_54 = local_54 + _DAT_0079920c;

    }

    FUN_005cbc40(&local_54);

    iVar1 = FUN_005df4c4();

    return iVar1 - local_58;

  }

  return 0;

}





// --- FUN_004f1e30 at 0x004F1E30 (size: 188) ---


undefined4 __thiscall FUN_004f1e30(int param_1,int param_2,int param_3)



{

  if (param_2 == 1) {

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

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

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

    *(undefined4 *)(param_3 + 0x14) = *(undefined4 *)(param_1 + 0x4c);

    *(undefined4 *)(param_3 + 0x18) = *(undefined4 *)(param_1 + 0x50);

    *(undefined4 *)(param_3 + 0x1c) = *(undefined4 *)(param_1 + 0x54);

    return 1;

  }

  if (param_2 != 3) {

    if (param_2 != 5) {

      return 0;

    }

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

    *(undefined4 *)(param_3 + 0xc) = *(undefined4 *)(param_1 + 0x84);

    *(undefined4 *)(param_3 + 0x10) = *(undefined4 *)(param_1 + 0x88);

    *(undefined4 *)(param_3 + 0x14) = *(undefined4 *)(param_1 + 0x8c);

    *(undefined4 *)(param_3 + 0x18) = *(undefined4 *)(param_1 + 0x90);

    *(undefined4 *)(param_3 + 0x1c) = *(undefined4 *)(param_1 + 0x94);

    return 1;

  }

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

  *(undefined4 *)(param_3 + 0xc) = *(undefined4 *)(param_1 + 100);

  *(undefined4 *)(param_3 + 0x10) = *(undefined4 *)(param_1 + 0x68);

  *(undefined4 *)(param_3 + 0x14) = *(undefined4 *)(param_1 + 0x6c);

  *(undefined4 *)(param_3 + 0x18) = *(undefined4 *)(param_1 + 0x70);

  *(undefined4 *)(param_3 + 0x1c) = *(undefined4 *)(param_1 + 0x74);

  return 1;

}





// --- FUN_004f1ef0 at 0x004F1EF0 (size: 127) ---


undefined4 * __fastcall FUN_004f1ef0(undefined4 *param_1)



{

  undefined4 uVar1;

  LONG *pLVar2;

  

  *param_1 = &PTR_FUN_007c4ed0;

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

  param_1[1] = DAT_008ef11c;

  InterlockedIncrement(pLVar2);

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

  param_1[2] = DAT_008ef11c;

  InterlockedIncrement(pLVar2);

  uVar1 = DAT_00841e74;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[3] = uVar1;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[9] = &PTR_FUN_007a11bc;

  param_1[0xd] = 1;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  return param_1;

}





// --- FUN_004f1f70 at 0x004F1F70 (size: 78) ---


void __fastcall FUN_004f1f70(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[2];

  param_1[9] = &PTR_FUN_0079385c;

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[1];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004f1fc0 at 0x004F1FC0 (size: 227) ---


int __thiscall FUN_004f1fc0(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  

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

  if (puVar1 != *(undefined4 **)(param_2 + 4)) {

    LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

    }

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

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

    InterlockedIncrement((LONG *)(iVar2 + 4));

  }

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

  if (puVar1 != *(undefined4 **)(param_2 + 8)) {

    LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

    }

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

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

    InterlockedIncrement((LONG *)(iVar2 + 4));

  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  return param_1;

}





// --- FUN_004f20b0 at 0x004F20B0 (size: 214) ---


undefined4 * __thiscall

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

            undefined4 param_6,int param_7)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  

  *param_1 = &PTR_FUN_007c4ea0;

  param_1[1] = param_5;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  if (param_2 != 0) {

    if (param_3 == -1) {

      iVar1 = FUN_0046f670(0,0);

    }

    else {

      iVar1 = FUN_0046f770(0,param_3);

    }

    param_1[2] = iVar1;

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_00463c00(0x1000012a);

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

        uVar3 = 0;

      }

      else {

        uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

      }

      param_1[3] = uVar3;

      piVar2 = (int *)FUN_00463c00(0x1000012b);

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

        uVar3 = 0;

      }

      else {

        uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

      }

      param_1[4] = uVar3;

      if (param_7 != DAT_00841e74) {

        iVar1 = FUN_00463c00(0x10000129);

        if (iVar1 != 0) {

          FUN_006a07e0(param_7,3);

        }

      }

      FUN_004f1cf0(param_4);

    }

  }

  return param_1;

}





// --- FUN_004f2190 at 0x004F2190 (size: 331) ---


undefined4 * __thiscall

FUN_004f2190(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,char param_6)



{

  char cVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined *local_94;

  undefined1 auStack_90 [144];

  

  FUN_004f20b0(param_2,0xffffffff,param_3,8,param_4,param_5);

  *param_1 = &PTR_FUN_007c4ee4;

  param_1[5] = param_4;

  if (param_1[3] != 0) {

    local_94 = PTR_DAT_00818340;

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

    cVar1 = FUN_005c9d70(param_1[5],&local_94);

    if (cVar1 != '\0') {

      FUN_0046a740(&local_94);

    }

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

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

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

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

    }

  }

  if (param_1[2] != 0) {

    local_94 = PTR_DAT_00818340;

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

    cVar1 = FUN_005c9e10(param_1[5],&local_94);

    if (cVar1 != '\0') {

      FUN_0042dc80();

      FUN_0042cbe0(&local_94,1);

      FUN_004618a0(auStack_90);

      (**(code **)(*(int *)param_1[2] + 0x110))(1);

      FUN_0042e590();

    }

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

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

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

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

    }

  }

  if (param_6 != '\0') {

    (**(code **)(*DAT_008f958c + 8))(8,param_1[5],param_1);

  }

  return param_1;

}





// --- FUN_004f22e0 at 0x004F22E0 (size: 507) ---


undefined4 * __thiscall

FUN_004f22e0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,int param_4,

            undefined1 param_5,undefined4 param_6,char param_7)



{

  char cVar1;

  LONG LVar2;

  int *piVar3;

  undefined4 *puVar4;

  undefined *local_b4;

  int iStack_b0;

  int iStack_ac;

  

  FUN_004f20b0(param_2,0xffffffff,param_3,9,param_4);

  *(undefined1 *)(param_1 + 7) = param_5;

  param_1[5] = param_4;

  *param_1 = &PTR_FUN_007c4f14;

  param_1[6] = param_4 + -1;

  if (param_1[3] != 0) {

    local_b4 = PTR_DAT_00818340;

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

    cVar1 = FUN_005c9eb0(param_1[5]);

    if (cVar1 != '\0') {

      FUN_0046a740();

    }

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

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

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

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

    }

  }

  if (param_1[2] != 0) {

    local_b4 = PTR_DAT_00818340;

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

    cVar1 = FUN_005c9f50(param_1[5]);

    if (cVar1 != '\0') {

      FUN_0042dc80();

      FUN_0042cbe0(&local_b4);

      FUN_004618a0();

      (**(code **)(*(int *)param_1[2] + 0x110))();

      FUN_0042e590();

    }

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

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

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

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

    }

  }

  if (param_7 != '\0') {

    (**(code **)(*DAT_008f958c + 8))(9,param_1[5]);

    (**(code **)(*DAT_008f958c + 8))(9,param_1[6],param_1);

    piVar3 = (int *)FUN_00415730(1,2,0x10000003);

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

      local_b4 = (undefined *)0x1;

      iStack_b0 = 0;

      iStack_ac = 0;

      FUN_004f1e30(param_1[6],&stack0xffffff38);

      if (iStack_b0 != 0) {

        (**(code **)(*DAT_008f958c + 8))(9,iStack_b0,param_1);

      }

      if (iStack_ac != 0) {

        (**(code **)(*DAT_008f958c + 8))(9,iStack_ac,param_1);

      }

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

    }

  }

  return param_1;

}





// --- FUN_004f24e0 at 0x004F24E0 (size: 4) ---


undefined4 __fastcall FUN_004f24e0(int param_1)



{

  return *(undefined4 *)(param_1 + 0x18);

}





// --- FUN_004f24f0 at 0x004F24F0 (size: 30) ---


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



{

  FUN_004f1f70();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f2510 at 0x004F2510 (size: 85) ---


undefined4 __thiscall FUN_004f2510(int param_1,uint param_2)



{

  uint *puVar1;

  

  if ((*(uint *)(param_1 + 0x44) != 0) && (*(int *)(param_1 + 0x40) != 0)) {

    puVar1 = *(uint **)(*(int *)(param_1 + 0x40) + (param_2 % *(uint *)(param_1 + 0x44)) * 4);

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

      while (param_2 != *puVar1) {

        puVar1 = (uint *)puVar1[0x18];

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

          return 0;

        }

      }

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

        FUN_004f1fc0(puVar1 + 2);

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004f2c40 at 0x004F2C40 (size: 341) ---


undefined4 __thiscall FUN_004f2c40(int param_1,int *param_2)



{

  char cVar1;

  int *piVar2;

  LONG LVar3;

  int iVar4;

  undefined4 *puVar5;

  code *pcVar6;

  undefined *local_10;

  undefined *local_c;

  int local_8;

  int local_4;

  

  local_c = PTR_DAT_00818340;

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

  cVar1 = FUN_005c9c90(*(undefined4 *)(param_1 + 0x14),&local_c);

  pcVar6 = InterlockedDecrement_exref;

  if (cVar1 != '\0') {

    FUN_00402730(&DAT_0079d2e0);

    piVar2 = (int *)FUN_004086c0(&local_4,&local_8);

    iVar4 = *param_2;

    if (iVar4 != *piVar2) {

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

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

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

      }

      iVar4 = *piVar2;

      *param_2 = iVar4;

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

    }

    pcVar6 = InterlockedDecrement_exref;

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

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

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

    }

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

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

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

    }

  }

  local_10 = PTR_DAT_00818340;

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

  FUN_005c9d00(*(undefined4 *)(param_1 + 0x14),&local_10);

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

    FUN_00402490(local_10,*(int *)(local_10 + -4) + -1);

  }

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

  iVar4 = (*pcVar6)(local_10 + -0x10);

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

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

  }

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

  iVar4 = (*pcVar6)(local_10 + -0x10);

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

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

  }

  return 1;

}





// --- FUN_004f2da0 at 0x004F2DA0 (size: 586) ---


undefined4 * __thiscall

FUN_004f2da0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,undefined4 param_6,char param_7)



{

  int iVar1;

  char cVar2;

  LONG LVar3;

  int *piVar4;

  int *piVar5;

  undefined1 *puVar6;

  undefined *puVar7;

  int **ppiVar8;

  undefined4 uVar9;

  int *local_a4;

  int *piStack_a0;

  undefined4 uStack_9c;

  undefined1 auStack_98 [4];

  undefined1 auStack_94 [4];

  undefined1 auStack_90 [56];

  int iStack_58;

  int iStack_54;

  

  FUN_004f20b0(param_2,param_3,param_4,4,param_5,param_6);

  *param_1 = &PTR_FUN_007c4fa4;

  param_1[5] = param_5;

  param_1[6] = 0;

  if (param_1[3] != 0) {

    local_a4 = (int *)PTR_DAT_00818340;

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

    cVar2 = FUN_005c9920(param_1[5],&local_a4);

    if (cVar2 != '\0') {

      FUN_0046a740(&local_a4);

    }

    piVar4 = local_a4 + -5;

    LVar3 = InterlockedDecrement(local_a4 + -4);

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

      (**(code **)*piVar4)(1);

    }

  }

  if (param_1[2] != 0) {

    local_a4 = (int *)PTR_DAT_00818340;

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

    cVar2 = FUN_004f2c40(&local_a4);

    if (cVar2 != '\0') {

      FUN_0042dc80();

      FUN_0042cbe0(&local_a4,1);

      FUN_004618a0(auStack_90);

      (**(code **)(*(int *)param_1[2] + 0x110))(1);

      FUN_0042e590();

    }

    piVar4 = local_a4 + -5;

    LVar3 = InterlockedDecrement(local_a4 + -4);

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

      (**(code **)*piVar4)(1);

    }

  }

  if (param_7 != '\0') {

    (**(code **)(*DAT_008f958c + 8))(4,param_1[5],param_1);

    piVar4 = (int *)FUN_00415730(4,2,0x10000004);

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

      FUN_004f1ef0();

      FUN_004f2510(param_1[5],auStack_90);

      if (iStack_58 != 0) {

        (**(code **)(*DAT_008f958c + 8))(4,iStack_58,param_1);

      }

      if (iStack_54 != 0) {

        (**(code **)(*DAT_008f958c + 8))(4,iStack_54,param_1);

      }

      FUN_004f1f70();

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

    }

  }

  ppiVar8 = &local_a4;

  puVar6 = auStack_94;

  puVar7 = &DAT_007c4ddc;

  local_a4 = (int *)0x0;

  FUN_00406d10(puVar6,&DAT_007c4ddc,ppiVar8);

  FUN_00406570(puVar6,puVar7,ppiVar8);

  piVar4 = local_a4;

  uVar9 = 0;

  piStack_a0 = (int *)0x0;

  uStack_9c = 0;

  piVar5 = local_a4;

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

    (**(code **)(*local_a4 + 0x10))(local_a4,0);

  }

  piVar5 = (int *)FUN_0048bb00(auStack_98,piVar5,uVar9);

  iVar1 = *piVar5;

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

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

  }

  piVar4 = piStack_a0;

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

    if (-1 < iVar1) {

      FUN_00592b70(param_1[5],param_1 + 6);

    }

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

  }

  return param_1;

}





// --- FUN_004f2ff0 at 0x004F2FF0 (size: 169) ---


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



float10 __fastcall FUN_004f2ff0(int param_1)



{

  double dVar1;

  int iVar2;

  int iVar3;

  undefined **local_60;

  int local_5c;

  undefined4 local_58;

  undefined4 local_54;

  double local_38;

  double local_30;

  

  local_60 = &PTR_FUN_007b26fc;

  local_5c = 0;

  local_58 = 0;

  local_54 = 0;

  iVar2 = FUN_0058fd80(&local_60);

  iVar3 = local_5c;

  if (iVar2 != 0) {

    for (; iVar3 != 0; iVar3 = *(int *)(iVar3 + 0x50)) {

      if (*(uint *)(param_1 + 0x14) == (*(uint *)(iVar3 + 4) & 0xffff)) {

        FUN_004b8a00(iVar3);

        local_60 = &PTR_FUN_007b26fc;

        dVar1 = (local_38 + local_30) - _DAT_008379a8;

        FUN_004b86f0();

        return (float10)dVar1;

      }

    }

  }

  local_60 = &PTR_FUN_007b26fc;

  FUN_004b86f0();

  return (float10)_DAT_00795610;

}





// --- FUN_004f30a0 at 0x004F30A0 (size: 186) ---


undefined4 __thiscall FUN_004f30a0(int param_1,int *param_2)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  int local_8;

  undefined4 *local_4;

  

  iVar1 = FUN_00567c00();

  if (iVar1 == 0) {

    return 0;

  }

  piVar2 = (int *)FUN_00567ef0(&local_4,*(undefined4 *)(param_1 + 0x14));

  FUN_00404a40(0,*piVar2 + 0x14);

  LVar3 = InterlockedDecrement(local_4 + 1);

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

    (**(code **)*local_4)(1);

  }

  iVar1 = *param_2;

  if (iVar1 != local_8) {

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

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

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

    }

    *param_2 = local_8;

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

  }

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

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

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

  }

  return 1;

}





// --- FUN_004f31c0 at 0x004F31C0 (size: 236) ---


undefined4 * __thiscall

FUN_004f31c0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined *param_4)



{

  char cVar1;

  LONG LVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 *puVar6;

  undefined *puVar7;

  

  puVar7 = param_4;

  FUN_004f20b0(param_2,param_3,param_3,0,param_4,DAT_00841e74);

  *param_1 = &PTR_FUN_007c4fd4;

  param_1[5] = puVar7;

  if (param_1[3] != 0) {

    param_4 = PTR_DAT_00818340;

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

    cVar1 = FUN_004f30a0(&param_4);

    if (cVar1 != '\0') {

      FUN_0046a740(&param_4);

    }

    puVar6 = (undefined4 *)(param_4 + -0x14);

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

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

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

    }

  }

  iVar3 = FUN_00463c00(0x10000129);

  if (iVar3 != 0) {

    FUN_00567c00(puVar7);

    iVar3 = FUN_00569990(puVar7);

    if (iVar3 != 0) {

      FUN_006a0570(1);

      iVar4 = FUN_005df0f5(0xc);

      if (iVar4 != 0) {

        uVar5 = FUN_00694a00(iVar3);

        FUN_006a0610(uVar5);

        return param_1;

      }

      FUN_006a0610(0);

    }

  }

  return param_1;

}





// --- FUN_004f32b0 at 0x004F32B0 (size: 4) ---


undefined4 __fastcall FUN_004f32b0(int param_1)



{

  return *(undefined4 *)(param_1 + 0x14);

}





// --- FUN_004f32c0 at 0x004F32C0 (size: 30) ---


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



{

  FUN_004f1b00();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f32e0 at 0x004F32E0 (size: 52) ---


undefined4 * __thiscall FUN_004f32e0(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_004f3a00(param_2,param_3);

  *param_1 = &PTR_FUN_007c51f8;

  param_1[0x17c] = &PTR_FUN_007aa43c;

  param_1[0x180] = 0;

  return param_1;

}





// --- FUN_004f3320 at 0x004F3320 (size: 21) ---


void __fastcall FUN_004f3320(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c51f8;

  param_1[0x17c] = &PTR_FUN_007aa43c;

  FUN_004f3a50();

  return;

}





// --- FUN_004f3340 at 0x004F3340 (size: 46) ---


void __thiscall FUN_004f3340(int *param_1,undefined4 param_2)



{

  FUN_00463830(param_2);

  if ((char)param_2 != '\0') {

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

    return;

  }

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

  return;

}





// --- FUN_004f3370 at 0x004F3370 (size: 26) ---


void FUN_004f3370(void)



{

  FUN_0055e1d0();

  FUN_0059b670(0);

  FUN_004f38c0();

  return;

}





// --- FUN_004f3390 at 0x004F3390 (size: 29) ---


uint __fastcall FUN_004f3390(int param_1)



{

  uint in_EAX;

  int iVar1;

  

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

    iVar1 = FUN_0046f670(1,0);

    return (uint)(iVar1 != 0);

  }

  return in_EAX & 0xffffff00;

}





// --- FUN_004f33b0 at 0x004F33B0 (size: 114) ---


void FUN_004f33b0(int *param_1,undefined4 param_2,undefined4 param_3)



{

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  FUN_0042c9c0(param_2,0x10000003);

  FUN_0046a350(local_90);

  FUN_0042c9c0(param_3,0x10000003);

  (**(code **)(*param_1 + 0x2b4))(local_90);

  FUN_0042e590();

  return;

}





// --- FUN_004f3430 at 0x004F3430 (size: 124) ---


void FUN_004f3430(void)



{

  char cVar1;

  int *piVar2;

  int *piVar3;

  

  piVar2 = (int *)FUN_00463c00(0x100001fc);

  piVar3 = (int *)FUN_00463c00(0x100001fd);

  cVar1 = FUN_004f39c0();

  if (cVar1 == '\0') {

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

      (**(code **)(*piVar2 + 0x9c))(0xd);

    }

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

      (**(code **)(*piVar3 + 0x9c))(0xd);

    }

  }

  else {

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

      (**(code **)(*piVar2 + 0x9c))(1);

    }

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

      (**(code **)(*piVar3 + 0x9c))(1);

      return;

    }

  }

  return;

}





// --- FUN_004f34e0 at 0x004F34E0 (size: 46) ---


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



{

  *param_1 = &PTR_FUN_007c51f8;

  param_1[0x17c] = &PTR_FUN_007aa43c;

  FUN_004f3a50();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f3510 at 0x004F3510 (size: 127) ---


uint __fastcall FUN_004f3510(int param_1)



{

  char cVar1;

  uint in_EAX;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

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

    piVar2 = (int *)FUN_0046f670(0,0);

    in_EAX = 0;

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

      iVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

      in_EAX = 0;

      if (iVar3 != 0) {

        FUN_0042dc80();

        FUN_0042c9c0(unaff_retaddr,0x10000003);

        cVar1 = FUN_0042ce00(1);

        if (cVar1 != '\0') {

          FUN_0046a350(&stack0xffffff6c);

        }

        in_EAX = FUN_0042e590();

      }

    }

  }

  return in_EAX & 0xffffff00;

}





// --- FUN_004f3590 at 0x004F3590 (size: 93) ---


int __thiscall FUN_004f3590(int param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 unaff_retaddr;

  

  iVar2 = 0;

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

    piVar1 = (int *)FUN_0046f670(5,0);

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

      iVar2 = (**(code **)(*piVar1 + 0x94))(0x10000036);

      if (iVar2 == 0) {

        return 0;

      }

      iVar2 = iVar2 + -0x1c;

      if (iVar2 != 0) {

        FUN_00484b90(unaff_retaddr,param_2);

        FUN_004f3af0(iVar2);

      }

    }

  }

  return iVar2;

}





// --- FUN_004f35f0 at 0x004F35F0 (size: 104) ---


int __fastcall FUN_004f35f0(int param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  iVar3 = 0;

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

    iVar1 = FUN_0046f670(2,0);

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_00463c00(0x10000219);

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

        iVar3 = (**(code **)(*piVar2 + 0x94))(0x10000035);

        if (iVar3 == 0) {

          return 0;

        }

        iVar3 = iVar3 + -0x20;

        if (iVar3 != 0) {

          FUN_00486f50(unaff_retaddr);

          FUN_004f3af0(iVar3);

        }

      }

    }

  }

  return iVar3;

}





// --- FUN_004f3660 at 0x004F3660 (size: 104) ---


int __fastcall FUN_004f3660(int param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  iVar3 = 0;

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

    iVar1 = FUN_0046f670(2,0);

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_00463c00(0x10000219);

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

        iVar3 = (**(code **)(*piVar2 + 0x94))(0x10000035);

        if (iVar3 == 0) {

          return 0;

        }

        iVar3 = iVar3 + -0x20;

        if (iVar3 != 0) {

          FUN_00487240(unaff_retaddr);

          FUN_004f3af0(iVar3);

        }

      }

    }

  }

  return iVar3;

}





// --- FUN_004f36d0 at 0x004F36D0 (size: 117) ---


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



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  iVar3 = 0;

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

    iVar1 = FUN_0046f670((-(param_3 != '\0') & 3U) + 3,0);

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_00463c00(0x1000021c);

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

        iVar3 = (**(code **)(*piVar2 + 0x94))(0x10000037);

        if (iVar3 == 0) {

          return 0;

        }

        iVar3 = iVar3 + -0x20;

        if (iVar3 != 0) {

          FUN_00485090(unaff_retaddr);

          FUN_004f3af0(iVar3);

        }

      }

    }

  }

  return iVar3;

}





// --- FUN_004f3750 at 0x004F3750 (size: 139) ---


int __thiscall FUN_004f3750(int param_1,char param_2)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  iVar3 = 0;

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

    iVar1 = FUN_0046f670(4,0);

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_00463c00(0x10000224);

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

        iVar3 = (**(code **)(*piVar2 + 0x94))(0x10000038);

        if (iVar3 == 0) {

          return 0;

        }

        iVar3 = iVar3 + -0x20;

        if (iVar3 != 0) {

          if (param_2 != '\0') {

            FUN_00484740(unaff_retaddr);

            FUN_004f3af0(iVar3);

            return iVar3;

          }

          FUN_004845c0(unaff_retaddr);

          FUN_004f3af0(iVar3);

        }

      }

    }

  }

  return iVar3;

}





// --- FUN_004f37e0 at 0x004F37E0 (size: 217) ---


void FUN_004f37e0(int param_1,undefined4 param_2)



{

  int iVar1;

  int *piVar2;

  undefined1 auStack_90 [144];

  

  iVar1 = (**(code **)(*(int *)(param_1 + 0x20) + 0xa0))();

  if (iVar1 != 0) {

    piVar2 = (int *)FUN_00463c00(0x1000021e);

    if ((piVar2 != (int *)0x0) && (iVar1 = (**(code **)(*piVar2 + 0x94))(0xc), iVar1 != 0)) {

      FUN_0042dc80();

      FUN_0042c9c0(param_2,0x10000003);

      FUN_0046a350(auStack_90);

      FUN_0042e590();

    }

    piVar2 = (int *)FUN_00463c00(0x1000021f);

    if ((piVar2 != (int *)0x0) && (iVar1 = (**(code **)(*piVar2 + 0x94))(0xc), iVar1 != 0)) {

      FUN_0042dc80();

      FUN_0042c9c0(param_2,0x10000003);

      FUN_0046a350(&stack0xffffff6c);

      FUN_0042e590();

    }

  }

  return;

}





// --- FUN_004f38c0 at 0x004F38C0 (size: 75) ---


byte __fastcall FUN_004f38c0(int param_1)



{

  int *piVar1;

  byte bVar2;

  byte bVar3;

  uint uVar4;

  

  uVar4 = 0;

  bVar3 = 1;

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

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x5f4) + uVar4 * 4);

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

        bVar2 = (**(code **)(*piVar1 + 0x2c8))();

        bVar3 = bVar3 & bVar2;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0x5fc));

  }

  (*(code *)**(undefined4 **)(param_1 + 0x5f0))(0);

  return bVar3;

}





// --- FUN_004f3910 at 0x004F3910 (size: 75) ---


byte __fastcall FUN_004f3910(int param_1)



{

  int *piVar1;

  byte bVar2;

  byte bVar3;

  uint uVar4;

  

  uVar4 = 0;

  bVar3 = 1;

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

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x5f4) + uVar4 * 4);

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

        bVar2 = (**(code **)(*piVar1 + 0x2c4))();

        bVar3 = bVar3 & bVar2;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0x5fc));

  }

  (*(code *)**(undefined4 **)(param_1 + 0x5f0))(0);

  return bVar3;

}





// --- FUN_004f3960 at 0x004F3960 (size: 96) ---


byte __fastcall FUN_004f3960(int param_1)



{

  int *piVar1;

  char cVar2;

  byte bVar3;

  byte bVar4;

  uint uVar5;

  

  uVar5 = 0;

  bVar4 = 1;

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

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x5f4) + uVar5 * 4);

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

        cVar2 = (**(code **)(*piVar1 + 700))();

        if (cVar2 != '\0') {

          bVar3 = (**(code **)(**(int **)(*(int *)(param_1 + 0x5f4) + uVar5 * 4) + 0x2c0))();

          bVar4 = bVar4 & bVar3;

        }

      }

      uVar5 = uVar5 + 1;

    } while (uVar5 < *(uint *)(param_1 + 0x5fc));

  }

  (*(code *)**(undefined4 **)(param_1 + 0x5f0))(0);

  return bVar4;

}





// --- FUN_004f39c0 at 0x004F39C0 (size: 62) ---


undefined4 __fastcall FUN_004f39c0(int param_1)



{

  int *piVar1;

  char cVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x5f4) + uVar3 * 4);

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

        cVar2 = (**(code **)(*piVar1 + 700))();

        if (cVar2 != '\0') {

          return 1;

        }

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 0x5fc));

  }

  return 0;

}





// --- FUN_004f3a00 at 0x004F3A00 (size: 72) ---


undefined4 * __thiscall FUN_004f3a00(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00464900(param_2,param_3);

  param_1[0x17c] = &PTR_LAB_007c538c;

  *param_1 = &PTR_FUN_007c5398;

  param_1[0x17c] = &PTR_LAB_007c538c;

  param_1[0x17d] = 0;

  param_1[0x17e] = 0;

  param_1[0x17f] = 0;

  return param_1;

}





// --- FUN_004f3a50 at 0x004F3A50 (size: 60) ---


void __fastcall FUN_004f3a50(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c5398;

  param_1[0x17c] = &PTR_LAB_007c538c;

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

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

  }

  FUN_00464e00();

  return;

}





// --- FUN_004f3a90 at 0x004F3A90 (size: 81) ---


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



{

  *param_1 = &PTR_FUN_007c5398;

  param_1[0x17c] = &PTR_LAB_007c538c;

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

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

  }

  FUN_00464e00();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f3af0 at 0x004F3AF0 (size: 117) ---


void __thiscall FUN_004f3af0(int param_1,int *param_2)



{

  char cVar1;

  uint uVar2;

  undefined4 uVar3;

  

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

    return;

  }

  uVar2 = *(uint *)(param_1 + 0x5f8) & 0x7fffffff;

  if (uVar2 <= *(uint *)(param_1 + 0x5fc)) {

    uVar3 = FUN_00453850(uVar2 + 1);

    cVar1 = FUN_004180a0(uVar3);

    if (cVar1 == '\0') goto LAB_004f3b38;

  }

  *(int **)(*(int *)(param_1 + 0x5f4) + *(int *)(param_1 + 0x5fc) * 4) = param_2;

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

LAB_004f3b38:

  if (param_1 == 0) {

    (**(code **)(*param_2 + 0x2cc))(0);

    return;

  }

  (**(code **)(*param_2 + 0x2cc))(param_1 + 0x5f0);

  return;

}





// --- FUN_004f3b70 at 0x004F3B70 (size: 57) ---


undefined4 __fastcall FUN_004f3b70(int param_1)



{

  undefined8 uVar1;

  

  uVar1 = __allshl();

  if (((*(uint *)(param_1 + 0x618) & (uint)uVar1) == 0) &&

     ((*(uint *)(param_1 + 0x61c) & (uint)((ulonglong)uVar1 >> 0x20)) == 0)) {

    return 0;

  }

  return 1;

}





// --- FUN_004f3bf0 at 0x004F3BF0 (size: 43) ---


void __fastcall FUN_004f3bf0(int param_1)



{

  (**(code **)(**(int **)(param_1 + 0x60c) + 0xfc))();

  (**(code **)(**(int **)(param_1 + 0x60c) + 0x104))();

  FUN_0047a600(1);

  return;

}





// --- FUN_004f3c20 at 0x004F3C20 (size: 43) ---


void __fastcall FUN_004f3c20(int param_1)



{

  (**(code **)(**(int **)(param_1 + 0x60c) + 0x108))();

  (**(code **)(**(int **)(param_1 + 0x60c) + 0x100))();

  FUN_0047a600(0);

  return;

}





// --- FUN_004f3c50 at 0x004F3C50 (size: 170) ---


void __thiscall FUN_004f3c50(int param_1,int param_2)



{

  char cVar1;

  undefined1 local_90 [4];

  undefined4 local_8c;

  

  FUN_0042dc80();

  local_8c = DAT_00842194;

  if (param_2 != 0x10000028) {

    local_8c = DAT_00842198;

  }

  FUN_0042c980(6);

  cVar1 = FUN_0042ce00(1);

  if ((cVar1 != '\0') && (*(int **)(param_1 + 0x60c) != (int *)0x0)) {

    (**(code **)(**(int **)(param_1 + 0x60c) + 0xfc))();

    (**(code **)(**(int **)(param_1 + 0x60c) + 0x104))();

    FUN_0047a600(1);

    FUN_0046a350(local_90);

    FUN_00467bc0();

    FUN_00469100();

  }

  FUN_0042e590();

  return;

}





// --- FUN_004f3d00 at 0x004F3D00 (size: 56) ---


undefined4 __fastcall FUN_004f3d00(int param_1)



{

  int iVar1;

  int iVar2;

  

  iVar2 = *(int *)(DAT_0083e03c + 0x32c);

  if (iVar2 != 0) {

    iVar1 = FUN_0045fb30();

    if (iVar2 == iVar1) {

      iVar2 = FUN_00460330();

      if (iVar2 == *(int *)(param_1 + 0x60c)) {

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004f3d40 at 0x004F3D40 (size: 61) ---


void __thiscall FUN_004f3d40(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = FUN_00429a00();

  if (((iVar1 == 0x1000007f) && (param_3 == *(int *)(param_1 + 0x5fc))) &&

     (*(int **)(param_2 + 4) != (int *)0x0)) {

    (**(code **)(**(int **)(param_2 + 4) + 0xe8))(param_1 + 0x618);

  }

  return;

}





// --- FUN_004f3d80 at 0x004F3D80 (size: 60) ---


void __thiscall FUN_004f3d80(int param_1,undefined4 param_2)



{

  int *piVar1;

  

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

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

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

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

      return;

    }

    piVar1 = (int *)FUN_004592b0();

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

      return;

    }

  }

  piVar1 = (int *)(**(code **)(*piVar1 + 0x1c))();

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

    return;

  }

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

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*piVar1 + 0x48))();

  return;

}





// --- FUN_004f3e20 at 0x004F3E20 (size: 1659) ---


void __fastcall FUN_004f3e20(int param_1)



{

  int iVar1;

  undefined4 *puStack_1c;

  undefined4 *local_18;

  int *local_14;

  undefined4 *local_10;

  int *local_c;

  

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

    local_18 = (undefined4 *)0x0;

    local_14 = (int *)0x0;

    FUN_0042a2d0(0x1b);

    local_10 = (undefined4 *)0x0;

    local_c = (int *)0x0;

    FUN_0042a2d0(0x19);

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d588);

    }

    iVar1 = 0x22;

    do {

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xfc))(&local_10);

      }

      iVar1 = iVar1 + -1;

    } while (iVar1 != 0);

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d4c8);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(2,&local_10);

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d568);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0xc,&local_10);

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d4d8);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(3,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(0x1f,&local_10);

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

          FUN_00429b10();

          (**(code **)(*local_14 + 0xf8))(10,&local_10);

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

            FUN_00429b10();

            (**(code **)(*local_14 + 0xf8))(0x13,&local_10);

          }

        }

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d4e8);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(4,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(0xb,&local_10);

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d538);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(8,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(9,&local_10);

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d578);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0x12,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(0x21,&local_10);

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d558);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0x1b,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(0x1c,&local_10);

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

          FUN_00429b10();

          (**(code **)(*local_14 + 0xf8))(0x1d,&local_10);

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

            FUN_00429b10();

            (**(code **)(*local_14 + 0xf8))(0x1e,&local_10);

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

              FUN_00429b10();

              (**(code **)(*local_14 + 0xf8))(0x20,&local_10);

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

                FUN_00429b10();

                (**(code **)(*local_14 + 0xf8))(0xe,&local_10);

              }

            }

          }

        }

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d508);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0xf,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(6,&local_10);

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

          FUN_00429b10();

          (**(code **)(*local_14 + 0xf8))(0x15,&local_10);

        }

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d518);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0x16,&local_10);

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d528);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(7,&local_10);

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

        FUN_00429b10();

        (**(code **)(*local_14 + 0xf8))(0x11,&local_10);

      }

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d548);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0xd,&local_10);

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d4f8);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(5,&local_10);

    }

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

      FUN_00429b10();

      (**(code **)(*local_c + 0x9c))(&DAT_0081d4b8);

    }

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0xf8))(0x1a,&local_10);

    }

    (**(code **)(**(int **)(param_1 + 0x610) + 0xd4))(&local_18);

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

      iVar1 = local_14[1];

      local_14[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_14)(1);

      }

      local_14 = (int *)0x0;

    }

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

      iVar1 = local_10[1];

      local_10[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_10)(1);

      }

      local_10 = (undefined4 *)0x0;

    }

    if ((puStack_1c != (undefined4 *)0x0) &&

       (iVar1 = puStack_1c[1], puStack_1c[1] = iVar1 + -1, iVar1 + -1 == 0)) {

      (**(code **)*puStack_1c)(1);

    }

    if ((local_18 != (undefined4 *)0x0) &&

       (iVar1 = local_18[1], local_18[1] = iVar1 + -1, iVar1 + -1 == 0)) {

      (**(code **)*local_18)(1);

    }

  }

  return;

}





// --- FUN_004f44a0 at 0x004F44A0 (size: 222) ---


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



void __thiscall FUN_004f44a0(int param_1,int param_2)



{

  undefined4 uVar1;

  float fVar2;

  bool bVar3;

  char cVar4;

  int *piVar5;

  

  if (param_2 != 3) {

    return;

  }

  if ((*(uint *)(param_1 + 0xa4) >> 4 & 1) == 0) {

    cVar4 = FUN_004f3d00();

    bVar3 = false;

    if (cVar4 != '\0') goto LAB_004f44c7;

  }

  else {

LAB_004f44c7:

    bVar3 = true;

  }

  fVar2 = ABS(*(float *)(param_1 + 0x600) - *(float *)(param_1 + 0x5fc)) * _DAT_007c56dc;

  if (bVar3) {

    fVar2 = fVar2 + *(float *)(param_1 + 0x604);

    *(float *)(param_1 + 0x604) = fVar2;

    if (fVar2 < *(float *)(param_1 + 0x600)) goto LAB_004f4536;

    *(undefined4 *)(param_1 + 0x604) = *(undefined4 *)(param_1 + 0x600);

  }

  else {

    fVar2 = *(float *)(param_1 + 0x604) - fVar2;

    *(float *)(param_1 + 0x604) = fVar2;

    if (fVar2 < *(float *)(param_1 + 0x5fc) == (fVar2 == *(float *)(param_1 + 0x5fc)))

    goto LAB_004f4536;

    *(undefined4 *)(param_1 + 0x604) = *(undefined4 *)(param_1 + 0x5fc);

  }

  FUN_00465fb0(3);

LAB_004f4536:

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

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

  piVar5 = *(int **)(param_1 + 0xb0);

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

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

      return;

    }

    piVar5 = (int *)FUN_004592b0();

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

      return;

    }

  }

  piVar5 = (int *)(**(code **)(*piVar5 + 0x1c))();

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

    (**(code **)(*piVar5 + 0x48))(uVar1);

  }

  return;

}





// --- FUN_004f4580 at 0x004F4580 (size: 183) ---


void __fastcall FUN_004f4580(int param_1)



{

  char cVar1;

  int iVar2;

  undefined4 *local_8;

  int *local_4;

  

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

    iVar2 = FUN_0055e1d0();

    if (iVar2 != 0) {

      FUN_0055e1d0();

      local_8 = (undefined4 *)0x0;

      local_4 = (int *)0x0;

      cVar1 = FUN_005d6690(*(undefined4 *)(param_1 + 0x5fc),0x1000007f,&local_8);

      if ((cVar1 != '\0') && (local_4 != (int *)0x0)) {

        (**(code **)(*local_4 + 0xe8))(param_1 + 0x618);

      }

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

        iVar2 = local_8[1];

        local_8[1] = iVar2 + -1;

        if (iVar2 + -1 == 0) {

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

        }

        local_8 = (undefined4 *)0x0;

      }

      if ((local_4 != (int *)0x0) && (iVar2 = local_4[1], local_4[1] = iVar2 + -1, iVar2 + -1 == 0))

      {

        (**(code **)*local_4)(1);

      }

    }

  }

  return;

}





// --- FUN_004f4640 at 0x004F4640 (size: 67) ---


void __thiscall FUN_004f4640(int param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  

  cVar1 = '\0';

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

    cVar1 = FUN_004695e0();

  }

  FUN_00463d60(param_2,param_3);

  if (cVar1 != '\0') {

    FUN_00469440(*(undefined4 *)(*(int *)(param_1 + 0x60c) + 0x61c));

  }

  return;

}





// --- FUN_004f4690 at 0x004F4690 (size: 251) ---


void __thiscall FUN_004f4690(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  char cVar3;

  LONG LVar4;

  undefined4 *puVar5;

  

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

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

    if (uVar1 == 0xffffffff) {

      puVar5 = &DAT_0083774c;

      FUN_00466830(&param_2);

      cVar3 = FUN_00494e10(puVar5);

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

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

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

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

      }

      if (cVar3 == '\0') {

        return;

      }

      FUN_0046a740(&DAT_0083774c);

      return;

    }

    *(uint *)(param_1 + 0x630) = uVar1 + 1;

    if (*(uint *)(param_1 + 0x62c) <= uVar1 + 1) {

      FUN_0046a740(&DAT_0083774c);

      *(undefined4 *)(param_1 + 0x630) = 0xffffffff;

      return;

    }

  }

  else {

    uVar2 = *(uint *)(param_1 + 0x62c);

    if (uVar1 < uVar2) {

      if (uVar1 == 0) {

        return;

      }

      *(uint *)(param_1 + 0x630) = uVar1 - 1;

    }

    else {

      if (uVar2 == 0) {

        return;

      }

      *(uint *)(param_1 + 0x630) = uVar2 - 1;

    }

  }

  FUN_0046a740(*(int *)(param_1 + 0x624) + *(int *)(param_1 + 0x630) * 4);

  param_2 = *(undefined4 *)(*(int *)(param_1 + 0x60c) + 0x61c);

  FUN_00469440();

  return;

}





// --- FUN_004f4790 at 0x004F4790 (size: 133) ---


undefined4 __fastcall FUN_004f4790(int param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  int *piVar4;

  

  iVar1 = *(int *)(DAT_0083e03c + 0x32c);

  if (iVar1 != 0) {

    iVar3 = FUN_0045fb30();

    if (iVar1 == iVar3) {

      piVar2 = *(int **)(param_1 + 0x60c);

      piVar4 = (int *)FUN_00460330();

      if (piVar4 == piVar2) {

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

        (**(code **)(**(int **)(param_1 + 0x60c) + 0x100))();

        FUN_0047a600(0);

        return 1;

      }

    }

  }

  (**(code **)(**(int **)(param_1 + 0x60c) + 0xfc))();

  (**(code **)(**(int **)(param_1 + 0x60c) + 0x104))();

  FUN_0047a600(1);

  return 1;

}





// --- FUN_004f4820 at 0x004F4820 (size: 118) ---


void __thiscall FUN_004f4820(int param_1,float param_2)



{

  int iVar1;

  int iVar2;

  

  *(float *)(param_1 + 0x600) = param_2;

  if (*(float *)(param_1 + 0x604) < param_2) {

    FUN_004f48a0(param_2);

  }

  if (((*(uint *)(param_1 + 0xa8) >> 4 & 1) == 0) &&

     (((iVar2 = *(int *)(DAT_0083e03c + 0x32c), iVar2 == 0 ||

       (iVar1 = FUN_0045fb30(), iVar2 != iVar1)) ||

      (iVar2 = FUN_00460330(), iVar2 != *(int *)(param_1 + 0x60c))))) {

    FUN_004f3d80(*(undefined4 *)(param_1 + 0x600));

  }

  return;

}





// --- FUN_004f48a0 at 0x004F48A0 (size: 177) ---


void __thiscall FUN_004f48a0(int param_1,float param_2)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  

  *(float *)(param_1 + 0x604) = param_2;

  if (param_2 < *(float *)(param_1 + 0x600)) {

    FUN_004f4820(param_2);

  }

  if ((*(uint *)(param_1 + 0xa8) >> 4 & 1) == 0) {

    iVar2 = *(int *)(DAT_0083e03c + 0x32c);

    if (iVar2 == 0) {

      return;

    }

    iVar1 = FUN_0045fb30();

    if (iVar2 != iVar1) {

      return;

    }

    iVar2 = FUN_00460330();

    if (iVar2 != *(int *)(param_1 + 0x60c)) {

      return;

    }

  }

  *(undefined4 *)(param_1 + 0x608) = *(undefined4 *)(param_1 + 0x604);

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

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

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

      return;

    }

    piVar3 = (int *)FUN_004592b0();

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

      return;

    }

  }

  piVar3 = (int *)(**(code **)(*piVar3 + 0x1c))();

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

    return;

  }

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

                    /* WARNING: Treating indirect jump as call */

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

  return;

}





// --- FUN_004f4960 at 0x004F4960 (size: 208) ---


undefined4 __thiscall FUN_004f4960(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  undefined *puVar3;

  undefined *puVar4;

  int iVar5;

  LONG LVar6;

  int *piVar7;

  

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

    return 0;

  }

  iVar1 = *param_1;

  iVar5 = param_1[2] - 1;

  param_1[2] = iVar5;

  puVar4 = PTR_DAT_00818340;

  for (piVar7 = (int *)(iVar1 + param_2 * 4); PTR_DAT_00818340 = puVar4,

      piVar7 < (int *)(iVar1 + iVar5 * 4); piVar7 = piVar7 + 1) {

    iVar2 = *piVar7;

    if (iVar2 != piVar7[1]) {

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

      if ((LVar6 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

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

      }

      *piVar7 = piVar7[1];

      InterlockedIncrement((LONG *)(piVar7[1] + -0x10));

    }

    puVar4 = PTR_DAT_00818340;

  }

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

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

  puVar3 = (undefined *)*piVar7;

  if (puVar3 != puVar4) {

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

    if ((LVar6 == 0) && ((undefined4 *)(puVar3 + -0x14) != (undefined4 *)0x0)) {

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

    }

    *piVar7 = (int)puVar4;

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

  }

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

  if ((LVar6 == 0) && ((undefined4 *)(puVar4 + -0x14) != (undefined4 *)0x0)) {

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

  }

  return 1;

}





// --- FUN_004f4a30 at 0x004F4A30 (size: 365) ---


void __fastcall FUN_004f4a30(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  

  FUN_004639a0();

  FUN_00460990(0x1000007e,(undefined4 *)(param_1 + 0x5f8));

  switch(*(undefined4 *)(param_1 + 0x5f8)) {

  case 1:

  case 8:

    *(undefined4 *)(param_1 + 0x614) = 0xfbffffff;

    break;

  case 2:

    *(undefined4 *)(param_1 + 0x614) = 0x101c;

    break;

  case 3:

    *(undefined4 *)(param_1 + 0x614) = 0x40c00;

    break;

  case 4:

    *(undefined4 *)(param_1 + 0x614) = 0x80000;

    break;

  case 5:

    *(undefined4 *)(param_1 + 0x614) = 0x78000000;

    break;

  default:

    goto switchD_004f4a59_caseD_6;

  }

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

switchD_004f4a59_caseD_6:

  piVar2 = (int *)FUN_00463c00(0x10000011);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  uVar3 = FUN_00463c00(0x1000048c);

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

  piVar2 = (int *)FUN_00463c00(0x10000016);

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

    uVar3 = 0;

  }

  else {

    uVar3 = (**(code **)(*piVar2 + 0x94))(0xc);

  }

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

  piVar2 = (int *)FUN_0043c680();

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

    iVar1 = param_1 + -4;

    (**(code **)(*piVar2 + 4))(0x186b6,iVar1);

    (**(code **)(*piVar2 + 4))(0x4dd252,iVar1);

    (**(code **)(*piVar2 + 4))(0x4dd267,iVar1);

    (**(code **)(*piVar2 + 4))(0x4dd26e,iVar1);

    (**(code **)(*piVar2 + 4))(0x4dd1f0,iVar1);

  }

  FUN_00465f90(1);

  piVar2 = (int *)FUN_0056f230();

  *(int **)(param_1 + 0x630) = piVar2;

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

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

  }

  FUN_004f3e20();

  (**(code **)(*(int *)(param_1 + -4) + 0x224))(DAT_0081820c,DAT_00818210);

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

                    /* WARNING: Treating indirect jump as call */

  (**(code **)(*(int *)(param_1 + -4) + 0x2a8))();

  return;

}





// --- FUN_004f4c40 at 0x004F4C40 (size: 156) ---


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



{

  int iVar1;

  undefined *puVar2;

  LONG LVar3;

  uint uVar4;

  

  puVar2 = PTR_DAT_00818340;

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

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

  uVar4 = iVar1 - 1;

  if (param_3 < uVar4) {

    if (uVar4 <= param_4) {

      param_4 = iVar1 - 2;

    }

    FUN_00402490(*param_1 + param_3 * 2,(param_4 - param_3) + 1);

    *param_2 = puVar2;

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

  }

  else {

    *param_2 = puVar2;

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

  }

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

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

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

  }

  return param_2;

}





// --- FUN_004f4ce0 at 0x004F4CE0 (size: 215) ---


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



{

  char cVar1;

  short sVar2;

  int iVar3;

  undefined4 uVar4;

  uint uVar5;

  undefined4 uVar6;

  

  if (param_3 == '\0') {

    iVar3 = param_1[1];

    uVar4 = (**(code **)(*param_1 + 8))(iVar3,0);

    cVar1 = FUN_0040b620(uVar4,iVar3);

    while( true ) {

      if (cVar1 != '\0') {

        return 1;

      }

      iVar3 = param_1[1];

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

      if (uVar5 < iVar3 + 1U) {

        iVar3 = (**(code **)*param_1)();

        param_1[1] = iVar3;

      }

      else {

        param_1[1] = iVar3 + 1U;

      }

      iVar3 = param_1[1];

      sVar2 = (**(code **)(*param_1 + 8))(iVar3);

      if (sVar2 == 0) break;

      uVar4 = (**(code **)(*param_1 + 8))(param_1[1],0);

      cVar1 = FUN_0040b620(uVar4,iVar3);

    }

  }

  else {

    while (param_1[1] != 0) {

      iVar3 = param_1[1] + -1;

      uVar6 = 0;

      param_1[1] = iVar3;

      uVar4 = (**(code **)(*param_1 + 8))(iVar3,0);

      cVar1 = FUN_0040b620(uVar4,uVar6);

      if (cVar1 != '\0') {

        return 1;

      }

    }

    param_1[1] = 0;

  }

  return 0;

}





// --- FUN_004f4dc0 at 0x004F4DC0 (size: 134) ---


void __fastcall FUN_004f4dc0(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + -1;

  *puVar1 = &PTR_FUN_007c5818;

  *param_1 = &PTR_FUN_007c56e0;

  FUN_00465fb0(1);

  piVar2 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

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

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

    param_1[0x18c] = 0;

  }

  if (((param_1[0x189] & 0x80000000) == 0x80000000) && (param_1[0x188] != 0)) {

    FUN_00407920(3);

  }

  FUN_004726c0();

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_004f4e50 at 0x004F4E50 (size: 151) ---


void __thiscall FUN_004f4e50(int param_1,undefined4 *param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  FUN_00480980(&param_2,0,L"@tell %s, ",*param_2);

  (**(code **)(**(int **)(param_1 + 0x60c) + 0xfc))();

  (**(code **)(**(int **)(param_1 + 0x60c) + 0x104))();

  FUN_0047a600(1);

  FUN_0046a740(&param_2);

  FUN_00469120(param_2[-1]);

  FUN_00466540();

  puVar2 = param_2 + -5;

  LVar1 = InterlockedDecrement(param_2 + -4);

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

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

  }

  return;

}





// --- FUN_004f4ef0 at 0x004F4EF0 (size: 462) ---


void __thiscall FUN_004f4ef0(int param_1,uint param_2)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  undefined4 *puVar4;

  int local_18;

  int local_14;

  undefined **local_10;

  int local_c;

  undefined4 local_8;

  int *local_4;

  

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

    local_14 = param_1;

    FUN_00466830(&local_18);

    if (param_2 < *(uint *)(local_18 + -4)) {

      iVar2 = *(uint *)(local_18 + -4) - param_2;

      local_4 = &local_18;

      local_10 = &PTR_FUN_0079549c;

      local_8 = 0;

      local_c = 0;

      if (iVar2 != 0) {

        FUN_0040b150(iVar2);

      }

      FUN_00402730(&DAT_0079d2e0);

      cVar1 = FUN_004f4ce0(&param_2,1);

      puVar4 = (undefined4 *)(param_2 - 0x14);

      LVar3 = InterlockedDecrement((LONG *)(param_2 - 0x10));

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

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

      }

      if ((cVar1 == '\0') || (*(uint *)(local_18 + -4) / 10 <= (uint)(iVar2 - local_c))) {

        local_c = 0;

        if (iVar2 != 0) {

          FUN_0040b150(iVar2);

        }

        FUN_00402730(&DAT_0079d2e0);

        cVar1 = FUN_004f4ce0(&param_2,0);

        puVar4 = (undefined4 *)(param_2 - 0x14);

        LVar3 = InterlockedDecrement((LONG *)(param_2 - 0x10));

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

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

        }

        if ((cVar1 == '\0') || (*(uint *)(local_18 + -4) / 10 <= (uint)(local_c - iVar2))) {

          FUN_00469c00(iVar2,1);

          local_10 = &PTR_LAB_00795478;

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

          if (LVar3 != 0) {

            return;

          }

          if ((undefined4 *)(local_18 + -0x14) == (undefined4 *)0x0) {

            return;

          }

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

          return;

        }

      }

      FUN_00469c00(local_c + 1,1);

      local_10 = &PTR_LAB_00795478;

      FUN_004011b0();

      return;

    }

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

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

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

    }

  }

  return;

}





// --- FUN_004f51b0 at 0x004F51B0 (size: 182) ---


undefined4 * __thiscall FUN_004f51b0(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  *param_1 = &PTR_FUN_007ccb60;

  FUN_00472670(param_2,param_3);

  param_1[0x17f] = 0;

  param_1[0x183] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  param_1[0x188] = 0;

  *param_1 = &PTR_FUN_007c5818;

  param_1[1] = &PTR_FUN_007c56e0;

  param_1[0x180] = 0x3f000000;

  param_1[0x182] = 0x3f000000;

  param_1[0x181] = 0x3f800000;

  param_1[0x186] = 0xffffffff;

  param_1[0x187] = 0xffffffff;

  param_1[0x189] = 0;

  param_1[0x18a] = 0;

  param_1[0x18b] = 0;

  param_1[0x18d] = 0;

  param_1[0x18c] = 0xffffffff;

  param_1[0x186] = param_1[0x186] & 0xfbffffff;

  param_1[0x187] = param_1[0x187];

  return param_1;

}





// --- FUN_004f5270 at 0x004F5270 (size: 34) ---


int __thiscall FUN_004f5270(int param_1,byte param_2)



{

  FUN_004f4dc0();

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

    operator_delete((void *)(param_1 + -4));

  }

  return param_1 + -4;

}





// --- FUN_004f53c0 at 0x004F53C0 (size: 1030) ---


uint FUN_004f53c0(void)



{

  char cVar1;

  int *piVar2;

  uint uVar3;

  LONG LVar4;

  undefined4 *puVar5;

  int iVar6;

  short *psVar7;

  wchar_t *pwVar8;

  short *local_24;

  int iStack_20;

  wchar_t *local_1c;

  int aiStack_18 [2];

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  short **ppsStack_4;

  

  piVar2 = (int *)FUN_0058a380(&local_1c);

  iVar6 = *(int *)(*piVar2 + -4);

  pwVar8 = local_1c + -10;

  uVar3 = InterlockedDecrement((LONG *)(local_1c + -8));

  if ((uVar3 == 0) && (pwVar8 != (wchar_t *)0x0)) {

    uVar3 = (*(code *)**(undefined4 **)pwVar8)(1);

  }

  if (iVar6 != 1) {

    FUN_00466830(&local_24);

    iVar6 = DAT_00837750;

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

    FUN_004d68c0(1,0,iVar6);

    iVar6 = *(int *)(local_24 + -2);

    psVar7 = local_24 + iVar6 + -1;

    if (iVar6 != 0) {

      psVar7 = local_24;

    }

    if (*psVar7 != 0x2f) {

      psVar7 = local_24 + iVar6 + -1;

      if (iVar6 != 0) {

        psVar7 = local_24;

      }

      if (*psVar7 != 0x40) {

        uVar3 = InterlockedDecrement((LONG *)(local_24 + -8));

        if ((uVar3 == 0) && (local_24 + -10 != (short *)0x0)) {

          uVar3 = (*(code *)**(undefined4 **)(local_24 + -10))(1);

          return uVar3 & 0xffffff00;

        }

        goto LAB_004f57bc;

      }

    }

    piVar2 = (int *)FUN_004f4c40(&local_1c,1,*(undefined4 *)(local_24 + -2));

    if (local_24 != (short *)*piVar2) {

      LVar4 = InterlockedDecrement((LONG *)(local_24 + -8));

      if ((LVar4 == 0) && (local_24 + -10 != (short *)0x0)) {

        (*(code *)**(undefined4 **)(local_24 + -10))(1);

      }

      local_24 = (short *)*piVar2;

      InterlockedIncrement((LONG *)(local_24 + -8));

    }

    pwVar8 = local_1c + -10;

    LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

    if ((LVar4 == 0) && (pwVar8 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)pwVar8)(1);

    }

    ppsStack_4 = &local_24;

    ppuStack_10 = &PTR_FUN_0079549c;

    uStack_c = 0;

    uStack_8 = 0;

    FUN_00402730(&DAT_007c5b18);

    puVar5 = (undefined4 *)FUN_004f4c40(aiStack_18,0,1);

    iVar6 = _wcsicmp((wchar_t *)*puVar5,local_1c);

    puVar5 = (undefined4 *)(aiStack_18[0] + -0x14);

    LVar4 = InterlockedDecrement((LONG *)(aiStack_18[0] + -0x10));

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

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

    }

    pwVar8 = local_1c + -10;

    LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

    if ((LVar4 == 0) && (pwVar8 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)pwVar8)(1);

    }

    if (iVar6 == 0) {

      iVar6 = (*(code *)*ppuStack_10)();

      if (iVar6 == 0) {

        uStack_8 = (*(code *)*ppuStack_10)();

      }

      else {

        uStack_8 = 1;

      }

    }

    else {

      FUN_00402730(&DAT_007c5b10);

      puVar5 = (undefined4 *)FUN_004f4c40(aiStack_18,0,2);

      iVar6 = _wcsicmp((wchar_t *)*puVar5,local_1c);

      puVar5 = (undefined4 *)(aiStack_18[0] + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(aiStack_18[0] + -0x10));

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

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

      }

      pwVar8 = local_1c + -10;

      LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

      if ((LVar4 == 0) && (pwVar8 != (wchar_t *)0x0)) {

        (*(code *)**(undefined4 **)pwVar8)(1);

      }

      if (iVar6 == 0) {

        uVar3 = (*(code *)*ppuStack_10)();

        if (uVar3 < 2) {

          uStack_8 = (*(code *)*ppuStack_10)();

        }

        else {

          uStack_8 = 2;

        }

      }

      else {

        FUN_00402730(L"reply ");

        puVar5 = (undefined4 *)FUN_004f4c40(aiStack_18,0,5);

        iVar6 = _wcsicmp((wchar_t *)*puVar5,local_1c);

        puVar5 = (undefined4 *)(aiStack_18[0] + -0x14);

        LVar4 = InterlockedDecrement((LONG *)(aiStack_18[0] + -0x10));

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

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

        }

        LVar4 = InterlockedDecrement((LONG *)(local_1c + -8));

        if ((LVar4 == 0) && (local_1c + -10 != (wchar_t *)0x0)) {

          (*(code *)**(undefined4 **)(local_1c + -10))(1);

        }

        if (iVar6 != 0) {

          ppuStack_10 = &PTR_LAB_00795478;

          uVar3 = FUN_004011b0();

          goto LAB_004f57bc;

        }

        FUN_0040b1b0(5);

      }

    }

    puVar5 = (undefined4 *)FUN_0058a380(aiStack_18);

    FUN_00480980(&iStack_20,0,L"@tell %hs,",*puVar5);

    LVar4 = InterlockedDecrement((LONG *)(aiStack_18[0] + -0x10));

    if ((LVar4 == 0) && ((undefined4 *)(aiStack_18[0] + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(aiStack_18[0] + -0x14))(1);

    }

    cVar1 = FUN_0040bdf0(&iStack_20);

    if (cVar1 != '\0') {

      FUN_0046a740(&local_24);

      FUN_00469120(*(undefined4 *)(iStack_20 + -4));

      FUN_00466540();

    }

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

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

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

    }

    psVar7 = local_24 + -10;

    ppuStack_10 = &PTR_LAB_00795478;

    uVar3 = InterlockedDecrement((LONG *)(local_24 + -8));

    if ((uVar3 == 0) && (psVar7 != (short *)0x0)) {

      uVar3 = (*(code *)**(undefined4 **)psVar7)(1);

      return uVar3 & 0xffffff00;

    }

  }

LAB_004f57bc:

  return uVar3 & 0xffffff00;

}





// --- FUN_004f57d0 at 0x004F57D0 (size: 684) ---


uint FUN_004f57d0(void)



{

  short *psVar1;

  char cVar2;

  int *piVar3;

  uint uVar4;

  LONG LVar5;

  undefined4 *puVar6;

  int iVar7;

  short *psVar8;

  wchar_t *pwVar9;

  short *local_24;

  int iStack_20;

  wchar_t *local_1c;

  undefined4 *apuStack_18 [2];

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  short **ppsStack_4;

  

  piVar3 = (int *)FUN_0058a440(&local_1c);

  pwVar9 = local_1c;

  iVar7 = *(int *)(*piVar3 + 8);

  uVar4 = InterlockedDecrement((LONG *)(local_1c + 2));

  if ((uVar4 == 0) && (pwVar9 != (wchar_t *)0x0)) {

    uVar4 = (*(code *)**(undefined4 **)pwVar9)(1);

  }

  if (iVar7 == 1) goto LAB_004f5a72;

  FUN_00466830(&local_24);

  iVar7 = DAT_00837750;

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

  FUN_004d68c0(1,0,iVar7);

  psVar1 = local_24;

  iVar7 = *(int *)(local_24 + -2);

  psVar8 = local_24 + iVar7 + -1;

  if (iVar7 != 0) {

    psVar8 = local_24;

  }

  if (*psVar8 == 0x2f) {

LAB_004f5894:

    piVar3 = (int *)FUN_004f4c40(&local_1c,1,*(undefined4 *)(local_24 + -2));

    if (local_24 != (short *)*piVar3) {

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

      if ((LVar5 == 0) && (local_24 + -10 != (short *)0x0)) {

        (*(code *)**(undefined4 **)(local_24 + -10))(1);

      }

      local_24 = (short *)*piVar3;

      InterlockedIncrement((LONG *)(local_24 + -8));

    }

    pwVar9 = local_1c + -10;

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

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

      (*(code *)**(undefined4 **)pwVar9)(1);

    }

    ppsStack_4 = &local_24;

    ppuStack_10 = &PTR_FUN_0079549c;

    uStack_c = 0;

    uStack_8 = 0;

    FUN_00402730(&DAT_007c5b20);

    puVar6 = (undefined4 *)FUN_004f4c40(apuStack_18,0,2);

    iVar7 = _wcsicmp((wchar_t *)*puVar6,local_1c);

    puVar6 = apuStack_18[0] + -5;

    LVar5 = InterlockedDecrement(apuStack_18[0] + -4);

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

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

    }

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

    if ((LVar5 == 0) && (local_1c + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(local_1c + -10))(1);

    }

    if (iVar7 == 0) {

      uVar4 = (*(code *)*ppuStack_10)();

      if (uVar4 < 2) {

        uStack_8 = (*(code *)*ppuStack_10)();

      }

      else {

        uStack_8 = 2;

      }

      piVar3 = (int *)FUN_0058a440(apuStack_18);

      FUN_00480980(&iStack_20,0,L"@tell %hs,",*piVar3 + 0x14);

      LVar5 = InterlockedDecrement(apuStack_18[0] + 1);

      if ((LVar5 == 0) && (apuStack_18[0] != (undefined4 *)0x0)) {

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

      }

      cVar2 = FUN_0040bdf0(&iStack_20);

      if (cVar2 != '\0') {

        FUN_0046a740(&local_24);

        FUN_00469120(*(undefined4 *)(iStack_20 + -4));

        FUN_00466540();

      }

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

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

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

      }

    }

    psVar1 = local_24;

    ppuStack_10 = &PTR_LAB_00795478;

    uVar4 = InterlockedDecrement((LONG *)(local_24 + -8));

  }

  else {

    psVar8 = local_24 + iVar7 + -1;

    if (iVar7 != 0) {

      psVar8 = local_24;

    }

    if (*psVar8 == 0x40) goto LAB_004f5894;

    uVar4 = InterlockedDecrement((LONG *)(local_24 + -8));

  }

  if ((uVar4 == 0) && (psVar1 + -10 != (short *)0x0)) {

    uVar4 = (*(code *)**(undefined4 **)(psVar1 + -10))(1);

  }

LAB_004f5a72:

  return uVar4 & 0xffffff00;

}





// --- FUN_004f5a80 at 0x004F5A80 (size: 684) ---


uint FUN_004f5a80(void)



{

  short *psVar1;

  char cVar2;

  int *piVar3;

  uint uVar4;

  LONG LVar5;

  undefined4 *puVar6;

  int iVar7;

  short *psVar8;

  wchar_t *pwVar9;

  short *local_24;

  int iStack_20;

  wchar_t *local_1c;

  undefined4 *apuStack_18 [2];

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  short **ppsStack_4;

  

  piVar3 = (int *)FUN_0058a500(&local_1c);

  pwVar9 = local_1c;

  iVar7 = *(int *)(*piVar3 + 8);

  uVar4 = InterlockedDecrement((LONG *)(local_1c + 2));

  if ((uVar4 == 0) && (pwVar9 != (wchar_t *)0x0)) {

    uVar4 = (*(code *)**(undefined4 **)pwVar9)(1);

  }

  if (iVar7 == 1) goto LAB_004f5d22;

  FUN_00466830(&local_24);

  iVar7 = DAT_00837750;

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

  FUN_004d68c0(1,0,iVar7);

  psVar1 = local_24;

  iVar7 = *(int *)(local_24 + -2);

  psVar8 = local_24 + iVar7 + -1;

  if (iVar7 != 0) {

    psVar8 = local_24;

  }

  if (*psVar8 == 0x2f) {

LAB_004f5b44:

    piVar3 = (int *)FUN_004f4c40(&local_1c,1,*(undefined4 *)(local_24 + -2));

    if (local_24 != (short *)*piVar3) {

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

      if ((LVar5 == 0) && (local_24 + -10 != (short *)0x0)) {

        (*(code *)**(undefined4 **)(local_24 + -10))(1);

      }

      local_24 = (short *)*piVar3;

      InterlockedIncrement((LONG *)(local_24 + -8));

    }

    pwVar9 = local_1c + -10;

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

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

      (*(code *)**(undefined4 **)pwVar9)(1);

    }

    ppsStack_4 = &local_24;

    ppuStack_10 = &PTR_FUN_0079549c;

    uStack_c = 0;

    uStack_8 = 0;

    FUN_00402730(&DAT_007c5b28);

    puVar6 = (undefined4 *)FUN_004f4c40(apuStack_18,0,2);

    iVar7 = _wcsicmp((wchar_t *)*puVar6,local_1c);

    puVar6 = apuStack_18[0] + -5;

    LVar5 = InterlockedDecrement(apuStack_18[0] + -4);

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

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

    }

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

    if ((LVar5 == 0) && (local_1c + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(local_1c + -10))(1);

    }

    if (iVar7 == 0) {

      uVar4 = (*(code *)*ppuStack_10)();

      if (uVar4 < 2) {

        uStack_8 = (*(code *)*ppuStack_10)();

      }

      else {

        uStack_8 = 2;

      }

      piVar3 = (int *)FUN_0058a500(apuStack_18);

      FUN_00480980(&iStack_20,0,L"@tell %hs,",*piVar3 + 0x14);

      LVar5 = InterlockedDecrement(apuStack_18[0] + 1);

      if ((LVar5 == 0) && (apuStack_18[0] != (undefined4 *)0x0)) {

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

      }

      cVar2 = FUN_0040bdf0(&iStack_20);

      if (cVar2 != '\0') {

        FUN_0046a740(&local_24);

        FUN_00469120(*(undefined4 *)(iStack_20 + -4));

        FUN_00466540();

      }

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

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

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

      }

    }

    psVar1 = local_24;

    ppuStack_10 = &PTR_LAB_00795478;

    uVar4 = InterlockedDecrement((LONG *)(local_24 + -8));

  }

  else {

    psVar8 = local_24 + iVar7 + -1;

    if (iVar7 != 0) {

      psVar8 = local_24;

    }

    if (*psVar8 == 0x40) goto LAB_004f5b44;

    uVar4 = InterlockedDecrement((LONG *)(local_24 + -8));

  }

  if ((uVar4 == 0) && (psVar1 + -10 != (short *)0x0)) {

    uVar4 = (*(code *)**(undefined4 **)(psVar1 + -10))(1);

  }

LAB_004f5d22:

  return uVar4 & 0xffffff00;

}





// --- FUN_004f5d30 at 0x004F5D30 (size: 43) ---


void __fastcall FUN_004f5d30(int param_1)



{

  char cVar1;

  

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

    cVar1 = FUN_004f53c0();

    if (cVar1 == '\0') {

      cVar1 = FUN_004f57d0();

      if (cVar1 == '\0') {

        FUN_004f5a80();

        return;

      }

    }

  }

  return;

}





// --- FUN_004f5d60 at 0x004F5D60 (size: 184) ---


void __fastcall FUN_004f5d60(int param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  int local_4;

  

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

    local_4 = param_1;

    FUN_004668a0(&local_4);

    iVar2 = local_4;

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

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

    }

    else {

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

        FUN_005821a0(&local_4,*(undefined4 *)(param_1 + 0x5fc));

      }

      FUN_00408e40(&local_4);

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

      *(undefined4 *)(param_1 + 0x630) = 0xffffffff;

      while (100 < uVar1) {

        FUN_004f4960(0);

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

      }

      FUN_00467ae0();

      iVar2 = local_4;

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

    }

    if ((iVar3 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

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

    }

  }

  return;

}





// --- FUN_004f5e20 at 0x004F5E20 (size: 199) ---


void __thiscall FUN_004f5e20(int param_1,int *param_2)



{

  switch(param_2[2]) {

  case 1:

    if (*param_2 == 0x10000019) {

      FUN_004f5d60();

      FUN_00462420(param_2);

      return;

    }

    if ((*param_2 == 0x1000048c) && (*(int *)(param_1 + 0x60c) != 0)) {

      FUN_00469440(*(undefined4 *)(*(int *)(param_1 + 0x60c) + 0x61c));

      (**(code **)(**(int **)(param_1 + 0x610) + 0x9c))(0xd);

      FUN_00462420(param_2);

      return;

    }

    break;

  case 0x12:

    if ((param_2[1] == *(int *)(param_1 + 0x608)) && ((short)param_2[3] == 0x20)) {

      FUN_004f5d30();

      FUN_00462420(param_2);

      return;

    }

    break;

  case 0x29:

  case 0x2a:

  case 0x2f:

    if (param_2[1] != *(int *)(param_1 + 0x608)) break;

  case 0x1b:

  case 0x1f:

    FUN_00465f90(3);

  }

  FUN_00462420(param_2);

  return;

}





// --- FUN_004f5f30 at 0x004F5F30 (size: 113) ---


void __fastcall FUN_004f5f30(int param_1)



{

  char cVar1;

  int iVar2;

  int iVar3;

  

  iVar3 = *(int *)(DAT_0083e03c + 0x32c);

  if (iVar3 != 0) {

    iVar2 = FUN_0045fb30();

    if (iVar3 == iVar2) {

      iVar3 = FUN_00460330();

      if (iVar3 == *(int *)(param_1 + 0x60c)) {

        FUN_0055e1d0();

        cVar1 = FUN_005d3df0();

        if (cVar1 == '\0') {

          (**(code **)(**(int **)(param_1 + 0x60c) + 0x108))();

          (**(code **)(**(int **)(param_1 + 0x60c) + 0x100))();

          FUN_0047a600(0);

        }

        FUN_004f5d60();

        return;

      }

    }

  }

  return;

}





// --- FUN_004f5fb0 at 0x004F5FB0 (size: 566) ---


void __thiscall FUN_004f5fb0(int param_1,int param_2)



{

  undefined *puVar1;

  char cVar2;

  undefined4 uVar3;

  LONG LVar4;

  int *piVar5;

  undefined4 *puVar6;

  LONG *lpAddend;

  undefined *puVar7;

  undefined4 *local_138;

  int local_134;

  int local_130;

  undefined4 *local_12c;

  int local_128;

  int local_124;

  undefined1 local_120 [144];

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0084219c,6);

  FUN_0042dc80();

  FUN_0042c9c0(DAT_00842194,6);

  FUN_0042e660(DAT_008421a0,local_90);

  puVar1 = PTR_DAT_00818340;

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

  if (param_2 == 0x10000020) {

    piVar5 = (int *)FUN_0058a440(&local_12c);

    uVar3 = FUN_00404a40(0,*piVar5 + 0x14);

    FUN_00402070(uVar3);

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

    puVar6 = local_12c;

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

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

      puVar6 = local_12c;

    }

LAB_004f612a:

    lpAddend = puVar6 + 1;

  }

  else {

    if (param_2 == 0x10000021) {

      piVar5 = (int *)FUN_0058a500(&local_138);

      uVar3 = FUN_00404a40(0,*piVar5 + 0x14);

      FUN_00402070(uVar3);

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

      puVar6 = local_138;

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

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

        puVar6 = local_138;

      }

      goto LAB_004f612a;

    }

    if (param_2 != 0x10000022) goto LAB_004f6144;

    uVar3 = FUN_0058a380(&local_130);

    uVar3 = FUN_004a2170(0,uVar3);

    FUN_00402070(uVar3);

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

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

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

    }

    puVar6 = (undefined4 *)(local_130 + -0x14);

    lpAddend = (LONG *)(local_130 + -0x10);

  }

  LVar4 = InterlockedDecrement(lpAddend);

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

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

  }

LAB_004f6144:

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

    puVar7 = puVar1;

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

    FUN_0042e8e0(DAT_008421a4,puVar7);

    cVar2 = FUN_0042ce00(1);

    if ((cVar2 != '\0') && (*(int *)(param_1 + 0x60c) != 0)) {

      FUN_004f3bf0();

      FUN_0046a350(local_120);

      FUN_00467bc0();

      FUN_00469100();

    }

  }

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

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

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

  }

  FUN_0042e590();

  FUN_0042e590();

  return;

}





// --- FUN_004f64c0 at 0x004F64C0 (size: 3) ---


void FUN_004f64c0(void)



{

  return;

}





// --- FUN_004f64f0 at 0x004F64F0 (size: 109) ---


void __thiscall FUN_004f64f0(int param_1,int param_2)



{

  int *piVar1;

  uint uVar2;

  

  if (*(int *)(param_2 + 8) == 0x18) {

    uVar2 = 0;

    if (*(uint *)(param_1 + 0x604) != 0) {

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

      while ((*piVar1 == 0 || (*piVar1 != *(int *)(param_2 + 4)))) {

        uVar2 = uVar2 + 1;

        piVar1 = piVar1 + 3;

        if (*(uint *)(param_1 + 0x604) <= uVar2) {

          FUN_00462420(param_2);

          return;

        }

      }

      FUN_0047a4a0(piVar1[1],*(uint *)(*piVar1 + 0xa4) >> 1 & 0xffffff01);

    }

  }

  FUN_00462420(param_2);

  return;

}





// --- FUN_004f6680 at 0x004F6680 (size: 187) ---


undefined4 __thiscall FUN_004f6680(int *param_1,uint param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  

  uVar2 = param_2;

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

    return 0;

  }

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

    if (param_2 == 0) {

      FUN_004cd4c0();

      return 1;

    }

    iVar3 = thunk_FUN_005df0f5(param_2 * 0xc);

    if (iVar3 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      param_2 = param_1[2];

      if (-1 < (int)(param_2 + -1)) {

        iVar4 = (param_2 + -1) * 0xc;

        do {

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

          puVar1 = (undefined4 *)(iVar4 + iVar3);

          *puVar1 = *puVar5;

          puVar1[1] = puVar5[1];

          puVar1[2] = puVar5[2];

          iVar4 = iVar4 + -0xc;

          param_2 = param_2 + -1;

        } while (param_2 != 0);

      }

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

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar3;

    param_1[1] = uVar2 | 0x80000000;

  }

  return 1;

}





// --- FUN_004f6740 at 0x004F6740 (size: 84) ---


undefined4 * __thiscall FUN_004f6740(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_FUN_007c5fb8;

  param_1[0x17e] = &PTR_FUN_007c5d10;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  param_1[0x183] = 0;

  return param_1;

}





// --- FUN_004f67d0 at 0x004F67D0 (size: 102) ---


void __fastcall FUN_004f67d0(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007c5fb8;

  *puVar1 = &PTR_FUN_007c5d10;

  FUN_004cd4c0();

  piVar2 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004f6840 at 0x004F6840 (size: 83) ---


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



{

  undefined4 *puVar1;

  undefined4 uVar2;

  

  if ((param_1[1] & 0x7fffffffU) <= (uint)param_1[2]) {

    uVar2 = FUN_00453850((param_1[1] & 0x7fffffffU) + 1);

    uVar2 = FUN_004f6680(uVar2);

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

      return uVar2;

    }

  }

  puVar1 = (undefined4 *)(*param_1 + param_1[2] * 0xc);

  *puVar1 = *param_2;

  puVar1[1] = param_2[1];

  uVar2 = param_2[2];

  puVar1[2] = uVar2;

  param_1[2] = param_1[2] + 1;

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

}





// --- FUN_004f68a0 at 0x004F68A0 (size: 30) ---


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



{

  FUN_004f67d0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f68c0 at 0x004F68C0 (size: 166) ---


void __fastcall FUN_004f68c0(int param_1)



{

  int iVar1;

  uint uVar2;

  undefined4 local_c;

  undefined1 local_8 [4];

  undefined1 local_4;

  

  local_c = FUN_00463c00(0x1000005c);

  FUN_00460990(0x10000029,local_8);

  local_4 = 0;

  FUN_004f6840(&local_c);

  local_c = FUN_00463c00(0x10000061);

  FUN_00460990(0x10000029,local_8);

  local_4 = 0;

  FUN_004f6840(&local_c);

  uVar2 = 0;

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

    iVar1 = 0;

    do {

      (**(code **)(**(int **)(*(int *)(param_1 + 0x5fc) + iVar1) + 0x18))(0);

      uVar2 = uVar2 + 1;

      iVar1 = iVar1 + 0xc;

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

  }

  return;

}





// --- FUN_004f6970 at 0x004F6970 (size: 16) ---


void FUN_004f6970(void)



{

  FUN_004639a0();

  FUN_004f68c0();

  return;

}





// --- FUN_004f6980 at 0x004F6980 (size: 227) ---


void __thiscall FUN_004f6980(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined1 auStack_10 [16];

  

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

    iVar1 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (iVar1 == param_2) {

    param_2 = 0;

  }

  iVar1 = FUN_005583f0(param_2);

  if (iVar1 != 0) {

    iVar2 = FUN_0058df90();

    if ((iVar2 == 0) && (*(int *)(iVar1 + 0x68) != 2)) goto LAB_004f69c9;

  }

  param_2 = 0;

  iVar1 = 0;

LAB_004f69c9:

  if (param_2 != *(int *)(param_1 + 8)) {

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

    if (iVar2 != 0) {

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

    }

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

    if (iVar1 != 0) {

      (**(code **)(*(int *)(iVar1 + 0xc) + 4))(0x4dd245,param_1);

    }

  }

  if (DAT_0083da58 != 0) {

    FUN_00451d60(param_2);

  }

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

    if (param_2 == 0) {

      (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(0);

      (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))(0);

      return;

    }

    puVar3 = (undefined4 *)FUN_004d9070(auStack_10,param_2);

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

    *(undefined4 *)(param_1 + 0x10) = puVar3[1];

    *(undefined4 *)(param_1 + 0x14) = puVar3[2];

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

  }

  return;

}





// --- FUN_004f6a70 at 0x004F6A70 (size: 350) ---


undefined4 FUN_004f6a70(int param_1)



{

  undefined4 uVar1;

  char cVar2;

  int *piVar3;

  undefined4 uVar4;

  int iVar5;

  undefined4 uVar6;

  undefined4 unaff_EBX;

  

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

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

    iVar5 = *piVar3;

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

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

    uVar4 = FUN_0054fe80(1);

    cVar2 = (**(code **)(iVar5 + 0x58))(uVar6,uVar1,uVar4);

    if (cVar2 != '\0') {

      switch(DAT_0081d640) {

      case 1:

        FUN_00442c70(param_1 + 0xac,0,0x3f800000);

        FUN_00442c90(0,4,unaff_EBX);

        break;

      case 2:

        FUN_00442c70(param_1 + 0xac,0,0x3f800000);

        FUN_00442c90(0,3,unaff_EBX);

        break;

      case 3:

        FUN_00442c70(param_1 + 0xac,0,0x3f800000);

        FUN_00442c90(0,5,unaff_EBX);

        break;

      case 4:

        uVar6 = FUN_00424000();

        FUN_004428b0(param_1 + 0xac,0,0x3f800000,0,3,uVar6);

      }

      iVar5 = FUN_005df0f5(0xc);

      if (iVar5 != 0) {

        uVar6 = FUN_00694d80(piVar3);

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

        return uVar6;

      }

    }

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

  }

  return 0;

}





// --- FUN_004f6bf0 at 0x004F6BF0 (size: 65) ---


void __fastcall FUN_004f6bf0(int param_1)



{

  char cVar1;

  

  FUN_0055e1d0();

  cVar1 = FUN_005d3ee0();

  *(char *)(param_1 + 0x60) = cVar1;

  if ((*(char *)(param_1 + 0x61) != '\0') && (cVar1 != '\0')) {

    FUN_004f6980(*(undefined4 *)(param_1 + 8));

    return;

  }

  (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(0);

  (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))(0);

  return;

}





// --- FUN_004f6c40 at 0x004F6C40 (size: 69) ---


void __fastcall FUN_004f6c40(int param_1)



{

  char cVar1;

  

  FUN_0055e1d0();

  cVar1 = FUN_005d3ee0();

  *(char *)(param_1 + 0x60) = cVar1;

  if ((*(char *)(param_1 + 0x61) != '\0') && (cVar1 != '\0')) {

    FUN_004f6980(*(undefined4 *)(param_1 + 8));

    return;

  }

  (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(0);

  (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))(0);

  return;

}





// --- FUN_004f6ce0 at 0x004F6CE0 (size: 84) ---


void __thiscall FUN_004f6ce0(int param_1,char param_2)



{

  char cVar1;

  

  if (*(char *)(param_1 + 0x61) != param_2) {

    *(char *)(param_1 + 0x61) = param_2;

    FUN_0055e1d0();

    cVar1 = FUN_005d3ee0();

    *(char *)(param_1 + 0x60) = cVar1;

    if ((*(char *)(param_1 + 0x61) == '\0') || (cVar1 == '\0')) {

      (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(0);

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

                    /* WARNING: Treating indirect jump as call */

      (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))();

      return;

    }

    FUN_004f6980(*(undefined4 *)(param_1 + 8));

  }

  return;

}





// --- FUN_004f6d80 at 0x004F6D80 (size: 103) ---


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



{

  char cVar1;

  undefined4 uVar2;

  

  if ((param_2 == *(int *)(param_1 + 0x1c)) && (cVar1 = FUN_00423f40(param_1 + 0x30), cVar1 != '\0')

     ) {

    return;

  }

  uVar2 = FUN_004f6a70(*(undefined4 *)(*(int *)(param_1 + 0x40) + param_2 * 4),param_3);

  FUN_006a0660();

  FUN_006a0610(uVar2);

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

  *(undefined4 *)(param_1 + 0x34) = param_3[1];

  *(undefined4 *)(param_1 + 0x38) = param_3[2];

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

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

  return;

}





// --- FUN_004f6df0 at 0x004F6DF0 (size: 118) ---


void __thiscall FUN_004f6df0(int param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 uVar2;

  uint uVar3;

  

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

  if (cVar1 == '\0') {

    uVar3 = 4;

    do {

      uVar2 = FUN_004f6a70(*(undefined4 *)(*(int *)(param_1 + 0x40) + uVar3),param_2);

      FUN_006a0660();

      FUN_006a0610(uVar2);

      uVar3 = uVar3 + 4;

    } while (uVar3 < 0x11);

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

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

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

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

  }

  return;

}





// --- FUN_004f6e70 at 0x004F6E70 (size: 127) ---


void __fastcall FUN_004f6e70(undefined4 *param_1)



{

  int *piVar1;

  

  *param_1 = &PTR_FUN_007c6218;

  param_1[1] = &PTR_LAB_007c620c;

  DAT_00842234 = 0;

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

  piVar1 = (int *)FUN_0043c680();

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

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

  }

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

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

  }

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

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

  }

  *param_1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_004f6ef0 at 0x004F6EF0 (size: 2083) ---


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



void __thiscall FUN_004f6ef0(int param_1,float param_2,int param_3,int *param_4,float param_5)



{

  float fVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int unaff_EBP;

  int iVar8;

  float10 fVar9;

  float10 fVar10;

  float10 fVar11;

  float10 fVar12;

  undefined4 uVar13;

  

  if (((*(char *)(param_1 + 0x61) == '\0') || (*(char *)(param_1 + 0x60) == '\0')) ||

     (param_2 == 0.0)) {

    uVar13 = 0;

LAB_004f76f7:

    (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(uVar13);

    (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))(0);

    return;

  }

  if (param_3 == 1) {

    FUN_004f6df0(param_1 + 0xc);

    iVar3 = FUN_0069fe60();

    iVar4 = FUN_0069fe70();

    iVar5 = (*(int *)(DAT_00870340 + 0x98) - iVar4) + -8;

    iVar7 = param_4[2];

    iVar8 = *param_4 - iVar3;

    iVar6 = (*(int *)(DAT_00870340 + 0x94) - iVar3) + -8;

    iVar2 = param_4[1] - iVar4;

    if (iVar7 < iVar8) {

      iVar8 = iVar7 + -1;

    }

    if (param_4[3] < iVar2) {

      iVar2 = param_4[3] + -1;

    }

    if (iVar8 < 8) {

      iVar8 = 8;

    }

    if (iVar2 < 8) {

      iVar2 = 8;

    }

    if (iVar7 < iVar3 + 8) {

      iVar7 = iVar3 + 8;

    }

    if (iVar6 - iVar3 < iVar8) {

      iVar8 = iVar6 - iVar3;

    }

    iVar3 = iVar5 - iVar4;

    if (iVar3 < iVar2) {

      iVar2 = iVar3;

    }

    if (iVar6 < iVar7) {

      iVar7 = iVar6;

    }

    (**(code **)(**(int **)(param_1 + 0x50) + 0x2c))(iVar8,iVar2);

    (**(code **)(**(int **)(param_1 + 0x50) + 0x30))

              ((iVar7 - iVar8) + iVar4,(iVar5 - iVar2) + unaff_EBP);

    uVar13 = 1;

    goto LAB_004f76f7;

  }

  if (param_3 != 2) {

    return;

  }

  if (((float)_DAT_007c6540 <= param_5) || (param_5 < (float)_DAT_007c6538)) {

    uVar13 = 6;

LAB_004f708d:

    FUN_004f6d80(uVar13,param_1 + 0xc);

  }

  else {

    if (((float)_DAT_007c6538 <= param_5) && (param_5 < (float)_DAT_007c6530)) {

      uVar13 = 7;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6530 <= param_5) && (param_5 < (float)_DAT_007c6528)) {

      uVar13 = 9;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6528 <= param_5) && (param_5 < (float)_DAT_007c6520)) {

      uVar13 = 0xc;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6520 <= param_5) && (param_5 < (float)_DAT_007c6518)) {

      uVar13 = 0xb;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6518 <= param_5) && (param_5 < (float)_DAT_007c6510)) {

      uVar13 = 10;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6510 <= param_5) && (param_5 < (float)_DAT_007c6508)) {

      uVar13 = 8;

      goto LAB_004f708d;

    }

    if (((float)_DAT_007c6508 <= param_5) && (param_5 < (float)_DAT_007c6540)) {

      uVar13 = 5;

      goto LAB_004f708d;

    }

  }

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

    return;

  }

  iVar2 = FUN_0069fe60();

  param_2 = (float)FUN_0069fe70();

  iVar8 = DAT_00870340;

  fVar9 = (float10)(int)param_2;

  if (param_5 < (float)_DAT_007c6500 == (param_5 == (float)_DAT_007c6500)) {

    if (((float)_DAT_007c6500 < param_5) &&

       (param_5 < (float)_DAT_007c64f8 != (param_5 == (float)_DAT_007c64f8))) {

      fVar1 = (float)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar1 = fVar1 + _DAT_0079920c;

      }

      param_2 = (fVar1 - DAT_007c61f4) - (float)iVar2;

      fVar10 = (float10)*(int *)(DAT_00870340 + 0x98);

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar10 = fVar10 + (float10)_DAT_0079920c;

      }

      fVar11 = (float10)fptan(((float10)_DAT_007c64f0 - (float10)param_5) * (float10)_DAT_007c61f0);

      param_5 = (float)((fVar10 * (float10)_DAT_007938b8 -

                        (float10)fVar1 * (float10)_DAT_007938b8 * fVar11) -

                       fVar9 * (float10)_DAT_007938b8);

      goto LAB_004f7553;

    }

    if (((float)_DAT_007c64f8 < param_5) &&

       (param_5 < (float)_DAT_007c64e8 != (param_5 == (float)_DAT_007c64e8))) {

      fVar10 = (float10)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar10 = fVar10 + (float10)_DAT_0079920c;

      }

      param_2 = (float)((fVar10 - (float10)DAT_007c61f4) - (float10)iVar2);

      fVar11 = (float10)fptan(((float10)param_5 - (float10)_DAT_007c64f0) * (float10)_DAT_007c61f0);

      fVar12 = (float10)*(int *)(DAT_00870340 + 0x98);

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar12 = fVar12 + (float10)_DAT_0079920c;

      }

      param_5 = (float)((fVar12 * (float10)_DAT_007938b8 + fVar10 * (float10)_DAT_007938b8 * fVar11)

                       - fVar9 * (float10)_DAT_007938b8);

      goto LAB_004f7553;

    }

    if (((float)_DAT_007c64e8 < param_5) &&

       (param_5 < (float)_DAT_007c64e0 != (param_5 == (float)_DAT_007c64e0))) {

      fVar10 = (float10)*(int *)(DAT_00870340 + 0x98);

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar10 = fVar10 + (float10)_DAT_0079920c;

      }

      fVar11 = (float10)fptan(((float10)_DAT_0079cc8c - (float10)param_5) * (float10)_DAT_007c61f0);

      fVar12 = (float10)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar12 = fVar12 + (float10)_DAT_0079920c;

      }

      param_2 = (float)((fVar12 * (float10)_DAT_007938b8 + fVar10 * (float10)_DAT_007938b8 * fVar11)

                       - (float10)iVar2 * (float10)_DAT_007938b8);

      param_5 = (float)((fVar10 - (float10)DAT_007c61f4) - fVar9);

      goto LAB_004f7553;

    }

    if (((float)_DAT_007c64e0 < param_5) &&

       (param_5 < (float)_DAT_007c64d8 != (param_5 == (float)_DAT_007c64d8))) {

      fVar10 = (float10)*(int *)(DAT_00870340 + 0x98);

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar10 = fVar10 + (float10)_DAT_0079920c;

      }

      fVar11 = (float10)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar11 = fVar11 + (float10)_DAT_0079920c;

      }

      fVar12 = (float10)fptan(((float10)param_5 - (float10)_DAT_0079cc8c) * (float10)_DAT_007c61f0);

      param_2 = (float)((fVar11 * (float10)_DAT_007938b8 - fVar10 * (float10)_DAT_007938b8 * fVar12)

                       - (float10)iVar2 * (float10)_DAT_007938b8);

      param_5 = (float)((fVar10 - (float10)DAT_007c61f4) - fVar9);

      goto LAB_004f7553;

    }

    if (((float)_DAT_007c64d8 < param_5) &&

       (param_5 < (float)_DAT_007c64d0 != (param_5 == (float)_DAT_007c64d0))) {

      param_2 = DAT_007c61f4;

      fVar10 = (float10)fptan(((float10)_DAT_007c64c8 - (float10)param_5) * (float10)_DAT_007c61f0);

      fVar11 = (float10)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar11 = fVar11 + (float10)_DAT_0079920c;

      }

      fVar12 = (float10)*(int *)(DAT_00870340 + 0x98);

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar12 = fVar12 + (float10)_DAT_0079920c;

      }

      param_5 = (float)((fVar12 * (float10)_DAT_007938b8 + fVar11 * (float10)_DAT_007938b8 * fVar10)

                       - fVar9 * (float10)_DAT_007938b8);

      goto LAB_004f7553;

    }

    if (((float)_DAT_007c64d0 < param_5) &&

       (param_5 < (float)_DAT_007c64c0 != (param_5 == (float)_DAT_007c64c0))) {

      fVar10 = (float10)*(int *)(DAT_00870340 + 0x98);

      param_2 = DAT_007c61f4;

      if (*(int *)(DAT_00870340 + 0x98) < 0) {

        fVar10 = fVar10 + (float10)_DAT_0079920c;

      }

      fVar11 = (float10)fptan(((float10)param_5 - (float10)_DAT_007c64c8) * (float10)_DAT_007c61f0);

      fVar12 = (float10)*(int *)(DAT_00870340 + 0x94);

      if (*(int *)(DAT_00870340 + 0x94) < 0) {

        fVar12 = fVar12 + (float10)_DAT_0079920c;

      }

      param_5 = (float)((fVar10 * (float10)_DAT_007938b8 - fVar12 * (float10)_DAT_007938b8 * fVar11)

                       - fVar9 * (float10)_DAT_007938b8);

      goto LAB_004f7553;

    }

    if (param_5 <= (float)_DAT_007c64c0) goto LAB_004f7553;

    fVar10 = (float10)*(int *)(DAT_00870340 + 0x94);

    if (*(int *)(DAT_00870340 + 0x94) < 0) {

      fVar10 = fVar10 + (float10)_DAT_0079920c;

    }

    fVar11 = (float10)fptan(((float10)_DAT_0079cc60 - (float10)param_5) * (float10)_DAT_007c61f0);

    fVar12 = (float10)*(int *)(DAT_00870340 + 0x98);

    if (*(int *)(DAT_00870340 + 0x98) < 0) {

      fVar12 = fVar12 + (float10)_DAT_0079920c;

    }

    fVar10 = fVar10 * (float10)_DAT_007938b8 - fVar12 * (float10)_DAT_007938b8 * fVar11;

  }

  else {

    fVar10 = (float10)fptan((float10)_DAT_007c61f0 * (float10)param_5);

    fVar11 = (float10)*(int *)(DAT_00870340 + 0x98);

    if (*(int *)(DAT_00870340 + 0x98) < 0) {

      fVar11 = fVar11 + (float10)_DAT_0079920c;

    }

    fVar12 = (float10)*(int *)(DAT_00870340 + 0x94);

    if (*(int *)(DAT_00870340 + 0x94) < 0) {

      fVar12 = fVar12 + (float10)_DAT_0079920c;

    }

    fVar10 = fVar12 * (float10)_DAT_007938b8 + fVar11 * (float10)_DAT_007938b8 * fVar10;

  }

  param_5 = DAT_007c61f4;

  param_2 = (float)(fVar10 - (float10)iVar2 * (float10)_DAT_007938b8);

LAB_004f7553:

  fVar10 = (float10)*(int *)(DAT_00870340 + 0x98);

  iVar7 = **(int **)(param_1 + 0x4c);

  if (*(int *)(DAT_00870340 + 0x98) < 0) {

    fVar10 = fVar10 + (float10)_DAT_0079920c;

  }

  FUN_004523e0(param_5,DAT_007c61f4,(float)((fVar10 - (float10)DAT_007c61f4) - fVar9));

  uVar13 = FUN_005df4c4();

  fVar1 = (float)*(int *)(iVar8 + 0x94);

  if (*(int *)(iVar8 + 0x94) < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  FUN_004523e0(param_2,DAT_007c61f4,(fVar1 - DAT_007c61f4) - (float)iVar2,uVar13);

  uVar13 = FUN_005df4c4();

  (**(code **)(iVar7 + 0x2c))(uVar13);

  (**(code **)(**(int **)(param_1 + 0x50) + 0x18))(0);

  (**(code **)(**(int **)(param_1 + 0x4c) + 0x18))(1);

  return;

}





// --- FUN_004f7720 at 0x004F7720 (size: 321) ---


undefined4 * __fastcall FUN_004f7720(undefined4 *param_1)



{

  char cVar1;

  undefined4 uVar2;

  uint uVar3;

  

  *param_1 = &PTR_FUN_00801670;

  *param_1 = &PTR_FUN_007ccb60;

  param_1[1] = &PTR_LAB_007a6af4;

  *param_1 = &PTR_FUN_007c6218;

  param_1[1] = &PTR_LAB_007c620c;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

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

  *(undefined1 *)((int)param_1 + 0x61) = 1;

  DAT_00842234 = param_1;

  if ((param_1[0x11] & 0x7fffffff) < 0xd) {

    cVar1 = FUN_004180a0(0xd);

    if (cVar1 != '\0') goto LAB_004f77dd;

  }

  else {

    uVar3 = 0xd;

    if (0xd < (uint)param_1[0x12]) {

      do {

        *(undefined4 *)(param_1[0x10] + uVar3 * 4) = 0;

        uVar3 = uVar3 + 1;

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

    }

LAB_004f77dd:

    param_1[0x12] = 0xd;

  }

  if ((param_1[0x16] & 0x7fffffff) < 5) {

    cVar1 = FUN_004180a0(5);

    if (cVar1 == '\0') goto LAB_004f7828;

  }

  else {

    uVar3 = 5;

    if (5 < (uint)param_1[0x17]) {

      do {

        *(undefined4 *)(param_1[0x15] + uVar3 * 4) = 0;

        uVar3 = uVar3 + 1;

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

    }

  }

  param_1[0x17] = 5;

LAB_004f7828:

  uVar3 = 1;

  do {

    uVar2 = FUN_00415730(uVar3,0x10000009,0xc);

    if (uVar3 < (uint)param_1[0x12]) {

      *(undefined4 *)(param_1[0x10] + uVar3 * 4) = uVar2;

    }

    uVar3 = uVar3 + 1;

  } while (uVar3 < 0xd);

  return param_1;

}





// --- FUN_004f78a0 at 0x004F78A0 (size: 429) ---


undefined4 __fastcall FUN_004f78a0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int *piVar3;

  

  uVar2 = FUN_00463ba0(0x10000045);

  *(undefined4 *)(param_1 + 0x4c) = uVar2;

  uVar2 = FUN_00463ba0(0x10000038);

  *(undefined4 *)(param_1 + 0x50) = uVar2;

  uVar2 = FUN_00463ba0(0x10000039);

  if (1 < *(uint *)(param_1 + 0x5c)) {

    *(undefined4 *)(*(int *)(param_1 + 0x54) + 4) = uVar2;

  }

  uVar2 = FUN_00463ba0(0x1000003a);

  if (2 < *(uint *)(param_1 + 0x5c)) {

    *(undefined4 *)(*(int *)(param_1 + 0x54) + 8) = uVar2;

  }

  uVar2 = FUN_00463ba0(0x1000003b);

  if (3 < *(uint *)(param_1 + 0x5c)) {

    *(undefined4 *)(*(int *)(param_1 + 0x54) + 0xc) = uVar2;

  }

  uVar2 = FUN_00463ba0(0x1000003c);

  if (4 < *(uint *)(param_1 + 0x5c)) {

    *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x10) = uVar2;

  }

  if ((((*(int *)(param_1 + 0x4c) != 0) && (*(int *)(param_1 + 0x50) != 0)) &&

      (iVar1 = *(int *)(param_1 + 0x54), *(int *)(iVar1 + 4) != 0)) &&

     (((*(int *)(iVar1 + 8) != 0 && (*(int *)(iVar1 + 0xc) != 0)) && (*(int *)(iVar1 + 0x10) != 0)))

     ) {

    piVar3 = (int *)FUN_0043c680();

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

      (**(code **)(*piVar3 + 4))(0x4dd1ef,param_1);

      (**(code **)(*piVar3 + 4))(0x4dd1f0,param_1);

      (**(code **)(*piVar3 + 4))(0x4dd21f,param_1);

      (**(code **)(*piVar3 + 4))(0x186a8,param_1);

    }

    param_1 = param_1 + 4;

    (**(code **)(*DAT_008f958c + 8))(7,0x1a,param_1);

    (**(code **)(*DAT_008f958c + 4))(0,7,0x1a,param_1);

    (**(code **)(*DAT_008f958c + 4))(0,1,0x86,param_1);

    (**(code **)(*DAT_008f958c + 4))(0,1,0x5f,param_1);

    (**(code **)(*DAT_008f958c + 4))(0,1,0x85,param_1);

    (**(code **)(*DAT_008f958c + 4))(0,5,1,param_1);

    FUN_004f6bf0();

    if (DAT_0083da58 != 0) {

      FUN_00451d50(&LAB_004f7870);

    }

    return 1;

  }

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

  return 0;

}





// --- FUN_004f7a90 at 0x004F7A90 (size: 95) ---


undefined4 * __thiscall

FUN_004f7a90(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 uVar1;

  

  *param_1 = &PTR_FUN_00793b3c;

  param_1[1] = 0;

  param_1[2] = 0;

  FUN_00406d60();

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  *param_1 = &PTR_FUN_00793b50;

  uVar1 = FUN_00407060(param_3,param_4);

  FUN_0040b020(&PTR_PTR_008183b8,uVar1);

  FUN_00406f90();

  return param_1;

}





// --- FUN_004f7b10 at 0x004F7B10 (size: 27) ---


undefined4 FUN_004f7b10(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0xb8);

  if (iVar1 != 0) {

    uVar2 = FUN_00535240();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7b70 at 0x004F7B70 (size: 30) ---


undefined4 FUN_004f7b70(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x48);

  if (iVar1 != 0) {

    uVar2 = FUN_0053ee60(0x800);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7bd0 at 0x004F7BD0 (size: 35) ---


undefined4 FUN_004f7bd0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0xa0);

  if (iVar1 != 0) {

    uVar2 = FUN_005526c0(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7c20 at 0x004F7C20 (size: 32) ---


undefined4 FUN_004f7c20(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x60);

  if (iVar1 != 0) {

    uVar2 = FUN_004fe5a0(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7c40 at 0x004F7C40 (size: 32) ---


undefined4 FUN_004f7c40(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_004fd360(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7c60 at 0x004F7C60 (size: 32) ---


undefined4 FUN_004f7c60(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_004fe830(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7c80 at 0x004F7C80 (size: 27) ---


undefined4 FUN_004f7c80(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0xa8);

  if (iVar1 != 0) {

    uVar2 = FUN_00683730();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7d00 at 0x004F7D00 (size: 30) ---


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



{

  FUN_004f7d20();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f7d20 at 0x004F7D20 (size: 31) ---


void __fastcall FUN_004f7d20(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007c66b0;

  param_1[0xc] = &PTR_FUN_007ff210;

  FUN_0067c1f0();

  FUN_004154b0();

  return;

}





// --- FUN_004f7d40 at 0x004F7D40 (size: 27) ---


undefined4 FUN_004f7d40(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0xa8);

  if (iVar1 != 0) {

    uVar2 = FUN_00680640();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7d60 at 0x004F7D60 (size: 32) ---


undefined4 FUN_004f7d60(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x40);

  if (iVar1 != 0) {

    uVar2 = FUN_005ad5e0(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7dc0 at 0x004F7DC0 (size: 32) ---


undefined4 FUN_004f7dc0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x48);

  if (iVar1 != 0) {

    uVar2 = FUN_005a6fd0(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7e00 at 0x004F7E00 (size: 27) ---


undefined4 FUN_004f7e00(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x148);

  if (iVar1 != 0) {

    uVar2 = FUN_0068f710();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7e70 at 0x004F7E70 (size: 32) ---


undefined4 FUN_004f7e70(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x38);

  if (iVar1 != 0) {

    uVar2 = FUN_005af240(DAT_008423b4);

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7e90 at 0x004F7E90 (size: 27) ---


undefined4 FUN_004f7e90(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0xf8);

  if (iVar1 != 0) {

    uVar2 = FUN_00517d80();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7eb0 at 0x004F7EB0 (size: 24) ---


undefined4 FUN_004f7eb0(void)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x50);

  if (iVar1 != 0) {

    uVar2 = FUN_005221b0();

    return uVar2;

  }

  return 0;

}





// --- FUN_004f7ef0 at 0x004F7EF0 (size: 35) ---


int FUN_004f7ef0(void)



{

  int iVar1;

  

  iVar1 = FUN_005df0f5(0xa8);

  if (iVar1 != 0) {

    iVar1 = FUN_00682450();

    if (iVar1 != 0) {

      return iVar1 + 0x78;

    }

  }

  return 0;

}





// --- FUN_004f7f20 at 0x004F7F20 (size: 32) ---


int FUN_004f7f20(void)



{

  uint uVar1;

  int iVar2;

  

  uVar1 = FUN_00406db0();

  if (4 < uVar1) {

    iVar2 = FUN_00406db0();

    return iVar2 + -4;

  }

  return 0;

}





// --- FUN_004f7f70 at 0x004F7F70 (size: 13) ---


void __thiscall FUN_004f7f70(int param_1,undefined4 param_2)



{

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

  return;

}





// --- FUN_004f7fc0 at 0x004F7FC0 (size: 24) ---


void __fastcall FUN_004f7fc0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c7450;

  if (param_1[5] == 0) {

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

  }

  return;

}





// --- FUN_004f7fe0 at 0x004F7FE0 (size: 85) ---


void __thiscall FUN_004f7fe0(int param_1,uint param_2)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = 1;

  *(uint *)(param_1 + 0x10) = param_2;

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

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

  if (1 < param_2) {

    do {

      uVar2 = *(uint *)(param_1 + 4) | uVar1;

      uVar1 = uVar1 << 1;

      *(uint *)(param_1 + 4) = uVar2;

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

  }

  uVar1 = 0;

  if (param_2 != 0) {

    do {

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

      uVar1 = uVar1 + 1;

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

  }

  return;

}





// --- FUN_004f8040 at 0x004F8040 (size: 136) ---


void __fastcall FUN_004f8040(int *param_1)



{

  uint uVar1;

  int iVar2;

  

  if (param_1[4] == 0) {

    if (param_1[3] == 0) {

      *(undefined4 *)(*(int *)(*param_1 + 0xc) + param_1[1] * 4) = *(undefined4 *)(param_1[2] + 4);

      iVar2 = *(int *)(*(int *)(*param_1 + 0xc) + param_1[1] * 4);

    }

    else {

      *(undefined4 *)(param_1[3] + 4) = *(undefined4 *)(param_1[2] + 4);

      iVar2 = *(int *)(param_1[3] + 4);

    }

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

      (*(code *)**(undefined4 **)param_1[2])(1);

    }

    if (iVar2 == 0) {

      do {

        uVar1 = param_1[1] + 1;

        param_1[3] = 0;

        param_1[1] = uVar1;

        if (*(uint *)(*param_1 + 0x10) <= uVar1) {

          param_1[4] = 1;

          param_1[2] = 0;

          return;

        }

        iVar2 = *(int *)(*(int *)(*param_1 + 0xc) + uVar1 * 4);

      } while (iVar2 == 0);

    }

    param_1[2] = iVar2;

  }

  return;

}





// --- FUN_004f8190 at 0x004F8190 (size: 31) ---


void __fastcall FUN_004f8190(int param_1)



{

  if (param_1 != 0) {

    *(undefined ***)(param_1 + 0x30) = &PTR_FUN_0079385c;

    FUN_004154b0();

    return;

  }

  ppuRam00000000 = &PTR_FUN_0079385c;

  FUN_004154b0();

  return;

}





// --- FUN_004f8210 at 0x004F8210 (size: 88) ---


void __fastcall FUN_004f8210(undefined4 *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  *param_1 = &PTR_LAB_007c6778;

  FUN_00443450();

  puVar2 = (undefined4 *)(param_1[0x16] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[0x16] + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(param_1[0x13] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[0x13] + -0x10));

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

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

  }

  FUN_004154b0();

  return;

}





// --- FUN_004f8290 at 0x004F8290 (size: 30) ---


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



{

  FUN_004f8210();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f82b0 at 0x004F82B0 (size: 78) ---


undefined4 * __fastcall FUN_004f82b0(undefined4 *param_1)



{

  LONG *pLVar1;

  

  FUN_00415460(DAT_008423b4);

  *param_1 = &PTR_LAB_007c6778;

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

  param_1[0x13] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

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

  param_1[0x16] = PTR_DAT_00818344;

  InterlockedIncrement(pLVar1);

  FUN_00443960();

  *param_1 = &PTR_LAB_007c67d0;

  return param_1;

}





// --- FUN_004f8310 at 0x004F8310 (size: 62) ---


void __thiscall FUN_004f8310(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

        return;

      }

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

    }

  }

  return;

}





// --- FUN_004f8350 at 0x004F8350 (size: 36) ---


undefined4 * __fastcall FUN_004f8350(undefined4 *param_1)



{

  param_1[1] = 0xf7e2;

  *param_1 = &PTR_FUN_007c6828;

  param_1[6] = 0;

  param_1[7] = 0;

  FUN_00406d60();

  return param_1;

}





// --- FUN_004f85b0 at 0x004F85B0 (size: 164) ---


undefined4 * FUN_004f85b0(undefined4 param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 uVar2;

  undefined4 *unaff_retaddr;

  uint local_24 [9];

  

  FUN_00401600(0);

  (**(code **)*param_2)(local_24);

  if ((local_24[0] >> 2 & 1) == 0) {

    FUN_0040a900(&stack0xffffffcc);

    uVar2 = FUN_00406db0();

    uVar2 = FUN_00406d80(uVar2);

    cVar1 = FUN_00547520(uVar2);

    if (cVar1 != '\0') {

      FUN_00406d90();

      *unaff_retaddr = 0;

      FUN_00406f90();

      FUN_0040b060();

      return unaff_retaddr;

    }

    FUN_00406f90();

  }

  *unaff_retaddr = 0x80004005;

  FUN_0040b060();

  return unaff_retaddr;

}





// --- FUN_004f8660 at 0x004F8660 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007c6834;

  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_004f86a0 at 0x004F86A0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007c6838;

  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_004f86e0 at 0x004F86E0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007c683c;

  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_004f8720 at 0x004F8720 (size: 102) ---


int * __thiscall

FUN_004f8720(int *param_1,int *param_2,int *param_3,int param_4,int param_5,int param_6,int param_7,

            int param_8,int param_9,int param_10,undefined1 param_11)



{

  int iVar1;

  

  iVar1 = *param_2;

  *param_1 = iVar1;

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

  iVar1 = *param_3;

  param_1[1] = iVar1;

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

  param_1[3] = param_5;

  param_1[2] = param_4;

  param_1[6] = param_8;

  param_1[4] = param_6;

  param_1[5] = param_7;

  *(undefined1 *)(param_1 + 9) = param_11;

  param_1[7] = param_9;

  param_1[8] = param_10;

  return param_1;

}





// --- FUN_004f8790 at 0x004F8790 (size: 36) ---


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



{

  *param_1 = &PTR_FUN_007c6840;

  FUN_00418150();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f87c0 at 0x004F87C0 (size: 49) ---


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



{

  undefined4 *puVar1;

  

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

    puVar1 = (undefined4 *)0x0;

  }

  else {

    puVar1 = (undefined4 *)((int)param_1 + 0x30);

  }

  *puVar1 = &PTR_FUN_0079385c;

  FUN_004154b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f8820 at 0x004F8820 (size: 156) ---


void __thiscall FUN_004f8820(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      }

      else {

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

      }

    }

  }

  FUN_004254b0(param_1 + 8,param_2);

  FUN_0040ad10(8);

  puVar1 = (undefined4 *)FUN_0040acf0(8);

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

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

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

      *(undefined4 *)(param_1 + 0x14) = puVar1[1];

    }

    else {

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

      puVar1[1] = *(undefined4 *)(param_1 + 0x14);

    }

  }

  FUN_004449f0(param_1 + 0x2c,param_2);

  FUN_00422250(param_1 + 0x30,param_2);

  FUN_004f88c0(param_2);

  return;

}





// --- FUN_004f88c0 at 0x004F88C0 (size: 303) ---


void __thiscall FUN_004f88c0(int param_1,int param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  undefined4 uVar4;

  int *piVar5;

  int iVar6;

  undefined1 *puVar7;

  undefined1 local_18 [12];

  undefined1 local_c [12];

  

  iVar3 = param_2;

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

    }

    else {

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

    }

  }

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

    uVar4 = FUN_0040a8d0();

    FUN_0040ad10(4);

    piVar5 = (int *)FUN_0040acf0(4);

    iVar6 = param_2;

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

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

        iVar6 = *piVar5;

      }

      else {

        *piVar5 = param_2;

      }

    }

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

      FUN_0040a8e0(uVar4);

      uVar4 = 0;

      puVar7 = local_18;

      iVar3 = iVar6;

      FUN_0040a920(local_c);

      uVar4 = FUN_00407140(puVar7,uVar4,iVar3);

      FUN_004070d0(uVar4);

      FUN_00406f90();

      FUN_00406f90();

      FUN_0040acf0(iVar6);

      puVar1 = (undefined4 *)FUN_00406d80();

      *puVar1 = 0;

    }

  }

  else {

    param_2 = FUN_00406db0();

    FUN_004449f0(&param_2,iVar3);

    uVar2 = FUN_00406db0();

    if (3 < uVar2) {

      iVar3 = FUN_00406db0(iVar3);

      iVar3 = FUN_00406d80(iVar3 + -4);

      FUN_00401590(iVar3 + 4);

      return;

    }

  }

  return;

}





// --- FUN_004f89f0 at 0x004F89F0 (size: 114) ---


void __thiscall FUN_004f89f0(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      }

      else {

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

      }

    }

  }

  FUN_0040ad10(8);

  puVar1 = (undefined4 *)FUN_0040acf0(8);

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

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

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

      puVar1[1] = *(undefined4 *)(param_1 + 0xc);

      return;

    }

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

    *(undefined4 *)(param_1 + 0xc) = puVar1[1];

  }

  return;

}





// --- FUN_004f8a70 at 0x004F8A70 (size: 140) ---


void __thiscall FUN_004f8a70(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      }

      else {

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

      }

    }

  }

  FUN_0040ad10(8);

  puVar1 = (undefined4 *)FUN_0040acf0(8);

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

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

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

      puVar1[1] = *(undefined4 *)(param_1 + 0xc);

      FUN_004449f0(param_1 + 0x10,param_2);

      return;

    }

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

    *(undefined4 *)(param_1 + 0xc) = puVar1[1];

  }

  FUN_004449f0(param_1 + 0x10,param_2);

  return;

}





// --- FUN_004f8b00 at 0x004F8B00 (size: 66) ---


undefined1 __thiscall

FUN_004f8b00(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  undefined1 uVar1;

  

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

  uVar1 = FUN_00671b60(param_2,param_3,param_4,param_5);

  FUN_0065e910();

  return uVar1;

}





// --- FUN_004f8b50 at 0x004F8B50 (size: 61) ---


undefined1 __thiscall

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



{

  undefined1 uVar1;

  

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

  uVar1 = FUN_00672060(param_2,param_3,param_4);

  FUN_0065e910();

  return uVar1;

}





// --- FUN_004f8b90 at 0x004F8B90 (size: 56) ---


undefined1 __thiscall FUN_004f8b90(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined1 uVar1;

  

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

  uVar1 = FUN_00671d00(param_2,param_3);

  FUN_0065e910();

  return uVar1;

}





// --- FUN_004f8bd0 at 0x004F8BD0 (size: 56) ---


undefined1 __thiscall FUN_004f8bd0(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined1 uVar1;

  

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

  uVar1 = FUN_006722b0(param_2,param_3);

  FUN_0065e910();

  return uVar1;

}





// --- FUN_004f8c10 at 0x004F8C10 (size: 26) ---


void __fastcall FUN_004f8c10(int param_1)



{

  if ((*(uint *)(param_1 + 8) & 0x80000000) == 0x80000000) {

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

  }

  return;

}





// --- FUN_004f8c30 at 0x004F8C30 (size: 26) ---


void __fastcall FUN_004f8c30(int param_1)



{

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

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

  }

  return;

}





// --- FUN_004f8cb0 at 0x004F8CB0 (size: 53) ---


void __thiscall FUN_004f8cb0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

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

    (**(code **)(**(int **)(*(int *)(param_1 + 0x1d4) + -4 + iVar1 * 4) + 8))(param_2,param_3);

  }

  return;

}





// --- FUN_004f8d10 at 0x004F8D10 (size: 75) ---


void __fastcall FUN_004f8d10(int param_1)



{

  if (((*(uint *)(param_1 + 0x24) & 0x80000000) == 0x80000000) && (*(int *)(param_1 + 0x20) != 0)) {

    operator_delete__((void *)(*(int *)(param_1 + 0x20) + -4));

  }

  if (((*(uint *)(param_1 + 0x18) & 0x80000000) == 0x80000000) && (*(int *)(param_1 + 0x14) != 0)) {

    operator_delete__((void *)(*(int *)(param_1 + 0x14) + -4));

  }

  return;

}





// --- FUN_004f8d60 at 0x004F8D60 (size: 40) ---


undefined4 * __fastcall FUN_004f8d60(undefined4 *param_1)



{

  FUN_00671f80();

  *param_1 = &PTR_FUN_007c6860;

  FUN_0065e8b0();

  FUN_00670fc0();

  return param_1;

}





// --- FUN_004f8d90 at 0x004F8D90 (size: 4) ---


undefined4 __fastcall FUN_004f8d90(int param_1)



{

  return *(undefined4 *)(param_1 + 8);

}





// --- FUN_004f8da0 at 0x004F8DA0 (size: 4) ---


undefined4 __fastcall FUN_004f8da0(int param_1)



{

  return *(undefined4 *)(param_1 + 0xc);

}





// --- FUN_004f8e10 at 0x004F8E10 (size: 25) ---


undefined4 __thiscall FUN_004f8e10(int param_1,undefined4 param_2)



{

  FUN_004139a0(param_1 + 0x73c);

  return param_2;

}





// --- FUN_004f8e50 at 0x004F8E50 (size: 54) ---


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



{

  FUN_004f8c10();

  FUN_0065e8d0();

  FUN_00671fe0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f8f80 at 0x004F8F80 (size: 212) ---


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



{

  uint uVar1;

  int iVar2;

  uint *puVar3;

  

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

    FUN_004f8d10();

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

      operator_delete(param_1);

    }

    return param_1;

  }

  iVar2 = *(int *)((int)param_1 + -4);

  if (-1 < iVar2 + -1) {

    puVar3 = (uint *)((int)param_1 + iVar2 * 0x30 + 0x18);

    do {

      if (((puVar3[-9] & 0x80000000) == 0x80000000) && (uVar1 = puVar3[-10], uVar1 != 0)) {

        FUN_00401030(uVar1,8,*(undefined4 *)(uVar1 - 4),FUN_00695670);

        operator_delete__((void *)(uVar1 - 4));

      }

      if (((puVar3[-0xc] & 0x80000000) == 0x80000000) && (uVar1 = puVar3[-0xd], uVar1 != 0)) {

        FUN_00401030(uVar1,8,*(undefined4 *)(uVar1 - 4),FUN_00695670);

        operator_delete__((void *)(uVar1 - 4));

      }

      iVar2 = iVar2 + -1;

      puVar3 = puVar3 + -0xc;

    } while (iVar2 != 0);

  }

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

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

  }

  return (void *)((int)param_1 + -4);

}





// --- FUN_004f9060 at 0x004F9060 (size: 143) ---


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



{

  uint *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

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

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

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

    }

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

      operator_delete(param_1);

    }

    return param_1;

  }

  iVar2 = *(int *)((int)param_1 + -4);

  if (-1 < iVar2 + -1) {

    puVar3 = (undefined4 *)((int)param_1 + iVar2 * 0x28 + 0x14);

    do {

      puVar1 = puVar3 + -9;

      puVar3 = puVar3 + -10;

      if ((*puVar1 & 0x80000000) == 0x80000000) {

        operator_delete__((void *)*puVar3);

      }

      iVar2 = iVar2 + -1;

    } while (iVar2 != 0);

  }

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

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

  }

  return (void *)((int)param_1 + -4);

}





// --- FUN_004f90f0 at 0x004F90F0 (size: 153) ---


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



{

  int iVar1;

  char cVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  uint uVar6;

  

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

    param_1[2] = 0;

    cVar2 = FUN_0044b740(param_2[1] & 0x7fffffff);

    if (cVar2 == '\0') {

      return param_1;

    }

  }

  puVar3 = (undefined4 *)*param_2;

  puVar4 = puVar3 + param_2[2] * 2;

  puVar5 = (undefined4 *)*param_1;

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

    *puVar5 = *puVar3;

    puVar5[1] = puVar3[1];

    puVar5 = puVar5 + 2;

  }

  uVar6 = param_2[2];

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

    puVar4 = (undefined4 *)FUN_0050a140();

    do {

      iVar1 = *param_1;

      *(undefined4 *)(iVar1 + uVar6 * 8) = *puVar4;

      *(undefined4 *)(iVar1 + 4 + uVar6 * 8) = puVar4[1];

      uVar6 = uVar6 + 1;

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

  }

  param_1[2] = param_2[2];

  return param_1;

}





// --- FUN_004f9190 at 0x004F9190 (size: 202) ---


void __thiscall FUN_004f9190(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      }

      else {

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

      }

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

    }

    else {

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

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

    }

    else {

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

    }

  }

  FUN_0040ad10(4);

  puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      FUN_0042fc00(param_2);

      return;

    }

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

  }

  FUN_0042fc00(param_2);

  return;

}





// --- FUN_004f9260 at 0x004F9260 (size: 108) ---


byte __thiscall FUN_004f9260(int *param_1,undefined4 param_2)



{

  byte bVar1;

  byte bVar2;

  undefined *puStack_20;

  undefined *puStack_1c;

  undefined4 uStack_14;

  int *piStack_10;

  

  piStack_10 = (int *)param_2;

  uStack_14 = 0x4f926f;

  bVar1 = FUN_006723d0();

  bVar2 = 0;

  if (bVar1 != 0) {

    piStack_10 = param_1 + 0x1dd;

    uStack_14 = 0x4f9283;

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

    bVar2 = bVar1 & bVar2;

    if (bVar2 == 0) {

      uStack_14 = 0;

      puStack_1c = &DAT_00795320;

      puStack_20 = (undefined *)0x4f9296;

      FUN_00402730();

      puStack_20 = &DAT_00795320;

      FUN_00402730();

      FUN_00403350(&puStack_20,0);

      FUN_0043d090(0xce);

      uStack_14 = 0x4f92c4;

      FUN_00671360();

    }

  }

  return bVar2;

}





// --- FUN_004f9ae0 at 0x004F9AE0 (size: 57) ---


int __thiscall FUN_004f9ae0(int param_1,int param_2)



{

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

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

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

  FUN_004f90f0(param_2 + 0x14);

  FUN_004f90f0(param_2 + 0x20);

  return param_1;

}





// --- FUN_004f9b20 at 0x004F9B20 (size: 30) ---


void __fastcall FUN_004f9b20(int param_1)



{

  if (((*(uint *)(param_1 + 0x10) & 0x80000000) == 0x80000000) && (*(int *)(param_1 + 0xc) != 0)) {

    FUN_004f8f80(3);

  }

  return;

}





// --- FUN_004f9c70 at 0x004F9C70 (size: 61) ---


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



{

  *param_1 = &PTR_FUN_007c6854;

  FUN_00524910();

  *param_1 = &PTR_FUN_007c7450;

  if (param_1[5] == 0) {

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

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f9cb0 at 0x004F9CB0 (size: 61) ---


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



{

  *param_1 = &PTR_FUN_007c6858;

  FUN_00524910();

  *param_1 = &PTR_FUN_007c7450;

  if (param_1[5] == 0) {

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

  }

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f9cf0 at 0x004F9CF0 (size: 143) ---


undefined4 * __thiscall FUN_004f9cf0(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_007c6838;

  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_004f9d80 at 0x004F9D80 (size: 143) ---


undefined4 * __thiscall FUN_004f9d80(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_007c683c;

  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_004f9e10 at 0x004F9E10 (size: 143) ---


undefined4 * __thiscall FUN_004f9e10(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_007c6834;

  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_004f9ea0 at 0x004F9EA0 (size: 208) ---


void __fastcall FUN_004f9ea0(int *param_1)



{

  int iVar1;

  int iVar2;

  uint local_34;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  

  param_1[2] = 0;

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

    if (*param_1 != 0) {

      local_34 = param_1[1] & 0x7fffffff;

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

        iVar1 = (local_34 - 1) * 0x30;

        do {

          iVar2 = *param_1 + iVar1;

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

          *(undefined4 *)(iVar2 + 0x10) = local_20;

          local_1c = 0;

          local_18 = 0;

          local_14 = 0;

          local_10 = 0;

          local_c = 0;

          local_8 = 0;

          *(undefined4 *)(iVar2 + 0xc) = local_24;

          FUN_004f90f0(&local_1c);

          FUN_004f90f0(&local_10);

          FUN_004f8d10();

          iVar1 = iVar1 + -0x30;

          local_34 = local_34 - 1;

        } while (local_34 != 0);

      }

    }

    return;

  }

  if (*param_1 != 0) {

    FUN_004f8f80(3);

  }

  *param_1 = 0;

  param_1[1] = 0;

  return;

}





// --- FUN_004f9f80 at 0x004F9F80 (size: 36) ---


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



{

  *param_1 = &PTR_FUN_007c6918;

  FUN_0049f850();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004f9fb0 at 0x004F9FB0 (size: 203) ---


undefined4 __thiscall FUN_004f9fb0(int *param_1,uint param_2)



{

  uint *puVar1;

  uint uVar2;

  uint *puVar3;

  int iVar4;

  

  uVar2 = param_2;

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

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

      return 1;

    }

    if (param_2 == 0) {

      FUN_004f9ea0();

      return 1;

    }

    puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 0x30 + 4);

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

      puVar1 = puVar3 + 1;

      *puVar3 = param_2;

      FUN_00401000(puVar1,0x30,param_2,&LAB_004f8cf0);

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

        if (*param_1 != 0) {

          param_2 = param_1[2];

          if (-1 < (int)(param_2 + -1)) {

            iVar4 = (param_2 + -1) * 0x30;

            do {

              FUN_004f9ae0(*param_1 + iVar4);

              iVar4 = iVar4 + -0x30;

              param_2 = param_2 + -1;

            } while (param_2 != 0);

          }

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

            FUN_004f8f80(3);

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = uVar2 | 0x80000000;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004fa080 at 0x004FA080 (size: 446) ---


undefined4 * __fastcall FUN_004fa080(undefined4 *param_1)



{

  undefined4 uVar1;

  uint uVar2;

  uint uVar3;

  

  FUN_00415460(DAT_008423b4);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6930;

  param_1[0xc] = &PTR_LAB_007c691c;

  param_1[0xe] = &PTR_FUN_007c7450;

  param_1[0x13] = 0;

  uVar1 = thunk_FUN_005df0f5(0x100);

  param_1[0x11] = uVar1;

  param_1[0x12] = 0x40;

  param_1[0x10] = 8;

  param_1[0xf] = 0;

  uVar2 = 1;

  do {

    uVar3 = param_1[0xf] | uVar2;

    uVar2 = uVar2 << 1;

    param_1[0xf] = uVar3;

  } while ((uVar3 | uVar2) < (uint)param_1[0x12]);

  uVar2 = 0;

  do {

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

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[0x12]);

  param_1[0xe] = &PTR_FUN_007c6854;

  param_1[0x14] = &PTR_FUN_007c7450;

  param_1[0x19] = 0;

  uVar1 = thunk_FUN_005df0f5(0x100);

  param_1[0x17] = uVar1;

  param_1[0x18] = 0x40;

  param_1[0x16] = 8;

  param_1[0x15] = 0;

  uVar2 = 1;

  do {

    uVar3 = param_1[0x15] | uVar2;

    uVar2 = uVar2 << 1;

    param_1[0x15] = uVar3;

  } while ((uVar3 | uVar2) < (uint)param_1[0x18]);

  uVar2 = 0;

  do {

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

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[0x18]);

  param_1[0x14] = &PTR_FUN_007c7450;

  param_1[0x1a] = &PTR_FUN_007c7450;

  param_1[0x1f] = 0;

  uVar1 = thunk_FUN_005df0f5(0x40);

  param_1[0x1d] = uVar1;

  param_1[0x1e] = 0x10;

  param_1[0x1c] = 8;

  param_1[0x1b] = 0;

  uVar2 = 1;

  do {

    uVar3 = param_1[0x1b] | uVar2;

    uVar2 = uVar2 << 1;

    param_1[0x1b] = uVar3;

  } while ((uVar3 | uVar2) < (uint)param_1[0x1e]);

  uVar2 = 0;

  do {

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

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[0x1e]);

  param_1[0x1a] = &PTR_FUN_007c7450;

  param_1[0x20] = &PTR_FUN_007c7450;

  param_1[0x25] = 0;

  uVar1 = thunk_FUN_005df0f5(0x100);

  param_1[0x23] = uVar1;

  param_1[0x24] = 0x40;

  param_1[0x22] = 8;

  param_1[0x21] = 0;

  uVar2 = 1;

  do {

    uVar3 = param_1[0x21] | uVar2;

    uVar2 = uVar2 << 1;

    param_1[0x21] = uVar3;

  } while ((uVar3 | uVar2) < (uint)param_1[0x24]);

  uVar2 = 0;

  do {

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

    uVar2 = uVar2 + 1;

  } while (uVar2 < (uint)param_1[0x24]);

  param_1[0x20] = &PTR_FUN_007c6858;

  return param_1;

}





// --- FUN_004fa250 at 0x004FA250 (size: 30) ---


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



{

  FUN_00524b50();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fa350 at 0x004FA350 (size: 319) ---


undefined4 __thiscall FUN_004fa350(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_004fa350(*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_004fa39f;

      }

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

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

    }

    piVar10 = (int *)0x0;

    piVar8 = (int *)0x0;

LAB_004fa39f:

    piVar6 = (int *)*piVar10;

    if (piVar6 == piVar8) {

LAB_004fa3b2:

      *piVar10 = piVar6[2];

    }

    else {

      do {

        piVar5 = piVar6;

        piVar6 = (int *)piVar5[2];

      } while (piVar6 != piVar8);

      if (piVar5 == (int *)0x0) goto LAB_004fa3b2;

      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_004fa490 at 0x004FA490 (size: 303) ---


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



{

  char cVar1;

  uint uVar2;

  int iVar3;

  undefined4 *puVar4;

  uint uVar5;

  int iVar6;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  

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

    param_1[2] = 0;

    cVar1 = FUN_004f9fb0(param_2[1] & 0x7fffffff);

    if (cVar1 == '\0') {

      return param_1;

    }

  }

  uVar5 = *param_2;

  uVar2 = param_2[2] * 0x30 + uVar5;

  if (uVar5 < uVar2) {

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

    do {

      puVar4[-2] = *(undefined4 *)(uVar5 + 8);

      puVar4[-1] = *(undefined4 *)(uVar5 + 0xc);

      *puVar4 = *(undefined4 *)(uVar5 + 0x10);

      FUN_004f90f0(uVar5 + 0x14);

      FUN_004f90f0(uVar5 + 0x20);

      uVar5 = uVar5 + 0x30;

      puVar4 = puVar4 + 0xc;

    } while (uVar5 < uVar2);

  }

  uVar5 = param_2[2];

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

    iVar3 = uVar5 * 0x30;

    do {

      iVar6 = *param_1 + iVar3;

      *(undefined4 *)(iVar6 + 8) = local_28;

      *(undefined4 *)(iVar6 + 0x10) = local_20;

      local_1c = 0;

      local_18 = 0;

      local_14 = 0;

      local_10 = 0;

      local_c = 0;

      local_8 = 0;

      *(undefined4 *)(iVar6 + 0xc) = local_24;

      FUN_004f90f0(&local_1c);

      FUN_004f90f0(&local_10);

      uVar5 = uVar5 + 1;

      iVar3 = iVar3 + 0x30;

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

  }

  param_1[2] = param_2[2];

  return param_1;

}





// --- FUN_004fa5c0 at 0x004FA5C0 (size: 158) ---


void __fastcall FUN_004fa5c0(int param_1)



{

  FUN_0065eb00();

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

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

  FUN_0065e8d0();

  *(undefined ***)(param_1 + 0x198) = &PTR_FUN_007c6918;

  FUN_0049f850();

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

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

  FUN_0065e8d0();

  *(undefined ***)(param_1 + 0x150) = &PTR_FUN_007c6918;

  FUN_0049f850();

  if (param_1 != 0) {

    FUN_0065e960();

    FUN_004151b0();

    return;

  }

  FUN_0065e960();

  FUN_004151b0();

  return;

}





// --- FUN_004fa660 at 0x004FA660 (size: 124) ---


void __thiscall FUN_004fa660(int param_1,int param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  *(undefined4 *)(param_1 + 500) = 2;

  FUN_004fa490(param_2 + 0xc);

  iVar1 = *(int *)(param_2 + 8) - *(int *)(param_1 + 0x2f8);

  if (iVar1 != 0) {

    FUN_004f8cb0(3,iVar1);

  }

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

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

    puVar2[1] = 1;

    puVar2[2] = 0;

    puVar2[6] = 0;

    puVar2[7] = 0;

    puVar2[8] = 0;

    puVar2[9] = 0;

    *puVar2 = &PTR_FUN_007c6840;

    puVar2[3] = 3;

  }

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

                    /* WARNING: Treating indirect jump as call */

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

  return;

}





// --- FUN_004fa6e0 at 0x004FA6E0 (size: 81) ---


void __thiscall FUN_004fa6e0(int param_1,int param_2)



{

  undefined4 *puVar1;

  

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

    FUN_0040ad10(4);

    puVar1 = (undefined4 *)FUN_0040acf0(4);

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

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

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

      }

      else {

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

      }

    }

  }

  FUN_004449f0(param_1 + 8,param_2);

  FUN_004fa740(param_2);

  return;

}





// --- FUN_004fa740 at 0x004FA740 (size: 140) ---


void __thiscall FUN_004fa740(int *param_1,int param_2)



{

  uint *puVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  uVar3 = param_1[2];

  FUN_0040ad10(4);

  puVar1 = (uint *)FUN_0040acf0(4);

  iVar4 = 0;

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

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

      uVar3 = *puVar1;

    }

    else {

      *puVar1 = uVar3;

    }

  }

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

    uVar2 = FUN_0040a8f0();

    if (uVar2 < uVar3) {

      FUN_0040aa50();

      return;

    }

    param_1[2] = 0;

    FUN_004fa7d0(uVar3,1);

  }

  uVar3 = 0;

  if (param_1[2] != 0) {

    do {

      (*(code *)**(undefined4 **)(*param_1 + iVar4))(param_2);

      uVar3 = uVar3 + 1;

      iVar4 = iVar4 + 0x30;

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

  }

  return;

}





// --- FUN_004fa7d0 at 0x004FA7D0 (size: 214) ---


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



{

  char cVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  

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

    uVar2 = param_2;

    if (param_3 == '\0') {

      uVar2 = FUN_00453850(param_2);

    }

    cVar1 = FUN_004f9fb0(uVar2);

    if (cVar1 == '\0') {

      return 0;

    }

  }

  else {

    _param_3 = param_2;

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

      iVar3 = param_2 * 0x30;

      do {

        iVar4 = *param_1 + iVar3;

        *(undefined4 *)(iVar4 + 8) = local_28;

        local_1c = 0;

        local_18 = 0;

        local_14 = 0;

        local_10 = 0;

        local_c = 0;

        local_8 = 0;

        *(undefined4 *)(iVar4 + 0xc) = local_24;

        *(undefined4 *)(iVar4 + 0x10) = local_20;

        FUN_004f90f0(&local_1c);

        FUN_004f90f0(&local_10);

        _param_3 = _param_3 + 1;

        iVar3 = iVar3 + 0x30;

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

    }

  }

  param_1[2] = param_2;

  return 1;

}





// --- FUN_004fa8b0 at 0x004FA8B0 (size: 1332) ---


undefined1 __thiscall

FUN_004fa8b0(int *param_1,int *param_2,undefined1 param_3,undefined4 param_4,char param_5,

            undefined4 param_6,int param_7,int param_8)



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  undefined4 uVar4;

  char cVar5;

  undefined1 uVar6;

  byte bVar7;

  uint uVar8;

  int *piVar9;

  LONG LVar10;

  undefined4 *puVar11;

  int iVar12;

  int iVar13;

  code *pcVar14;

  bool bVar15;

  longlong lVar16;

  undefined8 uVar17;

  undefined *puVar18;

  undefined4 uVar19;

  undefined4 uStack_48;

  uint local_40;

  int *piStack_3c;

  int iStack_38;

  undefined *local_34;

  undefined *local_30;

  undefined *local_2c;

  int iStack_28;

  int iStack_24;

  undefined4 uStack_20;

  undefined4 uStack_1c;

  uint uStack_18;

  undefined4 uStack_14;

  undefined4 uStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  undefined1 uStack_4;

  

  FUN_004141e0(0,&PTR_DAT_008183b4);

  *(undefined1 *)(param_1 + 0x7b) = param_3;

  *(undefined1 *)((int)param_1 + 0x1ed) = (undefined1)param_6;

  if ((param_1[0x79] & 0x7fffffffU) < 4) {

    cVar5 = FUN_004180a0(4);

    if (cVar5 == '\0') goto LAB_004fa934;

  }

  else {

    uVar8 = 4;

    if (4 < (uint)param_1[0x7a]) {

      do {

        *(undefined4 *)(param_1[0x78] + uVar8 * 4) = 0;

        uVar8 = uVar8 + 1;

      } while (uVar8 < (uint)param_1[0x7a]);

    }

  }

  param_1[0x7a] = 4;

LAB_004fa934:

  param_1[0x7d] = 0;

  uVar8 = 0;

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

    do {

      *(undefined4 *)(param_1[0x78] + uVar8 * 4) = 0;

      uVar8 = uVar8 + 1;

    } while (uVar8 < (uint)param_1[0x7a]);

  }

  local_34 = PTR_DAT_00818340;

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

  local_30 = PTR_DAT_00818344;

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

  local_2c = PTR_DAT_00818344;

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

  uVar19 = 1;

  puVar18 = PTR_DAT_008183b4;

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

  iVar13 = *param_2;

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

  cVar5 = FUN_00672b70(iVar13,puVar18,uVar19);

  uStack_48 = (int *)CONCAT13(cVar5,(undefined3)uStack_48);

  piVar9 = (int *)FUN_006727f0(&local_40);

  iVar13 = param_1[0xc1];

  if (iVar13 != *piVar9) {

    LVar10 = InterlockedDecrement((LONG *)(iVar13 + -0x10));

    if ((LVar10 == 0) && ((undefined4 *)(iVar13 + -0x14) != (undefined4 *)0x0)) {

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

    }

    iVar13 = *piVar9;

    param_1[0xc1] = iVar13;

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

  }

  LVar10 = InterlockedDecrement((LONG *)(local_40 - 0x10));

  if ((LVar10 == 0) && ((undefined4 *)(local_40 - 0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_40 - 0x14))(1);

  }

  uVar4 = DAT_008185f0;

  uVar19 = DAT_008185e8;

  local_40 = (param_5 != '\0') + 2;

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

    local_40 = local_40 & 0xfffffffb;

  }

  else {

    local_40 = local_40 | 4;

  }

  uVar6 = *(undefined1 *)((int)param_1 + 0x1ed);

  piStack_3c = (int *)FUN_006727f0(&iStack_38);

  iStack_28 = *param_2;

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

  iStack_24 = *piStack_3c;

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

  pcVar14 = InterlockedDecrement_exref;

  uStack_c = uVar19;

  uStack_20 = 1;

  uStack_1c = 0;

  uStack_18 = local_40;

  uStack_14 = 0;

  uStack_10 = 0;

  uStack_8 = uVar4;

  uStack_4 = uVar6;

  LVar10 = InterlockedDecrement((LONG *)(iStack_38 + -0x10));

  if ((LVar10 == 0) && ((undefined4 *)(iStack_38 + -0x14) != (undefined4 *)0x0)) {

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

  }

  if (cVar5 != '\0') {

    puVar11 = (undefined4 *)FUN_005df0f5(0x788);

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

      puVar11 = (undefined4 *)0x0;

    }

    else {

      FUN_00671f80();

      *puVar11 = &PTR_FUN_007c6860;

      FUN_0065e8b0();

      FUN_00670fc0();

    }

    *(undefined4 **)param_1[0x78] = puVar11;

    piVar9 = *(int **)param_1[0x78];

    uStack_48 = (int *)CONCAT13(piVar9 != (int *)0x0,(undefined3)uStack_48);

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

      cVar5 = (**(code **)(*piVar9 + 4))(&iStack_28);

      uStack_48 = (int *)CONCAT13(cVar5,(undefined3)uStack_48);

      if (cVar5 != '\0') {

        puVar11 = (undefined4 *)FUN_005df0f5(0x788);

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

          puVar11 = (undefined4 *)0x0;

        }

        else {

          FUN_00671f80();

          *puVar11 = &PTR_FUN_007c6860;

          FUN_0065e8b0();

          FUN_00670fc0();

        }

        *(undefined4 **)(param_1[0x78] + 0xc) = puVar11;

        bVar15 = *(int *)(param_1[0x78] + 0xc) != 0;

        uStack_48 = (int *)CONCAT13(bVar15,(undefined3)uStack_48);

        if (bVar15) {

          puVar11 = (undefined4 *)(**(code **)(**(int **)param_1[0x78] + 0x48))(&iStack_38);

          FUN_00413b60(&local_40,*puVar11);

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

          if (param_8 != 0) {

            uVar6 = (**(code **)(*param_1 + 0x40))(param_8);

            uStack_48 = (int *)CONCAT13(uVar6,(undefined3)uStack_48);

          }

          if ((uStack_48._3_1_ != '\0') && (param_7 != 0)) {

            bVar7 = (**(code **)(*param_1 + 0x4c))(param_7,param_6);

            uStack_48 = (int *)((uint)bVar7 << 0x18);

          }

        }

      }

    }

  }

  local_40 = 0;

  do {

    uVar8 = local_40;

    if ((*(int **)(local_40 + param_1[0x78]) != (int *)0x0) &&

       (lVar16 = (**(code **)(**(int **)(local_40 + param_1[0x78]) + 0x38))(), lVar16 != 0)) {

      uVar17 = (**(code **)(**(int **)(uVar8 + param_1[0x78]) + 0x38))();

      iVar13 = param_1[0x78];

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

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

        piVar9 = (int *)0x0;

      }

      else {

        *(undefined8 *)piVar9 = uVar17;

        piVar9[2] = 0;

        piVar9[4] = *(int *)(iVar13 + uVar8);

      }

      iVar13 = piVar9[1];

      iVar2 = *piVar9;

      iVar12 = __aullrem(iVar2,iVar13,param_1[0xb9],0);

      piVar1 = (int *)(param_1[0xb7] + iVar12 * 4);

      for (piVar3 = (int *)*piVar1; piVar3 != (int *)0x0; piVar3 = (int *)piVar3[2]) {

        if ((*piVar3 == iVar2) && (piVar3[1] == iVar13)) {

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

            operator_delete(piVar9);

            uVar8 = local_40;

            pcVar14 = InterlockedDecrement_exref;

            goto LAB_004fad25;

          }

          break;

        }

      }

      piVar9[2] = *piVar1;

      *piVar1 = (int)piVar9;

      if (piVar1 < (int *)param_1[0xb8]) {

        param_1[0xb8] = (int)piVar1;

      }

      param_1[0xba] = param_1[0xba] + 1;

      uVar8 = local_40;

      pcVar14 = InterlockedDecrement_exref;

    }

LAB_004fad25:

    local_40 = uVar8 + 4;

    if (0xf < (int)local_40) {

      DAT_00837ba8 = uStack_48._3_1_;

      FUN_0065e9a0();

      puVar11 = (undefined4 *)(iStack_24 + -0x14);

      iVar13 = (*pcVar14)(iStack_24 + -0x10);

      if ((iVar13 == 0) && (puVar11 != (undefined4 *)0x0)) {

        (**(code **)*puVar11)(1);

      }

      puVar11 = (undefined4 *)(local_2c + -0x14);

      iVar13 = (*pcVar14)(local_2c + -0x10);

      if ((iVar13 == 0) && (puVar11 != (undefined4 *)0x0)) {

        (**(code **)*puVar11)(1);

      }

      puVar11 = (undefined4 *)(local_34 + -0x14);

      iVar13 = (*pcVar14)(local_34 + -0x10);

      if ((iVar13 == 0) && (puVar11 != (undefined4 *)0x0)) {

        (**(code **)*puVar11)(1);

      }

      piVar9 = piStack_3c + -5;

      iVar13 = (*pcVar14)(piStack_3c + -4);

      if ((iVar13 == 0) && (piVar9 != (int *)0x0)) {

        (**(code **)*piVar9)(1);

      }

      iVar13 = (*pcVar14)(param_1 + -4);

      if ((iVar13 == 0) && (param_1 + -5 != (int *)0x0)) {

        (**(code **)param_1[-5])(1);

      }

      return uStack_48._3_1_;

    }

  } while( true );

}





// --- FUN_004fadf0 at 0x004FADF0 (size: 385) ---


void __fastcall FUN_004fadf0(int param_1)



{

  char cVar1;

  undefined4 uVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  int iVar7;

  undefined4 uVar8;

  undefined4 uVar9;

  int local_40;

  undefined8 local_3c;

  undefined *local_34;

  undefined *local_30;

  undefined *local_2c;

  

  if (*(int *)(*(int *)(param_1 + 0x1e0) + 0xc) != 0) {

    FUN_00401340();

    local_34 = PTR_DAT_00818340;

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

    local_30 = PTR_DAT_00818344;

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

    local_2c = PTR_DAT_00818344;

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

    InterlockedIncrement((LONG *)(*(int *)(param_1 + 0x304) + -0x10));

    FUN_00403350(&stack0xffffffa8,0);

    cVar1 = FUN_00672900();

    if (cVar1 != '\0') {

      iVar7 = (uint)(*(char *)(param_1 + 0x1ec) != '\0') * 4 + 2;

      uVar9 = 0;

      uVar8 = 0;

      uVar6 = 0x69466948;

      uVar5 = 1;

      uVar2 = FUN_006727f0(&local_3c);

      FUN_004f8720(&local_40,uVar2,uVar5,uVar6,iVar7,uVar8,uVar9);

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

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

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

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

      }

      cVar1 = (**(code **)(**(int **)(*(int *)(param_1 + 0x1e0) + 0xc) + 4))();

      if (cVar1 != '\0') {

        local_3c = (**(code **)(**(int **)(*(int *)(param_1 + 0x1e0) + 0xc) + 0x38))();

        FUN_00694490();

      }

      FUN_004374c0();

    }

    FUN_00493530();

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

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

      (*(code *)**(undefined4 **)(local_40 + -0x14))();

    }

  }

  return;

}





// --- FUN_004faf80 at 0x004FAF80 (size: 515) ---


/* WARNING: Removing unreachable block (ram,0x004fb0eb) */

/* WARNING: Removing unreachable block (ram,0x004fb093) */

/* WARNING: Removing unreachable block (ram,0x004fb09b) */

/* WARNING: Removing unreachable block (ram,0x004fb0aa) */

/* WARNING: Removing unreachable block (ram,0x004fb0b0) */

/* WARNING: Removing unreachable block (ram,0x004fb0be) */

/* WARNING: Removing unreachable block (ram,0x004fb0c9) */

/* WARNING: Removing unreachable block (ram,0x004fb0cc) */

/* WARNING: Removing unreachable block (ram,0x004fb0f7) */

/* WARNING: Removing unreachable block (ram,0x004fb106) */

/* WARNING: Removing unreachable block (ram,0x004fb110) */

/* WARNING: Removing unreachable block (ram,0x004fb11e) */

/* WARNING: Removing unreachable block (ram,0x004fb129) */

/* WARNING: Removing unreachable block (ram,0x004fb12c) */



void __thiscall FUN_004faf80(int *param_1,int param_2)



{

  char cVar1;

  char cVar2;

  undefined4 uVar3;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  uint uVar4;

  undefined8 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  

  uVar4 = 0;

  param_1[0x7d] = 1;

  param_1[0xbd] = 0;

  param_1[0xbe] = 0;

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

    FUN_004fadf0();

  }

  param_1[0x7c] = *(int *)(param_2 + 8);

  cVar1 = (**(code **)(*param_1 + 0x40))(*(undefined4 *)(param_2 + 8));

  if (cVar1 == '\0') {

    uVar8 = 0;

    uVar7 = extraout_ECX;

    FUN_00402730(&DAT_00795320);

    uVar6 = extraout_ECX_00;

    FUN_00402730(&DAT_00795320);

    uVar3 = extraout_ECX_01;

    FUN_00402730(&DAT_00795320);

    FUN_0043d090(0xc9,uVar3,uVar6,uVar7,uVar8);

    FUN_00405eb0();

  }

  else {

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

      do {

        cVar2 = (**(code **)(**(int **)(param_1[0x78] + uVar4 * 4) + 0x3c))();

        if (cVar2 != '\0') {

          uVar5 = (**(code **)(**(int **)(param_1[0x78] + uVar4 * 4) + 0x38))();

          uVar3 = FUN_00679100(uVar5);

          cVar2 = (**(code **)(**(int **)(param_1[0x78] + uVar4 * 4) + 0x28))(uVar3);

          if (cVar2 == '\0') {

            cVar1 = '\0';

          }

        }

        uVar4 = uVar4 + 1;

      } while (uVar4 < (uint)param_1[0x7a]);

    }

    FUN_00413b00();

    param_1[0xbf] = *(int *)(param_2 + 0xc);

    if (cVar1 != '\0') {

      FUN_004f85b0(&stack0x00000000,&stack0xffffffcc);

    }

  }

  return;

}





// --- FUN_004fb190 at 0x004FB190 (size: 58) ---


void __fastcall FUN_004fb190(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c6990;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007c683c;

  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_004fb1d0 at 0x004FB1D0 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007c698c;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_007c6838;

  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_004fb230 at 0x004FB230 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007c6990;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007c683c;

  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_004fb290 at 0x004FB290 (size: 444) ---


undefined4 __thiscall FUN_004fb290(undefined **param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  uint uVar5;

  int *piVar6;

  int *piVar7;

  uint uVar8;

  undefined **local_14;

  undefined4 local_10;

  undefined1 local_c [4];

  undefined4 uStack_8;

  int local_4;

  

  piVar7 = param_2;

  local_14 = param_1;

  FUN_00414190(local_c,param_2);

  if (local_4 == 0) {

    return 0;

  }

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

  uVar5 = 0;

  if (*(uint *)(iVar1 + 0x1c) != 0) {

    piVar6 = (int *)(*(int *)(iVar1 + 0x14) + 4);

    do {

      if (*piVar6 == piVar7[1]) {

        if (uVar5 != 0xffffffff) {

          if (uVar5 < *(uint *)(iVar1 + 0x1c)) {

            uVar8 = *(uint *)(iVar1 + 0x1c) - 1;

            *(uint *)(iVar1 + 0x1c) = uVar8;

            if (uVar5 != uVar8) {

              iVar2 = *(int *)(iVar1 + 0x14);

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

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

              iVar2 = *(int *)(iVar1 + 0x1c);

              iVar3 = *(int *)(iVar1 + 0x14);

              *(undefined ***)(iVar3 + iVar2 * 8) = local_14;

              *(undefined4 *)(iVar3 + 4 + iVar2 * 8) = local_10;

            }

          }

          if (*(int *)(iVar1 + 0x1c) == 0) {

            piVar6 = (int *)(**(code **)(param_1[1] + 0x98))

                                      (piVar7,*(undefined4 *)(iVar1 + 8),

                                       *(undefined4 *)(iVar1 + 0xc));

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

            (**(code **)(piVar6[0x1d4] + 4))();

            FUN_00671280(uStack_8);

            FUN_00670f20();

            (**(code **)(*piVar6 + 0x2c))(piVar6 + 0x1dd);

            FUN_0065e910();

            param_1 = local_14;

          }

        }

        break;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 2;

    } while (uVar5 < *(uint *)(iVar1 + 0x1c));

  }

  uVar5 = (uint)(piVar7[1] + *piVar7) % (uint)param_1[0x9c];

  piVar6 = *(int **)(param_1[0x9a] + uVar5 * 4);

  piVar4 = piVar6;

  do {

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

LAB_004fb400:

      if (param_1[0x9d] == (undefined *)0x0) {

        param_1[0x7d] = (undefined *)0x3;

        local_10 = 0xf7ea;

        local_14 = &PTR_FUN_007c6708;

        FUN_004f85b0(&param_2,&local_14);

      }

      return 1;

    }

    if ((*piVar4 == *piVar7) && (piVar4[1] == piVar7[1])) {

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

        if (piVar6 == piVar4) goto LAB_004fb3dd;

        do {

          piVar7 = piVar6;

          piVar6 = (int *)piVar7[2];

        } while (piVar6 != piVar4);

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

LAB_004fb3dd:

          *(int *)(param_1[0x9a] + uVar5 * 4) = piVar6[2];

        }

        else {

          piVar7[2] = piVar6[2];

        }

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

        operator_delete(piVar4);

      }

      goto LAB_004fb400;

    }

    piVar4 = (int *)piVar4[2];

  } while( true );

}





// --- FUN_004fb450 at 0x004FB450 (size: 141) ---


void __fastcall FUN_004fb450(int param_1)



{

  undefined4 local_10;

  undefined1 local_c [4];

  undefined **local_8;

  undefined4 local_4;

  

  FUN_004f9ea0();

  FUN_0041a390();

  FUN_0044b6c0();

  if (*(int *)(param_1 + 500) == 1) {

    *(undefined4 *)(param_1 + 500) = 3;

    local_4 = 0xf7ea;

    local_8 = &PTR_FUN_007c6708;

    FUN_004f85b0(local_c,&local_8);

  }

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

  local_10 = 0;

  FUN_00413a50(&local_10);

  FUN_004f8cb0(4,local_10);

  return;

}





// --- FUN_004fb820 at 0x004FB820 (size: 43) ---


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



{

  FUN_004fb190();

  FUN_00416710();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fb850 at 0x004FB850 (size: 4469) ---


void FUN_004fb850(void)



{

  char cVar1;

  int iVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7a70,1);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 1;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7a50,2);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 2;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7af0,3);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 3;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7b10,6);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 6;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7b50,7);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 7;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7b30,8);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 8;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7b70,10);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 10;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7b90,0xb);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0xb;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00444500,0xc);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0xc;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7bb0,0xd);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0xd;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004fa280,0xe);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0xe;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7bd0,0xf);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0xf;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7c00,0x10);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x10;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7c20,0x11);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x11;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7c40,0x12);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x12;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7c60,0x13);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x13;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7c80,0x14);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x14;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7ca0,0x15);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x15;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7d40,0x16);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x16;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7d60,0x18);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x18;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7d80,0x19);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x19;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7da0,0x1a);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1a;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7dc0,0x1b);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1b;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7de0,0x1c);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1c;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7e00,0x1d);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1d;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_0044c660,0x1e);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1e;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00449950,0x1f);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x1f;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004505a0,0x20);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x20;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_0044d3f0,0x21);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x21;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00445520,0x43);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x43;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7e20,0x22);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x22;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00459340,0x23);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x23;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_0041c0f0,0x24);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x24;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00430960,0x25);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x25;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00416850,0x26);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x26;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7e50,0x27);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x27;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004fb7e0,0x28);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x28;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7e70,0x29);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x29;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7e90,0x2a);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2a;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7eb0,0x2b);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2b;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f7ed0,0x2c);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2c;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_00428f50,0x2d);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2d;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f8270,0x2e);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2e;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004f8800,0x2f);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x2f;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(&LAB_004224d0,0x30);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x30;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  iVar2 = FUN_005df0f5(0x114);

  if (iVar2 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = FUN_004fd0a0(FUN_004f7ef0,0x31);

  }

  puVar4 = (undefined4 *)FUN_005df0f5(0xc);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    puVar4[2] = uVar3;

    *puVar4 = 0x31;

    puVar4[1] = 0;

  }

  cVar1 = FUN_0042bd40(puVar4);

  if ((cVar1 == '\0') && (puVar4 != (undefined4 *)0x0)) {

    operator_delete(puVar4);

  }

  return;

}





// --- FUN_004fc9d0 at 0x004FC9D0 (size: 442) ---


void __fastcall FUN_004fc9d0(undefined4 *param_1)



{

  LONG LVar1;

  uint uVar2;

  undefined4 *puVar3;

  

  *param_1 = &PTR_LAB_007c6a18;

  param_1[1] = &PTR_LAB_007e4258;

  param_1[0x4c] = &PTR_LAB_007c6a08;

  FUN_00415040();

  uVar2 = 0;

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

    do {

      puVar3 = *(undefined4 **)(param_1[0x78] + uVar2 * 4);

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

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

      }

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

      uVar2 = uVar2 + 1;

    } while (uVar2 < (uint)param_1[0x7a]);

  }

  puVar3 = (undefined4 *)(param_1[0xc1] + -0x14);

  param_1[0x7a] = 0;

  LVar1 = InterlockedDecrement((LONG *)(param_1[0xc1] + -0x10));

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

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

  }

  if (((param_1[0xbc] & 0x80000000) == 0x80000000) && (param_1[0xbb] != 0)) {

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

  }

  param_1[0x9e] = &PTR_FUN_007c698c;

  FUN_0041a390();

  param_1[0x9f] = &PTR_FUN_007c6838;

  if ((undefined4 *)param_1[0xb7] != param_1 + 0xa0) {

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

  }

  param_1[0xb7] = 0;

  param_1[0xb8] = 0;

  param_1[0xb9] = 0;

  param_1[0xba] = 0;

  param_1[0x81] = &PTR_FUN_007c6994;

  FUN_0041a390();

  param_1[0x82] = &PTR_FUN_007c6834;

  if ((undefined4 *)param_1[0x9a] != param_1 + 0x83) {

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

  }

  param_1[0x9a] = 0;

  param_1[0x9b] = 0;

  param_1[0x9c] = 0;

  param_1[0x9d] = 0;

  if (((param_1[0x7f] & 0x80000000) == 0x80000000) && (param_1[0x7e] != 0)) {

    FUN_004f8f80(3);

  }

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

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

  }

  uVar2 = 0;

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

    do {

      *(undefined4 *)(*(int *)(param_1[0x75] + uVar2 * 4) + 4) = 0;

      uVar2 = uVar2 + 1;

    } while (uVar2 < (uint)param_1[0x77]);

  }

  param_1[0x77] = 0;

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

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

  }

  FUN_004fa5c0();

  return;

}





// --- FUN_004fcf30 at 0x004FCF30 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007c6994;

  FUN_0041a390();

  param_1[1] = &PTR_FUN_007c6834;

  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_004fcf90 at 0x004FCF90 (size: 225) ---


undefined4 * __fastcall FUN_004fcf90(undefined4 *param_1)



{

  LONG *lpAddend;

  

  FUN_00678b50();

  param_1[0x75] = 0;

  param_1[0x76] = 0;

  param_1[0x77] = 0;

  *param_1 = &PTR_LAB_007c6a18;

  param_1[1] = &PTR_LAB_007e4258;

  param_1[0x4c] = &PTR_LAB_007c6a08;

  param_1[0x78] = 0;

  param_1[0x79] = 0;

  param_1[0x7a] = 0;

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

  param_1[0x7c] = 0;

  param_1[0x7e] = 0;

  param_1[0x7f] = 0;

  param_1[0x80] = 0;

  param_1[0x81] = &PTR_FUN_007c6994;

  FUN_004f9e10(0);

  param_1[0x81] = &PTR_FUN_007c6994;

  param_1[0x9e] = &PTR_FUN_007c698c;

  FUN_004f9cf0(0x17);

  param_1[0xbb] = 0;

  param_1[0xbc] = 0;

  param_1[0xbd] = 0;

  param_1[0xbf] = 1;

  param_1[0xc0] = 0;

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

  param_1[0xc1] = PTR_DAT_00818340;

  InterlockedIncrement(lpAddend);

  *(undefined1 *)((int)param_1 + 0x129) = 1;

  return param_1;

}





// --- FUN_004fd080 at 0x004FD080 (size: 30) ---


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



{

  FUN_004fc9d0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fd0a0 at 0x004FD0A0 (size: 32) ---


undefined4 * __thiscall FUN_004fd0a0(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00417510(param_2,param_3);

  *param_1 = &PTR_FUN_007c6a98;

  return param_1;

}





// --- thunk_FUN_00693860 at 0x004FD0C0 (size: 5) ---


undefined4 thunk_FUN_00693860(void)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  piVar2 = (int *)FUN_0043c680();

  iVar3 = (**(code **)(*piVar2 + 0x10))(0x186a9);

  if (iVar3 != 0) {

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

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

      piVar1 = (int *)*piVar2;

      piVar2 = (int *)piVar2[1];

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

        (**(code **)(*piVar1 + 0x14))(unaff_retaddr);

      }

    }

  }

  return 1;

}





// --- thunk_FUN_00693910 at 0x004FD0D0 (size: 5) ---


undefined4 thunk_FUN_00693910(undefined4 param_1)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  piVar2 = (int *)FUN_0043c680();

  iVar3 = (**(code **)(*piVar2 + 0x10))(0x186aa);

  if (iVar3 != 0) {

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

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

      piVar1 = (int *)*piVar2;

      piVar2 = (int *)piVar2[1];

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

        (**(code **)(*piVar1 + 0x1c))(unaff_retaddr,param_1);

      }

    }

  }

  return 1;

}





// --- thunk_FUN_00693810 at 0x004FD0E0 (size: 5) ---


undefined4 thunk_FUN_00693810(undefined4 param_1)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  undefined4 unaff_retaddr;

  

  piVar2 = (int *)FUN_0043c680();

  iVar3 = (**(code **)(*piVar2 + 0x10))(0x186ab);

  if (iVar3 != 0) {

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

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

      piVar1 = (int *)*piVar2;

      piVar2 = (int *)piVar2[1];

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

        (**(code **)(*piVar1 + 0x10))(unaff_retaddr,param_1);

      }

    }

  }

  return 1;

}





// --- FUN_004fd0f0 at 0x004FD0F0 (size: 83) ---


void FUN_004fd0f0(undefined4 param_1,int param_2,undefined4 param_3,undefined4 param_4,int param_5,

                 undefined4 param_6,undefined4 param_7,undefined4 param_8)



{

  FUN_006938a0(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8);

  if (param_2 != 0) {

    FUN_00693810(param_2,0);

  }

  if (param_5 != 0) {

    FUN_00693810(param_5,0);

  }

  return;

}





// --- FUN_004fd150 at 0x004FD150 (size: 7) ---


void __fastcall FUN_004fd150(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007c6b24;

  return;

}





// --- FUN_004fd160 at 0x004FD160 (size: 11) ---


void FUN_004fd160(void)



{

  DAT_00842454 = 0;

  return;

}





// --- FUN_004fd170 at 0x004FD170 (size: 14) ---


void __fastcall FUN_004fd170(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007c6b24;

  DAT_00842454 = param_1;

  return;

}





// --- FUN_004fd180 at 0x004FD180 (size: 40) ---


undefined4 FUN_004fd180(undefined4 *param_1,int *param_2,uint *param_3)



{

  if (*param_3 < 4) {

    return 0;

  }

  *param_1 = *(undefined4 *)*param_2;

  *param_2 = *param_2 + 4;

  *param_3 = *param_3 - 4;

  return 1;

}





// --- FUN_004fd1b0 at 0x004FD1B0 (size: 51) ---


int FUN_004fd1b0(uint *param_1)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  

  uVar2 = *param_1 & 0x80000003;

  if ((int)uVar2 < 0) {

    uVar2 = (uVar2 - 1 | 0xfffffffc) + 1;

  }

  if ((uVar2 != 0) && (iVar1 = 4 - uVar2, iVar3 = iVar1, iVar1 != 0)) {

    do {

      *(undefined1 *)*param_1 = 0;

      iVar3 = iVar3 + -1;

      *param_1 = *param_1 + 1;

    } while (iVar3 != 0);

    return iVar1;

  }

  return 0;

}





// --- FUN_004fd1f0 at 0x004FD1F0 (size: 46) ---


uint __fastcall FUN_004fd1f0(int *param_1)



{

  uint uVar1;

  int iVar2;

  

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

  iVar2 = 0;

  if (0xfffe < uVar1) {

    iVar2 = 4;

  }

  uVar1 = iVar2 + 2 + uVar1;

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

    return (4 - (uVar1 & 3)) + uVar1;

  }

  return uVar1;

}





// --- FUN_004fd220 at 0x004FD220 (size: 106) ---


void __fastcall FUN_004fd220(int *param_1)



{

  uint uVar1;

  int iVar2;

  void *pvVar3;

  undefined4 *puVar4;

  uint uVar5;

  LONG LVar6;

  

  uVar1 = param_1[2];

  while (uVar1 = uVar1 - 1, -1 < (int)uVar1) {

    iVar2 = *param_1;

    pvVar3 = *(void **)(iVar2 + uVar1 * 4);

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

      uVar5 = param_1[2] - 1;

      param_1[2] = uVar5;

      if (uVar1 != uVar5) {

        *(undefined4 *)(iVar2 + uVar1 * 4) = *(undefined4 *)(iVar2 + uVar5 * 4);

      }

    }

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

      FUN_004fd220();

      operator_delete(pvVar3);

    }

  }

  puVar4 = (undefined4 *)param_1[3];

  LVar6 = InterlockedDecrement(puVar4 + 1);

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

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

  }

  operator_delete__((void *)*param_1);

  return;

}





// --- FUN_004fd290 at 0x004FD290 (size: 205) ---


uint __thiscall FUN_004fd290(int *param_1,int *param_2,uint param_3)



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  uint uVar4;

  LONG LVar5;

  uint uVar6;

  undefined4 *puVar7;

  undefined4 *puVar8;

  

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

  iVar3 = 0;

  if (0xfffe < uVar6) {

    iVar3 = 4;

  }

  uVar1 = iVar3 + 2 + uVar6;

  uVar4 = uVar1 & 3;

  if (uVar4 == 0) {

    iVar3 = 0;

  }

  else {

    iVar3 = 4 - uVar4;

  }

  uVar1 = iVar3 + uVar1;

  if (uVar1 <= param_3) {

    uVar4 = uVar6;

    if (0xfffe < uVar6) {

      uVar4 = 0xffff;

    }

    *(short *)*param_2 = (short)uVar4;

    iVar3 = *param_2;

    *param_2 = iVar3 + 2;

    if ((short)uVar4 == -1) {

      *(uint *)(iVar3 + 2) = uVar6;

      *param_2 = *param_2 + 4;

    }

    puVar2 = (undefined4 *)*param_1;

    InterlockedIncrement(puVar2 + 1);

    puVar7 = puVar2 + 5;

    puVar8 = (undefined4 *)*param_2;

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

      *puVar8 = *puVar7;

      puVar7 = puVar7 + 1;

      puVar8 = puVar8 + 1;

    }

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

      *(undefined1 *)puVar8 = *(undefined1 *)puVar7;

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

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

    }

    *param_2 = *param_2 + uVar6;

    FUN_004fd1b0(param_2);

    LVar5 = InterlockedDecrement(puVar2 + 1);

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

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

    }

  }

  return uVar1;

}





// --- FUN_004fd360 at 0x004FD360 (size: 81) ---


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



{

  LONG *lpAddend;

  

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

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

  param_1[0x11] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[0x12] = DAT_00842460;

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6b68;

  param_1[0xc] = &PTR_LAB_007c6b54;

  return param_1;

}





// --- FUN_004fd3d0 at 0x004FD3D0 (size: 142) ---


uint __thiscall FUN_004fd3d0(int param_1,uint *param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  uVar1 = FUN_004fd590();

  if (uVar1 <= param_3) {

    FUN_004fd290(param_2,param_3);

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

    uVar3 = *param_2;

    *param_2 = uVar3 + 4;

    *(undefined4 *)(uVar3 + 4) = *(undefined4 *)(param_1 + 8);

    *param_2 = *param_2 + 4;

    uVar3 = 0;

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

      do {

        FUN_004fd3d0(param_2,param_3);

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(param_1 + 8));

    }

    uVar3 = *param_2 & 0x80000003;

    if ((int)uVar3 < 0) {

      uVar3 = (uVar3 - 1 | 0xfffffffc) + 1;

    }

    if (uVar3 != 0) {

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

        *(undefined1 *)*param_2 = 0;

        *param_2 = *param_2 + 1;

      }

    }

  }

  return uVar1;

}





// --- FUN_004fd460 at 0x004FD460 (size: 237) ---


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



{

  ushort uVar1;

  ushort *puVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  

  if (param_3 < 2) {

    return 0;

  }

  puVar2 = (ushort *)*param_2;

  uVar1 = *puVar2;

  uVar4 = param_3 - 2;

  *param_2 = (uint)(puVar2 + 1);

  uVar5 = (uint)uVar1;

  if (uVar1 == 0xffff) {

    if (uVar4 < 4) {

      return 0;

    }

    uVar5 = *(uint *)(puVar2 + 1);

    *param_2 = (uint)(puVar2 + 3);

    uVar4 = param_3 - 6;

  }

  if (uVar4 < uVar5) {

    return 0;

  }

  if (uVar5 == 0) {

    FUN_004ab990();

  }

  else if ((uVar5 == 1) && (*(char *)*param_2 == '\0')) {

    FUN_0048a0a0(&DAT_008ef120);

    *param_2 = *param_2 + 1;

  }

  else {

    FUN_004010a0();

    FUN_00403560(uVar5);

    puVar6 = (undefined4 *)*param_2;

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

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

      *puVar7 = *puVar6;

      puVar6 = puVar6 + 1;

      puVar7 = puVar7 + 1;

    }

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

      *(undefined1 *)puVar7 = *(undefined1 *)puVar6;

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

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

    }

    *param_2 = *param_2 + uVar5;

    *(undefined1 *)(*(int *)(*param_1 + 8) + 0x13 + *param_1) = 0;

    iVar3 = *param_1;

    if (*(char *)(*(int *)(iVar3 + 8) + 0x12 + iVar3) == '\0') {

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

    }

  }

  uVar5 = *param_2 & 0x80000003;

  if ((int)uVar5 < 0) {

    uVar5 = (uVar5 - 1 | 0xfffffffc) + 1;

  }

  if (uVar5 != 0) {

    *param_2 = (*param_2 - uVar5) + 4;

  }

  return 1;

}





// --- FUN_004fd560 at 0x004FD560 (size: 46) ---


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



{

  FUN_004f8190();

  FUN_004fd220();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fd590 at 0x004FD590 (size: 102) ---


uint __fastcall FUN_004fd590(int param_1)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  undefined4 local_4;

  

  local_4 = 0;

  iVar1 = FUN_004fd290(&local_4,0);

  uVar2 = iVar1 + 8;

  uVar3 = 0;

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

    do {

      iVar1 = FUN_004fd3d0(&local_4,0);

      uVar2 = uVar2 + iVar1;

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 8));

  }

  if ((uVar2 & 3) == 0) {

    return uVar2;

  }

  return (4 - (uVar2 & 3)) + uVar2;

}





// --- FUN_004fd600 at 0x004FD600 (size: 274) ---


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



{

  uint *puVar1;

  uint uVar2;

  undefined4 *puVar3;

  int iVar4;

  uint uVar5;

  LONG *lpAddend;

  

  puVar1 = param_2;

  uVar5 = *param_2;

  uVar2 = FUN_004fd590();

  if (uVar2 <= param_3) {

    FUN_004fd460(param_2,param_3);

    iVar4 = *(int *)*param_2;

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

    param_1[4] = iVar4;

    iVar4 = *(int *)*param_2;

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

    param_2 = (uint *)iVar4;

    if (0 < iVar4) {

      do {

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

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

          puVar3 = (undefined4 *)0x0;

        }

        else {

          *puVar3 = 0;

          puVar3[1] = 0;

          puVar3[2] = 0;

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

          puVar3[3] = DAT_008ef11c;

          InterlockedIncrement(lpAddend);

          puVar3[4] = DAT_00842460;

        }

        FUN_004fd600(puVar1,param_3);

        uVar2 = param_1[1];

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

LAB_004fd6b5:

          *(undefined4 **)(*param_1 + param_1[2] * 4) = puVar3;

          param_1[2] = param_1[2] + 1;

        }

        else {

          if (uVar2 == 0) {

            iVar4 = 8;

          }

          else {

            iVar4 = uVar2 * 2;

          }

          iVar4 = FUN_00500570(iVar4);

          if (iVar4 != 0) goto LAB_004fd6b5;

        }

        param_2 = (uint *)((int)param_2 + -1);

      } while (param_2 != (uint *)0x0);

    }

    if (*puVar1 - uVar5 <= param_3) {

      uVar5 = *puVar1 & 0x80000003;

      if ((int)uVar5 < 0) {

        uVar5 = (uVar5 - 1 | 0xfffffffc) + 1;

      }

      if (uVar5 != 0) {

        for (iVar4 = 4 - uVar5; iVar4 != 0; iVar4 = iVar4 + -1) {

          *(undefined1 *)*puVar1 = 0;

          *puVar1 = *puVar1 + 1;

        }

      }

      return 1;

    }

    *puVar1 = uVar5;

  }

  return 0;

}





// --- FUN_004fd750 at 0x004FD750 (size: 68) ---


undefined4 FUN_004fd750(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  

  iVar1 = *param_1;

  uVar2 = FUN_004fd590();

  if (uVar2 <= param_2) {

    FUN_004fd600(param_1,param_2);

    if ((uint)(*param_1 - iVar1) <= param_2) {

      return 1;

    }

    *param_1 = iVar1;

  }

  return 0;

}





// --- FUN_004fd7a0 at 0x004FD7A0 (size: 56) ---


int FUN_004fd7a0(int param_1,int param_2)



{

  if (param_1 < 1) {

    return 0;

  }

  param_2 = param_2 * 0x1e;

  if (param_2 < 0) {

    return param_1 * 0x96;

  }

  if (0x96 < param_2) {

    param_2 = 0x96;

  }

  return param_2 * param_1 + param_1 * 0x96;

}





// --- FUN_004fd7e0 at 0x004FD7E0 (size: 39) ---


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



float10 FUN_004fd7e0(int param_1,int param_2)



{

  if (param_1 < 1) {

    return (float10)_DAT_007c6bc0;

  }

  if (param_2 < 0) {

    return (float10)DAT_00796344;

  }

  return (float10)param_2 / (float10)param_1;

}





// --- FUN_004fd810 at 0x004FD810 (size: 59) ---


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



float10 FUN_004fd810(float param_1)



{

  if (param_1 < _DAT_007938b0) {

    return (float10)_DAT_007938b0;

  }

  if (param_1 < _DAT_007c6bc4) {

    return (float10)_DAT_007c6bc4 - (float10)param_1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_004fd850 at 0x004FD850 (size: 11) ---


void __thiscall FUN_004fd850(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = param_2;

  return;

}





// --- FUN_004fd860 at 0x004FD860 (size: 8) ---


uint __fastcall FUN_004fd860(uint *param_1)



{

  return ~*param_1 & 1;

}





// --- FUN_004fd870 at 0x004FD870 (size: 49) ---


byte __fastcall FUN_004fd870(uint *param_1)



{

  uint uVar1;

  

  uVar1 = *param_1;

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

    return 0x20;

  }

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

    return 0x10;

  }

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

    return 8;

  }

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

    return 4;

  }

  return (byte)uVar1 & 2;

}





// --- FUN_004fd8b0 at 0x004FD8B0 (size: 25) ---


uint __fastcall FUN_004fd8b0(uint *param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar2 = 0xffff;

  uVar1 = *param_1 & 0xffff0000;

  do {

    uVar2 = uVar2 >> 1;

    uVar1 = uVar1 >> 1;

  } while (uVar2 != 0);

  return uVar1;

}





// --- FUN_004fd8d0 at 0x004FD8D0 (size: 28) ---


uint __fastcall FUN_004fd8d0(uint *param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar2 = 0xffff;

  uVar1 = *param_1 & 0xffff0000;

  do {

    uVar2 = uVar2 >> 1;

    uVar1 = uVar1 >> 1;

  } while (uVar2 != 0);

  return uVar1 & 2;

}





// --- FUN_004fd8f0 at 0x004FD8F0 (size: 83) ---


uint __fastcall FUN_004fd8f0(uint *param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar2 = 0xffff;

  uVar1 = *param_1 & 0xffff0000;

  do {

    uVar2 = uVar2 >> 1;

    uVar1 = uVar1 >> 1;

  } while (uVar2 != 0);

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

    return 0x20;

  }

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

    return 0x10;

  }

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

    return 8;

  }

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

    return 4;

  }

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

    return 2;

  }

  return uVar1 & 0x80;

}





// --- FUN_004fd9d0 at 0x004FD9D0 (size: 71) ---


void __fastcall FUN_004fd9d0(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[2];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[1];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

    (**(code **)*puVar1)(1);

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004fda20 at 0x004FDA20 (size: 45) ---


int FUN_004fda20(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_004fd290(param_1,param_2);

  iVar2 = FUN_004fd290(param_1,param_2);

  return iVar2 + iVar1;

}





// --- FUN_004fda50 at 0x004FDA50 (size: 176) ---


void __fastcall FUN_004fda50(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  LONG LVar4;

  uint local_8;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_8 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      piVar3 = *(int **)(*(int *)(param_1 + 8) + local_8 * 4);

      while (piVar3 != (int *)0x0) {

        puVar1 = (undefined4 *)piVar3[1];

        piVar2 = (int *)piVar3[2];

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        puVar1 = (undefined4 *)*piVar3;

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        operator_delete(piVar3);

        piVar3 = piVar2;

      }

      *(undefined4 *)(*(int *)(param_1 + 8) + local_8 * 4) = 0;

      local_8 = local_8 + 1;

    } while (local_8 < *(uint *)(param_1 + 0xc));

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  return;

}





// --- FUN_004fdb00 at 0x004FDB00 (size: 212) ---


void __fastcall FUN_004fdb00(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  LONG LVar4;

  uint local_8;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_8 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      piVar3 = *(int **)(*(int *)(param_1 + 8) + local_8 * 4);

      while (piVar3 != (int *)0x0) {

        puVar1 = (undefined4 *)piVar3[3];

        piVar2 = (int *)piVar3[4];

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        puVar1 = (undefined4 *)piVar3[2];

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        piVar3[1] = (int)&PTR_FUN_0079385c;

        puVar1 = (undefined4 *)*piVar3;

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        operator_delete(piVar3);

        piVar3 = piVar2;

      }

      *(undefined4 *)(*(int *)(param_1 + 8) + local_8 * 4) = 0;

      local_8 = local_8 + 1;

    } while (local_8 < *(uint *)(param_1 + 0xc));

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  return;

}





// --- FUN_004fdbe0 at 0x004FDBE0 (size: 60) ---


undefined4 FUN_004fdbe0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_004fd460(param_1,param_2);

  if (iVar1 != 0) {

    iVar1 = FUN_004fd460(param_1,param_2);

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_004fdcb0 at 0x004FDCB0 (size: 104) ---


int __fastcall FUN_004fdcb0(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  undefined4 local_4;

  

  uVar4 = 0;

  iVar5 = 4;

  local_4 = 0;

  if (*(int *)(param_1 + 0xc) != 0) {

    do {

      for (iVar1 = *(int *)(*(int *)(param_1 + 8) + uVar4 * 4); iVar1 != 0;

          iVar1 = *(int *)(iVar1 + 8)) {

        iVar2 = FUN_004fd290(&local_4,0);

        iVar3 = FUN_004fd290(&local_4,0);

        iVar5 = iVar5 + iVar2 + iVar3;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0xc));

  }

  return iVar5;

}





// --- FUN_004fddb0 at 0x004FDDB0 (size: 105) ---


int __fastcall FUN_004fddb0(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  undefined4 local_4;

  

  uVar4 = 0;

  iVar5 = 4;

  local_4 = 0;

  if (*(int *)(param_1 + 0xc) != 0) {

    do {

      for (iVar1 = *(int *)(*(int *)(param_1 + 8) + uVar4 * 4); iVar1 != 0;

          iVar1 = *(int *)(iVar1 + 0x10)) {

        iVar2 = FUN_004fd290(&local_4,0);

        iVar3 = (**(code **)(*(int *)(iVar1 + 4) + 0xc))(&local_4,0);

        iVar5 = iVar5 + iVar2 + iVar3;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0xc));

  }

  return iVar5;

}





// --- FUN_004fde20 at 0x004FDE20 (size: 52) ---


void __fastcall FUN_004fde20(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c6bc8;

  FUN_004fda50();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004fdfc0 at 0x004FDFC0 (size: 132) ---


undefined4 __thiscall FUN_004fdfc0(int param_1,undefined4 param_2,undefined4 param_3)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  iVar2 = FUN_004fe0a0(param_2);

  if (iVar2 != 0) {

    return 0;

  }

  iVar2 = FUN_005df0f5(0x10);

  if (iVar2 != 0) {

    uVar1 = *(uint *)(param_1 + 0xc);

    FUN_00480760(param_2);

    FUN_00480760(param_3);

    *(undefined4 *)(iVar2 + 8) = 0;

    uVar3 = FUN_004fe050();

    uVar3 = uVar3 % uVar1;

    *(uint *)(iVar2 + 0xc) = uVar3;

    *(undefined4 *)(iVar2 + 8) = *(undefined4 *)(*(int *)(param_1 + 8) + uVar3 * 4);

    *(int *)(*(int *)(param_1 + 8) + uVar3 * 4) = iVar2;

    *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;

    return 1;

  }

  return 0;

}





// --- FUN_004fe050 at 0x004FE050 (size: 75) ---


uint __fastcall FUN_004fe050(int *param_1)



{

  char *pcVar1;

  char cVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  

  iVar5 = *param_1 + 0x14;

  uVar4 = 0;

  cVar2 = *(char *)(*param_1 + 0x14);

  while (cVar2 != '\0') {

    iVar3 = tolower((int)cVar2);

    uVar4 = uVar4 * 0x10 + (int)(char)iVar3;

    if ((uVar4 & 0xf0000000) != 0) {

      uVar4 = ((uVar4 & 0xf0000000) >> 0x18 ^ uVar4) & 0xfffffff;

    }

    pcVar1 = (char *)(iVar5 + 1);

    iVar5 = iVar5 + 1;

    cVar2 = *pcVar1;

  }

  return uVar4;

}





// --- FUN_004fe0a0 at 0x004FE0A0 (size: 86) ---


int __fastcall FUN_004fe0a0(int param_1)



{

  uint uVar1;

  int iVar2;

  char cVar3;

  uint uVar4;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  if ((uVar1 != 0) && (*(int *)(param_1 + 8) != 0)) {

    uVar4 = FUN_004fe050();

    for (iVar2 = *(int *)(*(int *)(param_1 + 8) + (uVar4 % uVar1) * 4); iVar2 != 0;

        iVar2 = *(int *)(iVar2 + 8)) {

      cVar3 = FUN_004ac350(iVar2,0);

      if (cVar3 != '\0') {

        return iVar2 + 4;

      }

    }

  }

  return 0;

}





// --- FUN_004fe100 at 0x004FE100 (size: 52) ---


void __fastcall FUN_004fe100(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c6bdc;

  FUN_004fdb00();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004fe2a0 at 0x004FE2A0 (size: 54) ---


undefined4 * __fastcall FUN_004fe2a0(undefined4 *param_1)



{

  LONG *pLVar1;

  

  *param_1 = &PTR_LAB_007c6bf0;

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[1] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[2] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  return param_1;

}





// --- FUN_004fe340 at 0x004FE340 (size: 91) ---


undefined4 __thiscall FUN_004fe340(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_004fe3a0(param_2);

  if (iVar1 == 0) {

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 != 0) {

      iVar1 = FUN_004fe490(param_2,param_3,*(undefined4 *)(param_1 + 0xc));

      if (iVar1 != 0) {

        *(undefined4 *)(iVar1 + 0x10) =

             *(undefined4 *)(*(int *)(param_1 + 8) + *(int *)(iVar1 + 0x14) * 4);

        *(int *)(*(int *)(param_1 + 8) + *(int *)(iVar1 + 0x14) * 4) = iVar1;

        *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004fe3a0 at 0x004FE3A0 (size: 155) ---


int * __thiscall FUN_004fe3a0(int param_1,int *param_2)



{

  byte bVar1;

  uint uVar2;

  uint uVar3;

  byte *pbVar4;

  int iVar5;

  int *piVar6;

  byte *pbVar7;

  bool bVar8;

  

  uVar2 = *(uint *)(param_1 + 0xc);

  if ((uVar2 != 0) && (*(int *)(param_1 + 8) != 0)) {

    uVar3 = *(uint *)(*param_2 + 0x10);

    if (uVar3 == 0xffffffff) {

      uVar3 = FUN_004fe440();

      *(uint *)(*param_2 + 0x10) = uVar3;

    }

    piVar6 = *(int **)(*(int *)(param_1 + 8) + (uVar3 % uVar2) * 4);

    if (piVar6 != (int *)0x0) {

      do {

        pbVar4 = (byte *)(*piVar6 + 0x14);

        pbVar7 = (byte *)(*param_2 + 0x14);

        do {

          bVar1 = *pbVar7;

          bVar8 = bVar1 < *pbVar4;

          if (bVar1 != *pbVar4) {

LAB_004fe418:

            iVar5 = (1 - (uint)bVar8) - (uint)(bVar8 != 0);

            goto LAB_004fe41d;

          }

          if (bVar1 == 0) break;

          bVar1 = pbVar7[1];

          bVar8 = bVar1 < pbVar4[1];

          if (bVar1 != pbVar4[1]) goto LAB_004fe418;

          pbVar7 = pbVar7 + 2;

          pbVar4 = pbVar4 + 2;

        } while (bVar1 != 0);

        iVar5 = 0;

LAB_004fe41d:

        if (iVar5 == 0) {

          return piVar6 + 1;

        }

        piVar6 = (int *)piVar6[4];

      } while (piVar6 != (int *)0x0);

    }

  }

  return (int *)0x0;

}





// --- FUN_004fe440 at 0x004FE440 (size: 66) ---


uint __fastcall FUN_004fe440(int *param_1)



{

  uint uVar1;

  char cVar2;

  int iVar3;

  

  cVar2 = *(char *)(*param_1 + 0x14);

  iVar3 = *param_1 + 0x14;

  uVar1 = 0;

  if (cVar2 != '\0') {

    do {

      uVar1 = uVar1 * 0x10 + (int)cVar2;

      if ((uVar1 & 0xf0000000) != 0) {

        uVar1 = ((uVar1 & 0xf0000000) >> 0x18 ^ uVar1) & 0xfffffff;

      }

      cVar2 = *(char *)(iVar3 + 1);

      iVar3 = iVar3 + 1;

    } while (cVar2 != '\0');

    if (uVar1 == 0xffffffff) {

      uVar1 = 0xfffffffe;

    }

  }

  return uVar1;

}





// --- FUN_004fe490 at 0x004FE490 (size: 102) ---


int * __thiscall FUN_004fe490(int *param_1,int *param_2,int param_3,uint param_4)



{

  int iVar1;

  uint uVar2;

  

  iVar1 = *param_2;

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  param_1[1] = (int)&PTR_LAB_007c6bf0;

  FUN_00480760(param_3 + 4);

  FUN_00480760(param_3 + 8);

  param_1[4] = 0;

  iVar1 = *param_2;

  uVar2 = *(uint *)(iVar1 + 0x10);

  if (uVar2 == 0xffffffff) {

    uVar2 = FUN_004fe440();

    *(uint *)(iVar1 + 0x10) = uVar2;

  }

  param_1[5] = uVar2 % param_4;

  return param_1;

}





// --- FUN_004fe500 at 0x004FE500 (size: 72) ---


undefined4 * __thiscall FUN_004fe500(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007c6bc8;

  FUN_004fda50();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fe550 at 0x004FE550 (size: 72) ---


undefined4 * __thiscall FUN_004fe550(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007c6bdc;

  FUN_004fdb00();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fe5a0 at 0x004FE5A0 (size: 103) ---


undefined4 * __thiscall FUN_004fe5a0(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6c18;

  param_1[0xc] = &PTR_LAB_007c6c04;

  param_1[0xe] = &PTR_FUN_007c6bc8;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0x20;

  param_1[0x12] = 0;

  FUN_005a8440();

  param_1[0x13] = &PTR_FUN_007c6bdc;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0x20;

  param_1[0x17] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_004fe640 at 0x004FE640 (size: 48) ---


void * __thiscall FUN_004fe640(void *param_1,byte param_2)



{

  FUN_004fe100();

  FUN_004fde20();

  FUN_004f8190();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fe670 at 0x004FE670 (size: 52) ---


void __fastcall FUN_004fe670(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c6c70;

  FUN_005d59a0();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004fe7e0 at 0x004FE7E0 (size: 72) ---


undefined4 * __thiscall FUN_004fe7e0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007c6c70;

  FUN_005d59a0();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fe830 at 0x004FE830 (size: 71) ---


undefined4 * __thiscall FUN_004fe830(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6c98;

  param_1[0xc] = &PTR_LAB_007c6c84;

  param_1[0xe] = &PTR_FUN_007c6c70;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0x20;

  param_1[0x12] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_004fe8a0 at 0x004FE8A0 (size: 40) ---


void * __thiscall FUN_004fe8a0(void *param_1,byte param_2)



{

  FUN_004fe670();

  FUN_004f8190();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004fe8d0 at 0x004FE8D0 (size: 64) ---


void __fastcall FUN_004fe8d0(int *param_1)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)*param_1;

  param_1[2] = 0;

  param_1[1] = 0;

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] != 0) {

      (**(code **)*puVar1)(3);

      *param_1 = 0;

      return;

    }

    operator_delete__(puVar1 + -1);

  }

  *param_1 = 0;

  return;

}





// --- FUN_004fe910 at 0x004FE910 (size: 67) ---


undefined4 __thiscall FUN_004fe910(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_2 < (uint)param_1[2]) {

    iVar2 = param_1[2] - 1;

    param_1[2] = iVar2;

    iVar1 = *param_1;

    uVar3 = param_2 * 0x10 + iVar1;

    while (uVar3 < (uint)(iVar2 * 0x10 + iVar1)) {

      uVar3 = uVar3 + 0x10;

      FUN_004ff2a0(uVar3);

    }

    return 1;

  }

  return 0;

}





// --- FUN_004fe960 at 0x004FE960 (size: 28) ---


void __thiscall FUN_004fe960(int param_1,uint param_2)



{

  if ((-1 < (int)param_2) && (param_2 < *(uint *)(param_1 + 0x14))) {

    FUN_004fe910();

    return;

  }

  return;

}





// --- FUN_004fe980 at 0x004FE980 (size: 42) ---


int __thiscall FUN_004fe980(int param_1,uint param_2)



{

  int iVar1;

  

  if (((param_2 < *(uint *)(param_1 + 0x14)) &&

      (iVar1 = param_2 * 0x10 + *(int *)(param_1 + 0xc), *(int *)(iVar1 + 4) != 0)) && (iVar1 != 0))

  {

    return *(int *)(iVar1 + 8) + 0x14;

  }

  return 0;

}





// --- FUN_004fe9b0 at 0x004FE9B0 (size: 39) ---


undefined4 __thiscall FUN_004fe9b0(int param_1,uint param_2)



{

  int iVar1;

  

  if (((param_2 < *(uint *)(param_1 + 0x14)) &&

      (iVar1 = param_2 * 0x10 + *(int *)(param_1 + 0xc), *(int *)(iVar1 + 4) != 0)) && (iVar1 != 0))

  {

    return *(undefined4 *)(iVar1 + 4);

  }

  return 0;

}





// --- FUN_004fe9e0 at 0x004FE9E0 (size: 62) ---


uint __thiscall FUN_004fe9e0(int param_1,int param_2)



{

  uint uVar1;

  int *piVar2;

  

  uVar1 = 0;

  if (*(uint *)(param_1 + 0x14) != 0) {

    piVar2 = (int *)(*(int *)(param_1 + 0xc) + 4);

    while (*piVar2 != param_2) {

      uVar1 = uVar1 + 1;

      piVar2 = piVar2 + 4;

      if (*(uint *)(param_1 + 0x14) <= uVar1) {

        return 0xffffffff;

      }

    }

    if (*(int *)(uVar1 * 0x10 + 4 + *(int *)(param_1 + 0xc)) != 0) {

      return uVar1;

    }

  }

  return 0xffffffff;

}





// --- FUN_004fea20 at 0x004FEA20 (size: 50) ---


undefined4 __thiscall FUN_004fea20(int param_1,uint param_2)



{

  int iVar1;

  

  if (((-1 < (int)param_2) &&

      ((((int)param_2 < *(int *)(param_1 + 0x28) || (*(int *)(param_1 + 0x28) < 1)) &&

       (param_2 < *(uint *)(param_1 + 0x14))))) &&

     (iVar1 = param_2 * 0x10 + *(int *)(param_1 + 0xc), *(int *)(iVar1 + 4) != 0)) {

    return *(undefined4 *)(iVar1 + 0xc);

  }

  return 0;

}





// --- FUN_004fea60 at 0x004FEA60 (size: 214) ---


undefined4 __thiscall FUN_004fea60(int *param_1,uint param_2)



{

  uint *puVar1;

  undefined4 *puVar2;

  uint *puVar3;

  uint uVar4;

  int iVar5;

  

  if ((uint)param_1[2] <= param_2) {

    if (param_2 <= (uint)param_1[1]) {

      return 1;

    }

    if (param_2 == 0) {

      FUN_004fe8d0();

      return 1;

    }

    puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 0x10 + 4);

    if (puVar3 != (uint *)0x0) {

      puVar1 = puVar3 + 1;

      *puVar3 = param_2;

      FUN_00401000(puVar1,0x10,param_2,FUN_004ff180);

      if (puVar1 != (uint *)0x0) {

        if (*param_1 != 0) {

          uVar4 = 0;

          if (param_1[2] != 0) {

            iVar5 = 0;

            do {

              FUN_004ff2a0(*param_1 + iVar5);

              uVar4 = uVar4 + 1;

              iVar5 = iVar5 + 0x10;

            } while (uVar4 < (uint)param_1[2]);

          }

          puVar2 = (undefined4 *)*param_1;

          if (puVar2 != (undefined4 *)0x0) {

            if (puVar2[-1] != 0) {

              (**(code **)*puVar2)(3);

              param_1[1] = param_2;

              *param_1 = (int)puVar1;

              return 1;

            }

            operator_delete__(puVar2 + -1);

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = param_2;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_004feb40 at 0x004FEB40 (size: 48) ---


void __fastcall FUN_004feb40(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[2];

  *param_1 = &PTR_LAB_007c6cf0;

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004fec30 at 0x004FEC30 (size: 164) ---


int __fastcall FUN_004fec30(int param_1)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  

  iVar3 = 0;

  iVar4 = 8;

  if (0 < *(int *)(param_1 + 0x14)) {

    iVar5 = 0;

    do {

      if (*(int *)(iVar5 + *(int *)(param_1 + 0xc) + 4) != 0) {

        iVar1 = FUN_004ff1b0();

        iVar4 = iVar4 + iVar1;

      }

      iVar3 = iVar3 + 1;

      iVar5 = iVar5 + 0x10;

    } while (iVar3 < *(int *)(param_1 + 0x14));

  }

  iVar4 = iVar4 + 4;

  iVar3 = 0;

  if (0 < *(int *)(param_1 + 0x20)) {

    iVar5 = 0;

    do {

      if (*(int *)(*(int *)(param_1 + 0x18) + 4 + iVar5) != 0) {

        iVar1 = FUN_004ff1b0();

        iVar4 = iVar4 + iVar1;

      }

      iVar3 = iVar3 + 1;

      iVar5 = iVar5 + 0x10;

    } while (iVar3 < *(int *)(param_1 + 0x20));

  }

  uVar2 = *(int *)(*(int *)(param_1 + 0x2c) + 8) - 1;

  iVar3 = 0;

  if (0xfffe < uVar2) {

    iVar3 = 4;

  }

  uVar2 = iVar3 + 2 + uVar2;

  if ((uVar2 & 3) != 0) {

    return (uVar2 - (uVar2 & 3)) + 0xc + iVar4 + 4;

  }

  return uVar2 + 8 + iVar4 + 4;

}





// --- FUN_004fedc0 at 0x004FEDC0 (size: 421) ---


undefined4 __thiscall FUN_004fedc0(int param_1,int *param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  LONG LVar4;

  int *piVar5;

  int iVar6;

  undefined **local_10 [2];

  undefined4 *puStack_8;

  

  *(undefined4 *)(param_1 + 0x24) = *(undefined4 *)*param_2;

  iVar3 = *param_2;

  piVar5 = (int *)(iVar3 + 4);

  *param_2 = (int)piVar5;

  iVar6 = *piVar5;

  *param_2 = iVar3 + 8;

  FUN_004ff180();

  puVar1 = *(undefined4 **)(param_1 + 0xc);

  *(undefined4 *)(param_1 + 0x14) = 0;

  *(undefined4 *)(param_1 + 0x10) = 0;

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  *(undefined4 *)(param_1 + 0xc) = 0;

  if (0 < iVar6) {

    do {

      FUN_004ff300(param_2,param_3);

      uVar2 = *(uint *)(param_1 + 0x10);

      if (*(uint *)(param_1 + 0x14) < uVar2) {

LAB_004fee52:

        FUN_004ff2a0(local_10);

        *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + 1;

      }

      else {

        if (uVar2 == 0) {

          iVar3 = 8;

        }

        else {

          iVar3 = uVar2 * 2;

        }

        iVar3 = FUN_004fea60(iVar3);

        if (iVar3 != 0) goto LAB_004fee52;

      }

      iVar6 = iVar6 + -1;

    } while (iVar6 != 0);

  }

  iVar3 = *(int *)*param_2;

  *param_2 = (int)((int *)*param_2 + 1);

  puVar1 = *(undefined4 **)(param_1 + 0x18);

  *(undefined4 *)(param_1 + 0x20) = 0;

  *(undefined4 *)(param_1 + 0x1c) = 0;

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  *(int *)(param_1 + 0x18) = 0;

  if (0 < iVar3) {

    do {

      FUN_004ff300(param_2,param_3);

      uVar2 = *(uint *)(param_1 + 0x1c);

      if (*(uint *)(param_1 + 0x20) < uVar2) {

LAB_004feee0:

        FUN_004ff2a0(local_10);

        *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;

      }

      else {

        if (uVar2 == 0) {

          iVar6 = 8;

        }

        else {

          iVar6 = uVar2 * 2;

        }

        iVar6 = FUN_004fea60(iVar6);

        if (iVar6 != 0) goto LAB_004feee0;

      }

      iVar3 = iVar3 + -1;

    } while (iVar3 != 0);

  }

  *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)*param_2;

  *param_2 = *param_2 + 4;

  FUN_004fd460(param_2,param_3);

  *(undefined4 *)(param_1 + 0x3c) = *(undefined4 *)*param_2;

  iVar3 = *param_2;

  *param_2 = iVar3 + 4;

  *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(iVar3 + 4);

  *param_2 = *param_2 + 4;

  local_10[0] = &PTR_LAB_007c6cf0;

  LVar4 = InterlockedDecrement(puStack_8 + 1);

  if ((LVar4 == 0) && (puStack_8 != (undefined4 *)0x0)) {

    (**(code **)*puStack_8)(1);

  }

  return 1;

}





// --- FUN_004fef70 at 0x004FEF70 (size: 118) ---


undefined4 __thiscall FUN_004fef70(int param_1,int param_2)



{

  uint uVar1;

  int *piVar2;

  int iVar3;

  

  iVar3 = 0;

  if (0 < *(int *)(param_1 + 0x14)) {

    piVar2 = (int *)(*(int *)(param_1 + 0xc) + 4);

    do {

      if (*piVar2 == *(int *)(param_2 + 4)) {

        return 0;

      }

      iVar3 = iVar3 + 1;

      piVar2 = piVar2 + 4;

    } while (iVar3 < *(int *)(param_1 + 0x14));

  }

  uVar1 = *(uint *)(param_1 + 0x10);

  if (uVar1 <= *(uint *)(param_1 + 0x14)) {

    if (uVar1 == 0) {

      iVar3 = 8;

    }

    else {

      iVar3 = uVar1 * 2;

    }

    iVar3 = FUN_004fea60(iVar3);

    if (iVar3 == 0) {

      return 1;

    }

  }

  FUN_004ff2a0(param_2);

  *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + 1;

  return 1;

}





// --- FUN_004feff0 at 0x004FEFF0 (size: 393) ---


int __thiscall FUN_004feff0(int param_1,int param_2)



{

  int *piVar1;

  undefined4 *puVar2;

  uint uVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int iStack_8;

  

  iVar4 = param_2;

  if (param_1 != param_2) {

    puVar2 = *(undefined4 **)(param_1 + 0xc);

    *(undefined4 *)(param_1 + 0x14) = 0;

    *(undefined4 *)(param_1 + 0x10) = 0;

    if (puVar2 != (undefined4 *)0x0) {

      if (puVar2[-1] == 0) {

        operator_delete__(puVar2 + -1);

      }

      else {

        (**(code **)*puVar2)(3);

      }

    }

    *(undefined4 *)(param_1 + 0xc) = 0;

    puVar2 = *(undefined4 **)(param_1 + 0x18);

    *(undefined4 *)(param_1 + 0x20) = 0;

    *(undefined4 *)(param_1 + 0x1c) = 0;

    if (puVar2 != (undefined4 *)0x0) {

      if (puVar2[-1] == 0) {

        operator_delete__(puVar2 + -1);

      }

      else {

        (**(code **)*puVar2)(3);

      }

    }

    *(int *)(param_1 + 0x18) = 0;

    piVar1 = (int *)(param_2 + 0x14);

    param_2 = 0;

    if (0 < *piVar1) {

      iStack_8 = 0;

      do {

        iVar7 = *(int *)(iVar4 + 0xc);

        uVar3 = *(uint *)(param_1 + 0x10);

        if (*(uint *)(param_1 + 0x14) < uVar3) {

LAB_004ff09f:

          FUN_004ff2a0(iVar7 + iStack_8);

          *(int *)(param_1 + 0x14) = *(int *)(param_1 + 0x14) + 1;

        }

        else {

          if (uVar3 == 0) {

            iVar5 = 8;

          }

          else {

            iVar5 = uVar3 * 2;

          }

          iVar5 = FUN_004fea60(iVar5);

          if (iVar5 != 0) goto LAB_004ff09f;

        }

        param_2 = param_2 + 1;

        iStack_8 = iStack_8 + 0x10;

      } while (param_2 < *(int *)(iVar4 + 0x14));

    }

    param_2 = 0;

    if (0 < *(int *)(iVar4 + 0x20)) {

      iVar7 = 0;

      do {

        iVar5 = *(int *)(iVar4 + 0x18);

        uVar3 = *(uint *)(param_1 + 0x1c);

        if (*(uint *)(param_1 + 0x20) < uVar3) {

LAB_004ff108:

          FUN_004ff2a0(iVar5 + iVar7);

          *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;

        }

        else {

          if (uVar3 == 0) {

            iVar6 = 8;

          }

          else {

            iVar6 = uVar3 * 2;

          }

          iVar6 = FUN_004fea60(iVar6);

          if (iVar6 != 0) goto LAB_004ff108;

        }

        param_2 = param_2 + 1;

        iVar7 = iVar7 + 0x10;

      } while (param_2 < *(int *)(iVar4 + 0x20));

    }

    *(undefined4 *)(param_1 + 0x24) = *(undefined4 *)(iVar4 + 0x24);

    *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(iVar4 + 0x28);

    FUN_004034c0(*(int *)(iVar4 + 0x2c) + 0x14);

    *(undefined4 *)(param_1 + 0x30) = *(undefined4 *)(iVar4 + 0x30);

    *(undefined4 *)(param_1 + 0x34) = *(undefined4 *)(iVar4 + 0x34);

    *(undefined4 *)(param_1 + 0x38) = *(undefined4 *)(iVar4 + 0x38);

    *(undefined4 *)(param_1 + 0x3c) = *(undefined4 *)(iVar4 + 0x3c);

    *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(iVar4 + 0x40);

  }

  return param_1;

}





// --- FUN_004ff180 at 0x004FF180 (size: 47) ---


undefined4 * __fastcall FUN_004ff180(undefined4 *param_1)



{

  LONG *lpAddend;

  

  *param_1 = &PTR_LAB_007c6cf0;

  param_1[1] = 0;

  lpAddend = (LONG *)(DAT_008ef11c + 4);

  param_1[2] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[3] = 0;

  return param_1;

}





// --- FUN_004ff1b0 at 0x004FF1B0 (size: 70) ---


uint __fastcall FUN_004ff1b0(int param_1)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  

  uVar1 = *(int *)(*(int *)(param_1 + 8) + 8) - 1;

  iVar3 = 0;

  if (0xfffe < uVar1) {

    iVar3 = 4;

  }

  uVar1 = iVar3 + 2 + uVar1;

  uVar2 = uVar1 & 3;

  if (uVar2 == 0) {

    iVar3 = 0;

  }

  else {

    iVar3 = 4 - uVar2;

  }

  uVar1 = iVar3 + 8 + uVar1;

  if ((uVar1 & 3) != 0) {

    return (4 - (uVar1 & 3)) + uVar1;

  }

  return uVar1;

}





// --- FUN_004ff200 at 0x004FF200 (size: 148) ---


uint __thiscall FUN_004ff200(int param_1,int *param_2,uint param_3)



{

  undefined4 *puVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  puVar1 = (undefined4 *)*param_2;

  uVar2 = *(int *)(*(int *)(param_1 + 8) + 8) - 1;

  iVar4 = 0;

  if (0xfffe < uVar2) {

    iVar4 = 4;

  }

  uVar2 = iVar4 + 2 + uVar2;

  uVar3 = uVar2 & 3;

  if (uVar3 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = 4 - uVar3;

  }

  uVar2 = iVar4 + 8 + uVar2;

  uVar3 = uVar2 & 3;

  if (uVar3 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = 4 - uVar3;

  }

  uVar2 = iVar4 + uVar2;

  if (uVar2 <= param_3) {

    *puVar1 = *(undefined4 *)(param_1 + 4);

    *param_2 = *param_2 + 4;

    FUN_004fd290(param_2,param_3 - 4);

    *(undefined4 *)*param_2 = *(undefined4 *)(param_1 + 0xc);

    *param_2 = *param_2 + 4;

    FUN_004fd1b0(param_2);

    uVar2 = *param_2 - (int)puVar1;

  }

  return uVar2;

}





// --- FUN_004ff2a0 at 0x004FF2A0 (size: 81) ---


int __thiscall FUN_004ff2a0(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_2 + 4);

  puVar1 = *(undefined4 **)(param_1 + 8);

  if (puVar1 != *(undefined4 **)(param_2 + 8)) {

    LVar3 = InterlockedDecrement(puVar1 + 1);

    if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    iVar2 = *(int *)(param_2 + 8);

    *(int *)(param_1 + 8) = iVar2;

    InterlockedIncrement((LONG *)(iVar2 + 4));

  }

  *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

  return param_1;

}





// --- FUN_004ff300 at 0x004FF300 (size: 98) ---


undefined4 __thiscall FUN_004ff300(int param_1,int *param_2,int param_3)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)*param_2;

  *(undefined4 *)(param_1 + 4) = *puVar1;

  *param_2 = *param_2 + 4;

  iVar2 = FUN_004fd460(param_2,param_3 + -4);

  if (iVar2 == 0) {

    printf("CharacterIdentity: Unpack failed for name_");

    *param_2 = (int)puVar1;

    return 0;

  }

  *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)*param_2;

  *param_2 = *param_2 + 4;

  FUN_004fd1b0(param_2);

  return 1;

}





// --- FUN_004ff370 at 0x004FF370 (size: 53) ---


undefined4 FUN_004ff370(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_00415730(param_1,0xb,0x1c);

  if (iVar1 == 0) {

    return 0;

  }

  if (DAT_0084247c != (int *)0x0) {

    (**(code **)(*DAT_0084247c + 0x14))();

  }

  DAT_0084247c = (int *)iVar1;

  return 1;

}





// --- FUN_004ff3b0 at 0x004FF3B0 (size: 44) ---


void FUN_004ff3b0(void)



{

  if (DAT_0084247c != (int *)0x0) {

    FUN_004144e0(1);

    (**(code **)(*DAT_0084247c + 0x14))();

  }

  DAT_0084247c = (int *)0x0;

  return;

}





// --- FUN_004ff3e0 at 0x004FF3E0 (size: 8) ---


void FUN_004ff3e0(void)



{

  FUN_00502f80();

  return;

}





// --- FUN_004ff3f0 at 0x004FF3F0 (size: 8) ---


void FUN_004ff3f0(void)



{

  FUN_00502fa0();

  return;

}





// --- FUN_004ff400 at 0x004FF400 (size: 20) ---


bool FUN_004ff400(void)



{

  int *piVar1;

  

  piVar1 = (int *)FUN_006b5980();

  return *piVar1 != 0;

}





// --- FUN_004ff420 at 0x004FF420 (size: 22) ---


void FUN_004ff420(void)



{

  if ((DAT_0084247c != 0) && (*(int *)(DAT_0084247c + 0x50) != 0)) {

    FUN_00501990();

    return;

  }

  return;

}





// --- FUN_004ff440 at 0x004FF440 (size: 55) ---


undefined4

FUN_004ff440(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  if ((DAT_0084247c != 0) && (*(int *)(DAT_0084247c + 0x50) != 0)) {

    FUN_00501600(param_1,param_2,param_3,param_4,param_5);

    return 1;

  }

  return 0;

}





// --- FUN_004ff480 at 0x004FF480 (size: 45) ---


undefined4 FUN_004ff480(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 uVar1;

  

  if ((DAT_0084247c != 0) && (*(int *)(DAT_0084247c + 0x50) != 0)) {

    uVar1 = FUN_00501860(param_1,param_2,param_3,param_4);

    return uVar1;

  }

  return 0;

}





// --- FUN_004ff4b0 at 0x004FF4B0 (size: 35) ---


undefined4 FUN_004ff4b0(undefined4 param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  if ((DAT_0084247c != 0) && (*(int *)(DAT_0084247c + 0x50) != 0)) {

    uVar1 = FUN_00502a10(param_1,param_2);

    return uVar1;

  }

  return 0;

}





// --- FUN_004ff4e0 at 0x004FF4E0 (size: 75) ---


undefined4 __fastcall FUN_004ff4e0(int *param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  if ((param_1[1] == 0) && (*param_1 != DAT_00842498)) {

    uVar1 = FUN_004220b0(*param_1,0x22);

    iVar2 = FUN_00415430(uVar1);

    param_1[5] = iVar2;

    if (iVar2 != 0) {

      return 1;

    }

    param_1[1] = 1;

  }

  return 0;

}





// --- FUN_004ff530 at 0x004FF530 (size: 55) ---


int FUN_004ff530(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_00502f50(param_1,param_2);

  if (iVar1 == 0) {

    return 0;

  }

  if ((*(int *)(iVar1 + 0x14) == 0) && (iVar2 = FUN_004ff4e0(), iVar2 == 0)) {

    return 0;

  }

  return iVar1;

}





// --- FUN_004ff570 at 0x004FF570 (size: 35) ---


undefined4 FUN_004ff570(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  FUN_00502fd0(param_1,param_2,param_3,param_4);

  return param_1;

}





// --- FUN_004ff5a0 at 0x004FF5A0 (size: 158) ---


uint __thiscall FUN_004ff5a0(undefined4 *param_1,int *param_2,uint *param_3)



{

  uint uVar1;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      *(undefined4 *)*param_2 = param_1[1];

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        *(undefined4 *)*param_2 = param_1[2];

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          *(undefined4 *)*param_2 = param_1[3];

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            *(undefined4 *)*param_2 = param_1[4];

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              *(undefined4 *)*param_2 = param_1[5];

              *param_2 = *param_2 + 4;

              *param_3 = *param_3 - 4;

            }

          }

        }

      }

    }

  }

  return *param_3;

}





// --- FUN_004ff640 at 0x004FF640 (size: 151) ---


undefined4 __thiscall FUN_004ff640(undefined4 *param_1,int *param_2,uint *param_3)



{

  uint uVar1;

  undefined4 uVar2;

  

  if (3 < *param_3) {

    *param_1 = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      uVar2 = *(undefined4 *)*param_2;

      *param_2 = (int)((undefined4 *)*param_2 + 1);

      *param_3 = *param_3 - 4;

      param_1[1] = uVar2;

      if (3 < *param_3) {

        uVar2 = *(undefined4 *)*param_2;

        *param_2 = (int)((undefined4 *)*param_2 + 1);

        *param_3 = *param_3 - 4;

        param_1[2] = uVar2;

        if (3 < *param_3) {

          param_1[3] = *(undefined4 *)*param_2;

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            uVar2 = *(undefined4 *)*param_2;

            *param_2 = (int)((undefined4 *)*param_2 + 1);

            *param_3 = *param_3 - 4;

            param_1[4] = uVar2;

            if (3 < *param_3) {

              uVar2 = *(undefined4 *)*param_2;

              *param_2 = (int)((undefined4 *)*param_2 + 1);

              *param_3 = *param_3 - 4;

              param_1[5] = uVar2;

            }

          }

        }

      }

    }

  }

  return 1;

}





// --- FUN_004ff6e0 at 0x004FF6E0 (size: 117) ---


undefined4 * __thiscall FUN_004ff6e0(undefined4 *param_1,undefined4 param_2)



{

  LONG *lpAddend;

  

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6da0;

  param_1[0xc] = &PTR_LAB_007c6d88;

  param_1[0xe] = 0;

  lpAddend = (LONG *)(DAT_008ef11c + 4);

  param_1[0xf] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x10] = 0xffffffff;

  param_1[0x11] = 1;

  return param_1;

}





// --- FUN_004ff770 at 0x004FF770 (size: 193) ---


void __fastcall FUN_004ff770(int param_1)



{

  void *pvVar1;

  

  pvVar1 = *(void **)(param_1 + 0x4c);

  *(undefined4 *)(param_1 + 0x40) = 0xffffffff;

  if (pvVar1 != (void *)0x0) {

    FUN_00501450();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x4c) = 0;

  }

  pvVar1 = *(void **)(param_1 + 0x50);

  if (pvVar1 != (void *)0x0) {

    FUN_00502da0();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x50) = 0;

  }

  pvVar1 = *(void **)(param_1 + 0x58);

  if (pvVar1 != (void *)0x0) {

    FUN_00502e50();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x58) = 0;

  }

  pvVar1 = *(void **)(param_1 + 0x5c);

  if (pvVar1 != (void *)0x0) {

    FUN_005031c0();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x5c) = 0;

  }

  if (*(void **)(param_1 + 0x74) != (void *)0x0) {

    operator_delete(*(void **)(param_1 + 0x74));

    *(undefined4 *)(param_1 + 0x74) = 0;

  }

  pvVar1 = *(void **)(param_1 + 0x54);

  if (pvVar1 != (void *)0x0) {

    FUN_00503310();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x54) = 0;

  }

  pvVar1 = *(void **)(param_1 + 0x60);

  if (pvVar1 != (void *)0x0) {

    thunk_FUN_00503440();

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 0x60) = 0;

  }

  return;

}





// --- FUN_004ff8d0 at 0x004FF8D0 (size: 151) ---


int __fastcall FUN_004ff8d0(int param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  

  uVar1 = *(int *)(*(int *)(param_1 + 0x3c) + 8) - 1;

  iVar3 = 0;

  if (0xfffe < uVar1) {

    iVar3 = 4;

  }

  uVar1 = iVar3 + 2 + uVar1;

  uVar4 = uVar1 & 3;

  if (uVar4 == 0) {

    iVar3 = 0;

  }

  else {

    iVar3 = 4 - uVar4;

  }

  iVar3 = iVar3 + 0x42c + uVar1;

  if (DAT_008ee9c8 != 0) {

    iVar2 = FUN_005a7a60();

    iVar3 = iVar3 + iVar2;

  }

  if ((*(byte *)(param_1 + 0x48) & 0x10) != 0) {

    iVar2 = FUN_00502500();

    iVar3 = iVar3 + iVar2;

  }

  if ((*(byte *)(param_1 + 0x48) & 1) != 0) {

    iVar2 = FUN_00503250();

    iVar3 = iVar3 + iVar2;

  }

  if ((*(byte *)(param_1 + 0x48) & 2) != 0) {

    iVar2 = FUN_00502e20();

    iVar3 = iVar3 + iVar2;

  }

  if ((*(byte *)(param_1 + 0x48) & 4) != 0) {

    iVar2 = FUN_00503150();

    iVar3 = iVar3 + iVar2;

  }

  if ((*(uint *)(param_1 + 0x48) & 0x200) != 0) {

    iVar3 = iVar3 + 0x18;

  }

  return iVar3;

}





// --- FUN_004ffec0 at 0x004FFEC0 (size: 1435) ---


/* WARNING: Function: __chkstk replaced with injection: alloca_probe */



int * __thiscall FUN_004ffec0(int param_1,int *param_2,uint param_3)



{

  void *pvVar1;

  int *piVar2;

  void *pvVar3;

  int iVar4;

  uint uVar5;

  uint uVar6;

  void *pvVar7;

  undefined4 uVar8;

  int iVar9;

  int *piVar10;

  uint *puVar11;

  undefined4 *puVar12;

  int *apiStack_430 [255];

  char *pcStack_34;

  uint local_20;

  uint local_18;

  int local_14;

  uint local_10;

  uint local_c;

  

  piVar2 = param_2;

  pcStack_34 = (char *)0x4ffeda;

  (**(code **)(*(int *)(param_1 + -0x30) + 0x3c))();

  uVar5 = param_3;

  if (3 < param_3) {

    *(undefined4 *)(param_1 + 8) = *(undefined4 *)*param_2;

    iVar4 = *param_2;

    *param_2 = iVar4 + 4;

    uVar5 = param_3 - 4;

    if (3 < param_3 - 4) {

      *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(iVar4 + 4);

      *param_2 = *param_2 + 4;

      uVar5 = param_3 - 8;

    }

  }

  param_3 = uVar5;

  if (*(uint *)(param_1 + 0x10) != 3) {

    if (*(uint *)(param_1 + 0x10) < 4) {

      pcStack_34 = 

      "Error: The executable has a more recent verion than the data files. You will need to update in order to run\n"

      ;

      apiStack_430[0xfe] = (int *)0x4fff3f;

      FUN_00555860();

      return (int *)0x0;

    }

    pcStack_34 = 

    "Error: The data files have a more recent verion than the executable. You will need to update in order to run\n"

    ;

    apiStack_430[0xfe] = (int *)0x4fff24;

    FUN_00555860();

    return (int *)0x0;

  }

  apiStack_430[0xfe] = param_2;

  apiStack_430[0xfd] = (int *)0x4fff5c;

  pcStack_34 = (char *)param_3;

  iVar4 = FUN_004fd460();

  if (iVar4 == 0) {

    return (int *)0x0;

  }

  uVar5 = *(int *)(*(int *)(param_1 + 0xc) + 8) - 1;

  iVar4 = 0;

  if (0xfffe < uVar5) {

    iVar4 = 4;

  }

  uVar5 = iVar4 + 2 + uVar5;

  uVar6 = uVar5 & 3;

  if (uVar6 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = 4 - uVar6;

  }

  uVar5 = param_3 - (iVar4 + uVar5);

  param_3 = uVar5;

  if (3 < uVar5) {

    iVar4 = *param_2;

    param_3 = uVar5 - 4;

    *param_2 = iVar4 + 4;

    if (3 < param_3) {

      param_3 = uVar5 - 8;

      *param_2 = iVar4 + 8;

      if (3 < param_3) {

        param_3 = uVar5 - 0xc;

        *param_2 = iVar4 + 0xc;

        if (3 < param_3) {

          param_3 = uVar5 - 0x10;

          *param_2 = iVar4 + 0x10;

          if (3 < param_3) {

            param_3 = uVar5 - 0x14;

            *param_2 = iVar4 + 0x14;

            if (3 < param_3) {

              param_3 = uVar5 - 0x18;

              *param_2 = iVar4 + 0x18;

              if (3 < param_3) {

                param_3 = uVar5 - 0x1c;

                *param_2 = iVar4 + 0x1c;

                if (3 < param_3) {

                  param_3 = uVar5 - 0x20;

                  *param_2 = iVar4 + 0x20;

                }

              }

            }

          }

        }

      }

    }

  }

  pcStack_34 = (char *)0x500020;

  uVar6 = 0;

  uVar5 = param_3;

  do {

    if (3 < uVar5) {

      apiStack_430[uVar6] = *(int **)*param_2;

      *param_2 = *param_2 + 4;

      uVar5 = param_3 - 4;

      param_3 = uVar5;

    }

    uVar6 = uVar6 + 1;

  } while (uVar6 < 0x100);

  FUN_005aaa90(apiStack_430);

  iVar4 = FUN_005df0f5(0x88);

  pvVar3 = DAT_008ee9c8;

  if ((((iVar4 != 0) &&

       (pvVar7 = (void *)FUN_005a7770(), pvVar3 = DAT_008ee9c8, pvVar7 != (void *)0x0)) &&

      (iVar4 = FUN_005a7fd0(param_2,&param_3), pvVar1 = DAT_008ee9c8, pvVar3 = DAT_008ee9c8,

      iVar4 != 0)) && (pvVar3 = pvVar7, DAT_008ee9c8 != (void *)0x0)) {

    FUN_005a7f80();

    operator_delete(pvVar1);

  }

  DAT_008ee9c8 = pvVar3;

  if (3 < param_3) {

    *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)*param_2;

    param_3 = param_3 - 4;

    *param_2 = *param_2 + 4;

  }

  if ((*(byte *)(param_1 + 0x18) & 0x10) != 0) {

    iVar4 = FUN_005df0f5(0x28);

    if (iVar4 == 0) {

      uVar8 = 0;

    }

    else {

      uVar8 = FUN_005015d0();

    }

    *(undefined4 *)(param_1 + 0x20) = uVar8;

    param_2 = (int *)FUN_00502820(param_2,&param_3);

  }

  if (((*(byte *)(param_1 + 0x18) & 1) != 0) && (param_2 != (int *)0x0)) {

    iVar4 = FUN_005df0f5(0xc);

    if (iVar4 == 0) {

      uVar8 = 0;

    }

    else {

      uVar8 = FUN_005031e0();

    }

    *(undefined4 *)(param_1 + 0x24) = uVar8;

    param_2 = (int *)FUN_00503380(piVar2,&param_3);

  }

  if ((*(byte *)(param_1 + 0x18) & 2) != 0) {

    if (param_2 == (int *)0x0) goto LAB_005003e5;

    iVar4 = FUN_005df0f5(0xc);

    if (iVar4 == 0) {

      uVar8 = 0;

    }

    else {

      uVar8 = FUN_005031e0();

    }

    *(undefined4 *)(param_1 + 0x28) = uVar8;

    if (3 < param_3) {

      local_10 = *(uint *)*piVar2;

      *piVar2 = (int)((uint *)*piVar2 + 1);

      param_3 = param_3 - 4;

    }

    FUN_00500570(local_10);

    local_c = 0;

    uVar5 = param_3;

    if (local_10 != 0) {

      do {

        iVar4 = FUN_005df0f5(0x14);

        if (iVar4 == 0) {

          iVar4 = 0;

        }

        else {

          iVar4 = FUN_00503c90();

        }

        if (3 < param_3) {

          uVar5 = *(uint *)*piVar2;

          *piVar2 = (int)((uint *)*piVar2 + 1);

          param_3 = param_3 - 4;

        }

        if (uVar5 == 0xffffffff) {

          *(undefined4 *)(iVar4 + 0x10) = 0;

        }

        else {

          *(undefined4 *)(iVar4 + 0x10) = *(undefined4 *)(**(int **)(param_1 + 0x24) + uVar5 * 4);

        }

        iVar9 = FUN_00503d20(piVar2,&param_3);

        if (iVar9 == 0) {

          return (int *)0x0;

        }

        FUN_00502ef0(iVar4);

        local_c = local_c + 1;

      } while (local_c < local_10);

    }

  }

  if (param_2 != (int *)0x0) {

    iVar4 = FUN_005df0f5(0x10);

    if (iVar4 == 0) {

      uVar8 = 0;

    }

    else {

      uVar8 = FUN_00502f40();

    }

    *(undefined4 *)(param_1 + 0x2c) = uVar8;

    if (3 < param_3) {

      local_20 = *(uint *)*piVar2;

      *piVar2 = (int)((uint *)*piVar2 + 1);

      param_3 = param_3 - 4;

    }

    FUN_00500570(local_20);

    local_c = 0;

    if (local_20 != 0) {

      do {

        iVar4 = FUN_005df0f5(0x14);

        if (iVar4 == 0) {

          piVar10 = (int *)0x0;

        }

        else {

          piVar10 = (int *)FUN_00503010();

        }

        iVar4 = FUN_004fd460(piVar2,param_3);

        if (iVar4 == 0) {

          return (int *)0x0;

        }

        uVar5 = *(int *)(*piVar10 + 8) - 1;

        iVar4 = 0;

        if (0xfffe < uVar5) {

          iVar4 = 4;

        }

        uVar5 = iVar4 + 2 + uVar5;

        uVar6 = uVar5 & 3;

        if (uVar6 == 0) {

          iVar4 = 0;

        }

        else {

          iVar4 = 4 - uVar6;

        }

        uVar5 = param_3 - (iVar4 + uVar5);

        param_3 = uVar5;

        if (3 < uVar5) {

          piVar10[1] = *(int *)*piVar2;

          iVar4 = *piVar2;

          param_3 = uVar5 - 4;

          puVar11 = (uint *)(iVar4 + 4);

          *piVar2 = (int)puVar11;

          if (3 < param_3) {

            local_10 = *puVar11;

            *piVar2 = iVar4 + 8;

            param_3 = uVar5 - 8;

          }

        }

        FUN_00500570(local_10);

        if (local_10 != 0) {

          local_18 = local_10;

          do {

            if (3 < param_3) {

              local_14 = *(int *)*piVar2;

              *piVar2 = (int)((int *)*piVar2 + 1);

              param_3 = param_3 - 4;

            }

            if (local_14 == -1) {

              uVar8 = 0;

            }

            else {

              uVar8 = *(undefined4 *)(**(int **)(param_1 + 0x28) + local_14 * 4);

            }

            uVar5 = piVar10[3];

            if ((uint)piVar10[4] < uVar5) {

LAB_0050037c:

              *(undefined4 *)(piVar10[2] + piVar10[4] * 4) = uVar8;

              piVar10[4] = piVar10[4] + 1;

            }

            else {

              if (uVar5 == 0) {

                iVar4 = 8;

              }

              else {

                iVar4 = uVar5 * 2;

              }

              iVar4 = FUN_00500570(iVar4);

              if (iVar4 != 0) goto LAB_0050037c;

            }

            local_18 = local_18 - 1;

          } while (local_18 != 0);

        }

        FUN_00503100(piVar10);

        local_c = local_c + 1;

      } while (local_c < local_20);

    }

    iVar4 = FUN_005df0f5(0x2c);

    if (iVar4 == 0) {

      uVar8 = 0;

    }

    else {

      uVar8 = FUN_00503830();

    }

    **(undefined4 **)(param_1 + 0x2c) = uVar8;

    iVar4 = FUN_005036d0(piVar2,&param_3);

    if (iVar4 == 0) {

      return (int *)0x0;

    }

  }

LAB_005003e5:

  puVar12 = (undefined4 *)FUN_005df0f5(0x18);

  if (puVar12 == (undefined4 *)0x0) {

    puVar12 = (undefined4 *)0x0;

  }

  else {

    *puVar12 = 0;

    puVar12[1] = 0x600127d;

    puVar12[2] = 0x6000261;

    puVar12[3] = 4;

    puVar12[4] = 0;

    puVar12[5] = 0;

  }

  *(undefined4 **)(param_1 + 0x44) = puVar12;

  if (((*(uint *)(param_1 + 0x18) & 0x200) != 0) && (param_2 != (int *)0x0)) {

    FUN_004ff640(piVar2,&param_3);

    return param_2;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 0x200;

  return param_2;

}





