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

// --- FUN_004a04f0 at 0x004A04F0 (size: 71) ---


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



{

  *param_1 = &PTR_FUN_007aa448;

  param_1[0x17c] = &PTR_FUN_007aa43c;

  param_1[0x181] = &PTR_FUN_007ccb60;

  param_1[0x181] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004f3320();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a0540 at 0x004A0540 (size: 70) ---


void __fastcall FUN_004a0540(int *param_1)



{

  int *piVar1;

  int iVar2;

  

  FUN_004639a0();

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

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

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

    param_1[0x180] = iVar2;

  }

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

  (**(code **)param_1[0x17c])(0);

  return;

}





// --- FUN_004a0590 at 0x004A0590 (size: 19) ---


void FUN_004a0590(void)



{

  FUN_00460270(0x10000027,&LAB_004a0490);

  return;

}





// --- FUN_004a1be0 at 0x004A1BE0 (size: 234) ---


undefined4 __thiscall FUN_004a1be0(int param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  

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

    return 0;

  }

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

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

  iVar3 = FUN_0069fe60();

  iVar4 = FUN_005df4c4();

  iVar5 = FUN_0069fe70();

  iVar6 = FUN_005df4c4();

  (**(code **)(*param_2 + 0x2c))((-iVar4 - iVar3 / 2) + iVar1,(-iVar6 - iVar5 / 2) + iVar2);

  (**(code **)(*param_2 + 0x18))(1);

  return 1;

}





// --- FUN_004a1cd0 at 0x004A1CD0 (size: 67) ---


uint FUN_004a1cd0(uint param_1,uint param_2)



{

  if ((((-1 < (int)param_1) && (-1 < (int)param_2)) && ((int)param_1 < 0x7f8)) &&

     ((int)param_2 < 0x7f8)) {

    return (param_2 & 7) + 1 + (param_1 & 7) * 8 |

           ((param_1 & 0xfffffff8) << 5 | (int)param_2 >> 3) << 0x10;

  }

  return 0;

}





// --- FUN_004a1d20 at 0x004A1D20 (size: 171) ---


undefined4 * __thiscall FUN_004a1d20(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_007abfc0;

  param_1[0x17e] = &PTR_FUN_007abd18;

  param_1[0x17f] = 0;

  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[0x18a] = &PTR_LAB_00797910;

  param_1[0x18b] = 0;

  param_1[0x18c] = 0x3f800000;

  param_1[0x18d] = 0;

  param_1[0x18e] = 0;

  param_1[399] = 0;

  param_1[0x199] = 0;

  param_1[0x19a] = 0;

  param_1[0x19b] = 0;

  FUN_00535b30();

  return param_1;

}





// --- FUN_004a1e00 at 0x004A1E00 (size: 105) ---


void __fastcall FUN_004a1e00(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007abfc0;

  *puVar1 = &PTR_FUN_007abd18;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  param_1[0x183] = 0;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  param_1[0x18a] = &PTR_FUN_0079385c;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004a1ea0 at 0x004A1EA0 (size: 30) ---


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



{

  FUN_004a1e00();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a1ec0 at 0x004A1EC0 (size: 19) ---


void FUN_004a1ec0(void)



{

  FUN_00460270(0x10000026,&LAB_004a1e70);

  return;

}





// --- FUN_004a1ee0 at 0x004A1EE0 (size: 186) ---


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



{

  int *piVar1;

  LONG LVar2;

  undefined4 *puVar3;

  int iStack_a4;

  int iStack_a0;

  

  iStack_a0 = param_3;

  iStack_a4 = param_1;

  piVar1 = (int *)FUN_0045d8b0();

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

    iStack_a0 = param_4[1];

    iStack_a4 = *param_4;

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

    (**(code **)(*piVar1 + 0x30))(param_4[2],param_4[3]);

    FUN_0042dc80();

    FUN_00402730(param_4[4]);

    FUN_0042cbe0(&iStack_a4,1);

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

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

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

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

    }

    FUN_004618a0(&iStack_a0);

    FUN_0042e590();

  }

  return;

}





// --- FUN_004a2170 at 0x004A2170 (size: 99) ---


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



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  LONG *lpAddend;

  undefined4 *puVar4;

  

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

  *param_1 = PTR_DAT_00818340;

  InterlockedIncrement(lpAddend);

  piVar2 = (int *)FUN_00403350(&param_3,0);

  iVar1 = *(int *)(*piVar2 + -4);

  if (iVar1 != 1) {

    FUN_00402490(*piVar2,iVar1 + -1);

  }

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

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

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

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

  }

  return param_1;

}





// --- FUN_004a21e0 at 0x004A21E0 (size: 1134) ---


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



undefined4 __fastcall FUN_004a21e0(int param_1)



{

  char cVar1;

  undefined4 *puVar2;

  LONG LVar3;

  int iVar4;

  undefined *puVar5;

  undefined *puVar6;

  wchar_t *pwVar7;

  bool bVar8;

  undefined *local_9c;

  wchar_t *local_98;

  undefined4 uStack_94;

  undefined8 local_90;

  undefined4 uStack_88;

  undefined4 uStack_84;

  undefined8 uStack_80;

  char local_74 [4];

  char local_70 [2];

  char local_6e;

  undefined4 auStack_6d [7];

  char local_50 [4];

  char local_4c [2];

  char local_4a;

  undefined4 uStack_49;

  

  *(double *)(param_1 + 0x620) = _DAT_008379a8 + _DAT_0079a1b0;

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

    local_4c[0] = s_Date__007ac108[4];

    local_4c[1] = s_Date__007ac108[5];

    local_50[0] = s_Date__007ac108[0];

    local_50[1] = s_Date__007ac108[1];

    local_50[2] = s_Date__007ac108[2];

    local_50[3] = s_Date__007ac108[3];

    _local_4a = CONCAT11((undefined1)uStack_49,s_Date__007ac108[6]);

    puVar2 = &uStack_49;

    for (iVar4 = 0xe; iVar4 != 0; iVar4 = iVar4 + -1) {

      *puVar2 = 0;

      puVar2 = puVar2 + 1;

    }

    *(undefined2 *)puVar2 = 0;

    *(undefined1 *)((int)puVar2 + 2) = 0;

    local_70[0] = s_Time__007ac100[4];

    local_70[1] = s_Time__007ac100[5];

    local_74[0] = s_Time__007ac100[0];

    local_74[1] = s_Time__007ac100[1];

    local_74[2] = s_Time__007ac100[2];

    local_74[3] = s_Time__007ac100[3];

    _local_6e = CONCAT11((undefined1)auStack_6d[0],s_Time__007ac100[6]);

    puVar2 = auStack_6d;

    for (iVar4 = 7; iVar4 != 0; iVar4 = iVar4 + -1) {

      *puVar2 = 0;

      puVar2 = puVar2 + 1;

    }

    *(undefined1 *)puVar2 = 0;

    if (DAT_008ee9c8 == 0) {

      _local_4a = 0x20;

      _local_6e = 0x20;

    }

    else {

      FUN_005a78b0(&local_4a,&local_6e);

    }

    local_9c = PTR_DAT_00818344;

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

    FUN_00402710(&local_9c,"%s\n%s",local_50);

    FUN_004a2170(0,&local_9c);

    puVar2 = (undefined4 *)FUN_00466830();

    pwVar7 = (wchar_t *)*puVar2;

    if (*(int *)(pwVar7 + -2) == *(int *)(local_98 + -2)) {

      if (((*(int *)(pwVar7 + -4) == *(int *)(local_98 + -4)) || (*(int *)(pwVar7 + -4) == -1)) ||

         (*(int *)(local_98 + -4) == -1)) {

        iVar4 = wcscmp(pwVar7,local_98);

        bVar8 = iVar4 != 0;

      }

      else {

        bVar8 = true;

      }

    }

    else {

      bVar8 = true;

    }

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

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

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

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

    }

    if (bVar8) {

      FUN_0046a740();

    }

    pwVar7 = local_98 + -10;

    LVar3 = InterlockedDecrement((LONG *)(local_98 + -8));

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

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

    }

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

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

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

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

    }

  }

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

    iVar4 = FUN_0055e1d0();

    if (iVar4 == 0) {

      return 0;

    }

    cVar1 = FUN_0055e5c0();

    if (cVar1 == '\0') {

      FUN_00402730();

      FUN_0046a740();

      FUN_004011b0();

      (**(code **)(**(int **)(param_1 + 0x604) + 0x18))();

    }

    else {

      uStack_88 = 0;

      uStack_84 = 0;

      local_98 = (wchar_t *)0x0;

      uStack_94 = 0;

      FUN_00560e00(&uStack_88,&local_98);

      if (_DAT_00795610 <= (double)CONCAT44(uStack_84,uStack_88)) {

        puVar6 = &DAT_007a75f4;

        if ((double)CONCAT44(uStack_84,uStack_88) <= _DAT_00795610) {

          puVar6 = &DAT_00795320;

        }

      }

      else {

        puVar6 = &DAT_007a75f8;

      }

      if (_DAT_00795610 <= (double)CONCAT44(uStack_94,local_98)) {

        puVar5 = &DAT_007a75ec;

        if ((double)CONCAT44(uStack_94,local_98) <= _DAT_00795610) {

          puVar5 = &DAT_00795320;

        }

      }

      else {

        puVar5 = &DAT_007a75f0;

      }

      if ((double)CONCAT44(uStack_84,uStack_88) < _DAT_00795610) {

        local_90 = -(double)CONCAT44(uStack_84,uStack_88);

      }

      else {

        local_90 = (double)CONCAT44(uStack_84,uStack_88);

      }

      if ((double)CONCAT44(uStack_94,local_98) < _DAT_00795610) {

        uStack_80 = -(double)CONCAT44(uStack_94,local_98);

      }

      else {

        uStack_80 = (double)CONCAT44(uStack_94,local_98);

      }

      FUN_00480980(&local_9c,0,L"%.1f%s, %.1f%s",(undefined4)uStack_80,uStack_80._4_4_,puVar5,

                   SUB84(local_90,0),local_90._4_4_,puVar6);

      FUN_00466830(&local_90);

      cVar1 = FUN_00494e10();

      FUN_004011b0();

      if (cVar1 != '\0') {

        FUN_0046a740();

      }

      FUN_004a1be0(*(undefined4 *)(param_1 + 0x604),uStack_88,uStack_84,local_98,uStack_94);

      FUN_004011b0();

    }

  }

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

    iVar4 = FUN_005aa530();

    if (iVar4 == 0) {

      (**(code **)(**(int **)(param_1 + 0x608) + 0x18))();

    }

    else {

      local_9c = (undefined *)0xffffffff;

      local_98 = (wchar_t *)0xffffffff;

      FUN_004527f0(&local_9c,&local_98);

      FUN_00497d70();

      if ((local_9c != (undefined *)0xffffffff) && (local_98 != (wchar_t *)0xffffffff)) {

        local_90 = (double)CONCAT44(local_90._4_4_,local_9c + -0x400);

        FUN_004a1be0(*(undefined4 *)(param_1 + 0x608),

                     (double)(int)(local_9c + -0x400) * _DAT_007a7e00 + _DAT_00799088,

                     (double)(int)(local_98 + -0x200) * _DAT_007a7e00 + _DAT_00799088);

        return 1;

      }

    }

  }

  return 1;

}





// --- FUN_004a2960 at 0x004A2960 (size: 70) ---


undefined4 * __fastcall FUN_004a2960(undefined4 *param_1)



{

  LONG *pLVar1;

  

  *param_1 = &PTR_LAB_007ac6e0;

  param_1[1] = DAT_0083fb1c;

  param_1[2] = 0;

  param_1[3] = 0;

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

  param_1[4] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

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

  param_1[5] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  return param_1;

}





// --- FUN_004a29b0 at 0x004A29B0 (size: 71) ---


void __fastcall FUN_004a29b0(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[5];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[4];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_004a2a00 at 0x004A2A00 (size: 61) ---


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



{

  *param_1 = &PTR_FUN_007ac5a8;

  param_1[0x17e] = &PTR_FUN_007ac300;

  param_1[0x17e] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a2a40 at 0x004A2A40 (size: 115) ---


void __fastcall FUN_004a2a40(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  FUN_004639a0();

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

  piVar1 = (int *)FUN_0043c680();

  param_1 = param_1 + 0x5f8;

  (**(code **)(*piVar1 + 4))(0x4dd225,param_1);

  (**(code **)(*piVar1 + 4))(0x4dd226,param_1);

  (**(code **)(*piVar1 + 4))(0x4dd227,param_1);

  (**(code **)(*piVar1 + 4))(0x4dd228,param_1);

  return;

}





// --- FUN_004a2ac0 at 0x004A2AC0 (size: 19) ---


void FUN_004a2ac0(void)



{

  FUN_00460270(0x10000025,&LAB_004a2900);

  return;

}





// --- FUN_004a2ae0 at 0x004A2AE0 (size: 94) ---


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



{

  int iVar1;

  undefined4 uVar2;

  

  *param_2 = 0xffffffff;

  *param_3 = 0xffffffff;

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

    return 0;

  }

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

    iVar1 = FUN_005aa530();

    if (iVar1 == 0) {

      return 0;

    }

    uVar2 = FUN_004527f0(param_2,param_3);

    FUN_00497d70(uVar2);

  }

  return 1;

}





// --- FUN_004a2b40 at 0x004A2B40 (size: 76) ---


void __thiscall FUN_004a2b40(int param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 unaff_retaddr;

  

  if (((*(int *)(param_1 + 0x600) != 0) && (piVar1 = (int *)FUN_0046f670(0,0), piVar1 != (int *)0x0)

      ) && (iVar2 = (**(code **)(*piVar1 + 0x94))(0xc), iVar2 != 0)) {

    FUN_00460820(0x29,1);

    FUN_0046a790(unaff_retaddr,0,param_2);

  }

  return;

}





// --- FUN_004a2b90 at 0x004A2B90 (size: 175) ---


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



{

  LONG *lpAddend;

  char cVar1;

  undefined4 *puVar2;

  LONG LVar3;

  char *pcVar4;

  char *pcVar5;

  

  puVar2 = DAT_008ef11c;

  lpAddend = DAT_008ef11c + 1;

  InterlockedIncrement(lpAddend);

  LVar3 = InterlockedDecrement(lpAddend);

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

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

  }

  FUN_00403560(*(int *)(*param_3 + 8) + -2 + *(int *)(*param_1 + 8));

  pcVar4 = (char *)(*param_1 + 0x14);

  pcVar5 = (char *)(puVar2 + 5);

  do {

    cVar1 = *pcVar4;

    pcVar4 = pcVar4 + 1;

    *pcVar5 = cVar1;

    pcVar5 = pcVar5 + 1;

  } while (cVar1 != '\0');

  pcVar4 = (char *)(*param_3 + 0x14);

  pcVar5 = (char *)(*(int *)(*param_1 + 8) + 0x13 + (int)puVar2);

  do {

    cVar1 = *pcVar4;

    pcVar4 = pcVar4 + 1;

    *pcVar5 = cVar1;

    pcVar5 = pcVar5 + 1;

  } while (cVar1 != '\0');

  *param_2 = puVar2;

  InterlockedIncrement(puVar2 + 1);

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  return param_2;

}





// --- FUN_004a2ca0 at 0x004A2CA0 (size: 145) ---


undefined4 __fastcall FUN_004a2ca0(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  LONG LVar4;

  

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

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

    return 0;

  }

  iVar2 = puVar1[6];

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

  if (iVar2 == 0) {

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

  }

  else {

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

  }

  FUN_005bba60(puVar1);

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

    puVar3 = (undefined4 *)puVar1[5];

    LVar4 = InterlockedDecrement(puVar3 + 1);

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

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

    }

    puVar3 = (undefined4 *)puVar1[4];

    LVar4 = InterlockedDecrement(puVar3 + 1);

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

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

    }

    *puVar1 = &PTR_FUN_0079385c;

    operator_delete(puVar1);

  }

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

  return 1;

}





// --- FUN_004a2d40 at 0x004A2D40 (size: 166) ---


void __fastcall FUN_004a2d40(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  undefined **local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 *local_8;

  undefined4 *local_4;

  

  local_14 = DAT_0083fb1c;

  local_8 = DAT_008ef11c;

  local_18 = &PTR_LAB_007ac6e0;

  local_10 = 0;

  local_c = 0;

  InterlockedIncrement(DAT_008ef11c + 1);

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

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

  puVar2 = local_4;

  while (local_4 = puVar2, iVar1 != 0) {

    FUN_004a2ca0(&local_18);

    puVar2 = local_4;

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

  }

  LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  puVar2 = local_8;

  LVar3 = InterlockedDecrement(local_8 + 1);

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

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

  }

  return;

}





// --- FUN_004a2df0 at 0x004A2DF0 (size: 107) ---


int __thiscall FUN_004a2df0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  FUN_004a2d40();

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

  while( true ) {

    if (iVar1 == 0) {

      return param_1;

    }

    iVar3 = FUN_005df0f5(0x20);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      FUN_005bbbb0(iVar1);

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

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

    }

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

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

    }

    else {

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

      *(int *)(iVar2 + 0x18) = iVar3;

      *(int *)(iVar3 + 0x1c) = iVar2;

    }

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

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

    if (iVar1 == 0) break;

    iVar1 = *(int *)(iVar1 + 0x18);

  }

  return param_1;

}





// --- FUN_004a2e60 at 0x004A2E60 (size: 233) ---


void __fastcall FUN_004a2e60(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  int *piVar3;

  int iVar4;

  LONG LVar5;

  undefined4 *local_8;

  int local_4;

  

  local_8 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

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

    FUN_004034c0("You do not currently own a house.");

  }

  else {

    FUN_004034c0("The purchase price for this dwelling is:\n");

    FUN_005bc210(&local_8);

  }

  uVar2 = FUN_00404a40(0,local_8 + 5);

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

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

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

      iVar4 = (**(code **)(*piVar3 + 0x94))(0xc);

      if (iVar4 != 0) {

        FUN_00460820(0x29,1);

        FUN_0046a790(uVar2,0,0);

      }

    }

  }

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

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

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

  }

  puVar1 = local_8;

  LVar5 = InterlockedDecrement(local_8 + 1);

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

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

  }

  return;

}





// --- FUN_004a2f50 at 0x004A2F50 (size: 146) ---


void __fastcall FUN_004a2f50(int param_1)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 uVar3;

  undefined4 *local_8;

  int local_4;

  

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

    FUN_0048c3e0("Rent:\n");

    FUN_005bc2a0(&local_8);

    uVar3 = 0;

    uVar1 = FUN_00404a40(0,local_8 + 5);

    FUN_004a2b40(uVar1,uVar3);

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

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

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

    }

    LVar2 = InterlockedDecrement(local_8 + 1);

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

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

    }

  }

  return;

}





// --- FUN_004a2ff0 at 0x004A2FF0 (size: 154) ---


void __fastcall FUN_004a2ff0(int param_1)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 uVar3;

  undefined4 *local_8;

  int local_4;

  

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

    FUN_0048c3e0("Bought: ");

    FUN_005bc3f0(*(undefined4 *)(*(int *)(param_1 + 0x5fc) + 4),&local_8);

    uVar3 = 0;

    uVar1 = FUN_00404a40(0,local_8 + 5);

    FUN_004a2b40(uVar1,uVar3);

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

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

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

    }

    LVar2 = InterlockedDecrement(local_8 + 1);

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

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

    }

  }

  return;

}





// --- FUN_004a3090 at 0x004A3090 (size: 372) ---


void __fastcall FUN_004a3090(int param_1)



{

  undefined4 uVar1;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined4 *local_c;

  undefined4 *local_8;

  int local_4;

  

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

    FUN_0048c3e0("This maintenance period ends: ");

    FUN_005bc380(*(int *)(param_1 + 0x5fc) + 0x74,&local_8);

    uVar1 = FUN_005df4c4();

    FUN_005bc3f0(uVar1);

    uVar5 = 0;

    uVar1 = FUN_00404a40(0,local_8 + 5);

    FUN_004a2b40(uVar1,uVar5);

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

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

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

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

    }

    FUN_0048c3e0("Maintenance is next due: ");

    if ((*(int *)(*(int *)(param_1 + 0x5fc) + 0x78) == 0) && (iVar3 = FUN_005bb7e0(), iVar3 == 0)) {

      FUN_005bc380(*(int *)(param_1 + 0x5fc) + 0x74,&local_c);

    }

    else {

      FUN_005bc380(*(int *)(param_1 + 0x5fc) + 0x74,&local_c);

    }

    uVar1 = FUN_005df4c4();

    FUN_005bc3f0(uVar1);

    uVar5 = 0;

    uVar1 = FUN_00404a40(0,local_c + 5);

    FUN_004a2b40(uVar1,uVar5);

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

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

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

    }

    LVar2 = InterlockedDecrement(local_c + 1);

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

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

    }

    LVar2 = InterlockedDecrement(local_8 + 1);

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

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

    }

    return;

  }

  return;

}





// --- FUN_004a3210 at 0x004A3210 (size: 317) ---


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

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

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

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

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

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

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

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

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

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

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

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



void __fastcall FUN_004a3210(int param_1)



{

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

    FUN_004a2ae0();

  }

  return;

}





// --- FUN_004a3350 at 0x004A3350 (size: 240) ---


void __fastcall FUN_004a3350(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 uVar3;

  LONG LVar4;

  undefined4 uVar5;

  undefined4 *local_8;

  int local_4;

  

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

    local_8 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    if ((*(int *)(*(int *)(param_1 + 0x5fc) + 0x78) == 0) && (iVar2 = FUN_005bb7e0(), iVar2 == 0)) {

      FUN_005bc4a0(*(int *)(param_1 + 0x5fc) + 0x74,&local_8);

      uVar5 = 2;

      uVar3 = FUN_00404a40(0,local_8 + 5);

      FUN_004a2b40(uVar3,uVar5);

    }

    else {

      FUN_004034c0(

                  "The maintenance has already been paid for this period. You may not prepay next period\'s maintenance."

                  );

      uVar5 = 1;

      uVar3 = FUN_00404a40(0,local_8 + 5);

      FUN_004a2b40(uVar3,uVar5);

    }

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

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

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

    }

    puVar1 = local_8;

    LVar4 = InterlockedDecrement(local_8 + 1);

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

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

    }

    return;

  }

  return;

}





// --- FUN_004a3440 at 0x004A3440 (size: 609) ---


/* WARNING: Type propagation algorithm not settling */



void FUN_004a3440(void)



{

  undefined4 *puVar1;

  int *piVar2;

  int iVar3;

  tm *_Tm;

  LONG LVar4;

  undefined4 **ppuVar5;

  int *piVar6;

  undefined4 **ppuVar7;

  undefined *puVar8;

  undefined4 **ppuVar9;

  int **ppiVar10;

  undefined4 uVar11;

  undefined4 **ppuVar12;

  undefined4 uVar13;

  int *local_428;

  undefined8 uStack_424;

  int local_41c;

  undefined4 *local_418;

  undefined4 *puStack_414;

  undefined4 *puStack_410;

  int *local_40c;

  undefined4 local_408;

  undefined4 *puStack_404;

  char acStack_400 [1024];

  

  ppiVar10 = &local_428;

  piVar6 = (int *)((int)&uStack_424 + 4);

  puVar8 = &DAT_007ac1a8;

  local_428 = (int *)0x0;

  FUN_00406d10(piVar6,&DAT_007ac1a8,ppiVar10);

  FUN_00406570(piVar6,puVar8,ppiVar10);

  piVar6 = local_428;

  uVar11 = 0;

  local_40c = (int *)0x0;

  local_408 = 0;

  piVar2 = local_428;

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

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

  }

  piVar2 = (int *)FUN_0048bb00(&local_418,piVar2,uVar11);

  iVar3 = *piVar2;

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

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

  }

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

    if (-1 < iVar3) {

      uStack_424._0_4_ = 0;

      FUN_00590c20(199,&uStack_424,0,0);

      local_428 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      iVar3 = FUN_005bc360((int)uStack_424);

      if (iVar3 == 0) {

        uStack_424._0_4_ = (int)uStack_424 + 0x278d00;

        _Tm = localtime(&uStack_424);

        strftime(acStack_400,0x400,"%c",_Tm);

        FUN_0048c3e0(". This restriction does not apply to apartments.");

        FUN_0048c3e0(acStack_400);

        ppuVar12 = &puStack_414;

        ppuVar9 = &puStack_404;

        ppuVar7 = &puStack_410;

        ppuVar5 = &local_418;

        FUN_0048c3e0("You may buy another landscape house at ");

        FUN_004a2b90(ppuVar5,ppuVar7);

        uVar11 = FUN_004a2b90(ppuVar9,ppuVar12);

        FUN_0048a0a0(uVar11);

        LVar4 = InterlockedDecrement(puStack_404 + 1);

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

          (**(code **)*puStack_404)(1);

        }

        LVar4 = InterlockedDecrement(local_418 + 1);

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

          (**(code **)*local_418)(1);

        }

        puVar1 = uStack_424._4_4_;

        LVar4 = InterlockedDecrement(uStack_424._4_4_ + 1);

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

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

        }

        LVar4 = InterlockedDecrement(puStack_410 + 1);

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

          (**(code **)*puStack_410)(1);

        }

        LVar4 = InterlockedDecrement(puStack_414 + 1);

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

          (**(code **)*puStack_414)(1);

        }

      }

      else if (*(int *)(local_41c + 0x5fc) == 0) {

        FUN_004034c0("You may buy another house immediately.");

      }

      else {

        FUN_004034c0("You may buy another house immediately after you abandon this one.");

      }

      piVar6 = local_428;

      uVar13 = 0;

      uVar11 = FUN_00404a40(0,local_428 + 5);

      FUN_004a2b40(uVar11,uVar13);

      LVar4 = InterlockedDecrement(uStack_424._4_4_ + -4);

      if ((LVar4 == 0) && (uStack_424._4_4_ + -5 != (undefined4 *)0x0)) {

        (**(code **)uStack_424._4_4_[-5])(1);

      }

      LVar4 = InterlockedDecrement(piVar6 + 1);

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

        (**(code **)*piVar6)(1);

      }

    }

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

  }

  return;

}





