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

// --- FUN_00510000 at 0x00510000 (size: 33) ---


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



undefined4 FUN_00510000(int param_1)



{

  if (_DAT_008eee6c <= *(float *)(param_1 + 8)) {

    return 1;

  }

  return 0;

}





// --- FUN_00510030 at 0x00510030 (size: 7) ---


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



float10 FUN_00510030(void)



{

  return (float10)_DAT_008eee6c;

}





// --- FUN_00510040 at 0x00510040 (size: 63) ---


undefined4 __fastcall FUN_00510040(int param_1)



{

  int iVar1;

  

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

    iVar1 = FUN_00518c40();

    if (iVar1 != 0) {

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x10000;

      return 1;

    }

  }

  *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffeffff;

  return 0;

}





// --- FUN_00510080 at 0x00510080 (size: 74) ---


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



undefined4 __thiscall FUN_00510080(int param_1,undefined4 param_2)



{

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

     (_DAT_007c78bc <

      *(float *)(param_1 + 0xe0) * *(float *)(param_1 + 0x130) +

      *(float *)(param_1 + 0xe4) * *(float *)(param_1 + 0x134) +

      *(float *)(param_1 + 0xe8) * *(float *)(param_1 + 0x138))) {

    return 0;

  }

  return param_2;

}





// --- FUN_005100d0 at 0x005100D0 (size: 111) ---


undefined4

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

            undefined4 param_5)



{

  int iVar1;

  

  if ((int *)param_2[0x4b] != (int *)0x0) {

    iVar1 = (**(code **)(*(int *)param_2[0x4b] + 0x5c))(param_1);

    if (iVar1 != 0) {

      *param_1 = param_2[2];

      param_1[1] = *param_2;

      param_1[2] = param_2[1];

      param_1[3] = param_2[2];

      FUN_0051c4f0(param_4);

      FUN_0051c510(param_5);

      FUN_0051c530(param_3);

      return 1;

    }

  }

  return 0;

}





// --- FUN_00510140 at 0x00510140 (size: 30) ---


void __fastcall FUN_00510140(int param_1)



{

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  return;

}





// --- FUN_00510160 at 0x00510160 (size: 59) ---


undefined4 __thiscall FUN_00510160(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  uVar1 = 0;

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

    uVar1 = FUN_00519f00(param_2);

  }

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  return uVar1;

}





// --- FUN_005101a0 at 0x005101A0 (size: 29) ---


void __thiscall FUN_005101a0(int param_1,undefined4 *param_2)



{

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

  *(undefined4 *)(param_1 + 0xfc) = param_2[1];

  *(undefined4 *)(param_1 + 0x100) = param_2[2];

  return;

}





// --- FUN_005101c0 at 0x005101C0 (size: 97) ---


void __thiscall

FUN_005101c0(int param_1,undefined4 param_2,int param_3,undefined4 param_4,undefined4 param_5)



{

  undefined1 local_14 [4];

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_4;

  

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

    FUN_005268e0();

    local_10 = param_2;

    local_4 = param_5;

    local_c = param_4;

    if (param_3 != 0) {

      FUN_005261b0();

    }

    FUN_00526110(local_14);

    FUN_005aebf0();

  }

  return;

}





// --- FUN_00510230 at 0x00510230 (size: 16) ---


void __fastcall FUN_00510230(int param_1)



{

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

    FUN_005259c0();

    return;

  }

  return;

}





// --- FUN_00510240 at 0x00510240 (size: 15) ---


undefined4 __fastcall FUN_00510240(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00518870();

    return uVar1;

  }

  return 0;

}





// --- FUN_00510250 at 0x00510250 (size: 18) ---


undefined4 __fastcall FUN_00510250(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_005255d0();

    return uVar1;

  }

  return 0;

}





// --- FUN_00510270 at 0x00510270 (size: 194) ---


void __thiscall FUN_00510270(int param_1,float param_2,float param_3)



{

  int iVar1;

  float10 fVar2;

  undefined4 local_8;

  undefined4 local_4;

  

  iVar1 = (int)param_2;

  if (param_3 != 0.0) {

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

      param_2 = 0.0;

    }

    else {

      fVar2 = (float10)FUN_00518be0();

      param_2 = (float)fVar2;

    }

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

      param_3 = 0.0;

    }

    else {

      fVar2 = (float10)FUN_00518bd0();

      param_3 = (float)fVar2;

    }

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

      local_8 = 0.0;

    }

    else {

      fVar2 = (float10)FUN_00518be0();

      local_8 = (float)fVar2;

    }

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

      local_4 = 0.0;

    }

    else {

      fVar2 = (float10)FUN_00518bd0();

      local_4 = (float)fVar2;

    }

    FUN_005aa8a0(local_4,local_8,param_1 + 0x48,param_3,param_2,iVar1 + 0x48);

    return;

  }

  FUN_005aa560((int)param_2 + 0x48);

  return;

}





// --- FUN_00510340 at 0x00510340 (size: 123) ---


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



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  

  if (param_2 == param_1) {

    return 0;

  }

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

    iVar1 = FUN_00521f10(param_3);

    if (iVar1 != 0) {

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

        iVar2 = FUN_005df0f5(0x24);

        if (iVar2 == 0) {

          uVar3 = 0;

        }

        else {

          uVar3 = FUN_0051bd30();

        }

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

      }

      FUN_0051bda0(param_2,iVar1 + 0x10,*(undefined4 *)(iVar1 + 0xc),param_3);

      return 1;

    }

  }

  return 0;

}





// --- FUN_005103c0 at 0x005103C0 (size: 108) ---


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



{

  int iVar1;

  undefined4 uVar2;

  

  if (param_2 == param_1) {

    return 0;

  }

  if ((param_3 != 0xffffffff) && (*(uint *)(*(int *)(param_1 + 0x10) + 0x58) <= param_3)) {

    return 0;

  }

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

    iVar1 = FUN_005df0f5(0x24);

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051bd30();

    }

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

  }

  FUN_0051bda0(param_2,param_4,param_3,0);

  return 1;

}





// --- FUN_00510430 at 0x00510430 (size: 52) ---


void __thiscall FUN_00510430(int param_1,float param_2)



{

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

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

  }

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

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

    FUN_00518e70();

    return;

  }

  return;

}





// --- FUN_00510470 at 0x00510470 (size: 15) ---


void __fastcall FUN_00510470(int param_1)



{

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

    FUN_00518e30();

    return;

  }

  return;

}





// --- FUN_00510480 at 0x00510480 (size: 113) ---


undefined4 __thiscall FUN_00510480(int param_1,float param_2)



{

  undefined4 uVar1;

  

  uVar1 = 0;

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

    uVar1 = FUN_00519fb0(param_2);

  }

  if (*(float *)(param_1 + 0xb4) != DAT_007c7820) {

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

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

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

    }

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

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

      FUN_00518e70(param_2);

    }

  }

  return uVar1;

}





// --- FUN_00510500 at 0x00510500 (size: 113) ---


undefined4 __thiscall FUN_00510500(int param_1,float param_2)



{

  undefined4 uVar1;

  

  uVar1 = 0;

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

    uVar1 = FUN_00519d40(param_2);

  }

  if (*(float *)(param_1 + 0xb4) != DAT_007c7820) {

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

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

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

    }

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

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

      FUN_00518e70(param_2);

    }

  }

  return uVar1;

}





// --- FUN_00510580 at 0x00510580 (size: 158) ---


undefined4 __thiscall FUN_00510580(int param_1,float param_2)



{

  float fVar1;

  undefined4 uVar2;

  

  uVar2 = 0;

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

    uVar2 = FUN_00519870(*(int *)((int)param_2 + 0x10));

  }

  *(undefined4 *)(param_1 + 0xb4) = *(undefined4 *)((int)param_2 + 0xb8);

  fVar1 = *(float *)((int)param_2 + 0xb8);

  *(float *)(param_1 + 0xb8) = fVar1;

  if (*(float *)(param_1 + 0xb4) != DAT_007c7820) {

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

    if (param_2 < fVar1) {

      param_2 = fVar1;

    }

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

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

      FUN_00518e70(param_2);

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

      return uVar2;

    }

  }

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

  return uVar2;

}





// --- FUN_00510620 at 0x00510620 (size: 193) ---


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



void __thiscall

FUN_00510620(int param_1,float param_2,float param_3,undefined4 param_4,undefined4 param_5)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_5,param_4)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(1,DAT_008eee70,DAT_008eee74,param_4,param_5,param_2,param_3,0);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

  else {

    param_2 = param_3;

    if (param_3 < *(float *)(param_1 + 0xb8)) {

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

    }

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

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

      FUN_00518e70(param_2);

      return;

    }

  }

  return;

}





// --- FUN_005106f0 at 0x005106F0 (size: 15) ---


void __fastcall FUN_005106f0(int param_1)



{

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

    FUN_005197e0();

    return;

  }

  return;

}





// --- FUN_00510700 at 0x00510700 (size: 15) ---


void __fastcall FUN_00510700(int param_1)



{

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

    FUN_00519830();

    return;

  }

  return;

}





// --- FUN_00510710 at 0x00510710 (size: 95) ---


undefined4 __thiscall FUN_00510710(int param_1,int param_2)



{

  undefined4 uVar1;

  

  uVar1 = DAT_008379a8;

  if (param_2 == 0) {

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

    return 1;

  }

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

    return 0;

  }

  if (-1 < (char)*(uint *)(param_1 + 0xac)) {

    *(undefined4 *)(param_1 + 0xdc) = DAT_008379ac;

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

  }

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

  return 1;

}





// --- FUN_00510770 at 0x00510770 (size: 76) ---


undefined4 __thiscall FUN_00510770(int param_1,int param_2)



{

  if (param_2 == 0) {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xffffffdf;

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

      FUN_00518e30(0);

    }

  }

  else {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x20;

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

      FUN_00518e30(1);

      return 1;

    }

  }

  return 1;

}





// --- FUN_005107c0 at 0x005107C0 (size: 68) ---


void __thiscall FUN_005107c0(int param_1,int param_2)



{

  if (param_2 == 0) {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffff7ff;

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

      FUN_00519ce0();

    }

  }

  else {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x800;

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

      FUN_00519730();

      return;

    }

  }

  return;

}





// --- FUN_00510810 at 0x00510810 (size: 88) ---


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



undefined4 __thiscall FUN_00510810(int param_1,float param_2)



{

  if (param_2 < (float)_DAT_00795610) {

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

    return 1;

  }

  if (_DAT_007958cc < param_2) {

    *(undefined4 *)(param_1 + 0xb0) = 0x3dcccccd;

    return 1;

  }

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

  return 1;

}





// --- FUN_00510870 at 0x00510870 (size: 15) ---


void __fastcall FUN_00510870(int param_1)



{

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

    FUN_00518860(1);

  }

  return;

}





// --- FUN_00510880 at 0x00510880 (size: 18) ---


void __fastcall FUN_00510880(int param_1)



{

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

    FUN_00524ed0();

    return;

  }

  return;

}





// --- FUN_005108b0 at 0x005108B0 (size: 18) ---


undefined4 __fastcall FUN_005108b0(int param_1)



{

  undefined4 uVar1;

  

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

    return 0;

  }

  uVar1 = FUN_00524e00();

  return uVar1;

}





// --- FUN_005108d0 at 0x005108D0 (size: 18) ---


undefined4 __fastcall FUN_005108d0(int param_1)



{

  undefined4 uVar1;

  

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

    return 0;

  }

  uVar1 = FUN_00524e30();

  return uVar1;

}





// --- FUN_005108f0 at 0x005108F0 (size: 13) ---


void __fastcall FUN_005108f0(int param_1)



{

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

    FUN_005188a0();

    return;

  }

  return;

}





// --- FUN_00510900 at 0x00510900 (size: 13) ---


void __fastcall FUN_00510900(int param_1)



{

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

    FUN_00518880();

    return;

  }

  return;

}





// --- FUN_00510910 at 0x00510910 (size: 27) ---


undefined4 __thiscall FUN_00510910(int param_1,undefined4 param_2)



{

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

    FUN_00519a20(param_2);

    return 1;

  }

  return 0;

}





// --- FUN_00510930 at 0x00510930 (size: 50) ---


undefined2 __thiscall FUN_00510930(int param_1,float param_2)



{

  int iVar1;

  

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

    return 1;

  }

  if (((*(float *)(param_1 + 0x24) <= param_2) && (*(int **)(param_1 + 0x90) != (int *)0x0)) &&

     (iVar1 = (**(code **)(**(int **)(param_1 + 0x90) + 0x68))(), iVar1 != 0)) {

    return 1;

  }

  return 0;

}





// --- FUN_00510970 at 0x00510970 (size: 95) ---


undefined4 __fastcall FUN_00510970(int *param_1)



{

  int iVar1;

  uint uVar2;

  

  iVar1 = param_1[2];

  if (iVar1 == param_1[1]) {

    return 0;

  }

  if (iVar1 == 0) {

    iVar1 = 0;

  }

  else {

    iVar1 = thunk_FUN_005df0f5(iVar1 << 2);

    uVar2 = 0;

    if (iVar1 == 0) {

      return 0;

    }

    if (param_1[2] != 0) {

      do {

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

        uVar2 = uVar2 + 1;

      } while (uVar2 < (uint)param_1[2]);

    }

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  param_1[1] = param_1[2];

  return 1;

}





// --- FUN_005109f0 at 0x005109F0 (size: 89) ---


void __thiscall FUN_005109f0(int param_1,undefined4 *param_2)



{

  int iVar1;

  

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

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

  *(undefined4 *)(param_1 + 0x2b0) = param_2[1];

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

  iVar1 = FUN_004524a0();

  if (iVar1 != 0) {

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

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

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

  }

  return;

}





// --- FUN_00510a50 at 0x00510A50 (size: 86) ---


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



{

  undefined4 uVar1;

  uint uVar2;

  

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

  if (param_3 == 0) {

    uVar2 = *(uint *)(param_1 + 0xa8) | 1;

  }

  else {

    uVar2 = *(uint *)(param_1 + 0xa8) & 0xfffffffe;

  }

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

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

  uVar1 = DAT_008379a8;

  *(undefined4 *)(param_1 + 0xdc) = DAT_008379ac;

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

  return;

}





// --- FUN_00510ab0 at 0x00510AB0 (size: 51) ---


undefined4 __fastcall FUN_00510ab0(int param_1)



{

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

    FUN_00519f00(0x65);

  }

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  return 1;

}





// --- FUN_00510af0 at 0x00510AF0 (size: 168) ---


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



{

  undefined4 uVar1;

  undefined4 local_64;

  undefined4 local_60;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

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

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

    return 7;

  }

  local_64 = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_4 = param_3;

  local_64 = 1;

  local_60 = param_2;

  uVar1 = FUN_00524cd0(&local_64);

  return uVar1;

}





// --- FUN_00510ba0 at 0x00510BA0 (size: 168) ---


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



{

  undefined4 uVar1;

  undefined4 local_64;

  undefined4 local_60;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

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

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

    return 7;

  }

  local_64 = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_4 = param_3;

  local_64 = 3;

  local_60 = param_2;

  uVar1 = FUN_00524cd0(&local_64);

  return uVar1;

}





// --- FUN_00510c50 at 0x00510C50 (size: 106) ---


void __fastcall FUN_00510c50(int param_1)



{

  undefined4 local_64 [4];

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  

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

    local_64[0] = 0;

    local_54 = &PTR_LAB_00797910;

    local_50 = 0;

    local_4c = 0x3f800000;

    local_48 = 0;

    local_44 = 0;

    local_40 = 0;

    local_18 = 0;

    local_14 = 0;

    local_10 = 0;

    FUN_00535b30();

    local_64[0] = 5;

    FUN_00524cd0(local_64);

  }

  return;

}





// --- FUN_00510cc0 at 0x00510CC0 (size: 18) ---


void __fastcall FUN_00510cc0(int param_1)



{

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

    FUN_00524db0(0x36);

  }

  return;

}





// --- FUN_00510ce0 at 0x00510CE0 (size: 84) ---


void __fastcall FUN_00510ce0(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00555ef0(param_1);

    *(undefined4 *)(param_1 + 200) = uVar1;

  }

  uVar1 = DAT_008379ac;

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

    if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

    }

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

  }

  return;

}





// --- FUN_00510d40 at 0x00510D40 (size: 108) ---


void __thiscall FUN_00510d40(int param_1,int param_2)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    if (param_2 != 0) {

      FUN_00524dc0();

    }

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  return;

}





// --- FUN_00510db0 at 0x00510DB0 (size: 259) ---


void __thiscall

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

            ,undefined4 param_6)



{

  undefined4 uVar1;

  undefined4 local_64 [2];

  undefined4 local_5c;

  undefined4 local_58;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    FUN_00524dc0();

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  local_64[0] = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_58 = param_3;

  local_c = param_4;

  local_5c = param_2;

  local_4 = param_6;

  local_64[0] = 6;

  local_8 = param_5;

  FUN_00524cd0(local_64);

  return;

}





// --- FUN_00510ec0 at 0x00510EC0 (size: 243) ---


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



{

  undefined4 uVar1;

  undefined4 local_64 [2];

  undefined4 local_5c;

  undefined4 local_58;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    FUN_00524dc0();

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  local_64[0] = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_5c = param_2;

  local_58 = param_3;

  local_64[0] = 8;

  local_4 = param_4;

  FUN_00524cd0(local_64);

  return;

}





// --- FUN_00510fc0 at 0x00510FC0 (size: 33) ---


void FUN_00510fc0(undefined4 param_1,undefined4 param_2)



{

  FUN_00510ce0();

  FUN_00555e10(param_1,param_2);

  return;

}





// --- FUN_00510ff0 at 0x00510FF0 (size: 27) ---


void __fastcall FUN_00510ff0(int param_1)



{

  FUN_00510ce0();

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

    FUN_00555ea0();

    return;

  }

  return;

}





// --- FUN_00511010 at 0x00511010 (size: 134) ---


void __thiscall FUN_00511010(int param_1,int param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  undefined4 local_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

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

    (**(code **)(**(int **)(param_1 + 300) + 0x60))();

  }

  uVar2 = 0;

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

    do {

      puVar1 = (undefined4 *)(*(int *)(param_2 + 0x14) + uVar2 * 8);

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

        FUN_0051c430();

        uStack_8 = *puVar1;

        uStack_4 = puVar1[1];

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

        (**(code **)(**(int **)(param_1 + 300) + 0x54))(&local_c);

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < *(uint *)(param_2 + 0x10));

  }

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

    FUN_0051af20(param_2);

  }

  return;

}





// --- FUN_005110a0 at 0x005110A0 (size: 81) ---


void __thiscall FUN_005110a0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

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

    FUN_0051a530(param_2);

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  return;

}





// --- FUN_00511100 at 0x00511100 (size: 201) ---


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



{

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  param_1[4] = param_2[4];

  param_1[5] = param_2[5];

  param_1[6] = &PTR_LAB_00797910;

  param_1[7] = param_2[7];

  FUN_00425f10(param_2 + 8);

  param_1[0x18] = &PTR_LAB_00797910;

  param_1[0x19] = param_2[0x19];

  FUN_00425f10(param_2 + 0x1a);

  param_1[0x2a] = param_2[0x2a];

  param_1[0x2b] = param_2[0x2b];

  param_1[0x2c] = param_2[0x2c];

  param_1[0x2d] = param_2[0x2d];

  param_1[0x2e] = param_2[0x2e];

  param_1[0x2f] = param_2[0x2f];

  param_1[0x30] = param_2[0x30];

  param_1[0x32] = param_2[0x32];

  param_1[0x33] = param_2[0x33];

  return param_1;

}





// --- FUN_005111d0 at 0x005111D0 (size: 579) ---


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



void __thiscall FUN_005111d0(int param_1,float param_2,int param_3)



{

  float *pfVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float local_28;

  float local_18;

  float local_14;

  float local_10;

  undefined1 local_c [8];

  float local_4;

  

  pfVar1 = (float *)(param_1 + 0xe0);

  local_28 = *(float *)(param_1 + 0xe8) * *(float *)(param_1 + 0xe8) +

             *(float *)(param_1 + 0xe4) * *(float *)(param_1 + 0xe4) + *pfVar1 * *pfVar1;

  if (local_28 <= DAT_00796344) {

    if ((*(int *)(param_1 + 0xc4) == 0) && ((*(uint *)(param_1 + 0xac) & 2) != 0)) {

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

    }

  }

  else {

    fVar2 = _DAT_007c78a4 * _DAT_007c78a4;

    if (fVar2 < local_28) {

      FUN_00452440(local_c);

      *pfVar1 = _DAT_007c78a4 * *pfVar1;

      *(float *)(param_1 + 0xe4) = _DAT_007c78a4 * *(float *)(param_1 + 0xe4);

      *(float *)(param_1 + 0xe8) = _DAT_007c78a4 * *(float *)(param_1 + 0xe8);

      local_28 = fVar2;

    }

    FUN_0050f940(param_2,local_28);

    if (local_28 - _DAT_007c78a0 * _DAT_007c78a0 < _DAT_007c78bc) {

      *pfVar1 = 0.0;

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

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

    }

    fVar4 = *(float *)(param_1 + 0xf0) * _DAT_007938b8;

    fVar5 = *(float *)(param_1 + 0xf4) * _DAT_007938b8;

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

    fVar3 = *(float *)(param_1 + 0xe8);

    *(float *)(param_3 + 0x34) =

         param_2 * *pfVar1 + *(float *)(param_1 + 0xec) * _DAT_007938b8 * param_2 * param_2 +

         *(float *)(param_3 + 0x34);

    *(float *)(param_3 + 0x38) =

         param_2 * fVar2 + fVar4 * param_2 * param_2 + *(float *)(param_3 + 0x38);

    *(float *)(param_3 + 0x3c) =

         param_2 * fVar3 + fVar5 * param_2 * param_2 + *(float *)(param_3 + 0x3c);

  }

  *pfVar1 = param_2 * *(float *)(param_1 + 0xec) + *pfVar1;

  *(float *)(param_1 + 0xe4) = param_2 * *(float *)(param_1 + 0xf0) + *(float *)(param_1 + 0xe4);

  *(float *)(param_1 + 0xe8) = param_2 * *(float *)(param_1 + 0xf4) + *(float *)(param_1 + 0xe8);

  local_18 = param_2 * *(float *)(param_1 + 0xf8);

  local_14 = param_2 * *(float *)(param_1 + 0xfc);

  local_10 = param_2 * *(float *)(param_1 + 0x100);

  local_4 = local_10;

  FUN_005364e0(&local_18);

  return;

}





// --- FUN_00511420 at 0x00511420 (size: 232) ---


void __fastcall FUN_00511420(int param_1)



{

  undefined4 uVar1;

  

  uVar1 = DAT_0082223c;

  if ((((*(uint *)(param_1 + 0xac) & 1) != 0) && ((*(uint *)(param_1 + 0xac) & 2) != 0)) &&

     ((*(uint *)(param_1 + 0xa8) & 0x800000) == 0)) {

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

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

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

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

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

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

    return;

  }

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

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

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

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

    return;

  }

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

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

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

  return;

}





// --- FUN_00511510 at 0x00511510 (size: 72) ---


undefined4 __fastcall FUN_00511510(int param_1)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  

  uVar2 = 0;

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

    iVar3 = 0;

    do {

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

        iVar1 = FUN_0052c3c0(param_1);

        if (iVar1 != 0) {

          return 1;

        }

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x18;

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

  }

  return 0;

}





// --- FUN_00511560 at 0x00511560 (size: 147) ---


undefined4 __thiscall FUN_00511560(int param_1,undefined4 param_2)



{

  int iVar1;

  

  if (DAT_00844d64 != 0) {

    iVar1 = FUN_00508890(param_2);

    if (iVar1 != 0) {

      if ((*(uint *)(iVar1 + 0xa8) & 0x200000) == 0) {

        if (((*(byte *)(param_1 + 0xa8) & 8) != 0) && (*(int **)(param_1 + 300) != (int *)0x0)) {

          (**(code **)(**(int **)(param_1 + 300) + 0x58))(param_2);

        }

        if (((*(byte *)(iVar1 + 0xa8) & 8) != 0) && (*(int **)(iVar1 + 300) != (int *)0x0)) {

          (**(code **)(**(int **)(iVar1 + 300) + 0x58))(*(undefined4 *)(param_1 + 8));

        }

      }

      return 1;

    }

  }

  if (((*(byte *)(param_1 + 0xa8) & 8) != 0) && (*(int **)(param_1 + 300) != (int *)0x0)) {

    (**(code **)(**(int **)(param_1 + 300) + 0x58))(param_2);

  }

  return 0;

}





// --- FUN_00511600 at 0x00511600 (size: 276) ---


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



void __fastcall FUN_00511600(int param_1)



{

  float fVar1;

  float local_1c;

  float local_18;

  float local_14;

  float local_10;

  float local_c;

  float local_8;

  float local_4;

  

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

    local_1c = DAT_00867414;

  }

  else {

    local_1c = DAT_0086c208;

  }

  FUN_0050aa30(&local_18,param_1 + 0x48);

  fVar1 = SQRT(local_10 * local_10 + local_18 * local_18 + local_14 * local_14);

  *(float *)(param_1 + 0x24) = fVar1;

  if (local_1c <= local_18 * local_18 + local_14 * local_14) {

    if (fVar1 <= _DAT_007c78bc) {

      local_c = 0.0;

      local_8 = 0.0;

      local_4 = 1.0;

    }

    else {

      local_4 = _DAT_007938b0 / fVar1;

      local_c = local_18 * local_4;

      local_8 = local_4 * local_14;

      local_4 = local_4 * local_10;

    }

    local_14 = local_8;

    local_18 = local_c;

    local_10 = local_4;

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

      FUN_00518dc0(fVar1,&local_18);

    }

  }

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

    FUN_00518d90();

    return;

  }

  return;

}





// --- FUN_00511720 at 0x00511720 (size: 53) ---


void __fastcall FUN_00511720(int param_1)



{

  ushort *puVar1;

  ushort uVar2;

  

  FUN_00511600();

  puVar1 = *(ushort **)(param_1 + 0x44);

  if ((puVar1 != (ushort *)0x0) && (uVar2 = 0, *puVar1 != 0)) {

    do {

      if (*(int *)(*(int *)(puVar1 + 2) + (uint)uVar2 * 4) != 0) {

        FUN_00511720();

      }

      puVar1 = *(ushort **)(param_1 + 0x44);

      uVar2 = uVar2 + 1;

    } while (uVar2 < *puVar1);

  }

  return;

}





// --- FUN_00511760 at 0x00511760 (size: 64) ---


void __fastcall FUN_00511760(int param_1)



{

  ushort *puVar1;

  ushort uVar2;

  

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

    FUN_00518e00(param_1 + 0x48);

  }

  puVar1 = *(ushort **)(param_1 + 0x44);

  if ((puVar1 != (ushort *)0x0) && (uVar2 = 0, *puVar1 != 0)) {

    do {

      if (*(int *)(*(int *)(puVar1 + 2) + (uint)uVar2 * 4) != 0) {

        FUN_00511760();

      }

      puVar1 = *(ushort **)(param_1 + 0x44);

      uVar2 = uVar2 + 1;

    } while (uVar2 < *puVar1);

  }

  return;

}





// --- FUN_005117a0 at 0x005117A0 (size: 81) ---


undefined4 __thiscall FUN_005117a0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

  if (param_2 == 0) {

    return 0;

  }

  uVar3 = 0;

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

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051be20(param_1);

    }

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

  }

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

    uVar3 = FUN_0051bed0(param_2);

  }

  return uVar3;

}





// --- FUN_00511800 at 0x00511800 (size: 23) ---


undefined4 __fastcall FUN_00511800(int param_1)



{

  undefined4 uVar1;

  

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

    return 1;

  }

  uVar1 = FUN_005117a0();

  return uVar1;

}





// --- FUN_00511820 at 0x00511820 (size: 43) ---


void __fastcall FUN_00511820(int param_1)



{

  void *pvVar1;

  

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

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

    FUN_0051c150();

    operator_delete(pvVar1);

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

  }

  return;

}





// --- FUN_00511850 at 0x00511850 (size: 25) ---


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



{

  FUN_00497d70(*(undefined4 *)(param_1 + 0x4c),param_2,param_3);

  return;

}





// --- FUN_00511870 at 0x00511870 (size: 87) ---


void __thiscall FUN_00511870(int param_1,undefined4 param_2)



{

  ushort uVar1;

  

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

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(param_2);

  }

  if ((*(short **)(param_1 + 0x44) != (short *)0x0) &&

     (uVar1 = 0, **(short **)(param_1 + 0x44) != 0)) {

    do {

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

        FUN_00511870(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < **(ushort **)(param_1 + 0x44));

  }

  return;

}





// --- FUN_005118d0 at 0x005118D0 (size: 98) ---


void __thiscall FUN_005118d0(int param_1,int param_2)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

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

    *(undefined4 *)(param_2 + 0x34) = *(undefined4 *)(*(int *)(param_1 + 0x90) + 0x28);

  }

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

  uVar3 = 0;

  if (uVar2 != 0) {

    iVar4 = 0;

    do {

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

      if (iVar1 != 0) {

        (*(code *)**(undefined4 **)(iVar1 + 0x38))(param_2,0,iVar1 + 0x5c,uVar2);

      }

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

      uVar3 = uVar3 + 1;

      iVar4 = iVar4 + 0x18;

    } while (uVar3 < uVar2);

  }

  return;

}





// --- FUN_00511940 at 0x00511940 (size: 87) ---


void __thiscall FUN_00511940(int param_1,int param_2)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  

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

    *(undefined4 *)(param_2 + 0x34) = *(undefined4 *)(*(int *)(param_1 + 0x90) + 0x28);

  }

  uVar2 = 0;

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

    iVar3 = 0;

    do {

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

      if (iVar1 != 0) {

        (**(code **)(*(int *)(iVar1 + 0x38) + 4))(param_2);

      }

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x18;

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

  }

  return;

}





// --- FUN_005119a0 at 0x005119A0 (size: 120) ---


void __thiscall FUN_005119a0(int param_1,int param_2)



{

  undefined4 uVar1;

  ushort uVar2;

  

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

    FUN_0052cb70(param_1);

    if ((*(short **)(param_1 + 0x44) != (short *)0x0) &&

       (uVar2 = 0, **(short **)(param_1 + 0x44) != 0)) {

      do {

        FUN_005119a0(param_2);

        uVar2 = uVar2 + 1;

      } while (uVar2 < **(ushort **)(param_1 + 0x44));

    }

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

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

    if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

      FUN_00518900(uVar1);

    }

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

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

      FUN_005189d0(param_2);

    }

  }

  return;

}





// --- FUN_00511a20 at 0x00511A20 (size: 101) ---


void __thiscall FUN_00511a20(int param_1,undefined4 param_2)



{

  ushort uVar1;

  

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

    FUN_0052cc50(param_1);

    if ((*(short **)(param_1 + 0x44) != (short *)0x0) &&

       (uVar1 = 0, **(short **)(param_1 + 0x44) != 0)) {

      do {

        FUN_00511a20(param_2);

        uVar1 = uVar1 + 1;

      } while (uVar1 < **(ushort **)(param_1 + 0x44));

    }

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

      FUN_00518a20(*(undefined4 *)(param_1 + 0x90));

    }

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

  }

  return;

}





// --- FUN_00511a90 at 0x00511A90 (size: 101) ---


void __thiscall FUN_00511a90(int param_1,undefined4 *param_2)



{

  int iVar1;

  uint uVar2;

  

  param_2[2] = 0;

  *param_2 = 0;

  FUN_006b5f30(*(undefined4 *)(*(int *)(param_1 + 0x90) + 0x28),*(int *)(param_1 + 0x90));

  if (((*(int *)(param_1 + 0x90) != 0) && (*(int *)(param_1 + 0x10) != 0)) &&

     (uVar2 = 0, param_2[2] != 0)) {

    do {

      iVar1 = *(int *)(param_2[3] + 4 + uVar2 * 8);

      if (iVar1 != 0) {

        FUN_00518c90(iVar1,param_2);

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < (uint)param_2[2]);

  }

  return;

}





// --- FUN_00511b00 at 0x00511B00 (size: 509) ---


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



undefined4 __fastcall FUN_00511b00(int param_1)



{

  float fVar1;

  float fVar2;

  undefined *puVar3;

  int iVar4;

  int iVar5;

  float *pfVar6;

  uint uVar7;

  int iVar8;

  undefined4 uVar9;

  uint local_14;

  float local_c;

  float local_8;

  

  if ((*(uint *)(param_1 + 0xa8) & 0x10000) == 0) {

    iVar8 = 0;

    if ((*(int *)(param_1 + 0x10) == 0) || (iVar4 = FUN_00518bb0(), iVar4 == 0)) {

      if ((*(int *)(param_1 + 0x10) == 0) || (iVar8 = FUN_00518b90(), iVar8 == 0)) {

        uVar9 = 0;

        pfVar6 = (float *)(param_1 + 0x84);

      }

      else {

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

          puVar3 = &DAT_00844eec;

        }

        else {

          puVar3 = (undefined *)FUN_00519630();

        }

        FUN_00452660(&local_c,puVar3);

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

        pfVar6 = &local_c;

      }

      iVar8 = FUN_0050f2d0(pfVar6,uVar9);

      if (iVar8 != 0) {

        return 1;

      }

    }

    else {

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

        local_14 = 0;

      }

      else {

        local_14 = FUN_00518bb0();

      }

      uVar7 = 0;

      if (local_14 == 0) {

        return 1;

      }

      iVar4 = FUN_00452950();

      while( true ) {

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

          iVar5 = 0;

        }

        else {

          iVar5 = FUN_00518bc0();

        }

        fVar2 = *(float *)(iVar4 + 0x10) * *(float *)(iVar8 + iVar5) +

                *(float *)(iVar8 + 8 + iVar5) * *(float *)(iVar4 + 0x28) +

                *(float *)(iVar4 + 0x1c) * *(float *)(iVar8 + 4 + iVar5) + *(float *)(iVar4 + 0x34);

        local_8 = *(float *)(iVar4 + 0x2c) * *(float *)(iVar8 + 8 + iVar5) +

                  *(float *)(iVar4 + 0x14) * *(float *)(iVar8 + iVar5) +

                  *(float *)(iVar4 + 0x20) * *(float *)(iVar8 + 4 + iVar5) +

                  *(float *)(iVar4 + 0x38);

        fVar1 = *(float *)(iVar8 + 0x10 + iVar5);

        if (((fVar2 < fVar1) || (local_8 < fVar1)) ||

           ((_DAT_00844d8c - fVar1 <= fVar2 || (_DAT_00844d8c - fVar1 <= local_8)))) break;

        uVar7 = uVar7 + 1;

        iVar8 = iVar8 + 0x14;

        if (local_14 <= uVar7) {

          return 1;

        }

      }

    }

  }

  else {

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

      puVar3 = &DAT_00844eec;

    }

    else {

      puVar3 = (undefined *)FUN_00519630();

    }

    FUN_00452660(&local_c,puVar3);

    fVar1 = *(float *)(puVar3 + 0xc);

    if (((fVar1 <= local_c) && (fVar1 <= local_8)) && (local_c < _DAT_00844d8c - fVar1)) {

      if (local_8 < _DAT_00844d8c - fVar1) {

        return 1;

      }

      return 0;

    }

  }

  return 0;

}





// --- FUN_00511d00 at 0x00511D00 (size: 136) ---


void __fastcall FUN_00511d00(int param_1)



{

  int iVar1;

  ushort *puVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  

  uVar5 = 0;

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

    iVar4 = 0;

    do {

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

      if ((iVar1 != 0) &&

         (FUN_0052bee0(*(int *)(param_1 + 0x98) + iVar4), *(int *)(param_1 + 0x10) != 0)) {

        FUN_00518930(iVar1);

      }

      uVar5 = uVar5 + 1;

      iVar4 = iVar4 + 0x18;

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

  }

  uVar5 = 0;

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

  while( true ) {

    puVar2 = *(ushort **)(param_1 + 0x44);

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

      uVar3 = 0;

    }

    else {

      uVar3 = (uint)*puVar2;

    }

    if (uVar3 <= uVar5) break;

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

      FUN_00511d00();

      uVar5 = uVar5 + 1;

    }

    else {

      FUN_00511d00();

      uVar5 = uVar5 + 1;

    }

  }

  return;

}





// --- FUN_00511d90 at 0x00511D90 (size: 65) ---


undefined4 __fastcall FUN_00511d90(int param_1)



{

  uint uVar1;

  int *piVar2;

  uint uVar3;

  

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

    return 0;

  }

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

  if (uVar1 != 0) {

    uVar3 = 0;

    if (uVar1 != 0) {

      piVar2 = (int *)(*(int *)(param_1 + 0x98) + 0x14);

      do {

        if (*piVar2 == 0) {

          return 0;

        }

        uVar3 = uVar3 + 1;

        piVar2 = piVar2 + 6;

      } while (uVar3 < uVar1);

    }

    return 1;

  }

  return 0;

}





// --- FUN_00511de0 at 0x00511DE0 (size: 100) ---


void __thiscall FUN_00511de0(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  

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

  if (param_2 == 0) {

    uVar2 = uVar1 & 0xfffffffd;

  }

  else {

    uVar2 = uVar1 | 2;

  }

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

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

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

      FUN_00524f00();

    }

  }

  else if ((param_2 == 0) && (*(int *)(param_1 + 0xc4) != 0)) {

    FUN_00524f20();

    FUN_00511420();

    return;

  }

  FUN_00511420();

  return;

}





// --- FUN_00511e50 at 0x00511E50 (size: 59) ---


undefined4 __thiscall FUN_00511e50(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  uVar1 = 0;

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

    uVar1 = FUN_00519f00(param_2);

  }

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  return uVar1;

}





// --- FUN_00511e90 at 0x00511E90 (size: 33) ---


void __thiscall FUN_00511e90(int param_1,undefined4 *param_2)



{

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

  param_2[1] = *(undefined4 *)(param_1 + 0x154);

  param_2[2] = *(undefined4 *)(param_1 + 0x158);

  return;

}





// --- FUN_00511ec0 at 0x00511EC0 (size: 219) ---


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



void __thiscall FUN_00511ec0(int param_1,float *param_2)



{

  float *pfVar1;

  undefined4 uVar2;

  char cVar3;

  undefined1 local_c [12];

  

  pfVar1 = (float *)(param_1 + 0xe0);

  cVar3 = FUN_0045fad0(pfVar1);

  if (cVar3 != '\0') {

    *pfVar1 = *param_2;

    *(float *)(param_1 + 0xe4) = param_2[1];

    *(float *)(param_1 + 0xe8) = param_2[2];

    if (_DAT_007c78a4 * _DAT_007c78a4 <

        *(float *)(param_1 + 0xe8) * *(float *)(param_1 + 0xe8) +

        *(float *)(param_1 + 0xe4) * *(float *)(param_1 + 0xe4) + *pfVar1 * *pfVar1) {

      FUN_00452440(local_c);

      *pfVar1 = _DAT_007c78a4 * *pfVar1;

      *(float *)(param_1 + 0xe4) = _DAT_007c78a4 * *(float *)(param_1 + 0xe4);

      *(float *)(param_1 + 0xe8) = _DAT_007c78a4 * *(float *)(param_1 + 0xe8);

    }

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

  }

  uVar2 = DAT_008379ac;

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

    if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

    }

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

  }

  return;

}





// --- FUN_00511fa0 at 0x00511FA0 (size: 106) ---


void __thiscall FUN_00511fa0(int param_1,float *param_2,undefined4 param_3)



{

  float local_c;

  float local_8;

  float local_4;

  

  local_c = *(float *)(param_1 + 0x78) * param_2[2] +

            *(float *)(param_1 + 0x6c) * param_2[1] + *(float *)(param_1 + 0x60) * *param_2;

  local_8 = *(float *)(param_1 + 0x7c) * param_2[2] +

            *(float *)(param_1 + 0x70) * param_2[1] + *(float *)(param_1 + 100) * *param_2;

  local_4 = *(float *)(param_1 + 0x80) * param_2[2] +

            *(float *)(param_1 + 0x74) * param_2[1] + *(float *)(param_1 + 0x68) * *param_2;

  FUN_00511ec0(&local_c,param_3);

  return;

}





// --- FUN_00512010 at 0x00512010 (size: 8) ---


void FUN_00512010(void)



{

  FUN_005364a0();

  return;

}





// --- FUN_00512020 at 0x00512020 (size: 160) ---


void __fastcall FUN_00512020(int param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  int iVar3;

  uint uVar4;

  

  puVar1 = *(undefined4 **)(param_1 + 0x104);

  while (puVar2 = puVar1, puVar2 != (undefined4 *)0x0) {

    puVar1 = (undefined4 *)puVar2[9];

    iVar3 = (**(code **)*puVar2)(param_1);

    if (iVar3 != 0) {

      if (puVar2[9] != 0) {

        *(undefined4 *)(puVar2[9] + 0x20) = puVar2[8];

      }

      if (puVar2[8] == 0) {

        *(undefined4 *)(param_1 + 0x104) = puVar2[9];

      }

      else {

        *(undefined4 *)(puVar2[8] + 0x24) = puVar2[9];

      }

      puVar2[8] = 0;

      puVar2[9] = 0;

      *puVar2 = &PTR_LAB_007c78c0;

      operator_delete(puVar2);

    }

  }

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

    uVar4 = 0;

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

      do {

        (**(code **)(**(int **)(*(int *)(param_1 + 0x108) + uVar4 * 4) + 4))(param_1);

        uVar4 = uVar4 + 1;

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

    }

    FUN_00510970();

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

  }

  return;

}





// --- FUN_005120c0 at 0x005120C0 (size: 193) ---


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



void __thiscall FUN_005120c0(int param_1,float param_2,float param_3,undefined4 param_4)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_4,param_3)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(1,DAT_008eee70,DAT_008eee74,param_3,param_4,0,param_2,0);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

  else {

    param_3 = param_2;

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

      param_3 = *(float *)(param_1 + 0xb8);

    }

    *(float *)(param_1 + 0xb4) = param_3;

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

      FUN_00518e70(param_3);

      return;

    }

  }

  return;

}





// --- FUN_00512190 at 0x00512190 (size: 109) ---


void __thiscall FUN_00512190(int param_1,float param_2)



{

  ushort uVar1;

  undefined4 local_4;

  

  local_4 = param_2;

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

    local_4 = *(float *)(param_1 + 0xb8);

  }

  *(float *)(param_1 + 0xb4) = local_4;

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

    FUN_00518e70(local_4);

  }

  for (uVar1 = 0;

      (*(ushort **)(param_1 + 0x44) != (ushort *)0x0 && (uVar1 < **(ushort **)(param_1 + 0x44)));

      uVar1 = uVar1 + 1) {

    FUN_00512190(param_2);

  }

  return;

}





// --- FUN_00512200 at 0x00512200 (size: 161) ---


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



void __thiscall

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

            ,undefined4 param_6)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_6,param_5)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(2,DAT_008eee70,DAT_008eee74,param_5,param_6,param_3,param_4,param_2);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

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

    FUN_00518eb0(param_2,param_4);

    return;

  }

  return;

}





// --- FUN_005122b0 at 0x005122B0 (size: 161) ---


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



void __thiscall

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

            ,undefined4 param_6)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_6,param_5)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(5,DAT_008eee70,DAT_008eee74,param_5,param_6,param_3,param_4,param_2);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

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

    FUN_00518f20(param_2,param_4);

    return;

  }

  return;

}





// --- FUN_00512360 at 0x00512360 (size: 149) ---


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



void __thiscall

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

            )



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_5,param_4)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(3,DAT_008eee70,DAT_008eee74,param_4,param_5,param_2,param_3,0);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

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

    FUN_00518ee0(param_3);

    return;

  }

  return;

}





// --- FUN_00512400 at 0x00512400 (size: 161) ---


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



void __thiscall

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

            ,undefined4 param_6)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_6,param_5)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(6,DAT_008eee70,DAT_008eee74,param_5,param_6,param_3,param_4,param_2);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

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

    FUN_00518f90(param_2,param_4);

    return;

  }

  return;

}





// --- FUN_005124b0 at 0x005124B0 (size: 149) ---


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



void __thiscall

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

            )



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_5,param_4)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(4,DAT_008eee70,DAT_008eee74,param_4,param_5,param_2,param_3,0);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

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

    FUN_00518f50(param_3);

    return;

  }

  return;

}





// --- FUN_00512550 at 0x00512550 (size: 15) ---


void __fastcall FUN_00512550(int param_1)



{

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

    FUN_00518fc0();

    return;

  }

  return;

}





// --- FUN_00512560 at 0x00512560 (size: 17) ---


undefined4 __fastcall FUN_00512560(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00519000();

    return uVar1;

  }

  return 0;

}





// --- FUN_00512580 at 0x00512580 (size: 13) ---


void __fastcall FUN_00512580(int param_1)



{

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

    FUN_00519040();

    return;

  }

  return;

}





// --- FUN_00512590 at 0x00512590 (size: 40) ---


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



void __thiscall FUN_00512590(int param_1,undefined4 param_2,float param_3)



{

  if (((float)_DAT_007938c0 <= param_3) && (*(int *)(param_1 + 0x90) != 0)) {

    FUN_005117a0(param_2);

  }

  return;

}





// --- FUN_005125c0 at 0x005125C0 (size: 177) ---


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



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



{

  int iVar1;

  int iVar2;

  int iVar3;

  float10 fVar4;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_4,param_3)) {

    fVar4 = (float10)FUN_0042c860(0,(float)(double)CONCAT44(param_4,param_3));

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(7,DAT_008eee70,DAT_008eee74,(double)(float)fVar4,0,0x3f800000,param_2);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

  else if (*(int *)(param_1 + 0x90) != 0) {

    FUN_005117a0(param_2);

    return;

  }

  return;

}





// --- FUN_00512680 at 0x00512680 (size: 50) ---


void __thiscall FUN_00512680(int param_1,undefined4 param_2)



{

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

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

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

    local_8 = param_2;

    local_c = param_2;

    local_4 = param_2;

    FUN_00519530(&local_c);

  }

  return;

}





// --- FUN_005126c0 at 0x005126C0 (size: 76) ---


void __fastcall FUN_005126c0(int param_1)



{

  uint uVar1;

  

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffffe;

  FUN_00511420();

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

  *(uint *)(param_1 + 0xac) = uVar1 & 0xfffffff5;

  if (((uVar1 & 2) != 0) && (*(int *)(param_1 + 0xc4) != 0)) {

    FUN_00524f20();

  }

  FUN_00511420();

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffe0b;

  return;

}





// --- FUN_00512710 at 0x00512710 (size: 126) ---


undefined4 __thiscall FUN_00512710(int param_1,int param_2)



{

  int iVar1;

  

  if (param_2 == 0) {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffffffb;

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

      iVar1 = FUN_00511510();

      if (iVar1 != 0) {

        *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 4;

        *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x100;

        return 0;

      }

    }

  }

  else {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 4;

  }

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffeff;

  return 1;

}





// --- FUN_00512790 at 0x00512790 (size: 187) ---


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



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  uint uVar4;

  undefined8 uVar5;

  

  uVar3 = 0;

  if ((*(uint *)(param_1 + 0xa8) & 0x400000) != 0) {

    uVar3 = 0x200;

  }

  uVar4 = uVar3;

  if (param_3 == 0) {

    if ((*(uint *)(param_1 + 0xac) & 1) != 0) {

      uVar5 = FUN_00510080(1);

      uVar2 = (uint)((ulonglong)uVar5 >> 0x20) & 8;

      if ((int)uVar5 == 0) {

        FUN_0050f3b0(*(undefined4 *)(param_1 + 0x140),param_1 + 0x130,uVar2);

      }

      else {

        FUN_0050f320(*(undefined4 *)(param_1 + 0x140),param_1 + 0x130,uVar2);

        uVar4 = uVar3 | 1;

        if ((*(byte *)(param_1 + 0xac) & 2) != 0) {

          uVar4 = uVar3 | 3;

        }

      }

    }

    if ((*(byte *)(param_1 + 0xac) & 4) != 0) {

      FUN_005109f0(param_1 + 0x144);

    }

  }

  if ((*(int *)(param_1 + 0x10) != 0) && (iVar1 = FUN_00518bf0(), iVar1 != 0)) {

    uVar4 = uVar4 | 0x10;

  }

  if ((*(byte *)(param_1 + 0xa8) & 0x40) != 0) {

    uVar4 = uVar4 | 8;

  }

  return uVar4;

}





// --- FUN_00512850 at 0x00512850 (size: 271) ---


undefined4

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



{

  uint *puVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  undefined4 uVar5;

  undefined1 local_c [12];

  

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

  uVar2 = *(uint *)(param_1 + 4) & 0xffff;

  if ((((uVar2 == 0) || (0x40 < uVar2)) && ((uVar2 < 0x100 || (0xfffd < uVar2)))) &&

     (uVar2 != 0xffff)) {

    return 0;

  }

  uVar5 = 0;

  *param_3 = 0;

  if ((*puVar1 & 0xffff) < 0x100) {

    FUN_005aac70(puVar1,param_1 + 0x3c);

    if (*puVar1 != 0) {

      iVar3 = FUN_0052b950(*puVar1);

      *param_3 = iVar3;

      return 1;

    }

  }

  else {

    iVar3 = FUN_0052b950(*puVar1);

    if (iVar3 != 0) {

      FUN_004562a0(local_c,param_1,param_2);

      iVar4 = FUN_0052e8b0(local_c,param_5);

      if (iVar4 != 0) {

        *puVar1 = *(uint *)(iVar4 + 0x28);

        *param_3 = iVar4;

        return 1;

      }

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

        FUN_005054a0();

        if (*puVar1 != 0) {

          iVar3 = FUN_0052b950(*puVar1);

          *param_3 = iVar3;

          uVar5 = 1;

        }

      }

    }

  }

  return uVar5;

}





// --- FUN_00512960 at 0x00512960 (size: 163) ---


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



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



{

  int iVar1;

  int unaff_EBP;

  

  FUN_0050a930(param_1,0,param_2);

  if ((*(byte *)(param_1 + 0x48) & 0x10) == 0) {

    *(undefined4 *)(param_3 + 0x26c) = 0;

  }

  iVar1 = FUN_0050cde0();

  if (iVar1 == 0) {

    return 0;

  }

  if ((*(byte *)(param_1 + 0x48) & 0x10) == 0) {

    if (_DAT_007c7828 <= *(float *)(param_3 + 0xfc) - *(float *)(param_2 + 0x3c)) {

      return 0;

    }

    if (_DAT_007c7828 <= *(float *)(param_3 + 0x100) - *(float *)(param_2 + 0x40)) {

      return 0;

    }

    if (*(int *)(param_3 + 0xc4) != *(int *)(unaff_EBP + 0x28)) {

      return 0;

    }

    *(undefined4 *)(param_2 + 0x3c) = *(undefined4 *)(param_3 + 0xfc);

    *(undefined4 *)(param_2 + 0x40) = *(undefined4 *)(param_3 + 0x100);

    *(undefined4 *)(param_2 + 0x44) = *(undefined4 *)(param_3 + 0x104);

  }

  return 1;

}





// --- FUN_00512a10 at 0x00512A10 (size: 95) ---


undefined4 __fastcall FUN_00512a10(int param_1)



{

  ushort *puVar1;

  ushort uVar2;

  

  FUN_00511d00();

  FUN_00508a80(param_1);

  FUN_00511a20(0);

  FUN_00509a40(*(undefined4 *)(param_1 + 8));

  for (uVar2 = 0;

      (puVar1 = *(ushort **)(param_1 + 0x44), puVar1 != (ushort *)0x0 && (uVar2 < *puVar1));

      uVar2 = uVar2 + 1) {

    FUN_00509a40(*(undefined4 *)(*(int *)(*(int *)(puVar1 + 2) + (uint)uVar2 * 4) + 8));

  }

  return 1;

}





// --- FUN_00512a70 at 0x00512A70 (size: 152) ---


void __fastcall FUN_00512a70(int param_1)



{

  ushort *puVar1;

  undefined4 uVar2;

  ushort uVar3;

  

  uVar2 = DAT_008379ac;

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

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

  FUN_00508a80(param_1);

  FUN_00508f10(*(undefined4 *)(param_1 + 8));

  for (uVar3 = 0;

      (uVar2 = DAT_008379ac, puVar1 = *(ushort **)(param_1 + 0x44), puVar1 != (ushort *)0x0 &&

      (uVar3 < *puVar1)); uVar3 = uVar3 + 1) {

    FUN_00508f10(*(undefined4 *)(*(int *)(*(int *)(puVar1 + 2) + (uint)uVar3 * 4) + 8));

  }

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

    if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

    }

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

  }

  return;

}





// --- FUN_00512b10 at 0x00512B10 (size: 115) ---


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



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  FUN_00525040(param_2,param_3);

  return;

}





// --- FUN_00512b90 at 0x00512B90 (size: 108) ---


void __fastcall FUN_00512b90(int param_1)



{

  undefined4 uVar1;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    FUN_00524dc0();

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  FUN_00524ea0();

  return;

}





// --- FUN_00512c00 at 0x00512C00 (size: 16) ---


undefined4 __fastcall FUN_00512c00(int param_1)



{

  FUN_00510ce0();

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

}





// --- FUN_00512c10 at 0x00512C10 (size: 141) ---


void __thiscall FUN_00512c10(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  float fVar11;

  float fVar12;

  

  fVar1 = *(float *)(param_1 + 0x70);

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

  fVar3 = *(float *)(param_1 + 0x6c);

  fVar4 = *(float *)(param_1 + 0xe0);

  fVar5 = *(float *)(param_1 + 0x74);

  fVar6 = *(float *)(param_1 + 0xe8);

  fVar7 = *(float *)(param_1 + 0x7c);

  fVar8 = *(float *)(param_1 + 0xe4);

  fVar9 = *(float *)(param_1 + 0x78);

  fVar10 = *(float *)(param_1 + 0xe0);

  fVar11 = *(float *)(param_1 + 0x80);

  fVar12 = *(float *)(param_1 + 0xe8);

  *param_2 = *(float *)(param_1 + 0x68) * *(float *)(param_1 + 0xe8) +

             *(float *)(param_1 + 0x60) * *(float *)(param_1 + 0xe0) +

             *(float *)(param_1 + 100) * *(float *)(param_1 + 0xe4);

  param_2[1] = fVar5 * fVar6 + fVar3 * fVar4 + fVar1 * fVar2;

  param_2[2] = fVar11 * fVar12 + fVar9 * fVar10 + fVar7 * fVar8;

  return;

}





// --- FUN_00512d10 at 0x00512D10 (size: 143) ---


int __thiscall FUN_00512d10(int param_1,int param_2)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  int iVar6;

  

  uVar2 = *(uint *)(param_2 + 8);

  iVar6 = 0;

  uVar5 = (uVar2 >> ((byte)*(undefined4 *)(param_1 + 8) & 0x1f) ^ uVar2) & *(uint *)(param_1 + 4);

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

  iVar3 = *piVar1;

  if (iVar3 == 0) {

    *piVar1 = param_2;

    return 0;

  }

  iVar4 = iVar3;

  if (*(uint *)(iVar3 + 8) != uVar2) {

    do {

      iVar6 = iVar4;

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

      if (iVar4 == 0) {

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

        *(int *)(*(int *)(param_1 + 0xc) + uVar5 * 4) = param_2;

        return 0;

      }

    } while (*(int *)(iVar4 + 8) != *(int *)(param_2 + 8));

  }

  if (iVar4 != param_2) {

    if (iVar6 == 0) {

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

      *(int *)(*(int *)(param_1 + 0xc) + uVar5 * 4) = param_2;

      return iVar4;

    }

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

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

  }

  return iVar4;

}





// --- FUN_00512de0 at 0x00512DE0 (size: 266) ---


void __thiscall FUN_00512de0(int param_1,float *param_2,float *param_3)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  float fVar11;

  float fVar12;

  float fVar13;

  float fVar14;

  

  fVar1 = param_2[0xb];

  fVar2 = param_3[0xf];

  fVar3 = param_2[5];

  fVar4 = param_3[0xd];

  fVar5 = param_2[8];

  fVar6 = param_3[0xe];

  fVar7 = param_2[0xe];

  fVar8 = param_2[0xc];

  fVar9 = param_3[0xf];

  fVar10 = param_2[6];

  fVar11 = param_3[0xd];

  fVar12 = param_2[9];

  fVar13 = param_3[0xe];

  fVar14 = param_2[0xf];

  *(float *)(param_1 + 0x34) =

       param_2[7] * param_3[0xe] + param_2[4] * param_3[0xd] + param_2[10] * param_3[0xf] +

       param_2[0xd];

  *(float *)(param_1 + 0x38) = fVar5 * fVar6 + fVar3 * fVar4 + fVar1 * fVar2 + fVar7;

  *(float *)(param_1 + 0x3c) = fVar12 * fVar13 + fVar10 * fVar11 + fVar8 * fVar9 + fVar14;

  FUN_00535dc0(((*param_2 * *param_3 - param_3[1] * param_2[1]) - param_3[2] * param_2[2]) -

               param_3[3] * param_2[3],

               (*param_3 * param_2[1] + param_3[3] * param_2[2] + *param_2 * param_3[1]) -

               param_3[2] * param_2[3],

               param_2[2] * *param_3 +

               param_2[3] * param_3[1] + (param_3[2] * *param_2 - param_3[3] * param_2[1]),

               param_2[3] * *param_3 +

               ((param_3[3] * *param_2 + param_3[2] * param_2[1]) - param_2[2] * param_3[1]));

  return;

}





// --- FUN_00512ef0 at 0x00512EF0 (size: 520) ---


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



undefined4 * __fastcall FUN_00512ef0(undefined4 *param_1)



{

  float fVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  

  param_1[1] = 0;

  param_1[2] = 0;

  *param_1 = &PTR_FUN_007c78ec;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0x3f800000;

  param_1[10] = 0;

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

  param_1[0xc] = 0;

  param_1[0xd] = 0;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[8] = 0x7f7fffff;

  param_1[9] = 0x7f7fffff;

  param_1[0x12] = &PTR_LAB_00797910;

  param_1[0x13] = 0;

  param_1[0x14] = 0x3f800000;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  FUN_00535b30();

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  puVar4 = (undefined4 *)thunk_FUN_005df0f5(100);

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

    puVar5 = (undefined4 *)0x0;

  }

  else {

    puVar5 = puVar4 + 1;

    *puVar4 = 4;

    FUN_00401000(puVar5,0x18,4,&LAB_005109d0);

  }

  fVar1 = _DAT_007938b0;

  param_1[0x26] = puVar5;

  fVar1 = fVar1 / _DAT_007c7824;

  param_1[0x28] = 0;

  param_1[0x29] = 4;

  param_1[0x27] = 4;

  uVar3 = DAT_007c7820;

  param_1[0x2c] = DAT_007c781c;

  uVar2 = DAT_007c7818;

  param_1[0x2b] = 0;

  param_1[0x2d] = uVar3;

  param_1[0x2f] = uVar2;

  param_1[0x31] = 0;

  param_1[0x32] = 0;

  param_1[0x33] = 0;

  param_1[0x34] = 0;

  param_1[0x2a] = &DAT_00400c08;

  param_1[0x2e] = uVar3;

  param_1[0x30] = fVar1;

  param_1[0x38] = 0;

  param_1[0x39] = 0;

  param_1[0x3a] = 0;

  param_1[0x3b] = 0;

  param_1[0x3c] = 0;

  param_1[0x3d] = 0;

  param_1[0x3e] = 0;

  param_1[0x3f] = 0;

  param_1[0x40] = 0;

  param_1[0x41] = 0;

  param_1[0x42] = 0;

  param_1[0x43] = 0;

  param_1[0x44] = 0;

  param_1[0x46] = 0;

  param_1[0x47] = 0;

  param_1[0x48] = 0;

  param_1[0x49] = 0;

  param_1[0x4a] = 0;

  param_1[0x4b] = 0;

  param_1[0x50] = 0;

  param_1[0x45] = 0x3f800000;

  param_1[0x51] = 0;

  param_1[0x52] = 0;

  param_1[0x53] = 0;

  param_1[0x54] = 0;

  param_1[0x55] = 0;

  param_1[0x56] = 0;

  param_1[0x57] = 0;

  param_1[0x58] = 0;

  param_1[0x59] = 0;

  param_1[0x5a] = 0;

  param_1[0x5b] = 0;

  param_1[0x5c] = 0;

  *(undefined2 *)(param_1 + 0x5d) = 0;

  return param_1;

}





// --- FUN_00513100 at 0x00513100 (size: 61) ---


undefined4 * FUN_00513100(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *extraout_ECX;

  

  iVar1 = FUN_005df0f5(0x178);

  if (iVar1 != 0) {

    iVar1 = FUN_00512ef0();

    if (iVar1 != 0) {

      iVar1 = FUN_00510a50(param_1,param_2);

      if (iVar1 != 0) {

        return extraout_ECX;

      }

      (**(code **)*extraout_ECX)(1);

    }

  }

  return (undefined4 *)0x0;

}





// --- FUN_00513140 at 0x00513140 (size: 98) ---


undefined4 * FUN_00513140(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = FUN_005df0f5(0x178);

  if (iVar1 != 0) {

    puVar2 = (undefined4 *)FUN_00512ef0();

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

      puVar2[2] = 0;

      puVar2[0x2a] = puVar2[0x2a] | 0x1001;

      iVar1 = FUN_0051a020(puVar2,param_1,param_2);

      puVar2[4] = iVar1;

      if (iVar1 != 0) {

        return puVar2;

      }

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

    }

  }

  return (undefined4 *)0x0;

}





// --- FUN_005131b0 at 0x005131B0 (size: 198) ---


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



{

  bool bVar1;

  int iVar2;

  

  if (param_2 == DAT_00844d94) {

    return 0;

  }

  bVar1 = false;

  iVar2 = FUN_0041c280(param_2);

  if (iVar2 == 6) {

    iVar2 = FUN_0051a170(param_1,param_2);

  }

  else {

    if (iVar2 != 7) {

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

        return 0;

      }

      bVar1 = true;

      iVar2 = FUN_0050f400(param_2 | 0x2000000,param_3);

      if (iVar2 == 0) {

        return 0;

      }

      goto LAB_0051322c;

    }

    iVar2 = FUN_0051a0d0(param_1,param_2,param_3);

  }

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

  if (iVar2 == 0) {

    return 0;

  }

LAB_0051322c:

  FUN_00510040();

  if (bVar1) {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 4;

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffeff;

    FUN_00510430(0x3e800000);

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x10;

  }

  return 1;

}





// --- FUN_00513280 at 0x00513280 (size: 93) ---


int __thiscall FUN_00513280(int param_1,int param_2)



{

  void *pvVar1;

  int iVar2;

  

  iVar2 = 0;

  if ((*(int *)(param_1 + 0x10) != 0) && (iVar2 = FUN_00519210(param_2), iVar2 != 0)) {

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

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

      FUN_00524ff0();

      operator_delete(pvVar1);

    }

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

    if (param_2 != DAT_00844d94) {

      FUN_00510d40(1);

    }

  }

  return iVar2;

}





// --- FUN_005132e0 at 0x005132E0 (size: 128) ---


void FUN_005132e0(float param_1)



{

  int iVar1;

  float10 fVar2;

  undefined4 local_4;

  

  FUN_00510ce0();

  if (DAT_00844d64 != 0) {

    iVar1 = FUN_00508890(param_1);

    if (iVar1 != 0) {

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

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

      }

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

        param_1 = 0.0;

      }

      else {

        fVar2 = (float10)FUN_00518be0();

        param_1 = (float)fVar2;

      }

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

        local_4 = 0.0;

      }

      else {

        fVar2 = (float10)FUN_00518bd0();

        local_4 = (float)fVar2;

      }

      FUN_00555e50(*(undefined4 *)(iVar1 + 8),local_4,param_1);

    }

  }

  return;

}





// --- FUN_00513360 at 0x00513360 (size: 222) ---


void __thiscall FUN_00513360(int param_1,float param_2,undefined4 param_3)



{

  undefined4 uVar1;

  undefined4 uVar2;

  int iVar3;

  float10 fVar4;

  float local_4;

  

  uVar1 = param_2;

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

    uVar2 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    FUN_00524dc0();

    uVar2 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  if ((DAT_00844d64 != 0) && (iVar3 = FUN_00508890(param_2), iVar3 != 0)) {

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

      param_2 = 0.0;

    }

    else {

      fVar4 = (float10)FUN_00518be0();

      param_2 = (float)fVar4;

    }

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

      local_4 = 0.0;

    }

    else {

      fVar4 = (float10)FUN_00518bd0();

      local_4 = (float)fVar4;

    }

    if (*(int *)(iVar3 + 0x40) != 0) {

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

    }

    FUN_00510db0(uVar1,*(undefined4 *)(iVar3 + 8),local_4,param_2,param_3);

  }

  return;

}





// --- FUN_00513440 at 0x00513440 (size: 61) ---


void FUN_00513440(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  if ((DAT_00844d64 != 0) && (iVar1 = FUN_00508890(param_1), iVar1 != 0)) {

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

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

    }

    FUN_00510ec0(param_1,*(undefined4 *)(iVar1 + 8),param_2);

  }

  return;

}





// --- FUN_00513480 at 0x00513480 (size: 227) ---


void __thiscall FUN_00513480(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined4 local_64 [4];

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

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

    uVar1 = FUN_00524c50(param_1,*(undefined4 *)(param_1 + 300));

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

    FUN_00524dc0();

    uVar1 = DAT_008379ac;

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

      if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

      }

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

    }

  }

  local_64[0] = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_64[0] = 9;

  local_4 = param_2;

  FUN_00524cd0(local_64);

  return;

}





// --- FUN_00513570 at 0x00513570 (size: 333) ---


void __thiscall FUN_00513570(int param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 uVar3;

  undefined4 local_2c;

  undefined4 local_28;

  float local_24;

  float local_20;

  undefined1 local_1c [4];

  undefined4 local_18;

  uint local_14;

  int local_10;

  

  puVar1 = param_2;

  if (*(int *)(*(int *)(param_1 + 0x90) + 0x28) != DAT_00844d94) {

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

      iVar2 = FUN_005df0f5(0x10);

      if (iVar2 == 0) {

        uVar3 = 0;

      }

      else {

        uVar3 = FUN_0051add0();

      }

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

    }

    local_24 = (float)param_2[6] * *(float *)(param_1 + 0x114);

    local_2c = 0;

    local_28 = 0;

    local_20 = DAT_00796344;

    if (*(float **)(param_1 + 0x120) != (float *)0x0) {

      local_20 = **(float **)(param_1 + 0x120);

    }

    local_20 = *(float *)(param_1 + 0x114) * (float)param_2[5] + local_20;

    FUN_0050b3f0();

    local_18 = 1;

    FUN_0052c5a0(param_1 + 0x48,&local_2c,local_1c,0);

    iVar2 = FUN_0051aea0(*param_2);

    param_2 = (undefined4 *)0x0;

    if (local_14 != 0) {

      do {

        if (*(int *)(local_10 + 4 + (int)param_2 * 8) != 0) {

          FUN_0052c420(*(undefined4 *)(param_1 + 8),param_1 + 0x48,*(undefined4 *)(param_1 + 0x114),

                       puVar1,iVar2);

        }

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

      } while (param_2 < local_14);

    }

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

      FUN_00511010(iVar2);

    }

    if (local_10 != 0) {

      operator_delete__((void *)(local_10 + -4));

    }

  }

  return;

}





// --- FUN_005136c0 at 0x005136C0 (size: 99) ---


void __thiscall FUN_005136c0(int param_1,int param_2)



{

  if (param_2 == 0) {

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

      FUN_00511100(&param_2);

      FUN_00525390();

    }

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

      FUN_00511100(&param_2);

      FUN_00555ff0();

    }

  }

  return;

}





// --- FUN_00513730 at 0x00513730 (size: 283) ---


void __thiscall FUN_00513730(int param_1,float param_2,undefined4 param_3)



{

  float fVar1;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  float local_c;

  float local_8;

  float local_4;

  

  local_40 = 0x3f800000;

  local_3c = 0;

  local_38 = 0;

  local_34 = 0;

  local_c = 0.0;

  local_8 = 0.0;

  local_4 = 0.0;

  FUN_00535b30();

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

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

      FUN_005188e0(param_2,&local_40);

    }

    if ((*(byte *)(param_1 + 0xac) & 2) == 0) {

      local_c = local_c * DAT_00796344;

      local_8 = local_8 * DAT_00796344;

      local_4 = local_4 * DAT_00796344;

    }

    else {

      fVar1 = *(float *)(param_1 + 0x114);

      local_c = local_c * fVar1;

      local_8 = local_8 * fVar1;

      local_4 = local_4 * fVar1;

    }

  }

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

    FUN_00555db0(&local_40,(double)param_2);

  }

  FUN_00512de0(param_1 + 0x50,&local_40);

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

    FUN_005111d0(param_2,param_3);

  }

  FUN_00512020();

  return;

}





// --- FUN_00513850 at 0x00513850 (size: 100) ---


void __thiscall FUN_00513850(int param_1,int param_2,uint param_3,undefined4 param_4)



{

  undefined1 local_40 [64];

  

  if (param_3 < *(uint *)(*(int *)(param_1 + 0x10) + 0x58)) {

    param_1 = *(int *)(*(int *)(*(int *)(param_1 + 0x10) + 0x5c) + param_3 * 4) + 0x38;

  }

  else {

    param_1 = param_1 + 0x50;

  }

  FUN_00512de0(param_1,param_4);

  FUN_00514b90(local_40);

  if (*(int *)(param_2 + 0x128) != 0) {

    FUN_0051c330();

  }

  if (*(int *)(param_2 + 0x30) != 0) {

    FUN_0051bfb0();

  }

  return;

}





// --- FUN_005138c0 at 0x005138C0 (size: 265) ---


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



{

  uint uVar1;

  int iVar2;

  undefined4 uVar3;

  int iVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 unaff_ESI;

  undefined4 unaff_EDI;

  

  iVar2 = FUN_0050bc20();

  if (iVar2 == 0) {

    return 0;

  }

  uVar3 = FUN_00512790(iVar2,param_4);

  thunk_FUN_0050da00(param_1,uVar3);

  if ((*(int *)(param_1 + 0x10) == 0) || (iVar4 = FUN_00518b90(), iVar4 == 0)) {

    FUN_0050a920(1,&DAT_00844eec,0x3f800000);

  }

  else {

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

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

      uVar5 = 0;

    }

    else {

      uVar5 = FUN_00518ba0();

    }

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

      FUN_0050a920(0,uVar5,uVar3);

    }

    else {

      uVar6 = FUN_00518b90();

      FUN_0050a920(uVar6,uVar5,uVar3);

    }

  }

  FUN_0050a930(*(undefined4 *)(param_1 + 0x90),unaff_EDI,unaff_ESI);

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

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

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

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

        *(undefined4 *)(iVar2 + 0x2f0) = 1;

      }

    }

    else {

      *(undefined4 *)(iVar2 + 0x2f0) = 2;

    }

  }

  else {

    *(undefined4 *)(iVar2 + 0x2f0) = 3;

  }

  iVar4 = FUN_0050cde0();

  FUN_0050a890(iVar2);

  if (iVar4 == 0) {

    return 0;

  }

  return iVar2;

}





// --- FUN_005139d0 at 0x005139D0 (size: 225) ---


undefined4 __fastcall FUN_005139d0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 uVar4;

  undefined *puVar5;

  

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

    return 0;

  }

  iVar1 = FUN_0050bc20();

  if (iVar1 == 0) {

    return 0;

  }

  uVar2 = FUN_00512790(iVar1,0);

  thunk_FUN_0050da00(param_1,uVar2);

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

    iVar3 = FUN_00518b90();

    if (iVar3 != 0) {

      puVar5 = *(undefined **)(param_1 + 0x114);

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

        uVar2 = 0;

      }

      else {

        uVar2 = FUN_00518ba0();

      }

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

        FUN_0050a920(0,uVar2,puVar5);

      }

      else {

        uVar4 = FUN_00518b90();

        FUN_0050a920(uVar4,uVar2,puVar5);

      }

      goto LAB_00513a77;

    }

  }

  puVar5 = &DAT_00844eec;

  FUN_0050a920(1,&DAT_00844eec,0x3f800000);

LAB_00513a77:

  FUN_0050a930(*(undefined4 *)(param_1 + 0x90),param_1 + 0x48,param_1 + 0x48);

  uVar2 = FUN_0050b4d0(puVar5);

  FUN_0050a890(iVar1);

  return uVar2;

}





// --- FUN_00513ac0 at 0x00513AC0 (size: 147) ---


undefined4 __thiscall FUN_00513ac0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  

  uVar1 = 0;

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

    if (((*(byte *)(param_1 + 0xa8) & 8) != 0) && (*(int *)(param_1 + 300) != 0)) {

      FUN_0051c550();

      local_10 = *(undefined4 *)(param_1 + 0xe0);

      local_c = *(undefined4 *)(param_1 + 0xe4);

      local_8 = *(undefined4 *)(param_1 + 0xe8);

      FUN_0051c450(param_2);

      (**(code **)(**(int **)(param_1 + 300) + 0x4c))(&local_10);

      uVar1 = 1;

    }

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

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

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffffcbf;

    }

  }

  return uVar1;

}





// --- FUN_00513b60 at 0x00513B60 (size: 504) ---


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



{

  undefined4 uVar1;

  uint uVar2;

  float10 fVar3;

  int iVar4;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  float local_28;

  float local_24;

  float local_20;

  undefined1 local_1c [28];

  

  uVar1 = 0;

  if ((*(uint *)(param_2 + 0xa8) & 0x200000) != 0) {

    uVar1 = FUN_00513ac0(param_3);

    return uVar1;

  }

  local_28 = *(float *)(param_1 + 0xe0) - *(float *)(param_2 + 0xe0);

  uVar2 = *(uint *)(param_1 + 0xa8) & 0x40;

  local_24 = *(float *)(param_1 + 0xe4) - *(float *)(param_2 + 0xe4);

  local_20 = *(float *)(param_1 + 0xe8) - *(float *)(param_2 + 0xe8);

  if ((*(uint *)(param_2 + 0xa8) & 0x10) == 0) {

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

      if (uVar2 == 0) {

        FUN_0051c560();

        FUN_005100d0(local_1c,param_2,&local_28,param_3,*(uint *)(param_2 + 0xa8) & 0x40,

                     *(uint *)(param_2 + 0xac) & 1);

        (**(code **)(**(int **)(param_1 + 300) + 0x50))(local_1c);

      }

      else {

        iVar4 = param_1 + 0x48;

        fVar3 = (float10)FUN_0050f4b0(iVar4);

        uVar1 = FUN_005aa630((float)fVar3,iVar4);

        FUN_0051c430();

        local_30 = *(undefined4 *)(param_2 + 8);

        local_34 = 0xffffffff;

        local_2c = uVar1;

        (**(code **)(**(int **)(param_1 + 300) + 0x54))(&local_34);

      }

      uVar1 = 1;

    }

    if (uVar2 != 0) {

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffffcbf;

    }

  }

  if ((((*(uint *)(param_2 + 0xa8) & 8) != 0) && ((*(byte *)(param_1 + 0xa8) & 0x10) == 0)) &&

     (*(int *)(param_2 + 300) != 0)) {

    if ((*(uint *)(param_2 + 0xa8) & 0x40) != 0) {

      iVar4 = param_2 + 0x48;

      fVar3 = (float10)FUN_0050f4b0(iVar4);

      uVar1 = FUN_005aa630((float)fVar3,iVar4);

      FUN_0051c430();

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

      local_34 = 0xffffffff;

      local_2c = uVar1;

      (**(code **)(**(int **)(param_2 + 300) + 0x54))(&local_34);

      return 1;

    }

    FUN_0051c560();

    FUN_005100d0(local_1c,param_1,&local_28,*(uint *)(param_2 + 0xac) & 1,param_3,uVar2);

    (**(code **)(**(int **)(param_2 + 300) + 0x50))(local_1c);

    uVar1 = 1;

  }

  return uVar1;

}





// --- FUN_00513d60 at 0x00513D60 (size: 67) ---


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



{

  undefined4 uVar1;

  

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

    return 1;

  }

  uVar1 = 0;

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

    FUN_00522990(&param_3,param_2,param_3);

    uVar1 = FUN_005117a0(param_3);

  }

  return uVar1;

}





// --- FUN_00513db0 at 0x00513DB0 (size: 67) ---


undefined4 __fastcall FUN_00513db0(int param_1)



{

  undefined4 uVar1;

  int local_4;

  

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

    return 1;

  }

  uVar1 = 0;

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

    local_4 = param_1;

    FUN_00522990(&local_4,*(undefined4 *)(param_1 + 0x38),*(undefined4 *)(param_1 + 0x3c));

    uVar1 = FUN_005117a0(local_4);

  }

  return uVar1;

}





// --- FUN_00513e00 at 0x00513E00 (size: 130) ---


undefined4 __thiscall FUN_00513e00(int param_1,int param_2)



{

  ushort *puVar1;

  int iVar2;

  undefined4 uVar3;

  ushort uVar4;

  

  puVar1 = *(ushort **)(param_1 + 0x44);

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

    for (uVar4 = 0; uVar4 < *puVar1; uVar4 = uVar4 + 1) {

      if ((*(int *)((uint)uVar4 * 4 + *(int *)(puVar1 + 10)) == param_2) &&

         (*(int *)((uint)uVar4 * 4 + *(int *)(puVar1 + 2)) != 0)) {

        iVar2 = *(int *)(*(int *)(puVar1 + 2) + (uint)uVar4 * 4);

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

          return 1;

        }

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

          return 0;

        }

        FUN_00522990(&param_2,*(undefined4 *)(iVar2 + 0x38),*(undefined4 *)(iVar2 + 0x3c));

        uVar3 = FUN_005117a0(param_2);

        return uVar3;

      }

    }

  }

  return 0;

}





// --- FUN_00513e90 at 0x00513E90 (size: 86) ---


void __thiscall FUN_00513e90(int param_1,int param_2)



{

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

    FUN_00511a20(1);

  }

  if (param_2 != 0) {

    FUN_005119a0(param_2);

    return;

  }

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

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(0);

  }

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

  return;

}





// --- FUN_00513ef0 at 0x00513EF0 (size: 113) ---


void __thiscall FUN_00513ef0(int param_1,int param_2)



{

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

    FUN_00511a20(1);

  }

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

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(0);

  }

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

  if (param_2 != 0) {

    FUN_0052bee0(*(undefined4 *)(param_1 + 0x98));

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

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

      FUN_00518930(param_2);

    }

  }

  return;

}





// --- FUN_00513f70 at 0x00513F70 (size: 101) ---


void __fastcall FUN_00513f70(int param_1)



{

  undefined4 uVar1;

  

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

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

      FUN_0051bac0(param_1);

    }

    if (((*(uint *)(*(int *)(param_1 + 0x40) + 0xa8) & 0x4000) != 0) &&

       (*(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xffffffdf,

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

      FUN_00518e30(0);

    }

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

    uVar1 = DAT_008379ac;

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

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

    FUN_005126c0();

    return;

  }

  return;

}





// --- FUN_00513fe0 at 0x00513FE0 (size: 212) ---


void __fastcall FUN_00513fe0(int param_1)



{

  short *psVar1;

  int iVar2;

  uint uVar3;

  undefined4 uVar4;

  

  while ((psVar1 = *(short **)(param_1 + 0x44), psVar1 != (short *)0x0 && (*psVar1 != 0))) {

    iVar2 = **(int **)(psVar1 + 2);

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

      if (*(int *)(*(int *)(iVar2 + 0x40) + 0x44) != 0) {

        FUN_0051bac0(iVar2);

      }

      if (((*(uint *)(*(int *)(iVar2 + 0x40) + 0xa8) & 0x4000) != 0) &&

         (*(uint *)(iVar2 + 0xa8) = *(uint *)(iVar2 + 0xa8) & 0xffffffdf,

         *(int *)(iVar2 + 0x10) != 0)) {

        FUN_00518e30(0);

      }

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

      uVar4 = DAT_008379a8;

      *(undefined4 *)(iVar2 + 0xdc) = DAT_008379ac;

      *(undefined4 *)(iVar2 + 0xd8) = uVar4;

      *(uint *)(iVar2 + 0xac) = *(uint *)(iVar2 + 0xac) & 0xfffffffe;

      FUN_00511420();

      uVar3 = *(uint *)(iVar2 + 0xac);

      *(uint *)(iVar2 + 0xac) = uVar3 & 0xfffffff5;

      if (((uVar3 & 2) != 0) && (*(int *)(iVar2 + 0xc4) != 0)) {

        FUN_00524f20();

      }

      FUN_00511420();

      *(uint *)(iVar2 + 0xac) = *(uint *)(iVar2 + 0xac) & 0xfffffe0b;

    }

  }

  return;

}





// --- FUN_005140c0 at 0x005140C0 (size: 179) ---


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



{

  switch(param_2) {

  case 0:

    FUN_00512680(param_3);

    return;

  case 1:

    FUN_00510430(param_3);

    return;

  case 2:

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

      FUN_00518eb0(param_4,param_3);

      return;

    }

    break;

  case 3:

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

      FUN_00518ee0(param_3);

      return;

    }

    break;

  case 4:

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

      FUN_00518f50(param_3);

      return;

    }

    break;

  case 5:

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

      FUN_00518f20(param_4,param_3);

      return;

    }

    break;

  case 6:

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

      FUN_00518f90(param_4,param_3);

      return;

    }

    break;

  case 7:

    FUN_00512590(param_4,param_3);

  }

  return;

}





// --- FUN_005141a0 at 0x005141A0 (size: 196) ---


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



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



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (_DAT_007c78bc <= (float)(double)CONCAT44(param_4,param_3)) {

    iVar3 = FUN_005df0f5(0x38);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051c580(0,DAT_008eee70,DAT_008eee74,param_3,param_4,

                           *(undefined4 *)(param_1 + 0x114),param_2,0);

    }

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

    for (iVar2 = iVar1; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x24)) {

    }

    if (iVar1 != 0) {

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

    }

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

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

  }

  else {

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

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

      local_8 = param_2;

      local_c = param_2;

      local_4 = param_2;

      FUN_00519530(&local_c);

      return;

    }

  }

  return;

}





// --- FUN_00514270 at 0x00514270 (size: 122) ---


void __thiscall FUN_00514270(int param_1,int param_2)



{

  int *piVar1;

  undefined4 *puVar2;

  int *piVar3;

  

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

    puVar2 = (undefined4 *)FUN_005df0f5(8);

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

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = 0;

    }

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

  }

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

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

  piVar3 = (int *)FUN_005df0f5(8);

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

    piVar3 = (int *)0x0;

  }

  else {

    *piVar3 = param_2;

    piVar3[1] = 0;

  }

  if (piVar1[1] == 0) {

    *piVar1 = (int)piVar3;

    piVar1[1] = (int)piVar3;

    return;

  }

  *(int **)(piVar1[1] + 4) = piVar3;

  piVar1[1] = *(int *)(piVar1[1] + 4);

  return;

}





// --- FUN_005142f0 at 0x005142F0 (size: 61) ---


undefined4 * __thiscall FUN_005142f0(undefined4 *param_1,int param_2)



{

  undefined4 uVar1;

  

  *param_1 = &PTR_FUN_007c7450;

  param_1[5] = 0;

  uVar1 = thunk_FUN_005df0f5(param_2 * 4);

  param_1[3] = uVar1;

  FUN_004f7fe0(param_2);

  *param_1 = &PTR_FUN_007c78f0;

  return param_1;

}





// --- FUN_00514330 at 0x00514330 (size: 144) ---


undefined4 FUN_00514330(undefined4 *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 *puVar5;

  

  puVar5 = (undefined4 *)FUN_005df0f5(0x20);

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

    puVar5 = (undefined4 *)0x0;

  }

  else {

    uVar1 = *param_1;

    uVar2 = param_1[1];

    uVar3 = param_1[2];

    uVar4 = param_1[3];

    puVar5[2] = param_2;

    puVar5[4] = uVar1;

    puVar5[5] = uVar2;

    puVar5[6] = uVar3;

    puVar5[7] = uVar4;

    puVar5[1] = 0;

    *puVar5 = &PTR_LAB_007c78e0;

  }

  puVar5 = (undefined4 *)FUN_00512d10(puVar5);

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

    return 0;

  }

  *param_1 = puVar5[4];

  param_1[1] = puVar5[5];

  param_1[2] = puVar5[6];

  param_1[3] = puVar5[7];

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

  return 1;

}





// --- FUN_005143c0 at 0x005143C0 (size: 65) ---


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



{

  int iVar1;

  

  *param_1 = param_2;

  param_1[3] = 0;

  param_1[1] = 0;

  if (param_2 == 0) {

    param_1[4] = 1;

    param_1[2] = 0;

  }

  else {

    param_1[4] = 0;

    iVar1 = **(int **)(param_2 + 0xc);

    param_1[2] = iVar1;

    if (iVar1 == 0) {

      FUN_004d8d00();

      return param_1;

    }

  }

  return param_1;

}





// --- FUN_00514410 at 0x00514410 (size: 94) ---


undefined4 __thiscall FUN_00514410(int param_1,undefined4 param_2)



{

  int iVar1;

  

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

    iVar1 = FUN_005131b0(param_2,1);

  }

  else {

    iVar1 = FUN_00519e60(param_2,1);

  }

  if (iVar1 == 0) {

    return 0;

  }

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

    FUN_00519f00(0x65);

  }

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  return 1;

}





// --- FUN_00514470 at 0x00514470 (size: 95) ---


undefined4 * FUN_00514470(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  undefined4 *puVar2;

  

  iVar1 = FUN_005df0f5(0x178);

  if (iVar1 != 0) {

    puVar2 = (undefined4 *)FUN_00512ef0();

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

      iVar1 = FUN_00510a50(param_2,param_3);

      if (iVar1 != 0) {

        iVar1 = FUN_005131b0(param_1,1);

        if (iVar1 != 0) {

          iVar1 = FUN_00510ab0();

          if (iVar1 != 0) {

            return puVar2;

          }

        }

      }

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

    }

  }

  return (undefined4 *)0x0;

}





// --- FUN_005144d0 at 0x005144D0 (size: 243) ---


void __thiscall FUN_005144d0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_2 + 200) != 0) {

    FUN_005117a0(*(int *)(param_2 + 200));

  }

  if (*(int *)(param_2 + 0xcc) != 0) {

    FUN_00513280(*(int *)(param_2 + 0xcc));

  }

  iVar1 = *(int *)(param_2 + 0xd0);

  if (iVar1 != 0) {

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

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

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

    }

    if (iVar1 != 0) {

      uVar2 = FUN_004220b0(iVar1,0x22);

      uVar2 = FUN_00415430(uVar2);

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

    }

  }

  iVar1 = *(int *)(param_2 + 0xd4);

  if (iVar1 != 0) {

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

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

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

    }

    if (iVar1 != 0) {

      uVar2 = FUN_004220b0(iVar1,0x2c);

      uVar2 = FUN_00415430(uVar2);

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

    }

  }

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

    if (*(int *)(param_2 + 0xc4) != 0) {

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x40000;

    }

    if (*(int *)(param_2 + 200) != 0) {

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x80000;

    }

    if ((*(uint *)(param_1 + 0xa8) & 0xc0000) != 0) {

      FUN_0050a5c0(param_1);

    }

  }

  return;

}





// --- FUN_005145d0 at 0x005145D0 (size: 600) ---


void __fastcall FUN_005145d0(int param_1)



{

  void *pvVar1;

  int iVar2;

  int *piVar3;

  undefined4 *puVar4;

  LONG LVar5;

  undefined4 *puVar6;

  

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

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

    FUN_00524ff0();

    operator_delete(pvVar1);

  }

  pvVar1 = *(void **)(param_1 + 200);

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

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

    thunk_FUN_00555f60();

    operator_delete(pvVar1);

  }

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

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

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

    FUN_0051c150();

    operator_delete(pvVar1);

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

  }

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

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

    FUN_0051c040();

    operator_delete(pvVar1);

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

  }

  puVar4 = *(undefined4 **)(param_1 + 0x104);

  while (puVar4 != (undefined4 *)0x0) {

    puVar6 = (undefined4 *)puVar4[9];

    *puVar4 = &PTR_LAB_007c78c0;

    operator_delete(puVar4);

    puVar4 = puVar6;

  }

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

  if (((*(uint *)(param_1 + 0xa8) & 1) != 0) && ((*(uint *)(param_1 + 0xa8) & 0xc0000) != 0)) {

    FUN_0050a230(param_1);

  }

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

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

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

  }

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

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

    while (iVar2 != 0) {

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

      puVar4 = (undefined4 *)*piVar3;

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

        puVar6 = (undefined4 *)0x0;

      }

      else {

        iVar2 = puVar4[1];

        *piVar3 = iVar2;

        if (iVar2 == 0) {

          piVar3[1] = 0;

        }

        puVar6 = (undefined4 *)*puVar4;

        operator_delete(puVar4);

      }

      LVar5 = InterlockedDecrement(puVar6 + 1);

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

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

      }

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

    }

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

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

      FUN_004c65a0();

      operator_delete(pvVar1);

    }

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

  }

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

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

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

  }

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

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(0);

  }

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

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

    FUN_0051a000();

    operator_delete(pvVar1);

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

  }

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

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

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

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

  *(undefined2 *)(param_1 + 0x174) = 0;

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

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

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

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

  }

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

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

    FUN_0051a9d0();

    operator_delete(pvVar1);

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

  }

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

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

    FUN_0051ae10();

    operator_delete(pvVar1);

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

  }

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

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

    FUN_0051b700();

    operator_delete(pvVar1);

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

  }

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

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

    FUN_0051bd60();

    operator_delete(pvVar1);

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

  }

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

  *(undefined **)(param_1 + 0xa8) = &DAT_00400c08;

  return;

}





// --- FUN_00514830 at 0x00514830 (size: 105) ---


void __fastcall FUN_00514830(undefined4 *param_1)



{

  undefined4 *puVar1;

  

  *param_1 = &PTR_FUN_007c78ec;

  FUN_005145d0();

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

  puVar1 = (undefined4 *)param_1[0x26];

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

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

  }

  param_1[0x26] = 0;

  param_1[0x12] = &PTR_FUN_0079385c;

  *param_1 = &PTR_LAB_007c78e0;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_005148a0 at 0x005148A0 (size: 80) ---


void __fastcall FUN_005148a0(int param_1)



{

  ushort *puVar1;

  uint uVar2;

  ushort uVar3;

  

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

      (puVar1 = *(ushort **)(param_1 + 0x44), puVar1 != (ushort *)0x0)) && (uVar3 = 0, *puVar1 != 0)

     ) {

    do {

      uVar2 = (uint)uVar3;

      FUN_00513850(*(undefined4 *)(*(int *)(puVar1 + 2) + uVar2 * 4),

                   *(undefined4 *)(*(int *)(puVar1 + 10) + uVar2 * 4),

                   uVar2 * 0x40 + *(int *)(puVar1 + 6));

      puVar1 = *(ushort **)(param_1 + 0x44);

      uVar3 = uVar3 + 1;

    } while (uVar3 < *puVar1);

  }

  return;

}





// --- FUN_005148f0 at 0x005148F0 (size: 281) ---


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



void __fastcall FUN_005148f0(int param_1)



{

  undefined4 uVar1;

  float10 fVar2;

  

  uVar1 = DAT_008379ac;

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

    DAT_008eee70 = DAT_008379a8;

    DAT_008eee74 = DAT_008379ac;

    fVar2 = (float10)(double)CONCAT44(DAT_008379ac,DAT_008379a8) -

            (float10)*(double *)(param_1 + 0xd8);

    if (fVar2 < (float10)_DAT_007c78bc == (fVar2 == (float10)_DAT_007c78bc)) {

      if ((float10)_DAT_00844da0 <= fVar2) {

        if (fVar2 <= (float10)_DAT_007c7840) {

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

            if ((*(uint *)(param_1 + 0xa8) & 0x40000) != 0) {

              FUN_005188e0((float)fVar2,0);

              FUN_005364e0(param_1 + 0xf8);

              FUN_00510140();

              FUN_005148a0();

            }

            if (((*(uint *)(param_1 + 0xa8) & 0x80000) != 0) && (*(int *)(param_1 + 0x30) != 0)) {

              FUN_0051bfb0();

            }

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

              FUN_0051c330();

            }

            FUN_00512020();

          }

          uVar1 = DAT_008379ac;

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

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

          return;

        }

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

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

        return;

      }

    }

    else {

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

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

    }

  }

  return;

}





// --- FUN_00514a10 at 0x00514A10 (size: 190) ---


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



{

  undefined4 uVar1;

  int iVar2;

  undefined4 local_10;

  undefined4 local_c;

  uint local_8;

  

  if ((*(byte *)(param_2 + 0xa8) & 1) != 0) {

    uVar1 = FUN_00513ac0(param_3);

    return uVar1;

  }

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

    iVar2 = FUN_005df0f5(0x18);

    if (iVar2 == 0) {

      uVar1 = 0;

    }

    else {

      uVar1 = FUN_005142f0(4);

    }

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

  }

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

    local_10 = DAT_008379a8;

    local_8 = *(uint *)(param_2 + 0xa8) & 4;

    local_c = DAT_008379ac;

    iVar2 = FUN_00514330(&local_10,*(undefined4 *)(param_2 + 8));

    if (iVar2 != 0) {

      return 0;

    }

    uVar1 = FUN_00513b60(param_2,param_3);

    return uVar1;

  }

  return 0;

}





// --- FUN_00514ad0 at 0x00514AD0 (size: 183) ---


void __fastcall FUN_00514ad0(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  undefined4 local_18;

  

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

  uVar4 = 0;

  if (iVar1 == 0) {

    return;

  }

  iVar3 = **(int **)(iVar1 + 0xc);

  if (iVar3 == 0) {

    FUN_004d8d00();

    uVar4 = 0;

  }

  do {

    do {

      if (iVar3 != 0) {

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

      }

      if ((DAT_00844d64 != 0) && (iVar2 = FUN_00508890(local_18), iVar2 != 0)) {

        FUN_00513b60(iVar2,*(uint *)(param_1 + 0xac) & 1);

      }

    } while ((iVar3 != 0) && (iVar3 = *(int *)(iVar3 + 4), iVar3 != 0));

    do {

      uVar4 = uVar4 + 1;

      if (*(uint *)(iVar1 + 0x10) <= uVar4) {

        return;

      }

      iVar3 = *(int *)(*(int *)(iVar1 + 0xc) + uVar4 * 4);

    } while (iVar3 == 0);

  } while( true );

}





// --- FUN_00514b90 at 0x00514B90 (size: 133) ---


void __thiscall FUN_00514b90(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  

  FUN_00425f10(param_2);

  iVar1 = FUN_00535c10();

  if (iVar1 == 0) {

    iVar1 = FUN_00535d20();

    if (iVar1 != 0) {

      local_40 = 0;

      local_3c = 0;

      local_38 = 0;

      local_34 = 0;

    }

  }

  FUN_00425f10(&local_40);

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  FUN_005148a0();

  return;

}





// --- FUN_00514c20 at 0x00514C20 (size: 55) ---


void __thiscall FUN_00514c20(int param_1,undefined4 param_2)



{

  FUN_00425f10(param_2);

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  FUN_005148a0();

  return;

}





// --- FUN_00514c60 at 0x00514C60 (size: 52) ---


void __thiscall FUN_00514c60(int param_1,undefined4 param_2)



{

  undefined1 local_40 [64];

  

  FUN_00425f10(param_1 + 0x50);

  FUN_00536b80(param_2);

  FUN_00514b90(local_40);

  return;

}





// --- FUN_00514ca0 at 0x00514CA0 (size: 126) ---


void __thiscall FUN_00514ca0(int param_1,int param_2)



{

  uint local_44;

  undefined1 local_40 [52];

  undefined1 local_c [12];

  

  local_44 = *(uint *)(param_2 + 4);

  FUN_00425f10(param_2 + 8);

  if ((local_44 & 0xffff) < 0x100) {

    FUN_005aac70(&local_44,local_c);

  }

  *(uint *)(param_1 + 0x4c) = local_44;

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(local_44);

  }

  FUN_00514b90(local_40);

  return;

}





// --- FUN_00514d20 at 0x00514D20 (size: 47) ---


void __fastcall FUN_00514d20(int param_1)



{

  FUN_00512a10();

  FUN_00514ca0(param_1 + 0x48);

  FUN_00508ce0(param_1,*(undefined4 *)(param_1 + 0x4c));

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

  return;

}





// --- FUN_00514d50 at 0x00514D50 (size: 203) ---


void __thiscall FUN_00514d50(int *param_1,uint param_2)



{

  undefined4 *puVar1;

  int iVar2;

  uint *puVar3;

  uint uVar4;

  uint *puVar5;

  

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

    FUN_00514e90(param_2);

    return;

  }

  puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 0x18 + 4);

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

    puVar5 = (uint *)0x0;

  }

  else {

    puVar5 = puVar3 + 1;

    *puVar3 = param_2;

    FUN_00401000(puVar5,0x18,param_2,&LAB_005109d0);

  }

  uVar4 = 0;

  if (param_1[3] != 0) {

    puVar3 = puVar5 + 2;

    do {

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

      puVar3[-1] = *(uint *)((int)puVar3 + iVar2 + 4);

      *puVar3 = *(uint *)((int)puVar3 + iVar2 + 8);

      puVar3[1] = *(uint *)((int)puVar3 + iVar2 + 0xc);

      puVar3[2] = *(uint *)((int)puVar3 + iVar2 + 0x10);

      puVar3[3] = *(uint *)((int)puVar3 + iVar2 + 0x14);

      uVar4 = uVar4 + 1;

      puVar3 = puVar3 + 6;

    } while (uVar4 < (uint)param_1[3]);

  }

  puVar1 = (undefined4 *)*param_1;

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

    if (puVar1[-1] != 0) {

      (**(code **)*puVar1)(3);

      *param_1 = (int)puVar5;

      param_1[3] = param_2;

      return;

    }

    operator_delete__(puVar1 + -1);

  }

  *param_1 = (int)puVar5;

  param_1[3] = param_2;

  return;

}





// --- FUN_00514e20 at 0x00514E20 (size: 30) ---


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



{

  FUN_00514e40();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00514e40 at 0x00514E40 (size: 79) ---


void __fastcall FUN_00514e40(undefined4 *param_1)



{

  int local_4;

  

  *param_1 = &PTR_FUN_007c78f0;

  FUN_005143c0(param_1);

  if (local_4 == 0) {

    do {

      FUN_004f8040();

    } while( true );

  }

  *param_1 = &PTR_FUN_007c7450;

  if (param_1[5] == 0) {

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

  }

  return;

}





// --- FUN_00514e90 at 0x00514E90 (size: 245) ---


void __thiscall FUN_00514e90(int *param_1,uint param_2)



{

  undefined4 *puVar1;

  int iVar2;

  uint *puVar3;

  uint uVar4;

  uint *puVar5;

  

  if ((uint)param_1[3] < param_2) {

    FUN_00514d50(param_2);

    return;

  }

  puVar5 = (uint *)0x0;

  if (param_2 == 0) {

    puVar1 = (undefined4 *)*param_1;

    param_1[3] = 0;

    if (puVar1 == (undefined4 *)0x0) goto LAB_00514f75;

    if (puVar1[-1] != 0) {

      (**(code **)*puVar1)(3);

      goto LAB_00514f75;

    }

  }

  else {

    puVar3 = (uint *)thunk_FUN_005df0f5(param_2 * 0x18 + 4);

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

      puVar5 = puVar3 + 1;

      *puVar3 = param_2;

      FUN_00401000(puVar5,0x18,param_2,&LAB_005109d0);

    }

    uVar4 = 0;

    param_1[3] = param_2;

    if (param_2 != 0) {

      puVar3 = puVar5 + 2;

      do {

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

        puVar3[-1] = *(uint *)((int)puVar3 + iVar2 + 4);

        *puVar3 = *(uint *)((int)puVar3 + iVar2 + 8);

        puVar3[1] = *(uint *)((int)puVar3 + iVar2 + 0xc);

        puVar3[2] = *(uint *)((int)puVar3 + iVar2 + 0x10);

        puVar3[3] = *(uint *)((int)puVar3 + iVar2 + 0x14);

        uVar4 = uVar4 + 1;

        puVar3 = puVar3 + 6;

      } while (uVar4 < (uint)param_1[3]);

    }

    puVar1 = (undefined4 *)*param_1;

    if (puVar1 == (undefined4 *)0x0) goto LAB_00514f75;

    if (puVar1[-1] != 0) {

      (**(code **)*puVar1)(3);

      goto LAB_00514f75;

    }

  }

  operator_delete__(puVar1 + -1);

LAB_00514f75:

  *param_1 = (int)puVar5;

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

    param_1[2] = param_2;

  }

  return;

}





// --- FUN_00514f90 at 0x00514F90 (size: 30) ---


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



{

  FUN_00514830();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00514fb0 at 0x00514FB0 (size: 105) ---


int FUN_00514fb0(int param_1)



{

  int iVar1;

  int iVar2;

  

  iVar1 = param_1;

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

    param_1 = DAT_00844d94;

  }

  else {

    FUN_005195f0(&param_1);

  }

  iVar2 = FUN_00514470(param_1,0,1);

  if (iVar2 != 0) {

    FUN_00510580(iVar1);

    if (((*(int *)(iVar2 + 0x10) != 0) &&

        (iVar1 = *(int *)(*(int *)(iVar2 + 0x10) + 0x54), iVar1 != 0)) &&

       (iVar1 = *(int *)(iVar1 + 200), iVar1 != 0)) {

      FUN_005117a0(iVar1);

    }

  }

  return iVar2;

}





// --- FUN_00515020 at 0x00515020 (size: 252) ---


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



void __fastcall FUN_00515020(int param_1)



{

  double dVar1;

  undefined4 uVar2;

  undefined1 local_48 [68];

  

  uVar2 = DAT_008379ac;

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

    DAT_008eee70 = DAT_008379a8;

    DAT_008eee74 = DAT_008379ac;

    dVar1 = (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(param_1 + 0xd8);

    if (dVar1 < (double)_DAT_007c78bc == (dVar1 == (double)_DAT_007c78bc)) {

      if (_DAT_00844da0 <= dVar1) {

        if (dVar1 <= _DAT_007c7840) {

          FUN_00424ce0();

          FUN_00513730((float)dVar1,local_48);

          FUN_00514b90(local_48);

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

            FUN_0051c330();

          }

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

            FUN_0051bfb0();

          }

          uVar2 = DAT_008379ac;

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

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

          return;

        }

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

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

        return;

      }

    }

    else {

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

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

    }

  }

  return;

}





// --- FUN_00515120 at 0x00515120 (size: 349) ---


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

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

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

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

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



void __thiscall FUN_00515120(int param_1,int param_2)



{

  int iVar1;

  double dVar2;

  int iVar3;

  int iVar4;

  int local_28;

  undefined4 local_24;

  undefined4 uStack_20;

  int local_1c;

  

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

    iVar1 = **(int **)(*(int *)(param_1 + 0x15c) + 0xc);

    if (iVar1 == 0) {

      FUN_004d8d00();

    }

    local_28 = 0;

    FUN_00500570(10);

    iVar4 = param_2;

    do {

      if (iVar1 != 0) {

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

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

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

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

      }

      dVar2 = _DAT_008379a8 - (double)CONCAT44(uStack_20,local_24);

      if (((double)_DAT_007938b0 < dVar2) ||

         (((local_1c != 0 && (_DAT_00795610 < dVar2)) || (param_2 != 0)))) {

        FUN_004f8040();

        iVar3 = FUN_00500570(8);

        if (iVar3 != 0) {

          *(int *)(local_28 * 4) = iVar4;

          local_28 = local_28 + 1;

        }

      }

      else {

        FUN_004d8d00();

      }

    } while( true );

  }

  return;

}





// --- FUN_00515280 at 0x00515280 (size: 593) ---


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



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



{

  float fVar1;

  float fVar2;

  bool bVar3;

  float fVar4;

  int iVar5;

  undefined4 uVar6;

  uint uVar7;

  undefined4 local_14;

  

  uVar7 = 0;

  if (((param_4 == 0) || ((*(byte *)(param_1 + 0xac) & 2) == 0)) ||

     (bVar3 = false, (*(uint *)(param_1 + 0xa8) & 0x800000) != 0)) {

    bVar3 = true;

  }

  local_14 = 0;

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

    do {

      iVar5 = *(int *)(*(int *)(param_2 + 0x68) + uVar7 * 4);

      if ((iVar5 != 0) && (iVar5 = FUN_00514a10(iVar5,param_3), iVar5 != 0)) {

        local_14 = 1;

      }

      uVar7 = uVar7 + 1;

    } while (uVar7 < *(uint *)(param_2 + 100));

  }

  FUN_00515120(0);

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

    if ((*(int *)(param_2 + 0x7c) == 0) &&

       ((param_4 != 0 || ((*(byte *)(param_1 + 0xac) & 2) == 0)))) goto LAB_00515337;

    iVar5 = FUN_00513ac0(param_3);

    uVar6 = 1;

    if (iVar5 == 0) goto LAB_00515337;

  }

  else {

    *(uint *)(param_1 + 0x160) = (uint)(*(int *)(param_2 + 0x7c) != 0);

LAB_00515337:

    uVar6 = local_14;

  }

  iVar5 = *(int *)(param_2 + 0x80);

  if (iVar5 < 2) {

    if ((bVar3) && (*(int *)(param_2 + 0x48) != 0)) {

      if ((*(uint *)(param_1 + 0xa8) & 0x20000) == 0) {

        fVar1 = *(float *)(param_2 + 0x4c) * *(float *)(param_1 + 0xe0) +

                *(float *)(param_1 + 0xe4) * *(float *)(param_2 + 0x50) +

                *(float *)(param_1 + 0xe8) * *(float *)(param_2 + 0x54);

        if (fVar1 < (float)_DAT_00795610) {

          fVar4 = -((*(float *)(param_1 + 0xb0) + _DAT_007938b0) * fVar1);

          fVar1 = *(float *)(param_2 + 0x50);

          fVar2 = *(float *)(param_2 + 0x54);

          *(float *)(param_1 + 0xe0) =

               fVar4 * *(float *)(param_2 + 0x4c) + *(float *)(param_1 + 0xe0);

          *(float *)(param_1 + 0xe4) = fVar4 * fVar1 + *(float *)(param_1 + 0xe4);

          *(float *)(param_1 + 0xe8) = fVar4 * fVar2 + *(float *)(param_1 + 0xe8);

        }

      }

      else {

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

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

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

      }

    }

  }

  else {

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

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

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

    if (iVar5 == 3) goto LAB_00515467;

  }

  if (iVar5 != 0) {

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

    if (iVar5 == 1) {

      *(uint *)(param_1 + 0xac) = uVar7 | 0x10;

      return uVar6;

    }

    if (iVar5 != 2) {

      *(uint *)(param_1 + 0xac) = uVar7 | 0x40;

      return uVar6;

    }

    *(uint *)(param_1 + 0xac) = uVar7 | 0x20;

    return uVar6;

  }

LAB_00515467:

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff8f;

  return uVar6;

}





// --- FUN_005154e0 at 0x005154E0 (size: 132) ---


void __thiscall FUN_005154e0(int param_1,int param_2)



{

  int iVar1;

  

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

  if (iVar1 != 0) {

    if (param_2 == iVar1) {

      return;

    }

    FUN_00513ef0(iVar1);

  }

  FUN_00513e90(param_2);

  if (param_2 != 0) {

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

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

      FUN_00514d50(1);

    }

    FUN_0051c660(param_1);

    *(undefined4 *)(*(int *)(param_1 + 0x98) + 0x10) = *(undefined4 *)(param_2 + 0x28);

    FUN_0052be90(*(undefined4 *)(param_1 + 0x98),1);

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

      FUN_00518970(param_2,1);

    }

  }

  return;

}





// --- FUN_00515570 at 0x00515570 (size: 108) ---


void __fastcall FUN_00515570(int param_1)



{

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

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

    FUN_00514d50(1);

  }

  FUN_0051c660(param_1);

  *(undefined4 *)(*(int *)(param_1 + 0x98) + 0x10) =

       *(undefined4 *)(*(int *)(param_1 + 0x90) + 0x28);

  FUN_0052be90(*(undefined4 *)(param_1 + 0x98),1);

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

    FUN_00518970(*(undefined4 *)(param_1 + 0x90),1);

  }

  return;

}





// --- FUN_005155e0 at 0x005155E0 (size: 307) ---


void __thiscall FUN_005155e0(int param_1,int param_2)



{

  int iVar1;

  ushort *puVar2;

  uint uVar3;

  int iVar4;

  uint uVar5;

  

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

    uVar5 = *(uint *)(param_2 + 8);

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

    if (*(uint *)(param_1 + 0xa4) < uVar5) {

      FUN_00514d50(uVar5);

    }

    uVar5 = 0;

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

      iVar4 = 0;

      do {

        FUN_0051c660(param_1);

        *(undefined4 *)(*(int *)(param_1 + 0x98) + 0x10 + iVar4) =

             *(undefined4 *)(*(int *)(param_2 + 0xc) + uVar5 * 8);

        uVar5 = uVar5 + 1;

        iVar4 = iVar4 + 0x18;

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

    }

    uVar5 = 0;

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

      iVar4 = 0;

      do {

        iVar1 = *(int *)(*(int *)(param_2 + 0xc) + 4 + uVar5 * 8);

        if (iVar1 == 0) {

          *(undefined4 *)(*(int *)(param_1 + 0x98) + 0x14 + iVar4) = 0;

        }

        else {

          FUN_0052be90(*(int *)(param_1 + 0x98) + iVar4,*(undefined4 *)(param_2 + 8));

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

            FUN_00518970(iVar1,*(undefined4 *)(param_1 + 0x94));

          }

        }

        uVar5 = uVar5 + 1;

        iVar4 = iVar4 + 0x18;

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

    }

  }

  else {

    FUN_00515570();

  }

  uVar5 = 0;

  while( true ) {

    puVar2 = *(ushort **)(param_1 + 0x44);

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

      uVar3 = 0;

    }

    else {

      uVar3 = (uint)*puVar2;

    }

    if (uVar3 <= uVar5) break;

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

      FUN_005155e0(param_2);

      uVar5 = uVar5 + 1;

    }

    else {

      FUN_005155e0(param_2);

      uVar5 = uVar5 + 1;

    }

  }

  return;

}





// --- FUN_00515720 at 0x00515720 (size: 62) ---


void __thiscall FUN_00515720(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  

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

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

    if (uVar1 == 0) {

      iVar2 = 8;

    }

    else {

      iVar2 = uVar1 * 2;

    }

    iVar2 = FUN_00500570(iVar2);

    if (iVar2 == 0) {

      return;

    }

  }

  *(undefined4 *)(*(int *)(param_1 + 0x108) + *(int *)(param_1 + 0x110) * 4) = param_2;

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

  return;

}





// --- FUN_00515760 at 0x00515760 (size: 357) ---


void __thiscall FUN_00515760(int param_1,int param_2)



{

  uint *puVar1;

  ushort *puVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  ushort uVar6;

  

  if (param_2 == 0) {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xffffbfff;

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

      FUN_00522990(&param_2,0x75,0x3f800000);

      FUN_005117a0(param_2);

    }

    for (uVar6 = 0;

        (puVar2 = *(ushort **)(param_1 + 0x44), puVar2 != (ushort *)0x0 && (uVar6 < *puVar2));

        uVar6 = uVar6 + 1) {

      iVar3 = *(int *)(*(int *)(puVar2 + 2) + (uint)uVar6 * 4);

      puVar1 = (uint *)(iVar3 + 0xa8);

      *puVar1 = *puVar1 & 0xffffffdf;

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

        FUN_00518e30(0);

      }

    }

    uVar4 = *(uint *)(param_1 + 0xa8);

    uVar5 = uVar4 & 0xffffffef;

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

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

      *(uint *)(param_1 + 0xa8) = uVar5 | 8;

      FUN_00514ad0();

    }

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

      FUN_005188a0();

    }

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

      FUN_0052ca50(param_1);

    }

  }

  else {

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x4000;

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

      FUN_00522990(&param_2,0x76,0x3f800000);

      FUN_005117a0(param_2);

    }

    for (uVar6 = 0;

        (puVar2 = *(ushort **)(param_1 + 0x44), puVar2 != (ushort *)0x0 && (uVar6 < *puVar2));

        uVar6 = uVar6 + 1) {

      iVar3 = *(int *)(*(int *)(puVar2 + 2) + (uint)uVar6 * 4);

      puVar1 = (uint *)(iVar3 + 0xa8);

      *puVar1 = *puVar1 | 0x20;

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

        FUN_00518e30(1);

      }

    }

    if ((*(byte *)(param_1 + 0xa8) & 8) != 0) {

      FUN_00515120(1);

      *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) & 0xfffffff7;

    }

    *(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x10;

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

      FUN_0052ca40(param_1);

    }

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

      FUN_005188a0();

      return;

    }

  }

  return;

}





// --- FUN_005158d0 at 0x005158D0 (size: 138) ---


undefined4 __thiscall FUN_005158d0(int param_1,uint param_2)



{

  uint uVar1;

  

  uVar1 = *(uint *)(param_1 + 0xa8) ^ param_2;

  *(uint *)(param_1 + 0xa8) = param_2;

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

    if ((param_2 & 0x800) == 0) {

      *(uint *)(param_1 + 0xa8) = param_2 & 0xfffff7ff;

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

        FUN_00519ce0();

      }

    }

    else {

      *(uint *)(param_1 + 0xa8) = param_2 | 0x800;

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

        FUN_00519730();

      }

    }

  }

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

    FUN_00510770(*(uint *)(param_1 + 0xa8) & 0x20,0);

  }

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

    FUN_00515760(*(uint *)(param_1 + 0xa8) & 0x4000,0);

  }

  return 1;

}





// --- FUN_00515960 at 0x00515960 (size: 101) ---


void __fastcall FUN_00515960(int param_1)



{

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

    FUN_005188c0();

  }

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

    FUN_00524f50();

  }

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

    FUN_00555e00();

  }

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

    FUN_0051b310();

    FUN_0051b290(2);

  }

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

    FUN_0051aa80(0);

  }

  FUN_00515120(1);

  return;

}





// --- FUN_005159d0 at 0x005159D0 (size: 106) ---


void __fastcall FUN_005159d0(int param_1)



{

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

    FUN_00524db0(0x3c);

  }

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

    FUN_00555e00();

  }

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

    FUN_00555e40();

  }

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

    FUN_00555ed0();

  }

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

    FUN_0051b310();

    FUN_0051b290(3);

  }

  FUN_00515120(1);

  return;

}





// --- FUN_00515a40 at 0x00515A40 (size: 531) ---


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



undefined4 __thiscall FUN_00515a40(int param_1,float param_2,int param_3)



{

  float fVar1;

  bool bVar2;

  int iVar3;

  undefined2 uVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 uVar7;

  uint uVar8;

  undefined2 *puVar9;

  int iStack_10;

  undefined4 local_c;

  undefined4 uStack_8;

  undefined4 uStack_4;

  

  iVar3 = (int)param_2;

  puVar5 = (undefined4 *)FUN_0051e270(&param_2);

  iVar6 = FUN_00513280(*puVar5);

  if (iVar6 != 0) {

    uVar8 = 0;

    iVar6 = *(int *)(iVar3 + 0xb0);

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

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

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

    }

    if (iVar6 != 0) {

      uVar7 = FUN_004220b0(iVar6,0x22);

      uVar7 = FUN_00415430(uVar7);

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

    }

    iVar6 = *(int *)(iVar3 + 0xb4);

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

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

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

    }

    if (iVar6 != 0) {

      uVar7 = FUN_004220b0(iVar6,0x2c);

      uVar7 = FUN_00415430(uVar7);

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

    }

    iStack_10 = FUN_004f8d90();

    if (iStack_10 == 0) {

      uVar7 = FUN_004f32b0();

      FUN_00510160(uVar7);

    }

    else {

      uVar7 = FUN_0051df70();

      *(undefined4 *)(param_1 + 0xcc) = uVar7;

      if (param_3 != 0) {

        uVar7 = FUN_004f8da0();

        FUN_00512b10(&iStack_10,uVar7);

      }

    }

    FUN_005158d0(*(undefined4 *)(iVar3 + 0x60),1);

    uVar7 = *(undefined4 *)(iVar3 + 100);

    *(undefined4 *)(param_1 + 0x114) = uVar7;

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

      local_c = uVar7;

      uStack_8 = uVar7;

      uStack_4 = uVar7;

      FUN_00519530(&local_c);

    }

    fVar1 = *(float *)(iVar3 + 0x68);

    if (((float)_DAT_00795610 <= fVar1) && (fVar1 <= (float)_DAT_007938c0)) {

      *(float *)(param_1 + 0xbc) = fVar1;

    }

    FUN_00510810(*(undefined4 *)(iVar3 + 0x6c));

    param_2 = *(float *)(iVar3 + 0x70);

    bVar2 = param_2 != DAT_007c7820;

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

    if ((bVar2) && (*(float *)(param_1 + 0xb4) = param_2, *(int *)(param_1 + 0x10) != 0)) {

      FUN_00518e70(param_2);

    }

    local_c = *(undefined4 *)(iVar3 + 0x74);

    uStack_8 = *(undefined4 *)(iVar3 + 0x78);

    uStack_4 = *(undefined4 *)(iVar3 + 0x7c);

    FUN_00511ec0(&local_c,1);

    local_c = *(undefined4 *)(iVar3 + 0x8c);

    uStack_8 = *(undefined4 *)(iVar3 + 0x90);

    uStack_4 = *(undefined4 *)(iVar3 + 0x94);

    *(undefined4 *)(param_1 + 0xf8) = local_c;

    *(undefined4 *)(param_1 + 0xfc) = uStack_8;

    *(undefined4 *)(param_1 + 0x100) = uStack_4;

    uVar7 = *(undefined4 *)(iVar3 + 0xb8);

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

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

    puVar9 = (undefined2 *)(param_1 + 0x164);

    do {

      uVar4 = FUN_0051df80(uVar8);

      *puVar9 = uVar4;

      uVar8 = uVar8 + 1;

      puVar9 = puVar9 + 1;

    } while (uVar8 < 9);

    return 1;

  }

  return 0;

}





// --- FUN_00515c60 at 0x00515C60 (size: 200) ---


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



void __fastcall FUN_00515c60(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  

  if ((DAT_00844f18 & 1) == 0) {

    DAT_00844f18 = DAT_00844f18 | 1;

    FUN_0050b3f0();

    _atexit((_func_4879 *)&LAB_00768830);

  }

  _DAT_00844f04 = 0;

  _DAT_00844efc = 0;

  _DAT_00844f00 = 1;

  if (((*(uint *)(param_1 + 0xa8) & 0x10000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    iVar1 = FUN_00518bb0();

    if (iVar1 != 0) {

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

        uVar2 = 0;

      }

      else {

        uVar2 = FUN_00518bc0();

      }

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

        uVar3 = 0;

      }

      else {

        uVar3 = FUN_00518bb0();

      }

      FUN_0052c600(param_1 + 0x48,uVar3,uVar2,&DAT_00844efc,0);

      goto LAB_00515d13;

    }

  }

  FUN_00511a90(&DAT_00844efc);

LAB_00515d13:

  FUN_00511d00();

  FUN_005155e0(&DAT_00844efc);

  return;

}





// --- FUN_00515d30 at 0x00515D30 (size: 246) ---


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



void __fastcall FUN_00515d30(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  undefined *puVar4;

  

  if ((DAT_00844f38 & 1) == 0) {

    DAT_00844f38 = DAT_00844f38 | 1;

    FUN_0050b3f0();

    _atexit((_func_4879 *)&LAB_00768850);

  }

  _DAT_00844f24 = 0;

  _DAT_00844f1c = 0;

  _DAT_00844f20 = 0;

  if ((*(uint *)(param_1 + 0xa8) & 0x10000) == 0) {

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

      iVar1 = FUN_00518bb0();

      if (iVar1 != 0) {

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

          uVar2 = 0;

        }

        else {

          uVar2 = FUN_00518bc0();

        }

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

          uVar3 = 0;

        }

        else {

          uVar3 = FUN_00518bb0();

        }

        FUN_0052c600(param_1 + 0x48,uVar3,uVar2,&DAT_00844f1c,0);

        goto LAB_00515e11;

      }

    }

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

      puVar4 = &DAT_00844eec;

    }

    else {

      puVar4 = (undefined *)FUN_00519630();

    }

    FUN_0052c5a0(param_1 + 0x48,puVar4,&DAT_00844f1c,0);

  }

  else {

    FUN_00511a90(&DAT_00844f1c);

  }

LAB_00515e11:

  FUN_00511d00();

  FUN_005155e0(&DAT_00844f1c);

  return;

}





// --- FUN_00515e30 at 0x00515E30 (size: 614) ---


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



undefined4 __thiscall FUN_00515e30(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  undefined4 uVar3;

  uint uVar4;

  ushort uVar5;

  

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

  iVar2 = *(int *)(param_2 + 0xbc);

  if (iVar2 == 0) {

    FUN_00512a10();

    FUN_00514ca0(param_2 + 0xc0);

    FUN_00508ce0(param_1,*(undefined4 *)(param_1 + 0x4c));

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

  }

  else {

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

      uVar3 = *(undefined4 *)(param_2 + 0xc4);

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

      if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

        FUN_00518900(uVar3);

      }

      if (*(short **)(param_1 + 0x44) != (short *)0x0) {

        uVar5 = 0;

        if (**(short **)(param_1 + 0x44) != 0) {

          do {

            iVar2 = *(int *)(*(int *)(*(int *)(param_1 + 0x44) + 4) + (uint)uVar5 * 4);

            uVar3 = *(undefined4 *)(param_2 + 0xc4);

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

            if (((*(uint *)(iVar2 + 0xa8) & 0x1000) == 0) && (*(int *)(iVar2 + 0x10) != 0)) {

              FUN_00518900(uVar3);

            }

            uVar5 = uVar5 + 1;

          } while (uVar5 < **(ushort **)(param_1 + 0x44));

        }

      }

    }

    else {

      FUN_00513e90(iVar2);

    }

    FUN_00514b90(param_2 + 200);

    iVar2 = *(int *)(param_2 + 0x2a4);

    *(undefined4 *)(param_1 + 0x140) = *(undefined4 *)(param_2 + 0x29c);

    *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_2 + 0x28c);

    *(undefined4 *)(param_1 + 0x134) = *(undefined4 *)(param_2 + 0x290);

    *(undefined4 *)(param_1 + 0x138) = *(undefined4 *)(param_2 + 0x294);

    *(undefined4 *)(param_1 + 0x13c) = *(undefined4 *)(param_2 + 0x298);

    if (*(int *)(param_2 + 0x288) == 0) {

      uVar4 = *(uint *)(param_1 + 0xac) & 0xfffffffe;

    }

    else {

      uVar4 = *(uint *)(param_1 + 0xac) | 1;

    }

    *(uint *)(param_1 + 0xac) = uVar4;

    FUN_00511420();

    if (iVar2 == 0) {

      uVar4 = *(uint *)(param_1 + 0xac) & 0xfffffff7;

    }

    else {

      uVar4 = *(uint *)(param_1 + 0xac) | 8;

    }

    *(uint *)(param_1 + 0xac) = uVar4;

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

      *(uint *)(param_1 + 0xac) = uVar4 & 0xfffffffd;

      if (((uVar4 & 2) != 0) && (*(int *)(param_1 + 0xc4) != 0)) {

        FUN_00524f20();

      }

      FUN_00511420();

    }

    else if (*(float *)(param_1 + 0x138) < _DAT_008eee6c) {

      FUN_00511de0(0);

    }

    else {

      FUN_00511de0(1);

    }

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

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

    *(undefined4 *)(param_1 + 0x14c) = *(undefined4 *)(param_2 + 0x2b4);

    if (*(int *)(param_2 + 0x2a8) == 0) {

      uVar4 = *(uint *)(param_1 + 0xac) & 0xfffffffb;

    }

    else {

      uVar4 = *(uint *)(param_1 + 0xac) | 4;

    }

    *(uint *)(param_1 + 0xac) = uVar4;

    FUN_00515280(param_2 + 0x270,uVar1 & 1,uVar1 & 2);

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

      if ((*(uint *)(param_1 + 0xa8) & 0x10000) != 0) {

        FUN_00515d30();

        return 1;

      }

      if (*(int *)(param_2 + 0x2fc) != 0) {

        FUN_00511d00();

        FUN_005155e0(param_2 + 0x2f4);

        return 1;

      }

    }

  }

  return 1;

}





// --- FUN_005160a0 at 0x005160A0 (size: 190) ---


void __fastcall FUN_005160a0(int param_1)



{

  uint uVar1;

  

  FUN_00515120(1);

  if (DAT_00844d64 != 0) {

    FUN_00508a80(param_1);

    FUN_00508f10(*(undefined4 *)(param_1 + 8));

  }

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

  FUN_00511d00();

  FUN_00511a20(0);

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

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900(0);

  }

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffffe;

  FUN_00511420();

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

  *(uint *)(param_1 + 0xac) = uVar1 & 0xfffffff5;

  if (((uVar1 & 2) != 0) && (*(int *)(param_1 + 0xc4) != 0)) {

    FUN_00524f20();

  }

  FUN_00511420();

  *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xfffffe0b;

  return;

}





// --- FUN_00516160 at 0x00516160 (size: 65) ---


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



{

  if (param_2 != 0) {

    FUN_00514b90(param_3 + 8);

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

      FUN_00513e90(param_2);

      FUN_00515d30();

    }

    return 0;

  }

  return 3;

}





// --- FUN_005161b0 at 0x005161B0 (size: 813) ---


void __thiscall FUN_005161b0(int param_1,undefined4 param_2)



{

  char cVar1;

  int iVar2;

  undefined4 *puVar3;

  float10 fVar4;

  undefined4 local_60;

  undefined4 local_5c;

  undefined4 local_58;

  undefined1 local_54 [12];

  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;

  

  if ((char)*(uint *)(param_1 + 0xac) < '\0') {

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

      return;

    }

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

      FUN_00512710(0,0);

    }

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

    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();

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

    FUN_00513730(param_2,&local_40);

    if ((*(int *)(param_1 + 0x10) == 0) || (iVar2 = FUN_00518b90(), iVar2 == 0)) {

      if ((*(int *)(param_1 + 0xc4) == 0) && ((*(uint *)(param_1 + 0xac) & 2) != 0)) {

        *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

      }

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

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

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

      FUN_00514b90(&local_40);

      local_60 = 0;

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

      local_5c = 0;

      local_58 = 0;

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

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

    }

    else {

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

      cVar1 = FUN_0050a9e0(puVar3);

      if (cVar1 == '\0') {

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

          if (((*(uint *)(param_1 + 0xa8) & 0x800000) != 0) && (iVar2 = FUN_0050f280(), iVar2 == 0))

          {

            fVar4 = (float10)FUN_004576f0();

            FUN_00536b80((float)fVar4);

          }

        }

        else {

          FUN_00452500(&local_60,puVar3);

          FUN_0043e880();

          FUN_00536af0(&local_60);

        }

        iVar2 = FUN_005138c0(param_1 + 0x48,&local_48,0);

        if (iVar2 == 0) {

          local_c = *puVar3;

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

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

          FUN_00514b90(&local_40);

          local_60 = 0;

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

          local_5c = 0;

          local_58 = 0;

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

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

        }

        else {

          FUN_0050aa30(&local_60,iVar2 + 0xc0);

          puVar3 = (undefined4 *)FUN_00455f00(local_54,param_2);

          local_60 = *puVar3;

          local_5c = puVar3[1];

          local_58 = puVar3[2];

          *(undefined4 *)(param_1 + 0x150) = local_60;

          *(undefined4 *)(param_1 + 0x154) = local_5c;

          *(undefined4 *)(param_1 + 0x158) = local_58;

          FUN_00515e30(iVar2);

        }

      }

      else {

        local_c = *puVar3;

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

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

        FUN_00514b90(&local_40);

        local_60 = 0;

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

        local_5c = 0;

        local_58 = 0;

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

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

      }

    }

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

      FUN_0051ab00();

    }

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

      FUN_0051b5c0();

    }

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

      FUN_00524ef0();

    }

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

      FUN_00518890();

    }

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

      FUN_00555d80();

    }

  }

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

    FUN_0051c330();

  }

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

    FUN_0051bfb0();

  }

  return;

}





// --- FUN_005164e0 at 0x005164E0 (size: 72) ---


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



{

  FUN_005119a0(param_2);

  FUN_00425f10(param_3);

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00519e40(param_1 + 0x50);

  }

  FUN_005148a0();

  FUN_00515c60();

  return;

}





// --- FUN_00516530 at 0x00516530 (size: 84) ---


void __fastcall FUN_00516530(int param_1)



{

  ushort uVar1;

  

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

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

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

        return;

      }

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

        return;

      }

      FUN_00515570();

    }

    else {

      FUN_00515d30();

    }

    for (uVar1 = 0;

        (*(ushort **)(param_1 + 0x44) != (ushort *)0x0 && (uVar1 < **(ushort **)(param_1 + 0x44)));

        uVar1 = uVar1 + 1) {

      FUN_00516530();

    }

  }

  return;

}





// --- FUN_00516590 at 0x00516590 (size: 192) ---


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



{

  uint uVar1;

  int iVar2;

  

  uVar1 = param_2;

  if (param_2 != 0) {

    iVar2 = FUN_00510340(param_1,param_3);

    if (iVar2 != 0) {

      FUN_00513f70();

      FUN_005160a0();

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

      if (*(int *)(uVar1 + 0x90) != 0) {

        FUN_00513e90(*(int *)(uVar1 + 0x90));

        if (*(int *)(uVar1 + 0x44) != 0) {

          iVar2 = FUN_0051bbb0(param_1,&param_2);

          if (iVar2 != 0) {

            FUN_00513850(param_1,*(undefined4 *)

                                  (*(int *)(*(int *)(uVar1 + 0x44) + 0x14) + (param_2 & 0xffff) * 4)

                         ,(param_2 & 0xffff) * 0x40 + *(int *)(*(int *)(uVar1 + 0x44) + 0xc));

            FUN_00516530();

          }

        }

      }

      if (((*(uint *)(*(int *)(param_1 + 0x40) + 0xa8) & 0x4000) != 0) &&

         (*(uint *)(param_1 + 0xa8) = *(uint *)(param_1 + 0xa8) | 0x20,

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

        FUN_00518e30(1);

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00516650 at 0x00516650 (size: 117) ---


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



{

  int iVar1;

  

  if ((param_2 != 0) && (iVar1 = FUN_005103c0(param_1,param_3,param_4), iVar1 != 0)) {

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

    FUN_00513f70();

    FUN_005160a0();

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

    if (*(int *)(param_2 + 0x90) != 0) {

      FUN_00513e90(*(int *)(param_2 + 0x90));

      FUN_00513850(param_1,param_3,param_4);

      FUN_00516530();

    }

    return 1;

  }

  return 0;

}





// --- FUN_005166d0 at 0x005166D0 (size: 314) ---


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



{

  undefined4 uVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  

  iVar3 = param_4;

  uVar1 = *(undefined4 *)(param_4 + 0x24);

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

    FUN_00512a70();

  }

  param_4 = 0;

  FUN_00512850(param_2,uVar1,&param_4,*(uint *)(param_3 + 0x48) >> 5 & 1,1);

  iVar4 = param_4;

  if (param_4 == 0) {

    FUN_00512a10();

    FUN_00514ca0(param_2);

    FUN_00508ce0(param_1,*(undefined4 *)(param_1 + 0x4c));

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

  }

  else {

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

      iVar2 = (**(code **)(**(int **)(param_1 + 300) + 0x74))();

      if (iVar2 != 0) {

LAB_00516754:

        iVar3 = FUN_00516160(iVar4,param_2);

        return iVar3;

      }

      iVar2 = (**(code **)(**(int **)(param_1 + 300) + 0x78))();

      if (iVar2 != 0) goto LAB_00516754;

      iVar2 = (**(code **)(**(int **)(param_1 + 300) + 0x7c))();

      if (iVar2 != 0) goto LAB_00516754;

    }

    if ((*(byte *)(param_3 + 0x48) & 0x20) != 0) {

      *(undefined4 *)(iVar3 + 0x2f8) = 1;

    }

    iVar4 = FUN_00512960(iVar4,param_2,iVar3,param_3);

    if (iVar4 == 0) {

      iVar3 = FUN_00515280(iVar3 + 0x270,0,0);

      return (-(uint)(iVar3 != 0) & 2) + 2;

    }

    if (*(int *)(iVar3 + 0xbc) == 0) {

      return 3;

    }

    iVar3 = FUN_00515e30(iVar3);

    if (iVar3 == 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00516810 at 0x00516810 (size: 486) ---


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



void __fastcall FUN_00516810(int param_1)



{

  float fVar1;

  undefined4 uVar2;

  float *pfVar3;

  float10 fVar4;

  double local_18 [2];

  

  if (((*(int *)(param_1 + 0x40) != 0) || (*(int *)(param_1 + 0x90) == 0)) ||

     ((*(uint *)(param_1 + 0xa8) & 0x1000000) != 0)) {

    *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

    return;

  }

  if (DAT_00844d68 != 0) {

    pfVar3 = (float *)FUN_0050aa30(local_18,param_1 + 0x48);

    *(float *)(param_1 + 0x14) = *pfVar3;

    *(float *)(param_1 + 0x18) = pfVar3[1];

    *(float *)(param_1 + 0x1c) = pfVar3[2];

    fVar1 = *(float *)(param_1 + 0x14);

    fVar1 = SQRT(*(float *)(param_1 + 0x1c) * *(float *)(param_1 + 0x1c) +

                 *(float *)(param_1 + 0x18) * *(float *)(param_1 + 0x18) + fVar1 * fVar1);

    *(float *)(param_1 + 0x20) = fVar1;

    if ((fVar1 <= _DAT_007c789c) || (*(int *)(DAT_00844d64 + 0x10) == 0)) {

      FUN_00510710(1);

    }

    else {

      *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) & 0xffffff7f;

    }

  }

  uVar2 = DAT_008379ac;

  fVar4 = (float10)(double)CONCAT44(DAT_008379ac,DAT_008379a8) -

          (float10)*(double *)(param_1 + 0xd8);

  _DAT_008eee70 = *(double *)(param_1 + 0xd8);

  local_18[0] = (double)fVar4;

  if (fVar4 < (float10)_DAT_007c78bc != (fVar4 == (float10)_DAT_007c78bc)) {

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

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

    return;

  }

  if ((float10)_DAT_007c7840 < fVar4) {

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

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

    return;

  }

  if (fVar4 < (float10)_DAT_00844da8 == (fVar4 == (float10)_DAT_00844da8)) {

    do {

      _DAT_008eee70 = _DAT_008eee70 + _DAT_00844da8;

      FUN_005161b0((float)_DAT_00844da8);

      fVar4 = (float10)local_18[0] - (float10)_DAT_00844da8;

      local_18[0] = (double)fVar4;

    } while ((float10)_DAT_00844da8 < fVar4);

    if (fVar4 <= (float10)_DAT_00844da0) goto LAB_005169c2;

  }

  _DAT_008eee70 = (double)((float10)_DAT_008eee70 + fVar4);

  FUN_005161b0((float)fVar4);

LAB_005169c2:

  uVar2 = DAT_008eee74;

  *(undefined4 *)(param_1 + 0xd8) = DAT_008eee70;

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

  return;

}





// --- FUN_00516a00 at 0x00516A00 (size: 305) ---


int FUN_00516a00(int param_1,undefined4 param_2)



{

  float fVar1;

  float fVar2;

  int iVar3;

  float *pfVar4;

  float10 fVar5;

  float10 fVar6;

  uint local_58;

  undefined **local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_30;

  undefined4 local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined4 local_20;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  iVar3 = 1;

  local_58 = 0;

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

    pfVar4 = (float *)FUN_00507820();

    do {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      local_48 = &PTR_LAB_00797910;

      fVar5 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

      fVar1 = *(float *)(param_1 + 0x58);

      fVar6 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

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

      *pfVar4 = (float)(fVar5 * (float10)fVar1) + *pfVar4;

      pfVar4[2] = pfVar4[2];

      pfVar4[1] = (float)(fVar6 * (float10)fVar2 + (float10)pfVar4[1]);

      iVar3 = FUN_005166d0(&local_48,param_1,param_2);

      if (iVar3 == 0) {

        return 0;

      }

      local_58 = local_58 + 1;

    } while (local_58 < *(uint *)(param_1 + 0x60));

  }

  return iVar3;

}





// --- FUN_00516b40 at 0x00516B40 (size: 115) ---


void FUN_00516b40(int param_1,undefined4 param_2)



{

  int iVar1;

  undefined **local_48;

  undefined4 local_44;

  

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

    FUN_00516a00(param_1,param_2);

    return;

  }

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

  local_48 = &PTR_LAB_00797910;

  FUN_00425f10(param_1 + 8);

  iVar1 = FUN_005166d0(&local_48,param_1,param_2);

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

    FUN_00516a00(param_1,param_2);

  }

  return;

}





// --- FUN_00516bc0 at 0x00516BC0 (size: 173) ---


undefined4 __fastcall FUN_00516bc0(int param_1)



{

  int iVar1;

  int iVar2;

  undefined *puVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 unaff_EBX;

  

  iVar1 = FUN_0050bc20();

  if (iVar1 == 0) {

    return 1;

  }

  thunk_FUN_0050da00(param_1,0);

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

    iVar2 = FUN_00518b90();

    if (iVar2 != 0) {

      uVar5 = *(undefined4 *)(param_1 + 0x114);

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

        puVar3 = (undefined *)0x0;

      }

      else {

        puVar3 = (undefined *)FUN_00518ba0();

      }

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

        uVar4 = 0;

      }

      else {

        uVar4 = FUN_00518b90();

      }

      goto LAB_00516c3c;

    }

  }

  uVar5 = 0x3f800000;

  puVar3 = &DAT_00844eec;

  uVar4 = 1;

LAB_00516c3c:

  FUN_0050a920(uVar4,puVar3,uVar5);

  uVar5 = FUN_00516b40(unaff_EBX,iVar1);

  FUN_0050a890(iVar1);

  return uVar5;

}





// --- FUN_00516c70 at 0x00516C70 (size: 220) ---


undefined4 __thiscall FUN_00516c70(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  undefined1 local_64 [100];

  

  uVar2 = DAT_008379ac;

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

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

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

    uVar2 = 1;

    if (param_2 != 0) {

      uVar2 = 0x11;

    }

    FUN_0051c680();

    FUN_0051c6d0(param_1 + 0x48);

    FUN_0051c670(uVar2);

    iVar1 = FUN_00516bc0(local_64);

    if (iVar1 == 0) {

      FUN_005aebf0();

      uVar2 = DAT_008379ac;

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

        if (-1 < (char)*(uint *)(param_1 + 0xac)) {

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

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

        }

        *(uint *)(param_1 + 0xac) = *(uint *)(param_1 + 0xac) | 0x80;

      }

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

        FUN_005188a0();

      }

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

        FUN_00524f40();

      }

      return 1;

    }

    FUN_005aebf0();

  }

  return 0;

}





// --- FUN_00516d50 at 0x00516D50 (size: 90) ---


undefined4 __fastcall FUN_00516d50(int param_1)



{

  int iVar1;

  undefined1 local_64 [100];

  

  FUN_00512a70();

  FUN_0051c680();

  FUN_0051c6d0(param_1 + 0x48);

  FUN_0051c670(0x11);

  iVar1 = FUN_00516bc0(local_64);

  if (iVar1 != 0) {

    FUN_005aebf0();

    return 0;

  }

  FUN_005aebf0();

  return 1;

}





// --- FUN_00516db0 at 0x00516DB0 (size: 91) ---


undefined4 FUN_00516db0(undefined4 param_1,int param_2)



{

  undefined4 uVar1;

  undefined1 local_64 [100];

  

  uVar1 = 0x1002;

  if (param_2 != 0) {

    uVar1 = 0x1012;

  }

  FUN_0051c680();

  FUN_0051c6d0(param_1);

  FUN_0051c670(uVar1);

  uVar1 = FUN_00516bc0(local_64);

  FUN_005aebf0();

  return uVar1;

}





// --- FUN_00516e10 at 0x00516E10 (size: 26) ---


void FUN_00516e10(undefined4 param_1)



{

  FUN_00514ca0(param_1);

  FUN_00516c70(1);

  return;

}





// --- FUN_00516e30 at 0x00516E30 (size: 267) ---


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



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



{

  ushort uVar1;

  uint uVar2;

  int iVar3;

  undefined4 uVar4;

  uint uVar5;

  bool bVar6;

  undefined1 local_64 [100];

  

  uVar1 = *(ushort *)(param_1 + 0x16c);

  uVar2 = (uint)uVar1 - (param_3 & 0xffff);

  uVar5 = (int)uVar2 >> 0x1f;

  if ((int)((uVar2 ^ uVar5) - uVar5) < 0x8000) {

    bVar6 = (ushort)param_3 < uVar1;

  }

  else {

    bVar6 = uVar1 < (ushort)param_3;

  }

  if (!bVar6) {

    iVar3 = FUN_00451b50(4,param_3);

    if ((iVar3 != 0) || (*(int *)(param_1 + 0x90) == 0)) {

      FUN_005159d0(1);

      FUN_0051c680();

      FUN_0051c6d0(param_2);

      FUN_0051c670(0x1012);

      FUN_00516bc0(local_64);

      FUN_005aebf0();

      return 1;

    }

    if (param_4 != 0) {

      if (*(float *)(param_1 + 0x20) < _DAT_007c789c) {

        uVar4 = FUN_0050f5e0();

        FUN_00510fc0(param_2,uVar4);

        return 1;

      }

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

        FUN_00555e40();

      }

      FUN_00516db0(param_2,1);

      return 1;

    }

  }

  return 0;

}





// --- FUN_00516f40 at 0x00516F40 (size: 253) ---


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



int FUN_00516f40(uint *param_1,int param_2,float *param_3,int param_4,int param_5)



{

  int iVar1;

  int iVar2;

  

  *param_1 = 0;

  if (((_DAT_007c7944 <= ABS(*param_3)) || (_DAT_007c7944 <= ABS(param_3[1]))) ||

     (_DAT_007c7944 <= ABS(param_3[2]))) {

    *param_1 = 1;

  }

  if (param_4 != 0) {

    *param_1 = *param_1 | 2;

  }

  if (param_5 != 0) {

    *param_1 = *param_1 | 4;

  }

  iVar1 = FUN_00527450();

  iVar2 = iVar1 + 4;

  if (_DAT_007c7944 <= ABS(*(float *)(param_2 + 8))) {

    iVar2 = iVar1 + 8;

  }

  else {

    *param_1 = *param_1 | 8;

  }

  if (_DAT_007c7944 <= ABS(*(float *)(param_2 + 0xc))) {

    iVar2 = iVar2 + 4;

  }

  else {

    *param_1 = *param_1 | 0x10;

  }

  if (_DAT_007c7944 <= ABS(*(float *)(param_2 + 0x10))) {

    iVar2 = iVar2 + 4;

  }

  else {

    *param_1 = *param_1 | 0x20;

  }

  if (_DAT_007c7944 <= ABS(*(float *)(param_2 + 0x14))) {

    iVar2 = iVar2 + 4;

  }

  else {

    *param_1 = *param_1 | 0x40;

  }

  if ((*param_1 & 1) != 0) {

    iVar2 = iVar2 + 0xc;

  }

  if ((*param_1 & 2) != 0) {

    iVar2 = iVar2 + 4;

  }

  return iVar2 + 8;

}





// --- FUN_00517040 at 0x00517040 (size: 57) ---


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



{

  int iVar1;

  

  if (param_3 < 0xc) {

    return 0;

  }

  *param_1 = *(undefined4 *)*param_2;

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  param_1[1] = *(undefined4 *)(iVar1 + 4);

  iVar1 = *param_2;

  *param_2 = iVar1 + 4;

  param_1[2] = *(undefined4 *)(iVar1 + 4);

  *param_2 = *param_2 + 4;

  return 1;

}





// --- FUN_005170c0 at 0x005170C0 (size: 234) ---


void FUN_005170c0(int *param_1,uint param_2,uint param_3,int param_4,undefined4 *param_5,

                 undefined4 param_6,undefined4 param_7,undefined2 param_8,undefined2 param_9,

                 undefined2 param_10,undefined2 param_11)



{

  int iVar1;

  

  *(uint *)*param_1 = param_3;

  *param_1 = *param_1 + 4;

  FUN_005aa7f0(param_1,param_2);

  if ((param_3 & 8) == 0) {

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

    *param_1 = *param_1 + 4;

  }

  if ((param_3 & 0x10) == 0) {

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

    *param_1 = *param_1 + 4;

  }

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

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

    *param_1 = *param_1 + 4;

  }

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

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

    *param_1 = *param_1 + 4;

  }

  if (((param_3 & 1) != 0) && (0xb < param_2)) {

    *(undefined4 *)*param_1 = *param_5;

    iVar1 = *param_1;

    *param_1 = iVar1 + 4;

    *(undefined4 *)(iVar1 + 4) = param_5[1];

    iVar1 = *param_1;

    *param_1 = iVar1 + 4;

    *(undefined4 *)(iVar1 + 4) = param_5[2];

    *param_1 = *param_1 + 4;

  }

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

    *(undefined4 *)*param_1 = param_6;

    *param_1 = *param_1 + 4;

  }

  *(undefined2 *)*param_1 = param_8;

  iVar1 = *param_1;

  *param_1 = iVar1 + 2;

  *(undefined2 *)(iVar1 + 2) = param_9;

  iVar1 = *param_1;

  *param_1 = iVar1 + 2;

  *(undefined2 *)(iVar1 + 2) = param_10;

  iVar1 = *param_1;

  *param_1 = iVar1 + 2;

  *(undefined2 *)(iVar1 + 2) = param_11;

  *param_1 = *param_1 + 2;

  return;

}





// --- FUN_005173a0 at 0x005173A0 (size: 77) ---


uint __fastcall FUN_005173a0(int param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  undefined4 local_4;

  

  local_4 = 0;

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

  iVar3 = (**(code **)(*(int *)(param_1 + 0x3c) + 0xc))(&stack0xfffffff4,0);

  uVar1 = iVar2 + 9 + iVar3;

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

    return (4 - (uVar1 & 3)) + uVar1;

  }

  return uVar1;

}





// --- FUN_00517570 at 0x00517570 (size: 124) ---


undefined4 * __thiscall

FUN_00517570(undefined4 *param_1,int param_2,undefined4 param_3,undefined2 param_4,

            undefined2 param_5,undefined2 param_6,undefined2 param_7)



{

  *param_1 = &PTR_LAB_007c7970;

  param_1[1] = &PTR_LAB_00797910;

  param_1[2] = 0;

  param_1[3] = 0x3f800000;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  FUN_00535b30();

  param_1[2] = *(undefined4 *)(param_2 + 4);

  FUN_00425f10(param_2 + 8);

  *(undefined2 *)(param_1 + 0x14) = param_4;

  param_1[0x13] = param_3;

  *(undefined2 *)((int)param_1 + 0x56) = param_7;

  *(undefined2 *)((int)param_1 + 0x52) = param_5;

  *(undefined2 *)(param_1 + 0x15) = param_6;

  return param_1;

}





// --- FUN_00517770 at 0x00517770 (size: 147) ---


undefined4 * __thiscall

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

            undefined2 param_5,undefined2 param_6,undefined2 param_7,undefined2 param_8)



{

  *param_1 = &PTR_LAB_007c7984;

  param_1[5] = &PTR_LAB_00797910;

  param_1[6] = 0;

  param_1[7] = 0x3f800000;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  FUN_00535b30();

  param_1[1] = param_2;

  param_1[2] = *param_3;

  param_1[3] = param_3[1];

  param_1[4] = param_3[2];

  param_1[6] = *(undefined4 *)(param_4 + 4);

  FUN_00425f10(param_4 + 8);

  *(undefined2 *)(param_1 + 0x17) = param_5;

  *(undefined2 *)((int)param_1 + 0x5e) = param_6;

  *(undefined2 *)(param_1 + 0x18) = param_7;

  *(undefined2 *)((int)param_1 + 0x62) = param_8;

  return param_1;

}





// --- FUN_005179f0 at 0x005179F0 (size: 19) ---


void __fastcall FUN_005179f0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c7998;

  *(undefined2 *)(param_1 + 1) = 0;

  *(undefined2 *)((int)param_1 + 6) = 0;

  return;

}





// --- FUN_00517a50 at 0x00517A50 (size: 63) ---


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



{

  int iVar1;

  

  if (param_3 < 4) {

    return 0;

  }

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

  iVar1 = *param_2;

  *param_2 = iVar1 + 2;

  *(undefined2 *)(param_1 + 6) = *(undefined2 *)(iVar1 + 2);

  *param_2 = *param_2 + 2;

  FUN_004fd1b0(param_2);

  return 1;

}





// --- FUN_00517ac0 at 0x00517AC0 (size: 46) ---


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



{

  param_1[0xf] = &PTR_FUN_0079385c;

  FUN_005200d0();

  *param_1 = &PTR_FUN_0079385c;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00517af0 at 0x00517AF0 (size: 173) ---


undefined4 * __thiscall

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

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

            undefined2 param_9)



{

  *param_1 = &PTR_FUN_007c795c;

  FUN_0051f300();

  param_1[0xf] = &PTR_LAB_00797910;

  param_1[0x10] = 0;

  param_1[0x11] = 0x3f800000;

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  FUN_00535b30();

  FUN_0051f770(param_2);

  param_1[0x10] = *(undefined4 *)(param_3 + 4);

  FUN_00425f10(param_3 + 8);

  param_1[0x22] = param_5;

  param_1[0x21] = param_4;

  *(undefined2 *)(param_1 + 0x23) = param_6;

  *(undefined2 *)(param_1 + 0x24) = param_8;

  *(undefined2 *)((int)param_1 + 0x8e) = param_7;

  *(undefined2 *)((int)param_1 + 0x92) = param_9;

  return param_1;

}





// --- FUN_00517c00 at 0x00517C00 (size: 78) ---


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



float10 __fastcall FUN_00517c00(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar1 = fVar1 * (float10)*(float *)(param_1 + 0xe0) + (float10)*(float *)(param_1 + 0xe4);

  if (fVar1 < (float10)_DAT_007c7a00) {

    return (float10)_DAT_007c7a00;

  }

  if ((float10)_DAT_007c7a04 < fVar1) {

    fVar1 = (float10)_DAT_007c7a04;

  }

  return fVar1;

}





// --- FUN_00517c50 at 0x00517C50 (size: 78) ---


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



float10 __fastcall FUN_00517c50(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar1 = fVar1 * (float10)*(float *)(param_1 + 0xe0) + (float10)*(float *)(param_1 + 0xe8);

  if (fVar1 < (float10)_DAT_007c7a00) {

    return (float10)_DAT_007c7a00;

  }

  if ((float10)_DAT_007c7a04 < fVar1) {

    fVar1 = (float10)_DAT_007c7a04;

  }

  return fVar1;

}





// --- FUN_00517ca0 at 0x00517CA0 (size: 78) ---


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



float10 __fastcall FUN_00517ca0(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar1 = fVar1 * (float10)*(float *)(param_1 + 0xec) + (float10)*(float *)(param_1 + 0xf0);

  if (fVar1 < (float10)DAT_00796344) {

    return (float10)DAT_00796344;

  }

  if ((float10)_DAT_007938b0 < fVar1) {

    fVar1 = (float10)_DAT_007938b0;

  }

  return fVar1;

}





// --- FUN_00517cf0 at 0x00517CF0 (size: 78) ---


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



float10 __fastcall FUN_00517cf0(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar1 = fVar1 * (float10)*(float *)(param_1 + 0xec) + (float10)*(float *)(param_1 + 0xf4);

  if (fVar1 < (float10)DAT_00796344) {

    return (float10)DAT_00796344;

  }

  if ((float10)_DAT_007938b0 < fVar1) {

    fVar1 = (float10)_DAT_007938b0;

  }

  return fVar1;

}





// --- FUN_00517d40 at 0x00517D40 (size: 50) ---


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



float10 __fastcall FUN_00517d40(int param_1)



{

  float10 fVar1;

  

  fVar1 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar1 = fVar1 * (float10)*(double *)(param_1 + 0x70) + (float10)*(double *)(param_1 + 0x78);

  if (fVar1 < (float10)_DAT_00795610) {

    fVar1 = (float10)DAT_00796344;

  }

  return fVar1;

}





// --- FUN_00517d80 at 0x00517D80 (size: 305) ---


undefined4 * __fastcall FUN_00517d80(undefined4 *param_1)



{

  FUN_00415460(DAT_00844f88);

  param_1[0xc] = &PTR_FUN_0079385c;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  *param_1 = &PTR_LAB_007c7a38;

  param_1[0xc] = &PTR_LAB_007c7a20;

  param_1[0x11] = DAT_00844f88;

  param_1[0x12] = DAT_00844f88;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 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[0x23] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  param_1[0x29] = 0;

  param_1[0x2a] = 0;

  param_1[0x2b] = 0;

  param_1[0x2c] = 0;

  param_1[0x2d] = 0;

  param_1[0x2e] = 0;

  param_1[0x2f] = 0;

  param_1[0x30] = 0;

  param_1[0x31] = 0;

  param_1[0x38] = 0;

  param_1[0x3b] = 0;

  param_1[0x3c] = 0;

  param_1[0x3d] = 0;

  param_1[0x32] = 0x3f800000;

  param_1[0x33] = 0x3f800000;

  param_1[0x34] = 0x3f800000;

  param_1[0x35] = 0x3f800000;

  param_1[0x36] = 0x3f800000;

  param_1[0x37] = 0x3f800000;

  param_1[0x39] = 0x3f800000;

  param_1[0x3a] = 0x3f800000;

  return param_1;

}





// --- FUN_00517ee0 at 0x00517EE0 (size: 99) ---


void __fastcall FUN_00517ee0(int param_1)



{

  float fVar1;

  float fVar2;

  

  fVar2 = *(float *)(param_1 + 0xcc) * (float)*(double *)(param_1 + 0x78);

  fVar1 = *(float *)(param_1 + 0xa0);

  if (*(float *)(param_1 + 0xa0) <= fVar2) {

    fVar1 = fVar2;

  }

  *(float *)(param_1 + 0x8c) = fVar1;

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

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

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

  return;

}





// --- FUN_00517f50 at 0x00517F50 (size: 118) ---


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



undefined4 __thiscall

FUN_00517f50(int param_1,int param_2,int param_3,float *param_4,double param_5)



{

  if (((0 < *(int *)(param_1 + 0x60)) && (*(int *)(param_1 + 0x60) <= param_3)) ||

     (*(int *)(param_1 + 0x58) <= param_2)) {

    return 0;

  }

  if ((*(uint *)(param_1 + 0x38) & 1) == 0) {

    if ((*(uint *)(param_1 + 0x38) & 2) == 0) {

      return 0;

    }

    if ((double)param_4[2] * (double)param_4[2] +

        (double)param_4[1] * (double)param_4[1] + (double)*param_4 * (double)*param_4 <=

        *(double *)(param_1 + 0x50) * *(double *)(param_1 + 0x50)) {

      return 0;

    }

  }

  else if (_DAT_008379a8 - param_5 <= *(double *)(param_1 + 0x50)) {

    return 0;

  }

  return 1;

}





// --- FUN_00517fd0 at 0x00517FD0 (size: 353) ---


void __thiscall FUN_00517fd0(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  int iVar5;

  float10 fVar6;

  float10 fVar7;

  float10 fVar8;

  float10 fVar9;

  float local_24;

  float local_20;

  

  fVar6 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar7 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar8 = (float10)FUN_0042c860(0xbf800000,0x3f800000);

  fVar4 = (float)fVar8 * *(float *)(param_1 + 0x90) +

          (float)fVar6 * *(float *)(param_1 + 0x98) + (float)fVar7 * *(float *)(param_1 + 0x94);

  fVar1 = *(float *)(param_1 + 0x90);

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

  fVar3 = *(float *)(param_1 + 0x98);

  iVar5 = FUN_004524a0();

  if (iVar5 == 0) {

    fVar9 = (float10)FUN_0042c860(0,0x3f800000);

    fVar9 = ((float10)*(float *)(param_1 + 0xa0) - (float10)*(float *)(param_1 + 0x9c)) * fVar9 +

            (float10)*(float *)(param_1 + 0x9c);

    local_24 = (float)((float10)((float)fVar8 - fVar4 * fVar1) * fVar9);

    local_20 = (float)((float10)((float)fVar7 - fVar4 * fVar2) * fVar9);

    fVar9 = fVar9 * (float10)((float)fVar6 - fVar4 * fVar3);

  }

  else {

    fVar9 = (float10)0.0;

    local_24 = 0.0;

    local_20 = 0.0;

  }

  *param_2 = local_24;

  param_2[1] = local_20;

  param_2[2] = (float)fVar9;

  return;

}





// --- FUN_00518140 at 0x00518140 (size: 94) ---


void __thiscall FUN_00518140(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float10 fVar4;

  

  fVar4 = (float10)FUN_0042c860(0,0x3f800000);

  fVar1 = (float)(((float10)*(float *)(param_1 + 0xcc) - (float10)*(float *)(param_1 + 200)) * fVar4

                 + (float10)*(float *)(param_1 + 200));

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

  fVar3 = *(float *)(param_1 + 0xac);

  *param_2 = fVar1 * *(float *)(param_1 + 0xa4);

  param_2[1] = fVar1 * fVar2;

  param_2[2] = fVar1 * fVar3;

  return;

}





// --- FUN_005181a0 at 0x005181A0 (size: 94) ---


void __thiscall FUN_005181a0(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float10 fVar4;

  

  fVar4 = (float10)FUN_0042c860(0,0x3f800000);

  fVar1 = (float)(((float10)*(float *)(param_1 + 0xd4) - (float10)*(float *)(param_1 + 0xd0)) *

                  fVar4 + (float10)*(float *)(param_1 + 0xd0));

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

  fVar3 = *(float *)(param_1 + 0xb8);

  *param_2 = fVar1 * *(float *)(param_1 + 0xb0);

  param_2[1] = fVar1 * fVar2;

  param_2[2] = fVar1 * fVar3;

  return;

}





// --- FUN_00518200 at 0x00518200 (size: 94) ---


void __thiscall FUN_00518200(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float10 fVar4;

  

  fVar4 = (float10)FUN_0042c860(0,0x3f800000);

  fVar1 = (float)(((float10)*(float *)(param_1 + 0xdc) - (float10)*(float *)(param_1 + 0xd8)) *

                  fVar4 + (float10)*(float *)(param_1 + 0xd8));

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

  fVar3 = *(float *)(param_1 + 0xc4);

  *param_2 = fVar1 * *(float *)(param_1 + 0xbc);

  param_2[1] = fVar1 * fVar2;

  param_2[2] = fVar1 * fVar3;

  return;

}





// --- FUN_00518270 at 0x00518270 (size: 50) ---


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



{

  *param_1 = &PTR_LAB_007c7a38;

  param_1[0xc] = &PTR_LAB_007c7a20;

  param_1[0xc] = &PTR_FUN_0079385c;

  FUN_004154b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005182b0 at 0x005182B0 (size: 609) ---


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



{

  int iVar1;

  undefined4 *puVar2;

  

  if (0xab < param_3) {

    *(undefined4 *)*param_2 = 0;

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    *(undefined8 *)(iVar1 + 4) = *(undefined8 *)(param_1 + 0x20);

    iVar1 = *param_2;

    *param_2 = iVar1 + 8;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

    *(undefined8 *)(iVar1 + 4) = *(undefined8 *)(param_1 + 0x38);

    iVar1 = *param_2;

    *param_2 = iVar1 + 8;

    *(undefined8 *)(iVar1 + 8) = *(undefined8 *)(param_1 + 0x48);

    iVar1 = *param_2;

    *param_2 = iVar1 + 8;

    *(undefined8 *)(iVar1 + 8) = *(undefined8 *)(param_1 + 0x40);

    iVar1 = *param_2;

    *param_2 = iVar1 + 8;

    if (0xb < param_3) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      *param_2 = *param_2 + 4;

    }

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

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

    *param_2 = (int)puVar2;

    if (0xb < param_3) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

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

      *param_2 = (int)puVar2;

    }

    *puVar2 = *(undefined4 *)(param_1 + 0x98);

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

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

    *param_2 = (int)puVar2;

    if (0xb < param_3) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

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

      *param_2 = (int)puVar2;

    }

    *puVar2 = *(undefined4 *)(param_1 + 0xa0);

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

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

    *param_2 = (int)puVar2;

    if (0xb < param_3) {

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

      iVar1 = *param_2;

      *param_2 = iVar1 + 4;

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

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

      *param_2 = (int)puVar2;

    }

    *puVar2 = *(undefined4 *)(param_1 + 0xa8);

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    iVar1 = *param_2;

    *param_2 = iVar1 + 4;

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

    *param_2 = *param_2 + 4;

  }

  return 0xac;

}





// --- FUN_00518790 at 0x00518790 (size: 163) ---


void __thiscall FUN_00518790(uint *param_1,undefined4 *param_2)



{

  undefined4 *puVar1;

  int iVar2;

  uint local_4;

  

  iVar2 = 0;

  local_4 = 0;

  if (*param_1 != 0) {

    do {

      puVar1 = (undefined4 *)(param_1[1] + 4 + iVar2);

      puVar1[0xd] = param_2[0xd];

      puVar1[0xe] = param_2[0xe];

      puVar1[0xf] = param_2[0xf];

      *puVar1 = *param_2;

      puVar1[1] = param_2[1];

      puVar1[2] = param_2[2];

      puVar1[3] = param_2[3];

      puVar1[4] = param_2[4];

      puVar1[5] = param_2[5];

      puVar1[6] = param_2[6];

      puVar1[7] = param_2[7];

      puVar1[8] = param_2[8];

      puVar1[9] = param_2[9];

      puVar1[10] = param_2[10];

      puVar1[0xb] = param_2[0xb];

      puVar1[0xc] = param_2[0xc];

      local_4 = local_4 + 1;

      iVar2 = iVar2 + 0x48;

    } while (local_4 < *param_1);

  }

  return;

}





// --- FUN_00518840 at 0x00518840 (size: 19) ---


void __fastcall FUN_00518840(int param_1)



{

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

    FUN_0051cb60(param_1 + 8);

  }

  return;

}





// --- FUN_00518860 at 0x00518860 (size: 15) ---


void __fastcall FUN_00518860(int param_1)



{

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

    FUN_0051c810();

    return;

  }

  return;

}





// --- FUN_00518870 at 0x00518870 (size: 8) ---


void FUN_00518870(void)



{

  FUN_005257d0();

  return;

}





// --- FUN_00518880 at 0x00518880 (size: 13) ---


void __fastcall FUN_00518880(int param_1)



{

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

    FUN_0051c900();

    return;

  }

  return;

}





// --- FUN_00518890 at 0x00518890 (size: 13) ---


void __fastcall FUN_00518890(int param_1)



{

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

    thunk_FUN_0051c900();

    return;

  }

  return;

}





// --- FUN_005188a0 at 0x005188A0 (size: 19) ---


void __fastcall FUN_005188a0(int param_1)



{

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

    FUN_0051cad0(param_1 + 8);

  }

  return;

}





// --- FUN_005188c0 at 0x005188C0 (size: 19) ---


void __fastcall FUN_005188c0(int param_1)



{

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

    FUN_0051c8d0(param_1 + 8);

  }

  return;

}





// --- FUN_005188e0 at 0x005188E0 (size: 26) ---


void FUN_005188e0(float param_1,undefined4 param_2)



{

  FUN_00526780((double)param_1,param_2);

  return;

}





// --- FUN_00518900 at 0x00518900 (size: 41) ---


void __thiscall FUN_00518900(int param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar2 * 4);

      if (iVar1 != 0) {

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

      }

      uVar2 = uVar2 + 1;

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

  }

  return;

}





// --- FUN_00518930 at 0x00518930 (size: 52) ---


void __thiscall FUN_00518930(int param_1,int param_2)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar2 * 4);

      if (iVar1 != 0) {

        (**(code **)(*(int *)(param_2 + 0x38) + 4))(iVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

  return;

}





// --- FUN_00518970 at 0x00518970 (size: 89) ---


void __thiscall FUN_00518970(int param_1,int param_2,uint param_3)



{

  int iVar1;

  undefined4 uVar2;

  uint uVar3;

  

  uVar2 = 0;

  if (1 < param_3) {

    uVar2 = *(undefined4 *)(param_2 + 0xdc);

  }

  uVar3 = 0;

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

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar3 * 4);

      if (iVar1 != 0) {

        (*(code *)**(undefined4 **)(param_2 + 0x38))(iVar1,uVar2,param_2 + 0x5c,param_3);

      }

      uVar3 = uVar3 + 1;

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

  }

  return;

}





// --- FUN_005189d0 at 0x005189D0 (size: 65) ---


void __thiscall FUN_005189d0(int param_1,int param_2)



{

  uint *puVar1;

  uint uVar2;

  int iVar3;

  

  if (((param_2 != 0) && (puVar1 = *(uint **)(param_1 + 0x70), puVar1 != (uint *)0x0)) &&

     (uVar2 = 0, *puVar1 != 0)) {

    iVar3 = 0;

    do {

      FUN_0052bde0(puVar1[1] + iVar3);

      puVar1 = *(uint **)(param_1 + 0x70);

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x48;

    } while (uVar2 < *puVar1);

  }

  return;

}





// --- FUN_00518a20 at 0x00518A20 (size: 65) ---


void __thiscall FUN_00518a20(int param_1,int param_2)



{

  uint *puVar1;

  uint uVar2;

  int iVar3;

  

  if (((param_2 != 0) && (puVar1 = *(uint **)(param_1 + 0x70), puVar1 != (uint *)0x0)) &&

     (uVar2 = 0, *puVar1 != 0)) {

    iVar3 = 0;

    do {

      FUN_0052be20(puVar1[1] + iVar3);

      puVar1 = *(uint **)(param_1 + 0x70);

      uVar2 = uVar2 + 1;

      iVar3 = iVar3 + 0x48;

    } while (uVar2 < *puVar1);

  }

  return;

}





// --- FUN_00518a70 at 0x00518A70 (size: 279) ---


undefined4 __fastcall FUN_00518a70(int param_1)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  undefined4 uVar4;

  uint uVar5;

  undefined4 *puVar6;

  

  iVar2 = *(int *)(*(int *)(param_1 + 0x54) + 0x38);

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

  if (iVar2 != 0) {

    iVar2 = thunk_FUN_005df0f5(iVar2 * 4);

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

    if (iVar2 != 0) {

      uVar3 = 0;

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

        do {

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

          uVar3 = uVar3 + 1;

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

      }

      if (*(int *)(*(int *)(param_1 + 0x54) + 0x3c) != 0) {

        uVar3 = 0;

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

          do {

            uVar4 = FUN_0050f230(*(undefined4 *)

                                  (*(int *)(*(int *)(param_1 + 0x54) + 0x3c) + uVar3 * 4));

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

            if (*(int *)(*(int *)(param_1 + 0x5c) + uVar3 * 4) == 0) break;

            uVar3 = uVar3 + 1;

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

        }

        uVar5 = 0;

        if (uVar3 != *(uint *)(param_1 + 0x58)) {

          return 0;

        }

        if (*(uint *)(param_1 + 0x58) != 0) {

          do {

            *(undefined4 *)(*(int *)(*(int *)(param_1 + 0x5c) + uVar5 * 4) + 0xe0) =

                 *(undefined4 *)(param_1 + 4);

            *(uint *)(*(int *)(*(int *)(param_1 + 0x5c) + uVar5 * 4) + 0xe4) = uVar5;

            uVar5 = uVar5 + 1;

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

        }

        if ((*(int *)(*(int *)(param_1 + 0x54) + 0x44) != 0) &&

           (uVar3 = 0, *(int *)(param_1 + 0x58) != 0)) {

          iVar2 = 0;

          do {

            iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar3 * 4);

            puVar6 = (undefined4 *)(*(int *)(*(int *)(param_1 + 0x54) + 0x44) + iVar2);

            *(undefined4 *)(iVar1 + 0x24) = *puVar6;

            *(undefined4 *)(iVar1 + 0x28) = puVar6[1];

            *(undefined4 *)(iVar1 + 0x2c) = puVar6[2];

            uVar3 = uVar3 + 1;

            iVar2 = iVar2 + 0xc;

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

        }

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00518b90 at 0x00518B90 (size: 7) ---


undefined4 __fastcall FUN_00518b90(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x50);

}





// --- FUN_00518ba0 at 0x00518BA0 (size: 7) ---


undefined4 __fastcall FUN_00518ba0(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x54);

}





// --- FUN_00518bb0 at 0x00518BB0 (size: 7) ---


undefined4 __fastcall FUN_00518bb0(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x48);

}





// --- FUN_00518bc0 at 0x00518BC0 (size: 7) ---


undefined4 __fastcall FUN_00518bc0(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x4c);

}





// --- FUN_00518bd0 at 0x00518BD0 (size: 10) ---


float10 __fastcall FUN_00518bd0(int param_1)



{

  return (float10)*(float *)(*(int *)(param_1 + 0x54) + 100) * (float10)*(float *)(param_1 + 0x68);

}





// --- FUN_00518be0 at 0x00518BE0 (size: 10) ---


float10 __fastcall FUN_00518be0(int param_1)



{

  return (float10)*(float *)(*(int *)(param_1 + 0x54) + 0x60) * (float10)*(float *)(param_1 + 0x68);

}





// --- FUN_00518bf0 at 0x00518BF0 (size: 7) ---


undefined4 __fastcall FUN_00518bf0(int param_1)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x5c);

}





// --- FUN_00518c00 at 0x00518C00 (size: 21) ---


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



float10 __fastcall FUN_00518c00(int param_1)



{

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

    return (float10)*(float *)(*(int *)(param_1 + 0x54) + 0x6c) *

           (float10)*(float *)(param_1 + 0x68);

  }

  return (float10)_DAT_007a1870;

}





// --- FUN_00518c20 at 0x00518C20 (size: 21) ---


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



float10 __fastcall FUN_00518c20(int param_1)



{

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

    return (float10)*(float *)(*(int *)(param_1 + 0x54) + 0x68) *

           (float10)*(float *)(param_1 + 0x68);

  }

  return (float10)_DAT_007a1870;

}





// --- FUN_00518c40 at 0x00518C40 (size: 72) ---


undefined4 __fastcall FUN_00518c40(uint *param_1)



{

  uint uVar1;

  int *piVar2;

  

  uVar1 = 0;

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

    piVar2 = (int *)param_1[0x17];

    do {

      if (*(int *)(**(int **)(*piVar2 + 0x20) + 0x78) != 0) {

        *param_1 = *param_1 | 0x10000;

        return 1;

      }

      uVar1 = uVar1 + 1;

      piVar2 = piVar2 + 1;

    } while (uVar1 < param_1[0x16]);

  }

  *param_1 = *param_1 & 0xfffeffff;

  return 0;

}





// --- FUN_00518c90 at 0x00518C90 (size: 29) ---


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



{

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

            (*(undefined4 *)(param_1 + 0x58),*(undefined4 *)(param_1 + 0x5c),param_3);

  return;

}





// --- FUN_00518cb0 at 0x00518CB0 (size: 58) ---


int __thiscall FUN_00518cb0(int param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  iVar1 = 1;

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

    do {

      if ((*(int *)(*(int *)(param_1 + 0x5c) + uVar2 * 4) != 0) &&

         (iVar1 = FUN_0050e3a0(param_2), iVar1 != 1)) {

        return iVar1;

      }

      uVar2 = uVar2 + 1;

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

  }

  return iVar1;

}





// --- FUN_00518cf0 at 0x00518CF0 (size: 77) ---


undefined4 __fastcall FUN_00518cf0(int param_1)



{

  int iVar1;

  uint uVar2;

  

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

    iVar1 = thunk_FUN_005df0f5(*(int *)(param_1 + 0x58) << 2);

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

    if (iVar1 == 0) {

      return 0;

    }

    uVar2 = 0;

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

      do {

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

        uVar2 = uVar2 + 1;

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

    }

  }

  return 1;

}





// --- FUN_00518d40 at 0x00518D40 (size: 79) ---


void __fastcall FUN_00518d40(int param_1)



{

  int iVar1;

  uint uVar2;

  

  if (*(int *)(param_1 + 0x6c) != 0) {

    uVar2 = 0;

    if (*(int *)(param_1 + 0x58) != 0) {

      do {

        iVar1 = *(int *)(*(int *)(param_1 + 0x6c) + uVar2 * 4);

        if (iVar1 != 0) {

          FUN_0053ed10(iVar1);

          *(undefined4 *)(*(int *)(param_1 + 0x6c) + uVar2 * 4) = 0;

        }

        uVar2 = uVar2 + 1;

      } while (uVar2 < *(uint *)(param_1 + 0x58));

    }

    operator_delete__(*(void **)(param_1 + 0x6c));

    *(undefined4 *)(param_1 + 0x6c) = 0;

  }

  return;

}





// --- FUN_00518d90 at 0x00518D90 (size: 42) ---


void __fastcall FUN_00518d90(int param_1)



{

  uint uVar1;

  

  uVar1 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050eb00();

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518dc0 at 0x00518DC0 (size: 55) ---


void __thiscall FUN_00518dc0(int param_1,undefined4 param_2,undefined4 param_3)



{

  uint uVar1;

  

  uVar1 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050ec70(param_2,param_3);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518e00 at 0x00518E00 (size: 46) ---


void __fastcall FUN_00518e00(int param_1)



{

  uint uVar1;

  

  uVar1 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050e270(0);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518e30 at 0x00518E30 (size: 62) ---


void __thiscall FUN_00518e30(int param_1,undefined4 param_2)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050e0e0(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518e70 at 0x00518E70 (size: 62) ---


void __thiscall FUN_00518e70(int param_1,undefined4 param_2)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050f140(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518eb0 at 0x00518EB0 (size: 39) ---


void __thiscall FUN_00518eb0(int param_1,uint param_2,undefined4 param_3)



{

  if (((*(int *)(param_1 + 0x54) != 0) && (param_2 < *(uint *)(param_1 + 0x58))) &&

     (*(int *)(*(int *)(param_1 + 0x5c) + param_2 * 4) != 0)) {

    FUN_0050f140(param_3);

  }

  return;

}





// --- FUN_00518ee0 at 0x00518EE0 (size: 62) ---


void __thiscall FUN_00518ee0(int param_1,undefined4 param_2)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050f0c0(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518f20 at 0x00518F20 (size: 39) ---


void __thiscall FUN_00518f20(int param_1,uint param_2,undefined4 param_3)



{

  if (((*(int *)(param_1 + 0x54) != 0) && (param_2 < *(uint *)(param_1 + 0x58))) &&

     (*(int *)(*(int *)(param_1 + 0x5c) + param_2 * 4) != 0)) {

    FUN_0050f0c0(param_3);

  }

  return;

}





// --- FUN_00518f50 at 0x00518F50 (size: 62) ---


void __thiscall FUN_00518f50(int param_1,undefined4 param_2)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050f040(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00518f90 at 0x00518F90 (size: 39) ---


void __thiscall FUN_00518f90(int param_1,uint param_2,undefined4 param_3)



{

  if (((*(int *)(param_1 + 0x54) != 0) && (param_2 < *(uint *)(param_1 + 0x58))) &&

     (*(int *)(*(int *)(param_1 + 0x5c) + param_2 * 4) != 0)) {

    FUN_0050f040(param_3);

  }

  return;

}





// --- FUN_00518fc0 at 0x00518FC0 (size: 64) ---


void __thiscall FUN_00518fc0(int param_1,undefined4 param_2,undefined4 param_3)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050eed0(param_2,param_3);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00519000 at 0x00519000 (size: 54) ---


undefined4 __thiscall FUN_00519000(int param_1,uint param_2,undefined4 param_3,undefined4 param_4)



{

  if ((*(int *)(param_1 + 0x54) != 0) && (param_2 < *(uint *)(param_1 + 0x58))) {

    if (*(int *)(*(int *)(param_1 + 0x5c) + param_2 * 4) != 0) {

      FUN_0050eed0(param_3,param_4);

    }

    return 1;

  }

  return 0;

}





// --- FUN_00519040 at 0x00519040 (size: 46) ---


void __fastcall FUN_00519040(int param_1)



{

  uint uVar1;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar1 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050ef70();

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00519070 at 0x00519070 (size: 61) ---


undefined4 __fastcall FUN_00519070(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  uint uVar3;

  

  uVar2 = 0;

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar3 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar3 * 4) != 0) {

        iVar1 = FUN_0050ee80();

        if (iVar1 != 0) {

          uVar2 = 1;

        }

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 0x58));

  }

  return uVar2;

}





// --- FUN_005190b0 at 0x005190B0 (size: 89) ---


undefined4 __thiscall FUN_005190b0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  uVar2 = 1;

  if (*(int *)(param_1 + 0x54) != 0) {

    for (; param_2 != 0; param_2 = *(int *)(param_2 + 0x10)) {

      if (((*(uint *)(param_1 + 0x58) <= *(uint *)(param_2 + 4)) ||

          (*(int *)(*(int *)(param_1 + 0x5c) + *(uint *)(param_2 + 4) * 4) == 0)) ||

         (iVar1 = FUN_0050f1d0(*(undefined4 *)(param_2 + 8)), iVar1 == 0)) {

        uVar2 = 0;

      }

    }

    return uVar2;

  }

  return 0;

}





// --- FUN_00519110 at 0x00519110 (size: 91) ---


undefined4 __thiscall FUN_00519110(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  uVar2 = 1;

  if (*(int *)(param_1 + 0x54) != 0) {

    for (; param_2 != 0; param_2 = *(int *)(param_2 + 0x14)) {

      if (((*(uint *)(param_1 + 0x58) <= *(uint *)(param_2 + 4)) ||

          (*(int *)(*(int *)(param_1 + 0x5c) + *(uint *)(param_2 + 4) * 4) == 0)) ||

         (iVar1 = FUN_0050e900(*(undefined4 *)(param_2 + 8),*(undefined4 *)(param_2 + 0xc)),

         iVar1 == 0)) {

        uVar2 = 0;

      }

    }

    return uVar2;

  }

  return 0;

}





// --- FUN_00519170 at 0x00519170 (size: 146) ---


int * __thiscall FUN_00519170(int *param_1,int param_2)



{

  int *piVar1;

  int *piVar2;

  int *piVar3;

  

  *param_1 = param_2;

  piVar1 = (int *)thunk_FUN_005df0f5(param_2 * 0x48 + 4);

  if (piVar1 == (int *)0x0) {

    param_1[1] = 0;

    return param_1;

  }

  *piVar1 = param_2;

  if (-1 < param_2 + -1) {

    piVar3 = piVar1 + 0x11;

    piVar2 = piVar1 + 1;

    do {

      *piVar2 = 0;

      piVar3[-0xf] = 0x3f800000;

      piVar3[-0xe] = 0;

      piVar3[-0xd] = 0;

      piVar3[-0xc] = 0;

      piVar3[-2] = 0;

      piVar3[-1] = 0;

      *piVar3 = 0;

      FUN_00535b30();

      piVar3[1] = 0;

      piVar2 = piVar2 + 0x12;

      piVar3 = piVar3 + 0x12;

      param_2 = param_2 + -1;

    } while (param_2 != 0);

  }

  param_1[1] = (int)(piVar1 + 1);

  return param_1;

}





// --- FUN_00519210 at 0x00519210 (size: 109) ---


undefined4 __thiscall FUN_00519210(int param_1,int param_2)



{

  void *pvVar1;

  int *piVar2;

  int iVar3;

  

  iVar3 = param_2;

  if (*(int *)(param_1 + 0x50) != 0) {

    piVar2 = (int *)FUN_0051c740(&param_2);

    if (*piVar2 == iVar3) {

      return 1;

    }

    pvVar1 = *(void **)(param_1 + 0x50);

    if (pvVar1 != (void *)0x0) {

      FUN_0051ca00();

      operator_delete(pvVar1);

    }

    *(undefined4 *)(param_1 + 0x50) = 0;

  }

  if (iVar3 != 0) {

    iVar3 = FUN_0051c780(iVar3);

    *(int *)(param_1 + 0x50) = iVar3;

    if (iVar3 == 0) {

      return 0;

    }

    FUN_0051c6f0(*(undefined4 *)(param_1 + 4));

  }

  return 1;

}





// --- FUN_00519280 at 0x00519280 (size: 156) ---


undefined4 __thiscall FUN_00519280(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  undefined4 local_64;

  undefined4 local_60;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

  if (*(int *)(param_1 + 0x50) == 0) {

    return 7;

  }

  local_64 = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_60 = param_2;

  local_4 = param_3;

  local_64 = 2;

  uVar1 = FUN_0051cbe0(&local_64,param_1 + 8);

  return uVar1;

}





// --- FUN_00519320 at 0x00519320 (size: 156) ---


undefined4 __thiscall FUN_00519320(int param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 uVar1;

  undefined4 local_64;

  undefined4 local_60;

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_4;

  

  if (*(int *)(param_1 + 0x50) == 0) {

    return 7;

  }

  local_64 = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_60 = param_2;

  local_4 = param_3;

  local_64 = 4;

  uVar1 = FUN_0051cbe0(&local_64,param_1 + 8);

  return uVar1;

}





// --- FUN_005193c0 at 0x005193C0 (size: 136) ---


undefined4 __fastcall FUN_005193c0(int param_1)



{

  undefined4 uVar1;

  undefined4 local_64 [4];

  undefined **local_54;

  undefined4 local_50;

  undefined4 local_4c;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  

  if (*(int *)(param_1 + 0x50) == 0) {

    return 7;

  }

  local_64[0] = 0;

  local_54 = &PTR_LAB_00797910;

  local_50 = 0;

  local_4c = 0x3f800000;

  local_48 = 0;

  local_44 = 0;

  local_40 = 0;

  local_18 = 0;

  local_14 = 0;

  local_10 = 0;

  FUN_00535b30();

  local_64[0] = 5;

  uVar1 = FUN_0051cbe0(local_64,param_1 + 8);

  return uVar1;

}





// --- FUN_00519450 at 0x00519450 (size: 95) ---


void __fastcall FUN_00519450(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

  if (*(int *)(param_1 + 0x5c) != 0) {

    uVar2 = 0;

    if (*(int *)(param_1 + 0x58) != 0) {

      do {

        pvVar1 = *(void **)(*(int *)(param_1 + 0x5c) + uVar2 * 4);

        if (pvVar1 != (void *)0x0) {

          FUN_0050ed40();

          operator_delete(pvVar1);

          *(undefined4 *)(*(int *)(param_1 + 0x5c) + uVar2 * 4) = 0;

        }

        uVar2 = uVar2 + 1;

      } while (uVar2 < *(uint *)(param_1 + 0x58));

    }

    operator_delete__(*(void **)(param_1 + 0x5c));

    *(undefined4 *)(param_1 + 0x5c) = 0;

  }

  *(undefined4 *)(param_1 + 0x58) = 0;

  return;

}





// --- FUN_005194b0 at 0x005194B0 (size: 119) ---


void __fastcall FUN_005194b0(int param_1)



{

  undefined1 local_14 [4];

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  if (*(int *)(*(int *)(param_1 + 0x54) + 0xc4) != 0) {

    FUN_005259c0();

    FUN_005268e0();

    local_10 = *(undefined4 *)(*(int *)(param_1 + 0x54) + 0xc4);

    local_c = 0;

    local_8 = 0xffffffff;

    local_4 = 0x41f00000;

    FUN_00526110(local_14);

    FUN_005aebf0();

  }

  if (*(int *)(param_1 + 4) != 0) {

    FUN_005144d0(*(undefined4 *)(param_1 + 0x54));

  }

  return;

}





// --- FUN_00519530 at 0x00519530 (size: 172) ---


undefined4 __thiscall FUN_00519530(int param_1,float *param_2)



{

  float *pfVar1;

  float fVar2;

  float fVar3;

  int iVar4;

  int iVar5;

  float fVar6;

  uint uVar7;

  int iVar8;

  

  pfVar1 = (float *)(param_1 + 0x60);

  *pfVar1 = *param_2;

  *(float *)(param_1 + 100) = param_2[1];

  *(float *)(param_1 + 0x68) = param_2[2];

  uVar7 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    iVar8 = 0;

    do {

      iVar4 = *(int *)(*(int *)(param_1 + 0x5c) + uVar7 * 4);

      if (iVar4 != 0) {

        iVar5 = *(int *)(*(int *)(param_1 + 0x54) + 0x44);

        if (iVar5 == 0) {

          *(float *)(iVar4 + 0x24) = *pfVar1;

          *(undefined4 *)(iVar4 + 0x28) = *(undefined4 *)(param_1 + 100);

          fVar6 = *(float *)(param_1 + 0x68);

        }

        else {

          fVar2 = *(float *)(iVar8 + 4 + iVar5);

          fVar3 = *(float *)(param_1 + 100);

          fVar6 = *(float *)(iVar8 + 8 + iVar5) * *(float *)(param_1 + 0x68);

          *(float *)(iVar4 + 0x24) = *(float *)(iVar8 + iVar5) * *pfVar1;

          *(float *)(iVar4 + 0x28) = fVar2 * fVar3;

        }

        *(float *)(iVar4 + 0x2c) = fVar6;

      }

      uVar7 = uVar7 + 1;

      iVar8 = iVar8 + 0xc;

    } while (uVar7 < *(uint *)(param_1 + 0x58));

  }

  return 1;

}





// --- FUN_005195e0 at 0x005195E0 (size: 15) ---


void __thiscall FUN_005195e0(int param_1,undefined4 *param_2)



{

  *param_2 = *(undefined4 *)(*(int *)(param_1 + 0x54) + 0x28);

  return;

}





// --- FUN_005195f0 at 0x005195F0 (size: 56) ---


void __thiscall FUN_005195f0(int param_1,int *param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x54) + 0x28);

  if (iVar1 == DAT_00844fe0) {

    if (*(int *)(param_1 + 0x58) != 1) {

      *param_2 = DAT_00844fe0;

      return;

    }

    iVar1 = *(int *)(**(int **)(**(int **)(param_1 + 0x5c) + 0x20) + 0x28);

  }

  *param_2 = iVar1;

  return;

}





// --- FUN_00519630 at 0x00519630 (size: 127) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined * __fastcall FUN_00519630(int param_1)



{

  if ((_DAT_00844fb0 & 1) == 0) {

    _DAT_00844fb0 = _DAT_00844fb0 | 1;

    _DAT_00844fa0 = 0;

    _DAT_00844fa4 = 0;

    _DAT_00844fa8 = 0;

    _DAT_00844fac = 0;

    _atexit((_func_4879 *)&DAT_00768890);

  }

  if (*(int *)(param_1 + 0x54) != 0) {

    return (undefined *)(*(int *)(param_1 + 0x54) + 0x70);

  }

  return &DAT_00844fa0;

}





// --- FUN_005196b0 at 0x005196B0 (size: 121) ---


undefined4 __thiscall FUN_005196b0(int param_1,float *param_2)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  int iVar5;

  

  iVar5 = *(int *)(param_1 + 0x54);

  if (iVar5 != 0) {

    fVar1 = *(float *)(param_1 + 100);

    fVar2 = *(float *)(iVar5 + 0x84);

    fVar3 = *(float *)(param_1 + 0x68);

    fVar4 = *(float *)(iVar5 + 0x88);

    *param_2 = *(float *)(param_1 + 0x60) * *(float *)(iVar5 + 0x80);

    param_2[1] = fVar1 * fVar2;

    param_2[2] = fVar3 * fVar4;

    param_2[3] = *(float *)(*(int *)(param_1 + 0x54) + 0x8c) * *(float *)(param_1 + 0x68);

    return 1;

  }

  return 0;

}





// --- FUN_00519730 at 0x00519730 (size: 168) ---


undefined4 __fastcall FUN_00519730(int param_1)



{

  uint *puVar1;

  uint uVar2;

  int iVar3;

  int *piVar4;

  uint uVar5;

  int iVar6;

  

  if ((*(int *)(param_1 + 4) != 0) && (*(int *)(*(int *)(param_1 + 0x54) + 0x90) != 0)) {

    iVar3 = FUN_005df0f5(8);

    if (iVar3 == 0) {

      piVar4 = (int *)0x0;

    }

    else {

      piVar4 = (int *)FUN_00519170(*(undefined4 *)(*(int *)(param_1 + 0x54) + 0x90));

    }

    *(int **)(param_1 + 0x70) = piVar4;

    uVar5 = 0;

    if (*piVar4 != 0) {

      iVar6 = 0;

      iVar3 = 0;

      do {

        uVar2 = *(uint *)(*(int *)(param_1 + 4) + 0xa8);

        piVar4 = (int *)(*(int *)(*(int *)(param_1 + 0x70) + 4) + iVar3);

        *piVar4 = *(int *)(*(int *)(param_1 + 0x54) + 0x94) + iVar6;

        if ((uVar2 & 1) != 0) {

          puVar1 = (uint *)(piVar4 + 0x11);

          *puVar1 = *puVar1 | 1;

        }

        uVar5 = uVar5 + 1;

        iVar3 = iVar3 + 0x48;

        iVar6 = iVar6 + 0x68;

      } while (uVar5 < **(uint **)(param_1 + 0x70));

    }

    FUN_005189d0(*(undefined4 *)(*(int *)(param_1 + 4) + 0x90));

  }

  return 1;

}





// --- FUN_005197e0 at 0x005197E0 (size: 67) ---


void __thiscall FUN_005197e0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar2 * 4);

      if (iVar1 != 0) {

        FUN_0050a630(*(undefined4 *)(**(int **)(iVar1 + 0x20) + 0x28),param_2,param_3);

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00519830 at 0x00519830 (size: 49) ---


void __thiscall FUN_00519830(int param_1,uint param_2,undefined4 param_3,undefined4 param_4)



{

  int iVar1;

  

  if ((param_2 < *(uint *)(param_1 + 0x58)) &&

     (iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + param_2 * 4), iVar1 != 0)) {

    FUN_0050a630(*(undefined4 *)(**(int **)(iVar1 + 0x20) + 0x28),param_3,param_4);

  }

  return;

}





// --- FUN_00519870 at 0x00519870 (size: 194) ---


undefined4 __thiscall FUN_00519870(int param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 uVar3;

  uint uVar4;

  

  FUN_00519450();

  piVar1 = *(int **)(param_2 + 0x54);

  *(int **)(param_1 + 0x54) = piVar1;

  if (piVar1 != (int *)0x0) {

    (**(code **)(*piVar1 + 0x10))();

  }

  *(undefined4 *)(param_1 + 0x60) = *(undefined4 *)(param_2 + 0x60);

  *(undefined4 *)(param_1 + 100) = *(undefined4 *)(param_2 + 100);

  *(undefined4 *)(param_1 + 0x68) = *(undefined4 *)(param_2 + 0x68);

  iVar2 = *(int *)(param_2 + 0x58);

  *(int *)(param_1 + 0x58) = iVar2;

  uVar3 = thunk_FUN_005df0f5(iVar2 * 4);

  *(undefined4 *)(param_1 + 0x5c) = uVar3;

  FUN_00518cf0();

  uVar4 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      uVar3 = FUN_0050ed00(*(undefined4 *)(*(int *)(param_2 + 0x5c) + uVar4 * 4));

      *(undefined4 *)(*(int *)(param_1 + 0x5c) + uVar4 * 4) = uVar3;

      *(undefined4 *)(*(int *)(*(int *)(param_1 + 0x5c) + uVar4 * 4) + 0xe0) =

           *(undefined4 *)(param_1 + 4);

      *(uint *)(*(int *)(*(int *)(param_1 + 0x5c) + uVar4 * 4) + 0xe4) = uVar4;

      if (*(int *)(param_2 + 0x6c) != 0) {

        *(undefined4 *)(*(int *)(param_1 + 0x6c) + uVar4 * 4) =

             *(undefined4 *)(*(int *)(param_2 + 0x6c) + uVar4 * 4);

        piVar1 = *(int **)(*(int *)(param_1 + 0x6c) + uVar4 * 4);

        if (piVar1 != (int *)0x0) {

          (**(code **)(*piVar1 + 0x10))();

        }

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(uint *)(param_1 + 0x58));

  }

  return 1;

}





// --- FUN_00519940 at 0x00519940 (size: 210) ---


undefined4 __thiscall FUN_00519940(int param_1,int param_2,undefined4 param_3)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 uVar3;

  int iVar4;

  int *piVar5;

  uint uVar6;

  uint uVar7;

  

  if (*(int *)(param_1 + 0x54) == 0) {

    return 0;

  }

  FUN_00518cf0();

  uVar2 = param_3;

  iVar1 = param_2;

  if (param_2 != DAT_00844fe0) {

    uVar7 = 0;

    if (*(int *)(param_1 + 0x58) != 0) {

      do {

        iVar4 = *(int *)(*(int *)(param_1 + 0x6c) + uVar7 * 4);

        if (iVar4 == 0) {

          uVar3 = FUN_0053f120(iVar1,uVar2);

          *(undefined4 *)(*(int *)(param_1 + 0x6c) + uVar7 * 4) = uVar3;

          iVar4 = *(int *)(*(int *)(param_1 + 0x6c) + uVar7 * 4);

LAB_005199ad:

          if (iVar4 != 0) break;

        }

        else if (*(int *)(iVar4 + 0x28) == iVar1) {

          iVar4 = FUN_0053ef50(uVar2);

          goto LAB_005199ad;

        }

        uVar7 = uVar7 + 1;

      } while (uVar7 < *(uint *)(param_1 + 0x58));

    }

    if (uVar7 != *(uint *)(param_1 + 0x58)) {

      uVar6 = 0;

      if (*(uint *)(param_1 + 0x58) != 0) {

        do {

          if (((*(int *)(*(int *)(param_1 + 0x5c) + uVar6 * 4) != 0) &&

              (*(int *)(*(int *)(param_1 + 0x6c) + uVar7 * 4) != 0)) &&

             (piVar5 = (int *)FUN_0050e070(&param_2), *piVar5 == iVar1)) {

            FUN_0050e9a0(*(undefined4 *)(*(int *)(param_1 + 0x6c) + uVar7 * 4));

          }

          uVar6 = uVar6 + 1;

        } while (uVar6 < *(uint *)(param_1 + 0x58));

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00519a20 at 0x00519A20 (size: 217) ---


void __thiscall FUN_00519a20(int param_1,undefined4 param_2)



{

  uint uVar1;

  

  uVar1 = 0;

  if (*(int *)(param_1 + 0x58) != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) != 0) {

        FUN_0050e0d0();

        FUN_005b3490(*(int *)(*(int *)(param_1 + 0x5c) + uVar1 * 4) + 0x30);

        FUN_005b2e20(param_2);

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(param_1 + 0x58));

  }

  return;

}





// --- FUN_00519b00 at 0x00519B00 (size: 279) ---


void __thiscall FUN_00519b00(int param_1,float *param_2,float *param_3,float *param_4)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  float fVar11;

  

  fVar9 = *param_3 * *param_4;

  fVar10 = param_3[1] * param_4[1];

  fVar11 = param_3[2] * param_4[2];

  fVar1 = param_2[5];

  fVar2 = param_2[0xb];

  fVar3 = param_2[8];

  fVar4 = param_2[0xe];

  fVar5 = param_2[6];

  fVar6 = param_2[0xc];

  fVar7 = param_2[9];

  fVar8 = param_2[0xf];

  *(float *)(param_1 + 0x34) =

       fVar10 * param_2[7] + fVar11 * param_2[10] + fVar9 * param_2[4] + param_2[0xd];

  *(float *)(param_1 + 0x38) = fVar10 * fVar3 + fVar11 * fVar2 + fVar9 * fVar1 + fVar4;

  *(float *)(param_1 + 0x3c) = fVar10 * fVar7 + fVar11 * fVar6 + fVar9 * fVar5 + fVar8;

  FUN_00535dc0(((param_3[3] * *param_2 - param_3[4] * param_2[1]) - param_3[5] * param_2[2]) -

               param_3[6] * param_2[3],

               (param_3[6] * param_2[2] + param_3[3] * param_2[1] + param_3[4] * *param_2) -

               param_3[5] * param_2[3],

               param_3[3] * param_2[2] +

               param_3[4] * param_2[3] + (*param_2 * param_3[5] - param_2[1] * param_3[6]),

               param_3[3] * param_2[3] +

               ((param_2[1] * param_3[5] + *param_2 * param_3[6]) - param_3[4] * param_2[2]));

  return;

}





// --- FUN_00519c20 at 0x00519C20 (size: 93) ---


void __thiscall FUN_00519c20(int param_1,undefined4 param_2)



{

  int *piVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  

  piVar1 = (int *)FUN_00525570();

  if (piVar1 != (int *)0x0) {

    uVar2 = *(uint *)(param_1 + 0x58);

    if ((uint)piVar1[3] < *(uint *)(param_1 + 0x58)) {

      uVar2 = piVar1[3];

    }

    uVar3 = 0;

    if (uVar2 != 0) {

      iVar4 = 0;

      do {

        FUN_00519b00(param_2,*piVar1 + iVar4,param_1 + 0x60);

        uVar3 = uVar3 + 1;

        iVar4 = iVar4 + 0x1c;

      } while (uVar3 < uVar2);

    }

  }

  return;

}





// --- FUN_00519c80 at 0x00519C80 (size: 94) ---


undefined4 __thiscall FUN_00519c80(int param_1,int param_2)



{

  int iVar1;

  

  if (param_2 == DAT_00844fe0) {

    return 0;

  }

  iVar1 = FUN_00520bb0(param_2);

  if (iVar1 != 0) {

    FUN_00519450();

    if (*(int **)(param_1 + 0x54) != (int *)0x0) {

      (**(code **)(**(int **)(param_1 + 0x54) + 0x14))();

      *(undefined4 *)(param_1 + 0x54) = 0;

    }

    *(int *)(param_1 + 0x54) = iVar1;

    iVar1 = FUN_00518a70();

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_00519ce0 at 0x00519CE0 (size: 90) ---


void __fastcall FUN_00519ce0(int param_1)



{

  undefined4 *puVar1;

  

  if ((*(int *)(param_1 + 4) != 0) && (*(int *)(param_1 + 0x70) != 0)) {

    FUN_00518a20(*(undefined4 *)(*(int *)(param_1 + 4) + 0x90));

    puVar1 = *(undefined4 **)(param_1 + 0x70);

    if (puVar1 != (undefined4 *)0x0) {

      if (puVar1[1] != 0) {

        operator_delete__((void *)(puVar1[1] + -4));

        puVar1[1] = 0;

      }

      *puVar1 = 0;

      operator_delete(puVar1);

    }

    *(undefined4 *)(param_1 + 0x70) = 0;

  }

  return;

}





// --- FUN_00519d40 at 0x00519D40 (size: 133) ---


bool FUN_00519d40(int param_1)



{

  bool bVar1;

  int iVar2;

  bool bVar3;

  

  bVar3 = true;

  bVar1 = 0 < *(int *)(param_1 + 0x28);

  if (bVar1) {

    iVar2 = FUN_005190b0(*(undefined4 *)(param_1 + 0x20));

    bVar3 = iVar2 != 0;

  }

  if (0 < *(int *)(param_1 + 0x1c)) {

    iVar2 = FUN_00519110(*(undefined4 *)(param_1 + 0x14));

    if (iVar2 == 0) {

      bVar3 = false;

    }

    bVar1 = true;

  }

  if (*(int *)(param_1 + 0x10) < 1) {

    if (!bVar1) {

      return bVar3;

    }

  }

  else {

    iVar2 = FUN_00519940(*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_1 + 8));

    if (iVar2 == 0) {

      bVar3 = false;

    }

  }

  iVar2 = FUN_00519070();

  if (iVar2 != 0) {

    return bVar3;

  }

  return false;

}





// --- FUN_00519dd0 at 0x00519DD0 (size: 100) ---


void __fastcall FUN_00519dd0(undefined4 *param_1)



{

  void *pvVar1;

  

  pvVar1 = (void *)param_1[0x14];

  if (pvVar1 != (void *)0x0) {

    FUN_0051ca00();

    operator_delete(pvVar1);

  }

  param_1[0x14] = 0;

  FUN_00518d40();

  FUN_00519ce0();

  FUN_00519450();

  if ((int *)param_1[0x15] != (int *)0x0) {

    (**(code **)(*(int *)param_1[0x15] + 0x14))();

    param_1[0x15] = 0;

  }

  *param_1 = 0;

  param_1[1] = 0;

  FUN_00525420(0);

  return;

}





// --- FUN_00519e40 at 0x00519E40 (size: 32) ---


void __thiscall FUN_00519e40(int param_1,undefined4 param_2)



{

  FUN_00519c20(param_2);

  if (*(int *)(param_1 + 0x70) != 0) {

    FUN_00518790(param_2);

  }

  return;

}





// --- FUN_00519e60 at 0x00519E60 (size: 149) ---


undefined4 __thiscall FUN_00519e60(int param_1,int param_2,int param_3)



{

  undefined4 uVar1;

  int iVar2;

  

  if ((*(int *)(param_1 + 0x54) == 0) || (*(int *)(*(int *)(param_1 + 0x54) + 0x28) != param_2)) {

    uVar1 = FUN_004220b0(param_2,7);

    iVar2 = FUN_00415430(uVar1);

    if (iVar2 == 0) {

      return 0;

    }

    FUN_00518d40();

    FUN_00519ce0();

    FUN_00519450();

    if (*(int **)(param_1 + 0x54) != (int *)0x0) {

      (**(code **)(**(int **)(param_1 + 0x54) + 0x14))();

      *(undefined4 *)(param_1 + 0x54) = 0;

    }

    *(int *)(param_1 + 0x54) = iVar2;

    if ((param_3 != 0) && (iVar2 = FUN_00518a70(), iVar2 == 0)) {

      return 0;

    }

    FUN_00519730();

    FUN_005194b0();

  }

  return 1;

}





// --- FUN_00519f00 at 0x00519F00 (size: 161) ---


undefined4 __thiscall FUN_00519f00(int param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  

  iVar1 = *(int *)(param_1 + 0x54);

  for (iVar2 = *(int *)(*(int *)(iVar1 + 0xb8) +

                       ((param_2 >> ((byte)*(undefined4 *)(iVar1 + 0xb4) & 0x1f) ^ param_2) &

                       *(uint *)(iVar1 + 0xb0)) * 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

    if (param_2 == *(uint *)(iVar2 + 8)) {

      if (iVar2 != 0) goto LAB_00519f8e;

      break;

    }

  }

  iVar2 = *(int *)(*(int *)(iVar1 + 0xb8) +

                  (0U >> ((byte)*(undefined4 *)(iVar1 + 0xb4) & 0x1f) & *(uint *)(iVar1 + 0xb0)) * 4

                  );

  do {

    if (iVar2 == 0) {

LAB_00519f6e:

      FUN_005255b0(0,0);

      return 0;

    }

    if (*(int *)(iVar2 + 8) == 0) {

      if (iVar2 != 0) {

        param_2 = 0;

LAB_00519f8e:

        FUN_005255b0(iVar2 + 0xc,param_2);

        return 1;

      }

      goto LAB_00519f6e;

    }

    iVar2 = *(int *)(iVar2 + 4);

  } while( true );

}





// --- FUN_00519fb0 at 0x00519FB0 (size: 80) ---


undefined4 __thiscall FUN_00519fb0(int param_1,int param_2)



{

  undefined4 uVar1;

  uint uVar2;

  

  if ((*(int *)(param_1 + 0x54) != 0) && (uVar2 = 0, *(int *)(param_1 + 0x58) != 0)) {

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar2 * 4) != 0) {

        FUN_0050e080();

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < *(uint *)(param_1 + 0x58));

  }

  FUN_00518d40();

  if (param_2 == 0) {

    return 1;

  }

  uVar1 = FUN_00519d40(param_2);

  return uVar1;

}





// --- FUN_0051a000 at 0x0051A000 (size: 17) ---


void FUN_0051a000(void)



{

  FUN_00519dd0();

  FUN_00525630();

  return;

}





// --- FUN_0051a020 at 0x0051A020 (size: 161) ---


undefined4 * FUN_0051a020(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x78);

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = 0;

    puVar1[1] = 0;

    FUN_005255f0();

    puVar1[0x14] = 0;

    puVar1[0x15] = 0;

    puVar1[0x16] = 0;

    puVar1[0x17] = 0;

    puVar1[0x18] = 0x3f800000;

    puVar1[0x19] = 0x3f800000;

    puVar1[0x1a] = 0x3f800000;

    puVar1[0x1b] = 0;

    puVar1[0x1c] = 0;

    puVar1[0x1d] = 0;

    puVar1[1] = param_1;

    FUN_00525420(param_1);

    iVar2 = FUN_00520d10(param_2,param_3);

    puVar1[0x15] = iVar2;

    if (iVar2 != 0) {

      iVar2 = FUN_00518a70();

      if (iVar2 != 0) {

        return puVar1;

      }

    }

    FUN_00519dd0();

    FUN_00525630();

    operator_delete(puVar1);

  }

  return (undefined4 *)0x0;

}





// --- FUN_0051a0d0 at 0x0051A0D0 (size: 149) ---


undefined4 * FUN_0051a0d0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x78);

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = 0;

    puVar1[1] = 0;

    FUN_005255f0();

    puVar1[0x14] = 0;

    puVar1[0x15] = 0;

    puVar1[0x16] = 0;

    puVar1[0x17] = 0;

    puVar1[0x18] = 0x3f800000;

    puVar1[0x19] = 0x3f800000;

    puVar1[0x1a] = 0x3f800000;

    puVar1[0x1b] = 0;

    puVar1[0x1c] = 0;

    puVar1[0x1d] = 0;

    puVar1[1] = param_1;

    FUN_00525420(param_1);

    iVar2 = FUN_00519e60(param_2,param_3);

    if (iVar2 != 0) {

      FUN_00519f00(0x65);

      return puVar1;

    }

    FUN_00519dd0();

    FUN_00525630();

    operator_delete(puVar1);

  }

  return (undefined4 *)0x0;

}





// --- FUN_0051a170 at 0x0051A170 (size: 144) ---


undefined4 * FUN_0051a170(undefined4 param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x78);

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = 0;

    puVar1[1] = 0;

    FUN_005255f0();

    puVar1[0x14] = 0;

    puVar1[0x15] = 0;

    puVar1[0x16] = 0;

    puVar1[0x17] = 0;

    puVar1[0x18] = 0x3f800000;

    puVar1[0x19] = 0x3f800000;

    puVar1[0x1a] = 0x3f800000;

    puVar1[0x1b] = 0;

    puVar1[0x1c] = 0;

    puVar1[0x1d] = 0;

    puVar1[1] = param_1;

    FUN_00525420(param_1);

    iVar2 = FUN_00519c80(param_2);

    if (iVar2 != 0) {

      FUN_00519f00(0x65);

      return puVar1;

    }

    FUN_00519dd0();

    FUN_00525630();

    operator_delete(puVar1);

  }

  return (undefined4 *)0x0;

}





// --- FUN_0051a200 at 0x0051A200 (size: 105) ---


undefined4 FUN_0051a200(int param_1,int param_2)



{

  float fVar1;

  float10 fVar2;

  float10 fVar3;

  

  fVar1 = *(float *)(param_1 + 4);

  fVar2 = (float10)FUN_005aa560(param_2 + 0x48);

  fVar3 = (float10)FUN_0050f490();

  if (fVar3 + (float10)fVar1 <= (float10)(float)fVar2) {

    if (*(int *)(param_1 + 8) != 0) {

      *(undefined4 *)(param_1 + 8) = 0;

      return 2;

    }

  }

  else if (*(int *)(param_1 + 8) == 0) {

    *(undefined4 *)(param_1 + 8) = 1;

    return 1;

  }

  return 0;

}





// --- FUN_0051a270 at 0x0051A270 (size: 87) ---


void __thiscall FUN_0051a270(undefined4 *param_1,int *param_2)



{

  int iVar1;

  

  *param_1 = param_2;

  param_1[1] = 0xffffffff;

  param_1[2] = 0;

  param_1[3] = 0;

  if (param_2 == (int *)0x0) {

    param_1[3] = 1;

    return;

  }

  do {

    iVar1 = param_1[1] + 1;

    param_1[1] = iVar1;

    if (param_2[1] <= iVar1) {

      param_1[3] = 1;

      return;

    }

    iVar1 = *(int *)(*param_2 + iVar1 * 4);

    param_1[2] = iVar1;

  } while (iVar1 == 0);

  return;

}





// --- FUN_0051a2d0 at 0x0051A2D0 (size: 62) ---


undefined4 * __thiscall FUN_0051a2d0(undefined4 *param_1,int param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  

  param_1[1] = param_2;

  *param_1 = 0;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(param_2 << 2);

  *param_1 = puVar1;

  for (uVar2 = param_1[1] & 0x3fffffff; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar1 = 0;

    puVar1 = puVar1 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar1 = 0;

    puVar1 = (undefined4 *)((int)puVar1 + 1);

  }

  return param_1;

}





// --- FUN_0051a310 at 0x0051A310 (size: 92) ---


void __fastcall FUN_0051a310(int *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  

  puVar3 = (undefined4 *)*param_1;

  if (puVar3 < puVar3 + param_1[1]) {

    do {

      puVar2 = (undefined4 *)*puVar3;

      while (puVar2 != (undefined4 *)0x0) {

        puVar1 = (undefined4 *)*puVar2;

        if ((void *)puVar2[1] != (void *)0x0) {

          operator_delete((void *)puVar2[1]);

        }

        operator_delete(puVar2);

        puVar2 = puVar1;

      }

      *puVar3 = 0;

      puVar3 = puVar3 + 1;

    } while (puVar3 < (undefined4 *)(*param_1 + param_1[1] * 4));

  }

  return;

}





// --- FUN_0051a370 at 0x0051A370 (size: 65) ---


void __fastcall FUN_0051a370(int *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  

  puVar3 = (undefined4 *)*param_1;

  if (puVar3 < puVar3 + param_1[1]) {

    do {

      puVar2 = (undefined4 *)*puVar3;

      while (puVar2 != (undefined4 *)0x0) {

        puVar1 = (undefined4 *)*puVar2;

        operator_delete(puVar2);

        puVar2 = puVar1;

      }

      *puVar3 = 0;

      puVar3 = puVar3 + 1;

    } while (puVar3 < (undefined4 *)(*param_1 + param_1[1] * 4));

  }

  return;

}





// --- FUN_0051a3c0 at 0x0051A3C0 (size: 98) ---


void __thiscall FUN_0051a3c0(int *param_1,int param_2,int param_3)



{

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_10 = 0;

  local_c = 0;

  local_8 = 0;

  local_4 = *(undefined4 *)(param_2 + 4);

  *(undefined4 *)(param_3 + 4) = 1;

  FUN_0052c5a0(*param_1 + 0x48,&local_10,param_3,0);

  return;

}





// --- FUN_0051a430 at 0x0051A430 (size: 80) ---


undefined4 __thiscall FUN_0051a430(int *param_1,undefined4 param_2,uint param_3)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  

  puVar1 = (undefined4 *)(*param_1 + ((param_3 >> 0x10 ^ param_3) % (uint)param_1[1]) * 4);

  puVar2 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar2 != (undefined4 *)0x0) {

    *puVar2 = 0;

    puVar2[1] = 0;

    puVar2[2] = 0;

    puVar2[2] = param_3;

    puVar2[1] = param_2;

    *puVar2 = *puVar1;

    *puVar1 = puVar2;

    return 1;

  }

  return 0;

}





// --- FUN_0051a480 at 0x0051A480 (size: 166) ---


undefined4 __thiscall FUN_0051a480(int *param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  

  if ((param_1[1] == 0) && (param_1[3] == 0)) {

    iVar1 = FUN_005df0f5(8);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_0051a2d0(0x20);

    }

    param_1[1] = iVar1;

    iVar1 = FUN_005df0f5(0x1c);

    if (iVar1 == 0) {

      iVar1 = 0;

    }

    else {

      iVar1 = FUN_0050b3f0();

    }

    param_1[3] = iVar1;

    FUN_0051a3c0(param_2,iVar1);

    if (*(int *)(param_1[3] + 8) != 0) {

      uVar2 = 0;

      do {

        if (*(int *)(*(int *)(param_1[3] + 0xc) + 4 + uVar2 * 8) != 0) {

          FUN_0052c770(*(undefined4 *)(*param_1 + 8),param_2);

        }

        uVar2 = uVar2 + 1;

      } while (uVar2 < *(uint *)(param_1[3] + 8));

    }

    return 1;

  }

  return 0;

}





// --- FUN_0051a530 at 0x0051A530 (size: 238) ---


void __thiscall FUN_0051a530(int param_1,uint *param_2)



{

  int *piVar1;

  uint uVar2;

  uint uVar3;

  int iVar4;

  uint *puVar5;

  

  piVar1 = *(int **)(param_1 + 4);

  if (piVar1 != (int *)0x0) {

    uVar2 = *param_2;

    piVar1 = *(int **)(*piVar1 + ((uVar2 >> 0x10 ^ uVar2) % (uint)piVar1[1]) * 4);

    if (piVar1 != (int *)0x0) {

      uVar3 = piVar1[2];

      while (uVar3 != uVar2) {

        piVar1 = (int *)*piVar1;

        if (piVar1 == (int *)0x0) goto LAB_0051a5e2;

        uVar3 = piVar1[2];

      }

      iVar4 = piVar1[1];

      if (iVar4 != 0) {

        if (param_2[1] != 1) {

          if (*(int *)(iVar4 + 4) != 1) {

            *(undefined4 *)(iVar4 + 4) = 2;

            *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + 1;

            return;

          }

          FUN_0051ad60(uVar2);

          if (*(int *)(param_1 + 8) == 0) {

            return;

          }

          *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + -1;

          return;

        }

        if (*(int *)(iVar4 + 4) != 2) {

          *(undefined4 *)(iVar4 + 4) = 1;

          *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + 1;

          return;

        }

        *(undefined4 *)(iVar4 + 4) = 0;

        if (*(int *)(param_1 + 8) == 0) {

          return;

        }

        *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + -1;

        return;

      }

    }

LAB_0051a5e2:

    puVar5 = (uint *)FUN_005df0f5(8);

    if (puVar5 == (uint *)0x0) {

      puVar5 = (uint *)0x0;

    }

    else {

      *puVar5 = 0;

      puVar5[1] = 0;

    }

    uVar2 = *param_2;

    *puVar5 = uVar2;

    puVar5[1] = param_2[1];

    FUN_0051a430(puVar5,uVar2);

    *(int *)(param_1 + 8) = *(int *)(param_1 + 8) + 1;

  }

  return;

}





// --- FUN_0051a620 at 0x0051A620 (size: 312) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0051a620(int *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int iVar2;

  uint uVar3;

  float10 fVar4;

  undefined1 local_1c [8];

  uint local_14;

  int local_10;

  

  if (((param_1[3] != 0) || (FUN_0051a480(param_2), param_1[3] != 0)) &&

     (fVar4 = (float10)FUN_005aa560(*param_1 + 0x48), (float10)_DAT_007b817c <= fVar4)) {

    param_1[7] = *(int *)(*param_1 + 0x4c);

    FUN_00425f10(*param_1 + 0x50);

    FUN_0050b3f0();

    FUN_0051a3c0(param_2,local_1c);

    uVar3 = 0;

    if (local_14 != 0) {

      do {

        if (*(int *)(local_10 + 4 + uVar3 * 8) != 0) {

          FUN_0052c770(*(undefined4 *)(*param_1 + 8),param_2);

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < local_14);

    }

    iVar2 = param_1[3];

    uVar3 = 0;

    if (*(int *)(iVar2 + 8) != 0) {

      do {

        iVar2 = FUN_0052b950(*(undefined4 *)(*(int *)(iVar2 + 0xc) + uVar3 * 8));

        if (iVar2 != 0) {

          FUN_0052c8a0(*(undefined4 *)(*param_1 + 8),param_2);

        }

        iVar2 = param_1[3];

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(iVar2 + 8));

    }

    puVar1 = (undefined4 *)param_1[3];

    puVar1[2] = 0;

    *puVar1 = 0;

    puVar1[1] = 0;

    uVar3 = 0;

    if (local_14 != 0) {

      do {

        FUN_006b5f30(*(undefined4 *)(local_10 + uVar3 * 8),0);

        uVar3 = uVar3 + 1;

      } while (uVar3 < local_14);

    }

    if (local_10 != 0) {

      operator_delete__((void *)(local_10 + -4));

    }

  }

  return;

}





// --- FUN_0051a760 at 0x0051A760 (size: 199) ---


void __thiscall FUN_0051a760(int param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  FUN_0051a270(*(undefined4 *)(param_1 + 4));

  do {

    if (local_4 != 0) {

      return;

    }

    if (local_8 == (undefined4 *)0x0) {

      puVar1 = (undefined4 *)0x0;

    }

    else {

      puVar1 = (undefined4 *)local_8[1];

    }

    local_8 = (undefined4 *)*local_8;

    while (local_8 == (undefined4 *)0x0) {

      local_c = local_c + 1;

      if (local_10[1] <= local_c) {

        local_4 = 1;

        break;

      }

      local_8 = *(undefined4 **)(*local_10 + local_c * 4);

    }

    if (puVar1[1] == 1) {

      FUN_004f64c0(param_2,puVar1);

    }

    else if (puVar1[1] == 2) {

      FUN_004f64c0(param_2,puVar1);

    }

    if (puVar1[1] == 2) {

      FUN_0051ad60(*puVar1);

      operator_delete(puVar1);

    }

    else {

      puVar1[1] = 0;

    }

  } while( true );

}





// --- FUN_0051a830 at 0x0051A830 (size: 175) ---


void __thiscall FUN_0051a830(int *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  void *pvVar2;

  int iVar3;

  uint uVar4;

  

  if (param_1[1] != 0) {

    FUN_0051a310();

    puVar1 = (undefined4 *)param_1[1];

    if (puVar1 != (undefined4 *)0x0) {

      FUN_0051a370();

      operator_delete__((void *)*puVar1);

      *puVar1 = 0;

      operator_delete(puVar1);

    }

    param_1[1] = 0;

    param_1[2] = 0;

  }

  if (param_1[3] != 0) {

    uVar4 = 0;

    if (*(int *)(param_1[3] + 8) != 0) {

      do {

        iVar3 = FUN_0052b950(*(undefined4 *)(*(int *)(param_1[3] + 0xc) + uVar4 * 8));

        if (iVar3 != 0) {

          FUN_0052c8a0(*(undefined4 *)(*param_1 + 8),param_2);

        }

        uVar4 = uVar4 + 1;

      } while (uVar4 < *(uint *)(param_1[3] + 8));

    }

    pvVar2 = (void *)param_1[3];

    if (pvVar2 != (void *)0x0) {

      if (*(int *)((int)pvVar2 + 0xc) != 0) {

        operator_delete__((void *)(*(int *)((int)pvVar2 + 0xc) + -4));

      }

      *(undefined4 *)((int)pvVar2 + 0xc) = 0;

      operator_delete(pvVar2);

    }

    param_1[3] = 0;

  }

  return;

}





// --- FUN_0051a8e0 at 0x0051A8E0 (size: 92) ---


void __fastcall FUN_0051a8e0(int param_1)



{

  uint uVar1;

  void *pvVar2;

  uint uVar3;

  

  uVar1 = *(uint *)(param_1 + 0x70);

  while (uVar1 = uVar1 - 1, -1 < (int)uVar1) {

    pvVar2 = (void *)FUN_0051ad60(*(undefined4 *)(*(int *)(param_1 + 0x68) + uVar1 * 4));

    if (pvVar2 != (void *)0x0) {

      if (*(int *)((int)pvVar2 + 0xc) == 0) {

        FUN_0051a830(pvVar2);

      }

      operator_delete(pvVar2);

    }

    if (uVar1 < *(uint *)(param_1 + 0x70)) {

      uVar3 = *(uint *)(param_1 + 0x70) - 1;

      *(uint *)(param_1 + 0x70) = uVar3;

      if (uVar1 != uVar3) {

        *(undefined4 *)(*(int *)(param_1 + 0x68) + uVar1 * 4) =

             *(undefined4 *)(*(int *)(param_1 + 0x68) + uVar3 * 4);

      }

    }

  }

  return;

}





// --- FUN_0051a940 at 0x0051A940 (size: 131) ---


void __thiscall FUN_0051a940(int param_1,undefined4 *param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  if (param_2[3] == 0) {

    FUN_0051a620(param_2);

    FUN_0051a760(*param_2);

    *(undefined4 *)(param_1 + 8) = 0;

  }

  else {

    iVar1 = FUN_0050ff60(param_2[3]);

    if (iVar1 == 0) {

      param_2[4] = 2;

      iVar1 = param_2[4];

      uVar2 = *param_2;

    }

    else {

      uVar2 = FUN_0051a200(param_2,iVar1);

      param_2[4] = uVar2;

      iVar1 = param_2[4];

      uVar2 = *param_2;

    }

    if (iVar1 == 1) {

      FUN_004f64c0(uVar2,param_2 + 3);

      return;

    }

    if (iVar1 == 2) {

      FUN_004f64c0(uVar2,param_2 + 3);

      return;

    }

  }

  return;

}





// --- FUN_0051a9d0 at 0x0051A9D0 (size: 170) ---


void __fastcall FUN_0051a9d0(int param_1)



{

  void *pvVar1;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  FUN_0051a8e0();

  FUN_0051a270(param_1 + 0x60);

  if (local_4 == 0) {

    if (local_8 == (undefined4 *)0x0) goto LAB_0051aa2c;

    do {

      pvVar1 = (void *)local_8[1];

      if (pvVar1 != (void *)0x0) {

        if (*(int *)((int)pvVar1 + 0xc) == 0) {

          FUN_0051a830(pvVar1);

        }

        operator_delete(pvVar1);

      }

LAB_0051aa2c:

      local_8 = (undefined4 *)*local_8;

      while (local_8 == (undefined4 *)0x0) {

        local_c = local_c + 1;

        if (local_10[1] <= local_c) goto LAB_0051aa46;

        local_8 = *(undefined4 **)(*local_10 + local_c * 4);

      }

    } while( true );

  }

LAB_0051aa46:

  operator_delete__(*(void **)(param_1 + 0x68));

  FUN_0051a370();

  operator_delete__(*(void **)(param_1 + 0x60));

  *(undefined4 *)(param_1 + 0x60) = 0;

  *(undefined ***)(param_1 + 0x18) = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0051aa80 at 0x0051AA80 (size: 114) ---


undefined4 __thiscall FUN_0051aa80(int param_1,uint param_2)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  

  piVar1 = *(int **)(*(int *)(param_1 + 0x60) +

                    ((param_2 >> 0x10 ^ param_2) % *(uint *)(param_1 + 100)) * 4);

  if (piVar1 == (int *)0x0) {

    return 0;

  }

  uVar2 = piVar1[2];

  while (uVar2 != param_2) {

    piVar1 = (int *)*piVar1;

    if (piVar1 == (int *)0x0) {

      return 0;

    }

    uVar2 = piVar1[2];

  }

  if (piVar1[1] != 0) {

    uVar2 = *(uint *)(param_1 + 0x6c);

    if (uVar2 <= *(uint *)(param_1 + 0x70)) {

      if (uVar2 == 0) {

        iVar3 = 8;

      }

      else {

        iVar3 = uVar2 * 2;

      }

      iVar3 = FUN_00500570(iVar3);

      if (iVar3 == 0) {

        return 1;

      }

    }

    *(uint *)(*(int *)(param_1 + 0x68) + *(int *)(param_1 + 0x70) * 4) = param_2;

    *(int *)(param_1 + 0x70) = *(int *)(param_1 + 0x70) + 1;

    return 1;

  }

  return 0;

}





// --- FUN_0051ab00 at 0x0051AB00 (size: 164) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0051ab00(int param_1)



{

  bool bVar1;

  undefined4 uVar2;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  FUN_0051a8e0();

  if (_DAT_007c7bd8 <= (double)CONCAT44(DAT_008eee74,DAT_008eee70) - *(double *)(param_1 + 0x10)) {

    FUN_0051a270(param_1 + 0x60);

    if (local_4 == 0) {

      bVar1 = false;

      do {

        if (local_8 == (undefined4 *)0x0) {

          uVar2 = 0;

        }

        else {

          uVar2 = local_8[1];

        }

        if (!bVar1) {

          local_8 = (undefined4 *)*local_8;

          while (local_8 == (undefined4 *)0x0) {

            local_c = local_c + 1;

            if (local_10[1] <= local_c) {

              bVar1 = true;

              break;

            }

            local_8 = *(undefined4 **)(*local_10 + local_c * 4);

          }

        }

        FUN_0051a940(uVar2);

      } while (!bVar1);

    }

    uVar2 = DAT_008eee74;

    *(undefined4 *)(param_1 + 0x10) = DAT_008eee70;

    *(undefined4 *)(param_1 + 0x14) = uVar2;

  }

  return;

}





// --- FUN_0051abb0 at 0x0051ABB0 (size: 98) ---


void __thiscall FUN_0051abb0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_2 <= (uint)param_1[3]) {

    FUN_0051ac20(param_2);

    return;

  }

  iVar2 = thunk_FUN_005df0f5(param_2 * 8);

  uVar3 = 0;

  if (param_1[3] != 0) {

    do {

      iVar1 = *param_1;

      *(undefined4 *)(iVar2 + uVar3 * 8) = *(undefined4 *)(iVar1 + uVar3 * 8);

      *(undefined4 *)(iVar2 + 4 + uVar3 * 8) = *(undefined4 *)(iVar1 + 4 + uVar3 * 8);

      uVar3 = uVar3 + 1;

    } while (uVar3 < (uint)param_1[3]);

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar2;

  param_1[3] = param_2;

  return;

}





// --- FUN_0051ac20 at 0x0051AC20 (size: 131) ---


void __thiscall FUN_0051ac20(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  if (param_2 <= (uint)param_1[3]) {

    if (param_2 == 0) {

      param_1[3] = 0;

      operator_delete__((void *)*param_1);

      *param_1 = 0;

    }

    else {

      iVar2 = thunk_FUN_005df0f5(param_2 * 8);

      uVar3 = 0;

      param_1[3] = param_2;

      if (param_2 != 0) {

        do {

          iVar1 = *param_1;

          *(undefined4 *)(iVar2 + uVar3 * 8) = *(undefined4 *)(iVar1 + uVar3 * 8);

          *(undefined4 *)(iVar2 + 4 + uVar3 * 8) = *(undefined4 *)(iVar1 + 4 + uVar3 * 8);

          uVar3 = uVar3 + 1;

        } while (uVar3 < (uint)param_1[3]);

      }

      operator_delete__((void *)*param_1);

      *param_1 = iVar2;

    }

    if (param_2 < (uint)param_1[2]) {

      param_1[2] = param_2;

    }

    return;

  }

  FUN_0051abb0(param_2);

  return;

}





// --- FUN_0051acb0 at 0x0051ACB0 (size: 74) ---


undefined4 * __thiscall

FUN_0051acb0(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 uVar1;

  

  *param_1 = param_2;

  param_1[1] = param_3;

  param_1[2] = param_4;

  param_1[3] = 0;

  param_1[4] = 0;

  uVar1 = thunk_FUN_005df0f5(0x20);

  param_1[5] = uVar1;

  param_1[8] = 4;

  param_1[6] = 4;

  param_1[7] = 0;

  return param_1;

}





// --- FUN_0051ad00 at 0x0051AD00 (size: 87) ---


void __thiscall FUN_0051ad00(int param_1,int param_2,undefined4 param_3)



{

  uint uVar1;

  int *piVar2;

  

  uVar1 = 0;

  if (*(uint *)(param_1 + 0x10) != 0) {

    piVar2 = *(int **)(param_1 + 0x14);

    do {

      if (param_2 == *piVar2) {

        return;

      }

      uVar1 = uVar1 + 1;

      piVar2 = piVar2 + 2;

    } while (uVar1 < *(uint *)(param_1 + 0x10));

  }

  if (*(uint *)(param_1 + 0x20) <= *(uint *)(param_1 + 0x10)) {

    FUN_0051abb0(*(uint *)(param_1 + 0x20) + 4);

  }

  *(int *)(*(int *)(param_1 + 0x14) + *(int *)(param_1 + 0x10) * 8) = param_2;

  *(undefined4 *)(*(int *)(param_1 + 0x14) + 4 + *(int *)(param_1 + 0x10) * 8) = param_3;

  *(int *)(param_1 + 0x10) = *(int *)(param_1 + 0x10) + 1;

  return;

}





// --- FUN_0051ad60 at 0x0051AD60 (size: 104) ---


int __thiscall FUN_0051ad60(int *param_1,uint param_2)



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  int *piVar4;

  

  piVar1 = (int *)(*param_1 + ((param_2 >> 0x10 ^ param_2) % (uint)param_1[1]) * 4);

  piVar4 = (int *)*piVar1;

  if (piVar4 == (int *)0x0) {

    return 0;

  }

  if (piVar4[2] != param_2) {

    do {

      piVar3 = piVar4;

      piVar4 = (int *)*piVar3;

      if (piVar4 == (int *)0x0) {

        return 0;

      }

    } while (piVar4[2] != param_2);

    if (piVar3 != (int *)0x0) {

      *piVar3 = *piVar4;

      iVar2 = piVar4[1];

      operator_delete(piVar4);

      return iVar2;

    }

  }

  *piVar1 = *piVar4;

  iVar2 = piVar4[1];

  operator_delete(piVar4);

  return iVar2;

}





// --- FUN_0051add0 at 0x0051ADD0 (size: 63) ---


undefined4 * __fastcall FUN_0051add0(undefined4 *param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 2;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(8);

  param_1[2] = puVar1;

  for (uVar2 = param_1[3] & 0x3fffffff; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar1 = 0;

    puVar1 = puVar1 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar1 = 0;

    puVar1 = (undefined4 *)((int)puVar1 + 1);

  }

  return param_1;

}





// --- FUN_0051ae10 at 0x0051AE10 (size: 138) ---


void __fastcall FUN_0051ae10(int param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  puVar1 = (undefined4 *)(param_1 + 8);

  FUN_0051a270(puVar1);

  if (local_4 == 0) {

    if (local_8 == (undefined4 *)0x0) goto LAB_0051ae60;

    do {

      pvVar2 = (void *)local_8[1];

      if (pvVar2 != (void *)0x0) {

        operator_delete__(*(void **)((int)pvVar2 + 0x14));

        *(undefined4 *)((int)pvVar2 + 0x14) = 0;

        operator_delete(pvVar2);

      }

LAB_0051ae60:

      local_8 = (undefined4 *)*local_8;

      while (local_8 == (undefined4 *)0x0) {

        local_c = local_c + 1;

        if (local_10[1] <= local_c) goto LAB_0051ae7d;

        local_8 = *(undefined4 **)(*local_10 + local_c * 4);

      }

    } while( true );

  }

LAB_0051ae7d:

  FUN_0051a370();

  operator_delete__((void *)*puVar1);

  *puVar1 = 0;

  return;

}





// --- FUN_0051aea0 at 0x0051AEA0 (size: 118) ---


undefined4 __thiscall FUN_0051aea0(undefined4 *param_1,undefined4 param_2)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  undefined4 uVar4;

  undefined4 *puVar5;

  

  iVar3 = FUN_005df0f5(0x24);

  if (iVar3 == 0) {

    uVar4 = 0;

  }

  else {

    uVar4 = FUN_0051acb0(param_1[1],param_2,*param_1);

  }

  uVar2 = param_1[1];

  puVar1 = (undefined4 *)(param_1[2] + ((uVar2 >> 0x10 ^ uVar2) % (uint)param_1[3]) * 4);

  puVar5 = (undefined4 *)FUN_005df0f5(0xc);

  if (puVar5 != (undefined4 *)0x0) {

    *puVar5 = 0;

    puVar5[1] = 0;

    puVar5[2] = 0;

    puVar5[1] = uVar4;

    puVar5[2] = uVar2;

    *puVar5 = *puVar1;

    *puVar1 = puVar5;

  }

  param_1[1] = param_1[1] + 1;

  return uVar4;

}





// --- FUN_0051af20 at 0x0051AF20 (size: 45) ---


void FUN_0051af20(undefined4 *param_1)



{

  FUN_0051ad60(*param_1);

  operator_delete__((void *)param_1[5]);

  param_1[5] = 0;

  operator_delete(param_1);

  return;

}





// --- FUN_0051af50 at 0x0051AF50 (size: 25) ---


void __thiscall FUN_0051af50(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = param_2;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  return;

}





// --- FUN_0051af70 at 0x0051AF70 (size: 65) ---


void __fastcall FUN_0051af70(int *param_1)



{

  int iVar1;

  

  if (param_1[3] == 0) {

    param_1[2] = *(int *)param_1[2];

    do {

      if (param_1[2] != 0) {

        return;

      }

      iVar1 = param_1[1] + 1;

      param_1[1] = iVar1;

      if (iVar1 < ((int *)*param_1)[1]) {

        param_1[2] = *(int *)(*(int *)*param_1 + iVar1 * 4);

      }

      else {

        param_1[3] = 1;

      }

    } while (param_1[3] == 0);

  }

  return;

}





// --- FUN_0051afc0 at 0x0051AFC0 (size: 127) ---


undefined4 * __fastcall FUN_0051afc0(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = &PTR_LAB_00797910;

  param_1[7] = 0;

  param_1[8] = 0x3f800000;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  FUN_00535b30();

  param_1[0x18] = &PTR_LAB_00797910;

  param_1[0x19] = 0;

  param_1[0x1a] = 0x3f800000;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  param_1[0x29] = 0;

  FUN_00535b30();

  param_1[0x30] = 0;

  param_1[0x32] = 0;

  param_1[0x33] = 0;

  return param_1;

}





// --- FUN_0051b040 at 0x0051B040 (size: 79) ---


void __thiscall FUN_0051b040(int *param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = param_1[1];

  if (iVar1 != 0) {

    *(undefined4 *)(iVar1 + 0x10) = param_2;

    *(undefined4 *)(iVar1 + 0x14) = param_3;

    iVar1 = FUN_0050ff60(*(undefined4 *)(param_1[1] + 4));

    if (iVar1 != 0) {

      FUN_0050f8d0(*(undefined4 *)(*param_1 + 8),*(undefined4 *)(param_1[1] + 8),

                   (float)*(double *)(param_1[1] + 0x10));

    }

  }

  return;

}





// --- FUN_0051b090 at 0x0051B090 (size: 229) ---


void __thiscall FUN_0051b090(int *param_1,undefined4 *param_2,int param_3,undefined4 param_4)



{

  undefined4 *puVar1;

  int iVar2;

  undefined1 local_dc [12];

  undefined4 local_d0;

  undefined4 local_cc;

  undefined4 local_c8;

  undefined4 local_c0;

  undefined4 local_bc;

  undefined4 local_b4;

  undefined4 local_6c;

  undefined4 local_1c;

  undefined4 local_18;

  undefined4 local_14;

  undefined4 local_10;

  

  param_2[6] = *(undefined4 *)(param_3 + 4);

  FUN_00425f10(param_3 + 8);

  FUN_0051afc0();

  iVar2 = *param_1;

  local_c0 = param_2[2];

  local_c8 = param_2[4];

  local_d0 = 0;

  local_cc = *(undefined4 *)(iVar2 + 8);

  local_bc = param_2[3];

  local_b4 = *(undefined4 *)(iVar2 + 0x4c);

  FUN_00425f10(iVar2 + 0x50);

  local_6c = *(undefined4 *)(param_3 + 4);

  FUN_00425f10(param_3 + 8);

  puVar1 = (undefined4 *)FUN_00511e90(local_dc);

  local_1c = *puVar1;

  local_18 = puVar1[1];

  local_14 = puVar1[2];

  local_10 = param_4;

  iVar2 = FUN_0050ff60(*param_2);

  if (iVar2 != 0) {

    FUN_0050f8b0(&local_d0);

  }

  return;

}





// --- FUN_0051b180 at 0x0051B180 (size: 110) ---


void __thiscall FUN_0051b180(int *param_1,double param_2,int param_3)



{

  float fVar1;

  float fVar2;

  int iVar3;

  float fVar4;

  float *pfVar5;

  undefined1 local_c [12];

  

  iVar3 = *param_1;

  *(undefined4 *)(param_3 + 4) = *(undefined4 *)(iVar3 + 0x4c);

  FUN_00425f10(iVar3 + 0x50);

  fVar4 = (float)param_2;

  pfVar5 = (float *)FUN_00511e90(local_c);

  fVar1 = pfVar5[1];

  fVar2 = pfVar5[2];

  *(float *)(param_3 + 0x3c) = fVar4 * *pfVar5 + *(float *)(param_3 + 0x3c);

  *(float *)(param_3 + 0x40) = fVar4 * fVar1 + *(float *)(param_3 + 0x40);

  *(float *)(param_3 + 0x44) = fVar4 * fVar2 + *(float *)(param_3 + 0x44);

  return;

}





// --- FUN_0051b1f0 at 0x0051B1F0 (size: 158) ---


void FUN_0051b1f0(int param_1)



{

  float10 fVar1;

  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();

  FUN_0051b180(*(undefined4 *)(param_1 + 8),*(undefined4 *)(param_1 + 0xc),&local_48);

  fVar1 = (float10)FUN_005aa560(param_1 + 0x14);

  if ((float10)*(float *)(param_1 + 0x10) < fVar1) {

    FUN_0051b090(param_1,&local_48,1);

  }

  return;

}





// --- FUN_0051b290 at 0x0051B290 (size: 126) ---


void __thiscall FUN_0051b290(int *param_1,undefined4 param_2)



{

  bool bVar1;

  undefined4 uVar2;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  if ((param_1[2] != 0) && (FUN_0051a270(param_1[2]), local_4 == 0)) {

    bVar1 = false;

    do {

      if (local_8 == (undefined4 *)0x0) {

        uVar2 = 0;

      }

      else {

        uVar2 = local_8[1];

      }

      if (!bVar1) {

        local_8 = (undefined4 *)*local_8;

        while (local_8 == (undefined4 *)0x0) {

          local_c = local_c + 1;

          if (local_10[1] <= local_c) {

            bVar1 = true;

            break;

          }

          local_8 = *(undefined4 **)(*local_10 + local_c * 4);

        }

      }

      FUN_0051b090(uVar2,*param_1 + 0x48,param_2);

    } while (!bVar1);

  }

  return;

}





// --- FUN_0051b310 at 0x0051B310 (size: 75) ---


void __fastcall FUN_0051b310(int *param_1)



{

  void *pvVar1;

  int iVar2;

  

  if (param_1[1] != 0) {

    iVar2 = FUN_0050ff60(*(undefined4 *)(param_1[1] + 4));

    if (iVar2 != 0) {

      FUN_0050f920(*(undefined4 *)(*param_1 + 8));

    }

    pvVar1 = (void *)param_1[1];

    if (pvVar1 != (void *)0x0) {

      *(undefined ***)((int)pvVar1 + 0x60) = &PTR_FUN_0079385c;

      *(undefined ***)((int)pvVar1 + 0x18) = &PTR_FUN_0079385c;

      operator_delete(pvVar1);

    }

    param_1[1] = 0;

  }

  return;

}





// --- FUN_0051b360 at 0x0051B360 (size: 254) ---


void __thiscall FUN_0051b360(int *param_1,uint param_2,uint param_3,uint param_4,uint param_5)



{

  int *piVar1;

  uint uVar2;

  int iVar3;

  uint *puVar4;

  

  piVar1 = (int *)param_1[2];

  if (piVar1 == (int *)0x0) {

    iVar3 = FUN_005df0f5(8);

    if (iVar3 == 0) {

      iVar3 = 0;

    }

    else {

      iVar3 = FUN_0051a2d0(4);

    }

    param_1[2] = iVar3;

  }

  else {

    piVar1 = *(int **)(*piVar1 + ((param_2 >> 0x10 ^ param_2) % (uint)piVar1[1]) * 4);

    if (piVar1 != (int *)0x0) {

      uVar2 = piVar1[2];

      while (uVar2 != param_2) {

        piVar1 = (int *)*piVar1;

        if (piVar1 == (int *)0x0) goto LAB_0051b3db;

        uVar2 = piVar1[2];

      }

      iVar3 = piVar1[1];

      if (iVar3 != 0) {

        *(uint *)(iVar3 + 0x10) = param_3;

        *(uint *)(iVar3 + 8) = param_4;

        *(uint *)(iVar3 + 0xc) = param_5;

        return;

      }

    }

  }

LAB_0051b3db:

  puVar4 = (uint *)FUN_005df0f5(0x60);

  if (puVar4 == (uint *)0x0) {

    puVar4 = (uint *)0x0;

  }

  else {

    *puVar4 = 0;

    puVar4[2] = 0;

    puVar4[3] = 0;

    puVar4[4] = 0;

    puVar4[5] = (uint)&PTR_LAB_00797910;

    puVar4[6] = 0;

    puVar4[7] = 0x3f800000;

    puVar4[8] = 0;

    puVar4[9] = 0;

    puVar4[10] = 0;

    puVar4[0x14] = 0;

    puVar4[0x15] = 0;

    puVar4[0x16] = 0;

    FUN_00535b30();

  }

  *puVar4 = param_2;

  puVar4[4] = param_3;

  puVar4[2] = param_4;

  puVar4[3] = param_5;

  FUN_0051a430(puVar4,param_2);

  FUN_0051b090(puVar4,*param_1 + 0x48,1);

  return;

}





// --- FUN_0051b460 at 0x0051B460 (size: 346) ---


void __thiscall FUN_0051b460(int param_1,int param_2)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  int iVar3;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  iVar3 = *(int *)(param_1 + 4);

  if (iVar3 != 0) {

    if (*(int *)(param_2 + 4) == *(int *)(iVar3 + 4)) {

      *(int *)(iVar3 + 4) = *(int *)(param_2 + 4);

      *(undefined4 *)(*(int *)(param_1 + 4) + 8) = *(undefined4 *)(param_2 + 8);

      iVar3 = *(int *)(param_1 + 4);

      *(undefined4 *)(iVar3 + 0x10) = *(undefined4 *)(param_2 + 0x10);

      *(undefined4 *)(iVar3 + 0x14) = *(undefined4 *)(param_2 + 0x14);

      *(undefined4 *)(*(int *)(param_1 + 4) + 0x1c) = *(undefined4 *)(param_2 + 0x1c);

      FUN_00425f10(param_2 + 0x20);

      *(undefined4 *)(*(int *)(param_1 + 4) + 100) = *(undefined4 *)(param_2 + 100);

      FUN_00425f10(param_2 + 0x68);

      iVar3 = *(int *)(param_1 + 4);

      *(undefined4 *)(iVar3 + 0xb4) = *(undefined4 *)(param_2 + 0xb4);

      *(undefined4 *)(iVar3 + 0xb8) = *(undefined4 *)(param_2 + 0xb8);

      *(undefined4 *)(iVar3 + 0xbc) = *(undefined4 *)(param_2 + 0xbc);

      *(undefined4 *)(*(int *)(param_1 + 4) + 0xc0) = *(undefined4 *)(param_2 + 0xc0);

      uVar1 = DAT_008379ac;

      iVar3 = *(int *)(param_1 + 4);

      *(undefined4 *)(iVar3 + 200) = DAT_008379a8;

      *(undefined4 *)(iVar3 + 0xcc) = uVar1;

      puVar2 = (undefined4 *)FUN_0050aa30(&local_c,*(int *)(param_1 + 4) + 0x60);

      iVar3 = *(int *)(param_1 + 4);

      *(undefined4 *)(iVar3 + 0xa8) = *puVar2;

      *(undefined4 *)(iVar3 + 0xac) = puVar2[1];

      *(undefined4 *)(iVar3 + 0xb0) = puVar2[2];

      iVar3 = FUN_004524a0();

      if (iVar3 != 0) {

        iVar3 = *(int *)(param_1 + 4);

        local_c = 0;

        *(undefined4 *)(iVar3 + 0xa8) = 0;

        local_8 = 0;

        local_4 = 0x3f800000;

        *(undefined4 *)(iVar3 + 0xac) = 0;

        *(undefined4 *)(iVar3 + 0xb0) = 0x3f800000;

      }

      FUN_00511100(*(undefined4 *)(param_1 + 4));

      FUN_005136c0();

      if (*(int *)(param_2 + 0xc0) == 2) {

        FUN_0051b310();

      }

    }

  }

  return;

}





// --- FUN_0051b5c0 at 0x0051B5C0 (size: 200) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0051b5c0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  undefined4 local_8;

  undefined4 local_4;

  

  if (_DAT_007c7c90 <= (double)CONCAT44(DAT_008eee74,DAT_008eee70) - *(double *)(param_1 + 0x10)) {

    iVar1 = *(int *)(param_1 + 4);

    if (((iVar1 != 0) && (*(int *)(iVar1 + 0xc0) == 0)) &&

       (_DAT_007c7c88 + *(double *)(iVar1 + 200) < _DAT_008379a8)) {

      *(undefined4 *)(iVar1 + 0xc0) = 6;

      FUN_00511100(*(undefined4 *)(param_1 + 4));

      FUN_005136c0();

    }

    if (*(int *)(param_1 + 8) != 0) {

      FUN_0051a270(*(int *)(param_1 + 8));

      while (local_4 == 0) {

        if (local_8 == 0) {

          uVar2 = 0;

        }

        else {

          uVar2 = *(undefined4 *)(local_8 + 4);

        }

        FUN_0051af70(0);

        FUN_0051b1f0(uVar2);

      }

    }

    uVar2 = DAT_008eee74;

    *(undefined4 *)(param_1 + 0x10) = DAT_008eee70;

    *(undefined4 *)(param_1 + 0x14) = uVar2;

  }

  return;

}





// --- FUN_0051b690 at 0x0051B690 (size: 99) ---


void __fastcall FUN_0051b690(int *param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  undefined4 *puVar3;

  undefined4 *puVar4;

  

  puVar4 = (undefined4 *)*param_1;

  if (puVar4 < puVar4 + param_1[1]) {

    do {

      puVar3 = (undefined4 *)*puVar4;

      while (puVar3 != (undefined4 *)0x0) {

        pvVar1 = (void *)puVar3[1];

        puVar2 = (undefined4 *)*puVar3;

        if (pvVar1 != (void *)0x0) {

          *(undefined ***)((int)pvVar1 + 0x14) = &PTR_FUN_0079385c;

          operator_delete(pvVar1);

        }

        operator_delete(puVar3);

        puVar3 = puVar2;

      }

      *puVar4 = 0;

      puVar4 = puVar4 + 1;

    } while (puVar4 < (undefined4 *)(*param_1 + param_1[1] * 4));

  }

  return;

}





// --- FUN_0051b700 at 0x0051B700 (size: 88) ---


void __fastcall FUN_0051b700(int param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  

  pvVar1 = *(void **)(param_1 + 4);

  if (pvVar1 != (void *)0x0) {

    *(undefined ***)((int)pvVar1 + 0x60) = &PTR_FUN_0079385c;

    *(undefined ***)((int)pvVar1 + 0x18) = &PTR_FUN_0079385c;

    operator_delete(pvVar1);

    *(undefined4 *)(param_1 + 4) = 0;

  }

  if (*(int *)(param_1 + 8) != 0) {

    FUN_0051b690();

    puVar2 = *(undefined4 **)(param_1 + 8);

    if (puVar2 != (undefined4 *)0x0) {

      FUN_0051a370();

      operator_delete__((void *)*puVar2);

      *puVar2 = 0;

      operator_delete(puVar2);

    }

  }

  return;

}





// --- FUN_0051b760 at 0x0051B760 (size: 349) ---


void __thiscall

FUN_0051b760(int *param_1,undefined4 param_2,int param_3,undefined4 param_4,undefined4 param_5,

            undefined4 param_6)



{

  void *pvVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 local_d0;

  undefined4 local_cc;

  undefined4 local_10;

  

  if (param_1[1] != 0) {

    iVar3 = FUN_0050ff60(*(undefined4 *)(param_1[1] + 4));

    if (iVar3 != 0) {

      FUN_0050f920(*(undefined4 *)(*param_1 + 8));

    }

    pvVar1 = (void *)param_1[1];

    if (pvVar1 != (void *)0x0) {

      *(undefined ***)((int)pvVar1 + 0x60) = &PTR_FUN_0079385c;

      *(undefined ***)((int)pvVar1 + 0x18) = &PTR_FUN_0079385c;

      operator_delete(pvVar1);

    }

    param_1[1] = 0;

  }

  if (param_3 == 0) {

    FUN_0051afc0();

    local_d0 = param_2;

    local_cc = 0;

    local_10 = 6;

    FUN_00511100(&local_d0);

    FUN_005136c0();

  }

  else {

    iVar3 = FUN_005df0f5(0xd0);

    if (iVar3 == 0) {

      puVar4 = (undefined4 *)0x0;

    }

    else {

      puVar4 = (undefined4 *)FUN_0051afc0();

    }

    param_1[1] = (int)puVar4;

    *puVar4 = param_2;

    *(int *)(param_1[1] + 4) = param_3;

    *(undefined4 *)(param_1[1] + 8) = param_4;

    iVar3 = param_1[1];

    *(undefined4 *)(iVar3 + 0x10) = param_5;

    *(undefined4 *)(iVar3 + 0x14) = param_6;

    uVar2 = DAT_008379ac;

    iVar3 = param_1[1];

    *(undefined4 *)(iVar3 + 200) = DAT_008379a8;

    *(undefined4 *)(iVar3 + 0xcc) = uVar2;

    iVar3 = FUN_0050ff60(*(undefined4 *)(param_1[1] + 4));

    if (iVar3 != 0) {

      FUN_0050f8d0(*(undefined4 *)(*param_1 + 8),*(undefined4 *)(param_1[1] + 8),

                   (float)*(double *)(param_1[1] + 0x10));

      return;

    }

  }

  return;

}





// --- FUN_0051b8c0 at 0x0051B8C0 (size: 50) ---


undefined4 __thiscall FUN_0051b8c0(int param_1,undefined4 param_2)



{

  void *pvVar1;

  

  if (*(int *)(param_1 + 8) != 0) {

    pvVar1 = (void *)FUN_0051ad60(param_2);

    if (pvVar1 != (void *)0x0) {

      *(undefined ***)((int)pvVar1 + 0x14) = &PTR_FUN_0079385c;

      operator_delete(pvVar1);

      return 1;

    }

  }

  return 0;

}





// --- FUN_0051b900 at 0x0051B900 (size: 95) ---


void __thiscall FUN_0051b900(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  ushort uVar3;

  

  if ((ushort)param_2 <= *(ushort *)(param_1 + 1)) {

    FUN_0051b9c0(param_2);

    return;

  }

  iVar1 = thunk_FUN_005df0f5((param_2 & 0xffff) << 2);

  uVar3 = 0;

  if ((short)param_1[1] != 0) {

    do {

      uVar2 = (uint)uVar3;

      uVar3 = uVar3 + 1;

      *(undefined4 *)(uVar2 * 4 + iVar1) = *(undefined4 *)(uVar2 * 4 + *param_1);

    } while (uVar3 < *(ushort *)(param_1 + 1));

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  *(ushort *)(param_1 + 1) = (ushort)param_2;

  return;

}





// --- FUN_0051b960 at 0x0051B960 (size: 95) ---


void __thiscall FUN_0051b960(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  ushort uVar3;

  

  if ((ushort)param_2 <= *(ushort *)(param_1 + 1)) {

    FUN_0051ba40(param_2);

    return;

  }

  iVar1 = thunk_FUN_005df0f5((param_2 & 0xffff) << 2);

  uVar3 = 0;

  if ((short)param_1[1] != 0) {

    do {

      uVar2 = (uint)uVar3;

      uVar3 = uVar3 + 1;

      *(undefined4 *)(uVar2 * 4 + iVar1) = *(undefined4 *)(uVar2 * 4 + *param_1);

    } while (uVar3 < *(ushort *)(param_1 + 1));

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  *(ushort *)(param_1 + 1) = (ushort)param_2;

  return;

}





// --- FUN_0051b9c0 at 0x0051B9C0 (size: 125) ---


void __thiscall FUN_0051b9c0(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  ushort uVar3;

  ushort uVar4;

  

  uVar4 = (ushort)param_2;

  if (*(ushort *)(param_1 + 1) < uVar4) {

    FUN_0051b900(param_2);

    return;

  }

  if (uVar4 == 0) {

    operator_delete__((void *)*param_1);

    *(undefined2 *)(param_1 + 1) = 0;

    *param_1 = 0;

    return;

  }

  iVar1 = thunk_FUN_005df0f5((param_2 & 0xffff) << 2);

  uVar3 = 0;

  *(ushort *)(param_1 + 1) = uVar4;

  if (uVar4 != 0) {

    do {

      uVar2 = (uint)uVar3;

      uVar3 = uVar3 + 1;

      *(undefined4 *)(uVar2 * 4 + iVar1) = *(undefined4 *)(uVar2 * 4 + *param_1);

    } while (uVar3 < *(ushort *)(param_1 + 1));

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  return;

}





// --- FUN_0051ba40 at 0x0051BA40 (size: 125) ---


void __thiscall FUN_0051ba40(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  ushort uVar3;

  ushort uVar4;

  

  uVar4 = (ushort)param_2;

  if (*(ushort *)(param_1 + 1) < uVar4) {

    FUN_0051b960(param_2);

    return;

  }

  if (uVar4 == 0) {

    operator_delete__((void *)*param_1);

    *(undefined2 *)(param_1 + 1) = 0;

    *param_1 = 0;

    return;

  }

  iVar1 = thunk_FUN_005df0f5((param_2 & 0xffff) << 2);

  uVar3 = 0;

  *(ushort *)(param_1 + 1) = uVar4;

  if (uVar4 != 0) {

    do {

      uVar2 = (uint)uVar3;

      uVar3 = uVar3 + 1;

      *(undefined4 *)(uVar2 * 4 + iVar1) = *(undefined4 *)(uVar2 * 4 + *param_1);

    } while (uVar3 < *(ushort *)(param_1 + 1));

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  return;

}





// --- FUN_0051bac0 at 0x0051BAC0 (size: 231) ---


void __thiscall FUN_0051bac0(ushort *param_1,int param_2)



{

  ushort uVar1;

  undefined4 *puVar2;

  ushort uVar3;

  uint uVar4;

  undefined4 *puVar5;

  uint uVar6;

  

  uVar1 = 0;

  if (*param_1 != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 2) + (uint)uVar1 * 4) == param_2) break;

      uVar1 = uVar1 + 1;

    } while (uVar1 < *param_1);

  }

  uVar3 = *param_1 - 1;

  *param_1 = uVar3;

  if (uVar1 < uVar3) {

    do {

      uVar3 = uVar1 + 1;

      uVar6 = (uint)uVar3;

      uVar4 = (uint)uVar1;

      *(undefined4 *)(*(int *)(param_1 + 2) + uVar4 * 4) =

           *(undefined4 *)(*(int *)(param_1 + 2) + uVar6 * 4);

      puVar2 = (undefined4 *)(uVar6 * 0x40 + *(int *)(param_1 + 6));

      puVar5 = (undefined4 *)(uVar4 * 0x40 + *(int *)(param_1 + 6));

      puVar5[0xd] = puVar2[0xd];

      puVar5[0xe] = puVar2[0xe];

      puVar5[0xf] = puVar2[0xf];

      *puVar5 = *puVar2;

      puVar5[1] = puVar2[1];

      puVar5[2] = puVar2[2];

      puVar5[3] = puVar2[3];

      puVar5[4] = puVar2[4];

      puVar5[5] = puVar2[5];

      puVar5[6] = puVar2[6];

      puVar5[7] = puVar2[7];

      puVar5[8] = puVar2[8];

      puVar5[9] = puVar2[9];

      puVar5[10] = puVar2[10];

      puVar5[0xb] = puVar2[0xb];

      puVar5[0xc] = puVar2[0xc];

      *(undefined4 *)(*(int *)(param_1 + 10) + uVar4 * 4) =

           *(undefined4 *)(*(int *)(param_1 + 10) + uVar6 * 4);

      *(undefined4 *)(*(int *)(param_1 + 0xe) + uVar4 * 4) =

           *(undefined4 *)(*(int *)(param_1 + 0xe) + uVar6 * 4);

      uVar1 = uVar3;

    } while (uVar3 < *param_1);

  }

  return;

}





// --- FUN_0051bbb0 at 0x0051BBB0 (size: 57) ---


undefined4 __thiscall FUN_0051bbb0(ushort *param_1,int param_2,ushort *param_3)



{

  ushort uVar1;

  

  uVar1 = 0;

  if (*param_1 != 0) {

    do {

      if (*(int *)(*(int *)(param_1 + 2) + (uint)uVar1 * 4) == param_2) {

        *param_3 = uVar1;

        return 1;

      }

      uVar1 = uVar1 + 1;

    } while (uVar1 < *param_1);

  }

  return 0;

}





// --- FUN_0051bbf0 at 0x0051BBF0 (size: 139) ---


void __thiscall FUN_0051bbf0(int *param_1,uint param_2)



{

  uint *puVar1;

  uint *puVar2;

  ushort uVar3;

  uint uVar4;

  

  if ((ushort)param_2 <= *(ushort *)(param_1 + 1)) {

    FUN_0051bc80(param_2);

    return;

  }

  uVar4 = param_2 & 0xffff;

  puVar1 = (uint *)thunk_FUN_005df0f5(uVar4 * 0x40 + 4);

  if (puVar1 == (uint *)0x0) {

    puVar2 = (uint *)0x0;

  }

  else {

    puVar2 = puVar1 + 1;

    *puVar1 = uVar4;

    FUN_00401000(puVar2,0x40,uVar4,FUN_00424ce0);

  }

  uVar3 = 0;

  if ((short)param_1[1] != 0) {

    do {

      FUN_00425f10(*param_1 + (uint)uVar3 * 0x40);

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(ushort *)(param_1 + 1));

  }

  if (*param_1 != 0) {

    operator_delete__((void *)(*param_1 + -4));

  }

  *param_1 = (int)puVar2;

  *(ushort *)(param_1 + 1) = (ushort)param_2;

  return;

}





// --- FUN_0051bc80 at 0x0051BC80 (size: 171) ---


void __thiscall FUN_0051bc80(int *param_1,uint param_2)



{

  uint *puVar1;

  ushort uVar2;

  uint *puVar3;

  ushort uVar4;

  

  uVar2 = (ushort)param_2;

  if (*(ushort *)(param_1 + 1) < uVar2) {

    FUN_0051bbf0(param_2);

    return;

  }

  puVar3 = (uint *)0x0;

  if (uVar2 == 0) {

    if (*param_1 != 0) {

      operator_delete__((void *)(*param_1 + -4));

    }

    *(undefined2 *)(param_1 + 1) = 0;

    *param_1 = 0;

    return;

  }

  param_2 = param_2 & 0xffff;

  puVar1 = (uint *)thunk_FUN_005df0f5(param_2 * 0x40 + 4);

  if (puVar1 != (uint *)0x0) {

    puVar3 = puVar1 + 1;

    *puVar1 = param_2;

    FUN_00401000(puVar3,0x40,param_2,FUN_00424ce0);

  }

  uVar4 = 0;

  *(ushort *)(param_1 + 1) = uVar2;

  if (uVar2 != 0) {

    do {

      FUN_00425f10(*param_1 + (uint)uVar4 * 0x40);

      uVar4 = uVar4 + 1;

    } while (uVar4 < *(ushort *)(param_1 + 1));

  }

  if (*param_1 != 0) {

    operator_delete__((void *)(*param_1 + -4));

  }

  *param_1 = (int)puVar3;

  return;

}





// --- FUN_0051bd30 at 0x0051BD30 (size: 36) ---


void __fastcall FUN_0051bd30(undefined2 *param_1)



{

  *param_1 = 0;

  *(undefined4 *)(param_1 + 2) = 0;

  param_1[4] = 0;

  *(undefined4 *)(param_1 + 6) = 0;

  param_1[8] = 0;

  *(undefined4 *)(param_1 + 10) = 0;

  param_1[0xc] = 0;

  *(undefined4 *)(param_1 + 0xe) = 0;

  param_1[0x10] = 0;

  return;

}





// --- FUN_0051bd60 at 0x0051BD60 (size: 57) ---


void __fastcall FUN_0051bd60(int param_1)



{

  operator_delete__(*(void **)(param_1 + 0x1c));

  operator_delete__(*(void **)(param_1 + 0x14));

  if (*(int *)(param_1 + 0xc) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0xc) + -4));

  }

  operator_delete__(*(void **)(param_1 + 4));

  return;

}





// --- FUN_0051bda0 at 0x0051BDA0 (size: 122) ---


void __thiscall

FUN_0051bda0(ushort *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5)



{

  int iVar1;

  

  if (param_1[4] <= *param_1) {

    iVar1 = param_1[4] + 4;

    FUN_0051b900(iVar1);

    FUN_0051bbf0(iVar1);

    FUN_0051b960(iVar1);

    FUN_0051b960(iVar1);

  }

  *(undefined4 *)(*(int *)(param_1 + 2) + (uint)*param_1 * 4) = param_2;

  FUN_00425f10(param_3);

  *(undefined4 *)(*(int *)(param_1 + 10) + (uint)*param_1 * 4) = param_4;

  *(undefined4 *)(*(int *)(param_1 + 0xe) + (uint)*param_1 * 4) = param_5;

  *param_1 = *param_1 + 1;

  return;

}





// --- FUN_0051be20 at 0x0051BE20 (size: 32) ---


void __thiscall FUN_0051be20(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = param_2;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0xffffffff;

  param_1[4] = 0;

  param_1[5] = 0;

  return;

}





// --- FUN_0051be40 at 0x0051BE40 (size: 138) ---


undefined4 __thiscall FUN_0051be40(int param_1,undefined4 param_2)



{

  double *pdVar1;

  undefined4 uVar2;

  double *pdVar3;

  

  pdVar3 = (double *)FUN_005df0f5(0x10);

  if (pdVar3 == (double *)0x0) {

    pdVar3 = (double *)0x0;

  }

  else {

    *(undefined4 *)pdVar3 = 0;

    *(undefined4 *)((int)pdVar3 + 4) = 0;

    *(undefined4 *)(pdVar3 + 1) = 0;

    *(undefined4 *)((int)pdVar3 + 0xc) = 0;

  }

  uVar2 = DAT_008379ac;

  pdVar1 = *(double **)(param_1 + 8);

  if (pdVar1 == (double *)0x0) {

    *(undefined4 *)pdVar3 = DAT_008379a8;

    *(undefined4 *)((int)pdVar3 + 4) = uVar2;

  }

  else {

    *pdVar3 = *(double *)(*(int *)(pdVar1 + 1) + 0x48) + *pdVar1;

  }

  *(undefined4 *)(pdVar3 + 1) = param_2;

  if (*(int *)(param_1 + 8) != 0) {

    *(double **)(*(int *)(param_1 + 8) + 0xc) = pdVar3;

    *(double **)(param_1 + 8) = pdVar3;

    return 1;

  }

  *(double **)(param_1 + 4) = pdVar3;

  *(double **)(param_1 + 8) = pdVar3;

  *(undefined4 *)(param_1 + 0xc) = 0xffffffff;

  *(double *)(param_1 + 0x10) = *(double *)**(undefined4 **)(*(int *)(pdVar3 + 1) + 0x38) + *pdVar3;

  return 1;

}





// --- FUN_0051bed0 at 0x0051BED0 (size: 65) ---


undefined4 FUN_0051bed0(undefined4 param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  uVar1 = FUN_004220b0(param_1,0x2b);

  iVar2 = FUN_00415430(uVar1);

  if ((iVar2 != 0) && (iVar2 = FUN_0051be40(iVar2), iVar2 != 0)) {

    return 1;

  }

  return 0;

}





// --- FUN_0051bf20 at 0x0051BF20 (size: 133) ---


undefined4 __fastcall FUN_0051bf20(int param_1)



{

  int iVar1;

  double *pdVar2;

  int iVar3;

  double *pdVar4;

  int iVar5;

  

  iVar1 = *(int *)(param_1 + 0xc);

  iVar5 = iVar1 + 1;

  *(int *)(param_1 + 0xc) = iVar5;

  pdVar2 = *(double **)(param_1 + 4);

  iVar3 = *(int *)(*(int *)(pdVar2 + 1) + 0x44);

  if (iVar3 <= iVar5) {

    return 0;

  }

  if (iVar1 + 2 < iVar3) {

    *(double *)(param_1 + 0x10) =

         **(double **)(*(int *)(*(int *)(pdVar2 + 1) + 0x38) + 4 + iVar5 * 4) + *pdVar2;

    return *(undefined4 *)(*(int *)(*(int *)(*(int *)(pdVar2 + 1) + 0x38) + iVar5 * 4) + 8);

  }

  pdVar4 = *(double **)((int)pdVar2 + 0xc);

  if (pdVar4 != (double *)0x0) {

    *(double *)(param_1 + 0x10) =

         *(double *)**(undefined4 **)(*(int *)(pdVar4 + 1) + 0x38) + *pdVar4;

    return *(undefined4 *)(*(int *)(*(int *)(*(int *)(pdVar2 + 1) + 0x38) + iVar5 * 4) + 8);

  }

  *(undefined4 *)(param_1 + 0x10) = 0;

  *(undefined4 *)(param_1 + 0x14) = 0xbff00000;

  return *(undefined4 *)(*(int *)(*(int *)(*(int *)(pdVar2 + 1) + 0x38) + iVar5 * 4) + 8);

}





// --- FUN_0051bfb0 at 0x0051BFB0 (size: 141) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0051bfb0(undefined4 *param_1)



{

  int iVar1;

  void *pvVar2;

  double *pdVar3;

  int *piVar4;

  

  iVar1 = param_1[1];

  while ((iVar1 != 0 && (*(double *)(param_1 + 4) <= _DAT_008379a8))) {

    piVar4 = (int *)FUN_0051bf20();

    if (piVar4 == (int *)0x0) {

      pvVar2 = (void *)param_1[1];

      pdVar3 = *(double **)((int)pvVar2 + 0xc);

      param_1[1] = pdVar3;

      param_1[3] = 0xffffffff;

      if (pdVar3 == (double *)0x0) {

        param_1[4] = 0;

        param_1[5] = 0xbff00000;

        param_1[2] = 0;

      }

      else {

        *(double *)(param_1 + 4) =

             *(double *)**(undefined4 **)(*(int *)(pdVar3 + 1) + 0x38) + *pdVar3;

      }

      if (pvVar2 != (void *)0x0) {

        if (*(int **)((int)pvVar2 + 8) != (int *)0x0) {

          (**(code **)(**(int **)((int)pvVar2 + 8) + 0x14))();

        }

        operator_delete(pvVar2);

      }

    }

    else {

      (**(code **)(*piVar4 + 4))(*param_1);

    }

    iVar1 = param_1[1];

  }

  return;

}





// --- FUN_0051c040 at 0x0051C040 (size: 102) ---


void __fastcall FUN_0051c040(int param_1)



{

  int iVar1;

  void *pvVar2;

  double *pdVar3;

  

  iVar1 = *(int *)(param_1 + 4);

  while (iVar1 != 0) {

    pvVar2 = *(void **)(param_1 + 4);

    pdVar3 = *(double **)((int)pvVar2 + 0xc);

    *(double **)(param_1 + 4) = pdVar3;

    *(undefined4 *)(param_1 + 0xc) = 0xffffffff;

    if (pdVar3 == (double *)0x0) {

      *(undefined4 *)(param_1 + 0x10) = 0;

      *(undefined4 *)(param_1 + 0x14) = 0xbff00000;

      *(undefined4 *)(param_1 + 8) = 0;

    }

    else {

      *(double *)(param_1 + 0x10) =

           *(double *)**(undefined4 **)(*(int *)(pdVar3 + 1) + 0x38) + *pdVar3;

    }

    if (pvVar2 != (void *)0x0) {

      if (*(int **)((int)pvVar2 + 8) != (int *)0x0) {

        (**(code **)(**(int **)((int)pvVar2 + 8) + 0x14))();

      }

      operator_delete(pvVar2);

    }

    iVar1 = *(int *)(param_1 + 4);

  }

  return;

}





// --- FUN_0051c0b0 at 0x0051C0B0 (size: 74) ---


int __fastcall FUN_0051c0b0(int param_1)



{

  int iVar1;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  iVar1 = 0;

  FUN_0051a270(param_1 + 4);

  if (local_4 != 0) {

    return 0;

  }

  do {

    iVar1 = iVar1 + 1;

    local_8 = (undefined4 *)*local_8;

    while (local_8 == (undefined4 *)0x0) {

      local_c = local_c + 1;

      if (local_10[1] <= local_c) {

        return iVar1;

      }

      local_8 = *(undefined4 **)(*local_10 + local_c * 4);

    }

  } while( true );

}





// --- FUN_0051c100 at 0x0051C100 (size: 66) ---


undefined4 * __fastcall FUN_0051c100(undefined4 *param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  

  *param_1 = 0xffff0000;

  param_1[1] = 0;

  param_1[2] = 2;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(8);

  param_1[1] = puVar1;

  for (uVar2 = param_1[2] & 0x3fffffff; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar1 = 0;

    puVar1 = puVar1 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar1 = 0;

    puVar1 = (undefined4 *)((int)puVar1 + 1);

  }

  return param_1;

}





// --- FUN_0051c150 at 0x0051C150 (size: 156) ---


void __fastcall FUN_0051c150(int param_1)



{

  undefined4 *puVar1;

  void *pvVar2;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  puVar1 = (undefined4 *)(param_1 + 4);

  FUN_0051a270(puVar1);

  do {

    if (local_4 != 0) {

      FUN_0051a370();

      operator_delete__((void *)*puVar1);

      *puVar1 = 0;

      return;

    }

    if (local_8 == (undefined4 *)0x0) {

      pvVar2 = (void *)0x0;

    }

    else {

      pvVar2 = (void *)local_8[1];

    }

    local_8 = (undefined4 *)*local_8;

    while (local_8 == (undefined4 *)0x0) {

      local_c = local_c + 1;

      if (local_10[1] <= local_c) {

        local_4 = 1;

        break;

      }

      local_8 = *(undefined4 **)(*local_10 + local_c * 4);

    }

    if (pvVar2 != (void *)0x0) {

      thunk_FUN_0051d8e0();

      operator_delete(pvVar2);

    }

  } while( true );

}





// --- FUN_0051c1f0 at 0x0051C1F0 (size: 166) ---


int __thiscall

FUN_0051c1f0(int *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,int param_6)



{

  void *pvVar1;

  int *piVar2;

  int iVar3;

  

  if (param_6 != 0) {

    pvVar1 = (void *)FUN_0051ad60(param_6);

    if (pvVar1 != (void *)0x0) {

      thunk_FUN_0051d8e0();

      operator_delete(pvVar1);

    }

  }

  piVar2 = (int *)FUN_0051d8b0(param_2);

  if (piVar2 != (int *)0x0) {

    iVar3 = FUN_0051def0(param_3);

    if (iVar3 != 0) {

      iVar3 = FUN_0051ccc0(param_4,param_5);

      if (iVar3 != 0) {

        iVar3 = FUN_0051df30();

        if (iVar3 != 0) {

          if (param_6 == 0) {

            param_6 = *param_1;

            *param_1 = param_6 + 1;

          }

          *piVar2 = param_6;

          FUN_0051a430(piVar2,param_6);

          return param_6;

        }

      }

    }

    thunk_FUN_0051d8e0();

    operator_delete(piVar2);

  }

  return 0;

}





// --- FUN_0051c2a0 at 0x0051C2A0 (size: 58) ---


undefined4 FUN_0051c2a0(int param_1)



{

  void *pvVar1;

  

  if (param_1 == 0) {

    return 0;

  }

  pvVar1 = (void *)FUN_0051ad60(param_1);

  if (pvVar1 != (void *)0x0) {

    thunk_FUN_0051d8e0();

    operator_delete(pvVar1);

    return 1;

  }

  return 0;

}





// --- FUN_0051c2e0 at 0x0051C2E0 (size: 75) ---


undefined4 __thiscall FUN_0051c2e0(int param_1,uint param_2)



{

  int *piVar1;

  uint uVar2;

  

  if ((param_2 != 0) &&

     (piVar1 = *(int **)(*(int *)(param_1 + 4) +

                        ((param_2 >> 0x10 ^ param_2) % *(uint *)(param_1 + 8)) * 4),

     piVar1 != (int *)0x0)) {

    uVar2 = piVar1[2];

    while (uVar2 != param_2) {

      piVar1 = (int *)*piVar1;

      if (piVar1 == (int *)0x0) {

        return 0;

      }

      uVar2 = piVar1[2];

    }

    if (piVar1[1] != 0) {

      *(undefined4 *)(piVar1[1] + 0x8c) = 1;

      return 1;

    }

  }

  return 0;

}





// --- FUN_0051c330 at 0x0051C330 (size: 152) ---


void __fastcall FUN_0051c330(int param_1)



{

  int iVar1;

  undefined4 *puVar2;

  int *local_10;

  int local_c;

  undefined4 *local_8;

  int local_4;

  

  FUN_0051a270(param_1 + 4);

  do {

    if (local_4 != 0) {

      return;

    }

    if (local_8 == (undefined4 *)0x0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      puVar2 = (undefined4 *)local_8[1];

    }

    local_8 = (undefined4 *)*local_8;

    while (local_8 == (undefined4 *)0x0) {

      local_c = local_c + 1;

      if (local_10[1] <= local_c) {

        local_4 = 1;

        break;

      }

      local_8 = *(undefined4 **)(*local_10 + local_c * 4);

    }

    iVar1 = FUN_0051dcb0();

    if (iVar1 == 0) {

      FUN_0051ad60(*puVar2);

      thunk_FUN_0051d8e0();

      operator_delete(puVar2);

    }

  } while( true );

}





// --- FUN_0051c3d0 at 0x0051C3D0 (size: 90) ---


undefined4 __thiscall

FUN_0051c3d0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            ,uint param_6)



{

  int *piVar1;

  uint uVar2;

  undefined4 uVar3;

  

  if ((param_6 != 0) &&

     (piVar1 = *(int **)(*(int *)(param_1 + 4) +

                        ((param_6 >> 0x10 ^ param_6) % *(uint *)(param_1 + 8)) * 4),

     piVar1 != (int *)0x0)) {

    uVar2 = piVar1[2];

    while (uVar2 != param_6) {

      piVar1 = (int *)*piVar1;

      if (piVar1 == (int *)0x0) goto LAB_0051c40c;

      uVar2 = piVar1[2];

    }

    if (piVar1[1] != 0) {

      return 0;

    }

  }

LAB_0051c40c:

  uVar3 = FUN_0051c1f0(param_2,param_3,param_4,param_5,param_6);

  return uVar3;

}





// --- FUN_0051c430 at 0x0051C430 (size: 17) ---


void __fastcall FUN_0051c430(undefined4 *param_1)



{

  *param_1 = 0xffffffff;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_0051c450 at 0x0051C450 (size: 29) ---


void __thiscall FUN_0051c450(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0xc) = *(uint *)(param_1 + 0xc) | 1;

    return;

  }

  *(uint *)(param_1 + 0xc) = *(uint *)(param_1 + 0xc) & 0xfffffffe;

  return;

}





// --- FUN_0051c470 at 0x0051C470 (size: 29) ---


void __thiscall FUN_0051c470(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 1;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xfffffffe;

  return;

}





// --- FUN_0051c490 at 0x0051C490 (size: 29) ---


void __thiscall FUN_0051c490(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 2;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xfffffffd;

  return;

}





// --- FUN_0051c4b0 at 0x0051C4B0 (size: 29) ---


void __thiscall FUN_0051c4b0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 0x40;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xffffffbf;

  return;

}





// --- FUN_0051c4d0 at 0x0051C4D0 (size: 29) ---


void __thiscall FUN_0051c4d0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 4;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xfffffffb;

  return;

}





// --- FUN_0051c4f0 at 0x0051C4F0 (size: 29) ---


void __thiscall FUN_0051c4f0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 8;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xfffffff7;

  return;

}





// --- FUN_0051c510 at 0x0051C510 (size: 29) ---


void __thiscall FUN_0051c510(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 0x10;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xffffffef;

  return;

}





// --- FUN_0051c530 at 0x0051C530 (size: 29) ---


void __thiscall FUN_0051c530(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) | 0x20;

    return;

  }

  *(uint *)(param_1 + 0x18) = *(uint *)(param_1 + 0x18) & 0xffffffdf;

  return;

}





// --- FUN_0051c550 at 0x0051C550 (size: 10) ---


void __fastcall FUN_0051c550(int param_1)



{

  *(undefined4 *)(param_1 + 0xc) = 0;

  return;

}





// --- FUN_0051c560 at 0x0051C560 (size: 22) ---


void __fastcall FUN_0051c560(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[4] = DAT_00845120;

  param_1[5] = 0;

  param_1[6] = 0;

  return;

}





// --- FUN_0051c580 at 0x0051C580 (size: 75) ---


void __thiscall

FUN_0051c580(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,

            undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8,

            undefined4 param_9)



{

  param_1[2] = param_2;

  param_1[4] = param_3;

  param_1[5] = param_4;

  param_1[6] = param_5;

  param_1[7] = param_6;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = param_9;

  *param_1 = &PTR_LAB_007c7dd0;

  param_1[0xc] = param_7;

  param_1[0xd] = param_8;

  return;

}





// --- FUN_0051c660 at 0x0051C660 (size: 16) ---


void __thiscall FUN_0051c660(int param_1,int param_2)



{

  *(int *)(param_1 + 0xc) = param_2;

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_2 + 8);

  return;

}





// --- FUN_0051c670 at 0x0051C670 (size: 10) ---


void __thiscall FUN_0051c670(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0x48) = param_2;

  return;

}





// --- FUN_0051c680 at 0x0051C680 (size: 73) ---


undefined4 * __fastcall FUN_0051c680(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_00797910;

  param_1[1] = 0;

  param_1[2] = 0x3f800000;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  FUN_00535b30();

  param_1[0x12] = 0;

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 0;

  return param_1;

}





// --- FUN_0051c6d0 at 0x0051C6D0 (size: 25) ---


void __thiscall FUN_0051c6d0(int param_1,int param_2)



{

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_2 + 4);

  FUN_00425f10();

  return;

}





// --- FUN_0051c6f0 at 0x0051C6F0 (size: 9) ---


void __thiscall FUN_0051c6f0(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = param_2;

  return;

}





// --- FUN_0051c700 at 0x0051C700 (size: 62) ---


bool __thiscall FUN_0051c700(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  int iVar2;

  

  if (*(int **)(param_1 + 4) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 4) + 0x14))();

  }

  uVar1 = FUN_004220b0(param_2,0xe);

  iVar2 = FUN_00415430(uVar1);

  *(int *)(param_1 + 4) = iVar2;

  return iVar2 != 0;

}





// --- FUN_0051c740 at 0x0051C740 (size: 56) ---


void __thiscall FUN_0051c740(int param_1,undefined4 *param_2)



{

  if (*(int *)(param_1 + 4) != 0) {

    *param_2 = *(undefined4 *)(*(int *)(param_1 + 4) + 0x28);

    return;

  }

  *param_2 = DAT_008451f4;

  return;

}





// --- FUN_0051c780 at 0x0051C780 (size: 72) ---


undefined4 * FUN_0051c780(int param_1)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x2c);

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = 0;

    puVar1[1] = 0;

    FUN_00526bd0();

    puVar1[8] = 0;

    puVar1[9] = 0;

    puVar1[10] = 0;

    if (param_1 != DAT_008451f4) {

      FUN_0051c700(param_1);

    }

    return puVar1;

  }

  return (undefined4 *)0x0;

}





// --- FUN_0051c7d0 at 0x0051C7D0 (size: 55) ---


void __thiscall FUN_0051c7d0(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  int iVar3;

  

  if (param_2 != 0) {

    iVar3 = 0;

    for (iVar1 = *(int *)(param_1 + 0x28); iVar1 != param_2; iVar1 = *(int *)(iVar1 + 4)) {

      if (iVar1 == 0) {

        return;

      }

      iVar2 = *(int *)(iVar1 + 0xc);

      *(undefined4 *)(iVar1 + 0xc) = 0;

      iVar3 = iVar3 + iVar2;

    }

    FUN_005257e0(iVar3);

  }

  return;

}





// --- FUN_0051c810 at 0x0051C810 (size: 184) ---


void __thiscall FUN_0051c810(int param_1,undefined4 param_2)



{

  int *piVar1;

  undefined4 *puVar2;

  int iVar3;

  

  iVar3 = *(int *)(param_1 + 0x24);

  if (iVar3 != 0) {

    *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) + 1;

    do {

      if (*(uint *)(param_1 + 0x20) < *(uint *)(iVar3 + 0xc)) break;

      if ((*(uint *)(iVar3 + 8) & 0x10000000) != 0) {

        FUN_00526d20();

      }

      FUN_00510880(*(undefined4 *)(iVar3 + 8),param_2);

      *(int *)(param_1 + 0x20) = *(int *)(param_1 + 0x20) - *(int *)(iVar3 + 0xc);

      piVar1 = *(int **)(param_1 + 0x24);

      if (piVar1 != (int *)0x0) {

        if ((int *)piVar1[1] == (int *)0x0) {

          iVar3 = *piVar1;

          *(int *)(param_1 + 0x24) = iVar3;

          if (iVar3 != 0) {

            *(undefined4 *)(iVar3 + 4) = 0;

          }

        }

        else {

          *(int *)piVar1[1] = *piVar1;

        }

        if (*piVar1 == 0) {

          puVar2 = *(undefined4 **)(*(int *)(param_1 + 0x28) + 4);

          *(undefined4 **)(param_1 + 0x28) = puVar2;

          if (puVar2 != (undefined4 *)0x0) {

            *puVar2 = 0;

          }

        }

        else {

          *(int *)(*piVar1 + 4) = piVar1[1];

        }

        *piVar1 = 0;

        piVar1[1] = 0;

        if (piVar1 != (int *)0x0) {

          operator_delete(piVar1);

        }

      }

      iVar3 = *(int *)(param_1 + 0x24);

    } while (iVar3 != 0);

    if ((*(int *)(param_1 + 0x20) != 0) && (iVar3 == 0)) {

      *(undefined4 *)(param_1 + 0x20) = 0;

    }

  }

  return;

}





// --- FUN_0051c8d0 at 0x0051C8D0 (size: 36) ---


void __fastcall FUN_0051c8d0(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(param_1 + 0x24);

  while (iVar1 != 0) {

    FUN_0051c810(0);

    iVar1 = *(int *)(param_1 + 0x24);

  }

  return;

}





// --- FUN_0051c900 at 0x0051C900 (size: 141) ---


void __fastcall FUN_0051c900(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 *puVar3;

  

  iVar1 = *(int *)(param_1 + 0x24);

  while ((iVar1 != 0 && (*(int *)(iVar1 + 0xc) == 0))) {

    if ((*(uint *)(iVar1 + 8) & 0x10000000) != 0) {

      FUN_00526d20();

    }

    FUN_00510880(*(undefined4 *)(iVar1 + 8),1);

    piVar2 = *(int **)(param_1 + 0x24);

    if (piVar2 != (int *)0x0) {

      if ((int *)piVar2[1] == (int *)0x0) {

        iVar1 = *piVar2;

        *(int *)(param_1 + 0x24) = iVar1;

        if (iVar1 != 0) {

          *(undefined4 *)(iVar1 + 4) = 0;

        }

      }

      else {

        *(int *)piVar2[1] = *piVar2;

      }

      if (*piVar2 == 0) {

        puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x28) + 4);

        *(undefined4 **)(param_1 + 0x28) = puVar3;

        if (puVar3 != (undefined4 *)0x0) {

          *puVar3 = 0;

        }

      }

      else {

        *(int *)(*piVar2 + 4) = piVar2[1];

      }

      *piVar2 = 0;

      piVar2[1] = 0;

      if (piVar2 != (int *)0x0) {

        operator_delete(piVar2);

      }

    }

    iVar1 = *(int *)(param_1 + 0x24);

  }

  return;

}





// --- FUN_0051c990 at 0x0051C990 (size: 105) ---


void __fastcall FUN_0051c990(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 *puVar3;

  

  while (piVar1 = *(int **)(param_1 + 0x24), piVar1 != (int *)0x0) {

    if ((int *)piVar1[1] == (int *)0x0) {

      iVar2 = *piVar1;

      *(int *)(param_1 + 0x24) = iVar2;

      if (iVar2 != 0) {

        *(undefined4 *)(iVar2 + 4) = 0;

      }

    }

    else {

      *(int *)piVar1[1] = *piVar1;

    }

    if (*piVar1 == 0) {

      puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x28) + 4);

      *(undefined4 **)(param_1 + 0x28) = puVar3;

      if (puVar3 != (undefined4 *)0x0) {

        *puVar3 = 0;

      }

    }

    else {

      *(int *)(*piVar1 + 4) = piVar1[1];

    }

    *piVar1 = 0;

    piVar1[1] = 0;

    if (piVar1 == (int *)0x0) break;

    operator_delete(piVar1);

  }

  if (*(int **)(param_1 + 4) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 4) + 0x14))();

    *(undefined4 *)(param_1 + 4) = 0;

  }

  return;

}





// --- FUN_0051ca00 at 0x0051CA00 (size: 17) ---


void FUN_0051ca00(void)



{

  FUN_0051c990();

  thunk_FUN_00526ee0();

  return;

}





// --- FUN_0051ca20 at 0x0051CA20 (size: 163) ---


void __thiscall FUN_0051ca20(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  

  iVar2 = *(int *)(param_1 + 0x28);

  if (iVar2 != 0) {

    while (*(int *)(iVar2 + 0xc) == 0) {

      iVar2 = *(int *)(iVar2 + 4);

      if (iVar2 == 0) {

        return;

      }

    }

    uVar1 = *(uint *)(iVar2 + 8);

    if (((uVar1 & 0x40000000) == 0) || ((uVar1 & 0x20000000) != 0)) {

      if (-1 < (int)uVar1) {

        return;

      }

      iVar2 = *(int *)(iVar2 + 4);

      if (iVar2 == 0) {

        return;

      }

      while (*(uint *)(iVar2 + 8) != uVar1) {

        if ((*(int *)(iVar2 + 0xc) != 0) && ((*(uint *)(iVar2 + 8) & 0x70000000) != 0)) {

          return;

        }

        iVar2 = *(int *)(iVar2 + 4);

        if (iVar2 == 0) {

          return;

        }

      }

    }

    else {

      iVar2 = *(int *)(iVar2 + 4);

      if (iVar2 == 0) {

        return;

      }

      while ((*(uint *)(iVar2 + 8) != uVar1 || (*(int *)(iVar2 + 0xc) == 0))) {

        if ((*(int *)(iVar2 + 0xc) != 0) && ((*(uint *)(iVar2 + 8) & 0xb0000000) != 0)) {

          return;

        }

        iVar2 = *(int *)(iVar2 + 4);

        if (iVar2 == 0) {

          return;

        }

      }

    }

    FUN_0051c7d0(iVar2,param_2);

  }

  return;

}





// --- FUN_0051cad0 at 0x0051CAD0 (size: 39) ---


void __fastcall FUN_0051cad0(int param_1)



{

  int iVar1;

  

  FUN_005258a0();

  iVar1 = *(int *)(param_1 + 0x24);

  while (iVar1 != 0) {

    FUN_0051c810(0);

    iVar1 = *(int *)(param_1 + 0x24);

  }

  return;

}





// --- thunk_FUN_0051c900 at 0x0051CB00 (size: 5) ---


void __fastcall thunk_FUN_0051c900(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 *puVar3;

  

  iVar1 = *(int *)(param_1 + 0x24);

  while ((iVar1 != 0 && (*(int *)(iVar1 + 0xc) == 0))) {

    if ((*(uint *)(iVar1 + 8) & 0x10000000) != 0) {

      FUN_00526d20();

    }

    FUN_00510880(*(undefined4 *)(iVar1 + 8),1);

    piVar2 = *(int **)(param_1 + 0x24);

    if (piVar2 != (int *)0x0) {

      if ((int *)piVar2[1] == (int *)0x0) {

        iVar1 = *piVar2;

        *(int *)(param_1 + 0x24) = iVar1;

        if (iVar1 != 0) {

          *(undefined4 *)(iVar1 + 4) = 0;

        }

      }

      else {

        *(int *)piVar2[1] = *piVar2;

      }

      if (*piVar2 == 0) {

        puVar3 = *(undefined4 **)(*(int *)(param_1 + 0x28) + 4);

        *(undefined4 **)(param_1 + 0x28) = puVar3;

        if (puVar3 != (undefined4 *)0x0) {

          *puVar3 = 0;

        }

      }

      else {

        *(int *)(*piVar2 + 4) = piVar2[1];

      }

      *piVar2 = 0;

      piVar2[1] = 0;

      if (piVar2 != (int *)0x0) {

        operator_delete(piVar2);

      }

    }

    iVar1 = *(int *)(param_1 + 0x24);

  }

  return;

}





// --- FUN_0051cb10 at 0x0051CB10 (size: 77) ---


void __thiscall FUN_0051cb10(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x10);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = param_2;

    puVar1[3] = param_3;

  }

  FUN_00410820(puVar1,*(undefined4 *)(param_1 + 0x28));

  FUN_0051ca20(param_4);

  return;

}





// --- FUN_0051cb60 at 0x0051CB60 (size: 123) ---


void __thiscall FUN_0051cb60(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  undefined4 *puVar2;

  undefined4 local_4;

  

  local_4 = 0;

  if (*(int *)(param_1 + 4) == 0) {

    local_4 = 0;

  }

  else {

    FUN_00523c40(param_1 + 8,param_2,&local_4);

  }

  uVar1 = local_4;

  puVar2 = (undefined4 *)FUN_005df0f5(0x10);

  if (puVar2 == (undefined4 *)0x0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = 0;

    puVar2[1] = 0;

    puVar2[2] = 0x41000003;

    puVar2[3] = uVar1;

  }

  FUN_00410820(puVar2,*(undefined4 *)(param_1 + 0x28));

  FUN_0051ca20(param_2);

  return;

}





// --- FUN_0051cbe0 at 0x0051CBE0 (size: 220) ---


undefined4 __thiscall FUN_0051cbe0(int param_1,int *param_2,undefined4 param_3)



{

  int iVar1;

  undefined4 local_4;

  

  if (*(int *)(param_1 + 4) == 0) {

    return 7;

  }

  iVar1 = *param_2;

  local_4 = 0;

  if (iVar1 != 2) {

    if (iVar1 == 4) {

      iVar1 = thunk_FUN_00523b60(param_2[1],*(undefined4 *)(param_2[0x18] + 0x14),param_1 + 8,

                                 param_3,&local_4);

      if (iVar1 == 0) {

        return 0x43;

      }

    }

    else {

      if (iVar1 != 5) {

        return param_3;

      }

      FUN_00524ad0(param_1 + 8,param_3,&local_4);

    }

    FUN_0051cb10(0x41000003,local_4,param_3);

    return 0;

  }

  iVar1 = FUN_00524a90(param_2[1],param_1 + 8,param_3,*(undefined4 *)(param_2[0x18] + 0x14),&local_4

                      );

  if (iVar1 == 0) {

    return 0x43;

  }

  FUN_0051cb10(param_2[1],local_4,param_3);

  return 0;

}





// --- FUN_0051ccc0 at 0x0051CCC0 (size: 71) ---


undefined4 __thiscall FUN_0051ccc0(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x4c) != 0) {

    iVar1 = FUN_00516650(*(undefined4 *)(param_1 + 4),param_2,param_3);

    if (iVar1 != 0) {

      *(undefined4 *)(param_1 + 8) = param_2;

      FUN_00425f10(param_3);

      return 1;

    }

  }

  return 0;

}





// --- FUN_0051cd10 at 0x0051CD10 (size: 77) ---


undefined4 __thiscall FUN_0051cd10(int param_1,int param_2)



{

  int iVar1;

  

  iVar1 = param_2 * 0x98 + *(int *)(param_1 + 0x54);

  if (*(double *)(iVar1 + 8) <= *(double *)(iVar1 + 0x10)) {

    FUN_00511940(*(undefined4 *)(*(int *)(param_1 + 0x5c) + param_2 * 4));

    *(undefined4 *)(*(int *)(param_1 + 0x5c) + param_2 * 4) = 0;

    *(int *)(param_1 + 0x70) = *(int *)(param_1 + 0x70) + -1;

    return 1;

  }

  return 0;

}





// --- FUN_0051cd60 at 0x0051CD60 (size: 87) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0051cd60(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x8c) == 0) {

    iVar1 = *(int *)(param_1 + 0x50);

    if ((_DAT_00795610 < *(double *)(iVar1 + 0x68)) &&

       (*(double *)(param_1 + 0x68) + *(double *)(iVar1 + 0x68) < _DAT_008eee70)) {

      *(undefined4 *)(param_1 + 0x8c) = 1;

    }

    if ((*(int *)(iVar1 + 0x60) != 0) && (*(int *)(iVar1 + 0x60) <= *(int *)(param_1 + 0x74))) {

      *(undefined4 *)(param_1 + 0x8c) = 1;

    }

  }

  return *(undefined4 *)(param_1 + 0x8c);

}





// --- FUN_0051cdc0 at 0x0051CDC0 (size: 1306) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0051cdc0(double *param_1,undefined4 param_2,int param_3,int param_4,int param_5)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  float fVar6;

  float fVar7;

  float fVar8;

  float fVar9;

  float fVar10;

  float fVar11;

  undefined4 uVar12;

  undefined4 uVar13;

  float fVar14;

  double dVar15;

  undefined4 *puVar16;

  float10 fVar17;

  float10 fVar18;

  float10 fVar19;

  float10 fVar20;

  undefined1 local_60 [4];

  float local_5c;

  float local_58;

  float local_54;

  float local_50;

  float local_4c;

  undefined1 local_48 [52];

  float local_14;

  float local_10;

  float local_c;

  

  dVar15 = (double)CONCAT44(DAT_008eee74,DAT_008eee70) - *param_1;

  if (param_3 == 0) {

    param_1[2] = dVar15;

  }

  else {

    param_1[2] = dVar15 + param_1[2];

    uVar12 = DAT_008eee74;

    *(undefined4 *)param_1 = DAT_008eee70;

    *(undefined4 *)((int)param_1 + 4) = uVar12;

  }

  switch(param_2) {

  case 1:

    puVar16 = (undefined4 *)FUN_0043d8b0(local_60,param_1 + 0xb);

    uVar12 = puVar16[1];

    uVar13 = puVar16[2];

    *(undefined4 *)(param_4 + 0x6c) = *puVar16;

    *(undefined4 *)(param_4 + 0x70) = uVar12;

    *(undefined4 *)(param_4 + 0x74) = uVar13;

    break;

  case 2:

  case 0xc:

    fVar4 = (float)param_1[2];

    fVar1 = *(float *)(param_1 + 0xd);

    fVar2 = *(float *)((int)param_1 + 0x5c);

    fVar3 = *(float *)(param_5 + 0x38);

    local_4c = *(float *)(param_1 + 0xc) + *(float *)(param_5 + 0x3c) +

               fVar4 * *(float *)((int)param_1 + 0x6c);

    *(float *)(param_4 + 0x6c) =

         *(float *)(param_5 + 0x34) + *(float *)(param_1 + 0xb) +

         fVar4 * *(float *)((int)param_1 + 100);

    *(float *)(param_4 + 0x70) = fVar2 + fVar3 + fVar4 * fVar1;

    *(float *)(param_4 + 0x74) = local_4c;

    break;

  case 3:

  case 8:

  case 10:

    fVar2 = *(float *)((int)param_1 + 0x74) * _DAT_007938b8;

    fVar1 = (float)param_1[2];

    local_5c = fVar1 * *(float *)(param_1 + 0xd);

    local_58 = fVar1 * *(float *)((int)param_1 + 0x6c);

    local_50 = *(float *)((int)param_1 + 0x5c) + *(float *)(param_5 + 0x38) + local_5c;

    local_4c = *(float *)(param_1 + 0xc) + *(float *)(param_5 + 0x3c) + local_58 +

               *(float *)(param_1 + 0xf) * _DAT_007938b8 * fVar1 * fVar1;

    *(float *)(param_4 + 0x6c) =

         *(float *)(param_1 + 0xb) + *(float *)(param_5 + 0x34) +

         fVar1 * *(float *)((int)param_1 + 100) +

         *(float *)(param_1 + 0xe) * _DAT_007938b8 * fVar1 * fVar1;

    *(float *)(param_4 + 0x70) = local_50 + fVar2 * fVar1 * fVar1;

    *(float *)(param_4 + 0x74) = local_4c;

    break;

  case 4:

  case 9:

  case 0xb:

    FUN_00425f10(param_5);

    local_58 = (float)param_1[2];

    local_5c = local_58 * *(float *)(param_1 + 0xd) + *(float *)((int)param_1 + 0x5c);

    local_14 = local_14 +

               local_58 * *(float *)((int)param_1 + 100) + *(float *)(param_1 + 0xb) +

               *(float *)(param_1 + 0xe) * _DAT_007938b8 * local_58 * local_58;

    local_10 = local_10 +

               local_5c + *(float *)((int)param_1 + 0x74) * _DAT_007938b8 * local_58 * local_58;

    local_c = local_c + local_58 * *(float *)((int)param_1 + 0x6c) + *(float *)(param_1 + 0xc) +

                        *(float *)(param_1 + 0xf) * _DAT_007938b8 * local_58 * local_58;

    local_54 = local_58 * *(float *)((int)param_1 + 0x7c);

    local_50 = local_58 * *(float *)(param_1 + 0x10);

    local_58 = local_58 * *(float *)((int)param_1 + 0x84);

    local_4c = local_58;

    FUN_004525f0(&local_54);

    FUN_00425f10(local_48);

    break;

  case 5:

    fVar19 = (float10)param_1[2];

    fVar20 = (float10)fcos((float10)*(float *)(param_1 + 0xe) * (float10)param_1[2]);

    fVar17 = (float10)fsin((float10)*(float *)((int)param_1 + 0x74) * (float10)param_1[2]);

    fVar1 = *(float *)(param_1 + 0x10);

    fVar2 = *(float *)(param_1 + 0xd);

    fVar3 = *(float *)((int)param_1 + 0x5c);

    fVar4 = *(float *)(param_5 + 0x38);

    fVar18 = (float10)fcos((float10)*(float *)(param_1 + 0xf) * (float10)param_1[2]);

    fVar5 = *(float *)((int)param_1 + 0x84);

    fVar6 = *(float *)((int)param_1 + 0x6c);

    fVar7 = *(float *)(param_1 + 0xc);

    fVar8 = *(float *)(param_5 + 0x3c);

    *(float *)(param_4 + 0x6c) =

         (float)(fVar19 * (float10)*(float *)((int)param_1 + 100) +

                 fVar20 * (float10)*(float *)((int)param_1 + 0x7c) +

                 (float10)*(float *)(param_1 + 0xb) + (float10)*(float *)(param_5 + 0x34));

    *(float *)(param_4 + 0x70) =

         (float)(fVar19 * (float10)fVar2 + fVar17 * (float10)fVar1 + (float10)fVar3 + (float10)fVar4

                );

    *(float *)(param_4 + 0x74) =

         (float)(fVar19 * (float10)fVar6 + fVar18 * (float10)fVar5 + (float10)fVar7 + (float10)fVar8

                );

    break;

  case 6:

    fVar14 = (float)param_1[2];

    fVar1 = *(float *)((int)param_1 + 0x74);

    fVar2 = *(float *)(param_1 + 0x10);

    fVar3 = *(float *)((int)param_1 + 100);

    fVar4 = *(float *)((int)param_1 + 0x5c);

    fVar5 = *(float *)(param_5 + 0x38);

    fVar6 = *(float *)(param_1 + 0xf);

    fVar7 = *(float *)((int)param_1 + 0x84);

    fVar8 = *(float *)((int)param_1 + 100);

    fVar9 = *(float *)((int)param_1 + 0x6c);

    fVar10 = *(float *)(param_1 + 0xc);

    fVar11 = *(float *)(param_5 + 0x3c);

    *(float *)(param_4 + 0x6c) =

         (*(float *)((int)param_1 + 0x7c) * *(float *)((int)param_1 + 100) +

         fVar14 * *(float *)(param_1 + 0xe)) * fVar14 + *(float *)(param_1 + 0xb) +

         *(float *)(param_5 + 0x34);

    *(float *)(param_4 + 0x70) = (fVar2 * fVar3 + fVar14 * fVar1) * fVar14 + fVar4 + fVar5;

    *(float *)(param_4 + 0x74) = (fVar7 * fVar8 + fVar14 * fVar6 + fVar9) * fVar14 + fVar10 + fVar11

    ;

    break;

  case 7:

    fVar19 = (float10)fcos((float10)*(float *)((int)param_1 + 100) * (float10)param_1[2]);

    fVar20 = (float10)param_1[2] * (float10)param_1[2];

    fVar1 = *(float *)(param_1 + 0x10);

    fVar2 = *(float *)((int)param_1 + 0x74);

    fVar3 = *(float *)((int)param_1 + 0x5c);

    fVar4 = *(float *)(param_5 + 0x38);

    fVar5 = *(float *)((int)param_1 + 0x84);

    fVar6 = *(float *)(param_1 + 0xf);

    fVar7 = *(float *)(param_1 + 0xc);

    fVar8 = *(float *)(param_5 + 0x3c);

    *(float *)(param_4 + 0x6c) =

         (float)(fVar20 * (float10)*(float *)(param_1 + 0xe) +

                 fVar19 * (float10)*(float *)((int)param_1 + 0x7c) +

                 (float10)*(float *)(param_1 + 0xb) + (float10)*(float *)(param_5 + 0x34));

    *(float *)(param_4 + 0x70) =

         (float)(fVar20 * (float10)fVar2 + fVar19 * (float10)fVar1 + (float10)fVar3 + (float10)fVar4

                );

    *(float *)(param_4 + 0x74) =

         (float)(fVar20 * (float10)fVar6 + fVar19 * (float10)fVar5 + (float10)fVar7 + (float10)fVar8

                );

  }

  if (param_1[2] < param_1[1]) {

    fVar19 = (float10)param_1[2] / (float10)param_1[1];

  }

  else {

    fVar19 = (float10)_DAT_007938b0;

  }

  fVar20 = ((float10)*(float *)((int)param_1 + 0x8c) - (float10)*(float *)(param_1 + 0x11)) * fVar19

           + (float10)*(float *)(param_1 + 0x11);

  *(float *)(param_4 + 0x24) = (float)fVar20;

  *(float *)(param_4 + 0x28) = (float)fVar20;

  *(float *)(param_4 + 0x2c) = (float)fVar20;

  FUN_0050f140((float)(((float10)*(float *)((int)param_1 + 0x94) -

                       (float10)*(float *)(param_1 + 0x12)) * fVar19 +

                      (float10)*(float *)(param_1 + 0x12)));

  return;

}





// --- FUN_0051d310 at 0x0051D310 (size: 135) ---


undefined4 * __thiscall FUN_0051d310(undefined4 *param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  param_1[1] = param_2;

  param_1[2] = 0xffffffff;

  *param_1 = 0;

  param_1[3] = 0x3f800000;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x12] = 0;

  FUN_00535b30();

  param_1[0x13] = 0;

  param_1[0x14] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  param_1[0x23] = 0;

  uVar1 = DAT_008379ac;

  param_1[0x24] = DAT_008379a8;

  param_1[0x25] = uVar1;

  uVar1 = DAT_008379ac;

  param_1[0x1e] = DAT_008379a8;

  param_1[0x1f] = uVar1;

  return param_1;

}





// --- FUN_0051d3a0 at 0x0051D3A0 (size: 56) ---


void __fastcall FUN_0051d3a0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  *(int *)(param_1 + 0x70) = *(int *)(param_1 + 0x70) + 1;

  iVar1 = *(int *)(param_1 + 0x4c);

  *(int *)(param_1 + 0x74) = *(int *)(param_1 + 0x74) + 1;

  *(undefined4 *)(param_1 + 0x80) = *(undefined4 *)(iVar1 + 0x84);

  *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(iVar1 + 0x88);

  *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(iVar1 + 0x8c);

  uVar2 = DAT_008eee74;

  *(undefined4 *)(param_1 + 0x78) = DAT_008eee70;

  *(undefined4 *)(param_1 + 0x7c) = uVar2;

  return;

}





// --- FUN_0051d3e0 at 0x0051D3E0 (size: 121) ---


void __fastcall FUN_0051d3e0(int param_1)



{

  int iVar1;

  float local_c;

  float local_8;

  float local_4;

  

  if ((*(byte *)(*(int *)(param_1 + 0x50) + 0x38) & 2) != 0) {

    iVar1 = *(int *)(param_1 + 0x4c);

    local_c = *(float *)(iVar1 + 0x84) - *(float *)(param_1 + 0x80);

    local_8 = *(float *)(iVar1 + 0x88) - *(float *)(param_1 + 0x84);

    local_4 = *(float *)(iVar1 + 0x8c) - *(float *)(param_1 + 0x88);

  }

  FUN_00517f50(*(undefined4 *)(param_1 + 0x70),*(undefined4 *)(param_1 + 0x74),&local_c,

               *(undefined4 *)(param_1 + 0x78),*(undefined4 *)(param_1 + 0x7c));

  return;

}





// --- FUN_0051d460 at 0x0051D460 (size: 1048) ---


void __thiscall

FUN_0051d460(undefined4 *param_1,int param_2,int param_3,int param_4,int param_5,float *param_6,

            undefined4 param_7,undefined4 param_8,float *param_9,undefined4 *param_10,

            float *param_11,float param_12,undefined4 param_13,undefined4 param_14,

            undefined4 param_15,undefined4 param_16,undefined4 param_17)



{

  float fVar1;

  float fVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 *puVar5;

  int iVar6;

  float *pfVar7;

  float fVar8;

  float *pfVar9;

  float10 fVar10;

  unkbyte10 Var11;

  float10 fVar12;

  float10 fVar13;

  float local_3c;

  float local_38;

  float local_34;

  undefined1 local_30 [12];

  undefined1 local_24 [12];

  float local_18 [3];

  undefined1 local_c [12];

  

  uVar4 = DAT_008eee74;

  uVar3 = DAT_008eee70;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[1] = uVar4;

  *param_1 = uVar3;

  param_1[2] = param_16;

  param_1[3] = param_17;

  if (param_3 == -1) {

    param_2 = param_2 + 0x50;

  }

  else {

    param_2 = *(int *)(*(int *)(*(int *)(param_2 + 0x10) + 0x5c) + param_3 * 4) + 0x38;

  }

  FUN_00425f10(param_2);

  fVar8 = *param_6 + *(float *)(param_4 + 0x34);

  fVar2 = *(float *)(param_4 + 0x38) + param_6[1];

  pfVar7 = (float *)(param_1 + 0x16);

  fVar1 = *(float *)(param_4 + 0x3c) + param_6[2];

  local_3c = fVar8 * (float)param_1[10] + fVar2 * (float)param_1[0xd] + fVar1 * (float)param_1[0x10]

  ;

  local_38 = fVar8 * (float)param_1[0xb] +

             fVar2 * (float)param_1[0xe] + fVar1 * (float)param_1[0x11];

  *pfVar7 = local_3c;

  param_1[0x17] = local_38;

  local_34 = fVar8 * (float)param_1[0xc] +

             fVar2 * (float)param_1[0xf] + fVar1 * (float)param_1[0x12];

  param_1[0x18] = local_34;

  switch(param_7) {

  case 1:

    break;

  case 4:

    param_1[0x1f] = *param_11;

    param_1[0x20] = param_11[1];

    param_1[0x21] = param_11[2];

  case 3:

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

  case 2:

    pfVar7 = &local_3c;

    goto LAB_0051d5d4;

  case 5:

    puVar5 = (undefined4 *)FUN_00452530(local_c,param_9);

    param_1[0x19] = *puVar5;

    param_1[0x1a] = puVar5[1];

    param_1[0x1b] = puVar5[2];

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

    param_1[0x1f] = *param_11;

    param_1[0x20] = param_11[1];

    param_1[0x21] = param_11[2];

    break;

  case 6:

    param_1[0x19] = *param_9;

    param_1[0x1a] = param_9[1];

    param_1[0x1b] = param_9[2];

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

    fVar10 = (float10)FUN_0042c860(0xc0490fdb,0x40490fdb);

    Var11 = FUN_0042c860(0xc0490fdb,0x40490fdb);

    fVar12 = (float10)fcos(Var11);

    fVar13 = (float10)fcos((float10)(float)fVar10);

    local_3c = (float)(fVar13 * (float10)*param_11 * fVar12);

    fVar10 = (float10)fsin((float10)(float)fVar10);

    local_38 = (float)(fVar10 * (float10)param_11[1] * fVar12);

    fVar10 = (float10)fsin(Var11);

    fVar8 = param_11[2];

    param_1[0x1f] = local_3c;

    local_34 = (float)(fVar10 * (float10)fVar8);

    param_1[0x20] = local_38;

    param_1[0x21] = local_34;

    iVar6 = FUN_004524a0();

    if (iVar6 != 0) {

      param_1[0x1f] = 0.0;

      param_1[0x20] = 0;

      param_1[0x21] = 0;

    }

    break;

  case 7:

    param_1[0x19] = *param_9;

    param_1[0x1a] = param_9[1];

    param_1[0x1b] = param_9[2];

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

    pfVar9 = (float *)(param_1 + 0x1f);

    *pfVar7 = *param_11 * *pfVar7;

    param_1[0x17] = param_11[1] * (float)param_1[0x17];

    param_1[0x18] = param_11[2] * (float)param_1[0x18];

    *pfVar9 = *pfVar7;

    fVar8 = (float)param_1[0x17];

    goto LAB_0051d7f7;

  case 9:

    puVar5 = (undefined4 *)FUN_00452530(local_30,param_11);

    param_1[0x1f] = *puVar5;

    param_1[0x20] = puVar5[1];

    param_1[0x21] = puVar5[2];

  case 8:

    puVar5 = (undefined4 *)FUN_00452530(local_24,param_10);

    param_1[0x1c] = *puVar5;

    param_1[0x1d] = puVar5[1];

    param_1[0x1e] = puVar5[2];

    pfVar7 = local_18;

LAB_0051d5d4:

    puVar5 = (undefined4 *)FUN_00452530(pfVar7,param_9);

    param_1[0x19] = *puVar5;

    param_1[0x1a] = puVar5[1];

    param_1[0x1b] = puVar5[2];

    break;

  case 0xb:

    param_1[0x1f] = *param_11;

    param_1[0x20] = param_11[1];

    param_1[0x21] = param_11[2];

  case 10:

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

  case 0xc:

    pfVar9 = (float *)(param_1 + 0x19);

    param_11 = param_9;

    goto LAB_0051d7f0;

  default:

    param_1[0x19] = *param_9;

    param_1[0x1a] = param_9[1];

    param_1[0x1b] = param_9[2];

    param_1[0x1c] = *param_10;

    param_1[0x1d] = param_10[1];

    param_1[0x1e] = param_10[2];

    pfVar9 = (float *)(param_1 + 0x1f);

LAB_0051d7f0:

    *pfVar9 = *param_11;

    fVar8 = param_11[1];

    pfVar7 = param_11;

LAB_0051d7f7:

    pfVar9[1] = fVar8;

    pfVar9[2] = pfVar7[2];

  }

  param_1[0x22] = param_12;

  param_1[0x23] = param_13;

  param_1[0x25] = param_15;

  param_1[0x24] = param_14;

  local_3c = param_12;

  *(float *)(param_5 + 0x24) = param_12;

  *(float *)(param_5 + 0x28) = param_12;

  local_34 = param_12;

  *(float *)(param_5 + 0x2c) = param_12;

  local_38 = param_12;

  FUN_0050f140(param_1[0x24]);

  FUN_0051cdc0(param_7,param_8,param_5,param_1 + 6);

  return;

}





// --- FUN_0051d8b0 at 0x0051D8B0 (size: 42) ---


int FUN_0051d8b0(int param_1)



{

  int iVar1;

  

  if (((param_1 != 0) && (iVar1 = FUN_005df0f5(0x98), iVar1 != 0)) &&

     (iVar1 = FUN_0051d310(param_1), iVar1 != 0)) {

    return iVar1;

  }

  return 0;

}





// --- FUN_0051d8e0 at 0x0051D8E0 (size: 210) ---


void __fastcall FUN_0051d8e0(int param_1)



{

  void *pvVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  uint uVar5;

  

  if (*(int *)(param_1 + 0x4c) != 0) {

    FUN_00513f70();

    FUN_005160a0();

  }

  if (*(int *)(param_1 + 0x58) != 0) {

    uVar5 = 0;

    if (*(int *)(*(int *)(param_1 + 0x50) + 0x58) != 0) {

      do {

        pvVar1 = *(void **)(*(int *)(param_1 + 0x58) + uVar5 * 4);

        if (pvVar1 != (void *)0x0) {

          FUN_0050ed40();

          operator_delete(pvVar1);

        }

        *(undefined4 *)(*(int *)(param_1 + 0x58) + uVar5 * 4) = 0;

        *(undefined4 *)(*(int *)(param_1 + 0x5c) + uVar5 * 4) = 0;

        uVar5 = uVar5 + 1;

      } while (uVar5 < *(uint *)(*(int *)(param_1 + 0x50) + 0x58));

    }

    operator_delete__(*(void **)(param_1 + 0x58));

    *(undefined4 *)(param_1 + 0x58) = 0;

  }

  if (*(int *)(param_1 + 0x54) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0x54) + -4));

    *(undefined4 *)(param_1 + 0x54) = 0;

  }

  piVar2 = *(int **)(param_1 + 0x50);

  if (piVar2 != (int *)0x0) {

    if (piVar2[10] != DAT_0084527c) {

      (**(code **)(*piVar2 + 0x14))();

    }

    *(undefined4 *)(param_1 + 0x50) = 0;

  }

  if (*(undefined4 **)(param_1 + 0x4c) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x4c))(1);

    *(undefined4 *)(param_1 + 0x4c) = 0;

  }

  *(undefined4 *)(param_1 + 0x5c) = 0;

  uVar4 = DAT_008eee74;

  uVar3 = DAT_008eee70;

  *(undefined4 *)(param_1 + 0x70) = 0;

  *(undefined4 *)(param_1 + 0x90) = uVar3;

  *(undefined4 *)(param_1 + 0x94) = uVar4;

  return;

}





// --- FUN_0051d9c0 at 0x0051D9C0 (size: 369) ---


undefined4 __thiscall FUN_0051d9c0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  int *piVar3;

  int *piVar4;

  int iVar5;

  float10 fVar6;

  

  FUN_0051d8e0();

  *(int *)(param_1 + 0x50) = param_2;

  iVar5 = *(int *)(param_2 + 0x48);

  if (iVar5 == DAT_0084527c) {

    FUN_0051d8e0();

    return 0;

  }

  iVar1 = FUN_00513140(*(undefined4 *)(param_2 + 0x58),param_2 + 0x80);

  *(int *)(param_1 + 0x4c) = iVar1;

  if (iVar1 != 0) {

    *(undefined4 *)(param_1 + 0x80) = *(undefined4 *)(iVar1 + 0x84);

    *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(iVar1 + 0x88);

    *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(iVar1 + 0x8c);

    *(undefined4 *)(param_1 + 0x5c) = *(undefined4 *)(*(int *)(iVar1 + 0x10) + 0x5c);

    iVar1 = thunk_FUN_005df0f5(*(int *)(*(int *)(param_1 + 0x50) + 0x58) * 4);

    *(int *)(param_1 + 0x58) = iVar1;

    if (iVar1 != 0) {

      iVar1 = 0;

      if (0 < *(int *)(*(int *)(param_1 + 0x50) + 0x58)) {

        do {

          *(undefined4 *)(*(int *)(param_1 + 0x58) + iVar1 * 4) = 0;

          iVar1 = iVar1 + 1;

        } while (iVar1 < *(int *)(*(int *)(param_1 + 0x50) + 0x58));

      }

      iVar1 = 0;

      if (0 < *(int *)(*(int *)(param_1 + 0x50) + 0x58)) {

        do {

          uVar2 = FUN_0050f230(iVar5);

          *(undefined4 *)(*(int *)(param_1 + 0x58) + iVar1 * 4) = uVar2;

          if (*(int *)(*(int *)(param_1 + 0x58) + iVar1 * 4) == 0) goto LAB_0051da06;

          iVar1 = iVar1 + 1;

        } while (iVar1 < *(int *)(*(int *)(param_1 + 0x50) + 0x58));

      }

      fVar6 = (float10)FUN_0050dfe0();

      *(float *)(param_1 + 100) = (float)fVar6;

      iVar5 = *(int *)(*(int *)(param_1 + 0x50) + 0x58);

      piVar3 = (int *)thunk_FUN_005df0f5(iVar5 * 0x98 + 4);

      if (piVar3 == (int *)0x0) {

        piVar4 = (int *)0x0;

      }

      else {

        *piVar3 = iVar5;

        piVar4 = piVar3 + 1;

        if (-1 < iVar5 + -1) {

          piVar3 = piVar3 + 0x16;

          do {

            piVar3[-0xf] = 0x3f800000;

            piVar3[-0xe] = 0;

            piVar3[-0xd] = 0;

            piVar3[-0xc] = 0;

            piVar3[-2] = 0;

            piVar3[-1] = 0;

            *piVar3 = 0;

            FUN_00535b30();

            piVar3 = piVar3 + 0x26;

            iVar5 = iVar5 + -1;

          } while (iVar5 != 0);

        }

      }

      *(int **)(param_1 + 0x54) = piVar4;

      if (piVar4 != (int *)0x0) {

        return 1;

      }

    }

  }

LAB_0051da06:

  FUN_0051d8e0();

  return 0;

}





// --- FUN_0051db40 at 0x0051DB40 (size: 353) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0051db40(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  undefined4 uVar5;

  undefined4 uVar6;

  undefined4 uVar7;

  int iVar8;

  float10 fVar9;

  undefined4 uVar10;

  float fVar11;

  float fVar12;

  float fVar13;

  float fVar14;

  double dVar15;

  undefined1 local_30 [12];

  undefined1 local_24 [12];

  undefined1 local_18 [12];

  undefined1 local_c [12];

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x50) + 0x58);

  iVar8 = 0;

  if (0 < iVar1) {

    piVar2 = *(int **)(param_1 + 0x5c);

    do {

      if (*piVar2 == 0) break;

      iVar8 = iVar8 + 1;

      piVar2 = piVar2 + 1;

    } while (iVar8 < *(int *)(*(int *)(param_1 + 0x50) + 0x58));

  }

  if ((iVar8 != iVar1) &&

     (*(undefined4 *)(*(int *)(param_1 + 0x5c) + iVar8 * 4) =

           *(undefined4 *)(*(int *)(param_1 + 0x58) + iVar8 * 4),

     *(int *)(*(int *)(param_1 + 0x5c) + iVar8 * 4) != 0)) {

    iVar1 = *(int *)(param_1 + 0x50);

    if ((*(int *)(iVar1 + 0x60) == 0) && (*(double *)(iVar1 + 0x68) == _DAT_00795610)) {

      uVar7 = 1;

    }

    else {

      uVar7 = 0;

    }

    uVar10 = *(undefined4 *)(iVar1 + 0x3c);

    fVar9 = (float10)FUN_00517d40();

    dVar15 = (double)fVar9;

    fVar9 = (float10)FUN_00517cf0(dVar15);

    fVar14 = (float)fVar9;

    fVar9 = (float10)FUN_00517ca0(fVar14);

    fVar13 = (float)fVar9;

    fVar9 = (float10)FUN_00517c50(fVar13);

    fVar12 = (float)fVar9;

    fVar9 = (float10)FUN_00517c00(fVar12);

    fVar11 = (float)fVar9;

    uVar3 = FUN_00518200(local_30);

    uVar4 = FUN_005181a0(local_24);

    uVar5 = FUN_00518140(local_18);

    uVar6 = FUN_00517fd0(local_c);

    FUN_0051d460(*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_1 + 8),param_1 + 0xc,

                 *(undefined4 *)(*(int *)(param_1 + 0x5c) + iVar8 * 4),uVar6,uVar10,uVar7,uVar5,

                 uVar4,uVar3,fVar11,fVar12,fVar13,fVar14,dVar15);

    FUN_005118d0();

    iVar1 = *(int *)(param_1 + 0x4c);

    *(int *)(param_1 + 0x70) = *(int *)(param_1 + 0x70) + 1;

    *(int *)(param_1 + 0x74) = *(int *)(param_1 + 0x74) + 1;

    *(undefined4 *)(param_1 + 0x80) = *(undefined4 *)(iVar1 + 0x84);

    *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(iVar1 + 0x88);

    *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(iVar1 + 0x8c);

    uVar7 = DAT_008eee74;

    *(undefined4 *)(param_1 + 0x78) = DAT_008eee70;

    *(undefined4 *)(param_1 + 0x7c) = uVar7;

  }

  return;

}





// --- FUN_0051dcb0 at 0x0051DCB0 (size: 548) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



bool __fastcall FUN_0051dcb0(int param_1)



{

  int iVar1;

  int iVar2;

  char cVar3;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  uint uVar7;

  bool bVar8;

  

  uVar7 = 0;

  if ((*(int *)(param_1 + 0x50) == 0) || (*(int *)(param_1 + 0x4c) == 0)) {

    return false;

  }

  cVar3 = FUN_00510930(*(undefined4 *)(param_1 + 100));

  if (cVar3 != '\0') {

    if (*(int *)(param_1 + 0x60) != 0) {

      *(undefined4 *)(param_1 + 0x60) = 0;

      FUN_00510470(0);

    }

    if (*(int *)(*(int *)(param_1 + 0x50) + 0x58) != 0) {

      iVar5 = 0;

      do {

        iVar1 = *(int *)(*(int *)(param_1 + 0x5c) + uVar7 * 4);

        if (iVar1 != 0) {

          iVar2 = *(int *)(param_1 + 0x50);

          if (*(int *)(iVar2 + 0x40) == 0) {

            iVar6 = *(int *)(param_1 + 0x54) + 0x18 + iVar5;

          }

          else if (*(int *)(param_1 + 8) == -1) {

            iVar6 = *(int *)(param_1 + 4) + 0x50;

          }

          else {

            iVar6 = *(int *)(*(int *)(*(int *)(*(int *)(param_1 + 4) + 0x10) + 0x5c) +

                            *(int *)(param_1 + 8) * 4) + 0x38;

          }

          if ((*(int *)(iVar2 + 0x60) == 0) && (*(double *)(iVar2 + 0x68) == _DAT_00795610)) {

            uVar4 = 1;

          }

          else {

            uVar4 = 0;

          }

          FUN_0051cdc0(*(undefined4 *)(iVar2 + 0x3c),uVar4,iVar1,iVar6);

          FUN_0051cd10(uVar7);

        }

        uVar7 = uVar7 + 1;

        iVar5 = iVar5 + 0x98;

      } while (uVar7 < *(uint *)(*(int *)(param_1 + 0x50) + 0x58));

    }

    bVar8 = true;

    if (*(int *)(param_1 + 0x8c) == 0) {

      iVar5 = FUN_0051d3e0();

      if (iVar5 != 0) {

        FUN_0051db40();

      }

      FUN_0051cd60();

    }

    else {

      bVar8 = *(int *)(param_1 + 0x70) != 0;

    }

    uVar4 = DAT_008eee74;

    *(undefined4 *)(param_1 + 0x90) = DAT_008eee70;

    *(undefined4 *)(param_1 + 0x94) = uVar4;

    return bVar8;

  }

  if (*(int *)(param_1 + 0x60) == 0) {

    FUN_00510470(1);

    *(undefined4 *)(param_1 + 0x60) = 1;

  }

  uVar4 = DAT_008eee74;

  *(undefined4 *)(param_1 + 0x90) = DAT_008eee70;

  iVar5 = *(int *)(param_1 + 0x50);

  *(undefined4 *)(param_1 + 0x94) = uVar4;

  if ((*(int *)(iVar5 + 0x60) == 0) && (*(double *)(iVar5 + 0x68) == _DAT_00795610)) {

    uVar7 = 0;

    if (*(int *)(iVar5 + 0x58) != 0) {

      iVar5 = 0;

      do {

        *(ulonglong *)(iVar5 + *(int *)(param_1 + 0x54)) = CONCAT44(DAT_008eee74,DAT_008eee70);

        uVar7 = uVar7 + 1;

        iVar5 = iVar5 + 0x98;

      } while (uVar7 < *(uint *)(*(int *)(param_1 + 0x50) + 0x58));

    }

    return true;

  }

  if (*(int *)(iVar5 + 0x58) != 0) {

    iVar5 = 0;

    uVar7 = 0;

    do {

      if (*(int *)(*(int *)(param_1 + 0x5c) + uVar7 * 4) != 0) {

        *(double *)(*(int *)(param_1 + 0x54) + iVar5 + 0x10) =

             (double)CONCAT44(DAT_008eee74,DAT_008eee70) -

             *(double *)(*(int *)(param_1 + 0x54) + iVar5);

        FUN_0051cd10(uVar7);

      }

      uVar7 = uVar7 + 1;

      iVar5 = iVar5 + 0x98;

    } while (uVar7 < *(uint *)(*(int *)(param_1 + 0x50) + 0x58));

  }

  if (*(int *)(param_1 + 0x8c) != 0) {

    return *(int *)(param_1 + 0x70) != 0;

  }

  iVar5 = FUN_0051d3e0();

  if (iVar5 != 0) {

    FUN_0051d3a0();

  }

  FUN_0051cd60();

  return true;

}





// --- thunk_FUN_0051d8e0 at 0x0051DEE0 (size: 5) ---


void __fastcall thunk_FUN_0051d8e0(int param_1)



{

  void *pvVar1;

  int *piVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  uint uVar5;

  

  if (*(int *)(param_1 + 0x4c) != 0) {

    FUN_00513f70();

    FUN_005160a0();

  }

  if (*(int *)(param_1 + 0x58) != 0) {

    uVar5 = 0;

    if (*(int *)(*(int *)(param_1 + 0x50) + 0x58) != 0) {

      do {

        pvVar1 = *(void **)(*(int *)(param_1 + 0x58) + uVar5 * 4);

        if (pvVar1 != (void *)0x0) {

          FUN_0050ed40();

          operator_delete(pvVar1);

        }

        *(undefined4 *)(*(int *)(param_1 + 0x58) + uVar5 * 4) = 0;

        *(undefined4 *)(*(int *)(param_1 + 0x5c) + uVar5 * 4) = 0;

        uVar5 = uVar5 + 1;

      } while (uVar5 < *(uint *)(*(int *)(param_1 + 0x50) + 0x58));

    }

    operator_delete__(*(void **)(param_1 + 0x58));

    *(undefined4 *)(param_1 + 0x58) = 0;

  }

  if (*(int *)(param_1 + 0x54) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0x54) + -4));

    *(undefined4 *)(param_1 + 0x54) = 0;

  }

  piVar2 = *(int **)(param_1 + 0x50);

  if (piVar2 != (int *)0x0) {

    if (piVar2[10] != DAT_0084527c) {

      (**(code **)(*piVar2 + 0x14))();

    }

    *(undefined4 *)(param_1 + 0x50) = 0;

  }

  if (*(undefined4 **)(param_1 + 0x4c) != (undefined4 *)0x0) {

    (**(code **)**(undefined4 **)(param_1 + 0x4c))(1);

    *(undefined4 *)(param_1 + 0x4c) = 0;

  }

  *(undefined4 *)(param_1 + 0x5c) = 0;

  uVar4 = DAT_008eee74;

  uVar3 = DAT_008eee70;

  *(undefined4 *)(param_1 + 0x70) = 0;

  *(undefined4 *)(param_1 + 0x90) = uVar3;

  *(undefined4 *)(param_1 + 0x94) = uVar4;

  return;

}





// --- FUN_0051def0 at 0x0051DEF0 (size: 63) ---


undefined4 FUN_0051def0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  if (param_1 != 0) {

    uVar1 = FUN_004220b0(param_1,0x2a);

    iVar2 = FUN_00415430(uVar1);

    if (iVar2 != 0) {

      uVar1 = FUN_0051d9c0(iVar2);

      return uVar1;

    }

  }

  return 0;

}





// --- FUN_0051df30 at 0x0051DF30 (size: 59) ---


undefined4 __fastcall FUN_0051df30(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  uVar1 = DAT_008379ac;

  *(undefined4 *)(param_1 + 0x68) = DAT_008379a8;

  *(undefined4 *)(param_1 + 0x6c) = uVar1;

  iVar2 = 0;

  if (0 < *(int *)(*(int *)(param_1 + 0x50) + 0x5c)) {

    do {

      FUN_0051db40();

      iVar2 = iVar2 + 1;

    } while (iVar2 < *(int *)(*(int *)(param_1 + 0x50) + 0x5c));

  }

  return 1;

}





// --- FUN_0051df70 at 0x0051DF70 (size: 4) ---


undefined4 __fastcall FUN_0051df70(int param_1)



{

  return *(undefined4 *)(param_1 + 0x10);

}





// --- FUN_0051df80 at 0x0051DF80 (size: 15) ---


undefined2 __thiscall FUN_0051df80(int param_1,int param_2)



{

  return *(undefined2 *)(param_1 + 0xc4 + param_2 * 2);

}





// --- FUN_0051df90 at 0x0051DF90 (size: 7) ---


undefined4 __fastcall FUN_0051df90(int param_1)



{

  return *(undefined4 *)(param_1 + 0xa4);

}





// --- FUN_0051dfa0 at 0x0051DFA0 (size: 7) ---


undefined4 __fastcall FUN_0051dfa0(int param_1)



{

  return *(undefined4 *)(param_1 + 0xa8);

}





// --- FUN_0051dfb0 at 0x0051DFB0 (size: 7) ---


undefined4 __fastcall FUN_0051dfb0(int param_1)



{

  return *(undefined4 *)(param_1 + 0x98);

}





// --- FUN_0051dfc0 at 0x0051DFC0 (size: 16) ---


undefined4 __thiscall FUN_0051dfc0(int param_1,int param_2)



{

  return *(undefined4 *)(*(int *)(param_1 + 0x9c) + param_2 * 4);

}





// --- FUN_0051dfd0 at 0x0051DFD0 (size: 16) ---


undefined4 __thiscall FUN_0051dfd0(int param_1,int param_2)



{

  return *(undefined4 *)(*(int *)(param_1 + 0xa0) + param_2 * 4);

}





// --- FUN_0051dfe0 at 0x0051DFE0 (size: 252) ---


undefined4 * __fastcall FUN_0051dfe0(undefined4 *param_1)



{

  undefined4 uVar1;

  undefined4 uVar2;

  

  *param_1 = &PTR_FUN_007c8044;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = &PTR_LAB_00797910;

  param_1[7] = 0;

  param_1[8] = 0x3f800000;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0x15] = 0;

  param_1[0x16] = 0;

  param_1[0x17] = 0;

  FUN_00535b30();

  uVar2 = DAT_007c8028;

  uVar1 = DAT_007c8024;

  param_1[0x1a] = DAT_007c8020;

  param_1[0x18] = &DAT_00400c08;

  param_1[0x19] = 0x3f800000;

  param_1[0x1b] = uVar1;

  param_1[0x1c] = uVar2;

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x26] = 0;

  param_1[0x27] = 0;

  param_1[0x28] = 0;

  param_1[0x29] = 0;

  param_1[0x2b] = 0;

  param_1[0x2c] = 0;

  param_1[0x2d] = 0;

  param_1[0x2e] = 0;

  param_1[0x2f] = 0;

  param_1[0x30] = 0;

  param_1[0x31] = 0;

  param_1[0x32] = 0;

  param_1[0x33] = 0;

  param_1[0x34] = 0;

  *(undefined2 *)(param_1 + 0x35) = 0;

  return param_1;

}





// --- FUN_0051e0e0 at 0x0051E0E0 (size: 362) ---


void __fastcall FUN_0051e0e0(int param_1)



{

  if (*(void **)(param_1 + 0x9c) != (void *)0x0) {

    operator_delete__(*(void **)(param_1 + 0x9c));

    *(undefined4 *)(param_1 + 0x9c) = 0;

  }

  if (*(void **)(param_1 + 0xa0) != (void *)0x0) {

    operator_delete__(*(void **)(param_1 + 0xa0));

    *(undefined4 *)(param_1 + 0xa0) = 0;

  }

  *(undefined4 *)(param_1 + 0x98) = 0;

  operator_delete__(*(void **)(param_1 + 8));

  *(undefined4 *)(param_1 + 8) = 0;

  *(undefined4 *)(param_1 + 0xc) = 0;

  *(undefined4 *)(param_1 + 0x14) = 0;

  *(undefined4 *)(param_1 + 0x1c) = 0;

  *(undefined4 *)(param_1 + 0x98) = 0;

  *(undefined4 *)(param_1 + 0x9c) = 0;

  *(undefined4 *)(param_1 + 0xa0) = 0;

  *(undefined4 *)(param_1 + 0xa4) = 0;

  *(undefined **)(param_1 + 0x60) = &DAT_00400c08;

  *(undefined4 *)(param_1 + 0xac) = DAT_008452d4;

  *(undefined4 *)(param_1 + 0xb0) = DAT_008452d4;

  *(undefined4 *)(param_1 + 0xb4) = DAT_008452d4;

  *(undefined4 *)(param_1 + 0xc0) = DAT_008452d4;

  *(undefined4 *)(param_1 + 0x74) = 0;

  *(undefined4 *)(param_1 + 0x78) = 0;

  *(undefined4 *)(param_1 + 0x7c) = 0;

  *(undefined4 *)(param_1 + 0x80) = 0;

  *(undefined4 *)(param_1 + 0x84) = 0;

  *(undefined4 *)(param_1 + 0x88) = 0;

  *(undefined4 *)(param_1 + 0x8c) = 0;

  *(undefined4 *)(param_1 + 0x90) = 0;

  *(undefined4 *)(param_1 + 0xb8) = 0;

  *(undefined4 *)(param_1 + 0xbc) = 0;

  *(undefined4 *)(param_1 + 100) = 0x3f800000;

  *(undefined4 *)(param_1 + 0x94) = 0;

  *(undefined4 *)(param_1 + 0xc4) = 0;

  *(undefined4 *)(param_1 + 200) = 0;

  *(undefined4 *)(param_1 + 0xcc) = 0;

  *(undefined4 *)(param_1 + 0xd0) = 0;

  *(undefined2 *)(param_1 + 0xd4) = 0;

  return;

}





// --- FUN_0051e250 at 0x0051E250 (size: 29) ---


void __fastcall FUN_0051e250(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c8044;

  FUN_0051e0e0();

  param_1[6] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0051e270 at 0x0051E270 (size: 15) ---


void __thiscall FUN_0051e270(int param_1,undefined4 *param_2)



{

  *param_2 = *(undefined4 *)(param_1 + 0xac);

  return;

}





// --- FUN_0051e280 at 0x0051E280 (size: 15) ---


void __thiscall FUN_0051e280(int param_1,undefined4 *param_2)



{

  *param_2 = *(undefined4 *)(param_1 + 0xc0);

  return;

}





// --- FUN_0051e290 at 0x0051E290 (size: 49) ---


undefined4 * __thiscall FUN_0051e290(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_FUN_007c8044;

  FUN_0051e0e0();

  param_1[6] = &PTR_FUN_0079385c;

  *param_1 = &PTR_FUN_0079385c;

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0051e8e0 at 0x0051E8E0 (size: 1212) ---


undefined4 __thiscall FUN_0051e8e0(int param_1,uint *param_2,uint param_3)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  uint uVar3;

  uint uVar4;

  undefined4 *puVar5;

  int iVar6;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_38;

  undefined4 local_34;

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  FUN_0051e0e0();

  *(undefined4 *)(param_1 + 4) = *(undefined4 *)*param_2;

  uVar4 = *param_2;

  *param_2 = uVar4 + 4;

  *(undefined4 *)(param_1 + 0x60) = *(undefined4 *)(uVar4 + 4);

  uVar4 = *param_2;

  *param_2 = uVar4 + 4;

  if ((*(uint *)(param_1 + 4) & 0x10000) == 0) {

    *(undefined4 *)(param_1 + 8) = 0;

    if ((*(uint *)(param_1 + 4) & 0x20000) == 0) {

      *(undefined4 *)(param_1 + 0x14) = 0;

    }

    else {

      *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

    }

  }

  else {

    *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(uVar4 + 4);

    *param_2 = *param_2 + 4;

    if (*(int *)(param_1 + 0xc) != 0) {

      puVar1 = (undefined4 *)thunk_FUN_005df0f5(*(int *)(param_1 + 0xc));

      uVar4 = *(uint *)(param_1 + 0xc);

      *(undefined4 **)(param_1 + 8) = puVar1;

      puVar5 = (undefined4 *)*param_2;

      for (uVar3 = uVar4 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {

        *puVar1 = *puVar5;

        puVar5 = puVar5 + 1;

        puVar1 = puVar1 + 1;

      }

      for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {

        *(undefined1 *)puVar1 = *(undefined1 *)puVar5;

        puVar5 = (undefined4 *)((int)puVar5 + 1);

        puVar1 = (undefined4 *)((int)puVar1 + 1);

      }

      puVar5 = (undefined4 *)(*param_2 + *(int *)(param_1 + 0xc));

      *param_2 = (uint)puVar5;

      *(undefined4 *)(param_1 + 0x10) = *puVar5;

      *param_2 = *param_2 + 4;

    }

  }

  if ((char)((uint)*(undefined4 *)(param_1 + 4) >> 8) < '\0') {

    (**(code **)(*(int *)(param_1 + 0x18) + 0x10))(param_2,param_3);

  }

  else {

    local_40 = 0x3f800000;

    local_3c = 0;

    local_38 = 0;

    local_34 = 0;

    local_c = 0;

    local_8 = 0;

    local_4 = 0;

    FUN_00535b30();

    *(undefined4 *)(param_1 + 0x1c) = 0;

    FUN_00425f10(&local_40);

  }

  if ((*(byte *)(param_1 + 4) & 2) == 0) {

    *(undefined4 *)(param_1 + 0xac) = DAT_008452d4;

  }

  else {

    uVar2 = *(undefined4 *)*param_2;

    *param_2 = (uint)((undefined4 *)*param_2 + 1);

    *(undefined4 *)(param_1 + 0xac) = uVar2;

  }

  if ((*(uint *)(param_1 + 4) & 0x800) == 0) {

    *(undefined4 *)(param_1 + 0xb0) = DAT_008452d4;

  }

  else {

    uVar2 = *(undefined4 *)*param_2;

    *param_2 = (uint)((undefined4 *)*param_2 + 1);

    *(undefined4 *)(param_1 + 0xb0) = uVar2;

  }

  uVar2 = DAT_008452d4;

  if ((*(uint *)(param_1 + 4) & 0x1000) != 0) {

    uVar2 = *(undefined4 *)*param_2;

    *param_2 = (uint)((undefined4 *)*param_2 + 1);

  }

  *(undefined4 *)(param_1 + 0xb4) = uVar2;

  if ((*(byte *)(param_1 + 4) & 1) == 0) {

    *(undefined4 *)(param_1 + 0xc0) = DAT_008452d4;

  }

  else {

    uVar2 = *(undefined4 *)*param_2;

    *param_2 = (uint)((undefined4 *)*param_2 + 1);

    *(undefined4 *)(param_1 + 0xc0) = uVar2;

  }

  if ((*(byte *)(param_1 + 4) & 0x20) == 0) {

    *(undefined4 *)(param_1 + 0xa4) = 0;

  }

  else {

    *(undefined4 *)(param_1 + 0xa4) = *(undefined4 *)*param_2;

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0xa8) = *(undefined4 *)(uVar4 + 4);

    *param_2 = *param_2 + 4;

  }

  if ((*(byte *)(param_1 + 4) & 0x40) == 0) {

    *(undefined4 *)(param_1 + 0x9c) = 0;

    *(undefined4 *)(param_1 + 0xa0) = 0;

  }

  else {

    *(undefined4 *)(param_1 + 0x98) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

    uVar2 = thunk_FUN_005df0f5(*(int *)(param_1 + 0x98) << 2);

    *(undefined4 *)(param_1 + 0x9c) = uVar2;

    uVar2 = thunk_FUN_005df0f5(*(int *)(param_1 + 0x98) << 2);

    *(undefined4 *)(param_1 + 0xa0) = uVar2;

    uVar4 = 0;

    if (*(int *)(param_1 + 0x98) != 0) {

      do {

        *(undefined4 *)(*(int *)(param_1 + 0x9c) + uVar4 * 4) = *(undefined4 *)*param_2;

        uVar3 = *param_2;

        *param_2 = uVar3 + 4;

        *(undefined4 *)(*(int *)(param_1 + 0xa0) + uVar4 * 4) = *(undefined4 *)(uVar3 + 4);

        *param_2 = *param_2 + 4;

        uVar4 = uVar4 + 1;

      } while (uVar4 < *(uint *)(param_1 + 0x98));

    }

  }

  if (*(char *)(param_1 + 4) < '\0') {

    *(undefined4 *)(param_1 + 100) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((*(uint *)(param_1 + 4) & 0x100) != 0) {

    *(undefined4 *)(param_1 + 0x68) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((*(uint *)(param_1 + 4) & 0x200) != 0) {

    *(undefined4 *)(param_1 + 0x6c) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((*(uint *)(param_1 + 4) & 0x40000) != 0) {

    *(undefined4 *)(param_1 + 0x70) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if (((*(byte *)(param_1 + 4) & 4) != 0) && (0xb < param_3)) {

    *(undefined4 *)(param_1 + 0x74) = *(undefined4 *)*param_2;

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x78) = *(undefined4 *)(uVar4 + 4);

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x7c) = *(undefined4 *)(uVar4 + 4);

    *param_2 = *param_2 + 4;

  }

  if (((*(byte *)(param_1 + 4) & 8) != 0) && (0xb < param_3)) {

    *(undefined4 *)(param_1 + 0x80) = *(undefined4 *)*param_2;

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x84) = *(undefined4 *)(uVar4 + 4);

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x88) = *(undefined4 *)(uVar4 + 4);

    *param_2 = *param_2 + 4;

  }

  if (((*(byte *)(param_1 + 4) & 0x10) != 0) && (0xb < param_3)) {

    *(undefined4 *)(param_1 + 0x8c) = *(undefined4 *)*param_2;

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x90) = *(undefined4 *)(uVar4 + 4);

    uVar4 = *param_2;

    *param_2 = uVar4 + 4;

    *(undefined4 *)(param_1 + 0x94) = *(undefined4 *)(uVar4 + 4);

    *param_2 = *param_2 + 4;

  }

  if ((*(uint *)(param_1 + 4) & 0x2000) == 0) {

    *(undefined4 *)(param_1 + 0xb8) = 0;

  }

  else {

    *(undefined4 *)(param_1 + 0xb8) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((*(uint *)(param_1 + 4) & 0x4000) == 0) {

    *(undefined4 *)(param_1 + 0xbc) = 0;

  }

  else {

    *(undefined4 *)(param_1 + 0xbc) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  *(undefined2 *)(param_1 + 0xc4) = *(undefined2 *)*param_2;

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xc6) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 200) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xca) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xcc) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xce) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xd0) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xd2) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  *(undefined2 *)(param_1 + 0xd4) = *(undefined2 *)(uVar4 + 2);

  uVar4 = *param_2;

  *param_2 = uVar4 + 2;

  uVar4 = uVar4 + 2 & 0x80000003;

  if ((int)uVar4 < 0) {

    uVar4 = (uVar4 - 1 | 0xfffffffc) + 1;

  }

  if (uVar4 != 0) {

    for (iVar6 = 4 - uVar4; iVar6 != 0; iVar6 = iVar6 + -1) {

      *(undefined1 *)*param_2 = 0;

      *param_2 = *param_2 + 1;

    }

  }

  return 1;

}





// --- FUN_0051eda0 at 0x0051EDA0 (size: 46) ---


undefined4 * __fastcall FUN_0051eda0(undefined4 *param_1)



{

  FUN_00415460(DAT_00845358);

  param_1[0xc] = &PTR_FUN_0079385c;

  param_1[0xe] = 0;

  param_1[0xf] = 0;

  *param_1 = &PTR_LAB_007c80a8;

  param_1[0xc] = &PTR_LAB_007c8094;

  return param_1;

}





// --- FUN_0051ede0 at 0x0051EDE0 (size: 26) ---


float10 __fastcall FUN_0051ede0(int param_1)



{

  if (2 < *(uint *)(param_1 + 0x38)) {

    return (float10)*(float *)(*(int *)(param_1 + 0x3c) + -0x18 + *(uint *)(param_1 + 0x38) * 0x14);

  }

  return (float10)*(float *)(*(int *)(param_1 + 0x3c) + 0x10);

}





// --- FUN_0051ee20 at 0x0051EE20 (size: 38) ---


void __fastcall FUN_0051ee20(int param_1)



{

  if (*(int *)(param_1 + 0x3c) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0x3c) + -4));

    *(undefined4 *)(param_1 + 0x3c) = 0;

  }

  *(undefined4 *)(param_1 + 0x38) = 0;

  return;

}





// --- FUN_0051ef10 at 0x0051EF10 (size: 168) ---


undefined4 __thiscall FUN_0051ef10(int param_1,int *param_2)



{

  undefined4 uVar1;

  int iVar2;

  int *piVar3;

  int iVar4;

  uint uVar5;

  int iVar6;

  

  (**(code **)(*(int *)(param_1 + -0x30) + 0x3c))();

  *(undefined4 *)(param_1 + 8) = *(undefined4 *)*param_2;

  *param_2 = *param_2 + 4;

  iVar6 = *(int *)(param_1 + 8);

  piVar3 = (int *)thunk_FUN_005df0f5(iVar6 * 0x14 + 4);

  if (piVar3 == (int *)0x0) {

    piVar3 = (int *)0x0;

  }

  else {

    *piVar3 = iVar6;

    piVar3 = piVar3 + 1;

  }

  *(int **)(param_1 + 0xc) = piVar3;

  uVar5 = 0;

  if (*(int *)(param_1 + 8) != 0) {

    iVar6 = 0;

    do {

      uVar1 = *(undefined4 *)*param_2;

      iVar4 = *(int *)(param_1 + 0xc);

      *param_2 = (int)((undefined4 *)*param_2 + 1);

      *(undefined4 *)(iVar4 + iVar6) = uVar1;

      iVar4 = iVar4 + iVar6;

      *(undefined4 *)(iVar4 + 4) = *(undefined4 *)*param_2;

      iVar2 = *param_2;

      *param_2 = iVar2 + 4;

      *(undefined4 *)(iVar4 + 8) = *(undefined4 *)(iVar2 + 4);

      iVar2 = *param_2;

      *param_2 = iVar2 + 4;

      *(undefined4 *)(iVar4 + 0xc) = *(undefined4 *)(iVar2 + 4);

      iVar2 = *param_2;

      *param_2 = iVar2 + 4;

      *(undefined4 *)(iVar4 + 0x10) = *(undefined4 *)(iVar2 + 4);

      *param_2 = *param_2 + 4;

      uVar5 = uVar5 + 1;

      iVar6 = iVar6 + 0x14;

    } while (uVar5 < *(uint *)(param_1 + 8));

  }

  return 1;

}





// --- FUN_0051efc0 at 0x0051EFC0 (size: 372) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0051efc0(int param_1,float param_2,uint *param_3,undefined4 *param_4)



{

  uint uVar1;

  float *pfVar2;

  uint uVar3;

  float *pfVar4;

  float local_4;

  

  pfVar2 = &local_4;

  if (DAT_008452f4 != 0) {

    *param_3 = 0;

    *param_4 = *(undefined4 *)(*(int *)(param_1 + 0x3c) + 4);

    return;

  }

  if (DAT_0081fc7c != 0xffffffff) {

    if ((int)DAT_0081fc7c < *(int *)(param_1 + 0x38)) {

      *param_3 = DAT_0081fc7c;

      *param_4 = *(undefined4 *)(*(int *)(param_1 + 0x3c) + 4 + DAT_0081fc7c * 0x14);

      return;

    }

    *param_3 = *(int *)(param_1 + 0x38) - 1;

    *param_4 = *(undefined4 *)(*(int *)(param_1 + 0x3c) + -0x10 + *(int *)(param_1 + 0x38) * 0x14);

    return;

  }

  local_4 = 0.0;

  if (DAT_00796344 <= ABS(param_2) - _DAT_0081fc68) {

    pfVar2 = &param_2;

  }

  if (DAT_0081fc78 == '\0') {

    local_4 = DAT_00867318;

  }

  else {

    local_4 = DAT_0086731c;

  }

  uVar1 = *(uint *)(param_1 + 0x38);

  uVar3 = 0;

  if (DAT_00796344 <= local_4) {

    if (uVar1 != 0) {

      pfVar4 = (float *)(*(int *)(param_1 + 0x3c) + 0x10);

      do {

        if (*pfVar2 < pfVar4[-1] - (pfVar4[-1] - *pfVar4) * local_4) goto LAB_0051f0c6;

        uVar3 = uVar3 + 1;

        pfVar4 = pfVar4 + 5;

      } while (uVar3 < uVar1);

    }

  }

  else if (uVar1 != 0) {

    pfVar4 = (float *)(*(int *)(param_1 + 0x3c) + 0xc);

    do {

      if (*pfVar2 < (*pfVar4 - pfVar4[-1]) * local_4 + *pfVar4) {

LAB_0051f0c6:

        *param_3 = uVar3;

        *param_4 = *(undefined4 *)(*(int *)(param_1 + 0x3c) + 4 + uVar3 * 0x14);

        return;

      }

      uVar3 = uVar3 + 1;

      pfVar4 = pfVar4 + 5;

    } while (uVar3 < uVar1);

  }

  *param_3 = uVar1 - 1;

  *param_4 = *(undefined4 *)(*(int *)(param_1 + 0x3c) + -0x10 + *(int *)(param_1 + 0x38) * 0x14);

  return;

}





// --- FUN_0051f190 at 0x0051F190 (size: 85) ---


undefined4 * __thiscall FUN_0051f190(undefined4 *param_1,byte param_2)



{

  *param_1 = &PTR_LAB_007c80a8;

  param_1[0xc] = &PTR_LAB_007c8094;

  if (param_1[0xf] != 0) {

    operator_delete__((void *)(param_1[0xf] + -4));

    param_1[0xf] = 0;

  }

  param_1[0xe] = 0;

  param_1[0xc] = &PTR_FUN_0079385c;

  FUN_004154b0();

  if ((param_2 & 1) != 0) {

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_0051f1f0 at 0x0051F1F0 (size: 90) ---


void __thiscall FUN_0051f1f0(int param_1,uint param_2)



{

  switch(param_2) {

  case 0x6500000d:

  case 0x6500000e:

    *(undefined4 *)(param_1 + 0x2c) = 0;

    return;

  case 0x6500000f:

  case 0x65000010:

    *(undefined4 *)(param_1 + 0x20) = 0;

    return;

  }

  if ((param_2 & 0x40000000) == 0) {

    if (((int)param_2 < 0) && (param_2 == *(uint *)(param_1 + 0x10))) {

      *(undefined4 *)(param_1 + 0x10) = 0x8000003d;

    }

  }

  else if (param_2 == *(uint *)(param_1 + 0x14)) {

    *(undefined4 *)(param_1 + 0x14) = 0x41000003;

    *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;

    return;

  }

  return;

}





// --- FUN_0051f260 at 0x0051F260 (size: 49) ---


void __thiscall FUN_0051f260(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);

  return;

}





// --- FUN_0051f2a0 at 0x0051F2A0 (size: 87) ---


void __thiscall FUN_0051f2a0(int param_1,uint param_2)



{

  if (param_2 == 0x6500000d) {

    *(undefined4 *)(param_1 + 0x18) = 0;

  }

  else {

    if (param_2 == 0x6500000f) {

      *(undefined4 *)(param_1 + 0x10) = 0;

      return;

    }

    if ((param_2 & 0x40000000) == 0) {

      if (((int)param_2 < 0) && (param_2 == *(uint *)(param_1 + 4))) {

        *(undefined4 *)(param_1 + 4) = 0x8000003d;

        return;

      }

    }

    else if (param_2 == *(uint *)(param_1 + 8)) {

      *(undefined4 *)(param_1 + 8) = 0x41000003;

      *(undefined4 *)(param_1 + 0xc) = 0x3f800000;

      return;

    }

  }

  return;

}





// --- FUN_0051f300 at 0x0051F300 (size: 67) ---


void __fastcall FUN_0051f300(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c8804;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 1;

  param_1[4] = 0x8000003d;

  param_1[5] = 0x41000003;

  param_1[6] = 0;

  param_1[7] = 0x3f800000;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0x3f800000;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  param_1[0xd] = 0x3f800000;

  return;

}





// --- FUN_0051f350 at 0x0051F350 (size: 81) ---


void __thiscall

FUN_0051f350(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x14);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    puVar1[1] = param_2;

    puVar1[2] = param_3;

    *puVar1 = 0;

    puVar1[3] = param_4;

    puVar1[4] = param_5;

  }

  if (*(undefined4 **)(param_1 + 8) != (undefined4 *)0x0) {

    **(undefined4 **)(param_1 + 8) = puVar1;

    *(undefined4 **)(param_1 + 8) = puVar1;

    return;

  }

  *(undefined4 **)(param_1 + 4) = puVar1;

  *(undefined4 **)(param_1 + 8) = puVar1;

  return;

}





// --- FUN_0051f3b0 at 0x0051F3B0 (size: 44) ---


int __fastcall FUN_0051f3b0(int param_1)



{

  int *piVar1;

  int iVar2;

  

  piVar1 = *(int **)(param_1 + 4);

  iVar2 = 0;

  if (piVar1 != (int *)0x0) {

    iVar2 = *piVar1;

    *(int *)(param_1 + 4) = iVar2;

    if (iVar2 == 0) {

      *(undefined4 *)(param_1 + 8) = 0;

    }

    *piVar1 = 0;

    iVar2 = piVar1[1];

    operator_delete(piVar1);

  }

  return iVar2;

}





// --- FUN_0051f3e0 at 0x0051F3E0 (size: 51) ---


void __fastcall FUN_0051f3e0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c8818;

  param_1[1] = 0x8000003d;

  param_1[2] = 0x41000003;

  param_1[3] = 0x3f800000;

  param_1[4] = 0;

  param_1[5] = 0x3f800000;

  param_1[6] = 0;

  param_1[7] = 0x3f800000;

  param_1[8] = 0;

  param_1[9] = 0;

  return;

}





// --- FUN_0051f420 at 0x0051F420 (size: 59) ---


void __fastcall FUN_0051f420(int param_1)



{

  int iVar1;

  int *piVar2;

  

  iVar1 = *(int *)(param_1 + 0x20);

  while (iVar1 != 0) {

    piVar2 = *(int **)(param_1 + 0x20);

    if (piVar2 != (int *)0x0) {

      iVar1 = *piVar2;

      *(int *)(param_1 + 0x20) = iVar1;

      if (iVar1 == 0) {

        *(undefined4 *)(param_1 + 0x24) = 0;

      }

      *piVar2 = 0;

      operator_delete(piVar2);

    }

    iVar1 = *(int *)(param_1 + 0x20);

  }

  return;

}





// --- FUN_0051f460 at 0x0051F460 (size: 142) ---


int __thiscall FUN_0051f460(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  

  FUN_0051f420();

  *(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);

  for (puVar1 = *(undefined4 **)(param_2 + 0x20); puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)*puVar1) {

    puVar2 = (undefined4 *)FUN_005df0f5(0x14);

    if (puVar2 == (undefined4 *)0x0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = puVar1[1];

      puVar2[2] = puVar1[2];

      puVar2[3] = puVar1[3];

      puVar2[4] = puVar1[4];

    }

    if (*(undefined4 **)(param_1 + 0x24) == (undefined4 *)0x0) {

      *(undefined4 **)(param_1 + 0x20) = puVar2;

    }

    else {

      **(undefined4 **)(param_1 + 0x24) = puVar2;

    }

    *(undefined4 **)(param_1 + 0x24) = puVar2;

  }

  return param_1;

}





// --- FUN_0051f4f0 at 0x0051F4F0 (size: 81) ---


void __thiscall

FUN_0051f4f0(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  undefined4 *puVar1;

  

  puVar1 = (undefined4 *)FUN_005df0f5(0x14);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    puVar1[1] = param_2;

    puVar1[2] = param_3;

    *puVar1 = 0;

    puVar1[3] = param_4;

    puVar1[4] = param_5;

  }

  if (*(undefined4 **)(param_1 + 0x24) != (undefined4 *)0x0) {

    **(undefined4 **)(param_1 + 0x24) = puVar1;

    *(undefined4 **)(param_1 + 0x24) = puVar1;

    return;

  }

  *(undefined4 **)(param_1 + 0x20) = puVar1;

  *(undefined4 **)(param_1 + 0x24) = puVar1;

  return;

}





// --- FUN_0051f550 at 0x0051F550 (size: 139) ---


void __thiscall FUN_0051f550(int param_1,uint param_2,int param_3)



{

  if (param_2 == 0x6500000d) {

    *(undefined4 *)(param_1 + 0x18) = 0x6500000d;

    *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(param_3 + 0x14);

  }

  else {

    if (param_2 == 0x6500000f) {

      *(undefined4 *)(param_1 + 0x10) = 0x6500000f;

      *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)(param_3 + 0x14);

      return;

    }

    if ((param_2 & 0x40000000) != 0) {

      *(uint *)(param_1 + 8) = param_2;

      *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_3 + 0x14);

      return;

    }

    if ((int)param_2 < 0) {

      *(undefined4 *)(param_1 + 8) = 0x41000003;

      *(uint *)(param_1 + 4) = param_2;

      return;

    }

    if ((param_2 & 0x10000000) != 0) {

      FUN_0051f4f0(param_2,*(undefined4 *)(param_3 + 0x14),*(undefined4 *)(param_3 + 0x28),

                   *(uint *)(param_3 + 4) >> 0xc & 1);

      return;

    }

  }

  return;

}





// --- FUN_0051f5e0 at 0x0051F5E0 (size: 44) ---


int __fastcall FUN_0051f5e0(int param_1)



{

  int *piVar1;

  int iVar2;

  

  piVar1 = *(int **)(param_1 + 0x20);

  iVar2 = 0;

  if (piVar1 != (int *)0x0) {

    iVar2 = *piVar1;

    *(int *)(param_1 + 0x20) = iVar2;

    if (iVar2 == 0) {

      *(undefined4 *)(param_1 + 0x24) = 0;

    }

    *piVar1 = 0;

    iVar2 = piVar1[1];

    operator_delete(piVar1);

  }

  return iVar2;

}





// --- FUN_0051f610 at 0x0051F610 (size: 24) ---


int __fastcall FUN_0051f610(int param_1)



{

  undefined4 *puVar1;

  int iVar2;

  

  iVar2 = 0;

  for (puVar1 = *(undefined4 **)(param_1 + 0x20); puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)*puVar1) {

    iVar2 = iVar2 + 1;

  }

  return iVar2;

}





// --- FUN_0051f630 at 0x0051F630 (size: 59) ---


void __fastcall FUN_0051f630(int param_1)



{

  int iVar1;

  int *piVar2;

  

  iVar1 = *(int *)(param_1 + 4);

  while (iVar1 != 0) {

    piVar2 = *(int **)(param_1 + 4);

    if (piVar2 != (int *)0x0) {

      iVar1 = *piVar2;

      *(int *)(param_1 + 4) = iVar1;

      if (iVar1 == 0) {

        *(undefined4 *)(param_1 + 8) = 0;

      }

      *piVar2 = 0;

      operator_delete(piVar2);

    }

    iVar1 = *(int *)(param_1 + 4);

  }

  return;

}





// --- FUN_0051f670 at 0x0051F670 (size: 236) ---


void __thiscall FUN_0051f670(int param_1,uint param_2,int param_3)



{

  switch(param_2) {

  case 0x6500000d:

  case 0x6500000e:

    break;

  case 0x6500000f:

  case 0x65000010:

    *(uint *)(param_1 + 0x20) = param_2;

    if ((*(uint *)(param_3 + 4) & 0x800) == 0) {

      *(undefined4 *)(param_1 + 0x24) = *(undefined4 *)(param_3 + 0x24);

      *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(param_3 + 0x14);

      return;

    }

    *(undefined4 *)(param_1 + 0x24) = 0;

    *(undefined4 *)(param_1 + 0x28) = *(undefined4 *)(param_3 + 0x14);

    return;

  default:

    if ((param_2 & 0x40000000) == 0) {

      if ((int)param_2 < 0) {

        if (*(uint *)(param_1 + 0x10) != param_2) {

          *(undefined4 *)(param_1 + 0x14) = 0x41000003;

          *(uint *)(param_1 + 0x10) = param_2;

          return;

        }

      }

      else if ((param_2 & 0x10000000) != 0) {

        FUN_0051f350(param_2,*(undefined4 *)(param_3 + 0x14),*(undefined4 *)(param_3 + 0x28),

                     *(uint *)(param_3 + 4) >> 0xc & 1);

      }

    }

    else if (param_2 != 0x44000007) {

      *(uint *)(param_1 + 0x14) = param_2;

      if ((*(uint *)(param_3 + 4) & 0x800) == 0) {

        *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(param_3 + 0x24);

        *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(param_3 + 0x14);

        return;

      }

      *(undefined4 *)(param_1 + 0x18) = 0;

      *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)(param_3 + 0x14);

      return;

    }

    return;

  }

  *(uint *)(param_1 + 0x2c) = param_2;

  if ((*(uint *)(param_3 + 4) & 0x800) == 0) {

    *(undefined4 *)(param_1 + 0x30) = *(undefined4 *)(param_3 + 0x24);

    *(undefined4 *)(param_1 + 0x34) = *(undefined4 *)(param_3 + 0x14);

    return;

  }

  *(undefined4 *)(param_1 + 0x30) = 0;

  *(undefined4 *)(param_1 + 0x34) = *(undefined4 *)(param_3 + 0x14);

  return;

}





// --- FUN_0051f770 at 0x0051F770 (size: 164) ---


int __thiscall FUN_0051f770(int param_1,int param_2)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  

  FUN_0051f630();

  *(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);

  for (puVar1 = *(undefined4 **)(param_2 + 4); puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)*puVar1) {

    puVar2 = (undefined4 *)FUN_005df0f5(0x14);

    if (puVar2 == (undefined4 *)0x0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = puVar1[1];

      puVar2[2] = puVar1[2];

      puVar2[3] = puVar1[3];

      puVar2[4] = puVar1[4];

    }

    if (*(undefined4 **)(param_1 + 8) == (undefined4 *)0x0) {

      *(undefined4 **)(param_1 + 4) = puVar2;

    }

    else {

      **(undefined4 **)(param_1 + 8) = puVar2;

    }

    *(undefined4 **)(param_1 + 8) = puVar2;

  }

  return param_1;

}





// --- FUN_0051fc90 at 0x0051FC90 (size: 33) ---


undefined4 * __thiscall FUN_0051fc90(undefined4 *param_1,undefined4 param_2)



{

  *param_1 = &PTR_FUN_007c8818;

  param_1[8] = 0;

  param_1[9] = 0;

  FUN_0051f460(param_2);

  return param_1;

}





// --- FUN_0051fcc0 at 0x0051FCC0 (size: 22) ---


void __fastcall FUN_0051fcc0(undefined4 *param_1)



{

  *param_1 = &PTR_FUN_007c8818;

  FUN_0051f420();

  *param_1 = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0051fce0 at 0x0051FCE0 (size: 552) ---


void __thiscall FUN_0051fce0(int param_1,uint *param_2,uint param_3)



{

  undefined4 *puVar1;

  uint uVar2;

  uint uVar3;

  ushort uVar4;

  int iVar5;

  

  uVar2 = 4;

  uVar3 = param_3 ^ (*(int *)(param_1 + 4) != -0x7fffffc3 ^ param_3) & 1;

  if ((uVar3 & 1) != 0) {

    uVar2 = 6;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 8) != 0x41000003) << 1 ^ uVar3) & 2;

  if ((uVar3 & 2) != 0) {

    uVar2 = uVar2 + 2;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 0x10) != 0) << 3 ^ uVar3) & 8;

  if ((uVar3 & 8) != 0) {

    uVar2 = uVar2 + 2;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 0x18) != 0) << 5 ^ uVar3) & 0x20;

  if ((uVar3 & 0x20) != 0) {

    uVar2 = uVar2 + 2;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 0xc) != 0x3f800000) << 2 ^ uVar3) & 4;

  if ((uVar3 & 4) != 0) {

    uVar2 = uVar2 + 4;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 0x14) != 0x3f800000) << 4 ^ uVar3) & 0x10;

  if ((uVar3 & 0x10) != 0) {

    uVar2 = uVar2 + 4;

  }

  uVar3 = uVar3 ^ ((uint)(*(int *)(param_1 + 0x1c) != 0x3f800000) << 6 ^ uVar3) & 0x40;

  if ((uVar3 & 0x40) != 0) {

    uVar2 = uVar2 + 4;

  }

  iVar5 = 0;

  for (puVar1 = *(undefined4 **)(param_1 + 0x20); puVar1 != (undefined4 *)0x0;

      puVar1 = (undefined4 *)*puVar1) {

    uVar2 = uVar2 + 8;

    iVar5 = iVar5 + 1;

  }

  uVar3 = uVar3 ^ (iVar5 << 7 ^ uVar3) & 0xf80;

  if ((uVar2 & 3) == 0) {

    iVar5 = 0;

  }

  else {

    iVar5 = 4 - (uVar2 & 3);

  }

  if (uVar2 + iVar5 <= param_3) {

    if (3 < param_3) {

      *(uint *)*param_2 = uVar3;

      *param_2 = *param_2 + 4;

    }

    if ((uVar3 & 1) != 0) {

      *(undefined2 *)*param_2 = *(undefined2 *)(param_1 + 4);

      *param_2 = *param_2 + 2;

    }

    if ((uVar3 & 2) != 0) {

      *(undefined2 *)*param_2 = *(undefined2 *)(param_1 + 8);

      *param_2 = *param_2 + 2;

    }

    if ((uVar3 & 8) != 0) {

      *(undefined2 *)*param_2 = *(undefined2 *)(param_1 + 0x10);

      *param_2 = *param_2 + 2;

    }

    if ((uVar3 & 0x20) != 0) {

      *(undefined2 *)*param_2 = *(undefined2 *)(param_1 + 0x18);

      *param_2 = *param_2 + 2;

    }

    if ((uVar3 & 4) != 0) {

      *(undefined4 *)*param_2 = *(undefined4 *)(param_1 + 0xc);

      *param_2 = *param_2 + 4;

    }

    if ((uVar3 & 0x10) != 0) {

      *(undefined4 *)*param_2 = *(undefined4 *)(param_1 + 0x14);

      *param_2 = *param_2 + 4;

    }

    if ((uVar3 & 0x40) != 0) {

      *(undefined4 *)*param_2 = *(undefined4 *)(param_1 + 0x1c);

      *param_2 = *param_2 + 4;

    }

    for (puVar1 = *(undefined4 **)(param_1 + 0x20); puVar1 != (undefined4 *)0x0;

        puVar1 = (undefined4 *)*puVar1) {

      if (7 < param_3) {

        uVar4 = *(ushort *)(puVar1 + 3) & 0x7fff;

        if (puVar1[4] != 0) {

          uVar4 = uVar4 | 0x8000;

        }

        *(undefined2 *)*param_2 = *(undefined2 *)(puVar1 + 1);

        uVar2 = *param_2;

        *param_2 = uVar2 + 2;

        *(ushort *)(uVar2 + 2) = uVar4;

        uVar2 = *param_2;

        *param_2 = uVar2 + 2;

        *(undefined4 *)(uVar2 + 2) = puVar1[2];

        *param_2 = *param_2 + 4;

      }

    }

    uVar2 = *param_2 & 0x80000003;

    if ((int)uVar2 < 0) {

      uVar2 = (uVar2 - 1 | 0xfffffffc) + 1;

    }

    if (uVar2 != 0) {

      for (iVar5 = 4 - uVar2; iVar5 != 0; iVar5 = iVar5 + -1) {

        *(undefined1 *)*param_2 = 0;

        *param_2 = *param_2 + 1;

      }

    }

  }

  return;

}





// --- FUN_0051ff10 at 0x0051FF10 (size: 446) ---


undefined4 __thiscall FUN_0051ff10(int param_1,uint *param_2,uint param_3)



{

  ushort uVar1;

  undefined4 *puVar2;

  int iVar3;

  uint uVar4;

  ushort *puVar5;

  

  FUN_0051f420();

  uVar4 = param_3;

  if (3 < param_3) {

    uVar4 = *(uint *)*param_2;

    *param_2 = (uint)((uint *)*param_2 + 1);

  }

  if ((uVar4 & 1) == 0) {

    *(undefined4 *)(param_1 + 4) = 0x8000003d;

  }

  else {

    uVar1 = *(ushort *)*param_2;

    *param_2 = (uint)((ushort *)*param_2 + 1);

    *(undefined4 *)(param_1 + 4) = *(undefined4 *)(&DAT_007c8190 + (uint)uVar1 * 4);

  }

  if ((uVar4 & 2) == 0) {

    *(undefined4 *)(param_1 + 8) = 0x41000003;

  }

  else {

    uVar1 = *(ushort *)*param_2;

    *param_2 = (uint)((ushort *)*param_2 + 1);

    *(undefined4 *)(param_1 + 8) = *(undefined4 *)(&DAT_007c8190 + (uint)uVar1 * 4);

  }

  if ((uVar4 & 8) == 0) {

    *(undefined4 *)(param_1 + 0x10) = 0;

  }

  else {

    uVar1 = *(ushort *)*param_2;

    *param_2 = (uint)((ushort *)*param_2 + 1);

    *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(&DAT_007c8190 + (uint)uVar1 * 4);

  }

  if ((uVar4 & 0x20) == 0) {

    *(undefined4 *)(param_1 + 0x18) = 0;

  }

  else {

    uVar1 = *(ushort *)*param_2;

    *param_2 = (uint)((ushort *)*param_2 + 1);

    *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(&DAT_007c8190 + (uint)uVar1 * 4);

  }

  if ((uVar4 & 4) == 0) {

    *(undefined4 *)(param_1 + 0xc) = 0x3f800000;

  }

  else {

    *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((uVar4 & 0x10) == 0) {

    *(undefined4 *)(param_1 + 0x14) = 0x3f800000;

  }

  else {

    *(undefined4 *)(param_1 + 0x14) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  if ((uVar4 & 0x40) == 0) {

    *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;

  }

  else {

    *(undefined4 *)(param_1 + 0x1c) = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

  }

  for (uVar4 = uVar4 >> 7 & 0x1f; uVar4 != 0; uVar4 = uVar4 - 1) {

    puVar2 = (undefined4 *)FUN_005df0f5(0x14);

    if (puVar2 == (undefined4 *)0x0) {

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = 0;

      puVar2[2] = 0x3f800000;

      puVar2[3] = 0;

      puVar2[4] = 0;

    }

    if (7 < param_3) {

      uVar1 = *(ushort *)*param_2;

      *param_2 = (uint)((ushort *)*param_2 + 1);

      puVar2[1] = *(undefined4 *)(&DAT_007c8190 + (uint)uVar1 * 4);

      puVar5 = (ushort *)*param_2 + 1;

      uVar1 = *(ushort *)*param_2;

      *param_2 = (uint)puVar5;

      puVar2[2] = *(undefined4 *)puVar5;

      *param_2 = *param_2 + 4;

      puVar2[3] = uVar1 & 0x7fff;

      puVar2[4] = (uint)(uVar1 >> 0xf);

    }

    if (*(undefined4 **)(param_1 + 0x24) == (undefined4 *)0x0) {

      *(undefined4 **)(param_1 + 0x20) = puVar2;

    }

    else {

      **(undefined4 **)(param_1 + 0x24) = puVar2;

    }

    *(undefined4 **)(param_1 + 0x24) = puVar2;

  }

  uVar4 = *param_2 & 0x80000003;

  if ((int)uVar4 < 0) {

    uVar4 = (uVar4 - 1 | 0xfffffffc) + 1;

  }

  if (uVar4 != 0) {

    for (iVar3 = 4 - uVar4; iVar3 != 0; iVar3 = iVar3 + -1) {

      *(undefined1 *)*param_2 = 0;

      *param_2 = *param_2 + 1;

    }

  }

  return 1;

}





