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

// --- FUN_00590030 at 0x00590030 (size: 30) ---


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



{

  FUN_005d2180();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00590050 at 0x00590050 (size: 93) ---


void __thiscall FUN_00590050(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined **local_8;

  undefined4 local_4;

  

  local_8 = &PTR_FUN_007e5464;

  local_4 = 0;

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

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_00596a80();

    }

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

    if (iVar1 == 0) {

      return;

    }

  }

  FUN_00596790(param_2,&local_8);

  return;

}





// --- FUN_005900b0 at 0x005900B0 (size: 55) ---


undefined4 __thiscall FUN_005900b0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined **local_8;

  undefined4 local_4;

  

  local_8 = &PTR_FUN_007e5464;

  local_4 = 0;

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

    return 0;

  }

  uVar1 = FUN_005967c0(param_2,&local_8);

  return uVar1;

}





// --- FUN_005900f0 at 0x005900F0 (size: 88) ---


void __fastcall FUN_005900f0(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x44);

        FUN_005d2180();

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

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

      uVar3 = uVar3 + 1;

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

  }

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

  return;

}





// --- FUN_00590150 at 0x00590150 (size: 155) ---


undefined4 __thiscall FUN_00590150(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[0x11]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x4c);

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

    return 0;

  }

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

  *puVar1 = *param_2;

  FUN_005d2460(param_3);

  puVar1[0x11] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[0x12] = uVar2;

  puVar1[0x11] = *(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_00590280 at 0x00590280 (size: 91) ---


int __fastcall FUN_00590280(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 + 0x44)) {

        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_005902e0 at 0x005902E0 (size: 99) ---


void __thiscall FUN_005902e0(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = FUN_005df0f5(0x24);

  if (iVar2 == 0) {

    iVar2 = 0;

  }

  else {

    FUN_005cd280(param_2);

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

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

  }

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

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

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

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

    return;

  }

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

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

  *(int *)(iVar2 + 0x20) = iVar1;

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

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

  return;

}





// --- FUN_00590350 at 0x00590350 (size: 73) ---


uint __thiscall FUN_00590350(int param_1,int *param_2,uint param_3)



{

  int *piVar1;

  uint uVar2;

  

  uVar2 = FUN_005903a0();

  if (uVar2 <= param_3) {

    if (3 < param_3) {

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

      *param_2 = *param_2 + 4;

    }

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

      (**(code **)(*piVar1 + 0xc))(param_2,param_3);

    }

  }

  return uVar2;

}





// --- FUN_005903a0 at 0x005903A0 (size: 52) ---


int __fastcall FUN_005903a0(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 local_4;

  

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

  iVar3 = 4;

  local_4 = 0;

  for (; piVar1 != (int *)0x0; piVar1 = (int *)piVar1[7]) {

    iVar2 = (**(code **)(*piVar1 + 0xc))(&local_4,0);

    iVar3 = iVar3 + iVar2;

  }

  return iVar3;

}





// --- FUN_005903e0 at 0x005903E0 (size: 52) ---


void __fastcall FUN_005903e0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5478;

  FUN_005900f0();

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

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

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00590560 at 0x00590560 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007e5478;

  FUN_005900f0();

  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_005905b0 at 0x005905B0 (size: 45) ---


undefined4 * __fastcall FUN_005905b0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e54a0;

  param_1[1] = &PTR_FUN_007e5478;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0x20;

  param_1[5] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_005905e0 at 0x005905E0 (size: 101) ---


void __fastcall FUN_005905e0(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  

  FUN_005cd250();

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

  while (iVar1 != 0) {

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

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

      iVar1 = puVar2[7];

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

      if (iVar1 == 0) {

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

      }

      else {

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

      }

      FUN_005cd210(puVar2);

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

        *puVar2 = &PTR_FUN_0079385c;

        operator_delete(puVar2);

      }

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

    }

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

  }

  return;

}





// --- FUN_00590650 at 0x00590650 (size: 39) ---


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



{

  FUN_005903e0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00590880 at 0x00590880 (size: 123) ---


undefined4 FUN_00590880(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int local_1c [7];

  

  FUN_005905e0();

  if (param_2 < 4) {

    return 0;

  }

  iVar1 = *(int *)*param_1;

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

  FUN_005cd250();

  iVar3 = 0;

  if (0 < iVar1) {

    do {

      iVar2 = (**(code **)(local_1c[0] + 0x10))(param_1,param_2);

      if (iVar2 == 0) {

        return 0;

      }

      FUN_005902e0(local_1c);

      iVar3 = iVar3 + 1;

    } while (iVar3 < iVar1);

  }

  return 1;

}





// --- FUN_00590900 at 0x00590900 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e548c;

  FUN_005905e0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00590930 at 0x00590930 (size: 40) ---


undefined4 * __thiscall FUN_00590930(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007cfc64;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590960 at 0x00590960 (size: 40) ---


undefined4 * __thiscall FUN_00590960(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e54ec;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590990 at 0x00590990 (size: 142) ---


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



{

  uint *puVar1;

  uint *puVar2;

  

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

    puVar1 = (uint *)0x0;

    for (puVar2 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[4]) {

      if (*puVar2 == *param_2) {

        *param_3 = puVar2[2];

        param_3[1] = puVar2[3];

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

          *(uint *)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4) = puVar2[4];

        }

        else {

          puVar1[4] = puVar2[4];

        }

        operator_delete(puVar2);

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

        return 1;

      }

      puVar1 = puVar2;

    }

  }

  return 0;

}





// --- FUN_00590a20 at 0x00590A20 (size: 40) ---


undefined4 * __thiscall FUN_00590a20(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e5500;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590a50 at 0x00590A50 (size: 136) ---


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



{

  uint *puVar1;

  uint *puVar2;

  

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

    puVar1 = (uint *)0x0;

    for (puVar2 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[2]) {

      if (*puVar2 == *param_2) {

        *param_3 = puVar2[1];

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

          *(uint *)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4) = puVar2[2];

        }

        else {

          puVar1[2] = puVar2[2];

        }

        operator_delete(puVar2);

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

        return 1;

      }

      puVar1 = puVar2;

    }

  }

  return 0;

}





// --- FUN_00590ae0 at 0x00590AE0 (size: 40) ---


undefined4 * __thiscall FUN_00590ae0(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e5514;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590b10 at 0x00590B10 (size: 61) ---


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



{

  uint *puVar1;

  

  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[4]) {

      if (*param_2 == *puVar1) {

        return puVar1 + 2;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_00590b50 at 0x00590B50 (size: 40) ---


undefined4 * __thiscall FUN_00590b50(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e5528;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590b80 at 0x00590B80 (size: 40) ---


undefined4 * __thiscall FUN_00590b80(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e553c;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590bb0 at 0x00590BB0 (size: 40) ---


undefined4 * __thiscall FUN_00590bb0(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e5550;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00590be0 at 0x00590BE0 (size: 61) ---


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



{

  uint *puVar1;

  

  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[0x13]) {

      if (*param_2 == *puVar1) {

        return puVar1 + 1;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_00590c20 at 0x00590C20 (size: 73) ---


undefined4 __thiscall

FUN_00590c20(int *param_1,undefined4 param_2,undefined4 *param_3,int param_4,undefined4 param_5)



{

  undefined4 *puVar1;

  

  if (param_1[2] != 0) {

    puVar1 = (undefined4 *)FUN_005d5760(&param_2);

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

      *param_3 = *puVar1;

      if (param_4 == 0) {

        (**(code **)(*param_1 + 4))(param_2,param_3,param_5);

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590c70 at 0x00590C70 (size: 48) ---


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



{

  undefined4 *puVar1;

  

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

    puVar1 = (undefined4 *)FUN_00590b10(&param_2);

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

      *param_3 = *puVar1;

      param_3[1] = puVar1[1];

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590ca0 at 0x00590CA0 (size: 42) ---


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



{

  undefined4 *puVar1;

  

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

    puVar1 = (undefined4 *)FUN_005d5760(&param_2);

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

      *param_3 = *puVar1;

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590cd0 at 0x00590CD0 (size: 74) ---


undefined4 __thiscall FUN_00590cd0(int *param_1,undefined4 param_2,undefined4 *param_3,int param_4)



{

  undefined4 *puVar1;

  

  if (param_1[5] != 0) {

    puVar1 = (undefined4 *)FUN_00590b10(&param_2);

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

      *param_3 = *puVar1;

      param_3[1] = puVar1[1];

      if (param_4 == 0) {

        (**(code **)(*param_1 + 8))(param_2,param_3);

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590d20 at 0x00590D20 (size: 42) ---


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



{

  undefined4 *puVar1;

  

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

    puVar1 = (undefined4 *)FUN_005d5760(&param_2);

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

      *param_3 = *puVar1;

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590d50 at 0x00590D50 (size: 42) ---


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



{

  undefined4 *puVar1;

  

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

    puVar1 = (undefined4 *)FUN_005d5760(&param_2);

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

      *param_3 = *puVar1;

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590d80 at 0x00590D80 (size: 56) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_00590be0(&param_2);

    if (iVar1 != 0) {

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

      FUN_00425f10(iVar1 + 8);

      return 1;

    }

  }

  return 0;

}





// --- FUN_00590dc0 at 0x00590DC0 (size: 157) ---


undefined4 __thiscall FUN_00590dc0(int param_1,uint *param_2,uint *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[4]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x18);

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

    return 0;

  }

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

  *puVar1 = *param_2;

  puVar1[2] = *param_3;

  puVar1[3] = param_3[1];

  puVar1[4] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[5] = uVar2;

  puVar1[4] = *(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_00590ee0 at 0x00590EE0 (size: 257) ---


bool __thiscall FUN_00590ee0(int param_1,int *param_2,uint param_3)



{

  int iVar1;

  undefined4 *puVar2;

  int *piVar3;

  uint uVar4;

  uint uVar5;

  int iVar6;

  uint uVar7;

  uint uVar8;

  undefined4 local_8;

  undefined4 local_4;

  

  uVar4 = param_3;

  piVar3 = param_2;

  if (param_3 < 4) {

    return false;

  }

  iVar1 = *param_2;

  FUN_00590ff0();

  uVar5 = *(uint *)*piVar3;

  *piVar3 = (int)((uint *)*piVar3 + 1);

  uVar7 = uVar5 >> 0x10;

  uVar5 = uVar5 & 0xffff;

  uVar8 = uVar4 - 4;

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

  if (uVar7 == 0) {

    return uVar5 == 0;

  }

  if (((0x10000 < uVar7) || (0x10000 < uVar5)) || (iVar6 = FUN_005a8440(), iVar6 == 0)) {

    return false;

  }

  param_3 = 0;

  if (uVar5 != 0) {

    do {

      if (uVar8 < 4) {

        return false;

      }

      puVar2 = (undefined4 *)*piVar3;

      param_2 = (int *)*puVar2;

      *piVar3 = (int)(puVar2 + 1);

      if (uVar8 < 8) {

        return false;

      }

      local_8 = puVar2[1];

      local_4 = puVar2[2];

      *piVar3 = (int)(puVar2 + 3);

      iVar6 = FUN_00590dc0(&param_2,&local_8);

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

        return false;

      }

      param_3 = param_3 + 1;

    } while (param_3 < uVar5);

  }

  return (uint)(*piVar3 - iVar1) <= uVar4;

}





// --- FUN_00590ff0 at 0x00590FF0 (size: 40) ---


void __fastcall FUN_00590ff0(int param_1)



{

  FUN_005911e0();

  if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

  }

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

  return;

}





// --- FUN_005910a0 at 0x005910A0 (size: 40) ---


int __fastcall FUN_005910a0(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 + 0x10)) {

        iVar2 = iVar2 + 0xc;

      }

      piVar4 = piVar4 + 1;

      iVar3 = iVar3 + -1;

    } while (iVar3 != 0);

  }

  return iVar2;

}





// --- FUN_005910d0 at 0x005910D0 (size: 264) ---


ushort __thiscall FUN_005910d0(int param_1,int *param_2,uint param_3)



{

  uint uVar1;

  undefined4 *puVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  uint local_24;

  undefined4 local_1c;

  int local_18;

  uint local_14;

  undefined4 local_10;

  undefined4 local_c;

  

  if (3 < param_3) {

    local_18 = *param_2;

    local_14 = param_3;

    FUN_00590ff0();

    uVar1 = *(uint *)*param_2;

    *param_2 = (int)((uint *)*param_2 + 1);

    uVar5 = uVar1 >> 0x10;

    uVar3 = uVar1 & 0xffff;

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

    if (uVar5 == 0) {

      return CONCAT11((char)(uVar1 >> 0x18),uVar3 == 0);

    }

    if (((uVar5 < 0x10001) && (uVar3 < 0x10001)) && (iVar4 = FUN_005a8440(), iVar4 != 0)) {

      local_24 = 0;

      if (uVar3 != 0) {

        do {

          if (param_3 - 4 < 4) {

            return 0;

          }

          puVar2 = (undefined4 *)*param_2;

          local_1c = *puVar2;

          *param_2 = (int)(puVar2 + 1);

          if (param_3 - 4 < 8) {

            return 0;

          }

          local_10 = puVar2[1];

          local_c = puVar2[2];

          *param_2 = (int)(puVar2 + 3);

          iVar4 = FUN_00590dc0(&local_1c,&local_10);

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

            return 0;

          }

          local_24 = local_24 + 1;

        } while (local_24 < uVar3);

      }

      return (ushort)((uint)(*param_2 - local_18) <= local_14);

    }

  }

  return 0;

}





// --- FUN_005911e0 at 0x005911E0 (size: 79) ---


void __fastcall FUN_005911e0(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x10);

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

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

      uVar3 = uVar3 + 1;

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

  }

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

  return;

}





// --- FUN_005912c0 at 0x005912C0 (size: 91) ---


int __fastcall FUN_005912c0(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 + 0x4c)) {

        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_00591320 at 0x00591320 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e54ec;

  FUN_00590ff0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00591350 at 0x00591350 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e5500;

  FUN_0052fcf0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00591380 at 0x00591380 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e5514;

  FUN_00590ff0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005913b0 at 0x005913B0 (size: 66) ---


uint * __thiscall FUN_005913b0(uint *param_1,uint *param_2,int param_3,uint param_4)



{

  *param_1 = *param_2;

  param_1[1] = (uint)&PTR_LAB_00797910;

  param_1[2] = *(uint *)(param_3 + 4);

  FUN_00425f10(param_3 + 8);

  param_1[0x13] = 0;

  param_1[0x14] = *param_2 % param_4;

  return param_1;

}





// --- FUN_00591400 at 0x00591400 (size: 41) ---


undefined4 __thiscall FUN_00591400(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int local_4;

  

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

    local_4 = param_1;

    uVar1 = FUN_00590a50(&param_2,&local_4);

    return uVar1;

  }

  return 0;

}





// --- FUN_00591430 at 0x00591430 (size: 205) ---


undefined4 __thiscall FUN_00591430(int param_1,uint param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007cfc64;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x40;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 8) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[2];

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

        uVar4 = FUN_0052dfd0(&param_2,&param_3);

        return uVar4;

      }

    }

    if (puVar5 + 1 != (uint *)0x0) {

      puVar5[1] = param_3;

      return 1;

    }

  }

  uVar4 = FUN_0052dfd0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_00591500 at 0x00591500 (size: 47) ---


undefined4 __thiscall FUN_00591500(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined1 local_8 [8];

  

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

    uVar1 = FUN_00590990(&param_2,local_8);

    return uVar1;

  }

  return 0;

}





// --- FUN_00591530 at 0x00591530 (size: 212) ---


undefined4 __thiscall FUN_00591530(int param_1,uint param_2,uint param_3,uint param_4)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e54ec;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x40;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0xc) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[4];

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

        uVar4 = FUN_00590dc0(&param_2,&param_3);

        return uVar4;

      }

    }

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

      puVar5[2] = param_3;

      puVar5[3] = param_4;

      return 1;

    }

  }

  uVar4 = FUN_00590dc0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_00591610 at 0x00591610 (size: 41) ---


undefined4 __thiscall FUN_00591610(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int local_4;

  

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

    local_4 = param_1;

    uVar1 = FUN_00590a50(&param_2,&local_4);

    return uVar1;

  }

  return 0;

}





// --- FUN_00591640 at 0x00591640 (size: 205) ---


undefined4 __thiscall FUN_00591640(int param_1,uint param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e5500;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x20;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x10) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[2];

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

        uVar4 = FUN_0052dfd0(&param_2,&param_3);

        return uVar4;

      }

    }

    if (puVar5 + 1 != (uint *)0x0) {

      puVar5[1] = param_3;

      return 1;

    }

  }

  uVar4 = FUN_0052dfd0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_00591710 at 0x00591710 (size: 47) ---


undefined4 __thiscall FUN_00591710(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined1 local_8 [8];

  

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

    uVar1 = FUN_00590990(&param_2,local_8);

    return uVar1;

  }

  return 0;

}





// --- FUN_00591740 at 0x00591740 (size: 212) ---


undefined4 __thiscall FUN_00591740(int param_1,uint param_2,uint param_3,uint param_4)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e5514;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x20;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x14) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[4];

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

        uVar4 = FUN_00590dc0(&param_2,&param_3);

        return uVar4;

      }

    }

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

      puVar5[2] = param_3;

      puVar5[3] = param_4;

      return 1;

    }

  }

  uVar4 = FUN_00590dc0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_00591820 at 0x00591820 (size: 205) ---


undefined4 __thiscall FUN_00591820(int param_1,uint param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e5528;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x20;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x1c) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[2];

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

        uVar4 = FUN_0052dfd0(&param_2,&param_3);

        return uVar4;

      }

    }

    if (puVar5 + 1 != (uint *)0x0) {

      puVar5[1] = param_3;

      return 1;

    }

  }

  uVar4 = FUN_0052dfd0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_005918f0 at 0x005918F0 (size: 41) ---


undefined4 __thiscall FUN_005918f0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int local_4;

  

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

    local_4 = param_1;

    uVar1 = FUN_00590a50(&param_2,&local_4);

    return uVar1;

  }

  return 0;

}





// --- FUN_00591920 at 0x00591920 (size: 205) ---


undefined4 __thiscall FUN_00591920(int param_1,uint param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007c9ca8;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x20;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x20) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[2];

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

        uVar4 = FUN_0052dfd0(&param_2,&param_3);

        return uVar4;

      }

    }

    if (puVar5 + 1 != (uint *)0x0) {

      puVar5[1] = param_3;

      return 1;

    }

  }

  uVar4 = FUN_0052dfd0(&param_2,&param_3);

  return uVar4;

}





// --- FUN_005919f0 at 0x005919F0 (size: 95) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  int *piVar3;

  int *piVar4;

  LONG LVar5;

  

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

    piVar4 = (int *)FUN_005d5760(&param_2);

    piVar3 = param_3;

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

      puVar1 = (undefined4 *)*param_3;

      if (puVar1 != (undefined4 *)*piVar4) {

        LVar5 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        iVar2 = *piVar4;

        *piVar3 = iVar2;

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

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00591ae0 at 0x00591AE0 (size: 161) ---


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



{

  uint uVar1;

  uint *puVar2;

  uint uVar3;

  

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

    for (puVar2 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[2]) {

      if (*param_2 == *puVar2) {

        if (puVar2 != (uint *)0xfffffffc) {

          return 0;

        }

        break;

      }

    }

  }

  puVar2 = (uint *)FUN_005df0f5(0x10);

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

    return 0;

  }

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

  *puVar2 = *param_2;

  uVar1 = *param_3;

  puVar2[1] = uVar1;

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

  puVar2[2] = 0;

  uVar3 = *param_2 % uVar3;

  puVar2[3] = uVar3;

  puVar2[2] = *(uint *)(*(int *)(param_1 + 8) + uVar3 * 4);

  *(uint **)(*(int *)(param_1 + 8) + uVar3 * 4) = puVar2;

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

  return 1;

}





// --- FUN_00591b90 at 0x00591B90 (size: 141) ---


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



{

  uint *puVar1;

  int iVar2;

  

  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[0x13]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  iVar2 = FUN_005df0f5(0x54);

  if ((iVar2 != 0) &&

     (iVar2 = FUN_005913b0(param_2,param_3,*(undefined4 *)(param_1 + 0xc)), iVar2 != 0)) {

    *(undefined4 *)(iVar2 + 0x4c) =

         *(undefined4 *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x50) * 4);

    *(int *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x50) * 4) = iVar2;

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

    return 1;

  }

  return 0;

}





// --- FUN_00591c20 at 0x00591C20 (size: 156) ---


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



{

  uint *puVar1;

  uint *puVar2;

  

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

    puVar1 = (uint *)0x0;

    for (puVar2 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[0x13]) {

      if (*puVar2 == *param_2) {

        *(uint *)(param_3 + 4) = puVar2[2];

        FUN_00425f10(puVar2 + 3);

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

          *(uint *)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4) =

               puVar2[0x13];

        }

        else {

          puVar1[0x13] = puVar2[0x13];

        }

        puVar2[1] = (uint)&PTR_FUN_0079385c;

        operator_delete(puVar2);

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

        return 1;

      }

      puVar1 = puVar2;

    }

  }

  return 0;

}





// --- FUN_00591cc0 at 0x00591CC0 (size: 211) ---


undefined4 __thiscall FUN_00591cc0(int param_1,uint param_2,undefined4 param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e553c;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x10;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x18) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[2];

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

        uVar4 = FUN_00591ae0(&param_2,param_3);

        return uVar4;

      }

    }

    if (puVar5 != (uint *)0xfffffffc) {

      FUN_0048a0a0(param_3);

      return 1;

    }

  }

  uVar4 = FUN_00591ae0(&param_2,param_3);

  return uVar4;

}





// --- FUN_00591da0 at 0x00591DA0 (size: 221) ---


undefined4 __thiscall FUN_00591da0(int param_1,uint param_2,int param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e5550;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x10;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 0x24) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[0x13];

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

        uVar4 = FUN_00591b90(&param_2,param_3);

        return uVar4;

      }

    }

    if (puVar5 != (uint *)0xfffffffc) {

      puVar5[2] = *(uint *)(param_3 + 4);

      FUN_00425f10(param_3 + 8);

      return 1;

    }

  }

  uVar4 = FUN_00591b90(&param_2,param_3);

  return uVar4;

}





// --- FUN_00591e80 at 0x00591E80 (size: 245) ---


bool __thiscall FUN_00591e80(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_0052fcf0();

  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_00591f80 at 0x00591F80 (size: 160) ---


undefined4 __thiscall FUN_00591f80(int param_1,uint *param_2)



{

  undefined4 *puVar1;

  uint *puVar2;

  uint *puVar3;

  LONG LVar4;

  

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

    puVar2 = (uint *)0x0;

    for (puVar3 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar3 != (uint *)0x0; puVar3 = (uint *)puVar3[2]) {

      if (*puVar3 == *param_2) {

        FUN_0048a0a0(puVar3 + 1);

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

          *(uint *)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4) = puVar3[2];

        }

        else {

          puVar2[2] = puVar3[2];

        }

        puVar1 = (undefined4 *)puVar3[1];

        LVar4 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        operator_delete(puVar3);

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

        return 1;

      }

      puVar2 = puVar3;

    }

  }

  return 0;

}





// --- FUN_00592020 at 0x00592020 (size: 263) ---


bool __thiscall FUN_00592020(int param_1,int *param_2,uint param_3)



{

  int iVar1;

  int *piVar2;

  uint uVar3;

  uint uVar4;

  int iVar5;

  uint uVar6;

  uint uVar7;

  int local_48 [18];

  

  uVar3 = param_3;

  piVar2 = param_2;

  if (param_3 < 4) {

    return false;

  }

  iVar1 = *param_2;

  FUN_00592130();

  uVar4 = *(uint *)*piVar2;

  *piVar2 = (int)((uint *)*piVar2 + 1);

  uVar6 = uVar4 >> 0x10;

  uVar4 = uVar4 & 0xffff;

  uVar7 = uVar3 - 4;

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

  if (uVar6 == 0) {

    return uVar4 == 0;

  }

  if (((0x10000 < uVar6) || (0x10000 < uVar4)) || (iVar5 = FUN_005a8440(), iVar5 == 0)) {

    return false;

  }

  FUN_00424d10();

  param_3 = 0;

  if (uVar4 != 0) {

    do {

      if (uVar7 < 4) {

        return false;

      }

      param_2 = *(int **)*piVar2;

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

      iVar5 = (**(code **)(local_48[0] + 0x10))(piVar2,uVar7);

      if (iVar5 == 0) {

        return false;

      }

      iVar5 = FUN_00591b90(&param_2,local_48);

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

        return false;

      }

      param_3 = param_3 + 1;

    } while (param_3 < uVar4);

  }

  return (uint)(*piVar2 - iVar1) <= uVar3;

}





// --- FUN_00592130 at 0x00592130 (size: 40) ---


void __fastcall FUN_00592130(int param_1)



{

  FUN_00592160();

  if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

  }

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

  return;

}





// --- FUN_00592160 at 0x00592160 (size: 86) ---


void __fastcall FUN_00592160(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x4c);

        *(undefined ***)((int)pvVar2 + 4) = &PTR_FUN_0079385c;

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

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

      uVar3 = uVar3 + 1;

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

  }

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

  return;

}





// --- FUN_005921c0 at 0x005921C0 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e5528;

  FUN_0052fcf0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005921f0 at 0x005921F0 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e5550;

  FUN_00592130();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00592220 at 0x00592220 (size: 41) ---


undefined4 __thiscall FUN_00592220(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int local_4;

  

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

    local_4 = param_1;

    uVar1 = FUN_00590a50(&param_2,&local_4);

    return uVar1;

  }

  return 0;

}





// --- FUN_00592250 at 0x00592250 (size: 132) ---


undefined4 __thiscall FUN_00592250(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined **local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_48 = &PTR_LAB_00797910;

  local_44 = 0;

  local_40 = 0x3f800000;

  local_3c = 0;

  local_38 = 0;

  local_34 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  FUN_00535b30();

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

    uVar1 = FUN_00591c20(&param_2,&local_48);

    return uVar1;

  }

  return 0;

}





// --- FUN_00592370 at 0x00592370 (size: 90) ---


int __fastcall FUN_00592370(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 + 8)) {

        iVar2 = FUN_004fd290(&local_4,0);

        iVar4 = iVar4 + 4 + iVar2;

      }

      uVar3 = uVar3 + 1;

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

  }

  return iVar4;

}





// --- FUN_005923d0 at 0x005923D0 (size: 295) ---


bool __thiscall FUN_005923d0(int param_1,int *param_2,uint param_3)



{

  int *piVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  undefined4 local_c;

  int local_8;

  uint local_4;

  

  uVar2 = param_3;

  piVar1 = param_2;

  if (param_3 < 4) {

    return false;

  }

  local_8 = *param_2;

  local_4 = param_3;

  FUN_00592500();

  uVar3 = *(uint *)*param_2;

  *param_2 = (int)((uint *)*param_2 + 1);

  uVar5 = uVar3 >> 0x10;

  uVar3 = uVar3 & 0xffff;

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

  if (uVar5 == 0) {

    return uVar3 == 0;

  }

  if (((uVar5 < 0x10001) && (uVar3 < 0x10001)) && (iVar4 = FUN_005a8440(), iVar4 != 0)) {

    FUN_00411850();

    param_2 = (int *)0x0;

    if (uVar3 != 0) {

      do {

        if (uVar2 - 4 < 4) goto LAB_005924e6;

        local_c = *(undefined4 *)*piVar1;

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

        iVar4 = FUN_004fd460(piVar1,uVar2 - 4);

        if ((iVar4 == 0) ||

           ((iVar4 = FUN_00591ae0(&local_c,&param_3), iVar4 == 0 && (*(int *)(param_1 + 4) == 0))))

        goto LAB_005924e6;

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

      } while (param_2 < uVar3);

    }

    if ((uint)(*piVar1 - local_8) <= local_4) {

      FUN_005abb30();

      return true;

    }

LAB_005924e6:

    FUN_005abb30();

  }

  return false;

}





// --- FUN_00592500 at 0x00592500 (size: 40) ---


void __fastcall FUN_00592500(int param_1)



{

  FUN_00592530();

  if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

  }

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

  return;

}





// --- FUN_00592530 at 0x00592530 (size: 131) ---


void __fastcall FUN_00592530(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 + 4);

        pvVar2 = *(void **)((int)pvVar3 + 8);

        LVar4 = InterlockedDecrement(puVar1 + 1);

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

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

        }

        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_005925c0 at 0x005925C0 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e553c;

  FUN_00592500();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005925f0 at 0x005925F0 (size: 99) ---


undefined4 __thiscall FUN_005925f0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  LONG LVar2;

  undefined4 *puVar3;

  undefined4 *local_4;

  

  puVar3 = DAT_008ef11c;

  local_4 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

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

    uVar1 = 0;

  }

  else {

    uVar1 = FUN_00591f80(&param_2,&local_4);

    puVar3 = local_4;

  }

  LVar2 = InterlockedDecrement(puVar3 + 1);

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

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

  }

  return uVar1;

}





// --- FUN_00592660 at 0x00592660 (size: 111) ---


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



undefined4 __thiscall FUN_00592660(int param_1,int param_2,int param_3,undefined4 *param_4)



{

  int iVar1;

  float fVar2;

  float fVar3;

  undefined4 uVar4;

  int iVar5;

  

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

  if (iVar1 == 0) {

    return 0;

  }

  iVar5 = *(int *)(param_1 + 8) * param_2 + *(int *)(param_1 + 0xc) * param_3 +

          *(int *)(param_1 + 4);

  fVar2 = (float)iVar5;

  if (iVar5 < 0) {

    fVar2 = fVar2 + _DAT_0079920c;

  }

  fVar3 = (float)iVar1;

  if (iVar1 < 0) {

    fVar3 = fVar3 + _DAT_0079920c;

  }

  floor((double)(fVar2 / fVar3 + _DAT_007938b8));

  uVar4 = FUN_005df4c4();

  *param_4 = uVar4;

  return 1;

}





// --- FUN_005926d0 at 0x005926D0 (size: 39) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_005cd620(param_2,param_3);

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592700 at 0x00592700 (size: 67) ---


undefined4 __thiscall FUN_00592700(int param_1,undefined4 param_2,undefined4 param_3,int param_4)



{

  int iVar1;

  

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

    iVar1 = FUN_005cd430(param_2,param_3);

    if (iVar1 != 0) {

      if (param_4 == 0) {

        FUN_0058fea0(param_2,param_3);

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592750 at 0x00592750 (size: 68) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_005df0f5(0x28);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_005cd5f0();

    }

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

    if (iVar1 == 0) {

      return;

    }

  }

  FUN_005cd690(param_2,param_3);

  return;

}





// --- FUN_005927a0 at 0x005927A0 (size: 68) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_005df0f5(0x28);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_005cd5f0();

    }

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

    if (iVar1 == 0) {

      return;

    }

  }

  FUN_005cd860(param_2,param_3);

  return;

}





// --- FUN_005927f0 at 0x005927F0 (size: 39) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_005cda20(param_2,param_3);

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592950 at 0x00592950 (size: 40) ---


undefined4 * __thiscall FUN_00592950(undefined4 *param_1,undefined4 param_2)



{

  param_1[3] = param_2;

  *param_1 = &PTR_FUN_007e559c;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00592980 at 0x00592980 (size: 61) ---


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



{

  uint *puVar1;

  

  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[10]) {

      if (*param_2 == *puVar1) {

        return puVar1 + 2;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_005929c0 at 0x005929C0 (size: 86) ---


uint * __thiscall FUN_005929c0(uint *param_1,uint *param_2,int param_3,uint param_4)



{

  *param_1 = *param_2;

  param_1[2] = (uint)&PTR_FUN_007a8458;

  param_1[3] = *(uint *)(param_3 + 4);

  param_1[4] = *(uint *)(param_3 + 8);

  param_1[5] = *(uint *)(param_3 + 0xc);

  param_1[6] = *(uint *)(param_3 + 0x10);

  param_1[7] = *(uint *)(param_3 + 0x14);

  param_1[8] = *(uint *)(param_3 + 0x18);

  param_1[9] = *(uint *)(param_3 + 0x1c);

  param_1[10] = 0;

  param_1[0xb] = *param_2 % param_4;

  return param_1;

}





// --- FUN_00592a20 at 0x00592A20 (size: 198) ---


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



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  int *piVar4;

  undefined4 local_8;

  undefined4 local_4;

  

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

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

    return 0;

  }

  if (param_1 == 1) {

    piVar4 = piVar2 + 0xe;

  }

  else if (param_1 == 3) {

    piVar4 = piVar2 + 0x16;

  }

  else {

    if (param_1 != 5) goto LAB_00592a6d;

    piVar4 = piVar2 + 0x1e;

  }

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

    local_4 = 0;

    local_8 = 0;

    iVar1 = piVar4[7];

    if (piVar4[6] != 0) {

      FUN_00592700(piVar4[6],&local_4,param_3);

    }

    if (iVar1 != 0) {

      FUN_00592700(iVar1,&local_8,param_3);

    }

    uVar3 = FUN_00592660(local_4,local_8,param_2);

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

    return uVar3;

  }

LAB_00592a6d:

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

  return 0;

}





