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

// --- FUN_00490900 at 0x00490900 (size: 593) ---


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



{

  int iVar1;

  LONG LVar2;

  undefined4 extraout_ECX;

  undefined4 uVar3;

  undefined4 *local_114;

  int *local_110;

  undefined4 uStack_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

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

    FUN_0042dc80();

    FUN_0042c9c0(DAT_0083f150,0x10000001);

    uVar3 = extraout_ECX;

    FUN_00401340(param_2);

    FUN_0042e9f0(DAT_0083f170,uVar3);

    FUN_006823d0();

    local_114 = (undefined4 *)0x0;

    local_110 = (int *)0x0;

    FUN_0042a2d0(0x8e);

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

      FUN_00429b10();

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

    }

    uStack_10c = FUN_00429a00();

    FUN_0042c290(&uStack_10c,&local_114);

    FUN_0042a2d0(0xc5);

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

      FUN_00429b10();

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

    }

    uStack_10c = FUN_00429a00();

    FUN_0042c290(&uStack_10c,&local_114);

    iVar1 = FUN_00478810(local_108);

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

    if (iVar1 != 0) {

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

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

        iVar1 = local_114[1];

        local_114[1] = iVar1 + -1;

        if (iVar1 + -1 == 0) {

          (**(code **)*local_114)(1);

        }

        local_114 = (undefined4 *)0x0;

      }

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

        iVar1 = local_110[1];

        local_110[1] = iVar1 + -1;

        if (iVar1 + -1 == 0) {

          (**(code **)*local_110)(1);

        }

        local_110 = (int *)0x0;

      }

      FUN_00681f60();

      FUN_0042e590();

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

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

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

      }

      return 1;

    }

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

      iVar1 = local_114[1];

      local_114[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_114)(1);

      }

      local_114 = (undefined4 *)0x0;

    }

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

      iVar1 = local_110[1];

      local_110[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_110)(1);

      }

      local_110 = (int *)0x0;

    }

    FUN_00681f60();

    FUN_0042e590();

  }

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

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

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

  }

  return 0;

}





// --- FUN_00490bc0 at 0x00490BC0 (size: 232) ---


void __fastcall FUN_00490bc0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  undefined1 local_38 [56];

  

  FUN_0056ad30();

  FUN_0059a040();

  if (DAT_0083da58 == 0) {

    uVar1 = 0;

  }

  else {

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

  }

  iVar2 = FUN_005b7ba0(uVar1,local_38);

  iVar4 = DAT_00871e54;

  if ((iVar2 == 0) && (DAT_00871e54 != 0)) {

    if (DAT_0083da58 == 0) {

      iVar2 = 0;

    }

    else {

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

    }

    if (DAT_00871e54 != iVar2) {

      piVar3 = (int *)FUN_005583f0(DAT_00871e54);

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

        iVar2 = (**(code **)(*piVar3 + 0x10))();

        if (iVar2 != 0) {

          FUN_005b7670();

          iVar4 = FUN_005b7bd0(iVar4,&stack0xffffff88);

          if (iVar4 == 0) {

            (**(code **)(**(int **)(param_1 + 0x63c) + 0x9c))(1);

            FUN_005b76c0();

            FUN_005b76c0();

            return;

          }

          FUN_005b76c0();

        }

      }

    }

  }

  (**(code **)(**(int **)(param_1 + 0x63c) + 0x9c))(0xd);

  FUN_005b76c0();

  return;

}





// --- FUN_00490cb0 at 0x00490CB0 (size: 118) ---


void __fastcall FUN_00490cb0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  undefined1 local_38 [56];

  

  FUN_0056ad30();

  FUN_0059a040();

  if (DAT_0083da58 == 0) {

    uVar1 = 0;

  }

  else {

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

  }

  iVar2 = FUN_005b7ba0(uVar1,local_38);

  if (iVar2 != 0) {

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

    FUN_005b76c0();

    return;

  }

  (**(code **)(**(int **)(param_1 + 0x640) + 0x9c))(0xd);

  FUN_005b76c0();

  return;

}





// --- FUN_00490d30 at 0x00490D30 (size: 52) ---


undefined4 __thiscall FUN_00490d30(int param_1,undefined1 param_2)



{

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

  FUN_006a2030(1,*(undefined4 *)(param_1 + 0x610),param_2);

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

  return 1;

}





// --- FUN_00490d70 at 0x00490D70 (size: 100) ---


undefined4 __thiscall FUN_00490d70(int param_1,char param_2)



{

  undefined4 in_EAX;

  undefined3 uVar2;

  undefined4 uVar1;

  undefined3 extraout_var;

  undefined1 local_38 [56];

  

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

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

  if (param_2 != '\0') {

    FUN_0056ad30();

    FUN_0059a040();

    if (DAT_0083da58 == 0) {

      uVar1 = 0;

    }

    else {

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

    }

    uVar1 = FUN_005b7ba0(uVar1,local_38);

    FUN_006a78e0(uVar1);

    FUN_005b76c0();

    uVar2 = extraout_var;

  }

  return CONCAT31(uVar2,1);

}





// --- FUN_00490de0 at 0x00490DE0 (size: 52) ---


undefined4 __thiscall FUN_00490de0(int param_1,char param_2)



{

  undefined4 in_EAX;

  undefined3 uVar1;

  undefined3 extraout_var;

  

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

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

  if (param_2 != '\0') {

    FUN_006a78e0(*(undefined4 *)(param_1 + 0x60c));

    uVar1 = extraout_var;

  }

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

  return CONCAT31(uVar1,1);

}





// --- FUN_00490e20 at 0x00490E20 (size: 206) ---


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

  *(undefined1 *)(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] = 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 = &PTR_FUN_007a6db0;

  param_1[0x17e] = &PTR_FUN_007a6b08;

  param_1[0x17f] = &PTR_LAB_007a6afc;

  return param_1;

}





// --- FUN_00490f20 at 0x00490F20 (size: 195) ---


void __fastcall FUN_00490f20(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int *piVar3;

  

  puVar1 = param_1 + 0x17e;

  puVar2 = param_1 + 0x17f;

  *param_1 = &PTR_FUN_007a6db0;

  *puVar1 = &PTR_FUN_007a6b08;

  *puVar2 = &PTR_LAB_007a6afc;

  piVar3 = (int *)FUN_0043c680();

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

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

  }

  FUN_00465fb0(1);

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

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

  FUN_00478560(param_1[0x192]);

  param_1[0x192] = 0;

  FUN_00478560(param_1[0x193]);

  param_1[0x193] = 0;

  FUN_00478560(param_1[0x194]);

  param_1[0x194] = 0;

  FUN_00478560(param_1[0x195]);

  param_1[0x195] = 0;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004910c0 at 0x004910C0 (size: 129) ---


void __thiscall FUN_004910c0(int *param_1,char *param_2,size_t param_3)



{

  uint uVar1;

  char cVar2;

  undefined4 *puVar3;

  int iVar4;

  char *pcVar5;

  LONG LVar6;

  char *pcVar7;

  

  puVar3 = (undefined4 *)*param_1;

  iVar4 = puVar3[2];

  uVar1 = param_3 + iVar4;

  if ((uint)puVar3[3] < uVar1) {

    FUN_00403560(uVar1 - 1);

    pcVar7 = (char *)(puVar3 + 5);

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

    do {

      cVar2 = *pcVar7;

      pcVar7 = pcVar7 + 1;

      *pcVar5 = cVar2;

      pcVar5 = pcVar5 + 1;

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

    LVar6 = InterlockedDecrement(puVar3 + 1);

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

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

    }

  }

  else {

    FUN_00411870();

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

  }

  strncpy((char *)(*param_1 + 0x13 + iVar4),param_2,param_3);

  *(undefined1 *)(*(int *)(*param_1 + 8) + 0x13 + *param_1) = 0;

  return;

}





// --- FUN_00491150 at 0x00491150 (size: 30) ---


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



{

  FUN_00490f20();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004914d0 at 0x004914D0 (size: 19) ---


void FUN_004914d0(void)



{

  FUN_00460270(0x1000002c,&LAB_00490ff0);

  return;

}





// --- FUN_004914f0 at 0x004914F0 (size: 44) ---


undefined4 __thiscall FUN_004914f0(undefined4 param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = *param_2;

  if ((*(int *)(iVar1 + 8) != 1) && (iVar1 != DAT_008ef11c)) {

    FUN_004910c0(iVar1 + 0x14,*(int *)(iVar1 + 8) + -1);

  }

  return param_1;

}





// --- FUN_00491610 at 0x00491610 (size: 1166) ---


void __fastcall FUN_00491610(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int iVar3;

  LONG LVar4;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 extraout_ECX_01;

  int unaff_EBX;

  undefined4 *puVar5;

  int *piVar6;

  undefined *puVar7;

  int **ppiVar8;

  undefined4 uVar9;

  int *local_204;

  int local_200;

  undefined4 *puStack_1fc;

  int local_1f4;

  int *local_1f0;

  undefined4 local_1ec;

  undefined1 auStack_1e8 [12];

  int iStack_1dc;

  

  ppiVar8 = &local_204;

  piVar6 = &local_200;

  puVar7 = &DAT_007a69a0;

  local_204 = (int *)0x0;

  FUN_00406d10(piVar6,&DAT_007a69a0,ppiVar8);

  FUN_00406570(piVar6,puVar7,ppiVar8);

  piVar6 = local_204;

  uVar9 = 0;

  local_1f0 = (int *)0x0;

  local_1ec = 0;

  piVar2 = local_204;

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

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

  }

  piVar2 = (int *)FUN_0048bb00(&local_1f4,piVar2,uVar9);

  iVar3 = *piVar2;

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

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

  }

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

    if (-1 < iVar3) {

      iVar3 = FUN_0056ad30();

      local_1f4 = iVar3 + 0x10;

      if (DAT_0083da58 == 0) {

        local_204 = (int *)0x0;

      }

      else {

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

      }

      FUN_0059a040();

      puVar1 = DAT_008ef11c;

      puStack_1fc = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      puVar5 = *(undefined4 **)(iVar3 + 0x3c);

      InterlockedIncrement(puVar5 + 1);

      if (puVar1 != puVar5) {

        LVar4 = InterlockedDecrement(puStack_1fc + 1);

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

          (**(code **)*puStack_1fc)(1);

        }

        puStack_1fc = puVar5;

        InterlockedIncrement(puVar5 + 1);

      }

      LVar4 = InterlockedDecrement(puVar5 + 1);

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

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

      }

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f20c,0x10000001);

      uVar9 = extraout_ECX;

      FUN_00401340(puStack_1fc + 5);

      FUN_0042e9f0(DAT_0083f230,uVar9);

      uVar9 = FUN_0042e980(&local_200,0);

      FUN_0046a740(uVar9);

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

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

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

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

      }

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f210,0x10000001);

      FUN_0042e000(DAT_0083f244,*(undefined4 *)(local_1f4 + 0x114),0);

      uVar9 = FUN_0042e980(&local_200,0);

      FUN_0046a740(uVar9);

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

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

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

      }

      FUN_005b7bd0(local_204,auStack_1e8);

      local_200 = 0;

      FUN_00590c20(0x1e,&local_200,0,0);

      if ((local_200 == -1) || (local_200 == iStack_1dc)) {

        FUN_0042dc80();

        FUN_0042c9c0(DAT_0083f220,0x10000001);

        puVar5 = DAT_008ef11c;

        InterlockedIncrement(DAT_008ef11c + 1);

        FUN_005b7620(&stack0xfffffdf4);

        uVar9 = extraout_ECX_01;

        FUN_00401340(puVar5 + 5);

        FUN_0042e9f0(DAT_0083f240,uVar9);

        FUN_0042e000(DAT_0083f238,iStack_1dc,iStack_1dc >> 0x1f);

        uVar9 = FUN_0042e980(&stack0xfffffdf8,0);

        FUN_0046a740(uVar9);

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

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

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

        }

        (**(code **)(**(int **)(param_1 + 0x61c) + 0x9c))(1);

        piVar6 = local_204;

        LVar4 = InterlockedDecrement(local_204 + 1);

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

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

        }

      }

      else {

        FUN_0042dc80();

        FUN_0042c9c0(DAT_0083f224,0x10000001);

        puVar5 = DAT_008ef11c;

        InterlockedIncrement(DAT_008ef11c + 1);

        FUN_005b7620(&stack0xfffffdf4);

        uVar9 = extraout_ECX_00;

        FUN_00401340(puVar5 + 5);

        FUN_0042e9f0(DAT_0083f240,uVar9);

        FUN_0042e000(DAT_0083f238,local_200,local_200 >> 0x1f);

        FUN_0042e000(DAT_0083f23c,local_200 - iStack_1dc,local_200 - iStack_1dc >> 0x1f);

        uVar9 = FUN_0042e980(&stack0xfffffdf8,0);

        FUN_0046a740(uVar9);

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

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

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

        }

        (**(code **)(**(int **)(param_1 + 0x61c) + 0x9c))(0x10000014);

        piVar6 = local_204;

        LVar4 = InterlockedDecrement(local_204 + 1);

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

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

        }

      }

      FUN_0042e590();

      FUN_0042e590();

      FUN_0042e590();

      puVar5 = puStack_1fc;

      LVar4 = InterlockedDecrement(puStack_1fc + 1);

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

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

      }

      FUN_005b76c0();

    }

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

  }

  return;

}





// --- FUN_00491aa0 at 0x00491AA0 (size: 883) ---


void __fastcall FUN_00491aa0(int param_1)



{

  int *piVar1;

  int *piVar2;

  undefined4 uVar3;

  LONG LVar4;

  int iVar5;

  undefined4 extraout_ECX;

  int *unaff_EBP;

  int *unaff_ESI;

  int **ppiVar6;

  int *unaff_EDI;

  undefined1 *puVar7;

  int *local_1f4;

  int **local_1f0;

  int *local_1dc;

  undefined1 local_1d8 [4];

  undefined1 local_1d4 [4];

  int *local_1d0;

  undefined4 local_1cc;

  int *apiStack_1c8 [10];

  undefined1 auStack_1a0 [24];

  undefined4 uStack_188;

  int *apiStack_158 [86];

  

  local_1f0 = &local_1dc;

  puVar7 = local_1d8;

  local_1f4 = (int *)&DAT_007a69a0;

  local_1dc = (int *)0x0;

  FUN_00406d10(puVar7);

  FUN_00406570(puVar7);

  piVar2 = local_1dc;

  local_1f4 = local_1dc;

  local_1f0 = (int **)0x0;

  local_1d0 = (int *)0x0;

  local_1cc = 0;

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

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

  }

  piVar1 = (int *)FUN_0048bb00(local_1d4);

  iVar5 = *piVar1;

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

    local_1f0 = (int **)0x491b0d;

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

  }

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

    if (-1 < iVar5) {

      local_1f0 = (int **)0x491b32;

      FUN_0056ad30();

      local_1f0 = (int **)0x491b43;

      FUN_0059a040();

      local_1f0 = apiStack_158;

      local_1f4 = (int *)0x491b52;

      local_1dc = (int *)FUN_005b7b70();

      local_1f0 = (int **)0x491b5f;

      FUN_0059a040();

      if (DAT_0083da58 == 0) {

        local_1f4 = (int *)0x0;

      }

      else {

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

      }

      local_1f0 = apiStack_1c8;

      piVar2 = (int *)FUN_005b7ba0();

      local_1dc = piVar2;

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

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

        FUN_00402730(&DAT_00795358);

        FUN_0046a740(&local_1f4);

        piVar1 = local_1f4 + -5;

        LVar4 = InterlockedDecrement(local_1f4 + -4);

        unaff_EDI = piVar2;

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

          (**(code **)*piVar1)(1);

        }

      }

      else {

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

        unaff_ESI = DAT_008ef11c;

        InterlockedIncrement(DAT_008ef11c + 1);

        FUN_005b7a40(&stack0xfffffe18);

        FUN_0042dc80();

        FUN_0042c9c0(DAT_0083f20c,0x10000001);

        uVar3 = extraout_ECX;

        FUN_00401340(unaff_ESI + 5);

        FUN_0042e9f0(DAT_0083f230,uVar3);

        uVar3 = FUN_0042e980(&stack0xfffffe1c,0);

        FUN_0046a740(uVar3);

        LVar4 = InterlockedDecrement(unaff_EBP + -4);

        if ((LVar4 == 0) && (unaff_EBP + -5 != (int *)0x0)) {

          (**(code **)unaff_EBP[-5])(1);

        }

        iVar5 = FUN_005b7640();

        if (iVar5 == 0) {

          (**(code **)(**(int **)(param_1 + 0x630) + 0x9c))(0xd);

        }

        else {

          (**(code **)(**(int **)(param_1 + 0x630) + 0x9c))(1);

        }

        FUN_0059a040();

        if (DAT_0083da58 == 0) {

          uVar3 = 0;

        }

        else {

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

        }

        FUN_005b7bd0(uVar3,auStack_1a0);

        FUN_0042dc80();

        FUN_0042c9c0(DAT_0083f22c,0x10000001);

        FUN_0042e000(DAT_0083f248,uStack_188,0);

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

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

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

        }

        uVar3 = FUN_0042e980(&local_1f0,0);

        FUN_0046a740(uVar3);

        ppiVar6 = local_1f0 + -5;

        LVar4 = InterlockedDecrement((LONG *)(local_1f0 + -4));

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

          (*(code *)**ppiVar6)(1);

        }

        FUN_0042e590();

        FUN_005b76c0();

        FUN_0042e590();

        piVar2 = local_1f4;

        LVar4 = InterlockedDecrement(local_1f4 + 1);

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

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

        }

      }

      if ((unaff_EDI == (int *)0x0) || (iVar5 = FUN_005b7640(), iVar5 == 0)) {

        uVar3 = 0;

      }

      else {

        uVar3 = 1;

      }

      FUN_00589eb0(4,uVar3);

      FUN_005b76c0();

      FUN_005b76c0();

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

      return;

    }

    local_1f0 = (int **)0x491b22;

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

    return;

  }

  return;

}





// --- FUN_00491e20 at 0x00491E20 (size: 1289) ---


void __fastcall FUN_00491e20(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  int *piVar6;

  LONG LVar7;

  int **ppiVar8;

  undefined4 extraout_ECX;

  int *unaff_EDI;

  int *piStack_318;

  int *local_314;

  int **local_310;

  int *local_2fc;

  int local_2f8;

  int local_2f4;

  int *local_2f0;

  undefined4 local_2ec;

  int *apiStack_2e8 [10];

  undefined1 auStack_2c0 [24];

  undefined4 uStack_2a8;

  int aiStack_1ec [123];

  

  local_310 = &local_2fc;

  piStack_318 = &local_2f4;

  local_314 = (int *)&DAT_007a69a0;

  local_2fc = (int *)0x0;

  FUN_00406d10();

  FUN_00406570();

  piVar6 = local_2fc;

  local_314 = local_2fc;

  local_310 = (int **)0x0;

  local_2f0 = (int *)0x0;

  local_2ec = 0;

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

    piStack_318 = (int *)0x491e72;

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

  }

  piStack_318 = &local_2f8;

  piVar1 = (int *)FUN_0048bb00();

  iVar2 = *piVar1;

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

    local_310 = (int **)0x491e8d;

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

  }

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

    return;

  }

  if (iVar2 < 0) {

    local_310 = (int **)0x491ea2;

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

    return;

  }

  local_310 = (int **)0x491eb2;

  iVar2 = FUN_0056ad30();

  local_310 = (int **)0x491ec0;

  FUN_0059a040();

  local_310 = apiStack_2e8;

  local_314 = (int *)0x491ecc;

  iVar3 = FUN_005b7b70();

  if (DAT_0083da58 == 0) {

    iVar4 = 0;

  }

  else {

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

  }

  local_2f4 = iVar3;

  if ((iVar3 == iVar4) || (iVar3 == 0)) {

    local_310 = (int **)0x0;

    local_314 = (int *)0x492253;

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

    FUN_00402730(&DAT_00795358);

    FUN_0046a740(&piStack_318);

    piVar6 = piStack_318 + -5;

    LVar7 = InterlockedDecrement(piStack_318 + -4);

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

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

    }

    FUN_00402730(&DAT_00795358);

    FUN_0046a740(&piStack_318);

    piVar6 = piStack_318 + -5;

    LVar7 = InterlockedDecrement(piStack_318 + -4);

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

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

    }

  }

  else {

    local_310 = (int **)0x1;

    local_314 = (int *)0x491f02;

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

    local_314 = (int *)0x491f0e;

    FUN_0059a040();

    if (DAT_0083da58 == 0) {

      piStack_318 = (int *)0x0;

    }

    else {

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

    }

    local_314 = aiStack_1ec;

    iVar4 = FUN_005b7ba0();

    if (iVar4 == iVar3) {

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f21c,0x10000001);

      uVar5 = FUN_0042e980(&stack0xfffffcfc,0);

      FUN_0046a740(uVar5);

      FUN_004011b0();

      piVar6 = (int *)FUN_00463c00(0x10000490);

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

      FUN_0059a040();

      if (DAT_0083da58 == 0) {

        uVar5 = 0;

      }

      else {

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

      }

      FUN_005b7bd0(uVar5,auStack_2c0);

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f22c,0x10000001);

      FUN_0042e000(DAT_0083f248,uStack_2a8,0);

      FUN_00476820(0x10000492);

      uVar5 = FUN_0042e980(&local_310,0);

      FUN_0046a740(uVar5);

      FUN_004011b0();

      FUN_0042e590();

      FUN_005b76c0();

    }

    else {

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f218,0x10000001);

      uVar5 = FUN_0042e980(&stack0xfffffcfc,0);

      FUN_0046a740(uVar5);

      FUN_004011b0();

      piVar6 = (int *)FUN_00463c00(0x10000490);

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

    }

    FUN_0042e590();

    local_314 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_005b7a40(&local_314);

    FUN_0042dc80();

    FUN_0042c9c0(DAT_0083f20c,0x10000001);

    uVar5 = extraout_ECX;

    FUN_00401340(local_314 + 5);

    FUN_0042e9f0(DAT_0083f230,uVar5);

    uVar5 = FUN_0042e980(&local_310,0);

    FUN_0046a740(uVar5);

    ppiVar8 = local_310 + -5;

    LVar7 = InterlockedDecrement((LONG *)(local_310 + -4));

    if ((LVar7 == 0) && (ppiVar8 != (int **)0x0)) {

      (*(code *)**ppiVar8)(1);

    }

    FUN_0042dc80();

    FUN_0042c9c0(DAT_0083f210,0x10000001);

    FUN_0042e000(DAT_0083f244,*(int *)(iVar2 + 0x120) + -1,0);

    uVar5 = FUN_0042e980(&local_310,0);

    FUN_0046a740(uVar5);

    ppiVar8 = local_310 + -5;

    LVar7 = InterlockedDecrement((LONG *)(local_310 + -4));

    if ((LVar7 == 0) && (ppiVar8 != (int **)0x0)) {

      (*(code *)**ppiVar8)(1);

    }

    iVar2 = FUN_005b7640();

    if (iVar2 == 0) {

      (**(code **)(**(int **)(param_1 + 0x620) + 0x9c))(0xd);

    }

    else {

      (**(code **)(**(int **)(param_1 + 0x620) + 0x9c))(1);

    }

    FUN_0042e590();

    FUN_0042e590();

    piVar6 = piStack_318;

    LVar7 = InterlockedDecrement(piStack_318 + 1);

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

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

    }

    FUN_005b76c0();

  }

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

    if (DAT_0083da58 == 0) {

      ppiVar8 = (int **)0x0;

    }

    else {

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

    }

    if (local_310 != ppiVar8) {

      iVar2 = FUN_005b7640();

      if (iVar2 != 0) {

        uVar5 = 1;

        goto LAB_00492301;

      }

    }

  }

  uVar5 = 0;

LAB_00492301:

  FUN_00589eb0(5,uVar5);

  FUN_005b76c0();

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

  return;

}





// --- FUN_00492620 at 0x00492620 (size: 803) ---


void __fastcall FUN_00492620(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  int *piVar5;

  LONG LVar6;

  undefined4 unaff_ESI;

  undefined4 *puVar7;

  undefined *puVar8;

  int **ppiVar9;

  undefined4 uVar10;

  int *local_ec;

  int iStack_e8;

  undefined1 uStack_e4;

  int *local_e0;

  int local_dc;

  int *local_d8;

  undefined4 local_d4 [2];

  int local_cc;

  undefined1 auStack_c8 [24];

  undefined4 uStack_b0;

  

  ppiVar9 = &local_ec;

  piVar5 = &local_dc;

  puVar8 = &DAT_007a69a0;

  local_ec = (int *)0x0;

  local_cc = param_1;

  FUN_00406d10(piVar5,&DAT_007a69a0,ppiVar9);

  FUN_00406570(piVar5,puVar8,ppiVar9);

  piVar5 = local_ec;

  uVar10 = 0;

  local_d8 = (int *)0x0;

  local_d4[0] = 0;

  piVar2 = local_ec;

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

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

  }

  piVar2 = (int *)FUN_0048bb00(&local_e0,piVar2,uVar10);

  iVar3 = *piVar2;

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

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

  }

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

    if (iVar3 < 0) {

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

      return;

    }

    local_dc = FUN_0056ad30();

    local_dc = local_dc + 0x10;

    FUN_0046e460();

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

    uStack_e4 = 0;

    FUN_0059a040();

    if (DAT_0083da58 == 0) {

      uVar10 = 0;

    }

    else {

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

    }

    iVar3 = FUN_005b7bb0(uVar10,auStack_c8);

joined_r0x00492705:

    if (iVar3 != 0) {

      iVar4 = FUN_005b7640();

      if (iVar4 != 0) {

        local_ec = (int *)CONCAT31(local_ec._1_3_,1);

      }

      iVar4 = FUN_0046f670(0,0);

      if (iVar4 != 0) {

        FUN_00460530(0x10000001,iVar3);

        piVar5 = (int *)FUN_00463c00(0x10000268);

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

           (iVar3 = (**(code **)(*piVar5 + 0x94))(0xc), puVar1 = DAT_008ef11c, iVar3 == 0))

        goto LAB_00492917;

        InterlockedIncrement(DAT_008ef11c + 1);

        FUN_005b7a40(&stack0xffffff10);

        uVar10 = FUN_00404a40(0,puVar1 + 5);

        FUN_0046a740(uVar10);

        piVar5 = local_d8 + -5;

        LVar6 = InterlockedDecrement(local_d8 + -4);

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

          (**(code **)*piVar5)(1);

        }

        piVar5 = (int *)FUN_00463c00(0x10000269);

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

          FUN_0042dc80();

          FUN_0042c9c0(DAT_0083f22c,0x10000001);

          FUN_0042e000(DAT_0083f248,uStack_b0,0);

          uVar10 = FUN_0042e980(&iStack_e8,0);

          FUN_0046a740(uVar10);

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

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

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

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

          }

          piVar5 = (int *)FUN_00463c00(0x100004aa);

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

             (piVar5 = (int *)(**(code **)(*piVar5 + 0x94))(0xc), piVar5 != (int *)0x0)) {

            iVar3 = FUN_005b7640();

            if (iVar3 == 0) {

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

            }

            else {

              (**(code **)(*piVar5 + 0x18))(0);

            }

            iVar3 = FUN_005b7bc0(unaff_ESI,local_d4);

            FUN_0042e590();

            LVar6 = InterlockedDecrement(puVar1 + 1);

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

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

            }

            goto joined_r0x00492705;

          }

          FUN_0042e590();

        }

        LVar6 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        goto LAB_00492917;

      }

      goto joined_r0x00492705;

    }

LAB_00492917:

    FUN_00589eb0(6,local_ec);

    FUN_005b76c0();

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

  }

  return;

}





// --- FUN_00492950 at 0x00492950 (size: 265) ---


void __fastcall FUN_00492950(int param_1)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int **ppiVar6;

  undefined4 uVar7;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

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

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

    FUN_00564d30();

    FUN_00565630();

  }

  ppiVar6 = &local_14;

  puVar4 = local_10;

  puVar5 = &DAT_007a69a0;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007a69a0,ppiVar6);

  FUN_00406570(puVar4,puVar5,ppiVar6);

  piVar2 = local_14;

  uVar7 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar3 = local_14;

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

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

  }

  piVar3 = (int *)FUN_0048bb00(local_c,piVar3,uVar7);

  iVar1 = *piVar3;

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

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

  }

  piVar2 = local_8;

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

    if (iVar1 < 0) {

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

      return;

    }

    FUN_00491610();

    FUN_00491e20();

    FUN_00491aa0();

    FUN_00492620();

    FUN_00490bc0();

    FUN_00490cb0();

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

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

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

      return;

    }

    (**(code **)(**(int **)(param_1 + 0x644) + 0x9c))(0xd);

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

  }

  return;

}





// --- FUN_00492a90 at 0x00492A90 (size: 473) ---


undefined4 __fastcall FUN_00492a90(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  int iVar3;

  LONG LVar4;

  undefined4 extraout_ECX;

  undefined4 local_114;

  int *local_110;

  undefined4 *local_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

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

    uVar2 = FUN_0058f840(DAT_00871e54,2,0);

    FUN_0048c3e0(uVar2);

    puVar1 = local_10c;

    if (local_10c[2] != 1) {

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f228,0x10000001);

      uVar2 = extraout_ECX;

      FUN_00401340(local_10c + 5);

      FUN_0042e9f0(DAT_0083f234,uVar2);

      FUN_006823d0();

      local_114 = 0;

      local_110 = (int *)0x0;

      FUN_0042a2d0(0x8e);

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

        FUN_00429b10();

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

      }

      local_10c = (undefined4 *)FUN_00429a00();

      FUN_0042c290(&local_10c,&local_114);

      FUN_0042a2d0(0xc5);

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

        FUN_00429b10();

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

      }

      local_10c = (undefined4 *)FUN_00429a00();

      FUN_0042c290(&local_10c,&local_114);

      iVar3 = FUN_00478810(local_108);

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

      if (iVar3 != 0) {

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

        FUN_004234d0();

        FUN_00681f60();

        FUN_0042e590();

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if (LVar4 == 0) {

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

        }

        return 1;

      }

      FUN_004234d0();

      FUN_00681f60();

      FUN_0042e590();

    }

    LVar4 = InterlockedDecrement(puVar1 + 1);

    if (LVar4 == 0) {

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

    }

  }

  return 0;

}





// --- FUN_00492c70 at 0x00492C70 (size: 593) ---


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