// --- FUN_004a36b0 at 0x004A36B0 (size: 70) ---


void __fastcall FUN_004a36b0(int param_1)



{

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

    FUN_0046e460();

    FUN_004a2e60();

    FUN_004a2f50();

    FUN_004a2ff0();

    FUN_004a3090();

    FUN_004a3210();

    FUN_004a3350();

    FUN_004a3440();

    return;

  }

  return;

}





// --- FUN_004a3700 at 0x004A3700 (size: 139) ---


undefined4 __thiscall FUN_004a3700(int param_1,undefined4 param_2)



{

  int iVar1;

  

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

    iVar1 = FUN_005df0f5(0x7c);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_005bc890(param_2);

    }

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

    if (iVar1 == 0) {

      return 0;

    }

  }

  else {

    FUN_005bc830(param_2);

  }

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

    FUN_0046e460();

    FUN_004a2e60();

    FUN_004a2f50();

    FUN_004a2ff0();

    FUN_004a3090();

    FUN_004a3210();

    FUN_004a3350();

    FUN_004a3440();

  }

  return 1;

}





// --- FUN_004a3790 at 0x004A3790 (size: 99) ---


undefined4 __fastcall FUN_004a3790(int param_1)



{

  if (*(undefined4 **)(param_1 + 0x5fc) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x5fc))(1);

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

  }

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

    FUN_0046e460();

    FUN_004a2e60();

    FUN_004a2f50();

    FUN_004a2ff0();

    FUN_004a3090();

    FUN_004a3210();

    FUN_004a3350();

    FUN_004a3440();

  }

  return 1;

}





// --- FUN_004a3880 at 0x004A3880 (size: 57) ---


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



{

  int iVar1;

  

  if (0xb < param_3) {

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    *(undefined4 *)(iVar1 + 4) = *(undefined4 *)(param_1 + 8);

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    *param_2 = *param_2 + 4;

  }

  return 0xc;

}





// --- FUN_004a38c0 at 0x004A38C0 (size: 46) ---


undefined4 __thiscall FUN_004a38c0(int param_1,int *param_2)



{

  int iVar1;

  

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

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

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

  *param_2 = *param_2 + 4;

  return 1;

}





// --- FUN_004a3900 at 0x004A3900 (size: 554) ---


void __fastcall FUN_004a3900(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007acdc8;

  *puVar1 = &PTR_FUN_007acb20;

  param_1[0x17f] = &PTR_LAB_007acb18;

  param_1[0x180] = &PTR_FUN_007acb14;

  FUN_00465fb0(3);

  FUN_00465fb0(0xb);

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

  if (param_1[399] != 0) {

    FUN_004e3230();

  }

  if (param_1[400] != 0) {

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_004e3230();

  }

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

    FUN_00454490();

  }

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

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

  }

  param_1[0x199] = 0;

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

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

    param_1[0x1a3] = 0;

  }

  (**(code **)(*DAT_008f958c + 0x10))(1,0x142,param_1 + 0x17f);

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004a3b60 at 0x004A3B60 (size: 453) ---


void FUN_004a3b60(uint param_1,undefined4 *param_2,undefined4 *param_3)



{

  *param_2 = 0;

  *param_3 = 0;

  if (param_1 < 0x1000058f) {

    if (param_1 == 0x1000058e) {

      *param_2 = 0x4000000;

      *param_3 = 0;

      return;

    }

    switch(param_1) {

    case 0x100001da:

      *param_2 = 0x8000;

      *param_3 = 0;

      return;

    case 0x100001db:

      *param_2 = 0x10000;

      *param_3 = 1;

      return;

    case 0x100001dc:

      *param_2 = 0x40000;

      *param_3 = 1;

      return;

    case 0x100001dd:

      *param_2 = 0x20000;

      *param_3 = 2;

      return;

    case 0x100001de:

      *param_2 = 0x80000;

      *param_3 = 2;

      return;

    case 0x100001df:

      *param_2 = 0x3500000;

      *param_3 = 0;

      return;

    case 0x100001e0:

      *param_2 = 0x800000;

      *param_3 = 0;

      return;

    case 0x100001e1:

      *param_2 = 0x200000;

      *param_3 = 0;

      return;

    case 0x100001e2:

      *param_2 = 2;

      *param_3 = 0;

      return;

    case 0x100001e3:

      *param_2 = 0x40;

      *param_3 = 0;

      return;

    }

  }

  else {

    switch(param_1) {

    case 0x10000595:

      *param_2 = 0x10000000;

      *param_3 = 0;

      return;

    case 0x10000596:

      *param_2 = 0x20000000;

      *param_3 = 0;

      return;

    case 0x10000597:

      *param_2 = 0x40000000;

      *param_3 = 0;

      return;

    case 0x100005ab:

      *param_2 = 1;

      *param_3 = 0;

      return;

    case 0x100005ac:

      *param_2 = 0x200;

      *param_3 = 0;

      return;

    case 0x100005ad:

      *param_2 = 0x400;

      *param_3 = 0;

      return;

    case 0x100005ae:

      *param_2 = 0x800;

      *param_3 = 0;

      return;

    case 0x100005af:

      *param_2 = 0x1000;

      *param_3 = 0;

      return;

    case 0x100005b0:

      *param_2 = 0x20;

      *param_3 = 0;

      return;

    case 0x100005b1:

      *param_2 = 0x2000;

      *param_3 = 0;

      return;

    case 0x100005b2:

      *param_2 = 0x4000;

      *param_3 = 0;

      return;

    case 0x100005b3:

      *param_2 = 0x100;

      *param_3 = 0;

      break;

    case 0x100005e9:

      *param_2 = 0x8000000;

      *param_3 = 0;

      return;

    }

  }

  return;

}





// --- FUN_004a3de0 at 0x004A3DE0 (size: 149) ---


void __thiscall FUN_004a3de0(int param_1,int param_2)



{

  char cVar1;

  int iVar2;

  int local_c;

  byte local_8 [4];

  undefined1 local_4 [4];

  

  FUN_004e3380(param_2,&param_2,local_4,local_8);

  if ((param_2 != 0) && ((local_8[0] & 0xe) == 0)) {

    iVar2 = FUN_0055e1d0();

    if (iVar2 != 0) {

      local_c = 0;

      cVar1 = FUN_0055fcb0(param_2,&local_c,1);

      if (cVar1 != '\0') {

        (**(code **)(**(int **)(param_1 + 0x678) + 0x9c))(0x10000040);

        return;

      }

      if (local_c == 0) {

        (**(code **)(**(int **)(param_1 + 0x678) + 0x9c))(0x10000041);

      }

    }

  }

  return;

}





// --- FUN_004a3e80 at 0x004A3E80 (size: 162) ---


undefined4 FUN_004a3e80(undefined4 param_1,uint *param_2,undefined4 *param_3)



{

  uint *puVar1;

  undefined4 *puVar2;

  char cVar3;

  int iVar4;

  uint uVar5;

  int iVar6;

  

  iVar4 = FUN_005583f0(param_1);

  puVar2 = param_3;

  puVar1 = param_2;

  if (iVar4 == 0) {

    return 0;

  }

  uVar5 = *(uint *)(iVar4 + 0xc0);

  if ((*param_2 == 0x200000) && ((uVar5 & 0x100000) != 0)) {

    uVar5 = uVar5 | 0x200000;

    *param_3 = 1;

  }

  if ((*param_2 & uVar5) != 0) {

    iVar6 = FUN_0055e1d0();

    if (iVar6 != 0) {

      if ((*puVar1 & 0x80001ff) == 0) {

        cVar3 = FUN_005617d0(*(undefined4 *)(iVar4 + 8),*puVar2,0,1,0,0);

        if (cVar3 != '\0') {

          return 1;

        }

      }

      else {

        param_1 = 0;

        cVar3 = FUN_00560f30(*(undefined4 *)(iVar4 + 8),&param_1,0);

        if (cVar3 != '\0') {

          return 1;

        }

      }

    }

  }

  return 0;

}





// --- FUN_004a3f30 at 0x004A3F30 (size: 163) ---


void __fastcall FUN_004a3f30(int param_1)



{

  undefined4 uVar1;

  

  if (DAT_0083da58 != 0) {

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

      if (*(int *)(DAT_0083da58 + 0xf8) != 0) {

        uVar1 = FUN_00558410(*(undefined4 *)(DAT_0083da58 + 0xf4));

        uVar1 = FUN_00514fb0(uVar1);

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

        FUN_00514c60(0x433f5e2f,1);

        FUN_005101c0(*(undefined4 *)(param_1 + 0x66c),1,1,0);

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

          FUN_004557f0(*(undefined4 *)(param_1 + 0x664));

        }

      }

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

        return;

      }

    }

    uVar1 = FUN_00451bc0();

    FUN_00510480(uVar1);

  }

  return;

}





// --- FUN_004a3fe0 at 0x004A3FE0 (size: 43) ---


void __fastcall FUN_004a3fe0(int param_1)



{

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

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

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

    FUN_00512580();

  }

  FUN_00465fb0(3);

  return;

}





// --- FUN_004a4010 at 0x004A4010 (size: 430) ---


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



{

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

    if (param_2 == 0x7fffffff) {

      FUN_00512550(param_3,param_4);

      return;

    }

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

      FUN_00512560(0x10,param_3,param_4);

    }

    if (((*(uint *)(param_1 + 0x6a0) & 2) != 0) || ((*(uint *)(param_1 + 0x6a0) & 0x200) != 0)) {

      FUN_00512560(9,param_3,param_4);

    }

    if (((*(uint *)(param_1 + 0x6a0) & 4) != 0) || ((*(uint *)(param_1 + 0x6a0) & 0x400) != 0)) {

      FUN_00512560(0,param_3,param_4);

    }

    if (((*(uint *)(param_1 + 0x6a0) & 8) != 0) || ((*(uint *)(param_1 + 0x6a0) & 0x800) != 0)) {

      FUN_00512560(10,param_3,param_4);

      FUN_00512560(0xd,param_3,param_4);

    }

    if (((*(uint *)(param_1 + 0x6a0) & 0x10) != 0) || ((*(uint *)(param_1 + 0x6a0) & 0x1000) != 0))

    {

      FUN_00512560(0xb,param_3,param_4);

      FUN_00512560(0xe,param_3,param_4);

    }

    if (((*(uint *)(param_1 + 0x6a0) & 0x40) != 0) || ((*(uint *)(param_1 + 0x6a0) & 0x2000) != 0))

    {

      FUN_00512560(1,param_3,param_4);

      FUN_00512560(5,param_3,param_4);

    }

    if (((char)*(uint *)(param_1 + 0x6a0) < '\0') || ((*(uint *)(param_1 + 0x6a0) & 0x4000) != 0)) {

      FUN_00512560(2,param_3,param_4);

      FUN_00512560(6,param_3,param_4);

    }

    if ((*(byte *)(param_1 + 0x6a0) & 0x20) != 0) {

      FUN_00512560(0xc,param_3,param_4);

      FUN_00512560(0xf,param_3,param_4);

    }

    if ((*(uint *)(param_1 + 0x6a0) & 0x100) != 0) {

      FUN_00512560(3,param_3,param_4);

      FUN_00512560(7,param_3,param_4);

      FUN_00512560(4,param_3,param_4);

      FUN_00512560(8,param_3,param_4);

    }

  }

  return;

}





// --- FUN_004a41c0 at 0x004A41C0 (size: 118) ---


void __fastcall FUN_004a41c0(int param_1)



{

  uint uVar1;

  uint uVar2;

  uint local_4;

  

  local_4 = 0;

  FUN_00590c20(0x142,&local_4,0,0);

  uVar2 = local_4 & 2;

  uVar1 = local_4 & 4;

  (**(code **)(**(int **)(param_1 + 0x67c) + 0x18))(local_4 & 0xffffff01);

  (**(code **)(**(int **)(param_1 + 0x680) + 0x18))(uVar2 != 0);

  (**(code **)(**(int **)(param_1 + 0x684) + 0x18))(uVar1 != 0);

  return;

}





// --- FUN_004a4240 at 0x004A4240 (size: 451) ---


void __thiscall FUN_004a4240(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined1 local_80 [4];

  undefined1 local_7c [4];

  undefined4 local_78;

  undefined4 local_74;

  undefined4 local_70;

  undefined4 local_6c;

  undefined4 local_68;

  undefined4 local_64;

  undefined4 local_60;

  undefined4 local_5c;

  undefined4 local_58;

  undefined4 local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  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;

  undefined4 local_4;

  

  switch(param_2) {

  case 6:

  case 7:

    puVar2 = &local_78;

    puVar3 = &local_6c;

    local_78 = 0;

    local_74 = 0;

    local_70 = 0;

    local_6c = 0x3df5c28f;

    local_68 = 0xc0400000;

    local_64 = 0x3f6147ae;

    break;

  case 8:

    local_48 = 0;

    local_44 = 0;

    local_40 = 0;

    local_3c = 0x3df5c28f;

    local_38 = 0xc059999a;

    local_34 = 0x3f800000;

    puVar2 = &local_48;

    puVar3 = &local_3c;

    break;

  case 9:

    puVar2 = &local_60;

    puVar3 = &local_54;

    local_60 = 0;

    local_5c = 0;

    local_58 = 0;

    local_54 = 0x3df5c28f;

    local_50 = 0xc059999a;

    local_4c = 0x3f6147ae;

    break;

  default:

    goto switchD_004a4259_caseD_a;

  case 0xc:

    puVar2 = (undefined4 *)FUN_00415640(local_80,0x10000011,7);

    uVar1 = *puVar2;

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

    FUN_005101c0(uVar1,1,1,0);

    local_30 = 0;

    local_2c = 0;

    local_28 = 0;

    local_24 = 0x3df5c28f;

    local_20 = 0xc059999a;

    local_1c = 0x3f6147ae;

    puVar2 = &local_30;

    puVar3 = &local_24;

    break;

  case 0xd:

    puVar2 = (undefined4 *)FUN_00415640(local_7c,0x10000013,7);

    uVar1 = *puVar2;

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

    FUN_005101c0(uVar1,1,1,0);

    local_18 = 0;

    local_14 = 0;

    local_10 = 0;

    local_c = 0x3df5c28f;

    local_8 = 0xc059999a;

    local_4 = 0x3f6147ae;

    puVar2 = &local_18;

    puVar3 = &local_c;

  }

  FUN_0046be10(puVar3,puVar2);

switchD_004a4259_caseD_a:

  return;

}





// --- FUN_004a4430 at 0x004A4430 (size: 344) ---


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



{

  undefined4 *puVar1;

  

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = &PTR_LAB_007a6af4;

  param_1[0x180] = &PTR_LAB_007acb10;

  *param_1 = &PTR_FUN_007acdc8;

  param_1[0x17e] = &PTR_FUN_007acb20;

  param_1[0x17f] = &PTR_LAB_007acb18;

  param_1[0x180] = &PTR_FUN_007acb14;

  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[0x18a] = 0;

  param_1[0x18b] = 0;

  param_1[0x18c] = 0;

  param_1[0x18d] = 0;

  param_1[0x18e] = 0;

  param_1[399] = 0;

  param_1[400] = 0;

  param_1[0x191] = 0;

  param_1[0x192] = 0;

  param_1[0x193] = 0;

  param_1[0x194] = 0;

  param_1[0x195] = 0;

  param_1[0x196] = 0;

  param_1[0x197] = 0;

  param_1[0x198] = 0;

  param_1[0x199] = 0;

  param_1[0x19a] = 0;

  param_1[0x19c] = 0;

  param_1[0x19d] = 0;

  param_1[0x19e] = 0;

  param_1[0x19f] = 0;

  param_1[0x1a0] = 0;

  param_1[0x1a1] = 0;

  param_1[0x1a3] = 0;

  param_1[0x1a4] = 0;

  param_1[0x1a6] = 0;

  param_1[0x1a7] = 0;

  param_1[0x1a8] = 0;

  puVar1 = (undefined4 *)FUN_00415640(&param_3,0x10000005,7);

  param_1[0x19b] = *puVar1;

  return param_1;

}





// --- FUN_004a4590 at 0x004A4590 (size: 30) ---


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



{

  FUN_004a3900();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a45e0 at 0x004A45E0 (size: 223) ---


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



{

  int *piVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  undefined4 uVar6;

  

  uVar6 = 0;

  if ((param_2 != 0) && ((param_4 & 0xe) == 0)) {

    iVar3 = FUN_005583f0(param_2);

    if (iVar3 != 0) {

      iVar4 = FUN_0055e1d0();

      piVar1 = param_1;

      if (iVar4 != 0) {

        param_4 = 0;

        iVar4 = (**(code **)(*param_1 + 0xa0))();

        if (iVar4 != 0) {

          iVar4 = (**(code **)(*piVar1 + 0xa0))();

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

        }

        FUN_004a3b60(uVar6,&param_4,&param_1);

        uVar5 = *(uint *)(iVar3 + 0xc0);

        if ((param_4 == 0x200000) && ((uVar5 & 0x100000) != 0)) {

          uVar5 = uVar5 | 0x200000;

        }

        if ((param_4 & uVar5) != 0) {

          cVar2 = FUN_0055fad0(param_2,1);

          if (cVar2 != '\0') {

            FUN_004e1f20(0x10000040);

            return 1;

          }

        }

        FUN_004e1f20(0x10000041);

      }

    }

  }

  return 1;

}





// --- FUN_004a46d0 at 0x004A46D0 (size: 121) ---


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



void __fastcall FUN_004a46d0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

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

  if ((iVar1 != 0) && (*(double *)(param_1 + 0x698) <= _DAT_008379a8)) {

    uVar2 = DAT_007ac93c;

    uVar3 = DAT_007ac938;

    if ((iVar1 != 1) && (uVar2 = DAT_007ac934, uVar3 = DAT_007ac930, iVar1 != 2)) {

      FUN_004a3fe0();

      return;

    }

    FUN_004a4010(*(undefined4 *)(param_1 + 0x6a0),uVar3,uVar2);

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

    *(double *)(param_1 + 0x698) = _DAT_008379a8 + _DAT_007ac940;

  }

  return;

}





// --- FUN_004a4820 at 0x004A4820 (size: 114) ---


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



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  

  uVar2 = *(uint *)(param_2 + 0xc);

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

  param_3 = *(uint *)(param_2 + 8) & param_3;

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

  if ((((uVar1 != 0) && (uVar3 == 0)) && (0x1ff < uVar1)) && (uVar1 < 0x4001)) {

    uVar3 = 0x7f;

  }

  if ((param_3 != 0) && (uVar2 == 0)) {

    if (param_3 < 0x200) {

      return param_1;

    }

    if (0x4000 < param_3) {

      return param_1;

    }

    uVar2 = 0x7f;

  }

  if (uVar3 < uVar2) {

    param_1 = param_2;

  }

  return param_1;

}





// --- FUN_004a48a0 at 0x004A48A0 (size: 41) ---


undefined4 __fastcall FUN_004a48a0(int param_1)



{

  if ((((*(uint *)(param_1 + 0x100) & 0x800000) == 0) && (*(int *)(param_1 + 200) == 0)) &&

     (*(int *)(param_1 + 0xcc) == 0)) {

    return 0;

  }

  return 1;

}





// --- FUN_004a48d0 at 0x004A48D0 (size: 19) ---


void FUN_004a48d0(void)



{

  FUN_00460270(0x10000024,&LAB_004a45b0);

  return;

}





// --- FUN_004a48f0 at 0x004A48F0 (size: 458) ---


undefined4 __thiscall FUN_004a48f0(int param_1,int param_2)



{

  undefined1 uVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 *unaff_EBX;

  undefined4 *local_14;

  int *piStack_10;

  undefined4 *puStack_c;

  undefined4 local_8;

  int *local_4;

  

  if (param_2 == 0) {

    return 0;

  }

  local_14 = (undefined4 *)((uint)local_14 & 0xffffff00);

  FUN_006a0660();

  iVar2 = FUN_005583f0(param_2);

  if (iVar2 != 0) {

    FUN_006a0570(1);

    iVar3 = FUN_005df0f5(0xc);

    if (iVar3 == 0) {

      uVar4 = 0;

    }

    else {

      uVar4 = FUN_0058f490();

      uVar4 = FUN_00694a00(uVar4);

    }

    FUN_006a0610(uVar4);

    if ((((*(uint *)(iVar2 + 0x100) & 0x800000) == 0) && (*(int *)(iVar2 + 200) == 0)) &&

       (*(int *)(iVar2 + 0xcc) == 0)) {

      uVar1 = 0;

    }

    else {

      uVar1 = 1;

    }

    local_14 = (undefined4 *)CONCAT31(local_14._1_3_,uVar1);

  }

  local_8 = 0;

  local_4 = (int *)0x0;

  FUN_0042a2d0(0x1000000f);

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

    FUN_00429b10();

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

  }

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

  local_14 = (undefined4 *)0x0;

  piStack_10 = (int *)0x0;

  FUN_0042a2d0(0x10000011);

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

    FUN_00429b10();

    (**(code **)(*piStack_10 + 0x74))(unaff_EBX);

  }

  (**(code **)(**(int **)(param_1 + 0x670) + 0xd4))(&local_14);

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

     (iVar2 = unaff_EBX[1], unaff_EBX[1] = iVar2 + -1, iVar2 + -1 == 0)) {

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

  }

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

    iVar2 = local_14[1];

    local_14[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

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

    }

    local_14 = (undefined4 *)0x0;

  }

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

    iVar2 = piStack_10[1];

    piStack_10[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*piStack_10)(1);

    }

    piStack_10 = (int *)0x0;

  }

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

    iVar2 = puStack_c[1];

    puStack_c[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*puStack_c)(1);

    }

  }

  return 1;

}





// --- FUN_004a4ac0 at 0x004A4AC0 (size: 243) ---


int FUN_004a4ac0(uint param_1)



