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

// --- FUN_00500460 at 0x00500460 (size: 88) ---


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



{

  undefined4 *puVar1;

  LONG LVar2;

  

  *param_1 = &PTR_LAB_007c6da0;

  param_1[0xc] = &PTR_LAB_007c6d88;

  FUN_004ff770();

  puVar1 = (undefined4 *)param_1[0xf];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  param_1[0xc] = &PTR_FUN_0079385c;

  FUN_004154b0();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005004c0 at 0x005004C0 (size: 31) ---


void FUN_005004c0(int param_1)



{

  if (param_1 != 0) {

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

    FUN_00536c10(param_1);

  }

  return;

}





// --- FUN_005004e0 at 0x005004E0 (size: 143) ---


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



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  

  if (param_4 == 0) {

    uVar2 = FUN_005df4c4();

  }

  else {

    uVar2 = 0xffffffff;

    if (*param_3 != 0xffffffff) {

      uVar2 = *param_3;

    }

    uVar1 = param_3[1];

    uVar3 = uVar2;

    if (uVar1 < uVar2) {

      uVar3 = uVar1;

    }

    uVar2 = (uint)(uVar1 < uVar2);

    if (param_3[2] < uVar3) {

      uVar2 = 2;

      uVar3 = param_3[2];

    }

    if (param_3[3] < uVar3) {

      return 3;

    }

  }

  return uVar2;

}





// --- FUN_00500570 at 0x00500570 (size: 147) ---


undefined4 __thiscall FUN_00500570(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  

  if (param_2 < (uint)param_1[2]) {

    return 0;

  }

  if ((uint)param_1[1] < param_2) {

    if (param_2 == 0) {

      param_1[2] = 0;

      param_1[1] = 0;

      operator_delete__((void *)*param_1);

      *param_1 = 0;

      return 1;

    }

    iVar1 = thunk_FUN_005df0f5(param_2 * 4);

    if (iVar1 == 0) {

      return 0;

    }

    if (*param_1 != 0) {

      uVar2 = 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_2;

  }

  return 1;

}





// --- FUN_00500610 at 0x00500610 (size: 71) ---


undefined4 FUN_00500610(uint *param_1,uint *param_2)



{

  uint uVar1;

  

  uVar1 = *param_1 & 0x80000003;

  if ((int)uVar1 < 0) {

    uVar1 = (uVar1 - 1 | 0xfffffffc) + 1;

  }

  if (uVar1 != 0) {

    uVar1 = 4 - uVar1;

    if (*param_2 < uVar1) {

      return 0;

    }

    *param_2 = *param_2 - uVar1;

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

      *(undefined1 *)*param_1 = 0;

      *param_1 = *param_1 + 1;

    }

  }

  return 1;

}





// --- FUN_00500680 at 0x00500680 (size: 17) ---


void __fastcall FUN_00500680(int param_1)



{

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

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

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

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

  return;

}





// --- FUN_005006a0 at 0x005006A0 (size: 373) ---


void __thiscall

FUN_005006a0(int *param_1,uint *param_2,int *param_3,uint param_4,int param_5,int param_6)



{

  undefined4 *puVar1;

  int iVar2;

  uint *puVar3;

  uint uVar4;

  int iVar5;

  undefined4 local_14 [4];

  undefined4 local_4;

  

  uVar4 = *(uint *)(*(int *)(param_1[1] + *param_1 * 4) + 0xc);

  *param_2 = uVar4;

  puVar1 = (undefined4 *)*param_3;

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

    param_1[5] = uVar4;

    uVar4 = *param_2;

    puVar3 = (uint *)thunk_FUN_005df0f5(uVar4 * 0x18 + 4);

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

LAB_00500754:

      puVar3 = (uint *)0x0;

    }

    else {

      *puVar3 = uVar4;

      puVar3 = puVar3 + 1;

      FUN_00401000(puVar3,0x18,uVar4,&LAB_00500660);

    }

  }

  else {

    if (uVar4 <= (uint)param_1[5]) goto LAB_00500759;

    if (puVar1[-1] == 0) {

      operator_delete__(puVar1 + -1);

    }

    else {

      (**(code **)*puVar1)(3);

    }

    uVar4 = *param_2;

    puVar3 = (uint *)thunk_FUN_005df0f5(uVar4 * 0x18 + 4);

    if (puVar3 == (uint *)0x0) goto LAB_00500754;

    *puVar3 = uVar4;

    puVar3 = puVar3 + 1;

    FUN_00401000(puVar3,0x18,uVar4,&LAB_00500660);

  }

  *param_3 = (int)puVar3;

LAB_00500759:

  local_14[0] = *(undefined4 *)(param_5 + (param_4 & 3) * 4);

  local_14[1] = *(undefined4 *)(param_5 + (param_4 + 1 & 3) * 4);

  local_14[2] = *(undefined4 *)(param_5 + (param_4 - 2 & 3) * 4);

  local_14[3] = *(undefined4 *)(param_5 + (param_4 - 1 & 3) * 4);

  uVar4 = 0;

  local_4 = *(undefined4 *)(param_5 + 0x10);

  if (*param_2 != 0) {

    iVar5 = 0;

    do {

      *(undefined4 *)(*param_3 + 4 + iVar5) =

           local_14[*(int *)(*(int *)(*(int *)(*(int *)(*(int *)(param_1[1] + *param_1 * 4) + 0x10)

                                              + param_6 * 4) + 4) + uVar4 * 4)];

      iVar2 = *param_3;

      *(undefined4 *)(iVar2 + iVar5 + 8) =

           **(undefined4 **)(*(int *)(*(int *)(param_1[1] + *param_1 * 4) + 4) + uVar4 * 4);

      *(undefined4 *)(iVar2 + iVar5 + 0xc) =

           *(undefined4 *)

            (*(int *)(*(int *)(*(int *)(param_1[1] + *param_1 * 4) + 4) + uVar4 * 4) + 4);

      uVar4 = uVar4 + 1;

      iVar5 = iVar5 + 0x18;

    } while (uVar4 < *param_2);

  }

  return;

}





// --- FUN_00500880 at 0x00500880 (size: 247) ---


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



{

  int iVar1;

  undefined4 uVar2;

  uint *puVar3;

  uint uVar4;

  int *piVar5;

  int iVar6;

  char cVar7;

  uint *puVar8;

  int iVar9;

  uint local_8;

  

  iVar1 = *(int *)(*(int *)(param_1[1] + *param_1 * 4) + 0x24);

  local_8 = 0;

  puVar8 = param_3;

  do {

    uVar2 = *(undefined4 *)(((int)&DAT_007c6eec - (int)param_3) + (int)puVar8);

    iVar9 = 0;

    if (0 < iVar1) {

      do {

        puVar3 = *(uint **)(*(int *)(*(int *)(param_1[1] + *param_1 * 4) + 0x1c) + iVar9 * 4);

        uVar4 = *puVar3;

        *puVar8 = puVar3[1];

        if ((param_2 >> ((byte)uVar2 & 0x1f) & 0x1f) == uVar4) break;

        iVar9 = iVar9 + 1;

      } while (iVar9 < iVar1);

    }

    if (iVar9 == iVar1) {

      return 0;

    }

    local_8 = local_8 + 1;

    puVar8 = puVar8 + 1;

  } while (local_8 < 4);

  cVar7 = ((param_2 & 0xc000000) != 0) * '\x02';

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

    cVar7 = cVar7 + '\x01';

  }

  cVar7 = cVar7 * '\x02';

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

    cVar7 = cVar7 + '\x01';

  }

  cVar7 = cVar7 * '\x02';

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

    cVar7 = cVar7 + '\x01';

  }

  if (cVar7 != '\0') {

    iVar9 = 0;

    if (0 < iVar1) {

      do {

        piVar5 = *(int **)(*(int *)(*(int *)(param_1[1] + *param_1 * 4) + 0x1c) + iVar9 * 4);

        iVar6 = *piVar5;

        param_3[4] = piVar5[1];

        if (iVar6 == 0x20) break;

        iVar9 = iVar9 + 1;

      } while (iVar9 < iVar1);

    }

    if (iVar9 == iVar1) {

      return 0;

    }

  }

  return 1;

}





// --- FUN_00500980 at 0x00500980 (size: 107) ---


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



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  undefined4 *puVar4;

  int iVar5;

  

  iVar5 = (uint)((param_2 & 0xc000000) != 0) * 2;

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

    iVar5 = iVar5 + 1;

  }

  iVar5 = iVar5 * 2;

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

    iVar5 = iVar5 + 1;

  }

  iVar5 = iVar5 * 2;

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

    iVar5 = iVar5 + 1;

  }

  iVar1 = *(int *)(param_1[1] + *param_1 * 4);

  uVar2 = *(uint *)(iVar1 + 0x18);

  uVar3 = 0;

  if (uVar2 != 0) {

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

    do {

      if (*(int *)*puVar4 == iVar5) {

        *param_3 = uVar3;

        return 1;

      }

      uVar3 = uVar3 + 1;

      puVar4 = puVar4 + 1;

    } while (uVar3 < uVar2);

  }

  return 0;

}





// --- FUN_005009f0 at 0x005009F0 (size: 72) ---


int __fastcall FUN_005009f0(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int *piVar6;

  

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

  iVar3 = 4;

  if (iVar4 != 0) {

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

    do {

      iVar1 = *piVar6;

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

      iVar5 = 8;

      if (iVar2 != 0) {

        iVar5 = iVar2 * 8 + 8;

      }

      iVar5 = iVar5 + 8 + (iVar2 + 1) * *(int *)(iVar1 + 0x18) * 4;

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

        iVar5 = iVar5 + *(int *)(iVar1 + 0x24) * 8;

      }

      iVar3 = iVar3 + iVar5;

      piVar6 = piVar6 + 1;

      iVar4 = iVar4 + -1;

    } while (iVar4 != 0);

  }

  return iVar3;

}





// --- FUN_00500a40 at 0x00500A40 (size: 227) ---


void __fastcall FUN_00500a40(int param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

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

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

        *puVar1 = 0;

        puVar1[1] = 0;

        operator_delete(puVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

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

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

  uVar2 = 0;

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

    do {

      puVar1 = *(undefined4 **)(*(int *)(param_1 + 0x10) + uVar2 * 4);

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

        if ((void *)puVar1[1] != (void *)0x0) {

          operator_delete__((void *)puVar1[1]);

        }

        puVar1[1] = 0;

        *puVar1 = 0;

        operator_delete(puVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x10));

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

  uVar2 = 0;

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

    do {

      puVar1 = *(undefined4 **)(*(int *)(param_1 + 0x1c) + uVar2 * 4);

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

        *puVar1 = 0x1f;

        puVar1[1] = DAT_00842518;

        operator_delete(puVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x1c));

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

  return;

}





// --- FUN_00500b30 at 0x00500B30 (size: 418) ---


uint __thiscall FUN_00500b30(undefined4 *param_1,uint *param_2,uint *param_3)



{

  uint uVar1;

  undefined4 *puVar2;

  uint uVar3;

  uint uVar4;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar1 = param_1[3];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar3 = 0;

  if (uVar1 != 0) {

    do {

      puVar2 = *(undefined4 **)(param_1[1] + uVar3 * 4);

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = *puVar2;

        *param_2 = *param_2 + 4;

        uVar4 = *param_3;

        *param_3 = uVar4 - 4;

        if (3 < uVar4 - 4) {

          *(undefined4 *)*param_2 = puVar2[1];

          *param_2 = *param_2 + 4;

          *param_3 = *param_3 - 4;

        }

      }

      uVar4 = *param_2 & 0x80000003;

      if ((int)uVar4 < 0) {

        uVar4 = (uVar4 - 1 | 0xfffffffc) + 1;

      }

      if (uVar4 != 0) {

        uVar4 = 4 - uVar4;

        if (uVar4 <= *param_3) {

          *param_3 = *param_3 - uVar4;

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

            *(undefined1 *)*param_2 = 0;

            *param_2 = *param_2 + 1;

          }

        }

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < uVar1);

  }

  uVar1 = param_1[6];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar3 = 0;

  if (uVar1 != 0) {

    do {

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = **(undefined4 **)(param_1[4] + uVar3 * 4);

        *param_2 = *param_2 + 4;

        *param_3 = *param_3 - 4;

      }

      uVar4 = 0;

      if (param_1[3] != 0) {

        do {

          if (3 < *param_3) {

            *(undefined4 *)*param_2 =

                 *(undefined4 *)(*(int *)(*(int *)(param_1[4] + uVar3 * 4) + 4) + uVar4 * 4);

            *param_2 = *param_2 + 4;

            *param_3 = *param_3 - 4;

          }

          uVar4 = uVar4 + 1;

        } while (uVar4 < (uint)param_1[3]);

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < uVar1);

  }

  uVar1 = param_1[9];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar3 = 0;

  if (uVar1 != 0) {

    do {

      puVar2 = *(undefined4 **)(param_1[7] + uVar3 * 4);

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = *puVar2;

        *param_2 = *param_2 + 4;

        uVar4 = *param_3;

        *param_3 = uVar4 - 4;

        if (3 < uVar4 - 4) {

          *(undefined4 *)*param_2 = puVar2[1];

          *param_2 = *param_2 + 4;

          *param_3 = *param_3 - 4;

        }

      }

      uVar4 = *param_2 & 0x80000003;

      if ((int)uVar4 < 0) {

        uVar4 = (uVar4 - 1 | 0xfffffffc) + 1;

      }

      if (uVar4 != 0) {

        uVar4 = 4 - uVar4;

        if (uVar4 <= *param_3) {

          *param_3 = *param_3 - uVar4;

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

            *(undefined1 *)*param_2 = 0;

            *param_2 = *param_2 + 1;

          }

        }

      }

      uVar3 = uVar3 + 1;

    } while (uVar3 < uVar1);

  }

  return *param_3;

}





// --- FUN_00500ce0 at 0x00500CE0 (size: 175) ---


void __fastcall FUN_00500ce0(int param_1)



{

  int *piVar1;

  int iVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 uVar5;

  uint local_20;

  

  local_20 = 0;

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

    do {

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

      if (*piVar1 != DAT_00842518) {

        uVar5 = 8;

        uVar3 = FUN_004220b0(*piVar1,0);

        FUN_0041a4e0(uVar3,uVar5);

      }

      uVar4 = 0;

      if (piVar1[9] != 0) {

        do {

          iVar2 = *(int *)(*(int *)(piVar1[7] + uVar4 * 4) + 4);

          if (iVar2 != DAT_00842518) {

            uVar5 = 8;

            uVar3 = FUN_004220b0(iVar2,0);

            FUN_0041a4e0(uVar3,uVar5);

          }

          uVar4 = uVar4 + 1;

        } while (uVar4 < (uint)piVar1[9]);

      }

      local_20 = local_20 + 1;

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

  }

  return;

}





// --- FUN_00500d90 at 0x00500D90 (size: 261) ---


undefined4 __thiscall

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

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



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  uint uVar4;

  uint local_8;

  

  uVar1 = FUN_005df4c4();

  uVar4 = uVar1;

  local_8 = uVar1;

  do {

    *param_1 = uVar4;

    iVar2 = FUN_00500880(*param_5,param_7);

    if (iVar2 != 0) {

      uVar3 = FUN_005004e0(param_2,param_3,param_5,param_9);

      uVar4 = uVar3;

      do {

        iVar2 = FUN_00500980(param_5[uVar4],param_8);

        if (iVar2 != 0) {

          *param_4 = uVar4;

          return param_5[uVar4];

        }

        uVar4 = uVar4 + 1 & 3;

      } while (uVar4 != uVar3);

      uVar4 = (local_8 + 1) % param_1[3];

      local_8 = uVar4;

    }

  } while (uVar4 != uVar1);

  *param_1 = 0;

  *param_4 = 0;

  return *param_5;

}





// --- FUN_00500ea0 at 0x00500EA0 (size: 115) ---


undefined4 __thiscall

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

            undefined4 param_5)



{

  undefined4 uVar1;

  int iVar2;

  undefined4 uVar3;

  

  uVar1 = **(undefined4 **)(param_1[1] + *param_1 * 4);

  FUN_005006a0(&param_5,param_1 + 4,param_3,param_4,param_5);

  iVar2 = FUN_0053efe0();

  if (iVar2 != 0) {

    FUN_0053ef90(param_5,param_1[4]);

  }

  uVar3 = FUN_00536fb0(2);

  FUN_00537020(uVar1,1);

  FUN_00536c60(iVar2);

  FUN_00537140(0);

  return uVar3;

}





// --- FUN_00500f20 at 0x00500F20 (size: 77) ---


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



{

  uint uVar1;

  uint uVar2;

  

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

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

  if (uVar1 != 0) {

    do {

      FUN_00500b30(param_2,param_3);

      uVar2 = uVar2 + 1;

    } while (uVar2 < uVar1);

  }

  return *param_3;

}





// --- FUN_00500f70 at 0x00500F70 (size: 773) ---


undefined4 __thiscall FUN_00500f70(undefined4 *param_1,uint *param_2,uint *param_3)



{

  uint *puVar1;

  uint *puVar2;

  uint *puVar3;

  undefined4 *puVar4;

  int iVar5;

  undefined4 uVar6;

  uint uVar7;

  uint *puVar8;

  undefined4 *puVar9;

  

  puVar2 = param_3;

  puVar1 = param_2;

  if (3 < *param_3) {

    uVar6 = *(undefined4 *)*param_2;

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

    *param_3 = *param_3 - 4;

    *param_1 = uVar6;

    if (3 < *param_3) {

      puVar8 = *(uint **)*param_2;

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

      *param_3 = *param_3 - 4;

      param_3 = puVar8;

    }

  }

  if ((param_3 != (uint *)0x0) && (FUN_00500570(param_3), param_3 != (uint *)0x0)) {

    param_2 = param_3;

    do {

      puVar4 = (undefined4 *)FUN_005df0f5(8);

      puVar9 = (undefined4 *)0x0;

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

        *puVar4 = 0;

        puVar4[1] = 0;

        puVar9 = puVar4;

      }

      if (3 < *puVar2) {

        *puVar9 = *(undefined4 *)*puVar1;

        *puVar1 = *puVar1 + 4;

        uVar7 = *puVar2;

        *puVar2 = uVar7 - 4;

        if (3 < uVar7 - 4) {

          puVar9[1] = *(undefined4 *)*puVar1;

          *puVar1 = *puVar1 + 4;

          *puVar2 = *puVar2 - 4;

        }

      }

      uVar7 = *puVar1 & 0x80000003;

      if ((int)uVar7 < 0) {

        uVar7 = (uVar7 - 1 | 0xfffffffc) + 1;

      }

      if (uVar7 != 0) {

        uVar7 = 4 - uVar7;

        if (uVar7 <= *puVar2) {

          *puVar2 = *puVar2 - uVar7;

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

            *(undefined1 *)*puVar1 = 0;

            *puVar1 = *puVar1 + 1;

          }

        }

      }

      uVar7 = param_1[2];

      if ((uint)param_1[3] < uVar7) {

LAB_0050106e:

        *(undefined4 **)(param_1[1] + param_1[3] * 4) = puVar9;

        param_1[3] = param_1[3] + 1;

      }

      else {

        if (uVar7 == 0) {

          iVar5 = 8;

        }

        else {

          iVar5 = uVar7 * 2;

        }

        iVar5 = FUN_00500570(iVar5);

        if (iVar5 != 0) goto LAB_0050106e;

      }

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

    } while (param_2 != (uint *)0x0);

    param_2 = (uint *)0x0;

  }

  if (3 < *puVar2) {

    param_3 = *(uint **)*puVar1;

    *puVar1 = (uint)((undefined4 *)*puVar1 + 1);

    *puVar2 = *puVar2 - 4;

  }

  FUN_00500570(param_3);

  puVar8 = param_3;

  puVar3 = param_3;

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

    do {

      param_2 = puVar3;

      puVar4 = (undefined4 *)FUN_005df0f5(8);

      puVar9 = (undefined4 *)0x0;

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

        *puVar4 = 0;

        puVar4[1] = 0;

        puVar9 = puVar4;

      }

      if (3 < *puVar2) {

        *puVar9 = *(undefined4 *)*puVar1;

        *puVar1 = *puVar1 + 4;

        *puVar2 = *puVar2 - 4;

      }

      uVar6 = thunk_FUN_005df0f5(param_1[3] * 4);

      puVar9[1] = uVar6;

      uVar7 = 0;

      if (param_1[3] != 0) {

        do {

          if (3 < *puVar2) {

            puVar8 = *(uint **)*puVar1;

            *puVar1 = (uint)((undefined4 *)*puVar1 + 1);

            *puVar2 = *puVar2 - 4;

          }

          *(uint **)(puVar9[1] + uVar7 * 4) = puVar8;

          uVar7 = uVar7 + 1;

        } while (uVar7 < (uint)param_1[3]);

      }

      uVar7 = param_1[5];

      if ((uint)param_1[6] < uVar7) {

LAB_00501155:

        *(undefined4 **)(param_1[4] + param_1[6] * 4) = puVar9;

        param_1[6] = param_1[6] + 1;

      }

      else {

        if (uVar7 == 0) {

          iVar5 = 8;

        }

        else {

          iVar5 = uVar7 * 2;

        }

        iVar5 = FUN_00500570(iVar5);

        if (iVar5 != 0) goto LAB_00501155;

      }

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

    } while ((uint *)((int)param_2 + -1) != (uint *)0x0);

    param_2 = (uint *)0x0;

  }

  if (3 < *puVar2) {

    param_3 = *(uint **)*puVar1;

    *puVar1 = (uint)((undefined4 *)*puVar1 + 1);

    *puVar2 = *puVar2 - 4;

  }

  if ((param_3 != (uint *)0x0) && (FUN_00500570(param_3), param_3 != (uint *)0x0)) {

    do {

      puVar4 = (undefined4 *)FUN_005df0f5(8);

      puVar9 = (undefined4 *)0x0;

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

        *puVar4 = 0x1f;

        puVar4[1] = 0;

        puVar9 = puVar4;

      }

      if (3 < *puVar2) {

        param_2 = *(uint **)*puVar1;

        *puVar1 = (uint)((undefined4 *)*puVar1 + 1);

        *puVar2 = *puVar2 - 4;

      }

      *puVar9 = param_2;

      if (3 < *puVar2) {

        uVar6 = *(undefined4 *)*puVar1;

        *puVar1 = (uint)((undefined4 *)*puVar1 + 1);

        *puVar2 = *puVar2 - 4;

        puVar9[1] = uVar6;

      }

      uVar7 = *puVar1 & 0x80000003;

      if ((int)uVar7 < 0) {

        uVar7 = (uVar7 - 1 | 0xfffffffc) + 1;

      }

      if (uVar7 != 0) {

        uVar7 = 4 - uVar7;

        if (uVar7 <= *puVar2) {

          *puVar2 = *puVar2 - uVar7;

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

            *(undefined1 *)*puVar1 = 0;

            *puVar1 = *puVar1 + 1;

          }

        }

      }

      uVar7 = param_1[8];

      if ((uint)param_1[9] < uVar7) {

LAB_00501253:

        *(undefined4 **)(param_1[7] + param_1[9] * 4) = puVar9;

        param_1[9] = param_1[9] + 1;

      }

      else {

        if (uVar7 == 0) {

          iVar5 = 8;

        }

        else {

          iVar5 = uVar7 * 2;

        }

        iVar5 = FUN_00500570(iVar5);

        if (iVar5 != 0) goto LAB_00501253;

      }

      param_3 = (uint *)((int)param_3 + -1);

    } while (param_3 != (uint *)0x0);

  }

  return 1;

}





// --- FUN_00501280 at 0x00501280 (size: 146) ---


void __fastcall FUN_00501280(int param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  uint uVar3;

  

  uVar3 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 4) + uVar3 * 4);

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

        FUN_00500a40();

        operator_delete__(*(void **)((int)pvVar1 + 0x1c));

        operator_delete__(*(void **)((int)pvVar1 + 0x10));

        operator_delete__(*(void **)((int)pvVar1 + 4));

        operator_delete(pvVar1);

      }

      uVar3 = uVar3 + 1;

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

  }

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

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

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

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

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

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

    if (puVar2[-1] != 0) {

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

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

      return;

    }

    operator_delete__(puVar2 + -1);

  }

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

  return;

}





// --- FUN_00501320 at 0x00501320 (size: 259) ---


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



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  uint *puVar4;

  uint *local_8;

  

  puVar4 = param_3;

  if (3 < *param_3) {

    puVar4 = *(uint **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_00501280();

  if (puVar4 != (uint *)0x0) {

    FUN_00500570(puVar4);

  }

  local_8 = (uint *)0x0;

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

    return 1;

  }

  do {

    puVar2 = (undefined4 *)FUN_005df0f5(0x28);

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

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = 0;

      puVar2[2] = 0;

      puVar2[3] = 0;

      puVar2[4] = 0;

      puVar2[5] = 0;

      puVar2[6] = 0;

      puVar2[7] = 0;

      puVar2[8] = 0;

      puVar2[9] = 0;

    }

    iVar3 = FUN_00500f70(param_2,param_3);

    if (iVar3 == 0) {

      return 0;

    }

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

    if (*(uint *)(param_1 + 0xc) < uVar1) {

LAB_005013ec:

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

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

    }

    else {

      if (uVar1 == 0) {

        iVar3 = 8;

      }

      else {

        iVar3 = uVar1 * 2;

      }

      iVar3 = FUN_00500570(iVar3);

      if (iVar3 != 0) goto LAB_005013ec;

    }

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

    if (puVar4 <= local_8) {

      return 1;

    }

  } while( true );

}





// --- FUN_00501430 at 0x00501430 (size: 22) ---


void __fastcall FUN_00501430(int param_1)



{

  FUN_00501280();

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

  return;

}





// --- FUN_00501450 at 0x00501450 (size: 114) ---


void __fastcall FUN_00501450(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  

  puVar1 = (undefined4 *)param_1[3];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[2];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)param_1[1];

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  puVar1 = (undefined4 *)*param_1;

  LVar2 = InterlockedDecrement(puVar1 + 1);

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

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

  }

  return;

}





// --- FUN_005014d0 at 0x005014D0 (size: 84) ---


void __fastcall FUN_005014d0(undefined4 *param_1)



{

  operator_delete__((void *)*param_1);

  param_1[5] = 0;

  param_1[6] = 0;

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[7] = 0;

  param_1[9] = DAT_0084253c;

  param_1[10] = DAT_0084253c;

  param_1[8] = 0;

  return;

}





// --- FUN_00501530 at 0x00501530 (size: 151) ---


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



undefined4 __thiscall

FUN_00501530(int param_1,float param_2,undefined4 *param_3,undefined4 *param_4,float *param_5)



{

  int iVar1;

  float *pfVar2;

  uint uVar3;

  undefined4 *puVar4;

  

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

  if (iVar1 == 0) {

    return 0;

  }

  uVar3 = 0;

  if (iVar1 != 1) {

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

    do {

      puVar4 = puVar4 + 1;

      if (param_2 < *(float *)*puVar4) break;

      uVar3 = uVar3 + 1;

    } while (uVar3 < iVar1 - 1U);

  }

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

  if (uVar3 == *(int *)(param_1 + 0x10) - 1U) {

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

    *param_5 = (param_2 - *(float *)*param_3) / (_DAT_007938b0 - *(float *)*param_3);

    return 1;

  }

  pfVar2 = (float *)(*(undefined4 **)(param_1 + 8))[uVar3 + 1];

  *param_4 = pfVar2;

  *param_5 = (param_2 - *(float *)*param_3) / (*pfVar2 - *(float *)*param_3);

  return 1;

}





// --- FUN_005015d0 at 0x005015D0 (size: 36) ---


void __fastcall FUN_005015d0(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[2] = 0;

  param_1[3] = 0x40080000;

  param_1[4] = 0;

  param_1[5] = 0x40340000;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  return;

}





// --- FUN_00501600 at 0x00501600 (size: 608) ---


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



void FUN_00501600(float param_1,float *param_2,undefined1 *param_3,float *param_4,

                 undefined1 *param_5)



{

  float fVar1;

  uint uVar2;

  undefined1 uVar3;

  undefined1 uVar4;

  int iVar5;

  float10 fVar6;

  float10 fVar7;

  float10 fVar8;

  float10 fVar9;

  int local_14;

  uint local_10;

  float local_c;

  float local_8;

  float local_4;

  

  iVar5 = FUN_00501530(param_1,&local_14,&local_10,&param_1);

  uVar2 = local_10;

  if (iVar5 != 0) {

    *param_2 = (*(float *)(local_10 + 0x14) - *(float *)(local_14 + 0x14)) * param_1 +

               *(float *)(local_14 + 0x14);

    param_2 = (float *)(uint)*(byte *)(local_10 + 0x19);

    uVar3 = FUN_005df4c4();

    param_2 = (float *)(uint)*(byte *)(local_10 + 0x18);

    uVar4 = FUN_005df4c4();

    local_10 = (uint)*(byte *)(local_10 + 0x1a);

    param_2 = (float *)CONCAT31(param_2._1_3_,uVar4);

    uVar4 = FUN_005df4c4();

    param_3[2] = uVar4;

    param_3[1] = uVar3;

    *param_3 = param_2._0_1_;

    param_3[3] = 0xff;

    fVar9 = ((float10)*(float *)(uVar2 + 4) - (float10)*(float *)(local_14 + 4)) * (float10)param_1

            + (float10)*(float *)(local_14 + 4);

    fVar1 = ((*(float *)(uVar2 + 0xc) - *(float *)(local_14 + 0xc)) * param_1 +

            *(float *)(local_14 + 0xc)) * (float)_DAT_0079c6b0;

    fVar6 = (((float10)*(float *)(uVar2 + 8) - (float10)*(float *)(local_14 + 8)) * (float10)param_1

            + (float10)*(float *)(local_14 + 8)) * (float10)_DAT_0079c6b0;

    fVar7 = (float10)fcos((float10)fVar1);

    fVar8 = (float10)fsin(fVar6);

    local_c = (float)(fVar9 * fVar8 * fVar7);

    fVar6 = (float10)fcos(fVar6);

    *param_4 = local_c;

    local_8 = (float)(fVar9 * fVar6 * fVar7);

    fVar6 = (float10)fsin((float10)fVar1);

    param_4[1] = local_8;

    local_4 = (float)(fVar6 * fVar9);

    param_4[2] = local_4;

    param_2 = (float *)(uint)*(byte *)(uVar2 + 0x11);

    uVar3 = FUN_005df4c4();

    param_2 = (float *)(uint)*(byte *)(uVar2 + 0x10);

    uVar4 = FUN_005df4c4();

    param_3 = (undefined1 *)(uint)*(byte *)(uVar2 + 0x12);

    param_2 = (float *)CONCAT31(param_2._1_3_,uVar4);

    uVar4 = FUN_005df4c4();

    param_5[2] = uVar4;

    param_5[1] = uVar3;

    *param_5 = param_2._0_1_;

    param_5[3] = 0xff;

    return;

  }

  *param_2 = 0.3;

  param_3[2] = 0xff;

  param_3[1] = 0xff;

  *param_3 = 0xff;

  param_3[3] = 0xff;

  param_5[2] = 0xff;

  param_5[1] = 0xff;

  *param_5 = 0xff;

  param_5[3] = 0xff;

  *param_4 = 0.5;

  param_4[1] = 0.0;

  param_4[2] = 0.8;

  return;

}





// --- FUN_00501860 at 0x00501860 (size: 304) ---


undefined4 FUN_00501860(uint param_1,float *param_2,float *param_3,undefined1 *param_4)



{

  undefined1 uVar1;

  undefined1 uVar2;

  int iVar3;

  float local_8;

  int local_4;

  

  iVar3 = FUN_00501530(param_1,&param_1,&local_4,&local_8);

  if ((((iVar3 != 0) && (param_1 != 0)) && (*(int *)(param_1 + 0x1c) != 0)) &&

     ((local_4 != 0 && (*(int *)(local_4 + 0x1c) != 0)))) {

    *param_2 = (*(float *)(local_4 + 0x20) - *(float *)(param_1 + 0x20)) * local_8 +

               *(float *)(param_1 + 0x20);

    *param_3 = (*(float *)(local_4 + 0x24) - *(float *)(param_1 + 0x24)) * local_8 +

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

    param_1 = (uint)*(byte *)(local_4 + 0x29);

    uVar1 = FUN_005df4c4();

    param_1 = (uint)*(byte *)(local_4 + 0x28);

    uVar2 = FUN_005df4c4();

    param_1 = CONCAT31(param_1._1_3_,uVar2);

    param_2 = (float *)(uint)*(byte *)(local_4 + 0x2a);

    uVar2 = FUN_005df4c4();

    param_4[1] = uVar1;

    param_4[2] = uVar2;

    *param_4 = (undefined1)param_1;

    param_4[3] = 0xff;

    return 1;

  }

  return 0;

}





// --- FUN_00501990 at 0x00501990 (size: 131) ---


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



void __fastcall FUN_00501990(uint *param_1)



{

  float fVar1;

  float fVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  int iVar6;

  

  if (DAT_008ee9c8 == 0) {

    iVar4 = 0;

    iVar6 = 0;

    iVar3 = 0;

  }

  else {

    iVar4 = *(int *)(DAT_008ee9c8 + 0x68);

    iVar6 = *(int *)(DAT_008ee9c8 + 0x10);

    iVar3 = *(int *)(DAT_008ee9c8 + 100);

  }

  iVar4 = (iVar3 * iVar6 + iVar4) * 0x6a42fdb2 + -0x7541e9ae;

  fVar1 = (float)iVar4;

  if (iVar4 < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  fVar2 = (float)(int)param_1[8];

  if ((int)param_1[8] < 0) {

    fVar2 = fVar2 + _DAT_0079920c;

  }

  floor((double)(fVar2 * fVar1 * _DAT_007c6f10));

  uVar5 = FUN_005df4c4();

  *param_1 = uVar5;

  if (param_1[8] <= uVar5) {

    *param_1 = 0;

  }

  return;

}





// --- FUN_00501a20 at 0x00501A20 (size: 253) ---


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



{

  uint uVar1;

  

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

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

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

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

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

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

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

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

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

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

              *param_2 = *param_2 + 4;

              uVar1 = *param_3;

              *param_3 = uVar1 - 4;

              if (3 < uVar1 - 4) {

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

                *param_2 = *param_2 + 4;

                uVar1 = *param_3;

                *param_3 = uVar1 - 4;

                if (3 < uVar1 - 4) {

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

                  *param_2 = *param_2 + 4;

                  uVar1 = *param_3;

                  *param_3 = uVar1 - 4;

                  if (3 < uVar1 - 4) {

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

                    *param_2 = *param_2 + 4;

                    *param_3 = *param_3 - 4;

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  FUN_00500610(param_2,param_3);

  return *param_3;

}





// --- FUN_00501b20 at 0x00501B20 (size: 244) ---


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



{

  uint uVar1;

  undefined4 uVar2;

  

  FUN_005014d0();

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

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

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

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

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

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

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

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

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

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

              *param_2 = *param_2 + 4;

              *param_3 = *param_3 - 4;

            }

          }

        }

      }

    }

  }

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

  if (3 < *param_3) {

    uVar2 = *(undefined4 *)*param_2;

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

    *param_3 = *param_3 - 4;

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

    if (3 < *param_3) {

      uVar2 = *(undefined4 *)*param_2;

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

      *param_3 = *param_3 - 4;

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

      if (3 < *param_3) {

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

        *param_2 = *param_2 + 4;

        *param_3 = *param_3 - 4;

      }

    }

  }

  FUN_00500610(param_2,param_3);

  return 1;

}





// --- FUN_00501c20 at 0x00501C20 (size: 168) ---


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



{

  uint uVar1;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      *(undefined4 *)*param_2 = param_1[2];

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        *(undefined4 *)*param_2 = param_1[3];

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          *(undefined4 *)*param_2 = param_1[4];

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            *(undefined4 *)*param_2 = param_1[5];

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              *(undefined4 *)*param_2 = param_1[6];

              *param_2 = *param_2 + 4;

              *param_3 = *param_3 - 4;

            }

          }

        }

      }

    }

  }

  FUN_00500610(param_2,param_3);

  return *param_3;

}





// --- FUN_00501cd0 at 0x00501CD0 (size: 167) ---


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



{

  uint uVar1;

  undefined4 uVar2;

  

  if (3 < *param_3) {

    *param_1 = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      uVar2 = *(undefined4 *)*param_2;

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

      *param_3 = *param_3 - 4;

      param_1[2] = uVar2;

      if (3 < *param_3) {

        param_1[3] = *(undefined4 *)*param_2;

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          param_1[4] = *(undefined4 *)*param_2;

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            param_1[5] = *(undefined4 *)*param_2;

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              param_1[6] = *(undefined4 *)*param_2;

              *param_2 = *param_2 + 4;

              *param_3 = *param_3 - 4;

            }

          }

        }

      }

    }

  }

  FUN_00500610(param_2,param_3);

  return 1;

}





// --- FUN_00501d80 at 0x00501D80 (size: 88) ---


void __fastcall FUN_00501d80(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 0x2c) + uVar2 * 4);

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

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x2c));

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

  operator_delete__(*(void **)(param_1 + 0x2c));

  return;

}





// --- FUN_00501de0 at 0x00501DE0 (size: 367) ---


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



{

  uint uVar1;

  uint uVar2;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      *(undefined4 *)*param_2 = param_1[1];

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        *(undefined4 *)*param_2 = param_1[2];

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          *(undefined4 *)*param_2 = param_1[3];

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            *(undefined4 *)*param_2 = param_1[4];

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              *(undefined4 *)*param_2 = param_1[5];

              *param_2 = *param_2 + 4;

              uVar1 = *param_3;

              *param_3 = uVar1 - 4;

              if (3 < uVar1 - 4) {

                *(undefined4 *)*param_2 = param_1[6];

                *param_2 = *param_2 + 4;

                uVar1 = *param_3;

                *param_3 = uVar1 - 4;

                if (3 < uVar1 - 4) {

                  *(undefined4 *)*param_2 = param_1[8];

                  *param_2 = *param_2 + 4;

                  uVar1 = *param_3;

                  *param_3 = uVar1 - 4;

                  if (3 < uVar1 - 4) {

                    *(undefined4 *)*param_2 = param_1[9];

                    *param_2 = *param_2 + 4;

                    uVar1 = *param_3;

                    *param_3 = uVar1 - 4;

                    if (3 < uVar1 - 4) {

                      *(undefined4 *)*param_2 = param_1[10];

                      *param_2 = *param_2 + 4;

                      uVar1 = *param_3;

                      *param_3 = uVar1 - 4;

                      if (3 < uVar1 - 4) {

                        *(undefined4 *)*param_2 = param_1[7];

                        *param_2 = *param_2 + 4;

                        *param_3 = *param_3 - 4;

                      }

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  FUN_00500610(param_2,param_3);

  uVar1 = param_1[0xd];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

  if (uVar1 != 0) {

    do {

      FUN_00501c20(param_2,param_3);

      uVar2 = uVar2 + 1;

    } while (uVar2 < uVar1);

  }

  return *param_3;

}





// --- FUN_00501f50 at 0x00501F50 (size: 225) ---


void __fastcall FUN_00501f50(int param_1)



{

  int iVar1;

  int iVar2;

  int iVar3;

  undefined4 uVar4;

  uint uVar5;

  undefined4 uVar6;

  undefined4 local_24;

  undefined4 local_20;

  

  local_20 = 0;

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

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0x18) + local_20 * 4);

      uVar5 = 0;

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

        do {

          iVar2 = *(int *)(*(int *)(*(int *)(iVar1 + 0x14) + uVar5 * 4) + 0x24);

          if (iVar2 != DAT_0084253c) {

            uVar6 = 8;

            uVar4 = FUN_004220b0(iVar2,0);

            FUN_0041a4e0(uVar4,uVar6);

          }

          uVar5 = uVar5 + 1;

        } while (uVar5 < *(uint *)(iVar1 + 0x1c));

      }

      local_24 = 0;

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

        do {

          iVar2 = *(int *)(*(int *)(iVar1 + 8) + local_24 * 4);

          uVar5 = 0;

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

            do {

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

              if (iVar3 != DAT_0084253c) {

                uVar6 = 8;

                uVar4 = FUN_004220b0(iVar3,0);

                FUN_0041a4e0(uVar4,uVar6);

              }

              uVar5 = uVar5 + 1;

            } while (uVar5 < *(uint *)(iVar2 + 0x34));

          }

          local_24 = local_24 + 1;

        } while (local_24 < *(uint *)(iVar1 + 0x10));

      }

      local_20 = local_20 + 1;

    } while (local_20 < *(uint *)(param_1 + 0x20));

  }

  return;

}





// --- FUN_00502040 at 0x00502040 (size: 184) ---


undefined4 __thiscall FUN_00502040(int *param_1,uint param_2)



{

  uint *puVar1;

  uint *puVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  

  if ((uint)param_1[2] <= param_2) {

    if (param_2 <= (uint)param_1[1]) {

      return 1;

    }

    if (param_2 == 0) {

      FUN_005225d0();

      return 1;

    }

    puVar2 = (uint *)thunk_FUN_005df0f5(param_2 * 0x2c + 4);

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

      puVar1 = puVar2 + 1;

      *puVar2 = param_2;

      FUN_00401000(puVar1,0x2c,param_2,FUN_0050a140);

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

        if (*param_1 != 0) {

          uVar5 = 0;

          if (param_1[2] != 0) {

            iVar3 = 0;

            do {

              puVar6 = (undefined4 *)(*param_1 + iVar3);

              puVar7 = (undefined4 *)(iVar3 + (int)puVar1);

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

                *puVar7 = *puVar6;

                puVar6 = puVar6 + 1;

                puVar7 = puVar7 + 1;

              }

              uVar5 = uVar5 + 1;

              iVar3 = iVar3 + 0x2c;

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

          }

          if (*param_1 != 0) {

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

          }

        }

        *param_1 = (int)puVar1;

        param_1[1] = param_2;

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_00502100 at 0x00502100 (size: 462) ---


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



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  uint *puVar4;

  undefined4 *puVar5;

  

  if (3 < *param_3) {

    *param_1 = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      param_1[1] = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        param_1[2] = *(undefined4 *)*param_2;

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          param_1[3] = *(undefined4 *)*param_2;

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            param_1[4] = *(undefined4 *)*param_2;

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              param_1[5] = *(undefined4 *)*param_2;

              *param_2 = *param_2 + 4;

              uVar1 = *param_3;

              *param_3 = uVar1 - 4;

              if (3 < uVar1 - 4) {

                param_1[6] = *(undefined4 *)*param_2;

                *param_2 = *param_2 + 4;

                uVar1 = *param_3;

                *param_3 = uVar1 - 4;

                if (3 < uVar1 - 4) {

                  param_1[8] = *(undefined4 *)*param_2;

                  *param_2 = *param_2 + 4;

                  uVar1 = *param_3;

                  *param_3 = uVar1 - 4;

                  if (3 < uVar1 - 4) {

                    param_1[9] = *(undefined4 *)*param_2;

                    *param_2 = *param_2 + 4;

                    uVar1 = *param_3;

                    *param_3 = uVar1 - 4;

                    if (3 < uVar1 - 4) {

                      param_1[10] = *(undefined4 *)*param_2;

                      *param_2 = *param_2 + 4;

                      uVar1 = *param_3;

                      *param_3 = uVar1 - 4;

                      if (3 < uVar1 - 4) {

                        param_1[7] = *(undefined4 *)*param_2;

                        *param_2 = *param_2 + 4;

                        *param_3 = *param_3 - 4;

                      }

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  FUN_00500610(param_2,param_3);

  puVar4 = param_3;

  if (3 < *param_3) {

    puVar4 = *(uint **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_00500570(puVar4);

  do {

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

      return *param_3;

    }

    puVar2 = (undefined4 *)FUN_005df0f5(0x1c);

    puVar5 = (undefined4 *)0x0;

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

      *puVar2 = 0;

      puVar2[1] = 0;

      puVar2[2] = 0;

      puVar2[3] = 0;

      puVar2[5] = 0;

      puVar2[6] = 0;

      puVar2[4] = 0xbf800000;

      puVar5 = puVar2;

    }

    FUN_00501cd0(param_2,param_3);

    uVar1 = param_1[0xc];

    if ((uint)param_1[0xd] < uVar1) {

LAB_005022b4:

      *(undefined4 **)(param_1[0xb] + param_1[0xd] * 4) = puVar5;

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

    }

    else {

      if (uVar1 == 0) {

        iVar3 = 8;

      }

      else {

        iVar3 = uVar1 * 2;

      }

      iVar3 = FUN_00500570(iVar3);

      if (iVar3 != 0) goto LAB_005022b4;

    }

    puVar4 = (uint *)((int)puVar4 + -1);

  } while( true );

}





// --- FUN_005022d0 at 0x005022D0 (size: 232) ---


void __fastcall FUN_005022d0(int param_1)



{

  void *pvVar1;

  undefined4 *puVar2;

  uint uVar3;

  

  uVar3 = 0;

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

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

    do {

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

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

        FUN_00501d80();

        operator_delete(pvVar1);

      }

      uVar3 = uVar3 + 1;

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

  }

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

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

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

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

  uVar3 = 0;

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

    do {

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

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

        operator_delete__((void *)*puVar2);

        puVar2[5] = 0;

        puVar2[6] = 0;

        *puVar2 = 0;

        puVar2[1] = 0;

        puVar2[2] = 0;

        puVar2[3] = 0;

        puVar2[4] = 0;

        puVar2[7] = 0;

        puVar2[9] = DAT_0084253c;

        puVar2[10] = DAT_0084253c;

        puVar2[8] = 0;

        operator_delete(puVar2);

      }

      uVar3 = uVar3 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x14));

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

  return;

}





// --- FUN_005023c0 at 0x005023C0 (size: 132) ---


int __fastcall FUN_005023c0(int *param_1)



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int *piVar6;

  

  uVar1 = *(int *)(*param_1 + 8) - 1;

  iVar3 = 0;

  if (0xfffe < uVar1) {

    iVar3 = 4;

  }

  uVar1 = iVar3 + 2 + uVar1;

  uVar2 = uVar1 & 3;

  if (uVar2 == 0) {

    iVar3 = 0;

  }

  else {

    iVar3 = 4 - uVar2;

  }

  uVar1 = iVar3 + 4 + uVar1;

  uVar2 = uVar1 & 3;

  if (uVar2 == 0) {

    iVar3 = 0;

  }

  else {

    iVar3 = 4 - uVar2;

  }

  iVar3 = uVar1 + 4 + iVar3;

  iVar5 = param_1[4];

  if (iVar5 != 0) {

    piVar6 = (int *)param_1[2];

    do {

      iVar4 = 0x30;

      if (*(int *)(*piVar6 + 0x34) != 0) {

        iVar4 = (*(int *)(*piVar6 + 0x34) * 3 + 6) * 8;

      }

      iVar3 = iVar3 + iVar4;

      piVar6 = piVar6 + 1;

      iVar5 = iVar5 + -1;

    } while (iVar5 != 0);

  }

  iVar3 = iVar3 + 4;

  if (param_1[7] != 0) {

    iVar3 = iVar3 + param_1[7] * 0x24;

  }

  return iVar3;

}





// --- FUN_00502450 at 0x00502450 (size: 166) ---


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



{

  int iVar1;

  uint uVar2;

  

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  iVar1 = FUN_004fd290(param_2,*param_3);

  *param_3 = *param_3 - iVar1;

  FUN_00500610(param_2,param_3);

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

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

    do {

      FUN_00501a20(param_2,param_3);

      uVar2 = uVar2 + 1;

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

  }

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

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

    do {

      FUN_00501de0(param_2,param_3);

      uVar2 = uVar2 + 1;

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

  }

  return *param_3;

}





// --- FUN_00502500 at 0x00502500 (size: 61) ---


uint __fastcall FUN_00502500(int param_1)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0x14;

  for (iVar2 = *(int *)(param_1 + 0x20); iVar2 != 0; iVar2 = iVar2 + -1) {

    iVar1 = FUN_005023c0();

    uVar3 = uVar3 + iVar1;

  }

  if ((uVar3 & 3) != 0) {

    return (4 - (uVar3 & 3)) + uVar3;

  }

  return uVar3;

}





// --- FUN_00502540 at 0x00502540 (size: 127) ---


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



{

  uint uVar1;

  uint uVar2;

  

  if (7 < *param_3) {

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

    *param_2 = *param_2 + 8;

    uVar1 = *param_3;

    *param_3 = uVar1 - 8;

    if (7 < uVar1 - 8) {

      *(undefined8 *)*param_2 = *(undefined8 *)(param_1 + 0x10);

      *param_2 = *param_2 + 8;

      *param_3 = *param_3 - 8;

    }

  }

  FUN_00500610(param_2,param_3);

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

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

  if (uVar1 != 0) {

    do {

      FUN_00502450(param_2,param_3);

      uVar2 = uVar2 + 1;

    } while (uVar2 < uVar1);

  }

  return *param_3;

}





// --- FUN_005025c0 at 0x005025C0 (size: 605) ---


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



{

  int *piVar1;

  int iVar2;

  uint uVar3;

  undefined4 *puVar4;

  uint uVar5;

  int local_14;

  undefined4 *local_10;

  int local_c;

  

  if (3 < *param_3) {

    param_1[1] = *(int *)*param_2;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  iVar2 = FUN_004fd460(param_2,*param_3);

  if (iVar2 == 0) {

    return 0;

  }

  uVar3 = *(int *)(*param_1 + 8) - 1;

  iVar2 = 0;

  if (0xfffe < uVar3) {

    iVar2 = 4;

  }

  uVar3 = iVar2 + 2 + uVar3;

  uVar5 = uVar3 & 3;

  if (uVar5 == 0) {

    iVar2 = 0;

  }

  else {

    iVar2 = 4 - uVar5;

  }

  *param_3 = *param_3 - (iVar2 + uVar3);

  FUN_00500610(param_2,param_3);

  if (3 < *param_3) {

    local_14 = *(int *)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_00500570(local_14);

  if (local_14 != 0) {

    local_c = local_14;

    do {

      local_10 = (undefined4 *)FUN_005df0f5(0x2c);

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

        local_10 = (undefined4 *)0x0;

      }

      else {

        *local_10 = 0;

        local_10[1] = 0;

        local_10[2] = 0;

        local_10[3] = 0;

        local_10[4] = 0;

        local_10[5] = 0;

        local_10[6] = 0;

        local_10[7] = 0;

        local_10[8] = 0;

        local_10[9] = 0;

        local_10[10] = 0;

      }

      FUN_00501b20(param_2,param_3);

      uVar3 = param_1[6];

      if ((uint)param_1[7] < uVar3) {

LAB_005026e4:

        *(undefined4 **)(param_1[5] + param_1[7] * 4) = local_10;

        param_1[7] = param_1[7] + 1;

      }

      else {

        if (uVar3 == 0) {

          iVar2 = 8;

        }

        else {

          iVar2 = uVar3 * 2;

        }

        iVar2 = FUN_00500570(iVar2);

        if (iVar2 != 0) goto LAB_005026e4;

      }

      local_c = local_c + -1;

    } while (local_c != 0);

  }

  if (3 < *param_3) {

    local_14 = *(int *)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_00500570(local_14);

  if (local_14 != 0) {

    local_10 = (undefined4 *)local_14;

    do {

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

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

        puVar4 = (undefined4 *)0x0;

      }

      else {

        *puVar4 = 0;

        puVar4[1] = 0;

        puVar4[2] = 0;

        puVar4[3] = 0;

        puVar4[5] = 0;

        puVar4[7] = 0;

        puVar4[8] = 0;

        puVar4[9] = 0;

        puVar4[0xb] = 0;

        puVar4[0xc] = 0;

        puVar4[0xd] = 0;

        *(undefined1 *)((int)puVar4 + 0x12) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x11) = 0xff;

        *(undefined1 *)(puVar4 + 4) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x13) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x1a) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x19) = 0xff;

        *(undefined1 *)(puVar4 + 6) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x1b) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x2a) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x29) = 0xff;

        *(undefined1 *)(puVar4 + 10) = 0xff;

        *(undefined1 *)((int)puVar4 + 0x2b) = 0xff;

      }

      FUN_00502100(param_2,param_3);

      uVar3 = 0;

      if (puVar4[0xd] != 0) {

        do {

          piVar1 = *(int **)(puVar4[0xb] + uVar3 * 4);

          piVar1[1] = *(int *)(param_1[5] + *piVar1 * 4);

          uVar3 = uVar3 + 1;

        } while (uVar3 < (uint)puVar4[0xd]);

      }

      uVar3 = param_1[3];

      if ((uint)param_1[4] < uVar3) {

LAB_005027f9:

        *(undefined4 **)(param_1[2] + param_1[4] * 4) = puVar4;

        param_1[4] = param_1[4] + 1;

      }

      else {

        if (uVar3 == 0) {

          iVar2 = 8;

        }

        else {

          iVar2 = uVar3 * 2;

        }

        iVar2 = FUN_00500570(iVar2);

        if (iVar2 != 0) goto LAB_005027f9;

      }

      local_10 = (undefined4 *)((int)local_10 + -1);

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

  }

  return 1;

}





// --- FUN_00502820 at 0x00502820 (size: 325) ---


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



{

  undefined4 *puVar1;

  uint uVar2;

  int *piVar3;

  int *piVar4;

  uint *puVar5;

  int iVar6;

  LONG *lpAddend;

  int *local_8;

  

  puVar5 = param_3;

  piVar4 = param_2;

  if (7 < *param_3) {

    puVar1 = (undefined4 *)*param_2;

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

    *(undefined4 *)(param_1 + 0xc) = puVar1[1];

    *param_2 = *param_2 + 8;

    uVar2 = *param_3;

    *param_3 = uVar2 - 8;

    if (7 < uVar2 - 8) {

      puVar1 = (undefined4 *)*param_2;

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

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

      *param_2 = *param_2 + 8;

      *param_3 = *param_3 - 8;

    }

  }

  FUN_00500610(param_2,param_3);

  if (3 < *param_3) {

    piVar3 = *(int **)*param_2;

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

    *param_3 = *param_3 - 4;

    param_2 = piVar3;

  }

  FUN_00500570(param_2);

  local_8 = (int *)0x0;

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

    do {

      param_3 = (uint *)FUN_005df0f5(0x20);

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

        param_3 = (uint *)0x0;

      }

      else {

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

        *param_3 = DAT_008ef11c;

        InterlockedIncrement(lpAddend);

        param_3[1] = 0;

        param_3[2] = 0;

        param_3[3] = 0;

        param_3[4] = 0;

        param_3[5] = 0;

        param_3[6] = 0;

        param_3[7] = 0;

      }

      iVar6 = FUN_005025c0(piVar4,puVar5);

      if (iVar6 == 0) {

        return 0;

      }

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

      if (*(uint *)(param_1 + 0x20) < uVar2) {

LAB_00502926:

        *(uint **)(*(int *)(param_1 + 0x18) + *(int *)(param_1 + 0x20) * 4) = param_3;

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

      }

      else {

        if (uVar2 == 0) {

          iVar6 = 8;

        }

        else {

          iVar6 = uVar2 * 2;

        }

        iVar6 = FUN_00500570(iVar6);

        if (iVar6 != 0) goto LAB_00502926;

      }

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

    } while (local_8 < param_2);

  }

  return 1;

}





// --- FUN_00502970 at 0x00502970 (size: 150) ---


void __fastcall FUN_00502970(undefined4 *param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  LONG LVar3;

  uint uVar4;

  

  uVar4 = 0;

  *param_1 = 0;

  param_1[2] = 0;

  param_1[3] = 0x40080000;

  param_1[4] = 0;

  param_1[5] = 0x40340000;

  if (param_1[8] != 0) {

    do {

      piVar1 = *(int **)(param_1[6] + uVar4 * 4);

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

        FUN_005022d0();

        operator_delete__((void *)piVar1[5]);

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

        puVar2 = (undefined4 *)*piVar1;

        LVar3 = InterlockedDecrement(puVar2 + 1);

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

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

        }

        operator_delete(piVar1);

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < (uint)param_1[8]);

  }

  param_1[8] = 0;

  param_1[7] = 0;

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

  param_1[6] = 0;

  return;

}





// --- FUN_00502a10 at 0x00502A10 (size: 896) ---


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



{

  float fVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  int *piVar5;

  uint uVar6;

  uint uVar7;

  int iVar8;

  int *piVar9;

  undefined4 *puVar10;

  undefined4 uVar11;

  undefined4 *puVar12;

  uint local_38;

  int local_34;

  int local_30;

  undefined4 local_2c [11];

  

  piVar5 = param_3;

  uVar6 = param_3[2];

  iVar2 = *(int *)(param_1[6] + *param_1 * 4);

  uVar3 = *(uint *)(iVar2 + 0x1c);

  if (uVar6 < uVar3) {

    puVar10 = local_2c;

    for (iVar8 = 0xb; iVar8 != 0; iVar8 = iVar8 + -1) {

      *puVar10 = 0;

      puVar10 = puVar10 + 1;

    }

    param_3 = (int *)(uVar3 - uVar6);

    do {

      uVar6 = piVar5[1];

      if ((uint)piVar5[2] < uVar6) {

LAB_00502a67:

        puVar10 = local_2c;

        puVar12 = (undefined4 *)(piVar5[2] * 0x2c + *piVar5);

        for (iVar8 = 0xb; iVar8 != 0; iVar8 = iVar8 + -1) {

          *puVar12 = *puVar10;

          puVar10 = puVar10 + 1;

          puVar12 = puVar12 + 1;

        }

        piVar5[2] = piVar5[2] + 1;

      }

      else {

        if (uVar6 == 0) {

          iVar8 = 8;

        }

        else {

          iVar8 = uVar6 * 2;

        }

        iVar8 = FUN_00502040(iVar8);

        if (iVar8 != 0) goto LAB_00502a67;

      }

      param_3 = (int *)((int)param_3 + -1);

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

  }

  uVar6 = piVar5[2];

  while (uVar3 < uVar6) {

    if (uVar3 < (uint)piVar5[2]) {

      uVar6 = piVar5[2] - 1;

      piVar5[2] = uVar6;

      if (uVar3 != uVar6) {

        puVar10 = (undefined4 *)(uVar6 * 0x2c + *piVar5);

        puVar12 = (undefined4 *)(uVar3 * 0x2c + *piVar5);

        for (iVar8 = 0xb; iVar8 != 0; iVar8 = iVar8 + -1) {

          *puVar12 = *puVar10;

          puVar10 = puVar10 + 1;

          puVar12 = puVar12 + 1;

        }

      }

    }

    uVar6 = piVar5[2];

  }

  uVar6 = 0;

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

    iVar8 = 0;

    do {

      iVar4 = *(int *)(*(int *)(iVar2 + 0x14) + uVar6 * 4);

      if ((*(float *)(iVar4 + 4) == *(float *)(iVar4 + 8)) ||

         ((uVar11 = DAT_0084253c, *(float *)(iVar4 + 4) < (float)param_2 &&

          ((float)param_2 < *(float *)(iVar4 + 8))))) {

        uVar11 = *(undefined4 *)(iVar4 + 0x24);

      }

      *(undefined4 *)(iVar8 + *piVar5) = uVar11;

      *(undefined4 *)(iVar8 + 4 + *piVar5) = *(undefined4 *)(iVar4 + 0x28);

      *(undefined4 *)(iVar8 + 0x28 + *piVar5) = *(undefined4 *)(iVar4 + 0x20);

      *(undefined4 *)(iVar8 + 8 + *piVar5) = 0;

      if (*(float *)(iVar4 + 4) == *(float *)(iVar4 + 8)) {

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

      }

      else {

        fVar1 = (((float)param_2 - *(float *)(iVar4 + 4)) *

                (*(float *)(iVar4 + 0x10) - *(float *)(iVar4 + 0xc))) /

                (*(float *)(iVar4 + 8) - *(float *)(iVar4 + 4)) + *(float *)(iVar4 + 0xc);

      }

      *(float *)(iVar8 + 0xc + *piVar5) = fVar1;

      puVar10 = (undefined4 *)(iVar8 + 0x10 + *piVar5);

      *puVar10 = *(undefined4 *)(iVar4 + 0x14);

      puVar10[1] = *(undefined4 *)(iVar4 + 0x18);

      puVar10[2] = *(undefined4 *)(iVar4 + 0x1c);

      *(undefined4 *)(iVar8 + 0x20 + *piVar5) = 0xbf800000;

      *(undefined4 *)(iVar8 + 0x24 + *piVar5) = 0xbf800000;

      *(undefined4 *)(iVar8 + 0x1c + *piVar5) = 0xbf800000;

      uVar6 = uVar6 + 1;

      iVar8 = iVar8 + 0x2c;

    } while (uVar6 < *(uint *)(iVar2 + 0x1c));

  }

  iVar8 = FUN_00501530(param_2,&local_34,&local_30,&param_3);

  if ((iVar8 != 0) && (local_38 = 0, *(int *)(local_34 + 0x34) != 0)) {

    do {

      iVar8 = *(int *)(*(int *)(local_34 + 0x2c) + local_38 * 4);

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

      uVar6 = 0;

      if (*(uint *)(iVar2 + 0x1c) != 0) {

        piVar9 = *(int **)(iVar2 + 0x14);

        do {

          if (iVar4 == *piVar9) break;

          uVar6 = uVar6 + 1;

          piVar9 = piVar9 + 1;

        } while (uVar6 < *(uint *)(iVar2 + 0x1c));

      }

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

        *(int *)(uVar6 * 0x2c + *piVar5) = *(int *)(iVar8 + 8);

      }

      fVar1 = *(float *)(*(int *)(*(int *)(local_34 + 0x2c) + local_38 * 4) + 0xc);

      if (fVar1 != DAT_00796344) {

        *(float *)(uVar6 * 0x2c + 8 + *piVar5) = fVar1;

      }

      if (((DAT_00796344 < *(float *)(iVar8 + 0x14)) || (DAT_00796344 < *(float *)(iVar8 + 0x18)))

         || (DAT_00796344 <= *(float *)(iVar8 + 0x10))) {

        uVar3 = *(uint *)(local_30 + 0x34);

        uVar7 = 0;

        if (uVar3 != 0) {

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

          do {

            if (iVar4 == *(int *)(*param_2 + 4)) break;

            uVar7 = uVar7 + 1;

            param_2 = param_2 + 1;

          } while (uVar7 < uVar3);

        }

        if (uVar7 < uVar3) {

          iVar4 = *(int *)(*(int *)(local_30 + 0x2c) + uVar7 * 4);

          if ((DAT_00796344 < *(float *)(iVar8 + 0x14)) && (DAT_00796344 < *(float *)(iVar4 + 0x14))

             ) {

            *(float *)(uVar6 * 0x2c + 0x20 + *piVar5) =

                 (*(float *)(iVar4 + 0x14) - *(float *)(iVar8 + 0x14)) * (float)param_3 +

                 *(float *)(iVar8 + 0x14);

          }

          if ((DAT_00796344 < *(float *)(iVar8 + 0x18)) && (DAT_00796344 < *(float *)(iVar4 + 0x18))

             ) {

            *(float *)(uVar6 * 0x2c + 0x24 + *piVar5) =

                 (*(float *)(iVar4 + 0x18) - *(float *)(iVar8 + 0x18)) * (float)param_3 +

                 *(float *)(iVar8 + 0x18);

          }

          if ((DAT_00796344 <= *(float *)(iVar8 + 0x10)) &&

             (DAT_00796344 <= *(float *)(iVar4 + 0x10))) {

            *(float *)(uVar6 * 0x2c + 0x1c + *piVar5) =

                 (*(float *)(iVar4 + 0x10) - *(float *)(iVar8 + 0x10)) * (float)param_3 +

                 *(float *)(iVar8 + 0x10);

          }

        }

      }

      local_38 = local_38 + 1;

    } while (local_38 < *(uint *)(local_34 + 0x34));

  }

  return 1;

}





// --- FUN_00502da0 at 0x00502DA0 (size: 22) ---


void __fastcall FUN_00502da0(int param_1)



{

  FUN_00502970();

  operator_delete__(*(void **)(param_1 + 0x18));

  return;

}





// --- FUN_00502dc0 at 0x00502DC0 (size: 84) ---


void __fastcall FUN_00502dc0(int *param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (param_1[2] != 0) {

    do {

      pvVar1 = *(void **)(*param_1 + uVar2 * 4);

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

        FUN_00503cc0();

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

  param_1[2] = 0;

  param_1[1] = 0;

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  return;

}





// --- FUN_00502e20 at 0x00502E20 (size: 45) ---


int __fastcall FUN_00502e20(int param_1)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  uVar3 = 0;

  iVar2 = 4;

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

    do {

      iVar1 = FUN_00503c20();

      iVar2 = iVar2 + iVar1;

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 8));

  }

  return iVar2;

}





// --- FUN_00502e50 at 0x00502E50 (size: 21) ---


void __fastcall FUN_00502e50(undefined4 *param_1)



{

  FUN_00502dc0();

  operator_delete__((void *)*param_1);

  return;

}





// --- FUN_00502e70 at 0x00502E70 (size: 121) ---


void __fastcall FUN_00502e70(int *param_1)



{

  int iVar1;

  int iVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 uVar5;

  uint local_18;

  

  local_18 = 0;

  if (param_1[2] != 0) {

    do {

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

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

        uVar4 = 0;

        do {

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

          if (iVar2 != DAT_00842550) {

            uVar5 = 8;

            uVar3 = FUN_004220b0(iVar2,0);

            FUN_0041a4e0(uVar3,uVar5);

          }

          uVar4 = uVar4 + 1;

        } while (uVar4 < *(uint *)(iVar1 + 0xc));

      }

      local_18 = local_18 + 1;

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

  }

  return;

}





// --- FUN_00502ef0 at 0x00502EF0 (size: 64) ---


undefined4 __thiscall FUN_00502ef0(int *param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  

  uVar1 = param_1[1];

  if (uVar1 <= (uint)param_1[2]) {

    if (uVar1 == 0) {

      iVar2 = 8;

    }

    else {

      iVar2 = uVar1 * 2;

    }

    iVar2 = FUN_00500570(iVar2);

    if (iVar2 == 0) {

      return 0;

    }

  }

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

  param_1[2] = param_1[2] + 1;

  return 1;

}





// --- FUN_00502f30 at 0x00502F30 (size: 7) ---


void FUN_00502f30(void)



{

  FUN_005034d0();

  return;

}





// --- FUN_00502f40 at 0x00502F40 (size: 16) ---


void __fastcall FUN_00502f40(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  return;

}





// --- FUN_00502f50 at 0x00502F50 (size: 45) ---


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



{

  int iVar1;

  

  if (param_2 < *(uint *)(param_1 + 0xc)) {

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

    if ((param_3 < *(uint *)(iVar1 + 0x10)) &&

       (iVar1 = *(int *)(*(int *)(iVar1 + 8) + param_3 * 4), iVar1 != 0)) {

      return *(undefined4 *)(iVar1 + 0x10);

    }

  }

  return 0;

}





// --- FUN_00502f80 at 0x00502F80 (size: 26) ---


undefined4 __thiscall FUN_00502f80(int param_1,uint param_2)



{

  if (param_2 < *(uint *)(param_1 + 0xc)) {

    return *(undefined4 *)(*(int *)(*(int *)(param_1 + 4) + param_2 * 4) + 0x10);

  }

  return 0;

}





// --- FUN_00502fa0 at 0x00502FA0 (size: 45) ---


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



{

  int iVar1;

  

  if (param_2 < *(uint *)(param_1 + 0xc)) {

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

    if ((param_3 < *(uint *)(iVar1 + 0x10)) &&

       (iVar1 = *(int *)(*(int *)(iVar1 + 8) + param_3 * 4), iVar1 != 0)) {

      return *(undefined4 *)(iVar1 + 0xc);

    }

  }

  return 0;

}





// --- FUN_00502fd0 at 0x00502FD0 (size: 59) ---


void __thiscall FUN_00502fd0(int param_1,undefined4 *param_2,int param_3,int param_4,uint param_5)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(*(int *)(*(int *)(param_1 + 4) + param_3 * 4) + 8) + param_4 * 4);

  if (param_5 < *(uint *)(iVar1 + 0xc)) {

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

    return;

  }

  *param_2 = DAT_008425b4;

  return;

}





// --- FUN_00503010 at 0x00503010 (size: 51) ---


int * __fastcall FUN_00503010(int *param_1)



{

  LONG *lpAddend;

  

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

  *param_1 = DAT_008ef11c;

  InterlockedIncrement(lpAddend);

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  *(undefined1 *)((int)param_1 + 6) = 0xff;

  *(undefined1 *)((int)param_1 + 5) = 0xff;

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

  *(undefined1 *)((int)param_1 + 7) = 0xff;

  return param_1;

}





// --- FUN_00503050 at 0x00503050 (size: 165) ---


void __fastcall FUN_00503050(undefined4 *param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  void *pvVar3;

  LONG LVar4;

  uint local_4;

  

  local_4 = 0;

  if (param_1[3] != 0) {

    do {

      piVar1 = *(int **)(param_1[1] + local_4 * 4);

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

        piVar1[4] = 0;

        piVar1[3] = 0;

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

        piVar1[2] = 0;

        operator_delete__((void *)0x0);

        puVar2 = (undefined4 *)*piVar1;

        LVar4 = InterlockedDecrement(puVar2 + 1);

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

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

        }

        operator_delete(piVar1);

      }

      local_4 = local_4 + 1;

    } while (local_4 < (uint)param_1[3]);

  }

  param_1[3] = 0;

  param_1[2] = 0;

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

  param_1[1] = 0;

  pvVar3 = (void *)*param_1;

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

    FUN_005037a0();

    operator_delete(pvVar3);

  }

  *param_1 = 0;

  return;

}





// --- FUN_00503100 at 0x00503100 (size: 65) ---


undefined4 __thiscall FUN_00503100(int param_1,undefined4 param_2)



{

  uint uVar1;

  int iVar2;

  

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

  if (uVar1 <= *(uint *)(param_1 + 0xc)) {

    if (uVar1 == 0) {

      iVar2 = 8;

    }

    else {

      iVar2 = uVar1 * 2;

    }

    iVar2 = FUN_00500570(iVar2);

    if (iVar2 == 0) {

      return 0;

    }

  }

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

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

  return 1;

}





// --- FUN_00503150 at 0x00503150 (size: 112) ---


int __fastcall FUN_00503150(int param_1)



{

  uint uVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  int *piVar5;

  int iVar6;

  

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

  iVar6 = 4;

  if (iVar2 != 0) {

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

    do {

      uVar1 = *(int *)(*(int *)*piVar5 + 8) - 1;

      iVar3 = 0;

      if (0xfffe < uVar1) {

        iVar3 = 4;

      }

      uVar1 = iVar3 + 2 + uVar1;

      uVar4 = uVar1 & 3;

      if (uVar4 == 0) {

        iVar3 = 0;

      }

      else {

        iVar3 = 4 - uVar4;

      }

      iVar6 = iVar6 + iVar3 + 8 + ((int *)*piVar5)[4] * 4 + uVar1;

      piVar5 = piVar5 + 1;

      iVar2 = iVar2 + -1;

    } while (iVar2 != 0);

  }

  iVar2 = FUN_005034f0();

  return iVar2 + iVar6;

}





// --- FUN_005031c0 at 0x005031C0 (size: 22) ---


void __fastcall FUN_005031c0(int param_1)



{

  FUN_00503050();

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

  return;

}





// --- FUN_005031e0 at 0x005031E0 (size: 13) ---


void __fastcall FUN_005031e0(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  return;

}





// --- FUN_005031f0 at 0x005031F0 (size: 84) ---


void __fastcall FUN_005031f0(int *param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (param_1[2] != 0) {

    do {

      pvVar1 = *(void **)(*param_1 + uVar2 * 4);

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

        FUN_00551de0();

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

  param_1[2] = 0;

  param_1[1] = 0;

  operator_delete__((void *)*param_1);

  *param_1 = 0;

  return;

}





// --- FUN_00503250 at 0x00503250 (size: 67) ---


uint __fastcall FUN_00503250(int param_1)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  

  uVar3 = 0;

  uVar2 = 4;

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

    do {

      iVar1 = FUN_00551f20();

      uVar2 = uVar2 + iVar1;

      uVar3 = uVar3 + 1;

    } while (uVar3 < *(uint *)(param_1 + 8));

  }

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

    return (4 - (uVar2 & 3)) + uVar2;

  }

  return uVar2;

}





// --- FUN_005032a0 at 0x005032A0 (size: 110) ---


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



{

  uint uVar1;

  uint uVar2;

  

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

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar2;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar1 = 0;

  if (uVar2 != 0) {

    do {

      FUN_00551e40(param_2,param_3);

      uVar1 = uVar1 + 1;

    } while (uVar1 < uVar2);

  }

  uVar2 = 0;

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

    do {

      FUN_00551f20();

      uVar2 = uVar2 + 1;

    } while (uVar2 < *(uint *)(param_1 + 8));

    return *param_3;

  }

  return *param_3;

}





// --- FUN_00503310 at 0x00503310 (size: 21) ---


void __fastcall FUN_00503310(undefined4 *param_1)



{

  FUN_005031f0();

  operator_delete__((void *)*param_1);

  return;

}





// --- FUN_00503330 at 0x00503330 (size: 75) ---


void __fastcall FUN_00503330(int *param_1)



{

  int iVar1;

  undefined4 uVar2;

  uint uVar3;

  undefined4 uVar4;

  

  uVar3 = 0;

  if (param_1[2] != 0) {

    do {

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

      if (iVar1 != DAT_0084260c) {

        uVar4 = 0;

        uVar2 = FUN_004220b0(iVar1,0);

        FUN_0041a4e0(uVar2,uVar4);

      }

      uVar3 = uVar3 + 1;

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

  }

  return;

}





// --- FUN_00503380 at 0x00503380 (size: 192) ---


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



{

  uint uVar1;

  uint *puVar2;

  int iVar3;

  undefined4 uVar4;

  int *piVar5;

  

  puVar2 = param_3;

  piVar5 = param_2;

  if (3 < *param_3) {

    piVar5 = *(int **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_005031f0();

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

    FUN_00500570(piVar5);

  }

  param_3 = (uint *)0x0;

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

    do {

      iVar3 = FUN_005df0f5(0x1c);

      if (iVar3 == 0) {

        uVar4 = 0;

      }

      else {

        uVar4 = FUN_00551dc0();

      }

      iVar3 = FUN_00552510(param_2,puVar2);

      if (iVar3 == 0) {

        return 0;

      }

      uVar1 = param_1[1];

      if ((uint)param_1[2] < uVar1) {

LAB_00503413:

        *(undefined4 *)(*param_1 + param_1[2] * 4) = uVar4;

        param_1[2] = param_1[2] + 1;

      }

      else {

        if (uVar1 == 0) {

          iVar3 = 8;

        }

        else {

          iVar3 = uVar1 * 2;

        }

        iVar3 = FUN_00500570(iVar3);

        if (iVar3 != 0) goto LAB_00503413;

      }

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

    } while (param_3 < piVar5);

  }

  return 1;

}





// --- FUN_00503440 at 0x00503440 (size: 122) ---


void __fastcall FUN_00503440(uint *param_1)



{

  int *piVar1;

  uint uVar2;

  

  if (param_1[1] != 0) {

    uVar2 = 0;

    if (*param_1 != 0) {

      do {

        piVar1 = *(int **)(param_1[1] + uVar2 * 4);

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

          if (*piVar1 != 0) {

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

          }

          *piVar1 = 0;

          operator_delete(piVar1);

        }

        uVar2 = uVar2 + 1;

      } while (uVar2 < *param_1);

    }

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

    param_1[1] = 0;

  }

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

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

    param_1[2] = 0;

  }

  *param_1 = 0;

  return;

}





// --- thunk_FUN_00503440 at 0x005034C0 (size: 5) ---


void __fastcall thunk_FUN_00503440(uint *param_1)



{

  int *piVar1;

  uint uVar2;

  

  if (param_1[1] != 0) {

    uVar2 = 0;

    if (*param_1 != 0) {

      do {

        piVar1 = *(int **)(param_1[1] + uVar2 * 4);

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

          if (*piVar1 != 0) {

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

          }

          *piVar1 = 0;

          operator_delete(piVar1);

        }

        uVar2 = uVar2 + 1;

      } while (uVar2 < *param_1);

    }

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

    param_1[1] = 0;

  }

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

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

    param_1[2] = 0;

  }

  *param_1 = 0;

  return;

}





// --- FUN_005034d0 at 0x005034D0 (size: 21) ---


void __fastcall FUN_005034d0(int *param_1)



{

  if (*param_1 != 0) {

    FUN_00500ce0();

    return;

  }

  FUN_00504710();

  return;

}





// --- FUN_005034f0 at 0x005034F0 (size: 29) ---


int __fastcall FUN_005034f0(int *param_1)



{

  int iVar1;

  

  if (*param_1 != 0) {

    iVar1 = FUN_005009f0();

    return iVar1 + 4;

  }

  iVar1 = FUN_00504400();

  return iVar1 + 4;

}





// --- FUN_00503510 at 0x00503510 (size: 188) ---


uint __fastcall FUN_00503510(int param_1)



{

  int *piVar1;

  undefined4 uVar2;

  uint uVar3;

  uint uVar4;

  uint uVar5;

  int *piVar6;

  

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

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

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

    uVar2 = thunk_FUN_005df0f5(0xa0);

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

    uVar3 = 0;

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

      do {

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

        uVar3 = uVar3 + 1;

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

    }

    return 0;

  }

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

  uVar4 = 0;

  piVar6 = piVar1;

  if (uVar3 != 0) {

    do {

      if (*piVar6 == 0) {

        return uVar4;

      }

      uVar4 = uVar4 + 1;

      piVar6 = piVar6 + 1;

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

  }

  uVar4 = uVar3 + 0x28;

  uVar2 = thunk_FUN_005df0f5(uVar4 * 4);

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

  uVar5 = 0;

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

    do {

      *(int *)(*(int *)(param_1 + 0x10) + uVar5 * 4) = piVar1[uVar5];

      uVar5 = uVar5 + 1;

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

  }

  for (uVar5 = *(uint *)(param_1 + 0xc); uVar5 < uVar4; uVar5 = uVar5 + 1) {

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

  }

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

  operator_delete__(piVar1);

  return uVar3;

}





// --- FUN_005035e0 at 0x005035E0 (size: 17) ---


undefined4 __fastcall FUN_005035e0(int param_1)



{

  undefined4 uVar1;

  

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

    return 0;

  }

  uVar1 = FUN_00504470();

  return uVar1;

}





// --- FUN_00503600 at 0x00503600 (size: 111) ---


void __fastcall FUN_00503600(undefined4 *param_1)



{

  void *pvVar1;

  

  pvVar1 = (void *)*param_1;

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

    FUN_00501430();

    operator_delete(pvVar1);

    *param_1 = 0;

  }

  if (param_1[1] != 0) {

    operator_delete(DAT_0084271c);

    DAT_0084271c = (void *)0x0;

    pvVar1 = (void *)param_1[1];

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

      FUN_00505330();

      operator_delete(pvVar1);

    }

    param_1[1] = 0;

  }

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

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

    param_1[4] = 0;

  }

  param_1[5] = 0;

  param_1[3] = 0;

  return;

}





// --- FUN_00503670 at 0x00503670 (size: 94) ---


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



{

  int iVar1;

  

  iVar1 = *param_1;

  if (3 < *param_3) {

    *(uint *)*param_2 = (uint)(iVar1 != 0);

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

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

    FUN_00504b40(param_2,param_3);

  }

  else {

    FUN_00500f20(param_2,param_3);

  }

  if (*param_1 != 0) {

    FUN_005009f0();

    return *param_3;

  }

  FUN_00504400();

  return *param_3;

}





// --- FUN_005036d0 at 0x005036D0 (size: 156) ---


void __thiscall FUN_005036d0(undefined4 *param_1,undefined4 *param_2,uint *param_3)



{

  int iVar1;

  undefined4 uVar2;

  uint *puVar3;

  

  puVar3 = param_3;

  if (3 < *param_3) {

    puVar3 = *(uint **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

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

    iVar1 = FUN_005df0f5(0x34);

    if (iVar1 == 0) {

      param_1[1] = 0;

      FUN_00505010(param_2,param_3);

      return;

    }

    uVar2 = FUN_00503fb0();

    param_1[1] = uVar2;

    FUN_00505010(param_2,param_3);

    return;

  }

  iVar1 = FUN_005df0f5(0x18);

  if (iVar1 == 0) {

    *param_1 = 0;

    FUN_00501320(param_2,param_3);

    return;

  }

  uVar2 = FUN_00500680();

  *param_1 = uVar2;

  FUN_00501320(param_2,param_3);

  return;

}





// --- FUN_00503770 at 0x00503770 (size: 44) ---


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



{

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

    *param_2 = DAT_008426bc;

    return param_2;

  }

  FUN_00504440(param_2,param_3);

  return param_2;

}





// --- FUN_005037a0 at 0x005037A0 (size: 35) ---


void __fastcall FUN_005037a0(int param_1)



{

  FUN_00503600();

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

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

  }

  operator_delete__(*(void **)(param_1 + 0x1c));

  return;

}





// --- FUN_005037d0 at 0x005037D0 (size: 82) ---


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



{

  undefined4 *puVar1;

  uint uVar2;

  undefined4 *puVar3;

  

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

  puVar3 = (undefined4 *)0x0;

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

    puVar1[1] = 0;

    puVar1[3] = param_2;

    puVar1[2] = param_3;

    *puVar1 = &PTR_LAB_007c78e0;

    puVar3 = puVar1;

  }

  uVar2 = ((uint)puVar3[2] >> ((byte)*(undefined4 *)(param_1 + 8) & 0x1f) ^ puVar3[2]) &

          *(uint *)(param_1 + 4);

  puVar3[1] = *(undefined4 *)(*(int *)(param_1 + 0xc) + uVar2 * 4);

  *(undefined4 **)(*(int *)(param_1 + 0xc) + uVar2 * 4) = puVar3;

  return;

}





// --- FUN_00503830 at 0x00503830 (size: 171) ---


undefined4 * __fastcall FUN_00503830(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  uint uVar3;

  uint uVar4;

  

  *param_1 = 0;

  param_1[1] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

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

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

    *puVar1 = &PTR_FUN_007c7450;

    puVar1[5] = 0;

    uVar2 = thunk_FUN_005df0f5(0x40);

    puVar1[3] = uVar2;

    puVar1[4] = 0x10;

    puVar1[2] = 8;

    puVar1[1] = 0;

    uVar3 = 1;

    do {

      uVar4 = puVar1[1] | uVar3;

      uVar3 = uVar3 << 1;

      puVar1[1] = uVar4;

    } while ((uVar4 | uVar3) < (uint)puVar1[4]);

    uVar3 = 0;

    do {

      *(undefined4 *)(puVar1[3] + uVar3 * 4) = 0;

      uVar3 = uVar3 + 1;

    } while (uVar3 < (uint)puVar1[4]);

    *puVar1 = &PTR_FUN_007c7098;

    param_1[2] = puVar1;

    param_1[10] = 0;

    param_1[6] = 0;

    return param_1;

  }

  param_1[2] = 0;

  param_1[10] = 0;

  param_1[6] = 0;

  return param_1;

}





// --- FUN_005038e0 at 0x005038E0 (size: 102) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

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

  puVar3 = (undefined4 *)0x0;

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

    *puVar1 = 0;

    puVar1[1] = 0;

    puVar1[2] = 0;

    puVar1[3] = 0;

    puVar3 = puVar1;

  }

  puVar3[2] = param_2;

  *puVar3 = param_3;

  iVar2 = FUN_00503510();

  *param_4 = iVar2;

  puVar3[1] = puVar3[1] + 1;

  puVar3[3] = *param_4;

  *(undefined4 *)(*(int *)(param_1 + 0x10) + *param_4 * 4) = param_2;

  FUN_005037d0(puVar3,param_3);

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

  return 1;

}





// --- FUN_00503950 at 0x00503950 (size: 267) ---


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



void __thiscall FUN_00503950(int *param_1,void *param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  uint uVar4;

  void *pvVar5;

  

  iVar2 = param_1[2];

  if (iVar2 != 0) {

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

    if (iVar3 == 0) {

      FUN_004d8d00();

    }

    uVar4 = 0;

    pvVar5 = param_2;

    while( true ) {

      if (iVar3 != 0) {

        pvVar5 = *(void **)(iVar3 + 0xc);

      }

      if (*(int *)((int)pvVar5 + 8) == *(int *)(param_1[4] + (int)param_2 * 4)) break;

      if ((iVar3 == 0) || (iVar3 = *(int *)(iVar3 + 4), iVar3 == 0)) {

        do {

          uVar4 = uVar4 + 1;

          if (*(uint *)(iVar2 + 0x10) <= uVar4) {

            return;

          }

          iVar3 = *(int *)(*(int *)(iVar2 + 0xc) + uVar4 * 4);

        } while (iVar3 == 0);

      }

    }

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

    *piVar1 = *piVar1 + -1;

    if (*piVar1 == 0) {

      *(undefined4 *)(param_1[4] + (int)param_2 * 4) = 0;

      FUN_004f8040();

      if (*param_1 == 0) {

        if (param_1[1] != 0) {

          FUN_00503e30(*(undefined4 *)((int)pvVar5 + 8));

        }

      }

      else {

        FUN_005004c0(*(undefined4 *)((int)pvVar5 + 8));

      }

      param_1[5] = param_1[5] + -1;

      operator_delete(pvVar5);

    }

  }

  return;

}





// --- FUN_00503a60 at 0x00503A60 (size: 30) ---


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



{

  FUN_00503a80();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00503a80 at 0x00503A80 (size: 79) ---


void __fastcall FUN_00503a80(undefined4 *param_1)



{

  int local_4;

  

  *param_1 = &PTR_FUN_007c7098;

  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_00503ad0 at 0x00503AD0 (size: 326) ---


undefined4 __thiscall

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

            undefined4 *param_5,undefined4 *param_6,undefined4 param_7,undefined4 param_8)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 uVar4;

  undefined1 local_14 [20];

  

  puVar1 = param_5;

  if (*param_1 != 0) {

    uVar2 = FUN_00500d90(param_2,param_3,param_5,param_6,param_7,local_14,&param_5,param_8);

    iVar3 = FUN_00523210(uVar2,&param_6);

    if (iVar3 != 0) {

      param_6[1] = param_6[1] + 1;

      *param_4 = param_6[3];

      return 1;

    }

    uVar4 = FUN_00500ea0(uVar2,*puVar1,local_14,param_5);

    uVar2 = FUN_005038e0(uVar4,uVar2,param_4);

    return uVar2;

  }

  if (param_1[1] == 0) {

    return 0;

  }

  uVar2 = *param_6;

  *param_5 = 0;

  iVar3 = FUN_00523210(uVar2,&param_6);

  if (iVar3 != 0) {

    param_6[1] = param_6[1] + 1;

    *param_4 = param_6[3];

    FUN_00401030(local_14,4,5,FUN_00695670);

    return 1;

  }

  uVar4 = FUN_00505410(uVar2,param_7);

  uVar2 = FUN_005038e0(uVar4,uVar2,param_4);

  FUN_00401030(local_14,4,5,FUN_00695670);

  return uVar2;

}





// --- FUN_00503c20 at 0x00503C20 (size: 11) ---


int __fastcall FUN_00503c20(int param_1)



{

  return *(int *)(param_1 + 0xc) * 4 + 8;

}





// --- FUN_00503c30 at 0x00503C30 (size: 88) ---


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



{

  undefined4 *puVar1;

  uint uVar2;

  

  puVar1 = (undefined4 *)*param_2;

  if (3 < *param_3) {

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

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar2 = 0;

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

    do {

      if (3 < *param_3) {

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

        *param_2 = *param_2 + 4;

        *param_3 = *param_3 - 4;

      }

      uVar2 = uVar2 + 1;

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

  }

  uVar2 = *param_3 + (*param_2 - (int)puVar1);

  *param_3 = uVar2;

  return uVar2;

}





// --- FUN_00503c90 at 0x00503C90 (size: 40) ---


undefined4 * __fastcall FUN_00503c90(undefined4 *param_1)



{

  LONG *lpAddend;

  

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

  *param_1 = PTR_DAT_00818344;

  InterlockedIncrement(lpAddend);

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  return param_1;

}





// --- FUN_00503cc0 at 0x00503CC0 (size: 81) ---


void __fastcall FUN_00503cc0(int *param_1)



{

  LONG LVar1;

  undefined4 *puVar2;

  

  FUN_004158b0();

  if (((param_1[2] & 0x80000000U) == 0x80000000) && (param_1[1] != 0)) {

    operator_delete__((void *)(param_1[1] + -4));

  }

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

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

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

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

  }

  return;

}





// --- FUN_00503d20 at 0x00503D20 (size: 267) ---


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



{

  int iVar1;

  char cVar2;

  uint uVar3;

  uint *puVar4;

  uint *puVar5;

  uint uVar6;

  

  puVar5 = param_3;

  if (3 < *param_3) {

    puVar5 = *(uint **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  FUN_004158b0();

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

    FUN_00415910(puVar5);

    puVar4 = param_3;

    for (; puVar5 != (uint *)0x0; puVar5 = (uint *)((int)puVar5 + -1)) {

      if (3 < *param_3) {

        puVar4 = *(uint **)*param_2;

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

        *param_3 = *param_3 - 4;

      }

      uVar3 = *(uint *)(param_1 + 8) & 0x7fffffff;

      if (*(uint *)(param_1 + 0xc) < uVar3) {

LAB_00503e0a:

        *(uint **)(*(int *)(param_1 + 4) + *(int *)(param_1 + 0xc) * 4) = puVar4;

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

      }

      else {

        uVar3 = uVar3 + 1;

        if (uVar3 < 9) {

          uVar3 = 8;

        }

        else if (uVar3 < 0x4001) {

          iVar1 = 0x1f;

          if (uVar3 != 0) {

            for (; uVar3 >> iVar1 == 0; iVar1 = iVar1 + -1) {

            }

          }

          uVar6 = 1 << ((byte)iVar1 & 0x1f);

          if (uVar6 < uVar3) {

            uVar3 = uVar6 * 2;

          }

        }

        else if ((uVar3 & 0x3fff) != 0) {

          uVar3 = uVar3 + (0x4000 - (uVar3 & 0x3fff));

        }

        cVar2 = FUN_00415910(uVar3);

        if (cVar2 != '\0') goto LAB_00503e0a;

      }

    }

  }

  return 1;

}





// --- FUN_00503e30 at 0x00503E30 (size: 18) ---


void FUN_00503e30(int param_1)



{

  if (param_1 != 0) {

    FUN_00536c10(param_1);

  }

  return;

}





// --- FUN_00503e50 at 0x00503E50 (size: 209) ---


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



{

  uint uVar1;

  

  uVar1 = (uint)((param_1 & 0xc000000) != 0);

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

    uVar1 = uVar1 | 2;

  }

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

    uVar1 = uVar1 | 4;

  }

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

    uVar1 = uVar1 | 8;

  }

  *param_2 = 0;

  *param_3 = 0;

  param_3[1] = 0;

  switch(uVar1) {

  case 0:

    goto switchD_00503ea8_caseD_0;

  default:

    *param_3 = uVar1;

switchD_00503ea8_caseD_0:

    return 1;

  case 7:

    *param_3 = 3;

    param_3[1] = 6;

    return 1;

  case 0xb:

    *param_3 = 9;

    param_3[1] = 3;

    return 1;

  case 0xd:

    *param_3 = 9;

    param_3[1] = 0xc;

    return 1;

  case 0xe:

    *param_3 = 6;

    param_3[1] = 0xc;

    return 1;

  case 0xf:

    *param_2 = 1;

    return 1;

  }

}





// --- FUN_00503f50 at 0x00503F50 (size: 29) ---


void FUN_00503f50(undefined4 param_1)



{

  undefined4 uVar1;

  

  uVar1 = FUN_004220b0(param_1,0xb);

  FUN_00415430(uVar1);

  return;

}





// --- FUN_00503f70 at 0x00503F70 (size: 55) ---


bool __fastcall FUN_00503f70(int *param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  if (*param_1 != DAT_00842770) {

    uVar1 = FUN_004220b0(*param_1,0xb);

    iVar2 = FUN_00415430(uVar1);

    param_1[1] = iVar2;

  }

  return param_1[1] != 0;

}





// --- FUN_00503fb0 at 0x00503FB0 (size: 47) ---


void __fastcall FUN_00503fb0(undefined4 *param_1)



{

  *param_1 = 0x10;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  return;

}





// --- FUN_00503fe0 at 0x00503FE0 (size: 124) ---


undefined4 FUN_00503fe0(undefined4 param_1,undefined4 param_2,int *param_3)



{

  undefined4 uVar1;

  int iVar2;

  

  iVar2 = param_3[1];

  if (iVar2 == 0) {

    if (*param_3 != DAT_00842770) {

      uVar1 = FUN_004220b0(*param_3,0xb);

      iVar2 = FUN_00415430(uVar1);

      param_3[1] = iVar2;

    }

    iVar2 = param_3[1];

    if (iVar2 == 0) {

      FUN_00540030(param_1,param_2,param_2,0,1);

      return 0;

    }

  }

  FUN_00540030(param_1,param_2,param_2,iVar2,param_3[3]);

  return 1;

}





// --- FUN_00504060 at 0x00504060 (size: 256) ---


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



undefined4 __thiscall FUN_00504060(int param_1,uint param_2,int *param_3,uint *param_4,int param_5)



{

  uint uVar1;

  float fVar2;

  float fVar3;

  int iVar4;

  uint uVar5;

  undefined4 uVar6;

  uint uVar7;

  uint uVar8;

  

  iVar4 = param_5 * 0x523aa99e + -0x51c9e74a;

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

  fVar2 = (float)iVar4;

  if (iVar4 < 0) {

    fVar2 = fVar2 + _DAT_0079920c;

  }

  fVar3 = (float)(int)uVar1;

  if ((int)uVar1 < 0) {

    fVar3 = fVar3 + _DAT_0079920c;

  }

  floor((double)(fVar3 * fVar2 * _DAT_007c6f10));

  iVar4 = FUN_005df4c4();

  uVar8 = 0;

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

    do {

      *param_3 = *(int *)(*(int *)(param_1 + 0x1c) + ((uVar8 + iVar4) % uVar1) * 4);

      *param_4 = 0;

      uVar5 = *(uint *)*param_3;

      uVar7 = 0;

      do {

        if (uVar5 == param_2) {

          *param_4 = uVar7;

          iVar4 = *param_3;

          if ((*(int *)(iVar4 + 8) == 0) && (*(int *)(iVar4 + 4) != DAT_00842770)) {

            FUN_004220b0(*(int *)(iVar4 + 4),0xb);

            uVar6 = FUN_00415430();

            *(undefined4 *)(iVar4 + 8) = uVar6;

          }

          return 1;

        }

        uVar5 = uVar5 * 2;

        if (0xf < uVar5) {

          uVar5 = uVar5 - 0xf;

        }

        uVar7 = uVar7 + 1;

      } while (uVar7 < 4);

      uVar8 = uVar8 + 1;

    } while (uVar8 < *(uint *)(param_1 + 0x24));

  }

  *param_3 = 0;

  return 0;

}





// --- FUN_00504160 at 0x00504160 (size: 447) ---


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



undefined4 __thiscall FUN_00504160(int param_1,uint param_2,int *param_3,uint *param_4,int param_5)



{

  float fVar1;

  float fVar2;

  uint uVar3;

  undefined4 uVar4;

  int iVar5;

  uint uVar6;

  

  if ((((param_2 == 1) || (param_2 == 2)) || (param_2 == 4)) || (param_2 == 8)) {

    fVar1 = (float)*(int *)(param_1 + 0xc);

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

      fVar1 = fVar1 + _DAT_0079920c;

    }

    iVar5 = param_5 * 0x523aa99e + -0x51c9e74a;

    fVar2 = (float)iVar5;

    if (iVar5 < 0) {

      fVar2 = fVar2 + _DAT_0079920c;

    }

    floor((double)(fVar2 * _DAT_007c6f10 * fVar1));

    iVar5 = FUN_005df4c4();

    fVar2 = (float)iVar5;

    if (iVar5 < 0) {

      fVar2 = fVar2 + _DAT_0079920c;

    }

    if (fVar1 <= fVar2) {

      iVar5 = 0;

    }

    *param_3 = *(int *)(*(int *)(param_1 + 4) + iVar5 * 4);

    *param_4 = 0;

    uVar3 = *(uint *)*param_3;

    uVar6 = 0;

    while (uVar3 != param_2) {

      uVar3 = uVar3 * 2;

      if (0xf < uVar3) {

        uVar3 = uVar3 - 0xf;

      }

      uVar6 = uVar6 + 1;

      if (3 < uVar6) {

        return 0;

      }

    }

  }

  else {

    fVar1 = (float)*(int *)(param_1 + 0x18);

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

      fVar1 = fVar1 + _DAT_0079920c;

    }

    iVar5 = param_5 * 0x523aa99e + -0x51c9e74a;

    fVar2 = (float)iVar5;

    if (iVar5 < 0) {

      fVar2 = fVar2 + _DAT_0079920c;

    }

    floor((double)(fVar2 * _DAT_007c6f10 * fVar1));

    iVar5 = FUN_005df4c4();

    fVar2 = (float)iVar5;

    if (iVar5 < 0) {

      fVar2 = fVar2 + _DAT_0079920c;

    }

    if (fVar1 <= fVar2) {

      iVar5 = 0;

    }

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

    *param_4 = 0;

    uVar3 = *(uint *)*param_3;

    uVar6 = 0;

    while (uVar3 != param_2) {

      uVar3 = uVar3 * 2;

      if (0xf < uVar3) {

        uVar3 = uVar3 - 0xf;

      }

      uVar6 = uVar6 + 1;

      if (3 < uVar6) {

        return 0;

      }

    }

  }

  *param_4 = uVar6;

  iVar5 = *param_3;

  if ((*(int *)(iVar5 + 8) == 0) && (*(int *)(iVar5 + 4) != DAT_00842770)) {

    FUN_004220b0(*(int *)(iVar5 + 4),0xb);

    uVar4 = FUN_00415430();

    *(undefined4 *)(iVar5 + 8) = uVar4;

  }

  return 1;

}





// --- FUN_00504320 at 0x00504320 (size: 128) ---


undefined4

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



{

  int iVar1;

  

  if (param_3 == 0) {

    return 0;

  }

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

    FUN_0053f5d0(param_1,param_2,param_2,*(int *)(param_5 + 4),*(undefined4 *)(param_5 + 0xc),

                 param_3,param_4);

    return 1;

  }

  iVar1 = FUN_00503f70();

  if (iVar1 != 0) {

    FUN_0053f5d0(param_1,param_2,param_2,*(undefined4 *)(param_5 + 4),*(undefined4 *)(param_5 + 0xc)

                 ,param_3,param_4);

    return 1;

  }

  return 0;

}





// --- FUN_005043a0 at 0x005043A0 (size: 82) ---


undefined4 __thiscall FUN_005043a0(int param_1,int param_2)



{

  uint uVar1;

  uint uVar2;

  undefined4 *puVar3;

  

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

  uVar2 = 0;

  if (uVar1 != 0) {

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

    do {

      if (param_2 == *(int *)*puVar3) {

        return **(undefined4 **)((*(undefined4 **)(param_1 + 0x28))[uVar2] + 4);

      }

      uVar2 = uVar2 + 1;

      puVar3 = puVar3 + 1;

    } while (uVar2 < uVar1);

  }

  if (uVar1 != 0) {

    return **(undefined4 **)(**(int **)(param_1 + 0x28) + 4);

  }

  return 0;

}





// --- FUN_00504400 at 0x00504400 (size: 61) ---


int __fastcall FUN_00504400(int param_1)



{

  int iVar1;

  

  iVar1 = 8;

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

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

  }

  iVar1 = iVar1 + 4;

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

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

  }

  iVar1 = iVar1 + 4;

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

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

  }

  iVar1 = iVar1 + 4;

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

    iVar1 = iVar1 + *(int *)(param_1 + 0x30) * 0x2c;

  }

  return iVar1;

}





// --- FUN_00504440 at 0x00504440 (size: 47) ---


void __thiscall FUN_00504440(int param_1,undefined4 *param_2,uint param_3)



{

  if (param_3 < *(uint *)(param_1 + 0x30)) {

    *param_2 = *(undefined4 *)

                (**(int **)(*(int *)(*(int *)(param_1 + 0x28) + param_3 * 4) + 4) + 0x2c);

    return;

  }

  *param_2 = DAT_00842770;

  return;

}





// --- FUN_00504470 at 0x00504470 (size: 31) ---


undefined4 __thiscall FUN_00504470(int param_1,uint param_2)



{

  if (param_2 < *(uint *)(param_1 + 0x30)) {

    return *(undefined4 *)(**(int **)(*(int *)(*(int *)(param_1 + 0x28) + param_2 * 4) + 4) + 0x28);

  }

  return 0;

}





// --- FUN_00504490 at 0x00504490 (size: 270) ---


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



{

  uint uVar1;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      *(undefined4 *)*param_2 = param_1[3];

      *param_2 = *param_2 + 4;

      uVar1 = *param_3;

      *param_3 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        *(undefined4 *)*param_2 = param_1[4];

        *param_2 = *param_2 + 4;

        uVar1 = *param_3;

        *param_3 = uVar1 - 4;

        if (3 < uVar1 - 4) {

          *(undefined4 *)*param_2 = param_1[5];

          *param_2 = *param_2 + 4;

          uVar1 = *param_3;

          *param_3 = uVar1 - 4;

          if (3 < uVar1 - 4) {

            *(undefined4 *)*param_2 = param_1[6];

            *param_2 = *param_2 + 4;

            uVar1 = *param_3;

            *param_3 = uVar1 - 4;

            if (3 < uVar1 - 4) {

              *(undefined4 *)*param_2 = param_1[7];

              *param_2 = *param_2 + 4;

              uVar1 = *param_3;

              *param_3 = uVar1 - 4;

              if (3 < uVar1 - 4) {

                *(undefined4 *)*param_2 = param_1[8];

                *param_2 = *param_2 + 4;

                uVar1 = *param_3;

                *param_3 = uVar1 - 4;

                if (3 < uVar1 - 4) {

                  *(undefined4 *)*param_2 = param_1[9];

                  *param_2 = *param_2 + 4;

                  uVar1 = *param_3;

                  *param_3 = uVar1 - 4;

                  if (3 < uVar1 - 4) {

                    *(undefined4 *)*param_2 = param_1[10];

                    *param_2 = *param_2 + 4;

                    uVar1 = *param_3;

                    *param_3 = uVar1 - 4;

                    if (3 < uVar1 - 4) {

                      *(undefined4 *)*param_2 = param_1[0xb];

                      *param_2 = *param_2 + 4;

                      *param_3 = *param_3 - 4;

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  return *param_3;

}





// --- FUN_005045a0 at 0x005045A0 (size: 272) ---


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



{

  undefined4 uVar1;

  uint uVar2;

  

  if (3 < *param_3) {

    uVar1 = *(undefined4 *)*param_2;

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

    *param_3 = *param_3 - 4;

    *param_1 = uVar1;

    if (3 < *param_3) {

      param_1[3] = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

      uVar2 = *param_3;

      *param_3 = uVar2 - 4;

      if (3 < uVar2 - 4) {

        param_1[4] = *(undefined4 *)*param_2;

        *param_2 = *param_2 + 4;

        uVar2 = *param_3;

        *param_3 = uVar2 - 4;

        if (3 < uVar2 - 4) {

          param_1[5] = *(undefined4 *)*param_2;

          *param_2 = *param_2 + 4;

          uVar2 = *param_3;

          *param_3 = uVar2 - 4;

          if (3 < uVar2 - 4) {

            param_1[6] = *(undefined4 *)*param_2;

            *param_2 = *param_2 + 4;

            uVar2 = *param_3;

            *param_3 = uVar2 - 4;

            if (3 < uVar2 - 4) {

              param_1[7] = *(undefined4 *)*param_2;

              *param_2 = *param_2 + 4;

              uVar2 = *param_3;

              *param_3 = uVar2 - 4;

              if (3 < uVar2 - 4) {

                param_1[8] = *(undefined4 *)*param_2;

                *param_2 = *param_2 + 4;

                uVar2 = *param_3;

                *param_3 = uVar2 - 4;

                if (3 < uVar2 - 4) {

                  param_1[9] = *(undefined4 *)*param_2;

                  *param_2 = *param_2 + 4;

                  uVar2 = *param_3;

                  *param_3 = uVar2 - 4;

                  if (3 < uVar2 - 4) {

                    param_1[10] = *(undefined4 *)*param_2;

                    *param_2 = *param_2 + 4;

                    uVar2 = *param_3;

                    *param_3 = uVar2 - 4;

                    if (3 < uVar2 - 4) {

                      uVar1 = *(undefined4 *)*param_2;

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

                      *param_3 = *param_3 - 4;

                      param_1[0xb] = uVar1;

                    }

                  }

                }

              }

            }

          }

        }

      }

    }

  }

  return 1;

}





// --- FUN_005046b0 at 0x005046B0 (size: 93) ---


void __fastcall FUN_005046b0(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 4) + uVar2 * 4);

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

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

          (**(code **)(**(int **)((int)pvVar1 + 4) + 0x14))();

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

        }

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

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

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

  operator_delete__((void *)0x0);

  return;

}





// --- FUN_00504710 at 0x00504710 (size: 261) ---


void __fastcall FUN_00504710(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  uint uVar3;

  undefined4 uVar4;

  

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

    uVar3 = 0;

    do {

      uVar4 = 8;

      uVar2 = FUN_004220b0(*(undefined4 *)(*(int *)(*(int *)(param_1 + 4) + uVar3 * 4) + 4),0);

      FUN_0041a4e0(uVar2,uVar4);

      uVar3 = uVar3 + 1;

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

  }

  uVar3 = 0;

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

    do {

      uVar4 = 8;

      uVar2 = FUN_004220b0(*(undefined4 *)(*(int *)(*(int *)(param_1 + 0x10) + uVar3 * 4) + 4),0);

      FUN_0041a4e0(uVar2,uVar4);

      uVar3 = uVar3 + 1;

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

  }

  uVar3 = 0;

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

    do {

      uVar4 = 8;

      uVar2 = FUN_004220b0(*(undefined4 *)(*(int *)(*(int *)(param_1 + 0x1c) + uVar3 * 4) + 4),0);

      FUN_0041a4e0(uVar2,uVar4);

      uVar3 = uVar3 + 1;

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

  }

  uVar3 = 0;

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

    do {

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

      uVar4 = 8;

      uVar2 = FUN_004220b0(*puVar1,0);

      FUN_0041a4e0(uVar2,uVar4);

      uVar4 = 8;

      uVar2 = FUN_004220b0(puVar1[0xb],0);

      FUN_0041a4e0(uVar2,uVar4);

      uVar3 = uVar3 + 1;

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

  }

  return;

}





// --- FUN_00504820 at 0x00504820 (size: 790) ---


undefined4 __thiscall FUN_00504820(int param_1,uint param_2,undefined4 *param_3,uint *param_4)



{

  undefined4 *puVar1;

  uint uVar2;

  undefined4 uVar3;

  int iVar4;

  byte bVar5;

  uint uVar6;

  undefined4 *puVar7;

  uint uVar8;

  undefined4 *puVar9;

  uint local_10 [4];

  

  local_10[0] = param_2 >> 0xf & 0x1f;

  local_10[1] = param_2 >> 10 & 0x1f;

  local_10[2] = param_2 >> 5 & 0x1f;

  local_10[3] = param_2 & 0x1f;

  uVar8 = 0;

  do {

    uVar2 = uVar8 + 1;

    if (uVar8 < 3) {

      uVar6 = uVar2;

      do {

        if (local_10[uVar8] == local_10[uVar6]) {

          puVar7 = (undefined4 *)local_10[uVar8];

          uVar8 = *(uint *)(param_1 + 0x30);

          uVar2 = 0;

          if (uVar8 == 0) goto LAB_005048e1;

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

          goto LAB_005048d0;

        }

        uVar6 = uVar6 + 1;

      } while (uVar6 < 4);

    }

    uVar8 = uVar2;

  } while (uVar2 < 4);

  uVar8 = *(uint *)(param_1 + 0x30);

  uVar2 = 0;

  if (uVar8 != 0) {

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

    do {

      if (local_10[0] == *(uint *)*puVar7) {

        iVar4 = (*(undefined4 **)(param_1 + 0x28))[uVar2];

        goto LAB_00504a46;

      }

      uVar2 = uVar2 + 1;

      puVar7 = puVar7 + 1;

    } while (uVar2 < uVar8);

  }

  if (uVar8 == 0) {

    uVar3 = 0;

  }

  else {

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

LAB_00504a46:

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

  }

  *param_3 = uVar3;

  uVar8 = *(uint *)(param_1 + 0x30);

  uVar2 = 0;

  if (uVar8 != 0) {

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

    do {

      if (local_10[1] == *(uint *)*puVar7) {

        iVar4 = (*(undefined4 **)(param_1 + 0x28))[uVar2];

        goto LAB_00504a80;

      }

      uVar2 = uVar2 + 1;

      puVar7 = puVar7 + 1;

    } while (uVar2 < uVar8);

  }

  if (uVar8 == 0) {

    uVar3 = 0;

  }

  else {

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

LAB_00504a80:

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

  }

  param_3[1] = uVar3;

  uVar8 = *(uint *)(param_1 + 0x30);

  uVar2 = 0;

  if (uVar8 != 0) {

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

    do {

      if (local_10[2] == *(uint *)*puVar7) {

        iVar4 = (*(undefined4 **)(param_1 + 0x28))[uVar2];

        goto LAB_00504ac4;

      }

      uVar2 = uVar2 + 1;

      puVar7 = puVar7 + 1;

    } while (uVar2 < uVar8);

  }

  if (uVar8 == 0) {

    uVar3 = 0;

  }

  else {

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

LAB_00504ac4:

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

  }

  param_3[2] = uVar3;

  uVar8 = *(uint *)(param_1 + 0x30);

  uVar2 = 0;

  if (uVar8 != 0) {

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

    do {

      if ((param_2 & 0x1f) == *(uint *)*puVar7) {

        iVar4 = (*(undefined4 **)(param_1 + 0x28))[uVar2];

        goto LAB_00504b03;

      }

      uVar2 = uVar2 + 1;

      puVar7 = puVar7 + 1;

    } while (uVar2 < uVar8);

  }

  if (uVar8 == 0) {

    uVar3 = 0;

  }

  else {

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

LAB_00504b03:

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

  }

  param_3[3] = uVar3;

  *param_4 = 2;

  param_4[1] = 4;

  param_4[2] = 8;

  return 1;

  while( true ) {

    uVar2 = uVar2 + 1;

    puVar9 = puVar9 + 1;

    if (uVar8 <= uVar2) break;

LAB_005048d0:

    if (puVar7 == *(undefined4 **)*puVar9) {

      iVar4 = (*(undefined4 **)(param_1 + 0x28))[uVar2];

      goto LAB_005048f1;

    }

  }

LAB_005048e1:

  if (uVar8 == 0) {

    uVar3 = 0;

  }

  else {

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

LAB_005048f1:

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

  }

  uVar8 = 0;

  *param_3 = uVar3;

  *param_4 = 0;

  param_4[1] = 0;

  param_4[2] = 0;

  puVar9 = param_3;

  do {

    puVar1 = (undefined4 *)local_10[uVar8];

    if (puVar1 != puVar7) {

      bVar5 = (byte)uVar8;

      if (*param_4 != 0) {

        if ((undefined4 *)local_10[uVar8] == puVar9) {

          if (uVar8 == 1) {

            uVar2 = *param_4;

          }

          else {

            if (uVar8 != 2) {

              if ((uVar8 == 3) && (uVar2 = *param_4, uVar2 == 4)) goto LAB_005049e6;

              goto LAB_0050499f;

            }

            uVar2 = *param_4;

          }

          if (uVar2 == uVar8) {

LAB_005049e6:

            *param_4 = (1 << (bVar5 & 0x1f)) + uVar2;

            return 1;

          }

        }

LAB_0050499f:

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

        uVar6 = 0;

        if (uVar2 == 0) goto LAB_005049c9;

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

        break;

      }

      uVar6 = 0;

      *param_4 = 1 << (bVar5 & 0x1f);

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

      if (uVar2 != 0) {

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

        do {

          if (puVar1 == *(undefined4 **)*puVar9) {

            uVar3 = **(undefined4 **)((*(undefined4 **)(param_1 + 0x28))[uVar6] + 4);

            goto LAB_00504972;

          }

          uVar6 = uVar6 + 1;

          puVar9 = puVar9 + 1;

        } while (uVar6 < uVar2);

      }

      if (uVar2 == 0) {

        uVar3 = 0;

      }

      else {

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

      }

LAB_00504972:

      param_3[1] = uVar3;

      puVar9 = puVar1;

    }

    uVar8 = uVar8 + 1;

    if (3 < uVar8) {

      return 1;

    }

  } while( true );

  while( true ) {

    uVar6 = uVar6 + 1;

    puVar7 = puVar7 + 1;

    if (uVar2 <= uVar6) break;

    if (local_10[uVar8] == *(uint *)*puVar7) {

      uVar3 = **(undefined4 **)((*(undefined4 **)(param_1 + 0x28))[uVar6] + 4);

      goto LAB_00504a18;

    }

  }

LAB_005049c9:

  if (uVar2 == 0) {

    uVar3 = 0;

  }

  else {

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

  }

LAB_00504a18:

  param_3[2] = uVar3;

  param_4[1] = 1 << (bVar5 & 0x1f);

  return 1;

}





// --- FUN_00504b40 at 0x00504B40 (size: 370) ---


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



{

  uint uVar1;

  undefined4 *puVar2;

  uint uVar3;

  uint uVar4;

  

  if (3 < *param_3) {

    *(undefined4 *)*param_2 = *param_1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar1 = param_1[3];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar4 = 0;

  if (uVar1 != 0) {

    do {

      puVar2 = *(undefined4 **)(param_1[1] + uVar4 * 4);

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = *puVar2;

        *param_2 = *param_2 + 4;

        uVar3 = *param_3;

        *param_3 = uVar3 - 4;

        if (3 < uVar3 - 4) {

          *(undefined4 *)*param_2 = puVar2[1];

          *param_2 = *param_2 + 4;

          *param_3 = *param_3 - 4;

        }

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < uVar1);

  }

  uVar1 = param_1[6];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar4 = 0;

  if (uVar1 != 0) {

    do {

      puVar2 = *(undefined4 **)(param_1[4] + uVar4 * 4);

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = *puVar2;

        *param_2 = *param_2 + 4;

        uVar3 = *param_3;

        *param_3 = uVar3 - 4;

        if (3 < uVar3 - 4) {

          *(undefined4 *)*param_2 = puVar2[1];

          *param_2 = *param_2 + 4;

          *param_3 = *param_3 - 4;

        }

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < uVar1);

  }

  uVar1 = param_1[9];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar4 = 0;

  if (uVar1 != 0) {

    do {

      puVar2 = *(undefined4 **)(param_1[7] + uVar4 * 4);

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = *puVar2;

        *param_2 = *param_2 + 4;

        uVar3 = *param_3;

        *param_3 = uVar3 - 4;

        if (3 < uVar3 - 4) {

          *(undefined4 *)*param_2 = puVar2[1];

          *param_2 = *param_2 + 4;

          *param_3 = *param_3 - 4;

        }

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < uVar1);

  }

  uVar1 = param_1[0xc];

  if (3 < *param_3) {

    *(uint *)*param_2 = uVar1;

    *param_2 = *param_2 + 4;

    *param_3 = *param_3 - 4;

  }

  uVar4 = 0;

  if (uVar1 != 0) {

    do {

      if (3 < *param_3) {

        *(undefined4 *)*param_2 = **(undefined4 **)(param_1[10] + uVar4 * 4);

        *param_2 = *param_2 + 4;

        *param_3 = *param_3 - 4;

      }

      FUN_00504490(param_2,param_3);

      uVar4 = uVar4 + 1;

    } while (uVar4 < uVar1);

  }

  return *param_3;

}





// --- FUN_00504cc0 at 0x00504CC0 (size: 188) ---


undefined4 __thiscall FUN_00504cc0(undefined4 *param_1,undefined4 *param_2,uint *param_3)



{

  uint uVar1;

  undefined4 *puVar2;

  int iVar3;

  uint *puVar4;

  

  puVar4 = param_3;

  if (3 < *param_3) {

    puVar4 = *(uint **)*param_2;

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

    *param_3 = *param_3 - 4;

  }

  *param_1 = puVar4;

  puVar2 = (undefined4 *)FUN_005df0f5(0x30);

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = DAT_00842770;

    puVar2[1] = 0;

    puVar2[2] = 0;

    puVar2[3] = 0;

    puVar2[4] = 0;

    puVar2[5] = 0;

    puVar2[6] = 0;

    puVar2[7] = 0;

    puVar2[8] = 0;

    puVar2[9] = 0;

    puVar2[10] = 0;

    puVar2[0xb] = DAT_00842770;

  }

  FUN_005045a0(param_2,param_3);

  uVar1 = param_1[2];

  if (uVar1 <= (uint)param_1[3]) {

    if (uVar1 == 0) {

      iVar3 = 8;

    }

    else {

      iVar3 = uVar1 * 2;

    }

    iVar3 = FUN_00500570(iVar3);

    if (iVar3 == 0) {

      return 1;

    }

  }

  *(undefined4 **)(param_1[1] + param_1[3] * 4) = puVar2;

  param_1[3] = param_1[3] + 1;

  return 1;

}





// --- FUN_00504d80 at 0x00504D80 (size: 300) ---


void __fastcall FUN_00504d80(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 4) + uVar2 * 4);

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

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

          (**(code **)(**(int **)((int)pvVar1 + 8) + 0x14))();

          *(undefined4 *)((int)pvVar1 + 8) = 0;

        }

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

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

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

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 0x10) + uVar2 * 4);

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

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

          (**(code **)(**(int **)((int)pvVar1 + 8) + 0x14))();

          *(undefined4 *)((int)pvVar1 + 8) = 0;

        }

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x10));

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

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 0x1c) + uVar2 * 4);

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

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

          (**(code **)(**(int **)((int)pvVar1 + 8) + 0x14))();

          *(undefined4 *)((int)pvVar1 + 8) = 0;

        }

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x1c));

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

  uVar2 = 0;

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

    do {

      pvVar1 = *(void **)(*(int *)(param_1 + 0x28) + uVar2 * 4);

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

        FUN_005046b0();

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

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

  }

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

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

  operator_delete__(*(void **)(param_1 + 0x28));

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

  return;

}





// --- FUN_00504eb0 at 0x00504EB0 (size: 346) ---


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



{

  undefined4 uVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  int local_2c;

  int local_28;

  int local_24 [6];

  undefined4 auStack_c [3];

  

  iVar2 = FUN_00504820(param_2,local_24 + 5,local_24 + 2);

  if (iVar2 == 0) {

    return 0;

  }

  if ((DAT_0084271c != 0) ||

     (DAT_0084271c = thunk_FUN_005df0f5(*param_1 * *param_1 * 4), DAT_0084271c != 0)) {

    iVar2 = DAT_0084271c;

    iVar3 = FUN_005043a0(0x20);

    local_28 = iVar3;

    FUN_00503e50(param_2,&local_2c,local_24);

    iVar4 = local_2c;

    uVar1 = param_3;

    if ((local_2c != 0) && (iVar3 != 0)) {

      local_24[5] = iVar3;

    }

    iVar2 = FUN_00503fe0(iVar2,param_3,local_24[5]);

    if (iVar2 != 0) {

      if (iVar4 == 0) {

        uVar5 = 0;

        do {

          iVar2 = *(int *)((int)local_24 + uVar5 + 8);

          if (iVar2 == 0) break;

          iVar2 = FUN_00504160(iVar2,&local_2c,&param_3,param_2);

          if (iVar2 == 0) {

            return 0;

          }

          FUN_00504320(DAT_0084271c,uVar1,*(undefined4 *)(local_2c + 8),param_3,

                       *(undefined4 *)((int)auStack_c + uVar5));

          uVar5 = uVar5 + 4;

        } while (uVar5 < 0xc);

        iVar2 = local_28;

        if (local_28 != 0) {

          uVar5 = 0;

          do {

            if (local_24[uVar5] == 0) {

              return 1;

            }

            iVar4 = FUN_00504060(local_24[uVar5],&local_28,&param_3,param_2);

            if (iVar4 != 0) {

              FUN_00504320(DAT_0084271c,uVar1,*(undefined4 *)(local_28 + 8),param_3,iVar2);

            }

            uVar5 = uVar5 + 1;

          } while (uVar5 < 2);

        }

      }

      return 1;

    }

  }

  return 0;

}





// --- FUN_00505010 at 0x00505010 (size: 791) ---


undefined4 __thiscall FUN_00505010(undefined4 *param_1,uint *param_2,uint *param_3)



{

  uint uVar1;

  uint *puVar2;

  undefined4 uVar3;

  int *piVar4;

  uint *puVar5;

  undefined4 *puVar6;

  int iVar7;

  undefined4 *puVar8;

  

  puVar5 = param_3;

  piVar4 = (int *)param_2;

  if (3 < *param_3) {

    *param_1 = *(undefined4 *)*param_2;

    *param_2 = *param_2 + 4;

    uVar1 = *param_3;

    *param_3 = uVar1 - 4;

    if (3 < uVar1 - 4) {

      puVar2 = *(uint **)*param_2;

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

      *param_3 = *param_3 - 4;

      param_3 = puVar2;

    }

  }

  FUN_00500570(param_3);

  for (puVar2 = param_3; puVar2 != (uint *)0x0; puVar2 = (uint *)((int)puVar2 + -1)) {

    puVar6 = (undefined4 *)FUN_005df0f5(0xc);

    puVar8 = (undefined4 *)0x0;

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

      *puVar6 = 0;

      uVar3 = DAT_00842770;

      puVar6[2] = 0;

      puVar6[1] = uVar3;

      puVar8 = puVar6;

    }

    if (3 < *puVar5) {

      *puVar8 = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

      uVar1 = *puVar5;

      *puVar5 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        uVar3 = *(undefined4 *)*param_2;

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

        *puVar5 = *puVar5 - 4;

        puVar8[1] = uVar3;

      }

    }

    uVar1 = param_1[2];

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

LAB_005050dc:

      *(undefined4 **)(param_1[1] + param_1[3] * 4) = puVar8;

      param_1[3] = param_1[3] + 1;

    }

    else {

      if (uVar1 == 0) {

        iVar7 = 8;

      }

      else {

        iVar7 = uVar1 * 2;

      }

      iVar7 = FUN_00500570(iVar7);

      if (iVar7 != 0) goto LAB_005050dc;

    }

  }

  if (3 < *puVar5) {

    param_3 = *(uint **)*param_2;

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

    *puVar5 = *puVar5 - 4;

  }

  FUN_00500570(param_3);

  for (puVar2 = param_3; puVar2 != (uint *)0x0; puVar2 = (uint *)((int)puVar2 + -1)) {

    puVar6 = (undefined4 *)FUN_005df0f5(0xc);

    puVar8 = (undefined4 *)0x0;

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

      *puVar6 = 0;

      uVar3 = DAT_00842770;

      puVar6[2] = 0;

      puVar6[1] = uVar3;

      puVar8 = puVar6;

    }

    if (3 < *puVar5) {

      *puVar8 = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

      uVar1 = *puVar5;

      *puVar5 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        uVar3 = *(undefined4 *)*param_2;

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

        *puVar5 = *puVar5 - 4;

        puVar8[1] = uVar3;

      }

    }

    uVar1 = param_1[5];

    if ((uint)param_1[6] < uVar1) {

LAB_00505194:

      *(undefined4 **)(param_1[4] + param_1[6] * 4) = puVar8;

      param_1[6] = param_1[6] + 1;

    }

    else {

      if (uVar1 == 0) {

        iVar7 = 8;

      }

      else {

        iVar7 = uVar1 * 2;

      }

      iVar7 = FUN_00500570(iVar7);

      if (iVar7 != 0) goto LAB_00505194;

    }

  }

  if (3 < *puVar5) {

    param_3 = *(uint **)*param_2;

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

    *puVar5 = *puVar5 - 4;

  }

  FUN_00500570(param_3);

  for (puVar2 = param_3; puVar2 != (uint *)0x0; puVar2 = (uint *)((int)puVar2 + -1)) {

    puVar6 = (undefined4 *)FUN_005df0f5(0xc);

    puVar8 = (undefined4 *)0x0;

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

      *puVar6 = 0;

      uVar3 = DAT_00842770;

      puVar6[2] = 0;

      puVar6[1] = uVar3;

      puVar8 = puVar6;

    }

    if (3 < *puVar5) {

      *puVar8 = *(undefined4 *)*param_2;

      *param_2 = *param_2 + 4;

      uVar1 = *puVar5;

      *puVar5 = uVar1 - 4;

      if (3 < uVar1 - 4) {

        uVar3 = *(undefined4 *)*param_2;

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

        *puVar5 = *puVar5 - 4;

        puVar8[1] = uVar3;

      }

    }

    uVar1 = param_1[8];

    if ((uint)param_1[9] < uVar1) {

LAB_0050524c:

      *(undefined4 **)(param_1[7] + param_1[9] * 4) = puVar8;

      param_1[9] = param_1[9] + 1;

    }

    else {

      if (uVar1 == 0) {

        iVar7 = 8;

      }

      else {

        iVar7 = uVar1 * 2;

      }

      iVar7 = FUN_00500570(iVar7);

      if (iVar7 != 0) goto LAB_0050524c;

    }

  }

  if (3 < *puVar5) {

    param_3 = *(uint **)*param_2;

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

    *puVar5 = *puVar5 - 4;

  }

  FUN_00500570(param_3);

  param_2 = (uint *)0x0;

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

    return 1;

  }

  do {

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

    puVar8 = (undefined4 *)0x0;

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

      *puVar6 = 0x1f;

      puVar6[1] = 0;

      puVar6[2] = 0;

      puVar6[3] = 0;

      puVar8 = puVar6;

    }

    iVar7 = FUN_00504cc0(piVar4,puVar5);

    if (iVar7 == 0) {

      return 0;

    }

    uVar1 = param_1[0xb];

    if ((uint)param_1[0xc] < uVar1) {

LAB_005052f4:

      *(undefined4 **)(param_1[10] + param_1[0xc] * 4) = puVar8;

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

    }

    else {

      if (uVar1 == 0) {

        iVar7 = 8;

      }

      else {

        iVar7 = uVar1 * 2;

      }

      iVar7 = FUN_00500570(iVar7);

      if (iVar7 != 0) goto LAB_005052f4;

    }

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

    if (param_3 <= param_2) {

      return 1;

    }

  } while( true );

}





// --- FUN_00505330 at 0x00505330 (size: 49) ---


void __fastcall FUN_00505330(int param_1)



{

  FUN_00504d80();

  operator_delete__(*(void **)(param_1 + 0x28));

  operator_delete__(*(void **)(param_1 + 0x1c));

  operator_delete__(*(void **)(param_1 + 0x10));

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

  return;

}





// --- FUN_00505370 at 0x00505370 (size: 149) ---


undefined4 FUN_00505370(int param_1)



{

  uint uVar1;

  int iVar2;

  uint uVar3;

  int *piVar4;

  

  iVar2 = FUN_006b5980();

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

  uVar3 = (**(uint **)(iVar2 + 4) >>

          ((byte)*(undefined4 *)(&DAT_007c712c + DAT_00846774 * 4) & 0x1f)) / (uVar1 >> 0x1c);

  if (uVar3 < DAT_0081f928) {

    uVar3 = DAT_0081f928;

  }

  FUN_00536c20();

  iVar2 = FUN_00504eb0(uVar1,uVar3);

  if (iVar2 != 0) {

    piVar4 = (int *)FUN_005411d0(DAT_0084271c,uVar3,uVar3);

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

      iVar2 = FUN_00537090(piVar4,3);

      if (iVar2 != 0) {

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

        return 1;

      }

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

    }

  }

  return 0;

}





// --- FUN_00505410 at 0x00505410 (size: 132) ---


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



{

  int *piVar1;

  int iVar2;

  int *piVar3;

  

  param_3 = (*param_1 >> ((byte)*(undefined4 *)(&DAT_007c712c + DAT_00846774 * 4) & 0x1f)) / param_3

  ;

  if (param_3 < DAT_0081f928) {

    param_3 = DAT_0081f928;

  }

  piVar1 = (int *)FUN_00536fb0(3);

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

    (**(code **)(*piVar1 + 0x44))(param_2);

    iVar2 = FUN_00504eb0(param_2,param_3);

    if (iVar2 != 0) {

      piVar3 = (int *)FUN_005411d0(DAT_0084271c,param_3,param_3);

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

        FUN_00537090(piVar3,3);

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

      }

    }

  }

  return piVar1;

}





// --- FUN_005054a0 at 0x005054A0 (size: 17) ---


void __fastcall FUN_005054a0(int param_1)



{

  FUN_005aac70(param_1 + 4,param_1 + 0x3c);

  return;

}





// --- FUN_005054c0 at 0x005054C0 (size: 117) ---


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



{

  uint uVar1;

  int iVar2;

  int iVar3;

  

  if (param_1 == 0) {

    return 0;

  }

  if (param_2 == 0) {

    uVar1 = 0;

    iVar3 = 0;

  }

  else {

    uVar1 = param_2 >> 0x15 & 0x7f8;

    iVar3 = (param_2 >> 0x10 & 0xff) << 3;

  }

  iVar2 = uVar1 - (param_1 >> 0x15 & 0x7f8);

  *param_3 = (int)(iVar2 + (iVar2 >> 0x1f & 7U)) >> 3;

  iVar3 = iVar3 + (param_1 >> 0x10 & 0xff) * -8;

  *param_4 = (int)(iVar3 + (iVar3 >> 0x1f & 7U)) >> 3;

  return 1;

}





// --- FUN_00505540 at 0x00505540 (size: 121) ---


void __fastcall FUN_00505540(int param_1)



{

  FUN_0054c3d0(0);

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

    FUN_00536c10(*(int *)(param_1 + 0x24));

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

  }

  FUN_0054c3f0(0);

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

    FUN_00536c10(*(int *)(param_1 + 0x28));

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

  }

  FUN_0054c3e0(0);

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

    FUN_00536c10(*(int *)(param_1 + 0x2c));

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

  }

  FUN_0054c400(0);

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

    FUN_00536c10(*(int *)(param_1 + 0x30));

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

  }

  return;

}





// --- FUN_005055c0 at 0x005055C0 (size: 147) ---


void __fastcall FUN_005055c0(int param_1)



{

  int iVar1;

  int iVar2;

  

  if ((*(int *)(param_1 + 8) != 0) && (iVar1 = 0, 0 < *(int *)(param_1 + 4))) {

    do {

      iVar2 = 0;

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

        do {

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

            FUN_00530a30();

            *(undefined4 *)(*(int *)(param_1 + 8) + (*(int *)(param_1 + 4) * iVar1 + iVar2) * 4) = 0

            ;

          }

          iVar2 = iVar2 + 1;

        } while (iVar2 < *(int *)(param_1 + 4));

      }

      iVar1 = iVar1 + 1;

    } while (iVar1 < *(int *)(param_1 + 4));

  }

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

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

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

  }

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

    operator_delete__(*(void **)(param_1 + 0xc));

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

  }

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

    FUN_005081c0();

  }

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

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

  return;

}





// --- FUN_00505660 at 0x00505660 (size: 38) ---


undefined4 __thiscall FUN_00505660(int *param_1,int param_2)



{

  if ((0 < param_2) && (param_1[2] == 0)) {

    *param_1 = param_2;

    param_1[1] = param_2 * 2 + 1;

    return 1;

  }

  return 0;

}





// --- FUN_00505690 at 0x00505690 (size: 22) ---


void __fastcall FUN_00505690(int param_1)



{

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

    FUN_00507830();

    return;

  }

  return;

}





// --- FUN_005056b0 at 0x005056B0 (size: 602) ---


void __fastcall FUN_005056b0(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  int iVar7;

  int iVar8;

  int local_8;

  

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

    uVar2 = thunk_FUN_005df0f5(*(int *)(param_1 + 4) * *(int *)(param_1 + 4) * 4);

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

  }

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

       *(undefined4 *)

        (*(int *)(param_1 + 8) +

        (*(int *)(param_1 + 0x18) * *(int *)(param_1 + 4) + *(int *)(param_1 + 0x1c)) * 4);

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

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

  iVar8 = 1;

  local_8 = 1;

  if (iVar3 < iVar7) {

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

    if (iVar7 <= iVar3) goto LAB_00505718;

  }

  else {

    iVar7 = (*(int *)(param_1 + 4) - iVar7) + -1;

    if (iVar7 < iVar3) goto LAB_00505718;

  }

  iVar3 = iVar7;

LAB_00505718:

  if (0 < iVar3) {

    do {

      iVar7 = 0;

      if (0 < iVar8) {

        do {

          iVar4 = 0;

          do {

            iVar5 = *(int *)((int)&DAT_0081dd1c + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dcfc + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dcdc + iVar4) + *(int *)(param_1 + 0x18);

            iVar6 = *(int *)((int)&DAT_0081dc9c + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dcbc + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dc7c + iVar4) + *(int *)(param_1 + 0x1c);

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

            if ((((iVar5 < iVar1) && (iVar6 < iVar1)) && (-1 < iVar5)) && (-1 < iVar6)) {

              *(undefined4 *)(*(int *)(param_1 + 0xc) + local_8 * 4) =

                   *(undefined4 *)(*(int *)(param_1 + 8) + (iVar1 * iVar5 + iVar6) * 4);

              local_8 = local_8 + 1;

            }

            iVar5 = *(int *)((int)&DAT_0081dd20 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dd00 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dce0 + iVar4) + *(int *)(param_1 + 0x18);

            iVar6 = *(int *)((int)&DAT_0081dca0 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dcc0 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dc80 + iVar4) + *(int *)(param_1 + 0x1c);

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

            if (((iVar5 < iVar1) && (iVar6 < iVar1)) && ((-1 < iVar5 && (-1 < iVar6)))) {

              *(undefined4 *)(*(int *)(param_1 + 0xc) + local_8 * 4) =

                   *(undefined4 *)(*(int *)(param_1 + 8) + (iVar1 * iVar5 + iVar6) * 4);

              local_8 = local_8 + 1;

            }

            iVar5 = *(int *)((int)&DAT_0081dd24 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dd04 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dce4 + iVar4) + *(int *)(param_1 + 0x18);

            iVar6 = *(int *)((int)&DAT_0081dca4 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dcc4 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dc84 + iVar4) + *(int *)(param_1 + 0x1c);

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

            if (((iVar5 < iVar1) && (iVar6 < iVar1)) && ((-1 < iVar5 && (-1 < iVar6)))) {

              *(undefined4 *)(*(int *)(param_1 + 0xc) + local_8 * 4) =

                   *(undefined4 *)(*(int *)(param_1 + 8) + (iVar1 * iVar5 + iVar6) * 4);

              local_8 = local_8 + 1;

            }

            iVar5 = *(int *)((int)&DAT_0081dd28 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dd08 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dce8 + iVar4) + *(int *)(param_1 + 0x18);

            iVar6 = *(int *)((int)&DAT_0081dca8 + iVar4) * iVar7 +

                    *(int *)((int)&DAT_0081dcc8 + iVar4) * iVar8 +

                    *(int *)((int)&DAT_0081dc88 + iVar4) + *(int *)(param_1 + 0x1c);

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

            if ((((iVar5 < iVar1) && (iVar6 < iVar1)) && (-1 < iVar5)) && (-1 < iVar6)) {

              *(undefined4 *)(*(int *)(param_1 + 0xc) + local_8 * 4) =

                   *(undefined4 *)(*(int *)(param_1 + 8) + (iVar1 * iVar5 + iVar6) * 4);

              local_8 = local_8 + 1;

            }

            iVar4 = iVar4 + 0x10;

          } while (iVar4 < 0x20);

          iVar7 = iVar7 + 1;

        } while (iVar7 < iVar8);

      }

      iVar8 = iVar8 + 1;

    } while (iVar8 <= iVar3);

  }

  return;

}





// --- FUN_00505920 at 0x00505920 (size: 138) ---


void __fastcall FUN_00505920(int param_1)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  

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

  uVar3 = 0;

  if (uVar1 != 0) {

    do {

      uVar2 = 0;

      if (uVar1 != 0) {

        do {

          if (*(int *)(*(int *)(param_1 + 8) + (uVar1 * uVar3 + uVar2) * 4) != 0) {

            FUN_00530ac0();

            FUN_005301a0();

          }

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

          uVar2 = uVar2 + 1;

        } while (uVar2 < uVar1);

      }

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

      uVar3 = uVar3 + 1;

    } while (uVar3 < uVar1);

  }

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

  uVar3 = 0;

  if (uVar1 != 0) {

    do {

      uVar2 = 0;

      if (uVar1 != 0) {

        do {

          if (*(int *)(*(int *)(param_1 + 8) + (uVar1 * uVar3 + uVar2) * 4) != 0) {

            FUN_00531780(0);

            FUN_005300f0();

          }

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

          uVar2 = uVar2 + 1;

        } while (uVar2 < uVar1);

      }

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

      uVar3 = uVar3 + 1;

    } while (uVar3 < uVar1);

  }

  return;

}





// --- FUN_005059f0 at 0x005059F0 (size: 267) ---


void __thiscall FUN_005059f0(int *param_1,int param_2,int param_3,undefined4 *param_4,uint *param_5)



{

  int iVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  uint uVar5;

  uint uVar6;

  

  uVar5 = param_3 - *param_1;

  uVar6 = param_2 - *param_1;

  iVar3 = (uVar5 ^ (int)uVar5 >> 0x1f) - ((int)uVar5 >> 0x1f);

  iVar1 = (uVar6 ^ (int)uVar6 >> 0x1f) - ((int)uVar6 >> 0x1f);

  if (iVar1 <= iVar3) {

    iVar1 = iVar3;

  }

  if (iVar1 < 2) {

    *param_4 = 1;

    uVar2 = 1;

  }

  else if (iVar1 < 3) {

    *param_4 = 2;

    uVar2 = 2;

  }

  else {

    if (4 < iVar1) {

      *param_4 = 8;

      *param_5 = 0;

      return;

    }

    *param_4 = 4;

    uVar2 = 4;

  }

  if (uVar6 == uVar2) {

    if (uVar5 == uVar2) {

      *param_5 = 7;

      return;

    }

    *param_5 = ((uVar5 != -uVar2) - 1 & 5) + 3;

    return;

  }

  uVar4 = -uVar2;

  if (uVar6 != uVar4) {

    if (uVar5 == uVar2) {

      *param_5 = 1;

      return;

    }

    *param_5 = (uVar5 != uVar4) - 1 & 2;

    return;

  }

  if (uVar5 == uVar2) {

    *param_5 = 5;

    return;

  }

  *param_5 = (uint)(uVar5 == uVar4) * 2 + 4;

  return;

}





// --- FUN_00505b00 at 0x00505B00 (size: 166) ---


/* WARNING: Function: __chkstk replaced with injection: alloca_probe */

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



void FUN_00505b00(int param_1)



{

  float fVar1;

  float fVar2;

  int *piVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  undefined1 *puVar7;

  uint uVar8;

  int iVar9;

  undefined1 auStack_92c [128];

  undefined1 auStack_8ac [2172];

  undefined4 uStack_30;

  

  iVar4 = param_1;

  iVar5 = *(int *)(param_1 + 0x48);

  if (iVar5 == 8) {

    if (*(int *)(param_1 + 0xfc) == 2) {

      iVar5 = 0;

      if (0 < *(int *)(param_1 + 0x48) * *(int *)(param_1 + 0x48)) {

        iVar4 = 0;

        do {

          *(undefined4 *)(*(int *)(param_1 + 0x90) + 0x104 + iVar4) = 2;

          iVar5 = iVar5 + 1;

          iVar4 = iVar4 + 0x108;

        } while (iVar5 < *(int *)(param_1 + 0x48) * *(int *)(param_1 + 0x48));

        return;

      }

    }

    else {

      uStack_30 = 0x505bb6;

      puVar7 = auStack_92c;

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

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

      param_1 = 0;

      do {

        FUN_0054dc00(fVar1,(float)param_1 * _DAT_007c7178 + fVar2,puVar7);

        param_1 = param_1 + 1;

        puVar7 = puVar7 + 0x80;

      } while (param_1 < *(int *)(iVar4 + 0x48) + 1);

      iVar5 = *(int *)(iVar4 + 0x48);

      uVar8 = 0;

      if (0 < iVar5) {

        do {

          iVar5 = iVar5 + 1;

          param_1 = 0;

          if (0 < iVar5) {

            do {

              FUN_0054dc00((float)(int)(uVar8 + 1) * _DAT_007c7178 + fVar1,

                           (float)param_1 * _DAT_007c7178 + fVar2,

                           auStack_92c + ((uVar8 - 1 & 1) * iVar5 + param_1) * 0x80);

              param_1 = param_1 + 1;

              iVar5 = *(int *)(iVar4 + 0x48) + 1;

            } while (param_1 < iVar5);

          }

          iVar5 = *(int *)(iVar4 + 0x48);

          iVar9 = 0;

          if (0 < iVar5) {

            do {

              piVar3 = (int *)((iVar5 * uVar8 + iVar9) * 0x108 + *(int *)(iVar4 + 0x90));

              if ((piVar3 != (int *)0x0) && (iVar5 = (**(code **)(*piVar3 + 0x68))(), iVar5 == 0)) {

                iVar5 = *(int *)(iVar4 + 0x48) + 1;

                iVar6 = ((uVar8 - 1 & 1) * iVar5 + iVar9) * 0x80;

                iVar5 = ((uVar8 & 1) * iVar5 + iVar9) * 0x80;

                iVar5 = FUN_0054e860(auStack_92c + iVar5,auStack_8ac + iVar5,auStack_92c + iVar6,

                                     auStack_8ac + iVar6,*(undefined4 *)(iVar4 + 0xe0),

                                     *(undefined4 *)(iVar4 + 0xe4));

                piVar3[0x41] = iVar5;

              }

              iVar5 = *(int *)(iVar4 + 0x48);

              iVar9 = iVar9 + 1;

            } while (iVar9 < iVar5);

          }

          iVar5 = *(int *)(iVar4 + 0x48);

          uVar8 = uVar8 + 1;

        } while ((int)uVar8 < iVar5);

      }

    }

  }

  else {

    iVar4 = 0;

    if (0 < iVar5 * iVar5) {

      iVar5 = 0;

      do {

        *(undefined4 *)(*(int *)(param_1 + 0x90) + 0x104 + iVar5) = 1;

        iVar4 = iVar4 + 1;

        iVar5 = iVar5 + 0x108;

      } while (iVar4 < *(int *)(param_1 + 0x48) * *(int *)(param_1 + 0x48));

      return;

    }

  }

  return;

}





// --- FUN_00505bac at 0x00505BAC (size: 392) ---


/* WARNING: Function: __chkstk replaced with injection: alloca_probe */

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



void FUN_00505bac(void)



{

  undefined4 uVar1;

  int *piVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined1 *puVar6;

  uint uVar7;

  int unaff_EBP;

  int unaff_ESI;

  int iVar8;

  int iVar9;

  undefined1 auStack_900 [2300];

  undefined4 uStack_4;

  

  uStack_4 = 0x505bb6;

  puVar6 = auStack_900;

  uVar3 = *(undefined4 *)(unaff_ESI + 0xd4);

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

  iVar8 = 0;

  *(undefined1 **)(unaff_EBP + -4) = auStack_900;

  *(undefined4 *)(unaff_EBP + -0xc) = uVar3;

  *(undefined4 *)(unaff_EBP + -8) = uVar1;

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

  do {

    FUN_0054dc00(*(undefined4 *)(unaff_EBP + -0xc),

                 (float)*(int *)(unaff_EBP + 8) * _DAT_007c7178 + *(float *)(unaff_EBP + -8),puVar6)

    ;

    iVar9 = *(int *)(unaff_ESI + 0x48);

    iVar8 = iVar8 + 1;

    puVar6 = puVar6 + 0x80;

    *(int *)(unaff_EBP + 8) = iVar8;

  } while (iVar8 < iVar9 + 1);

  iVar8 = *(int *)(unaff_ESI + 0x48);

  uVar7 = 0;

  if (0 < iVar8) {

    do {

      iVar9 = 0;

      iVar8 = iVar8 + 1;

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

      if (0 < iVar8) {

        uVar4 = uVar7 - 1 & 1;

        *(uint *)(unaff_EBP + -0x10) = uVar7 + 1;

        *(uint *)(unaff_EBP + -0x14) = uVar4;

        *(float *)(unaff_EBP + -0x10) = (float)*(int *)(unaff_EBP + -0x10);

        while( true ) {

          FUN_0054dc00(*(float *)(unaff_EBP + -0x10) * _DAT_007c7178 + *(float *)(unaff_EBP + -0xc),

                       (float)*(int *)(unaff_EBP + 8) * _DAT_007c7178 + *(float *)(unaff_EBP + -8),

                       (uVar4 * iVar8 + iVar9) * 0x80 + *(int *)(unaff_EBP + -4));

          iVar9 = iVar9 + 1;

          iVar8 = *(int *)(unaff_ESI + 0x48) + 1;

          *(int *)(unaff_EBP + 8) = iVar9;

          if (iVar8 <= iVar9) break;

          uVar4 = *(uint *)(unaff_EBP + -0x14);

        }

      }

      iVar8 = *(int *)(unaff_ESI + 0x48);

      iVar9 = 0;

      if (0 < iVar8) {

        do {

          piVar2 = (int *)((iVar8 * uVar7 + iVar9) * 0x108 + *(int *)(unaff_ESI + 0x90));

          *(int **)(unaff_EBP + 8) = piVar2;

          if ((piVar2 != (int *)0x0) && (iVar8 = (**(code **)(*piVar2 + 0x68))(), iVar8 == 0)) {

            uVar3 = *(undefined4 *)(unaff_ESI + 0xe0);

            *(undefined4 *)(unaff_EBP + -0x18) = *(undefined4 *)(unaff_ESI + 0xe4);

            iVar8 = *(int *)(unaff_ESI + 0x48) + 1;

            *(undefined4 *)(unaff_EBP + -0x1c) = uVar3;

            iVar5 = *(int *)(unaff_EBP + -4) + ((uVar7 - 1 & 1) * iVar8 + iVar9) * 0x80;

            iVar8 = *(int *)(unaff_EBP + -4) + ((uVar7 & 1) * iVar8 + iVar9) * 0x80;

            uVar3 = FUN_0054e860(iVar8,iVar8 + 0x80,iVar5,iVar5 + 0x80,

                                 *(undefined4 *)(unaff_EBP + -0x1c),

                                 *(undefined4 *)(unaff_EBP + -0x18));

            *(undefined4 *)(*(int *)(unaff_EBP + 8) + 0x104) = uVar3;

          }

          iVar8 = *(int *)(unaff_ESI + 0x48);

          iVar9 = iVar9 + 1;

        } while (iVar9 < iVar8);

      }

      iVar8 = *(int *)(unaff_ESI + 0x48);

      uVar7 = uVar7 + 1;

    } while ((int)uVar7 < iVar8);

  }

  return;

}





// --- FUN_00505d40 at 0x00505D40 (size: 55) ---


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



void FUN_00505d40(int param_1)



{

  DAT_008427a8 = param_1 != 0;

  _DAT_00842798 = 0;

  _DAT_0084279c = 0;

  _DAT_008427a0 = 0;

  _DAT_008427a4 = 0;

  return;

}





// --- FUN_00505d80 at 0x00505D80 (size: 68) ---


uint * FUN_00505d80(uint *param_1,uint param_2,int param_3)



{

  if ((((-1 < (int)param_2) && (-1 < param_3)) && ((int)param_2 < 0x7f8)) && (param_3 < 0x7f8)) {

    *param_1 = ((param_2 & 0xfffffff8) << 5 | param_3 >> 3) << 0x10 | 0xffff;

    return param_1;

  }

  *param_1 = 0;

  return param_1;

}





// --- FUN_00505dd0 at 0x00505DD0 (size: 157) ---


undefined4 * __fastcall FUN_00505dd0(undefined4 *param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[9] = 0;

  param_1[10] = 0;

  param_1[0xb] = 0;

  param_1[0xc] = 0;

  *param_1 = 5;

  param_1[1] = 0xb;

  DAT_00842780 = 0x3ecccccd;

  DAT_00842950 = 0x3f99999a;

  DAT_00842954 = 0;

  DAT_00842958 = 0x3f000000;

  FUN_00530850();

  iVar1 = FUN_005df0f5(0x2c);

  if (iVar1 != 0) {

    uVar2 = FUN_00507c50();

    param_1[8] = uVar2;

    return param_1;

  }

  param_1[8] = 0;

  return param_1;

}





// --- FUN_00505e70 at 0x00505E70 (size: 76) ---


void __fastcall FUN_00505e70(int param_1)



{

  void *pvVar1;

  

  FUN_005055c0();

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

    operator_delete__(DAT_00842790);

    DAT_00842790 = (void *)0x0;

  }

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

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

    FUN_00507d40();

    operator_delete(pvVar1);

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

  }

  FUN_00505540();

  return;

}





// --- FUN_00505ec0 at 0x00505EC0 (size: 100) ---


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



void __thiscall FUN_00505ec0(int param_1,int param_2,int param_3,int param_4)



{

  int iVar1;

  

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

  *(float *)(param_2 + 0xd4) = (float)(param_3 - *(int *)(param_1 + 0x18)) * _DAT_00842824;

  *(float *)(param_2 + 0xd8) = (float)(param_4 - iVar1) * _DAT_00842824;

  *(undefined4 *)(param_2 + 0xdc) = 0;

  return;

}





// --- FUN_00505f30 at 0x00505F30 (size: 392) ---


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



void __thiscall

FUN_00505f30(int param_1,float param_2,undefined4 param_3,float *param_4,undefined4 param_5)



{

  float fVar1;

  float fVar2;

  float fVar3;

  int iVar4;

  int iVar5;

  int iVar6;

  

  DAT_00842780 = param_2;

  DAT_0084277c = param_3;

  if (DAT_008427a8 == '\0') {

    DAT_00842950 = *param_4;

    DAT_00842954 = param_4[1];

    DAT_00842958 = param_4[2];

    DAT_00842778 = param_5;

  }

  else {

    iVar4 = FUN_004ff440(0x3f000000,&DAT_00842780,&DAT_0084277c,&DAT_00842950,&DAT_00842778);

    if ((iVar4 != 0) && (DAT_00842780 < DAT_0084295c)) {

      DAT_00842780 = DAT_0084295c;

    }

  }

  fVar3 = DAT_00842958;

  fVar2 = DAT_00842954;

  fVar1 = DAT_00842950;

  _DAT_008682c8 = DAT_00842950;

  _DAT_008682d0 = DAT_00842958;

  _DAT_008682cc = DAT_00842954;

  FUN_00451a60(DAT_00842778);

  _DAT_008682c0 = fVar2;

  _DAT_008682bc = fVar1;

  _DAT_008682c4 = fVar3;

  DAT_008682d4 = 0;

  if (DAT_0083da58 != 0) {

    FUN_004530e0(SQRT(DAT_00842950 * DAT_00842950 +

                      DAT_00842954 * DAT_00842954 + DAT_00842958 * DAT_00842958) * _DAT_0079a1e8 +

                 DAT_00842780,DAT_0084277c);

  }

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

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

    iVar5 = 0;

    if (0 < iVar4) {

      do {

        iVar6 = 0;

        if (0 < iVar4) {

          do {

            if (*(int *)(*(int *)(param_1 + 8) + (iVar4 * iVar5 + iVar6) * 4) != 0) {

              FUN_00532440();

            }

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

            iVar6 = iVar6 + 1;

          } while (iVar6 < iVar4);

        }

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

        iVar5 = iVar5 + 1;

      } while (iVar5 < iVar4);

    }

  }

  return;

}





// --- FUN_005060c0 at 0x005060C0 (size: 422) ---


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



{

  uint uVar1;

  undefined4 uVar2;

  int iVar3;

  int *piVar4;

  int *piVar5;

  int iVar6;

  int iVar7;

  undefined4 local_3c;

  int local_30;

  int local_28;

  

  local_3c = 1;

  piVar5 = param_1;

  if (param_2 != 0) {

    local_28 = (param_2 >> 0x10 & 0xff) << 3;

    piVar5 = (int *)(param_2 >> 0x15 & 0x7f8);

  }

  *param_3 = 0;

  iVar7 = *param_1;

  iVar6 = -iVar7;

  if (-iVar7 != iVar7 && iVar7 <= iVar6) {

    return 1;

  }

  piVar5 = piVar5 + iVar7 * -2;

  do {

    local_30 = -iVar7;

    if (-iVar7 == iVar7 || local_30 < iVar7) {

      iVar7 = local_28 + iVar7 * -8;

      do {

        if (((((int)piVar5 < 0) || (iVar7 < 0)) || (0x7f7 < (int)piVar5)) || (0x7f7 < iVar7)) {

          uVar1 = 0;

        }

        else {

          uVar1 = (((uint)piVar5 & 0xfffffff8) << 5 | iVar7 >> 3) << 0x10 | 0xffff;

        }

        if (uVar1 != DAT_0084282c) {

          uVar2 = FUN_004220b0(uVar1,1);

          iVar3 = thunk_FUN_00413a30(uVar2);

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

            uVar2 = FUN_004220b0(uVar1,1);

            piVar4 = (int *)FUN_00415430(uVar2);

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

              uVar2 = FUN_004220b0(uVar1 & 0xfffffffe | 0xfffe,2);

              thunk_FUN_00413a30(uVar2);

              goto LAB_00506210;

            }

            iVar3 = FUN_00530f80();

            if (iVar3 == 0) {

              local_3c = 0;

            }

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

          }

          else {

            local_3c = 0;

            if (iVar3 == -1) {

LAB_00506210:

              local_3c = 0;

              *param_3 = *param_3 + 1;

            }

          }

        }

        local_30 = local_30 + 1;

        iVar7 = iVar7 + 8;

      } while (local_30 <= *param_1);

    }

    iVar7 = *param_1;

    iVar6 = iVar6 + 1;

    piVar5 = piVar5 + 2;

    if (iVar7 < iVar6) {

      return local_3c;

    }

  } while( true );

}





// --- FUN_00506270 at 0x00506270 (size: 103) ---


void __thiscall FUN_00506270(int param_1,undefined4 param_2)



{

  uint uVar1;

  uint uVar2;

  uint uVar3;

  int local_8;

  undefined1 local_4 [4];

  

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

  uVar1 = 0;

  if (uVar2 != 0) {

    do {

      uVar3 = 0;

      if (uVar2 != 0) {

        do {

          FUN_005059f0(uVar1,uVar3,&local_8,local_4);

          if ((local_8 == 1) && (*(int *)(*(int *)(param_1 + 8) + (uVar2 * uVar1 + uVar3) * 4) != 0)

             ) {

            FUN_00531050(param_2);

          }

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

          uVar3 = uVar3 + 1;

        } while (uVar3 < uVar2);

      }

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

      uVar1 = uVar1 + 1;

    } while (uVar1 < uVar2);

  }

  return;

}





// --- FUN_005062e0 at 0x005062E0 (size: 1008) ---


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



void __fastcall FUN_005062e0(int param_1)



{

  float fVar1;

  uint uVar2;

  byte bVar3;

  ushort uVar4;

  undefined1 uVar5;

  undefined1 uVar6;

  int iVar7;

  undefined4 local_28;

  float local_24;

  undefined4 local_20;

  float local_1c;

  int local_18;

  double local_14;

  undefined1 local_c [12];

  

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

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

      FUN_00508010();

    }

    local_14 = _DAT_008379a8;

    if ((_DAT_00842798 <= _DAT_008379a8) && (DAT_0084247c != 0)) {

      _DAT_00842798 = *(double *)(*(int *)(DAT_0084247c + 0x50) + 8) + _DAT_008379a8;

      if (DAT_008ee9c8 == 0) {

        fVar1 = (float)_DAT_00795610;

      }

      else {

        fVar1 = *(float *)(DAT_008ee9c8 + 0x48);

      }

      local_1c = fVar1;

      if (_DAT_008427a0 < _DAT_008379a8) {

        iVar7 = FUN_004ff440(fVar1,&local_24,&local_20,local_c,&local_18);

        uVar2 = DAT_00842788;

        if (iVar7 != 0) {

          if (local_24 < DAT_0084295c) {

            local_24 = DAT_0084295c;

          }

          if (DAT_008427a9 != '\0') {

            if (_DAT_007938b0 <= _DAT_008427b8) {

              local_24 = DAT_008427ac;

              local_20 = DAT_00842788;

            }

            else {

              uVar4 = local_20._2_2_;

              local_1c = (float)((local_20._2_2_ & 0xff) - (DAT_00842788 >> 0x10 & 0xff));

              uVar5 = FUN_005df4c4();

              local_28._3_1_ = (byte)(uVar2 >> 0x18);

              bVar3 = local_28._3_1_;

              local_28._0_2_ = (undefined2)uVar2;

              local_28._0_3_ = CONCAT12(uVar5,(undefined2)local_28);

              local_1c = (float)((local_20 >> 8 & 0xff) - (uVar2 >> 8 & 0xff));

              uVar5 = FUN_005df4c4();

              uVar2 = (uint)(uint3)local_28;

              local_1c = (float)((local_20 & 0xff) - (uVar2 & 0xff));

              uVar6 = FUN_005df4c4();

              local_28 = CONCAT31(CONCAT21(local_28._2_2_,uVar5),uVar6);

              local_1c = (float)((uint)(uVar4 >> 8) - (uint)bVar3);

              uVar5 = FUN_005df4c4();

              local_28 = CONCAT13(uVar5,(uint3)local_28);

              local_20 = local_28;

              local_24 = local_24 - (local_24 - DAT_008427ac) * _DAT_008427b8;

              _DAT_008427b8 = _DAT_008427b8 + _DAT_007c7208;

            }

          }

          FUN_00505f30(local_24,local_20,local_c,local_18);

        }

        _DAT_008427a0 = _DAT_007c7200;

        if (DAT_0084247c != 0) {

          _DAT_008427a0 = *(double *)(*(int *)(DAT_0084247c + 0x50) + 0x10);

        }

        _DAT_008427a0 = _DAT_008427a0 + local_14;

      }

      FUN_005a4010(DAT_0081dbf8 == '\0');

      if (DAT_0081dbf8 != '\0') {

        FUN_005a3f90(DAT_0081dbf8);

        iVar7 = FUN_004ff480(fVar1,&local_1c,&local_24,&local_20);

        uVar2 = DAT_00842784;

        if (iVar7 != 0) {

          if (DAT_008427a9 != '\0') {

            if (_DAT_007938b0 <= _DAT_008427b8) {

              local_1c = DAT_008427b0;

              local_24 = DAT_008427b4;

              local_20 = DAT_00842784;

            }

            else {

              uVar4 = local_20._2_2_;

              local_18 = (local_20._2_2_ & 0xff) - (DAT_00842784 >> 0x10 & 0xff);

              uVar5 = FUN_005df4c4();

              local_28._3_1_ = (byte)(uVar2 >> 0x18);

              bVar3 = local_28._3_1_;

              local_28._0_2_ = (undefined2)uVar2;

              local_28._0_3_ = CONCAT12(uVar5,(undefined2)local_28);

              local_18 = (local_20 >> 8 & 0xff) - (uVar2 >> 8 & 0xff);

              uVar5 = FUN_005df4c4();

              uVar2 = (uint)(uint3)local_28;

              local_18 = (local_20 & 0xff) - (uVar2 & 0xff);

              uVar6 = FUN_005df4c4();

              local_28 = CONCAT31(CONCAT21(local_28._2_2_,uVar5),uVar6);

              local_18 = (uint)(uVar4 >> 8) - (uint)bVar3;

              uVar5 = FUN_005df4c4();

              local_28 = CONCAT13(uVar5,(uint3)local_28);

              local_1c = local_1c - (local_1c - DAT_008427b0) * _DAT_008427b8;

              local_24 = local_24 - (local_24 - DAT_008427b4) * _DAT_008427b8;

              _DAT_008427b8 = _DAT_008427b8 + _DAT_007c7208;

              local_20 = local_28;

            }

          }

          FUN_005a41b0(&local_20,local_1c,local_24);

          return;

        }

      }

    }

  }

  return;

}





// --- FUN_005066d0 at 0x005066D0 (size: 347) ---


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



{

  uint uVar1;

  uint uVar2;

  int iVar3;

  uint uVar4;

  int iVar5;

  uint uVar6;

  uint local_18;

  uint local_14;

  uint local_10;

  uint local_c;

  

  if (param_2 != 0) {

    local_18 = param_1[4];

    uVar4 = local_14;

    uVar6 = local_14;

    if (local_18 != 0) {

      uVar4 = (local_18 >> 0x10 & 0xff) << 3;

      uVar6 = local_18 >> 0x15 & 0x7f8;

    }

    FUN_00497d70(param_2,&local_18,&local_14);

    uVar2 = local_14;

    uVar1 = local_18;

    iVar5 = (int)((*param_1 * 8 - uVar6) + local_18) >> 3;

    iVar3 = (int)((*param_1 * 8 - uVar4) + local_14) >> 3;

    param_1[6] = iVar5;

    param_1[7] = iVar3;

    if ((((iVar5 < param_1[1]) && (iVar3 < param_1[1])) && (-1 < iVar5)) && (-1 < iVar3)) {

      if (param_3 != 0) {

        FUN_005056b0();

      }

      local_10 = uVar1 & 7;

      local_c = uVar2 & 7;

      local_18 = 0;

      if (0 < param_1[1]) {

        do {

          iVar3 = 0;

          uVar4 = local_18;

          if (0 < param_1[1]) {

            do {

              iVar5 = *(int *)(param_1[2] + (param_1[1] * uVar4 + iVar3) * 4);

              if (iVar5 != 0) {

                local_14 = FUN_005aab50(uVar4 - param_1[6],iVar3 - param_1[7]);

                FUN_00505ec0(iVar5,local_18,iVar3);

                thunk_FUN_005301e0(local_14,&local_10);

                uVar4 = local_18;

              }

              iVar3 = iVar3 + 1;

            } while (iVar3 < param_1[1]);

          }

          local_18 = uVar4 + 1;

        } while ((int)local_18 < param_1[1]);

        return;

      }

    }

    else {

      FUN_00506d30(0);

    }

  }

  return;

}





// --- FUN_00506830 at 0x00506830 (size: 100) ---


void FUN_00506830(uint param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  uVar1 = FUN_004220b0(param_1,1);

  iVar2 = FUN_00415430(uVar1);

  if (iVar2 != 0) {

    if (param_1 != 0) {

      *(uint *)(iVar2 + 0x98) = param_1 >> 0x15 & 0x7f8;

      *(uint *)(iVar2 + 0x9c) = (param_1 >> 0x10 & 0xff) << 3;

      return;

    }

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

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

  }

  return;

}





// --- FUN_005068a0 at 0x005068A0 (size: 196) ---


uint __thiscall FUN_005068a0(int *param_1,uint param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  int iVar4;

  int iVar5;

  int local_c;

  int local_8;

  int local_4;

  

  uVar3 = param_2;

  iVar1 = param_1[2];

  if (iVar1 == 0) {

    return 0;

  }

  iVar4 = FUN_00497c80(param_2);

  if ((iVar4 != 0) && ((uVar3 & 0xffff) < 0x100)) {

    FUN_0043d820(param_1[4],&param_2,&local_8);

    FUN_00497d70(uVar3,&local_c,&local_4);

    iVar5 = (int)((*param_1 * 8 - param_2) + local_c) >> 3;

    iVar4 = (*param_1 * 8 - local_8) + local_4 >> 3;

    if (((-1 < iVar5) && (((-1 < iVar4 && (iVar2 = param_1[1], iVar5 < iVar2)) && (iVar4 < iVar2))))

       && (uVar3 = *(uint *)(iVar1 + (iVar2 * iVar5 + iVar4) * 4), uVar3 != 0)) {

      return (*(int *)(uVar3 + 0x48) != 8) - 1 & uVar3;

    }

  }

  return 0;

}





// --- FUN_00506970 at 0x00506970 (size: 106) ---


int FUN_00506970(uint param_1)



{

  uint uVar1;

  int iVar2;

  uint local_4;

  

  uVar1 = param_1;

  iVar2 = FUN_005068a0(param_1);

  if (iVar2 == 0) {

    return 0;

  }

  FUN_00497d70(uVar1,&param_1,&local_4);

  param_1 = param_1 & 0x80000007;

  if ((int)param_1 < 0) {

    param_1 = (param_1 - 1 | 0xfffffff8) + 1;

  }

  local_4 = local_4 & 0x80000007;

  if ((int)local_4 < 0) {

    local_4 = (local_4 - 1 | 0xfffffff8) + 1;

  }

  return (*(int *)(iVar2 + 0x48) * param_1 + local_4) * 0x108 + *(int *)(iVar2 + 0x90);

}





// --- FUN_005069e0 at 0x005069E0 (size: 681) ---


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



void __fastcall FUN_005069e0(int param_1)



{

  bool bVar1;

  void *pvVar2;

  void *pvVar3;

  int iVar4;

  int iVar5;

  uint uVar6;

  int iVar7;

  int iVar8;

  int local_18;

  int local_14;

  int local_10;

  

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

  local_14 = 0;

  if (0 < iVar7) {

    do {

      iVar5 = 0;

      if (0 < iVar7) {

        do {

          iVar7 = *(int *)(*(int *)(param_1 + 8) + (iVar7 * local_14 + iVar5) * 4);

          iVar4 = 0;

          if ((iVar7 != 0) &&

             (*(undefined4 *)(iVar7 + 0xfc) = 0, 0 < *(int *)(iVar7 + 0x48) * *(int *)(iVar7 + 0x48)

             )) {

            iVar8 = 0;

            do {

              *(undefined4 *)(*(int *)(iVar7 + 0x90) + 0x104 + iVar8) = 0;

              iVar4 = iVar4 + 1;

              iVar8 = iVar8 + 0x108;

            } while (iVar4 < *(int *)(iVar7 + 0x48) * *(int *)(iVar7 + 0x48));

          }

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

          iVar5 = iVar5 + 1;

        } while (iVar5 < iVar7);

      }

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

      local_14 = local_14 + 1;

    } while (local_14 < iVar7);

  }

  iVar7 = 0;

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

    if (DAT_00842960 == *(int *)(param_1 + 4)) goto LAB_00506a9e;

    operator_delete__(DAT_00842790);

  }

  DAT_00842790 = (void *)thunk_FUN_005df0f5((*(int *)(param_1 + 4) + 1) * 0x100);

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

LAB_00506a9e:

  bVar1 = false;

  local_10 = 0;

  if (DAT_00867330 == 0) {

    local_18 = 0;

  }

  else {

    local_18 = *(int *)(DAT_00867330 + 0x38);

  }

  do {

    if (local_18 == 0) {

LAB_00506aea:

      bVar1 = true;

    }

    else {

      FUN_0054dcf0(DAT_00867330 + 0x10,iVar7);

      iVar7 = iVar7 + 1;

      local_10 = iVar7;

      if (iVar7 == local_18) goto LAB_00506aea;

    }

    iVar5 = 0;

    if (*(int *)(param_1 + 4) != -1 && -1 < *(int *)(param_1 + 4) + 1) {

      iVar4 = 0;

      do {

        FUN_0054dc00((float)-*(int *)(param_1 + 0x18) * _DAT_00842824,

                     (float)(iVar5 - *(int *)(param_1 + 0x1c)) * _DAT_00842824,

                     iVar4 + (int)DAT_00842790);

        iVar5 = iVar5 + 1;

        iVar4 = iVar4 + 0x80;

      } while (iVar5 < *(int *)(param_1 + 4) + 1);

    }

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

    uVar6 = 0;

    if (0 < iVar5) {

      do {

        iVar7 = 0;

        iVar5 = iVar5 + 1;

        if (0 < iVar5) {

          do {

            FUN_0054dc00((float)(int)((uVar6 - *(int *)(param_1 + 0x18)) + 1) * _DAT_00842824,

                         (float)(iVar7 - *(int *)(param_1 + 0x1c)) * _DAT_00842824,

                         (void *)(((uVar6 - 1 & 1) * iVar5 + iVar7) * 0x80 + (int)DAT_00842790));

            iVar7 = iVar7 + 1;

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

          } while (iVar7 < iVar5);

        }

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

        iVar5 = 0;

        if (0 < iVar7) {

          do {

            iVar4 = *(int *)(*(int *)(param_1 + 8) + (iVar7 * uVar6 + iVar5) * 4);

            if ((iVar4 != 0) &&

               (pvVar3 = (void *)(((uVar6 - 1 & 1) * (iVar7 + 1) + iVar5) * 0x80 + (int)DAT_00842790

                                 ),

               pvVar2 = (void *)((int)DAT_00842790 + ((uVar6 & 1) * (iVar7 + 1) + iVar5) * 0x80),

               iVar7 = FUN_0054e860(pvVar2,(int)pvVar2 + 0x80,pvVar3,(int)pvVar3 + 0x80,

                                    *(undefined4 *)(iVar4 + 0xe0),*(undefined4 *)(iVar4 + 0xe4)),

               iVar7 != 0)) {

              *(int *)(iVar4 + 0xfc) = iVar7;

              FUN_00505b00(iVar4);

            }

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

            iVar5 = iVar5 + 1;

          } while (iVar5 < iVar7);

        }

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

        uVar6 = uVar6 + 1;

        iVar7 = local_10;

      } while ((int)uVar6 < iVar5);

    }

    if (bVar1) {

      return;

    }

  } while( true );

}





// --- FUN_00506c90 at 0x00506C90 (size: 146) ---


int FUN_00506c90(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 *puVar4;

  

  puVar4 = &param_1;

  iVar1 = param_1;

  FUN_006b5980(puVar4,param_1);

  FUN_00503770(puVar4,iVar1);

  if (param_1 == DAT_0084282c) {

    return 0;

  }

  iVar1 = FUN_00536fb0(4);

  if (iVar1 != 0) {

    uVar2 = FUN_004220b0(param_1,0xb);

    iVar3 = FUN_00415430(uVar2);

    if (iVar3 != 0) {

      FUN_00537090(iVar3,4);

      *(uint *)(iVar1 + 0x58) = *(uint *)(iVar1 + 0x58) | 0x20000;

      return iVar1;

    }

    FUN_00536c10(iVar1);

  }

  return 0;

}





// --- FUN_00506d30 at 0x00506D30 (size: 88) ---


void __thiscall FUN_00506d30(int param_1,uint param_2)



{

  uint uVar1;

  

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

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

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

      operator_delete__(*(void **)(param_1 + 0xc));

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

    }

  }

  else {

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

    if (param_2 != uVar1) {

      *(uint *)(param_1 + 0x14) = param_2;

      FUN_005066d0(param_2,((uVar1 ^ param_2) & 0xffff0000) != 0);

      return;

    }

  }

  return;

}





// --- FUN_00506d90 at 0x00506D90 (size: 109) ---


void __fastcall FUN_00506d90(int param_1)



{

  int iVar1;

  int iVar2;

  

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

    FUN_00507a50(0);

  }

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

    FUN_005069e0();

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

    while (iVar2 = iVar2 + -1, -1 < iVar2) {

      iVar1 = *(int *)(*(int *)(param_1 + 0xc) + iVar2 * 4);

      if ((iVar1 != 0) && (*(int *)(iVar1 + 0xfc) != 0)) {

        (**(code **)(*DAT_00870340 + 0x50))(iVar1);

      }

    }

    if ((*(int *)(param_1 + 0x20) != 0) && (DAT_0081dbf9 != '\0')) {

      FUN_00507a50(1);

    }

  }

  return;

}





// --- FUN_00506e00 at 0x00506E00 (size: 1931) ---


void __thiscall FUN_00506e00(int *param_1,uint param_2,uint param_3,int param_4,uint param_5)



{

  int iVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  int iVar4;

  uint uVar5;

  uint uVar6;

  uint uVar7;

  int iVar8;

  int iVar9;

  uint local_10;

  uint local_c;

  undefined1 local_8 [8];

  

  FUN_00497d70(param_2,&local_c,&param_2);

  param_2 = param_2 + *param_1 * -8;

  uVar7 = local_c + *param_1 * -8;

  iVar9 = 0;

  if (((((param_1[2] == 0) || (param_5 != 0)) || (iVar8 = param_1[1], iVar8 <= (int)param_3)) ||

      ((iVar8 <= param_4 || ((int)param_3 <= -iVar8)))) || (param_4 <= -iVar8)) {

    FUN_005055c0();

    if (param_1[2] == 0) {

      iVar9 = thunk_FUN_005df0f5(param_1[1] * param_1[1] * 4);

      param_1[2] = iVar9;

    }

    param_4 = 0;

    if (0 < param_1[1]) {

      do {

        param_3 = uVar7;

        iVar9 = 0;

        uVar7 = param_2;

        if (0 < param_1[1]) {

          do {

            if ((((int)param_3 < 0) || ((int)uVar7 < 0)) ||

               ((0x7f7 < (int)param_3 || (0x7f7 < (int)uVar7)))) {

              *(undefined4 *)(param_1[2] + (param_1[1] * param_4 + iVar9) * 4) = 0;

            }

            else {

              uVar5 = ((param_3 & 0xfffffff8) << 5 | (int)uVar7 >> 3) << 0x10;

              uVar6 = uVar5 | 0xffff;

              param_5 = uVar6;

              uVar3 = FUN_004220b0(uVar6,1);

              iVar8 = FUN_00415430(uVar3);

              if (iVar8 != 0) {

                if (uVar6 != 0) {

                  local_10 = (uVar5 & 0xff000000) >> 0x15;

                  local_c = (param_5 >> 0x10 & 0xff) << 3;

                }

                *(uint *)(iVar8 + 0x98) = local_10;

                *(uint *)(iVar8 + 0x9c) = local_c;

              }

              *(int *)(param_1[2] + (param_1[1] * param_4 + iVar9) * 4) = iVar8;

            }

            iVar9 = iVar9 + 1;

            uVar7 = uVar7 + 8;

          } while (iVar9 < param_1[1]);

        }

        param_4 = param_4 + 1;

        param_3 = param_3 + 8;

        uVar7 = param_3;

      } while (param_4 < param_1[1]);

    }

  }

  else {

    if (param_3 == 0) {

      if (param_4 == 0) {

        param_4 = 0;

        if (0 < iVar8) {

          do {

            param_5 = uVar7;

            iVar9 = 0;

            if (0 < param_1[1]) {

              param_3 = param_2;

              do {

                iVar4 = param_1[2];

                iVar8 = param_1[1] * param_4 + iVar9;

                if (*(int *)(iVar4 + iVar8 * 4) == 0) {

                  iVar1 = FUN_0043d7f0(param_5,param_3);

                  if (iVar1 == 0) {

                    *(undefined4 *)(iVar4 + iVar8 * 4) = 0;

                  }

                  else {

                    puVar2 = (undefined4 *)FUN_00505d80(&local_c,param_5,param_3);

                    uVar3 = FUN_00506830(*puVar2);

                    *(undefined4 *)(param_1[2] + iVar8 * 4) = uVar3;

                  }

                }

                iVar9 = iVar9 + 1;

                param_3 = param_3 + 8;

              } while (iVar9 < param_1[1]);

            }

            param_4 = param_4 + 1;

            param_5 = param_5 + 8;

            uVar7 = param_5;

          } while (param_4 < param_1[1]);

        }

        goto LAB_005074c7;

      }

    }

    else if ((int)param_3 < 0) {

      iVar8 = iVar8 + -1;

      if (param_4 < 0) {

        if (-1 < iVar8) {

          local_10 = uVar7 + iVar8 * 8;

          do {

            iVar9 = param_1[1] + -1;

            if (-1 < iVar9) {

              param_5 = iVar9 + param_4;

              local_c = param_2 + iVar9 * 8;

              do {

                uVar7 = param_3;

                iVar4 = param_1[1];

                if ((((int)(iVar4 + param_3) <= iVar8) || (iVar4 + param_4 <= iVar9)) &&

                   (*(int *)(param_1[2] + (iVar4 * iVar8 + iVar9) * 4) != 0)) {

                  FUN_00530a30();

                }

                if (((int)(uVar7 + iVar8) < 0) || ((int)param_5 < 0)) {

                  iVar4 = FUN_0043d7f0(local_10,local_c);

                  if (iVar4 == 0) {

                    *(undefined4 *)(param_1[2] + (param_1[1] * iVar8 + iVar9) * 4) = 0;

                  }

                  else {

                    puVar2 = (undefined4 *)FUN_00505d80(local_8,local_10,local_c);

                    iVar4 = param_1[1];

                    uVar3 = FUN_00506830(*puVar2);

                    *(undefined4 *)(param_1[2] + (iVar4 * iVar8 + iVar9) * 4) = uVar3;

                  }

                }

                else {

                  *(undefined4 *)(param_1[2] + (param_1[1] * iVar8 + iVar9) * 4) =

                       *(undefined4 *)(param_1[2] + (param_1[1] * (uVar7 + iVar8) + param_5) * 4);

                }

                iVar9 = iVar9 + -1;

                param_5 = param_5 - 1;

                local_c = local_c - 8;

              } while (-1 < iVar9);

            }

            iVar8 = iVar8 + -1;

            local_10 = local_10 + -8;

          } while (-1 < iVar8);

        }

      }

      else if (-1 < iVar8) {

        local_c = uVar7 + iVar8 * 8;

        do {

          iVar9 = 0;

          if (0 < param_1[1]) {

            param_5 = param_2;

            do {

              uVar7 = param_3;

              if ((((int)(param_1[1] + param_3) <= iVar8) || (iVar9 < param_4)) &&

                 (*(int *)(param_1[2] + (param_1[1] * iVar8 + iVar9) * 4) != 0)) {

                FUN_00530a30();

              }

              if (((int)(uVar7 + iVar8) < 0) || (iVar4 = param_1[1], iVar4 <= param_4 + iVar9)) {

                iVar4 = FUN_0043d7f0(local_c,param_5);

                if (iVar4 == 0) {

                  *(undefined4 *)(param_1[2] + (param_1[1] * iVar8 + iVar9) * 4) = 0;

                }

                else {

                  puVar2 = (undefined4 *)FUN_00505d80(local_8,local_c,param_5);

                  iVar4 = param_1[1];

                  uVar3 = FUN_00506830(*puVar2);

                  *(undefined4 *)(param_1[2] + (iVar4 * iVar8 + iVar9) * 4) = uVar3;

                }

              }

              else {

                *(undefined4 *)(param_1[2] + (iVar4 * iVar8 + iVar9) * 4) =

                     *(undefined4 *)(param_1[2] + (iVar4 * (uVar7 + iVar8) + param_4 + iVar9) * 4);

              }

              iVar9 = iVar9 + 1;

              param_5 = param_5 + 8;

            } while (iVar9 < param_1[1]);

          }

          iVar8 = iVar8 + -1;

          local_c = local_c - 8;

        } while (-1 < iVar8);

      }

      goto LAB_005074c7;

    }

    if (param_4 < 0) {

      iVar9 = 0;

      if (0 < iVar8) {

        do {

          local_c = uVar7;

          iVar8 = param_1[1] + -1;

          if (-1 < iVar8) {

            param_5 = iVar8 + param_4;

            local_10 = param_2 + iVar8 * 8;

            do {

              if (((iVar9 < (int)param_3) || (param_1[1] + param_4 <= iVar8)) &&

                 (*(int *)(param_1[2] + (param_1[1] * iVar9 + iVar8) * 4) != 0)) {

                FUN_00530a30();

              }

              iVar4 = param_1[1];

              if (((int)(param_3 + iVar9) < iVar4) && (-1 < (int)param_5)) {

                *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) =

                     *(undefined4 *)(param_1[2] + (iVar4 * (param_3 + iVar9) + param_5) * 4);

              }

              else {

                iVar1 = FUN_0043d7f0(local_c,local_10);

                if (iVar1 == 0) {

                  *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) = 0;

                }

                else {

                  puVar2 = (undefined4 *)FUN_00505d80(local_8,local_c,local_10);

                  uVar3 = FUN_00506830(*puVar2);

                  *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) = uVar3;

                }

              }

              iVar8 = iVar8 + -1;

              param_5 = param_5 - 1;

              local_10 = local_10 + -8;

            } while (-1 < iVar8);

          }

          iVar9 = iVar9 + 1;

          local_c = local_c + 8;

          uVar7 = local_c;

        } while (iVar9 < param_1[1]);

      }

    }

    else {

      local_10 = uVar7;

      if (0 < iVar8) {

        do {

          iVar8 = 0;

          if (0 < param_1[1]) {

            param_5 = param_2;

            do {

              if (((iVar9 < (int)param_3) || (iVar8 < param_4)) &&

                 (*(int *)(param_1[2] + (param_1[1] * iVar9 + iVar8) * 4) != 0)) {

                FUN_00530a30();

              }

              iVar4 = param_1[1];

              local_c = param_3 + iVar9;

              if (((int)local_c < iVar4) && (param_4 + iVar8 < iVar4)) {

                *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) =

                     *(undefined4 *)(param_1[2] + (iVar4 * local_c + param_4 + iVar8) * 4);

              }

              else {

                iVar1 = FUN_0043d7f0(local_10,param_5);

                if (iVar1 == 0) {

                  *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) = 0;

                }

                else {

                  puVar2 = (undefined4 *)FUN_00505d80(local_8,local_10,param_5);

                  uVar3 = FUN_00506830(*puVar2);

                  *(undefined4 *)(param_1[2] + (iVar4 * iVar9 + iVar8) * 4) = uVar3;

                }

              }

              iVar8 = iVar8 + 1;

              param_5 = param_5 + 8;

            } while (iVar8 < param_1[1]);

          }

          iVar9 = iVar9 + 1;

          local_10 = local_10 + 8;

        } while (iVar9 < param_1[1]);

      }

    }

  }

LAB_005074c7:

  param_4 = 0;

  if (0 < param_1[1]) {

    do {

      iVar8 = 0;

      iVar9 = param_4;

      if (0 < param_1[1]) {

        do {

          iVar4 = *(int *)(param_1[2] + (param_1[1] * iVar9 + iVar8) * 4);

          if (iVar4 != 0) {

            FUN_005059f0(iVar9,iVar8,&param_3,&param_2);

            if ((*(int *)(iVar4 + 0x48) == 8) && ((int)(8 / (longlong)(int)param_3) != 8)) {

              FUN_00531000();

            }

            iVar1 = FUN_005338f0(*(undefined4 *)(iVar4 + 0x28),param_3,param_2);

            iVar9 = param_4;

            if (iVar1 != 0) {

              *(undefined4 *)(iVar4 + 0xf4) = 0xffffffff;

              *(undefined4 *)(iVar4 + 0xf8) = 0xffffffff;

              FUN_00530150();

              FUN_00532440();

              FUN_0052ff10();

              iVar9 = param_4;

            }

          }

          iVar8 = iVar8 + 1;

        } while (iVar8 < param_1[1]);

      }

      param_4 = iVar9 + 1;

    } while (param_4 < param_1[1]);

  }

  return;

}





// --- FUN_005075a0 at 0x005075A0 (size: 360) ---


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



undefined4 __thiscall FUN_005075a0(int param_1,int param_2,int param_3,int param_4,int param_5)



{

  float fVar1;

  int iVar2;

  undefined4 uVar3;

  

  if (DAT_0084247c == 0) {

    return 0;

  }

  FUN_00505540();

  uVar3 = 0;

  FUN_006b5980(0);

  iVar2 = FUN_005035e0(uVar3);

  fVar1 = (float)iVar2;

  if (iVar2 < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  FUN_0054c410(fVar1);

  uVar3 = 2;

  FUN_006b5980(2);

  iVar2 = FUN_005035e0(uVar3);

  fVar1 = (float)iVar2;

  if (iVar2 < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  FUN_0054c420(fVar1);

  uVar3 = 1;

  FUN_006b5980(1);

  iVar2 = FUN_005035e0(uVar3);

  fVar1 = (float)iVar2;

  if (iVar2 < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  FUN_0054c430(fVar1);

  uVar3 = 3;

  FUN_006b5980(3);

  iVar2 = FUN_005035e0(uVar3);

  fVar1 = (float)iVar2;

  if (iVar2 < 0) {

    fVar1 = fVar1 + _DAT_0079920c;

  }

  FUN_0054c440(fVar1);

  if (param_2 != 0) {

    uVar3 = FUN_00506c90(0);

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

    FUN_0054c3d0(uVar3);

  }

  if (param_4 != 0) {

    uVar3 = FUN_00506c90(2);

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

    FUN_0054c3f0(uVar3);

  }

  if (param_3 != 0) {

    uVar3 = FUN_00506c90(1);

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

    FUN_0054c3e0(uVar3);

  }

  if (param_5 != 0) {

    uVar3 = FUN_00506c90(3);

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

    FUN_0054c400(uVar3);

  }

  return 1;

}





// --- FUN_00507710 at 0x00507710 (size: 19) ---


void FUN_00507710(void)



{

  FUN_005075a0(0,DAT_0081ffa5,DAT_0081ffa5,0);

  return;

}





// --- FUN_00507730 at 0x00507730 (size: 232) ---


void __thiscall FUN_00507730(int param_1,uint param_2)



{

  uint uVar1;

  bool bVar2;

  int iVar3;

  int *piVar4;

  int *piVar5;

  int iVar6;

  bool bVar7;

  int local_8;

  int local_4;

  

  iVar6 = 0;

  if (param_2 == 0) {

    FUN_005055c0();

    return;

  }

  iVar3 = FUN_005054c0(*(undefined4 *)(param_1 + 0x10),param_2,&local_8,&local_4);

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

  bVar7 = iVar3 == 0;

  bVar2 = false;

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

    do {

      iVar3 = 0;

      piVar4 = piVar5;

      do {

        if (*piVar4 == 0) {

          bVar2 = true;

          goto LAB_005077b6;

        }

        iVar3 = iVar3 + 1;

        piVar4 = piVar4 + 1;

      } while (iVar3 < *(int *)(param_1 + 4));

      iVar6 = iVar6 + 1;

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

    } while (iVar6 < *(int *)(param_1 + 4));

  }

LAB_005077b6:

  if ((((local_8 == 0) && (local_4 == 0)) && (*(int *)(param_1 + 8) != 0)) && ((!bVar7 && (!bVar2)))

     ) {

    *(uint *)(param_1 + 0x10) = param_2;

    return;

  }

  FUN_00506e00(param_2,local_8,local_4,bVar7);

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

  *(uint *)(param_1 + 0x10) = param_2;

  FUN_005066d0(*(undefined4 *)(param_1 + 0x14),((uVar1 ^ param_2) & 0xffff0000) != 0 || bVar7);

  return;

}





// --- FUN_00507820 at 0x00507820 (size: 4) ---


int __fastcall FUN_00507820(int param_1)



{

  return param_1 + 0x3c;

}





// --- FUN_00507830 at 0x00507830 (size: 261) ---


void __thiscall FUN_00507830(int param_1,int param_2)



{

  int iVar1;

  int iVar2;

  uint uVar3;

  

  (**(code **)(**(int **)(param_1 + 0x28) + 0x44))(*(undefined4 *)(param_2 + 4));

  *(undefined4 *)(*(int *)(param_1 + 0x28) + 0x58) = *(undefined4 *)(param_2 + 4);

  FUN_00425f10(param_2 + 8);

  (**(code **)(**(int **)(param_1 + 0x24) + 0x44))(*(undefined4 *)(param_2 + 4));

  *(undefined4 *)(*(int *)(param_1 + 0x24) + 0x58) = *(undefined4 *)(param_2 + 4);

  FUN_00425f10(param_2 + 8);

  uVar3 = 0;

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

    do {

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

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

      if (iVar2 != 0) {

        FUN_00425f10(iVar2 + 0x50);

        if ((*(byte *)(*(int *)(param_1 + 0x18) + uVar3 * 4) & 4) == 0) {

          FUN_00536030(*(int *)(iVar1 + uVar3 * 4) + 0x50,param_2 + 8,0);

        }

        else {

          FUN_00507820();

        }

        FUN_00514b90(&stack0xffffffb8);

        FUN_00511870(*(undefined4 *)(param_2 + 4));

      }

      uVar3 = uVar3 + 1;

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

  }

  return;

}





// --- FUN_00507940 at 0x00507940 (size: 150) ---


int __thiscall FUN_00507940(int param_1,int param_2,float *param_3,int param_4,int param_5)



{

  int iVar1;

  

  if ((param_2 == 0) || ((param_5 != 0 && (DAT_0081dbf9 == '\0')))) {

    return 0;

  }

  iVar1 = FUN_00514470(param_2,0,0);

  if (iVar1 != 0) {

    if ((*param_3 != DAT_00796344) || (param_3[1] != DAT_00796344)) {

      FUN_005106f0(*param_3,param_3[1]);

    }

    if (param_4 != 0) {

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

      return iVar1;

    }

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

  }

  return iVar1;

}





// --- FUN_005079e0 at 0x005079E0 (size: 105) ---


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



void FUN_005079e0(undefined4 param_1,float param_2,float param_3)



{

  undefined4 local_c;

  float local_8;

  undefined4 local_4;

  

  if (param_2 != DAT_00796344) {

    FUN_00536b80(param_2);

  }

  if (param_3 != DAT_00796344) {

    local_8 = -param_3 * (float)_DAT_0079c6b0;

    local_c = 0;

    local_4 = 0;

    FUN_005364e0(&local_c);

  }

  return;

}





// --- FUN_00507a50 at 0x00507A50 (size: 300) ---


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



void __thiscall FUN_00507a50(int param_1,int param_2)



{

  uint uVar1;

  float fVar2;

  int *piVar3;

  char cVar4;

  char cVar5;

  int iVar6;

  uint uVar7;

  

  iVar6 = FUN_00451ec0();

  piVar3 = DAT_00870340;

  if ((iVar6 != 0) || (param_2 == 0)) {

    *(undefined1 *)(DAT_00870340 + 0x1f8) = 1;

    cVar4 = FUN_005a1560();

    FUN_005a3f90(DAT_008427a9 != '\0');

    fVar2 = DAT_0081fc98;

    FUN_0054bf30(DAT_0081fc98 * _DAT_007c6f14);

    FUN_005a3e20(8,0);

    if (param_2 == 0) {

      uVar7 = 0;

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

        do {

          if ((((*(int *)(*(int *)(param_1 + 0xc) + uVar7 * 4) != 0) &&

               (uVar1 = *(uint *)(*(int *)(param_1 + 0x18) + uVar7 * 4), (uVar1 & 1) == 0)) &&

              ((DAT_0081dbf9 != '\0' || ((uVar1 & 4) == 0)))) &&

             (((DAT_008427a9 == '\0' || (cVar5 = FUN_005a1560(), cVar5 == '\0')) ||

              ((*(byte *)(*(int *)(param_1 + 0x18) + uVar7 * 4) & 2) == 0)))) {

            FUN_00511720();

            FUN_00511760();

          }

          uVar7 = uVar7 + 1;

        } while (uVar7 < *(uint *)(param_1 + 0x14));

      }

    }

    else if (DAT_0081dbf9 != '\0') {

      (**(code **)(*DAT_00870340 + 100))(*(undefined4 *)(param_1 + 0x28));

    }

    FUN_0054bf30(fVar2);

    FUN_005a3e20(4,1);

    FUN_005a3f90(cVar4 != '\0');

    *(undefined1 *)(piVar3 + 0x1f8) = 0;

  }

  return;

}





// --- FUN_00507c50 at 0x00507C50 (size: 234) ---


undefined4 * __fastcall FUN_00507c50(undefined4 *param_1)



{

  int iVar1;

  undefined4 uVar2;

  LONG LVar3;

  int local_8;

  int local_4;

  

  *param_1 = 0;

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[3] = 0;

  param_1[4] = 0;

  param_1[5] = 0;

  param_1[6] = 0;

  param_1[7] = 0;

  param_1[8] = 0;

  iVar1 = FUN_005df0f5(0x148);

  if (iVar1 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_0052ce50();

  }

  param_1[9] = uVar2;

  iVar1 = FUN_005df0f5(0x148);

  if (iVar1 == 0) {

    uVar2 = 0;

  }

  else {

    uVar2 = FUN_0052ce50();

  }

  param_1[10] = uVar2;

  FUN_00401340(

              "Number of seconds to adjust Timer time to compute GameTime time.  GameTime effects the state of the sky"

              );

  FUN_00401340("GameTime.TimeZeroDelta");

  FUN_004369a0(&DAT_00842970,10,&local_8,&local_4,&LAB_00507b80,0,0,0);

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

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

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

  }

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

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

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

  }

  return param_1;

}





// --- FUN_00507d40 at 0x00507D40 (size: 209) ---


void __fastcall FUN_00507d40(int *param_1)



{

  undefined4 *puVar1;

  LONG LVar2;

  int *piVar3;

  uint uVar4;

  int iVar5;

  int *local_4;

  

  local_4 = param_1;

  FUN_00401340("GameTime.TimeZeroDelta");

  FUN_00436cf0(&local_4);

  piVar3 = local_4 + -5;

  LVar2 = InterlockedDecrement(local_4 + -4);

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

    (**(code **)*piVar3)(1);

  }

  uVar4 = 0;

  if (param_1[5] != 0) {

    do {

      if (*(int *)(param_1[3] + uVar4 * 4) != 0) {

        if ((*(byte *)(param_1[6] + uVar4 * 4) & 1) == 0) {

          iVar5 = param_1[9];

        }

        else {

          iVar5 = param_1[10];

        }

        FUN_00513ef0(iVar5);

        puVar1 = *(undefined4 **)(param_1[3] + uVar4 * 4);

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

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

        }

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < (uint)param_1[5]);

  }

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

    (**(code **)(*(int *)param_1[9] + 0x18))(1);

  }

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

    (**(code **)(*(int *)param_1[10] + 0x18))(1);

  }

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

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

  if (*param_1 != 0) {

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

  }

  return;

}





// --- FUN_00507e20 at 0x00507E20 (size: 494) ---


void __fastcall FUN_00507e20(int *param_1)



{

  int iVar1;

  uint uVar2;

  undefined4 *puVar3;

  int iVar4;

  int *piVar5;

  undefined4 uVar6;

  uint uVar7;

  bool bVar8;

  int iVar9;

  uint uStack_8;

  undefined1 auStack_4 [4];

  

  bVar8 = DAT_0081dd3c != DAT_0081dbf9;

  uStack_8 = param_1[5];

  uVar2 = param_1[2];

  DAT_0081dd3c = DAT_0081dbf9;

  for (uVar7 = uVar2; uVar7 < uStack_8; uVar7 = uVar7 + 1) {

    if (*(int *)(param_1[3] + uVar7 * 4) != 0) {

      if ((*(byte *)(param_1[6] + uVar7 * 4) & 1) == 0) {

        iVar4 = param_1[9];

      }

      else {

        iVar4 = param_1[10];

      }

      FUN_00513ef0(iVar4);

      puVar3 = *(undefined4 **)(param_1[3] + uVar7 * 4);

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

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

      }

      *(undefined4 *)(param_1[3] + uVar7 * 4) = 0;

    }

  }

  if (uStack_8 < uVar2) {

    FUN_00500570(uVar2);

    FUN_00500570(uVar2);

    if (uStack_8 < uVar2) {

      uStack_8 = uVar2 - uStack_8;

      do {

        uVar7 = param_1[4];

        if ((uint)param_1[5] < uVar7) {

LAB_00507ee6:

          *(undefined4 *)(param_1[3] + param_1[5] * 4) = 0;

          param_1[5] = param_1[5] + 1;

        }

        else {

          if (uVar7 == 0) {

            iVar4 = 8;

          }

          else {

            iVar4 = uVar7 * 2;

          }

          iVar4 = FUN_00500570(iVar4);

          if (iVar4 != 0) goto LAB_00507ee6;

        }

        uVar7 = param_1[7];

        if ((uint)param_1[8] < uVar7) {

LAB_00507f16:

          *(undefined4 *)(param_1[6] + param_1[8] * 4) = 0;

          param_1[8] = param_1[8] + 1;

        }

        else {

          if (uVar7 == 0) {

            iVar4 = 8;

          }

          else {

            iVar4 = uVar7 * 2;

          }

          iVar4 = FUN_00500570(iVar4);

          if (iVar4 != 0) goto LAB_00507f16;

        }

        uStack_8 = uStack_8 + -1;

      } while (uStack_8 != 0);

    }

  }

  uStack_8 = 0;

  if (uVar2 != 0) {

    iVar4 = 0;

    do {

      iVar1 = uStack_8 * 4;

      if (*(int *)(param_1[3] + iVar1) == 0) {

LAB_00507fb6:

        *(undefined4 *)(iVar1 + param_1[6]) = *(undefined4 *)(iVar4 + 0x28 + *param_1);

        iVar9 = param_1[3];

        uVar6 = FUN_00507940(*(undefined4 *)(iVar4 + *param_1),iVar4 + *param_1 + 0x10,

                             *(uint *)(iVar1 + param_1[6]) & 1,*(uint *)(iVar1 + param_1[6]) & 4);

        *(undefined4 *)(iVar9 + iVar1) = uVar6;

      }

      else {

        piVar5 = (int *)FUN_0050f460(auStack_4);

        if (((*(int *)(iVar4 + *param_1) != *piVar5) ||

            (*(uint *)(iVar1 + param_1[6]) != ((int *)(iVar4 + *param_1))[10])) ||

           ((bVar8 && ((*(uint *)(iVar1 + param_1[6]) & 4) != 0)))) {

          if ((*(byte *)(iVar1 + param_1[6]) & 1) == 0) {

            iVar9 = param_1[9];

          }

          else {

            iVar9 = param_1[10];

          }

          FUN_00513ef0(iVar9);

          if (*(undefined4 **)(iVar1 + param_1[3]) != (undefined4 *)0x0) {

            (**(code **)**(undefined4 **)(iVar1 + param_1[3]))(1);

          }

          goto LAB_00507fb6;

        }

      }

      uStack_8 = uStack_8 + 1;

      iVar4 = iVar4 + 0x2c;

    } while (uStack_8 < uVar2);

  }

  return;

}





// --- FUN_00508010 at 0x00508010 (size: 432) ---


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



void __fastcall FUN_00508010(int *param_1)



{

  float fVar1;

  uint uVar2;

  undefined4 uVar3;

  undefined4 uVar4;

  int iVar5;

  int iVar6;

  uint uVar7;

  undefined4 local_48;

  undefined4 local_44;

  undefined4 local_40;

  undefined4 local_3c;

  undefined4 local_14;

  undefined4 local_10;

  undefined4 local_c;

  

  FUN_004ff420();

  if (DAT_008ee9c8 == 0) {

    fVar1 = (float)_DAT_00795610;

  }

  else {

    fVar1 = *(float *)(DAT_008ee9c8 + 0x48);

  }

  iVar6 = FUN_004ff4b0(fVar1,param_1);

  if (iVar6 != 0) {

    FUN_00507e20();

    uVar2 = param_1[2];

    uVar7 = 0;

    if (uVar2 != 0) {

      iVar6 = 0;

      do {

        if (*(int *)(param_1[3] + uVar7 * 4) != 0) {

          uVar3 = *(undefined4 *)(iVar6 + 8 + *param_1);

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

          local_48 = 0x3f800000;

          local_44 = 0;

          local_40 = 0;

          local_3c = 0;

          local_14 = 0;

          local_10 = 0;

          local_c = 0;

          FUN_00535b30();

          if ((*(byte *)(param_1[6] + uVar7 * 4) & 4) != 0) {

            iVar5 = *(int *)param_1[3];

            local_14 = *(undefined4 *)(iVar5 + 0x84);

            local_10 = *(undefined4 *)(iVar5 + 0x88);

            local_c = *(undefined4 *)(iVar5 + 0x8c);

          }

          FUN_005079e0(&local_48,uVar3,uVar4);

          FUN_00514b90(&local_48);

          if (DAT_00796344 < *(float *)(iVar6 + 0x20 + *param_1)) {

            FUN_00512360(0,*(float *)(iVar6 + 0x20 + *param_1) * _DAT_007a1870,0,0);

          }

          if (DAT_00796344 < *(float *)(iVar6 + 0x24 + *param_1)) {

            FUN_005124b0(0,*(float *)(iVar6 + 0x24 + *param_1) * _DAT_007a1870,0,0);

          }

          if (DAT_00796344 <= *(float *)(iVar6 + 0x1c + *param_1)) {

            FUN_005120c0(*(float *)(iVar6 + 0x1c + *param_1) * _DAT_007a1870,0,0);

          }

        }

        uVar7 = uVar7 + 1;

        iVar6 = iVar6 + 0x2c;

      } while (uVar7 < uVar2);

    }

  }

  return;

}





// --- FUN_005081c0 at 0x005081C0 (size: 49) ---


void __fastcall FUN_005081c0(int *param_1)



{

  param_1[2] = 0;

  param_1[1] = 0;

  if (*param_1 != 0) {

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

  }

  *param_1 = 0;

  FUN_00507e20();

  return;

}





// --- FUN_00508200 at 0x00508200 (size: 90) ---


void __thiscall FUN_00508200(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  

  if (param_2 <= (uint)param_1[3]) {

    FUN_00508290(param_2);

    return;

  }

  iVar1 = thunk_FUN_005df0f5(param_2 * 4);

  uVar2 = 0;

  if (param_1[3] != 0) {

    do {

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

      uVar2 = uVar2 + 1;

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

  }

  operator_delete__((void *)*param_1);

  *param_1 = iVar1;

  param_1[3] = param_2;

  return;

}





// --- FUN_00508260 at 0x00508260 (size: 44) ---


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



{

  *param_1 = &PTR_FUN_007c7444;

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

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00508290 at 0x00508290 (size: 123) ---


void __thiscall FUN_00508290(int *param_1,uint param_2)



{

  int iVar1;

  uint uVar2;

  

  if (param_2 <= (uint)param_1[3]) {

    if (param_2 == 0) {

      param_1[3] = 0;

      operator_delete__((void *)*param_1);

      *param_1 = 0;

    }

    else {

      iVar1 = thunk_FUN_005df0f5(param_2 * 4);

      uVar2 = 0;

      param_1[3] = param_2;

      if (param_2 != 0) {

        do {

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

          uVar2 = uVar2 + 1;

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

      }

      operator_delete__((void *)*param_1);

      *param_1 = iVar1;

    }

    if (param_2 < (uint)param_1[2]) {

      param_1[2] = param_2;

    }

    return;

  }

  FUN_00508200(param_2);

  return;

}





// --- FUN_00508310 at 0x00508310 (size: 73) ---


void __fastcall FUN_00508310(int param_1)



{

  undefined4 *puVar1;

  uint uVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(*(int *)(param_1 + 0xc) << 5);

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

  puVar5 = puVar1;

  for (uVar2 = (uint)(*(int *)(param_1 + 0xc) << 4) >> 2; uVar2 != 0; uVar2 = uVar2 - 1) {

    *puVar5 = *puVar4;

    puVar4 = puVar4 + 1;

    puVar5 = puVar5 + 1;

  }

  for (iVar3 = 0; iVar3 != 0; iVar3 = iVar3 + -1) {

    *(undefined1 *)puVar5 = *(undefined1 *)puVar4;

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

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

  }

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

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

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

  return;

}





// --- FUN_00508420 at 0x00508420 (size: 65) ---


int __thiscall FUN_00508420(int param_1,int param_2)



{

  int iVar1;

  int *piVar2;

  uint uVar3;

  int *piVar4;

  

  uVar3 = 0;

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

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

    piVar4 = piVar2;

    do {

      if (*piVar4 == param_2) {

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

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

        piVar2[uVar3] = piVar2[iVar1];

        return param_2;

      }

      uVar3 = uVar3 + 1;

      piVar4 = piVar4 + 1;

    } while (uVar3 < *(uint *)(param_1 + 8));

  }

  return 0;

}





// --- FUN_00508470 at 0x00508470 (size: 120) ---


void __thiscall FUN_00508470(int param_1,double param_2,undefined4 param_3)



{

  double *pdVar1;

  int iVar2;

  int iVar3;

  undefined4 *puVar4;

  undefined4 *puVar5;

  int iVar6;

  

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

    FUN_00508310();

  }

  iVar6 = *(int *)(param_1 + 4) + -0x10;

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

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

  while (1 < iVar2) {

    iVar3 = (iVar2 >> 1) * 0x10;

    puVar4 = (undefined4 *)(iVar3 + iVar6);

    if (*(double *)(iVar3 + iVar6) <= param_2) break;

    puVar5 = (undefined4 *)(iVar2 * 0x10 + iVar6);

    *puVar5 = *puVar4;

    puVar5[1] = puVar4[1];

    puVar5[2] = puVar4[2];

    puVar5[3] = puVar4[3];

    iVar2 = iVar2 >> 1;

  }

  pdVar1 = (double *)(iVar2 * 0x10 + iVar6);

  *pdVar1 = param_2;

  *(undefined4 *)(pdVar1 + 1) = param_3;

  return;

}





// --- FUN_005084f0 at 0x005084F0 (size: 127) ---


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



{

  undefined4 *puVar1;

  int iVar2;

  undefined4 *puVar3;

  

  if ((0 < *(int *)(param_1 + 8)) &&

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

    *param_2 = *puVar1;

    param_2[1] = puVar1[1];

    *param_3 = *(undefined4 *)(*(int *)(param_1 + 4) + 8);

    if (1 < *(int *)(param_1 + 8)) {

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

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

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

      puVar3 = puVar1 + iVar2 * 4;

      *puVar1 = *puVar3;

      puVar1[1] = puVar3[1];

      puVar1[2] = puVar3[2];

      puVar1[3] = puVar3[3];

      FUN_00541840(1);

      return 1;

    }

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

    FUN_00541840(1);

    return 1;

  }

  return 0;

}





// --- FUN_00508570 at 0x00508570 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007c7448;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005085b0 at 0x005085B0 (size: 64) ---


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



{

  *param_1 = &PTR_FUN_007c744c;

  if ((undefined4 *)param_1[0x18] != param_1 + 1) {

    operator_delete__((undefined4 *)param_1[0x18]);

  }

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_005085f0 at 0x005085F0 (size: 92) ---


int __thiscall FUN_005085f0(int param_1,uint param_2)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  

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

                  ((param_2 >> ((byte)*(undefined4 *)(param_1 + 8) & 0x1f) ^ param_2) &

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

  iVar2 = *piVar1;

  if (iVar2 != 0) {

    if (*(uint *)(iVar2 + 8) == param_2) {

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

      return iVar2;

    }

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

    while (iVar3 != 0) {

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

      if (*(uint *)(iVar4 + 8) == param_2) {

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

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

        return iVar3;

      }

      iVar2 = iVar4;

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

    }

  }

  return 0;

}





// --- FUN_00508650 at 0x00508650 (size: 142) ---


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



{

  int iVar1;

  int *piVar2;

  int *piVar3;

  int *unaff_EBP;

  int *local_4;

  

  local_4 = param_1;

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

    piVar3 = (int *)*param_1;

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

      *param_1 = 0;

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

      param_1[1] = 0;

    }

    *param_2 = 0x80004002;

    return;

  }

  iVar1 = *param_3;

  param_3 = (int *)0x0;

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

  piVar2 = local_4;

  iVar1 = *piVar3;

  piVar3 = (int *)*param_1;

  if (iVar1 < 0) {

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

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

    }

    *param_1 = 0;

    param_1[1] = 0;

    *unaff_EBP = iVar1;

    return;

  }

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

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

  }

  *param_1 = (int)piVar2;

  param_1[1] = 0;

  *unaff_EBP = iVar1;

  return;

}





// --- FUN_005086e0 at 0x005086E0 (size: 217) ---


void FUN_005086e0(int param_1)



{

  int iVar1;

  uint uVar2;

  uint uVar3;

  

  uVar3 = 0;

  if ((DAT_00842b88 & 1) == 0) {

    DAT_00842b88 = DAT_00842b88 | 1;

    DAT_00842b78 = 0;

    DAT_00842b84 = 0;

    DAT_00842b80 = 0;

    DAT_00842b7c = 0x80;

    _atexit((_func_4879 *)&LAB_007677d0);

  }

  uVar2 = 0;

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

    do {

      iVar1 = *(int *)(*(int *)(param_1 + 0xa0) + uVar2 * 4);

      if (((*(byte *)(iVar1 + 0xa8) & 1) == 0) && (*(int *)(iVar1 + 0x40) == 0)) {

        if (DAT_00842b84 <= uVar3) {

          FUN_00508200(DAT_00842b7c + uVar3);

        }

        *(int *)(DAT_00842b78 + uVar3 * 4) = iVar1;

        if (DAT_00842b80 <= uVar3) {

          DAT_00842b80 = uVar3 + 1;

        }

        uVar3 = uVar3 + 1;

      }

      uVar2 = uVar2 + 1;

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

  }

  uVar2 = 0;

  if (uVar3 != 0) {

    do {

      FUN_00514d20();

      uVar2 = uVar2 + 1;

    } while (uVar2 < uVar3);

  }

  return;

}





// --- FUN_005087c0 at 0x005087C0 (size: 80) ---


void __fastcall FUN_005087c0(undefined4 param_1)



{

  int *piVar1;

  undefined1 *puVar2;

  undefined *puVar3;

  int *piVar4;

  undefined4 uVar5;

  undefined1 local_c [4];

  int *local_8;

  undefined4 local_4;

  

  local_8 = (int *)0x0;

  local_4 = 0;

  FUN_00508650(local_c,param_1);

  piVar1 = local_8;

  uVar5 = 0;

  puVar2 = local_c;

  puVar3 = &DAT_007c7378;

  piVar4 = local_8;

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

  FUN_00406c90(puVar2,puVar3,piVar4,uVar5);

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

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

  }

  return;

}





// --- FUN_00508810 at 0x00508810 (size: 57) ---


void __thiscall FUN_00508810(int param_1,int param_2)



{

  uint uVar1;

  

  uVar1 = (*(uint *)(param_2 + 8) >> ((byte)*(undefined4 *)(param_1 + 0x8c) & 0x1f) ^

          *(uint *)(param_2 + 8)) & *(uint *)(param_1 + 0x88);

  *(undefined4 *)(param_2 + 4) = *(undefined4 *)(*(int *)(param_1 + 0x90) + uVar1 * 4);

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

  return;

}





// --- FUN_00508850 at 0x00508850 (size: 57) ---


void __thiscall FUN_00508850(int param_1,int param_2)



{

  uint uVar1;

  

  uVar1 = (*(uint *)(param_2 + 8) >> ((byte)*(undefined4 *)(param_1 + 0xbc) & 0x1f) ^

          *(uint *)(param_2 + 8)) & *(uint *)(param_1 + 0xb8);

  *(undefined4 *)(param_2 + 4) = *(undefined4 *)(*(int *)(param_1 + 0xc0) + uVar1 * 4);

  *(int *)(*(int *)(param_1 + 0xc0) + uVar1 * 4) = param_2;

  return;

}





// --- FUN_00508890 at 0x00508890 (size: 65) ---


int __thiscall FUN_00508890(int param_1,uint param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x90) +

                  ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0x8c) & 0x1f) ^ param_2) &

                  *(uint *)(param_1 + 0x88)) * 4);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if (param_2 == *(uint *)(iVar1 + 8)) break;

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

  }

  return iVar1;

}





// --- FUN_005088e0 at 0x005088E0 (size: 65) ---


int __thiscall FUN_005088e0(int param_1,uint param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0xc0) +

                  ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0xbc) & 0x1f) ^ param_2) &

                  *(uint *)(param_1 + 0xb8)) * 4);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if (param_2 == *(uint *)(iVar1 + 8)) break;

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

  }

  return iVar1;

}





// --- FUN_00508930 at 0x00508930 (size: 65) ---


int __thiscall FUN_00508930(int param_1,uint param_2)



{

  int iVar1;

  

  iVar1 = *(int *)(*(int *)(param_1 + 0x1d8) +

                  ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0x1d4) & 0x1f) ^ param_2) &

                  *(uint *)(param_1 + 0x1d0)) * 4);

  while( true ) {

    if (iVar1 == 0) {

      return 0;

    }

    if (param_2 == *(uint *)(iVar1 + 8)) break;

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

  }

  return iVar1;

}





// --- FUN_00508980 at 0x00508980 (size: 133) ---


void __thiscall FUN_00508980(int param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  

  if (param_1 == -0xb4) {

    return;

  }

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

  if (iVar1 == 0) {

    FUN_004d8d00();

  }

  uVar2 = 0;

  do {

    do {

      (**(code **)(*(int *)(iVar1 + 0xc) + 0xc))(param_2);

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

    } while (iVar1 != 0);

    do {

      uVar2 = uVar2 + 1;

      if (*(uint *)(param_1 + 0xc4) <= uVar2) {

        return;

      }

      iVar1 = *(int *)(*(int *)(param_1 + 0xc0) + uVar2 * 4);

    } while (iVar1 == 0);

  } while( true );

}





// --- FUN_00508a10 at 0x00508A10 (size: 47) ---


void __thiscall FUN_00508a10(int param_1,uint *param_2)



{

  uint *puVar1;

  

  for (puVar1 = *(uint **)(*(int *)(param_1 + 0x60) + (*param_2 % *(uint *)(param_1 + 0x68)) * 4);

      (puVar1 != (uint *)0x0 && (*puVar1 != *param_2)); puVar1 = (uint *)puVar1[1]) {

  }

  return;

}





// --- FUN_00508a40 at 0x00508A40 (size: 58) ---


undefined4 FUN_00508a40(undefined4 param_1,int *param_2,int *param_3)



{

  int iVar1;

  

  iVar1 = FUN_00508890(param_1);

  *param_2 = iVar1;

  iVar1 = FUN_005088e0(param_1);

  *param_3 = iVar1;

  if ((*param_2 == 0) && (iVar1 == 0)) {

    return 0;

  }

  return 1;

}





// --- FUN_00508a80 at 0x00508A80 (size: 58) ---


void FUN_00508a80(int param_1)



{

  int iVar1;

  int iVar2;

  

  iVar1 = param_1;

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

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

    iVar2 = FUN_00508a10(&param_1);

    if (iVar2 != 0) {

      FUN_00508420(iVar1);

    }

  }

  return;

}





// --- FUN_00508ac0 at 0x00508AC0 (size: 143) ---


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



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007c7448;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

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

  }

  return param_1;

}





// --- FUN_00508b50 at 0x00508B50 (size: 143) ---


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



{

  undefined *puVar1;

  uint *puVar2;

  undefined4 uVar3;

  uint uVar4;

  int iVar5;

  undefined4 *puVar6;

  

  param_1[0x18] = 0;

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  *param_1 = &PTR_FUN_007c744c;

  puVar1 = PTR_DAT_00818558;

  puVar2 = (uint *)FUN_00422d20(PTR_DAT_00818554,PTR_DAT_00818558,&param_2,param_2,0);

  if (puVar2 == (uint *)puVar1) {

    puVar2 = puVar2 + -1;

  }

  uVar4 = *puVar2;

  param_1[0x1a] = uVar4;

  if (uVar4 < 0x18) {

    param_1[0x18] = param_1 + 1;

  }

  else {

    uVar3 = thunk_FUN_005df0f5(uVar4 << 2);

    param_1[0x18] = uVar3;

  }

  param_1[0x19] = (undefined4 *)param_1[0x18] + param_1[0x1a];

  puVar6 = (undefined4 *)param_1[0x18];

  for (uVar4 = param_1[0x1a] & 0x3fffffff; uVar4 != 0; uVar4 = uVar4 - 1) {

    *puVar6 = 0;

    puVar6 = puVar6 + 1;

  }

  for (iVar5 = 0; iVar5 != 0; iVar5 = iVar5 + -1) {

    *(undefined1 *)puVar6 = 0;

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

  }

  return param_1;

}





// --- FUN_00508be0 at 0x00508BE0 (size: 141) ---


void __fastcall FUN_00508be0(int param_1)



{

  int iVar1;

  void *pvVar2;

  void *pvVar3;

  int *piVar4;

  void *pvVar5;

  

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

  do {

    if (iVar1 == 0) {

      return;

    }

    piVar4 = *(int **)(param_1 + 100);

    while (piVar4 != (int *)(*(int *)(param_1 + 0x60) + *(int *)(param_1 + 0x68) * 4)) {

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

        piVar4 = *(int **)(param_1 + 100);

        pvVar5 = (void *)*piVar4;

        goto LAB_00508c1f;

      }

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

      *(int **)(param_1 + 100) = piVar4;

    }

    piVar4 = (int *)0x0;

    pvVar5 = (void *)0x0;

LAB_00508c1f:

    pvVar3 = (void *)*piVar4;

    if (pvVar3 == pvVar5) {

LAB_00508c32:

      *piVar4 = *(int *)((int)pvVar3 + 4);

    }

    else {

      do {

        pvVar2 = pvVar3;

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

      } while (pvVar3 != pvVar5);

      if (pvVar2 == (void *)0x0) goto LAB_00508c32;

      *(undefined4 *)((int)pvVar2 + 4) = *(undefined4 *)((int)pvVar3 + 4);

    }

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

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

      operator_delete__(*(void **)((int)pvVar5 + 0xc));

      *(undefined4 *)((int)pvVar5 + 0xc) = 0;

      operator_delete(pvVar5);

    }

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

  } while( true );

}





// --- FUN_00508c70 at 0x00508C70 (size: 105) ---


uint * __thiscall FUN_00508c70(int param_1,uint param_2)



{

  uint *puVar1;

  uint *puVar2;

  

  puVar2 = *(uint **)(*(int *)(param_1 + 0x74) + (param_2 % *(uint *)(param_1 + 0x7c)) * 4);

  do {

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

LAB_00508ca1:

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

      puVar2 = (uint *)0x0;

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

        puVar1[1] = 0;

        puVar1[2] = 0;

        *puVar1 = param_2;

        puVar1[3] = 0;

        puVar1[6] = 0;

        puVar1[5] = 0;

        puVar1[4] = 0x80;

        puVar2 = puVar1;

      }

      FUN_0042bd40(puVar2);

      return puVar2;

    }

    if (*puVar2 == param_2) {

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

        return puVar2;

      }

      goto LAB_00508ca1;

    }

    puVar2 = (uint *)puVar2[1];

  } while( true );

}





// --- FUN_00508ce0 at 0x00508CE0 (size: 80) ---


void FUN_00508ce0(int param_1,undefined4 param_2)



{

  int iVar1;

  int iVar2;

  

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

    FUN_0050ffc0(param_2);

    iVar2 = FUN_00508c70(*(undefined4 *)(param_1 + 0x4c));

    if (*(uint *)(iVar2 + 0x18) <= *(uint *)(iVar2 + 8)) {

      FUN_00508200(*(uint *)(iVar2 + 8) + 5);

    }

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

    *(int *)(iVar2 + 8) = iVar1 + 1;

    *(int *)(*(int *)(iVar2 + 0xc) + iVar1 * 4) = param_1;

  }

  return;

}





// --- FUN_00508d30 at 0x00508D30 (size: 104) ---


void FUN_00508d30(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

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

  pvVar1 = (void *)FUN_004171e0(&param_1);

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

    uVar2 = 0;

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

      do {

        FUN_00516d50();

        uVar2 = uVar2 + 1;

      } while (uVar2 < *(uint *)((int)pvVar1 + 8));

    }

    *(undefined4 *)((int)pvVar1 + 8) = 0;

    operator_delete__(*(void **)((int)pvVar1 + 0xc));

    *(undefined4 *)((int)pvVar1 + 0xc) = 0;

    operator_delete(pvVar1);

  }

  return;

}





// --- FUN_00508da0 at 0x00508DA0 (size: 94) ---


undefined4 FUN_00508da0(undefined4 *param_1,undefined4 *param_2)



{

  char cVar1;

  undefined4 *puVar2;

  

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

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

    puVar2 = (undefined4 *)0x0;

  }

  else {

    *puVar2 = *param_1;

    puVar2[1] = 0;

    puVar2[2] = *param_2;

    puVar2[3] = param_2[1];

  }

  cVar1 = FUN_0042bd40(puVar2);

  if (cVar1 == '\0') {

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

      operator_delete(puVar2);

    }

    return 0;

  }

  return 1;

}





// --- FUN_00508e00 at 0x00508E00 (size: 82) ---


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



{

  *param_1 = &PTR_FUN_007c7454;

  FUN_005870f0();

  param_1[1] = &PTR_FUN_007c744c;

  if ((undefined4 *)param_1[0x19] != param_1 + 2) {

    operator_delete__((undefined4 *)param_1[0x19]);

  }

  param_1[0x19] = 0;

  param_1[0x1a] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00508e60 at 0x00508E60 (size: 175) ---


void __fastcall FUN_00508e60(int param_1)



{

  int iVar1;

  uint uVar2;

  

  FUN_005870f0();

  uVar2 = 0;

  if (param_1 == -0x84) {

    return;

  }

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

  if (iVar1 == 0) {

    FUN_004d8d00();

    uVar2 = 0;

  }

  do {

    do {

      if ((*(int *)(iVar1 + 0x90) != 0) && ((*(byte *)(iVar1 + 0xa8) & 1) == 0)) {

        FUN_0045ce60(iVar1 + 8);

      }

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

    } while (iVar1 != 0);

    do {

      uVar2 = uVar2 + 1;

      if (*(uint *)(param_1 + 0x94) <= uVar2) {

        return;

      }

      iVar1 = *(int *)(*(int *)(param_1 + 0x90) + uVar2 * 4);

    } while (iVar1 == 0);

  } while( true );

}





// --- FUN_00508f10 at 0x00508F10 (size: 30) ---


void FUN_00508f10(void)



{

  void *pvVar1;

  

  pvVar1 = (void *)FUN_004171e0(&stack0x00000004);

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

    operator_delete(pvVar1);

  }

  return;

}





// --- FUN_00508f30 at 0x00508F30 (size: 108) ---


void FUN_00508f30(undefined4 *param_1)



{

  void *pvVar1;

  

  FUN_00515960();

  FUN_005160a0();

  FUN_005085f0(param_1[2]);

  FUN_005085f0(param_1[2]);

  pvVar1 = (void *)FUN_004171e0(param_1 + 2);

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

    operator_delete(pvVar1);

  }

  FUN_00513f70();

  FUN_00513fe0();

  (**(code **)*param_1)(1);

  return;

}





// --- FUN_00508fa0 at 0x00508FA0 (size: 255) ---


undefined4 __thiscall FUN_00508fa0(int param_1,uint param_2)



{

  int *piVar1;

  int iVar2;

  undefined4 unaff_EBX;

  

  for (iVar2 = *(int *)(*(int *)(param_1 + 0x90) +

                       ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0x8c) & 0x1f) ^ param_2) &

                       *(uint *)(param_1 + 0x88)) * 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

    if (param_2 == *(uint *)(iVar2 + 8)) goto LAB_00508fe2;

  }

  iVar2 = 0;

LAB_00508fe2:

  if (iVar2 == 0) {

    for (iVar2 = *(int *)(*(int *)(param_1 + 0xa8) +

                         ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0xa4) & 0x1f) ^ param_2) &

                         *(uint *)(param_1 + 0xa0)) * 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

      if (param_2 == *(uint *)(iVar2 + 8)) goto LAB_00509015;

    }

    iVar2 = 0;

LAB_00509015:

    if (iVar2 == 0) goto LAB_0050902b;

  }

  FUN_00508f30(iVar2);

LAB_0050902b:

  piVar1 = *(int **)(*(int *)(param_1 + 0xc0) +

                    ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0xbc) & 0x1f) ^ param_2) &

                    *(uint *)(param_1 + 0xb8)) * 4);

  while( true ) {

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

      return 0;

    }

    if (param_2 == piVar1[2]) break;

    piVar1 = (int *)piVar1[1];

  }

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

    return 0;

  }

  (**(code **)(*piVar1 + 4))();

  FUN_005085f0(piVar1[2]);

  FUN_005085f0(piVar1[2]);

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

  return unaff_EBX;

}





// --- FUN_00509420 at 0x00509420 (size: 3) ---


void FUN_00509420(void)



{

  return;

}





// --- FUN_00509430 at 0x00509430 (size: 3) ---


undefined4 FUN_00509430(void)



{

  return 0;

}





// --- FUN_00509450 at 0x00509450 (size: 36) ---


int __fastcall FUN_00509450(int *param_1)



{

  int iVar1;

  

  iVar1 = FUN_00401ea0();

  if ((iVar1 == 0) && (param_1 != (int *)0x0)) {

    (**(code **)(*param_1 + 0x20))(1);

  }

  return iVar1;

}





// --- FUN_00509480 at 0x00509480 (size: 627) ---


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



void __fastcall FUN_00509480(int *param_1)



{

  uint *puVar1;

  undefined4 uVar2;

  void *pvVar3;

  int *piVar4;

  int iVar5;

  uint uVar6;

  uint local_34;

  int *local_30;

  uint local_2c;

  double local_28;

  int *local_1c;

  uint local_18;

  int local_14;

  undefined4 local_10;

  int local_c;

  

  if (param_1[4] == 0) {

    return;

  }

  local_30 = param_1;

  if (_DAT_007c7420 < (double)CONCAT44(DAT_008379ac,DAT_008379a8) - _DAT_00842b90) {

    FUN_00508e60();

    _DAT_00842b90 = DAT_008379a8;

    _DAT_00842b94 = DAT_008379ac;

  }

  local_34 = 0;

  do {

    if (((param_1[0x7b] < 1) || ((double *)param_1[0x7a] == (double *)0x0)) ||

       (local_28 = *(double *)param_1[0x7a], (double)CONCAT44(DAT_008379ac,DAT_008379a8) <= local_28

       )) {

      local_1c = param_1 + 0x27;

      local_10 = 0;

      local_18 = 0;

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

        local_14 = *(int *)param_1[0x2a];

        local_c = 0;

        piVar4 = local_1c;

        iVar5 = local_14;

        uVar6 = 0;

        if ((local_14 != 0) ||

           (FUN_004d8d00(), piVar4 = local_1c, param_1 = local_30, iVar5 = local_14,

           uVar6 = local_18, local_c == 0)) {

          do {

            do {

              uVar2 = DAT_008379ac;

              if (_DAT_007c7428 <

                  (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(iVar5 + 0xd8)) {

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

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

                FUN_00547590(*(undefined4 *)(iVar5 + 8));

              }

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

            } while (iVar5 != 0);

            do {

              uVar6 = uVar6 + 1;

              param_1 = local_30;

              if ((uint)piVar4[4] <= uVar6) goto LAB_0050964d;

              iVar5 = *(int *)(piVar4[3] + uVar6 * 4);

            } while (iVar5 == 0);

          } while( true );

        }

      }

LAB_0050964d:

      local_1c = param_1 + 0x33;

      local_10 = 0;

      local_18 = 0;

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

        return;

      }

      local_14 = *(int *)param_1[0x36];

      local_c = 0;

      piVar4 = local_1c;

      iVar5 = local_14;

      uVar6 = 0;

      if ((local_14 == 0) &&

         (FUN_004d8d00(), piVar4 = local_1c, iVar5 = local_14, uVar6 = local_18, local_c != 0)) {

        return;

      }

      do {

        do {

          uVar2 = DAT_008379ac;

          if (_DAT_007c7428 <

              (double)CONCAT44(DAT_008379ac,DAT_008379a8) - *(double *)(iVar5 + 0x18)) {

            *(undefined4 *)(iVar5 + 0x18) = DAT_008379a8;

            *(undefined4 *)(iVar5 + 0x1c) = uVar2;

            FUN_00547590(*(undefined4 *)(iVar5 + 8));

          }

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

        } while (iVar5 != 0);

        do {

          uVar6 = uVar6 + 1;

          if ((uint)piVar4[4] <= uVar6) {

            return;

          }

          iVar5 = *(int *)(piVar4[3] + uVar6 * 4);

        } while (iVar5 == 0);

      } while( true );

    }

    FUN_005084f0(&local_28,&local_34);

    uVar6 = local_34;

    local_2c = local_34;

    for (puVar1 = *(uint **)(param_1[0x6f] + (local_34 % (uint)param_1[0x71]) * 4);

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

      if (*puVar1 == local_34) {

        if ((puVar1 != (uint *)0x0) &&

           (ABS(*(double *)(puVar1 + 2) - local_28) < (double)_DAT_007c7440)) {

          pvVar3 = (void *)FUN_004171e0(&local_2c);

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

            operator_delete(pvVar3);

          }

          (**(code **)(*param_1 + 0x1c))(uVar6);

        }

        break;

      }

    }

  } while( true );

}





// --- FUN_00509700 at 0x00509700 (size: 829) ---


void __fastcall FUN_00509700(int param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  int iVar3;

  uint *puVar4;

  int iVar5;

  int iVar6;

  bool bVar7;

  uint *puVar8;

  uint *puVar9;

  uint uVar10;

  undefined4 *puVar11;

  uint local_10;

  undefined4 *local_c;

  

  local_10 = 0;

  if (param_1 != -0x84) {

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

    bVar7 = false;

    if (local_c != (undefined4 *)0x0) goto LAB_0050975b;

    FUN_004d8d00();

LAB_0050974b:

    puVar11 = local_c;

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

LAB_00509766:

      do {

        local_10 = local_10 + 1;

        if (*(uint *)(param_1 + 0x94) <= local_10) {

          bVar7 = true;

          break;

        }

        local_c = *(undefined4 **)(*(int *)(param_1 + 0x90) + local_10 * 4);

      } while (local_c == (undefined4 *)0x0);

    }

    else {

LAB_0050975b:

      puVar2 = (undefined4 *)local_c[1];

      puVar11 = local_c;

      local_c = puVar2;

      if (puVar2 == (undefined4 *)0x0) goto LAB_00509766;

    }

    FUN_00515960();

    FUN_005160a0();

    uVar10 = puVar11[2];

    piVar1 = (int *)(*(int *)(param_1 + 0x90) +

                    ((uVar10 >> ((byte)*(undefined4 *)(param_1 + 0x8c) & 0x1f) ^ uVar10) &

                    *(uint *)(param_1 + 0x88)) * 4);

    iVar3 = *piVar1;

    if (iVar3 != 0) {

      if (*(uint *)(iVar3 + 8) == uVar10) {

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

      }

      else {

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

        while (iVar5 != 0) {

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

          if (*(uint *)(iVar6 + 8) == uVar10) {

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

            break;

          }

          iVar3 = iVar6;

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

        }

      }

    }

    uVar10 = puVar11[2];

    piVar1 = (int *)(*(int *)(param_1 + 0xa8) +

                    ((uVar10 >> ((byte)*(undefined4 *)(param_1 + 0xa4) & 0x1f) ^ uVar10) &

                    *(uint *)(param_1 + 0xa0)) * 4);

    iVar3 = *piVar1;

    if (iVar3 != 0) {

      if (*(uint *)(iVar3 + 8) == uVar10) {

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

      }

      else {

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

        while (iVar5 != 0) {

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

          if (*(uint *)(iVar6 + 8) == uVar10) {

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

            break;

          }

          iVar3 = iVar6;

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

        }

      }

    }

    uVar10 = (uint)puVar11[2] % *(uint *)(param_1 + 0x1c4);

    puVar9 = *(uint **)(*(int *)(param_1 + 0x1bc) + uVar10 * 4);

    for (puVar4 = puVar9; puVar4 != (uint *)0x0; puVar4 = (uint *)puVar4[1]) {

      if (*puVar4 == puVar11[2]) {

        if (puVar4 != (uint *)0x0) {

          if (puVar9 != puVar4) goto LAB_00509875;

          goto LAB_00509882;

        }

        break;

      }

    }

    goto LAB_005098a5;

  }

LAB_005098c9:

  if (param_1 == -0xb4) {

    puVar11 = (undefined4 *)0x0;

LAB_0050990b:

    if (puVar11 == (undefined4 *)0x0) goto LAB_005099fa;

  }

  else {

    puVar11 = (undefined4 *)**(int **)(param_1 + 0xc0);

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

      FUN_004d8d00();

      goto LAB_0050990b;

    }

  }

LAB_00509913:

  do {

    uVar10 = puVar11[2];

    piVar1 = (int *)(*(int *)(param_1 + 0xc0) +

                    ((uVar10 >> ((byte)*(undefined4 *)(param_1 + 0xbc) & 0x1f) ^ uVar10) &

                    *(uint *)(param_1 + 0xb8)) * 4);

    iVar3 = *piVar1;

    if (iVar3 != 0) {

      if (*(uint *)(iVar3 + 8) == uVar10) {

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

      }

      else {

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

        while (iVar5 != 0) {

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

          if (*(uint *)(iVar6 + 8) == uVar10) {

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

            break;

          }

          iVar3 = iVar6;

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

        }

      }

    }

    uVar10 = puVar11[2];

    piVar1 = (int *)(*(int *)(param_1 + 0xd8) +

                    ((uVar10 >> ((byte)*(undefined4 *)(param_1 + 0xd4) & 0x1f) ^ uVar10) &

                    *(uint *)(param_1 + 0xd0)) * 4);

    iVar3 = *piVar1;

    if (iVar3 != 0) {

      if (*(uint *)(iVar3 + 8) == uVar10) {

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

      }

      else {

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

        while (iVar5 != 0) {

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

          if (*(uint *)(iVar6 + 8) == uVar10) {

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

            break;

          }

          iVar3 = iVar6;

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

        }

      }

    }

    (**(code **)*puVar11)(1);

    if (param_1 == -0xb4) {

      puVar11 = (undefined4 *)0x0;

    }

    else {

      puVar11 = (undefined4 *)**(undefined4 **)(param_1 + 0xc0);

      if (puVar11 != (undefined4 *)0x0) goto LAB_00509913;

      FUN_004d8d00();

    }

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

LAB_005099fa:

  FUN_00524910();

  FUN_00524910();

  FUN_00524910();

  FUN_00524910();

  FUN_00508be0();

  FUN_00524910();

  return;

LAB_00509875:

  do {

    puVar8 = puVar9;

    puVar9 = (uint *)puVar8[1];

  } while (puVar9 != puVar4);

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

LAB_00509882:

    *(uint *)(*(int *)(param_1 + 0x1bc) + uVar10 * 4) = puVar9[1];

  }

  else {

    puVar8[1] = puVar9[1];

  }

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

  operator_delete(puVar4);

LAB_005098a5:

  FUN_00513f70();

  FUN_00513fe0();

  (**(code **)*puVar11)(1);

  if (bVar7) goto LAB_005098c9;

  goto LAB_0050974b;

}





// --- FUN_00509a40 at 0x00509A40 (size: 111) ---


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



void FUN_00509a40(undefined4 param_1)



{

  undefined4 uVar1;

  void *pvVar2;

  undefined8 local_8;

  

  uVar1 = param_1;

  local_8 = (double)CONCAT44(local_8._4_4_,param_1);

  pvVar2 = (void *)FUN_004171e0(&local_8);

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

    operator_delete(pvVar2);

  }

  local_8 = _DAT_008379a8 + _DAT_007c7418;

  FUN_00508da0(&param_1,&local_8);

  FUN_00508470((undefined4)local_8,local_8._4_4_,uVar1);

  return;

}





// --- FUN_00509ab0 at 0x00509AB0 (size: 171) ---


int __thiscall FUN_00509ab0(int param_1,uint param_2,int param_3)



{

  undefined4 uVar1;

  int iVar2;

  uint uVar3;

  

  for (iVar2 = *(int *)(*(int *)(param_1 + 0xa8) +

                       ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0xa4) & 0x1f) ^ param_2) &

                       *(uint *)(param_1 + 0xa0)) * 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

    if (param_2 == *(uint *)(iVar2 + 8)) goto LAB_00509aee;

  }

  iVar2 = 0;

LAB_00509aee:

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

    iVar2 = FUN_00513100(param_2,1);

    uVar1 = DAT_008379a8;

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

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

    uVar3 = (*(uint *)(iVar2 + 8) >> ((byte)*(undefined4 *)(param_1 + 0xa4) & 0x1f) ^

            *(uint *)(iVar2 + 8)) & *(uint *)(param_1 + 0xa0);

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

    *(int *)(*(int *)(param_1 + 0xa8) + uVar3 * 4) = iVar2;

    FUN_00509a40(param_2);

  }

  return iVar2;

}





// --- FUN_00509b60 at 0x00509B60 (size: 163) ---


int __thiscall FUN_00509b60(int param_1,uint param_2,int param_3)



{

  undefined4 uVar1;

  int iVar2;

  uint uVar3;

  

  for (iVar2 = *(int *)(*(int *)(param_1 + 0xd8) +

                       ((param_2 >> ((byte)*(undefined4 *)(param_1 + 0xd4) & 0x1f) ^ param_2) &

                       *(uint *)(param_1 + 0xd0)) * 4); iVar2 != 0; iVar2 = *(int *)(iVar2 + 4)) {

    if (param_2 == *(uint *)(iVar2 + 8)) goto LAB_00509b9e;

  }

  iVar2 = 0;

LAB_00509b9e:

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

    iVar2 = FUN_0054bb30(param_2);

    uVar1 = DAT_008379a8;

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

    *(undefined4 *)(iVar2 + 0x18) = uVar1;

    uVar3 = (*(uint *)(iVar2 + 8) >> ((byte)*(undefined4 *)(param_1 + 0xd4) & 0x1f) ^

            *(uint *)(iVar2 + 8)) & *(uint *)(param_1 + 0xd0);

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

    *(int *)(*(int *)(param_1 + 0xd8) + uVar3 * 4) = iVar2;

    FUN_00509a40(param_2);

  }

  return iVar2;

}





// --- FUN_00509c10 at 0x00509C10 (size: 400) ---


void __fastcall FUN_00509c10(undefined4 *param_1)



{

  *param_1 = &PTR_LAB_007c7458;

  param_1[1] = &PTR_FUN_00801670;

  DAT_00842adc = 0;

  FUN_00509700();

  param_1[0x79] = &PTR_FUN_007c7444;

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

  param_1[0x73] = &PTR_FUN_007c7450;

  if (param_1[0x78] == 0) {

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

  }

  param_1[0x56] = &PTR_FUN_007c7454;

  FUN_005870f0();

  param_1[0x57] = &PTR_FUN_007c744c;

  if ((undefined4 *)param_1[0x6f] != param_1 + 0x58) {

    operator_delete__((undefined4 *)param_1[0x6f]);

  }

  param_1[0x6f] = 0;

  param_1[0x70] = 0;

  param_1[0x71] = 0;

  param_1[0x72] = 0;

  param_1[0x39] = &PTR_FUN_0079cdb0;

  FUN_005870f0();

  param_1[0x3a] = &PTR_FUN_0079cda8;

  if ((undefined4 *)param_1[0x52] != param_1 + 0x3b) {

    operator_delete__((undefined4 *)param_1[0x52]);

  }

  param_1[0x52] = 0;

  param_1[0x53] = 0;

  param_1[0x54] = 0;

  param_1[0x55] = 0;

  param_1[0x33] = &PTR_FUN_007c7450;

  if (param_1[0x38] == 0) {

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

  }

  param_1[0x2d] = &PTR_FUN_007c7450;

  if (param_1[0x32] == 0) {

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

  }

  param_1[0x27] = &PTR_FUN_007c7450;

  if (param_1[0x2c] == 0) {

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

  }

  param_1[0x21] = &PTR_FUN_007c7450;

  if (param_1[0x26] == 0) {

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

  }

  param_1[5] = &PTR_FUN_007c7448;

  if ((undefined4 *)param_1[0x1d] != param_1 + 6) {

    operator_delete__((undefined4 *)param_1[0x1d]);

  }

  param_1[0x1d] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0x20] = 0;

  param_1[2] = &PTR_LAB_00793b6c;

  FUN_0043c610();

  return;

}





// --- FUN_00509da0 at 0x00509DA0 (size: 59) ---


void FUN_00509da0(undefined4 param_1,undefined4 param_2)



{

  int iVar1;

  

  iVar1 = FUN_00508890(param_1);

  if (iVar1 == 0) {

    FUN_00509ab0(param_1,1);

    FUN_00509a40(param_1);

  }

  FUN_00514270(param_2);

  return;

}





// --- FUN_00509de0 at 0x00509DE0 (size: 46) ---


void FUN_00509de0(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_00509b60(param_1,1);

  FUN_00509f00(param_2,param_3);

  FUN_00509a40(param_1);

  return;

}





// --- FUN_00509e10 at 0x00509E10 (size: 41) ---


void FUN_00509e10(undefined4 param_1,undefined4 param_2)



{

  FUN_00509b60(param_1,1);

  FUN_00509f50(param_2);

  FUN_00509a40(param_1);

  return;

}





// --- FUN_00509e40 at 0x00509E40 (size: 160) ---


void __thiscall FUN_00509e40(int param_1,undefined4 param_2)



{

  int iVar1;

  uint uVar2;

  undefined4 uVar3;

  uint uVar4;

  undefined4 uVar5;

  

  FUN_00513fe0();

  uVar4 = 0;

  iVar1 = FUN_0051dfb0();

  if (iVar1 != 0) {

    do {

      uVar2 = FUN_0051dfc0(uVar4);

      for (iVar1 = *(int *)(*(int *)(param_1 + 0x90) +

                           ((uVar2 >> ((byte)*(undefined4 *)(param_1 + 0x8c) & 0x1f) ^ uVar2) &

                           *(uint *)(param_1 + 0x88)) * 4); iVar1 != 0; iVar1 = *(int *)(iVar1 + 4))

      {

        if (uVar2 == *(uint *)(iVar1 + 8)) goto LAB_00509e9e;

      }

      iVar1 = 0;

LAB_00509e9e:

      if (iVar1 == 0) {

        uVar5 = 1;

        uVar3 = FUN_0051dfc0(uVar4);

        FUN_00509ab0(uVar3,uVar5);

      }

      uVar3 = FUN_0051dfd0(uVar4);

      FUN_00516590(param_2,uVar3);

      uVar4 = uVar4 + 1;

      uVar2 = FUN_0051dfb0();

    } while (uVar4 < uVar2);

  }

  return;

}





// --- FUN_00509ee0 at 0x00509EE0 (size: 30) ---


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



{

  FUN_00509c10();

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

    operator_delete(param_1);

  }

  return param_1;

}





// --- FUN_00509f00 at 0x00509F00 (size: 36) ---


void FUN_00509f00(undefined4 param_1,undefined4 param_2)



{

  undefined4 local_4;

  

  local_4 = 0;

  FUN_005b10e0(param_1,param_2,&local_4);

  return;

}





// --- FUN_00509f30 at 0x00509F30 (size: 31) ---


void FUN_00509f30(undefined4 param_1,undefined4 param_2,undefined4 param_3)



{

  FUN_005b12d0(param_1,param_2,&param_3,param_3);

  return;

}





// --- FUN_00509f50 at 0x00509F50 (size: 122) ---


void __thiscall FUN_00509f50(int param_1,int param_2)



{

  int *piVar1;

  undefined4 *puVar2;

  int *piVar3;

  

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

    puVar2 = (undefined4 *)FUN_005df0f5(8);

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

      puVar2 = (undefined4 *)0x0;

    }

    else {

      *puVar2 = 0;

      puVar2[1] = 0;

    }

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

  }

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

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

  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_0050a0b0 at 0x0050A0B0 (size: 132) ---


void __fastcall FUN_0050a0b0(int param_1)



{

  int iVar1;

  int *piVar2;

  undefined4 *puVar3;

  void *pvVar4;

  LONG LVar5;

  undefined4 *puVar6;

  

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

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

    while (iVar1 != 0) {

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

      puVar3 = (undefined4 *)*piVar2;

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

        puVar6 = (undefined4 *)0x0;

      }

      else {

        iVar1 = puVar3[1];

        *piVar2 = iVar1;

        if (iVar1 == 0) {

          piVar2[1] = 0;

        }

        puVar6 = (undefined4 *)*puVar3;

        operator_delete(puVar3);

      }

      LVar5 = InterlockedDecrement(puVar6 + 1);

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

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

      }

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

    }

    pvVar4 = *(void **)(param_1 + 0x20);

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

      FUN_004c65a0();

      operator_delete(pvVar4);

    }

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

  }

  FUN_00693960(param_1);

  return;

}





// --- FUN_0050a140 at 0x0050A140 (size: 3) ---


undefined4 __fastcall FUN_0050a140(undefined4 param_1)



{

  return param_1;

}





// --- FUN_0050a150 at 0x0050A150 (size: 10) ---


void __thiscall FUN_0050a150(int param_1,undefined4 param_2)



{

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

  return;

}





// --- FUN_0050a160 at 0x0050A160 (size: 201) ---


undefined4

FUN_0050a160(int param_1,undefined4 param_2,undefined4 param_3,ushort param_4,ushort param_5,

            int param_6)



{

  ushort uVar1;

  uint uVar2;

  int iVar3;

  undefined4 uVar4;

  bool bVar5;

  

  uVar4 = 0;

  iVar3 = 0;

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

    iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x14))();

  }

  uVar1 = *(ushort *)(param_1 + 0x166);

  uVar2 = (int)((uint)param_4 - (uint)uVar1) >> 0x1f;

  if ((int)(((uint)param_4 - (uint)uVar1 ^ uVar2) - uVar2) < 0x8000) {

    bVar5 = uVar1 < param_4;

  }

  else {

    bVar5 = param_4 < uVar1;

  }

  if (bVar5) {

    *(ushort *)(param_1 + 0x166) = param_4;

    uVar1 = *(ushort *)(param_1 + 0x16e);

    uVar2 = (int)((uint)uVar1 - (uint)param_5) >> 0x1f;

    if ((int)(((uint)uVar1 - (uint)param_5 ^ uVar2) - uVar2) < 0x8000) {

      bVar5 = param_5 < uVar1;

    }

    else {

      bVar5 = uVar1 < param_5;

    }

    if (bVar5) {

      return 0;

    }

    *(ushort *)(param_1 + 0x16e) = param_5;

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

      *(int *)(param_1 + 0xcc) = param_6;

      FUN_00512b10(&param_2,param_3);

      if (iVar3 != 0) {

        uVar4 = 1;

      }

    }

  }

  return uVar4;

}





// --- FUN_0050a230 at 0x0050A230 (size: 46) ---


void FUN_0050a230(int param_1)



{

  int *piVar1;

  int *piVar2;

  

  piVar1 = DAT_00842c50 + DAT_00842c58;

  piVar2 = DAT_00842c50;

  if (DAT_00842c50 < piVar1) {

    while (*piVar2 != param_1) {

      piVar2 = piVar2 + 1;

      if (piVar1 <= piVar2) {

        return;

      }

    }

    *piVar2 = piVar1[-1];

    DAT_00842c58 = DAT_00842c58 + -1;

  }

  return;

}





// --- FUN_0050a260 at 0x0050A260 (size: 133) ---


void FUN_0050a260(undefined4 param_1,undefined2 *param_2,undefined4 param_3)



{

  undefined1 uVar1;

  undefined2 uVar2;

  undefined2 uVar3;

  uint uVar4;

  uint uVar5;

  undefined4 *puVar6;

  undefined4 *puVar7;

  

  uVar2 = *param_2;

  uVar3 = param_2[1];

  uVar1 = *(undefined1 *)(param_2 + 2);

  puVar6 = (undefined4 *)((int)param_2 + 5);

  uVar4 = (uint)puVar6 & 0x80000003;

  if ((int)uVar4 < 0) {

    uVar4 = (uVar4 - 1 | 0xfffffffc) + 1;

  }

  if ((uVar4 != 0) && (uVar4 = 4 - uVar4, uVar4 != 0)) {

    puVar7 = puVar6;

    for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {

      *puVar7 = 0;

      puVar7 = puVar7 + 1;

    }

    for (uVar5 = uVar4 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {

      *(undefined1 *)puVar7 = 0;

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

    }

    puVar6 = (undefined4 *)((int)puVar6 + uVar4);

  }

  FUN_0050a160(param_1,puVar6,param_3,uVar2,uVar3,uVar1);

  return;

}





// --- FUN_0050a2f0 at 0x0050A2F0 (size: 225) ---


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



void FUN_0050a2f0(float param_1)



{

  undefined4 *puVar1;

  float fVar2;

  float fVar3;

  int *piVar4;

  uint uVar5;

  uint uVar6;

  undefined4 uVar7;

  

  uVar6 = 0;

  uVar5 = DAT_00842c64;

  if (DAT_00842c64 != 0) {

    do {

      puVar1 = *(undefined4 **)(DAT_00842c5c + uVar6 * 4);

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

        uVar7 = *puVar1;

        FUN_00414590(6,uVar7);

        piVar4 = (int *)FUN_00416f40(uVar7);

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

          operator_delete(puVar1);

          if ((uVar6 < DAT_00842c64) && (DAT_00842c64 = DAT_00842c64 - 1, uVar6 != DAT_00842c64)) {

            *(undefined4 *)(DAT_00842c5c + uVar6 * 4) =

                 *(undefined4 *)(DAT_00842c5c + DAT_00842c64 * 4);

          }

          uVar6 = uVar6 - 1;

          uVar5 = DAT_00842c64;

        }

        else {

          fVar2 = param_1 * (float)puVar1[1];

          fVar3 = param_1 * (float)puVar1[2];

          if (_DAT_007938b0 <= (float)puVar1[3]) {

            fVar2 = fVar2 - _DAT_007938b0;

          }

          if (_DAT_007938b0 <= (float)puVar1[4]) {

            fVar3 = fVar3 - _DAT_007938b0;

          }

          puVar1[3] = fVar2 + (float)puVar1[3];

          puVar1[4] = fVar3 + (float)puVar1[4];

          FUN_00534f10(puVar1[3],puVar1[4]);

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

          uVar5 = DAT_00842c64;

        }

      }

      uVar6 = uVar6 + 1;

    } while (uVar6 < uVar5);

  }

  return;

}





// --- FUN_0050a3e0 at 0x0050A3E0 (size: 62) ---


void __fastcall FUN_0050a3e0(int param_1)



{

  void *pvVar1;

  uint uVar2;

  

  uVar2 = 0;

  if (DAT_00842c64 != 0) {

    do {

      pvVar1 = *(void **)(DAT_00842c5c + uVar2 * 4);

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

        operator_delete(pvVar1);

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < DAT_00842c64);

  }

  operator_delete(*(void **)(param_1 + 0xc));

  return;

}





// --- FUN_0050a420 at 0x0050A420 (size: 269) ---


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



void __fastcall FUN_0050a420(int param_1)



{

  int *piVar1;

  int iVar2;

  int iVar3;

  double dVar4;

  uint uVar5;

  

  dVar4 = (double)CONCAT44(DAT_008379ac,DAT_008379a8) - _DAT_00842bb0;

  if (dVar4 < _DAT_00795610) {

    _DAT_00842bb0 = DAT_008379a8;

    _DAT_00842bb4 = DAT_008379ac;

    return;

  }

  if (_DAT_00842c08 <= dVar4) {

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

    piVar1[3] = 0;

    piVar1[1] = 0;

    if (*piVar1 == 0) {

      piVar1[4] = 1;

      piVar1[2] = 0;

    }

    else {

      piVar1[4] = 0;

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

      piVar1[2] = iVar2;

      if (iVar2 == 0) {

        FUN_004d8d00();

      }

    }

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

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

    while (iVar3 == 0) {

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

      FUN_00516810();

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

        FUN_00452da0();

      }

      FUN_004d8d00();

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

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

    }

    uVar5 = 0;

    _DAT_00842bb0 = DAT_008379a8;

    _DAT_00842bb4 = DAT_008379ac;

    if (DAT_00842c58 != 0) {

      do {

        FUN_005148f0();

        uVar5 = uVar5 + 1;

      } while (uVar5 < DAT_00842c58);

    }

    FUN_0050a2f0((float)dVar4);

  }

  return;

}





// --- FUN_0050a530 at 0x0050A530 (size: 134) ---


int * __thiscall FUN_0050a530(int *param_1,int param_2,int param_3)



{

  int iVar1;

  int *piVar2;

  int iVar3;

  

  param_1[2] = 0;

  *param_1 = param_2;

  param_1[1] = param_3;

  piVar2 = (int *)FUN_005df0f5(0x14);

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

    piVar2 = (int *)0x0;

  }

  else {

    iVar1 = *param_1;

    iVar3 = iVar1 + 0x84;

    *piVar2 = iVar3;

    piVar2[3] = 0;

    piVar2[1] = 0;

    if (iVar3 == 0) {

      piVar2[4] = 1;

      piVar2[2] = 0;

    }

    else {

      piVar2[4] = 0;

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

      piVar2[2] = iVar1;

      if (iVar1 == 0) {

        FUN_004d8d00();

      }

    }

  }

  param_1[3] = (int)piVar2;

  DAT_008eee70 = DAT_008379a8;

  DAT_008eee74 = DAT_008379ac;

  return param_1;

}





// --- FUN_0050a5c0 at 0x0050A5C0 (size: 110) ---


void FUN_0050a5c0(int param_1)



{

  int *piVar1;

  int iVar2;

  

  piVar1 = DAT_00842c50;

  do {

    if (DAT_00842c50 + DAT_00842c58 <= piVar1) {

LAB_0050a5ef:

      if (DAT_00842c54 <= DAT_00842c58) {

        if (DAT_00842c54 == 0) {

          iVar2 = 8;

        }

        else {

          iVar2 = DAT_00842c54 * 2;

        }

        iVar2 = FUN_00500570(iVar2);

        if (iVar2 == 0) {

          return;

        }

      }

      DAT_00842c50[DAT_00842c58] = param_1;

      DAT_00842c58 = DAT_00842c58 + 1;

      return;

    }

    if (*piVar1 == param_1) {

      *piVar1 = (DAT_00842c50 + DAT_00842c58)[-1];

      DAT_00842c58 = DAT_00842c58 - 1;

      goto LAB_0050a5ef;

    }

    piVar1 = piVar1 + 1;

  } while( true );

}





// --- FUN_0050a630 at 0x0050A630 (size: 239) ---


void FUN_0050a630(int param_1,float param_2,float param_3)



{

  void *pvVar1;

  int *piVar2;

  int iVar3;

  uint uVar4;

  

  uVar4 = 0;

  if (DAT_00842c64 != 0) {

    do {

      piVar2 = *(int **)(DAT_00842c5c + uVar4 * 4);

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

        pvVar1 = *(void **)(DAT_00842c5c + uVar4 * 4);

        if ((param_2 != DAT_00796344) || (param_3 != DAT_00796344)) {

          *(float *)((int)pvVar1 + 4) = param_2;

          *(float *)((int)pvVar1 + 8) = param_3;

          return;

        }

        if ((uVar4 < DAT_00842c64) && (DAT_00842c64 = DAT_00842c64 - 1, uVar4 != DAT_00842c64)) {

          *(undefined4 *)(DAT_00842c5c + uVar4 * 4) =

               *(undefined4 *)(DAT_00842c5c + DAT_00842c64 * 4);

        }

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

          return;

        }

        operator_delete(pvVar1);

        return;

      }

      uVar4 = uVar4 + 1;

    } while (uVar4 < DAT_00842c64);

  }

  piVar2 = (int *)FUN_005df0f5(0x14);

  *piVar2 = param_1;

  piVar2[1] = (int)param_2;

  piVar2[2] = (int)param_3;

  piVar2[3] = 0;

  piVar2[4] = 0;

  if (DAT_00842c60 <= DAT_00842c64) {

    if (DAT_00842c60 == 0) {

      iVar3 = 8;

    }

    else {

      iVar3 = DAT_00842c60 * 2;

    }

    iVar3 = FUN_00500570(iVar3);

    if (iVar3 == 0) {

      return;

    }

  }

  *(int **)(DAT_00842c5c + DAT_00842c64 * 4) = piVar2;

  DAT_00842c64 = DAT_00842c64 + 1;

  return;

}





// --- FUN_0050a720 at 0x0050A720 (size: 87) ---


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



void __thiscall FUN_0050a720(float *param_1,float *param_2)



{

  if (_DAT_007c7618 < ABS(param_1[2])) {

    param_2[2] = 0.0;

    param_2[2] = -(param_1[2] * DAT_00796344 + *param_2 * *param_1 + param_2[1] * param_1[1] +

                  param_1[3]) * ((float)_DAT_007938c0 / param_1[2]) -

                 -param_1[3] * ((float)_DAT_007938c0 / param_1[2]);

  }

  return;

}





// --- FUN_0050a780 at 0x0050A780 (size: 39) ---


void __thiscall FUN_0050a780(undefined4 *param_1,undefined4 *param_2)



{

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  param_1[3] = param_2[3];

  return;

}





// --- FUN_0050a7b0 at 0x0050A7B0 (size: 35) ---


void __thiscall FUN_0050a7b0(int param_1,undefined4 *param_2)



{

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

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

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

  *(undefined4 *)(param_1 + 0x1d0) = param_2[3];

  return;

}





// --- FUN_0050a7e0 at 0x0050A7E0 (size: 67) ---


void __thiscall FUN_0050a7e0(int param_1,float *param_2)



{

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

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

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

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

  FUN_0050d2e0();

  return;

}





// --- FUN_0050a830 at 0x0050A830 (size: 32) ---


void __fastcall FUN_0050a830(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[6] = 0;

  param_1[0xe] = 0;

  param_1[0x12] = 0;

  param_1[0x19] = 0;

  param_1[0x1e] = 0;

  param_1[0x1f] = 0;

  param_1[0xb] = 0;

  param_1[0x20] = 0;

  return;

}





// --- FUN_0050a850 at 0x0050A850 (size: 56) ---


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



{

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

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

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

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

  *(undefined4 *)(param_1 + 0x28) = param_2[3];

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

  return;

}





// --- FUN_0050a890 at 0x0050A890 (size: 7) ---


void FUN_0050a890(void)



{

  DAT_00842c6c = DAT_00842c6c + -1;

  return;

}





// --- FUN_0050a8a0 at 0x0050A8A0 (size: 97) ---


void __fastcall FUN_0050a8a0(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[7] = 0;

  FUN_0050ce00();

  param_1[0x9c] = 0;

  param_1[0xa2] = 0;

  param_1[0xaa] = 0;

  param_1[0xae] = 0;

  param_1[0xb5] = 0;

  param_1[0xba] = 0;

  param_1[0xbb] = 0;

  param_1[0xa7] = 0;

  param_1[0xbc] = 0;

  param_1[0xbf] = 0;

  param_1[0xbd] = 0;

  param_1[0xbe] = 0;

  return;

}





// --- thunk_FUN_0050da00 at 0x0050A910 (size: 5) ---


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



{

  int *piVar1;

  int iVar2;

  float10 fVar3;

  

  *param_1 = param_2;

  param_1[1] = param_3;

  param_1[2] = *(int *)(param_2 + 0x114);

  fVar3 = (float10)FUN_0050f4d0();

  param_1[3] = (int)(float)fVar3;

  fVar3 = (float10)FUN_0050f4f0();

  param_1[4] = (int)(float)fVar3;

  iVar2 = *param_1;

  param_1[5] = *(uint *)(iVar2 + 0xa8) & 4;

  param_1[6] = ~(*(uint *)(iVar2 + 0xa8) >> 6) & 1;

  piVar1 = *(int **)(iVar2 + 300);

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

    iVar2 = (**(code **)(*piVar1 + 0x28))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x80;

    }

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

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x100;

    }

    iVar2 = (**(code **)(*piVar1 + 0x20))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x800;

    }

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

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x1000;

    }

  }

  return;

}





// --- FUN_0050a920 at 0x0050A920 (size: 8) ---


void FUN_0050a920(void)



{

  FUN_0050d140();

  return;

}





// --- FUN_0050a930 at 0x0050A930 (size: 8) ---


void FUN_0050a930(void)



{

  FUN_0050d8f0();

  return;

}





// --- FUN_0050a940 at 0x0050A940 (size: 96) ---


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



{

  undefined4 uVar1;

  int iVar2;

  

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

    uVar1 = 2;

  }

  else {

    iVar2 = 0;

    uVar1 = 1;

    if (0 < param_3) {

      do {

        uVar1 = (**(code **)(*param_2 + 0x88))(param_1);

        switch(uVar1) {

        case 1:

        case 2:

          goto switchD_0050a973_caseD_1;

        case 4:

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

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

        default:

          iVar2 = iVar2 + 1;

          if (param_3 <= iVar2) {

            return uVar1;

          }

        }

      } while( true );

    }

  }

switchD_0050a973_caseD_1:

  return uVar1;

}





// --- FUN_0050a9b0 at 0x0050A9B0 (size: 47) ---


void __thiscall FUN_0050a9b0(int param_1,undefined4 param_2)



{

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

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

  FUN_0052c570(param_1 + 0x2f4,param_2,param_1 + 0x20);

  return;

}





// --- FUN_0050a9e0 at 0x0050A9E0 (size: 78) ---


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



undefined4 __thiscall FUN_0050a9e0(float *param_1,float *param_2)



{

  if (((ABS(*param_1 - *param_2) < _DAT_007c7618 != (ABS(*param_1 - *param_2) == _DAT_007c7618)) &&

      (ABS(param_1[1] - param_2[1]) < _DAT_007c7618 !=

       (ABS(param_1[1] - param_2[1]) == _DAT_007c7618))) &&

     (ABS(param_1[2] - param_2[2]) < _DAT_007c7618 !=

      (ABS(param_1[2] - param_2[2]) == _DAT_007c7618))) {

    return 1;

  }

  return 0;

}





// --- FUN_0050aa30 at 0x0050AA30 (size: 100) ---


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



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float local_18;

  float local_14;

  float local_10;

  

  FUN_0043e7d0(&local_18,*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_3 + 4));

  fVar1 = *(float *)(param_3 + 0x40);

  fVar2 = *(float *)(param_3 + 0x44);

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

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

  *param_2 = (local_18 + *(float *)(param_3 + 0x3c)) - *(float *)(param_1 + 0x3c);

  param_2[1] = (local_14 + fVar1) - fVar3;

  param_2[2] = (local_10 + fVar2) - fVar4;

  return;

}





// --- FUN_0050aaa0 at 0x0050AAA0 (size: 34) ---


undefined4 __thiscall FUN_0050aaa0(int param_1,undefined4 param_2)



{

  FUN_0043e7d0(param_2,*(undefined4 *)(param_1 + 0xa4),*(undefined4 *)(param_1 + 0x110));

  return param_2;

}





// --- FUN_0050aad0 at 0x0050AAD0 (size: 96) ---


void __thiscall FUN_0050aad0(int param_1,undefined4 *param_2)



{

  int iVar1;

  

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

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

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

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

  iVar1 = FUN_004524a0();

  if (iVar1 != 0) {

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

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

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

  }

  return;

}





// --- FUN_0050ab30 at 0x0050AB30 (size: 71) ---


void __thiscall FUN_0050ab30(int param_1,undefined4 *param_2)



{

  int iVar1;

  

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

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

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

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

  iVar1 = FUN_004524a0();

  if (iVar1 != 0) {

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

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

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

  }

  return;

}





// --- FUN_0050ab80 at 0x0050AB80 (size: 593) ---


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



void __thiscall FUN_0050ab80(int param_1,float *param_2,float *param_3,int *param_4)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float *pfVar4;

  int iVar5;

  double dVar6;

  undefined1 local_c [8];

  float local_4;

  

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

    *param_2 = 0.0;

    param_2[1] = 0.0;

    param_2[2] = 0.0;

    *param_3 = 0.0;

    param_3[1] = 0.0;

    param_3[2] = 0.0;

    *param_4 = 1;

    return;

  }

  pfVar4 = (float *)FUN_0050aa30(local_c,*(undefined4 *)(param_1 + 0xb8));

  *param_2 = *pfVar4;

  param_2[1] = pfVar4[1];

  param_2[2] = pfVar4[2];

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

  fVar2 = SQRT(param_2[2] * param_2[2] + param_2[1] * param_2[1] + *param_2 * *param_2);

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

    if (_DAT_007c7618 < fVar2) {

      fVar2 = fVar2 / fVar1;

      fVar3 = _DAT_007938b0 / fVar2;

      fVar1 = param_2[1];

      local_4 = fVar3 * param_2[2];

      *param_3 = fVar3 * *param_2;

      param_3[1] = fVar3 * fVar1;

      param_3[2] = local_4;

      floor((double)fVar2);

      iVar5 = FUN_005df4c4();

      *param_4 = iVar5 + 1;

      return;

    }

    *param_3 = 0.0;

    param_3[1] = 0.0;

    param_3[2] = 0.0;

    *param_4 = 0;

    return;

  }

  fVar2 = fVar2 / (_DAT_007c7614 * fVar1);

  if (fVar2 < _DAT_007938b0 == (fVar2 == _DAT_007938b0)) {

    dVar6 = ceil((double)fVar2);

    fVar2 = _DAT_007938b0 / (float)dVar6;

    fVar1 = param_2[1];

    local_4 = fVar2 * param_2[2];

    *param_3 = fVar2 * *param_2;

    param_3[1] = fVar2 * fVar1;

    param_3[2] = local_4;

    iVar5 = FUN_005df4c4();

    *param_4 = iVar5;

    return;

  }

  if (((*param_2 == DAT_00796344) && (param_2[1] == DAT_00796344)) && (param_2[2] == DAT_00796344))

  {

    *param_3 = 0.0;

    param_3[1] = 0.0;

    param_3[2] = 0.0;

    *param_4 = 0;

    return;

  }

  *param_3 = *param_2;

  param_3[1] = param_2[1];

  param_3[2] = param_2[2];

  *param_4 = 1;

  return;

}





// --- FUN_0050ad5f at 0x0050AD5F (size: 100) ---


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



void FUN_0050ad5f(void)



{

  float fVar1;

  float fVar2;

  float fVar3;

  undefined4 uVar4;

  float *unaff_ESI;

  float10 in_ST0;

  double dVar5;

  float *in_stack_00000028;

  undefined4 *in_stack_0000002c;

  

  dVar5 = ceil((double)in_ST0);

  fVar3 = _DAT_007938b0 / (float)dVar5;

  fVar1 = unaff_ESI[1];

  fVar2 = unaff_ESI[2];

  *in_stack_00000028 = fVar3 * *unaff_ESI;

  in_stack_00000028[1] = fVar3 * fVar1;

  in_stack_00000028[2] = fVar3 * fVar2;

  uVar4 = FUN_005df4c4();

  *in_stack_0000002c = uVar4;

  return;

}





// --- FUN_0050ae40 at 0x0050AE40 (size: 858) ---


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



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



{

  float *pfVar1;

  float *pfVar2;

  float fVar3;

  bool bVar4;

  int iVar5;

  float local_24;

  float local_20;

  float local_1c;

  float local_18;

  float local_14;

  float local_10;

  float local_4;

  

  local_20 = param_3[1];

  local_24 = *param_3;

  local_1c = param_3[2];

  bVar4 = false;

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

    if (local_24 * *(float *)(param_1 + 0x2ac) +

        local_20 * *(float *)(param_1 + 0x2b0) + local_1c * *(float *)(param_1 + 0x2b4) <

        DAT_00796344) {

      bVar4 = true;

    }

    else {

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

    }

  }

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

    if (bVar4) {

      fVar3 = local_20 * *(float *)(param_1 + 0x2b0) +

              local_1c * *(float *)(param_1 + 0x2b4) + local_24 * *(float *)(param_1 + 0x2ac);

      local_24 = local_24 - fVar3 * *(float *)(param_1 + 0x2ac);

      local_20 = local_20 - fVar3 * *(float *)(param_1 + 0x2b0);

      local_1c = local_1c - fVar3 * *(float *)(param_1 + 0x2b4);

    }

  }

  else {

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

    fVar3 = local_24 * *pfVar1 +

            local_20 * *(float *)(param_1 + 0x290) + local_1c * *(float *)(param_1 + 0x294);

    if (bVar4) {

      local_18 = *(float *)(param_1 + 0x2b4) * *(float *)(param_1 + 0x290) -

                 *(float *)(param_1 + 0x2b0) * *(float *)(param_1 + 0x294);

      local_14 = *(float *)(param_1 + 0x2ac) * *(float *)(param_1 + 0x294) -

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

      local_10 = *(float *)(param_1 + 0x2b0) * *pfVar1 -

                 *(float *)(param_1 + 0x2ac) * *(float *)(param_1 + 0x290);

      iVar5 = FUN_004524a0();

      if (iVar5 == 0) {

        local_1c = local_18 * local_24 + local_14 * local_20 + local_10 * local_1c;

        local_24 = local_18 * local_1c;

        local_20 = local_14 * local_1c;

        local_1c = local_10 * local_1c;

        local_18 = local_24;

        local_14 = local_20;

        local_10 = local_1c;

        local_4 = local_1c;

      }

      else {

        local_18 = 0.0;

        local_14 = 0.0;

        local_10 = 0.0;

        local_24 = 0.0;

        local_20 = 0.0;

        local_1c = 0.0;

      }

    }

    else if (fVar3 <= DAT_00796344) {

      local_4 = fVar3 * *(float *)(param_1 + 0x294);

      local_24 = local_24 - fVar3 * *pfVar1;

      local_20 = local_20 - fVar3 * *(float *)(param_1 + 0x290);

      local_1c = local_1c - local_4;

      local_18 = local_24;

      local_14 = local_20;

      local_10 = local_1c;

    }

    else {

      FUN_0050a720(&local_24);

    }

    if ((*(int *)(param_1 + 0x2a4) == 0) && (*(int *)(param_1 + 0x29c) != 0)) {

      FUN_0043e7d0(&local_18,*(undefined4 *)(param_1 + 0x130),*(int *)(param_1 + 0x29c));

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

      fVar3 = (*pfVar2 - local_18) * *pfVar1 +

              (pfVar2[1] - local_14) * *(float *)(param_1 + 0x290) +

              (pfVar2[2] - local_10) * *(float *)(param_1 + 0x294) + *(float *)(param_1 + 0x298);

      if ((fVar3 < pfVar2[3] - _DAT_007c7618) &&

         (local_10 = (pfVar2[3] - fVar3) / *(float *)(param_1 + 0x294), ABS(local_10) < pfVar2[3]))

      {

        local_18 = 0.0;

        local_14 = 0.0;

        FUN_0050a7e0(&local_18);

      }

    }

  }

  *param_2 = local_24;

  param_2[1] = local_20;

  param_2[2] = local_1c;

  return;

}





// --- FUN_0050b1a0 at 0x0050B1A0 (size: 425) ---


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



undefined4 __thiscall FUN_0050b1a0(int param_1,float *param_2)



{

  float *pfVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float fVar5;

  int iVar6;

  float *pfVar7;

  float unaff_ESI;

  float local_28;

  float local_24;

  float local_20;

  float local_1c;

  float local_10;

  float local_c;

  float local_4;

  

  fVar2 = param_2[1] * *(float *)(param_1 + 0x27c) - param_2[2] * *(float *)(param_1 + 0x278);

  fVar4 = *(float *)(param_1 + 0x274) * param_2[2] - *(float *)(param_1 + 0x27c) * *param_2;

  fVar3 = (*param_2 * *(float *)(param_1 + 0x278) - param_2[1] * *(float *)(param_1 + 0x274)) *

          DAT_00796344;

  fVar5 = fVar3 - fVar4;

  fVar3 = fVar2 - fVar3;

  local_28 = fVar4 * DAT_00796344 - fVar2 * DAT_00796344;

  iVar6 = FUN_004524a0();

  if (iVar6 != 0) {

    return 1;

  }

  FUN_0043e7d0(&local_24,*(undefined4 *)(param_1 + 0xc4),*(undefined4 *)(param_1 + 0x130));

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

  pfVar1 = *(float **)(param_1 + 0x58);

  local_10 = pfVar7[2] - pfVar1[2];

  local_c = local_24 + (*pfVar7 - *pfVar1);

  local_1c = local_c * fVar5 +

             (local_20 + (pfVar7[1] - pfVar1[1])) * fVar3 + (local_1c + local_10) * local_28;

  if (local_1c <= (float)_DAT_00795610) {

    local_24 = fVar5 * local_1c;

    local_20 = fVar3 * local_1c;

    local_1c = local_28 * local_1c;

    local_4 = local_1c;

    FUN_0050a7e0(&local_24);

    pfVar7 = (float *)&stack0xffffffcc;

  }

  else {

    local_1c = -local_1c;

    local_24 = fVar5 * local_1c;

    local_20 = fVar3 * local_1c;

    local_1c = local_28 * local_1c;

    local_4 = local_1c;

    FUN_0050a7e0(&local_24);

    pfVar7 = &local_28;

    local_28 = -unaff_ESI;

    local_24 = -fVar5;

    local_20 = -fVar3;

  }

  FUN_0050aad0(pfVar7);

  return 3;

}





// --- FUN_0050b350 at 0x0050B350 (size: 43) ---


void __fastcall FUN_0050b350(int param_1)



{

  *(undefined4 *)(param_1 + 0x160) = *(undefined4 *)(param_1 + 0x108);

  *(undefined4 *)(param_1 + 0x168) = *(undefined4 *)(param_1 + 0x110);

  FUN_00425f10(param_1 + 0x114);

  return;

}





// --- FUN_0050b380 at 0x0050B380 (size: 64) ---


void __thiscall FUN_0050b380(int param_1,int param_2,undefined4 param_3)



{

  *(undefined4 *)(param_1 + 0x110) = *(undefined4 *)(param_2 + 4);

  FUN_00425f10(param_2 + 8);

  *(undefined4 *)(param_1 + 0x108) = param_3;

  *(undefined4 *)(param_1 + 0x234) = 0;

  FUN_0050d2e0(0);

  return;

}





// --- FUN_0050b3c0 at 0x0050B3C0 (size: 41) ---


undefined4 * __thiscall FUN_0050b3c0(int param_1,undefined4 *param_2)



{

  *param_2 = &PTR_LAB_00797910;

  param_2[1] = *(undefined4 *)(param_1 + 0x1ec);

  FUN_00425f10(param_1 + 0x1f0);

  return param_2;

}





// --- FUN_0050b3f0 at 0x0050B3F0 (size: 93) ---


undefined4 * __fastcall FUN_0050b3f0(undefined4 *param_1)



{

  undefined4 *puVar1;

  undefined4 *puVar2;

  

  param_1[2] = 0;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(0x44);

  if (puVar1 == (undefined4 *)0x0) {

    puVar2 = (undefined4 *)0x0;

  }

  else {

    puVar2 = puVar1 + 1;

    *puVar1 = 8;

    FUN_00401000(puVar2,8,8,FUN_0050a140);

  }

  param_1[3] = puVar2;

  param_1[5] = 0;

  param_1[6] = 8;

  param_1[4] = 8;

  param_1[2] = 0;

  *param_1 = 0;

  param_1[1] = 0;

  param_1[4] = 8;

  return param_1;

}





// --- FUN_0050b450 at 0x0050B450 (size: 127) ---


undefined4 * __fastcall FUN_0050b450(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[1] = 0;

  param_1[7] = 0;

  FUN_0050cf50();

  param_1[0xb6] = 0;

  param_1[0xb9] = 0;

  param_1[0xb8] = 0;

  param_1[0xb7] = 0x80;

  param_1[0x9c] = 0;

  param_1[0xa2] = 0;

  param_1[0xaa] = 0;

  param_1[0xae] = 0;

  param_1[0xb5] = 0;

  param_1[0xba] = 0;

  param_1[0xbb] = 0;

  param_1[0xa7] = 0;

  param_1[0xbc] = 0;

  FUN_0050b3f0();

  FUN_0050a8a0();

  return param_1;

}





// --- FUN_0050b4d0 at 0x0050B4D0 (size: 102) ---


bool __fastcall FUN_0050b4d0(int param_1)



{

  undefined4 uVar1;

  int iVar2;

  

  uVar1 = *(undefined4 *)(param_1 + 0xbc);

  *(undefined4 *)(param_1 + 0x174) = 1;

  *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0xc4);

  FUN_00425f10(param_1 + 200);

  *(undefined4 *)(param_1 + 0x128) = uVar1;

  *(undefined4 *)(param_1 + 0x254) = 0;

  FUN_0050d2e0(0);

  iVar2 = FUN_0050fb20(param_1);

  return iVar2 != 1;

}





// --- FUN_0050b540 at 0x0050B540 (size: 834) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



int __thiscall FUN_0050b540(int *param_1,int param_2,undefined4 *param_3)



{

  float *pfVar1;

  bool bVar2;

  int iVar3;

  undefined4 local_10;

  undefined4 local_c;

  undefined4 local_8;

  float local_4;

  

  *param_3 = 0;

  bVar2 = true;

  if (param_2 == 1) {

    if (param_1[0x4c] == param_1[0x31]) {

      iVar3 = FUN_00424e90(param_1 + 0x32);

      if (iVar3 != 0) goto LAB_0050b590;

    }

  }

  else {

LAB_0050b590:

    bVar2 = false;

    if (param_2 != 1) {

      if ((1 < param_2) && (param_2 < 5)) {

        if (param_1[0x9c] != 0) {

          FUN_0050dab0();

          pfVar1 = (float *)param_1[0x16];

          if (ABS(*pfVar1 * (float)param_1[0x9d] +

                  pfVar1[1] * (float)param_1[0x9e] + pfVar1[2] * (float)param_1[0x9f] +

                  (float)param_1[0xa0]) < _DAT_007c7618 + *(float *)(param_1[0xd] + 0xc)) {

            FUN_0050a850(param_1 + 0x9d,param_1[0xa1]);

            param_1[0xa7] = param_1[0xa8];

            if ((*(byte *)(param_1 + 1) & 2) != 0) {

              bVar2 = true;

            }

          }

        }

        if (param_1[0xae] == 0) {

          local_10 = 0;

          local_c = 0;

          local_8 = 0x3f800000;

          FUN_0050aad0(&local_10);

        }

        FUN_0050b380(param_1 + 0x30,param_1[0x2f]);

        FUN_0050a9b0(0);

        param_2 = 1;

      }

      goto LAB_0050b6e9;

    }

  }

  iVar3 = param_1[0x4a];

  param_1[0x31] = param_1[0x4c];

  FUN_00425f10(param_1 + 0x4d);

  param_1[0x2f] = iVar3;

  FUN_0050d210();

  iVar3 = param_1[0x2f];

  param_1[0x4c] = param_1[0x31];

  FUN_00425f10(param_1 + 0x32);

  param_1[0x4a] = iVar3;

  param_1[0x95] = 0;

  FUN_0050d2e0(0);

LAB_0050b6e9:

  if (param_1[0xae] != 0) {

    FUN_0050ab30(param_1 + 0xaf);

  }

  if (((*(byte *)(param_1 + 1) & 4) == 0) && ((*(uint *)(*param_1 + 0xa8) & 0x400) != 0)) {

    if (bVar2) {

      param_1[0xbc] = 0;

    }

    else if (param_1[0xbc] == 0) {

      param_1[0xbc] = 1;

    }

    else if (param_1[0xbc] == 1) {

      param_1[0xbc] = 2;

    }

    else {

      pfVar1 = (float *)param_1[0xd];

      param_1[0xbc] = 3;

      local_10 = 0;

      local_c = 0;

      local_8 = 0x3f800000;

      local_4 = pfVar1[3] - ((pfVar1[1] + *pfVar1) * DAT_00796344 + pfVar1[2]);

      FUN_0050a850(&local_10,0);

      param_1[0xa7] = param_1[0x4c];

      if ((*(byte *)(param_1 + 1) & 1) == 0) {

        FUN_0050aad0(&local_10);

        param_1[0xbb] = 1;

      }

    }

  }

  param_1[0x9c] = param_1[0xa2];

  if (param_1[0xa2] != 0) {

    param_1[0x9d] = param_1[0xa3];

    param_1[0x9e] = param_1[0xa4];

    param_1[0x9f] = param_1[0xa5];

    param_1[0xa0] = param_1[0xa6];

    param_1[0xa8] = param_1[0xa7];

    param_1[0xa1] = param_1[0xa9];

  }

  if (param_1[0xa2] != 0) {

    param_1[1] = param_1[1] | 1;

    iVar3 = FUN_0050d9e0(param_1 + 0xa3);

    if (iVar3 != 0) {

      param_1[1] = param_1[1] | 2;

      return param_2;

    }

    param_1[1] = param_1[1] & 0xfffffffd;

    return param_2;

  }

  param_1[1] = param_1[1] & 0xfffffffc;

  return param_2;

}





// --- FUN_0050b890 at 0x0050B890 (size: 130) ---


int __thiscall FUN_0050b890(int param_1,int param_2,undefined4 *param_3)



{

  int iVar1;

  

  *param_3 = 0;

  iVar1 = *(int *)(param_1 + 0x128);

  if (iVar1 == 0) {

    return 2;

  }

  if (param_2 == 1) {

    *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)(param_1 + 0x130);

    FUN_00425f10(param_1 + 0x134);

    *(int *)(param_1 + 0xbc) = iVar1;

    FUN_0050d210();

  }

  else if (((1 < param_2) && (param_2 < 5)) && (*(int *)(param_1 + 0x26c) != 0)) {

    FUN_0050a830();

    return param_2;

  }

  return param_2;

}





// --- FUN_0050b920 at 0x0050B920 (size: 386) ---


undefined4 __thiscall FUN_0050b920(int param_1,int *param_2)



{

  int *piVar1;

  uint uVar2;

  undefined4 uVar3;

  int local_4c;

  undefined **ppuStack_48;

  uint uStack_44;

  undefined1 auStack_40 [52];

  undefined1 auStack_c [12];

  

  uVar2 = 0;

  uVar3 = 1;

  local_4c = 0;

  *(undefined4 *)(param_1 + 0x254) = 1;

  *(undefined4 *)(param_1 + 0x1d0) = 0;

  FUN_0052c570(param_1 + 0x2f4,&local_4c,param_1 + 0x20);

  if (*(int *)(param_1 + 0x2fc) != 0) {

    do {

      piVar1 = *(int **)(*(int *)(param_1 + 0x300) + 4 + uVar2 * 8);

      if ((piVar1 != (int *)0x0) && (piVar1 != param_2)) {

        uVar3 = (**(code **)(*piVar1 + 0x88))(param_1);

        switch(uVar3) {

        case 2:

        case 3:

          goto switchD_0050b989_caseD_2;

        case 4:

          *(undefined4 *)(param_1 + 0x288) = 0;

          *(undefined4 *)(param_1 + 0x2a4) = 0;

          return uVar3;

        }

      }

      uVar2 = uVar2 + 1;

    } while (uVar2 < *(uint *)(param_1 + 0x2fc));

  }

  *(int *)(param_1 + 0x128) = local_4c;

  if (local_4c != 0) {

    FUN_0050d6d0(*(undefined4 *)(local_4c + 0x28));

    return uVar3;

  }

  if (*(int *)(param_1 + 0x178) != 0) {

    return 2;

  }

  uStack_44 = *(uint *)(param_1 + 0x130);

  ppuStack_48 = &PTR_LAB_00797910;

  FUN_00425f10(param_1 + 0x134);

  if ((uStack_44 & 0xffff) < 0x100) {

    FUN_005aac70(&uStack_44,auStack_c);

  }

  if (uStack_44 != 0) {

    FUN_0050d6d0(uStack_44);

    *(uint *)(param_1 + 0x130) = uStack_44;

    FUN_00425f10(auStack_40);

    *(undefined4 *)(param_1 + 0x128) = 0;

    *(undefined4 *)(param_1 + 0x254) = 0;

    FUN_0050d2e0(0);

    *(undefined4 *)(param_1 + 0x254) = 1;

    return uVar3;

  }

  uVar3 = 2;

switchD_0050b989_caseD_2:

  return uVar3;

}





// --- FUN_0050bac0 at 0x0050BAC0 (size: 259) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



bool __thiscall FUN_0050bac0(int param_1,undefined4 param_2)



{

  float fVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 local_54;

  undefined4 local_50;

  float local_4c;

  undefined **local_48;

  undefined4 local_44;

  

  if ((*(byte *)(param_1 + 4) & 2) != 0) {

    iVar3 = FUN_0050ceb0();

    if (iVar3 == 0) {

      local_44 = *(undefined4 *)(param_1 + 0x130);

      uVar2 = *(undefined4 *)(param_1 + 0x128);

      local_48 = &PTR_LAB_00797910;

      FUN_00425f10(param_1 + 0x134);

      local_4c = *(float *)(param_1 + 0x10);

      *(undefined4 *)(param_1 + 0x1d8) = param_2;

      *(undefined4 *)(param_1 + 0x1f8) = 1;

      if ((*(uint *)(param_1 + 0x20) < 2) &&

         (fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc), fVar1 + fVar1 < local_4c)) {

        local_4c = *(float *)(*(int *)(param_1 + 0x34) + 0xc) * _DAT_007938b8;

      }

      fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc);

      if (fVar1 + fVar1 < local_4c) {

        local_4c = local_4c * _DAT_007938b8;

      }

      local_4c = -local_4c;

      local_54 = 0;

      local_50 = 0;

      FUN_0050a7e0(&local_54);

      iVar3 = FUN_0050c1c0(1);

      *(undefined4 *)(param_1 + 0x1f8) = 0;

      FUN_0050b380(&local_4c,uVar2);

      return iVar3 != 1;

    }

  }

  return true;

}





// --- FUN_0050bbd0 at 0x0050BBD0 (size: 68) ---


void __fastcall FUN_0050bbd0(int param_1)



{

  undefined4 uVar1;

  

  uVar1 = *(undefined4 *)(param_1 + 0x160);

  *(undefined4 *)(param_1 + 0x110) = *(undefined4 *)(param_1 + 0x168);

  FUN_00425f10(param_1 + 0x16c);

  *(undefined4 *)(param_1 + 0x108) = uVar1;

  *(undefined4 *)(param_1 + 0x234) = 0;

  FUN_0050d2e0(0);

  return;

}





// --- FUN_0050bc20 at 0x0050BC20 (size: 122) ---


undefined * FUN_0050bc20(void)



{

  int iVar1;

  

  if ((DAT_00844b80 & 1) == 0) {

    DAT_00844b80 = DAT_00844b80 | 1;

    iVar1 = 10;

    do {

      FUN_0050b450();

      iVar1 = iVar1 + -1;

    } while (iVar1 != 0);

    _atexit((_func_4879 *)&LAB_00767920);

  }

  if (DAT_00842c6c < 10) {

    iVar1 = DAT_00842c6c * 0x314;

    FUN_0050a8a0();

    DAT_00842c6c = DAT_00842c6c + 1;

    return &DAT_00842cb8 + iVar1;

  }

  return (undefined *)0x0;

}





// --- FUN_0050bca0 at 0x0050BCA0 (size: 51) ---


int __fastcall FUN_0050bca0(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0x128) == 0) {

    return 2;

  }

  iVar1 = FUN_0050a940(*(int *)(param_1 + 0x128),3);

  if (iVar1 == 1) {

    iVar1 = FUN_0050b920(*(undefined4 *)(param_1 + 0x128));

  }

  return iVar1;

}





// --- FUN_0050bce0 at 0x0050BCE0 (size: 133) ---


int __thiscall FUN_0050bce0(int param_1,int param_2,int param_3)



{

  undefined4 uVar1;

  int iVar2;

  

  iVar2 = *(int *)(param_1 + 0x128);

  if (iVar2 == 0) {

    return 2;

  }

  if (param_2 == 1) {

    *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)(param_1 + 0x130);

    FUN_00425f10(param_1 + 0x134);

    *(int *)(param_1 + 0xbc) = iVar2;

    FUN_0050d210();

  }

  else if (((2 < param_2) && (param_2 < 5)) && (param_3 != 0)) {

    uVar1 = FUN_0050bca0();

    iVar2 = FUN_0050bce0(uVar1,0);

    return iVar2;

  }

  return param_2;

}





// --- FUN_0050bd70 at 0x0050BD70 (size: 304) ---


bool __thiscall FUN_0050bd70(int param_1,float param_2,float param_3)



{

  int iVar1;

  undefined4 local_c;

  undefined4 local_8;

  float local_4;

  

  *(undefined4 *)(param_1 + 0x268) = 0;

  *(undefined4 *)(param_1 + 0x178) = 1;

  *(float *)(param_1 + 0x1e0) = param_2;

  *(undefined4 *)(param_1 + 0x1dc) = 0x3f800000;

  if (*(int *)(param_1 + 0x114) == 0) {

    *(undefined4 *)(param_1 + 0x254) = 0;

    local_4 = -param_2;

    *(undefined4 *)(param_1 + 0x168) = *(undefined4 *)(param_1 + 0x168);

    *(float *)(param_1 + 0x170) = local_4 + *(float *)(param_1 + 0x170);

    local_c = 0;

    local_8 = 0;

    *(undefined4 *)(param_1 + 0x16c) = *(undefined4 *)(param_1 + 0x16c);

    FUN_0050d2e0(&local_c);

  }

  iVar1 = FUN_0050c1c0(5);

  *(undefined4 *)(param_1 + 0x178) = 0;

  if (((iVar1 == 1) && (*(int *)(param_1 + 0x288) != 0)) && (param_3 <= *(float *)(param_1 + 0x294))

     ) {

    if ((((*(uint *)(param_1 + 4) & 0x200) != 0) && (*(int *)(param_1 + 0x114) == 0)) &&

       (iVar1 = FUN_0050bac0(param_3), iVar1 == 0)) {

      return false;

    }

    *(undefined4 *)(param_1 + 0x17c) = *(undefined4 *)(param_1 + 0x174);

    *(undefined4 *)(param_1 + 0x174) = 1;

    iVar1 = FUN_0050c1c0(1);

    *(undefined4 *)(param_1 + 0x174) = *(undefined4 *)(param_1 + 0x17c);

    return iVar1 == 1;

  }

  return false;

}





// --- FUN_0050bea0 at 0x0050BEA0 (size: 565) ---


bool __thiscall FUN_0050bea0(int param_1,int *param_2,undefined4 param_3,float param_4)



{

  float *pfVar1;

  float *pfVar2;

  int iVar3;

  undefined4 uVar4;

  int *unaff_retaddr;

  undefined4 uVar5;

  float local_54;

  float local_50;

  float local_4c [19];

  

  if (((*(uint *)(param_1 + 4) & 2) == 0) || ((*(uint *)(param_1 + 4) & 0x200) == 0)) {

    *(undefined4 *)(param_1 + 500) = 0;

    uVar5 = *(undefined4 *)(param_1 + 0x180);

    *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0x188);

    FUN_00425f10(param_1 + 0x18c);

    *(undefined4 *)(param_1 + 0x128) = uVar5;

    *(undefined4 *)(param_1 + 0x254) = 0;

    FUN_0050d2e0(0);

    *(undefined4 *)(param_1 + 0x288) = 0;

    *(undefined4 *)(param_1 + 0x2a4) = 0;

    *(undefined4 *)(param_1 + 0x254) = 1;

    *param_2 = 1;

    return true;

  }

  if ((*(int *)(param_1 + 0x288) != 0) && (*(float *)(param_1 + 0x294) < param_4)) {

    *(undefined4 *)(param_1 + 500) = 0;

    FUN_0050bbd0();

    iVar3 = FUN_0050b1a0(param_1 + 0x28c);

    *param_2 = iVar3;

    *(undefined4 *)(param_1 + 0x288) = 0;

    *(undefined4 *)(param_1 + 0x2a4) = 0;

    return false;

  }

  if (*(int *)(param_1 + 500) != 0) {

    FUN_0050bbd0();

    *(undefined4 *)(param_1 + 0x288) = 0;

    *(undefined4 *)(param_1 + 0x2a4) = 0;

    iVar3 = FUN_0050d750(param_1 + 0x270);

    *param_2 = iVar3;

    return iVar3 == 2;

  }

  if (*(int *)(param_1 + 0x288) == 0) {

    pfVar1 = *(float **)(param_1 + 0x58);

    pfVar2 = *(float **)(param_1 + 0x34);

    local_4c[0] = pfVar1[2] - pfVar2[2];

    local_50 = pfVar1[1] - pfVar2[1];

    local_54 = *pfVar1 - *pfVar2;

    FUN_0050a7e0(&local_54);

    FUN_0050bd70(param_2,param_3);

    *(undefined4 *)(param_1 + 0x288) = 0;

    *(undefined4 *)(param_1 + 0x2a4) = 0;

    FUN_0050bbd0();

    if (*(int *)(param_1 + 500) == 0) {

      *(undefined4 *)(param_1 + 500) = 0;

      *unaff_retaddr = 2;

      *(undefined4 *)(param_1 + 0x254) = 1;

      return true;

    }

    *(undefined4 *)(param_1 + 0x288) = 0;

    *(undefined4 *)(param_1 + 0x2a4) = 0;

    uVar5 = *(undefined4 *)(param_1 + 0x250);

    uVar4 = FUN_0050b3c0(local_4c);

    FUN_0050d4a0(uVar4,uVar5);

    FUN_0050a7b0(*(undefined4 *)(param_1 + 0x44));

    iVar3 = FUN_0050d750(param_1 + 0x270);

    *unaff_retaddr = iVar3;

    return iVar3 == 2;

  }

  *(undefined4 *)(param_1 + 500) = 0;

  FUN_0050bbd0();

  *(undefined4 *)(param_1 + 0x254) = 1;

  *(undefined4 *)(param_1 + 0x288) = 0;

  *(undefined4 *)(param_1 + 0x2a4) = 0;

  *param_2 = 1;

  return true;

}





// --- FUN_0050c0e0 at 0x0050C0E0 (size: 214) ---


undefined4 __thiscall FUN_0050c0e0(int param_1,undefined4 *param_2)



{

  float fVar1;

  int iVar2;

  float10 fVar3;

  undefined4 local_4;

  

  *(undefined4 *)(param_1 + 0x288) = 0;

  *(undefined4 *)(param_1 + 0x2a4) = 0;

  *(undefined4 *)(param_1 + 0x114) = 1;

  *(undefined4 *)(param_1 + 0x118) = *param_2;

  *(undefined4 *)(param_1 + 0x11c) = param_2[1];

  fVar1 = DAT_007c7610;

  *(undefined4 *)(param_1 + 0x120) = param_2[2];

  local_4 = 0x3d23d70a;

  param_2 = (undefined4 *)fVar1;

  if ((*(byte *)(param_1 + 4) & 2) != 0) {

    fVar3 = (float10)FUN_0050d9f0();

    param_2 = (undefined4 *)(float)fVar3;

    local_4 = *(undefined4 *)(param_1 + 0xc);

  }

  *(undefined4 **)(param_1 + 0x1d8) = param_2;

  *(undefined4 *)(param_1 + 0x180) = *(undefined4 *)(param_1 + 0x128);

  *(undefined4 *)(param_1 + 0x188) = *(undefined4 *)(param_1 + 0x130);

  FUN_00425f10(param_1 + 0x134);

  iVar2 = FUN_0050bd70(local_4,param_2);

  *(undefined4 *)(param_1 + 0x114) = 0;

  *(undefined4 *)(param_1 + 500) = 0;

  if (iVar2 == 0) {

    FUN_0050bbd0();

    return 0;

  }

  return 1;

}





// --- FUN_0050c1c0 at 0x0050C1C0 (size: 847) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



int __thiscall FUN_0050c1c0(int param_1,int param_2)



{

  float fVar1;

  float fVar2;

  bool bVar3;

  float fVar4;

  int iVar5;

  int iVar6;

  float10 fVar7;

  int local_14;

  float local_10;

  float local_c;

  int local_8;

  float fStack_4;

  

  if (*(int *)(param_1 + 0x128) == 0) {

    return 1;

  }

  iVar6 = 0;

  local_8 = 0;

  if (0 < param_2) {

    do {

      local_14 = FUN_0050a940(*(undefined4 *)(param_1 + 0x128),param_2);

      switch(local_14) {

      case 1:

        local_14 = FUN_0050b920(*(undefined4 *)(param_1 + 0x128));

        if (local_14 != 1) {

          *(undefined4 *)(param_1 + 0x268) = 0;

        }

        if (local_14 == 2) {

          return 2;

        }

        break;

      case 2:

        *(undefined4 *)(param_1 + 0x268) = 0;

        return local_14;

      case 4:

        *(undefined4 *)(param_1 + 0x288) = 0;

        *(undefined4 *)(param_1 + 0x2a4) = 0;

      case 3:

        *(undefined4 *)(param_1 + 0x268) = 0;

      }

      iVar6 = local_14;

      if (local_14 == 1) {

        if (*(int *)(param_1 + 0x124) != 0) {

          bVar3 = false;

          *(undefined4 *)(param_1 + 0x124) = 0;

          if ((*(int *)(param_1 + 0x288) != 0) && (iVar6 = FUN_0050bac0(DAT_007c7610), iVar6 != 0))

          {

            *(undefined4 *)(param_1 + 0x17c) = *(undefined4 *)(param_1 + 0x174);

            *(undefined4 *)(param_1 + 0x174) = 1;

            iVar6 = FUN_0050c1c0(param_2);

            *(undefined4 *)(param_1 + 0x174) = *(undefined4 *)(param_1 + 0x17c);

            if (iVar6 == 1) goto LAB_0050c491;

          }

          bVar3 = true;

LAB_0050c491:

          *(undefined4 *)(param_1 + 500) = 0;

          if (!bVar3) {

            return 1;

          }

          FUN_0050bbd0();

          *(undefined4 *)(param_1 + 0x288) = 0;

          *(undefined4 *)(param_1 + 0x2a4) = 0;

          if (*(int *)(param_1 + 0x270) == 0) {

            FUN_0050aad0(param_1 + 0x118);

            return 2;

          }

          FUN_0050dab0();

          *(int *)(param_1 + 0x270) = 0;

          return 2;

        }

        if (((*(int *)(param_1 + 0x268) == 0) || (*(int *)(param_1 + 0x178) != 0)) ||

           (*(int *)(param_1 + 0x114) != 0)) {

          if (*(int *)(param_1 + 0x288) != 0) {

            return 1;

          }

          if ((*(uint *)(param_1 + 4) & 1) == 0) {

            return 1;

          }

          if (*(int *)(param_1 + 0x178) != 0) {

            return 1;

          }

          if (*(int *)(param_1 + 0x128) == 0) {

            return 1;

          }

          if (*(int *)(param_1 + 0x18) == 0) {

            return 1;

          }

          local_10 = 0.04;

          local_c = DAT_007c7610;

          if ((*(uint *)(param_1 + 4) & 2) != 0) {

            fVar7 = (float10)FUN_0050d9f0();

            local_c = (float)fVar7;

            local_10 = *(float *)(param_1 + 0x10);

          }

          *(float *)(param_1 + 0x1d8) = local_c;

          FUN_0050b350();

          fVar4 = local_c;

          if ((*(uint *)(param_1 + 0x20) < 2) &&

             (fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc), fVar1 + fVar1 < local_10)) {

            local_10 = *(float *)(*(int *)(param_1 + 0x34) + 0xc) * _DAT_007938b8;

          }

          fVar2 = local_10;

          fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc);

          if (local_10 <= fVar1 + fVar1) {

            iVar6 = FUN_0050bd70(local_10,local_c);

          }

          else {

            fVar2 = local_10 * _DAT_007938b8;

            fStack_4 = fVar2;

            iVar6 = FUN_0050bd70(fVar2,local_c);

            if (iVar6 != 0) goto LAB_0050c4fa;

            iVar6 = FUN_0050bd70(fVar2,fVar4);

          }

          if (iVar6 != 0) {

LAB_0050c4fa:

            *(undefined4 *)(param_1 + 500) = 0;

            return 1;

          }

          iVar5 = FUN_0050bea0(&local_14,fVar2,fVar4);

          iVar6 = local_14;

          if (iVar5 != 0) {

            return local_14;

          }

        }

        else {

          *(undefined4 *)(param_1 + 0x268) = 0;

          if (*(int *)(param_1 + 600) == 0) {

            iVar6 = FUN_00538180(param_1 + 0x20,param_1 + 0x270,param_1 + 0x25c,

                                 *(undefined4 *)(param_1 + 0x58));

          }

          else {

            iVar5 = FUN_0050c0e0(param_1 + 0x25c);

            if (iVar5 == 0) {

              iVar6 = FUN_0050ce80(param_1,param_1 + 0x270);

            }

          }

        }

      }

      local_8 = local_8 + 1;

    } while (local_8 < param_2);

  }

  return iVar6;

}





// --- FUN_0050c520 at 0x0050C520 (size: 927) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0050c520(int param_1)



{

  float *pfVar1;

  bool bVar2;

  float fVar3;

  undefined4 uVar4;

  int iVar5;

  float *pfVar6;

  uint uVar7;

  double dVar8;

  float local_a0;

  float local_9c;

  float local_98;

  undefined4 local_94;

  float local_90;

  uint local_8c;

  float local_88;

  uint local_84;

  float local_80;

  uint local_7c;

  float local_78;

  float local_74;

  float local_70;

  float local_64;

  undefined4 local_60;

  undefined4 local_5c;

  undefined4 local_58;

  undefined4 local_54;

  undefined4 local_2c;

  undefined4 local_28;

  undefined4 local_24;

  undefined1 local_20 [28];

  

  uVar4 = *(undefined4 *)(param_1 + 0xbc);

  *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0xc4);

  FUN_00425f10();

  *(undefined4 *)(param_1 + 0x128) = uVar4;

  *(undefined4 *)(param_1 + 0x254) = 0;

  FUN_0050d2e0();

  *(undefined4 *)(param_1 + 0x2a8) = 0;

  *(undefined4 *)(param_1 + 0x288) = 0;

  *(undefined4 *)(param_1 + 0x2a4) = 0;

  uVar4 = FUN_0050c1c0();

  iVar5 = FUN_0050b890(uVar4,&local_94);

  if (iVar5 == 1) {

    return 1;

  }

  if (*(int *)(param_1 + 0x26c) != 0) {

    local_a0 = *(float *)(*(int *)(param_1 + 0x24) + 0xc);

    bVar2 = false;

    local_9c = 4.0;

    if (_DAT_007c7624 <= local_a0) {

      if (local_a0 < _DAT_007c7620) {

        local_a0 = 0.48;

      }

    }

    else {

      bVar2 = true;

      local_9c = 2.0;

    }

    fVar3 = _DAT_007c6f14 / (_DAT_007c7614 * local_a0);

    if (bVar2) {

      fVar3 = fVar3 * _DAT_007938b8;

    }

    if (fVar3 < _DAT_007938b0 == (fVar3 == _DAT_007938b0)) {

      dVar8 = ceil((double)fVar3);

      local_88 = local_9c / (float)dVar8;

      local_84 = FUN_005df4c4();

      local_98 = 0.0;

      local_9c = 0.0;

      local_8c = 0;

      local_80 = (local_88 / local_a0) * _DAT_007c761c;

      if (local_84 != 0) {

        do {

          local_98 = local_98 + local_88;

          local_9c = local_80 + local_9c;

          ceil((double)local_9c);

          iVar5 = FUN_005df4c4();

          uVar7 = iVar5 * 2;

          local_90 = (float)(int)uVar7;

          if ((int)uVar7 < 0) {

            local_90 = local_90 + _DAT_0079920c;

          }

          local_90 = _DAT_0079cc60 / local_90;

          local_60 = 0x3f800000;

          local_5c = 0;

          local_58 = 0;

          local_54 = 0;

          local_2c = 0;

          local_28 = 0;

          local_24 = 0;

          local_7c = uVar7;

          FUN_00535b30();

          local_a0 = 0.0;

          if (uVar7 != 0) {

            pfVar1 = (float *)(param_1 + 0x108);

            do {

              local_94 = *(undefined4 *)(param_1 + 0xbc);

              *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0xc4);

              FUN_00425f10();

              *(undefined4 *)(param_1 + 0x128) = local_94;

              *(undefined4 *)(param_1 + 0x254) = 0;

              FUN_0050d2e0();

              FUN_00536b80();

              pfVar6 = (float *)FUN_00536460();

              local_78 = local_98 * *pfVar6;

              local_74 = local_98 * pfVar6[1];

              local_70 = local_98 * pfVar6[2];

              local_64 = local_70;

              pfVar6 = (float *)FUN_0050ae40(local_20,&local_78);

              *pfVar1 = *pfVar6;

              *(float *)(param_1 + 0x10c) = pfVar6[1];

              *(float *)(param_1 + 0x110) = pfVar6[2];

              fVar3 = *(float *)(param_1 + 0x110) * *(float *)(param_1 + 0x110) +

                      *(float *)(param_1 + 0x10c) * *(float *)(param_1 + 0x10c) + *pfVar1 * *pfVar1;

              if (_DAT_007c7618 * _DAT_007c7618 < fVar3 != (_DAT_007c7618 * _DAT_007c7618 == fVar3))

              {

                *(undefined4 *)(param_1 + 0x254) = 0;

                *(float *)(param_1 + 0x168) = *(float *)(param_1 + 0x168) + *pfVar1;

                *(float *)(param_1 + 0x16c) =

                     *(float *)(param_1 + 0x10c) + *(float *)(param_1 + 0x16c);

                *(float *)(param_1 + 0x170) =

                     *(float *)(param_1 + 0x110) + *(float *)(param_1 + 0x170);

                FUN_0050d2e0();

                *(undefined4 *)(param_1 + 0x2a8) = 0;

                *(undefined4 *)(param_1 + 0x288) = 0;

                *(undefined4 *)(param_1 + 0x2a4) = 0;

                uVar4 = FUN_0050c1c0();

                iVar5 = FUN_0050b890(uVar4,&local_94);

                if (iVar5 == 1) {

                  return 1;

                }

              }

              local_a0 = (float)((int)local_a0 + 1);

            } while ((uint)local_a0 < local_7c);

          }

          local_8c = local_8c + 1;

        } while (local_8c < local_84);

        return 0;

      }

    }

  }

  return 0;

}





// --- FUN_0050c8c0 at 0x0050C8C0 (size: 881) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0050c8c0(int param_1)



{

  float *pfVar1;

  int iVar2;

  float fVar3;

  float fVar4;

  float *pfVar5;

  undefined4 uVar6;

  uint uVar7;

  uint uVar8;

  uint local_48;

  int local_44;

  uint local_40;

  float local_3c;

  float local_38;

  float local_34;

  float local_30;

  float local_2c;

  float local_28;

  float local_24;

  float local_20;

  float local_1c;

  float local_10;

  undefined1 local_c [12];

  

  if (*(int *)(param_1 + 0xb0) == 0) {

    return 0;

  }

  local_44 = 1;

  local_48 = 0;

  FUN_0050ab80(&local_3c,&local_24,&local_48);

  if ((*(byte *)(param_1 + 4) & 0x10) != 0) {

    iVar2 = *(int *)(param_1 + 0xb8);

    FUN_00535dc0(*(undefined4 *)(iVar2 + 8),*(undefined4 *)(iVar2 + 0xc),

                 *(undefined4 *)(iVar2 + 0x10),*(undefined4 *)(iVar2 + 0x14));

  }

  uVar6 = *(undefined4 *)(param_1 + 0xbc);

  *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0xc4);

  FUN_00425f10(param_1 + 200);

  *(undefined4 *)(param_1 + 0x128) = uVar6;

  uVar8 = 0;

  *(undefined4 *)(param_1 + 0x254) = 0;

  FUN_0050d2e0(0);

  if (local_48 == 0) {

    if ((*(byte *)(param_1 + 4) & 0x10) == 0) {

      iVar2 = *(int *)(param_1 + 0xb8);

      FUN_00535dc0(*(undefined4 *)(iVar2 + 8),*(undefined4 *)(iVar2 + 0xc),

                   *(undefined4 *)(iVar2 + 0x10),*(undefined4 *)(iVar2 + 0x14));

    }

    FUN_0050b380(param_1 + 0xc0,*(undefined4 *)(param_1 + 0xbc));

    *(undefined4 *)(param_1 + 0x254) = 1;

    *(undefined4 *)(param_1 + 0x1d0) = 0;

    FUN_0052c570(param_1 + 0x2f4,0,param_1 + 0x20);

    return 1;

  }

  if (local_48 != 0) {

    pfVar1 = (float *)(param_1 + 0x108);

    while( true ) {

      if ((((*(byte *)(param_1 + 4) & 4) != 0) && (uVar7 = local_48 - 1, uVar8 == uVar7)) &&

         (fVar3 = SQRT(local_3c * local_3c + local_38 * local_38 + local_34 * local_34),

         _DAT_007c7618 < fVar3)) {

        fVar4 = (float)(int)uVar7;

        if ((int)uVar7 < 0) {

          fVar4 = fVar4 + _DAT_0079920c;

        }

        fVar3 = (fVar3 - fVar4 * *(float *)(*(int *)(param_1 + 0x24) + 0xc)) / fVar3;

        local_30 = local_3c * fVar3;

        local_2c = local_38 * fVar3;

        local_28 = local_34 * fVar3;

        local_40 = uVar7;

        local_24 = local_30;

        local_20 = local_2c;

        local_1c = local_28;

        local_10 = local_28;

      }

      pfVar5 = (float *)FUN_0050ae40(local_c,&local_24);

      *pfVar1 = *pfVar5;

      *(float *)(param_1 + 0x10c) = pfVar5[1];

      *(float *)(param_1 + 0x110) = pfVar5[2];

      if (((*(uint *)(param_1 + 4) & 4) == 0) &&

         (*(float *)(param_1 + 0x110) * *(float *)(param_1 + 0x110) +

          *(float *)(param_1 + 0x10c) * *(float *)(param_1 + 0x10c) + *pfVar1 * *pfVar1 <

          _DAT_007c7618 * _DAT_007c7618)) break;

      if ((*(uint *)(param_1 + 4) & 0x10) == 0) {

        local_40 = uVar8 + 1;

        fVar3 = (float)(int)local_40;

        if ((int)local_40 < 0) {

          fVar3 = fVar3 + _DAT_0079920c;

        }

        fVar4 = (float)(int)local_48;

        if ((int)local_48 < 0) {

          fVar4 = fVar4 + _DAT_0079920c;

        }

        FUN_005360d0(*(int *)(param_1 + 0xb4) + 8,*(int *)(param_1 + 0xb8) + 8,fVar3 / fVar4);

      }

      *(undefined4 *)(param_1 + 0x2a8) = 0;

      *(undefined4 *)(param_1 + 0x288) = 0;

      *(undefined4 *)(param_1 + 0x2a4) = 0;

      if (*(int *)(param_1 + 0x174) == 0) {

        *(undefined4 *)(param_1 + 0x254) = 0;

        *(float *)(param_1 + 0x168) = *pfVar1 + *(float *)(param_1 + 0x168);

        *(float *)(param_1 + 0x16c) = *(float *)(param_1 + 0x10c) + *(float *)(param_1 + 0x16c);

        *(float *)(param_1 + 0x170) = *(float *)(param_1 + 0x110) + *(float *)(param_1 + 0x170);

        FUN_0050d2e0(pfVar1);

        uVar6 = FUN_0050c1c0(3);

        local_44 = FUN_0050b540(uVar6,&local_40);

        if (*(int *)(param_1 + 0x2f0) != 0) goto LAB_0050cb59;

      }

      else {

        uVar6 = FUN_0050c1c0(3);

        local_44 = FUN_0050b890(uVar6,&local_40);

        if (local_44 == 1) {

          return 1;

        }

        if (*(int *)(param_1 + 0x26c) == 0) {

          return 0;

        }

        FUN_0050a7e0(pfVar1);

      }

      if (((*(int *)(param_1 + 0x2b8) != 0) && ((*(byte *)(param_1 + 4) & 8) != 0)) ||

         (uVar8 = uVar8 + 1, local_48 <= uVar8)) goto LAB_0050cb59;

    }

    if (uVar8 == 0) {

      return 0;

    }

LAB_0050cb59:

    if (local_44 != 1) {

      return 0;

    }

  }

  return 1;

}





// --- FUN_0050cc40 at 0x0050CC40 (size: 413) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



bool __fastcall FUN_0050cc40(int param_1)



{

  float fVar1;

  undefined4 uVar2;

  int iVar3;

  undefined4 uVar4;

  float local_8;

  

  uVar2 = *(undefined4 *)(param_1 + 0xbc);

  *(undefined4 *)(param_1 + 0x130) = *(undefined4 *)(param_1 + 0xc4);

  FUN_00425f10(param_1 + 200);

  *(undefined4 *)(param_1 + 0x128) = uVar2;

  *(undefined4 *)(param_1 + 0x254) = 0;

  FUN_0050d2e0(0);

  *(undefined4 *)(param_1 + 0x174) = 2;

  if (*(int *)(param_1 + 0x128) == 0) {

    iVar3 = 2;

  }

  else {

    iVar3 = FUN_0050a940(*(int *)(param_1 + 0x128),3);

    if (iVar3 == 1) {

      iVar3 = FUN_0050b920(*(undefined4 *)(param_1 + 0x128));

    }

  }

  iVar3 = FUN_0050bce0(iVar3,1);

  if (iVar3 != 1) {

    return false;

  }

  *(undefined4 *)(param_1 + 0x174) = 1;

  iVar3 = FUN_0050c520();

  uVar2 = DAT_007c7610;

  if (iVar3 == 0) {

    return false;

  }

  if (*(int *)(param_1 + 0x18) == 0) goto LAB_0050cdc4;

  local_8 = *(float *)(param_1 + 0x10);

  *(undefined4 *)(param_1 + 0x1d8) = DAT_007c7610;

  FUN_0050b350();

  *(undefined4 *)(param_1 + 0x17c) = *(undefined4 *)(param_1 + 0x174);

  *(undefined4 *)(param_1 + 0x174) = 0;

  if ((*(uint *)(param_1 + 0x20) < 2) &&

     (fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc), fVar1 + fVar1 < local_8)) {

    local_8 = *(float *)(*(int *)(param_1 + 0x34) + 0xc) * _DAT_007938b8;

  }

  fVar1 = *(float *)(*(int *)(param_1 + 0x34) + 0xc);

  uVar4 = DAT_007c7610;

  if (local_8 <= fVar1 + fVar1) {

LAB_0050cd94:

    iVar3 = FUN_0050bd70(local_8,uVar4);

    if (iVar3 == 0) {

      FUN_0050bbd0();

      *(undefined4 *)(param_1 + 0x288) = 0;

      *(undefined4 *)(param_1 + 0x2a4) = 0;

    }

  }

  else {

    local_8 = local_8 * _DAT_007938b8;

    iVar3 = FUN_0050bd70(local_8,DAT_007c7610);

    uVar4 = uVar2;

    if (iVar3 == 0) goto LAB_0050cd94;

  }

  *(undefined4 *)(param_1 + 0x174) = *(undefined4 *)(param_1 + 0x17c);

  *(undefined4 *)(param_1 + 500) = 0;

LAB_0050cdc4:

  iVar3 = FUN_0050bce0(1,1);

  return iVar3 == 1;

}





// --- FUN_0050cde0 at 0x0050CDE0 (size: 20) ---


void __fastcall FUN_0050cde0(int param_1)



{

  if (*(int *)(param_1 + 0x174) == 0) {

    FUN_0050c8c0();

    return;

  }

  FUN_0050cc40();

  return;

}





// --- FUN_0050ce00 at 0x0050CE00 (size: 123) ---


void __fastcall FUN_0050ce00(undefined4 *param_1)



{

  *param_1 = 0;

  param_1[0x24] = 0;

  param_1[0x25] = 0;

  param_1[0x27] = 0;

  param_1[0x42] = 0;

  param_1[0x55] = 0;

  param_1[0x56] = 0;

  param_1[0x3d] = 0;

  param_1[0x41] = 0;

  param_1[0x6c] = 0;

  param_1[0x6d] = 0;

  param_1[0x6b] = 0;

  param_1[0x58] = 0;

  param_1[0x6e] = 0;

  param_1[0x75] = 0;

  param_1[0x76] = 0;

  param_1[0x8d] = 0;

  param_1[0x8e] = 0;

  param_1[0x92] = 0;

  param_1[0x93] = 1;

  return;

}





// --- FUN_0050ce80 at 0x0050CE80 (size: 46) ---


void __thiscall FUN_0050ce80(int param_1,undefined4 param_2,int param_3)



{

  *(undefined4 *)(param_3 + 0x18) = 0;

  *(undefined4 *)(param_3 + 0x34) = 0;

  *(undefined4 *)(param_1 + 0xf4) = 0;

  FUN_00538180(param_1,param_3,param_1 + 0xf8,*(undefined4 *)(param_1 + 0x38));

  return;

}





// --- FUN_0050ceb0 at 0x0050CEB0 (size: 52) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0050ceb0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x1d4) == 0) {

    return 1;

  }

  *(float *)(param_1 + 0x1d0) = *(float *)(param_1 + 0x1d0) * _DAT_007938b8;

  uVar1 = FUN_00539ba0(param_1 + 0x1c4,param_1 + 0x1dc);

  return uVar1;

}





// --- FUN_0050cef0 at 0x0050CEF0 (size: 82) ---


void __thiscall FUN_0050cef0(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;

  

  fVar1 = *(float *)(param_1 + 0x34);

  fVar2 = param_3[1];

  fVar3 = *(float *)(param_1 + 0x30);

  fVar4 = *param_3;

  fVar5 = *(float *)(param_1 + 0x38);

  fVar6 = param_3[2];

  fVar7 = *(float *)(param_1 + 0x28);

  fVar8 = param_3[1];

  fVar9 = *(float *)(param_1 + 0x24);

  fVar10 = *param_3;

  fVar11 = *(float *)(param_1 + 0x2c);

  fVar12 = param_3[2];

  *param_2 = *(float *)(param_1 + 0x20) * param_3[2] +

             *(float *)(param_1 + 0x18) * *param_3 + *(float *)(param_1 + 0x1c) * param_3[1];

  param_2[1] = fVar11 * fVar12 + fVar9 * fVar10 + fVar7 * fVar8;

  param_2[2] = fVar5 * fVar6 + fVar3 * fVar4 + fVar1 * fVar2;

  return;

}





// --- FUN_0050cf50 at 0x0050CF50 (size: 360) ---


int __fastcall FUN_0050cf50(int param_1)



{

  undefined4 *puVar1;

  undefined4 uVar2;

  undefined4 *puVar3;

  

  puVar3 = (undefined4 *)0x0;

  *(undefined4 *)(param_1 + 0x40) = 0;

  *(undefined ***)(param_1 + 0x3c) = &PTR_LAB_00797910;

  *(undefined4 *)(param_1 + 0x44) = 0x3f800000;

  *(undefined4 *)(param_1 + 0x48) = 0;

  *(undefined4 *)(param_1 + 0x4c) = 0;

  *(undefined4 *)(param_1 + 0x50) = 0;

  *(undefined4 *)(param_1 + 0x78) = 0;

  *(undefined4 *)(param_1 + 0x7c) = 0;

  *(undefined4 *)(param_1 + 0x80) = 0;

  FUN_00535b30();

  *(undefined ***)(param_1 + 0xa0) = &PTR_LAB_00797910;

  *(undefined4 *)(param_1 + 0xa4) = 0;

  *(undefined4 *)(param_1 + 0xa8) = 0x3f800000;

  *(undefined4 *)(param_1 + 0xac) = 0;

  *(undefined4 *)(param_1 + 0xb0) = 0;

  *(undefined4 *)(param_1 + 0xb4) = 0;

  *(undefined4 *)(param_1 + 0xdc) = 0;

  *(undefined4 *)(param_1 + 0xe0) = 0;

  *(undefined4 *)(param_1 + 0xe4) = 0;

  FUN_00535b30();

  *(undefined ***)(param_1 + 0x10c) = &PTR_LAB_00797910;

  *(undefined4 *)(param_1 + 0x110) = 0;

  *(undefined4 *)(param_1 + 0x114) = 0x3f800000;

  *(undefined4 *)(param_1 + 0x118) = 0;

  *(undefined4 *)(param_1 + 0x11c) = 0;

  *(undefined4 *)(param_1 + 0x120) = 0;

  *(undefined4 *)(param_1 + 0x148) = 0;

  *(undefined4 *)(param_1 + 0x14c) = 0;

  *(undefined4 *)(param_1 + 0x150) = 0;

  FUN_00535b30();

  *(undefined ***)(param_1 + 0x164) = &PTR_LAB_00797910;

  *(undefined4 *)(param_1 + 0x168) = 0;

  *(undefined4 *)(param_1 + 0x16c) = 0x3f800000;

  *(undefined4 *)(param_1 + 0x170) = 0;

  *(undefined4 *)(param_1 + 0x174) = 0;

  *(undefined4 *)(param_1 + 0x178) = 0;

  *(undefined4 *)(param_1 + 0x1a0) = 0;

  *(undefined4 *)(param_1 + 0x1a4) = 0;

  *(undefined4 *)(param_1 + 0x1a8) = 0;

  FUN_00535b30();

  *(undefined ***)(param_1 + 0x1e8) = &PTR_LAB_00797910;

  *(undefined4 *)(param_1 + 0x1ec) = 0;

  *(undefined4 *)(param_1 + 0x1f0) = 0x3f800000;

  *(undefined4 *)(param_1 + 500) = 0;

  *(undefined4 *)(param_1 + 0x1f8) = 0;

  *(undefined4 *)(param_1 + 0x1fc) = 0;

  *(undefined4 *)(param_1 + 0x224) = 0;

  *(undefined4 *)(param_1 + 0x228) = 0;

  *(undefined4 *)(param_1 + 0x22c) = 0;

  FUN_00535b30();

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(0x24);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    *puVar1 = 2;

    puVar1 = puVar1 + 1;

  }

  *(undefined4 **)(param_1 + 4) = puVar1;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(0x24);

  if (puVar1 == (undefined4 *)0x0) {

    puVar1 = (undefined4 *)0x0;

  }

  else {

    *puVar1 = 2;

    puVar1 = puVar1 + 1;

  }

  *(undefined4 **)(param_1 + 0x14) = puVar1;

  puVar1 = (undefined4 *)thunk_FUN_005df0f5(0x24);

  if (puVar1 != (undefined4 *)0x0) {

    *puVar1 = 2;

    puVar3 = puVar1 + 1;

  }

  *(undefined4 **)(param_1 + 0x24) = puVar3;

  uVar2 = thunk_FUN_005df0f5(0x18);

  *(undefined4 *)(param_1 + 0x34) = uVar2;

  uVar2 = thunk_FUN_005df0f5(0x18);

  *(undefined4 *)(param_1 + 0x38) = uVar2;

  FUN_0050ce00();

  return param_1;

}





// --- FUN_0050d0c0 at 0x0050D0C0 (size: 115) ---


void __fastcall FUN_0050d0c0(int param_1)



{

  if (*(int *)(param_1 + 4) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 4) + -4));

  }

  if (*(int *)(param_1 + 0x14) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0x14) + -4));

  }

  if (*(int *)(param_1 + 0x24) != 0) {

    operator_delete__((void *)(*(int *)(param_1 + 0x24) + -4));

  }

  operator_delete__(*(void **)(param_1 + 0x34));

  operator_delete__(*(void **)(param_1 + 0x38));

  *(undefined ***)(param_1 + 0x1e8) = &PTR_FUN_0079385c;

  *(undefined ***)(param_1 + 0x164) = &PTR_FUN_0079385c;

  *(undefined ***)(param_1 + 0x10c) = &PTR_FUN_0079385c;

  *(undefined ***)(param_1 + 0xa0) = &PTR_FUN_0079385c;

  *(undefined ***)(param_1 + 0x3c) = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0050d140 at 0x0050D140 (size: 203) ---


void __thiscall FUN_0050d140(uint *param_1,uint param_2,int param_3,float param_4)



{

  float fVar1;

  float fVar2;

  uint *puVar3;

  float *pfVar4;

  float *pfVar5;

  uint uVar6;

  

  if (param_2 < 3) {

    *param_1 = param_2;

  }

  else {

    *param_1 = 2;

  }

  uVar6 = 0;

  if (*param_1 != 0) {

    pfVar4 = (float *)(param_3 + 8);

    do {

      fVar1 = pfVar4[-1];

      fVar2 = *pfVar4;

      pfVar5 = (float *)((int)pfVar4 + param_1[1] + -param_3 + -8);

      *pfVar5 = param_4 * pfVar4[-2];

      pfVar5[1] = param_4 * fVar1;

      pfVar5[2] = param_4 * fVar2;

      uVar6 = uVar6 + 1;

      *(float *)((int)pfVar4 + param_1[1] + -param_3 + 4) = param_4 * pfVar4[1];

      pfVar4 = pfVar4 + 4;

    } while (uVar6 < *param_1);

  }

  puVar3 = (uint *)param_1[1];

  fVar1 = (float)puVar3[3];

  uVar6 = puVar3[1];

  fVar2 = (float)puVar3[2];

  param_1[2] = *puVar3;

  param_1[3] = uVar6;

  param_1[4] = (uint)(fVar2 - fVar1);

  return;

}





// --- FUN_0050d210 at 0x0050D210 (size: 195) ---


void __fastcall FUN_0050d210(uint *param_1)



{

  float *pfVar1;

  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;

  float fVar15;

  float *pfVar16;

  float *pfVar17;

  int iVar18;

  int iVar19;

  uint uVar20;

  

  uVar20 = 0;

  if (*param_1 != 0) {

    iVar19 = 0;

    iVar18 = 0;

    do {

      pfVar1 = (float *)(param_1[1] + iVar18);

      pfVar16 = (float *)(param_1[1] + iVar18);

      iVar18 = iVar18 + 0x10;

      fVar2 = (float)param_1[0x35];

      fVar3 = pfVar16[2];

      fVar4 = *pfVar16;

      fVar5 = (float)param_1[0x2f];

      fVar6 = (float)param_1[0x32];

      fVar7 = pfVar16[1];

      fVar8 = (float)param_1[0x38];

      fVar9 = (float)param_1[0x36];

      fVar10 = pfVar16[2];

      fVar11 = (float)param_1[0x33];

      fVar12 = pfVar16[1];

      fVar13 = (float)param_1[0x30];

      fVar14 = *pfVar16;

      pfVar17 = (float *)(param_1[0xe] + iVar19);

      uVar20 = uVar20 + 1;

      iVar19 = iVar19 + 0xc;

      fVar15 = (float)param_1[0x39];

      *pfVar17 = pfVar16[2] * (float)param_1[0x34] +

                 pfVar16[1] * (float)param_1[0x31] + *pfVar1 * (float)param_1[0x2e] +

                 (float)param_1[0x37];

      pfVar17[1] = fVar6 * fVar7 + fVar4 * fVar5 + fVar2 * fVar3 + fVar8;

      pfVar17[2] = fVar13 * fVar14 + fVar11 * fVar12 + fVar9 * fVar10 + fVar15;

    } while (uVar20 < *param_1);

  }

  return;

}





// --- FUN_0050d2e0 at 0x0050D2E0 (size: 440) ---


void __thiscall FUN_0050d2e0(uint *param_1,float *param_2)



{

  float *pfVar1;

  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;

  float fVar15;

  float *pfVar16;

  float *pfVar17;

  uint uVar18;

  int iVar19;

  

  uVar18 = 0;

  if (param_2 != (float *)0x0) {

    if (*param_1 != 0) {

      iVar19 = 0;

      do {

        pfVar1 = (float *)(param_1[5] + iVar19);

        pfVar16 = (float *)(param_1[5] + iVar19);

        uVar18 = uVar18 + 1;

        iVar19 = iVar19 + 0x10;

        *pfVar16 = *pfVar1 + *param_2;

        pfVar16[1] = param_2[1] + pfVar16[1];

        pfVar16[2] = param_2[2] + pfVar16[2];

      } while (uVar18 < *param_1);

    }

    param_1[6] = (uint)(*param_2 + (float)param_1[6]);

    param_1[7] = (uint)(param_2[1] + (float)param_1[7]);

    param_1[8] = (uint)(param_2[2] + (float)param_1[8]);

    return;

  }

  if (*param_1 != 0) {

    iVar19 = 0;

    do {

      *(undefined4 *)(iVar19 + 0xc + param_1[5]) = *(undefined4 *)(iVar19 + 0xc + param_1[1]);

      pfVar1 = (float *)(param_1[1] + iVar19);

      pfVar16 = (float *)(param_1[1] + iVar19);

      fVar2 = (float)param_1[0x50];

      fVar3 = pfVar16[2];

      fVar4 = *pfVar16;

      fVar5 = (float)param_1[0x4a];

      fVar6 = (float)param_1[0x4d];

      fVar7 = pfVar16[1];

      fVar8 = (float)param_1[0x53];

      fVar9 = (float)param_1[0x51];

      fVar10 = pfVar16[2];

      fVar11 = (float)param_1[0x4b];

      fVar12 = *pfVar16;

      fVar13 = (float)param_1[0x4e];

      fVar14 = pfVar16[1];

      pfVar17 = (float *)(param_1[5] + iVar19);

      uVar18 = uVar18 + 1;

      iVar19 = iVar19 + 0x10;

      fVar15 = (float)param_1[0x54];

      *pfVar17 = pfVar16[2] * (float)param_1[0x4f] +

                 pfVar16[1] * (float)param_1[0x4c] + *pfVar1 * (float)param_1[0x49] +

                 (float)param_1[0x52];

      pfVar17[1] = fVar6 * fVar7 + fVar4 * fVar5 + fVar2 * fVar3 + fVar8;

      pfVar17[2] = fVar13 * fVar14 + fVar11 * fVar12 + fVar9 * fVar10 + fVar15;

    } while (uVar18 < *param_1);

  }

  param_1[6] = (uint)((float)param_1[0x4c] * (float)param_1[3] +

                      (float)param_1[0x49] * (float)param_1[2] +

                      (float)param_1[0x4f] * (float)param_1[4] + (float)param_1[0x52]);

  param_1[7] = (uint)((float)param_1[0x4d] * (float)param_1[3] +

                      (float)param_1[0x4a] * (float)param_1[2] +

                      (float)param_1[0x50] * (float)param_1[4] + (float)param_1[0x53]);

  param_1[8] = (uint)((float)param_1[0x4e] * (float)param_1[3] +

                      (float)param_1[0x4b] * (float)param_1[2] +

                      (float)param_1[0x51] * (float)param_1[4] + (float)param_1[0x54]);

  return;

}





// --- FUN_0050d4a0 at 0x0050D4A0 (size: 559) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0050d4a0(uint *param_1,int param_2,float param_3)



{

  float fVar1;

  float fVar2;

  float fVar3;

  float fVar4;

  float *pfVar5;

  float *pfVar6;

  int iVar7;

  int iVar8;

  uint local_4c;

  undefined1 local_18 [12];

  undefined1 local_c [12];

  

  param_3 = _DAT_007938b0 / param_3;

  iVar7 = 0;

  local_4c = 0;

  if (*param_1 != 0) {

    iVar8 = 0;

    do {

      *(float *)(iVar8 + 0xc + param_1[9]) = param_3 * *(float *)(iVar8 + 0xc + param_1[1]);

      pfVar5 = (float *)FUN_00452830(local_18,param_1 + 0x43,param_1[1] + iVar8);

      pfVar6 = (float *)(param_1[9] + iVar8);

      fVar1 = pfVar5[1];

      fVar2 = pfVar5[2];

      *pfVar6 = param_3 * *pfVar5;

      pfVar6[1] = param_3 * fVar1;

      pfVar6[2] = param_3 * fVar2;

      pfVar5 = (float *)FUN_00452830(local_c,param_1 + 0x28,param_1[1] + iVar8);

      pfVar6 = (float *)(param_1[0xd] + iVar7);

      fVar1 = pfVar5[1];

      iVar8 = iVar8 + 0x10;

      iVar7 = iVar7 + 0xc;

      fVar2 = pfVar5[2];

      *pfVar6 = param_3 * *pfVar5;

      pfVar6[1] = param_3 * fVar1;

      pfVar6[2] = param_3 * fVar2;

      local_4c = local_4c + 1;

    } while (local_4c < *param_1);

  }

  param_1[0x10] = *(uint *)(param_2 + 4);

  param_1[0x1e] = *(uint *)(param_2 + 0x3c);

  param_1[0x1f] = *(uint *)(param_2 + 0x40);

  param_1[0x20] = *(uint *)(param_2 + 0x44);

  param_1[0x11] = *(uint *)(param_2 + 8);

  param_1[0x12] = *(uint *)(param_2 + 0xc);

  param_1[0x13] = *(uint *)(param_2 + 0x10);

  param_1[0x14] = *(uint *)(param_2 + 0x14);

  param_1[0x15] = *(uint *)(param_2 + 0x18);

  param_1[0x16] = *(uint *)(param_2 + 0x1c);

  param_1[0x17] = *(uint *)(param_2 + 0x20);

  param_1[0x18] = *(uint *)(param_2 + 0x24);

  param_1[0x19] = *(uint *)(param_2 + 0x28);

  param_1[0x1a] = *(uint *)(param_2 + 0x2c);

  param_1[0x1b] = *(uint *)(param_2 + 0x30);

  param_1[0x1c] = *(uint *)(param_2 + 0x34);

  param_1[0x1d] = *(uint *)(param_2 + 0x38);

  fVar3 = (*(float *)(param_2 + 0x28) + *(float *)(param_2 + 0x24)) * DAT_00796344;

  fVar1 = *(float *)(param_2 + 0x2c);

  fVar4 = (*(float *)(param_2 + 0x34) + *(float *)(param_2 + 0x30)) * DAT_00796344;

  fVar2 = *(float *)(param_2 + 0x38);

  param_1[0x21] =

       (uint)((*(float *)(param_2 + 0x1c) + *(float *)(param_2 + 0x18)) * DAT_00796344 +

             *(float *)(param_2 + 0x20));

  param_1[0x22] = (uint)(fVar3 + fVar1);

  param_1[0x23] = (uint)(fVar4 + fVar2);

  pfVar5 = (float *)param_1[9];

  fVar1 = pfVar5[3];

  fVar2 = pfVar5[1];

  fVar3 = pfVar5[2];

  param_1[10] = (uint)(*pfVar5 - fVar1 * (float)param_1[0x21]);

  param_1[0xb] = (uint)(fVar2 - fVar1 * (float)param_1[0x22]);

  param_1[0xc] = (uint)(fVar3 - fVar1 * (float)param_1[0x23]);

  return;

}





// --- FUN_0050d6d0 at 0x0050D6D0 (size: 120) ---


void __thiscall FUN_0050d6d0(int param_1,uint param_2)



{

  float local_c;

  float local_8;

  float local_4;

  

  if ((param_2 & 0xffff) < 0x100) {

    FUN_0043e7d0(&local_c,param_2,*(undefined4 *)(param_1 + 0x110));

    FUN_0050d2e0(&local_c);

    *(float *)(param_1 + 0x148) = local_c + *(float *)(param_1 + 0x148);

    *(float *)(param_1 + 0x14c) = local_8 + *(float *)(param_1 + 0x14c);

    *(float *)(param_1 + 0x150) = local_4 + *(float *)(param_1 + 0x150);

  }

  *(uint *)(param_1 + 0x110) = param_2;

  return;

}





// --- FUN_0050d750 at 0x0050D750 (size: 404) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __thiscall FUN_0050d750(int param_1,undefined4 param_2)



{

  float *pfVar1;

  float *pfVar2;

  int iVar3;

  undefined4 uVar4;

  float local_3c;

  float local_38;

  float local_34;

  float local_30;

  float local_2c;

  float local_28;

  float local_24;

  float local_20;

  float local_1c;

  float local_10;

  float local_c;

  

  iVar3 = FUN_0053a040(param_1 + 0x1c4,param_1 + 0x1dc,&local_3c);

  if (iVar3 == 0) {

    *(undefined4 *)(param_1 + 0x1d4) = 0;

    return 2;

  }

  *(undefined4 *)(param_1 + 0x1d4) = 0;

  *(undefined4 *)(param_1 + 0xf4) = 0;

  pfVar1 = *(float **)(param_1 + 0x38);

  pfVar2 = *(float **)(param_1 + 0x14);

  local_30 = local_38 * *(float *)(param_1 + 0x20c) +

             local_3c * *(float *)(param_1 + 0x200) + local_34 * *(float *)(param_1 + 0x218);

  local_2c = local_38 * *(float *)(param_1 + 0x210) +

             local_3c * *(float *)(param_1 + 0x204) + local_34 * *(float *)(param_1 + 0x21c);

  local_34 = local_38 * *(float *)(param_1 + 0x214) +

             local_3c * *(float *)(param_1 + 0x208) + local_34 * *(float *)(param_1 + 0x220);

  local_3c = local_30;

  local_38 = local_2c;

  local_28 = local_34;

  FUN_0043e7d0(&local_24,*(undefined4 *)(param_1 + 0xa4),*(undefined4 *)(param_1 + 0x110));

  local_10 = pfVar2[2] - pfVar1[2];

  local_c = local_24 + (*pfVar2 - *pfVar1);

  if (DAT_00796344 <

      local_c * local_30 +

      (local_20 + (pfVar2[1] - pfVar1[1])) * local_2c + local_28 * (local_1c + local_10)) {

    local_3c = local_30 * _DAT_0079a1a0;

    local_38 = local_38 * _DAT_0079a1a0;

    local_34 = local_34 * _DAT_0079a1a0;

  }

  uVar4 = FUN_00538180(param_1,param_2,&local_3c,pfVar1);

  return uVar4;

}





// --- FUN_0050d8f0 at 0x0050D8F0 (size: 142) ---


void __thiscall FUN_0050d8f0(int param_1,undefined4 param_2,int param_3,int param_4)



{

  *(undefined4 *)(param_1 + 0x90) = param_2;

  *(int *)(param_1 + 0x94) = param_3;

  *(int *)(param_1 + 0x98) = param_4;

  if (param_3 != 0) {

    *(undefined4 *)(param_1 + 0xa4) = *(undefined4 *)(param_3 + 4);

    FUN_00425f10(param_3 + 8);

    *(undefined4 *)(param_1 + 0x9c) = param_2;

    FUN_0050d210();

    *(undefined4 *)(param_1 + 0x154) = 0;

    return;

  }

  *(undefined4 *)(param_1 + 0xa4) = *(undefined4 *)(param_4 + 4);

  FUN_00425f10(param_4 + 8);

  *(undefined4 *)(param_1 + 0x9c) = param_2;

  FUN_0050d210();

  *(undefined4 *)(param_1 + 0x154) = 1;

  return;

}





// --- FUN_0050d980 at 0x0050D980 (size: 92) ---


undefined4 __thiscall FUN_0050d980(int *param_1,int param_2)



{

  int *piVar1;

  int iVar2;

  

  if ((*(uint *)(param_2 + 0xa8) & 0x40) != 0) {

    return 1;

  }

  if (((*(byte *)(*param_1 + 0xa8) & 0x40) != 0) && (*(int *)(param_2 + 8) != param_1[7])) {

    piVar1 = *(int **)(param_2 + 300);

    if (((*(uint *)(param_2 + 0xa8) & 4) != 0) && (piVar1 != (int *)0x0)) {

      return 1;

    }

    if (((param_1[7] != 0) && (piVar1 != (int *)0x0)) &&

       (iVar2 = (**(code **)(*piVar1 + 0x2c))(), iVar2 != 0)) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_0050d9e0 at 0x0050D9E0 (size: 7) ---


void FUN_0050d9e0(void)



{

  FUN_00510000();

  return;

}





// --- FUN_0050d9f0 at 0x0050D9F0 (size: 7) ---


void FUN_0050d9f0(void)



{

  FUN_00510030();

  return;

}





// --- FUN_0050da00 at 0x0050DA00 (size: 162) ---


void __thiscall FUN_0050da00(int *param_1,int param_2,int param_3)



{

  int *piVar1;

  int iVar2;

  float10 fVar3;

  

  *param_1 = param_2;

  param_1[1] = param_3;

  param_1[2] = *(int *)(param_2 + 0x114);

  fVar3 = (float10)FUN_0050f4d0();

  param_1[3] = (int)(float)fVar3;

  fVar3 = (float10)FUN_0050f4f0();

  param_1[4] = (int)(float)fVar3;

  iVar2 = *param_1;

  param_1[5] = *(uint *)(iVar2 + 0xa8) & 4;

  param_1[6] = ~(*(uint *)(iVar2 + 0xa8) >> 6) & 1;

  piVar1 = *(int **)(iVar2 + 300);

  if (piVar1 != (int *)0x0) {

    iVar2 = (**(code **)(*piVar1 + 0x28))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x80;

    }

    iVar2 = (**(code **)(*piVar1 + 0x10))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x100;

    }

    iVar2 = (**(code **)(*piVar1 + 0x20))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x800;

    }

    iVar2 = (**(code **)(*piVar1 + 0x24))();

    if (iVar2 != 0) {

      param_1[1] = param_1[1] | 0x1000;

    }

  }

  return;

}





// --- FUN_0050dab0 at 0x0050DAB0 (size: 45) ---


void FUN_0050dab0(void)



{

  undefined4 local_c;

  undefined4 local_8;

  undefined4 local_4;

  

  local_c = 0;

  local_8 = 0;

  local_4 = 0;

  FUN_00511ec0(&local_c,0);

  return;

}





// --- FUN_0050dae0 at 0x0050DAE0 (size: 786) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __thiscall

FUN_0050dae0(int param_1,float *param_2,float *param_3,undefined4 param_4,float param_5,int param_6,

            int param_7,undefined4 param_8)



{

  float fVar1;

  float *pfVar2;

  float fVar3;

  int iVar4;

  undefined4 local_1c;

  float local_18;

  float local_14;

  float local_10;

  float local_4;

  

  local_1c = 1;

  if ((*(byte *)(param_1 + 4) & 4) != 0) {

    local_10 = (param_2[2] * param_3[2] + param_3[1] * param_2[1] + *param_3 * *param_2 + param_3[3]

               ) - param_2[3];

    if (local_10 <= -_DAT_007c76f8) {

      pfVar2 = *(float **)(param_6 + 0x38);

      local_10 = local_10 /

                 ((param_2[1] - pfVar2[1]) * param_3[1] +

                 (*param_2 - *pfVar2) * *param_3 + (param_2[2] - pfVar2[2]) * param_3[2]);

      if ((((local_10 < DAT_00796344 == (local_10 == DAT_00796344)) &&

           (local_10 <= (float)_DAT_007938c0)) || (*(int *)(param_6 + 0x94) == 0)) ||

         ((*(uint *)(*(int *)(param_6 + 0x94) + 4) & 0xffff) < 0x100)) {

        local_10 = -local_10;

        local_18 = (*param_2 - *pfVar2) * local_10;

        local_14 = (param_2[1] - pfVar2[1]) * local_10;

        local_10 = (param_2[2] - pfVar2[2]) * local_10;

        local_4 = local_10;

        FUN_0050a7e0(&local_18);

        FUN_0050aad0(param_3);

        *(undefined4 *)(param_6 + 0x7c) = 1;

        return 3;

      }

    }

    return 1;

  }

  param_5 = *param_2 * *param_3 + (param_2[2] - param_2[3]) * param_3[2] + param_2[1] * param_3[1] +

            param_3[3] + param_5;

  if (-_DAT_007c76f8 <= param_5) {

    if (_DAT_007c76f8 < param_5) {

      return 1;

    }

    iVar4 = FUN_00510000(param_3);

    if (((*(int *)(param_6 + 0x158) != 0) || ((*(byte *)(param_1 + 4) & 2) == 0)) || (iVar4 != 0)) {

      FUN_0050a850(param_3,param_4);

      *(undefined4 *)(param_7 + 0x2c) = param_8;

    }

    if (((*(byte *)(param_1 + 4) & 1) == 0) && (*(int *)(param_6 + 0x158) == 0)) {

      FUN_0050aad0(param_3);

      *(undefined4 *)(param_7 + 0x7c) = 1;

    }

    local_1c = 1;

  }

  else {

    if (*(int *)(param_6 + 0x1d8) != 0) {

      return 2;

    }

    fVar1 = param_3[2];

    iVar4 = FUN_00510000(param_3);

    if (((*(int *)(param_6 + 0x158) != 0) || ((*(byte *)(param_1 + 4) & 2) == 0)) || (iVar4 != 0)) {

      FUN_0050a850(param_3,param_4);

      *(undefined4 *)(param_7 + 0x2c) = param_8;

      if (*(int *)(param_6 + 0x158) != 0) {

        fVar3 = ((float)_DAT_007938c0 -

                (_DAT_0079a1a0 / (*(float *)(param_6 + 0x1c0) * *(float *)(param_6 + 0x1bc))) *

                (param_5 / fVar1)) * *(float *)(param_6 + 0x1bc);

        if ((*(float *)(param_6 + 0x1bc) <= fVar3) || (fVar3 < (float)_DAT_007c7700)) {

          return 2;

        }

        *(float *)(param_6 + 0x1bc) = fVar3;

      }

      local_10 = -(param_5 / fVar1);

      local_18 = 0.0;

      local_14 = 0.0;

      FUN_0050a7e0(&local_18);

      local_1c = 3;

    }

    if (((*(byte *)(param_1 + 4) & 1) == 0) && (*(int *)(param_6 + 0x158) == 0)) {

      FUN_0050aad0(param_3);

      *(undefined4 *)(param_7 + 0x7c) = 1;

      return local_1c;

    }

  }

  return local_1c;

}





// --- FUN_0050de00 at 0x0050DE00 (size: 256) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0050de00(undefined4 *param_1,undefined4 *param_2,float *param_3)



{

  float *pfVar1;

  float fVar2;

  

  *param_1 = *param_2;

  param_1[1] = param_2[1];

  param_1[2] = param_2[2];

  if (((ABS(*param_3 - _DAT_00844c18) < _DAT_007c7798 !=

        (ABS(*param_3 - _DAT_00844c18) == _DAT_007c7798)) &&

      (ABS(param_3[1] - _DAT_00844c1c) < _DAT_007c7798 !=

       (ABS(param_3[1] - _DAT_00844c1c) == _DAT_007c7798))) &&

     (ABS(param_3[2] - _DAT_00844c20) < _DAT_007c7798 !=

      (ABS(param_3[2] - _DAT_00844c20) == _DAT_007c7798))) {

    param_1[6] = 0;

    param_1[3] = 0;

    param_1[4] = 0x3f800000;

    param_1[5] = 0;

    return;

  }

  pfVar1 = (float *)(param_1 + 3);

  param_1[6] = SQRT(*param_3 * *param_3 + param_3[1] * param_3[1] + param_3[2] * param_3[2]);

  fVar2 = _DAT_007938b0 / (float)param_1[6];

  *pfVar1 = *param_3;

  param_1[4] = param_3[1];

  param_1[5] = param_3[2];

  *pfVar1 = fVar2 * *pfVar1;

  param_1[4] = fVar2 * (float)param_1[4];

  param_1[5] = fVar2 * (float)param_1[5];

  return;

}





// --- FUN_0050df00 at 0x0050DF00 (size: 90) ---


void FUN_0050df00(float *param_1)



{

  DAT_0081fec0 = *param_1;

  DAT_0081fec4 = param_1[1];

  DAT_0081fec8 = param_1[2];

  DAT_0081fc84 = DAT_0081fec0;

  if (DAT_0081fec0 < DAT_0081fec4) {

    DAT_0081fc84 = DAT_0081fec4;

  }

  if (DAT_0081fc84 < DAT_0081fec8) {

    DAT_0081fc84 = DAT_0081fec8;

  }

  return;

}





// --- FUN_0050df60 at 0x0050DF60 (size: 17) ---


undefined4 __fastcall FUN_0050df60(int param_1)



{

  if (*(int *)(param_1 + 0xe0) != 0) {

    return *(undefined4 *)(*(int *)(param_1 + 0xe0) + 8);

  }

  return 0;

}





// --- FUN_0050df80 at 0x0050DF80 (size: 27) ---


undefined4 __fastcall FUN_0050df80(int param_1)



{

  if ((*(int *)(param_1 + 0xe0) != 0) && (*(int *)(param_1 + 0xe0) == DAT_00844d68)) {

    return 1;

  }

  return 0;

}





// --- FUN_0050dfa0 at 0x0050DFA0 (size: 22) ---


undefined4 __fastcall FUN_0050dfa0(int param_1)



{

  return CONCAT31((int3)((uint)*(int *)(param_1 + 0xdc) >> 8),

                  *(int *)(param_1 + 0xdc) == *(int *)(DAT_00870340 + 0xb0));

}





// --- FUN_0050dfc0 at 0x0050DFC0 (size: 18) ---


void __fastcall FUN_0050dfc0(int param_1)



{

  *(undefined4 *)(param_1 + 0xdc) = *(undefined4 *)(DAT_00870340 + 0xb0);

  return;

}





// --- FUN_0050dfe0 at 0x0050DFE0 (size: 21) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_0050dfe0(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    fVar1 = (float10)FUN_0051ede0();

    return fVar1;

  }

  return (float10)_DAT_007a61c0;

}





// --- FUN_0050e000 at 0x0050E000 (size: 97) ---


void FUN_0050e000(int *param_1,int *param_2)



{

  int *piVar1;

  uint uVar2;

  uint uVar3;

  

  piVar1 = (int *)*param_1;

  uVar2 = 1;

  if (piVar1 != (int *)0x0) {

    uVar2 = piVar1[0xe];

    (**(code **)(*piVar1 + 0x14))();

    *param_1 = 0;

  }

  if (*param_2 != 0) {

    uVar3 = 0;

    if (uVar2 != 0) {

      do {

        piVar1 = *(int **)(*param_2 + uVar3 * 4);

        if (piVar1 != (int *)0x0) {

          (**(code **)(*piVar1 + 0x14))();

          *(undefined4 *)(*param_2 + uVar3 * 4) = 0;

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < uVar2);

    }

    operator_delete__((void *)*param_2);

    *param_2 = 0;

  }

  return;

}





// --- FUN_0050e070 at 0x0050E070 (size: 15) ---


void __thiscall FUN_0050e070(int param_1,undefined4 *param_2)



{

  *param_2 = *(undefined4 *)(param_1 + 200);

  return;

}





// --- FUN_0050e080 at 0x0050E080 (size: 77) ---


void __fastcall FUN_0050e080(int param_1)



{

  uint uVar1;

  

  uVar1 = 0;

  if (*(int *)(**(int **)(param_1 + 0x20) + 0x34) != 0) {

    do {

      FUN_00536ca0();

      uVar1 = uVar1 + 1;

    } while (uVar1 < *(uint *)(**(int **)(param_1 + 0x20) + 0x34));

  }

  if (*(int *)(param_1 + 0xd8) != 0) {

    FUN_0053ed10(*(int *)(param_1 + 0xd8));

    *(undefined4 *)(param_1 + 0xd8) = 0;

  }

  return;

}





// --- FUN_0050e0d0 at 0x0050E0D0 (size: 11) ---


int __fastcall FUN_0050e0d0(int param_1)



{

  return **(int **)(param_1 + 0x20) + 0x98;

}





// --- FUN_0050e0e0 at 0x0050E0E0 (size: 29) ---


void __thiscall FUN_0050e0e0(int param_1,int param_2)



{

  if (param_2 != 0) {

    *(uint *)(param_1 + 0x1c) = *(uint *)(param_1 + 0x1c) | 1;

    return;

  }

  *(uint *)(param_1 + 0x1c) = *(uint *)(param_1 + 0x1c) & 0xfffffffe;

  return;

}





// --- FUN_0050e100 at 0x0050E100 (size: 106) ---


bool __fastcall FUN_0050e100(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  

  iVar1 = *(int *)(**(int **)(param_1 + 0x20) + 0x30);

  if (*(int *)(param_1 + 0xc0) != iVar1) {

    return true;

  }

  if (iVar1 == 0) {

    iVar1 = FUN_005df0f5(0x50);

    if (iVar1 != 0) {

      uVar2 = FUN_0053a4b0();

      goto LAB_0050e155;

    }

  }

  else {

    iVar1 = FUN_005df0f5(0x50);

    if (iVar1 != 0) {

      uVar2 = FUN_0053a500(*(undefined4 *)(**(int **)(param_1 + 0x20) + 0x30));

      goto LAB_0050e155;

    }

  }

  uVar2 = 0;

LAB_0050e155:

  *(undefined4 *)(param_1 + 0xc0) = uVar2;

  return *(int *)(param_1 + 0xc0) != 0;

}





// --- FUN_0050e170 at 0x0050E170 (size: 142) ---


undefined4 __fastcall FUN_0050e170(int param_1)



{

  int iVar1;

  undefined4 uVar2;

  uint uVar3;

  

  if (*(int *)(param_1 + 0xc4) != *(int *)(**(int **)(param_1 + 0x20) + 0x38)) {

    return 1;

  }

  iVar1 = thunk_FUN_005df0f5(*(int *)(**(int **)(param_1 + 0x20) + 0x34) * 4);

  *(int *)(param_1 + 0xc4) = iVar1;

  if (iVar1 != 0) {

    iVar1 = *(int *)(**(int **)(param_1 + 0x20) + 0x38);

    uVar3 = 0;

    if (*(int *)(**(int **)(param_1 + 0x20) + 0x34) != 0) {

      do {

        uVar2 = FUN_00536ff0(*(undefined4 *)(iVar1 + uVar3 * 4));

        *(undefined4 *)(*(int *)(param_1 + 0xc4) + uVar3 * 4) = uVar2;

        if (*(int *)(*(int *)(param_1 + 0xc4) + uVar3 * 4) == 0) {

          return 0;

        }

        uVar3 = uVar3 + 1;

      } while (uVar3 < *(uint *)(**(int **)(param_1 + 0x20) + 0x34));

    }

    return 1;

  }

  return 0;

}





// --- FUN_0050e200 at 0x0050E200 (size: 100) ---


void __fastcall FUN_0050e200(int param_1)



{

  int iVar1;

  uint uVar2;

  

  if (((*(int **)(param_1 + 0x20) != (int *)0x0) && (iVar1 = **(int **)(param_1 + 0x20), iVar1 != 0)

      ) && (*(int *)(param_1 + 0xc4) != *(int *)(iVar1 + 0x38))) {

    uVar2 = 0;

    if (*(int *)(iVar1 + 0x34) != 0) {

      do {

        FUN_00536c10(*(undefined4 *)(*(int *)(param_1 + 0xc4) + uVar2 * 4));

        uVar2 = uVar2 + 1;

      } while (uVar2 < *(uint *)(**(int **)(param_1 + 0x20) + 0x34));

    }

    operator_delete__(*(void **)(param_1 + 0xc4));

    *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)(**(int **)(param_1 + 0x20) + 0x38);

  }

  return;

}





// --- FUN_0050e270 at 0x0050E270 (size: 245) ---


void __thiscall FUN_0050e270(int param_1,int param_2)



{

  uint uVar1;

  int iVar2;

  

  if (((*(byte *)(param_1 + 0x1c) & 1) == 0) &&

     ((param_2 != 0 || (*(int *)(param_1 + 0xdc) != DAT_00870340[0x2c])))) {

    uVar1 = *(uint *)(param_1 + 0x14);

    if ((*(int *)(param_1 + 0x10) == 0) || (*(uint *)(*(int *)(param_1 + 0x10) + 0x38) <= uVar1)) {

      uVar1 = 0;

    }

    iVar2 = *(int *)(*(int *)(param_1 + 0x20) + uVar1 * 4);

    if (iVar2 != 0) {

      FUN_005a0ff0(*(undefined4 *)(param_1 + 0xc0),0);

      FUN_0054c3c0(*(undefined4 *)(param_1 + 0xc4));

      FUN_0050df00(param_1 + 0x24);

      if (((*(int *)(param_1 + 0xe0) != 0) && (*(int *)(*(int *)(param_1 + 0xe0) + 8) != 0)) ||

         (DAT_00867348 = 0, DAT_00844c04 != 0)) {

        DAT_00867348 = 1;

      }

      DAT_008ee3d8 = param_1;

      iVar2 = (**(code **)(*DAT_00870340 + 0x70))(iVar2,param_1 + 0x78,param_2 != 0);

      DAT_008ee3d8 = 0;

      if ((iVar2 == 2) && (DAT_00844bfc != 0)) {

        if (*(int *)(param_1 + 0xe0) == 0) {

          iVar2 = 0;

        }

        else {

          iVar2 = *(int *)(*(int *)(param_1 + 0xe0) + 8);

        }

        if (DAT_00844bfc == iVar2) {

          DAT_00844c00 = 1;

        }

      }

    }

  }

  return;

}





// --- FUN_0050e370 at 0x0050E370 (size: 34) ---


bool __fastcall FUN_0050e370(int param_1)



{

  int iVar1;

  

  iVar1 = *(int *)(param_1 + 0x10);

  if ((iVar1 != 0) && (*(int *)(iVar1 + 0x38) != 0)) {

    return *(int *)(*(int *)(iVar1 + 0x3c) + 4) != 1;

  }

  return false;

}





// --- FUN_0050e3a0 at 0x0050E3A0 (size: 65) ---


undefined4 __thiscall FUN_0050e3a0(int param_1,undefined4 param_2)



{

  undefined4 uVar1;

  

  uVar1 = 1;

  if ((**(int **)(param_1 + 0x20) != 0) && (*(int *)(**(int **)(param_1 + 0x20) + 0x78) != 0)) {

    FUN_0050d4a0(param_1 + 0x30,*(undefined4 *)(param_1 + 0x2c));

    uVar1 = FUN_00535440(param_2,*(undefined4 *)(param_1 + 0x2c));

  }

  return uVar1;

}





// --- FUN_0050e3f0 at 0x0050E3F0 (size: 191) ---


void __thiscall FUN_0050e3f0(int param_1,float *param_2,int 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;

  float fVar12;

  float fVar13;

  float fVar14;

  float fVar15;

  float fVar16;

  float local_24;

  float local_20;

  float local_1c;

  

  FUN_0043e7d0(&local_24,*(undefined4 *)(param_1 + 4),*(undefined4 *)(param_3 + 4));

  fVar1 = *(float *)(param_3 + 0x28);

  fVar2 = param_4[1];

  fVar3 = *(float *)(param_3 + 0x1c);

  fVar4 = *param_4;

  fVar5 = *(float *)(param_3 + 0x34);

  fVar6 = param_4[2];

  fVar7 = *(float *)(param_3 + 0x40);

  fVar8 = *(float *)(param_3 + 0x2c);

  fVar9 = param_4[1];

  fVar10 = *(float *)(param_3 + 0x20);

  fVar11 = *param_4;

  fVar12 = *(float *)(param_3 + 0x38);

  fVar13 = param_4[2];

  fVar14 = *(float *)(param_3 + 0x44);

  fVar15 = *(float *)(param_1 + 0x40);

  fVar16 = *(float *)(param_1 + 0x44);

  *param_2 = (local_24 +

             *(float *)(param_3 + 0x30) * param_4[2] +

             *(float *)(param_3 + 0x18) * *param_4 + *(float *)(param_3 + 0x24) * param_4[1] +

             *(float *)(param_3 + 0x3c)) - *(float *)(param_1 + 0x3c);

  param_2[1] = (local_20 + fVar5 * fVar6 + fVar3 * fVar4 + fVar1 * fVar2 + fVar7) - fVar15;

  param_2[2] = (local_1c + fVar12 * fVar13 + fVar10 * fVar11 + fVar8 * fVar9 + fVar14) - fVar16;

  return;

}





// --- FUN_0050e4b0 at 0x0050E4B0 (size: 158) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0050e4b0(int param_1)



{

  int iVar1;

  float10 fVar2;

  

  if (((*(int **)(param_1 + 0x20) == (int *)0x0) || (iVar1 = **(int **)(param_1 + 0x20), iVar1 == 0)

      ) || (*(int *)(iVar1 + 0x30) == 0)) {

    fVar2 = (float10)DAT_00796344;

  }

  else {

    fVar2 = (float10)FUN_0053a450();

  }

  if (fVar2 == (float10)*(float *)(param_1 + 0xcc)) {

    if (((*(int **)(param_1 + 0x20) == (int *)0x0) ||

        (iVar1 = **(int **)(param_1 + 0x20), iVar1 == 0)) || (*(int *)(iVar1 + 0x30) == 0)) {

      fVar2 = (float10)_DAT_007938b0;

    }

    else {

      fVar2 = (float10)FUN_0069f540();

    }

    if (fVar2 == (float10)*(float *)(param_1 + 0xd0)) {

      if (((*(int **)(param_1 + 0x20) == (int *)0x0) ||

          (iVar1 = **(int **)(param_1 + 0x20), iVar1 == 0)) || (*(int *)(iVar1 + 0x30) == 0)) {

        fVar2 = (float10)DAT_00796344;

      }

      else {

        fVar2 = (float10)FUN_0053a480();

      }

      if (fVar2 == (float10)*(float *)(param_1 + 0xd4)) {

        return 1;

      }

    }

  }

  return 0;

}





// --- FUN_0050e550 at 0x0050E550 (size: 237) ---


undefined4 * __fastcall FUN_0050e550(undefined4 *param_1)



{

  undefined4 uVar1;

  

  param_1[8] = 0;

  param_1[9] = 0x3f800000;

  param_1[10] = 0x3f800000;

  param_1[0xb] = 0x3f800000;

  param_1[0xc] = &PTR_LAB_00797910;

  param_1[0xd] = 0;

  param_1[0xe] = 0x3f800000;

  param_1[0xf] = 0;

  param_1[0x10] = 0;

  param_1[0x11] = 0;

  param_1[0x1b] = 0;

  param_1[0x1c] = 0;

  param_1[0x1d] = 0;

  FUN_00535b30();

  param_1[0x1e] = &PTR_LAB_00797910;

  param_1[0x1f] = 0;

  param_1[0x20] = 0x3f800000;

  param_1[0x21] = 0;

  param_1[0x22] = 0;

  param_1[0x23] = 0;

  param_1[0x2d] = 0;

  param_1[0x2e] = 0;

  param_1[0x2f] = 0;

  FUN_00535b30();

  param_1[1] = 0;

  param_1[2] = 0;

  param_1[0x38] = 0;

  param_1[5] = 0;

  param_1[4] = 0;

  param_1[7] = 0;

  param_1[0x30] = 0;

  param_1[0x31] = 0;

  param_1[0x36] = 0;

  param_1[0x39] = 0xffffffff;

  param_1[6] = 1;

  param_1[3] = 0x3f800000;

  *param_1 = 0x7f7fffff;

  uVar1 = DAT_00844c6c;

  param_1[0x37] = 0;

  param_1[0x32] = uVar1;

  return param_1;

}





// --- FUN_0050e640 at 0x0050E640 (size: 258) ---


undefined4 __thiscall FUN_0050e640(int param_1,int param_2)



{

  uint uVar1;

  undefined4 *puVar2;

  undefined4 uVar3;

  uint uVar4;

  

  puVar2 = (undefined4 *)thunk_FUN_005df0f5(4);

  *(undefined4 **)(param_1 + 0x20) = puVar2;

  *puVar2 = **(undefined4 **)(param_2 + 0x20);

  (**(code **)(*(int *)**(undefined4 **)(param_1 + 0x20) + 0x10))();

  *(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 + 0x34) = *(undefined4 *)(param_2 + 0x34);

  FUN_00425f10(param_2 + 0x38);

  *(undefined4 *)(param_1 + 0x7c) = *(undefined4 *)(param_2 + 0x7c);

  FUN_00425f10(param_2 + 0x80);

  *(undefined4 *)(param_1 + 200) = *(undefined4 *)(param_2 + 200);

  *(undefined4 *)(param_1 + 0xd0) = *(undefined4 *)(param_2 + 0xd0);

  *(undefined4 *)(param_1 + 0xd4) = *(undefined4 *)(param_2 + 0xd4);

  uVar1 = *(uint *)(**(int **)(param_1 + 0x20) + 0x34);

  if (*(int *)(param_2 + 0xc4) != *(int *)(**(int **)(param_2 + 0x20) + 0x38)) {

    uVar3 = thunk_FUN_005df0f5(uVar1 * 4);

    uVar4 = 0;

    *(undefined4 *)(param_1 + 0xc4) = uVar3;

    if (uVar1 != 0) {

      do {

        *(undefined4 *)(*(int *)(param_1 + 0xc4) + uVar4 * 4) =

             *(undefined4 *)(*(int *)(param_2 + 0xc4) + uVar4 * 4);

        (**(code **)(**(int **)(*(int *)(param_1 + 0xc4) + uVar4 * 4) + 0x10))();

        uVar4 = uVar4 + 1;

      } while (uVar4 < uVar1);

    }

    return 1;

  }

  *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)(**(int **)(param_1 + 0x20) + 0x38);

  return 1;

}





// --- FUN_0050e750 at 0x0050E750 (size: 102) ---


void __fastcall FUN_0050e750(int param_1)



{

  int *piVar1;

  undefined4 *puVar2;

  int iVar3;

  int local_4;

  

  iVar3 = 0;

  local_4 = param_1;

  if (0 < *(int *)(**(int **)(param_1 + 0x20) + 0x34)) {

    do {

      piVar1 = (int *)FUN_00537130(&local_4);

      if (*piVar1 != 0) {

        puVar2 = (undefined4 *)FUN_00537130(&local_4);

        *(undefined4 *)(param_1 + 200) = *puVar2;

        return;

      }

      iVar3 = iVar3 + 1;

    } while (iVar3 < *(int *)(**(int **)(param_1 + 0x20) + 0x34));

  }

  *(undefined4 *)(param_1 + 200) = DAT_00844c6c;

  return;

}





// --- FUN_0050e7c0 at 0x0050E7C0 (size: 320) ---


bool FUN_0050e7c0(undefined4 param_1,int *param_2,int *param_3)



{

  int iVar1;

  undefined4 uVar2;

  int *piVar3;

  int iVar4;

  uint uVar5;

  undefined4 *puVar6;

  

  uVar2 = FUN_004220b0(param_1,6);

  piVar3 = (int *)FUN_00415430(uVar2);

  if (piVar3 == (int *)0x0) {

    return false;

  }

  iVar4 = piVar3[0x2c];

  (**(code **)(*piVar3 + 0x14))();

  uVar2 = FUN_004220b0(iVar4,0x1a);

  iVar4 = FUN_00415430(uVar2);

  *param_2 = iVar4;

  if (iVar4 == 0) {

    puVar6 = (undefined4 *)thunk_FUN_005df0f5(4);

    *param_3 = (int)puVar6;

    *puVar6 = 0;

    uVar2 = FUN_004220b0(param_1,6);

    uVar2 = FUN_00415430(uVar2);

    *(undefined4 *)*param_3 = uVar2;

  }

  else {

    iVar4 = thunk_FUN_005df0f5(*(int *)(iVar4 + 0x38) << 2);

    *param_3 = iVar4;

    uVar5 = 0;

    if (*(int *)(*param_2 + 0x38) != 0) {

      do {

        *(undefined4 *)(*param_3 + uVar5 * 4) = 0;

        uVar5 = uVar5 + 1;

      } while (uVar5 < *(uint *)(*param_2 + 0x38));

    }

    uVar5 = 0;

    if (*(int *)(*param_2 + 0x38) != 0) {

      iVar4 = 0;

      do {

        iVar1 = *(int *)(*(int *)(*param_2 + 0x3c) + iVar4);

        if (iVar1 == DAT_00844c6c) {

          *(undefined4 *)(*param_3 + uVar5 * 4) = 0;

        }

        else {

          uVar2 = FUN_004220b0(iVar1,6);

          uVar2 = FUN_00415430(uVar2);

          *(undefined4 *)(*param_3 + uVar5 * 4) = uVar2;

        }

        uVar5 = uVar5 + 1;

        iVar4 = iVar4 + 0x14;

      } while (uVar5 < *(uint *)(*param_2 + 0x38));

    }

  }

  iVar4 = *(int *)*param_3;

  if (iVar4 == 0) {

    FUN_0050e000(param_2,param_3);

  }

  return iVar4 != 0;

}





// --- FUN_0050e900 at 0x0050E900 (size: 151) ---


undefined4 __thiscall FUN_0050e900(int param_1,int param_2,int param_3)



{

  int iVar1;

  int iVar2;

  int *piVar3;

  uint uVar4;

  

  iVar1 = param_3;

  if ((param_3 != DAT_00844c6c) &&

     ((*(int *)(param_1 + 0xc4) != *(int *)(**(int **)(param_1 + 0x20) + 0x38) ||

      (iVar2 = FUN_0050e170(), iVar2 != 0)))) {

    uVar4 = 0;

    if (*(int *)(**(int **)(param_1 + 0x20) + 0x34) != 0) {

      do {

        piVar3 = (int *)FUN_00537120(&param_3);

        if ((*piVar3 == param_2) && (iVar2 = FUN_00537020(iVar1,0), iVar2 == 0)) {

          return 0;

        }

        uVar4 = uVar4 + 1;

      } while (uVar4 < *(uint *)(**(int **)(param_1 + 0x20) + 0x34));

    }

    return 1;

  }

  return 0;

}





// --- FUN_0050e9a0 at 0x0050E9A0 (size: 147) ---


undefined4 __thiscall FUN_0050e9a0(int param_1,int param_2)



{

  int iVar1;

  undefined4 uVar2;

  

  if ((param_2 != 0) &&

     ((*(int *)(param_1 + 0xc4) != *(int *)(**(int **)(param_1 + 0x20) + 0x38) ||

      (iVar1 = FUN_0050e170(), iVar1 != 0)))) {

    iVar1 = 0;

    if (0 < *(int *)(**(int **)(param_1 + 0x20) + 0x34)) {

      do {

        FUN_00536c60(param_2);

        iVar1 = iVar1 + 1;

      } while (iVar1 < *(int *)(**(int **)(param_1 + 0x20) + 0x34));

    }

    if (*(int *)(param_1 + 0xd8) != 0) {

      FUN_0053ed10(*(int *)(param_1 + 0xd8));

      *(undefined4 *)(param_1 + 0xd8) = 0;

    }

    uVar2 = FUN_0053ed90(param_2);

    *(undefined4 *)(param_1 + 0xd8) = uVar2;

    return 1;

  }

  return 0;

}





// --- FUN_0050ea40 at 0x0050EA40 (size: 44) ---


void __fastcall FUN_0050ea40(int param_1)



{

  int iVar1;

  

  if ((*(int **)(param_1 + 0x20) != (int *)0x0) && (iVar1 = **(int **)(param_1 + 0x20), iVar1 != 0))

  {

    if (*(int *)(param_1 + 0xc0) != *(int *)(iVar1 + 0x30)) {

      FUN_00405f70();

    }

    *(undefined4 *)(param_1 + 0xc0) = 0;

  }

  return;

}





// --- FUN_0050ea70 at 0x0050EA70 (size: 121) ---


void __fastcall FUN_0050ea70(int param_1)



{

  *(undefined4 *)(param_1 + 0x7c) = *(undefined4 *)(param_1 + 0x34);

  FUN_00425f10(param_1 + 0x38);

  if (*(int *)(param_1 + 0x18) != 1) {

    switch(*(int *)(param_1 + 0x18)) {

    case 2:

      FUN_00536af0(param_1 + 4);

      return;

    case 3:

      FUN_00536780(0,param_1 + 4);

      return;

    case 4:

      FUN_00536780(1,param_1 + 4);

      return;

    case 5:

      FUN_00536780(2,param_1 + 4);

    }

  }

  return;

}





// --- FUN_0050eb00 at 0x0050EB00 (size: 358) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __fastcall FUN_0050eb00(float *param_1)



{

  float fVar1;

  float fVar2;

  int iVar3;

  float local_18;

  float local_14;

  float local_10;

  float local_c;

  float local_8;

  float local_4;

  

  iVar3 = *(int *)param_1[8];

  local_c = param_1[9] * *(float *)(iVar3 + 0x7c);

  local_8 = param_1[10] * *(float *)(iVar3 + 0x80);

  local_10 = param_1[0xb] * *(float *)(iVar3 + 0x84);

  local_4 = local_10;

  FUN_0050e3f0(&local_18,param_1 + 0xc,&local_c);

  fVar2 = _DAT_007c7798;

  fVar1 = SQRT(local_18 * local_18 + local_14 * local_14 + local_10 * local_10);

  *param_1 = fVar1;

  if (fVar1 <= fVar2) {

    local_18 = 0.0;

    param_1[1] = 0.0;

    local_14 = 0.0;

    local_10 = 1.0;

    param_1[2] = 0.0;

    param_1[3] = 1.0;

  }

  else {

    fVar2 = _DAT_007938b0 / fVar1;

    local_18 = local_18 * fVar2;

    local_14 = local_14 * fVar2;

    local_10 = local_10 * fVar2;

    param_1[1] = local_18;

    param_1[2] = local_14;

    param_1[3] = local_10;

    local_4 = local_10;

  }

  if (param_1[4] != 0.0) {

    if (param_1[0x38] == 0.0) {

      iVar3 = 0;

    }

    else {

      iVar3 = *(int *)((int)param_1[0x38] + 8);

    }

    if (iVar3 != DAT_00844c08) {

      FUN_0051efc0(fVar1 / param_1[0xb],param_1 + 5,param_1 + 6);

      goto LAB_0050ec4e;

    }

  }

  param_1[5] = 0.0;

  param_1[6] = 1.4013e-45;

LAB_0050ec4e:

  if (*(int *)((int)param_1[8] + (int)param_1[5] * 4) != 0) {

    FUN_0050ea70();

  }

  return;

}





// --- FUN_0050ec70 at 0x0050EC70 (size: 130) ---


void __thiscall FUN_0050ec70(float *param_1,float param_2,float *param_3)



{

  int iVar1;

  

  *param_1 = param_2;

  param_1[1] = *param_3;

  param_1[2] = param_3[1];

  param_1[3] = param_3[2];

  if (param_1[4] != 0.0) {

    if (param_1[0x38] == 0.0) {

      iVar1 = 0;

    }

    else {

      iVar1 = *(int *)((int)param_1[0x38] + 8);

    }

    if (iVar1 != DAT_00844c08) {

      FUN_0051efc0(param_2 / param_1[0xb],param_1 + 5,param_1 + 6);

      goto LAB_0050ecdb;

    }

  }

  param_1[5] = 0.0;

  param_1[6] = 1.4013e-45;

LAB_0050ecdb:

  if (*(int *)((int)param_1[8] + (int)param_1[5] * 4) != 0) {

    FUN_0050ea70();

  }

  return;

}





// --- FUN_0050ed00 at 0x0050ED00 (size: 50) ---


int FUN_0050ed00(undefined4 param_1)



{

  int iVar1;

  

  iVar1 = FUN_005df0f5(0xe8);

  if (iVar1 != 0) {

    iVar1 = FUN_0050e550();

    if (iVar1 != 0) {

      FUN_0050e640(param_1);

    }

    return iVar1;

  }

  return 0;

}





// --- FUN_0050ed40 at 0x0050ED40 (size: 105) ---


void __fastcall FUN_0050ed40(int param_1)



{

  int iVar1;

  

  if (*(int **)(param_1 + 0xd8) != (int *)0x0) {

    (**(code **)(**(int **)(param_1 + 0xd8) + 0x14))();

    *(undefined4 *)(param_1 + 0xd8) = 0;

  }

  if ((*(int **)(param_1 + 0x20) != (int *)0x0) && (iVar1 = **(int **)(param_1 + 0x20), iVar1 != 0))

  {

    if (*(int *)(param_1 + 0xc0) != *(int *)(iVar1 + 0x30)) {

      FUN_00405f70();

    }

    *(undefined4 *)(param_1 + 0xc0) = 0;

  }

  FUN_0050e200();

  FUN_0050e000(param_1 + 0x10,param_1 + 0x20);

  *(undefined ***)(param_1 + 0x78) = &PTR_FUN_0079385c;

  *(undefined ***)(param_1 + 0x30) = &PTR_FUN_0079385c;

  return;

}





// --- FUN_0050edb0 at 0x0050EDB0 (size: 198) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0050edb0(int param_1,undefined4 param_2,int *param_3)



{

  int *piVar1;

  int iVar2;

  float10 fVar3;

  

  FUN_0050e200();

  piVar1 = (int *)(param_1 + 0x20);

  FUN_0050e000((undefined4 *)(param_1 + 0x10),piVar1);

  *(undefined4 *)(param_1 + 0x10) = param_2;

  *piVar1 = (int)param_3;

  *(undefined4 *)(param_1 + 0xc4) = *(undefined4 *)(*param_3 + 0x38);

  FUN_0050e750();

  if ((((int *)*piVar1 == (int *)0x0) || (iVar2 = *(int *)*piVar1, iVar2 == 0)) ||

     (*(int *)(iVar2 + 0x30) == 0)) {

    fVar3 = (float10)DAT_00796344;

  }

  else {

    fVar3 = (float10)FUN_0053a450();

  }

  *(float *)(param_1 + 0xcc) = (float)fVar3;

  if ((((int *)*piVar1 == (int *)0x0) || (iVar2 = *(int *)*piVar1, iVar2 == 0)) ||

     (*(int *)(iVar2 + 0x30) == 0)) {

    fVar3 = (float10)_DAT_007938b0;

  }

  else {

    fVar3 = (float10)FUN_0069f540();

  }

  *(float *)(param_1 + 0xd0) = (float)fVar3;

  if ((((int *)*piVar1 == (int *)0x0) || (iVar2 = *(int *)*piVar1, iVar2 == 0)) ||

     (*(int *)(iVar2 + 0x30) == 0)) {

    fVar3 = (float10)DAT_00796344;

  }

  else {

    fVar3 = (float10)FUN_0053a480();

  }

  *(float *)(param_1 + 0xd4) = (float)fVar3;

  if (*(int *)(param_1 + 0xd8) != 0) {

    FUN_0050e9a0(*(int *)(param_1 + 0xd8));

  }

  return;

}





// --- FUN_0050ee80 at 0x0050EE80 (size: 71) ---


undefined4 __fastcall FUN_0050ee80(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0xd8) != 0) {

    FUN_0050e9a0(*(int *)(param_1 + 0xd8));

  }

  iVar1 = 0;

  if (0 < *(int *)(**(int **)(param_1 + 0x20) + 0x34)) {

    do {

      FUN_00537140(0);

      iVar1 = iVar1 + 1;

    } while (iVar1 < *(int *)(**(int **)(param_1 + 0x20) + 0x34));

  }

  return 1;

}





// --- FUN_0050eed0 at 0x0050EED0 (size: 158) ---


void __thiscall FUN_0050eed0(int param_1,float param_2,float param_3)



{

  char cVar1;

  int iVar2;

  

  if ((param_2 != *(float *)(param_1 + 0xd4)) || (param_3 != *(float *)(param_1 + 0xd0))) {

    *(float *)(param_1 + 0xd0) = param_3;

    *(float *)(param_1 + 0xd4) = param_2;

    cVar1 = FUN_0050e4b0();

    if (cVar1 == '\0') {

      iVar2 = FUN_0050e100();

      if (iVar2 != 0) {

        FUN_0053a460(param_2);

        FUN_0053a490(param_3);

      }

    }

    else if ((*(int **)(param_1 + 0x20) != (int *)0x0) &&

            (iVar2 = **(int **)(param_1 + 0x20), iVar2 != 0)) {

      if (*(int *)(param_1 + 0xc0) != *(int *)(iVar2 + 0x30)) {

        FUN_00405f70();

      }

      *(undefined4 *)(param_1 + 0xc0) = 0;

      return;

    }

  }

  return;

}





// --- FUN_0050ef70 at 0x0050EF70 (size: 199) ---


void __fastcall FUN_0050ef70(int param_1)



{

  int iVar1;

  int *piVar2;

  float10 fVar3;

  undefined4 local_8;

  undefined4 local_4;

  

  if (((*(int **)(param_1 + 0x20) == (int *)0x0) || (iVar1 = **(int **)(param_1 + 0x20), iVar1 == 0)

      ) || (*(int *)(iVar1 + 0x30) == 0)) {

    fVar3 = (float10)DAT_00796344;

  }

  else {

    fVar3 = (float10)FUN_0053a450();

  }

  piVar2 = *(int **)(param_1 + 0x20);

  if (fVar3 != (float10)*(float *)(param_1 + 0xcc)) {

    if (((piVar2 == (int *)0x0) || (*piVar2 == 0)) || (*(int *)(*piVar2 + 0x30) == 0)) {

      local_4 = 0.0;

    }

    else {

      fVar3 = (float10)FUN_0053a480();

      local_4 = (float)fVar3;

    }

    if (((*(int **)(param_1 + 0x20) == (int *)0x0) ||

        (iVar1 = **(int **)(param_1 + 0x20), iVar1 == 0)) || (*(int *)(iVar1 + 0x30) == 0)) {

      local_8 = 1.0;

    }

    else {

      fVar3 = (float10)FUN_0069f540();

      local_8 = (float)fVar3;

    }

    FUN_0050eed0(local_4,local_8);

    return;

  }

  if ((piVar2 != (int *)0x0) && (*piVar2 != 0)) {

    if (*(int *)(param_1 + 0xc0) != *(int *)(*piVar2 + 0x30)) {

      FUN_00405f70();

    }

    *(undefined4 *)(param_1 + 0xc0) = 0;

  }

  return;

}





// --- FUN_0050f040 at 0x0050F040 (size: 113) ---


void __thiscall FUN_0050f040(int param_1,float param_2)



{

  char cVar1;

  int iVar2;

  

  if (param_2 != *(float *)(param_1 + 0xd0)) {

    *(float *)(param_1 + 0xd0) = param_2;

    cVar1 = FUN_0050e4b0();

    if (cVar1 == '\0') {

      iVar2 = FUN_0050e100();

      if (iVar2 != 0) {

        FUN_0053a490(param_2);

      }

    }

    else if ((*(int **)(param_1 + 0x20) != (int *)0x0) &&

            (iVar2 = **(int **)(param_1 + 0x20), iVar2 != 0)) {

      if (*(int *)(param_1 + 0xc0) != *(int *)(iVar2 + 0x30)) {

        FUN_00405f70();

      }

      *(undefined4 *)(param_1 + 0xc0) = 0;

      return;

    }

  }

  return;

}





// --- FUN_0050f0c0 at 0x0050F0C0 (size: 113) ---


void __thiscall FUN_0050f0c0(int param_1,float param_2)



{

  char cVar1;

  int iVar2;

  

  if (param_2 != *(float *)(param_1 + 0xd4)) {

    *(float *)(param_1 + 0xd4) = param_2;

    cVar1 = FUN_0050e4b0();

    if (cVar1 == '\0') {

      iVar2 = FUN_0050e100();

      if (iVar2 != 0) {

        FUN_0053a460(param_2);

      }

    }

    else if ((*(int **)(param_1 + 0x20) != (int *)0x0) &&

            (iVar2 = **(int **)(param_1 + 0x20), iVar2 != 0)) {

      if (*(int *)(param_1 + 0xc0) != *(int *)(iVar2 + 0x30)) {

        FUN_00405f70();

      }

      *(undefined4 *)(param_1 + 0xc0) = 0;

      return;

    }

  }

  return;

}





// --- FUN_0050f140 at 0x0050F140 (size: 139) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0050f140(int param_1,float param_2)



{

  char cVar1;

  int iVar2;

  

  if ((*(int *)(param_1 + 0xe0) == 0) ||

     ((*(uint *)(*(int *)(param_1 + 0xe0) + 0xa8) & 0x100000) == 0)) {

    if (param_2 == _DAT_007938b0) {

      *(uint *)(param_1 + 0x1c) = *(uint *)(param_1 + 0x1c) | 1;

      return;

    }

    *(uint *)(param_1 + 0x1c) = *(uint *)(param_1 + 0x1c) & 0xfffffffe;

    if (*(float *)(param_1 + 0xcc) != param_2) {

      *(float *)(param_1 + 0xcc) = param_2;

      cVar1 = FUN_0050e4b0();

      if (cVar1 != '\0') {

        FUN_0050ea40();

        return;

      }

      iVar2 = FUN_0050e100();

      if (iVar2 != 0) {

        FUN_0053a430(param_2);

      }

    }

  }

  return;

}





// --- FUN_0050f1d0 at 0x0050F1D0 (size: 83) ---


undefined4 FUN_0050f1d0(int param_1)



{

  int iVar1;

  undefined4 local_4;

  

  iVar1 = param_1;

  if (param_1 != DAT_00844c6c) {

    param_1 = 0;

    local_4 = 0;

    iVar1 = FUN_0050e7c0(iVar1,&local_4,&param_1);

    if (iVar1 != 0) {

      FUN_0050edb0(local_4,param_1);

      return 1;

    }

  }

  return 0;

}





// --- FUN_0050f230 at 0x0050F230 (size: 73) ---


void * FUN_0050f230(undefined4 param_1)



{

  int iVar1;

  void *pvVar2;

  

  iVar1 = FUN_005df0f5(0xe8);

  if (iVar1 != 0) {

    pvVar2 = (void *)FUN_0050e550();

    if (pvVar2 != (void *)0x0) {

      iVar1 = FUN_0050f1d0(param_1);

      if (iVar1 == 0) {

        FUN_0050ed40();

        operator_delete(pvVar2);

        pvVar2 = (void *)0x0;

      }

      return pvVar2;

    }

  }

  return (void *)0x0;

}





// --- FUN_0050f280 at 0x0050F280 (size: 68) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 __fastcall FUN_0050f280(float *param_1)



{

  if (((ABS(*param_1) < _DAT_007c78bc) && (ABS(param_1[1]) < _DAT_007c78bc)) &&

     (ABS(param_1[2]) < _DAT_007c78bc)) {

    return 1;

  }

  return 0;

}





// --- FUN_0050f2d0 at 0x0050F2D0 (size: 71) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



undefined4 FUN_0050f2d0(float *param_1,float param_2)



{

  if ((((param_2 <= *param_1) && (param_2 <= param_1[1])) && (*param_1 < _DAT_00844d8c - param_2))

     && (param_1[1] < _DAT_00844d8c - param_2)) {

    return 1;

  }

  return 0;

}





// --- FUN_0050f320 at 0x0050F320 (size: 132) ---


void __thiscall FUN_0050f320(int param_1,undefined4 param_2,undefined4 *param_3,undefined4 param_4)



{

  *(undefined4 *)(param_1 + 0x270) = 1;

  *(undefined4 *)(param_1 + 0x274) = *param_3;

  *(undefined4 *)(param_1 + 0x278) = param_3[1];

  *(undefined4 *)(param_1 + 0x27c) = param_3[2];

  *(undefined4 *)(param_1 + 0x280) = param_3[3];

  *(undefined4 *)(param_1 + 0x284) = param_4;

  *(undefined4 *)(param_1 + 0x2a0) = param_2;

  *(undefined4 *)(param_1 + 0x288) = 1;

  *(undefined4 *)(param_1 + 0x28c) = *param_3;

  *(undefined4 *)(param_1 + 0x290) = param_3[1];

  *(undefined4 *)(param_1 + 0x294) = param_3[2];

  *(undefined4 *)(param_1 + 0x298) = param_3[3];

  *(undefined4 *)(param_1 + 0x2a4) = param_4;

  *(undefined4 *)(param_1 + 0x29c) = param_2;

  return;

}





// --- FUN_0050f3b0 at 0x0050F3B0 (size: 75) ---


void __thiscall FUN_0050f3b0(int param_1,undefined4 param_2,undefined4 *param_3,undefined4 param_4)



{

  *(undefined4 *)(param_1 + 0x270) = 1;

  *(undefined4 *)(param_1 + 0x274) = *param_3;

  *(undefined4 *)(param_1 + 0x278) = param_3[1];

  *(undefined4 *)(param_1 + 0x27c) = param_3[2];

  *(undefined4 *)(param_1 + 0x280) = param_3[3];

  *(undefined4 *)(param_1 + 0x284) = param_4;

  *(undefined4 *)(param_1 + 0x29c) = param_2;

  return;

}





// --- FUN_0050f400 at 0x0050F400 (size: 38) ---


bool __thiscall FUN_0050f400(int param_1,undefined4 param_2,undefined4 param_3)



{

  int iVar1;

  

  iVar1 = FUN_0051a0d0(param_1,param_2,param_3);

  *(int *)(param_1 + 0x10) = iVar1;

  return iVar1 != 0;

}





// --- FUN_0050f430 at 0x0050F430 (size: 39) ---


undefined4 * __thiscall FUN_0050f430(int param_1,undefined4 *param_2)



{

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_005195e0(param_2);

    return param_2;

  }

  *param_2 = DAT_00844d94;

  return param_2;

}





// --- FUN_0050f460 at 0x0050F460 (size: 39) ---


undefined4 * __thiscall FUN_0050f460(int param_1,undefined4 *param_2)



{

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_005195f0(param_2);

    return param_2;

  }

  *param_2 = DAT_00844d94;

  return param_2;

}





// --- FUN_0050f490 at 0x0050F490 (size: 19) ---


float10 __fastcall FUN_0050f490(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    fVar1 = (float10)FUN_00518bd0();

    return fVar1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_0050f4b0 at 0x0050F4B0 (size: 19) ---


float10 __fastcall FUN_0050f4b0(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    fVar1 = (float10)FUN_00518be0();

    return fVar1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_0050f4d0 at 0x0050F4D0 (size: 19) ---


float10 __fastcall FUN_0050f4d0(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    fVar1 = (float10)FUN_00518c00();

    return fVar1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_0050f4f0 at 0x0050F4F0 (size: 19) ---


float10 __fastcall FUN_0050f4f0(int param_1)



{

  float10 fVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    fVar1 = (float10)FUN_00518c20();

    return fVar1;

  }

  return (float10)DAT_00796344;

}





// --- FUN_0050f510 at 0x0050F510 (size: 17) ---


undefined4 __fastcall FUN_0050f510(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    uVar1 = FUN_005196b0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f530 at 0x0050F530 (size: 13) ---


void __fastcall FUN_0050f530(int param_1)



{

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_00518840();

    return;

  }

  return;

}





// --- FUN_0050f540 at 0x0050F540 (size: 20) ---


undefined4 __fastcall FUN_0050f540(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    uVar1 = FUN_00519280();

    return uVar1;

  }

  return 0x47;

}





// --- FUN_0050f560 at 0x0050F560 (size: 20) ---


undefined4 __fastcall FUN_0050f560(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x10) != 0) {

    uVar1 = FUN_00519320();

    return uVar1;

  }

  return 0x47;

}





// --- FUN_0050f580 at 0x0050F580 (size: 28) ---


undefined4 __fastcall FUN_0050f580(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0xc4) != 0) {

    iVar1 = FUN_00524e80();

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_0050f5a0 at 0x0050F5A0 (size: 13) ---


void __fastcall FUN_0050f5a0(int param_1)



{

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_005193c0();

    return;

  }

  return;

}





// --- FUN_0050f5b0 at 0x0050F5B0 (size: 16) ---


void __fastcall FUN_0050f5b0(int param_1)



{

  if (*(int *)(param_1 + 200) != 0) {

    FUN_00555e00();

    return;

  }

  return;

}





// --- FUN_0050f5c0 at 0x0050F5C0 (size: 18) ---


undefined4 __fastcall FUN_0050f5c0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 200) != 0) {

    uVar1 = FUN_00555e90();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f5e0 at 0x0050F5E0 (size: 28) ---


undefined4 __fastcall FUN_0050f5e0(int param_1)



{

  int iVar1;

  

  if (*(int *)(param_1 + 0xc4) != 0) {

    iVar1 = FUN_00524e60();

    if (iVar1 != 0) {

      return 1;

    }

  }

  return 0;

}





// --- FUN_0050f600 at 0x0050F600 (size: 7) ---


undefined4 __fastcall FUN_0050f600(int param_1)



{

  return *(undefined4 *)(param_1 + 0xcc);

}





// --- FUN_0050f610 at 0x0050F610 (size: 16) ---


void __fastcall FUN_0050f610(int param_1)



{

  if (*(int *)(param_1 + 200) != 0) {

    FUN_00555e40();

    return;

  }

  return;

}





// --- FUN_0050f620 at 0x0050F620 (size: 18) ---


undefined4 __fastcall FUN_0050f620(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 200) != 0) {

    uVar1 = FUN_00555fd0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f640 at 0x0050F640 (size: 68) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_0050f640(int param_1)



{

  if (param_1 != DAT_00844d68) {

    if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

      return (float10)_DAT_007c7854;

    }

    return (float10)_DAT_007c7858;

  }

  if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

    return (float10)_DAT_007c784c;

  }

  return (float10)_DAT_007c7850;

}





// --- FUN_0050f690 at 0x0050F690 (size: 68) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_0050f690(int param_1)



{

  if (param_1 != DAT_00844d68) {

    if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

      return (float10)_DAT_007c7864;

    }

    return (float10)_DAT_007c7868;

  }

  if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

    return (float10)_DAT_007c785c;

  }

  return (float10)_DAT_007c7860;

}





// --- FUN_0050f6e0 at 0x0050F6E0 (size: 68) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



float10 __fastcall FUN_0050f6e0(int param_1)



{

  if (param_1 != DAT_00844d68) {

    if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

      return (float10)_DAT_007c7874;

    }

    return (float10)_DAT_007c7878;

  }

  if ((*(uint *)(param_1 + 0x4c) & 0xffff) < 0x100) {

    return (float10)_DAT_007c786c;

  }

  return (float10)_DAT_007c7870;

}





// --- FUN_0050f730 at 0x0050F730 (size: 18) ---


undefined4 __fastcall FUN_0050f730(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 200) != 0) {

    uVar1 = FUN_00555ee0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f750 at 0x0050F750 (size: 173) ---


undefined4 __thiscall

FUN_0050f750(int param_1,undefined4 param_2,float param_3,int param_4,float param_5)



{

  undefined4 uVar1;

  float10 fVar2;

  undefined4 local_8;

  undefined4 local_4;

  

  if (((*(int *)(param_1 + 0x40) == 0) && ((*(uint *)(param_1 + 0xa8) & 0x10) == 0)) &&

     ((*(uint *)(param_1 + 0xa8) & 0x200000) == 0)) {

    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;

    }

    uVar1 = FUN_005377f0(param_1 + 0x48,local_4,local_8,param_2,param_4 + 4,param_4 + 0xc,

                         param_3 * *(float *)(param_4 + 0x14) + param_5,

                         param_3 * *(float *)(param_4 + 0x18));

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f800 at 0x0050F800 (size: 85) ---


void __thiscall

FUN_0050f800(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            ,undefined4 param_6)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x124) == 0) {

    iVar1 = FUN_005df0f5(0x18);

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051af50(param_1);

    }

    *(undefined4 *)(param_1 + 0x124) = uVar2;

  }

  FUN_0051b760(param_2,param_3,param_4,param_5,param_6);

  return;

}





// --- FUN_0050f860 at 0x0050F860 (size: 16) ---


void __fastcall FUN_0050f860(int param_1)



{

  if (*(int *)(param_1 + 0x124) != 0) {

    FUN_0051b310();

    return;

  }

  return;

}





// --- FUN_0050f870 at 0x0050F870 (size: 28) ---


void __thiscall FUN_0050f870(int param_1,undefined4 param_2,undefined4 param_3)



{

  if (*(int *)(param_1 + 0x124) != 0) {

    FUN_0051b040(param_2,param_3);

  }

  return;

}





// --- FUN_0050f890 at 0x0050F890 (size: 28) ---


float10 __fastcall FUN_0050f890(int param_1)



{

  int iVar1;

  

  if ((*(int *)(param_1 + 0x124) != 0) &&

     (iVar1 = *(int *)(*(int *)(param_1 + 0x124) + 4), iVar1 != 0)) {

    return (float10)*(double *)(iVar1 + 0x10);

  }

  return (float10)DAT_00796344;

}





// --- FUN_0050f8b0 at 0x0050F8B0 (size: 18) ---


void __fastcall FUN_0050f8b0(int param_1)



{

  if (*(int *)(param_1 + 0x124) != 0) {

    FUN_0051b460();

    return;

  }

  return;

}





// --- FUN_0050f8d0 at 0x0050F8D0 (size: 80) ---


void __thiscall FUN_0050f8d0(int param_1,undefined4 param_2,undefined4 param_3,float param_4)



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x124) == 0) {

    iVar1 = FUN_005df0f5();

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051af50();

    }

    *(undefined4 *)(param_1 + 0x124) = uVar2;

  }

  FUN_0051b360(param_2,param_3,(double)param_4);

  return;

}





// --- FUN_0050f920 at 0x0050F920 (size: 20) ---


undefined4 __fastcall FUN_0050f920(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x124) != 0) {

    uVar1 = FUN_0051b8c0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050f940 at 0x0050F940 (size: 479) ---


/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */



void __thiscall FUN_0050f940(int param_1,undefined4 param_2,float param_3)



{

  float fVar1;

  float10 fVar2;

  

  if ((*(byte *)(param_1 + 0xac) & 2) != 0) {

    if ((*(uint *)(param_1 + 0xa8) & 0x800000) == 0) {

      fVar1 = *(float *)(param_1 + 0x130) * *(float *)(param_1 + 0xe0) +

              *(float *)(param_1 + 0x134) * *(float *)(param_1 + 0xe4) +

              *(float *)(param_1 + 0x138) * *(float *)(param_1 + 0xe8);

      if (fVar1 < _DAT_007c78a0) {

        *(float *)(param_1 + 0xe0) =

             *(float *)(param_1 + 0xe0) - fVar1 * *(float *)(param_1 + 0x130);

        *(float *)(param_1 + 0xe4) =

             *(float *)(param_1 + 0xe4) - fVar1 * *(float *)(param_1 + 0x134);

        *(float *)(param_1 + 0xe8) =

             *(float *)(param_1 + 0xe8) - fVar1 * *(float *)(param_1 + 0x138);

        goto LAB_0050fad8;

      }

    }

    else {

      fVar1 = *(float *)(param_1 + 0xe0) * *(float *)(param_1 + 0x130) +

              *(float *)(param_1 + 0xe4) * *(float *)(param_1 + 0x134) +

              *(float *)(param_1 + 0xe8) * *(float *)(param_1 + 0x138);

      if (fVar1 < _DAT_007c78a0) {

        *(float *)(param_1 + 0xe0) =

             *(float *)(param_1 + 0xe0) - fVar1 * *(float *)(param_1 + 0x130);

        *(float *)(param_1 + 0xe4) =

             *(float *)(param_1 + 0xe4) - fVar1 * *(float *)(param_1 + 0x134);

        *(float *)(param_1 + 0xe8) =

             *(float *)(param_1 + 0xe8) - fVar1 * *(float *)(param_1 + 0x138);

        if (((float)_DAT_007c78d8 <= param_3) && ((float)_DAT_007c78d0 <= param_3)) {

          fcos((float10)_DAT_007c78c8);

        }

LAB_0050fad8:

        fVar2 = (float10)_CIpow();

        *(float *)(param_1 + 0xe0) = (float)(fVar2 * (float10)*(float *)(param_1 + 0xe0));

        *(float *)(param_1 + 0xe4) = (float)(fVar2 * (float10)*(float *)(param_1 + 0xe4));

        *(float *)(param_1 + 0xe8) = (float)(fVar2 * (float10)*(float *)(param_1 + 0xe8));

        return;

      }

    }

  }

  return;

}





// --- FUN_0050fb20 at 0x0050FB20 (size: 737) ---


int __thiscall FUN_0050fb20(int param_1,uint param_2)



{

  undefined4 uVar1;

  int iVar2;

  int iVar3;

  int iVar4;

  uint uVar5;

  uint uVar6;

  bool bVar7;

  int local_c;

  int iStack_8;

  

  iVar2 = param_2;

  if ((((*(uint *)(param_1 + 0xa8) & 4) != 0) && ((*(uint *)(param_1 + 0xa8) & 0x10) != 0)) ||

     ((*(int **)(param_1 + 300) != (int *)0x0 &&

      (((*(byte *)(param_2 + 4) & 4) != 0 &&

       (iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x2c))(), iVar3 != 0)))))) {

    return 1;

  }

  if (((*(uint *)(param_1 + 0xa8) & 4) == 0) &&

     ((*(int *)(param_2 + 0x14) == 0 || ((*(uint *)(param_1 + 0xa8) & 1) != 0)))) {

    local_c = 0;

  }

  else {

    local_c = 1;

    if (*(int *)(param_2 + 0x178) != 0) {

      return 1;

    }

  }

  *(int *)(param_2 + 0x1cc) = local_c;

  if ((((((*(int **)(param_1 + 300) == (int *)0x0) ||

         (iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x10))(), iVar3 == 0)) ||

        ((*(uint *)(param_2 + 4) & 0x100) == 0)) ||

       ((bVar7 = true, (char)*(uint *)(param_2 + 4) < '\0' ||

        (iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x28))(), iVar3 != 0)))) ||

      (((*(uint *)(param_2 + 4) & 0x800) != 0 &&

       (iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x20))(), iVar3 != 0)))) ||

     (((*(uint *)(param_2 + 4) & 0x1000) != 0 &&

      (iVar3 = (**(code **)(**(int **)(param_1 + 300) + 0x24))(), iVar3 != 0)))) {

    bVar7 = false;

  }

  iVar3 = 1;

  iStack_8 = 0;

  if (((*(byte *)(param_1 + 0xa8) & 0x40) != 0) ||

     ((*(int **)(param_1 + 300) != (int *)0x0 &&

      (iVar4 = (**(code **)(**(int **)(param_1 + 300) + 0x2c))(), iVar4 != 0)))) {

    iStack_8 = 1;

  }

  if ((((*(uint *)(param_1 + 0xa8) & 0x10000) == 0) || (bVar7)) ||

     (iVar4 = FUN_0050d980(param_1), iVar4 != 0)) {

    if (((*(int *)(param_1 + 0x10) == 0) || (iVar4 = FUN_00518bb0(), iVar4 == 0)) ||

       ((bVar7 || (iVar4 = FUN_0050d980(param_1), iVar4 != 0)))) {

      if (((*(int *)(param_1 + 0x10) != 0) && (iVar4 = FUN_00518b90(), iVar4 != 0)) &&

         ((!bVar7 && (iVar4 = FUN_0050d980(param_1), iVar4 == 0)))) {

        for (param_2 = 0;

            (*(int *)(param_1 + 0x10) != 0 && (uVar6 = FUN_00518b90(), param_2 < uVar6));

            param_2 = param_2 + 1) {

          uVar1 = *(undefined4 *)(param_1 + 0x114);

          if (*(int *)(param_1 + 0x10) != 0) {

            FUN_00518ba0();

          }

          iVar3 = FUN_00538d10(param_1 + 0x48,uVar1,iVar2,iStack_8);

          if (iVar3 != 1) goto LAB_0050fd80;

        }

      }

    }

    else {

      for (uVar6 = 0; (*(int *)(param_1 + 0x10) != 0 && (uVar5 = FUN_00518bb0(), uVar6 < uVar5));

          uVar6 = uVar6 + 1) {

        uVar1 = *(undefined4 *)(param_1 + 0x114);

        if (*(int *)(param_1 + 0x10) != 0) {

          FUN_00518bc0();

        }

        iVar3 = FUN_0053c650(param_1 + 0x48,uVar1,param_2);

        if (iVar3 != 1) goto LAB_0050fd80;

      }

    }

  }

  else if ((*(int *)(param_1 + 0x10) != 0) && (iVar3 = FUN_00518cb0(param_2), iVar3 != 1)) {

LAB_0050fd80:

    if (*(int *)(iVar2 + 0x178) == 0) {

      if ((*(byte *)(param_1 + 0xa8) & 1) == 0) {

        if ((local_c == 0) && ((iStack_8 == 0 || ((*(uint *)(iVar2 + 4) & 0x400) == 0)))) {

          FUN_006b5d60(param_1,iVar3);

        }

        else {

          iVar3 = 1;

          *(undefined4 *)(iVar2 + 0x2b8) = 0;

          FUN_006b5d60(param_1,1);

        }

      }

      else if ((*(byte *)(iVar2 + 4) & 1) == 0) {

        *(undefined4 *)(iVar2 + 0x2ec) = 1;

      }

    }

  }

  *(undefined4 *)(iVar2 + 0x1cc) = 0;

  return iVar3;

}





// --- FUN_0050fe10 at 0x0050FE10 (size: 22) ---


void __thiscall FUN_0050fe10(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0x24) = param_2;

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_00518dc0();

    return;

  }

  return;

}





// --- FUN_0050fe30 at 0x0050FE30 (size: 80) ---


void __thiscall

FUN_0050fe30(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x128) == 0) {

    iVar1 = FUN_005df0f5(0xc);

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051c100();

    }

    *(undefined4 *)(param_1 + 0x128) = uVar2;

  }

  FUN_0051c1f0(param_1,param_2,param_3,param_4,param_5);

  return;

}





// --- FUN_0050fe80 at 0x0050FE80 (size: 80) ---


void __thiscall

FUN_0050fe80(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5

            )



{

  int iVar1;

  undefined4 uVar2;

  

  if (*(int *)(param_1 + 0x128) == 0) {

    iVar1 = FUN_005df0f5(0xc);

    if (iVar1 == 0) {

      uVar2 = 0;

    }

    else {

      uVar2 = FUN_0051c100();

    }

    *(undefined4 *)(param_1 + 0x128) = uVar2;

  }

  FUN_0051c3d0(param_1,param_2,param_3,param_4,param_5);

  return;

}





// --- FUN_0050fed0 at 0x0050FED0 (size: 20) ---


undefined4 __fastcall FUN_0050fed0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x128) != 0) {

    uVar1 = FUN_0051c2a0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050fef0 at 0x0050FEF0 (size: 20) ---


undefined4 __fastcall FUN_0050fef0(int param_1)



{

  undefined4 uVar1;

  

  if (*(int *)(param_1 + 0x128) != 0) {

    uVar1 = FUN_0051c2e0();

    return uVar1;

  }

  return 0;

}





// --- FUN_0050ff30 at 0x0050FF30 (size: 36) ---


bool __thiscall FUN_0050ff30(int param_1,undefined4 param_2,undefined4 param_3)



{

  bool bVar1;

  

  bVar1 = *(int *)(param_1 + 0x28) != 0;

  if (bVar1) {

    FUN_00551700(param_2,param_1,param_3);

  }

  return bVar1;

}





// --- FUN_0050ff60 at 0x0050FF60 (size: 24) ---


undefined4 FUN_0050ff60(undefined4 param_1)



{

  undefined4 uVar1;

  

  if (DAT_00844d64 != 0) {

    uVar1 = FUN_00508890(param_1);

    return uVar1;

  }

  return 0;

}





// --- FUN_0050ff80 at 0x0050FF80 (size: 10) ---


void FUN_0050ff80(undefined4 param_1)



{

  DAT_00844d64 = param_1;

  return;

}





// --- FUN_0050ff90 at 0x0050FF90 (size: 10) ---


void FUN_0050ff90(undefined4 param_1)



{

  DAT_00844d68 = param_1;

  return;

}





// --- FUN_0050ffa0 at 0x0050FFA0 (size: 32) ---


void __thiscall FUN_0050ffa0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 300) = param_2;

  if (*(int *)(param_1 + 0xc4) != 0) {

    FUN_00524c20();

    return;

  }

  return;

}





// --- FUN_0050ffc0 at 0x0050FFC0 (size: 37) ---


void __thiscall FUN_0050ffc0(int param_1,undefined4 param_2)



{

  *(undefined4 *)(param_1 + 0x4c) = param_2;

  if (((*(uint *)(param_1 + 0xa8) & 0x1000) == 0) && (*(int *)(param_1 + 0x10) != 0)) {

    FUN_00518900();

    return;

  }

  return;

}





// --- FUN_0050fff0 at 0x0050FFF0 (size: 15) ---


void __fastcall FUN_0050fff0(int param_1)



{

  if (*(int *)(param_1 + 0x10) != 0) {

    FUN_00518930();

    return;

  }

  return;

}





