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

// --- FUN_00560020 at 0x00560020 (size: 71) ---


void __fastcall FUN_00560020(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cd910;

  param_1[1] = &PTR_FUN_007a7980;

  FUN_005d1400();

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

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

    param_1[3] = 0;

  }

  param_1[4] = 0;

  param_1[1] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00560070 at 0x00560070 (size: 91) ---


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



{

  *param_1 = &PTR_FUN_007cd910;

  param_1[1] = &PTR_FUN_007a7980;

  FUN_005d1400();

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

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

    param_1[3] = 0;

  }

  param_1[4] = 0;

  param_1[1] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005600d0 at 0x005600D0 (size: 245) ---


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



void __fastcall FUN_005600d0(int param_1)



{

  int *piVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  int iVar5;

  

  uVar4 = DAT_008379ac;

  uVar3 = DAT_008379a8;

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

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

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

      if ((char)piVar2[0xe] == '\0') {

        if (*(double *)(piVar2 + 0xc) < (double)CONCAT44(uVar4,uVar3)) {

          *(double *)(piVar2 + 0xc) = (double)CONCAT44(uVar4,uVar3) + *(double *)(piVar2 + 6);

          iVar5 = FUN_0058cfd0(piVar2[1],*(undefined4 *)(param_1 + 0x1e8),piVar2[2],piVar2[3],

                               (char)piVar2[4],*(undefined1 *)((int)piVar2 + 0x11));

          if (iVar5 == 0) {

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

              (*(code *)**(undefined4 **)*piVar2)(piVar2[1]);

LAB_005601af:

              *(undefined1 *)(piVar2 + 0xe) = 1;

            }

          }

          else if (((_DAT_00795610 < *(double *)(piVar2 + 8)) &&

                   (*(double *)(piVar2 + 10) < (double)CONCAT44(uVar4,uVar3))) &&

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

            (**(code **)(*(int *)*piVar2 + 4))(piVar2[1]);

            goto LAB_005601af;

          }

        }

        piVar2 = (int *)piVar2[0x10];

      }

      else {

        piVar1 = (int *)piVar2[0x10];

        FUN_0055f9f0(piVar2);

        piVar2 = piVar1;

      }

    }

  }

  return;

}





// --- FUN_00560280 at 0x00560280 (size: 438) ---


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



undefined4 __fastcall FUN_00560280(int param_1)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int **ppiVar6;

  undefined4 uVar7;

  int *local_a8;

  float fStack_a4;

  int *local_a0;

  undefined4 local_9c;

  undefined1 local_98 [4];

  undefined1 local_94 [4];

  undefined1 auStack_90 [144];

  

  ppiVar6 = &local_a8;

  puVar4 = local_98;

  puVar5 = &DAT_007cd540;

  local_a8 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007cd540,ppiVar6);

  FUN_00406570(puVar4,puVar5,ppiVar6);

  piVar2 = local_a8;

  uVar7 = 0;

  local_a0 = (int *)0x0;

  local_9c = 0;

  piVar3 = local_a8;

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

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

  }

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

  iVar1 = *piVar3;

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

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

  }

  piVar2 = local_a0;

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

    return 0;

  }

  if (iVar1 < 0) {

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

    return 0;

  }

  fStack_a4 = 0.0;

  FUN_0058ff60(&fStack_a4);

  if (fStack_a4 == *(float *)(param_1 + 0x23c)) {

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

    return 1;

  }

  if (((float)_DAT_00795ee0 <= *(float *)(param_1 + 0x23c)) || (fStack_a4 < (float)_DAT_00795ee0)) {

    if (((float)_DAT_007938c0 <= *(float *)(param_1 + 0x23c)) || (fStack_a4 < (float)_DAT_007938c0))

    goto LAB_0056040d;

    FUN_0042dc80();

    FUN_00402730(L"You are encumbered!");

    FUN_0042cbe0(&local_a8,1);

    FUN_004011b0();

  }

  else {

    FUN_0042dc80();

    FUN_00402730(L"You are severely encumbered!");

    FUN_0042cbe0(&local_a8,1);

    FUN_004011b0();

  }

  FUN_00693500(0x1a,auStack_90);

  FUN_0042e590();

LAB_0056040d:

  *(float *)(param_1 + 0x23c) = fStack_a4;

  FUN_006a3590(fStack_a4);

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

  return 1;

}





// --- FUN_00560440 at 0x00560440 (size: 337) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  int iVar3;

  undefined4 extraout_ECX;

  undefined4 extraout_ECX_00;

  undefined4 uVar4;

  undefined4 *local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined **local_44 [2];

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  int local_1c;

  undefined4 *local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  int local_8;

  

  local_18 = DAT_008ef11c;

  local_44[0] = &PTR_FUN_0079f27c;

  local_38 = 0;

  local_34 = 0;

  local_30 = 0;

  local_2c = 0;

  local_28 = 0;

  local_24 = 0;

  local_20 = 0;

  local_1c = 5;

  InterlockedIncrement(DAT_008ef11c + 1);

  local_14 = 0;

  local_10 = 0;

  local_c = 0;

  local_3c = 0;

  FUN_004fedc0(&param_2,param_3);

  FUN_004e9280(&local_18);

  FUN_004034c0(local_54 + 5);

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

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

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

  LVar2 = InterlockedDecrement(local_54 + 1);

  uVar4 = extraout_ECX;

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

    (**(code **)*local_54)(1);

    uVar4 = extraout_ECX_00;

  }

  if (local_1c == -1) {

    local_1c = 0x14;

  }

  if (local_8 != 0) {

    FUN_0048c3e0(*(int *)(param_1 + 0x1c) + 0x14);

    iVar3 = FUN_005570e0(uVar4);

    if (iVar3 == 0) {

      param_3 = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      FUN_004034c0(

                  "Failed to startup Turbine chat!\n\nVerify that chatclient.dll is in your Asheron\'s Call directory and try again."

                  );

      puVar1 = param_3;

      LVar2 = InterlockedDecrement(param_3 + 1);

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

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

      }

    }

  }

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

  FUN_00693aa0(local_44);

  FUN_00479d80();

  return;

}





// --- FUN_005605a0 at 0x005605A0 (size: 86) ---


void __thiscall FUN_005605a0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int iVar2;

  

  iVar2 = (**(code **)(*DAT_0083e72c + 0x24))();

  if (iVar2 != 0) {

    iVar2 = FUN_004fe9e0(param_2);

    if (iVar2 != -1) {

      FUN_004e9280(param_1 + 0x1c);

      FUN_005476f0();

      uVar1 = DAT_008379ac;

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

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

    }

  }

  return;

}





// --- FUN_00560600 at 0x00560600 (size: 263) ---


undefined4 __thiscall FUN_00560600(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

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

    iVar1 = (**(code **)(*DAT_0083e72c + 0x24))();

    if (iVar1 != 0) {

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

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

        FUN_005429e0();

        FUN_005475c0();

      }

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

    }

    return 0;

  }

  FUN_0058a070();

  iVar1 = FUN_00541770();

  if (iVar1 != 0) {

    iVar1 = (**(code **)(*DAT_0083e72c + 0x24))();

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

    if (iVar1 == 0) {

      return 0;

    }

    if (DAT_0083da58 != 0) {

      FUN_00453c90(1);

    }

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

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

    }

    FUN_004e9280(param_1 + 0x1c);

    FUN_00547780(iVar1);

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

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

    FUN_00589e70(1);

    uVar3 = 1;

    uVar2 = 1;

    FUN_0056b210(1,1);

    FUN_0056cb80(uVar2,uVar3);

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

    FUN_005429d0();

    uVar2 = DAT_008379ac;

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

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

  }

  FUN_006ae770();

  return 1;

}





// --- FUN_00560710 at 0x00560710 (size: 1453) ---


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

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

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

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



void __thiscall FUN_00560710(int param_1,char param_2,char param_3,undefined4 param_4,char param_5)



{

  double dVar1;

  int iVar2;

  float fVar3;

  longlong lVar4;

  bool bVar5;

  char cVar6;

  int iVar7;

  int iVar8;

  int *piVar9;

  int iVar10;

  int iVar11;

  uint uVar12;

  float10 fVar13;

  float10 fVar14;

  float10 extraout_ST1;

  int local_58;

  undefined8 uStack_48;

  undefined8 uStack_40;

  undefined4 *puStack_28;

  int *piStack_24;

  float fStack_20;

  float fStack_1c;

  float fStack_18;

  undefined1 auStack_14 [16];

  

  local_58 = 0;

  FUN_00406d10();

  FUN_00406570();

  FUN_004c1da0();

  iVar7 = DAT_00871e54;

  if (DAT_00871e54 == 0) {

    iVar7 = DAT_00871e58;

  }

  iVar8 = FUN_00508890();

  if (((param_3 == '\0') && (iVar8 != 0)) && (*(int *)(iVar8 + 0x90) != 0)) {

    FUN_00452de0(iVar8,&fStack_20);

    fVar3 = fStack_18;

    if (fStack_18 < (float)_DAT_00795610) {

      fVar3 = -fStack_18;

    }

    _CIpow();

    fVar13 = (float10)_CIpow();

    uStack_40 = (double)((float10)fVar3 * (float10)_DAT_007cd7a8 + SQRT(fVar13 + extraout_ST1));

LAB_00560832:

    lVar4 = 0;

    if (param_2 != '\0') goto LAB_00560846;

  }

  else {

    param_2 = param_2 == '\0';

    if ((bool)param_2) {

      uStack_40 = 73728.0;

      goto LAB_00560832;

    }

    uStack_40 = 0.0;

  }

  lVar4 = 0x40f20000;

LAB_00560846:

  uStack_48 = (double)(lVar4 << 0x20);

  piVar9 = (int *)FUN_0052dcf0();

  iVar8 = *piVar9;

  puStack_28 = (undefined4 *)piVar9[1];

  piStack_24 = (int *)piVar9[2];

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

LAB_005608b0:

    do {

      iVar2 = *piStack_24;

      if ((iVar2 == 0) || (iVar2 == *(int *)(param_1 + 0x244))) goto LAB_00560c4b;

      piVar9 = (int *)FUN_005088e0();

      iVar10 = FUN_00508890();

      iVar11 = 0;

      if (iVar10 != 0) {

        iVar11 = FUN_00452de0(iVar10,auStack_14);

      }

      if (((piVar9 == (int *)0x0) || (iVar10 == 0)) || (iVar11 == 0)) goto LAB_00560c4b;

      bVar5 = false;

      switch(param_4) {

      case 1:

        if (piVar9[0x2e] != 0) goto LAB_00560a68;

        if (piVar9[0x42] != 0) {

          uVar12 = piVar9[0x40] & 0x8044000;

          goto LAB_00560a66;

        }

        break;

      case 2:

        if (((piVar9[0x40] & 0x8044000U) != 0) || (iVar11 = FUN_0058d080(), iVar11 != 0)) {

          iVar11 = FUN_0056b210();

          FUN_00569e30();

          if (((*(int *)(iVar11 + 0x1c) != 2) && (*(int *)(iVar11 + 0x1c) != 4)) ||

             ((((cVar6 = FUN_0056b340(), cVar6 != '\0' && (cVar6 = FUN_00569ed0(), cVar6 == '\0'))

               && ((piVar9[0x40] & 0x200U) == 0)) && ((*(uint *)(iVar10 + 0xa8) & 0x200000) == 0))))

          break;

        }

        goto LAB_00560a68;

      case 3:

        FUN_0056b210();

        FUN_00569e30();

        cVar6 = FUN_0056b340();

        if ((((cVar6 == '\0') || ((piVar9[0x40] & 0x200U) != 0)) ||

            (iVar11 = FUN_0058d080(), iVar11 == 0)) || (cVar6 = FUN_00569ed0(), cVar6 != '\0'))

        goto LAB_00560a68;

        break;

      case 4:

        iVar11 = (**(code **)(*piVar9 + 0x10))();

        if (iVar11 != 0) {

          uVar12 = FUN_0058d080();

LAB_00560a66:

          if (uVar12 != 0) break;

        }

LAB_00560a68:

        bVar5 = true;

        break;

      case 5:

        iVar11 = (**(code **)(*piVar9 + 0x7c))();

        if ((iVar11 == 0) || (iVar11 = FUN_0058e9a0(), iVar11 != 0)) goto LAB_00560a68;

      }

      if ((char)piVar9[0x40] < '\0') {

        piStack_24 = (int *)piStack_24[1];

        if (piStack_24 != (int *)0x0) goto LAB_005608b0;

        do {

          puStack_28 = puStack_28 + 1;

          if (puStack_28 == (undefined4 *)(*(int *)(iVar8 + 0x60) + *(int *)(iVar8 + 0x68) * 4))

          goto LAB_00560c91;

          piStack_24 = (int *)*puStack_28;

        } while (piStack_24 == (int *)0x0);

      }

      else {

        if (((((param_5 == '\0') || (piVar9[0x2e] != *(int *)(param_1 + 0x1e8))) &&

             (piVar9[0x19] == 0)) && ((!bVar5 && (*(int *)(iVar10 + 0x90) != 0)))) &&

           ((*(uint *)(iVar10 + 0xa8) & 0x100000) == 0)) {

          FUN_00452de0(iVar10,&fStack_20);

          fVar13 = (float10)FUN_0055e500((double)fStack_20,(double)fStack_1c);

          fVar14 = (float10)FUN_0055e5a0();

          if ((float10)(double)fVar13 <= fVar14) {

            fVar14 = (float10)FUN_0055e530((double)fStack_18);

            dVar1 = (double)(fVar14 + (float10)(double)fVar13);

            if (((iVar2 != iVar7) || (param_3 != '\0')) && (iVar2 != *(int *)(param_1 + 0x1e8))) {

              if (param_2 == '\0') {

                cVar6 = FUN_0055e550(dVar1,iVar2,SUB84(uStack_48,0),uStack_48._4_4_,local_58);

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

                   (cVar6 = FUN_0055e550(dVar1,iVar2,SUB84(uStack_40,0),uStack_40._4_4_,iVar7),

                   cVar6 == '\x01')) {

LAB_00560c47:

                  local_58 = iVar2;

                  uStack_48 = dVar1;

                }

              }

              else {

                cVar6 = FUN_0055e550(dVar1,iVar2,SUB84(uStack_48,0),uStack_48._4_4_,local_58);

                if ((cVar6 == '\x01') &&

                   (cVar6 = FUN_0055e550(dVar1,iVar2,SUB84(uStack_40,0),uStack_40._4_4_,iVar7),

                   cVar6 == '\0')) goto LAB_00560c47;

              }

            }

          }

        }

LAB_00560c4b:

        piStack_24 = (int *)piStack_24[1];

        if (piStack_24 != (int *)0x0) goto LAB_005608b0;

        do {

          puStack_28 = puStack_28 + 1;

          if (puStack_28 == (undefined4 *)(*(int *)(iVar8 + 0x60) + *(int *)(iVar8 + 0x68) * 4))

          goto LAB_00560c91;

          piStack_24 = (int *)*puStack_28;

        } while (piStack_24 == (int *)0x0);

      }

    } while (piStack_24 != (int *)0x0);

LAB_00560c91:

    if (local_58 != 0) {

      FUN_0058d110(local_58,0);

    }

  }

  return;

}





// --- FUN_00560ce0 at 0x00560CE0 (size: 275) ---


undefined4 FUN_00560ce0(float param_1)



{

  int *piVar1;

  int iVar2;

  float10 fVar3;

  float10 extraout_ST1;

  undefined1 *puVar4;

  undefined *puVar5;

  int *piVar6;

  int **ppiVar7;

  undefined4 uVar8;

  int *local_18;

  undefined1 local_14 [4];

  undefined1 local_10 [4];

  int *local_c;

  undefined4 local_8;

  

  ppiVar7 = &local_18;

  puVar4 = local_14;

  puVar5 = &DAT_007cd5c8;

  local_18 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007cd5c8,ppiVar7);

  FUN_00406570(puVar4,puVar5,ppiVar7);

  piVar1 = local_18;

  uVar8 = 0;

  local_c = (int *)0x0;

  local_8 = 0;

  piVar6 = local_18;

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

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

  }

  FUN_004c1da0(local_10,piVar6,uVar8);

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

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

  }

  piVar1 = local_c;

  iVar2 = FUN_00508890(param_1);

  if ((iVar2 != 0) && (*(int *)(iVar2 + 0x90) != 0)) {

    FUN_00452de0(iVar2,&local_c);

    iVar2 = FUN_00451ec0();

    if (iVar2 == 0) {

      param_1 = DAT_007cd6c4;

    }

    else {

      param_1 = DAT_007cd6c0;

    }

    _CIpow();

    fVar3 = (float10)_CIpow();

    if (SQRT(fVar3 + extraout_ST1) < (float10)param_1) {

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

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

      }

      return 1;

    }

  }

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

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

  }

  return 0;

}





// --- FUN_00560e00 at 0x00560E00 (size: 303) ---


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



undefined4 FUN_00560e00(double *param_1,double *param_2)



{

  double *pdVar1;

  int *piVar2;

  double *pdVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined *puVar6;

  int *piVar7;

  undefined4 *puVar8;

  undefined4 uVar9;

  int local_10;

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  pdVar3 = param_2;

  pdVar1 = param_1;

  puVar8 = &param_1;

  puVar5 = &param_2;

  *(undefined4 *)param_1 = 0;

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

  puVar6 = &DAT_007cd5c8;

  *(undefined4 *)param_2 = 0;

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

  param_1 = (double *)0x0;

  FUN_00406d10(puVar5,&DAT_007cd5c8,puVar8);

  FUN_00406570(puVar5,puVar6,puVar8);

  piVar2 = (int *)param_1;

  uVar9 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar7 = (int *)param_1;

  if (param_1 != (double *)0x0) {

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

  }

  FUN_004c1da0(local_c,piVar7,uVar9);

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

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

  }

  piVar2 = local_8;

  iVar4 = FUN_00508890(*(undefined4 *)(local_10 + 0x1e8));

  if ((iVar4 != 0) && (*(int *)(iVar4 + 0x90) != 0)) {

    iVar4 = FUN_00511850(&param_1,&local_10);

    if (iVar4 != 0) {

      param_2 = (double *)(local_10 + -0x400);

      *pdVar1 = (double)(int)((int)param_1 + -0x400) * _DAT_007a7e00 + _DAT_00799088;

      *pdVar3 = (double)(int)param_2 * _DAT_007a7e00 + _DAT_00799088;

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

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

      }

      return 1;

    }

  }

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

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

  }

  return 0;

}





// --- FUN_00560f30 at 0x00560F30 (size: 66) ---


bool FUN_00560f30(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  char cVar1;

  int iVar2;

  

  cVar1 = FUN_0055fcb0(param_1,param_2,param_3);

  if (cVar1 != '\0') {

    iVar2 = FUN_005583f0(param_1);

    if (iVar2 != 0) {

      FUN_0058e3c0(*(undefined4 *)(iVar2 + 0xc0));

    }

  }

  return cVar1 != '\0';

}





// --- FUN_00560f80 at 0x00560F80 (size: 186) ---


undefined4 FUN_00560f80(void)



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int **ppiVar6;

  undefined4 uVar7;

  int *local_18;

  int local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar6 = &local_18;

  puVar4 = local_10;

  puVar5 = &DAT_007cd540;

  local_14 = 0;

  local_18 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007cd540,ppiVar6);

  FUN_00406570(puVar4,puVar5,ppiVar6);

  piVar2 = local_18;

  uVar7 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar3 = local_18;

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

    (**(code **)(*local_18 + 0x10))(local_18,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 (-1 < iVar1) {

      FUN_00590c20(0xbc,&local_14,0,0);

      if ((local_14 == 0xc) || (local_14 == 0xd)) {

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

        return 1;

      }

    }

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

  }

  return 0;

}





// --- FUN_00561040 at 0x00561040 (size: 174) ---


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



void __thiscall

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

            undefined1 param_6,undefined1 param_7,undefined4 param_8,undefined4 param_9,

            undefined4 param_10,undefined4 param_11)



{

  int *piVar1;

  int local_40;

  int local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined1 local_30;

  undefined1 local_2f;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  double local_18;

  double local_10;

  undefined1 local_8;

  

  for (piVar1 = *(int **)(param_1 + 0x2dc); piVar1 != (int *)0x0; piVar1 = (int *)piVar1[0x10]) {

    if ((*piVar1 == param_2) && (piVar1[1] == param_3)) {

      *(undefined1 *)(piVar1 + 0xe) = 1;

    }

  }

  local_10 = _DAT_008379a8 + (double)CONCAT44(param_9,param_8);

  local_3c = param_3;

  local_38 = param_4;

  local_34 = param_5;

  local_18 = _DAT_008379a8 + (double)CONCAT44(param_11,param_10);

  local_30 = param_6;

  local_2f = param_7;

  local_28 = param_8;

  local_24 = param_9;

  local_20 = param_10;

  local_1c = param_11;

  local_40 = param_2;

  local_8 = 0;

  FUN_0055f470(*(undefined4 *)(param_1 + 0x2dc),&local_40);

  return;

}





// --- FUN_005610f0 at 0x005610F0 (size: 138) ---


undefined4 FUN_005610f0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined **local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_0055a0c0();

  if (param_2 < 4) {

    return 0;

  }

  iVar3 = 0;

  iVar1 = *(int *)*param_1;

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

  local_10 = &PTR_FUN_007acafc;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  if (0 < iVar1) {

    do {

      iVar2 = (*(code *)local_10[4])(param_1,param_2);

      if (iVar2 == 0) {

        return 0;

      }

      FUN_00558850(&local_10);

      iVar3 = iVar3 + 1;

    } while (iVar3 < iVar1);

  }

  return 1;

}





// --- FUN_00561180 at 0x00561180 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007cd7b0;

  FUN_0055a0c0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005611b0 at 0x005611B0 (size: 36) ---


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



{

  *param_1 = &PTR_FUN_007cd7c4;

  FUN_0055ffe0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005611e0 at 0x005611E0 (size: 542) ---


undefined4 * __fastcall FUN_005611e0(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int *piVar3;

  LONG *lpAddend;

  undefined1 *puVar4;

  undefined *puVar5;

  int *piVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  undefined1 local_18 [4];

  undefined1 local_14 [4];

  undefined4 local_10;

  undefined4 local_c;

  

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_FUN_00795824;

  param_1[3] = &PTR_LAB_007a6af4;

  param_1[4] = &PTR_LAB_007b405c;

  puVar1 = param_1 + 1;

  puVar2 = param_1 + 3;

  *param_1 = &PTR_LAB_007cdcc0;

  *puVar1 = &PTR_FUN_007cda18;

  param_1[2] = &PTR_FUN_007cda08;

  *puVar2 = &PTR_LAB_007cda00;

  param_1[4] = &PTR_LAB_007cd9f8;

  param_1[6] = 1;

  param_1[5] = &PTR_LAB_00793b6c;

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

  param_1[7] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  FUN_0059b760();

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

  param_1[0x7c] = 0;

  param_1[0x7d] = 0;

  param_1[0x7e] = 0;

  param_1[0x7f] = 0;

  param_1[0x80] = 0;

  param_1[0x81] = 0;

  param_1[0x82] = 0;

  param_1[0x83] = 0;

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

  *(undefined1 *)((int)param_1 + 0x221) = 0;

  *(undefined1 *)((int)param_1 + 0x222) = 0;

  *(undefined1 *)((int)param_1 + 0x223) = 0;

  param_1[0x8a] = 0;

  param_1[0x8b] = 0;

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

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

  FUN_0055e680();

  param_1[0xb3] = 0;

  param_1[0xb4] = 0;

  param_1[0xb6] = &PTR_FUN_007cd7c4;

  param_1[0xb7] = 0;

  param_1[0xb8] = 0;

  param_1[0xb9] = 0;

  FUN_0059a250();

  DAT_0087119c = param_1;

  InterlockedIncrement(param_1 + 6);

  FUN_0055e130();

  local_10 = 0;

  local_c = 0;

  FUN_0055f4f0(local_18,param_1 + 0xc);

  uVar8 = 0;

  puVar4 = local_14;

  puVar5 = &DAT_007cd520;

  uVar7 = local_10;

  FUN_00406d10(puVar4,&DAT_007cd520,local_10,0);

  FUN_00406a90(puVar4,puVar5,uVar7,uVar8);

  piVar6 = (int *)0x1;

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

  (**(code **)(*DAT_008f958c + 8))(8,1,puVar2);

  (**(code **)(*DAT_008f958c + 8))(1,0xe6,puVar2);

  piVar3 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar3 + 4))(0x186a8,puVar1);

    (**(code **)(*piVar3 + 4))(0x186ab,puVar1);

    (**(code **)(*piVar3 + 4))(0x186a9,puVar1);

    (**(code **)(*piVar3 + 4))(0x186aa,puVar1);

    (**(code **)(*piVar3 + 4))(0x4dd201,puVar1);

    (**(code **)(*piVar3 + 4))(0x4dd1f6,puVar1);

  }

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

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

  }

  return param_1;

}





// --- FUN_00561400 at 0x00561400 (size: 37) ---


int __fastcall FUN_00561400(int param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

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

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

  }

  return iVar1;

}





// --- FUN_00561430 at 0x00561430 (size: 94) ---


void __fastcall FUN_00561430(int param_1)



{

  void *pvVar1;

  

  FUN_0055ffe0();

  FUN_004c65a0();

  FUN_005d59f0();

  FUN_0055e9c0();

  pvVar1 = *(void **)(param_1 + 0x2d4);

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

    FUN_00587a40();

    operator_delete(pvVar1);

  }

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

  FUN_005d1400();

  return;

}





// --- FUN_00561670 at 0x00561670 (size: 158) ---


void FUN_00561670(undefined4 param_1)



{

  int iVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 *local_8;

  undefined4 *local_4;

  

  FUN_005444d0(L"3rd party API not in use.");

  iVar1 = FUN_0055b0a0();

  if (iVar1 != 0) {

    piVar2 = (int *)FUN_0055a740();

    (**(code **)(*piVar2 + 0xc))(piVar2,&local_4);

    FUN_0055f580(local_4);

  }

  FUN_00546290(&local_4,0);

  FUN_006ae970(param_1,&local_4);

  LVar3 = InterlockedDecrement(local_4 + 1);

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

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

  }

  LVar3 = InterlockedDecrement(local_8 + 1);

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

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

  }

  return;

}





// --- FUN_00561710 at 0x00561710 (size: 23) ---


uint FUN_00561710(int param_1,int param_2,undefined4 param_3)



{

  uint uVar1;

  int iVar2;

  char cVar3;

  int iVar4;

  uint uVar5;

  bool bVar6;

  

  iVar4 = FUN_0058de80(0);

  iVar2 = param_1;

  if (iVar4 == 0) {

    return 0;

  }

  iVar4 = FUN_005583f0(param_1);

  uVar5 = 0;

  if (iVar4 != 0) {

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

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

      param_1 = 0;

      uVar5 = FUN_00560f30(iVar2,&param_1,param_3);

      uVar5 = uVar5 & 0xff;

      if (param_1 != 0) goto LAB_0056173d;

      bVar6 = uVar5 == 0;

      if (!bVar6) goto LAB_005617bf;

    }

    if ((param_2 != 0) && ((uVar1 & 0x7eff8000) != 0)) {

      cVar3 = FUN_005617d0(iVar2,2,1,0,0,1);

      bVar6 = cVar3 == '\0';

      if (!bVar6) goto LAB_005617bf;

    }

    uVar5 = FUN_0058df90();

    if (uVar5 == 0) {

      cVar3 = FUN_0055e5e0(iVar2,0);

      bVar6 = cVar3 == '\0';

LAB_005617bf:

      return (uint)!bVar6;

    }

  }

LAB_0056173d:

  return uVar5 & 0xffffff00;

}





// --- FUN_00561727 at 0x00561727 (size: 162) ---


uint FUN_00561727(undefined4 param_1,int param_2,int param_3,undefined4 param_4)



{

  uint uVar1;

  int iVar2;

  char cVar3;

  int iVar4;

  uint uVar5;

  bool bVar6;

  

  iVar2 = param_2;

  iVar4 = FUN_005583f0(param_2);

  uVar5 = 0;

  if (iVar4 != 0) {

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

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

      param_2 = 0;

      uVar5 = FUN_00560f30(iVar2,&param_2,param_4);

      uVar5 = uVar5 & 0xff;

      if (param_2 != 0) goto LAB_0056173d;

      bVar6 = uVar5 == 0;

      if (!bVar6) goto LAB_005617bf;

    }

    if ((param_3 != 0) && ((uVar1 & 0x7eff8000) != 0)) {

      cVar3 = FUN_005617d0(iVar2,2,1,0,0,1);

      bVar6 = cVar3 == '\0';

      if (!bVar6) goto LAB_005617bf;

    }

    uVar5 = FUN_0058df90();

    if (uVar5 == 0) {

      cVar3 = FUN_0055e5e0(iVar2,0);

      bVar6 = cVar3 == '\0';

LAB_005617bf:

      return (uint)!bVar6;

    }

  }

LAB_0056173d:

  return uVar5 & 0xffffff00;

}





// --- FUN_005617d0 at 0x005617D0 (size: 3630) ---


bool __thiscall

FUN_005617d0(int param_1,int param_2,int param_3,int param_4,int param_5,int param_6,int param_7)