{

  undefined4 uVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined **local_20;

  undefined4 local_1c;

  uint local_18;

  undefined4 local_14;

  undefined **local_10;

  int local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (DAT_0083da58 == 0) {

    uVar1 = 0;

  }

  else {

    uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  iVar2 = FUN_005583f0(uVar1);

  if (iVar2 == 0) {

    return 0;

  }

  if (param_1 != 0) {

    iVar2 = FUN_0058ce20();

    if (iVar2 != 0) {

      local_10 = &PTR_FUN_007acafc;

      local_c = 0;

      local_8 = 0;

      local_4 = 0;

      local_20 = &PTR_FUN_007acafc;

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

      if (iVar2 != 0) {

        iVar4 = 0;

        do {

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

          local_18 = *(uint *)(iVar2 + 8);

          local_14 = *(undefined4 *)(iVar2 + 0xc);

          if ((param_1 & local_18) != 0) {

            iVar3 = FUN_004a4820(&local_20,&local_10,param_1);

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

            local_8 = *(undefined4 *)(iVar3 + 8);

            local_4 = *(undefined4 *)(iVar3 + 0xc);

            local_c = iVar4;

          }

          iVar2 = *(int *)(iVar2 + 0x10);

        } while (iVar2 != 0);

        if (iVar4 != 0) {

          return iVar4;

        }

      }

      if (DAT_0083da58 != 0) {

        return *(int *)(DAT_0083da58 + 0xf4);

      }

    }

  }

  return 0;

}





// --- FUN_004a4bc0 at 0x004A4BC0 (size: 203) ---


void __fastcall FUN_004a4bc0(int param_1)



{

  char cVar1;

  undefined4 uVar2;

  int *piVar3;

  int *piVar4;

  undefined4 local_c [3];

  

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

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

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

  }

  FUN_00415640(local_c,0x1000000c,7);

  uVar2 = FUN_004220b0(local_c[0],0xc);

  piVar3 = (int *)FUN_00415430(uVar2);

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

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

    *(int **)(param_1 + 0x68c) = piVar4;

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

        (cVar1 = (**(code **)(*piVar4 + 0x58))(piVar3[0x28],piVar3[0x29],piVar3[0x37],1),

        cVar1 != '\0')) && (cVar1 = FUN_00442c70(piVar3 + 0x2b,0,0x3f800000), cVar1 != '\0')) {

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

      return;

    }

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

  }

  return;

}





// --- FUN_004a4c90 at 0x004A4C90 (size: 327) ---


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



{

  char cVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  uint uVar5;

  undefined1 local_10 [16];

  

  if ((*(int *)(param_1 + 0x674) != 0) && (*(int *)(param_1 + 0x68c) != 0)) {

    iVar2 = FUN_0069fe00();

    iVar3 = FUN_0069fe30();

    cVar1 = FUN_004418d0(local_10,param_2 - iVar2,param_3 - iVar3);

    if (cVar1 == '\0') {

      return 0;

    }

    cVar1 = FUN_00423f40(&DAT_0081b17c);

    uVar5 = (uint)(cVar1 != '\0');

    cVar1 = FUN_00423f40(&DAT_0081b18c);

    if (cVar1 != '\0') {

      uVar5 = 0x202;

    }

    cVar1 = FUN_00423f40(&DAT_0081b19c);

    if (cVar1 != '\0') {

      uVar5 = 0x404;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1ac);

    if (cVar1 != '\0') {

      uVar5 = 0x808;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1bc);

    if (cVar1 != '\0') {

      uVar5 = 0x1010;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1cc);

    if (cVar1 != '\0') {

      uVar5 = 0x2040;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1dc);

    if (cVar1 != '\0') {

      uVar5 = 0x4080;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1ec);

    if (cVar1 != '\0') {

      uVar5 = 0x20;

    }

    cVar1 = FUN_00423f40(&DAT_0081b1fc);

    if (cVar1 != '\0') {

      uVar5 = 0x100;

    }

    uVar4 = FUN_004a4ac0(uVar5);

    return uVar4;

  }

  return 0;

}





// --- FUN_004a4de0 at 0x004A4DE0 (size: 210) ---


/* WARNING: Type propagation algorithm not settling */



bool FUN_004a4de0(undefined4 param_1)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  int iVar4;

  int local_98 [2];

  undefined1 local_90 [144];

  

  iVar2 = FUN_005583f0(param_1);

  if (iVar2 != 0) {

    if ((*(uint *)(iVar2 + 0xc0) & 0x8007fff) == 0) {

      FUN_0042dc80();

      FUN_00402730(L"You can\'t put that item there");

      FUN_0042cbe0(local_98,1);

      LVar3 = InterlockedDecrement((LONG *)(local_98[0] + -0x10));

      if ((LVar3 == 0) && ((undefined4 *)(local_98[0] + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(local_98[0] + -0x14))(1);

      }

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

    }

    else {

      iVar4 = FUN_0058de80(0);

      if (iVar4 != 0) {

        iVar4 = FUN_0055e1d0();

        if (iVar4 != 0) {

          local_98[1] = 0;

          cVar1 = FUN_00560f30(*(undefined4 *)(iVar2 + 8),local_98 + 1,0);

          return cVar1 != '\0';

        }

      }

    }

  }

  return false;

}





// --- FUN_004a4ec0 at 0x004A4EC0 (size: 245) ---


uint FUN_004a4ec0(int param_1)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

    iVar1 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (param_1 == iVar1) {

    return 0x7fffffff;

  }

  iVar1 = FUN_004a4ac0(0x404);

  if (iVar1 == param_1) {

    uVar2 = 4;

  }

  iVar1 = FUN_004a4ac0(0x2040);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 0x40;

  }

  iVar1 = FUN_004a4ac0(0x4080);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 0x80;

  }

  iVar1 = FUN_004a4ac0(0x100);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 0x100;

  }

  iVar1 = FUN_004a4ac0(0x202);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 2;

  }

  iVar1 = FUN_004a4ac0(0x808);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 8;

  }

  iVar1 = FUN_004a4ac0(0x1010);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 0x10;

  }

  iVar1 = FUN_004a4ac0(0x20);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 0x20;

  }

  iVar1 = FUN_004a4ac0(0x404);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 4;

  }

  iVar1 = FUN_004a4ac0(1);

  if (iVar1 == param_1) {

    uVar2 = uVar2 | 1;

  }

  return uVar2;

}





// --- FUN_004a4fc0 at 0x004A4FC0 (size: 85) ---


void __thiscall FUN_004a4fc0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int iVar2;

  

  iVar2 = FUN_004a4ec0(param_2);

  if (iVar2 != 0) {

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

    uVar1 = DAT_008379ac;

    *(undefined4 *)(param_1 + 0x698) = DAT_008379a8;

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

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

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

      FUN_00512580();

      FUN_00465f90(3);

    }

  }

  return;

}





// --- FUN_004a50f0 at 0x004A50F0 (size: 230) ---


void FUN_004a50f0(int param_1)



{

  int *piVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 local_10;

  int iStack_c;

  byte abStack_8 [4];

  undefined1 auStack_4 [4];

  

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

  piVar1 = *(int **)(*(int *)(param_1 + 0xc) + 0x10);

  uVar5 = 0;

  if (iVar4 == 0) {

    return;

  }

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

    return;

  }

  param_1 = 0;

  local_10 = 0;

  iVar3 = (**(code **)(*piVar1 + 0xa0))();

  if (iVar3 != 0) {

    iVar3 = (**(code **)(*piVar1 + 0xa0))();

    uVar5 = *(undefined4 *)(iVar3 + 0x2e4);

  }

  FUN_004a3b60(uVar5,&param_1,&local_10);

  FUN_004e3380(iVar4,&iStack_c,auStack_4,abStack_8);

  if (iStack_c == 0) {

    return;

  }

  if ((abStack_8[0] & 0xe) != 0) {

    return;

  }

  if ((abStack_8[0] & 1) == 0) {

    if (param_1 == 0) {

      if (piVar1[0xb9] != 0x100001d6) goto LAB_004a51b6;

      cVar2 = FUN_004a4de0(iStack_c);

    }

    else {

      cVar2 = FUN_004a3e80(iStack_c,&param_1,&local_10);

    }

    if (cVar2 != '\0') {

      return;

    }

  }

LAB_004a51b6:

  iVar4 = FUN_005583f0(iStack_c);

  if (iVar4 != 0) {

    FUN_0058cf00(0);

  }

  return;

}





// --- FUN_004a5200 at 0x004A5200 (size: 1217) ---


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



{

  bool bVar1;

  LONG LVar2;

  int iVar3;

  wchar_t *pwVar4;

  undefined4 *puVar5;

  wchar_t *pwVar6;

  int *piVar7;

  undefined *local_a0;

  undefined *local_9c;

  int *local_98;

  int local_94;

  undefined1 auStack_90 [144];

  

  local_a0 = PTR_DAT_00818340;

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

  local_9c = PTR_DAT_00818340;

  bVar1 = false;

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

  if (param_3 != 0) {

    local_98 = (int *)FUN_0058f8e0(&local_94,param_3,2,0);

    if (local_9c != (undefined *)*local_98) {

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

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

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

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

      }

      local_9c = (undefined *)*local_98;

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

    }

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

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

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

    }

  }

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

    if (param_3 == 0) {

      FUN_00407e40(L"Drag necklaces here to wear them");

      goto LAB_004a5630;

    }

LAB_004a55c9:

    bVar1 = true;

  }

  else {

    if ((param_2 == *(int *)(param_1 + 0x608)) || (param_2 == *(int *)(param_1 + 0x610))) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag bracelets here to wear them");

        goto LAB_004a5630;

      }

      goto LAB_004a55c9;

    }

    if ((param_2 == *(int *)(param_1 + 0x60c)) || (param_2 == *(int *)(param_1 + 0x614))) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag rings here to wear them");

        goto LAB_004a5630;

      }

      goto LAB_004a55c9;

    }

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

      if (param_3 == 0) {

        FUN_00407e40(L"Drag weapons here to wield them");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x61c)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag missile ammunition here to wield it");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x620)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag shields here to wield them");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x62c)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag trinkets here to activate them");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x630)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag cloaks here to activate them");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x634)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag a Blue Aetheria sigil here to activate it");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else if (param_2 == *(int *)(param_1 + 0x638)) {

      if (param_3 == 0) {

        FUN_00407e40(L"Drag a Yellow Aetheria sigil here to activate it");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

    else {

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

        if ((param_2 == *(int *)(param_1 + 0x624)) || (param_2 == *(int *)(param_1 + 0x628))) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag clothing items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x640)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag head items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x644)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag chest items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x648)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag abdomen items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x64c)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag upper arm items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x650)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag lower arm items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x654)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag glove items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x658)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag upper leg items here to wear them");

            goto LAB_004a5630;

          }

        }

        else if (param_2 == *(int *)(param_1 + 0x65c)) {

          if (param_3 == 0) {

            FUN_00407e40(L"Drag lower leg items here to wear them");

            goto LAB_004a5630;

          }

        }

        else {

          if (param_2 != *(int *)(param_1 + 0x660)) goto LAB_004a55cb;

          if (param_3 == 0) {

            FUN_00407e40(L"Drag foot coverings here to wear them");

            goto LAB_004a5630;

          }

        }

        goto LAB_004a55c9;

      }

      if (param_3 == 0) {

        FUN_00407e40(L"Drag a Red Aetheria sigil here to activate it");

        goto LAB_004a5630;

      }

      bVar1 = false;

    }

  }

LAB_004a55cb:

  if (param_3 != 0) {

    if (bVar1) {

      pwVar4 = L"take off";

      pwVar6 = L"worn";

    }

    else {

      pwVar4 = L"unwield";

      pwVar6 = L"wielded";

    }

    puVar5 = (undefined4 *)FUN_0058f8e0(&local_98,param_3,2,0);

    FUN_004027b0(&local_a0,L"%s (%s)\nDouble-click to %s",*puVar5,pwVar6,pwVar4);

    piVar7 = local_98 + -5;

    LVar2 = InterlockedDecrement(local_98 + -4);

    if ((LVar2 == 0) && (piVar7 != (int *)0x0)) {

      (**(code **)*piVar7)(1);

    }

  }

LAB_004a5630:

  FUN_0042dc80();

  FUN_0042cbe0(&local_a0,1);

  iVar3 = FUN_0046dc50(0);

  if (iVar3 != 0) {

    FUN_004618a0(auStack_90);

    *(uint *)(iVar3 + 0xa4) = *(uint *)(iVar3 + 0xa4) | 0x20;

  }

  FUN_0042e590();

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

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

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

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

  }

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

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

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

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

  }

  return;

}





// --- FUN_004a5fa0 at 0x004A5FA0 (size: 859) ---


void __thiscall FUN_004a5fa0(int param_1,int *param_2)



{

  int *piVar1;

  char cVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  int iVar6;

  

  piVar1 = param_2;

  iVar3 = param_2[2];

  if (iVar3 == 1) {

    if (*param_2 == 0x100005be) {

      FUN_00460cc0(0xe,&param_2);

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

        (**(code **)(**(int **)(param_1 + 0x668) + 0x18))(1);

        (**(code **)(**(int **)(param_1 + 0x674) + 0x18))(1);

        (**(code **)(**(int **)(param_1 + 0x640) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x644) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x648) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x64c) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x650) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x654) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x658) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x65c) + 0x18))(0);

        (**(code **)(**(int **)(param_1 + 0x660) + 0x18))(0);

        FUN_00462420(piVar1);

        return;

      }

      (**(code **)(**(int **)(param_1 + 0x668) + 0x18))(0);

      (**(code **)(**(int **)(param_1 + 0x674) + 0x18))(0);

      (**(code **)(**(int **)(param_1 + 0x640) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x644) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x648) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x64c) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x650) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x654) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x658) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x65c) + 0x18))(1);

      (**(code **)(**(int **)(param_1 + 0x660) + 0x18))(1);

      FUN_00462420(piVar1);

      return;

    }

  }

  else {

    if (iVar3 == 0x15) {

      if (*param_2 == 0x100001d6) {

        (**(code **)(**(int **)(param_1 + 0x678) + 0x9c))(0x1000003f);

      }

      FUN_004a50f0(piVar1);

      FUN_00462420(piVar1);

      return;

    }

    if (iVar3 == 0x21) {

      if (((*param_2 == 0x100001d6) && (iVar3 = FUN_004a4c90(param_2[5],param_2[6]), iVar3 != 0)) &&

         (cVar2 = FUN_004a48f0(iVar3), cVar2 != '\0')) {

        FUN_0045e120(*(undefined4 *)(param_1 + 0x670),0x10,0x10);

        FUN_006a9640(iVar3,0,0);

        FUN_00462420(piVar1);

        return;

      }

    }

    else if (iVar3 == 0x1c) {

      if (*param_2 == 0x100001d6) {

        uVar4 = (**(code **)(*DAT_00837ff4 + 0x18))();

        uVar5 = (**(code **)(*DAT_00837ff4 + 0x1c))();

        iVar3 = FUN_004a4c90(uVar4,uVar5);

        if (iVar3 != 0) {

          if (piVar1[3] == 7) {

            iVar6 = FUN_00564d30();

            if ((iVar6 != 0) && (iVar6 = FUN_00564d30(), *(int *)(iVar6 + 0x2c) != 0)) {

              iVar3 = FUN_00564d30();

              uVar4 = *(undefined4 *)(iVar3 + 0x2c);

              uVar5 = FUN_0048e5f0(uVar4);

              FUN_00564d30(uVar5);

              FUN_005658d0(uVar5,uVar4);

              FUN_00462420(piVar1);

              return;

            }

            FUN_0058d110(iVar3,0);

            FUN_00462420(piVar1);

            return;

          }

          if (piVar1[3] == 8) {

            FUN_0058d110(iVar3,0);

            FUN_00564d30(iVar3);

            FUN_005657b0(iVar3);

            FUN_00462420(piVar1);

            return;

          }

        }

      }

    }

    else if ((iVar3 == 0x3e) && (*param_2 == 0x100001d6)) {

      if (param_2[3] != 0) {

        if (*(int *)(DAT_0083e03c + 0x31c) != 0) {

          FUN_004a3de0(*(int *)(DAT_0083e03c + 0x31c));

          FUN_00462420(piVar1);

          return;

        }

        (**(code **)(**(int **)(param_1 + 0x678) + 0x9c))(0x1000003f);

        FUN_00462420(piVar1);

        return;

      }

      (**(code **)(**(int **)(param_1 + 0x678) + 0x9c))(0x1000003f);

    }

  }

  FUN_00462420(piVar1);

  return;

}





// --- FUN_004a6300 at 0x004A6300 (size: 1287) ---


void __thiscall FUN_004a6300(int param_1,undefined4 param_2,uint param_3)



{

  int iVar1;

  

  iVar1 = FUN_0055e1d0();

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x604),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x608),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x610),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x60c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x614),param_2);

  }

  if ((param_3 & 0x3500000) != 0) {

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x618),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x620),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x61c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x624),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x628),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x62c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x630),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x634),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x638),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x63c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x640),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x644),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x648),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x64c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x650),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x654),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x658),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x65c),param_2);

  }

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

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

    FUN_004e49f0();

    FUN_004e4a90(param_2);

    FUN_004a5200(*(undefined4 *)(param_1 + 0x660),param_2);

  }

  return;

}





// --- FUN_004a6810 at 0x004A6810 (size: 277) ---


void FUN_004a6810(undefined4 param_1,undefined4 param_2,int param_3,uint param_4,undefined4 param_5,

                 undefined4 param_6,int param_7,uint param_8)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  

  iVar1 = FUN_005583f0(param_1);

  iVar2 = FUN_0055e1d0();

  if (iVar1 != 0) {

    if (iVar2 != 0) {

      if (DAT_0083da58 == 0) {

        iVar3 = 0;

      }

      else {

        iVar3 = *(int *)(DAT_0083da58 + 0xf4);

      }

      if ((param_3 == iVar3) && (param_4 != 0)) {

        uVar4 = *(uint *)(iVar1 + 0xc0);

        if ((uVar4 & 0x8007fff) == 0) {

          *(uint *)(iVar2 + 0x230) = *(uint *)(iVar2 + 0x230) & ~param_4;

          uVar4 = param_4;

        }

        else {

          *(uint *)(iVar2 + 0x230) = *(uint *)(iVar2 + 0x230) & ~uVar4;

          *(uint *)(iVar2 + 0x234) = *(uint *)(iVar2 + 0x234) & ~*(uint *)(iVar1 + 0xbc);

        }

        FUN_004a6300(0,uVar4);

      }

    }

    if (DAT_0083da58 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if ((param_7 == iVar3) && (param_8 != 0)) {

      uVar4 = *(uint *)(iVar1 + 0xc0);

      if ((uVar4 & 0x8007fff) == 0) {

        *(uint *)(iVar2 + 0x230) = *(uint *)(iVar2 + 0x230) | param_8;

        FUN_004a6300(param_1,param_8);

        return;

      }

      *(uint *)(iVar2 + 0x230) = *(uint *)(iVar2 + 0x230) | uVar4;

      *(uint *)(iVar2 + 0x234) = *(uint *)(iVar2 + 0x234) | *(uint *)(iVar1 + 0xbc);

      FUN_004a6300(param_1,uVar4);

    }

  }

  return;

}





// --- FUN_004a6930 at 0x004A6930 (size: 163) ---


undefined4 FUN_004a6930(void)



{

  uint uVar1;

  uint uVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  

  if (DAT_0083da58 == 0) {

    uVar3 = 0;

  }

  else {

    uVar3 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  iVar4 = FUN_005583f0(uVar3);

  iVar5 = FUN_0055e1d0();

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

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

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

    FUN_004a6300(0,0x7fffffff);

    iVar4 = FUN_0058ce20();

    if (iVar4 != 0) {

      for (iVar4 = *(int *)(iVar4 + 4); iVar4 != 0; iVar4 = *(int *)(iVar4 + 0x10)) {

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

        uVar3 = *(undefined4 *)(iVar4 + 4);

        uVar2 = *(uint *)(iVar4 + 0xc);

        if (uVar1 != 0) {

          *(uint *)(iVar5 + 0x230) = *(uint *)(iVar5 + 0x230) | uVar1;

        }

        if ((uVar1 & 0x8007fff) != 0) {

          *(uint *)(iVar5 + 0x234) = *(uint *)(iVar5 + 0x234) | uVar2;

        }

        FUN_004a6300(uVar3,uVar1);

      }

      FUN_004a3f30();

    }

  }

  return 1;

}





// --- FUN_004a69e0 at 0x004A69E0 (size: 78) ---


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



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  *param_1 = &PTR_FUN_007ad9b0;

  param_1[0x17e] = &PTR_FUN_007ad708;

  return param_1;

}





// --- FUN_004a6ac0 at 0x004A6AC0 (size: 185) ---


void __fastcall FUN_004a6ac0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  

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

    if (DAT_0083da58 == 0) {

      iVar2 = 0;

    }

    else {

      iVar2 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (*(int *)(*(int *)(*(int *)(param_1 + 8) + 0x608) + 0x66c) != iVar2) {

      FUN_004e49f0();

      if (DAT_0083da58 == 0) {

        uVar1 = 0;

      }

      else {

        uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

      }

      FUN_004e4a90(uVar1);

      if (DAT_0083da58 == 0) {

        uVar1 = 0;

      }

      else {

        uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

      }

      FUN_004e5660(uVar1,0,1);

      if (DAT_0083da58 == 0) {

        uVar1 = 0;

      }

      else {

        uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

      }

      FUN_004e5770(uVar1,1);

    }

  }

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

    FUN_004a6930();

  }

  return;

}





// --- FUN_004a6bb0 at 0x004A6BB0 (size: 108) ---


void __thiscall

FUN_004a6bb0(int param_1,int param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5,

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



{

  if ((param_2 == *(int *)(*(int *)(*(int *)(param_1 + 0xc) + 0x600) + 0x66c)) &&

     (param_6 != *(int *)(*(int *)(*(int *)(param_1 + 8) + 0x608) + 0x66c))) {

    FUN_004e57f0();

  }

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

    FUN_004a6810(param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9);

  }

  return;

}





// --- FUN_004a6c20 at 0x004A6C20 (size: 44) ---


void __fastcall FUN_004a6c20(int param_1)



{

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

    FUN_004e3250();

    FUN_004e5890();

    return;

  }

  return;

}





// --- FUN_004a6c50 at 0x004A6C50 (size: 82) ---


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



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007ad9b0;

  *puVar1 = &PTR_FUN_007ad708;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a6cb0 at 0x004A6CB0 (size: 283) ---


void __fastcall FUN_004a6cb0(int param_1)



{

  undefined4 uVar1;

  int *piVar2;

  

  FUN_004639a0();

  uVar1 = FUN_00463c00(0x100001d3);

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

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

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

    uVar1 = 0;

  }

  else {

    uVar1 = (**(code **)(*piVar2 + 0x94))(0x10000024);

  }

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

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

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

    uVar1 = 0;

  }

  else {

    uVar1 = (**(code **)(*piVar2 + 0x94))(0x10000022);

  }

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

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

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

    uVar1 = 0;

  }

  else {

    uVar1 = (**(code **)(*piVar2 + 0x94))(0x10000021);

  }

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

  piVar2 = (int *)FUN_0043c680();

  param_1 = param_1 + 0x5f8;

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

  (**(code **)(*piVar2 + 4))(0x4dd1f1,param_1);

  (**(code **)(*piVar2 + 4))(0x4dd1f2,param_1);

  (**(code **)(*piVar2 + 4))(0x4dd1f6,param_1);

  (**(code **)(*piVar2 + 4))(0x4dd266,param_1);

  (**(code **)(*piVar2 + 4))(0x186ab,param_1);

  (**(code **)(*piVar2 + 4))(0x186a8,param_1);

  (**(code **)(*piVar2 + 4))(0x4dd25b,param_1);

  (**(code **)(*piVar2 + 4))(0x4dd25d,param_1);

  return;

}





// --- FUN_004a6dd0 at 0x004A6DD0 (size: 19) ---


void FUN_004a6dd0(void)



{

  FUN_00460270(0x10000023,&LAB_004a6a60);

  return;

}





// --- FUN_004a6df0 at 0x004A6DF0 (size: 196) ---


void __thiscall FUN_004a6df0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_005583f0(param_2);

  if (iVar1 != 0) {

    iVar2 = FUN_0058df90();

    if ((iVar2 != 0) &&

       ((((*(uint *)(iVar1 + 0x100) & 0x800000) != 0 || (*(int *)(iVar1 + 200) != 0)) ||

        (*(int *)(iVar1 + 0xcc) != 0)))) {

      (**(code **)(*(int *)(param_1 + -0x5f8) + 0x18))(1);

      if (DAT_0083da58 == 0) {

        iVar1 = 0;

      }

      else {

        iVar1 = *(int *)(DAT_0083da58 + 0xf4);

      }

      if (param_2 == iVar1) {

        if (DAT_0083da58 != 0) {

          FUN_004e5770(*(undefined4 *)(DAT_0083da58 + 0xf4),1);

          return;

        }

        FUN_004e5770(0,1);

        return;

      }

      FUN_004e5770(param_2,1);

    }

  }

  return;

}





// --- FUN_004a70e0 at 0x004A70E0 (size: 78) ---


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



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  *param_1 = &PTR_FUN_007aded0;

  param_1[0x17e] = &PTR_FUN_007adc28;

  return param_1;

}





// --- FUN_004a7190 at 0x004A7190 (size: 82) ---


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



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007aded0;

  *puVar1 = &PTR_FUN_007adc28;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a71f0 at 0x004A71F0 (size: 19) ---