// --- FUN_00592af0 at 0x00592AF0 (size: 80) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_00592980(&param_2);

    if (iVar1 != 0) {

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

      *(undefined4 *)(param_3 + 8) = *(undefined4 *)(iVar1 + 8);

      *(undefined4 *)(param_3 + 0xc) = *(undefined4 *)(iVar1 + 0xc);

      *(undefined4 *)(param_3 + 0x10) = *(undefined4 *)(iVar1 + 0x10);

      *(undefined4 *)(param_3 + 0x14) = *(undefined4 *)(iVar1 + 0x14);

      *(undefined4 *)(param_3 + 0x18) = *(undefined4 *)(iVar1 + 0x18);

      *(undefined4 *)(param_3 + 0x1c) = *(undefined4 *)(iVar1 + 0x1c);

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592b40 at 0x00592B40 (size: 48) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_00592980(&param_2);

    if (iVar1 != 0) {

      *param_3 = *(int *)(iVar1 + 0x10) + *(int *)(iVar1 + 0xc);

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592b70 at 0x00592B70 (size: 43) ---


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



{

  int iVar1;

  

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

    iVar1 = FUN_00592980(&param_2);

    if (iVar1 != 0) {

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

      return 1;

    }

  }

  return 0;

}





// --- FUN_00592ba0 at 0x00592BA0 (size: 141) ---


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



{

  uint *puVar1;

  int iVar2;

  

  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[10]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  iVar2 = FUN_005df0f5(0x30);

  if ((iVar2 != 0) &&

     (iVar2 = FUN_005929c0(param_2,param_3,*(undefined4 *)(param_1 + 0xc)), iVar2 != 0)) {

    *(undefined4 *)(iVar2 + 0x28) =

         *(undefined4 *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x2c) * 4);

    *(int *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x2c) * 4) = iVar2;

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

    return 1;

  }

  return 0;

}





// --- FUN_00592cc0 at 0x00592CC0 (size: 91) ---


int __fastcall FUN_00592cc0(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 + 0x28)) {

        iVar2 = (**(code **)(*(int *)(iVar1 + 8) + 0xc))(&local_4,0);

        iVar4 = iVar4 + 4 + iVar2;

      }

      uVar3 = uVar3 + 1;

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

  }

  return iVar4;

}





// --- FUN_00592d20 at 0x00592D20 (size: 222) ---


undefined4 __thiscall FUN_00592d20(int param_1,int param_2,int *param_3,int param_4)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  int local_4;

  

  iVar1 = param_2;

  local_4 = 0;

  if ((((param_2 == 1) || (param_2 == 3)) || (param_2 == 5)) &&

     (iVar3 = FUN_00592a20(param_2,&local_4,param_4), iVar3 == 0)) {

    return 0;

  }

  iVar3 = local_4;

  if (iVar1 == 1) {

    param_2 = 0;

    iVar4 = FUN_00590c20(0x17b,&param_2,0,0);

    if (iVar4 != 0) {

      iVar3 = iVar3 + param_2;

    }

    local_4 = 0;

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

    if (0 < local_4) {

      iVar3 = iVar3 + local_4 * 2;

    }

  }

  piVar2 = param_3;

  if ((*(int *)(param_1 + 0x60) == 0) || (iVar4 = FUN_005cd520(iVar1,param_3), iVar4 == 0)) {

    if (iVar3 == 0) {

      return 0;

    }

    *piVar2 = iVar3;

  }

  else {

    *piVar2 = *piVar2 + iVar3;

  }

  if (param_4 == 0) {

    FUN_0058fec0(iVar1,piVar2);

  }

  return 1;

}





// --- FUN_00592e00 at 0x00592E00 (size: 95) ---


undefined4 FUN_00592e00(int param_1,uint *param_2,uint *param_3)



{

  int iVar1;

  

  if (((param_1 != 2) && (param_1 != 4)) && (param_1 != 6)) {

    return 1;

  }

  if ((int)*param_2 < 0) {

    *param_2 = 0;

    return 1;

  }

  iVar1 = FUN_00592d20(param_1 + -1,param_3,0);

  if (iVar1 == 0) {

    return 0;

  }

  if (*param_3 < *param_2) {

    *param_2 = *param_3;

  }

  return 1;

}





// --- FUN_00592e60 at 0x00592E60 (size: 252) ---


undefined4 __thiscall

FUN_00592e60(int param_1,undefined4 param_2,undefined4 *param_3,undefined4 param_4)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  int iVar5;

  undefined4 local_8;

  undefined4 local_4;

  

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

  uVar4 = param_2;

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

    return 0;

  }

  iVar2 = FUN_0049b8b0(param_2);

  if (iVar2 == 0) {

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

    return 0;

  }

  iVar5 = 1;

  param_2 = uVar4;

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

    iVar3 = FUN_00592980(&param_2);

    if (iVar3 != 0) {

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

    }

  }

  uVar4 = param_4;

  if (iVar5 < *(int *)(iVar2 + 0x20)) {

    *param_3 = 0;

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

    return 1;

  }

  local_4 = 0;

  local_8 = 0;

  iVar5 = *(int *)(iVar2 + 0x3c);

  if (*(int *)(iVar2 + 0x38) != 0) {

    FUN_00592700(*(int *)(iVar2 + 0x38),&local_4,param_4);

  }

  if (iVar5 != 0) {

    FUN_00592700(iVar5,&local_8,uVar4);

  }

  uVar4 = FUN_00592660(local_4,local_8,param_3);

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

  return uVar4;

}





// --- FUN_00592f60 at 0x00592F60 (size: 245) ---


undefined4 __thiscall FUN_00592f60(int param_1,uint param_2,int param_3)



{

  uint uVar1;

  int iVar2;

  undefined4 *puVar3;

  undefined4 uVar4;

  uint *puVar5;

  

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

    puVar3 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar3 = (undefined4 *)0x0;

    }

    else {

      *puVar3 = &PTR_FUN_007e559c;

      puVar3[1] = 0;

      puVar3[2] = 0;

      puVar3[3] = 0x20;

      puVar3[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if (((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 100) + 8), iVar2 != 0)) &&

     (puVar5 = *(uint **)(iVar2 + (param_2 % uVar1) * 4), puVar5 != (uint *)0x0)) {

    while (param_2 != *puVar5) {

      puVar5 = (uint *)puVar5[10];

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

        uVar4 = FUN_00592ba0(&param_2,param_3);

        return uVar4;

      }

    }

    if (puVar5 != (uint *)0xfffffff8) {

      puVar5[3] = *(uint *)(param_3 + 4);

      puVar5[4] = *(uint *)(param_3 + 8);

      puVar5[5] = *(uint *)(param_3 + 0xc);

      puVar5[6] = *(uint *)(param_3 + 0x10);

      puVar5[7] = *(uint *)(param_3 + 0x14);

      puVar5[8] = *(uint *)(param_3 + 0x18);

      puVar5[9] = *(uint *)(param_3 + 0x1c);

      return 1;

    }

  }

  uVar4 = FUN_00592ba0(&param_2,param_3);

  return uVar4;

}





// --- FUN_00593060 at 0x00593060 (size: 234) ---


undefined4 __thiscall FUN_00593060(int param_1,uint param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined **local_20;

  undefined4 local_1c;

  undefined4 local_18;

  uint local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

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

    puVar4 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar4 = (undefined4 *)0x0;

    }

    else {

      *puVar4 = &PTR_FUN_007e559c;

      puVar4[1] = 0;

      puVar4[2] = 0;

      puVar4[3] = 0x20;

      puVar4[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if ((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 100) + 8), iVar2 != 0)) {

    for (puVar3 = *(uint **)(iVar2 + (param_2 % uVar1) * 4); puVar3 != (uint *)0x0;

        puVar3 = (uint *)puVar3[10]) {

      if (param_2 == *puVar3) {

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

          puVar3[5] = param_3;

          return 1;

        }

        break;

      }

    }

  }

  local_14 = param_3;

  local_20 = &PTR_FUN_007a8458;

  local_1c = 0;

  local_18 = 0;

  local_10 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  uVar5 = FUN_00592ba0(&param_2,&local_20);

  return uVar5;

}





// --- FUN_00593150 at 0x00593150 (size: 250) ---


undefined4 __thiscall FUN_00593150(int param_1,uint param_2,undefined4 param_3)



{

  uint uVar1;

  int iVar2;

  uint *puVar3;

  undefined4 *puVar4;

  undefined4 uVar5;

  undefined **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_1 + 100) == 0) {

    puVar4 = (undefined4 *)FUN_005df0f5(0x14);

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

      puVar4 = (undefined4 *)0x0;

    }

    else {

      *puVar4 = &PTR_FUN_007e559c;

      puVar4[1] = 0;

      puVar4[2] = 0;

      puVar4[3] = 0x20;

      puVar4[4] = 0;

      FUN_005a8440();

    }

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

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

      return 0;

    }

  }

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

  if ((uVar1 != 0) && (iVar2 = *(int *)(*(int *)(param_1 + 100) + 8), iVar2 != 0)) {

    for (puVar3 = *(uint **)(iVar2 + (param_2 % uVar1) * 4); puVar3 != (uint *)0x0;

        puVar3 = (uint *)puVar3[10]) {

      if (param_2 == *puVar3) {

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

          FUN_005cb8b0(param_3);

          return 1;

        }

        break;

      }

    }

  }

  local_20 = &PTR_FUN_007a8458;

  local_1c = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  FUN_005cb8b0(param_3);

  uVar5 = FUN_00592ba0(&param_2,&local_20);

  return uVar5;

}





// --- FUN_00593250 at 0x00593250 (size: 188) ---


undefined4 __thiscall FUN_00593250(int param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined4 uVar2;

  undefined **local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  uint local_4;

  

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

    iVar1 = FUN_005df0f5(0x28);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_005cd5f0();

    }

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

    if (iVar1 == 0) {

      return 0;

    }

  }

  local_10 = *(undefined4 *)(param_3 + 4);

  local_c = *(undefined4 *)(param_3 + 8);

  local_8 = *(undefined4 *)(param_3 + 0xc);

  local_4 = *(uint *)(param_3 + 0x10);

  local_14 = &PTR_FUN_007a8b80;

  if (((param_2 == 2) || (param_2 == 4)) || (param_2 == 6)) {

    param_3 = 0;

    iVar1 = FUN_00592d20(param_2 + -1,&param_3,0);

    if (iVar1 == 0) {

      return 0;

    }

    if (param_3 < local_4) {

      local_4 = param_3;

    }

  }

  uVar2 = FUN_005cda90(param_2,&local_14);

  return uVar2;

}





// --- FUN_00593310 at 0x00593310 (size: 104) ---


void __thiscall

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

            undefined4 param_5)



{

  int iVar1;

  

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

    iVar1 = FUN_005df0f5(0x28);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_005cd5f0();

    }

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

    if (iVar1 == 0) {

      return;

    }

  }

  *param_4 = param_3;

  iVar1 = FUN_00592e00(param_2,param_4,param_5);

  if (iVar1 == 0) {

    return;

  }

  FUN_005cdba0(param_2,*param_4);

  return;

}





// --- FUN_00593380 at 0x00593380 (size: 446) ---


undefined4 __thiscall FUN_00593380(int param_1,int param_2,int *param_3,int param_4)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  int local_c;

  int local_8;

  int local_4;

  

  piVar1 = param_3;

  iVar3 = param_2;

  iVar2 = FUN_00592e60(param_2,param_3,param_4);

  if (iVar2 == 0) {

    return 0;

  }

  local_8 = iVar3;

  if ((*(int *)(param_1 + 100) != 0) && (iVar2 = FUN_00592980(&local_8), iVar2 != 0)) {

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

  }

  local_c = 0;

  iVar2 = FUN_00590c20(0x16d,&local_c,0,0);

  if ((iVar2 != 0) && (0 < local_c)) {

    *piVar1 = *piVar1 + local_c;

  }

  param_3 = (int *)0x0;

  switch(iVar3) {

  case 0x1f:

  case 0x20:

  case 0x21:

  case 0x22:

  case 0x2b:

    uVar4 = 0x12e;

    break;

  default:

    goto switchD_00593416_caseD_23;

  case 0x29:

  case 0x2c:

  case 0x2d:

  case 0x2e:

  case 0x31:

    uVar4 = 300;

    break;

  case 0x2f:

    uVar4 = 0x12d;

  }

  FUN_00590c20(uVar4,&param_3,0,0);

  if (0 < (int)param_3) {

    *piVar1 = *piVar1 + 10;

  }

switchD_00593416_caseD_23:

  param_2 = 0;

  FUN_00590c20(0x186,&param_2,0,0);

  if ((((0 < param_2) && (local_8 = iVar3, *(int *)(param_1 + 100) != 0)) &&

      (iVar2 = FUN_00592980(&local_8), iVar2 != 0)) && (*(int *)(iVar2 + 4) != 1)) {

    *piVar1 = *piVar1 + param_2;

  }

  if (param_4 == 0) {

    param_4 = 0;

    local_8 = 0;

    FUN_0058fee0(iVar3,piVar1);

    iVar2 = FUN_00590c20(0x146,&param_4,0,0);

    if ((iVar2 != 0) && (0 < param_4)) {

      *piVar1 = *piVar1 + 5;

    }

    FUN_00590c20(0x158,&local_8,0,0);

    iVar2 = local_8;

    if (((0 < local_8) && (local_4 = iVar3, *(int *)(param_1 + 100) != 0)) &&

       ((iVar3 = FUN_00592980(&local_4), iVar3 != 0 && (*(int *)(iVar3 + 4) == 3)))) {

      *piVar1 = *piVar1 + iVar2 * 2;

    }

  }

  return 1;

}





// --- FUN_00593a30 at 0x00593A30 (size: 40) ---


void __fastcall FUN_00593a30(int param_1)



{

  FUN_00593a60();

  if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

  }

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

  return;

}





// --- FUN_00593a60 at 0x00593A60 (size: 86) ---


void __fastcall FUN_00593a60(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x28);

        *(undefined ***)((int)pvVar2 + 8) = &PTR_FUN_0079385c;

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

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

      uVar3 = uVar3 + 1;

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

  }

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

  return;

}





// --- FUN_00593ac0 at 0x00593AC0 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e559c;

  FUN_00593a30();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00593af0 at 0x00593AF0 (size: 28) ---


void FUN_00593af0(undefined4 param_1,undefined4 param_2)



{

  FUN_00593310(param_1,param_2,&param_1,&param_2);

  return;

}





// --- FUN_00593b10 at 0x00593B10 (size: 225) ---


void __fastcall FUN_00593b10(int param_1)



{

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

  return;

}





// --- FUN_00593c20 at 0x00593C20 (size: 154) ---


void __thiscall FUN_00593c20(int param_1,uint *param_2)



{

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

    *param_2 = *param_2 | 1;

  }

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

    *param_2 = *param_2 | 2;

  }

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

    *param_2 = *param_2 | 4;

  }

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

    *param_2 = *param_2 | 0x100;

  }

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

    *param_2 = *param_2 | 0x200;

  }

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

    *param_2 = *param_2 | 8;

  }

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

    *param_2 = *param_2 | 0x10;

  }

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

    *param_2 = *param_2 | 0x20;

  }

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

    *param_2 = *param_2 | 0x40;

  }

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

    *param_2 = *param_2 | 0x80;

  }

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

    *param_2 = *param_2 | 0x400;

  }

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

    *param_2 = *param_2 | 0x800;

  }

  return;

}





// --- FUN_00593de0 at 0x00593DE0 (size: 80) ---


bool FUN_00593de0(void)



{

  int local_8;

  int local_4;

  

  local_8 = 0;

  FUN_00590ca0(0x2c,&local_8);

  if (local_8 != 0) {

    return true;

  }

  local_4 = 0;

  FUN_00590ca0(0x2d,&local_4);

  return local_4 != 0;

}





// --- FUN_00593e30 at 0x00593E30 (size: 53) ---


bool FUN_00593e30(void)



{

  char cVar1;

  int local_4;

  

  cVar1 = FUN_00593de0();

  if (cVar1 != '\0') {

    return true;

  }

  local_4 = 0;

  FUN_00590ca0(0x61,&local_4);

  return local_4 != 0;

}





// --- FUN_00593e70 at 0x00593E70 (size: 123) ---


undefined4 * __thiscall FUN_00593e70(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c6720;

  param_1[0xc] = &PTR_LAB_007c670c;

  FUN_00596d00(param_2);

  param_1[0xe] = &PTR_LAB_007e568c;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  *param_1 = &PTR_LAB_007e5630;

  param_1[0xc] = &PTR_LAB_007e56bc;

  return param_1;

}





// --- FUN_00594130 at 0x00594130 (size: 142) ---


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



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  int *unaff_EBP;

  int *local_4;

  

  local_4 = param_1;

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

    piVar3 = (int *)*param_1;

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

      *param_1 = 0;

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

      param_1[1] = 0;

    }

    *param_2 = 0x80004002;

    return;

  }

  iVar1 = *param_3;

  param_3 = (int *)0x0;

  piVar3 = (int *)(**(code **)(iVar1 + 0xc))(&local_4,&DAT_007e560c,&param_3);

  piVar2 = local_4;

  iVar1 = *piVar3;

  piVar3 = (int *)*param_1;

  if (iVar1 < 0) {

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

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

    }

    *param_1 = 0;

    param_1[1] = 0;

    *unaff_EBP = iVar1;

    return;

  }

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

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

  }

  *param_1 = (int)piVar2;

  param_1[1] = 0;

  *unaff_EBP = iVar1;

  return;

}





// --- FUN_00594620 at 0x00594620 (size: 117) ---


undefined4 * __fastcall FUN_00594620(undefined4 *param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  undefined4 uVar5;

  undefined1 local_10 [4];

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  FUN_00593e70(DAT_00872018);

  *param_1 = &PTR_LAB_007e56d0;

  param_1[0xc] = &PTR_LAB_007e56bc;

  param_1[0xe] = &PTR_LAB_007e568c;

  local_8 = (int *)0x0;

  local_4 = 0;

  FUN_00594130(local_10,param_1);

  piVar1 = local_8;

  uVar5 = 0;

  puVar2 = local_c;

  puVar3 = &DAT_007e55fc;

  piVar4 = local_8;

  FUN_00406d10(puVar2,&DAT_007e55fc,local_8,0);

  FUN_00406a90(puVar2,puVar3,piVar4,uVar5);

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

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

  }

  return param_1;

}





// --- FUN_005946c0 at 0x005946C0 (size: 75) ---


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



{

  *param_1 = &PTR_LAB_007e5630;

  param_1[0xc] = &PTR_LAB_007e56bc;

  param_1[0xe] = &PTR_LAB_007e568c;

  FUN_00593b10();

  FUN_00596d30();

  param_1[0xc] = &PTR_FUN_0079385c;

  FUN_004154b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00594710 at 0x00594710 (size: 80) ---


void __fastcall FUN_00594710(undefined4 param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  undefined4 uVar5;

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  local_8 = (int *)0x0;

  local_4 = 0;

  FUN_00594130(local_c,param_1);

  piVar1 = local_8;

  uVar5 = 0;

  puVar2 = local_c;

  puVar3 = &DAT_007e55fc;

  piVar4 = local_8;

  FUN_00406d10(puVar2,&DAT_007e55fc,local_8,0);

  FUN_00406c90(puVar2,puVar3,piVar4,uVar5);

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

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

  }

  return;

}





// --- FUN_00594770 at 0x00594770 (size: 28) ---


undefined4 __fastcall FUN_00594770(int param_1)



{

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

    return 0;

  }

  FUN_004b8110(*(int *)(param_1 + 0x10));

  return 1;

}





// --- FUN_00594790 at 0x00594790 (size: 18) ---


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



float10 __fastcall FUN_00594790(int param_1)



{

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

    return (float10)_DAT_007938b0;

  }

  return (float10)*(float *)(*(int *)(param_1 + 0x10) + 0x4c);

}





// --- FUN_005947b0 at 0x005947B0 (size: 111) ---


int __fastcall FUN_005947b0(int param_1)



{

  int iVar1;

  int iVar2;

  undefined4 local_4;

  

  iVar2 = 4;

  local_4 = 0;

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

    iVar2 = (**(code **)(**(int **)(param_1 + 4) + 0xc))(&local_4,0);

    iVar2 = iVar2 + 4;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 8) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0xc) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x10) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

  return iVar2;

}





// --- FUN_00594820 at 0x00594820 (size: 29) ---


void __fastcall FUN_00594820(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5738;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  return;

}





// --- FUN_00594840 at 0x00594840 (size: 79) ---


void __fastcall FUN_00594840(int param_1)



{

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

  return;

}





// --- FUN_00594890 at 0x00594890 (size: 83) ---


undefined4 __thiscall FUN_00594890(int param_1,int param_2)



{

  int iVar1;

  

  if ((*(uint *)(param_2 + 0x44) & 0x800000) == 0) {

    return 0;

  }

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

    iVar1 = FUN_005df0f5(0x50);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_004b8a00(param_2);

    }

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

    if (iVar1 == 0) {

      return 0;

    }

  }

  FUN_004b8110(param_2);

  return 1;

}





// --- FUN_00594980 at 0x00594980 (size: 62) ---


uint * __thiscall FUN_00594980(int param_1,uint param_2)



{

  uint *puVar1;

  

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

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

        puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[0x26]) {

      if (param_2 == *puVar1) {

        return puVar1 + 2;

      }

    }

  }

  return (uint *)0x0;

}





// --- FUN_005949c0 at 0x005949C0 (size: 43) ---


uint FUN_005949c0(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    uVar1 = FUN_005cbc40(param_2);

    uVar3 = uVar3 | uVar1;

  }

  return uVar3;

}





// --- FUN_005949f0 at 0x005949F0 (size: 43) ---


uint FUN_005949f0(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    uVar1 = FUN_005cbc80(param_2);

    uVar3 = uVar3 | uVar1;

  }

  return uVar3;

}





// --- FUN_00594a20 at 0x00594A20 (size: 77) ---


undefined4 FUN_00594a20(undefined4 param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  

  uVar2 = 0;

  if (param_2 == 0) {

    return 0;

  }

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

  while (iVar3 != 0) {

    iVar1 = FUN_006b0d80(param_1);

    if (iVar1 == 0) {

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

    }

    else {

      FUN_004b8110(param_1);

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

      uVar2 = 1;

    }

  }

  return uVar2;

}





// --- FUN_00594a70 at 0x00594A70 (size: 51) ---


undefined4 FUN_00594a70(uint param_1,int param_2)



{

  int iVar1;

  

  if (param_2 != 0) {

    for (iVar1 = *(int *)(param_2 + 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 0x50)) {

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

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_00594ab0 at 0x00594AB0 (size: 143) ---


undefined4 __thiscall FUN_00594ab0(int param_1,uint param_2,int param_3)



{

  int *piVar1;

  int iVar2;

  

  if (0x7fff < param_2) {

    return 1;

  }

  piVar1 = (int *)FUN_00415730(6,2,0x10000005);

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

    iVar2 = FUN_00594980(param_2);

    if (iVar2 != 0) {

      if ((*(byte *)(iVar2 + 0x18) & 4) != 0) {

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

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

        return 1;

      }

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

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

      return 1;

    }

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

  }

  return 0;

}





// --- FUN_00594b40 at 0x00594B40 (size: 48) ---


void FUN_00594b40(int param_1)



{

  int iVar1;

  

  if (param_1 != 0) {

    for (iVar1 = *(int *)(param_1 + 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 0x50)) {

      FUN_00594ab0(*(uint *)(iVar1 + 4) & 0xffff,1);

    }

  }

  return;

}





// --- FUN_00594b70 at 0x00594B70 (size: 95) ---


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



undefined4 FUN_00594b70(int param_1,int *param_2)



{

  int iVar1;

  

  if ((*param_2 != 0) &&

     (*(double *)(param_1 + 0x20) < _DAT_00795610 == (*(double *)(param_1 + 0x20) == _DAT_00795610))

     ) {

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

    while( true ) {

      if (iVar1 == 0) {

        return 0;

      }

      if ((((*(uint *)(iVar1 + 4) ^ *(uint *)(param_1 + 4)) & 0xffff) == 0) &&

         (_DAT_00795610 < *(double *)(iVar1 + 0x20))) break;

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

    }

    FUN_004b8110(param_1);

    return 1;

  }

  return 0;

}





// --- FUN_00594bd0 at 0x00594BD0 (size: 96) ---


void __thiscall FUN_00594bd0(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = FUN_005df0f5(0x58);

  if (iVar2 == 0) {

    iVar2 = 0;

  }

  else {

    FUN_004b8a00(param_2);

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

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

  }

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

  if (iVar1 == 0) {

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

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

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

    return;

  }

  *(int *)(iVar1 + 0x54) = iVar2;

  *(int *)(iVar2 + 0x50) = iVar1;

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

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

  return;

}





// --- FUN_00594c30 at 0x00594C30 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e5738;

  FUN_00594840();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00594c60 at 0x00594C60 (size: 118) ---


undefined4 FUN_00594c60(int param_1,int *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  

  if (*param_2 == 0) {

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

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

      puVar1 = (undefined4 *)0x0;

    }

    else {

      *puVar1 = &PTR_FUN_007b26fc;

      puVar1[1] = 0;

      puVar1[2] = 0;

      puVar1[3] = 0;

    }

    *param_2 = (int)puVar1;

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

      return 0;

    }

  }

  iVar2 = FUN_00594b70(param_1,param_2);

  if (iVar2 == 0) {

    FUN_00594bd0(param_1);

    FUN_00594ab0(*(uint *)(param_1 + 4) & 0xffff,1);

  }

  return 1;

}





// --- FUN_00594ce0 at 0x00594CE0 (size: 223) ---


undefined4 __thiscall FUN_00594ce0(int param_1,int param_2)



{

  uint uVar1;

  undefined4 uVar2;

  int iVar3;

  

  uVar1 = *(uint *)(param_2 + 0x44);

  if ((((uVar1 >> 9 ^ uVar1) >> 1 ^ uVar1) & 0x4000) == 0) {

    return 0;

  }

  if ((*(uint *)(param_2 + 0x44) & 0x800000) != 0) {

    uVar2 = FUN_00594890(param_2);

    return uVar2;

  }

  if (((*(uint *)(param_2 + 0x44) & 0x1000000) != 0) &&

     (iVar3 = FUN_00594a20(param_2,*(undefined4 *)(param_1 + 0xc)), iVar3 != 0)) {

    return 1;

  }

  if ((*(uint *)(param_2 + 0x44) & 0x4000) == 0) {

    if (((char)(*(uint *)(param_2 + 0x44) >> 8) < '\0') &&

       (iVar3 = FUN_00594a20(param_2,*(undefined4 *)(param_1 + 8)), iVar3 != 0)) {

      return 1;

    }

  }

  else {

    iVar3 = FUN_00594a20(param_2,*(undefined4 *)(param_1 + 4));

    if (iVar3 != 0) {

      return 1;

    }

  }

  uVar1 = *(uint *)(param_2 + 0x44);

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

    FUN_00594c60(param_2,param_1 + 0xc);

    return 1;

  }

  if ((uVar1 & 0x4000) == 0) {

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

      FUN_00594c60(param_2,param_1 + 8);

    }

    return 1;

  }

  FUN_00594c60(param_2,param_1 + 4);

  return 1;

}





// --- FUN_00594dc0 at 0x00594DC0 (size: 43) ---


uint FUN_00594dc0(int param_1)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    uVar1 = FUN_00594ce0(iVar2);

    uVar3 = uVar3 | uVar1;

  }

  return uVar3;

}





// --- FUN_00594df0 at 0x00594DF0 (size: 107) ---


bool __thiscall FUN_00594df0(int param_1,int param_2)



{

  int iVar1;

  

  if (param_2 == 0) {

    return false;

  }

  if (param_2 == 0x29a) {

    return *(int *)(param_1 + 0x10) != 0;

  }

  iVar1 = FUN_00594a70(param_2,*(undefined4 *)(param_1 + 0xc));

  if (iVar1 == 0) {

    iVar1 = FUN_00594a70(param_2,*(undefined4 *)(param_1 + 4));

    if (iVar1 == 0) {

      iVar1 = FUN_00594a70(param_2,*(undefined4 *)(param_1 + 8));

      return iVar1 != 0;

    }

  }

  return true;

}





// --- FUN_00595030 at 0x00595030 (size: 231) ---


undefined4 __thiscall FUN_00595030(int param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  

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

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

    return 0;

  }

  iVar3 = FUN_006b0d80(param_2);

  if (iVar3 != 0) {

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

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

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

    if (iVar3 == 0) {

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

    }

    else {

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

    }

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

      puVar1[0x10] = &PTR_FUN_0079385c;

      *puVar1 = &PTR_FUN_0079385c;

      operator_delete(puVar1);

    }

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

    return 1;

  }

  iVar3 = puVar1[0x14];

  while( true ) {

    if (iVar3 == 0) {

      return 0;

    }

    iVar3 = FUN_006b0d80(param_2);

    if (iVar3 != 0) break;

    puVar1 = (undefined4 *)puVar1[0x14];

    iVar3 = puVar1[0x14];

  }

  FUN_004b8110(puVar1[0x14]);

  puVar2 = (undefined4 *)puVar1[0x14];

  iVar3 = puVar2[0x14];

  puVar1[0x14] = iVar3;

  if (iVar3 == 0) {

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

  }

  else {

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

  }

  puVar2[0x10] = &PTR_FUN_0079385c;

  *puVar2 = &PTR_FUN_0079385c;

  operator_delete(puVar2);

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

  return 1;

}





// --- FUN_00595120 at 0x00595120 (size: 169) ---


undefined4 FUN_00595120(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  

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

  do {

    if (iVar3 == 0) {

LAB_00595172:

      iVar3 = FUN_005df0f5(0x58);

      if (iVar3 == 0) {

        iVar3 = 0;

      }

      else {

        FUN_004b8a00(param_1);

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

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

      }

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

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

      }

      else {

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

        *(int *)(iVar1 + 0x50) = iVar3;

        *(int *)(iVar3 + 0x54) = iVar1;

      }

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

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

      return 1;

    }

    if (*(int *)(iVar3 + 0xc) == *(int *)(param_1 + 0xc)) {

      iVar1 = FUN_005cbc10(param_1);

      if (iVar1 != 0) {

        return 0;

      }

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

        uVar2 = FUN_005cbe30(*(int *)(iVar3 + 4));

        FUN_00595030(uVar2);

      }

      goto LAB_00595172;

    }

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

  } while( true );

}





// --- FUN_005951d0 at 0x005951D0 (size: 81) ---


int FUN_005951d0(uint param_1,int param_2)



{

  undefined4 uVar1;

  int iVar2;

  

  if (param_2 == 0) {

    return 0;

  }

  uVar1 = FUN_005cbe30(param_1);

  iVar2 = FUN_00595030(uVar1);

  if (iVar2 != 0) {

    FUN_00594ab0(param_1 & 0xffff,0xffffffff);

  }

  return iVar2;

}





// --- FUN_00595230 at 0x00595230 (size: 97) ---


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



undefined4 __thiscall FUN_00595230(int param_1,uint param_2,double *param_3)



{

  double dVar1;

  int iVar2;

  

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

    for (iVar2 = *(int *)(*(int *)(param_1 + 0xc) + 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x50))

    {

      if ((*(uint *)(iVar2 + 4) & 0xffff) == param_2) {

        dVar1 = (*(double *)(iVar2 + 0x20) + *(double *)(iVar2 + 0x18)) - _DAT_008379a8;

        *param_3 = dVar1;

        if (dVar1 < _DAT_00795610 != (dVar1 == _DAT_00795610)) {

          FUN_00595030(iVar2);

          return 0;

        }

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_005952a0 at 0x005952A0 (size: 61) ---


uint FUN_005952a0(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0;

  if (param_1 == 0) {

    return 0;

  }

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

    uVar1 = FUN_00595120(iVar2,param_2);

    uVar3 = uVar3 | uVar1;

  }

  return uVar3;

}





// --- FUN_005952e0 at 0x005952E0 (size: 111) ---


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



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  if (param_1 == 0) {

    return 0;

  }

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

  uVar3 = 0;

  do {

    if (iVar4 == 0) {

      return uVar3;

    }

    if ((param_2 & *(uint *)(iVar4 + 0x44)) != 0) {

      if (((*(uint *)(iVar4 + 0x44) & 0x2000) == 0) && (*(int *)(iVar4 + 0x48) != param_3)) {

        iVar1 = FUN_005cbd10(param_3);

        if (iVar1 == 0) {

          iVar1 = FUN_005cbd60(param_3);

          if (iVar1 == 0) goto LAB_00595340;

        }

      }

      uVar2 = FUN_00595120(iVar4,param_4);

      uVar3 = uVar3 | uVar2;

    }

LAB_00595340:

    iVar4 = *(int *)(iVar4 + 0x50);

  } while( true );

}





// --- FUN_00595350 at 0x00595350 (size: 92) ---


undefined4 __thiscall FUN_00595350(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 uVar3;

  

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

  if ((puVar1 == (undefined4 *)0x0) || (puVar1[1] != param_2)) {

    iVar2 = FUN_005951d0(param_2,*(undefined4 *)(param_1 + 0xc));

    if (iVar2 == 0) {

      iVar2 = FUN_005951d0(param_2,*(undefined4 *)(param_1 + 4));

      if (iVar2 == 0) {

        uVar3 = FUN_005951d0(param_2,*(undefined4 *)(param_1 + 8));

        return uVar3;

      }

    }

  }

  else {

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

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

  }

  return 1;

}





// --- FUN_005953b0 at 0x005953B0 (size: 41) ---


uint __thiscall FUN_005953b0(int param_1,undefined4 param_2)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = FUN_005952a0(*(undefined4 *)(param_1 + 4),param_2);

  uVar2 = FUN_005952a0(*(undefined4 *)(param_1 + 8),param_2);

  return uVar2 | uVar1;

}





// --- FUN_005953e0 at 0x005953E0 (size: 243) ---


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



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



{

  int iVar1;

  uint *puVar2;

  uint uVar3;

  uint uVar4;

  undefined **local_10;

  int local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  puVar2 = param_3;

  uVar4 = *param_3;

  param_3 = (uint *)(float)(int)*param_3;

  if ((int)uVar4 < 0) {

    param_3 = (uint *)((float)param_3 + _DAT_0079920c);

  }

  local_10 = &PTR_FUN_007b26fc;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  FUN_005952e0(*(undefined4 *)(param_1 + 4),1,param_2,&local_10);

  FUN_005952e0(*(undefined4 *)(param_1 + 8),1,param_2,&local_10);

  uVar4 = 0;

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

    uVar3 = FUN_005cbc40(&param_3);

    uVar4 = uVar4 | uVar3;

    if (iVar1 == 0) break;

  }

  if (*puVar2 < 10) {

    if ((float)param_3 < _DAT_007938b0) {

      param_3 = (uint *)0x3f800000;

    }

  }

  else if ((float)param_3 < _DAT_0079c6d4) {

    param_3 = (uint *)0x41200000;

  }

  uVar3 = FUN_005df4c4();

  *puVar2 = uVar3;

  local_10 = &PTR_FUN_007b26fc;

  FUN_004b86f0();

  return uVar4;

}