{

  char cVar1;

  undefined1 uVar2;

  int iVar3;

  undefined4 *puVar4;

  int *piVar5;

  int iVar6;

  int iVar7;

  uint uVar8;

  uint uVar9;

  uint uVar10;

  bool bVar11;

  uint uVar12;

  undefined4 uVar13;

  uint local_a4;

  int local_a0;

  uint local_9c;

  int local_98;

  undefined1 local_94 [4];

  undefined1 local_90 [144];

  

  iVar3 = FUN_0058de80(param_4);

  if (iVar3 == 0) {

    return false;

  }

  bVar11 = false;

  local_a0 = 0;

  iVar3 = FUN_005583f0(param_2);

  if (iVar3 == 0) {

    return false;

  }

  local_98 = iVar3;

  if ((*(int *)(iVar3 + 0xb8) != 0) && (*(int *)(iVar3 + 0xb8) != *(int *)(param_1 + 0x1e8))) {

    if (param_4 != 0) {

      return false;

    }

    puVar4 = (undefined4 *)FUN_0058f8b0(&local_a4,2,0);

    FUN_00480980(&local_98,0,L"The %s is being wielded by someone else",*puVar4);

    FUN_004011b0();

    FUN_0042dc80();

    FUN_0042cbe0(&local_98,1);

    FUN_00693500(0x1a,local_90);

    FUN_0042e590();

    FUN_004011b0();

    return false;

  }

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

  if ((local_9c & 0x7fffffff) == 0) {

    return false;

  }

  cVar1 = FUN_0055fad0(param_2,param_4);

  if (cVar1 == '\0') {

    if (param_6 == 0) {

      return false;

    }

    iVar3 = FUN_0058df90();

    if (iVar3 != 0) {

      return false;

    }

    uVar2 = FUN_00561710(param_2,0,0);

    return (bool)uVar2;

  }

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

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

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

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

  if ((local_9c & 0x8000) == 0) {

LAB_005619a1:

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

      if ((*(uint *)(param_1 + 0x230) & 0x4000000) == 0) {

        uVar12 = 0x4000000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x274);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing a trinket.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x8000000) == 0) {

        uVar12 = 0x8000000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x278);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing a cloak.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x10000000) == 0) {

        uVar12 = 0x10000000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x27c);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already using aetheria of Lyr.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x20000000) == 0) {

        uVar12 = 0x20000000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x280);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already using aetheria of Kor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x40000000) == 0) {

        uVar12 = 0x40000000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x284);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already using aetheria of Tem.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

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

        uVar12 = 1;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x288);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing a helm.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x200) == 0) {

        uVar12 = 0x200;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x28c);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing chest armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x400) == 0) {

        uVar12 = 0x400;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x290);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing abdomen armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x800) == 0) {

        uVar12 = 0x800;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x294);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing upper arm armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x1000) == 0) {

        uVar12 = 0x1000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x298);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing lower arm armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

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

        uVar12 = 0x20;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x29c);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing hand armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x2000) == 0) {

        uVar12 = 0x2000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x2a0);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing upper leg armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

      if ((*(uint *)(param_1 + 0x230) & 0x4000) == 0) {

        uVar12 = 0x4000;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x2a4);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing lower leg armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

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

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

        uVar12 = 0x100;

        goto LAB_00562095;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x2a8);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing foot armor.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

    local_a4 = local_9c & 0x30000;

    if ((local_a4 != 0) || ((local_9c & 0xc0000) != 0)) {

      if (local_a4 == 0) {

        if (param_3 == 1) {

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

          iVar7 = *(int *)(param_1 + 0x25c);

        }

        else {

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

          iVar7 = *(int *)(param_1 + 0x254);

        }

      }

      else if (param_3 == 1) {

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

        iVar7 = *(int *)(param_1 + 600);

      }

      else {

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

        iVar7 = *(int *)(param_1 + 0x250);

      }

      uVar12 = piVar5[1];

      if (((*(uint *)(param_1 + 0x230) & uVar12) == 0) ||

         (((param_7 != 0 && (*piVar5 != param_2)) &&

          (uVar12 = *(uint *)(iVar7 + 4), (*(uint *)(param_1 + 0x230) & uVar12) == 0))))

      goto LAB_00562095;

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

      if (param_5 == 0) {

        if (local_a4 == 0) {

          FUN_0042dc80();

          FUN_00402730(L"You\'re already wearing jewelry on both hands.");

          FUN_0042cbe0(&local_a4,1);

          FUN_004011b0();

        }

        else {

          FUN_0042dc80();

          FUN_00402730(L"You\'re already wearing jewelry on both wrists.");

          FUN_0042cbe0(&local_a4,1);

          FUN_004011b0();

        }

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

    }

  }

  else {

    if ((*(uint *)(param_1 + 0x230) & 0x8000) != 0) {

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x24c);

      if (param_5 == 0) {

        FUN_0042dc80();

        FUN_00402730(L"You\'re already wearing jewelry on your neck.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

      }

      goto LAB_005619a1;

    }

    uVar12 = 0x8000;

LAB_00562095:

    FUN_0058e3c0(uVar12);

    bVar11 = true;

    local_a0 = 1;

  }

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

    local_9c = 0x200000;

  }

  bVar11 = !bVar11;

  if (!bVar11) goto LAB_005625ee;

  uVar12 = local_9c & 0x3500000;

  if (uVar12 != 0) {

    if ((*(uint *)(param_1 + 0x230) & 0x3500000) == 0) {

      iVar7 = **(int **)(param_1 + 0x268);

      if ((iVar7 == 0) || (iVar6 = FUN_0055e100(), iVar6 == 0)) {

        iVar7 = **(int **)(param_1 + 0x264);

        if ((*(int *)(iVar3 + 0xe8) != 0) &&

           (((iVar7 != 0 && (iVar6 = FUN_005583f0(iVar7), iVar6 != 0)) &&

            (*(int *)(iVar3 + 0xe8) != *(int *)(iVar6 + 0xe8))))) {

          *(int *)(param_1 + 0x2ac) = iVar7;

        }

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

          FUN_0058e3c0(uVar12);

          return true;

        }

      }

      else {

        *(int *)(param_1 + 0x2ac) = iVar7;

      }

    }

    else {

      iVar7 = FUN_00588720(param_2,**(undefined4 **)(param_1 + 0x260),1);

      if (iVar7 != 0) {

        return true;

      }

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x260);

    }

  }

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

    if ((*(uint *)(param_1 + 0x230) & 0x200000) == 0) {

      FUN_0058e3c0(0x200000);

      return true;

    }

    *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x268);

  }

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

    if ((*(uint *)(param_1 + 0x230) & 0x800000) == 0) {

      FUN_0058e3c0(0x800000);

      return true;

    }

    iVar7 = FUN_00588720(param_2,**(undefined4 **)(param_1 + 0x264),1);

    if (iVar7 != 0) {

      return true;

    }

    iVar7 = FUN_005583f0(**(undefined4 **)(param_1 + 0x264));

    if ((iVar7 == 0) || (*(int *)(iVar7 + 0xa4) != *(int *)(iVar3 + 0xa4))) {

      *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x264);

    }

    else if (param_4 == 0) {

      puVar4 = (undefined4 *)FUN_0058f8b0(local_94,1,0);

      FUN_00480980(&local_a4,0,L"You cannot wield more %s",*puVar4);

      FUN_004011b0();

      FUN_0042dc80();

      FUN_0042cbe0(&local_a4,1);

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

      FUN_004011b0();

    }

  }

  if ((local_9c & 0x80001ff) == 0) {

LAB_00562496:

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

    if (iVar3 != 0) {

      if (param_5 != 0) {

        if (iVar3 == param_2) {

          return false;

        }

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

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

        *(int *)(param_1 + 0x2c0) = param_3;

        puVar4 = (undefined4 *)FUN_0058f8e0(local_94,iVar3,2,0);

        FUN_00480980(&local_98,0,L"Moving %s to your backpack",*puVar4);

        FUN_004011b0();

        iVar3 = FUN_00588f70(*(undefined4 *)(param_1 + 0x2ac),*(undefined4 *)(param_1 + 0x1e8),0,1,0

                            );

        if (iVar3 == 0) {

          iVar3 = FUN_005583f0(*(undefined4 *)(param_1 + 0x2ac));

          if (iVar3 != 0) {

            puVar4 = (undefined4 *)FUN_0058f8e0(local_94,*(undefined4 *)(param_1 + 0x2ac),2,0);

            FUN_004300a0(&local_98,L" - cannot unwield the %s",*puVar4);

            FUN_004011b0();

          }

          FUN_0055e660();

          iVar3 = local_a0;

        }

        else {

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

          iVar3 = 1;

        }

        FUN_0042dc80();

        FUN_0042cbe0(&local_98,1);

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

        FUN_004011b0();

        return iVar3 != 0;

      }

      FUN_0055e660();

    }

  }

  else {

    uVar12 = *(uint *)(param_1 + 0x230);

    uVar8 = local_9c & 0x40;

    uVar10 = uVar12 & 2;

    uVar9 = uVar12 & 0x40;

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

      if ((uVar8 == 0) || (uVar9 != 0)) {

LAB_0056242d:

        if (((local_9c & 0x8000000) == 0) || ((uVar12 & 0x8000000) != 0)) {

          if (((local_9c & 2) == 0) || (uVar10 == 0)) {

            if ((uVar8 == 0) || (uVar9 == 0)) {

              if (((local_9c & 0x8000000) != 0) && ((uVar12 & 0x8000000) != 0)) {

                *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x278);

              }

            }

            else {

              *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x26c);

            }

          }

          else {

            *(undefined4 *)(param_1 + 0x2ac) = **(undefined4 **)(param_1 + 0x270);

          }

          goto LAB_00562496;

        }

        uVar13 = 0x8000000;

      }

      else {

        uVar13 = 0x40;

      }

    }

    else if (uVar8 == 0) {

      if (uVar10 != 0) goto LAB_0056242d;

      uVar13 = 2;

    }

    else {

      if ((uVar10 != 0) || (uVar9 != 0)) {

        FUN_0042dc80();

        FUN_00402730(L"You must unwield your shirt and pants to wield that.");

        FUN_0042cbe0(&local_a4,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

        goto LAB_00562496;

      }

      uVar13 = 0x42;

    }

    FUN_0058e3c0(uVar13);

    local_a0 = 1;

  }

  bVar11 = local_a0 == 0;

LAB_005625ee:

  return !bVar11;

}





// --- FUN_00563660 at 0x00563660 (size: 418) ---


void __fastcall FUN_00563660(undefined4 *param_1)



{

  void *pvVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 *puVar4;

  int iVar5;

  

  puVar4 = param_1 + 1;

  param_1[-2] = &PTR_LAB_007cdcc0;

  param_1[-1] = &PTR_FUN_007cda18;

  *param_1 = &PTR_FUN_007cda08;

  *puVar4 = &PTR_LAB_007cda00;

  param_1[2] = &PTR_LAB_007cd9f8;

  FUN_00561430();

  (**(code **)(*DAT_008f958c + 0x10))(1,5,-(uint)(param_1 != (undefined4 *)0x8) & (uint)puVar4);

  iVar5 = 1;

  (**(code **)(*DAT_008f958c + 0x10))(8,1,-(uint)(param_1 != (undefined4 *)0x8) & (uint)puVar4);

  (**(code **)(*DAT_008f958c + 0x10))(1,0xe6,-(uint)(param_1 != (undefined4 *)0x8) & (uint)puVar4);

  piVar2 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar2 + 0xc))(-(uint)(param_1 != (undefined4 *)0x8) & (uint)(param_1 + -1));

  }

  pvVar1 = (void *)param_1[9];

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

    FUN_00564700();

    operator_delete(pvVar1);

  }

  param_1[9] = 0;

  param_1[0xb8] = &PTR_FUN_007cd910;

  param_1[0xb9] = &PTR_FUN_007a7980;

  FUN_005d1400();

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

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

    param_1[0xbb] = 0;

  }

  param_1[0xbc] = 0;

  param_1[0xb9] = &PTR_FUN_0079385c;

  param_1[0xb8] = &PTR_FUN_0079385c;

  param_1[0xb4] = &PTR_FUN_007cd7c4;

  FUN_0055ffe0();

  FUN_004c65a0();

  FUN_0055f240();

  FUN_0059b5e0();

  puVar4 = (undefined4 *)param_1[5];

  LVar3 = InterlockedDecrement(puVar4 + 1);

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

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

  }

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

  param_1[3] = &PTR_LAB_00793b6c;

  *puVar4 = &PTR_FUN_00795824;

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

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

  }

  if (iVar5 != 0) {

    *(undefined ***)(iVar5 + 4) = &PTR_FUN_007ccb60;

    FUN_0043c610();

    return;

  }

  ppuRam00000000 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_00563810 at 0x00563810 (size: 348) ---


void FUN_00563810(undefined4 param_1,undefined4 param_2)



{

  undefined *puVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined4 uVar4;

  LONG LVar5;

  int unaff_EBX;

  undefined *local_94;

  undefined1 auStack_90 [144];

  

  puVar2 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  puVar1 = PTR_DAT_00818340;

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

  iVar3 = FUN_004fd460(&param_1,param_2);

  if ((iVar3 == 0) || (puVar2[2] == 1)) {

    FUN_00407e40(L" for Code of Conduct Violations");

  }

  else {

    uVar4 = FUN_00404a40(0,puVar2 + 5);

    FUN_00402070(uVar4);

    LVar5 = InterlockedDecrement(puVar2 + -4);

    if ((LVar5 == 0) && (puVar2 + -5 != (undefined4 *)0x0)) {

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

    }

  }

  local_94 = PTR_DAT_00818340;

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

  FUN_004027b0(&local_94,L"You have been booted from Asheron\'s Call%s.",puVar1);

  FUN_0042dc80();

  FUN_0042cbe0(&local_94,1);

  (**(code **)(*DAT_0083e72c + 0x20))(0x10000002,auStack_90);

  FUN_0042e590();

  LVar5 = InterlockedDecrement(puVar2 + -4);

  if ((LVar5 == 0) && (puVar2 + -5 != (undefined4 *)0x0)) {

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

  }

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

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

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

  }

  LVar5 = InterlockedDecrement(puVar2 + 1);

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

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

  }

  return;

}





// --- FUN_00563970 at 0x00563970 (size: 505) ---


void FUN_00563970(int *param_1,undefined4 param_2)



{

  undefined *puVar1;

  char *pcVar2;

  int iVar3;

  undefined4 uVar4;

  LONG LVar5;

  tm *_Tm;

  char *pcVar6;

  int iVar7;

  char *pcVar8;

  undefined4 *unaff_EBX;

  undefined4 *puVar9;

  code *pcVar10;

  undefined *local_9c;

  int local_98;

  int local_94;

  undefined1 auStack_90 [144];

  

  puVar1 = PTR_DAT_00818340;

  iVar7 = *param_1;

  param_1 = param_1 + 1;

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

  local_98 = DAT_008ef11c;

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

  iVar3 = FUN_004fd460(&param_1,param_2);

  if ((iVar3 != 0) && (*(int *)(local_98 + 8) != 1)) {

    uVar4 = FUN_00404a40(0,local_98 + 0x14);

    FUN_00402070(uVar4);

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

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

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

      (**(code **)*puVar9)(1);

    }

  }

  local_9c = PTR_DAT_00818340;

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

  if (iVar7 < 1) {

    FUN_004027b0(&local_9c,L"You have been banned from Asheron\'s Call%s.",puVar1);

    pcVar10 = InterlockedDecrement_exref;

  }

  else {

    local_94 = FUN_0040fa90();

    if (local_94 % 0x3c != 0) {

      local_94 = local_94 + (0x3c - local_94 % 0x3c);

    }

    local_94 = local_94 + iVar7;

    _Tm = localtime((time_t *)&local_94);

    pcVar6 = asctime(_Tm);

    pcVar2 = pcVar6;

    do {

      pcVar8 = pcVar2;

      pcVar2 = pcVar8 + 1;

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

    pcVar8[-1] = '\0';

    FUN_00404a40(0,pcVar6);

    FUN_004027b0(&local_9c,

                 L"You have been banned until %s%s. For ban appeals, please visit support.turbine.com"

                 ,puVar1,puVar1);

    pcVar10 = InterlockedDecrement_exref;

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

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

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

    }

  }

  FUN_0042dc80();

  FUN_0042cbe0(&local_9c,1);

  (**(code **)(*DAT_0083e72c + 0x20))(0x10000002,auStack_90);

  FUN_0042e590();

  iVar7 = (*pcVar10)(unaff_EBX + -4);

  if ((iVar7 == 0) && (unaff_EBX + -5 != (undefined4 *)0x0)) {

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

  }

  iVar7 = (*pcVar10)(unaff_EBX + 1);

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

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

  }

  iVar7 = (*pcVar10)(puVar1 + -0x10);

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

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

  }

  return;

}





// --- FUN_00563b70 at 0x00563B70 (size: 180) ---


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



void __fastcall FUN_00563b70(int param_1)



{

  LONG LVar1;

  int *piVar2;

  int iVar3;

  undefined4 *puVar4;

  int local_4;

  

  local_4 = param_1;

  FUN_00404a40(0,"Logging off...\n");

  FUN_005649f0(&local_4,0,1,0);

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

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

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

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

  }

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

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

  *(double *)(param_1 + 0x1f8) = _DAT_008379a8 + _DAT_007cd568;

  piVar2 = (int *)FUN_005583f0(*(undefined4 *)(param_1 + 0x1e8));

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

    iVar3 = (**(code **)(*piVar2 + 0x1c))();

    if (iVar3 != 0) {

      *(double *)(param_1 + 0x1f8) = *(double *)(param_1 + 0x1f8) + _DAT_0079a1a8;

    }

  }

  (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x94))();

  return;

}





// --- FUN_00563c30 at 0x00563C30 (size: 143) ---


void __fastcall FUN_00563c30(int param_1)



{

  int iVar1;

  int *piVar2;

  

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

  if (iVar1 != 0) {

    iVar1 = FUN_0058ce30();

    if (iVar1 != 0) {

      FUN_006a22a0();

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

        FUN_00593e30();

        iVar1 = FUN_0055b0a0();

        if (iVar1 != 0) {

          piVar2 = (int *)FUN_0055a740();

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

          FUN_00561670(0);

        }

      }

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

      FUN_0047a400(1);

      FUN_0045b4c0(0xb,0);

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

      return;

    }

  }

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

  return;

}





// --- FUN_00563cc0 at 0x00563CC0 (size: 70) ---


void __fastcall FUN_00563cc0(int param_1)



{

  int iVar1;

  

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

  if ((*(char *)(param_1 + 0x216) != '\0') && (iVar1 != 0)) {

    iVar1 = FUN_0058ce30();

    if ((iVar1 != 0) && (*(undefined1 *)(param_1 + 0x214) = 1, *(char *)(param_1 + 0x212) != '\0'))

    {

      FUN_00563c30();

      return;

    }

  }

  return;

}





// --- FUN_00563d10 at 0x00563D10 (size: 334) ---


bool FUN_00563d10(int param_1,undefined4 param_2,int param_3)



{

  char cVar1;

  undefined2 uVar2;

  int iVar3;

  int iVar4;

  

  cVar1 = '\0';

  if (param_1 == 0) {

    return false;

  }

  iVar3 = FUN_005583f0(param_1);

  if (iVar3 != 0) {

    if (param_3 == 0) {

      uVar2 = FUN_00589290(iVar3);

      switch(uVar2) {

      case 2:

        cVar1 = FUN_0055e5e0(param_1,0);

        break;

      case 3:

        cVar1 = FUN_005617d0(param_1,2,0,1,0,1);

        break;

      case 4:

        cVar1 = FUN_00561710(param_1,1,0);

        break;

      case 5:

        iVar4 = param_1;

        FUN_0056e6b0(param_1);

        cVar1 = FUN_0056ec90(iVar4);

        break;

      case 6:

        FUN_006ad4f0(param_1);

        cVar1 = '\x01';

        break;

      case 7:

        FUN_006a9e60(param_1);

        break;

      case 8:

        cVar1 = FUN_005617d0(param_1,1,0,1,0,1);

      }

    }

    FUN_004fd850(*(undefined4 *)(iVar3 + 0xd8));

    iVar4 = FUN_0058df90();

    if ((iVar4 != 0) && (iVar4 = FUN_004a48a0(), iVar4 != 0)) {

      FUN_0047a1b0(*(undefined4 *)(iVar3 + 8));

      cVar1 = '\x01';

    }

    iVar3 = FUN_004fd860();

    if ((iVar3 != 0) && (iVar3 = FUN_004fd8b0(), iVar3 == 0)) {

      iVar3 = FUN_004a48a0();

      if ((iVar3 != 0) && (iVar3 = FUN_0058df90(), iVar3 == 0)) {

        FUN_00588200(param_1);

        cVar1 = '\x01';

      }

    }

    return cVar1 != '\0';

  }

  return false;

}





// --- FUN_00563e80 at 0x00563E80 (size: 34) ---


int __thiscall FUN_00563e80(int param_1,byte param_2)



{

  FUN_00563660();

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

    operator_delete((void *)(param_1 + -8));

  }

  return param_1 + -8;

}





// --- FUN_00563eb0 at 0x00563EB0 (size: 332) ---


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



void __fastcall FUN_00563eb0(int param_1)



{

  int iVar1;

  float10 fVar2;

  int *piVar3;

  int iStack_14;

  undefined4 local_10;

  undefined4 uStack_c;

  

  local_10 = DAT_008379a8;

  uStack_c = DAT_008379ac;

  if ((*(char *)(param_1 + 0x211) != '\0') && (*(char *)(param_1 + 0x210) != '\0')) {

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

    iVar1 = (**(code **)(*DAT_0083e72c + 0x24))();

    if (iVar1 != 0) {

      FUN_00560600(*(undefined4 *)(iVar1 + 0x4c));

    }

  }

  if ((*(double *)(param_1 + 0x1f0) != _DAT_00795610) &&

     (_DAT_007cd5d8 <= (double)CONCAT44(uStack_c,local_10) - *(double *)(param_1 + 0x1f0))) {

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

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

    FUN_00693a20();

  }

  if (_DAT_007cd560 <

      (double)CONCAT44(uStack_c,local_10) - (double)CONCAT44(_DAT_0087128c,_DAT_00871288)) {

    piVar3 = &iStack_14;

    FUN_004114c0(piVar3);

    fVar2 = (float10)FUN_004116e0(piVar3);

    if ((*(char *)(param_1 + 0x222) == '\0') &&

       (((float10)_DAT_007cd5e8 < fVar2 || (iStack_14 == 0)))) {

      FUN_00693a20();

    }

    _DAT_00871288 = local_10;

    _DAT_0087128c = uStack_c;

  }

  FUN_0059b720();

  if ((*(char *)(param_1 + 0x220) != '\0') && (DAT_00871ed0 == 0)) {

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

    FUN_00563b70();

  }

  if ((*(char *)(param_1 + 0x223) != '\0') &&

     (*(double *)(param_1 + 0x228) <= (double)CONCAT44(uStack_c,local_10))) {

    FUN_006939e0(0x18);

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

  }

  FUN_005600d0();

  return;

}





// --- FUN_005642c0 at 0x005642C0 (size: 77) ---


void __thiscall FUN_005642c0(int param_1,char param_2)



{

  FUN_0059b670(0);

  if (param_2 != '\0') {

    FUN_0055e4a0();

    return;

  }

  if (DAT_00871ed0 == 0) {

    FUN_00563b70();

    return;

  }

  FUN_004882f0("Logging off...\n",0,1,0);

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

  return;

}





// --- FUN_00564310 at 0x00564310 (size: 297) ---


void __fastcall FUN_00564310(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  int local_4;

  

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

    return;

  }

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

  uVar2 = DAT_008379ac;

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

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

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

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

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

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

  local_4 = param_1;

  FUN_005583f0(uVar2);

  FUN_0058d850();

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

    while( true ) {

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

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

        iVar4 = 0;

      }

      else {

        iVar4 = piVar1[1];

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

        if (iVar4 == 0) {

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

        }

        iVar4 = *piVar1;

        operator_delete(piVar1);

      }

      if (iVar4 == 0) break;

      iVar4 = FUN_005583f0(iVar4);

      if (iVar4 != 0) {

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

          FUN_00567c00();

          uVar2 = FUN_00567c10();

          iVar3 = FUN_005df0f5(0x108);

          if (iVar3 == 0) {

            uVar2 = 0;

          }

          else {

            uVar2 = FUN_005875a0(uVar2);

          }

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

        }

        FUN_00587c10(iVar4,&local_4);

      }

    }

  }

  FUN_006a45f0(1);

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

    FUN_00563cc0();

  }

  FUN_006ab960();

  return;

}





// --- FUN_00564440 at 0x00564440 (size: 539) ---


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



{

  int *piVar1;

  int *unaff_EBP;

  int iVar2;

  undefined1 *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined *puVar6;

  undefined4 *puVar7;

  undefined4 uVar8;

  int *local_38;

  undefined4 local_34;

  undefined **local_30;

  undefined4 local_2c;

  undefined4 uStack_28;

  undefined4 uStack_24;

  undefined **ppuStack_20;

  undefined4 uStack_1c;

  undefined4 uStack_18;

  undefined4 uStack_14;

  int iStack_c;

  int *piStack_8;

  int iStack_4;

  

  puVar7 = &param_3;

  iVar2 = param_2 + (int)param_3;

  ppiVar5 = &local_38;

  puVar6 = &DAT_007cd540;

  param_3 = (int *)0x0;

  FUN_00406d10(ppiVar5,&DAT_007cd540,puVar7);

  FUN_00406570(ppiVar5,puVar6,puVar7);

  piVar1 = param_3;

  uVar8 = 0;

  local_30 = (undefined **)0x0;

  local_2c = 0;

  piVar4 = param_3;

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

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

  }

  FUN_0048bb00(&local_34,piVar4,uVar8);

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

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

  }

  if (local_30 != (undefined **)0x0) {

    (**(code **)(local_30[0xc] + 0x10))(&param_2,iVar2 - param_2);

    FUN_005d59f0();

    (**(code **)(*(int *)(param_1 + 0x34) + 0x10))(&iStack_4,iVar2 - iStack_4);

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

    ppuStack_20 = &PTR_FUN_007cd418;

    uStack_1c = 0;

    uStack_18 = 0;

    uStack_14 = 0;

    local_30 = &PTR_FUN_007cd7b0;

    local_2c = 0;

    uStack_28 = 0;

    uStack_24 = 0;

    FUN_0055bc20(&iStack_c,iVar2 - iStack_c);

    FUN_005610f0(&iStack_c,iVar2 - iStack_c);

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

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

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

    }

    ppiVar5 = &piStack_8;

    puVar3 = &stack0xffffffbc;

    puVar6 = &DAT_007cd5c8;

    piStack_8 = (int *)0x0;

    FUN_00406d10(puVar3,&DAT_007cd5c8,ppiVar5);

    FUN_00406570(puVar3,puVar6,ppiVar5);

    piVar1 = piStack_8;

    uVar8 = 0;

    local_38 = (int *)0x0;

    local_34 = 0;

    piVar4 = piStack_8;

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

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

    }

    FUN_004c1da0(&stack0xffffffb8,piVar4,uVar8);

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

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

    }

    FUN_005596b0(iVar2,&ppuStack_20);

    FUN_0055a190(iVar2,&local_30);

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

      FUN_00564310();

    }

    FUN_0059b6a0();

    FUN_0047a200(unaff_EBP,param_1 + 0x30);

    FUN_006a3680();

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

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

    }

    local_30 = &PTR_FUN_007cd7b0;

    FUN_0055a0c0();

    local_30 = &PTR_FUN_0079385c;

    ppuStack_20 = &PTR_FUN_007cd418;

    FUN_0055b780();

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

  }

  return;

}





// --- FUN_00564660 at 0x00564660 (size: 72) ---


undefined4 * __fastcall FUN_00564660(undefined4 *param_1)



{

  undefined4 uVar1;

  

  FUN_005c7a30();

  *param_1 = &PTR_LAB_007ce660;

  param_1[0x96] = 0;

  param_1[0x97] = 0;

  param_1[0x98] = 0;

  uVar1 = FUN_00415730(1,0x10000008,10);

  param_1[0x96] = uVar1;

  uVar1 = FUN_0053efe0();

  param_1[0x97] = uVar1;

  return param_1;

}





// --- FUN_00564700 at 0x00564700 (size: 43) ---


void __fastcall FUN_00564700(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007ce660;

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

  FUN_0053ed10(param_1[0x97]);

  FUN_005c5db0();

  return;

}





// --- FUN_00564730 at 0x00564730 (size: 129) ---


undefined4 FUN_00564730(undefined4 param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int *piVar2;

  char *pcVar3;

  code *pcVar4;

  

  uVar1 = FUN_004220b0(param_1,10);

  piVar2 = (int *)FUN_00415430(uVar1);

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

    uVar1 = FUN_0053edb0(param_2);

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

    return uVar1;

  }

  pcVar4 = FUN_00555800;

  pcVar3 = " not loaded correctly from database.";

  FUN_00555810("palette ");

  FUN_00555840(param_1);

  FUN_00555810(pcVar3);

  FUN_005557a0(pcVar4);

  return 0;

}





// --- FUN_005649f0 at 0x005649F0 (size: 831) ---


void __thiscall

FUN_005649f0(undefined4 param_1,int *param_2,int param_3,char param_4,undefined4 param_5)



{

  char cVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  LONG LVar5;

  tm *_Tm;

  undefined4 extraout_ECX;

  BSTR bstrString;

  undefined4 *puVar6;

  undefined4 uVar7;

  undefined *puStack_948;

  int local_944;

  undefined *puStack_940;

  int local_93c;

  int iStack_938;

  undefined4 local_934;

  undefined **ppuStack_930;

  int iStack_92c;

  undefined4 uStack_928;

  undefined4 uStack_924;

  undefined1 auStack_920 [144];

  undefined1 auStack_890 [144];

  wchar_t awStack_800 [1024];

  

  bstrString = (BSTR)0x0;

  local_93c = 0;

  local_934 = param_1;

  if (param_4 != '\0') {

    iVar2 = FUN_0055b0a0();

    if (iVar2 != 0) {

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

        bstrString = SysAllocString((OLECHAR *)*param_2);

      }

      piVar3 = (int *)FUN_0055a740();

      (**(code **)(*piVar3 + 0x1c))(piVar3,bstrString,param_3,&local_93c);

      SysFreeString(bstrString);

    }

    if (local_93c != 0) {

      return;

    }

  }

  local_944 = *param_2;

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

  uVar7 = extraout_ECX;

  FUN_00402730(&DAT_0079d2e0);

  FUN_004d68c0(1,1,uVar7);

  FUN_0055e1d0();

  cVar1 = FUN_005d49b0();

  if (cVar1 != '\0') {

    ppuStack_930 = &PTR_FUN_00795488;

    iStack_92c = 0;

    uStack_928 = 0;

    uStack_924 = 0;

    thunk_FUN_0040bc80(&local_944,0x20,&ppuStack_930);

    for (iVar2 = iStack_92c; iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

      puStack_948 = PTR_DAT_00818340;

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

      iVar4 = FUN_00683a30(iVar2,1,1,&puStack_948);

      if (iVar4 != 0) {

        FUN_00402730(L"****");

        FUN_0040d870(iVar2,&iStack_938);

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

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

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

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

        }

      }

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

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

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

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

      }

    }

    ppuStack_930 = &PTR_FUN_00795488;

    FUN_0040d410();

  }

  puStack_940 = PTR_DAT_00818340;

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

  if (param_3 != 0x1a) {

    FUN_0055e1d0();

    cVar1 = FUN_005d4a00();

    if (cVar1 != '\0') {

      puStack_948 = (undefined *)FUN_0040fa90();

      _Tm = localtime((time_t *)&puStack_948);

      wcsftime(awStack_800,0x400,L"%#H:%M:%S ",_Tm);

      FUN_00407e40(awStack_800);

    }

    if ((DAT_008712c4 != 0) &&

       (iVar2 = fprintf((FILE *)DAT_008712c4,"%ls%ls\n",puStack_940,local_944), 0x800 < iVar2)) {

      FUN_00480980(&puStack_948,0,

                   L"Wrote long string (%d characters) to log file instead of to the screen.\n",

                   iVar2);

      FUN_005649f0(&puStack_948,param_3,1,0);

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

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

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

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

      }

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

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

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

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

      }

      goto LAB_00564d10;

    }

  }

  FUN_0042dc80();

  FUN_0042cbe0(&local_944,1);

  FUN_0042dc80();

  FUN_0042cbe0(&puStack_940,1);

  FUN_006934a0(param_3,auStack_890,auStack_920,param_5);

  FUN_0042e590();

  FUN_0042e590();

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

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

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

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

  }

LAB_00564d10:

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

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

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

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

  }

  return;

}





// --- FUN_00564d30 at 0x00564D30 (size: 6) ---


undefined4 FUN_00564d30(void)



{

  return DAT_00871354;

}





// --- FUN_00564d50 at 0x00564D50 (size: 35) ---


undefined4 __fastcall FUN_00564d50(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00415730(0x10000003,7,0x22);

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

  }

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

}





// --- FUN_00564d80 at 0x00564D80 (size: 33) ---


undefined4 FUN_00564d80(undefined4 param_1,undefined4 param_2,int param_3)



{

  FUN_006a97f0(param_1,param_2,param_3 != 0);

  return 0;

}





// --- FUN_00564db0 at 0x00564DB0 (size: 84) ---


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



{

  int iVar1;

  

  iVar1 = FUN_005583f0(param_3);

  if (iVar1 != 0) {

    iVar1 = FUN_0058df90();

    if (iVar1 != 0) {

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

        FUN_006ab180(param_3);

        return;

      }

      FUN_005898b0(param_2,0,0);

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

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

    }

  }

  return;

}





// --- FUN_00564e10 at 0x00564E10 (size: 32) ---


void __thiscall FUN_00564e10(int param_1,undefined4 param_2)



{

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

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

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

    }

    FUN_006ab1d0(param_2);

  }

  return;

}





// --- FUN_00564e30 at 0x00564E30 (size: 8) ---


undefined4 FUN_00564e30(void)



{

  FUN_006a35e0();

  return 0;

}





// --- FUN_00564e40 at 0x00564E40 (size: 182) ---


undefined4 FUN_00564e40(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  switch(param_1) {

  case 1:

    FUN_006a8380(param_3,param_2);

    return 0;

  case 2:

    FUN_006a3380(param_3,param_2);

    return 0;

  case 3:

    FUN_006a3320(param_3,param_2);

    return 0;

  case 4:

    FUN_006a75b0(param_3,param_2);

    return 0;

  case 5:

    FUN_006a34e0(param_3,param_2);

    return 0;

  case 6:

    FUN_006a33e0(param_3,param_2);

    return 0;

  case 7:

    FUN_006a37f0(param_3,param_2);

  }

  return 0;

}





// --- FUN_00564f20 at 0x00564F20 (size: 23) ---


undefined4 FUN_00564f20(undefined4 param_1,undefined4 param_2)



{

  FUN_006a3280(param_1,param_2);

  return 0;

}





// --- FUN_00564f40 at 0x00564F40 (size: 18) ---


undefined4 FUN_00564f40(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00693a60(param_3);

  return 0;

}





// --- FUN_00564f60 at 0x00564F60 (size: 48) ---


void __thiscall FUN_00564f60(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = FUN_005df0f5(0x88);

  if (iVar1 != 0) {

    uVar2 = FUN_004591e0(param_2);

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

    return;

  }

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

  return;

}





// --- FUN_00564f90 at 0x00564F90 (size: 4) ---


undefined4 __fastcall FUN_00564f90(int param_1)



{

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

}





// --- FUN_00564fc0 at 0x00564FC0 (size: 23) ---


undefined4 FUN_00564fc0(undefined4 param_1,undefined4 param_2)



{

  FUN_006a6b10(param_1,param_2);

  return 0;

}





// --- FUN_00564fe0 at 0x00564FE0 (size: 18) ---


undefined4 FUN_00564fe0(undefined4 param_1)



{

  FUN_006a6a10(param_1);

  return 0;

}





// --- FUN_00565000 at 0x00565000 (size: 37) ---


undefined4 FUN_00565000(undefined4 param_1,int param_2)



{

  FUN_006a67e0(param_1);

  if (param_2 != 0) {

    FUN_006a6970(param_1);

  }

  return 0;

}





// --- FUN_00565030 at 0x00565030 (size: 22) ---


undefined4 FUN_00565030(undefined4 param_1)



{

  FUN_0055e1d0(param_1);

  FUN_0055fe30(param_1);

  return 0;

}





// --- FUN_00565050 at 0x00565050 (size: 93) ---


undefined4

FUN_00565050(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8,

            undefined4 param_9,undefined4 param_10,undefined4 param_11,undefined4 param_12,

            undefined4 param_13,undefined4 param_14,undefined4 param_15,undefined4 param_16)



{

  FUN_006a3730(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,

               param_11,param_12,param_13,param_14,param_15,param_16);

  return 0;

}





// --- FUN_005650b0 at 0x005650B0 (size: 130) ---


void __fastcall FUN_005650b0(undefined4 *param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  

  param_1[-2] = &PTR_LAB_007cee48;

  param_1[-1] = &PTR_FUN_007ceba0;

  *param_1 = &PTR_FUN_007ceb94;

  piVar1 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar1 + 0xc))(-(uint)(param_1 != (undefined4 *)0x8) & (uint)(param_1 + -1));

  }

  puVar2 = (undefined4 *)(-(uint)(param_1 != (undefined4 *)0x8) & (uint)param_1);

  param_1[1] = &PTR_LAB_00793b6c;

  *puVar2 = &PTR_FUN_00795824;

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

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

  }

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

    param_1[-1] = &PTR_FUN_007ccb60;

    FUN_0043c610();

    return;

  }

  ppuRam00000000 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_00565140 at 0x00565140 (size: 37) ---


int __fastcall FUN_00565140(int param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

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

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

  }

  return iVar1;

}





// --- FUN_005652b0 at 0x005652B0 (size: 207) ---


void __thiscall FUN_005652b0(int param_1,int param_2,char param_3)



{

  int iVar1;

  int *piVar2;

  

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

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

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

      FUN_006ab1d0(0);

    }

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

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

      if (iVar1 != 0) {

        FUN_0058d7d0();

      }

      FUN_006a9750(0);

      if (param_3 != '\0') {

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

      }

    }

    if (((*(int *)(param_1 + 0x18) != 0) && (DAT_00871e54 != 0)) &&

       (DAT_00871e54 != *(int *)(param_1 + 0x18))) {

      iVar1 = FUN_005583f0(DAT_00871e54);

      if (iVar1 != 0) {

        iVar1 = FUN_0058dce0(*(undefined4 *)(param_1 + 0x18));

        if (iVar1 != 0) {

          FUN_0058d110(0,0);

        }

      }

    }

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

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

    if (param_2 != 0) {

      piVar2 = (int *)FUN_005583f0(param_2);

      iVar1 = (**(code **)(*piVar2 + 0x7c))();

      if (iVar1 != 0) {

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

      }

    }

  }

  return;

}





// --- FUN_005653d0 at 0x005653D0 (size: 277) ---


void __fastcall FUN_005653d0(int param_1)