void FUN_004a71f0(void)



{

  FUN_00460270(0x10000022,&LAB_004a7160);

  return;

}





// --- FUN_004a7210 at 0x004A7210 (size: 201) ---


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



void __thiscall FUN_004a7210(int param_1,double param_2)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  int local_4;

  

  param_2 = param_2 * _DAT_007ae020;

  if (_DAT_00795610 <= param_2) {

    if (param_2 <= _DAT_007938c0) goto LAB_004a725a;

    param_2._4_4_ = 0x3ff00000;

  }

  else {

    param_2._4_4_ = 0;

  }

  param_2 = (double)((ulonglong)param_2._4_4_ << 0x20);

LAB_004a725a:

  local_4 = param_1;

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

    FUN_00460760(0x69,(float)param_2);

  }

  floor(param_2 * _DAT_007ae018);

  uVar1 = FUN_005df4c4();

  FUN_00480980(&local_4,0,L"%d%%",uVar1);

  FUN_0046a740();

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

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

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

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

  }

  return;

}





// --- FUN_004a72e0 at 0x004A72E0 (size: 204) ---


void __fastcall FUN_004a72e0(int param_1)



{

  undefined4 uVar1;

  int *piVar2;

  

  FUN_004639a0();

  uVar1 = FUN_00463c00(0x100001d8);

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

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

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

    uVar1 = 0;

  }

  else {

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

  }

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

  FUN_004a7210(0,0);

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

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

    uVar1 = 0;

  }

  else {

    uVar1 = (**(code **)(*piVar2 + 0x94))(0x10000031);

  }

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

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

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

    uVar1 = 0;

  }

  else {

    uVar1 = (**(code **)(*piVar2 + 0x94))(0x10000031);

  }

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

  piVar2 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar2 + 4))(0x4dd220,param_1 + 0x5f8);

    (**(code **)(*piVar2 + 4))(0x4dd1f0,param_1 + 0x5f8);

  }

  return;

}





// --- FUN_004a74b0 at 0x004A74B0 (size: 61) ---


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



{

  *param_1 = &PTR_FUN_007ae0f8;

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17e] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a74f0 at 0x004A74F0 (size: 19) ---


void FUN_004a74f0(void)



{

  FUN_00460270(0x10000021,&LAB_004a7440);

  return;

}





// --- FUN_004a75c0 at 0x004A75C0 (size: 96) ---


void __fastcall FUN_004a75c0(int param_1)



{

  undefined4 uVar1;

  int *piVar2;

  

  FUN_004639a0();

  uVar1 = FUN_00463c00(0x100001c3);

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

  piVar2 = (int *)FUN_0043c680();

  (**(code **)(*piVar2 + 4))(0x4dd1f0,param_1 + 0x5f8);

  (**(code **)(*piVar2 + 4))(0x4dd215,param_1 + 0x5f8);

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

  return;

}





// --- FUN_004a7620 at 0x004A7620 (size: 94) ---


void __fastcall FUN_004a7620(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007ae558;

  *puVar1 = &PTR_FUN_007ae2b0;

  param_1[0x17f] = &PTR_LAB_007ae2a4;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  (**(code **)(*DAT_008f958c + 0x10))(1,0x81,param_1 + 0x17f);

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004a76b0 at 0x004A76B0 (size: 92) ---


undefined4 * __thiscall FUN_004a76b0(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 = &PTR_FUN_007ae558;

  param_1[0x17e] = &PTR_FUN_007ae2b0;

  param_1[0x17f] = &PTR_LAB_007ae2a4;

  param_1[0x180] = 0;

  param_1[0x181] = 0x3f800000;

  return param_1;

}





// --- FUN_004a7710 at 0x004A7710 (size: 30) ---


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



{

  FUN_004a7620();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a7760 at 0x004A7760 (size: 19) ---


void FUN_004a7760(void)



{

  FUN_00460270(0x10000020,&LAB_004a7730);

  return;

}





// --- FUN_004a7780 at 0x004A7780 (size: 719) ---


undefined4 __fastcall FUN_004a7780(int param_1)



{

  int *piVar1;

  int iVar2;

  LONG LVar3;

  int iVar4;

  int *piVar5;

  undefined *puVar6;

  int **ppiVar7;

  undefined4 uVar8;

  int *local_25c;

  undefined4 uStack_258;

  int *local_254;

  undefined4 local_250;

  int iStack_24c;

  int local_248;

  undefined1 local_244 [4];

  undefined1 auStack_240 [288];

  undefined1 auStack_120 [288];

  

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

    ppiVar7 = &local_25c;

    piVar5 = &local_248;

    puVar6 = &DAT_007ae278;

    local_25c = (int *)0x0;

    FUN_00406d10(piVar5,&DAT_007ae278,ppiVar7);

    FUN_00406570(piVar5,puVar6,ppiVar7);

    piVar5 = local_25c;

    uVar8 = 0;

    local_254 = (int *)0x0;

    local_250 = 0;

    piVar1 = local_25c;

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

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

    }

    piVar1 = (int *)FUN_0048bb00(local_244,piVar1,uVar8);

    iVar2 = *piVar1;

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

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

    }

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

      if (-1 < iVar2) {

        iVar2 = FUN_005df4c4();

        iVar2 = 100 - iVar2;

        if (iVar2 < 1) {

          FUN_0042dc80();

          FUN_0042c9c0(DAT_0083fdc8,0x10000001);

          uVar8 = FUN_0042e980(&local_25c,0);

          FUN_0046a740(uVar8);

          piVar5 = local_25c + -5;

          LVar3 = InterlockedDecrement(local_25c + -4);

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

            (**(code **)*piVar5)(1);

          }

        }

        else {

          iStack_24c = 0;

          FUN_00590c20(0x81,&iStack_24c,0,0);

          uStack_258 = 0;

          iVar4 = FUN_00590c20(0x8b,&uStack_258,0,0);

          if (iVar4 == 0) {

            FUN_00590c20(0x19,&uStack_258,0,0);

          }

          local_248 = FUN_005c9fb0(*(undefined4 *)(param_1 + 0x604),uStack_258);

          local_248 = local_248 - iStack_24c;

          FUN_0042dc80();

          FUN_0042c9c0(DAT_0083fdbc,0x10000001);

          FUN_0042e000(DAT_0083fdcc,iVar2,iVar2 >> 0x1f);

          uVar8 = FUN_0042e980(&local_25c,0);

          FUN_0046a740(uVar8);

          piVar5 = local_25c + -5;

          LVar3 = InterlockedDecrement(local_25c + -4);

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

            (**(code **)*piVar5)(1);

          }

          FUN_0042dc80();

          FUN_0042c9c0(DAT_0083fdc0,0x10000001);

          FUN_0042e000(DAT_0083fdcc,iVar2,iVar2 >> 0x1f);

          FUN_00469fa0(auStack_240);

          FUN_0042dc80();

          FUN_0042c9c0(DAT_0083fdc4,0x10000001);

          FUN_0042e000(DAT_0083fdd0,local_248,local_248 >> 0x1f);

          FUN_00469fa0(auStack_120);

          FUN_0042e590();

          FUN_0042e590();

        }

        FUN_0042e590();

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

        return 1;

      }

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

    }

  }

  return 0;

}





// --- FUN_004a7a80 at 0x004A7A80 (size: 30) ---


void __fastcall FUN_004a7a80(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0058fe80();

  *(float *)(param_1 + 0xc) = (float)fVar1;

  FUN_004a7780();

  return;

}





// --- FUN_004a7bc0 at 0x004A7BC0 (size: 46) ---


void __fastcall FUN_004a7bc0(int param_1)



{

  undefined4 uVar1;

  

  FUN_004639a0();

  uVar1 = FUN_00463c00(0x100001ba);

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

  uVar1 = FUN_00463c00(0x100001bd);

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

  return;

}





// --- FUN_004a7c50 at 0x004A7C50 (size: 75) ---


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



{

  *param_1 = &PTR_FUN_007ae8d8;

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x17e] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a7ca0 at 0x004A7CA0 (size: 19) ---


void FUN_004a7ca0(void)



{

  FUN_00460270(0x1000001f,&LAB_004a7bf0);

  return;

}





// --- FUN_004a7ea0 at 0x004A7EA0 (size: 31) ---


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



{

  if ((*param_1 == *param_2) && (param_1[1] == param_2[1])) {

    return 0;

  }

  return 1;

}





// --- FUN_004a7ec0 at 0x004A7EC0 (size: 32) ---


undefined4 __fastcall FUN_004a7ec0(int *param_1)



{

  if ((((-1 < *param_1) && (-1 < param_1[1])) && (*param_1 < 8)) && (param_1[1] < 8)) {

    return 1;

  }

  return 0;

}





// --- FUN_004a7ee0 at 0x004A7EE0 (size: 91) ---


void __fastcall FUN_004a7ee0(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)(param_1 + 0x16c);

  iVar2 = 8;

  do {

    *puVar1 = puVar1[-0x5a];

    puVar1[1] = puVar1[-0x59];

    puVar1[2] = puVar1[-0x58];

    puVar1[3] = puVar1[-0x57];

    puVar1[4] = puVar1[-0x56];

    puVar1[5] = puVar1[-0x55];

    puVar1[6] = puVar1[-0x54];

    puVar1[7] = puVar1[-0x53];

    puVar1 = puVar1 + 8;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  return;

}





// --- FUN_004a7f40 at 0x004A7F40 (size: 112) ---


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



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x183] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  param_1[0x186] = 0;

  param_1[0x187] = 0;

  *param_1 = &PTR_FUN_007af000;

  param_1[0x17e] = &PTR_FUN_007aed58;

  param_1[0x182] = 0xffffffff;

  return param_1;

}





// --- FUN_004a7fe0 at 0x004A7FE0 (size: 87) ---


void __fastcall FUN_004a7fe0(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007af000;

  *puVar1 = &PTR_FUN_007aed58;

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

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

  }

  param_1[0x186] = 0;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004a8090 at 0x004A8090 (size: 47) ---


undefined4 __thiscall

FUN_004a8090(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  FUN_006a9a60(param_2,param_3,param_4,param_5);

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

  return 1;

}





// --- FUN_004a80c0 at 0x004A80C0 (size: 237) ---


void __fastcall FUN_004a80c0(int param_1)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  

  iVar5 = 0;

  do {

    iVar4 = 0;

    iVar1 = 7 - iVar5;

    do {

      iVar2 = iVar1;

      if (*(int *)(*(int *)(param_1 + 0x134) + 0x608) == 0) {

        iVar2 = iVar5 + (7 - iVar4) * 8;

      }

      piVar3 = (int *)FUN_0046dc50(iVar2);

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

        iVar2 = *(int *)(param_1 + 4 + (iVar4 + iVar5 * 8) * 4);

        if (iVar2 == 0) {

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

        }

        else {

          FUN_00463c80(*(undefined4 *)(iVar2 + 4),3);

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

        }

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

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

          if ((((*(int *)(param_1 + 0x26c) == iVar5) &&

               (iVar2 = *(int *)(param_1 + 0x270), iVar2 == iVar4)) &&

              (-1 < *(int *)(param_1 + 0x26c))) &&

             (((-1 < iVar2 && (*(int *)(param_1 + 0x26c) < 8)) && (iVar2 < 8)))) {

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

          }

          else {

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

          }

        }

      }

      iVar4 = iVar4 + 1;

      iVar1 = iVar1 + 8;

    } while (iVar4 < 8);

    iVar5 = iVar5 + 1;

  } while (iVar5 < 8);

  return;

}





// --- FUN_004a81d0 at 0x004A81D0 (size: 124) ---


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



{

  int *piVar1;

  int iVar2;

  

  if (3 < param_3) {

    iVar2 = *(int *)*param_2;

    piVar1 = (int *)*param_2 + 1;

    *param_2 = (int)piVar1;

    if ((iVar2 == *(int *)(param_1 + 8)) && (3 < param_3 - 4)) {

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

      iVar2 = *param_2;

      *param_2 = iVar2 + 4;

      if (3 < param_3 - 8) {

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

        *param_2 = *param_2 + 4;

        iVar2 = FUN_004a8250(param_2,param_3 - 0xc);

        if (iVar2 != 0) {

          iVar2 = FUN_004a8250(param_2,param_3 - 0xc);

          if (iVar2 != 0) {

            return 1;

          }

        }

      }

    }

  }

  return 0;

}





// --- FUN_004a8250 at 0x004A8250 (size: 58) ---


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



{

  int iVar1;

  

  if (3 < param_3) {

    *param_1 = *(undefined4 *)*param_2;

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    if (3 < param_3 - 4) {

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

      *param_2 = *param_2 + 4;

      return 1;

    }

  }

  return 0;

}





// --- FUN_004a8290 at 0x004A8290 (size: 72) ---


undefined4 __fastcall FUN_004a8290(int param_1)



{

  if ((((*(int *)(param_1 + 0x10c) != 0) && (*(int *)(param_1 + 0x118) != 0)) &&

      (**(int **)(param_1 + 0x104) != 0)) &&

     (((**(int **)(param_1 + 0x110) != 0 && (*(int *)(**(int **)(param_1 + 0x104) + 8) == 6)) &&

      (*(int *)(**(int **)(param_1 + 0x110) + 8) == 6)))) {

    return 1;

  }

  return 0;

}





// --- FUN_004a82e0 at 0x004A82E0 (size: 292) ---


bool FUN_004a82e0(int *param_1,int *param_2,int *param_3,int *param_4)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  int *piVar4;

  int iVar5;

  uint uVar6;

  int iVar7;

  

  uVar3 = *param_2 - *param_1;

  uVar6 = param_2[1] - param_1[1];

  if (uVar3 == 0) {

    uVar2 = uVar6;

    if (uVar6 == 0) {

      return false;

    }

  }

  else {

    uVar2 = uVar3;

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

      iVar7 = (uVar6 ^ (int)uVar6 >> 0x1f) - ((int)uVar6 >> 0x1f);

      iVar1 = (uVar3 ^ (int)uVar3 >> 0x1f) - ((int)uVar3 >> 0x1f);

      if (iVar7 < iVar1) {

        *param_4 = iVar7;

      }

      else {

        *param_4 = iVar1;

      }

      if ((int)uVar3 % *param_4 != 0) {

        return false;

      }

      if ((int)uVar6 % *param_4 != 0) {

        return false;

      }

      goto LAB_004a8354;

    }

  }

  *param_4 = (uVar2 ^ (int)uVar2 >> 0x1f) - ((int)uVar2 >> 0x1f);

LAB_004a8354:

  iVar1 = (int)uVar3 / *param_4;

  iVar7 = (int)uVar6 / *param_4;

  iVar5 = 0;

  piVar4 = &DAT_00823bd4;

  do {

    if ((piVar4[-3] == iVar1) && (piVar4[-2] == iVar7)) {

      *param_3 = iVar5;

    }

    if ((piVar4[-1] == iVar1) && (*piVar4 == iVar7)) {

      *param_3 = iVar5 + 1;

    }

    if ((piVar4[1] == iVar1) && (piVar4[2] == iVar7)) {

      *param_3 = iVar5 + 2;

    }

    if ((piVar4[3] == iVar1) && (piVar4[4] == iVar7)) {

      *param_3 = iVar5 + 3;

    }

    if ((piVar4[5] == iVar1) && (piVar4[6] == iVar7)) {

      *param_3 = iVar5 + 4;

    }

    if ((piVar4[7] == iVar1) && (piVar4[8] == iVar7)) {

      *param_3 = iVar5 + 5;

    }

    if ((piVar4[9] == iVar1) && (piVar4[10] == iVar7)) {

      *param_3 = iVar5 + 6;

    }

    if ((piVar4[0xb] == iVar1) && (piVar4[0xc] == iVar7)) {

      *param_3 = iVar5 + 7;

    }

    piVar4 = piVar4 + 0x10;

    iVar5 = iVar5 + 8;

  } while ((int)piVar4 < 0x823c54);

  return iVar5 != 0x10;

}





// --- FUN_004a8410 at 0x004A8410 (size: 99) ---


void __fastcall FUN_004a8410(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

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

  iVar2 = 8;

  do {

    *puVar1 = puVar1[0x5a];

    puVar1[1] = puVar1[0x5b];

    puVar1[2] = puVar1[0x5c];

    puVar1[3] = puVar1[0x5d];

    puVar1[4] = puVar1[0x5e];

    puVar1[5] = puVar1[0x5f];

    puVar1[6] = puVar1[0x60];

    puVar1[7] = puVar1[0x61];

    puVar1 = puVar1 + 8;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  FUN_004a80c0();

  return;

}





// --- FUN_004a8480 at 0x004A8480 (size: 30) ---


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



{

  FUN_004a7fe0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a84a0 at 0x004A84A0 (size: 19) ---


void FUN_004a84a0(void)



{

  FUN_00460270(0x1000001e,&LAB_004a8040);

  return;

}





// --- FUN_004a84c0 at 0x004A84C0 (size: 261) ---


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



{

  char cVar1;

  int iVar2;

  undefined4 *local_8;

  int *local_4;

  

  local_8 = (undefined4 *)0x0;

  local_4 = (int *)0x0;

  if ((*(int **)(param_3 + 4) == (int *)0x0) ||

     (cVar1 = (**(code **)(**(int **)(param_3 + 4) + 0xf4))(param_2,&local_8), cVar1 == '\0')) {

    *param_1 = DAT_0083fe7c;

    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] + -1, local_4[1] = iVar2, iVar2 == 0)) {

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

    }

  }

  else {

    param_3 = DAT_0083fe7c;

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

      (**(code **)(*local_4 + 0xb0))(&param_3);

    }

    *param_1 = param_3;

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

    }

  }

  return param_1;

}





// --- FUN_004a85d0 at 0x004A85D0 (size: 93) ---


undefined4 * __fastcall FUN_004a85d0(undefined4 *param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

  *param_1 = &PTR_FUN_007af14c;

  puVar1 = param_1 + 0x41;

  iVar2 = 2;

  do {

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = 0;

    puVar1 = puVar1 + 3;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  param_1[0x47] = 0;

  param_1[0x48] = 0;

  param_1[0x49] = 0xffffffff;

  param_1[0x4a] = 0xffffffff;

  param_1[0x4b] = 0xffffffff;

  param_1[0x4c] = 0xffffffff;

  puVar1 = param_1;

  for (iVar2 = 0x40; puVar1 = puVar1 + 1, iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar1 = 0;

  }

  return param_1;

}





// --- FUN_004a8630 at 0x004A8630 (size: 147) ---


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



{

  int iVar1;

  uint uVar2;

  

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

  if (uVar2 <= param_3) {

    uVar2 = param_3;

    if (3 < param_3) {

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

      iVar1 = *param_2;

      uVar2 = param_3 - 4;

      *param_2 = iVar1 + 4;

      if (3 < uVar2) {

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

        iVar1 = *param_2;

        uVar2 = param_3 - 8;

        *param_2 = iVar1 + 4;

        if (3 < uVar2) {

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

          *param_2 = *param_2 + 4;

          uVar2 = param_3 - 0xc;

        }

      }

    }

    if (7 < uVar2) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      *param_2 = *param_2 + 4;

    }

    if (7 < uVar2 - 8) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      *param_2 = *param_2 + 4;

    }

  }

  return;

}





// --- FUN_004a86d0 at 0x004A86D0 (size: 73) ---


void __thiscall FUN_004a86d0(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 1;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af158;

  return;

}





// --- FUN_004a8770 at 0x004A8770 (size: 73) ---


void __thiscall FUN_004a8770(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 2;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af16c;

  return;

}





// --- FUN_004a87e0 at 0x004A87E0 (size: 73) ---


void __thiscall FUN_004a87e0(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 3;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af180;

  return;

}





// --- FUN_004a8880 at 0x004A8880 (size: 73) ---


void __thiscall FUN_004a8880(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 4;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af194;

  return;

}





// --- FUN_004a88f0 at 0x004A88F0 (size: 73) ---


void __thiscall FUN_004a88f0(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 5;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af1a8;

  return;

}





// --- FUN_004a8980 at 0x004A8980 (size: 73) ---


void __thiscall FUN_004a8980(undefined4 *param_1,undefined4 param_2,undefined4 *param_3)



{

  param_1[1] = DAT_0083fe7c;

  *param_1 = &PTR_FUN_007af138;

  param_1[2] = 6;

  param_1[3] = param_2;

  param_1[4] = *param_3;

  param_1[5] = param_3[1];

  param_1[6] = *param_3;

  param_1[7] = param_3[1];

  param_1[8] = 0;

  *param_1 = &PTR_LAB_007af1bc;

  return;

}





// --- FUN_004a8a00 at 0x004A8A00 (size: 97) ---


void __thiscall FUN_004a8a00(int param_1,int param_2,int param_3,int param_4)



{

  int iVar1;

  int iVar2;

  

  if (param_2 != 0) {

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

    if ((((-1 < iVar1) && (iVar2 = *(int *)(param_2 + 0x14), -1 < iVar2)) && (iVar1 < 8)) &&

       ((iVar2 < 8 && (iVar2 = iVar2 + iVar1 * 8, *(int *)(param_1 + 4 + iVar2 * 4) == param_2)))) {

      *(undefined4 *)(param_1 + 4 + iVar2 * 4) = 0;

    }

    *(int *)(param_2 + 0x10) = param_3;

    *(int *)(param_2 + 0x14) = param_4;

    if (((-1 < param_3) && (-1 < param_4)) && ((param_3 < 8 && (param_4 < 8)))) {

      *(int *)(param_1 + 4 + (param_4 + param_3 * 8) * 4) = param_2;

    }

  }

  return;

}





// --- FUN_004a8a70 at 0x004A8A70 (size: 98) ---


void __thiscall FUN_004a8a70(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  

  if (param_2 != 0) {

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

    if ((((-1 < iVar1) && (iVar2 = *(int *)(param_2 + 0x14), -1 < iVar2)) && (iVar1 < 8)) &&

       ((iVar2 < 8 && (iVar2 = iVar2 + iVar1 * 8, *(int *)(param_1 + 4 + iVar2 * 4) == param_2)))) {

      *(undefined4 *)(param_1 + 4 + iVar2 * 4) = 0;

    }

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

    iVar1 = *(int *)(param_2 + 0x1c);

    *(int *)(param_2 + 0x14) = iVar1;

    iVar2 = *(int *)(param_2 + 0x10);

    if (((-1 < iVar2) && (-1 < iVar1)) && ((iVar2 < 8 && (iVar1 < 8)))) {

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

    }

  }

  return;

}





// --- FUN_004a8ae0 at 0x004A8AE0 (size: 113) ---


void __fastcall FUN_004a8ae0(undefined4 *param_1)



{

  void *pvVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  uint uVar5;

  

  *param_1 = &PTR_FUN_007af14c;

  puVar4 = param_1;

  for (iVar2 = 0x40; puVar4 = puVar4 + 1, iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar4 = 0;

  }

  puVar3 = param_1 + 0x43;

  iVar2 = 2;

  do {

    uVar5 = 0;

    if (*puVar3 != 0) {

      do {

        pvVar1 = *(void **)(puVar3[-2] + uVar5 * 4);

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

          operator_delete(pvVar1);

        }

        uVar5 = uVar5 + 1;

      } while (uVar5 < *puVar3);

    }

    puVar3 = puVar3 + 3;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  param_1 = param_1 + 0x47;

  iVar2 = 2;

  do {

    puVar4 = param_1 + -3;

    param_1 = param_1 + -3;

    operator_delete__((void *)*puVar4);

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  return;

}





// --- FUN_004a8b60 at 0x004A8B60 (size: 30) ---


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



{

  FUN_004a8ae0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a8b80 at 0x004A8B80 (size: 110) ---


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



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  

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

    return 0;

  }

  uVar1 = param_1[1];

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

    if (uVar1 == 0) {

      iVar2 = 8;

    }

    else {

      iVar2 = uVar1 * 2;

    }

    iVar2 = FUN_00500570(iVar2);

    if (iVar2 == 0) {

      return 0;

    }

  }

  if (param_1[2] != 0) {

    iVar2 = *param_1;

    for (puVar3 = (undefined4 *)(iVar2 + -4 + param_1[2] * 4);

        (undefined4 *)(iVar2 + param_3 * 4) <= puVar3; puVar3 = puVar3 + -1) {

      puVar3[1] = *puVar3;

    }

  }

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

  param_1[2] = param_1[2] + 1;

  return 1;

}





// --- FUN_004a8bf0 at 0x004A8BF0 (size: 48) ---


void FUN_004a8bf0(int param_1,undefined4 param_2,undefined4 param_3)