// --- FUN_005954e0 at 0x005954E0 (size: 307) ---


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



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



{

  int *piVar1;

  int iVar2;

  uint uVar3;

  uint uVar4;

  uint uVar5;

  float fStack_14;

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  piVar1 = (int *)FUN_00415730(0x10000002,3,0x1000000c);

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

    return 0;

  }

  iVar2 = FUN_005ccbc0(param_2);

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

  if (iVar2 == 0) {

    return 0;

  }

  fStack_14 = (float)(int)*param_3;

  uVar5 = 0;

  if ((int)*param_3 < 0) {

    fStack_14 = fStack_14 + _DAT_0079920c;

  }

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

    uVar5 = FUN_005cbc40(&fStack_14);

  }

  uStack_c = 0;

  uStack_8 = 0;

  uStack_4 = 0;

  ppuStack_10 = &PTR_FUN_007b26fc;

  FUN_005952e0(*(undefined4 *)(param_1 + 4),2,param_2,&ppuStack_10);

  FUN_005952e0(*(undefined4 *)(param_1 + 8),2,param_2,&ppuStack_10);

  uVar3 = FUN_005949c0(&ppuStack_10,&fStack_14);

  if (*param_3 < 5) {

    if (fStack_14 < _DAT_007938b0) {

      fStack_14 = 1.0;

    }

  }

  else if (fStack_14 < _DAT_007b817c) {

    fStack_14 = 5.0;

  }

  uVar4 = FUN_005df4c4();

  *param_3 = uVar4;

  ppuStack_10 = &PTR_FUN_007b26fc;

  FUN_004b86f0();

  return uVar5 | uVar3;

}





// --- FUN_00595620 at 0x00595620 (size: 226) ---


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



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



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  uint uVar4;

  float local_14;

  undefined **local_10;

  int local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_14 = (float)*param_3;

  uVar3 = 0;

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

    uVar3 = FUN_005cbc40(&local_14);

  }

  local_10 = &PTR_FUN_007b26fc;

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  FUN_005952e0(*(undefined4 *)(param_1 + 4),0x10,param_2,&local_10);

  FUN_005952e0(*(undefined4 *)(param_1 + 8),0x10,param_2,&local_10);

  uVar4 = 0;

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

    uVar1 = FUN_005cbc40(&local_14);

    uVar4 = uVar4 | uVar1;

    if (iVar2 == 0) break;

  }

  if (local_14 < _DAT_007938b8 != (local_14 == _DAT_007938b8)) {

    local_14 = 0.0;

  }

  iVar2 = FUN_005df4c4();

  *param_3 = iVar2;

  local_10 = &PTR_FUN_007b26fc;

  FUN_004b86f0();

  return uVar3 | uVar4;

}





// --- FUN_00595710 at 0x00595710 (size: 261) ---


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



undefined4 __thiscall FUN_00595710(int param_1,undefined4 param_2,int *param_3,int param_4)



{

  int *piVar1;

  int iVar2;

  undefined4 uVar3;

  float fStack_14;

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  piVar1 = (int *)FUN_00415730(0x10000002,3,0x1000000c);

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

    return 0;

  }

  iVar2 = FUN_006b2e40(param_2);

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

  if (iVar2 != 0) {

    fStack_14 = (float)*param_3;

    ppuStack_10 = &PTR_FUN_007b26fc;

    uStack_c = 0;

    uStack_8 = 0;

    uStack_4 = 0;

    FUN_005952e0(*(undefined4 *)(param_1 + 4),4,param_2,&ppuStack_10);

    FUN_005952e0(*(undefined4 *)(param_1 + 8),4,param_2,&ppuStack_10);

    uVar3 = FUN_005949c0(&ppuStack_10,&fStack_14);

    if ((param_4 == 0) && (fStack_14 < _DAT_007938b8 != (fStack_14 == _DAT_007938b8))) {

      fStack_14 = 0.0;

    }

    iVar2 = FUN_005df4c4();

    *param_3 = iVar2;

    ppuStack_10 = &PTR_FUN_007b26fc;

    FUN_004b86f0();

    return uVar3;

  }

  return 0;

}





// --- FUN_00595820 at 0x00595820 (size: 217) ---


undefined4 __thiscall FUN_00595820(int param_1,undefined4 param_2,double *param_3)



{

  int *piVar1;

  int iVar2;

  undefined4 uVar3;

  float fStack_14;

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  piVar1 = (int *)FUN_00415730(0x10000002,3,0x1000000c);

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

    return 0;

  }

  iVar2 = FUN_006b2ee0(param_2);

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

  if (iVar2 == 0) {

    return 0;

  }

  fStack_14 = (float)*param_3;

  ppuStack_10 = &PTR_FUN_007b26fc;

  uStack_c = 0;

  uStack_8 = 0;

  uStack_4 = 0;

  FUN_005952e0(*(undefined4 *)(param_1 + 4),8,param_2,&ppuStack_10);

  FUN_005952e0(*(undefined4 *)(param_1 + 8),8,param_2,&ppuStack_10);

  uVar3 = FUN_005949c0(&ppuStack_10,&fStack_14);

  *param_3 = (double)fStack_14;

  ppuStack_10 = &PTR_FUN_007b26fc;

  FUN_004b86f0();

  return uVar3;

}





// --- FUN_00595900 at 0x00595900 (size: 174) ---


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



{

  int *piVar1;

  int iVar2;

  undefined **ppuStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  piVar1 = (int *)FUN_00415730(0x10000002,3,0x1000000c);

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

    return 0;

  }

  iVar2 = FUN_006b2ee0(param_2);

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

  if (iVar2 != 0) {

    ppuStack_10 = &PTR_FUN_007b26fc;

    uStack_c = 0;

    uStack_8 = 0;

    uStack_4 = 0;

    FUN_005952e0(*(undefined4 *)(param_1 + 4),8,param_2,&ppuStack_10);

    FUN_005952e0(*(undefined4 *)(param_1 + 8),8,param_2,&ppuStack_10);

    FUN_005949f0(&ppuStack_10,param_3);

    ppuStack_10 = &PTR_FUN_007b26fc;

    FUN_004b86f0();

  }

  return 1;

}





// --- FUN_005959b0 at 0x005959B0 (size: 32) ---


uint __thiscall FUN_005959b0(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  int iVar3;

  uint uVar4;

  uint *puVar5;

  uint local_54;

  

  puVar5 = *(uint **)(param_2 + 4);

  local_54 = 0;

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

    return 0;

  }

  do {

    while( true ) {

      while( true ) {

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

          return local_54;

        }

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

        uVar4 = *puVar5;

        if ((puVar1 == (undefined4 *)0x0) || (puVar1[1] != uVar4)) break;

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

        local_54 = local_54 | 1;

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

        puVar5 = (uint *)puVar5[1];

      }

      if (*(int *)(param_1 + 0xc) != 0) break;

LAB_00595a5e:

      iVar3 = FUN_005951d0(uVar4,*(undefined4 *)(param_1 + 4));

      if (iVar3 == 0) {

        uVar4 = FUN_005951d0(uVar4,*(undefined4 *)(param_1 + 8));

        puVar5 = (uint *)puVar5[1];

        local_54 = local_54 | uVar4;

      }

      else {

        puVar5 = (uint *)puVar5[1];

        local_54 = local_54 | 1;

      }

    }

    uVar2 = FUN_005cbe30(uVar4);

    iVar3 = FUN_00595030(uVar2);

    if (iVar3 == 0) goto LAB_00595a5e;

    FUN_00594ab0(uVar4 & 0xffff,0xffffffff);

    puVar5 = (uint *)puVar5[1];

    local_54 = local_54 | 1;

  } while( true );

}





// --- FUN_005959d0 at 0x005959D0 (size: 225) ---


uint FUN_005959d0(uint param_1)



{

  undefined4 *puVar1;

  uint *in_EAX;

  undefined4 uVar2;

  int iVar3;

  uint uVar4;

  int unaff_EDI;

  

LAB_005959d5:

  do {

    while( true ) {

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

        return param_1;

      }

      puVar1 = *(undefined4 **)(unaff_EDI + 0x10);

      uVar4 = *in_EAX;

      if ((puVar1 == (undefined4 *)0x0) || (puVar1[1] != uVar4)) break;

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

      param_1 = param_1 | 1;

      *(undefined4 *)(unaff_EDI + 0x10) = 0;

      in_EAX = (uint *)in_EAX[1];

    }

    if (*(int *)(unaff_EDI + 0xc) != 0) {

      uVar2 = FUN_005cbe30(uVar4);

      iVar3 = FUN_00595030(uVar2);

      if (iVar3 != 0) {

        FUN_00594ab0(uVar4 & 0xffff,0xffffffff);

        in_EAX = (uint *)in_EAX[1];

        param_1 = param_1 | 1;

        goto LAB_005959d5;

      }

    }

    iVar3 = FUN_005951d0(uVar4,*(undefined4 *)(unaff_EDI + 4));

    if (iVar3 == 0) {

      uVar4 = FUN_005951d0(uVar4,*(undefined4 *)(unaff_EDI + 8));

      in_EAX = (uint *)in_EAX[1];

      param_1 = param_1 | uVar4;

    }

    else {

      in_EAX = (uint *)in_EAX[1];

      param_1 = param_1 | 1;

    }

  } while( true );

}





// --- FUN_00595ac0 at 0x00595AC0 (size: 189) ---


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



undefined4 FUN_00595ac0(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  int iVar4;

  undefined **local_10;

  undefined4 *local_c;

  undefined4 *local_8;

  int local_4;

  

  if (param_1 == 0) {

    return 0;

  }

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

  local_10 = &PTR_FUN_007a4ed0;

  local_c = (undefined4 *)0x0;

  local_8 = (undefined4 *)0x0;

  local_4 = 0;

  puVar3 = (undefined4 *)0x0;

LAB_00595af7:

  do {

    if (iVar4 == 0) {

      local_c = puVar3;

      uVar2 = FUN_005959b0(&local_10);

      local_10 = &PTR_FUN_007a4ed0;

      FUN_0048bc30();

      return uVar2;

    }

    puVar1 = puVar3;

    if (*(double *)(iVar4 + 0x20) != _DAT_007e5730) {

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

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

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

        puVar1 = (undefined4 *)0x0;

      }

      else {

        *puVar1 = uVar2;

        puVar1[1] = 0;

        puVar1[2] = 0;

      }

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

        iVar4 = *(int *)(iVar4 + 0x50);

        local_4 = local_4 + 1;

        puVar3 = puVar1;

        local_8 = puVar1;

        goto LAB_00595af7;

      }

      puVar3[2] = puVar1;

      puVar1[1] = puVar3;

      local_4 = local_4 + 1;

    }

    iVar4 = *(int *)(iVar4 + 0x50);

    puVar3 = puVar1;

  } while( true );

}





// --- FUN_00595b80 at 0x00595B80 (size: 198) ---


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



undefined4 FUN_00595b80(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  int iVar4;

  undefined **local_10;

  undefined4 *local_c;

  undefined4 *local_8;

  int local_4;

  

  if (param_1 == 0) {

    return 0;

  }

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

  local_10 = &PTR_FUN_007a4ed0;

  local_c = (undefined4 *)0x0;

  local_8 = (undefined4 *)0x0;

  local_4 = 0;

  puVar3 = (undefined4 *)0x0;

LAB_00595bb7:

  do {

    if (iVar4 == 0) {

      local_c = puVar3;

      uVar2 = FUN_005959b0(&local_10);

      local_10 = &PTR_FUN_007a4ed0;

      FUN_0048bc30();

      return uVar2;

    }

    puVar1 = puVar3;

    if (((*(uint *)(iVar4 + 0x44) & 0x2000000) == 0) && (*(double *)(iVar4 + 0x20) != _DAT_007e5730)

       ) {

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

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

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

        puVar1 = (undefined4 *)0x0;

      }

      else {

        *puVar1 = uVar2;

        puVar1[1] = 0;

        puVar1[2] = 0;

      }

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

        iVar4 = *(int *)(iVar4 + 0x50);

        local_4 = local_4 + 1;

        puVar3 = puVar1;

        local_8 = puVar1;

        goto LAB_00595bb7;

      }

      puVar3[2] = puVar1;

      puVar1[1] = puVar3;

      local_4 = local_4 + 1;

    }

    iVar4 = *(int *)(iVar4 + 0x50);

    puVar3 = puVar1;

  } while( true );

}





// --- FUN_00595c50 at 0x00595C50 (size: 31) ---


uint __fastcall FUN_00595c50(int param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = FUN_00595ac0(*(undefined4 *)(param_1 + 4));

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

  return uVar2 | uVar1;

}





// --- FUN_00595c70 at 0x00595C70 (size: 31) ---


uint __fastcall FUN_00595c70(int param_1)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = FUN_00595b80(*(undefined4 *)(param_1 + 4));

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

  return uVar2 | uVar1;

}





// --- FUN_00595ca0 at 0x00595CA0 (size: 99) ---


void __thiscall FUN_00595ca0(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = FUN_005df0f5(0x40);

  if (iVar2 == 0) {

    iVar2 = 0;

  }

  else {

    FUN_00597900(param_2);

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

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

  }

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

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

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

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

    return;

  }

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

  *(int *)(iVar1 + 0x38) = iVar2;

  *(int *)(iVar2 + 0x3c) = iVar1;

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

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

  return;

}





// --- FUN_00595da0 at 0x00595DA0 (size: 73) ---


uint __thiscall FUN_00595da0(int param_1,int *param_2,uint param_3)



{

  int *piVar1;

  uint uVar2;

  

  uVar2 = FUN_00595df0();

  if (uVar2 <= param_3) {

    if (3 < param_3) {

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

      *param_2 = *param_2 + 4;

    }

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

      (**(code **)(*piVar1 + 0xc))(param_2,param_3);

    }

  }

  return uVar2;

}





// --- FUN_00595df0 at 0x00595DF0 (size: 52) ---


int __fastcall FUN_00595df0(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 local_4;

  

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

  iVar3 = 4;

  local_4 = 0;

  for (; piVar1 != (int *)0x0; piVar1 = (int *)piVar1[0xe]) {

    iVar2 = (**(code **)(*piVar1 + 0xc))(&local_4,0);

    iVar3 = iVar3 + iVar2;

  }

  return iVar3;

}





// --- FUN_00595e30 at 0x00595E30 (size: 111) ---


void __fastcall FUN_00595e30(int param_1)



{

  int iVar1;

  void *pvVar2;

  

  FUN_00597750();

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

  while (iVar1 != 0) {

    pvVar2 = *(void **)(param_1 + 4);

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

      iVar1 = *(int *)((int)pvVar2 + 0x38);

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

      if (iVar1 == 0) {

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

      }

      else {

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

      }

      FUN_00597810(pvVar2);

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

        FUN_005977c0();

        operator_delete(pvVar2);

      }

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

    }

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

  }

  FUN_005977c0();

  return;

}





// --- FUN_00595ea0 at 0x00595EA0 (size: 107) ---


int __thiscall FUN_00595ea0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  FUN_00595e30();

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

  while( true ) {

    if (iVar1 == 0) {

      return param_1;

    }

    iVar3 = FUN_005df0f5(0x40);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      FUN_00597900(iVar1);

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

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

    }

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

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

    }

    else {

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

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

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

    }

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

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

    if (iVar1 == 0) break;

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

  }

  return param_1;

}





// --- FUN_00595f10 at 0x00595F10 (size: 22) ---


void __fastcall FUN_00595f10(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e57b0;

  FUN_00595e30();

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00595f30 at 0x00595F30 (size: 141) ---


undefined4 FUN_00595f30(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int local_38 [14];

  

  FUN_00595e30();

  if (param_2 < 4) {

    return 0;

  }

  iVar1 = *(int *)*param_1;

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

  FUN_00597750();

  iVar3 = 0;

  if (0 < iVar1) {

    do {

      iVar2 = (**(code **)(local_38[0] + 0x10))(param_1,param_2);

      if (iVar2 == 0) {

        FUN_005977c0();

        return 0;

      }

      FUN_00595ca0(local_38);

      iVar3 = iVar3 + 1;

    } while (iVar3 < iVar1);

  }

  FUN_005977c0();

  return 1;

}





// --- FUN_00595fc0 at 0x00595FC0 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e57b0;

  FUN_00595e30();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00595ff0 at 0x00595FF0 (size: 65) ---


uint * __thiscall FUN_00595ff0(uint *param_1,uint *param_2,undefined4 param_3,uint param_4)



{

  *param_1 = *param_2;

  param_1[1] = (uint)&PTR_FUN_007e57b0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  FUN_00595ea0(param_3);

  param_1[5] = 0;

  param_1[6] = *param_2 % param_4;

  return param_1;

}





// --- FUN_00596040 at 0x00596040 (size: 141) ---


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



{

  uint *puVar1;

  int iVar2;

  

  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[5]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  iVar2 = FUN_005df0f5(0x1c);

  if ((iVar2 != 0) &&

     (iVar2 = FUN_00595ff0(param_2,param_3,*(undefined4 *)(param_1 + 0xc)), iVar2 != 0)) {

    *(undefined4 *)(iVar2 + 0x14) =

         *(undefined4 *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x18) * 4);

    *(int *)(*(int *)(param_1 + 8) + *(int *)(iVar2 + 0x18) * 4) = iVar2;

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

    return 1;

  }

  return 0;

}





// --- FUN_005960d0 at 0x005960D0 (size: 124) ---


void __fastcall FUN_005960d0(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint local_4;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_4 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + local_4 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x14);

        *(undefined4 *)((int)pvVar2 + 4) = &PTR_FUN_007e57b0;

        FUN_00595e30();

        *(undefined4 *)((int)pvVar2 + 4) = &PTR_FUN_0079385c;

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

      *(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_005962c0 at 0x005962C0 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007e579c;

  FUN_005960d0();

  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_00596310 at 0x00596310 (size: 45) ---


undefined4 * __fastcall FUN_00596310(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e57c4;

  param_1[1] = &PTR_FUN_007e579c;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0x20;

  param_1[5] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00596340 at 0x00596340 (size: 91) ---


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



{

  *param_1 = &PTR_FUN_007e57c4;

  param_1[1] = &PTR_FUN_007e579c;

  FUN_005960d0();

  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_005963c0 at 0x005963C0 (size: 87) ---


void __thiscall FUN_005963c0(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

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

  uVar5 = 0;

  if (uVar1 != 0) {

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

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007e57d8;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

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

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007e57d8;

  param_2[3] = uVar1;

  return;

}





// --- FUN_00596420 at 0x00596420 (size: 77) ---


bool __thiscall FUN_00596420(int param_1,uint param_2)



{

  uint *puVar1;

  

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

    for (puVar1 = *(uint **)(*(int *)(param_1 + 0xc) + (param_2 % *(uint *)(param_1 + 0x10)) * 4);

        puVar1 != (uint *)0x0; puVar1 = (uint *)puVar1[3]) {

      if (param_2 == *puVar1) {

        return puVar1 != (uint *)0xfffffffc;

      }

    }

  }

  return false;

}





// --- FUN_00596470 at 0x00596470 (size: 157) ---


undefined4 FUN_00596470(int param_1)



{

  int iVar1;

  uint uVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  undefined1 local_10 [4];

  undefined4 *local_c;

  int local_8;

  uint local_4;

  

  FUN_005963c0(local_10);

LAB_00596492:

  do {

    do {

      puVar4 = local_c;

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

        return 1;

      }

      puVar3 = (undefined4 *)FUN_005df0f5(0xc);

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

        puVar3 = (undefined4 *)0x0;

      }

      else {

        *puVar3 = *puVar4;

        puVar3[1] = 0;

        puVar3[2] = 0;

      }

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

      if (iVar1 == 0) {

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

      }

      else {

        *(undefined4 **)(iVar1 + 8) = puVar3;

        puVar3[1] = iVar1;

      }

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

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

      local_c = (undefined4 *)puVar4[3];

    } while ((undefined4 *)puVar4[3] != (undefined4 *)0x0);

    uVar2 = puVar4[4];

    do {

      uVar2 = uVar2 + 1;

      if (local_4 <= uVar2) {

        local_c = (undefined4 *)0x0;

        goto LAB_00596492;

      }

    } while (*(int *)(local_8 + uVar2 * 4) == 0);

    local_c = *(undefined4 **)(local_8 + uVar2 * 4);

  } while( true );

}





// --- FUN_005965a0 at 0x005965A0 (size: 91) ---


int __fastcall FUN_005965a0(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 + 0xc)) {

        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_00596600 at 0x00596600 (size: 86) ---


void __fastcall FUN_00596600(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0xc);

        *(undefined ***)((int)pvVar2 + 4) = &PTR_FUN_0079385c;

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

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

      uVar3 = uVar3 + 1;

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

  }

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

  return;

}





// --- FUN_00596660 at 0x00596660 (size: 159) ---


undefined4 __thiscall FUN_00596660(int param_1,uint *param_2,int 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[3]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x14);

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

    return 0;

  }

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

  *puVar1 = *param_2;

  puVar1[1] = (uint)&PTR_FUN_007e5464;

  puVar1[2] = *(uint *)(param_3 + 4);

  puVar1[3] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[4] = uVar2;

  puVar1[3] = *(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_00596700 at 0x00596700 (size: 144) ---


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



{

  uint *puVar1;

  uint *puVar2;

  

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

    puVar1 = (uint *)0x0;

    for (puVar2 = *(uint **)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4);

        puVar2 != (uint *)0x0; puVar2 = (uint *)puVar2[3]) {

      if (*puVar2 == *param_2) {

        *(uint *)(param_3 + 4) = puVar2[2];

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

          *(uint *)(*(int *)(param_1 + 8) + (*param_2 % *(uint *)(param_1 + 0xc)) * 4) = puVar2[3];

        }

        else {

          puVar1[3] = puVar2[3];

        }

        puVar2[1] = (uint)&PTR_FUN_0079385c;

        operator_delete(puVar2);

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

        return 1;

      }

      puVar1 = puVar2;

    }

  }

  return 0;

}





// --- FUN_00596790 at 0x00596790 (size: 34) ---


undefined4 FUN_00596790(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  if (param_1 != 0) {

    uVar1 = FUN_00596660(&param_1,param_2);

    return uVar1;

  }

  return 0;

}





// --- FUN_005967c0 at 0x005967C0 (size: 21) ---


void FUN_005967c0(undefined4 param_1,undefined4 param_2)



{

  FUN_00596700(&param_1,param_2);

  return;

}





// --- FUN_005967e0 at 0x005967E0 (size: 199) ---


void FUN_005967e0(void)



{

  uint uVar1;

  uint *puVar2;

  int iVar3;

  char *pcVar4;

  char *pcVar5;

  bool bVar6;

  uint local_34;

  undefined1 local_30 [8];

  undefined1 local_28 [4];

  uint *local_24;

  int local_20;

  uint local_1c;

  char local_18 [20];

  

  FUN_005963c0(local_28);

joined_r0x00596806:

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

    return;

  }

  puVar2 = (uint *)local_24[3];

  local_34 = *local_24;

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

    uVar1 = local_24[4];

    do {

      uVar1 = uVar1 + 1;

      if (local_1c <= uVar1) {

        puVar2 = (uint *)0x0;

        goto LAB_0059683e;

      }

    } while (*(int *)(local_20 + uVar1 * 4) == 0);

    puVar2 = *(uint **)(local_20 + uVar1 * 4);

  }

LAB_0059683e:

  local_24 = puVar2;

  if ((local_34 != 0) && (local_34 < 0x2000)) goto code_r0x0059684c;

  goto LAB_00596892;

code_r0x0059684c:

  FUN_00509430(local_34,local_18,0x10);

  iVar3 = 8;

  bVar6 = true;

  pcVar4 = local_18;

  pcVar5 = "Unknown";

  do {

    if (iVar3 == 0) break;

    iVar3 = iVar3 + -1;

    bVar6 = *pcVar4 == *pcVar5;

    pcVar4 = pcVar4 + 1;

    pcVar5 = pcVar5 + 1;

  } while (bVar6);

  if (bVar6) {

LAB_00596892:

    FUN_00596700(&local_34,local_30);

  }

  goto joined_r0x00596806;

}





// --- FUN_005968b0 at 0x005968B0 (size: 52) ---


void __fastcall FUN_005968b0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e57dc;

  FUN_00596600();

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

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

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_005968f0 at 0x005968F0 (size: 312) ---


ushort __thiscall FUN_005968f0(int param_1,int *param_2,uint param_3)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  uint local_24;

  undefined4 local_1c;

  int local_18;

  uint local_14;

  undefined **local_10;

  undefined4 local_c;

  

  if (3 < param_3) {

    local_18 = *param_2;

    local_14 = param_3;

    FUN_00596600();

    if (*(void **)(param_1 + 8) != (void *)0x0) {

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

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

    }

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

    uVar1 = *(uint *)*param_2;

    *param_2 = (int)((uint *)*param_2 + 1);

    uVar4 = uVar1 >> 0x10;

    uVar2 = uVar1 & 0xffff;

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

    if (uVar4 == 0) {

      return CONCAT11((char)(uVar1 >> 0x18),uVar2 == 0);

    }

    if (((uVar4 < 0x10001) && (uVar2 < 0x10001)) && (iVar3 = FUN_005a8440(), iVar3 != 0)) {

      local_10 = &PTR_FUN_007e5464;

      local_c = 0;

      local_24 = 0;

      if (uVar2 != 0) {

        do {

          if (param_3 - 4 < 4) {

            return 0;

          }

          local_1c = *(undefined4 *)*param_2;

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

          iVar3 = (*(code *)local_10[4])(param_2,param_3 - 4);

          if (iVar3 == 0) {

            return 0;

          }

          iVar3 = FUN_00596660(&local_1c,&local_10);

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

            return 0;

          }

          local_24 = local_24 + 1;

        } while (local_24 < uVar2);

      }

      return (ushort)((uint)(*param_2 - local_18) <= local_14);

    }

  }

  return 0;

}





// --- FUN_00596a30 at 0x00596A30 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007e57dc;

  FUN_00596600();

  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_00596a80 at 0x00596A80 (size: 45) ---


undefined4 * __fastcall FUN_00596a80(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e57f0;

  param_1[1] = &PTR_FUN_007e57dc;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0x40;

  param_1[5] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_00596b10 at 0x00596B10 (size: 39) ---


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



{

  FUN_005968b0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00596b40 at 0x00596B40 (size: 137) ---


void __fastcall FUN_00596b40(int param_1)



{

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

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

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

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

  }

  return;

}





// --- FUN_00596bd0 at 0x00596BD0 (size: 90) ---


void __thiscall FUN_00596bd0(int param_1,uint *param_2)



{

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

    *param_2 = *param_2 | 1;

  }

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

    *param_2 = *param_2 | 0x80;

  }

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

    *param_2 = *param_2 | 2;

  }

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

    *param_2 = *param_2 | 4;

  }

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

    *param_2 = *param_2 | 0x10;

  }

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

    *param_2 = *param_2 | 8;

  }

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

    *param_2 = *param_2 | 0x40;

  }

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

    *param_2 = *param_2 | 0x20;

  }

  return;

}





// --- FUN_00596c30 at 0x00596C30 (size: 195) ---


int __fastcall FUN_00596c30(int param_1)



{

  int iVar1;

  int iVar2;

  undefined4 local_4;

  

  iVar2 = 8;

  local_4 = 0;

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

    iVar2 = (**(code **)(**(int **)(param_1 + 8) + 0xc))(&local_4,0);

    iVar2 = iVar2 + 8;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0xc) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x10) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x14) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x18) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x1c) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x20) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

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

    iVar1 = (**(code **)(**(int **)(param_1 + 0x24) + 0xc))(&local_4,0);

    iVar2 = iVar2 + iVar1;

  }

  return iVar2;

}





// --- FUN_00596d00 at 0x00596D00 (size: 40) ---


void __fastcall FUN_00596d00(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007e583c;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  return;

}





// --- FUN_00596d30 at 0x00596D30 (size: 11) ---


void __fastcall FUN_00596d30(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007e583c;

  FUN_00596b40();

  return;

}





// --- FUN_00596d40 at 0x00596D40 (size: 195) ---


uint __thiscall FUN_00596d40(int param_1,int *param_2,uint param_3)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  

  uVar3 = FUN_00596c30();

  uVar2 = param_3;

  if (uVar3 <= param_3) {

    param_3 = 0;

    FUN_00596bd0(&param_3);

    *(uint *)*param_2 = param_3;

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    *param_2 = *param_2 + 4;

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

      (**(code **)(**(int **)(param_1 + 8) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0xc) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x10) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x14) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x18) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x1c) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x20) + 0xc))(param_2,uVar2);

    }

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

      (**(code **)(**(int **)(param_1 + 0x24) + 0xc))(param_2,uVar2);

    }

  }

  return uVar3;

}





// --- FUN_00596e10 at 0x00596E10 (size: 735) ---


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



{

  uint *puVar1;

  uint uVar2;

  int *piVar3;

  int iVar4;

  undefined4 uVar5;

  int iVar6;

  

  piVar3 = param_2;

  puVar1 = (uint *)*param_2;

  if (3 < param_3) {

    uVar2 = *puVar1;

    *param_2 = (int)(puVar1 + 1);

    if (3 < param_3 - 4) {

      *(uint *)(param_1 + 4) = puVar1[1];

      iVar6 = param_3 - 8;

      *param_2 = *param_2 + 4;

      if ((uVar2 & 1) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590930(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 8) + 0x10))(param_2,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      param_2._0_1_ = (char)uVar2;

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

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590960(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0xc) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

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

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

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

      }

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

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590a20(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0x10) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      if ((uVar2 & 4) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590ae0(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0x14) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      if ((uVar2 & 0x10) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590b80(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0x18) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      if ((uVar2 & 8) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590b50(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0x1c) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      if ((uVar2 & 0x40) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_0052f540(0);

          }

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

        }

        iVar4 = (**(code **)(**(int **)(param_1 + 0x20) + 0x10))(piVar3,iVar6);

        if (iVar4 == 0) {

          return 0;

        }

      }

      if ((uVar2 & 0x20) == 0) {

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

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

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

        }

      }

      else {

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

          iVar4 = FUN_005df0f5(0x14);

          if (iVar4 == 0) {

            uVar5 = 0;

          }

          else {

            uVar5 = FUN_00590bb0(0);

          }

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

        }

        iVar6 = (**(code **)(**(int **)(param_1 + 0x24) + 0x10))(piVar3,iVar6);

        if (iVar6 == 0) {

          return 0;

        }

      }

      uVar5 = FUN_00526db0(*piVar3,puVar1,param_3);

      return uVar5;

    }

  }

  return 0;

}





// --- FUN_005971f0 at 0x005971F0 (size: 114) ---


void __thiscall FUN_005971f0(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = FUN_005df0f5(0x130);

  if (iVar2 == 0) {

    iVar2 = 0;

  }

  else {

    FUN_005cf850(param_2);

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

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

  }

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

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

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

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

    return;

  }

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

  *(int *)(iVar1 + 0x128) = iVar2;

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

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

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

  return;

}





// --- FUN_00597270 at 0x00597270 (size: 76) ---


uint __thiscall FUN_00597270(int param_1,int *param_2,uint param_3)



{

  int *piVar1;

  uint uVar2;

  

  uVar2 = FUN_005972c0();

  if (uVar2 <= param_3) {

    if (3 < param_3) {

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

      *param_2 = *param_2 + 4;

    }

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

      (**(code **)(*piVar1 + 0xc))(param_2,param_3);

    }

  }

  return uVar2;

}





// --- FUN_005972c0 at 0x005972C0 (size: 55) ---


int __fastcall FUN_005972c0(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  undefined4 local_4;

  

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

  iVar3 = 4;

  local_4 = 0;

  for (; piVar1 != (int *)0x0; piVar1 = (int *)piVar1[0x4a]) {

    iVar2 = (**(code **)(*piVar1 + 0xc))(&local_4,0);

    iVar3 = iVar3 + iVar2;

  }

  return iVar3;

}





// --- FUN_00597300 at 0x00597300 (size: 97) ---


int __fastcall FUN_00597300(int param_1)



{

  int iVar1;

  int iVar2;

  undefined4 local_4;

  

  local_4 = 0;

  iVar2 = 8;

  switch(*(undefined4 *)(param_1 + 4)) {

  case 1:

  case 2:

  case 6:

    iVar2 = 0xc;

    break;

  case 5:

  case 0xf:

  case 0x27:

    iVar2 = 0x10;

    break;

  case 0xc:

  case 0xd:

  case 0x16:

  case 0x17:

  case 0x1b:

  case 0x1c:

  case 0x1d:

  case 0x1e:

  case 0x1f:

  case 0x20:

  case 0x21:

  case 0x22:

  case 0x23:

  case 0x24:

  case 0x25:

  case 0x26:

    iVar2 = FUN_004fd290(&local_4,0);

    iVar2 = iVar2 + 8;

  }

  iVar1 = (**(code **)(*(int *)(param_1 + 0x28) + 0xc))(&local_4,0);

  return iVar1 + iVar2;

}





// --- FUN_005974a0 at 0x005974A0 (size: 120) ---


void __fastcall FUN_005974a0(int param_1)



{

  int iVar1;

  void *pvVar2;

  

  FUN_005ced20();

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

  while (iVar1 != 0) {

    pvVar2 = *(void **)(param_1 + 4);

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

      iVar1 = *(int *)((int)pvVar2 + 0x128);

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

      if (iVar1 == 0) {

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

      }

      else {

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

      }

      FUN_005ceeb0(pvVar2);

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

        FUN_005cee30();

        operator_delete(pvVar2);

      }

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

    }

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

  }

  FUN_005cee30();

  return;

}





