/* @00496078 file=? name=FUN_00496078 */

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

undefined4 __thiscall FUN_00496078(void *this,undefined4 *param_1,int param_2)

{
  undefined4 *puVar1;
  int iVar2;
  int extraout_EAX;
  code *pcVar3;
  undefined4 *extraout_ECX;
  undefined4 *extraout_ECX_00;
  undefined4 *extraout_ECX_01;
  undefined4 *extraout_ECX_02;
  undefined4 *extraout_ECX_03;
  int iVar4;
  int *piVar5;
  undefined4 local_2c;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18;
  int local_14;
  uint local_10;
  uint local_c;
  uint local_8;
  
  iVar4 = 0;
  local_20 = DAT_00509850;
  local_1c = DAT_00509854;
  local_18 = DAT_00509858;
  local_2c = DAT_0050985c;
  local_28 = DAT_00509860;
  local_24 = _DAT_00509864;
  piVar5 = (int *)0x0;
  if (DAT_005097e8 != (char *)0x0) {
    *DAT_005097e8 = '\0';
  }
  for (; (param_1[2] == 0 && (iVar4 < param_2)); iVar4 = iVar4 + iVar2 + local_c) {
    iVar2 = FUN_004951f4(this,param_1,&local_8,&local_c);
    if (param_1[2] != 0) break;
    if ((int)local_8 < 0x2009) {
      if (local_8 == 0x2008) {
        FUN_00492fc4(param_1,(int *)&DAT_005097e8,(uint *)&DAT_005097f8,local_c);
        this = extraout_ECX;
      }
      else {
        if (local_8 != 0) {
          if (local_8 == 0x31) {
            FUN_00492df0(param_1,(char *)&local_20,3);
            FUN_00492df0(param_1,(char *)&local_2c,3);
            this = extraout_ECX_00;
            goto LAB_004961eb;
          }
          if (local_8 != 0x2000) goto LAB_004961cb;
        }
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX_02;
      }
    }
    else if (local_8 == 0x200a) {
      this = param_1;
      FUN_00492c84(param_1);
    }
    else if (local_8 == 0x2037) {
      piVar5 = FUN_004de55c(local_c);
      if (piVar5 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_bmfRead_failed_to_allocate_m_00509c47);
        FUN_00492ba0(param_1,local_c);
        return 0;
      }
      FUN_00492f10(param_1,(char *)piVar5,local_c);
      local_10 = local_c;
      this = extraout_ECX_01;
    }
    else {
LAB_004961cb:
      FUN_0049a300(1,s_dpl_bmfRead_got_unrecognized_blo_00509c7a);
      FUN_00492ba0(param_1,local_c);
      this = extraout_ECX_03;
    }
LAB_004961eb:
  }
  if ((DAT_005097e8 != (char *)0x0) && (*DAT_005097e8 != '\0')) {
    FUN_00497194(2,DAT_005097e8,2,(int *)param_1[0xc],&local_14,FUN_004897b8,FUN_00489a68);
    if ((local_14 == 0) && (extraout_EAX != 0)) {
      puVar1 = *(undefined4 **)(extraout_EAX + 0x18);
      FUN_0048c060((int)puVar1,local_20,local_1c,local_18,local_2c,local_28,local_24);
      FUN_0048d538(puVar1);
      if ((piVar5 != (int *)0x0) && (pcVar3 = (code *)FUN_00496644(), pcVar3 != (code *)0x0)) {
        (*pcVar3)(0xe,puVar1,piVar5,local_10);
      }
    }
    else if (extraout_EAX == 0) {
      FUN_0049a300(1,s_dpl_bmfRead_failed_to_lookup_ram_00509cae);
    }
    else {
      FUN_0049a300(1,s_dpl_bmfRead___ramp___s__already_d_00509cd6);
    }
  }
  if (piVar5 != (int *)0x0) {
    FUN_004de420(piVar5);
  }
  return 1;
}



/* @004962c4 file=? name=FUN_004962c4 */

undefined4 __thiscall FUN_004962c4(void *this,undefined4 *param_1)

{
  bool bVar1;
  undefined4 uVar2;
  void *this_00;
  void *this_01;
  void *extraout_ECX;
  void *extraout_ECX_00;
  void *extraout_ECX_01;
  void *extraout_ECX_02;
  void *extraout_ECX_03;
  void *extraout_ECX_04;
  void *extraout_ECX_05;
  void *this_02;
  void *extraout_ECX_06;
  uint local_c;
  uint local_8;
  
  bVar1 = true;
  param_1[2] = 0;
  param_1[10] = 0x3f800000;
  *(undefined1 *)(param_1 + 0xb) = 0;
  FUN_004951f4(this,param_1,&local_8,&local_c);
  if (param_1[2] == 0) {
    this_02 = this_00;
    if (local_8 == 3) {
      FUN_0049529c(this_00,param_1,local_c);
      FUN_004951f4(this_01,param_1,&local_8,&local_c);
      this_02 = extraout_ECX;
    }
    while ((param_1[2] == 0 && (bVar1))) {
      if ((int)local_8 < 0x21) {
        if (local_8 == 0x20) {
          FUN_00495440(param_1,local_c);
          this_02 = extraout_ECX_02;
        }
        else if (local_8 == 0) {
LAB_0049639d:
          FUN_00492ba0(param_1,local_c);
          this_02 = extraout_ECX_04;
        }
        else if (local_8 == 5) {
          bVar1 = false;
        }
        else {
          if (local_8 != 0x10) goto LAB_004963b0;
          if (DAT_005097d4 == 0) {
            FUN_00492ba0(param_1,local_c);
            this_02 = extraout_ECX_01;
          }
          else {
            FUN_00495a44(this_02,param_1,local_c);
            this_02 = extraout_ECX_00;
          }
        }
      }
      else if (local_8 == 0x30) {
        FUN_00496078(this_02,param_1,local_c);
        this_02 = extraout_ECX_03;
      }
      else {
        if (local_8 == 0x2000) goto LAB_0049639d;
LAB_004963b0:
        FUN_0049a300(1,s_dpl_bmfRead_got_unrecognized_blo_00509cff);
        FUN_00492ba0(param_1,local_c);
        this_02 = extraout_ECX_05;
      }
      if (bVar1) {
        FUN_004951f4(this_02,param_1,&local_8,&local_c);
        this_02 = extraout_ECX_06;
      }
    }
    if (param_1[2] == 0) {
      uVar2 = 1;
    }
    else {
      uVar2 = 0;
    }
  }
  else {
    uVar2 = 0;
  }
  return uVar2;
}



/* @00496408 file=? name=FUN_00496408 */

undefined4 __cdecl FUN_00496408(LPCSTR param_1,int param_2)

{
  char cVar1;
  undefined4 uVar2;
  int *piVar3;
  char *pcVar4;
  void *extraout_ECX;
  void *this;
  char *pcVar6;
  bool bVar7;
  char local_10 [8];
  undefined1 local_8;
  undefined3 uVar5;
  
  if (param_1 == (LPCSTR)0x0) {
    FUN_0049a300(1,s_dpl_bmfRead_got_no_file_to_open__00509d3b);
    uVar2 = 0;
  }
  else {
    if ((DAT_005097dc == (int *)0x0) &&
       (DAT_005097dc = FUN_004de55c(0x4000), DAT_005097dc == (int *)0x0)) {
      FUN_0049a300(1,s_dpl_bmfRead_failed_to_allocate_r_00509d5c);
      return 0;
    }
    piVar3 = FUN_004930c0(param_1,0x4000,DAT_005097dc,1);
    if (piVar3 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_bmfRead_failed_to_open_file___00509d87);
      uVar2 = 0;
    }
    else {
      piVar3[0xc] = param_2;
      FUN_00492f10(piVar3,local_10,8);
      local_8 = 0;
      pcVar4 = local_10;
      pcVar6 = &DAT_00509dad;
      this = extraout_ECX;
      do {
        cVar1 = *pcVar4;
        uVar5 = (undefined3)((uint)this >> 8);
        this = (void *)CONCAT31(uVar5,cVar1);
        bVar7 = cVar1 == *pcVar6;
        if (!bVar7) break;
        if (cVar1 == '\0') goto LAB_004964ed;
        cVar1 = pcVar4[1];
        this = (void *)CONCAT31(uVar5,cVar1);
        bVar7 = cVar1 == pcVar6[1];
        if (!bVar7) break;
        pcVar4 = pcVar4 + 2;
        pcVar6 = pcVar6 + 2;
        bVar7 = cVar1 == '\0';
      } while (!bVar7);
      if (bVar7) {
LAB_004964ed:
        uVar2 = FUN_004962c4(this,piVar3);
        FUN_00493188(piVar3);
      }
      else {
        FUN_0049a300(1,s_dpl_bmfRead___s__is_not_a_valid_b_00509db6);
        FUN_00493188(piVar3);
        uVar2 = 0;
      }
    }
  }
  return uVar2;
}



/* @00496508 file=? name=FUN_00496508 */

void __cdecl FUN_00496508(int param_1)

{
  if (param_1 != 0) {
    DAT_005097d4 = 1;
    return;
  }
  DAT_005097d4 = 0;
  return;
}



/* @00496530 file=? name=FUN_00496530 */

void __cdecl FUN_00496530(int param_1)

{
  if (param_1 != 0) {
    DAT_005097d8 = 1;
    return;
  }
  DAT_005097d8 = 0;
  return;
}



/* @00496558 file=? name=FUN_00496558 */

void FUN_00496558(void)

{
  if (DAT_005097dc != (int *)0x0) {
    FUN_004de420(DAT_005097dc);
    DAT_005097dc = (int *)0x0;
  }
  DAT_005097d4 = 1;
  DAT_005097d8 = 1;
  FUN_0049309c(&DAT_005097e0,(undefined4 *)&DAT_005097f0);
  FUN_0049309c(&DAT_005097e4,(undefined4 *)&DAT_005097f4);
  FUN_0049309c(&DAT_005097e8,(undefined4 *)&DAT_005097f8);
  FUN_0049309c(&DAT_00509800,(undefined4 *)&DAT_00509808);
  FUN_0049309c(&DAT_00509804,(undefined4 *)&DAT_0050980c);
  return;
}



/* @00496600 file=? name=FUN_00496600 */

void FUN_00496600(void)

{
  return;
}



/* @00496604 file=? name=FUN_00496604 */

void __cdecl FUN_00496604(undefined4 param_1)

{
  DAT_00509e90 = param_1;
  return;
}



/* @00496614 file=? name=FUN_00496614 */

undefined4 FUN_00496614(void)

{
  return DAT_00509e90;
}



/* @0049661c file=? name=FUN_0049661c */

void __cdecl FUN_0049661c(undefined4 param_1)

{
  DAT_00509e94 = param_1;
  return;
}



/* @0049662c file=? name=FUN_0049662c */

undefined4 FUN_0049662c(void)

{
  return DAT_00509e94;
}



/* @00496634 file=? name=FUN_00496634 */

void __cdecl FUN_00496634(undefined4 param_1)

{
  DAT_00509e98 = param_1;
  return;
}



/* @00496644 file=? name=FUN_00496644 */

undefined4 FUN_00496644(void)

{
  return DAT_00509e98;
}



/* @0049664c file=? name=FUN_0049664c */

void __cdecl FUN_0049664c(undefined4 param_1)

{
  DAT_00509e9c = param_1;
  return;
}



/* @0049665c file=? name=FUN_0049665c */

undefined4 FUN_0049665c(void)

{
  return DAT_00509e9c;
}



/* @00496664 file=? name=FUN_00496664 */

void FUN_00496664(void)

{
  DAT_00509e90 = 0;
  DAT_00509e94 = 0;
  DAT_00509e98 = 0;
  DAT_00509e9c = 0;
  return;
}



/* @00496684 file=? name=FUN_00496684 */

uint __cdecl
FUN_00496684(char *param_1,undefined4 *param_2,undefined4 *param_3,undefined4 *param_4,uint param_5,
            int *param_6)

{
  char *pcVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  char *pcVar5;
  undefined4 *puVar6;
  bool bVar7;
  undefined *local_18;
  undefined4 local_14;
  int local_10;
  int local_c;
  int local_8;
  
  local_8 = 0;
  local_18 = PTR_DAT_00509ed8;
  local_14 = DAT_00509edc;
  local_c = FUN_004d4a78(param_1);
  puVar6 = param_3 + local_8;
  do {
    pcVar5 = (char *)*puVar6;
    if (pcVar5 == (char *)0x0) {
      uVar4 = FUN_0049b3e4(param_1,(undefined4 *)*param_2,param_3,1,param_4,param_5,param_6,1);
      return uVar4;
    }
    iVar2 = FUN_004d4a78(pcVar5);
    if (iVar2 <= local_c) {
      pcVar3 = param_1 + (local_c - iVar2);
      do {
        if (*pcVar3 != *pcVar5) goto LAB_0049672b;
        bVar7 = true;
        if (*pcVar3 == '\0') break;
        pcVar1 = pcVar3 + 1;
        if (*pcVar1 != pcVar5[1]) goto LAB_0049672b;
        pcVar3 = pcVar3 + 2;
        pcVar5 = pcVar5 + 2;
        bVar7 = *pcVar1 == '\0';
      } while (!bVar7);
      if ((bVar7) &&
         (uVar4 = FUN_0049b3e4(param_1,(undefined4 *)*param_2,&local_18,1,param_4,param_5,&local_10,
                               1), uVar4 != 0)) {
        *param_6 = local_8;
        return 1;
      }
    }
LAB_0049672b:
    local_8 = local_8 + 1;
    puVar6 = puVar6 + 1;
  } while( true );
}



/* @00496764 file=? name=FUN_00496764 */

int * FUN_00496764(void)

{
  int *piVar1;
  
  piVar1 = FUN_004de2bc(1,4);
  if (piVar1 == (int *)0x0) {
    FUN_0049a300(1,s_dpl_NewFilepath_failed_to_alloca_00509ee1);
    return (int *)0x0;
  }
  return piVar1;
}



/* @00496794 file=? name=FUN_00496794 */

void __cdecl FUN_00496794(int *param_1)

{
  if (param_1 != (int *)0x0) {
    if ((int *)*param_1 != (int *)0x0) {
      FUN_0049b500((int *)*param_1);
    }
    FUN_004de420(param_1);
  }
  return;
}



/* @004967b8 file=? name=FUN_004967b8 */

undefined4 __cdecl FUN_004967b8(int *param_1,char *param_2,char *param_3,char *param_4)

{
  undefined4 uVar1;
  int *piVar2;
  int *piVar3;
  
  if (param_1 == (int *)0x0) {
    uVar1 = 0;
  }
  else {
    piVar2 = (int *)*param_1;
    if (piVar2 == (int *)0x0) {
      piVar2 = FUN_00496764();
      if (piVar2 == (int *)0x0) {
        return 0;
      }
      *param_1 = (int)piVar2;
    }
    if ((int *)*piVar2 != (int *)0x0) {
      FUN_0049b500((int *)*piVar2);
    }
    piVar3 = FUN_0049b2ac(param_2,param_3,param_4);
    *piVar2 = (int)piVar3;
    uVar1 = 1;
  }
  return uVar1;
}



/* @0049680c file=? name=FUN_0049680c */

int * __cdecl FUN_0049680c(undefined4 *param_1)

{
  int *piVar1;
  char *pcVar2;
  int iVar3;
  int iVar4;
  int local_8;
  
  iVar4 = 0;
  if (param_1 == (undefined4 *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    pcVar2 = (char *)FUN_0049b454(&local_8,(undefined4 *)*param_1);
    while (pcVar2 != (char *)0x0) {
      iVar3 = FUN_004d4a78(pcVar2);
      iVar4 = iVar3 + iVar4 + 1;
      pcVar2 = (char *)FUN_0049b464(&local_8);
    }
    if (iVar4 == 0) {
      piVar1 = (int *)0x0;
    }
    else {
      piVar1 = FUN_004de55c(iVar4 + 1);
      if (piVar1 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_GetFilePath_failed_to_alloca_00509f1e);
        piVar1 = (int *)0x0;
      }
      else {
        *(undefined1 *)piVar1 = 0;
        pcVar2 = (char *)FUN_0049b454(&local_8,(undefined4 *)*param_1);
        while (pcVar2 != (char *)0x0) {
          FUN_004d49b8((char *)piVar1,pcVar2);
          FUN_004d49b8((char *)piVar1,&DAT_00509f49);
          pcVar2 = (char *)FUN_0049b464(&local_8);
        }
        iVar4 = FUN_004d4a78((char *)piVar1);
        *(undefined1 *)((int)piVar1 + iVar4 + -1) = 0;
      }
    }
  }
  return piVar1;
}



/* @004968d8 file=? name=FUN_004968d8 */

undefined4 __cdecl FUN_004968d8(int *param_1,char *param_2,int param_3)

{
  undefined4 uVar1;
  int *piVar2;
  int iVar3;
  uint uVar4;
  
  if (param_1 == (int *)0x0) {
    uVar1 = 0;
  }
  else {
    piVar2 = (int *)*param_1;
    if (piVar2 == (int *)0x0) {
      piVar2 = FUN_00496764();
      if (piVar2 == (int *)0x0) {
        return 0;
      }
      *param_1 = (int)piVar2;
    }
    if (param_3 == 0) {
      uVar4 = 0;
    }
    else if (param_3 == 1) {
      uVar4 = 1;
    }
    else if (param_3 == 2) {
      uVar4 = 2;
    }
    else {
      uVar4 = 1;
    }
    iVar3 = FUN_0049b344(*piVar2,param_2,uVar4);
    *piVar2 = iVar3;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00496940 file=? name=FUN_00496940 */

int * FUN_00496940(void)

{
  int *piVar1;
  
  piVar1 = FUN_004de2bc(1,0xc);
  if (piVar1 == (int *)0x0) {
    FUN_0049a300(1,s_dpl_NewFileExtnFunc_failed_to_al_00509f4b);
    return (int *)0x0;
  }
  return piVar1;
}



/* @00496970 file=? name=FUN_00496970 */

void __cdecl FUN_00496970(int *param_1)

{
  int iVar1;
  
  if (param_1 != (int *)0x0) {
    for (iVar1 = 0; iVar1 < param_1[2]; iVar1 = iVar1 + 1) {
      FUN_004de420(*(int **)(*param_1 + iVar1 * 4));
    }
    FUN_004de420((int *)*param_1);
    FUN_004de420((int *)param_1[1]);
    FUN_004de420(param_1);
  }
  return;
}



/* @004969b0 file=? name=FUN_004969b0 */

undefined4 __cdecl FUN_004969b0(int *param_1,char *param_2,undefined4 param_3)

{
  char *pcVar1;
  undefined4 uVar2;
  int *piVar3;
  char *pcVar4;
  int *piVar5;
  int *piVar6;
  char *pcVar7;
  int iVar8;
  bool bVar9;
  
  if (param_1 == (int *)0x0) {
    uVar2 = 0;
  }
  else {
    piVar3 = (int *)*param_1;
    if (piVar3 == (int *)0x0) {
      piVar3 = FUN_00496940();
      if (piVar3 == (int *)0x0) {
        return 0;
      }
      *param_1 = (int)piVar3;
    }
    for (iVar8 = 0; iVar8 < piVar3[2]; iVar8 = iVar8 + 1) {
      pcVar7 = *(char **)(*piVar3 + iVar8 * 4);
      pcVar4 = param_2;
      do {
        if (*pcVar4 != *pcVar7) goto LAB_00496a1d;
        bVar9 = true;
        if (*pcVar4 == '\0') break;
        pcVar1 = pcVar4 + 1;
        if (*pcVar1 != pcVar7[1]) goto LAB_00496a1d;
        pcVar4 = pcVar4 + 2;
        pcVar7 = pcVar7 + 2;
        bVar9 = *pcVar1 == '\0';
      } while (!bVar9);
      if (bVar9) {
        *(undefined4 *)(piVar3[1] + iVar8 * 4) = param_3;
        return 1;
      }
LAB_00496a1d:
    }
    piVar5 = (int *)FUN_00402300(param_2);
    if (piVar5 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_AddFileExtnFunc_failed_to_al_00509f9b);
      uVar2 = 0;
    }
    else {
      if ((int *)*piVar3 == (int *)0x0) {
        piVar6 = FUN_004de55c((piVar3[2] + 2) * 4);
      }
      else {
        piVar6 = FUN_004de760((int *)*piVar3,(piVar3[2] + 2) * 4);
      }
      if (piVar6 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_AddFileExtnFunc_failed_to_al_00509fdf);
        FUN_004de420(piVar5);
        uVar2 = 0;
      }
      else {
        *piVar3 = (int)piVar6;
        *(undefined4 *)(*piVar3 + 4 + piVar3[2] * 4) = 0;
        if ((int *)piVar3[1] == (int *)0x0) {
          piVar6 = FUN_004de55c((piVar3[2] + 1) * 4);
        }
        else {
          piVar6 = FUN_004de760((int *)piVar3[1],(piVar3[2] + 1) * 4);
        }
        if (piVar6 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_AddFileExtnFunc_failed_to_al_0050a01c);
          FUN_004de420(piVar5);
          uVar2 = 0;
        }
        else {
          piVar3[1] = (int)piVar6;
          *(int **)(*piVar3 + piVar3[2] * 4) = piVar5;
          *(undefined4 *)(piVar3[1] + piVar3[2] * 4) = param_3;
          piVar3[2] = piVar3[2] + 1;
          uVar2 = 1;
        }
      }
    }
  }
  return uVar2;
}



/* @00496b08 file=? name=FUN_00496b08 */

undefined4 __cdecl FUN_00496b08(int *param_1,char *param_2)

{
  char *pcVar1;
  char *pcVar2;
  char *pcVar3;
  int iVar4;
  bool bVar5;
  
  if (param_1 != (int *)0x0) {
    for (iVar4 = 0; iVar4 < param_1[2]; iVar4 = iVar4 + 1) {
      pcVar3 = *(char **)(*param_1 + iVar4 * 4);
      pcVar2 = param_2;
      do {
        if (*pcVar2 != *pcVar3) goto LAB_00496b4d;
        bVar5 = true;
        if (*pcVar2 == '\0') break;
        pcVar1 = pcVar2 + 1;
        if (*pcVar1 != pcVar3[1]) goto LAB_00496b4d;
        pcVar2 = pcVar2 + 2;
        pcVar3 = pcVar3 + 2;
        bVar5 = *pcVar1 == '\0';
      } while (!bVar5);
      if (bVar5) {
        return *(undefined4 *)(param_1[1] + iVar4 * 4);
      }
LAB_00496b4d:
    }
  }
  return 0;
}



/* @00496b5c file=? name=FUN_00496b5c */

int * __cdecl FUN_00496b5c(int *param_1)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int local_8;
  
  local_8 = 0;
  if (param_1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    for (iVar3 = 0; iVar3 < param_1[2]; iVar3 = iVar3 + 1) {
      iVar2 = FUN_004d4a78(*(char **)(*param_1 + iVar3 * 4));
      local_8 = iVar2 + local_8 + 1;
    }
    if (local_8 == 0) {
      piVar1 = (int *)0x0;
    }
    else {
      piVar1 = FUN_004de55c(local_8 + 1);
      if (piVar1 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_GetFileExtnFuncExtensions_fa_0050a058);
        piVar1 = (int *)0x0;
      }
      else {
        *(undefined1 *)piVar1 = 0;
        for (iVar3 = 0; iVar3 < param_1[2]; iVar3 = iVar3 + 1) {
          FUN_004d49b8((char *)piVar1,*(char **)(*param_1 + iVar3 * 4));
          FUN_004d49b8((char *)piVar1,&DAT_0050a091);
        }
        iVar3 = FUN_004d4a78((char *)piVar1);
        *(undefined1 *)((int)piVar1 + iVar3 + -1) = 0;
      }
    }
  }
  return piVar1;
}



/* @00496c18 file=? name=FUN_00496c18 */

undefined4 __cdecl FUN_00496c18(uint param_1,uint param_2)

{
  if (param_2 == param_1) {
    return 0;
  }
  if (param_1 < param_2) {
    return 0xffffffff;
  }
  return 1;
}



/* @00496c3c file=? name=FUN_00496c3c */

void __cdecl FUN_00496c3c(undefined4 param_1)

{
  if (DAT_0050a0d0 != 0) {
    FUN_0049a300(1,s_dpl_SetHandleCacheSize___handle_c_0050a0d8);
    return;
  }
  DAT_0050a0d4 = param_1;
  return;
}



/* @00496c6c file=? name=FUN_00496c6c */

void __cdecl FUN_00496c6c(int param_1,undefined4 param_2)

{
  if (param_1 != 0) {
    if ((DAT_0050a0d0 == (int *)0x0) &&
       (DAT_0050a0d0 = FUN_0049a71c(DAT_0050a0d4,0x496c00,0x496c18), DAT_0050a0d0 == (int *)0x0)) {
      FUN_0049a300(1,s_dpl_CacheHandle_failed_to_create_0050a10f);
      return;
    }
    FUN_0049a5cc(DAT_0050a0d0,param_1,param_2);
  }
  return;
}



/* @00496cd0 file=? name=FUN_00496cd0 */

undefined4 __cdecl FUN_00496cd0(undefined4 param_1)

{
  undefined4 uVar1;
  
  if (DAT_0050a0d0 != (undefined4 *)0x0) {
    uVar1 = FUN_0049a584(DAT_0050a0d0,param_1);
    return uVar1;
  }
  return 0;
}



/* @00496cf0 file=? name=FUN_00496cf0 */

void __cdecl FUN_00496cf0(undefined4 param_1)

{
  if (DAT_0050a0d0 != (undefined4 *)0x0) {
    FUN_0049a610(DAT_0050a0d0,param_1,0,(undefined4 *)0x0);
  }
  return;
}



/* @00496d10 file=? name=FUN_00496d10 */

void FUN_00496d10(void)

{
  if (DAT_0050a0d0 != (int *)0x0) {
    FUN_0049a794(DAT_0050a0d0);
    DAT_0050a0d0 = (int *)0x0;
  }
  DAT_0050a0d4 = 0x209;
  return;
}



/* @00496d68 file=? name=FUN_00496d68 */

void __cdecl FUN_00496d68(undefined4 param_1)

{
  if (DAT_0050a17c != 0) {
    FUN_0049a300(1,s_dpl_SetMaterialItemCacheSize___m_0050a1fd);
    return;
  }
  DAT_0050a180 = param_1;
  return;
}



/* @00496d98 file=? name=FUN_00496d98 */

int * __cdecl FUN_00496d98(char *param_1)

{
  char *pcVar1;
  int *piVar2;
  uint uVar3;
  int *piVar4;
  char *pcVar5;
  char *pcVar6;
  int *piVar7;
  bool bVar8;
  char local_410 [1024];
  int *local_10;
  int local_c;
  int local_8;
  
  piVar7 = (int *)0x0;
  if (DAT_0050a190 == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_LookupMaterialFile___no_mate_0050a241);
    piVar7 = (int *)0x0;
  }
  else {
    if (DAT_0050a174 == (int *)0x0) {
      DAT_0050a174 = FUN_0049a71c(DAT_0050a178,0,0);
      if (DAT_0050a174 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a275);
        return (int *)0x0;
      }
    }
    else {
      piVar7 = (int *)FUN_0049a584(DAT_0050a174,param_1);
    }
    if (piVar7 == (int *)0x0) {
      uVar3 = FUN_00496684(param_1,DAT_0050a190,&PTR_DAT_0050a194,(undefined4 *)local_410,0x400,
                           &local_8);
      if (uVar3 == 0) {
        piVar7 = (int *)0x0;
      }
      else {
        piVar7 = (int *)FUN_0049a584(DAT_0050a174,local_410);
        if (piVar7 == (int *)0x0) {
          local_c = 0;
          piVar7 = FUN_004de55c(0x14);
          if (piVar7 == (int *)0x0) {
            FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a2a9);
            return (int *)0x0;
          }
          piVar4 = (int *)FUN_00402300(local_410);
          if (piVar4 == (int *)0x0) {
            FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a2db);
            FUN_004de420(piVar7);
            return (int *)0x0;
          }
          local_10 = (int *)FUN_00402300(param_1);
          if (local_10 == (int *)0x0) {
            FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a30c);
            FUN_004de420(piVar4);
            FUN_004de420(piVar7);
            return (int *)0x0;
          }
          piVar7[1] = (int)local_10;
          piVar7[2] = DAT_0050a184;
          if (local_8 == 0) {
            *piVar7 = 0;
            local_c = FUN_00496408(local_410,(int)piVar7);
          }
          if (local_c == 0) {
            FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a33e);
            FUN_004de420(local_10);
            FUN_004de420(piVar4);
            FUN_004de420(piVar7);
            return (int *)0x0;
          }
          piVar7[3] = local_c;
          piVar7[4] = 0;
          piVar2 = piVar7;
          if (DAT_0050a18c != (int *)0x0) {
            DAT_0050a18c[4] = (int)piVar7;
            piVar2 = DAT_0050a188;
          }
          DAT_0050a188 = piVar2;
          DAT_0050a184 = DAT_0050a184 + 1;
          DAT_0050a18c = piVar7;
          FUN_0049a5cc(DAT_0050a174,piVar4,piVar7);
        }
        pcVar6 = local_410;
        pcVar5 = param_1;
        do {
          if (*pcVar5 != *pcVar6) goto LAB_00496fcb;
          bVar8 = true;
          if (*pcVar5 == '\0') break;
          pcVar1 = pcVar5 + 1;
          if (*pcVar1 != pcVar6[1]) goto LAB_00496fcb;
          pcVar5 = pcVar5 + 2;
          pcVar6 = pcVar6 + 2;
          bVar8 = *pcVar1 == '\0';
        } while (!bVar8);
        if (!bVar8) {
LAB_00496fcb:
          pcVar6 = FUN_00402300(param_1);
          if (pcVar6 == (char *)0x0) {
            FUN_0049a300(1,s_dpl_LookupMaterialFile_failed_to_0050a378);
          }
          else {
            FUN_0049a5cc(DAT_0050a174,pcVar6,piVar7);
          }
        }
      }
    }
  }
  return piVar7;
}



/* @00497000 file=? name=FUN_00497000 */

uint __cdecl FUN_00497000(uint *param_1,uint param_2)

{
  char *pcVar1;
  uint uVar2;
  uint uVar3;
  
  uVar2 = param_1[1] << 2 | *param_1;
  for (pcVar1 = (char *)param_1[2]; *pcVar1 != '\0'; pcVar1 = pcVar1 + 1) {
    uVar2 = uVar2 * 0x10 + (int)*pcVar1;
    uVar3 = uVar2 & 0xf0000000;
    if (uVar3 != 0) {
      uVar2 = uVar2 ^ uVar3 >> 0x18 ^ uVar3;
    }
  }
  return uVar2 % param_2;
}



/* @00497044 file=? name=FUN_00497044 */

undefined4 __cdecl FUN_00497044(int *param_1,int *param_2)

{
  byte bVar1;
  undefined4 uVar2;
  byte *pbVar3;
  byte *pbVar4;
  bool bVar5;
  bool bVar6;
  
  if (*param_1 < *param_2) {
    uVar2 = 0xffffffff;
  }
  else if (*param_2 < *param_1) {
    uVar2 = 1;
  }
  else if (param_1[1] < param_2[1]) {
    uVar2 = 0xffffffff;
  }
  else if (param_2[1] < param_1[1]) {
    uVar2 = 1;
  }
  else {
    pbVar3 = (byte *)param_1[2];
    pbVar4 = (byte *)param_2[2];
    do {
      bVar1 = *pbVar3;
      bVar5 = bVar1 < *pbVar4;
      bVar6 = bVar1 == *pbVar4;
      if (!bVar6) break;
      bVar5 = false;
      bVar6 = true;
      if (bVar1 == 0) break;
      bVar1 = pbVar3[1];
      bVar5 = bVar1 < pbVar4[1];
      bVar6 = bVar1 == pbVar4[1];
      if (!bVar6) break;
      pbVar3 = pbVar3 + 2;
      pbVar4 = pbVar4 + 2;
      bVar5 = false;
      bVar6 = bVar1 == 0;
    } while (!bVar6);
    uVar2 = CONCAT31((int3)(-(uint)bVar5 >> 8),(byte)-(uint)bVar5 | !bVar6);
  }
  return uVar2;
}



/* @004970b0 file=? name=FUN_004970b0 */

int * FUN_004970b0(void)

{
  int *piVar1;
  
  piVar1 = FUN_0049a71c(DAT_0050a180,0x497000,0x497044);
  if (piVar1 == (int *)0x0) {
    FUN_0049a300(1,s_dpl_NewMaterialItemCache_failed_t_0050a3aa);
  }
  return piVar1;
}



/* @004970e8 file=? name=FUN_004970e8 */

int * __cdecl FUN_004970e8(int param_1,char *param_2,int param_3)

{
  int *piVar1;
  char *pcVar2;
  
  if ((DAT_0050a17c == (int *)0x0) && (DAT_0050a17c = FUN_004970b0(), DAT_0050a17c == (int *)0x0)) {
    return (int *)0x0;
  }
  piVar1 = FUN_004de2bc(1,0x1c);
  if (piVar1 == (int *)0x0) {
    FUN_0049a300(1,s_dpl_CacheMaterialItem_failed_to_a_0050a3db);
    piVar1 = (int *)0x0;
  }
  else {
    pcVar2 = FUN_00402300(param_2);
    piVar1[2] = (int)pcVar2;
    if (piVar1[2] == 0) {
      FUN_0049a300(1,s_dpl_CacheMaterialItem_failed_to_a_0050a415);
      FUN_004de420(piVar1);
      piVar1 = (int *)0x0;
    }
    else {
      *piVar1 = param_1;
      if (param_3 == 0) {
        piVar1[1] = 0;
      }
      else {
        piVar1[1] = *(int *)(param_3 + 8);
      }
      piVar1[3] = param_3;
      FUN_0049a5cc(DAT_0050a17c,piVar1,piVar1);
    }
  }
  return piVar1;
}



/* @00497194 file=? name=FUN_00497194 */

int * __cdecl
FUN_00497194(int param_1,char *param_2,byte param_3,int *param_4,int *param_5,undefined *param_6,
            undefined *param_7)

{
  code *pcVar1;
  int iVar2;
  int *unaff_EBX;
  int *piVar3;
  int local_18;
  int local_14;
  char *local_10;
  int local_c;
  char *local_8;
  
  piVar3 = (int *)0x0;
  if (param_2 == (char *)0x0) {
    return unaff_EBX;
  }
  if (param_4 == (int *)0x0) {
    if ((param_1 == 0) && (pcVar1 = (code *)FUN_0049665c(), pcVar1 != (code *)0x0)) {
      param_2 = (char *)(*pcVar1)(param_2);
    }
    local_8 = FUN_004d4c4c(param_2,':');
    if (local_8 == (char *)0x0) {
      local_14 = 0;
      local_10 = param_2;
    }
    else {
      *local_8 = '\0';
      param_4 = FUN_00496d98(param_2);
      if (param_4 == (int *)0x0) {
        FUN_0049a300(1,s_failed_to_find_material_file___s_0050a44f);
        *local_8 = ':';
        return unaff_EBX;
      }
      *local_8 = ':';
      local_14 = param_4[2];
      local_10 = local_8 + 1;
    }
  }
  else {
    local_14 = param_4[2];
    local_10 = param_2;
  }
  local_18 = param_1;
  if (DAT_0050a17c == (int *)0x0) {
    DAT_0050a17c = FUN_004970b0();
    if (DAT_0050a17c == (int *)0x0) {
      return unaff_EBX;
    }
  }
  else {
    piVar3 = (int *)FUN_0049a584(DAT_0050a17c,&local_18);
  }
  if (piVar3 == (int *)0x0) {
    if (param_4 == (int *)0x0) {
      if ((param_3 & 1) == 0) {
        iVar2 = 0;
        if ((param_6 != (undefined *)0x0) && (iVar2 = (*(code *)param_6)(), iVar2 == 0)) {
          return unaff_EBX;
        }
        piVar3 = FUN_004970e8(param_1,param_2,0);
        if (piVar3 == (int *)0x0) {
          if (iVar2 == 0) {
            return unaff_EBX;
          }
          if (param_7 == (undefined *)0x0) {
            return unaff_EBX;
          }
          (*(code *)param_7)(iVar2);
          return unaff_EBX;
        }
        piVar3[6] = iVar2;
        FUN_00496c6c(iVar2,piVar3);
      }
    }
    else {
      if (*param_4 != 0) {
        if (*param_4 == 1) {
          FUN_0049a300(1,s_dpl_LookupMaterialItem_does_not_y_0050a472);
          return unaff_EBX;
        }
        FUN_0049a300(1,s_dpl_LookupMaterialItem_unknown_m_0050a4b2);
        return unaff_EBX;
      }
      if ((param_3 & 1) != 0) {
        return unaff_EBX;
      }
      local_c = 0;
      if ((param_6 != (undefined *)0x0) && (local_c = (*(code *)param_6)(), local_c == 0)) {
        return unaff_EBX;
      }
      piVar3 = FUN_004970e8(param_1,param_2,(int)param_4);
      if (piVar3 == (int *)0x0) {
        if (local_c == 0) {
          return unaff_EBX;
        }
        if (param_7 == (undefined *)0x0) {
          return unaff_EBX;
        }
        (*(code *)param_7)(local_c);
        return unaff_EBX;
      }
      pcVar1 = (code *)FUN_00496614();
      if (pcVar1 != (code *)0x0) {
        iVar2 = 0;
        if (param_1 == 0) {
          iVar2 = 0xb;
        }
        else if (param_1 == 1) {
          iVar2 = 0xc;
        }
        else if (param_1 == 2) {
          iVar2 = 0xe;
        }
        if (iVar2 != 0) {
          (*pcVar1)(iVar2,local_c);
        }
      }
      piVar3[6] = local_c;
      FUN_00496c6c(local_c,piVar3);
    }
  }
  if (piVar3 != (int *)0x0) {
    if ((param_3 & 4) == 0) {
      piVar3[4] = piVar3[4] + 1;
    }
    if (param_5 != (int *)0x0) {
      *param_5 = piVar3[5];
    }
    if ((param_3 & 2) != 0) {
      piVar3[5] = 1;
    }
  }
  return unaff_EBX;
}



/* @004973f0 file=? name=FUN_004973f0 */

undefined4 __cdecl FUN_004973f0(int param_1,undefined4 *param_2,uint *param_3)

{
  char cVar1;
  int iVar2;
  int iVar3;
  int *piVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  
  pcVar7 = *(char **)(param_1 + 8);
  if (*(int *)(param_1 + 0xc) == 0) {
    iVar2 = FUN_004d4a78(pcVar7);
    uVar6 = iVar2 + 1;
  }
  else {
    iVar2 = FUN_004d4a78(*(char **)(*(int *)(param_1 + 0xc) + 4));
    iVar3 = FUN_004d4a78(pcVar7);
    uVar6 = iVar2 + iVar3 + 2;
  }
  if ((int)*param_3 < (int)uVar6) {
    if ((int)uVar6 < 0x50) {
      uVar6 = 0x50;
    }
    piVar4 = FUN_004de760((int *)*param_2,uVar6);
    if (piVar4 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_GetMaterialItemName_failed_t_0050a4e5);
      return 0;
    }
    *param_2 = piVar4;
    *param_3 = uVar6;
  }
  if (*(int *)(param_1 + 0xc) == 0) {
    uVar6 = 0xffffffff;
    do {
      pcVar8 = pcVar7;
      if (uVar6 == 0) break;
      uVar6 = uVar6 - 1;
      pcVar8 = pcVar7 + 1;
      cVar1 = *pcVar7;
      pcVar7 = pcVar8;
    } while (cVar1 != '\0');
    uVar6 = ~uVar6;
    pcVar7 = pcVar8 + -uVar6;
    pcVar8 = (char *)*param_2;
    for (uVar5 = uVar6 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
      *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
      pcVar7 = pcVar7 + 4;
      pcVar8 = pcVar8 + 4;
    }
    for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {
      *pcVar8 = *pcVar7;
      pcVar7 = pcVar7 + 1;
      pcVar8 = pcVar8 + 1;
    }
  }
  else {
    FUN_004d7f10((undefined1 *)*param_2,s__s__s_0050a523);
  }
  return 1;
}



/* @004974c4 file=? name=FUN_004974c4 */

int __cdecl
FUN_004974c4(int param_1,int *param_2,undefined4 *param_3,uint *param_4,int param_5,
            undefined4 *param_6)

{
  int *piVar1;
  int iVar2;
  
  if (DAT_0050a17c != 0) {
    if (param_5 == 0) {
      piVar1 = (int *)FUN_0049a814(param_2,(undefined4 *)0x0);
    }
    else {
      piVar1 = (int *)FUN_0049a7b8(param_2,DAT_0050a17c,(undefined4 *)0x0);
    }
    while (piVar1 != (int *)0x0) {
      if (param_1 == *piVar1) {
        if (param_6 != (undefined4 *)0x0) {
          iVar2 = FUN_004973f0((int)piVar1,param_3,param_4);
          if (iVar2 == 0) {
            *param_6 = 0;
            return piVar1[6];
          }
          *param_6 = *param_3;
        }
        return piVar1[6];
      }
      piVar1 = (int *)FUN_0049a814(param_2,(undefined4 *)0x0);
    }
  }
  return 0;
}



/* @00497558 file=? name=FUN_00497558 */

undefined4 __cdecl FUN_00497558(undefined4 param_1,undefined4 *param_2,uint *param_3)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    iVar1 = FUN_004973f0(iVar1,param_2,param_3);
    if (iVar1 == 0) {
      uVar2 = 0;
    }
    else {
      uVar2 = *param_2;
    }
  }
  return uVar2;
}



/* @00497590 file=? name=FUN_00497590 */

void __cdecl FUN_00497590(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0x10) = *(int *)(iVar1 + 0x10) + 1;
  }
  return;
}



/* @004975a8 file=? name=FUN_004975a8 */

void __cdecl FUN_004975a8(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0x10) = *(int *)(iVar1 + 0x10) + -1;
  }
  return;
}



/* @004975c0 file=? name=FUN_004975c0 */

undefined4 * FUN_004975c0(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_004897a0();
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0048ba98((int)puVar1,0x3f800000,0,0);
    FUN_0048bc10((int)puVar1,0x3f800000,0,0);
    FUN_0048bb54((int)puVar1,0,0,0);
    FUN_0048bd94((int)puVar1,0x3f800000,0x3f800000,0x3f800000);
    FUN_0048bccc((int)puVar1,0,0,0,0x3f800000);
    FUN_0048d4d4(puVar1);
  }
  return puVar1;
}



/* @0049763c file=? name=FUN_0049763c */

undefined4 * FUN_0049763c(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_004897b8();
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0048c060((int)puVar1,0,0,0,0x3f800000,0x3f800000,0x3f800000);
    FUN_0048d538(puVar1);
  }
  return puVar1;
}



/* @00497678 file=? name=FUN_00497678 */

undefined4 __cdecl FUN_00497678(char *param_1,byte param_2,int *param_3)

{
  int extraout_EAX;
  
  FUN_00497194(0,param_1,param_2,(int *)0x0,param_3,FUN_004975c0,FUN_00489a28);
  if (extraout_EAX != 0) {
    return *(undefined4 *)(extraout_EAX + 0x18);
  }
  return 0;
}



/* @004976ac file=? name=FUN_004976ac */

void __cdecl FUN_004976ac(undefined4 param_1)

{
  FUN_00497590(param_1);
  return;
}



/* @004976bc file=? name=FUN_004976bc */

void __cdecl FUN_004976bc(undefined4 param_1)

{
  FUN_004975a8(param_1);
  return;
}



/* @004976cc file=? name=FUN_004976cc */

void __cdecl FUN_004976cc(undefined4 *param_1)

{
  FUN_004974c4(0,(int *)&DAT_00524b14,&DAT_0050a19c,(uint *)&DAT_0050a1a0,1,param_1);
  return;
}



/* @004976f0 file=? name=FUN_004976f0 */

void __cdecl FUN_004976f0(undefined4 *param_1)

{
  FUN_004974c4(0,(int *)&DAT_00524b14,&DAT_0050a19c,(uint *)&DAT_0050a1a0,0,param_1);
  return;
}



/* @00497714 file=? name=FUN_00497714 */

void __cdecl FUN_00497714(undefined4 param_1)

{
  FUN_00497558(param_1,&DAT_0050a19c,(uint *)&DAT_0050a1a0);
  return;
}



/* @00497730 file=? name=FUN_00497730 */

undefined4 __cdecl FUN_00497730(char *param_1,byte param_2,int *param_3)

{
  int extraout_EAX;
  
  FUN_00497194(1,param_1,param_2,(int *)0x0,param_3,FUN_00489768,FUN_00489998);
  if (extraout_EAX != 0) {
    return *(undefined4 *)(extraout_EAX + 0x18);
  }
  return 0;
}



/* @00497764 file=? name=FUN_00497764 */

void __cdecl FUN_00497764(undefined4 param_1)

{
  FUN_00497590(param_1);
  return;
}



/* @00497774 file=? name=FUN_00497774 */

void __cdecl FUN_00497774(undefined4 param_1)

{
  FUN_004975a8(param_1);
  return;
}



/* @00497784 file=? name=FUN_00497784 */

void __cdecl FUN_00497784(undefined4 *param_1)

{
  FUN_004974c4(1,(int *)&DAT_00524b20,&DAT_0050a1a4,(uint *)&DAT_0050a1a8,1,param_1);
  return;
}



/* @004977a8 file=? name=FUN_004977a8 */

void __cdecl FUN_004977a8(undefined4 *param_1)

{
  FUN_004974c4(1,(int *)&DAT_00524b20,&DAT_0050a1a4,(uint *)&DAT_0050a1a8,0,param_1);
  return;
}



/* @004977cc file=? name=FUN_004977cc */

void __cdecl FUN_004977cc(undefined4 param_1)

{
  FUN_00497558(param_1,&DAT_0050a1a4,(uint *)&DAT_0050a1a8);
  return;
}



/* @004977e8 file=? name=FUN_004977e8 */

undefined4 __cdecl FUN_004977e8(char *param_1,byte param_2,int *param_3)

{
  int extraout_EAX;
  
  FUN_00497194(2,param_1,param_2,(int *)0x0,param_3,FUN_0049763c,FUN_00489a68);
  if (extraout_EAX != 0) {
    return *(undefined4 *)(extraout_EAX + 0x18);
  }
  return 0;
}



/* @0049781c file=? name=FUN_0049781c */

void __cdecl FUN_0049781c(undefined4 param_1)

{
  FUN_00497590(param_1);
  return;
}



/* @0049782c file=? name=FUN_0049782c */

void __cdecl FUN_0049782c(undefined4 param_1)

{
  FUN_004975a8(param_1);
  return;
}



/* @0049783c file=? name=FUN_0049783c */

void __cdecl FUN_0049783c(undefined4 *param_1)

{
  FUN_004974c4(2,(int *)&DAT_00524b2c,&DAT_0050a1ac,(uint *)&DAT_0050a1b0,1,param_1);
  return;
}



/* @00497860 file=? name=FUN_00497860 */

void __cdecl FUN_00497860(undefined4 *param_1)

{
  FUN_004974c4(2,(int *)&DAT_00524b2c,&DAT_0050a1ac,(uint *)&DAT_0050a1b0,0,param_1);
  return;
}



/* @00497884 file=? name=FUN_00497884 */

void __cdecl FUN_00497884(undefined4 param_1)

{
  FUN_00497558(param_1,&DAT_0050a1ac,(uint *)&DAT_0050a1b0);
  return;
}



/* @004978a0 file=? name=FUN_004978a0 */

void __cdecl FUN_004978a0(char *param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_004968d8(&DAT_0050a190,param_1,param_2);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_AddToMaterialFilePath_failed_0050a529);
  }
  return;
}



/* @004978d4 file=? name=FUN_004978d4 */

void __cdecl FUN_004978d4(char *param_1,char *param_2,char *param_3)

{
  int iVar1;
  
  iVar1 = FUN_004967b8(&DAT_0050a190,param_1,param_2,param_3);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_SetMaterialFilePath_failed_t_0050a565);
  }
  return;
}



/* @00497910 file=? name=FUN_00497910 */

void FUN_00497910(void)

{
  FUN_0049680c(DAT_0050a190);
  return;
}



/* @00497924 file=? name=FUN_00497924 */

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

void FUN_00497924(void)

{
  undefined4 uVar1;
  int iVar2;
  int *piVar3;
  int local_14 [3];
  int *local_8;
  
  uVar1 = 0;
  piVar3 = DAT_0050a188;
  if (DAT_0050a174 != (int *)0x0) {
    iVar2 = FUN_0049a7b8(local_14,(int)DAT_0050a174,&local_8);
    while (iVar2 != 0) {
      FUN_004de420(local_8);
      iVar2 = FUN_0049a814(local_14,&local_8);
    }
    FUN_0049a794(DAT_0050a174);
    DAT_0050a174 = (int *)0x0;
    uVar1 = DAT_0050a174;
    piVar3 = DAT_0050a188;
  }
  for (; DAT_0050a174 = (int *)uVar1, piVar3 != (int *)0x0; piVar3 = (int *)piVar3[4]) {
    FUN_004de420((int *)piVar3[1]);
    FUN_004de420(piVar3);
    uVar1 = DAT_0050a174;
  }
  DAT_0050a188 = (int *)0x0;
  DAT_0050a18c = 0;
  DAT_0050a178 = 0x3f;
  if (DAT_0050a17c != (int *)0x0) {
    piVar3 = (int *)FUN_0049a7b8(local_14,(int)DAT_0050a17c,(undefined4 *)0x0);
    while (piVar3 != (int *)0x0) {
      FUN_004de420(piVar3);
      piVar3 = (int *)FUN_0049a814(local_14,(undefined4 *)0x0);
    }
    FUN_0049a794(DAT_0050a17c);
    DAT_0050a17c = (int *)0x0;
  }
  DAT_0050a180 = 0x101;
  DAT_0050a184 = 1;
  if (DAT_0050a190 != (int *)0x0) {
    FUN_00496794(DAT_0050a190);
    DAT_0050a190 = (int *)0x0;
  }
  if (DAT_0050a19c != (int *)0x0) {
    FUN_004de420(DAT_0050a19c);
    DAT_0050a19c = (int *)0x0;
    _DAT_0050a1a0 = 0;
  }
  if (DAT_0050a1a4 != (int *)0x0) {
    FUN_004de420(DAT_0050a1a4);
    DAT_0050a1a4 = (int *)0x0;
    _DAT_0050a1a8 = 0;
  }
  if (DAT_0050a1ac != (int *)0x0) {
    FUN_004de420(DAT_0050a1ac);
    DAT_0050a1ac = (int *)0x0;
    _DAT_0050a1b0 = 0;
  }
  return;
}



/* @00497a88 file=? name=FUN_00497a88 */

void __cdecl FUN_00497a88(int *param_1)

{
  int *piVar1;
  
  while (param_1 != (int *)0x0) {
    piVar1 = (int *)param_1[1];
    FUN_004de420(param_1);
    param_1 = piVar1;
  }
  return;
}



/* @00497aa8 file=? name=FUN_00497aa8 */

int * __cdecl FUN_00497aa8(int *param_1,int param_2)

{
  int *piVar1;
  
  piVar1 = FUN_004de2bc(1,8);
  if (piVar1 == (int *)0x0) {
    FUN_0049a300(1,s_dpl_AddNameList_failed_to_alloca_0050a5df);
    piVar1 = (int *)0x0;
  }
  else {
    *piVar1 = param_2;
    piVar1[1] = *param_1;
    *param_1 = (int)piVar1;
  }
  return piVar1;
}



/* @00497b18 file=? name=FUN_00497b18 */

void __cdecl FUN_00497b18(char *param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_004968d8(&DAT_0050a65c,param_1,param_2);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_AddToObjectFilePath_failed_t_0050a6bc);
  }
  return;
}



/* @00497b4c file=? name=FUN_00497b4c */

void __cdecl FUN_00497b4c(char *param_1,char *param_2,char *param_3)

{
  int iVar1;
  
  iVar1 = FUN_004967b8(&DAT_0050a65c,param_1,param_2,param_3);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_SetObjectFilePath_failed_to_s_0050a6f6);
  }
  return;
}



/* @00497b88 file=? name=FUN_00497b88 */

void FUN_00497b88(void)

{
  FUN_0049680c(DAT_0050a65c);
  return;
}



/* @00497b9c file=? name=FUN_00497b9c */

void __cdecl FUN_00497b9c(char *param_1,undefined4 param_2)

{
  int iVar1;
  
  iVar1 = FUN_004969b0(&DAT_0050a660,param_1,param_2);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_SetExtnObjectLoadFunc_failed_0050a731);
  }
  return;
}



/* @00497bcc file=? name=FUN_00497bcc */

void __cdecl FUN_00497bcc(char *param_1)

{
  FUN_00496b08(DAT_0050a660,param_1);
  return;
}



/* @00497be4 file=? name=FUN_00497be4 */

void FUN_00497be4(void)

{
  FUN_00496b5c(DAT_0050a660);
  return;
}



/* @00497bf8 file=? name=FUN_00497bf8 */

void __cdecl FUN_00497bf8(char *param_1)

{
  char *pcVar1;
  
  if (DAT_0050a668 != (undefined4 *)0x0) {
    pcVar1 = FUN_00402300(param_1);
    if (pcVar1 == (char *)0x0) {
      FUN_0049a300(1,s_dpl_SetObjectName_failed_to_allo_0050a769);
      return;
    }
    *DAT_0050a668 = pcVar1;
  }
  return;
}



/* @00497c30 file=? name=FUN_00497c30 */

void __cdecl FUN_00497c30(undefined4 *param_1,uint param_2)

{
  int iVar1;
  int *piVar2;
  
  if (DAT_0050a668 != 0) {
    piVar2 = FUN_004de55c(param_2);
    if (piVar2 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_SetObjectSpecial_failed_to_a_0050a79f);
    }
    else {
      FUN_004d4918(piVar2,param_1,param_2);
      iVar1 = DAT_0050a668;
      *(int **)(DAT_0050a668 + 4) = piVar2;
      *(uint *)(iVar1 + 8) = param_2;
    }
  }
  return;
}



/* @00497c7c file=? name=FUN_00497c7c */

int * __cdecl
FUN_00497c7c(int param_1,char *param_2,undefined4 *param_3,uint param_4,int param_5,int param_6)

{
  int *piVar1;
  int *piVar2;
  int *piVar3;
  int *local_8;
  
  if (DAT_0050a668 == 0) {
    piVar1 = (int *)0x0;
  }
  else {
    if (param_1 == 0) {
      local_8 = (int *)(DAT_0050a668 + 0x1c);
    }
    else {
      if (param_1 != 1) {
        FUN_0049a300(1,s_dpl_AddObjectItem_unknown_object_0050a7db);
        return (int *)0x0;
      }
      local_8 = (int *)(DAT_0050a668 + 0x20);
    }
    piVar2 = (int *)FUN_00402300(param_2);
    if (piVar2 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_AddObjectItem_failed_to_allo_0050a807);
      piVar1 = (int *)0x0;
    }
    else {
      if ((param_3 == (undefined4 *)0x0) || (param_4 == 0)) {
        piVar3 = (int *)0x0;
        param_4 = 0;
      }
      else {
        piVar3 = FUN_004de55c(param_4);
        if (piVar3 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_AddObjectItem_failed_to_allo_0050a83d);
          FUN_004de420(piVar2);
          return (int *)0x0;
        }
        FUN_004d4918(piVar3,param_3,param_4);
      }
      piVar1 = FUN_004de2bc(1,0x1c);
      if (piVar1 == (int *)0x0) {
        FUN_0049a300(1,s_dpl_AddObjectItem_failed_to_allo_0050a876);
        if (piVar3 != (int *)0x0) {
          FUN_004de420(piVar3);
        }
        FUN_004de420(piVar2);
        piVar1 = (int *)0x0;
      }
      else {
        *piVar1 = (int)piVar2;
        piVar1[1] = (int)piVar3;
        piVar1[2] = param_4;
        piVar1[4] = param_5;
        piVar1[5] = param_6;
        piVar1[6] = *local_8;
        *local_8 = (int)piVar1;
        if (param_6 != 0) {
          FUN_00496c6c(param_6,piVar1);
        }
      }
    }
  }
  return piVar1;
}



/* @00497db4 file=? name=FUN_00497db4 */

void __cdecl FUN_00497db4(int *param_1)

{
  int iVar1;
  int *piVar2;
  code *pcVar3;
  
  iVar1 = FUN_0048c6bc((int)param_1);
  if (iVar1 != 0) {
    FUN_0048c654((int)param_1,0);
    FUN_004976bc(iVar1);
  }
  iVar1 = FUN_0048c6ec((int)param_1);
  if (iVar1 != 0) {
    FUN_0048c688((int)param_1,0);
    FUN_004976bc(iVar1);
  }
  while( true ) {
    piVar2 = (int *)FUN_0048a4d4((int)param_1,0);
    if (piVar2 == (int *)0x0) break;
    FUN_00489ff0((int)param_1,(int)piVar2);
    FUN_0049a300(4,s_deleting_geometry_0x_x__0050a8b3);
    FUN_00489b68(piVar2);
  }
  pcVar3 = (code *)FUN_0049662c();
  if (pcVar3 != (code *)0x0) {
    (*pcVar3)(9,param_1);
  }
  FUN_0049a300(4,s_deleting_geogroup_0x_x__0050a8cb);
  FUN_00489b28(param_1);
  return;
}



/* @00497e5c file=? name=FUN_00497e5c */

void __cdecl FUN_00497e5c(int *param_1)

{
  int *piVar1;
  int *piVar2;
  code *pcVar3;
  
  while( true ) {
    piVar2 = (int *)FUN_0048a464((int)param_1,0);
    if (piVar2 == (int *)0x0) break;
    FUN_00489f78((int)param_1,(int)piVar2);
    piVar1 = (int *)FUN_00496cd0(piVar2);
    if (piVar1 == (int *)0x0) {
      FUN_00497db4(piVar2);
    }
    else {
      piVar1[4] = 0;
      if (piVar1[3] < 1) {
        FUN_00497ed8(1,piVar1);
      }
    }
  }
  pcVar3 = (code *)FUN_0049662c();
  if (pcVar3 != (code *)0x0) {
    (*pcVar3)(8,param_1);
  }
  FUN_0049a300(4,s_deleting_lod_0x_x__0050a8e3);
  FUN_00489ae8(param_1);
  return;
}



/* @00497ed8 file=? name=FUN_00497ed8 */

void __cdecl FUN_00497ed8(int param_1,int *param_2)

{
  FUN_00496cf0(param_2[5]);
  if (param_1 == 0) {
    FUN_00497e5c((int *)param_2[5]);
  }
  else {
    if (param_1 != 1) {
      FUN_0049a300(1,s_dpl_DeleteObjectItem_unknown_obj_0050a8f6);
      return;
    }
    FUN_00497db4((int *)param_2[5]);
  }
  if ((int *)*param_2 != (int *)0x0) {
    FUN_004de420((int *)*param_2);
  }
  if ((int *)param_2[1] != (int *)0x0) {
    FUN_004de420((int *)param_2[1]);
  }
  FUN_004de420(param_2);
  return;
}



/* @00497f44 file=? name=FUN_00497f44 */

undefined4 __cdecl FUN_00497f44(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 == 0) {
    return 0;
  }
  return *(undefined4 *)(iVar1 + 0x10);
}



/* @00497f60 file=? name=FUN_00497f60 */

undefined4 __cdecl FUN_00497f60(undefined4 param_1)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00496cd0(param_1);
  if (puVar1 == (undefined4 *)0x0) {
    return 0;
  }
  return *puVar1;
}



/* @00497f7c file=? name=FUN_00497f7c */

undefined4 __cdecl FUN_00497f7c(undefined4 param_1,undefined4 *param_2)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 == 0) {
    return 0;
  }
  if (param_2 != (undefined4 *)0x0) {
    *param_2 = *(undefined4 *)(iVar1 + 8);
  }
  return *(undefined4 *)(iVar1 + 4);
}



/* @00497fa8 file=? name=FUN_00497fa8 */

undefined4 __cdecl FUN_00497fa8(undefined4 param_1)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00496cd0(param_1);
  if (puVar1 == (undefined4 *)0x0) {
    return 0;
  }
  return *puVar1;
}



/* @00497fc4 file=? name=FUN_00497fc4 */

undefined4 __cdecl FUN_00497fc4(undefined4 param_1)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00496cd0(param_1);
  if (puVar1 == (undefined4 *)0x0) {
    return 0;
  }
  return *puVar1;
}



/* @00497fe0 file=? name=FUN_00497fe0 */

undefined4 __cdecl FUN_00497fe0(undefined4 param_1,undefined4 *param_2)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 == 0) {
    return 0;
  }
  if (param_2 != (undefined4 *)0x0) {
    *param_2 = *(undefined4 *)(iVar1 + 8);
  }
  return *(undefined4 *)(iVar1 + 4);
}



/* @0049800c file=? name=FUN_0049800c */

undefined4 * __cdecl FUN_0049800c(int param_1,undefined4 param_2,char *param_3)

{
  char *pcVar1;
  undefined4 *puVar2;
  int iVar3;
  char *pcVar4;
  char *pcVar5;
  bool bVar6;
  
  iVar3 = FUN_00496cd0(param_2);
  if ((iVar3 != 0) && (param_3 != (char *)0x0)) {
    if (param_1 == 0) {
      puVar2 = *(undefined4 **)(iVar3 + 0x1c);
    }
    else {
      if (param_1 != 1) {
        FUN_0049a300(1,s_dpl_LookupObjectItem_unknown_obj_0050a925);
        return (undefined4 *)0x0;
      }
      puVar2 = *(undefined4 **)(iVar3 + 0x20);
    }
    for (; puVar2 != (undefined4 *)0x0; puVar2 = (undefined4 *)puVar2[6]) {
      pcVar4 = (char *)*puVar2;
      pcVar5 = param_3;
      do {
        if (*pcVar4 != *pcVar5) goto LAB_0049807f;
        bVar6 = true;
        if (*pcVar4 == '\0') break;
        pcVar1 = pcVar4 + 1;
        if (*pcVar1 != pcVar5[1]) goto LAB_0049807f;
        pcVar4 = pcVar4 + 2;
        pcVar5 = pcVar5 + 2;
        bVar6 = *pcVar1 == '\0';
      } while (!bVar6);
      if (bVar6) {
        return puVar2;
      }
LAB_0049807f:
    }
  }
  return (undefined4 *)0x0;
}



/* @0049808c file=? name=FUN_0049808c */

undefined4 __cdecl
FUN_0049808c(int param_1,int *param_2,int *param_3,int param_4,undefined4 *param_5)

{
  int in_EAX;
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  puVar3 = (undefined4 *)0x0;
  if (DAT_0050a654 == 0) {
    uVar1 = 0;
  }
  else {
    iVar2 = DAT_0050a664;
    if (param_4 == 0) {
      if (*param_3 == 0) {
        if (*param_2 == 0) {
          iVar2 = 0;
        }
        else {
          iVar2 = *(int *)(*param_2 + 0x2c);
        }
      }
      else {
        puVar3 = (undefined4 *)*param_3;
        iVar2 = in_EAX;
      }
    }
    if (puVar3 == (undefined4 *)0x0) {
      for (; iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x2c)) {
        if (param_1 == 0) {
          puVar3 = *(undefined4 **)(iVar2 + 0x1c);
        }
        else {
          if (param_1 != 1) {
            FUN_0049a300(1,s_dpl_IterateObjectItem_unknown_ob_0050a954);
            return 0;
          }
          puVar3 = *(undefined4 **)(iVar2 + 0x20);
        }
        if (puVar3 != (undefined4 *)0x0) break;
      }
      if (puVar3 == (undefined4 *)0x0) {
        *param_2 = 0;
        return 0;
      }
    }
    *param_2 = iVar2;
    *param_3 = puVar3[6];
    if (param_5 != (undefined4 *)0x0) {
      *param_5 = *puVar3;
    }
    uVar1 = puVar3[5];
  }
  return uVar1;
}



/* @0049812c file=? name=FUN_0049812c */

undefined4 __cdecl FUN_0049812c(undefined4 param_1,char *param_2,byte param_3,undefined4 *param_4)

{
  undefined4 *puVar1;
  
  puVar1 = FUN_0049800c(0,param_1,param_2);
  if (puVar1 != (undefined4 *)0x0) {
    if ((param_3 & 4) == 0) {
      puVar1[3] = puVar1[3] + 1;
    }
    if (param_4 != (undefined4 *)0x0) {
      *param_4 = 1;
    }
    return puVar1[5];
  }
  return 0;
}



/* @00498168 file=? name=FUN_00498168 */

void __cdecl FUN_00498168(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0xc) = *(int *)(iVar1 + 0xc) + 1;
  }
  return;
}



/* @00498180 file=? name=FUN_00498180 */

void __cdecl FUN_00498180(undefined4 param_1)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00496cd0(param_1);
  if (((piVar1 != (int *)0x0) && (piVar1[3] = piVar1[3] + -1, piVar1[3] < 1)) && (piVar1[4] == 0)) {
    FUN_00497ed8(0,piVar1);
  }
  return;
}



/* @004981b0 file=? name=FUN_004981b0 */

void __cdecl FUN_004981b0(undefined4 *param_1)

{
  FUN_0049808c(0,(int *)&DAT_0050a66c,(int *)&DAT_0050a670,1,param_1);
  return;
}



/* @004981d0 file=? name=FUN_004981d0 */

void __cdecl FUN_004981d0(undefined4 *param_1)

{
  FUN_0049808c(0,(int *)&DAT_0050a66c,(int *)&DAT_0050a670,0,param_1);
  return;
}



/* @004981f0 file=? name=FUN_004981f0 */

undefined4 __cdecl FUN_004981f0(undefined4 param_1,char *param_2,byte param_3,undefined4 *param_4)

{
  undefined4 *puVar1;
  
  puVar1 = FUN_0049800c(1,param_1,param_2);
  if (puVar1 != (undefined4 *)0x0) {
    if ((param_3 & 4) == 0) {
      puVar1[3] = puVar1[3] + 1;
    }
    if (param_4 != (undefined4 *)0x0) {
      *param_4 = 1;
    }
    return puVar1[5];
  }
  return 0;
}



/* @0049822c file=? name=FUN_0049822c */

void __cdecl FUN_0049822c(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 != 0) {
    *(int *)(iVar1 + 0xc) = *(int *)(iVar1 + 0xc) + 1;
  }
  return;
}



/* @00498244 file=? name=FUN_00498244 */

void __cdecl FUN_00498244(undefined4 param_1)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00496cd0(param_1);
  if (((piVar1 != (int *)0x0) && (piVar1[3] = piVar1[3] + -1, piVar1[3] < 1)) && (piVar1[4] == 0)) {
    FUN_00497ed8(1,piVar1);
  }
  return;
}



/* @00498274 file=? name=FUN_00498274 */

void __cdecl FUN_00498274(undefined4 *param_1)

{
  FUN_0049808c(1,(int *)&DAT_0050a674,(int *)&DAT_0050a678,1,param_1);
  return;
}



/* @00498294 file=? name=FUN_00498294 */

void __cdecl FUN_00498294(undefined4 *param_1)

{
  FUN_0049808c(1,(int *)&DAT_0050a674,(int *)&DAT_0050a678,0,param_1);
  return;
}



/* @004982b4 file=? name=FUN_004982b4 */

void __cdecl FUN_004982b4(undefined4 param_1)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  int *piVar7;
  code *pcVar8;
  
  piVar5 = (int *)FUN_00496cd0(param_1);
  if ((piVar5 != (int *)0x0) && (piVar5[6] = piVar5[6] + -1, piVar5[6] < 1)) {
    iVar1 = piVar5[9];
    FUN_0049a300(4,s_unloading_object___s___0050a984);
    iVar4 = piVar5[7];
    while (iVar4 != 0) {
      iVar2 = *(int *)(iVar4 + 0x18);
      *(undefined4 *)(iVar4 + 0x18) = 0;
      iVar4 = iVar2;
    }
    iVar4 = piVar5[8];
    while (iVar4 != 0) {
      iVar2 = *(int *)(iVar4 + 0x18);
      *(undefined4 *)(iVar4 + 0x18) = 0;
      iVar4 = iVar2;
    }
    while (piVar7 = (int *)FUN_0048a3f4(iVar1,0), piVar7 != (int *)0x0) {
      FUN_00489f00(iVar1,(int)piVar7);
      piVar6 = (int *)FUN_00496cd0(piVar7);
      if (piVar6 == (int *)0x0) {
        FUN_00497e5c(piVar7);
      }
      else {
        piVar6[4] = 0;
        if ((piVar6 != (int *)0x0) && (piVar6[3] < 1)) {
          FUN_00497ed8(0,piVar6);
        }
      }
    }
    FUN_00496cf0(piVar5[9]);
    if (piVar5[3] != 0) {
      FUN_0049a610(DAT_0050a654,piVar5[3],0,(undefined4 *)0x0);
      FUN_004de420((int *)piVar5[3]);
    }
    if ((int *)piVar5[4] != (int *)0x0) {
      FUN_004de420((int *)piVar5[4]);
    }
    puVar3 = (undefined4 *)piVar5[5];
    if (puVar3 != (undefined4 *)0x0) {
      for (; puVar3 != (undefined4 *)0x0; puVar3 = (undefined4 *)puVar3[1]) {
        FUN_0049a610(DAT_0050a654,*puVar3,0,(undefined4 *)0x0);
        FUN_004de420((int *)*puVar3);
      }
      FUN_00497a88((int *)piVar5[5]);
    }
    pcVar8 = (code *)FUN_0049662c();
    if (pcVar8 != (code *)0x0) {
      (*pcVar8)(7,piVar5[9]);
    }
    FUN_0049a300(4,s_deleting_object_0x_x__0050a99b);
    FUN_00489aa8((int *)piVar5[9]);
    iVar1 = piVar5[10];
    if ((iVar1 != 0) || (piVar5[0xb] != 0)) {
      if (iVar1 == 0) {
        DAT_0050a664 = piVar5[0xb];
      }
      else {
        *(int *)(iVar1 + 0x2c) = piVar5[0xb];
      }
      if (piVar5[0xb] != 0) {
        *(int *)(piVar5[0xb] + 0x28) = piVar5[10];
      }
    }
    FUN_004de420(piVar5);
  }
  return;
}



/* @00498448 file=? name=FUN_00498448 */

int __cdecl FUN_00498448(char *param_1,uint param_2)

{
  char *pcVar1;
  int iVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  int *piVar6;
  bool bVar7;
  char local_418 [1024];
  undefined4 local_18;
  int *local_14;
  int *local_10;
  int local_c;
  int local_8;
  
  piVar6 = (int *)0x0;
  FUN_0049a300(4,s_load_object___s___0050a9b1);
  if (DAT_0050a65c == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_LoadObject___no_object_file_p_0050a9c3);
    iVar2 = 0;
  }
  else if (DAT_0050a660 == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_LoadObject___no_object_file_e_0050a9ed);
    iVar2 = 0;
  }
  else {
    if ((param_2 & 1) == 0) {
      if (DAT_0050a654 == (int *)0x0) {
        DAT_0050a654 = FUN_0049a71c(DAT_0050a658,0,0);
        if (DAT_0050a654 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadObject_failed_to_create_f_0050aa1d);
          return 0;
        }
      }
      else {
        piVar6 = (int *)FUN_0049a584(DAT_0050a654,param_1);
      }
    }
    if (piVar6 == (int *)0x0) {
      uVar3 = FUN_00496684(param_1,DAT_0050a65c,(undefined4 *)*DAT_0050a660,(undefined4 *)local_418,
                           0x400,&local_8);
      if (uVar3 == 0) {
        return 0;
      }
      if ((param_2 & 1) == 0) {
        piVar6 = (int *)FUN_0049a584(DAT_0050a654,local_418);
      }
      if ((piVar6 == (int *)0x0) && ((param_2 & 2) == 0)) {
        local_c = 0;
        local_10 = (int *)0x0;
        local_18 = DAT_0050a668;
        piVar6 = FUN_004de2bc(1,0x30);
        if (piVar6 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadObject_failed_to_allocat_0050aa49);
          return 0;
        }
        if (((param_2 & 1) == 0) &&
           (local_10 = (int *)FUN_00402300(local_418), local_10 == (int *)0x0)) {
          FUN_0049a300(1,s_dpl_LoadObject_failed_to_copy_lo_0050aa73);
          FUN_004de420(piVar6);
          return 0;
        }
        local_14 = (int *)FUN_00402300(param_1);
        if (local_14 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadObject_failed_to_copy_sh_0050aa9c);
          if (local_10 != (int *)0x0) {
            FUN_004de420(local_10);
          }
          FUN_004de420(piVar6);
          return 0;
        }
        piVar6[4] = (int)local_14;
        DAT_0050a668 = piVar6;
        FUN_0049a300(4,s_loading_object___s___0050aac6);
        if (*(int *)(DAT_0050a660[1] + local_8 * 4) != 0) {
          local_c = (**(code **)(DAT_0050a660[1] + local_8 * 4))(local_418);
        }
        DAT_0050a668 = (int *)local_18;
        if (local_c == 0) {
          FUN_0049a300(1,s_dpl_LoadObject_failed_to_load_ob_0050aadb);
          FUN_004de420(local_14);
          if (local_10 != (int *)0x0) {
            FUN_004de420(local_10);
          }
          FUN_004de420(piVar6);
          return 0;
        }
        piVar6[9] = local_c;
        if ((param_2 & 1) == 0) {
          if (DAT_0050a664 != (int *)0x0) {
            DAT_0050a664[10] = (int)piVar6;
          }
          piVar6[0xb] = (int)DAT_0050a664;
          DAT_0050a664 = piVar6;
          piVar6[3] = (int)local_10;
          FUN_0049a5cc(DAT_0050a654,local_10,piVar6);
        }
        FUN_00496c6c(local_c,piVar6);
      }
      if ((piVar6 != (int *)0x0) && ((param_2 & 1) == 0)) {
        pcVar5 = local_418;
        pcVar4 = param_1;
        do {
          if (*pcVar4 != *pcVar5) goto LAB_0049874b;
          bVar7 = true;
          if (*pcVar4 == '\0') break;
          pcVar1 = pcVar4 + 1;
          if (*pcVar1 != pcVar5[1]) goto LAB_0049874b;
          pcVar4 = pcVar4 + 2;
          pcVar5 = pcVar5 + 2;
          bVar7 = *pcVar1 == '\0';
        } while (!bVar7);
        if (!bVar7) {
LAB_0049874b:
          pcVar5 = FUN_00402300(param_1);
          if (pcVar5 == (char *)0x0) {
            FUN_0049a300(1,s_dpl_LoadObject_failed_to_copy_sh_0050ab0b);
          }
          else {
            FUN_00497aa8(piVar6 + 5,(int)pcVar5);
            FUN_0049a5cc(DAT_0050a654,pcVar5,piVar6);
          }
        }
      }
    }
    if (piVar6 == (int *)0x0) {
      iVar2 = 0;
    }
    else {
      if ((param_2 & 4) == 0) {
        piVar6[6] = piVar6[6] + 1;
      }
      iVar2 = piVar6[9];
    }
  }
  return iVar2;
}



/* @004987a4 file=? name=FUN_004987a4 */

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

void FUN_004987a4(void)

{
  int *piVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  
  if (DAT_0050a654 != (int *)0x0) {
    FUN_0049a794(DAT_0050a654);
    DAT_0050a654 = (int *)0x0;
  }
  DAT_0050a658 = 0x209;
  piVar4 = DAT_0050a664;
  while (piVar4 != (int *)0x0) {
    piVar1 = (int *)piVar4[0xb];
    piVar3 = (int *)piVar4[7];
    while (piVar3 != (int *)0x0) {
      piVar2 = (int *)piVar3[6];
      if ((int *)*piVar3 != (int *)0x0) {
        FUN_004de420((int *)*piVar3);
      }
      if ((int *)piVar3[1] != (int *)0x0) {
        FUN_004de420((int *)piVar3[1]);
      }
      FUN_004de420(piVar3);
      piVar3 = piVar2;
    }
    piVar3 = (int *)piVar4[8];
    while (piVar3 != (int *)0x0) {
      piVar2 = (int *)piVar3[6];
      if ((int *)*piVar3 != (int *)0x0) {
        FUN_004de420((int *)*piVar3);
      }
      if ((int *)piVar3[1] != (int *)0x0) {
        FUN_004de420((int *)piVar3[1]);
      }
      FUN_004de420(piVar3);
      piVar3 = piVar2;
    }
    if ((int *)piVar4[3] != (int *)0x0) {
      FUN_004de420((int *)piVar4[3]);
    }
    if ((int *)piVar4[4] != (int *)0x0) {
      FUN_004de420((int *)piVar4[4]);
    }
    piVar3 = (int *)piVar4[5];
    if (piVar3 != (int *)0x0) {
      while (piVar3 != (int *)0x0) {
        piVar2 = (int *)piVar3[1];
        FUN_004de420((int *)*piVar3);
        FUN_004de420(piVar3);
        piVar3 = piVar2;
      }
    }
    FUN_004de420(piVar4);
    piVar4 = piVar1;
  }
  DAT_0050a664 = (int *)0x0;
  DAT_0050a668 = 0;
  if (DAT_0050a65c != (int *)0x0) {
    FUN_00496794(DAT_0050a65c);
    DAT_0050a65c = (int *)0x0;
  }
  if (DAT_0050a660 != (int *)0x0) {
    FUN_00496970(DAT_0050a660);
    DAT_0050a660 = (int *)0x0;
  }
  _DAT_0050a66c = 0;
  _DAT_0050a670 = 0;
  _DAT_0050a674 = 0;
  _DAT_0050a678 = 0;
  return;
}



/* @004988f8 file=? name=FUN_004988f8 */

undefined4 * __cdecl FUN_004988f8(undefined4 *param_1)

{
  short sVar1;
  short sVar2;
  short sVar3;
  undefined4 uVar4;
  byte *pbVar5;
  undefined4 *puVar6;
  uint uVar7;
  uint uVar8;
  byte *pbVar9;
  short sVar10;
  int local_14;
  int local_10;
  int local_c;
  int *local_8;
  
  uVar4 = FUN_00492cb4(param_1);
  sVar1 = (short)uVar4;
  FUN_00492ba0(param_1,2);
  uVar4 = FUN_00492cb4(param_1);
  sVar2 = (short)uVar4;
  uVar4 = FUN_00492cb4(param_1);
  sVar3 = (short)uVar4;
  uVar4 = FUN_00492cb4(param_1);
  sVar10 = (short)uVar4;
  if (sVar1 == 1) {
    FUN_00492ba0(param_1,500);
  }
  else {
    if (sVar1 != 0x101) {
      FUN_0049a300(1,s_dpl_sgiRead___not_a_known_SGI_fi_0050aba8);
      return (undefined4 *)0x0;
    }
    FUN_00492ba0(param_1,500);
    local_8 = FUN_004de55c((int)sVar3 * (int)sVar10 * 4);
    if (local_8 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_sgiRead_failed_to_allocate_R_0050ab78);
      return (undefined4 *)0x0;
    }
    FUN_00492df0(param_1,(char *)local_8,(int)sVar3 * (int)sVar10);
  }
  pbVar5 = (byte *)FUN_004de55c(((int)sVar2 * (int)sVar3 + 0x80) * (int)sVar10);
  if (pbVar5 == (byte *)0x0) {
    FUN_0049a300(1,s_dpl_sgiRead_could_not_allocate_m_0050abd1);
    puVar6 = (undefined4 *)0x0;
  }
  else {
    for (local_c = 0; local_c < sVar10; local_c = local_c + 1) {
      for (local_14 = 0; local_14 < sVar3; local_14 = local_14 + 1) {
        pbVar9 = pbVar5 + local_14 * (int)sVar2 * (int)sVar10 + (sVar10 - local_c) + -1;
        if (sVar1 == 1) {
          for (local_10 = 0; local_10 < sVar2; local_10 = local_10 + 1) {
            uVar4 = FUN_00492c84(param_1);
            *pbVar9 = (byte)uVar4;
            pbVar9 = pbVar9 + sVar10;
          }
        }
        else {
          FUN_00492c0c(param_1,local_8[sVar3 * local_c + local_14]);
          local_10 = 0;
          while (local_10 < sVar2) {
            uVar7 = FUN_00492c84(param_1);
            if ((char)uVar7 != '\0') {
              uVar8 = uVar7 & 0x7f;
              if ((uVar7 & 0x80) == 0) {
                uVar4 = FUN_00492c84(param_1);
                while (uVar8 != 0) {
                  *pbVar9 = (byte)uVar4;
                  pbVar9 = pbVar9 + sVar10;
                  uVar8 = uVar8 - 1;
                }
              }
              else {
                while (uVar8 != 0) {
                  uVar4 = FUN_00492c84(param_1);
                  *pbVar9 = (byte)uVar4;
                  pbVar9 = pbVar9 + sVar10;
                  uVar8 = uVar8 - 1;
                }
              }
              local_10 = local_10 + (uVar7 & 0x7f);
            }
          }
        }
      }
    }
    puVar6 = (undefined4 *)FUN_00489788();
    if (puVar6 == (undefined4 *)0x0) {
      FUN_0049a300(1,s_dpl_sgiRead_failed_to_create_dpl_0050ac05);
      puVar6 = (undefined4 *)0x0;
    }
    else {
      FUN_0048c32c((int)puVar6,(int)sVar2,(int)sVar3);
      FUN_0048c3c8((int)puVar6,(int)sVar10);
      FUN_0048c548((int)puVar6,pbVar5,0,(int)sVar2 * (int)sVar3);
      if (sVar1 == 0x101) {
        FUN_004de420(local_8);
      }
      FUN_004de420((int *)pbVar5);
      FUN_0048d5b0(puVar6);
    }
  }
  return puVar6;
}



/* @00498ba4 file=? name=FUN_00498ba4 */

undefined4 * __cdecl FUN_00498ba4(LPCSTR param_1)

{
  undefined4 *puVar1;
  int *piVar2;
  undefined4 uVar3;
  
  if (param_1 == (LPCSTR)0x0) {
    FUN_0049a300(1,s_dpl_sgiRead_got_no_file_to_open__0050ac2e);
    puVar1 = (undefined4 *)0x0;
  }
  else {
    if ((DAT_0050ab74 == (int *)0x0) &&
       (DAT_0050ab74 = FUN_004de55c(0x4000), DAT_0050ab74 == (int *)0x0)) {
      FUN_0049a300(1,s_dpl_sgiRead_failed_to_allocate_r_0050ac4f);
      return (undefined4 *)0x0;
    }
    piVar2 = FUN_004930c0(param_1,0x4000,DAT_0050ab74,0);
    if (piVar2 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_sgiRead_failed_to_open_file___0050ac7a);
      puVar1 = (undefined4 *)0x0;
    }
    else {
      uVar3 = FUN_00492cb4(piVar2);
      if ((short)uVar3 == 0x1da) {
        puVar1 = FUN_004988f8(piVar2);
        FUN_00493188(piVar2);
      }
      else {
        FUN_0049a300(1,s_dpl_sgiRead___s__is_not_a_valid_S_0050aca0);
        FUN_00493188(piVar2);
        puVar1 = (undefined4 *)0x0;
      }
    }
  }
  return puVar1;
}



/* @00498c68 file=? name=FUN_00498c68 */

void FUN_00498c68(void)

{
  if (DAT_0050ab74 != (int *)0x0) {
    FUN_004de420(DAT_0050ab74);
    DAT_0050ab74 = (int *)0x0;
  }
  return;
}



/* @00498c84 file=? name=FUN_00498c84 */

void __cdecl FUN_00498c84(undefined4 param_1)

{
  if (DAT_0050ad08 != 0) {
    FUN_0049a300(1,s_dpl_SetTexmapFileCacheSize___tex_0050ad1c);
    return;
  }
  DAT_0050ad0c = param_1;
  return;
}



/* @00498cb4 file=? name=FUN_00498cb4 */

void __cdecl FUN_00498cb4(char *param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_004968d8(&DAT_0050ad10,param_1,param_2);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_AddToTexmapFilePath_failed_t_0050ad5c);
  }
  return;
}



/* @00498ce8 file=? name=FUN_00498ce8 */

void __cdecl FUN_00498ce8(char *param_1,char *param_2,char *param_3)

{
  int iVar1;
  
  iVar1 = FUN_004967b8(&DAT_0050ad10,param_1,param_2,param_3);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_SetTexmapFilePath_failed_to_s_0050ad96);
  }
  return;
}



/* @00498d24 file=? name=FUN_00498d24 */

void FUN_00498d24(void)

{
  FUN_0049680c(DAT_0050ad10);
  return;
}



/* @00498d38 file=? name=FUN_00498d38 */

void __cdecl FUN_00498d38(char *param_1,undefined4 param_2)

{
  int iVar1;
  
  iVar1 = FUN_004969b0(&DAT_0050ad14,param_1,param_2);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_dpl_SetExtnTexmapLoadFunc_failed_0050add1);
  }
  return;
}



/* @00498d68 file=? name=FUN_00498d68 */

void __cdecl FUN_00498d68(char *param_1)

{
  FUN_00496b08(DAT_0050ad14,param_1);
  return;
}



/* @00498d80 file=? name=FUN_00498d80 */

void FUN_00498d80(void)

{
  FUN_00496b5c(DAT_0050ad14);
  return;
}



/* @00498d94 file=? name=FUN_00498d94 */

undefined4 __cdecl FUN_00498d94(undefined4 param_1)

{
  int iVar1;
  
  iVar1 = FUN_00496cd0(param_1);
  if (iVar1 == 0) {
    return 0;
  }
  return *(undefined4 *)(iVar1 + 4);
}



/* @00498db0 file=? name=FUN_00498db0 */

void __cdecl FUN_00498db0(undefined4 param_1)

{
  undefined4 *puVar1;
  int iVar2;
  int *piVar3;
  
  piVar3 = (int *)FUN_00496cd0(param_1);
  if ((piVar3 != (int *)0x0) && (piVar3[3] = piVar3[3] + -1, piVar3[3] < 1)) {
    FUN_0049a300(4,s_unloading_texmap___s___0050ae09);
    FUN_00496cf0(piVar3[4]);
    if (*piVar3 != 0) {
      FUN_0049a610(DAT_0050ad08,*piVar3,0,(undefined4 *)0x0);
      FUN_004de420((int *)*piVar3);
    }
    if ((int *)piVar3[1] != (int *)0x0) {
      FUN_004de420((int *)piVar3[1]);
    }
    puVar1 = (undefined4 *)piVar3[2];
    if (puVar1 != (undefined4 *)0x0) {
      for (; puVar1 != (undefined4 *)0x0; puVar1 = (undefined4 *)puVar1[1]) {
        FUN_0049a610(DAT_0050ad08,*puVar1,0,(undefined4 *)0x0);
        FUN_004de420((int *)*puVar1);
      }
      FUN_00497a88((int *)piVar3[2]);
    }
    FUN_0049a300(4,s_deleting_texmap_0x_x__0050ae20);
    FUN_004899d8((int *)piVar3[4]);
    iVar2 = piVar3[5];
    if ((iVar2 != 0) || (piVar3[6] != 0)) {
      if (iVar2 == 0) {
        DAT_0050ad18 = piVar3[6];
      }
      else {
        *(int *)(iVar2 + 0x18) = piVar3[6];
      }
      if (piVar3[6] != 0) {
        *(int *)(piVar3[6] + 0x14) = piVar3[5];
      }
    }
    FUN_004de420(piVar3);
  }
  return;
}



/* @00498eb4 file=? name=FUN_00498eb4 */

int __cdecl FUN_00498eb4(char *param_1,uint param_2)

{
  char *pcVar1;
  int iVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  int *piVar6;
  bool bVar7;
  char local_414 [1024];
  int *local_14;
  int *local_10;
  int local_c;
  int local_8;
  
  piVar6 = (int *)0x0;
  FUN_0049a300(4,s_load_texmap___s___0050ae36);
  if (DAT_0050ad10 == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_LoadTexmap___no_texmap_file_p_0050ae48);
    iVar2 = 0;
  }
  else if (DAT_0050ad14 == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_LoadTexmap___no_texmap_file_e_0050ae72);
    iVar2 = 0;
  }
  else {
    if ((param_2 & 1) == 0) {
      if (DAT_0050ad08 == (int *)0x0) {
        DAT_0050ad08 = FUN_0049a71c(DAT_0050ad0c,0,0);
        if (DAT_0050ad08 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_create_f_0050aea2);
          return 0;
        }
      }
      else {
        piVar6 = (int *)FUN_0049a584(DAT_0050ad08,param_1);
      }
    }
    if (piVar6 == (int *)0x0) {
      uVar3 = FUN_00496684(param_1,DAT_0050ad10,(undefined4 *)*DAT_0050ad14,(undefined4 *)local_414,
                           0x400,&local_8);
      if (uVar3 == 0) {
        return 0;
      }
      if ((param_2 & 1) == 0) {
        piVar6 = (int *)FUN_0049a584(DAT_0050ad08,local_414);
      }
      if ((piVar6 == (int *)0x0) && ((param_2 & 2) == 0)) {
        local_c = 0;
        local_10 = (int *)0x0;
        piVar6 = FUN_004de2bc(1,0x1c);
        if (piVar6 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_allocat_0050aece);
          return 0;
        }
        if (((param_2 & 1) == 0) &&
           (local_10 = (int *)FUN_00402300(local_414), local_10 == (int *)0x0)) {
          FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_copy_lo_0050aef8);
          FUN_004de420(piVar6);
          return 0;
        }
        local_14 = (int *)FUN_00402300(param_1);
        if (local_14 == (int *)0x0) {
          FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_copy_sh_0050af21);
          if (local_10 != (int *)0x0) {
            FUN_004de420(local_10);
          }
          FUN_004de420(piVar6);
          return 0;
        }
        piVar6[1] = (int)local_14;
        FUN_0049a300(4,s_loading_texmap___s___0050af4b);
        if (*(int *)(DAT_0050ad14[1] + local_8 * 4) != 0) {
          local_c = (**(code **)(DAT_0050ad14[1] + local_8 * 4))(local_414);
        }
        if (local_c == 0) {
          FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_load_te_0050af60);
          FUN_004de420(local_14);
          if (local_10 != (int *)0x0) {
            FUN_004de420(local_10);
          }
          FUN_004de420(piVar6);
          return 0;
        }
        piVar6[4] = local_c;
        if ((param_2 & 1) == 0) {
          if (DAT_0050ad18 != (int *)0x0) {
            DAT_0050ad18[5] = (int)piVar6;
          }
          piVar6[6] = (int)DAT_0050ad18;
          DAT_0050ad18 = piVar6;
          *piVar6 = (int)local_10;
          FUN_0049a5cc(DAT_0050ad08,local_10,piVar6);
        }
        FUN_00496c6c(local_c,piVar6);
      }
      if ((piVar6 != (int *)0x0) && ((param_2 & 1) == 0)) {
        pcVar5 = local_414;
        pcVar4 = param_1;
        do {
          if (*pcVar4 != *pcVar5) goto LAB_004991a0;
          bVar7 = true;
          if (*pcVar4 == '\0') break;
          pcVar1 = pcVar4 + 1;
          if (*pcVar1 != pcVar5[1]) goto LAB_004991a0;
          pcVar4 = pcVar4 + 2;
          pcVar5 = pcVar5 + 2;
          bVar7 = *pcVar1 == '\0';
        } while (!bVar7);
        if (!bVar7) {
LAB_004991a0:
          pcVar5 = FUN_00402300(param_1);
          if (pcVar5 == (char *)0x0) {
            FUN_0049a300(1,s_dpl_LoadTexmap_failed_to_copy_sh_0050af90);
          }
          else {
            FUN_00497aa8(piVar6 + 2,(int)pcVar5);
            FUN_0049a5cc(DAT_0050ad08,pcVar5,piVar6);
          }
        }
      }
    }
    if (piVar6 == (int *)0x0) {
      iVar2 = 0;
    }
    else {
      if ((param_2 & 4) == 0) {
        piVar6[3] = piVar6[3] + 1;
      }
      iVar2 = piVar6[4];
    }
  }
  return iVar2;
}



/* @004991f8 file=? name=FUN_004991f8 */

void FUN_004991f8(void)

{
  int *piVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  
  if (DAT_0050ad08 != (int *)0x0) {
    FUN_0049a794(DAT_0050ad08);
    DAT_0050ad08 = (int *)0x0;
  }
  DAT_0050ad0c = 0x3f;
  piVar4 = DAT_0050ad18;
  while (piVar4 != (int *)0x0) {
    piVar1 = (int *)piVar4[6];
    if ((int *)*piVar4 != (int *)0x0) {
      FUN_004de420((int *)*piVar4);
    }
    if ((int *)piVar4[1] != (int *)0x0) {
      FUN_004de420((int *)piVar4[1]);
    }
    piVar2 = (int *)piVar4[2];
    if (piVar2 != (int *)0x0) {
      while (piVar2 != (int *)0x0) {
        piVar3 = (int *)piVar2[1];
        FUN_004de420((int *)*piVar2);
        FUN_004de420(piVar2);
        piVar2 = piVar3;
      }
    }
    FUN_004de420(piVar4);
    piVar4 = piVar1;
  }
  DAT_0050ad18 = (int *)0x0;
  if (DAT_0050ad10 != (int *)0x0) {
    FUN_00496794(DAT_0050ad10);
    DAT_0050ad10 = (int *)0x0;
  }
  if (DAT_0050ad14 != (int *)0x0) {
    FUN_00496970(DAT_0050ad14);
    DAT_0050ad14 = (int *)0x0;
  }
  return;
}



/* @004992bc file=? name=FUN_004992bc */

undefined4 * __cdecl FUN_004992bc(undefined4 *param_1,int param_2)

{
  byte bVar1;
  undefined4 *puVar2;
  uint uVar3;
  undefined4 uVar4;
  byte *pbVar5;
  int unaff_ESI;
  int iVar6;
  int local_24;
  char local_20;
  char local_1f [3];
  byte local_1c;
  byte local_1b;
  undefined1 local_1a;
  byte local_19;
  byte *local_18;
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  if (*(char *)(param_2 + 0x12) == '\x01') {
    local_8 = 1;
  }
  else if ((*(char *)(param_2 + 0x12) == '\b') && (*(char *)(param_2 + 1) == '\0')) {
    local_8 = 1;
  }
  else if (*(char *)(param_2 + 0x12) == ' ') {
    local_8 = 4;
  }
  else {
    local_8 = 3;
  }
  local_18 = (byte *)FUN_004de55c((uint)*(ushort *)(param_2 + 0xe) *
                                  (uint)*(ushort *)(param_2 + 0x10) * local_8);
  if (local_18 == (byte *)0x0) {
    FUN_0049a300(1,s_dpl_tgaRead_failed_to_allocate_m_0050affc);
    puVar2 = (undefined4 *)0x0;
  }
  else {
    bVar1 = *(byte *)(param_2 + 0x13);
    if ((bVar1 & 0x20) == 0) {
      if ((bVar1 & 0x10) == 0) {
        local_c = local_8;
        local_10 = 0;
        pbVar5 = local_18;
      }
      else {
        local_c = -local_8;
        local_10 = (uint)*(ushort *)(param_2 + 0xe) * 2 * local_8;
        pbVar5 = local_18 + (*(ushort *)(param_2 + 0xe) - 1) * local_8;
      }
    }
    else if ((bVar1 & 0x10) == 0) {
      local_c = local_8;
      local_10 = -((uint)*(ushort *)(param_2 + 0xe) * 2 * local_8);
      pbVar5 = local_18 +
               (uint)*(ushort *)(param_2 + 0xe) * (*(ushort *)(param_2 + 0x10) - 1) * local_8;
    }
    else {
      local_c = -local_8;
      local_10 = 0;
      pbVar5 = local_18 +
               ((uint)*(ushort *)(param_2 + 0xe) * (uint)*(ushort *)(param_2 + 0x10) + -1) * local_8
      ;
    }
    if (*(byte *)(param_2 + 2) < 4) {
      for (local_14 = 0; local_14 < (int)(uint)*(ushort *)(param_2 + 0x10); local_14 = local_14 + 1)
      {
        bVar1 = *(byte *)(param_2 + 0x12);
        if (bVar1 < 0x11) {
          if (bVar1 == 0x10) {
            for (iVar6 = 0; iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe); iVar6 = iVar6 + 1) {
              uVar3 = FUN_00492cb4(param_1);
              *pbVar5 = (byte)((int)(uVar3 & 0xffff) >> 7) & 0xf8;
              pbVar5[1] = (byte)((int)(uVar3 & 0xffff) >> 2) & 0xf8;
              pbVar5[2] = (byte)(uVar3 << 3);
              pbVar5 = pbVar5 + local_c;
            }
          }
          else if (bVar1 == 1) {
            iVar6 = 0;
            while (iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe)) {
              uVar4 = FUN_00492c84(param_1);
              bVar1 = 0x80;
              for (; (bVar1 != 0 && (iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe)));
                  iVar6 = iVar6 + 1) {
                if ((bVar1 & (byte)uVar4) == 0) {
                  *pbVar5 = 0xff;
                }
                else {
                  *pbVar5 = 0;
                }
                pbVar5 = pbVar5 + local_c;
                bVar1 = bVar1 >> 1;
              }
            }
          }
          else if (bVar1 == 8) {
            if (local_8 == 1) {
              for (iVar6 = 0; iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe); iVar6 = iVar6 + 1) {
                uVar4 = FUN_00492c84(param_1);
                *pbVar5 = (byte)uVar4;
                pbVar5 = pbVar5 + local_c;
              }
            }
            else {
              for (iVar6 = 0; iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe); iVar6 = iVar6 + 1) {
                uVar3 = FUN_00492c84(param_1);
                FUN_004d4918((undefined4 *)pbVar5,
                             (undefined4 *)((uVar3 & 0xff) * 3 + param_2 + 0x14),3);
                pbVar5 = pbVar5 + local_c;
              }
            }
          }
        }
        else if (bVar1 == 0x18) {
          for (iVar6 = 0; iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe); iVar6 = iVar6 + 1) {
            FUN_00492f10(param_1,(char *)pbVar5,3);
            pbVar5 = pbVar5 + local_c;
          }
        }
        else if (bVar1 == 0x20) {
          for (iVar6 = 0; iVar6 < (int)(uint)*(ushort *)(param_2 + 0xe); iVar6 = iVar6 + 1) {
            FUN_00492f10(param_1,(char *)(pbVar5 + 1),3);
            uVar3 = FUN_00492c84(param_1);
            if ((uVar3 & 0x80) == 0) {
              *pbVar5 = 0xff;
            }
            else {
              *pbVar5 = (char)uVar3 * '\x02';
            }
            pbVar5 = pbVar5 + local_c;
          }
        }
        pbVar5 = pbVar5 + local_10;
      }
    }
    else {
      for (local_14 = 0; local_14 < (int)(uint)*(ushort *)(param_2 + 0x10); local_14 = local_14 + 1)
      {
        while (unaff_ESI < (int)(uint)*(ushort *)(param_2 + 0xe)) {
          uVar3 = FUN_00492c84(param_1);
          local_24 = (uVar3 & 0x7f) + 1;
          if ((uVar3 & 0x80) == 0) {
            bVar1 = *(byte *)(param_2 + 0x12);
            if (bVar1 < 0x11) {
              if (bVar1 == 0x10) {
                while (local_24 != 0) {
                  uVar3 = FUN_00492cb4(param_1);
                  *pbVar5 = (byte)((int)(uVar3 & 0xffff) >> 7) & 0xf8;
                  pbVar5[1] = (byte)((int)(uVar3 & 0xffff) >> 2) & 0xf8;
                  pbVar5[2] = (byte)(uVar3 << 3);
                  pbVar5 = pbVar5 + local_c;
                  unaff_ESI = unaff_ESI + 1;
                  local_24 = local_24 + -1;
                }
              }
              else if (bVar1 == 1) {
                while (iVar6 = local_24 + -1, local_24 != 0) {
                  uVar4 = FUN_00492c84(param_1);
                  local_19 = (byte)uVar4;
                  bVar1 = 0x80;
                  for (; (local_24 = iVar6, bVar1 != 0 &&
                         (unaff_ESI < (int)(uint)*(ushort *)(param_2 + 0xe)));
                      unaff_ESI = unaff_ESI + 1) {
                    if ((local_19 & bVar1) == 0) {
                      *pbVar5 = 0xff;
                    }
                    else {
                      *pbVar5 = 0;
                    }
                    pbVar5 = pbVar5 + local_c;
                    bVar1 = bVar1 >> 1;
                  }
                }
              }
              else if (bVar1 == 8) {
                if (local_8 == 1) {
                  while (local_24 != 0) {
                    uVar4 = FUN_00492c84(param_1);
                    *pbVar5 = (byte)uVar4;
                    pbVar5 = pbVar5 + local_c;
                    unaff_ESI = unaff_ESI + 1;
                    local_24 = local_24 + -1;
                  }
                }
                else {
                  while (local_24 != 0) {
                    uVar3 = FUN_00492c84(param_1);
                    local_19 = (byte)uVar3;
                    FUN_004d4918((undefined4 *)pbVar5,
                                 (undefined4 *)((uVar3 & 0xff) * 3 + param_2 + 0x14),3);
                    pbVar5 = pbVar5 + local_c;
                    unaff_ESI = unaff_ESI + 1;
                    local_24 = local_24 + -1;
                  }
                }
              }
            }
            else if (bVar1 == 0x18) {
              while (local_24 != 0) {
                FUN_00492f10(param_1,(char *)pbVar5,3);
                pbVar5 = pbVar5 + local_c;
                unaff_ESI = unaff_ESI + 1;
                local_24 = local_24 + -1;
              }
            }
            else if (bVar1 == 0x20) {
              while (local_24 != 0) {
                FUN_00492f10(param_1,(char *)(pbVar5 + 1),3);
                uVar3 = FUN_00492c84(param_1);
                if ((uVar3 & 0x80) == 0) {
                  *pbVar5 = 0xff;
                }
                else {
                  *pbVar5 = (char)uVar3 * '\x02';
                }
                pbVar5 = pbVar5 + local_c;
                unaff_ESI = unaff_ESI + 1;
                local_24 = local_24 + -1;
              }
            }
          }
          else {
            bVar1 = *(byte *)(param_2 + 0x12);
            if (bVar1 < 0x11) {
              if (bVar1 == 0x10) {
                uVar3 = FUN_00492cb4(param_1);
                local_1c = (byte)((int)(uVar3 & 0xffff) >> 7) & 0xf8;
                local_1b = (byte)((int)(uVar3 & 0xffff) >> 2) & 0xf8;
                local_1a = (undefined1)(uVar3 << 3);
                while (local_24 != 0) {
                  FUN_004d4918((undefined4 *)pbVar5,(undefined4 *)&local_1c,3);
                  pbVar5 = pbVar5 + local_c;
                  unaff_ESI = unaff_ESI + 1;
                  local_24 = local_24 + -1;
                }
              }
              else if (bVar1 == 1) {
                uVar4 = FUN_00492c84(param_1);
                local_19 = (byte)uVar4;
                while (iVar6 = local_24 + -1, local_24 != 0) {
                  bVar1 = 0x80;
                  for (; (local_24 = iVar6, bVar1 != 0 &&
                         (unaff_ESI < (int)(uint)*(ushort *)(param_2 + 0xe)));
                      unaff_ESI = unaff_ESI + 1) {
                    if ((local_19 & bVar1) == 0) {
                      *pbVar5 = 0xff;
                    }
                    else {
                      *pbVar5 = 0;
                    }
                    pbVar5 = pbVar5 + local_c;
                    bVar1 = bVar1 >> 1;
                  }
                }
              }
              else if (bVar1 == 8) {
                uVar4 = FUN_00492c84(param_1);
                local_19 = (byte)uVar4;
                if (local_8 == 1) {
                  while (local_24 != 0) {
                    *pbVar5 = local_19;
                    pbVar5 = pbVar5 + local_c;
                    unaff_ESI = unaff_ESI + 1;
                    local_24 = local_24 + -1;
                  }
                }
                else {
                  while (local_24 != 0) {
                    FUN_004d4918((undefined4 *)pbVar5,
                                 (undefined4 *)((uint)local_19 * 3 + param_2 + 0x14),3);
                    pbVar5 = pbVar5 + local_c;
                    unaff_ESI = unaff_ESI + 1;
                    local_24 = local_24 + -1;
                  }
                }
              }
            }
            else if (bVar1 == 0x18) {
              FUN_00492f10(param_1,(char *)&local_1c,3);
              while (local_24 != 0) {
                FUN_004d4918((undefined4 *)pbVar5,(undefined4 *)&local_1c,3);
                pbVar5 = pbVar5 + local_c;
                unaff_ESI = unaff_ESI + 1;
                local_24 = local_24 + -1;
              }
            }
            else if (bVar1 == 0x20) {
              FUN_00492f10(param_1,local_1f,3);
              uVar3 = FUN_00492c84(param_1);
              if ((uVar3 & 0x80) == 0) {
                local_20 = -1;
              }
              else {
                local_20 = (char)uVar3 * '\x02';
              }
              while (local_24 != 0) {
                FUN_004d4918((undefined4 *)pbVar5,(undefined4 *)&local_20,4);
                pbVar5 = pbVar5 + local_c;
                unaff_ESI = unaff_ESI + 1;
                local_24 = local_24 + -1;
              }
            }
          }
        }
        pbVar5 = pbVar5 + local_10;
      }
    }
    puVar2 = (undefined4 *)FUN_00489788();
    if (puVar2 == (undefined4 *)0x0) {
      FUN_0049a300(1,s_dpl_tgaRead_failed_to_create_dpl_0050b023);
      puVar2 = (undefined4 *)0x0;
    }
    else {
      FUN_0048c32c((int)puVar2,(uint)*(ushort *)(param_2 + 0xe),(uint)*(ushort *)(param_2 + 0x10));
      FUN_0048c3c8((int)puVar2,local_8);
      FUN_0048c548((int)puVar2,local_18,0,
                   (uint)*(ushort *)(param_2 + 0xe) * (uint)*(ushort *)(param_2 + 0x10));
      FUN_004de420((int *)local_18);
      FUN_0048d5b0(puVar2);
    }
  }
  return puVar2;
}



/* @00499918 file=? name=FUN_00499918 */

undefined4 * __cdecl FUN_00499918(undefined4 *param_1)

{
  undefined4 uVar1;
  undefined4 *puVar2;
  int iVar3;
  byte *pbVar4;
  uint uVar5;
  byte local_318;
  char local_317;
  char local_316;
  ushort local_314;
  ushort local_312;
  char local_310;
  undefined2 local_30e;
  undefined2 local_30c;
  undefined2 local_30a;
  undefined2 local_308;
  undefined1 local_306;
  undefined1 local_305;
  byte local_304 [768];
  
  uVar1 = FUN_00492c84(param_1);
  local_318 = (byte)uVar1;
  uVar1 = FUN_00492c84(param_1);
  local_317 = (char)uVar1;
  uVar1 = FUN_00492c84(param_1);
  local_316 = (char)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_314 = (ushort)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_312 = (ushort)uVar1;
  uVar1 = FUN_00492c84(param_1);
  local_310 = (char)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_30e = (undefined2)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_30c = (undefined2)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_30a = (undefined2)uVar1;
  uVar1 = FUN_00492cb4(param_1);
  local_308 = (undefined2)uVar1;
  uVar1 = FUN_00492c84(param_1);
  local_306 = (undefined1)uVar1;
  uVar1 = FUN_00492c84(param_1);
  local_305 = (undefined1)uVar1;
  if ((((local_316 == '\x01') || (local_316 == '\x02')) || (local_316 == '\x03')) ||
     (((local_316 == '\t' || (local_316 == '\n')) || (local_316 == '\v')))) {
    FUN_00492ba0(param_1,(uint)local_318);
    if (local_317 != '\0') {
      if (local_310 == '\x10') {
        uVar5 = (uint)local_314;
        pbVar4 = local_304 + uVar5 * 3;
        for (; (int)uVar5 < (int)(uint)local_312; uVar5 = uVar5 + 1) {
          iVar3 = FUN_00492cb4(param_1);
          *pbVar4 = (byte)((short)iVar3 >> 7) & 0xf8;
          pbVar4[1] = (byte)((short)iVar3 >> 2) & 0xf8;
          pbVar4[2] = (byte)(iVar3 << 3);
          pbVar4 = pbVar4 + 3;
        }
      }
      else if (local_310 == '\x18') {
        FUN_00492f10(param_1,(char *)(local_304 + (uint)local_314 * 3),(uint)local_312 * 3);
      }
    }
    puVar2 = FUN_004992bc(param_1,(int)&local_318);
  }
  else {
    FUN_0049a300(1,s_dpl_tgaRead___not_a_recognised_i_0050b04c);
    puVar2 = (undefined4 *)0x0;
  }
  return puVar2;
}



/* @00499ab0 file=? name=FUN_00499ab0 */

undefined4 * __cdecl FUN_00499ab0(LPCSTR param_1)

{
  undefined4 *puVar1;
  int *piVar2;
  
  if (param_1 == (LPCSTR)0x0) {
    FUN_0049a300(1,s_dpl_tgaRead_got_no_file_to_open__0050b077);
    puVar1 = (undefined4 *)0x0;
  }
  else {
    if ((DAT_0050aff8 == (int *)0x0) &&
       (DAT_0050aff8 = FUN_004de55c(0x4000), DAT_0050aff8 == (int *)0x0)) {
      FUN_0049a300(1,s_dpl_tgaRead_failed_to_allocate_r_0050b098);
      return (undefined4 *)0x0;
    }
    piVar2 = FUN_004930c0(param_1,0x4000,DAT_0050aff8,1);
    if (piVar2 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_tgaRead_failed_to_open_file___0050b0c3);
      puVar1 = (undefined4 *)0x0;
    }
    else {
      puVar1 = FUN_00499918(piVar2);
      FUN_00493188(piVar2);
    }
  }
  return puVar1;
}



/* @00499b48 file=? name=FUN_00499b48 */

void FUN_00499b48(void)

{
  if (DAT_0050aff8 != (int *)0x0) {
    FUN_004de420(DAT_0050aff8);
    DAT_0050aff8 = (int *)0x0;
  }
  return;
}



/* @00499b64 file=? name=FUN_00499b64 */

void * __thiscall FUN_00499b64(void *this,undefined4 *param_1,uint *param_2,uint *param_3)

{
  uint uVar1;
  uint uVar2;
  uint uVar3;
  void *local_8;
  
  uVar3 = 0;
  uVar1 = FUN_00492cb4(param_1);
  uVar2 = (int)(uVar1 & 0xffff) >> 0xc & 0xc;
  if (uVar2 == 0) {
    uVar3 = FUN_00492c84(param_1);
    uVar3 = uVar3 & 0xff;
    local_8 = (void *)0x3;
  }
  else if (uVar2 == 4) {
    uVar3 = FUN_00492cb4(param_1);
    uVar3 = uVar3 & 0xffff;
    local_8 = (void *)0x4;
  }
  else if (uVar2 == 8) {
    uVar3 = FUN_00492d84(param_1);
    local_8 = (void *)0x6;
  }
  else {
    FUN_0049a300(1,s_dpl_vtxRead_got_unrecognised_blo_0050b12c);
    param_1[2] = 1;
    local_8 = this;
  }
  *param_2 = uVar1 & 0x3fff;
  *param_3 = uVar3;
  return local_8;
}



/* @00499c0c file=? name=FUN_00499c0c */

undefined4 __thiscall FUN_00499c0c(void *this,undefined4 *param_1,int param_2)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 *extraout_ECX;
  undefined4 *extraout_ECX_00;
  undefined4 *extraout_ECX_01;
  undefined4 *extraout_ECX_02;
  undefined4 *extraout_ECX_03;
  undefined4 *extraout_ECX_04;
  undefined4 *extraout_ECX_05;
  undefined4 *extraout_ECX_06;
  int iVar3;
  uint local_c;
  uint local_8;
  
  iVar3 = 0;
  do {
    if ((param_1[2] != 0) || (param_2 <= iVar3)) {
      return 1;
    }
    iVar1 = FUN_00499b64(this,param_1,&local_8,&local_c);
    if (param_1[2] != 0) {
      return 0;
    }
    if ((int)local_8 < 0x2005) {
      if (local_8 == 0x2004) {
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX_01;
      }
      else if ((local_8 == 0) || (local_8 == 0x2000)) {
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX_05;
      }
      else if (local_8 == 0x2002) {
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX;
      }
      else if (local_8 == 0x2003) {
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX_00;
      }
      else {
LAB_00499d1d:
        FUN_0049a300(1,s_dpl_vtxRead_got_unrecognized_blo_0050b18a);
        FUN_00492ba0(param_1,local_c);
        this = extraout_ECX_06;
      }
    }
    else if (local_8 == 0x2005) {
      FUN_00492ba0(param_1,local_c);
      this = extraout_ECX_02;
    }
    else if (local_8 == 0x2006) {
      FUN_00492ba0(param_1,local_c);
      this = extraout_ECX_03;
    }
    else if (local_8 == 0x2007) {
      this = param_1;
      uVar2 = FUN_00492c84(param_1);
      if ((char)uVar2 != '\x02') {
        FUN_0049a300(1,s_dpl_vtxRead___file_is_not_a_text_0050b15c);
        param_1[2] = 1;
        return 0;
      }
    }
    else {
      if (local_8 != 0x2009) goto LAB_00499d1d;
      FUN_00492ba0(param_1,local_c);
      this = extraout_ECX_04;
    }
    iVar3 = iVar3 + iVar1 + local_c;
  } while( true );
}



/* @00499d5c file=? name=FUN_00499d5c */

bool __cdecl
FUN_00499d5c(undefined4 *param_1,int param_2,undefined4 param_3,undefined4 param_4,int param_5,
            int param_6,int param_7)

{
  undefined1 uVar1;
  int iVar2;
  undefined1 *puVar3;
  undefined1 *puVar4;
  int iVar5;
  int iVar6;
  undefined1 *local_20;
  int local_1c;
  int local_18;
  int local_10;
  int local_c;
  int local_8;
  
  if (param_6 == 0x68) {
    local_c = param_5;
  }
  else if (param_6 == 0x69) {
    local_c = param_5 * 2;
  }
  else if (param_6 == 0x6a) {
    local_c = param_5 * 3;
  }
  else if (param_6 == 0x6b) {
    local_c = param_5 << 2;
  }
  iVar2 = local_c + 7;
  if (iVar2 < 0) {
    iVar2 = local_c + 0xe;
  }
  iVar2 = iVar2 >> 3;
  FUN_0048c32c(param_2,param_3,param_4);
  FUN_0048c3c8(param_2,iVar2);
  local_8 = param_7 / iVar2;
  if ((*(byte *)(param_1 + 7) & 3) != 0) {
    FUN_004d493c((undefined4 *)param_1[6],(undefined4 *)param_1[7],param_1[9]);
    param_1[7] = param_1[6];
  }
  local_18 = 0;
  for (; (param_1[2] == 0 && (0 < local_8)); local_8 = local_8 - local_10) {
    if ((int)param_1[9] < iVar2) {
      FUN_00492b20(param_1);
    }
    local_10 = (int)param_1[9] / iVar2;
    if (local_8 < local_10) {
      local_10 = local_8;
    }
    local_20 = (undefined1 *)param_1[7];
    local_1c = 0;
    if (0 < local_10) {
      do {
        iVar6 = 0;
        iVar5 = iVar2 + -1;
        puVar4 = local_20 + iVar5;
        puVar3 = local_20;
        if (0 < iVar5) {
          do {
            uVar1 = *puVar3;
            *puVar3 = *puVar4;
            iVar6 = iVar6 + 1;
            puVar3 = puVar3 + 1;
            *puVar4 = uVar1;
            iVar5 = iVar5 + -1;
            puVar4 = puVar4 + -1;
          } while (iVar6 < iVar5);
        }
        local_20 = local_20 + iVar2;
        local_1c = local_1c + 1;
      } while (local_1c < local_10);
    }
    FUN_0048c548(param_2,(byte *)param_1[7],local_18,local_10);
    FUN_00492ba0(param_1,local_10 * iVar2);
    local_18 = local_18 + local_10;
  }
  if (local_8 >= 1) {
    FUN_0049a300(1,s_dpl_vtxRead_failed_to_read_in_al_0050b1c0);
  }
  return local_8 < 1;
}



/* @00499f10 file=? name=FUN_00499f10 */

undefined4 * __cdecl FUN_00499f10(undefined4 *param_1,uint param_2)

{
  bool bVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 *extraout_ECX;
  undefined4 *extraout_ECX_00;
  undefined4 *extraout_ECX_01;
  undefined4 *extraout_ECX_02;
  undefined4 *extraout_ECX_03;
  undefined4 *extraout_ECX_04;
  undefined4 *puVar4;
  int iVar5;
  int local_14;
  int local_10;
  uint local_c;
  uint local_8;
  
  iVar5 = 0;
  local_10 = 0;
  local_14 = 0;
  bVar1 = false;
  puVar2 = (undefined4 *)FUN_00489788();
  puVar4 = extraout_ECX;
  if (puVar2 == (undefined4 *)0x0) {
    FUN_0049a300(1,s_dpl_vtxRead_failed_to_create_dpl_0050b1ee);
    FUN_00492ba0(param_1,param_2);
    puVar2 = (undefined4 *)0x0;
  }
  else {
    for (; (param_1[2] == 0 && (iVar5 < (int)param_2)); iVar5 = iVar5 + iVar3 + local_c) {
      iVar3 = FUN_00499b64(puVar4,param_1,&local_8,&local_c);
      if (param_1[2] != 0) {
        return (undefined4 *)0x0;
      }
      puVar4 = param_1;
      if ((int)local_8 < 0x2061) {
        if (local_8 == 0x2060) {
          FUN_00492c84(param_1);
        }
        else {
          if (local_8 != 0) {
            if (local_8 - 0x68 < 4) {
              if ((local_10 < 1) || (local_14 < 1)) {
                FUN_0049a300(1,s_dpl_vtxRead_no_texture_size_spec_0050b24a);
                FUN_00492ba0(param_1,local_c);
                puVar4 = extraout_ECX_02;
              }
              else if (bVar1) {
                FUN_0049a300(1,s_dpl_vtxRead_texels_already_defin_0050b217);
                FUN_00492ba0(param_1,local_c);
                puVar4 = extraout_ECX_01;
              }
              else {
                FUN_00499d5c(param_1,(int)puVar2,local_10,local_14,8,local_8,local_c);
                bVar1 = true;
                puVar4 = extraout_ECX_00;
              }
              goto LAB_0049a099;
            }
            if (local_8 - 0x68 != 0x1f98) goto LAB_0049a079;
          }
          FUN_00492ba0(param_1,local_c);
          puVar4 = extraout_ECX_03;
        }
      }
      else if (local_8 == 0x2061) {
        FUN_00492c84(param_1);
      }
      else if (local_8 == 0x2062) {
        local_10 = FUN_00492d84(param_1);
        local_14 = FUN_00492d84(param_1);
      }
      else {
LAB_0049a079:
        FUN_0049a300(1,s_dpl_vtxRead_got_unrecognized_blo_0050b282);
        FUN_00492ba0(param_1,local_c);
        puVar4 = extraout_ECX_04;
      }
LAB_0049a099:
    }
    FUN_0048d5b0(puVar2);
  }
  return puVar2;
}



/* @0049a0c0 file=? name=FUN_0049a0c0 */

undefined4 * __thiscall FUN_0049a0c0(void *this,undefined4 *param_1)

{
  bool bVar1;
  bool bVar2;
  void *this_00;
  void *this_01;
  void *extraout_ECX;
  void *extraout_ECX_00;
  void *extraout_ECX_01;
  void *extraout_ECX_02;
  void *extraout_ECX_03;
  void *this_02;
  void *extraout_ECX_04;
  undefined4 *local_10;
  uint local_c;
  uint local_8;
  
  bVar1 = true;
  bVar2 = false;
  local_10 = (undefined4 *)0x0;
  param_1[2] = 0;
  FUN_00499b64(this,param_1,&local_8,&local_c);
  if (param_1[2] == 0) {
    this_02 = this_00;
    if (local_8 == 3) {
      FUN_00499c0c(this_00,param_1,local_c);
      FUN_00499b64(this_01,param_1,&local_8,&local_c);
      this_02 = extraout_ECX;
    }
    while ((param_1[2] == 0 && (bVar1))) {
      if (local_8 == 0) {
LAB_0049a17c:
        FUN_00492ba0(param_1,local_c);
        this_02 = extraout_ECX_02;
      }
      else if (local_8 == 5) {
        bVar1 = false;
      }
      else if (local_8 == 0x60) {
        if (bVar2) {
          FUN_0049a300(1,s_dpl_vtxRead_texmap_already_defin_0050b2b8);
          FUN_00492ba0(param_1,local_c);
          this_02 = extraout_ECX_01;
        }
        else {
          local_10 = FUN_00499f10(param_1,local_c);
          bVar2 = true;
          this_02 = extraout_ECX_00;
        }
      }
      else {
        if (local_8 == 0x2000) goto LAB_0049a17c;
        FUN_0049a300(1,s_dpl_vtxRead_got_unrecognized_blo_0050b2dc);
        FUN_00492ba0(param_1,local_c);
        this_02 = extraout_ECX_03;
      }
      if (bVar1) {
        FUN_00499b64(this_02,param_1,&local_8,&local_c);
        this_02 = extraout_ECX_04;
      }
    }
  }
  else {
    local_10 = (undefined4 *)0x0;
  }
  return local_10;
}



/* @0049a1dc file=? name=FUN_0049a1dc */

undefined4 * __cdecl FUN_0049a1dc(LPCSTR param_1)

{
  char cVar1;
  undefined4 *puVar2;
  int *piVar3;
  char *pcVar4;
  void *extraout_ECX;
  void *this;
  char *pcVar6;
  bool bVar7;
  char local_10 [8];
  undefined1 local_8;
  undefined3 uVar5;
  
  if (param_1 == (LPCSTR)0x0) {
    FUN_0049a300(1,s_dpl_vtxRead_got_no_file_to_open__0050b318);
    puVar2 = (undefined4 *)0x0;
  }
  else {
    if ((DAT_0050b128 == (int *)0x0) &&
       (DAT_0050b128 = FUN_004de55c(0x4000), DAT_0050b128 == (int *)0x0)) {
      FUN_0049a300(1,s_dpl_vtxRead_failed_to_allocate_r_0050b339);
      return (undefined4 *)0x0;
    }
    piVar3 = FUN_004930c0(param_1,0x4000,DAT_0050b128,1);
    if (piVar3 == (int *)0x0) {
      FUN_0049a300(1,s_dpl_vtxRead_failed_to_open_file___0050b364);
      puVar2 = (undefined4 *)0x0;
    }
    else {
      FUN_00492f10(piVar3,local_10,8);
      local_8 = 0;
      pcVar4 = local_10;
      pcVar6 = &DAT_0050b38a;
      this = extraout_ECX;
      do {
        cVar1 = *pcVar4;
        uVar5 = (undefined3)((uint)this >> 8);
        this = (void *)CONCAT31(uVar5,cVar1);
        bVar7 = cVar1 == *pcVar6;
        if (!bVar7) break;
        if (cVar1 == '\0') goto LAB_0049a2bb;
        cVar1 = pcVar4[1];
        this = (void *)CONCAT31(uVar5,cVar1);
        bVar7 = cVar1 == pcVar6[1];
        if (!bVar7) break;
        pcVar4 = pcVar4 + 2;
        pcVar6 = pcVar6 + 2;
        bVar7 = cVar1 == '\0';
      } while (!bVar7);
      if (bVar7) {
LAB_0049a2bb:
        puVar2 = FUN_0049a0c0(this,piVar3);
        FUN_00493188(piVar3);
      }
      else {
        FUN_0049a300(1,s_dpl_vtxRead___s__is_not_a_valid_v_0050b393);
        FUN_00493188(piVar3);
        puVar2 = (undefined4 *)0x0;
      }
    }
  }
  return puVar2;
}



/* @0049a2d4 file=? name=FUN_0049a2d4 */

void FUN_0049a2d4(void)

{
  if (DAT_0050b128 != (int *)0x0) {
    FUN_004de420(DAT_0050b128);
    DAT_0050b128 = (int *)0x0;
  }
  return;
}



/* @0049a2f0 file=? name=FUN_0049a2f0 */

void __cdecl FUN_0049a2f0(undefined4 param_1)

{
  DAT_0050b3f8 = param_1;
  return;
}



/* @0049a300 file=? name=FUN_0049a300 */

void __cdecl FUN_0049a300(int param_1,char *param_2)

{
  if (param_1 <= DAT_00505b54) {
    FUN_004d6f80(&DAT_0051f830,s_dPL_Warning___s____0050b446);
    FUN_004d8080(&DAT_0051f830,param_2,(uint *)&stack0x0000000c);
    FUN_004d6f80(&DAT_0051f830,&DAT_0050b45a);
    if (DAT_0050b3f8 != 0) {
      FUN_004d6f80(DAT_0050b3f8,s_dPL_Warning___s____0050b45c);
      FUN_004d8080(DAT_0050b3f8,param_2,(uint *)&stack0x0000000c);
      FUN_004d6f80(DAT_0050b3f8,&DAT_0050b470);
    }
  }
  return;
}



/* @0049a3a8 file=? name=FUN_0049a3a8 */

void FUN_0049a3a8(void)

{
  DAT_0050b3f8 = 0;
  return;
}



/* @0049a3b0 file=? name=FUN_0049a3b0 */

void __cdecl FUN_0049a3b0(undefined4 *param_1,int param_2,int param_3,int param_4)

{
  uint uVar1;
  
  if (param_3 == 0) {
    param_3 = 100;
  }
  if (param_4 == 0) {
    param_4 = 4;
  }
  uVar1 = param_4 + 3U & 0xfffffffc;
  *param_1 = 0;
  param_1[1] = 0;
  param_1[2] = 0;
  param_1[3] = 0;
  param_1[4] = param_3;
  param_1[5] = uVar1;
  param_1[6] = (((uVar1 + param_2) - 1) / uVar1) * uVar1;
  return;
}



/* @0049a40c file=? name=FUN_0049a40c */

void __cdecl FUN_0049a40c(undefined4 *param_1,undefined *param_2)

{
  undefined4 *puVar1;
  
  if (param_1 == (undefined4 *)0x0) {
    FUN_004debc8(s_cb____NULL_0050b474,s_LIBDU_BALLOC_C_0050b47f,0x70);
  }
  while (puVar1 = (undefined4 *)*param_1, puVar1 != (undefined4 *)0x0) {
    *param_1 = *puVar1;
    (*(code *)param_2)(puVar1);
  }
  return;
}



/* @0049a444 file=? name=FUN_0049a444 */

undefined4 * __cdecl FUN_0049a444(undefined4 *param_1,undefined *param_2)

{
  undefined4 *puVar1;
  uint uVar2;
  int iVar3;
  int iVar4;
  
  if (param_1 == (undefined4 *)0x0) {
    FUN_004debc8(s_cb____NULL_0050b48e,s_LIBDU_BALLOC_C_0050b499,0x87);
  }
  if ((uint)param_1[2] < (uint)param_1[3]) {
    FUN_004debc8(s_cb_>totalItems_>__cb_>freeItems_0050b4a8,s_LIBDU_BALLOC_C_0050b4c8,0x88);
  }
  if (param_1[1] == 0) {
    iVar4 = param_1[4];
    uVar2 = param_1[6];
    puVar1 = (undefined4 *)(*(code *)param_2)(iVar4 * uVar2 + 8);
    if (puVar1 == (undefined4 *)0x0) {
      return (undefined4 *)0x0;
    }
    puVar1[1] = iVar4;
    *puVar1 = *param_1;
    *param_1 = puVar1;
    param_1[1] = puVar1 + 2;
    param_1[2] = param_1[2] + iVar4;
    param_1[3] = param_1[3] + iVar4;
    uVar2 = uVar2 >> 2;
    iVar3 = 0;
    while (iVar4 = iVar4 + -1, iVar4 != 0) {
      puVar1[iVar3 + 2] = puVar1 + uVar2 + iVar3 + 2;
      iVar3 = iVar3 + uVar2;
    }
    puVar1[iVar3 + 2] = 0;
  }
  puVar1 = (undefined4 *)param_1[1];
  param_1[1] = *puVar1;
  param_1[3] = param_1[3] + -1;
  return puVar1;
}



/* @0049a4f4 file=? name=FUN_0049a4f4 */

void __cdecl FUN_0049a4f4(int param_1,undefined4 *param_2)

{
  if (param_1 == 0) {
    FUN_004debc8(s_cb____NULL_0050b4d7,s_LIBDU_BALLOC_C_0050b4e2,0xbd);
  }
  if (*(uint *)(param_1 + 8) < *(uint *)(param_1 + 0xc)) {
    FUN_004debc8(s_cb_>totalItems_>__cb_>freeItems_0050b4f1,s_LIBDU_BALLOC_C_0050b511,0xbe);
  }
  *param_2 = *(undefined4 *)(param_1 + 4);
  *(undefined4 **)(param_1 + 4) = param_2;
  *(int *)(param_1 + 0xc) = *(int *)(param_1 + 0xc) + 1;
  return;
}



/* @0049a548 file=? name=FUN_0049a548 */

uint __cdecl FUN_0049a548(char *param_1,uint param_2)

{
  uint uVar1;
  uint uVar2;
  
  uVar1 = 0;
  for (; *param_1 != '\0'; param_1 = param_1 + 1) {
    uVar1 = uVar1 * 0x10 + (int)*param_1;
    uVar2 = uVar1 & 0xf0000000;
    if (uVar2 != 0) {
      uVar1 = uVar1 ^ uVar2 >> 0x18 ^ uVar2;
    }
  }
  return uVar1 % param_2;
}



/* @0049a584 file=? name=FUN_0049a584 */

undefined4 __cdecl FUN_0049a584(undefined4 *param_1,undefined4 param_2)

{
  code *pcVar1;
  int iVar2;
  undefined4 uVar3;
  undefined4 *puVar4;
  
  pcVar1 = (code *)param_1[1];
  iVar2 = (*(code *)*param_1)(param_2,param_1[9]);
  for (puVar4 = (undefined4 *)param_1[iVar2 + 10]; puVar4 != (undefined4 *)0x0;
      puVar4 = (undefined4 *)*puVar4) {
    iVar2 = (*pcVar1)(puVar4[1],param_2);
    if (iVar2 == 0) break;
  }
  if (puVar4 == (undefined4 *)0x0) {
    uVar3 = 0;
  }
  else {
    uVar3 = puVar4[2];
  }
  return uVar3;
}



/* @0049a5cc file=? name=FUN_0049a5cc */

void __cdecl FUN_0049a5cc(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = (*(code *)*param_1)(param_2,param_1[9]);
  puVar2 = FUN_0049a444(param_1 + 2,FUN_004de55c);
  *puVar2 = param_1[iVar1 + 10];
  puVar2[1] = param_2;
  puVar2[2] = param_3;
  param_1[iVar1 + 10] = puVar2;
  return;
}



/* @0049a610 file=? name=FUN_0049a610 */

undefined4 __cdecl
FUN_0049a610(undefined4 *param_1,undefined4 param_2,int param_3,undefined4 *param_4)

{
  code *pcVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  undefined4 *puVar4;
  undefined4 *puVar5;
  int iVar6;
  int iVar7;
  
  pcVar1 = (code *)param_1[1];
  iVar6 = (*(code *)*param_1)(param_2,param_1[9]);
  if (param_3 == 0) {
    puVar5 = (undefined4 *)param_1[iVar6 + 10];
    puVar4 = (undefined4 *)0x0;
    while (puVar3 = puVar5, puVar3 != (undefined4 *)0x0) {
      iVar7 = (*pcVar1)(puVar3[1],param_2);
      if (iVar7 == 0) {
        uVar2 = puVar3[2];
        if (param_4 != (undefined4 *)0x0) {
          *param_4 = puVar3[1];
        }
        if (puVar4 == (undefined4 *)0x0) {
          param_1[iVar6 + 10] = *puVar3;
        }
        else {
          *puVar4 = *puVar3;
        }
        FUN_0049a4f4((int)(param_1 + 2),puVar3);
        return uVar2;
      }
      puVar4 = puVar3;
      puVar5 = (undefined4 *)*puVar3;
    }
  }
  else {
    puVar5 = (undefined4 *)param_1[iVar6 + 10];
    puVar4 = (undefined4 *)0x0;
    while (puVar3 = puVar5, puVar3 != (undefined4 *)0x0) {
      iVar7 = (*pcVar1)(puVar3[1],param_2);
      if ((iVar7 == 0) && (param_3 == puVar3[2])) {
        uVar2 = puVar3[2];
        if (param_4 != (undefined4 *)0x0) {
          *param_4 = puVar3[1];
        }
        if (puVar4 == (undefined4 *)0x0) {
          param_1[iVar6 + 10] = *puVar3;
        }
        else {
          *puVar4 = *puVar3;
        }
        FUN_0049a4f4((int)(param_1 + 2),puVar3);
        return uVar2;
      }
      puVar4 = puVar3;
      puVar5 = (undefined4 *)*puVar3;
    }
  }
  return 0;
}



/* @0049a71c file=? name=FUN_0049a71c */

int * __cdecl FUN_0049a71c(int param_1,int param_2,int param_3)

{
  int *piVar1;
  
  piVar1 = FUN_004de55c((param_1 + -1) * 4 + 0x2c);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    FUN_0049a3b0(piVar1 + 2,0xc,100,0);
    piVar1[9] = param_1;
    FUN_004d4988(piVar1 + 10,0,param_1 << 2);
    if (param_2 == 0) {
      *piVar1 = (int)FUN_0049a548;
    }
    else {
      *piVar1 = param_2;
    }
    if (param_3 == 0) {
      piVar1[1] = (int)FUN_004d4a1c;
    }
    else {
      piVar1[1] = param_3;
    }
  }
  return piVar1;
}



/* @0049a794 file=? name=FUN_0049a794 */

void __cdecl FUN_0049a794(int *param_1)

{
  FUN_0049a40c(param_1 + 2,FUN_004de420);
  FUN_004de420(param_1);
  return;
}



/* @0049a7b8 file=? name=FUN_0049a7b8 */

undefined4 __cdecl FUN_0049a7b8(int *param_1,int param_2,undefined4 *param_3)

{
  int iVar1;
  int *piVar2;
  
  *param_1 = param_2;
  iVar1 = 0;
  for (piVar2 = (int *)(param_2 + 0x28); (iVar1 < *(int *)(param_2 + 0x24) && (*piVar2 == 0));
      piVar2 = piVar2 + 1) {
    iVar1 = iVar1 + 1;
  }
  if (iVar1 == *(int *)(param_2 + 0x24)) {
    param_1[2] = 0;
  }
  else {
    param_1[2] = *(int *)(param_2 + 0x28 + iVar1 * 4);
  }
  param_1[1] = iVar1;
  if (param_1[2] == 0) {
    return 0;
  }
  if (param_3 != (undefined4 *)0x0) {
    *param_3 = *(undefined4 *)(param_1[2] + 4);
  }
  return *(undefined4 *)(param_1[2] + 8);
}



/* @0049a814 file=? name=FUN_0049a814 */

undefined4 __cdecl FUN_0049a814(int *param_1,undefined4 *param_2)

{
  int iVar1;
  int iVar2;
  undefined4 uVar3;
  int *piVar4;
  
  iVar1 = *param_1;
  iVar2 = *(int *)param_1[2];
  if (iVar2 == 0) {
    iVar2 = param_1[1] + 1;
    for (piVar4 = (int *)(iVar1 + 0x28 + iVar2 * 4);
        (iVar2 < *(int *)(iVar1 + 0x24) && (*piVar4 == 0)); piVar4 = piVar4 + 1) {
      iVar2 = iVar2 + 1;
    }
    if (iVar2 == *(int *)(iVar1 + 0x24)) {
      param_1[2] = 0;
    }
    else {
      param_1[2] = *(int *)(iVar1 + 0x28 + iVar2 * 4);
    }
    param_1[1] = iVar2;
    if (param_1[2] == 0) {
      uVar3 = 0;
    }
    else {
      if (param_2 != (undefined4 *)0x0) {
        *param_2 = *(undefined4 *)(param_1[2] + 4);
      }
      uVar3 = *(undefined4 *)(param_1[2] + 8);
    }
  }
  else {
    param_1[2] = iVar2;
    if (param_2 != (undefined4 *)0x0) {
      *param_2 = *(undefined4 *)(iVar2 + 4);
    }
    uVar3 = *(undefined4 *)(param_1[2] + 8);
  }
  return uVar3;
}



/* @0049a88c file=? name=FUN_0049a88c */

void __cdecl FUN_0049a88c(int *param_1,undefined4 param_2)

{
  int iVar1;
  int iVar2;
  
  iVar1 = *param_1;
  do {
    iVar2 = iVar1;
    iVar1 = *(int *)(iVar2 + 0xc);
  } while (iVar1 != 0);
  *(undefined4 *)(iVar2 + 0xc) = param_2;
  return;
}



/* @0049a8a8 file=? name=FUN_0049a8a8 */

int __cdecl FUN_0049a8a8(int param_1,int param_2,int param_3)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  
  iVar4 = param_2;
  do {
    iVar2 = iVar4;
    iVar4 = *(int *)(iVar2 + 0xc);
  } while (iVar4 != 0);
  iVar4 = 0;
  iVar1 = param_1;
  if (param_3 == 0) {
    while (((iVar3 = iVar1, iVar3 != 0 && (*(int *)(iVar3 + 4) != 1)) && (*(int *)(iVar3 + 4) != 2))
          ) {
      iVar4 = iVar3;
      iVar1 = *(int *)(iVar3 + 0xc);
    }
  }
  else if (param_3 == 1) {
    while ((iVar3 = iVar1, iVar3 != 0 && (*(int *)(iVar3 + 4) != 2))) {
      iVar4 = iVar3;
      iVar1 = *(int *)(iVar3 + 0xc);
    }
  }
  else {
    iVar3 = param_1;
    if (param_3 == 2) {
      for (; iVar3 = 0, iVar1 != 0; iVar1 = *(int *)(iVar1 + 0xc)) {
        iVar4 = iVar1;
      }
    }
  }
  if (iVar4 != 0) {
    *(int *)(iVar4 + 0xc) = param_2;
    param_2 = param_1;
  }
  *(int *)(iVar2 + 0xc) = iVar3;
  return param_2;
}



/* @0049a920 file=? name=FUN_0049a920 */

int * __cdecl FUN_0049a920(char *param_1)

{
  char cVar1;
  int iVar2;
  int *piVar3;
  uint uVar4;
  uint uVar5;
  int *piVar6;
  char *pcVar7;
  int *piVar8;
  
  iVar2 = FUN_004d4a78(param_1);
  piVar3 = FUN_004de55c(iVar2 + 1);
  if (piVar3 != (int *)0x0) {
    uVar4 = 0xffffffff;
    do {
      pcVar7 = param_1;
      if (uVar4 == 0) break;
      uVar4 = uVar4 - 1;
      pcVar7 = param_1 + 1;
      cVar1 = *param_1;
      param_1 = pcVar7;
    } while (cVar1 != '\0');
    uVar4 = ~uVar4;
    piVar6 = (int *)(pcVar7 + -uVar4);
    piVar8 = piVar3;
    for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
      *piVar8 = *piVar6;
      piVar6 = piVar6 + 1;
      piVar8 = piVar8 + 1;
    }
    for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
      *(char *)piVar8 = (char)*piVar6;
      piVar6 = (int *)((int)piVar6 + 1);
      piVar8 = (int *)((int)piVar8 + 1);
    }
  }
  return piVar3;
}



/* @0049a968 file=? name=FUN_0049a968 */

void __cdecl FUN_0049a968(char *param_1)

{
  uint uVar1;
  
  if (param_1 != (char *)0x0) {
    for (; *param_1 != '\0'; param_1 = param_1 + 1) {
      uVar1 = FUN_004dc89c((int)*param_1);
      *param_1 = (char)uVar1;
    }
  }
  return;
}



/* @0049a990 file=? name=FUN_0049a990 */

void FUN_0049a990(void)

{
  FUN_004d8e80();
  return;
}



/* @0049a99c file=? name=FUN_0049a99c */

void __cdecl FUN_0049a99c(char param_1,int *param_2)

{
  uint uVar1;
  char *pcVar2;
  int iVar3;
  
  if (((&DAT_005207dd)[param_1] & 0xc) == 0) {
    FUN_004d7388(param_2,0x7fe);
    *(undefined1 *)((int)param_2 + 2) = 0x2f;
  }
  else {
    uVar1 = FUN_004dc89c((int)param_1);
    *(char *)param_2 = (char)uVar1;
    *(undefined1 *)((int)param_2 + 1) = 0x3a;
    *(undefined1 *)((int)param_2 + 2) = 0x2f;
    FUN_004d8ce0((char)uVar1 + -0x60,(int *)((int)param_2 + 3));
  }
  pcVar2 = (char *)((int)param_2 + 2);
  while( true ) {
    pcVar2 = FUN_004d49f4(pcVar2,'\\');
    if (pcVar2 == (char *)0x0) break;
    *pcVar2 = '/';
    pcVar2 = pcVar2 + 1;
  }
  iVar3 = FUN_004d4a78((char *)param_2);
  if ((0 < iVar3) && (*(char *)((int)param_2 + iVar3 + -1) != '/')) {
    *(undefined1 *)((int)param_2 + iVar3) = 0x2f;
    *(undefined1 *)((int)param_2 + iVar3 + 1) = 0;
  }
  return;
}



/* @0049aa2c file=? name=FUN_0049aa2c */

char * __cdecl FUN_0049aa2c(char *param_1)

{
  char cVar1;
  char *pcVar2;
  char *pcVar3;
  char *pcVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  undefined1 local_804 [2048];
  
  pcVar2 = param_1;
  while (pcVar2 = FUN_004d49f4(pcVar2,'\\'), pcVar2 != (char *)0x0) {
    *pcVar2 = '/';
    pcVar2 = pcVar2 + 1;
  }
  pcVar2 = param_1 + 1;
  pcVar3 = (char *)0x0;
  while (pcVar2 = FUN_004d49f4(pcVar2 + 1,':'), pcVar2 != (char *)0x0) {
    if (((&DAT_005207dd)[pcVar2[-1]] & 0xc) != 0) {
      pcVar3 = pcVar2;
    }
  }
  pcVar2 = param_1;
  pcVar4 = param_1;
  if (pcVar3 != (char *)0x0) {
    pcVar2 = pcVar3 + -1;
    pcVar4 = pcVar2;
  }
  while (pcVar3 = FUN_004d49f4(pcVar2,'/'), pcVar3 != (char *)0x0) {
    if (pcVar3[1] == '/') {
      if (pcVar4[1] == ':') {
        pcVar3[-1] = *pcVar4;
        *pcVar3 = ':';
        pcVar2 = pcVar3 + -1;
        pcVar4 = pcVar3 + -1;
      }
      else {
        pcVar2 = pcVar3 + 1;
        pcVar4 = pcVar3 + 1;
      }
    }
    else {
      pcVar2 = pcVar3 + 1;
    }
  }
  if ((*pcVar4 == '/') || (pcVar4[1] == ':')) {
    if ((pcVar4[1] == ':') && (pcVar4[2] != '/')) {
      FUN_0049a99c(*pcVar4,(int *)local_804);
      FUN_004d49b8(local_804,pcVar4 + 2);
    }
    else if (*pcVar4 == '/') {
      local_804[0] = FUN_0049a990();
      local_804[0] = local_804[0] + 'a';
      local_804[1] = 0x3a;
      uVar5 = 0xffffffff;
      do {
        pcVar2 = pcVar4;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar2 = pcVar4 + 1;
        cVar1 = *pcVar4;
        pcVar4 = pcVar2;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar2 = pcVar2 + -uVar5;
      pcVar3 = local_804 + 2;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar3 = *(undefined4 *)pcVar2;
        pcVar2 = pcVar2 + 4;
        pcVar3 = pcVar3 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar3 = *pcVar2;
        pcVar2 = pcVar2 + 1;
        pcVar3 = pcVar3 + 1;
      }
    }
    else {
      uVar5 = 0xffffffff;
      do {
        pcVar2 = pcVar4;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar2 = pcVar4 + 1;
        cVar1 = *pcVar4;
        pcVar4 = pcVar2;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar2 = pcVar2 + -uVar5;
      pcVar3 = local_804;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar3 = *(undefined4 *)pcVar2;
        pcVar2 = pcVar2 + 4;
        pcVar3 = pcVar3 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar3 = *pcVar2;
        pcVar2 = pcVar2 + 1;
        pcVar3 = pcVar3 + 1;
      }
    }
  }
  else {
    FUN_0049a99c('\0',(int *)local_804);
    FUN_004d49b8(local_804,pcVar4);
  }
  pcVar2 = local_804;
  pcVar3 = (char *)0x0;
  while (pcVar4 = FUN_004d49f4(pcVar2,'/'), pcVar4 != (char *)0x0) {
    if ((((pcVar4[1] == '.') && (pcVar4[2] == '.')) && (pcVar4[3] == '/')) &&
       (pcVar3 != (char *)0x0)) {
      uVar5 = 0xffffffff;
      pcVar2 = pcVar4 + 3;
      do {
        pcVar4 = pcVar2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar4 = pcVar2 + 1;
        cVar1 = *pcVar2;
        pcVar2 = pcVar4;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar2 = pcVar4 + -uVar5;
      pcVar4 = param_1;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar4 = *(undefined4 *)pcVar2;
        pcVar2 = pcVar2 + 4;
        pcVar4 = pcVar4 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar4 = *pcVar2;
        pcVar2 = pcVar2 + 1;
        pcVar4 = pcVar4 + 1;
      }
      uVar5 = 0xffffffff;
      pcVar2 = param_1;
      do {
        pcVar4 = pcVar2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar4 = pcVar2 + 1;
        cVar1 = *pcVar2;
        pcVar2 = pcVar4;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar2 = pcVar4 + -uVar5;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar3 = *(undefined4 *)pcVar2;
        pcVar2 = pcVar2 + 4;
        pcVar3 = pcVar3 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar3 = *pcVar2;
        pcVar2 = pcVar2 + 1;
        pcVar3 = pcVar3 + 1;
      }
      pcVar2 = local_804;
      pcVar3 = (char *)0x0;
    }
    else if ((pcVar4[1] == '.') && (pcVar4[2] == '/')) {
      uVar5 = 0xffffffff;
      pcVar2 = pcVar4 + 2;
      do {
        pcVar7 = pcVar2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = pcVar2 + 1;
        cVar1 = *pcVar2;
        pcVar2 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar2 = pcVar7 + -uVar5;
      pcVar7 = param_1;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar7 = *(undefined4 *)pcVar2;
        pcVar2 = pcVar2 + 4;
        pcVar7 = pcVar7 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar7 = *pcVar2;
        pcVar2 = pcVar2 + 1;
        pcVar7 = pcVar7 + 1;
      }
      uVar5 = 0xffffffff;
      pcVar2 = param_1;
      do {
        pcVar7 = pcVar2;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = pcVar2 + 1;
        cVar1 = *pcVar2;
        pcVar2 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar7 = pcVar7 + -uVar5;
      for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar4 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar4 = pcVar4 + 4;
      }
      for (uVar5 = uVar5 & 3; pcVar2 = pcVar3, uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar4 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar4 = pcVar4 + 1;
      }
    }
    else {
      pcVar2 = pcVar4 + 1;
      pcVar3 = pcVar4;
    }
  }
  FUN_0049a968(local_804);
  uVar5 = 0xffffffff;
  pcVar2 = local_804;
  do {
    pcVar3 = pcVar2;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar3 = pcVar2 + 1;
    cVar1 = *pcVar2;
    pcVar2 = pcVar3;
  } while (cVar1 != '\0');
  uVar5 = ~uVar5;
  pcVar2 = pcVar3 + -uVar5;
  pcVar3 = param_1;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar3 = *(undefined4 *)pcVar2;
    pcVar2 = pcVar2 + 4;
    pcVar3 = pcVar3 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar3 = *pcVar2;
    pcVar2 = pcVar2 + 1;
    pcVar3 = pcVar3 + 1;
  }
  return param_1;
}



/* @0049acb0 file=? name=FUN_0049acb0 */

int * __cdecl FUN_0049acb0(char *param_1)

{
  char cVar1;
  int iVar2;
  int *piVar3;
  uint uVar4;
  uint uVar5;
  int *piVar6;
  char *pcVar7;
  int *piVar8;
  
  iVar2 = FUN_004d4a78(param_1);
  piVar3 = FUN_004de55c(iVar2 + 1);
  if (piVar3 == (int *)0x0) {
    piVar3 = (int *)&DAT_0050b52a;
  }
  else {
    uVar4 = 0xffffffff;
    do {
      pcVar7 = param_1;
      if (uVar4 == 0) break;
      uVar4 = uVar4 - 1;
      pcVar7 = param_1 + 1;
      cVar1 = *param_1;
      param_1 = pcVar7;
    } while (cVar1 != '\0');
    uVar4 = ~uVar4;
    piVar6 = (int *)(pcVar7 + -uVar4);
    piVar8 = piVar3;
    for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
      *piVar8 = *piVar6;
      piVar6 = piVar6 + 1;
      piVar8 = piVar8 + 1;
    }
    for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
      *(char *)piVar8 = (char)*piVar6;
      piVar6 = (int *)((int)piVar6 + 1);
      piVar8 = (int *)((int)piVar8 + 1);
    }
  }
  return piVar3;
}



/* @0049ad00 file=? name=FUN_0049ad00 */

int * __cdecl FUN_0049ad00(char *param_1,char *param_2,int param_3)

{
  char cVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  int *piVar5;
  int *piVar6;
  int iVar7;
  int iVar8;
  int *piVar9;
  uint uVar10;
  uint uVar11;
  char *pcVar12;
  undefined4 *puVar13;
  char *pcVar14;
  int *piVar15;
  undefined4 *puVar16;
  bool bVar17;
  int *local_10;
  int *local_c;
  
  local_c = (int *)0x0;
  local_10 = (int *)0x0;
  piVar2 = FUN_0049a920(param_1);
  if (piVar2 == (int *)0x0) {
    FUN_004d6f80(&DAT_0051f830,s_du___path_searching___out_of_mem_0050b52b);
    piVar3 = (int *)0x0;
  }
  else {
    piVar4 = (int *)FUN_004d4d1c((char *)piVar2,&DAT_0050b550);
    piVar3 = local_c;
    while (piVar4 != (int *)0x0) {
      bVar17 = (char)*piVar4 == '~';
      piVar5 = piVar4;
      if (bVar17) {
        piVar5 = FUN_0049acb0((char *)piVar4);
      }
      piVar6 = FUN_004de55c(0x10);
      if (piVar6 == (int *)0x0) {
        FUN_004d6f80(&DAT_0051f830,s_du___path_searching___out_of_mem_0050b552);
        return (int *)0x0;
      }
      if (param_2 == (char *)0x0) {
        iVar7 = FUN_004d4a78((char *)piVar5);
        piVar9 = FUN_004de55c(iVar7 + 1);
        *piVar6 = (int)piVar9;
      }
      else {
        iVar7 = FUN_004d4a78(param_2);
        iVar8 = FUN_004d4a78((char *)piVar5);
        piVar9 = FUN_004de55c(iVar7 + iVar8 + 2);
        *piVar6 = (int)piVar9;
      }
      if (*piVar6 == 0) {
        FUN_004d6f80(&DAT_0051f830,s_du___path_searching___out_of_mem_0050b577);
        FUN_004de420(piVar2);
        return (int *)0x0;
      }
      if (param_2 == (char *)0x0) {
        uVar10 = 0xffffffff;
        piVar9 = piVar5;
        do {
          piVar15 = piVar9;
          if (uVar10 == 0) break;
          uVar10 = uVar10 - 1;
          piVar15 = (int *)((int)piVar9 + 1);
          iVar7 = *piVar9;
          piVar9 = piVar15;
        } while ((char)iVar7 != '\0');
        uVar10 = ~uVar10;
        puVar13 = (undefined4 *)((int)piVar15 - uVar10);
        puVar16 = (undefined4 *)*piVar6;
        for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
          *puVar16 = *puVar13;
          puVar13 = puVar13 + 1;
          puVar16 = puVar16 + 1;
        }
        for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
          *(undefined1 *)puVar16 = *(undefined1 *)puVar13;
          puVar13 = (undefined4 *)((int)puVar13 + 1);
          puVar16 = (undefined4 *)((int)puVar16 + 1);
        }
      }
      else {
        uVar10 = 0xffffffff;
        pcVar12 = param_2;
        do {
          pcVar14 = pcVar12;
          if (uVar10 == 0) break;
          uVar10 = uVar10 - 1;
          pcVar14 = pcVar12 + 1;
          cVar1 = *pcVar12;
          pcVar12 = pcVar14;
        } while (cVar1 != '\0');
        uVar10 = ~uVar10;
        pcVar12 = pcVar14 + -uVar10;
        pcVar14 = (char *)*piVar6;
        for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
          *(undefined4 *)pcVar14 = *(undefined4 *)pcVar12;
          pcVar12 = pcVar12 + 4;
          pcVar14 = pcVar14 + 4;
        }
        for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
          *pcVar14 = *pcVar12;
          pcVar12 = pcVar12 + 1;
          pcVar14 = pcVar14 + 1;
        }
        FUN_004d49b8((char *)*piVar6,&DAT_0050b59c);
        FUN_004d49b8((char *)*piVar6,(char *)piVar5);
      }
      piVar6[1] = param_3;
      piVar4 = FUN_0049a920((char *)piVar4);
      piVar6[2] = (int)piVar4;
      piVar6[3] = 0;
      if (bVar17) {
        FUN_004de420(piVar5);
      }
      local_c = piVar6;
      if (piVar3 != (int *)0x0) {
        local_10[3] = (int)piVar6;
        local_c = piVar3;
      }
      piVar4 = (int *)FUN_004d4d1c((char *)0x0,&DAT_0050b59e);
      piVar3 = local_c;
      local_10 = piVar6;
    }
    FUN_004de420(piVar2);
  }
  return piVar3;
}



/* @0049aed8 file=? name=FUN_0049aed8 */

int * __cdecl FUN_0049aed8(char *param_1,char *param_2)

{
  int *piVar1;
  char *pcVar2;
  int *piVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  int local_c;
  int *local_8;
  
  piVar1 = FUN_0049a920(param_2);
  if (piVar1 == (int *)0x0) {
    FUN_004d6f80(&DAT_0051f830,s_du___path_searching___out_of_mem_0050b5a0);
    local_8 = (int *)0x0;
  }
  else {
    piVar5 = (int *)0x0;
    iVar4 = 0;
    pcVar2 = FUN_004d4d1c((char *)piVar1,&DAT_0050b5c5);
    while (pcVar2 != (char *)0x0) {
      if (iVar4 == 0) {
        piVar5 = FUN_004de55c(4);
      }
      else {
        piVar5 = FUN_004de760(piVar5,(iVar4 + 1) * 4);
      }
      if (piVar5 == (int *)0x0) {
        FUN_004d6f80(&DAT_0051f830,s_du___path_searching___out_of_mem_0050b5c7);
        return (int *)0x0;
      }
      piVar5[iVar4] = (int)pcVar2;
      iVar4 = iVar4 + 1;
      pcVar2 = FUN_004d4d1c((char *)0x0,&DAT_0050b5ec);
    }
    if (iVar4 == 0) {
      local_8 = (int *)0x0;
    }
    else {
      local_8 = (int *)0x0;
      local_c = 0;
      piVar6 = piVar5;
      if (0 < iVar4) {
        do {
          piVar3 = FUN_0049ad00(param_1,(char *)*piVar6,2);
          if (local_8 != (int *)0x0) {
            FUN_0049a88c((int *)&local_8,piVar3);
            piVar3 = local_8;
          }
          local_8 = piVar3;
          local_c = local_c + 1;
          piVar6 = piVar6 + 1;
        } while (local_c < iVar4);
      }
      FUN_004de420(piVar5);
      FUN_004de420(piVar1);
    }
  }
  return local_8;
}



/* @0049afe8 file=? name=FUN_0049afe8 */

bool __cdecl
FUN_0049afe8(LPCSTR param_1,int param_2,char *param_3,undefined4 param_4,undefined4 *param_5)

{
  int *piVar1;
  
  piVar1 = FUN_004d6f54(param_1,param_3);
  *param_5 = piVar1;
  if ((piVar1 != (int *)0x0) && (param_2 == 0)) {
    FUN_004d6b08((int *)*param_5);
  }
  return piVar1 != (int *)0x0;
}



/* @0049b028 file=? name=FUN_0049b028 */

uint __cdecl
FUN_0049b028(char *param_1,undefined4 *param_2,int *param_3,int param_4,char *param_5,
            undefined4 param_6,undefined4 *param_7)

{
  char cVar1;
  bool bVar2;
  int iVar3;
  undefined3 extraout_var;
  undefined3 extraout_var_00;
  uint uVar4;
  uint uVar5;
  char *pcVar6;
  char *pcVar7;
  int local_c;
  
  uVar5 = 0;
  if (param_2 == (undefined4 *)0x0) {
    bVar2 = FUN_0049afe8(param_1,param_4,param_5,param_6,param_7);
    uVar5 = CONCAT31(extraout_var_00,bVar2);
  }
  else {
    iVar3 = FUN_004d4a78(param_1);
    local_c = 0;
    while (((char *)*param_2 != (char *)0x0 && (uVar5 == 0))) {
      uVar5 = 0xffffffff;
      pcVar6 = (char *)*param_2;
      do {
        pcVar7 = pcVar6;
        if (uVar5 == 0) break;
        uVar5 = uVar5 - 1;
        pcVar7 = pcVar6 + 1;
        cVar1 = *pcVar6;
        pcVar6 = pcVar7;
      } while (cVar1 != '\0');
      uVar5 = ~uVar5;
      pcVar6 = pcVar7 + -uVar5;
      pcVar7 = param_1 + iVar3;
      for (uVar4 = uVar5 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
        *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
        pcVar6 = pcVar6 + 4;
        pcVar7 = pcVar7 + 4;
      }
      for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
        *pcVar7 = *pcVar6;
        pcVar6 = pcVar6 + 1;
        pcVar7 = pcVar7 + 1;
      }
      bVar2 = FUN_0049afe8(param_1,param_4,param_5,param_6,param_7);
      uVar5 = CONCAT31(extraout_var,bVar2);
      if (uVar5 != 0) {
        *param_3 = local_c;
      }
      local_c = local_c + 1;
      param_2 = param_2 + 1;
    }
  }
  return uVar5;
}



/* @0049b0dc file=? name=FUN_0049b0dc */

uint __cdecl
FUN_0049b0dc(char *param_1,undefined4 *param_2,undefined4 *param_3,int param_4,char *param_5,
            undefined4 param_6,undefined4 *param_7,undefined4 *param_8,uint param_9,int *param_10,
            int param_11)

{
  char cVar1;
  bool bVar2;
  int iVar3;
  uint uVar4;
  int *piVar5;
  uint uVar6;
  char *pcVar7;
  int *piVar8;
  int *piVar9;
  char *pcVar10;
  char local_808 [2048];
  int local_8;
  
  bVar2 = true;
  if ((param_1 == (char *)0x0) || (param_2 == (undefined4 *)0x0)) {
    uVar4 = 0;
  }
  else {
    if (*param_1 == '~') {
      piVar5 = FUN_0049acb0(param_1);
      uVar4 = 0xffffffff;
      piVar8 = piVar5;
      do {
        piVar9 = piVar8;
        if (uVar4 == 0) break;
        uVar4 = uVar4 - 1;
        piVar9 = (int *)((int)piVar8 + 1);
        iVar3 = *piVar8;
        piVar8 = piVar9;
      } while ((char)iVar3 != '\0');
      uVar4 = ~uVar4;
      pcVar7 = (char *)((int)piVar9 - uVar4);
      pcVar10 = local_808;
      for (uVar6 = uVar4 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar10 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar10 = pcVar10 + 4;
      }
      for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
        *pcVar10 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar10 = pcVar10 + 1;
      }
      FUN_004de420(piVar5);
      bVar2 = false;
    }
    else if ((param_1[1] == ':') && (((&DAT_005207dd)[*param_1] & 0xc) != 0)) {
      uVar4 = 0xffffffff;
      pcVar7 = param_1;
      do {
        pcVar10 = pcVar7;
        if (uVar4 == 0) break;
        uVar4 = uVar4 - 1;
        pcVar10 = pcVar7 + 1;
        cVar1 = *pcVar7;
        pcVar7 = pcVar10;
      } while (cVar1 != '\0');
      uVar4 = ~uVar4;
      pcVar7 = pcVar10 + -uVar4;
      pcVar10 = local_808;
      for (uVar6 = uVar4 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
        *(undefined4 *)pcVar10 = *(undefined4 *)pcVar7;
        pcVar7 = pcVar7 + 4;
        pcVar10 = pcVar10 + 4;
      }
      for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
        *pcVar10 = *pcVar7;
        pcVar7 = pcVar7 + 1;
        pcVar10 = pcVar10 + 1;
      }
      bVar2 = false;
    }
    uVar4 = 0;
    if (bVar2) {
      while ((param_2 != (undefined4 *)0x0 && (uVar4 == 0))) {
        uVar4 = 0xffffffff;
        pcVar7 = (char *)*param_2;
        do {
          pcVar10 = pcVar7;
          if (uVar4 == 0) break;
          uVar4 = uVar4 - 1;
          pcVar10 = pcVar7 + 1;
          cVar1 = *pcVar7;
          pcVar7 = pcVar10;
        } while (cVar1 != '\0');
        uVar4 = ~uVar4;
        pcVar7 = pcVar10 + -uVar4;
        pcVar10 = local_808;
        for (uVar6 = uVar4 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
          *(undefined4 *)pcVar10 = *(undefined4 *)pcVar7;
          pcVar7 = pcVar7 + 4;
          pcVar10 = pcVar10 + 4;
        }
        for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
          *pcVar10 = *pcVar7;
          pcVar7 = pcVar7 + 1;
          pcVar10 = pcVar10 + 1;
        }
        FUN_004d49b8(local_808,&DAT_0050b5ee);
        FUN_004d49b8(local_808,param_1);
        uVar4 = FUN_0049b028(local_808,param_3,&local_8,param_4,param_5,param_6,param_7);
        param_2 = (undefined4 *)param_2[3];
      }
    }
    else {
      uVar4 = FUN_0049b028(local_808,param_3,&local_8,param_4,param_5,param_6,param_7);
    }
    if ((uVar4 != 0) && (param_8 != (undefined4 *)0x0)) {
      if (param_11 == 1) {
        FUN_0049aa2c(local_808);
      }
      FUN_004d4b9c(param_8,local_808,param_9);
    }
    if (param_10 != (int *)0x0) {
      *param_10 = local_8;
    }
  }
  return uVar4;
}



/* @0049b28c file=? name=FUN_0049b28c */

void __cdecl FUN_0049b28c(undefined *param_1)

{
  PTR_DAT_0050b524 = param_1;
  return;
}



/* @0049b29c file=? name=FUN_0049b29c */

void __cdecl FUN_0049b29c(undefined *param_1)

{
  PTR_DAT_0050b520 = param_1;
  return;
}



/* @0049b2ac file=? name=FUN_0049b2ac */

int * __cdecl FUN_0049b2ac(char *param_1,char *param_2,char *param_3)

{
  int *piVar1;
  char *pcVar2;
  int *local_8;
  
  local_8 = (int *)0x0;
  if (param_1 != (char *)0x0) {
    local_8 = FUN_0049ad00(param_1,(char *)0x0,0);
  }
  piVar1 = local_8;
  if ((param_2 != (char *)0x0) &&
     (piVar1 = FUN_0049ad00(param_2,(char *)0x0,1), local_8 != (int *)0x0)) {
    FUN_0049a88c((int *)&local_8,piVar1);
    piVar1 = local_8;
  }
  local_8 = piVar1;
  piVar1 = local_8;
  if (param_3 != (char *)0x0) {
    pcVar2 = (char *)FUN_004dee74(PTR_DAT_0050b520);
    if (pcVar2 == (char *)0x0) {
      pcVar2 = PTR_DAT_0050b524;
    }
    piVar1 = FUN_0049aed8(param_3,pcVar2);
    if (local_8 != (int *)0x0) {
      FUN_0049a88c((int *)&local_8,piVar1);
      piVar1 = local_8;
    }
  }
  local_8 = piVar1;
  return local_8;
}



/* @0049b344 file=? name=FUN_0049b344 */

void __cdecl FUN_0049b344(int param_1,char *param_2,uint param_3)

{
  int *in_EAX;
  char *pcVar1;
  
  if (param_3 < 2) {
    in_EAX = FUN_0049ad00(param_2,(char *)0x0,param_3);
  }
  else if (param_3 == 2) {
    pcVar1 = (char *)FUN_004dee74(PTR_DAT_0050b520);
    if (pcVar1 == (char *)0x0) {
      pcVar1 = PTR_DAT_0050b524;
    }
    in_EAX = FUN_0049aed8(param_2,pcVar1);
  }
  if (param_1 != 0) {
    FUN_0049a8a8(param_1,(int)in_EAX,param_3);
  }
  return;
}



/* @0049b3a0 file=? name=FUN_0049b3a0 */

undefined4 __cdecl
FUN_0049b3a0(char *param_1,undefined4 *param_2,undefined4 *param_3,char *param_4,undefined4 *param_5
            ,uint param_6,int *param_7,int param_8)

{
  uint uVar1;
  undefined4 local_8;
  
  uVar1 = FUN_0049b0dc(param_1,param_2,param_3,1,param_4,0,&local_8,param_5,param_6,param_7,param_8)
  ;
  if (uVar1 == 0) {
    local_8 = 0;
  }
  return local_8;
}



/* @0049b3e4 file=? name=FUN_0049b3e4 */

uint __cdecl
FUN_0049b3e4(char *param_1,undefined4 *param_2,undefined4 *param_3,uint param_4,undefined4 *param_5,
            uint param_6,int *param_7,int param_8)

{
  uint uVar1;
  undefined4 local_10;
  char local_c [8];
  
  if ((((param_4 & 1) == 0) && ((param_4 & 4) == 0)) && ((param_4 & 8) == 0)) {
    if ((param_4 & 2) == 0) {
      return 0;
    }
    local_c[0] = 'w';
    local_c[1] = 0;
  }
  else {
    local_c[0] = 'r';
    if ((param_4 & 2) != 0) {
      local_c[1] = 0x77;
      local_c[2] = 0;
    }
  }
  uVar1 = FUN_0049b0dc(param_1,param_2,param_3,0,local_c,0,&local_10,param_5,param_6,param_7,param_8
                      );
  return uVar1;
}



/* @0049b454 file=? name=FUN_0049b454 */

undefined4 __cdecl FUN_0049b454(undefined4 *param_1,undefined4 *param_2)

{
  *param_1 = param_2;
  return *param_2;
}



/* @0049b464 file=? name=FUN_0049b464 */

undefined4 __cdecl FUN_0049b464(int *param_1)

{
  undefined4 *puVar1;
  
  if (*param_1 == 0) {
    return 0;
  }
  puVar1 = *(undefined4 **)(*param_1 + 0xc);
  *param_1 = (int)puVar1;
  if (puVar1 != (undefined4 *)0x0) {
    return *puVar1;
  }
  return 0;
}



/* @0049b488 file=? name=FUN_0049b488 */

int * __cdecl FUN_0049b488(int *param_1,char *param_2)

{
  char *pcVar1;
  int *piVar2;
  int *piVar3;
  int *piVar4;
  char *pcVar5;
  char *pcVar6;
  bool bVar7;
  
  piVar3 = (int *)0x0;
  piVar4 = param_1;
  do {
    if (piVar4 == (int *)0x0) {
      return param_1;
    }
    pcVar5 = (char *)piVar4[2];
    pcVar6 = param_2;
    do {
      bVar7 = *pcVar5 == *pcVar6;
      if (!bVar7) break;
      if (*pcVar5 == '\0') goto LAB_0049b4bd;
      pcVar1 = pcVar5 + 1;
      bVar7 = *pcVar1 == pcVar6[1];
      if (!bVar7) break;
      pcVar5 = pcVar5 + 2;
      pcVar6 = pcVar6 + 2;
      bVar7 = *pcVar1 == '\0';
    } while (!bVar7);
    if (bVar7) {
LAB_0049b4bd:
      FUN_004de420((int *)*piVar4);
      FUN_004de420((int *)piVar4[2]);
      if (piVar3 == (int *)0x0) {
        param_1 = (int *)piVar4[3];
      }
      else {
        piVar3[3] = piVar4[3];
      }
      piVar2 = (int *)piVar4[3];
      FUN_004de420(piVar4);
      piVar4 = piVar2;
    }
    else {
      piVar3 = piVar4;
      piVar4 = (int *)piVar4[3];
    }
  } while( true );
}



/* @0049b500 file=? name=FUN_0049b500 */

void __cdecl FUN_0049b500(int *param_1)

{
  int *piVar1;
  
  while (param_1 != (int *)0x0) {
    FUN_004de420((int *)*param_1);
    FUN_004de420((int *)param_1[2]);
    piVar1 = (int *)param_1[3];
    FUN_004de420(param_1);
    param_1 = piVar1;
  }
  return;
}



/* @0049b54c file=? name=FUN_0049b54c */

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

undefined4 * __cdecl FUN_0049b54c(undefined4 *param_1,int param_2,int param_3)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  
  FUN_0044d1c0(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050b6b4;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(puVar2);
  }
  param_1[0x3a] = iVar3;
  piVar1 = (int *)(param_1[0x3a] + 0xc);
  *piVar1 = *piVar1 + 1;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(puVar2);
  }
  param_1[0x3b] = iVar3;
  piVar1 = (int *)(param_1[0x3b] + 0xc);
  *piVar1 = *piVar1 + 1;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(puVar2);
  }
  param_1[0x3e] = iVar3;
  piVar1 = (int *)(param_1[0x3e] + 0xc);
  *piVar1 = *piVar1 + 1;
  param_1[0x39] = 0;
  param_1[0x3c] = 0;
  iVar3 = FUN_00404118(param_2,s_mission_0050b635,s_temperature_0050b63d,(float *)(param_1 + 0x3d));
  if (iVar3 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_ERROR__no_temperature_in_egg__0050b649,(char *)0x0);
    FUN_004036a0(1);
  }
  param_1[0x3d] = _DAT_0049b644 + (float)param_1[0x3d];
  return param_1;
}



/* @0049b648 file=? name=FUN_0049b648 */

void __cdecl FUN_0049b648(int *param_1,byte param_2)

{
  int *piVar1;
  int *piVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b6b4;
    piVar2 = (int *)param_1[0x3e];
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    piVar2 = (int *)param_1[0x3b];
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    piVar2 = (int *)param_1[0x3a];
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    FUN_0044d5d4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049b6bc file=bt/btmssn.cpp name=FUN_0049b6bc */

void FUN_0049b6bc(void)

{
  FUN_0040385c(s_Should_never_reach_BTMission__Se_0050b668,s_d__tesla_bt_bt_BTMSSN_CPP_0050b698,0x45
              );
  return;
}



/* @0049b6d8 file=? name=FUN_0049b6d8 */

void __cdecl FUN_0049b6d8(int param_1,undefined4 param_2,int param_3)

{
  int iVar1;
  undefined4 *puVar2;
  
  if (*(int *)(param_1 + 0xe4) == 0) {
    *(undefined4 *)(param_1 + 0xe4) = param_2;
  }
  iVar1 = FUN_004084fc((float *)(param_1 + 0xec),(float *)&DAT_004e0f80,0.0001);
  if (iVar1 != 0) {
    FUN_00408440((float *)(param_1 + 0xec),(undefined4 *)(param_3 + 0x4c));
  }
  if (*(int *)(param_1 + 0xe8) == -1) {
    *(undefined4 *)(param_1 + 0xe8) = *(undefined4 *)(param_3 + 0x24);
  }
  puVar2 = (undefined4 *)FUN_00402298(0x14);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_00415e90(puVar2,1);
    *puVar2 = &PTR_FUN_0050b9a8;
  }
  puVar2[3] = *(undefined4 *)(param_3 + 0x2c);
  puVar2[4] = *(undefined4 *)(param_3 + 0x5c);
  (**(code **)(*(int *)(param_1 + 0x114) + 8))(param_1 + 0x114,puVar2,param_3 + 0x30);
  return;
}



/* @0049b784 file=? name=FUN_0049b784 */

void __cdecl FUN_0049b784(int param_1)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int *extraout_ECX;
  int *this;
  undefined4 uStack_b0;
  undefined4 uStack_ac;
  undefined **local_90;
  int local_8c;
  undefined4 local_78;
  undefined4 local_74;
  undefined4 local_70;
  undefined4 local_6c [2];
  undefined4 local_64;
  undefined4 local_60;
  undefined4 local_5c;
  undefined4 local_58;
  undefined4 local_54;
  undefined4 local_50;
  undefined4 local_4c [2];
  int local_44 [4];
  int local_34;
  undefined4 local_30;
  undefined4 local_2c;
  undefined4 local_28;
  undefined4 *local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18 [2];
  undefined4 *local_10;
  undefined4 local_c;
  int local_8;
  
  iVar3 = *(int *)(param_1 + 0xd0);
  FUN_0049c28b(local_44,param_1 + 0x114);
  this = local_44;
  local_8 = (**(code **)(local_44[0] + 0x14))();
  if (local_8 != 0) {
    local_c = *(undefined4 *)(param_1 + 0xe8);
    local_10 = (undefined4 *)(iVar3 + 0x184);
    local_78 = 0x34;
    local_74 = 0x13;
    local_70 = 1;
    FUN_00420ea4(local_6c,(undefined4 *)&DAT_00522524);
    local_64 = 0;
    local_60 = 0;
    local_5c = *(undefined4 *)(param_1 + 0xec);
    local_58 = *(undefined4 *)(param_1 + 0xf0);
    local_54 = *(undefined4 *)(param_1 + 0xf4);
    local_50 = local_c;
    FUN_00420ea4(local_4c,local_10);
    uStack_ac = 0x49b844;
    FUN_00419e18((int *)&local_90,0x13,0x34);
    local_90 = &PTR_FUN_0050b984;
    FUN_00420ef4((undefined4 *)(local_8c + 0x2c),local_4c);
    *(undefined4 *)(local_8c + 0x28) = local_50;
    FUN_00408440((undefined4 *)(local_8c + 0x1c),&local_5c);
    uStack_ac = 0x49b89d;
    (*(code *)local_90[8])();
    FUN_00420e8c(local_18);
    FUN_00420ef4(local_18,(undefined4 *)(iVar3 + 0x184));
    (**(code **)(local_44[0] + 8))();
    while (iVar2 = (**(code **)(local_44[0] + 0x30))(), iVar2 != 0) {
      uStack_ac = 0x49b8e3;
      (*(code *)local_90[8])();
      local_1c = *(undefined4 *)(local_34 + 0x1c);
      uStack_ac = 0x49b905;
      (*(code *)local_90[8])();
      uStack_ac = 0x49b91e;
      (*(code *)local_90[8])();
      iVar2 = *(int *)(*(int *)(iVar3 + 0x128) + *(int *)(iVar2 + 0x10) * 4);
      local_20 = *(undefined4 *)(iVar2 + 0x3e4);
      iVar1 = (**(code **)(*(int *)(param_1 + 0xfc) + 0xc))();
      if (iVar1 == 0) {
        local_24 = (undefined4 *)FUN_00402298(0x10);
        if (local_24 != (undefined4 *)0x0) {
          local_28 = *(undefined4 *)(iVar2 + 0x3e4);
          FUN_00424716(local_24,&local_28);
        }
        local_2c = *(undefined4 *)(iVar2 + 0x3e4);
        uStack_ac = 0x49b99e;
        (**(code **)(*(int *)(param_1 + 0xfc) + 8))();
      }
      (**(code **)(local_44[0] + 0x10))();
    }
    local_30 = 0;
    iVar3 = FUN_0041a1a4(**(int **)(*(int *)(param_1 + 0xe4) + 0xc),0x4e6f54);
    if (iVar3 != 0) {
      local_30 = 1;
    }
    FUN_00420ea4(&uStack_b0,(undefined4 *)(*(int *)(param_1 + 0xe4) + 0x184));
    FUN_0049baa0(param_1);
    (**(code **)(**(int **)(param_1 + 0xe4) + 0xc))();
    FUN_00403310((int *)&local_90,0);
    this = extraout_ECX;
  }
  FUN_00417858(this,local_44,1);
  *(undefined4 *)(param_1 + 0xe4) = 0;
  *(undefined4 *)(param_1 + 0xe8) = 0xffffffff;
  FUN_00408440((undefined4 *)(param_1 + 0xec),&DAT_004e0f80);
  FUN_0049c2c9(local_44,2);
  return;
}



/* @0049baa0 file=? name=FUN_0049baa0 */

void __cdecl FUN_0049baa0(int param_1)

{
  undefined4 uVar1;
  int *piVar2;
  uint *puVar3;
  int iVar4;
  uint local_a8 [5];
  undefined4 local_94;
  undefined4 local_90;
  undefined4 local_8c;
  undefined4 local_88 [2];
  undefined4 local_80;
  undefined4 local_7c;
  undefined4 local_78;
  undefined4 local_74;
  undefined4 local_70;
  undefined4 local_6c;
  undefined4 local_68;
  undefined4 local_64;
  undefined4 local_60;
  undefined4 local_5c [2];
  undefined4 local_54 [2];
  undefined4 local_4c;
  undefined4 local_48;
  undefined4 local_44;
  undefined4 local_40;
  undefined4 local_3c;
  undefined4 local_38;
  undefined4 local_34;
  int local_30 [4];
  int local_20;
  float local_1c;
  int local_18;
  undefined4 local_14;
  float local_10;
  float local_c;
  int local_8;
  
  FUN_0049c314(local_30,param_1 + 0xfc);
  local_4c = DAT_004e0fec;
  local_48 = DAT_004e0ff0;
  local_44 = DAT_004e0ff4;
  local_40 = DAT_004e0ff8;
  local_3c = DAT_004e0ffc;
  local_38 = DAT_004e1000;
  local_34 = DAT_004e1004;
  piVar2 = (int *)FUN_00414b60();
  local_8 = *piVar2;
  local_c = 0.1;
  local_10 = 0.0;
  local_14 = *(undefined4 *)(DAT_004efc94 + 0x28);
  FUN_00408440(&local_4c,(undefined4 *)&stack0x00000014);
  while( true ) {
    piVar2 = local_30;
    iVar4 = (**(code **)(local_30[0] + 0x30))();
    if (iVar4 == 0) break;
    iVar4 = *(int *)(param_1 + 0xd0);
    uVar1 = *(undefined4 *)(local_20 + 0x1c);
    local_a8[0] = 0x5c;
    local_a8[1] = 3;
    local_a8[2] = 1;
    FUN_00420ea4(local_a8 + 3,(undefined4 *)&DAT_00522524);
    local_94 = 0;
    local_90 = 0;
    local_8c = 0x31;
    FUN_00420ea4(local_88,(undefined4 *)&DAT_00522524);
    local_7c = 0x100;
    local_78 = local_4c;
    local_74 = local_48;
    local_70 = local_44;
    local_6c = local_40;
    local_68 = local_3c;
    local_64 = local_38;
    local_60 = local_34;
    local_80 = uVar1;
    FUN_00420ea4(local_5c,(undefined4 *)&stack0x0000000c);
    FUN_00420ea4(local_54,(undefined4 *)(iVar4 + 0x184));
    local_10 = local_c + local_10;
    puVar3 = (uint *)FUN_004336f0(local_a8);
    local_18 = local_8;
    local_1c = local_10;
    iVar4 = FUN_004dcd94();
    local_18 = local_18 + iVar4;
    FUN_0041acbc(*(int *)(DAT_004efc94 + 0x60),3,local_14,puVar3,local_18);
    FUN_004022d0((int *)puVar3);
    (**(code **)(local_30[0] + 0xc))(local_30);
  }
  FUN_00417858(piVar2,local_30,1);
  FUN_0049c352(local_30,2);
  return;
}



/* @0049bca4 file=? name=FUN_0049bca4 */

undefined4 * __cdecl
FUN_0049bca4(undefined4 *param_1,undefined4 param_2,undefined4 param_3,char *param_4,
            undefined4 param_5)

{
  undefined4 *puVar1;
  
  FUN_0041c52c(param_1,param_2,param_3,param_4,param_5);
  *param_1 = &PTR_FUN_0050b954;
  FUN_0049bfde(param_1 + 0x3f,0,1);
  FUN_0049c123(param_1 + 0x45,0,0);
  puVar1 = (undefined4 *)FUN_00402298(0x160);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0041de1c(puVar1,param_1,0);
  }
  param_1[0x38] = puVar1;
  param_1[7] = PTR_FUN_0050b6fc;
  param_1[8] = DAT_0050b700;
  param_1[9] = DAT_0050b704;
  param_1[0x4b] = *(undefined4 *)(param_4 + 0x30);
  param_1[0x3e] = *(undefined4 *)(param_4 + 0x34);
  param_1[0x39] = 0;
  param_1[0x3a] = 0xffffffff;
  FUN_00408440(param_1 + 0x3b,&DAT_004e0f80);
  return param_1;
}



/* @0049bd7c file=? name=FUN_0049bd7c */

void __cdecl FUN_0049bd7c(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  void *this;
  int local_18 [5];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b954;
    puVar1 = (undefined4 *)param_1[0x38];
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
    FUN_0049c28b(local_18,(int)(param_1 + 0x45));
    FUN_00417858(this,local_18,1);
    FUN_0049c2c9(local_18,2);
    FUN_0049c146(param_1 + 0x45,2);
    FUN_0049c001(param_1 + 0x3f,2);
    FUN_0041c648(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049be10 file=? name=FUN_0049be10 */

undefined4 __cdecl
FUN_0049be10(int param_1,int param_2,char *param_3,char *param_4,char *param_5,int param_6,
            int param_7)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  char *local_8;
  
  iVar1 = FUN_0041c684(param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    param_5[0x20] = -0x2d;
    param_5[0x21] = '\v';
    param_5[0x22] = '\0';
    param_5[0x23] = '\0';
    param_5[0x24] = '8';
    param_5[0x25] = '\0';
    param_5[0x26] = '\0';
    param_5[0x27] = '\0';
    iVar1 = FUN_00404088(param_6,param_4,s_TerrainHitExplosion_0050b761,&local_8);
    if (iVar1 == 0) {
      FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_missing_TerrainHitExplosion__0050b775,(char *)0x0);
      uVar2 = 0;
    }
    else {
      puVar3 = (undefined4 *)FUN_00406ff8(param_1,local_8,1,-1);
      if (puVar3 == (undefined4 *)0x0) {
        FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_cannot_find_0050b794,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_8,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_in_resource_file__0050b7a2,(char *)0x0);
        uVar2 = 0;
      }
      else {
        *(undefined4 *)(param_5 + 0x30) = *puVar3;
        iVar1 = FUN_00404118(param_6,param_4,s_RendererCompensateTime_0050b7b6,
                             (float *)(param_5 + 0x34));
        if (iVar1 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_RendererCompensateTime___0050b7cd,(char *)0x0);
          uVar2 = 0;
        }
        else {
          uVar2 = 1;
        }
      }
    }
  }
  return uVar2;
}



/* @0049bf54 file=? name=FUN_0049bf54 */

void __cdecl FUN_0049bf54(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50b6cc);
  return;
}



/* @0049bfde file=? name=FUN_0049bfde */

undefined4 * __cdecl FUN_0049bfde(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  FUN_004186ac(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050b938;
  return param_1;
}



/* @0049c001 file=? name=FUN_0049c001 */

void __cdecl FUN_0049c001(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b938;
    FUN_004186dc(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_0049c0d8(param_1);
    }
  }
  return;
}



/* @0049c02d file=? name=FUN_0049c02d */

undefined4 __cdecl FUN_0049c02d(undefined4 param_1,int param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(int *)(param_3 + 0x1c) == *(int *)(param_2 + 0x1c)) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
    if (*(int *)(param_2 + 0x1c) <= *(int *)(param_3 + 0x1c)) {
      uVar1 = 0xffffffff;
    }
  }
  return uVar1;
}



/* @0049c05c file=? name=FUN_0049c05c */

undefined4 __cdecl FUN_0049c05c(undefined4 param_1,int *param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(int *)(param_3 + 0x1c) == *param_2) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
    if (*param_2 <= *(int *)(param_3 + 0x1c)) {
      uVar1 = 0xffffffff;
    }
  }
  return uVar1;
}



/* @0049c088 file=? name=FUN_0049c088 */

void FUN_0049c088(void)

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = DAT_0050b858;
  DAT_0050b858 = DAT_0050b858 + 1;
  puVar2 = DAT_0050b854;
  if ((iVar1 == 0) && (puVar2 = (undefined4 *)FUN_00402298(0x28), puVar2 != (undefined4 *)0x0)) {
    FUN_00402b98(puVar2,0x18,100,100,s_VChainOf_0050b7f1);
  }
  DAT_0050b854 = puVar2;
  FUN_00402f74((int)DAT_0050b854);
  return;
}



/* @0049c0d8 file=? name=FUN_0049c0d8 */

void __cdecl FUN_0049c0d8(undefined4 *param_1)

{
  FUN_00402f98((int)DAT_0050b854,param_1);
  DAT_0050b858 = DAT_0050b858 + -1;
  if (DAT_0050b858 == 0) {
    if (DAT_0050b854 != (int *)0x0) {
      FUN_00402c28(DAT_0050b854,0);
      FUN_004022d0(DAT_0050b854);
    }
    DAT_0050b854 = (int *)0x0;
  }
  return;
}



/* @0049c123 file=? name=FUN_0049c123 */

undefined4 * __cdecl FUN_0049c123(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  FUN_004186ac(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050b91c;
  return param_1;
}



/* @0049c146 file=? name=FUN_0049c146 */

void __cdecl FUN_0049c146(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b91c;
    FUN_004186dc(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_0049c221(param_1);
    }
  }
  return;
}



/* @0049c172 file=? name=FUN_0049c172 */

undefined4 __cdecl FUN_0049c172(undefined4 param_1,int param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(float *)(param_2 + 0x1c) == *(float *)(param_3 + 0x1c)) {
    return 0;
  }
  if (*(float *)(param_2 + 0x1c) <= *(float *)(param_3 + 0x1c)) {
    uVar1 = 0xffffffff;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0049c1a3 file=? name=FUN_0049c1a3 */

undefined4 __cdecl FUN_0049c1a3(undefined4 param_1,float *param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*param_2 == *(float *)(param_3 + 0x1c)) {
    return 0;
  }
  if (*param_2 <= *(float *)(param_3 + 0x1c)) {
    uVar1 = 0xffffffff;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0049c1d1 file=? name=FUN_0049c1d1 */

void FUN_0049c1d1(void)

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = DAT_0050b860;
  DAT_0050b860 = DAT_0050b860 + 1;
  puVar2 = DAT_0050b85c;
  if ((iVar1 == 0) && (puVar2 = (undefined4 *)FUN_00402298(0x28), puVar2 != (undefined4 *)0x0)) {
    FUN_00402b98(puVar2,0x18,100,100,s_VChainOf_0050b7fa);
  }
  DAT_0050b85c = puVar2;
  FUN_00402f74((int)DAT_0050b85c);
  return;
}



/* @0049c221 file=? name=FUN_0049c221 */

void __cdecl FUN_0049c221(undefined4 *param_1)

{
  FUN_00402f98((int)DAT_0050b85c,param_1);
  DAT_0050b860 = DAT_0050b860 + -1;
  if (DAT_0050b860 == 0) {
    if (DAT_0050b85c != (int *)0x0) {
      FUN_00402c28(DAT_0050b85c,0);
      FUN_004022d0(DAT_0050b85c);
    }
    DAT_0050b85c = (int *)0x0;
  }
  return;
}



/* @0049c26c file=? name=FUN_0049c26c */

undefined4 * __cdecl FUN_0049c26c(undefined4 *param_1,int param_2)

{
  FUN_004188dc(param_1,param_2);
  *param_1 = &PTR_FUN_0050b8c0;
  return param_1;
}



/* @0049c28b file=? name=FUN_0049c28b */

undefined4 * __cdecl FUN_0049c28b(undefined4 *param_1,int param_2)

{
  FUN_004188dc(param_1,param_2);
  *param_1 = &PTR_FUN_0050b8c0;
  return param_1;
}



/* @0049c2aa file=? name=FUN_0049c2aa */

undefined4 * __cdecl FUN_0049c2aa(undefined4 *param_1,int param_2)

{
  FUN_00418904(param_1,param_2);
  *param_1 = &PTR_FUN_0050b8c0;
  return param_1;
}



/* @0049c2c9 file=? name=FUN_0049c2c9 */

void __cdecl FUN_0049c2c9(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b8c0;
    FUN_00418930(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049c2f5 file=? name=FUN_0049c2f5 */

undefined4 * __cdecl FUN_0049c2f5(undefined4 *param_1,int param_2)

{
  FUN_004188dc(param_1,param_2);
  *param_1 = &PTR_FUN_0050b864;
  return param_1;
}



/* @0049c314 file=? name=FUN_0049c314 */

undefined4 * __cdecl FUN_0049c314(undefined4 *param_1,int param_2)

{
  FUN_004188dc(param_1,param_2);
  *param_1 = &PTR_FUN_0050b864;
  return param_1;
}



/* @0049c333 file=? name=FUN_0049c333 */

undefined4 * __cdecl FUN_0049c333(undefined4 *param_1,int param_2)

{
  FUN_00418904(param_1,param_2);
  *param_1 = &PTR_FUN_0050b864;
  return param_1;
}



/* @0049c352 file=? name=FUN_0049c352 */

void __cdecl FUN_0049c352(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050b864;
    FUN_00418930(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049c37e file=? name=FUN_0049c37e */

undefined4 * __cdecl FUN_0049c37e(undefined4 param_1,int param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_0042ea6b();
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0042ea14(puVar1,param_1,param_2,param_3);
  }
  return puVar1;
}



/* @0049c3ae file=? name=FUN_0049c3ae */

undefined4 * __cdecl FUN_0049c3ae(undefined4 param_1,int param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00424ac5();
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00424a6e(puVar1,param_1,param_2,param_3);
  }
  return puVar1;
}



/* @0049c3de file=? name=FUN_0049c3de */

void FUN_0049c3de(void)

{
  return;
}



/* @0049c3e3 file=? name=FUN_0049c3e3 */

void __cdecl FUN_0049c3e3(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    FUN_00415ed8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049c40c file=? name=FUN_0049c40c */

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

void __cdecl FUN_0049c40c(int param_1)

{
  float fVar1;
  int iVar2;
  int *piVar3;
  float10 fVar4;
  
  iVar2 = FUN_0042104c((int *)&stack0x00000008,(int *)(param_1 + 0x180));
  if (iVar2 == 0) {
    iVar2 = FUN_0049c600(param_1);
  }
  else {
    piVar3 = (int *)FUN_00414b60();
    fVar1 = (float)*piVar3 / DAT_0052140c - *(float *)(param_1 + 0x17c);
    if (_DAT_0049c50c <= fVar1) {
      if (fVar1 <= _DAT_0049c510) {
        fVar4 = FUN_00408050();
        if ((float)fVar4 <= (float)_DAT_0049c514) {
          iVar2 = *(int *)(param_1 + 0x178);
        }
        else {
          iVar2 = FUN_0049c600(param_1);
        }
      }
      else {
        iVar2 = FUN_0049c600(param_1);
      }
    }
    else {
      iVar2 = *(int *)(param_1 + 0x178);
    }
  }
  *(int *)(param_1 + 0x178) = iVar2;
  piVar3 = (int *)FUN_00414b60();
  *(float *)(param_1 + 0x17c) = (float)*piVar3 / DAT_0052140c;
  FUN_00420ef4((undefined4 *)(param_1 + 0x180),(undefined4 *)&stack0x00000008);
  piVar3 = *(int **)(*(int *)(*(int *)(param_1 + 0xc) + 0x120) + iVar2 * 4);
  (**(code **)(*piVar3 + 0x18))(piVar3,&stack0x00000010);
  FUN_0049c51c(param_1);
  return;
}



/* @0049c51c file=? name=FUN_0049c51c */

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

void __cdecl FUN_0049c51c(int param_1)

{
  int iVar1;
  float fVar2;
  int iVar3;
  int local_2c [7];
  float local_10;
  uint local_c;
  float local_8;
  
  iVar1 = *(int *)(param_1 + 0xc);
  local_c = 0;
  local_8 = 0.0;
  FUN_00424830(local_2c,param_1 + 0x160);
  while (iVar3 = (**(code **)(local_2c[0] + 0x28))(local_2c), iVar3 != 0) {
    local_10 = *(float *)(*(int *)(*(int *)(iVar1 + 0x120) + *(int *)(iVar3 + 0xc) * 4) + 0x158);
    local_c = local_c + 1;
    local_8 = local_10 + local_8;
  }
  fVar2 = _DAT_0049c5f8;
  if (local_c != 0) {
    fVar2 = local_8 / (float)local_c;
  }
  *(float *)(param_1 + 0x158) = fVar2;
  fVar2 = _DAT_0049c5f8;
  if ((_DAT_0049c5f8 <= *(float *)(param_1 + 0x158)) &&
     (fVar2 = _DAT_0049c5fc, *(float *)(param_1 + 0x158) <= _DAT_0049c5fc)) {
    fVar2 = *(float *)(param_1 + 0x158);
  }
  *(float *)(param_1 + 0x158) = fVar2;
  FUN_0042484f(local_2c,2);
  return;
}



/* @0049c600 file=? name=FUN_0049c600 */

undefined4 __cdecl FUN_0049c600(int param_1)

{
  uint uVar1;
  int iVar2;
  undefined4 uVar3;
  int local_20 [7];
  
  FUN_00424830(local_20,param_1 + 0x160);
  uVar1 = (**(code **)(local_20[0] + 0x14))(local_20);
  iVar2 = FUN_0040807c(&DAT_00521f5c,uVar1);
  iVar2 = (**(code **)(local_20[0] + 0x34))(local_20,iVar2);
  uVar3 = *(undefined4 *)(iVar2 + 0xc);
  FUN_0042484f(local_20,2);
  return uVar3;
}



/* @0049c66c file=? name=FUN_0049c66c */

void __cdecl FUN_0049c66c(int param_1,int param_2)

{
  FUN_0041bbd8(param_1 + 100,param_2);
  *(uint *)(param_1 + 0xb8) = *(uint *)(param_1 + 0xb8) | 8;
  return;
}



/* @0049c690 file=? name=FUN_0049c690 */

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

void __cdecl FUN_0049c690(int *param_1,int *param_2)

{
  int iVar1;
  float fVar2;
  int iVar3;
  int iVar4;
  undefined4 auStack_78 [2];
  int iStack_70;
  int iStack_6c;
  int iStack_68;
  int iStack_64;
  int iStack_60;
  int iStack_5c;
  int iStack_58;
  int iStack_54;
  int iStack_50;
  int iStack_4c;
  int local_34 [7];
  int *local_18;
  int *local_14;
  int *local_10;
  undefined4 local_c [2];
  
  iVar1 = param_1[3];
  iStack_4c = 0x49c6b2;
  FUN_00424830(local_34,(int)(param_1 + 0x58));
  iVar3 = (**(code **)(local_34[0] + 0x14))();
  if (iVar3 == 0) {
    iStack_4c = 0x49c793;
    FUN_0041e4e0(param_1,param_2);
    iVar3 = FUN_00417ab4((int)(param_1 + 0x62));
    if (iVar3 != 0) {
      FUN_0049c51c(iVar3);
    }
    if ((*param_2 == 4) && (0 < param_1[0x6b])) {
      iStack_4c = 0x49c7d0;
      iVar3 = FUN_0040807c(&DAT_00521f5c,param_1[0x6b]);
      iVar3 = FUN_00417ab4(*(int *)(param_1[0x6d] + iVar3 * 4) + 4);
      iStack_4c = 0x49c7f8;
      iVar4 = FUN_0041a1a4(**(int **)(iVar3 + 0xc),0x50f4bc);
      if (iVar4 != 0) {
        FUN_004b11bc(iVar3);
      }
    }
    if ((param_1[0x66] == 0) || ((float)param_1[0x56] < _DAT_0049c99c)) {
      if ((param_1[0x6a] == 0) && (param_1[0x69] == 0)) {
        if (_DAT_0049c99c <= (float)param_1[0x56]) {
          iStack_4c = 0x49c943;
          FUN_0049cad4(param_1,iVar1);
        }
      }
      else if (*(int *)(iVar1 + 0x40) - 3U < 2) {
        if ((param_1[0x6a] == 0) || ((float)param_1[0x56] < _DAT_0049c99c)) {
          if ((param_1[0x69] != 0) && (_DAT_0049c99c <= (float)param_1[0x56])) {
            iStack_4c = 0x49c8c5;
            FUN_0041bbd8(iVar1 + 0x2c,9);
          }
        }
        else {
          iStack_4c = 0x49c88f;
          FUN_0041bbd8(iVar1 + 0x2c,9);
        }
      }
      else {
        iVar3 = FUN_0049fb54(iVar1);
        if (iVar3 == 0) {
          if ((param_1[0x6a] == 0) || ((float)param_1[0x56] < _DAT_0049c9a0)) {
            if ((param_1[0x69] != 0) && (_DAT_0049c9a0 <= (float)param_1[0x56])) {
              iStack_4c = 0x49c926;
              FUN_0041bbd8(iVar1 + 0x2c,3);
            }
          }
          else {
            iStack_4c = 0x49c8fb;
            FUN_0041bbd8(iVar1 + 0x2c,4);
          }
        }
      }
    }
    else {
      iStack_4c = 0x49c82e;
      FUN_0041bbd8((int)(param_1 + 4),1);
      iStack_4c = 0x49c83c;
      FUN_0041bbd8(iVar1 + 0x2c,9);
    }
    fVar2 = _DAT_0049c9a4;
    if ((_DAT_0049c9a4 <= (float)param_1[0x56]) &&
       (fVar2 = _DAT_0049c99c, (float)param_1[0x56] <= _DAT_0049c99c)) {
      fVar2 = (float)param_1[0x56];
    }
    param_1[0x56] = (int)fVar2;
    iStack_4c = 0x49c98f;
    FUN_0042484f(local_34,2);
  }
  else {
    iStack_4c = 0x49c6d8;
    FUN_00420ea4(local_c,(undefined4 *)(iVar1 + 0x43c));
    iStack_70 = *param_2;
    local_10 = param_2 + 2;
    iStack_6c = param_2[1];
    iStack_68 = *local_10;
    iStack_64 = param_2[3];
    local_14 = param_2 + 5;
    iStack_60 = param_2[4];
    iStack_5c = *local_14;
    iStack_58 = param_2[6];
    local_18 = param_2 + 8;
    iStack_54 = param_2[7];
    iStack_50 = *local_18;
    iStack_4c = param_2[9];
    FUN_00420ea4(auStack_78,local_c);
    FUN_0049c40c((int)param_1);
    iStack_4c = 0x49c784;
    FUN_0042484f(local_34,2);
  }
  return;
}



/* @0049c9a8 file=? name=FUN_0049c9a8 */

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

void __cdecl FUN_0049c9a8(int param_1)

{
  int iVar1;
  int iVar2;
  float fVar3;
  int *piVar4;
  int iVar5;
  
  FUN_0041bbd8(param_1 + 0x10,1);
  *(undefined4 *)(param_1 + 0x158) = 0x3f800000;
  for (iVar5 = 0; iVar5 < *(int *)(param_1 + 0x1ac); iVar5 = iVar5 + 1) {
    piVar4 = (int *)FUN_00417ab4(*(int *)(*(int *)(param_1 + 0x1b4) + iVar5 * 4) + 4);
    iVar1 = *(int *)(*(int *)(param_1 + 0x1b4) + iVar5 * 4);
    iVar2 = piVar4[0x38];
    *(float *)(iVar2 + 0x158) =
         (*(float *)(iVar1 + 0x10) - *(float *)(iVar1 + 0x14)) + *(float *)(iVar2 + 0x158);
    fVar3 = _DAT_0049cacc;
    if ((_DAT_0049cacc <= *(float *)(iVar2 + 0x158)) &&
       (fVar3 = _DAT_0049cad0, *(float *)(iVar2 + 0x158) <= _DAT_0049cad0)) {
      fVar3 = *(float *)(iVar2 + 0x158);
    }
    *(float *)(iVar2 + 0x158) = fVar3;
    if (_DAT_0049cad0 <= *(float *)(iVar2 + 0x158)) {
      if (piVar4[0x39] != 0) {
        FUN_0041bbd8(*(int *)(param_1 + 0xc) + 0x2c,9);
      }
      FUN_0041bbd8((int)(piVar4 + 0xb),1);
      if (piVar4[0x41] != 0) {
        (**(code **)(*piVar4 + 0x34))(piVar4);
      }
      FUN_0041bbd8(iVar2 + 0x10,1);
    }
  }
  return;
}



/* @0049cad4 file=? name=FUN_0049cad4 */

void __cdecl FUN_0049cad4(int *param_1,int param_2)

{
  undefined4 uVar1;
  int *piVar2;
  int iVar3;
  undefined4 *puVar4;
  int *piVar5;
  int local_50 [7];
  int local_34 [7];
  int *local_18;
  int *local_14;
  int *local_10;
  int *local_c;
  int local_8;
  
  FUN_0049c9a8((int)param_1);
  (**(code **)(*param_1 + 0xc))(param_1,1);
  iVar3 = param_1[0x65];
  FUN_0041f216(local_34,param_2 + 0x300);
  iVar3 = (**(code **)(local_34[0] + 0x34))(local_34,iVar3);
  FUN_0041f235(local_34,2);
  local_8 = iVar3;
  if (param_1[0x68] != 0) {
    puVar4 = (undefined4 *)FUN_00402298(0x1c);
    if (puVar4 == (undefined4 *)0x0) {
      local_10 = (int *)0x0;
      local_c = local_10;
    }
    else {
      local_10 = FUN_00424811(puVar4,local_8 + 0xd0);
      local_c = local_10;
    }
    while (iVar3 = (**(code **)(*local_c + 0x28))(local_c), iVar3 != 0) {
      piVar5 = *(int **)(*(int *)(param_2 + 0x120) + *(int *)(iVar3 + 0xc) * 4);
      if ((param_1 != piVar5) && (piVar5[0x1e] != 1)) {
        FUN_0049cad4(piVar5,param_2);
        (**(code **)(*piVar5 + 0xc))(piVar5,2);
      }
    }
    if (local_c != (int *)0x0) {
      (**(code **)*local_c)(local_c,3);
    }
  }
  if (param_1[0x67] != 0) {
    puVar4 = (undefined4 *)FUN_00402298(0x1c);
    if (puVar4 == (undefined4 *)0x0) {
      local_14 = (int *)0x0;
    }
    else {
      local_14 = FUN_00424811(puVar4,local_8 + 0xe8);
    }
    while (iVar3 = (**(code **)(*local_14 + 0x28))(local_14), iVar3 != 0) {
      uVar1 = *(undefined4 *)(iVar3 + 0xc);
      FUN_0041f216(local_50,param_2 + 0x300);
      iVar3 = (**(code **)(local_50[0] + 0x34))(local_50,uVar1);
      FUN_0041f235(local_50,2);
      puVar4 = (undefined4 *)FUN_00402298(0x1c);
      if (puVar4 == (undefined4 *)0x0) {
        local_18 = (int *)0x0;
        piVar5 = local_18;
      }
      else {
        local_18 = FUN_00424811(puVar4,iVar3 + 0xd0);
        piVar5 = local_18;
      }
      while (iVar3 = (**(code **)(*piVar5 + 0x28))(piVar5), iVar3 != 0) {
        piVar2 = *(int **)(*(int *)(param_2 + 0x120) + *(int *)(iVar3 + 0xc) * 4);
        FUN_0049cad4(piVar2,param_2);
        (**(code **)(*piVar2 + 0xc))(piVar2,2);
      }
      if (piVar5 != (int *)0x0) {
        (**(code **)*piVar5)(piVar5,3);
      }
    }
    if (local_14 != (int *)0x0) {
      (**(code **)*local_14)(local_14,3);
    }
  }
  return;
}



/* @0049ccc4 file=? name=FUN_0049ccc4 */

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

undefined4 __cdecl FUN_0049ccc4(int *param_1,int param_2)

{
  float fVar1;
  int *piVar2;
  undefined4 uVar3;
  int iVar4;
  int iVar5;
  float10 fVar6;
  float local_8;
  
  fVar1 = *(float *)(param_2 + 4) * _DAT_0049ce48;
  if (_DAT_0049ce4c < fVar1) {
    fVar1 = _DAT_0049ce4c;
  }
  *(float *)(param_2 + 4) = *(float *)(param_2 + 4) - fVar1;
  (**(code **)(*param_1 + 0x18))(param_1,param_2);
  fVar6 = FUN_00408050();
  if (param_1[0x6d] != 0) {
    for (iVar5 = 0; iVar5 < param_1[0x6b]; iVar5 = iVar5 + 1) {
      local_8 = *(float *)(*(int *)(param_1[0x6d] + iVar5 * 4) + 0x18);
      iVar4 = 0;
      piVar2 = (int *)param_1[0x6d];
      if (0 < iVar5) {
        do {
          local_8 = *(float *)(*piVar2 + 0x18) + local_8;
          iVar4 = iVar4 + 1;
          piVar2 = piVar2 + 1;
        } while (iVar4 < iVar5);
      }
      if ((float)fVar6 <= local_8 / (float)param_1[0x6c]) {
        piVar2 = (int *)FUN_00417ab4(*(int *)(param_1[0x6d] + iVar5 * 4) + 4);
        iVar4 = *(int *)(param_1[0x6d] + iVar5 * 4);
        if (*(float *)(iVar4 + 0x14) < *(float *)(iVar4 + 0x10)) {
          fVar6 = FUN_004ac07c(piVar2,param_2);
          iVar4 = *(int *)(param_1[0x6d] + iVar5 * 4);
          *(float *)(iVar4 + 0x14) = (float)(fVar6 + (float10)*(float *)(iVar4 + 0x14));
        }
        uVar3 = FUN_00417ab4(*(int *)(param_1[0x6d] + iVar5 * 4) + 4);
        return uVar3;
      }
    }
  }
  return 0;
}



/* @0049ce50 file=? name=FUN_0049ce50 */

/* WARNING: Type propagation algorithm not settling */
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

undefined4 * __cdecl FUN_0049ce50(undefined4 *param_1,int param_2,undefined4 param_3,int *param_4)

{
  int *piVar1;
  undefined4 *puVar2;
  undefined4 uVar3;
  float *pfVar4;
  int iVar5;
  float10 fVar6;
  undefined4 local_40;
  int local_3c;
  int *local_38;
  int local_34 [2];
  undefined4 *local_2c;
  float local_28;
  float local_24;
  int local_20;
  int *local_1c;
  undefined4 *local_18;
  int *local_14;
  undefined4 *local_10;
  int *local_c;
  undefined4 *local_8;
  
  FUN_0041df5c(param_1,param_2,param_3,param_4);
  *param_1 = &PTR_FUN_0050bb90;
  FUN_00424767(param_1 + 0x58,0,1);
  piVar1 = (int *)FUN_00414b60();
  param_1[0x5f] = (float)*piVar1 / DAT_0052140c;
  FUN_00420ea4(param_1 + 0x60,(undefined4 *)(param_2 + 0x184));
  FUN_0049ddc9(param_1 + 0x62,0);
  param_1[0x6c] = 0;
  (**(code **)(*param_4 + 0x1c))(param_4,param_1 + 0x67,4);
  (**(code **)(*param_4 + 0x1c))(param_4,param_1 + 0x68,4);
  (**(code **)(*param_4 + 0x1c))(param_4,param_1 + 0x65,4);
  (**(code **)(*param_4 + 0x1c))(param_4,param_1 + 0x69,4);
  local_8 = param_1 + 0x6a;
  local_c = param_4;
  (**(code **)(*param_4 + 0x1c))(param_4,local_8,4);
  local_10 = param_1 + 0x66;
  local_14 = param_4;
  (**(code **)(*param_4 + 0x1c))(param_4,local_10,4);
  local_18 = param_1 + 0x6b;
  local_1c = param_4;
  (**(code **)(*param_4 + 0x1c))(param_4,local_18,4);
  pfVar4 = (float *)(param_1 + 0x51);
  local_20 = 0;
  do {
    local_24 = _DAT_0049d1c4 / (float)param_1[0x50];
    local_28 = *pfVar4;
    fVar6 = FUN_004dcd00((double)(local_28 - local_24));
    if ((float10)_DAT_0049d1c8 < fVar6) {
      *pfVar4 = _DAT_0049d1c4 / (*pfVar4 * (float)param_1[0x50]);
    }
    if ((param_1[0x69] != 0) || (param_1[0x6a] != 0)) {
      *pfVar4 = *pfVar4 * _DAT_0049d1cc;
    }
    local_20 = local_20 + 1;
    pfVar4 = pfVar4 + 1;
  } while (local_20 < 5);
  if (param_1[0x6b] == 0) {
    param_1[0x6d] = 0;
  }
  else {
    uVar3 = FUN_004022b0(param_1[0x6b] << 2);
    param_1[0x6d] = uVar3;
    for (iVar5 = 0; iVar5 < (int)param_1[0x6b]; iVar5 = iVar5 + 1) {
      local_2c = (undefined4 *)FUN_00402298(0x1c);
      if (local_2c == (undefined4 *)0x0) {
        puVar2 = (undefined4 *)0x0;
      }
      else {
        puVar2 = FUN_0049dd18(local_2c,param_1);
      }
      *(undefined4 **)(param_1[0x6d] + iVar5 * 4) = puVar2;
    }
    local_34[1] = 0xffffffff;
    for (iVar5 = 0; iVar5 < (int)param_1[0x6b]; iVar5 = iVar5 + 1) {
      (**(code **)(*param_4 + 0x1c))(param_4,*(int *)(param_1[0x6d] + iVar5 * 4) + 0x18);
      (**(code **)(*param_4 + 0x1c))(param_4,*(int *)(param_1[0x6d] + iVar5 * 4) + 0x10);
      param_1[0x6c] = *(float *)(*(int *)(param_1[0x6d] + iVar5 * 4) + 0x18) + (float)param_1[0x6c];
      (**(code **)(*param_4 + 0x1c))(param_4,local_34 + 1);
      if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
        (**(code **)(*(int *)(*(int *)(param_1[0x6d] + iVar5 * 4) + 4) + 4))
                  (*(int *)(param_1[0x6d] + iVar5 * 4) + 4);
      }
    }
  }
  local_34[0] = 0;
  local_38 = param_4;
  (**(code **)(*param_4 + 0x1c))(param_4,local_34);
  local_3c = 0;
  if (0 < local_34[0]) {
    do {
      (**(code **)(*param_4 + 0x1c))(param_4,&local_40);
      puVar2 = (undefined4 *)FUN_00402298(0x10);
      if (puVar2 == (undefined4 *)0x0) {
        puVar2 = (undefined4 *)0x0;
      }
      else {
        puVar2 = FUN_00424716(puVar2,&local_40);
      }
      (**(code **)(param_1[0x58] + 8))(param_1 + 0x58,puVar2);
      local_3c = local_3c + 1;
    } while (local_3c < local_34[0]);
  }
  if (local_34[0] == 0) {
    param_1[0x5e] = 0;
  }
  else {
    uVar3 = FUN_0049c600((int)param_1);
    param_1[0x5e] = uVar3;
  }
  return param_1;
}



/* @0049d1d0 file=? name=FUN_0049d1d0 */

void __cdecl FUN_0049d1d0(int param_1)

{
  int iVar1;
  int iVar2;
  int local_20 [7];
  
  iVar1 = *(int *)(param_1 + 0xc);
  FUN_00424830(local_20,param_1 + 0x160);
  while( true ) {
    iVar2 = (**(code **)(local_20[0] + 0x28))(local_20);
    if (iVar2 == 0) break;
    iVar2 = *(int *)(*(int *)(iVar1 + 0x120) + *(int *)(iVar2 + 0xc) * 4);
    (**(code **)(*(int *)(iVar2 + 0x188) + 4))(iVar2 + 0x188,param_1);
  }
  FUN_0042484f(local_20,2);
  return;
}



/* @0049d23c file=? name=FUN_0049d23c */

void __cdecl FUN_0049d23c(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  void *this;
  int iVar2;
  int local_20 [7];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bb90;
    if (param_1[0x6d] != 0) {
      for (iVar2 = 0; iVar2 < param_1[0x6b]; iVar2 = iVar2 + 1) {
        puVar1 = *(undefined4 **)(param_1[0x6d] + iVar2 * 4);
        if (puVar1 != (undefined4 *)0x0) {
          (**(code **)*puVar1)(puVar1,3);
        }
      }
      FUN_004022d0((int *)param_1[0x6d]);
    }
    FUN_00424830(local_20,(int)(param_1 + 0x58));
    FUN_00417858(this,local_20,1);
    FUN_0042484f(local_20,2);
    FUN_0049dde8(param_1 + 0x62,2);
    FUN_0042478a(param_1 + 0x58,2);
    FUN_0041e394(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049d304 file=? name=FUN_0049d304 */

undefined4 __cdecl
FUN_0049d304(undefined4 param_1,uint param_2,char *param_3,int param_4,char *param_5,uint param_6,
            undefined4 *param_7,int *param_8)

{
  char *pcVar1;
  uint *puVar2;
  int iVar3;
  undefined4 uVar4;
  char *pcVar5;
  int *piVar6;
  undefined4 *puVar7;
  char *pcVar8;
  bool bVar9;
  undefined8 uVar10;
  uint uVar11;
  byte bVar12;
  undefined4 *puVar13;
  char local_ec [64];
  char *local_ac;
  int *local_a8;
  int local_a4;
  int *local_a0;
  int *local_9c;
  int *local_98;
  int local_94;
  int *local_90;
  char *local_8c;
  int *local_88;
  int *local_84;
  int *local_80;
  char *local_7c;
  int local_78;
  undefined1 local_74 [4];
  undefined1 local_70 [4];
  int *local_6c;
  int local_68;
  undefined4 *local_64;
  int *local_60;
  int *local_5c;
  char *local_58;
  char *local_54;
  undefined4 local_50;
  int *local_4c;
  char *local_48;
  char *local_44;
  int *local_40;
  int *local_3c;
  undefined4 local_38;
  undefined4 local_34;
  char *local_30;
  int *local_2c;
  uint *local_28;
  char *local_24;
  int local_20;
  int *local_1c;
  undefined4 local_18;
  int *local_14;
  undefined4 local_10;
  uint *local_c;
  char *local_8;
  
  local_8 = param_5;
  piVar6 = param_8;
  uVar11 = param_6;
  puVar13 = param_7;
  local_c = (uint *)FUN_00402298(0x10);
  if (local_c == (uint *)0x0) {
    puVar2 = (uint *)0x0;
  }
  else {
    puVar2 = FUN_00402460(local_c,local_8);
  }
  puVar2[3] = puVar2[3] + 1;
  iVar3 = FUN_0041e590(param_2,param_3,param_4,(int *)puVar2,piVar6,uVar11,(int)puVar13);
  if (iVar3 == 0) {
    uVar4 = 0xffffffff;
  }
  else {
    local_10 = 0;
    FUN_00404190(param_6,param_5,s_DescendOnDestruction_0050b9f1,&local_10);
    local_14 = param_8;
    (**(code **)(*param_8 + 0x20))(param_8,&local_10,4);
    local_18 = 0;
    FUN_00404190(param_6,param_5,s_DestroySiblingsOnDestruction_0050ba06,&local_18);
    local_1c = param_8;
    (**(code **)(*param_8 + 0x20))(param_8,&local_18,4);
    local_24 = param_5;
    iVar3 = param_4;
    local_28 = (uint *)FUN_00402298(0x10);
    if (local_28 == (uint *)0x0) {
      puVar2 = (uint *)0x0;
    }
    else {
      puVar2 = FUN_00402460(local_28,local_24);
    }
    puVar2[3] = puVar2[3] + 1;
    local_20 = FUN_0049db20((int *)puVar2,iVar3);
    local_2c = param_8;
    (**(code **)(*param_8 + 0x20))(param_8,&local_20,4);
    local_34 = 0;
    local_38 = 0;
    iVar3 = FUN_00404088(param_6,param_5,s_LegDamageZone_0050ba23,&local_30);
    if (iVar3 != 0) {
      pcVar8 = s_RightLeg_0050ba31;
      pcVar5 = local_30;
      do {
        if (*pcVar5 != *pcVar8) goto LAB_0049d486;
        bVar9 = true;
        if (*pcVar5 == '\0') break;
        pcVar1 = pcVar5 + 1;
        if (*pcVar1 != pcVar8[1]) goto LAB_0049d486;
        pcVar5 = pcVar5 + 2;
        pcVar8 = pcVar8 + 2;
        bVar9 = *pcVar1 == '\0';
      } while (!bVar9);
      if (bVar9) {
        local_38 = 1;
      }
LAB_0049d486:
      pcVar5 = s_LeftLeg_0050ba3a;
      do {
        if (*local_30 != *pcVar5) goto LAB_0049d4b3;
        bVar9 = true;
        if (*local_30 == '\0') break;
        pcVar8 = local_30 + 1;
        if (*pcVar8 != pcVar5[1]) goto LAB_0049d4b3;
        local_30 = local_30 + 2;
        pcVar5 = pcVar5 + 2;
        bVar9 = *pcVar8 == '\0';
      } while (!bVar9);
      if (bVar9) {
        local_34 = 1;
      }
    }
LAB_0049d4b3:
    local_3c = param_8;
    (**(code **)(*param_8 + 0x20))(param_8,&local_34,4);
    local_40 = param_8;
    (**(code **)(*param_8 + 0x20))(param_8,&local_38,4);
    iVar3 = FUN_00404088(param_6,param_5,s_VitalDamageZone_0050ba42,&local_44);
    if (iVar3 == 0) {
      local_48 = param_5;
      uVar10 = FUN_004dbd4c(&DAT_00524e20,param_6);
      local_4c = (int *)uVar10;
      FUN_004dbb24(local_4c,&DAT_0050ba52,(char *)0x0);
      FUN_004dbb24(local_4c,local_48,(char *)0x0);
      FUN_004dbb24(local_4c,s_missing_VitalDamageZone__0050ba56,(char *)0x0);
      FUN_004d9c38(local_4c);
      uVar4 = 0;
    }
    else {
      local_50 = 0;
      pcVar8 = &DAT_0050ba70;
      pcVar5 = local_44;
      do {
        if (*pcVar5 != *pcVar8) goto LAB_0049d594;
        bVar9 = true;
        if (*pcVar5 == '\0') break;
        pcVar1 = pcVar5 + 1;
        if (*pcVar1 != pcVar8[1]) goto LAB_0049d594;
        pcVar5 = pcVar5 + 2;
        pcVar8 = pcVar8 + 2;
        bVar9 = *pcVar1 == '\0';
      } while (!bVar9);
      if (bVar9) {
        local_50 = 1;
      }
      else {
LAB_0049d594:
        pcVar5 = s_False_0050ba75;
        do {
          if (*local_44 != *pcVar5) goto LAB_0049d5c1;
          bVar9 = true;
          if (*local_44 == '\0') break;
          pcVar8 = local_44 + 1;
          if (*pcVar8 != pcVar5[1]) goto LAB_0049d5c1;
          local_44 = local_44 + 2;
          pcVar5 = pcVar5 + 2;
          bVar9 = *pcVar8 == '\0';
        } while (!bVar9);
        if (!bVar9) {
LAB_0049d5c1:
          local_54 = param_5;
          local_58 = param_3;
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_0050ba7b,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_54,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_Improper_format_for_LegDamageZon_0050ba7d,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
          return 0;
        }
        local_50 = 0;
      }
      local_5c = param_8;
      (**(code **)(*param_8 + 0x20))(param_8,&local_50,4);
      local_60 = FUN_00404720(param_6,param_5,s_CriticalSubsystem_0050ba9f);
      local_64 = (undefined4 *)local_60[1];
      local_68 = FUN_00403b60((int)local_60);
      local_6c = param_8;
      (**(code **)(*param_8 + 0x20))(param_8,&local_68,4);
      for (; local_64 != (undefined4 *)0x0; local_64 = (undefined4 *)*local_64) {
        iVar3 = FUN_004d7f84(local_64[1],(byte *)s__s__f__f_0050bab1);
        if (iVar3 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_error_in_CriticalSubsystem_Forma_0050baba,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
LAB_0049d6e9:
          if (local_60 != (int *)0x0) {
            (**(code **)*local_60)(local_60,3);
          }
          return 0xffffffff;
        }
        (**(code **)(*param_8 + 0x20))(param_8,local_70,4);
        (**(code **)(*param_8 + 0x20))(param_8,local_74,4);
        pcVar5 = local_ec;
        pcVar8 = s_ControlsMapper_0050bade;
        do {
          if (*pcVar5 != *pcVar8) goto LAB_0049d75a;
          bVar9 = true;
          if (*pcVar5 == '\0') break;
          pcVar1 = pcVar5 + 1;
          if (*pcVar1 != pcVar8[1]) goto LAB_0049d75a;
          pcVar5 = pcVar5 + 2;
          pcVar8 = pcVar8 + 2;
          bVar9 = *pcVar1 == '\0';
        } while (!bVar9);
        if (bVar9) {
          local_78 = 0;
          iVar3 = local_78;
        }
        else {
LAB_0049d75a:
          pcVar5 = local_ec;
          pcVar8 = s_Power_0050baed;
          do {
            if (*pcVar5 != *pcVar8) goto LAB_0049d78f;
            bVar9 = true;
            if (*pcVar5 == '\0') break;
            pcVar1 = pcVar5 + 1;
            if (*pcVar1 != pcVar8[1]) goto LAB_0049d78f;
            pcVar5 = pcVar5 + 2;
            pcVar8 = pcVar8 + 2;
            bVar9 = *pcVar1 == '\0';
          } while (!bVar9);
          if (bVar9) {
            local_78 = 1;
            iVar3 = local_78;
          }
          else {
LAB_0049d78f:
            FUN_00404088(param_2,s_gamedata_0050baf3,s_Subsystems_0050bafc,&local_7c);
            local_80 = (int *)FUN_004064fc((char *)*param_7,local_7c);
            piVar6 = (int *)FUN_00402298(0x20);
            if (piVar6 == (int *)0x0) {
              local_84 = (int *)0x0;
            }
            else {
              local_84 = FUN_00403e84(piVar6,(char *)local_80,1);
            }
            local_88 = FUN_0040485c((int)local_84,(char *)0x0);
            iVar3 = 2;
            for (puVar13 = (undefined4 *)local_88[1]; puVar13 != (undefined4 *)0x0;
                puVar13 = (undefined4 *)*puVar13) {
              pcVar5 = (char *)(puVar13 + 2);
              pcVar8 = local_ec;
              do {
                if (*pcVar5 != *pcVar8) goto LAB_0049d82f;
                bVar9 = true;
                if (*pcVar5 == '\0') break;
                pcVar1 = pcVar5 + 1;
                if (*pcVar1 != pcVar8[1]) goto LAB_0049d82f;
                pcVar5 = pcVar5 + 2;
                pcVar8 = pcVar8 + 2;
                bVar9 = *pcVar1 == '\0';
              } while (!bVar9);
              if (bVar9) break;
LAB_0049d82f:
              iVar3 = iVar3 + 1;
            }
            FUN_00403ecc(local_84,3);
            FUN_004022d0(local_80);
            if (local_88 != (int *)0x0) {
              (**(code **)*local_88)(local_88,3);
            }
            if (puVar13 == (undefined4 *)0x0) {
              bVar12 = 0x3a;
              local_8c = param_3;
              FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
              piVar6 = FUN_004db92c(&DAT_00524e20,bVar12);
              FUN_004dbb24(piVar6,local_ec,(char *)0x0);
              FUN_004dbb24(piVar6,s_does_not_exist__0050bb07,(char *)0x0);
              goto LAB_0049d6e9;
            }
          }
        }
        local_78 = iVar3;
        (**(code **)(*param_8 + 0x20))(param_8,&local_78,4);
      }
      if (local_60 != (int *)0x0) {
        (**(code **)*local_60)(local_60,3);
      }
      local_90 = FUN_00404720(param_6,param_5,s_LODRedirect_0050bb19);
      puVar13 = (undefined4 *)local_90[1];
      local_94 = FUN_00403b60((int)local_90);
      local_98 = param_8;
      (**(code **)(*param_8 + 0x20))(param_8,&local_94,4);
      while (puVar13 != (undefined4 *)0x0) {
        puVar7 = (undefined4 *)FUN_00402298(0x10);
        if (puVar7 == (undefined4 *)0x0) {
          local_9c = (int *)0x0;
        }
        else {
          local_9c = (int *)FUN_004023f4(puVar7);
        }
        local_9c[3] = local_9c[3] + 1;
        FUN_00402a98((int *)&local_a0,(int *)&local_9c,(char *)puVar13[1]);
        piVar6 = local_a0 + 3;
        *piVar6 = *piVar6 + -1;
        if (*piVar6 == 0) {
          FUN_004024d8(local_a0,3);
        }
        if (local_9c[2] == 0) {
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_error_in_LODRedirect_Format__0050bb25,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
LAB_0049d9f3:
          if (local_90 != (int *)0x0) {
            (**(code **)*local_90)(local_90,3);
          }
          uVar4 = 0xffffffff;
          piVar6 = local_9c + 3;
          *piVar6 = *piVar6 + -1;
          if (*piVar6 != 0) {
            return 0xffffffff;
          }
          FUN_004024d8(local_9c,3);
          return uVar4;
        }
        local_9c[3] = local_9c[3] + 1;
        local_a4 = FUN_004274f8(local_9c,param_4);
        if (local_a4 == -1) {
          uVar10 = FUN_004dbd4c(&DAT_00524e20,param_2);
          piVar6 = (int *)uVar10;
          FUN_004dbb24(piVar6,&DAT_0050bb43,(char *)0x0);
          local_a8 = local_9c;
          local_ac = (char *)local_9c[2];
          FUN_004dbb24(piVar6,local_ac,(char *)0x0);
          FUN_004dbb24(piVar6,s_Not_Found__0050bb45,(char *)0x0);
          FUN_004d9c38(piVar6);
          goto LAB_0049d9f3;
        }
        (**(code **)(*param_8 + 0x20))(param_8,&local_a4,4);
        puVar13 = (undefined4 *)*puVar13;
        piVar6 = local_9c + 3;
        *piVar6 = *piVar6 + -1;
        if (*piVar6 == 0) {
          FUN_004024d8(local_9c,3);
        }
      }
      if (local_90 != (int *)0x0) {
        (**(code **)*local_90)(local_90,3);
      }
      uVar4 = 1;
    }
  }
  return uVar4;
}



/* @0049db20 file=? name=FUN_0049db20 */

int __cdecl FUN_0049db20(int *param_1,int param_2)

{
  int *piVar1;
  char cVar2;
  undefined4 *puVar3;
  char *pcVar4;
  char *pcVar5;
  uint *puVar6;
  int iVar7;
  uint uVar8;
  uint uVar9;
  char *pcVar10;
  char *pcVar11;
  bool bVar12;
  char local_98 [128];
  uint *local_18;
  int *local_14;
  undefined4 *local_10;
  int *local_c;
  int local_8;
  
  local_8 = -1;
  local_c = FUN_0040485c(param_2,(char *)0x0);
  local_10 = (undefined4 *)local_c[1];
joined_r0x0049db52:
  do {
    if (local_10 == (undefined4 *)0x0) {
      if (local_c != (int *)0x0) {
        (**(code **)*local_c)(local_c,3);
      }
      iVar7 = -1;
      piVar1 = param_1 + 3;
      *piVar1 = *piVar1 + -1;
      if (*piVar1 == 0) {
        FUN_004024d8(param_1,3);
      }
      return iVar7;
    }
    uVar8 = 0xffffffff;
    pcVar5 = (char *)(local_10 + 2);
    do {
      pcVar11 = pcVar5;
      if (uVar8 == 0) break;
      uVar8 = uVar8 - 1;
      pcVar11 = pcVar5 + 1;
      cVar2 = *pcVar5;
      pcVar5 = pcVar11;
    } while (cVar2 != '\0');
    uVar8 = ~uVar8;
    pcVar5 = pcVar11 + -uVar8;
    pcVar11 = local_98;
    for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
      *(undefined4 *)pcVar11 = *(undefined4 *)pcVar5;
      pcVar5 = pcVar5 + 4;
      pcVar11 = pcVar11 + 4;
    }
    pcVar4 = local_98;
    pcVar10 = s_LAB_ONLY_0050bb51;
    for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
      *pcVar11 = *pcVar5;
      pcVar5 = pcVar5 + 1;
      pcVar11 = pcVar11 + 1;
    }
    do {
      bVar12 = *pcVar4 == *pcVar10;
      if (!bVar12) break;
      if (*pcVar4 == '\0') goto LAB_0049dbd5;
      pcVar5 = pcVar4 + 1;
      bVar12 = *pcVar5 == pcVar10[1];
      if (!bVar12) break;
      pcVar4 = pcVar4 + 2;
      pcVar10 = pcVar10 + 2;
      bVar12 = *pcVar5 == '\0';
    } while (!bVar12);
    if (bVar12) {
LAB_0049dbd5:
      local_10 = (undefined4 *)*local_10;
      goto joined_r0x0049db52;
    }
    pcVar5 = local_98;
    pcVar11 = s_DamageZones_0050bb5a;
    do {
      if (*pcVar5 != *pcVar11) goto LAB_0049dbe2;
      bVar12 = true;
      if (*pcVar5 == '\0') break;
      pcVar4 = pcVar5 + 1;
      if (*pcVar4 != pcVar11[1]) goto LAB_0049dbe2;
      pcVar5 = pcVar5 + 2;
      pcVar11 = pcVar11 + 2;
      bVar12 = *pcVar4 == '\0';
    } while (!bVar12);
    if (bVar12) goto LAB_0049dbd5;
LAB_0049dbe2:
    local_8 = local_8 + 1;
    local_14 = FUN_00404720(param_2,local_98,s_dzone_0050bb66);
    puVar3 = (undefined4 *)local_14[1];
    while (puVar3 != (undefined4 *)0x0) {
      pcVar5 = (char *)puVar3[1];
      puVar6 = (uint *)FUN_00402298(0x10);
      if (puVar6 == (uint *)0x0) {
        local_18 = (uint *)0x0;
      }
      else {
        local_18 = FUN_00402460(puVar6,pcVar5);
      }
      local_18[3] = local_18[3] + 1;
      iVar7 = FUN_004027d8((int)local_18,(int)param_1);
      if (iVar7 == 0) {
        if (local_14 != (int *)0x0) {
          (**(code **)*local_14)(local_14,3);
        }
        if (local_c != (int *)0x0) {
          (**(code **)*local_c)(local_c,3);
        }
        puVar6 = local_18 + 3;
        *puVar6 = *puVar6 - 1;
        iVar7 = local_8;
        if (*puVar6 == 0) {
          FUN_004024d8((int *)local_18,3);
        }
        piVar1 = param_1 + 3;
        *piVar1 = *piVar1 + -1;
        if (*piVar1 != 0) {
          return iVar7;
        }
        FUN_004024d8(param_1,3);
        return iVar7;
      }
      puVar3 = (undefined4 *)*puVar3;
      puVar6 = local_18 + 3;
      *puVar6 = *puVar6 - 1;
      if (*puVar6 == 0) {
        FUN_004024d8((int *)local_18,3);
      }
    }
    if (local_14 != (int *)0x0) {
      (**(code **)*local_14)(local_14,3);
    }
    local_10 = (undefined4 *)*local_10;
  } while( true );
}



/* @0049dd18 file=? name=FUN_0049dd18 */

undefined4 * __cdecl FUN_0049dd18(undefined4 *param_1,undefined4 param_2)

{
  *param_1 = &PTR_FUN_0050bb8c;
  FUN_0049dd7e(param_1 + 1,param_2);
  param_1[6] = 0;
  param_1[5] = 0;
  return param_1;
}



/* @0049dd44 file=? name=FUN_0049dd44 */

void __cdecl FUN_0049dd44(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bb8c;
    FUN_0049dd9d(param_1 + 1,2);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049dd74 file=? name=FUN_0049dd74 */

undefined4 FUN_0049dd74(void)

{
  return 1;
}



/* @0049dd7e file=? name=FUN_0049dd7e */

undefined4 * __cdecl FUN_0049dd7e(undefined4 *param_1,undefined4 param_2)

{
  FUN_004179d4(param_1,param_2);
  *param_1 = &PTR_FUN_0050bb84;
  return param_1;
}



/* @0049dd9d file=? name=FUN_0049dd9d */

void __cdecl FUN_0049dd9d(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bb84;
    FUN_004179f8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049ddc9 file=? name=FUN_0049ddc9 */

undefined4 * __cdecl FUN_0049ddc9(undefined4 *param_1,undefined4 param_2)

{
  FUN_004179d4(param_1,param_2);
  *param_1 = &PTR_FUN_0050bb7c;
  return param_1;
}



/* @0049dde8 file=? name=FUN_0049dde8 */

void __cdecl FUN_0049dde8(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bb7c;
    FUN_004179f8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049de14 file=? name=FUN_0049de14 */

int __cdecl FUN_0049de14(int param_1)

{
  int iVar1;
  int iVar2;
  float10 fVar3;
  int local_28 [4];
  int local_18;
  int local_10;
  float local_c;
  float local_8;
  
  iVar2 = -1;
  FUN_0040139b(local_28,param_1 + 0x14);
  fVar3 = FUN_00408050();
  local_8 = (float)fVar3;
  (**(code **)(local_28[0] + 4))(local_28);
  iVar1 = (**(code **)(local_28[0] + 0x30))(local_28);
  while ((iVar1 != 0 && (iVar2 == -1))) {
    local_c = *(float *)(*(int *)(local_18 + local_10 * 4) + 0x14);
    if (local_8 < local_c) {
      iVar2 = *(int *)(iVar1 + 0xc);
    }
    (**(code **)(local_28[0] + 0xc))(local_28);
    iVar1 = (**(code **)(local_28[0] + 0x30))(local_28);
  }
  FUN_004013ba(local_28,2);
  return iVar2;
}



/* @0049deb0 file=? name=FUN_0049deb0 */

undefined4 * __cdecl FUN_0049deb0(undefined4 *param_1,undefined4 param_2,int *param_3)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  int *local_14 [2];
  undefined4 *local_c;
  int *local_8;
  
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_FUN_0050bd9c;
  param_1[3] = param_2;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(puVar2);
  }
  param_1[4] = iVar3;
  piVar1 = (int *)(param_1[4] + 0xc);
  *piVar1 = *piVar1 + 1;
  FUN_0049f204(param_1 + 5,0,0);
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    local_14[0] = (int *)0x0;
  }
  else {
    local_14[0] = (int *)FUN_004023f4(puVar2);
  }
  local_14[0][3] = local_14[0][3] + 1;
  local_c = param_1 + 5;
  FUN_0049e5e4(param_3,(int *)local_14);
  FUN_00402a4c((int *)&local_8,param_1 + 4,(int *)local_14);
  piVar1 = local_8 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_8,3);
  }
  piVar1 = local_14[0] + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_14[0],3);
  }
  return param_1;
}



/* @0049df80 file=? name=FUN_0049df80 */

void __cdecl FUN_0049df80(int *param_1,byte param_2)

{
  int *piVar1;
  int *piVar2;
  void *this;
  int local_20 [7];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bd9c;
    FUN_0040139b(local_20,(int)(param_1 + 5));
    FUN_00417858(this,local_20,1);
    FUN_004013ba(local_20,2);
    FUN_0049f227(param_1 + 5,2);
    piVar2 = (int *)param_1[4];
    piVar1 = piVar2 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar2,3);
    }
    FUN_0041790c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049e000 file=? name=FUN_0049e000 */

undefined4 FUN_0049e000(void)

{
  return 1;
}



/* @0049e00c file=? name=FUN_0049e00c */

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

undefined4 __cdecl
FUN_0049e00c(int param_1,char *param_2,char *param_3,undefined4 *param_4,int param_5,int *param_6)

{
  char *pcVar1;
  int iVar2;
  undefined4 uVar3;
  undefined4 *puVar4;
  int *piVar5;
  uint *puVar6;
  undefined4 *puVar7;
  int local_b0 [7];
  char local_94 [64];
  int local_54 [6];
  int *local_3c;
  int local_38;
  int *local_34;
  char *local_30;
  char *local_2c;
  int local_28;
  uint *local_24;
  int *local_20;
  char *local_1c;
  float local_18;
  float local_14;
  int *local_10;
  int *local_c;
  char *local_8;
  
  iVar2 = FUN_00403f84((int)param_4,param_3);
  if (iVar2 == 0) {
    pcVar1 = (char *)*param_4;
    local_8 = param_3;
    FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
    FUN_004dbb24((int *)&DAT_00524e68,s_does_not_exist_in_0050bbed,(char *)0x0);
    FUN_004dbb24((int *)&DAT_00524e68,pcVar1,(char *)0x0);
    FUN_004d9c38((int *)&DAT_00524e68);
    uVar3 = 0;
  }
  else {
    puVar4 = (undefined4 *)FUN_00402298(0x10);
    if (puVar4 == (undefined4 *)0x0) {
      local_3c = (int *)0x0;
    }
    else {
      local_3c = (int *)FUN_004023f4(puVar4);
    }
    local_3c[3] = local_3c[3] + 1;
    FUN_0049f204(local_54,0,0);
    local_34 = local_54;
    FUN_00402a98((int *)&local_c,(int *)&local_3c,param_3);
    piVar5 = local_c + 3;
    *piVar5 = *piVar5 + -1;
    if (*piVar5 == 0) {
      FUN_004024d8(local_c,3);
    }
    local_10 = FUN_00404720((int)param_4,param_3,s_DamageZone_0050bc00);
    puVar4 = (undefined4 *)local_10[1];
    local_38 = FUN_00403b60((int)local_10);
    local_18 = 0.0;
    FUN_00404088(param_1,s_video_0050bc0b,s_skeleton_0050bc11,&local_1c);
    local_20 = (int *)FUN_004064fc(*(char **)(param_5 + 0x10),local_1c);
    piVar5 = (int *)FUN_00402298(0x20);
    if (piVar5 == (int *)0x0) {
      piVar5 = (int *)0x0;
    }
    else {
      piVar5 = FUN_00403e84(piVar5,(char *)local_20,1);
    }
    if ((*(byte *)(piVar5 + 7) & 2) == 0) {
      iVar2 = piVar5[3];
    }
    else {
      iVar2 = piVar5[4];
    }
    if (iVar2 == 0) {
      FUN_004dbb24(&DAT_00524e20,(char *)local_20,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_is_empty_or_missing__0050bc1a,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
    }
    else {
      while (puVar4 != (undefined4 *)0x0) {
        iVar2 = FUN_004d7f84(puVar4[1],(byte *)s__s__f_0050bc30);
        if (iVar2 == 0) {
          pcVar1 = (char *)*param_4;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_0050bc36,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_0050bc38,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_error_in_DamageZone_Table_Format_0050bc3b,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
          goto LAB_0049e1a9;
        }
        puVar6 = (uint *)FUN_00402298(0x10);
        if (puVar6 == (uint *)0x0) {
          local_24 = (uint *)0x0;
        }
        else {
          local_24 = FUN_00402460(puVar6,local_94);
        }
        local_24[3] = local_24[3] + 1;
        local_24[3] = local_24[3] + 1;
        local_28 = FUN_004274f8((int *)local_24,(int)piVar5);
        if (local_28 == -1) {
          FUN_004dbb24(&DAT_00524e20,(char *)*param_4,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_0050bc5e,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,&DAT_0050bc61,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_94,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_Not_Found__0050bc63,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
          puVar6 = local_24 + 3;
          *puVar6 = *puVar6 - 1;
          if (*puVar6 == 0) {
            FUN_004024d8((int *)local_24,3);
          }
          goto LAB_0049e1a9;
        }
        puVar7 = (undefined4 *)FUN_00402298(0x10);
        if (puVar7 == (undefined4 *)0x0) {
          puVar7 = (undefined4 *)0x0;
        }
        else {
          puVar7 = FUN_00424716(puVar7,&local_28);
        }
        local_18 = local_14 + local_18;
        (**(code **)(*local_34 + 8))(local_34,puVar7,&local_18);
        puVar4 = (undefined4 *)*puVar4;
        puVar6 = local_24 + 3;
        *puVar6 = *puVar6 - 1;
        if (*puVar6 == 0) {
          FUN_004024d8((int *)local_24,3);
        }
      }
      if (_DAT_0049e520 == local_18) {
        FUN_0049e524(param_6,(int *)&local_3c);
        if (local_10 != (int *)0x0) {
          (**(code **)*local_10)(local_10,3);
        }
        FUN_004022d0(local_20);
        FUN_00403ecc(piVar5,3);
        FUN_0040137c(local_b0,(int)local_34);
        FUN_00417858(local_b0,local_b0,1);
        uVar3 = 1;
        FUN_004013ba(local_b0,2);
        FUN_0049f227(local_54,2);
        piVar5 = local_3c + 3;
        *piVar5 = *piVar5 + -1;
        if (*piVar5 != 0) {
          return uVar3;
        }
        FUN_004024d8(local_3c,3);
        return uVar3;
      }
      local_2c = param_3;
      local_30 = (char *)*param_4;
      FUN_004dbb24(&DAT_00524e20,local_30,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,&DAT_0050bc6f,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_2c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___percentages_do_not_sum_to_100__0050bc72,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
    }
LAB_0049e1a9:
    if (local_10 != (int *)0x0) {
      (**(code **)*local_10)(local_10,3);
    }
    FUN_004022d0(local_20);
    FUN_00403ecc(piVar5,3);
    if (local_34 != (int *)0x0) {
      (**(code **)*local_34)(local_34,3);
    }
    uVar3 = 0;
    FUN_0049f227(local_54,2);
    piVar5 = local_3c + 3;
    *piVar5 = *piVar5 + -1;
    if (*piVar5 == 0) {
      FUN_004024d8(local_3c,3);
    }
  }
  return uVar3;
}



/* @0049e524 file=? name=FUN_0049e524 */

int * __cdecl FUN_0049e524(int *param_1,int *param_2)

{
  int *piVar1;
  int iVar2;
  int local_28 [4];
  int local_18;
  int local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  piVar1 = (int *)FUN_004029b0(param_1,*param_2);
  (**(code **)(*piVar1 + 0x20))(piVar1,param_2 + 1,4);
  FUN_0040137c(local_28,param_2[2]);
  (**(code **)(local_28[0] + 4))(local_28);
  iVar2 = (**(code **)(local_28[0] + 0x30))(local_28);
  while (iVar2 != 0) {
    local_8 = *(undefined4 *)(*(int *)(local_18 + local_10 * 4) + 0x14);
    local_c = *(undefined4 *)(iVar2 + 0xc);
    piVar1 = (int *)(**(code **)(*param_1 + 0x20))(param_1,&local_8,4);
    (**(code **)(*piVar1 + 0x20))(piVar1,&local_c,4);
    (**(code **)(local_28[0] + 0xc))(local_28);
    iVar2 = (**(code **)(local_28[0] + 0x30))(local_28);
  }
  FUN_004013ba(local_28,2);
  return param_1;
}



/* @0049e5e4 file=? name=FUN_0049e5e4 */

int * __cdecl FUN_0049e5e4(int *param_1,int *param_2)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 local_c;
  undefined1 local_8 [4];
  
  piVar1 = (int *)FUN_00402aec(param_1,param_2);
  (**(code **)(*piVar1 + 0x1c))(piVar1,param_2 + 1,4);
  for (iVar3 = 0; iVar3 < param_2[1]; iVar3 = iVar3 + 1) {
    piVar1 = (int *)(**(code **)(*param_1 + 0x1c))(param_1,local_8,4);
    (**(code **)(*piVar1 + 0x1c))(piVar1,&local_c,4);
    puVar2 = (undefined4 *)FUN_00402298(0x10);
    if (puVar2 == (undefined4 *)0x0) {
      puVar2 = (undefined4 *)0x0;
    }
    else {
      puVar2 = FUN_00424716(puVar2,&local_c);
    }
    (**(code **)(*(int *)param_2[2] + 8))((int *)param_2[2],puVar2,local_8);
  }
  return param_1;
}



/* @0049e678 file=? name=FUN_0049e678 */

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

void __cdecl FUN_0049e678(int param_1,float param_2)

{
  int iVar1;
  float local_10;
  float local_c;
  float local_8;
  
  if (*(int *)(param_1 + 0xc) != 0) {
    local_8 = *(float *)(*(int *)(param_1 + 0x10) + 0x1d8);
    param_2 = local_8 + param_2;
    if (_DAT_0049e72c <= param_2) {
      param_2 = param_2 - _DAT_0049e72c;
    }
    if (param_2 < _DAT_0049e730) {
      param_2 = _DAT_0049e72c + param_2;
      local_c = param_2;
    }
  }
  FUN_004dcd10((double)((float10)*(int *)(param_1 + 0x2c) * _DAT_0049e734 * (float10)param_2));
  iVar1 = FUN_004dcd94();
  local_10 = ((float)(iVar1 + 1) * _DAT_0049e72c) / (float)*(int *)(param_1 + 0x2c);
  (**(code **)(*(int *)(param_1 + 0x14) + 0xc))(param_1 + 0x14,&local_10);
  return;
}



/* @0049e740 file=? name=FUN_0049e740 */

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

undefined4 * __cdecl FUN_0049e740(undefined4 *param_1,int param_2,int *param_3)

{
  undefined4 *puVar1;
  int iVar2;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_LAB_0050bd90;
  FUN_0049f2b2(param_1 + 5,0,1);
  (**(code **)(*param_3 + 0x1c))(param_3,param_1 + 3,4);
  (**(code **)(*param_3 + 0x1c))(param_3,param_1 + 0xb,4);
  local_c = _DAT_0049e810 / (float)(int)param_1[0xb];
  local_8 = local_c;
  for (iVar2 = 1; iVar2 <= (int)param_1[0xb]; iVar2 = iVar2 + 1) {
    puVar1 = (undefined4 *)FUN_00402298(0x2c);
    if (puVar1 == (undefined4 *)0x0) {
      puVar1 = (undefined4 *)0x0;
    }
    else {
      puVar1 = FUN_0049deb0(puVar1,param_2,param_3);
    }
    local_14 = (float)iVar2 * local_8;
    local_10 = local_14;
    (**(code **)(param_1[5] + 8))(param_1 + 5,puVar1,&local_14);
  }
  param_1[4] = *(undefined4 *)(param_2 + 0x438);
  return param_1;
}



/* @0049e880 file=? name=FUN_0049e880 */

undefined4 FUN_0049e880(void)

{
  return 1;
}



/* @0049e88c file=? name=FUN_0049e88c */

undefined4 __cdecl
FUN_0049e88c(int param_1,char *param_2,char *param_3,undefined4 *param_4,int param_5,int *param_6)

{
  uint *puVar1;
  undefined4 *puVar2;
  char *pcVar3;
  int iVar4;
  undefined4 uVar5;
  uint *puVar6;
  int local_10;
  int *local_c;
  undefined4 local_8;
  
  iVar4 = FUN_00404190((int)param_4,param_3,s_RotateWithTorso_0050bc9f,&local_8);
  if (iVar4 == 0) {
    FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
    FUN_004dbb24((int *)&DAT_00524e68,s_missing_RotateWithTorso__0050bcaf,(char *)0x0);
    FUN_004d9c38((int *)&DAT_00524e68);
    uVar5 = 0;
  }
  else {
    (**(code **)(*param_6 + 0x20))(param_6,&local_8,4);
    local_c = FUN_00404720((int)param_4,param_3,s_PieSlice_0050bcca);
    puVar2 = (undefined4 *)local_c[1];
    local_10 = FUN_00403b60((int)local_c);
    (**(code **)(*param_6 + 0x20))(param_6,&local_10,4);
    while (puVar2 != (undefined4 *)0x0) {
      pcVar3 = (char *)puVar2[1];
      puVar6 = (uint *)FUN_00402298(0x10);
      if (puVar6 == (uint *)0x0) {
        puVar6 = (uint *)0x0;
      }
      else {
        puVar6 = FUN_00402460(puVar6,pcVar3);
      }
      puVar6[3] = puVar6[3] + 1;
      if (puVar6[2] == 0) {
        FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_error_in_damage_table_format_0050bcd3,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
        if (local_c != (int *)0x0) {
          (**(code **)*local_c)(local_c,3);
        }
        uVar5 = 0xffffffff;
        puVar1 = puVar6 + 3;
        *puVar1 = *puVar1 - 1;
        if (*puVar1 != 0) {
          return 0xffffffff;
        }
        FUN_004024d8((int *)puVar6,3);
        return uVar5;
      }
      FUN_0049e00c(param_1,param_2,(char *)puVar6[2],param_4,param_5,param_6);
      puVar2 = (undefined4 *)*puVar2;
      puVar1 = puVar6 + 3;
      *puVar1 = *puVar1 - 1;
      if (*puVar1 == 0) {
        FUN_004024d8((int *)puVar6,3);
      }
    }
    if (local_c != (int *)0x0) {
      (**(code **)*local_c)(local_c,3);
    }
    uVar5 = 1;
  }
  return uVar5;
}



/* @0049ea48 file=? name=FUN_0049ea48 */

undefined4 * __cdecl FUN_0049ea48(undefined4 *param_1,int param_2,int *param_3)

{
  undefined4 *puVar1;
  int local_8;
  
  FUN_004178cc(param_1,2);
  *param_1 = &PTR_FUN_0050bd84;
  param_1[3] = param_2;
  FUN_0049f3d5(param_1 + 4,0,1);
  (**(code **)(*param_3 + 0x1c))(param_3,param_1 + 10,4);
  for (local_8 = 0; local_8 < (int)param_1[10]; local_8 = local_8 + 1) {
    puVar1 = (undefined4 *)FUN_00402298(0x30);
    if (puVar1 == (undefined4 *)0x0) {
      puVar1 = (undefined4 *)0x0;
    }
    else {
      puVar1 = FUN_0049e740(puVar1,param_2,param_3);
    }
    (**(code **)(param_1[4] + 8))(param_1 + 4,puVar1,&local_8);
  }
  return param_1;
}



/* @0049eadc file=? name=FUN_0049eadc */

void __cdecl FUN_0049eadc(int *param_1,byte param_2)

{
  void *this;
  int local_20 [7];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bd84;
    FUN_0040146f(local_20,(int)(param_1 + 4));
    FUN_00417858(this,local_20,1);
    FUN_0040148e(local_20,2);
    FUN_0049f3f8(param_1 + 4,2);
    FUN_0041790c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049eb48 file=? name=FUN_0049eb48 */

undefined4 FUN_0049eb48(void)

{
  return 1;
}



/* @0049eb54 file=? name=FUN_0049eb54 */

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

void __cdecl FUN_0049eb54(int param_1,float *param_2)

{
  float fVar1;
  float *pfVar2;
  int iVar3;
  float10 fVar4;
  float local_30;
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  int local_c;
  float local_8;
  
  local_30 = DAT_004e0f80;
  local_2c = DAT_004e0f84;
  local_28 = DAT_004e0f88;
  pfVar2 = FUN_00408bf8(&local_30,param_2,(float *)(*(int *)(param_1 + 0xc) + 0xd0));
  FUN_00408440(&local_30,pfVar2);
  local_8 = *(float *)(*(int *)(*(int *)(param_1 + 0xc) + 0x2ec) + 0xc);
  fVar1 = _DAT_0049ed00;
  if ((_DAT_0049ed00 <= local_2c) && (fVar1 = local_2c, local_8 < local_2c)) {
    fVar1 = local_8;
  }
  local_2c = fVar1;
  FUN_004dcd10((double)((float)*(int *)(param_1 + 0x28) * (local_2c / local_8)));
  local_c = FUN_004dcd94();
  if (local_c < 0) {
    local_c = 0;
  }
  if (*(int *)(param_1 + 0x28) + -1 < local_c) {
    local_c = *(int *)(param_1 + 0x28) + -1;
  }
  iVar3 = (**(code **)(*(int *)(param_1 + 0x10) + 0xc))(param_1 + 0x10,&local_c);
  local_14 = local_28;
  fVar4 = FUN_004dcd00((double)local_28);
  if ((float10)_DAT_0049ed04 < fVar4) {
    local_18 = local_30;
    fVar4 = FUN_004dcd00((double)local_30);
    if ((float10)_DAT_0049ed04 < fVar4) {
      fVar4 = FUN_004dc8ec((double)local_28,SUB84((double)local_30,0),
                           (uint)((ulonglong)(double)local_30 >> 0x20));
      local_20 = (float)fVar4;
      local_10 = local_20;
      if (local_20 < _DAT_0049ed00) {
        local_24 = _DAT_0049ed08 + local_20;
        local_10 = local_24;
      }
      goto LAB_0049ece8;
    }
  }
  fVar4 = FUN_00408050();
  local_1c = (float)(fVar4 * (float10)_DAT_0049ed08);
  local_10 = local_1c;
LAB_0049ece8:
  FUN_0049e678(iVar3,local_10);
  return;
}



/* @0049ed28 file=? name=FUN_0049ed28 */

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

{
  int *piVar1;
  uint *puVar2;
  int iVar3;
  uint uVar4;
  undefined4 uVar5;
  uint local_dc [2];
  char *local_d4;
  uint local_cc [2];
  char *local_c4;
  uint local_bc [2];
  char *local_b4;
  uint local_ac [2];
  char *local_a4;
  char local_9c [20];
  uint *local_88;
  uint *local_84;
  uint *local_80;
  char *local_7c;
  uint *local_78;
  char *local_74;
  int *local_70;
  uint *local_6c;
  uint *local_68;
  int *local_64;
  uint *local_60;
  uint *local_5c;
  char *local_58;
  uint *local_54;
  uint *local_50;
  char *local_4c;
  int *local_48;
  uint local_44;
  int *local_40;
  int local_3c;
  char *local_38;
  uint *local_34;
  uint *local_30;
  char *local_2c;
  uint *local_28;
  char *local_24;
  int *local_20;
  uint *local_1c;
  char *local_18;
  uint *local_14;
  char *local_10;
  uint *local_c;
  uint *local_8;
  
  puVar2 = (uint *)FUN_00402298(0x10);
  if (puVar2 == (uint *)0x0) {
    local_8 = (uint *)0x0;
  }
  else {
    local_8 = FUN_00402460(puVar2,s_Layer_0050bcf2);
  }
  uVar4 = 1;
  local_8[3] = local_8[3] + 1;
  local_10 = (char *)FUN_004dd3ec(1,local_9c,10);
  puVar2 = (uint *)FUN_00402298(0x10);
  if (puVar2 == (uint *)0x0) {
    local_14 = (uint *)0x0;
  }
  else {
    local_14 = FUN_00402460(puVar2,local_10);
  }
  local_14[3] = local_14[3] + 1;
  FUN_00402624(local_ac,(int)local_8,(int)local_14);
  local_18 = local_a4;
  puVar2 = (uint *)FUN_00402298(0x10);
  if (puVar2 == (uint *)0x0) {
    local_c = (uint *)0x0;
  }
  else {
    local_c = FUN_00402460(puVar2,local_18);
  }
  local_c[3] = local_c[3] + 1;
  FUN_004024d8((int *)local_ac,2);
  local_1c = local_14;
  puVar2 = local_14 + 3;
  *puVar2 = *puVar2 - 1;
  if (*puVar2 == 0) {
    FUN_004024d8((int *)local_14,3);
  }
  while( true ) {
    iVar3 = FUN_00403f84((int)param_3,(char *)local_c[2]);
    if (iVar3 == 0) break;
    uVar4 = uVar4 + 1;
    local_24 = (char *)FUN_004dd3ec(uVar4,local_9c,10);
    puVar2 = (uint *)FUN_00402298(0x10);
    if (puVar2 == (uint *)0x0) {
      local_28 = (uint *)0x0;
    }
    else {
      local_28 = FUN_00402460(puVar2,local_24);
    }
    local_28[3] = local_28[3] + 1;
    FUN_00402624(local_bc,(int)local_8,(int)local_28);
    local_2c = local_b4;
    local_34 = (uint *)FUN_00402298(0x10);
    if (local_34 == (uint *)0x0) {
      local_30 = (uint *)0x0;
    }
    else {
      local_30 = FUN_00402460(local_34,local_2c);
    }
    local_30[3] = local_30[3] + 1;
    FUN_004024d8((int *)local_bc,2);
    FUN_00402a4c((int *)&local_20,(int *)&local_c,(int *)&local_30);
    piVar1 = local_20 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(local_20,3);
    }
    puVar2 = local_30 + 3;
    *puVar2 = *puVar2 - 1;
    if (*puVar2 == 0) {
      FUN_004024d8((int *)local_30,3);
    }
    puVar2 = local_28 + 3;
    *puVar2 = *puVar2 - 1;
    if (*puVar2 == 0) {
      FUN_004024d8((int *)local_28,3);
    }
  }
  if (uVar4 == 1) {
    local_38 = (char *)*param_3;
    FUN_004dbb24(&DAT_00524e20,local_38,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_has_bad_format__0050bcf8,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  local_3c = uVar4 - 1;
  local_40 = param_5;
  (**(code **)(*param_5 + 0x20))(param_5,&local_3c,4);
  local_44 = 1;
  local_4c = (char *)FUN_004dd3ec(1,local_9c,10);
  local_54 = (uint *)FUN_00402298(0x10);
  if (local_54 == (uint *)0x0) {
    local_50 = (uint *)0x0;
  }
  else {
    local_50 = FUN_00402460(local_54,local_4c);
  }
  local_50[3] = local_50[3] + 1;
  FUN_00402624(local_cc,(int)local_8,(int)local_50);
  local_58 = local_c4;
  local_60 = (uint *)FUN_00402298(0x10);
  if (local_60 == (uint *)0x0) {
    local_5c = (uint *)0x0;
  }
  else {
    local_5c = FUN_00402460(local_60,local_58);
  }
  local_5c[3] = local_5c[3] + 1;
  FUN_004024d8((int *)local_cc,2);
  FUN_00402a4c((int *)&local_48,(int *)&local_c,(int *)&local_5c);
  local_64 = local_48;
  piVar1 = local_48 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_48,3);
  }
  local_68 = local_5c;
  puVar2 = local_5c + 3;
  *puVar2 = *puVar2 - 1;
  if (*puVar2 == 0) {
    FUN_004024d8((int *)local_5c,3);
  }
  local_6c = local_50;
  puVar2 = local_50 + 3;
  *puVar2 = *puVar2 - 1;
  if (*puVar2 == 0) {
    FUN_004024d8((int *)local_50,3);
  }
  while( true ) {
    iVar3 = FUN_00403f84((int)param_3,(char *)local_c[2]);
    if (iVar3 == 0) break;
    FUN_0049e88c(param_1,param_2,(char *)local_c[2],param_3,param_4,param_5);
    local_44 = local_44 + 1;
    local_74 = (char *)FUN_004dd3ec(local_44,local_9c,10);
    puVar2 = (uint *)FUN_00402298(0x10);
    if (puVar2 == (uint *)0x0) {
      local_78 = (uint *)0x0;
    }
    else {
      local_78 = FUN_00402460(puVar2,local_74);
    }
    local_78[3] = local_78[3] + 1;
    FUN_00402624(local_dc,(int)local_8,(int)local_78);
    local_7c = local_d4;
    puVar2 = (uint *)FUN_00402298(0x10);
    if (puVar2 == (uint *)0x0) {
      local_80 = (uint *)0x0;
    }
    else {
      local_80 = FUN_00402460(puVar2,local_7c);
    }
    local_80[3] = local_80[3] + 1;
    FUN_004024d8((int *)local_dc,2);
    FUN_00402a4c((int *)&local_70,(int *)&local_c,(int *)&local_80);
    piVar1 = local_70 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(local_70,3);
    }
    puVar2 = local_80 + 3;
    *puVar2 = *puVar2 - 1;
    if (*puVar2 == 0) {
      FUN_004024d8((int *)local_80,3);
    }
    puVar2 = local_78 + 3;
    *puVar2 = *puVar2 - 1;
    if (*puVar2 == 0) {
      FUN_004024d8((int *)local_78,3);
    }
  }
  uVar5 = 1;
  local_84 = local_c;
  puVar2 = local_c + 3;
  *puVar2 = *puVar2 - 1;
  if (*puVar2 == 0) {
    FUN_004024d8((int *)local_c,3);
  }
  local_88 = local_8;
  puVar2 = local_8 + 3;
  *puVar2 = *puVar2 - 1;
  if (*puVar2 == 0) {
    FUN_004024d8((int *)local_8,3);
  }
  return uVar5;
}



/* @0049f204 file=? name=FUN_0049f204 */

undefined4 * __cdecl FUN_0049f204(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  FUN_00419184(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050bd68;
  return param_1;
}



/* @0049f227 file=? name=FUN_0049f227 */

void __cdecl FUN_0049f227(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bd68;
    FUN_004191b4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049f253 file=? name=FUN_0049f253 */

undefined4 __cdecl FUN_0049f253(undefined4 param_1,int param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(float *)(param_2 + 0x14) == *(float *)(param_3 + 0x14)) {
    return 0;
  }
  if (*(float *)(param_2 + 0x14) <= *(float *)(param_3 + 0x14)) {
    uVar1 = 0xffffffff;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0049f284 file=? name=FUN_0049f284 */

undefined4 __cdecl FUN_0049f284(undefined4 param_1,float *param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*param_2 == *(float *)(param_3 + 0x14)) {
    return 0;
  }
  if (*param_2 <= *(float *)(param_3 + 0x14)) {
    uVar1 = 0xffffffff;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0049f2b2 file=? name=FUN_0049f2b2 */

undefined4 * __cdecl FUN_0049f2b2(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  FUN_00419184(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050bd4c;
  return param_1;
}



/* @0049f2d5 file=? name=FUN_0049f2d5 */

void __cdecl FUN_0049f2d5(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bd4c;
    FUN_004191b4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049f301 file=? name=FUN_0049f301 */

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

undefined4 __cdecl FUN_0049f301(undefined4 param_1,int param_2,int param_3)

{
  undefined4 uVar1;
  float10 fVar2;
  
  fVar2 = FUN_004dcd00((double)(*(float *)(param_2 + 0x14) - *(float *)(param_3 + 0x14)));
  if ((float10)_DAT_0049f369 < fVar2) {
    if (*(float *)(param_2 + 0x14) <= *(float *)(param_3 + 0x14)) {
      uVar1 = 0xffffffff;
    }
    else {
      uVar1 = 1;
    }
  }
  else {
    uVar1 = 0;
  }
  return uVar1;
}



/* @0049f3d5 file=? name=FUN_0049f3d5 */

undefined4 * __cdecl FUN_0049f3d5(undefined4 *param_1,undefined4 param_2,undefined4 param_3)

{
  FUN_00419184(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050bd30;
  return param_1;
}



/* @0049f3f8 file=? name=FUN_0049f3f8 */

void __cdecl FUN_0049f3f8(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bd30;
    FUN_004191b4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0049f424 file=? name=FUN_0049f424 */

undefined4 __cdecl FUN_0049f424(undefined4 param_1,int param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(int *)(param_3 + 0x14) == *(int *)(param_2 + 0x14)) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
    if (*(int *)(param_2 + 0x14) <= *(int *)(param_3 + 0x14)) {
      uVar1 = 0xffffffff;
    }
  }
  return uVar1;
}



/* @0049f453 file=? name=FUN_0049f453 */

undefined4 __cdecl FUN_0049f453(undefined4 param_1,int *param_2,int param_3)

{
  undefined4 uVar1;
  
  if (*(int *)(param_3 + 0x14) == *param_2) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
    if (*param_2 <= *(int *)(param_3 + 0x14)) {
      uVar1 = 0xffffffff;
    }
  }
  return uVar1;
}



/* @0049f47f file=? name=FUN_0049f47f */

undefined4 * __cdecl FUN_0049f47f(undefined4 param_1,int param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_0041d485();
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0041d42e(puVar1,param_1,param_2,param_3);
  }
  return puVar1;
}



/* @0049f4af file=? name=FUN_0049f4af */

undefined4 * __cdecl FUN_0049f4af(undefined4 param_1,int param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_0049f568();
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0049f50f(puVar1,param_1,param_2,param_3);
  }
  return puVar1;
}



/* @0049f4df file=? name=FUN_0049f4df */

undefined4 * __cdecl FUN_0049f4df(undefined4 param_1,int param_2,undefined4 *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00437fc5();
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00437f6e(puVar1,param_1,param_2,param_3);
  }
  return puVar1;
}



/* @0049f50f file=? name=FUN_0049f50f */

undefined4 * __cdecl
FUN_0049f50f(undefined4 *param_1,undefined4 param_2,int param_3,undefined4 *param_4)

{
  FUN_004190e8(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050bdb0;
  param_1[5] = *param_4;
  return param_1;
}



/* @0049f53c file=? name=FUN_0049f53c */

void __cdecl FUN_0049f53c(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050bdb0;
    FUN_0041910c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_0049f5b8(param_1);
    }
  }
  return;
}



/* @0049f568 file=? name=FUN_0049f568 */

void FUN_0049f568(void)

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = DAT_0050bdac;
  DAT_0050bdac = DAT_0050bdac + 1;
  puVar2 = DAT_0050bda8;
  if ((iVar1 == 0) && (puVar2 = (undefined4 *)FUN_00402298(0x28), puVar2 != (undefined4 *)0x0)) {
    FUN_00402b98(puVar2,0x18,100,100,s_TableEntryOf_0050bd23);
  }
  DAT_0050bda8 = puVar2;
  FUN_00402f74((int)DAT_0050bda8);
  return;
}



/* @0049f5b8 file=? name=FUN_0049f5b8 */

void __cdecl FUN_0049f5b8(undefined4 *param_1)

{
  FUN_00402f98((int)DAT_0050bda8,param_1);
  DAT_0050bdac = DAT_0050bdac + -1;
  if (DAT_0050bdac == 0) {
    if (DAT_0050bda8 != (int *)0x0) {
      FUN_00402c28(DAT_0050bda8,0);
      FUN_004022d0(DAT_0050bda8);
    }
    DAT_0050bda8 = (int *)0x0;
  }
  return;
}



/* @0049f624 file=? name=FUN_0049f624 */

void __cdecl FUN_0049f624(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0041fd18(param_1,param_2);
  iVar1 = *(int *)(param_1 + 400);
  *(int *)(iVar1 + 0x1fc) = param_1;
  *(uint *)(iVar1 + 0x28) = *(uint *)(iVar1 + 0x28) & 0xffffbfff;
  if ((*(uint *)(param_1 + 0x28) & 0xc) != 4) {
    *(undefined4 *)(*(int *)(param_1 + 0x7dc) + 0x1d4) =
         *(undefined4 *)(*(int *)(iVar1 + 0x1f8) + 0xf4);
  }
  return;
}



/* @0049f674 file=? name=FUN_0049f674 */

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

void __cdecl FUN_0049f674(int *param_1)

{
  int iVar1;
  int iVar2;
  
  iVar2 = *(int *)(DAT_004efc94 + 0x2c);
  iVar1 = FUN_0042904c(iVar2);
  param_1[0x41] = (int)((float)iVar1 * _DAT_0049f6f8);
  iVar2 = FUN_0042904c(iVar2);
  param_1[0x40] = (int)((float)iVar2 * _DAT_0049f6fc);
  FUN_0040ab44((float *)(param_1 + 0x34),param_1 + 0x40);
  (**(code **)(*param_1 + 0x34))(param_1);
  FUN_0041bbd8((int)(param_1 + 0xb),2);
  FUN_004a4c54((int)param_1,1);
  param_1[10] = param_1[10] & 0xfffffffd;
  return;
}



/* @0049f728 file=? name=FUN_0049f728 */

void __cdecl FUN_0049f728(int param_1,int param_2)

{
  int iVar1;
  int local_10 [3];
  
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004a4f15(local_10,param_1 + 0x7cc);
    while( true ) {
      iVar1 = (**(code **)(local_10[0] + 0x28))(local_10);
      if (iVar1 == 0) break;
      *(undefined4 *)(iVar1 + 0x1d0) = 1;
    }
    FUN_0049f788(param_1);
    FUN_004a4f72(local_10,2);
  }
  return;
}



/* @0049f788 file=? name=FUN_0049f788 */

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

void __cdecl FUN_0049f788(int param_1)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int local_14 [3];
  float local_8;
  
  FUN_004a4f15(local_14,param_1 + 0x7cc);
  iVar3 = 0;
  while (iVar1 = (**(code **)(local_14[0] + 0x28))(local_14), iVar1 != 0) {
    iVar3 = iVar3 + *(int *)(iVar1 + 0x1d0);
  }
  (**(code **)(local_14[0] + 4))(local_14);
  while (iVar1 = (**(code **)(local_14[0] + 0x28))(local_14), iVar1 != 0) {
    local_8 = _DAT_0049f850;
    if (0 < iVar3) {
      local_8 = (float)*(int *)(iVar1 + 0x1d0) / (float)iVar3;
    }
    if (local_8 <= *(float *)(iVar1 + 0x15c)) {
      iVar2 = 2;
    }
    else {
      iVar2 = 1;
    }
    FUN_0041bbd8(iVar1 + 0x1dc,iVar2);
    *(float *)(iVar1 + 0x15c) = local_8;
    FUN_0041bbd8(iVar1 + 0x1dc,0);
  }
  FUN_004a4f72(local_14,2);
  return;
}



/* @0049fa00 file=? name=FUN_0049fa00 */

void __cdecl FUN_0049fa00(int param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    *(undefined4 *)(param_1 + 0x398) = 1;
  }
  return;
}



/* @0049fa1c file=? name=FUN_0049fa1c */

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

void __cdecl FUN_0049fa1c(int param_1)

{
  int iVar1;
  bool bVar2;
  int iVar3;
  undefined4 uVar4;
  int iVar5;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  local_8 = 0;
  local_c = 0;
  local_10 = 0.0;
  for (iVar5 = 2; iVar5 < *(int *)(param_1 + 0x124); iVar5 = iVar5 + 1) {
    iVar1 = *(int *)(*(int *)(param_1 + 0x128) + iVar5 * 4);
    if (iVar1 != 0) {
      if (*(int *)(iVar1 + 4) == 0xbbe) {
        local_10 = *(float *)(iVar1 + 300) / *(float *)(iVar1 + 0x128);
      }
      else if (*(int *)(iVar1 + 4) == 0xbc1) {
        if ((*(int *)(iVar1 + 0x40) != 1) && (*(int *)(iVar1 + 0x210) != 4)) {
          local_c = local_c + 1;
        }
      }
      else {
        iVar3 = FUN_0041a1a4(**(int **)(iVar1 + 0xc),0x511830);
        if ((iVar3 != 0) && (*(int *)(iVar1 + 0x40) != 1)) {
          iVar3 = FUN_0041a1a4(**(int **)(iVar1 + 0xc),0x5121a8);
          if (iVar3 == 0) {
            local_8 = local_8 + 1;
          }
          else if (*(int *)(iVar1 + 0x364) != 7) {
            local_8 = local_8 + 1;
          }
        }
      }
    }
  }
  if ((*(int *)(param_1 + 0x40) == 3) || (*(int *)(param_1 + 0x40) == 4)) {
    bVar2 = true;
  }
  else {
    bVar2 = false;
  }
  if ((((local_8 < *(int *)(param_1 + 0x448)) || (local_c == 0)) || (local_10 < _DAT_0049fb50)) ||
     ((bVar2 && (*(int *)(*(int *)(param_1 + 400) + 0x25c) == 0)))) {
    uVar4 = 1;
  }
  else {
    uVar4 = 0;
  }
  *(undefined4 *)(param_1 + 0x414) = uVar4;
  return;
}



/* @0049fb54 file=? name=FUN_0049fb54 */

undefined4 __cdecl FUN_0049fb54(int param_1)

{
  undefined4 uVar1;
  
  if ((*(int *)(param_1 + 0x40) == 2) || (*(int *)(param_1 + 0x40) == 9)) {
    uVar1 = 1;
  }
  else {
    uVar1 = 0;
  }
  return uVar1;
}



/* @0049fb74 file=? name=FUN_0049fb74 */

void __cdecl FUN_0049fb74(int param_1,undefined4 *param_2,undefined4 param_3)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  
  FUN_0040a938((undefined4 *)(param_1 + 0x100),param_2);
  FUN_00408440((undefined4 *)(param_1 + 0x58c),param_2);
  FUN_0040a938((undefined4 *)(param_1 + 0x260),param_2);
  FUN_0040a938((undefined4 *)(param_1 + 300),param_2);
  FUN_0040a7f4((undefined4 *)(param_1 + 0x1c4),(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4((undefined4 *)(param_1 + 0x298),(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4((undefined4 *)(param_1 + 0x2c8),(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4((undefined4 *)(param_1 + 0x1dc),(undefined4 *)&DAT_004e0fd4);
  FUN_00408440((undefined4 *)(param_1 + 500),&DAT_004e0f74);
  FUN_00408440((undefined4 *)(param_1 + 0x200),&DAT_004e0f74);
  FUN_00408440((undefined4 *)(param_1 + 0x598),&DAT_004e0f74);
  *(undefined4 *)(param_1 + 0x5a4) = 0;
  FUN_0040ab44((float *)(param_1 + 0xd0),(undefined4 *)(param_1 + 0x100));
  *(undefined4 *)(param_1 + 0x77c) = 0;
  *(undefined4 *)(param_1 + 0x348) = 0;
  *(undefined4 *)(param_1 + 0x6b8) = 0;
  *(undefined4 *)(param_1 + 0x6b4) = 0;
  *(undefined4 *)(param_1 + 0x3f0) = 0;
  FUN_0041bbd8(param_1 + 0x2c,0);
  *(undefined4 *)(param_1 + 0x328) = 0;
  *(undefined4 *)(param_1 + 0x32c) = 0;
  *(undefined4 *)(param_1 + 0x330) = 0;
  *(undefined4 *)(param_1 + 0x334) = 0;
  *(undefined4 *)(param_1 + 0x338) = 0;
  *(undefined4 *)(param_1 + 0x33c) = 0;
  *(undefined4 *)(param_1 + 0x54c) = 0;
  *(undefined4 *)(param_1 + 0x550) = 0;
  *(undefined4 *)(param_1 + 0x554) = 0;
  *(undefined4 *)(param_1 + 0x558) = 0;
  *(undefined4 *)(param_1 + 0x55c) = 0;
  *(undefined4 *)(param_1 + 0x560) = 0;
  puVar2 = (undefined4 *)FUN_00414b60();
  *(undefined4 *)(param_1 + 0x778) = *puVar2;
  *(undefined4 *)(param_1 + 0x654) = 0;
  *(undefined4 *)(param_1 + 0x658) = 0;
  *(undefined4 *)(param_1 + 0x650) = 0;
  *(undefined4 *)(param_1 + 0x398) = 0;
  *(undefined4 *)(param_1 + 0x3f4) = 0;
  *(undefined4 *)(param_1 + 0x344) = *(undefined4 *)(param_1 + 0x5b8);
  *(undefined4 *)(param_1 + 0x5ac) = 0x3f800000;
  FUN_0041bbd8(param_1 + 0x39c,0);
  FUN_004283b8(param_1 + 0x65c,1);
  FUN_0041bbd8(param_1 + 0x714,0);
  *(undefined4 *)(param_1 + 0x3fc) = 0;
  *(undefined4 *)(param_1 + 0x400) = DAT_005209d0;
  for (iVar3 = 0; iVar3 < *(int *)(param_1 + 0x11c); iVar3 = iVar3 + 1) {
    FUN_0041dd68(*(int *)(*(int *)(param_1 + 0x120) + iVar3 * 4));
  }
  for (iVar3 = 2; iVar3 < *(int *)(param_1 + 0x124); iVar3 = iVar3 + 1) {
    piVar1 = *(int **)(*(int *)(param_1 + 0x128) + iVar3 * 4);
    if (piVar1 != (int *)0x0) {
      (**(code **)(*piVar1 + 0x28))(piVar1,param_3);
    }
  }
  FUN_0049f788(param_1);
  if ((*(uint *)(param_1 + 0x28) & 0xc) != 4) {
    FUN_004a4c54(param_1,0x1f);
  }
  return;
}



/* @0049fe0c file=? name=FUN_0049fe0c */

void __cdecl FUN_0049fe0c(int param_1,undefined4 param_2)

{
  int *piVar1;
  int iVar2;
  
  for (iVar2 = 0; iVar2 < *(int *)(param_1 + 0x124); iVar2 = iVar2 + 1) {
    piVar1 = *(int **)(*(int *)(param_1 + 0x128) + iVar2 * 4);
    (**(code **)(*piVar1 + 0x2c))(piVar1,param_2);
  }
  return;
}



/* @0049fe40 file=? name=FUN_0049fe40 */

void __cdecl FUN_0049fe40(int param_1,undefined4 param_2)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)**(int **)(param_1 + 0x128);
  if ((puVar1 != (undefined4 *)0x0) && (puVar1 != (undefined4 *)0x0)) {
    (**(code **)*puVar1)(puVar1,3);
  }
  **(undefined4 **)(param_1 + 0x128) = param_2;
  return;
}



/* @0049fe70 file=? name=FUN_0049fe70 */

undefined4 __cdecl FUN_0049fe70(int param_1)

{
  return *(undefined4 *)(param_1 + 0x5b4);
}



/* @0049fe80 file=? name=FUN_0049fe80 */

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

void __cdecl FUN_0049fe80(int param_1)

{
  int iVar1;
  float fVar2;
  int *piVar3;
  int iVar4;
  int iVar5;
  uint local_20;
  float local_1c;
  uint local_18;
  float local_14;
  uint local_c;
  float local_8;
  
  local_c = 0;
  local_8 = 0.0;
  piVar3 = *(int **)(param_1 + 0x120);
  for (iVar5 = 0; iVar5 < *(int *)(param_1 + 0x11c); iVar5 = iVar5 + 1) {
    iVar4 = *piVar3;
    local_c = local_c + 1;
    piVar3 = piVar3 + 1;
    local_8 = *(float *)(iVar4 + 0x158) + local_8;
  }
  fVar2 = _DAT_0049ffc8;
  if (local_c != 0) {
    fVar2 = local_8 / (float)local_c;
  }
  *(float *)(param_1 + 0x354) = fVar2;
  local_18 = 0;
  local_14 = 0.0;
  local_20 = 0;
  local_1c = 0.0;
  for (iVar5 = 0; iVar5 < *(int *)(param_1 + 0x124); iVar5 = iVar5 + 1) {
    iVar4 = *(int *)(*(int *)(param_1 + 0x128) + iVar5 * 4);
    iVar1 = *(int *)(iVar4 + 0xe0);
    if (iVar1 != 0) {
      local_18 = local_18 + 1;
      local_14 = *(float *)(iVar1 + 0x158) + local_14;
      iVar4 = FUN_0041a1a4(**(int **)(iVar4 + 0xc),0x51155c);
      if (iVar4 != 0) {
        local_20 = local_20 + 1;
        local_1c = *(float *)(*(int *)(*(int *)(*(int *)(param_1 + 0x128) + iVar5 * 4) + 0xe0) +
                             0x158) + local_1c;
      }
    }
  }
  fVar2 = _DAT_0049ffc8;
  if (local_18 != 0) {
    fVar2 = local_14 / (float)local_18;
  }
  *(float *)(param_1 + 0x358) = fVar2;
  fVar2 = _DAT_0049ffc8;
  if (local_20 != 0) {
    fVar2 = local_1c / (float)local_20;
  }
  *(float *)(param_1 + 0x35c) = fVar2;
  return;
}



/* @004a1232 file=? name=FUN_004a1232 */

/* WARNING (jumptable): Unable to track spacebase fully for stack */
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

void FUN_004a1232(void)

{
  undefined4 *puVar1;
  int *piVar2;
  int *piVar3;
  int unaff_EBP;
  
  puVar1 = *(undefined4 **)(unaff_EBP + 0xc);
  piVar2 = *(int **)(unaff_EBP + 8);
  switch(*(undefined2 *)((int)puVar1 + 6)) {
  case 0:
    FUN_00408f44((float *)(unaff_EBP + -0x10),(float *)(piVar2 + 0x4e));
    FUN_00408440((undefined4 *)(unaff_EBP + -0x1c),piVar2 + 0xb5);
    FUN_0042249c(piVar2,puVar1);
    FUN_00409a00((float *)(piVar2 + 0x4e),(float *)(unaff_EBP + -0x10));
    FUN_00408440(piVar2 + 0xb5,(undefined4 *)(unaff_EBP + -0x1c));
    piVar2[0x1df] = 1;
    if ((piVar2[0x1ca] == 2) || (piVar2[0x1ca] == 3)) {
      FUN_0040a7f4(piVar2 + 0xa6,(undefined4 *)&DAT_004e0fd4);
    }
    if ((piVar2[0x10] != piVar2[0xf]) && ((piVar2[0xf] == 2 || (piVar2[0x10] == 2)))) {
      FUN_0040a938(piVar2 + 0x40,piVar2 + 0x4b);
      FUN_0040a938(piVar2 + 0x98,piVar2 + 0x4b);
      FUN_0040a7f4(piVar2 + 0xa6,piVar2 + 0xb2);
      piVar2[0x1df] = 0;
      if ((*(byte *)((int)piVar2 + 0x29) & 0x40) == 0) {
        (**(code **)(*piVar2 + 0x34))(piVar2);
      }
    }
    piVar2[0x1ad] = puVar1[0x1d];
    break;
  default:
    FUN_0042249c(piVar2,puVar1);
    break;
  case 2:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    piVar2[0x1ad] = puVar1[4];
    break;
  case 3:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    piVar2[0x196] = puVar1[4];
    FUN_0041bbd8((int)(piVar2 + 0x131),puVar1[6]);
    if (puVar1[5] == 0) {
      FUN_004283b8((int)(piVar2 + 0x197),1);
      FUN_0041bbd8((int)(piVar2 + 0x1c5),puVar1[5]);
    }
    else if (puVar1[5] == 1) {
      FUN_0041bbd8((int)(piVar2 + 0x1c5),puVar1[5]);
    }
    else {
      FUN_004a800c((int)piVar2,puVar1[5]);
    }
    piVar2[0x1ad] = puVar1[7];
    break;
  case 4:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    piVar3 = (int *)FUN_00414b60();
    piVar2[0x1de] = *piVar3;
    FUN_00409a00((float *)(piVar2 + 0x4e),(float *)(puVar1 + 4));
    FUN_00408440(piVar2 + 0xb5,puVar1 + 7);
    piVar3 = (int *)FUN_00414b60();
    piVar2[0xb8] = *piVar3;
    *(int *)(unaff_EBP + -0x34) = piVar2[0xb8] - piVar2[5];
    *(float *)(unaff_EBP + -4) = (float)*(int *)(unaff_EBP + -0x34) / DAT_0052140c;
    if (*(float *)(unaff_EBP + -4) < _DAT_004a1670) {
      piVar2[0xb8] = piVar2[0xb8] + (piVar2[0xb8] - piVar2[5]);
    }
    piVar2[0x1ad] = puVar1[10];
    break;
  case 5:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    FUN_0041bbd8((int)(piVar2 + 0x114),puVar1[4]);
    piVar2[0x129] = puVar1[5];
    FUN_00408440(piVar2 + 0x12a,puVar1 + 6);
    piVar2[0x12d] = puVar1[9];
    FUN_004a800c((int)piVar2,0x20);
    FUN_0040a7f4(piVar2 + 0xa6,(undefined4 *)&DAT_004e0fd4);
    piVar2[0x1ad] = puVar1[10];
    break;
  case 6:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    FUN_0041bbd8((int)(piVar2 + 0x114),puVar1[4]);
    piVar2[0x129] = puVar1[5];
    FUN_00408440(piVar2 + 0x12a,puVar1 + 6);
    piVar2[0x12d] = puVar1[9];
    FUN_0041bbd8((int)(piVar2 + 0x1c5),0);
    piVar2[0x195] = 1;
    piVar2[0x196] = 1;
    FUN_0040a7f4(piVar2 + 0xa6,(undefined4 *)&DAT_004e0fd4);
    piVar2[0x1ad] = puVar1[10];
    break;
  case 7:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    FUN_0041bbd8((int)(piVar2 + 0x114),puVar1[4]);
    piVar2[0x129] = puVar1[5];
    FUN_00408440(piVar2 + 0x12a,puVar1 + 6);
    piVar2[0x12d] = puVar1[9];
    piVar2[0x1ad] = puVar1[10];
    break;
  case 8:
    FUN_0041bd34((int)piVar2,(int)puVar1);
    piVar2[0xfd] = puVar1[4];
    piVar2[0x1ad] = puVar1[5];
  }
  if ((piVar2[0xf] != piVar2[0x10]) && (piVar2[0xf] == 2)) {
    FUN_00436668((undefined4 *)(unaff_EBP + -0x30),(int)piVar2);
    FUN_004364e4(*(int *)(DAT_004efc94 + 0x38),piVar2,(uint *)(unaff_EBP + -0x30));
    FUN_0041bbd8((int)(piVar2 + 0xb),piVar2[0x10]);
  }
  return;
}



/* @004a1674 file=bt/mech.cpp name=FUN_004a1674 */

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

int * __cdecl FUN_004a1674(int *param_1,int param_2,undefined4 param_3)

{
  int *piVar1;
  char cVar2;
  int iVar3;
  undefined4 uVar4;
  int *piVar5;
  int iVar6;
  uint *puVar7;
  int iVar8;
  undefined4 *puVar9;
  uint uVar10;
  uint uVar11;
  char *pcVar12;
  char *pcVar13;
  int local_1f8 [6];
  int local_1e0 [6];
  int local_1c8 [6];
  char local_1b0 [32];
  int local_190 [3];
  int local_184 [7];
  undefined4 local_168 [2];
  int *local_160;
  int *local_158;
  int local_154;
  int *local_150;
  int *local_14c;
  int *local_148;
  int *local_144;
  int *local_140;
  int *local_13c;
  undefined4 *local_138;
  undefined4 *local_134;
  int local_130;
  uint *local_12c;
  int local_128;
  int local_124;
  undefined4 local_120;
  uint *local_11c;
  char *local_118;
  int local_114;
  undefined4 local_110;
  int local_10c;
  float *local_108;
  float local_104;
  float local_100;
  float *local_fc;
  float local_f8;
  float local_f4;
  float local_f0;
  float local_ec;
  float local_e8;
  float local_e4;
  float local_e0;
  float local_dc;
  float local_d8;
  float local_d4;
  float local_d0;
  float local_cc;
  float local_c8;
  float local_c4;
  float local_c0;
  float local_bc;
  float local_b8;
  int *local_b4;
  undefined4 *local_b0;
  int local_ac;
  undefined4 *local_a8;
  undefined4 *local_a4;
  int *local_a0;
  int *local_9c;
  int *local_98;
  int *local_94;
  int *local_90;
  int *local_8c;
  int *local_88;
  int *local_84;
  int *local_80;
  int *local_7c;
  int *local_78;
  int *local_74;
  int *local_70;
  int *local_6c;
  int *local_68;
  int *local_64;
  int *local_60;
  int *local_5c;
  int local_58;
  int local_54;
  int local_50;
  int local_4c;
  int local_48;
  int *local_44;
  float *local_40;
  int *local_3c;
  int *local_38;
  int *local_34;
  int *local_30;
  int *local_2c;
  int *local_28;
  int *local_24;
  undefined4 *local_20;
  undefined4 *local_1c;
  undefined4 *local_18;
  int *local_14;
  int *local_10;
  int *local_c;
  int *local_8;
  
  FUN_00424e38(param_1,param_2,param_3);
  *param_1 = (int)&PTR_FUN_0050cfa8;
  local_8 = param_1 + 0xd8;
  FUN_00435a7c(param_1 + 0xdb);
  FUN_0041b9ec(param_1 + 0xe7,0x21);
  param_1[0xff] = 0;
  param_1[0x100] = DAT_005209d0;
  param_1[0x104] = 0;
  FUN_004a4d60(param_1 + 0x106,0);
  FUN_00420ea4(param_1 + 0x10f,param_1 + 0x61);
  FUN_0041b9ec(param_1 + 0x114,3);
  param_1[0x12a] = 0;
  param_1[299] = 0;
  param_1[300] = 0x3f800000;
  FUN_0041b9ec(param_1 + 0x131,2);
  local_c = param_1 + 0x163;
  local_10 = param_1 + 0x166;
  FUN_00427768(param_1 + 0x197,(int)param_1);
  FUN_00427768(param_1 + 0x1af,(int)param_1);
  FUN_0041b9ec(param_1 + 0x1c5,0x21);
  param_1[0x1e8] = 0;
  param_1[0x1e9] = 0;
  param_1[0x1ea] = 0;
  FUN_004a4dab(param_1 + 0x1eb,0);
  FUN_004a4df6(param_1 + 0x1ef,0);
  FUN_004a4e41(param_1 + 499,0);
  FUN_0043ad4f((uint *)(param_1 + 0x1f8),0xf,0);
  FUN_0043ad4f((uint *)(param_1 + 0x1fb),0xf,0);
  FUN_0043ad4f((uint *)(param_1 + 0x1fe),0xf,0);
  FUN_0043ad4f((uint *)(param_1 + 0x201),0xf,0);
  FUN_0043ad4f((uint *)(param_1 + 0x204),0xf,0);
  local_14 = param_1 + 0x20e;
  local_18 = (undefined4 *)FUN_00402298(0x10);
  if (local_18 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(local_18);
  }
  param_1[0x211] = iVar3;
  piVar1 = (int *)(param_1[0x211] + 0xc);
  *piVar1 = *piVar1 + 1;
  local_1c = (undefined4 *)FUN_00402298(0x10);
  if (local_1c == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(local_1c);
  }
  param_1[0x212] = iVar3;
  piVar1 = (int *)(param_1[0x212] + 0xc);
  *piVar1 = *piVar1 + 1;
  local_20 = (undefined4 *)FUN_00402298(0x10);
  if (local_20 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(local_20);
  }
  param_1[0x213] = iVar3;
  piVar1 = (int *)(param_1[0x213] + 0xc);
  *piVar1 = *piVar1 + 1;
  param_1[10] = param_1[10] | 0x10;
  param_1[0x14a] = 0;
  param_1[0x10e] = 0;
  param_1[0x16d] = 0;
  param_1[0xca] = 0;
  param_1[0xcb] = 0;
  param_1[0xcc] = 0;
  param_1[0xcd] = 0;
  param_1[0xce] = 0;
  param_1[0xcf] = 0;
  param_1[0x153] = 0;
  param_1[0x154] = 0;
  param_1[0x155] = 0;
  param_1[0x156] = 0;
  param_1[0x157] = 0;
  param_1[0x158] = 0;
  param_1[0xd0] = 0;
  local_24 = (int *)FUN_00414b60();
  local_28 = param_1 + 0x1de;
  *local_28 = *local_24;
  param_1[0xd2] = 0;
  param_1[0x1ae] = 0;
  param_1[0x1ad] = 0;
  FUN_0040a938(param_1 + 0x98,param_1 + 0x40);
  FUN_0040a938(param_1 + 0x4b,param_1 + 0x40);
  local_2c = param_1 + 0x40;
  local_30 = param_1 + 0x163;
  FUN_00408440(local_30,local_2c);
  FUN_0040a7f4(param_1 + 0x71,(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4(param_1 + 0xa6,(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4(param_1 + 0xb2,(undefined4 *)&DAT_004e0fd4);
  FUN_0040a7f4(param_1 + 0x77,(undefined4 *)&DAT_004e0fd4);
  local_34 = param_1 + 0x7d;
  FUN_00408440(local_34,&DAT_004e0f74);
  local_38 = param_1 + 0x80;
  FUN_00408440(local_38,&DAT_004e0f74);
  local_3c = param_1 + 0x40;
  local_40 = (float *)(param_1 + 0x34);
  FUN_0040ab44(local_40,local_3c);
  local_44 = param_1 + 0x166;
  FUN_00408440(local_44,&DAT_004e0f74);
  param_1[0x169] = 0;
  param_1[0xe6] = 0;
  param_1[0x1df] = 0;
  param_1[0xfe] = 0;
  param_1[0xfc] = 0;
  param_1[0x105] = 0;
  FUN_00408e90(param_1 + 0xd8,&DAT_004e0f8c);
  param_1[0x160] = 0;
  param_1[0x15f] = 0;
  param_1[0x194] = 0;
  param_1[0x207] = 0;
  param_1[0x208] = 0;
  param_1[0x20a] = 0;
  FUN_0040a7f4(param_1 + 0x20b,(undefined4 *)&DAT_004e0fd4);
  param_1[0x1e7] = 0;
  param_1[0x1dd] = 0;
  param_1[0x209] = 0;
  param_1[0xd5] = 0;
  param_1[0xd6] = 0;
  param_1[0xd7] = 0;
  param_1[0x12d] = 0;
  param_1[0x129] = 2;
  param_1[0x1e0] = param_1[0x119];
  FUN_0041bbd8((int)(param_1 + 0x131),1);
  FUN_0041bbd8((int)(param_1 + 0x131),param_1[0x136]);
  local_50 = param_1[0xbb];
  param_1[0x146] = *(int *)(local_50 + 0xc);
  param_1[0x147] = (int)((float)_DAT_004a2d38 * (float)param_1[0x146]);
  param_1[0x16a] = 0x3f800000;
  param_1[0x16b] = 0x3f800000;
  local_54 = param_1[0x65];
  local_4c = local_50;
  local_48 = FUN_00433ed4(*(int *)(DAT_004efc94 + 0x30) + 0x14);
  param_1[0x94] = *(int *)(local_48 + 0x34) + 0x2c;
  if ((param_1[10] & 0xcU) == 4) {
    param_1[7] = (int)PTR_LAB_0050c0e8;
    param_1[8] = DAT_0050c0ec;
    param_1[9] = DAT_0050c0f0;
  }
  else {
    param_1[7] = (int)PTR_LAB_0050c0f4;
    param_1[8] = DAT_0050c0f8;
    param_1[9] = DAT_0050c0fc;
  }
  param_1[0x101] = 0x447a0000;
  param_1[0x102] = 0;
  param_1[0x103] = (int)(param_1 + 0x43);
  local_58 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_1[0x6f],0x11);
  iVar3 = *(int *)(local_58 + 4);
  *(int *)(local_58 + 4) = *(int *)(local_58 + 4) + 1;
  if (iVar3 == 0) {
    FUN_00406cd0(local_58);
  }
  FUN_004030dc(local_168,*(undefined4 *)(local_58 + 0x3c),*(undefined4 *)(local_58 + 0x40),0);
  param_1[0x49] = *local_160 + 2;
  local_160 = local_160 + 1;
  iVar3 = FUN_004022b0(param_1[0x49] << 2);
  param_1[0x4a] = iVar3;
  *(undefined4 *)param_1[0x4a] = 0;
  uVar4 = FUN_00417ab4((int)(param_1 + 199));
  *(undefined4 *)(param_1[0x4a] + 4) = uVar4;
  param_1[0x12e] = (int)((*(float *)(param_1[0xba] + 4) - *(float *)param_1[0xba]) * _DAT_004a2d40);
  *(float *)(param_1[0xbb] + 8) = (float)param_1[0x12e] + *(float *)(param_1[0xbb] + 8);
  param_1[0x112] = 0;
  param_1[0x10d] = 0;
  for (iVar3 = 2; piVar1 = local_160, iVar3 < param_1[0x49]; iVar3 = iVar3 + 1) {
    *(undefined4 *)(param_1[0x4a] + iVar3 * 4) = 0;
    if (((*(byte *)(local_160 + 0xb) & 4) == 0) || ((param_1[10] & 0xcU) != 4)) {
      switch(local_160[8]) {
      case 0xbbd:
        local_64 = (int *)FUN_00402298(0x230);
        if (local_64 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004ae568(local_64,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbbe:
        local_5c = (int *)FUN_00402298(0x1e4);
        if (local_5c == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004ae8d0(local_5c,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x1f7] = *(int *)(param_1[0x4a] + iVar3 * 4);
        break;
      default:
        FUN_0040385c(s_Unknown_subsystem_resource_>clas_0050c411,s_d__tesla_bt_bt_MECH_CPP_0050c436,
                     0x936);
        break;
      case 0xbc0:
        local_60 = (int *)FUN_00402298(0x230);
        if (local_60 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004af408(local_60,(int)param_1,iVar3,(char *)piVar1,&DAT_0050e640);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbc1:
        local_70 = (int *)FUN_00402298(0x250);
        if (local_70 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b225c(local_70,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbc2:
        local_68 = (int *)FUN_00402298(0x31c);
        if (local_68 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b0f74(local_68,(int)param_1,iVar3,(char *)piVar1,&DAT_0050f4ac,0,0);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbc3:
        local_80 = (int *)FUN_00402298(0x328);
        if (local_80 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b1d18(local_80,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbc4:
        local_84 = (int *)FUN_00402298(0x3d0);
        if (local_84 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b3778(local_84,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x14a] = *(int *)(param_1[0x4a] + iVar3 * 4);
        break;
      case 0xbc5:
        local_88 = (int *)FUN_00402298(0x280);
        if (local_88 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b6b0c(local_88,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x10e] = *(int *)(param_1[0x4a] + iVar3 * 4);
        break;
      case 0xbc6:
        local_6c = (int *)FUN_00402298(0x358);
        if (local_6c == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b8fec(local_6c,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbc8:
        local_8c = (int *)FUN_00402298(0x478);
        if (local_8c == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bb120(local_8c,(int)param_1,iVar3,(char *)piVar1,&DAT_00511d78);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x112] = param_1[0x112] + 1;
        break;
      case 0xbcb:
        local_a0 = (int *)FUN_00402298(0x22c);
        if (local_a0 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bd5c4(local_a0,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbcd:
        local_94 = (int *)FUN_00402298(0x448);
        if (local_94 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bc3fc(local_94,(int)param_1,iVar3,(char *)piVar1,&DAT_00512198);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x112] = param_1[0x112] + 1;
        break;
      case 0xbce:
        local_9c = (int *)FUN_00402298(0x484);
        if (local_9c == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bdcb4(local_9c,(int)param_1,iVar3,(char *)piVar1,&DAT_005128a8);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x112] = param_1[0x112] + 1;
        break;
      case 0xbd0:
        local_98 = (int *)FUN_00402298(0x44c);
        if (local_98 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bcff0(local_98,(int)param_1,iVar3,(char *)piVar1,&DAT_00512478);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x112] = param_1[0x112] + 1;
        break;
      case 0xbd3:
        local_a4 = (undefined4 *)FUN_00402298(0x130);
        if (local_a4 == (undefined4 *)0x0) {
          puVar9 = (undefined4 *)0x0;
        }
        else {
          puVar9 = FUN_0049bca4(local_a4,param_1,iVar3,(char *)piVar1,&DAT_0050b6bc);
        }
        *(undefined4 **)(param_1[0x4a] + iVar3 * 4) = puVar9;
        param_1[0x10d] = *(int *)(param_1[0x4a] + iVar3 * 4);
        break;
      case 0xbd4:
        local_90 = (int *)FUN_00402298(0x478);
        if (local_90 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004bb888(local_90,(int)param_1,iVar3,(char *)piVar1,&DAT_005120c4);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x112] = param_1[0x112] + 1;
        break;
      case 0xbd6:
        local_74 = (int *)FUN_00402298(0x2a4);
        if (local_74 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b7f94(local_74,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        param_1[0x16d] = *(int *)(param_1[0x4a] + iVar3 * 4);
        break;
      case 0xbd8:
        local_78 = (int *)FUN_00402298(0x238);
        if (local_78 == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b84dc(local_78,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
        break;
      case 0xbdc:
        local_a8 = (undefined4 *)FUN_00402298(0x104);
        if (local_a8 == (undefined4 *)0x0) {
          puVar9 = (undefined4 *)0x0;
        }
        else {
          puVar9 = FUN_004ad228(local_a8,(int)param_1,iVar3,(char *)piVar1,&DAT_0050e270);
        }
        *(undefined4 **)(param_1[0x4a] + iVar3 * 4) = puVar9;
        break;
      case 0xbde:
        local_7c = (int *)FUN_00402298(0x234);
        if (local_7c == (int *)0x0) {
          piVar5 = (int *)0x0;
        }
        else {
          piVar5 = FUN_004b8718(local_7c,(int)param_1,iVar3,(char *)piVar1);
        }
        *(int **)(param_1[0x4a] + iVar3 * 4) = piVar5;
      }
    }
    local_160 = (int *)((int)local_160 + piVar1[9]);
  }
  param_1[0x112] = 2;
  if ((param_1[0x10e] != 0) && (param_1[0x14a] != 0)) {
    local_ac = param_1[0x10e] + 0x1d8;
    *(int *)(param_1[0x14a] + 600) = local_ac;
  }
  for (iVar3 = 2; iVar3 < param_1[0x49]; iVar3 = iVar3 + 1) {
    piVar1 = *(int **)(param_1[0x4a] + iVar3 * 4);
    if ((piVar1 != (int *)0x0) && (iVar8 = FUN_0041a1a4(*(int *)piVar1[3],0x50e604), iVar8 != 0)) {
      (**(code **)(*piVar1 + 0x38))(piVar1);
    }
  }
  for (iVar3 = 2; iVar3 < param_1[0x49]; iVar3 = iVar3 + 1) {
    iVar8 = *(int *)(param_1[0x4a] + iVar3 * 4);
    if ((iVar8 != 0) && (iVar6 = FUN_0041a1a4(**(int **)(iVar8 + 0xc),0x51155c), iVar6 != 0)) {
      (**(code **)(param_1[0x1eb] + 4))(param_1 + 0x1eb,iVar8);
    }
  }
  for (iVar3 = 2; iVar3 < param_1[0x49]; iVar3 = iVar3 + 1) {
    iVar8 = *(int *)(param_1[0x4a] + iVar3 * 4);
    if ((iVar8 != 0) && (iVar6 = FUN_0041a1a4(**(int **)(iVar8 + 0xc),0x511830), iVar6 != 0)) {
      (**(code **)(param_1[0x1ef] + 4))(param_1 + 0x1ef,iVar8);
      param_1[0x104] = param_1[0x104] | *(uint *)(iVar8 + 0x334);
    }
  }
  for (iVar3 = 2; iVar3 < param_1[0x49]; iVar3 = iVar3 + 1) {
    iVar8 = *(int *)(param_1[0x4a] + iVar3 * 4);
    if ((iVar8 != 0) && (iVar6 = FUN_0041a1a4(**(int **)(iVar8 + 0xc),0x50e4fc), iVar6 != 0)) {
      (**(code **)(param_1[499] + 4))(param_1 + 499,iVar8);
    }
  }
  *(int *)(local_58 + 4) = *(int *)(local_58 + 4) + -1;
  local_58 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_1[0x6f],0xf);
  iVar3 = *(int *)(local_58 + 4);
  *(int *)(local_58 + 4) = *(int *)(local_58 + 4) + 1;
  if (iVar3 == 0) {
    FUN_00406cd0(local_58);
  }
  iVar3 = *(int *)(local_58 + 0x3c);
  local_b4 = param_1 + 0x68;
  local_b0 = (undefined4 *)(iVar3 + 0xa8);
  param_1[0x130] = *(int *)(iVar3 + 0x74);
  FUN_00408440(local_b4,local_b0);
  param_1[0x148] = *(int *)(iVar3 + 0x78);
  param_1[0x149] = *(int *)(iVar3 + 0x7c);
  param_1[0x195] = 0;
  param_1[0x196] = 0;
  param_1[0xfd] = 0;
  FUN_0041bbd8((int)(param_1 + 0xe7),0);
  FUN_0041bbd8((int)(param_1 + 0x1c5),0);
  param_1[0xd1] = *(int *)(iVar3 + 0x44);
  param_1[0x16c] = param_1[0xd1];
  param_1[0x16e] = param_1[0xd1];
  param_1[0x16f] = *(int *)(iVar3 + 0x48);
  param_1[0x170] = *(int *)(iVar3 + 0x4c);
  param_1[0x12f] = *(int *)(iVar3 + 0x70);
  param_1[0x1e1] = *(int *)(iVar3 + 0x80);
  param_1[0x1e2] = *(int *)(iVar3 + 0x84);
  param_1[0x1e3] = *(int *)(iVar3 + 0x88);
  param_1[0x1e4] = *(int *)(iVar3 + 0x8c);
  param_1[0x1e5] = *(int *)(iVar3 + 0x90);
  param_1[0x1e6] = *(int *)(iVar3 + 0x94);
  local_d0 = *(float *)(iVar3 + 0x50);
  local_bc = local_d0 * _DAT_004a2d44;
  param_1[0x159] = (int)local_bc;
  local_d8 = *(float *)(iVar3 + 0x54);
  local_b8 = local_d8 * _DAT_004a2d44;
  param_1[0x15a] = (int)local_b8;
  local_e0 = *(float *)(iVar3 + 0x58);
  local_c0 = local_e0 * _DAT_004a2d44;
  param_1[0x15b] = (int)local_c0;
  local_e8 = *(float *)(iVar3 + 0x5c);
  local_c4 = local_e8 * _DAT_004a2d44;
  param_1[0x15c] = (int)local_c4;
  local_f0 = *(float *)(iVar3 + 0xa0);
  local_c8 = local_f0 * _DAT_004a2d44;
  param_1[0x1dc] = (int)local_c8;
  param_1[0x1db] = *(int *)(iVar3 + 0x9c);
  param_1[0x1da] = *(int *)(iVar3 + 0x98);
  param_1[0x10c] = *(int *)(iVar3 + 0xa4);
  local_fc = (float *)(param_1 + 0x15d);
  local_f8 = *(float *)(iVar3 + 0x60);
  *local_fc = local_f8 * _DAT_004a2d44;
  local_104 = *(float *)(iVar3 + 100);
  local_108 = (float *)(param_1 + 0x15e);
  *local_108 = local_104 * _DAT_004a2d44;
  local_100 = local_104;
  local_f4 = local_f8;
  local_ec = local_f0;
  local_e4 = local_e8;
  local_dc = local_e0;
  local_d4 = local_d8;
  local_cc = local_d0;
  local_10c = FUN_00417ab4((int)(param_1 + 199));
  local_118 = (char *)(iVar3 + 0xb4);
  local_11c = (uint *)FUN_00402298(0x10);
  if (local_11c == (uint *)0x0) {
    puVar7 = (uint *)0x0;
  }
  else {
    puVar7 = FUN_00402460(local_11c,local_118);
  }
  puVar7[3] = puVar7[3] + 1;
  local_114 = FUN_00424b60((int)param_1,(int *)puVar7);
  local_120 = *(undefined4 *)(local_114 + 0xc0);
  local_110 = local_120;
  FUN_0041d3b3(local_184,local_10c + 0xe4);
  iVar8 = (**(code **)(local_184[0] + 0x34))(local_184,local_120);
  FUN_0041d3d2(local_184,2);
  param_1[0x10b] = iVar8;
  local_124 = FUN_004dee74(s_L4VIEWEXT_0050c44e);
  if (local_124 == 0) {
    if ((param_1[10] & 0xcU) == 4) {
      FUN_004a80d4((int)param_1,iVar3);
    }
    else {
      FUN_004a86c8((int)param_1,iVar3);
    }
  }
  else {
    param_1[0x15f] = 1;
    FUN_004a80d4((int)param_1,iVar3);
  }
  FUN_004a4f9e(local_190,(int)(param_1 + 0x1eb));
  while (iVar8 = (**(code **)(local_190[0] + 0x28))(local_190), iVar8 != 0) {
    FUN_004b8ef0(iVar8);
    param_1[0x1e9] = 1;
  }
  FUN_004283b8((int)(param_1 + 0x197),1);
  local_12c = (uint *)FUN_00402298(0x10);
  if (local_12c == (uint *)0x0) {
    puVar7 = (uint *)0x0;
  }
  else {
    puVar7 = FUN_00402460(local_12c,s_jointlocal_0050c458);
  }
  puVar7[3] = puVar7[3] + 1;
  local_128 = FUN_00424b60((int)param_1,(int *)puVar7);
  param_1[0x172] = *(int *)(local_128 + 0xc0);
  param_1[0xe5] = 0;
  param_1[0xdd] = 1;
  param_1[0xde] = 1;
  param_1[0xdb] = *(int *)(iVar3 + 0x68);
  param_1[0xdc] = *(int *)(iVar3 + 0x6c);
  *(int *)(local_58 + 4) = *(int *)(local_58 + 4) + -1;
  local_130 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_1[0x6f],0x14);
  iVar3 = *(int *)(local_130 + 4);
  *(int *)(local_130 + 4) = *(int *)(local_130 + 4) + 1;
  if (iVar3 == 0) {
    FUN_00406cd0(local_130);
  }
  uVar10 = 0xffffffff;
  pcVar12 = (char *)(local_130 + 0xc);
  do {
    pcVar13 = pcVar12;
    if (uVar10 == 0) break;
    uVar10 = uVar10 - 1;
    pcVar13 = pcVar12 + 1;
    cVar2 = *pcVar12;
    pcVar12 = pcVar13;
  } while (cVar2 != '\0');
  uVar10 = ~uVar10;
  pcVar12 = pcVar13 + -uVar10;
  pcVar13 = local_1b0;
  for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
    *(undefined4 *)pcVar13 = *(undefined4 *)pcVar12;
    pcVar12 = pcVar12 + 4;
    pcVar13 = pcVar13 + 4;
  }
  for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
    *pcVar13 = *pcVar12;
    pcVar12 = pcVar12 + 1;
    pcVar13 = pcVar13 + 1;
  }
  FUN_004032dc(local_1c8,*(undefined4 *)(local_130 + 0x3c),*(undefined4 *)(local_130 + 0x40),0);
  (**(code **)(local_1c8[0] + 0x14))(local_1c8,4);
  for (iVar3 = 0; iVar3 < param_1[0x47]; iVar3 = iVar3 + 1) {
    puVar9 = (undefined4 *)FUN_00402298(0x1b8);
    if (puVar9 == (undefined4 *)0x0) {
      puVar9 = (undefined4 *)0x0;
    }
    else {
      puVar9 = FUN_0049ce50(puVar9,(int)param_1,iVar3,local_1c8);
    }
    *(undefined4 **)(param_1[0x48] + iVar3 * 4) = puVar9;
  }
  for (iVar3 = 0; iVar3 < param_1[0x47]; iVar3 = iVar3 + 1) {
    FUN_0049d1d0(*(int *)(param_1[0x48] + iVar3 * 4));
  }
  *(int *)(local_130 + 4) = *(int *)(local_130 + 4) + -1;
  iVar3 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_1[0x6f],0x1e);
  param_1[0x214] = 0;
  if (iVar3 != 0) {
    iVar8 = *(int *)(iVar3 + 4);
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + 1;
    if (iVar8 == 0) {
      FUN_00406cd0(iVar3);
    }
    FUN_004032dc(local_1e0,*(undefined4 *)(iVar3 + 0x3c),*(undefined4 *)(iVar3 + 0x40),0);
    for (iVar8 = 0; iVar8 < param_1[0x47]; iVar8 = iVar8 + 1) {
      FUN_0041e4a8(*(int *)(param_1[0x48] + iVar8 * 4),local_1e0);
    }
    local_134 = (undefined4 *)FUN_00402298(0x18);
    if (local_134 == (undefined4 *)0x0) {
      puVar9 = (undefined4 *)0x0;
    }
    else {
      puVar9 = FUN_0042a984(local_134,(int)param_1);
    }
    param_1[0x214] = (int)puVar9;
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + -1;
    FUN_00403310(local_1e0,2);
  }
  iVar8 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_1b0,0x1d,-1);
  iVar3 = *(int *)(iVar8 + 4);
  *(int *)(iVar8 + 4) = *(int *)(iVar8 + 4) + 1;
  if (iVar3 == 0) {
    FUN_00406cd0(iVar8);
  }
  FUN_004032dc(local_1f8,*(undefined4 *)(iVar8 + 0x3c),*(undefined4 *)(iVar8 + 0x40),0);
  local_138 = (undefined4 *)FUN_00402298(0x2c);
  if (local_138 == (undefined4 *)0x0) {
    puVar9 = (undefined4 *)0x0;
  }
  else {
    puVar9 = FUN_0049ea48(local_138,(int)param_1,local_1f8);
  }
  param_1[0x111] = (int)puVar9;
  *(int *)(iVar8 + 4) = *(int *)(iVar8 + 4) + -1;
  FUN_00402a98((int *)&local_13c,param_1 + 0x211,(char *)(param_2 + 0x7c));
  local_140 = local_13c;
  piVar1 = local_13c + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_13c,3);
  }
  FUN_00402a98((int *)&local_144,param_1 + 0x212,(char *)(param_2 + 0x90));
  local_148 = local_144;
  piVar1 = local_144 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_144,3);
  }
  FUN_00402a98((int *)&local_14c,param_1 + 0x213,(char *)(param_2 + 0xa4));
  local_150 = local_14c;
  piVar1 = local_14c + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_14c,3);
  }
  local_154 = *(int *)(DAT_004efc94 + 0x24);
  puVar9 = (undefined4 *)FUN_00403ad0(local_154 + 0x18,s_Mechs_0050c463);
  if (puVar9 == (undefined4 *)0x0) {
    puVar9 = FUN_004212b0(local_154,s_Mechs_0050c469);
  }
  local_158 = param_1;
  (**(code **)(puVar9[4] + 4))(puVar9 + 4,param_1);
  FUN_0049f788((int)param_1);
  FUN_00403310(local_1f8,2);
  FUN_00403310(local_1c8,2);
  FUN_004a4ffb(local_190,2);
  return param_1;
}



/* @004a2d48 file=? name=FUN_004a2d48 */

int * __cdecl FUN_004a2d48(int param_1)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00402298(0x854);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_004a1674(piVar1,param_1,&DAT_0050bde4);
  }
  return piVar1;
}



/* @004a2d78 file=? name=FUN_004a2d78 */

undefined4 __cdecl FUN_004a2d78(undefined4 *param_1)

{
  int iVar1;
  
  iVar1 = FUN_00423864(param_1);
  if (iVar1 == 0) {
    return 0;
  }
  param_1[7] = 0xbb9;
  return 1;
}



/* @004a2da8 file=? name=FUN_004a2da8 */

undefined4 __cdecl
FUN_004a2da8(int param_1,char *param_2,int param_3,undefined4 param_4,float *param_5)

{
  char *pcVar1;
  char cVar2;
  float *pfVar3;
  int iVar4;
  float *pfVar5;
  char *pcVar6;
  int *piVar7;
  undefined4 *puVar8;
  uint uVar9;
  uint uVar10;
  char *pcVar11;
  float *pfVar12;
  bool bVar13;
  char *local_50;
  char *local_4c;
  char *local_48;
  char *local_44;
  char *local_40;
  char *local_3c;
  char *local_38;
  char *local_34;
  char *local_30;
  char *local_2c;
  char *local_28;
  char *local_24;
  char *local_20;
  float *local_1c;
  float *local_18;
  float *local_14;
  float *local_10;
  float *local_c;
  float *local_8;
  
  pfVar3 = param_5;
  if ((param_5 == (float *)0x0) && (pfVar3 = (float *)FUN_00402298(200), pfVar3 != (float *)0x0)) {
    local_8 = pfVar3 + 1;
    local_c = pfVar3 + 4;
    local_10 = pfVar3 + 7;
    local_14 = pfVar3 + 10;
    local_18 = pfVar3 + 0x1a;
    local_1c = pfVar3 + 0x2a;
  }
  iVar4 = FUN_004238bc(param_1,param_2,param_3,param_4,pfVar3);
  if ((iVar4 != -1) &&
     (iVar4 = FUN_00435ac8(param_1,param_2,param_3,param_4,pfVar3 + 0x1a), iVar4 != -1)) {
    iVar4 = FUN_00404088(param_3,s_gamedata_0050c46f,s_AnimationPrefix_0050c478,&local_20);
    if (iVar4 == 0) {
      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_missing_AnimationPrefix__0050c488,(char *)0x0);
    }
    else {
      iVar4 = FUN_004d4a78(local_20);
      if (iVar4 == 3) {
        uVar9 = 0xffffffff;
        do {
          pcVar6 = local_20;
          if (uVar9 == 0) break;
          uVar9 = uVar9 - 1;
          pcVar6 = local_20 + 1;
          cVar2 = *local_20;
          local_20 = pcVar6;
        } while (cVar2 != '\0');
        uVar9 = ~uVar9;
        pfVar5 = (float *)(pcVar6 + -uVar9);
        pfVar12 = pfVar3 + 0x10;
        for (uVar10 = uVar9 >> 2; uVar10 != 0; uVar10 = uVar10 - 1) {
          *pfVar12 = *pfVar5;
          pfVar5 = pfVar5 + 1;
          pfVar12 = pfVar12 + 1;
        }
        for (uVar9 = uVar9 & 3; uVar9 != 0; uVar9 = uVar9 - 1) {
          *(char *)pfVar12 = *(char *)pfVar5;
          pfVar5 = (float *)((int)pfVar5 + 1);
          pfVar12 = (float *)((int)pfVar12 + 1);
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c4c9,s_MaxAcceleration_0050c4d2,pfVar3 + 0x11);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_MaxAcceleration__0050c4e2,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c4fd,s_RelativeMechValue_0050c506,pfVar3 + 0x1c)
        ;
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_RelativeMechValue__0050c518,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c536,s_LookLeftAngle_0050c53f,pfVar3 + 0x14);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_LookLeftAngle__0050c54d,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c566,s_LookRightAngle_0050c56f,pfVar3 + 0x15);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_LookRightAngle__0050c57e,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c598,s_LookFrontAngle_0050c5a1,pfVar3 + 0x16);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_LookFrontAngle__0050c5b0,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c5ca,s_LookBackAngle_0050c5d3,pfVar3 + 0x17);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_LookBackAngle__0050c5e1,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c5fa,s_WalkingTurnRate_0050c603,pfVar3 + 0x18);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_WalkingTurnRate__0050c613,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c62e,s_RunningTurnRate_0050c637,pfVar3 + 0x19);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_runningTurnRate__0050c647,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404088(param_3,s_gamedata_0050c662,s_CameraOffset_0050c66b,&local_24);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_CameraOffset__0050c678,(char *)0x0);
        }
        FUN_00408944(local_24,pfVar3 + 0x2a);
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c690,s_DeathSplashDamage_0050c699,pfVar3 + 0x1e)
        ;
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_DeathSplashDamage__0050c6ab,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c6c8,s_DeathSplashRadius_0050c6d1,pfVar3 + 0x1f)
        ;
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_DeathSplashRadius__0050c6e3,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404088(param_3,s_gamedata_0050c700,s_DeathEffect_0050c709,&local_28);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_DeathEffect__0050c715,(char *)0x0);
          return 0;
        }
        pfVar5 = (float *)FUN_00406ff8(param_1,local_28,1,-1);
        if (pfVar5 == (float *)0x0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_cannot_find_0050c72c,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_28,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_in_resource_file__0050c73a,(char *)0x0);
          return 0;
        }
        pfVar3[0x1d] = *pfVar5;
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c74e,s_MaxUnstableAcceleration_0050c757,
                             pfVar3 + 0x20);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_MaxUnstableAcceleration__0050c76f,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c792,s_UnstableAccelerationEffect_0050c79b,
                             pfVar3 + 0x21);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UnstableAccelerationEffe_0050c7b6,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c7dc,s_UnstableGunTheEngineEffect_0050c7e5,
                             pfVar3 + 0x22);
        if (iVar4 == 0) {
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UnstableGunTheEngineEffe_0050c800,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c826,s_UnstableSuperStopEffect_0050c82f,
                             pfVar3 + 0x23);
        if (iVar4 == 0) {
          local_2c = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UnstableSuperStopEffect__0050c847,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c86a,s_UnstableHighVelocityEffect_0050c873,
                             pfVar3 + 0x24);
        if (iVar4 == 0) {
          local_30 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UnstableHighVelocityEffe_0050c88e,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c8b4,s_UnstableStopedTurnEffect_0050c8bd,
                             pfVar3 + 0x25);
        if (iVar4 == 0) {
          local_34 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UnstableStopedTurnEffect_0050c8d6,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c8fa,s_SuperStopAcceleration_0050c903,
                             pfVar3 + 0x12);
        if (iVar4 == 0) {
          local_38 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_SuperStopAcceleration__0050c919,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c93a,s_ThrottleAdjustment_0050c943,pfVar3 + 0x13
                            );
        if (iVar4 == 0) {
          local_3c = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_ThrottleAdjustment__0050c956,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c974,s_UpdateTurnVelocityDiffrence_0050c97d,
                             pfVar3 + 0x27);
        if (iVar4 == 0) {
          local_40 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UpdateTurnVelocityDiffre_0050c999,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050c9c0,s_UpdateTurnDegreeDiffrence_0050c9c9,
                             pfVar3 + 0x28);
        if (iVar4 == 0) {
          local_44 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UpdateTurnDegreeDiffrenc_0050c9e3,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050ca08,s_UpdatePositionDiffrence_0050ca11,
                             pfVar3 + 0x26);
        if (iVar4 == 0) {
          local_48 = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_UpdatePositionDiffrence__0050ca29,(char *)0x0);
          return 0;
        }
        iVar4 = FUN_00404118(param_3,s_gamedata_0050ca4c,s_TimeDelay_0050ca55,pfVar3 + 0x29);
        if (iVar4 == 0) {
          local_4c = param_2;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_missing_TimeDelay__0050ca5f,(char *)0x0);
          return 0;
        }
        local_50 = s_Unspecified_0050ca74;
        iVar4 = FUN_00404088(param_3,s_gamedata_0050ca80,s_ShadowJointName_0050ca89,&local_50);
        if (iVar4 != 0) {
          pcVar11 = s_Unspecified_0050ca99;
          pcVar6 = local_50;
          do {
            if (*pcVar6 != *pcVar11) goto LAB_004a36e3;
            bVar13 = true;
            if (*pcVar6 == '\0') break;
            pcVar1 = pcVar6 + 1;
            if (*pcVar1 != pcVar11[1]) goto LAB_004a36e3;
            pcVar6 = pcVar6 + 2;
            pcVar11 = pcVar11 + 2;
            bVar13 = *pcVar1 == '\0';
          } while (!bVar13);
          if (!bVar13) {
LAB_004a36e3:
            uVar9 = FUN_004d4a78(local_50);
            if (0x13 < uVar9) {
              FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,s_ShadowJointName_must_be_less_tha_0050cac0,(char *)0x0);
              piVar7 = FUN_004db880(&DAT_00524e20,0x14);
              FUN_004dbb24(piVar7,s_characters_long__0050cae4,(char *)0x0);
              return 0;
            }
            FUN_004d4918(pfVar3 + 0x2d,(undefined4 *)local_50,uVar9 + 1);
            if (param_5 == (float *)0x0) {
              puVar8 = (undefined4 *)FUN_00406db4(param_1,param_2,0xf,1,0,pfVar3,200,-1);
              FUN_004022d0((int *)pfVar3);
              return *puVar8;
            }
            return 0;
          }
        }
        FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_missing_ShadowJointName__0050caa5,(char *)0x0);
        return 0;
      }
      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_must_have_3_letter_AnimationPref_0050c4a3,(char *)0x0);
    }
  }
  if (param_5 == (float *)0x0) {
    FUN_004022d0((int *)pfVar3);
  }
  return 0xffffffff;
}



/* @004a3794 file=? name=FUN_004a3794 */

undefined4 __cdecl
FUN_004a3794(char *param_1,int param_2,undefined *param_3,int param_4,char *param_5,int param_6,
            undefined4 *param_7,int *param_8)

{
  char cVar1;
  undefined4 *puVar2;
  undefined4 uVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  uint *puVar7;
  undefined *puVar8;
  uint uVar9;
  uint uVar10;
  char *pcVar11;
  char *pcVar12;
  char *pcVar13;
  byte bVar14;
  byte bVar15;
  uint local_19c [2];
  char *local_194;
  char local_18c [80];
  undefined4 *local_13c;
  char *local_138;
  char *local_134;
  uint *local_130;
  uint *local_12c;
  char *local_128;
  int *local_124;
  char *local_120;
  int *local_11c;
  char *local_118;
  int *local_114;
  uint *local_110;
  uint *local_10c;
  char *local_108;
  int *local_104;
  char *local_100;
  char *local_fc;
  uint *local_f8;
  uint *local_f4;
  char *local_f0;
  int *local_ec;
  char *local_e8;
  int *local_e4;
  char *local_e0;
  int *local_dc;
  uint *local_d8;
  uint *local_d4;
  char *local_d0;
  int *local_cc;
  char *local_c8;
  char *local_c4;
  uint *local_c0;
  uint *local_bc;
  char *local_b8;
  char *local_b4;
  uint *local_b0;
  uint *local_ac;
  char *local_a8;
  char *local_a4;
  char *local_a0;
  uint *local_9c;
  uint *local_98;
  char *local_94;
  uint *local_90;
  char *local_8c;
  char *local_88;
  int local_84;
  char *local_80;
  uint *local_7c;
  char *local_78;
  uint *local_74;
  char *local_70;
  char *local_6c;
  char *local_68;
  char *local_64;
  char *local_60;
  char *local_5c;
  int *local_58;
  char *local_54;
  int *local_50;
  int *local_4c;
  int *local_48;
  int *local_44;
  char *local_40;
  char *local_3c;
  char *local_38;
  char *local_34;
  char *local_30;
  char *local_2c;
  char *local_28;
  int local_24;
  int local_20;
  int *local_1c;
  int *local_18;
  char *local_14;
  int local_10;
  undefined4 *local_c;
  int *local_8;
  
  local_8 = FUN_0040485c(param_2,(char *)0x0);
  local_c = (undefined4 *)local_8[1];
  if ((*(byte *)(param_2 + 0x1c) & 2) == 0) {
    local_10 = *(int *)(param_2 + 0xc);
  }
  else {
    local_10 = *(int *)(param_2 + 0x10);
  }
  if (local_10 == 0) {
    local_14 = param_5;
    FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_is_missing_control_mappings__0050caf7,(char *)0x0);
LAB_004a3808:
    if (local_8 != (int *)0x0) {
      (**(code **)*local_8)(local_8,3);
    }
    uVar3 = 0xffffffff;
  }
  else {
    local_18 = (int *)FUN_004022b0((local_10 * 6 + 6) * 0x18);
    *local_18 = local_10;
    local_1c = local_18 + 1;
    local_20 = 0;
    local_24 = 0;
    if (0 < local_10) {
LAB_004a386b:
      piVar5 = local_1c;
      pcVar12 = (char *)(local_c + 2);
      iVar4 = FUN_00404088(param_2,pcVar12,s_IOMapping_0050cb16,&local_28);
      if (iVar4 != 0) {
        iVar4 = (*(code *)param_3)(local_28,piVar5);
        if (iVar4 == 0) {
          local_34 = local_28;
          local_38 = param_5;
          FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s___control_type___0050cb35,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,local_34,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s___does_not_exist__0050cb46,(char *)0x0);
          goto LAB_004a38db;
        }
        piVar5[3] = -1;
        local_18c[0] = '\0';
        iVar4 = FUN_00404088(param_2,pcVar12,s_Subsystem_0050cb59,&local_3c);
        if (iVar4 != 0) {
          iVar4 = FUN_004d4b58(local_3c,s_ControlsMapper_0050cb63);
          if (iVar4 == 0) {
            piVar5[3] = 0;
            uVar9 = 0xffffffff;
            pcVar11 = local_3c;
            do {
              pcVar13 = pcVar11;
              if (uVar9 == 0) break;
              uVar9 = uVar9 - 1;
              pcVar13 = pcVar11 + 1;
              cVar1 = *pcVar11;
              pcVar11 = pcVar13;
            } while (cVar1 != '\0');
            uVar9 = ~uVar9;
            pcVar11 = pcVar13 + -uVar9;
            pcVar13 = local_18c;
            for (uVar10 = uVar9 >> 2; uVar10 != 0; uVar10 = uVar10 - 1) {
              *(undefined4 *)pcVar13 = *(undefined4 *)pcVar11;
              pcVar11 = pcVar11 + 4;
              pcVar13 = pcVar13 + 4;
            }
            for (uVar9 = uVar9 & 3; uVar9 != 0; uVar9 = uVar9 - 1) {
              *pcVar13 = *pcVar11;
              pcVar11 = pcVar11 + 1;
              pcVar13 = pcVar13 + 1;
            }
            goto LAB_004a3c00;
          }
          FUN_00404088(param_6,s_gamedata_0050cb72,s_Subsystems_0050cb7b,&local_40);
          local_44 = (int *)FUN_004064fc((char *)*param_7,local_40);
          piVar6 = (int *)FUN_00402298(0x20);
          if (piVar6 == (int *)0x0) {
            local_48 = (int *)0x0;
          }
          else {
            local_48 = FUN_00403e84(piVar6,(char *)local_44,0x1e);
          }
          local_4c = FUN_0040485c((int)local_48,(char *)0x0);
          puVar2 = (undefined4 *)local_4c[1];
          piVar5[3] = 2;
          while (puVar2 != (undefined4 *)0x0) {
            iVar4 = FUN_004d4b58((char *)(puVar2 + 2),local_3c);
            if (iVar4 == 0) {
              iVar4 = FUN_00404088((int)local_48,local_3c,&DAT_0050cb86,&local_40);
              if (iVar4 == 0) {
                local_50 = local_44;
                local_54 = local_3c;
                bVar14 = 0x3a;
                local_5c = param_5;
                FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
                local_58 = FUN_004db92c(&DAT_00524e20,bVar14);
                FUN_004dbb24(local_58,local_54,(char *)0x0);
                FUN_004dbb24(local_58,s_does_not_have_a__Type__in_file___0050cb8b,(char *)0x0);
                FUN_004dbb24(local_58,(char *)local_50,(char *)0x0);
                FUN_004dbb24(local_58,&DAT_0050cbad,(char *)0x0);
              }
              uVar9 = 0xffffffff;
              pcVar11 = local_40;
              goto code_r0x004a3b0c;
            }
            puVar2 = (undefined4 *)*puVar2;
            piVar5[3] = piVar5[3] + 1;
          }
          goto LAB_004a3b41;
        }
        goto LAB_004a3c00;
      }
      bVar14 = 0x3a;
      local_30 = param_5;
      local_2c = pcVar12;
      FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
      piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
      FUN_004dbb24(piVar5,local_2c,(char *)0x0);
      FUN_004dbb24(piVar5,s_has_no_IOMapping___0050cb20,(char *)0x0);
LAB_004a38db:
      FUN_004022d0(local_18);
      goto LAB_004a3808;
    }
LAB_004a44c9:
    *local_18 = local_20;
    local_13c = (undefined4 *)
                FUN_00406db4(param_4,param_1,0x13,1,0,local_18,(int)local_1c - (int)local_18,-1);
    FUN_004022e8(local_18);
    if (local_8 != (int *)0x0) {
      (**(code **)*local_8)(local_8,3);
    }
    uVar3 = *local_13c;
  }
  return uVar3;
  while( true ) {
    uVar9 = uVar9 - 1;
    pcVar13 = pcVar11 + 1;
    cVar1 = *pcVar11;
    pcVar11 = pcVar13;
    if (cVar1 == '\0') break;
code_r0x004a3b0c:
    pcVar13 = pcVar11;
    if (uVar9 == 0) break;
  }
  uVar9 = ~uVar9;
  pcVar11 = pcVar13 + -uVar9;
  pcVar13 = local_18c;
  for (uVar10 = uVar9 >> 2; uVar10 != 0; uVar10 = uVar10 - 1) {
    *(undefined4 *)pcVar13 = *(undefined4 *)pcVar11;
    pcVar11 = pcVar11 + 4;
    pcVar13 = pcVar13 + 4;
  }
  for (uVar9 = uVar9 & 3; uVar9 != 0; uVar9 = uVar9 - 1) {
    *pcVar13 = *pcVar11;
    pcVar11 = pcVar11 + 1;
    pcVar13 = pcVar13 + 1;
  }
  local_3c = local_40;
LAB_004a3b41:
  FUN_004022d0(local_44);
  if (puVar2 == (undefined4 *)0x0) {
    local_60 = local_3c;
    local_64 = param_5;
    FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s__subsystem___0050cbb1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,local_60,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___does_not_exist__0050cbbe,(char *)0x0);
    FUN_00403ecc(local_48,3);
    if (local_4c != (int *)0x0) {
      (**(code **)*local_4c)(local_4c,3);
    }
    FUN_004022e8(local_18);
    goto LAB_004a3808;
  }
  FUN_00403ecc(local_48,3);
  if (local_4c != (int *)0x0) {
    (**(code **)*local_4c)(local_4c,3);
  }
LAB_004a3c00:
  iVar4 = FUN_00404088(param_2,pcVar12,&DAT_0050cbd1,&local_68);
  if (iVar4 == 0) {
    bVar14 = 0x3a;
    local_70 = param_5;
    local_6c = pcVar12;
    FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
    piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
    FUN_004dbb24(piVar5,local_6c,(char *)0x0);
    FUN_004dbb24(piVar5,s_is_missing_Mode__0050cbd6,(char *)0x0);
  }
  else {
    local_78 = local_68;
    puVar7 = (uint *)FUN_00402298(0x10);
    if (puVar7 == (uint *)0x0) {
      local_74 = (uint *)0x0;
    }
    else {
      local_74 = FUN_00402460(puVar7,local_78);
    }
    local_74[3] = local_74[3] + 1;
    FUN_00402838(local_19c,local_74,0,(char *)0x0);
    local_80 = local_194;
    puVar7 = (uint *)FUN_00402298(0x10);
    if (puVar7 == (uint *)0x0) {
      local_7c = (uint *)0x0;
    }
    else {
      local_7c = FUN_00402460(puVar7,local_80);
    }
    local_7c[3] = local_7c[3] + 1;
    FUN_004024d8((int *)local_19c,2);
    local_84 = (**(code **)(*param_8 + 0x18))(param_8,local_7c[2],piVar5 + 4);
    if (local_84 == 0) {
      bVar14 = 0x3a;
      local_8c = param_5;
      local_88 = pcVar12;
      FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
      piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
      FUN_004dbb24(piVar5,local_88,(char *)0x0);
      FUN_004dbb24(piVar5,s_has_an_unsupported_Mode_type___0050cbe9,(char *)0x0);
      local_90 = local_7c;
      local_94 = (char *)local_7c[2];
      FUN_004dbb24(piVar5,local_94,(char *)0x0);
      FUN_004dbb24(piVar5,&DAT_0050cc09,(char *)0x0);
      local_98 = local_7c;
      puVar7 = local_7c + 3;
      *puVar7 = *puVar7 - 1;
      if (*puVar7 == 0) {
        FUN_004024d8((int *)local_7c,3);
      }
      local_9c = local_74;
      puVar7 = local_74 + 3;
      *puVar7 = *puVar7 - 1;
      if (*puVar7 == 0) {
        FUN_004024d8((int *)local_74,3);
      }
    }
    else {
      iVar4 = FUN_00404088(param_2,pcVar12,&DAT_0050cc0c,&local_a0);
      if (iVar4 == 0) {
        bVar14 = 0x3a;
        local_a8 = param_5;
        local_a4 = pcVar12;
        FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
        piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
        FUN_004dbb24(piVar5,local_a4,(char *)0x0);
        FUN_004dbb24(piVar5,s_is_missing_type__0050cc11,(char *)0x0);
        local_ac = local_7c;
        puVar7 = local_7c + 3;
        *puVar7 = *puVar7 - 1;
        if (*puVar7 == 0) {
          FUN_004024d8((int *)local_7c,3);
        }
        local_b0 = local_74;
        puVar7 = local_74 + 3;
        *puVar7 = *puVar7 - 1;
        if (*puVar7 == 0) {
          FUN_004024d8((int *)local_74,3);
        }
      }
      else {
        puVar8 = FUN_004a9770(local_18c);
        if (puVar8 == (undefined *)0x0) {
          local_b4 = local_3c;
          bVar14 = 0x3a;
          local_b8 = param_5;
          FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
          piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
          FUN_004dbb24(piVar5,local_b4,(char *)0x0);
          FUN_004dbb24(piVar5,s_is_an_unsupported_subsystem__0050cc24,(char *)0x0);
          local_bc = local_7c;
          puVar7 = local_7c + 3;
          *puVar7 = *puVar7 - 1;
          if (*puVar7 == 0) {
            FUN_004024d8((int *)local_7c,3);
          }
          local_c0 = local_74;
          puVar7 = local_74 + 3;
          *puVar7 = *puVar7 - 1;
          if (*puVar7 == 0) {
            FUN_004024d8((int *)local_74,3);
          }
        }
        else {
          iVar4 = FUN_004d4b58(local_a0,s_EventMapping_0050cc43);
          if (iVar4 == 0) {
            piVar5[2] = 1;
            iVar4 = FUN_00404088(param_2,pcVar12,s_MessageID_0050cc50,&local_c4);
            if (iVar4 == 0) {
              bVar14 = 0x3a;
              local_d0 = param_5;
              local_c8 = pcVar12;
              FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
              local_cc = FUN_004db92c(&DAT_00524e20,bVar14);
              FUN_004dbb24(local_cc,local_c8,(char *)0x0);
              FUN_004dbb24(local_cc,s_is_missing_MessageID__0050cc5a,(char *)0x0);
              local_d4 = local_7c;
              puVar7 = local_7c + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_7c,3);
              }
              local_d8 = local_74;
              puVar7 = local_74 + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_74,3);
              }
            }
            else {
              local_dc = (int *)FUN_0041a058(*(int **)(puVar8 + 4),local_c4);
              if (local_dc != (int *)0x0) {
                piVar5[5] = *local_dc;
LAB_004a4483:
                local_1c = local_1c + 6;
                local_20 = local_20 + 1;
                local_c = (undefined4 *)*local_c;
                puVar7 = local_7c + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_7c,3);
                }
                puVar7 = local_74 + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_74,3);
                }
                local_24 = local_24 + 1;
                if (local_10 <= local_24) goto LAB_004a44c9;
                goto LAB_004a386b;
              }
              local_e0 = local_c4;
              bVar15 = 0x3a;
              local_e8 = local_3c;
              bVar14 = 0x3a;
              local_f0 = param_5;
              FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
              local_ec = FUN_004db92c(&DAT_00524e20,bVar14);
              FUN_004dbb24(local_ec,local_e8,(char *)0x0);
              local_e4 = FUN_004db92c(local_ec,bVar15);
              FUN_004dbb24(local_e4,local_e0,(char *)0x0);
              FUN_004dbb24(local_e4,s_is_an_unsupported_messageID__0050cc72,(char *)0x0);
              local_f4 = local_7c;
              puVar7 = local_7c + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_7c,3);
              }
              local_f8 = local_74;
              puVar7 = local_74 + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_74,3);
              }
            }
          }
          else {
            iVar4 = FUN_004d4b58(local_a0,s_DirectMapping_0050cc91);
            if (iVar4 == 0) {
              piVar5[2] = 0;
              iVar4 = FUN_00404088(param_2,pcVar12,s_AttributeID_0050cc9f,&local_fc);
              if (iVar4 == 0) {
                bVar14 = 0x3a;
                local_108 = param_5;
                local_100 = pcVar12;
                FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
                local_104 = FUN_004db92c(&DAT_00524e20,bVar14);
                FUN_004dbb24(local_104,local_100,(char *)0x0);
                FUN_004dbb24(local_104,s_is_missing_AttributeID__0050ccab,(char *)0x0);
                local_10c = local_7c;
                puVar7 = local_7c + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_7c,3);
                }
                local_110 = local_74;
                puVar7 = local_74 + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_74,3);
                }
              }
              else {
                local_114 = (int *)FUN_0041c2fc(*(int **)(puVar8 + 8),local_fc);
                if (local_114 != (int *)0x0) {
                  piVar5[5] = *local_114;
                  goto LAB_004a4483;
                }
                local_118 = local_fc;
                bVar15 = 0x3a;
                local_120 = local_3c;
                bVar14 = 0x3a;
                local_128 = param_5;
                FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
                local_124 = FUN_004db92c(&DAT_00524e20,bVar14);
                FUN_004dbb24(local_124,local_120,(char *)0x0);
                local_11c = FUN_004db92c(local_124,bVar15);
                FUN_004dbb24(local_11c,local_118,(char *)0x0);
                FUN_004dbb24(local_11c,s_is_an_unsupported_AttributeID__0050ccc5,(char *)0x0);
                local_12c = local_7c;
                puVar7 = local_7c + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_7c,3);
                }
                local_130 = local_74;
                puVar7 = local_74 + 3;
                *puVar7 = *puVar7 - 1;
                if (*puVar7 == 0) {
                  FUN_004024d8((int *)local_74,3);
                }
              }
            }
            else {
              bVar14 = 0x3a;
              local_138 = param_5;
              local_134 = pcVar12;
              FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
              piVar5 = FUN_004db92c(&DAT_00524e20,bVar14);
              FUN_004dbb24(piVar5,local_134,(char *)0x0);
              FUN_004dbb24(piVar5,s_has_unknown_mapping_type__0050cce6,(char *)0x0);
              puVar7 = local_7c + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_7c,3);
              }
              puVar7 = local_74 + 3;
              *puVar7 = *puVar7 - 1;
              if (*puVar7 == 0) {
                FUN_004024d8((int *)local_74,3);
              }
            }
          }
        }
      }
    }
  }
  FUN_004022e8(local_18);
  goto LAB_004a3808;
}



/* @004a452c file=? name=FUN_004a452c */

void __cdecl FUN_004a452c(int *param_1,byte param_2)

{
  int iVar1;
  int *piVar2;
  undefined4 *puVar3;
  int *piVar4;
  int iVar5;
  int local_10 [3];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cfa8;
    puVar3 = (undefined4 *)param_1[0x111];
    if (puVar3 != (undefined4 *)0x0) {
      (**(code **)*puVar3)(puVar3,3);
    }
    iVar1 = *(int *)(DAT_004efc94 + 0x24);
    puVar3 = (undefined4 *)FUN_00403ad0(iVar1 + 0x18,s_Mechs_0050cd02);
    if (puVar3 != (undefined4 *)0x0) {
      FUN_00421414(local_10,(int)(puVar3 + 4));
      piVar4 = (int *)(**(code **)(local_10[0] + 0x30))(local_10);
      if (param_1 == piVar4) {
        (**(code **)(local_10[0] + 0x48))(local_10);
        iVar5 = (**(code **)(local_10[0] + 0x30))(local_10);
        if (iVar5 == 0) {
          FUN_00421308(iVar1,puVar3);
        }
      }
      FUN_00421452(local_10,2);
    }
    puVar3 = (undefined4 *)param_1[0x214];
    if ((puVar3 != (undefined4 *)0x0) && (puVar3 != (undefined4 *)0x0)) {
      (**(code **)*puVar3)(puVar3,3);
    }
    piVar2 = (int *)param_1[0x213];
    piVar4 = piVar2 + 3;
    *piVar4 = *piVar4 + -1;
    if (*piVar4 == 0) {
      FUN_004024d8(piVar2,3);
    }
    piVar2 = (int *)param_1[0x212];
    piVar4 = piVar2 + 3;
    *piVar4 = *piVar4 + -1;
    if (*piVar4 == 0) {
      FUN_004024d8(piVar2,3);
    }
    piVar2 = (int *)param_1[0x211];
    piVar4 = piVar2 + 3;
    *piVar4 = *piVar4 + -1;
    if (*piVar4 == 0) {
      FUN_004024d8(piVar2,3);
    }
    FUN_0043adb5(param_1 + 0x204,2);
    FUN_0043adb5(param_1 + 0x201,2);
    FUN_0043adb5(param_1 + 0x1fe,2);
    FUN_0043adb5(param_1 + 0x1fb,2);
    FUN_0043adb5(param_1 + 0x1f8,2);
    FUN_004a4e60(param_1 + 499,2);
    FUN_004a4e15(param_1 + 0x1ef,2);
    FUN_004a4dca(param_1 + 0x1eb,2);
    FUN_0041baa4(param_1 + 0x1c5,2);
    FUN_004278d4(param_1 + 0x1af,2);
    FUN_004278d4(param_1 + 0x197,2);
    FUN_0041baa4(param_1 + 0x131,2);
    FUN_0041baa4(param_1 + 0x114,2);
    FUN_004a4d7f(param_1 + 0x106,2);
    FUN_0041baa4(param_1 + 0xe7,2);
    FUN_00425550(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a474c file=? name=FUN_004a474c */

undefined4 __cdecl FUN_004a474c(int param_1,char *param_2,uint param_3,undefined4 *param_4)

{
  char cVar1;
  undefined4 *puVar2;
  bool bVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  undefined3 extraout_var;
  int *piVar7;
  uint uVar8;
  uint uVar9;
  char *pcVar10;
  char *pcVar11;
  undefined4 uVar12;
  int local_7c [6];
  char local_64 [32];
  int local_44 [6];
  undefined4 *local_2c;
  int *local_28;
  char *local_24;
  int local_20;
  int *local_1c;
  int local_18;
  int *local_14;
  char *local_10;
  int *local_c;
  char *local_8;
  
  iVar4 = FUN_00404088(param_3,s_video_0050cd08,s_skeleton_0050cd0e,&local_8);
  if (iVar4 == 0) {
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_is_missing__skl_file_specificati_0050cd17,(char *)0x0);
    return 0xffffffff;
  }
  local_c = (int *)FUN_004064fc((char *)param_4[4],local_8);
  piVar5 = (int *)FUN_00402298(0x20);
  if (piVar5 == (int *)0x0) {
    piVar5 = (int *)0x0;
  }
  else {
    piVar5 = FUN_00403e84(piVar5,(char *)local_c,1);
  }
  if ((*(byte *)(piVar5 + 7) & 2) == 0) {
    iVar4 = piVar5[3];
  }
  else {
    iVar4 = piVar5[4];
  }
  if (iVar4 == 0) {
    FUN_004dbb24(&DAT_00524e20,(char *)local_c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_is_empty_or_missing__0050cd3d,(char *)0x0);
  }
  else {
    iVar4 = FUN_00404088(param_3,s_gamedata_0050cd54,s_DamageZones_0050cd5d,&local_10);
    if (iVar4 == 0) {
      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_is_missing__dmg_file_specificati_0050cd69,(char *)0x0);
    }
    else {
      local_14 = (int *)FUN_004064fc((char *)*param_4,local_10);
      piVar6 = (int *)FUN_00402298(0x20);
      if (piVar6 == (int *)0x0) {
        piVar6 = (int *)0x0;
      }
      else {
        piVar6 = FUN_00403e84(piVar6,(char *)local_14,1);
      }
      if ((*(byte *)(piVar6 + 7) & 2) == 0) {
        iVar4 = piVar6[3];
      }
      else {
        iVar4 = piVar6[4];
      }
      if (iVar4 == 0) {
        FUN_004dbb24(&DAT_00524e20,(char *)local_14,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_is_empty_or_missing__0050cd8f,(char *)0x0);
      }
      else {
        bVar3 = FUN_004040d8((int)piVar5,&DAT_0050cda6,s_DZoneCount_0050cdab,&local_18);
        if (CONCAT31(extraout_var,bVar3) != 0) {
          FUN_0040328c(local_44,0);
          (**(code **)(local_44[0] + 0x20))(local_44,&local_18,4);
          local_1c = FUN_00404720((int)piVar5,s_DamageZones_0050cdcf,&DAT_0050cddb);
          iVar4 = FUN_00403b60((int)local_1c);
          if (iVar4 == 0) {
            FUN_004dbb24(&DAT_00524e20,s_No_dZones_listed_in_DamageZones_P_0050cddf,(char *)0x0);
            FUN_004d9c38(&DAT_00524e20);
          }
          else {
            local_20 = 0;
            for (puVar2 = (undefined4 *)local_1c[1]; puVar2 != (undefined4 *)0x0;
                puVar2 = (undefined4 *)*puVar2) {
              local_20 = local_20 + 1;
              uVar8 = 0xffffffff;
              pcVar10 = (char *)(puVar2 + 2);
              do {
                pcVar11 = pcVar10;
                if (uVar8 == 0) break;
                uVar8 = uVar8 - 1;
                pcVar11 = pcVar10 + 1;
                cVar1 = *pcVar10;
                pcVar10 = pcVar11;
              } while (cVar1 != '\0');
              uVar8 = ~uVar8;
              pcVar10 = pcVar11 + -uVar8;
              pcVar11 = local_64;
              for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
                *(undefined4 *)pcVar11 = *(undefined4 *)pcVar10;
                pcVar10 = pcVar10 + 4;
                pcVar11 = pcVar11 + 4;
              }
              for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
                *pcVar11 = *pcVar10;
                pcVar10 = pcVar10 + 1;
                pcVar11 = pcVar11 + 1;
              }
              FUN_0049d304(param_1,param_3,param_2,(int)piVar5,local_64,(uint)piVar6,param_4,
                           local_44);
            }
            if (local_18 == local_20) {
              iVar4 = FUN_00404088(param_3,s_gamedata_0050ce39,s_DamageLookupTable_0050ce42,
                                   &local_24);
              if (iVar4 == 0) {
                FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
                FUN_004dbb24(&DAT_00524e20,s_is_missing__tbl_file_specificati_0050ce54,(char *)0x0);
                uVar12 = 0xffffffff;
                FUN_00403310(local_44,2);
                return uVar12;
              }
              local_28 = (int *)FUN_004064fc((char *)*param_4,local_24);
              piVar7 = (int *)FUN_00402298(0x20);
              if (piVar7 == (int *)0x0) {
                piVar7 = (int *)0x0;
              }
              else {
                piVar7 = FUN_00403e84(piVar7,(char *)local_28,1);
              }
              if ((*(byte *)(piVar7 + 7) & 2) == 0) {
                iVar4 = piVar7[3];
              }
              else {
                iVar4 = piVar7[4];
              }
              if (iVar4 != 0) {
                FUN_0040328c(local_7c,0);
                FUN_0049ed28(param_3,param_2,piVar7,(int)param_4,local_7c);
                local_2c = (undefined4 *)FUN_00406f3c(param_1,param_2,0x14,1,0,local_44,-1);
                FUN_00406f3c(param_1,param_2,0x1d,1,0,local_7c,-1);
                FUN_004022d0(local_c);
                FUN_00403ecc(piVar5,3);
                FUN_004022d0(local_14);
                FUN_00403ecc(piVar6,3);
                if (local_1c != (int *)0x0) {
                  (**(code **)*local_1c)(local_1c,3);
                }
                FUN_004022d0(local_28);
                FUN_00403ecc(piVar7,3);
                uVar12 = *local_2c;
                FUN_00403310(local_7c,2);
                FUN_00403310(local_44,2);
                return uVar12;
              }
              FUN_004dbb24(&DAT_00524e20,(char *)local_28,(char *)0x0);
              FUN_004dbb24(&DAT_00524e20,s_is_empty_or_missing__0050ce7a,(char *)0x0);
              FUN_004022e8(local_28);
              FUN_00403ecc(piVar7,3);
              FUN_00403310(local_44,2);
              goto LAB_004a4814;
            }
            FUN_004dbb24(&DAT_00524e20,s_DZoneCount____damage_zones_found_0050ce04,(char *)0x0);
            FUN_004d9c38(&DAT_00524e20);
          }
          FUN_004022d0(local_c);
          FUN_00403ecc(piVar5,3);
          FUN_004022d0(local_14);
          FUN_00403ecc(piVar6,3);
          uVar12 = 0xffffffff;
          FUN_00403310(local_44,2);
          return uVar12;
        }
        FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_is_missing_DZoneCount_0050cdb6,(char *)0x0);
      }
      FUN_004022e8(local_14);
      FUN_00403ecc(piVar6,3);
    }
  }
LAB_004a4814:
  FUN_004022e8(local_c);
  FUN_00403ecc(piVar5,3);
  return 0xffffffff;
}



/* @004a4c54 file=? name=FUN_004a4c54 */

void __cdecl FUN_004a4c54(int param_1,ushort param_2)

{
  int iVar1;
  
  iVar1 = FUN_0049fb54(param_1);
  if (iVar1 != 0) {
    param_2 = param_2 & 0xfe03;
  }
  *(ushort *)(param_1 + 0x18) = *(ushort *)(param_1 + 0x18) | param_2;
  return;
}



/* @004a4c7c file=? name=FUN_004a4c7c */

void __cdecl FUN_004a4c7c(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50bdb4);
  return;
}



/* @004a4d60 file=? name=FUN_004a4d60 */

undefined4 * __cdecl FUN_004a4d60(undefined4 *param_1,undefined4 param_2)

{
  FUN_0041827c(param_1,param_2);
  *param_1 = &PTR_FUN_0050cfa0;
  return param_1;
}



/* @004a4d7f file=? name=FUN_004a4d7f */

void __cdecl FUN_004a4d7f(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cfa0;
    FUN_004182a8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4dab file=? name=FUN_004a4dab */

undefined4 * __cdecl FUN_004a4dab(undefined4 *param_1,undefined4 param_2)

{
  FUN_00417be0(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf98;
  return param_1;
}



/* @004a4dca file=? name=FUN_004a4dca */

void __cdecl FUN_004a4dca(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cf98;
    FUN_00417c0c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4df6 file=? name=FUN_004a4df6 */

undefined4 * __cdecl FUN_004a4df6(undefined4 *param_1,undefined4 param_2)

{
  FUN_00417be0(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf90;
  return param_1;
}



/* @004a4e15 file=? name=FUN_004a4e15 */

void __cdecl FUN_004a4e15(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cf90;
    FUN_00417c0c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4e41 file=? name=FUN_004a4e41 */

undefined4 * __cdecl FUN_004a4e41(undefined4 *param_1,undefined4 param_2)

{
  FUN_00417be0(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf88;
  return param_1;
}



/* @004a4e60 file=? name=FUN_004a4e60 */

void __cdecl FUN_004a4e60(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cf88;
    FUN_00417c0c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4e8c file=? name=FUN_004a4e8c */

undefined4 * __cdecl FUN_004a4e8c(undefined4 *param_1,int param_2)

{
  FUN_00418398(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf34;
  return param_1;
}



/* @004a4eab file=? name=FUN_004a4eab */

undefined4 * __cdecl FUN_004a4eab(undefined4 *param_1,int param_2)

{
  FUN_00418398(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf34;
  return param_1;
}



/* @004a4eca file=? name=FUN_004a4eca */

undefined4 * __cdecl FUN_004a4eca(undefined4 *param_1,int param_2)

{
  FUN_004183c0(param_1,param_2);
  *param_1 = &PTR_FUN_0050cf34;
  return param_1;
}



/* @004a4ee9 file=? name=FUN_004a4ee9 */

void __cdecl FUN_004a4ee9(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cf34;
    FUN_004183ec(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4f15 file=? name=FUN_004a4f15 */

undefined4 * __cdecl FUN_004a4f15(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050cee4;
  return param_1;
}



/* @004a4f34 file=? name=FUN_004a4f34 */

undefined4 * __cdecl FUN_004a4f34(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050cee4;
  return param_1;
}



/* @004a4f53 file=? name=FUN_004a4f53 */

undefined4 * __cdecl FUN_004a4f53(undefined4 *param_1,int param_2)

{
  FUN_00417d28(param_1,param_2);
  *param_1 = &PTR_FUN_0050cee4;
  return param_1;
}



/* @004a4f72 file=? name=FUN_004a4f72 */

void __cdecl FUN_004a4f72(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050cee4;
    FUN_00417d54(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a4f9e file=? name=FUN_004a4f9e */

undefined4 * __cdecl FUN_004a4f9e(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050ce94;
  return param_1;
}



/* @004a4fbd file=? name=FUN_004a4fbd */

undefined4 * __cdecl FUN_004a4fbd(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050ce94;
  return param_1;
}



/* @004a4fdc file=? name=FUN_004a4fdc */

undefined4 * __cdecl FUN_004a4fdc(undefined4 *param_1,int param_2)

{
  FUN_00417d28(param_1,param_2);
  *param_1 = &PTR_FUN_0050ce94;
  return param_1;
}



/* @004a4ffb file=? name=FUN_004a4ffb */

void __cdecl FUN_004a4ffb(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050ce94;
    FUN_00417d54(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004a5028 file=bt/mech2.cpp name=FUN_004a5028 */

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

float10 __cdecl FUN_004a5028(int param_1,float param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  float fVar4;
  float10 fVar5;
  float local_8;
  
  iVar2 = **(int **)(param_1 + 0x128);
  iVar3 = *(int *)(param_1 + 0x40);
  if (*(int *)(param_1 + 0x650) == 0) {
    if (iVar3 == 5) {
      FUN_004a7fc4(param_1,0x1c);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar3 == 6) {
      FUN_004a7fc4(param_1,0x1d);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar3 == 7) {
      FUN_004a7fc4(param_1,0x1e);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar3 == 8) {
      FUN_004a7fc4(param_1,0x1f);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
  }
  iVar3 = *(int *)(param_1 + 0x3b0);
  if ((*(float *)(param_1 + 0x348) <= _DAT_004a5674) &&
     ((((iVar3 == 6 || (iVar3 == 7)) || (iVar3 == 8)) || (iVar3 == 9)))) {
    FUN_0041bbd8(param_1 + 0x39c,0);
    *(undefined4 *)(param_1 + 0x654) = 1;
  }
  switch(*(undefined4 *)(param_1 + 0x3b0)) {
  case 0:
    if (*(float *)(param_1 + 0x530) < *(float *)(iVar2 + 0x128)) {
      FUN_004a7fc4(param_1,5);
    }
    else {
      local_8 = 0.0;
      if (_DAT_004a5674 <= *(float *)(iVar2 + 0x128)) break;
      FUN_004a7fc4(param_1,0x10);
    }
  case 2:
  case 3:
  case 5:
  case 8:
  case 9:
  case 10:
  case 0xb:
  case 0xe:
  case 0xf:
  case 0x10:
  case 0x11:
  case 0x14:
  case 0x15:
  case 0x1c:
  case 0x1d:
  case 0x1e:
  case 0x1f:
  case 0x20:
switchD_004a510d_caseD_2:
    if (*(int *)(param_1 + 0x3b0) == 0) {
      FUN_0040385c(s_Standing_Not_Supported_0050d7cd,s_d__tesla_bt_bt_MECH2_CPP_0050d7e4,0xd3);
    }
    fVar5 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * *(float *)(param_1 + 0x5a8) * *(float *)(param_1 + 0x5ac),1);
    local_8 = (float)fVar5;
    *(float *)(param_1 + 0x348) = local_8 / param_2;
    break;
  case 1:
    local_8 = 0.0;
    break;
  case 4:
    if (*(float *)(param_1 + 0x530) < *(float *)(iVar2 + 0x128)) {
      FUN_0041bbd8(param_1 + 0x39c,0);
      FUN_004a4c54(param_1,8);
      break;
    }
    local_8 = 0.0;
    if (*(float *)(iVar2 + 0x128) < _DAT_004a5674) {
      FUN_0041bbd8(param_1 + 0x39c,0);
      FUN_004a4c54(param_1,8);
      break;
    }
    goto switchD_004a510d_caseD_2;
  case 6:
  case 7:
    if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar2 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar2 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x530) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x530);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar2 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar2 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x534)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x534);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar5 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * (*(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x534)) *
                         *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar5;
    break;
  case 0xc:
  case 0xd:
    if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar2 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar2 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x538) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x538);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar2 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar2 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x7a0)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x7a0);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar5 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * (*(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x34c)) *
                         *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar5;
    break;
  case 0x12:
  case 0x13:
    if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar2 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x5b0) * param_2;
        if (*(float *)(iVar2 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar2 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x350) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x350);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x5b0) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar2 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar2 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x52c)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x52c);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar4 = *(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x350);
    if (fVar4 <= _DAT_004a5674) {
      fVar4 = -fVar4;
    }
    fVar5 = FUN_0042790c(param_1 + 0x65c,fVar4 * param_2 * *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar5;
    break;
  case 0x16:
  case 0x17:
  case 0x18:
  case 0x19:
  case 0x1a:
  case 0x1b:
    FUN_00408440((undefined4 *)(param_1 + 0x598),&DAT_004e0f74);
    *(undefined4 *)(param_1 + 0x5a4) = 0;
    *(undefined4 *)(param_1 + 0x654) = 0;
    *(undefined4 *)(param_1 + 0x650) = 0;
    FUN_0041bbd8(param_1 + 0x39c,0);
    FUN_004283b8(param_1 + 0x65c,1);
    break;
  default:
    FUN_004dbb24(&DAT_00524e20,s_StandingAnimation_0050cfe8 + *(int *)(param_1 + 0x3b0) * 0x3c,
                 (char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_0040385c(s_Unsupported_mech_animation__0050d7fd,s_d__tesla_bt_bt_MECH2_CPP_0050d81a,0x13b);
  }
  return (float10)local_8;
}



/* @004a5678 file=bt/mech2.cpp name=FUN_004a5678 */

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

float10 __cdecl FUN_004a5678(int param_1,float param_2,int param_3)

{
  undefined4 uVar1;
  int iVar2;
  float fVar3;
  float10 fVar4;
  float local_8;
  
  iVar2 = *(int *)(param_1 + 0x40);
  if (*(int *)(param_1 + 0x650) == 0) {
    if (iVar2 == 5) {
      FUN_004a800c(param_1,0x1c);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar2 == 6) {
      FUN_004a800c(param_1,0x1d);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar2 == 7) {
      FUN_004a800c(param_1,0x1e);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
    else if (iVar2 == 8) {
      FUN_004a800c(param_1,0x1f);
      *(undefined4 *)(param_1 + 0x650) = 1;
    }
  }
  switch(*(undefined4 *)(param_1 + 0x728)) {
  case 0:
    local_8 = 0.0;
    if (*(float *)(param_1 + 0x530) < *(float *)(param_1 + 0x6b4)) {
      FUN_004a800c(param_1,5);
    }
    else {
      if (_DAT_004a5bf4 <= *(float *)(param_1 + 0x6b4)) break;
      FUN_004a800c(param_1,0x10);
    }
  case 2:
  case 3:
  case 4:
  case 5:
  case 8:
  case 9:
  case 10:
  case 0xb:
  case 0xe:
  case 0xf:
  case 0x10:
  case 0x11:
  case 0x14:
  case 0x15:
  case 0x1c:
  case 0x1d:
  case 0x1e:
  case 0x1f:
  case 0x20:
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * *(float *)(param_1 + 0x5a8) * *(float *)(param_1 + 0x5ac),param_3
                        );
    local_8 = (float)fVar4;
    *(float *)(param_1 + 0x6b8) = local_8 / param_2;
    break;
  case 1:
    local_8 = 0.0;
    break;
  case 6:
  case 7:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x530) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x530);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x534)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x534);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * (*(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x534)) *
                         *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0xc:
  case 0xd:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x538) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x538);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x7a0)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x7a0);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * (*(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x34c)) *
                         *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0x12:
  case 0x13:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x5b0) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x350) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x350);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x5b0) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x52c)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x52c);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar3 = *(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x350);
    if (fVar3 <= _DAT_004a5bf4) {
      fVar3 = -fVar3;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,fVar3 * param_2 * *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0x16:
  case 0x17:
  case 0x18:
  case 0x19:
  case 0x1a:
  case 0x1b:
    FUN_00408440((undefined4 *)(param_1 + 0x598),&DAT_004e0f74);
    *(undefined4 *)(param_1 + 0x5a4) = 0;
    *(undefined4 *)(param_1 + 0x658) = 0;
    *(undefined4 *)(param_1 + 0x650) = 0;
    FUN_0041bbd8(param_1 + 0x714,0);
    FUN_004283b8(param_1 + 0x6bc,param_3);
    break;
  default:
    FUN_004dbb24(&DAT_00524e20,s_StandingAnimation_0050cfe8 + *(int *)(param_1 + 0x728) * 0x3c,
                 (char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_0040385c(s_Unsupported_mech_animation__0050d833,s_d__tesla_bt_bt_MECH2_CPP_0050d850,0x206);
  }
  return (float10)local_8;
}



/* @004a5bf8 file=bt/mech2.cpp name=FUN_004a5bf8 */

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

float10 __cdecl FUN_004a5bf8(int param_1,float param_2,int param_3)

{
  undefined4 uVar1;
  int iVar2;
  float fVar3;
  float10 fVar4;
  float local_c;
  float local_8;
  
  iVar2 = *(int *)(param_1 + 0x728);
  if (((iVar2 - 6U < 2) || (iVar2 - 0xcU < 2)) || (iVar2 - 0x12U < 2)) {
    if (*(int *)(param_1 + 0x40) == 3) {
      if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x53c)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x53c);
      }
      *(undefined4 *)(param_1 + 0x6b4) = uVar1;
    }
    else {
      if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x540)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x540);
      }
      *(undefined4 *)(param_1 + 0x6b4) = uVar1;
    }
    fVar3 = _DAT_004a6340;
    if (_DAT_004a6340 <= *(float *)(param_1 + 0x6b4)) {
      fVar3 = *(float *)(param_1 + 0x6b4);
    }
    *(float *)(param_1 + 0x6b4) = fVar3;
  }
  switch(*(undefined4 *)(param_1 + 0x728)) {
  case 0:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x530)) {
      local_8 = 0.0;
      break;
    }
    FUN_004a800c(param_1,5);
  case 2:
  case 3:
  case 4:
  case 5:
  case 8:
  case 9:
  case 10:
  case 0xb:
  case 0xe:
  case 0xf:
  case 0x10:
  case 0x11:
  case 0x14:
  case 0x15:
  case 0x16:
  case 0x17:
  case 0x1a:
  case 0x1b:
  case 0x20:
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * *(float *)(param_1 + 0x5a8) * *(float *)(param_1 + 0x5ac),param_3
                        );
    local_8 = (float)fVar4;
    *(float *)(param_1 + 0x6b8) = local_8 / param_2;
    break;
  case 1:
    local_8 = 0.0;
    break;
  case 6:
  case 7:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x530) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x530);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x534)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x534);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * (*(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x534)) *
                         *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0xc:
  case 0xd:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x538) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x538);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x7a0)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x7a0);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,
                         param_2 * (*(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x34c)) *
                         *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0x12:
  case 0x13:
    if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
      if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x5b0) * param_2;
        if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x350) <= *(float *)(param_1 + 0x6b8)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x350);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x6b8) =
           *(float *)(param_1 + 0x5b0) * param_2 + *(float *)(param_1 + 0x6b8);
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x6b4);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x52c)) {
        uVar1 = *(undefined4 *)(param_1 + 0x6b8);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x52c);
      }
      *(undefined4 *)(param_1 + 0x6b8) = uVar1;
    }
    fVar3 = *(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x350);
    if (fVar3 <= _DAT_004a6340) {
      fVar3 = -fVar3;
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,fVar3 * param_2 * *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  case 0x18:
  case 0x19:
    if (*(int *)(param_1 + 0x40) == 3) {
      if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
        if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
          *(float *)(param_1 + 0x6b8) =
               *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
          if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
            uVar1 = *(undefined4 *)(param_1 + 0x6b8);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x6b4);
          }
          *(undefined4 *)(param_1 + 0x6b8) = uVar1;
          if (*(float *)(param_1 + 0x53c) <= *(float *)(param_1 + 0x6b8)) {
            uVar1 = *(undefined4 *)(param_1 + 0x6b8);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x53c);
          }
          *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        }
      }
      else {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
        if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x544)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x544);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
      local_c = *(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x544);
    }
    else {
      if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
        if (*(float *)(param_1 + 0x6b4) < *(float *)(param_1 + 0x6b8)) {
          *(float *)(param_1 + 0x6b8) =
               *(float *)(param_1 + 0x6b8) - *(float *)(param_1 + 0x344) * param_2;
          if (*(float *)(param_1 + 0x6b4) <= *(float *)(param_1 + 0x6b8)) {
            uVar1 = *(undefined4 *)(param_1 + 0x6b8);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x6b4);
          }
          *(undefined4 *)(param_1 + 0x6b8) = uVar1;
          if (*(float *)(param_1 + 0x540) <= *(float *)(param_1 + 0x6b8)) {
            uVar1 = *(undefined4 *)(param_1 + 0x6b8);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x540);
          }
          *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        }
      }
      else {
        *(float *)(param_1 + 0x6b8) =
             *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x6b8);
        if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x6b4)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x6b4);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
        if (*(float *)(param_1 + 0x6b8) <= *(float *)(param_1 + 0x548)) {
          uVar1 = *(undefined4 *)(param_1 + 0x6b8);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x548);
        }
        *(undefined4 *)(param_1 + 0x6b8) = uVar1;
      }
      local_c = *(float *)(param_1 + 0x6b8) / *(float *)(param_1 + 0x548);
    }
    fVar4 = FUN_0042790c(param_1 + 0x6bc,param_2 * local_c * *(float *)(param_1 + 0x5a8),param_3);
    local_8 = (float)fVar4;
    break;
  default:
    FUN_004dbb24(&DAT_00524e20,s_StandingAnimation_0050cfe8 + *(int *)(param_1 + 0x728) * 0x3c,
                 (char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_0040385c(s_Unsupported_mech_animation__0050d869,s_d__tesla_bt_bt_MECH2_CPP_0050d886,0x2e8);
  }
  return (float10)local_8;
}



/* @004a6344 file=? name=FUN_004a6344 */

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

float10 __thiscall
FUN_004a6344(int param_1,int param_2,undefined4 param_3,float param_4,int param_5)

{
  undefined4 uVar1;
  int iVar2;
  float fVar3;
  int iVar4;
  float10 fVar5;
  float local_8;
  
  local_8 = 0.0;
  iVar4 = *(int *)(param_2 + 0x40);
  iVar2 = *(int *)(param_2 + 0x728);
  if (((iVar2 - 6U < 2) || (iVar2 - 0xcU < 2)) || (iVar2 - 0x12U < 2)) {
    if (iVar4 == 3) {
      if (*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x53c)) {
        uVar1 = *(undefined4 *)(param_2 + 0x6b4);
      }
      else {
        uVar1 = *(undefined4 *)(param_2 + 0x53c);
      }
      *(undefined4 *)(param_2 + 0x6b4) = uVar1;
    }
    else {
      if (*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x540)) {
        uVar1 = *(undefined4 *)(param_2 + 0x6b4);
      }
      else {
        uVar1 = *(undefined4 *)(param_2 + 0x540);
      }
      *(undefined4 *)(param_2 + 0x6b4) = uVar1;
    }
    fVar3 = _DAT_004a6924;
    if (_DAT_004a6924 <= *(float *)(param_2 + 0x6b4)) {
      fVar3 = *(float *)(param_2 + 0x6b4);
    }
    *(float *)(param_2 + 0x6b4) = fVar3;
  }
  switch(*(undefined4 *)(param_2 + 0x728)) {
  default:
    goto switchD_004a63ff_caseD_0;
  case 2:
    FUN_0041bbd8(param_2 + 0x714,1);
    goto switchD_004a63ff_caseD_0;
  case 3:
  case 8:
  case 9:
  case 0x14:
  case 0x15:
  case 0x1a:
  case 0x1b:
    FUN_0041bbd8(param_2 + 0x714,0);
    goto switchD_004a63ff_caseD_0;
  case 4:
    FUN_0041bbd8(param_2 + 0x714,0);
    goto switchD_004a63ff_caseD_0;
  case 5:
  case 6:
  case 0xe:
    if ((*(float *)(param_2 + 0x530) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x530) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      if ((*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x534)) ||
         (*(float *)(param_2 + 0x344) * param_4 + *(float *)(param_2 + 0x6b8) <=
          *(float *)(param_2 + 0x534))) {
        if (iVar4 == 4) {
          param_1 = 7;
        }
        if (iVar4 == 3) {
          param_1 = 0x16;
        }
LAB_004a6505:
        FUN_004a800c(param_2,param_1);
        fVar5 = FUN_0042790c(param_2 + 0x6bc,
                             (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                             *(float *)(param_2 + 0x534),param_5);
        local_8 = (float)fVar5;
        goto switchD_004a63ff_caseD_0;
      }
      iVar4 = 0xb;
    }
    else {
      iVar4 = 9;
    }
    break;
  case 7:
  case 0xf:
    if ((*(float *)(param_2 + 0x530) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x530) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      if ((*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x534)) ||
         (*(float *)(param_2 + 0x344) * param_4 + *(float *)(param_2 + 0x6b8) <=
          *(float *)(param_2 + 0x534))) {
        if (iVar4 == 3) {
          param_1 = 6;
        }
        if (iVar4 == 4) {
          param_1 = 0x17;
        }
        goto LAB_004a6505;
      }
      iVar4 = 10;
    }
    else {
      iVar4 = 8;
    }
    break;
  case 10:
  case 0xc:
    if ((*(float *)(param_2 + 0x538) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x538) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      iVar4 = 0xd;
LAB_004a6648:
      FUN_004a800c(param_2,iVar4);
      fVar5 = FUN_0042790c(param_2 + 0x6bc,
                           (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                           *(float *)(param_2 + 0x34c),param_5);
      local_8 = (float)fVar5;
      goto switchD_004a63ff_caseD_0;
    }
    iVar4 = 0xf;
    break;
  case 0xb:
  case 0xd:
    if ((*(float *)(param_2 + 0x538) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x538) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      iVar4 = 0xc;
      goto LAB_004a6648;
    }
    iVar4 = 0xe;
    break;
  case 0x10:
  case 0x12:
    if ((*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x52c)) ||
       (*(float *)(param_2 + 0x5b0) * param_4 + *(float *)(param_2 + 0x6b8) <=
        *(float *)(param_2 + 0x52c))) {
      FUN_004a800c(param_2,0x13);
      if ((param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
          *(float *)(param_2 + 0x350) <= _DAT_004a6924) {
        fVar3 = (-param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                *(float *)(param_2 + 0x350);
      }
      else {
        fVar3 = (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                *(float *)(param_2 + 0x350);
      }
      fVar5 = FUN_0042790c(param_2 + 0x6bc,fVar3,param_5);
      local_8 = (float)fVar5;
      goto switchD_004a63ff_caseD_0;
    }
    iVar4 = 0x15;
    break;
  case 0x11:
  case 0x13:
    if ((*(float *)(param_2 + 0x6b4) <= *(float *)(param_2 + 0x52c)) ||
       (*(float *)(param_2 + 0x5b0) * param_4 + *(float *)(param_2 + 0x6b8) <=
        *(float *)(param_2 + 0x52c))) {
      FUN_004a800c(param_2,0x12);
      if ((param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
          *(float *)(param_2 + 0x350) <= _DAT_004a6924) {
        fVar3 = (-param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                *(float *)(param_2 + 0x350);
      }
      else {
        fVar3 = (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                *(float *)(param_2 + 0x350);
      }
      fVar5 = FUN_0042790c(param_2 + 0x6bc,fVar3,param_5);
      local_8 = (float)fVar5;
      goto switchD_004a63ff_caseD_0;
    }
    iVar4 = 0x14;
    break;
  case 0x16:
  case 0x18:
    if ((*(float *)(param_2 + 0x53c) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x53c) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      FUN_004a800c(param_2,0x18);
      fVar5 = FUN_0042790c(param_2 + 0x6bc,
                           (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                           *(float *)(param_2 + 0x544),param_5);
      local_8 = (float)fVar5;
      goto switchD_004a63ff_caseD_0;
    }
    iVar4 = 0x1a;
    break;
  case 0x17:
  case 0x19:
    if ((*(float *)(param_2 + 0x540) <= *(float *)(param_2 + 0x6b4)) ||
       (*(float *)(param_2 + 0x540) <=
        *(float *)(param_2 + 0x6b8) - *(float *)(param_2 + 0x344) * param_4)) {
      FUN_004a800c(param_2,0x19);
      fVar5 = FUN_0042790c(param_2 + 0x6bc,
                           (param_4 * *(float *)(param_2 + 0x6b8) * *(float *)(param_2 + 0x5a8)) /
                           *(float *)(param_2 + 0x548),param_5);
      local_8 = (float)fVar5;
      goto switchD_004a63ff_caseD_0;
    }
    iVar4 = 0x1b;
    break;
  case 0x20:
    FUN_0041bbd8(param_2 + 0x714,0);
    goto switchD_004a63ff_caseD_0;
  }
  FUN_004a800c(param_2,iVar4);
  fVar5 = FUN_0042790c(param_2 + 0x6bc,param_4 * *(float *)(param_2 + 0x5a8),param_5);
  local_8 = (float)fVar5;
switchD_004a63ff_caseD_0:
  return (float10)local_8;
}



/* @004a71f4 file=bt/mech2.cpp name=FUN_004a71f4 */

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

float10 __cdecl FUN_004a71f4(int param_1,float param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  float fVar5;
  float10 fVar6;
  float local_c;
  float local_8;
  
  iVar2 = *(int *)(param_1 + 0x40);
  iVar3 = **(int **)(param_1 + 0x128);
  iVar4 = *(int *)(param_1 + 0x3b0);
  if (((iVar4 - 6U < 2) || (iVar4 - 0xcU < 2)) || (iVar4 - 0x12U < 2)) {
    if (iVar2 == 3) {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x53c)) {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x53c);
      }
      *(undefined4 *)(iVar3 + 0x128) = uVar1;
    }
    else {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x540)) {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x540);
      }
      *(undefined4 *)(iVar3 + 0x128) = uVar1;
    }
    fVar5 = _DAT_004a796c;
    if (_DAT_004a796c <= *(float *)(iVar3 + 0x128)) {
      fVar5 = *(float *)(iVar3 + 0x128);
    }
    *(float *)(iVar3 + 0x128) = fVar5;
  }
  switch(*(undefined4 *)(param_1 + 0x3b0)) {
  case 0:
    if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x530)) {
      local_8 = 0.0;
      break;
    }
    FUN_004a7fc4(param_1,5);
  case 2:
  case 3:
  case 5:
  case 8:
  case 9:
  case 10:
  case 0xb:
  case 0xe:
  case 0xf:
  case 0x10:
  case 0x11:
  case 0x14:
  case 0x15:
  case 0x16:
  case 0x17:
  case 0x1a:
  case 0x1b:
  case 0x20:
switchD_004a72b4_caseD_2:
    fVar6 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * *(float *)(param_1 + 0x5a8) * *(float *)(param_1 + 0x5ac),1);
    local_8 = (float)fVar6;
    *(float *)(param_1 + 0x348) = local_8 / param_2;
    break;
  case 1:
    local_8 = 0.0;
    break;
  case 4:
    if (*(float *)(param_1 + 0x530) < *(float *)(iVar3 + 0x128)) {
      FUN_0041bbd8(param_1 + 0x39c,0);
      FUN_004a4c54(param_1,8);
      break;
    }
    goto switchD_004a72b4_caseD_2;
  case 6:
  case 7:
    if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar3 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar3 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x530) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x530);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar3 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x534)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x534);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar6 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * (*(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x534)) *
                         *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar6;
    break;
  case 0xc:
  case 0xd:
    if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar3 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
        if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar3 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x538) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x538);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar3 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x7a0)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x7a0);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar6 = FUN_0042790c(param_1 + 0x65c,
                         param_2 * (*(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x34c)) *
                         *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar6;
    break;
  case 0x12:
  case 0x13:
    if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
      if (*(float *)(iVar3 + 0x128) < *(float *)(param_1 + 0x348)) {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x5b0) * param_2;
        if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar3 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x350) <= *(float *)(param_1 + 0x348)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x350);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
    }
    else {
      *(float *)(param_1 + 0x348) =
           *(float *)(param_1 + 0x5b0) * param_2 + *(float *)(param_1 + 0x348);
      if (*(float *)(param_1 + 0x348) <= *(float *)(iVar3 + 0x128)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
      if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x52c)) {
        uVar1 = *(undefined4 *)(param_1 + 0x348);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x52c);
      }
      *(undefined4 *)(param_1 + 0x348) = uVar1;
    }
    fVar5 = *(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x350);
    if (fVar5 <= _DAT_004a796c) {
      fVar5 = -fVar5;
    }
    fVar6 = FUN_0042790c(param_1 + 0x65c,fVar5 * param_2 * *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar6;
    break;
  case 0x18:
  case 0x19:
    if (iVar2 == 3) {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
        if (*(float *)(iVar3 + 0x128) < *(float *)(param_1 + 0x348)) {
          *(float *)(param_1 + 0x348) =
               *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
          if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
            uVar1 = *(undefined4 *)(param_1 + 0x348);
          }
          else {
            uVar1 = *(undefined4 *)(iVar3 + 0x128);
          }
          *(undefined4 *)(param_1 + 0x348) = uVar1;
          if (*(float *)(param_1 + 0x53c) <= *(float *)(param_1 + 0x348)) {
            uVar1 = *(undefined4 *)(param_1 + 0x348);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x53c);
          }
          *(undefined4 *)(param_1 + 0x348) = uVar1;
        }
      }
      else {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
        if (*(float *)(param_1 + 0x348) <= *(float *)(iVar3 + 0x128)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar3 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x544)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x544);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
      local_c = *(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x544);
    }
    else {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
        if (*(float *)(iVar3 + 0x128) < *(float *)(param_1 + 0x348)) {
          *(float *)(param_1 + 0x348) =
               *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_2;
          if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x348)) {
            uVar1 = *(undefined4 *)(param_1 + 0x348);
          }
          else {
            uVar1 = *(undefined4 *)(iVar3 + 0x128);
          }
          *(undefined4 *)(param_1 + 0x348) = uVar1;
          if (*(float *)(param_1 + 0x540) <= *(float *)(param_1 + 0x348)) {
            uVar1 = *(undefined4 *)(param_1 + 0x348);
          }
          else {
            uVar1 = *(undefined4 *)(param_1 + 0x540);
          }
          *(undefined4 *)(param_1 + 0x348) = uVar1;
        }
      }
      else {
        *(float *)(param_1 + 0x348) =
             *(float *)(param_1 + 0x344) * param_2 + *(float *)(param_1 + 0x348);
        if (*(float *)(param_1 + 0x348) <= *(float *)(iVar3 + 0x128)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(iVar3 + 0x128);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
        if (*(float *)(param_1 + 0x348) <= *(float *)(param_1 + 0x548)) {
          uVar1 = *(undefined4 *)(param_1 + 0x348);
        }
        else {
          uVar1 = *(undefined4 *)(param_1 + 0x548);
        }
        *(undefined4 *)(param_1 + 0x348) = uVar1;
      }
      local_c = *(float *)(param_1 + 0x348) / *(float *)(param_1 + 0x548);
    }
    fVar6 = FUN_0042790c(param_1 + 0x65c,param_2 * local_c * *(float *)(param_1 + 0x5a8),1);
    local_8 = (float)fVar6;
    break;
  default:
    FUN_004dbb24(&DAT_00524e20,s_StandingAnimation_0050cfe8 + *(int *)(param_1 + 0x3b0) * 0x3c,
                 (char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    FUN_0040385c(s_Unsupported_mech_animation__0050d89f,s_d__tesla_bt_bt_MECH2_CPP_0050d8bc,0x672);
  }
  return (float10)local_8;
}



/* @004a7970 file=? name=FUN_004a7970 */

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

float10 __cdecl FUN_004a7970(int param_1,undefined4 param_2,float param_3)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  float fVar4;
  int unaff_ESI;
  int iVar5;
  float10 fVar6;
  float local_8;
  
  local_8 = 0.0;
  iVar5 = *(int *)(param_1 + 0x3b0);
  iVar2 = *(int *)(param_1 + 0x40);
  iVar3 = **(int **)(param_1 + 0x128);
  if (((iVar5 - 6U < 2) || (iVar5 - 0xcU < 2)) || (iVar5 - 0x12U < 2)) {
    if (iVar2 == 3) {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x53c)) {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x53c);
      }
      *(undefined4 *)(iVar3 + 0x128) = uVar1;
    }
    else {
      if (*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x540)) {
        uVar1 = *(undefined4 *)(iVar3 + 0x128);
      }
      else {
        uVar1 = *(undefined4 *)(param_1 + 0x540);
      }
      *(undefined4 *)(iVar3 + 0x128) = uVar1;
    }
    fVar4 = _DAT_004a7f4c;
    if (_DAT_004a7f4c <= *(float *)(iVar3 + 0x128)) {
      fVar4 = *(float *)(iVar3 + 0x128);
    }
    *(float *)(iVar3 + 0x128) = fVar4;
  }
  switch(*(undefined4 *)(param_1 + 0x3b0)) {
  default:
    goto switchD_004a7a34_caseD_0;
  case 2:
    FUN_0041bbd8(param_1 + 0x39c,1);
    goto switchD_004a7a34_caseD_0;
  case 3:
  case 8:
  case 9:
  case 0x14:
  case 0x15:
  case 0x1a:
  case 0x1b:
    FUN_0041bbd8(param_1 + 0x39c,0);
    goto switchD_004a7a34_caseD_0;
  case 4:
    FUN_0041bbd8(param_1 + 0x39c,0);
    goto switchD_004a7a34_caseD_0;
  case 5:
  case 6:
  case 0xe:
    if ((*(float *)(param_1 + 0x530) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x530) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      if ((*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x534)) ||
         (*(float *)(param_1 + 0x344) * param_3 + *(float *)(param_1 + 0x348) <=
          *(float *)(param_1 + 0x534))) {
        if (iVar2 == 4) {
          unaff_ESI = 7;
        }
        if (iVar2 == 3) {
          unaff_ESI = 0x16;
        }
LAB_004a7b38:
        FUN_004a7fc4(param_1,unaff_ESI);
        fVar6 = FUN_0042790c(param_1 + 0x65c,
                             (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                             *(float *)(param_1 + 0x534),1);
        local_8 = (float)fVar6;
        goto switchD_004a7a34_caseD_0;
      }
      iVar5 = 0xb;
    }
    else {
      iVar5 = 9;
    }
    break;
  case 7:
  case 0xf:
    if ((*(float *)(param_1 + 0x530) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x530) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      if ((*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x534)) ||
         (*(float *)(param_1 + 0x344) * param_3 + *(float *)(param_1 + 0x348) <=
          *(float *)(param_1 + 0x534))) {
        if (iVar2 == 3) {
          unaff_ESI = 6;
        }
        if (iVar2 == 4) {
          unaff_ESI = 0x17;
        }
        goto LAB_004a7b38;
      }
      iVar5 = 10;
    }
    else {
      iVar5 = 8;
    }
    break;
  case 10:
  case 0xc:
    if ((*(float *)(param_1 + 0x538) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x538) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      iVar5 = 0xd;
LAB_004a7c79:
      FUN_004a7fc4(param_1,iVar5);
      fVar6 = FUN_0042790c(param_1 + 0x65c,
                           (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                           *(float *)(param_1 + 0x34c),1);
      local_8 = (float)fVar6;
      goto switchD_004a7a34_caseD_0;
    }
    iVar5 = 0xf;
    break;
  case 0xb:
  case 0xd:
    if ((*(float *)(param_1 + 0x538) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x538) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      iVar5 = 0xc;
      goto LAB_004a7c79;
    }
    iVar5 = 0xe;
    break;
  case 0x10:
  case 0x12:
    if ((*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x52c)) ||
       (*(float *)(param_1 + 0x5b0) * param_3 + *(float *)(param_1 + 0x348) <=
        *(float *)(param_1 + 0x52c))) {
      FUN_004a7fc4(param_1,0x13);
      if ((param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
          *(float *)(param_1 + 0x350) <= _DAT_004a7f4c) {
        fVar4 = (-param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                *(float *)(param_1 + 0x350);
      }
      else {
        fVar4 = (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                *(float *)(param_1 + 0x350);
      }
      fVar6 = FUN_0042790c(param_1 + 0x65c,fVar4,1);
      local_8 = (float)fVar6;
      goto switchD_004a7a34_caseD_0;
    }
    iVar5 = 0x15;
    break;
  case 0x11:
  case 0x13:
    if ((*(float *)(iVar3 + 0x128) <= *(float *)(param_1 + 0x52c)) ||
       (*(float *)(param_1 + 0x5b0) * param_3 + *(float *)(param_1 + 0x348) <=
        *(float *)(param_1 + 0x52c))) {
      FUN_004a7fc4(param_1,0x12);
      if ((param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
          *(float *)(param_1 + 0x350) <= _DAT_004a7f4c) {
        fVar4 = (-param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                *(float *)(param_1 + 0x350);
      }
      else {
        fVar4 = (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                *(float *)(param_1 + 0x350);
      }
      fVar6 = FUN_0042790c(param_1 + 0x65c,fVar4,1);
      local_8 = (float)fVar6;
      goto switchD_004a7a34_caseD_0;
    }
    iVar5 = 0x14;
    break;
  case 0x16:
  case 0x18:
    if ((*(float *)(param_1 + 0x53c) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x53c) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      FUN_004a7fc4(param_1,0x18);
      fVar6 = FUN_0042790c(param_1 + 0x65c,
                           (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                           *(float *)(param_1 + 0x544),1);
      local_8 = (float)fVar6;
      goto switchD_004a7a34_caseD_0;
    }
    iVar5 = 0x1a;
    break;
  case 0x17:
  case 0x19:
    if ((*(float *)(param_1 + 0x540) <= *(float *)(iVar3 + 0x128)) ||
       (*(float *)(param_1 + 0x540) <=
        *(float *)(param_1 + 0x348) - *(float *)(param_1 + 0x344) * param_3)) {
      FUN_004a7fc4(param_1,0x19);
      fVar6 = FUN_0042790c(param_1 + 0x65c,
                           (param_3 * *(float *)(param_1 + 0x348) * *(float *)(param_1 + 0x5a8)) /
                           *(float *)(param_1 + 0x548),1);
      local_8 = (float)fVar6;
      goto switchD_004a7a34_caseD_0;
    }
    iVar5 = 0x1b;
    break;
  case 0x20:
    FUN_0041bbd8(param_1 + 0x39c,0);
    goto switchD_004a7a34_caseD_0;
  }
  FUN_004a7fc4(param_1,iVar5);
  fVar6 = FUN_0042790c(param_1 + 0x65c,param_3 * *(float *)(param_1 + 0x5a8),1);
  local_8 = (float)fVar6;
switchD_004a7a34_caseD_0:
  return (float10)local_8;
}



/* @004a7f50 file=? name=FUN_004a7f50 */

void __cdecl FUN_004a7f50(undefined4 param_1,char *param_2,char *param_3)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  char local_10 [3];
  char local_d [9];
  
  uVar2 = 0xffffffff;
  do {
    pcVar4 = param_2;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar4 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar4;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar4 = pcVar4 + -uVar2;
  pcVar5 = local_10;
  for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar5 = *(undefined4 *)pcVar4;
    pcVar4 = pcVar4 + 4;
    pcVar5 = pcVar5 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar5 = *pcVar4;
    pcVar4 = pcVar4 + 1;
    pcVar5 = pcVar5 + 1;
  }
  uVar2 = 0xffffffff;
  do {
    pcVar4 = param_3;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar4 = param_3 + 1;
    cVar1 = *param_3;
    param_3 = pcVar4;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar4 = pcVar4 + -uVar2;
  pcVar5 = local_10 + 3;
  for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar5 = *(undefined4 *)pcVar4;
    pcVar4 = pcVar4 + 4;
    pcVar5 = pcVar5 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar5 = *pcVar4;
    pcVar4 = pcVar4 + 1;
    pcVar5 = pcVar5 + 1;
  }
  FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_10,0x10,-1);
  return;
}



/* @004a7fc4 file=? name=FUN_004a7fc4 */

void __cdecl FUN_004a7fc4(int param_1,int param_2)

{
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5cc + param_2 * 4),PTR_LAB_0050d6f0,DAT_0050d6f4
               ,DAT_0050d6f8);
  FUN_0041bbd8(param_1 + 0x39c,param_2);
  return;
}



/* @004a800c file=? name=FUN_004a800c */

void __cdecl FUN_004a800c(int param_1,int param_2)

{
  FUN_004277a8(param_1 + 0x6bc,*(int *)(param_1 + 0x5cc + param_2 * 4),PTR_LAB_0050d6fc,DAT_0050d700
               ,DAT_0050d704);
  FUN_0041bbd8(param_1 + 0x714,param_2);
  return;
}



/* @004a8054 file=? name=FUN_004a8054 */

void __cdecl FUN_004a8054(int param_1,int param_2,float *param_3,float *param_4)

{
  int iVar1;
  
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5cc + param_2 * 4),PTR_LAB_0050d708,DAT_0050d70c
               ,DAT_0050d710);
  *param_3 = 0.0;
  *param_4 = 0.0;
  for (iVar1 = 0; iVar1 < *(int *)(param_1 + 0x670); iVar1 = iVar1 + 1) {
    *param_3 = (*(float *)(*(int *)(param_1 + 0x680) + iVar1 * 4) - *param_4) *
               *(float *)(*(int *)(param_1 + 0x690) + 8 + iVar1 * 0xc) + *param_3;
    *param_4 = *(float *)(*(int *)(param_1 + 0x680) + iVar1 * 4);
  }
  return;
}



/* @004a80d4 file=? name=FUN_004a80d4 */

void __cdecl FUN_004a80d4(int param_1,int param_2)

{
  char *pcVar1;
  char cVar2;
  undefined4 *puVar3;
  int iVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  char local_20 [3];
  undefined4 local_1d;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  *(undefined4 *)(param_1 + 0x5c4) = 0;
  pcVar1 = (char *)(param_2 + 0x40);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8d5);
  *(undefined4 *)(param_1 + 0x5e0) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5e0),PTR_LAB_0050d714,DAT_0050d718,DAT_0050d71c)
  ;
  *(undefined4 *)(param_1 + 0x530) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8d9);
  *(undefined4 *)(param_1 + 0x5e4) = *puVar3;
  FUN_004a8054(param_1,6,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8dd);
  *(undefined4 *)(param_1 + 0x5e8) = *puVar3;
  FUN_004a8054(param_1,7,&local_10,&local_14);
  *(float *)(param_1 + 0x534) = (local_8 + local_10) / (local_c + local_14);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8e1);
  *(undefined4 *)(param_1 + 0x5ec) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8e5);
  *(undefined4 *)(param_1 + 0x5f0) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8e9);
  *(undefined4 *)(param_1 + 0x5f4) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5f4),PTR_LAB_0050d720,DAT_0050d724,DAT_0050d728)
  ;
  *(undefined4 *)(param_1 + 0x538) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8ed);
  *(undefined4 *)(param_1 + 0x5f8) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8f1);
  *(undefined4 *)(param_1 + 0x5fc) = *puVar3;
  FUN_004a8054(param_1,0xc,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8f5);
  *(undefined4 *)(param_1 + 0x600) = *puVar3;
  FUN_004a8054(param_1,0xd,&local_10,&local_14);
  *(float *)(param_1 + 0x34c) = (local_8 + local_10) / (local_c + local_14);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8f9);
  *(undefined4 *)(param_1 + 0x604) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d8fd);
  *(undefined4 *)(param_1 + 0x608) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d901);
  *(undefined4 *)(param_1 + 0x64c) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d905);
  *(undefined4 *)(param_1 + 0x60c) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x60c),PTR_LAB_0050d72c,DAT_0050d730,DAT_0050d734)
  ;
  *(undefined4 *)(param_1 + 0x52c) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d909);
  *(undefined4 *)(param_1 + 0x610) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d90d);
  *(undefined4 *)(param_1 + 0x61c) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d911);
  *(undefined4 *)(param_1 + 0x620) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d915);
  *(undefined4 *)(param_1 + 0x614) = *puVar3;
  FUN_004a8054(param_1,0x12,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d919);
  *(undefined4 *)(param_1 + 0x618) = *puVar3;
  FUN_004a8054(param_1,0x13,&local_8,&local_c);
  uVar5 = 0xffffffff;
  *(float *)(param_1 + 0x350) = (local_8 + local_10) / (local_c + local_14);
  *(float *)(param_1 + 0x350) = -*(float *)(param_1 + 0x350);
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d91d;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x580) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d921);
    *(undefined4 *)(param_1 + 0x624) = *puVar3;
    FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x624),PTR_LAB_0050d738,DAT_0050d73c,
                 DAT_0050d740);
    *(undefined4 *)(param_1 + 0x53c) =
         *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d925);
    *(undefined4 *)(param_1 + 0x628) = *puVar3;
    FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x628),PTR_LAB_0050d744,DAT_0050d748,
                 DAT_0050d74c);
    *(undefined4 *)(param_1 + 0x540) =
         *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d929);
    *(undefined4 *)(param_1 + 0x62c) = *puVar3;
    FUN_004a8054(param_1,0x18,&local_8,&local_c);
    *(float *)(param_1 + 0x544) = local_8 / local_c;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d92d);
    *(undefined4 *)(param_1 + 0x630) = *puVar3;
    FUN_004a8054(param_1,0x19,&local_8,&local_c);
    *(float *)(param_1 + 0x548) = local_8 / local_c;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d931);
    *(undefined4 *)(param_1 + 0x634) = *puVar3;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d935);
    *(undefined4 *)(param_1 + 0x638) = *puVar3;
  }
  *(undefined4 *)(param_1 + 0x584) = 0;
  uVar5 = 0xffffffff;
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d939;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x584) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d93d);
    *(undefined4 *)(param_1 + 0x5d8) = *puVar3;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d941);
    *(undefined4 *)(param_1 + 0x5d4) = *puVar3;
  }
  *(undefined4 *)(param_1 + 0x588) = 0;
  uVar5 = 0xffffffff;
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d945;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x588) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d949);
    *(undefined4 *)(param_1 + 0x5dc) = *puVar3;
  }
  return;
}



/* @004a86c8 file=? name=FUN_004a86c8 */

void __cdecl FUN_004a86c8(int param_1,int param_2)

{
  char *pcVar1;
  char cVar2;
  undefined4 *puVar3;
  int iVar4;
  uint uVar5;
  uint uVar6;
  char *pcVar7;
  char *pcVar8;
  char local_20 [3];
  undefined4 local_1d;
  undefined1 uStack_19;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  *(undefined4 *)(param_1 + 0x5c4) = 0;
  pcVar1 = (char *)(param_2 + 0x40);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d94d);
  *(undefined4 *)(param_1 + 0x5e0) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5e0),PTR_LAB_0050d750,DAT_0050d754,DAT_0050d758)
  ;
  *(undefined4 *)(param_1 + 0x530) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d952);
  *(undefined4 *)(param_1 + 0x5e4) = *puVar3;
  FUN_004a8054(param_1,6,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d957);
  *(undefined4 *)(param_1 + 0x5e8) = *puVar3;
  FUN_004a8054(param_1,7,&local_10,&local_14);
  *(float *)(param_1 + 0x534) = (local_8 + local_10) / (local_c + local_14);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d95c);
  *(undefined4 *)(param_1 + 0x5ec) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d961);
  *(undefined4 *)(param_1 + 0x5f0) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d966);
  *(undefined4 *)(param_1 + 0x5f4) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x5f4),PTR_LAB_0050d75c,DAT_0050d760,DAT_0050d764)
  ;
  *(undefined4 *)(param_1 + 0x538) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d96b);
  *(undefined4 *)(param_1 + 0x5f8) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d970);
  *(undefined4 *)(param_1 + 0x5fc) = *puVar3;
  FUN_004a8054(param_1,0xc,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d975);
  *(undefined4 *)(param_1 + 0x600) = *puVar3;
  FUN_004a8054(param_1,0xd,&local_10,&local_14);
  *(float *)(param_1 + 0x34c) = (local_8 + local_10) / (local_c + local_14);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d97a);
  *(undefined4 *)(param_1 + 0x604) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d97f);
  *(undefined4 *)(param_1 + 0x608) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d984);
  *(undefined4 *)(param_1 + 0x64c) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d989);
  *(undefined4 *)(param_1 + 0x60c) = *puVar3;
  FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x60c),PTR_LAB_0050d768,DAT_0050d76c,DAT_0050d770)
  ;
  *(undefined4 *)(param_1 + 0x52c) =
       *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d98e);
  *(undefined4 *)(param_1 + 0x610) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d993);
  *(undefined4 *)(param_1 + 0x61c) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d998);
  *(undefined4 *)(param_1 + 0x620) = *puVar3;
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d99d);
  *(undefined4 *)(param_1 + 0x614) = *puVar3;
  FUN_004a8054(param_1,0x12,&local_8,&local_c);
  puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9a2);
  *(undefined4 *)(param_1 + 0x618) = *puVar3;
  FUN_004a8054(param_1,0x13,&local_8,&local_c);
  uVar5 = 0xffffffff;
  *(float *)(param_1 + 0x350) = (local_8 + local_10) / (local_c + local_14);
  *(float *)(param_1 + 0x350) = -*(float *)(param_1 + 0x350);
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d9a7;
  uStack_19 = DAT_0050d9ab;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x580) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9ac);
    *(undefined4 *)(param_1 + 0x624) = *puVar3;
    FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x624),PTR_LAB_0050d774,DAT_0050d778,
                 DAT_0050d77c);
    *(undefined4 *)(param_1 + 0x53c) =
         *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9b1);
    *(undefined4 *)(param_1 + 0x628) = *puVar3;
    FUN_004277a8(param_1 + 0x65c,*(int *)(param_1 + 0x628),PTR_LAB_0050d780,DAT_0050d784,
                 DAT_0050d788);
    *(undefined4 *)(param_1 + 0x540) =
         *(undefined4 *)(*(int *)(param_1 + 0x690) + 8 + *(int *)(param_1 + 0x670) * 0xc);
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9b6);
    *(undefined4 *)(param_1 + 0x62c) = *puVar3;
    FUN_004a8054(param_1,0x18,&local_8,&local_c);
    *(float *)(param_1 + 0x544) = local_8 / local_c;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9bb);
    *(undefined4 *)(param_1 + 0x630) = *puVar3;
    FUN_004a8054(param_1,0x19,&local_8,&local_c);
    *(float *)(param_1 + 0x548) = local_8 / local_c;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9c0);
    *(undefined4 *)(param_1 + 0x634) = *puVar3;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9c5);
    *(undefined4 *)(param_1 + 0x638) = *puVar3;
  }
  *(undefined4 *)(param_1 + 0x584) = 0;
  uVar5 = 0xffffffff;
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d9ca;
  uStack_19 = DAT_0050d9ce;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x584) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9cf);
    *(undefined4 *)(param_1 + 0x5d8) = *puVar3;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9d4);
    *(undefined4 *)(param_1 + 0x5d4) = *puVar3;
  }
  *(undefined4 *)(param_1 + 0x588) = 0;
  uVar5 = 0xffffffff;
  pcVar7 = pcVar1;
  do {
    pcVar8 = pcVar7;
    if (uVar5 == 0) break;
    uVar5 = uVar5 - 1;
    pcVar8 = pcVar7 + 1;
    cVar2 = *pcVar7;
    pcVar7 = pcVar8;
  } while (cVar2 != '\0');
  uVar5 = ~uVar5;
  pcVar7 = pcVar8 + -uVar5;
  pcVar8 = local_20;
  for (uVar6 = uVar5 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) {
    *(undefined4 *)pcVar8 = *(undefined4 *)pcVar7;
    pcVar7 = pcVar7 + 4;
    pcVar8 = pcVar8 + 4;
  }
  for (uVar5 = uVar5 & 3; uVar5 != 0; uVar5 = uVar5 - 1) {
    *pcVar8 = *pcVar7;
    pcVar7 = pcVar7 + 1;
    pcVar8 = pcVar8 + 1;
  }
  local_1d = DAT_0050d9d9;
  uStack_19 = DAT_0050d9dd;
  iVar4 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),local_20,0x10,-1);
  if (iVar4 != 0) {
    *(undefined4 *)(param_1 + 0x588) = 1;
    puVar3 = (undefined4 *)FUN_004a7f50(param_1,pcVar1,&DAT_0050d9de);
    *(undefined4 *)(param_1 + 0x5dc) = *puVar3;
  }
  return;
}



/* @004a8cc0 file=? name=FUN_004a8cc0 */

/* WARNING: Type propagation algorithm not settling */

undefined4 __cdecl
FUN_004a8cc0(int param_1,char *param_2,int param_3,int param_4,char *param_5,char *param_6,
            char *param_7,int param_8,int param_9)

{
  char *pcVar1;
  char *pcVar2;
  int iVar3;
  undefined3 extraout_var;
  int *piVar4;
  char *pcVar5;
  bool bVar6;
  byte bVar7;
  
  pcVar5 = s_HeatSinkClassID_0050da25;
  pcVar2 = param_2;
  do {
    bVar6 = *pcVar2 == *pcVar5;
    if (!bVar6) break;
    if (*pcVar2 == '\0') goto LAB_004a8cf5;
    pcVar1 = pcVar2 + 1;
    bVar6 = *pcVar1 == pcVar5[1];
    if (!bVar6) break;
    pcVar2 = pcVar2 + 2;
    pcVar5 = pcVar5 + 2;
    bVar6 = *pcVar1 == '\0';
  } while (!bVar6);
  if (bVar6) {
LAB_004a8cf5:
    iVar3 = FUN_004ae9dc(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
  }
  else {
    pcVar5 = s_ReservoirClassID_0050da35;
    pcVar2 = param_2;
    do {
      if (*pcVar2 != *pcVar5) goto LAB_004a8d6f;
      bVar6 = true;
      if (*pcVar2 == '\0') break;
      pcVar1 = pcVar2 + 1;
      if (*pcVar1 != pcVar5[1]) goto LAB_004a8d6f;
      pcVar2 = pcVar2 + 2;
      pcVar5 = pcVar5 + 2;
      bVar6 = *pcVar1 == '\0';
    } while (!bVar6);
    if (bVar6) {
      iVar3 = FUN_004af580(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
    }
    else {
LAB_004a8d6f:
      pcVar5 = s_CondenserClassID_0050da46;
      pcVar2 = param_2;
      do {
        if (*pcVar2 != *pcVar5) goto LAB_004a8dbf;
        bVar6 = true;
        if (*pcVar2 == '\0') break;
        pcVar1 = pcVar2 + 1;
        if (*pcVar1 != pcVar5[1]) goto LAB_004a8dbf;
        pcVar2 = pcVar2 + 2;
        pcVar5 = pcVar5 + 2;
        bVar6 = *pcVar1 == '\0';
      } while (!bVar6);
      if (bVar6) {
        iVar3 = FUN_004ae658(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
      }
      else {
LAB_004a8dbf:
        pcVar5 = s_PoweredSubsystemClassID_0050da57;
        pcVar2 = param_2;
        do {
          if (*pcVar2 != *pcVar5) goto LAB_004a8e0f;
          bVar6 = true;
          if (*pcVar2 == '\0') break;
          pcVar1 = pcVar2 + 1;
          if (*pcVar1 != pcVar5[1]) goto LAB_004a8e0f;
          pcVar2 = pcVar2 + 2;
          pcVar5 = pcVar5 + 2;
          bVar6 = *pcVar1 == '\0';
        } while (!bVar6);
        if (bVar6) {
          iVar3 = FUN_004b13ac(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
        }
        else {
LAB_004a8e0f:
          pcVar5 = s_MyomersClassID_0050da6f;
          pcVar2 = param_2;
          do {
            if (*pcVar2 != *pcVar5) goto LAB_004a8e5f;
            bVar6 = true;
            if (*pcVar2 == '\0') break;
            pcVar1 = pcVar2 + 1;
            if (*pcVar1 != pcVar5[1]) goto LAB_004a8e5f;
            pcVar2 = pcVar2 + 2;
            pcVar5 = pcVar5 + 2;
            bVar6 = *pcVar1 == '\0';
          } while (!bVar6);
          if (bVar6) {
            iVar3 = FUN_004b9140(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
          }
          else {
LAB_004a8e5f:
            pcVar5 = s_GeneratorClassID_0050da7e;
            pcVar2 = param_2;
            do {
              if (*pcVar2 != *pcVar5) goto LAB_004a8eaf;
              bVar6 = true;
              if (*pcVar2 == '\0') break;
              pcVar1 = pcVar2 + 1;
              if (*pcVar1 != pcVar5[1]) goto LAB_004a8eaf;
              pcVar2 = pcVar2 + 2;
              pcVar5 = pcVar5 + 2;
              bVar6 = *pcVar1 == '\0';
            } while (!bVar6);
            if (bVar6) {
              iVar3 = FUN_004b23bc(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
            }
            else {
LAB_004a8eaf:
              pcVar5 = s_HUDClassID_0050da8f;
              pcVar2 = param_2;
              do {
                if (*pcVar2 != *pcVar5) goto LAB_004a8eff;
                bVar6 = true;
                if (*pcVar2 == '\0') break;
                pcVar1 = pcVar2 + 1;
                if (*pcVar1 != pcVar5[1]) goto LAB_004a8eff;
                pcVar2 = pcVar2 + 2;
                pcVar5 = pcVar5 + 2;
                bVar6 = *pcVar1 == '\0';
              } while (!bVar6);
              if (bVar6) {
                iVar3 = FUN_004b81d4(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
              }
              else {
LAB_004a8eff:
                pcVar5 = s_SearchlightClassID_0050da9a;
                pcVar2 = param_2;
                do {
                  if (*pcVar2 != *pcVar5) goto LAB_004a8f4f;
                  bVar6 = true;
                  if (*pcVar2 == '\0') break;
                  pcVar1 = pcVar2 + 1;
                  if (*pcVar1 != pcVar5[1]) goto LAB_004a8f4f;
                  pcVar2 = pcVar2 + 2;
                  pcVar5 = pcVar5 + 2;
                  bVar6 = *pcVar1 == '\0';
                } while (!bVar6);
                if (bVar6) {
                  iVar3 = FUN_004b85a8(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
                }
                else {
LAB_004a8f4f:
                  pcVar5 = s_ThermalSightClassID_0050daad;
                  pcVar2 = param_2;
                  do {
                    if (*pcVar2 != *pcVar5) goto LAB_004a8f9f;
                    bVar6 = true;
                    if (*pcVar2 == '\0') break;
                    pcVar1 = pcVar2 + 1;
                    if (*pcVar1 != pcVar5[1]) goto LAB_004a8f9f;
                    pcVar2 = pcVar2 + 2;
                    pcVar5 = pcVar5 + 2;
                    bVar6 = *pcVar1 == '\0';
                  } while (!bVar6);
                  if (bVar6) {
                    iVar3 = FUN_004b87d4(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
                  }
                  else {
LAB_004a8f9f:
                    pcVar5 = s_SensorClassID_0050dac1;
                    pcVar2 = param_2;
                    do {
                      if (*pcVar2 != *pcVar5) goto LAB_004a8fef;
                      bVar6 = true;
                      if (*pcVar2 == '\0') break;
                      pcVar1 = pcVar2 + 1;
                      if (*pcVar1 != pcVar5[1]) goto LAB_004a8fef;
                      pcVar2 = pcVar2 + 2;
                      pcVar5 = pcVar5 + 2;
                      bVar6 = *pcVar1 == '\0';
                    } while (!bVar6);
                    if (bVar6) {
                      bVar6 = FUN_004b1dcc(param_4,param_5,param_6,param_7,param_8,param_9,param_1);
                      iVar3 = CONCAT31(extraout_var,bVar6);
                    }
                    else {
LAB_004a8fef:
                      pcVar5 = s_GyroscopeClassID_0050dacf;
                      pcVar2 = param_2;
                      do {
                        if (*pcVar2 != *pcVar5) goto LAB_004a903f;
                        bVar6 = true;
                        if (*pcVar2 == '\0') break;
                        pcVar1 = pcVar2 + 1;
                        if (*pcVar1 != pcVar5[1]) goto LAB_004a903f;
                        pcVar2 = pcVar2 + 2;
                        pcVar5 = pcVar5 + 2;
                        bVar6 = *pcVar1 == '\0';
                      } while (!bVar6);
                      if (bVar6) {
                        iVar3 = FUN_004b3eb4(param_4,param_5,param_6,param_7,param_8,param_9,param_1
                                            );
                      }
                      else {
LAB_004a903f:
                        pcVar5 = s_TorsoClassID_0050dae0;
                        pcVar2 = param_2;
                        do {
                          if (*pcVar2 != *pcVar5) goto LAB_004a908f;
                          bVar6 = true;
                          if (*pcVar2 == '\0') break;
                          pcVar1 = pcVar2 + 1;
                          if (*pcVar1 != pcVar5[1]) goto LAB_004a908f;
                          pcVar2 = pcVar2 + 2;
                          pcVar5 = pcVar5 + 2;
                          bVar6 = *pcVar1 == '\0';
                        } while (!bVar6);
                        if (bVar6) {
                          iVar3 = FUN_004b6fec(param_4,param_5,param_6,param_7,param_8,param_9,
                                               param_1);
                        }
                        else {
LAB_004a908f:
                          pcVar5 = s_EmitterClassID_0050daed;
                          pcVar2 = param_2;
                          do {
                            if (*pcVar2 != *pcVar5) goto LAB_004a90e3;
                            bVar6 = true;
                            if (*pcVar2 == '\0') break;
                            pcVar1 = pcVar2 + 1;
                            if (*pcVar1 != pcVar5[1]) goto LAB_004a90e3;
                            pcVar2 = pcVar2 + 2;
                            pcVar5 = pcVar5 + 2;
                            bVar6 = *pcVar1 == '\0';
                          } while (!bVar6);
                          if (bVar6) {
                            iVar3 = FUN_004bb478(param_3,param_4,param_5,param_6,param_7,param_8,
                                                 param_9,param_1);
                          }
                          else {
LAB_004a90e3:
                            pcVar5 = s_PPCClassID_0050dafc;
                            pcVar2 = param_2;
                            do {
                              if (*pcVar2 != *pcVar5) goto LAB_004a9137;
                              bVar6 = true;
                              if (*pcVar2 == '\0') break;
                              pcVar1 = pcVar2 + 1;
                              if (*pcVar1 != pcVar5[1]) goto LAB_004a9137;
                              pcVar2 = pcVar2 + 2;
                              pcVar5 = pcVar5 + 2;
                              bVar6 = *pcVar1 == '\0';
                            } while (!bVar6);
                            if (bVar6) {
                              iVar3 = FUN_004bb8e0(param_3,param_4,param_5,param_6,param_7,param_8,
                                                   param_9,param_1);
                            }
                            else {
LAB_004a9137:
                              pcVar5 = s_ProjectileWeaponClassID_0050db07;
                              pcVar2 = param_2;
                              do {
                                if (*pcVar2 != *pcVar5) goto LAB_004a918b;
                                bVar6 = true;
                                if (*pcVar2 == '\0') break;
                                pcVar1 = pcVar2 + 1;
                                if (*pcVar1 != pcVar5[1]) goto LAB_004a918b;
                                pcVar2 = pcVar2 + 2;
                                pcVar5 = pcVar5 + 2;
                                bVar6 = *pcVar1 == '\0';
                              } while (!bVar6);
                              if (bVar6) {
                                iVar3 = FUN_004bc7cc(param_3,param_4,param_5,param_6,param_7,param_8
                                                     ,param_9,param_1);
                              }
                              else {
LAB_004a918b:
                                pcVar5 = s_MissileLauncherClassID_0050db1f;
                                pcVar2 = param_2;
                                do {
                                  if (*pcVar2 != *pcVar5) goto LAB_004a91df;
                                  bVar6 = true;
                                  if (*pcVar2 == '\0') break;
                                  pcVar1 = pcVar2 + 1;
                                  if (*pcVar1 != pcVar5[1]) goto LAB_004a91df;
                                  pcVar2 = pcVar2 + 2;
                                  pcVar5 = pcVar5 + 2;
                                  bVar6 = *pcVar1 == '\0';
                                } while (!bVar6);
                                if (bVar6) {
                                  iVar3 = FUN_004bd08c(param_3,param_4,param_5,param_6,param_7,
                                                       param_8,param_9,param_1);
                                }
                                else {
LAB_004a91df:
                                  pcVar5 = s_GaussRifleClassID_0050db36;
                                  pcVar2 = param_2;
                                  do {
                                    if (*pcVar2 != *pcVar5) goto LAB_004a9233;
                                    bVar6 = true;
                                    if (*pcVar2 == '\0') break;
                                    pcVar1 = pcVar2 + 1;
                                    if (*pcVar1 != pcVar5[1]) goto LAB_004a9233;
                                    pcVar2 = pcVar2 + 2;
                                    pcVar5 = pcVar5 + 2;
                                    bVar6 = *pcVar1 == '\0';
                                  } while (!bVar6);
                                  if (bVar6) {
                                    iVar3 = FUN_004bdd14(param_3,param_4,param_5,param_6,param_7,
                                                         param_8,param_9,param_1);
                                  }
                                  else {
LAB_004a9233:
                                    pcVar5 = s_AmmoBinClassID_0050db48;
                                    pcVar2 = param_2;
                                    do {
                                      if (*pcVar2 != *pcVar5) goto LAB_004a9287;
                                      bVar6 = true;
                                      if (*pcVar2 == '\0') break;
                                      pcVar1 = pcVar2 + 1;
                                      if (*pcVar1 != pcVar5[1]) goto LAB_004a9287;
                                      pcVar2 = pcVar2 + 2;
                                      pcVar5 = pcVar5 + 2;
                                      bVar6 = *pcVar1 == '\0';
                                    } while (!bVar6);
                                    if (bVar6) {
                                      iVar3 = FUN_004bd6f0(param_3,param_4,param_5,param_6,param_7,
                                                           param_8,param_9,param_1);
                                    }
                                    else {
LAB_004a9287:
                                      pcVar5 = s_SubsystemMessageManagerClassID_0050db57;
                                      pcVar2 = param_2;
                                      do {
                                        if (*pcVar2 != *pcVar5) goto LAB_004a92d7;
                                        bVar6 = true;
                                        if (*pcVar2 == '\0') break;
                                        pcVar1 = pcVar2 + 1;
                                        if (*pcVar1 != pcVar5[1]) goto LAB_004a92d7;
                                        pcVar2 = pcVar2 + 2;
                                        pcVar5 = pcVar5 + 2;
                                        bVar6 = *pcVar1 == '\0';
                                      } while (!bVar6);
                                      if (bVar6) {
                                        iVar3 = FUN_0049be10(param_3,param_4,param_5,param_6,param_7
                                                             ,param_8,param_9);
                                      }
                                      else {
LAB_004a92d7:
                                        pcVar5 = s_MechTechClassID_0050db76;
                                        pcVar2 = param_2;
                                        do {
                                          if (*pcVar2 != *pcVar5) goto LAB_004a9324;
                                          bVar6 = true;
                                          if (*pcVar2 == '\0') break;
                                          pcVar1 = pcVar2 + 1;
                                          if (*pcVar1 != pcVar5[1]) goto LAB_004a9324;
                                          pcVar2 = pcVar2 + 2;
                                          pcVar5 = pcVar5 + 2;
                                          bVar6 = *pcVar1 == '\0';
                                        } while (!bVar6);
                                        if (!bVar6) {
LAB_004a9324:
                                          bVar7 = 0x3a;
                                          FUN_004dbb24(&DAT_00524e20,param_5,(char *)0x0);
                                          piVar4 = FUN_004db92c(&DAT_00524e20,bVar7);
                                          FUN_004dbb24(piVar4,param_6,(char *)0x0);
                                          FUN_004dbb24(piVar4,
                                                  s_has_an_unknown_component_type_of_0050db86,
                                                  (char *)0x0);
                                          FUN_004dbb24(piVar4,param_2,(char *)0x0);
                                          FUN_004d9c38(piVar4);
                                          return 0xffffffff;
                                        }
                                        iVar3 = FUN_004ad48c(param_4,param_5,param_6,param_7,param_8
                                                             ,param_9,param_3);
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  if (iVar3 == 0) {
    return 0xffffffff;
  }
  return 1;
}



/* @004a9390 file=? name=FUN_004a9390 */

undefined4 __cdecl FUN_004a9390(int param_1,char *param_2,int param_3,undefined4 *param_4)

{
  char *pcVar1;
  int iVar2;
  undefined4 uVar3;
  int *piVar4;
  undefined4 *puVar5;
  byte bVar6;
  undefined4 local_58 [2];
  int *local_50;
  int local_48;
  char *local_44;
  uint local_40;
  int *local_3c;
  char *local_38;
  int local_34;
  int *local_30;
  char *local_2c;
  int *local_28;
  char *local_24;
  int *local_20;
  int *local_1c;
  char *local_18;
  int *local_14;
  int *local_10;
  char *local_c;
  char *local_8;
  
  iVar2 = FUN_00404088(param_3,s_gamedata_0050dba9,s_Subsystems_0050dbb2,&local_8);
  if (iVar2 == 0) {
    local_c = param_2;
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s_is_missing__sub_file_specificati_0050dbbd,(char *)0x0);
    uVar3 = 0xffffffff;
  }
  else {
    local_10 = (int *)FUN_004064fc((char *)*param_4,local_8);
    piVar4 = (int *)FUN_00402298(0x20);
    if (piVar4 == (int *)0x0) {
      local_14 = (int *)0x0;
    }
    else {
      local_14 = FUN_00403e84(piVar4,(char *)local_10,1);
    }
    local_20 = FUN_0040485c((int)local_14,(char *)0x0);
    iVar2 = 0;
    for (puVar5 = (undefined4 *)local_20[1]; puVar5 != (undefined4 *)0x0;
        puVar5 = (undefined4 *)*puVar5) {
      iVar2 = iVar2 + 1;
    }
    if (iVar2 == 0) {
      local_24 = param_2;
      FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_has_no_subsystems__0050dbe3,(char *)0x0);
      if (local_20 != (int *)0x0) {
        (**(code **)*local_20)(local_20,3);
      }
      FUN_004022d0(local_10);
      FUN_00403ecc(local_14,3);
      uVar3 = 0xffffffff;
    }
    else {
      local_28 = (int *)FUN_004022b0(iVar2 * 0x770);
      FUN_004030dc(local_58,local_28,iVar2 * 0x770,0);
      *local_50 = iVar2;
      local_50 = local_50 + 1;
      for (puVar5 = (undefined4 *)local_20[1]; puVar5 != (undefined4 *)0x0;
          puVar5 = (undefined4 *)*puVar5) {
        pcVar1 = (char *)(puVar5 + 2);
        iVar2 = FUN_00404088((int)local_14,pcVar1,&DAT_0050dbf8,&local_2c);
        if (iVar2 == 0) {
          bVar6 = 0x3a;
          FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
          piVar4 = FUN_004db92c(&DAT_00524e20,bVar6);
          FUN_004dbb24(piVar4,pcVar1,(char *)0x0);
          FUN_004dbb24(piVar4,s_missing_Type__0050dbfd,(char *)0x0);
LAB_004a9555:
          FUN_004022e8(local_28);
          if (local_20 != (int *)0x0) {
            (**(code **)*local_20)(local_20,3);
          }
          FUN_004022d0(local_10);
          FUN_00403ecc(local_14,3);
          return 0xffffffff;
        }
        iVar2 = FUN_00404088((int)local_14,pcVar1,s_Include_0050dc0d,&local_18);
        if (iVar2 == 0) {
          piVar4 = (int *)0x0;
          local_1c = (int *)0x0;
        }
        else {
          piVar4 = (int *)FUN_004064fc((char *)*param_4,local_18);
          local_30 = (int *)FUN_00402298(0x20);
          if (local_30 == (int *)0x0) {
            local_1c = (int *)0x0;
          }
          else {
            local_1c = FUN_00403e84(local_30,(char *)piVar4,1);
          }
        }
        local_34 = 1;
        if (piVar4 != (int *)0x0) {
          local_38 = FUN_004d4c78(local_2c,s_ClassID_0050dc15);
          iVar2 = FUN_004d4a78(local_2c);
          local_3c = (int *)FUN_004022b0(iVar2 + 1);
          local_40 = (int)local_38 - (int)local_2c;
          local_3c = FUN_004d4b9c(local_3c,local_2c,local_40);
          local_44 = (char *)((int)local_3c + local_40);
          *local_44 = DAT_0050dc1d;
          local_48 = FUN_004a8cc0(local_34,local_2c,param_1,param_3,param_2,(char *)local_3c,
                                  (char *)local_50,(int)local_1c,(int)param_4);
          local_34 = local_34 + 1;
          FUN_004022e8(local_3c);
          if (local_48 == -1) goto LAB_004a9555;
        }
        iVar2 = FUN_004a8cc0(local_34,local_2c,param_1,param_3,param_2,pcVar1,(char *)local_50,
                             (int)local_14,(int)param_4);
        if (iVar2 == -1) goto LAB_004a9555;
        if (piVar4 != (int *)0x0) {
          FUN_004022d0(piVar4);
          FUN_00403ecc(local_1c,3);
        }
        local_50 = (int *)((int)local_50 + local_50[9]);
      }
      puVar5 = (undefined4 *)
               FUN_00406db4(param_1,param_2,0x11,1,0,local_28,(int)local_50 - (int)local_28,-1);
      FUN_004022e8(local_28);
      if (local_20 != (int *)0x0) {
        (**(code **)*local_20)(local_20,3);
      }
      FUN_004022d0(local_10);
      FUN_00403ecc(local_14,3);
      uVar3 = *puVar5;
    }
  }
  return uVar3;
}



/* @004a9770 file=? name=FUN_004a9770 */

undefined * __cdecl FUN_004a9770(char *param_1)

{
  char *pcVar1;
  char *pcVar2;
  char *pcVar3;
  bool bVar4;
  
  pcVar3 = &DAT_0050dc1f;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a97a4;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a97a4;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050bde4;
  }
LAB_004a97a4:
  pcVar3 = s_ControlsMapper_0050dc20;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a97d1;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a97d1;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050ee00;
  }
LAB_004a97d1:
  pcVar3 = s_AmmoBinClassID_0050dc2f;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a97fe;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a97fe;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_005125bc;
  }
LAB_004a97fe:
  pcVar3 = s_HeatSinkClassID_0050dc3e;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a982b;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a982b;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050e580;
  }
LAB_004a982b:
  pcVar3 = s_ReservoirClassID_0050dc4e;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9858;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9858;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050e640;
  }
LAB_004a9858:
  pcVar3 = s_CondenserClassID_0050dc5f;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9885;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9885;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050e4ec;
  }
LAB_004a9885:
  pcVar3 = s_PoweredSubsystemClassID_0050dc70;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a98b2;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a98b2;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050f4ac;
  }
LAB_004a98b2:
  pcVar3 = s_MyomersClassID_0050dc88;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a98df;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a98df;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0051154c;
  }
LAB_004a98df:
  pcVar3 = s_GeneratorClassID_0050dc97;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a990c;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a990c;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050fb50;
  }
LAB_004a990c:
  pcVar3 = s_HUDClassID_0050dca8;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9939;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9939;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00511078;
  }
LAB_004a9939:
  pcVar3 = s_SensorClassID_0050dcb3;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9966;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9966;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050fa1c;
  }
LAB_004a9966:
  pcVar3 = s_SearchlightClassID_0050dcc1;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9993;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9993;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00511198;
  }
LAB_004a9993:
  pcVar3 = s_ThermalSightClassID_0050dcd4;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a99c0;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a99c0;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00511228;
  }
LAB_004a99c0:
  pcVar3 = s_GyroscopeClassID_0050dce8;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a99ed;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a99ed;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050fdb0;
  }
LAB_004a99ed:
  pcVar3 = s_TorsoClassID_0050dcf9;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9a1a;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9a1a;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00510af8;
  }
LAB_004a9a1a:
  pcVar3 = s_EmitterClassID_0050dd06;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9a47;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9a47;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00511d78;
  }
LAB_004a9a47:
  pcVar3 = s_PPCClassID_0050dd15;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9a74;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9a74;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_005120c4;
  }
LAB_004a9a74:
  pcVar3 = s_ProjectileWeaponClassID_0050dd20;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9aa1;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9aa1;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00512198;
  }
LAB_004a9aa1:
  pcVar3 = s_MissileLauncherClassID_0050dd38;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9ace;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9ace;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00512478;
  }
LAB_004a9ace:
  pcVar3 = s_GaussRifleClassID_0050dd4f;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9afb;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9afb;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_00512478;
  }
LAB_004a9afb:
  pcVar3 = s_ControlsMapper_0050dd61;
  pcVar2 = param_1;
  do {
    if (*pcVar2 != *pcVar3) goto LAB_004a9b28;
    bVar4 = true;
    if (*pcVar2 == '\0') break;
    pcVar1 = pcVar2 + 1;
    if (*pcVar1 != pcVar3[1]) goto LAB_004a9b28;
    pcVar2 = pcVar2 + 2;
    pcVar3 = pcVar3 + 2;
    bVar4 = *pcVar1 == '\0';
  } while (!bVar4);
  if (bVar4) {
    return &DAT_0050ee00;
  }
LAB_004a9b28:
  pcVar2 = s_MechTech_0050dd70;
  do {
    if (*param_1 != *pcVar2) {
      return (undefined *)0x0;
    }
    bVar4 = true;
    if (*param_1 == '\0') break;
    pcVar3 = param_1 + 1;
    if (*pcVar3 != pcVar2[1]) {
      return (undefined *)0x0;
    }
    param_1 = param_1 + 2;
    pcVar2 = pcVar2 + 2;
    bVar4 = *pcVar3 == '\0';
  } while (!bVar4);
  if (!bVar4) {
    return (undefined *)0x0;
  }
  return &DAT_0050e270;
}



/* @004ab188 file=? name=FUN_004ab188 */

void __cdecl FUN_004ab188(int param_1,float param_2)

{
  float local_10 [3];
  
  FUN_004086ac(local_10,(float *)(param_1 + 0x2d4),param_2);
  FUN_00409f58((float *)(param_1 + 0x26c),(float *)(param_1 + 0x138),local_10);
  return;
}



/* @004ab1c8 file=? name=FUN_004ab1c8 */

undefined4 __cdecl FUN_004ab1c8(int param_1,float param_2,int param_3)

{
  float *pfVar1;
  int iVar2;
  undefined4 uVar3;
  float10 fVar4;
  float local_64;
  undefined4 local_60;
  undefined4 local_5c;
  undefined4 local_58;
  float local_54 [3];
  float local_48 [3];
  float local_3c [12];
  float local_c;
  float local_8;
  
  if (*(int *)(param_1 + 0x3f4) == 0) {
    *(undefined4 *)(param_1 + 0x344) = *(undefined4 *)(param_1 + 0x5b8);
  }
  else {
    *(undefined4 *)(param_1 + 0x344) = *(undefined4 *)(param_1 + 0x5bc);
  }
  iVar2 = FUN_0049fb54(param_1);
  if (iVar2 == 0) {
    if (((*(uint *)(param_1 + 0x28) & 0xc) == 4) &&
       (*(int *)(param_1 + 0x10) < *(int *)(param_1 + 0x2e0))) {
      iVar2 = *(int *)(param_1 + 0x2e0) - *(int *)(param_1 + 0x778);
      uVar3 = 1;
    }
    else {
      iVar2 = *(int *)(param_1 + 0x10) - *(int *)(param_1 + 0x778);
      uVar3 = 0;
    }
    local_8 = (float)iVar2 / DAT_0052140c;
    if (*(int *)(param_1 + 0x77c) != 0) {
      if ((*(uint *)(param_1 + 0x28) & 0xc) == 4) {
        FUN_00408644((float *)(param_1 + 0x598),(float *)(param_1 + 300),(float *)(param_1 + 0x100))
        ;
        *(undefined4 *)(param_1 + 0x5a4) = 1;
        *(undefined4 *)(param_1 + 0x77c) = 0;
      }
      else {
        FUN_00408440((undefined4 *)(param_1 + 0x260),(undefined4 *)(param_1 + 300));
        *(undefined4 *)(param_1 + 0x77c) = 0;
      }
    }
    if (((*(int *)(param_1 + 0x40) == 3) || (*(int *)(param_1 + 0x40) == 4)) &&
       (*(int *)(param_1 + 0x580) != 0)) {
      fVar4 = FUN_004a5bf8(param_1,param_2,param_3);
    }
    else {
      fVar4 = FUN_004a5678(param_1,param_2,param_3);
    }
    local_c = (float)fVar4;
    *(float *)(param_1 + 0x2a0) = -local_c / param_2;
    *(undefined4 *)(param_1 + 0x29c) = 0;
    *(undefined4 *)(param_1 + 0x298) = 0;
    FUN_004ab188(param_1,local_8);
    FUN_00408440((undefined4 *)(param_1 + 0x2a4),(undefined4 *)(param_1 + 0x2d4));
    FUN_0040aadc(local_3c);
    pfVar1 = (float *)(param_1 + 0x260);
    FUN_0040ab44(local_3c,pfVar1);
    FUN_00408744(local_48,(float *)(param_1 + 0x298),local_3c);
    FUN_00408440(local_54,&DAT_004e0f74);
    FUN_00408614(local_54,local_54,local_48,param_2);
    FUN_004085ec(pfVar1,pfVar1,local_54);
    FUN_00408440(local_54,&DAT_004e0f74);
    FUN_00408614(local_54,local_54,(float *)(param_1 + 0x2a4),param_2);
    local_64 = *(float *)(param_1 + 0x26c);
    local_60 = *(undefined4 *)(param_1 + 0x270);
    local_5c = *(undefined4 *)(param_1 + 0x274);
    local_58 = *(undefined4 *)(param_1 + 0x278);
    FUN_00409f58((float *)(param_1 + 0x26c),&local_64,local_54);
  }
  else {
    FUN_0040a7f4((undefined4 *)(param_1 + 0x298),(undefined4 *)&DAT_004e0fd4);
    uVar3 = 0;
  }
  return uVar3;
}



/* @004ab430 file=? name=FUN_004ab430 */

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

void __cdecl FUN_004ab430(int *param_1,float param_2)

{
  float *pfVar1;
  uint *puVar2;
  int iVar3;
  float10 fVar4;
  int local_98;
  float local_94;
  int local_90;
  float local_8c;
  int local_88;
  int local_84;
  float local_80;
  int local_7c;
  int local_78;
  float local_74;
  float local_70;
  float local_6c;
  float local_68;
  float local_64;
  float local_60;
  int *local_5c;
  int local_58;
  int *local_54;
  int local_50;
  int local_4c;
  int local_48;
  int *local_44;
  int *local_40;
  float *local_3c;
  float local_38;
  int *local_34;
  float local_30;
  float *local_2c;
  float *local_28;
  float local_24;
  int *local_20;
  float *local_1c;
  float *local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  FUN_0040a7f4(param_1 + 0x77,(undefined4 *)&DAT_004e0fd4);
  iVar3 = FUN_004ab1c8((int)param_1,param_2,1);
  if (iVar3 == 0) {
    if (param_1[0x169] == 1) {
      local_8c = (float)param_1[0x166];
      local_34 = param_1 + 5;
      local_88 = param_1[0x167];
      local_84 = param_1[0x168];
      local_30 = (_DAT_004ab9cc - (float)(param_1[4] - *local_34) / DAT_0052140c) + param_2;
      if (local_30 <= param_2) {
        param_1[0x169] = 0;
      }
      else {
        local_38 = param_2 / local_30;
        FUN_004086ac(&local_8c,&local_8c,local_38);
      }
      pfVar1 = (float *)(param_1 + 0x98);
      local_3c = pfVar1;
      FUN_004085ec(pfVar1,pfVar1,&local_8c);
      param_1[0x99] = param_1[0x41];
      FUN_0040a938(param_1 + 0x40,pfVar1);
      FUN_00408644((float *)(param_1 + 0x166),(float *)(param_1 + 0x166),&local_8c);
    }
    else {
      param_1[0x99] = param_1[0x41];
      FUN_0040a938(param_1 + 0x40,param_1 + 0x98);
    }
    local_40 = param_1 + 0xa6;
    FUN_00408440(param_1 + 0x7d,local_40);
    local_44 = param_1 + 0xa9;
    FUN_00408440(param_1 + 0x74,local_44);
  }
  else {
    local_8 = param_2 / ((float)(param_1[0xb8] - param_1[4]) / DAT_0052140c + param_2);
    FUN_0040a4d8((float *)(param_1 + 0x43),(float *)(param_1 + 0x43),(float *)(param_1 + 0x9b),
                 local_8);
    local_c = local_8;
    FUN_00408848((float *)(param_1 + 0x74),(float *)(param_1 + 0x74),_DAT_004ab9c8 - local_8,
                 (float *)(param_1 + 0xa9),local_8);
    if (param_1[0x169] == 1) {
      local_80 = (float)param_1[0x166];
      local_7c = param_1[0x167];
      local_78 = param_1[0x168];
      local_10 = (_DAT_004ab9cc - (float)(param_1[4] - param_1[5]) / DAT_0052140c) + param_2;
      if (local_10 <= param_2) {
        param_1[0x169] = 0;
      }
      else {
        local_14 = param_2 / local_10;
        FUN_004086ac(&local_80,&local_80,local_14);
      }
      pfVar1 = (float *)(param_1 + 0x98);
      local_18 = pfVar1;
      FUN_004085ec(pfVar1,pfVar1,&local_80);
      param_1[0x99] = param_1[0x41];
      local_1c = pfVar1;
      FUN_00408440(param_1 + 0x40,pfVar1);
      FUN_00408644((float *)(param_1 + 0x166),(float *)(param_1 + 0x166),&local_80);
    }
    else {
      local_20 = param_1 + 0x98;
      param_1[0x99] = param_1[0x41];
      FUN_00408440(param_1 + 0x40,local_20);
    }
    local_24 = local_8;
    local_28 = (float *)(param_1 + 0xa6);
    local_2c = (float *)(param_1 + 0x7d);
    FUN_00408848((float *)(param_1 + 0x7d),local_2c,_DAT_004ab9c8 - local_8,local_28,local_8);
  }
  if ((*(byte *)((int)param_1 + 0x29) & 0x40) == 0) {
    (**(code **)(*param_1 + 0x34))(param_1);
    local_48 = *(int *)(DAT_004efc94 + 0x30);
    local_50 = param_1[0x65];
    local_4c = FUN_00433ed4(local_48 + 0x14);
    local_54 = *(int **)(local_4c + 0x30);
    local_58 = param_1[0xba];
    iVar3 = FUN_0040e36c(*local_54,local_58);
    param_1[0xbc] = iVar3;
  }
  else {
    local_5c = param_1 + 0x40;
    FUN_0040ab44((float *)(param_1 + 0x34),local_5c);
  }
  local_98 = param_1[0x40];
  local_90 = param_1[0x42];
  local_94 = *(float *)(param_1[0xbb] + 8) + (float)param_1[0x41];
  FUN_0040e5f0(param_1[0xbc],(int)&local_98,&local_60);
  if (local_60 != _DAT_004ab9d0) {
    local_60 = local_60 - *(float *)(param_1[0xbb] + 8);
    param_1[0x41] = (int)((float)param_1[0x41] - local_60);
    *(float *)(param_1[0xba] + 8) = *(float *)(param_1[0xba] + 8) - local_60;
    *(float *)(param_1[0xba] + 0xc) = *(float *)(param_1[0xba] + 0xc) - local_60;
  }
  FUN_00421b6c((int)param_1);
  puVar2 = (uint *)(param_1 + 0x1f8);
  FUN_0043ade4(puVar2,param_1[0x73]);
  FUN_0043ade4((uint *)(param_1 + 0x1fb),param_1[0x72]);
  FUN_0043ade4((uint *)(param_1 + 0x1fe),param_1[0x71]);
  FUN_0043ade4((uint *)(param_1 + 0x201),param_1[0x75]);
  FUN_0043ade4((uint *)(param_1 + 0x204),param_2);
  fVar4 = FUN_0043ae47(puVar2);
  local_64 = (float)fVar4;
  fVar4 = FUN_0043ae0b((uint *)(param_1 + 0x1fe));
  local_68 = (float)fVar4;
  fVar4 = FUN_0043ae0b(puVar2);
  local_6c = (float)fVar4;
  fVar4 = FUN_0043ae0b((uint *)(param_1 + 0x201));
  local_70 = (float)fVar4;
  fVar4 = FUN_0043ae0b((uint *)(param_1 + 0x204));
  local_74 = (float)fVar4;
  FUN_0040a7f4(param_1 + 0x77,(undefined4 *)&DAT_004e0fd4);
  if (_DAT_004ab9d4 < local_74) {
    param_1[0x79] = (int)((local_64 - (float)param_1[0x207]) / local_74);
    param_1[0x78] = (int)((local_6c - (float)param_1[0x20a]) / local_74);
    param_1[0x77] = (int)((local_68 - (float)param_1[0x208]) / local_74);
    param_1[0x7b] = (int)((local_70 - (float)param_1[0x209]) / local_74);
  }
  param_1[0x207] = (int)local_64;
  param_1[0x20a] = (int)local_6c;
  param_1[0x208] = (int)local_68;
  param_1[0x209] = (int)local_70;
  FUN_00421b2c((int)param_1);
  return;
}



/* @004abb40 file=? name=FUN_004abb40 */

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

void __cdecl
FUN_004abb40(int param_1,float param_2,int *param_3,undefined4 param_4,undefined4 *param_5)

{
  int *piVar1;
  int iVar2;
  float10 fVar3;
  undefined4 local_17c;
  undefined4 local_178;
  undefined4 local_174;
  undefined4 local_170 [2];
  undefined4 local_168;
  undefined4 local_164;
  undefined4 local_160 [2];
  int local_158;
  uint local_154;
  undefined4 local_150;
  undefined4 local_14c;
  undefined4 local_148;
  undefined4 local_144;
  undefined4 local_140;
  undefined4 local_13c;
  undefined4 local_138;
  undefined4 local_134;
  undefined4 local_130;
  undefined4 local_12c;
  undefined4 local_128;
  undefined4 local_124;
  undefined4 local_120;
  undefined4 local_11c;
  undefined4 local_118;
  undefined4 local_114;
  undefined4 local_110;
  undefined4 local_10c;
  undefined4 local_108;
  undefined4 local_104;
  undefined4 local_100;
  undefined4 local_fc;
  undefined4 local_f8;
  undefined4 local_f4;
  undefined4 local_f0;
  undefined4 local_ec;
  float local_e8;
  float local_e4;
  float local_e0;
  undefined4 local_dc;
  undefined4 local_d8;
  undefined4 local_d4;
  undefined4 local_d0 [2];
  undefined4 local_c8;
  undefined4 local_c4;
  undefined4 local_c0 [2];
  int local_b8;
  uint local_b4;
  undefined4 local_b0;
  undefined4 local_ac;
  undefined4 local_a8;
  undefined4 local_a4;
  undefined4 local_a0;
  undefined4 local_9c;
  undefined4 local_98;
  undefined4 local_94;
  undefined4 local_90;
  undefined4 local_8c;
  undefined4 local_88;
  undefined4 local_84;
  undefined4 local_80;
  undefined4 local_7c;
  undefined4 local_78;
  undefined4 local_74;
  undefined4 local_70;
  undefined4 local_6c;
  undefined4 local_68;
  undefined4 local_64;
  undefined4 local_60;
  undefined4 local_5c;
  undefined4 local_58;
  undefined4 local_54;
  undefined4 local_50;
  undefined4 local_4c;
  float local_48 [3];
  float local_3c;
  float local_38;
  float local_34;
  undefined4 *local_30;
  uint local_2c;
  int *local_28;
  undefined4 *local_24;
  int local_20;
  undefined4 *local_1c;
  int *local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  iVar2 = (**(code **)(*(int *)(*(int *)(param_1 + 0x2e8) + 0x18) + 0x1c))
                    (*(int *)(param_1 + 0x2e8),param_3,param_1 + 500,
                     *(undefined4 *)(param_1 + 0x2f8),param_5 + 5,&local_10);
  if (iVar2 != 0) {
    if (param_2 < local_10) {
      local_10 = param_2;
    }
    local_14 = local_10 / param_2;
    local_c = *(float *)(param_1 + 0x244);
    local_8 = *(float *)(param_1 + 0x240);
    piVar1 = *(int **)(*param_3 + 0x1c);
    fVar3 = FUN_00422ff8(param_1,param_4,param_2,local_14,(float *)(param_5 + 5),&local_c,
                         *(float *)(param_1 + 0x248),&local_8);
    param_5[1] = (float)fVar3;
    if ((piVar1 != (int *)0x0) && (iVar2 = FUN_0041a1a4(*(int *)piVar1[3],0x4e4518), iVar2 != 0)) {
      local_18 = piVar1;
      (**(code **)(*piVar1 + 0x20))(local_48,piVar1);
      FUN_00408644(&local_3c,(float *)(param_1 + 500),local_48);
      if (local_34 * (float)param_5[7] + local_38 * (float)param_5[6] + local_3c * (float)param_5[5]
          < _DAT_004ac044) {
        return;
      }
      if (local_18[1] == 0xbb9) {
        FUN_0041db7c((int)&local_78);
        local_1c = param_5;
        local_78 = *param_5;
        local_74 = param_5[1];
        local_4c = param_5[0xb];
        FUN_00408440(&local_70,param_5 + 2);
        FUN_00408440(&local_64,local_1c + 5);
        FUN_00408440(&local_58,local_1c + 8);
        local_20 = DAT_0050b9ac;
        local_24 = (undefined4 *)(param_1 + 0x184);
        local_dc = 100;
        local_d8 = 0x12;
        local_d4 = 1;
        FUN_00420ea4(local_d0,(undefined4 *)&DAT_00522524);
        local_c8 = 0;
        local_c4 = 0;
        FUN_00420ea4(local_c0,local_24);
        local_b8 = local_20;
        local_b4 = (uint)(local_20 < 0);
        local_b0 = local_78;
        local_ac = local_74;
        local_a8 = local_70;
        local_a4 = local_6c;
        local_a0 = local_68;
        local_9c = local_64;
        local_98 = local_60;
        local_94 = local_5c;
        local_90 = local_58;
        local_8c = local_54;
        local_88 = local_50;
        local_84 = local_4c;
        local_80 = 0xffffffff;
        local_7c = 1;
        (**(code **)(*local_18 + 0xc))(local_18,&local_dc);
      }
    }
    if ((piVar1 != (int *)0x0) && (iVar2 = FUN_0041a1a4(*(int *)piVar1[3],0x4e7038), iVar2 != 0)) {
      local_2c = piVar1[10] & 0x8000;
      local_28 = piVar1;
      FUN_00408644(&local_e8,(float *)(param_1 + 500),(float *)&DAT_004e0f74);
      if (local_e0 * (float)param_5[7] + local_e4 * (float)param_5[6] + local_e8 * (float)param_5[5]
          < _DAT_004ac044) {
        return;
      }
      FUN_0041db7c((int)&local_118);
      local_118 = *param_5;
      local_114 = param_5[1];
      local_ec = param_5[0xb];
      FUN_00408440(&local_110,param_5 + 2);
      FUN_00408440(&local_104,param_5 + 5);
      FUN_00408440(&local_f8,param_5 + 8);
      iVar2 = DAT_0050b9ac;
      local_30 = (undefined4 *)(param_1 + 0x184);
      local_17c = 100;
      local_178 = 0x12;
      local_174 = 1;
      FUN_00420ea4(local_170,(undefined4 *)&DAT_00522524);
      local_168 = 0;
      local_164 = 0;
      FUN_00420ea4(local_160,local_30);
      local_158 = iVar2;
      local_154 = (uint)(iVar2 < 0);
      local_150 = local_118;
      local_14c = local_114;
      local_148 = local_110;
      local_144 = local_10c;
      local_140 = local_108;
      local_13c = local_104;
      local_138 = local_100;
      local_134 = local_fc;
      local_130 = local_f8;
      local_12c = local_f4;
      local_128 = local_f0;
      local_124 = local_ec;
      local_120 = 0xffffffff;
      local_11c = 1;
      (**(code **)(*local_28 + 0xc))(local_28,&local_17c);
      if (local_2c == 0) {
        param_5[1] = 0x3aa137f4;
      }
    }
    if (local_c == _DAT_004ac048) {
      if ((local_8 == _DAT_004ac048) && (*(int *)(param_1 + 0x44c) == 0)) {
        *(undefined4 *)(param_1 + 0x44c) = 2;
      }
    }
    else {
      *(undefined4 *)(param_1 + 0x44c) = 1;
    }
  }
  return;
}



/* @004ac04c file=? name=FUN_004ac04c */

void __cdecl FUN_004ac04c(int param_1)

{
  *(undefined4 *)(*(int *)(param_1 + 0x2ec) + 0xc) = *(undefined4 *)(param_1 + 0x51c);
  return;
}



/* @004ac064 file=? name=FUN_004ac064 */

void __cdecl FUN_004ac064(int param_1)

{
  *(undefined4 *)(*(int *)(param_1 + 0x2ec) + 0xc) = *(undefined4 *)(param_1 + 0x518);
  return;
}



/* @004ac07c file=? name=FUN_004ac07c */

float10 __cdecl FUN_004ac07c(int *param_1,undefined4 param_2)

{
  float fVar1;
  
  fVar1 = *(float *)(param_1[0x38] + 0x158);
  (**(code **)(*param_1 + 0x24))(param_1,param_2);
  return (float10)(*(float *)(param_1[0x38] + 0x158) - fVar1);
}



/* @004ac0bc file=? name=FUN_004ac0bc */

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

void __cdecl FUN_004ac0bc(int *param_1,undefined4 param_2)

{
  (**(code **)(*(int *)param_1[0x38] + 0x18))((int *)param_1[0x38],param_2);
  if (_DAT_004ac140 <= *(float *)(param_1[0x38] + 0x158)) {
    FUN_0041bbd8((int)(param_1 + 0xb),1);
    if (param_1[0x41] != 0) {
      (**(code **)(*param_1 + 0x34))(param_1);
    }
    *(undefined4 *)(param_1[0x38] + 0x158) = 0x3f800000;
    if (param_1[0x39] != 0) {
      FUN_0041bbd8(param_1[0x34] + 0x2c,9);
    }
  }
  return;
}



/* @004ac144 file=? name=FUN_004ac144 */

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

undefined4 __cdecl FUN_004ac144(int param_1)

{
  if (_DAT_004ac18c <= *(float *)(*(int *)(param_1 + 0xe0) + 0x158)) {
    return 1;
  }
  if (_DAT_004ac190 < *(float *)(*(int *)(param_1 + 0xe0) + 0x158)) {
    return 2;
  }
  return 0;
}



/* @004ac194 file=? name=FUN_004ac194 */

undefined4 __cdecl FUN_004ac194(char *param_1,undefined4 *param_2)

{
  int iVar1;
  undefined **ppuVar2;
  
  ppuVar2 = &PTR_s_Destroyed_0050de74;
  while( true ) {
    if (*ppuVar2 == (char *)0x0) {
      return 0;
    }
    iVar1 = FUN_004d4b58(param_1,*ppuVar2);
    if (iVar1 == 0) break;
    ppuVar2 = ppuVar2 + 2;
  }
  *param_2 = ppuVar2[1];
  return 1;
}



/* @004ac1d4 file=? name=FUN_004ac1d4 */

undefined4 __cdecl FUN_004ac1d4(int *param_1,int param_2)

{
  undefined4 uVar1;
  
  if (param_2 == 0) {
    if (param_1[0x38] != 0) {
      *(undefined4 *)(param_1[0x38] + 0x158) = 0x3f800000;
    }
    FUN_0041bbd8((int)(param_1 + 0xb),1);
    if (param_1[0x41] != 0) {
      (**(code **)(*param_1 + 0x34))(param_1);
    }
    return 1;
  }
  uVar1 = FUN_0041c800();
  return uVar1;
}



/* @004ac22c file=? name=FUN_004ac22c */

void __cdecl FUN_004ac22c(int *param_1)

{
  int iVar1;
  
  iVar1 = param_1[0x38];
  *(undefined4 *)(iVar1 + 0x158) = 0;
  FUN_0041bbd8(iVar1 + 0x10,0);
  FUN_0041bbd8((int)(param_1 + 0xb),0);
  if (param_1[0x41] != 0) {
    (**(code **)(*param_1 + 0x34))(param_1);
  }
  return;
}



/* @004ac274 file=? name=FUN_004ac274 */

void __cdecl FUN_004ac274(int *param_1,undefined4 *param_2)

{
  int iVar1;
  undefined4 local_dc;
  undefined4 local_d8;
  undefined4 local_d4;
  undefined4 local_d0 [2];
  undefined4 local_c8;
  undefined4 local_c4;
  undefined4 local_c0 [2];
  int local_b8;
  uint local_b4;
  undefined4 local_b0;
  undefined4 local_ac;
  undefined4 local_a8;
  undefined4 local_a4;
  undefined4 local_a0;
  undefined4 local_9c;
  undefined4 local_98;
  undefined4 local_94;
  undefined4 local_90;
  undefined4 local_8c;
  undefined4 local_88;
  undefined4 local_84;
  int local_80;
  uint local_7c;
  undefined4 local_78 [15];
  int local_3c [3];
  int local_30 [4];
  int local_20 [4];
  int *local_10;
  int local_c;
  int *local_8;
  
  FUN_0041bbd8((int)(param_1 + 0xb),2);
  if (param_1[0x41] != 0) {
    (**(code **)(*param_1 + 0x34))(param_1);
  }
  FUN_0041bbd8((int)(param_1 + 0xb),1);
  if (param_1[0x41] != 0) {
    (**(code **)(*param_1 + 0x34))(param_1);
  }
  *(undefined4 *)(param_1[0x38] + 0x158) = 0x3f800000;
  FUN_004acfa9(local_20,(int)param_1,0xffffffff);
  FUN_004ad03a(local_30,0);
  while( true ) {
    iVar1 = (**(code **)(local_20[0] + 0x28))(local_20);
    if (iVar1 == 0) break;
    if (*(int *)(iVar1 + 4) == 0x4e) {
      (**(code **)(local_30[0] + 4))(local_30,iVar1);
    }
  }
  FUN_004ad0a4(local_3c,(int)local_30);
  iVar1 = (**(code **)(local_3c[0] + 0x14))(local_3c);
  param_2[1] = (float)param_2[1] / (float)iVar1;
  FUN_0040aadc(local_78);
  local_8 = (int *)param_1[0x34];
  while( true ) {
    iVar1 = (**(code **)(local_3c[0] + 0x28))(local_3c);
    if (iVar1 == 0) break;
    FUN_004dbb24(&DAT_00524e20,s_ammo_explosion_damaging_0050df61,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,*(char **)(*(int *)(iVar1 + 0x15c) + 8),(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    local_c = param_1[0x36];
    local_10 = local_8 + 0x61;
    iVar1 = *(int *)(iVar1 + 0x13c);
    local_dc = 100;
    local_d8 = 0x12;
    local_d4 = 1;
    FUN_00420ea4(local_d0,(undefined4 *)&DAT_00522524);
    local_c8 = 0;
    local_c4 = 0;
    FUN_00420ea4(local_c0,local_10);
    local_b4 = (uint)(iVar1 < 0);
    local_b0 = *param_2;
    local_ac = param_2[1];
    local_a8 = param_2[2];
    local_a4 = param_2[3];
    local_a0 = param_2[4];
    local_9c = param_2[5];
    local_98 = param_2[6];
    local_94 = param_2[7];
    local_90 = param_2[8];
    local_8c = param_2[9];
    local_88 = param_2[10];
    local_84 = param_2[0xb];
    local_80 = local_c;
    local_7c = (uint)(local_c < 0);
    local_b8 = iVar1;
    (**(code **)(*local_8 + 0xc))(local_8,&local_dc);
  }
  FUN_004ad0e2(local_3c,2);
  FUN_004ad059(local_30,2);
  FUN_004ad00e(local_20,2);
  return;
}



/* @004ac4fc file=? name=FUN_004ac4fc */

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

float10 __cdecl
FUN_004ac4fc(undefined4 param_1,float param_2,float param_3,float param_4,float param_5)

{
  float fVar1;
  
  fVar1 = (_DAT_004ac52c - param_4) / (param_2 - param_3);
  return (float10)fVar1 * (float10)param_5 + (float10)(param_2 - fVar1);
}



/* @004ac530 file=? name=FUN_004ac530 */

undefined4 * __cdecl
FUN_004ac530(undefined4 *param_1,undefined4 param_2,undefined4 param_3,int *param_4,
            undefined4 param_5,undefined4 param_6,undefined4 param_7,undefined4 param_8)

{
  int *piVar1;
  undefined4 *puVar2;
  int iVar3;
  int *local_8;
  
  FUN_0041c5c0(param_1,param_2,param_3,(char *)param_4[2],param_5,param_6);
  *param_1 = &PTR_FUN_0050e210;
  puVar2 = (undefined4 *)FUN_00402298(0x10);
  if (puVar2 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(puVar2);
  }
  param_1[0x3d] = iVar3;
  piVar1 = (int *)(param_1[0x3d] + 0xc);
  *piVar1 = *piVar1 + 1;
  param_1[0x3a] = param_7;
  param_1[0x3b] = param_8;
  param_1[0x39] = 0;
  FUN_00402a98((int *)&local_8,param_1 + 0x3d,&DAT_0050df7a);
  piVar1 = local_8 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_8,3);
  }
  FUN_00408440(param_1 + 0x3e,&DAT_004e0f80);
  param_1[0x42] = 0;
  param_1[0x43] = 0;
  param_1[0x41] = 0;
  param_1[0x44] = 0xffffffff;
  puVar2 = (undefined4 *)FUN_00402298(0x160);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar2 = FUN_0041de1c(puVar2,param_1,0);
  }
  param_1[0x38] = puVar2;
  piVar1 = param_4 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(param_4,3);
  }
  return param_1;
}



/* @004ac644 file=? name=FUN_004ac644 */

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

int * __cdecl
FUN_004ac644(int *param_1,undefined4 param_2,undefined4 param_3,char *param_4,undefined4 param_5,
            int param_6,int param_7)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  char *pcVar5;
  float10 fVar6;
  int *local_10;
  int *local_c;
  undefined4 *local_8;
  
  FUN_0041c52c(param_1,param_2,param_3,param_4,param_5);
  *param_1 = (int)&PTR_FUN_0050e210;
  local_8 = (undefined4 *)FUN_00402298(0x10);
  if (local_8 == (undefined4 *)0x0) {
    iVar3 = 0;
  }
  else {
    iVar3 = FUN_004023f4(local_8);
  }
  param_1[0x3d] = iVar3;
  piVar1 = (int *)(param_1[0x3d] + 0xc);
  *piVar1 = *piVar1 + 1;
  param_1[0x41] = 0;
  FUN_0041bbd8((int)(param_1 + 0xb),0);
  if (param_1[0x41] != 0) {
    (**(code **)(*param_1 + 0x34))();
  }
  param_1[0x3a] = param_6;
  param_1[0x3b] = param_7;
  param_1[0x3c] = (int)param_4;
  param_1[0x44] = -1;
  if (*(int *)(param_4 + 0x48) == 1) {
    param_1[0x39] = 1;
  }
  else {
    param_1[0x39] = 0;
  }
  FUN_00402a98((int *)&local_c,param_1 + 0x3d,param_4 + 0x4c);
  piVar1 = local_c + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_c,3);
  }
  FUN_00408440(param_1 + 0x3e,(undefined4 *)(param_4 + 0xcc));
  param_1[0x41] = *(int *)(param_4 + 0xd8);
  param_1[0x42] = *(int *)(param_4 + 0xe0);
  param_1[0x43] = *(int *)(param_4 + 0xdc);
  puVar4 = (undefined4 *)FUN_00402298(0x160);
  if (puVar4 == (undefined4 *)0x0) {
    puVar4 = (undefined4 *)0x0;
  }
  else {
    puVar4 = FUN_0041de1c(puVar4,param_1,0);
  }
  param_1[0x38] = (int)puVar4;
  FUN_00402a98((int *)&local_10,(int *)(param_1[0x38] + 0x15c),(char *)param_1[0x35]);
  piVar1 = local_10 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(local_10,3);
  }
  iVar3 = 0;
  pcVar5 = param_4 + 0x30;
  *(undefined4 *)(param_1[0x38] + 0x140) = *(undefined4 *)(param_4 + 0x44);
  do {
    *(undefined4 *)(param_1[0x38] + 0x144 + iVar3 * 4) = *(undefined4 *)pcVar5;
    iVar3 = iVar3 + 1;
    pcVar5 = pcVar5 + 4;
  } while (iVar3 < 5);
  iVar3 = 0;
  do {
    fVar6 = FUN_004dcd00((double)(*(float *)(param_1[0x38] + 0x144 + iVar3 * 4) -
                                 _DAT_004ac860 / *(float *)(param_1[0x38] + 0x140)));
    if ((float10)_DAT_004ac864 < fVar6) {
      iVar2 = param_1[0x38];
      *(float *)(iVar2 + 0x144 + iVar3 * 4) =
           _DAT_004ac860 / (*(float *)(iVar2 + 0x144 + iVar3 * 4) * *(float *)(iVar2 + 0x140));
    }
    iVar3 = iVar3 + 1;
  } while (iVar3 < 5);
  return param_1;
}



/* @004ac868 file=? name=FUN_004ac868 */

void __cdecl FUN_004ac868(int *param_1,byte param_2)

{
  int *piVar1;
  undefined4 *puVar2;
  int *piVar3;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e210;
    puVar2 = (undefined4 *)param_1[0x38];
    if (puVar2 != (undefined4 *)0x0) {
      (**(code **)*puVar2)(puVar2,3);
    }
    piVar3 = (int *)param_1[0x3d];
    piVar1 = piVar3 + 3;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 == 0) {
      FUN_004024d8(piVar3,3);
    }
    FUN_0041c648(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ac8c0 file=? name=FUN_004ac8c0 */

void __cdecl FUN_004ac8c0(int param_1)

{
  int iVar1;
  uint uVar2;
  int *piVar3;
  
  iVar1 = *(int *)(param_1 + 0x40);
  if (iVar1 == 0) {
    FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___DefaultState_0050df99,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    return;
  }
  if (iVar1 != 1) {
    if (iVar1 != 2) {
      uVar2 = *(uint *)(param_1 + 0x40);
      FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___UnknownState______0050dfa9,(char *)0x0);
      piVar3 = FUN_004db880(&DAT_00524e20,uVar2);
      FUN_004d9c38(piVar3);
      return;
    }
    FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___Exploding_0050df8c,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
    return;
  }
  FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s___Destroyed_0050df7f,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  return;
}



/* @004ac9c8 file=? name=FUN_004ac9c8 */

bool __cdecl FUN_004ac9c8(int param_1)

{
  return *(int *)(*(int *)(*(int *)(param_1 + 0xd0) + 400) + 0x274) == 0;
}



/* @004ac9ec file=? name=FUN_004ac9ec */

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

undefined4 __cdecl
FUN_004ac9ec(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  char *pcVar1;
  char cVar2;
  int iVar3;
  undefined4 uVar4;
  char *pcVar5;
  uint uVar6;
  uint uVar7;
  char *pcVar8;
  bool bVar9;
  float local_20;
  float local_1c;
  char *local_18;
  char *local_14;
  char *local_10;
  char *local_c;
  int local_8;
  
  iVar3 = FUN_0041c684(param_1,param_2,param_3,param_4,param_5,param_6);
  if (iVar3 == 0) {
    uVar4 = 0;
  }
  else {
    param_4[0x24] = -0x1c;
    param_4[0x25] = '\0';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x45;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xe0] = '\0';
      param_4[0xe1] = '\0';
      param_4[0xe2] = -0x80;
      param_4[0xe3] = -0x41;
      local_8 = 0;
      pcVar5 = param_4 + 0x30;
      do {
        pcVar5[0] = '\0';
        pcVar5[1] = '\0';
        pcVar5[2] = -0x80;
        pcVar5[3] = -0x41;
        local_8 = local_8 + 1;
        pcVar5 = pcVar5 + 4;
      } while (local_8 < 5);
      param_4[0x48] = -1;
      param_4[0x49] = -1;
      param_4[0x4a] = -1;
      param_4[0x4b] = -1;
      iVar3 = 0;
      pcVar5 = param_4 + 0x4c;
      do {
        *pcVar5 = '\0';
        iVar3 = iVar3 + 1;
        pcVar5 = pcVar5 + 1;
      } while (iVar3 < 0x80);
      *(undefined4 *)(param_4 + 0x4c) = DAT_0050dfc0;
      param_4[0x50] = DAT_0050dfc4;
      local_c = param_4 + 0xcc;
      FUN_00408440((undefined4 *)local_c,&DAT_004e0f80);
      param_4[0x44] = '\0';
      param_4[0x45] = '\0';
      param_4[0x46] = -0x80;
      param_4[0x47] = -0x41;
      param_4[0xd8] = '\0';
      param_4[0xd9] = '\0';
      param_4[0xda] = '\0';
      param_4[0xdb] = '\0';
      param_4[0xdc] = '\0';
      param_4[0xdd] = '\0';
      param_4[0xde] = '\0';
      param_4[0xdf] = '\0';
    }
    FUN_00404190(param_5,param_3,s_PrintSimulationState_0050dfc5,(undefined4 *)(param_4 + 0xd8));
    FUN_00404118(param_5,param_3,s_CollisionCriticalHitWeight_0050dfda,(float *)(param_4 + 0xdc));
    local_10 = s_Unspecified_0050dff5;
    FUN_00404088(param_5,param_3,s_VideoObjectName_0050e001,&local_10);
    pcVar8 = s_Unspecified_0050e011;
    pcVar5 = local_10;
    do {
      bVar9 = *pcVar5 == *pcVar8;
      if (!bVar9) break;
      if (*pcVar5 == '\0') goto LAB_004acb51;
      pcVar1 = pcVar5 + 1;
      bVar9 = *pcVar1 == pcVar8[1];
      if (!bVar9) break;
      pcVar5 = pcVar5 + 2;
      pcVar8 = pcVar8 + 2;
      bVar9 = *pcVar1 == '\0';
    } while (!bVar9);
    if (!bVar9) {
      uVar6 = 0xffffffff;
      pcVar5 = local_10;
      do {
        pcVar8 = pcVar5;
        if (uVar6 == 0) break;
        uVar6 = uVar6 - 1;
        pcVar8 = pcVar5 + 1;
        cVar2 = *pcVar5;
        pcVar5 = pcVar8;
      } while (cVar2 != '\0');
      uVar6 = ~uVar6;
      pcVar5 = pcVar8 + -uVar6;
      pcVar8 = param_4 + 0x4c;
      for (uVar7 = uVar6 >> 2; uVar7 != 0; uVar7 = uVar7 - 1) {
        *(undefined4 *)pcVar8 = *(undefined4 *)pcVar5;
        pcVar5 = pcVar5 + 4;
        pcVar8 = pcVar8 + 4;
      }
      for (uVar6 = uVar6 & 3; uVar6 != 0; uVar6 = uVar6 - 1) {
        *pcVar8 = *pcVar5;
        pcVar5 = pcVar5 + 1;
        pcVar8 = pcVar8 + 1;
      }
    }
LAB_004acb51:
    local_14 = s_Unspecified_0050e01d;
    iVar3 = FUN_00404088(param_5,param_3,s_VitalSubsystem_0050e029,&local_14);
    if ((iVar3 == 0) && (*(int *)(param_4 + 0x48) == -1)) {
      FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_missing_VitalSubsystem__0050e038,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      uVar4 = 0;
    }
    else {
      pcVar8 = s_Unspecified_0050e052;
      pcVar5 = local_14;
      do {
        if (*pcVar5 != *pcVar8) goto LAB_004acbd7;
        bVar9 = true;
        if (*pcVar5 == '\0') break;
        pcVar1 = pcVar5 + 1;
        if (*pcVar1 != pcVar8[1]) goto LAB_004acbd7;
        pcVar5 = pcVar5 + 2;
        pcVar8 = pcVar8 + 2;
        bVar9 = *pcVar1 == '\0';
      } while (!bVar9);
      if (!bVar9) {
LAB_004acbd7:
        pcVar8 = &DAT_0050e05e;
        pcVar5 = local_14;
        do {
          if (*pcVar5 != *pcVar8) goto LAB_004acc06;
          bVar9 = true;
          if (*pcVar5 == '\0') break;
          pcVar1 = pcVar5 + 1;
          if (*pcVar1 != pcVar8[1]) goto LAB_004acc06;
          pcVar5 = pcVar5 + 2;
          pcVar8 = pcVar8 + 2;
          bVar9 = *pcVar1 == '\0';
        } while (!bVar9);
        if (bVar9) {
          param_4[0x48] = '\x01';
          param_4[0x49] = '\0';
          param_4[0x4a] = '\0';
          param_4[0x4b] = '\0';
        }
        else {
LAB_004acc06:
          pcVar8 = s_False_0050e063;
          pcVar5 = local_14;
          do {
            if (*pcVar5 != *pcVar8) goto LAB_004acc33;
            bVar9 = true;
            if (*pcVar5 == '\0') break;
            pcVar1 = pcVar5 + 1;
            if (*pcVar1 != pcVar8[1]) goto LAB_004acc33;
            pcVar5 = pcVar5 + 2;
            pcVar8 = pcVar8 + 2;
            bVar9 = *pcVar1 == '\0';
          } while (!bVar9);
          if (!bVar9) {
LAB_004acc33:
            FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
            FUN_004dbb24(&DAT_00524e20,s___VitalSubsystem_must_be_True_or_0050e069,(char *)0x0);
            FUN_004d9c38(&DAT_00524e20);
            return 0;
          }
          param_4[0x48] = '\0';
          param_4[0x49] = '\0';
          param_4[0x4a] = '\0';
          param_4[0x4b] = '\0';
        }
      }
      iVar3 = FUN_00404088(param_5,param_3,s_SiteOffset_0050e092,&local_18);
      if (iVar3 != 0) {
        FUN_00408944(local_18,(float *)(param_4 + 0xcc));
      }
      iVar3 = FUN_00404118(param_5,param_3,s_WeaponDamagePoints_0050e09d,(float *)(param_4 + 0x44));
      if ((iVar3 == 0) && (_DAT_004aceec == *(float *)(param_4 + 0x44))) {
        FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,s_Must_have_a_WeaponDamagePoints_0050e0b0,(char *)0x0);
        FUN_004d9c38(&DAT_00524e20);
        uVar4 = 0;
      }
      else {
        iVar3 = FUN_00404118(param_5,param_3,s_CriticalHitScoreBonus_0050e0d0,
                             (float *)(param_4 + 0xe0));
        if ((iVar3 == 0) && (_DAT_004aceec == *(float *)(param_4 + 0xe0))) {
          FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
          FUN_004dbb24(&DAT_00524e20,s_Must_have_a_CriticalHitScoreBonu_0050e0e6,(char *)0x0);
          FUN_004d9c38(&DAT_00524e20);
          uVar4 = 0;
        }
        else {
          local_1c = _DAT_004acef0 / *(float *)(param_4 + 0x44);
          local_20 = -1.0;
          iVar3 = FUN_00404118(param_5,param_3,s_CollisionDamagePoints_0050e109,&local_20);
          if ((iVar3 == 0) && (*(float *)(param_4 + 0x30) == _DAT_004aceec)) {
            *(float *)(param_4 + 0x30) = local_1c;
          }
          if (local_20 != _DAT_004aceec) {
            *(float *)(param_4 + 0x30) = _DAT_004acef0 / local_20;
          }
          local_20 = -1.0;
          iVar3 = FUN_00404118(param_5,param_3,s_BallisticDamagePoints_0050e11f,&local_20);
          if ((iVar3 == 0) && (*(float *)(param_4 + 0x34) == _DAT_004aceec)) {
            *(float *)(param_4 + 0x34) = local_1c;
          }
          if (local_20 != _DAT_004aceec) {
            *(float *)(param_4 + 0x34) = _DAT_004acef0 / local_20;
          }
          local_20 = -1.0;
          iVar3 = FUN_00404118(param_5,param_3,s_ExplosiveDamagePoints_0050e135,&local_20);
          if ((iVar3 == 0) && (*(float *)(param_4 + 0x38) == _DAT_004aceec)) {
            *(float *)(param_4 + 0x38) = local_1c;
          }
          if (local_20 != _DAT_004aceec) {
            *(float *)(param_4 + 0x38) = _DAT_004acef0 / local_20;
          }
          local_20 = -1.0;
          iVar3 = FUN_00404118(param_5,param_3,s_LaserDamagePoints_0050e14b,&local_20);
          if ((iVar3 == 0) && (*(float *)(param_4 + 0x3c) == _DAT_004aceec)) {
            *(float *)(param_4 + 0x3c) = local_1c;
          }
          if (local_20 != _DAT_004aceec) {
            *(float *)(param_4 + 0x3c) = _DAT_004acef0 / local_20;
          }
          local_20 = -1.0;
          iVar3 = FUN_00404118(param_5,param_3,s_EnergyDamagePoints_0050e15d,&local_20);
          if ((iVar3 == 0) && (*(float *)(param_4 + 0x40) == _DAT_004aceec)) {
            *(float *)(param_4 + 0x40) = local_1c;
          }
          if (local_20 != _DAT_004aceec) {
            *(float *)(param_4 + 0x40) = _DAT_004acef0 / local_20;
          }
          uVar4 = 1;
        }
      }
    }
  }
  return uVar4;
}



/* @004acfa9 file=? name=FUN_004acfa9 */

undefined4 * __cdecl FUN_004acfa9(undefined4 *param_1,int param_2,undefined4 param_3)

{
  FUN_00415f30(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050e1c8;
  return param_1;
}



/* @004acfcc file=? name=FUN_004acfcc */

undefined4 * __cdecl FUN_004acfcc(undefined4 *param_1,int param_2,undefined4 param_3)

{
  FUN_00415f30(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0050e1c8;
  return param_1;
}



/* @004acfef file=? name=FUN_004acfef */

undefined4 * __cdecl FUN_004acfef(undefined4 *param_1,int param_2)

{
  FUN_00415f60(param_1,param_2);
  *param_1 = &PTR_FUN_0050e1c8;
  return param_1;
}



/* @004ad00e file=? name=FUN_004ad00e */

void __cdecl FUN_004ad00e(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e1c8;
    FUN_00415f90(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad03a file=? name=FUN_004ad03a */

undefined4 * __cdecl FUN_004ad03a(undefined4 *param_1,undefined4 param_2)

{
  FUN_00417be0(param_1,param_2);
  *param_1 = &PTR_FUN_0050e1c0;
  return param_1;
}



/* @004ad059 file=? name=FUN_004ad059 */

void __cdecl FUN_004ad059(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e1c0;
    FUN_00417c0c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad085 file=? name=FUN_004ad085 */

undefined4 * __cdecl FUN_004ad085(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050e170;
  return param_1;
}



/* @004ad0a4 file=? name=FUN_004ad0a4 */

undefined4 * __cdecl FUN_004ad0a4(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050e170;
  return param_1;
}



/* @004ad0c3 file=? name=FUN_004ad0c3 */

undefined4 * __cdecl FUN_004ad0c3(undefined4 *param_1,int param_2)

{
  FUN_00417d28(param_1,param_2);
  *param_1 = &PTR_FUN_0050e170;
  return param_1;
}



/* @004ad0e2 file=? name=FUN_004ad0e2 */

void __cdecl FUN_004ad0e2(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e170;
    FUN_00417d54(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad10e file=? name=FUN_004ad10e */

void __cdecl FUN_004ad10e(int *param_1,undefined4 param_2)

{
  (**(code **)(*param_1 + 0x28))(param_1,param_2);
  return;
}



/* @004ad124 file=? name=FUN_004ad124 */

undefined4 * __cdecl FUN_004ad124(undefined4 *param_1,undefined4 param_2)

{
  undefined4 *puVar1;
  int iVar2;
  
  FUN_00415e90(param_1,1);
  *param_1 = &PTR_FUN_0050e3d0;
  FUN_004de998(param_1 + 3,0x10,7,1,FUN_004ad619);
  param_1[0x1f] = param_2;
  iVar2 = 0;
  puVar1 = param_1 + 3;
  do {
    *puVar1 = 0;
    puVar1[2] = 0;
    puVar1[1] = 0;
    puVar1[3] = 0;
    iVar2 = iVar2 + 1;
    puVar1 = puVar1 + 4;
  } while (iVar2 < 7);
  return param_1;
}



/* @004ad180 file=? name=FUN_004ad180 */

void __cdecl FUN_004ad180(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e3d0;
    FUN_00415ed8(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_00402f98(0x50e248,param_1);
    }
  }
  return;
}



/* @004ad1b8 file=? name=FUN_004ad1b8 */

void __cdecl FUN_004ad1b8(int *param_1,byte param_2)

{
  void *this;
  int local_10 [3];
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e3a0;
    FUN_004ad68b(local_10,(int)(param_1 + 0x39));
    FUN_00417858(this,local_10,1);
    FUN_004ad6c9(local_10,2);
    FUN_004ad640(param_1 + 0x39,2);
    FUN_0041c648(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad228 file=? name=FUN_004ad228 */

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

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  int iVar4;
  
  FUN_0041c52c(param_1,param_2,param_3,param_4,param_5);
  *param_1 = &PTR_FUN_0050e3a0;
  FUN_004ad621(param_1 + 0x39,0);
  if ((*(uint *)(param_2 + 0x28) & 0xc) == 0) {
    param_1[7] = PTR_FUN_0050e2b0;
    param_1[8] = DAT_0050e2b4;
    param_1[9] = DAT_0050e2b8;
    param_1[0x40] = *(undefined4 *)(param_4 + 0x30);
    param_1[0x3d] = *(undefined4 *)(param_4 + 0x34);
    param_1[0x3e] = *(undefined4 *)(param_4 + 0x38);
    param_1[0x3f] = *(undefined4 *)(param_4 + 0x3c);
    for (iVar4 = *(int *)(param_2 + 0x124) + -2; -1 < iVar4; iVar4 = iVar4 + -1) {
      iVar1 = *(int *)(*(int *)(param_2 + 0x128) + iVar4 * 4);
      if (((iVar1 != 0) && (iVar2 = FUN_0041a1a4(**(int **)(iVar1 + 0xc),0x50de2c), iVar2 != 0)) &&
         ((*(byte *)(iVar1 + 0x28) & 8) != 0)) {
        puVar3 = FUN_00402f74(0x50e248);
        if (puVar3 == (undefined4 *)0x0) {
          puVar3 = (undefined4 *)0x0;
        }
        else {
          puVar3 = FUN_004ad124(puVar3,iVar1);
        }
        (**(code **)(param_1[0x39] + 4))(param_1 + 0x39,puVar3);
      }
    }
  }
  else {
    param_1[10] = param_1[10] | 2;
  }
  return param_1;
}



/* @004ad33c file=? name=FUN_004ad33c */

void __cdecl FUN_004ad33c(int param_1)

{
  int iVar1;
  uint *puVar2;
  uint uVar3;
  uint local_64 [7];
  uint local_48 [8];
  int local_28 [3];
  int *local_1c;
  int *local_18;
  int *local_14;
  uint local_10;
  int *local_c;
  int local_8;
  
  local_8 = *(int *)(DAT_004efc94 + 0x38);
  FUN_004ad68b(local_28,param_1 + 0xe4);
  while( true ) {
    iVar1 = (**(code **)(local_28[0] + 0x28))(local_28);
    if (iVar1 == 0) break;
    local_c = *(int **)(iVar1 + 0x7c);
    local_10 = (**(code **)(*local_c + 0x30))(local_c);
    puVar2 = (uint *)(iVar1 + 0xc);
    iVar1 = 0;
    do {
      uVar3 = local_10 & 1;
      if (puVar2[1] != 0) {
        if ((int)puVar2[3] < *(int *)(param_1 + 0x10)) {
          puVar2[1] = 0;
        }
        else {
          uVar3 = *puVar2;
        }
      }
      if (uVar3 != *puVar2) {
        if (uVar3 == 0) {
          local_1c = *(int **)(param_1 + 0xd0);
          FUN_004366b8(local_64,(int)local_1c,local_c,iVar1);
          FUN_004364e4(local_8,local_1c,local_64);
        }
        else {
          local_14 = local_c;
          local_18 = *(int **)(param_1 + 0xd0);
          FUN_00436688(local_48,(int)local_18,local_c,iVar1,*(undefined4 *)(param_1 + 0x100));
          FUN_004364e4(local_8,local_18,local_48);
        }
      }
      *puVar2 = uVar3;
      iVar1 = iVar1 + 1;
      local_10 = (int)local_10 >> 1;
      puVar2 = puVar2 + 4;
    } while (iVar1 < 7);
  }
  FUN_004ad6c9(local_28,2);
  return;
}



/* @004ad470 file=? name=FUN_004ad470 */

void __cdecl FUN_004ad470(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e280);
  return;
}



/* @004ad48c file=? name=FUN_004ad48c */

undefined4 __cdecl
FUN_004ad48c(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  char *local_8;
  
  iVar1 = FUN_0041c684(param_1,param_2,param_3,param_4,param_5,param_6);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    param_4[0x24] = '@';
    param_4[0x25] = '\0';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x24;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    param_4[0x30] = -1;
    param_4[0x31] = -1;
    param_4[0x32] = -1;
    param_4[0x33] = -1;
    param_4[0x34] = '\0';
    param_4[0x35] = '\0';
    param_4[0x36] = '\0';
    param_4[0x37] = '\0';
    param_4[0x38] = '\0';
    param_4[0x39] = '\0';
    param_4[0x3a] = '\0';
    param_4[0x3b] = '\0';
    param_4[0x3c] = '\0';
    param_4[0x3d] = '\0';
    param_4[0x3e] = '\0';
    param_4[0x3f] = '\0';
    if ((*(int *)(param_4 + 0x30) == -1) &&
       (iVar1 = FUN_00404088(param_5,param_3,s_AlarmModel_0050e322,&local_8), iVar1 == 0)) {
      return 1;
    }
    puVar3 = (undefined4 *)FUN_00406ff8(param_7,local_8,1,-1);
    if (puVar3 == (undefined4 *)0x0) {
      FUN_004dbb24(&DAT_00524e20,param_3,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s_couldn_t_locate_0050e32d,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_8,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s__mod_0050e33f,(char *)0x0);
      uVar2 = 0;
    }
    else {
      uVar2 = 1;
      *(undefined4 *)(param_4 + 0x30) = *puVar3;
    }
  }
  return uVar2;
}



/* @004ad619 file=? name=FUN_004ad619 */

undefined4 __cdecl FUN_004ad619(undefined4 param_1)

{
  return param_1;
}



/* @004ad621 file=? name=FUN_004ad621 */

undefined4 * __cdecl FUN_004ad621(undefined4 *param_1,undefined4 param_2)

{
  FUN_00417be0(param_1,param_2);
  *param_1 = &PTR_FUN_0050e398;
  return param_1;
}



/* @004ad640 file=? name=FUN_004ad640 */

void __cdecl FUN_004ad640(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e398;
    FUN_00417c0c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad66c file=? name=FUN_004ad66c */

undefined4 * __cdecl FUN_004ad66c(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050e348;
  return param_1;
}



/* @004ad68b file=? name=FUN_004ad68b */

undefined4 * __cdecl FUN_004ad68b(undefined4 *param_1,int param_2)

{
  FUN_00417d00(param_1,param_2);
  *param_1 = &PTR_FUN_0050e348;
  return param_1;
}



/* @004ad6aa file=? name=FUN_004ad6aa */

undefined4 * __cdecl FUN_004ad6aa(undefined4 *param_1,int param_2)

{
  FUN_00417d28(param_1,param_2);
  *param_1 = &PTR_FUN_0050e348;
  return param_1;
}



/* @004ad6c9 file=? name=FUN_004ad6c9 */

void __cdecl FUN_004ad6c9(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050e348;
    FUN_00417d54(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ad748 file=? name=FUN_004ad748 */

void __cdecl FUN_004ad748(int *param_1,undefined4 param_2)

{
  FUN_004ac0bc(param_1,param_2);
  return;
}



/* @004ad760 file=? name=FUN_004ad760 */

void __cdecl FUN_004ad760(int *param_1)

{
  param_1[0x45] = param_1[0x4f];
  param_1[0x56] = (int)((float)param_1[0x4f] * (float)param_1[0x55]);
  param_1[0x4b] = param_1[0x4a];
  param_1[0x4c] = 0;
  param_1[0x4d] = 1;
  param_1[0x57] = 0x3f800000;
  FUN_004ad884((int)param_1);
  FUN_004ad7f0((int)param_1);
  param_1[0x4e] = 0;
  FUN_004ac22c(param_1);
  return;
}



/* @004ad7d4 file=? name=FUN_004ad7d4 */

undefined4 __cdecl FUN_004ad7d4(int param_1)

{
  return *(undefined4 *)(*(int *)(*(int *)(param_1 + 0xd0) + 400) + 0x260);
}



/* @004ad7f0 file=? name=FUN_004ad7f0 */

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

void __cdecl FUN_004ad7f0(int param_1)

{
  float fVar1;
  float fVar2;
  float10 fVar3;
  
  *(float *)(param_1 + 0x1cc) = *(float *)(param_1 + 0x114) * *(float *)(param_1 + 300);
  fVar1 = (float)(_DAT_004ad870 * (float10)*(float *)(param_1 + 0x1cc));
  fVar2 = _DAT_004ad87c;
  if ((_DAT_004ad87c <= fVar1) && (fVar2 = fVar1, _DAT_004ad880 < fVar1)) {
    fVar2 = _DAT_004ad880;
  }
  FUN_0043ade4((uint *)(param_1 + 0x144),fVar2);
  fVar3 = FUN_0043ae0b((uint *)(param_1 + 0x144));
  *(float *)(param_1 + 0x120) = (float)fVar3;
  return;
}



/* @004ad884 file=? name=FUN_004ad884 */

void __cdecl FUN_004ad884(int param_1)

{
  int iVar1;
  
  iVar1 = 0;
  do {
    FUN_0043ade4((uint *)(param_1 + 0x144),0);
    iVar1 = iVar1 + 1;
  } while (iVar1 < 0xf);
  return;
}



/* @004ad8ac file=? name=FUN_004ad8ac */

void __cdecl FUN_004ad8ac(int param_1,float param_2)

{
  int iVar1;
  float10 fVar2;
  int iVar3;
  
  iVar3 = param_1 + 0x164;
  iVar1 = FUN_00417ab4(iVar3);
  if ((iVar1 != 0) && (*(int *)(param_1 + 0x134) != 0)) {
    fVar2 = FUN_004ad9ec((short)iVar3,param_1,iVar1,param_2);
    *(float *)(iVar1 + 0x1c8) = (float)fVar2 + *(float *)(iVar1 + 0x1c8);
    *(float *)(param_1 + 0x1c8) = -(float)fVar2 + *(float *)(param_1 + 0x1c8);
    FUN_004ada94(param_1,param_2);
  }
  return;
}



/* @004ad924 file=? name=FUN_004ad924 */

void __cdecl FUN_004ad924(int *param_1,float param_2)

{
  int iVar1;
  
  iVar1 = FUN_004ad7d4((int)param_1);
  if (iVar1 != 0) {
    param_1[0x56] = (int)((float)param_1[0x72] + (float)param_1[0x56]);
    param_1[0x45] = (int)((float)param_1[0x56] / (float)param_1[0x55]);
    FUN_004ad7f0((int)param_1);
    param_1[0x72] = 0;
    FUN_004ad8ac((int)param_1,param_2);
  }
  iVar1 = FUN_004ad7d4((int)param_1);
  if (iVar1 != 0) {
    FUN_004adbf8(param_1,param_2);
  }
  if ((float)param_1[0x47] < (float)param_1[0x45]) {
    FUN_0041bbd8((int)(param_1 + 0x5c),2);
    return;
  }
  if ((float)param_1[0x46] < (float)param_1[0x45]) {
    FUN_0041bbd8((int)(param_1 + 0x5c),1);
    return;
  }
  FUN_0041bbd8((int)(param_1 + 0x5c),0);
  return;
}



/* @004ad9ec file=? name=FUN_004ad9ec */

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

float10 __thiscall FUN_004ad9ec(undefined2 param_1,int param_2,int param_3,float param_4)

{
  float fVar1;
  float fVar2;
  float fVar3;
  float fVar4;
  float fVar5;
  double dVar6;
  float fVar7;
  float fVar8;
  float10 fVar9;
  
  fVar7 = *(float *)(param_2 + 0x154) / *(float *)(param_2 + 0x160);
  fVar8 = fVar7 + *(float *)(param_3 + 0x154);
  fVar1 = *(float *)(param_2 + 0x114);
  fVar2 = *(float *)(param_2 + 0x160);
  fVar3 = *(float *)(param_3 + 0x158);
  fVar4 = *(float *)(param_3 + 0x1c8);
  fVar5 = *(float *)(param_2 + 0x158);
  dVar6 = (double)((-param_4 *
                   *(float *)(param_2 + 0x140) *
                   (*(float *)(param_2 + 300) / *(float *)(param_2 + 0x128)) *
                   *(float *)(param_2 + 0x15c)) / fVar8);
  fVar9 = (float10)FUN_004dca38(param_1,SUB84(dVar6,0),(uint)((ulonglong)dVar6 >> 0x20));
  return (float10)(float)((float10)(fVar1 * fVar2 - (fVar3 + fVar4 + fVar5) / fVar8) *
                          (float10)fVar7 * ((float10)_DAT_004ada90 - fVar9));
}



/* @004ada94 file=? name=FUN_004ada94 */

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

void __cdecl FUN_004ada94(int param_1,float param_2)

{
  float fVar1;
  float fVar2;
  float fVar3;
  float fVar4;
  int iVar5;
  float10 fVar6;
  
  iVar5 = FUN_00417ab4(param_1 + 0x164);
  if ((iVar5 != 0) &&
     (fVar6 = FUN_004dcd00((double)(*(float *)(param_1 + 0x1cc) - *(float *)(iVar5 + 0x1cc))),
     (float10)_DAT_004adbf4 < fVar6)) {
    fVar1 = *(float *)(iVar5 + 0x1cc) / *(float *)(param_1 + 0x114) - *(float *)(param_1 + 300);
    fVar2 = *(float *)(param_1 + 0x128) * param_2;
    if (-fVar2 <= fVar1) {
      if (fVar2 < fVar1) {
        fVar1 = fVar2;
      }
    }
    else {
      fVar1 = -fVar2;
    }
    fVar2 = *(float *)(param_1 + 0x128) - *(float *)(param_1 + 300);
    fVar3 = -*(float *)(param_1 + 300);
    fVar4 = -(*(float *)(iVar5 + 0x128) - *(float *)(iVar5 + 300));
    if ((fVar3 <= fVar1) && (fVar3 = fVar1, fVar2 < fVar1)) {
      fVar3 = fVar2;
    }
    if ((fVar4 <= fVar3) && (fVar4 = fVar3, *(float *)(iVar5 + 300) < fVar3)) {
      fVar4 = *(float *)(iVar5 + 300);
    }
    fVar4 = *(float *)(param_1 + 0x15c) * fVar4;
    *(float *)(param_1 + 300) = fVar4 + *(float *)(param_1 + 300);
    *(float *)(iVar5 + 300) = *(float *)(iVar5 + 300) - fVar4;
  }
  return;
}



/* @004adbf8 file=? name=FUN_004adbf8 */

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

void __cdecl FUN_004adbf8(int *param_1,float param_2)

{
  float fVar1;
  float10 fVar2;
  
  param_1[0x4c] = (int)(*(float *)(param_1[0x38] + 0x158) * (float)param_1[0x48]);
  if ((float)param_1[0x4c] < _DAT_0050e3d8) {
    param_1[0x4c] = 0;
  }
  fVar1 = (float)param_1[0x4c] * param_2;
  if ((float)param_1[0x4b] < fVar1) {
    fVar1 = (float)param_1[0x4b];
  }
  param_1[0x4b] = (int)((float)param_1[0x4b] - fVar1);
  fVar2 = FUN_004dcd00((double)fVar1);
  if ((float10)_DAT_004adcfc < fVar2) {
    fVar2 = (float10)(**(code **)(*param_1 + 0x38))(param_1,fVar1);
    param_1[0x4b] = (int)(float)(fVar2 + (float10)(float)param_1[0x4b]);
  }
  if ((param_1[0x4e] != 0) || ((float)param_1[0x4c] <= _DAT_0050e3d4)) {
    if ((param_1[0x4e] == 1) && ((float)param_1[0x4c] < _DAT_0050e3d8)) {
      param_1[0x4e] = 0;
    }
  }
  else {
    param_1[0x4e] = 1;
  }
  return;
}



/* @004add30 file=? name=FUN_004add30 */

uint __cdecl FUN_004add30(int param_1)

{
  uint uVar1;
  int iVar2;
  
  uVar1 = FUN_004ac144(param_1);
  if (*(int *)(param_1 + 0x184) != 0) {
    uVar1 = uVar1 | 8;
  }
  if (*(int *)(param_1 + 0x138) != 0) {
    iVar2 = FUN_004ad7d4(param_1);
    if (iVar2 != 0) {
      uVar1 = uVar1 | 4;
    }
  }
  return uVar1;
}



/* @004add6c file=? name=FUN_004add6c */

undefined4 __cdecl FUN_004add6c(int *param_1,int param_2)

{
  undefined4 uVar1;
  
  if (param_2 == 1) {
    *(undefined4 *)(param_1[0x38] + 0x158) = 0x3f000000;
    return 1;
  }
  uVar1 = FUN_004ac1d4(param_1,param_2);
  return uVar1;
}



/* @004adda0 file=bt/heat.cpp name=FUN_004adda0 */

int * __cdecl
FUN_004adda0(int *param_1,int param_2,undefined4 param_3,char *param_4,undefined4 param_5,
            int param_6,int param_7)

{
  int iVar1;
  int local_8;
  
  FUN_004ac644(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  *param_1 = (int)&PTR_FUN_0050edc4;
  param_1[0x45] = *(int *)(param_4 + 0xe4);
  param_1[0x46] = *(int *)(param_4 + 0xe8);
  param_1[0x47] = *(int *)(param_4 + 0xec);
  param_1[0x48] = 0;
  param_1[0x49] = 0x3f000000;
  param_1[0x4a] = 0x3f800000;
  param_1[0x4b] = param_1[0x4a];
  param_1[0x4c] = 0;
  param_1[0x4d] = 1;
  param_1[0x4e] = 0;
  param_1[0x4f] = param_1[0x45];
  param_1[0x50] = *(int *)(param_4 + 0xf0);
  FUN_0043ad4f((uint *)(param_1 + 0x51),0xf,0);
  param_1[0x54] = 0x3ecccccd;
  param_1[0x55] = *(int *)(param_4 + 0xf4);
  param_1[0x56] = (int)((float)param_1[0x55] * (float)param_1[0x4f]);
  param_1[0x57] = 0x3f800000;
  param_1[0x58] = 0x3f800000;
  FUN_004af9cf(param_1 + 0x59,0);
  FUN_0041b9ec(param_1 + 0x5c,3);
  param_1[0x72] = 0;
  if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
    param_1[7] = (int)PTR_FUN_0050e4e0;
    param_1[8] = DAT_0050e4e4;
    param_1[9] = DAT_0050e4e8;
  }
  param_1[0x71] = (int)param_4;
  local_8 = 0;
  iVar1 = FUN_0041a1a4(*(int *)param_1[3],0x50e590);
  if (iVar1 == 0) {
    if (*(int *)(param_4 + 0xf8) < *(int *)(param_2 + 0x124)) {
      local_8 = *(int *)(*(int *)(param_2 + 0x128) + *(int *)(param_4 + 0xf8) * 4);
    }
    else {
      FUN_0040385c(s_Bad_subsystem_resource_>heatSink_0050e7c9,s_d__tesla_bt_bt_HEAT_CPP_0050e804,
                   0x25f);
    }
    if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
      if (local_8 == 0) {
        FUN_0040385c(s_Master_heatable_subystem_is_miss_0050e81c,s_d__tesla_bt_bt_HEAT_CPP_0050e859,
                     0x26b);
      }
      else {
        (**(code **)(param_1[0x59] + 4))(param_1 + 0x59,local_8);
      }
    }
    else if (((*(uint *)(param_2 + 0x28) & 0xc) == 4) && (local_8 != 0)) {
      (**(code **)(param_1[0x59] + 4))(param_1 + 0x59,local_8);
    }
  }
  FUN_004ad7f0((int)param_1);
  return param_1;
}



/* @004adfd4 file=? name=FUN_004adfd4 */

void __cdecl FUN_004adfd4(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050edc4;
    FUN_0041baa4(param_1 + 0x5c,2);
    FUN_004af9ee(param_1 + 0x59,2);
    FUN_0043adb5(param_1 + 0x51,2);
    FUN_004ac868(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ae034 file=? name=FUN_004ae034 */

void __cdecl FUN_004ae034(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e3ec);
  return;
}



/* @004ae050 file=? name=FUN_004ae050 */

void __cdecl FUN_004ae050(int param_1)

{
  int iVar1;
  
  FUN_004ac8c0(param_1);
  iVar1 = *(int *)(param_1 + 0x184);
  if (iVar1 == 0) {
    FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___NormalHeat_0050e893,(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  else {
    if (iVar1 == 1) {
      FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___DegradationHeat_0050e880,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      return;
    }
    if (iVar1 == 2) {
      FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___FailureHeat_0050e871,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      return;
    }
  }
  FUN_004dbb24(&DAT_00524e20,*(char **)(param_1 + 0xd4),(char *)0x0);
  FUN_004dbb24(&DAT_00524e20,s_Unknown_Heat_State__0050e8a1,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  return;
}



/* @004ae150 file=? name=FUN_004ae150 */

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

undefined4 __cdecl
FUN_004ae150(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  char *pcVar1;
  int iVar2;
  undefined4 uVar3;
  char *pcVar4;
  char *pcVar5;
  bool bVar6;
  char *local_8;
  
  iVar2 = FUN_004ac9ec(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar2 == 0) {
    uVar3 = 0;
  }
  else {
    param_4[0x24] = -4;
    param_4[0x25] = '\0';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x44;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xe4] = '\0';
      param_4[0xe5] = '\0';
      param_4[0xe6] = -0x80;
      param_4[0xe7] = -0x41;
      param_4[0xe8] = '\0';
      param_4[0xe9] = '\0';
      param_4[0xea] = -0x80;
      param_4[0xeb] = -0x41;
      param_4[0xec] = '\0';
      param_4[0xed] = '\0';
      param_4[0xee] = -0x80;
      param_4[0xef] = -0x41;
      param_4[0xf0] = '\0';
      param_4[0xf1] = '\0';
      param_4[0xf2] = -0x80;
      param_4[0xf3] = -0x41;
      param_4[0xf4] = '\0';
      param_4[0xf5] = '\0';
      param_4[0xf6] = -0x80;
      param_4[0xf7] = -0x41;
      param_4[0xf8] = -1;
      param_4[0xf9] = -1;
      param_4[0xfa] = -1;
      param_4[0xfb] = -1;
    }
    iVar2 = FUN_00404118(param_5,param_3,s_StartingTemperature_0050e8b6,(float *)(param_4 + 0xe4));
    if ((iVar2 == 0) && (_DAT_004ae460 == *(float *)(param_4 + 0xe4))) {
      FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_missing_StartingTemperature__0050e8ca,(char *)0x0);
      uVar3 = 0;
    }
    else {
      iVar2 = FUN_00404118(param_5,param_3,s_DegradationTemperature_0050e8e9,
                           (float *)(param_4 + 0xe8));
      if ((iVar2 == 0) && (_DAT_004ae460 == *(float *)(param_4 + 0xe8))) {
        FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
        FUN_004dbb24((int *)&DAT_00524e68,s_missing_DegradationTemperature__0050e900,(char *)0x0);
        uVar3 = 0;
      }
      else {
        iVar2 = FUN_00404118(param_5,param_3,s_FailureTemperature_0050e922,(float *)(param_4 + 0xec)
                            );
        if ((iVar2 == 0) && (_DAT_004ae460 == *(float *)(param_4 + 0xec))) {
          FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
          FUN_004dbb24((int *)&DAT_00524e68,s_missing_FailureTemperature__0050e935,(char *)0x0);
          uVar3 = 0;
        }
        else {
          iVar2 = FUN_00404118(param_5,param_3,s_ThermalConductance_0050e953,
                               (float *)(param_4 + 0xf0));
          if ((iVar2 == 0) && (_DAT_004ae460 == *(float *)(param_4 + 0xf0))) {
            FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
            FUN_004dbb24((int *)&DAT_00524e68,s_missing_ThermalConductance__0050e966,(char *)0x0);
            uVar3 = 0;
          }
          else {
            iVar2 = FUN_00404118(param_5,param_3,s_ThermalMass_0050e984,(float *)(param_4 + 0xf4));
            if ((iVar2 == 0) && (_DAT_004ae460 == *(float *)(param_4 + 0xf4))) {
              FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
              FUN_004dbb24((int *)&DAT_00524e68,s_missing_ThermalMass__0050e990,(char *)0x0);
              uVar3 = 0;
            }
            else {
              local_8 = s_Unspecified_0050e9a7;
              iVar2 = FUN_00404088(param_5,param_3,s_HeatSink_0050e9b3,&local_8);
              if ((iVar2 == 0) && (*(int *)(param_4 + 0xf8) == -1)) {
                FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
                FUN_004dbb24((int *)&DAT_00524e68,s_missing_HeatSink__0050e9bc,(char *)0x0);
                uVar3 = 0;
              }
              else {
                pcVar5 = s_Unspecified_0050e9d0;
                pcVar4 = local_8;
                do {
                  bVar6 = *pcVar4 == *pcVar5;
                  if (!bVar6) break;
                  if (*pcVar4 == '\0') goto LAB_004ae418;
                  pcVar1 = pcVar4 + 1;
                  bVar6 = *pcVar1 == pcVar5[1];
                  if (!bVar6) break;
                  pcVar4 = pcVar4 + 2;
                  pcVar5 = pcVar5 + 2;
                  bVar6 = *pcVar1 == '\0';
                } while (!bVar6);
                if (!bVar6) {
                  iVar2 = FUN_004215b0(param_5,local_8);
                  *(int *)(param_4 + 0xf8) = iVar2;
                }
LAB_004ae418:
                if (*(int *)(param_4 + 0xf8) < 0) {
                  FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
                  FUN_004dbb24((int *)&DAT_00524e68,s_has_an_invalid_heat_sink__0050e9dc,(char *)0x0
                              );
                  uVar3 = 0;
                }
                else {
                  *(int *)(param_4 + 0xf8) = *(int *)(param_4 + 0xf8) + 2;
                  uVar3 = 1;
                }
              }
            }
          }
        }
      }
    }
  }
  return uVar3;
}



/* @004ae4d8 file=? name=FUN_004ae4d8 */

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

void __cdecl FUN_004ae4d8(int *param_1,undefined4 param_2)

{
  float fVar1;
  
  param_1[0x58] = (int)((_DAT_004ae530 - *(float *)(param_1[0x38] + 0x158)) * (float)param_1[0x76]);
  fVar1 = _DAT_004ae530;
  if (_DAT_004ae530 <= (float)param_1[0x58]) {
    fVar1 = (float)param_1[0x58];
  }
  param_1[0x58] = (int)fVar1;
  FUN_004ad748(param_1,param_2);
  return;
}



/* @004ae568 file=? name=FUN_004ae568 */

int * __cdecl FUN_004ae568(int *param_1,int param_2,undefined4 param_3,char *param_4)

{
  char *pcVar1;
  int iVar2;
  
  FUN_004adda0(param_1,param_2,param_3,param_4,&DAT_0050e4ec,0,0);
  *param_1 = (int)&PTR_FUN_0050ed88;
  FUN_0041b9ec(param_1 + 0x77,3);
  param_1[0x74] = 1;
  param_1[0x57] = 0;
  param_1[0x58] = *(int *)(param_4 + 0xfc);
  param_1[0x76] = param_1[0x58];
  param_1[10] = param_1[10] | 8;
  pcVar1 = (char *)param_1[0x35];
  iVar2 = FUN_004d4a78(pcVar1);
  iVar2 = FUN_004dd1e0(pcVar1 + iVar2 + -1);
  param_1[0x75] = iVar2;
  return param_1;
}



/* @004ae5fc file=? name=FUN_004ae5fc */

void __cdecl FUN_004ae5fc(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050ed88;
    FUN_0041baa4(param_1 + 0x77,2);
    FUN_004adfd4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ae63c file=? name=FUN_004ae63c */

void __cdecl FUN_004ae63c(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e4fc);
  return;
}



/* @004ae658 file=? name=FUN_004ae658 */

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

undefined4 __cdecl
FUN_004ae658(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_004ae150(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    param_4[0x24] = '\0';
    param_4[0x25] = '\x01';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x43;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xfc] = '\0';
      param_4[0xfd] = '\0';
      param_4[0xfe] = -0x80;
      param_4[0xff] = -0x41;
    }
    iVar1 = FUN_00404118(param_5,param_3,s_RefrigerationFactor_0050ea38,(float *)(param_4 + 0xfc));
    if ((iVar1 == 0) && (_DAT_004ae708 == *(float *)(param_4 + 0xfc))) {
      FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_missing_RefrigerationFactor__0050ea4c,(char *)0x0);
      uVar2 = 0;
    }
    else {
      uVar2 = 1;
    }
  }
  return uVar2;
}



/* @004ae724 file=? name=FUN_004ae724 */

void __cdecl FUN_004ae724(int *param_1,undefined4 param_2)

{
  FUN_004ad748(param_1,param_2);
  return;
}



/* @004ae73c file=? name=FUN_004ae73c */

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

void __cdecl FUN_004ae73c(int *param_1,float param_2)

{
  float fVar1;
  float fVar2;
  double dVar3;
  float fVar4;
  int iVar5;
  float10 fVar6;
  int *piVar7;
  
  iVar5 = FUN_004ad7d4((int)param_1);
  if (iVar5 != 0) {
    param_1[0x56] = (int)((float)param_1[0x72] + (float)param_1[0x56]);
    param_1[0x45] = (int)((float)param_1[0x56] / (float)param_1[0x55]);
    piVar7 = param_1;
    FUN_004ad7f0((int)param_1);
    param_1[0x72] = 0;
    fVar4 = _DAT_004ae89c - (_DAT_004ae89c - (float)param_1[0x75]) * _DAT_004ae8a0;
    fVar1 = (float)param_1[0x45];
    fVar2 = (float)param_1[0x58];
    dVar3 = (double)((-param_2 *
                     (float)param_1[0x50] *
                     (_DAT_004ae8a4 - *(float *)(param_1[0x38] + 0x158)) *
                     ((float)param_1[0x4b] / (float)param_1[0x4a]) * (float)param_1[0x57]) /
                    (float)param_1[0x55]);
    fVar6 = (float10)FUN_004dca38((short)piVar7,SUB84(dVar3,0),(uint)((ulonglong)dVar3 >> 0x20));
    param_1[0x72] =
         (int)(-(float)((float10)(fVar1 * fVar2 - fVar4) * (float10)(float)param_1[0x55] *
                       ((float10)_DAT_004ae8a4 - fVar6)) + (float)param_1[0x72]);
  }
  fVar1 = (float)param_1[0x4a] - (float)param_1[0x4b];
  if (_DAT_004ae8a8 < fVar1) {
    fVar6 = FUN_004dcd00((double)fVar1);
    if ((float10)_DAT_004ae8ac < fVar6) {
      fVar6 = (float10)(**(code **)(*param_1 + 0x38))(param_1,fVar1);
      param_1[0x4b] = (int)(float)(fVar6 + (float10)(float)param_1[0x4b]);
    }
  }
  return;
}



/* @004ae8d0 file=? name=FUN_004ae8d0 */

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

int * __cdecl FUN_004ae8d0(int *param_1,int param_2,undefined4 param_3,char *param_4)

{
  FUN_004adda0(param_1,param_2,param_3,param_4,&DAT_0050e580,0,0);
  *param_1 = (int)&PTR_LAB_0050ed4c;
  param_1[0x74] = *(int *)(param_4 + 0xfc);
  param_1[0x75] = 0x43960000;
  FUN_004afa1a(param_1 + 0x76,0);
  param_1[0x50] =
       (int)(float)(_DAT_004ae974 * (float10)param_1[0x74] * (float10)(float)param_1[0x50]);
  if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
    param_1[7] = (int)PTR_FUN_0050e5e8;
    param_1[8] = DAT_0050e5ec;
    param_1[9] = DAT_0050e5f0;
  }
  return param_1;
}



/* @004ae9c0 file=? name=FUN_004ae9c0 */

void __cdecl FUN_004ae9c0(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e590);
  return;
}



/* @004ae9dc file=? name=FUN_004ae9dc */

undefined4 __cdecl
FUN_004ae9dc(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  bool bVar1;
  int iVar2;
  undefined4 uVar3;
  undefined3 extraout_var;
  
  iVar2 = FUN_004ae150(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar2 == 0) {
    uVar3 = 0;
  }
  else {
    param_4[0x24] = '\0';
    param_4[0x25] = '\x01';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x42;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xfc] = -1;
      param_4[0xfd] = -1;
      param_4[0xfe] = -1;
      param_4[0xff] = -1;
    }
    bVar1 = FUN_004040d8(param_5,param_3,s_HeatSinkCount_0050ea95,(int *)(param_4 + 0xfc));
    if ((CONCAT31(extraout_var,bVar1) == 0) && (*(int *)(param_4 + 0xfc) == -1)) {
      FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_missing_HeatSinkCount__0050eaa3,(char *)0x0);
      uVar3 = 0;
    }
    else {
      uVar3 = 1;
    }
  }
  return uVar3;
}



/* @004aea84 file=? name=FUN_004aea84 */

void __cdecl FUN_004aea84(int *param_1,undefined4 param_2)

{
  FUN_004ac0bc(param_1,param_2);
  return;
}



/* @004aea9c file=? name=FUN_004aea9c */

void __cdecl FUN_004aea9c(int *param_1)

{
  FUN_004ac22c(param_1);
  FUN_0041bbd8((int)(param_1 + 0x4b),0);
  return;
}



/* @004aeac4 file=? name=FUN_004aeac4 */

void __cdecl FUN_004aeac4(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00417ab4(param_1 + 0x114);
  if (*(float *)(iVar1 + 0x114) <= *(float *)(param_1 + 0x124)) {
    if (*(float *)(iVar1 + 0x114) <= *(float *)(param_1 + 0x120)) {
      FUN_0041bbd8(param_1 + 300,0);
    }
    else {
      FUN_0041bbd8(param_1 + 300,1);
    }
  }
  else {
    FUN_0041bbd8(param_1 + 300,2);
  }
  return;
}



/* @004aeb40 file=? name=FUN_004aeb40 */

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

{
  FUN_004ac644(param_1,param_2,param_3,param_4,param_5,0,0);
  *param_1 = (int)&PTR_FUN_0050ed10;
  FUN_004af9cf(param_1 + 0x45,0);
  param_1[0x48] = *(int *)(param_4 + 0xe8);
  param_1[0x49] = *(int *)(param_4 + 0xec);
  param_1[0x4a] = *(int *)(param_4 + 0xe4);
  FUN_0041b9ec(param_1 + 0x4b,3);
  if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
    param_1[7] = (int)PTR_FUN_0050e634;
    param_1[8] = DAT_0050e638;
    param_1[9] = DAT_0050e63c;
  }
  return param_1;
}



/* @004aebe8 file=? name=FUN_004aebe8 */

void __cdecl FUN_004aebe8(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0050ed10;
    FUN_0041baa4(param_1 + 0x4b,2);
    FUN_004af9ee(param_1 + 0x45,2);
    FUN_004ac868(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004aec38 file=? name=FUN_004aec38 */

void __cdecl FUN_004aec38(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e604);
  return;
}



/* @004aec54 file=? name=FUN_004aec54 */

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

undefined4 __cdecl
FUN_004aec54(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  char *pcVar1;
  int iVar2;
  undefined4 uVar3;
  char *pcVar4;
  char *pcVar5;
  bool bVar6;
  char *local_8;
  
  iVar2 = FUN_004ac9ec(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar2 == 0) {
    uVar3 = 0;
  }
  else {
    param_4[0x24] = -0x10;
    param_4[0x25] = '\0';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x41;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xe4] = -1;
      param_4[0xe5] = -1;
      param_4[0xe6] = -1;
      param_4[0xe7] = -1;
    }
    iVar2 = FUN_00404118(param_5,param_3,s_DegradationTemperature_0050eac8,(float *)(param_4 + 0xe8)
                        );
    if ((iVar2 == 0) && (_DAT_004aee28 == *(float *)(param_4 + 0xe8))) {
      FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_missing_DegradationTemperature__0050eadf,(char *)0x0);
      uVar3 = 0;
    }
    else {
      iVar2 = FUN_00404118(param_5,param_3,s_FailureTemperature_0050eb01,(float *)(param_4 + 0xec));
      if ((iVar2 == 0) && (_DAT_004aee28 == *(float *)(param_4 + 0xec))) {
        FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
        FUN_004dbb24((int *)&DAT_00524e68,s_missing_FailureTemperature__0050eb14,(char *)0x0);
        uVar3 = 0;
      }
      else {
        local_8 = s_Unspecified_0050eb32;
        iVar2 = FUN_00404088(param_5,param_3,s_WatchedSubsystem_0050eb3e,&local_8);
        if ((iVar2 == 0) && (*(int *)(param_4 + 0xe4) == -1)) {
          FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
          FUN_004dbb24((int *)&DAT_00524e68,s_missing_WatchedSubsystem__0050eb4f,(char *)0x0);
          uVar3 = 0;
        }
        else {
          pcVar5 = s_Unspecified_0050eb6b;
          pcVar4 = local_8;
          do {
            bVar6 = *pcVar4 == *pcVar5;
            if (!bVar6) break;
            if (*pcVar4 == '\0') goto LAB_004aede2;
            pcVar1 = pcVar4 + 1;
            bVar6 = *pcVar1 == pcVar5[1];
            if (!bVar6) break;
            pcVar4 = pcVar4 + 2;
            pcVar5 = pcVar5 + 2;
            bVar6 = *pcVar1 == '\0';
          } while (!bVar6);
          if (!bVar6) {
            iVar2 = FUN_004215b0(param_5,local_8);
            *(int *)(param_4 + 0xe4) = iVar2;
          }
LAB_004aede2:
          if (*(int *)(param_4 + 0xe4) < 0) {
            FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
            FUN_004dbb24((int *)&DAT_00524e68,s_has_an_invalid_watched_subsystem_0050eb77,
                         (char *)0x0);
            uVar3 = 0;
          }
          else {
            *(int *)(param_4 + 0xe4) = *(int *)(param_4 + 0xe4) + 2;
            uVar3 = 1;
          }
        }
      }
    }
  }
  return uVar3;
}



/* @004aee70 file=? name=FUN_004aee70 */

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

void __cdecl FUN_004aee70(int param_1,int param_2)

{
  bool bVar1;
  undefined3 extraout_var;
  
  bVar1 = FUN_004ac9c8(param_1);
  if (CONCAT31(extraout_var,bVar1) == 0) {
    if (*(int *)(param_2 + 0xc) < 1) {
      FUN_0041bbd8(param_1 + 0x1d0,0);
    }
    else {
      if ((*(int *)(param_1 + 0x1e4) != 1) && (_DAT_004aeedc < *(float *)(param_1 + 300))) {
        FUN_0041bbd8(param_1 + 0x1d0,1);
      }
      *(undefined4 *)(param_1 + 0x228) = 0;
    }
    *(ushort *)(param_1 + 0x18) = *(ushort *)(param_1 + 0x18) | 1;
  }
  return;
}



/* @004aeef8 file=? name=FUN_004aeef8 */

void __cdecl FUN_004aeef8(int param_1,int param_2)

{
  FUN_0041bd34(param_1,param_2);
  if (*(int *)(param_2 + 0x10) == 0) {
    FUN_0041bbd8(param_1 + 0x1d0,0);
  }
  else {
    FUN_0041bbd8(param_1 + 0x1d0,1);
  }
  return;
}



/* @004aef40 file=? name=FUN_004aef40 */

void __cdecl FUN_004aef40(int param_1,undefined4 *param_2,undefined2 param_3)

{
  FUN_0041c500(param_1,param_2,param_3);
  *param_2 = 0x14;
  param_2[4] = (uint)(*(int *)(param_1 + 0x1e4) == 1);
  return;
}



/* @004aef78 file=? name=FUN_004aef78 */

void __cdecl FUN_004aef78(int param_1,float param_2)

{
  if (*(int *)(param_1 + 0x1e4) == 1) {
    *(float *)(param_1 + 0x228) = param_2 + *(float *)(param_1 + 0x228);
    FUN_004aefa4(param_1,param_2);
  }
  return;
}



/* @004aefa4 file=? name=FUN_004aefa4 */

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

void __cdecl FUN_004aefa4(int param_1,float param_2)

{
  float fVar1;
  int iVar2;
  int iVar3;
  float10 fVar4;
  int local_6c [3];
  int local_60 [3];
  int local_54 [3];
  int local_48 [3];
  int local_3c [4];
  float local_2c;
  float local_28;
  float local_24;
  float local_20;
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_8 = *(float *)(param_1 + 300);
  fVar4 = FUN_004dcd00((double)local_8);
  if ((float10)_DAT_004af3a0 < fVar4) {
    iVar3 = *(int *)(param_1 + 0xd0);
    FUN_004afa65(local_3c,0);
    FUN_004a4f15(local_48,iVar3 + 0x7cc);
    while (iVar2 = (**(code **)(local_48[0] + 0x28))(), iVar2 != 0) {
      (**(code **)(local_3c[0] + 4))(local_3c);
    }
    FUN_004afab0(local_54,iVar3 + 0x7bc);
    while (iVar2 = (**(code **)(local_54[0] + 0x28))(), iVar2 != 0) {
      (**(code **)(local_3c[0] + 4))(local_3c);
    }
    FUN_004a4f9e(local_60,iVar3 + 0x7ac);
    while (iVar3 = (**(code **)(local_60[0] + 0x28))(), iVar3 != 0) {
      (**(code **)(local_3c[0] + 4))(local_3c);
    }
    FUN_00417ab4(param_1 + 0x164);
    (**(code **)(local_3c[0] + 4))(local_3c);
    FUN_004afb58(local_6c,(int)local_3c);
    while (iVar3 = (**(code **)(local_6c[0] + 0x28))(), iVar3 != 0) {
      local_c = *(float *)(param_1 + 300);
      fVar4 = FUN_004dcd00((double)local_c);
      if (fVar4 <= (float10)_DAT_004af3a0) {
        FUN_004afb96(local_6c,2);
        FUN_004a4ffb(local_60,2);
        FUN_004afb0d(local_54,2);
        FUN_004a4f72(local_48,2);
        FUN_004afa84(local_3c,2);
        return;
      }
      if (*(float *)(iVar3 + 0x15c) != _DAT_004af3a4) {
        fVar1 = -*(float *)(param_1 + 0x224) * *(float *)(iVar3 + 0x15c) * param_2;
        local_14 = -*(float *)(param_1 + 300);
        local_10 = local_14;
        if ((local_14 <= fVar1) && (local_10 = fVar1, _DAT_004af3a4 < fVar1)) {
          local_10 = _DAT_004af3a4;
        }
        local_24 = *(float *)(iVar3 + 300);
        fVar4 = FUN_004dcd00((double)local_24);
        if ((float10)_DAT_004af3a0 < fVar4) {
          local_20 = local_10;
          if (local_10 <= _DAT_004af3a4) {
            local_20 = -local_10;
          }
          local_20 = local_20 / *(float *)(iVar3 + 300);
          local_1c = local_10;
          if (local_10 <= _DAT_004af3a4) {
            local_1c = -local_10;
          }
          local_1c = local_1c / *(float *)(param_1 + 300);
          local_18 = *(float *)(iVar3 + 0x158) * local_20 - *(float *)(param_1 + 0x158) * local_1c;
        }
        else {
          local_20 = local_10;
          if (local_10 <= _DAT_004af3a4) {
            local_20 = -local_10;
          }
          local_20 = local_20 / *(float *)(iVar3 + 0x128);
          local_1c = local_10;
          if (local_10 <= _DAT_004af3a4) {
            local_1c = -local_10;
          }
          local_1c = local_1c / *(float *)(param_1 + 300);
          local_18 = *(float *)(iVar3 + 0x158) * local_20 - *(float *)(param_1 + 0x158) * local_1c;
        }
        *(float *)(param_1 + 300) = local_10 + *(float *)(param_1 + 300);
        *(float *)(iVar3 + 300) = *(float *)(iVar3 + 300) - local_10;
        if (_DAT_004af3a4 <= *(float *)(iVar3 + 300)) {
          if (*(float *)(iVar3 + 300) <= *(float *)(iVar3 + 0x128)) {
            fVar1 = *(float *)(iVar3 + 300);
          }
          else {
            fVar1 = *(float *)(iVar3 + 0x128);
          }
        }
        else {
          fVar1 = (float)_DAT_004af3a8;
        }
        *(float *)(iVar3 + 300) = fVar1;
        if (*(float *)(iVar3 + 0x154) * *(float *)(param_1 + 0x13c) < local_18) {
          local_18 = *(float *)(iVar3 + 0x154) * *(float *)(param_1 + 0x13c);
        }
        local_2c = -local_18;
        if (_DAT_004af3a4 < local_2c) {
          local_2c = _DAT_004af3a4;
        }
        *(float *)(iVar3 + 0x1c8) = local_2c + *(float *)(iVar3 + 0x1c8);
        local_28 = local_2c;
      }
    }
    FUN_004afb96(local_6c,2);
    FUN_004a4ffb(local_60,2);
    FUN_004afb0d(local_54,2);
    FUN_004a4f72(local_48,2);
    FUN_004afa84(local_3c,2);
  }
  return;
}



/* @004af3b0 file=? name=FUN_004af3b0 */

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

float10 __cdecl FUN_004af3b0(int param_1,float param_2)

{
  float fVar1;
  
  fVar1 = _DAT_004af404;
  if ((_DAT_004af404 <= param_2) && (fVar1 = param_2, *(float *)(param_1 + 300) < param_2)) {
    fVar1 = *(float *)(param_1 + 300);
  }
  *(float *)(param_1 + 300) = *(float *)(param_1 + 300) - fVar1;
  return (float10)fVar1;
}



/* @004af408 file=? name=FUN_004af408 */

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

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

{
  int iVar1;
  
  FUN_004adda0(param_1,param_2,param_3,param_4,param_5,0,0);
  *param_1 = (int)&PTR_LAB_0050ecd4;
  FUN_0041b9ec(param_1 + 0x74,2);
  param_1[0x8b] = 0x3f000000;
  param_1[0x4a] = *(int *)(param_4 + 0xfc);
  param_1[0x89] = *(int *)(param_4 + 0x100);
  param_1[0x4b] = param_1[0x4a];
  param_1[0x57] = 0;
  FUN_0041bbd8((int)(param_1 + 0x74),0);
  param_1[0x8a] = 0;
  if (((*(uint *)(param_2 + 0x28) & 0xc) == 0) && ((*(uint *)(param_2 + 0x28) & 0x100) != 0)) {
    param_1[7] = (int)PTR_FUN_0050e6b4;
    param_1[8] = DAT_0050e6b8;
    param_1[9] = DAT_0050e6bc;
    iVar1 = FUN_00417ab4((int)(param_1 + 0x59));
    (**(code **)(*(int *)(iVar1 + 0x1d8) + 4))(iVar1 + 0x1d8,param_1);
    param_1[0x4a] =
         (int)(float)(_DAT_004af518 * (float10)*(int *)(iVar1 + 0x1d0) *
                     (float10)(float)param_1[0x4a]);
    param_1[0x4b] = param_1[0x4a];
  }
  else {
    param_1[10] = param_1[10] | 2;
  }
  return param_1;
}



/* @004af564 file=? name=FUN_004af564 */

void __cdecl FUN_004af564(int param_1)

{
  FUN_0041a1a4(**(int **)(param_1 + 0xc),0x50e650);
  return;
}



/* @004af580 file=? name=FUN_004af580 */

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

undefined4 __cdecl
FUN_004af580(int param_1,char *param_2,char *param_3,char *param_4,int param_5,int param_6,
            int param_7)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_004ae150(param_1,param_2,param_3,param_4,param_5,param_6,param_7);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    param_4[0x24] = '\x04';
    param_4[0x25] = '\x01';
    param_4[0x26] = '\0';
    param_4[0x27] = '\0';
    param_4[0x20] = -0x40;
    param_4[0x21] = '\v';
    param_4[0x22] = '\0';
    param_4[0x23] = '\0';
    if (param_7 == 1) {
      param_4[0xfc] = '\0';
      param_4[0xfd] = '\0';
      param_4[0xfe] = -0x80;
      param_4[0xff] = -0x41;
      param_4[0x100] = '\0';
      param_4[0x101] = '\0';
      param_4[0x102] = -0x80;
      param_4[0x103] = -0x41;
    }
    iVar1 = FUN_00404118(param_5,param_3,s_CoolantCapacity_0050ebc2,(float *)(param_4 + 0xfc));
    if ((iVar1 == 0) && (_DAT_004af694 == *(float *)(param_4 + 0xfc))) {
      FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_missing_CoolantCapacity__0050ebd2,(char *)0x0);
      uVar2 = 0;
    }
    else {
      iVar1 = FUN_00404118(param_5,param_3,s_CoolantSquirtMass_0050ebed,(float *)(param_4 + 0x100));
      if ((iVar1 == 0) && (_DAT_004af694 == *(float *)(param_4 + 0x100))) {
        FUN_004dbb24((int *)&DAT_00524e68,param_3,(char *)0x0);
        FUN_004dbb24((int *)&DAT_00524e68,s_missing_CoolantSquirtMass__0050ebff,(char *)0x0);
        uVar2 = 0;
      }
      else {
        uVar2 = 1;
      }
    }
  }
  return uVar2;
}