{

  if (param_1 != 0) {

    FUN_004a8a00(param_1,param_2,param_3);

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

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

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

  }

  return;

}





// --- FUN_004a8c20 at 0x004A8C20 (size: 491) ---


int __thiscall FUN_004a8c20(int param_1,int *param_2,int *param_3,int param_4)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int unaff_EBX;

  int unaff_EBP;

  uint uVar5;

  int unaff_retaddr;

  uint local_4;

  

  iVar2 = *param_3;

  if ((((iVar2 < 0) || (iVar3 = param_3[1], iVar3 < 0)) || (7 < iVar2)) || (7 < iVar3)) {

    return -0x68;

  }

  piVar1 = param_2 + 4;

  uVar5 = iVar2 - *piVar1;

  local_4 = 0;

  if (param_2[3] == 0) {

    iVar4 = iVar3 - param_2[5];

  }

  else {

    iVar4 = param_2[5] - iVar3;

  }

  if (((param_4 == 0) || (iVar2 != *(int *)(param_1 + 0x124))) ||

     ((iVar3 != *(int *)(param_1 + 0x128) ||

      ((param_2[2] != 1 || (iVar2 = (**(code **)(*param_2 + 4))(uVar5,iVar4), iVar2 == 0)))))) {

    iVar2 = *(int *)(param_1 + 4 + (param_3[1] + *param_3 * 8) * 4);

LAB_004a8d01:

    if (iVar2 != 0) {

      if (*(int *)(iVar2 + 0xc) == param_2[3]) {

        return -0x69;

      }

      iVar2 = (**(code **)(*param_2 + 4))(uVar5,iVar4);

      if (iVar2 == 0) {

        return -100;

      }

      goto LAB_004a8d5f;

    }

  }

  else {

    iVar2 = *(int *)(param_1 + 4 + (*(int *)(param_1 + 0x130) + *(int *)(param_1 + 300) * 8) * 4);

    if (*(int *)(iVar2 + 8) == 1) {

      FUN_004a8a00(iVar2,*(undefined4 *)(param_1 + 0x124),*(undefined4 *)(param_1 + 0x128));

      local_4 = 1;

      goto LAB_004a8d01;

    }

  }

  iVar2 = (**(code **)*param_2)(uVar5,iVar4);

  if (iVar2 == 0) {

    return -100;

  }

LAB_004a8d5f:

  iVar2 = 1;

  if ((1 < (int)((uVar5 ^ (int)uVar5 >> 0x1f) - ((int)uVar5 >> 0x1f))) ||

     (1 < (int)((local_4 ^ (int)local_4 >> 0x1f) - ((int)local_4 >> 0x1f)))) {

    FUN_004a82e0(piVar1,unaff_retaddr,&local_4,&stack0x00000000);

    iVar3 = param_2[5];

    if (1 < unaff_retaddr) {

      iVar4 = *piVar1 << 3;

      do {

        iVar4 = iVar4 + (&DAT_00823bc8)[local_4 * 2] * 8;

        iVar3 = iVar3 + (&DAT_00823bcc)[local_4 * 2];

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

          return -0x6b;

        }

        iVar2 = iVar2 + 1;

      } while (iVar2 < unaff_retaddr);

    }

  }

  if (unaff_EBP == 0) {

    return 1;

  }

  return (unaff_EBX != 0) + 2;

}





// --- FUN_004a8e10 at 0x004A8E10 (size: 154) ---


void __fastcall FUN_004a8e10(int param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  void *pvVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 *puVar7;

  int local_4;

  

  puVar7 = (undefined4 *)(param_1 + 0x16c);

  local_4 = 8;

  do {

    iVar6 = 8;

    do {

      if ((((void *)puVar7[-0x5a] != (void *)0x0) &&

          (pvVar4 = (void *)*puVar7, pvVar4 != (void *)0x0)) && ((void *)puVar7[-0x5a] != pvVar4)) {

        puVar3 = (undefined4 *)(param_1 + 0x104 + *(int *)((int)pvVar4 + 0xc) * 0xc);

        puVar5 = (undefined4 *)*puVar3;

        puVar2 = puVar5 + *(int *)(param_1 + 0x10c + *(int *)((int)pvVar4 + 0xc) * 0xc);

        for (; puVar5 < puVar2; puVar5 = puVar5 + 1) {

          if ((void *)*puVar5 == pvVar4) {

            *puVar5 = puVar2[-1];

            piVar1 = puVar3 + 2;

            *piVar1 = *piVar1 + -1;

            break;

          }

        }

        operator_delete(pvVar4);

      }

      *puVar7 = 0;

      puVar7 = puVar7 + 1;

      iVar6 = iVar6 + -1;

    } while (iVar6 != 0);

    local_4 = local_4 + -1;

    if (local_4 == 0) {

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

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

      FUN_004a80c0();

      return;

    }

  } while( true );

}





// --- FUN_004a8ec0 at 0x004A8EC0 (size: 121) ---


void __fastcall FUN_004a8ec0(int param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  int iVar3;

  int iVar4;

  uint *puVar5;

  uint uVar6;

  

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

  iVar4 = 8;

  do {

    iVar3 = 8;

    do {

      puVar2[-0x5a] = 0;

      *puVar2 = 0;

      puVar2 = puVar2 + 1;

      iVar3 = iVar3 + -1;

    } while (iVar3 != 0);

    iVar4 = iVar4 + -1;

  } while (iVar4 != 0);

  puVar5 = (uint *)(param_1 + 0x10c);

  iVar4 = 2;

  do {

    uVar6 = 0;

    if (*puVar5 != 0) {

      do {

        pvVar1 = *(void **)(puVar5[-2] + uVar6 * 4);

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

          operator_delete(pvVar1);

        }

        uVar6 = uVar6 + 1;

      } while (uVar6 < *puVar5);

    }

    *puVar5 = 0;

    puVar5[-1] = 0;

    operator_delete__((void *)puVar5[-2]);

    puVar5[-2] = 0;

    puVar5 = puVar5 + 3;

    iVar4 = iVar4 + -1;

  } while (iVar4 != 0);

  return;

}





// --- FUN_004a8f50 at 0x004A8F50 (size: 554) ---


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



{

  char cVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  int iVar5;

  undefined1 auStack_34 [4];

  undefined1 auStack_30 [4];

  undefined1 auStack_2c [4];

  undefined1 auStack_28 [4];

  undefined1 auStack_24 [4];

  undefined1 auStack_20 [4];

  undefined1 auStack_1c [4];

  undefined1 auStack_18 [4];

  undefined1 auStack_14 [4];

  undefined4 *puStack_10;

  undefined4 *puStack_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  FUN_004a85d0();

  *param_1 = &PTR_FUN_007af1d0;

  param_1[0x4e] = 0;

  param_1[0x9b] = 0xffffffff;

  param_1[0x9c] = 0xffffffff;

  param_1[0x4d] = param_2;

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

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

    uVar3 = 0;

  }

  else {

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

  }

  param_1[0x4e] = uVar3;

  iVar5 = 0x40;

  do {

    FUN_0046f2c0(0x10000178,0);

    iVar5 = iVar5 + -1;

  } while (iVar5 != 0);

  uStack_8 = 0;

  uStack_4 = 0;

  cVar1 = (**(code **)(*(int *)param_1[0x4e] + 0xd0))(0x10000021,&uStack_8);

  if (cVar1 != '\0') {

    puVar4 = (undefined4 *)FUN_004a84c0(&uStack_4,0,&puStack_10);

    param_1[0x4f] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(&stack0xffffffc4,3,&puStack_10);

    param_1[0x50] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(&stack0xffffffc8,1,&puStack_10);

    param_1[0x51] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_34,2,&puStack_10);

    param_1[0x52] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_30,4,&puStack_10);

    param_1[0x53] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_2c,5,&puStack_10);

    param_1[0x54] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_28,6,&puStack_10);

    param_1[0x55] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_24,9,&puStack_10);

    param_1[0x56] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_20,7,&puStack_10);

    param_1[0x57] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_1c,8,&puStack_10);

    param_1[0x58] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_18,10,&puStack_10);

    param_1[0x59] = *puVar4;

    puVar4 = (undefined4 *)FUN_004a84c0(auStack_14,0xb,&puStack_10);

    param_1[0x5a] = *puVar4;

  }

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

    iVar5 = puStack_10[1];

    puStack_10[1] = iVar5 + -1;

    if (iVar5 + -1 == 0) {

      (**(code **)*puStack_10)(1);

    }

    puStack_10 = (undefined4 *)0x0;

  }

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

     (iVar5 = puStack_c[1], puStack_c[1] = iVar5 + -1, iVar5 + -1 == 0)) {

    (**(code **)*puStack_c)(1);

  }

  return param_1;

}





// --- FUN_004a9180 at 0x004A9180 (size: 534) ---


void __thiscall FUN_004a9180(int param_1,int param_2,int param_3,int param_4,undefined4 param_5)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  int iVar6;

  int local_8;

  int local_4;

  

  iVar3 = param_4;

  iVar6 = param_2;

  local_4 = param_3;

  local_8 = param_2;

  param_2 = 0;

  switch(param_5) {

  case 1:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a86d0(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x13c);

    }

    else {

      uVar5 = *(undefined4 *)(param_1 + 0x154);

    }

    break;

  case 2:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a8770(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x140);

    }

    else {

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

    }

    break;

  case 3:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a87e0(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x148);

    }

    else {

      uVar5 = *(undefined4 *)(param_1 + 0x160);

    }

    break;

  case 4:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a8880(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x144);

    }

    else {

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

    }

    break;

  case 5:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a88f0(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x14c);

    }

    else {

      uVar5 = *(undefined4 *)(param_1 + 0x164);

    }

    break;

  case 6:

    iVar4 = FUN_005df0f5(0x24);

    if (iVar4 == 0) {

      param_2 = 0;

    }

    else {

      param_2 = FUN_004a8980(iVar3,&local_8);

    }

    if (iVar3 == 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x150);

    }

    else {

      uVar5 = *(undefined4 *)(param_1 + 0x168);

    }

    break;

  default:

    goto switchD_004a91b1_default;

  }

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

switchD_004a91b1_default:

  iVar4 = param_2;

  *(int *)(param_1 + 4 + (param_3 + iVar6 * 8) * 4) = param_2;

  if (*(int *)(param_2 + 8) == 6) {

    FUN_004a8b80(&param_2,0);

    return;

  }

  uVar2 = *(uint *)(param_1 + 0x108 + iVar3 * 0xc);

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

  if (uVar2 <= (uint)piVar1[2]) {

    if (uVar2 == 0) {

      iVar6 = 8;

    }

    else {

      iVar6 = uVar2 * 2;

    }

    iVar6 = FUN_00500570(iVar6);

    if (iVar6 == 0) {

      return;

    }

  }

  *(int *)(*piVar1 + piVar1[2] * 4) = iVar4;

  piVar1[2] = piVar1[2] + 1;

  return;

}





// --- FUN_004a93b0 at 0x004A93B0 (size: 122) ---


undefined4 __thiscall FUN_004a93b0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  

  iVar1 = **(int **)(param_1 + 0x104 + (uint)(param_2 == 1) * 0xc);

  if (iVar1 != 0) {

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

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

    iVar4 = 0;

    if (0 < iVar2) {

      do {

        iVar3 = FUN_004a8c20(*(undefined4 *)(*(int *)(param_1 + 0x104) + iVar4 * 4),iVar1 + 0x10,0);

        if (0 < iVar3) {

          return 1;

        }

        iVar4 = iVar4 + 1;

      } while (iVar4 < iVar2);

    }

  }

  return 0;

}





// --- FUN_004a9430 at 0x004A9430 (size: 98) ---


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



{

  undefined4 uVar1;

  undefined4 uVar2;

  

  uVar1 = *(undefined4 *)(param_1 + 4 + (param_3[1] + *param_3 * 8) * 4);

  FUN_004a8a00(param_2,*param_3,param_3[1]);

  FUN_004a8a00(uVar1,DAT_00823c48,DAT_00823c4c);

  uVar2 = FUN_004a93b0(*(undefined4 *)(param_2 + 0xc));

  FUN_004a8a70(param_2);

  FUN_004a8a70(uVar1);

  return uVar2;

}





// --- FUN_004a9600 at 0x004A9600 (size: 43) ---


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



{

  *param_1 = &PTR_FUN_007af1d0;

  FUN_004a8ec0();

  FUN_004a8ae0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004a9630 at 0x004A9630 (size: 946) ---


void FUN_004a9630(void)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 local_200 [128];

  

  FUN_004a8ec0();

  local_200[0xf] = 5;

  local_200[0x14] = 5;

  local_200[2] = 0;

  local_200[3] = 2;

  local_200[4] = 1;

  local_200[5] = 0;

  local_200[6] = 0;

  local_200[7] = 3;

  local_200[8] = 2;

  local_200[9] = 0;

  local_200[10] = 0;

  local_200[0xb] = 4;

  local_200[0xc] = 3;

  local_200[0xd] = 0;

  local_200[0xe] = 0;

  local_200[0x10] = 4;

  local_200[0x11] = 0;

  local_200[0x12] = 0;

  local_200[0x13] = 6;

  local_200[0x15] = 0;

  local_200[0x16] = 0;

  local_200[0x17] = 4;

  local_200[0x18] = 6;

  local_200[0x19] = 0;

  local_200[0x1a] = 0;

  local_200[0x1b] = 3;

  local_200[0x1c] = 7;

  local_200[0x1d] = 0;

  local_200[0x1e] = 0;

  local_200[0x1f] = 2;

  local_200[0x20] = 0;

  local_200[0x21] = 1;

  local_200[0x22] = 0;

  local_200[0x23] = 1;

  local_200[0x24] = 1;

  local_200[0x25] = 1;

  local_200[0x26] = 0;

  local_200[0x27] = 1;

  local_200[0x28] = 2;

  local_200[0x29] = 1;

  local_200[0x2a] = 0;

  local_200[0x2b] = 1;

  local_200[0x2c] = 3;

  local_200[0x2d] = 1;

  local_200[0x2e] = 0;

  local_200[0x2f] = 1;

  local_200[0x30] = 4;

  local_200[0x31] = 1;

  local_200[0x32] = 0;

  local_200[0x33] = 1;

  local_200[0x34] = 5;

  local_200[0x35] = 1;

  local_200[0x36] = 0;

  local_200[0x37] = 1;

  local_200[0x38] = 6;

  local_200[0x39] = 1;

  local_200[0x3a] = 0;

  local_200[0x3b] = 1;

  local_200[0x3c] = 7;

  local_200[0x3d] = 1;

  local_200[0x3e] = 0;

  local_200[0x3f] = 1;

  local_200[0x40] = 0;

  local_200[0x41] = 6;

  local_200[0x42] = 1;

  local_200[0x60] = 0;

  local_200[0x50] = 4;

  local_200[0x5c] = 7;

  local_200[0x61] = 7;

  local_200[0x65] = 7;

  local_200[0x69] = 7;

  local_200[0x6b] = 4;

  local_200[0x6d] = 7;

  local_200[0x70] = 4;

  local_200[0x71] = 7;

  local_200[0x75] = 7;

  local_200[0x77] = 4;

  local_200[0x79] = 7;

  local_200[0x7c] = 7;

  local_200[0x7d] = 7;

  local_200[0x43] = 1;

  local_200[0x44] = 1;

  local_200[0x45] = 6;

  local_200[0x46] = 1;

  local_200[0x47] = 1;

  local_200[0x48] = 2;

  local_200[0x49] = 6;

  local_200[0x4a] = 1;

  local_200[0x4b] = 1;

  local_200[0x4c] = 3;

  local_200[0x4d] = 6;

  local_200[0x4e] = 1;

  local_200[0x4f] = 1;

  local_200[0x51] = 6;

  local_200[0x52] = 1;

  local_200[0x53] = 1;

  local_200[0x54] = 5;

  local_200[0x55] = 6;

  local_200[0x56] = 1;

  local_200[0x57] = 1;

  local_200[0x58] = 6;

  local_200[0x59] = 6;

  local_200[0x5a] = 1;

  local_200[0x5b] = 1;

  local_200[0x5d] = 6;

  local_200[0x5e] = 1;

  local_200[0x5f] = 1;

  local_200[0x62] = 1;

  local_200[99] = 2;

  local_200[100] = 1;

  local_200[0x66] = 1;

  local_200[0x67] = 3;

  local_200[0x68] = 2;

  local_200[0x6a] = 1;

  local_200[0x6c] = 3;

  local_200[0x6e] = 1;

  local_200[0x6f] = 5;

  local_200[0x72] = 1;

  local_200[0x73] = 6;

  local_200[0x74] = 5;

  local_200[0x76] = 1;

  local_200[0x78] = 6;

  local_200[0x7a] = 1;

  local_200[0x7b] = 3;

  local_200[0x7e] = 1;

  local_200[0x7f] = 2;

  puVar1 = local_200 + 2;

  iVar2 = 0x20;

  do {

    FUN_004a9180(puVar1[-2],puVar1[-1],*puVar1,puVar1[1]);

    puVar1 = puVar1 + 4;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  FUN_004a80c0();

  return;

}





// --- FUN_004a99f0 at 0x004A99F0 (size: 366) ---


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



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  int local_10;

  undefined4 local_c;

  int local_8;

  undefined4 local_4;

  

  if (param_2 == 0) {

    return 0xffffff9a;

  }

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

    return 0xffffff94;

  }

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

    return 0xffffff92;

  }

  iVar4 = 1;

  if (*param_3 < *(int *)(param_2 + 0x10)) {

    iVar4 = -1;

  }

  local_8 = *(int *)(param_2 + 0x10) + iVar4;

  if (-1 < local_8) {

    piVar5 = param_1 + *(int *)(param_2 + 0x14) + local_8 * 8 + 1;

    iVar3 = local_8;

    do {

      if (7 < iVar3) {

        return 0xffffff9a;

      }

      iVar1 = *piVar5;

      if (iVar1 != 0) {

        if ((*(int *)(iVar1 + 8) != 2) || (*(int *)(iVar1 + 0xc) != *(int *)(param_2 + 0xc))) {

          return 0xffffff95;

        }

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

          return 0xffffff92;

        }

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

        local_10 = *(int *)(param_2 + 0x10) + iVar4 * 2;

        local_c = uVar2;

        local_4 = uVar2;

        iVar4 = FUN_004a9430(param_2,&local_8);

        if (iVar4 == 0) {

          iVar4 = FUN_004a9430(param_2,&local_10);

          if (iVar4 == 0) {

            FUN_004a8bf0(iVar1,local_8,uVar2);

            FUN_004a8bf0(param_2,local_10,local_c);

            (**(code **)(*param_1 + 4))(iVar1);

            return 1;

          }

          return 0xffffff96;

        }

        return 0xffffff93;

      }

      iVar3 = iVar3 + iVar4;

      piVar5 = piVar5 + iVar4 * 8;

    } while (-1 < iVar3);

  }

  return 0xffffff9a;

}





// --- FUN_004a9b60 at 0x004A9B60 (size: 56) ---


int FUN_004a9b60(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_004a8c20(param_1,param_2,1);

  if ((0 < iVar1) && (iVar2 = FUN_004a9430(param_1,param_2), iVar2 != 0)) {

    return -0x6a;

  }

  return iVar1;

}





// --- FUN_004a9ba0 at 0x004A9BA0 (size: 845) ---


undefined4 __thiscall FUN_004a9ba0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  int iVar9;

  int *piVar10;

  int local_1c;

  int local_18;

  int *local_14;

  int local_10;

  int local_c;

  int local_8;

  int local_4;

  

  iVar1 = param_1 + param_2 * 0xc;

  iVar9 = **(int **)(param_1 + 0x104 + param_2 * 0xc);

  if (iVar9 != 0) {

    piVar2 = *(int **)(iVar9 + 0x10);

    local_10 = *(int *)(iVar9 + 0x14);

    local_18 = *(int *)(param_1 + 0x10c + (uint)(param_2 == 0) * 0xc);

    piVar10 = &DAT_00823bc8;

    local_14 = piVar2;

    do {

      local_4 = local_10 + piVar10[1];

      local_8 = *piVar10 + (int)piVar2;

      iVar7 = FUN_004a8c20(iVar9,&local_8,1);

      if ((0 < iVar7) && (iVar7 = FUN_004a9430(iVar9,&local_8), iVar7 == 0)) {

        return 0;

      }

      piVar10 = piVar10 + 2;

    } while ((int)piVar10 < 0x823c08);

    iVar7 = FUN_004a93b0(param_2);

    iVar9 = local_18;

    if ((iVar7 != 0) && (iVar7 = 0, 0 < local_18)) {

      do {

        iVar3 = *(int *)(*(int *)(param_1 + (uint)(param_2 == 0) * 0xc + 0x104) + iVar7 * 4);

        iVar8 = FUN_004a8c20(iVar3,&local_14,0);

        if (0 < iVar8) {

          local_4 = *(int *)(iVar3 + 0x14);

          iVar9 = *(int *)(iVar3 + 0x10);

          local_8 = iVar9;

          FUN_004a82e0(&local_8,&local_14,&local_c,&local_18);

          iVar7 = *(int *)(iVar1 + 0x10c);

          local_1c = 0;

          if (0 < local_18) {

            do {

              param_2 = 0;

              if (0 < iVar7) {

                do {

                  iVar3 = *(int *)(*(int *)(iVar1 + 0x104) + param_2 * 4);

                  iVar8 = FUN_004a8c20(iVar3,&local_8,1);

                  if (0 < iVar8) {

                    iVar8 = local_4 + iVar9 * 8;

                    iVar4 = *(int *)(param_1 + 4 + iVar8 * 4);

                    local_14 = (int *)(param_1 + 4 + iVar8 * 4);

                    if (iVar3 != 0) {

                      iVar8 = *(int *)(iVar3 + 0x10);

                      if ((((-1 < iVar8) && (iVar5 = *(int *)(iVar3 + 0x14), -1 < iVar5)) &&

                          (iVar8 < 8)) &&

                         ((iVar5 < 8 &&

                          (piVar2 = (int *)(param_1 + 4 + (iVar5 + iVar8 * 8) * 4), *piVar2 == iVar3

                          )))) {

                        *piVar2 = 0;

                      }

                      *(int *)(iVar3 + 0x10) = iVar9;

                      *(int *)(iVar3 + 0x14) = local_4;

                      if (((-1 < iVar9) && (-1 < local_4)) && ((iVar9 < 8 && (local_4 < 8)))) {

                        *local_14 = iVar3;

                      }

                    }

                    iVar8 = DAT_00823c4c;

                    iVar9 = DAT_00823c48;

                    if (iVar4 != 0) {

                      iVar5 = *(int *)(iVar4 + 0x10);

                      if ((((-1 < iVar5) && (iVar6 = *(int *)(iVar4 + 0x14), -1 < iVar6)) &&

                          (iVar5 < 8)) &&

                         ((iVar6 < 8 &&

                          (iVar6 = iVar6 + iVar5 * 8, *(int *)(param_1 + 4 + iVar6 * 4) == iVar4))))

                      {

                        *(undefined4 *)(param_1 + 4 + iVar6 * 4) = 0;

                      }

                      *(int *)(iVar4 + 0x10) = iVar9;

                      *(int *)(iVar4 + 0x14) = iVar8;

                      if (((-1 < iVar9) && (-1 < iVar8)) && ((iVar9 < 8 && (iVar8 < 8)))) {

                        *(int *)(param_1 + 4 + (iVar8 + iVar9 * 8) * 4) = iVar4;

                      }

                    }

                    iVar8 = FUN_004a93b0(*(undefined4 *)(iVar3 + 0xc));

                    iVar9 = *(int *)(iVar3 + 0x10);

                    if ((((-1 < iVar9) && (iVar5 = *(int *)(iVar3 + 0x14), -1 < iVar5)) &&

                        (iVar9 < 8)) &&

                       ((iVar5 < 8 &&

                        (piVar2 = (int *)(param_1 + 4 + (iVar5 + iVar9 * 8) * 4), *piVar2 == iVar3))

                       )) {

                      *piVar2 = 0;

                    }

                    iVar9 = *(int *)(iVar3 + 0x18);

                    *(undefined4 *)(iVar3 + 0x14) = *(undefined4 *)(iVar3 + 0x1c);

                    *(int *)(iVar3 + 0x10) = iVar9;

                    if (((-1 < iVar9) && (iVar5 = *(int *)(iVar3 + 0x14), -1 < iVar5)) &&

                       ((iVar9 < 8 && (iVar5 < 8)))) {

                      *(int *)(param_1 + 4 + (iVar5 + iVar9 * 8) * 4) = iVar3;

                    }

                    if (iVar4 != 0) {

                      iVar9 = *(int *)(iVar4 + 0x10);

                      if ((((-1 < iVar9) && (iVar3 = *(int *)(iVar4 + 0x14), -1 < iVar3)) &&

                          (iVar9 < 8)) &&

                         ((iVar3 < 8 &&

                          (piVar2 = (int *)(param_1 + 4 + (iVar3 + iVar9 * 8) * 4), *piVar2 == iVar4

                          )))) {

                        *piVar2 = 0;

                      }

                      iVar9 = *(int *)(iVar4 + 0x18);

                      *(undefined4 *)(iVar4 + 0x14) = *(undefined4 *)(iVar4 + 0x1c);

                      *(int *)(iVar4 + 0x10) = iVar9;

                      if (((-1 < iVar9) && (iVar3 = *(int *)(iVar4 + 0x14), -1 < iVar3)) &&

                         ((iVar9 < 8 && (iVar3 < 8)))) {

                        *(int *)(param_1 + 4 + (iVar3 + iVar9 * 8) * 4) = iVar4;

                      }

                    }

                    iVar9 = local_8;

                    if (iVar8 == 0) {

                      return 0;

                    }

                  }

                  param_2 = param_2 + 1;

                } while (param_2 < iVar7);

              }

              iVar9 = iVar9 + (&DAT_00823bc8)[local_c * 2];

              local_4 = local_4 + (&DAT_00823bcc)[local_c * 2];

              local_1c = local_1c + 1;

              local_8 = iVar9;

            } while (local_1c < local_18);

          }

          return 1;

        }

        iVar7 = iVar7 + 1;

      } while (iVar7 < iVar9);

    }

  }

  return 0;

}