{

  int iVar1;

  LONG LVar2;

  undefined4 extraout_ECX;

  undefined4 uVar3;

  undefined4 *local_114;

  int *local_110;

  undefined4 uStack_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

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

    FUN_0042dc80();

    FUN_0042c9c0(DAT_0083f204,0x10000001);

    uVar3 = extraout_ECX;

    FUN_00401340(param_2);

    FUN_0042e9f0(DAT_0083f234,uVar3);

    FUN_006823d0();

    local_114 = (undefined4 *)0x0;

    local_110 = (int *)0x0;

    FUN_0042a2d0(0x8e);

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

      FUN_00429b10();

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

    }

    uStack_10c = FUN_00429a00();

    FUN_0042c290(&uStack_10c,&local_114);

    FUN_0042a2d0(0xc5);

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

      FUN_00429b10();

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

    }

    uStack_10c = FUN_00429a00();

    FUN_0042c290(&uStack_10c,&local_114);

    iVar1 = FUN_00478810(local_108);

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

    if (iVar1 != 0) {

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

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

        iVar1 = local_114[1];

        local_114[1] = iVar1 + -1;

        if (iVar1 + -1 == 0) {

          (**(code **)*local_114)(1);

        }

        local_114 = (undefined4 *)0x0;

      }

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

        iVar1 = local_110[1];

        local_110[1] = iVar1 + -1;

        if (iVar1 + -1 == 0) {

          (**(code **)*local_110)(1);

        }

        local_110 = (int *)0x0;

      }

      FUN_00681f60();

      FUN_0042e590();

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

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

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

      }

      return 1;

    }

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

      iVar1 = local_114[1];

      local_114[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_114)(1);

      }

      local_114 = (undefined4 *)0x0;

    }

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

      iVar1 = local_110[1];

      local_110[1] = iVar1 + -1;

      if (iVar1 + -1 == 0) {

        (**(code **)*local_110)(1);

      }

      local_110 = (int *)0x0;

    }

    FUN_00681f60();

    FUN_0042e590();

  }

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

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

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

  }

  return 0;

}





// --- FUN_00492ed0 at 0x00492ED0 (size: 538) ---


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

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



undefined4 __fastcall FUN_00492ed0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  LONG LVar3;

  undefined4 extraout_ECX;

  undefined4 uStack_150;

  undefined4 *puStack_14c;

  undefined4 *local_140 [12];

  undefined1 auStack_110 [272];

  

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

    FUN_0056ad30();

    FUN_0059a040();

    if (DAT_0083da58 == 0) {

      uVar1 = 0;

    }

    else {

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

    }

    iVar2 = FUN_005b7ba0(uVar1,local_140);

    if (iVar2 != 0) {

      puStack_14c = local_140[0];

      InterlockedIncrement(local_140[0] + 1);

      if (local_140[0][2] == 1) {

        LVar3 = InterlockedDecrement(local_140[0] + 1);

        if (LVar3 == 0) {

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

        }

        FUN_005b76c0();

        return 0;

      }

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f208,0x10000001);

      uVar1 = extraout_ECX;

      FUN_00401340(local_140[0] + 5);

      FUN_0042e9f0(DAT_0083f234,uVar1);

      FUN_006823d0();

      FUN_0042a2d0(0x8e);

      uStack_150 = FUN_00429a00();

      FUN_0042c290(&uStack_150,&stack0xfffffea8);

      FUN_0042a2d0(0xc5);

      uStack_150 = FUN_00429a00();

      FUN_0042c290(&uStack_150,&stack0xfffffea8);

      iVar2 = FUN_00478810(auStack_110);

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

      if (iVar2 != 0) {

        FUN_004234d0();

        FUN_00681f60();

        FUN_0042e590();

        FUN_005abb30();

        FUN_005b76c0();

        return 1;

      }

      FUN_004234d0();

      FUN_00681f60();

      FUN_0042e590();

      FUN_005abb30();

    }

    FUN_005b76c0();

  }

  return 0;

}





// --- FUN_004930f0 at 0x004930F0 (size: 539) ---


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

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



undefined4 __fastcall FUN_004930f0(int param_1)



{

  int iVar1;

  LONG LVar2;

  undefined4 extraout_ECX;

  undefined4 uVar3;

  undefined4 uStack_150;

  undefined4 *puStack_14c;

  undefined4 *local_140 [12];

  undefined1 auStack_110 [272];

  

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

    FUN_0056ad30();

    FUN_0059a040();

    iVar1 = FUN_005b7bd0(*(undefined4 *)(param_1 + 0x604),local_140);

    if (iVar1 != 0) {

      puStack_14c = local_140[0];

      InterlockedIncrement(local_140[0] + 1);

      if (local_140[0][2] == 1) {

        LVar2 = InterlockedDecrement(local_140[0] + 1);

        if (LVar2 == 0) {

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

        }

        FUN_005b76c0();

        return 0;

      }

      FUN_0042dc80();

      FUN_0042c9c0(DAT_0083f214,0x10000001);

      uVar3 = extraout_ECX;

      FUN_00401340(local_140[0] + 5);

      FUN_0042e9f0(DAT_0083f234,uVar3);

      FUN_006823d0();

      FUN_0042a2d0(0x8e);

      uStack_150 = FUN_00429a00();

      FUN_0042c290(&uStack_150,&stack0xfffffea8);

      FUN_0042a2d0(0xc5);

      uStack_150 = FUN_00429a00();

      FUN_0042c290(&uStack_150,&stack0xfffffea8);

      iVar1 = FUN_00478810(auStack_110);

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

      if (iVar1 != 0) {

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

        FUN_004234d0();

        FUN_00681f60();

        FUN_0042e590();

        FUN_005abb30();

        FUN_005b76c0();

        return 1;

      }

      FUN_004234d0();

      FUN_00681f60();

      FUN_0042e590();

      FUN_005abb30();

    }

    FUN_005b76c0();

  }

  return 0;

}





// --- FUN_00493310 at 0x00493310 (size: 209) ---


void __thiscall FUN_00493310(int param_1,int *param_2)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  

  if (param_2[2] == 1) {

    iVar3 = *param_2;

    if (iVar3 == 0x10000263) {

      FUN_00492a90();

    }

    else {

      if (iVar3 == 0x10000264) {

        FUN_00492ed0();

        FUN_00462420(param_2);

        return;

      }

      if (iVar3 == 0x10000265) {

        FUN_004930f0();

        FUN_00462420(param_2);

        return;

      }

    }

  }

  else if (param_2[2] == 4) {

    uVar2 = FUN_0046cf60();

    iVar3 = FUN_0046dc50(uVar2);

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

    if (iVar3 == 0) {

      *piVar1 = 0;

    }

    else {

      FUN_00460a60(0x10000001,piVar1);

    }

    if (*piVar1 != 0) {

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

      FUN_00462420(param_2);

      return;

    }

    (**(code **)(**(int **)(param_1 + 0x644) + 0x9c))(0xd);

    FUN_00462420(param_2);

    return;

  }

  FUN_00462420(param_2);

  return;

}





// --- FUN_00493420 at 0x00493420 (size: 89) ---


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



uint __thiscall FUN_00493420(int param_1,int param_2)



{

  double dVar1;

  uint in_EAX;

  

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

    dVar1 = *(double *)(param_1 + 0x620) + _DAT_007938c0;

    in_EAX = CONCAT22((short)(in_EAX >> 0x10),

                      (ushort)(_DAT_008379a8 < dVar1) << 8 |

                      (ushort)(NAN(_DAT_008379a8) || NAN(dVar1)) << 10 |

                      (ushort)(_DAT_008379a8 == dVar1) << 0xe);

    if (_DAT_008379a8 < dVar1 || (_DAT_008379a8 == dVar1) != 0) {

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

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

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

      return 1;

    }

  }

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

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

  return in_EAX & 0xffffff00;

}





// --- FUN_00493480 at 0x00493480 (size: 47) ---


int FUN_00493480(int param_1,int param_2,int param_3)



{

  for (; param_1 != param_2; param_1 = param_1 + 0x40) {

    if (param_3 != 0) {

      FUN_004951d0(param_1);

    }

    param_3 = param_3 + 0x40;

  }

  return param_3;

}





// --- FUN_004934b0 at 0x004934B0 (size: 62) ---


int FUN_004934b0(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = param_2 - param_1 >> 6;

  if (iVar1 < 1) {

    return param_3;

  }

  do {

    param_2 = param_2 + -0x40;

    param_3 = param_3 + -0x40;

    FUN_00495300(param_2);

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_3;

}





// --- FUN_004934f0 at 0x004934F0 (size: 61) ---


int FUN_004934f0(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = param_2 - param_1 >> 6;

  if (iVar1 < 1) {

    return param_3;

  }

  do {

    FUN_00495300(param_1);

    param_1 = param_1 + 0x40;

    param_3 = param_3 + 0x40;

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_3;

}





// --- FUN_00493530 at 0x00493530 (size: 98) ---


void __fastcall FUN_00493530(int *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)(param_1[2] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[2] + -0x10));

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

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

  }

  puVar2 = (undefined4 *)(param_1[1] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_1[1] + -0x10));

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

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

  }

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

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

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

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

  }

  return;

}





// --- FUN_004935a0 at 0x004935A0 (size: 84) ---


void FUN_004935a0(int param_1)



{

  code *pcVar1;

  char cVar2;

  code *in_stack_00000048;

  

  pcVar1 = in_stack_00000048;

  param_1 = param_1 + -0x40;

  cVar2 = (*in_stack_00000048)(&stack0x00000008,param_1);

  while (cVar2 != '\0') {

    FUN_00495300(param_1);

    param_1 = param_1 + -0x40;

    cVar2 = (*pcVar1)(&stack0x00000008,param_1);

  }

  FUN_00495300(&stack0x00000008);

  FUN_00493530();

  return;

}





// --- FUN_00493600 at 0x00493600 (size: 118) ---


void FUN_00493600(int param_1,int param_2,int param_3)



{

  int iVar1;

  char cVar2;

  code *in_stack_00000050;

  

  while (param_3 < param_2) {

    param_2 = (param_2 + -1) / 2;

    iVar1 = param_2 * 0x40 + param_1;

    cVar2 = (*in_stack_00000050)(iVar1,&stack0x00000010);

    if (cVar2 == '\0') break;

    FUN_00495300(iVar1);

  }

  FUN_00495300(&stack0x00000010);

  FUN_00493530();

  return;

}





// --- FUN_00493680 at 0x00493680 (size: 100) ---


void __fastcall FUN_00493680(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  FUN_004639a0();

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

  FUN_0043c680();

  FUN_00465f90(3);

  return;

}





// --- FUN_004936f0 at 0x004936F0 (size: 376) ---


void __fastcall FUN_004936f0(int param_1)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined *puStack_10;

  uint local_c;

  int iStack_8;

  int iStack_4;

  

  if ((*(int *)(*(int *)(param_1 + 0x608) + 0x610) ==

       *(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc) >> 6) &&

     (local_c = 0, *(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc) >> 6 != 0)) {

    iVar4 = 0;

    do {

      FUN_0046dc50(local_c);

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

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

      {

        puStack_10 = PTR_DAT_00818340;

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

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

        piVar2 = (int *)FUN_00495980(&iStack_4,*(undefined1 *)(iVar1 + 0x10 + iVar4),

                                     *(undefined4 *)(iVar1 + 0x18 + iVar4),

                                     *(undefined4 *)(iVar1 + 0x1c + iVar4));

        if (puStack_10 != (undefined *)*piVar2) {

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

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

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

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

          }

          puStack_10 = (undefined *)*piVar2;

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

        }

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

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

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

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

        }

        FUN_0046a740(&puStack_10);

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

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

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

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

        }

      }

      local_c = local_c + 1;

      iVar4 = iVar4 + 0x40;

    } while (local_c < (uint)(*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc) >> 6));

  }

  return;

}





// --- FUN_00493870 at 0x00493870 (size: 51) ---


void FUN_00493870(int param_1,int param_2)



{

  for (; param_1 != param_2; param_1 = param_1 + 0x40) {

    FUN_004951d0(param_1);

    FUN_004935a0(param_1);

  }

  return;

}





// --- FUN_004938b0 at 0x004938B0 (size: 161) ---


void FUN_004938b0(int param_1,int param_2,int param_3)



{

  int iVar1;

  char cVar2;

  int iVar3;

  int iVar4;

  code *in_stack_00000050;

  

  iVar3 = param_2;

  while( true ) {

    iVar1 = iVar3 * 2;

    iVar4 = iVar1 + 2;

    if (param_3 <= iVar4) break;

    iVar3 = iVar4 * 0x40 + param_1;

    cVar2 = (*in_stack_00000050)(iVar3,iVar3 + -0x40);

    if (cVar2 != '\0') {

      iVar4 = iVar1 + 1;

    }

    FUN_00495300(iVar4 * 0x40 + param_1);

    iVar3 = iVar4;

  }

  if (iVar4 == param_3) {

    FUN_00495300(iVar4 * 0x40 + -0x40 + param_1);

    iVar3 = iVar1 + 1;

  }

  FUN_004951d0(&stack0x00000010);

  FUN_00493600(param_1,iVar3,param_2);

  FUN_00493530();

  return;

}





// --- FUN_00493960 at 0x00493960 (size: 427) ---


void FUN_00493960(int param_1)



{

  int *piVar1;

  int iVar2;

  LONG LVar3;

  undefined4 *puVar4;

  undefined *local_8;

  int iStack_4;

  

  local_8 = PTR_DAT_00818340;

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

  FUN_0046f2c0(0x10000589,0);

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

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

    FUN_004027b0(&local_8,&DAT_007a11d4,*(undefined4 *)(param_1 + 0xc));

    FUN_0046a740(&local_8);

  }

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

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

    FUN_0046a740(param_1 + 4);

  }

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

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

    piVar1 = (int *)FUN_00495980(&iStack_4,*(undefined1 *)(param_1 + 0x10),

                                 *(undefined4 *)(param_1 + 0x18),*(undefined4 *)(param_1 + 0x1c));

    if (local_8 != (undefined *)*piVar1) {

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

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

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

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

      }

      local_8 = (undefined *)*piVar1;

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

    }

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

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

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

    }

    FUN_0046a740(&local_8);

  }

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

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

    FUN_0046a740(param_1);

  }

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

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

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

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

  }

  return;

}





// --- FUN_00493b10 at 0x00493B10 (size: 262) ---


uint FUN_00493b10(uint param_1,uint param_2)



{

  code *pcVar1;

  char cVar2;

  LONG LVar3;

  undefined4 *puVar4;

  code *in_stack_0000004c;

  int iStack_40;

  int iStack_3c;

  int iStack_38;

  

  pcVar1 = in_stack_0000004c;

  while( true ) {

    cVar2 = (*pcVar1)(param_1,&stack0x0000000c);

    while (cVar2 != '\0') {

      param_1 = param_1 + 0x40;

      cVar2 = (*pcVar1)(param_1,&stack0x0000000c);

    }

    param_2 = param_2 - 0x40;

    cVar2 = (*pcVar1)(&stack0x0000000c,param_2);

    while (cVar2 != '\0') {

      param_2 = param_2 - 0x40;

      cVar2 = (*pcVar1)(&stack0x0000000c,param_2);

    }

    if (param_2 <= param_1) break;

    FUN_004951d0(param_1);

    FUN_00495300(param_2);

    FUN_00495300(&iStack_40);

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

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

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

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

    }

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

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

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

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

    }

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

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

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

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

    }

    param_1 = param_1 + 0x40;

  }

  FUN_00493530();

  return param_1;

}





// --- FUN_00493c20 at 0x00493C20 (size: 117) ---


void FUN_00493c20(int *param_1,int *param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  for (; param_1 != param_2; param_1 = param_1 + 0x10) {

    puVar2 = (undefined4 *)(param_1[2] + -0x14);

    LVar1 = InterlockedDecrement((LONG *)(param_1[2] + -0x10));

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

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

    }

    puVar2 = (undefined4 *)(param_1[1] + -0x14);

    LVar1 = InterlockedDecrement((LONG *)(param_1[1] + -0x10));

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

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

    }

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

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

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

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

    }

  }

  return;

}





// --- FUN_00493ca0 at 0x00493CA0 (size: 113) ---


void FUN_00493ca0(undefined4 param_1,int param_2)



{

  char cVar1;

  code *in_stack_0000004c;

  

  cVar1 = (*in_stack_0000004c)(&stack0x0000000c,param_1);

  if (cVar1 != '\0') {

    FUN_004934b0(param_1,param_2,param_2 + 0x40,&stack0x0000004c,0);

    FUN_00495300(&stack0x0000000c);

    FUN_00493530();

    return;

  }

  FUN_004951d0(&stack0x0000000c);

  FUN_004935a0(param_2);

  FUN_00493530();

  return;

}





// --- FUN_00493d20 at 0x00493D20 (size: 81) ---


void FUN_00493d20(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  iVar1 = param_2 - param_1 >> 6;

  if (1 < iVar1) {

    iVar2 = (iVar1 + -2) / 2;

    iVar3 = iVar2 * 0x40 + param_1;

    while( true ) {

      FUN_004951d0(iVar3);

      FUN_004938b0(param_1,iVar2,iVar1);

      if (iVar2 == 0) break;

      iVar2 = iVar2 + -1;

      iVar3 = iVar3 + -0x40;

    }

  }

  return;

}





// --- FUN_00493dd0 at 0x00493DD0 (size: 97) ---


void __fastcall FUN_00493dd0(int param_1)



{

  int iVar1;

  uint uVar2;

  

  FUN_0046e460();

  FUN_0046dc70(0,1);

  uVar2 = 0;

  if (*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc) >> 6 != 0) {

    iVar1 = 0;

    do {

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

      uVar2 = uVar2 + 1;

      iVar1 = iVar1 + 0x40;

    } while (uVar2 < (uint)(*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc) >> 6));

  }

  return;

}





// --- FUN_00493e40 at 0x00493E40 (size: 523) ---


undefined4 FUN_00493e40(int *param_1,wchar_t *param_2)



{

  undefined *puVar1;

  LONG LVar2;

  wchar_t *pwVar3;

  wchar_t *local_8;

  

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

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

    if ((LVar2 == 0) && (param_2 + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(param_2 + -10))(1);

    }

    return 1;

  }

  InterlockedIncrement((LONG *)(param_2 + -8));

  puVar1 = PTR_DAT_00818340;

  local_8 = (wchar_t *)PTR_DAT_00818340;

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

  FUN_00408390();

  _wcslwr(param_2);

  if (puVar1 != (undefined *)*param_1) {

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

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

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

    }

    local_8 = (wchar_t *)*param_1;

    InterlockedIncrement((LONG *)(local_8 + -8));

  }

  FUN_00408390();

  _wcslwr(local_8);

  pwVar3 = wcsstr(local_8,param_2);

  if ((pwVar3 == (wchar_t *)0x0) || ((int)pwVar3 - (int)local_8 >> 1 < 0)) {

    FUN_00402070(param_1 + 1);

    FUN_00408390();

    _wcslwr(local_8);

    pwVar3 = wcsstr(local_8,param_2);

    if ((pwVar3 == (wchar_t *)0x0) || ((int)pwVar3 - (int)local_8 >> 1 < 0)) {

      FUN_00402070(param_1 + 2);

      FUN_00408390();

      _wcslwr(local_8);

      pwVar3 = wcsstr(local_8,param_2);

      if ((pwVar3 != (wchar_t *)0x0) && (-1 < (int)pwVar3 - (int)local_8 >> 1)) {

        FUN_004011b0();

        FUN_004011b0();

        FUN_004011b0();

        return 1;

      }

      FUN_004011b0();

      FUN_004011b0();

      FUN_004011b0();

      return 0;

    }

  }

  LVar2 = InterlockedDecrement((LONG *)(local_8 + -8));

  if ((LVar2 == 0) && (local_8 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -10))(1);

  }

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

  if ((LVar2 == 0) && (param_2 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(param_2 + -10))(1);

  }

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

  if ((LVar2 == 0) && (param_2 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(param_2 + -10))(1);

  }

  return 1;

}





// --- FUN_00494050 at 0x00494050 (size: 63) ---


void FUN_00494050(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_1;

  if (param_1 != param_2) {

    while (iVar1 = iVar1 + 0x40, iVar1 != param_2) {

      FUN_004951d0(iVar1);

      FUN_00493ca0(param_1,iVar1);

    }

  }

  return;

}





// --- FUN_004940a0 at 0x004940A0 (size: 78) ---


void FUN_004940a0(int param_1,int param_2,undefined4 param_3)



{

  if (0x400 < (int)(param_2 - param_1 & 0xffffffc0U)) {

    FUN_00494050(param_1,param_1 + 0x400,param_3);

    FUN_00493870(param_1 + 0x400,param_2,0,param_3);

    return;

  }

  FUN_00494050(param_1,param_2,param_3);

  return;

}





// --- FUN_004940f0 at 0x004940F0 (size: 208) ---


void FUN_004940f0(int param_1,int param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  uint uVar3;

  int local_40;

  int local_3c;

  int local_38;

  

  uVar3 = param_2 - param_1;

  while (0x40 < (int)(uVar3 & 0xffffffc0)) {

    FUN_004951d0(param_1 + -0x40 + uVar3);

    FUN_00495300(param_1);

    uVar3 = uVar3 - 0x40;

    FUN_004951d0(&local_40);

    FUN_004938b0(param_1,0,(int)uVar3 >> 6);

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

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

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

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

    }

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

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

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

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

    }

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

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

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

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

    }

  }

  return;

}





// --- FUN_004941c0 at 0x004941C0 (size: 253) ---


void FUN_004941c0(int param_1,uint param_2,uint param_3,undefined4 param_4,code *param_5)



{

  char cVar1;

  LONG LVar2;

  uint uVar3;

  undefined4 *puVar4;

  int iStack_40;

  int iStack_3c;

  int iStack_38;

  

  FUN_00493d20(param_1,param_2,param_5,0,0);

  for (uVar3 = param_2; uVar3 < param_3; uVar3 = uVar3 + 0x40) {

    cVar1 = (*param_5)(uVar3,param_1);

    if (cVar1 != '\0') {

      FUN_004951d0(uVar3);

      FUN_00495300(param_1);

      FUN_004951d0(&iStack_40);

      FUN_004938b0(param_1,0,(int)(param_2 - param_1) >> 6);

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

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

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

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

      }

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

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

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

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

      }

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

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

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

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

      }

    }

  }

  FUN_004940f0(param_1,param_2,param_5);

  return;

}





// --- FUN_004942c0 at 0x004942C0 (size: 130) ---


undefined4 * __thiscall FUN_004942c0(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_007a7138;

  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;

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

  param_1[0x188] = 0;

  param_1[0x189] = 0;

  param_1[0x18a] = 0;

  param_1[0x18b] = 0;

  param_1[0x186] = 0xffffffff;

  return param_1;

}





// --- FUN_00494380 at 0x00494380 (size: 132) ---


void __fastcall FUN_00494380(undefined4 *param_1)



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  undefined4 uStack_4;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007a7138;

  *puVar1 = &PTR_FUN_007ccb60;

  uStack_4 = param_1;

  FUN_00465fb0(3);

  piVar3 = (int *)FUN_0043c680();

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

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

  }

  FUN_00493c20(param_1[0x17f],param_1[0x180],(int)&uStack_4 + 3);

  iVar2 = param_1[0x17f];

  if (iVar2 != 0) {

    FUN_004051c0(iVar2,(param_1[0x181] - iVar2 >> 6) << 6);

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_00494440 at 0x00494440 (size: 305) ---


void __thiscall

FUN_00494440(uint *param_1,uint param_2,undefined4 param_3,undefined4 param_4,uint param_5,

            char param_6)



{

  uint *puVar1;

  uint uVar2;

  uint uVar3;

  uint local_8;

  int local_4;

  

  local_8 = (int)(param_1[1] - *param_1) >> 6;

  puVar1 = &param_5;

  if (param_5 <= local_8) {

    puVar1 = &local_8;

  }

  local_4 = *puVar1 + local_8;

  if (local_4 == 0) {

    local_8 = 0;

  }

  else if ((uint)(local_4 * 0x40) < 0x81) {

    local_8 = FUN_004050d0(local_4 * 0x40);

  }

  else {

    local_8 = FUN_005df0f5();

  }

  uVar2 = local_8;

  for (uVar3 = *param_1; uVar3 != param_2; uVar3 = uVar3 + 0x40) {

    if (uVar2 != 0) {

      FUN_004951d0(uVar3);

    }

    uVar2 = uVar2 + 0x40;

  }

  uVar3 = param_5;

  if (param_5 == 1) {

    if (uVar2 != 0) {

      FUN_004951d0(param_3);

    }

    uVar2 = uVar2 + 0x40;

  }

  else {

    for (; uVar3 != 0; uVar3 = uVar3 - 1) {

      if (uVar2 != 0) {

        FUN_004951d0(param_3);

      }

      uVar2 = uVar2 + 0x40;

    }

  }

  if (param_6 == '\0') {

    uVar2 = FUN_00493480(param_2,param_1[1],uVar2,&param_6);

  }

  FUN_00493c20(*param_1,param_1[1],&param_6);

  uVar3 = *param_1;

  if (uVar3 != 0) {

    FUN_004051c0(uVar3,((int)(param_1[2] - uVar3) >> 6) << 6);

  }

  param_1[1] = uVar2;

  *param_1 = local_8;

  param_1[2] = local_4 * 0x40 + local_8;

  return;

}





// --- FUN_00494580 at 0x00494580 (size: 30) ---


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



{

  FUN_00494380();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_004945a0 at 0x004945A0 (size: 19) ---


void FUN_004945a0(void)



{

  FUN_00460270(0x10000049,&LAB_00494410);

  return;

}





// --- FUN_004945c0 at 0x004945C0 (size: 217) ---


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



{

  int iVar1;

  int iVar2;

  undefined1 local_40 [64];

  

  iVar1 = param_1[1];

  iVar2 = param_2 - *param_1 >> 6;

  if (iVar1 == param_1[2]) {

    FUN_00494440(param_2,param_3,&param_3,1,0);

    return iVar2 * 0x40 + *param_1;

  }

  if (param_2 == iVar1) {

    if (iVar1 != 0) {

      FUN_004951d0(param_3);

    }

    param_1[1] = param_1[1] + 0x40;

    return iVar2 * 0x40 + *param_1;

  }

  if (iVar1 != 0) {

    FUN_004951d0(iVar1 + -0x40);

  }

  param_1[1] = param_1[1] + 0x40;

  FUN_004951d0(param_3);

  FUN_004934b0(param_2,param_1[1] + -0x80,param_1[1] + -0x40,&param_3,0);

  FUN_00495300(local_40);

  FUN_00493530();

  return iVar2 * 0x40 + *param_1;

}





// --- FUN_004946a0 at 0x004946A0 (size: 228) ---


void FUN_004946a0(int param_1,int param_2,undefined4 param_3,int param_4,code *param_5)



{

  char cVar1;

  int iVar2;

  int iVar3;

  

  if (0x400 < (int)(param_2 - param_1 & 0xffffffc0U)) {

    while (param_4 != 0) {

      param_4 = param_4 + -1;

      iVar2 = ((param_2 - param_1 >> 6) - (param_2 - param_1 >> 0x1f) >> 1) * 0x40 + param_1;

      cVar1 = (*param_5)(param_1,iVar2);

      if (cVar1 == '\0') {

        cVar1 = (*param_5)(param_1,param_2 + -0x40);

        iVar3 = param_1;

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

           (cVar1 = (*param_5)(iVar2,param_2 + -0x40), iVar3 = iVar2, cVar1 != '\0')) {

          iVar3 = param_2 + -0x40;

        }

      }

      else {

        cVar1 = (*param_5)(iVar2,param_2 + -0x40);

        iVar3 = iVar2;

        if (cVar1 == '\0') {

          cVar1 = (*param_5)(param_1,param_2 + -0x40);

          iVar3 = param_2 + -0x40;

          if (cVar1 == '\0') {

            iVar3 = param_1;

          }

        }

      }

      FUN_004951d0(iVar3);

      iVar2 = FUN_00493b10(param_1,param_2);

      FUN_004946a0(iVar2,param_2,0,param_4,param_5);

      param_2 = iVar2;

      if ((int)(iVar2 - param_1 & 0xffffffc0U) < 0x401) {

        return;

      }

    }

    FUN_004941c0(param_1,param_2,param_2,0,param_5);

  }

  return;

}





// --- FUN_00494790 at 0x00494790 (size: 346) ---


void __thiscall FUN_00494790(int param_1,char param_2)



{

  char cVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 uVar4;

  int iVar5;

  undefined *puVar6;

  undefined *puVar7;

  uint uStack_8;

  int local_4;

  

  puVar6 = PTR_DAT_00818340;

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

  if (param_2 != '\0') {

    piVar2 = (int *)FUN_00466830(&local_4);

    if (puVar6 != (undefined *)*piVar2) {

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

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

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

      }

      puVar6 = (undefined *)*piVar2;

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

    }

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

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

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

    }

  }

  uVar4 = FUN_004934f0(*(undefined4 *)(param_1 + 0x600),*(undefined4 *)(param_1 + 0x600),

                       *(undefined4 *)(param_1 + 0x5fc),&param_2,0);

  FUN_00493c20(uVar4,*(undefined4 *)(param_1 + 0x600),&param_2);

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

  iVar5 = 0;

  uStack_8 = 0;

  if (DAT_0083f33c - DAT_0083f338 >> 6 != 0) {

    do {

      if (param_2 == '\0') {

LAB_0049488a:

        FUN_004945c0(*(undefined4 *)(param_1 + 0x600),iVar5 + DAT_0083f338);

      }

      else {

        puVar7 = puVar6;

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

        cVar1 = FUN_00493e40(DAT_0083f338 + iVar5,puVar7);

        if (cVar1 != '\0') goto LAB_0049488a;

      }

      uStack_8 = uStack_8 + 1;

      iVar5 = iVar5 + 0x40;

    } while (uStack_8 < (uint)(DAT_0083f33c - DAT_0083f338 >> 6));

  }

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

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

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

  }

  return;

}





// --- FUN_004948f0 at 0x004948F0 (size: 74) ---


void FUN_004948f0(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  

  if (param_1 != param_2) {

    iVar2 = 0;

    for (iVar1 = param_2 - param_1 >> 6; iVar1 != 1; iVar1 = iVar1 >> 1) {

      iVar2 = iVar2 + 1;

    }

    FUN_004946a0(param_1,param_2,0,iVar2 * 2,param_3);

    FUN_004940a0(param_1,param_2,param_3);

  }

  return;

}





// --- FUN_00494940 at 0x00494940 (size: 340) ---


void __fastcall FUN_00494940(int param_1)



{

  int iVar1;

  

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

  if (iVar1 == 1) {

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

      FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00496010);

      FUN_00493dd0();

      return;

    }

    FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00495dd0);

    FUN_00493dd0();

    return;

  }

  if (iVar1 == 2) {

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

      FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00496130);

      FUN_00493dd0();

      return;

    }

    FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00495ef0);

    FUN_00493dd0();

    return;

  }

  if (iVar1 == 3) {

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

      FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00494d60);

      FUN_00493dd0();

      return;

    }

    FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00494ce0);

    FUN_00493dd0();

    return;

  }

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

    FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00494d40);

    FUN_00493dd0();

    return;

  }

  FUN_004948f0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00494cc0);

  FUN_00493dd0();

  return;

}