// --- FUN_00597520 at 0x00597520 (size: 201) ---


bool __thiscall FUN_00597520(int param_1,int *param_2,uint param_3)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  int iVar3;

  

  if (param_3 < 8) {

    return false;

  }

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

  iVar3 = *param_2;

  *param_2 = iVar3 + 4;

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

  iVar3 = *param_2;

  puVar2 = (undefined4 *)(iVar3 + 4);

  *param_2 = (int)puVar2;

  switch(*(undefined4 *)(param_1 + 4)) {

  case 1:

  case 6:

    if (param_3 < 0xc) {

      return false;

    }

    uVar1 = *puVar2;

    *param_2 = iVar3 + 8;

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

    goto switchD_00597565_caseD_3;

  case 2:

    if (param_3 < 0xc) {

      return false;

    }

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

    break;

  default:

    goto switchD_00597565_caseD_3;

  case 5:

  case 0x27:

    if (param_3 < 0x10) {

      return false;

    }

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

    iVar3 = *param_2;

    *param_2 = iVar3 + 4;

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

    break;

  case 0xc:

  case 0xd:

  case 0x16:

  case 0x17:

  case 0x1b:

  case 0x1c:

  case 0x1d:

  case 0x1e:

  case 0x1f:

  case 0x20:

  case 0x21:

  case 0x22:

  case 0x23:

  case 0x24:

  case 0x25:

  case 0x26:

    FUN_004fd460(param_2,param_3);

    goto switchD_00597565_caseD_3;

  case 0xf:

    if (param_3 < 0x10) {

      return false;

    }

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

    iVar3 = *param_2;

    *param_2 = iVar3 + 4;

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

  }

  *param_2 = *param_2 + 4;

switchD_00597565_caseD_3:

  iVar3 = (**(code **)(*(int *)(param_1 + 0x28) + 0x10))(param_2,param_3);

  return iVar3 != 0;

}





// --- FUN_00597630 at 0x00597630 (size: 49) ---


undefined4 __thiscall FUN_00597630(undefined4 param_1,int param_2)



{

  int iVar1;

  

  FUN_005974a0();

  for (iVar1 = *(int *)(param_2 + 4); (iVar1 != 0 && (FUN_005971f0(iVar1), iVar1 != 0));

      iVar1 = *(int *)(iVar1 + 0x128)) {

  }

  return param_1;

}





// --- FUN_00597720 at 0x00597720 (size: 42) ---


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



{

  *param_1 = &PTR_FUN_007e58a4;

  FUN_005974a0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00597750 at 0x00597750 (size: 99) ---


undefined4 * __fastcall FUN_00597750(undefined4 *param_1)



{

  LONG *lpAddend;

  

  *param_1 = &PTR_FUN_007e58b8;

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

  param_1[4] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[10] = &PTR_FUN_007e58a4;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = DAT_00872080;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  FUN_004034c0(&DAT_007938af);

  param_1[8] = 0;

  param_1[9] = 0;

  return param_1;

}





// --- FUN_005977c0 at 0x005977C0 (size: 70) ---


void __fastcall FUN_005977c0(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  *param_1 = &PTR_FUN_007e58b8;

  param_1[10] = &PTR_FUN_007e58a4;

  FUN_005974a0();

  param_1[10] = &PTR_FUN_0079385c;

  puVar1 = (undefined4 *)param_1[4];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_00597810 at 0x00597810 (size: 131) ---


int __thiscall FUN_00597810(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  

  if (param_1 != param_2) {

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

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

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

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

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

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

    FUN_00597630(param_2 + 0x28);

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

    if (puVar1 != *(undefined4 **)(param_2 + 0x10)) {

      LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

      }

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

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

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

    }

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

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

  }

  return param_1;

}





// --- FUN_005978a0 at 0x005978A0 (size: 90) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  

  *param_1 = &PTR_FUN_007e58b8;

  param_1[10] = &PTR_FUN_007e58a4;

  FUN_005974a0();

  param_1[10] = &PTR_FUN_0079385c;

  puVar1 = (undefined4 *)param_1[4];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00597900 at 0x00597900 (size: 65) ---


undefined4 * __thiscall FUN_00597900(undefined4 *param_1,undefined4 param_2)



{

  LONG *lpAddend;

  

  *param_1 = &PTR_FUN_007e58b8;

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

  param_1[4] = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[10] = &PTR_FUN_007e58a4;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  FUN_00597810(param_2);

  return param_1;

}





// --- FUN_00597950 at 0x00597950 (size: 51) ---


undefined4 __fastcall FUN_00597950(int param_1)



{

  switch(*(undefined4 *)(param_1 + 0xc)) {

  case 1:

    return 0x22;

  case 2:

    return 0x21;

  case 3:

    return 0x20;

  case 4:

    return 0x1f;

  case 5:

    return 0x2b;

  default:

    return 0;

  }

}





// --- FUN_005979a0 at 0x005979A0 (size: 34) ---


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



float10 FUN_005979a0(void)



{

  int iVar1;

  float10 fVar2;

  

  iVar1 = FUN_00424150();

  if (iVar1 != 0) {

    fVar2 = (float10)FUN_00599730();

    return fVar2;

  }

  return (float10)_DAT_007e58d0;

}





// --- FUN_005979d0 at 0x005979D0 (size: 302) ---


int __thiscall FUN_005979d0(int param_1,int param_2)



{

  undefined4 *puVar1;

  int iVar2;

  LONG LVar3;

  

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

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

    LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

    }

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

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

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

  }

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

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

    LVar3 = InterlockedDecrement(puVar1 + 1);

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

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

    }

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

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

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

  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  *(undefined8 *)(param_1 + 0x70) = *(undefined8 *)(param_2 + 0x70);

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

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

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

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

  FUN_005998c0(param_2 + 0x84);

  return param_1;

}





// --- FUN_00597b00 at 0x00597B00 (size: 98) ---


int __fastcall FUN_00597b00(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 local_4;

  

  local_4 = 0;

  iVar1 = FUN_004fd290(&local_4,0);

  iVar2 = FUN_004fd290(&local_4,0);

  iVar3 = (**(code **)(*(int *)(param_1 + 0x3c) + 0xc))(&local_4,0);

  iVar4 = (**(code **)(*(int *)(param_1 + 0x84) + 0xc))(&stack0xfffffff4,0);

  return iVar4 + 0x50 + iVar1 + iVar2 + iVar3;

}





// --- FUN_00597cd0 at 0x00597CD0 (size: 98) ---


undefined4 * __thiscall FUN_00597cd0(undefined4 *param_1,undefined4 param_2)



{

  LONG *pLVar1;

  int iVar2;

  undefined4 *puVar3;

  

  *param_1 = &PTR_FUN_007a4ee4;

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

  param_1[1] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

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

  param_1[2] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  param_1[0xf] = &PTR_FUN_007a4adc;

  puVar3 = param_1 + 0x10;

  for (iVar2 = 8; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar3 = 0;

    puVar3 = puVar3 + 1;

  }

  FUN_00599710();

  FUN_005979d0(param_2);

  return param_1;

}





// --- FUN_00597d40 at 0x00597D40 (size: 111) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  byte *pbVar3;

  LONG LVar4;

  

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

  InterlockedIncrement(puVar1 + 1);

  FUN_00411870();

  iVar2 = puVar1[2];

  for (pbVar3 = (byte *)(puVar1 + 5); pbVar3 != (byte *)(iVar2 + 0x13 + (int)puVar1);

      pbVar3 = pbVar3 + 1) {

    *pbVar3 = *pbVar3 >> 4 | *pbVar3 << 4;

  }

  *param_2 = (int)puVar1;

  InterlockedIncrement(puVar1 + 1);

  LVar4 = InterlockedDecrement(puVar1 + 1);

  if (LVar4 == 0) {

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

  }

  return param_2;

}





// --- FUN_00597db0 at 0x00597DB0 (size: 111) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  byte *pbVar3;

  LONG LVar4;

  

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

  InterlockedIncrement(puVar1 + 1);

  FUN_00411870();

  iVar2 = puVar1[2];

  for (pbVar3 = (byte *)(puVar1 + 5); pbVar3 != (byte *)(iVar2 + 0x13 + (int)puVar1);

      pbVar3 = pbVar3 + 1) {

    *pbVar3 = *pbVar3 >> 4 | *pbVar3 << 4;

  }

  *param_2 = (int)puVar1;

  InterlockedIncrement(puVar1 + 1);

  LVar4 = InterlockedDecrement(puVar1 + 1);

  if (LVar4 == 0) {

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

  }

  return param_2;

}





// --- FUN_00597e20 at 0x00597E20 (size: 326) ---


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



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  byte *pbVar3;

  uint uVar4;

  uint uVar5;

  LONG LVar6;

  int iVar7;

  undefined4 *puVar8;

  undefined4 *puVar9;

  undefined4 local_20 [8];

  

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

  InterlockedIncrement(puVar1 + 1);

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

  InterlockedIncrement(puVar2 + 1);

  FUN_00411870();

  iVar7 = puVar1[2];

  for (pbVar3 = (byte *)(puVar1 + 5); pbVar3 != (byte *)(iVar7 + 0x13 + (int)puVar1);

      pbVar3 = pbVar3 + 1) {

    *pbVar3 = *pbVar3 >> 4 | *pbVar3 << 4;

  }

  FUN_00411870();

  iVar7 = puVar2[2];

  for (pbVar3 = (byte *)(puVar2 + 5); pbVar3 != (byte *)(iVar7 + 0x13 + (int)puVar2);

      pbVar3 = pbVar3 + 1) {

    *pbVar3 = *pbVar3 >> 4 | *pbVar3 << 4;

  }

  uVar4 = puVar1[4];

  if (uVar4 == 0xffffffff) {

    uVar4 = FUN_004fe440();

    puVar1[4] = uVar4;

  }

  uVar5 = puVar2[4];

  if (uVar5 == 0xffffffff) {

    uVar5 = FUN_004fe440();

    puVar2[4] = uVar5;

  }

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

  puVar9 = local_20;

  for (iVar7 = 8; iVar7 != 0; iVar7 = iVar7 + -1) {

    *puVar9 = *puVar8;

    puVar8 = puVar8 + 1;

    puVar9 = puVar9 + 1;

  }

  FUN_005bdac0(uVar5 % 0xbeadcf45 + uVar4 % 0x12107680);

  puVar9 = local_20;

  puVar8 = param_2;

  for (iVar7 = 8; puVar8 = puVar8 + 1, iVar7 != 0; iVar7 = iVar7 + -1) {

    *puVar8 = *puVar9;

    puVar9 = puVar9 + 1;

  }

  *param_2 = &PTR_FUN_007a4adc;

  LVar6 = InterlockedDecrement(puVar2 + 1);

  if (LVar6 == 0) {

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

  }

  LVar6 = InterlockedDecrement(puVar1 + 1);

  if (LVar6 == 0) {

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

  }

  return param_2;

}





// --- FUN_00597f70 at 0x00597F70 (size: 67) ---


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



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined1 local_24 [4];

  undefined4 local_20 [8];

  

  FUN_00597e20(local_24);

  FUN_005be120(param_3,*(undefined4 *)(param_1 + 0x34));

  puVar2 = local_20;

  puVar3 = param_2;

  for (iVar1 = 8; puVar3 = puVar3 + 1, iVar1 != 0; iVar1 = iVar1 + -1) {

    *puVar3 = *puVar2;

    puVar2 = puVar2 + 1;

  }

  *param_2 = &PTR_FUN_007a4adc;

  return;

}





// --- FUN_00597fc0 at 0x00597FC0 (size: 233) ---


void FUN_00597fc0(undefined4 *param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  undefined4 local_4c;

  undefined **local_48;

  undefined4 local_44 [8];

  undefined1 local_24 [4];

  int aiStack_20 [8];

  

  FUN_00597e20(local_24);

  local_48 = &PTR_FUN_007a4adc;

  puVar5 = local_44;

  for (iVar2 = 8; iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar5 = 0;

    puVar5 = puVar5 + 1;

  }

  iVar2 = 0;

  iVar3 = 0;

  do {

    if (((iVar3 < 0) || (7 < iVar3)) || (iVar1 = aiStack_20[iVar3], iVar1 == 0)) break;

    switch(iVar1) {

    case 1:

    case 2:

    case 3:

    case 4:

    case 5:

    case 6:

    case 0x6e:

    case 0x6f:

    case 0x70:

    case 0xc0:

    case 0xc1:

      FUN_005bd970(iVar2,iVar1);

      iVar2 = iVar2 + 1;

    }

    iVar3 = iVar3 + 1;

  } while (iVar3 < 8);

  local_4c = 0;

  FUN_005bda20(&local_4c);

  switch(local_4c) {

  case 1:

    iVar3 = 1;

    break;

  case 2:

    iVar3 = 2;

    break;

  case 3:

  case 4:

  case 7:

    iVar3 = 3;

    break;

  case 5:

  case 6:

  case 8:

  case 9:

  case 10:

    iVar3 = 4;

    break;

  default:

    iVar3 = 0;

  }

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

    FUN_005bd970(iVar2,0xbc);

    iVar2 = iVar2 + 1;

  }

  puVar4 = local_44;

  puVar5 = param_1;

  for (iVar2 = 8; puVar5 = puVar5 + 1, iVar2 != 0; iVar2 = iVar2 + -1) {

    *puVar5 = *puVar4;

    puVar4 = puVar4 + 1;

  }

  *param_1 = &PTR_FUN_007a4adc;

  return;

}





// --- FUN_005981a0 at 0x005981A0 (size: 43) ---


void FUN_005981a0(void)



{

  int iVar1;

  undefined1 local_24 [36];

  

  FUN_00597e20(local_24);

  iVar1 = FUN_005bd950();

  if (iVar1 == 0) {

    return;

  }

  FUN_005bd9e0();

  return;

}





// --- FUN_005981d0 at 0x005981D0 (size: 42) ---


uint FUN_005981d0(void)



{

  uint uVar1;

  undefined1 local_24 [36];

  

  FUN_00597e20(local_24);

  uVar1 = FUN_005bda10();

  if (6 < uVar1) {

    if (uVar1 < 9) {

      return uVar1 - 1;

    }

    uVar1 = uVar1 - 2;

  }

  return uVar1;

}





// --- FUN_00598200 at 0x00598200 (size: 365) ---


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



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 *puVar5;

  

  iVar1 = *param_2;

  uVar4 = FUN_00597b00();

  if (uVar4 <= param_3) {

    FUN_004fd460(param_2,param_3);

    FUN_004fd460(param_2,param_3);

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

    iVar2 = *param_2;

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

    *param_2 = (int)puVar5;

    uVar3 = *puVar5;

    *param_2 = iVar2 + 8;

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

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x30) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x34) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x38) = *(undefined4 *)(iVar2 + 4);

    *param_2 = *param_2 + 4;

    (**(code **)(*(int *)(param_1 + 0x84) + 0x10))(param_2,param_3);

    (**(code **)(*(int *)(param_1 + 0x3c) + 0x10))(param_2,param_3);

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 100) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x68) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

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

    *param_2 = (int)puVar5;

    *(undefined4 *)(param_1 + 0x70) = *puVar5;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 8;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x7c) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    *(undefined4 *)(param_1 + 0x80) = *(undefined4 *)(iVar2 + 4);

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

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

    iVar2 = *param_2;

    *param_2 = iVar2 + 4;

    if ((uint)((iVar2 + 4) - iVar1) <= param_3) {

      return 1;

    }

    *param_2 = iVar1;

  }

  return 0;

}





// --- FUN_00598370 at 0x00598370 (size: 139) ---


undefined4 * FUN_00598370(undefined4 *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  LONG LVar2;

  char *pcVar3;

  

  puVar1 = DAT_008ef11c;

  InterlockedIncrement(DAT_008ef11c + 1);

  switch(param_2) {

  case 1:

    pcVar3 = "War Magic";

    break;

  case 2:

    pcVar3 = "Life Magic";

    break;

  case 3:

    pcVar3 = "Item Enchantment";

    break;

  case 4:

    pcVar3 = "Creature Enchantment";

    break;

  case 5:

    pcVar3 = "Void Magic";

    break;

  default:

    pcVar3 = "None";

  }

  FUN_004034c0(pcVar3);

  *param_1 = puVar1;

  InterlockedIncrement(puVar1 + 1);

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return param_1;

}





// --- FUN_00598410 at 0x00598410 (size: 31) ---


bool FUN_00598410(void)



{

  int iVar1;

  undefined1 local_24 [36];

  

  FUN_00597e20(local_24);

  iVar1 = FUN_005bd9e0();

  return iVar1 == 0;

}





// --- FUN_00598550 at 0x00598550 (size: 87) ---


void __thiscall FUN_00598550(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

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

  uVar5 = 0;

  if (uVar1 != 0) {

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

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007e5930;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

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

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007e5930;

  param_2[3] = uVar1;

  return;

}





// --- FUN_005985b0 at 0x005985B0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007e594c;

  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_00598680 at 0x00598680 (size: 94) ---


int __fastcall FUN_00598680(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 + 0x98)) {

        iVar2 = (**(code **)(*(int *)(iVar1 + 8) + 0xc))(&local_4,0);

        iVar4 = iVar4 + 4 + iVar2;

      }

      uVar3 = uVar3 + 1;

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

  }

  return iVar4;

}





// --- FUN_00598760 at 0x00598760 (size: 209) ---


void __fastcall FUN_00598760(int param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  void *pvVar3;

  LONG LVar4;

  uint local_8;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_8 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar3 = *(void **)(*(int *)(param_1 + 8) + local_8 * 4);

      while (pvVar3 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar3 + 0x98);

        FUN_00599890();

        puVar2 = *(undefined4 **)((int)pvVar3 + 0x10);

        *(undefined ***)((int)pvVar3 + 0x44) = &PTR_FUN_0079385c;

        LVar4 = InterlockedDecrement(puVar2 + 1);

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

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

        }

        puVar2 = *(undefined4 **)((int)pvVar3 + 0xc);

        LVar4 = InterlockedDecrement(puVar2 + 1);

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

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

        }

        *(undefined ***)((int)pvVar3 + 8) = &PTR_FUN_0079385c;

        operator_delete(pvVar3);

        pvVar3 = pvVar1;

      }

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

      local_8 = local_8 + 1;

    } while (local_8 < *(uint *)(param_1 + 0xc));

  }

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

  return;

}





// --- FUN_005989a0 at 0x005989A0 (size: 170) ---


undefined4 __thiscall FUN_005989a0(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[0x26]) {

      if (*param_2 == *puVar1) {

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

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0xa0);

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

    return 0;

  }

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

  *puVar1 = *param_2;

  FUN_00597cd0(param_3);

  puVar1[0x26] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[0x27] = uVar2;

  puVar1[0x26] = *(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_00598a50 at 0x00598A50 (size: 72) ---


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



{

  *param_1 = &PTR_FUN_007e5938;

  FUN_00598760();

  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_00598aa0 at 0x00598AA0 (size: 143) ---


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

  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_00598b30 at 0x00598B30 (size: 59) ---


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



{

  param_1[6] = &PTR_LAB_007a5164;

  param_1[6] = &PTR_FUN_0079385c;

  param_1[2] = &PTR_FUN_007a5160;

  FUN_0049f850();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00598b70 at 0x00598B70 (size: 114) ---


undefined4 __fastcall FUN_00598b70(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

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

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

    return 0;

  }

  iVar2 = puVar1[7];

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

  if (iVar2 == 0) {

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

  }

  else {

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

  }

  FUN_005c7ff0(puVar1);

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

    puVar1[6] = &PTR_LAB_007a5164;

    puVar1[6] = &PTR_FUN_0079385c;

    puVar1[2] = &PTR_FUN_007a5160;

    FUN_0049f850();

    *puVar1 = &PTR_FUN_0079385c;

    operator_delete(puVar1);

  }

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

  return 1;

}





// --- FUN_00598bf0 at 0x00598BF0 (size: 165) ---


void __fastcall FUN_00598bf0(int param_1)



{

  void *pvVar1;

  undefined **local_1c;

  undefined4 local_18;

  undefined **local_14;

  void *local_10;

  undefined4 local_c;

  int local_8;

  undefined **local_4;

  

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

    local_1c = &PTR_FUN_007e5950;

    local_18 = 0;

    local_10 = (void *)0x0;

    local_c = 0;

    local_8 = 0;

    local_14 = &PTR_FUN_007a83d8;

    local_4 = &PTR_LAB_007a5164;

    FUN_00598b70(&local_1c);

    local_4 = &PTR_FUN_0079385c;

    local_14 = &PTR_FUN_007a5160;

    pvVar1 = local_10;

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

      local_10 = *(void **)((int)pvVar1 + 4);

      if (local_10 == (void *)0x0) {

        local_c = 0;

      }

      else {

        *(undefined4 *)((int)local_10 + 8) = 0;

      }

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

        operator_delete(pvVar1);

      }

      local_8 = local_8 + -1;

      pvVar1 = local_10;

    }

  }

  return;

}





// --- FUN_00598cb0 at 0x00598CB0 (size: 73) ---


uint __thiscall FUN_00598cb0(int *param_1,int *param_2,uint param_3)



{

  int *piVar1;

  uint uVar2;

  

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

  if (uVar2 <= param_3) {

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

    *param_2 = *param_2 + 4;

    for (piVar1 = (int *)param_1[-3]; piVar1 != (int *)0x0; piVar1 = (int *)piVar1[7]) {

      (**(code **)(*piVar1 + 0xc))(param_2,param_3);

    }

  }

  return uVar2;

}





// --- FUN_00598d54 at 0x00598D54 (size: 225) ---


undefined4 FUN_00598d54(void)



{

  int iVar1;

  uint uVar2;

  int *piVar3;

  uint uVar4;

  int iVar5;

  int *in_stack_00000020;

  uint in_stack_00000024;

  

  piVar3 = in_stack_00000020;

  iVar1 = *in_stack_00000020;

  FUN_00598bf0();

  uVar2 = *(uint *)*in_stack_00000020;

  *in_stack_00000020 = (int)((uint *)*in_stack_00000020 + 1);

  in_stack_00000020 = (int *)0x0;

  if (uVar2 != 0) {

    do {

      iVar5 = 0;

      uVar4 = *piVar3 - iVar1;

      if (uVar4 < in_stack_00000024) {

        iVar5 = in_stack_00000024 - uVar4;

      }

      iVar5 = (*(code *)PTR_FUN_007e5960)(piVar3,iVar5);

      if ((iVar5 == 0) || (iVar5 = FUN_00598e40(&stack0x00000000), iVar5 == 0)) {

        FUN_0049f850();

        return 0;

      }

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

    } while (in_stack_00000020 < uVar2);

  }

  FUN_0049f850();

  return 1;

}





// --- FUN_00598e40 at 0x00598E40 (size: 112) ---


undefined4 __thiscall FUN_00598e40(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

  iVar2 = FUN_005df0f5(0x24);

  if (iVar2 == 0) {

    return 0;

  }

  FUN_005be2c0(param_2);

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

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

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

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

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

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

    return 1;

  }

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

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

  *(int *)(iVar2 + 0x20) = iVar1;

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

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

  return 1;

}





// --- FUN_00598eb0 at 0x00598EB0 (size: 36) ---


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



{

  *param_1 = &PTR_FUN_007e5934;

  FUN_00598bf0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00598ee0 at 0x00598EE0 (size: 50) ---


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



{

  param_1[4] = &PTR_LAB_007e5968;

  param_1[4] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007e5934;

  FUN_00598bf0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00598f20 at 0x00598F20 (size: 41) ---


void __fastcall FUN_00598f20(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5980;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = &PTR_FUN_0079385c;

  param_1[1] = &PTR_FUN_007e597c;

  param_1[5] = &PTR_LAB_007e5968;

  return;

}





// --- FUN_00598f50 at 0x00598F50 (size: 59) ---


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



{

  param_1[5] = &PTR_LAB_007e5968;

  param_1[5] = &PTR_FUN_0079385c;

  param_1[1] = &PTR_FUN_007e5934;

  FUN_00598bf0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00598f90 at 0x00598F90 (size: 160) ---


void __fastcall FUN_00598f90(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

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

  do {

    if (iVar1 == 0) {

      return;

    }

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

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

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

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

        pvVar5 = (void *)*piVar4;

        goto LAB_00598fd2;

      }

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

      *(int **)(param_1 + 100) = piVar4;

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_00598fd2:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_00598fe5:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

        pvVar3 = *(void **)((int)pvVar2 + 4);

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_00598fe5;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

    *(int *)(param_1 + 0x6c) = *(int *)(param_1 + 0x6c) + -1;

    if (pvVar5 != (void *)0x0) {

      *(undefined ***)((int)pvVar5 + 0x1c) = &PTR_LAB_007e5968;

      *(undefined ***)((int)pvVar5 + 0x1c) = &PTR_FUN_0079385c;

      *(undefined ***)((int)pvVar5 + 0xc) = &PTR_FUN_007e5934;

      FUN_00598bf0();

      *(undefined ***)((int)pvVar5 + 8) = &PTR_FUN_0079385c;

      operator_delete(pvVar5);

    }

    iVar1 = *(int *)(param_1 + 0x6c);

  } while( true );

}





// --- FUN_00599030 at 0x00599030 (size: 82) ---


undefined4 * __thiscall FUN_00599030(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e5964;

  FUN_00598f90();

  param_1[1] = &PTR_FUN_007e594c;

  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_005990a0 at 0x005990A0 (size: 504) ---


/* WARNING: Removing unreachable block (ram,0x00599169) */

/* WARNING: Removing unreachable block (ram,0x0059917d) */

/* WARNING: Removing unreachable block (ram,0x00599198) */



undefined4 __thiscall FUN_005990a0(int param_1,uint param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  undefined4 uVar2;

  uint uVar3;

  int iVar4;

  int iVar5;

  uint uVar6;

  undefined1 local_c [12];

  

  uVar3 = param_2;

  if (param_2 == 2) {

    FUN_00598f90();

    iVar1 = FUN_005413a0(2,&param_2,param_3,param_4);

    if (iVar1 != 0) {

      uVar3 = param_2 >> 0x18;

      if (DAT_007956cc <= uVar3) {

        uVar3 = DAT_007956cc - 1;

      }

      uVar2 = FUN_006b3a50(*(undefined4 *)(PTR_DAT_00818554 + uVar3 * 4));

      FUN_0046c280(uVar2);

      uVar6 = param_2 & 0xffffff;

      uVar3 = 0;

      iVar1 = 0;

      if (uVar6 != 0) {

        do {

          iVar4 = FUN_005df0f5(0x20);

          if (iVar4 == 0) {

            iVar4 = 0;

          }

          else {

            *(undefined4 *)(iVar4 + 4) = 0;

            FUN_00598f20();

          }

          iVar5 = FUN_005413a0(2,iVar4,param_3,param_4);

          if (iVar5 == 0) {

            return 0;

          }

          iVar5 = FUN_005992a0(2,iVar4 + 8,param_3,param_4);

          if (iVar5 == 0) {

            return 0;

          }

          FUN_00599310(iVar4,iVar1);

          uVar3 = uVar3 + 1;

          iVar1 = iVar4;

        } while (uVar3 < uVar6);

      }

      return 1;

    }

  }

  else {

    uVar6 = *(uint *)(param_1 + -4);

    if (uVar6 < 0x1000000) {

      param_2 = uVar6;

      iVar1 = FUN_006b3a20(*(undefined4 *)(param_1 + -8));

      param_2 = uVar6 | (iVar1 - (int)PTR_DAT_00818554 >> 2) << 0x18;

      iVar1 = FUN_005413a0(uVar3,&param_2,param_3,param_4);

      if (iVar1 != 0) {

        uVar2 = FUN_0052dcf0(local_c);

        FUN_006b3f40(uVar2);

        uVar2 = FUN_006b3f60(local_c);

        FUN_006b3f40(uVar2);

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_005992a0 at 0x005992A0 (size: 111) ---


undefined4 FUN_005992a0(int param_1,int *param_2,int *param_3,int *param_4)



{

  undefined4 uVar1;

  int iVar2;

  

  if (param_1 == 0) {

    iVar2 = (**(code **)(*param_2 + 8))();

    *param_4 = *param_4 - iVar2;

    return 1;

  }

  if (param_1 != 1) {

    if (param_1 != 2) {

      return 0;

    }

    iVar2 = *param_3;

    uVar1 = (**(code **)(*param_2 + 0x10))(param_3,*param_4);

    *param_4 = *param_4 + (iVar2 - *param_3);

    return uVar1;

  }

  iVar2 = (**(code **)(*param_2 + 0xc))(param_3,*param_4);

  *param_4 = *param_4 - iVar2;

  return 1;

}





// --- FUN_00599310 at 0x00599310 (size: 99) ---


int __thiscall FUN_00599310(int param_1,uint *param_2,uint *param_3)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  

  uVar2 = *(uint *)(param_1 + 0x68);

  uVar4 = *param_2 % uVar2;

  if (param_3 != (uint *)0x0) {

    uVar5 = *param_3 % uVar2;

    if (uVar4 == uVar5) {

      param_3[1] = (uint)param_2;

      iVar3 = *(int *)(param_1 + 0x6c) + 1;

      *(int *)(param_1 + 0x6c) = iVar3;

      return CONCAT31((int3)((uint)iVar3 >> 8),1);

    }

    if (uVar4 <= uVar5) {

      return (uint)(uint3)((ulonglong)*param_3 / (ulonglong)uVar2 >> 8) << 8;

    }

  }

  puVar1 = (undefined4 *)(*(int *)(param_1 + 0x60) + uVar4 * 4);

  *puVar1 = param_2;

  if (param_3 == (uint *)0x0) {

    *(undefined4 **)(param_1 + 100) = puVar1;

  }

  iVar3 = *(int *)(param_1 + 0x6c) + 1;

  *(int *)(param_1 + 0x6c) = iVar3;

  return CONCAT31((int3)((uint)iVar3 >> 8),1);

}





// --- FUN_00599380 at 0x00599380 (size: 96) ---


undefined4 * __thiscall FUN_00599380(undefined4 *param_1,byte param_2)



{

  param_1[0x1d] = &PTR_LAB_007e5994;

  param_1[0x1d] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_007e5964;

  FUN_00598f90();

  param_1[1] = &PTR_FUN_007e594c;

  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_005993e0 at 0x005993E0 (size: 115) ---


undefined4 * __thiscall FUN_005993e0(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007e59c8;

  param_1[0xc] = &PTR_LAB_007e59b0;

  param_1[0xe] = &PTR_FUN_007e5938;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0x2000;

  param_1[0x12] = 0;

  FUN_005a8440();

  param_1[0x13] = &PTR_FUN_007e5964;

  FUN_00598aa0(0x17);

  param_1[0x30] = &PTR_FUN_007cab80;

  param_1[0x13] = &PTR_FUN_007e59ac;

  param_1[0x30] = &PTR_LAB_007e5994;

  return param_1;

}





// --- FUN_00599470 at 0x00599470 (size: 30) ---


void * __thiscall FUN_00599470(void *param_1,byte param_2)



{

  FUN_00599490();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00599490 at 0x00599490 (size: 155) ---


void __fastcall FUN_00599490(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007e59c8;

  param_1[0xc] = &PTR_LAB_007e59b0;

  param_1[0x30] = &PTR_LAB_007e5994;

  param_1[0x30] = &PTR_FUN_0079385c;

  param_1[0x13] = &PTR_FUN_007e5964;

  FUN_00598f90();

  param_1[0x14] = &PTR_FUN_007e594c;

  if ((undefined4 *)param_1[0x2c] != param_1 + 0x15) {

    operator_delete__((undefined4 *)param_1[0x2c]);

  }

  param_1[0x2c] = 0;

  param_1[0x2d] = 0;

  param_1[0x2e] = 0;

  param_1[0x2f] = 0;

  param_1[0xe] = &PTR_FUN_007e5938;

  FUN_00598760();

  if ((void *)param_1[0x10] != (void *)0x0) {

    operator_delete__((void *)param_1[0x10]);

    param_1[0x10] = 0;

  }

  param_1[0x11] = 0;

  param_1[0xe] = &PTR_FUN_0079385c;

  param_1[0xc] = &PTR_FUN_0079385c;

  FUN_004154b0();

  return;

}





// --- FUN_00599540 at 0x00599540 (size: 375) ---


undefined4 FUN_00599540(undefined4 param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  switch(param_1) {

  case 1:

    iVar1 = FUN_005df0f5(0x58);

    if (iVar1 != 0) {

      uVar2 = FUN_00599b60();

      return uVar2;

    }

    break;

  case 2:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599e50();

      return uVar2;

    }

    break;

  case 3:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599d30();

      return uVar2;

    }

    break;

  case 4:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_0059a020();

      return uVar2;

    }

    break;

  case 5:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599a20();

      return uVar2;

    }

    break;

  case 6:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599a20();

      return uVar2;

    }

    break;

  case 7:

    iVar1 = FUN_005df0f5(0x10);

    if (iVar1 != 0) {

      uVar2 = FUN_00599ec0();

      return uVar2;

    }

    break;

  case 8:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599a20();

      return uVar2;

    }

    break;

  case 9:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_005999c0();

      return uVar2;

    }

    break;

  case 10:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599e70();

      return uVar2;

    }

    break;

  case 0xb:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599d50();

      return uVar2;

    }

    break;

  case 0xc:

    iVar1 = FUN_005df0f5(0x58);

    if (iVar1 != 0) {

      uVar2 = FUN_00599cd0();

      return uVar2;

    }

    break;

  case 0xd:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599a60();

      return uVar2;

    }

    break;

  case 0xe:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599a00();

      return uVar2;

    }

    break;

  case 0xf:

    iVar1 = FUN_005df0f5(8);

    if (iVar1 != 0) {

      uVar2 = FUN_00599e90();

      return uVar2;

    }

  }

  return 0;

}





