/* @004c5f30 file=? name=FUN_004c5f30 */

void __cdecl FUN_004c5f30(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_00518a58;
    FUN_00442c12(*(int *)(param_1[7] + 0x4c) + 4,(char *)param_1[0x24]);
    FUN_004022e8((int *)param_1[0x24]);
    param_1[0x24] = 0;
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c5f8c file=? name=FUN_004c5f8c */

void FUN_004c5f8c(void)

{
  FUN_004448ac();
  return;
}



/* @004c5f9c file=? name=FUN_004c5f9c */

void FUN_004c5f9c(void)

{
  return;
}



/* @004c5fa4 file=? name=FUN_004c5fa4 */

void __cdecl FUN_004c5fa4(int param_1)

{
  *(undefined4 *)(param_1 + 0xa4) = 0xffffffff;
  return;
}



/* @004c5fb8 file=? name=FUN_004c5fb8 */

void __cdecl FUN_004c5fb8(int param_1)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar1 = *(int *)(param_1 + 0x9c);
  iVar2 = FUN_004dcd94();
  if (iVar2 < 0) {
    iVar2 = 0;
  }
  if (iVar1 < iVar2) {
    iVar2 = iVar1;
  }
  if (iVar2 != *(int *)(param_1 + 0xa4)) {
    *(int *)(param_1 + 0xa4) = iVar2;
    iVar1 = *(int *)(*(int *)(param_1 + 0x1c) + 0x4c);
    puVar3 = FUN_00442aec(iVar1 + 4,*(char **)(param_1 + 0x90),0);
    if (puVar3 != (undefined4 *)0x0) {
      if (iVar2 != 0) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))
                  (param_1 + 0x48,*(undefined4 *)(param_1 + 0x94));
        (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
                  (param_1 + 0x48,*(undefined4 *)(param_1 + 0x98),0,puVar3,0,0,iVar2,
                   *(undefined4 *)(param_1 + 0xa0));
        iVar2 = iVar2 + 1;
      }
      if (iVar2 < *(int *)(param_1 + 0x9c)) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,iVar2,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))
                  (param_1 + 0x48,*(undefined4 *)(param_1 + 0x98));
        (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
                  (param_1 + 0x48,*(undefined4 *)(param_1 + 0x94),0,puVar3,iVar2,0,
                   *(undefined4 *)(param_1 + 0x9c),*(undefined4 *)(param_1 + 0xa0));
      }
    }
    FUN_00442c12(iVar1 + 4,*(char **)(param_1 + 0x90));
  }
  return;
}



/* @004c61c8 file=? name=FUN_004c61c8 */

int * __cdecl
FUN_004c61c8(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,undefined4 param_7,undefined4 param_8,char *param_9,undefined4 param_10,
            undefined4 param_11,undefined4 param_12,undefined4 param_13)

{
  undefined4 *puVar1;
  
  FUN_004c5e84(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_13);
  *param_1 = (int)&PTR_FUN_00518a14;
  puVar1 = (undefined4 *)FUN_00402298(0x18);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00474855(puVar1,0,param_1 + 0x2a,param_12);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar1);
  return param_1;
}



/* @004c6244 file=? name=FUN_004c6244 */

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

int * __cdecl
FUN_004c6244(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,undefined4 param_7,undefined4 param_8,float param_9,float param_10,
            float param_11,float param_12,float param_13,float param_14,uint param_15,
            undefined4 param_16,undefined4 param_17,undefined4 param_18,undefined4 param_19,
            undefined4 param_20)

{
  int iVar1;
  
  FUN_004745e0(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_15,param_16,param_17,param_18,param_19,
               param_20);
  *param_1 = (int)&PTR_FUN_005189d0;
  iVar1 = (param_15 ^ (int)param_15 >> 0x1f) - ((int)param_15 >> 0x1f);
  param_1[0x30] = (int)((float)(iVar1 / (iVar1 + -1)) * _DAT_004c62d4);
  return param_1;
}



/* @004c62fc file=? name=FUN_004c62fc */

undefined4 __cdecl
FUN_004c62fc(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00402298(0xcc);
  if (piVar1 != (int *)0x0) {
    FUN_004c6394(piVar1,DAT_00517eb0,DAT_00517ef4,param_5,0,param_1,param_2,param_3,DAT_00517f38,
                 DAT_00517f7c,DAT_00517f38,DAT_00517f7c,DAT_00517fc0,DAT_00518004,DAT_00518048,
                 DAT_0051808c,DAT_005180d0,DAT_00518114,DAT_00518158,1,s_SegmentArcRatio_00518598);
  }
  return 1;
}



/* @004c6394 file=? name=FUN_004c6394 */

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

int * __cdecl
FUN_004c6394(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,undefined4 param_7,undefined4 param_8,float param_9,float param_10,
            float param_11,float param_12,float param_13,float param_14,uint param_15,
            undefined4 param_16,undefined4 param_17,undefined4 param_18,undefined4 param_19,
            undefined4 param_20,undefined4 param_21)

{
  int iVar1;
  undefined4 *puVar2;
  
  FUN_00473f44(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_15,param_16,param_17,param_20,param_21);
  *param_1 = (int)&PTR_FUN_0051898c;
  iVar1 = (param_15 ^ (int)param_15 >> 0x1f) - ((int)param_15 >> 0x1f);
  param_1[0x32] = (int)((float)(iVar1 / (iVar1 + -1)) * _DAT_004c6484);
  puVar2 = (undefined4 *)FUN_00402298(0x18);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar2 = FUN_00474855(puVar2,0,param_1 + 0x30,param_18);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar2);
  puVar2 = (undefined4 *)FUN_00402298(0x18);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar2 = FUN_00474855(puVar2,0,param_1 + 0x31,param_19);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar2);
  return param_1;
}



/* @004c668d file=? name=FUN_004c668d */

void __cdecl FUN_004c668d(int *param_1,byte param_2)

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



/* @004c66b3 file=? name=FUN_004c66b3 */

void __cdecl FUN_004c66b3(int *param_1,byte param_2)

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



/* @004c66d9 file=? name=FUN_004c66d9 */

void __cdecl FUN_004c66d9(int *param_1,byte param_2)

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



/* @004c66ff file=? name=FUN_004c66ff */

void __cdecl FUN_004c66ff(int *param_1,byte param_2)

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



/* @004c6725 file=? name=FUN_004c6725 */

void __cdecl FUN_004c6725(int *param_1,byte param_2)

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



/* @004c674b file=? name=FUN_004c674b */

void __cdecl FUN_004c674b(int *param_1,byte param_2)

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



/* @004c6771 file=? name=FUN_004c6771 */

void __cdecl FUN_004c6771(int *param_1,byte param_2)

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



/* @004c6798 file=? name=FUN_004c6798 */

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

{
  char *pcVar1;
  int iVar2;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_11);
  *param_1 = &PTR_FUN_0051a1fc;
  pcVar1 = (char *)FUN_004700ac(param_9);
  param_1[0x24] = pcVar1;
  FUN_00442aec(*(int *)(param_1[7] + 0x4c) + 4,pcVar1,0);
  iVar2 = FUN_0041bfc0(param_7,s_CurrentSeekVoltageIndex_00519b05);
  param_1[0x25] = iVar2;
  iVar2 = FUN_0041bfc0(param_7,s_MinSeekVoltageIndex_00519b1d);
  param_1[0x26] = iVar2;
  iVar2 = FUN_0041bfc0(param_7,s_MaxSeekVoltageIndex_00519b31);
  param_1[0x27] = iVar2;
  iVar2 = FUN_0041bfc0(param_7,s_SeekVoltage_00519b45);
  param_1[0x28] = iVar2;
  param_1[0x29] = param_8;
  param_1[0x2a] = param_7;
  (**(code **)(param_1[0x12] + 0xc))(param_1 + 0x12,3);
  (**(code **)(param_1[0x12] + 8))(param_1 + 0x12,0x97,0x80,0x17d,0x13b);
  param_1[0x2c] = 0x43660000;
  param_1[0x2d] = 0x433b0000;
  param_1[0x2f] = param_10;
  param_1[0x2e] = 0;
  return param_1;
}



/* @004c68ac file=? name=FUN_004c68ac */

void __cdecl FUN_004c68ac(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051a1fc;
    FUN_00442c12(*(int *)(param_1[7] + 0x4c) + 4,(char *)param_1[0x24]);
    FUN_004022e8((int *)param_1[0x24]);
    param_1[0x24] = 0;
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c6908 file=? name=FUN_004c6908 */

void FUN_004c6908(void)

{
  FUN_004448ac();
  return;
}



/* @004c6918 file=? name=FUN_004c6918 */

void FUN_004c6918(void)

{
  return;
}



/* @004c6920 file=? name=FUN_004c6920 */

void __cdecl FUN_004c6920(int param_1)

{
  *(undefined4 *)(param_1 + 0xac) = 0x461c3c00;
  return;
}



/* @004c6934 file=? name=FUN_004c6934 */

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

void __cdecl FUN_004c6934(int *param_1)

{
  int iVar1;
  undefined4 *puVar2;
  int iVar3;
  int iVar4;
  undefined4 uVar5;
  undefined4 uVar6;
  int iVar7;
  float10 fVar8;
  float local_c;
  
  if (*(int *)(param_1[0x2a] + 0x40) == 1) {
    if (param_1[0x2e] == 0) {
      param_1[0x2e] = 1;
      FUN_004c6be4((int)param_1);
      iVar7 = *(int *)(param_1[7] + 0x4c);
      puVar2 = FUN_00442aec(iVar7 + 4,(char *)param_1[0x24],0);
      iVar3 = FUN_004dcd94();
      iVar1 = puVar2[3];
      iVar4 = FUN_004dcd94();
      (**(code **)(param_1[0x12] + 0x24))(param_1 + 0x12,iVar3 - iVar1 >> 1,iVar4 - puVar2[4] >> 1);
      (**(code **)(param_1[0x12] + 0x18))(param_1 + 0x12,0xff);
      (**(code **)(param_1[0x12] + 0x54))(param_1 + 0x12,0,puVar2,0,0,puVar2[3] + -1,puVar2[4] + -1)
      ;
      FUN_00442c12(iVar7 + 4,(char *)param_1[0x24]);
    }
  }
  else {
    if (param_1[0x2e] != 0) {
      param_1[0x2e] = 0;
      (**(code **)(*param_1 + 0xc))(param_1);
    }
    fVar8 = (float10)(**(code **)(*(int *)param_1[0x2a] + 0x3c))((int *)param_1[0x2a],0x463b8000);
    if ((float)param_1[0x2b] != (float)fVar8) {
      param_1[0x2b] = (int)(float)fVar8;
      FUN_004c6be4((int)param_1);
      (**(code **)(param_1[0x12] + 0x18))(param_1 + 0x12,0xff);
      (**(code **)(param_1[0x12] + 0x24))(param_1 + 0x12,0,0);
      for (local_c = 0.0; local_c < _DAT_004c6be0; local_c = local_c + _DAT_004c6bdc) {
        (**(code **)(*(int *)param_1[0x2a] + 0x3c))((int *)param_1[0x2a],local_c);
        uVar5 = FUN_004dcd94();
        uVar6 = FUN_004dcd94();
        (**(code **)(param_1[0x12] + 0x30))(param_1 + 0x12,uVar5,uVar6);
      }
      param_1[0x30] = -1;
      param_1[0x31] = -1;
      (**(code **)(param_1[0x12] + 0xc))(param_1 + 0x12,3);
      if (((int *)param_1[0x25] != (int *)0x0) && (param_1[0x28] != 0)) {
        param_1[0x32] = *(int *)param_1[0x25];
        FUN_004c6c6c((int)param_1);
      }
    }
    if ((((int *)param_1[0x25] != (int *)0x0) && (param_1[0x28] != 0)) &&
       (iVar7 = *(int *)param_1[0x25], iVar7 != param_1[0x32])) {
      FUN_004c6c6c((int)param_1);
      param_1[0x32] = iVar7;
      FUN_004c6c6c((int)param_1);
    }
    if (param_1[0x2f] != 0) {
      if (-1 < param_1[0x30]) {
        FUN_004c6c30((int)param_1);
      }
      (**(code **)(*(int *)param_1[0x2a] + 0x3c))((int *)param_1[0x2a],*(undefined4 *)param_1[0x29])
      ;
      iVar7 = FUN_004dcd94();
      param_1[0x30] = iVar7;
      iVar7 = FUN_004dcd94();
      param_1[0x31] = iVar7;
      FUN_004c6c30((int)param_1);
    }
  }
  return;
}



/* @004c6be4 file=? name=FUN_004c6be4 */

void __cdecl FUN_004c6be4(int param_1)

{
  int iVar1;
  
  iVar1 = param_1 + 0x48;
  (**(code **)(*(int *)(param_1 + 0x48) + 0xc))(iVar1,0);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,0);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,0,0);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x48))(iVar1,1000,1000);
  return;
}



/* @004c6c30 file=? name=FUN_004c6c30 */

void __cdecl FUN_004c6c30(int param_1)

{
  (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
            (param_1 + 0x48,*(int *)(param_1 + 0xc0) + -4,*(int *)(param_1 + 0xc4) + -4);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(param_1 + 0x48,8,8);
  return;
}



/* @004c6c6c file=? name=FUN_004c6c6c */

void __cdecl FUN_004c6c6c(int param_1)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  int iVar4;
  
  iVar1 = **(int **)(param_1 + 0x9c);
  for (iVar4 = **(int **)(param_1 + 0x98); iVar4 <= iVar1; iVar4 = iVar4 + 1) {
    (**(code **)(**(int **)(param_1 + 0xa8) + 0x3c))
              (*(int **)(param_1 + 0xa8),*(undefined4 *)(*(int *)(param_1 + 0xa0) + iVar4 * 4));
    uVar2 = FUN_004dcd94();
    uVar3 = FUN_004dcd94();
    if (iVar4 == *(int *)(param_1 + 200)) {
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0,uVar3);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(param_1 + 0x48,uVar2,uVar3);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(param_1 + 0x48,uVar2,0);
    }
    else {
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0,uVar3);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(param_1 + 0x48,10,uVar3);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,uVar2,0);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(param_1 + 0x48,uVar2,10);
    }
  }
  return;
}



/* @004c6d80 file=? name=FUN_004c6d80 */

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

{
  int iVar1;
  undefined4 *puVar2;
  int iVar3;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_10);
  *param_1 = &PTR_FUN_0051a1b8;
  param_1[0x26] = s_btjoy_pcc_00519b51;
  param_1[0x27] = s_cm_off_pcc_00519b5b;
  param_1[0x28] = s_cm_other_pcc_00519b66;
  param_1[0x29] = s_cm_only_pcc_00519b73;
  param_1[0x2a] = s_cm_both_pcc_00519b7f;
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_7,param_8);
  param_1[0x25] = 0;
  param_1[0x24] = param_9;
  iVar1 = *(int *)(param_4 + 0x4c);
  FUN_00442aec(iVar1 + 4,(char *)param_1[0x26],0);
  iVar3 = 0;
  puVar2 = param_1 + 0x27;
  do {
    FUN_00442d2b(iVar1 + 0x20,(char *)*puVar2,0);
    iVar3 = iVar3 + 1;
    puVar2 = puVar2 + 1;
  } while (iVar3 < 4);
  return param_1;
}



/* @004c6e54 file=? name=FUN_004c6e54 */

void __cdecl FUN_004c6e54(int *param_1,byte param_2)

{
  int iVar1;
  int *piVar2;
  int iVar3;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051a1b8;
    iVar1 = *(int *)(param_1[7] + 0x4c);
    FUN_00442c12(iVar1 + 4,(char *)param_1[0x26]);
    iVar3 = 0;
    piVar2 = param_1 + 0x27;
    do {
      FUN_00442e51(iVar1 + 0x20,(char *)*piVar2);
      iVar3 = iVar3 + 1;
      piVar2 = piVar2 + 1;
    } while (iVar3 < 4);
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c6ec8 file=? name=FUN_004c6ec8 */

void FUN_004c6ec8(void)

{
  FUN_004448ac();
  return;
}



/* @004c6ed8 file=? name=FUN_004c6ed8 */

void FUN_004c6ed8(void)

{
  return;
}



/* @004c6ee0 file=? name=FUN_004c6ee0 */

void __cdecl FUN_004c6ee0(int param_1,undefined4 param_2)

{
  *(undefined4 *)(param_1 + 0x94) = param_2;
  return;
}



/* @004c6ef4 file=? name=FUN_004c6ef4 */

void __cdecl FUN_004c6ef4(int param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  iVar2 = 0;
  *(undefined4 *)(param_1 + 0xbc) = 1;
  puVar1 = (undefined4 *)(param_1 + 0xac);
  do {
    *puVar1 = 0xffffffff;
    iVar2 = iVar2 + 1;
    puVar1 = puVar1 + 1;
  } while (iVar2 < 4);
  return;
}



/* @004c6f1c file=? name=FUN_004c6f1c */

void __cdecl FUN_004c6f1c(int param_1)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  int *local_18;
  int local_10;
  
  if (*(int *)(param_1 + 0x94) != 0) {
    iVar2 = *(int *)(*(int *)(param_1 + 0x1c) + 0x4c);
    if (*(int *)(param_1 + 0xbc) != 0) {
      *(undefined4 *)(param_1 + 0xbc) = 0;
      puVar3 = FUN_00442aec(iVar2 + 4,*(char **)(param_1 + 0x98),0);
      if (puVar3 != (undefined4 *)0x0) {
        iVar1 = param_1 + 0x48;
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,0xff);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,0,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x54))
                  (iVar1,0,puVar3,0,0,puVar3[3] + -1,puVar3[4] + -1);
      }
    }
    piVar6 = &DAT_00518eb8;
    iVar1 = *(int *)(DAT_004efc94 + 0x3c);
    local_10 = 0;
    local_18 = (int *)(param_1 + 0xac);
    do {
      iVar4 = *(int *)(param_1 + 0x90);
      iVar4 = (**(code **)(*(int *)(iVar1 + 0x1c0 + *piVar6 * 0x20) + 0x24))
                        (*piVar6 * 0x20 + iVar1 + 0x1c0,*(undefined4 *)(iVar4 + 0xe8),iVar4,
                         *(undefined4 *)(iVar4 + 0xec),0x10000);
      if (iVar4 != *local_18) {
        *local_18 = iVar4;
        piVar5 = FUN_00442d2b(iVar2 + 0x20,*(char **)(param_1 + 0x9c + iVar4 * 4),0);
        if (piVar5 != (int *)0x0) {
          (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0xc,piVar6[-1]);
          (**(code **)(*(int *)(param_1 + 0x48) + 0x5c))
                    (param_1 + 0x48,0,0,piVar5,0,0,*piVar5 + -1,piVar5[1] + -1);
        }
        FUN_00442e51(iVar2 + 0x20,*(char **)(param_1 + 0x9c + iVar4 * 4));
      }
      local_10 = local_10 + 1;
      local_18 = local_18 + 1;
      piVar6 = piVar6 + 2;
    } while (local_10 < 4);
  }
  return;
}



/* @004c70a4 file=? name=FUN_004c70a4 */

int * __cdecl
FUN_004c70a4(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,undefined4 param_7,undefined4 param_8,char *param_9,undefined4 param_10,
            undefined4 param_11,int param_12,int param_13,undefined4 param_14,undefined4 param_15)

{
  undefined4 *puVar1;
  
  FUN_004c4d88(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,1,param_9,param_10,
               param_11,param_12,param_13,param_15);
  *param_1 = (int)&PTR_FUN_0051a174;
  param_1[0x2b] = 0;
  puVar1 = (undefined4 *)FUN_00402298(0x18);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004c3134(puVar1,0,param_1 + 0x2b,param_14);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar1);
  return param_1;
}



/* @004c7134 file=? name=FUN_004c7134 */

void __cdecl FUN_004c7134(int *param_1,byte param_2)

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



/* @004c7160 file=? name=FUN_004c7160 */

int * __cdecl
FUN_004c7160(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,undefined4 param_7,undefined4 param_8,char *param_9,undefined4 param_10,
            undefined4 param_11,int param_12,int param_13,undefined4 param_14,undefined4 param_15)

{
  undefined4 *puVar1;
  
  FUN_004c4d88(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,1,param_9,param_10,
               param_11,param_12,param_13,param_15);
  *param_1 = (int)&PTR_FUN_0051a130;
  param_1[0x2b] = 0;
  puVar1 = (undefined4 *)FUN_00402298(0x18);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004c31ec(puVar1,0,param_1 + 0x2b,param_14);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar1);
  return param_1;
}



/* @004c71f0 file=? name=FUN_004c71f0 */

void __cdecl FUN_004c71f0(int *param_1,byte param_2)

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



/* @004c721c file=? name=FUN_004c721c */

int * __cdecl
FUN_004c721c(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,int param_7,int param_8,int param_9,int param_10,char *param_11,int param_12
            ,int param_13,undefined4 param_14,float param_15,float param_16,undefined4 param_17,
            undefined4 param_18)

{
  undefined4 *puVar1;
  
  FUN_00472ef0(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_15,param_16,0,param_18);
  *param_1 = (int)&PTR_FUN_0051a0e4;
  puVar1 = (undefined4 *)FUN_00402298(0x18);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004c3288(puVar1,0,param_1 + 0x2d,param_17);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar1);
  return param_1;
}



/* @004c72ac file=? name=FUN_004c72ac */

int * __cdecl
FUN_004c72ac(int *param_1,undefined4 param_2,undefined4 param_3,int param_4,undefined4 param_5,
            int param_6,int param_7,int param_8,int param_9,int param_10,char *param_11,int param_12
            ,int param_13,undefined4 param_14,float param_15,float param_16,undefined4 param_17,
            undefined4 param_18)

{
  undefined4 *puVar1;
  
  FUN_00472ef0(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_15,param_16,0,param_18);
  *param_1 = (int)&PTR_FUN_0051a0e4;
  puVar1 = (undefined4 *)FUN_00402298(0x18);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00474855(puVar1,0,param_1 + 0x2d,param_17);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar1);
  return param_1;
}



/* @004c733c file=? name=FUN_004c733c */

void __cdecl FUN_004c733c(int *param_1,byte param_2)

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



/* @004c7368 file=? name=FUN_004c7368 */

undefined4 __cdecl FUN_004c7368(int param_1,int param_2,int param_3,int param_4,int param_5)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  
  iVar1 = FUN_0041f98c(param_4,&DAT_00518f24);
  if (iVar1 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_Subsystem___00519b9c,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_00518f24,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___not_found__00519ba8,(char *)0x0);
    uVar2 = 0;
  }
  else {
    puVar3 = (undefined4 *)FUN_00402298(0xb4);
    if (puVar3 != (undefined4 *)0x0) {
      FUN_004c746c(puVar3,DAT_00518ee0,param_5,0,param_1,param_2,param_3,iVar1,&DAT_00518f68,
                   DAT_00518fac,&DAT_00518ff0,DAT_00519034,DAT_00519078,&DAT_005190bc,DAT_00519100,
                   &DAT_00519144,DAT_00519188,&DAT_005191cc,&DAT_00519210,DAT_00519254,DAT_00519298,
                   s_GeneratorCluster_00519a8c);
    }
    uVar2 = 1;
  }
  return uVar2;
}



/* @004c746c file=? name=FUN_004c746c */

undefined4 * __cdecl
FUN_004c746c(undefined4 *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,
            int param_6,int param_7,int param_8,char *param_9,int param_10,char *param_11,
            int param_12,int param_13,char *param_14,int param_15,char *param_16,int param_17,
            char *param_18,char *param_19,int param_20,int param_21,undefined4 param_22)

{
  undefined4 uVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  int iVar5;
  int iVar6;
  int iVar7;
  int iVar8;
  int iVar9;
  undefined4 uVar10;
  int *piVar11;
  
  FUN_00444818(param_1,0xffff,param_2,param_3,param_4,param_5,param_22);
  *param_1 = &PTR_FUN_0051a0a0;
  uVar1 = FUN_004442b8();
  uVar2 = FUN_004442b8();
  uVar3 = FUN_004442b8();
  uVar4 = FUN_004442b8();
  iVar5 = FUN_0041bfc0(param_8,s_CurrentTemperature_00519bb6);
  iVar6 = FUN_0041bfc0(param_8,s_DegradationTemperature_00519bc9);
  iVar7 = FUN_0041bfc0(param_8,s_FailureTemperature_00519be0);
  iVar8 = FUN_0041bfc0(param_8,s_CoolantMassLeakRate_00519bf3);
  iVar9 = FUN_0041bfc0(param_8,s_OutputVoltage_00519c07);
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_6,param_7);
  param_1[0x25] = param_17;
  uVar10 = FUN_004700ac(param_9);
  param_1[0x24] = uVar10;
  FUN_00442d2b(*(int *)(param_3 + 0x4c) + 0x20,(char *)param_1[0x24],0);
  piVar11 = (int *)FUN_00402298(0xbc);
  if (piVar11 == (int *)0x0) {
    piVar11 = (int *)0x0;
  }
  else {
    piVar11 = FUN_004c4724(piVar11,uVar1,param_2,param_3,param_4,param_5,param_6 + 5,param_7 + 0x29,
                           param_6 + 0xc,param_7 + 0x5c,param_11,param_12,param_13,param_10,iVar5,
                           iVar6,iVar7,s_VertTwoPartBar_0051995c);
  }
  param_1[0x26] = piVar11;
  piVar11 = (int *)FUN_00402298(0xcc);
  if (piVar11 == (int *)0x0) {
    piVar11 = (int *)0x0;
  }
  else {
    piVar11 = FUN_004c72ac(piVar11,uVar2,param_2,param_3,param_4,param_5,param_6 + 0x18,
                           param_7 + 0x29,param_6 + 0x1c,param_7 + 0x5c,param_14,param_15,param_10,3
                           ,0.0,12000.0,iVar9,s_GeneratorVoltage_scalar__00519a73);
  }
  param_1[0x27] = piVar11;
  piVar11 = (int *)FUN_00402298(0xb8);
  if (piVar11 == (int *)0x0) {
    piVar11 = (int *)0x0;
  }
  else {
    piVar11 = FUN_004c5b7c(piVar11,uVar3,param_2,param_3,param_4,param_5,param_6,param_7 + 0x27,
                           param_16,param_10,param_17,3,*(int *)(param_8 + 0x150),iVar8,
                           s_LeakGauge_005199ce);
  }
  param_1[0x28] = piVar11;
  piVar11 = (int *)FUN_00402298(0xa4);
  if (piVar11 == (int *)0x0) {
    piVar11 = (int *)0x0;
  }
  else {
    piVar11 = FUN_004739d8(piVar11,uVar4,param_2,param_3,param_4,param_5,param_6 + 0xc,param_7 + 2,
                           param_18,param_20,param_21,param_8 + 0x1d4,s_TwoState_005198af);
  }
  param_1[0x29] = piVar11;
  piVar11 = (int *)FUN_00402298(0xa4);
  if (piVar11 == (int *)0x0) {
    piVar11 = (int *)0x0;
  }
  else {
    piVar11 = FUN_004739d8(piVar11,uVar4,param_2,param_3,param_4,param_5,param_6 + 2,param_7 + 2,
                           param_19,param_20,param_21,param_8 + 0x1d4,s_TwoState_005198af);
  }
  param_1[0x2a] = piVar11;
  param_1[0x2b] = param_8;
  return param_1;
}



/* @004c7778 file=? name=FUN_004c7778 */

void __cdecl FUN_004c7778(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051a0a0;
    FUN_00442e51(*(int *)(param_1[7] + 0x4c) + 0x20,(char *)param_1[0x24]);
    FUN_004022e8((int *)param_1[0x24]);
    param_1[0x24] = 0;
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c77d4 file=? name=FUN_004c77d4 */

void FUN_004c77d4(void)

{
  FUN_004448ac();
  return;
}



/* @004c77e4 file=? name=FUN_004c77e4 */

void FUN_004c77e4(void)

{
  return;
}



/* @004c77ec file=? name=FUN_004c77ec */

void __cdecl FUN_004c77ec(int param_1)

{
  *(undefined4 *)(param_1 + 0xb0) = 0xffffffff;
  (**(code **)(**(int **)(param_1 + 0x98) + 0xc))(*(int **)(param_1 + 0x98));
  (**(code **)(**(int **)(param_1 + 0x9c) + 0xc))(*(int **)(param_1 + 0x9c));
  (**(code **)(**(int **)(param_1 + 0xa0) + 0xc))(*(int **)(param_1 + 0xa0));
  (**(code **)(**(int **)(param_1 + 0xa4) + 0xc))(*(int **)(param_1 + 0xa4));
  (**(code **)(**(int **)(param_1 + 0xa8) + 0xc))(*(int **)(param_1 + 0xa8));
  return;
}



/* @004c7844 file=? name=FUN_004c7844 */

void __cdecl FUN_004c7844(int param_1)

{
  int iVar1;
  int *piVar2;
  uint uVar3;
  
  uVar3 = (uint)(*(int *)(*(int *)(param_1 + 0xac) + 0x40) == 1);
  if (uVar3 != *(uint *)(param_1 + 0xb0)) {
    *(uint *)(param_1 + 0xb0) = uVar3;
    FUN_004c7978(param_1,uVar3);
    if (uVar3 == 0) {
      iVar1 = *(int *)(*(int *)(param_1 + 0x1c) + 0x4c);
      piVar2 = FUN_00442d2b(iVar1 + 0x20,*(char **)(param_1 + 0x90),0);
      if (piVar2 != (int *)0x0) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x5c))
                  (param_1 + 0x48,1,0,piVar2,0,0,*piVar2 + -1,piVar2[1] + -1);
      }
      FUN_00442e51(iVar1 + 0x20,*(char **)(param_1 + 0x90));
    }
    else {
      iVar1 = param_1 + 0x48;
      (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,*(undefined4 *)(param_1 + 0x94));
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,0,0);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(iVar1,0x23,0x66);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,1,0);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(iVar1,0x24,0x66);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,0,0x66);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(iVar1,0x23,0);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,1,0x66);
      (**(code **)(*(int *)(param_1 + 0x48) + 0x30))(iVar1,0x24,0);
    }
  }
  return;
}



/* @004c7978 file=? name=FUN_004c7978 */

void __cdecl FUN_004c7978(int param_1,int param_2)

{
  FUN_00444650(*(int **)(param_1 + 0x9c),param_2);
  FUN_00444650(*(int **)(param_1 + 0x98),param_2);
  FUN_00444650(*(int **)(param_1 + 0xa4),param_2);
  FUN_00444650(*(int **)(param_1 + 0xa8),param_2);
  return;
}



/* @004c79c8 file=? name=FUN_004c79c8 */

void __cdecl
FUN_004c79c8(int *param_1,int param_2,int param_3,char *param_4,char *param_5,char *param_6)

{
  if (param_3 != 0) {
    (**(code **)(*param_1 + 0x18))(param_1,0);
    (**(code **)(*param_1 + 0x24))(param_1,0x97,0x80);
    (**(code **)(*param_1 + 0x48))(param_1,0x17d,0x13b);
  }
  if (param_4 == (char *)0x0) {
    (**(code **)(*param_1 + 0x18))(param_1,0);
    (**(code **)(*param_1 + 0x24))(param_1,0x15a,0x145);
    (**(code **)(*param_1 + 0x48))(param_1,0x17f,0x159);
  }
  else {
    (**(code **)(*param_1 + 0x18))(param_1,0xff);
    FUN_004c2ec4(0x15a,0x145,param_1,param_2,param_4);
  }
  if (param_5 == (char *)0x0) {
    (**(code **)(*param_1 + 0x18))(param_1,0);
    (**(code **)(*param_1 + 0x24))(param_1,0x85,0x58);
    (**(code **)(*param_1 + 0x48))(param_1,0x17f,0x7c);
  }
  else {
    (**(code **)(*param_1 + 0x18))(param_1,0xff);
    FUN_004c2ec4(0x85,0x58,param_1,param_2,param_5);
  }
  if (param_6 == (char *)0x0) {
    (**(code **)(*param_1 + 0x18))(param_1,0);
    (**(code **)(*param_1 + 0x24))(param_1,0x2a,0x34);
    (**(code **)(*param_1 + 0x4c))(param_1,99,10);
    (**(code **)(*param_1 + 0x24))(param_1,10,0);
    (**(code **)(*param_1 + 0x48))(param_1,0x9f,0x2d);
  }
  else {
    (**(code **)(*param_1 + 0x18))(param_1,0xff);
    FUN_004c2ec4(0x2a,0x34,param_1,param_2,param_6);
  }
  return;
}



/* @004c7b30 file=? name=FUN_004c7b30 */

undefined4 __cdecl
FUN_004c7b30(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5)

{
  uint uVar1;
  int *piVar2;
  undefined4 uVar3;
  undefined4 *puVar4;
  
  uVar1 = DAT_0051936c;
  if (((int)DAT_0051936c < 1) || (0xc < (int)DAT_0051936c)) {
    FUN_004dbb24(&DAT_00524e20,s_PrepEngr__screen_number_out_of_r_00519c1e,(char *)0x0);
    piVar2 = FUN_004db78c(&DAT_00524e20,uVar1);
    FUN_004dbb24(piVar2,&DAT_00519c46,(char *)0x0);
    uVar3 = 0;
  }
  else {
    puVar4 = (undefined4 *)FUN_00402298(0x90);
    if (puVar4 != (undefined4 *)0x0) {
      FUN_004c7bf0(puVar4,DAT_00519328,param_5,0,param_1,param_4,DAT_0051936c,&DAT_005193b0,
                   &DAT_005193f4,&DAT_00519438,&DAT_0051947c,&DAT_005194c0,&DAT_00519504,
                   &DAT_00519548,s_PrepEngr_00519a9d);
    }
    uVar3 = 1;
  }
  return uVar3;
}



/* @004c7bf0 file=? name=FUN_004c7bf0 */

undefined4 * __cdecl
FUN_004c7bf0(undefined4 *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,
            undefined4 param_6,undefined4 param_7,char *param_8,char *param_9,char *param_10,
            char *param_11,char *param_12,char *param_13,char *param_14,undefined4 param_15)

{
  int iVar1;
  undefined4 uVar2;
  
  FUN_004440d4(param_1,param_2,param_3,param_4,param_5,param_15);
  *param_1 = &PTR_FUN_0051a06c;
  param_1[0x1c] = param_6;
  param_1[0x1b] = param_7;
  uVar2 = FUN_004700ac(param_8);
  param_1[0x1d] = uVar2;
  uVar2 = FUN_004700ac(param_9);
  param_1[0x1e] = uVar2;
  uVar2 = FUN_004700ac(param_10);
  param_1[0x1f] = uVar2;
  uVar2 = FUN_004700ac(param_11);
  param_1[0x20] = uVar2;
  uVar2 = FUN_004700ac(param_12);
  param_1[0x21] = uVar2;
  uVar2 = FUN_004700ac(param_13);
  param_1[0x22] = uVar2;
  uVar2 = FUN_004700ac(param_14);
  param_1[0x23] = uVar2;
  iVar1 = *(int *)(param_3 + 0x4c) + 4;
  FUN_00442aec(iVar1,(char *)param_1[0x1d],0);
  FUN_00442aec(iVar1,(char *)param_1[0x1e],0);
  FUN_00442aec(iVar1,(char *)param_1[0x1f],0);
  FUN_00442aec(iVar1,(char *)param_1[0x20],0);
  FUN_00442aec(iVar1,(char *)param_1[0x21],0);
  FUN_00442aec(iVar1,(char *)param_1[0x22],0);
  FUN_00442aec(iVar1,(char *)param_1[0x23],0);
  return param_1;
}



/* @004c7d14 file=? name=FUN_004c7d14 */

void __cdecl FUN_004c7d14(int *param_1,byte param_2)

{
  int iVar1;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051a06c;
    iVar1 = *(int *)(param_1[7] + 0x4c) + 4;
    FUN_00442c12(iVar1,(char *)param_1[0x1d]);
    FUN_00442c12(iVar1,(char *)param_1[0x1e]);
    FUN_00442c12(iVar1,(char *)param_1[0x1f]);
    FUN_00442c12(iVar1,(char *)param_1[0x20]);
    FUN_00442c12(iVar1,(char *)param_1[0x21]);
    FUN_00442c12(iVar1,(char *)param_1[0x22]);
    FUN_00442c12(iVar1,(char *)param_1[0x23]);
    FUN_004022e8((int *)param_1[0x1d]);
    param_1[0x1d] = 0;
    FUN_004022e8((int *)param_1[0x1e]);
    param_1[0x1e] = 0;
    FUN_004022e8((int *)param_1[0x1f]);
    param_1[0x1f] = 0;
    FUN_004022e8((int *)param_1[0x20]);
    param_1[0x20] = 0;
    FUN_004022e8((int *)param_1[0x21]);
    param_1[0x21] = 0;
    FUN_004022e8((int *)param_1[0x22]);
    param_1[0x22] = 0;
    FUN_004022e8((int *)param_1[0x23]);
    param_1[0x23] = 0;
    FUN_0044ae0c(param_1 + 9,2);
    FUN_00443f7c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c7e48 file=? name=FUN_004c7e48 */

void __cdecl FUN_004c7e48(int param_1)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  int local_58 [17];
  char *local_14;
  int local_10;
  int local_c;
  int local_8;
  
  local_8 = *(int *)(*(int *)(param_1 + 0x1c) + 0x4c);
  local_c = *(int *)(*(int *)(param_1 + 0x70) + 0x124);
  iVar4 = 0;
  if (0 < local_c) {
    do {
      if ((((iVar4 != 0) &&
           (iVar2 = *(int *)(*(int *)(*(int *)(param_1 + 0x70) + 0x128) + iVar4 * 4), iVar2 != 0))
          && (iVar3 = FUN_0041a1a4(**(int **)(iVar2 + 0xc),0x50f4bc), iVar3 != 0)) &&
         (*(int *)(iVar2 + 0x1dc) == *(int *)(param_1 + 0x6c))) {
        FUN_004700bc(local_58,local_8,0xe9,0x176,*(char **)(param_1 + 0x74),2,0,0,0xff);
        piVar1 = (int *)(param_1 + 0x24);
        FUN_00470430(local_58,piVar1,(float)*(int *)(param_1 + 0x6c));
        FUN_0047018c(local_58,2);
        local_10 = 0;
        iVar4 = FUN_0041bfc0(iVar2,s_HeatSink_00519c49);
        if ((iVar4 != 0) && (iVar4 = FUN_00417ab4(iVar4), iVar4 != 0)) {
          local_10 = *(int *)(iVar4 + 0x1d4);
        }
        FUN_004700bc((int *)&stack0xffffff64,local_8,0x15e,5,*(char **)(param_1 + 0x74),1,0,0,0xff);
        FUN_00470430((int *)&stack0xffffff64,piVar1,(float)local_10);
        FUN_0047018c((int *)&stack0xffffff64,2);
        local_14 = (char *)(iVar2 + 0x224);
        (**(code **)(*(int *)(param_1 + 0x24) + 0x18))();
        (**(code **)(*(int *)(param_1 + 0x24) + 0x24))();
        (**(code **)(*(int *)(param_1 + 0x24) + 0x48))();
        if (local_14 != (char *)0x0) {
          (**(code **)(*(int *)(param_1 + 0x24) + 0x18))();
          FUN_004c2ec4(0x125,0x172,piVar1,local_8,local_14);
        }
        switch(*(undefined4 *)(iVar2 + 4)) {
        case 0xbc3:
          FUN_004c79c8((int *)(param_1 + 0x24),local_8,1,(char *)0x0,(char *)0x0,(char *)0x0);
          (**(code **)(*(int *)(param_1 + 0x24) + 0x18))();
          FUN_004c2ec4(0xb8,0x8c,(int *)(param_1 + 0x24),local_8,*(char **)(param_1 + 0x8c));
          return;
        default:
          return;
        case 0xbc6:
          FUN_004c79c8((int *)(param_1 + 0x24),local_8,0,(char *)0x0,*(char **)(param_1 + 0x88),
                       *(char **)(param_1 + 0x80));
          return;
        case 0xbc8:
        case 0xbd4:
          FUN_004c79c8((int *)(param_1 + 0x24),local_8,0,*(char **)(param_1 + 0x78),
                       *(char **)(param_1 + 0x7c),*(char **)(param_1 + 0x80));
          return;
        case 0xbcd:
        case 0xbd0:
          FUN_004c79c8((int *)(param_1 + 0x24),local_8,1,(char *)0x0,(char *)0x0,
                       *(char **)(param_1 + 0x84));
          return;
        case 0xbce:
          FUN_004dbb24(&DAT_00524e20,s_PrepEngr__Gauss_rifle_not_yet_su_00519c52,(char *)0x0);
          FUN_004c79c8((int *)(param_1 + 0x24),local_8,1,(char *)0x0,(char *)0x0,
                       *(char **)(param_1 + 0x80));
          return;
        }
      }
      iVar4 = iVar4 + 1;
    } while (iVar4 < local_c);
  }
  return;
}



/* @004c8140 file=? name=FUN_004c8140 */

undefined4 * __cdecl
FUN_004c8140(undefined4 *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,
            int param_6,int param_7,int param_8,undefined4 param_9,char *param_10,char *param_11,
            char *param_12,int param_13,undefined4 param_14)

{
  undefined4 uVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  undefined4 uVar5;
  undefined4 uVar6;
  undefined4 uVar7;
  int iVar8;
  int iVar9;
  int iVar10;
  int iVar11;
  int iVar12;
  int *piVar13;
  undefined4 *puVar14;
  int iVar15;
  int iVar16;
  int iVar17;
  
  FUN_00444818(param_1,0xffff,0xffffffff,param_3,param_4,param_5,param_14);
  *param_1 = &PTR_FUN_0051a020;
  uVar1 = FUN_004442b8();
  uVar2 = FUN_004442b8();
  uVar3 = FUN_004442b8();
  uVar4 = FUN_004442b8();
  uVar5 = FUN_004442dc();
  uVar6 = FUN_004442dc();
  uVar7 = FUN_004442dc();
  iVar8 = FUN_0041bfc0(param_8,s_InputVoltage_00519c7b);
  iVar9 = FUN_0041bfc0(param_8,s_HeatSink_00519c88);
  iVar10 = FUN_0041bfc0(param_8,s_CurrentTemperature_00519c91);
  iVar11 = FUN_0041bfc0(param_8,s_DegradationTemperature_00519ca4);
  iVar12 = FUN_0041bfc0(param_8,s_FailureTemperature_00519cbb);
  iVar15 = *(int *)(param_3 + 0x4c);
  piVar13 = (int *)FUN_00402298(0xb8);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c4170(piVar13,uVar1,param_2,param_3,param_4,param_5,param_6 + 0x13,
                           param_7 + 0x10,param_6 + 0xdc,param_7 + 0x1f,param_11,0xff,0,iVar10,
                           iVar11,iVar12,s_HorizTwoPartBar_0051994c);
  }
  param_1[0x26] = piVar13;
  piVar13 = (int *)FUN_00402298(0xb4);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c70a4(piVar13,uVar2,param_2,param_3,param_4,param_5,param_6 + 0xe5,
                           param_7 + 0xe,s_btploop_pcc_00519cce,0xff,0,7,1,param_8,
                           s_CoolingLoop_00519a42);
  }
  param_1[0x27] = piVar13;
  if (iVar8 == 0) {
    param_1[0x29] = 0;
  }
  else {
    piVar13 = (int *)FUN_00402298(0xb4);
    if (piVar13 == (int *)0x0) {
      piVar13 = (int *)0x0;
    }
    else {
      piVar13 = FUN_004c7160(piVar13,uVar3,param_2,param_3,param_4,param_5,param_6 + 0x10e,
                             param_7 + 0xe,s_btpbus_pcc_00519cda,0xff,0,5,1,iVar8,
                             s_PowerSource_00519a4e);
    }
    param_1[0x29] = piVar13;
  }
  iVar16 = *(int *)(param_8 + 0x1e0);
  param_1[0x24] = 0;
  if ((-1 < iVar16) && (*(int *)(param_13 + iVar16 * 4) != 0)) {
    puVar14 = (undefined4 *)FUN_00402298(0x7c);
    if (puVar14 == (undefined4 *)0x0) {
      puVar14 = (undefined4 *)0x0;
    }
    else {
      puVar14 = FUN_00471d00(puVar14,param_2,param_3,param_4,param_5,param_6 + 0x90,param_7 + 0x36,
                             *(char **)(param_13 + iVar16 * 4),0,0xff,0,s_BackgroundBitmap_00519843)
      ;
    }
    param_1[0x24] = puVar14;
  }
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_6,param_7);
  (**(code **)(param_1[0x12] + 0x18))(param_1 + 0x12,0xff);
  FUN_004c2ec4(9,0xb4,param_1 + 0x12,iVar15,param_12);
  iVar15 = FUN_00447f1c(param_3,param_10);
  iVar9 = FUN_00417ab4(iVar9);
  iVar16 = FUN_0041bfc0(iVar9,s_CurrentTemperature_00519ce5);
  iVar9 = FUN_0041bfc0(iVar9,s_DegradationTemperature_00519cf8);
  iVar17 = FUN_0041bfc0(param_8,s_CoolantMassLeakRate_00519d0f);
  piVar13 = (int *)FUN_00402298(0xb4);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c70a4(piVar13,uVar1,param_9,param_3,param_4,iVar15,0x254,0x13b,
                           s_bteloop_pcc_00519d23,0xff,0,7,1,param_8,s_CoolingLoop_00519a42);
  }
  param_1[0x28] = piVar13;
  piVar13 = (int *)FUN_00402298(0xb4);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c5148(piVar13,uVar2,param_9,param_3,param_4,iVar15,400,10,
                           s_btecmode_pcc_00519d2f,0xff,0,1,2,param_8 + 0x134,
                           s_OneOfSeveralInt_00519989);
  }
  param_1[0x2d] = piVar13;
  if (iVar8 == 0) {
    param_1[0x2a] = 0;
    param_1[0x25] = 0;
    param_1[0x2e] = 0;
  }
  else {
    piVar13 = (int *)FUN_00402298(0xb4);
    if (piVar13 == (int *)0x0) {
      piVar13 = (int *)0x0;
    }
    else {
      piVar13 = FUN_004c7160(piVar13,uVar3,param_9,param_3,param_4,iVar15,0x1a,0xd0,
                             s_btebus_pcc_00519d3c,0xff,0,5,1,iVar8,s_PowerSource_00519a4e);
    }
    param_1[0x2a] = piVar13;
    piVar13 = (int *)FUN_00402298(0xcc);
    if (piVar13 == (int *)0x0) {
      piVar13 = (int *)0x0;
    }
    else {
      piVar13 = FUN_004c721c(piVar13,uVar4,param_9,param_3,param_4,iVar15,0x89,0x82,0x93,0x13b,
                             s_evolt_pcc_00519d47,0xff,0,3,0.0,12000.0,iVar8,
                             s_GeneratorVoltage_slotOf__00519a5a);
    }
    param_1[0x25] = piVar13;
    iVar8 = FUN_0041a1a4(**(int **)(param_8 + 0xc),0x50f4bc);
    if (iVar8 == 0) {
      param_1[0x2e] = 0;
    }
    else {
      piVar13 = (int *)FUN_00402298(0xb4);
      if (piVar13 == (int *)0x0) {
        piVar13 = (int *)0x0;
      }
      else {
        piVar13 = FUN_004c5470(piVar13,uVar1,param_9,param_3,param_4,iVar15,0xbe,0,
                               s_btemode_pcc_00519d51,0xff,0,1,3,param_8 + 0x2b8,
                               s_OneOfSeveralStates_005199ac);
      }
      param_1[0x2e] = piVar13;
    }
  }
  piVar13 = (int *)FUN_00402298(0xbc);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c4724(piVar13,uVar5,param_9,param_3,param_4,iVar15,0x1d1,0x5c,0x1eb,0x124,
                           param_11,0xff,0xff,0,iVar10,iVar11,iVar12,s_VertTwoPartBar_0051995c);
  }
  param_1[0x2c] = piVar13;
  piVar13 = (int *)FUN_00402298(0xbc);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c4724(piVar13,uVar6,param_9,param_3,param_4,iVar15,0x222,0x5c,0x23d,0x124,
                           param_11,0xff,0xff,0,iVar16,iVar9,iVar12,s_VertTwoPartBar_0051995c);
  }
  param_1[0x2b] = piVar13;
  piVar13 = (int *)FUN_00402298(0xb8);
  if (piVar13 == (int *)0x0) {
    piVar13 = (int *)0x0;
  }
  else {
    piVar13 = FUN_004c5b7c(piVar13,uVar7,param_9,param_3,param_4,iVar15,0x255,0xe0,
                           s_eleak_pcc_00519d5d,0,0xff,3,*(int *)(param_8 + 0x150),iVar17,
                           s_LeakGauge_005199ce);
  }
  param_1[0x2f] = piVar13;
  param_1[0x31] = 0;
  param_1[0x30] = param_8;
  return param_1;
}



/* @004c87dc file=? name=FUN_004c87dc */

void __cdecl FUN_004c87dc(int *param_1,byte param_2)

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



/* @004c8808 file=? name=FUN_004c8808 */

void FUN_004c8808(void)

{
  FUN_004448ac();
  return;
}



/* @004c8818 file=? name=FUN_004c8818 */

void FUN_004c8818(void)

{
  return;
}



/* @004c8820 file=? name=FUN_004c8820 */

void __cdecl FUN_004c8820(int param_1)

{
  int *piVar1;
  
  piVar1 = *(int **)(param_1 + 0x90);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0xc))(piVar1);
  }
  (**(code **)(**(int **)(param_1 + 0x98) + 0xc))(*(int **)(param_1 + 0x98));
  (**(code **)(**(int **)(param_1 + 0x9c) + 0xc))(*(int **)(param_1 + 0x9c));
  (**(code **)(**(int **)(param_1 + 0xa0) + 0xc))(*(int **)(param_1 + 0xa0));
  (**(code **)(**(int **)(param_1 + 0xb4) + 0xc))(*(int **)(param_1 + 0xb4));
  piVar1 = *(int **)(param_1 + 0xa4);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0xc))(piVar1);
  }
  piVar1 = *(int **)(param_1 + 0xa8);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0xc))(piVar1);
  }
  piVar1 = *(int **)(param_1 + 0xb8);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0xc))(piVar1);
  }
  piVar1 = *(int **)(param_1 + 0x94);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0xc))(piVar1);
  }
  (**(code **)(**(int **)(param_1 + 0xac) + 0xc))(*(int **)(param_1 + 0xac));
  (**(code **)(**(int **)(param_1 + 0xb0) + 0xc))(*(int **)(param_1 + 0xb0));
  (**(code **)(**(int **)(param_1 + 0xbc) + 0xc))(*(int **)(param_1 + 0xbc));
  *(undefined4 *)(param_1 + 200) = 0;
  return;
}



/* @004c88e4 file=? name=FUN_004c88e4 */

void __cdecl FUN_004c88e4(int *param_1)

{
  int *piVar1;
  int iVar2;
  
  param_1[0x31] = (uint)(*(int *)(param_1[0x30] + 0x40) == 1);
  iVar2 = (**(code **)(*param_1 + 0x48))(param_1);
  if (iVar2 != param_1[0x32]) {
    param_1[0x32] = iVar2;
    (**(code **)(*param_1 + 0x44))(param_1,iVar2);
    if (iVar2 == 0) {
      FUN_004c89c4((int)param_1,0);
      piVar1 = (int *)param_1[0x24];
      if (piVar1 != (int *)0x0) {
        (**(code **)(*piVar1 + 0xc))(piVar1);
      }
    }
    else {
      piVar1 = param_1 + 0x12;
      (**(code **)(param_1[0x12] + 0x18))(piVar1,0);
      (**(code **)(param_1[0x12] + 0x24))(piVar1,1,0x32);
      (**(code **)(param_1[0x12] + 0x48))(piVar1,0x136,0xad);
      FUN_004c89c4((int)param_1,0xff);
    }
  }
  return;
}



/* @004c8990 file=? name=FUN_004c8990 */

undefined4 __cdecl FUN_004c8990(int param_1)

{
  if (*(int *)(param_1 + 0xc4) != 0) {
    return 1;
  }
  if (*(int *)(*(int *)(param_1 + 0xc0) + 0x278) != 4) {
    return 1;
  }
  return 0;
}



/* @004c89c4 file=? name=FUN_004c89c4 */

void __cdecl FUN_004c89c4(int param_1,undefined4 param_2)

{
  int iVar1;
  
  iVar1 = param_1 + 0x48;
  (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,param_2);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,9,0x33);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x38))(iVar1,0x132,0xab);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,9,0xab);
  (**(code **)(*(int *)(param_1 + 0x48) + 0x38))(iVar1,0x132,0x33);
  return;
}



/* @004c8a28 file=? name=FUN_004c8a28 */

void __cdecl FUN_004c8a28(int param_1,int param_2)

{
  FUN_00444650(*(int **)(param_1 + 0x98),param_2);
  FUN_00444650(*(int **)(param_1 + 0x9c),param_2);
  if (*(int **)(param_1 + 0xa4) != (int *)0x0) {
    FUN_00444650(*(int **)(param_1 + 0xa4),param_2);
  }
  return;
}



/* @004c8a6c file=? name=FUN_004c8a6c */

int * __cdecl
FUN_004c8a6c(int *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,int param_9,undefined4 param_10,char *param_11,char *param_12,
            char *param_13,char *param_14,int param_15,undefined4 param_16)

{
  undefined4 uVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  int iVar5;
  int *piVar6;
  undefined4 *puVar7;
  
  FUN_004c8140(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_10,param_11,
               param_12,param_13,param_15,param_16);
  *param_1 = (int)&PTR_FUN_00519fd4;
  uVar1 = FUN_004442dc();
  uVar2 = FUN_004442dc();
  uVar3 = FUN_004442dc();
  uVar4 = FUN_004442dc();
  param_1[0x36] = 0x42c80000;
  iVar5 = FUN_00447f1c(param_3,param_11);
  piVar6 = (int *)FUN_00402298(0xa4);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_004739d8(piVar6,uVar1,param_10,param_3,param_4,iVar5,200,0x110,param_14,0,0xff,
                          param_1 + 0x31,s_TwoState_005198af);
  }
  param_1[0x37] = (int)piVar6;
  param_1[0x33] = param_9;
  param_1[0x34] = 0;
  piVar6 = (int *)FUN_00402298(0xa4);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_004739d8(piVar6,uVar2,param_10,param_3,param_4,iVar5,0x97,0xe8,
                          s_btehfail_pcc_00519d67,0,0xff,param_1 + 0x34,s_TwoState_005198af);
  }
  param_1[0x38] = (int)piVar6;
  piVar6 = (int *)FUN_00402298(0xa4);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_004739d8(piVar6,uVar3,param_10,param_3,param_4,iVar5,0x97,0xc0,
                          s_btepfail_pcc_00519d74,0,0xff,param_8 + 0x324,s_TwoState_005198af);
  }
  param_1[0x39] = (int)piVar6;
  piVar6 = (int *)FUN_00402298(0xa4);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_004739d8(piVar6,uVar4,param_10,param_3,param_4,iVar5,0x97,0x98,
                          s_btesfail_pcc_00519d81,0xff,0,param_8 + 800,s_TwoState_005198af);
  }
  param_1[0x3a] = (int)piVar6;
  piVar6 = (int *)FUN_00402298(0x98);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_00470888(piVar6,uVar3,param_10,param_3,param_4,iVar5,0x132,0x8c,0x15a,0xaa,
                          s_helv18_pcc_00519d8e,3,0,0,0xff,param_1 + 0x36,
                          s_NumericDisplayScalar_005197a5);
  }
  param_1[0x3b] = (int)piVar6;
  puVar7 = (undefined4 *)FUN_00402298(0x18);
  if (puVar7 == (undefined4 *)0x0) {
    puVar7 = (undefined4 *)0x0;
  }
  else {
    puVar7 = FUN_00474855(puVar7,0,param_1 + 0x35,param_8 + 0x31c);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar7);
  return param_1;
}



/* @004c8d18 file=? name=FUN_004c8d18 */

void __cdecl FUN_004c8d18(int *param_1,byte param_2)

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



/* @004c8d44 file=? name=FUN_004c8d44 */

void FUN_004c8d44(void)

{
  FUN_004c8808();
  return;
}



/* @004c8d54 file=? name=FUN_004c8d54 */

void FUN_004c8d54(void)

{
  return;
}



/* @004c8d5c file=? name=FUN_004c8d5c */

void __cdecl FUN_004c8d5c(int param_1)

{
  FUN_004c8820(param_1);
  (**(code **)(**(int **)(param_1 + 0xdc) + 0xc))(*(int **)(param_1 + 0xdc));
  (**(code **)(**(int **)(param_1 + 0xe4) + 0xc))(*(int **)(param_1 + 0xe4));
  (**(code **)(**(int **)(param_1 + 0xe0) + 0xc))(*(int **)(param_1 + 0xe0));
  (**(code **)(**(int **)(param_1 + 0xe8) + 0xc))(*(int **)(param_1 + 0xe8));
  (**(code **)(**(int **)(param_1 + 0xec) + 0xc))(*(int **)(param_1 + 0xec));
  return;
}



/* @004c8db0 file=? name=FUN_004c8db0 */

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

void __cdecl FUN_004c8db0(int *param_1)

{
  if (param_1[0x33] != 0) {
    param_1[0x34] = (uint)(*(int *)(param_1[0x33] + 0x40) == 1);
  }
  param_1[0x36] = (int)((float)param_1[0x35] * _DAT_004c8df0);
  FUN_004c88e4(param_1);
  return;
}



/* @004c8f54 file=? name=FUN_004c8f54 */

void __cdecl FUN_004c8f54(int *param_1,byte param_2)

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



/* @004c8f80 file=? name=FUN_004c8f80 */

void FUN_004c8f80(void)

{
  FUN_004c8808();
  return;
}



/* @004c8f90 file=? name=FUN_004c8f90 */

void FUN_004c8f90(void)

{
  return;
}



/* @004c8f98 file=? name=FUN_004c8f98 */

void __cdecl FUN_004c8f98(int param_1)

{
  FUN_004c8820(param_1);
  (**(code **)(**(int **)(param_1 + 0xd0) + 0xc))(*(int **)(param_1 + 0xd0));
  (**(code **)(**(int **)(param_1 + 0xd4) + 0xc))(*(int **)(param_1 + 0xd4));
  return;
}



/* @004c8fc4 file=? name=FUN_004c8fc4 */

int * __cdecl
FUN_004c8fc4(int *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,undefined4 param_9,char *param_10,char *param_11,char *param_12,
            char *param_13,int param_14,undefined4 param_15)

{
  char *pcVar1;
  undefined4 uVar2;
  int iVar3;
  int iVar4;
  undefined4 *puVar5;
  int *piVar6;
  
  FUN_004c8140(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_14,param_15);
  *param_1 = (int)&PTR_FUN_00519f38;
  uVar2 = FUN_004442b8();
  iVar3 = FUN_0041bfc0(param_8,s_PercentDone_00519dbf);
  iVar4 = FUN_004700ac(param_13);
  param_1[0x33] = iVar4;
  puVar5 = FUN_00442aec(*(int *)(param_3 + 0x4c) + 4,(char *)param_1[0x33],0);
  if (puVar5 == (undefined4 *)0x0) {
    pcVar1 = (char *)param_1[0x33];
    FUN_004dbb24(&DAT_00524e20,s_WeaponCluster_missing___00519dcb,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,pcVar1,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_00519de3,(char *)0x0);
    param_1[0x37] = 0;
    param_1[0x38] = 0;
  }
  else {
    param_1[0x37] = 0x41 - ((int)puVar5[3] >> 1);
    param_1[0x38] = 0x6d - ((int)puVar5[4] >> 1);
  }
  piVar6 = (int *)FUN_00402298(0xc4);
  if (piVar6 == (int *)0x0) {
    piVar6 = (int *)0x0;
  }
  else {
    piVar6 = FUN_004c6244(piVar6,0xffff,param_2,param_3,0,param_5,param_6 + 0x41,param_7 + 0x6d,40.0
                          ,60.0,40.0,60.0,0.0,360.0,0x14,0,0xff,iVar3,1,s_SegmentArc270_00519a02);
  }
  param_1[0x34] = (int)piVar6;
  puVar5 = (undefined4 *)FUN_00402298(0xc0);
  if (puVar5 == (undefined4 *)0x0) {
    puVar5 = (undefined4 *)0x0;
  }
  else {
    puVar5 = FUN_004c6d80(puVar5,uVar2,param_2,param_3,0,param_5,param_6 + 0xee,param_7 + 0x38,
                          param_8,s_ConfigMap_00519a38);
  }
  param_1[0x35] = (int)puVar5;
  puVar5 = (undefined4 *)FUN_00402298(0x18);
  if (puVar5 == (undefined4 *)0x0) {
    puVar5 = (undefined4 *)0x0;
  }
  else {
    puVar5 = FUN_00474855(puVar5,0,param_1 + 0x36,iVar3);
  }
  (**(code **)(*param_1 + 0x34))(param_1,puVar5);
  return param_1;
}



/* @004c91d4 file=? name=FUN_004c91d4 */

void __cdecl FUN_004c91d4(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_00519f38;
    FUN_00442c12(*(int *)(param_1[7] + 0x4c) + 4,(char *)param_1[0x33]);
    FUN_004022e8((int *)param_1[0x33]);
    param_1[0x33] = 0;
    FUN_004c87dc(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c9230 file=? name=FUN_004c9230 */

void FUN_004c9230(void)

{
  FUN_004740c0();
  FUN_004c8808();
  return;
}



/* @004c9250 file=? name=FUN_004c9250 */

void FUN_004c9250(void)

{
  return;
}



/* @004c9258 file=? name=FUN_004c9258 */

void __cdecl FUN_004c9258(int param_1)

{
  *(undefined4 *)(param_1 + 0xe4) = 0xfffffffe;
  (**(code **)(**(int **)(param_1 + 0xd4) + 0xc))(*(int **)(param_1 + 0xd4));
  (**(code **)(**(int **)(param_1 + 0xd0) + 0xc))(*(int **)(param_1 + 0xd0));
  FUN_004c8820(param_1);
  return;
}



/* @004c9290 file=? name=FUN_004c9290 */

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

void __cdecl FUN_004c9290(int *param_1)

{
  uint uVar1;
  
  FUN_004c88e4(param_1);
  if ((param_1[0x32] == 0) &&
     (uVar1 = (uint)(_DAT_004c92e0 < (float)param_1[0x36]), uVar1 != param_1[0x39])) {
    param_1[0x39] = uVar1;
    (**(code **)(*param_1 + 0x4c))(param_1,uVar1);
  }
  return;
}



/* @004c92e4 file=? name=FUN_004c92e4 */

void __cdecl FUN_004c92e4(int param_1,int param_2)

{
  FUN_00444650(*(int **)(param_1 + 0xd4),param_2);
  FUN_00444650(*(int **)(param_1 + 0xd0),param_2);
  if (param_2 == 0) {
    *(undefined4 *)(param_1 + 0xe4) = 0xfffffffe;
  }
  FUN_004c8a28(param_1,param_2);
  return;
}



/* @004c932c file=? name=FUN_004c932c */

void __cdecl FUN_004c932c(int param_1,int param_2)

{
  undefined4 *puVar1;
  undefined4 uVar2;
  
  puVar1 = FUN_00442aec(*(int *)(*(int *)(param_1 + 0x1c) + 0x4c) + 4,*(char **)(param_1 + 0xcc),0);
  if (puVar1 != (undefined4 *)0x0) {
    (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
              (param_1 + 0x48,*(undefined4 *)(param_1 + 0xdc),*(undefined4 *)(param_1 + 0xe0));
    uVar2 = 0;
    if (param_2 != 0) {
      uVar2 = 0xff;
    }
    (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,uVar2);
    (**(code **)(*(int *)(param_1 + 0x48) + 0x54))
              (param_1 + 0x48,0,puVar1,0,0,puVar1[3] + -1,puVar1[4] + -1);
  }
  return;
}



/* @004c93b0 file=? name=FUN_004c93b0 */

int * __cdecl
FUN_004c93b0(int *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,undefined4 param_9,char *param_10,char *param_11,char *param_12,
            char *param_13,int param_14,undefined4 param_15)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  int *piVar5;
  
  FUN_004c8fc4(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_15);
  *param_1 = (int)&PTR_FUN_00519ee8;
  uVar1 = FUN_004442dc();
  iVar2 = FUN_00447f1c(param_3,param_10);
  iVar3 = FUN_0041bfc0(param_8,s_OutputVoltage_00519de7);
  puVar4 = (undefined4 *)FUN_00402298(0xcc);
  if (puVar4 == (undefined4 *)0x0) {
    puVar4 = (undefined4 *)0x0;
  }
  else {
    puVar4 = FUN_004c6798(puVar4,0xffff,param_9,param_3,0,iVar2,param_8,iVar3,
                          s_edestryd_pcc_00519df5,1,s_EngrGraph_00519a2e);
  }
  param_1[0x3a] = (int)puVar4;
  piVar5 = (int *)FUN_00402298(0xb4);
  if (piVar5 == (int *)0x0) {
    piVar5 = (int *)0x0;
  }
  else {
    piVar5 = FUN_004c5148(piVar5,uVar1,param_9,param_3,param_4,iVar2,0xf,0,s_bteseek_pcc_00519e02,
                          0xff,0,1,4,param_8 + 0x3f0,s_OneOfSeveralInt_00519989);
  }
  param_1[0x3b] = (int)piVar5;
  return param_1;
}



/* @004c94dc file=? name=FUN_004c94dc */

void __cdecl FUN_004c94dc(int *param_1,byte param_2)

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



/* @004c9508 file=? name=FUN_004c9508 */

void FUN_004c9508(void)

{
  FUN_004c9230();
  return;
}



/* @004c9518 file=? name=FUN_004c9518 */

void FUN_004c9518(void)

{
  return;
}



/* @004c9520 file=? name=FUN_004c9520 */

void __cdecl FUN_004c9520(int param_1)

{
  FUN_004c9258(param_1);
  (**(code **)(**(int **)(param_1 + 0xe8) + 0xc))(*(int **)(param_1 + 0xe8));
  (**(code **)(**(int **)(param_1 + 0xec) + 0xc))(*(int **)(param_1 + 0xec));
  *(undefined4 *)(param_1 + 0xe4) = 0xffffffff;
  return;
}



/* @004c9558 file=? name=FUN_004c9558 */

int * __cdecl
FUN_004c9558(int *param_1,undefined4 param_2,int param_3,undefined4 param_4,int param_5,int param_6,
            int param_7,int param_8,undefined4 param_9,char *param_10,char *param_11,char *param_12,
            char *param_13,int param_14,char *param_15,char *param_16,undefined4 param_17)

{
  int *piVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  undefined4 uVar4;
  undefined4 uVar5;
  undefined4 uVar6;
  int iVar7;
  int iVar8;
  undefined4 *puVar9;
  undefined4 *puVar10;
  
  FUN_004c8fc4(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,param_9,param_10,
               param_11,param_12,param_13,param_14,param_17);
  *param_1 = (int)&PTR_FUN_00519e98;
  piVar1 = (int *)FUN_00414b60();
  param_1[0x3d] = *piVar1;
  param_1[0x3e] = (int)((float)param_1[0x3d] / DAT_0052140c);
  uVar2 = FUN_00444290();
  uVar3 = FUN_004442b8();
  uVar4 = FUN_004442b8();
  uVar5 = FUN_004442b8();
  uVar6 = FUN_004442dc();
  iVar7 = FUN_00417ab4(param_8 + 0x43c);
  piVar1 = (int *)FUN_00402298(0x98);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_00470cfc(piVar1,uVar3,param_2,param_3,param_4,param_5,param_6 + 0x27,param_7 + 100,
                          param_6 + 0x5f,param_7 + 0x76,param_15,4,0,0,0xff,iVar7 + 0x180,
                          s_NumericDisplayInteger_005197ba);
  }
  param_1[0x45] = (int)piVar1;
  iVar8 = FUN_00447f1c(param_3,param_10);
  piVar1 = (int *)FUN_00402298(0x98);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_00470cfc(piVar1,uVar4,param_9,param_3,param_4,iVar8,0xdc,0x104,0x140,300,param_16,4
                          ,0,0,0xff,iVar7 + 0x180,s_NumericDisplayInteger_005197ba);
  }
  param_1[0x46] = (int)piVar1;
  param_1[0x3a] = 0;
  piVar1 = (int *)FUN_00402298(0xa4);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_004739d8(piVar1,uVar5,param_9,param_3,param_4,iVar8,0xa0,0xb2,s_btejam_pcc_00519e0e
                          ,0,0xff,param_1 + 0x3a,s_TwoState_005198af);
  }
  param_1[0x42] = (int)piVar1;
  param_1[0x3b] = 0;
  param_1[0x3c] = 0;
  piVar1 = (int *)FUN_00402298(0xa4);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_004739d8(piVar1,uVar5,param_9,param_3,param_4,iVar8,0x121,0xb6,
                          s_btefire_pcc_00519e19,0,0xff,param_1 + 0x3b,s_TwoState_005198af);
  }
  param_1[0x43] = (int)piVar1;
  puVar9 = (undefined4 *)FUN_00402298(0x48);
  if (puVar9 == (undefined4 *)0x0) {
    puVar9 = (undefined4 *)0x0;
  }
  else {
    puVar10 = (undefined4 *)FUN_00447f84(param_3,iVar8);
    puVar9 = FUN_0044ad78(puVar9,puVar10);
  }
  param_1[0x3f] = (int)puVar9;
  piVar1 = (int *)FUN_00402298(0xac);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_00473c94(piVar1,uVar5,param_9,param_3,param_4,iVar8,0x130,0xbc,0x162,0xee,
                          s_helv42_pcc_00519e25,2,0,0,0xff,param_1 + 0x3e,param_1 + 0x3b,
                          s_NumericDisplayScalarTwoState_005198b8);
  }
  param_1[0x40] = (int)piVar1;
  piVar1 = (int *)FUN_00402298(0xa4);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_004739d8(piVar1,uVar6,param_9,param_3,param_4,iVar8,0xc2,0x85,
                          s_edestryd_pcc_00519e30,0,0xff,param_1 + 0x31,s_TwoState_005198af);
  }
  param_1[0x41] = (int)piVar1;
  piVar1 = (int *)FUN_00402298(0xac);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_004c61c8(piVar1,uVar2,param_9,param_3,param_4,iVar8,0xf,0,s_bteejtm_pcc_00519e3d,0,
                          0xff,param_8 + 0x3f8,s_BitMapInverseWipeScalar_005199ea);
  }
  param_1[0x44] = (int)piVar1;
  return param_1;
}



/* @004c9940 file=? name=FUN_004c9940 */

void __cdecl FUN_004c9940(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_00519e98;
    puVar1 = (undefined4 *)param_1[0x3f];
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
    param_1[0x3f] = 0;
    puVar1 = (undefined4 *)param_1[0x40];
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
    param_1[0x40] = 0;
    FUN_004c91d4(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c99a4 file=? name=FUN_004c99a4 */

void FUN_004c99a4(void)

{
  FUN_00470e0c();
  FUN_004c9230();
  return;
}



/* @004c99c4 file=? name=FUN_004c99c4 */

void FUN_004c99c4(void)

{
  return;
}



/* @004c99cc file=? name=FUN_004c99cc */

void __cdecl FUN_004c99cc(int param_1)

{
  (**(code **)(**(int **)(param_1 + 0x114) + 0xc))(*(int **)(param_1 + 0x114));
  (**(code **)(**(int **)(param_1 + 0x118) + 0xc))(*(int **)(param_1 + 0x118));
  (**(code **)(**(int **)(param_1 + 0x104) + 0xc))(*(int **)(param_1 + 0x104));
  (**(code **)(**(int **)(param_1 + 0x108) + 0xc))(*(int **)(param_1 + 0x108));
  (**(code **)(**(int **)(param_1 + 0x10c) + 0xc))(*(int **)(param_1 + 0x10c));
  (**(code **)(**(int **)(param_1 + 0x100) + 0xc))(*(int **)(param_1 + 0x100));
  (**(code **)(**(int **)(param_1 + 0x110) + 0xc))(*(int **)(param_1 + 0x110));
  FUN_004c9258(param_1);
  return;
}



/* @004c9a38 file=? name=FUN_004c9a38 */

void __cdecl FUN_004c9a38(int *param_1)

{
  int iVar1;
  int iVar2;
  int *piVar3;
  
  param_1[0x3a] = (uint)(*(int *)(param_1[0x30] + 0x364) == 5);
  iVar2 = FUN_00417ab4(param_1[0x30] + 0x43c);
  iVar1 = *(int *)(iVar2 + 0x18c);
  param_1[0x3b] = iVar1;
  if (iVar1 == 0) {
    if (param_1[0x3c] != 0) {
      param_1[0x3c] = 0;
    }
  }
  else {
    param_1[0x3c] = 1;
    piVar3 = (int *)FUN_00414b60();
    param_1[0x3d] = *piVar3;
    param_1[0x3d] = param_1[0x3d] - *(int *)(iVar2 + 400);
    param_1[0x3e] = (int)((float)param_1[0x3d] / DAT_0052140c);
  }
  FUN_004c9290(param_1);
  return;
}



/* @004c9adc file=? name=FUN_004c9adc */

undefined4 __cdecl FUN_004c9adc(int param_1)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_00417ab4(*(int *)(param_1 + 0xc0) + 0x43c);
  if (*(int *)(iVar1 + 0x180) == 0) {
    return 1;
  }
  if (*(int *)(param_1 + 0xe8) != 0) {
    return 1;
  }
  uVar2 = FUN_004c8990(param_1);
  return uVar2;
}



/* @004c9b24 file=? name=FUN_004c9b24 */

void __cdecl FUN_004c9b24(int param_1,int param_2)

{
  FUN_00444650(*(int **)(param_1 + 0x114),param_2);
  FUN_004c92e4(param_1,param_2);
  return;
}



/* @004c9b50 file=? name=FUN_004c9b50 */

void __cdecl FUN_004c9b50(int param_1,int param_2)

{
  FUN_004c932c(param_1,param_2);
  if (param_2 == 0) {
    FUN_00470ec8(*(int *)(param_1 + 0x114),0,0xff);
  }
  else {
    FUN_00470ec8(*(int *)(param_1 + 0x114),0xff,0);
  }
  return;
}



/* @004c9bd0 file=? name=FUN_004c9bd0 */

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

{
  uint *puVar1;
  int *piVar2;
  undefined4 uVar3;
  undefined **ppuVar4;
  undefined4 *puVar5;
  undefined4 uVar6;
  int iVar7;
  undefined4 uVar8;
  int iVar9;
  int iVar10;
  int iVar11;
  char *pcVar12;
  char *pcVar13;
  int iVar14;
  undefined4 uVar15;
  uint *local_10;
  int local_c;
  int local_8;
  
  local_8 = 0;
  ppuVar4 = &PTR_s_dz_door_0051a240;
  puVar5 = param_1;
  do {
    pcVar12 = *ppuVar4;
    puVar1 = (uint *)FUN_00402298(0x10);
    if (puVar1 == (uint *)0x0) {
      local_10 = (uint *)0x0;
    }
    else {
      local_10 = FUN_00402460(puVar1,pcVar12);
    }
    local_10[3] = local_10[3] + 1;
    local_c = FUN_0042076c(param_7,(int *)&local_10);
    piVar2 = (int *)FUN_00402298(0x70);
    if (piVar2 == (int *)0x0) {
      piVar2 = (int *)0x0;
    }
    else {
      uVar6 = param_3;
      iVar7 = param_4;
      uVar8 = param_5;
      iVar9 = param_6;
      iVar10 = param_7;
      iVar11 = param_8;
      pcVar12 = param_9;
      pcVar13 = param_10;
      iVar14 = local_c;
      uVar15 = param_11;
      uVar3 = FUN_004442b8();
      piVar2 = FUN_004c3b98(piVar2,uVar3,uVar6,iVar7,uVar8,iVar9,iVar10,iVar11,pcVar12,pcVar13,
                            iVar14,uVar15);
    }
    *puVar5 = piVar2;
    puVar1 = local_10 + 3;
    *puVar1 = *puVar1 - 1;
    if (*puVar1 == 0) {
      FUN_004024d8((int *)local_10,3);
    }
    local_8 = local_8 + 1;
    param_8 = param_8 + 1;
    ppuVar4 = ppuVar4 + 1;
    puVar5 = puVar5 + 1;
  } while (local_8 < 0x1c);
  return param_1;
}



/* @004c9ca8 file=? name=FUN_004c9ca8 */

void __cdecl FUN_004c9ca8(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  int *piVar2;
  int iVar3;
  
  if (param_1 != (int *)0x0) {
    iVar3 = 0;
    piVar2 = param_1;
    do {
      puVar1 = (undefined4 *)*piVar2;
      if (puVar1 != (undefined4 *)0x0) {
        (**(code **)*puVar1)(puVar1,3);
      }
      *piVar2 = 0;
      iVar3 = iVar3 + 1;
      piVar2 = piVar2 + 1;
    } while (iVar3 < 0x1c);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004c9ce8 file=? name=FUN_004c9ce8 */

undefined4 FUN_004c9ce8(void)

{
  return 1;
}



/* @004c9cf4 file=? name=FUN_004c9cf4 */

void __cdecl FUN_004c9cf4(undefined4 *param_1)

{
  int iVar1;
  
  iVar1 = 0;
  do {
    (**(code **)(*(int *)*param_1 + 0xc))((int *)*param_1);
    iVar1 = iVar1 + 1;
    param_1 = param_1 + 1;
  } while (iVar1 < 0x1c);
  return;
}



/* @004c9d18 file=? name=FUN_004c9d18 */

void __cdecl FUN_004c9d18(int *param_1,undefined4 param_2)

{
  int iVar1;
  
  iVar1 = 0;
  do {
    FUN_004c3c38(*param_1,param_2);
    iVar1 = iVar1 + 1;
    param_1 = param_1 + 1;
  } while (iVar1 < 0x1c);
  return;
}



/* @004c9d44 file=? name=FUN_004c9d44 */

bool __cdecl
FUN_004c9d44(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5)

{
  int iVar1;
  undefined4 *puVar2;
  
  puVar2 = (undefined4 *)FUN_00402298(0xc4);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_004c9e10(puVar2,DAT_0051a2bc,DAT_0051a300,param_5,0,param_1,param_2,param_3,&DAT_0051a344,
                 DAT_0051a388,DAT_0051a3cc,s_SectorDisplay_0051bb34);
  }
  iVar1 = *(int *)(param_5 + 0x4c);
  puVar2 = FUN_00442aec(iVar1 + 4,&DAT_0051a344,0);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_00442c12(iVar1 + 4,&DAT_0051a344);
  }
  else {
    FUN_004dbb24(&DAT_00524e20,s_SectorDisplay__Missing_image___0051bc90,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_0051a344,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,&DAT_0051bcaf,(char *)0x0);
  }
  return puVar2 != (undefined4 *)0x0;
}



/* @004c9e10 file=? name=FUN_004c9e10 */

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

{
  int iVar1;
  undefined4 uVar2;
  undefined4 *puVar3;
  int *piVar4;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_12);
  *param_1 = &PTR_FUN_0051beec;
  uVar2 = FUN_004700ac(param_9);
  param_1[0x25] = uVar2;
  param_1[0x2a] = param_10;
  param_1[0x2b] = param_11;
  param_1[0x24] = 0;
  param_1[0x2d] = 500;
  param_1[0x2c] = 500;
  iVar1 = *(int *)(param_4 + 0x4c);
  puVar3 = FUN_00442aec(iVar1 + 4,(char *)param_1[0x25],0);
  if (puVar3 == (undefined4 *)0x0) {
    param_1[0x26] = 0;
    param_1[0x27] = 0;
    param_1[0x28] = 0;
    param_1[0x29] = 0;
  }
  else {
    param_1[0x26] = (int)puVar3[3] / 0xe;
    param_1[0x27] = param_1[0x26] * 0xc;
    param_1[0x28] = param_1[0x26] * 0xc + param_1[0x26] + -1;
    param_1[0x29] = puVar3[4];
  }
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_7,param_8);
  piVar4 = (int *)FUN_00402298(0x44);
  if (piVar4 == (int *)0x0) {
    piVar4 = (int *)0x0;
  }
  else {
    piVar4 = FUN_004700bc(piVar4,iVar1,0,0,param_9,3,0,param_10,param_11);
  }
  param_1[0x2f] = piVar4;
  piVar4 = (int *)FUN_00402298(0x44);
  if (piVar4 == (int *)0x0) {
    piVar4 = (int *)0x0;
  }
  else {
    piVar4 = FUN_004700bc(piVar4,iVar1,param_1[0x26] << 2,0,param_9,3,0,param_10,param_11);
  }
  param_1[0x30] = piVar4;
  return param_1;
}



/* @004c9f94 file=? name=FUN_004c9f94 */

void __cdecl FUN_004c9f94(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051beec;
    FUN_00442c12(*(int *)(param_1[7] + 0x4c) + 4,(char *)param_1[0x25]);
    FUN_004022e8((int *)param_1[0x25]);
    param_1[0x25] = 0;
    FUN_0047018c((int *)param_1[0x2f],3);
    param_1[0x2f] = 0;
    FUN_0047018c((int *)param_1[0x30],3);
    param_1[0x30] = 0;
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ca020 file=? name=FUN_004ca020 */

void FUN_004ca020(void)

{
  FUN_004448ac();
  return;
}



/* @004ca030 file=? name=FUN_004ca030 */

void FUN_004ca030(void)

{
  return;
}



/* @004ca038 file=? name=FUN_004ca038 */

void __cdecl FUN_004ca038(int param_1)

{
  *(undefined4 *)(param_1 + 0xb8) = 1;
  FUN_004703f4(*(int *)(param_1 + 0xc0));
  FUN_004703f4(*(int *)(param_1 + 0xbc));
  return;
}



/* @004ca068 file=? name=FUN_004ca068 */

void __cdecl FUN_004ca068(int param_1,undefined4 param_2)

{
  *(undefined4 *)(param_1 + 0x90) = param_2;
  return;
}



/* @004ca07c file=? name=FUN_004ca07c */

void __cdecl FUN_004ca07c(int param_1)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  
  if (*(int *)(param_1 + 0x90) != 0) {
    iVar2 = FUN_004dcd94();
    iVar3 = FUN_004dcd94();
    piVar1 = (int *)(param_1 + 0x48);
    FUN_00470430(*(int **)(param_1 + 0xbc),piVar1,(float)(iVar2 + *(int *)(param_1 + 0xb0)));
    FUN_00470430(*(int **)(param_1 + 0xc0),piVar1,(float)(iVar3 + *(int *)(param_1 + 0xb4)));
    if (*(int *)(param_1 + 0xb8) != 0) {
      *(undefined4 *)(param_1 + 0xb8) = 0;
      puVar4 = FUN_00442aec(*(int *)(*(int *)(param_1 + 0x1c) + 0x4c) + 4,*(char **)(param_1 + 0x94)
                            ,0);
      if (puVar4 != (undefined4 *)0x0) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(piVar1,*(int *)(param_1 + 0x98) * 3,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(piVar1,*(undefined4 *)(param_1 + 0xac));
        (**(code **)(*(int *)(param_1 + 0x48) + 0x54))
                  (piVar1,0,puVar4,*(undefined4 *)(param_1 + 0x9c),0,*(undefined4 *)(param_1 + 0xa0)
                   ,*(undefined4 *)(param_1 + 0xa4));
      }
    }
  }
  return;
}



/* @004ca208 file=? name=FUN_004ca208 */

undefined4 * __cdecl
FUN_004ca208(undefined4 *param_1,undefined4 param_2,undefined4 param_3,int param_4,
            undefined4 param_5,int param_6,undefined4 param_7,int param_8,char *param_9,
            undefined4 param_10,int param_11,undefined4 param_12,undefined4 param_13)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  int *piVar4;
  int iVar5;
  int local_1c;
  int local_18;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_13);
  *param_1 = &PTR_FUN_0051bea8;
  param_1[0x29] = param_10;
  param_1[0x28] = param_12;
  param_1[0x26] = param_7;
  param_1[0x27] = param_8 + -0x20;
  iVar1 = *(int *)(param_4 + 0x4c);
  puVar3 = FUN_00442aec(iVar1 + 4,param_9,0);
  iVar2 = puVar3[3];
  iVar5 = (iVar2 / 0xe) * 8;
  FUN_00442c12(iVar1 + 4,param_9);
  param_1[0x2a] = iVar5 + 0x86;
  if ((*(byte *)(param_1 + 0x28) & 4) != 0) {
    param_1[0x2a] = param_1[0x2a] + iVar2 / 0xe + 0x20;
  }
  puVar3 = param_1 + 0x3b;
  local_1c = param_1[0x27] + 3;
  local_18 = 0;
  do {
    piVar4 = (int *)FUN_00402298(0x44);
    if (piVar4 == (int *)0x0) {
      piVar4 = (int *)0x0;
    }
    else {
      piVar4 = FUN_004700bc(piVar4,iVar1,param_1[0x26] + 0x82,local_1c,param_9,8,2,0,param_11);
    }
    *puVar3 = piVar4;
    if ((*(byte *)(param_1 + 0x28) & 4) == 0) {
      puVar3[0x11] = 0;
    }
    else {
      piVar4 = (int *)FUN_00402298(0x44);
      if (piVar4 == (int *)0x0) {
        piVar4 = (int *)0x0;
      }
      else {
        piVar4 = FUN_004700bc(piVar4,iVar1,param_1[0x26] + iVar5 + 0xa2,local_1c,param_9,1,0,0,
                              param_11);
      }
      puVar3[0x11] = piVar4;
    }
    puVar3 = puVar3 + 1;
    local_18 = local_18 + 1;
    local_1c = local_1c - param_1[0x29];
  } while (local_18 < 8);
  return param_1;
}



/* @004ca39c file=? name=FUN_004ca39c */

void __cdecl FUN_004ca39c(int *param_1,byte param_2)

{
  int *piVar1;
  int iVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051bea8;
    iVar2 = 0;
    piVar1 = param_1 + 0x3b;
    do {
      if ((int *)*piVar1 != (int *)0x0) {
        FUN_0047018c((int *)*piVar1,3);
        *piVar1 = 0;
      }
      if ((int *)piVar1[0x11] != (int *)0x0) {
        FUN_0047018c((int *)piVar1[0x11],3);
        piVar1[0x11] = 0;
      }
      iVar2 = iVar2 + 1;
      piVar1 = piVar1 + 1;
    } while (iVar2 < 8);
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004ca40c file=? name=FUN_004ca40c */

void FUN_004ca40c(void)

{
  FUN_004448ac();
  return;
}



/* @004ca41c file=? name=FUN_004ca41c */

void FUN_004ca41c(void)

{
  return;
}



/* @004ca424 file=? name=FUN_004ca424 */

void __cdecl FUN_004ca424(int param_1,undefined4 param_2)

{
  *(undefined4 *)(param_1 + 0x90) = param_2;
  return;
}



/* @004ca438 file=? name=FUN_004ca438 */

void __cdecl FUN_004ca438(int param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  *(undefined4 *)(param_1 + 0x94) = 999;
  *(undefined4 *)(param_1 + 0x10c) = 0;
  iVar2 = 0;
  puVar1 = (undefined4 *)(param_1 + 0xac);
  do {
    *puVar1 = 0xffffffff;
    puVar1[8] = 0xba83126f;
    puVar1[0x19] = 0xffffffff;
    iVar2 = iVar2 + 1;
    puVar1 = puVar1 + 1;
  } while (iVar2 < 8);
  return;
}



/* @004ca478 file=? name=FUN_004ca478 */

void __cdecl FUN_004ca478(int param_1)

{
  int iVar1;
  int iVar2;
  int *piVar3;
  undefined4 uVar4;
  int *piVar5;
  int local_54 [3];
  int local_48 [8];
  int local_28;
  float local_24;
  undefined4 local_20;
  int local_1c;
  int local_18;
  uint local_14;
  int local_10;
  int local_c;
  int local_8;
  
  iVar1 = FUN_00403ad0(*(int *)(DAT_004efc94 + 0x24) + 0x18,s_Players_0051bcba);
  if (iVar1 != 0) {
    if (*(int *)(param_1 + 0x90) == 0) {
      local_10 = -1;
      local_14 = 0;
    }
    else {
      iVar2 = *(int *)(*(int *)(param_1 + 0x90) + 400);
      local_10 = *(int *)(iVar2 + 0x1cc);
      iVar2 = FUN_0044fc10(*(int *)(iVar2 + 0x204));
      local_14 = (uint)(iVar2 != -1);
    }
    piVar3 = local_48;
    local_8 = 0;
    do {
      *piVar3 = 0;
      local_8 = local_8 + 1;
      piVar3 = piVar3 + 1;
    } while (local_8 < 8);
    FUN_00421414(local_54,iVar1 + 0x10);
    while (iVar1 = (**(code **)(local_54[0] + 0x28))(local_54), iVar1 != 0) {
      if ((((*(byte *)(iVar1 + 0x29) & 0x40) == 0) && (iVar2 = *(int *)(iVar1 + 0x1cc), iVar2 < 8))
         && (-1 < iVar2)) {
        local_48[iVar2] = iVar1;
      }
    }
    local_c = *(int *)(param_1 + 0x9c);
    local_8 = 0;
    piVar3 = local_48;
    piVar5 = (int *)(param_1 + 0xac);
    do {
      if (*piVar5 != *piVar3) {
        *piVar5 = *piVar3;
        piVar5[8] = -0x1a5697ea;
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
                  (param_1 + 0x48,*(int *)(param_1 + 0x98) + 1,local_c);
        if (*piVar3 == 0) {
          (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,0);
          (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(param_1 + 0x48,0x80,0x20);
          FUN_00470758(piVar5[0x10],(int *)(param_1 + 0x48));
          if (piVar5[0x21] != 0) {
            FUN_00470758(piVar5[0x21],(int *)(param_1 + 0x48));
          }
        }
        else {
          local_18 = *(int *)(DAT_004efc94 + 200);
          local_20 = *(undefined4 *)(*piVar3 + 0x1e0);
          local_1c = (**(code **)(*(int *)(local_18 + 0x68) + 0xc))(local_18 + 0x68,&local_20);
          if (local_1c == 0) {
            (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,0);
            (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(param_1 + 0x48,0x80,0x20);
          }
          else {
            uVar4 = 0xff;
            if (((*(byte *)(param_1 + 0xa0) & 1) != 0) && (*(int *)(*piVar3 + 0x1fc) != 0)) {
              uVar4 = FUN_004c2f88();
            }
            (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,uVar4);
            (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
                      (param_1 + 0x48,0,0,local_1c,0,0,*(int *)(local_1c + 0xc) + -1,
                       *(int *)(local_1c + 0x10) + -1);
          }
        }
      }
      local_8 = local_8 + 1;
      piVar5 = piVar5 + 1;
      piVar3 = piVar3 + 1;
      local_c = local_c - *(int *)(param_1 + 0xa4);
    } while (local_8 < 8);
    piVar5 = (int *)(param_1 + 0xec);
    local_8 = 0;
    piVar3 = local_48;
    do {
      if (*piVar3 == 0) {
        FUN_00470758(*piVar5,(int *)(param_1 + 0x48));
      }
      else {
        local_24 = *(float *)(*piVar3 + 0x1c8);
        if ((float)piVar5[-8] != local_24) {
          piVar5[-8] = (int)local_24;
          if ((local_10 < local_8) && ((*(byte *)(param_1 + 0xa0) & 2) == 0)) {
            FUN_00470758(*piVar5,(int *)(param_1 + 0x48));
          }
          else {
            FUN_00470430((int *)*piVar5,(int *)(param_1 + 0x48),local_24);
          }
        }
      }
      local_8 = local_8 + 1;
      piVar5 = piVar5 + 1;
      piVar3 = piVar3 + 1;
    } while (local_8 < 8);
    if ((*(byte *)(param_1 + 0xa0) & 4) != 0) {
      if (local_14 == 0) {
        if (*(int *)(param_1 + 0x10c) == 1) {
          piVar3 = (int *)(param_1 + 0x130);
          local_8 = 0;
          do {
            FUN_00470758(*piVar3,(int *)(param_1 + 0x48));
            piVar3[-8] = -1;
            local_8 = local_8 + 1;
            piVar3 = piVar3 + 1;
          } while (local_8 < 8);
        }
      }
      else {
        piVar5 = (int *)(param_1 + 0x110);
        local_8 = 0;
        piVar3 = local_48;
        do {
          if (*piVar3 == 0) {
            if (*piVar5 != -1) {
              FUN_00470758(piVar5[8],(int *)(param_1 + 0x48));
              *piVar5 = -1;
            }
          }
          else {
            local_28 = *(int *)(*piVar3 + 0x204);
            iVar1 = FUN_0044fc10(local_28);
            iVar1 = iVar1 - *(int *)(local_28 + 0x40);
            if (iVar1 != *piVar5) {
              *piVar5 = iVar1;
              if (iVar1 == -1) {
                FUN_00470758(piVar5[8],(int *)(param_1 + 0x48));
              }
              else {
                FUN_00470430((int *)piVar5[8],(int *)(param_1 + 0x48),(float)(iVar1 + 1));
              }
            }
          }
          local_8 = local_8 + 1;
          piVar5 = piVar5 + 1;
          piVar3 = piVar3 + 1;
        } while (local_8 < 8);
      }
      *(uint *)(param_1 + 0x10c) = local_14;
    }
    iVar1 = *(int *)(param_1 + 0x94);
    if (iVar1 != local_10) {
      if ((-1 < iVar1) && (iVar1 < 8)) {
        iVar1 = param_1 + 0x48;
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
                  (iVar1,*(undefined4 *)(param_1 + 0x98),
                   (*(int *)(param_1 + 0x9c) - *(int *)(param_1 + 0x94) * *(int *)(param_1 + 0xa4))
                   + -1);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x44))(iVar1,*(undefined4 *)(param_1 + 0xa8),0x22);
      }
      if ((-1 < local_10) && (local_10 < 8)) {
        iVar1 = param_1 + 0x48;
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,0xff);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
                  (iVar1,*(undefined4 *)(param_1 + 0x98),
                   (*(int *)(param_1 + 0x9c) - local_10 * *(int *)(param_1 + 0xa4)) + -1);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x44))(iVar1,*(undefined4 *)(param_1 + 0xa8),0x22);
      }
      *(int *)(param_1 + 0x94) = local_10;
    }
    FUN_00421452(local_54,2);
  }
  return;
}



/* @004ca90c file=? name=FUN_004ca90c */

undefined4 __cdecl FUN_004ca90c(int param_1)

{
  undefined4 *puVar1;
  int in_stack_00000014;
  
  puVar1 = (undefined4 *)FUN_00402298(0x178);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_004ca958(puVar1,DAT_0051ab4c,DAT_0051ab90,in_stack_00000014,0,param_1,&DAT_0051abd4,
                 s_PilotList_0051bb4a);
  }
  return 1;
}



/* @004ca958 file=? name=FUN_004ca958 */

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

{
  int iVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  int *piVar5;
  int *piVar6;
  int *piVar7;
  int local_18;
  int local_14;
  int local_10;
  int local_c;
  int local_8;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_8);
  piVar7 = &DAT_0051af88;
  *param_1 = &PTR_FUN_0051be64;
  param_1[0x24] = 0;
  param_1[0x25] = 0;
  iVar1 = *(int *)(param_4 + 0x4c);
  local_8 = 0;
  piVar6 = param_1 + 0x26;
  do {
    iVar2 = *piVar7;
    iVar3 = piVar7[1];
    iVar4 = piVar7[2];
    if (iVar4 == 0) {
LAB_004ca9cc:
      local_c = iVar2 + 0x95;
      local_10 = iVar3 + -0xd;
      local_14 = iVar2 + 0xe8;
      local_18 = iVar3 + -0xd;
    }
    else if (iVar4 == 1) {
      local_c = iVar2 + -8;
      local_10 = iVar3 + -0x50;
      local_14 = iVar2 + 0x48;
      local_18 = iVar3 + -0x50;
    }
    else {
      if (iVar4 != 2) goto LAB_004ca9cc;
      local_c = iVar2 + -8;
      local_10 = iVar3 + 0x44;
      local_14 = iVar2 + 0x48;
      local_18 = iVar3 + 0x44;
    }
    *piVar6 = iVar2;
    piVar6[1] = iVar3;
    piVar6[2] = 0;
    piVar6[3] = 0;
    piVar5 = (int *)FUN_00402298(0x44);
    if (piVar5 == (int *)0x0) {
      piVar5 = (int *)0x0;
    }
    else {
      piVar5 = FUN_004700bc(piVar5,iVar1,local_c,local_10,param_7,2,2,0,0xff);
    }
    piVar6[4] = (int)piVar5;
    piVar5 = (int *)FUN_00402298(0x44);
    if (piVar5 == (int *)0x0) {
      piVar5 = (int *)0x0;
    }
    else {
      piVar5 = FUN_004700bc(piVar5,iVar1,local_14,local_18,param_7,2,2,0,0xff);
    }
    piVar6[5] = (int)piVar5;
    piVar5 = (int *)FUN_00402298(0x44);
    if (piVar5 == (int *)0x0) {
      piVar5 = (int *)0x0;
    }
    else {
      piVar5 = FUN_004700bc(piVar5,iVar1,iVar2,iVar3,param_7,1,2,0,0xff);
    }
    piVar6[6] = (int)piVar5;
    piVar7 = piVar7 + 3;
    local_8 = local_8 + 1;
    piVar6 = piVar6 + 7;
    if (7 < local_8) {
      return param_1;
    }
  } while( true );
}



/* @004cab10 file=? name=FUN_004cab10 */

void __cdecl FUN_004cab10(int *param_1,byte param_2)

{
  int *piVar1;
  int iVar2;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051be64;
    iVar2 = 0;
    piVar1 = param_1 + 0x26;
    do {
      FUN_0047018c((int *)piVar1[4],3);
      piVar1[4] = 0;
      FUN_0047018c((int *)piVar1[5],3);
      piVar1[5] = 0;
      FUN_0047018c((int *)piVar1[6],3);
      piVar1[6] = 0;
      iVar2 = iVar2 + 1;
      piVar1 = piVar1 + 7;
    } while (iVar2 < 8);
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004cab8c file=? name=FUN_004cab8c */

void FUN_004cab8c(void)

{
  FUN_004448ac();
  return;
}



/* @004cab9c file=? name=FUN_004cab9c */

void FUN_004cab9c(void)

{
  return;
}



/* @004caba4 file=? name=FUN_004caba4 */

void __cdecl FUN_004caba4(int param_1)

{
  int iVar1;
  int iVar2;
  
  iVar2 = 0;
  iVar1 = param_1 + 0x98;
  do {
    *(undefined4 *)(iVar1 + 8) = 0xffffffff;
    iVar2 = iVar2 + 1;
    iVar1 = iVar1 + 0x1c;
  } while (iVar2 < 8);
  *(undefined4 *)(param_1 + 0x90) = 9;
  return;
}



/* @004cabd0 file=? name=FUN_004cabd0 */

void __cdecl FUN_004cabd0(int param_1)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  undefined4 local_c;
  
  iVar4 = **(int **)(*(int *)(DAT_004efc94 + 0x6c) + 0x128);
  iVar2 = FUN_004b0898(iVar4,0);
  if (iVar2 != 0) {
    if (7 < *(int *)(param_1 + 0x90)) {
      *(undefined4 *)(param_1 + 0x90) = 0;
      *(undefined4 *)(param_1 + 0x94) = 0;
    }
    iVar3 = *(int *)(param_1 + 0x90) * 0x1c + param_1;
    if (*(int *)(param_1 + 0x94) == 0) {
      iVar4 = FUN_004b0898(iVar4,*(int *)(param_1 + 0x90));
      if (iVar4 == 0) {
        *(undefined4 *)(param_1 + 0x94) = 1;
      }
    }
    else {
      iVar4 = 0;
    }
    if (iVar4 == 0) {
      if (*(int *)(iVar3 + 0xa0) != 0) {
        piVar1 = (int *)(param_1 + 0x48);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
                  (piVar1,*(undefined4 *)(iVar3 + 0x98),*(undefined4 *)(iVar3 + 0x9c));
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(piVar1,0);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(piVar1,0x80,0x20);
        FUN_00470758(*(int *)(iVar3 + 0xa8),piVar1);
        FUN_00470758(*(int *)(iVar3 + 0xac),piVar1);
        FUN_00470758(*(int *)(iVar3 + 0xb0),piVar1);
      }
    }
    else {
      if (*(int *)(iVar2 + 0x284) == 0) {
        local_c = 0;
      }
      else {
        local_c = (uint)(iVar4 == *(int *)(*(int *)(iVar2 + 0x284) + 400));
      }
      if ((iVar4 != *(int *)(iVar3 + 0xa0)) || (*(uint *)(iVar3 + 0xa4) != local_c)) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x24))
                  (param_1 + 0x48,*(undefined4 *)(iVar3 + 0x98),*(undefined4 *)(iVar3 + 0x9c));
        FUN_004cad70(param_1,iVar4,local_c);
        *(uint *)(iVar3 + 0xa4) = local_c;
      }
      FUN_00470430(*(int **)(iVar3 + 0xa8),(int *)(param_1 + 0x48),(float)*(int *)(iVar4 + 0x27c));
      FUN_00470430(*(int **)(iVar3 + 0xac),(int *)(param_1 + 0x48),(float)*(int *)(iVar4 + 0x280));
    }
  }
  *(int *)(param_1 + 0x90) = *(int *)(param_1 + 0x90) + 1;
  return;
}



/* @004cad70 file=? name=FUN_004cad70 */

void __cdecl FUN_004cad70(int param_1,int param_2,int param_3)

{
  int iVar1;
  undefined4 uVar2;
  undefined4 uVar3;
  undefined4 local_8;
  
  local_8 = *(undefined4 *)(param_2 + 0x1e0);
  iVar1 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                    (*(int *)(DAT_004efc94 + 200) + 0x68,&local_8);
  uVar3 = 0xff;
  if (param_3 == 0) {
    uVar3 = 0;
  }
  uVar2 = 0;
  if (param_3 == 0) {
    uVar2 = 0xff;
  }
  if (iVar1 == 0) {
    (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,uVar3);
    (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(param_1 + 0x48,0x80,0x20);
  }
  else {
    (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,uVar2);
    (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
              (param_1 + 0x48,uVar3,0,iVar1,0,0,*(int *)(iVar1 + 0xc) + -1,
               *(int *)(iVar1 + 0x10) + -1);
  }
  return;
}



/* @004cae20 file=? name=FUN_004cae20 */

void __cdecl FUN_004cae20(int param_1,undefined4 param_2,int param_3,int param_4)

{
  int iVar1;
  bool bVar2;
  int iVar3;
  
  bVar2 = false;
  iVar3 = 0;
  iVar1 = *(int *)(param_3 + 0x204);
  if (iVar1 != 0) {
    iVar3 = FUN_0044fc10(iVar1);
    if (iVar3 != -1) {
      bVar2 = true;
      iVar3 = (iVar3 - *(int *)(iVar1 + 0x40)) + 1;
    }
  }
  if (bVar2) {
    FUN_00470430(*(int **)(param_4 + 0x18),(int *)(param_1 + 0x48),(float)iVar3);
  }
  else {
    FUN_00470758(*(int *)(param_4 + 0x18),(int *)(param_1 + 0x48));
  }
  return;
}



/* @004cae90 file=? name=FUN_004cae90 */

undefined4 __cdecl
FUN_004cae90(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5)

{
  uint uVar1;
  int *piVar2;
  undefined4 *puVar3;
  undefined4 uVar4;
  
  uVar1 = DAT_0051b07c;
  uVar4 = 0;
  if (((int)DAT_0051b07c < 1) || (8 < (int)DAT_0051b07c)) {
    FUN_004dbb24(&DAT_00524e20,s_PlayerStatus__Make_player_number_0051bcd9,(char *)0x0);
    piVar2 = FUN_004db78c(&DAT_00524e20,uVar1);
    FUN_004dbb24(piVar2,&DAT_0051bd0a,(char *)0x0);
  }
  else {
    puVar3 = (undefined4 *)FUN_00402298(200);
    if (puVar3 != (undefined4 *)0x0) {
      FUN_004cb1a8(puVar3,DAT_0051aff4,DAT_0051b038,param_5,0,param_1,param_2,param_3,uVar1,
                   &DAT_0051b0c0,DAT_0051b104,DAT_0051b148,DAT_0051b18c,DAT_0051b1d0,
                   s_PlayerStatus_0051bb54);
    }
    uVar4 = 1;
  }
  return uVar4;
}



/* @004caf50 file=? name=FUN_004caf50 */

void __cdecl FUN_004caf50(int *param_1,undefined1 *param_2,int param_3)

{
  int iVar1;
  int local_c;
  undefined1 local_5;
  
  (**(code **)(*param_1 + 0x1c))(param_1,&local_c,4);
  iVar1 = 0;
  if (0 < local_c) {
    do {
      (**(code **)(*param_1 + 0x1c))(param_1,&local_5,1);
      if (iVar1 < param_3 + -1) {
        *param_2 = local_5;
        param_2 = param_2 + 1;
      }
      iVar1 = iVar1 + 1;
    } while (iVar1 < local_c);
  }
  *param_2 = 0;
  return;
}



/* @004cafac file=? name=FUN_004cafac */

int * __cdecl FUN_004cafac(int param_1,int param_2,int param_3,int *param_4)

{
  uint uVar1;
  byte bVar2;
  int *piVar3;
  undefined4 *puVar4;
  int iVar5;
  byte *pbVar6;
  byte *pbVar7;
  char local_68 [80];
  int local_18;
  int local_14;
  int *local_10;
  int *local_c;
  int local_8;
  
  local_8 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),*(int *)(param_1 + 0x1bc),0x20);
  if (local_8 == 0) {
    uVar1 = *(uint *)(param_1 + 0x1bc);
    FUN_004dbb24(&DAT_00524e20,s_CreateMutantPixelmap8__couldn_t_f_0051bd0d,(char *)0x0);
    piVar3 = FUN_004db78c(&DAT_00524e20,uVar1);
    FUN_004dbb24(piVar3,&DAT_0051bd3d,(char *)0x0);
  }
  else {
    iVar5 = *(int *)(local_8 + 4);
    *(int *)(local_8 + 4) = *(int *)(local_8 + 4) + 1;
    if (iVar5 == 0) {
      FUN_00406cd0(local_8);
    }
    puVar4 = (undefined4 *)FUN_00402298(0x18);
    if (puVar4 == (undefined4 *)0x0) {
      local_c = (int *)0x0;
    }
    else {
      local_c = FUN_004032dc(puVar4,*(undefined4 *)(local_8 + 0x3c),*(undefined4 *)(local_8 + 0x40),
                             0);
    }
    if (local_c == (int *)0x0) {
      FUN_004dbb24(&DAT_00524e20,s_CreateMutantPixelmap8__couldn_t_o_0051bd40,(char *)0x0);
    }
    else {
      FUN_004caf50(local_c,local_68,0x50);
      local_10 = FUN_00442d2b(param_2 + 0x20,local_68,0);
      if (local_10 == (int *)0x0) {
        FUN_004dbb24(&DAT_00524e20,s_CreateMutantPixelmap8_can_t_find_0051bd6d,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,local_68,(char *)0x0);
        FUN_004dbb24(&DAT_00524e20,&DAT_0051bd95,(char *)0x0);
        FUN_004d9c70(&DAT_00524e20);
      }
      else {
        pbVar6 = (byte *)local_10[2];
        if (param_4 == (int *)0x0) {
          piVar3 = (int *)FUN_00402298(0xc);
          if (piVar3 == (int *)0x0) {
            param_4 = (int *)0x0;
          }
          else {
            param_4 = FUN_00449c88(piVar3,*local_10,local_10[1]);
          }
        }
        local_18 = param_3 + -0x20;
        pbVar7 = (byte *)param_4[2];
        for (local_14 = local_10[1]; 0 < local_14; local_14 = local_14 + -1) {
          for (iVar5 = *local_10; 0 < iVar5; iVar5 = iVar5 + -1) {
            bVar2 = *pbVar6;
            pbVar6 = pbVar6 + 1;
            if (0x1f < bVar2) {
              bVar2 = bVar2 + (char)local_18;
            }
            *pbVar7 = bVar2;
            pbVar7 = pbVar7 + 1;
          }
        }
        FUN_00442e51(param_2 + 0x20,local_68);
      }
      FUN_00403310(local_c,3);
    }
    *(int *)(local_8 + 4) = *(int *)(local_8 + 4) + -1;
  }
  return param_4;
}



/* @004cb1a8 file=? name=FUN_004cb1a8 */

undefined4 * __cdecl
FUN_004cb1a8(undefined4 *param_1,undefined4 param_2,undefined4 param_3,int param_4,
            undefined4 param_5,int param_6,undefined4 param_7,undefined4 param_8,int param_9,
            char *param_10,undefined4 param_11,undefined4 param_12,undefined4 param_13,
            undefined4 param_14,undefined4 param_15)

{
  int iVar1;
  int *piVar2;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_15);
  *param_1 = &PTR_FUN_0051be20;
  param_1[0x29] = param_11;
  param_1[0x2a] = param_12;
  param_1[0x2b] = param_13;
  param_1[0x2c] = param_14;
  param_1[0x24] = param_6;
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_7,param_8);
  param_1[0x25] = param_9 + -1;
  param_1[0x26] = 0;
  param_1[0x27] = 0;
  param_1[0x28] = 0;
  param_1[0x2d] = 0;
  iVar1 = *(int *)(param_4 + 0x4c);
  piVar2 = (int *)FUN_00402298(0x44);
  if (piVar2 == (int *)0x0) {
    piVar2 = (int *)0x0;
  }
  else {
    piVar2 = FUN_004700bc(piVar2,iVar1,0x72,0xd8,param_10,5,2,param_1[0x29],param_1[0x2a]);
  }
  param_1[0x2e] = piVar2;
  return param_1;
}



/* @004cb28c file=? name=FUN_004cb28c */

void __cdecl FUN_004cb28c(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051be20;
    param_1[0x26] = 0;
    FUN_0047018c((int *)param_1[0x2e],3);
    param_1[0x2e] = 0;
    if ((int *)param_1[0x28] != (int *)0x0) {
      FUN_00449d0c((int *)param_1[0x28],3);
      param_1[0x28] = 0;
    }
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004cb2f8 file=? name=FUN_004cb2f8 */

void FUN_004cb2f8(void)

{
  FUN_004448ac();
  return;
}



/* @004cb308 file=? name=FUN_004cb308 */

void FUN_004cb308(void)

{
  return;
}



/* @004cb310 file=? name=FUN_004cb310 */

void __cdecl FUN_004cb310(int param_1)

{
  FUN_004703f4(*(int *)(param_1 + 0xb8));
  if (*(undefined4 **)(param_1 + 0xb4) != (undefined4 *)0x0) {
    FUN_004c9cf4(*(undefined4 **)(param_1 + 0xb4));
  }
  *(undefined4 *)(param_1 + 0xbc) = 1;
  *(undefined4 *)(param_1 + 0xc0) = 0xffffffff;
  *(undefined4 *)(param_1 + 0xc4) = 0xffffffff;
  return;
}



/* @004cb358 file=? name=FUN_004cb358 */

void __cdecl FUN_004cb358(int *param_1)

{
  int *piVar1;
  int iVar2;
  int *piVar3;
  undefined4 *puVar4;
  int iVar5;
  uint uVar6;
  int local_20 [3];
  int local_14;
  undefined4 local_10;
  undefined4 *local_c;
  int local_8;
  
  iVar2 = FUN_00403ad0(*(int *)(DAT_004efc94 + 0x24) + 0x18,s_Players_0051bd97);
  if (iVar2 != 0) {
    FUN_00421414(local_20,iVar2 + 0x10);
    iVar2 = (**(code **)(local_20[0] + 0x34))(local_20,param_1[0x25]);
    if ((iVar2 != param_1[0x26]) && (param_1[0x26] = iVar2, iVar2 != 0)) {
      iVar2 = *(int *)(iVar2 + 0x1fc);
      if (iVar2 == 0) {
        param_1[0x26] = 0;
      }
      else {
        local_8 = *(int *)(param_1[7] + 0x4c);
        iVar5 = param_1[0x25] * 0x1c + 0x10;
        piVar3 = FUN_004cafac(iVar2,local_8,iVar5,(int *)param_1[0x28]);
        param_1[0x28] = (int)piVar3;
        if ((int *)param_1[0x2d] != (int *)0x0) {
          FUN_004c9ca8((int *)param_1[0x2d],3);
        }
        local_c = (undefined4 *)FUN_00402298(0x70);
        if (local_c == (undefined4 *)0x0) {
          puVar4 = (undefined4 *)0x0;
        }
        else {
          puVar4 = FUN_004c9bd0(local_c,param_1[9],param_1[6],param_1[7],param_1[5],param_1[0x24],
                                iVar2,iVar5,s_adpal_pcc_0051bd9f,s_adpal2_pcc_0051bda9,
                                s_PlayerStatusMappingGroup_0051bdb4);
        }
        param_1[0x2d] = (int)puVar4;
        local_10 = *(undefined4 *)(param_1[0x26] + 0x1e0);
        iVar2 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                          (*(int *)(DAT_004efc94 + 200) + 0x68,&local_10);
        param_1[0x27] = iVar2;
        (**(code **)(*param_1 + 0xc))(param_1);
      }
    }
    FUN_00421452(local_20,2);
  }
  if (param_1[0x26] != 0) {
    piVar3 = param_1 + 0x12;
    FUN_00470430((int *)param_1[0x2e],piVar3,*(float *)(param_1[0x26] + 0x1c8));
    iVar2 = *(int *)(param_1[0x26] + 0x1fc);
    local_14 = 0;
    iVar5 = FUN_0041a1a4(**(int **)(iVar2 + 0xc),0x50bdb4);
    if (iVar5 != 0) {
      local_14 = FUN_0049fb54(iVar2);
    }
    if (local_14 != param_1[0x31]) {
      param_1[0x31] = local_14;
      if ((int *)param_1[0x2d] != (int *)0x0) {
        FUN_004c9d18((int *)param_1[0x2d],local_14);
      }
    }
    if (param_1[0x2f] != 0) {
      param_1[0x2f] = 0;
      if (param_1[0x28] != 0) {
        (**(code **)(param_1[0x12] + 0x24))(piVar3,1,1);
        piVar1 = (int *)param_1[0x28];
        (**(code **)(param_1[0x12] + 0x5c))(piVar3,1,0,piVar1,0,0,*piVar1 + -1,piVar1[1] + -1);
      }
      (**(code **)(param_1[0x12] + 0x24))(piVar3,1,0xcf);
      if (param_1[0x27] == 0) {
        (**(code **)(param_1[0x12] + 0x18))(piVar3,param_1[0x29]);
        (**(code **)(param_1[0x12] + 0x4c))(piVar3,0x80,0x20);
      }
      else {
        uVar6 = FUN_004c2f94(iVar2);
        (**(code **)(param_1[0x12] + 0x18))(piVar3,uVar6);
        iVar2 = param_1[0x27];
        (**(code **)(param_1[0x12] + 0x58))
                  (piVar3,param_1[0x29],0,iVar2,0,0,*(int *)(iVar2 + 0xc) + -1,
                   *(int *)(iVar2 + 0x10) + -1);
      }
    }
    iVar2 = *(int *)(param_1[0x26] + 0x1c4);
    if (iVar2 != param_1[0x30]) {
      param_1[0x30] = iVar2;
      if (iVar2 == 0) {
        iVar2 = param_1[0x2b];
      }
      else {
        iVar2 = param_1[0x2c];
      }
      (**(code **)(param_1[0x12] + 0x18))(param_1 + 0x12,iVar2);
      (**(code **)(param_1[0x12] + 0x24))(param_1 + 0x12,0,0);
      (**(code **)(param_1[0x12] + 0x44))(param_1 + 0x12,0x9f,0xef);
    }
  }
  return;
}



/* @004cb678 file=? name=FUN_004cb678 */

bool __cdecl
FUN_004cb678(int param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,int param_5)

{
  int iVar1;
  undefined4 *puVar2;
  
  puVar2 = (undefined4 *)FUN_00402298(0xa4);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_004cb704(puVar2,DAT_0051b43c,DAT_0051b480,param_5,0,param_1,param_2,param_3,&DAT_0051b4c4,
                 DAT_0051b508,s_MessageBoard_0051bb61);
  }
  iVar1 = *(int *)(param_5 + 0x4c) + 4;
  puVar2 = FUN_00442aec(iVar1,&DAT_0051b4c4,0);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_00442c12(iVar1,&DAT_0051b4c4);
  }
  return puVar2 != (undefined4 *)0x0;
}



/* @004cb704 file=? name=FUN_004cb704 */

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

{
  char *pcVar1;
  
  FUN_00444818(param_1,param_2,param_3,param_4,param_5,param_6,param_11);
  *param_1 = &PTR_FUN_0051bddc;
  pcVar1 = (char *)FUN_004700ac(param_9);
  param_1[0x25] = pcVar1;
  FUN_00442aec(*(int *)(param_4 + 0x4c) + 4,pcVar1,0);
  (**(code **)(param_1[0x12] + 0x10))(param_1 + 0x12,param_7,param_8);
  param_1[0x26] = param_10;
  param_1[0x24] = 0;
  return param_1;
}



/* @004cb788 file=? name=FUN_004cb788 */

void __cdecl FUN_004cb788(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051bddc;
    FUN_00442c12(*(int *)(param_1[7] + 0x4c) + 4,(char *)param_1[0x25]);
    FUN_004022e8((int *)param_1[0x25]);
    param_1[0x25] = 0;
    FUN_00444870(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004cb7e4 file=? name=FUN_004cb7e4 */

void FUN_004cb7e4(void)

{
  FUN_004448ac();
  return;
}



/* @004cb7f4 file=? name=FUN_004cb7f4 */

void FUN_004cb7f4(void)

{
  return;
}



/* @004cb7fc file=? name=FUN_004cb7fc */

void __cdecl FUN_004cb7fc(int param_1)

{
  *(undefined4 *)(param_1 + 0x9c) = 0xffffffff;
  *(undefined4 *)(param_1 + 0xa0) = 0xfffffffe;
  return;
}



/* @004cb818 file=? name=FUN_004cb818 */

void __cdecl FUN_004cb818(int param_1,undefined4 param_2)

{
  *(undefined4 *)(param_1 + 0x90) = param_2;
  return;
}



/* @004cb82c file=? name=FUN_004cb82c */

void __cdecl FUN_004cb82c(int param_1)

{
  int iVar1;
  undefined4 *puVar2;
  int iVar3;
  undefined4 uVar4;
  int iVar5;
  undefined4 local_14;
  undefined4 local_10;
  int local_c;
  int local_8;
  
  if ((*(int *)(param_1 + 0x90) != 0) &&
     (iVar1 = *(int *)(*(int *)(param_1 + 0x90) + 400), iVar1 != 0)) {
    iVar1 = *(int *)(iVar1 + 0x1dc);
    if (iVar1 == 0) {
      iVar5 = 0;
      iVar1 = -1;
    }
    else {
      iVar5 = *(int *)(iVar1 + 0x10);
      iVar1 = *(int *)(iVar1 + 0xc);
    }
    if (iVar1 != *(int *)(param_1 + 0xa0)) {
      *(int *)(param_1 + 0xa0) = iVar1;
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(param_1 + 0x48,0,0);
      if (*(int *)(param_1 + 0xa0) == -1) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))
                  (param_1 + 0x48,*(undefined4 *)(param_1 + 0x98));
        (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(param_1 + 0x48,0x80,0x20);
      }
      else {
        local_8 = (*(uint *)(param_1 + 0xa0) & 3) << 7;
        local_c = ((int)*(uint *)(param_1 + 0xa0) >> 2) << 5;
        uVar4 = FUN_004c2f88();
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(param_1 + 0x48,uVar4);
        iVar1 = *(int *)(*(int *)(param_1 + 0x1c) + 0x4c);
        puVar2 = FUN_00442aec(iVar1 + 4,*(char **)(param_1 + 0x94),0);
        if (puVar2 != (undefined4 *)0x0) {
          (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
                    (param_1 + 0x48,*(undefined4 *)(param_1 + 0x98),0,puVar2,local_8,local_c,
                     local_8 + 0x7f,local_c + 0x1f);
        }
        FUN_00442c12(iVar1 + 4,*(char **)(param_1 + 0x94));
      }
    }
    if (iVar5 != *(int *)(param_1 + 0x9c)) {
      iVar1 = param_1 + 0x48;
      (**(code **)(*(int *)(param_1 + 0x48) + 0x24))(iVar1,0x80,0);
      if (iVar5 == 0) {
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,*(undefined4 *)(param_1 + 0x98));
        if (*(int *)(param_1 + 0x9c) == -1) {
          (**(code **)(*(int *)(param_1 + 0x48) + 0x4c))(iVar1,0x80,0x20);
        }
        else {
          local_10 = *(undefined4 *)(*(int *)(param_1 + 0x9c) + 0x1e0);
          iVar3 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                            (*(int *)(DAT_004efc94 + 200) + 0x68,&local_10);
          (**(code **)(*(int *)(param_1 + 0x48) + 0x54))
                    (iVar1,0,iVar3,0,0,*(int *)(iVar3 + 0xc) + -1,*(int *)(iVar3 + 0x10) + -1);
        }
      }
      else {
        uVar4 = FUN_004c2f88();
        (**(code **)(*(int *)(param_1 + 0x48) + 0x18))(iVar1,uVar4);
        local_14 = *(undefined4 *)(iVar5 + 0x1e0);
        iVar3 = (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 200) + 0x68) + 0xc))
                          (*(int *)(DAT_004efc94 + 200) + 0x68,&local_14);
        (**(code **)(*(int *)(param_1 + 0x48) + 0x58))
                  (iVar1,*(undefined4 *)(param_1 + 0x98),0,iVar3,0,0,*(int *)(iVar3 + 0xc) + -1,
                   *(int *)(iVar3 + 0x10) + -1);
      }
      *(int *)(param_1 + 0x9c) = iVar5;
    }
  }
  return;
}



/* @004cbea0 file=? name=FUN_004cbea0 */

int * __cdecl FUN_004cbea0(int *param_1)

{
  undefined4 uVar1;
  undefined4 *puVar2;
  
  FUN_0046f97c(param_1);
  *param_1 = (int)&PTR_FUN_0051cebc;
  puVar2 = (undefined4 *)FUN_00402298(0x14);
  if (puVar2 != (undefined4 *)0x0) {
    FUN_00448c54(puVar2);
    *puVar2 = &PTR_FUN_0051ceb0;
  }
  param_1[0x7033] = (int)puVar2;
  uVar1 = *(undefined4 *)(DAT_004efc94 + 0x3c);
  puVar2 = (undefined4 *)FUN_00402298(0x44);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar2 = FUN_00474c4c(puVar2,uVar1);
  }
  param_1[0x7032] = (int)puVar2;
  puVar2 = (undefined4 *)FUN_00402298(0x74);
  if (puVar2 == (undefined4 *)0x0) {
    puVar2 = (undefined4 *)0x0;
  }
  else {
    puVar2 = FUN_00468778(puVar2);
  }
  param_1[0x13] = (int)puVar2;
  FUN_00448928(param_1,s_gauge_l4gauge_cfg_0051ce9e,(int *)&PTR_PTR_0051c910);
  return param_1;
}



/* @004cbf40 file=? name=FUN_004cbf40 */

void __cdecl FUN_004cbf40(int *param_1,byte param_2)

{
  undefined4 *puVar1;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_0051cebc;
    FUN_00447fc0((int)param_1,0);
    puVar1 = (undefined4 *)param_1[0x13];
    if (puVar1 != (undefined4 *)0x0) {
      (**(code **)*puVar1)(puVar1,3);
    }
    param_1[0x13] = 0;
    FUN_0046fbcc(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @004cbf90 file=? name=FUN_004cbf90 */

void __cdecl FUN_004cbf90(int param_1)

{
  FUN_00447b60(param_1);
  return;
}



/* @004cbfa0 file=? name=FUN_004cbfa0 */

void __cdecl FUN_004cbfa0(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),*(int *)(param_2 + 0x1bc),0x12);
  if (iVar1 != 0) {
    iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4518);
    if (iVar1 == 0) {
      iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e6ef8);
      if (iVar1 != 0) {
        FUN_00443864((float *)(param_1 + 0xb0),param_2);
      }
    }
    else {
      FUN_004434f4(param_1 + 0x94,param_2);
    }
  }
  FUN_0046fd6c(param_1,param_2);
  return;
}



/* @004cc028 file=? name=FUN_004cc028 */

void __cdecl FUN_004cc028(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),*(int *)(param_2 + 0x1bc),0x12);
  if (iVar1 != 0) {
    iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4518);
    if (iVar1 == 0) {
      iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e6ef8);
      if (iVar1 != 0) {
        FUN_00443930(param_1 + 0xb0,param_2);
      }
    }
    else {
      FUN_00443510(param_1 + 0x94,param_2);
    }
  }
  FUN_0046fda0(param_1,param_2);
  return;
}



/* @004cc0e1 file=? name=FUN_004cc0e1 */

void __cdecl FUN_004cc0e1(int *param_1,byte param_2)

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



/* @004cc108 file=? name=FUN_004cc108 */

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

{
  int iVar1;
  undefined **ppuVar2;
  
  ppuVar2 = &PTR_s_coolingLoop1_0051cf1c;
  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;
}



/* @004cc148 file=? name=FUN_004cc148 */

undefined4 __cdecl FUN_004cc148(undefined4 param_1)

{
  undefined4 uVar1;
  
  uVar1 = 0xffffffff;
  switch(param_1) {
  case 0:
    uVar1 = 0x2f;
    break;
  case 1:
    uVar1 = 0x2e;
    break;
  case 2:
    uVar1 = 0x2d;
    break;
  case 3:
    uVar1 = 0x2c;
    break;
  case 4:
    uVar1 = 0x2b;
    break;
  case 5:
    uVar1 = 0x2a;
  }
  return uVar1;
}



/* @004cc1a0 file=? name=FUN_004cc1a0 */

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

{
  int iVar1;
  int iVar2;
  
  iVar2 = -1;
  iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x50f4bc);
  if ((iVar1 != 0) && (0 < *(int *)(param_2 + 0x1dc))) {
    iVar1 = *(int *)(param_2 + 0x1dc) + -1;
    if (param_1 == 0x80) {
      iVar2 = *(int *)(&DAT_0051cffc + iVar1 * 4);
      *param_3 = *(undefined4 *)(&DAT_0051cf9c + iVar1 * 4);
    }
    else {
      iVar2 = *(int *)(&DAT_0051d02c + iVar1 * 4);
      *param_3 = *(undefined4 *)(&DAT_0051cfcc + iVar1 * 4);
      switch(param_1) {
      case 0x82:
        iVar2 = iVar2 + -1;
        break;
      case 0x83:
        iVar2 = iVar2 + -2;
        break;
      case 0x84:
        iVar2 = iVar2 + -3;
        break;
      case 0x85:
        iVar2 = iVar2 + -4;
        break;
      case 0x86:
        iVar2 = iVar2 + -5;
        break;
      case 0x87:
        iVar2 = iVar2 + -6;
        break;
      case 0x88:
        iVar2 = iVar2 + -7;
      }
    }
  }
  return iVar2;
}



/* @004cc264 file=? name=FUN_004cc264 */

undefined4 __cdecl FUN_004cc264(int param_1)

{
  return *(undefined4 *)(&DAT_0051d058 + *(int *)(param_1 + 0x1d4) * 4);
}



/* @004cc27c file=? name=FUN_004cc27c */

undefined4 __cdecl FUN_004cc27c(int param_1)

{
  return *(undefined4 *)(&DAT_0051d070 + *(int *)(param_1 + 0x1e0) * 4);
}



/* @004cc294 file=? name=FUN_004cc294 */

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

{
  int iVar1;
  undefined4 uVar2;
  undefined4 local_c;
  undefined4 local_8;
  
  iVar1 = FUN_004ac194(param_3,&local_8);
  if (iVar1 == 0) {
    uVar2 = 0;
  }
  else {
    iVar1 = FUN_004cc108(param_4,&local_c);
    if (iVar1 == 0) {
      uVar2 = 0;
    }
    else {
      (**(code **)(*param_2 + 0x20))(param_2,&local_8,4);
      (**(code **)(*param_2 + 0x20))(param_2,&local_c,4);
      uVar2 = 1;
    }
  }
  return uVar2;
}



/* @004cc2fc file=? name=FUN_004cc2fc */

void __cdecl
FUN_004cc2fc(undefined4 param_1,int param_2,undefined4 param_3,int param_4,int param_5,int *param_6)

{
  int iVar1;
  int *piVar2;
  int unaff_EBX;
  int local_10;
  int local_c;
  int local_8;
  
  (**(code **)(*param_6 + 0x1c))(param_6,&local_8,4);
  (**(code **)(*param_6 + 0x1c))(param_6,&local_c,4);
  if (param_5 == local_8) {
    local_10 = -1;
    iVar1 = FUN_0041a1a4(**(int **)(param_4 + 0xc),0x50e4fc);
    if (iVar1 == 0) {
      iVar1 = FUN_0041a1a4(**(int **)(param_4 + 0xc),0x50fb60);
      if (iVar1 == 0) {
        if (local_c < 0x80) {
          unaff_EBX = FUN_004cc148(local_c);
        }
        else {
          unaff_EBX = FUN_004cc1a0(local_c,param_4,&local_10);
        }
      }
      else if (param_5 == 2) {
        unaff_EBX = FUN_004cc27c(param_4);
      }
    }
    else if (param_5 == 2) {
      unaff_EBX = FUN_004cc264(param_4);
    }
    if ((-1 < unaff_EBX) && (*(int *)(DAT_004efc94 + 0x4c) != 0)) {
      piVar2 = (int *)FUN_00444c80(*(int *)(*(int *)(DAT_004efc94 + 0x4c) + 0x1c0c8),unaff_EBX,
                                   local_10);
      if (piVar2 != (int *)0x0) {
        FUN_00444e64(piVar2,1);
        (**(code **)(*(int *)(param_2 + 0x18) + 4))(param_2 + 0x18,piVar2);
      }
    }
  }
  return;
}



/* @004cc40c file=? name=FUN_004cc40c */

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

undefined4 * __cdecl
FUN_004cc40c(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 *param_4,
            undefined4 param_5,undefined4 *param_6,undefined4 param_7,undefined4 param_8,
            undefined4 param_9,undefined4 param_10,undefined4 param_11,undefined4 param_12,
            undefined4 param_13,undefined4 param_14,undefined4 param_15)

{
  int *piVar1;
  int iVar2;
  undefined4 uVar3;
  undefined4 local_24 [6];
  float local_c;
  undefined4 *local_8;
  
  FUN_004530ec(param_1,param_2,param_3);
  *param_1 = &PTR_LAB_0051db44;
  local_8 = param_1 + 0xcd;
  FUN_004d123b(param_1 + 0xd1,0);
  param_1[0x94] = param_4;
  param_1[0x95] = *param_4;
  param_1[0x96] = param_5;
  param_1[0x89] = param_6;
  param_1[0x8a] = *param_6;
  param_1[0x8b] = param_11;
  param_1[0x8c] = param_12;
  param_1[0x91] = *(undefined4 *)param_1[0x95];
  param_1[0x92] = ((undefined4 *)param_1[0x95])[1];
  param_1[0x93] = *(undefined4 *)(param_1[0x95] + 8);
  param_1[0x90] = 0;
  param_1[0x78] = 0;
  param_1[0x77] = 0;
  param_1[0xe] = 0;
  param_1[0xd] = 0;
  param_1[0x79] = param_8;
  param_1[0x7a] = 0;
  param_1[0x7b] = param_9;
  param_1[0x7c] = param_10;
  param_1[0x7d] = param_7;
  param_1[0x7e] = 0;
  param_1[0xd0] = param_13;
  FUN_00408440(param_1 + 0xcd,&DAT_004e0f74);
  param_1[0xc9] = param_14;
  FUN_00408440(param_1 + 0xca,&DAT_004e0f74);
  param_1[0x61] = param_15;
  param_1[0x62] = 0;
  piVar1 = (int *)FUN_00414b60();
  param_1[0x4b] = (float)*piVar1 / DAT_0052140c;
  param_1[8] = *(undefined4 *)(param_1[0x95] + 0x24);
  param_1[7] = 0;
  param_1[0x60] = 0;
  param_1[0x7f] = 0x3eb33333;
  param_1[0x80] = 0x3e800000;
  param_1[0x81] = 0x3f000000;
  param_1[0x83] = 0x3c03126f;
  param_1[0x82] = 0x3c83126f;
  param_1[9] = 0xd;
  param_1[10] = 1;
  param_1[0x84] = 0xbe800000;
  param_1[0x85] = 0x3eb33333;
  param_1[0x86] = 0x3f000000;
  param_1[0x88] = 0x3c03126f;
  param_1[0x87] = 0x3c83126f;
  param_1[0xb] = 0x15;
  param_1[0xc] = 1;
  iVar2 = FUN_00498448(s_PNAME1_bgf_0051d1f7,0);
  param_1[0xbb] = iVar2;
  iVar2 = FUN_00498448(s_PNAME2_bgf_0051d202,0);
  param_1[0xbc] = iVar2;
  iVar2 = FUN_00498448(s_PNAME3_bgf_0051d20d,0);
  param_1[0xbd] = iVar2;
  iVar2 = FUN_00498448(s_PNAME4_bgf_0051d218,0);
  param_1[0xbe] = iVar2;
  iVar2 = FUN_00498448(s_PNAME5_bgf_0051d223,0);
  param_1[0xbf] = iVar2;
  iVar2 = FUN_00498448(s_PNAME6_bgf_0051d22e,0);
  param_1[0xc0] = iVar2;
  iVar2 = FUN_00498448(s_PNAME7_bgf_0051d239,0);
  param_1[0xc1] = iVar2;
  iVar2 = FUN_00498448(s_PNAME8_bgf_0051d244,0);
  param_1[0xc2] = iVar2;
  uVar3 = FUN_00489708();
  param_1[199] = uVar3;
  iVar2 = FUN_00489724();
  param_1[200] = iVar2;
  FUN_0048ab0c(iVar2,param_1[0xbb]);
  FUN_0048ac30(param_1[200],0);
  FUN_00489e04(param_1[199],param_1[200]);
  FUN_00491cc4(param_1[199],0.12,0x3df5c28f,0x3df5c28f);
  FUN_00491c58(param_1[199],0x80000000,0xbda3d70a,0xbf800000);
  FUN_004901a0(param_1[199],1);
  FUN_0048fe54(param_1[199],7);
  FUN_0048d5d4((undefined4 *)param_1[200]);
  FUN_0048d3e8((undefined4 *)param_1[199]);
  FUN_00489ba8(param_1[199]);
  param_1[0x8d] = (float)param_1[0x8b] - (float)param_1[0x8c];
  if ((float)param_1[0x8c] <= (float)param_1[0x8a]) {
    if ((float)param_1[0x8a] <= (float)param_1[0x8b]) {
      uVar3 = param_1[0x8a];
    }
    else {
      uVar3 = param_1[0x8b];
    }
  }
  else {
    uVar3 = param_1[0x8c];
  }
  param_1[0x8a] = uVar3;
  param_1[0x8f] = ((float)param_1[0x8a] - (float)param_1[0x8c]) / (float)param_1[0x8d];
  param_1[0x8e] = param_1[0x8f];
  piVar1 = FUN_00487f34();
  param_1[0x97] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x98] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x99] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9b] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9c] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9a] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9d] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xb7] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xb8] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xb9] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xb6] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9e] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xba] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0x9f] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xa0] = piVar1;
  piVar1 = FUN_00487f34();
  param_1[0xa1] = piVar1;
  FUN_00487fbc(param_1[0x97],1);
  FUN_00488850(param_1[0x97],(undefined4 *)param_1[0x98]);
  FUN_00488030(param_1[0x97]);
  FUN_00488054((byte *)param_1[0x97]);
  FUN_00487fbc(param_1[0x98],1);
  FUN_00488500(param_1[0x98],0x3f800000);
  FUN_004888c0(param_1[0x98]);
  FUN_00488630(param_1[0x98],0x3f400000,0,0);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0xa1]);
  FUN_00488630(param_1[0x98],0,0x3f400000,0);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0x9a]);
  FUN_00488340(param_1[0x98]);
  FUN_00488408(param_1[0x98],0,0);
  FUN_004883a4(param_1[0x98]);
  FUN_00488278(param_1[0x98]);
  FUN_00488408(param_1[0x98],0x3d23d70a,0);
  FUN_00488408(param_1[0x98],0x3dcccccd,0);
  FUN_00488408(param_1[0x98],0xbd23d70a,0);
  FUN_00488408(param_1[0x98],0xbdcccccd,0);
  FUN_00488408(param_1[0x98],0,0x3d23d70a);
  FUN_00488408(param_1[0x98],0,0x3dcccccd);
  FUN_00488408(param_1[0x98],0,0xbd23d70a);
  FUN_00488408(param_1[0x98],0,0xbdcccccd);
  FUN_004882dc(param_1[0x98]);
  FUN_00488500(param_1[0x98],0x40400000);
  FUN_00488278(param_1[0x98]);
  FUN_00488408(param_1[0x98],0x3dcccccd,0);
  FUN_00488408(param_1[0x98],0x3e23d70a,0);
  FUN_00488408(param_1[0x98],0xbdcccccd,0);
  FUN_00488408(param_1[0x98],0xbe23d70a,0);
  FUN_00488408(param_1[0x98],0,0x3dcccccd);
  FUN_00488408(param_1[0x98],0,0x3e23d70a);
  FUN_00488408(param_1[0x98],0,0xbdcccccd);
  FUN_00488408(param_1[0x98],0,0xbe23d70a);
  FUN_004882dc(param_1[0x98]);
  FUN_00488500(param_1[0x98],0x3f800000);
  FUN_004cd938(param_1,param_1[0x98],param_1[9],param_1[10],(float)param_1[0x81],
               (float)param_1[0x7f],(float)param_1[0x80],3,(float)param_1[0x83],(float)param_1[0x82]
              );
  FUN_0048856c(param_1[0x98]);
  FUN_00488500(param_1[0x98],0x40000000);
  FUN_00488630(param_1[0x98],0x3f400000,0x3f400000,0);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0x9b]);
  FUN_00488500(param_1[0x98],0x3f800000);
  FUN_00488630(param_1[0x98],0,0x3f400000,0);
  FUN_004880e8(param_1[0x98]);
  FUN_00488408(param_1[0x98],(float)param_1[0x7f] - (float)param_1[0x82],param_1[0x80]);
  FUN_00488408(param_1[0x98],((float)param_1[0x7f] - _DAT_004cd7f4) - (float)param_1[0x82],
               (float)param_1[0x80] + _DAT_004cd7f4);
  FUN_00488408(param_1[0x98],((float)param_1[0x7f] - _DAT_004cd7f4) - (float)param_1[0x82],
               (float)param_1[0x80] - _DAT_004cd7f4);
  FUN_00488408(param_1[0x98],(float)param_1[0x7f] - (float)param_1[0x82],param_1[0x80]);
  FUN_0048814c(param_1[0x98]);
  FUN_004885cc(param_1[0x98]);
  FUN_004cd938(param_1,param_1[0x98],param_1[0xb],param_1[0xc],(float)param_1[0x86],
               (float)param_1[0x84],(float)param_1[0x85],0,(float)param_1[0x88],(float)param_1[0x87]
              );
  local_c = (float)param_1[0x86] * _DAT_004cd7f8 + (float)param_1[0x84];
  FUN_0048856c(param_1[0x98]);
  FUN_00488500(param_1[0x98],0x40000000);
  FUN_00488630(param_1[0x98],0x3f400000,0x3f400000,0);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0x9c]);
  FUN_00488500(param_1[0x98],0x3f800000);
  FUN_00488630(param_1[0x98],0,0x3f400000,0);
  FUN_004880e8(param_1[0x98]);
  FUN_00488408(param_1[0x98],local_c,(float)param_1[0x85] - (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c + _DAT_004cd7f4,
               ((float)param_1[0x85] - _DAT_004cd7f4) - (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c - _DAT_004cd7f4,
               ((float)param_1[0x85] - _DAT_004cd7f4) - (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c,(float)param_1[0x85] - (float)param_1[0x87]);
  FUN_0048814c(param_1[0x98]);
  FUN_004885cc(param_1[0x98]);
  FUN_004880e8(param_1[0x98]);
  FUN_00488408(param_1[0x98],local_c,(float)param_1[0x85] + (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c + _DAT_004cd7f4,
               (float)param_1[0x85] + _DAT_004cd7f4 + (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c - _DAT_004cd7f4,
               (float)param_1[0x85] + _DAT_004cd7f4 + (float)param_1[0x87]);
  FUN_00488408(param_1[0x98],local_c,(float)param_1[0x85] + (float)param_1[0x87]);
  FUN_0048814c(param_1[0x98]);
  FUN_0048856c(param_1[0x98]);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0x9e]);
  FUN_0048847c(param_1[0x98],0,0,0x3cf5c28f,0);
  FUN_00488278(param_1[0x98]);
  FUN_00488408(param_1[0x98],0,0xbd23d70a);
  FUN_00488408(param_1[0x98],0,0xbba3d70a);
  FUN_004882dc(param_1[0x98]);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0xba]);
  FUN_004885cc(param_1[0x98]);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0xb6]);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0x9d]);
  FUN_00488850(param_1[0x98],(undefined4 *)param_1[0xb7]);
  FUN_00488030(param_1[0x98]);
  FUN_00488054((byte *)param_1[0x98]);
  FUN_00488b80(local_24);
  FUN_00488bac((int)local_24,*(float *)param_1[0x95],((float *)param_1[0x95])[1]);
  FUN_00487fbc(param_1[0x9a],1);
  FUN_00488718(param_1[0x9a],local_24);
  FUN_00488030(param_1[0x9a]);
  FUN_00488054((byte *)param_1[0x9a]);
  FUN_00488b80(local_24);
  FUN_00488bac((int)local_24,0.0,-(float)param_1[0x81] * (float)param_1[0x8f]);
  FUN_00487fbc(param_1[0x9b],1);
  FUN_004887b0(param_1[0x9b],local_24,0);
  FUN_00488030(param_1[0x9b]);
  FUN_00488054((byte *)param_1[0x9b]);
  FUN_00488b80(local_24);
  FUN_00487fbc(param_1[0x9c],1);
  FUN_004887b0(param_1[0x9c],local_24,0);
  FUN_00488030(param_1[0x9c]);
  FUN_00488054((byte *)param_1[0x9c]);
  FUN_00488b80(local_24);
  FUN_00488bac((int)local_24,(float)param_1[0x84],
               ((float)param_1[0x85] - (float)param_1[0x87] * _DAT_004cd7fc) - _DAT_004cd800);
  FUN_00487fbc(param_1[0x9e],1);
  FUN_004887b0(param_1[0x9e],local_24,0);
  FUN_00488030(param_1[0x9e]);
  FUN_00488054((byte *)param_1[0x9e]);
  FUN_00487fbc(param_1[0xba],1);
  FUN_00488030(param_1[0xba]);
  FUN_00488054((byte *)param_1[0xba]);
  FUN_00487fbc(param_1[0xb6],1);
  FUN_00488030(param_1[0xb6]);
  FUN_00488054((byte *)param_1[0xb6]);
  FUN_00488b80(local_24);
  FUN_00487fbc(param_1[0x9d],1);
  FUN_004887b0(param_1[0x9d],local_24,0);
  FUN_00488030(param_1[0x9d]);
  FUN_00488054((byte *)param_1[0x9d]);
  FUN_00487fbc(param_1[0xb7],1);
  FUN_00488030(param_1[0xb7]);
  FUN_00488054((byte *)param_1[0xb7]);
  FUN_00487fbc(param_1[0xb8],1);
  FUN_00488630(param_1[0xb8],0,0x3f400000,0);
  FUN_0048847c(param_1[0xb8],0,0,0x3df5c28f,0);
  FUN_00488030(param_1[0xb8]);
  FUN_00488054((byte *)param_1[0xb8]);
  FUN_00487fbc(param_1[0xb9],1);
  FUN_00488630(param_1[0xb9],0,0x3f400000,0);
  FUN_0048847c(param_1[0xb9],0,0,0x3df5c28f,0);
  FUN_00488278(param_1[0xb9]);
  FUN_00488408(param_1[0xb9],0x3e0f5c29,0);
  FUN_00488408(param_1[0xb9],0x3dcccccd,0);
  FUN_00488408(param_1[0xb9],0xbe0f5c29,0);
  FUN_00488408(param_1[0xb9],0xbdcccccd,0);
  FUN_00488408(param_1[0xb9],0,0x3e0f5c29);
  FUN_00488408(param_1[0xb9],0,0x3dcccccd);
  FUN_00488408(param_1[0xb9],0,0xbe0f5c29);
  FUN_00488408(param_1[0xb9],0,0xbdcccccd);
  FUN_004882dc(param_1[0xb9]);
  FUN_00488030(param_1[0xb9]);
  FUN_00488054((byte *)param_1[0xb9]);
  FUN_00487fbc(param_1[0x9f],1);
  FUN_00488500(param_1[0x9f],0x41400000);
  FUN_004886ac(param_1[0x9f],0x3f000000);
  FUN_00488278(param_1[0x9f]);
  FUN_00488408(param_1[0x9f],0xbf99999a,0xbe99a6b5);
  FUN_00488408(param_1[0x9f],0xbfc00000,0);
  FUN_00488408(param_1[0x9f],0xbfc00000,0);
  FUN_00488408(param_1[0x9f],0xbf99999a,0x3e99a6b5);
  FUN_004882dc(param_1[0x9f]);
  FUN_00488500(param_1[0x9f],0x3f800000);
  FUN_004886ac(param_1[0x9f],0x3f800000);
  FUN_00488030(param_1[0x9f]);
  FUN_00488054((byte *)param_1[0x9f]);
  FUN_00487fbc(param_1[0xa0],1);
  FUN_00488500(param_1[0xa0],0x41400000);
  FUN_004886ac(param_1[0xa0],0x3f000000);
  FUN_00488278(param_1[0xa0]);
  FUN_00488408(param_1[0xa0],0x3f99999a,0x3e99a6b5);
  FUN_00488408(param_1[0xa0],0x3fc00000,0);
  FUN_00488408(param_1[0xa0],0x3fc00000,0);
  FUN_00488408(param_1[0xa0],0x3f99999a,0xbe99a6b5);
  FUN_004882dc(param_1[0xa0]);
  FUN_00488500(param_1[0xa0],0x3f800000);
  FUN_004886ac(param_1[0xa0],0x3f800000);
  FUN_00488030(param_1[0xa0]);
  FUN_00488054((byte *)param_1[0xa0]);
  FUN_00487fbc(param_1[0xa1],1);
  FUN_00488030(param_1[0xa1]);
  FUN_00488054((byte *)param_1[0xa1]);
  FUN_00487fbc(param_1[0x99],1);
  FUN_00488500(param_1[0x99],0x3f800000);
  FUN_004888c0(param_1[0x99]);
  FUN_00488630(param_1[0x99],0,0x3f400000,0);
  FUN_00488850(param_1[0x99],(undefined4 *)param_1[0x9a]);
  FUN_00488278(param_1[0x99]);
  FUN_00488408(param_1[0x99],0xbda3d70a,0);
  FUN_00488408(param_1[0x99],0xbca3d70a,0);
  FUN_00488408(param_1[0x99],0x3ca3d70a,0);
  FUN_00488408(param_1[0x99],0x3da3d70a,0);
  FUN_00488408(param_1[0x99],0,0xbda3d70a);
  FUN_00488408(param_1[0x99],0,0xbca3d70a);
  FUN_00488408(param_1[0x99],0,0x3ca3d70a);
  FUN_00488408(param_1[0x99],0,0x3da3d70a);
  FUN_004882dc(param_1[0x99]);
  FUN_00488030(param_1[0x99]);
  FUN_00488054((byte *)param_1[0x99]);
  if (param_1[0x93] == 1) {
    FUN_00488ab4(param_1[0x96],param_1[0x97]);
    FUN_0048d42c((undefined4 *)param_1[0x96]);
  }
  return param_1;
}



/* @004cd918 file=? name=FUN_004cd918 */

undefined4 __cdecl FUN_004cd918(int param_1)

{
  int iVar1;
  
  FUN_004531c4(param_1);
  for (iVar1 = 0; iVar1 < *(int *)(param_1 + 0x38); iVar1 = iVar1 + 1) {
  }
  return 1;
}



/* @004cd938 file=? name=FUN_004cd938 */

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

void __cdecl
FUN_004cd938(undefined4 param_1,int param_2,int param_3,int param_4,float param_5,float param_6,
            float param_7,int param_8,float param_9,float param_10)

{
  float fVar1;
  int iVar2;
  int iVar3;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_c;
  undefined4 local_8;
  
  local_8 = param_6;
  local_c = param_7;
  fVar1 = param_5 / (float)(param_3 + -1);
  local_28 = _DAT_004cdabc;
  local_24 = _DAT_004cdabc;
  local_20 = _DAT_004cdabc;
  local_1c = _DAT_004cdabc;
  if (param_8 == 0) {
    local_18 = 0.0;
    local_20 = param_10;
    local_28 = param_9;
    local_14 = fVar1;
  }
  else if (param_8 == 1) {
    local_18 = 0.0;
    local_20 = param_10;
    local_28 = param_9;
    local_14 = -fVar1;
  }
  else if (param_8 == 2) {
    local_14 = 0.0;
    local_1c = param_10;
    local_24 = param_9;
    local_18 = fVar1;
  }
  else if (param_8 == 3) {
    local_14 = 0.0;
    local_1c = param_10;
    local_24 = param_9;
    local_18 = -fVar1;
  }
  iVar2 = 0;
  FUN_00488278(param_2);
  iVar3 = 0;
  if (0 < param_3) {
    do {
      if (iVar2 == 0) {
        FUN_00488408(param_2,local_8 + local_1c,local_c + local_20);
        FUN_00488408(param_2,local_8 - local_1c,local_c - local_20);
        iVar2 = param_4;
      }
      else {
        FUN_00488408(param_2,local_8 + local_24,local_c + local_28);
        FUN_00488408(param_2,local_8 - local_24,local_c - local_28);
        iVar2 = iVar2 + -1;
      }
      local_8 = local_14 + local_8;
      local_c = local_18 + local_c;
      iVar3 = iVar3 + 1;
    } while (iVar3 < param_3);
  }
  FUN_004882dc(param_2);
  return;
}



/* @004cdac0 file=bt_l4/btl4vid.cpp name=FUN_004cdac0 */

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

void __cdecl
FUN_004cdac0(int param_1,float param_2,int param_3,undefined4 *param_4,int param_5,
            undefined4 param_6,undefined4 param_7,undefined4 param_8,int param_9,undefined4 param_10
            ,undefined4 param_11,int param_12,undefined4 param_13,undefined4 param_14)

{
  float fVar1;
  float fVar2;
  byte *pbVar3;
  byte *pbVar4;
  
  if (9 < *(int *)(param_1 + 0x38)) {
    FUN_0040385c(s_Tried_to_display_too_many_weapon_0051d24f,
                 s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d272,0x338);
  }
  *(undefined4 *)(param_1 + 100 + *(int *)(param_1 + 0x38) * 4) = param_11;
  *(undefined4 *)(param_1 + 0x8c + *(int *)(param_1 + 0x38) * 4) = param_10;
  *(undefined4 *)(param_1 + 0xb4 + *(int *)(param_1 + 0x38) * 4) = param_13;
  *(int *)(param_1 + 0x130 + *(int *)(param_1 + 0x38) * 4) = param_9;
  *(undefined4 *)(param_1 + 0xdc + *(int *)(param_1 + 0x38) * 4) = *(undefined4 *)(param_9 + 0x14);
  *(int *)(param_1 + 0x158 + *(int *)(param_1 + 0x38) * 4) = param_12;
  *(undefined4 *)(param_1 + 0x104 + *(int *)(param_1 + 0x38) * 4) = *(undefined4 *)(param_12 + 0x14)
  ;
  *(undefined4 **)(param_1 + 0x18c + *(int *)(param_1 + 0x38) * 4) = param_4;
  *(undefined4 *)(param_1 + 0x1b4 + *(int *)(param_1 + 0x38) * 4) = *param_4;
  *(undefined4 *)(param_1 + 0x3c + *(int *)(param_1 + 0x38) * 4) = param_14;
  pbVar3 = (byte *)FUN_00487f34();
  pbVar4 = (byte *)FUN_00487f34();
  *(byte **)(param_1 + 0x2b0 + *(int *)(param_1 + 0x38) * 4) = pbVar3;
  *(byte **)(param_1 + 0x288 + *(int *)(param_1 + 0x38) * 4) = pbVar4;
  if (*(float *)(param_1 + 0x230) <= param_2) {
    if (*(float *)(param_1 + 0x22c) < param_2) {
      param_2 = *(float *)(param_1 + 0x22c);
    }
  }
  else {
    param_2 = *(float *)(param_1 + 0x230);
  }
  fVar2 = *(float *)(param_1 + 0x1fc) + *(float *)(param_1 + 0x208) +
          (float)param_3 * (float)_DAT_004cdce8;
  fVar1 = -*(float *)(param_1 + 0x204) *
          ((param_2 - *(float *)(param_1 + 0x230)) / *(float *)(param_1 + 0x234)) +
          *(float *)(param_1 + 0x200);
  FUN_00487fbc((int)pbVar3,1);
  FUN_00488630((int)pbVar3,param_6,param_7,param_8);
  FUN_0048847c((int)pbVar3,fVar2,fVar1,0x3c449ba6,1);
  FUN_00488630((int)pbVar3,0,0,0);
  FUN_0048847c((int)pbVar3,fVar2,fVar1,0x3c656042,0);
  if (param_5 != 0) {
    FUN_00488630((int)pbVar3,0x3f333333,0x3f333333,0x3f333333);
    FUN_00488340((int)pbVar3);
    FUN_00488408((int)pbVar3,fVar2,fVar1);
    FUN_004883a4((int)pbVar3);
  }
  FUN_00488030((int)pbVar3);
  FUN_00488054(pbVar3);
  FUN_00487fbc((int)pbVar4,1);
  FUN_00488630((int)pbVar4,0,0,0);
  FUN_0048847c((int)pbVar4,fVar2,fVar1,0x3c656042,0);
  FUN_00488030((int)pbVar4);
  FUN_00488054(pbVar4);
  *(int *)(param_1 + 0x38) = *(int *)(param_1 + 0x38) + 1;
  return;
}



/* @004ceecc file=? name=FUN_004ceecc */

undefined4 * __cdecl
FUN_004ceecc(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
            undefined4 param_5,undefined4 param_6)

{
  FUN_0045a180(param_1,param_2,param_3,param_4,param_5,param_6);
  *param_1 = &PTR_FUN_0051daf4;
  return param_1;
}



/* @004ceefc file=? name=FUN_004ceefc */

void __cdecl FUN_004ceefc(int *param_1,byte param_2)

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



/* @004cef28 file=bt_l4/btl4vid.cpp name=FUN_004cef28 */

undefined4 __cdecl FUN_004cef28(int param_1,int param_2,undefined4 param_3,int param_4)

{
  char *pcVar1;
  char cVar2;
  int iVar3;
  int *piVar4;
  undefined4 *puVar5;
  undefined4 *puVar6;
  char *pcVar7;
  int iVar8;
  int iVar9;
  uint uVar10;
  uint uVar11;
  char *pcVar12;
  bool bVar13;
  undefined4 uVar14;
  undefined4 local_320 [3];
  undefined4 local_314 [3];
  float local_308;
  undefined4 local_304;
  undefined4 local_300;
  float local_2fc [3];
  undefined4 local_2f0 [12];
  int local_2c0 [7];
  int local_2a4 [7];
  undefined4 local_288 [12];
  int local_258 [7];
  char local_23c [40];
  undefined4 *local_214;
  undefined4 *local_210;
  int *local_20c;
  int *local_208;
  int local_204;
  int local_200;
  int local_1fc;
  undefined4 *local_1f8;
  undefined4 *local_1f4;
  int *local_1f0;
  undefined4 local_1ec;
  int local_1e8;
  undefined4 *local_1e4;
  undefined4 *local_1e0;
  undefined4 *local_1dc;
  int local_1d8;
  undefined4 *local_1d4;
  undefined4 *local_1d0;
  undefined4 *local_1cc;
  undefined4 *local_1c8;
  undefined4 *local_1c4;
  undefined4 *local_1c0;
  int local_1bc;
  int *local_1b8;
  undefined4 *local_1b4;
  int local_1b0;
  undefined4 *local_1ac;
  int local_1a8;
  undefined4 *local_1a4;
  int local_1a0;
  int local_19c;
  int local_198;
  int local_194;
  undefined4 *local_190;
  undefined4 *local_18c;
  int local_188;
  int local_184;
  int local_180;
  int local_17c;
  undefined4 local_178;
  int *local_174;
  int local_170;
  int local_16c;
  int *local_168;
  undefined4 *local_164;
  int *local_160;
  float *local_15c;
  undefined4 *local_158;
  int *local_154;
  int *local_150;
  int *local_14c;
  int *local_148;
  int *local_144;
  int *local_140;
  undefined4 *local_13c;
  int *local_138;
  int local_134;
  undefined4 *local_130;
  int local_12c;
  int local_128;
  int local_124;
  int local_120;
  int *local_11c;
  int *local_118;
  undefined4 *local_114;
  undefined4 *local_110;
  undefined4 *local_10c;
  int local_108;
  int local_104;
  int local_100;
  int local_fc;
  undefined4 *local_f8;
  undefined4 *local_f4;
  int local_f0;
  undefined4 *local_ec;
  int local_e8;
  undefined4 *local_e4;
  undefined4 *local_e0;
  undefined4 *local_dc;
  undefined4 *local_d8;
  undefined4 *local_d4;
  undefined4 *local_d0;
  undefined4 *local_cc;
  undefined4 *local_c8;
  undefined4 *local_c4;
  undefined4 *local_c0;
  undefined4 *local_bc;
  undefined4 *local_b8;
  undefined4 *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;
  int local_84;
  uint local_80;
  int local_7c;
  int local_78;
  int local_74;
  undefined4 *local_70;
  undefined4 *local_6c;
  int *local_68;
  int *local_64;
  undefined4 *local_60;
  int local_5c;
  int local_58;
  undefined4 *local_54;
  int local_50;
  int *local_4c;
  int local_48;
  int local_44;
  undefined4 *local_40;
  int local_3c;
  undefined4 *local_38;
  undefined4 *local_34;
  undefined4 *local_30;
  undefined4 *local_2c;
  undefined4 *local_28;
  undefined4 local_24;
  undefined4 *local_20;
  uint local_1c;
  int local_18;
  int local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 *local_8;
  
  local_20 = (undefined4 *)0x0;
  local_1c = 1;
  local_8 = FUN_0045a724();
  if (param_4 == 1) {
    local_c = 1;
    local_10 = 0;
    local_24 = 4;
    local_2c = (undefined4 *)FUN_00402298(0x60);
    if (local_2c == (undefined4 *)0x0) {
      local_28 = (undefined4 *)0x0;
    }
    else {
      local_28 = FUN_00455de4(local_2c,param_2,1,1,local_8);
    }
  }
  else {
    local_c = 3;
    local_10 = 0xffffffff;
    local_24 = 0;
    local_30 = (undefined4 *)FUN_00402298(0x60);
    if (local_30 == (undefined4 *)0x0) {
      local_28 = (undefined4 *)0x0;
    }
    else {
      local_28 = FUN_00455de4(local_30,param_2,1,0,local_8);
    }
  }
  local_38 = (undefined4 *)FUN_00402298(100);
  if (local_38 == (undefined4 *)0x0) {
    local_34 = (undefined4 *)0x0;
  }
  else {
    local_34 = FUN_00453578(local_38,param_2,3,0,local_8,local_c,local_10);
  }
  FUN_00455c18((int)local_28,local_34);
  if (((param_4 == 1) && (local_3c = FUN_0041bf44(param_2,1), local_3c != 0)) &&
     (local_40 = (undefined4 *)FUN_00402298(0x48), local_40 != (undefined4 *)0x0)) {
    FUN_00453f18(local_40,param_2,2,*(undefined4 *)(param_1 + 300),local_8,local_34[0xb],local_3c,2)
    ;
  }
  if ((*(int *)(param_1 + 0xb0) != 0) && (iVar3 = FUN_00417ab4(param_1 + 0x40), param_2 == iVar3)) {
    local_44 = local_34[0xb];
    FUN_00489cec(local_44,*(int *)(param_1 + 0x120));
  }
  local_48 = param_2;
  local_4c = (int *)FUN_004022b0(*(int *)(param_2 + 0x318) << 2);
  local_50 = FUN_00417ab4(local_48 + 0x31c);
  FUN_0041f216(local_258,local_48 + 0x300);
LAB_004cf86e:
  do {
    iVar3 = (**(code **)(local_258[0] + 0x28))(local_258);
    if (iVar3 == 0) {
      if (param_4 == 1) {
        local_e8 = FUN_0041f98c(param_2,&DAT_0051d2ae);
        if (local_e8 == 0) {
          FUN_004dbb24(&DAT_00524e20,s_Mech_did_not_have_a_HUD_subsyste_0051d36f,(char *)0x0);
        }
        else {
          iVar3 = FUN_0041bfc0(param_2,s_TargetReticle_0051d2b2);
          *(int *)(param_1 + 0x130) = iVar3;
          local_ec = (undefined4 *)FUN_0041bf44(local_e8,8);
          local_f0 = FUN_0041bf44(local_e8,4);
          local_f4 = (undefined4 *)FUN_0041bf44(local_e8,5);
          local_f8 = (undefined4 *)FUN_0041bf44(local_e8,6);
          local_fc = FUN_0041bf44(local_e8,0xd);
          local_100 = FUN_0041bf44(local_e8,0xc);
          local_104 = FUN_0041bf44(local_e8,0xb);
          local_108 = FUN_0041bf44(local_e8,10);
          if (((local_108 == 0) || (*(int *)(param_1 + 0x130) == 0)) ||
             ((local_ec == (undefined4 *)0x0 ||
              ((((local_f0 == 0 || (local_f4 == (undefined4 *)0x0)) ||
                (local_f8 == (undefined4 *)0x0)) || (local_fc == 0)))))) {
            FUN_0040385c(s_Bad_reticle__one_of_TargetReticl_0051d2c0,
                         s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d315,0x7be);
          }
          local_10c = (undefined4 *)FUN_00402298(0x358);
          if (local_10c == (undefined4 *)0x0) {
            local_20 = (undefined4 *)0x0;
          }
          else {
            local_114 = local_f8;
            local_110 = local_f4;
            local_20 = FUN_004cc40c(local_10c,param_2,1,(undefined4 *)(param_1 + 0x130),
                                    *(undefined4 *)(param_1 + 0x124),local_ec,local_fc,local_f0,
                                    *local_f4,*local_f8,0x44960000,0,local_100,local_104,local_108);
          }
          if (local_20 == (undefined4 *)0x0) {
            FUN_0040385c(s_Could_not_create_the_reticle_0051d333,
                         s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d351,0x7d3);
          }
        }
      }
      local_118 = (int *)0x0;
      local_11c = (int *)0x0;
      iVar3 = 0;
      do {
        if (*(int *)(param_2 + 0x124) <= iVar3) {
          if ((local_118 != (int *)0x0) &&
             (local_1cc = (undefined4 *)FUN_00402298(0x2c), local_1cc != (undefined4 *)0x0)) {
            FUN_00456778(local_1cc,param_2,1,local_118,(int)local_11c);
          }
          local_1d4 = (undefined4 *)FUN_00402298(0x14);
          if (local_1d4 == (undefined4 *)0x0) {
            local_1dc = (undefined4 *)0x0;
          }
          else {
            local_1dc = FUN_00460cd0(local_1d4,param_2,(int)local_4c);
          }
          local_1d8 = param_2;
          local_1d0 = local_1dc;
          (**(code **)(*(int *)(param_1 + 0x3a4) + 8))(param_1 + 0x3a4,local_1dc,&local_1d8);
          FUN_004022e8(local_4c);
          local_1e4 = (undefined4 *)FUN_00402298(0x38);
          if (local_1e4 == (undefined4 *)0x0) {
            local_1e0 = (undefined4 *)0x0;
          }
          else {
            local_1e0 = FUN_00455d3c(local_1e4,param_2,3,0x3f000000);
          }
          FUN_00455e88((int)local_28,local_1e0);
          iVar3 = 0;
          do {
            if (*(int *)(param_2 + 0x11c) <= iVar3) {
              uVar14 = local_34[0xb];
              FUN_0041f235(local_258,2);
              return uVar14;
            }
            local_1e8 = *(int *)(*(int *)(param_2 + 0x120) + iVar3 * 4);
            local_1ec = local_24;
            iVar8 = (**(code **)(*(int *)(local_1e8 + 0xbc) + 0xc))(local_1e8 + 0xbc,&local_1ec);
            if (iVar8 != 0) {
              local_1f8 = (undefined4 *)FUN_00402298(0x3c);
              if (local_1f8 == (undefined4 *)0x0) {
                local_1f4 = (undefined4 *)0x0;
              }
              else {
                local_1f4 = FUN_00455c7c(local_1f8,param_2,3,(undefined4 *)(local_1e8 + 0x158),
                                         0x3d23d70a);
              }
              FUN_00455c18((int)local_1e0,local_1f4);
              (**(code **)(**(int **)(iVar8 + 0xc) + 4))(*(int **)(iVar8 + 0xc));
              while( true ) {
                iVar9 = (**(code **)(**(int **)(iVar8 + 0xc) + 0x30))(*(int **)(iVar8 + 0xc));
                if (iVar9 == 0) {
                  local_1f0 = (int *)0x0;
                }
                else {
                  local_1fc = (**(code **)(**(int **)(iVar8 + 0xc) + 0x28))(*(int **)(iVar8 + 0xc));
                  local_1f0 = (int *)(local_1fc + 0xc);
                }
                if (local_1f0 == (int *)0x0) break;
                uVar10 = 0xffffffff;
                pcVar12 = *(char **)(*local_1f0 + 8);
                do {
                  pcVar7 = pcVar12;
                  if (uVar10 == 0) break;
                  uVar10 = uVar10 - 1;
                  pcVar7 = pcVar12 + 1;
                  cVar2 = *pcVar12;
                  pcVar12 = pcVar7;
                } while (cVar2 != '\0');
                uVar10 = ~uVar10;
                pcVar12 = pcVar7 + -uVar10;
                pcVar7 = (char *)&DAT_00524b54;
                for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
                  *(undefined4 *)pcVar7 = *(undefined4 *)pcVar12;
                  pcVar12 = pcVar12 + 4;
                  pcVar7 = pcVar7 + 4;
                }
                for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
                  *pcVar7 = *pcVar12;
                  pcVar12 = pcVar12 + 1;
                  pcVar7 = pcVar7 + 1;
                }
                local_204 = FUN_00497678((char *)&DAT_00524b54,0,&local_200);
                if (local_204 == 0) {
                  FUN_004dbb24(&DAT_00524e20,s_BTL4VideoRenderer__Material_name_0051d6f8,(char *)0x0
                              );
                  FUN_004dbb24(&DAT_00524e20,(char *)&DAT_00524b54,(char *)0x0);
                  FUN_004dbb24(&DAT_00524e20,s_could_not_be_found_0051d71a,(char *)0x0);
                }
                else {
                  FUN_00402a98((int *)&local_208,local_1f0,(char *)&DAT_00524b54);
                  local_20c = local_208;
                  piVar4 = local_208 + 3;
                  *piVar4 = *piVar4 + -1;
                  if (*piVar4 == 0) {
                    FUN_004024d8(local_208,3);
                  }
                  local_214 = (undefined4 *)FUN_00402298(0xe8);
                  if (local_214 == (undefined4 *)0x0) {
                    local_210 = (undefined4 *)0x0;
                  }
                  else {
                    local_210 = FUN_004573e4(local_214,param_2,3,local_204,
                                             (undefined4 *)(local_1e8 + 0x158),0.1);
                  }
                  FUN_00455c18((int)local_1f4,local_210);
                }
              }
            }
            iVar3 = iVar3 + 1;
          } while( true );
        }
        iVar8 = *(int *)(*(int *)(param_2 + 0x128) + iVar3 * 4);
        if (((iVar8 != 0) && (iVar3 != 0)) && (local_120 = *(int *)(iVar8 + 0xdc), local_120 != -1))
        {
          local_124 = local_120;
          FUN_0041f216(local_2c0,local_48 + 0x300);
          iVar9 = (**(code **)(local_2c0[0] + 0x34))(local_2c0,local_124);
          FUN_0041f235(local_2c0,2);
          if (*(int *)(iVar9 + 0xc4) == 0) {
            local_128 = local_34[0xb];
          }
          else {
            local_12c = *(int *)(iVar9 + 200);
            local_128 = local_4c[local_12c];
          }
          local_130 = (undefined4 *)(iVar9 + 0x74);
          puVar5 = local_130;
          puVar6 = local_2f0;
          for (iVar9 = 0xc; iVar9 != 0; iVar9 = iVar9 + -1) {
            *puVar6 = *puVar5;
            puVar5 = puVar5 + 1;
            puVar6 = puVar6 + 1;
          }
          iVar9 = FUN_0041a1a4(**(int **)(iVar8 + 0xc),0x50de2c);
          if (iVar9 == 0) {
            local_14 = 0;
          }
          else {
            local_134 = iVar8;
            FUN_0040b058((int)local_2f0,3,local_2fc);
            local_308 = *(float *)(local_134 + 0xf8);
            local_304 = *(undefined4 *)(local_134 + 0xfc);
            local_300 = *(undefined4 *)(local_134 + 0x100);
            FUN_004085ec(local_2fc,local_2fc,&local_308);
            FUN_0040b0ac((int)local_2f0,3,local_2fc);
            local_13c = (undefined4 *)FUN_00402298(0x10);
            if (local_13c == (undefined4 *)0x0) {
              local_138 = (int *)0x0;
            }
            else {
              local_138 = (int *)FUN_004023f4(local_13c);
            }
            local_138[3] = local_138[3] + 1;
            local_144 = (int *)(local_134 + 0xf4);
            local_148 = (int *)*local_144;
            local_148[3] = local_148[3] + 1;
            FUN_00402a4c((int *)&local_140,(int *)&local_138,(int *)&local_148);
            local_14c = local_140;
            piVar4 = local_140 + 3;
            *piVar4 = *piVar4 + -1;
            if (*piVar4 == 0) {
              FUN_004024d8(local_140,3);
            }
            local_150 = local_148;
            piVar4 = local_148 + 3;
            *piVar4 = *piVar4 + -1;
            if (*piVar4 == 0) {
              FUN_004024d8(local_148,3);
            }
            pcVar7 = &DAT_0051d398;
            pcVar12 = (char *)local_138[2];
            do {
              bVar13 = *pcVar7 == *pcVar12;
              if (!bVar13) break;
              if (*pcVar7 == '\0') goto LAB_004cfd8d;
              pcVar1 = pcVar7 + 1;
              bVar13 = *pcVar1 == pcVar12[1];
              if (!bVar13) break;
              pcVar7 = pcVar7 + 2;
              pcVar12 = pcVar12 + 2;
              bVar13 = *pcVar1 == '\0';
            } while (!bVar13);
            if (bVar13) {
LAB_004cfd8d:
              local_14 = 0;
            }
            else {
              uVar10 = 0xffffffff;
              pcVar12 = (char *)local_138[2];
              do {
                pcVar7 = pcVar12;
                if (uVar10 == 0) break;
                uVar10 = uVar10 - 1;
                pcVar7 = pcVar12 + 1;
                cVar2 = *pcVar12;
                pcVar12 = pcVar7;
              } while (cVar2 != '\0');
              uVar10 = ~uVar10;
              pcVar12 = pcVar7 + -uVar10;
              pcVar7 = local_23c;
              for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
                *(undefined4 *)pcVar7 = *(undefined4 *)pcVar12;
                pcVar12 = pcVar12 + 4;
                pcVar7 = pcVar7 + 4;
              }
              for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
                *pcVar7 = *pcVar12;
                pcVar12 = pcVar12 + 1;
                pcVar7 = pcVar7 + 1;
              }
              local_14 = FUN_00498448(local_23c,local_1c);
            }
            local_154 = local_138;
            piVar4 = local_138 + 3;
            *piVar4 = *piVar4 + -1;
            if (*piVar4 == 0) {
              FUN_004024d8(local_138,3);
            }
          }
          if (((param_4 == 1) &&
              (iVar9 = FUN_0041a1a4(**(int **)(iVar8 + 0xc),0x511830), iVar9 != 0)) &&
             (local_20 != (undefined4 *)0x0)) {
            local_158 = (undefined4 *)FUN_0041bf44(iVar8,0x15);
            local_15c = (float *)FUN_0041bf44(iVar8,0x16);
            local_160 = (int *)FUN_0041bf44(iVar8,0x17);
            local_164 = (undefined4 *)FUN_0041bf44(iVar8,0x18);
            local_168 = (int *)FUN_0041bf44(iVar8,0x19);
            local_16c = FUN_0041bf44(iVar8,1);
            local_170 = FUN_0041bf44(iVar8,0x1c);
            local_174 = (int *)FUN_0041bf44(iVar8,0x1b);
            if (local_158 == (undefined4 *)0x0) {
              FUN_0040385c(s_No_TargetWithinRange_attribute_i_0051d39d,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d3d2,0x866);
            }
            if (local_15c == (float *)0x0) {
              FUN_0040385c(s_No_WeaponRange_attribute_in_weap_0051d3f0,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d41f,0x868);
            }
            if (local_160 == (int *)0x0) {
              FUN_0040385c(s_No_PipPosition_attribute_in_weap_0051d43d,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d46c,0x86a);
            }
            if (local_164 == (undefined4 *)0x0) {
              FUN_0040385c(s_No_PipColor_attribute_in_weapons_0051d48a,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d4b6,0x86c);
            }
            if (local_168 == (int *)0x0) {
              FUN_0040385c(s_No_PipExtendedRange_attribute_in_0051d4d4,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d508,0x86e);
            }
            if (local_16c == 0) {
              FUN_0040385c(s_No_SimulationState_attribute_in_w_0051d526,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d559,0x870);
            }
            if (local_170 == 0) {
              FUN_0040385c(s_No_SimulationState_attribute_in_w_0051d577,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d5aa,0x873);
            }
            if (local_174 == (int *)0x0) {
              FUN_0040385c(s_No_RearFiring_attribute_in_weapo_0051d5c8,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d5f6,0x875);
            }
            if (*local_174 == 0) {
              local_178 = 1;
            }
            else {
              local_178 = 2;
            }
            FUN_004cdac0((int)local_20,*local_15c,*local_160,local_158,*local_168,*local_164,
                         local_164[1],local_164[2],local_170,2,3,local_16c,1,local_178);
          }
          switch(*(undefined4 *)(iVar8 + 4)) {
          case 0xbc0:
            FUN_0040b058((int)local_2f0,3,local_320);
            local_1b0 = FUN_0041bfc0(iVar8,s_ReservoirState_0051d614);
            if (local_1b0 == 0) {
              FUN_0040385c(s_Reservoir_did_not_have_a_Reservo_0051d623,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d64c,0x926);
            }
            local_1b4 = (undefined4 *)FUN_00402298(0x138);
            if (local_1b4 != (undefined4 *)0x0) {
              FUN_00456a68(local_1b4,param_2,2,local_1b0,1,*(undefined4 **)(param_1 + 0x318),
                           local_128,local_320);
            }
            break;
          case 0xbc8:
            local_17c = FUN_0041bf44(iVar8,0x1e);
            local_180 = FUN_0041bf44(iVar8,0x1f);
            local_184 = FUN_0041bf44(iVar8,0x1d);
            local_188 = FUN_0041bf44(iVar8,0x1c);
            local_190 = (undefined4 *)FUN_00402298(0x80);
            if (local_190 == (undefined4 *)0x0) {
              local_18c = (undefined4 *)0x0;
            }
            else {
              local_18c = FUN_004593c0(local_190,param_2,2,local_14,local_8,1,0,local_128,local_2f0,
                                       local_188,0,local_180,local_17c);
            }
            break;
          case 0xbcd:
            FUN_0040b058((int)local_2f0,3,local_314);
            local_1a8 = FUN_0041bf44(iVar8,0x1c);
            if ((param_4 != 1) &&
               (local_1ac = (undefined4 *)FUN_00402298(0x138), local_1ac != (undefined4 *)0x0)) {
              FUN_00456a68(local_1ac,param_2,2,local_1a8,0,*(undefined4 **)(param_1 + 0x2e4),
                           local_128,local_314);
            }
            break;
          case 0xbd4:
            local_194 = FUN_0041bf44(iVar8,0x1e);
            local_198 = FUN_0041bf44(iVar8,0x1f);
            local_19c = FUN_0041bf44(iVar8,0x1d);
            local_1a0 = FUN_0041bf44(iVar8,0x1c);
            local_1a4 = (undefined4 *)FUN_00402298(0x88);
            if (local_1a4 != (undefined4 *)0x0) {
              FUN_004590d8(local_1a4,param_2,2,local_14,local_8,1,0,local_128,local_2f0,local_1a0,0,
                           local_198,local_194,0x40000000);
            }
            break;
          case 0xbd8:
            local_1b8 = (int *)FUN_0041bfc0(iVar8,s_LightOn_0051d66a);
            if (local_1b8 == (int *)0x0) {
              FUN_0040385c(s_searchlight_subsystem_had_no_lig_0051d672,
                           s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d6a2,0x941);
            }
            if (param_4 == 1) {
              if (local_118 == (int *)0x0) {
                local_118 = local_1b8;
              }
              else {
                local_11c = local_1b8;
              }
            }
            else {
              local_1bc = FUN_00498448(s_spot_bgf_0051d6c0,0);
              if (local_1bc == 0) {
                FUN_004dbb24(&DAT_00524e20,s_Couldn_t_locate_spot_bgf_for_mec_0051d6c9,(char *)0x0);
              }
              else {
                local_1c4 = (undefined4 *)FUN_00402298(0x50);
                if (local_1c4 == (undefined4 *)0x0) {
                  local_1c0 = (undefined4 *)0x0;
                }
                else {
                  local_1c0 = FUN_0045848c(local_1c4,param_2,(int)local_8,local_1bc,1,0,local_2f0,
                                           local_128);
                }
                local_1c8 = (undefined4 *)FUN_00402298(0x2c);
                if (local_1c8 != (undefined4 *)0x0) {
                  FUN_0045612c(local_1c8,param_2,1,local_1c0[6],1,local_1b8);
                }
              }
            }
          }
        }
        iVar3 = iVar3 + 1;
      } while( true );
    }
    FUN_0040aadc(local_288);
    local_54 = (undefined4 *)(iVar3 + 0x74);
    FUN_0040ab28(local_288,local_54);
    if (*(int *)(iVar3 + 0xc4) == 0) {
      local_58 = local_34[0xb];
    }
    else {
      local_5c = *(int *)(iVar3 + 200);
      local_58 = local_4c[local_5c];
    }
    if (*(int *)(iVar3 + 0x10) != 0) {
      if (param_4 == 1) {
        local_60 = (undefined4 *)(iVar3 + 0x11c);
        local_68 = (int *)*local_60;
        pcVar7 = s_siteeyepoint_0051d290;
        local_68[3] = local_68[3] + 1;
        pcVar12 = (char *)local_68[2];
        do {
          bVar13 = *pcVar12 == *pcVar7;
          if ((!bVar13) || (bVar13 = true, *pcVar12 == '\0')) break;
          pcVar1 = pcVar12 + 1;
          bVar13 = *pcVar1 == pcVar7[1];
          if (!bVar13) break;
          pcVar12 = pcVar12 + 2;
          pcVar7 = pcVar7 + 2;
          bVar13 = *pcVar1 == '\0';
        } while (!bVar13);
        uVar10 = (uint)bVar13;
        piVar4 = local_68 + 3;
        *piVar4 = *piVar4 + -1;
        local_64 = local_68;
        if (*piVar4 == 0) {
          FUN_004024d8(local_68,3);
        }
        if (uVar10 != 0) {
          local_6c = (undefined4 *)FUN_0041bfc0(param_2,s_EyepointRotation_0051d29d);
          local_70 = (undefined4 *)FUN_00402298(0x5c);
          if (local_70 != (undefined4 *)0x0) {
            FUN_004579a8(local_70,param_2,(int)local_8,local_288,local_58,
                         *(undefined4 **)(param_1 + 0x124),local_6c);
          }
        }
      }
      goto LAB_004cf86e;
    }
    piVar4 = (int *)FUN_00424084(iVar3,local_24);
    if (piVar4 == (int *)0x0) {
      local_14 = 0;
    }
    else {
      uVar10 = 0xffffffff;
      pcVar12 = *(char **)(*piVar4 + 8);
      do {
        pcVar7 = pcVar12;
        if (uVar10 == 0) break;
        uVar10 = uVar10 - 1;
        pcVar7 = pcVar12 + 1;
        cVar2 = *pcVar12;
        pcVar12 = pcVar7;
      } while (cVar2 != '\0');
      uVar10 = ~uVar10;
      pcVar12 = pcVar7 + -uVar10;
      pcVar7 = local_23c;
      for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
        *(undefined4 *)pcVar7 = *(undefined4 *)pcVar12;
        pcVar12 = pcVar12 + 4;
        pcVar7 = pcVar7 + 4;
      }
      for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
        *pcVar7 = *pcVar12;
        pcVar12 = pcVar12 + 1;
        pcVar7 = pcVar7 + 1;
      }
      local_14 = FUN_00498448(local_23c,local_1c);
    }
    piVar4 = (int *)FUN_00424084(iVar3,local_24);
    if (piVar4 == (int *)0x0) {
      local_18 = 0;
      local_74 = 0;
    }
    else {
      uVar10 = 0xffffffff;
      pcVar12 = *(char **)(*piVar4 + 8);
      do {
        pcVar7 = pcVar12;
        if (uVar10 == 0) break;
        uVar10 = uVar10 - 1;
        pcVar7 = pcVar12 + 1;
        cVar2 = *pcVar12;
        pcVar12 = pcVar7;
      } while (cVar2 != '\0');
      uVar10 = ~uVar10;
      pcVar12 = pcVar7 + -uVar10;
      pcVar7 = local_23c;
      for (uVar11 = uVar10 >> 2; uVar11 != 0; uVar11 = uVar11 - 1) {
        *(undefined4 *)pcVar7 = *(undefined4 *)pcVar12;
        pcVar12 = pcVar12 + 4;
        pcVar7 = pcVar7 + 4;
      }
      for (uVar10 = uVar10 & 3; uVar10 != 0; uVar10 = uVar10 - 1) {
        *pcVar7 = *pcVar12;
        pcVar12 = pcVar12 + 1;
        pcVar7 = pcVar7 + 1;
      }
      local_18 = FUN_00498448(local_23c,local_1c);
      local_78 = *(int *)(*(int *)(param_2 + 0x120) + *(int *)(iVar3 + 0x100) * 4);
      local_74 = local_78 + 100;
    }
    local_7c = *(int *)(iVar3 + 0xcc);
    iVar8 = 0;
    if (*(int *)(iVar3 + 0xc0) == -1) {
      local_80 = 3;
    }
    else {
      local_84 = *(int *)(iVar3 + 0xc0);
      FUN_0041d3b3(local_2a4,local_50 + 0xe4);
      iVar8 = (**(code **)(local_2a4[0] + 0x34))(local_2a4,local_84);
      FUN_0041d3d2(local_2a4,2);
      local_80 = *(uint *)(iVar8 + 0x10);
    }
    if (2 < local_80) {
      if (local_80 != 3) {
        if (local_80 == 4) {
          local_a4 = (undefined4 *)FUN_00402298(0x7c);
          if (local_a4 == (undefined4 *)0x0) {
            local_a0 = (undefined4 *)0x0;
          }
          else {
            puVar5 = (undefined4 *)FUN_0041cfa0(iVar8);
            local_a0 = FUN_004539b4(local_a4,param_2,3,local_14,local_8,local_c,local_10,local_58,
                                    local_288,puVar5);
          }
          FUN_00455e88((int)local_28,local_a0);
          local_4c[local_7c] = local_a0[0xb];
          if (local_18 != 0) {
            local_ac = (undefined4 *)FUN_00402298(0x30);
            if (local_ac == (undefined4 *)0x0) {
              local_a8 = (undefined4 *)0x0;
            }
            else {
              local_a8 = FUN_00453474(local_ac,param_2,0,local_18,local_a0[0xb],local_c,local_10,1);
            }
            local_b0 = (undefined4 *)FUN_00402298(0x30);
            if (local_b0 != (undefined4 *)0x0) {
              FUN_00456224(local_b0,param_2,2,local_a0[0xc],1,local_74,0);
            }
            local_b4 = (undefined4 *)FUN_00402298(0x30);
            if (local_b4 != (undefined4 *)0x0) {
              FUN_00456224(local_b4,param_2,2,local_a8[0xb],1,local_74,1);
            }
          }
          goto LAB_004cf86e;
        }
        if (local_80 == 5) {
          local_bc = (undefined4 *)FUN_00402298(0x8c);
          if (local_bc == (undefined4 *)0x0) {
            local_b8 = (undefined4 *)0x0;
          }
          else {
            puVar5 = *(undefined4 **)(iVar8 + 0xc);
            puVar6 = (undefined4 *)FUN_0041cfa0(iVar8);
            local_b8 = FUN_00453ac4(local_bc,param_2,3,local_14,local_8,local_c,local_10,local_58,
                                    local_288,puVar6,puVar5);
          }
          FUN_00455e88((int)local_28,local_b8);
          local_4c[local_7c] = local_b8[0xb];
          if (local_18 != 0) {
            local_c4 = (undefined4 *)FUN_00402298(0x30);
            if (local_c4 == (undefined4 *)0x0) {
              local_c0 = (undefined4 *)0x0;
            }
            else {
              local_c0 = FUN_00453474(local_c4,param_2,0,local_18,local_b8[0xb],local_c,local_10,1);
            }
            local_c8 = (undefined4 *)FUN_00402298(0x30);
            if (local_c8 != (undefined4 *)0x0) {
              FUN_00456224(local_c8,param_2,2,local_b8[0xc],1,local_74,0);
            }
            local_cc = (undefined4 *)FUN_00402298(0x30);
            if (local_cc != (undefined4 *)0x0) {
              FUN_00456224(local_cc,param_2,2,local_c0[0xb],1,local_74,1);
            }
          }
          goto LAB_004cf86e;
        }
      }
      local_d4 = (undefined4 *)FUN_00402298(0x50);
      if (local_d4 == (undefined4 *)0x0) {
        local_d0 = (undefined4 *)0x0;
      }
      else {
        local_d0 = FUN_0045848c(local_d4,param_2,(int)local_8,local_14,local_c,local_10,local_288,
                                local_58);
      }
      local_4c[local_7c] = local_d0[4];
      if (local_18 != 0) {
        local_dc = (undefined4 *)FUN_00402298(0x30);
        if (local_dc == (undefined4 *)0x0) {
          local_d8 = (undefined4 *)0x0;
        }
        else {
          local_d8 = FUN_00453474(local_dc,param_2,0,local_18,local_d0[4],local_c,local_10,1);
        }
        local_e0 = (undefined4 *)FUN_00402298(0x30);
        if (local_e0 != (undefined4 *)0x0) {
          FUN_00456224(local_e0,param_2,2,local_d0[6],1,local_74,0);
        }
        local_e4 = (undefined4 *)FUN_00402298(0x30);
        if (local_e4 != (undefined4 *)0x0) {
          FUN_00456224(local_e4,param_2,2,local_d8[0xb],1,local_74,1);
        }
      }
      goto LAB_004cf86e;
    }
    local_8c = (undefined4 *)FUN_00402298(0x78);
    if (local_8c == (undefined4 *)0x0) {
      local_88 = (undefined4 *)0x0;
    }
    else {
      local_88 = FUN_004537e8(local_8c,param_2,3,local_14,local_8,local_c,local_10,local_58,
                              local_288,*(undefined4 **)(iVar8 + 0xc));
    }
    FUN_00455e88((int)local_28,local_88);
    local_4c[local_7c] = local_88[0xb];
    if (local_18 != 0) {
      local_94 = (undefined4 *)FUN_00402298(0x30);
      if (local_94 == (undefined4 *)0x0) {
        local_90 = (undefined4 *)0x0;
      }
      else {
        local_90 = FUN_00453474(local_94,param_2,0,local_18,local_88[0xb],local_c,local_10,1);
      }
      local_98 = (undefined4 *)FUN_00402298(0x30);
      if (local_98 != (undefined4 *)0x0) {
        FUN_00456224(local_98,param_2,2,local_88[0xc],1,local_74,0);
      }
      local_9c = (undefined4 *)FUN_00402298(0x30);
      if (local_9c != (undefined4 *)0x0) {
        FUN_00456224(local_9c,param_2,2,local_90[0xb],1,local_74,1);
      }
    }
  } while( true );
}



/* @004d0774 file=? name=FUN_004d0774 */

void __cdecl FUN_004d0774(int param_1,int param_2,int param_3,int param_4)

{
  undefined4 *puVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  int iVar5;
  
  DAT_004f1aa8 = param_2;
  iVar5 = 0;
  iVar2 = *(int *)(param_2 + 4);
  if (iVar2 == 0xbb9) {
    FUN_0045d3cc(param_1,0x68);
    FUN_004d0cc0(param_1,param_2);
    iVar5 = FUN_004cef28(param_1,param_2,param_3,param_4);
    FUN_004d11e8();
  }
  else if (iVar2 == 0xbba) {
    iVar2 = FUN_00498448(s_tmst_c_bgf_0051d72f,0);
    puVar4 = (undefined4 *)FUN_00402298(100);
    if (puVar4 == (undefined4 *)0x0) {
      puVar4 = (undefined4 *)0x0;
    }
    else {
      puVar4 = FUN_00453578(puVar4,param_2,1,iVar2,*(undefined4 *)(param_1 + 300),1,0);
    }
    puVar1 = (undefined4 *)FUN_00402298(0x120);
    if (puVar1 != (undefined4 *)0x0) {
      FUN_00458c58(puVar1,param_2,0,*(undefined4 **)(param_1 + 0x2cc),puVar4[0xb]);
    }
  }
  else if (iVar2 == 0xbda) {
    iVar2 = FUN_0041bf44(param_2,1);
    if ((*(uint *)(param_2 + 0x28) & 0xc) == 4) {
      iVar3 = FUN_0041bfc0(param_2,s_DropZoneLocation_0051d73a);
      if ((iVar2 != 0) && (iVar3 != 0)) {
        puVar4 = (undefined4 *)FUN_00402298(0x40);
        if (puVar4 != (undefined4 *)0x0) {
          FUN_00458d2c(puVar4,param_2,2,*(undefined4 *)(param_1 + 300),iVar2,iVar3,1);
        }
      }
    }
    else if (iVar2 != 0) {
      puVar4 = (undefined4 *)FUN_00402298(0x50);
      if (puVar4 != (undefined4 *)0x0) {
        FUN_00454394(puVar4,param_2,2,*(undefined4 *)(param_1 + 300),
                     *(undefined4 *)(param_1 + 0x128),*(undefined4 *)(param_1 + 0x124),iVar2,
                     *(undefined4 *)(param_1 + 200),*(undefined4 *)(param_1 + 0xd0),
                     *(undefined4 *)(param_1 + 0xcc),*(undefined4 *)(param_1 + 0xd4),
                     *(undefined4 *)(param_1 + 0xd8),3,4);
      }
    }
  }
  else {
    FUN_0045e744(param_1,param_2,param_3,param_4);
  }
  DAT_004f1aa8 = 0;
  if (iVar5 != 0) {
    FUN_0045a994(param_1,iVar5,param_2);
  }
  return;
}



/* @004d097c file=? name=FUN_004d097c */

void __cdecl FUN_004d097c(int param_1,int param_2,int param_3,uint param_4)

{
  int iVar1;
  int iVar2;
  int *piVar3;
  int local_6c [3];
  undefined4 local_60;
  undefined4 local_5c;
  undefined4 local_58;
  undefined4 local_54 [12];
  int local_24 [4];
  int local_14;
  int local_10;
  int local_c;
  uint local_8;
  
  FUN_00452cad(local_24,0);
  FUN_0040aadc(local_54);
  iVar2 = FUN_0041dbd0(param_3,1);
  if (iVar2 == 0) {
    FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d74b,(char *)0x0);
    FUN_004d9c70(&DAT_00524e20);
    FUN_00452ccc(local_24,2);
  }
  else {
    FUN_0040ab28(local_54,(undefined4 *)(iVar2 + 0x74));
    FUN_0040b058((int)local_54,3,&local_60);
    iVar2 = *(int *)(*(int *)(iVar2 + 0xc4) + 0xc0);
    if (iVar2 == -1) {
      FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d785,(char *)0x0);
      FUN_004d9c70(&DAT_00524e20);
      FUN_00452ccc(local_24,2);
    }
    else {
      local_14 = param_2;
      local_10 = (**(code **)(*(int *)(param_1 + 0x3a4) + 0xc))(param_1 + 0x3a4,&local_14);
      if (local_10 == 0) {
        FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d7ca,(char *)0x0);
        FUN_004d9c70(&DAT_00524e20);
        FUN_00452ccc(local_24,2);
      }
      else {
        local_c = *(int *)(*(int *)(local_10 + 0x10) + iVar2 * 4);
        iVar2 = FUN_00407064(*(int *)(DAT_004efc94 + 0x68),param_4,10);
        if (iVar2 == 0) {
          FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d810,(char *)0x0);
          piVar3 = FUN_004db78c(&DAT_00524e20,param_4);
          FUN_004dbb24(piVar3,s_has_no_video_resource_0051d83b,(char *)0x0);
          FUN_00452ccc(local_24,2);
        }
        else {
          iVar1 = *(int *)(iVar2 + 4);
          *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + 1;
          if (iVar1 == 0) {
            FUN_00406cd0(iVar2);
          }
          FUN_0045a0c4(local_24,iVar2);
          *(int *)(iVar2 + 4) = *(int *)(iVar2 + 4) + -1;
          FUN_004614d7(local_6c,(int)local_24);
          if (*(int *)(param_2 + 400) == 0) {
            FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d853,(char *)0x0);
            local_8 = 0;
          }
          else {
            local_8 = *(uint *)(*(int *)(param_2 + 400) + 0x1e0);
          }
          (**(code **)(local_6c[0] + 4))(local_6c);
          while( true ) {
            iVar2 = (**(code **)(local_6c[0] + 0x28))(local_6c);
            if (iVar2 == 0) break;
            iVar2 = FUN_004dd1e0(*(char **)(iVar2 + 0xc));
            if (iVar2 < 1000) {
              FUN_004dbb24(&DAT_00524e20,s_StartEntityEffectImplementation__0051d897,(char *)0x0);
            }
            else {
              FUN_004606d4(param_1,local_60,local_5c,local_58,iVar2,local_c,local_8);
            }
          }
          FUN_0045a134((int)local_24);
          FUN_00461515(local_6c,2);
          FUN_00452ccc(local_24,2);
        }
      }
    }
  }
  return;
}



/* @004d0c14 file=? name=FUN_004d0c14 */

void __cdecl FUN_004d0c14(undefined4 param_1,int param_2)

{
  uint uVar1;
  
  if (*(int *)(param_2 + 400) != 0) {
    uVar1 = *(int *)(*(int *)(param_2 + 400) + 0x1e0) << 0x10;
    FUN_00490368(uVar1,uVar1 | 0xffff);
    return;
  }
  FUN_004dbb24(&DAT_00524e20,s_StopAllEntityEffectsImplementati_0051d8da,(char *)0x0);
  return;
}



/* @004d0c5c file=? name=FUN_004d0c5c */

void __cdecl FUN_004d0c5c(int param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  int local_8;
  
  iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4afc);
  if (iVar1 != 0) {
    local_8 = param_2;
    puVar2 = (undefined4 *)(**(code **)(*(int *)(param_1 + 0x3a4) + 0xc))(param_1 + 0x3a4,&local_8);
    if ((puVar2 != (undefined4 *)0x0) && (puVar2 != (undefined4 *)0x0)) {
      (**(code **)*puVar2)(puVar2,3);
    }
  }
  FUN_004369a0(param_1,param_2);
  return;
}



/* @004d0cc0 file=bt_l4/btl4vid.cpp name=FUN_004d0cc0 */

void __cdecl FUN_004d0cc0(undefined4 param_1,int param_2)

{
  char cVar1;
  int iVar2;
  int iVar3;
  int *piVar4;
  int *piVar5;
  char *pcVar6;
  char *pcVar7;
  uint uVar8;
  uint uVar9;
  char *pcVar10;
  char *pcVar11;
  char local_7c [80];
  char *local_2c;
  char *local_28;
  char *local_24;
  undefined4 *local_20;
  uint local_1c;
  char *local_18;
  char *local_14;
  char *local_10;
  undefined4 *local_c;
  int *local_8;
  
  if (DAT_0051d19c == '\0') {
    DAT_0051d198 = FUN_004d4a78(PTR_s__color__0051d188);
    DAT_0051d19c = DAT_0051d19c + '\x01';
  }
  if (DAT_0051d1a4 == '\0') {
    DAT_0051d1a0 = FUN_004d4a78(PTR_s__badge__0051d18c);
    DAT_0051d1a4 = DAT_0051d1a4 + '\x01';
  }
  if (DAT_0051d1ac == '\0') {
    DAT_0051d1a8 = FUN_004d4a78(PTR_s__patch__0051d190);
    DAT_0051d1ac = DAT_0051d1ac + '\x01';
  }
  if (DAT_0051d1b4 == '\0') {
    DAT_0051d1b0 = FUN_004d4a78(PTR_s__serno__0051d194);
    DAT_0051d1b4 = DAT_0051d1b4 + '\x01';
  }
  iVar3 = FUN_00406ff8(*(int *)(DAT_004efc94 + 0x68),s_vehicletable_0051d941,0x19,-1);
  if (iVar3 != 0) {
    iVar2 = *(int *)(iVar3 + 4);
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + 1;
    if (iVar2 == 0) {
      FUN_00406cd0(iVar3);
    }
    local_20 = *(undefined4 **)(iVar3 + 0x3c);
    uVar8 = *(uint *)(iVar3 + 0x40);
    piVar4 = (int *)FUN_004022b0(uVar8);
    FUN_004d4918(piVar4,local_20,uVar8);
    *(int *)(iVar3 + 4) = *(int *)(iVar3 + 4) + -1;
    piVar5 = (int *)FUN_00402298(0x20);
    if (piVar5 == (int *)0x0) {
      local_8 = (int *)0x0;
    }
    else {
      local_8 = FUN_00403e84(piVar5,(char *)0x0,1);
    }
    FUN_00404d00((int)local_8,(char *)piVar4,uVar8);
    FUN_004022d0(piVar4);
    pcVar11 = *(char **)(*(int *)(param_2 + 0x848) + 8);
    pcVar7 = *(char **)(*(int *)(param_2 + 0x844) + 8);
    pcVar6 = *(char **)(*(int *)(param_2 + 0x84c) + 8);
    iVar3 = FUN_00404088((int)local_8,s_color_0051d94e,pcVar11,&local_10);
    if (iVar3 == 0) {
      local_24 = pcVar11;
      FUN_004dbb24(&DAT_00524e20,s_____Color_value___0051d954,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_24,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___from_egg_not_found_in_vehicle_t_0051d966,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      FUN_0040385c(s_Exiting__0051d991,s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051d99a,0xbeb);
    }
    iVar3 = FUN_00404088((int)local_8,s_badge_0051d9b8,pcVar7,&local_14);
    if (iVar3 == 0) {
      local_28 = pcVar7;
      FUN_004dbb24(&DAT_00524e20,s_____Badge_value___0051d9be,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_28,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___from_egg_not_found_in_vehicle_t_0051d9d0,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      FUN_0040385c(s_Exiting__0051d9fb,s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051da04,0xbf2);
    }
    iVar3 = FUN_00404088((int)local_8,s_patch_0051da22,pcVar6,&local_18);
    if (iVar3 == 0) {
      local_2c = pcVar6;
      FUN_004dbb24(&DAT_00524e20,s_____Patch_value___0051da28,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,local_2c,(char *)0x0);
      FUN_004dbb24(&DAT_00524e20,s___from_egg_not_found_in_vehicle_t_0051da3a,(char *)0x0);
      FUN_004d9c38(&DAT_00524e20);
      FUN_0040385c(s_Exiting__0051da65,s_d__tesla_bt_bt_l4_BTL4VID_CPP_0051da6e,0xbf9);
    }
    DAT_004f1aac = FUN_00404720((int)local_8,s_substitute_0051da8c,(char *)0x0);
    for (local_c = (undefined4 *)DAT_004f1aac[1]; local_c != (undefined4 *)0x0;
        local_c = (undefined4 *)*local_c) {
      pcVar11 = local_7c;
      pcVar7 = (char *)local_c[1];
      local_7c[0] = '\0';
      while (pcVar6 = FUN_004d49f4(pcVar7,'%'), pcVar6 != (char *)0x0) {
        local_1c = (int)pcVar6 - (int)pcVar7;
        pcVar10 = pcVar7;
        if (local_1c != 0) {
          FUN_004d4b9c((undefined4 *)pcVar11,pcVar7,local_1c);
          pcVar11 = pcVar11 + local_1c;
          pcVar10 = pcVar6;
        }
        iVar3 = FUN_004d4ae0(pcVar6,PTR_s__serno__0051d194,DAT_0051d1b0);
        if (iVar3 == 0) {
          if (s_0GraphicGaugeBackground_0051d1b5[0] != '\0') {
            *pcVar11 = s_0GraphicGaugeBackground_0051d1b5[0];
            pcVar11 = pcVar11 + 1;
          }
          pcVar7 = pcVar10 + DAT_0051d1b0;
        }
        else {
          iVar3 = FUN_004d4ae0(pcVar6,PTR_s__color__0051d188,DAT_0051d198);
          if (iVar3 == 0) {
            if (local_10 != (char *)0x0) {
              uVar8 = 0xffffffff;
              pcVar7 = local_10;
              do {
                pcVar6 = pcVar7;
                if (uVar8 == 0) break;
                uVar8 = uVar8 - 1;
                pcVar6 = pcVar7 + 1;
                cVar1 = *pcVar7;
                pcVar7 = pcVar6;
              } while (cVar1 != '\0');
              uVar8 = ~uVar8;
              pcVar7 = pcVar6 + -uVar8;
              pcVar6 = pcVar11;
              for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
                *(undefined4 *)pcVar6 = *(undefined4 *)pcVar7;
                pcVar7 = pcVar7 + 4;
                pcVar6 = pcVar6 + 4;
              }
              for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
                *pcVar6 = *pcVar7;
                pcVar7 = pcVar7 + 1;
                pcVar6 = pcVar6 + 1;
              }
              iVar3 = FUN_004d4a78(local_10);
              pcVar11 = pcVar11 + iVar3;
            }
            pcVar7 = pcVar10 + DAT_0051d198;
          }
          else {
            iVar3 = FUN_004d4ae0(pcVar6,PTR_s__badge__0051d18c,DAT_0051d1a0);
            if (iVar3 == 0) {
              if (local_14 != (char *)0x0) {
                uVar8 = 0xffffffff;
                pcVar7 = local_14;
                do {
                  pcVar6 = pcVar7;
                  if (uVar8 == 0) break;
                  uVar8 = uVar8 - 1;
                  pcVar6 = pcVar7 + 1;
                  cVar1 = *pcVar7;
                  pcVar7 = pcVar6;
                } while (cVar1 != '\0');
                uVar8 = ~uVar8;
                pcVar7 = pcVar6 + -uVar8;
                pcVar6 = pcVar11;
                for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
                  *(undefined4 *)pcVar6 = *(undefined4 *)pcVar7;
                  pcVar7 = pcVar7 + 4;
                  pcVar6 = pcVar6 + 4;
                }
                for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
                  *pcVar6 = *pcVar7;
                  pcVar7 = pcVar7 + 1;
                  pcVar6 = pcVar6 + 1;
                }
                iVar3 = FUN_004d4a78(local_14);
                pcVar11 = pcVar11 + iVar3;
              }
              pcVar7 = pcVar10 + DAT_0051d1a0;
            }
            else {
              iVar3 = FUN_004d4ae0(pcVar6,PTR_s__patch__0051d190,DAT_0051d1a8);
              if (iVar3 == 0) {
                if (local_18 != (char *)0x0) {
                  uVar8 = 0xffffffff;
                  pcVar7 = local_18;
                  do {
                    pcVar6 = pcVar7;
                    if (uVar8 == 0) break;
                    uVar8 = uVar8 - 1;
                    pcVar6 = pcVar7 + 1;
                    cVar1 = *pcVar7;
                    pcVar7 = pcVar6;
                  } while (cVar1 != '\0');
                  uVar8 = ~uVar8;
                  pcVar7 = pcVar6 + -uVar8;
                  pcVar6 = pcVar11;
                  for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
                    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar7;
                    pcVar7 = pcVar7 + 4;
                    pcVar6 = pcVar6 + 4;
                  }
                  for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
                    *pcVar6 = *pcVar7;
                    pcVar7 = pcVar7 + 1;
                    pcVar6 = pcVar6 + 1;
                  }
                  iVar3 = FUN_004d4a78(local_18);
                  pcVar11 = pcVar11 + iVar3;
                }
                pcVar7 = pcVar10 + DAT_0051d1a8;
              }
              else {
                pcVar7 = pcVar10 + 1;
                *pcVar11 = *pcVar10;
                pcVar11 = pcVar11 + 1;
              }
            }
          }
        }
      }
      if (*pcVar7 == '\0') {
        *pcVar11 = '\0';
      }
      else {
        uVar8 = 0xffffffff;
        do {
          pcVar6 = pcVar7;
          if (uVar8 == 0) break;
          uVar8 = uVar8 - 1;
          pcVar6 = pcVar7 + 1;
          cVar1 = *pcVar7;
          pcVar7 = pcVar6;
        } while (cVar1 != '\0');
        uVar8 = ~uVar8;
        pcVar7 = pcVar6 + -uVar8;
        for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
          *(undefined4 *)pcVar11 = *(undefined4 *)pcVar7;
          pcVar7 = pcVar7 + 4;
          pcVar11 = pcVar11 + 4;
        }
        for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
          *pcVar11 = *pcVar7;
          pcVar7 = pcVar7 + 1;
          pcVar11 = pcVar11 + 1;
        }
      }
      iVar3 = FUN_004d4a78(local_7c);
      pcVar7 = (char *)FUN_004022b0(iVar3 + 1);
      uVar8 = 0xffffffff;
      pcVar11 = local_7c;
      do {
        pcVar6 = pcVar11;
        if (uVar8 == 0) break;
        uVar8 = uVar8 - 1;
        pcVar6 = pcVar11 + 1;
        cVar1 = *pcVar11;
        pcVar11 = pcVar6;
      } while (cVar1 != '\0');
      uVar8 = ~uVar8;
      pcVar11 = pcVar6 + -uVar8;
      pcVar6 = pcVar7;
      for (uVar9 = uVar8 >> 2; uVar9 != 0; uVar9 = uVar9 - 1) {
        *(undefined4 *)pcVar6 = *(undefined4 *)pcVar11;
        pcVar11 = pcVar11 + 4;
        pcVar6 = pcVar6 + 4;
      }
      for (uVar8 = uVar8 & 3; uVar8 != 0; uVar8 = uVar8 - 1) {
        *pcVar6 = *pcVar11;
        pcVar11 = pcVar11 + 1;
        pcVar6 = pcVar6 + 1;
      }
      local_c[1] = pcVar7;
    }
    FUN_00403ecc(local_8,3);
    if (s_0GraphicGaugeBackground_0051d1b5[0] == '9') {
      s_0GraphicGaugeBackground_0051d1b5[0] = 'A';
    }
    else {
      s_0GraphicGaugeBackground_0051d1b5[0] = s_0GraphicGaugeBackground_0051d1b5[0] + '\x01';
    }
    FUN_0049664c(FUN_00459eb8);
  }
  return;
}



/* @004d11e8 file=? name=FUN_004d11e8 */

void FUN_004d11e8(void)

{
  undefined4 *puVar1;
  
  FUN_0049664c(0);
  if (DAT_004f1aac != (undefined4 *)0x0) {
    for (puVar1 = (undefined4 *)DAT_004f1aac[1]; puVar1 != (undefined4 *)0x0;
        puVar1 = (undefined4 *)*puVar1) {
      if ((int *)puVar1[1] != (int *)0x0) {
        FUN_004022d0((int *)puVar1[1]);
        puVar1[1] = 0;
      }
    }
    if (DAT_004f1aac != (undefined4 *)0x0) {
      (**(code **)*DAT_004f1aac)(DAT_004f1aac,3);
    }
    DAT_004f1aac = (undefined4 *)0x0;
  }
  return;
}



/* @004d123b file=? name=FUN_004d123b */

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

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



/* @004d125a file=? name=FUN_004d125a */

void __cdecl FUN_004d125a(int *param_1,byte param_2)

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



/* @004d1286 file=? name=FUN_004d1286 */

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

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



/* @004d12a5 file=? name=FUN_004d12a5 */

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

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



/* @004d12c4 file=? name=FUN_004d12c4 */

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

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



/* @004d12e3 file=? name=FUN_004d12e3 */

void __cdecl FUN_004d12e3(int *param_1,byte param_2)

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



/* @004d130f file=? name=FUN_004d130f */

void __cdecl FUN_004d130f(int *param_1,byte param_2)

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



/* @004d133c file=? name=FUN_004d133c */

void __cdecl FUN_004d133c(int param_1,char *param_2,undefined4 param_3)

{
  int *piVar1;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  piVar1 = (int *)FUN_0041f98c(param_1,param_2);
  if (piVar1 == (int *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_SendFakeButtonEvents__subsystem___0051e1b6,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,param_2,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,s___not_found_0051e1d8,(char *)0x0);
  }
  else {
    local_14 = 0x10;
    local_10 = param_3;
    local_c = 1;
    local_8 = 1;
    (**(code **)(*piVar1 + 0xc))(piVar1,&local_14);
    local_24 = 0x10;
    local_20 = param_3;
    local_1c = 1;
    local_18 = 0xffffffff;
    (**(code **)(*piVar1 + 0xc))(piVar1,&local_24);
  }
  return;
}



/* @004d13f0 file=? name=FUN_004d13f0 */

void __cdecl FUN_004d13f0(char *param_1,undefined4 param_2)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_0041f98c(*(int *)(DAT_004efc94 + 0x6c),param_1);
  if (piVar1 != (int *)0x0) {
    (**(code **)(*piVar1 + 0x20))(piVar1,param_2);
  }
  return;
}



/* @004d141c file=? name=FUN_004d141c */

void __cdecl FUN_004d141c(int param_1,int param_2)

{
  int iVar1;
  undefined4 local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  iVar1 = *(int *)(param_2 + 0xc);
  if (iVar1 < 0x166) {
    if (iVar1 == 0x165) {
      FUN_004d13f0(s_LRM15_0051e259,0);
    }
    else if (iVar1 < 0x162) {
      if (iVar1 == 0x161) {
        FUN_004d13f0(s_GeneratorD_0051e230,0);
      }
      else if (iVar1 == 0x5c) {
        local_14 = 0x10;
        local_10 = 0x19;
        local_c = 1;
        local_8 = 1;
        FUN_00419bbc(*(int *)(param_1 + 0xd0),(int)&local_14);
      }
      else if (iVar1 == 0x15e) {
        FUN_004d13f0(s_GeneratorA_0051e20f,0);
      }
      else if (iVar1 == 0x15f) {
        FUN_004d13f0(s_GeneratorB_0051e21a,0);
      }
      else if (iVar1 == 0x160) {
        FUN_004d13f0(s_GeneratorC_0051e225,0);
      }
    }
    else if (iVar1 == 0x162) {
      FUN_004d13f0(s_Condenser1_0051e23b,0);
    }
    else if (iVar1 == 0x163) {
      FUN_004d13f0(s_LRM15_0051e246,2);
    }
    else if (iVar1 == 0x164) {
      FUN_004d13f0(s_AmmoBinLRM15_0051e24c,1);
    }
  }
  else {
    switch(iVar1) {
    case 0x166:
      FUN_004d13f0(s_Avionics_0051e25f,0);
      break;
    case 0x167:
      FUN_004d13f0(&DAT_0051e268,0);
      break;
    case 0x168:
      FUN_004d13f0(s_GeneratorA_0051e26c,1);
      break;
    case 0x169:
      FUN_004d13f0(s_GeneratorB_0051e277,1);
      break;
    case 0x16a:
      FUN_004d13f0(s_GeneratorC_0051e282,1);
      break;
    case 0x16b:
      FUN_004d13f0(s_GeneratorD_0051e28d,1);
      break;
    case 0x16c:
      FUN_004d13f0(s_Condenser1_0051e298,1);
      break;
    case 0x185:
      if (*(int *)(DAT_004efc94 + 0x4c) != 0) {
        FUN_00448654(*(int *)(DAT_004efc94 + 0x4c));
      }
    }
  }
  return;
}



/* @004d168c file=? name=FUN_004d168c */

void __cdecl FUN_004d168c(int param_1,int param_2)

{
  int *piVar1;
  undefined4 local_98;
  undefined4 local_94;
  undefined4 local_90;
  undefined4 local_8c [2];
  undefined4 local_84;
  undefined4 local_80;
  undefined4 local_7c [2];
  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;
  undefined4 local_48;
  undefined4 local_44;
  undefined4 local_40;
  undefined4 local_3c;
  undefined4 local_38;
  undefined4 local_34;
  undefined4 local_30;
  undefined4 local_2c;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  piVar1 = *(int **)(param_1 + 0xd0);
  if (*(int *)(param_2 + 0xc) == 1) {
    FUN_0041db7c((int)&local_34);
    local_34 = 2;
    local_30 = 0x47c35000;
    local_8 = 0;
    FUN_00408440(&local_14,piVar1 + 0x40);
    local_98 = 100;
    local_94 = 0x12;
    local_90 = 1;
    FUN_00420ea4(local_8c,(undefined4 *)&DAT_00522524);
    local_84 = 0;
    local_80 = 0;
    FUN_00420ea4(local_7c,piVar1 + 0x61);
    local_74 = 0xffffffff;
    local_70 = 1;
    local_6c = local_34;
    local_68 = local_30;
    local_64 = local_2c;
    local_60 = local_28;
    local_5c = local_24;
    local_58 = local_20;
    local_54 = local_1c;
    local_50 = local_18;
    local_4c = local_14;
    local_48 = local_10;
    local_44 = local_c;
    local_40 = local_8;
    local_3c = 0xffffffff;
    local_38 = 1;
    (**(code **)(*piVar1 + 0xc))(piVar1,&local_98);
  }
  return;
}



/* @004d17ac file=? name=FUN_004d17ac */

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

{
  int *piVar1;
  
  param_4[3] = param_4[3] + 1;
  FUN_004b02f0(param_1,param_2,param_3,param_4,param_5,param_6);
  *param_1 = &PTR_FUN_0051e440;
  param_1[0x6a] = 0;
  param_1[0x68] = 0x40000000;
  param_1[0x69] = 0x40000000;
  piVar1 = param_4 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(param_4,3);
  }
  return param_1;
}



/* @004d1814 file=? name=FUN_004d1814 */

void __cdecl FUN_004d1814(int *param_1,byte param_2)

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



/* @004d1840 file=? name=FUN_004d1840 */

void __cdecl
FUN_004d1840(undefined4 param_1,int param_2,undefined4 param_3,undefined4 param_4,undefined4 param_5
            ,undefined4 param_6,undefined4 param_7)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = *(int **)(DAT_004efc94 + 0x3c);
  (**(code **)(*piVar1 + 0x20))(piVar1,param_3,param_4,param_4,param_7,0x10000,0x8000);
  (**(code **)(piVar1[param_2 * 8 + 0x70] + 0x14))
            (piVar1 + param_2 * 8 + 0x70,0x8000,param_4,param_6,param_4);
  iVar2 = 0x40;
  do {
    if (iVar2 == 0x41) {
      iVar2 = 0x45;
    }
    (**(code **)(piVar1[iVar2 * 8 + 0x70] + 0x14))
              (piVar1 + iVar2 * 8 + 0x70,0x8000,param_4,param_5,param_4);
    iVar2 = iVar2 + 1;
  } while (iVar2 < 0x48);
  return;
}



/* @004d18dc file=? name=FUN_004d18dc */

void __cdecl FUN_004d18dc(undefined4 param_1,int param_2)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = *(int **)(DAT_004efc94 + 0x3c);
  (**(code **)(*piVar1 + 0x24))(piVar1,0x8000,0x10000);
  (**(code **)(piVar1[param_2 * 8 + 0x70] + 0xc))(piVar1 + param_2 * 8 + 0x70,0x8000);
  iVar2 = 0x40;
  do {
    if (iVar2 == 0x41) {
      iVar2 = 0x45;
    }
    (**(code **)(piVar1[iVar2 * 8 + 0x70] + 0xc))(piVar1 + iVar2 * 8 + 0x70,0x8000);
    iVar2 = iVar2 + 1;
  } while (iVar2 < 0x48);
  return;
}



/* @004d195c file=? name=FUN_004d195c */

void FUN_004d195c(void)

{
  return;
}



/* @004d1964 file=? name=FUN_004d1964 */

void FUN_004d1964(void)

{
  return;
}



/* @004d196c file=? name=FUN_004d196c */

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

void __cdecl FUN_004d196c(int param_1,float param_2)

{
  int iVar1;
  int iVar2;
  float10 fVar3;
  
  fVar3 = FUN_004dcd00((double)(*(float *)(param_1 + 0x11c) - _DAT_004d1ac0));
  if (fVar3 <= (float10)_DAT_004d1ac4) {
    *(undefined4 *)(param_1 + 0x11c) = 0x3f800000;
  }
  FUN_004b0600(param_1);
  iVar1 = *(int *)(*(int *)(param_1 + 0xd0) + 0x414);
  if (iVar1 != *(int *)(param_1 + 0x1a8)) {
    *(int *)(param_1 + 0x1a8) = iVar1;
    iVar2 = *(int *)(DAT_004efc94 + 0x50);
    if (iVar1 == 0) {
      *(undefined4 *)(iVar2 + 8) = *(undefined4 *)(iVar2 + 4);
      *(uint *)(iVar2 + 4) = *(uint *)(iVar2 + 4) & 0xffdfffff;
    }
    else {
      *(undefined4 *)(iVar2 + 8) = *(undefined4 *)(iVar2 + 4);
      *(uint *)(iVar2 + 4) = *(uint *)(iVar2 + 4) | 0x200000;
    }
  }
  if (*(float *)(param_1 + 0x1a0) != *(float *)(param_1 + 0x1a4)) {
    if (*(float *)(param_1 + 0x1a0) <= *(float *)(param_1 + 0x1a4)) {
      *(float *)(param_1 + 0x1a4) = *(float *)(param_1 + 0x1a4) - param_2;
      if (*(float *)(param_1 + 0x1a4) < *(float *)(param_1 + 0x1a0)) {
        *(undefined4 *)(param_1 + 0x1a4) = *(undefined4 *)(param_1 + 0x1a0);
      }
    }
    else {
      *(float *)(param_1 + 0x1a4) = param_2 + *(float *)(param_1 + 0x1a4);
      if (*(float *)(param_1 + 0x1a0) < *(float *)(param_1 + 0x1a4)) {
        *(undefined4 *)(param_1 + 0x1a4) = *(undefined4 *)(param_1 + 0x1a0);
      }
    }
    iVar1 = *(int *)(param_1 + 0xd0);
    fVar3 = FUN_004dce94(2.0,SUB84((double)*(float *)(param_1 + 0x1a4),0),
                         (uint)((ulonglong)(double)*(float *)(param_1 + 0x1a4) >> 0x20));
    *(float *)(iVar1 + 0x404) = (float)(fVar3 * (float10)_DAT_004d1ac8);
  }
  FUN_004afd10(param_1);
  return;
}



/* @004d1ae4 file=? name=FUN_004d1ae4 */

void __cdecl FUN_004d1ae4(undefined4 param_1,int param_2)

{
  int iVar1;
  uint uVar2;
  
  iVar1 = *(int *)(DAT_004efc94 + 0x50);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) & 0xffe3ffff;
  uVar2 = *(uint *)(&DAT_0051dbe4 + param_2 * 4);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) | uVar2;
  FUN_004b0494();
  return;
}



/* @004d1b24 file=? name=FUN_004d1b24 */

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

{
  int iVar1;
  uint uVar2;
  int iVar3;
  
  iVar3 = param_2 * 5 + param_3;
  iVar1 = *(int *)(DAT_004efc94 + 0x50);
  uVar2 = *(uint *)(&DAT_0051dbf0 + iVar3 * 8);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) & ~uVar2;
  uVar2 = *(uint *)(&DAT_0051dbf4 + iVar3 * 8);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) | uVar2;
  return;
}



/* @004d1b64 file=? name=FUN_004d1b64 */

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

void __cdecl FUN_004d1b64(int param_1)

{
  float fVar1;
  
  fVar1 = *(float *)(param_1 + 0x1a0) - _DAT_004d1b94;
  *(float *)(param_1 + 0x1a0) = fVar1;
  if (fVar1 < _DAT_004d1b98) {
    *(undefined4 *)(param_1 + 0x1a0) = 0;
  }
  return;
}



/* @004d1b9c file=? name=FUN_004d1b9c */

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

void __cdecl FUN_004d1b9c(int param_1)

{
  float fVar1;
  
  fVar1 = _DAT_004d1bcc + *(float *)(param_1 + 0x1a0);
  *(float *)(param_1 + 0x1a0) = fVar1;
  if (_DAT_004d1bd0 < fVar1) {
    *(undefined4 *)(param_1 + 0x1a0) = 0x40a00000;
  }
  return;
}



/* @004d1bf0 file=? name=FUN_004d1bf0 */

void __cdecl FUN_004d1bf0(int *param_1,int param_2)

{
  int iVar1;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  undefined4 local_18;
  undefined4 local_14;
  undefined4 local_10;
  undefined4 local_c;
  undefined4 local_8;
  
  iVar1 = *(int *)(param_2 + 0xc);
  if (iVar1 < 0x71) {
    if (iVar1 == 0x70) {
      FUN_004b04d8((int)param_1,0);
      return;
    }
    switch(iVar1) {
    case 0x2b:
      FUN_004d1b64((int)param_1);
      return;
    case 0x2d:
      FUN_004d1b9c((int)param_1);
      return;
    case 0x31:
      FUN_004d1b24(param_1,0,1);
      return;
    case 0x32:
      FUN_004d1b24(param_1,0,2);
      return;
    case 0x33:
      FUN_004d1b24(param_1,0,3);
      return;
    case 0x34:
      FUN_004d1b24(param_1,0,4);
      return;
    case 0x35:
      FUN_004d1b24(param_1,0,0);
      return;
    case 0x61:
      FUN_004d1b24(param_1,1,1);
      return;
    case 0x62:
      FUN_004d1b24(param_1,2,0);
      return;
    case 99:
      FUN_004d1b24(param_1,2,3);
      return;
    case 100:
      FUN_004d1b24(param_1,1,3);
      return;
    case 0x65:
      FUN_004b049c((int)param_1,1);
      return;
    case 0x66:
      FUN_004d1b24(param_1,1,4);
      return;
    case 0x67:
      FUN_004d1b24(param_1,1,0);
      return;
    case 0x69:
      FUN_004b049c((int)param_1,6);
      return;
    case 0x6a:
      FUN_004d133c(param_1[0x34],s_LRM10_0051e2e3,0xb);
      return;
    case 0x6c:
      FUN_004d133c(param_1[0x34],s_Searchlight_0051e2d7,3);
      return;
    case 0x6f:
      FUN_004b049c((int)param_1,7);
      return;
    }
  }
  else if (iVar1 < 0x13c) {
    if (iVar1 == 0x13b) {
      FUN_00476e34(*(int *)(DAT_004efc94 + 0x3c));
      return;
    }
    switch(iVar1) {
    case 0x72:
      FUN_004b049c((int)param_1,2);
      return;
    case 0x73:
      FUN_004d1b24(param_1,1,2);
      return;
    case 0x74:
      FUN_004b049c((int)param_1,3);
      return;
    case 0x75:
      FUN_004b049c((int)param_1,5);
      return;
    case 0x76:
      FUN_004d1b24(param_1,2,4);
      return;
    case 0x77:
      FUN_004b049c((int)param_1,0);
      return;
    case 0x78:
      FUN_004d1b24(param_1,2,2);
      return;
    case 0x79:
      FUN_004b049c((int)param_1,4);
      return;
    case 0x7a:
      FUN_004d1b24(param_1,2,1);
      return;
    }
  }
  else if (iVar1 < 0x14c) {
    if (iVar1 == 0x14b) {
      param_1[0x4c] = -1;
      param_1[0x4d] = 1;
      param_1[0x4e] = -1;
      param_1[0x4f] = -1;
      param_1[0x50] = -1;
      return;
    }
    if (iVar1 == 0x13c) {
      FUN_00476e54(*(int *)(DAT_004efc94 + 0x3c));
      return;
    }
    if (iVar1 == 0x13d) {
      local_14 = 0x10;
      local_10 = 0;
      local_c = 1;
      local_8 = 1;
      FUN_004afbe0(param_1,(int)&local_14);
      return;
    }
    if (iVar1 == 0x13e) {
      local_24 = 0x10;
      local_20 = 0;
      local_1c = 1;
      local_18 = 1;
      FUN_004afcac(param_1,(int)&local_24);
      return;
    }
    if (iVar1 == 0x148) {
      param_1[0x4c] = 1;
      param_1[0x4d] = -1;
      param_1[0x4e] = -1;
      param_1[0x4f] = -1;
      param_1[0x50] = -1;
      return;
    }
  }
  else {
    if (iVar1 == 0x14d) {
      param_1[0x4c] = -1;
      param_1[0x4d] = -1;
      param_1[0x4e] = 1;
      param_1[0x4f] = -1;
      param_1[0x50] = -1;
      return;
    }
    if (iVar1 == 0x150) {
      param_1[0x4c] = -1;
      param_1[0x4d] = -1;
      param_1[0x4e] = -1;
      param_1[0x4f] = 1;
      param_1[0x50] = -1;
      return;
    }
    if (iVar1 == 0x18d) {
      param_1[0x4c] = -1;
      param_1[0x4d] = -1;
      param_1[0x4e] = -1;
      param_1[0x4f] = -1;
      param_1[0x50] = 1;
      return;
    }
  }
  FUN_004d141c((int)param_1,param_2);
  return;
}



/* @004d2150 file=? name=FUN_004d2150 */

void __cdecl FUN_004d2150(int param_1,float param_2)

{
  if (*(int *)(param_1 + 0x1ac) < 1) {
    if (*(int *)(param_1 + 0x1b0) < 1) {
      *(undefined4 *)(param_1 + 0x124) = 0;
      *(undefined4 *)(param_1 + 0x11c) = 0;
    }
    else {
      *(undefined4 *)(param_1 + 0x11c) = 0x3f800000;
      *(undefined4 *)(param_1 + 0x124) = 1;
    }
  }
  else {
    *(undefined4 *)(param_1 + 0x11c) = 0x3f800000;
    *(undefined4 *)(param_1 + 0x124) = 0;
  }
  *(float *)(param_1 + 0x120) = (float)(*(int *)(param_1 + 0x1b4) - *(int *)(param_1 + 0x1b8));
  FUN_004d196c(param_1,param_2);
  return;
}



/* @004d21d0 file=? name=FUN_004d21d0 */

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

{
  int *piVar1;
  int iVar2;
  
  param_4[3] = param_4[3] + 1;
  FUN_004d17ac(param_1,param_2,param_3,param_4,param_5,param_6);
  *param_1 = &PTR_FUN_0051e3f0;
  param_1[7] = PTR_FUN_0051dcc4;
  param_1[8] = DAT_0051dcc8;
  param_1[9] = DAT_0051dccc;
  param_1[0x6b] = 0;
  param_1[0x6c] = 0;
  param_1[0x6d] = 0;
  param_1[0x6e] = 0;
  iVar2 = *(int *)(DAT_004efc94 + 0x3c);
  (**(code **)(*(int *)(iVar2 + 0xa00) + 0x18))(iVar2 + 0xa00,0xffffffff,param_1 + 0x6b,param_1);
  (**(code **)(*(int *)(iVar2 + 0x9e0) + 0x18))(iVar2 + 0x9e0,0xffffffff,param_1 + 0x6c,param_1);
  (**(code **)(*(int *)(iVar2 + 0x1a0) + 0x14))(iVar2 + 0x1a0,0xffffffff,param_1,0x17,param_1);
  piVar1 = param_4 + 3;
  *piVar1 = *piVar1 + -1;
  if (*piVar1 == 0) {
    FUN_004024d8(param_4,3);
  }
  return param_1;
}



/* @004d22b4 file=? name=FUN_004d22b4 */

void __cdecl FUN_004d22b4(int *param_1,byte param_2)

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



/* @004d22e0 file=? name=FUN_004d22e0 */

void __cdecl FUN_004d22e0(int param_1)

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



/* @004d22fc file=? name=FUN_004d22fc */

void __cdecl FUN_004d22fc(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,0,0);
  }
  return;
}



/* @004d231c file=? name=FUN_004d231c */

void __cdecl FUN_004d231c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,0,1);
  }
  return;
}



/* @004d233c file=? name=FUN_004d233c */

void __cdecl FUN_004d233c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,0,2);
  }
  return;
}



/* @004d235c file=? name=FUN_004d235c */

void __cdecl FUN_004d235c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,0,3);
  }
  return;
}



/* @004d237c file=? name=FUN_004d237c */

void __cdecl FUN_004d237c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,0,4);
  }
  return;
}



/* @004d239c file=? name=FUN_004d239c */

void __cdecl FUN_004d239c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,1,0);
  }
  return;
}



/* @004d23bc file=? name=FUN_004d23bc */

void __cdecl FUN_004d23bc(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,1,1);
  }
  return;
}



/* @004d23dc file=? name=FUN_004d23dc */

void __cdecl FUN_004d23dc(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,1,2);
  }
  return;
}



/* @004d23fc file=? name=FUN_004d23fc */

void __cdecl FUN_004d23fc(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,1,3);
  }
  return;
}



/* @004d241c file=? name=FUN_004d241c */

void __cdecl FUN_004d241c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,1,4);
  }
  return;
}



/* @004d243c file=? name=FUN_004d243c */

void __cdecl FUN_004d243c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,2,0);
  }
  return;
}



/* @004d245c file=? name=FUN_004d245c */

void __cdecl FUN_004d245c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,2,1);
  }
  return;
}



/* @004d247c file=? name=FUN_004d247c */

void __cdecl FUN_004d247c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,2,2);
  }
  return;
}



/* @004d249c file=? name=FUN_004d249c */

void __cdecl FUN_004d249c(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,2,3);
  }
  return;
}



/* @004d24bc file=? name=FUN_004d24bc */

void __cdecl FUN_004d24bc(undefined4 param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b24(param_1,2,4);
  }
  return;
}



/* @004d24dc file=? name=FUN_004d24dc */

void __cdecl FUN_004d24dc(int param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b64(param_1);
  }
  return;
}



/* @004d24f8 file=? name=FUN_004d24f8 */

void __cdecl FUN_004d24f8(int param_1,int param_2)

{
  if (0 < *(int *)(param_2 + 0xc)) {
    FUN_004d1b9c(param_1);
  }
  return;
}



/* @004d2514 file=? name=FUN_004d2514 */

void __cdecl FUN_004d2514(int param_1,int param_2)

{
  if (*(int *)(param_2 + 0xc) == 0x13b) {
    FUN_00476e8c(*(int *)(DAT_004efc94 + 0x3c));
    FUN_0041bbd8(*(int *)(param_1 + 0xd0) + 0x2c,0);
    return;
  }
  if (*(int *)(param_2 + 0xc) != 0x186) {
    FUN_004d141c(param_1,param_2);
    return;
  }
  FUN_0044e6c0(DAT_004efc94);
  return;
}



/* @004d2574 file=? name=FUN_004d2574 */

void __cdecl FUN_004d2574(int param_1,int param_2)

{
  int iVar1;
  int *piVar2;
  
  if (0 < *(int *)(param_2 + 0xc)) {
    piVar2 = &DAT_0051dcd0;
    iVar1 = 0;
    do {
      if (*(int *)(param_2 + 0xc) + -1 == *piVar2) {
        if (iVar1 < 7) {
          FUN_004b049c(param_1,iVar1 + 1);
          return;
        }
        FUN_004b04d8(param_1,0);
        return;
      }
      iVar1 = iVar1 + 1;
      piVar2 = piVar2 + 1;
    } while (iVar1 < 8);
  }
  return;
}



/* @004d25c0 file=? name=FUN_004d25c0 */

void __cdecl FUN_004d25c0(int param_1,float param_2)

{
  *(float *)(param_1 + 0x120) = *(float *)(param_1 + 0x1b4) - *(float *)(param_1 + 0x1b8);
  FUN_004d196c(param_1,param_2);
  return;
}



/* @004d25e8 file=? name=FUN_004d25e8 */

void __cdecl FUN_004d25e8(undefined4 param_1,int param_2,undefined4 param_3,undefined4 param_4)

{
  int iVar1;
  
  iVar1 = (param_2 + -1) * 0x20;
  (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 0x3c) + 0x1c0 + iVar1) + 0x1c))
            (iVar1 + *(int *)(DAT_004efc94 + 0x3c) + 0x1c0,0x10000,param_3,param_4,param_1);
  return;
}



/* @004d262c file=? name=FUN_004d262c */

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

{
  int iVar1;
  
  iVar1 = (param_2 + -1) * 0x20;
  (**(code **)(*(int *)(*(int *)(DAT_004efc94 + 0x3c) + 0x1c0 + iVar1) + 0x20))
            (iVar1 + *(int *)(DAT_004efc94 + 0x3c) + 0x1c0,0x10000,param_3,param_1);
  return;
}



/* @004d266c file=? name=FUN_004d266c */

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

{
  int iVar1;
  int *piVar2;
  int local_8;
  
  param_4[3] = param_4[3] + 1;
  FUN_004d17ac(param_1,param_2,param_3,param_4,param_5,param_6);
  *param_1 = &PTR_FUN_0051e3a0;
  param_1[7] = PTR_FUN_0051deb4;
  param_1[8] = DAT_0051deb8;
  param_1[9] = DAT_0051debc;
  param_1[0x6b] = 0;
  param_1[0x6c] = 0;
  param_1[0x6d] = 0;
  param_1[0x6e] = 0;
  iVar1 = *(int *)(DAT_004efc94 + 0x3c);
  (**(code **)(*(int *)(iVar1 + 0x1a0) + 0x14))(iVar1 + 0x1a0,0xffffffff,param_1,0x19,param_1);
  (**(code **)(*(int *)(iVar1 + 0x44) + 0x18))(iVar1 + 0x44,0xffffffff,param_1 + 0x6d,param_1);
  (**(code **)(*(int *)(iVar1 + 100) + 0x18))(iVar1 + 100,0xffffffff,param_1 + 0x6e,param_1);
  (**(code **)(*(int *)(iVar1 + 0x960) + 0x14))(iVar1 + 0x960,0x200000,param_2,0x19,param_1);
  piVar2 = FUN_00476fc0(iVar1,0x3d,0x200000);
  if (piVar2 != (int *)0x0) {
    FUN_00444e64(piVar2,1);
  }
  piVar2 = &DAT_0051dcd0;
  local_8 = 0;
  do {
    (**(code **)(*(int *)(iVar1 + 0x1c0 + *piVar2 * 0x20) + 0x14))
              (*piVar2 * 0x20 + iVar1 + 0x1c0,0xffffffff,param_1,0x1a,param_1);
    FUN_00476fc0(iVar1,*piVar2,0xffffffff);
    local_8 = local_8 + 1;
    piVar2 = piVar2 + 1;
  } while (local_8 < 8);
  piVar2 = param_4 + 3;
  *piVar2 = *piVar2 + -1;
  if (*piVar2 == 0) {
    FUN_004024d8(param_4,3);
  }
  return param_1;
}



/* @004d27cc file=? name=FUN_004d27cc */

void __cdecl FUN_004d27cc(int *param_1,byte param_2)

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



/* @004d27f8 file=? name=FUN_004d27f8 */

void __cdecl FUN_004d27f8(int param_1)

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



/* @004d29fc file=? name=FUN_004d29fc */

undefined4 * __cdecl FUN_004d29fc(undefined4 *param_1)

{
  int iVar1;
  undefined4 *puVar2;
  undefined4 *puVar3;
  
  FUN_00436b1c(param_1);
  *param_1 = &PTR_FUN_0051e568;
  puVar2 = &DAT_004e107c;
  puVar3 = param_1 + 0x16;
  for (iVar1 = 0xc; iVar1 != 0; iVar1 = iVar1 + -1) {
    *puVar3 = *puVar2;
    puVar2 = puVar2 + 1;
    puVar3 = puVar3 + 1;
  }
  param_1[0x14] = 0;
  param_1[0x15] = 0;
  return param_1;
}



/* @004d2a34 file=? name=FUN_004d2a34 */

void __cdecl FUN_004d2a34(int *param_1,byte param_2)

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



/* @004d2a60 file=? name=FUN_004d2a60 */

void __cdecl FUN_004d2a60(int param_1,int param_2)

{
  int iVar1;
  uint *puVar2;
  
  FUN_00436bd8(param_1,param_2);
  *(undefined4 *)(param_1 + 0x50) = 0;
  iVar1 = FUN_0041a1a4(**(int **)(param_2 + 0xc),0x4e4afc);
  if (iVar1 != 0) {
    puVar2 = (uint *)FUN_00402298(0x10);
    if (puVar2 == (uint *)0x0) {
      puVar2 = (uint *)0x0;
    }
    else {
      puVar2 = FUN_00402460(puVar2,s_siteeyepoint_0051e4d1);
    }
    puVar2[3] = puVar2[3] + 1;
    iVar1 = FUN_00424b60(param_2,(int *)puVar2);
    *(int *)(param_1 + 0x54) = iVar1;
    if (iVar1 != 0) {
      *(undefined4 *)(param_1 + 0x50) = 1;
      FUN_004d2ae4(param_1);
    }
  }
  return;
}



/* @004d2ae4 file=? name=FUN_004d2ae4 */

void __cdecl FUN_004d2ae4(int param_1)

{
  int iVar1;
  undefined4 local_34 [12];
  
  if (*(int *)(param_1 + 0x50) == 0) {
    FUN_00436c08(local_34,param_1);
    FUN_0040ab28((undefined4 *)(param_1 + 0x58),local_34);
  }
  else {
    iVar1 = FUN_00417ab4(param_1 + 8);
    FUN_00424da8(iVar1,*(int *)(param_1 + 0x54),(float *)(param_1 + 0x58));
  }
  return;
}



/* @004d2b34 file=? name=FUN_004d2b34 */

void __cdecl FUN_004d2b34(int param_1)

{
  FUN_00436c38(param_1);
  FUN_004d2ae4(param_1);
  return;
}



/* @004d2b4c file=? name=FUN_004d2b4c */

void __cdecl FUN_004d2b4c(undefined4 *param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  
  puVar2 = (undefined4 *)(param_2 + 0x58);
  for (iVar1 = 0xc; iVar1 != 0; iVar1 = iVar1 + -1) {
    *param_1 = *puVar2;
    puVar2 = puVar2 + 1;
    param_1 = param_1 + 1;
  }
  return;
}



/* @004d2b6c file=? name=FUN_004d2b6c */

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

{
  FUN_0046739c(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0051e518;
  return param_1;
}



/* @004d2b90 file=? name=FUN_004d2b90 */

void __cdecl FUN_004d2b90(int *param_1,byte param_2)

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



/* @004d2bbc file=? name=FUN_004d2bbc */

undefined4 * FUN_004d2bbc(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x88);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004d29fc(puVar1);
  }
  return puVar1;
}



/* @004d2be0 file=? name=FUN_004d2be0 */

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

{
  FUN_0049b54c(param_1,param_2,param_3);
  *param_1 = &PTR_FUN_0051e870;
  return param_1;
}



/* @004d2c04 file=? name=FUN_004d2c04 */

void __cdecl FUN_004d2c04(int *param_1,byte param_2)

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



/* @004d2c30 file=bt_l4/btl4mssn.cpp name=FUN_004d2c30 */

void __cdecl FUN_004d2c30(int param_1,int param_2)

{
  char *pcVar1;
  uint *puVar2;
  int *piVar3;
  char *pcVar4;
  int iVar5;
  undefined3 extraout_var;
  undefined4 *puVar6;
  uint uVar7;
  undefined3 extraout_var_00;
  undefined3 extraout_var_01;
  char *pcVar8;
  bool bVar9;
  int local_a4 [5];
  int local_90 [5];
  undefined4 local_7c;
  int local_78;
  float local_74;
  int *local_70;
  int *local_6c;
  int *local_68;
  int *local_64;
  int *local_60;
  int *local_5c;
  undefined4 *local_58;
  uint *local_54;
  uint *local_50;
  uint *local_4c;
  char *local_48;
  char *local_44;
  int *local_40;
  char *local_3c;
  float local_38;
  int local_34;
  char *local_30;
  int *local_2c;
  int *local_28;
  char *local_24;
  char *local_20;
  int *local_1c;
  char *local_18;
  char *local_14;
  char *local_10;
  char *local_c;
  int *local_8;
  
  local_8 = *(int **)(*(int *)(*(int *)(DAT_004efc94 + 0x2c) + 0x14) + 0x1064);
  local_8[3] = local_8[3] + 1;
  *(undefined4 *)(param_1 + 0x2c) = 0;
  local_c = (char *)0x0;
  FUN_00404088(param_2,(char *)local_8[2],s_vehicle_0051e5b5,&local_c);
  if (local_c == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Error__vehicle_not_specified__0051e5bd,(char *)0x0);
    FUN_004036a0(1);
  }
  pcVar4 = FUN_00402300(local_c);
  *(char **)(param_1 + 0x2c) = pcVar4;
  *(undefined4 *)(param_1 + 0x28) = 0;
  local_10 = (char *)0x0;
  FUN_00404088(param_2,(char *)local_8[2],s_dropzone_0051e5dc,&local_10);
  if (local_10 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Error__dropzone_not_specified__0051e5e5,(char *)0x0);
    FUN_004036a0(1);
  }
  pcVar4 = FUN_00402300(local_10);
  *(char **)(param_1 + 0x28) = pcVar4;
  *(undefined4 *)(param_1 + 0x3c) = 0;
  FUN_004040d8(param_2,(char *)local_8[2],s_loadzones_0051e605,(int *)(param_1 + 0x3c));
  *(undefined4 *)(param_1 + 0x20) = 0;
  local_14 = (char *)0x0;
  FUN_00404088(param_2,(char *)local_8[2],s_color_0051e60f,&local_14);
  if (local_14 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Error__color_not_specified__0051e615,(char *)0x0);
    FUN_004036a0(1);
  }
  pcVar4 = FUN_00402300(local_14);
  *(char **)(param_1 + 0x20) = pcVar4;
  local_18 = (char *)0x0;
  FUN_00404088(param_2,(char *)local_8[2],s_patch_0051e632,&local_18);
  if (local_18 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Error__patch_not_specified__0051e638,(char *)0x0);
    FUN_004036a0(1);
  }
  FUN_00402a98((int *)&local_1c,(int *)(param_1 + 0xf8),local_18);
  piVar3 = local_1c + 3;
  *piVar3 = *piVar3 + -1;
  if (*piVar3 == 0) {
    FUN_004024d8(local_1c,3);
  }
  *(undefined4 *)(param_1 + 0x24) = 0;
  local_20 = (char *)0x0;
  FUN_00404088(param_2,(char *)local_8[2],s_badge_0051e655,&local_20);
  if (local_20 == (char *)0x0) {
    FUN_004dbb24(&DAT_00524e20,s_Error__badge_not_specified__0051e65b,(char *)0x0);
    FUN_004036a0(1);
  }
  pcVar4 = FUN_00402300(local_20);
  *(char **)(param_1 + 0x24) = pcVar4;
  iVar5 = FUN_00404088(param_2,(char *)local_8[2],s_badge_0051e678,&local_24);
  if (iVar5 == 0) {
    FUN_00402a98((int *)&local_2c,(int *)(param_1 + 0xec),s_DEFAULT_0051e67e);
    piVar3 = local_2c + 3;
    *piVar3 = *piVar3 + -1;
    if (*piVar3 == 0) {
      FUN_004024d8(local_2c,3);
    }
  }
  else {
    FUN_00402a98((int *)&local_28,(int *)(param_1 + 0xec),local_24);
    piVar3 = local_28 + 3;
    *piVar3 = *piVar3 + -1;
    if (*piVar3 == 0) {
      FUN_004024d8(local_28,3);
    }
  }
  local_30 = s_Unspecified_0051e686;
  iVar5 = FUN_00404088(param_2,(char *)local_8[2],s_experience_0051e692,&local_30);
  if (iVar5 == 0) {
    pcVar4 = *(char **)(param_1 + 0x2c);
    pcVar8 = s_camera_0051e69d;
    do {
      bVar9 = *pcVar4 == *pcVar8;
      if (!bVar9) break;
      if (*pcVar4 == '\0') goto LAB_004d2f3e;
      pcVar1 = pcVar4 + 1;
      bVar9 = *pcVar1 == pcVar8[1];
      if (!bVar9) break;
      pcVar4 = pcVar4 + 2;
      pcVar8 = pcVar8 + 2;
      bVar9 = *pcVar1 == '\0';
    } while (!bVar9);
    if (!bVar9) {
      FUN_004dbb24((int *)&DAT_00524e68,(char *)local_8[2],(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_page_missing_expereince__0051e6a4,(char *)0x0);
      FUN_004d9c38((int *)&DAT_00524e68);
      FUN_0040385c(s_Exiting_0051e6be,s_d__tesla_bt_bt_l4_BTL4MSSN_CPP_0051e6c6,0xf0);
      goto LAB_004d3052;
    }
  }
LAB_004d2f3e:
  pcVar8 = s_Unspecified_0051e6e5;
  pcVar4 = local_30;
  do {
    if (*pcVar8 != *pcVar4) goto LAB_004d2f68;
    bVar9 = true;
    if (*pcVar8 == '\0') break;
    pcVar1 = pcVar8 + 1;
    if (*pcVar1 != pcVar4[1]) goto LAB_004d2f68;
    pcVar8 = pcVar8 + 2;
    pcVar4 = pcVar4 + 2;
    bVar9 = *pcVar1 == '\0';
  } while (!bVar9);
  if (!bVar9) {
LAB_004d2f68:
    iVar5 = FUN_004d4b58(local_30,s_novice_0051e6f1);
    if (iVar5 == 0) {
      *(undefined4 *)(param_1 + 0xe4) = 0;
    }
    else {
      iVar5 = FUN_004d4b58(local_30,s_standard_0051e6f8);
      if (iVar5 == 0) {
        *(undefined4 *)(param_1 + 0xe4) = 1;
      }
      else {
        iVar5 = FUN_004d4b58(local_30,s_veteran_0051e701);
        if (iVar5 == 0) {
          *(undefined4 *)(param_1 + 0xe4) = 2;
        }
        else {
          iVar5 = FUN_004d4b58(local_30,s_expert_0051e709);
          pcVar4 = local_30;
          if (iVar5 == 0) {
            *(undefined4 *)(param_1 + 0xe4) = 3;
          }
          else {
            FUN_004dbb24((int *)&DAT_00524e68,(char *)local_8[2],(char *)0x0);
            FUN_004dbb24((int *)&DAT_00524e68,s_has_an_unknown_experience_field_o_0051e710,
                         (char *)0x0);
            FUN_004dbb24((int *)&DAT_00524e68,pcVar4,(char *)0x0);
            FUN_004d9c38((int *)&DAT_00524e68);
            FUN_0040385c(s_Exiting_0051e735,s_d__tesla_bt_bt_l4_BTL4MSSN_CPP_0051e73d,0x108);
          }
        }
      }
    }
  }
LAB_004d3052:
  local_34 = 0;
  bVar9 = FUN_004040d8(param_2,(char *)local_8[2],s_advancedDamage_0051e75c,&local_34);
  if (CONCAT31(extraout_var,bVar9) != 0) {
    if (local_34 == 0) {
      *(undefined4 *)(param_1 + 0xf0) = 0;
    }
    else {
      *(undefined4 *)(param_1 + 0xf0) = 1;
    }
  }
  iVar5 = FUN_00404088(param_2,(char *)local_8[2],&DAT_0051e76b,&local_3c);
  if (iVar5 == 0) {
    FUN_004dbb24((int *)&DAT_00524e68,s_Each_Player_page_must_have_a_rol_0051e7fd,(char *)0x0);
    FUN_004d9c38((int *)&DAT_00524e68);
    FUN_0040385c(s_Exiting_0051e827,s_d__tesla_bt_bt_l4_BTL4MSSN_CPP_0051e82f,0x1c3);
  }
  else {
    FUN_00402a98((int *)&local_40,(int *)(param_1 + 0xe8),local_3c);
    piVar3 = local_40 + 3;
    *piVar3 = *piVar3 + -1;
    if (*piVar3 == 0) {
      FUN_004024d8(local_40,3);
    }
    iVar5 = FUN_00404088(param_2,local_3c,s_model_0051e770,&local_44);
    if (iVar5 == 0) {
      FUN_004dbb24((int *)&DAT_00524e68,local_3c,(char *)0x0);
      FUN_004dbb24((int *)&DAT_00524e68,s_page_or_model_field_missing___0051e7b7,(char *)0x0);
      FUN_004d9c38((int *)&DAT_00524e68);
      FUN_0040385c(s_Exiting_0051e7d6,s_d__tesla_bt_bt_l4_BTL4MSSN_CPP_0051e7de,0x1bd);
    }
    else {
      FUN_004323c7(local_90,param_1 + 0x50);
      puVar6 = (undefined4 *)(**(code **)(local_90[0] + 0x54))(local_90,param_1 + 0xe8);
      FUN_00432405(local_90,2);
      if (puVar6 == (undefined4 *)0x0) {
        puVar6 = (undefined4 *)FUN_00402298(0x2c);
        if (puVar6 == (undefined4 *)0x0) {
          puVar6 = (undefined4 *)0x0;
        }
        else {
          local_48 = local_44;
          local_50 = (uint *)FUN_00402298(0x10);
          if (local_50 == (uint *)0x0) {
            local_4c = (uint *)0x0;
          }
          else {
            local_4c = FUN_00402460(local_50,local_48);
          }
          local_4c[3] = local_4c[3] + 1;
          puVar6 = FUN_00429a9c(puVar6,(int *)(param_1 + 0xe8),(int *)&local_4c);
        }
        local_54 = local_4c;
        puVar2 = local_4c + 3;
        *puVar2 = *puVar2 - 1;
        if (*puVar2 == 0) {
          FUN_004024d8((int *)local_4c,3);
        }
        local_5c = puVar6 + 9;
        local_60 = (int *)*local_5c;
        local_60[3] = local_60[3] + 1;
        local_58 = puVar6;
        FUN_004323c7(local_a4,param_1 + 0x50);
        iVar5 = (**(code **)(local_a4[0] + 0x54))(local_a4,&local_60);
        FUN_00432405(local_a4,2);
        uVar7 = (uint)(iVar5 == 0);
        local_64 = local_60;
        piVar3 = local_60 + 3;
        *piVar3 = *piVar3 + -1;
        if (*piVar3 == 0) {
          FUN_004024d8(local_60,3);
        }
        if (uVar7 != 0) {
          local_68 = local_58 + 9;
          local_6c = (int *)*local_68;
          local_6c[3] = local_6c[3] + 1;
          (**(code **)(*(int *)(param_1 + 0x50) + 8))(param_1 + 0x50,local_58,&local_6c);
          local_70 = local_6c;
          piVar3 = local_6c + 3;
          *piVar3 = *piVar3 + -1;
          if (*piVar3 == 0) {
            FUN_004024d8(local_6c,3);
          }
        }
      }
      iVar5 = FUN_00404118(param_2,local_3c,s_dmgInflctdMdfr_0051e776,&local_38);
      if (iVar5 != 0) {
        puVar6[3] = local_38;
      }
      iVar5 = FUN_00404118(param_2,local_3c,s_dmgRcvdMdfr_0051e785,&local_38);
      if (iVar5 != 0) {
        local_74 = local_38;
        puVar6[4] = local_38;
      }
      iVar5 = FUN_00404118(param_2,local_3c,s_dmgBias_0051e791,&local_38);
      if (iVar5 != 0) {
        puVar6[6] = local_38;
      }
      iVar5 = FUN_00404118(param_2,local_3c,s_friendlyFire_0051e799,&local_38);
      if (iVar5 != 0) {
        puVar6[5] = local_38;
      }
      bVar9 = FUN_004040d8(param_2,local_3c,s_return_0051e7a6,&local_78);
      if (CONCAT31(extraout_var_00,bVar9) != 0) {
        puVar6[10] = local_78;
      }
      iVar5 = FUN_00404118(param_2,local_3c,s_killBonus_0051e7ad,&local_38);
      if (iVar5 != 0) {
        puVar6[7] = local_38;
      }
    }
  }
  bVar9 = FUN_004040d8(param_2,(char *)local_8[2],s_bitmapindex_0051e84e,(int *)(param_1 + 0x4c));
  if (CONCAT31(extraout_var_01,bVar9) == 0) {
    FUN_004dbb24(&DAT_00524e20,s_No_Bitmap_for_player_0051e85a,(char *)0x0);
    FUN_004dbb24(&DAT_00524e20,(char *)local_8[2],(char *)0x0);
    FUN_004d9c38(&DAT_00524e20);
  }
  else {
    local_7c = *(undefined4 *)(param_1 + 0x4c);
    iVar5 = (**(code **)(*(int *)(param_1 + 0x68) + 0xc))(param_1 + 0x68,&local_7c);
    if (((iVar5 != 0) && (*(int *)(DAT_004efc94 + 0x4c) != 0)) &&
       (piVar3 = *(int **)(*(int *)(DAT_004efc94 + 0x4c) + 0x1c530), piVar3 != (int *)0x0)) {
      (**(code **)(*piVar3 + 0x28))
                (piVar3,1,0,0xff,0,0,0,0,iVar5,0,0,*(int *)(iVar5 + 0xc) + -1,
                 *(int *)(iVar5 + 0x10) + -1);
      (**(code **)(*piVar3 + 8))(piVar3,1);
      (**(code **)(*piVar3 + 0xc))(piVar3);
    }
  }
  piVar3 = local_8 + 3;
  *piVar3 = *piVar3 + -1;
  if (*piVar3 == 0) {
    FUN_004024d8(local_8,3);
  }
  return;
}



/* @004d34b0 file=? name=FUN_004d34b0 */

undefined4 FUN_004d34b0(void)

{
  FUN_0044d828();
  return 1;
}



/* @004d34c4 file=? name=FUN_004d34c4 */

undefined4 * __cdecl
FUN_004d34c4(undefined4 *param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)

{
  FUN_0047b410(param_1,param_2,1,param_3,param_4);
  *param_1 = &PTR_FUN_0051ed9c;
  FUN_004dbb24(&DAT_00524e20,s_BTL4Application__BTL4Application_0051ebd6,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  return param_1;
}



/* @004d350c file=? name=FUN_004d350c */

void __cdecl FUN_004d350c(int *param_1,byte param_2)

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



/* @004d3538 file=? name=FUN_004d3538 */

undefined4 * FUN_004d3538(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004c1548(puVar1);
  }
  return puVar1;
}



/* @004d3564 file=? name=FUN_004d3564 */

undefined4 * __cdecl FUN_004d3564(int param_1)

{
  undefined4 *puVar1;
  
  if (*(int *)(param_1 + 0xd0) == 0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = (undefined4 *)FUN_00402298(0x3e0);
    if (puVar1 == (undefined4 *)0x0) {
      return (undefined4 *)0x0;
    }
    puVar1 = FUN_004ceecc(puVar1,DAT_004e8238,DAT_004e823c,1,0,1);
  }
  return puVar1;
}



/* @004d35b0 file=? name=FUN_004d35b0 */

undefined4 * __cdecl FUN_004d35b0(int param_1)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  float10 fVar4;
  undefined4 uVar5;
  
  iVar1 = FUN_004dee74(s_AWE_FRONT_0051ec1e);
  iVar2 = FUN_004dee74(s_AWE_REAR_0051ec28);
  if ((iVar1 == 0) || (iVar2 == 0)) {
    puVar3 = (undefined4 *)0x0;
  }
  else {
    puVar3 = (undefined4 *)FUN_00402298(0x1b0);
    if (puVar3 == (undefined4 *)0x0) {
      puVar3 = (undefined4 *)0x0;
    }
    else {
      uVar5 = DAT_004fd550;
      fVar4 = FUN_0044e19c(param_1);
      puVar3 = FUN_004d2b6c(puVar3,(float)fVar4,uVar5);
    }
  }
  return puVar3;
}



/* @004d3614 file=? name=FUN_004d3614 */

undefined4 * FUN_004d3614(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0xc);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0044c2d0(puVar1,0x50421);
    *puVar1 = &PTR_LAB_0051ed98;
  }
  return puVar1;
}



/* @004d3644 file=? name=FUN_004d3644 */

undefined4 * __cdecl FUN_004d3644(undefined4 param_1)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0xd10);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_00475c18(puVar1);
  }
  (**(code **)(puVar1[0x68] + 0x14))(puVar1 + 0x68,0xffffffff,param_1,7,param_1);
  return puVar1;
}



/* @004d368c file=? name=FUN_004d368c */

int * FUN_004d368c(void)

{
  int iVar1;
  int *piVar2;
  
  iVar1 = FUN_004dee74(s_L4GAUGE_0051ec31);
  if (iVar1 == 0) {
    piVar2 = (int *)0x0;
  }
  else {
    piVar2 = (int *)FUN_00402298(0x1c53c);
    if (piVar2 == (int *)0x0) {
      return (int *)0x0;
    }
    piVar2 = FUN_004cbea0(piVar2);
  }
  return piVar2;
}



/* @004d36c4 file=? name=FUN_004d36c4 */

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

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0xfc);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004d2be0(puVar1,param_2,param_3);
  }
  return puVar1;
}



/* @004d36f4 file=bt_l4/btl4app.cpp name=FUN_004d36f4 */

int * __cdecl FUN_004d36f4(int param_1,int param_2)

{
  int iVar1;
  uint *puVar2;
  undefined4 *puVar3;
  int iVar4;
  int *piVar5;
  char *pcVar6;
  char *pcVar7;
  undefined4 uVar8;
  undefined *puVar9;
  char local_60 [2];
  char acStack_5e [30];
  undefined4 local_40;
  undefined4 local_3c;
  int *local_30;
  uint *local_2c;
  undefined4 *local_28;
  uint *local_24;
  undefined4 *local_20;
  int *local_1c;
  undefined4 *local_18;
  undefined4 *local_14;
  undefined4 *local_10;
  int *local_c;
  char *local_8;
  
  piVar5 = (int *)0x0;
  iVar1 = *(int *)(param_1 + 0x3c);
  local_8 = (char *)0x0;
  if (*(int *)(param_2 + 0x1c) == 0x45) {
    piVar5 = FUN_0042d16c(param_2);
    pcVar6 = s_ControlsMapper_0051ec39;
    pcVar7 = local_60;
    local_c = piVar5;
    for (iVar4 = 3; iVar4 != 0; iVar4 = iVar4 + -1) {
      *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
      pcVar6 = pcVar6 + 4;
      pcVar7 = pcVar7 + 4;
    }
    *(undefined2 *)pcVar7 = *(undefined2 *)pcVar6;
    pcVar7[2] = pcVar6[2];
    local_40 = 0xf;
    local_3c = 0x30;
    if (*(int *)(iVar1 + 0xc98) == 2) {
      local_10 = (undefined4 *)FUN_00402298(0x110);
      if (local_10 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar3 = FUN_0047ac5c(local_10,local_c,0,local_60,&DAT_004fd318);
      }
      local_8 = s_Thrustmaster_0051ec48;
    }
    else if (*(int *)(iVar1 + 0xc98) == 4) {
      local_14 = (undefined4 *)FUN_00402298(0x108);
      if (local_14 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar3 = FUN_0047ad3c(local_14,local_c,0,local_60,&DAT_004fd364);
      }
      local_8 = &DAT_0051ec55;
    }
    else {
      local_18 = (undefined4 *)FUN_00402298(0x108);
      if (local_18 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar3 = FUN_0047aa78(local_18,local_c,0,local_60,&DAT_004fd2b0);
      }
    }
    FUN_0042c630((int)local_c,puVar3);
  }
  else if (*(int *)(param_2 + 0x1c) == 0xbb9) {
    piVar5 = FUN_004a2d48(param_2);
    local_1c = piVar5;
    FUN_00476eac(iVar1,0.05);
    FUN_00476eec(iVar1,0.05);
    FUN_00476f10(iVar1,0.05);
    if (*(int *)(iVar1 + 0xc98) == 2) {
      local_20 = (undefined4 *)FUN_00402298(0x1bc);
      if (local_20 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar9 = &DAT_0051dc68;
        uVar8 = 0x7dc;
        local_24 = (uint *)FUN_00402298(0x10);
        if (local_24 == (uint *)0x0) {
          puVar2 = (uint *)0x0;
        }
        else {
          puVar2 = FUN_00402460(local_24,s_ControlsMapper_0051ec58);
        }
        puVar2[3] = puVar2[3] + 1;
        puVar3 = FUN_004d21d0(local_20,local_1c,0,(int *)puVar2,uVar8,puVar9);
      }
      local_8 = s_Thrustmaster_0051ec67;
    }
    else if (*(int *)(iVar1 + 0xc98) == 4) {
      local_28 = (undefined4 *)FUN_00402298(0x1bc);
      if (local_28 == (undefined4 *)0x0) {
        puVar3 = (undefined4 *)0x0;
      }
      else {
        puVar9 = &DAT_0051dcf0;
        uVar8 = 0x7dc;
        local_2c = (uint *)FUN_00402298(0x10);
        if (local_2c == (uint *)0x0) {
          puVar2 = (uint *)0x0;
        }
        else {
          puVar2 = FUN_00402460(local_2c,s_ControlsMapper_0051ec74);
        }
        puVar2[3] = puVar2[3] + 1;
        puVar3 = FUN_004d266c(local_28,local_1c,0,(int *)puVar2,uVar8,puVar9);
      }
      local_8 = &DAT_0051ec83;
    }
    else {
      FUN_004dbb24(&DAT_00524e20,s______Mech_has_no_controls_mappin_0051ec86,(char *)0x0);
      FUN_0040385c(s_BTL4Application__MakeViewpointEn_0051ecae,
                   s_d__tesla_bt_bt_l4_BTL4APP_CPP_0051ecd3,400);
      puVar3 = (undefined4 *)0x0;
    }
    FUN_0049fe40((int)local_1c,puVar3);
    (**(code **)(*local_1c + 0x38))(local_1c);
  }
  if (((local_8 != (char *)0x0) &&
      (local_30 = (int *)FUN_00407064(*(int *)(DAT_004efc94 + 0x68),piVar5[0x6f],6),
      local_30 != (int *)0x0)) &&
     (local_30 = (int *)FUN_004070dc(*(int *)(param_1 + 0x68),*local_30,local_8),
     local_30 != (int *)0x0)) {
    iVar4 = local_30[1];
    local_30[1] = local_30[1] + 1;
    if (iVar4 == 0) {
      FUN_00406cd0((int)local_30);
    }
    FUN_0047703c(iVar1,(int)piVar5,(int *)local_30[0xf]);
    local_30[1] = local_30[1] + -1;
  }
  if (*(int **)(param_1 + 0x4c) != (int *)0x0) {
    FUN_0046ff64(*(int **)(param_1 + 0x4c),&DAT_0051ecf1,piVar5);
  }
  return piVar5;
}



/* @004d3a2c file=? name=FUN_004d3a2c */

void __cdecl FUN_004d3a2c(int param_1)

{
  int iVar1;
  
  FUN_004dbb24(&DAT_00524e20,s_BTL4Application__RunMissionMessa_0051ecf6,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  iVar1 = *(int *)(param_1 + 0x50);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) | 0x400000;
  FUN_004dbb24(&DAT_00524e20,s_Turning_Plasma_Score_Display_On_0051ed20,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  FUN_0047b788(param_1);
  return;
}



/* @004d3a94 file=? name=FUN_004d3a94 */

void __cdecl FUN_004d3a94(int param_1)

{
  int iVar1;
  
  iVar1 = *(int *)(param_1 + 0x50);
  *(undefined4 *)(iVar1 + 8) = *(undefined4 *)(iVar1 + 4);
  *(uint *)(iVar1 + 4) = *(uint *)(iVar1 + 4) & 0xffbfffff;
  FUN_0047b864(param_1);
  FUN_004dbb24(&DAT_00524e20,s_Turning_Plasma_Score_Display_Off_0051ed40,(char *)0x0);
  FUN_004d9c38(&DAT_00524e20);
  return;
}



/* @004d3b74 file=? name=FUN_004d3b74 */

undefined4 * __cdecl FUN_004d3b74(undefined4 *param_1)

{
  FUN_0047c5d8(param_1);
  *param_1 = &PTR_FUN_0051f204;
  return param_1;
}



/* @004d3b90 file=? name=FUN_004d3b90 */

void __cdecl FUN_004d3b90(undefined4 param_1,uint *param_2)

{
  FUN_004d3ecc(DAT_004efc94,param_2);
  return;
}



/* @004d3bb8 file=? name=FUN_004d3bb8 */

void __cdecl FUN_004d3bb8(int *param_1,byte param_2)

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



/* @004d3be4 file=? name=FUN_004d3be4 */

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

{
  FUN_004d34c4(param_1,param_2,0x3eb,&DAT_0051ee5c);
  *param_1 = &PTR_FUN_0051f1a4;
  param_1[6] = param_3;
  return param_1;
}



/* @004d3c14 file=? name=FUN_004d3c14 */

undefined4 * FUN_004d3c14(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x28);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0047bfc4(puVar1);
  }
  return puVar1;
}



/* @004d3c34 file=? name=FUN_004d3c34 */

void __cdecl FUN_004d3c34(int *param_1)

{
  FUN_0047b468(param_1);
  return;
}



/* @004d3c44 file=? name=FUN_004d3c44 */

void __cdecl FUN_004d3c44(int param_1)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_004d3b74(puVar1);
  }
  FUN_0044de1c(*(int *)(param_1 + 100),puVar1);
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0044dd08(puVar1,0x48);
    *puVar1 = &PTR_FUN_004f037c;
  }
  FUN_0044de1c(*(int *)(param_1 + 100),puVar1);
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0044dd08(puVar1,0x48);
    *puVar1 = &PTR_FUN_004f031c;
  }
  FUN_0044de1c(*(int *)(param_1 + 100),puVar1);
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0044dd08(puVar1,0x48);
    *puVar1 = &PTR_FUN_004f0304;
  }
  FUN_0044de1c(*(int *)(param_1 + 100),puVar1);
  puVar1 = (undefined4 *)FUN_00402298(0x10);
  if (puVar1 != (undefined4 *)0x0) {
    FUN_0044dd08(puVar1,0x48);
    *puVar1 = &PTR_FUN_004f0364;
  }
  FUN_0044de1c(*(int *)(param_1 + 100),puVar1);
  return;
}



/* @004d3d40 file=? name=FUN_004d3d40 */

undefined4 __cdecl FUN_004d3d40(int param_1,int param_2)

{
  undefined4 uVar1;
  int *piVar2;
  
  if ((*(int *)(param_1 + 0x70) == 0) || (*(int *)(param_1 + 0x88) == 1)) {
    if ((*(int *)(param_1 + 0x70) == 0) || (DAT_004efc98 != 0)) {
      uVar1 = 0;
    }
    else {
      uVar1 = 1;
    }
  }
  else {
    FUN_004dcd94();
    if (DAT_004fd550 == 2) {
      (**(code **)(**(int **)(param_1 + 0x3c) + 0x18))(*(int **)(param_1 + 0x3c));
    }
    FUN_00435794(*(int *)(param_1 + 0x34));
    FUN_004363ec(*(int *)(param_1 + 0x38),param_2);
    FUN_00434a08();
    FUN_0043649c(*(int *)(param_1 + 0x38));
    FUN_00436440(*(int *)(param_1 + 0x38),param_2);
    (**(code **)(**(int **)(param_1 + 0x40) + 0x24))(*(int **)(param_1 + 0x40));
    if (*(int *)(param_1 + 0x88) == 5) {
      piVar2 = (int *)FUN_00414b60();
      *(float *)(param_1 + 0x58) =
           *(float *)(*(int *)(param_1 + 200) + 0xe0) -
           (float)(*piVar2 - *(int *)(param_1 + 0x5c)) / DAT_0052140c;
    }
    if ((*(int *)(param_1 + 0x70) == 0) || (DAT_004efc98 != 0)) {
      uVar1 = 0;
    }
    else {
      uVar1 = 1;
    }
  }
  return uVar1;
}



/* @004d3ea0 file=? name=FUN_004d3ea0 */

void __cdecl FUN_004d3ea0(int *param_1,byte param_2)

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



/* @004d3ecc file=? name=FUN_004d3ecc */

void __cdecl FUN_004d3ecc(int param_1,uint *param_2)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_0041d7f0(*(int *)(param_1 + 0x20),*param_2);
  (**(code **)(*piVar1 + 0x14))(piVar1,param_2,param_2 + 4);
  return;
}



/* @004d3ef8 file=? name=FUN_004d3ef8 */

void __cdecl FUN_004d3ef8(int param_1)

{
  int *piVar1;
  int iVar2;
  int *piVar3;
  
  if (*(int *)(param_1 + 0x88) == 3) {
    piVar1 = *(int **)(param_1 + 0x18);
    iVar2 = (**(code **)*piVar1)(piVar1);
    piVar3 = (int *)FUN_00414b60();
    *(int *)(param_1 + 0xd4) = *piVar3 - *(int *)(iVar2 + 0xc);
    FUN_0044f850(piVar1);
  }
  FUN_004d3a2c(param_1);
  return;
}



/* @004d3f44 file=? name=FUN_004d3f44 */

void __cdecl FUN_004d3f44(int param_1)

{
  char *pcVar1;
  int *piVar2;
  int iVar3;
  char *pcVar4;
  int iVar5;
  int iVar6;
  char *pcVar7;
  bool bVar8;
  uint local_30 [5];
  int local_1c [3];
  int local_10;
  char *local_c;
  int local_8;
  
  iVar3 = FUN_0044e13c(param_1);
  if (*(int **)(param_1 + 0x18) != (int *)0x0) {
    FUN_0044fac0(iVar3,*(int **)(param_1 + 0x18));
    *(undefined4 *)(param_1 + 0x18) = 0;
    local_8 = FUN_00403ad0(*(int *)(DAT_004efc94 + 0x24) + 0x18,s_DropZones_0051f19a);
    local_c = &DAT_0051ee67;
    iVar3 = 0;
    while( true ) {
      iVar6 = FUN_0042efe4(iVar3);
      if (iVar6 == 0) break;
      *local_c = (char)iVar3 + '1';
      FUN_00421414(local_1c,local_8 + 0x10);
LAB_004d3fea:
      do {
        iVar5 = (**(code **)(local_1c[0] + 0x28))(local_1c);
        if (iVar5 == 0) break;
        pcVar4 = (char *)(iVar5 + 0x1c8);
        pcVar7 = &DAT_0051ee64;
        do {
          if (*pcVar4 != *pcVar7) goto LAB_004d3fea;
          bVar8 = true;
          if (*pcVar4 == '\0') break;
          pcVar1 = pcVar4 + 1;
          if (*pcVar1 != pcVar7[1]) goto LAB_004d3fea;
          pcVar4 = pcVar4 + 2;
          pcVar7 = pcVar7 + 2;
          bVar8 = *pcVar1 == '\0';
        } while (!bVar8);
      } while (!bVar8);
      if (iVar5 == 0) {
        FUN_00421452(local_1c,2);
      }
      else {
        piVar2 = *(int **)(iVar6 + 0x1fc);
        if (piVar2[1] == 0xbb9) {
          FUN_0049fb74((int)piVar2,(undefined4 *)(iVar5 + 0x100),0);
          piVar2[7] = (int)PTR_FUN_0051ee69;
          piVar2[8] = DAT_0051ee6d;
          piVar2[9] = DAT_0051ee71;
          FUN_00419cb8((int)piVar2);
          local_10 = *(int *)(DAT_004efc94 + 0x38);
          FUN_00436668(local_30,(int)piVar2);
          FUN_004364e4(local_10,piVar2,local_30);
        }
        FUN_00421452(local_1c,2);
      }
      iVar3 = iVar3 + 1;
    }
    iVar3 = *(int *)(param_1 + 0x48);
    FUN_00460840(iVar3);
    FUN_0045a7a8(iVar3,4);
  }
  FUN_004d3a94(param_1);
  return;
}



/* @004d40d8 file=? name=FUN_004d40d8 */

void __cdecl FUN_004d40d8(int param_1)

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



/* @004d4179 file=? name=FUN_004d4179 */

undefined2 FUN_004d4179(void)

{
  code *pcVar1;
  undefined2 uVar2;
  
  pcVar1 = (code *)swi(0x11);
  uVar2 = (*pcVar1)();
  return uVar2;
}



/* @004d4183 file=? name=FUN_004d4183 */

undefined2 FUN_004d4183(void)

{
  code *pcVar1;
  undefined2 uVar2;
  
  pcVar1 = (code *)swi(0x12);
  uVar2 = (*pcVar1)();
  return uVar2;
}



/* @004d418d file=? name=FUN_004d418d */

undefined4 FUN_004d418d(void)

{
  code *pcVar1;
  undefined2 extraout_CX;
  undefined2 extraout_DX;
  
  pcVar1 = (code *)swi(0x1a);
  (*pcVar1)();
  return CONCAT22(extraout_CX,extraout_DX);
}



/* @004d45b0 file=? name=FUN_004d45b0 */

undefined4 FUN_004d45b0(void)

{
  undefined4 in_EAX;
  
  LOCK();
  UNLOCK();
  return in_EAX;
}



/* @004d45c6 file=? name=FUN_004d45c6 */

undefined2 __cdecl FUN_004d45c6(undefined2 param_1)

{
  undefined2 uVar1;
  
  uVar1 = in(param_1);
  return uVar1;
}



/* @004d45d3 file=? name=FUN_004d45d3 */

undefined1 __cdecl FUN_004d45d3(undefined2 param_1)

{
  undefined1 uVar1;
  
  uVar1 = in(param_1);
  return uVar1;
}



/* @004d45df file=? name=FUN_004d45df */

undefined2 __cdecl FUN_004d45df(undefined2 param_1)

{
  undefined2 uVar1;
  
  uVar1 = in(param_1);
  return uVar1;
}



/* @004d45ec file=? name=FUN_004d45ec */

undefined1 __cdecl FUN_004d45ec(undefined2 param_1)

{
  undefined1 uVar1;
  
  uVar1 = in(param_1);
  return uVar1;
}



/* @004d461f file=? name=FUN_004d461f */

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

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

{
  undefined4 uVar1;
  undefined4 uVar2;
  uint uVar3;
  undefined4 uVar4;
  undefined4 extraout_ECX;
  undefined4 extraout_EDX;
  undefined2 uVar5;
  undefined2 uVar6;
  undefined2 uVar7;
  undefined2 uVar8;
  byte bVar9;
  byte in_PF;
  byte in_AF;
  byte in_ZF;
  byte in_SF;
  byte in_TF;
  byte in_IF;
  byte in_OF;
  byte in_NT;
  byte in_AC;
  byte in_VIF;
  byte in_VIP;
  byte in_ID;
  
  uVar5 = *param_4;
  uVar7 = param_4[4];
  uVar8 = param_4[5];
  uVar6 = param_4[3];
  uVar1 = *(undefined4 *)(param_2 + 4);
  uVar2 = *(undefined4 *)(param_2 + 0x14);
  bVar9 = 0;
  uVar4 = FUN_004d45b0();
  uVar3 = (uint)(bVar9 & 1);
  *param_3 = uVar4;
  param_3[1] = uVar1;
  param_3[2] = extraout_ECX;
  param_3[3] = extraout_EDX;
  param_3[4] = param_3;
  param_3[5] = uVar2;
  param_3[7] = (uint)(in_NT & 1) * 0x4000 | (uint)(in_OF & 1) * 0x800 | (uint)(in_IF & 1) * 0x200 |
               (uint)(in_TF & 1) * 0x100 | (uint)(in_SF & 1) * 0x80 | (uint)(in_ZF & 1) * 0x40 |
               (uint)(in_AF & 1) * 0x10 | (uint)(in_PF & 1) * 4 | uVar3 |
               (uint)(in_ID & 1) * 0x200000 | (uint)(in_VIP & 1) * 0x100000 |
               (uint)(in_VIF & 1) * 0x80000 | (uint)(in_AC & 1) * 0x40000;
  param_3[6] = uVar3;
  *param_4 = uVar5;
  param_4[3] = uVar6;
  param_4[4] = uVar7;
  param_4[5] = uVar8;
  if (uVar3 == 0) {
    DAT_00520bcc = uVar4;
    _DAT_00524dd0 = uVar4;
  }
  return;
}



/* @004d46a5 file=? name=FUN_004d46a5 */

void FUN_004d46a5(void)

{
  if (DAT_00525224 != 2) {
    FUN_004ded48(s_This_DPMI32_module_cannot_be_run_0051f224);
  }
  return;
}



/* @004d46c0 file=? name=FUN_004d46c0 */

undefined2 __cdecl FUN_004d46c0(undefined2 param_1,undefined2 param_2)

{
  out(param_1,param_2);
  return param_2;
}



/* @004d46cf file=? name=FUN_004d46cf */

undefined1 __cdecl FUN_004d46cf(undefined2 param_1,undefined1 param_2)

{
  out(param_1,param_2);
  return param_2;
}



/* @004d46dc file=? name=FUN_004d46dc */

undefined6 __cdecl FUN_004d46dc(undefined2 param_1,ushort param_2)

{
  out(param_1,param_2);
  return CONCAT24(param_1,(uint)param_2);
}



/* @004d46ed file=? name=FUN_004d46ed */

undefined6 __cdecl FUN_004d46ed(undefined2 param_1,byte param_2)

{
  out(param_1,param_2);
  return CONCAT24(param_1,(uint)param_2);
}



/* @004d46fc file=? name=FUN_004d46fc */

void __cdecl FUN_004d46fc(undefined2 *param_1)

{
  undefined2 in_ES;
  undefined2 in_CS;
  undefined2 in_SS;
  undefined2 in_DS;
  undefined2 in_FS;
  undefined2 in_GS;
  
  *param_1 = in_ES;
  param_1[1] = in_CS;
  param_1[2] = in_SS;
  param_1[3] = in_DS;
  param_1[4] = in_FS;
  param_1[5] = in_GS;
  return;
}



/* @004d4718 file=? name=FUN_004d4718 */

uint FUN_004d4718(void)

{
  HANDLE hConsoleHandle;
  BOOL BVar1;
  uint uVar2;
  short *psVar3;
  DWORD DStack_28;
  uint local_24;
  _INPUT_RECORD local_20;
  
  uVar2 = DAT_0051f5d8;
  if (DAT_0051f5dc == '\0') {
    if (DAT_0051f5d8 == 0xffffffff) {
      hConsoleHandle = GetStdHandle(0xfffffff6);
      BVar1 = GetConsoleMode(hConsoleHandle,&local_24);
      if (BVar1 == 1) {
        if (((local_24 & 7) == 0) ||
           (BVar1 = SetConsoleMode(hConsoleHandle,local_24 & 0xfffffff8), BVar1 == 1)) {
          do {
            do {
              do {
                BVar1 = ReadConsoleInputA(hConsoleHandle,&local_20,1,&DStack_28);
                if (BVar1 != 1) {
                  uVar2 = 0xffffffff;
                  goto LAB_004d483d;
                }
              } while (local_20.Event.KeyEvent.bKeyDown == 0);
              uVar2 = (uint)local_20.Event.KeyEvent.wVirtualKeyCode;
              for (psVar3 = &DAT_0051f254; (uVar2 != (int)*psVar3 && (*psVar3 != -1));
                  psVar3 = psVar3 + 5) {
              }
            } while (*psVar3 == -1);
            if ((local_20.Event.KeyEvent.dwControlKeyState & 3) == 0) {
              if ((local_20.Event.KeyEvent.dwControlKeyState & 0xc) == 0) {
                if ((local_20.Event.KeyEvent.dwControlKeyState & 0x10) == 0) {
                  if ((uVar2 < 0x41) || (0x5a < uVar2)) {
                    uVar2 = (uint)psVar3[1];
                  }
                  else {
                    uVar2 = (uint)(char)local_20.Event.MouseEvent.dwControlKeyState._2_1_;
                  }
                }
                else {
                  uVar2 = (uint)psVar3[2];
                }
              }
              else {
                uVar2 = (uint)psVar3[3];
              }
            }
            else {
              uVar2 = (uint)psVar3[4];
            }
          } while (uVar2 == 0xffffffff);
          if ((uVar2 & 0x100) != 0) {
            DAT_0051f5d8 = uVar2 & 0xff;
            uVar2 = 0;
          }
LAB_004d483d:
          if (((local_24 & 7) != 0) && (BVar1 = SetConsoleMode(hConsoleHandle,local_24), BVar1 != 1)
             ) {
            uVar2 = 0xffffffff;
          }
        }
        else {
          uVar2 = 0xffffffff;
        }
      }
      else {
        uVar2 = 0xffffffff;
      }
    }
    else {
      DAT_0051f5d8 = 0xffffffff;
    }
  }
  else {
    DAT_0051f5dc = '\0';
    uVar2 = (uint)DAT_0051f5dd;
  }
  return uVar2;
}



/* @004d4860 file=? name=FUN_004d4860 */

uint __cdecl FUN_004d4860(byte param_1)

{
  if (DAT_0051f5dc != '\0') {
    return 0xffffffff;
  }
  DAT_0051f5dc = 1;
  DAT_0051f5dd = param_1;
  return (uint)param_1;
}



/* @004d4888 file=? name=FUN_004d4888 */

undefined4 FUN_004d4888(void)

{
  undefined4 uVar1;
  HANDLE hConsoleInput;
  BOOL BVar2;
  DWORD DStack_24;
  DWORD local_20;
  _INPUT_RECORD local_1c;
  
  if (DAT_0051f5dc == '\0') {
    hConsoleInput = GetStdHandle(0xfffffff6);
    do {
      BVar2 = GetNumberOfConsoleInputEvents(hConsoleInput,&local_20);
      if (((BVar2 != 1) || (local_20 == 0)) ||
         (BVar2 = PeekConsoleInputA(hConsoleInput,&local_1c,1,&DStack_24), BVar2 != 1)) break;
      if ((((byte)local_1c.EventType & 1) != 0) && (local_1c.Event.KeyEvent.bKeyDown != 0)) {
        return 1;
      }
      BVar2 = ReadConsoleInputA(hConsoleInput,&local_1c,1,&DStack_24);
    } while (BVar2 == 1);
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @004d48f8 file=? name=FUN_004d48f8 */

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

{
  char *pcVar1;
  undefined1 in_ZF;
  
  if (param_3 != 0) {
    do {
      pcVar1 = param_1;
      if (param_3 == 0) break;
      param_3 = param_3 + -1;
      pcVar1 = param_1 + 1;
      in_ZF = param_2 == *param_1;
      param_1 = pcVar1;
    } while (!(bool)in_ZF);
    if ((bool)in_ZF) {
      return pcVar1 + -1;
    }
  }
  return (char *)0x0;
}



/* @004d4918 file=? name=FUN_004d4918 */

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

{
  uint uVar1;
  undefined4 *puVar2;
  
  puVar2 = param_1;
  for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {
    *puVar2 = *param_2;
    param_2 = param_2 + 1;
    puVar2 = puVar2 + 1;
  }
  for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {
    *(undefined1 *)puVar2 = *(undefined1 *)param_2;
    param_2 = (undefined4 *)((int)param_2 + 1);
    puVar2 = (undefined4 *)((int)puVar2 + 1);
  }
  return param_1;
}



/* @004d493c file=? name=FUN_004d493c */

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

{
  uint uVar1;
  undefined1 *puVar2;
  undefined4 *puVar3;
  undefined1 *puVar4;
  undefined4 *puVar5;
  
  if (param_1 < param_2) {
    puVar3 = param_1;
    for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {
      *puVar3 = *param_2;
      param_2 = param_2 + 1;
      puVar3 = puVar3 + 1;
    }
    for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {
      *(undefined1 *)puVar3 = *(undefined1 *)param_2;
      param_2 = (undefined4 *)((int)param_2 + 1);
      puVar3 = (undefined4 *)((int)puVar3 + 1);
    }
  }
  else if (param_1 != param_2) {
    puVar2 = (undefined1 *)((int)param_2 + (param_3 - 1));
    puVar4 = (undefined1 *)((int)param_1 + (param_3 - 1));
    for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {
      *puVar4 = *puVar2;
      puVar2 = puVar2 + -1;
      puVar4 = puVar4 + -1;
    }
    puVar3 = (undefined4 *)(puVar2 + -3);
    puVar5 = (undefined4 *)(puVar4 + -3);
    for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {
      *puVar5 = *puVar3;
      puVar3 = puVar3 + -1;
      puVar5 = puVar5 + -1;
    }
  }
  return param_1;
}



/* @004d4988 file=? name=FUN_004d4988 */

undefined4 * __cdecl FUN_004d4988(undefined4 *param_1,undefined1 param_2,uint param_3)

{
  uint uVar1;
  undefined4 *puVar2;
  
  puVar2 = param_1;
  for (uVar1 = param_3 >> 2; uVar1 != 0; uVar1 = uVar1 - 1) {
    *puVar2 = CONCAT22(CONCAT11(param_2,param_2),CONCAT11(param_2,param_2));
    puVar2 = puVar2 + 1;
  }
  for (uVar1 = param_3 & 3; uVar1 != 0; uVar1 = uVar1 - 1) {
    *(undefined1 *)puVar2 = param_2;
    puVar2 = (undefined4 *)((int)puVar2 + 1);
  }
  return param_1;
}



/* @004d49b8 file=? name=FUN_004d49b8 */

char * __cdecl FUN_004d49b8(char *param_1,char *param_2)

{
  char cVar1;
  int iVar2;
  uint uVar3;
  uint uVar4;
  char *pcVar5;
  char *pcVar6;
  
  iVar2 = -1;
  pcVar5 = param_1;
  do {
    pcVar6 = pcVar5;
    if (iVar2 == 0) break;
    iVar2 = iVar2 + -1;
    pcVar6 = pcVar5 + 1;
    cVar1 = *pcVar5;
    pcVar5 = pcVar6;
  } while (cVar1 != '\0');
  uVar3 = 0xffffffff;
  do {
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar5;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  pcVar5 = pcVar5 + -uVar3;
  pcVar6 = pcVar6 + -1;
  for (uVar4 = uVar3 >> 2; uVar4 != 0; uVar4 = uVar4 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar3 = uVar3 & 3; uVar3 != 0; uVar3 = uVar3 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  return param_1;
}



/* @004d49f4 file=? name=FUN_004d49f4 */

char * __cdecl FUN_004d49f4(char *param_1,char param_2)

{
  char *pcVar1;
  uint uVar2;
  bool bVar3;
  
  uVar2 = 0xffffffff;
  bVar3 = true;
  pcVar1 = param_1;
  do {
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    bVar3 = *pcVar1 == '\0';
    pcVar1 = pcVar1 + 1;
  } while (!bVar3);
  uVar2 = ~uVar2;
  do {
    pcVar1 = param_1;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar1 = param_1 + 1;
    bVar3 = param_2 == *param_1;
    param_1 = pcVar1;
  } while (!bVar3);
  if (bVar3) {
    pcVar1 = pcVar1 + -1;
  }
  else {
    pcVar1 = (char *)0x0;
  }
  return pcVar1;
}



/* @004d4a1c file=? name=FUN_004d4a1c */

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

{
  char cVar1;
  char cVar2;
  uint uVar3;
  char *pcVar4;
  char *pcVar5;
  
  uVar3 = 0xffffffff;
  pcVar4 = param_2;
  do {
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    cVar1 = *pcVar4;
    pcVar4 = pcVar4 + 1;
  } while (cVar1 != '\0');
  uVar3 = ~uVar3;
  do {
    pcVar4 = param_1;
    pcVar5 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar5 = param_2 + 1;
    pcVar4 = param_1 + 1;
    cVar2 = *param_2;
    cVar1 = *param_1;
    param_1 = pcVar4;
    param_2 = pcVar5;
  } while (cVar1 == cVar2);
  return (uint)(byte)pcVar4[-1] - (uint)(byte)pcVar5[-1];
}



/* @004d4a48 file=? name=FUN_004d4a48 */

char * __cdecl FUN_004d4a48(char *param_1,char *param_2)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  char *pcVar4;
  
  uVar2 = 0xffffffff;
  pcVar4 = param_2;
  do {
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    cVar1 = *pcVar4;
    pcVar4 = pcVar4 + 1;
  } while (cVar1 != '\0');
  pcVar4 = param_1;
  for (uVar3 = ~uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar4 = *(undefined4 *)param_2;
    param_2 = param_2 + 4;
    pcVar4 = pcVar4 + 4;
  }
  for (uVar2 = ~uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar4 = *param_2;
    param_2 = param_2 + 1;
    pcVar4 = pcVar4 + 1;
  }
  return param_1;
}



/* @004d4a78 file=? name=FUN_004d4a78 */

int __cdecl FUN_004d4a78(char *param_1)

{
  char cVar1;
  uint uVar2;
  
  uVar2 = 0xffffffff;
  do {
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    cVar1 = *param_1;
    param_1 = param_1 + 1;
  } while (cVar1 != '\0');
  return ~uVar2 - 1;
}



/* @004d4a94 file=? name=FUN_004d4a94 */

char * __cdecl FUN_004d4a94(char *param_1,char *param_2,uint param_3)

{
  char cVar1;
  int iVar2;
  uint uVar3;
  uint uVar4;
  uint uVar5;
  char *pcVar6;
  char *pcVar7;
  
  iVar2 = -1;
  pcVar6 = param_1;
  do {
    pcVar7 = pcVar6;
    if (iVar2 == 0) break;
    iVar2 = iVar2 + -1;
    pcVar7 = pcVar6 + 1;
    cVar1 = *pcVar6;
    pcVar6 = pcVar7;
  } while (cVar1 != '\0');
  uVar3 = 0xffffffff;
  do {
    pcVar6 = param_2;
    if (uVar3 == 0) break;
    uVar3 = uVar3 - 1;
    pcVar6 = param_2 + 1;
    cVar1 = *param_2;
    param_2 = pcVar6;
  } while (cVar1 != '\0');
  uVar4 = ~uVar3 - 1;
  if (param_3 < uVar4) {
    uVar4 = param_3;
  }
  pcVar6 = pcVar6 + -~uVar3;
  pcVar7 = pcVar7 + -1;
  for (uVar5 = uVar4 >> 2; uVar5 != 0; uVar5 = uVar5 - 1) {
    *(undefined4 *)pcVar7 = *(undefined4 *)pcVar6;
    pcVar6 = pcVar6 + 4;
    pcVar7 = pcVar7 + 4;
  }
  for (uVar4 = uVar4 & 3; uVar4 != 0; uVar4 = uVar4 - 1) {
    *pcVar7 = *pcVar6;
    pcVar6 = pcVar6 + 1;
    pcVar7 = pcVar7 + 1;
  }
  *pcVar7 = '\0';
  return param_1;
}



/* @004d4ae0 file=? name=FUN_004d4ae0 */

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

{
  char cVar1;
  char cVar2;
  int iVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  
  iVar3 = 0;
  iVar4 = param_3;
  pcVar5 = param_2;
  if (param_3 != 0) {
    do {
      if (iVar4 == 0) break;
      iVar4 = iVar4 + -1;
      cVar1 = *pcVar5;
      pcVar5 = pcVar5 + 1;
    } while (cVar1 != '\0');
    iVar4 = param_3 - iVar4;
    do {
      pcVar5 = param_1;
      pcVar6 = param_2;
      if (iVar4 == 0) break;
      iVar4 = iVar4 + -1;
      pcVar6 = param_2 + 1;
      pcVar5 = param_1 + 1;
      cVar2 = *param_2;
      cVar1 = *param_1;
      param_1 = pcVar5;
      param_2 = pcVar6;
    } while (cVar1 == cVar2);
    iVar3 = (uint)(byte)pcVar5[-1] - (uint)(byte)pcVar6[-1];
  }
  return iVar3;
}



/* @004d4b14 file=? name=FUN_004d4b14 */

int __cdecl FUN_004d4b14(byte *param_1,byte *param_2,int param_3)

{
  if (param_3 == 0) {
    return 0;
  }
  while( true ) {
    if (param_3 == 0) {
      return (uint)param_1[-1] - (uint)param_2[-1];
    }
    if (*param_1 != *param_2) break;
    param_1 = param_1 + 1;
    param_2 = param_2 + 1;
    param_3 = param_3 + -1;
  }
  return (uint)*param_1 - (uint)*param_2;
}



/* @004d4b58 file=? name=FUN_004d4b58 */

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

{
  uint uVar1;
  uint uVar2;
  char cVar3;
  
  while( true ) {
    uVar1 = FUN_004dc8c4((int)*param_1);
    uVar2 = FUN_004dc8c4((int)*param_2);
    cVar3 = (char)uVar1;
    if ((cVar3 != (char)uVar2) || (cVar3 == '\0')) break;
    param_1 = param_1 + 1;
    param_2 = param_2 + 1;
  }
  return (int)cVar3 - (int)(char)uVar2;
}



/* @004d4b9c file=? name=FUN_004d4b9c */

undefined4 * __cdecl FUN_004d4b9c(undefined4 *param_1,char *param_2,uint param_3)

{
  uint uVar1;
  
  uVar1 = FUN_004d4a78(param_2);
  if (param_3 < uVar1) {
    FUN_004d4918(param_1,(undefined4 *)param_2,param_3);
  }
  else {
    FUN_004d4918(param_1,(undefined4 *)param_2,uVar1);
    FUN_004d4988((undefined4 *)(uVar1 + (int)param_1),0,param_3 - uVar1);
  }
  return param_1;
}



/* @004d4bec file=? name=FUN_004d4bec */

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

{
  uint uVar1;
  uint uVar2;
  int iVar3;
  
  while( true ) {
    uVar1 = FUN_004dc8c4((int)*param_1);
    uVar2 = FUN_004dc8c4((int)*param_2);
    if (((uVar1 != uVar2) || (*param_1 == '\0')) || (param_3 == 0)) break;
    param_3 = param_3 + -1;
    param_1 = param_1 + 1;
    param_2 = param_2 + 1;
  }
  if (param_3 == 0) {
    iVar3 = 0;
  }
  else {
    uVar1 = FUN_004dc8c4((int)*param_1);
    uVar2 = FUN_004dc8c4((int)*param_2);
    iVar3 = uVar1 - uVar2;
  }
  return iVar3;
}



/* @004d4c4c file=? name=FUN_004d4c4c */

char * __cdecl FUN_004d4c4c(char *param_1,char param_2)

{
  int iVar1;
  char *pcVar2;
  
  iVar1 = FUN_004d4a78(param_1);
  pcVar2 = param_1 + iVar1;
  while( true ) {
    if (param_2 == *pcVar2) {
      return pcVar2;
    }
    if (param_1 == pcVar2) break;
    pcVar2 = pcVar2 + -1;
  }
  return (char *)0x0;
}



/* @004d4c78 file=? name=FUN_004d4c78 */

char * __cdecl FUN_004d4c78(char *param_1,char *param_2)

{
  int iVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  char *pcVar5;
  int iVar6;
  char *local_10;
  
  iVar1 = FUN_004d4a78(param_1);
  iVar2 = FUN_004d4a78(param_2);
  if (iVar2 != 0) {
    if (iVar1 == 0) {
      param_1 = (char *)0x0;
    }
    else {
      iVar3 = 0;
      while( true ) {
        for (pcVar5 = param_1 + iVar3; (iVar3 < iVar1 && (*pcVar5 != *param_2)); pcVar5 = pcVar5 + 1
            ) {
          iVar3 = iVar3 + 1;
        }
        if (iVar1 == iVar3) {
          return (char *)0x0;
        }
        iVar6 = 0;
        local_10 = param_2;
        iVar4 = iVar3;
        for (pcVar5 = param_1 + iVar3;
            ((iVar4 < iVar1 && (iVar6 < iVar2)) && (*pcVar5 == *local_10)); pcVar5 = pcVar5 + 1) {
          iVar4 = iVar4 + 1;
          iVar6 = iVar6 + 1;
          local_10 = local_10 + 1;
        }
        if (iVar6 == iVar2) {
          return param_1 + iVar3;
        }
        if (iVar1 == iVar4) break;
        iVar3 = iVar3 + 1;
      }
      param_1 = (char *)0x0;
    }
  }
  return param_1;
}



/* @004d4d1c file=? name=FUN_004d4d1c */

char * __cdecl FUN_004d4d1c(char *param_1,char *param_2)

{
  char *pcVar1;
  char *pcVar2;
  
  if (param_1 == (char *)0x0) {
    param_1 = DAT_00524c54;
  }
  for (; pcVar1 = param_2, *param_1 != '\0'; param_1 = param_1 + 1) {
    for (; (*pcVar1 != '\0' && (*pcVar1 != *param_1)); pcVar1 = pcVar1 + 1) {
    }
    if (*pcVar1 == '\0') break;
  }
  DAT_00524c54 = param_1;
  if (*param_1 == '\0') {
    pcVar2 = (char *)0x0;
  }
  else {
    for (; pcVar1 = param_2, pcVar2 = param_1, *DAT_00524c54 != '\0';
        DAT_00524c54 = DAT_00524c54 + 1) {
      for (; *pcVar1 != '\0'; pcVar1 = pcVar1 + 1) {
        if (*pcVar1 == *DAT_00524c54) {
          *DAT_00524c54 = '\0';
          DAT_00524c54 = DAT_00524c54 + 1;
          return param_1;
        }
      }
    }
  }
  return pcVar2;
}



/* @004d4d84 file=? name=FUN_004d4d84 */

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

{
  int iVar1;
  
  iVar1 = FUN_004d4a78(param_2);
  FUN_004d4918(param_1,(undefined4 *)param_2,iVar1 + 1);
  return iVar1 + (int)param_1;
}



/* @004d4db0 file=? name=FUN_004d4db0 */

void FUN_004d4db0(void)

{
  code *UNRECOVERED_JUMPTABLE;
  
                    /* WARNING: Could not recover jumptable at 0x004d4db4. Too many branches */
                    /* WARNING: Treating indirect jump as call */
  (*UNRECOVERED_JUMPTABLE)();
  return;
}



/* @004d4db7 file=? name=FUN_004d4db7 */

char * __cdecl FUN_004d4db7(int param_1)

{
  if (param_1 == 0) {
    return s_<notype>_0051f6d8;
  }
  return (char *)(param_1 + (uint)*(ushort *)(param_1 + 6));
}



/* @004d4dd0 file=? name=FUN_004d4dd0 */

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

{
  char cVar1;
  char cVar2;
  char *pcVar3;
  char *pcVar4;
  
  if (param_2 == param_1) {
    return 1;
  }
  if (((short)param_1[1] == (short)param_2[1]) && (*param_1 == *param_2)) {
    if (((*(ushort *)(param_1 + 1) | *(ushort *)(param_2 + 1)) & 0x80) != 0) {
      return 0;
    }
    pcVar3 = (char *)((int)param_1 + (uint)*(ushort *)((int)param_1 + 6));
    pcVar4 = (char *)((int)param_2 + (uint)*(ushort *)((int)param_2 + 6));
    do {
      cVar1 = *pcVar3;
      pcVar3 = pcVar3 + 1;
      cVar2 = *pcVar4;
      pcVar4 = pcVar4 + 1;
      if (cVar2 != cVar1) {
        return 0;
      }
    } while (cVar1 != '\0');
    return 1;
  }
  return 0;
}



/* @004d4e36 file=? name=FUN_004d4e36 */

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

{
  int *piVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  
  puVar4 = (undefined4 *)((uint)*(ushort *)(param_1 + 0x12) + param_1);
  do {
    piVar1 = (int *)*puVar4;
    if (piVar1 == (int *)0x0) {
      puVar4 = (undefined4 *)((uint)*(ushort *)(param_1 + 0x10) + param_1);
      while( true ) {
        piVar1 = (int *)*puVar4;
        if (piVar1 == (int *)0x0) {
          return 0;
        }
        if ((param_4 == 0) || ((puVar4[2] & 3) != 3)) {
          iVar2 = 0;
        }
        else {
          iVar2 = 1;
        }
        iVar3 = FUN_004d4dd0(param_2,piVar1);
        if ((iVar3 != 0) && (iVar2 != 0)) break;
        if (((*(byte *)(piVar1 + 3) & 4) != 0) &&
           (iVar2 = FUN_004d4e36((int)piVar1,param_2,param_3,iVar2), iVar2 != 0)) {
          return 1;
        }
        puVar4 = puVar4 + 3;
      }
      return 1;
    }
    if ((*(byte *)(puVar4 + 2) & 8) == 0) {
      if ((param_4 == 0) || ((puVar4[2] & 3) != 3)) {
        iVar2 = 0;
      }
      else {
        iVar2 = 1;
      }
      iVar3 = FUN_004d4dd0(param_2,piVar1);
      if ((iVar3 != 0) && (iVar2 != 0)) {
        return 1;
      }
      if (((*(byte *)(piVar1 + 3) & 4) != 0) &&
         (iVar2 = FUN_004d4e36((int)piVar1,param_2,param_3,iVar2), iVar2 != 0)) {
        return 1;
      }
    }
    puVar4 = puVar4 + 3;
  } while( true );
}



/* @004d4f30 file=? name=FUN_004d4f30 */

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

{
  uint uVar1;
  ushort uVar2;
  ushort uVar3;
  int iVar4;
  undefined4 uVar5;
  uint uVar6;
  
  while( true ) {
    while( true ) {
      if (param_2 == param_1) {
        return 1;
      }
      uVar2 = *(ushort *)(param_1 + 1);
      uVar3 = *(ushort *)(param_2 + 1);
      if ((uVar3 & uVar2 & 0x10) == 0) break;
      uVar6 = uVar2 & 0x300;
      uVar1 = uVar3 & 0x300;
      if (uVar6 != uVar1) {
        if ((param_3 != 0) || (uVar6 == uVar1)) {
          return 0;
        }
        if ((byte)(~(byte)(uVar1 >> 8) & (byte)(uVar6 >> 8)) != 0) {
          return 0;
        }
      }
      param_3 = 1;
      param_1 = (int *)param_1[2];
      param_2 = (int *)param_2[2];
    }
    if ((uVar3 & uVar2 & 0x400) == 0) break;
    if ((param_1[3] != param_2[3]) && ((param_3 != 0 || (param_1[3] != 0 || param_2[3] != 0)))) {
      return 0;
    }
    param_3 = 1;
    param_1 = (int *)param_1[2];
    param_2 = (int *)param_2[2];
  }
  iVar4 = FUN_004d4dd0(param_1,param_2);
  if (iVar4 != 0) {
    return 1;
  }
  if ((((uVar2 & 2) != 0) && ((uVar3 & 1) != 0)) && ((*(byte *)(param_1 + 3) & 4) != 0)) {
    uVar5 = FUN_004d4e36((int)param_1,param_2,param_4,1);
    return uVar5;
  }
  return 0;
}



/* @004d503f file=? name=FUN_004d503f */

int * __cdecl FUN_004d503f(uint param_1)

{
  uint *puVar1;
  int *piVar2;
  int unaff_FS_OFFSET;
  
  piVar2 = FUN_004de55c(param_1);
  if (piVar2 == (int *)0x0) {
    if ((0x80 < param_1) || ((*(byte *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 4) & 1) != 0)
       ) {
      FUN_004dedb8();
    }
    puVar1 = (uint *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 4);
    *puVar1 = *puVar1 | 1;
    piVar2 = *(int **)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0x1c);
  }
  return piVar2;
}



/* @004d5089 file=? name=FUN_004d5089 */

void __cdecl FUN_004d5089(int *param_1)

{
  uint *puVar1;
  int unaff_FS_OFFSET;
  
  if (param_1 == *(int **)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0x1c)) {
    puVar1 = (uint *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 4);
    *puVar1 = *puVar1 & 0xfffffffe;
    return;
  }
  FUN_004de420(param_1);
  return;
}



/* @004d50b6 file=? name=FUN_004d50b6 */

bool __cdecl FUN_004d50b6(int *param_1,undefined4 param_2,int *param_3,byte param_4)

{
  ushort uVar1;
  ushort uVar2;
  int iVar3;
  
  iVar3 = FUN_004d4f30(param_1,param_3,0,param_2);
  if (iVar3 != 0) {
    return true;
  }
  uVar1 = *(ushort *)(param_1 + 1);
  uVar2 = *(ushort *)(param_3 + 1);
  if ((uVar2 & 0x20) != 0) {
    iVar3 = FUN_004d4f30(param_1,(int *)param_3[2],1,param_2);
    if (iVar3 != 0) {
      return true;
    }
    uVar2 = *(ushort *)((int *)param_3[2] + 1);
    if ((uVar2 & 0x10) == 0) {
      return false;
    }
    iVar3 = FUN_004d4f30(param_1,(int *)param_3[2],0,param_2);
    if (iVar3 != 0) {
      return true;
    }
  }
  if ((uVar2 & 0x10) != 0) {
    if ((param_4 & 1) != 0) {
      return true;
    }
    if ((uVar1 & 0x10) == 0) {
      return false;
    }
    if ((uVar2 & 0x40) != 0) {
      return (uVar1 & 0x300) == (uVar2 & 0x300);
    }
  }
  return false;
}



/* @004d5177 file=? name=FUN_004d5177 */

void __cdecl FUN_004d5177(undefined4 param_1,undefined4 param_2,undefined *param_3,uint param_4)

{
  uint uVar1;
  
  if ((param_4 & 0x1000) == 0) {
    uVar1 = param_4 & 7;
    if (uVar1 == 1) {
      (*(code *)param_3)(param_1,param_2);
      return;
    }
    if (uVar1 == 2) {
      (*(code *)param_3)(param_2,param_1);
      return;
    }
    if (uVar1 == 3) {
      (*(code *)param_3)();
      return;
    }
    if (uVar1 != 5) {
      return;
    }
    (*(code *)param_3)(param_1,param_2);
  }
  else {
    uVar1 = param_4 & 7;
    if (uVar1 == 1) {
      (*(code *)param_3)(param_1,0,param_2);
      return;
    }
    if (uVar1 == 2) {
      (*(code *)param_3)(param_1,param_2,0);
      return;
    }
    if (uVar1 == 3) {
      (*(code *)param_3)();
      return;
    }
    if (uVar1 == 5) {
      (*(code *)param_3)(param_1,0,param_2);
      return;
    }
  }
  return;
}



/* @004d51fb file=? name=FUN_004d51fb */

void __cdecl FUN_004d51fb(undefined4 param_1,undefined *param_2,uint param_3,int param_4)

{
  undefined4 uVar1;
  uint uVar2;
  
  uVar1 = 2;
  if (param_4 == 0) {
    uVar1 = 0;
  }
  uVar2 = param_3 & 7;
  if (uVar2 == 1) {
    (*(code *)param_2)(param_1,uVar1);
    return;
  }
  if (uVar2 == 2) {
    (*(code *)param_2)(param_1,uVar1);
    return;
  }
  if (uVar2 != 3) {
    if (uVar2 != 5) {
      return;
    }
    (*(code *)param_2)(param_1,uVar1);
    return;
  }
  (*(code *)param_2)();
  return;
}



/* @004d5248 file=? name=FUN_004d5248 */

void __cdecl FUN_004d5248(undefined4 param_1,undefined *param_2,uint param_3)

{
  uint uVar1;
  
  uVar1 = param_3 & 7;
  if (uVar1 == 1) {
    (*(code *)param_2)(param_1);
    return;
  }
  if (uVar1 == 2) {
    (*(code *)param_2)(param_1);
    return;
  }
  if (uVar1 == 3) {
    (*(code *)param_2)();
    return;
  }
  if (uVar1 != 5) {
    return;
  }
  (*(code *)param_2)(param_1);
  return;
}



/* @004d5282 file=? name=FUN_004d5282 */

void __cdecl
FUN_004d5282(uint *param_1,undefined4 *param_2,int param_3,undefined *param_4,uint param_5,
            int param_6,int param_7,int param_8,undefined4 param_9,int param_10)

{
  ushort uVar1;
  uint uVar2;
  undefined4 *unaff_FS_OFFSET;
  ULONG_PTR local_40;
  undefined4 local_3c;
  int *local_38;
  undefined4 local_34;
  int *local_30;
  uint local_2c;
  uint *local_28;
  undefined4 local_24;
  undefined2 local_14;
  
  FUN_004d66b8();
  local_28 = param_1;
  *(uint *)(*(int *)(unaff_FS_OFFSET[1] + -8) + 0x18) =
       (uint)*(ushort *)((int)param_1 + 6) + (int)param_1;
  *(int *)(*(int *)(unaff_FS_OFFSET[1] + -8) + 0x14) = param_7;
  *(int *)(*(int *)(unaff_FS_OFFSET[1] + -8) + 0x10) = param_8;
  uVar2 = *param_1;
  uVar1 = (ushort)param_1[1];
  if ((uVar1 & 2) == 0) {
    local_2c = 0;
  }
  else {
    local_2c = param_1[3];
  }
  if ((uVar1 & 0x30) != 0) {
    param_1 = (uint *)param_1[2];
  }
  local_30 = FUN_004d503f(uVar2 + 0x46);
  *local_30 = **(int **)(unaff_FS_OFFSET[1] + -8);
  **(undefined4 **)(unaff_FS_OFFSET[1] + -8) = local_30;
  local_30[1] = (int)local_28;
  local_30[3] = param_6;
  local_30[4] = uVar2;
  *(ushort *)(local_30 + 6) = uVar1;
  *(undefined2 *)((int)local_30 + 0x1a) = (undefined2)local_2c;
  local_30[5] = (int)param_1;
  local_30[2] = param_3;
  local_30[10] = 0;
  local_30[0xb] = 0;
  local_30[7] = (int)FUN_004d5089;
  local_30[0xd] = param_7;
  local_30[0xe] = param_8;
  local_30[8] = (int)param_4;
  local_30[9] = param_5;
  *(undefined1 *)((int)local_30 + 0x45) = 0;
  *(undefined1 *)(local_30 + 0x11) = 1;
  FUN_004d4918((undefined4 *)((int)local_30 + 0x46),param_2,uVar2);
  if ((local_2c & 1) != 0) {
    local_34 = *DAT_00524c68;
    local_14 = 8;
    FUN_004d5177((int)local_30 + 0x46,param_2,param_4,param_5);
    local_14 = 0;
    *DAT_00524c68 = local_34;
  }
  if ((param_10 == 0) && ((local_2c & 2) != 0)) {
    local_14 = 0x14;
    FUN_004d51fb(param_2,(undefined *)local_28[10],(uint)(ushort)local_28[0xb],1);
    local_14 = 0;
  }
  local_40 = *(ULONG_PTR *)(*(int *)(unaff_FS_OFFSET[1] + -8) + 0x18);
  local_3c = param_9;
  local_38 = local_30;
  RaiseException(0xeefface,1,3,&local_40);
  *unaff_FS_OFFSET = local_24;
  return;
}



/* @004d5488 file=? name=FUN_004d5488 */

void __cdecl
FUN_004d5488(uint *param_1,undefined4 *param_2,int param_3,undefined *param_4,uint param_5,
            int param_6,int param_7,int param_8)

{
  undefined4 unaff_retaddr;
  
  FUN_004d5282(param_1,param_2,param_3,param_4,param_5,param_6,param_7,param_8,unaff_retaddr,0);
  return;
}



/* @004d54b5 file=? name=FUN_004d54b5 */

void __cdecl FUN_004d54b5(int param_1,int param_2)

{
  int iVar1;
  undefined4 *puVar2;
  int unaff_FS_OFFSET;
  undefined4 unaff_retaddr;
  
  iVar1 = **(int **)(*(int *)(unaff_FS_OFFSET + 4) + -8);
  if (iVar1 == 0) {
    FUN_004d6723();
  }
  if (*(char *)(iVar1 + 0x44) == '\0') {
    puVar2 = *(undefined4 **)(iVar1 + 0x40);
  }
  else {
    puVar2 = (undefined4 *)(iVar1 + 0x46);
  }
  FUN_004d5282(*(uint **)(iVar1 + 4),puVar2,*(int *)(iVar1 + 8),*(undefined **)(iVar1 + 0x20),
               *(uint *)(iVar1 + 0x24),*(int *)(iVar1 + 0xc),param_1,param_2,unaff_retaddr,1);
  return;
}



/* @004d5506 file=? name=FUN_004d5506 */

void __cdecl FUN_004d5506(undefined4 param_1,undefined4 *param_2)

{
  undefined4 local_54;
  undefined4 local_50;
  undefined4 local_44;
  
  if (param_2 == (undefined4 *)0x0) {
    local_54 = 0x26;
    local_50 = 2;
    local_44 = 0;
    param_2 = &local_54;
  }
  param_2[1] = param_2[1] | 2;
  FUN_004d69ea(param_2,(PEXCEPTION_RECORD)param_2);
  return;
}



/* @004d5545 file=? name=FUN_004d5545 */

void __cdecl FUN_004d5545(undefined4 param_1,undefined *param_2,uint param_3)

{
  undefined4 *unaff_FS_OFFSET;
  undefined4 local_24;
  
  FUN_004d66b8();
  FUN_004d51fb(param_1,param_2,param_3,1);
  *unaff_FS_OFFSET = local_24;
  return;
}



/* @004d5593 file=? name=FUN_004d5593 */

void __cdecl FUN_004d5593(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  
  if (*(char *)(param_1 + 0x44) != '\0') {
    if ((*(byte *)(param_1 + 0x1a) & 2) != 0) {
      uVar1 = *DAT_00524c68;
      FUN_004d5545(param_1 + 0x46,*(undefined **)(*(int *)(param_1 + 4) + 0x28),
                   (uint)*(ushort *)(*(int *)(param_1 + 4) + 0x2c));
      *DAT_00524c68 = uVar1;
    }
    *(undefined1 *)(param_1 + 0x44) = 0;
  }
  if (*(char *)(param_1 + 0x45) != '\0') {
    iVar2 = *(int *)(param_1 + 0x3c);
    if (((*(byte *)(iVar2 + 4) & 2) != 0) && ((*(byte *)(iVar2 + 0xc) & 2) != 0)) {
      FUN_004d5545(*(undefined4 *)(param_1 + 0x40),*(undefined **)(iVar2 + 0x28),
                   (uint)*(ushort *)(iVar2 + 0x2c));
    }
    *(undefined1 *)(param_1 + 0x45) = 0;
  }
  return;
}



/* @004d563c file=? name=FUN_004d563c */

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

{
  int *piVar1;
  int iVar2;
  undefined4 *local_8;
  
  while( true ) {
    piVar1 = (int *)*param_1;
    if (piVar1 == (int *)0x0) {
      return 0;
    }
    local_8 = (undefined4 *)(*param_4 + param_1[1]);
    if (param_2 != 0) {
      local_8 = (undefined4 *)*local_8;
    }
    iVar2 = FUN_004d4dd0(piVar1,param_3);
    if (iVar2 != 0) break;
    if ((((*(byte *)(piVar1 + 1) & 2) != 0) &&
        ((undefined4 *)((int)piVar1 + (uint)*(ushort *)(piVar1 + 4)) != (undefined4 *)0x0)) &&
       (iVar2 = FUN_004d563c((undefined4 *)((int)piVar1 + (uint)*(ushort *)(piVar1 + 4)),0,param_3,
                             (int *)&local_8), iVar2 != 0)) {
      *param_4 = (int)local_8;
      return 1;
    }
    param_1 = param_1 + 3;
  }
  *param_4 = (int)local_8;
  return 1;
}



/* @004d56c2 file=? name=FUN_004d56c2 */

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

{
  int *piVar1;
  int iVar2;
  int iVar3;
  
  piVar1 = param_3;
  iVar3 = param_2;
  if (((param_1 != 0) &&
      (iVar2 = FUN_004d563c((undefined4 *)((uint)*(ushort *)(param_2 + 0x10) + param_2),0,param_3,
                            &param_1), iVar2 == 0)) &&
     (iVar3 = FUN_004d563c((undefined4 *)((uint)*(ushort *)(iVar3 + 0x12) + iVar3),1,piVar1,&param_1
                          ), iVar3 == 0)) {
    param_1 = 0;
  }
  return param_1;
}



/* @004d571e file=? name=FUN_004d571e */

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

{
  ushort uVar1;
  uint uVar2;
  undefined4 *puVar3;
  int iVar4;
  ushort uVar5;
  uint *puVar6;
  bool bVar7;
  bool bVar8;
  undefined4 *local_8;
  
  puVar6 = *(uint **)(param_1 + 4);
  *(uint **)(param_3 + 0x3c) = puVar6;
  if ((puVar6 != (uint *)0x0) && ((*(byte *)(param_1 + 8) & 0x80) == 0)) {
    bVar7 = (*(uint *)(param_1 + 8) & 1) == 0;
    local_8 = (undefined4 *)(param_3 + 0x46);
    *(undefined1 *)(param_3 + 0x45) = 1;
    *(int *)(param_3 + 0x40) = *param_4 + param_5;
    uVar2 = *puVar6;
    uVar1 = (ushort)puVar6[1];
    uVar5 = uVar1;
    if ((uVar1 & 0x30) != 0) {
      puVar6 = (uint *)puVar6[2];
      uVar5 = (ushort)puVar6[1];
    }
    if (((uVar1 & 0x10) == 0) || ((*(byte *)(param_3 + 0xc) & 1) == 0)) {
      if (((uVar5 & 1) == 0) || ((uVar1 & 0x30) == 0)) {
        if ((*(byte *)(param_3 + 0x18) & 1) == 0) {
          if ((uVar1 & 0x20) == 0) {
            FUN_004d4918(*(undefined4 **)(param_3 + 0x40),local_8,uVar2);
          }
          else {
            FUN_004d4918(*(undefined4 **)(param_3 + 0x40),&local_8,uVar2);
            bVar7 = true;
          }
        }
        else {
          iVar4 = FUN_004d4dd0(*(int **)(param_3 + 0x14),(int *)puVar6);
          if (iVar4 == 0) {
            local_8 = (undefined4 *)
                      FUN_004d56c2((int)local_8,*(int *)(param_3 + 0x14),(int *)puVar6);
          }
          bVar7 = iVar4 == 0 || bVar7;
          if ((puVar6[3] & 1) == 0) {
            FUN_004d4918(*(undefined4 **)(param_3 + 0x40),local_8,uVar2);
          }
          else {
            FUN_004d5177(*(undefined4 *)(param_3 + 0x40),local_8,*(undefined **)(param_1 + 0xc),
                         *(uint *)(param_1 + 0x10));
            bVar7 = true;
          }
        }
      }
      else {
        bVar8 = (uVar1 & 0x20) == 0;
        if (bVar8) {
          local_8 = (undefined4 *)*local_8;
        }
        bVar7 = !bVar8 || bVar7;
        iVar4 = FUN_004d4dd0(*(int **)(param_3 + 0x14),(int *)puVar6);
        puVar3 = local_8;
        if ((iVar4 == 0) &&
           (local_8 = (undefined4 *)
                      FUN_004d56c2((int)local_8,*(int *)(param_3 + 0x14),(int *)puVar6),
           local_8 != puVar3)) {
          bVar7 = true;
        }
        FUN_004d4918(*(undefined4 **)(param_3 + 0x40),&local_8,uVar2);
      }
    }
    else {
      FUN_004d4988(*(undefined4 **)(param_3 + 0x40),0,uVar2);
      bVar7 = true;
    }
    if (!bVar7) {
      if ((puVar6[3] & 2) != 0) {
        FUN_004d5545(local_8,(undefined *)puVar6[10],(uint)(ushort)puVar6[0xb]);
      }
      *(undefined1 *)(param_3 + 0x44) = 0;
    }
  }
  return;
}



/* @004d58d2 file=? name=FUN_004d58d2 */

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

void __cdecl FUN_004d58d2(int param_1)

{
  int *piVar1;
  int *piVar2;
  undefined4 uVar3;
  uint uVar4;
  uint uVar5;
  undefined1 *puVar6;
  uint uVar7;
  int unaff_FS_OFFSET;
  
  puVar6 = &stack0xfffffffc;
  uVar7 = (uint)*(ushort *)(param_1 + 0x10);
  do {
    while( true ) {
      do {
        while( true ) {
          uVar5 = uVar7;
          if ((uVar5 == 0) || (uVar5 == *(uint *)(puVar6 + 0xc))) {
            return;
          }
          uVar7 = (uint)*(ushort *)(*(int *)(puVar6 + -4) + uVar5);
          uVar4 = (uint)*(ushort *)(*(int *)(puVar6 + -4) + uVar5 + 2);
          *(ushort *)(*(int *)(puVar6 + 8) + 0x10) = *(ushort *)(*(int *)(puVar6 + -4) + uVar5);
          if (uVar4 != 0) break;
          _DAT_00524c58 = *(undefined4 *)(*(int *)(puVar6 + -4) + 4 + uVar5 + 4);
          *(undefined2 *)(*(int *)(puVar6 + 8) + 0x12) = 1;
          FUN_004d69ff();
          *(undefined2 *)(*(int *)(puVar6 + 8) + 0x12) = 0;
        }
      } while (uVar4 - 1 < 3);
      if (uVar4 == 4) break;
      if (uVar4 - 1 == 4) {
        uVar3 = FUN_004d5fe6(*(int **)(*(int *)(puVar6 + -4) + uVar5 + 8),
                             *(int *)(*(int *)(puVar6 + -4) + uVar5 + 4) + *(int *)(puVar6 + -0xc),
                             *(int *)(puVar6 + 8),*(int *)(puVar6 + -8));
        *(undefined4 *)(puVar6 + -0xc) = uVar3;
      }
    }
    piVar1 = *(int **)(*(int *)(unaff_FS_OFFSET + 4) + -8);
    do {
      piVar2 = piVar1;
      piVar1 = (int *)*piVar2;
      if (piVar1 == (int *)0x0) break;
    } while ((piVar1[10] != *(int *)(puVar6 + 8)) || (uVar5 != piVar1[0xc]));
    *piVar2 = *piVar1;
    FUN_004d5593((int)piVar1);
    (*(code *)piVar1[7])(piVar1);
  } while( true );
}



/* @004d59e0 file=? name=FUN_004d59e0 */

void __cdecl FUN_004d59e0(int param_1)

{
  FUN_004d58d2(param_1);
  return;
}



/* @004d59f3 file=? name=FUN_004d59f3 */

void __cdecl FUN_004d59f3(undefined4 *param_1)

{
  undefined4 *unaff_FS_OFFSET;
  
  FUN_004d58d2((int)param_1);
  *unaff_FS_OFFSET = *param_1;
  return;
}



/* @004d5a10 file=? name=FUN_004d5a10 */

int * __cdecl FUN_004d5a10(int param_1,int param_2)

{
  bool bVar1;
  undefined3 extraout_var;
  int *piVar2;
  
  piVar2 = (int *)(param_1 + 8);
  while( true ) {
    if (*piVar2 == 0) {
      return (int *)0x0;
    }
    if ((int *)piVar2[1] == (int *)0x0) break;
    bVar1 = FUN_004d50b6(*(int **)(param_2 + 4),*(undefined4 *)(param_2 + 8),(int *)piVar2[1],
                         (byte)*(undefined4 *)(param_2 + 0xc));
    if (CONCAT31(extraout_var,bVar1) != 0) {
      return piVar2;
    }
    piVar2 = piVar2 + 5;
  }
  return piVar2;
}



/* @004d5a65 file=? name=FUN_004d5a65 */

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

undefined4 FUN_004d5a65(void)

{
  undefined4 uVar1;
  bool bVar2;
  undefined3 extraout_var;
  int *piVar3;
  int *piVar4;
  uint uVar5;
  int unaff_EBP;
  int iVar6;
  undefined4 *unaff_FS_OFFSET;
  
  *(undefined4 *)(unaff_EBP + -4) = *(undefined4 *)(unaff_EBP + 8);
  *(undefined4 *)(unaff_EBP + -8) = *(undefined4 *)(unaff_EBP + 0xc);
  *(undefined4 *)(unaff_EBP + -0xc) = *(undefined4 *)(unaff_EBP + 0x10);
  *(undefined4 *)(unaff_EBP + -0x10) = *(undefined4 *)(*(int *)(unaff_EBP + -4) + 0x1c);
  piVar4 = *(int **)(*(int *)(unaff_EBP + -8) + 8);
  *(int *)(unaff_EBP + -0x18) = *(int *)(unaff_EBP + -8) - piVar4[1];
  *(undefined4 *)(unaff_EBP + -0x1c) = *(undefined4 *)(*(int *)(unaff_EBP + -8) + 0xc);
  if ((*(byte *)(*(int *)(unaff_EBP + -4) + 4) & 6) == 0) {
    uVar5 = (uint)*(ushort *)(*(int *)(unaff_EBP + -8) + 0x10);
    while (uVar5 != 0) {
      *(uint *)(unaff_EBP + -0x14) = (uint)*(ushort *)((int)piVar4 + uVar5);
      *(uint *)(unaff_EBP + -0x20) = (uint)*(ushort *)((int)piVar4 + uVar5 + 2);
      iVar6 = uVar5 + 4;
      switch(*(undefined4 *)(unaff_EBP + -0x20)) {
      case 1:
        if (**(int **)(unaff_EBP + -4) != 0xeefface) {
          *(undefined4 *)(unaff_EBP + -0x34) = *(undefined4 *)(unaff_EBP + -4);
          *(undefined4 *)(unaff_EBP + -0x30) = *(undefined4 *)(unaff_EBP + -0xc);
          *(undefined4 *)(*(int *)(unaff_EBP + -8) + 0x14) = **(undefined4 **)(unaff_EBP + -4);
          *(int *)(*(int *)(unaff_EBP + -8) + 0x18) = unaff_EBP + -0x34;
          _DAT_00524c5c = *(undefined4 *)((int)piVar4 + iVar6);
          iVar6 = FUN_004d69ff();
LAB_004d5c8d:
          if (iVar6 < 0) {
            if ((*(byte *)(*(int *)(unaff_EBP + -4) + 4) & 1) != 0) {
              *(undefined2 *)(*(int *)(unaff_EBP + -8) + 0x10) = *(undefined2 *)(unaff_EBP + -0x14);
            }
            return 0;
          }
          if (iVar6 != 0) {
            *(undefined4 *)(*(int *)(unaff_EBP + -8) + 0x18) = 0;
            *(undefined4 *)(unaff_EBP + -0x2c) = *(undefined4 *)(unaff_EBP + -0x14);
LAB_004d5bb9:
            FUN_004d5506(*(undefined4 *)(unaff_EBP + -8),*(undefined4 **)(unaff_EBP + -4));
            FUN_004d58d2(*(int *)(unaff_EBP + -8));
            *(undefined2 *)(*(int *)(unaff_EBP + -8) + 0x10) = *(undefined2 *)(unaff_EBP + -0x2c);
            if (*(int *)(unaff_EBP + -0x20) == 3) {
              FUN_004d571e(*(int *)(unaff_EBP + -0x24),*(undefined4 *)(unaff_EBP + -8),
                           *(int *)(unaff_EBP + -0x10),*(int **)(unaff_EBP + -0x28),
                           *(int *)(unaff_EBP + -0x18));
            }
            FUN_004d4db0();
          }
        }
        break;
      case 2:
        if (**(int **)(unaff_EBP + -4) != 0xeefface) {
          *(undefined4 *)(*(int *)(unaff_EBP + -8) + 0x14) = **(undefined4 **)(unaff_EBP + -4);
          iVar6 = *(int *)((int)piVar4 + iVar6);
          goto LAB_004d5c8d;
        }
        break;
      case 3:
        if (**(int **)(unaff_EBP + -4) == 0xeefface) {
          *(undefined4 *)(unaff_EBP + -0x28) = *(undefined4 *)((int)piVar4 + iVar6);
          piVar3 = FUN_004d5a10(*(int *)(unaff_EBP + -0x28),*(int *)(unaff_EBP + -0x10));
          *(int **)(unaff_EBP + -0x24) = piVar3;
          if (*(int *)(unaff_EBP + -0x24) != 0) {
            *(undefined4 *)(*(int *)(unaff_EBP + -0x10) + 0x28) = *(undefined4 *)(unaff_EBP + -8);
            *(undefined4 *)(*(int *)(unaff_EBP + -0x10) + 0x2c) = *(undefined4 *)(unaff_EBP + -0x24)
            ;
            *(uint *)(*(int *)(unaff_EBP + -0x10) + 0x30) = uVar5 + 8;
            *(uint *)(unaff_EBP + -0x2c) = uVar5 + 8;
            goto LAB_004d5bb9;
          }
        }
      }
      uVar5 = *(uint *)(unaff_EBP + -0x14);
    }
  }
  else {
    FUN_004d58d2(*(int *)(unaff_EBP + -8));
    if ((**(int **)(unaff_EBP + -4) == 0xeefface) && (piVar4 = (int *)*piVar4, piVar4 != (int *)0x0)
       ) {
      for (; *piVar4 != 0; piVar4 = piVar4 + 1) {
        bVar2 = FUN_004d50b6(*(int **)(*(int *)(unaff_EBP + -0x10) + 4),
                             *(undefined4 *)(*(int *)(unaff_EBP + -0x10) + 8),(int *)*piVar4,
                             (byte)*(undefined4 *)(*(int *)(unaff_EBP + -0x10) + 0xc));
        if (CONCAT31(extraout_var,bVar2) != 0) {
          return 1;
        }
      }
      uVar1 = *unaff_FS_OFFSET;
      *unaff_FS_OFFSET = **(undefined4 **)(unaff_EBP + -8);
      FUN_004d679c();
      *unaff_FS_OFFSET = uVar1;
    }
  }
  return 1;
}



/* @004d5cdf file=? name=FUN_004d5cdf */

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

{
  undefined4 *unaff_FS_OFFSET;
  undefined4 local_24;
  
  FUN_004d66b8();
  FUN_004d51fb(param_1,*(undefined **)(param_2 + 0x28),(uint)*(ushort *)(param_2 + 0x2c),param_3);
  *unaff_FS_OFFSET = local_24;
  return;
}



/* @004d5d4b file=? name=FUN_004d5d4b */

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

{
  undefined4 *puVar1;
  int *piVar2;
  
  while (piVar2 = param_2 + -3, param_3 <= piVar2) {
    puVar1 = (undefined4 *)(param_2[-2] + param_1);
    if (param_5 != 0) {
      puVar1 = (undefined4 *)*puVar1;
    }
    param_2 = piVar2;
    if ((*(byte *)(*piVar2 + 0xc) & 2) != 0) {
      FUN_004d5d90((int)puVar1,*piVar2,param_4,0,param_6);
      param_4 = 0;
    }
  }
  return;
}



/* @004d5d90 file=? name=FUN_004d5d90 */

void __cdecl FUN_004d5d90(int param_1,int param_2,uint param_3,int param_4,undefined4 param_5)

{
  int *piVar1;
  int iVar2;
  uint uVar3;
  int *piVar4;
  int *piVar5;
  int *piVar6;
  int *piVar7;
  uint local_18;
  int *local_10;
  
  if (param_4 == 0) {
    uVar3 = *(uint *)(param_2 + 0x24);
  }
  else {
    uVar3 = *(uint *)(param_2 + 0x20);
  }
  if ((param_3 == 0) || (uVar3 <= param_3)) {
    FUN_004d5cdf(param_1,param_2,param_4);
  }
  else {
    piVar1 = (int *)((uint)*(ushort *)(param_2 + 0x12) + param_2);
    local_10 = piVar1;
    if (param_4 != 0) {
      for (; iVar2 = *local_10, iVar2 != 0; local_10 = local_10 + 3) {
        if ((*(byte *)(iVar2 + 0xc) & 2) != 0) {
          if (param_3 <= *(uint *)(iVar2 + 0x24)) {
            FUN_004d5d4b(param_1,local_10 + 3,piVar1,param_3,1,param_5);
            return;
          }
          param_3 = param_3 - *(uint *)(iVar2 + 0x24);
        }
      }
    }
    piVar6 = (int *)((uint)*(ushort *)(param_2 + 0x10) + param_2);
    for (piVar7 = piVar6; iVar2 = *piVar7, iVar2 != 0; piVar7 = piVar7 + 3) {
      if ((*(byte *)(iVar2 + 0xc) & 2) != 0) {
        if (param_3 <= *(uint *)(iVar2 + 0x24)) {
          FUN_004d5d4b(param_1,piVar7 + 3,piVar6,param_3,0,param_5);
          if (param_4 == 0) {
            return;
          }
          FUN_004d5d4b(param_1,local_10,piVar1,0,1,param_5);
          return;
        }
        param_3 = param_3 - *(uint *)(iVar2 + 0x24);
      }
    }
    piVar4 = (int *)((uint)*(ushort *)(param_2 + 0x2e) + param_2);
    piVar5 = piVar4;
    while( true ) {
      iVar2 = *piVar5;
      local_18 = 1;
      if ((*(byte *)(iVar2 + 5) & 4) != 0) {
        local_18 = *(uint *)(iVar2 + 0xc);
        iVar2 = *(int *)(iVar2 + 8);
      }
      uVar3 = *(int *)(iVar2 + 0x20) * local_18;
      if (param_3 <= uVar3) break;
      param_3 = param_3 - uVar3;
      piVar5 = piVar5 + 2;
    }
    do {
      if (local_18 < 2) {
        FUN_004d5d90(param_1 + piVar5[1],*piVar5,param_3,1,param_5);
      }
      else {
        FUN_004d5f36(param_1 + piVar5[1],*piVar5,param_3,param_5);
      }
      param_3 = 0;
      piVar5 = piVar5 + -2;
    } while (piVar4 <= piVar5);
    FUN_004d5d4b(param_1,piVar7,piVar6,0,0,param_5);
    if (param_4 != 0) {
      FUN_004d5d4b(param_1,local_10,piVar1,0,1,param_5);
    }
  }
  return;
}



/* @004d5f36 file=? name=FUN_004d5f36 */

void __cdecl FUN_004d5f36(int param_1,int param_2,uint param_3,undefined4 param_4)

{
  int *piVar1;
  uint uVar2;
  uint uVar3;
  int iVar4;
  uint local_8;
  
  piVar1 = *(int **)(param_2 + 8);
  uVar2 = piVar1[8];
  if (param_3 == 0) {
    param_3 = uVar2 * *(int *)(param_2 + 0xc);
  }
  local_8 = param_3 / uVar2;
  uVar3 = param_3 - local_8 * uVar2;
  iVar4 = param_1 + local_8 * *piVar1;
  if (uVar3 != 0) {
    FUN_004d5d90(iVar4,(int)piVar1,uVar3,1,param_4);
  }
  while (local_8 != 0) {
    iVar4 = iVar4 - *piVar1;
    FUN_004d5d90(iVar4,(int)piVar1,uVar2,1,param_4);
    local_8 = local_8 - 1;
  }
  return;
}



/* @004d5fa8 file=? name=FUN_004d5fa8 */

int __cdecl FUN_004d5fa8(int param_1,int *param_2)

{
  int iVar1;
  int iVar2;
  
  iVar1 = *param_2;
  if ((*(uint *)(iVar1 + 0xc) & 0x50) != 0x50) {
    return param_1;
  }
  if (*(int *)(iVar1 + 8) == -1) {
    return param_1;
  }
  iVar1 = *(int *)(*(int *)(iVar1 + 8) + param_1);
  iVar2 = *(int *)(iVar1 + -8);
  *param_2 = *(int *)((iVar1 - *(int *)(iVar1 + -4)) + -0xc);
  return param_1 - iVar2;
}



/* @004d5fe6 file=? name=FUN_004d5fe6 */

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

{
  bool bVar1;
  undefined4 uVar2;
  int iVar3;
  uint uVar4;
  int *piVar5;
  int iVar6;
  uint uVar7;
  int *local_1c;
  int *local_18;
  int local_14;
  int *local_10;
  int local_c;
  int local_8;
  
  local_8 = 0;
  if (param_1 == (int *)0x0) {
    uVar2 = 0;
  }
  else {
    uVar7 = (*DAT_00524c68 - *(int *)(param_3 + 0x1c)) - param_2;
    if ((*(byte *)(param_1 + 1) & 0x20) != 0) {
      uVar7 = *(uint *)(*(int *)(*param_1 + 8) + 0x20);
    }
    if ((*(byte *)((int)param_1 + 5) & 1) == 0) {
      piVar5 = param_1;
      if ((int)uVar7 < 1) {
        if ((param_1[1] & 3U) != 3) {
          return 0;
        }
        local_8 = 1;
      }
      else {
        for (; *piVar5 != 0; piVar5 = piVar5 + 3) {
          local_c = *piVar5;
          iVar6 = 1;
          if (((((*(byte *)(local_c + 4) & 0x10) != 0) &&
               (local_c = *(int *)(local_c + 8), (*(byte *)(local_c + 4) & 2) != 0)) &&
              ((*(byte *)(local_c + 0xc) & 0x20) != 0)) && ((*(byte *)(piVar5 + 1) & 8) != 0)) {
            if ((*(byte *)(piVar5 + 1) & 4) == 0) {
              local_10 = (int *)piVar5[2];
            }
            else {
              local_10 = (int *)(param_4 + piVar5[2]);
            }
            local_10 = (int *)*local_10;
            if ((*(byte *)(piVar5 + 1) & 0x40) != 0) {
              local_10 = (int *)((int)local_10 + 4);
            }
            local_10 = (int *)FUN_004d5fa8((int)local_10,&local_c);
          }
          iVar3 = local_c;
          if ((*(byte *)(local_c + 5) & 4) != 0) {
            iVar6 = *(int *)(local_c + 0xc);
            iVar3 = *(int *)(local_c + 8);
          }
          uVar4 = *(int *)(iVar3 + 0x20) * iVar6;
          if (uVar7 <= uVar4) goto LAB_004d6109;
          uVar7 = uVar7 - uVar4;
        }
        piVar5 = piVar5 + -3;
      }
LAB_004d6109:
      do {
        local_14 = *piVar5;
        uVar4 = piVar5[1];
        if ((uVar4 & 4) == 0) {
          local_18 = (int *)piVar5[2];
        }
        else {
          local_18 = (int *)(param_4 + piVar5[2]);
        }
        if ((uVar4 & 0x11) != 0) {
          local_14 = *(int *)(local_14 + 8);
          local_1c = (int *)*local_18;
          local_18 = local_1c;
          if ((uVar4 & 0x48) == 0x40) {
            local_18 = local_1c + 1;
          }
          if ((((*(byte *)(local_14 + 4) & 2) != 0) && ((*(byte *)(local_14 + 0xc) & 0x20) != 0)) &&
             ((uVar4 & 8) != 0)) {
            local_18 = (int *)FUN_004d5fa8((int)local_18,&local_14);
          }
        }
        if (local_8 == 0) {
          if ((*(byte *)(local_14 + 5) & 4) == 0) {
            FUN_004d5d90((int)local_18,local_14,uVar7,1,param_4);
          }
          else {
            FUN_004d5f36((int)local_18,local_14,uVar7,param_4);
          }
        }
        if ((uVar4 & 3) == 3) {
          if ((uVar4 & 0x48) == 0x48) {
            local_1c = local_1c + -1;
          }
          if ((*(byte *)(local_14 + 5) & 4) == 0) {
            if (*(int *)(local_14 + 0x14) == 0) {
              FUN_004022d0(local_1c);
            }
            else {
              FUN_004d5248(local_1c,*(undefined **)(local_14 + 0x14),
                           (uint)*(ushort *)(local_14 + 0x18));
            }
          }
          else {
            local_14 = *(int *)(local_14 + 8);
            if (*(int *)(local_14 + 0x1c) == 0) {
              FUN_004022e8(local_1c);
            }
            else {
              FUN_004d5248(local_1c,*(undefined **)(local_14 + 0x1c),
                           (uint)*(ushort *)(local_14 + 0x1a));
            }
          }
        }
        uVar7 = 0;
        bVar1 = param_1 < piVar5;
        piVar5 = piVar5 + -3;
      } while (bVar1);
      uVar2 = 0;
    }
    else {
      uVar2 = *(undefined4 *)(*param_1 + 0x24);
    }
  }
  return uVar2;
}



/* @004d6257 file=? name=FUN_004d6257 */

uint __cdecl FUN_004d6257(int param_1)

{
  uint uVar1;
  int iVar2;
  
  if (param_1 == -1) {
    uVar1 = 0xffffffff;
  }
  else {
    iVar2 = FUN_004d4b14((byte *)(*(int *)(param_1 + 4) + -8),(byte *)s___BCCxh1_0051f6e1,8);
    if (iVar2 == 0) {
      uVar1 = (uint)*(ushort *)(param_1 + 0x10);
    }
    else {
      uVar1 = 0xffffffff;
    }
  }
  return uVar1;
}



/* @004d62b7 file=? name=FUN_004d62b7 */

undefined4 * __cdecl FUN_004d62b7(undefined4 *param_1)

{
  undefined4 local_8;
  
  *param_1 = &PTR_FUN_0051f6f8;
  local_8 = 0;
  FUN_004d5488((uint *)&DAT_004d6621,&local_8,0,(undefined *)0x0,0,0,0,0);
  return param_1;
}



/* @004d62ed file=? name=FUN_004d62ed */

undefined4 __cdecl FUN_004d62ed(undefined4 param_1)

{
  return param_1;
}



/* @004d62f5 file=? name=FUN_004d62f5 */

void __cdecl FUN_004d62f5(int *param_1,byte param_2)

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



/* @004d6314 file=? name=FUN_004d6314 */

void __cdecl FUN_004d6314(int param_1,int param_2)

{
  FUN_004d4dd0(*(int **)(param_1 + 4),*(int **)(param_2 + 4));
  return;
}



/* @004d632d file=? name=FUN_004d632d */

bool __cdecl FUN_004d632d(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_004d6314(param_1,param_2);
  return iVar1 == 0;
}



/* @004d634a file=? name=FUN_004d634a */

bool __cdecl FUN_004d634a(int param_1,int param_2)

{
  int iVar1;
  bool bVar2;
  
  if (*(int *)(param_1 + 4) == 0) {
    bVar2 = false;
  }
  else if (*(int *)(param_2 + 4) == 0) {
    bVar2 = true;
  }
  else {
    iVar1 = FUN_004d4a1c((char *)((uint)*(ushort *)(*(int *)(param_1 + 4) + 6) +
                                 *(int *)(param_1 + 4)),
                         (char *)((uint)*(ushort *)(*(int *)(param_2 + 4) + 6) +
                                 *(int *)(param_2 + 4)));
    bVar2 = iVar1 < 0;
  }
  return bVar2;
}



/* @004d6396 file=? name=FUN_004d6396 */

void __cdecl FUN_004d6396(int param_1)

{
  FUN_004d4db7(*(int *)(param_1 + 4));
  return;
}



/* @004d63a7 file=? name=FUN_004d63a7 */

int __cdecl FUN_004d63a7(int param_1,int param_2,undefined4 param_3,int param_4)

{
  if (param_1 == 0) {
    FUN_004d5488((uint *)&DAT_004d6638,(undefined4 *)&DAT_00524c60,0,(undefined *)0x0,0,0,0,0);
  }
  *(undefined4 *)(param_4 + 4) = *(undefined4 *)((param_2 - *(int *)(param_2 + -4)) + -0xc);
  return param_4;
}



/* @004d63e5 file=? name=FUN_004d63e5 */

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

{
  int *piVar1;
  bool bVar2;
  int iVar3;
  undefined4 *puVar4;
  undefined4 *puVar5;
  undefined4 *puVar6;
  int *local_1c;
  uint local_18;
  int local_14;
  undefined4 *local_10;
  uint local_c;
  
  local_c = 0;
  local_10 = (undefined4 *)0x0;
  local_14 = 0;
  if (((param_6 != (int *)0x0) && (iVar3 = FUN_004d4dd0(param_6,param_2), iVar3 != 0)) ||
     ((*(byte *)(param_2 + 3) & 4) == 0)) {
    return (undefined4 *)0x0;
  }
  bVar2 = false;
  puVar5 = (undefined4 *)((uint)*(ushort *)((int)param_2 + 0x12) + (int)param_2);
  do {
    while (piVar1 = (int *)*puVar5, piVar1 == (int *)0x0) {
      if (bVar2) {
        *param_7 = local_c;
        if (local_14 != 1) {
          return (undefined4 *)0x0;
        }
        return local_10;
      }
      bVar2 = true;
      puVar5 = (undefined4 *)((uint)*(ushort *)(param_2 + 4) + (int)param_2);
    }
    if ((*(byte *)(puVar5 + 2) & 8) == 0) {
      if ((param_8 == 0) || ((puVar5[2] & 3) != 3)) {
        local_18 = 0;
      }
      else {
        local_18 = 1;
      }
      puVar6 = (undefined4 *)(param_1 + puVar5[1]);
      local_1c = param_9;
      if ((*(byte *)(puVar5 + 2) & 4) != 0) {
        puVar6 = (undefined4 *)*puVar6;
        local_1c = piVar1;
      }
      iVar3 = FUN_004d4dd0(param_4,piVar1);
      if (iVar3 == 0) {
        if (((*(byte *)(piVar1 + 3) & 4) != 0) &&
           (puVar6 = FUN_004d63e5((int)puVar6,piVar1,param_3,param_4,param_5,param_6,param_7,
                                  local_18,local_1c), puVar6 != (undefined4 *)0x0)) {
          local_18 = *param_7;
LAB_004d6500:
          if ((local_14 == 0) || (puVar6 != local_10)) {
            local_14 = local_14 + 1;
            local_c = local_18;
            local_10 = puVar6;
          }
          else {
            local_c = local_c | local_18;
          }
        }
      }
      else if (param_3 == (undefined4 *)0x0) {
        if ((param_5 == 0) ||
           (puVar4 = FUN_004d63e5((int)puVar6,piVar1,(undefined4 *)param_5,param_6,0,(int *)0x0,
                                  param_7,0,(int *)0x0), puVar4 != (undefined4 *)0x0))
        goto LAB_004d6500;
      }
      else if (puVar6 == param_3) {
        return puVar6;
      }
    }
    puVar5 = puVar5 + 3;
  } while( true );
}



/* @004d655c file=? name=FUN_004d655c */

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

{
  int *piVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 *puVar4;
  uint local_c;
  int *local_8;
  
  local_8 = param_3;
  if (param_1 != 0) {
    puVar4 = (undefined4 *)(param_1 - *(int *)(param_2 + -8));
    piVar1 = *(int **)((param_2 - *(int *)(param_2 + -4)) + -0xc);
    if (param_4 == (int *)0x0) {
      return puVar4;
    }
    iVar2 = FUN_004d4dd0(param_4,piVar1);
    if (iVar2 != 0) {
      return puVar4;
    }
    iVar2 = FUN_004d4dd0(local_8,piVar1);
    if ((iVar2 == 0) &&
       (puVar3 = FUN_004d63e5((int)puVar4,piVar1,(undefined4 *)0x0,param_4,param_1,local_8,&local_c,
                              1,(int *)0x0), puVar3 != (undefined4 *)0x0)) {
      return puVar3;
    }
    puVar4 = FUN_004d63e5((int)puVar4,piVar1,(undefined4 *)0x0,param_4,0,(int *)0x0,&local_c,1,
                          (int *)0x0);
    if ((puVar4 != (undefined4 *)0x0) && (local_c != 0)) {
      return puVar4;
    }
  }
  if (param_5 != 0) {
    FUN_004d5488((uint *)&DAT_004d6654,(undefined4 *)&DAT_00524c61,0,(undefined *)0x0,0,0,0,0);
  }
  return (undefined4 *)0x0;
}



/* @004d66b8 file=? name=FUN_004d66b8 */

void FUN_004d66b8(void)

{
  undefined4 *puVar1;
  int in_EAX;
  undefined4 *puVar2;
  int unaff_EBP;
  undefined2 in_FS;
  
  puVar2 = (undefined4 *)(unaff_EBP + *(int *)(in_EAX + 4));
  puVar2[2] = in_EAX;
  puVar2[3] = &stack0x00000004;
  puVar2[1] = &DAT_004d5a5f;
  puVar2[4] = 0;
  *(undefined4 *)((int)puVar2 + 0x12) = 0;
  puVar2[7] = *DAT_00524c68;
  puVar1 = (undefined4 *)segment(in_FS,0);
  *puVar2 = *puVar1;
  puVar1 = (undefined4 *)segment(in_FS,0);
  *puVar1 = puVar2;
  return;
}



/* @004d66fe file=? name=FUN_004d66fe */

undefined4 __cdecl FUN_004d66fe(int param_1)

{
  undefined4 uVar1;
  int unaff_FS_OFFSET;
  
  uVar1 = *(undefined4 *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 8);
  if (param_1 != 0) {
    *(int *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 8) = param_1;
  }
  return uVar1;
}



/* @004d6723 file=? name=FUN_004d6723 */

void FUN_004d6723(void)

{
  undefined4 *unaff_FS_OFFSET;
  undefined4 local_24;
  
  FUN_004d66b8();
  thunk_FUN_004d87e8();
  (**(code **)(*(int *)(unaff_FS_OFFSET[1] + -8) + 8))();
  FUN_004dedb8();
  *unaff_FS_OFFSET = local_24;
  return;
}



/* @004d6777 file=? name=FUN_004d6777 */

undefined4 __cdecl FUN_004d6777(int param_1)

{
  undefined4 uVar1;
  int unaff_FS_OFFSET;
  
  uVar1 = *(undefined4 *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0xc);
  if (param_1 != 0) {
    *(int *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0xc) = param_1;
  }
  return uVar1;
}



/* @004d679c file=? name=FUN_004d679c */

void FUN_004d679c(void)

{
  int unaff_FS_OFFSET;
  
  (**(code **)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0xc))();
  FUN_004dedb8();
  return;
}



/* @004d67b0 file=? name=FUN_004d67b0 */

undefined4 __cdecl FUN_004d67b0(int param_1,int param_2)

{
  if (param_1 == 0) {
    return 0;
  }
  return *(undefined4 *)
          (*(int *)((*(int *)(param_1 + param_2) - *(int *)(*(int *)(param_1 + param_2) + -4)) +
                   -0xc) + 0x20);
}



/* @004d67cf file=? name=FUN_004d67cf */

void __cdecl FUN_004d67cf(int param_1)

{
  HMODULE hModule;
  FARPROC pFVar1;
  int unaff_FS_OFFSET;
  bool bVar2;
  uint local_c;
  int local_8;
  
  bVar2 = param_1 == 0;
  if (param_1 == 0) {
    if (DAT_004e0058 != '\0') {
      pFVar1 = (FARPROC)0x0;
      hModule = GetModuleHandleA((LPCSTR)0x0);
      if (hModule != (HMODULE)0x0) {
        pFVar1 = GetProcAddress(hModule,s___GetExceptDLLinfo_0051f7d8);
      }
      if (pFVar1 != (FARPROC)0x0) {
        (*pFVar1)(&local_c);
        if ((0x82727348 < local_c) && (local_c < 0x8272735a)) {
          param_1 = local_8;
        }
      }
    }
    if (param_1 == 0) {
      FUN_004d6888(&local_c);
      param_1 = local_8;
    }
  }
  else {
    *(undefined1 **)(param_1 + 8) = &LAB_004d66f8;
    *(undefined1 **)(param_1 + 0xc) = &LAB_004d6771;
  }
  *(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) = param_1;
  if (bVar2) {
    DAT_00524c68 = *(int *)(unaff_FS_OFFSET + 4) + -4;
  }
  *(undefined4 *)(*(int *)(unaff_FS_OFFSET + 4) + -4) = 0;
  *(undefined4 *)(*(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 4) = 0;
  return;
}



/* @004d6888 file=? name=FUN_004d6888 */

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

void __cdecl FUN_004d6888(undefined4 *param_1)

{
  int unaff_FS_OFFSET;
  
  _DAT_0051f718 = *(int *)(*(int *)(unaff_FS_OFFSET + 4) + -8) + 0x24;
  *param_1 = 0x82727349;
  param_1[1] = &DAT_0051f6fc;
  return;
}



/* @004d68b0 file=? name=FUN_004d68b0 */

undefined4 FUN_004d68b0(void)

{
  return 1;
}



/* @004d6958 file=? name=FUN_004d6958 */

void __cdecl FUN_004d6958(undefined4 *param_1)

{
  *param_1 = 0;
  param_1[1] = &LAB_004d68bc;
  FUN_004d6a08(param_1);
  return;
}



/* @004d6974 file=? name=FUN_004d6974 */

void __cdecl FUN_004d6974(undefined4 *param_1)

{
  FUN_004d6a1d(param_1);
  return;
}



/* @004d6984 file=? name=FUN_004d6984 */

undefined4 __cdecl FUN_004d6984(undefined4 param_1)

{
  undefined4 uVar1;
  
  uVar1 = DAT_00524c70;
  DAT_00524c70 = param_1;
  return uVar1;
}



/* @004d69d0 file=? name=FUN_004d69d0 */

void FUN_004d69d0(void)

{
  if (DAT_005252c4 != (undefined4 *)0x0) {
    FUN_004d6958(DAT_005252c4);
  }
  return;
}



/* @004d69ea file=? name=FUN_004d69ea */

void __fastcall FUN_004d69ea(undefined4 param_1,PEXCEPTION_RECORD param_2)

{
  PVOID in_EAX;
  
  RtlUnwind(in_EAX,(PVOID)0x4d69fb,param_2,(PVOID)0x0);
  return;
}



/* @004d69ff file=? name=FUN_004d69ff */

void FUN_004d69ff(void)

{
  undefined4 *unaff_EBX;
  
  (*(code *)*unaff_EBX)();
  return;
}



/* @004d6a08 file=? name=FUN_004d6a08 */

void __cdecl FUN_004d6a08(undefined4 *param_1)

{
  undefined4 *puVar1;
  undefined2 in_FS;
  
  puVar1 = (undefined4 *)segment(in_FS,0);
  *param_1 = *puVar1;
  puVar1 = (undefined4 *)segment(in_FS,0);
  *puVar1 = param_1;
  return;
}



/* @004d6a1d file=? name=FUN_004d6a1d */

void __cdecl FUN_004d6a1d(undefined4 *param_1)

{
  undefined4 *puVar1;
  int *piVar2;
  undefined2 in_FS;
  
  piVar2 = (int *)segment(in_FS,0);
  piVar2 = (int *)*piVar2;
  if (param_1 == piVar2) {
    puVar1 = (undefined4 *)segment(in_FS,0);
    *puVar1 = *param_1;
  }
  else {
    for (; piVar2 != (int *)0xffffffff; piVar2 = (int *)*piVar2) {
      if ((undefined4 *)*piVar2 == param_1) {
        *piVar2 = *param_1;
        return;
      }
    }
  }
  return;
}



/* @004d6a50 file=? name=thunk_FUN_004d92c4 */

undefined4 __cdecl thunk_FUN_004d92c4(uint param_1)

{
  undefined4 uVar1;
  BOOL BVar2;
  
  if (DAT_0051fbc0 <= param_1) {
    uVar1 = FUN_004d9148(6);
    return uVar1;
  }
  BVar2 = CloseHandle(*(HANDLE *)(&DAT_00524d14 + param_1 * 4));
  if (BVar2 == 1) {
    (&DAT_0051fbc4)[param_1] = 0;
    return 0;
  }
  uVar1 = FUN_004d91ac();
  return uVar1;
}



/* @004d6a58 file=? name=thunk_FUN_004d87e8 */

int thunk_FUN_004d87e8(void)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  
  iVar3 = 0;
  piVar1 = &DAT_0051f800;
  iVar2 = DAT_0051fbc0;
  while (iVar2 != 0) {
    if ((*(byte *)((int)piVar1 + 0x12) & 3) != 0) {
      FUN_004d6b9c(piVar1);
      iVar3 = iVar3 + 1;
    }
    piVar1 = piVar1 + 6;
    iVar2 = iVar2 + -1;
  }
  return iVar3;
}



/* @004d6a68 file=? name=thunk_FUN_004d9334 */

DWORD __cdecl thunk_FUN_004d9334(uint param_1,LONG param_2,int param_3)

{
  DWORD DVar1;
  
  if (param_1 < DAT_0051fbc0) {
    if (param_3 == 0) {
      DVar1 = 0;
    }
    else if (param_3 == 1) {
      DVar1 = 1;
    }
    else {
      if (param_3 != 2) {
        DVar1 = FUN_004d9148(1);
        return DVar1;
      }
      DVar1 = 2;
    }
    (&DAT_0051fbc4)[param_1] = (&DAT_0051fbc4)[param_1] & 0xfffffdff;
    DVar1 = SetFilePointer(*(HANDLE *)(&DAT_00524d14 + param_1 * 4),param_2,(PLONG)0x0,DVar1);
    if (DVar1 == 0xffffffff) {
      FUN_004d91ac();
    }
  }
  else {
    DVar1 = FUN_004d9148(6);
  }
  return DVar1;
}



/* @004d6a70 file=? name=thunk_FUN_004d93ac */

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

int __cdecl thunk_FUN_004d93ac(LPCSTR param_1,uint param_2,uint param_3)

{
  bool bVar1;
  uint uVar2;
  int iVar3;
  HANDLE hObject;
  undefined3 extraout_var;
  DWORD dwFlagsAndAttributes;
  DWORD DVar4;
  _SECURITY_ATTRIBUTES _Stack_18;
  DWORD DStack_c;
  DWORD DStack_8;
  
  if ((param_2 & 0xc000) == 0) {
    param_2 = param_2 | *(uint *)PTR_DAT_0051fc68 & 0xc000;
  }
  if ((param_2 & 0x8000) == 0) {
    param_2 = param_2 | 0x4000;
  }
  uVar2 = param_2 & 0x700;
  if (uVar2 < 0x501) {
    if (uVar2 == 0x500) {
LAB_004d940f:
      DVar4 = 1;
      goto LAB_004d9430;
    }
    if (uVar2 == 0x100) {
      DVar4 = 4;
      goto LAB_004d9430;
    }
    if (uVar2 != 0x200) {
      if (uVar2 == 0x300) {
        DVar4 = 2;
        goto LAB_004d9430;
      }
      goto LAB_004d942b;
    }
  }
  else if (uVar2 != 0x600) {
    if (uVar2 != 0x700) {
LAB_004d942b:
      DVar4 = 3;
      goto LAB_004d9430;
    }
    goto LAB_004d940f;
  }
  DVar4 = 5;
LAB_004d9430:
  if ((param_2 & 0x100) == 0) {
    dwFlagsAndAttributes = GetFileAttributesA(param_1);
    if (dwFlagsAndAttributes == 0xffffffff) {
      dwFlagsAndAttributes = 0;
    }
  }
  else if ((param_3 & _DAT_005201e4 & 0x80) == 0) {
    dwFlagsAndAttributes = 1;
  }
  else {
    dwFlagsAndAttributes = 0x80;
  }
  uVar2 = param_2 & 3;
  if (uVar2 == 0) {
    DStack_8 = 0x80000000;
  }
  else if (uVar2 == 1) {
    DStack_8 = 0x40000000;
  }
  else {
    if (uVar2 != 2) {
      iVar3 = FUN_004d9148(1);
      return iVar3;
    }
    DStack_8 = 0xc0000000;
  }
  uVar2 = param_2 & 0x70;
  if (uVar2 == 0x10) {
    DStack_c = 0;
  }
  else if (uVar2 == 0x20) {
    DStack_c = 1;
  }
  else if (uVar2 == 0x30) {
    DStack_c = 2;
  }
  else {
    DStack_c = 3;
  }
  _Stack_18.nLength = 0xc;
  _Stack_18.lpSecurityDescriptor = (LPVOID)0x0;
  _Stack_18.bInheritHandle = (BOOL)((param_2 & 0x80) == 0);
  hObject = CreateFileA(param_1,DStack_8,DStack_c,&_Stack_18,DVar4,dwFlagsAndAttributes,(HANDLE)0x0)
  ;
  if (hObject == (HANDLE)0xffffffff) {
    DVar4 = GetLastError();
    uVar2 = DVar4 & 0xffff;
    if ((uVar2 == 0x6e) && (uVar2 = 0x50, (param_2 & 0x100) == 0)) {
      uVar2 = 2;
    }
    iVar3 = FUN_004d9148(uVar2);
  }
  else {
    bVar1 = FUN_004d9304((uint)hObject);
    if (CONCAT31(extraout_var,bVar1) != 0) {
      param_2 = param_2 | 0x2000;
    }
    iVar3 = FUN_004d8eac(hObject,param_2 & 0xfffff8ff);
    if (iVar3 == -1) {
      FUN_004d9148(4);
      CloseHandle(hObject);
    }
  }
  return iVar3;
}



/* @004d6a78 file=? name=thunk_FUN_004d892c */

char * __cdecl thunk_FUN_004d892c(uint param_1,char *param_2,char *param_3)

{
  char *pcVar1;
  uint uVar2;
  DWORD DVar3;
  char *pcVar4;
  DWORD DVar5;
  char *pcVar6;
  
  if (param_1 < DAT_0051fbc0) {
    if (param_3 + 1 < (char *)0x2) {
      pcVar1 = (char *)0x0;
    }
    else if ((*(byte *)((int)&DAT_0051fbc4 + param_1 * 4 + 1) & 0x40) == 0) {
      pcVar1 = (char *)FUN_004d91c0(param_1,param_2,(DWORD)param_3);
    }
    else if ((*(byte *)((int)&DAT_0051fbc4 + param_1 * 4 + 1) & 2) == 0) {
      pcVar1 = (char *)0x0;
      if (param_3 != (char *)0x0) {
        while( true ) {
          uVar2 = (int)param_3 - (int)pcVar1;
          DVar3 = FUN_004d91c0(param_1,param_2,uVar2);
          if (DVar3 == 0xffffffff) {
            return (char *)0xffffffff;
          }
          if (DVar3 == 0) {
            return pcVar1;
          }
          pcVar4 = FUN_004d48f8(param_2,'\x1a',DVar3);
          if (pcVar4 != (char *)0x0) {
            (&DAT_0051fbc4)[param_1] = (&DAT_0051fbc4)[param_1] | 0x200;
            DVar3 = (int)pcVar4 - (int)param_2;
            if (DVar3 == 0) {
              return pcVar1;
            }
          }
          if ((param_2[DVar3 - 1] == '\r') &&
             (DVar5 = FUN_004d91c0(param_1,param_2 + (DVar3 - 1),1), DVar5 == 0xffffffff)) break;
          pcVar6 = FUN_004d88c0(param_2,DVar3);
          pcVar1 = pcVar1 + (int)pcVar6;
          if ((DVar3 < uVar2) && ((*(byte *)((int)&DAT_0051fbc4 + param_1 * 4 + 1) & 0x20) != 0)) {
            return pcVar1;
          }
          if (pcVar4 != (char *)0x0) {
            return pcVar1;
          }
          if (pcVar6 != (char *)0x0) {
            return pcVar1;
          }
          if (param_3 <= pcVar1) {
            return pcVar1;
          }
        }
        pcVar1 = (char *)0xffffffff;
      }
    }
    else {
      pcVar1 = (char *)0x0;
    }
  }
  else {
    pcVar1 = (char *)FUN_004d9148(-6);
  }
  return pcVar1;
}



/* @004d6a80 file=? name=thunk_FUN_004d8b14 */

char * __cdecl thunk_FUN_004d8b14(uint param_1,char *param_2,char *param_3)

{
  char *pcVar1;
  char *pcVar2;
  DWORD DVar3;
  undefined4 auStack_8c [32];
  DWORD DStack_c;
  char *pcStack_8;
  
  if (param_1 < DAT_0051fbc0) {
    if (param_3 + 1 < (char *)0x2) {
      param_3 = (char *)0x0;
    }
    else {
      if ((*(byte *)((int)&DAT_0051fbc4 + param_1 * 4 + 1) & 8) != 0) {
        FUN_004d9334(param_1,0,2);
      }
      pcVar1 = param_2;
      pcVar2 = param_3;
      if ((*(byte *)((int)&DAT_0051fbc4 + param_1 * 4 + 1) & 0x40) == 0) {
        param_3 = (char *)FUN_004d9224(param_1,param_2,(DWORD)param_3);
      }
      else {
        for (; pcVar2 != (char *)0x0; pcVar2 = pcVar2 + -(int)pcStack_8) {
          pcStack_8 = pcVar2;
          DVar3 = FUN_004d8a5c(pcVar1,(int *)&pcStack_8,auStack_8c,0x80);
          DStack_c = FUN_004d9224(param_1,auStack_8c,DVar3);
          if (DVar3 != DStack_c) {
            if (DStack_c == 0xffffffff) {
              return (char *)0xffffffff;
            }
            return pcVar1 + (DStack_c - (int)param_2);
          }
          pcVar1 = pcVar1 + (int)pcStack_8;
        }
      }
    }
  }
  else {
    param_3 = (char *)FUN_004d9148(-6);
  }
  return param_3;
}



/* @004d6a88 file=? name=FUN_004d6a88 */

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

{
  if ((*(byte *)((int)param_1 + 0x12) & 4) != 0) {
    FUN_004de420((int *)param_1[1]);
  }
  *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xfff3;
  param_1[3] = 0;
  param_1[1] = (int)param_1 + 0x17;
  *param_1 = (int)param_1 + 0x17;
  if ((param_3 != 2) && (param_4 != 0)) {
    PTR_FUN_00520c14 = &LAB_004d87b0;
    if (param_2 == (int *)0x0) {
      param_2 = FUN_004de55c(param_4);
      if (param_2 == (int *)0x0) {
        return 0xffffffff;
      }
      *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 4;
    }
    *param_1 = (int)param_2;
    param_1[1] = (int)param_2;
    param_1[3] = param_4;
    if (param_3 == 1) {
      *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 8;
    }
  }
  return 0;
}



/* @004d6b08 file=? name=FUN_004d6b08 */

undefined4 __cdecl FUN_004d6b08(int *param_1)

{
  undefined4 uVar1;
  int iVar2;
  char *pcVar3;
  
  if ((param_1 == (int *)0x0) || ((short)param_1[5] != (short)param_1)) {
    uVar1 = 0xffffffff;
  }
  else {
    if (param_1[3] != 0) {
      if ((param_1[2] < 0) && (iVar2 = FUN_004d6b9c(param_1), iVar2 != 0)) {
        return 0xffffffff;
      }
      if ((*(byte *)((int)param_1 + 0x12) & 4) != 0) {
        FUN_004de420((int *)param_1[1]);
      }
    }
    uVar1 = FUN_004d92c4((int)*(char *)((int)param_1 + 0x16));
    *(undefined2 *)((int)param_1 + 0x12) = 0;
    param_1[3] = 0;
    param_1[2] = 0;
    *(undefined1 *)((int)param_1 + 0x16) = 0xff;
    if (*(ushort *)(param_1 + 4) != 0) {
      pcVar3 = FUN_004d760c((char *)0x0,(char *)0x0,*(ushort *)(param_1 + 4));
      FUN_004d959c(pcVar3);
      *(undefined2 *)(param_1 + 4) = 0;
    }
  }
  return uVar1;
}



/* @004d6b9c file=? name=FUN_004d6b9c */

undefined4 __cdecl FUN_004d6b9c(int *param_1)

{
  undefined4 uVar1;
  char *pcVar2;
  char *pcVar3;
  
  if (param_1 == (int *)0x0) {
    FUN_004d6d50();
    uVar1 = 0;
  }
  else if ((short)param_1[5] == (short)param_1) {
    if (param_1[2] < 0) {
      pcVar3 = (char *)(param_1[3] + param_1[2] + 1);
      param_1[2] = param_1[2] - (int)pcVar3;
      *param_1 = param_1[1];
      pcVar2 = FUN_004d8b14((int)*(char *)((int)param_1 + 0x16),(char *)param_1[1],pcVar3);
      if ((pcVar3 == pcVar2) || ((*(byte *)((int)param_1 + 0x13) & 2) != 0)) {
        uVar1 = 0;
      }
      else {
        *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x10;
        uVar1 = 0xffffffff;
      }
    }
    else {
      if ((((*(byte *)((int)param_1 + 0x12) & 8) != 0) || ((int)param_1 + 0x17 == *param_1)) &&
         (param_1[2] = 0, (int)param_1 + 0x17 == *param_1)) {
        *param_1 = param_1[1];
      }
      uVar1 = 0;
    }
  }
  else {
    uVar1 = 0xffffffff;
  }
  return uVar1;
}



/* @004d6c20 file=? name=FUN_004d6c20 */

/* WARNING: Type propagation algorithm not settling */

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

{
  int *piVar1;
  char *pcVar2;
  byte *pbVar3;
  char *pcVar4;
  undefined4 *puVar5;
  uint unaff_EDI;
  char *local_8;
  
  puVar5 = param_1;
  if (param_3[3] == 0) {
    unaff_EDI = 0;
    while ((unaff_EDI != 10 && (param_2 = param_2 + -1, 0 < param_2))) {
      piVar1 = param_3 + 2;
      *piVar1 = *piVar1 + -1;
      if (*piVar1 < 0) {
        unaff_EDI = FUN_004d7438(param_3);
      }
      else {
        pbVar3 = (byte *)*param_3;
        *param_3 = *param_3 + 1;
        unaff_EDI = (uint)*pbVar3;
      }
      if (unaff_EDI == 0xffffffff) break;
      *(char *)puVar5 = (char)unaff_EDI;
      puVar5 = (undefined4 *)((int)puVar5 + 1);
    }
  }
  else {
    pcVar2 = (char *)(param_2 - 1);
    do {
      while( true ) {
        if ((int)pcVar2 < 0) goto LAB_004d6d25;
        local_8 = (char *)param_3[2];
        if ((int)local_8 < 1) break;
        if (pcVar2 <= local_8) {
          local_8 = pcVar2;
        }
        pcVar4 = FUN_004d48f8((char *)*param_3,'\n',(int)local_8);
        if (pcVar4 != (char *)0x0) {
          local_8 = pcVar4 + (1 - *param_3);
        }
        FUN_004d4918(puVar5,(undefined4 *)*param_3,(uint)local_8);
        *param_3 = (int)(local_8 + *param_3);
        param_3[2] = param_3[2] - (int)local_8;
        puVar5 = (undefined4 *)((int)puVar5 + (int)local_8);
        pcVar2 = (char *)((int)pcVar2 - (int)local_8);
        if ((pcVar4 != (char *)0x0) || (pcVar2 == (char *)0x0)) {
          unaff_EDI = 10;
          goto LAB_004d6d25;
        }
      }
      piVar1 = param_3 + 2;
      *piVar1 = *piVar1 + -1;
      if (*piVar1 < 0) {
        unaff_EDI = FUN_004d7438(param_3);
      }
      else {
        pbVar3 = (byte *)*param_3;
        *param_3 = *param_3 + 1;
        unaff_EDI = (uint)*pbVar3;
      }
      if (unaff_EDI == 0xffffffff) {
        *(ushort *)((int)param_3 + 0x12) = *(ushort *)((int)param_3 + 0x12) | 0x20;
        break;
      }
      *(char *)puVar5 = (char)unaff_EDI;
      puVar5 = (undefined4 *)((int)puVar5 + 1);
      pcVar2 = pcVar2 + -1;
    } while (unaff_EDI != 10);
  }
LAB_004d6d25:
  if ((unaff_EDI == 0xffffffff) && (puVar5 == param_1)) {
    param_1 = (undefined4 *)0x0;
  }
  else {
    *(undefined1 *)puVar5 = 0;
    if ((*(byte *)((int)param_3 + 0x12) & 0x10) != 0) {
      param_1 = (undefined4 *)0x0;
    }
  }
  return param_1;
}



/* @004d6d50 file=? name=FUN_004d6d50 */

int FUN_004d6d50(void)

{
  char *pcVar1;
  undefined4 *puVar2;
  int iVar3;
  char *pcVar4;
  int iVar5;
  
  iVar3 = 0;
  puVar2 = &DAT_0051f800;
  iVar5 = DAT_0051fbc0;
  while (iVar5 != 0) {
    if ((int)puVar2[2] < 0) {
      pcVar4 = (char *)(puVar2[3] + puVar2[2] + 1);
      puVar2[2] = puVar2[2] - (int)pcVar4;
      *puVar2 = (char *)puVar2[1];
      pcVar1 = FUN_004d8b14((int)*(char *)((int)puVar2 + 0x16),(char *)puVar2[1],pcVar4);
      if ((pcVar4 != pcVar1) && ((*(byte *)((int)puVar2 + 0x13) & 2) == 0)) {
        *(ushort *)((int)puVar2 + 0x12) = *(ushort *)((int)puVar2 + 0x12) | 0x10;
      }
      iVar3 = iVar3 + 1;
    }
    puVar2 = puVar2 + 6;
    iVar5 = iVar5 + -1;
  }
  return iVar3;
}



/* @004d6db0 file=? name=FUN_004d6db0 */

void __cdecl FUN_004d6db0(undefined *param_1)

{
  PTR_DAT_0051fc68 = param_1;
  return;
}



/* @004d6dc0 file=? name=FUN_004d6dc0 */

uint __cdecl FUN_004d6dc0(char *param_1,uint *param_2,undefined4 *param_3)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  undefined4 uVar4;
  
  uVar4 = 0;
  cVar1 = *param_1;
  if (cVar1 == 'r') {
    uVar3 = 0;
    uVar2 = 1;
  }
  else if (cVar1 == 'w') {
    uVar3 = 0x301;
    uVar4 = 0x80;
    uVar2 = 2;
  }
  else {
    if (cVar1 != 'a') {
      return 0;
    }
    uVar3 = 0x901;
    uVar4 = 0x80;
    uVar2 = 2;
  }
  cVar1 = param_1[1];
  if ((cVar1 == '+') || ((param_1[2] == '+' && ((cVar1 == 't' || (cVar1 == 'b')))))) {
    if (cVar1 == '+') {
      cVar1 = param_1[2];
    }
    uVar3 = uVar3 & 0xfffffffe | 2;
    uVar4 = 0x180;
    uVar2 = 3;
  }
  if (cVar1 == 't') {
    uVar3 = uVar3 | 0x4000;
  }
  else if (cVar1 == 'b') {
    uVar3 = uVar3 | 0x8000;
    uVar2 = uVar2 | 0x40;
  }
  else {
    uVar3 = uVar3 | *(uint *)PTR_DAT_0051fc68 & 0xc000;
    if ((*(uint *)PTR_DAT_0051fc68 & 0x8000) != 0) {
      uVar2 = uVar2 | 0x40;
    }
  }
  PTR_FUN_00520c18 = &LAB_004d8788;
  *param_2 = uVar3;
  *param_3 = uVar4;
  return uVar2;
}



/* @004d6e80 file=? name=FUN_004d6e80 */

int * __cdecl FUN_004d6e80(int *param_1,LPCSTR param_2,char *param_3,uint param_4)

{
  uint uVar1;
  int iVar2;
  uint local_c;
  uint local_8;
  
  uVar1 = FUN_004d6dc0(param_3,&local_8,&local_c);
  *(short *)((int)param_1 + 0x12) = (short)uVar1;
  if ((short)uVar1 == 0) {
LAB_004d6ecb:
    *(undefined1 *)((int)param_1 + 0x16) = 0xff;
    *(undefined2 *)((int)param_1 + 0x12) = 0;
    param_1 = (int *)0x0;
  }
  else {
    if (*(char *)((int)param_1 + 0x16) < '\0') {
      iVar2 = FUN_004d93ac(param_2,local_8 | param_4,local_c);
      *(char *)((int)param_1 + 0x16) = (char)iVar2;
      if ((char)iVar2 < '\0') goto LAB_004d6ecb;
    }
    if ((*(byte *)((int)&DAT_0051fbc4 + *(char *)((int)param_1 + 0x16) * 4 + 1) & 0x20) != 0) {
      *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x200;
    }
    iVar2 = FUN_004d7e84(param_1,(int *)0x0,(uint)((*(byte *)((int)param_1 + 0x13) & 2) != 0),0x200)
    ;
    if (iVar2 == 0) {
      *(undefined2 *)(param_1 + 4) = 0;
    }
    else {
      FUN_004d6b08(param_1);
      param_1 = (int *)0x0;
    }
  }
  return param_1;
}



/* @004d6f28 file=? name=FUN_004d6f28 */

undefined4 * FUN_004d6f28(void)

{
  undefined4 *puVar1;
  
  puVar1 = &DAT_0051f800;
  while( true ) {
    if (*(char *)((int)puVar1 + 0x16) < '\0') {
      return puVar1;
    }
    if (&DAT_0051f800 + DAT_0051fbc0 * 6 <= puVar1) break;
    puVar1 = puVar1 + 6;
  }
  return (undefined4 *)0x0;
}



/* @004d6f54 file=? name=FUN_004d6f54 */

int * __cdecl FUN_004d6f54(LPCSTR param_1,char *param_2)

{
  int *piVar1;
  int *piVar2;
  
  piVar1 = FUN_004d6f28();
  piVar2 = (int *)0x0;
  if (piVar1 != (int *)0x0) {
    piVar2 = FUN_004d6e80(piVar1,param_1,param_2,0);
  }
  return piVar2;
}



/* @004d6f80 file=? name=FUN_004d6f80 */

void __cdecl FUN_004d6f80(undefined4 param_1,char *param_2)

{
  FUN_004d812c(FUN_004d6fa0,param_1,param_2,(uint *)&stack0x0000000c);
  return;
}



/* @004d6fa0 file=? name=FUN_004d6fa0 */

char * __cdecl FUN_004d6fa0(byte *param_1,char *param_2,int *param_3)

{
  uint uVar1;
  int iVar2;
  char *pcVar3;
  
  pcVar3 = param_2;
  if ((*(byte *)((int)param_3 + 0x12) & 8) == 0) {
    pcVar3 = (char *)param_3[3];
    if ((pcVar3 == (char *)0x0) || (pcVar3 < param_2)) {
      if ((param_3[3] == 0) || ((param_3[2] == 0 || (iVar2 = FUN_004d6b9c(param_3), iVar2 == 0)))) {
        pcVar3 = FUN_004d8b14((int)*(char *)((int)param_3 + 0x16),(char *)param_1,param_2);
        if (pcVar3 < param_2) {
          param_2 = (char *)0x0;
        }
      }
      else {
        param_2 = (char *)0x0;
      }
    }
    else {
      if (-1 < (int)(param_2 + param_3[2])) {
        if (param_3[2] == 0) {
          param_3[2] = -1 - (int)pcVar3;
        }
        else {
          iVar2 = FUN_004d6b9c(param_3);
          if (iVar2 != 0) {
            return (char *)0x0;
          }
        }
      }
      FUN_004d4918((undefined4 *)*param_3,(undefined4 *)param_1,(uint)param_2);
      param_3[2] = (int)(param_2 + param_3[2]);
      *param_3 = (int)(param_2 + *param_3);
    }
  }
  else {
    for (; pcVar3 != (char *)0x0; pcVar3 = pcVar3 + -1) {
      uVar1 = FUN_004d7518(*param_1,param_3);
      if (uVar1 == 0xffffffff) {
        return (char *)0x0;
      }
      param_1 = param_1 + 1;
    }
  }
  return param_2;
}



/* @004d70b0 file=? name=FUN_004d70b0 */

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

{
  int *piVar1;
  byte *pbVar2;
  char *pcVar3;
  uint uVar4;
  char *unaff_ESI;
  char *pcVar5;
  char *local_c;
  uint local_8;
  
  local_c = param_1;
  if (param_3[3] != 0) {
LAB_004d70cf:
    if (param_2 == (char *)0x0) {
      return unaff_ESI;
    }
    do {
      pcVar3 = (char *)param_3[2];
      if (pcVar3 != (char *)0x0) {
        pcVar5 = param_2;
        if (pcVar3 < param_2) {
          pcVar5 = pcVar3;
        }
        FUN_004d4918((undefined4 *)local_c,(undefined4 *)*param_3,(uint)pcVar5);
        *param_3 = (int)(pcVar5 + *param_3);
        param_3[2] = param_3[2] - (int)pcVar5;
        if (param_2 == pcVar5) {
          return unaff_ESI;
        }
        local_c = local_c + (int)pcVar5;
        param_2 = param_2 + -(int)pcVar5;
      }
      if ((char *)param_3[3] <= param_2) {
        pcVar5 = param_2 + -((uint)param_2 % (uint)param_3[3]);
        pcVar3 = FUN_004d892c((int)*(char *)((int)param_3 + 0x16),local_c,pcVar5);
        if (param_2 == pcVar3) {
          return unaff_ESI;
        }
        if (pcVar3 == (char *)0xffffffff) {
          *(ushort *)((int)param_3 + 0x12) = *(ushort *)((int)param_3 + 0x12) | 0x10;
          return unaff_ESI;
        }
        local_c = local_c + (int)pcVar3;
        param_2 = param_2 + -(int)pcVar3;
        if (pcVar5 != pcVar3) goto code_r0x004d715c;
      }
      uVar4 = FUN_004d744c(param_3);
      if (uVar4 == 0xffffffff) {
        *(ushort *)((int)param_3 + 0x12) = *(ushort *)((int)param_3 + 0x12) | 0x20;
        return unaff_ESI;
      }
      local_8._0_1_ = (char)uVar4;
      *local_c = (char)local_8;
      local_c = local_c + 1;
      param_2 = param_2 + -1;
      if (param_2 == (char *)0x0) {
        return unaff_ESI;
      }
    } while( true );
  }
  for (; param_2 != (char *)0x0; param_2 = param_2 + -1) {
    piVar1 = param_3 + 2;
    *piVar1 = *piVar1 + -1;
    if (*piVar1 < 0) {
      local_8 = FUN_004d7438(param_3);
    }
    else {
      pbVar2 = (byte *)*param_3;
      *param_3 = *param_3 + 1;
      local_8 = (uint)*pbVar2;
    }
    if (local_8 == 0xffffffff) break;
    *local_c = (char)local_8;
    local_c = local_c + 1;
  }
  if (local_8 == 0xffffffff) {
    *(ushort *)((int)param_3 + 0x12) = *(ushort *)((int)param_3 + 0x12) | 0x20;
  }
  return unaff_ESI;
code_r0x004d715c:
  if (((*(byte *)((int)param_3 + 0x12) & 0x40) != 0) || (pcVar3 == (char *)0x0)) {
    *(ushort *)((int)param_3 + 0x12) = *(ushort *)((int)param_3 + 0x12) | 0x20;
    return unaff_ESI;
  }
  goto LAB_004d70cf;
}



/* @004d71e0 file=? name=FUN_004d71e0 */

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

{
  uint uVar1;
  int extraout_EAX;
  char *pcVar2;
  
  if (param_2 == 0) {
    uVar1 = 0;
  }
  else {
    pcVar2 = FUN_004d70b0(param_1,(char *)(param_2 * param_3),param_4);
    uVar1 = (uint)(param_2 * param_3 - extraout_EAX) / (uint)pcVar2;
  }
  return uVar1;
}



/* @004d7214 file=? name=FUN_004d7214 */

int __cdecl FUN_004d7214(undefined4 *param_1)

{
  char cVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  int iVar5;
  char *pcVar6;
  
  iVar2 = param_1[2];
  if (iVar2 < 0) {
    iVar2 = param_1[3] + iVar2 + 1;
  }
  if ((*(byte *)((int)param_1 + 0x12) & 0x40) == 0) {
    pcVar6 = (char *)*param_1;
    iVar3 = iVar2;
    iVar5 = iVar2;
    if ((int)param_1[2] < 0) {
      while (iVar3 = iVar2 + -1, iVar2 != 0) {
        pcVar6 = pcVar6 + -1;
        iVar2 = iVar3;
        if (*pcVar6 == '\n') {
          iVar5 = iVar5 + 1;
        }
      }
    }
    else {
      while (iVar4 = iVar3 + -1, iVar5 = iVar2, iVar3 != 0) {
        cVar1 = *pcVar6;
        pcVar6 = pcVar6 + 1;
        iVar3 = iVar4;
        if (cVar1 == '\n') {
          iVar2 = iVar2 + 1;
        }
      }
    }
    return iVar5;
  }
  return iVar2;
}



/* @004d7270 file=? name=FUN_004d7270 */

undefined4 __cdecl FUN_004d7270(int *param_1,LONG param_2,int param_3)

{
  int iVar1;
  undefined4 uVar2;
  DWORD DVar3;
  
  iVar1 = FUN_004d6b9c(param_1);
  if (iVar1 == 0) {
    if ((param_3 == 1) && (0 < param_1[2])) {
      iVar1 = FUN_004d7214(param_1);
      param_2 = param_2 - iVar1;
    }
    *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xfe5f;
    param_1[2] = 0;
    *param_1 = param_1[1];
    DVar3 = FUN_004d9334((int)*(char *)((int)param_1 + 0x16),param_2,param_3);
    if (DVar3 == 0xffffffff) {
      uVar2 = 0xffffffff;
    }
    else {
      uVar2 = 0;
    }
  }
  else {
    uVar2 = 0xffffffff;
  }
  return uVar2;
}



/* @004d72d4 file=? name=FUN_004d72d4 */

DWORD __cdecl FUN_004d72d4(undefined4 *param_1)

{
  DWORD DVar1;
  DWORD DVar2;
  int iVar3;
  
  DVar1 = FUN_004d9334((int)*(char *)((int)param_1 + 0x16),0,1);
  if (DVar1 != 0xffffffff) {
    if ((int)param_1[2] < 0) {
      DVar2 = DVar1;
      if ((*(byte *)((int)&DAT_0051fbc4 + *(char *)((int)param_1 + 0x16) * 4 + 1) & 8) != 0) {
        DVar2 = FUN_004d9334((int)*(char *)((int)param_1 + 0x16),0,2);
        if (DVar2 == 0xffffffff) {
          return 0xffffffff;
        }
        DVar1 = FUN_004d9334((int)*(char *)((int)param_1 + 0x16),DVar1,0);
        if (DVar1 == 0xffffffff) {
          return 0xffffffff;
        }
      }
      iVar3 = FUN_004d7214(param_1);
      DVar1 = DVar2 + iVar3;
    }
    else {
      iVar3 = FUN_004d7214(param_1);
      DVar1 = DVar1 - iVar3;
    }
  }
  return DVar1;
}



/* @004d7358 file=? name=FUN_004d7358 */

uint __cdecl FUN_004d7358(byte *param_1,uint param_2,uint param_3,int *param_4)

{
  char *pcVar1;
  
  if (param_2 != 0) {
    pcVar1 = FUN_004d6fa0(param_1,(char *)(param_2 * param_3),param_4);
    param_3 = (uint)pcVar1 / param_2;
  }
  return param_3;
}



/* @004d7388 file=? name=FUN_004d7388 */

void __cdecl FUN_004d7388(int *param_1,uint param_2)

{
  FUN_004d8d20(0,param_1,param_2);
  return;
}



/* @004d73a0 file=? name=FUN_004d73a0 */

void FUN_004d73a0(void)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = &DAT_0051f800;
  iVar2 = 0x28;
  while (iVar2 != 0) {
    if ((*(ushort *)((int)piVar1 + 0x12) & 0x300) == 0x300) {
      FUN_004d6b9c(piVar1);
    }
    piVar1 = piVar1 + 6;
    iVar2 = iVar2 + -1;
  }
  return;
}



/* @004d73d4 file=? name=FUN_004d73d4 */

undefined4 __cdecl FUN_004d73d4(undefined4 *param_1)

{
  char *pcVar1;
  
  if ((*(byte *)((int)param_1 + 0x13) & 2) != 0) {
    FUN_004d73a0();
  }
  *param_1 = (char *)param_1[1];
  pcVar1 = FUN_004d892c((int)*(char *)((int)param_1 + 0x16),(char *)param_1[1],(char *)param_1[3]);
  param_1[2] = pcVar1;
  if (0 < (int)pcVar1) {
    *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xffdf;
    return 0;
  }
  if (param_1[2] == 0) {
    *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xfe7f | 0x20;
  }
  else {
    param_1[2] = 0;
    *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x10;
  }
  return 0xffffffff;
}



/* @004d7438 file=? name=FUN_004d7438 */

void __cdecl FUN_004d7438(int *param_1)

{
  param_1[2] = param_1[2] + 1;
  FUN_004d744c(param_1);
  return;
}



/* @004d744c file=? name=FUN_004d744c */

uint __cdecl FUN_004d744c(int *param_1)

{
  byte *pbVar1;
  int iVar2;
  char *pcVar3;
  uint uVar4;
  
  if (param_1 == (int *)0x0) {
    return 0xffffffff;
  }
  if (0 < param_1[2]) {
    param_1[2] = param_1[2] + -1;
    pbVar1 = (byte *)*param_1;
    *param_1 = *param_1 + 1;
    return (uint)*pbVar1;
  }
  if (((param_1[2] < 0) || ((*(ushort *)((int)param_1 + 0x12) & 0x110) != 0)) ||
     ((*(byte *)((int)param_1 + 0x12) & 1) == 0)) {
    *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x10;
    return 0xffffffff;
  }
  *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x80;
  if (param_1[3] != 0) {
    iVar2 = FUN_004d73d4(param_1);
    if (iVar2 != 0) {
      return 0xffffffff;
    }
    param_1[2] = param_1[2] + -1;
    pbVar1 = (byte *)*param_1;
    *param_1 = *param_1 + 1;
    return (uint)*pbVar1;
  }
  if ((*(byte *)((int)param_1 + 0x13) & 2) != 0) {
    FUN_004d73a0();
  }
  pcVar3 = FUN_004d892c((int)*(char *)((int)param_1 + 0x16),(char *)&DAT_00524db4,(char *)0x1);
  if (pcVar3 == (char *)0x0) {
    uVar4 = FUN_004d8834((int)*(char *)((int)param_1 + 0x16));
    if (uVar4 == 1) {
      *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xfe7f | 0x20;
    }
    else {
      *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) | 0x10;
    }
    return 0xffffffff;
  }
  *(ushort *)((int)param_1 + 0x12) = *(ushort *)((int)param_1 + 0x12) & 0xffdf;
  return (uint)DAT_00524db4;
}



/* @004d7518 file=? name=FUN_004d7518 */

uint __cdecl FUN_004d7518(byte param_1,int *param_2)

{
  byte *pbVar1;
  int iVar2;
  uint uVar3;
  char *pcVar4;
  byte local_5;
  
  local_5 = param_1;
  if (param_2[2] < -1) {
    param_2[2] = param_2[2] + 1;
    pbVar1 = (byte *)*param_2;
    *param_2 = *param_2 + 1;
    *pbVar1 = param_1;
    if ((((*(byte *)((int)param_2 + 0x12) & 8) != 0) && ((param_1 == 10 || (param_1 == 0xd)))) &&
       (iVar2 = FUN_004d6b9c(param_2), iVar2 != 0)) {
      return 0xffffffff;
    }
    uVar3 = (uint)local_5;
  }
  else if (((*(ushort *)((int)param_2 + 0x12) & 0x90) == 0) &&
          ((*(ushort *)((int)param_2 + 0x12) & 2) != 0)) {
    *(ushort *)((int)param_2 + 0x12) = *(ushort *)((int)param_2 + 0x12) | 0x100;
    if (param_2[3] == 0) {
      pcVar4 = FUN_004d8b14((int)*(char *)((int)param_2 + 0x16),(char *)&local_5,(char *)0x1);
      if ((pcVar4 == (char *)0x1) || ((*(byte *)((int)param_2 + 0x13) & 2) != 0)) {
        uVar3 = (uint)local_5;
      }
      else {
        *(ushort *)((int)param_2 + 0x12) = *(ushort *)((int)param_2 + 0x12) | 0x10;
        uVar3 = 0xffffffff;
      }
    }
    else {
      if ((param_2[2] != 0) && (iVar2 = FUN_004d6b9c(param_2), iVar2 != 0)) {
        return 0xffffffff;
      }
      param_2[2] = -param_2[3];
      pbVar1 = (byte *)*param_2;
      *param_2 = *param_2 + 1;
      *pbVar1 = local_5;
      if (((*(byte *)((int)param_2 + 0x12) & 8) != 0) &&
         (((local_5 == 10 || (local_5 == 0xd)) && (iVar2 = FUN_004d6b9c(param_2), iVar2 != 0)))) {
        return 0xffffffff;
      }
      uVar3 = (uint)local_5;
    }
  }
  else {
    *(ushort *)((int)param_2 + 0x12) = *(ushort *)((int)param_2 + 0x12) | 0x10;
    uVar3 = 0xffffffff;
  }
  return uVar3;
}



/* @004d760c file=? name=FUN_004d760c */

char * __cdecl FUN_004d760c(char *param_1,char *param_2,ushort param_3)

{
  char *pcVar1;
  
  if (param_1 == (char *)0x0) {
    param_1 = &DAT_00524dbe;
  }
  if (param_2 == (char *)0x0) {
    param_2 = &DAT_0051fc6c;
  }
  pcVar1 = (char *)FUN_004d4d84((undefined4 *)param_1,param_2);
  FUN_004dd3d0((uint)param_3,pcVar1);
  FUN_004d49b8(param_1,&DAT_0051fc70);
  return param_1;
}



/* @004d765c file=? name=FUN_004d765c */

char * __cdecl FUN_004d765c(char *param_1,ushort *param_2)

{
  int iVar1;
  
  do {
    *param_2 = *param_2 + 1;
    if (*param_2 == 0) {
      *param_2 = 1;
    }
    param_1 = FUN_004d760c(param_1,(char *)0x0,*param_2);
    iVar1 = FUN_004d9288(param_1,0);
  } while (iVar1 == 0);
  return param_1;
}



/* @004d771c file=? name=FUN_004d771c */

void __cdecl FUN_004d771c(char *param_1)

{
  FUN_004d812c(FUN_004d6fa0,&DAT_0051f818,param_1,(uint *)&stack0x00000008);
  return;
}



/* @004d773c file=? name=FUN_004d773c */

int __cdecl
FUN_004d773c(undefined *param_1,undefined *param_2,undefined4 param_3,byte *param_4,
            undefined4 *param_5)

{
  byte *pbVar1;
  byte bVar2;
  int iVar3;
  byte *pbVar4;
  uint uVar5;
  byte local_54 [32];
  int local_34;
  byte *local_24;
  byte local_1d;
  uint local_1c;
  uint local_18;
  int local_14;
  uint local_10;
  int local_c;
  byte local_5;
  
  local_c = 0;
  local_10 = 0;
LAB_004d7752:
  do {
    local_1d = *param_4;
    if (local_1d == 0) {
      return local_c;
    }
    pbVar1 = param_4 + 1;
    if (local_1d == 0x25) {
      local_1d = param_4[1];
      param_4 = param_4 + 2;
      pbVar1 = param_4;
      if (local_1d != 0x25) {
        local_5 = 0x20;
        uVar5 = 0xffffffff;
LAB_004d7803:
        if ((local_1d & 0x80) == 0) {
          iVar3 = (int)(char)(&DAT_005200f4)[(char)local_1d];
        }
        else {
          iVar3 = 2;
        }
        switch(iVar3) {
        default:
          goto switchD_004d7824_caseD_0;
        case 2:
          goto switchD_004d7824_caseD_2;
        case 4:
          local_5 = local_5 | 1;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 5:
          if ((int)uVar5 < 0) {
            iVar3 = (int)(char)local_1d;
          }
          else {
            iVar3 = uVar5 * 10 + (int)(char)local_1d;
          }
          uVar5 = iVar3 - 0x30;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 6:
          if ((local_5 & 1) == 0) {
            local_24 = (byte *)*param_5;
            param_5 = param_5 + 1;
          }
          if ((int)uVar5 < 0) {
            uVar5 = 1;
          }
          if (uVar5 == 0) goto LAB_004d7b71;
          goto LAB_004d7b48;
        case 7:
        case 8:
          local_18 = 10;
          goto switchD_004d7824_caseD_0;
        case 9:
          local_18 = 0;
          goto switchD_004d7824_caseD_0;
        case 10:
          thunk_FUN_004dd258();
          if (local_14 < 0) goto LAB_004d7cb4;
          if (local_14 == 0) goto switchD_004d7824_caseD_2;
          if ((local_5 & 1) == 0) {
            param_5 = param_5 + 1;
            thunk_FUN_004dd258();
            local_c = local_c + 1;
          }
          goto LAB_004d7752;
        case 0xb:
          local_5 = local_5 | 8;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 0xc:
          local_5 = local_5 | 2;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 0xd:
          local_5 = local_5 | 4;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 0xe:
          local_18 = 8;
          goto switchD_004d7824_caseD_0;
        case 0xf:
          goto switchD_004d7824_caseD_f;
        case 0x10:
          FUN_004d4988((undefined4 *)local_54,0,0x20);
          local_1c = 0;
          bVar2 = *param_4;
          pbVar1 = param_4 + 1;
          if (bVar2 == 0x5e) {
            local_1c = 1;
            bVar2 = param_4[1];
            pbVar1 = param_4 + 2;
          }
          goto LAB_004d7baa;
        case 0x11:
          uVar5 = local_10;
          goto LAB_004d7969;
        case 0x12:
          goto switchD_004d7824_caseD_12;
        case 0x13:
          uVar5 = FUN_004d7cd8(param_1,param_2,param_3,0x10,8,(int *)&local_10,&local_14);
          if (local_14 < 1) goto switchD_004d7824_caseD_2;
          if ((local_5 & 1) == 0) {
            *(uint *)*param_5 = uVar5;
            local_c = local_c + 1;
            param_5 = param_5 + 1;
          }
          goto LAB_004d7752;
        case 0x14:
          local_5 = local_5 & 0xdf;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        case 0x15:
          local_5 = local_5 | 0x20;
          local_1d = *param_4;
          param_4 = param_4 + 1;
          goto LAB_004d7803;
        }
      }
    }
    param_4 = pbVar1;
    local_10 = local_10 + 1;
    bVar2 = (*(code *)param_1)(param_3);
    if (bVar2 == 0xff) goto LAB_004d7cb4;
    if (((local_1d & 0x80) == 0) && ((&DAT_005200f4)[(char)local_1d] == '\x01')) {
      while (((bVar2 & 0x80) == 0 && ((&DAT_005200f4)[(char)bVar2] == '\x01'))) {
        local_10 = local_10 + 1;
        bVar2 = (*(code *)param_1)(param_3);
        if (bVar2 == 0xff) goto LAB_004d7cb4;
      }
      (*(code *)param_2)((int)(char)bVar2,param_3);
      local_10 = local_10 - 1;
    }
    else if (bVar2 != local_1d) {
      (*(code *)param_2)((int)(char)bVar2,param_3);
      goto switchD_004d7824_caseD_2;
    }
  } while( true );
switchD_004d7824_caseD_12:
  local_18 = 0x10;
switchD_004d7824_caseD_0:
  uVar5 = FUN_004d7cd8(param_1,param_2,param_3,local_18,uVar5 & 0x7fff,(int *)&local_10,&local_14);
  if (local_14 < 0) goto LAB_004d7cb4;
  if (local_14 == 0) goto switchD_004d7824_caseD_2;
LAB_004d7969:
  if ((('@' < (char)local_1d) && ((char)local_1d < '[')) && (local_1d != 0x58)) {
    local_5 = local_5 | 4;
  }
  if ((local_5 & 1) == 0) {
    if ((local_5 & 4) == 0) {
      if ((local_5 & 2) == 0) {
        *(uint *)*param_5 = uVar5;
      }
      else {
        *(short *)*param_5 = (short)uVar5;
      }
    }
    else {
      *(uint *)*param_5 = uVar5;
    }
    param_5 = param_5 + 1;
    if (local_1d != 0x6e) {
      local_c = local_c + 1;
    }
  }
  goto LAB_004d7752;
LAB_004d7baa:
  pbVar4 = pbVar1;
  local_1d = bVar2;
  if (bVar2 == 0) goto switchD_004d7824_caseD_2;
  local_54[(int)(char)bVar2 >> 3 & 0x1f] =
       local_54[(int)(char)bVar2 >> 3 & 0x1f] | '\x01' << (bVar2 & 7);
  bVar2 = *pbVar4;
  param_4 = pbVar4 + 1;
  if (bVar2 != 0x5d) {
    pbVar1 = param_4;
    if (((bVar2 == 0x2d) && ((char)local_1d < (char)*param_4)) && (*param_4 != 0x5d)) {
      bVar2 = *param_4;
      while( true ) {
        local_1d = local_1d + 1;
        pbVar1 = pbVar4 + 2;
        if ((char)bVar2 <= (char)local_1d) break;
        local_54[(int)(char)local_1d >> 3 & 0x1f] =
             local_54[(int)(char)local_1d >> 3 & 0x1f] | '\x01' << (local_1d & 7);
      }
    }
    goto LAB_004d7baa;
  }
  if (uVar5 == 0xffffffff) {
    uVar5 = 0x7fff;
  }
  if ((local_5 & 1) == 0) {
    local_24 = (byte *)*param_5;
    param_5 = param_5 + 1;
  }
  local_34 = 0;
  bVar2 = 0x5d;
  while (uVar5 = uVar5 - 1, -1 < (int)uVar5) {
    local_10 = local_10 + 1;
    bVar2 = (*(code *)param_1)(param_3);
    if ((bVar2 == 0xff) ||
       (((1 << (bVar2 & 7) & (int)(char)local_54[(int)(char)bVar2 >> 3 & 0x1f]) != 0) == local_1c))
    break;
    local_34 = local_34 + 1;
    if ((local_5 & 1) == 0) {
      *local_24 = bVar2;
      local_24 = local_24 + 1;
    }
  }
  if (-1 < (int)uVar5) {
    (*(code *)param_2)((int)(char)bVar2,param_3);
    local_10 = local_10 - 1;
  }
  if ((local_34 != 0) && ((local_5 & 1) == 0)) {
    *local_24 = 0;
    local_24 = local_24 + 1;
    local_c = local_c + 1;
  }
  if (bVar2 == 0xff) {
LAB_004d7cb4:
    (*(code *)param_2)(0xffffffff,param_3);
    if (local_c == 0) {
      local_c = -1;
    }
    else {
switchD_004d7824_caseD_2:
    }
    return local_c;
  }
  goto LAB_004d7752;
  while (((bVar2 & 0x80) == 0 && ((&DAT_005200f4)[(char)bVar2] == '\x01'))) {
switchD_004d7824_caseD_f:
    local_10 = local_10 + 1;
    bVar2 = (*(code *)param_1)(param_3);
    if (bVar2 == 0xff) goto LAB_004d7cb4;
  }
  if ((local_5 & 1) == 0) {
    local_24 = (byte *)*param_5;
    local_c = local_c + 1;
    param_5 = param_5 + 1;
  }
  if (uVar5 == 0xffffffff) {
    uVar5 = 0x7fff;
  }
  do {
    if ((local_5 & 1) == 0) {
      *local_24 = bVar2;
      local_24 = local_24 + 1;
    }
    local_10 = local_10 + 1;
    bVar2 = (*(code *)param_1)(param_3);
  } while ((((bVar2 != 0xff) && (bVar2 != 0)) &&
           (((bVar2 & 0x80) != 0 || ((&DAT_005200f4)[(char)bVar2] != '\x01')))) &&
          (uVar5 = uVar5 - 1, 0 < (int)uVar5));
  (*(code *)param_2)((int)(char)bVar2,param_3);
  local_10 = local_10 - 1;
  if ((local_5 & 1) == 0) {
    *local_24 = 0;
  }
  goto LAB_004d7752;
  while( true ) {
    if ((local_5 & 1) == 0) {
      *local_24 = bVar2;
      local_24 = local_24 + 1;
    }
    uVar5 = uVar5 - 1;
    if ((int)uVar5 < 1) break;
LAB_004d7b48:
    local_10 = local_10 + 1;
    bVar2 = (*(code *)param_1)(param_3);
    if (bVar2 == 0xff) goto LAB_004d7cb4;
  }
LAB_004d7b71:
  if ((local_5 & 1) == 0) {
    local_c = local_c + 1;
  }
  goto LAB_004d7752;
}



/* @004d7cd8 file=? name=FUN_004d7cd8 */

uint __cdecl
FUN_004d7cd8(undefined *param_1,undefined *param_2,undefined4 param_3,uint param_4,int param_5,
            int *param_6,int *param_7)

{
  int iVar1;
  int iVar2;
  int iVar3;
  uint uVar4;
  int iVar5;
  bool bVar6;
  bool bVar7;
  int local_1c;
  int local_18;
  uint local_14;
  int local_10;
  int local_c;
  
  bVar6 = false;
  local_c = 0;
  local_10 = 1;
  local_14 = 0;
  local_18 = 0;
  iVar5 = 0;
  iVar1 = local_c;
LAB_004d7d00:
  do {
    local_c = iVar1;
    iVar1 = local_c + 1;
    iVar3 = (*(code *)param_1)(param_3);
    if (iVar5 == 0) {
      if (((-1 < iVar3) && (iVar3 < 0x80)) && (((&DAT_005207dd)[iVar3] & 1) != 0))
      goto LAB_004d7d00;
      iVar5 = 1;
    }
    iVar2 = param_5 + -1;
    if (iVar2 < 0) goto LAB_004d7e3c;
    if ((iVar5 != 1) || ((iVar5 = 2, iVar3 != 0x2b && (iVar3 != 0x2d)))) {
      if (iVar5 == 2) {
        iVar5 = 3;
        if ((iVar3 == 0x30) && ((local_18 = 1, param_4 == 0 || (param_4 == 0x10)))) {
          iVar1 = local_c + 2;
          iVar3 = (*(code *)param_1)(param_3);
          param_5 = param_5 + -2;
          if (param_5 < 0) goto LAB_004d7e3c;
          if ((iVar3 == 0x78) || (iVar3 == 0x58)) {
            param_4 = 0x10;
            goto LAB_004d7d00;
          }
          iVar2 = param_5;
          if (param_4 == 0) {
            param_4 = 8;
          }
        }
        local_c = iVar1;
        param_5 = iVar2;
        iVar2 = param_5;
        iVar1 = local_c;
        if (param_4 == 0) {
          param_4 = 10;
        }
        else if (((int)param_4 < 1) || (0x24 < (int)param_4)) goto LAB_004d7e3c;
      }
      local_c = iVar1;
      param_5 = iVar2;
      iVar1 = local_c;
      if (iVar5 == 3) {
        if ((iVar3 < 0x30) || (0x39 < iVar3)) {
          if ((iVar3 < 0x61) || (0x7a < iVar3)) {
            if ((iVar3 < 0x41) || (0x5a < iVar3)) goto LAB_004d7e3c;
            local_1c = iVar3 + -0x37;
          }
          else {
            local_1c = iVar3 + -0x57;
          }
        }
        else {
          local_1c = iVar3 + -0x30;
        }
        if ((int)param_4 <= local_1c) goto LAB_004d7e3c;
        local_18 = local_18 + 1;
        uVar4 = local_14 * param_4 + local_1c;
        bVar7 = local_14 != (uVar4 - local_1c) / param_4;
        local_14 = uVar4;
        if (bVar7) {
          local_10 = 2;
          local_14 = 0x80000000;
          if (!bVar6) {
            local_14 = 0x7fffffff;
          }
LAB_004d7e3c:
          local_c = iVar1;
          if (local_10 != 2) {
            (*(code *)param_2)(iVar3,param_3);
            local_c = local_c + -1;
            if (bVar6) {
              local_14 = -local_14;
            }
          }
          if ((local_18 == 0) && (local_10 = -1, iVar3 != -1)) {
            local_10 = 0;
          }
          *param_7 = local_10;
          *param_6 = *param_6 + local_c;
          return local_14;
        }
      }
      goto LAB_004d7d00;
    }
    bVar6 = iVar3 == 0x2d;
    param_5 = iVar2;
  } while( true );
}



/* @004d7e84 file=? name=FUN_004d7e84 */

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

{
  undefined4 uVar1;
  
  if ((((short)param_1[5] == (short)param_1) && (param_3 < 3)) && (param_4 < 0x80000000)) {
    if (param_1[2] != 0) {
      FUN_004d7270(param_1,0,1);
    }
    if ((*(byte *)((int)param_1 + 0x12) & 4) != 0) {
      FUN_004de420((int *)param_1[1]);
    }
    uVar1 = FUN_004d6a88(param_1,param_2,param_3,param_4);
  }
  else {
    uVar1 = 0xffffffff;
  }
  return uVar1;
}



/* @004d7f10 file=? name=FUN_004d7f10 */

void __cdecl FUN_004d7f10(undefined1 *param_1,char *param_2)

{
  *param_1 = 0;
  FUN_004d812c(&LAB_004d7ee8,&param_1,param_2,(uint *)&stack0x0000000c);
  return;
}



/* @004d7f34 file=? name=FUN_004d7f34 */

void __cdecl FUN_004d7f34(undefined1 *param_1,char *param_2,uint *param_3)

{
  *param_1 = 0;
  FUN_004d812c(&LAB_004d7ee8,&param_1,param_2,param_3);
  return;
}



/* @004d7f58 file=? name=FUN_004d7f58 */

uint __cdecl FUN_004d7f58(int *param_1)

{
  byte *pbVar1;
  uint uVar2;
  
  pbVar1 = (byte *)*param_1;
  *param_1 = *param_1 + 1;
  if (*pbVar1 == 0) {
    uVar2 = 0xffffffff;
  }
  else {
    uVar2 = (uint)*pbVar1;
  }
  return uVar2;
}



/* @004d7f78 file=? name=FUN_004d7f78 */

void __cdecl FUN_004d7f78(undefined4 param_1,int *param_2)

{
  *param_2 = *param_2 + -1;
  return;
}



/* @004d7f84 file=? name=FUN_004d7f84 */

void __cdecl FUN_004d7f84(undefined4 param_1,byte *param_2)

{
  FUN_004d773c(FUN_004d7f58,FUN_004d7f78,&param_1,param_2,(undefined4 *)&stack0x0000000c);
  return;
}



/* @004d7fa8 file=? name=FUN_004d7fa8 */

void __cdecl FUN_004d7fa8(undefined4 param_1,byte *param_2,undefined4 *param_3)

{
  FUN_004d773c(FUN_004d7f58,FUN_004d7f78,&param_1,param_2,param_3);
  return;
}



/* @004d8080 file=? name=FUN_004d8080 */

void __cdecl FUN_004d8080(undefined4 param_1,char *param_2,uint *param_3)

{
  FUN_004d812c(FUN_004d6fa0,param_1,param_2,param_3);
  return;
}



/* @004d80a0 file=? name=FUN_004d80a0 */

void __cdecl FUN_004d80a0(int param_1)

{
  int iVar1;
  
  if (*(int *)(param_1 + 0x50) != 0) {
    iVar1 = (**(code **)(param_1 + 0x54))
                      (param_1,*(int *)(param_1 + 0x50),*(undefined4 *)(param_1 + 0x58));
    if (iVar1 == 0) {
      *(undefined4 *)(param_1 + 0x60) = 1;
    }
    *(undefined4 *)(param_1 + 0x50) = 0;
  }
  return;
}



/* @004d80d0 file=? name=FUN_004d80d0 */

void __cdecl FUN_004d80d0(undefined1 param_1,int param_2)

{
  if (0x4f < *(int *)(param_2 + 0x50)) {
    FUN_004d80a0(param_2);
  }
  *(undefined1 *)(param_2 + *(int *)(param_2 + 0x50)) = param_1;
  *(int *)(param_2 + 0x50) = *(int *)(param_2 + 0x50) + 1;
  *(int *)(param_2 + 0x5c) = *(int *)(param_2 + 0x5c) + 1;
  return;
}



/* @004d80f8 file=? name=FUN_004d80f8 */

void __cdecl FUN_004d80f8(uint param_1,int param_2)

{
  char *pcVar1;
  int iVar2;
  char cVar3;
  
  iVar2 = 7;
  pcVar1 = (char *)(param_2 + 7);
  do {
    cVar3 = (char)(param_1 & 0xf);
    if ((param_1 & 0xf) < 10) {
      *pcVar1 = cVar3 + '0';
    }
    else {
      *pcVar1 = cVar3 + '7';
    }
    param_1 = param_1 >> 4;
    iVar2 = iVar2 + -1;
    pcVar1 = pcVar1 + -1;
  } while (-1 < iVar2);
  return;
}



/* @004d812c file=? name=FUN_004d812c */

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

{
  uint *puVar1;
  int iVar2;
  uint uVar3;
  bool bVar4;
  bool bVar5;
  bool bVar6;
  bool bVar7;
  bool bVar8;
  uint uVar9;
  char cVar10;
  char *pcVar11;
  uint uVar12;
  bool bVar13;
  undefined1 local_c0 [80];
  undefined4 local_70;
  undefined4 local_6c;
  undefined4 local_68;
  undefined4 local_64;
  int local_60;
  char local_5c [8];
  undefined1 local_54;
  uint local_2c;
  uint local_28;
  uint local_24;
  char *local_20;
  char local_19;
  char *local_18;
  int local_14;
  char local_d;
  uint local_c;
  uint local_8;
  
  local_60 = 0;
  local_64 = 0;
  local_70 = 0;
  local_6c = param_1;
  local_68 = param_2;
LAB_004d8152:
  pcVar11 = param_3;
  cVar10 = *pcVar11;
  param_3 = pcVar11 + 1;
  if (cVar10 != '\0') {
    if (cVar10 == '%') {
      if (*param_3 != '%') {
        uVar9 = 0;
        local_d = '\0';
        local_14 = 0;
        uVar12 = 0;
        bVar7 = false;
        bVar13 = false;
        bVar6 = false;
        bVar5 = false;
        local_c = 0xffffffff;
        local_8 = 0xffffffff;
switchD_004d81b8_default:
        bVar4 = false;
        cVar10 = *param_3;
        param_3 = param_3 + 1;
        local_18 = pcVar11;
        if (cVar10 < ' ') goto switchD_004d81b8_caseD_13;
        switch((&DAT_0052015b)[cVar10]) {
        case 0:
          local_18 = pcVar11;
          if (uVar9 != 0) goto switchD_004d81b8_caseD_13;
          if (local_d != '+') {
            local_d = cVar10;
          }
          goto switchD_004d81b8_default;
        case 1:
          local_18 = pcVar11;
          if (uVar9 != 0) goto switchD_004d81b8_caseD_13;
          uVar12 = 1;
          goto switchD_004d81b8_default;
        case 2:
          uVar3 = *param_4;
          if (uVar9 < 2) {
            local_8 = uVar3;
            if ((int)uVar3 < 0) {
              bVar5 = true;
              local_8 = -uVar3;
            }
            uVar9 = 3;
            param_4 = param_4 + 1;
          }
          else {
            local_18 = pcVar11;
            if (uVar9 != 4) goto switchD_004d81b8_caseD_13;
            uVar9 = 5;
            param_4 = param_4 + 1;
            local_c = uVar3;
          }
          goto switchD_004d81b8_default;
        case 3:
          local_18 = pcVar11;
          if (uVar9 != 0) goto switchD_004d81b8_caseD_13;
          bVar5 = true;
          goto switchD_004d81b8_default;
        case 4:
          local_18 = pcVar11;
          if (3 < uVar9) goto switchD_004d81b8_caseD_13;
          uVar9 = 4;
          local_c = local_c + 1;
          goto switchD_004d81b8_default;
        case 5:
          goto switchD_004d81b8_caseD_5;
        case 6:
          bVar6 = true;
          uVar9 = 5;
          goto switchD_004d81b8_default;
        case 7:
          bVar6 = false;
          uVar9 = 5;
          goto switchD_004d81b8_default;
        case 8:
          bVar7 = true;
          bVar6 = false;
          uVar9 = 5;
          goto switchD_004d81b8_default;
        case 9:
          if (uVar9 == 0) {
            if (!bVar5) {
              bVar13 = true;
              uVar9 = 1;
            }
          }
          else {
switchD_004d81b8_caseD_5:
            cVar10 = cVar10 + -0x30;
            if (uVar9 < 3) {
              uVar9 = 2;
              if (local_8 == 0xffffffff) {
                local_8 = (uint)cVar10;
              }
              else {
                local_8 = local_8 * 10 + (int)cVar10;
              }
            }
            else {
              local_18 = pcVar11;
              if (uVar9 != 4) goto switchD_004d81b8_caseD_13;
              local_c = local_c * 10 + (int)cVar10;
            }
          }
          goto switchD_004d81b8_default;
        case 10:
          goto switchD_004d81b8_caseD_a;
        case 0xb:
          local_24 = 8;
          break;
        case 0xc:
          local_24 = 10;
          break;
        case 0xd:
          local_24 = 0x10;
          local_19 = cVar10 + -0x17;
          break;
        case 0xe:
          local_20 = (char *)*param_4;
          FUN_004d80f8((uint)local_20,(int)local_5c);
          local_54 = 0;
          local_20 = local_5c;
          param_4 = param_4 + 1;
          goto LAB_004d8548;
        case 0xf:
          local_20 = local_5c + 1;
          thunk_FUN_004dd24c();
          param_4 = (uint *)thunk_FUN_004dd24c();
          goto LAB_004d8548;
        case 0x10:
          local_5c[0] = (char)*param_4;
          local_5c[1] = 0;
          local_20 = local_5c;
          local_2c = 1;
          param_4 = param_4 + 1;
          goto LAB_004d85b9;
        case 0x11:
          puVar1 = param_4 + 1;
          local_20 = (char *)*param_4;
          if (local_20 == (char *)0x0) {
            local_20 = &DAT_00520174;
          }
          local_2c = FUN_004d4a78(local_20);
          param_4 = puVar1;
          if (((int)local_c < (int)local_2c) && (-1 < (int)local_c)) {
            local_2c = local_c;
          }
          goto LAB_004d85b9;
        case 0x12:
          puVar1 = param_4 + 1;
          local_20 = (char *)*param_4;
          param_4 = puVar1;
          if (bVar6) {
            *(undefined4 *)local_20 = local_64;
          }
          else if (bVar7) {
            *(undefined2 *)local_20 = (undefined2)local_64;
          }
          else {
            *(undefined4 *)local_20 = local_64;
          }
          goto LAB_004d8152;
        case 0x13:
        case 0x14:
        case 0x15:
          goto switchD_004d81b8_caseD_13;
        case 0x16:
          uVar9 = 5;
          goto switchD_004d81b8_default;
        case 0x17:
          uVar9 = 5;
        default:
          goto switchD_004d81b8_default;
        }
        local_d = '\0';
        bVar8 = false;
        goto LAB_004d8398;
      }
      param_3 = pcVar11 + 2;
      cVar10 = '%';
    }
    FUN_004d80d0(cVar10,(int)local_c0);
    goto LAB_004d8152;
  }
  goto LAB_004d8763;
switchD_004d81b8_caseD_a:
  local_24 = 10;
  bVar8 = true;
LAB_004d8398:
  if (bVar6) {
    uVar9 = *param_4;
  }
  else if (bVar7) {
    if (bVar8) {
      uVar9 = (uint)(short)(ushort)*param_4;
    }
    else {
      uVar9 = (uint)(ushort)*param_4;
    }
  }
  else {
    uVar9 = *param_4;
  }
  param_4 = param_4 + 1;
  local_20 = local_5c + 1;
  if (uVar9 == 0) {
    if (local_c == 0) {
      local_5c[1] = 0;
      goto LAB_004d840a;
    }
  }
  else {
    uVar12 = uVar12 | 4;
  }
  FUN_004dd35c(uVar9,local_20,local_24,bVar8,local_19);
LAB_004d840a:
  if ((int)local_c < 0) {
LAB_004d8548:
    if ((bVar13) && (0 < (int)local_8)) {
      local_2c = FUN_004d4a78(local_20);
      if (*local_20 == '-') {
        local_2c = local_2c + -1;
      }
      if ((int)local_2c < (int)local_8) {
        local_14 = local_8 - local_2c;
      }
    }
    if ((*local_20 == '-') || (local_d != '\0')) {
      if (*local_20 != '-') {
        local_20 = local_20 + -1;
        *local_20 = local_d;
      }
      if ((0 < local_14) && ((int)local_c < 0)) {
        local_14 = local_14 + -1;
      }
    }
    local_2c = FUN_004d4a78(local_20);
  }
  else {
    local_28 = FUN_004d4a78(local_20);
    local_2c = local_28;
    if (*local_20 == '-') {
      local_28 = local_28 - 1;
    }
    else if (local_d != '\0') {
      local_2c = local_28 + 1;
      local_20 = local_20 + -1;
      *local_20 = local_d;
    }
    if ((int)local_28 < (int)local_c) {
      local_14 = local_c - local_28;
    }
  }
LAB_004d85b9:
  if (uVar12 == 5) {
    if (cVar10 == 'o') {
      if (local_14 < 1) {
        local_14 = 1;
      }
    }
    else if ((cVar10 == 'x') || (cVar10 == 'X')) {
      bVar4 = true;
      local_8 = local_8 - 2;
      local_14 = local_14 + -2;
      if (local_14 < 0) {
        local_14 = 0;
      }
    }
  }
  local_2c = local_2c + local_14;
  if ((!bVar5) && ((int)local_2c < (int)local_8)) {
    do {
      FUN_004d80d0(0x20,(int)local_c0);
      local_8 = local_8 - 1;
    } while ((int)local_2c < (int)local_8);
  }
  if (bVar4) {
    FUN_004d80d0(0x30,(int)local_c0);
    FUN_004d80d0(cVar10,(int)local_c0);
  }
  if (0 < local_14) {
    local_2c = local_2c - local_14;
    local_8 = local_8 - local_14;
    cVar10 = *local_20;
    if (((cVar10 == '-') || (cVar10 == ' ')) || (cVar10 == '+')) {
      cVar10 = *local_20;
      local_20 = local_20 + 1;
      FUN_004d80d0(cVar10,(int)local_c0);
      local_2c = local_2c + -1;
      local_8 = local_8 - 1;
    }
    while (iVar2 = local_14 + -1, bVar13 = local_14 != 0, local_14 = iVar2, bVar13) {
      FUN_004d80d0(0x30,(int)local_c0);
    }
  }
  if (local_2c != 0) {
    local_8 = local_8 - local_2c;
    while (local_2c != 0) {
      cVar10 = *local_20;
      local_2c = local_2c + -1;
      local_20 = local_20 + 1;
      FUN_004d80d0(cVar10,(int)local_c0);
    }
    local_2c = -1;
  }
  while (uVar12 = local_8 - 1, bVar13 = 0 < (int)local_8, local_8 = uVar12, bVar13) {
    FUN_004d80d0(0x20,(int)local_c0);
  }
  goto LAB_004d8152;
switchD_004d81b8_caseD_13:
  while( true ) {
    pcVar11 = local_18 + 1;
    cVar10 = *local_18;
    local_18 = pcVar11;
    if (cVar10 == '\0') break;
    FUN_004d80d0(cVar10,(int)local_c0);
  }
LAB_004d8763:
  FUN_004d80a0((int)local_c0);
  if (local_60 != 0) {
    local_64 = 0xffffffff;
  }
  return local_64;
}



/* @004d87e8 file=? name=FUN_004d87e8 */

int FUN_004d87e8(void)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  
  iVar3 = 0;
  piVar1 = &DAT_0051f800;
  iVar2 = DAT_0051fbc0;
  while (iVar2 != 0) {
    if ((*(byte *)((int)piVar1 + 0x12) & 3) != 0) {
      FUN_004d6b9c(piVar1);
      iVar3 = iVar3 + 1;
    }
    piVar1 = piVar1 + 6;
    iVar2 = iVar2 + -1;
  }
  return iVar3;
}



/* @004d8834 file=? name=FUN_004d8834 */

uint __cdecl FUN_004d8834(uint param_1)

{
  uint uVar1;
  DWORD DVar2;
  DWORD DVar3;
  DWORD DVar4;
  
  if (param_1 < DAT_0051fbc0) {
    if (((&DAT_0051fbc4)[param_1] & 0x200) == 0) {
      if (((&DAT_0051fbc4)[param_1] & 0x2000) == 0) {
        DVar2 = FUN_004d9334(param_1,0,1);
        if (DVar2 == 0xffffffff) {
          uVar1 = 0xffffffff;
        }
        else {
          DVar3 = FUN_004d9334(param_1,0,2);
          if (DVar3 == 0xffffffff) {
            uVar1 = 0xffffffff;
          }
          else {
            DVar4 = FUN_004d9334(param_1,DVar2,0);
            if (DVar4 == 0xffffffff) {
              uVar1 = 0xffffffff;
            }
            else {
              uVar1 = (uint)((int)DVar3 <= (int)DVar2);
            }
          }
        }
      }
      else {
        uVar1 = 0;
      }
    }
    else {
      uVar1 = 1;
    }
  }
  else {
    uVar1 = FUN_004d9148(-6);
  }
  return uVar1;
}