// --- FUN_00494aa0 at 0x00494AA0 (size: 407) ---


void __thiscall FUN_00494aa0(int param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  undefined4 uVar3;

  

  iVar2 = param_2[2];

  if (iVar2 != 1) {

    if ((((iVar2 != 4) && (iVar2 == 0x43)) && (iVar2 = FUN_0046cf60(), iVar2 != -1)) &&

       (cVar1 = FUN_00493420(iVar2), cVar1 != '\0')) {

      FUN_00496710(*(undefined4 *)(*(int *)(param_1 + 0x5fc) + 0xc + iVar2 * 0x40));

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

      FUN_00462420(param_2);

      return;

    }

    goto switchD_00494b2b_caseD_10000583;

  }

  switch(*param_2) {

  case 0x1000057f:

    if (*(int *)(param_1 + 0x610) == 0) goto LAB_00494bab;

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

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

    break;

  case 0x10000580:

    uVar3 = 1;

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

      *(bool *)(param_1 + 0x614) = *(char *)(param_1 + 0x614) == '\0';

    }

    else {

LAB_00494bbe:

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

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

    }

    break;

  case 0x10000581:

    uVar3 = 3;

    if (*(int *)(param_1 + 0x610) != 3) goto LAB_00494bbe;

    *(bool *)(param_1 + 0x614) = *(char *)(param_1 + 0x614) == '\0';

    break;

  case 0x10000582:

    uVar3 = 2;

    if (*(int *)(param_1 + 0x610) != 2) goto LAB_00494bbe;

LAB_00494bab:

    *(bool *)(param_1 + 0x614) = *(char *)(param_1 + 0x614) == '\0';

    break;

  default:

    goto switchD_00494b2b_caseD_10000583;

  case 0x10000585:

    goto switchD_00494b2b_caseD_10000585;

  case 0x10000586:

    uVar3 = 1;

    goto LAB_00494c1b;

  case 0x10000588:

    FUN_00467ae0();

    FUN_00494790(0);

    FUN_00494940();

switchD_00494b2b_caseD_10000585:

    iVar2 = FUN_0046cf60();

    if ((iVar2 == -1) || (DAT_0083f284 == (int *)0x0)) goto switchD_00494b2b_caseD_10000583;

    FUN_004968b0(*(undefined4 *)(*(int *)(param_1 + 0x5fc) + 0xc + iVar2 * 0x40));

    uVar3 = 0;

LAB_00494c1b:

    FUN_00494790(uVar3);

  }

  FUN_00494940();

switchD_00494b2b_caseD_10000583:

  FUN_00462420(param_2);

  return;

}





// --- FUN_00494ca0 at 0x00494CA0 (size: 20) ---


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



float10 FUN_00494ca0(double param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)param_1;

  if (fVar1 < (float10)_DAT_00795610) {

    fVar1 = -fVar1;

  }

  return fVar1;

}





// --- FUN_00494dc0 at 0x00494DC0 (size: 75) ---


void __fastcall FUN_00494dc0(int param_1)



{

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

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

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

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

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

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

  FUN_00467ae0();

  FUN_00467ae0();

  FUN_00467ae0();

  return;

}





// --- FUN_00494e10 at 0x00494E10 (size: 64) ---


uint __thiscall FUN_00494e10(undefined4 *param_1,undefined4 *param_2)



{

  wchar_t *_Str2;

  wchar_t *_Str1;

  int iVar1;

  

  _Str2 = (wchar_t *)*param_2;

  _Str1 = (wchar_t *)*param_1;

  iVar1 = *(int *)(_Str1 + -2);

  if (iVar1 == *(int *)(_Str2 + -2)) {

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

    if (((iVar1 == *(int *)(_Str2 + -4)) || (iVar1 == -1)) || (*(int *)(_Str2 + -4) == -1)) {

      iVar1 = wcscmp(_Str1,_Str2);

      return (uint)(iVar1 != 0);

    }

  }

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

}





// --- FUN_00494e50 at 0x00494E50 (size: 276) ---


int * __fastcall FUN_00494e50(int *param_1)



{

  undefined *puVar1;

  LONG LVar2;

  LONG *pLVar3;

  

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

  *param_1 = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[1] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[2] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

  puVar1 = (undefined *)*param_1;

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    *param_1 = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  puVar1 = (undefined *)param_1[1];

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    param_1[1] = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  puVar1 = (undefined *)param_1[2];

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    param_1[2] = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  param_1[3] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

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

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

  return param_1;

}





// --- FUN_00494f70 at 0x00494F70 (size: 222) ---


void __fastcall FUN_00494f70(int *param_1)



{

  undefined *puVar1;

  LONG LVar2;

  LONG *pLVar3;

  

  puVar1 = (undefined *)*param_1;

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    *param_1 = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  puVar1 = (undefined *)param_1[1];

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    param_1[1] = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  puVar1 = (undefined *)param_1[2];

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    param_1[2] = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  param_1[3] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

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

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

  return;

}





// --- FUN_00495050 at 0x00495050 (size: 169) ---


undefined4 * __thiscall FUN_00495050(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_007a7470;

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

  param_1[0x188] = 0;

  param_1[0x189] = 0;

  param_1[0x18a] = 0;

  param_1[0x18b] = 0;

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

  param_1[0x18d] = 0;

  FUN_00494e50();

  param_1[0x19e] = 0;

  param_1[0x19f] = 0;

  return param_1;

}





// --- FUN_00495130 at 0x00495130 (size: 79) ---


void __fastcall FUN_00495130(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007a7470;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_00465fb0(3);

  piVar2 = (int *)FUN_0043c680();

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

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

  }

  FUN_00493530();

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004951b0 at 0x004951B0 (size: 32) ---


undefined4 __fastcall FUN_004951b0(int param_1)



{

  return CONCAT31((int3)(DAT_0083f33c - DAT_0083f338 >> 0xe),

                  *(int *)(param_1 + 0x634) == DAT_0083f33c - DAT_0083f338 >> 6);

}





// --- FUN_004951d0 at 0x004951D0 (size: 292) ---


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



{

  int iVar1;

  LONG LVar2;

  LONG *pLVar3;

  

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

  *param_1 = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[1] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[2] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

  iVar1 = *param_1;

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

    *param_1 = iVar1;

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

  }

  iVar1 = param_1[1];

  if (iVar1 != param_2[1]) {

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

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

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

    }

    iVar1 = param_2[1];

    param_1[1] = iVar1;

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

  }

  iVar1 = param_1[2];

  if (iVar1 != param_2[2]) {

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

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

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

    }

    iVar1 = param_2[2];

    param_1[2] = iVar1;

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

  }

  param_1[3] = param_2[3];

  *(char *)(param_1 + 4) = (char)param_2[4];

  param_1[6] = param_2[6];

  param_1[7] = param_2[7];

  param_1[8] = param_2[8];

  param_1[9] = param_2[9];

  param_1[10] = param_2[10];

  *(char *)(param_1 + 0xb) = (char)param_2[0xb];

  param_1[0xc] = param_2[0xc];

  param_1[0xd] = param_2[0xd];

  param_1[0xe] = param_2[0xe];

  param_1[0xf] = param_2[0xf];

  return param_1;

}





// --- FUN_00495300 at 0x00495300 (size: 240) ---


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



{

  int iVar1;

  LONG LVar2;

  

  iVar1 = *param_1;

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

    *param_1 = iVar1;

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

  }

  iVar1 = param_1[1];

  if (iVar1 != param_2[1]) {

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

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

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

    }

    iVar1 = param_2[1];

    param_1[1] = iVar1;

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

  }

  iVar1 = param_1[2];

  if (iVar1 != param_2[2]) {

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

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

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

    }

    iVar1 = param_2[2];

    param_1[2] = iVar1;

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

  }

  param_1[3] = param_2[3];

  *(char *)(param_1 + 4) = (char)param_2[4];

  param_1[6] = param_2[6];

  param_1[7] = param_2[7];

  param_1[8] = param_2[8];

  param_1[9] = param_2[9];

  param_1[10] = param_2[10];

  *(char *)(param_1 + 0xb) = (char)param_2[0xb];

  param_1[0xc] = param_2[0xc];

  param_1[0xd] = param_2[0xd];

  param_1[0xe] = param_2[0xe];

  param_1[0xf] = param_2[0xf];

  return param_1;

}





// --- FUN_004953f0 at 0x004953F0 (size: 30) ---


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



{

  FUN_00495130();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00495410 at 0x00495410 (size: 19) ---


void FUN_00495410(void)



{

  FUN_00460270(0x10000048,&LAB_00495180);

  return;

}





// --- FUN_00495430 at 0x00495430 (size: 514) ---


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



undefined4 __fastcall FUN_00495430(int param_1)



{

  double dVar1;

  int *piVar2;

  LONG LVar3;

  ulong uVar4;

  wchar_t *_Str;

  int local_10;

  int iStack_c;

  int iStack_8;

  int iStack_4;

  

  _Str = (wchar_t *)PTR_DAT_00818340;

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

  piVar2 = (int *)FUN_00466830(&local_10);

  if (_Str != (wchar_t *)*piVar2) {

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

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

      (*(code *)**(undefined4 **)((int)_Str + -0x14))(1);

    }

    _Str = (wchar_t *)*piVar2;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar2 = _errno();

  *piVar2 = 0;

  uVar4 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x658) = uVar4;

  piVar2 = (int *)FUN_00466830(&iStack_c);

  if (_Str != (wchar_t *)*piVar2) {

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

    if ((LVar3 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(_Str + -10))(1);

    }

    _Str = (wchar_t *)*piVar2;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar2 = _errno();

  *piVar2 = 0;

  uVar4 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x65c) = uVar4;

  piVar2 = (int *)FUN_00466830(&iStack_8);

  if (_Str != (wchar_t *)*piVar2) {

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

    if ((LVar3 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(_Str + -10))(1);

    }

    _Str = (wchar_t *)*piVar2;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar2 = _errno();

  *piVar2 = 0;

  uVar4 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x660) = uVar4;

  iStack_4 = *(int *)(param_1 + 0x65c) * 0xe10;

  dVar1 = (double)iStack_4 +

          (double)(int)(uVar4 * 0x3c) + (double)(*(int *)(param_1 + 0x658) * 0x15180) +

          _DAT_008379a8;

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

  *(double *)(param_1 + 0x650) = dVar1;

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

  if ((LVar3 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(_Str + -10))(1);

  }

  return 0;

}





// --- FUN_00495640 at 0x00495640 (size: 826) ---


void __fastcall FUN_00495640(int param_1)



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  LONG LVar4;

  ulong uVar5;

  undefined4 *puVar6;

  wchar_t *_Str;

  int local_c;

  int iStack_8;

  int iStack_4;

  

  _Str = (wchar_t *)PTR_DAT_00818340;

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

  piVar3 = (int *)FUN_00466830(&local_c);

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

  iVar2 = *piVar1;

  if (iVar2 != *piVar3) {

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

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

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

    }

    iVar2 = *piVar3;

    *piVar1 = iVar2;

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

  }

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

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

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

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

  }

  piVar3 = (int *)FUN_00466830(&local_c);

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

  if (iVar2 != *piVar3) {

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

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

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

    }

    iVar2 = *piVar3;

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

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

  }

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

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

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

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

  }

  piVar3 = (int *)FUN_00466830(&local_c);

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

  if (iVar2 != *piVar3) {

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

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

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

    }

    iVar2 = *piVar3;

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

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

  }

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

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

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

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

  }

  *(undefined4 *)(param_1 + 0x644) = *(undefined4 *)(param_1 + 0x634);

  piVar3 = (int *)FUN_00466830(&local_c);

  if (_Str != (wchar_t *)*piVar3) {

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

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

      (*(code *)**(undefined4 **)((int)_Str + -0x14))(1);

    }

    _Str = (wchar_t *)*piVar3;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar3 = _errno();

  *piVar3 = 0;

  uVar5 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x658) = uVar5;

  piVar3 = (int *)FUN_00466830(&iStack_8);

  if (_Str != (wchar_t *)*piVar3) {

    LVar4 = InterlockedDecrement((LONG *)(_Str + -8));

    if ((LVar4 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(_Str + -10))(1);

    }

    _Str = (wchar_t *)*piVar3;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar3 = _errno();

  *piVar3 = 0;

  uVar5 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x65c) = uVar5;

  piVar3 = (int *)FUN_00466830(&iStack_4);

  if (_Str != (wchar_t *)*piVar3) {

    LVar4 = InterlockedDecrement((LONG *)(_Str + -8));

    if ((LVar4 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

      (*(code *)**(undefined4 **)(_Str + -10))(1);

    }

    _Str = (wchar_t *)*piVar3;

    InterlockedIncrement((LONG *)(_Str + -8));

  }

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

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

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

  }

  piVar3 = _errno();

  *piVar3 = 0;

  uVar5 = wcstoul(_Str,(wchar_t **)0x0,0);

  *(ulong *)(param_1 + 0x660) = uVar5;

  if (*(uint *)(param_1 + 0x634) <= (uint)(DAT_0083f33c - DAT_0083f338 >> 6)) {

    FUN_00495300(piVar1);

  }

  LVar4 = InterlockedDecrement((LONG *)(_Str + -8));

  if ((LVar4 == 0) && (_Str + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(_Str + -10))(1);

  }

  return;

}





// --- FUN_00495980 at 0x00495980 (size: 194) ---


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



undefined4 * FUN_00495980(undefined4 *param_1,char param_2,double param_3)



{

  int iVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818340;

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

  if (((param_2 == '\0') || (param_3 <= _DAT_00795610)) || (iVar1 = FUN_005df4c4(), iVar1 < 1)) {

    FUN_004027b0();

  }

  else {

    FUN_00566bb0((double)iVar1,&local_4);

  }

  *param_1 = local_4;

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

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

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

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

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

  }

  return param_1;

}





// --- FUN_00495a50 at 0x00495A50 (size: 276) ---


void __fastcall FUN_00495a50(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined **ppuVar3;

  int iStack_24;

  undefined **ppuStack_20;

  undefined *puStack_1c;

  undefined **ppuStack_18;

  undefined *local_8;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818340;

  ppuStack_18 = (undefined **)0x495a6c;

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

  local_8 = PTR_DAT_00818340;

  ppuStack_18 = (undefined **)0x495a7b;

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

  ppuStack_18 = &local_4;

  puStack_1c = (undefined *)0x495a8a;

  FUN_004027b0();

  ppuStack_20 = &local_8;

  puStack_1c = &DAT_00795320;

  iStack_24 = 0x495a99;

  FUN_004027b0();

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

  ppuStack_18 = (undefined **)0x495ab0;

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

  ppuStack_18 = (undefined **)0x1;

  puStack_1c = (undefined *)0x495abd;

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

  puStack_1c = (undefined *)0x1;

  ppuStack_20 = (undefined **)0x495aca;

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

  ppuStack_20 = (undefined **)0x1;

  iStack_24 = 0x495ad7;

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

  iStack_24 = 1;

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

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

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

  FUN_0046a740(&iStack_24);

  FUN_0046a740(&ppuStack_20);

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

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

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

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

  }

  ppuVar3 = ppuStack_20 + -5;

  LVar1 = InterlockedDecrement((LONG *)(ppuStack_20 + -4));

  if ((LVar1 == 0) && (ppuVar3 != (undefined **)0x0)) {

    (**(code **)*ppuVar3)(1);

  }

  return;

}





// --- FUN_00495b70 at 0x00495B70 (size: 92) ---


void __fastcall FUN_00495b70(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_4;

  

  local_4 = param_1;

  FUN_00495980(&local_4,*(undefined1 *)(param_1 + 0x648),*(undefined4 *)(param_1 + 0x650),

               *(undefined4 *)(param_1 + 0x654));

  FUN_0046a740(&local_4);

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

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

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

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

  }

  return;

}





// --- FUN_00495bd0 at 0x00495BD0 (size: 381) ---


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



void __fastcall FUN_00495bd0(int param_1)



{

  double dVar1;

  double dVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  LONG LVar7;

  undefined *puVar8;

  undefined *puVar9;

  undefined4 *puVar10;

  undefined *local_1c;

  undefined8 uStack_18;

  undefined8 uStack_10;

  

  local_1c = PTR_DAT_00818340;

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

  if (local_1c != PTR_DAT_00818340) {

    puVar10 = (undefined4 *)(local_1c + -0x14);

    LVar7 = InterlockedDecrement((LONG *)(local_1c + -0x10));

    if ((LVar7 == 0) && (puVar10 != (undefined4 *)0x0)) {

      (**(code **)*puVar10)(1);

    }

    local_1c = PTR_DAT_00818340;

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

  }

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

    FUN_004027b0(&local_1c,L"None");

  }

  else {

    if (_DAT_00795610 <= *(double *)(param_1 + 0x668)) {

      puVar9 = &DAT_007a75f4;

      if (*(double *)(param_1 + 0x668) <= _DAT_00795610) {

        puVar9 = &DAT_00795320;

      }

    }

    else {

      puVar9 = &DAT_007a75f8;

    }

    if (_DAT_00795610 <= *(double *)(param_1 + 0x670)) {

      puVar8 = &DAT_007a75ec;

      if (*(double *)(param_1 + 0x670) <= _DAT_00795610) {

        puVar8 = &DAT_00795320;

      }

    }

    else {

      puVar8 = &DAT_007a75f0;

    }

    dVar1 = *(double *)(param_1 + 0x668);

    if (dVar1 < _DAT_00795610) {

      dVar1 = -dVar1;

    }

    dVar2 = *(double *)(param_1 + 0x670);

    if (dVar2 < _DAT_00795610) {

      dVar2 = -dVar2;

    }

    uStack_18._4_4_ = (undefined4)((ulonglong)dVar1 >> 0x20);

    uVar3 = uStack_18._4_4_;

    uStack_18._0_4_ = SUB84(dVar1,0);

    uStack_10._4_4_ = (undefined4)((ulonglong)dVar2 >> 0x20);

    uVar4 = uStack_10._4_4_;

    uStack_10._0_4_ = SUB84(dVar2,0);

    uVar5 = (undefined4)uStack_18;

    uStack_18 = dVar1;

    uVar6 = (undefined4)uStack_10;

    uStack_10 = dVar2;

    FUN_004027b0(&local_1c,L"%.1f%s, %.1f%s",uVar6,uVar4,puVar8,uVar5,uVar3,puVar9);

  }

  FUN_0046a740(&local_1c);

  puVar10 = (undefined4 *)(local_1c + -0x14);

  LVar7 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar7 == 0) && (puVar10 != (undefined4 *)0x0)) {

    (**(code **)*puVar10)(1);

  }

  return;

}





// --- FUN_00495d50 at 0x00495D50 (size: 113) ---


void __fastcall FUN_00495d50(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818340;

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

  iVar3 = 1;

  if (0 < *(int *)(param_1 + 0x644)) {

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

  }

  FUN_004027b0(&local_4,L"~ %d ~",iVar3);

  FUN_0046a740(&local_4);

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

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

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

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

  }

  return;

}





// --- FUN_00495ef0 at 0x00495EF0 (size: 280) ---


bool FUN_00495ef0(int *param_1,int *param_2)



{

  undefined *puVar1;

  undefined *puVar2;

  LONG LVar3;

  int iVar4;

  wchar_t *local_8;

  wchar_t *local_4;

  

  puVar1 = PTR_DAT_00818340;

  local_4 = (wchar_t *)PTR_DAT_00818340;

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

  puVar2 = PTR_DAT_00818340;

  local_8 = (wchar_t *)PTR_DAT_00818340;

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

  if (puVar1 != (undefined *)*param_1) {

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

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

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

    }

    local_4 = (wchar_t *)*param_1;

    InterlockedIncrement((LONG *)(local_4 + -8));

  }

  if (puVar2 != (undefined *)*param_2) {

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

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

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

    }

    local_8 = (wchar_t *)*param_2;

    InterlockedIncrement((LONG *)(local_8 + -8));

  }

  FUN_00408390();

  _wcslwr(local_4);

  FUN_00408390();

  _wcslwr(local_8);

  iVar4 = wcscmp(local_4,local_8);

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

  if ((LVar3 == 0) && (local_8 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -10))(1);

  }

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

  if ((LVar3 == 0) && (local_4 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -10))(1);

  }

  return iVar4 < 0;

}





// --- FUN_00496130 at 0x00496130 (size: 280) ---


bool FUN_00496130(int *param_1,int *param_2)



{

  undefined *puVar1;

  undefined *puVar2;

  LONG LVar3;

  int iVar4;

  wchar_t *local_8;

  wchar_t *local_4;

  

  puVar1 = PTR_DAT_00818340;

  local_4 = (wchar_t *)PTR_DAT_00818340;

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

  puVar2 = PTR_DAT_00818340;

  local_8 = (wchar_t *)PTR_DAT_00818340;

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

  if (puVar1 != (undefined *)*param_1) {

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

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

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

    }

    local_4 = (wchar_t *)*param_1;

    InterlockedIncrement((LONG *)(local_4 + -8));

  }

  if (puVar2 != (undefined *)*param_2) {

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

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

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

    }

    local_8 = (wchar_t *)*param_2;

    InterlockedIncrement((LONG *)(local_8 + -8));

  }

  FUN_00408390();

  _wcslwr(local_4);

  FUN_00408390();

  _wcslwr(local_8);

  iVar4 = wcscmp(local_4,local_8);

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

  if ((LVar3 == 0) && (local_8 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -10))(1);

  }

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

  if ((LVar3 == 0) && (local_4 + -10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -10))(1);

  }

  return 0 < iVar4;

}





// --- FUN_00496250 at 0x00496250 (size: 535) ---


void __fastcall FUN_00496250(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  FUN_004639a0();

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

  FUN_00495a50();

  FUN_00465f90(3);

  FUN_00465f90(0xb);

  DAT_0083f284 = param_1;

  return;

}





// --- FUN_00496470 at 0x00496470 (size: 198) ---


void __fastcall FUN_00496470(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int aiStack_20 [4];

  undefined **ppuStack_10;

  undefined *local_4;

  

  local_4 = PTR_DAT_00818340;

  ppuStack_10 = (undefined **)0x496487;

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

  ppuStack_10 = &local_4;

  aiStack_20[3] = 0x496496;

  FUN_004027b0();

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

  ppuStack_10 = (undefined **)0x4964ad;

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

  ppuStack_10 = (undefined **)0x0;

  aiStack_20[3] = 0x4964ba;

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

  aiStack_20[3] = 0;

  aiStack_20[2] = 0x4964c7;

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

  aiStack_20[2] = 0;

  aiStack_20[1] = 0x4964d4;

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

  aiStack_20[1] = 0;

  aiStack_20[0] = 0x4964e1;

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

  aiStack_20[0] = 0;

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

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

  FUN_0046a740(aiStack_20);

  FUN_00495b70();

  puVar2 = (undefined4 *)(aiStack_20[0] + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(aiStack_20[0] + -0x10));

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

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

  }

  return;

}





// --- FUN_00496540 at 0x00496540 (size: 63) ---


void __fastcall FUN_00496540(int param_1)



{

  undefined1 uVar1;

  int iVar2;

  

  iVar2 = FUN_0055e1d0();

  if (iVar2 != 0) {

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

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

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

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

    uVar1 = FUN_00560e00((undefined4 *)(param_1 + 0x668),(undefined4 *)(param_1 + 0x670));

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

    FUN_00495bd0();

    return;

  }

  return;

}





// --- FUN_00496580 at 0x00496580 (size: 59) ---


int __thiscall FUN_00496580(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_2;

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

    FUN_004934f0(param_2 + 0x40,*(int *)(param_1 + 4),param_2,&param_2,0);

  }

  *(int *)(param_1 + 4) = *(int *)(param_1 + 4) + -0x40;

  FUN_00493530();

  return iVar1;

}





// --- FUN_004965c0 at 0x004965C0 (size: 328) ---


void __fastcall FUN_004965c0(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined *local_4;

  

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

    local_4 = PTR_DAT_00818340;

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

    FUN_00494f70();

    FUN_00494f70();

    FUN_0046a740(param_1 + 0x638);

    FUN_0046a740(param_1 + 0x63c);

    FUN_0046a740(param_1 + 0x640);

    FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x658));

    FUN_0046a740(&local_4);

    FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x65c));

    FUN_0046a740(&local_4);

    FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x660));

    FUN_0046a740(&local_4);

    FUN_00495b70();

    FUN_00495bd0();

    FUN_00495d50();

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

      FUN_00495a50();

    }

    else {

      FUN_00496470();

    }

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

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

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

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

    }

  }

  return;

}





// --- FUN_00496710 at 0x00496710 (size: 352) ---


void __thiscall FUN_00496710(int param_1,uint param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined *local_4;

  

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

    local_4 = PTR_DAT_00818340;

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

    if (param_2 <= (uint)(DAT_0083f33c - DAT_0083f338 >> 6)) {

      FUN_00495300(param_2 * 0x40 + -0x40 + DAT_0083f338);

      *(uint *)(param_1 + 0x634) = param_2;

      FUN_0046a740(param_1 + 0x638);

      FUN_0046a740(param_1 + 0x63c);

      FUN_0046a740(param_1 + 0x640);

      FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x658));

      FUN_0046a740(&local_4);

      FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x65c));

      FUN_0046a740(&local_4);

      FUN_004027b0(&local_4,&DAT_007a11d4,*(undefined4 *)(param_1 + 0x660));

      FUN_0046a740(&local_4);

      FUN_00495b70();

      FUN_00495bd0();

      FUN_00495d50();

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

        FUN_00495a50();

      }

      else {

        FUN_00496470();

      }

    }

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

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

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

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

    }

  }

  return;

}





// --- FUN_00496870 at 0x00496870 (size: 57) ---


void __fastcall FUN_00496870(int param_1)



{

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

    return;

  }

  FUN_00495b70();

  FUN_00495bd0();

  FUN_00495d50();

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

    FUN_00496470();

    return;

  }

  FUN_00495a50();

  return;

}





// --- FUN_004968b0 at 0x004968B0 (size: 140) ---


void __thiscall FUN_004968b0(int param_1,uint param_2)



{

  uint uVar1;

  int iVar2;

  

  if ((*(char *)(param_1 + 0x630) != '\0') &&

     (uVar1 = DAT_0083f33c - DAT_0083f338 >> 6, param_2 <= uVar1)) {

    if (uVar1 < 2) {

      FUN_004965c0();

      return;

    }

    FUN_00496580(param_2 * 0x40 + -0x40 + DAT_0083f338);

    uVar1 = 0;

    if (DAT_0083f33c - DAT_0083f338 >> 6 != 0) {

      iVar2 = 0;

      do {

        uVar1 = uVar1 + 1;

        *(uint *)(iVar2 + 0xc + DAT_0083f338) = uVar1;

        iVar2 = iVar2 + 0x40;

      } while (uVar1 < (uint)(DAT_0083f33c - DAT_0083f338 >> 6));

    }

    FUN_00496710(1);

  }

  return;

}





// --- FUN_00496940 at 0x00496940 (size: 416) ---


void FUN_00496940(int param_1,int *param_2)



{

  undefined *puVar1;

  int iVar2;

  int *piVar3;

  LONG LVar4;

  undefined4 uVar5;

  int *piVar6;

  LONG *lpAddend;

  undefined4 *puVar7;

  int iStack_10;

  int iStack_c;

  int iStack_8;

  int iStack_4;

  

  piVar3 = param_2;

  puVar1 = (undefined *)*param_2;

  if (puVar1 != PTR_DAT_00818344) {

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

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

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

    }

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

    *piVar3 = (int)PTR_DAT_00818344;

    InterlockedIncrement(lpAddend);

  }

  if (DAT_0083da58 == 0) {

    uVar5 = 0;

  }

  else {

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

  }

  uVar5 = FUN_0058f840(uVar5,0,0);

  FUN_00401340(uVar5);

  piVar6 = (int *)FUN_004114c0();

  piVar6 = (int *)(**(code **)(*piVar6 + 0x54))();

  iVar2 = *piVar6;

  iStack_4 = iVar2;

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

  FUN_00408fd0(&iStack_c,0);

  iStack_10 = DAT_00838188;

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

  param_2 = (int *)PTR_DAT_00818344;

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

  thunk_FUN_0040c780(&param_2,&iStack_10);

  FUN_00402710(piVar3,"%s%s-%s-%s.txt",param_2,param_1,iStack_c,iStack_8);

  puVar7 = (undefined4 *)((int)param_2 + -0x14);

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

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

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

  }

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

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

  return;

}





// --- FUN_00496ae0 at 0x00496AE0 (size: 113) ---


void FUN_00496ae0(int param_1,undefined4 param_2)



{

  int iVar1;

  LONG LVar2;

  undefined4 *puVar3;

  

  FUN_00564d30();

  iVar1 = param_1;

  FUN_00404a40(0,param_1);

  FUN_005649f0(&param_1,param_2,1,0);

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

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

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

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

  }

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

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

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

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

  }

  return;

}





// --- FUN_00496b60 at 0x00496B60 (size: 74) ---


void __fastcall FUN_00496b60(int param_1)



{

  undefined1 local_40 [12];

  int local_34;

  

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

    FUN_00494e50();

    local_34 = (DAT_0083f33c - DAT_0083f338 >> 6) + 1;

    FUN_004945c0(DAT_0083f33c,local_40);

    FUN_00493530();

  }

  return;

}





// --- FUN_00496bb0 at 0x00496BB0 (size: 110) ---


void __thiscall FUN_00496bb0(int param_1,undefined4 *param_2)



{

  char cVar1;

  int iVar2;

  

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

    FUN_00462420(param_2);

    return;

  }

  if (((param_2[2] == 0x18) && (param_2[1] == param_1)) && (param_2[3] != 0)) {

    FUN_00496870();

  }

  if (param_2[2] == 1) {

    switch(*param_2) {

    case 0x10000565:

      FUN_00495640();

      if (*(int *)(param_1 + 0x634) != 1) {

        FUN_00496710(*(int *)(param_1 + 0x634) + -1);

        FUN_00462420(param_2);

        return;

      }

      break;

    case 0x10000566:

      FUN_00495640();

      cVar1 = FUN_004951b0();

      if (cVar1 == '\0') {

        FUN_00496710(*(int *)(param_1 + 0x634) + 1);

        FUN_00462420(param_2);

        return;

      }

      break;

    case 0x10000567:

      FUN_00495640();

      FUN_00496b60();

      FUN_00496710(DAT_0083f33c - DAT_0083f338 >> 6);

      FUN_00462420(param_2);

      return;

    case 0x1000056f:

      FUN_00495640();

      FUN_00496710(1);

      FUN_00462420(param_2);

      return;

    case 0x10000571:

      FUN_00495640();

      FUN_00496710(DAT_0083f33c - DAT_0083f338 >> 6);

      FUN_00462420(param_2);

      return;

    case 0x10000574:

      FUN_00496540();

      FUN_00462420(param_2);

      return;

    case 0x1000057d:

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

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

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

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

        FUN_00495a50();

        FUN_00462420(param_2);

        return;

      }

      iVar2 = FUN_00495430();

      if (iVar2 == 0) {

        FUN_00496470();

        FUN_00462420(param_2);

        return;

      }

      FUN_00494dc0();

    }

  }

  FUN_00462420(param_2);

  return;

}