{

  char cVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  bool bVar6;

  int local_4;

  

  iVar2 = FUN_00451d20();

  bVar6 = iVar2 != 0;

  uVar5 = 0;

  uVar4 = 0;

  iVar2 = bVar6 + 1;

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

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

    if (iVar3 == 0) {

      iVar3 = FUN_0056b210();

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

      if ((iVar3 == 2) || (iVar3 == 4)) {

        iVar2 = bVar6 + 3;

      }

      else if (iVar3 == 8) {

        iVar2 = bVar6 + 5;

      }

    }

    else if (iVar3 == 1) {

      uVar5 = 0xe;

      uVar4 = 0xe;

      iVar2 = bVar6 + 0xc;

    }

    else if (iVar3 == 2) {

      iVar2 = bVar6 + 10;

    }

    else if (iVar3 == 3) {

      if (bVar6) {

        uVar4 = FUN_00451d20();

        cVar1 = FUN_00588ea0(uVar4);

        uVar5 = 0xe;

        uVar4 = 0xe;

        iVar2 = 0x29 - (uint)(cVar1 != '\0');

      }

      else {

        uVar5 = 0xe;

        iVar2 = 0x27;

        uVar4 = 0xe;

      }

    }

  }

  else {

    iVar2 = bVar6 + 0xe;

  }

  FUN_00415640(&local_4,iVar2,6);

  if ((local_4 != *(int *)(param_1 + 0x30)) &&

     (*(int *)(param_1 + 0x30) = local_4, DAT_0083e03c != 0)) {

    FUN_0045a910(local_4,uVar5,uVar4,1);

  }

  return;

}





// --- FUN_005654f0 at 0x005654F0 (size: 70) ---


undefined4 FUN_005654f0(undefined4 param_1,undefined4 param_2,int param_3)



{

  undefined4 in_stack_ffffffd0;

  

  FUN_0059a130(param_1);

  FUN_0055e1d0();

  FUN_0055ff00(in_stack_ffffffd0);

  if (param_3 != 0) {

    FUN_0059a130(param_1);

    FUN_0055e1d0();

    FUN_0055eb30();

  }

  return 0;

}





// --- FUN_00565540 at 0x00565540 (size: 147) ---


undefined4 * __fastcall FUN_00565540(undefined4 *param_1)



{

  int *piVar1;

  

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_FUN_00795824;

  *param_1 = &PTR_LAB_007cee48;

  param_1[1] = &PTR_FUN_007ceba0;

  param_1[2] = &PTR_FUN_007ceb94;

  param_1[4] = 1;

  param_1[3] = &PTR_LAB_00793b6c;

  param_1[0xd] = 0;

  param_1[0xf] = 0;

  DAT_00871354 = param_1;

  InterlockedIncrement(param_1 + 4);

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

  param_1[0xb] = 0;

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

  *(undefined1 *)((int)param_1 + 0x41) = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[5] = 0;

  param_1[0xc] = DAT_00871370;

  piVar1 = (int *)FUN_0043c680();

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

    (**(code **)(*piVar1 + 4))(0x4dd26d,param_1 + 1);

  }

  return param_1;

}





// --- FUN_005655e0 at 0x005655E0 (size: 34) ---


int __thiscall FUN_005655e0(int param_1,byte param_2)



{

  FUN_005650b0();

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

    operator_delete((void *)(param_1 + -8));

  }

  return param_1 + -8;

}





// --- FUN_00565610 at 0x00565610 (size: 20) ---


void __fastcall FUN_00565610(int param_1)



{

  int iVar1;

  

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

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

  if (iVar1 == 1) {

    FUN_005653d0();

    return;

  }

  return;

}





// --- FUN_00565630 at 0x00565630 (size: 11) ---


void __fastcall FUN_00565630(int param_1)



{

  int *piVar1;

  

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

  *piVar1 = *piVar1 + -1;

  if (*piVar1 == 0) {

    FUN_005653d0();

    return;

  }

  return;

}





// --- FUN_00565640 at 0x00565640 (size: 81) ---


void __fastcall FUN_00565640(int param_1)



{

  int iVar1;

  

  FUN_006ae4c0(0x451);

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

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

    FUN_006ab1d0(0);

  }

  FUN_005652b0(0,1);

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

  iVar1 = FUN_0056b210();

  *(undefined1 *)(iVar1 + 0x46) = 1;

  FUN_0058d110(0,0);

  return;

}





// --- FUN_005656a0 at 0x005656A0 (size: 63) ---


undefined4 FUN_005656a0(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(DAT_00871354 + 0x14) + -1;

  *(int *)(DAT_00871354 + 0x14) = iVar1;

  if (iVar1 == 0) {

    FUN_005653d0();

  }

  if (param_1 != 0) {

    iVar1 = FUN_0056f230();

    if (iVar1 != 0) {

      FUN_00572760(param_1,&DAT_0083774c);

    }

  }

  return 0;

}





// --- FUN_005656e0 at 0x005656E0 (size: 109) ---


void __thiscall FUN_005656e0(int param_1,int param_2)



{

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

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

    if (param_2 == 0) {

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

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

        (**(code **)(*DAT_00837ff4 + 0x38))(0x1000000b,param_1 + 8);

      }

    }

    else if ((0 < param_2) && (param_2 < 4)) {

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

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

        (**(code **)(*DAT_00837ff4 + 0x34))(0x1000000b,param_1 + 8,2000);

        FUN_005653d0();

        return;

      }

    }

    FUN_005653d0();

  }

  return;

}





// --- FUN_005657b0 at 0x005657B0 (size: 83) ---


void __thiscall FUN_005657b0(int param_1,int param_2)



{

  if (param_2 != 0) {

    FUN_006b0510(param_2);

    return;

  }

  if (*(int *)(param_1 + 0x2c) != 2) {

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

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

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

      (**(code **)(*DAT_00837ff4 + 0x34))(0x1000000b,param_1 + 8,2000);

    }

    FUN_005653d0();

  }

  return;

}





// --- FUN_00565810 at 0x00565810 (size: 83) ---


void __thiscall FUN_00565810(int param_1,int param_2)



{

  if (param_2 != 0) {

    FUN_006b0560(param_2);

    return;

  }

  if (*(int *)(param_1 + 0x2c) != 2) {

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

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

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

      (**(code **)(*DAT_00837ff4 + 0x34))(0x1000000b,param_1 + 8,2000);

    }

    FUN_005653d0();

  }

  return;

}





// --- FUN_00565870 at 0x00565870 (size: 88) ---


void __fastcall FUN_00565870(int param_1)



{

  int iVar1;

  

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

    if (param_1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = param_1 + 8;

    }

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

  }

  FUN_00565640();

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

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

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

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

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

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

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

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

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

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

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

  FUN_005653d0();

  return;

}





// --- FUN_005658d0 at 0x005658D0 (size: 62) ---


void FUN_005658d0(undefined4 param_1,int param_2)



{

  if (param_2 == 1) {

    FUN_005898b0(param_1,0,0);

  }

  else {

    if (param_2 == 2) {

      FUN_005657b0(param_1);

      return;

    }

    if (param_2 == 3) {

      FUN_00589d20(param_1);

      return;

    }

  }

  return;

}





// --- FUN_00565910 at 0x00565910 (size: 28) ---


void FUN_00565910(undefined4 param_1,int param_2)



{

  if (param_2 == 2) {

    FUN_00565810(param_1);

  }

  return;

}





// --- FUN_00565cd0 at 0x00565CD0 (size: 149) ---


undefined4 FUN_00565cd0(void)



{

  size_t sVar1;

  LONG LVar2;

  wchar_t *local_94;

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar1 = wcslen(L"The Portal Storm has subsided");

  FUN_004022d0(sVar1);

  wcscpy(local_94,L"The Portal Storm has subsided");

  FUN_0042cbe0(&local_94,1);

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

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

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

  }

  FUN_00693500(0x1a,local_90);

  FUN_006b04c0(0);

  FUN_0042e590();

  return 0;

}





// --- FUN_00565d70 at 0x00565D70 (size: 203) ---


undefined4 FUN_00565d70(undefined4 param_1)



{

  size_t sVar1;

  LONG LVar2;

  undefined4 uVar3;

  int iVar4;

  wchar_t *local_94;

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar1 = wcslen(L"This area is getting too crowded - a Portal Storm is brewing.");

  FUN_004022d0(sVar1);

  wcscpy(local_94,L"This area is getting too crowded - a Portal Storm is brewing.");

  FUN_0042cbe0(&local_94,1);

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

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

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

  }

  FUN_00693500(0x1a,local_90);

  if (DAT_0083da58 == 0) {

    uVar3 = 0;

  }

  else {

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

  }

  iVar4 = FUN_00558410(uVar3);

  if (iVar4 != 0) {

    FUN_00513d60(0x73,0);

  }

  FUN_006b04c0(param_1);

  FUN_0042e590();

  return 0;

}





// --- FUN_00565e40 at 0x00565E40 (size: 206) ---


undefined4 FUN_00565e40(undefined4 param_1)



{

  size_t sVar1;

  LONG LVar2;

  undefined4 uVar3;

  int iVar4;

  wchar_t *local_94;

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar1 = wcslen(L"A Portal Storm is imminent - leave this crowded area!");

  FUN_004022d0(sVar1);

  wcscpy(local_94,L"A Portal Storm is imminent - leave this crowded area!");

  FUN_0042cbe0(&local_94,1);

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

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

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

  }

  FUN_00693500(0x1a,local_90);

  if (DAT_0083da58 == 0) {

    uVar3 = 0;

  }

  else {

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

  }

  iVar4 = FUN_00558410(uVar3);

  if (iVar4 != 0) {

    FUN_00513d60(0x73,0x3f800000);

  }

  FUN_006b04c0(param_1);

  FUN_0042e590();

  return 0;

}





// --- FUN_00565f10 at 0x00565F10 (size: 115) ---


undefined4 FUN_00565f10(void)



{

  size_t sVar1;

  LONG LVar2;

  wchar_t *local_4;

  

  sVar1 = wcslen(L"The Portal Storm has teleported you away from the crowded area!\n");

  FUN_004022d0(sVar1);

  wcscpy(local_4,L"The Portal Storm has teleported you away from the crowded area!\n");

  FUN_006b0470();

  FUN_006b04c0(0);

  FUN_005649f0(&local_4,0,1,0);

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

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

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

  }

  return 0;

}





// --- FUN_005660a0 at 0x005660A0 (size: 372) ---


int * FUN_005660a0(int *param_1,int param_2)



{

  char cVar1;

  int iVar2;

  bool bVar3;

  char *pcVar4;

  undefined4 uVar5;

  LONG LVar6;

  char *pcVar7;

  int iVar8;

  float10 fVar9;

  undefined *local_c;

  char *local_8;

  int local_4;

  

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

  bVar3 = true;

  FUN_00401340(&DAT_007938af);

  while (iVar2 != 0) {

    iVar8 = 0;

    if (iVar2 != 0) {

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

    }

    pcVar4 = "Unknown";

    do {

      cVar1 = *pcVar4;

      pcVar4 = pcVar4 + 1;

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

    FUN_00401280();

    pcVar7 = "Unknown";

    pcVar4 = local_8;

    do {

      cVar1 = *pcVar7;

      pcVar7 = pcVar7 + 1;

      *pcVar4 = cVar1;

      pcVar4 = pcVar4 + 1;

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

    uVar5 = FUN_004f1b20();

    FUN_005ce450(uVar5);

    if (bVar3) {

      local_c = PTR_DAT_008183b4;

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

    }

    else {

      FUN_00401340();

    }

    fVar9 = (float10)FUN_00599ba0();

    uVar5 = FUN_0051df70(local_8,(double)fVar9);

    FUN_00406500(&local_4,"%s%d %s (ws %.2lf)",local_c,uVar5);

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

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

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

    }

    bVar3 = false;

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

    iVar2 = iVar8;

    if ((LVar6 == 0) && (local_8 + -0x14 != (char *)0x0)) {

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

    }

  }

  *param_1 = local_4;

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

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

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

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

  }

  return param_1;

}





// --- FUN_00566220 at 0x00566220 (size: 410) ---


undefined4 * FUN_00566220(undefined4 *param_1,wchar_t *param_2)



{

  undefined4 *puVar1;

  size_t sVar2;

  int iVar3;

  LONG LVar4;

  undefined *puVar5;

  undefined4 *puVar6;

  int iVar7;

  wchar_t *pwVar8;

  wchar_t *local_8;

  int local_4;

  

  sVar2 = wcslen(L" The following were not suitable for salvaging");

  FUN_004022d0(sVar2);

  wcscpy(local_8,L" The following were not suitable for salvaging");

  puVar6 = *(undefined4 **)(param_2 + 2);

  iVar7 = 0;

  local_4 = 0;

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

    do {

      iVar3 = FUN_005583f0(*puVar6);

      if (iVar3 != 0) {

        puVar5 = &DAT_007cf0cc;

        if (iVar7 != 0) {

          puVar5 = &DAT_007cf0c4;

        }

        puVar1 = *(undefined4 **)(iVar3 + 0x9c);

        InterlockedIncrement(puVar1 + 1);

        FUN_004300a0(&local_8,L"%s%hs",puVar5,puVar1 + 5);

        LVar4 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        iVar7 = local_4 + 1;

        local_4 = iVar7;

      }

      puVar6 = (undefined4 *)puVar6[1];

    } while (puVar6 != (undefined4 *)0x0);

    if (iVar7 != 0) {

      sVar2 = wcslen(L".\n");

      FUN_004022d0(sVar2);

      wcscpy(param_2,L".\n");

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

        FUN_00402490(param_2,*(int *)(param_2 + -2) + -1);

      }

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

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

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

      }

      goto LAB_0056637c;

    }

  }

  if (local_8 != (wchar_t *)PTR_DAT_00818340) {

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

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

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

    }

    local_8 = (wchar_t *)PTR_DAT_00818340;

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

  }

LAB_0056637c:

  *param_1 = local_8;

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

  pwVar8 = local_8 + -10;

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

  if ((LVar4 == 0) && (pwVar8 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar8)(1);

  }

  return param_1;

}





// --- FUN_005663c0 at 0x005663C0 (size: 586) ---


undefined4 FUN_005663c0(undefined *param_1)



{

  int iVar1;

  LONG LVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 *local_10 [2];

  undefined *local_8;

  int iStack_4;

  

  FUN_0048c3e0(&DAT_007938af);

  iVar1 = FUN_0058a000(0,local_10,0x19);

  puVar4 = local_10[0];

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

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

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

  }

  if (iVar1 == 0) {

    local_8 = PTR_DAT_00818340;

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

    iVar1 = FUN_005ca6d0();

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

      uVar3 = FUN_005ca6d0();

      FUN_005660a0(&iStack_4,uVar3);

      local_10[0] = DAT_008ef11c;

      InterlockedIncrement(DAT_008ef11c + 1);

      uVar3 = FUN_004f1b20(local_10);

      FUN_005b5ae0(uVar3);

      param_1 = PTR_DAT_00818340;

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

      iVar1 = FUN_006b4b20();

      if (iVar1 != 0) {

        uVar3 = FUN_006b4b20();

        FUN_004027b0(&param_1,L" Your augmentation has given you a return bonus of %d%%!",uVar3);

      }

      FUN_004027b0(&local_8,L"You obtain %hs using your knowledge of %hs.%s\n",iStack_4,

                   local_10[0] + 5,param_1);

      FUN_005649f0(&local_8,0,1,0);

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

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

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

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

      }

      puVar4 = local_10[0];

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

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

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

      }

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

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

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

      }

    }

    iVar1 = FUN_00426990();

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

      uVar7 = 0;

      uVar6 = 1;

      uVar5 = 0;

      uVar3 = FUN_00426990(0,1,0);

      uVar3 = FUN_00566220(&param_1,uVar3);

      FUN_005649f0(uVar3,uVar5,uVar6,uVar7);

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

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

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

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

      }

    }

    iVar1 = FUN_005ca6d0();

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

      iVar1 = FUN_00426990();

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

        FUN_00402730(L"Salvaging Failed!\n");

        FUN_005649f0(&param_1,0,1,0);

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

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

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

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

        }

      }

    }

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

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

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

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

    }

  }

  return 0;

}





// --- FUN_00566610 at 0x00566610 (size: 229) ---


void FUN_00566610(int param_1,undefined4 param_2)



{

  int *piVar1;

  int iVar2;

  undefined1 *puVar3;

  undefined *puVar4;

  int *piVar5;

  int **ppiVar6;

  undefined4 uVar7;

  int *local_18;

  int local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar6 = &local_18;

  puVar3 = local_10;

  puVar4 = &DAT_007cea80;

  local_18 = (int *)0x0;

  FUN_00406d10(puVar3,&DAT_007cea80,ppiVar6);

  FUN_00406570(puVar3,puVar4,ppiVar6);

  piVar1 = local_18;

  uVar7 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar5 = local_18;

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

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

  }

  local_18 = (int *)FUN_004c1da0(local_c,piVar5,uVar7);

  local_18 = (int *)*local_18;

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

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

  }

  piVar1 = local_8;

  if ((local_8 != (int *)0x0) && (-1 < (int)local_18)) {

    FUN_005596b0(param_1,param_2);

    iVar2 = FUN_005088e0(param_1);

    if (iVar2 != 0) {

      FUN_0058d850();

    }

  }

  if ((param_1 == *(int *)(local_14 + 0x1c)) && ((param_1 != DAT_00871ed4 || (DAT_00871ed0 != 4))))

  {

    FUN_006a9750(*(int *)(local_14 + 0x1c));

    FUN_0058d8e0(param_1);

  }

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

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

  }

  return;

}





// --- FUN_00566ab0 at 0x00566AB0 (size: 242) ---


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



{

  int iVar1;

  int iVar2;

  int *piVar3;

  LONG LVar4;

  undefined **local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  undefined1 local_28 [36];

  undefined4 *local_4;

  

  iVar2 = param_3;

  iVar1 = *param_2;

  piVar3 = param_2 + 1;

  param_2 = piVar3;

  FUN_005d2be0();

  FUN_005d2d20(&param_2,(int)piVar3 + (iVar2 - (int)param_2));

  local_38 = &PTR_FUN_007b6110;

  local_34 = 0;

  local_30 = 0;

  local_2c = 0;

  FUN_004c1d10(&param_2,(int)piVar3 + (iVar2 - (int)param_2));

  FUN_005652b0(0,1);

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

  FUN_006ab220(iVar1,local_28,&local_38,(iVar1 == *(int *)(param_1 + 0x24)) + '\x02');

  if ((iVar1 == *(int *)(param_1 + 0x24)) && (*(int *)(param_1 + 0x28) != 0)) {

    FUN_006ab180(*(int *)(param_1 + 0x28));

  }

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

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

  local_38 = &PTR_FUN_007b6110;

  FUN_004c1ca0();

  local_38 = &PTR_FUN_0079385c;

  LVar4 = InterlockedDecrement(local_4 + 1);

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

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

  }

  return;

}





// --- FUN_00566bb0 at 0x00566BB0 (size: 340) ---


undefined4 FUN_00566bb0(void)



{

  ulonglong uVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int *piVar7;

  LONG LVar8;

  int iVar9;

  char *pcVar10;

  char acStack_401 [1025];

  

  uVar2 = FUN_005df4c4();

  iVar3 = (int)(((ulonglong)uVar2 % 0x278d00) / 0x15180);

  uVar1 = ((ulonglong)uVar2 % 0x278d00) % 0x15180;

  iVar4 = (int)(uVar1 / 0xe10);

  uVar1 = uVar1 % 0xe10;

  iVar5 = (int)(uVar1 / 0x3c);

  iVar9 = (int)(uVar1 % 0x3c);

  pcVar10 = acStack_401 + 1;

  if (uVar2 / 0x278d00 != 0) {

    iVar6 = _snprintf(acStack_401 + 1,0x400,"%dmo ",uVar2 / 0x278d00);

    pcVar10 = acStack_401 + iVar6 + 1;

  }

  if (iVar3 != 0) {

    iVar3 = _snprintf(pcVar10,(int)&stack0x00000000 - (int)pcVar10,"%dd ",iVar3);

    pcVar10 = pcVar10 + iVar3;

  }

  if (iVar4 != 0) {

    iVar3 = _snprintf(pcVar10,(int)&stack0x00000000 - (int)pcVar10,"%dh ",iVar4);

    pcVar10 = pcVar10 + iVar3;

  }

  if (iVar5 != 0) {

    iVar3 = _snprintf(pcVar10,(int)&stack0x00000000 - (int)pcVar10,"%dm ",iVar5);

    pcVar10 = pcVar10 + iVar3;

  }

  _snprintf(pcVar10,(int)&stack0x00000000 - (int)pcVar10,"%ds ",iVar9);

  pcVar10 = acStack_401;

  do {

    pcVar10 = pcVar10 + 1;

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

  pcVar10[-1] = '\0';

  piVar7 = (int *)FUN_00404a40(0,acStack_401 + 1);

  iVar3 = *(int *)(*piVar7 + -4);

  if (iVar3 != 1) {

    FUN_00402490(*piVar7,iVar3 + -1);

  }

  LVar8 = InterlockedDecrement((LONG *)(iVar9 + -0x10));

  if ((LVar8 == 0) && ((undefined4 *)(iVar9 + -0x14) != (undefined4 *)0x0)) {

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

  }

  return 1;

}





// --- FUN_00566d10 at 0x00566D10 (size: 449) ---


uint __thiscall FUN_00566d10(int *param_1,int *param_2,int *param_3)



{

  char cVar1;

  char *pcVar2;

  char *pcVar3;

  LONG LVar4;

  char *pcVar5;

  char *_Dest;

  int iVar6;

  int *piVar7;

  size_t _Count;

  undefined4 *puVar8;

  char *local_18;

  char *local_14;

  undefined4 *local_10;

  int local_c;

  int *local_8;

  int *local_4;

  

  piVar7 = (int *)0x0;

  local_c = 0;

  local_8 = (int *)0x0;

  local_4 = (int *)0x0;

  for (pcVar2 = strstr((char *)(*param_1 + 0x14),(char *)(*param_2 + 0x14)); pcVar2 != (char *)0x0;

      pcVar2 = strstr(pcVar2 + *(int *)(*param_2 + 8) + -1,(char *)(*param_2 + 0x14))) {

    local_14 = pcVar2;

    if (piVar7 == local_4) {

      FUN_004052a0(piVar7,&local_14,&param_3,1,1);

    }

    else {

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

        *piVar7 = (int)pcVar2;

      }

      local_8 = piVar7 + 1;

    }

    piVar7 = local_8;

  }

  local_14 = (char *)((int)piVar7 - local_c >> 2);

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

    if (local_c != 0) {

      FUN_004051c0(local_c,((int)local_4 - local_c >> 2) << 2);

    }

    return 0;

  }

  puVar8 = (undefined4 *)*param_1;

  local_10 = puVar8;

  FUN_00403560((*(int *)(*param_3 + 8) - *(int *)(*param_2 + 8)) * (int)local_14 + -1 + puVar8[2]);

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

  pcVar2 = (char *)(puVar8 + 5);

  local_18 = (char *)0x0;

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

    do {

      _Count = *(int *)(local_c + (int)local_18 * 4) - (int)pcVar2;

      strncpy(_Dest,pcVar2,_Count);

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

      pcVar5 = _Dest + _Count;

      do {

        cVar1 = *pcVar3;

        pcVar3 = pcVar3 + 1;

        *pcVar5 = cVar1;

        pcVar5 = pcVar5 + 1;

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

      _Dest = _Dest + _Count + *(int *)(*param_3 + 8) + -1;

      pcVar2 = pcVar2 + *(int *)(*param_2 + 8) + _Count + -1;

      local_18 = local_18 + 1;

      puVar8 = local_10;

    } while (local_18 < local_14);

  }

  iVar6 = (int)_Dest - (int)pcVar2;

  do {

    cVar1 = *pcVar2;

    pcVar2[iVar6] = cVar1;

    pcVar2 = pcVar2 + 1;

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

  LVar4 = InterlockedDecrement(puVar8 + 1);

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

    (**(code **)*puVar8)(1);

  }

  if (local_c != 0) {

    FUN_004051c0(local_c,((int)local_4 - local_c >> 2) << 2);

  }

  return (uint)local_14;

}





// --- FUN_00566ee0 at 0x00566EE0 (size: 731) ---


undefined4 FUN_00566ee0(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 *puStack_120;

  int *piStack_11c;

  undefined4 *local_118;

  undefined4 *local_114;

  undefined1 auStack_110 [120];

  undefined1 auStack_98 [148];

  

  iVar2 = FUN_005583f0(param_2);

  FUN_0048c3e0("\nAre you sure you want to attempt to destroy your ");

  puVar1 = *(undefined4 **)(iVar2 + 0x9c);

  InterlockedIncrement(puVar1 + 1);

  if ((puVar1[2] != 1) && (puVar1 != DAT_008ef11c)) {

    FUN_004910c0(puVar1 + 5,puVar1[2] + -1);

  }

  LVar3 = InterlockedDecrement(puVar1 + 1);

  if (LVar3 == 0) {

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

  }

  FUN_0048c3e0(" and drain its mana into this stone?");

  puVar1 = local_118;

  if ((local_118[2] != 1) && (local_118 != DAT_008ef11c)) {

    FUN_004910c0(local_118 + 5,local_118[2] + -1);

  }

  LVar3 = InterlockedDecrement(puVar1 + 1);

  if (LVar3 == 0) {

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

  }

  FUN_0042dc80();

  uVar5 = 1;

  uVar4 = FUN_00404a40(0,local_114 + 5);

  FUN_0042cbe0(uVar4,uVar5);

  LVar3 = InterlockedDecrement(local_118 + -4);

  if ((LVar3 == 0) && (local_118 + -5 != (undefined4 *)0x0)) {

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

  }

  FUN_006823d0();

  puStack_120 = (undefined4 *)0x0;

  piStack_11c = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  local_118 = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&local_118,&puStack_120);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

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

  }

  local_118 = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&local_118,&puStack_120);

  FUN_0042a2d0(0x1000003d);

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

    FUN_00429b10();

    (**(code **)(*piStack_11c + 0xcc))(param_1);

  }

  local_118 = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&local_118,&puStack_120);

  FUN_0042a2d0(0x1000003e);

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

    FUN_00429b10();

    (**(code **)(*piStack_11c + 0xcc))(param_2);

  }

  local_118 = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&local_118,&puStack_120);

  FUN_00478830(auStack_110,&LAB_00566700);

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

    iVar2 = puStack_120[1];

    puStack_120[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*puStack_120)(1);

    }

    puStack_120 = (undefined4 *)0x0;

  }

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

    iVar2 = piStack_11c[1];

    piStack_11c[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*piStack_11c)(1);

    }

    piStack_11c = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  LVar3 = InterlockedDecrement(local_114 + 1);

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

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

  }

  return 1;

}





// --- FUN_005671c0 at 0x005671C0 (size: 493) ---


undefined4 FUN_005671c0(undefined4 param_1)



{

  int iVar1;

  size_t sVar2;

  LONG LVar3;

  undefined4 *puStack_114;

  int *piStack_110;

  wchar_t *local_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar2 = wcslen(

                L"Using this altar will make you a player killer, able to attack or be attacked by other player killers. Are you sure you want to do this?"

                );

  FUN_004022d0(sVar2);

  wcscpy(local_10c,

         L"Using this altar will make you a player killer, able to attack or be attacked by other player killers. Are you sure you want to do this?"

        );

  FUN_0042cbe0(&local_10c,1);

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

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

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

  }

  FUN_006823d0();

  puStack_114 = (undefined4 *)0x0;

  piStack_110 = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0x1000003d);

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

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xcc))(param_1);

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_00478830(local_108,&LAB_005668c0);

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

    iVar1 = puStack_114[1];

    puStack_114[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*puStack_114)(1);

    }

    puStack_114 = (undefined4 *)0x0;

  }

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

    iVar1 = piStack_110[1];

    piStack_110[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*piStack_110)(1);

    }

    piStack_110 = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  return 1;

}





// --- FUN_005673b0 at 0x005673B0 (size: 493) ---


undefined4 FUN_005673b0(undefined4 param_1)



{

  int iVar1;

  size_t sVar2;

  LONG LVar3;

  undefined4 *puStack_114;

  int *piStack_110;

  wchar_t *local_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar2 = wcslen(

                L"Using this altar will make you a non-player killer, unable to attack or be attacked by other player killers. Are you sure you want to do this?"

                );

  FUN_004022d0(sVar2);

  wcscpy(local_10c,

         L"Using this altar will make you a non-player killer, unable to attack or be attacked by other player killers. Are you sure you want to do this?"

        );

  FUN_0042cbe0(&local_10c,1);

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

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

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

  }

  FUN_006823d0();

  puStack_114 = (undefined4 *)0x0;

  piStack_110 = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0x1000003d);

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

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xcc))(param_1);

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_00478830(local_108,&LAB_005668c0);

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

    iVar1 = puStack_114[1];

    puStack_114[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*puStack_114)(1);

    }

    puStack_114 = (undefined4 *)0x0;

  }

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

    iVar1 = piStack_110[1];

    piStack_110[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*piStack_110)(1);

    }

    piStack_110 = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  return 1;

}





// --- FUN_005675a0 at 0x005675A0 (size: 493) ---


undefined4 FUN_005675a0(undefined4 param_1)



{

  int iVar1;

  size_t sVar2;

  LONG LVar3;

  undefined4 *puStack_114;

  int *piStack_110;

  wchar_t *local_10c;

  undefined1 local_108 [120];

  undefined1 local_90 [144];

  

  FUN_0042dc80();

  sVar2 = wcslen(L"Are you sure you want to use this rare item?");

  FUN_004022d0(sVar2);

  wcscpy(local_10c,L"Are you sure you want to use this rare item?");

  FUN_0042cbe0(&local_10c,1);

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

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

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

  }

  FUN_006823d0();

  puStack_114 = (undefined4 *)0x0;

  piStack_110 = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

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

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_0042a2d0(0x1000003d);

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

    FUN_00429b10();

    (**(code **)(*piStack_110 + 0xcc))(param_1);

  }

  local_10c = (wchar_t *)FUN_00429a00();

  FUN_0042c290(&local_10c,&puStack_114);

  FUN_00478830(local_108,&LAB_005668c0);

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

    iVar1 = puStack_114[1];

    puStack_114[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*puStack_114)(1);

    }

    puStack_114 = (undefined4 *)0x0;

  }

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

    iVar1 = piStack_110[1];

    piStack_110[1] = iVar1 + -1;

    if (iVar1 + -1 == 0) {

      (**(code **)*piStack_110)(1);

    }

    piStack_110 = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  return 1;

}





// --- FUN_00567790 at 0x00567790 (size: 1127) ---


undefined4 FUN_00567790(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  LONG LVar4;

  int *piVar5;

  undefined4 uVar6;

  undefined4 **ppuVar7;

  undefined4 **ppuVar8;

  undefined4 **ppuVar9;

  undefined4 **ppuVar10;

  undefined4 **ppuVar11;

  undefined4 **ppuVar12;

  undefined4 **ppuVar13;

  undefined4 **ppuVar14;

  undefined4 uVar15;

  undefined4 *puStack_144;

  int *piStack_140;

  undefined4 *puStack_13c;

  undefined4 *local_138;

  undefined4 *local_134;

  undefined4 *puStack_130;

  undefined4 *puStack_12c;

  undefined4 *puStack_128;

  undefined4 *puStack_124;

  undefined4 *puStack_120;

  undefined4 *puStack_11c;

  undefined4 *puStack_118;

  undefined4 *puStack_114;

  undefined1 auStack_110 [120];

  undefined1 auStack_98 [148];

  

  iVar2 = FUN_005583f0(param_1);

  iVar3 = FUN_005583f0(param_2);

  local_134 = *(undefined4 **)(iVar2 + 0x9c);

  InterlockedIncrement(local_134 + 1);

  FUN_0048c3e0(" (100)");

  FUN_00566d10(&local_138,&DAT_008ef120);

  LVar4 = InterlockedDecrement(local_138 + 1);

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

    (**(code **)*local_138)(1);

  }

  local_138 = *(undefined4 **)(iVar3 + 0x9c);

  InterlockedIncrement(local_138 + 1);

  FUN_0048c3e0("\nAre you sure you want to apply the ");

  FUN_0048c3e0(" may be destroyed.");

  FUN_0048c3e0("? The ");

  FUN_0048c3e0(" to the ");

  ppuVar14 = &puStack_124;

  ppuVar13 = &puStack_120;

  ppuVar12 = &local_138;

  ppuVar11 = &puStack_114;

  ppuVar10 = &puStack_130;

  ppuVar9 = &puStack_11c;

  ppuVar8 = &local_138;

  ppuVar7 = &puStack_118;

  FUN_004a2b90(&puStack_13c,&puStack_12c);

  FUN_004a2b90(ppuVar7,ppuVar8);

  FUN_004a2b90(ppuVar9,ppuVar10);

  FUN_004a2b90(ppuVar11,ppuVar12);

  piVar5 = (int *)FUN_004a2b90(ppuVar13,ppuVar14);

  iVar2 = *piVar5;

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

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

  }

  LVar4 = InterlockedDecrement(puStack_120 + 1);

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

    (**(code **)*puStack_120)(1);

  }

  LVar4 = InterlockedDecrement(puStack_114 + 1);

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

    (**(code **)*puStack_114)(1);

  }

  LVar4 = InterlockedDecrement(puStack_11c + 1);

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

    (**(code **)*puStack_11c)(1);

  }

  LVar4 = InterlockedDecrement(puStack_118 + 1);

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

    (**(code **)*puStack_118)(1);

  }

  puVar1 = puStack_13c;

  LVar4 = InterlockedDecrement(puStack_13c + 1);

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

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

  }

  LVar4 = InterlockedDecrement(puStack_12c + 1);

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

    (**(code **)*puStack_12c)(1);

  }

  LVar4 = InterlockedDecrement(puStack_130 + 1);

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

    (**(code **)*puStack_130)(1);

  }

  LVar4 = InterlockedDecrement(puStack_124 + 1);

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

    (**(code **)*puStack_124)(1);

  }

  FUN_0042dc80();

  uVar15 = 1;

  uVar6 = FUN_00404a40(0,puStack_128 + 5);

  FUN_0042cbe0(uVar6,uVar15);

  LVar4 = InterlockedDecrement(puStack_13c + -4);

  if ((LVar4 == 0) && (puStack_13c + -5 != (undefined4 *)0x0)) {

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

  }

  FUN_006823d0();

  puStack_144 = (undefined4 *)0x0;

  piStack_140 = (int *)0x0;

  FUN_0042a2d0(0x8e);

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

    FUN_00429b10();

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

  }

  puStack_13c = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&puStack_13c,&puStack_144);

  FUN_0042a2d0(0xc5);

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

    FUN_00429b10();

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

  }

  puStack_13c = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&puStack_13c,&puStack_144);

  FUN_0042a2d0(0x1000003d);

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

    FUN_00429b10();

    (**(code **)(*piStack_140 + 0xcc))(param_1);

  }

  puStack_13c = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&puStack_13c,&puStack_144);

  FUN_0042a2d0(0x1000003e);

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

    FUN_00429b10();

    (**(code **)(*piStack_140 + 0xcc))(param_2);

  }

  puStack_13c = (undefined4 *)FUN_00429a00();

  FUN_0042c290(&puStack_13c,&puStack_144);

  FUN_00478830(auStack_110,&LAB_00566700);

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

    iVar2 = puStack_144[1];

    puStack_144[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*puStack_144)(1);

    }

    puStack_144 = (undefined4 *)0x0;

  }

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

    iVar2 = piStack_140[1];

    piStack_140[1] = iVar2 + -1;

    if (iVar2 + -1 == 0) {

      (**(code **)*piStack_140)(1);

    }

    piStack_140 = (int *)0x0;

  }

  FUN_00681f60();

  FUN_0042e590();

  LVar4 = InterlockedDecrement(puStack_128 + 1);

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

    (**(code **)*puStack_128)(1);

  }

  LVar4 = InterlockedDecrement(local_138 + 1);

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

    (**(code **)*local_138)(1);

  }

  puVar1 = local_134;

  LVar4 = InterlockedDecrement(local_134 + 1);

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

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

  }

  return 1;

}