// --- FUN_00599700 at 0x00599700 (size: 15) ---


void __thiscall FUN_00599700(int param_1,int param_2)



{

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_2 + 4);

  return;

}





// --- FUN_00599710 at 0x00599710 (size: 17) ---


void __fastcall FUN_00599710(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5a60;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_00599730 at 0x00599730 (size: 19) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_00599730(int param_1)



{

  float10 fVar1;

  

  if (*(int **)(param_1 + 8) != (int *)0x0) {

                    /* WARNING: Could not recover jumptable at 0x00599739. Too many branches */

                    /* WARNING: Treating indirect jump as call */

    fVar1 = (float10)(**(code **)(**(int **)(param_1 + 8) + 0x1c))();

    return fVar1;

  }

  return (float10)_DAT_007e5a58;

}





// --- FUN_005997b0 at 0x005997B0 (size: 105) ---


undefined4 __thiscall FUN_005997b0(int param_1,int *param_2,uint param_3)



{

  int *piVar1;

  undefined4 uVar2;

  

  if (param_3 < 4) {

    return 0;

  }

  if (*(undefined4 **)(param_1 + 8) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 8))(1);

    *(undefined4 *)(param_1 + 8) = 0;

  }

  *(undefined4 *)(param_1 + 4) = 0;

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)*param_2;

  *param_2 = *param_2 + 4;

  piVar1 = (int *)FUN_00599540(*(undefined4 *)(param_1 + 4));

  *(int **)(param_1 + 8) = piVar1;

  if (piVar1 == (int *)0x0) {

    return 0;

  }

  uVar2 = (**(code **)(*piVar1 + 0x10))(param_2,param_3 - 4);

  return uVar2;

}





// --- FUN_00599820 at 0x00599820 (size: 16) ---


void __fastcall FUN_00599820(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5a78;

  param_1[1] = 0;

  return;

}





// --- FUN_00599840 at 0x00599840 (size: 32) ---


void __thiscall FUN_00599840(int *param_1,int *param_2,uint param_3)



{

  uint uVar1;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (uVar1 <= param_3) {

    *(int *)*param_2 = param_1[1];

    *param_2 = *param_2 + 4;

  }

  return;

}





// --- FUN_00599860 at 0x00599860 (size: 43) ---


undefined4 __thiscall FUN_00599860(int *param_1,int *param_2,uint param_3)



{

  uint uVar1;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (param_3 < uVar1) {

    return 0;

  }

  param_1[1] = *(int *)*param_2;

  *param_2 = *param_2 + 4;

  return 1;

}





// --- FUN_00599890 at 0x00599890 (size: 44) ---


void __fastcall FUN_00599890(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e5a60;

  if ((undefined4 *)param_1[2] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[2])(1);

    param_1[2] = 0;

  }

  param_1[1] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_005998c0 at 0x005998C0 (size: 90) ---


int __thiscall FUN_005998c0(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  

  if (*(undefined4 **)(param_1 + 8) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 8))(1);

    *(undefined4 *)(param_1 + 8) = 0;

  }

  *(undefined4 *)(param_1 + 4) = 0;

  iVar1 = *(int *)(param_2 + 4);

  *(int *)(param_1 + 4) = iVar1;

  if (iVar1 != 0) {

    piVar2 = (int *)FUN_00599540(iVar1);

    *(int **)(param_1 + 8) = piVar2;

    (**(code **)(*piVar2 + 0x18))(piVar2,*(undefined4 *)(param_2 + 8));

    return param_1;

  }

  *(undefined4 *)(param_1 + 8) = 0;

  return param_1;

}





// --- FUN_00599920 at 0x00599920 (size: 64) ---


undefined4 * __thiscall FUN_00599920(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e5a60;

  if ((undefined4 *)param_1[2] != (undefined4 *)0x0) {

    (*(code *)**(undefined4 **)param_1[2])(1);

    param_1[2] = 0;

  }

  param_1[1] = 0;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00599960 at 0x00599960 (size: 39) ---


uint __thiscall FUN_00599960(int *param_1,undefined4 param_2,uint param_3)



{

  uint uVar1;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (uVar1 <= param_3) {

    FUN_00599840(param_2,param_3);

  }

  return uVar1;

}





// --- FUN_00599990 at 0x00599990 (size: 45) ---


bool __thiscall FUN_00599990(int *param_1,undefined4 param_2,uint param_3)



{

  uint uVar1;

  int iVar2;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (param_3 < uVar1) {

    return false;

  }

  iVar2 = FUN_00599860(param_2,param_3);

  return iVar2 != 0;

}





// --- FUN_005999c0 at 0x005999C0 (size: 18) ---


undefined4 * __fastcall FUN_005999c0(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5ad0;

  return param_1;

}





// --- FUN_00599a00 at 0x00599A00 (size: 18) ---


undefined4 * __fastcall FUN_00599a00(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5b20;

  return param_1;

}





// --- FUN_00599a20 at 0x00599A20 (size: 18) ---


undefined4 * __fastcall FUN_00599a20(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5ed8;

  return param_1;

}





// --- FUN_00599a60 at 0x00599A60 (size: 18) ---


undefined4 * __fastcall FUN_00599a60(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5bb0;

  return param_1;

}





// --- FUN_00599a80 at 0x00599A80 (size: 135) ---


int __thiscall FUN_00599a80(int param_1,int param_2)



{

  FUN_00599700(param_2);

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_2 + 8);

  *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

  *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(param_2 + 0x10);

  *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)(param_2 + 0x14);

  *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(param_2 + 0x18);

  *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(param_2 + 0x1c);

  *(undefined4 *)(param_1 + 0x20) = *(undefined4 *)(param_2 + 0x20);

  *(undefined4 *)(param_1 + 0x24) = *(undefined4 *)(param_2 + 0x24);

  *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(param_2 + 0x28);

  *(undefined4 *)(param_1 + 0x2c) = *(undefined4 *)(param_2 + 0x2c);

  *(undefined4 *)(param_1 + 0x30) = *(undefined4 *)(param_2 + 0x30);

  *(undefined4 *)(param_1 + 0x34) = *(undefined4 *)(param_2 + 0x34);

  *(undefined4 *)(param_1 + 0x38) = *(undefined4 *)(param_2 + 0x38);

  *(undefined4 *)(param_1 + 0x40) = *(undefined4 *)(param_2 + 0x40);

  *(undefined4 *)(param_1 + 0x44) = *(undefined4 *)(param_2 + 0x44);

  *(undefined4 *)(param_1 + 0x48) = *(undefined4 *)(param_2 + 0x48);

  *(undefined4 *)(param_1 + 0x4c) = *(undefined4 *)(param_2 + 0x4c);

  *(undefined4 *)(param_1 + 0x50) = *(undefined4 *)(param_2 + 0x50);

  *(undefined4 *)(param_1 + 0x54) = *(undefined4 *)(param_2 + 0x54);

  return param_1;

}





// --- FUN_00599b60 at 0x00599B60 (size: 51) ---


undefined4 * __fastcall FUN_00599b60(undefined4 *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  

  FUN_00599820();

  uVar2 = DAT_007e5c0c;

  uVar1 = DAT_007e5c00;

  param_1[2] = DAT_007e5c08;

  *param_1 = &PTR_FUN_007e5c10;

  param_1[3] = uVar2;

  param_1[4] = 0;

  param_1[5] = uVar1;

  return param_1;

}





// --- FUN_00599ba0 at 0x00599BA0 (size: 4) ---


float10 __fastcall FUN_00599ba0(int param_1)



{

  return (float10)*(double *)(param_1 + 8);

}





// --- FUN_00599cd0 at 0x00599CD0 (size: 51) ---


undefined4 * __fastcall FUN_00599cd0(undefined4 *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  

  FUN_00599820();

  uVar2 = DAT_007e5c0c;

  uVar1 = DAT_007e5c00;

  param_1[2] = DAT_007e5c08;

  param_1[3] = uVar2;

  param_1[4] = 0;

  param_1[5] = uVar1;

  *param_1 = &PTR_FUN_007e5c60;

  return param_1;

}





// --- FUN_00599d30 at 0x00599D30 (size: 18) ---


undefined4 * __fastcall FUN_00599d30(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5cb8;

  return param_1;

}





// --- FUN_00599d50 at 0x00599D50 (size: 18) ---


undefined4 * __fastcall FUN_00599d50(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5d10;

  return param_1;

}





// --- FUN_00599d70 at 0x00599D70 (size: 91) ---


undefined4 __thiscall FUN_00599d70(int *param_1,undefined4 *param_2,uint param_3)



{

  undefined4 uVar1;

  undefined4 uVar2;

  uint uVar3;

  int iVar4;

  

  uVar3 = (**(code **)(*param_1 + 0x4c))();

  if (param_3 < uVar3) {

    return 0;

  }

  uVar1 = *param_2;

  uVar3 = (**(code **)(*param_1 + 0x4c))();

  if (uVar3 <= param_3) {

    uVar2 = *param_2;

    iVar4 = FUN_00599860(param_2,param_3);

    if (iVar4 != 0) {

      return 1;

    }

    *param_2 = uVar2;

  }

  *param_2 = uVar1;

  return 0;

}





// --- FUN_00599df0 at 0x00599DF0 (size: 52) ---


uint __thiscall FUN_00599df0(int *param_1,undefined4 param_2,uint param_3)



{

  uint uVar1;

  uint uVar2;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (uVar1 <= param_3) {

    uVar2 = (**(code **)(*param_1 + 0x4c))();

    if (uVar2 <= param_3) {

      FUN_00599840(param_2,param_3);

    }

  }

  return uVar1;

}





// --- FUN_00599e50 at 0x00599E50 (size: 18) ---


undefined4 * __fastcall FUN_00599e50(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5d70;

  return param_1;

}





// --- FUN_00599e70 at 0x00599E70 (size: 18) ---


undefined4 * __fastcall FUN_00599e70(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5dc8;

  return param_1;

}





// --- FUN_00599e90 at 0x00599E90 (size: 18) ---


undefined4 * __fastcall FUN_00599e90(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5e20;

  return param_1;

}





// --- FUN_00599ec0 at 0x00599EC0 (size: 35) ---


undefined4 * __fastcall FUN_00599ec0(undefined4 *param_1)



{

  undefined4 uVar1;

  

  FUN_00599820();

  uVar1 = DAT_007e5e7c;

  param_1[2] = DAT_007e5e78;

  *param_1 = &PTR_FUN_007e5e80;

  param_1[3] = uVar1;

  return param_1;

}





// --- FUN_00599ef0 at 0x00599EF0 (size: 43) ---


void FUN_00599ef0(int param_1,int param_2)



{

  if ((param_1 != 0) && (param_2 != 0)) {

    FUN_00599700(param_2);

    *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_2 + 8);

    *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

  }

  return;

}





// --- FUN_00599f20 at 0x00599F20 (size: 51) ---


uint __thiscall FUN_00599f20(int *param_1,int *param_2,uint param_3)



{

  uint uVar1;

  

  uVar1 = (**(code **)(*param_1 + 0x4c))();

  if (uVar1 <= param_3) {

    FUN_00599840(param_2,param_3);

    *(undefined8 *)*param_2 = *(undefined8 *)(param_1 + 2);

    *param_2 = *param_2 + 8;

  }

  return uVar1;

}





// --- FUN_0059a020 at 0x0059A020 (size: 18) ---


undefined4 * __fastcall FUN_0059a020(undefined4 *param_1)



{

  FUN_00599820();

  *param_1 = &PTR_FUN_007e5f38;

  return param_1;

}





// --- FUN_0059a040 at 0x0059A040 (size: 18) ---


undefined4 * __fastcall FUN_0059a040(undefined4 *param_1)



{

  FUN_005b7670();

  *param_1 = &PTR_FUN_007e5f8c;

  return param_1;

}





// --- FUN_0059a060 at 0x0059A060 (size: 30) ---


void * __thiscall FUN_0059a060(void *param_1,byte param_2)



{

  FUN_005b76c0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059a080 at 0x0059A080 (size: 18) ---


undefined4 * __fastcall FUN_0059a080(undefined4 *param_1)



{

  FUN_005b7c00();

  *param_1 = &PTR_FUN_007e5fd8;

  return param_1;

}





// --- FUN_0059a0a0 at 0x0059A0A0 (size: 30) ---


void * __thiscall FUN_0059a0a0(void *param_1,byte param_2)



{

  FUN_0055b160();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059a0c0 at 0x0059A0C0 (size: 63) ---


void __thiscall FUN_0059a0c0(int param_1,int param_2)



{

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_2 + 4);

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_2 + 8);

  *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);

  *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(param_2 + 0x10);

  *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)(param_2 + 0x14);

  *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(param_2 + 0x18);

  *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(param_2 + 0x1c);

  *(undefined4 *)(param_1 + 0x20) = *(undefined4 *)(param_2 + 0x20);

  *(undefined4 *)(param_1 + 0x24) = *(undefined4 *)(param_2 + 0x24);

  return;

}





// --- FUN_0059a100 at 0x0059A100 (size: 38) ---


void __fastcall FUN_0059a100(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e6024;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  return;

}





// --- FUN_0059a130 at 0x0059A130 (size: 69) ---


void __thiscall FUN_0059a130(undefined4 *param_1,int param_2)



{

  *param_1 = &PTR_FUN_007e6024;

  param_1[1] = *(undefined4 *)(param_2 + 4);

  param_1[2] = *(undefined4 *)(param_2 + 8);

  param_1[3] = *(undefined4 *)(param_2 + 0xc);

  param_1[4] = *(undefined4 *)(param_2 + 0x10);

  param_1[5] = *(undefined4 *)(param_2 + 0x14);

  param_1[6] = *(undefined4 *)(param_2 + 0x18);

  param_1[7] = *(undefined4 *)(param_2 + 0x1c);

  param_1[8] = *(undefined4 *)(param_2 + 0x20);

  param_1[9] = *(undefined4 *)(param_2 + 0x24);

  return;

}





// --- FUN_0059a1e0 at 0x0059A1E0 (size: 100) ---


undefined4 __thiscall FUN_0059a1e0(int param_1,int *param_2,uint param_3)



{

  int iVar1;

  undefined4 *puVar2;

  

  if (param_3 < 0x1c) {

    return 0;

  }

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)*param_2;

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  puVar2 = (undefined4 *)(iVar1 + 4);

  *param_2 = (int)puVar2;

  *(undefined4 *)(param_1 + 0x10) = *puVar2;

  *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)(iVar1 + 8);

  iVar1 = *param_2;

  puVar2 = (undefined4 *)(iVar1 + 8);

  *param_2 = (int)puVar2;

  *(undefined4 *)(param_1 + 0x18) = *puVar2;

  *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(iVar1 + 0xc);

  *param_2 = *param_2 + 8;

  return 1;

}





// --- FUN_0059a250 at 0x0059A250 (size: 45) ---