// --- FUN_004a9fb0 at 0x004A9FB0 (size: 72) ---


uint __thiscall FUN_004a9fb0(int param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  iVar1 = FUN_004a93b0(param_2);

  if (iVar1 != 0) {

    iVar1 = FUN_004a9ba0(param_2);

    uVar2 = (-(uint)(iVar1 != 0) & 0x400) + 0x400;

  }

  *(uint *)(param_1 + 0x120) = (uint)(0x3ff < uVar2);

  return uVar2;

}





// --- FUN_004aa040 at 0x004AA040 (size: 79) ---


void FUN_004aa040(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  FUN_00564d30();

  FUN_00404a40(0,param_1);

  FUN_005649f0(&param_1,0,1,0);

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

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

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

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

  }

  return;

}





// --- FUN_004aa090 at 0x004AA090 (size: 291) ---


uint __thiscall FUN_004aa090(int param_1,int param_2,int param_3,uint param_4)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  void *pvVar4;

  int iVar5;

  undefined4 *puVar6;

  int iVar7;

  undefined4 uVar8;

  int iVar9;

  uint uVar10;

  int local_8;

  int local_4;

  

  iVar7 = param_3;

  piVar2 = (int *)(param_1 + 4 + (param_3 + param_2 * 8) * 4);

  pvVar4 = (void *)*piVar2;

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

    return param_4;

  }

  iVar5 = *(int *)((int)pvVar4 + 0xc);

  piVar3 = (int *)(param_1 + 0x104 + iVar5 * 0xc);

  *piVar2 = 0;

  puVar6 = (undefined4 *)*piVar3;

  puVar1 = puVar6 + piVar3[2];

  for (; puVar6 < puVar1; puVar6 = puVar6 + 1) {

    if ((void *)*puVar6 == pvVar4) {

      *puVar6 = puVar1[-1];

      piVar3[2] = piVar3[2] + -1;

      break;

    }

  }

  operator_delete(pvVar4);

  local_8 = param_2;

  local_4 = iVar7;

  iVar7 = FUN_005df0f5(0x24);

  if (iVar7 == 0) {

    iVar7 = 0;

  }

  else {

    iVar7 = FUN_004a88f0(iVar5,&local_8);

  }

  if (iVar5 == 0) {

    uVar8 = *(undefined4 *)(param_1 + 0x14c);

  }

  else {

    uVar8 = *(undefined4 *)(param_1 + 0x164);

  }

  *(undefined4 *)(iVar7 + 4) = uVar8;

  *piVar2 = iVar7;

  param_2 = iVar7;

  if (*(int *)(iVar7 + 8) == 6) {

    FUN_004a8b80(&param_2,0);

  }

  else {

    uVar10 = piVar3[1];

    if (uVar10 <= (uint)piVar3[2]) {

      if (uVar10 == 0) {

        iVar9 = 8;

      }

      else {

        iVar9 = uVar10 * 2;

      }

      iVar9 = FUN_00500570(iVar9);

      if (iVar9 == 0) goto LAB_004aa183;

    }

    *(int *)(*piVar3 + piVar3[2] * 4) = iVar7;

    piVar3[2] = piVar3[2] + 1;

  }

LAB_004aa183:

  uVar10 = FUN_004a9fb0(iVar5 == 0);

  return param_4 | uVar10;

}





// --- FUN_004aa1c0 at 0x004AA1C0 (size: 530) ---


uint __thiscall FUN_004aa1c0(int *param_1,int *param_2,int *param_3)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  int iVar5;

  uint uVar6;

  uint uVar7;

  

  piVar4 = param_3;

  iVar1 = *param_2;

  if (iVar1 < 0) {

    return 0xffffff98;

  }

  iVar2 = param_2[1];

  if (iVar2 < 0) {

    return 0xffffff98;

  }

  if (7 < iVar1) {

    return 0xffffff98;

  }

  if (7 < iVar2) {

    return 0xffffff98;

  }

  iVar3 = *param_3;

  if (iVar3 < 0) {

    return 0xffffff98;

  }

  if (param_3[1] < 0) {

    return 0xffffff98;

  }

  if (7 < iVar3) {

    return 0xffffff98;

  }

  if (param_3[1] < 8) {

    iVar5 = FUN_004a8290();

    if (iVar5 == 0) {

      return 0xffffff91;

    }

    iVar1 = param_1[iVar2 + iVar1 * 8 + 1];

    iVar2 = param_1[param_3[1] + iVar3 * 8 + 1];

    if (iVar1 != 0) {

      if (*(int *)(iVar1 + 0xc) != param_1[0x47]) {

        return 0xffffff99;

      }

      if (((*(int *)(iVar1 + 8) == 6) &&

          (uVar6 = iVar3 - *param_2 >> 0x1f, (iVar3 - *param_2 ^ uVar6) - uVar6 == 2)) &&

         (param_3[1] == param_2[1])) {

        uVar6 = FUN_004a99f0(iVar1,param_3);

        param_3 = (int *)iVar2;

      }

      else {

        uVar6 = FUN_004a9b60(iVar1,param_3);

        if ((int)uVar6 < 1) {

          return uVar6;

        }

        param_3 = (int *)iVar2;

        if ((uVar6 & 0x3ff) == 3) {

          param_3 = (int *)param_1[param_1[0x4c] + param_1[0x4b] * 8 + 1];

        }

      }

      if (0 < (int)uVar6) {

        FUN_004a8bf0(iVar1,*piVar4,piVar4[1]);

        FUN_004a8bf0(param_3,DAT_00823c48,DAT_00823c4c);

        param_1[0x49] = DAT_00823c48;

        param_1[0x4a] = DAT_00823c4c;

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

          uVar7 = piVar4[1] - param_2[1] >> 0x1f;

          if ((piVar4[1] - param_2[1] ^ uVar7) - uVar7 == 2) {

            param_1[0x49] = *param_2;

            param_1[0x4a] = (param_2[1] + piVar4[1]) / 2;

            param_1[0x4b] = *piVar4;

            param_1[0x4c] = piVar4[1];

          }

          if ((piVar4[1] == 0) || (piVar4[1] == 7)) {

            uVar6 = uVar6 | 0x1000;

          }

        }

        iVar2 = param_1[0x47];

        param_1[0x47] = (uint)(iVar2 == 0);

        uVar7 = FUN_004a9fb0((uint)(iVar2 == 0));

        uVar6 = uVar6 | uVar7;

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

          (**(code **)(*param_1 + 8))(iVar1,param_3);

          return uVar6;

        }

        (**(code **)(*param_1 + 4))(iVar1);

      }

      return uVar6;

    }

    return 0xffffff9a;

  }

  return 0xffffff98;

}





// --- FUN_004aa4a0 at 0x004AA4A0 (size: 285) ---


undefined4 __thiscall FUN_004aa4a0(int param_1,int param_2)



{

  LONG LVar1;

  int local_94;

  undefined1 local_90 [144];

  

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

    FUN_0042dc80();

    FUN_00402730(L"You are already playing this game.");

    FUN_0042cbe0(&local_94,1);

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

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

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

    }

  }

  else {

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

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

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

      FUN_006a9950(param_2,0xffffffff);

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

        (**(code **)(**(int **)(param_1 + 0x5fc) + 0x9c))(1);

      }

      FUN_004aa040("Attempting to join game, please wait...\n");

      return 1;

    }

    FUN_0042dc80();

    FUN_00402730(L"You are already playing another game.");

    FUN_0042cbe0(&local_94,1);

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

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

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

    }

  }

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  return 0;

}





// --- FUN_004aa5c0 at 0x004AA5C0 (size: 490) ---


void FUN_004aa5c0(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  char *pcVar3;

  

  puVar1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  if ((int)param_1 < 1) {

    switch(param_1) {

    case (undefined4 *)0xffffff92:

      pcVar3 = "You cannot castle after moving the King or Rook";

      break;

    case (undefined4 *)0xffffff93:

      pcVar3 = "You cannot castle through check";

      break;

    case (undefined4 *)0xffffff94:

      pcVar3 = "You cannot castle out of check";

      break;

    case (undefined4 *)0xffffff95:

      pcVar3 = "You can only move through empty squares";

      break;

    case (undefined4 *)0xffffff96:

      pcVar3 = "That move would put you in check";

      break;

    case (undefined4 *)0xffffff97:

      pcVar3 = "You cannot attack your own pieces";

      break;

    case (undefined4 *)0xffffff98:

      pcVar3 = "You cannot move off the board";

      break;

    case (undefined4 *)0xffffff99:

      pcVar3 = "The selected piece is not yours";

      break;

    case (undefined4 *)0xffffff9a:

      pcVar3 = "You tried to move an empty square";

      break;

    case (undefined4 *)0xffffff9b:

      pcVar3 = "The selected piece cannot move that far";

      break;

    case (undefined4 *)0xffffff9c:

      pcVar3 = "The selected piece cannot move that direction";

      break;

    default:

      pcVar3 = "That move is invalid";

      break;

    case (undefined4 *)0xfffffffd:

      FUN_004aa040("Its not your turn, please wait for your opponents move.\n");

      FUN_005abb30();

      return;

    }

    FUN_004034c0(pcVar3);

    FUN_0048c3e0(", try again.  ");

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

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

    }

    LVar2 = InterlockedDecrement(param_1 + 1);

    if (LVar2 == 0) {

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

    }

    FUN_0048c3e0("It is your turn to move.\n");

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

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

    }

    LVar2 = InterlockedDecrement(param_1 + 1);

    if (LVar2 == 0) {

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

    }

  }

  else if (((uint)param_1 & 0x800) == 0) {

    FUN_004034c0("Move in progress.");

    if (((uint)param_1 & 0x400) == 0) {

      pcVar3 = "\n";

    }

    else {

      pcVar3 = "  Your opponent is in Check.\n";

    }

    FUN_0048c3e0(pcVar3);

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

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

    }

    LVar2 = InterlockedDecrement(param_1 + 1);

    if (LVar2 == 0) {

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

    }

  }

  else {

    FUN_004034c0("You have checkmated your opponent!\n");

  }

  FUN_004aa040(puVar1 + 5);

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return;

}





// --- FUN_004aa850 at 0x004AA850 (size: 199) ---


void __thiscall FUN_004aa850(undefined4 *param_1,uint param_2)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = DAT_008ef11c;

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

    FUN_004aa040("You have been checkmated!\n");

    return;

  }

  InterlockedIncrement(DAT_008ef11c + 1);

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

    FUN_004034c0("You are in check!  ");

  }

  FUN_0048c3e0("It is your turn to move.\n");

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

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

  }

  LVar2 = InterlockedDecrement(param_1 + 1);

  if (LVar2 == 0) {

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

  }

  FUN_004aa040(puVar1 + 5);

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return;

}





// --- FUN_004aa920 at 0x004AA920 (size: 124) ---


void __thiscall FUN_004aa920(int param_1,undefined4 param_2)



{

  int iVar1;

  

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

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

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

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

  FUN_004aa040(param_2);

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

    (**(code **)(**(int **)(param_1 + 0x604) + 0x9c))(1);

  }

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

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

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

  *(undefined4 *)(iVar1 + 0x124) = 0xffffffff;

  *(undefined4 *)(iVar1 + 0x128) = 0xffffffff;

  *(undefined4 *)(iVar1 + 300) = 0xffffffff;

  *(undefined4 *)(iVar1 + 0x130) = 0xffffffff;

  *(undefined4 *)(iVar1 + 0x26c) = 0xffffffff;

  *(undefined4 *)(iVar1 + 0x270) = 0xffffffff;

  return;

}





// --- FUN_004aa9a0 at 0x004AA9A0 (size: 486) ---


void __thiscall FUN_004aa9a0(int param_1,int *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  int iVar6;

  uint local_8;

  int local_4;

  

  uVar5 = 0xffffffff;

  iVar6 = -1;

  if ((*param_2 == 0x10000174) && (*(int *)(param_1 + 0x138) != 0)) {

    iVar2 = FUN_0046e5e0();

    if (iVar2 != 0) {

      uVar3 = FUN_00480780(iVar2);

      uVar5 = uVar3 & 0x80000007;

      if ((int)uVar5 < 0) {

        uVar5 = (uVar5 - 1 | 0xfffffff8) + 1;

      }

      iVar6 = (int)(uVar3 + ((int)uVar3 >> 0x1f & 7U)) >> 3;

    }

  }

  if (((((param_2[3] == 7) && (-1 < (int)uVar5)) && ((int)uVar5 < 8)) &&

      ((-1 < iVar6 && (iVar6 < 8)))) && (*(int *)(*(int *)(param_1 + 0x134) + 0x610) == 3)) {

    iVar2 = *(int *)(*(int *)(param_1 + 0x134) + 0x608);

    if (iVar2 == 0) {

      iVar6 = 7 - iVar6;

    }

    else {

      uVar5 = 7 - uVar5;

    }

    local_8 = uVar5;

    local_4 = iVar6;

    iVar4 = FUN_004a7ec0();

    if (iVar4 != 0) {

      puVar1 = (uint *)(param_1 + 0x26c);

      iVar4 = FUN_004a7ec0();

      if (iVar4 != 0) {

        iVar2 = FUN_004a7ea0(&local_8);

        if (iVar2 == 0) {

          *puVar1 = 0xffffffff;

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

          FUN_004a80c0();

          return;

        }

        FUN_004a7ee0();

        param_2 = (int *)FUN_004aa1c0(puVar1,&local_8);

        if (0 < (int)param_2) {

          if (((uint)param_2 & 0x1000) != 0) {

            param_2 = (int *)FUN_004aa090(uVar5,iVar6,param_2);

          }

          FUN_004a8090(*puVar1,*(undefined4 *)(param_1 + 0x270),uVar5,iVar6);

          *puVar1 = local_8;

          *(int *)(param_1 + 0x270) = local_4;

          FUN_004aa5c0(param_2);

          FUN_004a80c0();

          return;

        }

        *puVar1 = 0xffffffff;

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

        FUN_004aa5c0(param_2);

        FUN_004a80c0();

        return;

      }

      iVar6 = *(int *)(param_1 + 4 + (iVar6 + uVar5 * 8) * 4);

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

        *puVar1 = local_8;

        *(int *)(param_1 + 0x270) = local_4;

        FUN_004a80c0();

      }

    }

  }

  return;

}





// --- FUN_004aab90 at 0x004AAB90 (size: 128) ---


void FUN_004aab90(int param_1)



{

  uint uVar1;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

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

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

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

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

  FUN_004a7ee0();

  uVar1 = FUN_004aa1c0(&local_8,&local_10);

  FUN_004a8e10();

  if (0 < (int)uVar1) {

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

      uVar1 = FUN_004aa090(*(undefined4 *)(param_1 + 0x14),*(undefined4 *)(param_1 + 0x18),uVar1);

    }

    FUN_004aa850(uVar1);

    FUN_004a80c0();

  }

  return;

}





// --- FUN_004ab090 at 0x004AB090 (size: 107) ---


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



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x182] = 0;

  param_1[0x184] = 0;

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

  *param_1 = &PTR_FUN_007afba0;

  param_1[0x17e] = &PTR_FUN_007af8f8;

  param_1[0x181] = 0xbff00000;

  param_1[0x183] = 0xbff00000;

  param_1[0x185] = 0xbff00000;

  return param_1;

}





// --- FUN_004ab130 at 0x004AB130 (size: 52) ---


void __fastcall FUN_004ab130(int param_1)



{

  undefined4 uVar1;

  int *piVar2;

  

  FUN_004639a0();

  uVar1 = FUN_00463c00(0x10000169);

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

  piVar2 = (int *)FUN_0043c680();

  (**(code **)(*piVar2 + 4))(0x4dd21d,param_1 + 0x5f8);

  return;

}





// --- FUN_004ab1a0 at 0x004AB1A0 (size: 92) ---


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



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007afba0;

  *puVar1 = &PTR_FUN_007af8f8;

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  param_1[0x17f] = 0;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004ab200 at 0x004AB200 (size: 19) ---


void FUN_004ab200(void)



{

  FUN_00460270(0x1000001d,&LAB_004ab170);

  return;

}





// --- FUN_004ab220 at 0x004AB220 (size: 526) ---


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



undefined4 __fastcall FUN_004ab220(int param_1)



{

  undefined4 uVar1;

  LONG LVar2;

  float10 fVar3;

  int local_1b4;

  undefined1 local_1b0 [144];

  undefined1 auStack_120 [144];

  undefined1 auStack_90 [144];

  

  FUN_0042dc80();

  FUN_0042c9c0();

  uVar1 = FUN_0042e980();

  FUN_0046a740(uVar1);

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

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

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

  }

  FUN_0042c9c0();

  FUN_00469fa0(local_1b0);

  FUN_0042c9c0();

  FUN_00469fa0(local_1b0);

  FUN_004114c0();

  fVar3 = (float10)FUN_004116d0();

  FUN_0042dc80();

  FUN_0042c9c0();

  FUN_0042e080(DAT_0083ff84,(double)(float)fVar3,2);

  FUN_00469fa0(auStack_90);

  FUN_0042dc80();

  FUN_0042c9c0();

  if (*(double *)(param_1 + 0x610) <= _DAT_00795610) {

    FUN_00401340();

    FUN_0042e9f0();

  }

  else {

    FUN_0042e080(DAT_0083ff88,*(double *)(param_1 + 0x610) * _DAT_0079a5a8,0);

  }

  FUN_00469fa0(auStack_120);

  if ((*(char *)(param_1 + 0x618) != '\0') ||

     (_DAT_007afcd8 <= _DAT_008379a8 - *(double *)(param_1 + 0x608))) {

    *(double *)(param_1 + 0x608) = _DAT_008379a8;

    FUN_006a27c0();

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

  }

  FUN_0042e590();

  FUN_0042e590();

  FUN_0042e590();

  return 1;

}





// --- FUN_004ab550 at 0x004AB550 (size: 109) ---


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



undefined * FUN_004ab550(double param_1)



{

  bool bVar1;

  undefined4 uVar2;

  

  bVar1 = param_1 < _DAT_007938c0;

  uVar2 = FUN_005df4c4();

  sprintf(&DAT_0083ff90,"%c%d%%",(int)(char)(bVar1 * '\x02' + '+'),uVar2);

  return &DAT_0083ff90;

}





// --- FUN_004ab5c0 at 0x004AB5C0 (size: 101) ---


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



undefined * FUN_004ab5c0(double param_1)



{

  double dVar1;

  

  dVar1 = _DAT_007938c0 - param_1;

  if (dVar1 < _DAT_00795610) {

    dVar1 = -dVar1;

  }

  sprintf(&DAT_0083ff90,"%c%.1lf%%",(int)(char)((param_1 < _DAT_007938c0) * '\x02' + '+'),

          dVar1 * _DAT_007aff88);

  return &DAT_0083ff90;

}





// --- FUN_004ab630 at 0x004AB630 (size: 121) ---


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



{

  FUN_00472670(param_2,param_3);

  param_1[0x17e] = &PTR_FUN_007ccb60;

  param_1[0x17f] = 0;

  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[0x188] = 0;

  param_1[0x189] = 0;

  *param_1 = &PTR_FUN_007b0248;

  param_1[0x17e] = &PTR_FUN_007affa0;

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

  return param_1;

}





// --- FUN_004ab710 at 0x004AB710 (size: 58) ---


uint __thiscall FUN_004ab710(int param_1,int param_2,int *param_3)



{

  uint uVar1;

  

  if ((((char)param_3[8] != '\0') && (param_2 == *(int *)(*(int *)(param_1 + 0x600) + 0x84))) &&

     (*param_3 == 0x10000024)) {

    return (uint)param_3 & 0xffffff00;

  }

  uVar1 = FUN_0045fce0();

  return uVar1;

}





// --- FUN_004ab750 at 0x004AB750 (size: 65) ---


void __fastcall FUN_004ab750(int param_1)



{

  char cVar1;

  int iVar2;

  

  cVar1 = FUN_004603a0();

  if ((cVar1 != '\0') && (*(char *)(param_1 + 0x24) != '\0')) {

    if (DAT_00871e54 != 0) {

      iVar2 = DAT_00871e54;

      FUN_00564d30(DAT_00871e54);

      FUN_005657b0(iVar2);

      return;

    }

    (**(code **)(*(int *)(param_1 + -0x5f8) + 0x18))(0);

  }

  return;

}





// --- FUN_004ab7a0 at 0x004AB7A0 (size: 269) ---


void __thiscall FUN_004ab7a0(int param_1,int *param_2)



{

  int *piVar1;

  

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

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

  if (param_2 == piVar1) {

    (**(code **)(**(int **)(param_1 + 0x604) + 8))(0);

    (**(code **)(**(int **)(param_1 + 0x608) + 8))(0);

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

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

                    /* WARNING: Treating indirect jump as call */

    (**(code **)(**(int **)(param_1 + 0x600) + 8))(1);

    return;

  }

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

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

    (**(code **)(**(int **)(param_1 + 0x608) + 8))(0);

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

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

                    /* WARNING: Treating indirect jump as call */

    (**(code **)(**(int **)(param_1 + 0x604) + 8))(1);

    return;

  }

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

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

    (**(code **)(**(int **)(param_1 + 0x604) + 8))(0);

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

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

                    /* WARNING: Treating indirect jump as call */

    (**(code **)(**(int **)(param_1 + 0x608) + 8))(1);

    return;

  }

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

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

    (**(code **)(**(int **)(param_1 + 0x604) + 8))(0);

    (**(code **)(**(int **)(param_1 + 0x608) + 8))(0);

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

                    /* WARNING: Treating indirect jump as call */

    (**(code **)(**(int **)(param_1 + 0x60c) + 8))(1);

    return;

  }

  return;

}





// --- FUN_004ab8b0 at 0x004AB8B0 (size: 106) ---


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



void __fastcall FUN_004ab8b0(int param_1)



{

  int iVar1;

  

  if (((*(uint *)(param_1 + 0xa4) >> 1 & 1) != 0) && (*(double *)(param_1 + 0x620) <= _DAT_008379a8)

     ) {

    iVar1 = FUN_0056b210();

    if (*(int *)(iVar1 + 0x1c) != 1) {

      if (((*(int *)(param_1 + 0x5fc) == *(int *)(param_1 + 0x604)) ||

          (*(int *)(param_1 + 0x5fc) == *(int *)(param_1 + 0x608))) &&

         (*(int *)(param_1 + 0x618) != 0)) {

        FUN_006a94a0(*(int *)(param_1 + 0x618));

      }

      *(double *)(param_1 + 0x620) = _DAT_008379a8 + _DAT_007b0380;

    }

  }

  return;

}





// --- FUN_004ab920 at 0x004AB920 (size: 39) ---


void __thiscall FUN_004ab920(int param_1,undefined4 param_2)