// --- FUN_00567c00 at 0x00567C00 (size: 6) ---


undefined4 FUN_00567c00(void)



{

  return DAT_0087144c;

}





// --- FUN_00567c10 at 0x00567C10 (size: 35) ---


undefined4 __fastcall FUN_00567c10(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00415730(5,2,0x10000006);

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

  }

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

}





// --- FUN_00567c40 at 0x00567C40 (size: 68) ---


void __fastcall FUN_00567c40(int param_1)



{

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

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

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

  }

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

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

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

  }

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

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

    DAT_0087144c = (int *)0x0;

  }

  return;

}





// --- FUN_00567c90 at 0x00567C90 (size: 84) ---


void FUN_00567c90(undefined4 param_1,int param_2)



{

  (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0xc0))();

  if (param_2 == 0) {

    FUN_006a3f70(param_1);

    FUN_00564d30();

    FUN_00565610();

    return;

  }

  FUN_006a3e60(param_2,param_1);

  FUN_00564d30();

  FUN_00565610();

  return;

}





// --- FUN_00567dd0 at 0x00567DD0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007cf78c;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

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

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00567e10 at 0x00567E10 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007cf790;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

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

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00567e50 at 0x00567E50 (size: 88) ---


undefined4 __thiscall FUN_00567e50(int param_1,uint param_2)



{

  uint *puVar1;

  

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

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

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

      while (param_2 != *puVar1) {

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

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

          return 0;

        }

      }

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

        FUN_005979d0(puVar1 + 2);

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_00567eb0 at 0x00567EB0 (size: 57) ---


bool __thiscall FUN_00567eb0(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  int iVar2;

  

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

    uVar1 = FUN_00415730(6,2,0x10000005);

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

  }

  iVar2 = FUN_00567e50(param_2,param_3);

  return iVar2 != 0;

}





// --- FUN_00567ef0 at 0x00567EF0 (size: 104) ---


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



{

  undefined4 uVar1;

  undefined1 local_90 [144];

  

  FUN_0048b420();

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

    uVar1 = FUN_00415730(6,2,0x10000005);

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

  }

  FUN_00567e50(param_3,local_90);

  FUN_00597d40(param_2);

  FUN_0048b4d0();

  return param_2;

}





// --- FUN_00567f60 at 0x00567F60 (size: 104) ---


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



{

  undefined4 uVar1;

  undefined1 local_90 [144];

  

  FUN_0048b420();

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

    uVar1 = FUN_00415730(6,2,0x10000005);

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

  }

  FUN_00567e50(param_3,local_90);

  FUN_00597db0(param_2);

  FUN_0048b4d0();

  return param_2;

}





// --- FUN_00567fd0 at 0x00567FD0 (size: 795) ---


bool FUN_00567fd0(int param_1,uint param_2,char param_3)



{

  LONG LVar1;

  int iVar2;

  int *piVar3;

  uint uVar4;

  undefined4 *puVar5;

  int iVar6;

  int local_98;

  undefined1 auStack_94 [4];

  undefined1 local_90 [144];

  

  if (param_2 == 0) {

    if (param_1 == 0) {

      return true;

    }

    if (param_3 != '\0') {

      return false;

    }

    FUN_0042dc80();

    FUN_00402730(L"This spell would require no target");

    FUN_0042cbe0(&local_98,1);

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

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

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

    }

  }

  else {

    if (param_1 != 0) {

      iVar2 = FUN_0055e1d0();

      if (((param_2 & 0x8107) == 0) && (param_1 == *(int *)(iVar2 + 0x1e8))) {

        if (param_3 != '\0') {

          return false;

        }

        FUN_0042dc80();

        FUN_00402730(L"You cannot cast this spell upon yourself");

        FUN_0042cbe0(&local_98,1);

        FUN_004011b0();

      }

      else {

        piVar3 = (int *)FUN_005583f0(param_1);

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

          return false;

        }

        if ((piVar3[0x3e] == 0) || ((uint)piVar3[0x3e] < 2)) {

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

          if ((((param_2 & uVar4) == 0) && ((param_2 & 0x8107) == 0)) ||

             ((iVar6 = (**(code **)(*piVar3 + 0x10))(), iVar6 == 0 &&

              ((*(byte *)(piVar3 + 0x40) & 0x10) == 0)))) {

            if (param_3 != '\0') {

              return false;

            }

            puVar5 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

            FUN_00480980(&local_98,0,L"This spell cannot be cast on %s",*puVar5);

            FUN_004011b0();

            FUN_0042dc80();

            FUN_0042cbe0(&local_98,1);

          }

          else {

            if (piVar3[0x50] == 0) {

              iVar2 = FUN_005583f0(*(undefined4 *)(iVar2 + 0x1e8));

              return iVar2 != 0;

            }

            if (param_3 != '\0') {

              return false;

            }

            puVar5 = (undefined4 *)FUN_0058f8b0(auStack_94,2,0);

            FUN_00480980(&local_98,0,L"This spell cannot be cast on %s",*puVar5);

            FUN_004011b0();

            FUN_0042dc80();

            FUN_0042cbe0(&local_98,1);

          }

          FUN_00693500(0x1a,local_90);

          FUN_0042e590();

          FUN_004011b0();

          return false;

        }

        if (param_3 != '\0') {

          return false;

        }

        FUN_0042dc80();

        FUN_00402730(L"Cannot cast spell on a stack of items.");

        FUN_0042cbe0(&local_98,1);

        FUN_004011b0();

      }

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

      return false;

    }

    if (param_3 != '\0') {

      return false;

    }

    FUN_0042dc80();

    FUN_00402730(L"This spell would require a target");

    FUN_0042cbe0(&local_98,1);

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

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

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

    }

  }

  FUN_00693500(0x1a,local_90);

  FUN_0042e590();

  return false;

}





// --- FUN_005682f0 at 0x005682F0 (size: 462) ---


void FUN_005682f0(undefined4 param_1,int param_2)



{

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  int *piVar4;

  int *piVar5;

  int *piVar6;

  undefined4 *puVar7;

  undefined4 local_cc;

  undefined4 local_c8;

  undefined4 local_c4;

  undefined4 local_c0;

  undefined1 local_b4 [16];

  undefined4 local_a4;

  uint local_9c;

  undefined **local_24 [9];

  

  FUN_0048b420();

  puVar7 = (undefined4 *)(DAT_0087144c + 0x10);

  if (*(int *)(DAT_0087144c + 0x10) == 0) {

    uVar1 = FUN_00415730(6,2,0x10000005);

    *puVar7 = uVar1;

  }

  iVar2 = FUN_00567e50(param_1,local_b4);

  if ((iVar2 == 0) || (*(int *)(param_2 + 8) == 0)) {

    FUN_0048b4d0();

    return;

  }

  FUN_00597e20(local_24);

  uVar1 = FUN_005bda10();

  piVar3 = (int *)FUN_00415730(uVar1,0x10000006,0xc);

  local_24[0] = &PTR_FUN_0079385c;

  FUN_00442c70(piVar3 + 0x2b,0,0x3f800000);

  uVar1 = FUN_004220b0(local_a4,0xc);

  piVar4 = (int *)FUN_00415430(uVar1);

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

    FUN_00442c70(piVar4 + 0x2b,2,0x3f800000);

  }

  piVar5 = (int *)FUN_00415730(2 - (uint)((local_9c & 0x10) != 0),0x10000007,0xc);

  local_cc = 0x3f800000;

  local_c8 = 0x3f800000;

  local_c4 = 0x3f800000;

  local_c0 = 0x3f800000;

  FUN_00441750(&local_cc,piVar5 + 0x2b);

  if ((local_9c & 0x2000) == 0) {

    if ((local_9c & 8) == 0) goto LAB_00568486;

    uVar1 = 3;

  }

  else {

    uVar1 = 4;

  }

  piVar6 = (int *)FUN_00415730(uVar1,0x10000007,0xc);

  FUN_00442c70(piVar6 + 0x2b,2,0x3f800000);

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

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

  }

LAB_00568486:

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

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

  }

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

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

  }

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

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

  }

  FUN_0048b4d0();

  return;

}





// --- FUN_005684c0 at 0x005684C0 (size: 198) ---


void FUN_005684c0(undefined4 param_1,int param_2)



{

  undefined4 uVar1;

  int *piVar2;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

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

    uVar1 = FUN_004220b0(param_1,0xc);

    piVar2 = (int *)FUN_00415430(uVar1);

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

      FUN_00443040(&DAT_00871460);

      return;

    }

    FUN_00442c70(piVar2 + 0x2b,0,0x3f800000);

    local_10 = 0x3f800000;

    local_c = 0x3f800000;

    local_8 = 0x3f800000;

    local_4 = 0x3f800000;

    local_20 = 0;

    local_1c = 0;

    local_18 = 0;

    local_14 = 0x3f800000;

    FUN_004416d0(&local_10,&local_20);

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

  }

  return;

}





// --- FUN_00568590 at 0x00568590 (size: 146) ---


undefined4 FUN_00568590(undefined4 param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_00590050(param_1);

    FUN_006a4550(param_1);

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

  }

  return 0;

}





// --- FUN_00568630 at 0x00568630 (size: 146) ---


undefined4 FUN_00568630(undefined4 param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_005900b0(param_1);

    FUN_006a45a0(param_1);

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

  }

  return 0;

}





// --- FUN_005686d0 at 0x005686D0 (size: 173) ---


undefined4 FUN_005686d0(int param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_0058fde0(param_1);

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

      FUN_006a4640();

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

      return 0;

    }

    FUN_006a4280();

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

  }

  return 0;

}





// --- FUN_00568780 at 0x00568780 (size: 142) ---


undefined4 FUN_00568780(undefined4 param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_0058fe20(param_1);

    FUN_006a4280();

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

  }

  return 0;

}





// --- FUN_00568810 at 0x00568810 (size: 140) ---


undefined4 FUN_00568810(void)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_0058fd60();

    FUN_006a4280();

    FUN_006a4640();

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

  }

  return 0;

}





// --- FUN_005688a0 at 0x005688A0 (size: 140) ---


undefined4 FUN_005688a0(void)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  int **ppiVar5;

  undefined4 uVar6;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar5 = &local_14;

  puVar2 = local_10;

  puVar3 = &DAT_007cf648;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar2,&DAT_007cf648,ppiVar5);

  FUN_00406570(puVar2,puVar3,ppiVar5);

  piVar1 = local_14;

  uVar6 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar4 = local_14;

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

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

  }

  FUN_0048bb00(local_c,piVar4,uVar6);

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

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

  }

  piVar1 = local_8;

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

    FUN_0058fd70();

    FUN_006a4280();

    FUN_006a4640();

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

  }

  return 0;

}





// --- FUN_00568930 at 0x00568930 (size: 155) ---


bool FUN_00568930(void)



{

  int *piVar1;

  bool bVar2;

  undefined1 *puVar3;

  undefined *puVar4;

  int *piVar5;

  int **ppiVar6;

  undefined4 uVar7;

  int *local_18;

  int local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar6 = &local_18;

  puVar3 = local_10;

  puVar4 = &DAT_007cf648;

  local_14 = 1;

  local_18 = (int *)0x0;

  FUN_00406d10(puVar3,&DAT_007cf648,ppiVar6);

  FUN_00406570(puVar3,puVar4,ppiVar6);

  piVar1 = local_18;

  uVar7 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar5 = local_18;

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

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

  }

  FUN_0048bb00(local_c,piVar5,uVar7);

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

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

  }

  piVar1 = local_8;

  FUN_00590ca0(0x44,&local_14);

  bVar2 = local_14 != 0;

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

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

  }

  return bVar2;

}





// --- FUN_005689d0 at 0x005689D0 (size: 283) ---


undefined4 FUN_005689d0(undefined4 param_1,int param_2,undefined4 param_3,char param_4)



{

  char cVar1;

  undefined4 uVar2;

  int iVar3;

  int *piVar4;

  undefined4 *puVar5;

  undefined4 uVar6;

  undefined1 local_128 [4];

  undefined1 local_124 [4];

  undefined1 local_120 [144];

  undefined1 local_90 [144];

  

  if (param_2 != 0) {

    FUN_0048b420();

    puVar5 = (undefined4 *)(DAT_0087144c + 0x10);

    if (*(int *)(DAT_0087144c + 0x10) == 0) {

      uVar2 = FUN_00415730(6,2,0x10000005);

      *puVar5 = uVar2;

    }

    iVar3 = FUN_00567e50(param_2,local_120);

    if (iVar3 != 0) {

      uVar2 = FUN_005981a0(param_3);

      cVar1 = FUN_00567fd0(param_1,uVar2);

      if (cVar1 != '\0') {

        if (param_4 != '\0') {

          FUN_0042dc80();

          piVar4 = (int *)FUN_00597d40(local_128);

          uVar6 = 1;

          uVar2 = FUN_00480980(local_124,0,L"Casting %hs",*piVar4 + 0x14,1);

          FUN_0042cbe0(uVar2,uVar6);

          FUN_004011b0();

          FUN_005abb30();

          FUN_00693500(0x1a,local_90);

          FUN_0042e590();

        }

        FUN_0048b4d0();

        return 1;

      }

    }

    FUN_0048b4d0();

  }

  return 0;

}





// --- FUN_00568af0 at 0x00568AF0 (size: 558) ---


undefined4 FUN_00568af0(undefined4 param_1,int param_2)



{

  int *piVar1;

  int *piVar2;

  int iVar3;

  LONG LVar4;

  int iVar5;

  undefined1 *puVar6;

  undefined *puVar7;

  int *piVar8;

  int **ppiVar9;

  undefined4 uVar10;

  int *local_24;

  undefined4 local_20;

  int local_1c;

  undefined1 local_18 [4];

  undefined1 local_14 [4];

  int *local_10;

  undefined4 local_c;

  

  iVar5 = param_2;

  FUN_005bd2c0(&local_20,*(undefined4 *)(param_2 + 0xc));

  iVar3 = FUN_0055e1d0();

  local_1c = FUN_005583f0(*(undefined4 *)(iVar3 + 0x1e8));

  if (local_1c == 0) {

    FUN_004e9280(iVar3 + 0x1c);

    FUN_0048c3e0(local_10 + 5);

    FUN_00597f70(param_1,&local_24);

    LVar4 = InterlockedDecrement(local_24 + 1);

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

      (**(code **)*local_24)(1);

    }

    LVar4 = InterlockedDecrement(local_10 + 1);

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

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

    }

    return param_1;

  }

  ppiVar9 = &local_24;

  puVar6 = local_18;

  puVar7 = &DAT_007cf648;

  param_2 = 0;

  local_24 = (int *)0x0;

  FUN_00406d10(puVar6,&DAT_007cf648,ppiVar9);

  FUN_00406570(puVar6,puVar7,ppiVar9);

  piVar1 = local_24;

  uVar10 = 0;

  local_10 = (int *)0x0;

  local_c = 0;

  piVar8 = local_24;

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

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

  }

  FUN_0048bb00(local_14,piVar8,uVar10);

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

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

  }

  piVar1 = local_10;

  switch(*(undefined4 *)(iVar5 + 0xc)) {

  case 1:

    uVar10 = 0x129;

    break;

  case 2:

    uVar10 = 0x128;

    break;

  case 3:

    uVar10 = 0x127;

    break;

  case 4:

    uVar10 = 0x126;

    break;

  case 5:

    uVar10 = 0x148;

    break;

  default:

    goto switchD_00568c09_default;

  }

  FUN_00590c20(uVar10,&param_2,0,0);

  if (param_2 < 1) {

switchD_00568c09_default:

    iVar5 = FUN_0058d9b0(local_20);

    if (iVar5 == 0) {

      FUN_004e9280(iVar3 + 0x1c);

      piVar2 = local_10;

      FUN_0048c3e0(local_10 + 5);

      FUN_00597f70(param_1,&local_24);

      piVar8 = local_24;

      LVar4 = InterlockedDecrement(local_24 + 1);

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

        (**(code **)*piVar8)(1);

      }

      LVar4 = InterlockedDecrement(piVar2 + 1);

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

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

      }

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

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

      }

      return param_1;

    }

  }

  FUN_00597fc0(param_1);

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

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

  }

  return param_1;

}





// --- FUN_00568d40 at 0x00568D40 (size: 73) ---


void __fastcall FUN_00568d40(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

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

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

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

    puVar2 = puVar2 + 1;

  }

  FUN_005691e0(*puVar2);

  return;

}





// --- FUN_00568d90 at 0x00568D90 (size: 73) ---


void __fastcall FUN_00568d90(int param_1)



{

  undefined *puVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  puVar1 = PTR_DAT_00818558;

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

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

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

    puVar2 = puVar2 + 1;

  }

  FUN_00569320(*puVar2);

  return;

}





// --- FUN_00568de0 at 0x00568DE0 (size: 725) ---


void FUN_00568de0(undefined4 param_1)



{

  char cVar1;

  undefined4 uVar2;

  int iVar3;

  LONG LVar4;

  undefined4 *puVar5;

  int iVar6;

  int local_148;

  undefined **local_144;

  undefined4 auStack_140 [8];

  undefined1 local_120 [24];

  byte local_108;

  undefined1 local_90 [144];

  

  FUN_0048b420();

  puVar5 = (undefined4 *)(DAT_0087144c + 0x10);

  if (*(int *)(DAT_0087144c + 0x10) == 0) {

    uVar2 = FUN_00415730(6,2,0x10000005);

    *puVar5 = uVar2;

  }

  iVar3 = FUN_00567e50(param_1,local_120);

  if (iVar3 == 0) {

    FUN_0048b4d0();

    return;

  }

  cVar1 = FUN_00568930();

  if (cVar1 != '\0') {

    FUN_00568af0(&local_144,local_120);

    FUN_0055e1d0();

    FUN_0055e220();

    iVar6 = 0;

    iVar3 = FUN_005bd990();

    if (0 < iVar3) {

      do {

        if ((iVar6 < 0) || (7 < iVar6)) {

          uVar2 = 0;

        }

        else {

          uVar2 = auStack_140[iVar6];

        }

        puVar5 = (undefined4 *)FUN_005bd3c0(&local_148,uVar2);

        iVar3 = FUN_005872b0(*puVar5);

        if (iVar3 == 0) {

          FUN_0042dc80();

          FUN_00402730(L"You do not have all of this spell\'s components");

          FUN_0042cbe0(&local_148,1);

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

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

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

          }

          FUN_00693500(0x1a,local_90);

          FUN_0042e590();

          local_144 = &PTR_FUN_0079385c;

          FUN_0048b4d0();

          return;

        }

        iVar6 = iVar6 + 1;

        iVar3 = FUN_005bd990();

      } while (iVar6 < iVar3);

    }

  }

  if ((local_108 & 8) == 0) {

    iVar6 = FUN_005981a0();

    iVar3 = DAT_00871e54;

    if (iVar6 == 0) {

      (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0xc0))();

      FUN_006a3f70(param_1);

      FUN_00564d30();

      FUN_00565610();

      FUN_0048b4d0();

      return;

    }

    if (DAT_00871e54 == 0) {

      FUN_0042dc80();

      FUN_00402730(L"You must select a suitable target before casting this spell");

      FUN_0042cbe0(&local_148,1);

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

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

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

      }

      FUN_00693500(0x1a,local_90);

      FUN_0042e590();

    }

    else {

      cVar1 = FUN_005689d0(DAT_00871e54,param_1,0,1);

      if (cVar1 != '\0') {

        FUN_00567c90(param_1,iVar3);

        FUN_0058d110(iVar3,0);

        FUN_0048b4d0();

        return;

      }

    }

    FUN_0048b4d0();

    return;

  }

  if (DAT_0083da58 == 0) {

    FUN_00567c90(param_1,0);

    FUN_0048b4d0();

    return;

  }

  FUN_00567c90(param_1,*(undefined4 *)(DAT_0083da58 + 0xf4));

  FUN_0048b4d0();

  return;

}





// --- FUN_005690c0 at 0x005690C0 (size: 143) ---


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



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007cf78c;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

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

    *(undefined1 *)puVar6 = 0;

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

  }

  return param_1;

}





// --- FUN_00569150 at 0x00569150 (size: 143) ---


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



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007cf790;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

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

    *(undefined1 *)puVar6 = 0;

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

  }

  return param_1;

}





// --- FUN_005691e0 at 0x005691E0 (size: 310) ---


undefined4 __thiscall FUN_005691e0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  int *piVar5;

  uint *puVar6;

  uint *puVar7;

  undefined4 *puVar8;

  uint *puVar9;

  uint uVar10;

  uint *puVar11;

  

  iVar2 = param_2;

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

    return 0;

  }

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

  puVar3 = (uint *)0x0;

  do {

    if (iVar1 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

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

      }

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

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

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

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

      FUN_00693b20(iVar2);

      puVar4 = (undefined4 *)PTR_DAT_00818558;

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

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

        puVar11 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar4;

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

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

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

            puVar8 = puVar8 + 1;

          }

          FUN_005691e0(*puVar8);

        }

        uVar10 = *puVar3 % *(uint *)(param_1 + 0x68);

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

        puVar3[1] = *(uint *)(iVar2 + uVar10 * 4);

        *(uint **)(iVar2 + uVar10 * 4) = puVar3;

        uVar10 = iVar2 + uVar10 * 4;

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

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

        }

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

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar11;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

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

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

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

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

        puVar9 = (uint *)*puVar11;

        goto LAB_0056922f;

      }

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

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

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_0056922f:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_00569242:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

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

      puVar6[1] = puVar7[1];

    }

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

    puVar9[1] = (uint)puVar3;

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

    puVar3 = puVar9;

  } while( true );

}





// --- FUN_00569320 at 0x00569320 (size: 310) ---


undefined4 __thiscall FUN_00569320(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  int *piVar5;

  uint *puVar6;

  uint *puVar7;

  undefined4 *puVar8;

  uint *puVar9;

  uint uVar10;

  uint *puVar11;

  

  iVar2 = param_2;

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

    return 0;

  }

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

  puVar3 = (uint *)0x0;

  do {

    if (iVar1 == 0) {

      if (*(void **)(param_1 + 0x60) != (void *)(param_1 + 4)) {

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

      }

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

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

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

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

      FUN_00693b20(iVar2);

      puVar4 = (undefined4 *)PTR_DAT_00818558;

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

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

        puVar11 = (uint *)puVar3[1];

        PTR_DAT_00818558 = (undefined *)puVar4;

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

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

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

            puVar8 = puVar8 + 1;

          }

          FUN_00569320(*puVar8);

        }

        uVar10 = *puVar3 % *(uint *)(param_1 + 0x68);

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

        puVar3[1] = *(uint *)(iVar2 + uVar10 * 4);

        *(uint **)(iVar2 + uVar10 * 4) = puVar3;

        uVar10 = iVar2 + uVar10 * 4;

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

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

        }

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

        puVar4 = (undefined4 *)PTR_DAT_00818558;

        puVar3 = puVar11;

      }

      PTR_DAT_00818558 = (undefined *)puVar4;

      return 1;

    }

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

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

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

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

        puVar9 = (uint *)*puVar11;

        goto LAB_0056936f;

      }

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

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

    }

    puVar11 = (uint *)0x0;

    puVar9 = (uint *)0x0;

LAB_0056936f:

    puVar7 = (uint *)*puVar11;

    if (puVar7 == puVar9) {

LAB_00569382:

      *puVar11 = puVar7[1];

    }

    else {

      do {

        puVar6 = puVar7;

        puVar7 = (uint *)puVar6[1];

      } while (puVar7 != puVar9);

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

      puVar6[1] = puVar7[1];

    }

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

    puVar9[1] = (uint)puVar3;

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

    puVar3 = puVar9;

  } while( true );

}





// --- FUN_00569460 at 0x00569460 (size: 398) ---


undefined4 FUN_00569460(ushort param_1)



{

  int iVar1;

  LONG LVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  undefined4 *local_98;

  undefined4 *puStack_94;

  undefined1 local_90 [144];

  

  FUN_0048c3e0(&DAT_007938af);

  iVar1 = FUN_0058a000(0,&local_98,7);

  puVar4 = local_98;

  LVar2 = InterlockedDecrement(local_98 + 1);

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

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

  }

  if ((iVar1 == 0) && (param_1 < 0x8000)) {

    FUN_0048b420();

    puVar4 = (undefined4 *)(DAT_0087144c + 0x10);

    if (*(int *)(DAT_0087144c + 0x10) == 0) {

      uVar3 = FUN_00415730(6,2,0x10000005);

      *puVar4 = uVar3;

    }

    iVar1 = FUN_00567e50(param_1,local_90);

    if (iVar1 == 0) {

      FUN_0048b4d0();

      return 0;

    }

    FUN_00597d40(&puStack_94);

    if (param_1 == 0x29a) {

      FUN_0048c3e0(" penalty");

      FUN_004914f0(&local_98);

      FUN_005abb30();

    }

    FUN_0048c3e0(" has expired.\n");

    if ((local_98[2] != 1) && (local_98 != DAT_008ef11c)) {

      FUN_004910c0(local_98 + 5,local_98[2] + -1);

    }

    LVar2 = InterlockedDecrement(local_98 + 1);

    if (LVar2 == 0) {

      (**(code **)*local_98)(1);

    }

    FUN_004882f0(puStack_94 + 5,7,1,0);

    LVar2 = InterlockedDecrement(puStack_94 + 1);

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

      (**(code **)*puStack_94)(1);

    }

    FUN_0048b4d0();

  }

  return 1;

}





// --- FUN_005695f0 at 0x005695F0 (size: 120) ---


uint __thiscall FUN_005695f0(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

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

  do {

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

LAB_0056961b:

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

        FUN_00568d40();

      }

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

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

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

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

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

      }

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

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

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

    }

    if (*puVar1 == *param_2) {

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

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_0056961b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00569670 at 0x00569670 (size: 120) ---


uint __thiscall FUN_00569670(int param_1,uint *param_2)



{

  uint *puVar1;

  int iVar2;

  uint uVar3;

  

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

  do {

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

LAB_0056969b:

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

        FUN_00568d90();

      }

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

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

      param_2[1] = *(uint *)(iVar2 + uVar3 * 4);

      *(uint **)(iVar2 + uVar3 * 4) = param_2;

      uVar3 = iVar2 + uVar3 * 4;

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

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

      }

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

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

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

    }

    if (*puVar1 == *param_2) {

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

        return (uint)puVar1 & 0xffffff00;

      }

      goto LAB_0056969b;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_005696f0 at 0x005696F0 (size: 219) ---


undefined4 FUN_005696f0(int param_1,char param_2)



{

  bool bVar1;

  int *piVar2;

  int iVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int *piVar6;

  int **ppiVar7;

  undefined4 uVar8;

  int *local_64;

  undefined1 local_60 [4];

  undefined1 local_5c [4];

  int *local_58;

  undefined4 local_54;

  undefined1 auStack_50 [4];

  int iStack_4c;

  

  ppiVar7 = &local_64;

  puVar4 = local_60;

  puVar5 = &DAT_007cf648;

  local_64 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007cf648,ppiVar7);

  FUN_00406570(puVar4,puVar5,ppiVar7);

  piVar2 = local_64;

  uVar8 = 0;

  local_58 = (int *)0x0;

  local_54 = 0;

  piVar6 = local_64;

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

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

  }

  FUN_0048bb00(local_5c,piVar6,uVar8);

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

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

  }

  piVar2 = local_58;

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

    bVar1 = false;

    FUN_005cbdd0();

    iVar3 = FUN_0058fe60(auStack_50);

    if ((iVar3 != 0) && (iStack_4c == param_1)) {

      bVar1 = true;

    }

    FUN_0058fda0(param_1);

    if (bVar1) {

      FUN_006a4640();

    }

    else {

      FUN_006a4280();

    }

  }

  if (param_2 != '\0') {

    FUN_00569460(param_1);

  }

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

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

  }

  return 0;

}





// --- FUN_005697d0 at 0x005697D0 (size: 224) ---


undefined4 FUN_005697d0(int *param_1,char param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int *piVar6;

  int **ppiVar7;

  undefined4 uVar8;

  int *local_68 [2];

  undefined1 local_60 [4];

  undefined1 local_5c [4];

  int *local_58;

  undefined4 local_54;

  undefined1 auStack_50 [4];

  int iStack_4c;

  

  ppiVar7 = local_68;

  puVar4 = local_60;

  puVar5 = &DAT_007cf648;

  iVar3 = 0;

  local_68[0] = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007cf648,ppiVar7);

  FUN_00406570(puVar4,puVar5,ppiVar7);

  piVar1 = local_68[0];

  uVar8 = 0;

  local_58 = (int *)0x0;

  local_54 = 0;

  piVar6 = local_68[0];

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

    (**(code **)(*local_68[0] + 0x10))(local_68[0],0);

  }

  FUN_0048bb00(local_5c,piVar6,uVar8);

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

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

  }

  piVar1 = local_58;

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

    FUN_005cbdd0();

    iVar2 = FUN_0058fe60(auStack_50);

    if (iVar2 != 0) {

      iVar3 = iStack_4c;

    }

    FUN_0058fdc0(param_1);

    FUN_006a4280();

  }

  while (param_1 = (int *)param_1[1], param_1 != (int *)0x0) {

    if (param_2 != '\0') {

      FUN_00569460(*param_1);

    }

    if (*param_1 == iVar3) {

      FUN_006a4640();

    }

  }

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

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

  }

  return 0;

}





// --- FUN_005698b0 at 0x005698B0 (size: 15) ---


void FUN_005698b0(undefined4 param_1)



{

  FUN_005696f0(param_1,0);

  return;

}





// --- FUN_005698c0 at 0x005698C0 (size: 15) ---


void FUN_005698c0(undefined4 param_1)



{

  FUN_005697d0(param_1,0);

  return;

}





// --- FUN_005698d0 at 0x005698D0 (size: 88) ---