undefined4 * __fastcall FUN_0059a250(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007cd910;

  param_1[1] = &PTR_FUN_007a7980;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0x20;

  param_1[5] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_0059a280 at 0x0059A280 (size: 42) ---


void __fastcall FUN_0059a280(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[1];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0059a2b0 at 0x0059A2B0 (size: 183) ---


void __fastcall FUN_0059a2b0(int param_1)



{

  undefined4 *puVar1;

  int *piVar2;

  int *piVar3;

  LONG LVar4;

  uint local_8;

  

  if ((*(int *)(param_1 + 8) != 0) && (local_8 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      piVar3 = *(int **)(*(int *)(param_1 + 8) + local_8 * 4);

      while (piVar3 != (int *)0x0) {

        puVar1 = (undefined4 *)piVar3[2];

        piVar2 = (int *)piVar3[5];

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        piVar3[1] = (int)&PTR_FUN_0079385c;

        puVar1 = (undefined4 *)*piVar3;

        LVar4 = InterlockedDecrement(puVar1 + 1);

        if ((LVar4 == 0) && (puVar1 != (undefined4 *)0x0)) {

          (**(code **)*puVar1)(1);

        }

        operator_delete(piVar3);

        piVar3 = piVar2;

      }

      *(undefined4 *)(*(int *)(param_1 + 8) + local_8 * 4) = 0;

      local_8 = local_8 + 1;

    } while (local_8 < *(uint *)(param_1 + 0xc));

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  return;

}





// --- FUN_0059a370 at 0x0059A370 (size: 52) ---


void __fastcall FUN_0059a370(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e6070;

  FUN_0059a2b0();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0059a440 at 0x0059A440 (size: 105) ---


int __fastcall FUN_0059a440(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  undefined4 local_4;

  

  uVar4 = 0;

  iVar5 = 4;

  local_4 = 0;

  if (*(int *)(param_1 + 0xc) != 0) {

    do {

      for (iVar1 = *(int *)(*(int *)(param_1 + 8) + uVar4 * 4); iVar1 != 0;

          iVar1 = *(int *)(iVar1 + 0x14)) {

        iVar2 = FUN_004fd290(&local_4,0);

        iVar3 = (**(code **)(*(int *)(iVar1 + 4) + 0xc))(&local_4,0);

        iVar5 = iVar5 + iVar2 + iVar3;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0xc));

  }

  return iVar5;

}





// --- FUN_0059a610 at 0x0059A610 (size: 91) ---


undefined4 __thiscall FUN_0059a610(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_0059a740(param_2);

  if (iVar1 == 0) {

    iVar1 = FUN_005df0f5(0x1c);

    if (iVar1 != 0) {

      iVar1 = FUN_0059a670(param_2,param_3,*(undefined4 *)(param_1 + 0xc));

      if (iVar1 != 0) {

        *(undefined4 *)(iVar1 + 0x14) =

             *(undefined4 *)(*(int *)(param_1 + 8) + *(int *)(iVar1 + 0x18) * 4);

        *(int *)(*(int *)(param_1 + 8) + *(int *)(iVar1 + 0x18) * 4) = iVar1;

        *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_0059a670 at 0x0059A670 (size: 65) ---


int * __thiscall FUN_0059a670(int *param_1,int *param_2,undefined4 param_3,uint param_4)



{

  int iVar1;

  uint uVar2;

  

  iVar1 = *param_2;

  *param_1 = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  FUN_0059a6c0(param_3);

  param_1[5] = 0;

  uVar2 = FUN_004fe050();

  param_1[6] = uVar2 % param_4;

  return param_1;

}





// --- FUN_0059a6c0 at 0x0059A6C0 (size: 49) ---


undefined4 * __thiscall FUN_0059a6c0(undefined4 *param_1,int param_2)



{

  int iVar1;

  

  *param_1 = &PTR_FUN_007e6084;

  iVar1 = *(int *)(param_2 + 4);

  param_1[1] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  param_1[2] = *(undefined4 *)(param_2 + 8);

  param_1[3] = *(undefined4 *)(param_2 + 0xc);

  return param_1;

}





// --- FUN_0059a700 at 0x0059A700 (size: 62) ---


undefined4 * __thiscall FUN_0059a700(undefined4 *param_1,byte param_2)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[1];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059a740 at 0x0059A740 (size: 86) ---


int __fastcall FUN_0059a740(int param_1)



{

  uint uVar1;

  int iVar2;

  char cVar3;

  uint uVar4;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  if ((uVar1 != 0) && (*(int *)(param_1 + 8) != 0)) {

    uVar4 = FUN_004fe050();

    for (iVar2 = *(int *)(*(int *)(param_1 + 8) + (uVar4 % uVar1) * 4); iVar2 != 0;

        iVar2 = *(int *)(iVar2 + 0x14)) {

      cVar3 = FUN_004ac350(iVar2,0);

      if (cVar3 != '\0') {

        return iVar2 + 4;

      }

    }

  }

  return 0;

}





// --- FUN_0059a7a0 at 0x0059A7A0 (size: 72) ---


undefined4 * __thiscall FUN_0059a7a0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e6070;

  FUN_0059a2b0();

  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_0059a7f0 at 0x0059A7F0 (size: 95) ---


void __fastcall FUN_0059a7f0(int param_1)



{

  *(undefined4 *)(param_1 + 0x38) = &PTR_FUN_007e6070;

  FUN_0059a2b0();

  if (*(void **)(param_1 + 0x40) != (void *)0x0) {

    operator_delete__(*(void **)(param_1 + 0x40));

    *(undefined4 *)(param_1 + 0x40) = 0;

  }

  *(undefined4 *)(param_1 + 0x44) = 0;

  *(undefined4 *)(param_1 + 0x38) = &PTR_FUN_0079385c;

  if (param_1 != 0) {

    *(undefined ***)(param_1 + 0x30) = &PTR_FUN_0079385c;

    FUN_004154b0();

    return;

  }

  ppuRam00000000 = &PTR_FUN_0079385c;

  FUN_004154b0();

  return;

}





// --- FUN_0059a880 at 0x0059A880 (size: 30) ---


void * __thiscall FUN_0059a880(void *param_1,byte param_2)



{

  FUN_0059a7f0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059a8d0 at 0x0059A8D0 (size: 86) ---


undefined4 __thiscall FUN_0059a8d0(int param_1,int *param_2)



{

  int iVar1;

  int *piVar2;

  uint uVar3;

  uint unaff_retaddr;

  

  piVar2 = param_2;

  iVar1 = *param_2;

  param_2 = (int *)0x0;

  uVar3 = (**(code **)(*(int *)(param_1 + 8) + 0xc))(&param_2,0);

  if (uVar3 <= unaff_retaddr) {

    (**(code **)(*(int *)(param_1 + 8) + 0x10))(piVar2,unaff_retaddr);

    if ((uint)(*piVar2 - iVar1) <= unaff_retaddr) {

      return 1;

    }

    *piVar2 = iVar1;

  }

  return 0;

}





// --- FUN_0059a930 at 0x0059A930 (size: 87) ---


void __thiscall FUN_0059a930(int param_1,undefined4 *param_2)



{

  uint uVar1;

  int *piVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  int *piVar6;

  

  uVar1 = *(uint *)(param_1 + 0xc);

  uVar5 = 0;

  if (uVar1 != 0) {

    piVar2 = *(int **)(param_1 + 8);

    piVar6 = piVar2;

    do {

      if (*piVar6 != 0) {

        iVar4 = piVar2[uVar5];

        param_2[2] = piVar2;

        param_2[1] = iVar4;

        *param_2 = &PTR_LAB_007e6140;

        param_2[3] = uVar1;

        return;

      }

      uVar5 = uVar5 + 1;

      piVar6 = piVar6 + 1;

    } while (uVar5 < uVar1);

  }

  uVar3 = *(undefined4 *)(param_1 + 8);

  param_2[1] = 0;

  param_2[2] = uVar3;

  *param_2 = &PTR_LAB_007e6140;

  param_2[3] = uVar1;

  return;

}





// --- FUN_0059aa20 at 0x0059AA20 (size: 94) ---


int __fastcall FUN_0059aa20(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 + 0x114)) {

        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_0059aa80 at 0x0059AA80 (size: 323) ---


void __fastcall FUN_0059aa80(undefined4 *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[0xd];

  param_1[0x32] = &PTR_FUN_0079385c;

  param_1[0x20] = &PTR_FUN_0079385c;

  param_1[0xe] = &PTR_FUN_0079385c;

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[0xc];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[0xb];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[10];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[9];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[8];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[7];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[6];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[5];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[4];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  puVar1 = (undefined4 *)param_1[3];

  LVar2 = InterlockedDecrement(puVar1 + 1);

  if ((LVar2 == 0) && (puVar1 != (undefined4 *)0x0)) {

    (**(code **)*puVar1)(1);

  }

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0059ac30 at 0x0059AC30 (size: 91) ---


void __fastcall FUN_0059ac30(int param_1)



{

  void *pvVar1;

  void *pvVar2;

  uint uVar3;

  

  if ((*(int *)(param_1 + 8) != 0) && (uVar3 = 0, *(int *)(param_1 + 0xc) != 0)) {

    do {

      pvVar2 = *(void **)(*(int *)(param_1 + 8) + uVar3 * 4);

      while (pvVar2 != (void *)0x0) {

        pvVar1 = *(void **)((int)pvVar2 + 0x114);

        FUN_0059aa80();

        operator_delete(pvVar2);

        pvVar2 = pvVar1;

      }

      *(undefined4 *)(*(int *)(param_1 + 8) + uVar3 * 4) = 0;

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 0xc));

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  return;

}





// --- FUN_0059ac90 at 0x0059AC90 (size: 52) ---


void __fastcall FUN_0059ac90(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e6144;

  FUN_0059ac30();

  if ((void *)param_1[2] != (void *)0x0) {

    operator_delete__((void *)param_1[2]);

    param_1[2] = 0;

  }

  param_1[3] = 0;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0059ae30 at 0x0059AE30 (size: 170) ---


undefined4 __thiscall FUN_0059ae30(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[0x45]) {

      if (*param_2 == *puVar1) {

        if (puVar1 != (uint *)0xfffffffc) {

          return 0;

        }

        break;

      }

    }

  }

  puVar1 = (uint *)FUN_005df0f5(0x11c);

  if (puVar1 == (uint *)0x0) {

    return 0;

  }

  uVar2 = *(uint *)(param_1 + 0xc);

  *puVar1 = *param_2;

  FUN_0059b140(param_3);

  puVar1[0x45] = 0;

  uVar2 = *param_2 % uVar2;

  puVar1[0x46] = uVar2;

  puVar1[0x45] = *(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_0059aee0 at 0x0059AEE0 (size: 72) ---


undefined4 * __thiscall FUN_0059aee0(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e6144;

  FUN_0059ac30();

  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_0059af30 at 0x0059AF30 (size: 71) ---


undefined4 * __thiscall FUN_0059af30(undefined4 *param_1,undefined4 param_2)



{

  FUN_00415460(param_2);

  param_1[0xc] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007e6170;

  param_1[0xc] = &PTR_LAB_007e6158;

  param_1[0xe] = &PTR_FUN_007e6144;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0x1000;

  param_1[0x12] = 0;

  FUN_005a8440();

  return param_1;

}





// --- FUN_0059af90 at 0x0059AF90 (size: 53) ---


undefined4 * __thiscall FUN_0059af90(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_LAB_007e6170;

  param_1[0xc] = &PTR_LAB_007e6158;

  FUN_0059ac90();

  FUN_004f8190();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059afe0 at 0x0059AFE0 (size: 351) ---


undefined4 * __fastcall FUN_0059afe0(undefined4 *param_1)



{

  LONG *pLVar1;

  

  *param_1 = &PTR_FUN_007e6200;

  param_1[1] = 0;

  param_1[2] = 0;

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[3] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[4] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[5] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[6] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[7] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[8] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[9] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[10] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[0xb] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[0xc] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  pLVar1 = (LONG *)(DAT_008ef11c + 4);

  param_1[0xd] = DAT_008ef11c;

  InterlockedIncrement(pLVar1);

  param_1[0xe] = &PTR_LAB_00797910;

  param_1[0xf] = 0;

  param_1[0x10] = 0x3f800000;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  FUN_00535b30();

  param_1[0x20] = &PTR_LAB_00797910;

  param_1[0x21] = 0;

  param_1[0x22] = 0x3f800000;

  param_1[0x23] = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x2f] = 0;

  param_1[0x30] = 0;

  param_1[0x31] = 0;

  FUN_00535b30();

  param_1[0x32] = &PTR_LAB_00797910;

  param_1[0x33] = 0;

  param_1[0x34] = 0x3f800000;

  param_1[0x35] = 0;

  param_1[0x36] = 0;

  param_1[0x37] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  FUN_00535b30();

  return param_1;

}





// --- FUN_0059b140 at 0x0059B140 (size: 271) ---


undefined4 * __thiscall FUN_0059b140(undefined4 *param_1,int param_2)



{

  int iVar1;

  

  *param_1 = &PTR_FUN_007e6200;

  param_1[1] = *(undefined4 *)(param_2 + 4);

  param_1[2] = *(undefined4 *)(param_2 + 8);

  iVar1 = *(int *)(param_2 + 0xc);

  param_1[3] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x10);

  param_1[4] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x14);

  param_1[5] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x18);

  param_1[6] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x1c);

  param_1[7] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x20);

  param_1[8] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x24);

  param_1[9] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x28);

  param_1[10] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x2c);

  param_1[0xb] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x30);

  param_1[0xc] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  iVar1 = *(int *)(param_2 + 0x34);

  param_1[0xd] = iVar1;

  InterlockedIncrement((LONG *)(iVar1 + 4));

  param_1[0xe] = &PTR_LAB_00797910;

  param_1[0xf] = *(undefined4 *)(param_2 + 0x3c);

  FUN_00425f10(param_2 + 0x40);

  param_1[0x20] = &PTR_LAB_00797910;

  param_1[0x21] = *(undefined4 *)(param_2 + 0x84);

  FUN_00425f10(param_2 + 0x88);

  param_1[0x32] = &PTR_LAB_00797910;

  param_1[0x33] = *(undefined4 *)(param_2 + 0xcc);

  FUN_00425f10(param_2 + 0xd0);

  return param_1;

}





// --- FUN_0059b250 at 0x0059B250 (size: 30) ---


void * __thiscall FUN_0059b250(void *param_1,byte param_2)



{

  FUN_0059aa80();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059b270 at 0x0059B270 (size: 285) ---


int __fastcall FUN_0059b270(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  int iVar9;

  int iVar10;

  int iVar11;

  int iVar12;

  int iVar13;

  int iVar14;

  int *unaff_EBX;

  undefined4 local_8;

  int local_4;

  

  local_4 = param_1 + 0x38;

  local_8 = 0;

  iVar1 = FUN_004fd290(&local_8,0);

  iVar2 = FUN_004fd290(&local_8,0);

  iVar3 = FUN_004fd290(&local_8,0);

  iVar4 = FUN_004fd290(&local_8,0);

  iVar5 = FUN_004fd290(&local_8,0);

  iVar6 = FUN_004fd290(&local_8,0);

  iVar7 = FUN_004fd290(&local_8,0);

  iVar8 = FUN_004fd290(&local_8,0);

  iVar9 = FUN_004fd290(&local_8,0);

  iVar10 = FUN_004fd290(&local_8,0);

  iVar11 = FUN_004fd290(&local_8,0);

  iVar12 = (**(code **)(*(int *)(param_1 + 0x80) + 0xc))(&local_8,0);

  iVar13 = (**(code **)(*unaff_EBX + 0xc))(&stack0xfffffff0,0);

  iVar14 = (**(code **)(*(int *)(param_1 + 200) + 0xc))(&stack0xffffffe8,0);

  return iVar14 + 8 +

         iVar1 + iVar2 + iVar3 + iVar4 + iVar5 + iVar6 + iVar7 + iVar8 + iVar9 + iVar10 + iVar11 +

         iVar12 + iVar13;

}





// --- FUN_0059b570 at 0x0059B570 (size: 18) ---


undefined4 * __fastcall FUN_0059b570(undefined4 *param_1)



{

  FUN_005ba8e0();

  *param_1 = &PTR_FUN_007e6214;

  return param_1;

}





// --- FUN_0059b590 at 0x0059B590 (size: 30) ---


void * __thiscall FUN_0059b590(void *param_1,byte param_2)



{

  FUN_0056aa40();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059b5b0 at 0x0059B5B0 (size: 37) ---


undefined4 * __thiscall

FUN_0059b5b0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  FUN_005d6730(param_2,param_3,param_4);

  *param_1 = &PTR_FUN_007e9b54;

  return param_1;

}





// --- FUN_0059b5e0 at 0x0059B5E0 (size: 29) ---


void __fastcall FUN_0059b5e0(undefined4 *param_1)



{

  param_1[-1] = &PTR_LAB_007e6420;

  *param_1 = &PTR_LAB_007e6404;

  FUN_005d6160();

  return;

}





// --- FUN_0059b600 at 0x0059B600 (size: 33) ---


undefined4 FUN_0059b600(undefined4 param_1)



{

  switch(param_1) {

  case 0:

  case 1:

  case 2:

  case 0xf:

  case 0x10:

  case 0x11:

  case 0x12:

  case 0x19:

  case 0x1b:

  case 0x23:

  case 0x24:

  case 0x25:

  case 0x26:

  case 0x27:

  case 0x2a:

  case 0x2b:

  case 0x2e:

  case 0x2f:

  case 0x31:

  case 0x32:

  case 0x33:

  case 0x34:

    return 1;

  default:

    return 0;

  }

}





// --- FUN_0059b670 at 0x0059B670 (size: 44) ---


void __thiscall FUN_0059b670(int param_1,char param_2)



{

  if ((*(char *)(param_1 + 0x1a8) != '\0') || (param_2 != '\0')) {

    FUN_006a1ee0(param_1 + 4);

  }

  *(undefined1 *)(param_1 + 0x1a8) = 0;

  return;

}





// --- FUN_0059b6a0 at 0x0059B6A0 (size: 115) ---


void __fastcall FUN_0059b6a0(int param_1)



{

  undefined1 uVar1;

  char cVar2;

  undefined4 uVar3;

  

  *(undefined1 *)(param_1 + 0x1a8) = 0;

  *(undefined4 *)(param_1 + 0x1b0) = 0;

  *(undefined4 *)(param_1 + 0x1b4) = 0xbff00000;

  uVar1 = FUN_005d3c20();

  FUN_00505d40(uVar1);

  cVar2 = FUN_005d43d0();

  DAT_0081dbf8 = '\x01' - (cVar2 != '\0');

  cVar2 = FUN_005d3bd0();

  FUN_00451e10(cVar2 == '\0');

  uVar3 = FUN_005d3cb0();

  FUN_0056b210(uVar3);

  FUN_0056bc10(uVar3);

  return;

}





// --- FUN_0059b720 at 0x0059B720 (size: 59) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0059b720(int param_1)



{

  double dVar1;

  

  if ((*(char *)(param_1 + 0x1a8) != '\0') &&

     (dVar1 = _DAT_007e6440 + *(double *)(param_1 + 0x1b0),

     dVar1 < _DAT_008379a8 != (dVar1 == _DAT_008379a8))) {

    FUN_006a1ee0(param_1 + 4);

    *(undefined1 *)(param_1 + 0x1a8) = 0;

  }

  return;

}





// --- FUN_0059b760 at 0x0059B760 (size: 55) ---


undefined4 * __fastcall FUN_0059b760(undefined4 *param_1)



{

  FUN_005d6340();

  param_1[1] = &PTR_LAB_007e6404;

  *(undefined1 *)(param_1 + 0x6a) = 0;

  param_1[0x6c] = 0;

  *param_1 = &PTR_LAB_007e6420;

  param_1[0x6d] = 0xbff00000;

  return param_1;

}





// --- FUN_0059ba50 at 0x0059BA50 (size: 254) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_0059ba50(void)



{

  int iVar1;

  int iVar2;

  float fVar3;

  int iVar4;

  float unaff_EBX;

  float unaff_EBP;

  float *pfVar5;

  undefined4 *puVar6;

  float *pfVar7;

  undefined4 *puVar8;

  float unaff_retaddr;

  float fStack_c4;

  undefined1 local_c0 [4];

  float fStack_bc;

  float fStack_b8;

  float fStack_b4;

  float fStack_ac;

  float fStack_a8;

  float fStack_a4;

  float fStack_8c;

  float local_80 [16];

  undefined4 local_40 [14];

  float *pfStack_8;

  float fStack_4;

  

  iVar1 = *(int *)(DAT_00870340 + 0x94);

  iVar2 = *(int *)(DAT_00870340 + 0x98);

  pfVar5 = (float *)(DAT_00870340 + 0x148);

  pfVar7 = local_80;

  for (iVar4 = 0x10; iVar4 != 0; iVar4 = iVar4 + -1) {

    *pfVar7 = *pfVar5;

    pfVar5 = pfVar5 + 1;

    pfVar7 = pfVar7 + 1;

  }

  puVar6 = (undefined4 *)(DAT_00870340 + 0x108);

  puVar8 = local_40;

  for (iVar4 = 0x10; iVar4 != 0; iVar4 = iVar4 + -1) {

    *puVar8 = *puVar6;

    puVar6 = puVar6 + 1;

    puVar8 = puVar8 + 1;

  }

  thunk_FUN_005e16bf(local_c0,0,local_40);

  fVar3 = (float)iVar1;

  if (iVar1 < 0) {

    fVar3 = fVar3 + _DAT_0079920c;

  }

  fStack_8c = ((fStack_4 + fStack_4) / fVar3 - _DAT_007938b0) / fStack_8c;

  fVar3 = (float)iVar2;

  if (iVar2 < 0) {

    fVar3 = fVar3 + _DAT_0079920c;

  }

  fVar3 = (_DAT_0079a1a0 / local_80[2]) * ((unaff_retaddr + unaff_retaddr) / fVar3 - _DAT_007938b0);

  *pfStack_8 = unaff_EBP * fStack_8c + fStack_bc * fVar3 + fStack_ac;

  pfStack_8[2] = unaff_EBX * fStack_8c + fStack_b8 * fVar3 + fStack_a8;

  pfStack_8[1] = fStack_c4 * fStack_8c + fStack_b4 * fVar3 + fStack_a4;

  return;

}





// --- FUN_0059bba0 at 0x0059BBA0 (size: 49) ---


undefined4 * __thiscall FUN_0059bba0(int *param_1,undefined4 *param_2)



{

  if ((*param_1 != 1) && (*param_1 != 2)) {

    *param_2 = 0;

    param_2[1] = 0;

    param_2[2] = 0;

    return param_2;

  }

  FUN_00536460(param_2);

  return param_2;

}





// --- FUN_0059bbe0 at 0x0059BBE0 (size: 29) ---


void FUN_0059bbe0(void)



{

  if (DAT_0087222c != (void *)0x0) {

    operator_delete(DAT_0087222c);

    DAT_0087222c = (void *)0x0;

  }

  return;

}





// --- FUN_0059bc00 at 0x0059BC00 (size: 317) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0059bc00(void)



{

  _DAT_008682b0 = 0;

  _DAT_008682b4 = 0;

  _DAT_008682b8 = 0;

  _DAT_008682c8 = 0;

  _DAT_008682cc = 0;

  _DAT_008682d0 = 0xbf800000;

  _DAT_008682bc = 0x3f800000;

  _DAT_008682d8 = 3;

  _DAT_008682fc = 0;

  _DAT_00868300 = 0;

  _DAT_00868304 = 0;

  _DAT_00868308 = 0x3f800000;

  _DAT_008682dc = 0x3f800000;

  _DAT_008682e0 = 0x3f800000;

  _DAT_008682e4 = 0x3f800000;

  _DAT_008682e8 = 0x3f800000;

  _DAT_008682ec = 0x3f800000;

  _DAT_008682f0 = 0x3f800000;

  _DAT_008682f4 = 0x3f800000;

  _DAT_008682f8 = 0x3f800000;

  _DAT_00868318 = 0;

  _DAT_0086831c = 0xbf800000;

  _DAT_00868320 = 0;

  _DAT_00868340 = 0;

  _DAT_008682c0 = 0x3f800000;

  _DAT_008682c4 = 0x3f800000;

  DAT_008682d4 = 0;

  FUN_0054ca10();

  FUN_0054ca10();

  return 0;

}





// --- FUN_0059bd40 at 0x0059BD40 (size: 402) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0059bd40(undefined4 param_1,undefined4 *param_2,undefined4 param_3,int *param_4)



{

  float fVar1;

  float fVar2;

  undefined4 *puVar3;

  int iVar4;

  undefined1 local_4c [12];

  undefined1 local_40 [12];

  undefined1 local_34 [12];

  undefined1 local_28 [12];

  undefined1 local_1c [12];

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (*(int *)(DAT_00870340 + 0x468) == 0) {

    return 0;

  }

  param_2[1] = (float)param_4[0x14] * (float)param_4[0x17];

  local_10 = 0;

  local_c = 0;

  param_2[2] = (float)param_4[0x15] * (float)param_4[0x17];

  local_8 = 0;

  fVar1 = (float)param_4[0x16];

  local_4 = 0;

  fVar2 = (float)param_4[0x17];

  param_2[5] = 0;

  param_2[6] = 0;

  param_2[7] = 0;

  param_2[8] = 0;

  param_2[3] = fVar1 * fVar2;

  param_2[9] = 0;

  param_2[10] = 0;

  param_2[0xb] = 0;

  param_2[0xc] = 0;

  iVar4 = *param_4;

  if (iVar4 == 0) {

    *param_2 = 1;

    param_2[0x14] = 0x3f800000;

    param_2[0x13] = (float)param_4[0x18] * _DAT_00821cd4;

    param_2[0xd] = param_4[0xe];

    param_2[0xe] = param_4[0x10];

    param_2[0xf] = param_4[0xf];

  }

  else {

    if (iVar4 == 1) {

      *param_2 = 3;

      puVar3 = (undefined4 *)FUN_0059bba0(local_28);

      param_2[0x10] = *puVar3;

      iVar4 = FUN_0059bba0(local_1c);

      param_2[0x11] = *(undefined4 *)(iVar4 + 8);

      iVar4 = FUN_0059bba0(&local_10);

      param_2[0x12] = *(undefined4 *)(iVar4 + 4);

      return 1;

    }

    if (iVar4 != 2) {

      return 1;

    }

    *param_2 = 2;

    param_2[0x14] = 0x3f800000;

    param_2[0x13] = (float)param_4[0x18] * _DAT_00821cd4;

    param_2[0x18] = param_4[0x19];

    param_2[0x19] = param_4[0x19];

    param_2[0xd] = param_4[0xe];

    param_2[0xe] = param_4[0x10];

    param_2[0xf] = param_4[0xf];

    puVar3 = (undefined4 *)FUN_0059bba0(local_4c);

    param_2[0x10] = *puVar3;

    iVar4 = FUN_0059bba0(local_40);

    param_2[0x11] = *(undefined4 *)(iVar4 + 8);

    iVar4 = FUN_0059bba0(local_34);

    param_2[0x12] = *(undefined4 *)(iVar4 + 4);

  }

  param_2[0x15] = 0;

  param_2[0x16] = 0x3f800000;

  param_2[0x17] = 0;

  return 1;

}





// --- FUN_0059c990 at 0x0059C990 (size: 11) ---


undefined4 FUN_0059c990(void)



{

  FUN_0059bc00();

  return 1;

}





// --- FUN_0059c9a0 at 0x0059C9A0 (size: 267) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_0059c9a0(void)



{

  int *piVar1;

  int iVar2;

  undefined1 *puStack_a8;

  int iStack_a4;

  undefined1 *puStack_a0;

  undefined4 uStack_9c;

  int iStack_98;

  undefined1 auStack_8c [12];

  undefined1 auStack_80 [40];

  int aiStack_58 [3];

  undefined1 auStack_4c [56];

  float fStack_14;

  int iStack_10;

  

  iVar2 = DAT_00870340;

  if ((_DAT_008729b4 & 1) == 0) {

    _DAT_008729b4 = _DAT_008729b4 | 1;

  }

  iStack_98 = 0x59c9c7;

  uStack_9c = FUN_0054ca00();

  iStack_98 = iVar2 + 0x108;

  puStack_a0 = auStack_80;

  iStack_a4 = 0x59c9d9;

  thunk_FUN_005e1199();

  iStack_a4 = iVar2 + 0x148;

  puStack_a8 = auStack_8c;

  thunk_FUN_005e1199();

  piVar1 = aiStack_58;

  if (iStack_10 == 0) {

    piVar1 = &iStack_98;

  }

  thunk_FUN_005e0979(&puStack_a8);

  iVar2 = DAT_008729b0 * 0x10;

  DAT_008729b0 = DAT_008729b0 + 1;

  if (DAT_008729b0 == 100) {

    DAT_008729b0 = 0;

  }

  if (iStack_10 == 0) {

    *(float *)(&DAT_00872370 + iVar2) = fStack_14;

    *(int **)(&DAT_00872374 + iVar2) = piVar1;

  }

  else {

    *(float *)(&DAT_00872370 + iVar2) =

         fStack_14 * (float)_DAT_008672f8 * (float)_DAT_00799088 +

         (float)_DAT_008672f8 * (float)puStack_a8 * (float)_DAT_00799088;

    *(float *)(&DAT_00872374 + iVar2) =

         (float)puStack_a8 * (float)_DAT_008672e0 * (float)_DAT_00799088 -

         (float)piVar1 * (float)_DAT_008672e0 * (float)_DAT_00799088;

  }

  *(undefined1 **)(&DAT_00872378 + iVar2) = auStack_4c;

  *(undefined1 **)(&DAT_0087237c + iVar2) = puStack_a8;

  return;

}





// --- FUN_0059cb40 at 0x0059CB40 (size: 255) ---


void __fastcall FUN_0059cb40(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  

  *(undefined4 *)(param_1 + 0xc) = 0x7fffffff;

  *(undefined4 *)(param_1 + 0x28) = 0x7fffffff;

  *(undefined1 *)(param_1 + 1) = 0;

  *(undefined1 *)(param_1 + 2) = 0;

  iVar2 = 8;

  *(undefined4 *)(param_1 + 4) = 8;

  *(undefined4 *)(param_1 + 8) = 0;

  *(undefined4 *)(param_1 + 0x10) = 0;

  *(undefined4 *)(param_1 + 0x18) = 0;

  *(undefined1 *)(param_1 + 0x1c) = 0;

  *(undefined4 *)(param_1 + 0x20) = 8;

  *(undefined1 *)(param_1 + 0x24) = 0;

  *(undefined4 *)(param_1 + 0x2c) = 0;

  *(undefined4 *)(param_1 + 0x30) = 0;

  *(undefined4 *)(param_1 + 0x34) = 0;

  *(undefined4 *)(param_1 + 0x14) = 1;

  *(undefined4 *)(param_1 + 0x38) = DAT_00821e00;

  *(undefined4 *)(param_1 + 0x3c) = DAT_00821e04;

  *(undefined4 *)(param_1 + 0x40) = DAT_00821e08;

  *(undefined4 *)(param_1 + 0x44) = DAT_00821e0c;

  *(undefined4 *)(param_1 + 0x70) = 0x7fffffff;

  *(undefined4 *)(param_1 + 0x7c) = 0x7fffffff;

  *(undefined1 *)(param_1 + 0x48) = 0;

  *(undefined1 *)(param_1 + 0x49) = 0;

  *(undefined1 *)(param_1 + 0x4a) = 0;

  *(undefined1 *)(param_1 + 0x4b) = 0;

  *(undefined4 *)(param_1 + 0x4c) = 0;

  *(undefined4 *)(param_1 + 0x50) = 0;

  *(undefined1 *)(param_1 + 0x54) = 0;

  *(undefined4 *)(param_1 + 0x60) = 0;

  *(undefined4 *)(param_1 + 100) = 0;

  *(undefined1 *)(param_1 + 0x68) = 0;

  *(undefined4 *)(param_1 + 0x6c) = 0;

  *(undefined1 *)(param_1 + 0x74) = 0;

  *(undefined4 *)(param_1 + 0x78) = 0;

  puVar1 = (undefined4 *)(param_1 + 0x80);

  iVar3 = 0x10;

  do {

    *puVar1 = 3;

    puVar1[1] = 3;

    puVar1[2] = 1;

    puVar1[3] = 1;

    puVar1[4] = 1;

    puVar1[5] = 0;

    puVar1 = puVar1 + 6;

    iVar3 = iVar3 + -1;

  } while (iVar3 != 0);

  puVar1 = (undefined4 *)(param_1 + 0x200);

  do {

    *puVar1 = 0;

    puVar1[1] = 2;

    puVar1[2] = 2;

    puVar1[3] = 1;

    puVar1[4] = 2;

    puVar1[5] = 2;

    puVar1[6] = 1;

    puVar1[7] = 0;

    puVar1[8] = 0;

    puVar1 = puVar1 + 9;

    iVar2 = iVar2 + -1;

  } while (iVar2 != 0);

  *(undefined4 *)(param_1 + 0x55) = 0;

  *(undefined4 *)(param_1 + 0x59) = 0;

  return;

}





// --- FUN_0059cc40 at 0x0059CC40 (size: 43) ---


undefined4 * __thiscall FUN_0059cc40(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e6520;

  FUN_00698990();

  FUN_00446f00();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059cca0 at 0x0059CCA0 (size: 760) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_0059cca0(int *param_1,char param_2)



{

  float *pfVar1;

  bool bVar2;

  float fVar3;

  uint uVar4;

  bool bVar5;

  bool bVar6;

  bool bVar7;

  undefined4 uVar8;

  uint uVar9;

  float *pfVar10;

  int iVar11;

  int unaff_EBX;

  int iVar12;

  uint uVar13;

  int iStack_4;

  

  FUN_0054c9f0();

  uVar13 = DAT_00821e28;

  if (param_2 == '\0') {

    uVar13 = DAT_00821e24;

  }

  bVar2 = true;

  iVar12 = 0;

  bVar5 = true;

  bVar6 = true;

  bVar7 = true;

  if (*(char *)((int)param_1 + 0xe) != '\0') {

    do {

      pfVar10 = *(float **)(*param_1 + iVar12 * 4);

      if (*pfVar10 != (float)_DAT_007e6548) {

        bVar2 = false;

      }

      if (*pfVar10 != (float)_DAT_007e6540) {

        bVar5 = false;

      }

      if (pfVar10[1] != (float)_DAT_007e6548) {

        bVar7 = false;

      }

      if (pfVar10[1] != (float)_DAT_007e6540) {

        bVar6 = false;

      }

      uVar8 = FUN_0059c9a0(pfVar10,1);

      (&DAT_008edfa8)[iVar12] = uVar8;

      iVar12 = iVar12 + 1;

    } while (iVar12 < (int)(uint)*(byte *)((int)param_1 + 0xe));

    if ((((!bVar2) && (!bVar5)) && (!bVar6)) && (!bVar7)) {

      if (param_2 == '\0') {

        DAT_008729c4 = DAT_008729c4 + 1;

      }

      iStack_4 = 0;

      _DAT_0086730c = 0;

      _DAT_00847064 = 0x3f800000;

      _DAT_008470c8 = 1;

      FUN_006b7c40(&DAT_008edfa8,*(undefined1 *)((int)param_1 + 0xe),&DAT_008edf30,&iStack_4,0);

      if (2 < iStack_4) {

        FUN_005a47d0(0,0);

        FUN_005a3be0(0);

        FUN_005a3ca0(5,6,1);

        FUN_005a3e20(8,uVar13 >> 2 & 0xffffff01);

        (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0x164))

                  (*(int **)(DAT_00870340 + 0x468),0x144);

        FUN_005a3d80(1);

        iVar12 = DAT_00870340;

        DAT_00821e20 = DAT_00821e20 + 1;

        switch(DAT_00821e20) {

        case 0:

          DAT_008edf28 = 0xffffff;

          break;

        case 1:

          DAT_008edf28 = 0xff0000;

          break;

        case 2:

          DAT_008edf28 = 0xff00;

          break;

        case 3:

          DAT_008edf28 = 0xff;

          break;

        case 4:

          DAT_008edf28 = 0xffff00;

          break;

        case 5:

          DAT_008edf28 = 0xffff;

          break;

        case 6:

          DAT_008edf28 = 0xff00ff;

          break;

        case 7:

          DAT_008edf28 = 0;

          DAT_00821e20 = -1;

        }

        iVar11 = 0;

        if (0 < unaff_EBX) {

          uVar4 = DAT_008edf28 >> 8;

          uVar9 = DAT_008edf28 & 0xff;

          pfVar10 = (float *)&DAT_008edbe4;

          do {

            pfVar1 = (float *)(&DAT_008edf30)[iVar11];

            fVar3 = (float)*(int *)(iVar12 + 0x8c);

            if (*(int *)(iVar12 + 0x8c) < 0) {

              fVar3 = fVar3 + _DAT_0079920c;

            }

            pfVar10[-1] = fVar3 + *pfVar1 / pfVar1[3];

            fVar3 = (float)*(int *)(iVar12 + 0x90);

            if (*(int *)(iVar12 + 0x90) < 0) {

              fVar3 = fVar3 + _DAT_0079920c;

            }

            *pfVar10 = fVar3 + pfVar1[1] / pfVar1[3];

            fVar3 = _DAT_007e6538;

            if ((uVar13 & 1) == 0) {

              fVar3 = pfVar1[2] / pfVar1[3];

            }

            pfVar10[1] = fVar3;

            iVar11 = iVar11 + 1;

            fVar3 = _DAT_007938b0 / pfVar1[3];

            pfVar10[3] = (float)((uVar4 & 0xffff) << 8 | ~(uVar13 << 0x1e) & 0x80000000 | uVar9);

            pfVar10[2] = fVar3;

            pfVar10 = pfVar10 + 7;

          } while (iVar11 < unaff_EBX);

        }

        FUN_005a1520(6,unaff_EBX + -2,&DAT_008edbe0,0x1c);

      }

    }

  }

  return;

}





// --- FUN_0059cfd0 at 0x0059CFD0 (size: 186) ---


undefined4 __fastcall FUN_0059cfd0(int param_1)



{

  bool bVar1;

  bool bVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  uint uStack_588;

  uint uStack_584;

  undefined4 local_580 [76];

  undefined1 auStack_450 [1104];

  

  uVar5 = 0;

  bVar1 = false;

  local_580[0] = 0;

  uVar3 = (**(code **)(**(int **)(param_1 + 0x1c) + 0x10))(*(int **)(param_1 + 0x1c));

  uStack_588 = 0xffffffff;

  bVar2 = false;

  if ((DAT_0081ffbc != 0) && (DAT_0081ffbc <= uVar3)) {

    uStack_588 = DAT_0081ffbc - 1;

  }

  if (uVar3 != 0) {

    do {

      iVar4 = (**(code **)(**(int **)(param_1 + 0x1c) + 0x14))

                        (*(int **)(param_1 + 0x1c),uVar5,0,auStack_450);

      if (iVar4 == 0) {

        iVar4 = (**(code **)(**(int **)(param_1 + 0x1c) + 0x38))

                          (*(int **)(param_1 + 0x1c),uVar5,1,local_580);

        if (iVar4 == 0) {

          if (!bVar1) {

            bVar1 = true;

            uStack_584 = uVar5;

          }

          if (uStack_588 == uVar5) {

            bVar2 = true;

          }

        }

      }

      uVar5 = uVar5 + 1;

    } while (uVar5 < uVar3);

    if (bVar1) {

      if (!bVar2) {

        uStack_588 = uStack_584;

      }

      *(uint *)(param_1 + 8) = uStack_588;

      return 1;

    }

  }

  return 0;

}





// --- FUN_0059d090 at 0x0059D090 (size: 201) ---


void __thiscall

FUN_0059d090(int param_1,int param_2,int param_3,float param_4,undefined4 param_5,undefined4 param_6

            ,int param_7)



{

  float fVar1;

  int iVar2;

  char unaff_BL;

  undefined4 *puVar3;

  undefined4 *unaff_EDI;

  

  fVar1 = (float)param_3;

  puVar3 = (undefined4 *)(param_1 + ((uint)(param_7 == 0x252) * 8 + 0x24) * param_2);

  *puVar3 = *unaff_EDI;

  puVar3[1] = unaff_EDI[1];

  puVar3[2] = unaff_EDI[2];

  puVar3[3] = fVar1 * (float)unaff_EDI[5];

  puVar3[4] = fVar1 * (float)unaff_EDI[6];

  puVar3[5] = fVar1 * (float)unaff_EDI[7];

  iVar2 = FUN_005df4c4();

  puVar3[6] = iVar2 << 0x18 | 0xffffff;

  if (((unaff_BL < '\0') ||

      (iVar2 = (int)unaff_BL, (int)(uint)*(ushort *)((int)unaff_EDI + 0xe) <= iVar2)) ||

     (unaff_EDI[4] == 0)) {

    puVar3[7] = 0;

    puVar3[8] = 0;

    if (param_7 == 0x252) {

      puVar3[9] = 0;

      puVar3[10] = 0;

    }

  }

  else {

    puVar3[7] = *(undefined4 *)(unaff_EDI[4] + iVar2 * 8);

    puVar3[8] = *(undefined4 *)(unaff_EDI[4] + 4 + iVar2 * 8);

    if (param_7 == 0x252) {

      puVar3[9] = param_4 * (float)puVar3[7];

      puVar3[10] = param_4 * (float)puVar3[8];

      return;

    }

  }

  return;

}





// --- FUN_0059d160 at 0x0059D160 (size: 116) ---


undefined4 FUN_0059d160(undefined4 *param_1)



{

  float *pfVar1;

  int *piVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  float unaff_ESI;

  int unaff_EDI;

  

  if (param_1[2] != 0x252) {

    return 0;

  }

  piVar2 = (int *)*param_1;

  iVar3 = (**(code **)(*piVar2 + 0x14))(piVar2);

  iVar4 = (**(code **)(*piVar2 + 0x3c))(piVar2,0,&stack0x00000000);

  if (iVar4 < 0) {

    return 0;

  }

  if (0 < iVar3) {

    iVar4 = 0;

    do {

      pfVar1 = (float *)(unaff_EDI + 0x1c + iVar4);

      iVar5 = unaff_EDI + iVar4;

      iVar4 = iVar4 + 0x2c;

      iVar3 = iVar3 + -1;

      *(float *)(iVar5 + 0x24) = unaff_ESI * *pfVar1;

      *(float *)(iVar5 + 0x28) = unaff_ESI * *(float *)(iVar5 + 0x20);

    } while (iVar3 != 0);

  }

  (**(code **)(*piVar2 + 0x40))(piVar2);

  param_1[3] = unaff_EDI;

  return 1;

}





// --- FUN_0059d1e0 at 0x0059D1E0 (size: 85) ---


undefined4 FUN_0059d1e0(undefined4 *param_1)



{

  int *piVar1;

  int *piVar2;

  

  piVar1 = (int *)*param_1;

  if (piVar1 != (int *)0x0) {

    piVar2 = (int *)*piVar1;

    if (piVar2 != (int *)0x0) {

      (**(code **)(*piVar2 + 8))(piVar2);

      *piVar1 = 0;

    }

    if ((int *)piVar1[1] != (int *)0x0) {

      (**(code **)(*(int *)piVar1[1] + 0x14))();

      piVar1[1] = 0;

    }

    operator_delete__((void *)piVar1[4]);

    piVar1[4] = 0;

    operator_delete(piVar1);

  }

  *param_1 = 0;

  return 1;

}





// --- FUN_0059d240 at 0x0059D240 (size: 301) ---


undefined4

FUN_0059d240(undefined4 param_1,undefined4 param_2,undefined4 param_3,char param_4,

            undefined1 param_5,char param_6)



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  ushort uVar4;

  ushort uVar5;

  undefined4 *puVar6;

  

  uVar5 = DAT_008729c0;

  uVar4 = DAT_008729bc;

  if (param_6 == '\0') {

    if (DAT_008729c0 < 3000) {

      uVar1 = (uint)DAT_008729c0;

      (&DAT_008b0380)[uVar1 * 0x15] = param_1;

      (&DAT_008b0384)[uVar1 * 0x15] = param_2;

      (&DAT_008b0388)[uVar1 * 0x15] = param_3;

      (&DAT_008b03d1)[uVar1 * 0x54] = param_5;

      (&DAT_008b03d0)[uVar1 * 0x54] = param_4;

      if (param_4 != '\0') {

        (&DAT_008b038c)[uVar1 * 0x15] = *(undefined4 *)(DAT_00870340 + 0x7e4);

        puVar2 = (undefined4 *)FUN_0054ca00();

        puVar6 = (undefined4 *)(&DAT_008b0390 + (uint)DAT_008729c0 * 0x54);

        for (iVar3 = 0x10; uVar5 = DAT_008729c0, iVar3 != 0; iVar3 = iVar3 + -1) {

          *puVar6 = *puVar2;

          puVar2 = puVar2 + 1;

          puVar6 = puVar6 + 1;

        }

      }

      DAT_008729c0 = uVar5 + 1;

      return 1;

    }

  }

  else if (DAT_008729bc < 3000) {

    uVar1 = (uint)DAT_008729bc;

    (&DAT_00872b20)[uVar1 * 0x15] = param_1;

    (&DAT_00872b24)[uVar1 * 0x15] = param_2;

    (&DAT_00872b28)[uVar1 * 0x15] = param_3;

    (&DAT_00872b71)[uVar1 * 0x54] = param_5;

    (&DAT_00872b70)[uVar1 * 0x54] = param_4;

    if (param_4 != '\0') {

      (&DAT_00872b2c)[uVar1 * 0x15] = *(undefined4 *)(DAT_00870340 + 0x7e4);

      puVar2 = (undefined4 *)FUN_0054ca00();

      puVar6 = (undefined4 *)(&DAT_00872b30 + (uint)DAT_008729bc * 0x54);

      for (iVar3 = 0x10; uVar4 = DAT_008729bc, iVar3 != 0; iVar3 = iVar3 + -1) {

        *puVar6 = *puVar2;

        puVar2 = puVar2 + 1;

        puVar6 = puVar6 + 1;

      }

    }

    DAT_008729bc = uVar4 + 1;

    return 1;

  }

  return 0;

}





// --- FUN_0059d370 at 0x0059D370 (size: 104) ---


undefined4 __fastcall FUN_0059d370(int param_1)



{

  char cVar1;

  int iVar2;

  

  if (*(int *)(param_1 + 0x94) == 0) {

    iVar2 = FUN_005df0f5(0x48);

    if (iVar2 == 0) {

      iVar2 = 0;

    }

    else {

      iVar2 = FUN_00698a40();

    }

    *(int *)(param_1 + 0x94) = iVar2;

    if (iVar2 != 0) {

      cVar1 = FUN_00698a70(0xffff,1);

      if (cVar1 != '\0') goto LAB_0059d3d0;

      if (*(undefined4 **)(param_1 + 0x94) != (undefined4 *)0x0) {

        (**(code **)**(undefined4 **)(param_1 + 0x94))(1);

      }

      *(undefined4 *)(param_1 + 0x94) = 0;

    }

    return 0;

  }

LAB_0059d3d0:

  return *(undefined4 *)(param_1 + 0x94);

}





// --- FUN_0059d3e0 at 0x0059D3E0 (size: 51) ---


void __fastcall FUN_0059d3e0(undefined4 *param_1)



{

  param_1[2] = 0;

  if ((param_1[1] & 0x80000000) == 0x80000000) {

    operator_delete__((void *)*param_1);

    *param_1 = 0;

    param_1[1] = 0;

  }

  return;

}





// --- FUN_0059d420 at 0x0059D420 (size: 160) ---


void FUN_0059d420(int *param_1,int *param_2)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined1 local_24 [12];

  undefined1 local_18 [12];

  undefined1 local_c [12];

  

  iVar1 = *param_2;

  *param_1 = iVar1;

  if (iVar1 != 0) {

    if (iVar1 == 1) {

      uVar3 = FUN_00536460(local_24);

      piVar2 = (int *)FUN_00452590(local_18,uVar3);

      param_1[0xe] = *piVar2;

      param_1[0xf] = piVar2[1];

      param_1[0x10] = piVar2[2];

      goto LAB_0059d461;

    }

    if (iVar1 != 2) goto LAB_0059d461;

  }

  piVar2 = (int *)FUN_004526c0(local_c,param_2 + 0xe);

  param_1[0xe] = *piVar2;

  param_1[0xf] = piVar2[1];

  param_1[0x10] = piVar2[2];

LAB_0059d461:

  param_1[0x14] = param_2[0x14];

  param_1[0x15] = param_2[0x15];

  param_1[0x16] = param_2[0x16];

  param_1[0x17] = param_2[0x17];

  param_1[0x18] = param_2[0x18];

  param_1[0x19] = param_2[0x19];

  return;

}





// --- FUN_0059d4c0 at 0x0059D4C0 (size: 81) ---


undefined4 __fastcall FUN_0059d4c0(int param_1)



{

  undefined4 uVar1;

  char cVar2;

  

  if ((((*(uint *)(param_1 + 0x58) & 6) != 0) && (*(int *)(param_1 + 0x6c) == 0)) &&

     (*(char *)(param_1 + 0x38) != '\0')) {

    cVar2 = FUN_005374c0();

    if (cVar2 != '\0') {

      FUN_00446c00();

    }

  }

  uVar1 = DAT_008379b4;

  *(undefined4 *)(param_1 + 0x40) = DAT_008379b0;

  *(undefined4 *)(param_1 + 0x44) = uVar1;

  if (DAT_00870340 != 0) {

    *(undefined4 *)(param_1 + 0x48) = *(undefined4 *)(DAT_00870340 + 0xb0);

  }

  return *(undefined4 *)(param_1 + 0x6c);

}





// --- FUN_0059d520 at 0x0059D520 (size: 988) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0059d520(int param_1,char param_2,char param_3,char param_4)



{

  uint uVar1;

  char cVar2;

  undefined4 uVar3;

  int iVar4;

  char cVar5;

  int iVar6;

  undefined4 uVar7;

  undefined4 uVar8;

  undefined4 local_8;

  int local_4;

  

  iVar4 = DAT_00870340;

  DAT_00867380 = param_1;

  DAT_00867384 = *(uint *)(param_1 + 0x58) | 0x10000000;

  iVar6 = FUN_0059d4c0();

  DAT_00867388 = (uint)(iVar6 != 0);

  if (param_3 == '\0') {

    FUN_005a4610(0,4,2,0);

    FUN_005a4550(0,4,2,0);

    FUN_005a4610(1,1,2,1);

    uVar8 = 1;

  }

  else {

    FUN_005a4610(0,4,2,0);

    FUN_005a4550(0,0x11,0,0);

    FUN_005a4610(1,0x10,2,1);

    FUN_005a4550(1,4,2,1);

    FUN_005a4420(1,1,1);

    FUN_005a4460(1,2,2,2);

    FUN_005a4610(2,1,2,1);

    uVar8 = 2;

  }

  FUN_005a4550(uVar8,1,2,1);

  if (iVar6 == 0) {

LAB_0059d650:

    uVar1 = *(uint *)(DAT_00867380 + 0x60);

    _DAT_00821da8 = uVar1;

    DAT_00821da4 = FUN_005df4c4();

    FUN_005a1080(DAT_00821da4 << 0x18 | uVar1 & 0xffffff,0);

    local_4 = *(int *)(iVar4 + 0x7ec);

  }

  else {

    if (param_2 == '\0') {

      uVar8 = 3;

    }

    else {

      DAT_00867384 = DAT_00867384 | 0x40000000;

      uVar8 = 1;

    }

    FUN_005a4420(0,uVar8,uVar8);

    FUN_005a4460(0,2,2,2);

    local_4 = FUN_0053f310();

    if (local_4 == 0) goto LAB_0059d650;

  }

  _DAT_00867408 = *(undefined4 *)(DAT_00867380 + 0x78);

  if (DAT_00867344 == 0) {

    _DAT_0081ffd0 = *(float *)(DAT_00867380 + 0x7c);

    _DAT_0081ffd4 = _DAT_0081ffd0;

    _DAT_0081ffd8 = _DAT_0081ffd0;

  }

  else {

    _DAT_0081ffd0 = _DAT_0086c244 * *(float *)(DAT_00867380 + 0x7c);

    _DAT_0081ffd4 = _DAT_0086c248 * *(float *)(DAT_00867380 + 0x7c);

    _DAT_0081ffd8 = _DAT_0086c24c * *(float *)(DAT_00867380 + 0x7c);

  }

  if (((DAT_00867384 & 0x100) == 0) && (param_4 == '\0')) {

    if ((DAT_00867384 & 0x200) == 0) {

      uVar7 = 2;

      if ((DAT_00867384 & 0x10000) == 0) {

        uVar8 = 1;

        cVar5 = '\0';

        goto LAB_0059d76a;

      }

      uVar8 = 2;

    }

    else {

      uVar7 = 6;

      uVar8 = 2;

      if ((DAT_00867384 & 0x10000) == 0) {

        uVar8 = 5;

      }

    }

  }

  else {

    uVar7 = 5;

    uVar8 = 2;

    if ((DAT_00867384 & 0x10000) == 0) {

      uVar8 = 6;

    }

  }

  cVar5 = '\x01';

LAB_0059d76a:

  cVar2 = '\0';

  if (((DAT_00867384 & 4) != 0) && (param_4 == '\0')) {

    if (cVar5 == '\0') {

      uVar7 = 2;

      uVar8 = 6;

    }

    if ((DAT_00867388 == 0) || (DAT_00821e30 = DAT_00821d9c, *(int *)(iVar6 + 0x68) == 0)) {

      DAT_00821e30 = DAT_00821da0;

    }

    cVar5 = '\x01';

    cVar2 = '\x01';

  }

  _DAT_0086740c = _DAT_00867408;

  _DAT_00867410 = _DAT_00867408;

  if ((DAT_00867384 & 0x10) == 0) {

    DAT_00821da4 = 0xff;

  }

  else {

    if (((DAT_008ee020 != 0) || (cVar5 == '\0')) || (cVar2 == '\x01')) {

      cVar5 = '\x01';

      uVar7 = 5;

      uVar8 = 6;

      cVar2 = '\0';

    }

    DAT_00821da4 = FUN_005df4c4();

  }

  uVar3 = DAT_00821e2c;

  if (((*(int *)(iVar4 + 0x7e4) == 0) || (*(int *)(*(int *)(iVar4 + 0x7e4) + 8) == 0)) ||

     ((cVar5 != '\0' && (cVar2 != '\x01')))) {

    if ((cVar2 == '\0') && (cVar5 != '\0')) {

      local_8 = 0;

    }

    else {

      local_8 = 1;

    }

  }

  else {

    uVar7 = 5;

    uVar8 = 6;

    cVar5 = '\x01';

    cVar2 = '\0';

    local_8 = 0;

  }

  FUN_005a47d0(0,local_4);

  FUN_005a3be0(cVar2);

  FUN_005a3c60(DAT_00821e30);

  FUN_005a3c20(7);

  FUN_005a3ca0(uVar7,uVar8,1);

  FUN_005a3ba0(cVar5);

  if (*(char *)(iVar4 + 0x7e0) == '\0') {

    FUN_005a3e20(uVar3,local_8);

  }

  cVar5 = FUN_005a1560();

  if ((cVar5 != '\0') && ((DAT_00867384 & 0x10000) == 0)) {

    FUN_005a4040(0);

    return DAT_00821da4;

  }

  FUN_005a4040(1);

  return DAT_00821da4;

}





// --- FUN_0059d900 at 0x0059D900 (size: 338) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_0059d900(float *param_1,float *param_2,float *param_3,float *param_4,int param_5)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  

  fVar1 = *(float *)(param_5 + 0x38) - *param_1;

  fVar2 = *(float *)(param_5 + 0x3c) - param_1[1];

  fVar3 = *(float *)(param_5 + 0x40) - param_1[2];

  fVar4 = fVar1 * fVar1 + fVar2 * fVar2 + fVar3 * fVar3;

  fVar5 = SQRT(fVar4);

  fVar6 = *(float *)(param_5 + 0x60) * _DAT_00821e34;

  if ((fVar5 < fVar6) &&

     (fVar1 = (_DAT_007938b0 / (_DAT_007e6518 + _DAT_007e6518)) *

              (param_1[3] * fVar1 +

              param_1[4] * fVar2 +

              param_1[5] * fVar3 + ((_DAT_007e6518 + _DAT_007e6518) - _DAT_007938b0) * fVar5),

     DAT_00796344 < fVar1)) {

    fVar2 = fVar5;

    if (_DAT_007938b0 < fVar4) {

      fVar2 = fVar4 * fVar5;

    }

    fVar2 = (_DAT_007938b0 - fVar5 / fVar6) * *(float *)(param_5 + 0x5c) * (fVar1 / fVar2);

    fVar1 = fVar2 * *(float *)(param_5 + 0x50);

    if (*(float *)(param_5 + 0x50) < fVar1) {

      fVar1 = *(float *)(param_5 + 0x50);

    }

    *param_2 = fVar1 + *param_2;

    fVar1 = fVar2 * *(float *)(param_5 + 0x54);

    if (*(float *)(param_5 + 0x54) < fVar1) {

      fVar1 = *(float *)(param_5 + 0x54);

    }

    *param_3 = fVar1 + *param_3;

    fVar2 = fVar2 * *(float *)(param_5 + 0x58);

    if (*(float *)(param_5 + 0x58) < fVar2) {

      fVar2 = *(float *)(param_5 + 0x58);

    }

    *param_4 = fVar2 + *param_4;

    return;

  }

  return;

}





// --- FUN_0059da60 at 0x0059DA60 (size: 1304) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0059da60(int param_1,int param_2,char param_3,undefined4 param_4,int *param_5)



{

  float fVar1;

  int *piVar2;

  bool bVar3;

  bool bVar4;

  float fVar5;

  int *piVar6;

  char cVar7;

  int iVar8;

  undefined2 extraout_var_00;

  undefined2 extraout_var_01;

  undefined2 uVar11;

  undefined4 *puVar9;

  undefined3 uVar10;

  undefined3 extraout_var;

  undefined4 uVar12;

  undefined4 uStack_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 uStack_2c;

  undefined4 local_28;

  undefined4 local_24;

  int iStack_20;

  int iStack_1c;

  undefined4 uStack_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  piVar6 = param_5;

  bVar3 = (float)param_5[3] == DAT_00796344;

  if ((((DAT_008ee074 == 0) || (*(char *)(DAT_00870340 + 0x44) == '\0')) || (param_3 == '\0')) ||

     (bVar3)) {

    param_5 = (int *)0x0;

    bVar4 = false;

  }

  else {

    bVar4 = true;

    param_5 = (int *)0x1;

  }

  FUN_0059d520(param_2,*(byte *)(param_1 + piVar6[4]) & 1,

               CONCAT31((int3)((uint)DAT_00870340 >> 8),bVar4),param_4);

  if ((bVar4) && (FUN_006b71c0(1), (float)piVar6[3] != DAT_0081fcc8)) {

    FUN_0059d160(piVar6,DAT_0081fcc8);

  }

  FUN_005a3d80((DAT_008ee070 == 0) + '\x01');

  if ((DAT_008ee06c == 0) || (*(char *)(DAT_00870340 + 0x7e0) != '\0')) {

    uVar12 = 1;

  }

  else {

    uVar12 = 0;

  }

  FUN_005a41f0(uVar12);

  if ((char)piVar6[5] < '\0') {

    FUN_005a4310(1);

    if (*(int *)(DAT_00870340 + 0x7e4) == 0) {

      _DAT_008ee03c = DAT_00821e38;

      _DAT_008ee044 = 0x3f800000;

      _DAT_008ee038 = DAT_00821e38;

      _DAT_008ee040 = DAT_00821e38;

      _DAT_008ee02c = DAT_00821e38;

      _DAT_008ee028 = DAT_00821e38;

      _DAT_008ee030 = DAT_00821e38;

      _DAT_008ee034 = 0x3f800000;

      (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xc4))

                (*(int **)(DAT_00870340 + 0x468),&DAT_008ee028);

      FUN_005a3ef0(0);

      FUN_005a3f40(0);

    }

  }

  else if (DAT_00796344 < *(float *)(param_2 + 0x78)) {

    iVar8 = *(int *)(DAT_00870340 + 0x7e4);

    if (iVar8 == 0) {

      DAT_008ee058 = *(undefined4 *)(param_2 + 0x78);

      DAT_008ee064 = 0x3f800000;

      DAT_008ee05c = DAT_008ee058;

      DAT_008ee060 = DAT_008ee058;

      (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xc4))

                (*(int **)(DAT_00870340 + 0x468),&DAT_008ee028);

    }

    else {

      DAT_008ee058 = *(undefined4 *)(iVar8 + 0x3c);

      DAT_008ee05c = *(undefined4 *)(iVar8 + 0x40);

      DAT_008ee060 = *(undefined4 *)(iVar8 + 0x44);

      DAT_008ee064 = *(undefined4 *)(iVar8 + 0x48);

      uVar12 = *(undefined4 *)(param_2 + 0x78);

      *(undefined4 *)(iVar8 + 0x3c) = uVar12;

      *(undefined4 *)(iVar8 + 0x40) = uVar12;

      *(undefined4 *)(iVar8 + 0x44) = uVar12;

      *(undefined4 *)(iVar8 + 0x48) = 0x3f800000;

      (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xc4))

                (*(int **)(DAT_00870340 + 0x468),iVar8 + 0xc);

    }

  }

  if (*(char *)((int)piVar6 + 0x15) == '\0') {

    uVar12 = 0;

  }

  else {

    iStack_20 = piVar6[6];

    iStack_1c = piVar6[7];

    local_34 = 0;

    local_38 = 0;

    local_3c = 0;

    local_24 = 0;

    local_28 = 0;

    local_30 = 0;

    local_14 = 0;

    local_8 = 0;

    local_c = 0;

    local_10 = 0;

    local_4 = 0x3f800000;

    uStack_18 = 0x3f800000;

    uStack_2c = 0x3f800000;

    uStack_40 = 0x3f800000;

    (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0xb0))

              (*(int **)(DAT_00870340 + 0x468),0x10,&uStack_40);

    uVar12 = 3;

  }

  iVar8 = FUN_005a4710(0,uVar12);

  piVar2 = (int *)*piVar6;

  if (piVar2 == (int *)0x0) {

    if (piVar6[1] != 0) {

      iVar8 = FUN_00444bf0(param_1);

    }

  }

  else {

    cVar7 = '\x01';

    iVar8 = (**(code **)(*piVar2 + 0xc))(piVar2,param_1);

    while ((iVar8 == -0x7789fe84 && (cVar7 != '\0'))) {

      cVar7 = FUN_004473d0(0xffff);

      iVar8 = (**(code **)(*piVar2 + 0xc))(piVar2,param_1);

    }

  }

  iVar8 = CONCAT31((int3)((uint)iVar8 >> 8),param_3);

  if (((param_3 == '\0') || (iVar8 = (int)param_5, param_5 != (int *)0x0)) || (iVar8 = 0, bVar3)) {

    uVar11 = (undefined2)((uint)iVar8 >> 0x10);

  }

  else {

    FUN_006b71c0(0);

    FUN_005a46c0(0,1);

    if ((float)piVar6[3] != DAT_0081fcc8) {

      FUN_0059d160(piVar6,DAT_0081fcc8);

    }

    piVar2 = (int *)*piVar6;

    if (piVar2 == (int *)0x0) {

      if (piVar6[1] != 0) {

        FUN_00444bf0(param_1);

        FUN_005a46c0(0,0);

        uVar11 = extraout_var_01;

        goto LAB_0059dec5;

      }

    }

    else {

      cVar7 = '\x01';

      iVar8 = (**(code **)(*piVar2 + 0xc))(piVar2,param_1);

      while ((iVar8 == -0x7789fe84 && (cVar7 != '\0'))) {

        cVar7 = FUN_004473d0(0xffff);

        iVar8 = (**(code **)(*piVar2 + 0xc))(piVar2,param_1);

      }

    }

    FUN_005a46c0(0,0);

    uVar11 = extraout_var_00;

  }