// --- FUN_00496da0 at 0x00496DA0 (size: 1961) ---


void __thiscall FUN_00496da0(int param_1,int param_2)



{

  LONG LVar1;

  FILE *_File;

  int iVar2;

  byte *pbVar3;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  char *pcVar7;

  undefined4 *puVar8;

  byte *pbVar9;

  byte *pbVar10;

  code *pcVar11;

  bool bVar12;

  bool bVar13;

  char **ppcVar14;

  char local_865;

  undefined *local_864;

  undefined4 local_860;

  char *local_85c;

  FILE *local_858;

  undefined4 local_854;

  undefined4 uStack_850;

  undefined1 local_84c [4];

  undefined1 local_848 [4];

  int local_844;

  undefined1 local_840 [4];

  int local_83c;

  undefined1 local_838 [4];

  char local_834 [2100];

  

  local_85c = PTR_DAT_00818344;

  local_844 = param_1;

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

  pcVar11 = InterlockedDecrement_exref;

  iVar6 = 0;

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

    pcVar7 = local_85c + -0x14;

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

    if ((LVar1 == 0) && (pcVar7 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar7)(1);

    }

  }

  else {

    ppcVar14 = &local_85c;

    iVar2 = param_2;

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

    FUN_00496940(iVar2,ppcVar14);

    local_864 = PTR_DAT_00818344;

    local_860 = 0;

    local_854 = 0;

    uStack_850 = 0;

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

    local_865 = '\0';

    _File = fopen(local_85c,"r");

    pcVar11 = InterlockedDecrement_exref;

    local_858 = _File;

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

      iVar2 = FUN_004934f0(DAT_0083f33c,DAT_0083f33c,DAT_0083f338,&local_865,0);

      FUN_00493c20(iVar2,DAT_0083f33c,&local_865);

      DAT_0083f33c = iVar2;

      pcVar7 = fgets(local_834,0x834,_File);

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

        pbVar3 = (byte *)strtok(local_834," \t\n\r");

        if (pbVar3 != (byte *)0x0) {

          if (local_865 == '\0') {

            iVar2 = 7;

            bVar12 = false;

            iVar5 = 0;

            bVar13 = true;

            pbVar9 = pbVar3;

            pbVar10 = &DAT_007a76e0;

            do {

              if (iVar2 == 0) break;

              iVar2 = iVar2 + -1;

              bVar12 = *pbVar9 < *pbVar10;

              bVar13 = *pbVar9 == *pbVar10;

              pbVar9 = pbVar9 + 1;

              pbVar10 = pbVar10 + 1;

            } while (bVar13);

            if (!bVar13) {

              iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

            }

            if (iVar5 != 0) {

              uVar4 = 0x1a;

              FUN_00401340("Problem loading journal: Your journal file does not create a new page!")

              ;

              FUN_00496ae0(iVar2,uVar4);

              fclose(local_858);

              pcVar11 = InterlockedDecrement_exref;

              puVar8 = (undefined4 *)(local_864 + -0x14);

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

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

                (**(code **)*puVar8)(1);

              }

              pcVar7 = local_85c + -0x14;

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

              if ((LVar1 == 0) && (pcVar7 != (char *)0x0)) {

                (*(code *)**(undefined4 **)pcVar7)(1);

              }

              goto LAB_004974b1;

            }

          }

          iVar2 = 7;

          bVar12 = false;

          iVar5 = 0;

          bVar13 = true;

          pbVar9 = pbVar3;

          pbVar10 = &DAT_007a76e0;

          do {

            if (iVar2 == 0) break;

            iVar2 = iVar2 + -1;

            bVar12 = *pbVar9 < *pbVar10;

            bVar13 = *pbVar9 == *pbVar10;

            pbVar9 = pbVar9 + 1;

            pbVar10 = pbVar10 + 1;

          } while (bVar13);

          if (!bVar13) {

            iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

          }

          if (iVar5 == 0) {

            FUN_00496b60();

            iVar2 = DAT_0083f33c - DAT_0083f338 >> 6;

            iVar6 = iVar2 + -1;

            *(int *)(iVar6 * 0x40 + 0xc + DAT_0083f338) = iVar2;

            local_865 = '\x01';

          }

          else {

            iVar2 = 7;

            bVar12 = false;

            iVar5 = 0;

            bVar13 = true;

            pbVar9 = pbVar3;

            pbVar10 = &DAT_007a76d8;

            do {

              if (iVar2 == 0) break;

              iVar2 = iVar2 + -1;

              bVar12 = *pbVar9 < *pbVar10;

              bVar13 = *pbVar9 == *pbVar10;

              pbVar9 = pbVar9 + 1;

              pbVar10 = pbVar10 + 1;

            } while (bVar13);

            if (!bVar13) {

              iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

            }

            if (iVar5 == 0) {

              pcVar7 = strtok((char *)0x0," \t\n\r");

              sscanf(pcVar7,"%d",&local_860);

            }

            else {

              iVar2 = 7;

              bVar12 = false;

              iVar5 = 0;

              bVar13 = true;

              pbVar9 = pbVar3;

              pbVar10 = &DAT_007a76d0;

              do {

                if (iVar2 == 0) break;

                iVar2 = iVar2 + -1;

                bVar12 = *pbVar9 < *pbVar10;

                bVar13 = *pbVar9 == *pbVar10;

                pbVar9 = pbVar9 + 1;

                pbVar10 = pbVar10 + 1;

              } while (bVar13);

              if (!bVar13) {

                iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

              }

              if (iVar5 == 0) {

                pcVar7 = strtok((char *)0x0,"\n\r");

                FUN_00405000(pcVar7);

                uVar4 = FUN_00403350(&local_83c,0);

                FUN_00402070(uVar4);

                puVar8 = (undefined4 *)(local_83c + -0x14);

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

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

                  (**(code **)*puVar8)(1);

                }

              }

              else {

                iVar2 = 7;

                bVar12 = false;

                iVar5 = 0;

                bVar13 = true;

                pbVar9 = pbVar3;

                pbVar10 = &DAT_007a76c4;

                do {

                  if (iVar2 == 0) break;

                  iVar2 = iVar2 + -1;

                  bVar12 = *pbVar9 < *pbVar10;

                  bVar13 = *pbVar9 == *pbVar10;

                  pbVar9 = pbVar9 + 1;

                  pbVar10 = pbVar10 + 1;

                } while (bVar13);

                if (!bVar13) {

                  iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                }

                if (iVar5 == 0) {

                  pcVar7 = strtok((char *)0x0,"\n\r");

                  FUN_00405000(pcVar7);

                  uVar4 = FUN_00403350(local_840,0);

                  FUN_00402070(uVar4);

                  FUN_004011b0();

                }

                else {

                  iVar2 = 7;

                  bVar12 = false;

                  iVar5 = 0;

                  bVar13 = true;

                  pbVar9 = pbVar3;

                  pbVar10 = &DAT_007a76bc;

                  do {

                    if (iVar2 == 0) break;

                    iVar2 = iVar2 + -1;

                    bVar12 = *pbVar9 < *pbVar10;

                    bVar13 = *pbVar9 == *pbVar10;

                    pbVar9 = pbVar9 + 1;

                    pbVar10 = pbVar10 + 1;

                  } while (bVar13);

                  if (!bVar13) {

                    iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                  }

                  if (iVar5 == 0) {

                    pcVar7 = strtok((char *)0x0,"\n\r");

                    FUN_00405000(pcVar7);

                    FUN_00401340(&DAT_00795508);

                    FUN_00401340(&DAT_007a76b8);

                    FUN_004053a0(local_848,local_84c);

                    FUN_004011b0();

                    FUN_004011b0();

                    uVar4 = FUN_00403350(local_838,0);

                    FUN_00402070(uVar4);

                    FUN_004011b0();

                  }

                  else {

                    iVar2 = 7;

                    bVar12 = false;

                    iVar5 = 0;

                    bVar13 = true;

                    pbVar9 = pbVar3;

                    pbVar10 = &DAT_007a76b0;

                    do {

                      if (iVar2 == 0) break;

                      iVar2 = iVar2 + -1;

                      bVar12 = *pbVar9 < *pbVar10;

                      bVar13 = *pbVar9 == *pbVar10;

                      pbVar9 = pbVar9 + 1;

                      pbVar10 = pbVar10 + 1;

                    } while (bVar13);

                    if (!bVar13) {

                      iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                    }

                    if (iVar5 == 0) {

                      pcVar7 = strtok((char *)0x0," \t\n\r");

                      iVar2 = sscanf(pcVar7,"%d",&local_860);

                      if (iVar2 == 1) {

                        *(undefined4 *)(iVar6 * 0x40 + 0x20 + DAT_0083f338) = local_860;

                      }

                    }

                    else {

                      iVar2 = 7;

                      bVar12 = false;

                      iVar5 = 0;

                      bVar13 = true;

                      pbVar9 = pbVar3;

                      pbVar10 = &DAT_007a76a8;

                      do {

                        if (iVar2 == 0) break;

                        iVar2 = iVar2 + -1;

                        bVar12 = *pbVar9 < *pbVar10;

                        bVar13 = *pbVar9 == *pbVar10;

                        pbVar9 = pbVar9 + 1;

                        pbVar10 = pbVar10 + 1;

                      } while (bVar13);

                      if (!bVar13) {

                        iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                      }

                      if (iVar5 == 0) {

                        pcVar7 = strtok((char *)0x0," \t\n\r");

                        iVar2 = sscanf(pcVar7,"%d",&local_860);

                        if (iVar2 == 1) {

                          *(undefined4 *)(iVar6 * 0x40 + 0x24 + DAT_0083f338) = local_860;

                        }

                      }

                      else {

                        iVar2 = 7;

                        bVar12 = false;

                        iVar5 = 0;

                        bVar13 = true;

                        pbVar9 = pbVar3;

                        pbVar10 = &DAT_007a76a0;

                        do {

                          if (iVar2 == 0) break;

                          iVar2 = iVar2 + -1;

                          bVar12 = *pbVar9 < *pbVar10;

                          bVar13 = *pbVar9 == *pbVar10;

                          pbVar9 = pbVar9 + 1;

                          pbVar10 = pbVar10 + 1;

                        } while (bVar13);

                        if (!bVar13) {

                          iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                        }

                        if (iVar5 == 0) {

                          pcVar7 = strtok((char *)0x0," \t\n\r");

                          iVar2 = sscanf(pcVar7,"%d",&local_860);

                          if (iVar2 == 1) {

                            *(undefined4 *)(iVar6 * 0x40 + 0x28 + DAT_0083f338) = local_860;

                          }

                        }

                        else {

                          iVar2 = 7;

                          bVar12 = false;

                          iVar5 = 0;

                          bVar13 = true;

                          pbVar9 = pbVar3;

                          pbVar10 = &DAT_007a7698;

                          do {

                            if (iVar2 == 0) break;

                            iVar2 = iVar2 + -1;

                            bVar12 = *pbVar9 < *pbVar10;

                            bVar13 = *pbVar9 == *pbVar10;

                            pbVar9 = pbVar9 + 1;

                            pbVar10 = pbVar10 + 1;

                          } while (bVar13);

                          if (!bVar13) {

                            iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                          }

                          if (iVar5 == 0) {

                            pbVar3 = (byte *)strtok((char *)0x0," \t\n\r");

                            iVar5 = 5;

                            bVar12 = false;

                            iVar2 = 0;

                            bVar13 = true;

                            pbVar9 = &DAT_007a7690;

                            do {

                              if (iVar5 == 0) break;

                              iVar5 = iVar5 + -1;

                              bVar12 = *pbVar3 < *pbVar9;

                              bVar13 = *pbVar3 == *pbVar9;

                              pbVar3 = pbVar3 + 1;

                              pbVar9 = pbVar9 + 1;

                            } while (bVar13);

                            if (!bVar13) {

                              iVar2 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                            }

                            if (iVar2 == 0) {

                              *(undefined1 *)(iVar6 * 0x40 + 0x2c + DAT_0083f338) = 1;

                            }

                            else {

                              *(undefined1 *)(iVar6 * 0x40 + 0x2c + DAT_0083f338) = 0;

                            }

                          }

                          else {

                            iVar2 = 7;

                            bVar12 = false;

                            iVar5 = 0;

                            bVar13 = true;

                            pbVar9 = pbVar3;

                            pbVar10 = &DAT_007a7688;

                            do {

                              if (iVar2 == 0) break;

                              iVar2 = iVar2 + -1;

                              bVar12 = *pbVar9 < *pbVar10;

                              bVar13 = *pbVar9 == *pbVar10;

                              pbVar9 = pbVar9 + 1;

                              pbVar10 = pbVar10 + 1;

                            } while (bVar13);

                            if (!bVar13) {

                              iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                            }

                            if (iVar5 == 0) {

                              pcVar7 = strtok((char *)0x0," \t\n\r");

                              iVar2 = sscanf(pcVar7,"%lf",&local_854);

                              if (iVar2 == 1) {

                                *(ulonglong *)(iVar6 * 0x40 + 0x30 + DAT_0083f338) =

                                     CONCAT44(uStack_850,local_854);

                              }

                            }

                            else {

                              iVar2 = 7;

                              bVar12 = false;

                              iVar5 = 0;

                              bVar13 = true;

                              pbVar9 = pbVar3;

                              pbVar10 = &DAT_007a7680;

                              do {

                                if (iVar2 == 0) break;

                                iVar2 = iVar2 + -1;

                                bVar12 = *pbVar9 < *pbVar10;

                                bVar13 = *pbVar9 == *pbVar10;

                                pbVar9 = pbVar9 + 1;

                                pbVar10 = pbVar10 + 1;

                              } while (bVar13);

                              if (!bVar13) {

                                iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                              }

                              if (iVar5 == 0) {

                                pcVar7 = strtok((char *)0x0," \t\n\r");

                                iVar2 = sscanf(pcVar7,"%lf",&local_854);

                                if (iVar2 == 1) {

                                  *(ulonglong *)(iVar6 * 0x40 + 0x38 + DAT_0083f338) =

                                       CONCAT44(uStack_850,local_854);

                                }

                              }

                              else {

                                iVar2 = 7;

                                bVar12 = false;

                                iVar5 = 0;

                                bVar13 = true;

                                pbVar9 = pbVar3;

                                pbVar10 = &DAT_007a7678;

                                do {

                                  if (iVar2 == 0) break;

                                  iVar2 = iVar2 + -1;

                                  bVar12 = *pbVar9 < *pbVar10;

                                  bVar13 = *pbVar9 == *pbVar10;

                                  pbVar9 = pbVar9 + 1;

                                  pbVar10 = pbVar10 + 1;

                                } while (bVar13);

                                if (!bVar13) {

                                  iVar5 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                                }

                                if (iVar5 == 0) {

                                  pbVar3 = (byte *)strtok((char *)0x0," \t\n\r");

                                  iVar5 = 5;

                                  bVar12 = false;

                                  iVar2 = 0;

                                  bVar13 = true;

                                  pbVar9 = &DAT_007a7690;

                                  do {

                                    if (iVar5 == 0) break;

                                    iVar5 = iVar5 + -1;

                                    bVar12 = *pbVar3 < *pbVar9;

                                    bVar13 = *pbVar3 == *pbVar9;

                                    pbVar3 = pbVar3 + 1;

                                    pbVar9 = pbVar9 + 1;

                                  } while (bVar13);

                                  if (!bVar13) {

                                    iVar2 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                                  }

                                  if (iVar2 == 0) {

                                    *(undefined1 *)(iVar6 * 0x40 + 0x10 + DAT_0083f338) = 1;

                                  }

                                  else {

                                    *(undefined1 *)(iVar6 * 0x40 + 0x10 + DAT_0083f338) = 0;

                                  }

                                }

                                else {

                                  iVar5 = 7;

                                  bVar12 = false;

                                  iVar2 = 0;

                                  bVar13 = true;

                                  pbVar9 = &DAT_007a7670;

                                  do {

                                    if (iVar5 == 0) break;

                                    iVar5 = iVar5 + -1;

                                    bVar12 = *pbVar3 < *pbVar9;

                                    bVar13 = *pbVar3 == *pbVar9;

                                    pbVar3 = pbVar3 + 1;

                                    pbVar9 = pbVar9 + 1;

                                  } while (bVar13);

                                  if (!bVar13) {

                                    iVar2 = (1 - (uint)bVar12) - (uint)(bVar12 != 0);

                                  }

                                  if (iVar2 == 0) {

                                    pcVar7 = strtok((char *)0x0," \t\n\r");

                                    iVar2 = sscanf(pcVar7,"%lf",&local_854);

                                    if (iVar2 == 1) {

                                      *(ulonglong *)(iVar6 * 0x40 + 0x18 + DAT_0083f338) =

                                           CONCAT44(uStack_850,local_854);

                                    }

                                  }

                                }

                              }

                            }

                          }

                        }

                      }

                    }

                  }

                }

              }

            }

          }

        }

        pcVar7 = fgets(local_834,0x834,local_858);

        _File = local_858;

      }

      fclose(_File);

      pcVar11 = InterlockedDecrement_exref;

      puVar8 = (undefined4 *)(local_864 + -0x14);

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

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

        (**(code **)*puVar8)(1);

      }

      pcVar7 = local_85c + -0x14;

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

      if ((LVar1 == 0) && (pcVar7 != (char *)0x0)) {

        (*(code *)**(undefined4 **)pcVar7)(1);

      }

LAB_004974b1:

      iVar6 = (*pcVar11)(param_2 + -0x10);

      goto joined_r0x004974b9;

    }

    puVar8 = (undefined4 *)(local_864 + -0x14);

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

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

      (**(code **)*puVar8)(1);

    }

    pcVar7 = local_85c + -0x14;

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

    if ((LVar1 == 0) && (pcVar7 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar7)(1);

    }

  }

  iVar6 = (*pcVar11)(param_2 + -0x10);

joined_r0x004974b9:

  if ((iVar6 == 0) && ((undefined4 *)(param_2 + -0x14) != (undefined4 *)0x0)) {

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

  }

  return;

}





// --- FUN_00497550 at 0x00497550 (size: 1377) ---


void __thiscall FUN_00497550(int param_1,int param_2)



{

  int iVar1;

  undefined *puVar2;

  LONG LVar3;

  FILE *_File;

  int iVar4;

  undefined4 *puVar5;

  char *pcVar6;

  code *pcVar7;

  char **ppcVar8;

  undefined *local_28;

  undefined *local_24;

  char *local_20;

  int iStack_1c;

  int iStack_18;

  uint local_14;

  int local_10;

  int iStack_c;

  undefined *puStack_8;

  undefined4 *puStack_4;

  

  local_20 = PTR_DAT_00818344;

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

  local_28 = PTR_DAT_00818344;

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

  local_24 = PTR_DAT_00818344;

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

  pcVar7 = InterlockedDecrement_exref;

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

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

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

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

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

    }

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

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

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

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

    }

    pcVar6 = local_20 + -0x14;

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

    if ((LVar3 == 0) && (pcVar6 != (char *)0x0)) {

      (*(code *)**(undefined4 **)pcVar6)(1);

    }

  }

  else {

    ppcVar8 = &local_20;

    iVar4 = param_2;

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

    FUN_00496940(iVar4,ppcVar8);

    _File = fopen(local_20,"w");

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

       (_File = fopen(local_20,"w+"), pcVar7 = InterlockedDecrement_exref, _File == (FILE *)0x0)) {

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

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

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

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

      }

    }

    else {

      local_14 = 0;

      if (DAT_0083f33c - DAT_0083f338 >> 6 != 0) {

        iVar4 = 0;

        do {

          FUN_00402710(&local_28,"<NEWP>\n");

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00408fd0(&local_10,0);

          iVar1 = local_10;

          FUN_00402710(&local_28,"<LABE> %s\n",local_10);

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

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

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

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

          }

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00408fd0(&iStack_c,0);

          iVar1 = iStack_c;

          FUN_00402710(&local_28,"<TITL> %s\n",iStack_c);

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

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

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

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

          }

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00408fd0(&puStack_8,0);

          puVar2 = puStack_8;

          if (local_24 != puStack_8) {

            puStack_4 = (undefined4 *)(local_24 + -0x14);

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

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

              (**(code **)*puStack_4)(1);

            }

            local_24 = puVar2;

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

          }

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

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

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

          }

          FUN_00401340(&DAT_007a76b8);

          FUN_00401340(&DAT_00795508);

          FUN_004053a0(&iStack_1c,&iStack_18);

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

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

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

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

          }

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

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

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

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

          }

          FUN_00402710(&local_28,"<NOTE> %s\n",local_24);

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<DAYS> %d\n",*(undefined4 *)(iVar4 + 0x20 + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<HOUR> %d\n",*(undefined4 *)(iVar4 + 0x24 + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<MINU> %d\n",*(undefined4 *)(iVar4 + 0x28 + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          pcVar6 = "TRUE";

          if (*(char *)(iVar4 + 0x2c + DAT_0083f338) == '\0') {

            pcVar6 = "FALSE";

          }

          FUN_00402710(&local_28,"<LOC?> %s\n",pcVar6);

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<LOCX> %f\n",*(undefined4 *)(iVar4 + 0x30 + DAT_0083f338),

                       *(undefined4 *)(iVar4 + 0x34 + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<LOCY> %f\n",*(undefined4 *)(iVar4 + 0x38 + DAT_0083f338),

                       *(undefined4 *)(iVar4 + 0x3c + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          pcVar6 = "TRUE";

          if (*(char *)(iVar4 + 0x10 + DAT_0083f338) == '\0') {

            pcVar6 = "FALSE";

          }

          FUN_00402710(&local_28,"<TIM?> %s\n",pcVar6);

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          FUN_00402710(&local_28,"<TIME> %f\n\n",*(undefined4 *)(iVar4 + 0x18 + DAT_0083f338),

                       *(undefined4 *)(iVar4 + 0x1c + DAT_0083f338));

          fwrite(local_28,1,*(int *)(local_28 + -4) - 1,_File);

          local_14 = local_14 + 1;

          iVar4 = iVar4 + 0x40;

        } while (local_14 < (uint)(DAT_0083f33c - DAT_0083f338 >> 6));

      }

      fclose(_File);

      pcVar7 = InterlockedDecrement_exref;

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

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

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

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

      }

    }

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

    iVar4 = (*pcVar7)(local_28 + -0x10);

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

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

    }

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

    iVar4 = (*pcVar7)(local_24 + -0x10);

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

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

    }

  }

  iVar4 = (*pcVar7)(param_2 + -0x10);

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

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

  }

  return;

}





// --- FUN_00497bd0 at 0x00497BD0 (size: 171) ---


void __thiscall FUN_00497bd0(int param_1,undefined *param_2)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined *puVar4;

  

  uVar1 = param_2;

  FUN_00463830(param_2);

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

    param_2 = PTR_DAT_00818344;

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

    FUN_00402710(&param_2,"Journal");

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

      FUN_004948f0(DAT_0083f338,DAT_0083f33c,&LAB_00494cc0);

    }

    FUN_00495640();

    puVar4 = param_2;

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

    FUN_00497550(puVar4);

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

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

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

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

    }

  }

  return;

}





// --- FUN_00497c80 at 0x00497C80 (size: 97) ---


undefined4 FUN_00497c80(uint param_1)



{

  uint uVar1;

  

  uVar1 = param_1 & 0xffff;

  if (((((uVar1 != 0) && (uVar1 < 0x41)) || ((0xff < uVar1 && (uVar1 < 0xfffe)))) ||

      (uVar1 == 0xffff)) &&

     (((param_1 >> 0x15 & 0x7f8) < 0x7f8 && ((param_1 >> 0xd & 0x7f8) < 0x7f8)))) {

    return 1;

  }

  return 0;

}





// --- FUN_00497cf0 at 0x00497CF0 (size: 89) ---


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



uint __thiscall FUN_00497cf0(int param_1,int param_2)



{

  double dVar1;

  uint in_EAX;

  

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

    dVar1 = *(double *)(param_1 + 0x630) + _DAT_007938c0;

    in_EAX = CONCAT22((short)(in_EAX >> 0x10),

                      (ushort)(_DAT_008379a8 < dVar1) << 8 |

                      (ushort)(NAN(_DAT_008379a8) || NAN(dVar1)) << 10 |

                      (ushort)(_DAT_008379a8 == dVar1) << 0xe);

    if (_DAT_008379a8 < dVar1 || (_DAT_008379a8 == dVar1) != 0) {

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

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

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

      return 1;

    }

  }

  *(double *)(param_1 + 0x630) = _DAT_008379a8;

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

  return in_EAX & 0xffffff00;

}





// --- FUN_00497d70 at 0x00497D70 (size: 125) ---


undefined4 FUN_00497d70(uint param_1,uint *param_2,int *param_3)



{

  int iVar1;

  

  iVar1 = FUN_00497c80(param_1);

  if ((iVar1 != 0) && ((param_1 & 0xffff) < 0x100)) {

    *param_2 = param_1 >> 0x15 & 0x7f8;

    *param_3 = (param_1 >> 0x10 & 0xff) << 3;

    *param_2 = *param_2 + ((param_1 & 0xffff) - 1 >> 3);

    iVar1 = *param_3 + (param_1 - 1 & 7);

    *param_3 = iVar1;

    if ((-1 < (int)*param_2) && (((-1 < iVar1 && ((int)*param_2 < 0x7f8)) && (iVar1 < 0x7f8)))) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00497df0 at 0x00497DF0 (size: 77) ---


void __fastcall FUN_00497df0(int *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  puVar2 = (undefined4 *)(param_1[1] + -0x14);

  param_1[2] = (int)&PTR_FUN_0079385c;

  LVar1 = InterlockedDecrement((LONG *)(param_1[1] + -0x10));

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

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

  }

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

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

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

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

  }

  return;

}





// --- FUN_00497e40 at 0x00497E40 (size: 168) ---


int * __fastcall FUN_00497e40(int *param_1)



{

  undefined *puVar1;

  LONG LVar2;

  LONG *pLVar3;

  

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

  *param_1 = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[1] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

  FUN_0059a100();

  puVar1 = (undefined *)*param_1;

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    *param_1 = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  puVar1 = (undefined *)param_1[1];

  if (puVar1 != PTR_DAT_00818340) {

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

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

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

    }

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

    param_1[1] = (int)PTR_DAT_00818340;

    InterlockedIncrement(pLVar3);

  }

  return param_1;

}





// --- FUN_00497ef0 at 0x00497EF0 (size: 87) ---


void __thiscall FUN_00497ef0(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

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

  uVar5 = 0;

  if (uVar1 != 0) {

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

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007a797c;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

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

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007a797c;

  param_2[3] = uVar1;

  return;

}





// --- FUN_00497f50 at 0x00497F50 (size: 66) ---


void __fastcall FUN_00497f50(int param_1)



{

  int iVar1;

  uint uVar2;

  int *piVar3;

  

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

  if (iVar1 != 0) {

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

    return;

  }

  uVar2 = *(int *)(*(int *)(param_1 + 4) + 0x34) + 1;

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

    piVar3 = (int *)(*(int *)(param_1 + 8) + uVar2 * 4);

    do {

      if (*piVar3 != 0) {

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

        return;

      }

      uVar2 = uVar2 + 1;

      piVar3 = piVar3 + 1;

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

  }

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

  return;

}





// --- FUN_00497fa0 at 0x00497FA0 (size: 62) ---


uint * __thiscall FUN_00497fa0(int param_1,uint param_2)



{

  uint *puVar1;

  

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

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

        puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[0x45]) {

      if (param_2 == *puVar1) {

        return puVar1 + 1;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_00497fe0 at 0x00497FE0 (size: 173) ---


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



{

  int iVar1;

  LONG LVar2;

  LONG *pLVar3;

  

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

  *param_1 = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

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

  param_1[1] = (int)PTR_DAT_00818340;

  InterlockedIncrement(pLVar3);

  FUN_0059a100();

  iVar1 = *param_1;

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

    *param_1 = iVar1;

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

  }

  iVar1 = param_1[1];

  if (iVar1 != param_2[1]) {

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

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

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

    }

    iVar1 = param_2[1];

    param_1[1] = iVar1;

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

  }

  FUN_0059a0c0(param_2 + 2);

  return param_1;

}





// --- FUN_00498090 at 0x00498090 (size: 131) ---


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



{

  int iVar1;

  LONG LVar2;

  

  iVar1 = *param_1;

  if (iVar1 != *param_2) {

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

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

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

    }

    iVar1 = *param_2;

    *param_1 = iVar1;

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

  }

  iVar1 = param_1[1];

  if (iVar1 != param_2[1]) {

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

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

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

    }

    iVar1 = param_2[1];

    param_1[1] = iVar1;

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

  }

  FUN_0059a0c0(param_2 + 2);

  return param_1;

}





// --- FUN_00498120 at 0x00498120 (size: 332) ---


void __fastcall FUN_00498120(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  FUN_004639a0();

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

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

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

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

    uVar2 = 0;

  }

  else {

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

  }

  *(undefined4 *)(param_1 + 0x618) = uVar2;

  piVar1 = (int *)FUN_00463c00(0x100005e3);

  if (piVar1 == (int *)0x0) {

    uVar2 = 0;

  }

  else {

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

  }

  *(undefined4 *)(param_1 + 0x61c) = uVar2;

  piVar1 = (int *)FUN_00463c00(0x100005de);

  if (piVar1 == (int *)0x0) {

    uVar2 = 0;

  }

  else {

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

  }

  *(undefined4 *)(param_1 + 0x620) = uVar2;

  piVar1 = (int *)FUN_0043c680();

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 4))(0x4dd281,param_1 + 0x5f8);

    (**(code **)(*piVar1 + 4))(0x4dd282,param_1 + 0x5f8);

  }

  FUN_00465f90(3);

  return;

}





// --- FUN_00498270 at 0x00498270 (size: 155) ---


undefined4 __thiscall FUN_00498270(int param_1,uint *param_2,undefined4 param_3)