{

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

    (**(code **)(**(int **)(param_1 + 0x74) + 0x18))(param_2);

  }

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

    (**(code **)(**(int **)(param_1 + 0x78) + 0x18))(param_2);

  }

  return;

}





// --- FUN_004ab950 at 0x004AB950 (size: 39) ---


void __thiscall FUN_004ab950(int param_1,undefined4 param_2)



{

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

    (**(code **)(**(int **)(param_1 + 0x74) + 0x18))(param_2);

  }

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

    (**(code **)(**(int **)(param_1 + 0x7c) + 0x18))(param_2);

  }

  return;

}





// --- FUN_004ab990 at 0x004AB990 (size: 63) ---


void __fastcall FUN_004ab990(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  LONG *lpAddend;

  

  puVar1 = (undefined4 *)*param_1;

  if (puVar1 != DAT_008ef11c) {

    LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    lpAddend = DAT_008ef11c + 1;

    *param_1 = (int)DAT_008ef11c;

    InterlockedIncrement(lpAddend);

  }

  return;

}





// --- FUN_004ab9d0 at 0x004AB9D0 (size: 87) ---


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



{

  byte bVar1;

  byte *pbVar2;

  int iVar3;

  byte *pbVar4;

  bool bVar5;

  

  pbVar4 = (byte *)(*param_2 + 0x14);

  pbVar2 = (byte *)(*param_1 + 0x14);

  while( true ) {

    bVar1 = *pbVar2;

    bVar5 = bVar1 < *pbVar4;

    if (bVar1 != *pbVar4) break;

    if (bVar1 == 0) {

      return 1;

    }

    bVar1 = pbVar2[1];

    bVar5 = bVar1 < pbVar4[1];

    if (bVar1 != pbVar4[1]) break;

    pbVar2 = pbVar2 + 2;

    pbVar4 = pbVar4 + 2;

    if (bVar1 == 0) {

      return 1;

    }

  }

  iVar3 = (1 - (uint)bVar5) - (uint)(bVar5 != 0);

  return CONCAT31((int3)((uint)iVar3 >> 8),iVar3 == 0);

}





// --- FUN_004aba30 at 0x004ABA30 (size: 87) ---


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



{

  byte bVar1;

  byte *pbVar2;

  int iVar3;

  byte *pbVar4;

  bool bVar5;

  

  pbVar4 = (byte *)(*param_2 + 0x14);

  pbVar2 = (byte *)(*param_1 + 0x14);

  while( true ) {

    bVar1 = *pbVar2;

    bVar5 = bVar1 < *pbVar4;

    if (bVar1 != *pbVar4) break;

    if (bVar1 == 0) {

      return 0;

    }

    bVar1 = pbVar2[1];

    bVar5 = bVar1 < pbVar4[1];

    if (bVar1 != pbVar4[1]) break;

    pbVar2 = pbVar2 + 2;

    pbVar4 = pbVar4 + 2;

    if (bVar1 == 0) {

      return 0;

    }

  }

  iVar3 = (1 - (uint)bVar5) - (uint)(bVar5 != 0);

  return CONCAT31((int3)((uint)iVar3 >> 8),iVar3 != 0);

}





// --- FUN_004aba90 at 0x004ABA90 (size: 101) ---


int __thiscall FUN_004aba90(int *param_1,int *param_2,int param_3)



{

  byte bVar1;

  byte *pbVar2;

  int iVar3;

  byte *pbVar4;

  bool bVar5;

  

  if (param_3 == 0) {

    iVar3 = _stricmp((char *)(*param_1 + 0x14),(char *)(*param_2 + 0x14));

    return iVar3;

  }

  pbVar4 = (byte *)(*param_2 + 0x14);

  pbVar2 = (byte *)(*param_1 + 0x14);

  while( true ) {

    bVar1 = *pbVar2;

    bVar5 = bVar1 < *pbVar4;

    if (bVar1 != *pbVar4) break;

    if (bVar1 == 0) {

      return 0;

    }

    bVar1 = pbVar2[1];

    bVar5 = bVar1 < pbVar4[1];

    if (bVar1 != pbVar4[1]) break;

    pbVar2 = pbVar2 + 2;

    pbVar4 = pbVar4 + 2;

    if (bVar1 == 0) {

      return 0;

    }

  }

  return (1 - (uint)bVar5) - (uint)(bVar5 != 0);

}





// --- FUN_004abb00 at 0x004ABB00 (size: 19) ---


void FUN_004abb00(void)



{

  FUN_00460270(0x1000001c,&LAB_004ab6e0);

  return;

}





// --- FUN_004abb20 at 0x004ABB20 (size: 15) ---


void FUN_004abb20(int param_1)



{

  if (param_1 == 3) {

    FUN_004ab8b0();

  }

  return;

}





// --- FUN_004abb70 at 0x004ABB70 (size: 323) ---


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



{

  undefined4 uVar1;

  LONG *pLVar2;

  

  *param_1 = &PTR_LAB_007b0388;

  param_1[1] = 0;

  param_1[2] = 0;

  FUN_005b4350();

  param_1[0x1c] = param_2;

  *param_1 = &PTR_LAB_007b03a8;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  param_1[0x24] = 0;

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

  param_1[0x25] = DAT_008ef11c;

  InterlockedIncrement(pLVar2);

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

  param_1[0x26] = DAT_008ef11c;

  InterlockedIncrement(pLVar2);

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

  param_1[0x27] = DAT_008ef11c;

  InterlockedIncrement(pLVar2);

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

    uVar1 = FUN_00463c00(0x1000012e);

    param_1[0x1d] = uVar1;

  }

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

    uVar1 = FUN_00463c00(0x10000138);

    param_1[0x1e] = uVar1;

    uVar1 = FUN_00463c00(0x10000139);

    param_1[0x1f] = uVar1;

    uVar1 = FUN_00463c00(0x1000013a);

    param_1[0x24] = uVar1;

    uVar1 = FUN_00463c00(0x1000013c);

    param_1[0x20] = uVar1;

    uVar1 = FUN_00463c00(0x1000013e);

    param_1[0x21] = uVar1;

    uVar1 = FUN_00463c00(0x1000013f);

    param_1[0x22] = uVar1;

    uVar1 = FUN_00463c00(0x10000137);

    param_1[0x23] = uVar1;

  }

  param_1[0x28] = 1;

  param_1[0x29] = 2;

  return param_1;

}





// --- FUN_004abcc0 at 0x004ABCC0 (size: 118) ---


void __fastcall FUN_004abcc0(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[0x27];

  *param_1 = &PTR_LAB_007b03a8;

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[0x26];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[0x25];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_LAB_007b0388;

  FUN_005b4390();

  return;

}





// --- FUN_004abfd0 at 0x004ABFD0 (size: 406) ---


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



{

  undefined4 uVar1;

  int *piVar2;

  int iVar3;

  

  *param_1 = &PTR_LAB_007b0388;

  param_1[1] = 0;

  param_1[2] = 0;

  FUN_005b4350();

  param_1[0x1c] = param_2;

  *param_1 = &PTR_LAB_007b03b8;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x26] = 0x20;

  param_1[0x27] = 0x20;

  if (param_2 != 0) {

    uVar1 = FUN_00463c00(0x10000153);

    param_1[0x1d] = uVar1;

  }

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

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x1e] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x1f] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x20] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x21] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x22] = uVar1;

    uVar1 = FUN_00463c00(0x1000015f);

    param_1[0x23] = uVar1;

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

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

      iVar3 = 0;

    }

    else {

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

    }

    param_1[0x24] = iVar3;

    if (iVar3 != 0) {

      param_1[0x26] = *(undefined4 *)(iVar3 + 0x7c);

      uVar1 = FUN_0069fe60();

      param_1[0x27] = uVar1;

    }

  }

  return param_1;

}





// --- FUN_004ac170 at 0x004AC170 (size: 44) ---


void __fastcall FUN_004ac170(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x90) + 0x610);

  while (0 < iVar1) {

    FUN_0046e430(iVar1 + -1);

    iVar1 = *(int *)(*(int *)(param_1 + 0x90) + 0x610);

  }

  return;

}





// --- FUN_004ac1a0 at 0x004AC1A0 (size: 311) ---


void __fastcall FUN_004ac1a0(int param_1)



{

  char cVar1;

  int *piVar2;

  int *piVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 unaff_EBP;

  int iVar6;

  undefined4 local_14;

  int local_10;

  int *piStack_c;

  undefined4 *local_8;

  undefined4 *local_4;

  

  if ((*(int *)(param_1 + 0x90) != 0) &&

     (iVar6 = 0, local_10 = param_1, 0 < *(int *)(*(int *)(param_1 + 0x90) + 0x610))) {

    do {

      piVar2 = (int *)FUN_0046dc50(iVar6);

      if ((piVar2 != (int *)0x0) && (piVar3 = (int *)FUN_00463c00(0x10000330), piVar3 != (int *)0x0)

         ) {

        local_14 = 0;

        local_8 = (undefined4 *)0x0;

        local_4 = (undefined4 *)0x0;

        cVar1 = (**(code **)(*piVar2 + 0xd0))(0x10000010,&local_8);

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

          (**(code **)(*piStack_c + 0x78))(&stack0xffffffe4);

        }

        FUN_0055e1d0();

        iVar4 = FUN_0055e220();

        if (iVar4 == 0) {

LAB_004ac268:

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

        }

        else {

          puVar5 = (undefined4 *)FUN_005bd3c0(&local_14,unaff_EBP);

          iVar4 = FUN_005872b0(*puVar5);

          if (iVar4 == 0) goto LAB_004ac268;

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

        }

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

          iVar4 = local_8[1];

          local_8[1] = iVar4 + -1;

          if (iVar4 + -1 == 0) {

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

          }

          local_8 = (undefined4 *)0x0;

        }

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

          iVar4 = local_4[1];

          local_4[1] = iVar4 + -1;

          if (iVar4 + -1 == 0) {

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

          }

          local_4 = (undefined4 *)0x0;

        }

      }

      iVar6 = iVar6 + 1;

    } while (iVar6 < *(int *)(*(int *)(local_10 + 0x90) + 0x610));

  }

  return;

}





// --- FUN_004ac2e0 at 0x004AC2E0 (size: 101) ---


undefined4 FUN_004ac2e0(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  

  FUN_005bd3c0(&param_1,param_1);

  FUN_0055e1d0();

  piVar2 = (int *)FUN_0055e220();

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

    return 0;

  }

  iVar4 = 0;

  do {

    piVar2 = piVar2 + 1;

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

      return 0;

    }

    for (puVar1 = *(undefined4 **)*piVar2; puVar1 != (undefined4 *)0x0;

        puVar1 = (undefined4 *)*puVar1) {

      if (param_1 == puVar1[2]) {

        uVar3 = FUN_00586d60();

        return uVar3;

      }

    }

    iVar4 = iVar4 + 1;

  } while (iVar4 < 7);

  return 0;

}





// --- FUN_004ac350 at 0x004AC350 (size: 23) ---


bool FUN_004ac350(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_004aba90(param_1,param_2);

  return iVar1 == 0;

}





// --- FUN_004ac370 at 0x004AC370 (size: 68) ---


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



{

  LONG LVar1;

  undefined4 *puVar2;

  

  puVar2 = param_1;

  FUN_0048c3e0(param_2);

  FUN_004a2b90(puVar2,param_3);

  LVar1 = InterlockedDecrement(param_1 + 1);

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

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

  }

  return param_1;

}





// --- FUN_004ac460 at 0x004AC460 (size: 333) ---


void __fastcall FUN_004ac460(wchar_t *param_1)



{

  byte bVar1;

  undefined4 *puVar2;

  byte *pbVar3;

  int iVar4;

  LONG LVar5;

  size_t sVar6;

  undefined4 uVar7;

  byte *pbVar8;

  wchar_t *pwVar9;

  bool bVar10;

  wchar_t *local_8;

  undefined4 *local_4;

  

  local_8 = param_1;

  FUN_0048c3e0(&DAT_007938af);

  puVar2 = local_4;

  pbVar8 = (byte *)(local_4 + 5);

  pbVar3 = (byte *)(*(int *)(param_1 + 0x4a) + 0x14);

  do {

    bVar1 = *pbVar3;

    bVar10 = bVar1 < *pbVar8;

    if (bVar1 != *pbVar8) {

LAB_004ac4b8:

      iVar4 = (1 - (uint)bVar10) - (uint)(bVar10 != 0);

      goto LAB_004ac4bd;

    }

    if (bVar1 == 0) break;

    bVar1 = pbVar3[1];

    bVar10 = bVar1 < pbVar8[1];

    if (bVar1 != pbVar8[1]) goto LAB_004ac4b8;

    pbVar3 = pbVar3 + 2;

    pbVar8 = pbVar8 + 2;

  } while (bVar1 != 0);

  iVar4 = 0;

LAB_004ac4bd:

  LVar5 = InterlockedDecrement(local_4 + 1);

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

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

  }

  if (iVar4 == 0) {

    (**(code **)(**(int **)(local_8 + 0x42) + 0x9c))(1);

    FUN_00467ae0();

  }

  sVar6 = wcslen(L"--");

  FUN_004022d0(sVar6);

  wcscpy(local_8,L"--");

  FUN_0046a740(&local_8);

  pwVar9 = local_8 + -10;

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

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

    (*(code *)**(undefined4 **)pwVar9)(1);

  }

  if (DAT_0083da58 == 0) {

    uVar7 = 0;

  }

  else {

    uVar7 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  uVar7 = FUN_0058f8e0(&local_4,uVar7,0,0);

  FUN_00469f70(uVar7);

  LVar5 = InterlockedDecrement(local_4 + -4);

  if ((LVar5 == 0) && (local_4 + -5 != (undefined4 *)0x0)) {

    (**(code **)local_4[-5])(1);

  }

  return;

}





// --- FUN_004ac5b0 at 0x004AC5B0 (size: 527) ---


void __fastcall FUN_004ac5b0(int param_1)



{

  char cVar1;

  LONG LVar2;

  undefined4 uVar3;

  int iVar4;

  undefined4 *unaff_EBX;

  undefined4 unaff_ESI;

  undefined1 *puVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 *puStack_10;

  int *piStack_c;

  undefined4 local_8;

  undefined4 local_4;

  

  puStack_10._0_3_ = (uint3)(ushort)puStack_10;

  local_8 = 0;

  local_4 = 0;

  cVar1 = (**(code **)(**(int **)(param_1 + 0x84) + 0xd0))(0x16,&local_8);

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

    (**(code **)(*piStack_c + 0x70))(&stack0xffffffea);

  }

  if ((char)((uint)unaff_ESI >> 0x10) != '\0') goto LAB_004ac773;

  FUN_0048c3e0(&DAT_007938af);

  cVar1 = FUN_004aba30(&stack0xffffffec);

  LVar2 = InterlockedDecrement(unaff_EBX + 1);

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

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

  }

  if (cVar1 == '\0') {

    iVar4 = FUN_005583f0(*(undefined4 *)(param_1 + 4));

    if (iVar4 != 0) {

      if ((*(byte *)(iVar4 + 0x100) & 2) == 0) {

        FUN_00402730(L"This item is not inscribable.");

      }

      else {

        if (*(int *)(iVar4 + 0xc4) != 0) goto LAB_004ac773;

        FUN_00402730(L"Item must be in your inventory to inscribe.");

      }

      puVar5 = &stack0xffffffec;

      uVar7 = 0;

      uVar6 = 1;

      uVar3 = 0x1a;

      FUN_00564d30(puVar5,0x1a,1,0);

      FUN_005649f0(puVar5,uVar3,uVar6,uVar7);

      FUN_004011b0();

      goto LAB_004ac773;

    }

LAB_004ac72f:

    FUN_00402730(L"Item must be in your inventory to inscribe.");

  }

  else {

    if (DAT_0083da58 == 0) {

      uVar3 = 0;

    }

    else {

      uVar3 = *(undefined4 *)(DAT_0083da58 + 0xf4);

    }

    uVar3 = FUN_0058f840(uVar3,0,0);

    uVar3 = FUN_0048c3e0(uVar3);

    cVar1 = FUN_004aba30(uVar3);

    LVar2 = InterlockedDecrement(unaff_EBX + 1);

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

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

    }

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

    FUN_00480980(&stack0xffffffec,0,L"Only %hs can change the inscription",

                 *(int *)(param_1 + 0x94) + 0x14);

  }

  uVar7 = 0;

  uVar6 = 1;

  puVar5 = &stack0xffffffec;

  uVar3 = 0x1a;

  FUN_00564d30(puVar5,0x1a,1,0);

  FUN_005649f0(puVar5,uVar3,uVar6,uVar7);

  LVar2 = InterlockedDecrement(unaff_EBX + -4);

  if ((LVar2 == 0) && (unaff_EBX + -5 != (undefined4 *)0x0)) {

    (**(code **)unaff_EBX[-5])(1);

  }

LAB_004ac773:

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

     (iVar4 = puStack_10[1], puStack_10[1] = iVar4 + -1, iVar4 + -1 == 0)) {

    (**(code **)*puStack_10)(1);

  }

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

     (iVar4 = piStack_c[1], piStack_c[1] = iVar4 + -1, iVar4 + -1 == 0)) {

    (**(code **)*piStack_c)(1);

  }

  return;

}





// --- FUN_004ac7c0 at 0x004AC7C0 (size: 71) ---


int FUN_004ac7c0(int param_1,undefined4 param_2,undefined4 param_3)



{

  LONG LVar1;

  int iVar2;

  

  iVar2 = param_1;

  FUN_00401340(param_2);

  FUN_0040bbc0(iVar2,param_3);

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

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

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

  }

  return param_1;

}





// --- FUN_004ac810 at 0x004AC810 (size: 108) ---


void FUN_004ac810(undefined4 param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 *local_4;

  

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_00487620(&local_4,&DAT_007aff7c,param_1);

  puVar1 = local_4;

  if (local_4 != DAT_008ef11c) {

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

  }

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return;

}





// --- FUN_004ac880 at 0x004AC880 (size: 535) ---


undefined4 __fastcall FUN_004ac880(int *param_1)



{

  int iVar1;

  LONG *lpAddend;

  char cVar2;

  int iVar3;

  undefined4 *puVar4;

  int *piVar5;

  int iVar6;

  LONG LVar7;

  char *pcVar8;

  uint uVar9;

  int iVar10;

  uint uVar11;

  undefined4 *puVar12;

  char acStack_18 [4];

  undefined4 *local_14;

  int iStack_10;

  int local_c;

  int iStack_8;

  int *local_4;

  

  puVar12 = DAT_008ef11c;

  iVar10 = *param_1;

  iVar3 = *(int *)(iVar10 + 8);

  iVar1 = iVar3 + -1;

  if (iVar1 != 0) {

    pcVar8 = (char *)(iVar3 + 0x13 + iVar10);

    if (iVar3 != 0) {

      pcVar8 = (char *)(iVar10 + 0x14);

    }

    iVar10 = iVar3 + -2;

    if (*pcVar8 != '-') {

      iVar10 = iVar1;

    }

    if (iVar10 < 1) {

      local_c = 0;

    }

    else {

      local_c = (iVar10 + -1) / 3;

    }

    lpAddend = DAT_008ef11c + 1;

    local_14 = DAT_008ef11c;

    local_4 = param_1;

    InterlockedIncrement(lpAddend);

    LVar7 = InterlockedDecrement(lpAddend);

    if ((LVar7 == 0) && (puVar12 != (undefined4 *)0x0)) {

      (**(code **)*puVar12)(1);

    }

    iVar6 = local_c;

    FUN_00403560(local_c + iVar1);

    *(undefined1 *)((int)local_14 + iVar1 + iVar6 + 0x14) = 0;

    iStack_10 = 0;

    iStack_8 = 0;

    puVar12 = local_14;

    piVar5 = local_4;

    for (uVar9 = iVar3 - 2; local_4 = piVar5, -1 < (int)uVar9; uVar9 = uVar9 - 1) {

      if (((0 < iStack_8) && (0 < iVar10)) && (iStack_8 % 3 == 0)) {

        acStack_18[0] = ',';

        uVar11 = (uVar9 - iStack_10) + local_c;

        if ((uVar11 < (uint)puVar12[2]) && (*(char *)(uVar11 + 0x14 + (int)puVar12) != ',')) {

          if (uVar11 == puVar12[2] - 1) {

            FUN_004910c0(acStack_18,1);

            puVar12 = local_14;

          }

          else {

            FUN_00411870();

            *(char *)(uVar11 + 0x14 + (int)local_14) = acStack_18[0];

            puVar12 = local_14;

            if (acStack_18[0] == '\0') {

              pcVar8 = (char *)(local_14 + 5);

              do {

                cVar2 = *pcVar8;

                pcVar8 = pcVar8 + 1;

              } while (cVar2 != '\0');

              local_14[2] = pcVar8 + (1 - ((int)local_14 + 0x15));

            }

          }

        }

        iStack_10 = iStack_10 + 1;

      }

      iVar1 = *local_4;

      if (uVar9 < *(uint *)(iVar1 + 8)) {

        pcVar8 = (char *)(iVar1 + 0x14 + uVar9);

      }

      else {

        pcVar8 = (char *)(*(uint *)(iVar1 + 8) + 0x13 + iVar1);

      }

      acStack_18[0] = *pcVar8;

      uVar11 = (uVar9 - iStack_10) + local_c;

      if ((uVar11 < (uint)puVar12[2]) && (*(char *)(uVar11 + 0x14 + (int)puVar12) != acStack_18[0]))

      {

        if (uVar11 == puVar12[2] - 1) {

          FUN_004910c0(acStack_18,1);

          puVar12 = local_14;

        }

        else {

          FUN_00411870();

          *(char *)(uVar11 + 0x14 + (int)local_14) = acStack_18[0];

          puVar12 = local_14;

          if (acStack_18[0] == '\0') {

            pcVar8 = (char *)(local_14 + 5);

            do {

              cVar2 = *pcVar8;

              pcVar8 = pcVar8 + 1;

            } while (cVar2 != '\0');

            local_14[2] = pcVar8 + (1 - ((int)local_14 + 0x15));

          }

        }

      }

      iStack_8 = iStack_8 + 1;

      iVar10 = iVar10 + -1;

      piVar5 = local_4;

    }

    puVar4 = (undefined4 *)*piVar5;

    if (puVar4 != puVar12) {

      LVar7 = InterlockedDecrement(puVar4 + 1);

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

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

      }

      *piVar5 = (int)puVar12;

      InterlockedIncrement(puVar12 + 1);

    }

    LVar7 = InterlockedDecrement(puVar12 + 1);

    if ((LVar7 == 0) && (puVar12 != (undefined4 *)0x0)) {

      (**(code **)*puVar12)(1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_004acaa0 at 0x004ACAA0 (size: 925) ---


void __fastcall FUN_004acaa0(int param_1)



{

  bool bVar1;

  undefined4 *puVar2;

  char cVar3;

  int iVar4;

  int *piVar5;

  LONG LVar6;

  int *piVar7;

  undefined4 **ppuVar8;

  undefined *puVar9;

  int **ppiVar10;

  undefined4 uVar11;

  int *local_30;

  undefined4 *local_2c;

  undefined4 *local_28;

  undefined4 *local_24;

  int *local_20;

  undefined4 local_1c;

  undefined4 local_18;

  int *local_14;

  int *local_10;

  undefined4 local_c;

  

  local_18 = 0;

  local_14 = (int *)0x0;

  FUN_0042a2d0(0x16);

  local_20 = (int *)0x0;

  local_1c = 0;

  FUN_0042a2d0(0x27);

  local_28 = (undefined4 *)FUN_005583f0(*(undefined4 *)(param_1 + 4));

  if ((local_28 == (undefined4 *)0x0) || ((*(byte *)(local_28 + 0x40) & 2) == 0)) {

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0x74))(0);

    }

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

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

      FUN_00429b10();

      (**(code **)(*local_20 + 0x74))(0);

    }

    (**(code **)(**(int **)(param_1 + 0x84) + 0xd4))(&local_24);

    (**(code **)(**(int **)(param_1 + 0x8c) + 0x110))(1);

    goto LAB_004acd3f;

  }

  ppiVar10 = &local_30;

  ppuVar8 = &local_24;

  puVar9 = &DAT_007afdf0;

  local_30 = (int *)0x0;

  FUN_00406d10(ppuVar8,&DAT_007afdf0,ppiVar10);

  FUN_00406570(ppuVar8,puVar9,ppiVar10);

  piVar5 = local_30;

  uVar11 = 0;

  local_10 = (int *)0x0;

  local_c = 0;

  piVar7 = local_30;

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

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

  }

  local_24 = (undefined4 *)FUN_0048bb00(&local_2c,piVar7,uVar11);

  local_24 = (undefined4 *)*local_24;

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

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

  }

  FUN_0048c3e0(&DAT_007938af);

  piVar5 = local_30;

  iVar4 = _stricmp((char *)(*(int *)(param_1 + 0x94) + 0x14),(char *)(local_30 + 5));

  if (iVar4 == 0) {

LAB_004acbfa:

    iVar4 = FUN_0058df90();

    piVar7 = local_10;

    if (iVar4 == 0) goto LAB_004acc07;

LAB_004acc2d:

    bVar1 = true;

  }

  else {

    if (DAT_0083da58 == 0) {

      uVar11 = 0;

    }

    else {

      uVar11 = *(undefined4 *)(DAT_0083da58 + 0xf4);

    }

    uVar11 = FUN_0058f840(uVar11,0,0);

    piVar5 = (int *)FUN_0048c3e0(uVar11);

    iVar4 = _stricmp((char *)(*(int *)(param_1 + 0x94) + 0x14),(char *)(*piVar5 + 0x14));

    puVar2 = local_2c;

    LVar6 = InterlockedDecrement(local_2c + 1);

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

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

    }

    piVar5 = local_30;

    if (iVar4 == 0) goto LAB_004acbfa;