undefined4 FUN_005698d0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

  }

  cVar1 = FUN_005695f0(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_00569930 at 0x00569930 (size: 88) ---


undefined4 FUN_00569930(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

  }

  cVar1 = FUN_00569670(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_00569990 at 0x00569990 (size: 188) ---


uint __thiscall FUN_00569990(int param_1,uint param_2)



{

  uint *puVar1;

  char cVar2;

  int *piVar3;

  undefined4 uVar4;

  int iVar5;

  uint uVar6;

  undefined4 unaff_ESI;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x80) + (param_2 % *(uint *)(param_1 + 0x88)) * 4);

  do {

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

LAB_005699cc:

      uVar6 = 0;

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

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

        iVar5 = *piVar3;

        uVar4 = FUN_0054fe80(1);

        cVar2 = (**(code **)(iVar5 + 0x58))(0x20,0x20,uVar4);

        if (cVar2 != '\0') {

          iVar5 = FUN_005df0f5(0xc);

          if (iVar5 == 0) {

            uVar6 = 0;

          }

          else {

            uVar6 = FUN_00694d80(piVar3);

          }

          FUN_005698d0(&stack0xfffffff4,&stack0xffffffec);

          FUN_005682f0(unaff_ESI,uVar6);

        }

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

      }

      return uVar6;

    }

    if (*puVar1 == param_2) {

      if ((puVar1 != (uint *)0x0) && (puVar1[2] != 0)) {

        return puVar1[2];

      }

      goto LAB_005699cc;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00569a50 at 0x00569A50 (size: 191) ---


uint __thiscall FUN_00569a50(int param_1,uint param_2)



{

  uint *puVar1;

  char cVar2;

  int *piVar3;

  undefined4 uVar4;

  int iVar5;

  uint uVar6;

  undefined4 unaff_ESI;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0xf4) + (param_2 % *(uint *)(param_1 + 0xfc)) * 4);

  do {

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

LAB_00569a8c:

      uVar6 = 0;

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

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

        iVar5 = *piVar3;

        uVar4 = FUN_0054fe80(1);

        cVar2 = (**(code **)(iVar5 + 0x58))(0x20,0x20,uVar4);

        if (cVar2 != '\0') {

          iVar5 = FUN_005df0f5(0xc);

          if (iVar5 == 0) {

            uVar6 = 0;

          }

          else {

            uVar6 = FUN_00694d80(piVar3);

          }

          FUN_00569930(&stack0xfffffff4,&stack0xffffffec);

          FUN_005684c0(unaff_ESI,uVar6);

        }

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

      }

      return uVar6;

    }

    if (*puVar1 == param_2) {

      if ((puVar1 != (uint *)0x0) && (puVar1[2] != 0)) {

        return puVar1[2];

      }

      goto LAB_00569a8c;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





// --- FUN_00569b10 at 0x00569B10 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007cfa1c;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007cf78c;

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

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

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00569b70 at 0x00569B70 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007cfa20;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007cf790;

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

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

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00569bd0 at 0x00569BD0 (size: 108) ---


undefined4 * __fastcall FUN_00569bd0(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007cfa24;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = &PTR_FUN_007cfa1c;

  FUN_005690c0(0x17);

  param_1[0x24] = &PTR_FUN_007cfa20;

  FUN_00569150(0x17);

  DAT_0087144c = param_1;

  InterlockedIncrement(param_1 + 3);

  return param_1;

}





// --- FUN_00569c40 at 0x00569C40 (size: 385) ---


void __fastcall FUN_00569c40(undefined4 *param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined1 local_c [12];

  

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007cfa24;

  piVar1 = (int *)FUN_0052dcf0(local_c);

  iVar2 = piVar1[2];

  iVar3 = *piVar1;

  piVar1 = (int *)piVar1[1];

  while (iVar2 != 0) {

    do {

      if (*(undefined4 **)(iVar2 + 8) != (undefined4 *)0x0) {

        (**(code **)**(undefined4 **)(iVar2 + 8))(1);

      }

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

    } while (iVar2 != 0);

    do {

      piVar1 = piVar1 + 1;

      if (piVar1 == (int *)(*(int *)(iVar3 + 0x60) + *(int *)(iVar3 + 0x68) * 4)) goto LAB_00569cb4;

      iVar2 = *piVar1;

    } while (iVar2 == 0);

  }

LAB_00569cb4:

  FUN_005870f0();

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

  do {

    if (piVar1 == (int *)(param_1[0x3d] + param_1[0x3f] * 4)) {

      piVar1 = (int *)0x0;

      iVar3 = 0;

joined_r0x00569cf6:

      while (iVar3 != 0) {

        do {

          if (*(undefined4 **)(iVar3 + 8) != (undefined4 *)0x0) {

            (**(code **)**(undefined4 **)(iVar3 + 8))(1);

          }

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

        } while (iVar3 != 0);

        do {

          piVar1 = piVar1 + 1;

          if (piVar1 == (int *)(param_1[0x3d] + param_1[0x3f] * 4)) goto LAB_00569d28;

          iVar3 = *piVar1;

        } while (iVar3 == 0);

      }

LAB_00569d28:

      FUN_005870f0();

      param_1[0x24] = &PTR_FUN_007cfa20;

      FUN_005870f0();

      param_1[0x25] = &PTR_FUN_007cf790;

      if ((undefined4 *)param_1[0x3d] != param_1 + 0x26) {

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

      }

      param_1[0x3d] = 0;

      param_1[0x3e] = 0;

      param_1[0x3f] = 0;

      param_1[0x40] = 0;

      param_1[7] = &PTR_FUN_007cfa1c;

      FUN_005870f0();

      param_1[8] = &PTR_FUN_007cf78c;

      if ((undefined4 *)param_1[0x20] != param_1 + 9) {

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

      }

      param_1[0x20] = 0;

      param_1[0x21] = 0;

      param_1[0x22] = 0;

      param_1[0x23] = 0;

      param_1[2] = &PTR_LAB_00793b6c;

      param_1[1] = &PTR_FUN_007ccb60;

      FUN_0043c610();

      return;

    }

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

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

      iVar3 = *piVar1;

      goto joined_r0x00569cf6;

    }

    piVar1 = (int *)param_1[0x3e] + 1;

    param_1[0x3e] = piVar1;

  } while( true );

}





// --- FUN_00569dd0 at 0x00569DD0 (size: 43) ---


int __fastcall FUN_00569dd0(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_00569c40();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_00569e00 at 0x00569E00 (size: 35) ---


void __fastcall FUN_00569e00(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007cfc34;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_00569e30 at 0x00569E30 (size: 6) ---


undefined4 FUN_00569e30(void)



{

  return DAT_0087150c;

}





// --- FUN_00569e40 at 0x00569E40 (size: 25) ---


void __fastcall FUN_00569e40(int param_1)



{

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

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

  }

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

  return;

}





// --- FUN_00569e60 at 0x00569E60 (size: 109) ---


undefined4 FUN_00569e60(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_005ba1c0(param_1);

  FUN_005ba870(param_1,param_2);

  if (iVar1 == 0) {

    iVar1 = FUN_005583f0(param_1);

    if (iVar1 != 0) {

      FUN_006a3490(iVar1);

    }

    FUN_006a73b0(param_1);

  }

  FUN_006a74a0(param_1,param_2,param_3);

  FUN_00589eb0(3,1);

  return 0;

}





// --- FUN_00569ed0 at 0x00569ED0 (size: 30) ---


bool __thiscall FUN_00569ed0(int param_1,undefined4 param_2)



{

  int iVar1;

  

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

    iVar1 = FUN_005ba1c0(param_2);

    return iVar1 != 0;

  }

  return false;

}





// --- FUN_00569ef0 at 0x00569EF0 (size: 25) ---


undefined4 __thiscall FUN_00569ef0(int param_1,int param_2)



{

  int iVar1;

  

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

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

    return CONCAT31((int3)((uint)iVar1 >> 8),iVar1 == param_2);

  }

  return 0;

}





// --- FUN_00569fe0 at 0x00569FE0 (size: 43) ---


int __fastcall FUN_00569fe0(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_00569e00();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_0056a010 at 0x0056A010 (size: 64) ---


undefined4 * __fastcall FUN_0056a010(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007cfc34;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[4] = 0;

  DAT_0087150c = param_1;

  InterlockedIncrement(param_1 + 3);

  return param_1;

}





// --- FUN_0056a0e0 at 0x0056A0E0 (size: 40) ---


int __fastcall FUN_0056a0e0(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int *piVar4;

  

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

  iVar2 = 4;

  if (iVar3 != 0) {

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

    do {

      for (iVar1 = *piVar4; iVar1 != 0; iVar1 = *(int *)(iVar1 + 8)) {

        iVar2 = iVar2 + 8;

      }

      piVar4 = piVar4 + 1;

      iVar3 = iVar3 + -1;

    } while (iVar3 != 0);

  }

  return iVar2;

}





// --- FUN_0056a110 at 0x0056A110 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007cfc64;

  FUN_005d59a0();

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

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

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0056a160 at 0x0056A160 (size: 291) ---


undefined4 __thiscall FUN_0056a160(int param_1,int param_2)



{

  uint uVar1;

  bool bVar2;

  undefined4 *puVar3;

  int iVar4;

  undefined4 uVar5;

  int iVar6;

  int iVar7;

  undefined1 local_10 [4];

  undefined4 *local_c;

  int local_8;

  uint local_4;

  

  bVar2 = false;

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

    bVar2 = true;

    iVar4 = FUN_005df0f5(0x44);

    if (iVar4 == 0) {

      uVar5 = 0;

    }

    else {

      uVar5 = FUN_0059b570();

    }

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

  }

  iVar4 = *(int *)(*(int *)(param_1 + 0x10) + 0x1c);

  iVar6 = 0;

  iVar7 = 0;

  if (iVar4 != *(int *)(param_2 + 0x1c)) {

    iVar6 = *(int *)(param_2 + 0x1c);

    iVar7 = iVar4;

  }

  FUN_005ba960(param_2);

  FUN_006a7610(*(undefined4 *)(param_1 + 0x10));

  if (bVar2) {

    FUN_0048ecc0(local_10);

joined_r0x0056a1df:

    puVar3 = local_c;

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

      iVar4 = FUN_005583f0(*puVar3);

      if (iVar4 != 0) {

        FUN_006a3490(iVar4);

      }

      local_c = (undefined4 *)puVar3[0xd];

      if ((undefined4 *)puVar3[0xd] == (undefined4 *)0x0) {

        uVar1 = puVar3[0xe];

        do {

          uVar1 = uVar1 + 1;

          if (local_4 <= uVar1) {

            local_c = (undefined4 *)0x0;

            goto joined_r0x0056a1df;

          }

        } while (*(int *)(local_8 + uVar1 * 4) == 0);

        local_c = *(undefined4 **)(local_8 + uVar1 * 4);

      }

      goto joined_r0x0056a1df;

    }

  }

  else if (iVar7 != iVar6) {

    iVar4 = FUN_005583f0(iVar7);

    if (iVar4 != 0) {

      FUN_006a3490(iVar4);

    }

    iVar4 = FUN_005583f0(iVar6);

    if (iVar4 != 0) {

      FUN_006a3490(iVar4);

    }

    FUN_006a7550(iVar6,iVar7);

  }

  FUN_00589eb0(3,1);

  return 0;

}





// --- FUN_0056a290 at 0x0056A290 (size: 202) ---


void __fastcall FUN_0056a290(int param_1)



{

  uint uVar1;

  int *piVar2;

  int iVar3;

  undefined1 local_10 [4];

  int *local_c;

  int local_8;

  uint local_4;

  

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

    iVar3 = FUN_005ba1c0(DAT_00871e54);

    if (iVar3 != 0) {

      iVar3 = 0;

      FUN_0048ecc0(local_10);

joined_r0x0056a2d0:

      piVar2 = local_c;

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

        if (iVar3 == DAT_00871e54) {

          FUN_0058d110(*piVar2,0);

          return;

        }

        iVar3 = *piVar2;

        local_c = (int *)piVar2[0xd];

        if ((int *)piVar2[0xd] == (int *)0x0) {

          uVar1 = piVar2[0xe];

          do {

            uVar1 = uVar1 + 1;

            if (local_4 <= uVar1) {

              local_c = (int *)0x0;

              goto joined_r0x0056a2d0;

            }

          } while (*(int *)(local_8 + uVar1 * 4) == 0);

          local_c = *(int **)(local_8 + uVar1 * 4);

        }

        goto joined_r0x0056a2d0;

      }

    }

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

      iVar3 = FUN_0048ecc0(local_10);

      FUN_0058d110(**(undefined4 **)(iVar3 + 4),0);

    }

  }

  return;

}





// --- FUN_0056a360 at 0x0056A360 (size: 168) ---


void __fastcall FUN_0056a360(int param_1)



{

  uint uVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  undefined1 local_10 [4];

  int *local_c;

  int local_8;

  uint local_4;

  

  iVar3 = DAT_00871e54;

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

    return;

  }

  FUN_0048ecc0(local_10);

  iVar5 = 0;

joined_r0x0056a392:

  do {

    do {

      piVar2 = local_c;

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

         ((((iVar5 != 0 && (*(int *)(param_1 + 0x10) != 0)) &&

           (iVar4 = FUN_005ba1c0(iVar3), iVar4 != 0)) && (*piVar2 == iVar3)))) {

        FUN_0058d110(iVar5,0);

        return;

      }

      iVar5 = *piVar2;

      local_c = (int *)piVar2[0xd];

    } while ((int *)piVar2[0xd] != (int *)0x0);

    uVar1 = piVar2[0xe];

    do {

      uVar1 = uVar1 + 1;

      if (local_4 <= uVar1) {

        local_c = (int *)0x0;

        goto joined_r0x0056a392;

      }

    } while (*(int *)(local_8 + uVar1 * 4) == 0);

    local_c = *(int **)(local_8 + uVar1 * 4);

  } while( true );

}





// --- FUN_0056a410 at 0x0056A410 (size: 273) ---


bool __thiscall FUN_0056a410(int param_1,int *param_2,uint param_3)



{

  undefined4 *puVar1;

  int *piVar2;

  uint uVar3;

  uint uVar4;

  int iVar5;

  uint uVar6;

  undefined4 local_c;

  int local_8;

  uint local_4;

  

  uVar3 = param_3;

  piVar2 = param_2;

  if (param_3 < 4) {

    return false;

  }

  local_8 = *param_2;

  local_4 = param_3;

  FUN_005d59a0();

  if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

  }

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

  uVar4 = *(uint *)*piVar2;

  *piVar2 = (int)((uint *)*piVar2 + 1);

  uVar6 = uVar4 >> 0x10;

  uVar4 = uVar4 & 0xffff;

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

  if (uVar6 == 0) {

    return uVar4 == 0;

  }

  if (((0x10000 < uVar6) || (0x10000 < uVar4)) || (iVar5 = FUN_005a8440(), iVar5 == 0)) {

    return false;

  }

  param_3 = 0;

  if (uVar4 != 0) {

    do {

      if (uVar3 - 4 < 4) {

        return false;

      }

      puVar1 = (undefined4 *)*piVar2;

      local_c = *puVar1;

      *piVar2 = (int)(puVar1 + 1);

      param_2 = (int *)puVar1[1];

      *piVar2 = (int)(puVar1 + 2);

      iVar5 = FUN_0052dfd0(&local_c,&param_2);

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

        return false;

      }

      param_3 = param_3 + 1;

    } while (param_3 < uVar4);

  }

  return (uint)(*piVar2 - local_8) <= local_4;

}





// --- FUN_0056a530 at 0x0056A530 (size: 155) ---


undefined4 __thiscall FUN_0056a530(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[0xd]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x3c);

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

    return 0;

  }

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

  *puVar1 = *param_2;

  FUN_005baa30(param_3);

  puVar1[0xd] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[0xe] = uVar2;

  puVar1[0xd] = *(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_0056a5d0 at 0x0056A5D0 (size: 118) ---


int __thiscall FUN_0056a5d0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_1 != param_2) {

    FUN_005d59a0();

    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 + 8);

          FUN_0052dfd0(iVar2,iVar2 + 4);

          iVar2 = iVar1;

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(param_2 + 0xc));

    }

  }

  return param_1;

}





// --- FUN_0056a650 at 0x0056A650 (size: 70) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  

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

  *(undefined ***)((int)param_1 + 4) = &PTR_FUN_007a61ac;

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *(undefined ***)((int)param_1 + 4) = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0056a6a0 at 0x0056A6A0 (size: 145) ---


void __fastcall FUN_0056a6a0(int param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  void *pvVar3;

  LONG LVar4;

  uint local_4;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_4 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar3 = *(void **)(*(int *)(param_1 + 8) + local_4 * 4);

      while (pvVar3 != (void *)0x0) {

        puVar1 = *(undefined4 **)((int)pvVar3 + 8);

        pvVar2 = *(void **)((int)pvVar3 + 0x34);

        *(undefined ***)((int)pvVar3 + 4) = &PTR_FUN_007a61ac;

        LVar4 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        *(undefined ***)((int)pvVar3 + 4) = &PTR_FUN_0079385c;

        operator_delete(pvVar3);

        pvVar3 = pvVar2;

      }

      *(undefined4 *)(*(int *)(param_1 + 8) + local_4 * 4) = 0;

      local_4 = local_4 + 1;

    } while (local_4 < *(uint *)(param_1 + 0xc));

  }

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

  return;

}





// --- FUN_0056a7d0 at 0x0056A7D0 (size: 91) ---


int __fastcall FUN_0056a7d0(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 + 0x34)) {

        iVar2 = (**(code **)(*(int *)(iVar1 + 4) + 0xc))(&local_4,0);

        iVar4 = iVar4 + 4 + iVar2;

      }

      uVar3 = uVar3 + 1;

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

  }

  return iVar4;

}





// --- FUN_0056a970 at 0x0056A970 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007cfc78;

  FUN_0056a6a0();

  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_0056a9c0 at 0x0056A9C0 (size: 118) ---


int __thiscall FUN_0056a9c0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_1 != param_2) {

    FUN_0056a6a0();

    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 + 0x34);

          FUN_0056a530(iVar2,iVar2 + 4);

          iVar2 = iVar1;

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(param_2 + 0xc));

    }

  }

  return param_1;

}





// --- FUN_0056aa40 at 0x0056AA40 (size: 134) ---


void __fastcall FUN_0056aa40(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  param_1[0xc] = &PTR_FUN_007cfc64;

  FUN_005d59a0();

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

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

    param_1[0xe] = 0;

  }

  param_1[0xf] = 0;

  param_1[0xc] = &PTR_FUN_0079385c;

  puVar1 = (undefined4 *)param_1[6];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  param_1[1] = &PTR_FUN_007cfc78;

  FUN_0056a6a0();

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

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

    param_1[3] = 0;

  }

  param_1[4] = 0;

  param_1[1] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0056aad0 at 0x0056AAD0 (size: 125) ---


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



{

  int iVar1;

  

  *param_1 = &PTR_FUN_007e6214;

  param_1[1] = &PTR_FUN_007cfc78;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  FUN_0056a9c0(param_2 + 4);

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

  param_1[6] = iVar1;

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

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

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

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

  param_1[10] = *(undefined4 *)(param_2 + 0x28);

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

  param_1[0xc] = &PTR_FUN_007cfc64;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  FUN_0056a5d0(param_2 + 0x30);

  return param_1;

}





// --- FUN_0056ab50 at 0x0056AB50 (size: 159) ---


void __fastcall FUN_0056ab50(int param_1)



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined1 local_54 [4];

  undefined4 *puStack_50;

  int iStack_4c;

  uint uStack_48;

  

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

    FUN_0056aad0(*(int *)(param_1 + 0x10));

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

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

    }

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

    FUN_0048ecc0(local_54);

joined_r0x0056ab93:

    puVar2 = puStack_50;

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

      iVar3 = FUN_005583f0(*puVar2);

      if (iVar3 != 0) {

        FUN_006a3490(iVar3);

      }

      puStack_50 = (undefined4 *)puVar2[0xd];

      if ((undefined4 *)puVar2[0xd] == (undefined4 *)0x0) {

        uVar1 = puVar2[0xe];

        do {

          uVar1 = uVar1 + 1;

          if (uStack_48 <= uVar1) {

            puStack_50 = (undefined4 *)0x0;

            goto joined_r0x0056ab93;

          }

        } while (*(int *)(iStack_4c + uVar1 * 4) == 0);

        puStack_50 = *(undefined4 **)(iStack_4c + uVar1 * 4);

      }

      goto joined_r0x0056ab93;

    }

    FUN_0056aa40();

  }

  return;

}





// --- FUN_0056ac10 at 0x0056AC10 (size: 25) ---


undefined4 FUN_0056ac10(void)



{

  FUN_0056ab50();

  FUN_006a7500();

  FUN_00589eb0(3,0);

  return 0;

}





// --- FUN_0056ac30 at 0x0056AC30 (size: 116) ---


undefined4 FUN_0056ac30(int param_1)



{

  int iVar1;

  

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

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

  }

  if (param_1 == iVar1) {

    FUN_0056ab50();

  }

  else {

    FUN_005ba7c0(param_1);

    iVar1 = FUN_005583f0(param_1);

    if (iVar1 != 0) {

      FUN_006a3490(iVar1);

    }

  }

  FUN_006a7450(param_1);

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

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

  }

  if (param_1 == iVar1) {

    FUN_00589eb0(3,0);

  }

  return 0;

}





// --- FUN_0056acb0 at 0x0056ACB0 (size: 116) ---


undefined4 FUN_0056acb0(int param_1)



{

  int iVar1;

  

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

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

  }

  if (param_1 == iVar1) {

    FUN_0056ab50();

  }

  else {

    FUN_005ba7c0(param_1);

    iVar1 = FUN_005583f0(param_1);

    if (iVar1 != 0) {

      FUN_006a3490(iVar1);

    }

  }

  FUN_006a7400(param_1);

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

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

  }

  if (param_1 == iVar1) {

    FUN_00589eb0(3,0);

  }

  return 0;

}





// --- FUN_0056ad30 at 0x0056AD30 (size: 6) ---


undefined4 FUN_0056ad30(void)



{

  return DAT_008715bc;

}





// --- FUN_0056ad70 at 0x0056AD70 (size: 18) ---


undefined4 FUN_0056ad70(undefined4 param_1)



{

  FUN_006a8330(param_1);

  return 0;

}





// --- FUN_0056ad90 at 0x0056AD90 (size: 28) ---


undefined4 FUN_0056ad90(undefined4 param_1,int param_2)



{

  FUN_006a8290(param_1,param_2 != 0);

  return 0;

}





// --- FUN_0056adb0 at 0x0056ADB0 (size: 56) ---


void __fastcall FUN_0056adb0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007cfe6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_005b8c00();

  param_1[4] = &PTR_FUN_0079385c;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_0056aec0 at 0x0056AEC0 (size: 34) ---


undefined4 FUN_0056aec0(undefined4 param_1,undefined4 param_2)



{

  FUN_005b7b10(param_1);

  FUN_006a82e0(param_1,param_2);

  return 0;

}





// --- FUN_0056aef0 at 0x0056AEF0 (size: 65) ---


undefined4 * __fastcall FUN_0056aef0(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007cfe6c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  FUN_0059a080();

  DAT_008715bc = param_1;

  InterlockedIncrement(param_1 + 3);

  return param_1;

}





// --- FUN_0056af40 at 0x0056AF40 (size: 43) ---


int __fastcall FUN_0056af40(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_0056adb0();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_0056af70 at 0x0056AF70 (size: 551) ---


undefined4 FUN_0056af70(int param_1)



{

  int iVar1;

  LONG LVar2;

  int iVar3;

  undefined *puVar4;

  undefined4 *unaff_ESI;

  undefined4 *puVar5;

  int iStack_54;

  undefined1 *puStack_50;

  undefined1 auStack_40 [8];

  undefined1 local_38 [52];

  int iStack_4;

  

  puStack_50 = (undefined1 *)0x56af81;

  FUN_0059a040();

  puStack_50 = local_38;

  iStack_54 = param_1;

  iVar1 = FUN_005b7bd0();

  if (iVar1 == 0) {

    FUN_005b76c0();

    return 0;

  }

  FUN_00402730(L"Note: An asterisk (*) indicates that the character is currently online.\n");

  FUN_005649f0(&iStack_4,0,1,0);

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

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

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

  }

  iVar1 = DAT_008ef11c;

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

  FUN_005b7a40(&stack0xffffffb8);

  iVar3 = FUN_005b7640();

  puVar4 = &DAT_007cff38;

  if (iVar3 == 0) {

    puVar4 = &DAT_00795320;

  }

  FUN_00480980(&stack0xffffffbc,0,L"Allegiance information for %hs%s:\n",iVar1 + 0x14,puVar4);

  FUN_005649f0(&stack0xffffffbc,0,1,0);

  iVar1 = FUN_005b7ba0(param_1,auStack_40);

  if (iVar1 != 0) {

    FUN_005b7a40(&puStack_50);

    iVar1 = FUN_005b7640();

    puVar4 = &DAT_007cff38;

    if (iVar1 == 0) {

      puVar4 = &DAT_00795320;

    }

    FUN_004027b0(&stack0xffffffb4,L"   Patron: %hs%s\n",puStack_50 + 0x14,puVar4);

    FUN_005649f0(&stack0xffffffb4,0,1,0);

  }

  iVar1 = FUN_005b7bb0(param_1,&stack0xffffffb8);

  if (iVar1 != 0) {

    FUN_004882f0("   Vassals: \n",0,1,0);

    do {

      FUN_005b7a40(&stack0xffffffa8);

      iVar3 = FUN_005b7640();

      puVar4 = &DAT_007cff38;

      if (iVar3 == 0) {

        puVar4 = &DAT_00795320;

      }

      FUN_004027b0(&iStack_54,L"      %hs%s\n",unaff_ESI + 5,puVar4);

      FUN_005649f0(&iStack_54,0,1,0);

      iVar1 = FUN_005b7bc0(iVar1,&puStack_50);

    } while (iVar1 != 0);

  }

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

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

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

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

  }

  LVar2 = InterlockedDecrement(unaff_ESI + 1);

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

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

  }

  FUN_005b76c0();

  return 0;

}





// --- FUN_0056b1a0 at 0x0056B1A0 (size: 109) ---


void __fastcall FUN_0056b1a0(int param_1)



{

  int *piVar1;

  

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

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

  *(undefined1 *)(param_1 + 0x18) = 0;

  *(undefined4 *)(param_1 + 0x28) = 0;

  *(undefined4 *)(param_1 + 0x2c) = 0;

  *(undefined1 *)(param_1 + 0x30) = 0;

  *(undefined4 *)(param_1 + 0x34) = 0;

  *(undefined4 *)(param_1 + 0x38) = 0;

  *(undefined1 *)(param_1 + 0x3d) = 0;

  *(undefined1 *)(param_1 + 0x47) = 0;

  *(undefined4 *)(param_1 + 0x48) = 0;

  *(undefined1 *)(param_1 + 0x3e) = 0;

  *(undefined1 *)(param_1 + 0x3c) = 0;

  *(undefined4 *)(param_1 + 0x40) = 0;

  *(undefined4 *)(param_1 + 0x24) = 2;

  *(undefined1 *)(param_1 + 0x45) = 0;

  *(undefined1 *)(param_1 + 0x46) = 0;

  *(undefined1 *)(param_1 + 0x44) = 0;

  *(undefined4 *)(param_1 + 0x4c) = 0x3f000000;

  *(undefined1 *)(param_1 + 0x19) = 0;

  *(undefined1 *)(param_1 + 0x50) = 0;

  piVar1 = (int *)FUN_0043c680();

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 4))(0x4dd1ef,param_1 + 4);

  }

  return;

}





// --- FUN_0056b210 at 0x0056B210 (size: 6) ---


undefined4 FUN_0056b210(void)



{

  return DAT_0087166c;

}





// --- FUN_0056b220 at 0x0056B220 (size: 35) ---


void __fastcall FUN_0056b220(int *param_1)



{

  DAT_0087166c = param_1;

  (**(code **)(*param_1 + 0x10))();

  (**(code **)(*DAT_008f958c + 8))(1,0x28,param_1 + 3);

  return;

}





// --- FUN_0056b250 at 0x0056B250 (size: 73) ---


void __fastcall FUN_0056b250(int param_1)



{

  if (DAT_0087166c != (int *)0x0) {

    (**(code **)(*DAT_0087166c + 0x14))();

    DAT_0087166c = (int *)0x0;

  }

  if (param_1 != 0) {

    (**(code **)(*DAT_008f958c + 0x10))(1,0x28,param_1 + 0xc);

    return;

  }

  (**(code **)(*DAT_008f958c + 0x10))(1,0x28,0);

  return;

}





// --- FUN_0056b2a0 at 0x0056B2A0 (size: 23) ---


undefined4 FUN_0056b2a0(undefined4 param_1,undefined4 param_2)



{

  FUN_006aaf00(param_1,param_2);

  return 0;

}





// --- FUN_0056b2c0 at 0x0056B2C0 (size: 121) ---


undefined4 FUN_0056b2c0(int param_1)



{

  int iVar1;

  

  if (param_1 == 4) {

    iVar1 = FUN_0055e1d0();

    if ((*(uint *)(iVar1 + 0x230) >> 0x16 & 1) == 0) {

      return 0;

    }

  }

  else if (param_1 == 8) {

    iVar1 = FUN_0055e1d0();

    if ((*(byte *)(iVar1 + 0x233) & 1) == 0) {

      return 0;

    }

  }

  else if ((((param_1 == 2) && (iVar1 = FUN_0055e1d0(), (*(uint *)(iVar1 + 0x230) >> 0x14 & 1) == 0)

            ) && (iVar1 = FUN_0055e1d0(), (*(uint *)(iVar1 + 0x230) >> 0x19 & 1) == 0)) &&

          (iVar1 = FUN_0055e1d0(), (*(uint *)(iVar1 + 0x230) & 0x3500000) != 0)) {

    return 0;

  }

  return 1;

}





// --- FUN_0056b340 at 0x0056B340 (size: 217) ---


byte FUN_0056b340(int param_1)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  int *piVar4;

  

  if (param_1 != 0) {

    if (DAT_0083da58 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_1 != iVar3) {

      piVar1 = (int *)FUN_005583f0(param_1);

      if ((piVar1 != (int *)0x0) && (uVar2 = (**(code **)(*piVar1 + 0x18))(), (uVar2 & 0x10) != 0))

      {

        if ((piVar1[0x40] & 0x200000U) != 0) {

          return 1;

        }

        iVar3 = FUN_0055e1d0();

        piVar4 = (int *)FUN_005583f0(*(undefined4 *)(iVar3 + 0x1e8));

        if (piVar4 != (int *)0x0) {

          if ((piVar4[0x40] & 0x200000U) != 0) {

            return 1;

          }

          iVar3 = (**(code **)(*piVar1 + 0x10))();

          if (iVar3 == 0) {

            if (piVar1[0x50] == 0) {

              return *(byte *)(piVar1 + 0x40) >> 4 & 1;

            }

          }

          else {

            iVar3 = (**(code **)(*piVar1 + 0x20))();

            if ((iVar3 != 0) && (iVar3 = (**(code **)(*piVar4 + 0x20))(), iVar3 != 0)) {

              return 1;

            }

            iVar3 = (**(code **)(*piVar1 + 0x24))();

            if ((iVar3 != 0) && (iVar3 = (**(code **)(*piVar4 + 0x24))(), iVar3 != 0)) {

              return 1;

            }

          }

        }

      }

      return 0;

    }

  }

  return 1;

}





// --- FUN_0056b5a0 at 0x0056B5A0 (size: 41) ---


undefined4 __fastcall FUN_0056b5a0(int param_1)



{

  char cVar1;

  undefined4 uVar2;

  

  FUN_0055e1d0();

  cVar1 = FUN_005d3a90();

  if ((cVar1 == '\0') ||

     ((uVar2 = 1, *(char *)(param_1 + 0x3c) == '\0' && (*(int *)(param_1 + 0x34) != 1)))) {

    uVar2 = 0;

  }

  return uVar2;

}





// --- FUN_0056b5d0 at 0x0056B5D0 (size: 31) ---


void __thiscall FUN_0056b5d0(int param_1,undefined4 param_2)



{

  FUN_006a36d0(*(undefined4 *)(param_1 + 0x34),param_2);

  *(undefined4 *)(param_1 + 0x38) = param_2;

  return;

}





// --- FUN_0056b5f0 at 0x0056B5F0 (size: 54) ---


void __fastcall FUN_0056b5f0(int param_1)



{

  *(undefined1 *)(param_1 + 0x30) = 0;

  *(undefined4 *)(param_1 + 0x28) = 0;

  *(undefined4 *)(param_1 + 0x2c) = 0;

  if (*(int *)(param_1 + 0x34) == 1) {

    FUN_006a36d0(1,0);

    *(undefined4 *)(param_1 + 0x34) = 0;

    return;

  }

  FUN_006a3540(*(int *)(param_1 + 0x34));

  *(undefined4 *)(param_1 + 0x34) = 0;

  return;

}





// --- FUN_0056b630 at 0x0056B630 (size: 83) ---


int FUN_0056b630(void)



{

  int iVar1;

  int iVar2;

  

  iVar2 = DAT_00871e54;

  if (((DAT_00871e54 == 0) || (iVar1 = FUN_005583f0(DAT_00871e54), iVar1 == 0)) ||

     (iVar1 = FUN_0058df90(), iVar1 != 0)) {

    return 0;

  }

  iVar1 = FUN_00558410(iVar2);

  if ((iVar1 != 0) && (*(int *)(iVar1 + 0x40) != 0)) {

    iVar2 = *(int *)(*(int *)(iVar1 + 0x40) + 8);

  }

  if ((iVar2 != 0) && (iVar1 = FUN_005583f0(iVar2), iVar1 == 0)) {

    return 0;

  }

  return iVar2;

}





// --- FUN_0056b690 at 0x0056B690 (size: 93) ---


void __fastcall FUN_0056b690(int param_1)



{

  char cVar1;

  int iVar2;

  

  FUN_00564d30();

  iVar2 = FUN_00564f90();

  if (iVar2 != 0) {

    if ((*(char *)(param_1 + 0x19) != '\0') &&

       ((*(int *)(param_1 + 0x1c) == 2 || (*(int *)(param_1 + 0x1c) == 4)))) {

      iVar2 = FUN_0056b630();

      if (iVar2 != 0) {

        cVar1 = FUN_0056b340(iVar2);

        if (cVar1 != '\0') {

          FUN_004583a0(iVar2);

          return;

        }

      }

    }

    FUN_004583a0(0);

  }

  return;

}





// --- FUN_0056b6f0 at 0x0056B6F0 (size: 98) ---


void __fastcall FUN_0056b6f0(int param_1)



{

  int iVar1;

  

  if (*(char *)(param_1 + 0x18) != '\0') {

    *(undefined1 *)(param_1 + 0x30) = 0;

    *(undefined4 *)(param_1 + 0x28) = 0;

    *(undefined4 *)(param_1 + 0x2c) = 0;

    if (*(int *)(param_1 + 0x34) == 1) {

      FUN_006a36d0(1,0);

    }

    else {

      FUN_006a3540(*(int *)(param_1 + 0x34));

    }

    *(undefined4 *)(param_1 + 0x34) = 0;

  }

  if (*(int *)(DAT_0083da58 + 0xf8) != 0) {

    iVar1 = FUN_00512b90();

    if (iVar1 != 0) {

      iVar1 = FUN_00512b90();

      *(undefined4 *)(iVar1 + 0x70) = 0;

    }

  }

  *(undefined1 *)(param_1 + 0x18) = 0;

  return;

}





// --- FUN_0056b760 at 0x0056B760 (size: 307) ---


void __thiscall FUN_0056b760(int param_1,undefined4 param_2,int param_3)



{

  int *piVar1;

  int iVar2;

  int unaff_EDI;

  undefined4 uVar3;

  

  piVar1 = DAT_00837ff4;

  if (DAT_00837ff4 == (int *)0x0) {

    return;

  }

  if (param_3 == 2) {

    if (param_1 == 0) {

      iVar2 = 0;

    }

    else {

      iVar2 = param_1 + 8;

    }

    uVar3 = 0x10000003;

  }

  else if (param_3 == 4) {

    if (param_1 == 0) {

      iVar2 = 0;

      uVar3 = 0x10000004;

    }

    else {

      iVar2 = param_1 + 8;

      uVar3 = 0x10000004;

    }

  }

  else {

    if (param_3 != 8) goto LAB_0056b7cf;

    if (param_1 == 0) {

      iVar2 = 0;

      uVar3 = 0x10000005;

    }

    else {

      iVar2 = param_1 + 8;

      uVar3 = 0x10000005;

    }

  }

  (**(code **)(*DAT_00837ff4 + 0x38))(uVar3,iVar2);

LAB_0056b7cf:

  if (param_1 == 0) {

    iVar2 = 0;

  }

  else {

    iVar2 = param_1 + 8;

  }

  (**(code **)(*piVar1 + 0x34))(0x10000002,iVar2,1000);

  if (unaff_EDI == 2) {

    if (param_1 == 0) {

      param_1 = 0;

    }

    else {

      param_1 = param_1 + 8;

    }

    (**(code **)(*piVar1 + 0x34))(0x10000003,param_1,1000);

  }

  else {

    if (unaff_EDI == 4) {

      if (param_1 == 0) {

        (**(code **)(*piVar1 + 0x34))(0x10000004,0,1000);

        return;

      }

      (**(code **)(*piVar1 + 0x34))(0x10000004,param_1 + 8,1000);

      return;

    }

    if (unaff_EDI == 8) {

      if (param_1 == 0) {

        (**(code **)(*piVar1 + 0x34))(0x10000005,0,1000);

        return;

      }

      (**(code **)(*piVar1 + 0x34))(0x10000005,param_1 + 8,1000);

      return;

    }

  }

  return;

}