LAB_0059dec5:

  if ((char)piVar6[5] < '\0') {

    FUN_005a4310(0);

    puVar9 = *(undefined4 **)(DAT_00870340 + 0x7e4);

    if (puVar9 == (undefined4 *)0x0) {

      FUN_005a3ef0(1);

      FUN_005a3f40(1);

      puVar9 = (undefined4 *)FUN_005a0ff0(0,1);

    }

  }

  else {

    fVar1 = *(float *)(param_2 + 0x78);

    fVar5 = (float)_DAT_00795610;

    puVar9 = (undefined4 *)

             CONCAT22(uVar11,(ushort)(fVar1 < fVar5) << 8 | (ushort)(NAN(fVar1) || NAN(fVar5)) << 10

                             | (ushort)(fVar1 == fVar5) << 0xe);

    if (fVar1 < fVar5 == 0 && (fVar1 == fVar5) == 0) {

      iVar8 = *(int *)(DAT_00870340 + 0x7e4);

      if (iVar8 == 0) {

        puVar9 = (undefined4 *)FUN_005a0ff0(0,1);

      }

      else {

        puVar9 = (undefined4 *)(iVar8 + 0x3c);

        *puVar9 = DAT_008ee058;

        *(undefined4 *)(iVar8 + 0x40) = DAT_008ee05c;

        *(undefined4 *)(iVar8 + 0x44) = DAT_008ee060;

        *(undefined4 *)(iVar8 + 0x48) = DAT_008ee064;

      }

    }

  }

  uVar10 = (undefined3)((uint)puVar9 >> 8);

  if (*(char *)((int)piVar6 + 0x15) != '\0') {

    FUN_005a4710(0,0);

    uVar10 = extraout_var;

  }

  return CONCAT31(uVar10,1);

}





// --- FUN_0059df80 at 0x0059DF80 (size: 189) ---


undefined4 __thiscall FUN_0059df80(int *param_1,uint param_2)



{

  undefined4 *puVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_00439640();

      return 1;

    }

    iVar2 = thunk_FUN_005df0f5(param_2 << 4);

    if (iVar2 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        iVar3 = (iVar4 + -1) * 0x10;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar3);

          puVar1 = (undefined4 *)(iVar3 + iVar2);

          *puVar1 = *puVar5;

          puVar1[1] = puVar5[1];

          puVar1[2] = puVar5[2];

          iVar3 = iVar3 + -0x10;

          iVar4 = iVar4 + -1;

          puVar1[3] = puVar5[3];

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar2;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_0059e040 at 0x0059E040 (size: 176) ---


undefined4 __thiscall FUN_0059e040(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  undefined4 *puVar5;

  undefined4 *puVar6;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((param_1[1] & 0x7fffffffU) < param_2) {

    if (param_2 == 0) {

      FUN_0059d3e0();

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 0x14);

    if (iVar1 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      iVar4 = param_1[2];

      if (-1 < iVar4 + -1) {

        iVar2 = (iVar4 + -1) * 0x14;

        do {

          puVar5 = (undefined4 *)(*param_1 + iVar2);

          puVar6 = (undefined4 *)(iVar2 + iVar1);

          iVar2 = iVar2 + -0x14;

          iVar4 = iVar4 + -1;

          for (iVar3 = 5; iVar3 != 0; iVar3 = iVar3 + -1) {

            *puVar6 = *puVar5;

            puVar5 = puVar5 + 1;

            puVar6 = puVar6 + 1;

          }

        } while (iVar4 != 0);

      }

      if ((param_1[1] & 0x80000000U) == 0x80000000) {

        operator_delete__((void *)*param_1);

      }

    }

    *param_1 = iVar1;

    param_1[1] = param_2 | 0x80000000;

  }

  return 1;

}





// --- FUN_0059e0f0 at 0x0059E0F0 (size: 752) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0059e0f0(undefined4 *param_1)



{

  int iVar1;

  float fVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  uint uVar6;

  int iVar7;

  int iVar8;

  int *piVar9;

  int unaff_EDI;

  int *piStack_90;

  int iStack_80;

  int *piStack_7c;

  int aiStack_78 [3];

  int *local_6c;

  undefined4 uStack_68;

  float fStack_40;

  float fStack_3c;

  float fStack_38;

  float fStack_28;

  float fStack_1c;

  undefined4 *puStack_c;

  int iStack_8;

  

  if (param_1[2] != 0x252) {

    return 0;

  }

  if ((DAT_00821e3c != 0) &&

     ((-1 < (char)*(byte *)(param_1 + 5) || ((*(byte *)(param_1 + 5) & 0x7f) == DAT_008683b4)))) {

    return 1;

  }

  piVar9 = (int *)*param_1;

  piStack_90 = piVar9;

  local_6c = piVar9;

  iStack_80 = (**(code **)(*piVar9 + 0x14))();

  iVar3 = (**(code **)(*piVar9 + 0x3c))(piVar9,0,aiStack_78);

  if (iVar3 < 0) {

    return 0;

  }

  if (0 < iStack_80) {

    iVar3 = 0;

    do {

      iVar7 = 0;

      piStack_90 = (int *)0x0;

      if (0 < (int)DAT_008683b4) {

        iVar8 = iStack_8 + 8;

        do {

          iVar1 = (&DAT_0086b748)[iVar7];

          aiStack_78[1] = 0x3f800000;

          aiStack_78[2] = 0;

          local_6c = (int *)0x0;

          uStack_68 = 0;

          fStack_40 = 0.0;

          fStack_3c = 0.0;

          fStack_38 = 0.0;

          FUN_00535b30();

          FUN_0059d420(aiStack_78,iVar1 + 0x70,iVar8);

          if (aiStack_78[0] == 0) {

            FUN_0059d900(iVar3 + unaff_EDI,&piStack_90,&stack0xffffff74,&stack0xffffff78,aiStack_78)

            ;

          }

          else if ((aiStack_78[0] == 1) &&

                  (fVar2 = fStack_3c * *(float *)(iVar3 + 0x10 + unaff_EDI) +

                           fStack_40 * *(float *)(iVar3 + 0xc + unaff_EDI) +

                           fStack_38 * *(float *)(iVar3 + 0x14 + unaff_EDI), DAT_00796344 < fVar2))

          {

            piStack_90 = (int *)(fStack_28 * fVar2 * fStack_1c + (float)piStack_90);

          }

          iVar7 = iVar7 + 1;

        } while (iVar7 < (int)DAT_008683b4);

        if (DAT_00796344 <= (float)piStack_90) {

          if (_DAT_007938b0 < (float)piStack_90) {

            piStack_90 = (int *)0x3f800000;

          }

        }

        else {

          piStack_90 = (int *)0x0;

        }

      }

      uVar4 = FUN_005df4c4();

      uVar5 = FUN_005df4c4();

      uVar6 = FUN_005df4c4();

      *(uint *)(iVar3 + 0x18 + unaff_EDI) =

           ((uVar4 | 0xffffff00) << 8 | uVar5 & 0xff) << 8 | uVar6 & 0xff;

      iVar3 = iVar3 + 0x2c;

      iStack_80 = iStack_80 + -1;

      piVar9 = piStack_7c;

      param_1 = puStack_c;

    } while (iStack_80 != 0);

  }

  (**(code **)(*piVar9 + 0x40))(piVar9);

  *(byte *)(param_1 + 5) = ((byte)DAT_008683b4 & 0x7f) + 0x80;

  return 1;

}





// --- FUN_0059e3f0 at 0x0059E3F0 (size: 436) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



byte FUN_0059e3f0(float param_1)



{

  byte bVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  byte bVar5;

  undefined *puVar6;

  undefined4 *puVar7;

  undefined4 *puVar8;

  undefined4 local_40 [16];

  

  uVar4 = (uint)DAT_008729bc;

  bVar5 = 1;

  if ((int)DAT_008ee07c < (int)uVar4) {

    DAT_008ee07c = uVar4;

  }

  uVar2 = (uint)DAT_008729c0;

  if ((int)DAT_008ee078 < (int)uVar2) {

    DAT_008ee078 = uVar2;

  }

  if ((float)uVar4 < param_1 * _DAT_007e6550) {

    if ((float)uVar2 < param_1 * _DAT_007e6550) {

      return 0;

    }

  }

  if (DAT_008729bc != 0) {

    puVar7 = (undefined4 *)(DAT_00870340 + 200);

    puVar8 = local_40;

    for (iVar3 = 0x10; iVar3 != 0; iVar3 = iVar3 + -1) {

      *puVar8 = *puVar7;

      puVar7 = puVar7 + 1;

      puVar8 = puVar8 + 1;

    }

    iVar3 = 0;

    if (uVar4 != 0) {

      puVar6 = &DAT_00872b30;

      do {

        if (puVar6[0x40] != '\0') {

          FUN_005a4820(puVar6);

          FUN_005a0ff0(*(undefined4 *)(puVar6 + -4),0);

        }

        bVar1 = FUN_0059da60(*(undefined4 *)(puVar6 + -0xc),*(undefined4 *)(puVar6 + -8),0,

                             puVar6[0x41],*(undefined4 *)(puVar6 + -0x10));

        bVar5 = bVar5 & bVar1;

        iVar3 = iVar3 + 1;

        puVar6 = puVar6 + 0x54;

      } while (iVar3 < (int)(uint)DAT_008729bc);

    }

    FUN_005a4820(local_40);

  }

  DAT_008729bc = 0;

  if (DAT_008729c0 != 0) {

    puVar7 = (undefined4 *)(DAT_00870340 + 200);

    puVar8 = local_40;

    for (iVar3 = 0x10; iVar3 != 0; iVar3 = iVar3 + -1) {

      *puVar8 = *puVar7;

      puVar7 = puVar7 + 1;

      puVar8 = puVar8 + 1;

    }

    iVar3 = 0;

    if (DAT_008729c0 != 0) {

      puVar6 = &DAT_008b0390;

      do {

        if (puVar6[0x40] != '\0') {

          FUN_005a4820(puVar6);

          FUN_005a0ff0(*(undefined4 *)(puVar6 + -4),0);

        }

        bVar1 = FUN_0059da60(*(undefined4 *)(puVar6 + -0xc),*(undefined4 *)(puVar6 + -8),0,

                             puVar6[0x41],*(undefined4 *)(puVar6 + -0x10));

        bVar5 = bVar5 & bVar1;

        iVar3 = iVar3 + 1;

        puVar6 = puVar6 + 0x54;

      } while (iVar3 < (int)(uint)DAT_008729c0);

    }

    FUN_005a4820(local_40);

  }

  DAT_008729c0 = 0;

  return bVar5;

}





// --- FUN_0059e5b0 at 0x0059E5B0 (size: 419) ---


byte FUN_0059e5b0(undefined4 param_1,char param_2,int param_3)



{

  undefined1 uVar1;

  undefined1 uVar2;

  byte bVar3;

  byte bVar4;

  int iVar5;

  int unaff_retaddr;

  undefined1 uVar6;

  uint uStack_c;

  int iStack_4;

  

  (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0x164))

            (*(int **)(DAT_00870340 + 0x468),*(undefined4 *)(param_3 + 8));

  bVar4 = 1;

  iVar5 = 0;

  uVar2 = 1;

  uVar6 = 1;

  if (0 < iStack_4) {

    do {

      if ((DAT_00821e40 == 0) || ((*(byte *)(*(int *)(unaff_retaddr + iVar5 * 4) + 0x58) & 6) != 0))

      {

LAB_0059e626:

        if (((*(char *)(DAT_00870340 + 0x7e0) == '\0') && (DAT_00821d98 != 0)) &&

           (DAT_00867374 == 0)) {

          if ((DAT_0081ffa6 != '\0') && ((*(byte *)(iVar5 + *(int *)(param_3 + 0x10)) & 8) != 0)) {

            bVar3 = FUN_0059d240(param_3,iVar5,*(undefined4 *)(unaff_retaddr + iVar5 * 4),uVar2,1,1)

            ;

            bVar4 = bVar4 & bVar3;

            uVar2 = 0;

            goto LAB_0059e67a;

          }

          bVar3 = *(byte *)(iVar5 + *(int *)(param_3 + 0x10));

          if (((byte)DAT_00821d98 & bVar3) != 0) {

            bVar3 = bVar3 >> 3;

            uStack_c = CONCAT31(uStack_c._1_3_,bVar3) & 0xffffff01;

            uVar1 = uVar6;

            if ((bVar3 & 1) != 0) {

              uVar1 = uVar2;

            }

            bVar3 = FUN_0059d240(param_3,iVar5,*(undefined4 *)(unaff_retaddr + iVar5 * 4),uVar1,0,

                                 uStack_c);

            bVar4 = bVar4 & bVar3;

            if ((char)uStack_c == '\0') {

              uVar6 = 0;

            }

            else {

              uVar2 = 0;

            }

            goto LAB_0059e69e;

          }

          if ((((DAT_00821d98 & 4) == 0) || (*(int *)(DAT_00870340 + 0x7e4) == 0)) ||

             (*(int *)(*(int *)(DAT_00870340 + 0x7e4) + 8) == 0)) goto LAB_0059e67a;

          bVar3 = FUN_0059d240(param_3,iVar5,*(undefined4 *)(unaff_retaddr + iVar5 * 4),uVar6,0,0);

          uVar6 = 0;

        }

        else {

LAB_0059e67a:

          FUN_0054c9f0();

          bVar3 = FUN_0059da60(iVar5,*(undefined4 *)(unaff_retaddr + iVar5 * 4),DAT_00867374 != 0,0,

                               param_3);

        }

        bVar4 = bVar4 & bVar3;

      }

      else if ((DAT_008ee3d4 == 0) && (param_2 == '\0')) {

        DAT_00821e40 = 1;

        goto LAB_0059e626;

      }

LAB_0059e69e:

      iVar5 = iVar5 + 1;

    } while (iVar5 < iStack_4);

  }

  return bVar4;

}





// --- FUN_0059e760 at 0x0059E760 (size: 96) ---


void FUN_0059e760(int param_1,int param_2,int param_3)



{

  ushort uVar1;

  byte bVar2;

  

  if (param_2 == 0) {

    bVar2 = *(byte *)(param_1 + 0xf) & 1;

    uVar1 = *(ushort *)(param_1 + 0x1c);

    DAT_0086738c = *(undefined4 *)(param_1 + 0x14);

  }

  else {

    bVar2 = *(byte *)(param_1 + 0xf) & 2;

    uVar1 = *(ushort *)(param_1 + 0x1e);

    DAT_0086738c = *(undefined4 *)(param_1 + 0x18);

  }

  FUN_0059d520(*(undefined4 *)(DAT_0086737c + (uint)uVar1 * 4),bVar2 != 0,param_3 != 0,0);

  return;

}





// --- FUN_0059e8a0 at 0x0059E8A0 (size: 43) ---


undefined4 FUN_0059e8a0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  if (DAT_00821e44 == 0) {

    return 1;

  }

  uVar1 = FUN_0059e5b0(*(undefined4 *)(param_1 + 0x34),DAT_0086737c,param_2,0);

  return uVar1;

}





// --- FUN_0059e8d0 at 0x0059E8D0 (size: 986) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void FUN_0059e8d0(int *param_1)



{

  undefined4 *puVar1;

  byte bVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  undefined4 *puVar6;

  float *pfVar7;

  int iVar8;

  bool bVar9;

  undefined4 uVar10;

  

  if ((DAT_008ee3a8 == 0) &&

     ((*(uint *)(*(int *)(DAT_0086737c + (uint)*(ushort *)(param_1 + 7) * 4) + 0x58) & 6) != 0)) {

    FUN_0054c9f0();

    if ((DAT_00821e50 == 0) ||

       (((*(char *)(DAT_00870340 + 0x44) == '\0' || (DAT_00867374 == 0)) || (DAT_00821e4c == 0)))) {

      bVar9 = false;

    }

    else {

      bVar9 = true;

    }

    DAT_0086738c = param_1[5];

    iVar3 = FUN_0059d520(*(undefined4 *)(DAT_0086737c + (uint)*(ushort *)(param_1 + 7) * 4),

                         (*(byte *)((int)param_1 + 0xf) & 1) != 0,

                         CONCAT31((int3)((uint)DAT_0086738c >> 8),bVar9),0);

    if ((DAT_008ee3a4 == 0) && (param_1[4] != 1)) {

      uVar10 = 2;

    }

    else {

      uVar10 = 1;

    }

    FUN_005a3d80(uVar10);

    if ((DAT_008ee3a0 == 0) || (*(char *)(DAT_00870340 + 0x7e0) != '\0')) {

      uVar10 = 1;

    }

    else {

      uVar10 = 0;

    }

    FUN_005a41f0(uVar10);

    if (bVar9) {

      FUN_006b71c0(1);

      (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0x164))(*(int **)(DAT_00870340 + 0x468),0x252)

      ;

      iVar3 = 0;

      if (*(char *)((int)param_1 + 0xe) != '\0') {

        puVar6 = &DAT_008ee1ec;

        iVar4 = DAT_0086738c;

        do {

          puVar1 = *(undefined4 **)(*param_1 + iVar3 * 4);

          puVar6[-1] = *puVar1;

          *puVar6 = puVar1[1];

          puVar6[1] = puVar1[2];

          puVar6[2] = puVar1[5];

          puVar6[3] = puVar1[6];

          iVar8 = DAT_00821e48;

          puVar6[4] = puVar1[7];

          iVar5 = 0xff;

          if (iVar8 == 0) {

            iVar4 = FUN_0059c9a0(puVar1,0);

            iVar5 = FUN_006b7170(*(undefined4 *)(iVar4 + 8));

            iVar4 = DAT_0086738c;

          }

          bVar9 = DAT_00867388 != 0;

          puVar6[5] = iVar5 << 0x18 | 0xffffff;

          if ((bVar9) && (puVar1[4] != 0)) {

            puVar6[6] = _DAT_0081fccc * *(float *)(puVar1[4] + *(char *)(iVar4 + iVar3) * 8);

            puVar6[7] = _DAT_0081fcd0 * *(float *)(puVar1[4] + 4 + *(char *)(iVar4 + iVar3) * 8);

            puVar6[8] = DAT_0081fcc8 * (float)puVar6[6];

            puVar6[9] = DAT_0081fcc8 * (float)puVar6[7];

          }

          iVar3 = iVar3 + 1;

          puVar6 = puVar6 + 0xb;

        } while (iVar3 < (int)(uint)*(byte *)((int)param_1 + 0xe));

      }

      FUN_005a1520(6,*(byte *)((int)param_1 + 0xe) - 2,&DAT_008ee1e8,0x2c);

      return;

    }

    (**(code **)(**(int **)(DAT_00870340 + 0x468) + 0x164))(*(int **)(DAT_00870340 + 0x468),0x152);

    iVar4 = 0;

    if (*(char *)((int)param_1 + 0xe) != '\0') {

      puVar6 = &DAT_008ee084;

      iVar8 = DAT_0086738c;

      do {

        puVar1 = *(undefined4 **)(*param_1 + iVar4 * 4);

        puVar6[-1] = *puVar1;

        *puVar6 = puVar1[1];

        puVar6[1] = puVar1[2];

        puVar6[2] = puVar1[5];

        puVar6[3] = puVar1[6];

        puVar6[4] = puVar1[7];

        puVar6[5] = iVar3 << 0x18 | 0xffffff;

        iVar5 = DAT_0086738c;

        if (((DAT_00867374 != 0) && (DAT_00821e4c != 0)) && (iVar3 != 0xff)) {

          iVar3 = 0xff;

        }

        if (DAT_00867388 != 0) {

          puVar6[6] = _DAT_0081fccc * *(float *)(puVar1[4] + *(char *)(iVar8 + iVar4) * 8);

          puVar6[7] = _DAT_0081fcd0 * *(float *)(puVar1[4] + 4 + *(char *)(iVar5 + iVar4) * 8);

          iVar8 = iVar5;

        }

        iVar4 = iVar4 + 1;

        puVar6 = puVar6 + 9;

      } while (iVar4 < (int)(uint)*(byte *)((int)param_1 + 0xe));

    }

    FUN_005a1520(6,*(byte *)((int)param_1 + 0xe) - 2,&DAT_008ee080,0x24);

    if ((DAT_00821e4c == 0) || ((*(byte *)(DAT_00867380 + 0x58) & 4) != 0)) {

      bVar9 = false;

    }

    else {

      bVar9 = true;

    }

    if ((DAT_00867374 != 0) && (bVar9)) {

      FUN_006b71c0(0);

      bVar9 = false;

      iVar3 = 0;

      if (*(char *)((int)param_1 + 0xe) != '\0') {

        pfVar7 = (float *)&DAT_008ee09c;

        do {

          bVar2 = 0xff;

          if (DAT_00821e48 == 0) {

            iVar4 = FUN_0059c9a0(*(undefined4 *)(*param_1 + iVar3 * 4),0);

            bVar2 = FUN_006b7170(*(undefined4 *)(iVar4 + 8));

            if (bVar2 != 0) goto LAB_0059ec4a;

          }

          else {

LAB_0059ec4a:

            bVar9 = true;

          }

          pfVar7[-1] = (float)((uint)bVar2 << 0x18 | (uint)pfVar7[-1] & 0xffffff);

          if (DAT_00867388 != 0) {

            *pfVar7 = DAT_0081fcc8 * *pfVar7;

            pfVar7[1] = DAT_0081fcc8 * pfVar7[1];

          }

          iVar3 = iVar3 + 1;

          pfVar7 = pfVar7 + 9;

        } while (iVar3 < (int)(uint)*(byte *)((int)param_1 + 0xe));

        if (bVar9) {

          FUN_005a1520(6,*(byte *)((int)param_1 + 0xe) - 2,&DAT_008ee080,0x24);

        }

      }

    }

  }

  return;

}





// --- FUN_0059ece0 at 0x0059ECE0 (size: 242) ---


undefined4 __fastcall FUN_0059ece0(int param_1)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  char cVar4;

  int *piVar5;

  uint uVar6;

  int iVar7;

  uint uVar8;

  undefined1 local_c [12];

  

  piVar5 = (int *)FUN_0052dcf0(local_c);

  iVar7 = piVar5[2];

  iVar1 = *piVar5;

  piVar5 = (int *)piVar5[1];

  while (iVar7 != 0) {

    do {

      piVar2 = *(int **)(iVar7 + 8);

      if (piVar2 != (int *)0x0) {

        uVar8 = piVar2[0x2b];

        if (0xffff < uVar8) {

          uVar8 = 0xffff;

        }

        if ((uint)piVar2[0xb] < uVar8) {

          iVar3 = piVar2[0xc];

          uVar6 = uVar8 - piVar2[0xb];

          uVar6 = uVar6 + (uVar6 >> 1);

          if (uVar6 < 0x1000) {

            uVar6 = 0x1000;

          }

          uVar8 = uVar8 + uVar6;

          if (0xffff < uVar8) {

            uVar8 = 0xffff;

          }

          (**(code **)(*piVar2 + 0x14))();

          cVar4 = (**(code **)(*piVar2 + 0x10))(uVar8,iVar3,1);

          if (cVar4 == '\0') {

            return 0;

          }

        }

        FUN_00698910();

      }

      iVar7 = *(int *)(iVar7 + 4);

    } while (iVar7 != 0);

    do {

      piVar5 = piVar5 + 1;

      if (piVar5 == (int *)(*(int *)(iVar1 + 0x60) + *(int *)(iVar1 + 0x68) * 4)) goto LAB_0059edab;

      iVar7 = *piVar5;

    } while (iVar7 == 0);

  }