LAB_004acc07:

    piVar7 = local_10;

    if (((local_10 != (int *)0x0) && (-1 < (int)local_24)) &&

       (cVar3 = FUN_00593e30(), cVar3 != '\0')) goto LAB_004acc2d;

    bVar1 = false;

  }

  LVar6 = InterlockedDecrement(piVar5 + 1);

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

    (**(code **)*piVar5)(1);

  }

  if (bVar1) {

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

      FUN_00429b10();

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

    }

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

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

      FUN_00429b10();

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

    }

    (**(code **)(**(int **)(param_1 + 0x84) + 0xd4))(&local_24);

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

  }

  else {

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

      FUN_00429b10();

      (**(code **)(*local_14 + 0x74))(0);

    }

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

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

      FUN_00429b10();

      (**(code **)(*local_20 + 0x74))(0);

    }

    (**(code **)(**(int **)(param_1 + 0x84) + 0xd4))(&local_24);

    (**(code **)(**(int **)(param_1 + 0x8c) + 0x110))(1);

  }

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

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

  }

LAB_004acd3f:

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

    iVar4 = local_2c[1];

    local_2c[1] = iVar4 + -1;

    if (iVar4 + -1 == 0) {

      (**(code **)*local_2c)(1);

    }

    local_2c = (undefined4 *)0x0;

  }

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

    iVar4 = local_28[1];

    local_28[1] = iVar4 + -1;

    if (iVar4 + -1 == 0) {

      (**(code **)*local_28)(1);

    }

    local_28 = (undefined4 *)0x0;

  }

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

    iVar4 = local_24[1];

    local_24[1] = iVar4 + -1;

    if (iVar4 + -1 == 0) {

      (**(code **)*local_24)(1);

    }

    local_24 = (undefined4 *)0x0;

  }

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

  {

    (**(code **)*local_20)(1);

  }

  return;

}





// --- FUN_004ace40 at 0x004ACE40 (size: 402) ---


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



{

  undefined4 uVar1;

  undefined4 *puVar2;

  LONG LVar3;

  char *pcVar4;

  

  uVar1 = param_4;

  if (((param_1 == 2) || (param_1 == 4)) || (param_1 == 6)) {

    pcVar4 = "base ";

  }

  else {

    pcVar4 = "";

  }

  FUN_004034c0(pcVar4);

  switch(param_1) {

  case 1:

  case 2:

  case 8:

    param_4 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_005c96c0(param_2,&param_4);

    FUN_004914f0(&param_4);

    puVar2 = param_4;

    LVar3 = InterlockedDecrement(param_4 + 1);

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

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

      return;

    }

    break;

  case 3:

  case 4:

    param_4 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_005c97e0(param_2,&param_4);

    goto LAB_004acf23;

  case 5:

  case 6:

    param_4 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_005c9880(param_2,&param_4);

LAB_004acf23:

    FUN_004914f0(&param_4);

    FUN_005abb30();

    return;

  case 7:

    FUN_004034c0("level");

    return;

  case 9:

  case 10:

    FUN_004034c0("unknown quality");

    if (param_2 == 0x11f) {

      FUN_004034c0("Standing with the Celestial Hand");

      return;

    }

    if (param_2 == 0x120) {

      FUN_004034c0("Standing with the Eldrytch Web");

      return;

    }

    if (param_2 == 0x121) {

      FUN_004034c0("Standing with the Radiant Blood");

      return;

    }

    FUN_004034c0("unknown quality");

    return;

  case 0xb:

    FUN_005b6a90(param_3,uVar1);

    return;

  case 0xc:

    FUN_005b57c0(param_3,uVar1);

  }

  return;

}





// --- FUN_004ad0b0 at 0x004AD0B0 (size: 1448) ---


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



{

  undefined4 uVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  

  *param_1 = &PTR_LAB_007b0388;

  param_1[1] = 0;

  param_1[2] = 0;

  FUN_005b4350();

  param_1[0x1c] = param_2;

  *param_1 = &PTR_LAB_007b055c;

  param_1[0x1d] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  if (param_2 != 0) {

    uVar1 = FUN_00463c00(0x10000140);

    param_1[0x1d] = uVar1;

  }

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

    uVar1 = FUN_00463c00(0x1000014c);

    param_1[0x20] = uVar1;

    uVar1 = FUN_00463c00(0x1000014d);

    param_1[0x1e] = uVar1;

    uVar1 = FUN_00463c00(0x1000014f);

    param_1[0x1f] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

      uVar1 = (**(code **)(*piVar2 + 0x94))(0xd);

    }

    param_1[0x21] = uVar1;

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

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

      uVar1 = 0;

    }

    else {

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

    }

    param_1[0x23] = uVar1;

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

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

      iVar3 = 0;

    }

    else {

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

    }

    if (DAT_00840124 == 0) {

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,1,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,2,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,4,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,3,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,5,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,6,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,2,1,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,4,0,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,6,0,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

    }

    if (*(int *)(iVar3 + 0x610) == 0) {

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,1,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,2,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,4,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,3,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,5,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x18);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f2190(iVar3,DAT_00840124,6,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,2,1,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,4,0,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

      iVar4 = FUN_005df0f5(0x20);

      if (iVar4 == 0) {

        param_2 = 0;

      }

      else {

        param_2 = FUN_004f22e0(iVar3,DAT_00840124,6,0,DAT_008400ac,0);

      }

      FUN_004637a0(&param_2);

    }

  }

  return param_1;

}





// --- FUN_004ad660 at 0x004AD660 (size: 213) ---


void __fastcall FUN_004ad660(undefined4 *param_1)



{

  int *piVar1;

  uint uVar2;

  

  *param_1 = &PTR_LAB_007b055c;

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

    FUN_0046e460();

  }

  uVar2 = 0;

  if (DAT_00840124 != 0) {

    do {

      piVar1 = *(int **)(DAT_0084011c + uVar2 * 4);

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

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

      }

      *(undefined4 *)(DAT_0084011c + uVar2 * 4) = 0;

      uVar2 = uVar2 + 1;

    } while (uVar2 < DAT_00840124);

  }

  uVar2 = 0;

  if (DAT_00840124 != 0) {

    do {

      *(undefined4 *)(DAT_0084011c + uVar2 * 4) = 0;

      uVar2 = uVar2 + 1;

    } while (uVar2 < DAT_00840124);

  }

  DAT_00840124 = 0;

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

    FUN_00454490();

  }

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

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

  }

  param_1[0x22] = 0;

  *param_1 = &PTR_LAB_007b0388;

  FUN_005b4390();

  return;

}





// --- FUN_004ad740 at 0x004AD740 (size: 131) ---


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



{

  undefined4 uVar1;

  

  FUN_004ad0b0(param_2);

  *param_1 = &PTR_LAB_007b0574;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

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

    uVar1 = FUN_00463c00(0x10000150);

    param_1[0x24] = uVar1;

    uVar1 = FUN_00463c00(0x10000151);

    param_1[0x25] = uVar1;

    uVar1 = FUN_00463c00(0x10000152);

    param_1[0x26] = uVar1;

    uVar1 = FUN_00463c00(0x1000053a);

    param_1[0x27] = uVar1;

  }

  return param_1;

}





// --- FUN_004ad7d0 at 0x004AD7D0 (size: 377) ---


float10 FUN_004ad7d0(int *param_1)



{

  int *piVar1;

  int iVar2;

  int **ppiVar3;

  int **ppiVar4;

  int *piVar5;

  undefined *puVar6;

  undefined4 uVar7;

  int *piStack_18;

  int *local_14;

  undefined4 local_10;

  int *local_c;

  int *local_8;

  int *local_4;

  

  ppiVar3 = &local_4;

  ppiVar4 = &local_8;

  puVar6 = &DAT_007afdf0;

  local_4 = (int *)0x0;

  FUN_00406d10(ppiVar4,&DAT_007afdf0,ppiVar3);

  FUN_00406570(ppiVar4,puVar6,ppiVar3);

  piVar1 = local_4;

  uVar7 = 0;

  local_14 = (int *)0x0;

  local_10 = 0;

  piVar5 = local_4;

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

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

  }

  FUN_0048bb00(&local_c,piVar5,uVar7);

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

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

  }

  piVar1 = param_1;

  piStack_18 = (int *)0x0;

  iVar2 = FUN_00597950();

  piVar5 = local_14;

  if (iVar2 == 0) {

    local_8 = (int *)0x0;

    FUN_00592b40(0x1f,&local_8);

    local_c = (int *)0x0;

    FUN_00592b40(0x20,&local_c);

    local_14 = (int *)0x0;

    FUN_00592b40(0x21,&local_14);

    param_1 = (int *)0x0;

    FUN_00592b40(0x22,&param_1);

    local_4 = (int *)0x0;

    FUN_00592b40(0x2b,&local_4);

    ppiVar3 = &param_1;

    if ((int)param_1 <= (int)local_14) {

      ppiVar3 = &local_14;

    }

    if ((int)*ppiVar3 <= (int)local_c) {

      ppiVar3 = &local_c;

    }

    if ((int)*ppiVar3 <= (int)local_8) {

      ppiVar3 = &local_8;

    }

    piStack_18 = *ppiVar3;

    ppiVar4 = &piStack_18;

    if ((int)*ppiVar3 <= (int)local_4) {

      ppiVar4 = &local_4;

    }

    piStack_18 = *ppiVar4;

  }

  else {

    ppiVar3 = &piStack_18;

    uVar7 = FUN_00597950(ppiVar3);

    piVar5 = local_14;

    FUN_00592b40(uVar7,ppiVar3);

  }

  param_1 = (int *)((float)piVar1[10] * (float)(int)piStack_18 + (float)piVar1[9]);

  if ((float)DAT_007aff58 < (float)param_1) {

    param_1 = DAT_007aff58;

  }

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

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

  }

  return (float10)(float)param_1;

}





// --- FUN_004ad950 at 0x004AD950 (size: 99) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  undefined4 uVar3;

  LONG *lpAddend;

  

  puVar1 = (undefined4 *)*param_1;

  if (puVar1 != DAT_008ef11c) {

    LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    lpAddend = DAT_008ef11c + 1;

    *param_1 = (int)DAT_008ef11c;

    InterlockedIncrement(lpAddend);

  }

  FUN_004ac810(param_2);

  if (param_3 != 0) {

    uVar3 = FUN_004ac880();

    return uVar3;

  }

  return 1;

}





// --- FUN_004ad9c0 at 0x004AD9C0 (size: 86) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  LONG *lpAddend;

  

  puVar1 = (undefined4 *)*param_1;

  if (puVar1 != DAT_008ef11c) {

    LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

    }

    lpAddend = DAT_008ef11c + 1;

    *param_1 = (int)DAT_008ef11c;

    InterlockedIncrement(lpAddend);

  }

  FUN_004ac810(param_2);

  FUN_004ac880();

  return param_1;

}





// --- FUN_004ada20 at 0x004ADA20 (size: 351) ---


void __fastcall FUN_004ada20(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 *puVar4;

  

  FUN_004639a0();

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

  iVar3 = FUN_005df0f5(0xa8);

  if (iVar3 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_004abb70(param_1);

  }

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

  puVar4 = (undefined4 *)FUN_005df0f5(0x94);

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

    puVar4 = (undefined4 *)0x0;

  }

  else {

    FUN_004ad0b0(param_1);

    *puVar4 = &PTR_LAB_007b0568;

    puVar4[0x24] = 0;

    if (puVar4[0x1d] != 0) {

      uVar2 = FUN_00463c00(0x1000014e);

      puVar4[0x24] = uVar2;

    }

  }

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

  iVar3 = FUN_005df0f5(0xa0);

  if (iVar3 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_004ad740(param_1);

  }

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

  iVar3 = FUN_005df0f5(0xa0);

  if (iVar3 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_004abfd0(param_1);

  }

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

  FUN_00465f90(3);

  piVar1 = (int *)FUN_0043c680();

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

    iVar3 = param_1 + 0x5f8;

    (**(code **)(*piVar1 + 4))(0x4dd1e7,iVar3);

    (**(code **)(*piVar1 + 4))(0x4dd1ed,iVar3);

    (**(code **)(*piVar1 + 4))(0x4dd1ee,iVar3);

    (**(code **)(*piVar1 + 4))(0x4dd1ef,iVar3);

    (**(code **)(*piVar1 + 4))(0x4dd255,iVar3);

    (**(code **)(*piVar1 + 4))(0x186a8,iVar3);

  }

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

  return;

}





// --- FUN_004adbd0 at 0x004ADBD0 (size: 223) ---


void __fastcall FUN_004adbd0(undefined4 *param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  undefined4 *puVar3;

  int *piVar4;

  

  pvVar2 = (void *)param_1[0x180];

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007b0248;

  *puVar1 = &PTR_FUN_007affa0;

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

    FUN_004abcc0();

    operator_delete(pvVar2);

  }

  puVar3 = (undefined4 *)param_1[0x181];

  param_1[0x180] = 0;

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

    *puVar3 = &PTR_LAB_007b0568;

    FUN_004ad660();

    operator_delete(puVar3);

  }

  puVar3 = (undefined4 *)param_1[0x182];

  param_1[0x181] = 0;

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

    *puVar3 = &PTR_LAB_007b0574;

    FUN_004ad660();

    operator_delete(puVar3);

  }

  puVar3 = (undefined4 *)param_1[0x183];

  param_1[0x182] = 0;

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

    *puVar3 = &PTR_LAB_007b0388;

    FUN_005b4390();

    operator_delete(puVar3);

  }

  param_1[0x183] = 0;

  FUN_00465fb0(3);

  piVar4 = (int *)FUN_0043c680();

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

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

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004adcb0 at 0x004ADCB0 (size: 431) ---


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



{

  int iVar1;

  char cVar2;

  undefined4 uVar3;

  LONG LVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  undefined4 **ppuVar7;

  undefined4 **ppuVar8;

  undefined4 *local_c;

  undefined4 *local_8;

  undefined4 *local_4;

  

  iVar1 = (int)param_3;

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

    if ((int)param_3 < 2) {

      uVar3 = FUN_00404a40(0,param_2);

      FUN_0046a740(uVar3);

      puVar6 = param_2 + -5;

      LVar4 = InterlockedDecrement(param_2 + -4);

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

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

      }

    }

    else {

      param_3 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      cVar2 = FUN_004ad950(iVar1,1);

      if (cVar2 == '\0') {

        FUN_004034c0(&DAT_007b0580);

      }

      FUN_0048c3e0(param_2);

      FUN_0048c3e0(&DAT_00795098);

      ppuVar8 = &local_c;

      ppuVar7 = &local_8;

      FUN_004a2b90(&local_4,&param_2);

      uVar3 = FUN_004a2b90(ppuVar7,ppuVar8);

      FUN_0048a0a0(uVar3);

      LVar4 = InterlockedDecrement(local_8 + 1);

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

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

      }

      LVar4 = InterlockedDecrement(local_4 + 1);

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

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

      }

      puVar6 = param_2;

      LVar4 = InterlockedDecrement(param_2 + 1);

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

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

      }

      LVar4 = InterlockedDecrement(local_c + 1);

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

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

      }

      puVar6 = param_3;

      uVar3 = FUN_00404a40(0,param_3 + 5);

      FUN_0046a740(uVar3);

      puVar5 = param_2 + -5;

      LVar4 = InterlockedDecrement(param_2 + -4);

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

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

      }

      LVar4 = InterlockedDecrement(puVar6 + 1);

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

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

        return;

      }

    }

  }

  return;

}





// --- FUN_004ade60 at 0x004ADE60 (size: 435) ---


void __thiscall FUN_004ade60(int *param_1,int param_2)



{

  int iVar1;

  LONG LVar2;

  int iVar3;

  undefined4 *puVar4;

  uint unaff_EBP;

  int *piVar5;

  undefined4 *unaff_EDI;

  undefined4 unaff_retaddr;

  undefined4 uVar6;

  undefined4 *puStack_44;

  undefined4 *local_40;

  undefined4 local_3c;

  undefined1 local_38 [44];

  char cStack_c;

  

  if ((param_2 != 0) && ((param_2 == param_1[0x185] || (param_2 == param_1[0x186])))) {

    if (param_2 == param_1[0x185]) {

      param_1[0x185] = 0;

      FUN_00564d30();

      FUN_00565630();

      param_1[0x186] = param_2;

    }

    FUN_005b70d0();

    iVar1 = FUN_005b3ca0(local_38);

    if (iVar1 == 0) {

      piVar5 = (int *)param_1[0x180];

    }

    else {

      local_40 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      local_3c = 0;

      iVar1 = FUN_005b4a00(5,&local_40);

      if ((iVar1 == 0) && (iVar1 = FUN_005b48e0(0x105,&local_3c), iVar1 == 0)) {

        piVar5 = (int *)param_1[0x181];

      }

      else {

        piVar5 = (int *)param_1[0x182];

      }

      puVar4 = local_40;

      LVar2 = InterlockedDecrement(local_40 + 1);

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

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

      }

    }

    iVar1 = FUN_005583f0(param_2);

    if (iVar1 != 0) {

      puStack_44 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      iVar3 = FUN_005b4a00(0x34,&puStack_44);

      if (iVar3 == 0) {

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

        puVar4 = (undefined4 *)FUN_0058f510(2,0);

      }

      else {

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

        puVar4 = puStack_44 + 5;

      }

      FUN_004adcb0(puVar4,uVar6);

      (**(code **)*piVar5)(param_2,iVar1);

      (**(code **)(*piVar5 + 4))(unaff_retaddr,unaff_EBP >> 0x18);

      if ((int *)param_1[0x17f] != piVar5) {

        FUN_004ab7a0(piVar5);

      }

      if (cStack_c != '\0') {

        (**(code **)(*param_1 + 0x18))(1);

      }

      LVar2 = InterlockedDecrement(unaff_EDI + 1);

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

        (**(code **)*unaff_EDI)(1);

      }

    }

  }

  return;

}





// --- FUN_004ae020 at 0x004AE020 (size: 178) ---


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



{

  LONG LVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  undefined *puVar5;

  

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

    if (1 < *(uint *)(*(int *)(param_1 + 0x80) + 0x61c)) {

      if (param_4 == 0) {

        puVar5 = &DAT_007b03e4;

      }

      else {

        puVar5 = &DAT_0079d2e0;

      }

      FUN_00402730(puVar5);

      FUN_00469f70(&param_4);

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

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

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

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

      }

    }

    uVar4 = 0;

    uVar2 = FUN_00404a40(0,param_2);

    FUN_0046a000(uVar2,uVar4,param_3);

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

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

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

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

    }

  }

  return;

}





// --- FUN_004ae220 at 0x004AE220 (size: 362) ---


void FUN_004ae220(undefined4 *param_1)



{

  LONG *lpAddend;

  char cVar1;

  int iVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined4 **ppuVar5;

  undefined4 **ppuVar6;

  undefined4 *local_10;

  undefined4 local_c;

  undefined4 *apuStack_8 [2];

  

  puVar4 = DAT_008ef11c;

  lpAddend = DAT_008ef11c + 1;

  local_10 = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  iVar2 = FUN_005b48e0(0x13,&local_c);

  if (iVar2 == 0) {

    FUN_004034c0("Value: ???");

    puVar4 = local_10;

  }

  else {

    if (puVar4 != DAT_008ef11c) {

      LVar3 = InterlockedDecrement(lpAddend);

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

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

      }

      local_10 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

    }

    FUN_004ac810(local_c);

    cVar1 = FUN_004ac880();

    if (cVar1 == '\0') {

      FUN_004034c0(&DAT_007b0580);

    }

    ppuVar6 = &local_10;

    ppuVar5 = apuStack_8;

    FUN_0048c3e0("Value: ");

    FUN_004a2b90(ppuVar5,ppuVar6);

    LVar3 = InterlockedDecrement(param_1 + 1);

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

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

    }

    puVar4 = local_10;

    if (local_10 != apuStack_8[0]) {

      LVar3 = InterlockedDecrement(local_10 + 1);

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

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

      }

      InterlockedIncrement(apuStack_8[0] + 1);

      puVar4 = apuStack_8[0];

    }

    LVar3 = InterlockedDecrement(apuStack_8[0] + 1);

    if ((LVar3 == 0) && (apuStack_8[0] != (undefined4 *)0x0)) {

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

    }

  }

  FUN_004ae020(puVar4 + 5,0,1);

  LVar3 = InterlockedDecrement(puVar4 + 1);

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

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

  }

  return;

}





// --- FUN_004ae9a0 at 0x004AE9A0 (size: 605) ---


void __fastcall FUN_004ae9a0(int param_1)



{

  bool bVar1;

  char cVar2;

  LONG LVar3;

  undefined4 uVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  undefined *puVar7;

  undefined4 *local_c;

  undefined4 *local_8;

  undefined4 *local_4;

  

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

    return;

  }

  FUN_00466830(&local_8);

  FUN_00408fd0(&local_4,0);

  puVar6 = local_4;

  FUN_0048c3e0(local_4);

  puVar5 = puVar6 + -5;

  LVar3 = InterlockedDecrement(puVar6 + -4);

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

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

  }

  puVar6 = local_8 + -5;

  LVar3 = InterlockedDecrement(local_8 + -4);

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

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

  }

  FUN_0048c3e0(&DAT_007938af);

  cVar2 = FUN_004ab9d0(&local_4);

  if (cVar2 != '\0') {

    FUN_0048c3e0(&DAT_007938af);

    cVar2 = FUN_004ab9d0(&local_8);

    LVar3 = InterlockedDecrement(local_8 + 1);

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

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

    }

    if (cVar2 != '\0') {

      bVar1 = false;

      goto LAB_004aea80;

    }

  }

  bVar1 = true;

LAB_004aea80:

  puVar6 = local_4;

  LVar3 = InterlockedDecrement(local_4 + 1);

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

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

  }

  if ((bVar1) && (cVar2 = FUN_004aba30(param_1 + 0x9c), cVar2 != '\0')) {

    FUN_006aa810(*(undefined4 *)(param_1 + 4),&local_c);

  }

  FUN_0048c3e0(&DAT_007938af);

  cVar2 = FUN_004ab9d0(&local_4);

  puVar6 = local_4;

  LVar3 = InterlockedDecrement(local_4 + 1);

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

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

  }

  if (cVar2 == '\0') {

    if (DAT_0083da58 == 0) {

      uVar4 = 0;

    }

    else {

      uVar4 = *(undefined4 *)(DAT_0083da58 + 0xf4);

    }

    puVar7 = (undefined *)FUN_0058f840(uVar4,0,0);

  }

  else {

    (**(code **)(**(int **)(param_1 + 0x84) + 0x9c))(0x10000050);

    FUN_00402730(L"<Inscribe here>");

    FUN_0046a740(&local_4);

    LVar3 = InterlockedDecrement(local_4 + -4);

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

      (**(code **)local_4[-5])(1);

    }

    FUN_00467ae0();

    FUN_004034c0(&DAT_007938af);

    puVar7 = &DAT_007938af;

  }

  FUN_004034c0(puVar7);

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

  if (puVar6 != local_c) {

    LVar3 = InterlockedDecrement(puVar6 + 1);

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

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

    }

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

    InterlockedIncrement(local_c + 1);

  }

  LVar3 = InterlockedDecrement(local_c + 1);

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

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

  }

  return;

}