// --- FUN_0056b8a0 at 0x0056B8A0 (size: 32) ---


void FUN_0056b8a0(undefined4 param_1)



{

  undefined4 uVar1;

  

  uVar1 = FUN_004220b0(param_1,0x1000000d);

  FUN_00415430(uVar1);

  return;

}





// --- FUN_0056b8c0 at 0x0056B8C0 (size: 134) ---


void __fastcall FUN_0056b8c0(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  undefined4 *puVar3;

  

  puVar1 = param_1 + -2;

  *puVar1 = &PTR_LAB_007d04a8;

  param_1[-1] = &PTR_FUN_007d0200;

  *param_1 = &PTR_FUN_007d01f4;

  param_1[1] = &PTR_LAB_007d01ec;

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    if (puVar1 == (undefined4 *)0x0) {

      puVar3 = (undefined4 *)0x0;

    }

    else {

      puVar3 = param_1 + -1;

    }

    (**(code **)(*piVar2 + 0xc))(puVar3);

  }

  puVar3 = (undefined4 *)(-(uint)(param_1 != (undefined4 *)0x8) & (uint)param_1);

  param_1[2] = &PTR_LAB_00793b6c;

  *puVar3 = &PTR_FUN_00795824;

  if (DAT_00837ff4 != (int *)0x0) {

    (**(code **)(*DAT_00837ff4 + 0x3c))(puVar3);

  }

  if (puVar1 != (undefined4 *)0x0) {

    param_1[-1] = &PTR_FUN_007ccb60;

    FUN_0043c610();

    return;

  }

  ppuRam00000000 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_0056b960 at 0x0056B960 (size: 37) ---


int __fastcall FUN_0056b960(int param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != 0)) {

    (*(code *)**(undefined4 **)(param_1 + 8))(1);

  }

  return iVar1;

}





// --- FUN_0056ba60 at 0x0056BA60 (size: 140) ---


void __fastcall FUN_0056ba60(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  *(undefined1 *)(param_1 + 0x3c) = 1;

  *(undefined1 *)(param_1 + 0x3d) = 1;

  if (*(char *)(param_1 + 0x3e) == '\0') {

    if (*(int *)(param_1 + 0x34) == 0) {

      iVar2 = (*(char *)(param_1 + 0x50) != '\0') + 1;

      *(int *)(param_1 + 0x34) = iVar2;

      if (iVar2 == 1) {

        FUN_006a36d0(1,0);

      }

      else {

        FUN_006a3440(iVar2);

      }

    }

    uVar1 = *(undefined4 *)(param_1 + 0x40);

    FUN_006a36d0(*(undefined4 *)(param_1 + 0x34),uVar1);

    *(undefined4 *)(param_1 + 0x38) = uVar1;

    *(undefined1 *)(param_1 + 0x30) = 0;

    *(undefined4 *)(param_1 + 0x28) = 0;

    *(undefined4 *)(param_1 + 0x2c) = 0;

  }

  DAT_00871ee0 = 1;

  FUN_00564d30();

  FUN_00565610();

  return;

}





// --- FUN_0056baf0 at 0x0056BAF0 (size: 47) ---


void __fastcall FUN_0056baf0(int param_1)



{

  undefined4 uVar1;

  

  *(undefined1 *)(param_1 + 0x30) = 1;

  uVar1 = DAT_008379ac;

  *(undefined4 *)(param_1 + 0x28) = DAT_008379a8;

  *(undefined4 *)(param_1 + 0x2c) = uVar1;

  FUN_006a36d0(*(undefined4 *)(param_1 + 0x34),0);

  *(undefined4 *)(param_1 + 0x38) = 0;

  return;

}





// --- FUN_0056bb20 at 0x0056BB20 (size: 162) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_0056bb20(int param_1)



{

  double dVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  int iVar5;

  float10 fVar6;

  

  uVar3 = DAT_007cffdc;

  uVar2 = DAT_007cffd8;

  if (*(char *)(param_1 + 0x30) == '\0') {

    return (float10)DAT_00796344;

  }

  if (DAT_0083da58 == 0) {

    uVar4 = 0;

  }

  else {

    uVar4 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  FUN_00558410(uVar4);

  iVar5 = FUN_005108d0();

  dVar1 = _DAT_007cffe0;

  if (*(int *)(iVar5 + 4) != -0x7fffffba) {

    dVar1 = (double)CONCAT44(uVar3,uVar2);

  }

  fVar6 = ((float10)_DAT_008379a8 - (float10)*(double *)(param_1 + 0x28)) / (float10)dVar1;

  if (fVar6 <= (float10)_DAT_007938b0) {

    if (fVar6 < (float10)DAT_00796344) {

      fVar6 = (float10)DAT_00796344;

    }

    return fVar6;

  }

  return (float10)_DAT_007938b0;

}





// --- FUN_0056bbd0 at 0x0056BBD0 (size: 63) ---


void __fastcall FUN_0056bbd0(int param_1)



{

  if ((((*(char *)(param_1 + 0x3d) != '\0') || (*(char *)(param_1 + 0x3e) != '\0')) ||

      (*(char *)(param_1 + 0x3c) != '\0')) || (*(char *)(param_1 + 0x44) != '\0')) {

    FUN_006aa940();

    *(undefined1 *)(param_1 + 0x44) = 0;

    if ((*(char *)(param_1 + 0x30) != '\0') && (*(int *)(param_1 + 0x34) == 1)) {

      FUN_0056b5f0();

      return;

    }

  }

  return;

}





// --- FUN_0056bc10 at 0x0056BC10 (size: 20) ---


void __thiscall FUN_0056bc10(int param_1,char param_2)



{

  if (param_2 != *(char *)(param_1 + 0x19)) {

    *(char *)(param_1 + 0x19) = param_2;

    FUN_0056b690();

  }

  return;

}





// --- FUN_0056bc70 at 0x0056BC70 (size: 84) ---


void __fastcall FUN_0056bc70(int param_1)



{

  int iVar1;

  int *piVar2;

  

  if (DAT_00837ff4 != (int *)0x0) {

    if (param_1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = param_1 + 8;

    }

    (**(code **)(*DAT_00837ff4 + 0x3c))(iVar1);

  }

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    if (param_1 != 0) {

      (**(code **)(*piVar2 + 0xc))(param_1 + 4);

      FUN_0056b1a0();

      return;

    }

    (**(code **)(*piVar2 + 0xc))(0);

  }

  FUN_0056b1a0();

  return;

}





// --- FUN_0056bcd0 at 0x0056BCD0 (size: 180) ---


void __fastcall FUN_0056bcd0(int param_1)



{

  char cVar1;

  int iVar2;

  

  if (*(char *)(param_1 + 0x18) == '\0') {

    FUN_00512b90();

    iVar2 = FUN_00528dd0();

    if (iVar2 == 0) {

      FUN_0055e1d0();

      cVar1 = FUN_005d3a90();

      if (cVar1 != '\0') {

        FUN_006aa940();

        *(undefined1 *)(param_1 + 0x44) = 0;

      }

      FUN_006a36d0(*(undefined4 *)(param_1 + 0x34),0);

      *(undefined4 *)(param_1 + 0x38) = 0;

      *(undefined1 *)(param_1 + 0x18) = 1;

      *(undefined4 *)(param_1 + 0x34) = 3;

      FUN_006a3440(3);

      FUN_0056baf0();

                    /* WARNING: Could not recover jumptable at 0x0056bd81. Too many branches */

                    /* WARNING: Treating indirect jump as call */

      (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x4c))();

      return;

    }

    if (iVar2 == 0x48) {

      FUN_005649f0(&DAT_00871708,0x1a,1,0);

      return;

    }

    if (iVar2 == 0x49) {

      FUN_005649f0(&DAT_00871710,0x1a,1,0);

      return;

    }

    FUN_005649f0(&DAT_0087170c,0x1a,1,0);

  }

  return;

}





// --- FUN_0056bd90 at 0x0056BD90 (size: 51) ---


float10 __fastcall FUN_0056bd90(float param_1)



{

  float *pfVar1;

  float10 fVar2;

  float local_4;

  

  if (*(char *)((int)param_1 + 0x18) != '\0') {

    local_4 = param_1;

    fVar2 = (float10)FUN_0056bb20();

    local_4 = (float)fVar2;

    pfVar1 = &DAT_007d01c8;

    if ((float10)DAT_007d01c8 <= fVar2) {

      pfVar1 = &local_4;

    }

    return (float10)*pfVar1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_0056bdd0 at 0x0056BDD0 (size: 74) ---


undefined4 * __fastcall FUN_0056bdd0(undefined4 *param_1)



{

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[2] = &PTR_FUN_00795824;

  param_1[3] = &PTR_LAB_007a6af4;

  *param_1 = &PTR_LAB_007d04a8;

  param_1[1] = &PTR_FUN_007d0200;

  param_1[2] = &PTR_FUN_007d01f4;

  param_1[3] = &PTR_LAB_007d01ec;

  param_1[5] = 1;

  param_1[4] = &PTR_LAB_00793b6c;

  FUN_0056b1a0();

  return param_1;

}





// --- FUN_0056be20 at 0x0056BE20 (size: 34) ---


int __thiscall FUN_0056be20(int param_1,byte param_2)



{

  FUN_0056b8c0();

  if ((param_2 & 1) != 0) {

    operator_delete((void *)(param_1 + -8));

  }

  return param_1 + -8;

}





// --- FUN_0056c050 at 0x0056C050 (size: 268) ---


undefined4 FUN_0056c050(char param_1)



{

  char extraout_AH;

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  undefined1 auStack_4 [4];

  

  if (DAT_0083da58 == 0) {

    uVar1 = 0;

  }

  else {

    uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  iVar2 = FUN_005583f0(uVar1);

  if (iVar2 == 0) {

    return 1;

  }

  iVar2 = FUN_0058dc30(0x2500000,0);

  if (iVar2 == 0) {

    iVar2 = FUN_0058dc30(0x1000000,0);

    if (iVar2 != 0) {

      piVar3 = (int *)FUN_005583f0(iVar2);

      if (piVar3 == (int *)0x0) {

        return 1;

      }

      (**(code **)(*piVar3 + 0x18))();

      if (-1 < extraout_AH) {

        if (param_1 != '\0') {

          return 1;

        }

        puVar4 = (undefined4 *)FUN_0058f8b0(auStack_4,2,0);

        FUN_00480980(&param_1,0,L"You can\'t enter combat mode while wielding the %s",*puVar4);

        FUN_004011b0();

        FUN_005649f0(&param_1,0x1a,1,0);

        FUN_004011b0();

        return 1;

      }

      return 8;

    }

  }

  else {

    iVar2 = FUN_005583f0(iVar2);

    if (iVar2 == 0) {

      return 1;

    }

    if (*(int *)(iVar2 + 0xec) == 2) {

      return 4;

    }

  }

  return 2;

}





// --- FUN_0056c160 at 0x0056C160 (size: 1038) ---


void FUN_0056c160(int *param_1,undefined4 *param_2,int param_3,undefined4 param_4,int param_5,

                 int param_6,uint param_7)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  LONG LVar4;

  int *piVar5;

  undefined4 uVar6;

  int unaff_EBP;

  undefined4 *unaff_ESI;

  undefined4 *puVar7;

  undefined4 *unaff_EDI;

  code *pcVar8;

  bool bVar9;

  undefined4 uVar10;

  undefined4 uVar11;

  undefined4 uVar12;

  undefined *puStack_58;

  char *pcStack_54;

  undefined4 *local_50;

  undefined4 *puStack_4c;

  int local_48;

  undefined1 auStack_40 [64];

  

  local_48 = 0;

  FUN_0048c3e0(&DAT_007938af);

  iVar3 = FUN_0058a000(0,&local_50,6);

  LVar4 = InterlockedDecrement(local_50 + 1);

  if ((LVar4 == 0) && (local_50 != (undefined4 *)0x0)) {

    (**(code **)*local_50)(1);

  }

  if (iVar3 == 0) {

    local_50 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    puStack_4c = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    iVar3 = (int)param_2;

    FUN_005ca020(param_2,param_3,param_4,&local_50,&puStack_4c);

    FUN_005b52b0(iVar3,auStack_40,0x40);

    FUN_00401340(auStack_40);

    FUN_004080c0();

    _strlwr(pcStack_54);

    bVar9 = *(int *)(pcStack_54 + -4) != 1;

    if (bVar9) {

      FUN_00401340(&DAT_00795098);

      piVar5 = (int *)FUN_0040bbc0(&param_3,&param_2);

    }

    else {

      piVar5 = (int *)FUN_00401340(&DAT_007938af);

    }

    if (pcStack_54 != (char *)*piVar5) {

      LVar4 = InterlockedDecrement((LONG *)(pcStack_54 + -0x10));

      if ((LVar4 == 0) && (pcStack_54 + -0x14 != (char *)0x0)) {

        (*(code *)**(undefined4 **)(pcStack_54 + -0x14))(1);

      }

      pcStack_54 = (char *)*piVar5;

      InterlockedIncrement((LONG *)(pcStack_54 + -0x10));

    }

    if (bVar9) {

      puVar7 = (undefined4 *)(param_3 + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(param_3 + -0x10));

      if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

    }

    if (bVar9) {

      puVar7 = (undefined4 *)((int)param_2 + -0x14);

      LVar4 = InterlockedDecrement((LONG *)((int)param_2 + -0x10));

      if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

    }

    if (!bVar9) {

      puVar7 = (undefined4 *)(local_48 + -0x14);

      LVar4 = InterlockedDecrement((LONG *)(local_48 + -0x10));

      if ((LVar4 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

    }

    puVar7 = DAT_008ef11c;

    param_2 = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    iVar3 = param_5;

    if (param_5 != 1) {

      FUN_004034c0(&DAT_00795520);

      puVar7 = param_2;

    }

    puStack_58 = PTR_DAT_00818344;

    InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

    if (param_6 != 0) {

      FUN_00405000("Critical hit!  ");

    }

    uVar2 = param_7;

    if ((param_7 & 8) != 0) {

      FUN_00406500(&puStack_58,"Overpower! ");

    }

    if ((uVar2 & 4) != 0) {

      FUN_00406500(&puStack_58,"Sneak Attack! ");

    }

    if ((uVar2 & 2) != 0) {

      FUN_00406500(&puStack_58,"Recklessness! ");

    }

    FUN_00406500(&puStack_58,"You %s %s for %d point%s of %sdamage!",local_50 + 5,*param_1 + 0x14,

                 iVar3,puVar7 + 5,pcStack_54);

    pcVar8 = InterlockedDecrement_exref;

    if ((uVar2 & 1) != 0) {

      FUN_00401340(

                  " Your target\'s Critical Protection augmentation allows them to avoid your critical hit!"

                  );

      if (param_2[-1] != 1) {

        FUN_00404ef0(param_2,param_2[-1] + -1);

      }

      pcVar8 = InterlockedDecrement_exref;

      puVar1 = param_2 + -5;

      LVar4 = InterlockedDecrement(param_2 + -4);

      if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

        (**(code **)*puVar1)(1);

      }

    }

    FUN_00401340(&DAT_00795508);

    if (param_2[-1] != 1) {

      FUN_00404ef0(param_2,param_2[-1] + -1);

    }

    puVar1 = param_2 + -5;

    iVar3 = (*pcVar8)(param_2 + -4);

    if ((iVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    uVar12 = 0;

    uVar11 = 1;

    uVar10 = 0x16;

    uVar6 = FUN_00403350(&param_1,0);

    FUN_005649f0(uVar6,uVar10,uVar11,uVar12);

    piVar5 = param_1 + -5;

    iVar3 = (*pcVar8)(param_1 + -4);

    if ((iVar3 == 0) && (piVar5 != (int *)0x0)) {

      (**(code **)*piVar5)(1);

    }

    iVar3 = (*pcVar8)(unaff_ESI + -4);

    if ((iVar3 == 0) && (unaff_ESI + -5 != (undefined4 *)0x0)) {

      (**(code **)unaff_ESI[-5])(1);

    }

    iVar3 = (*pcVar8)(puVar7 + 1);

    if ((iVar3 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    iVar3 = (*pcVar8)(unaff_EBP + -0x10);

    if ((iVar3 == 0) && ((undefined4 *)(unaff_EBP + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(unaff_EBP + -0x14))(1);

    }

    iVar3 = (*pcVar8)(unaff_ESI + 1);

    if ((iVar3 == 0) && (unaff_ESI != (undefined4 *)0x0)) {

      (**(code **)*unaff_ESI)(1);

    }

    iVar3 = (*pcVar8)(unaff_EDI + 1);

    if ((iVar3 == 0) && (unaff_EDI != (undefined4 *)0x0)) {

      (**(code **)*unaff_EDI)(1);

    }

  }

  return;

}





// --- FUN_0056c570 at 0x0056C570 (size: 437) ---


bool __thiscall FUN_0056c570(int param_1,char param_2)



{

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  int local_18;

  uint uStack_14;

  int *local_10 [2];

  int *local_8;

  

  if (DAT_0083da58 == 0) {

    uVar1 = 0;

  }

  else {

    uVar1 = *(undefined4 *)(DAT_0083da58 + 0xf4);

  }

  iVar2 = FUN_00558410(uVar1);

  if (iVar2 != 0) {

    switch(*(int *)(param_1 + 0x1c) + -1) {

    case 0:

    case 7:

switchD_0056c5ab_caseD_0:

      iVar2 = FUN_0050f580();

      return iVar2 == 0;

    case 1:

      local_18 = 0;

      uVar1 = FUN_00485200(local_10,&DAT_007d0094);

      FUN_0048bc80(uVar1);

      if (local_10[0] != (int *)0x0) {

        (**(code **)(*local_10[0] + 0x14))();

      }

      FUN_00590c20(0x2f,&local_18,0,0);

      if (local_18 == 0) {

        local_18 = 0x19;

      }

      FUN_005108d0();

      uStack_14 = DAT_00871688;

      FUN_00590d20(4,&uStack_14);

      if (uStack_14 == DAT_00871688) {

        if (local_8 != (int *)0x0) {

          (**(code **)(*local_8 + 0x14))();

        }

      }

      else {

        piVar3 = (int *)FUN_0056b8a0(uStack_14);

        if (piVar3 != (int *)0x0) {

          if (param_2 != '\0') {

            if (local_8 != (int *)0x0) {

              (**(code **)(*local_8 + 0x14))();

            }

            return true;

          }

          (**(code **)(*piVar3 + 0x14))();

          iVar2 = FUN_0050f580();

          if (local_8 != (int *)0x0) {

            (**(code **)(*local_8 + 0x14))();

          }

          return (bool)('\x01' - (iVar2 != 0));

        }

        if (local_8 != (int *)0x0) {

          (**(code **)(*local_8 + 0x14))();

          return false;

        }

      }

      break;

    case 3:

      iVar2 = FUN_005108d0();

      uVar1 = *(undefined4 *)(iVar2 + 4);

      iVar2 = FUN_005108d0();

      switch(uVar1) {

      case 0x8000003f:

      case 0x80000041:

      case 0x80000043:

      case 0x80000047:

      case 0x8000013b:

      case 0x8000013c:

        if (*(int *)(iVar2 + 8) == 0x41000003) {

          if (param_2 != '\0') {

            return true;

          }

          goto switchD_0056c5ab_caseD_0;

        }

      }

    }

  }

  return false;

}





// --- FUN_0056c850 at 0x0056C850 (size: 106) ---


void __fastcall FUN_0056c850(int param_1)



{

  undefined4 uVar1;

  char cVar2;

  int iVar3;

  

  cVar2 = FUN_0056c570(1);

  if ((cVar2 != '\0') && (*(char *)(param_1 + 0x30) == '\0')) {

    iVar3 = (*(char *)(param_1 + 0x50) != '\0') + 1;

    *(int *)(param_1 + 0x34) = iVar3;

    if (iVar3 == 1) {

      FUN_006a36d0(1,0);

    }

    else {

      FUN_006a3440(iVar3);

    }

    *(undefined1 *)(param_1 + 0x30) = 1;

    uVar1 = DAT_008379ac;

    *(undefined4 *)(param_1 + 0x28) = DAT_008379a8;

    *(undefined4 *)(param_1 + 0x2c) = uVar1;

    FUN_006a36d0(*(undefined4 *)(param_1 + 0x34),0);

    *(undefined4 *)(param_1 + 0x38) = 0;

  }

  return;

}





// --- FUN_0056c8c0 at 0x0056C8C0 (size: 265) ---


void __thiscall FUN_0056c8c0(int param_1,int param_2,char param_3)



{

  char cVar1;

  int iVar2;

  undefined4 uVar3;

  LONG LVar4;

  undefined4 *puVar5;

  

  *(undefined1 *)(param_1 + 0x30) = 0;

  *(undefined4 *)(param_1 + 0x28) = 0;

  *(undefined4 *)(param_1 + 0x2c) = 0;

  iVar2 = FUN_0056b630();

  uVar3 = FUN_0056b630();

  cVar1 = FUN_0056b340(uVar3);

  if (cVar1 == '\0') {

    iVar2 = 0;

  }

  cVar1 = FUN_0056c570(1);

  if (cVar1 == '\0') {

    if (iVar2 != 0) goto LAB_0056c98c;

  }

  else if (iVar2 != 0) {

    if (*(int *)(param_1 + 0x1c) == 2) {

      FUN_006aab70(iVar2,param_2,*(undefined4 *)(param_1 + 0x40));

    }

    else if (*(int *)(param_1 + 0x1c) == 4) {

      FUN_006aacc0(iVar2,param_2,*(undefined4 *)(param_1 + 0x40));

    }

    FUN_0055e1d0();

    cVar1 = FUN_005d3a90();

    if (cVar1 != '\0') {

      *(undefined1 *)(param_1 + 0x44) = 1;

    }

    *(undefined1 *)(param_1 + 0x3d) = 1;

    goto LAB_0056c98c;

  }

  FUN_00402730(L"You must select a valid combat target before attacking");

  FUN_005649f0(&param_2,0x1a,1,0);

  puVar5 = (undefined4 *)(param_2 + -0x14);

  LVar4 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar4 == 0) && (puVar5 != (undefined4 *)0x0)) {

    (**(code **)*puVar5)(1);

  }

LAB_0056c98c:

  if (*(char *)(param_1 + 0x3d) == '\0') {

    *(undefined1 *)(param_1 + 0x30) = 0;

    *(undefined4 *)(param_1 + 0x28) = 0;

    *(undefined4 *)(param_1 + 0x2c) = 0;

    if (*(int *)(param_1 + 0x34) == 1) {

      FUN_006a36d0(1,0);

    }

    else {

      FUN_006a3540(*(int *)(param_1 + 0x34));

    }

    *(undefined4 *)(param_1 + 0x34) = 0;

  }

  if (param_3 == '\0') {

    *(undefined1 *)(param_1 + 0x3d) = 0;

  }

  return;

}





// --- FUN_0056c9d0 at 0x0056C9D0 (size: 247) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0056c9d0(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined1 *puVar3;

  undefined4 uVar4;

  undefined *puVar5;

  int *piVar6;

  undefined4 uVar7;

  int **ppiVar8;

  undefined4 uVar9;

  undefined4 uVar10;

  int local_18;

  int *local_14;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  ppiVar8 = &local_14;

  puVar3 = local_10;

  puVar5 = &DAT_007d0094;

  local_18 = 0;

  local_14 = (int *)0x0;

  FUN_00406d10(puVar3,&DAT_007d0094,ppiVar8);

  FUN_00406570(puVar3,puVar5,ppiVar8);

  piVar1 = local_14;

  uVar9 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar6 = local_14;

  if (local_14 != (int *)0x0) {

    (**(code **)(*local_14 + 0x10))(local_14,0);

  }

  FUN_0048bb00(local_c,piVar6,uVar9);

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 0x14))();

  }

  piVar1 = local_8;

  if (local_8 != (int *)0x0) {

    FUN_00590d50(0xb,&local_18);

  }

  if ((((local_18 != 0) && (_DAT_008379a8 - *(double *)(param_1 + 0x58) < _DAT_007d01c0)) &&

      (iVar2 = FUN_005583f0(local_18), iVar2 != 0)) && (*(int *)(iVar2 + 100) == 0)) {

    FUN_0058d110(local_18,0);

    if (piVar1 == (int *)0x0) {

      return;

    }

    (**(code **)(*piVar1 + 0x14))();

    return;

  }

  uVar10 = 0;

  uVar7 = 2;

  uVar4 = 1;

  uVar9 = 1;

  FUN_0055e1d0(1,1,2,0);

  FUN_00560710(uVar9,uVar4,uVar7,uVar10);

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 0x14))();

  }

  return;

}





// --- FUN_0056cad0 at 0x0056CAD0 (size: 163) ---


void __fastcall FUN_0056cad0(int param_1)



{

  char cVar1;

  

  FUN_0056b690();

  FUN_0055e1d0();

  cVar1 = FUN_005d3a90();

  if (((cVar1 != '\0') && ((*(char *)(param_1 + 0x38) != '\0' || (*(int *)(param_1 + 0x30) == 1))))

     && ((*(char *)(param_1 + 0x39) != '\0' ||

         (((*(char *)(param_1 + 0x3a) != '\0' || (*(char *)(param_1 + 0x38) != '\0')) ||

          (*(char *)(param_1 + 0x40) != '\0')))))) {

    FUN_006aa940();

    *(undefined1 *)(param_1 + 0x40) = 0;

    if ((*(char *)(param_1 + 0x2c) != '\0') && (*(int *)(param_1 + 0x30) == 1)) {

      FUN_0056b5f0();

    }

  }

  if (DAT_00871e54 == 0) {

    if (*(char *)(param_1 + 0x42) == '\0') {

      if ((*(int *)(param_1 + 0x18) == 2) || (*(int *)(param_1 + 0x18) == 4)) {

        FUN_0055e1d0();

        cVar1 = FUN_005d3e90();

        if (cVar1 != '\0') {

          FUN_0056c9d0();

          return;

        }

      }

    }

    else {

      *(undefined1 *)(param_1 + 0x42) = 0;

    }

  }

  return;

}





// --- FUN_0056cb80 at 0x0056CB80 (size: 520) ---


void __thiscall FUN_0056cb80(int param_1,int param_2,char param_3)



{

  char cVar1;

  undefined1 uVar2;

  int iVar3;

  int *piVar4;

  undefined4 *puVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  undefined4 uVar9;

  int local_4;

  

  iVar8 = param_2;

  iVar3 = *(int *)(param_1 + 0x1c);

  if (param_2 == iVar3) {

    return;

  }

  local_4 = param_1;

  if (param_3 != '\0') {

    cVar1 = FUN_0056b2c0(param_2);

    if (cVar1 == '\0') {

      iVar3 = FUN_0055e1d0();

      iVar3 = FUN_005583f0(**(undefined4 **)(iVar3 + 0x260));

      if (iVar3 == 0) {

        return;

      }

      piVar4 = (int *)FUN_005caaf0(&param_2,iVar8);

      iVar3 = *piVar4;

      puVar5 = (undefined4 *)FUN_0058f8b0(&local_4,2,0);

      FUN_00480980(&param_3,0,L"You can\'t enter %hs mode while wielding the %s",iVar3 + 0x14,

                   *puVar5);

      FUN_005abb30();

      FUN_004011b0();

LAB_0056cc4f:

      FUN_005649f0(&param_3,0x1a,1,0);

      FUN_004011b0();

      return;

    }

    iVar6 = FUN_0055e1d0();

    if (*(char *)(iVar6 + 0x238) != '\0') {

      FUN_00402730(L"You can\'t enter combat mode while in portal space");

      goto LAB_0056cc4f;

    }

    cVar1 = FUN_0056c570(0);

    if (cVar1 == '\0') {

      *(int *)(param_1 + 0x20) = iVar8;

      return;

    }

  }

  *(int *)(param_1 + 0x1c) = iVar8;

  FUN_00564d30();

  FUN_005653d0();

  if (*(char *)(param_1 + 0x19) != '\0') {

    FUN_0056b690();

  }

  if (param_3 != '\0') {

    FUN_006aa9d0(*(undefined4 *)(param_1 + 0x1c));

  }

  FUN_0055e1d0();

  uVar2 = FUN_005d3e40();

  *(undefined1 *)(param_1 + 0x50) = uVar2;

  FUN_006aaeb0(*(undefined4 *)(param_1 + 0x1c));

  FUN_0056b760(*(undefined4 *)(param_1 + 0x1c),iVar3);

  iVar8 = DAT_00871e54;

  if ((*(int *)(param_1 + 0x1c) != 2) && (*(int *)(param_1 + 0x1c) != 4)) goto LAB_0056cd62;

  iVar6 = FUN_0056b630();

  if (DAT_0083da58 == 0) {

    iVar7 = 0;

  }

  else {

    iVar7 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (iVar8 != iVar7) {

    cVar1 = FUN_0056b340(iVar6);

    if (cVar1 == '\0') {

      iVar6 = 0;

    }

    else if (iVar8 == iVar6) goto LAB_0056cd2b;

    FUN_0058d110(iVar6,0);

  }

LAB_0056cd2b:

  FUN_0055e1d0();

  cVar1 = FUN_005d3e90();

  if (cVar1 != '\0') {

    iVar8 = FUN_0056b630();

    if (iVar8 != 0) {

      uVar9 = FUN_0056b630();

      cVar1 = FUN_0056b340(uVar9);

      if (cVar1 != '\0') goto LAB_0056cd62;

    }

    FUN_0056c9d0();

  }

LAB_0056cd62:

  iVar8 = FUN_0055b0a0();

  if (iVar8 != 0) {

    piVar4 = (int *)FUN_0055a740();

    (**(code **)(*piVar4 + 0x2c))(piVar4,iVar3,*(undefined4 *)(param_1 + 0x1c),param_3);

  }

  return;

}





// --- FUN_0056cd90 at 0x0056CD90 (size: 160) ---


void __fastcall FUN_0056cd90(int param_1)



{

  char cVar1;

  int iVar2;

  LONG LVar3;

  undefined4 *puVar4;

  int local_4;

  

  local_4 = param_1;

  iVar2 = FUN_0056b630();

  if (*(char *)(param_1 + 0x50) == '\0') {

    if (iVar2 != 0) {

      cVar1 = FUN_0056b340(iVar2);

      if (cVar1 != '\0') goto LAB_0056cdf4;

    }

    FUN_00402730(L"You must select a valid combat target before attacking");

    FUN_005649f0(&local_4,0x1a,1,0);

    puVar4 = (undefined4 *)(local_4 + -0x14);

    LVar3 = InterlockedDecrement((LONG *)(local_4 + -0x10));

    if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

      (**(code **)*puVar4)(1);

      return;

    }

  }

  else {

LAB_0056cdf4:

    *(undefined1 *)(param_1 + 0x3e) = 1;

    *(undefined4 *)(param_1 + 0x40) = 0x3f800000;

    (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0x50))();

    (**(code **)(**(int **)(DAT_0083da58 + 0xb8) + 0xc0))();

    *(undefined1 *)(param_1 + 0x45) = 0;

    FUN_0056c850();

  }

  return;

}





// --- FUN_0056ce30 at 0x0056CE30 (size: 208) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0056ce30(float param_1,undefined4 param_2,float param_3)



{

  float *pfVar1;

  float10 fVar2;

  float local_4;

  

  if (*(char *)((int)param_1 + 0x3e) != '\0') {

    *(undefined1 *)((int)param_1 + 0x3e) = 0;

    local_4 = param_1;

    fVar2 = (float10)FUN_0056bb20();

    local_4 = (float)fVar2;

    if (param_3 == _DAT_007d0080) {

      if (*(char *)((int)param_1 + 0x50) == '\0') {

        param_3 = *(float *)((int)param_1 + 0x4c);

        pfVar1 = &local_4;

        if (local_4 <= param_3) {

          pfVar1 = &param_3;

        }

        *(float *)((int)param_1 + 0x40) = *pfVar1;

      }

      else {

        *(float *)((int)param_1 + 0x40) = local_4;

      }

    }

    else {

      *(float *)((int)param_1 + 0x40) = param_3;

    }

    if (*(char *)((int)param_1 + 0x3d) != '\0') {

      *(undefined1 *)((int)param_1 + 0x47) = 1;

      *(undefined4 *)((int)param_1 + 0x48) = *(undefined4 *)((int)param_1 + 0x40);

      return;

    }

    if ((((*(char *)((int)param_1 + 0x50) != '\0') || (*(float *)((int)param_1 + 0x4c) <= local_4))

        || (*(char *)((int)param_1 + 0x44) != '\0')) &&

       ((FUN_0056c8c0(param_2,1), *(char *)((int)param_1 + 0x50) == '\0' &&

        (*(float *)((int)param_1 + 0x4c) < *(float *)((int)param_1 + 0x40))))) {

      *(undefined4 *)((int)param_1 + 0x40) = *(undefined4 *)((int)param_1 + 0x4c);

      FUN_0056c8c0(param_2,1);

    }

  }

  return;

}





// --- FUN_0056d070 at 0x0056D070 (size: 232) ---