{

  uint *puVar1;

  uint uVar2;

  

  if ((*(uint *)(param_1 + 0xc) != 0) && (*(int *)(param_1 + 8) != 0)) {

    for (puVar1 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[0xc]) {

      if (*param_2 == *puVar1) {

        if (puVar1 != (uint *)0xfffffff8) {

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x38);

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  uVar2 = *(uint *)(param_1 + 0xc);

  *puVar1 = *param_2;

  FUN_0059a130(param_3);

  puVar1[0xc] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[0xd] = uVar2;

  puVar1[0xc] = *(uint *)(*(int *)(param_1 + 8) + uVar2 * 4);

  *(uint **)(*(int *)(param_1 + 8) + uVar2 * 4) = puVar1;

  *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;

  return 1;

}





// --- FUN_00498310 at 0x00498310 (size: 47) ---


int FUN_00498310(int param_1,int param_2,int param_3)



{

  for (; param_1 != param_2; param_1 = param_1 + 0x30) {

    if (param_3 != 0) {

      FUN_00497fe0(param_1);

    }

    param_3 = param_3 + 0x30;

  }

  return param_3;

}





// --- FUN_00498340 at 0x00498340 (size: 77) ---


int FUN_00498340(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = (param_2 - param_1) / 0x30;

  if (iVar1 < 1) {

    return param_3;

  }

  do {

    param_2 = param_2 + -0x30;

    param_3 = param_3 + -0x30;

    FUN_00498090(param_2);

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_3;

}





// --- FUN_00498390 at 0x00498390 (size: 69) ---


int FUN_00498390(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  iVar1 = (param_2 - param_1) / 0x30;

  if (iVar1 < 1) {

    return param_3;

  }

  do {

    FUN_00498090(param_1);

    param_1 = param_1 + 0x30;

    param_3 = param_3 + 0x30;

    iVar1 = iVar1 + -1;

  } while (iVar1 != 0);

  return param_3;

}





// --- FUN_004983e0 at 0x004983E0 (size: 121) ---


void FUN_004983e0(undefined4 param_1,undefined4 param_2)



{

  LONG LVar1;

  int local_30;

  int local_2c;

  undefined **local_28;

  

  FUN_00497fe0(param_1);

  FUN_00498090(param_2);

  FUN_00498090(&local_30);

  local_28 = &PTR_FUN_0079385c;

  LVar1 = InterlockedDecrement((LONG *)(local_2c + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_2c + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_2c + -0x14))(1);

  }

  LVar1 = InterlockedDecrement((LONG *)(local_30 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_30 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_30 + -0x14))(1);

  }

  return;

}





// --- FUN_00498460 at 0x00498460 (size: 148) ---


void FUN_00498460(int param_1,int param_2,int param_3,undefined **param_4)



{

  code *pcVar1;

  char cVar2;

  LONG LVar3;

  undefined4 *puVar4;

  code *in_stack_00000038;

  

  pcVar1 = in_stack_00000038;

  param_1 = param_1 + -0x30;

  cVar2 = (*in_stack_00000038)(&param_2,param_1);

  while (cVar2 != '\0') {

    FUN_00498090(param_1);

    param_1 = param_1 + -0x30;

    cVar2 = (*pcVar1)(&param_2,param_1);

  }

  FUN_00498090(&param_2);

  puVar4 = (undefined4 *)(param_3 + -0x14);

  param_4 = &PTR_FUN_0079385c;

  LVar3 = InterlockedDecrement((LONG *)(param_3 + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  puVar4 = (undefined4 *)(param_2 + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return;

}





// --- FUN_00498500 at 0x00498500 (size: 185) ---


void FUN_00498500(int param_1,int param_2,int param_3,int param_4,int param_5,undefined **param_6)



{

  int iVar1;

  char cVar2;

  LONG LVar3;

  undefined4 *puVar4;

  code *in_stack_00000040;

  

  while (param_3 < param_2) {

    param_2 = (param_2 + -1) / 2;

    iVar1 = param_2 * 0x30 + param_1;

    cVar2 = (*in_stack_00000040)(iVar1,&param_4);

    if (cVar2 == '\0') break;

    FUN_00498090(iVar1);

  }

  FUN_00498090(&param_4);

  puVar4 = (undefined4 *)(param_5 + -0x14);

  param_6 = &PTR_FUN_0079385c;

  LVar3 = InterlockedDecrement((LONG *)(param_5 + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  puVar4 = (undefined4 *)(param_4 + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(param_4 + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return;

}





// --- FUN_004985c0 at 0x004985C0 (size: 52) ---


void __fastcall FUN_004985c0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007a7980;

  FUN_005d1400();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00498690 at 0x00498690 (size: 91) ---


int __fastcall FUN_00498690(int param_1)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  undefined4 local_4;

  

  uVar3 = 0;

  iVar4 = 4;

  local_4 = 0;

  if (*(int *)(param_1 + 0xc) != 0) {

    do {

      for (iVar1 = *(int *)(*(int *)(param_1 + 8) + uVar3 * 4); iVar1 != 0;

          iVar1 = *(int *)(iVar1 + 0x30)) {

        iVar2 = (**(code **)(*(int *)(iVar1 + 8) + 0xc))(&local_4,0);

        iVar4 = iVar4 + 4 + iVar2;

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 0xc));

  }

  return iVar4;

}





// --- FUN_00498810 at 0x00498810 (size: 72) ---


undefined4 * __thiscall FUN_00498810(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007a7980;

  FUN_005d1400();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00498860 at 0x00498860 (size: 118) ---


int __thiscall FUN_00498860(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_1 != param_2) {

    FUN_005d1400();

    uVar3 = 0;

    if (*(void **)(param_1 + 8) != (void *)0x0) {

      operator_delete__(*(void **)(param_1 + 8));

      *(undefined4 *)(param_1 + 8) = 0;

    }

    *(undefined4 *)(param_1 + 0xc) = 0;

    *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

    FUN_005a8440();

    if (*(int *)(param_2 + 0xc) != 0) {

      do {

        iVar2 = *(int *)(*(int *)(param_2 + 8) + uVar3 * 4);

        while (iVar2 != 0) {

          iVar1 = *(int *)(iVar2 + 0x30);

          FUN_00498270(iVar2,iVar2 + 8);

          iVar2 = iVar1;

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(param_2 + 0xc));

    }

  }

  return param_1;

}





// --- FUN_004988e0 at 0x004988E0 (size: 98) ---


void FUN_004988e0(int *param_1,int *param_2)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  for (; param_1 != param_2; param_1 = param_1 + 0xc) {

    puVar2 = (undefined4 *)(param_1[1] + -0x14);

    param_1[2] = (int)&PTR_FUN_0079385c;

    LVar1 = InterlockedDecrement((LONG *)(param_1[1] + -0x10));

    if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

      (**(code **)*puVar2)(1);

    }

    puVar2 = (undefined4 *)(*param_1 + -0x14);

    LVar1 = InterlockedDecrement((LONG *)(*param_1 + -0x10));

    if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

      (**(code **)*puVar2)(1);

    }

  }

  return;

}





// --- FUN_00498950 at 0x00498950 (size: 51) ---


void FUN_00498950(int param_1,int param_2)



{

  for (; param_1 != param_2; param_1 = param_1 + 0x30) {

    FUN_00497fe0(param_1);

    FUN_00498460(param_1);

  }

  return;

}





// --- FUN_00498990 at 0x00498990 (size: 230) ---


void FUN_00498990(int param_1,int param_2,int param_3,int param_4,int param_5,undefined **param_6)



{

  int iVar1;

  char cVar2;

  int iVar3;

  LONG LVar4;

  int iVar5;

  undefined4 *puVar6;

  code *in_stack_00000040;

  

  iVar3 = param_2;

  while( true ) {

    iVar1 = iVar3 * 2;

    iVar5 = iVar1 + 2;

    if (param_3 <= iVar5) break;

    iVar3 = iVar5 * 0x30 + param_1;

    cVar2 = (*in_stack_00000040)(iVar3,iVar3 + -0x30);

    if (cVar2 != '\0') {

      iVar5 = iVar1 + 1;

    }

    FUN_00498090(iVar5 * 0x30 + param_1);

    iVar3 = iVar5;

  }

  if (iVar5 == param_3) {

    FUN_00498090(iVar5 * 0x30 + -0x30 + param_1);

    iVar3 = iVar1 + 1;

  }

  FUN_00497fe0(&param_4);

  FUN_00498500(param_1,iVar3,param_2);

  puVar6 = (undefined4 *)(param_5 + -0x14);

  param_6 = &PTR_FUN_0079385c;

  LVar4 = InterlockedDecrement((LONG *)(param_5 + -0x10));

  if ((LVar4 == 0) && (puVar6 != (undefined4 *)0x0)) {

    (**(code **)*puVar6)(1);

  }

  puVar6 = (undefined4 *)(param_4 + -0x14);

  LVar4 = InterlockedDecrement((LONG *)(param_4 + -0x10));

  if ((LVar4 == 0) && (puVar6 != (undefined4 *)0x0)) {

    (**(code **)*puVar6)(1);

  }

  return;

}





// --- FUN_00498e80 at 0x00498E80 (size: 120) ---


uint FUN_00498e80(uint param_1,uint param_2)



{

  code *pcVar1;

  char cVar2;

  code *in_stack_0000003c;

  

  pcVar1 = in_stack_0000003c;

  while( true ) {

    cVar2 = (*pcVar1)(param_1,&stack0x0000000c);

    while (cVar2 != '\0') {

      param_1 = param_1 + 0x30;

      cVar2 = (*pcVar1)(param_1,&stack0x0000000c);

    }

    param_2 = param_2 - 0x30;

    cVar2 = (*pcVar1)(&stack0x0000000c,param_2);

    while (cVar2 != '\0') {

      param_2 = param_2 - 0x30;

      cVar2 = (*pcVar1)(&stack0x0000000c,param_2);

    }

    if (param_2 <= param_1) break;

    FUN_004983e0(param_1,param_2);

    param_1 = param_1 + 0x30;

  }

  FUN_00497df0();

  return param_1;

}





// --- FUN_00498f00 at 0x00498F00 (size: 146) ---


void FUN_00498f00(int param_1,int param_2,undefined4 param_3,int param_4,int param_5,

                 undefined **param_6)



{

  LONG LVar1;

  undefined4 *puVar2;

  undefined4 in_stack_00000040;

  

  FUN_00498090(param_1);

  FUN_00497fe0(&param_4);

  FUN_00498990(param_1,0,(param_2 - param_1) / 0x30);

  puVar2 = (undefined4 *)(param_5 + -0x14);

  param_6 = &PTR_FUN_0079385c;

  LVar1 = InterlockedDecrement((LONG *)(param_5 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = (undefined4 *)(param_4 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(param_4 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  return;

}





// --- FUN_00498fa0 at 0x00498FA0 (size: 98) ---


void FUN_00498fa0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  iVar1 = (param_2 - param_1) / 0x30;

  if (1 < iVar1) {

    iVar2 = (iVar1 + -2) / 2;

    iVar3 = iVar2 * 0x30 + param_1;

    while( true ) {

      FUN_00497fe0(iVar3);

      FUN_00498990(param_1,iVar2,iVar1);

      if (iVar2 == 0) break;

      iVar2 = iVar2 + -1;

      iVar3 = iVar3 + -0x30;

    }

  }

  return;

}





// --- FUN_00499010 at 0x00499010 (size: 168) ---


void FUN_00499010(undefined4 param_1,int param_2,int param_3,int param_4,undefined **param_5)



{

  char cVar1;

  LONG LVar2;

  undefined4 *puVar3;

  code *in_stack_0000003c;

  

  cVar1 = (*in_stack_0000003c)(&param_3,param_1);

  if (cVar1 == '\0') {

    FUN_00497fe0(&param_3);

    FUN_00498460(param_2);

  }

  else {

    FUN_00498340(param_1,param_2,param_2 + 0x30,&stack0x0000003c,0);

    FUN_00498090(&param_3);

  }

  puVar3 = (undefined4 *)(param_4 + -0x14);

  param_5 = &PTR_FUN_0079385c;

  LVar2 = InterlockedDecrement((LONG *)(param_4 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  puVar3 = (undefined4 *)(param_3 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(param_3 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return;

}





// --- FUN_004990c0 at 0x004990C0 (size: 475) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_004990c0(int param_1,int param_2,undefined4 param_3)



{

  uint uVar1;

  int iVar2;

  

  iVar2 = param_2;

  uVar1 = *(uint *)(param_1 + 0xc);

  if (uVar1 == 1) {

    FUN_004027b0();

    return;

  }

  if (uVar1 == 2) {

    FUN_004027b0();

    return;

  }

  if (uVar1 != 3) {

    if (3 < uVar1) {

      if (*(int *)(*(int *)(param_2 + 0x14) + 8) == 1) {

        FUN_004027b0(param_3,L"In Progress");

        return;

      }

      FUN_00401a40();

      FUN_00402710(&param_2,*(int *)(iVar2 + 0x14) + 0x14,*(int *)(param_1 + 0xc) + -4);

      FUN_00404a40(0,param_2);

      FUN_00402070();

      FUN_004011b0();

      FUN_004011b0();

    }

    return;

  }

  if (_DAT_00795610 < *(double *)(param_1 + 0x18)) {

    if (_DAT_00795610 < *(double *)(param_1 + 0x18) - (_DAT_008379a8 - *(double *)(param_1 + 0x20)))

    {

      FUN_00401a60();

      iVar2 = FUN_005df4c4(&param_2);

      FUN_00566bb0((double)iVar2);

      FUN_004027b0(param_3,L"Done (");

      FUN_00408800(&param_2);

      FUN_00402730(L" to Repeat)");

      FUN_00408800(&param_3);

      FUN_004011b0();

      FUN_004011b0();

      return;

    }

    FUN_004027b0();

    return;

  }

  if (*(int *)(*(int *)(param_2 + 0x34) + 8) == 1) {

    FUN_004027b0();

    return;

  }

  FUN_004027b0();

  return;

}





// --- FUN_004992a0 at 0x004992A0 (size: 63) ---


void FUN_004992a0(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_1;

  if (param_1 != param_2) {

    while (iVar1 = iVar1 + 0x30, iVar1 != param_2) {

      FUN_00497fe0(iVar1);

      FUN_00499010(param_1,iVar1);

    }

  }

  return;

}





// --- FUN_004992f0 at 0x004992F0 (size: 110) ---


int FUN_004992f0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = -(param_2 - param_1 >> 0x1f);

  if (1 < (param_2 - param_1) / 0x30) {

    param_2 = param_2 + -0x30;

    do {

      FUN_00497fe0(param_2);

      FUN_00498f00(param_1,param_2,param_2);

      param_2 = param_2 + -0x30;

      iVar1 = (0x30 - param_1) + param_2;

      iVar2 = iVar1 * 0x2aaaaaab;

    } while (1 < iVar1 / 0x30);

  }

  return iVar2;

}





// --- FUN_00499360 at 0x00499360 (size: 124) ---


undefined4 * __thiscall FUN_00499360(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_007a7ca0;

  param_1[0x17e] = &PTR_FUN_007a79f8;

  param_1[0x17f] = 0;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  param_1[0x182] = 0;

  param_1[0x189] = 0;

  *(undefined1 *)(param_1 + 0x18a) = 0;

  param_1[0x18c] = 0;

  param_1[0x18d] = 0;

  param_1[0x18e] = 0;

  param_1[399] = 0;

  param_1[0x18b] = 0xffffffff;

  return param_1;

}





// --- FUN_00499410 at 0x00499410 (size: 151) ---


void __fastcall FUN_00499410(undefined4 *param_1)



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  undefined4 uStack_4;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007a7ca0;

  *puVar1 = &PTR_FUN_007a79f8;

  uStack_4 = param_1;

  FUN_00465fb0(3);

  piVar3 = (int *)FUN_0043c680();

  if (piVar3 != (int *)0x0) {

    (**(code **)(*piVar3 + 0xc))(puVar1);

  }

  FUN_004988e0(param_1[0x17f],param_1[0x180],(int)&uStack_4 + 3);

  iVar2 = param_1[0x17f];

  if (iVar2 != 0) {

    FUN_004051c0(iVar2,((param_1[0x181] - iVar2) / 0x30) * 0x30);

  }

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_004994e0 at 0x004994E0 (size: 1263) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_004994e0(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 uVar3;

  LONG LVar4;

  int iVar5;

  undefined *puVar6;

  undefined4 *puVar7;

  undefined *puVar8;

  int iVar9;

  uint uVar10;

  float10 fVar11;

  int local_2c;

  int local_28;

  undefined *puStack_24;

  double local_20;

  int *local_14;

  double dStack_10;

  

  iVar2 = *(int *)(param_1 + 0x608);

  uVar10 = 0;

  if (*(uint *)(iVar2 + 0x610) == 0) {

    return;

  }

  piVar1 = *(int **)(iVar2 + 0x608);

  while (*piVar1 != *(int *)(iVar2 + 0x614)) {

    uVar10 = uVar10 + 1;

    piVar1 = piVar1 + 1;

    if (*(uint *)(iVar2 + 0x610) <= uVar10) {

      return;

    }

  }

  if (uVar10 == 0xffffffff) {

    return;

  }

  piVar1 = (int *)FUN_00415730(0x17,2,0x10000010);

  if (piVar1 == (int *)0x0) {

    return;

  }

  iVar9 = uVar10 * 0x30;

  local_14 = piVar1;

  iVar2 = FUN_00497fa0(*(undefined4 *)(*(int *)(param_1 + 0x5fc) + 0x10 + iVar9));

  if (iVar2 == 0) {

    (**(code **)(*piVar1 + 0x14))();

    return;

  }

  uVar3 = FUN_00404a40();

  FUN_0046a740(uVar3);

  puVar7 = (undefined4 *)(local_20._0_4_ + -0x14);

  LVar4 = InterlockedDecrement((LONG *)(local_20._0_4_ + -0x10));

  if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  local_2c = 0;

  local_28 = 0;

  if ((*(int *)(*(int *)(iVar2 + 0x1c) + 8) == 1) ||

     (((uVar10 = *(uint *)(*(int *)(param_1 + 0x5fc) + 0x14 + iVar9), uVar10 != 2 && (uVar10 < 4))

      && (*(int *)(*(int *)(iVar2 + 0x18) + 8) != 1)))) {

    uVar3 = FUN_00404a40();

    FUN_0046a740(uVar3);

    FUN_004011b0();

    iVar5 = *(int *)(iVar2 + 0x3c);

  }

  else {

    uVar3 = FUN_00404a40();

    FUN_0046a740(uVar3);

    FUN_004011b0();

    iVar5 = *(int *)(iVar2 + 0x84);

  }

  if (iVar5 != 0) {

    iVar5 = FUN_00497d70(iVar5,&local_2c,&local_28);

    if (iVar5 == 0) {

      FUN_00402730(L"Indoors");

    }

    else {

      dStack_10 = (double)(local_2c + -0x400) * _DAT_007a7e00 + _DAT_00799088;

      local_20 = (double)(local_28 + -0x400) * _DAT_007a7e00 + _DAT_00799088;

      if (_DAT_00795610 <= dStack_10) {

        puVar6 = &DAT_007a75f4;

        if (dStack_10 <= _DAT_00795610) {

          puVar6 = &DAT_00795320;

        }

      }

      else {

        puVar6 = &DAT_007a75f8;

      }

      if (_DAT_00795610 <= local_20) {

        puVar8 = &DAT_007a75ec;

        if (local_20 <= _DAT_00795610) {

          puVar8 = &DAT_00795320;

        }

      }

      else {

        puVar8 = &DAT_007a75f0;

      }

      fVar11 = (float10)FUN_00494ca0(dStack_10,puVar6);

      fVar11 = (float10)FUN_00494ca0(local_20._0_4_,(int)((ulonglong)local_20 >> 0x20),puVar8,

                                     (double)fVar11);

      FUN_00480980(&local_20,0,L"%.1f%s, %.1f%s",(double)fVar11);

    }

    FUN_0046a740(&local_20);

    FUN_004011b0();

  }

  puStack_24 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_004990c0(*(int *)(param_1 + 0x5fc) + 8 + iVar9,iVar2,&puStack_24);

  FUN_0046a740(&puStack_24);

  if (*(int *)(iVar2 + 0xcc) != 0) {

    iVar5 = FUN_00497d70(*(int *)(iVar2 + 0xcc),&local_2c,&local_28);

    if (iVar5 == 0) {

      FUN_00402730(L"Indoors");

    }

    else {

      dStack_10 = (double)(local_2c + -0x400) * _DAT_007a7e00 + _DAT_00799088;

      local_20 = (double)(local_28 + -0x400) * _DAT_007a7e00 + _DAT_00799088;

      if (_DAT_00795610 <= dStack_10) {

        puVar6 = &DAT_007a75f4;

        if (dStack_10 <= _DAT_00795610) {

          puVar6 = &DAT_00795320;

        }

      }

      else {

        puVar6 = &DAT_007a75f8;

      }

      if (_DAT_00795610 <= local_20) {

        puVar8 = &DAT_007a75ec;

        if (local_20 <= _DAT_00795610) {

          puVar8 = &DAT_00795320;

        }

      }

      else {

        puVar8 = &DAT_007a75f0;

      }

      fVar11 = (float10)FUN_00494ca0(dStack_10,puVar6);

      fVar11 = (float10)FUN_00494ca0(local_20._0_4_,(int)((ulonglong)local_20 >> 0x20),puVar8,

                                     (double)fVar11);

      FUN_00480980(&local_20,0,L"%.1f%s, %.1f%s",(double)fVar11);

    }

    FUN_0046a740(&local_20);

    FUN_004011b0();

  }

  if (*(int *)(*(int *)(iVar2 + 0x30) + 8) == 1) {

    FUN_00402730(L"None");

  }

  else {

    dStack_10 = *(double *)(*(int *)(param_1 + 0x5fc) + iVar9 + 0x18) -

                (_DAT_008379a8 - *(double *)(*(int *)(param_1 + 0x5fc) + 0x28 + iVar9));

    if (_DAT_00795610 < dStack_10) {

      FUN_00401a60();

      iVar2 = FUN_005df4c4(&local_28);

      local_20 = (double)CONCAT44(local_20._4_4_,iVar2);

      FUN_00566bb0((double)iVar2);

      FUN_0046a740(&local_28);

      goto LAB_00499998;

    }

    FUN_00402730(L"Finished");

  }

  FUN_0046a740(&local_20);

LAB_00499998:

  FUN_004011b0();

  puVar7 = (undefined4 *)(puStack_24 + -0x14);

  LVar4 = InterlockedDecrement((LONG *)(puStack_24 + -0x10));

  if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  (**(code **)(*local_14 + 0x14))();

  return;

}





// --- FUN_004999d0 at 0x004999D0 (size: 318) ---


void FUN_004999d0(undefined *param_1)



{

  undefined *puVar1;

  undefined *puVar2;

  int *piVar3;

  int iVar4;

  int *piVar5;

  int iVar6;

  LONG LVar7;

  undefined4 *puVar8;

  

  piVar3 = (int *)FUN_00415730(0x17,2,0x10000010);

  puVar2 = param_1;

  if (piVar3 != (int *)0x0) {

    iVar4 = FUN_00497fa0(*(undefined4 *)(param_1 + 0x10));

    puVar1 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_0046f2c0(0x100005d7,0);

    piVar5 = (int *)FUN_00463c00(0x100005d1);

    if ((piVar5 != (int *)0x0) && (iVar6 = (**(code **)(*piVar5 + 0x94))(0xc), iVar6 != 0)) {

      FUN_0046a740(puVar2);

    }

    if (((iVar4 != 0) && (piVar5 = (int *)FUN_00463c00(0x100005d2), piVar5 != (int *)0x0)) &&

       (iVar6 = (**(code **)(*piVar5 + 0x94))(0xc), iVar6 != 0)) {

      param_1 = PTR_DAT_00818340;

      InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

      FUN_004990c0(puVar2 + 8,iVar4,&param_1);

      FUN_0046a740(&param_1);

      puVar8 = (undefined4 *)(param_1 + -0x14);

      LVar7 = InterlockedDecrement((LONG *)(param_1 + -0x10));

      if ((LVar7 == 0) && (puVar8 != (undefined4 *)0x0)) {

        (**(code **)*puVar8)(1);

      }

    }

    puVar8 = (undefined4 *)(puVar1 + -0x14);

    LVar7 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar7 == 0) && (puVar8 != (undefined4 *)0x0)) {

      (**(code **)*puVar8)(1);

    }

    (**(code **)(*piVar3 + 0x14))();

  }

  return;

}





// --- FUN_00499b10 at 0x00499B10 (size: 502) ---


void __fastcall FUN_00499b10(int param_1)



{

  uint uVar1;

  uint uVar2;

  uint *puVar3;

  int *piVar4;

  int *piVar5;

  LONG LVar6;

  int iVar7;

  int iVar8;

  undefined4 *puVar9;

  undefined *local_c;

  uint local_8;

  int *local_4;

  

  if ((*(int *)(*(int *)(param_1 + 0x608) + 0x610) ==

       (*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc)) / 0x30) &&

     (local_4 = (int *)FUN_00415730(0x17,2,0x10000010), local_4 != (int *)0x0)) {

    iVar7 = *(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc);

    iVar8 = iVar7 >> 0x1f;

    local_8 = 0;

    if (iVar7 / 0x30 + iVar8 != iVar8) {

      iVar8 = 0;

      do {

        piVar5 = local_4;

        local_c = (undefined *)FUN_0046dc50(local_8);

        piVar4 = (int *)FUN_00463c00(0x100005d1);

        if ((piVar4 != (int *)0x0) && (iVar7 = (**(code **)(*piVar4 + 0x94))(0xc), iVar7 != 0)) {

          FUN_0046a740(*(int *)(param_1 + 0x5fc) + iVar8);

        }

        uVar1 = piVar5[0x11];

        uVar2 = *(uint *)(iVar8 + 0x10 + *(int *)(param_1 + 0x5fc));

        if ((uVar1 != 0) && (iVar7 = piVar5[0x10], iVar7 != 0)) {

          for (puVar3 = *(uint **)(iVar7 + (uVar2 % uVar1) * 4); puVar3 != (uint *)0x0;

              puVar3 = (uint *)puVar3[0x45]) {

            if (uVar2 == *puVar3) {

              if (((puVar3 + 1 != (uint *)0x0) &&

                  (piVar5 = (int *)FUN_00463c00(0x100005d2), piVar5 != (int *)0x0)) &&

                 (iVar7 = (**(code **)(*piVar5 + 0x94))(0xc), iVar7 != 0)) {

                local_c = PTR_DAT_00818340;

                InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

                FUN_004990c0(iVar8 + 8 + *(int *)(param_1 + 0x5fc),puVar3 + 1,&local_c);

                FUN_00402070(&local_c);

                FUN_0046a740(&local_c);

                puVar9 = (undefined4 *)(local_c + -0x14);

                LVar6 = InterlockedDecrement((LONG *)(local_c + -0x10));

                if ((LVar6 == 0) && (puVar9 != (undefined4 *)0x0)) {

                  (**(code **)*puVar9)(1);

                }

              }

              break;

            }

          }

        }

        local_8 = local_8 + 1;

        iVar8 = iVar8 + 0x30;

      } while (local_8 < (uint)((*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc)) / 0x30));

    }

    piVar5 = local_4;

    FUN_004994e0();

    (**(code **)(*piVar5 + 0x14))();

  }

  return;

}





// --- FUN_00499d10 at 0x00499D10 (size: 341) ---


void __thiscall

FUN_00499d10(uint *param_1,uint param_2,undefined4 param_3,undefined4 param_4,uint param_5,

            char param_6)



{

  uint *puVar1;

  uint uVar2;

  uint uVar3;

  uint local_8;

  int local_4;

  

  local_8 = (int)(param_1[1] - *param_1) / 0x30;

  puVar1 = &param_5;

  if (param_5 <= local_8) {

    puVar1 = &local_8;

  }

  local_4 = *puVar1 + local_8;

  if (local_4 == 0) {

    local_8 = 0;

  }

  else if ((uint)(local_4 * 0x30) < 0x81) {

    local_8 = FUN_004050d0(local_4 * 0x30);

  }

  else {

    local_8 = FUN_005df0f5();

  }

  uVar2 = local_8;

  for (uVar3 = *param_1; uVar3 != param_2; uVar3 = uVar3 + 0x30) {

    if (uVar2 != 0) {

      FUN_00497fe0(uVar3);

    }

    uVar2 = uVar2 + 0x30;

  }

  uVar3 = param_5;

  if (param_5 == 1) {

    if (uVar2 != 0) {

      FUN_00497fe0(param_3);

    }

    uVar2 = uVar2 + 0x30;

  }

  else {

    for (; uVar3 != 0; uVar3 = uVar3 - 1) {

      if (uVar2 != 0) {

        FUN_00497fe0(param_3);

      }

      uVar2 = uVar2 + 0x30;

    }

  }

  if (param_6 == '\0') {

    uVar2 = FUN_00498310(param_2,param_1[1],uVar2,&param_6);

  }

  FUN_004988e0(*param_1,param_1[1],&param_6);

  uVar3 = *param_1;

  if (uVar3 != 0) {

    FUN_004051c0(uVar3,((int)(param_1[2] - uVar3) / 0x30) * 0x30);

  }

  param_1[1] = uVar2;

  *param_1 = local_8;

  param_1[2] = local_4 * 0x30 + local_8;

  return;

}





// --- FUN_00499e70 at 0x00499E70 (size: 92) ---


void FUN_00499e70(int param_1,int param_2,undefined4 param_3)



{

  if (0x10 < (param_2 - param_1) / 0x30) {

    FUN_004992a0(param_1,param_1 + 0x300,param_3);

    FUN_00498950(param_1 + 0x300,param_2,0,param_3);

    return;

  }

  FUN_004992a0(param_1,param_2,param_3);

  return;

}





// --- FUN_00499ed0 at 0x00499ED0 (size: 111) ---


void FUN_00499ed0(undefined4 param_1,uint param_2,uint param_3,undefined4 param_4,code *param_5)



{

  char cVar1;

  uint uVar2;

  

  FUN_00498fa0(param_1,param_2,param_5,0,0);

  for (uVar2 = param_2; uVar2 < param_3; uVar2 = uVar2 + 0x30) {

    cVar1 = (*param_5)(uVar2,param_1);

    if (cVar1 != '\0') {

      FUN_00497fe0(uVar2);

      FUN_00498f00(param_1,param_2,uVar2);

    }

  }

  FUN_004992f0(param_1,param_2,param_5);

  return;

}





// --- FUN_00499f40 at 0x00499F40 (size: 30) ---


void * __thiscall FUN_00499f40(void *param_1,byte param_2)



{

  FUN_00499410();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00499f60 at 0x00499F60 (size: 19) ---


void FUN_00499f60(void)



{

  FUN_00460270(0x1000004b,&LAB_004994b0);

  return;

}





// --- FUN_00499f80 at 0x00499F80 (size: 199) ---


void __fastcall FUN_00499f80(int param_1)



{

  uint uVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  uint uVar5;

  

  iVar4 = *(int *)(param_1 + 0x608);

  uVar1 = 0;

  if (*(uint *)(iVar4 + 0x610) != 0) {

    piVar3 = *(int **)(iVar4 + 0x608);

    do {

      if (*piVar3 == *(int *)(iVar4 + 0x614)) goto LAB_00499fb7;

      uVar1 = uVar1 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar1 < *(uint *)(iVar4 + 0x610));

  }

  uVar1 = 0xffffffff;

LAB_00499fb7:

  FUN_0046e460();

  FUN_0046dc70(0,1);

  iVar2 = *(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc);

  iVar4 = iVar2 >> 0x1f;

  uVar5 = 0;

  if (iVar2 / 0x30 + iVar4 != iVar4) {

    iVar4 = 0;

    do {

      FUN_004999d0(*(int *)(param_1 + 0x5fc) + iVar4);

      uVar5 = uVar5 + 1;

      iVar4 = iVar4 + 0x30;

    } while (uVar5 < (uint)((*(int *)(param_1 + 0x600) - *(int *)(param_1 + 0x5fc)) / 0x30));

  }

  FUN_0046ef60(uVar1,1);

  FUN_004994e0();

  return;

}





// --- FUN_0049a050 at 0x0049A050 (size: 234) ---


int __thiscall FUN_0049a050(int *param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  undefined1 local_30 [48];

  

  iVar1 = param_1[1];

  iVar2 = (param_2 - *param_1) / 0x30;

  if (iVar1 == param_1[2]) {

    FUN_00499d10(param_2,param_3,&param_3,1,0);

    return iVar2 * 0x30 + *param_1;

  }

  if (param_2 == iVar1) {

    if (iVar1 != 0) {

      FUN_00497fe0(param_3);

    }

    param_1[1] = param_1[1] + 0x30;

    return iVar2 * 0x30 + *param_1;

  }

  if (iVar1 != 0) {

    FUN_00497fe0(iVar1 + -0x30);

  }

  param_1[1] = param_1[1] + 0x30;

  FUN_00497fe0(param_3);

  FUN_00498340(param_2,param_1[1] + -0x60,param_1[1] + -0x30,&param_3,0);

  FUN_00498090(local_30);

  FUN_00497df0();

  return iVar2 * 0x30 + *param_1;

}





// --- FUN_0049a190 at 0x0049A190 (size: 573) ---


void __fastcall FUN_0049a190(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int *piVar4;

  undefined4 *puVar5;

  LONG LVar6;

  undefined1 local_8d;

  undefined *local_8c;

  int *local_88;

  undefined **local_84;

  void *local_7c;

  undefined4 local_78;

  int local_74;

  int local_70;

  int local_6c;

  undefined1 local_68 [4];

  int local_64;

  undefined1 local_58 [4];

  undefined *puStack_54;

  undefined **local_28 [2];

  undefined4 local_20;

  

  local_70 = param_1;

  uVar2 = FUN_00498390(*(undefined4 *)(param_1 + 0x600),*(undefined4 *)(param_1 + 0x600),

                       *(undefined4 *)(param_1 + 0x5fc),&local_8d,0);

  FUN_004988e0(uVar2,*(undefined4 *)(param_1 + 0x600),&local_8d);

  *(undefined4 *)(param_1 + 0x600) = uVar2;

  iVar3 = FUN_0055e1d0();

  if ((iVar3 != 0) && (piVar4 = (int *)FUN_00415730(0x17,2,0x10000010), piVar4 != (int *)0x0)) {

    local_84 = &PTR_FUN_007a7980;

    local_7c = (void *)0x0;

    local_78 = 0;

    local_74 = 0;

    local_88 = piVar4;

    FUN_00498860(iVar3 + 0x2ec);

    if (local_74 == 0) {

      FUN_004985c0();

      (**(code **)(*piVar4 + 0x14))();

      return;

    }

    FUN_00497ef0(local_68);

    while (local_64 != 0) {

      FUN_0059a130(local_64 + 8);

      iVar3 = FUN_00497fa0(local_20);

      FUN_00497e40();

      FUN_0059a0c0(local_28);

      puVar5 = (undefined4 *)FUN_00404a40(0,*(int *)(iVar3 + 0xc) + 0x14);

      FUN_004027b0(local_58,&DAT_00799070,*puVar5);

      puVar5 = (undefined4 *)(local_6c + -0x14);

      LVar6 = InterlockedDecrement((LONG *)(local_6c + -0x10));

      if ((LVar6 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      local_8c = PTR_DAT_00818340;

      InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

      iVar1 = local_70;

      FUN_004990c0(local_28,iVar3,&local_8c);

      if (puStack_54 != local_8c) {

        puVar5 = (undefined4 *)(puStack_54 + -0x14);

        LVar6 = InterlockedDecrement((LONG *)(puStack_54 + -0x10));

        if ((LVar6 == 0) && (puVar5 != (undefined4 *)0x0)) {

          (**(code **)*puVar5)(1);

        }

        puStack_54 = local_8c;

        InterlockedIncrement((LONG *)(local_8c + -0x10));

      }

      FUN_0049a050(*(undefined4 *)(iVar1 + 0x600),local_58);

      puVar5 = (undefined4 *)(local_8c + -0x14);

      LVar6 = InterlockedDecrement((LONG *)(local_8c + -0x10));

      if ((LVar6 == 0) && (puVar5 != (undefined4 *)0x0)) {

        (**(code **)*puVar5)(1);

      }

      FUN_00497df0();

      local_28[0] = &PTR_FUN_0079385c;

      FUN_00497f50();

      piVar4 = local_88;

    }

    local_84 = &PTR_FUN_007a7980;

    FUN_005d1400();

    if (local_7c != (void *)0x0) {

      operator_delete__(local_7c);

    }

    (**(code **)(*piVar4 + 0x14))();

  }

  return;

}





// --- FUN_0049a3d0 at 0x0049A3D0 (size: 270) ---


void FUN_0049a3d0(int param_1,int param_2,undefined4 param_3,int param_4,code *param_5)



{

  char cVar1;

  int iVar2;

  int iVar3;

  

  if (0x10 < (param_2 - param_1) / 0x30) {

    while (param_4 != 0) {

      param_4 = param_4 + -1;

      iVar2 = ((param_2 - param_1) / 0x60) * 0x30 + param_1;

      cVar1 = (*param_5)(param_1,iVar2);

      if (cVar1 == '\0') {

        cVar1 = (*param_5)(param_1,param_2 + -0x30);

        iVar3 = param_1;

        if ((cVar1 == '\0') &&

           (cVar1 = (*param_5)(iVar2,param_2 + -0x30), iVar3 = iVar2, cVar1 != '\0')) {

          iVar3 = param_2 + -0x30;

        }

      }

      else {

        cVar1 = (*param_5)(iVar2,param_2 + -0x30);

        iVar3 = iVar2;

        if (cVar1 == '\0') {

          cVar1 = (*param_5)(param_1,param_2 + -0x30);

          iVar3 = param_2 + -0x30;

          if (cVar1 == '\0') {

            iVar3 = param_1;

          }

        }

      }

      FUN_00497fe0(iVar3);

      iVar2 = FUN_00498e80(param_1,param_2);

      FUN_0049a3d0(iVar2,param_2,0,param_4,param_5);

      param_2 = iVar2;

      if ((iVar2 - param_1) / 0x30 < 0x11) {

        return;

      }

    }

    FUN_00499ed0(param_1,param_2,param_2,0,param_5);

  }

  return;

}





// --- FUN_0049a4e0 at 0x0049A4E0 (size: 90) ---


void FUN_0049a4e0(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int iVar2;

  

  if (param_1 != param_2) {

    iVar1 = 0;

    for (iVar2 = (param_2 - param_1) / 0x30; iVar2 != 1; iVar2 = iVar2 >> 1) {

      iVar1 = iVar1 + 1;

    }

    FUN_0049a3d0(param_1,param_2,0,iVar1 * 2,param_3);

    FUN_00499e70(param_1,param_2,param_3);

  }

  return;

}





// --- FUN_0049a540 at 0x0049A540 (size: 260) ---


void __fastcall FUN_0049a540(int param_1)



{

  FUN_00499f80();

  if (*(int *)(param_1 + 0x624) == 0) {

    if (*(char *)(param_1 + 0x628) != '\0') {

      FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00496130);

      FUN_00499f80();

      return;

    }

    FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00495ef0);

    FUN_00499f80();

    return;

  }

  if (*(int *)(param_1 + 0x624) != 1) {

    if (*(char *)(param_1 + 0x628) != '\0') {

      FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00496130);

      FUN_00499f80();

      return;

    }

    FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),FUN_00495ef0);

    FUN_00499f80();

    return;

  }

  if (*(char *)(param_1 + 0x628) != '\0') {

    FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00498c80);

    FUN_00499f80();

    return;

  }

  FUN_0049a4e0(*(undefined4 *)(param_1 + 0x5fc),*(undefined4 *)(param_1 + 0x600),&LAB_00498a80);

  FUN_00499f80();

  return;

}





// --- FUN_0049a7b0 at 0x0049A7B0 (size: 37) ---


void FUN_0049a7b0(undefined4 param_1)



{

  FUN_00463830(param_1);

  if ((char)param_1 != '\0') {

    FUN_0049a190();

    FUN_0049a540();

  }

  return;

}





// --- FUN_0049a7e0 at 0x0049A7E0 (size: 140) ---


void __fastcall FUN_0049a7e0(int param_1)



{

  uint uVar1;

  int iVar2;

  int *piVar3;

  int local_4;

  

  iVar2 = *(int *)(param_1 + 0x604);

  uVar1 = 0;

  if (*(uint *)(iVar2 + 0x610) != 0) {

    piVar3 = *(int **)(iVar2 + 0x608);

    do {

      if (*piVar3 == *(int *)(iVar2 + 0x614)) goto LAB_0049a813;

      uVar1 = uVar1 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar1 < *(uint *)(iVar2 + 0x610));

  }

  uVar1 = 0xffffffff;

LAB_0049a813:

  local_4 = param_1;

  iVar2 = FUN_0046dc50(uVar1);

  if (iVar2 != 0) {

    local_4 = 0;

    FUN_00460990(0x1000008e,&local_4);

    if (local_4 != *(int *)(param_1 + 0x60c)) {

      (**(code **)(**(int **)(param_1 + 0x600) + 0x9c))(1);

      return;

    }

  }

  (**(code **)(**(int **)(param_1 + 0x600) + 0x9c))(0xd);

  return;

}





// --- FUN_0049a870 at 0x0049A870 (size: 126) ---


undefined4 __thiscall FUN_0049a870(int param_1,int param_2,undefined4 *param_3)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar1 == (undefined4 *)0x0) {

    return 0;

  }

  *puVar1 = *param_3;

  puVar1[1] = 0;

  puVar1[2] = 0;

  if (*(int *)(param_1 + 4) == 0) {

    *(undefined4 **)(param_1 + 4) = puVar1;

    *(undefined4 **)(param_1 + 8) = puVar1;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return 1;

  }

  puVar1[1] = param_2;

  puVar1[2] = *(undefined4 *)(param_2 + 8);

  if (*(int *)(param_2 + 8) != 0) {

    *(undefined4 **)(*(int *)(param_2 + 8) + 4) = puVar1;

    *(undefined4 **)(param_2 + 8) = puVar1;

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

    return 1;

  }

  *(undefined4 **)(param_1 + 4) = puVar1;

  *(undefined4 **)(param_2 + 8) = puVar1;

  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;

  return 1;

}





// --- FUN_0049a8f0 at 0x0049A8F0 (size: 182) ---


void __fastcall FUN_0049a8f0(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  

  FUN_004639a0();

  piVar1 = (int *)FUN_00463c00(0x1000052f);

  if (piVar1 == (int *)0x0) {

    uVar2 = 0;

  }

  else {

    uVar2 = (**(code **)(*piVar1 + 0x94))(0xc);

  }

  *(undefined4 *)(param_1 + 0x5fc) = uVar2;

  piVar1 = (int *)FUN_00463c00(0x10000535);

  if (piVar1 == (int *)0x0) {

    uVar2 = 0;

  }

  else {

    uVar2 = (**(code **)(*piVar1 + 0x94))(1);

  }

  *(undefined4 *)(param_1 + 0x600) = uVar2;

  piVar1 = (int *)FUN_00463c00(0x10000532);

  if (piVar1 == (int *)0x0) {

    uVar2 = 0;

  }

  else {

    uVar2 = (**(code **)(*piVar1 + 0x94))(5);

  }

  *(undefined4 *)(param_1 + 0x604) = uVar2;

  piVar1 = (int *)FUN_0043c680();

  if (piVar1 != (int *)0x0) {

    param_1 = param_1 + 0x5f8;

    (**(code **)(*piVar1 + 4))(0x4dd277,param_1);

    (**(code **)(*piVar1 + 4))(0x4dd279,param_1);

    (**(code **)(*piVar1 + 4))(0x4dd278,param_1);

  }

  return;

}





// --- FUN_0049a9b0 at 0x0049A9B0 (size: 130) ---


void FUN_0049a9b0(int *param_1)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  

  piVar1 = param_1;

  iVar3 = param_1[2];

  if (iVar3 == 1) {

    if (*param_1 == 0x10000535) {

      uVar2 = FUN_0046cf60();

      iVar3 = FUN_0046dc50(uVar2);

      if (iVar3 != 0) {

        param_1 = (int *)0x0;

        FUN_00460990(0x1000008e,&param_1);

        FUN_006a6680(param_1);

      }

    }

  }

  else if ((iVar3 == 4) || (iVar3 == 0x43)) {

    FUN_0049a7e0();

    FUN_00462420(piVar1);

    return;

  }

  FUN_00462420(piVar1);

  return;

}





// --- FUN_0049aa40 at 0x0049AA40 (size: 216) ---


int __thiscall FUN_0049aa40(int param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  int iVar5;

  LONG LVar6;

  int local_8;

  

  puVar1 = param_2;

  local_8 = 0;

  if (0 < *(int *)(*(int *)(param_1 + 0x604) + 0x610)) {

    do {

      iVar2 = FUN_0046dc50(local_8);

      if (iVar2 != 0) {

        piVar3 = (int *)FUN_00463c00(0x10000537);

        if (piVar3 != (int *)0x0) {

          (**(code **)(*piVar3 + 0x94))(0xc);

        }

        puVar4 = (undefined4 *)FUN_00466830(&param_2);

        iVar5 = wcscmp((wchar_t *)*puVar1,(wchar_t *)*puVar4);

        puVar4 = param_2 + -5;

        LVar6 = InterlockedDecrement(param_2 + -4);

        if ((LVar6 == 0) && (puVar4 != (undefined4 *)0x0)) {

          (**(code **)*puVar4)(1);

        }

        if (iVar5 < 0) {

          return iVar2;

        }

      }

      local_8 = local_8 + 1;

    } while (local_8 < *(int *)(*(int *)(param_1 + 0x604) + 0x610));

  }

  return 0;

}





// --- FUN_0049ab20 at 0x0049AB20 (size: 218) ---


undefined4 FUN_0049ab20(undefined *param_1)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  int *piVar4;

  LONG LVar5;

  undefined4 *puVar6;

  

  iVar1 = (int)param_1;

  if (param_1 != (undefined *)0x0) {

    param_1 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    iVar2 = FUN_005c7eb0(iVar1,&param_1);

    if (iVar2 != 0) {

      uVar3 = FUN_0049aa40(&param_1);

      FUN_0046f670(0,uVar3);

      piVar4 = (int *)FUN_00463c00(0x10000537);

      if (piVar4 != (int *)0x0) {

        iVar2 = (**(code **)(*piVar4 + 0x94))(0xc);

        if (iVar2 != 0) {

          FUN_0046a740(&param_1);

          FUN_00460470(0x1000008e,iVar1);

          puVar6 = (undefined4 *)(param_1 + -0x14);

          LVar5 = InterlockedDecrement((LONG *)(param_1 + -0x10));

          if ((LVar5 == 0) && (puVar6 != (undefined4 *)0x0)) {

            (**(code **)*puVar6)(1);

          }

          return 1;

        }

      }

    }

    puVar6 = (undefined4 *)(param_1 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_1 + -0x10));

    if ((LVar5 == 0) && (puVar6 != (undefined4 *)0x0)) {

      (**(code **)*puVar6)(1);

    }

  }

  return 0;

}