LAB_0059edab:

  if (*(int *)(param_1 + 0x94) != 0) {

    FUN_00698d90();

  }

  return 1;

}





// --- FUN_0059ede0 at 0x0059EDE0 (size: 218) ---


undefined4 * __fastcall FUN_0059ede0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e6570;

  param_1[1] = 0;

  param_1[2] = 800;

  param_1[3] = 600;

  *(undefined1 *)(param_1 + 4) = 0;

  param_1[5] = 0;

  param_1[6] = 0x20;

  *(undefined1 *)(param_1 + 7) = 0;

  *(undefined1 *)((int)param_1 + 0x1d) = 0;

  *(undefined1 *)((int)param_1 + 0x1e) = 0;

  param_1[8] = 0;

  *(undefined1 *)((int)param_1 + 0x25) = 0;

  *(undefined1 *)(param_1 + 9) = 1;

  *(undefined1 *)((int)param_1 + 0x26) = 1;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  *(undefined1 *)(param_1 + 0x11) = 0;

  *(undefined1 *)((int)param_1 + 0x45) = 0;

  *(undefined1 *)((int)param_1 + 0x46) = 0;

  *(undefined1 *)((int)param_1 + 0x47) = 0;

  *(undefined1 *)(param_1 + 0x12) = 0;

  *(undefined1 *)((int)param_1 + 0x49) = 0;

  *(undefined1 *)((int)param_1 + 0x4a) = 0;

  *(undefined1 *)((int)param_1 + 0x4b) = 0;

  *(undefined1 *)(param_1 + 0x13) = 0;

  *(undefined1 *)((int)param_1 + 0x4d) = 0;

  *(undefined1 *)((int)param_1 + 0x4e) = 0;

  *(undefined1 *)((int)param_1 + 0x4f) = 0;

  *(undefined1 *)(param_1 + 0x14) = 0;

  *(undefined1 *)((int)param_1 + 0x51) = 0;

  *(undefined1 *)((int)param_1 + 0x52) = 0;

  *(undefined1 *)((int)param_1 + 0x53) = 0;

  *(undefined1 *)(param_1 + 0x15) = 0;

  *(undefined1 *)((int)param_1 + 0x55) = 0;

  *(undefined1 *)(param_1 + 0x16) = 0;

  *(undefined1 *)((int)param_1 + 0x59) = 0;

  *(undefined1 *)((int)param_1 + 0x5a) = 0;

  *(undefined1 *)((int)param_1 + 0x5b) = 0;

  *(undefined1 *)(param_1 + 0x17) = 0;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  FUN_00550150();

  FUN_00550850();

  return param_1;

}





// --- FUN_0059eed0 at 0x0059EED0 (size: 56) ---


void __fastcall FUN_0059eed0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007e6570;

  FUN_005502a0();

  if (((param_1[0x73] & 0x80000000) == 0x80000000) && (param_1[0x72] != 0)) {

    operator_delete__((void *)(param_1[0x72] + -4));

  }

  return;

}





// --- FUN_0059ef10 at 0x0059EF10 (size: 76) ---


undefined4 * __thiscall FUN_0059ef10(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e6570;

  FUN_005502a0();

  if (((param_1[0x73] & 0x80000000) == 0x80000000) && (param_1[0x72] != 0)) {

    operator_delete__((void *)(param_1[0x72] + -4));

  }

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059ef60 at 0x0059EF60 (size: 54) ---


undefined4 * __thiscall FUN_0059ef60(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007e65e8;

  FUN_005a2c50();

  FUN_004020c0();

  FUN_0059eed0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0059efa0 at 0x0059EFA0 (size: 258) ---


undefined4 __fastcall FUN_0059efa0(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  char cVar3;

  uint uVar4;

  uint uVar5;

  undefined4 unaff_EBX;

  uint uVar6;

  uint uVar7;

  undefined4 uStack_4c;

  undefined4 uStack_48;

  

  uVar4 = (**(code **)(**(int **)(param_1 + 0x1c) + 0x18))

                    (*(int **)(param_1 + 0x1c),*(undefined4 *)(param_1 + 8));

  uVar6 = 0;

  if (uVar4 != 0) {

    do {

      (**(code **)(*piRam00000032 + 0x1c))(piRam00000032,uRam0000001e,0x16,uVar6,&stack0xffffffac);

      if (uRam0000002a < (uRam00000026 & 0x7fffffff)) {

LAB_0059f04a:

        uRam0000002a = uRam0000002a + 1;

      }

      else {

        uVar5 = (uRam00000026 & 0x7fffffff) + 1;

        if (uVar5 < 9) {

          uVar5 = 8;

        }

        else if (uVar5 < 0x4001) {

          iVar2 = 0x1f;

          if (uVar5 != 0) {

            for (; uVar5 >> iVar2 == 0; iVar2 = iVar2 + -1) {

            }

          }

          uVar7 = 1 << ((byte)iVar2 & 0x1f);

          if (uVar7 < uVar5) {

            uVar5 = uVar7 * 2;

          }

        }

        else if ((uVar5 & 0x3fff) != 0) {

          uVar5 = uVar5 + (0x4000 - (uVar5 & 0x3fff));

        }

        cVar3 = FUN_0059df80(uVar5);

        if (cVar3 != '\0') goto LAB_0059f04a;

      }

      puVar1 = (undefined4 *)(uRam0000002a * 0x10 + -0x10 + iRam00000022);

      *puVar1 = unaff_EBX;

      puVar1[1] = param_1;

      puVar1[2] = uStack_48;

      puVar1[3] = uStack_4c;

      FUN_00535a80();

      FUN_0043d290(puVar1[2]);

      uVar6 = uVar6 + 1;

    } while (uVar6 < uVar4);

  }

  return 1;

}





// --- FUN_0059f0b0 at 0x0059F0B0 (size: 2543) ---


undefined4

FUN_0059f0b0(uint param_1,int param_2,int param_3,int param_4,int param_5,float param_6,char param_7

            )



{

  int *piVar1;

  uint *puVar2;

  char cVar3;

  ushort uVar4;

  int *piVar5;

  int iVar6;

  ushort *puVar7;

  undefined4 *puVar8;

  int iVar9;

  int *piVar10;

  undefined4 uVar11;

  uint uVar12;

  uint uVar13;

  int iVar14;

  int iVar15;

  int iVar16;

  int iVar17;

  int *unaff_ESI;

  uint *puVar18;

  uint uVar19;

  uint uVar20;

  void *pvVar21;

  int *piVar22;

  int *piVar23;

  int *piVar24;

  int *piVar25;

  int *piVar26;

  int *local_5c;

  int local_58;

  int *local_54;

  uint local_50;

  undefined4 *local_4c;

  int local_48;

  int iStack_44;

  int iStack_40;

  int local_3c;

  uint local_38;

  int iStack_34;

  uint local_30;

  int iStack_2c;

  uint uStack_20;

  int iStack_1c;

  int local_18;

  int iStack_14;

  undefined4 *puStack_10;

  undefined4 uStack_c;

  undefined4 uStack_8;

  int local_4;

  

  piVar5 = (int *)FUN_005df0f5(0x24);

  iVar17 = 0;

  if (piVar5 == (int *)0x0) {

    piVar5 = (int *)0x0;

  }

  else {

    *piVar5 = 0;

    piVar5[1] = 0;

    piVar5[2] = 0;

    piVar5[3] = 0;

    piVar5[4] = 0;

    *(undefined1 *)(piVar5 + 5) = 0;

    *(undefined1 *)((int)piVar5 + 0x15) = 0;

    piVar5[8] = 0;

  }

  local_54 = piVar5;

  iVar6 = thunk_FUN_005df0f5(param_1);

  piVar5[4] = iVar6;

  uVar19 = 1;

  local_48 = 0;

  local_18 = 0;

  local_50 = 1;

  *(char *)(piVar5 + 5) = (param_7 == '\0') + -1;

  local_58 = *(int *)(param_3 + 0x20);

  if (local_58 != 0) {

    puVar7 = (ushort *)(*(int *)(param_3 + 0x24) + 0xe);

    iVar6 = local_58;

    do {

      if (uVar19 < *puVar7) {

        uVar19 = (uint)*puVar7;

      }

      puVar7 = puVar7 + 0x10;

      iVar6 = iVar6 + -1;

      local_50 = uVar19;

    } while (iVar6 != 0);

  }

  uVar19 = local_58 * local_50 * 8;

  local_4c = (undefined4 *)thunk_FUN_005df0f5(uVar19);

  puVar8 = local_4c;

  for (uVar19 = uVar19 >> 2; uVar19 != 0; uVar19 = uVar19 - 1) {

    *puVar8 = 0xffffffff;

    puVar8 = puVar8 + 1;

  }

  for (iVar6 = 0; iVar6 != 0; iVar6 = iVar6 + -1) {

    *(undefined1 *)puVar8 = 0xff;

    puVar8 = (undefined4 *)((int)puVar8 + 1);

  }

  if ((DAT_008ee3c4 & 1) == 0) {

    DAT_008ee3c4 = DAT_008ee3c4 | 1;

    DAT_008ee3b8 = 0;

    DAT_008ee3bc = 0;

    DAT_008ee3c0 = 0;

    _atexit((_func_4879 *)&LAB_007769f0);

  }

  if ((param_1 <= (DAT_008ee3bc & 0x7fffffff)) || (cVar3 = FUN_0059e040(param_1), cVar3 != '\0')) {

    DAT_008ee3c0 = param_1;

  }

  iVar6 = 0;

  if (0 < (int)param_1) {

    iVar14 = 0;

    do {

      puVar8 = (undefined4 *)(DAT_008ee3b8 + iVar14);

      puVar8[1] = 0;

      puVar8[2] = 0;

      *puVar8 = 0;

      puVar8[3] = 0xffffffff;

      puVar8[4] = 0;

      uVar19 = *(uint *)(*(int *)(param_2 + iVar6 * 4) + 0x58);

      if ((uVar19 & 0x10300) == 0) {

        if ((uVar19 & 4) == 0) {

          if ((uVar19 & 0x10) == 0) {

            *(undefined1 *)(iVar6 + piVar5[4]) = 0;

          }

          else {

            *(undefined1 *)(iVar6 + piVar5[4]) = 4;

          }

        }

        else {

          *(undefined1 *)(iVar6 + piVar5[4]) = 8;

        }

      }

      else {

        *(undefined1 *)(iVar6 + piVar5[4]) = 2;

      }

      iVar6 = iVar6 + 1;

      iVar14 = iVar14 + 0x14;

    } while (iVar6 < (int)param_1);

  }

  if (0 < param_4) {

    piVar5 = (int *)(param_5 + 0x10);

    local_3c = param_4;

    do {

      local_38 = (uint)*(byte *)((int)piVar5 + -2);

      iVar6 = *piVar5;

      iVar14 = local_38 - 2;

      if ((iVar6 == 2) || (iVar16 = iVar14, iVar6 == 1)) {

        iVar16 = iVar14 * 2;

      }

      local_48 = local_48 + iVar16;

      iVar16 = 1;

      if (iVar6 == 2) {

        iVar16 = 2;

      }

      if (iVar16 != 0) {

        iVar6 = 0;

        do {

          if (iVar6 == 0) {

            uVar4 = *(ushort *)(piVar5 + 3);

          }

          else {

            uVar4 = *(ushort *)((int)piVar5 + 0xe);

          }

          iVar9 = DAT_008ee3b8 + (uint)uVar4 * 0x14;

          iVar15 = *(int *)(iVar9 + 4) + iVar14;

          *(int *)(iVar9 + 4) = iVar15;

          if (*piVar5 == 1) {

            *(int *)(iVar9 + 4) = iVar15 + iVar14;

          }

          iVar6 = iVar6 + 1;

        } while (iVar6 < iVar16);

      }

      *(byte *)(local_54[4] + (uint)*(ushort *)(piVar5 + 3)) =

           *(byte *)(local_54[4] + (uint)*(ushort *)(piVar5 + 3)) |

           '\0' < *(char *)((int)piVar5 + -1);

      iVar6 = 0;

      if (local_38 != 0) {

        do {

          iVar14 = piVar5[1];

          if (iVar14 == 0) {

            iVar16 = 0;

          }

          else {

            iVar16 = (int)*(char *)(iVar14 + iVar6);

          }

          uVar19 = (uint)*(ushort *)(piVar5[-3] + iVar6 * 2);

          if (local_4c[iVar16 * local_58 + uVar19] == -1) {

            if (iVar14 == 0) {

              iVar14 = 0;

            }

            else {

              iVar14 = (int)*(char *)(iVar14 + iVar6);

            }

            local_4c[iVar14 * local_58 + uVar19] = iVar17;

            iVar17 = iVar17 + 1;

          }

          if (*piVar5 == 1) {

            iVar14 = piVar5[1];

            if (iVar14 == 0) {

              iVar16 = 0;

            }

            else {

              iVar16 = (int)*(char *)(iVar14 + iVar6);

            }

            uVar19 = (uint)*(ushort *)(piVar5[-3] + iVar6 * 2);

            if (local_4c[(iVar16 + local_50) * local_58 + uVar19] == -1) {

              if (iVar14 == 0) {

                iVar14 = 0;

              }

              else {

                iVar14 = (int)*(char *)(iVar14 + iVar6);

              }

              local_4c[(iVar14 + local_50) * local_58 + uVar19] = iVar17;

              iVar17 = iVar17 + 1;

            }

          }

          if (*piVar5 == 2) {

            iVar14 = piVar5[2];

            if (iVar14 == 0) {

              iVar16 = 0;

            }

            else {

              iVar16 = (int)*(char *)(iVar14 + iVar6);

            }

            uVar19 = (uint)*(ushort *)(piVar5[-3] + iVar6 * 2);

            if (local_4c[(iVar16 + local_50) * local_58 + uVar19] == -1) {

              if (iVar14 == 0) {

                iVar14 = 0;

              }

              else {

                iVar14 = (int)*(char *)(iVar14 + iVar6);

              }

              local_4c[(iVar14 + local_50) * local_58 + uVar19] = iVar17;

              iVar17 = iVar17 + 1;

            }

          }

          iVar6 = iVar6 + 1;

        } while (iVar6 < (int)local_38);

      }

      piVar5 = piVar5 + 0xc;

      local_3c = local_3c + -1;

    } while (local_3c != 0);

    local_3c = 0;

    piVar5 = local_54;

    local_18 = iVar17;

  }

  iVar6 = 0;

  if (0 < (int)param_1) {

    iVar14 = 0;

    do {

      piVar10 = (int *)(DAT_008ee3b8 + iVar14);

      *piVar10 = iVar6;

      iVar6 = iVar6 + piVar10[1];

      iVar14 = iVar14 + 0x14;

      param_1 = param_1 - 1;

    } while (param_1 != 0);

  }

  iVar6 = 0x252;

  if (param_6 <= DAT_00796344) {

    iVar6 = 0x152;

  }

  piVar5[2] = iVar6;

  uVar11 = 0x220;

  local_4 = (uint)(iVar6 == 0x252) * 8 + 0x24;

  if (*(char *)(DAT_00870340 + 0x4c) == '\0') {

    uVar11 = 0x18220;

  }

  iVar17 = FUN_005ee7e5(local_48,iVar17,uVar11,iVar6,*(undefined4 *)(DAT_00870340 + 0x468),&local_5c

                       );

  if (iVar17 < 0) {

    piVar10 = (int *)*piVar5;

    if (piVar10 != (int *)0x0) {

      (**(code **)(*piVar10 + 8))(piVar10);

      *piVar5 = 0;

    }

    if ((int *)piVar5[1] != (int *)0x0) {

      (**(code **)(*(int *)piVar5[1] + 0x14))();

      piVar5[1] = 0;

    }

    operator_delete__((void *)piVar5[4]);

    piVar5[4] = 0;

    operator_delete(piVar5);

    return 0;

  }

  puVar18 = &local_30;

  piVar26 = (int *)0x0;

  piVar10 = local_5c;

  iVar17 = (**(code **)(*local_5c + 0x3c))();

  if (iVar17 < 0) {

    piVar10 = (int *)*piVar5;

    if (piVar10 != (int *)0x0) {

      (**(code **)(*piVar10 + 8))(piVar10);

      *piVar5 = 0;

    }

    if ((int *)piVar5[1] != (int *)0x0) {

      (**(code **)(*(int *)piVar5[1] + 0x14))();

      piVar5[1] = 0;

    }

    operator_delete__((void *)piVar5[4]);

    piVar5[4] = 0;

    operator_delete(piVar5);

    if (unaff_ESI == (int *)0x0) {

      return 0;

    }

    (**(code **)(*unaff_ESI + 8))(unaff_ESI);

    return 0;

  }

  piVar25 = &iStack_40;

  piVar24 = (int *)0x0;

  iVar17 = (**(code **)(*unaff_ESI + 0x44))();

  if (iVar17 < 0) {

    (**(code **)(*piVar26 + 0x40))(piVar26);

    piVar26 = (int *)*piVar5;

    if (piVar26 != (int *)0x0) {

      (**(code **)(*piVar26 + 8))(piVar26);

      *piVar5 = 0;

    }

    if ((int *)piVar5[1] != (int *)0x0) {

      (**(code **)(*(int *)piVar5[1] + 0x14))();

      piVar5[1] = 0;

    }

    operator_delete__((void *)piVar5[4]);

    piVar5[4] = 0;

    operator_delete(piVar5);

    if (piVar10 == (int *)0x0) {

      return 0;

    }

    (**(code **)(*piVar10 + 8))(piVar10);

    return 0;

  }

  piVar23 = &iStack_44;

  piVar22 = (int *)0x0;

  iVar17 = (**(code **)(*piVar26 + 0x60))(piVar26);

  if (iVar17 < 0) {

    (**(code **)(*piVar24 + 0x40))(piVar24);

    (**(code **)(*unaff_ESI + 0x48))(unaff_ESI);

    piVar10 = (int *)*piVar5;

    if (piVar10 != (int *)0x0) {

      (**(code **)(*piVar10 + 8))(piVar10);

      *piVar5 = 0;

    }

    if ((int *)piVar5[1] != (int *)0x0) {

      (**(code **)(*(int *)piVar5[1] + 0x14))();

      piVar5[1] = 0;

    }

    operator_delete__((void *)piVar5[4]);

    piVar5[4] = 0;

    operator_delete(piVar5);

    if (piVar23 == (int *)0x0) {

      return 0;

    }

    (**(code **)(*piVar23 + 8))(piVar23);

    return 0;

  }

  if (0 < iStack_14) {

    piVar5 = puStack_10 + 4;

    iStack_40 = iStack_14;

    do {

      local_48 = *(byte *)((int)piVar5 + -2) - 2;

      iStack_44 = 1;

      local_5c = (int *)0x1;

      if (*piVar5 == 2) {

        iStack_44 = 2;

      }

      if (*piVar5 == 1) {

        local_5c = (int *)0x2;

      }

      uStack_20 = 0;

      if (iStack_44 != 0) {

        do {

          if (uStack_20 == 0) {

            uVar4 = *(ushort *)(piVar5 + 3);

          }

          else {

            uVar4 = *(ushort *)((int)piVar5 + 0xe);

          }

          local_30 = (uint)uVar4;

          iVar17 = *(int *)(iStack_1c + local_30 * 4);

          if ((*(byte *)(iVar17 + 0x58) & 0x10) == 0) {

            local_4c = (undefined4 *)0x0;

          }

          else {

            local_4c = *(undefined4 **)(iVar17 + 0x74);

          }

          piVar1 = (int *)(DAT_008ee3b8 + local_30 * 0x14);

          iStack_14 = 0;

          if (0 < (int)local_5c) {

            do {

              if (uStack_20 == 0) {

                iVar17 = piVar5[1];

              }

              else {

                iVar17 = piVar5[2];

              }

              iVar6 = 0;

              if (0 < local_48) {

                local_38 = (iStack_14 + uStack_20) * (int)piVar26;

                do {

                  iStack_2c = *piVar1 + piVar1[2];

                  iStack_34 = iStack_2c * 3;

                  iVar14 = 0;

                  do {

                    if (iVar14 == 0) {

                      iVar16 = 0;

                    }

                    else {

                      iVar16 = iVar14 + iVar6;

                    }

                    if (iVar17 == 0) {

                      iVar9 = 0;

                    }

                    else {

                      iVar9 = (int)*(char *)(iVar16 + iVar17);

                    }

                    uVar19 = puVar18[(local_38 + iVar9) * (int)piVar25 +

                                     (uint)*(ushort *)(piVar5[-3] + iVar16 * 2)];

                    iVar16 = iVar14;

                    if (iStack_14 != 0) {

                      iVar16 = 2 - iVar14;

                    }

                    *(ushort *)(local_58 + (iStack_34 + iVar16) * 2) = (ushort)uVar19;

                    uVar19 = (uint)(ushort)uVar19;

                    if (uVar19 < (uint)piVar1[3]) {

                      piVar1[3] = uVar19;

                    }

                    if ((uint)piVar1[4] < uVar19) {

                      piVar1[4] = uVar19;

                    }

                    if ((iStack_14 == 0) && (uStack_20 == 0)) {

                      uVar11 = 1;

                    }

                    else {

                      uVar11 = 0xffffffff;

                    }

                    FUN_0059d090(uVar19,uVar11,uStack_c,local_4c,uStack_8,piVar10[2]);

                    iVar14 = iVar14 + 1;

                  } while (iVar14 < 3);

                  if (local_50 != 0) {

                    *(uint *)(local_50 + iStack_2c * 4) = local_30;

                  }

                  piVar1[2] = piVar1[2] + 1;

                  iVar6 = iVar6 + 1;

                } while (iVar6 < local_48);

              }

              iStack_14 = iStack_14 + 1;

            } while (iStack_14 < (int)local_5c);

          }

          uStack_20 = uStack_20 + 1;

        } while ((int)uStack_20 < iStack_44);

      }

      piVar5 = piVar5 + 0xc;

      iStack_40 = iStack_40 + -1;

    } while (iStack_40 != 0);

  }

  operator_delete__(puVar18);

  (**(code **)(*piVar24 + 0x40))(piVar24);

  (**(code **)(*unaff_ESI + 0x48))(unaff_ESI);

  (**(code **)(*piVar23 + 100))(piVar23);

  if ((DAT_008ee3c4 & 2) == 0) {

    DAT_008ee3c4 = DAT_008ee3c4 | 2;

    DAT_008ee3ac = 0;

    DAT_008ee3b0 = 0;

    DAT_008ee3b4 = 0;

    _atexit((_func_4879 *)&LAB_007769d0);

  }

  uVar19 = 0;

  DAT_008ee3b4 = 0;

  if (DAT_008ee3c0 != 0) {

    iStack_2c = 0;

    uVar12 = 0;

    do {

      puVar18 = (uint *)(iStack_2c + DAT_008ee3b8);

      if (*(int *)(iStack_2c + 4 + DAT_008ee3b8) != 0) {

        uVar13 = uVar12;

        if (uVar12 < (DAT_008ee3b0 & 0x7fffffff)) {

LAB_0059f964:

          DAT_008ee3b4 = uVar13 + 1;

        }

        else {

          uVar13 = (DAT_008ee3b0 & 0x7fffffff) + 1;

          if (uVar13 < 9) {

            uVar13 = 8;

          }

          else if (uVar13 < 0x4001) {

            iVar17 = 0x1f;

            if (uVar13 != 0) {

              for (; uVar13 >> iVar17 == 0; iVar17 = iVar17 + -1) {

              }

            }

            uVar20 = 1 << ((byte)iVar17 & 0x1f);

            uStack_20 = uVar13;

            if (uVar20 < uVar13) {

              uVar13 = uVar20 * 2;

            }

          }

          else if ((uVar13 & 0x3fff) != 0) {

            uVar13 = uVar13 + (0x4000 - (uVar13 & 0x3fff));

          }

          cVar3 = FUN_0059e040(uVar13);

          uVar13 = DAT_008ee3b4;

          if (cVar3 != '\0') goto LAB_0059f964;

        }

        puVar2 = (uint *)(DAT_008ee3ac + uVar12 * 0x14);

        *puVar2 = uVar19;

        puVar2[1] = *puVar18;

        puVar2[2] = puVar18[1];

        puVar2[3] = puVar18[3];

        puVar2[4] = (puVar18[4] - puVar18[3]) + 1;

        uVar12 = DAT_008ee3b4;

      }

      uVar19 = uVar19 + 1;

      iStack_2c = iStack_2c + 0x14;

    } while (uVar19 < DAT_008ee3c0);

    if (uVar12 != 0) {

      iVar17 = (**(code **)(*piVar22 + 0x70))(piVar22,DAT_008ee3ac,uVar12);

      if (iVar17 == 0) {

        unaff_ESI[8] = iStack_34 * local_48 + DAT_008ee3b4 * 0x14 + (int)piVar10 * 6;

        *unaff_ESI = (int)piVar22;

        unaff_ESI[3] = local_18;

        *puStack_10 = unaff_ESI;

        return 1;

      }

      if (piVar22 != (int *)0x0) {

        (**(code **)(*piVar22 + 8))(piVar22);

      }

      piVar5 = (int *)*unaff_ESI;

      if (piVar5 != (int *)0x0) {

        (**(code **)(*piVar5 + 8))(piVar5);

        *unaff_ESI = 0;

      }

      if ((int *)unaff_ESI[1] != (int *)0x0) {

        (**(code **)(*(int *)unaff_ESI[1] + 0x14))();

        unaff_ESI[1] = 0;

      }

      pvVar21 = (void *)unaff_ESI[4];

      goto LAB_0059fa3c;

    }

  }

  if (piVar22 != (int *)0x0) {

    (**(code **)(*piVar22 + 8))(piVar22);

  }

  piVar5 = (int *)*unaff_ESI;

  if (piVar5 != (int *)0x0) {

    (**(code **)(*piVar5 + 8))(piVar5);

    *unaff_ESI = 0;

  }

  if ((int *)unaff_ESI[1] != (int *)0x0) {

    (**(code **)(*(int *)unaff_ESI[1] + 0x14))();

    unaff_ESI[1] = 0;

  }

  pvVar21 = (void *)unaff_ESI[4];

LAB_0059fa3c:

  operator_delete__(pvVar21);

  unaff_ESI[4] = 0;

  operator_delete(unaff_ESI);

  return 0;

}





// --- FUN_0059fba0 at 0x0059FBA0 (size: 51) ---


void FUN_0059fba0(int param_1,undefined4 param_2)



{

  FUN_0059f0b0(*(undefined4 *)(param_1 + 0x34),*(undefined4 *)(param_1 + 0x38),param_1 + 0x3c,

               *(undefined4 *)(param_1 + 0x88),*(undefined4 *)(param_1 + 0x8c),0x3f800000,0,param_2)

  ;

  return;

}





// --- FUN_0059fbe0 at 0x0059FBE0 (size: 539) ---


void __fastcall FUN_0059fbe0(int param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  int local_8;

  int local_4;

  

  *(undefined4 *)(param_1 + 0x18) = 0;

  *(undefined4 *)(param_1 + 0x1c) = 0;

  FUN_005870f0();

  *(undefined4 *)(param_1 + 0x94) = 0;

  puVar2 = (undefined4 *)(param_1 + 0x98);

  *puVar2 = 0;

  FUN_00401340("Texture sampler mipmap LOD bias");

  FUN_00401340("RenderD3D.MipmapLODBias");

  if (puVar2 != (undefined4 *)0x0) {

    FUN_004369a0(puVar2,9,&local_8,&local_4,0,0,0,0);

  }

  puVar2 = (undefined4 *)(local_8 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = (undefined4 *)(local_4 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340(

              "Mask for what mesh types will get delay-rendered. Alpha=2, Translucent=4, ClipMap=8."

              );

  FUN_00401340("RenderD3D.AlphaDelayMask");

  FUN_004369a0(&DAT_00821d98,4,&local_4,&local_8,0,0,0,0);

  puVar2 = (undefined4 *)(local_4 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = (undefined4 *)(local_8 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340("Z-Buffer test ref value (for DDS textures)");

  FUN_00401340("RenderD3D.DDSAlphaTestRef");

  FUN_004369a0(&DAT_00821da0,3,&local_4,&local_8,0,0,0,0);

  puVar2 = (undefined4 *)(local_4 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  puVar2 = (undefined4 *)(local_8 + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar1 == 0) && (puVar2 != (undefined4 *)0x0)) {

    (**(code **)*puVar2)(1);

  }

  FUN_00401340("Z-Buffer test ref value (for palettized textures)");

  FUN_00401340("RenderD3D.256AlphaTestRef");

  FUN_004369a0(&DAT_00821d9c,3,&local_4,&local_8,0,0,0,0);

  LVar1 = InterlockedDecrement((LONG *)(local_4 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_4 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_4 + -0x14))(1);

  }

  LVar1 = InterlockedDecrement((LONG *)(local_8 + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_8 + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_8 + -0x14))(1);

  }

  return;

}





// --- FUN_0059fe00 at 0x0059FE00 (size: 405) ---


void __fastcall FUN_0059fe00(int param_1)



{

  LONG LVar1;

  int *piVar2;

  int iVar3;

  undefined4 *puVar4;

  int iVar5;

  int local_1c;

  int iStack_18;

  undefined1 auStack_c [12];

  

  FUN_00401340("RenderD3D.MipmapLODBias");

  FUN_00436cf0(&local_1c);

  puVar4 = (undefined4 *)(local_1c + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar1 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  FUN_00401340("RenderD3D.AlphaDelayMask");

  FUN_00436cf0(&local_1c);

  puVar4 = (undefined4 *)(local_1c + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar1 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  FUN_00401340("RenderD3D.DDSAlphaTestRef");

  FUN_00436cf0(&local_1c);

  puVar4 = (undefined4 *)(local_1c + -0x14);

  LVar1 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar1 == 0) && (puVar4 != (undefined4 *)0x0)) {

    (**(code **)*puVar4)(1);

  }

  FUN_00401340("RenderD3D.256AlphaTestRef");

  FUN_00436cf0(&local_1c);

  LVar1 = InterlockedDecrement((LONG *)(local_1c + -0x10));

  if ((LVar1 == 0) && ((undefined4 *)(local_1c + -0x14) != (undefined4 *)0x0)) {

    (*(code *)**(undefined4 **)(local_1c + -0x14))(1);

  }

  if (*(undefined4 **)(param_1 + 0x94) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x94))(1);

  }

  *(undefined4 *)(param_1 + 0x94) = 0;

  piVar2 = (int *)FUN_0052dcf0(auStack_c);

  iVar5 = piVar2[2];

  iVar3 = *piVar2;

  piVar2 = (int *)piVar2[1];

  iStack_18 = iVar3;

  while (iVar5 != 0) {

    do {

      if (*(undefined4 **)(iVar5 + 8) != (undefined4 *)0x0) {

        (**(code **)**(undefined4 **)(iVar5 + 8))(1);

        iVar3 = iStack_18;

      }

      iVar5 = *(int *)(iVar5 + 4);

    } while (iVar5 != 0);

    do {

      piVar2 = piVar2 + 1;

      if (piVar2 == (int *)(*(int *)(iVar3 + 0x60) + *(int *)(iVar3 + 0x68) * 4)) goto LAB_0059ff63;

      iVar5 = *piVar2;

    } while (iVar5 == 0);

  }

LAB_0059ff63:

  FUN_005870f0();

  piVar2 = *(int **)(param_1 + 0x1c);

  if (piVar2 != (int *)0x0) {

    (**(code **)(*piVar2 + 8))(piVar2);

    *(undefined4 *)(param_1 + 0x1c) = 0;

  }

  if (*(HMODULE *)(param_1 + 0x18) != (HMODULE)0x0) {

    FreeLibrary(*(HMODULE *)(param_1 + 0x18));

    *(undefined4 *)(param_1 + 0x18) = 0;

  }

  return;

}





// --- FUN_0059ffa0 at 0x0059FFA0 (size: 23) ---


void FUN_0059ffa0(void)



{

  FUN_0059fe00();

  FUN_0054f3b0();

  FUN_0059fbe0();

  return;

}





// --- FUN_0059ffc0 at 0x0059FFC0 (size: 179) ---


int * __thiscall FUN_0059ffc0(int param_1,uint param_2,uint param_3)



{

  uint *puVar1;

  char cVar2;

  int *piVar3;

  uint uVar4;

  

  puVar1 = *(uint **)(*(int *)(param_1 + 0x84) + (param_2 % *(uint *)(param_1 + 0x8c)) * 4);

  do {

    if (puVar1 == (uint *)0x0) {

LAB_0059ffee:

      piVar3 = (int *)FUN_005df0f5(0xb8);

      if (piVar3 != (int *)0x0) {

        FUN_00447220();

        *piVar3 = (int)&PTR_FUN_007e6520;

        FUN_00698580();

        uVar4 = 0x2000;

        if (0x2000 < param_3) {

          uVar4 = param_3;

        }

        cVar2 = (**(code **)(*piVar3 + 0x10))(uVar4,param_2,1);

        if (cVar2 != '\0') {

          FUN_006891f0(&stack0xfffffff8,&stack0xfffffff0);

          return piVar3;

        }

        (**(code **)*piVar3)(1);

      }

      return (int *)0x0;

    }

    if (*puVar1 == param_2) {

      if (puVar1 != (uint *)0x0) {

        return (int *)puVar1[2];

      }

      goto LAB_0059ffee;

    }

    puVar1 = (uint *)puVar1[1];

  } while( true );

}