undefined4 FUN_0056d070(int *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  int iVar4;

  

  puVar1 = DAT_008ef11c;

  if (DAT_0083da58 == 0) {

    iVar4 = 0;

  }

  else {

    iVar4 = *(int *)(DAT_0083da58 + 0xf4);

  }

  InterlockedIncrement(DAT_008ef11c + 1);

  iVar2 = FUN_004fd460(&param_1,param_2);

  if (iVar2 != 0) {

    if (((iVar4 != *param_1) && (iVar4 != param_1[1])) && (puVar1[2] != 1)) {

      FUN_0048c3e0(&DAT_00795508);

      FUN_004914f0(&param_1);

      FUN_005abb30();

      FUN_004882f0(puVar1 + 5,0,1,0);

    }

    LVar3 = InterlockedDecrement(puVar1 + 1);

    if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    return 1;

  }

  LVar3 = InterlockedDecrement(puVar1 + 1);

  if ((LVar3 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return 0;

}





// --- FUN_0056d160 at 0x0056D160 (size: 226) ---


undefined4 FUN_0056d160(undefined4 param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  LONG LVar4;

  

  puVar1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  iVar3 = FUN_004fd460(&param_1,param_2);

  if (iVar3 == 0) {

    LVar4 = InterlockedDecrement(puVar1 + 1);

    if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    return 0;

  }

  if (puVar1[2] != 1) {

    FUN_0048c3e0(&DAT_00795508);

    puVar2 = param_2;

    if ((param_2[2] != 1) && (param_2 != DAT_008ef11c)) {

      FUN_004910c0(param_2 + 5,param_2[2] + -1);

    }

    LVar4 = InterlockedDecrement(puVar2 + 1);

    if (LVar4 == 0) {

      (**(code **)*puVar2)(1);

    }

    FUN_004882f0(puVar1 + 5,0,1,0);

  }

  LVar4 = InterlockedDecrement(puVar1 + 1);

  if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  return 1;

}





// --- FUN_0056d250 at 0x0056D250 (size: 275) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0056d250(int param_1,int param_2)



{

  int iVar1;

  char cVar2;

  

  if (*(char *)(param_1 + 0x3c) != '\0') {

    FUN_00564d30();

    FUN_00565630();

    *(undefined1 *)(param_1 + 0x3c) = 0;

  }

  *(undefined1 *)(param_1 + 0x3d) = 0;

  DAT_00871ee0 = 0;

  if ((param_2 != 0) && (*(char *)(param_1 + 0x44) != '\0')) {

    FUN_0056bbd0();

  }

  if ((*(char *)(param_1 + 0x3e) == '\0') && (*(char *)(param_1 + 0x50) == '\0')) {

    FUN_0055e1d0();

    cVar2 = FUN_005d3a90();

    if ((cVar2 != '\0') &&

       ((*(char *)(param_1 + 0x44) != '\0' &&

        (_DAT_007a1870 < ABS(*(float *)(param_1 + 0x40) - *(float *)(param_1 + 0x4c)))))) {

      *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(param_1 + 0x4c);

      FUN_0056c8c0(*(undefined4 *)(param_1 + 0x24),0);

    }

  }

  FUN_0055e1d0();

  cVar2 = FUN_005d3a90();

  if ((cVar2 == '\0') || (*(char *)(param_1 + 0x44) == '\0')) {

    iVar1 = *(int *)(param_1 + 0x34);

    *(undefined1 *)(param_1 + 0x44) = 0;

    if (iVar1 != 3) {

      *(undefined1 *)(param_1 + 0x30) = 0;

      *(undefined4 *)(param_1 + 0x28) = 0;

      *(undefined4 *)(param_1 + 0x2c) = 0;

      if (iVar1 == 1) {

        FUN_006a36d0(1,0);

      }

      else {

        FUN_006a3540(iVar1);

      }

      *(undefined4 *)(param_1 + 0x34) = 0;

    }

LAB_0056d327:

    if (*(char *)(param_1 + 0x3e) == '\0') goto LAB_0056d33d;

  }

  else if (*(char *)(param_1 + 0x3e) == '\0') {

    FUN_0056baf0();

    *(undefined1 *)(param_1 + 0x45) = 1;

    goto LAB_0056d327;

  }

  if ((*(char *)(param_1 + 0x30) == '\0') && (*(char *)(param_1 + 0x3d) == '\0')) {

    FUN_0056c850();

  }

LAB_0056d33d:

  if (*(char *)(param_1 + 0x47) != '\0') {

    FUN_0056cd90();

    FUN_0056ce30(*(undefined4 *)(param_1 + 0x24),*(undefined4 *)(param_1 + 0x48));

    *(undefined1 *)(param_1 + 0x47) = 0;

    *(undefined4 *)(param_1 + 0x48) = 0;

  }

  return;

}





// --- FUN_0056d370 at 0x0056D370 (size: 375) ---


void __thiscall FUN_0056d370(int param_1,int *param_2)



{

  undefined4 uVar1;

  char cVar2;

  LONG LVar3;

  int iVar4;

  int *piVar5;

  undefined4 *local_8;

  

  FUN_0048c3e0("You evaded ");

  piVar5 = (int *)*param_2;

  if ((piVar5[2] != 1) && (piVar5 != DAT_008ef11c)) {

    FUN_004910c0(piVar5 + 5,piVar5[2] + -1);

  }

  FUN_0048c3e0(&DAT_007d0738);

  piVar5 = param_2;

  if ((param_2[2] != 1) && (param_2 != DAT_008ef11c)) {

    FUN_004910c0(param_2 + 5,param_2[2] + -1);

  }

  LVar3 = InterlockedDecrement(piVar5 + 1);

  if (LVar3 == 0) {

    (**(code **)*piVar5)(1);

  }

  FUN_0048c3e0(&DAT_007938af);

  iVar4 = FUN_0058a000(0,&param_2,6);

  piVar5 = param_2;

  LVar3 = InterlockedDecrement(param_2 + 1);

  if ((LVar3 == 0) && (piVar5 != (int *)0x0)) {

    (**(code **)*piVar5)(1);

  }

  if (iVar4 == 0) {

    FUN_00404a40(0,local_8 + 5);

    FUN_005649f0(&param_2,0x15,1,0);

    piVar5 = param_2 + -5;

    LVar3 = InterlockedDecrement(param_2 + -4);

    if ((LVar3 == 0) && (piVar5 != (int *)0x0)) {

      (**(code **)*piVar5)(1);

    }

  }

  uVar1 = DAT_008379ac;

  *(undefined4 *)(param_1 + 0x58) = DAT_008379a8;

  *(undefined4 *)(param_1 + 0x5c) = uVar1;

  if ((*(int *)(param_1 + 0x1c) == 2) || (*(int *)(param_1 + 0x1c) == 4)) {

    FUN_0055e1d0();

    cVar2 = FUN_005d3e90();

    if ((cVar2 != '\0') && (DAT_00871e54 == 0)) {

      FUN_0056c9d0();

    }

  }

  LVar3 = InterlockedDecrement(local_8 + 1);

  if ((LVar3 == 0) && (local_8 != (undefined4 *)0x0)) {

    (**(code **)*local_8)(1);

  }

  return;

}





// --- FUN_0056d4f0 at 0x0056D4F0 (size: 273) ---


void FUN_0056d4f0(int *param_1)



{

  LONG LVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined4 *local_8;

  

  puVar4 = (undefined4 *)*param_1;

  param_1 = puVar4;

  InterlockedIncrement(puVar4 + 1);

  FUN_0048c3e0(" evaded your attack.\n");

  if ((local_8[2] != 1) && (local_8 != DAT_008ef11c)) {

    FUN_004910c0(local_8 + 5,local_8[2] + -1);

    puVar4 = param_1;

  }

  LVar1 = InterlockedDecrement(local_8 + 1);

  if (LVar1 == 0) {

    (**(code **)*local_8)(1);

  }

  FUN_0048c3e0(&DAT_007938af);

  iVar2 = FUN_0058a000(0,&param_1,6);

  puVar3 = param_1;

  LVar1 = InterlockedDecrement(param_1 + 1);

  if ((LVar1 == 0) && (puVar3 != (undefined4 *)0x0)) {

    (**(code **)*puVar3)(1);

  }

  if (iVar2 == 0) {

    FUN_00404a40(0,puVar4 + 5);

    FUN_005649f0(&param_1,0x16,1,0);

    puVar3 = param_1 + -5;

    LVar1 = InterlockedDecrement(param_1 + -4);

    if ((LVar1 == 0) && (puVar3 != (undefined4 *)0x0)) {

      (**(code **)*puVar3)(1);

    }

  }

  LVar1 = InterlockedDecrement(puVar4 + 1);

  if ((LVar1 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  return;

}





// --- FUN_0056d610 at 0x0056D610 (size: 37) ---


void __fastcall FUN_0056d610(int param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  

  uVar2 = 1;

  if (*(int *)(param_1 + 0x1c) == 1) {

    uVar1 = FUN_0056c050(0);

    FUN_0056cb80(uVar1,uVar2);

    return;

  }

  FUN_0056cb80(1,1);

  return;

}





// --- FUN_0056d640 at 0x0056D640 (size: 34) ---


void __thiscall FUN_0056d640(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(param_1 + 0x24);

  *(int *)(param_1 + 0x24) = param_2;

  if ((iVar1 != param_2) || (*(char *)(param_1 + 0x3e) == '\0')) {

    FUN_0056cd90();

  }

  return;

}





// --- FUN_0056d670 at 0x0056D670 (size: 3378) ---


void FUN_0056d670(int *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5,

                 undefined4 param_6,int param_7,uint param_8)



{

  undefined4 *puVar1;

  LONG *pLVar2;

  char cVar3;

  int *piVar4;

  LONG LVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  undefined4 uVar9;

  undefined4 uVar10;

  undefined4 uVar11;

  int iVar12;

  undefined4 *puVar13;

  char *pcVar14;

  bool bVar15;

  undefined4 **ppuVar16;

  undefined4 **ppuVar17;

  undefined4 **ppuVar18;

  undefined4 **ppuVar19;

  undefined4 **ppuVar20;

  undefined4 **ppuVar21;

  undefined4 **ppuVar22;

  undefined4 **ppuVar23;

  undefined4 **ppuVar24;

  undefined4 **ppuVar25;

  undefined4 **ppuVar26;

  undefined4 **ppuVar27;

  LONG **ppLVar28;

  undefined4 **ppuVar29;

  undefined4 **ppuVar30;

  undefined4 **ppuVar31;

  undefined4 **ppuVar32;

  undefined4 *local_1c0;

  undefined4 *local_1bc;

  char *local_1b8;

  undefined4 *local_1b4;

  undefined4 *local_1b0;

  undefined4 *puStack_1ac;

  undefined4 *puStack_1a8;

  undefined4 *local_1a4;

  undefined4 *local_1a0;

  undefined4 *puStack_19c;

  undefined4 *puStack_198;

  undefined4 *puStack_194;

  undefined4 *puStack_190;

  undefined4 *puStack_18c;

  undefined4 *puStack_188;

  undefined4 *puStack_184;

  undefined4 *puStack_180;

  undefined4 *puStack_17c;

  undefined4 *puStack_178;

  undefined4 *puStack_174;

  undefined4 *puStack_170;

  LONG *pLStack_16c;

  undefined4 *puStack_168;

  undefined4 *puStack_164;

  undefined4 *puStack_160;

  undefined4 *puStack_15c;

  undefined4 *puStack_158;

  undefined4 *local_154;

  undefined4 *puStack_150;

  int local_14c;

  undefined4 *puStack_148;

  undefined4 *puStack_144;

  undefined1 local_140 [64];

  undefined1 uStack_100;

  undefined4 uStack_ff;

  

  local_1b0 = (undefined4 *)0x0;

  local_154 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  local_1a4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  local_1a0 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_005ca020(param_2,param_3,param_4,&local_154,&local_1a4);

  FUN_005b52b0(param_2,local_140,0x40);

  FUN_00401340(local_140);

  FUN_004080c0();

  _strlwr(local_1b8);

  bVar15 = *(int *)(local_1b8 + -4) != 1;

  if (bVar15) {

    FUN_00401340(&DAT_00795098);

    piVar4 = (int *)FUN_0040bbc0(&local_1c0,&local_1bc);

  }

  else {

    piVar4 = (int *)FUN_00401340(&DAT_007938af);

  }

  if (local_1b8 != (char *)*piVar4) {

    LVar5 = InterlockedDecrement((LONG *)(local_1b8 + -0x10));

    if ((LVar5 == 0) && (local_1b8 + -0x14 != (char *)0x0)) {

      (*(code *)**(undefined4 **)(local_1b8 + -0x14))(1);

    }

    local_1b8 = (char *)*piVar4;

    InterlockedIncrement((LONG *)(local_1b8 + -0x10));

  }

  if (bVar15) {

    puVar13 = local_1c0 + -5;

    LVar5 = InterlockedDecrement(local_1c0 + -4);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

  }

  if (bVar15) {

    LVar5 = InterlockedDecrement(local_1bc + -4);

    if ((LVar5 == 0) && (local_1bc + -5 != (undefined4 *)0x0)) {

      (**(code **)local_1bc[-5])(1);

    }

  }

  if (!bVar15) {

    LVar5 = InterlockedDecrement(local_1b4 + -4);

    if ((LVar5 == 0) && (local_1b4 + -5 != (undefined4 *)0x0)) {

      (**(code **)local_1b4[-5])(1);

    }

  }

  if (param_5 != 1) {

    FUN_004034c0(&DAT_00795520);

  }

  uStack_100 = 0;

  puVar13 = &uStack_ff;

  for (iVar12 = 0x3f; iVar12 != 0; iVar12 = iVar12 + -1) {

    *puVar13 = 0;

    puVar13 = puVar13 + 1;

  }

  *(undefined2 *)puVar13 = 0;

  *(undefined1 *)((int)puVar13 + 2) = 0;

  puStack_170 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  puVar13 = DAT_008ef11c;

  puStack_1a8 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  FUN_005d1ea0(param_6,&uStack_100,0x100);

  FUN_0048c3e0(&uStack_100);

  local_1b4 = (undefined4 *)FUN_005aa310(&puStack_158,&puStack_170);

  puStack_1ac = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  if (param_7 != 0) {

    FUN_004034c0("Critical hit! ");

  }

  if ((param_8 & 8) != 0) {

    piVar4 = (int *)FUN_0048c3e0("Overpower! ");

    puVar1 = (undefined4 *)*piVar4;

    if ((puVar1[2] != 1) && (puVar1 != DAT_008ef11c)) {

      FUN_004910c0(puVar1 + 5,puVar1[2] + -1);

    }

    puVar1 = local_1c0;

    LVar5 = InterlockedDecrement(local_1c0 + 1);

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

  }

  if ((param_8 & 4) != 0) {

    piVar4 = (int *)FUN_0048c3e0("Sneak Attack! ");

    puVar1 = (undefined4 *)*piVar4;

    if ((puVar1[2] != 1) && (puVar1 != DAT_008ef11c)) {

      FUN_004910c0(puVar1 + 5,puVar1[2] + -1);

    }

    puVar1 = local_1c0;

    LVar5 = InterlockedDecrement(local_1c0 + 1);

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

  }

  if ((param_8 & 2) != 0) {

    piVar4 = (int *)FUN_0048c3e0("Reckless! ");

    puVar1 = (undefined4 *)*piVar4;

    if ((puVar1[2] != 1) && (puVar1 != DAT_008ef11c)) {

      FUN_004910c0(puVar1 + 5,puVar1[2] + -1);

    }

    puVar1 = local_1c0;

    LVar5 = InterlockedDecrement(local_1c0 + 1);

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

  }

  if (local_1b4 == (undefined4 *)0x0) {

    FUN_0048c3e0(local_1b8);

    local_1bc = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_004ad9c0(param_5);

    local_1c0 = (undefined4 *)*param_1;

    InterlockedIncrement(local_1c0 + 1);

    uVar6 = FUN_0048c3e0("damage!");

    ppuVar32 = &local_1b0;

    ppuVar31 = &local_1b4;

    ppuVar30 = &puStack_168;

    uVar7 = FUN_0048c3e0(&DAT_007d07cc);

    ppuVar25 = &puStack_15c;

    ppuVar29 = &local_1a0;

    ppuVar23 = &puStack_164;

    uVar8 = FUN_0048c3e0(" point");

    ppLVar28 = &pLStack_16c;

    ppuVar27 = &local_1bc;

    ppuVar20 = &puStack_174;

    uVar9 = FUN_0048c3e0(" for ");

    ppuVar19 = &puStack_17c;

    uVar10 = FUN_0048c3e0(&DAT_007d07ac);

    ppuVar24 = &puStack_184;

    ppuVar22 = &local_1a4;

    ppuVar21 = &puStack_18c;

    uVar11 = FUN_0048c3e0(&DAT_00795098);

    ppuVar18 = &puStack_194;

    FUN_004a2b90(&puStack_198,&local_1c0);

    FUN_004a2b90(ppuVar18,uVar11);

    FUN_004a2b90(ppuVar21,ppuVar22);

    FUN_004a2b90(ppuVar24,uVar10);

    FUN_004a2b90(ppuVar19,uVar9);

    FUN_004a2b90(ppuVar20,ppuVar27);

    FUN_004a2b90(ppLVar28,uVar8);

    FUN_004a2b90(ppuVar23,ppuVar29);

    FUN_004a2b90(ppuVar25,uVar7);

    FUN_004a2b90(ppuVar30,ppuVar31);

    piVar4 = (int *)FUN_004a2b90(ppuVar32,uVar6);

    if (puVar13 != (undefined4 *)*piVar4) {

      LVar5 = InterlockedDecrement(puVar13 + 1);

      if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

        (**(code **)*puVar13)(1);

      }

      puStack_1a8 = (undefined4 *)*piVar4;

      InterlockedIncrement(puStack_1a8 + 1);

    }

    puVar13 = local_1b0;

    LVar5 = InterlockedDecrement(local_1b0 + 1);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

    LVar5 = InterlockedDecrement(puStack_168 + 1);

    if ((LVar5 == 0) && (puStack_168 != (undefined4 *)0x0)) {

      (**(code **)*puStack_168)(1);

    }

    LVar5 = InterlockedDecrement(puStack_15c + 1);

    if ((LVar5 == 0) && (puStack_15c != (undefined4 *)0x0)) {

      (**(code **)*puStack_15c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_164 + 1);

    if ((LVar5 == 0) && (puStack_164 != (undefined4 *)0x0)) {

      (**(code **)*puStack_164)(1);

    }

    pLVar2 = pLStack_16c;

    LVar5 = InterlockedDecrement(pLStack_16c + 1);

    if ((LVar5 == 0) && (pLVar2 != (LONG *)0x0)) {

      (**(code **)*pLVar2)(1);

    }

    LVar5 = InterlockedDecrement(puStack_174 + 1);

    if ((LVar5 == 0) && (puStack_174 != (undefined4 *)0x0)) {

      (**(code **)*puStack_174)(1);

    }

    LVar5 = InterlockedDecrement(puStack_17c + 1);

    if ((LVar5 == 0) && (puStack_17c != (undefined4 *)0x0)) {

      (**(code **)*puStack_17c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_184 + 1);

    if ((LVar5 == 0) && (puStack_184 != (undefined4 *)0x0)) {

      (**(code **)*puStack_184)(1);

    }

    LVar5 = InterlockedDecrement(puStack_18c + 1);

    if ((LVar5 == 0) && (puStack_18c != (undefined4 *)0x0)) {

      (**(code **)*puStack_18c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_194 + 1);

    if ((LVar5 == 0) && (puStack_194 != (undefined4 *)0x0)) {

      (**(code **)*puStack_194)(1);

    }

    LVar5 = InterlockedDecrement(puStack_198 + 1);

    if ((LVar5 == 0) && (puStack_198 != (undefined4 *)0x0)) {

      (**(code **)*puStack_198)(1);

    }

    puVar13 = local_1c0;

    LVar5 = InterlockedDecrement(local_1c0 + 1);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

    LVar5 = InterlockedDecrement(puStack_190 + 1);

    if ((LVar5 == 0) && (puStack_190 != (undefined4 *)0x0)) {

      (**(code **)*puStack_190)(1);

    }

    LVar5 = InterlockedDecrement(puStack_178 + 1);

    if ((LVar5 == 0) && (puStack_178 != (undefined4 *)0x0)) {

      (**(code **)*puStack_178)(1);

    }

    LVar5 = InterlockedDecrement(puStack_160 + 1);

    if ((LVar5 == 0) && (puStack_160 != (undefined4 *)0x0)) {

      (**(code **)*puStack_160)(1);

    }

    puVar13 = local_1bc;

    LVar5 = InterlockedDecrement(local_1bc + 1);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

    LVar5 = InterlockedDecrement(puStack_180 + 1);

    if ((LVar5 == 0) && (puStack_180 != (undefined4 *)0x0)) {

      (**(code **)*puStack_180)(1);

    }

    LVar5 = InterlockedDecrement(puStack_19c + 1);

    if ((LVar5 == 0) && (puStack_19c != (undefined4 *)0x0)) {

      (**(code **)*puStack_19c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_188 + 1);

    puVar13 = local_1b4;

    if ((LVar5 == 0) && (puStack_188 != (undefined4 *)0x0)) {

      (**(code **)*puStack_188)(1);

      puVar13 = local_1b4;

    }

  }

  else {

    FUN_0048c3e0(local_1b8);

    local_1bc = DAT_008ef11c;

    InterlockedIncrement(DAT_008ef11c + 1);

    FUN_004ad9c0(param_5);

    local_1b4 = puStack_170;

    pLStack_16c = puStack_170 + 1;

    InterlockedIncrement(pLStack_16c);

    puStack_150 = (undefined4 *)*param_1;

    InterlockedIncrement(puStack_150 + 1);

    uVar6 = FUN_0048c3e0("damage!");

    ppuVar24 = &puStack_148;

    ppuVar32 = &local_1c0;

    ppuVar21 = &puStack_144;

    uVar7 = FUN_0048c3e0(&DAT_007d07cc);

    ppuVar31 = &puStack_188;

    ppuVar30 = &local_1a0;

    ppuVar29 = &puStack_19c;

    uVar8 = FUN_0048c3e0(" point");

    ppuVar27 = &puStack_180;

    ppuVar22 = &local_1bc;

    ppuVar18 = &puStack_160;

    uVar9 = FUN_0048c3e0(" for ");

    ppuVar26 = &puStack_178;

    ppuVar25 = &local_1b4;

    ppuVar23 = &puStack_190;

    uVar10 = FUN_0048c3e0(" your ");

    ppuVar20 = &puStack_198;

    ppuVar19 = &local_1a4;

    ppuVar17 = &puStack_194;

    uVar11 = FUN_0048c3e0(&DAT_00795098);

    ppuVar16 = &puStack_18c;

    FUN_004a2b90(&puStack_184,&puStack_150);

    FUN_004a2b90(ppuVar16,uVar11);

    FUN_004a2b90(ppuVar17,ppuVar19);

    FUN_004a2b90(ppuVar20,uVar10);

    FUN_004a2b90(ppuVar23,ppuVar25);

    FUN_004a2b90(ppuVar26,uVar9);

    FUN_004a2b90(ppuVar18,ppuVar22);

    FUN_004a2b90(ppuVar27,uVar8);

    FUN_004a2b90(ppuVar29,ppuVar30);

    FUN_004a2b90(ppuVar31,uVar7);

    FUN_004a2b90(ppuVar21,ppuVar32);

    piVar4 = (int *)FUN_004a2b90(ppuVar24,uVar6);

    if (puVar13 != (undefined4 *)*piVar4) {

      LVar5 = InterlockedDecrement(puVar13 + 1);

      if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

        (**(code **)*puVar13)(1);

      }

      puStack_1a8 = (undefined4 *)*piVar4;

      InterlockedIncrement(puStack_1a8 + 1);

    }

    LVar5 = InterlockedDecrement(puStack_148 + 1);

    if ((LVar5 == 0) && (puStack_148 != (undefined4 *)0x0)) {

      (**(code **)*puStack_148)(1);

    }

    LVar5 = InterlockedDecrement(puStack_144 + 1);

    if ((LVar5 == 0) && (puStack_144 != (undefined4 *)0x0)) {

      (**(code **)*puStack_144)(1);

    }

    LVar5 = InterlockedDecrement(puStack_188 + 1);

    if ((LVar5 == 0) && (puStack_188 != (undefined4 *)0x0)) {

      (**(code **)*puStack_188)(1);

    }

    LVar5 = InterlockedDecrement(puStack_19c + 1);

    if ((LVar5 == 0) && (puStack_19c != (undefined4 *)0x0)) {

      (**(code **)*puStack_19c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_180 + 1);

    if ((LVar5 == 0) && (puStack_180 != (undefined4 *)0x0)) {

      (**(code **)*puStack_180)(1);

    }

    LVar5 = InterlockedDecrement(puStack_160 + 1);

    if ((LVar5 == 0) && (puStack_160 != (undefined4 *)0x0)) {

      (**(code **)*puStack_160)(1);

    }

    LVar5 = InterlockedDecrement(puStack_178 + 1);

    if ((LVar5 == 0) && (puStack_178 != (undefined4 *)0x0)) {

      (**(code **)*puStack_178)(1);

    }

    LVar5 = InterlockedDecrement(puStack_190 + 1);

    if ((LVar5 == 0) && (puStack_190 != (undefined4 *)0x0)) {

      (**(code **)*puStack_190)(1);

    }

    LVar5 = InterlockedDecrement(puStack_198 + 1);

    if ((LVar5 == 0) && (puStack_198 != (undefined4 *)0x0)) {

      (**(code **)*puStack_198)(1);

    }

    LVar5 = InterlockedDecrement(puStack_194 + 1);

    if ((LVar5 == 0) && (puStack_194 != (undefined4 *)0x0)) {

      (**(code **)*puStack_194)(1);

    }

    LVar5 = InterlockedDecrement(puStack_18c + 1);

    if ((LVar5 == 0) && (puStack_18c != (undefined4 *)0x0)) {

      (**(code **)*puStack_18c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_184 + 1);

    if ((LVar5 == 0) && (puStack_184 != (undefined4 *)0x0)) {

      (**(code **)*puStack_184)(1);

    }

    puVar13 = puStack_150;

    LVar5 = InterlockedDecrement(puStack_150 + 1);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

    LVar5 = InterlockedDecrement(puStack_17c + 1);

    if ((LVar5 == 0) && (puStack_17c != (undefined4 *)0x0)) {

      (**(code **)*puStack_17c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_174 + 1);

    if ((LVar5 == 0) && (puStack_174 != (undefined4 *)0x0)) {

      (**(code **)*puStack_174)(1);

    }

    LVar5 = InterlockedDecrement(pLStack_16c);

    if ((LVar5 == 0) && (local_1b4 != (undefined4 *)0x0)) {

      (**(code **)*local_1b4)(1);

    }

    LVar5 = InterlockedDecrement(puStack_164 + 1);

    if ((LVar5 == 0) && (puStack_164 != (undefined4 *)0x0)) {

      (**(code **)*puStack_164)(1);

    }

    puVar13 = local_1bc;

    LVar5 = InterlockedDecrement(local_1bc + 1);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

    LVar5 = InterlockedDecrement(puStack_15c + 1);

    if ((LVar5 == 0) && (puStack_15c != (undefined4 *)0x0)) {

      (**(code **)*puStack_15c)(1);

    }

    LVar5 = InterlockedDecrement(puStack_168 + 1);

    if ((LVar5 == 0) && (puStack_168 != (undefined4 *)0x0)) {

      (**(code **)*puStack_168)(1);

    }

    puVar1 = local_1b0;

    LVar5 = InterlockedDecrement(local_1b0 + 1);

    puVar13 = local_1c0;

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

      puVar13 = local_1c0;

    }

  }

  LVar5 = InterlockedDecrement(puVar13 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  FUN_0048c3e0(&DAT_007938af);

  iVar12 = FUN_0058a000(0,&local_1c0,6);

  puVar13 = local_1c0;

  LVar5 = InterlockedDecrement(local_1c0 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  if (iVar12 == 0) {

    if ((param_8 & 1) != 0) {

      FUN_0048c3e0(" Your Critical Protection augmentation allows you to avoid a critical hit!");

      puVar13 = local_1b0;

      if ((local_1b0[2] != 1) && (local_1b0 != DAT_008ef11c)) {

        FUN_004910c0(local_1b0 + 5,local_1b0[2] + -1);

      }

      LVar5 = InterlockedDecrement(puVar13 + 1);

      if (LVar5 == 0) {

        (**(code **)*puVar13)(1);

      }

    }

    FUN_0048c3e0(&DAT_00795508);

    puVar13 = local_1b0;

    if ((local_1b0[2] != 1) && (local_1b0 != DAT_008ef11c)) {

      FUN_004910c0(local_1b0 + 5,local_1b0[2] + -1);

    }

    LVar5 = InterlockedDecrement(puVar13 + 1);

    if (LVar5 == 0) {

      (**(code **)*puVar13)(1);

    }

    FUN_00404a40(0,puStack_1a8 + 5);

    FUN_005649f0(&local_1c0,0x15,1,0);

    puVar13 = local_1c0 + -5;

    LVar5 = InterlockedDecrement(local_1c0 + -4);

    if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

      (**(code **)*puVar13)(1);

    }

  }

  uVar6 = DAT_008379ac;

  *(undefined4 *)(local_14c + 0x58) = DAT_008379a8;

  *(undefined4 *)(local_14c + 0x5c) = uVar6;

  if ((*(int *)(local_14c + 0x1c) == 2) || (*(int *)(local_14c + 0x1c) == 4)) {

    FUN_0055e1d0();

    cVar3 = FUN_005d3e90();

    if ((cVar3 != '\0') && (DAT_00871e54 == 0)) {

      FUN_0056c9d0();

    }

  }

  puVar13 = puStack_1ac;

  LVar5 = InterlockedDecrement(puStack_1ac + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  LVar5 = InterlockedDecrement(puStack_158 + 1);

  if ((LVar5 == 0) && (puStack_158 != (undefined4 *)0x0)) {

    (**(code **)*puStack_158)(1);

  }

  puVar13 = puStack_1a8;

  LVar5 = InterlockedDecrement(puStack_1a8 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  puVar13 = puStack_170;

  LVar5 = InterlockedDecrement(puStack_170 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  pcVar14 = local_1b8 + -0x14;

  LVar5 = InterlockedDecrement((LONG *)(local_1b8 + -0x10));

  if ((LVar5 == 0) && (pcVar14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)pcVar14)(1);

  }

  puVar13 = local_1a0;

  LVar5 = InterlockedDecrement(local_1a0 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  puVar13 = local_1a4;

  LVar5 = InterlockedDecrement(local_1a4 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  puVar13 = local_154;

  LVar5 = InterlockedDecrement(local_154 + 1);

  if ((LVar5 == 0) && (puVar13 != (undefined4 *)0x0)) {

    (**(code **)*puVar13)(1);

  }

  return;

}





// --- FUN_0056e6b0 at 0x0056E6B0 (size: 6) ---


undefined4 FUN_0056e6b0(void)



{

  return DAT_0087174c;

}





// --- FUN_0056e6e0 at 0x0056E6E0 (size: 18) ---


undefined4 FUN_0056e6e0(undefined4 param_1)



{

  FUN_006ae560(param_1);

  return 0;

}





// --- FUN_0056e700 at 0x0056E700 (size: 50) ---


undefined4 FUN_0056e700(undefined4 param_1)



{

  int iVar1;

  int *piVar2;

  

  FUN_006ae670(param_1);

  iVar1 = FUN_0055b0a0();

  if (iVar1 != 0) {

    piVar2 = (int *)FUN_0055a740();

    (**(code **)(*piVar2 + 0x4c))(piVar2);

  }

  FUN_005bb570();

  return 0;

}





// --- FUN_0056e740 at 0x0056E740 (size: 36) ---


undefined4 FUN_0056e740(undefined4 param_1,undefined4 param_2)



{

  FUN_005bb4e0(param_1,1);

  FUN_006ae710(param_1,param_2);

  return 0;

}





// --- FUN_0056e770 at 0x0056E770 (size: 8) ---


undefined4 FUN_0056e770(void)



{

  FUN_006ae470();

  return 0;

}





// --- FUN_0056e780 at 0x0056E780 (size: 21) ---


void FUN_0056e780(undefined4 param_1,undefined4 param_2)



{

  FUN_006ae030(param_1,param_2);

  return;

}





// --- FUN_0056e7a0 at 0x0056E7A0 (size: 21) ---


void __fastcall FUN_0056e7a0(int param_1)



{

  *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x38) = 1;

  FUN_006adf70(*(undefined4 *)(param_1 + 0x10));

  return;

}





// --- FUN_0056e7c0 at 0x0056E7C0 (size: 15) ---


void __fastcall FUN_0056e7c0(int param_1)



{

  *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x38) = 0;

  FUN_006ae1d0();

  return;

}





// --- thunk_FUN_006ae330 at 0x0056E7D0 (size: 5) ---


char thunk_FUN_006ae330(void)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puStack_c;

  undefined **ppuStack_8;

  undefined4 uStack_4;

  

  uStack_4 = FUN_005473a0();

  ppuStack_8 = &PTR_FUN_00802c2c;

  puStack_c = (undefined4 *)0x0;

  iVar2 = FUN_006b4010(&puStack_c,0);

  iVar2 = iVar2 + 4;

  puVar3 = (undefined4 *)thunk_FUN_005df0f5(iVar2);

  puStack_c = puVar3;

  FUN_006b4010(&puStack_c,iVar2);

  *puStack_c = 0x204;

  puStack_c = puStack_c + 1;

  cVar1 = FUN_005473d0(puVar3,iVar2);

  if (cVar1 == '\0') {

    FUN_005473b0(uStack_4);

  }

  return cVar1;

}





// --- thunk_FUN_006ae140 at 0x0056E7E0 (size: 5) ---


char thunk_FUN_006ae140(void)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 *puStack_c;

  undefined **ppuStack_8;

  undefined4 uStack_4;

  

  uStack_4 = FUN_005473a0();

  ppuStack_8 = &PTR_FUN_00802c2c;

  puStack_c = (undefined4 *)0x0;

  iVar2 = FUN_006b4010(&puStack_c,0);

  iVar2 = iVar2 + 4;

  puVar3 = (undefined4 *)thunk_FUN_005df0f5(iVar2);

  puStack_c = puVar3;

  FUN_006b4010(&puStack_c,iVar2);

  *puStack_c = 0x1f7;

  puStack_c = puStack_c + 1;

  cVar1 = FUN_005473d0(puVar3,iVar2);

  if (cVar1 == '\0') {

    FUN_005473b0(uStack_4);

  }

  return cVar1;

}





// --- FUN_0056e7f0 at 0x0056E7F0 (size: 27) ---


int FUN_0056e7f0(void)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_005bb1e0();

  iVar2 = FUN_005bb1c0();

  return iVar2 + iVar1;

}





// --- FUN_0056e810 at 0x0056E810 (size: 27) ---


int FUN_0056e810(void)



{

  int iVar1;

  int iVar2;

  

  iVar1 = FUN_005bb220();

  iVar2 = FUN_005bb200();

  return iVar2 + iVar1;

}





// --- FUN_0056e830 at 0x0056E830 (size: 21) ---


bool FUN_0056e830(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_005bb0e0(param_1);

  return iVar1 != 0;

}





// --- FUN_0056e850 at 0x0056E850 (size: 67) ---


void __fastcall FUN_0056e850(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(undefined4 **)(param_1 + 0x10) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x10))(1);

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  *(undefined4 *)(param_1 + 0x14) = 0;

  *(undefined4 *)(param_1 + 0x18) = 0;

  *(undefined4 *)(param_1 + 0x1c) = 0;

  *(undefined4 *)(param_1 + 0x20) = 0;

  iVar1 = FUN_005df0f5(0x40);

  if (iVar1 != 0) {

    uVar2 = FUN_005bb6a0();

    *(undefined4 *)(param_1 + 0x10) = uVar2;

    return;

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  return;

}





// --- FUN_0056e8a0 at 0x0056E8A0 (size: 61) ---


void __fastcall FUN_0056e8a0(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007d0d0c;

  param_1[1] = &PTR_FUN_007ccb60;

  if ((undefined4 *)param_1[4] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[4])(1);

  }

  param_1[4] = 0;

  param_1[2] = &PTR_LAB_00793b6c;

  param_1[1] = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_0056e9b0 at 0x0056E9B0 (size: 51) ---


undefined4 FUN_0056e9b0(undefined4 param_1,int param_2)



{

  undefined4 uVar1;

  

  if (param_2 == 1) {

    uVar1 = 1;

  }

  else {

    if (param_2 != 2) goto LAB_0056e9d2;

    uVar1 = 2;

  }

  FUN_005bb4e0(param_1,uVar1);

LAB_0056e9d2:

  FUN_006ae610(param_1,param_2);

  return 0;

}





// --- FUN_0056e9f0 at 0x0056E9F0 (size: 154) ---


undefined4 __thiscall FUN_0056e9f0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  

  if (param_2 == 0) {

    *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x38) = 0;

  }

  else {

    if (DAT_0083da58 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_2 == iVar1) {

      *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x38) = 1;

    }

    else {

      *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x3c) = 1;

    }

  }

  FUN_006ae3c0(param_2);

  if (param_2 != 0) {

    if (DAT_0083da58 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_2 == iVar1) {

      iVar1 = FUN_0055b0a0();

      if (iVar1 != 0) {

        piVar2 = (int *)FUN_0055a740();

        (**(code **)(*piVar2 + 0x44))(piVar2,1);

      }

    }

    else {

      iVar1 = FUN_0055b0a0();

      if (iVar1 != 0) {

        piVar2 = (int *)FUN_0055a740();

        (**(code **)(*piVar2 + 0x44))(piVar2,2);

        return 0;

      }

    }

  }

  return 0;

}





// --- FUN_0056ea90 at 0x0056EA90 (size: 124) ---


undefined4 __thiscall FUN_0056ea90(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  

  if (DAT_0083da58 == 0) {

    iVar1 = 0;

  }

  else {

    iVar1 = *(int *)(DAT_0083da58 + 0xf4);

  }

  if (param_2 == iVar1) {

    *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x38) = 0;

  }

  else {

    *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x3c) = 0;

  }

  FUN_006ae510(param_2);

  if (param_2 == *(int *)(DAT_0083da58 + 0xf4)) {

    iVar1 = FUN_0055b0a0();

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_0055a740();

      (**(code **)(*piVar2 + 0x48))(piVar2,1);

    }

  }

  else {

    iVar1 = FUN_0055b0a0();

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_0055a740();

      (**(code **)(*piVar2 + 0x48))(piVar2,2);

      return 0;

    }

  }

  return 0;

}