// --- FUN_0049ac00 at 0x0049AC00 (size: 67) ---


void __thiscall FUN_0049ac00(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  

  iVar2 = param_2;

  piVar1 = *(int **)(param_1 + 0x1c);

  while( true ) {

    if (piVar1 == (int *)0x0) {

      iVar3 = FUN_0049a870(*(int **)(param_1 + 0x1c),&param_2);

      if (iVar3 != 0) {

        FUN_0049ab20(iVar2);

      }

      return;

    }

    if (*piVar1 == param_2) break;

    piVar1 = (int *)piVar1[1];

  }

  return;

}





// --- FUN_0049ac50 at 0x0049AC50 (size: 45) ---


void __fastcall FUN_0049ac50(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007a7fe4;

  param_1[6] = &PTR_LAB_007a5164;

  param_1[6] = &PTR_FUN_0079385c;

  param_1[2] = &PTR_FUN_007a5160;

  FUN_0049f850();

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0049ac80 at 0x0049AC80 (size: 65) ---


undefined4 * __thiscall FUN_0049ac80(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007a7fe4;

  param_1[6] = &PTR_LAB_007a5164;

  param_1[6] = &PTR_FUN_0079385c;

  param_1[2] = &PTR_FUN_007a5160;

  FUN_0049f850();

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049acd0 at 0x0049ACD0 (size: 77) ---


undefined4 * __thiscall FUN_0049acd0(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_007a82a0;

  param_1[0x17e] = &PTR_FUN_007a7ff8;

  param_1[0x180] = 0;

  param_1[0x181] = 0;

  FUN_005c7fc0();

  return param_1;

}





// --- FUN_0049ad50 at 0x0049AD50 (size: 112) ---


void __fastcall FUN_0049ad50(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x17e;

  *param_1 = &PTR_FUN_007a82a0;

  *puVar1 = &PTR_FUN_007a7ff8;

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

  param_1[0x182] = &PTR_FUN_007a7fe4;

  param_1[0x188] = &PTR_LAB_007a5164;

  param_1[0x188] = &PTR_FUN_0079385c;

  param_1[0x184] = &PTR_FUN_007a5160;

  FUN_0049f850();

  param_1[0x182] = &PTR_FUN_0079385c;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004726c0();

  return;

}





// --- FUN_0049adf0 at 0x0049ADF0 (size: 30) ---


void * __thiscall FUN_0049adf0(void *param_1,byte param_2)



{

  FUN_0049ad50();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049ae10 at 0x0049AE10 (size: 19) ---


void FUN_0049ae10(void)



{

  FUN_00460270(0x10000046,&LAB_0049adc0);

  return;

}





// --- FUN_0049ae30 at 0x0049AE30 (size: 356) ---


undefined4 __fastcall FUN_0049ae30(int param_1)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  int iVar3;

  LONG LVar4;

  undefined4 *puVar5;

  bool bVar6;

  undefined *local_1c;

  int local_18;

  undefined **ppuStack_14;

  undefined4 *puStack_10;

  undefined4 uStack_c;

  int iStack_8;

  undefined **ppuStack_4;

  

  local_1c = PTR_DAT_00818340;

  uVar1 = *(undefined4 *)(param_1 + 0x60c);

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  iVar3 = FUN_005c7eb0(uVar1,&local_1c);

  if (iVar3 == 0) {

    FUN_00402730(L"Unknown");

    FUN_0046a740(&local_18);

    LVar4 = InterlockedDecrement((LONG *)(local_18 + -0x10));

    if ((LVar4 == 0) && ((undefined4 *)(local_18 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_18 + -0x14))(1);

    }

  }

  else {

    FUN_0046a740(&local_1c);

  }

  FUN_0046e460();

  FUN_0046dc70(0,1);

  ppuStack_14 = &PTR_FUN_007a5160;

  puStack_10 = (undefined4 *)0x0;

  uStack_c = 0;

  iStack_8 = 0;

  FUN_004db900(param_1 + 0x610);

  ppuStack_14 = &PTR_FUN_007a83d8;

  ppuStack_4 = &PTR_LAB_007a5164;

  for (puVar5 = puStack_10; puVar5 != (undefined4 *)0x0; puVar5 = (undefined4 *)puVar5[1]) {

    FUN_0049ab20(*puVar5);

  }

  FUN_0049a7e0();

  ppuStack_4 = &PTR_FUN_0079385c;

  ppuStack_14 = &PTR_FUN_007a5160;

  while (puVar5 = puStack_10, puStack_10 != (undefined4 *)0x0) {

    puVar2 = (undefined4 *)puStack_10[1];

    if (puVar2 == (undefined4 *)0x0) {

      uStack_c = 0;

    }

    else {

      puVar2[2] = 0;

    }

    bVar6 = puStack_10 != (undefined4 *)0x0;

    puStack_10 = puVar2;

    if (bVar6) {

      operator_delete(puVar5);

    }

    iStack_8 = iStack_8 + -1;

  }

  puVar5 = (undefined4 *)(local_1c + -0x14);

  LVar4 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

  return 1;

}





// --- FUN_0049b020 at 0x0049B020 (size: 32) ---


void __fastcall FUN_0049b020(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007a8458;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  return;

}





// --- FUN_0049b040 at 0x0049B040 (size: 72) ---


undefined4 * __thiscall FUN_0049b040(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_004f1080(param_2,param_3);

  *param_1 = &PTR_FUN_007a8718;

  param_1[0x17e] = &PTR_FUN_007a8470;

  param_1[0x17f] = &PTR_LAB_007c4b0c;

  param_1[399] = 0;

  param_1[400] = 0xffffffff;

  return param_1;

}





// --- FUN_0049b0c0 at 0x0049B0C0 (size: 55) ---


void __fastcall FUN_0049b0c0(int param_1)



{

  int *piVar1;

  

  FUN_004f0a20();

  piVar1 = (int *)FUN_0043c680();

  if (param_1 != 0) {

    (**(code **)(*piVar1 + 4))(0x4dd241,param_1 + 0x5f8);

    return;

  }

  (**(code **)(*piVar1 + 4))(0x4dd241,0);

  return;

}





// --- FUN_0049b250 at 0x0049B250 (size: 56) ---


undefined4 * __thiscall FUN_0049b250(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007a8718;

  param_1[0x17e] = &PTR_FUN_007a8470;

  param_1[0x17f] = &PTR_LAB_007c4b0c;

  FUN_004f1270();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049b290 at 0x0049B290 (size: 19) ---


void FUN_0049b290(void)



{

  FUN_00460270(0x1000002b,&LAB_0049b100);

  return;

}





// --- FUN_0049b380 at 0x0049B380 (size: 567) ---


undefined4 FUN_0049b380(void)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  int local_a0;

  undefined4 uStack_9c;

  undefined4 uStack_98;

  undefined4 uStack_94;

  

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f494,0x10000001);

  uVar5 = 0;

  uVar4 = 0;

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0e00(uVar1,uVar4,uVar5);

  FUN_0046a790(uVar1,uVar4,uVar5);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  FUN_0042c9c0(DAT_0083f498,0x10000001);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0e50(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  uStack_9c = 0;

  FUN_00590c20(0x18,&uStack_9c,0,0);

  FUN_0042c9c0(DAT_0083f49c,0x10000001);

  FUN_0042e000(DAT_0083f4bc,uStack_9c,0);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0ea0(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  FUN_0042c9c0(DAT_0083f4a0,0x10000001);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0f40(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  uStack_98 = 0;

  uStack_94 = 0;

  FUN_00590c70(2,&uStack_98);

  FUN_0042c9c0(DAT_0083f4a4,0x10000001);

  FUN_0042e000(DAT_0083f4b8,uStack_98,uStack_94);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0f90(uVar1);

  FUN_0046a740(uVar1);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && ((undefined4 *)(local_a0 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_a0 + -0x14))(1);

  }

  FUN_0042e590();

  return 1;

}





// --- FUN_0049b5c0 at 0x0049B5C0 (size: 616) ---


undefined4 __thiscall FUN_0049b5c0(int *param_1,undefined4 param_2)



{

  LONG LVar1;

  uint uVar2;

  int *piVar3;

  int unaff_EBX;

  int unaff_EBP;

  undefined4 *puVar4;

  undefined **ppuVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  uint local_9c;

  undefined *local_98 [38];

  

  local_98[0] = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_005c9920(param_1[399],local_98);

  uVar7 = 0;

  uVar6 = 0;

  ppuVar5 = local_98;

  FUN_004f0e00(ppuVar5,0,0);

  FUN_0046a790(ppuVar5,uVar6,uVar7);

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f4b0,0x10000001);

  uVar6 = FUN_0042e980(&local_9c,0);

  FUN_004f0e50(uVar6);

  FUN_0046a740(uVar6);

  puVar4 = (undefined4 *)(local_9c - 0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_9c - 0x10));

  if ((LVar1 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  uVar2 = (**(code **)(*param_1 + 0x15c))(param_2);

  FUN_0042c9c0(DAT_0083f4b4,0x10000001);

  FUN_0042e000(DAT_0083f4c4,uVar2,0);

  uVar6 = FUN_0042e980(&stack0xffffff60,0);

  FUN_004f0ea0(uVar6);

  FUN_0046a740(uVar6);

  LVar1 = InterlockedDecrement((LONG *)(unaff_EBX + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(unaff_EBX + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EBX + -0x14))(1);

  }

  FUN_0042c9c0(DAT_0083f498,0x10000001);

  uVar6 = FUN_0042e980(&stack0xffffff60,0);

  FUN_004f0f40(uVar6);

  FUN_0046a740(uVar6);

  LVar1 = InterlockedDecrement((LONG *)(unaff_EBX + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(unaff_EBX + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EBX + -0x14))(1);

  }

  local_98[0] = (undefined *)0x0;

  FUN_00590c20(0x18,local_98,0,0);

  FUN_0042c9c0(DAT_0083f49c,0x10000001);

  FUN_0042e000(DAT_0083f4bc,local_98[0],0);

  uVar6 = FUN_0042e980(&stack0xffffff60,0);

  FUN_004f0f90(uVar6);

  FUN_0046a740(uVar6);

  LVar1 = InterlockedDecrement((LONG *)(unaff_EBX + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(unaff_EBX + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EBX + -0x14))(1);

  }

  piVar3 = (int *)FUN_004f1030();

  (**(code **)(*piVar3 + 0x18))(0);

  if ((uVar2 == 0) || (local_9c < uVar2)) {

    piVar3 = (int *)FUN_004f0fe0();

    uVar6 = 0xd;

  }

  else {

    piVar3 = (int *)FUN_004f0fe0();

    uVar6 = 1;

  }

  (**(code **)(*piVar3 + 0x9c))(uVar6);

  FUN_0042e590();

  LVar1 = InterlockedDecrement((LONG *)(unaff_EBP + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(unaff_EBP + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EBP + -0x14))(1);

  }

  return 1;

}





// --- FUN_0049b830 at 0x0049B830 (size: 87) ---


void __thiscall FUN_0049b830(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  uVar5 = 0;

  if (uVar1 != 0) {

    piVar2 = *(int **)(param_1 + 8);

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007a8880;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

  uVar3 = *(undefined4 *)(param_1 + 8);

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007a8880;

  param_2[3] = uVar1;

  return;

}





// --- FUN_0049b890 at 0x0049B890 (size: 22) ---


void __fastcall FUN_0049b890(int *param_1)



{

  if ((int *)*param_1 != (int *)0x0) {

    (**(code **)(*(int *)*param_1 + 0x14))();

    *param_1 = 0;

  }

  return;

}





// --- FUN_0049b8b0 at 0x0049B8B0 (size: 59) ---


uint * __thiscall FUN_0049b8b0(int param_1,uint param_2)



{

  uint *puVar1;

  

  if ((*(uint *)(param_1 + 0x44) != 0) && (*(int *)(param_1 + 0x40) != 0)) {

    for (puVar1 = *(uint **)(*(int *)(param_1 + 0x40) + (param_2 % *(uint *)(param_1 + 0x44)) * 4);

        puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[0x18]) {

      if (param_2 == *puVar1) {

        return puVar1 + 2;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_0049bad0 at 0x0049BAD0 (size: 1391) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __thiscall FUN_0049bad0(int *param_1,undefined4 param_2)



{

  float fVar1;

  int iVar2;

  LONG LVar3;

  int iVar4;

  int iVar5;

  int *piVar6;

  undefined **ppuVar7;

  code *pcVar8;

  undefined **unaff_EBP;

  undefined4 *puVar9;

  int unaff_ESI;

  int unaff_EDI;

  float fVar10;

  undefined4 uVar11;

  undefined4 uVar12;

  undefined *puStack_d4;

  undefined **ppuStack_d0;

  int iStack_cc;

  undefined4 local_c8;

  undefined *local_c4;

  undefined **ppuStack_c0;

  undefined4 uStack_bc;

  undefined *local_b8;

  undefined4 local_b4;

  int iStack_b0;

  undefined4 uStack_ac;

  undefined4 uStack_a8;

  undefined4 uStack_a4;

  undefined4 uStack_c;

  undefined4 uStack_4;

  

  local_c4 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_005c9920(param_1[399],&local_c4);

  uVar12 = 0;

  uVar11 = 0;

  ppuVar7 = &local_c4;

  FUN_004f0e00(ppuVar7,0,0);

  FUN_0046a790(ppuVar7,uVar11,uVar12);

  local_b4 = 0;

  FUN_00593380(param_1[399],&local_b4,1);

  local_c8 = 0;

  FUN_00593380(param_1[399],&local_c8,0);

  local_b8 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_004027b0(&local_b8,L"%s: %d",local_c4,local_c8);

  uVar12 = 0;

  uVar11 = 0;

  ppuVar7 = &local_b8;

  FUN_004f0e00(ppuVar7,0,0);

  FUN_0046a790(ppuVar7,uVar11,uVar12);

  iVar2 = (**(code **)(**(int **)(param_1[0x18a] + param_1[400] * 4) + 0x28))(param_2);

  if (iVar2 < 0) {

    puStack_d4 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_004027b0(&puStack_d4,L" (%d)",iVar2);

    uVar12 = 3;

    uVar11 = 0;

    ppuVar7 = &puStack_d4;

    FUN_004f0e00(ppuVar7,0,3);

    FUN_0046a000(ppuVar7,uVar11,uVar12);

    puVar9 = (undefined4 *)(puStack_d4 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(puStack_d4 + -0x10));

    if ((LVar3 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

  }

  iStack_cc = iStack_cc - iVar2;

  iVar2 = iStack_cc - (int)local_b8;

  pcVar8 = InterlockedDecrement_exref;

  if (iVar2 != 0) {

    ppuStack_d0 = (undefined **)PTR_DAT_00818340;

    uVar11 = 0;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    if ((int)local_b8 < iStack_cc) {

      uVar11 = 1;

      FUN_00407e40(&DAT_007a8894);

    }

    else if (iStack_cc < (int)local_b8) {

      uVar11 = 2;

    }

    puStack_d4 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_004027b0(&puStack_d4,L" (%s%d)",ppuStack_d0,iVar2);

    uVar12 = 0;

    ppuVar7 = &puStack_d4;

    FUN_004f0e00(ppuVar7,0,uVar11);

    FUN_0046a000(ppuVar7,uVar12,uVar11);

    pcVar8 = InterlockedDecrement_exref;

    puVar9 = (undefined4 *)(puStack_d4 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(puStack_d4 + -0x10));

    if ((LVar3 == 0) && (puVar9 != (undefined4 *)0x0)) {

      (**(code **)*puVar9)(1);

    }

    ppuVar7 = ppuStack_d0 + -5;

    LVar3 = InterlockedDecrement((LONG *)(ppuStack_d0 + -4));

    if ((LVar3 == 0) && (ppuVar7 != (undefined **)0x0)) {

      (**(code **)*ppuVar7)(1);

    }

  }

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f4a8,0x10000001);

  uVar11 = FUN_0042e980(&stack0xffffff28,0);

  FUN_004f0e50(uVar11);

  FUN_0046a740(uVar11);

  iVar4 = (*pcVar8)(iVar2 + -0x10);

  if ((iVar4 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

  }

  iVar2 = (**(code **)(*param_1 + 0x15c))(uStack_4);

  if (iVar2 == 0) {

    FUN_0042c9c0(DAT_0083f490,0x10000001);

  }

  else {

    FUN_0042c9c0(DAT_0083f4ac,0x10000001);

    FUN_0042e000(DAT_0083f4c0,iVar2,0);

  }

  uVar11 = FUN_0042e980(&stack0xffffff20,0);

  FUN_004f0ea0(uVar11);

  FUN_0046a740(uVar11);

  iVar4 = (*pcVar8)(unaff_ESI + -0x10);

  if ((iVar4 == 0) && ((undefined4 *)(unaff_ESI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_ESI + -0x14))(1);

  }

  ppuStack_c0 = &PTR_FUN_007a8458;

  uStack_bc = 0;

  local_b8 = (undefined *)0x0;

  local_b4 = 0;

  iStack_b0 = 0;

  uStack_ac = 0;

  uStack_a8 = 0;

  uStack_a4 = 0;

  FUN_00592af0(param_1[399],&ppuStack_c0);

  iVar4 = iStack_b0;

  uVar11 = uStack_bc;

  iVar5 = FUN_005c93b0(uStack_bc,iStack_b0);

  iVar4 = FUN_005c93b0(uVar11,iVar4 + 1);

  iVar4 = iVar4 - iVar5;

  if (iVar4 == 0) {

    fVar10 = 0.0;

  }

  else {

    fVar10 = (float)((int)local_b8 - iVar5);

    if ((int)local_b8 - iVar5 < 0) {

      fVar10 = fVar10 + _DAT_0079920c;

    }

    fVar1 = (float)iVar4;

    if (iVar4 < 0) {

      fVar1 = fVar1 + _DAT_0079920c;

    }

    fVar10 = fVar10 / fVar1;

    unaff_EDI = iVar4;

  }

  uVar11 = 0x69;

  FUN_004f0ef0(0x69,fVar10);

  FUN_00460760(uVar11,fVar10);

  FUN_0042c9c0(DAT_0083f4a0,0x10000001);

  uVar11 = FUN_0042e980(&stack0xffffff1c,0);

  FUN_004f0f40(uVar11);

  FUN_0046a740(uVar11);

  LVar3 = InterlockedDecrement((LONG *)(unaff_EDI + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  ppuStack_d0 = (undefined **)0x0;

  iStack_cc = 0;

  FUN_00590c70(2,&ppuStack_d0);

  FUN_0042c9c0(DAT_0083f4a4,0x10000001);

  FUN_0042e000(DAT_0083f4b8,ppuStack_d0,iStack_cc);

  uVar11 = FUN_0042e980(&stack0xffffff1c,0);

  FUN_004f0f90(uVar11);

  FUN_0046a740(uVar11);

  LVar3 = InterlockedDecrement((LONG *)(unaff_EDI + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  if ((unaff_EBP == (undefined **)0x0) || ((iStack_cc == 0 && (ppuStack_d0 < unaff_EBP)))) {

    piVar6 = (int *)FUN_004f0fe0();

    uVar11 = 0xd;

  }

  else {

    piVar6 = (int *)FUN_004f0fe0();

    uVar11 = 1;

  }

  (**(code **)(*piVar6 + 0x9c))(uVar11);

  piVar6 = (int *)FUN_004f1030();

  (**(code **)(*piVar6 + 0x18))(1);

  ppuVar7 = (undefined **)(**(code **)(*param_1 + 0x164))(uStack_c);

  if ((ppuVar7 == (undefined **)0x0) || ((iVar2 == 0 && (unaff_EBP < ppuVar7)))) {

    piVar6 = (int *)FUN_004f1030();

    uVar11 = 0xd;

  }

  else {

    piVar6 = (int *)FUN_004f1030();

    uVar11 = 1;

  }

  (**(code **)(*piVar6 + 0x9c))(uVar11);

  ppuStack_d0 = &PTR_FUN_0079385c;

  FUN_0042e590();

  LVar3 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

  }

  LVar3 = InterlockedDecrement((LONG *)(unaff_EDI + -0x10));

  if ((LVar3 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  return 1;

}





// --- FUN_0049c040 at 0x0049C040 (size: 710) ---


undefined1 __thiscall

FUN_0049c040(int param_1,undefined4 param_2,int param_3,wchar_t *param_4,uint param_5)



{

  char cVar1;

  uint uVar2;

  int *piVar3;

  int iVar4;

  LONG LVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  uint uVar8;

  undefined1 uVar9;

  wchar_t *pwVar10;

  int iVar11;

  wchar_t *local_10;

  int local_c;

  undefined4 *local_8;

  int *local_4;

  

  pwVar10 = param_4;

  local_c = 0;

  if (param_4 == (wchar_t *)0x0) {

    return 0;

  }

  local_10 = (wchar_t *)PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_005c9920(param_2,&local_10);

  iVar11 = *(int *)(param_1 + 0x624);

  uVar2 = 0;

  if (*(uint *)(iVar11 + 0x610) != 0) {

    piVar3 = *(int **)(iVar11 + 0x608);

    do {

      if ((wchar_t *)*piVar3 == pwVar10) goto LAB_0049c0af;

      uVar2 = uVar2 + 1;

      piVar3 = piVar3 + 1;

    } while (uVar2 < *(uint *)(iVar11 + 0x610));

  }

  uVar2 = 0xffffffff;

LAB_0049c0af:

  if (param_5 == 0) {

    uVar8 = *(uint *)(iVar11 + 0x610);

  }

  else {

    uVar8 = 0;

    if (*(uint *)(iVar11 + 0x610) != 0) {

      piVar3 = *(int **)(iVar11 + 0x608);

      do {

        if (*piVar3 == param_5) goto LAB_0049c0ef;

        uVar8 = uVar8 + 1;

        piVar3 = piVar3 + 1;

      } while (uVar8 < *(uint *)(iVar11 + 0x610));

    }

    uVar8 = 0xffffffff;

  }

LAB_0049c0ef:

  param_5 = uVar8;

  iVar11 = uVar2 + 1;

  if (iVar11 < (int)param_5) {

    do {

      piVar3 = (int *)FUN_0046dc50(iVar11);

      if (piVar3 != (int *)0x0) {

        local_8 = (undefined4 *)0x0;

        local_4 = (int *)0x0;

        cVar1 = (**(code **)(*piVar3 + 0xd0))(0x1000003a,&local_8);

        if (cVar1 != '\0') {

          local_c = 0;

          if (local_4 != (int *)0x0) {

            (**(code **)(*local_4 + 0x78))(&local_c);

          }

          param_4 = (wchar_t *)PTR_DAT_00818340;

          InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

          (**(code **)(**(int **)(*(int *)(param_1 + 0x628) + local_c * 4) + 0xc))(&param_4);

          iVar4 = wcscmp(local_10,param_4);

          pwVar10 = param_4 + -10;

          if (iVar4 < 0) {

            LVar5 = InterlockedDecrement((LONG *)(param_4 + -8));

            if ((LVar5 == 0) && (pwVar10 != (wchar_t *)0x0)) {

              (*(code *)**(undefined4 **)pwVar10)(1);

            }

            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 != (int *)0x0) &&

               (iVar4 = local_4[1], local_4[1] = iVar4 + -1, iVar4 + -1 == 0)) {

              (**(code **)*local_4)(1);

            }

            break;

          }

          LVar5 = InterlockedDecrement((LONG *)(param_4 + -8));

          if ((LVar5 == 0) && (pwVar10 != (wchar_t *)0x0)) {

            (*(code *)**(undefined4 **)pwVar10)(1);

          }

        }

        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 != (int *)0x0) {

          iVar4 = local_4[1];

          local_4[1] = iVar4 + -1;

          if (iVar4 + -1 == 0) {

            (**(code **)*local_4)(1);

          }

          local_4 = (int *)0x0;

        }

      }

      iVar11 = iVar11 + 1;

    } while (iVar11 < (int)param_5);

  }

  iVar4 = FUN_005df0f5(0x1c);

  if (iVar4 == 0) {

    uVar6 = 0;

  }

  else {

    uVar6 = FUN_004f2da0(*(undefined4 *)(param_1 + 0x624),iVar11,*(undefined4 *)(param_1 + 0x630),

                         param_2,*(undefined4 *)(param_3 + 0xc),1);

  }

  uVar2 = *(uint *)(param_1 + 0x62c) & 0x7fffffff;

  if (uVar2 <= *(uint *)(param_1 + 0x630)) {

    uVar7 = FUN_00453850(uVar2 + 1);

    cVar1 = FUN_004180a0(uVar7);

    if (cVar1 == '\0') {

      uVar9 = 0;

      goto LAB_0049c2d9;

    }

  }

  *(undefined4 *)(*(int *)(param_1 + 0x628) + *(int *)(param_1 + 0x630) * 4) = uVar6;

  *(int *)(param_1 + 0x630) = *(int *)(param_1 + 0x630) + 1;

  uVar9 = 1;

LAB_0049c2d9:

  pwVar10 = local_10 + -10;

  LVar5 = InterlockedDecrement((LONG *)(local_10 + -8));

  if ((LVar5 == 0) && (pwVar10 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar10)(1);

  }

  return uVar9;

}





// --- FUN_0049c610 at 0x0049C610 (size: 550) ---


undefined1 __fastcall FUN_0049c610(int *param_1)



{

  uint uVar1;

  undefined1 uVar2;

  int *piVar3;

  int *piVar4;

  undefined4 *puVar5;

  int **ppiVar6;

  undefined *puVar7;

  int **ppiVar8;

  undefined4 uVar9;

  int *piVar10;

  int *local_50;

  int *local_4c;

  int *local_48;

  int *local_44;

  int *local_40;

  undefined4 local_3c;

  undefined1 auStack_38 [4];

  undefined4 *puStack_34;

  int iStack_30;

  uint uStack_2c;

  undefined **ppuStack_28;

  int iStack_24;

  undefined4 uStack_20;

  undefined4 uStack_1c;

  undefined4 uStack_18;

  undefined4 uStack_14;

  undefined4 uStack_10;

  undefined4 uStack_c;

  

  FUN_004f11e0();

  local_48 = (int *)FUN_00415730(4,2,0x10000004);

  if (local_48 != (int *)0x0) {

    ppiVar8 = &local_50;

    ppiVar6 = &local_44;

    puVar7 = &DAT_007a8434;

    local_50 = (int *)0x0;

    FUN_00406d10(ppiVar6,&DAT_007a8434,ppiVar8);

    FUN_00406570(ppiVar6,puVar7,ppiVar8);

    piVar3 = local_50;

    uVar9 = 0;

    local_40 = (int *)0x0;

    local_3c = 0;

    piVar4 = local_50;

    if (local_50 != (int *)0x0) {

      (**(code **)(*local_50 + 0x10))(local_50,0);

    }

    local_4c = (int *)FUN_0048bb00(&local_4c,piVar4,uVar9);

    local_4c = (int *)*local_4c;

    if (piVar3 != (int *)0x0) {

      (**(code **)(*piVar3 + 0x14))();

    }

    if (local_40 != (int *)0x0) {

      if (-1 < (int)local_4c) {

        local_44 = (int *)FUN_0046f670(1,0);

        piVar3 = (int *)FUN_0046f670(2,0);

        local_50 = (int *)FUN_0046f670(3,0);

        local_4c = (int *)FUN_0046f670(4,0);

        FUN_0049b830(auStack_38);

LAB_0049c725:

        do {

          do {

            puVar5 = puStack_34;

            if (puVar5 == (undefined4 *)0x0) {

              param_1[400] = -1;

              uVar2 = (**(code **)(*param_1 + 0x138))(local_40);

              (**(code **)(*local_44 + 0x14))();

              (**(code **)(*local_4c + 0x14))();

              return uVar2;

            }

            ppuStack_28 = &PTR_FUN_007a8458;

            iStack_24 = 0;

            uStack_20 = 0;

            uStack_1c = 0;

            uStack_18 = 0;

            uStack_14 = 0;

            uStack_10 = 0;

            uStack_c = 0;

            FUN_00592af0(*puVar5,&ppuStack_28);

            if (iStack_24 == 3) {

              uVar9 = *puVar5;

              piVar4 = local_44;

              piVar10 = piVar3;

            }

            else if (iStack_24 == 2) {

              uVar9 = *puVar5;

              piVar4 = piVar3;

              piVar10 = local_50;

            }

            else {

              if ((iStack_24 != 1) || (piVar4 = local_50, piVar10 = local_4c, 1 < (int)puVar5[10]))

              {

                piVar4 = local_4c;

                piVar10 = (int *)0x0;

              }

              uVar9 = *puVar5;

            }

            FUN_0049c040(uVar9,puVar5 + 2,piVar4,piVar10);

            ppuStack_28 = &PTR_FUN_0079385c;

            puStack_34 = (undefined4 *)puVar5[0x18];

          } while ((undefined4 *)puVar5[0x18] != (undefined4 *)0x0);

          uVar1 = puVar5[0x19];

          do {

            uVar1 = uVar1 + 1;

            if (uStack_2c <= uVar1) {

              puStack_34 = (undefined4 *)0x0;

              goto LAB_0049c725;

            }

          } while (*(int *)(iStack_30 + uVar1 * 4) == 0);

          puStack_34 = *(undefined4 **)(iStack_30 + uVar1 * 4);

        } while( true );

      }

      (**(code **)(*local_40 + 0x14))();

    }

    (**(code **)(*local_48 + 0x14))();

  }

  return 0;

}





// --- FUN_0049c860 at 0x0049C860 (size: 717) ---


/* WARNING: Removing unreachable block (ram,0x0049ca95) */

/* WARNING: Removing unreachable block (ram,0x0049caa6) */

/* WARNING: Removing unreachable block (ram,0x0049caac) */

/* WARNING: Removing unreachable block (ram,0x0049ca01) */

/* WARNING: Removing unreachable block (ram,0x0049c95f) */

/* WARNING: Removing unreachable block (ram,0x0049c9aa) */

/* WARNING: Removing unreachable block (ram,0x0049ca48) */

/* WARNING: Removing unreachable block (ram,0x0049cab8) */

/* WARNING: Removing unreachable block (ram,0x0049cac9) */

/* WARNING: Removing unreachable block (ram,0x0049cacf) */



undefined4 __thiscall FUN_0049c860(int *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  LONG LVar3;

  undefined4 uVar4;

  int iStack_120;

  undefined4 *puStack_11c;

  undefined4 *local_118;

  undefined1 auStack_114 [272];

  

  if (param_1[399] != 0) {

    local_118 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_005c96c0(param_1[399],&local_118);

    uVar2 = (**(code **)(*param_1 + 0x15c))(param_2);

    local_118 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_00487620(&local_118,"Are you sure you want to spend %d credits to train %s?",uVar2,

                 puStack_11c + 5);

    FUN_0042dc80();

    uVar4 = 1;

    uVar2 = FUN_00404a40(0,local_118 + 5);

    FUN_0042cbe0(uVar2,uVar4);

    LVar3 = InterlockedDecrement((LONG *)(iStack_120 + -0x10));

    if ((LVar3 == 0) && ((undefined4 *)(iStack_120 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(iStack_120 + -0x14))(1);

    }

    FUN_006823d0();

    FUN_0042a2d0(0x8e);

    iStack_120 = FUN_00429a00();

    FUN_0042c290(&iStack_120,&stack0xfffffed8);

    FUN_0042a2d0(0xc5);

    iStack_120 = FUN_00429a00();

    FUN_0042c290(&iStack_120,&stack0xfffffed8);

    FUN_0042a2d0(0x10000040);

    iStack_120 = FUN_00429a00();

    FUN_0042c290(&iStack_120,&stack0xfffffed8);

    FUN_0042a2d0(0x10000041);

    iStack_120 = FUN_00429a00();

    FUN_0042c290(&iStack_120,&stack0xfffffed8);

    FUN_00478830(auStack_114,&LAB_0049c480);

    FUN_00681f60();

    FUN_0042e590();

    puVar1 = local_118;

    LVar3 = InterlockedDecrement(local_118 + 1);

    if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    LVar3 = InterlockedDecrement(puStack_11c + 1);

    if ((LVar3 == 0) && (puStack_11c != (undefined4 *)0x0)) {

      (**(code **)*puStack_11c)(1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_0049ccd0 at 0x0049CCD0 (size: 56) ---


undefined4 * __thiscall FUN_0049ccd0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007a8e48;

  param_1[0x17e] = &PTR_FUN_007a8ba0;

  param_1[0x17f] = &PTR_LAB_007c4b0c;

  FUN_004f1270();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049cd10 at 0x0049CD10 (size: 19) ---


void FUN_0049cd10(void)



{

  FUN_00460270(0x1000002a,&LAB_0049cc70);

  return;

}





// --- FUN_0049d000 at 0x0049D000 (size: 75) ---


undefined4 __thiscall FUN_0049d000(int param_1,int param_2,int param_3)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x63c) != -1) {

    iVar1 = (**(code **)(**(int **)(*(int *)(param_1 + 0x628) + *(int *)(param_1 + 0x63c) * 4) +

                        0x14))();

    if (iVar1 == param_2) {

      iVar1 = (**(code **)(**(int **)(*(int *)(param_1 + 0x628) + *(int *)(param_1 + 0x63c) * 4) +

                          0x18))();

      if (iVar1 == param_3) {

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_0049d050 at 0x0049D050 (size: 567) ---


undefined4 FUN_0049d050(void)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  int local_a0;

  undefined4 uStack_9c;

  undefined4 uStack_98;

  undefined4 uStack_94;

  

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f4f8,0x10000001);

  uVar5 = 0;

  uVar4 = 0;

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0e00(uVar1,uVar4,uVar5);

  FUN_0046a790(uVar1,uVar4,uVar5);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  FUN_0042c9c0(DAT_0083f4fc,0x10000001);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0e50(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  uStack_9c = 0;

  FUN_00590c20(0x18,&uStack_9c,0,0);

  FUN_0042c9c0(DAT_0083f500,0x10000001);

  FUN_0042e000(DAT_0083f518,uStack_9c,0);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0ea0(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  FUN_0042c9c0(DAT_0083f504,0x10000001);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0f40(uVar1);

  FUN_0046a740(uVar1);

  puVar3 = (undefined4 *)(local_a0 + -0x14);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  uStack_98 = 0;

  uStack_94 = 0;

  FUN_00590c70(2,&uStack_98);

  FUN_0042c9c0(DAT_0083f508,0x10000001);

  FUN_0042e000(DAT_0083f514,uStack_98,uStack_94);

  uVar1 = FUN_0042e980(&local_a0,0);

  FUN_004f0f90(uVar1);

  FUN_0046a740(uVar1);

  LVar2 = InterlockedDecrement((LONG *)(local_a0 + -0x10));

  if ((LVar2 == 0) && ((undefined4 *)(local_a0 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_a0 + -0x14))(1);

  }

  FUN_0042e590();

  return 1;

}





// --- FUN_0049d4f0 at 0x0049D4F0 (size: 1066) ---


undefined4 __fastcall FUN_0049d4f0(int *param_1)



{

  undefined *puVar1;

  undefined4 uVar2;

  LONG LVar3;

  int *piVar4;

  undefined **ppuVar5;

  undefined *unaff_EBX;

  code *pcVar6;

  undefined **unaff_ESI;

  int unaff_EDI;

  int iVar7;

  undefined4 *puVar8;

  undefined4 unaff_retaddr;

  uint *puVar9;

  undefined4 uVar10;

  undefined **ppuVar11;

  undefined *puStack_b0;

  uint auStack_ac [3];

  undefined *puStack_a0;

  uint uStack_9c;

  undefined4 uStack_98;

  undefined *local_94 [37];

  

  local_94[0] = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  ppuVar11 = local_94;

  (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0xc))();

  uStack_9c = 0;

  uVar10 = 1;

  puVar9 = &uStack_9c;

  uVar2 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x18))(puVar9,1);

  FUN_00592700(uVar2,puVar9,uVar10);

  auStack_ac[0] = 0;

  uVar10 = 0;

  puVar9 = auStack_ac;

  uVar2 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x18))(puVar9,0);

  FUN_00592700(uVar2,puVar9,uVar10);

  puStack_a0 = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_004027b0(&puStack_a0,L"%s: %d",uStack_98,auStack_ac[0]);

  uVar10 = 0;

  uVar2 = 0;

  ppuVar5 = &puStack_a0;

  FUN_004f0e00(ppuVar5,0,0);

  FUN_0046a790(ppuVar5,uVar2,uVar10);

  puVar1 = PTR_DAT_00818340;

  iVar7 = auStack_ac[0] - uStack_9c;

  pcVar6 = InterlockedDecrement_exref;

  if (iVar7 != 0) {

    uVar2 = 0;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    if (uStack_9c < auStack_ac[0]) {

      uVar2 = 1;

      FUN_00407e40(&DAT_007a8894);

    }

    else if (auStack_ac[0] < uStack_9c) {

      uVar2 = 2;

    }

    puStack_b0 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_004027b0(&puStack_b0,L" (%s%d)",puVar1,iVar7);

    uVar10 = 0;

    ppuVar5 = &puStack_b0;

    FUN_004f0e00(ppuVar5,0,uVar2);

    FUN_0046a000(ppuVar5,uVar10,uVar2);

    pcVar6 = InterlockedDecrement_exref;

    puVar8 = (undefined4 *)(puStack_b0 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(puStack_b0 + -0x10));

    if ((LVar3 == 0) && (puVar8 != (undefined4 *)0x0)) {

      (**(code **)*puVar8)(1);

    }

    LVar3 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    unaff_EBX = puVar1;

    if ((LVar3 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

    }

  }

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f50c,0x10000001);

  uVar2 = FUN_0042e980(&stack0xffffff4c,0);

  FUN_004f0e50(uVar2);

  FUN_0046a740(uVar2);

  iVar7 = (*pcVar6)(unaff_EBX + -0x10);

  if ((iVar7 == 0) && ((undefined4 *)(unaff_EBX + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EBX + -0x14))(1);

  }

  iVar7 = (**(code **)(*param_1 + 0x15c))(unaff_retaddr);

  if (iVar7 == 0) {

    FUN_0042c9c0(DAT_0083f4f4,0x10000001);

  }

  else {

    FUN_0042c9c0(DAT_0083f510,0x10000001);

    FUN_0042e000(DAT_0083f51c,iVar7,0);

  }

  uVar2 = FUN_0042e980(&stack0xffffff44,0);

  FUN_004f0ea0(uVar2);

  FUN_0046a740(uVar2);

  iVar7 = (*pcVar6)(unaff_ESI + -4);

  if ((iVar7 == 0) && (unaff_ESI + -5 != (undefined **)0x0)) {

    (**(code **)unaff_ESI[-5])(1);

  }

  FUN_0042c9c0(DAT_0083f504,0x10000001);

  uVar2 = FUN_0042e980(&stack0xffffff40,0);

  FUN_004f0f40(uVar2);

  FUN_0046a740(uVar2);

  iVar7 = (*pcVar6)(unaff_EDI + -0x10);

  if ((iVar7 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  FUN_00590c70(2,&stack0xffffff48);

  FUN_0042c9c0(DAT_0083f508,0x10000001);

  FUN_0042e000(DAT_0083f514,0,0);

  uVar2 = FUN_0042e980(&stack0xffffff3c,0);

  FUN_004f0f90(uVar2);

  FUN_0046a740(uVar2);

  ppuVar5 = ppuVar11 + -5;

  iVar7 = (*pcVar6)(ppuVar11 + -4);

  if ((iVar7 == 0) && (ppuVar5 != (undefined **)0x0)) {

    (**(code **)*ppuVar5)(1);

  }

  if ((ppuVar11 == (undefined **)0x0) || (unaff_ESI < ppuVar11)) {

    piVar4 = (int *)FUN_004f0fe0();

    uVar2 = 0xd;

  }

  else {

    piVar4 = (int *)FUN_004f0fe0();

    uVar2 = 1;

  }

  (**(code **)(*piVar4 + 0x9c))(uVar2);

  ppuVar5 = (undefined **)(**(code **)(*param_1 + 0x164))(unaff_retaddr);

  if ((ppuVar5 == (undefined **)0x0) || ((unaff_EDI == 0 && (ppuVar11 < ppuVar5)))) {

    piVar4 = (int *)FUN_004f1030();

    uVar2 = 0xd;

  }

  else {

    piVar4 = (int *)FUN_004f1030();

    uVar2 = 1;

  }

  (**(code **)(*piVar4 + 0x9c))(uVar2);

  FUN_0042e590();

  iVar7 = (*pcVar6)(unaff_EDI + -0x10);

  if ((iVar7 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  iVar7 = (*pcVar6)(unaff_ESI + -4);

  if ((iVar7 == 0) && (unaff_ESI + -5 != (undefined **)0x0)) {

    (**(code **)unaff_ESI[-5])(1);

  }

  return 1;

}





// --- FUN_0049d920 at 0x0049D920 (size: 1212) ---


undefined4 __fastcall FUN_0049d920(int *param_1)



{

  undefined *puVar1;

  undefined *puVar2;

  undefined4 uVar3;

  int iVar4;

  int iVar5;

  LONG LVar6;

  int iVar7;

  int *piVar8;

  code *pcVar9;

  int unaff_EDI;

  undefined4 *puVar10;

  int unaff_retaddr;

  undefined1 *puVar11;

  undefined **ppuVar12;

  undefined4 uVar13;

  undefined **ppuVar14;

  undefined **ppuStack_b8;

  undefined *puStack_b4;

  undefined4 uStack_b0;

  undefined *puStack_ac;

  undefined4 uStack_a8;

  undefined4 uStack_a4;

  undefined *local_a0 [2];

  undefined4 auStack_98 [38];

  

  local_a0[0] = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  ppuVar14 = local_a0;

  (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0xc))();

  uStack_a8 = 0;

  puVar10 = &uStack_a8;

  uVar3 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x18))(puVar10);

  FUN_00592d20(uVar3,puVar10);

  uStack_b0 = 0;

  puVar10 = &uStack_b0;

  uVar3 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x18))(puVar10);

  FUN_00592d20(uVar3,puVar10);

  auStack_98[0] = 0;

  puVar10 = auStack_98;

  iVar4 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x18))(puVar10);

  FUN_00592d20(iVar4 + 1,puVar10);

  puStack_ac = PTR_DAT_00818340;

  InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

  FUN_004027b0(&puStack_ac,L"%s: %d/%d",uStack_a4,auStack_98[0]);

  uVar3 = 0;

  ppuVar12 = &puStack_ac;

  FUN_004f0e00(ppuVar12,0);

  FUN_0046a790(ppuVar12,uVar3);

  iVar4 = unaff_retaddr;

  iVar5 = (**(code **)(**(int **)(param_1[0x18a] + param_1[399] * 4) + 0x28))();

  puVar1 = PTR_DAT_00818340;

  if (iVar5 < 0) {

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_004027b0(&stack0xffffff44,L" (%d)",iVar5);

    uVar13 = 3;

    uVar3 = 0;

    puVar11 = &stack0xffffff44;

    FUN_004f0e00(puVar11,0,3);

    FUN_0046a000(puVar11,uVar3,uVar13);

    ppuStack_b8 = (undefined **)(puVar1 + -0x14);

    LVar6 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar6 == 0) && (ppuStack_b8 != (undefined **)0x0)) {

      (**(code **)*ppuStack_b8)(1);

    }

  }

  puVar1 = PTR_DAT_00818340;

  puStack_b4 = puStack_b4 + -iVar5;

  iVar5 = (int)puStack_b4 - (int)puStack_ac;

  pcVar9 = InterlockedDecrement_exref;

  if (iVar5 != 0) {

    ppuStack_b8 = (undefined **)PTR_DAT_00818340;

    uVar3 = 0;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    if (puStack_ac < puStack_b4) {

      uVar3 = 1;

      FUN_00407e40(&DAT_007a8894);

    }

    else if (puStack_b4 < puStack_ac) {

      uVar3 = 2;

    }

    puVar2 = PTR_DAT_00818340;

    InterlockedIncrement((LONG *)(PTR_DAT_00818340 + -0x10));

    FUN_004027b0(&stack0xffffff44,L" (%s%d)",puVar1,iVar5);

    uVar13 = 0;

    puVar11 = &stack0xffffff44;

    FUN_004f0e00(puVar11,0,uVar3);

    FUN_0046a000(puVar11,uVar13,uVar3);

    pcVar9 = InterlockedDecrement_exref;

    puVar10 = (undefined4 *)(puVar2 + -0x14);

    LVar6 = InterlockedDecrement((LONG *)(puVar2 + -0x10));

    if ((LVar6 == 0) && (puVar10 != (undefined4 *)0x0)) {

      (**(code **)*puVar10)(1);

    }

    LVar6 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

    if ((LVar6 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

    }

  }

  FUN_0042dc80();

  FUN_0042c9c0(DAT_0083f50c,0x10000001);

  uVar3 = FUN_0042e980(&stack0xffffff40,0);

  FUN_004f0e50(uVar3);

  FUN_0046a740(uVar3);

  iVar7 = (*pcVar9)(iVar5 + -0x10);

  if ((iVar7 == 0) && ((undefined4 *)(iVar5 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar5 + -0x14))(1);

  }

  iVar5 = (**(code **)(*param_1 + 0x15c))(unaff_retaddr);

  if (iVar5 == 0) {

    FUN_0042c9c0(DAT_0083f4f4,0x10000001);

  }

  else {

    FUN_0042c9c0(DAT_0083f510,0x10000001);

    FUN_0042e000(DAT_0083f51c,iVar5,0);

  }

  uVar3 = FUN_0042e980(&stack0xffffff38,0);

  FUN_004f0ea0(uVar3);

  FUN_0046a740(uVar3);

  iVar5 = (*pcVar9)(unaff_EDI + -0x10);

  if ((iVar5 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  FUN_0042c9c0(DAT_0083f504,0x10000001);

  uVar3 = FUN_0042e980(&stack0xffffff34,0);

  FUN_004f0f40(uVar3);

  FUN_0046a740(uVar3);

  ppuVar12 = ppuVar14 + -5;

  iVar5 = (*pcVar9)(ppuVar14 + -4);

  if ((iVar5 == 0) && (ppuVar12 != (undefined **)0x0)) {

    (**(code **)*ppuVar12)(1);

  }

  puStack_b4 = (undefined *)0x0;

  uStack_b0 = 0;

  FUN_00590c70(2,&puStack_b4);

  FUN_0042c9c0(DAT_0083f508,0x10000001);

  FUN_0042e000(DAT_0083f514,puStack_b4,uStack_b0);

  uVar3 = FUN_0042e980(&stack0xffffff30,0);

  FUN_004f0f90(uVar3);

  FUN_0046a740(uVar3);

  iVar5 = (*pcVar9)(iVar4 + -0x10);

  if ((iVar5 == 0) && ((undefined4 *)(iVar4 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar4 + -0x14))(1);

  }

  if ((ppuVar14 == (undefined **)0x0) ||

     ((puStack_b4 == (undefined *)0x0 && (ppuStack_b8 < ppuVar14)))) {

    piVar8 = (int *)FUN_004f0fe0();

    (**(code **)(*piVar8 + 0x9c))(0xd);

    piVar8 = (int *)FUN_004f1030();

    uVar3 = 0xd;

  }

  else {

    piVar8 = (int *)FUN_004f0fe0();

    (**(code **)(*piVar8 + 0x9c))(1);

    piVar8 = (int *)FUN_004f1030();

    uVar3 = 1;

  }

  (**(code **)(*piVar8 + 0x9c))(uVar3);

  FUN_0042e590();

  iVar4 = (*pcVar9)(ppuVar14 + -4);

  if ((iVar4 == 0) && (ppuVar14 + -5 != (undefined **)0x0)) {

    (**(code **)ppuVar14[-5])(1);

  }

  iVar4 = (*pcVar9)(unaff_EDI + -0x10);

  if ((iVar4 == 0) && ((undefined4 *)(unaff_EDI + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(unaff_EDI + -0x14))(1);

  }

  return 1;

}





// --- thunk_FUN_004639a0 at 0x0049E2D0 (size: 5) ---


void __fastcall thunk_FUN_004639a0(int param_1)



{

  int *piVar1;

  

  piVar1 = (int *)0x0;

  if (*(int *)(param_1 + 0x120) != 0) {

    if (*(int *)(param_1 + 0x124) == 0) {

      piVar1 = (int *)0x0;

    }

    else {

      piVar1 = (int *)(*(int *)(param_1 + 0x124) + -8);

    }

  }

  while( true ) {

    if (piVar1 == (int *)0x0) {

      return;

    }

    if ((int *)*piVar1 != (int *)0x0) {

      (**(code **)(*(int *)*piVar1 + 0xc0))();

    }

    if (piVar1[2] == 0) break;

    piVar1 = (int *)(piVar1[2] + -8);

  }

  return;

}





// --- FUN_0049e330 at 0x0049E330 (size: 61) ---


undefined4 * __thiscall FUN_0049e330(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007a9040;

  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_0049e370 at 0x0049E370 (size: 19) ---


void FUN_0049e370(void)



{

  FUN_00460270(0x10000029,&LAB_0049e2e0);

  return;

}





// --- FUN_0049e570 at 0x0049E570 (size: 80) ---


void __fastcall FUN_0049e570(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  

  puVar1 = param_1 + 0x181;

  *param_1 = &PTR_FUN_007a97d8;

  param_1[0x17c] = &PTR_FUN_007aa43c;

  *puVar1 = &PTR_FUN_007a9530;

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

  FUN_00465fb0(0xc);

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004f3320();

  return;

}





// --- FUN_0049eaa0 at 0x0049EAA0 (size: 30) ---


void * __thiscall FUN_0049eaa0(void *param_1,byte param_2)



{

  FUN_0049e570();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049eac0 at 0x0049EAC0 (size: 142) ---


void __fastcall FUN_0049eac0(int *param_1)



{

  int *piVar1;

  int iVar2;

  

  FUN_004639a0();

  param_1[0x182] = 0;

  param_1[0x183] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  param_1[0x186] = 0;

  param_1[0x187] = 0;

  piVar1 = (int *)FUN_00463c00(0x10000200);

  if (piVar1 != (int *)0x0) {

    iVar2 = (**(code **)(*piVar1 + 0x94))(5);

    param_1[0x180] = iVar2;

  }

  (**(code **)(*param_1 + 0x144))();

  (**(code **)param_1[0x17c])(0);

  piVar1 = (int *)FUN_0043c680();

  (**(code **)(*piVar1 + 4))(0x4dd276,param_1 + 0x181);

  FUN_00465f90(0xc);

  return;

}





// --- FUN_0049eb50 at 0x0049EB50 (size: 19) ---


void FUN_0049eb50(void)



{

  FUN_00460270(0x10000028,&LAB_0049e5c0);

  return;

}





// --- FUN_0049eb70 at 0x0049EB70 (size: 657) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0049eb70(int *param_1)



{

  char cVar1;

  LONG LVar2;

  undefined4 *puVar3;

  float10 fVar4;

  undefined8 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 *local_10;

  float local_c;

  

  puVar3 = DAT_008ef11c;

  local_10 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  if (param_1[0x182] != 0) {

    fVar4 = (float10)FUN_00484f80();

    local_c = (float)fVar4;

    if (fVar4 != (float10)(float)s_33s_ID_Option_HighResChange_007a9b0c._0_4_) {

      FUN_00484f90(0x3f733333);

      FUN_00487620(&local_10,

                   "Camera Stiffness was changed from %f to the mouse turning default of %f.",

                   (double)local_c,0x60000000,0x3fee6666);

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  if (param_1[0x183] != 0) {

    fVar4 = (float10)FUN_00484f80();

    local_c = (float)fVar4;

    if (fVar4 != (float10)_DAT_007a9abc) {

      FUN_00484f90(0x42480000);

      FUN_00487620(&local_10,

                   "Camera Adjustment was changed from %f to the mouse turning default of %f.",

                   (double)local_c,0x60000000,0x3fee6666);

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  if (param_1[0x184] != 0) {

    fVar4 = (float10)FUN_00484f80();

    local_c = (float)fVar4;

    if (fVar4 != (float10)(float)s_333_Camera_Adjustment_was_change_007a9a6c._0_4_) {

      FUN_00484f90(0x3f333333);

      FUN_00487620(&local_10,

                   "Mouse Sensitivity was changed from %f to the mouse turning default of %f.",

                   (double)local_c,0x60000000,0x3fee6666);

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  if ((int *)param_1[0x185] != (int *)0x0) {

    cVar1 = (**(code **)(*(int *)param_1[0x185] + 0x2e0))();

    if (cVar1 == '\x01') {

      (**(code **)(*(int *)param_1[0x185] + 0x2dc))(0);

      FUN_00487620(&local_10,

                   "Align To Slope was changed from TRUE to the mouse turning default of FALSE.");

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  if ((int *)param_1[0x186] != (int *)0x0) {

    cVar1 = (**(code **)(*(int *)param_1[0x186] + 0x2e0))();

    if (cVar1 == '\0') {

      (**(code **)(*(int *)param_1[0x186] + 0x2dc))(1);

      FUN_00487620(&local_10,

                   "Invert Mouselook Axes was changed from FALSE to the mouse turning default of TRUE."

                  );

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  if ((int *)param_1[0x187] != (int *)0x0) {

    cVar1 = (**(code **)(*(int *)param_1[0x187] + 0x2e0))();

    if (cVar1 == '\0') {

      (**(code **)(*(int *)param_1[0x187] + 0x2dc))(1);

      FUN_00487620(&local_10,

                   "Turn to Face Camera was changed from FALSE to the mouse turning default of TRUE."

                  );

      puVar3 = local_10;

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = CONCAT44(7,local_10 + 5);

      FUN_00564d30(local_10 + 5,7,1,0);

      FUN_004882f0(uVar5,uVar6,uVar7);

    }

  }

  (**(code **)(*param_1 + 0x138))();

  LVar2 = InterlockedDecrement(puVar3 + 1);

  if ((LVar2 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  return;

}





// --- FUN_0049f020 at 0x0049F020 (size: 553) ---


int * __thiscall FUN_0049f020(int param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 *unaff_retaddr;

  undefined4 uVar3;

  

  if (*(int *)(param_1 + 0x600) == 0) {

    return (int *)0x0;

  }

  piVar1 = (int *)FUN_0046f670(8,0);

  if (piVar1 == (int *)0x0) {

    return (int *)0x0;

  }

  iVar2 = (**(code **)(*piVar1 + 0x94))(0x10000044);

  if (iVar2 == 0) {

    return (int *)0x0;

  }

  piVar1 = (int *)(iVar2 + -0x20);

  if (piVar1 == (int *)0x0) {

    return (int *)0x0;

  }

  FUN_004862b0(*unaff_retaddr,1);

  FUN_004effc0(param_2);

  switch(param_2) {

  case 2:

    uVar3 = 0x101c;

    break;

  case 3:

    uVar3 = 0x40c00;

    break;

  case 4:

    uVar3 = 0x80000;

    break;

  case 5:

    uVar3 = 0x78000000;

    break;

  default:

    goto switchD_0049f088_caseD_6;

  case 8:

    (**(code **)(*piVar1 + 0x2d8))(0xfbffffff,0);

    goto switchD_0049f088_caseD_6;

  }

  (**(code **)(*piVar1 + 0x2d8))(uVar3,0);

  FUN_00486660(0x83912021,0,DAT_0083f840,DAT_0083f844);

switchD_0049f088_caseD_6:

  FUN_00486660(0x600040,0,DAT_0083f830,DAT_0083f834);

  FUN_00486660(0x20080,0,DAT_0083f848,DAT_0083f84c);

  FUN_00486660(0x1004,0,DAT_0083f838,DAT_0083f83c);

  FUN_00486660(0x18,0,DAT_0083f850,DAT_0083f854);

  FUN_00486660(0x40c00,0,DAT_0083f858,DAT_0083f85c);

  FUN_00486660(0x80000,0,DAT_0083f860,DAT_0083f864);

  FUN_00486660(0x8000000,0,DAT_0083f868,DAT_0083f86c);

  FUN_00486660(0x10000000,0,DAT_0083f870,DAT_0083f874);

  FUN_00486660(0x20000000,0,DAT_0083f878,DAT_0083f87c);

  FUN_00486660(0x40000000,0,DAT_0083f880,DAT_0083f884);

  FUN_00486660(0,1,DAT_0083f888,DAT_0083f88c);

  FUN_00486660(0x4000000,0,DAT_0083f890,DAT_0083f894);

  FUN_004861b0();

  FUN_004f3af0(piVar1);

  return piVar1;

}





// --- FUN_0049f270 at 0x0049F270 (size: 161) ---


void __thiscall FUN_0049f270(int *param_1,int param_2)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  

  *param_1 = param_2;

  param_1[1] = 0;

  piVar1 = (int *)thunk_FUN_005df0f5(param_2 * 0x10 + 4);

  if (piVar1 == (int *)0x0) {

    piVar2 = (int *)0x0;

  }

  else {

    piVar2 = piVar1 + 1;

    *piVar1 = param_2;

    piVar1 = piVar2;

    if (-1 < param_2 + -1) {

      do {

        *piVar1 = (int)&PTR_LAB_007a9dc4;

        piVar1[1] = 0;

        piVar1[2] = 0;

        piVar1[3] = 0;

        param_2 = param_2 + -1;

        piVar1 = piVar1 + 4;

      } while (param_2 != 0);

    }

  }

  iVar3 = *param_1;

  param_1[2] = (int)piVar2;

  piVar1 = (int *)thunk_FUN_005df0f5(iVar3 * 0x10 + 4);

  if (piVar1 == (int *)0x0) {

    param_1[3] = 0;

    return;

  }

  *piVar1 = iVar3;

  piVar2 = piVar1 + 1;

  if (-1 < iVar3 + -1) {

    do {

      *piVar2 = (int)&PTR_LAB_007a9dc4;

      piVar2[1] = 0;

      piVar2[2] = 0;

      piVar2[3] = 0;

      iVar3 = iVar3 + -1;

      piVar2 = piVar2 + 4;

    } while (iVar3 != 0);

  }

  param_1[3] = (int)(piVar1 + 1);

  return;

}





// --- FUN_0049f320 at 0x0049F320 (size: 87) ---


void __fastcall FUN_0049f320(int *param_1)



{

  int iVar1;

  int local_c [3];

  

  if (*param_1 != param_1[1]) {

    do {

      if (param_1 + 2 != local_c) {

        param_1[3] = *(int *)(*param_1 + 4);

        param_1[4] = *param_1;

      }

      if (param_1 + 5 != local_c) {

        param_1[6] = 0;

        param_1[7] = *param_1;

      }

    } while ((param_1[6] == param_1[3]) &&

            (iVar1 = *param_1, *param_1 = iVar1 + 0x10, iVar1 + 0x10 != param_1[1]));

  }

  return;

}





// --- FUN_0049f380 at 0x0049F380 (size: 74) ---


void __fastcall FUN_0049f380(int *param_1)



{

  int *piVar1;

  int iVar2;

  

  FUN_004639a0();

  piVar1 = (int *)FUN_00463c00(0x1000050d);

  if (piVar1 == (int *)0x0) {

    iVar2 = 0;

  }

  else {

    iVar2 = (**(code **)(*piVar1 + 0x94))(5);

  }

  param_1[0x180] = iVar2;

  (**(code **)(*param_1 + 0x144))();

  (**(code **)param_1[0x17c])(0);

  return;

}





// --- FUN_0049f3d0 at 0x0049F3D0 (size: 211) ---


void __thiscall FUN_0049f3d0(uint *param_1,uint *param_2,uint *param_3)



{

  int iVar1;

  uint *puVar2;

  undefined4 *puVar3;

  int iVar4;

  int iVar5;

  

  iVar4 = ((*param_2 << 0x18 | *param_2 >> 8) % *param_1) * 0x10 + param_1[2];

  iVar5 = ((*param_3 << 0x18 | *param_3 >> 8) % *param_1) * 0x10 + param_1[3];

  puVar2 = (uint *)FUN_005df0f5(8);

  if (puVar2 == (uint *)0x0) {

    puVar2 = (uint *)0x0;

  }

  else {

    *puVar2 = *param_2;

    puVar2[1] = *param_3;

  }

  puVar3 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar3 != (undefined4 *)0x0) {

    *puVar3 = puVar2;

    puVar3[1] = 0;

    puVar3[2] = 0;

    if (*(int *)(iVar4 + 4) == 0) {

      *(undefined4 **)(iVar4 + 4) = puVar3;

    }

    else {

      iVar1 = *(int *)(iVar4 + 8);

      *(undefined4 **)(iVar1 + 4) = puVar3;

      puVar3[2] = iVar1;

    }

    *(undefined4 **)(iVar4 + 8) = puVar3;

    *(int *)(iVar4 + 0xc) = *(int *)(iVar4 + 0xc) + 1;

  }

  puVar3 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar3 != (undefined4 *)0x0) {

    *puVar3 = puVar2;

    puVar3[1] = 0;

    puVar3[2] = 0;

    if (*(int *)(iVar5 + 4) == 0) {

      *(undefined4 **)(iVar5 + 4) = puVar3;

      *(undefined4 **)(iVar5 + 8) = puVar3;

      *(int *)(iVar5 + 0xc) = *(int *)(iVar5 + 0xc) + 1;

      return;

    }

    iVar4 = *(int *)(iVar5 + 8);

    *(undefined4 **)(iVar4 + 4) = puVar3;

    puVar3[2] = iVar4;

    *(undefined4 **)(iVar5 + 8) = puVar3;

    *(int *)(iVar5 + 0xc) = *(int *)(iVar5 + 0xc) + 1;

  }

  return;

}





// --- FUN_0049f4b0 at 0x0049F4B0 (size: 99) ---


undefined4 __thiscall FUN_0049f4b0(int *param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = *param_1;

  if (((iVar1 != 0) && (iVar1 != param_1[1])) && (param_1[6] != param_1[3])) {

    if ((iVar1 == *param_2) && (param_2[3] == param_1[3])) {

      return 1;

    }

    return 0;

  }

  if (((*param_2 != 0) && (*param_2 != param_2[1])) && (param_2[6] != param_2[3])) {

    return 0;

  }

  return 1;

}





// --- FUN_0049f520 at 0x0049F520 (size: 144) ---


void __thiscall FUN_0049f520(uint *param_1,int *param_2,uint *param_3)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  undefined4 *puVar4;

  int iVar5;

  int iVar6;

  int local_18 [3];

  int local_c [3];

  

  uVar1 = *param_1;

  uVar2 = *param_3;

  uVar3 = param_1[2];

  iVar5 = ((uVar2 << 0x18 | uVar2 >> 8) % uVar1) * 0x10;

  iVar6 = iVar5 + uVar3;

  for (puVar4 = *(undefined4 **)(iVar5 + 4 + uVar3);

      (puVar4 != (undefined4 *)0x0 && (*(uint *)*puVar4 != uVar2)); puVar4 = (undefined4 *)puVar4[1]

      ) {

  }

  param_2[2] = (int)&PTR_LAB_007a9dc0;

  param_2[3] = 0;

  param_2[4] = 0;

  param_2[5] = (int)&PTR_LAB_007a9dc0;

  param_2[6] = 0;

  param_2[7] = 0;

  param_2[1] = uVar1 * 0x10 + uVar3;

  *param_2 = iVar6;

  if (param_2 + 2 != local_18) {

    param_2[3] = (int)puVar4;

    param_2[4] = iVar6;

  }

  if (param_2 + 5 != local_c) {

    param_2[6] = 0;

    param_2[7] = iVar6;

  }

  return;

}





// --- FUN_0049f5b0 at 0x0049F5B0 (size: 145) ---


void __thiscall FUN_0049f5b0(uint *param_1,int *param_2,uint *param_3)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  int *piVar4;

  int iVar5;

  int iVar6;

  int local_18 [3];

  int local_c [3];

  

  uVar1 = *param_1;

  uVar2 = *param_3;

  uVar3 = param_1[3];

  iVar5 = ((uVar2 << 0x18 | uVar2 >> 8) % uVar1) * 0x10;

  iVar6 = iVar5 + uVar3;

  for (piVar4 = *(int **)(iVar5 + 4 + uVar3);

      (piVar4 != (int *)0x0 && (*(uint *)(*piVar4 + 4) != uVar2)); piVar4 = (int *)piVar4[1]) {

  }

  param_2[2] = (int)&PTR_LAB_007a9dc0;

  param_2[3] = 0;

  param_2[4] = 0;

  param_2[5] = (int)&PTR_LAB_007a9dc0;

  param_2[6] = 0;

  param_2[7] = 0;

  param_2[1] = uVar1 * 0x10 + uVar3;

  *param_2 = iVar6;

  if (param_2 + 2 != local_18) {

    param_2[3] = (int)piVar4;

    param_2[4] = iVar6;

  }

  if (param_2 + 5 != local_c) {

    param_2[6] = 0;

    param_2[7] = iVar6;

  }

  return;

}





// --- FUN_0049f650 at 0x0049F650 (size: 131) ---


undefined4 __thiscall FUN_0049f650(int *param_1,undefined4 param_2,undefined4 *param_3)



{

  char cVar1;

  int local_40;

  int local_3c;

  undefined **local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined **local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined1 local_20 [12];

  int *local_14;

  

  FUN_0049f520(local_20,param_2);

  local_40 = *param_1 * 0x10 + param_1[2];

  local_38 = &PTR_LAB_007a9dc0;

  local_2c = &PTR_LAB_007a9dc0;

  local_34 = 0;

  local_30 = 0;

  local_28 = 0;

  local_24 = 0;

  local_3c = local_40;

  FUN_0049f320();

  cVar1 = FUN_0049f4b0(&local_40);

  if (cVar1 != '\0') {

    return 0;

  }

  *param_3 = *(undefined4 *)(*local_14 + 4);

  return 1;

}





// --- FUN_0049f6e0 at 0x0049F6E0 (size: 130) ---


undefined4 __thiscall FUN_0049f6e0(int *param_1,undefined4 param_2,undefined4 *param_3)



{

  char cVar1;

  int local_40;

  int local_3c;

  undefined **local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined **local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined1 local_20 [12];

  undefined4 *local_14;

  

  FUN_0049f5b0(local_20,param_2);

  local_40 = *param_1 * 0x10 + param_1[2];

  local_38 = &PTR_LAB_007a9dc0;

  local_2c = &PTR_LAB_007a9dc0;

  local_34 = 0;

  local_30 = 0;

  local_28 = 0;

  local_24 = 0;

  local_3c = local_40;

  FUN_0049f320();

  cVar1 = FUN_0049f4b0(&local_40);

  if (cVar1 != '\0') {

    return 0;

  }

  *param_3 = *(undefined4 *)*local_14;

  return 1;

}





// --- FUN_0049f770 at 0x0049F770 (size: 106) ---


char __thiscall FUN_0049f770(int *param_1,undefined4 param_2)



{

  char cVar1;

  int local_40;

  int local_3c;

  undefined **local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined **local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined1 local_20 [32];

  

  local_40 = *param_1 * 0x10 + param_1[2];

  local_38 = &PTR_LAB_007a9dc0;

  local_2c = &PTR_LAB_007a9dc0;

  local_34 = 0;

  local_30 = 0;

  local_28 = 0;

  local_24 = 0;

  local_3c = local_40;

  FUN_0049f320();

  FUN_0049f520(local_20,param_2);

  cVar1 = FUN_0049f4b0(&local_40);

  return '\x01' - (cVar1 != '\0');

}





// --- FUN_0049f7e0 at 0x0049F7E0 (size: 106) ---


char __thiscall FUN_0049f7e0(int *param_1,undefined4 param_2)



{

  char cVar1;

  int local_40;

  int local_3c;

  undefined **local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined **local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined1 local_20 [32];

  

  local_40 = *param_1 * 0x10 + param_1[2];

  local_38 = &PTR_LAB_007a9dc0;

  local_2c = &PTR_LAB_007a9dc0;

  local_34 = 0;

  local_30 = 0;

  local_28 = 0;

  local_24 = 0;

  local_3c = local_40;

  FUN_0049f320();

  FUN_0049f5b0(local_20,param_2);

  cVar1 = FUN_0049f4b0(&local_40);

  return '\x01' - (cVar1 != '\0');

}





// --- FUN_0049f850 at 0x0049F850 (size: 52) ---


void __fastcall FUN_0049f850(int param_1)



{

  void *pvVar1;

  int iVar2;

  

  while (pvVar1 = *(void **)(param_1 + 4), pvVar1 != (void *)0x0) {

    iVar2 = *(int *)((int)pvVar1 + 4);

    *(int *)(param_1 + 4) = iVar2;

    if (iVar2 == 0) {

      *(undefined4 *)(param_1 + 8) = 0;

    }

    else {

      *(undefined4 *)(iVar2 + 8) = 0;

    }

    if (pvVar1 != (void *)0x0) {

      operator_delete(pvVar1);

    }

    *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + -1;

  }

  return;

}





// --- FUN_0049f980 at 0x0049F980 (size: 196) ---


void __fastcall FUN_0049f980(uint *param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  uint local_4;

  

  local_4 = 0;

  if (*param_1 != 0) {

    iVar4 = 0;

    do {

      for (puVar1 = *(undefined4 **)(param_1[2] + 4 + iVar4); puVar1 != (undefined4 *)0x0;

          puVar1 = (undefined4 *)puVar1[1]) {

        if ((void *)*puVar1 != (void *)0x0) {

          operator_delete((void *)*puVar1);

        }

      }

      iVar5 = param_1[2] + iVar4;

      while (pvVar2 = *(void **)(iVar5 + 4), pvVar2 != (void *)0x0) {

        iVar3 = *(int *)((int)pvVar2 + 4);

        *(int *)(iVar5 + 4) = iVar3;

        if (iVar3 == 0) {

          *(undefined4 *)(iVar5 + 8) = 0;

        }

        else {

          *(undefined4 *)(iVar3 + 8) = 0;

        }

        if (pvVar2 != (void *)0x0) {

          operator_delete(pvVar2);

        }

        *(int *)(iVar5 + 0xc) = *(int *)(iVar5 + 0xc) + -1;

      }

      iVar5 = param_1[3] + iVar4;

      while (pvVar2 = *(void **)(iVar5 + 4), pvVar2 != (void *)0x0) {

        iVar3 = *(int *)((int)pvVar2 + 4);

        *(int *)(iVar5 + 4) = iVar3;

        if (iVar3 == 0) {

          *(undefined4 *)(iVar5 + 8) = 0;

        }

        else {

          *(undefined4 *)(iVar3 + 8) = 0;

        }

        if (pvVar2 != (void *)0x0) {

          operator_delete(pvVar2);

        }

        *(int *)(iVar5 + 0xc) = *(int *)(iVar5 + 0xc) + -1;

      }

      local_4 = local_4 + 1;

      iVar4 = iVar4 + 0x10;

    } while (local_4 < *param_1);

  }

  param_1[1] = 0;

  return;

}





// --- FUN_0049faf0 at 0x0049FAF0 (size: 75) ---


void __fastcall FUN_0049faf0(int param_1)



{

  undefined4 *puVar1;

  

  FUN_0049f980();

  puVar1 = *(undefined4 **)(param_1 + 8);

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  puVar1 = *(undefined4 **)(param_1 + 0xc);

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] != 0) {

      (**(code **)*puVar1)(3);

      return;

    }

    operator_delete__(puVar1 + -1);

  }

  return;

}





// --- FUN_0049fb40 at 0x0049FB40 (size: 111) ---


void __thiscall FUN_0049fb40(uint *param_1,int param_2)



{

  uint uVar1;

  undefined4 local_10 [2];

  undefined4 local_8;

  undefined4 local_4;

  

  uVar1 = param_1[1];

  param_1[1] = uVar1 + param_2;

  if (*param_1 >> 1 < uVar1 + param_2) {

    local_10[0] = 0;

    local_8 = 0;

    local_4 = 0;

    FUN_0049f270(*param_1 * 2);

    FUN_0049fbb0(param_1);

    FUN_0049faf0();

    FUN_0049f270(*param_1 << 1);

    FUN_0049fbb0(local_10);

    FUN_0049faf0();

  }

  return;

}





// --- FUN_0049fbb0 at 0x0049FBB0 (size: 393) ---


/* WARNING: Removing unreachable block (ram,0x0049fc8a) */

/* WARNING: Removing unreachable block (ram,0x0049fc94) */



undefined4 __thiscall FUN_0049fbb0(undefined4 param_1,int *param_2)



{

  int iVar1;

  int iVar2;

  bool bVar3;

  int iVar4;

  int iVar5;

  int *piVar6;

  int local_48;

  

  FUN_0049f980();

  iVar5 = param_2[2];

  iVar4 = *param_2 * 0x10 + iVar5;

  local_48 = 0;

  FUN_0049f320();

  piVar6 = (int *)0x0;

  while( true ) {

    iVar1 = *param_2;

    iVar2 = param_2[2];

    FUN_0049f320();

    if (((iVar5 == 0) || (iVar5 == iVar4)) || (piVar6 == (int *)0x0)) {

      bVar3 = true;

    }

    else if ((iVar5 == iVar1 * 0x10 + iVar2) && (piVar6 == (int *)0x0)) {

      bVar3 = true;

    }

    else {

      bVar3 = false;

    }

    if (bVar3) break;

    local_48 = local_48 + 1;

    FUN_0049f3d0(*piVar6,*piVar6 + 4);

    if ((iVar5 != iVar4) && (piVar6 = (int *)piVar6[1], piVar6 == (int *)0x0)) {

      iVar5 = iVar5 + 0x10;

      FUN_0049f320();

    }

  }

  FUN_0049fb40(local_48);

  return param_1;

}





// --- FUN_0049fd40 at 0x0049FD40 (size: 85) ---


undefined4 * __thiscall FUN_0049fd40(undefined4 *param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_004f32e0(param_2,param_3);

  param_1[0x181] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_FUN_007a9dd0;

  param_1[0x17c] = &PTR_LAB_007a9dc8;

  param_1[0x181] = &PTR_FUN_007ccb60;

  param_1[0x182] = 0;

  param_1[0x184] = 0;

  param_1[0x185] = 0;

  FUN_0049f270(0x40);

  return param_1;

}





// --- FUN_0049fdd0 at 0x0049FDD0 (size: 137) ---


void __fastcall FUN_0049fdd0(undefined4 *param_1)



{

  undefined4 *puVar1;

  

  *param_1 = &PTR_FUN_007a9dd0;

  param_1[0x17c] = &PTR_LAB_007a9dc8;

  param_1[0x181] = &PTR_FUN_007ccb60;

  FUN_0049f980();

  puVar1 = (undefined4 *)param_1[0x184];

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  puVar1 = (undefined4 *)param_1[0x185];

  if (puVar1 != (undefined4 *)0x0) {

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  param_1[0x181] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  FUN_004f3320();

  return;

}





// --- FUN_0049fe90 at 0x0049FE90 (size: 69) ---


undefined1 FUN_0049fe90(undefined4 param_1,undefined4 param_2)



{

  char cVar1;

  

  cVar1 = FUN_0049f770(param_1);

  if (cVar1 == '\0') {

    cVar1 = FUN_0049f7e0(param_2);

    if (cVar1 == '\0') {

      FUN_0049f3d0(param_1,param_2);

      FUN_0049fb40(1);

      return 1;

    }

  }

  return 0;

}





// --- FUN_0049fee0 at 0x0049FEE0 (size: 30) ---


void * __thiscall FUN_0049fee0(void *param_1,byte param_2)



{

  FUN_0049fdd0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0049ff00 at 0x0049FF00 (size: 19) ---


void FUN_0049ff00(void)



{

  FUN_00460270(0x10000042,&LAB_0049fe60);

  return;

}