// --- FUN_0056eb10 at 0x0056EB10 (size: 107) ---


undefined4 * __fastcall FUN_0056eb10(undefined4 *param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  param_1[1] = &PTR_FUN_007ccb60;

  *param_1 = &PTR_LAB_007d0d0c;

  param_1[1] = &PTR_FUN_007ccb60;

  param_1[3] = 1;

  param_1[2] = &PTR_LAB_00793b6c;

  DAT_0087174c = param_1;

  InterlockedIncrement(param_1 + 3);

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  iVar1 = FUN_005df0f5(0x40);

  if (iVar1 != 0) {

    uVar2 = FUN_005bb6a0();

    param_1[4] = uVar2;

    return param_1;

  }

  param_1[4] = 0;

  return param_1;

}





// --- FUN_0056eb80 at 0x0056EB80 (size: 34) ---


int __thiscall FUN_0056eb80(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x10) + 0x18);

  iVar2 = 0;

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if (*(int *)(iVar1 + 4) == param_2) break;

    iVar1 = *(int *)(iVar1 + 0xc);

    iVar2 = iVar2 + 1;

  }

  return iVar2;

}





// --- FUN_0056ebb0 at 0x0056EBB0 (size: 43) ---


int __fastcall FUN_0056ebb0(void *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (void *)0x0)) {

    FUN_0056e8a0();

    operator_delete(param_1);

  }

  return iVar1;

}





// --- FUN_0056ebe0 at 0x0056EBE0 (size: 162) ---


undefined4 __thiscall FUN_0056ebe0(wchar_t *param_1,undefined4 param_2)



{

  size_t sVar1;

  LONG LVar2;

  int iVar3;

  int *piVar4;

  wchar_t *pwVar5;

  wchar_t *local_4;

  

  local_4 = param_1;

  sVar1 = wcslen(L"The trade has been cancelled.");

  FUN_004022d0(sVar1);

  wcscpy(local_4,L"The trade has been cancelled.");

  FUN_005649f0(&local_4,0x1a,1,0);

  pwVar5 = local_4 + -10;

  LVar2 = InterlockedDecrement((LONG *)(local_4 + -8));

  if ((LVar2 == 0) && (pwVar5 != (wchar_t *)0x0)) {

    (*(code *)**(undefined4 **)pwVar5)(1);

  }

  FUN_006ae4c0(param_2);

  iVar3 = FUN_0055b0a0();

  if (iVar3 != 0) {

    piVar4 = (int *)FUN_0055a740();

    (**(code **)(*piVar4 + 0x40))(piVar4);

  }

  FUN_005bb570();

  param_1[10] = L'\0';

  param_1[0xb] = L'\0';

  param_1[0xc] = L'\0';

  param_1[0xd] = L'\0';

  return 0;

}





// --- FUN_0056ec90 at 0x0056EC90 (size: 157) ---


undefined4 FUN_0056ec90(int param_1)



{

  int iVar1;

  LONG LVar2;

  int local_94;

  undefined1 local_90 [144];

  

  iVar1 = FUN_0056b210();

  if (*(int *)(iVar1 + 0x1c) == 1) {

    if (param_1 != 0) {

      FUN_006ae260(param_1);

      return 1;

    }

  }

  else {

    FUN_0042dc80();

    FUN_00402730(L"You need to be in peace mode to trade.");

    FUN_0042cbe0(&local_94,1);

    LVar2 = InterlockedDecrement((LONG *)(local_94 + -0x10));

    if ((LVar2 == 0) && ((undefined4 *)(local_94 + -0x14) != (undefined4 *)0x0)) {

      (*(code *)**(undefined4 **)(local_94 + -0x14))(1);

    }

    FUN_00693500(0x1a,local_90);

    FUN_0042e590();

  }

  return 0;

}





// --- FUN_0056ed30 at 0x0056ED30 (size: 207) ---


void __thiscall FUN_0056ed30(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  undefined1 local_94 [4];

  undefined1 local_90 [144];

  

  iVar1 = FUN_005583f0(param_3);

  if (iVar1 != 0) {

    iVar1 = FUN_0058df90();

    if (iVar1 != 0) {

      if (*(int *)(param_1 + 0x18) != 0) {

        if (*(int *)(param_1 + 0x18) == param_2) {

          FUN_006ae6c0(param_3);

          return;

        }

        FUN_0042dc80();

        FUN_00402730(L"You are already trading with someone else.");

        FUN_0042cbe0(local_94,1);

        FUN_004011b0();

        FUN_00693500(0x1a,local_90);

        FUN_0042e590();

        return;

      }

      FUN_005898b0(param_2,0,0);

      *(int *)(param_1 + 0x1c) = param_2;

      *(undefined4 *)(param_1 + 0x20) = param_3;

    }

  }

  return;

}





// --- FUN_0056ee00 at 0x0056EE00 (size: 166) ---


undefined4 __thiscall

FUN_0056ee00(int param_1,int param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5)



{

  int iVar1;

  int *piVar2;

  

  *(int *)(param_1 + 0x14) = param_2;

  *(undefined4 *)(param_1 + 0x18) = param_3;

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_005bb030(param_3,param_4,param_5);

    if (DAT_0083da58 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)(DAT_0083da58 + 0xf4);

    }

    if (param_2 == iVar1) {

      *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x34) = 1;

    }

    else {

      *(undefined4 *)(*(int *)(param_1 + 0x10) + 0x34) = 0;

    }

    FUN_006ae5b0(param_2,param_3,param_4,param_5);

    iVar1 = FUN_0055b0a0();

    if (iVar1 != 0) {

      piVar2 = (int *)FUN_0055a740();

      (**(code **)(*piVar2 + 0x38))(piVar2,param_3);

    }

    if (*(int *)(param_1 + 0x18) == *(int *)(param_1 + 0x1c)) {

      FUN_0056ed30(*(int *)(param_1 + 0x1c),*(undefined4 *)(param_1 + 0x20));

    }

    *(undefined4 *)(param_1 + 0x20) = 0;

    *(undefined4 *)(param_1 + 0x1c) = 0;

  }

  return 0;

}





// --- FUN_0056eeb0 at 0x0056EEB0 (size: 219) ---


undefined4 FUN_0056eeb0(int *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int *piVar2;

  int iVar3;

  undefined1 *puVar4;

  undefined *puVar5;

  int *piVar6;

  undefined4 *puVar7;

  undefined4 uVar8;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  uVar1 = param_1;

  iVar3 = FUN_005583f0(param_1);

  puVar7 = &param_1;

  puVar4 = local_10;

  puVar5 = &DAT_007d0c30;

  param_1 = (int *)0x0;

  FUN_00406d10(puVar4,&DAT_007d0c30,puVar7);

  FUN_00406570(puVar4,puVar5,puVar7);

  piVar2 = param_1;

  uVar8 = 0;

  local_8 = (int *)0x0;

  local_4 = 0;

  piVar6 = param_1;

  if (param_1 != (int *)0x0) {

    (**(code **)(*param_1 + 0x10))(param_1,0);

  }

  param_1 = (int *)FUN_004c1da0(local_c,piVar6,uVar8);

  param_1 = (int *)*param_1;

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 0x14))();

  }

  piVar2 = local_8;

  if (local_8 != (int *)0x0) {

    if (-1 < (int)param_1) {

      FUN_005bb450(uVar1,2,param_2);

      if (iVar3 != 0) {

        FUN_0058d850();

        FUN_00508f10(uVar1);

        (**(code **)(*piVar2 + 0x14))();

        return 1;

      }

    }

    (**(code **)(*piVar2 + 0x14))();

  }

  return 0;

}





// --- FUN_0056ef90 at 0x0056EF90 (size: 87) ---


undefined4 FUN_0056ef90(undefined4 param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  int *piVar2;

  

  if (param_2 == 1) {

    FUN_005bb450(param_1,1,param_3);

  }

  else if (param_2 == 2) {

    FUN_0056eeb0(param_1,param_3);

  }

  FUN_006ae410(param_1,param_2,param_3);

  iVar1 = FUN_0055b0a0();

  if (iVar1 != 0) {

    piVar2 = (int *)FUN_0055a740();

    (**(code **)(*piVar2 + 0x3c))(piVar2,param_2,param_1);

  }

  return 0;

}





// --- FUN_0056eff0 at 0x0056EFF0 (size: 67) ---


void FUN_0056eff0(void)



{

  undefined4 uVar1;

  

  uVar1 = FUN_005bb6a0();

  FUN_006adf70(uVar1);

  FUN_0055b780();

  FUN_0055b780();

  return;

}





// --- FUN_0056f040 at 0x0056F040 (size: 493) ---


undefined4 FUN_0056f040(char *param_1,undefined4 *param_2)



{

  int iVar1;

  

  if (param_1 == (char *)0x0) {

    return 0;

  }

  iVar1 = _stricmp(param_1,"Scarab");

  if (iVar1 == 0) {

LAB_0056f063:

    *param_2 = 0;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Herb");

  if (iVar1 == 0) {

LAB_0056f084:

    *param_2 = 1;

    return 1;

  }

  iVar1 = _stricmp(param_1,"PowderedGem");

  if (iVar1 == 0) {

LAB_0056f0a5:

    *param_2 = 2;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Powder");

  if (iVar1 == 0) {

LAB_0056f0c6:

    *param_2 = 2;

    return 1;

  }

  iVar1 = _stricmp(param_1,"AlchemicalSubstance");

  if (iVar1 == 0) {

LAB_0056f0e7:

    *param_2 = 3;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Potion");

  if (iVar1 == 0) {

LAB_0056f108:

    *param_2 = 3;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Talisman");

  if (iVar1 == 0) {

LAB_0056f129:

    *param_2 = 4;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Taper");

  if (iVar1 == 0) {

LAB_0056f14a:

    *param_2 = 5;

    return 1;

  }

  iVar1 = _stricmp(param_1,"Pea");

  if (iVar1 != 0) {

    iVar1 = _stricmp(param_1,"Scarabs");

    if (iVar1 == 0) goto LAB_0056f063;

    iVar1 = _stricmp(param_1,"Herbs");

    if (iVar1 == 0) goto LAB_0056f084;

    iVar1 = _stricmp(param_1,"PowderedGems");

    if (iVar1 == 0) goto LAB_0056f0a5;

    iVar1 = _stricmp(param_1,"Powders");

    if (iVar1 == 0) goto LAB_0056f0c6;

    iVar1 = _stricmp(param_1,"AlchemicalSubstances");

    if (iVar1 == 0) goto LAB_0056f0e7;

    iVar1 = _stricmp(param_1,"Potions");

    if (iVar1 == 0) goto LAB_0056f108;

    iVar1 = _stricmp(param_1,"Talismans");

    if (iVar1 == 0) goto LAB_0056f129;

    iVar1 = _stricmp(param_1,"Tapers");

    if (iVar1 == 0) goto LAB_0056f14a;

    iVar1 = _stricmp(param_1,"Peas");

    if (iVar1 != 0) {

      return 0;

    }

  }

  *param_2 = 6;

  return 1;

}





// --- FUN_0056f230 at 0x0056F230 (size: 6) ---


undefined4 FUN_0056f230(void)



{

  return DAT_008717fc;

}





// --- FUN_0056f2a0 at 0x0056F2A0 (size: 81) ---


undefined4 FUN_0056f2a0(undefined4 param_1)



{

  int iVar1;

  int iVar2;

  

  FUN_00589f40(param_1);

  iVar1 = FUN_00589f20();

  if (iVar1 != 0) {

    iVar1 = FUN_004f1b20();

    FUN_00589eb0(7,iVar1 != 0);

    iVar2 = FUN_00589f80();

    if ((iVar2 != 0) && (iVar1 != 0)) {

      FUN_00589e70(7);

    }

  }

  return 0;

}





// --- FUN_0056f300 at 0x0056F300 (size: 38) ---


undefined4

FUN_0056f300(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  FUN_0058ad90(param_1,param_2,param_3,param_4,param_5);

  return 0;

}





// --- FUN_0056f330 at 0x0056F330 (size: 76) ---


bool __fastcall FUN_0056f330(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  

  iVar3 = FUN_0040fa90();

  iVar2 = *(int *)(param_1 + 0x90);

  *(int *)(param_1 + 0x90) = iVar3;

  if (iVar2 == 0) {

    return false;

  }

  piVar1 = (int *)(param_1 + 0x94);

  *piVar1 = *piVar1 + (1 - (iVar3 - iVar2));

  if (*piVar1 < 0) {

    *(undefined4 *)(param_1 + 0x94) = 0;

  }

  return 0 < *(int *)(param_1 + 0x94);

}





// --- FUN_0056f400 at 0x0056F400 (size: 260) ---


undefined4 __fastcall FUN_0056f400(undefined4 param_1)



{

  undefined1 uVar1;

  int iVar2;

  

  iVar2 = FUN_00556ed0(param_1);

  if (iVar2 == 0) {

    FUN_00589eb0(8,0);

    FUN_00589eb0(9,0);

    FUN_00589eb0(10,0);

    FUN_00589eb0(0xb,0);

    FUN_00589eb0(0xc,0);

    FUN_00589eb0(0xd,0);

    return 0;

  }

  FUN_0055e1d0();

  uVar1 = FUN_005d45b0();

  FUN_00589eb0(8,uVar1);

  FUN_0055e1d0();

  uVar1 = FUN_005d4600();

  FUN_00589eb0(9,uVar1);

  FUN_0055e1d0();

  uVar1 = FUN_005d4650();

  FUN_00589eb0(10,uVar1);

  FUN_0055e1d0();

  uVar1 = FUN_005d46a0();

  FUN_00589eb0(0xb,uVar1);

  FUN_0055e1d0();

  uVar1 = FUN_005d46f0();

  FUN_00589eb0(0xc,uVar1);

  iVar2 = FUN_00560f80();

  FUN_00589eb0(0xd,iVar2 != 0);

  return 1;

}





// --- FUN_0056f510 at 0x0056F510 (size: 73) ---


undefined4 FUN_0056f510(char *param_1,char *param_2)



{

  char cVar1;

  int iVar2;

  int iVar3;

  

  cVar1 = *param_2;

  while( true ) {

    if (cVar1 == '\0') {

      return 1;

    }

    if (*param_1 == '\0') break;

    iVar2 = tolower((int)*param_1);

    iVar3 = tolower((int)*param_2);

    if (iVar2 != iVar3) {

      return 0;

    }

    cVar1 = param_2[1];

    param_1 = param_1 + 1;

    param_2 = param_2 + 1;

  }

  return 0;

}





// --- FUN_0056f6d0 at 0x0056F6D0 (size: 64) ---


undefined4 * __thiscall FUN_0056f6d0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007d10fc;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0056f710 at 0x0056F710 (size: 212) ---


undefined4 __thiscall FUN_0056f710(int *param_1,int *param_2,char param_3)



{

  uint uVar1;

  char cVar2;

  int iVar3;

  undefined4 uVar4;

  uint uVar5;

  

  if (*(int *)(*param_2 + -4) == 1) {

    return 1;

  }

  uVar1 = *(int *)(*param_2 + -4) - 1;

  if (param_3 != '\0') {

    if ((int)uVar1 < 0) {

      FUN_0040b0f0(uVar1);

    }

    if ((uint)param_1[1] < uVar1) {

      param_1[1] = 0;

    }

    else {

      iVar3 = param_1[1] - uVar1;

      while( true ) {

        param_1[1] = iVar3;

        uVar4 = (**(code **)(*param_1 + 4))(iVar3);

        cVar2 = FUN_0056f510(uVar4,*param_2);

        if (cVar2 != '\0') {

          param_1[2] = param_1[1] + uVar1;

          return 1;

        }

        if (param_1[1] == 0) break;

        iVar3 = param_1[1] + -1;

      }

    }

    param_1[1] = 0;

    return 0;

  }

  while( true ) {

    uVar4 = (**(code **)(*param_1 + 4))(param_1[1]);

    cVar2 = FUN_0056f510(uVar4,*param_2);

    if (cVar2 != '\0') {

      param_1[2] = param_1[1] + uVar1;

      return 1;

    }

    iVar3 = param_1[1];

    uVar5 = (**(code **)*param_1)();

    if (uVar5 < iVar3 + 1U) break;

    param_1[1] = iVar3 + 1U;

  }

  iVar3 = (**(code **)*param_1)();

  param_1[1] = iVar3;

  return 0;

}





// --- FUN_0056f7f0 at 0x0056F7F0 (size: 106) ---


undefined1 FUN_0056f7f0(char *param_1)



{

  int *piVar1;

  LONG LVar2;

  undefined1 uVar3;

  char *local_4;

  

  local_4 = (char *)0x0;

  piVar1 = _errno();

  *piVar1 = 0;

  strtol(param_1,&local_4,0);

  if (*local_4 == '\0') {

    piVar1 = _errno();

    if (*piVar1 != 0x22) {

      uVar3 = 1;

      goto LAB_0056f836;

    }

  }

  uVar3 = 0;

LAB_0056f836:

  LVar2 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar2 == 0) && (param_1 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(param_1 + -0x14))(1);

  }

  return uVar3;

}





// --- FUN_0056f860 at 0x0056F860 (size: 213) ---


void __fastcall FUN_0056f860(undefined4 *param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  LONG LVar3;

  undefined4 *puVar4;

  

  puVar1 = param_1 + 1;

  *param_1 = &PTR_LAB_007d13b0;

  *puVar1 = &PTR_FUN_007d1108;

  param_1[2] = &PTR_LAB_007d1100;

  piVar2 = (int *)FUN_0043c680();

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 0xc))(puVar1);

  }

  puVar4 = (undefined4 *)(param_1[0x26] + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(param_1[0x26] + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  puVar4 = (undefined4 *)(param_1[0x22] + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(param_1[0x22] + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  puVar4 = (undefined4 *)(param_1[0x21] + -0x14);

  LVar3 = InterlockedDecrement((LONG *)(param_1[0x21] + -0x10));

  if ((LVar3 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  param_1[5] = &PTR_FUN_007d10fc;

  if ((undefined4 *)param_1[0x1d] != param_1 + 6) {

    operator_delete__((undefined4 *)param_1[0x1d]);

  }

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[3] = &PTR_LAB_00793b6c;

  *puVar1 = &PTR_FUN_007ccb60;

  FUN_0043c610();

  return;

}





// --- FUN_0056f940 at 0x0056F940 (size: 90) ---


undefined4 FUN_0056f940(undefined4 *param_1)



{

  int iVar1;

  undefined4 *puVar2;

  LONG LVar3;

  

  FUN_0058a050(param_1);

  iVar1 = DAT_00871e54;

  if (DAT_00871e54 != 0) {

    FUN_0048c3e0(&DAT_007938af);

    FUN_0058a000(iVar1,&param_1,1);

    puVar2 = param_1;

    LVar3 = InterlockedDecrement(param_1 + 1);

    if ((LVar3 == 0) && (puVar2 != (undefined4 *)0x0)) {

      (**(code **)*puVar2)(1);

    }

  }

  return 0;

}





// --- FUN_0056f9a0 at 0x0056F9A0 (size: 312) ---


void __thiscall FUN_0056f9a0(int *param_1,int param_2,int param_3,undefined4 *param_4)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  char cVar3;

  char *pcVar4;

  LONG LVar5;

  LONG *lpAddend;

  int iVar6;

  char *pcVar7;

  

  pcVar7 = (char *)(*param_1 + 0x14);

  iVar6 = *(int *)(*param_1 + 8) + -1;

  if ((param_2 != 0) && (cVar3 = *pcVar7, cVar3 != '\0')) {

    do {

      pcVar4 = strchr((char *)(param_4 + 5),(int)cVar3);

      if (pcVar4 == (char *)0x0) break;

      cVar3 = pcVar7[1];

      pcVar7 = pcVar7 + 1;

      iVar6 = iVar6 + -1;

    } while (cVar3 != '\0');

  }

  if ((param_3 != 0) && (iVar6 != 0)) {

    do {

      pcVar4 = strchr((char *)(param_4 + 5),(int)pcVar7[iVar6 + -1]);

      if (pcVar4 == (char *)0x0) break;

      iVar6 = iVar6 + -1;

    } while (iVar6 != 0);

  }

  puVar1 = (undefined4 *)*param_1;

  if ((pcVar7 == (char *)(puVar1 + 5)) && (iVar6 == puVar1[2] + -1)) {

    iVar6 = InterlockedDecrement(param_4 + 1);

  }

  else {

    InterlockedIncrement(puVar1 + 1);

    puVar2 = (undefined4 *)*param_1;

    if (puVar2 != DAT_008ef11c) {

      LVar5 = InterlockedDecrement(puVar2 + 1);

      if ((LVar5 == 0) && (puVar2 != (undefined4 *)0x0)) {

        (**(code **)*puVar2)(1);

      }

      lpAddend = DAT_008ef11c + 1;

      *param_1 = (int)DAT_008ef11c;

      InterlockedIncrement(lpAddend);

    }

    if (iVar6 != 0) {

      FUN_004910c0(pcVar7,iVar6);

    }

    LVar5 = InterlockedDecrement(puVar1 + 1);

    if ((LVar5 == 0) && (puVar1 != (undefined4 *)0x0)) {

      (**(code **)*puVar1)(1);

    }

    iVar6 = InterlockedDecrement(param_4 + 1);

  }

  if ((iVar6 == 0) && (param_4 != (undefined4 *)0x0)) {

    (**(code **)*param_4)(1);

  }

  return;

}





// --- FUN_0056fae0 at 0x0056FAE0 (size: 62) ---


int * __thiscall

FUN_0056fae0(int *param_1,int *param_2,int param_3,int param_4,int param_5,int param_6)



{

  int iVar1;

  

  iVar1 = *param_2;

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  param_1[2] = param_3;

  param_1[4] = param_5;

  param_1[1] = 0;

  param_1[3] = param_4;

  param_1[5] = param_6;

  return param_1;

}





// --- FUN_0056fb20 at 0x0056FB20 (size: 305) ---


undefined4 FUN_0056fb20(int *param_1)



{

  char *_String;

  char *pcVar1;

  int iVar2;

  LONG LVar3;

  int iVar4;

  undefined4 uVar5;

  char *local_8;

  

  _String = (char *)*param_1;

  if (0x100 < *(uint *)(_String + -4)) {

    return 0;

  }

  InterlockedIncrement((LONG *)(_String + -0x10));

  FUN_004080c0();

  _strlwr(_String);

  FUN_00401340("<tell:");

  pcVar1 = strstr(_String,local_8);

  if (pcVar1 == (char *)0x0) {

    iVar2 = -1;

  }

  else {

    iVar2 = (int)pcVar1 - (int)_String;

  }

  LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar3 == 0) && (local_8 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

  }

  FUN_00401340(&DAT_00795508);

  pcVar1 = strstr((char *)*param_1,local_8);

  if (pcVar1 == (char *)0x0) {

    iVar4 = -1;

  }

  else {

    iVar4 = (int)pcVar1 - *param_1;

  }

  LVar3 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar3 == 0) && (local_8 + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

  }

  if ((iVar2 == -1) && (iVar4 == -1)) {

    uVar5 = 1;

  }

  else {

    uVar5 = 0;

  }

  LVar3 = InterlockedDecrement((LONG *)(_String + -0x10));

  if ((LVar3 == 0) && (_String + -0x14 != (char *)0x0)) {

    (*(code *)**(undefined4 **)(_String + -0x14))(1);

  }

  return uVar5;

}





// --- FUN_0056fc60 at 0x0056FC60 (size: 113) ---


undefined4 * FUN_0056fc60(undefined4 *param_1,int *param_2,int *param_3)



{

  undefined *puVar1;

  LONG LVar2;

  

  puVar1 = PTR_DAT_00818344;

  InterlockedIncrement((LONG *)(PTR_DAT_00818344 + -0x10));

  if (*param_2 != 0) {

    FUN_00405000(*(undefined4 *)*param_3);

    *param_2 = *param_2 + -1;

    *param_3 = *param_3 + 4;

  }

  *param_1 = puVar1;

  InterlockedIncrement((LONG *)(puVar1 + -0x10));

  LVar2 = InterlockedDecrement((LONG *)(puVar1 + -0x10));

  if ((LVar2 == 0) && ((undefined4 *)(puVar1 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(puVar1 + -0x14))(1);

  }

  return param_1;

}





// --- FUN_0056fd40 at 0x0056FD40 (size: 28) ---


undefined1 FUN_0056fd40(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  undefined1 uVar3;

  int *piVar4;

  LONG LVar5;

  int iVar6;

  undefined4 *puVar7;

  undefined4 uVar8;

  int iStack_4;

  

  if (param_1 < 2) {

    uVar3 = FUN_006a7bf0(1);

    return uVar3;

  }

  piVar4 = (int *)FUN_0056fc60(&iStack_4,&param_1,&param_2);

  iVar1 = *piVar4;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  puVar7 = (undefined4 *)(iStack_4 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(iStack_4 + -0x10));

  if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  piVar4 = (int *)FUN_0056fc60(&iStack_4,&param_1,&param_2);

  iVar2 = *piVar4;

  param_1 = iVar2;

  InterlockedIncrement((LONG *)(iVar2 + -0x10));

  LVar5 = InterlockedDecrement((LONG *)(iStack_4 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iStack_4 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iStack_4 + -0x14))(1);

  }

  FUN_00401340("guest");

  iVar6 = FUN_00404b40(&param_2,0);

  puVar7 = (undefined4 *)(param_2 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

  if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  if (iVar6 == 0) {

    FUN_00401340(&DAT_00795090);

    iVar6 = FUN_00404b40(&param_2,0);

    puVar7 = (undefined4 *)(param_2 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      uVar3 = FUN_006a7bf0(2);

      LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

      }

      LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

      if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

      }

      return uVar3;

    }

    FUN_00401340("close");

    iVar6 = FUN_00404b40(&param_2,0);

    puVar7 = (undefined4 *)(param_2 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      uVar8 = 3;

      goto LAB_0056ff19;

    }

  }

  else {

    FUN_00401340("storage");

    iVar6 = FUN_00404b40(&param_2,0);

    puVar7 = (undefined4 *)(param_2 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      FUN_00401340(&DAT_00795090);

      iVar6 = FUN_00404b40(&param_2,0);

      puVar7 = (undefined4 *)(param_2 + -0x14);

      LVar5 = InterlockedDecrement((LONG *)(param_2 + -0x10));

      if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

      if (iVar6 == 0) {

        uVar8 = 4;

      }

      else {

        FUN_00401340("close");

        iVar6 = FUN_00404b40(&param_2,0);

        FUN_004011b0();

        if (iVar6 != 0) goto LAB_00570010;

        uVar8 = 5;

      }

LAB_0056ff19:

      uVar3 = FUN_006a7bf0(uVar8);

      FUN_004011b0();

      FUN_004011b0();

      return uVar3;

    }

  }

LAB_00570010:

  LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

  }

  LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

  }

  return 0;

}





// --- FUN_0056fd5c at 0x0056FD5C (size: 758) ---


undefined1 FUN_0056fd5c(int param_1,undefined4 param_2,int param_3,int param_4)



{

  int iVar1;

  int iVar2;

  undefined1 uVar3;

  int *piVar4;

  LONG LVar5;

  int iVar6;

  undefined4 *puVar7;

  undefined4 uVar8;

  

  piVar4 = (int *)FUN_0056fc60(&param_1,&param_3,&param_4);

  iVar1 = *piVar4;

  InterlockedIncrement((LONG *)(iVar1 + -0x10));

  puVar7 = (undefined4 *)(param_1 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  piVar4 = (int *)FUN_0056fc60(&param_1,&param_3,&param_4);

  iVar2 = *piVar4;

  param_3 = iVar2;

  InterlockedIncrement((LONG *)(iVar2 + -0x10));

  puVar7 = (undefined4 *)(param_1 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(param_1 + -0x10));

  if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  FUN_00401340("guest");

  iVar6 = FUN_00404b40(&param_4,0);

  puVar7 = (undefined4 *)(param_4 + -0x14);

  LVar5 = InterlockedDecrement((LONG *)(param_4 + -0x10));

  if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

    (**(code **)*puVar7)(1);

  }

  if (iVar6 == 0) {

    FUN_00401340(&DAT_00795090);

    iVar6 = FUN_00404b40(&param_4,0);

    puVar7 = (undefined4 *)(param_4 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_4 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      uVar3 = FUN_006a7bf0(2);

      LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

      if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

      }

      LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

      if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

        (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

      }

      return uVar3;

    }

    FUN_00401340("close");

    iVar6 = FUN_00404b40(&param_4,0);

    puVar7 = (undefined4 *)(param_4 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_4 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      uVar8 = 3;

      goto LAB_0056ff19;

    }

  }

  else {

    FUN_00401340("storage");

    iVar6 = FUN_00404b40(&param_4,0);

    puVar7 = (undefined4 *)(param_4 + -0x14);

    LVar5 = InterlockedDecrement((LONG *)(param_4 + -0x10));

    if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

      (**(code **)*puVar7)(1);

    }

    if (iVar6 == 0) {

      FUN_00401340(&DAT_00795090);

      iVar6 = FUN_00404b40(&param_4,0);

      puVar7 = (undefined4 *)(param_4 + -0x14);

      LVar5 = InterlockedDecrement((LONG *)(param_4 + -0x10));

      if ((LVar5 == 0) && (puVar7 != (undefined4 *)0x0)) {

        (**(code **)*puVar7)(1);

      }

      if (iVar6 == 0) {

        uVar8 = 4;

      }

      else {

        FUN_00401340("close");

        iVar6 = FUN_00404b40(&param_4,0);

        FUN_004011b0();

        if (iVar6 != 0) goto LAB_00570010;

        uVar8 = 5;

      }

LAB_0056ff19:

      uVar3 = FUN_006a7bf0(uVar8);

      FUN_004011b0();

      FUN_004011b0();

      return uVar3;

    }

  }

LAB_00570010:

  LVar5 = InterlockedDecrement((LONG *)(iVar2 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iVar2 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar2 + -0x14))(1);

  }

  LVar5 = InterlockedDecrement((LONG *)(iVar1 + -0x10));

  if ((LVar5 == 0) && ((undefined4 *)(iVar1 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(iVar1 + -0x14))(1);

  }

  return 0;

}





