/* @0047c1f0 file=? name=FUN_0047c1f0 */

undefined4 __cdecl FUN_0047c1f0(int param_1)

{
  int iVar1;
  undefined4 *puVar2;
  undefined4 uVar3;
  int local_20 [7];
  
  FUN_0041d66c(param_1);
  iVar1 = *(int *)(DAT_004efc94 + 0x2c);
  FUN_0042939c(local_20,iVar1);
  while( true ) {
    puVar2 = (undefined4 *)(**(code **)(local_20[0] + 0x28))(local_20);
    if (puVar2 == (undefined4 *)0x0) break;
    FUN_00428fdc(iVar1,(int)puVar2);
    if (puVar2 != (undefined4 *)0x0) {
      (**(code **)*puVar2)(puVar2,3);
    }
  }
  uVar3 = 1;
  FUN_004293c0(local_20,2);
  return uVar3;
}



/* @0047c260 file=? name=FUN_0047c260 */

undefined4 FUN_0047c260(void)

{
  return 0;
}



/* @0047c268 file=? name=FUN_0047c268 */

void __cdecl FUN_0047c268(int *param_1,byte param_2)

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



/* @0047c294 file=? name=FUN_0047c294 */

void __cdecl FUN_0047c294(int param_1)

{
  FUN_0041bbd8(param_1 + 0x74,3);
  return;
}



/* @0047c2ac file=? name=FUN_0047c2ac */

void __cdecl FUN_0047c2ac(int param_1)

{
  FUN_0041bbd8(param_1 + 0x74,5);
  return;
}



/* @0047c2c4 file=? name=FUN_0047c2c4 */

void __cdecl FUN_0047c2c4(int param_1,uint *param_2)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  
  if (*(int *)(param_1 + 0xd4) == 0) {
    *(undefined4 *)(param_1 + 0xd4) = 1;
    piVar1 = (int *)FUN_00414b60();
    iVar3 = *piVar1;
    iVar2 = FUN_004dcd94();
    FUN_0041acbc(*(int *)(param_1 + 0x60),2,param_1,param_2,iVar3 + iVar2);
  }
  else {
    iVar3 = FUN_0044e13c(param_1);
    FUN_0044fa6c(iVar3,*(int **)(param_1 + 0x18));
    *(undefined4 *)(param_1 + 0x18) = 0;
    FUN_0047b864(param_1);
  }
  return;
}



/* @0047c380 file=? name=FUN_0047c380 */

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

{
  undefined4 *puVar1;
  
  if (*(int *)(param_3 + 4) != 5) {
    if (*(int *)(param_3 + 4) != 6) goto LAB_0047c3e7;
    if (param_1[0x35] != 0) {
      puVar1 = (undefined4 *)FUN_00414b60();
      param_2[3] = *puVar1;
      FUN_0044f7f4((int *)param_1[6],param_2);
      goto LAB_0047c3e7;
    }
  }
  puVar1 = (undefined4 *)FUN_00414b60();
  param_2[3] = *puVar1;
  FUN_0044f7f4((int *)param_1[6],param_2);
LAB_0047c3e7:
  FUN_0041d59c(param_1,param_2,param_3);
  return;
}



/* @0047c3fc file=? name=FUN_0047c3fc */

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

{
  FUN_0047b410(param_1,param_2,param_3,0x3eb,&DAT_004fd9a8);
  *param_1 = &PTR_FUN_004fdb24;
  param_1[0x35] = 0;
  return param_1;
}



/* @0047c434 file=? name=FUN_0047c434 */

undefined4 FUN_0047c434(void)

{
  return 0;
}



/* @0047c43c file=? name=FUN_0047c43c */

undefined4 * FUN_0047c43c(void)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x44);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0047bd48(puVar1);
  }
  return puVar1;
}



/* @0047c45c file=? name=FUN_0047c45c */

int * FUN_0047c45c(void)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00402298(0x80);
  if (piVar1 == (int *)0x0) {
    piVar1 = (int *)0x0;
  }
  else {
    piVar1 = FUN_0047bdd4(piVar1);
  }
  return piVar1;
}



/* @0047c480 file=? name=FUN_0047c480 */

void __cdecl FUN_0047c480(int *param_1)

{
  int iVar1;
  
  FUN_0044e1b0(param_1);
  FUN_0045046c(param_1[8]);
  iVar1 = FUN_0044e13c((int)param_1);
  iVar1 = FUN_0044f9c4(iVar1);
  param_1[6] = iVar1;
  return;
}



/* @0047c4b0 file=? name=FUN_0047c4b0 */

void FUN_0047c4b0(void)

{
  return;
}



/* @0047c4b8 file=? name=FUN_0047c4b8 */

undefined4 FUN_0047c4b8(void)

{
  return 0;
}



/* @0047c4c0 file=? name=FUN_0047c4c0 */

undefined4 FUN_0047c4c0(void)

{
  return 0;
}



/* @0047c4c8 file=? name=FUN_0047c4c8 */

undefined4 FUN_0047c4c8(void)

{
  return 0;
}



/* @0047c4d0 file=? name=FUN_0047c4d0 */

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

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



/* @0047c500 file=? name=FUN_0047c500 */

undefined4 FUN_0047c500(void)

{
  return 0;
}



/* @0047c508 file=? name=FUN_0047c508 */

undefined4 __cdecl FUN_0047c508(int param_1)

{
  undefined4 uVar1;
  
  (**(code **)(**(int **)(param_1 + 0x3c) + 0x18))(*(int **)(param_1 + 0x3c));
  if ((*(int *)(param_1 + 0x70) == 0) || (DAT_004efc98 != 0)) {
    uVar1 = 0;
  }
  else {
    uVar1 = 1;
  }
  return uVar1;
}



/* @0047c538 file=? name=FUN_0047c538 */

void __cdecl FUN_0047c538(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_0041d8a8(*(int **)(param_1 + 0x20));
  if (iVar1 == 0) {
    FUN_0041b07c(*(int *)(param_1 + 0x60),2);
  }
  return;
}



/* @0047c560 file=? name=FUN_0047c560 */

undefined4 __cdecl FUN_0047c560(int param_1)

{
  undefined4 uVar1;
  
  FUN_0044e6e8(param_1);
  if ((DAT_004efc98 == 0) && (*(int *)(param_1 + 0xd4) == 0)) {
    uVar1 = 1;
  }
  else {
    uVar1 = 0;
  }
  return uVar1;
}



/* @0047c590 file=? name=FUN_0047c590 */

void __cdecl FUN_0047c590(int *param_1,byte param_2)

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



/* @0047c5bc file=? name=FUN_0047c5bc */

void __cdecl FUN_0047c5bc(int param_1)

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



/* @0047c5d8 file=? name=FUN_0047c5d8 */

undefined4 * __cdecl FUN_0047c5d8(undefined4 *param_1)

{
  FUN_0044dd08(param_1,0x48);
  *param_1 = &PTR_FUN_004fdb04;
  return param_1;
}



/* @0047c5f8 file=munga_l4/l4splr.cpp name=FUN_0047c5f8 */

void FUN_0047c5f8(void)

{
  FUN_0040385c(s_SpoolerTask__DispatchPacket___sh_004fda65,
               s_d__tesla_bt_munga_l4_L4SPLR_CPP_004fda96,0x29e);
  return;
}



/* @0047c614 file=munga_l4/l4splr.cpp name=FUN_0047c614 */

undefined4 FUN_0047c614(void)

{
  FUN_0040385c(s_SpoolerTask__GetTimeBias___shoul_004fdab6,
               s_d__tesla_bt_munga_l4_L4SPLR_CPP_004fdae4,0x2a6);
  return 0;
}



/* @0047c634 file=? name=FUN_0047c634 */

void __cdecl FUN_0047c634(int *param_1)

{
  int *piVar1;
  int iVar2;
  int iVar3;
  int iVar4;
  int *piVar5;
  
  piVar5 = *(int **)(DAT_004efc94 + 0x18);
  if (piVar5 != (int *)0x0) {
    iVar2 = *(int *)(DAT_004efc94 + 0x88);
    if (iVar2 == 1) {
      piVar1 = (int *)(**(code **)*piVar5)(piVar5);
      while (*piVar1 == 0) {
        FUN_0044f850(piVar5);
        (**(code **)(*param_1 + 0x18))(param_1,piVar1);
        piVar1 = (int *)(**(code **)*piVar5)(piVar5);
      }
    }
    else {
      if (iVar2 != 2) {
        if (iVar2 - 4U < 2) {
          while( true ) {
            iVar3 = (**(code **)*piVar5)(piVar5);
            iVar2 = *(int *)(iVar3 + 0xc);
            iVar4 = (**(code **)(*param_1 + 0x1c))(param_1);
            piVar1 = (int *)FUN_00414b60();
            if (*piVar1 < iVar2 + iVar4) {
              return;
            }
            FUN_0044f850(piVar5);
            (**(code **)(*param_1 + 0x18))(param_1,iVar3);
            piVar5 = *(int **)(DAT_004efc94 + 0x18);
            if (piVar5 == (int *)0x0) break;
            iVar2 = (**(code **)(*piVar5 + 4))(piVar5);
            if (iVar2 == 0) {
              return;
            }
          }
          return;
        }
        if (iVar2 - 4U != 7) {
          return;
        }
      }
      piVar1 = (int *)(**(code **)*piVar5)(piVar5);
      while ((*piVar1 != 4 && (iVar2 = (**(code **)(*piVar5 + 4))(piVar5), iVar2 != 0))) {
        FUN_0044f850(piVar5);
        (**(code **)(*param_1 + 0x18))(param_1,piVar1);
        piVar1 = (int *)(**(code **)*piVar5)(piVar5);
      }
    }
  }
  return;
}



/* @0047c734 file=? name=FUN_0047c734 */

void __cdecl FUN_0047c734(int *param_1,byte param_2)

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



/* @0047c7e8 file=? name=FUN_0047c7e8 */

undefined8 __cdecl FUN_0047c7e8(int param_1,int param_2)

{
  undefined1 uVar1;
  undefined8 uVar2;
  
  uVar1 = 0x3c;
  if (param_2 == 0) {
    uVar1 = 0;
  }
  uVar2 = FUN_00476568(param_1,0x39,uVar1);
  return uVar2;
}



/* @0047c80c file=? name=FUN_0047c80c */

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

{
  int iVar1;
  
  FUN_0044fafc(param_1,param_2,0);
  *param_1 = &PTR_FUN_004fdd54;
  param_1[0x10] = param_3;
  param_1[10] = *(undefined4 *)(DAT_004efc94 + 0x3c);
  param_1[0xe] = 0xffffffff;
  param_1[0xf] = 0xffffffff;
  param_1[0x12] = 0;
  param_1[0xb] = 0;
  param_1[0xc] = 0;
  param_1[9] = 0;
  iVar1 = FUN_004dee74(s_L4INTERCOM_004fdcb5);
  if (iVar1 == 0) {
    param_1[0x15] = 0xfffffffe;
  }
  else {
    FUN_0047ca28((int)param_1);
  }
  return param_1;
}



/* @0047c880 file=? name=FUN_0047c880 */

void __cdecl FUN_0047c880(int *param_1,byte param_2)

{
  int *piVar1;
  
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004fdd54;
    (**(code **)(*param_1 + 8))(param_1,0);
    FUN_0047c7e8(param_1[10],0);
    if (param_1[0x15] == -1) {
      piVar1 = (int *)FUN_00402298(0x20);
      if (piVar1 == (int *)0x0) {
        piVar1 = (int *)0x0;
      }
      else {
        piVar1 = FUN_00403e84(piVar1,s_FAILURE_LOG_004fdcc0,1);
      }
      FUN_00404298((int)piVar1,s_Intercom_004fdccc,s_seekError_004fdcd5,1);
      FUN_00403ecc(piVar1,3);
    }
    FUN_0044fb40(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0047c918 file=? name=FUN_0047c918 */

undefined4 FUN_0047c918(void)

{
  FUN_0044fb84();
  return 1;
}



/* @0047c92c file=? name=FUN_0047c92c */

void __cdecl FUN_0047c92c(int param_1,undefined4 param_2)

{
  if ((*(int *)(param_1 + 0x54) != -2) && (*(int *)(param_1 + 0x54) != -1)) {
    FUN_0044fc00(param_1,param_2);
  }
  return;
}



/* @0047c94c file=? name=FUN_0047c94c */

undefined8 __fastcall FUN_0047c94c(undefined4 param_1,int param_2,int param_3,undefined4 param_4)

{
  undefined1 uVar1;
  int iVar2;
  undefined8 uVar3;
  
  iVar2 = *(int *)(param_3 + 0x54);
  if (iVar2 == 3) {
    FUN_0044fc8c(param_3,param_4);
    iVar2 = *(int *)(param_3 + 0x1c);
    param_2 = *(int *)(param_3 + 0x48);
    if (iVar2 != param_2) {
      *(int *)(param_3 + 0x48) = iVar2;
      uVar1 = 0x3c;
      if (*(int *)(param_3 + 0x1c) == 0) {
        uVar1 = 0;
      }
      FUN_00476568(*(int *)(param_3 + 0x28),0x3b,uVar1);
      uVar1 = 0x3c;
      if (*(int *)(param_3 + 0x1c) == 0) {
        uVar1 = 0x14;
      }
      uVar3 = FUN_00476568(*(int *)(param_3 + 0x28),0x20,uVar1);
      param_2 = (int)((ulonglong)uVar3 >> 0x20);
      iVar2 = (int)uVar3;
    }
  }
  return CONCAT44(param_2,iVar2);
}



/* @0047c9b4 file=? name=FUN_0047c9b4 */

void __cdecl FUN_0047c9b4(int *param_1,int param_2)

{
  if ((param_2 != 0) && (param_1[8] == 0)) {
    FUN_0044fd14(param_1,param_2);
    FUN_00476568(param_1[10],0x20,0);
    FUN_0047cdc0((int)param_1,0);
  }
  if ((param_2 == 0) && (param_1[8] != 0)) {
    FUN_0044fd14(param_1,0);
    FUN_0047cdc0((int)param_1,1);
    param_1[0x12] = 2;
    (**(code **)(*param_1 + 8))(param_1,param_1[7]);
  }
  return;
}



/* @0047ca28 file=? name=FUN_0047ca28 */

void __cdecl FUN_0047ca28(int param_1)

{
  *(undefined4 *)(param_1 + 0x50) = 0;
  *(undefined4 *)(param_1 + 0x34) = 0;
  *(undefined4 *)(param_1 + 0x44) = 0x54;
  FUN_0047cdc0(param_1,0);
  FUN_0047c7e8(*(int *)(param_1 + 0x28),0);
  *(undefined4 *)(param_1 + 0x54) = 0;
  return;
}



/* @0047ca64 file=? name=FUN_0047ca64 */

int __cdecl FUN_0047ca64(int param_1,float param_2)

{
  int iVar1;
  int iVar2;
  int extraout_ECX;
  int *piVar3;
  int extraout_EDX;
  int extraout_EDX_00;
  int iVar4;
  undefined8 uVar5;
  
  iVar2 = *(int *)(param_1 + 0x54);
  if ((iVar2 != -2) && (iVar2 != -1)) {
    if (iVar2 == 3) {
      if (*(int *)(param_1 + 0x24) < 1) {
        if (*(int *)(param_1 + 0x24) < 0) {
          FUN_0044fc1c(param_1,0);
          *(undefined4 *)(param_1 + 0x24) = 0;
        }
      }
      else {
        FUN_0044fc1c(param_1,1);
        *(undefined4 *)(param_1 + 0x24) = 0;
      }
    }
    else if (*(int *)(param_1 + 0x48) != 0) {
      FUN_0044fc1c(param_1,0);
    }
    iVar2 = 0;
    if ((*(int *)(param_1 + 0x4c) != 0) && (iVar2 = *(int *)(param_1 + 0x30), 0 < iVar2)) {
      iVar4 = -1;
      iVar1 = 0;
      piVar3 = &DAT_004fdc20;
      do {
        if (iVar2 + -1 == *piVar3) {
          iVar4 = *(int *)(param_1 + 0x40) + iVar1;
          break;
        }
        iVar1 = iVar1 + 1;
        piVar3 = piVar3 + 1;
      } while (iVar1 < 7);
      if (iVar4 != -1) {
        FUN_0044fb98(param_1,iVar4);
      }
      iVar2 = 0;
      *(undefined4 *)(param_1 + 0x30) = 0;
    }
    if (*(int *)(param_1 + 0x50) != 0) {
      iVar2 = FUN_0047ca28(param_1);
    }
    *(float *)(param_1 + 0x34) = param_2 + *(float *)(param_1 + 0x34);
    switch(*(undefined4 *)(param_1 + 0x54)) {
    case 0:
      iVar1 = FUN_0047cca0(param_1,0.28);
      iVar2 = 0;
      if (iVar1 != 0) {
        *(int *)(param_1 + 0x44) = *(int *)(param_1 + 0x44) + -1;
        iVar2 = *(int *)(param_1 + 0x44);
        if (iVar2 < 1) {
          *(undefined4 *)(param_1 + 0x54) = 0xffffffff;
          *(undefined4 *)(param_1 + 0x14) = 0xffffffff;
        }
        else if (*(int *)(param_1 + 0x2c) < 1) {
          uVar5 = FUN_0047cd10(param_1);
          iVar2 = (int)uVar5;
        }
        else {
          *(undefined4 *)(param_1 + 0x38) = 0x27;
          *(undefined4 *)(param_1 + 0x54) = 2;
          (**(code **)(**(int **)(DAT_004efc94 + 0x4c) + 0x50))
                    (*(int **)(DAT_004efc94 + 0x4c),s_intercomEnable_004fdcdf,0);
          iVar2 = *(int *)(param_1 + 0x20);
          if (iVar2 == 0) {
            FUN_0047cdc0(param_1,1);
            FUN_0044fb98(param_1,*(undefined4 *)(param_1 + 0x40));
            iVar2 = extraout_ECX;
            iVar1 = extraout_EDX_00;
          }
          else {
            *(undefined4 *)(param_1 + 0x18) = *(undefined4 *)(param_1 + 0x40);
            iVar1 = extraout_EDX;
          }
          uVar5 = FUN_0047cd58(iVar2,iVar1,param_1);
          iVar2 = (int)uVar5;
        }
      }
      break;
    case 1:
      iVar1 = FUN_0047cca0(param_1,0.05);
      iVar2 = 0;
      if (iVar1 != 0) {
        iVar2 = *(int *)(param_1 + 0x14) - *(int *)(param_1 + 0x38);
        if (iVar2 == 0) {
          *(undefined4 *)(param_1 + 0x54) = 2;
          iVar2 = 0;
        }
        else {
          if (iVar2 < 0x15) {
            if (iVar2 < -0x14) {
              iVar2 = iVar2 + 0x28;
            }
          }
          else {
            iVar2 = iVar2 + -0x28;
          }
          iVar1 = param_1;
          if (iVar2 < 0) {
            uVar5 = FUN_0047cd10(param_1);
            iVar2 = (int)((ulonglong)uVar5 >> 0x20);
          }
          else {
            uVar5 = FUN_0047ccc4(param_1);
            iVar2 = (int)((ulonglong)uVar5 >> 0x20);
          }
          uVar5 = FUN_0047cd58(iVar1,iVar2,param_1);
          iVar2 = (int)uVar5;
        }
      }
      break;
    case 2:
      iVar1 = FUN_0047cca0(param_1,0.2);
      iVar2 = 0;
      if (iVar1 != 0) {
        uVar5 = FUN_0047c7e8(*(int *)(param_1 + 0x28),1);
        iVar2 = (int)uVar5;
        *(undefined4 *)(param_1 + 0x54) = 3;
      }
      break;
    case 3:
      iVar2 = *(int *)(param_1 + 0x14);
      if (iVar2 != *(int *)(param_1 + 0x38)) {
        *(undefined4 *)(param_1 + 0x54) = 1;
        *(undefined4 *)(param_1 + 0x34) = 0x3d4ccccd;
        uVar5 = FUN_0047c7e8(*(int *)(param_1 + 0x28),0);
        iVar2 = (int)uVar5;
      }
    }
  }
  return iVar2;
}



/* @0047cca0 file=? name=FUN_0047cca0 */

undefined4 __cdecl FUN_0047cca0(int param_1,float param_2)

{
  if (param_2 <= *(float *)(param_1 + 0x34)) {
    *(undefined4 *)(param_1 + 0x34) = 0;
    return 1;
  }
  return 0;
}



/* @0047ccc4 file=? name=FUN_0047ccc4 */

undefined8 __cdecl FUN_0047ccc4(int param_1)

{
  undefined8 uVar1;
  
  *(int *)(param_1 + 0x38) = *(int *)(param_1 + 0x38) + 1;
  if (0x27 < *(int *)(param_1 + 0x38)) {
    *(undefined4 *)(param_1 + 0x38) = 0;
  }
  FUN_00476568(*(int *)(param_1 + 0x28),0x3a,0x3c);
  FUN_00476568(*(int *)(param_1 + 0x28),0x3a,0x3c);
  uVar1 = FUN_00476568(*(int *)(param_1 + 0x28),0x3a,0);
  return uVar1;
}



/* @0047cd10 file=? name=FUN_0047cd10 */

undefined8 __cdecl FUN_0047cd10(int param_1)

{
  int *piVar1;
  undefined8 uVar2;
  
  piVar1 = (int *)(param_1 + 0x38);
  *piVar1 = *piVar1 + -1;
  if (*piVar1 < 0) {
    *(undefined4 *)(param_1 + 0x38) = 0x27;
  }
  FUN_00476568(*(int *)(param_1 + 0x28),0x38,0x3c);
  FUN_00476568(*(int *)(param_1 + 0x28),0x38,0x3c);
  uVar2 = FUN_00476568(*(int *)(param_1 + 0x28),0x38,0);
  return uVar2;
}



/* @0047cd58 file=? name=FUN_0047cd58 */

undefined8 __fastcall FUN_0047cd58(undefined4 param_1,int param_2,int param_3)

{
  int iVar1;
  undefined8 uVar2;
  
  iVar1 = 0;
  if ((*(int *)(param_3 + 0x4c) != 0) &&
     (iVar1 = *(int *)(param_3 + 0x3c), iVar1 != *(int *)(param_3 + 0x38))) {
    if ((iVar1 != -1) && (iVar1 = iVar1 - *(int *)(param_3 + 0x40), iVar1 < 7)) {
      uVar2 = FUN_00476568(*(int *)(param_3 + 0x28),(&DAT_004fdc20)[iVar1],0x14);
      param_2 = (int)((ulonglong)uVar2 >> 0x20);
    }
    *(int *)(param_3 + 0x3c) = *(int *)(param_3 + 0x38);
    iVar1 = 0;
    if (*(int *)(param_3 + 0x38) != -1) {
      param_2 = *(int *)(param_3 + 0x40);
      iVar1 = *(int *)(param_3 + 0x38) - param_2;
      if (iVar1 < 7) {
        uVar2 = FUN_00476568(*(int *)(param_3 + 0x28),(&DAT_004fdc20)[iVar1],0x3c);
        param_2 = (int)((ulonglong)uVar2 >> 0x20);
        iVar1 = (int)uVar2;
      }
    }
  }
  return CONCAT44(param_2,iVar1);
}



/* @0047cdc0 file=? name=FUN_0047cdc0 */

undefined8 __cdecl FUN_0047cdc0(int param_1,int param_2)

{
  undefined1 uVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined8 uVar4;
  
  if ((param_2 == -2) || (param_2 == -1)) {
    iVar2 = 0;
    *(undefined4 *)(param_1 + 0x4c) = 0;
    puVar3 = &DAT_004fdc20;
    do {
      uVar4 = FUN_00476568(*(int *)(param_1 + 0x28),*puVar3,0);
      iVar2 = iVar2 + 1;
      puVar3 = puVar3 + 1;
    } while (iVar2 < 7);
  }
  else {
    *(undefined4 *)(param_1 + 0x4c) = 1;
    iVar2 = 0;
    puVar3 = &DAT_004fdc20;
    do {
      uVar1 = 0x3c;
      if (*(int *)(param_1 + 0x38) - *(int *)(param_1 + 0x40) != iVar2) {
        uVar1 = 0x14;
      }
      uVar4 = FUN_00476568(*(int *)(param_1 + 0x28),*puVar3,uVar1);
      iVar2 = iVar2 + 1;
      puVar3 = puVar3 + 1;
    } while (iVar2 < 7);
  }
  return uVar4;
}



/* @0047ce3c file=? name=FUN_0047ce3c */

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

{
  undefined4 *puVar1;
  
  FUN_0044fd64(param_1,param_2);
  *param_1 = &PTR_FUN_004fdd28;
  FUN_0047d062(param_1 + 0xb,0);
  puVar1 = (undefined4 *)FUN_00414b60();
  param_1[10] = *puVar1;
  return param_1;
}



/* @0047ce7c file=? name=FUN_0047ce7c */

void __cdecl FUN_0047ce7c(int *param_1,byte param_2)

{
  if (param_1 != (int *)0x0) {
    *param_1 = (int)&PTR_FUN_004fdd28;
    FUN_0047d081(param_1 + 0xb,2);
    FUN_0044fd9c(param_1,0);
    if ((param_2 & 1) != 0) {
      FUN_004022d0(param_1);
    }
  }
  return;
}



/* @0047ceb8 file=? name=FUN_0047ceb8 */

void __cdecl FUN_0047ceb8(int param_1)

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



/* @0047ced4 file=? name=FUN_0047ced4 */

undefined4 * __cdecl FUN_0047ced4(int param_1,int param_2)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00402298(0x58);
  if (puVar1 == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1 = FUN_0047c80c(puVar1,param_2,0);
  }
  (**(code **)(*(int *)(param_1 + 0x18) + 4))(param_1 + 0x18,puVar1);
  if (*(int *)(*(int *)(*(int *)(DAT_004efc94 + 0x2c) + 0x14) + 0xc) == param_2) {
    (**(code **)(*(int *)(param_1 + 0x2c) + 4))(param_1 + 0x2c,puVar1);
  }
  return puVar1;
}



/* @0047cf3c file=? name=FUN_0047cf3c */

void FUN_0047cf3c(void)

{
  FUN_0044fdfc();
  return;
}



/* @0047cf54 file=? name=FUN_0047cf54 */

void __cdecl FUN_0047cf54(int param_1)

{
  FUN_0044fe04(param_1);
  return;
}



/* @0047cf64 file=? name=FUN_0047cf64 */

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

void __cdecl FUN_0047cf64(int param_1)

{
  float fVar1;
  int iVar2;
  int *piVar3;
  
  if (0 < DAT_0052331c) {
    DAT_0052331c = 0;
    iVar2 = FUN_00417ab4(param_1 + 0x2c);
    if (iVar2 != 0) {
      FUN_004dbb24(&DAT_00524e20,s_L4IcomManager__Execute__Reset____004fdcfc,(char *)0x0);
      FUN_0047ca28(iVar2);
    }
  }
  piVar3 = (int *)FUN_00414b60();
  fVar1 = (float)(*piVar3 - *(int *)(param_1 + 0x28)) / DAT_0052140c;
  if (_DAT_0047d004 < fVar1) {
    *(int *)(param_1 + 0x28) = *piVar3;
    iVar2 = FUN_00417ab4(param_1 + 0x2c);
    if (iVar2 != 0) {
      FUN_0047ca64(iVar2,fVar1);
    }
  }
  return;
}



/* @0047d062 file=? name=FUN_0047d062 */

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

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



/* @0047d081 file=? name=FUN_0047d081 */

void __cdecl FUN_0047d081(int *param_1,byte param_2)

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



/* @0047d0b0 file=? name=FUN_0047d0b0 */

undefined8 __fastcall FUN_0047d0b0(undefined4 param_1,undefined4 param_2)

{
  code *pcVar1;
  undefined4 unaff_retaddr;
  
  pcVar1 = (code *)swi(0x31);
  DAT_004fdd64 = (*pcVar1)(param_2);
  return CONCAT44(param_1,unaff_retaddr);
}



/* @0047d0ce file=? name=FUN_0047d0ce */

undefined8 __fastcall FUN_0047d0ce(undefined4 param_1,undefined4 param_2)

{
  short *psVar1;
  undefined1 *puVar2;
  undefined2 uVar3;
  undefined4 in_EAX;
  uint uVar4;
  undefined1 *puVar5;
  short sVar6;
  
  uVar3 = DAT_004fdd64;
  psVar1 = (short *)segment(DAT_004fdd64,DAT_00522b94);
  uVar4 = (uint)(ushort)(*psVar1 + 6);
  puVar5 = DAT_00522b88;
  sVar6 = DAT_00522b92;
  do {
    puVar2 = (undefined1 *)segment(uVar3,sVar6);
    *puVar5 = *puVar2;
    sVar6 = sVar6 + 1;
    puVar5 = puVar5 + 1;
    uVar4 = uVar4 - 1;
  } while (uVar4 != 0 && puVar5 != (undefined1 *)0x0);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d10f file=? name=FUN_0047d10f */

undefined8 __fastcall FUN_0047d10f(undefined4 param_1,undefined4 param_2)

{
  uint *puVar1;
  undefined2 uVar2;
  undefined4 in_EAX;
  uint uVar3;
  byte *pbVar4;
  short sVar5;
  
  uVar2 = DAT_004fdd64;
  uVar3 = (uint)(ushort)(*DAT_00522b84 + 6);
  pbVar4 = DAT_00522b88;
  sVar5 = DAT_00522b92;
  do {
    puVar1 = (uint *)segment(uVar2,sVar5);
    *puVar1 = (uint)*pbVar4;
    sVar5 = sVar5 + 1;
    pbVar4 = pbVar4 + 1;
    uVar3 = uVar3 - 1;
  } while (uVar3 != 0 && pbVar4 != (byte *)0x0);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d14d file=? name=FUN_0047d14d */

undefined8 __fastcall FUN_0047d14d(undefined4 param_1,undefined4 param_2)

{
  undefined1 *puVar1;
  undefined2 uVar2;
  undefined4 in_EAX;
  int iVar3;
  undefined1 *puVar4;
  short sVar5;
  
  uVar2 = DAT_004fdd64;
  iVar3 = 6;
  puVar4 = DAT_004f0760;
  sVar5 = DAT_00522b8c;
  do {
    puVar1 = (undefined1 *)segment(uVar2,sVar5);
    *puVar4 = *puVar1;
    sVar5 = sVar5 + 1;
    puVar4 = puVar4 + 1;
    iVar3 = iVar3 + -1;
  } while (iVar3 != 0 && puVar4 != (undefined1 *)0x0);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d184 file=? name=FUN_0047d184 */

undefined8 __cdecl
FUN_0047d184(short *param_1,undefined2 param_2,undefined1 param_3,short param_4,short param_5)

{
  code *pcVar1;
  byte bVar2;
  undefined2 extraout_CX;
  int iVar3;
  short sVar4;
  undefined *extraout_EDX;
  undefined2 uVar5;
  undefined4 unaff_EBX;
  undefined **ppuVar6;
  undefined2 in_DS;
  undefined1 uVar7;
  bool bVar8;
  undefined4 unaff_retaddr;
  
  pcVar1 = (code *)swi(0x31);
  DAT_004fdd68 = in_DS;
  (*pcVar1)();
  *(undefined2 *)((int)param_1 + 0x411) = 0;
  *(undefined2 *)((int)param_1 + 0x413) = 0;
  *(undefined2 *)((int)param_1 + 0x415) = 0;
  *(undefined2 *)((int)param_1 + 0xb) = 0;
  *(undefined2 *)((int)param_1 + 0xd) = 0;
  *(undefined2 *)((int)param_1 + 0xf) = 0;
  uVar7 = false;
  bVar8 = true;
  *(undefined1 *)(param_1 + 2) = 0;
  param_1[1] = 0;
  *(undefined1 *)((int)param_1 + 5) = 0;
  *(undefined1 *)(param_1 + 3) = 0;
  *(undefined4 *)((int)param_1 + 7) = 0;
  *param_1 = param_4;
  iVar3 = 4;
  ppuVar6 = &PTR_LAB_004fdd6a;
  do {
    if (bVar8) {
      *(short *)((int)ppuVar6 + 0xe) = param_4;
      *(char *)(ppuVar6 + 4) = (char)param_5;
      ppuVar6[1] = (undefined *)param_1;
      *(undefined ***)((int)param_1 + 7) = ppuVar6;
      pcVar1 = (code *)swi(0x31);
      (*pcVar1)();
      *(undefined2 *)(ppuVar6 + 3) = extraout_CX;
      ppuVar6[2] = extraout_EDX;
      pcVar1 = (code *)swi(0x31);
      (*pcVar1)();
      if ((bool)uVar7) {
        param_1[1] = 0x100;
      }
      else {
        bVar2 = in(param_4 + 3);
        out(param_4 + 3,bVar2 | 0x80);
        out(param_4,(char)param_2);
        out(param_4 + 1,(char)((ushort)param_2 >> 8));
        sVar4 = param_4 + 3;
        bVar2 = in(sVar4);
        out(sVar4,bVar2 & 0x7f);
        out(sVar4,param_3);
        if (param_5 == 0xc) {
          uVar5 = 0x6410;
        }
        else {
          uVar5 = 0x6308;
        }
        *(byte *)((int)ppuVar6 + 0x11) = (byte)uVar5;
        bVar2 = in(0x21);
        out(0x21,bVar2 & ~(byte)uVar5);
        out(0x20,(char)((ushort)uVar5 >> 8));
        DAT_004fddbc = in(param_4 + 2);
        bVar2 = in(param_4 + 4);
        out(param_4 + 4,bVar2 & 0xf7);
        sVar4 = param_4 + 1;
        bVar2 = in(sVar4);
        out(sVar4,bVar2 & 0xf0);
        bVar2 = in(sVar4);
        out(sVar4,bVar2 | 0xf);
        bVar2 = in(param_4 + 4);
        out(param_4 + 4,bVar2 | 0xb);
        in(param_4);
        in(param_4);
        in(param_4 + 6);
        DAT_004fddba = in(param_4 + 5);
        DAT_004fddbb = in(sVar4);
        *(undefined1 *)(param_1 + 2) = 1;
      }
      goto LAB_0047d317;
    }
    uVar7 = (undefined **)0xffffffeb < ppuVar6;
    ppuVar6 = ppuVar6 + 5;
    bVar8 = ppuVar6 == (undefined **)0x0;
    iVar3 = iVar3 + -1;
  } while (iVar3 != 0);
  param_1[1] = 0x100;
LAB_0047d317:
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return CONCAT44(unaff_EBX,unaff_retaddr);
}



/* @0047d324 file=? name=FUN_0047d324 */

void __fastcall FUN_0047d324(undefined4 param_1,undefined4 param_2,short *param_3)

{
  int iVar1;
  code *pcVar2;
  byte bVar3;
  
  pcVar2 = (code *)swi(0x31);
  (*pcVar2)();
  if (param_3 != (short *)0x0) {
    bVar3 = in(*param_3 + 4);
    out(*param_3 + 4,bVar3 & 0xf4);
    iVar1 = *(int *)((int)param_3 + 7);
    if (iVar1 != 0) {
      *(undefined2 *)(iVar1 + 0xe) = 0;
      pcVar2 = (code *)swi(0x31);
      (*pcVar2)();
      bVar3 = in(0x21);
      out(0x21,bVar3 | *(byte *)(iVar1 + 0x11));
    }
  }
  pcVar2 = (code *)swi(0x31);
  (*pcVar2)(param_2,param_1);
  return;
}



/* @0047d3fd file=? name=FUN_0047d3fd */

undefined8 __fastcall FUN_0047d3fd(undefined4 param_1,undefined4 param_2,int param_3,int param_4)

{
  undefined4 in_EAX;
  
  if (param_3 != 0) {
    if (param_4 == 0) {
      *(undefined1 *)(param_3 + 6) = 1;
    }
    else {
      *(undefined1 *)(param_3 + 6) = 0;
    }
  }
  return CONCAT44(param_2,in_EAX);
}



/* @0047d428 file=? name=FUN_0047d428 */

undefined8 __fastcall
FUN_0047d428(undefined4 param_1,undefined4 param_2,short *param_3,undefined1 *param_4,int param_5)

{
  undefined1 uVar1;
  ushort uVar2;
  code *pcVar3;
  undefined4 in_EAX;
  int extraout_ECX;
  int iVar4;
  ushort *puVar5;
  
  if (((param_3 != (short *)0x0) && ((char)param_3[2] != '\0')) && (param_5 < 0x400)) {
    do {
    } while ((ushort)(0x400U - *(short *)((int)param_3 + 0xf)) < (ushort)param_5);
    pcVar3 = (code *)swi(0x31);
    (*pcVar3)();
    iVar4 = extraout_ECX;
    do {
      uVar1 = *param_4;
      param_4 = param_4 + 1;
      puVar5 = (ushort *)((int)param_3 + 0xb);
      uVar2 = *puVar5;
      *(undefined1 *)((int)puVar5 + uVar2 + 6) = uVar1;
      *puVar5 = uVar2 + 1 & 0x3ff;
      puVar5[2] = puVar5[2] + 1;
      iVar4 = iVar4 + -1;
    } while (iVar4 != 0);
    FUN_0047d5a2(0,*param_3);
    pcVar3 = (code *)swi(0x31);
    (*pcVar3)(param_2,param_1);
  }
  return CONCAT44(param_2,in_EAX);
}



/* @0047d4a3 file=? name=FUN_0047d4a3 */

undefined8 __fastcall FUN_0047d4a3(undefined4 param_1,undefined4 param_2,short *param_3)

{
  byte bVar1;
  uint uVar2;
  
  uVar2 = 0;
  if (param_3 != (short *)0x0) {
    bVar1 = in(*param_3 + 5);
    uVar2 = bVar1 & 0xffffff60 ^ 0x60;
  }
  return CONCAT44(param_2,uVar2);
}



/* @0047d517 file=? name=FUN_0047d517 */

undefined2 __cdecl FUN_0047d517(int param_1)

{
  return *(undefined2 *)(param_1 + 0xf);
}



/* @0047d5a2 file=? name=FUN_0047d5a2 */

byte __fastcall FUN_0047d5a2(undefined4 param_1,short param_2)

{
  short *psVar1;
  ushort uVar2;
  byte bVar3;
  int unaff_ESI;
  int iVar4;
  
  bVar3 = in(param_2 + 5);
  if (((bVar3 & 0x20) != 0) &&
     ((*(char *)(unaff_ESI + 6) != '\0' || (*(char *)(unaff_ESI + 5) != '\0')))) {
    uVar2 = *(ushort *)(unaff_ESI + 0xd);
    iVar4 = unaff_ESI + 0xb + (uint)uVar2;
    bVar3 = *(byte *)(iVar4 + 6);
    iVar4 = iVar4 - (uint)uVar2;
    *(ushort *)(iVar4 + 2) = uVar2 + 1 & 0x3ff;
    psVar1 = (short *)(iVar4 + 4);
    *psVar1 = *psVar1 + -1;
    out(param_2,bVar3);
  }
  return bVar3;
}



/* @0047d61b file=? name=FUN_0047d61b */

undefined2 __fastcall FUN_0047d61b(undefined4 param_1)

{
  ushort uVar1;
  char cVar2;
  undefined1 uVar3;
  byte bVar4;
  ushort in_AX;
  undefined1 uVar5;
  byte extraout_AH;
  undefined4 extraout_ECX;
  short sVar6;
  short extraout_DX;
  ushort *puVar7;
  int iVar8;
  int unaff_EDI;
  
  iVar8 = *(int *)(unaff_EDI + 4);
  sVar6 = *(short *)(unaff_EDI + 0xe);
  while( true ) {
    uVar5 = (undefined1)(in_AX >> 8);
    cVar2 = in(sVar6 + 2);
    in_AX = CONCAT11(uVar5,cVar2);
    if (cVar2 == '\x01') break;
    if (cVar2 == '\x04') {
      uVar3 = in(sVar6);
      in_AX = CONCAT11(uVar5,uVar3);
      puVar7 = (ushort *)(iVar8 + 0x411);
      uVar1 = *puVar7;
      *(undefined1 *)((int)puVar7 + uVar1 + 6) = uVar3;
      *puVar7 = uVar1 + 1 & 0x3ff;
      puVar7[2] = puVar7[2] + 1;
    }
    else if (cVar2 == '\x02') {
      if ((*(short *)(iVar8 + 0xf) != 0) &&
         ((*(char *)(iVar8 + 6) != '\0' || (*(char *)(iVar8 + 5) != '\0')))) {
        uVar1 = *(ushort *)(iVar8 + 0xd);
        iVar8 = iVar8 + 0xb + (uint)uVar1;
        uVar3 = *(undefined1 *)(iVar8 + 6);
        in_AX = CONCAT11(uVar5,uVar3);
        iVar8 = iVar8 - (uint)uVar1;
        *(ushort *)(iVar8 + 2) = uVar1 + 1 & 0x3ff;
        *(short *)(iVar8 + 4) = *(short *)(iVar8 + 4) + -1;
        iVar8 = iVar8 + -0xb;
        out(sVar6,uVar3);
      }
    }
    else if (cVar2 == '\0') {
      bVar4 = in(sVar6 + 6);
      in_AX = CONCAT11(uVar5,bVar4);
      if ((bVar4 & 1) != 0) {
        if ((bVar4 & 0x10) == 0) {
          *(undefined1 *)(iVar8 + 5) = 0;
        }
        else {
          *(undefined1 *)(iVar8 + 5) = 1;
          bVar4 = in(sVar6 + 5);
          in_AX = CONCAT11(uVar5,bVar4);
          if (((bVar4 & 0x20) != 0) && (*(short *)(iVar8 + 0xf) != 0)) {
            FUN_0047d5a2(param_1,sVar6);
            in_AX = (ushort)extraout_AH << 8;
            param_1 = extraout_ECX;
            sVar6 = extraout_DX;
          }
        }
      }
    }
    else {
      bVar4 = in(sVar6 + 5);
      in_AX = bVar4 & 0x1e;
      *(ushort *)(iVar8 + 2) = *(ushort *)(iVar8 + 2) | in_AX;
    }
  }
  out(0x20,0x20);
  return CONCAT11(uVar5,0x20);
}



/* @0047d70c file=? name=FUN_0047d70c */

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

undefined4 __cdecl FUN_0047d70c(uint param_1,undefined4 param_2)

{
  code *pcVar1;
  undefined4 unaff_retaddr;
  
  _DAT_004fddf4 = param_2;
  if (param_1 < 0x100) {
    _DAT_004fdddc = param_1;
  }
  else {
    _DAT_004fdddc = CONCAT22((short)(param_1 >> 0x10),0x4f02);
    _DAT_004fddd0 = param_1;
  }
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  DAT_004fddf2 = (*pcVar1)();
  return unaff_retaddr;
}



/* @0047d76d file=? name=FUN_0047d76d */

undefined6 __cdecl FUN_0047d76d(int param_1)

{
  byte bVar1;
  undefined4 in_EAX;
  
  out(0x3d4,0x11);
  bVar1 = in(0x3d5);
  out(0x3d5,bVar1 & 0x7f);
  out(0x3d4,0);
  if (param_1 == 0) {
    out(0x3d5,DAT_004fe0ff);
    DAT_004fe0fe = '\0';
  }
  else if (DAT_004fe0fe == '\0') {
    DAT_004fe0fe = '\x01';
    DAT_004fe0ff = in(0x3d5);
    out(0x3d5,DAT_004fe0ff + -9);
  }
  out(0x3d4,0x11);
  out(0x3d5,bVar1);
  return CONCAT24(0x3d5,in_EAX);
}



/* @0047d7da file=? name=FUN_0047d7da */

undefined8 __fastcall FUN_0047d7da(undefined4 param_1,undefined4 param_2,int param_3)

{
  undefined4 in_EAX;
  undefined2 uVar1;
  
  if (param_3 == 0) {
    uVar1 = 0x319;
  }
  else {
    uVar1 = 0x31a;
  }
  out(uVar1,(char)param_3);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d7f6 file=? name=FUN_0047d7f6 */

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

undefined8 __thiscall FUN_0047d7f6(void *this,uint param_1)

{
  code *pcVar1;
  undefined4 in_EAX;
  undefined4 unaff_EBP;
  
  _DAT_004fddd4 = param_1 & 0xff;
  _DAT_004fdddc = CONCAT22((short)((uint)in_EAX >> 0x10),0x4f05);
  _DAT_004fddd0 = 0;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return CONCAT44(this,unaff_EBP);
}



/* @0047d848 file=? name=FUN_0047d848 */

undefined8 __fastcall
FUN_0047d848(undefined4 param_1,undefined4 param_2,undefined2 *param_3,undefined2 *param_4,
            int param_5)

{
  int iVar1;
  int iVar2;
  bool bVar3;
  
  iVar2 = 0;
  iVar1 = 0x20;
  do {
    while( true ) {
      bVar3 = param_5 < 0;
      param_5 = param_5 << 1;
      if (bVar3) break;
      param_3 = param_3 + 1;
      iVar1 = iVar1 + -1;
      param_4 = param_4 + 1;
      if (iVar1 == 0) goto LAB_0047d881;
    }
    *param_3 = *param_4;
    iVar2 = iVar2 + 1;
    iVar1 = iVar1 + -1;
    param_4 = param_4 + 1;
    param_3 = param_3 + 1;
  } while (iVar1 != 0);
LAB_0047d881:
  return CONCAT44(param_2,iVar2);
}



/* @0047d88b file=? name=FUN_0047d88b */

undefined8 __fastcall
FUN_0047d88b(undefined4 param_1,undefined4 param_2,undefined1 *param_3,undefined2 *param_4,
            int param_5)

{
  int iVar1;
  int iVar2;
  bool bVar3;
  
  iVar2 = 0;
  iVar1 = 0x20;
  do {
    while( true ) {
      bVar3 = param_5 < 0;
      param_5 = param_5 << 1;
      if (bVar3) break;
      param_3 = param_3 + 1;
      iVar1 = iVar1 + -1;
      param_4 = param_4 + 1;
      if (iVar1 == 0) goto LAB_0047d8c1;
    }
    *param_3 = (char)*param_4;
    iVar2 = iVar2 + 1;
    iVar1 = iVar1 + -1;
    param_4 = param_4 + 1;
    param_3 = param_3 + 1;
  } while (iVar1 != 0);
LAB_0047d8c1:
  return CONCAT44(param_2,iVar2);
}



/* @0047d8cb file=? name=FUN_0047d8cb */

undefined8 __fastcall FUN_0047d8cb(undefined4 param_1,undefined4 param_2,short param_3)

{
  undefined4 in_EAX;
  int iVar1;
  
  out(param_3 + 2,0);
  iVar1 = 0x300;
  do {
    out(param_3 + 3,0);
    iVar1 = iVar1 + -1;
  } while (iVar1 != 0);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d8f2 file=? name=FUN_0047d8f2 */

undefined8 __fastcall
FUN_0047d8f2(undefined4 param_1,undefined4 param_2,byte *param_3,short param_4)

{
  undefined4 in_EAX;
  int iVar1;
  undefined1 *puVar2;
  byte *pbVar3;
  
  iVar1 = 0x300;
  pbVar3 = &DAT_004fddfe;
  do {
    *pbVar3 = *param_3 >> 2;
    iVar1 = iVar1 + -1;
    param_3 = param_3 + 1;
    pbVar3 = pbVar3 + 1;
  } while (iVar1 != 0);
  out(param_4 + 2,0);
  iVar1 = 0x300;
  puVar2 = &DAT_004fddfe;
  while (iVar1 != 0) {
    iVar1 = iVar1 + -1;
    out(*puVar2,param_4 + 3);
    puVar2 = puVar2 + 1;
  }
  return CONCAT44(param_2,in_EAX);
}



/* @0047d962 file=? name=FUN_0047d962 */

undefined8 __fastcall
FUN_0047d962(undefined4 param_1,undefined4 param_2,undefined2 param_3,undefined1 param_4)

{
  undefined4 in_EAX;
  
  out(param_3,param_4);
  return CONCAT44(param_2,in_EAX);
}



/* @0047d97c file=? name=FUN_0047d97c */

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

undefined8 __fastcall FUN_0047d97c(undefined4 param_1)

{
  code *pcVar1;
  byte bVar2;
  byte bVar3;
  byte bVar4;
  short sVar5;
  undefined2 extraout_DX;
  undefined4 unaff_EBX;
  undefined4 unaff_retaddr;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)(param_1);
  sVar5 = 0;
  out(0x201,0);
  bVar4 = DAT_004fe108;
  do {
    bVar2 = in(0x201);
    bVar2 = bVar2 & DAT_004fe108;
    bVar3 = bVar2 ^ bVar4;
    if (bVar3 != 0) {
      if ((bVar3 & 1) != 0) {
        DAT_004fe100 = sVar5;
      }
      if ((bVar3 & 2) != 0) {
        DAT_004fe102 = sVar5;
      }
      if ((bVar3 & 4) != 0) {
        _DAT_004fe104 = sVar5;
      }
      if ((bVar3 & 8) != 0) {
        DAT_004fe106 = sVar5;
      }
      bVar4 = bVar2;
      if (bVar2 == 0) break;
    }
    sVar5 = sVar5 + 1;
  } while (sVar5 != 0x800);
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  bVar4 = in(extraout_DX);
  DAT_004fe109 = ~bVar4 & 0xf0;
  return CONCAT44(unaff_EBX,unaff_retaddr);
}



/* @0047d9f4 file=? name=FUN_0047d9f4 */

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

undefined8 __cdecl
FUN_0047d9f4(short *param_1,undefined2 param_2,short param_3,short param_4,undefined4 param_5,
            undefined1 param_6,undefined4 param_7,undefined1 param_8)

{
  code *pcVar1;
  byte bVar2;
  undefined2 extraout_CX;
  int iVar3;
  short sVar4;
  undefined *extraout_EDX;
  undefined2 uVar5;
  undefined4 unaff_EBX;
  undefined **ppuVar6;
  undefined2 in_DS;
  undefined1 uVar7;
  bool bVar8;
  undefined4 local_8;
  
  local_8 = 0;
  pcVar1 = (code *)swi(0x31);
  DAT_004fe10c = in_DS;
  (*pcVar1)();
  DAT_004fe164 = 0;
  *(undefined2 *)((int)param_1 + 0x22d) = 0;
  *(undefined2 *)((int)param_1 + 0x231) = 0;
  *(undefined2 *)((int)param_1 + 0x233) = 0;
  *(undefined2 *)((int)param_1 + 0x22f) = 0;
  *(undefined2 *)((int)param_1 + 0x235) = 0;
  *(undefined2 *)((int)param_1 + 0x237) = 0;
  *(undefined2 *)((int)param_1 + 0x239) = 0;
  *(undefined2 *)((int)param_1 + 0x1f) = 0;
  *(undefined2 *)((int)param_1 + 0x23) = 0;
  *(undefined2 *)((int)param_1 + 0x25) = 0;
  *(undefined2 *)((int)param_1 + 0x21) = 0;
  *(undefined2 *)((int)param_1 + 0x27) = 0;
  *(undefined2 *)((int)param_1 + 0x29) = 0;
  *(undefined2 *)((int)param_1 + 0x2b) = 0;
  uVar7 = false;
  bVar8 = true;
  *(undefined1 *)(param_1 + 2) = 0;
  *(undefined1 *)((int)param_1 + 5) = 0;
  *(undefined1 *)(param_1 + 3) = 0;
  *(undefined1 *)(param_1 + 7) = 0;
  param_1[1] = 0;
  *(undefined4 *)((int)param_1 + 0x1b) = 0;
  _DAT_004fe15e = 0;
  *(undefined1 *)((int)param_1 + 7) = 0;
  *(undefined1 *)((int)param_1 + 0xf) = 0;
  *param_1 = param_3;
  *(undefined4 *)((int)param_1 + 0x13) = param_7;
  *(undefined1 *)((int)param_1 + 0xd) = param_8;
  *(undefined4 *)((int)param_1 + 0x17) = param_5;
  *(undefined1 *)(param_1 + 9) = param_6;
  iVar3 = 4;
  ppuVar6 = &PTR_LAB_004fe10e;
  do {
    if (bVar8) {
      *(short *)((int)ppuVar6 + 0xe) = param_3;
      DAT_004fe178 = param_3;
      *(char *)(ppuVar6 + 4) = (char)param_4;
      ppuVar6[1] = (undefined *)param_1;
      *(undefined ***)((int)param_1 + 0x1b) = ppuVar6;
      pcVar1 = (code *)swi(0x31);
      (*pcVar1)();
      *(undefined2 *)(ppuVar6 + 3) = extraout_CX;
      ppuVar6[2] = extraout_EDX;
      pcVar1 = (code *)swi(0x31);
      (*pcVar1)();
      if ((bool)uVar7) {
        param_1[1] = 0x100;
        local_8 = 0xfffffffe;
      }
      else {
        DAT_004fe16c = in(0x21);
        out(0x20,0xb);
        DAT_004fe16d = in(0x20);
        out(0x20,10);
        DAT_004fe16e = in(0x20);
        if (param_4 == 0xc) {
          uVar5 = 0x6410;
        }
        else {
          uVar5 = 0x6308;
        }
        *(byte *)((int)ppuVar6 + 0x11) = (byte)uVar5;
        bVar2 = in(0x21);
        out(0x21,bVar2 & ~(byte)uVar5);
        out(0x20,(char)((ushort)uVar5 >> 8));
        DAT_004fe16f = in(0x21);
        out(0x20,0xb);
        DAT_004fe170 = in(0x20);
        out(0x20,10);
        DAT_004fe171 = in(0x20);
        DAT_004fe177 = in(param_3 + 2);
        bVar2 = in(param_3 + 4);
        out(param_3 + 4,bVar2 & 0xf7);
        bVar2 = in(param_3 + 1);
        out(param_3 + 1,bVar2 & 0xf0);
        bVar2 = in(param_3 + 3);
        out(param_3 + 3,bVar2 | 0x80);
        out(param_3,(char)param_2);
        out(param_3 + 1,(char)((ushort)param_2 >> 8));
        sVar4 = param_3 + 3;
        bVar2 = in(sVar4);
        out(sVar4,bVar2 & 0x7f);
        out(sVar4,3);
        bVar2 = in(param_3 + 1);
        out(param_3 + 1,bVar2 | 0xf);
        bVar2 = in(param_3 + 4);
        out(param_3 + 4,bVar2 | 10);
        in(param_3);
        in(param_3);
        in(param_3 + 6);
        DAT_004fe175 = in(param_3 + 5);
        DAT_004fe176 = in(param_3 + 1);
        DAT_004fe172 = in(0x21);
        out(0x20,0xb);
        DAT_004fe173 = in(0x20);
        out(0x20,10);
        DAT_004fe174 = in(0x20);
        *(undefined1 *)(param_1 + 2) = 1;
      }
      goto LAB_0047dc58;
    }
    uVar7 = (undefined **)0xffffffeb < ppuVar6;
    ppuVar6 = ppuVar6 + 5;
    bVar8 = ppuVar6 == (undefined **)0x0;
    iVar3 = iVar3 + -1;
  } while (iVar3 != 0);
  param_1[1] = 0x100;
  local_8 = 0xffffffff;
LAB_0047dc58:
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  DAT_004fe164 = 1;
  return CONCAT44(unaff_EBX,local_8);
}



/* @0047dc71 file=? name=FUN_0047dc71 */

undefined8 __fastcall FUN_0047dc71(undefined4 param_1,undefined4 param_2,short *param_3)

{
  int iVar1;
  code *pcVar2;
  byte bVar3;
  undefined4 unaff_EBX;
  undefined4 unaff_retaddr;
  
  pcVar2 = (code *)swi(0x31);
  (*pcVar2)();
  DAT_004fe164 = 0;
  if (param_3 != (short *)0x0) {
    bVar3 = in(*param_3 + 4);
    out(*param_3 + 4,bVar3 & 0xf5);
    iVar1 = *(int *)((int)param_3 + 0x1b);
    if (iVar1 != 0) {
      *(undefined2 *)(iVar1 + 0xe) = 0;
      pcVar2 = (code *)swi(0x31);
      (*pcVar2)();
      bVar3 = in(0x21);
      out(0x21,bVar3 | *(byte *)(iVar1 + 0x11));
    }
  }
  pcVar2 = (code *)swi(0x31);
  (*pcVar2)(param_2,param_1);
  DAT_004fe164 = 1;
  return CONCAT44(unaff_EBX,unaff_retaddr);
}



/* @0047dce3 file=? name=FUN_0047dce3 */

undefined8 __cdecl FUN_0047dce3(int param_1,byte *param_2)

{
  short sVar1;
  ushort uVar2;
  byte bVar3;
  uint uVar4;
  uint uVar5;
  int iVar6;
  int iVar7;
  undefined4 unaff_EDI;
  
  uVar4 = 0;
  if (param_1 != 0) {
    if (*(char *)(param_1 + 4) == '\0') {
      uVar4 = 0;
    }
    else {
      uVar4 = (uint)*(ushort *)(param_1 + 0x235);
      if (*(ushort *)(param_1 + 0x235) != 0) {
        *(short *)(param_1 + 0x239) = *(short *)(param_1 + 0x239) + 1;
        uVar2 = *(ushort *)(param_1 + 0x233);
        iVar6 = param_1 + 0x22d + (uint)uVar2;
        bVar3 = *(byte *)(iVar6 + 0xe);
        iVar6 = iVar6 - (uint)uVar2;
        *(ushort *)(iVar6 + 6) = uVar2 + 1 & 0x1ff;
        iVar7 = iVar6 + -0x22d;
        if ((bVar3 & 0x80) == 0) {
          bVar3 = in(DAT_004fe178 + 4);
          out(DAT_004fe178 + 4,bVar3 & 0xf5);
          out(0x20,0x20);
          uVar4 = 0;
        }
        else {
          *param_2 = bVar3;
          bVar3 = *(byte *)(*(int *)(iVar6 + -0x216) + (bVar3 & 0x7f));
          uVar4 = bVar3 + 1;
          uVar5 = (uint)(ushort)bVar3;
          if (bVar3 != 0) {
            do {
              param_2 = param_2 + 1;
              *(short *)(iVar7 + 0x239) = *(short *)(iVar7 + 0x239) + 1;
              uVar2 = *(ushort *)(iVar7 + 0x233);
              iVar7 = iVar7 + 0x22d + (uint)uVar2;
              bVar3 = *(byte *)(iVar7 + 0xe);
              iVar7 = iVar7 - (uint)uVar2;
              *(ushort *)(iVar7 + 6) = uVar2 + 1 & 0x1ff;
              iVar7 = iVar7 + -0x22d;
              *param_2 = bVar3;
              uVar5 = uVar5 - 1;
            } while (uVar5 != 0);
          }
          LOCK();
          sVar1 = *(short *)(iVar7 + 0x239);
          *(short *)(iVar7 + 0x239) = 0;
          UNLOCK();
          *(short *)(iVar7 + 0x235) = *(short *)(iVar7 + 0x235) - sVar1;
          *(undefined2 *)(iVar7 + 0x22f) = *(undefined2 *)(iVar7 + 0x233);
        }
      }
    }
  }
  return CONCAT44(unaff_EDI,uVar4);
}



/* @0047ddda file=? name=FUN_0047ddda */

undefined8 __fastcall
FUN_0047ddda(undefined4 param_1,undefined4 param_2,short *param_3,byte *param_4)

{
  ushort uVar1;
  code *pcVar2;
  byte bVar3;
  undefined4 in_EAX;
  int extraout_ECX;
  int iVar4;
  short sVar5;
  undefined2 *puVar6;
  
  if ((param_3 != (short *)0x0) && ((char)param_3[2] != '\0')) {
    while( true ) {
      if ((ushort)(*(byte *)(*(int *)((int)param_3 + 0x13) + (*param_4 & 0x7f)) + 1) <=
          (ushort)((0x200 - *(short *)((int)param_3 + 0x27)) - *(short *)((int)param_3 + 0x29)))
      break;
      bVar3 = in(DAT_004fe178 + 4);
      out(DAT_004fe178 + 4,bVar3 & 0xf5);
      out(0x20,0x20);
    }
    pcVar2 = (code *)swi(0x31);
    (*pcVar2)();
    DAT_004fe164 = 0;
    iVar4 = extraout_ECX;
    do {
      bVar3 = *param_4;
      param_4 = param_4 + 1;
      puVar6 = (undefined2 *)((int)param_3 + 0x1f);
      if (*(ushort *)((int)param_3 + 0x29) < 0x200) {
LAB_0047de9e:
        *(short *)((int)param_3 + 0x29) = *(short *)((int)param_3 + 0x29) + 1;
        uVar1 = *(ushort *)((int)param_3 + 0x23);
        *(byte *)((int)puVar6 + uVar1 + 0xe) = bVar3;
        puVar6[2] = uVar1 + 1 & 0x1ff;
      }
      else {
        sVar5 = DAT_004fe178 + 4;
        bVar3 = in(sVar5);
        out(sVar5,bVar3 & 0xf5);
        out(0x20,0x20);
        bVar3 = 8;
        if (sVar5 < 4) goto LAB_0047de9e;
      }
      iVar4 = iVar4 + -1;
    } while (iVar4 != 0);
    LOCK();
    sVar5 = puVar6[5];
    puVar6[5] = 0;
    UNLOCK();
    puVar6[4] = puVar6[4] + sVar5;
    *puVar6 = puVar6[2];
    FUN_0047dfcb(0,*param_3);
    pcVar2 = (code *)swi(0x31);
    (*pcVar2)(param_2,param_1);
    DAT_004fe164 = 1;
  }
  return CONCAT44(param_2,in_EAX);
}



/* @0047def5 file=? name=FUN_0047def5 */

undefined8 __fastcall FUN_0047def5(undefined4 param_1,undefined4 param_2,short *param_3)

{
  byte bVar1;
  uint uVar2;
  
  uVar2 = 0;
  if (param_3 != (short *)0x0) {
    bVar1 = in(*param_3 + 5);
    uVar2 = bVar1 & 0xffffff60 ^ 0x60;
  }
  return CONCAT44(param_2,uVar2);
}



/* @0047df1a file=? name=FUN_0047df1a */

undefined8 __fastcall FUN_0047df1a(undefined4 param_1,undefined4 param_2,int param_3)

{
  ushort uVar1;
  uint uVar2;
  
  uVar2 = 0;
  if (param_3 != 0) {
    uVar1 = *(ushort *)(param_3 + 2) & 0x100;
    if (uVar1 == 0) {
      LOCK();
      uVar1 = *(ushort *)(param_3 + 2);
      *(ushort *)(param_3 + 2) = 0;
      UNLOCK();
    }
    uVar2 = (uint)uVar1;
  }
  return CONCAT44(param_2,uVar2);
}



/* @0047df47 file=? name=FUN_0047df47 */

ulonglong __fastcall FUN_0047df47(undefined4 param_1,undefined4 param_2)

{
  code *pcVar1;
  undefined4 uVar2;
  
  pcVar1 = (code *)swi(0x31);
  uVar2 = (*pcVar1)(param_2);
  return CONCAT44(param_1,uVar2) & 0xffffffff000000ff;
}



/* @0047df82 file=? name=FUN_0047df82 */

undefined2 __cdecl FUN_0047df82(int param_1)

{
  return *(undefined2 *)(param_1 + 0x27);
}



/* @0047df93 file=? name=FUN_0047df93 */

undefined6 __fastcall FUN_0047df93(undefined4 param_1,short param_2,short *param_3,int param_4)

{
  undefined1 uVar1;
  undefined3 uVar3;
  uint uVar2;
  
  uVar2 = 0;
  if (param_3 != (short *)0x0) {
    param_2 = *param_3;
    uVar3 = (undefined3)((uint)param_3 >> 8);
    if (param_4 == 0) {
      uVar1 = in(param_2 + 4);
      uVar2 = CONCAT31(uVar3,uVar1) & 0xfffffffe;
      out(param_2 + 4,(char)uVar2);
    }
    else {
      uVar1 = in(param_2 + 4);
      uVar2 = CONCAT31(uVar3,uVar1) | 1;
      out(param_2 + 4,(char)uVar2);
    }
  }
  return CONCAT24(param_2,uVar2);
}



/* @0047dfcb file=? name=FUN_0047dfcb */

void __fastcall FUN_0047dfcb(undefined4 param_1,short param_2)

{
  byte bVar1;
  
  bVar1 = in(param_2 + 5);
  if ((bVar1 & 0x20) != 0) {
    FUN_0047dfe2(param_1,param_2);
  }
  return;
}



/* @0047dfe2 file=? name=FUN_0047dfe2 */

ushort __fastcall FUN_0047dfe2(undefined4 param_1,undefined2 param_2)

{
  char *pcVar1;
  undefined1 uVar2;
  byte bVar3;
  char cVar4;
  ushort uVar5;
  ushort uVar6;
  short sVar7;
  undefined4 in_EAX;
  undefined3 uVar10;
  uint uVar9;
  int unaff_ESI;
  int iVar11;
  int iVar12;
  undefined4 uVar8;
  
  uVar10 = (undefined3)((uint)in_EAX >> 8);
  if (*(char *)(unaff_ESI + 6) != '\0') {
    LOCK();
    uVar2 = *(undefined1 *)(unaff_ESI + 6);
    *(undefined1 *)(unaff_ESI + 6) = 0;
    UNLOCK();
    out(param_2,uVar2);
    DAT_004fe168 = DAT_004fe168 + 1;
    return (ushort)CONCAT31(uVar10,uVar2);
  }
  cVar4 = *(char *)(unaff_ESI + 7);
  uVar8 = CONCAT31(uVar10,cVar4);
  uVar5 = (ushort)uVar8;
  if (cVar4 != '\0') {
    if (cVar4 == '\x02') {
      if (*(char *)(unaff_ESI + 0xe) == '\0') {
        pcVar1 = (char *)(unaff_ESI + 8);
        cVar4 = *pcVar1;
        *pcVar1 = *pcVar1 + -1;
        if (*pcVar1 != '\0' && SBORROW1(cVar4,'\x01') == *pcVar1 < '\0') {
          *(short *)(unaff_ESI + 0x2b) = *(short *)(unaff_ESI + 0x2b) + 1;
          uVar5 = *(ushort *)(unaff_ESI + 0x25);
          iVar11 = unaff_ESI + 0x1f + (uint)uVar5;
          bVar3 = *(byte *)(iVar11 + 0xe);
          uVar6 = (ushort)CONCAT31(uVar10,bVar3);
          iVar11 = iVar11 - (uint)uVar5;
          *(ushort *)(iVar11 + 6) = uVar5 + 1 & 0x1ff;
          if (0x7f < bVar3) {
            bVar3 = in(DAT_004fe178 + 4);
            out(DAT_004fe178 + 4,bVar3 & 0xf5);
            out(0x20,0x20);
            param_2 = 0xffff;
            uVar6 = 3;
          }
          out(param_2,(char)uVar6);
          pcVar1 = (char *)(iVar11 + -0x13);
          *pcVar1 = *pcVar1 + (char)uVar6;
          DAT_004fe168 = DAT_004fe168 + 1;
          return uVar6;
        }
        uVar9 = CONCAT31(uVar10,*(undefined1 *)(unaff_ESI + 0xc)) & 0xffffff7f;
        out(param_2,(char)uVar9);
        DAT_004fe168 = DAT_004fe168 + 1;
        *(undefined1 *)(unaff_ESI + 0xb) = 4;
        *(undefined1 *)(unaff_ESI + 7) = 3;
        return (ushort)uVar9;
      }
      *(undefined2 *)(unaff_ESI + 0x2b) = 0;
      *(undefined2 *)(unaff_ESI + 0x25) = *(undefined2 *)(unaff_ESI + 0x21);
      bVar3 = *(byte *)(unaff_ESI + 0xe);
      *(undefined1 *)(unaff_ESI + 0xe) = 0;
      if ((bVar3 & 1) == 0) {
        *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x200;
      }
      pcVar1 = (char *)(unaff_ESI + 9);
      cVar4 = *pcVar1;
      *pcVar1 = *pcVar1 + -1;
      if (SBORROW1(cVar4,'\x01') == *pcVar1 < '\0') {
        out(param_2,0xfe);
        DAT_004fe168 = DAT_004fe168 + 1;
        *(undefined1 *)(unaff_ESI + 7) = 1;
        return (ushort)CONCAT31(uVar10,0xfe);
      }
      *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x400;
      iVar11 = unaff_ESI + 0x1f + (uint)*(ushort *)(unaff_ESI + 0x21);
      iVar12 = iVar11 - (uint)*(ushort *)(unaff_ESI + 0x21);
      sVar7 = *(byte *)(*(int *)(unaff_ESI + 0x13) + (*(byte *)(iVar11 + 0xe) & 0x7f)) + 1;
      *(short *)(iVar12 + 8) = *(short *)(iVar12 + 8) - sVar7;
      uVar5 = sVar7 + *(short *)(iVar12 + 2) & 0x1ff;
      *(ushort *)(iVar12 + 2) = uVar5;
      *(ushort *)(iVar12 + 6) = uVar5;
      *(undefined2 *)(iVar12 + 0xc) = 0;
      unaff_ESI = iVar12 + -0x1f;
    }
    else {
      if (cVar4 != '\x03') {
        if (cVar4 == '\x01') goto LAB_0047e05c;
        bVar3 = in(DAT_004fe178 + 4);
        out(DAT_004fe178 + 4,bVar3 & 0xf5);
        out(0x20,0x20);
        param_2 = 0xffff;
        uVar8 = 0;
      }
      uVar10 = (undefined3)((uint)uVar8 >> 8);
      LOCK();
      bVar3 = *(byte *)(unaff_ESI + 0xe);
      *(byte *)(unaff_ESI + 0xe) = 0;
      UNLOCK();
      if (bVar3 == 0) {
        pcVar1 = (char *)(unaff_ESI + 0xb);
        cVar4 = *pcVar1;
        *pcVar1 = *pcVar1 + -1;
        if (SBORROW1(cVar4,'\x01') == *pcVar1 < '\0') {
          out(param_2,0xff);
          DAT_004fe168 = DAT_004fe168 + 1;
          return (ushort)CONCAT31(uVar10,0xff);
        }
        *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x800;
        *(undefined2 *)(unaff_ESI + 0x2b) = 0;
        *(undefined2 *)(unaff_ESI + 0x25) = *(undefined2 *)(unaff_ESI + 0x21);
        pcVar1 = (char *)(unaff_ESI + 9);
        cVar4 = *pcVar1;
        *pcVar1 = *pcVar1 + -1;
        if (SBORROW1(cVar4,'\x01') == *pcVar1 < '\0') {
          out(param_2,0xfe);
          DAT_004fe168 = DAT_004fe168 + 1;
          *(undefined1 *)(unaff_ESI + 0xb) = 4;
          *(undefined1 *)(unaff_ESI + 7) = 1;
          return (ushort)CONCAT31(uVar10,0xfe);
        }
      }
      else {
        if ((bVar3 & 1) != 0) {
          LOCK();
          sVar7 = *(short *)(unaff_ESI + 0x2b);
          *(short *)(unaff_ESI + 0x2b) = 0;
          UNLOCK();
          *(short *)(unaff_ESI + 0x27) = *(short *)(unaff_ESI + 0x27) - sVar7;
          uVar5 = *(ushort *)(unaff_ESI + 0x25);
          *(ushort *)(unaff_ESI + 0x21) = uVar5;
          *(undefined1 *)(unaff_ESI + 7) = 0;
          goto LAB_0047e042;
        }
        *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x1000;
        *(undefined2 *)(unaff_ESI + 0x2b) = 0;
        *(undefined2 *)(unaff_ESI + 0x25) = *(undefined2 *)(unaff_ESI + 0x21);
        pcVar1 = (char *)(unaff_ESI + 10);
        cVar4 = *pcVar1;
        *pcVar1 = *pcVar1 + -1;
        if (SBORROW1(cVar4,'\x01') == *pcVar1 < '\0') goto LAB_0047e05c;
      }
      *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x400;
      iVar11 = unaff_ESI + 0x1f + (uint)*(ushort *)(unaff_ESI + 0x21);
      iVar12 = iVar11 - (uint)*(ushort *)(unaff_ESI + 0x21);
      sVar7 = *(byte *)(*(int *)(unaff_ESI + 0x13) + (*(byte *)(iVar11 + 0xe) & 0x7f)) + 1;
      *(short *)(iVar12 + 8) = *(short *)(iVar12 + 8) - sVar7;
      uVar5 = sVar7 + *(short *)(iVar12 + 2) & 0x1ff;
      *(ushort *)(iVar12 + 2) = uVar5;
      *(ushort *)(iVar12 + 6) = uVar5;
      *(undefined2 *)(iVar12 + 0xc) = 0;
      unaff_ESI = iVar12 + -0x1f;
      *(undefined1 *)(iVar12 + -0x18) = 0;
    }
  }
LAB_0047e042:
  if (*(char *)(unaff_ESI + 5) != '\0') {
    return uVar5;
  }
  if (*(short *)(unaff_ESI + 0x27) == 0) {
    return uVar5;
  }
  *(undefined1 *)(unaff_ESI + 9) = 3;
  *(undefined1 *)(unaff_ESI + 10) = 3;
LAB_0047e05c:
  *(short *)(unaff_ESI + 0x2b) = *(short *)(unaff_ESI + 0x2b) + 1;
  uVar5 = *(ushort *)(unaff_ESI + 0x25);
  iVar11 = unaff_ESI + 0x1f + (uint)uVar5;
  bVar3 = *(byte *)(iVar11 + 0xe);
  iVar11 = iVar11 - (uint)uVar5;
  *(ushort *)(iVar11 + 6) = uVar5 + 1 & 0x1ff;
  if (0x7f < bVar3) {
    uVar9 = CONCAT11(bVar3,bVar3) & 0xffff7fff;
    bVar3 = (byte)(uVar9 >> 8);
    if (bVar3 < *(byte *)(iVar11 + -0x12)) {
      out(param_2,(char)uVar9);
      *(char *)(iVar11 + -0x13) = (char)uVar9;
      DAT_004fe168 = DAT_004fe168 + 1;
      cVar4 = *(char *)(*(int *)(iVar11 + -0xc) + (uint)bVar3) + '\x01';
      *(char *)(iVar11 + -0x17) = cVar4;
      *(undefined1 *)(iVar11 + -0x18) = 2;
      return (ushort)CONCAT31((int3)(uVar9 >> 8),cVar4);
    }
  }
  bVar3 = in(DAT_004fe178 + 4);
  out(DAT_004fe178 + 4,bVar3 & 0xf5);
  out(0x20,0x20);
  LOCK();
  sVar7 = *(short *)(iVar11 + 0xc);
  *(short *)(iVar11 + 0xc) = 0;
  UNLOCK();
  *(short *)(iVar11 + 8) = *(short *)(iVar11 + 8) - sVar7;
  *(ushort *)(iVar11 + 2) = *(ushort *)(iVar11 + 6);
  *(undefined1 *)(iVar11 + -0x18) = 0;
  return *(ushort *)(iVar11 + 6);
}



/* @0047e2e6 file=? name=FUN_0047e2e6 */

void __fastcall FUN_0047e2e6(undefined4 param_1,short param_2)

{
  char *pcVar1;
  char cVar2;
  ushort uVar3;
  byte in_AL;
  byte bVar4;
  undefined1 uVar5;
  uint uVar6;
  short sVar7;
  int unaff_ESI;
  int iVar8;
  
  if ((in_AL & 0x80) != 0) {
    if (in_AL == 0xff) {
      return;
    }
    if (in_AL == 0xfc) {
      *(byte *)(unaff_ESI + 0xe) = *(byte *)(unaff_ESI + 0xe) | 1;
      return;
    }
    if (in_AL == 0xfd) {
      *(byte *)(unaff_ESI + 0xe) = *(byte *)(unaff_ESI + 0xe) | 2;
      return;
    }
  }
  if (*(char *)(unaff_ESI + 0xf) != '\0') {
    if ((in_AL & 0x80) == 0) {
      pcVar1 = (char *)(unaff_ESI + 0x10);
      cVar2 = *pcVar1;
      *pcVar1 = *pcVar1 + -1;
      if (*pcVar1 != '\0' && SBORROW1(cVar2,'\x01') == *pcVar1 < '\0') {
        if ((short)(0x200 - *(short *)(unaff_ESI + 0x235)) != *(short *)(unaff_ESI + 0x237)) {
          *(char *)(unaff_ESI + 0x11) = *(char *)(unaff_ESI + 0x11) + in_AL;
          if (0x1ff < *(ushort *)(unaff_ESI + 0x237)) {
            sVar7 = DAT_004fe178 + 4;
            bVar4 = in(sVar7);
            out(sVar7,bVar4 & 0xf5);
            out(0x20,0x20);
            in_AL = 8;
            if (3 < sVar7) {
              return;
            }
          }
          *(short *)(unaff_ESI + 0x237) = *(short *)(unaff_ESI + 0x237) + 1;
          uVar3 = *(ushort *)(unaff_ESI + 0x231);
          *(byte *)(unaff_ESI + 0x22d + uVar3 + 0xe) = in_AL;
          *(ushort *)(unaff_ESI + 0x231) = uVar3 + 1 & 0x1ff;
          return;
        }
        bVar4 = in(DAT_004fe178 + 4);
        out(DAT_004fe178 + 4,bVar4 & 0xf5);
        out(0x20,0x20);
        *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x8000;
        *(undefined2 *)(unaff_ESI + 0x237) = 0;
        *(undefined2 *)(unaff_ESI + 0x231) = *(undefined2 *)(unaff_ESI + 0x22d);
        goto LAB_0047e588;
      }
      if (in_AL == (*(byte *)(unaff_ESI + 0x11) & 0x7f)) {
        LOCK();
        sVar7 = *(short *)(unaff_ESI + 0x237);
        *(short *)(unaff_ESI + 0x237) = 0;
        UNLOCK();
        *(short *)(unaff_ESI + 0x235) = *(short *)(unaff_ESI + 0x235) + sVar7;
        *(undefined2 *)(unaff_ESI + 0x22d) = *(undefined2 *)(unaff_ESI + 0x231);
        uVar5 = 0xfc;
      }
      else {
        *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x4000;
        *(undefined2 *)(unaff_ESI + 0x237) = 0;
        *(undefined2 *)(unaff_ESI + 0x231) = *(undefined2 *)(unaff_ESI + 0x22d);
        uVar5 = 0xfd;
      }
    }
    else {
      *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x2000;
      *(undefined2 *)(unaff_ESI + 0x237) = 0;
      *(undefined2 *)(unaff_ESI + 0x231) = *(undefined2 *)(unaff_ESI + 0x22d);
      if (in_AL == 0xfe) goto LAB_0047e588;
      uVar5 = 0xfd;
    }
    *(undefined1 *)(unaff_ESI + 6) = uVar5;
    FUN_0047dfcb(param_1,param_2);
LAB_0047e588:
    *(undefined1 *)(unaff_ESI + 0xf) = 0;
    return;
  }
  if ((in_AL & 0x80) == 0) {
    *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x2000;
    return;
  }
  if (in_AL == 0xfe) {
    return;
  }
  iVar8 = unaff_ESI + 0x22d;
  if ((short)(0x200 - *(short *)(unaff_ESI + 0x235)) == *(short *)(unaff_ESI + 0x237)) {
    bVar4 = in(DAT_004fe178 + 4);
    out(DAT_004fe178 + 4,bVar4 & 0xf5);
    out(0x20,0x20);
    *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x8000;
    return;
  }
  uVar6 = CONCAT11(in_AL,in_AL) & 0xffff7fff;
  if (*(byte *)(unaff_ESI + 0x12) <= (byte)(uVar6 >> 8)) {
    bVar4 = in(DAT_004fe178 + 4);
    out(DAT_004fe178 + 4,bVar4 & 0xf5);
    out(0x20,0x20);
    *(ushort *)(unaff_ESI + 2) = *(ushort *)(unaff_ESI + 2) | 0x8000;
    return;
  }
  if (0x1ff < *(ushort *)(unaff_ESI + 0x237)) {
    sVar7 = DAT_004fe178 + 4;
    bVar4 = in(sVar7);
    out(sVar7,bVar4 & 0xf5);
    out(0x20,0x20);
    uVar6 = 8;
    if (3 < sVar7) goto LAB_0047e40e;
  }
  *(short *)(unaff_ESI + 0x237) = *(short *)(unaff_ESI + 0x237) + 1;
  uVar3 = *(ushort *)(unaff_ESI + 0x231);
  iVar8 = iVar8 + (uint)uVar3;
  *(char *)(iVar8 + 0xe) = (char)uVar6;
  iVar8 = iVar8 - (uint)uVar3;
  *(ushort *)(iVar8 + 4) = uVar3 + 1 & 0x1ff;
LAB_0047e40e:
  *(char *)(iVar8 + -0x21c) = (char)uVar6;
  *(char *)(iVar8 + -0x21d) = *(char *)(*(int *)(iVar8 + -0x216) + (uVar6 >> 8)) + '\x01';
  *(undefined1 *)(iVar8 + -0x21e) = 1;
  return;
}



/* @0047e5c1 file=? name=FUN_0047e5c1 */

undefined4 __fastcall FUN_0047e5c1(undefined4 param_1,undefined4 param_2)

{
  ushort *puVar1;
  int iVar2;
  char cVar3;
  undefined1 uVar4;
  byte bVar5;
  ushort uVar6;
  uint in_EAX;
  uint3 uVar7;
  undefined2 extraout_var;
  undefined4 extraout_ECX;
  undefined4 extraout_ECX_00;
  short sVar8;
  short extraout_DX;
  short extraout_DX_00;
  undefined2 uVar9;
  undefined2 extraout_var_00;
  undefined2 extraout_var_01;
  int unaff_EDI;
  undefined4 uStack_14;
  
  DAT_004fe164 = 0;
  iVar2 = *(int *)(unaff_EDI + 4);
  sVar8 = *(short *)(unaff_EDI + 0xe);
  uVar9 = (undefined2)((uint)param_2 >> 0x10);
  while( true ) {
    while( true ) {
      while( true ) {
        while( true ) {
          uVar7 = (uint3)(in_EAX >> 8);
          cVar3 = in(sVar8 + 2);
          if (cVar3 != '\x04') break;
          in(sVar8);
          in_EAX = FUN_0047e2e6(param_1,sVar8);
          param_1 = extraout_ECX;
          sVar8 = extraout_DX;
          uVar9 = extraout_var_00;
        }
        if (cVar3 != '\x02') break;
        uVar6 = FUN_0047dfe2(param_1,sVar8);
        in_EAX = CONCAT22(extraout_var,uVar6);
        param_1 = extraout_ECX_00;
        sVar8 = extraout_DX_00;
        uVar9 = extraout_var_01;
      }
      if (cVar3 != '\0') break;
      in(sVar8 + 6);
      in_EAX = (uint)uVar7 << 8;
    }
    if (cVar3 != '\x06') break;
    uVar4 = in(sVar8 + 5);
    in_EAX = CONCAT22((short)(in_EAX >> 0x10),(short)CONCAT31(uVar7,uVar4)) & 0xffff001e;
    puVar1 = (ushort *)(iVar2 + 2);
    *puVar1 = *puVar1 | (ushort)in_EAX;
  }
  if (cVar3 != '\x01') {
    bVar5 = in(DAT_004fe178 + 4);
    out(DAT_004fe178 + 4,bVar5 & 0xf5);
    uStack_14 = CONCAT22(uVar9,DAT_004fe178);
    out(0x20,0x20);
    uVar7 = 0;
  }
  out(0x20,0x20);
  DAT_004fe164 = uStack_14;
  return CONCAT31(uVar7,0x20);
}



/* @0047e661 file=? name=FUN_0047e661 */

undefined4 FUN_0047e661(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return 0;
}



/* @0047e693 file=? name=FUN_0047e693 */

void FUN_0047e693(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return;
}



/* @0047e6c0 file=? name=FUN_0047e6c0 */

undefined4 __thiscall
FUN_0047e6c0(void *this,uint param_1,undefined2 *param_2,undefined2 *param_3,undefined4 *param_4)

{
  code *pcVar1;
  undefined4 uVar2;
  undefined2 extraout_CX;
  undefined2 unaff_SI;
  uint unaff_EDI;
  undefined2 in_FS;
  undefined2 in_GS;
  undefined1 in_CF;
  bool bVar3;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)(in_GS,in_FS,this);
  pcVar1 = (code *)swi(0x31);
  uVar2 = (*pcVar1)();
  if ((bool)in_CF) {
    return 0xffffffff;
  }
  DAT_004fe26c = (undefined2)uVar2;
  bVar3 = false;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)(uVar2);
  if (bVar3) {
    return 0xffffffff;
  }
  bVar3 = 0xffaf < (ushort)param_1;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  if (bVar3) {
    return 0xffffffff;
  }
  *param_2 = unaff_SI;
  param_2[1] = 0xe280;
  FUN_0047ef7d(CONCAT22(unaff_SI,0xe280),param_1);
  *param_3 = extraout_CX;
  param_3[1] = 0;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  *param_4 = 0;
  param_4[1] = unaff_EDI & 0xffff;
  return 0;
}



/* @0047e7c4 file=? name=FUN_0047e7c4 */

void FUN_0047e7c4(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return;
}



/* @0047e7fa file=? name=FUN_0047e7fa */

void __cdecl FUN_0047e7fa(undefined4 param_1,ushort param_2,undefined4 *param_3)

{
  code *pcVar1;
  undefined4 uVar2;
  undefined4 unaff_EBX;
  
  pcVar1 = (code *)swi(0x31);
  uVar2 = (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)(uVar2,uVar2,uVar2);
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  SegmentLimit((uint)param_2);
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  *param_3 = 0;
  param_3[1] = unaff_EBX;
  return;
}



/* @0047e85f file=? name=FUN_0047e85f */

void __cdecl FUN_0047e85f(int *param_1,undefined6 param_2)

{
  int iVar1;
  int iVar2;
  
  iVar2 = (int)param_2;
  iVar1 = 0x20;
  do {
    *param_1 = iVar2;
    *(short *)(param_1 + 1) = (short)((uint6)param_2 >> 0x20);
    iVar2 = iVar2 + 0x6c;
    param_1 = param_1 + 2;
    iVar1 = iVar1 + -1;
  } while (iVar1 != 0);
  return;
}



/* @0047e88f file=? name=FUN_0047e88f */

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

{
  code *pcVar1;
  undefined6 uVar2;
  
  pcVar1 = (code *)swi(0x31);
  uVar2 = (*pcVar1)();
  *param_2 = (int)uVar2 << 4;
  *param_3 = (short)((uint6)uVar2 >> 0x20);
  return;
}



/* @0047e8c5 file=? name=FUN_0047e8c5 */

void FUN_0047e8c5(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return;
}



/* @0047e8ee file=? name=FUN_0047e8ee */

void FUN_0047e8ee(void)

{
  int iVar1;
  undefined1 *extraout_EDX;
  undefined1 *puVar2;
  undefined1 *in_stack_00000014;
  
  (*(code *)&stack0x00000004)();
  puVar2 = extraout_EDX;
  for (iVar1 = 0x6a; iVar1 != 0; iVar1 = iVar1 + -1) {
    *in_stack_00000014 = *puVar2;
    puVar2 = puVar2 + 1;
    in_stack_00000014 = in_stack_00000014 + 1;
  }
  return;
}



/* @0047e923 file=? name=FUN_0047e923 */

void __cdecl
FUN_0047e923(undefined4 param_1,undefined4 param_2,undefined6 param_3,undefined1 *param_4)

{
  int iVar1;
  undefined1 *extraout_EDX;
  undefined1 *puVar2;
  undefined1 *puVar3;
  undefined2 uVar4;
  
  (*(code *)&param_1)();
  uVar4 = (undefined2)((uint6)param_3 >> 0x20);
  puVar2 = extraout_EDX;
  puVar3 = param_4;
  for (iVar1 = 0x6a; iVar1 != 0; iVar1 = iVar1 + -1) {
    *puVar3 = *puVar2;
    puVar2 = puVar2 + 1;
    puVar3 = puVar3 + 1;
  }
  *(undefined2 *)(param_4 + 0x44) = uVar4;
  *(undefined2 *)(param_4 + 0x4c) = uVar4;
  *(undefined2 *)(param_4 + 0x54) = uVar4;
  *(undefined2 *)(param_4 + 0x5c) = uVar4;
  return;
}



/* @0047e973 file=? name=FUN_0047e973 */

void FUN_0047e973(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047e996 file=? name=FUN_0047e996 */

void FUN_0047e996(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047e9b9 file=? name=FUN_0047e9b9 */

void FUN_0047e9b9(void)

{
  undefined2 extraout_CX;
  undefined2 extraout_DX;
  
  DAT_004fe270._0_2_ = (*(code *)&stack0x00000004)();
  DAT_004fe278._0_2_ = (short)(char)((ushort)extraout_CX >> 8);
  DAT_004fe274._0_2_ = (short)(char)extraout_CX;
  DAT_004fe27c._0_2_ = extraout_DX;
  return;
}



/* @0047e9fd file=? name=FUN_0047e9fd */

void __cdecl
FUN_0047e9fd(undefined4 param_1,undefined4 param_2,undefined6 param_3,undefined1 *param_4)

{
  int iVar1;
  undefined1 *extraout_EDX;
  undefined1 *puVar2;
  undefined1 *puVar3;
  undefined2 uVar4;
  
  (*(code *)&param_1)();
  uVar4 = (undefined2)((uint6)param_3 >> 0x20);
  puVar2 = extraout_EDX;
  puVar3 = param_4;
  for (iVar1 = 0x6a; iVar1 != 0; iVar1 = iVar1 + -1) {
    *puVar3 = *puVar2;
    puVar2 = puVar2 + 1;
    puVar3 = puVar3 + 1;
  }
  *(undefined2 *)(param_4 + 0x44) = uVar4;
  *(undefined2 *)(param_4 + 0x4c) = uVar4;
  *(undefined2 *)(param_4 + 0x54) = uVar4;
  *(undefined2 *)(param_4 + 0x5c) = uVar4;
  return;
}



/* @0047ea4d file=? name=FUN_0047ea4d */

void FUN_0047ea4d(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047ea7d file=? name=FUN_0047ea7d */

void FUN_0047ea7d(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047eaa0 file=? name=FUN_0047eaa0 */

void __cdecl
FUN_0047eaa0(undefined4 param_1,undefined2 param_2,undefined4 param_3,undefined2 param_4,
            undefined6 param_5)

{
  undefined4 extraout_ECX;
  undefined4 unaff_ESI;
  undefined4 uVar1;
  undefined4 *in_stack_00000028;
  
  uVar1 = (undefined4)param_5;
  (*(code *)&param_1)();
  *in_stack_00000028 = uVar1;
  in_stack_00000028[2] = extraout_ECX;
  in_stack_00000028[4] = unaff_ESI;
  *(undefined2 *)(in_stack_00000028 + 1) = param_2;
  *(undefined2 *)(in_stack_00000028 + 3) = param_4;
  *(undefined2 *)(in_stack_00000028 + 5) = param_4;
  return;
}



/* @0047eaf3 file=? name=FUN_0047eaf3 */

void FUN_0047eaf3(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047eb28 file=? name=FUN_0047eb28 */

void FUN_0047eb28(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047eb51 file=? name=FUN_0047eb51 */

void FUN_0047eb51(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047eb77 file=? name=FUN_0047eb77 */

void FUN_0047eb77(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047eb9e file=? name=FUN_0047eb9e */

undefined4 FUN_0047eb9e(void)

{
  code *pcVar1;
  undefined4 in_stack_00000010;
  
  pcVar1 = (code *)swi(0x2f);
  (*pcVar1)();
  return in_stack_00000010;
}



/* @0047ebc8 file=? name=FUN_0047ebc8 */

undefined2 FUN_0047ebc8(void)

{
  code *pcVar1;
  undefined2 uVar2;
  
  pcVar1 = (code *)swi(0x2f);
  uVar2 = (*pcVar1)();
  if ((char)uVar2 == '\x03') {
    pcVar1 = (code *)swi(0x4b);
    (*pcVar1)();
    uVar2 = 0;
  }
  return uVar2;
}



/* @0047ebfd file=? name=FUN_0047ebfd */

undefined2 FUN_0047ebfd(void)

{
  code *pcVar1;
  undefined2 uVar2;
  
  pcVar1 = (code *)swi(0x2f);
  uVar2 = (*pcVar1)();
  if ((char)uVar2 == '\x03') {
    pcVar1 = (code *)swi(0x4b);
    (*pcVar1)();
    uVar2 = 0;
  }
  return uVar2;
}



/* @0047ec32 file=? name=FUN_0047ec32 */

void __cdecl
FUN_0047ec32(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined2 param_4)

{
  undefined4 uVar1;
  undefined4 unaff_ESI;
  
  uVar1 = param_3;
  (*(code *)&param_1)();
  DAT_004fe1d0._0_4_ = unaff_ESI;
  DAT_004fe1d8._0_4_ = uVar1;
  DAT_004fe1d0._4_2_ = param_4;
  DAT_004fe1d8._4_2_ = param_4;
  return;
}



/* @0047ec71 file=? name=FUN_0047ec71 */

undefined1 * __cdecl FUN_0047ec71(int param_1)

{
  undefined1 *puVar1;
  int iVar2;
  undefined1 *puVar3;
  
  puVar1 = *(undefined1 **)((int)DAT_004fe1d0 + param_1 * 4);
  if (puVar1 == (undefined1 *)0xffffffff) {
    puVar1 = (undefined1 *)0x0;
  }
  else {
    puVar3 = &DAT_004fe180;
    for (iVar2 = 0x50; iVar2 != 0; iVar2 = iVar2 + -1) {
      *puVar3 = *puVar1;
      puVar1 = puVar1 + 1;
      puVar3 = puVar3 + 1;
    }
    puVar1 = &DAT_004fe180;
  }
  return puVar1;
}



/* @0047ecbb file=? name=FUN_0047ecbb */

void __cdecl FUN_0047ecbb(int param_1,undefined4 param_2)

{
  int iVar1;
  undefined2 in_DS;
  
  iVar1 = (int)DAT_004fe1d8;
  *(undefined4 *)(iVar1 + param_1 * 6) = param_2;
  *(undefined2 *)(iVar1 + 4 + param_1 * 6) = in_DS;
  return;
}



/* @0047ecf1 file=? name=FUN_0047ecf1 */

void FUN_0047ecf1(void)

{
  undefined2 in_CS;
  undefined2 uVar1;
  
  uVar1 = 0x47;
  (*(code *)&stack0x00000014)();
  (*(code *)&stack0x00000004)(CONCAT22(uVar1,in_CS));
  return;
}



/* @0047ed26 file=? name=FUN_0047ed26 */

undefined4 FUN_0047ed26(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return DAT_004fe1e0;
}



/* @0047ed51 file=? name=FUN_0047ed51 */

void FUN_0047ed51(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x2f);
  (*pcVar1)();
  return;
}



/* @0047ed6e file=? name=FUN_0047ed6e */

bool __cdecl FUN_0047ed6e(undefined4 param_1,undefined2 *param_2,undefined2 *param_3)

{
  code *pcVar1;
  undefined2 uVar2;
  undefined2 extraout_DX;
  undefined1 in_CF;
  
  pcVar1 = (code *)swi(0x31);
  uVar2 = (*pcVar1)();
  if (!(bool)in_CF) {
    *param_2 = extraout_DX;
    *param_3 = uVar2;
  }
  return (bool)in_CF;
}



/* @0047eddd file=? name=FUN_0047eddd */

bool __cdecl FUN_0047eddd(undefined2 param_1)

{
  code *pcVar1;
  
  DAT_004fe238 = 0x8107;
  DAT_004fe230 = 0;
  DAT_004fe23e = param_1;
  DAT_004fe21c = 0;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  DAT_004fe23c = DAT_004fe23c & 1;
  return DAT_004fe23c != 0;
}



/* @0047ee49 file=? name=FUN_0047ee49 */

void __cdecl FUN_0047ee49(undefined2 param_1)

{
  code *pcVar1;
  
  DAT_004fe238 = 0x8108;
  DAT_004fe230 = 0;
  DAT_004fe23e = param_1;
  DAT_004fe21c = 0;
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return;
}



/* @0047ee96 file=? name=FUN_0047ee96 */

undefined2 FUN_0047ee96(void)

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



/* @0047ef16 file=? name=FUN_0047ef16 */

void FUN_0047ef16(void)

{
  code *pcVar1;
  
  pcVar1 = (code *)swi(0x31);
  (*pcVar1)();
  return;
}



/* @0047ef40 file=? name=FUN_0047ef40 */

void FUN_0047ef40(void)

{
  return;
}



/* @0047ef44 file=? name=FUN_0047ef44 */

void FUN_0047ef44(void)

{
  return;
}



/* @0047ef48 file=? name=FUN_0047ef48 */

void FUN_0047ef48(void)

{
  code *pcVar1;
  undefined4 uVar2;
  undefined4 *in_stack_00000014;
  
  pcVar1 = (code *)swi(0x21);
  uVar2 = (*pcVar1)();
  *in_stack_00000014 = uVar2;
  return;
}



/* @0047ef7d file=? name=FUN_0047ef7d */

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

void __cdecl FUN_0047ef7d(undefined4 param_1,uint param_2)

{
  code *pcVar1;
  int iVar2;
  
  iVar2 = (param_2 >> 0xd) + 1;
  do {
    pcVar1 = (code *)swi(0x31);
    (*pcVar1)();
    _DAT_004fe2b0 = _DAT_004fe2b0 | 8;
    pcVar1 = (code *)swi(0x31);
    (*pcVar1)();
    iVar2 = iVar2 + -1;
  } while (iVar2 != 0);
  return;
}



/* @0047efd1 file=? name=FUN_0047efd1 */

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

{
  for (; param_4 != 0; param_4 = param_4 + -1) {
    *param_1 = *param_3;
    param_3 = param_3 + 1;
    param_1 = param_1 + 1;
  }
  return;
}



/* @0047eff4 file=? name=FUN_0047eff4 */

void FUN_0047eff4(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @0047f013 file=? name=FUN_0047f013 */

void FUN_0047f013(void)

{
  return;
}



/* @0047f016 file=? name=FUN_0047f016 */

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

{
  for (; param_3 != 0; param_3 = param_3 + -1) {
    *param_1 = param_4;
    param_1 = param_1 + 1;
  }
  return;
}



/* @0047f03a file=? name=FUN_0047f03a */

void FUN_0047f03a(void)

{
  return;
}



/* @0047f03f file=? name=FUN_0047f03f */

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

undefined4 __cdecl
FUN_0047f03f(uint param_1,uint param_2,undefined4 *param_3,undefined4 *param_4,undefined2 *param_5,
            undefined1 *param_6,undefined4 *param_7)

{
  char *pcVar1;
  undefined4 uVar2;
  uint uVar3;
  int iVar4;
  void *this;
  uint unaff_ESI;
  undefined4 local_28;
  undefined4 uStack_24;
  undefined1 *local_20;
  undefined4 local_1c;
  undefined4 local_18;
  uint local_14;
  int local_10;
  char *local_c;
  char *local_8;
  
  local_8 = (char *)0x2c;
  local_c = (char *)0x30;
  local_10 = 0;
  local_14 = 0;
  if (param_2 < 6) {
    if (*(int *)(&DAT_004fe3d4 + param_2 * 4) == 0) {
      if ((param_1 < 0xe000) || (0xe200 < param_1)) {
        uVar2 = 6;
      }
      else {
        FUN_004d4a48(&DAT_004ff08c,&DAT_004fef8c);
        FUN_004d49b8(&DAT_004ff08c,s_hmidrv_386_004ff580);
        uVar3 = thunk_FUN_004d93ac(&DAT_004ff08c,0x8000,unaff_ESI);
        if (uVar3 == 0xffffffff) {
          uVar2 = 0xf;
        }
        else {
          thunk_FUN_004d892c(uVar3,&DAT_004ff320,local_8);
          while ((local_14 <= DAT_004ff340 && (local_10 == 0))) {
            thunk_FUN_004d892c(uVar3,&DAT_004ff34c,local_c);
            pcVar1 = DAT_004ff370;
            if ((DAT_004ff374 == param_1) && ((_DAT_004ff378 & 0x8000) != 0)) {
              local_10 = 1;
              iVar4 = FUN_0047e6c0(this,(uint)DAT_004ff370,param_5,(undefined2 *)&local_18,&local_20
                                  );
              if (iVar4 == -1) {
                return 5;
              }
              FUN_0047e7fa(local_20,(ushort)local_1c,&local_28);
              FUN_0047e661();
              DAT_004ff214 = FUN_004de55c(0xa000);
              if (DAT_004ff214 == (int *)0x0) {
                return 5;
              }
              thunk_FUN_004d892c(uVar3,(char *)DAT_004ff214,pcVar1);
              FUN_0047efd1(local_20,local_1c,(undefined1 *)DAT_004ff214,(int)pcVar1);
              FUN_004de420(DAT_004ff214);
              *param_3 = local_28;
              param_3[1] = uStack_24;
              *param_4 = local_20;
              param_4[1] = local_1c;
              *param_6 = (char)pcVar1;
              *param_7 = local_18;
            }
            else {
              thunk_FUN_004d9334(uVar3,(LONG)DAT_004ff370,1);
            }
            local_14 = local_14 + 1;
          }
          thunk_FUN_004d92c4(uVar3);
          *(uint *)(&DAT_004fe488 + param_2 * 4) = DAT_004ff374;
          *(undefined4 *)(&DAT_004fe3d4 + param_2 * 4) = 1;
          uVar2 = 0;
        }
      }
    }
    else {
      uVar2 = 9;
    }
  }
  else {
    uVar2 = 10;
  }
  return uVar2;
}



/* @0047f27c file=? name=FUN_0047f27c */

undefined4 __cdecl FUN_0047f27c(uint param_1)

{
  undefined4 uVar1;
  
  if (param_1 < 6) {
    if (*(int *)(&DAT_004fe3d4 + param_1 * 4) == 0) {
      uVar1 = 10;
    }
    else {
      *(undefined4 *)(&DAT_004fe3d4 + param_1 * 4) = 0;
      FUN_0047e693();
      FUN_0047e7c4();
      FUN_0047e7c4();
      uVar1 = 0;
    }
  }
  else {
    uVar1 = 10;
  }
  return uVar1;
}



/* @0047f334 file=? name=FUN_0047f334 */

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

undefined4 __cdecl
FUN_0047f334(uint param_1,undefined4 *param_2,undefined4 *param_3,undefined2 *param_4,
            undefined1 *param_5,undefined4 *param_6)

{
  undefined4 uVar1;
  uint uVar2;
  int iVar3;
  void *this;
  uint unaff_ESI;
  char *pcVar4;
  undefined4 local_28;
  undefined4 uStack_24;
  undefined1 *local_20;
  undefined4 local_1c;
  undefined4 local_18;
  uint local_14;
  int local_10;
  char *local_c;
  char *local_8;
  
  local_8 = (char *)0x2c;
  local_c = (char *)0x30;
  local_10 = 0;
  local_14 = 0;
  if ((param_1 < 0x1000) || (0x1023 < param_1)) {
    uVar1 = 6;
  }
  else {
    FUN_004d4a48(&DAT_004ff08c,&DAT_004fef8c);
    FUN_004d49b8(&DAT_004ff08c,s_hmidrv_386_004ff58b);
    uVar2 = thunk_FUN_004d93ac(&DAT_004ff08c,0x8000,unaff_ESI);
    if (uVar2 == 0xffffffff) {
      uVar1 = 0xf;
    }
    else {
      thunk_FUN_004d892c(uVar2,&DAT_004ff320,local_8);
      while ((local_14 <= DAT_004ff340 && (local_10 == 0))) {
        thunk_FUN_004d892c(uVar2,&DAT_004ff34c,local_c);
        if ((DAT_004ff374 == param_1) && ((_DAT_004ff378 & 0x4000) != 0)) {
          local_10 = 1;
          pcVar4 = (char *)(DAT_004ff370 + 0x4000);
          iVar3 = FUN_0047e6c0(this,(uint)pcVar4,param_4,(undefined2 *)&local_18,&local_20);
          if (iVar3 == -1) {
            return 5;
          }
          FUN_0047e7fa(local_20,(ushort)local_1c,&local_28);
          FUN_0047e661();
          DAT_004ff214 = FUN_004de55c(0xa000);
          if (DAT_004ff214 == (int *)0x0) {
            return 5;
          }
          thunk_FUN_004d892c(uVar2,(char *)DAT_004ff214,pcVar4);
          FUN_0047efd1(local_20,local_1c,(undefined1 *)DAT_004ff214,(int)pcVar4);
          FUN_004de420(DAT_004ff214);
          *param_2 = local_28;
          param_2[1] = uStack_24;
          *param_3 = local_20;
          param_3[1] = local_1c;
          *param_5 = (char)pcVar4;
          *param_6 = local_18;
        }
        else {
          thunk_FUN_004d9334(uVar2,DAT_004ff370,1);
        }
        local_14 = local_14 + 1;
      }
      thunk_FUN_004d92c4(uVar2);
      uVar1 = 0;
    }
  }
  return uVar1;
}



/* @0047f525 file=? name=FUN_0047f525 */

undefined4 FUN_0047f525(void)

{
  FUN_0047e693();
  FUN_0047e7c4();
  FUN_0047e7c4();
  return 0;
}



/* @0047f5a2 file=? name=FUN_0047f5a2 */

void FUN_0047f5a2(void)

{
  return;
}



/* @0047f629 file=? name=FUN_0047f629 */

undefined8 __fastcall FUN_0047f629(undefined4 param_1,undefined4 param_2,int param_3,int *param_4)

{
  int iVar1;
  int iVar2;
  int *piVar3;
  undefined2 in_CS;
  undefined2 in_DS;
  
  piVar3 = (int *)*(undefined6 *)(&DAT_004fe4c4 + param_3 * 0x80);
  iVar2 = 0;
  do {
    if ((*(ushort *)(piVar3 + 0xc) & 0x8000) == 0) {
      iVar1 = *param_4;
      *piVar3 = iVar1;
      piVar3[2] = iVar1;
      *(undefined2 *)(piVar3 + 1) = in_DS;
      *(undefined2 *)(piVar3 + 3) = in_DS;
      piVar3[4] = iVar1 + param_4[0xc];
      *(undefined2 *)(piVar3 + 5) = in_DS;
      if ((*(ushort *)(param_4 + 10) & 0x40) == 0) {
        iVar1 = param_4[2];
        piVar3[6] = iVar1;
        piVar3[7] = iVar1;
      }
      else {
        iVar1 = param_4[0xc];
        piVar3[6] = iVar1;
        piVar3[7] = iVar1;
        piVar3[8] = param_4[0xd];
      }
      *(short *)((int)piVar3 + 0x32) = (short)param_4[5];
      *(short *)(piVar3 + 0xd) = (short)param_4[6];
      *(ushort *)(piVar3 + 0xc) = (ushort)param_4[10] | 0xa000;
      *(short *)((int)piVar3 + 0x36) = (short)param_4[4];
      iVar1 = param_4[7];
      piVar3[0xf] = iVar1;
      *(undefined2 *)(piVar3 + 1) = 0;
      if (iVar1 != 0) {
        *(undefined2 *)(piVar3 + 0x10) = in_CS;
      }
      *(short *)(piVar3 + 0xe) = (short)param_4[3];
      *(short *)((int)piVar3 + 0x4a) = (short)param_4[9];
      *(undefined2 *)((int)piVar3 + 0x3a) = 0;
      piVar3[0x11] = param_4[0xe];
      *(undefined2 *)(piVar3 + 0x12) = 0;
      piVar3[0x13] = 0;
      *(short *)(piVar3 + 0x15) = (short)param_4[0x10];
      *(short *)((int)piVar3 + 0x56) = (short)param_4[0x11];
      *(short *)(piVar3 + 0x16) = (short)param_4[0x12];
      *(short *)((int)piVar3 + 0x5a) = (short)param_4[0x13];
      *(short *)(piVar3 + 0x17) = (short)param_4[0x14];
      *(short *)((int)piVar3 + 0x5e) = (short)param_4[0x15];
      *(short *)(piVar3 + 0x18) = (short)param_4[0x16];
      *(undefined4 *)((int)piVar3 + 0x62) = 0;
      *(undefined2 *)((int)piVar3 + 0x66) = 0;
      goto LAB_0047f759;
    }
    piVar3 = piVar3 + 0x1b;
    iVar2 = iVar2 + 1;
  } while (iVar2 != 0x20);
  iVar2 = -1;
LAB_0047f759:
  return CONCAT44(param_2,iVar2);
}



/* @0047f807 file=? name=FUN_0047f807 */

undefined8 __fastcall FUN_0047f807(undefined4 param_1,undefined4 param_2,int param_3,uint param_4)

{
  undefined4 uVar1;
  int iVar2;
  
  iVar2 = (int)*(undefined6 *)(&DAT_004fe4c4 + param_3 * 0x80 + param_4 * 8);
  uVar1 = 10;
  if (((param_4 < 0x21) && (uVar1 = 0, (*(ushort *)(iVar2 + 0x30) & 0x1000) == 0)) &&
     ((*(ushort *)(iVar2 + 0x30) & 0x8000) != 0)) {
    *(ushort *)(iVar2 + 0x30) = *(ushort *)(iVar2 + 0x30) & 0x7fff;
    *(undefined2 *)(iVar2 + 0x34) = 0;
  }
  return CONCAT44(param_2,uVar1);
}



/* @0047f8a2 file=? name=FUN_0047f8a2 */

void FUN_0047f8a2(void)

{
  return;
}



/* @0047f8a7 file=? name=FUN_0047f8a7 */

void FUN_0047f8a7(void)

{
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  FUN_0047e661();
  return;
}



/* @0047fa43 file=? name=FUN_0047fa43 */

void FUN_0047fa43(void)

{
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  FUN_0047e693();
  return;
}



/* @0047fbdf file=? name=FUN_0047fbdf */

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

undefined4 __cdecl FUN_0047fbdf(char *param_1)

{
  FUN_0047f8a7();
  _DAT_004ff2ec = 1;
  if (param_1 == (char *)0x0) {
    DAT_004fef8c = 0;
  }
  else {
    FUN_004d4a48(&DAT_004fef8c,param_1);
  }
  return 0;
}



/* @0047fc16 file=? name=FUN_0047fc16 */

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

undefined4 FUN_0047fc16(void)

{
  FUN_0047fa43();
  _DAT_004ff2ec = 0;
  return 0;
}



/* @0047fc2c file=? name=FUN_0047fc2c */

int __cdecl FUN_0047fc2c(uint param_1,int param_2,uint *param_3,uint *param_4)

{
  int iVar1;
  uint uVar2;
  uint local_30;
  int local_2c;
  int local_28;
  undefined4 *local_24;
  uint local_20;
  uint local_1c;
  uint local_18;
  uint local_14;
  uint local_10;
  uint local_c;
  uint local_8;
  
  local_8 = *param_3;
  local_14 = param_3[3];
  local_18 = param_3[4];
  local_1c = param_3[5];
  local_10 = param_3[6];
  for (local_c = 0;
      (uVar2 = 6, local_c < 5 && (uVar2 = local_c, *(int *)(&DAT_004fea18 + local_c * 4) != 0));
      local_c = local_c + 1) {
  }
  if (uVar2 == 6) {
    local_2c = 0xb;
  }
  else {
    *(uint *)(&DAT_004fea18 + uVar2 * 4) = param_1;
    if (param_3[10] == 0) {
      local_24 = (undefined4 *)(&DAT_004fe30c + uVar2 * 8);
      local_28 = uVar2 * 4;
      iVar1 = FUN_0047f03f(param_1,uVar2,local_24,(undefined4 *)(&DAT_004fe2e4 + uVar2 * 8),
                           (undefined2 *)(&DAT_004fe3ac + uVar2 * 4),&DAT_004fe334 + uVar2 * 4,
                           (undefined4 *)(&DAT_004fe2bc + local_28));
      if (iVar1 != 0) {
        return iVar1;
      }
      param_3[9] = *(uint *)(&DAT_004fe2e4 + uVar2 * 8);
      param_3[10] = *(uint *)(&DAT_004fe2e8 + uVar2 * 8);
      param_3[0xb] = *(uint *)(&DAT_004fe30c + uVar2 * 8);
      param_3[0xc] = *(uint *)(&DAT_004fe310 + uVar2 * 8);
      local_2c = 0;
    }
    else {
      *(uint *)(&DAT_004fe2e4 + uVar2 * 8) = param_3[9];
      *(uint *)(&DAT_004fe2e8 + uVar2 * 8) = param_3[10];
      *(uint *)(&DAT_004fe30c + uVar2 * 8) = param_3[0xb];
      *(uint *)(&DAT_004fe310 + uVar2 * 8) = param_3[0xc];
    }
    local_20 = uVar2;
    local_2c = FUN_0048082c(uVar2,(undefined1 *)(&DAT_004fea30 + uVar2 * 0x1b));
    if (local_2c == 0) {
      if (*(uint *)(&DAT_004fea18 + uVar2 * 4) < 0xe106) {
        *(uint *)(&DAT_004fe424 + uVar2 * 4) = local_8;
        if (local_14 == 0) {
          *(uint *)(&DAT_004fe438 + uVar2 * 8) = param_3[1];
          (&DAT_004fe43c)[uVar2 * 2] = param_3[2];
          local_30 = param_3[0x13];
          local_20 = uVar2;
        }
        else {
          *(undefined4 *)(&DAT_004ff2d8 + uVar2 * 4) = 1;
          iVar1 = FUN_00480686(local_8,&local_30,(undefined4 *)(&DAT_004fe474 + uVar2 * 4),
                               (undefined4 *)(&DAT_004fe438 + uVar2 * 8));
          if (iVar1 != 0) {
            FUN_0047f27c(uVar2);
            *(undefined4 *)(&DAT_004fea18 + uVar2 * 4) = 0;
            return 5;
          }
          param_3[1] = *(uint *)(&DAT_004fe438 + uVar2 * 8);
          param_3[2] = (&DAT_004fe43c)[uVar2 * 2];
          if (*(int *)(&DAT_004fea54 + uVar2 * 0x6c) == 8) {
            if ((*(uint *)(&DAT_004fea6c + uVar2 * 0x6c) & 0x8000) == 0) {
              local_20 = uVar2;
              FUN_0047f016(*(undefined1 **)(&DAT_004fe438 + uVar2 * 8),(&DAT_004fe43c)[uVar2 * 2],
                           local_8,0x80);
            }
            else {
              local_20 = uVar2;
              FUN_0047f016(*(undefined1 **)(&DAT_004fe438 + uVar2 * 8),(&DAT_004fe43c)[uVar2 * 2],
                           local_8,0);
            }
          }
          else {
            local_20 = uVar2;
            FUN_0047f016(*(undefined1 **)(&DAT_004fe438 + uVar2 * 8),(&DAT_004fe43c)[uVar2 * 2],
                         local_8,0);
          }
        }
        if (param_3[0xe] == 0) {
          if (param_3[0x12] == 0) {
            local_2c = FUN_0047f334(*(uint *)(&DAT_004fea98 + uVar2 * 0x6c),
                                    (undefined4 *)(&DAT_004fe384 + uVar2 * 8),
                                    (undefined4 *)(&DAT_004fe35c + uVar2 * 8),
                                    (undefined2 *)(&DAT_004fe3c0 + uVar2 * 4),
                                    &DAT_004fe348 + uVar2 * 4,
                                    (undefined4 *)(&DAT_004fe2d0 + uVar2 * 4));
            if (local_2c != 0) {
              return local_2c;
            }
          }
          else {
            iVar1 = FUN_0047f334(param_3[0x12],(undefined4 *)(&DAT_004fe384 + uVar2 * 8),
                                 (undefined4 *)(&DAT_004fe35c + uVar2 * 8),
                                 (undefined2 *)(&DAT_004fe3c0 + uVar2 * 4),&DAT_004fe348 + uVar2 * 4
                                 ,(undefined4 *)(&DAT_004fe2d0 + uVar2 * 4));
            if (iVar1 != 0) {
              return iVar1;
            }
            local_2c = 0;
          }
          param_3[0xd] = *(uint *)(&DAT_004fe35c + uVar2 * 8);
          param_3[0xe] = *(uint *)(&DAT_004fe360 + uVar2 * 8);
          param_3[0xf] = *(uint *)(&DAT_004fe384 + uVar2 * 8);
          param_3[0x10] = *(uint *)(&DAT_004fe388 + uVar2 * 8);
        }
        else {
          *(uint *)(&DAT_004fe35c + uVar2 * 8) = param_3[0xd];
          *(uint *)(&DAT_004fe360 + uVar2 * 8) = param_3[0xe];
          *(uint *)(&DAT_004fe384 + uVar2 * 8) = param_3[0xf];
          *(uint *)(&DAT_004fe388 + uVar2 * 8) = param_3[0x10];
        }
        local_20 = uVar2;
        if ((*(uint *)(&DAT_004fea6c + uVar2 * 0x6c) & 0x200) != 0) {
          FUN_0047ecf1();
        }
        *(undefined4 *)(&DAT_004fe3e8 + uVar2 * 4) = 1;
        FUN_0047eaa0(*(undefined4 *)(&DAT_004fe384 + uVar2 * 8),
                     (short)*(undefined4 *)(&DAT_004fe388 + uVar2 * 8),
                     *(undefined4 *)(&DAT_004fe35c + uVar2 * 8),
                     (short)*(undefined4 *)(&DAT_004fe360 + uVar2 * 8),
                     *(undefined6 *)(&DAT_004fe438 + uVar2 * 8));
        *(undefined4 *)(&DAT_004fe49c + uVar2 * 8) = DAT_004ff300;
        *(undefined4 *)(&DAT_004fe4a0 + uVar2 * 8) = DAT_004ff304;
        *(undefined4 *)(&DAT_004fe9ec + uVar2 * 8) = DAT_004ff308;
        *(undefined4 *)(uVar2 * 8 + 0x4fe9f0) = DAT_004ff30c;
        local_20 = uVar2;
        FUN_0047e85f((int *)(&DAT_004fe4c4 + uVar2 * 0x100),
                     CONCAT15((char)((uint)DAT_004ff314 >> 8),
                              CONCAT14((char)DAT_004ff314,DAT_004ff310)));
      }
      else {
        *(undefined4 *)(&DAT_004fe4a0 + uVar2 * 8) = 0;
      }
      param_3[7] = *(uint *)(&DAT_004fe49c + uVar2 * 8);
      param_3[8] = *(uint *)(&DAT_004fe4a0 + uVar2 * 8);
      local_20 = uVar2;
      FUN_0047ebc8();
      *(uint *)(&DAT_004fe460 + uVar2 * 4) = local_30;
      (&DAT_004fecd8)[uVar2] = (char)*(undefined4 *)(param_2 + 8);
      FUN_0047eaf3();
      FUN_0047eb77();
      FUN_0047eb51();
      local_30 = *(uint *)(&DAT_004fe460 + uVar2 * 4);
      FUN_0047eb28();
      *(undefined4 *)(&DAT_004fe3d4 + uVar2 * 4) = 1;
      *(undefined4 *)(&DAT_004fe3fc + uVar2 * 4) = 1;
      param_3[0x11] = (uint)(&PTR_FUN_004ff380)[uVar2];
      *(uint *)(&DAT_004fece0 + uVar2 * 0x50) = *param_3;
      *(uint *)(&DAT_004fece4 + uVar2 * 0x50) = param_3[1];
      *(uint *)(uVar2 * 0x50 + 0x4fece8) = param_3[2];
      *(uint *)(&DAT_004fecec + uVar2 * 0x50) = param_3[3];
      *(uint *)(&DAT_004fecf0 + uVar2 * 0x50) = param_3[4];
      (&DAT_004fecf4)[uVar2 * 0x14] = param_1;
      *(uint *)(&DAT_004fecf8 + uVar2 * 0x50) = param_3[6];
      (&DAT_004fecfc)[uVar2 * 0x14] = param_3[7];
      (&DAT_004fed00)[uVar2 * 0x14] = param_3[8];
      *(uint *)(&DAT_004fed04 + uVar2 * 0x50) = param_3[9];
      *(uint *)(uVar2 * 0x50 + 0x4fed08) = param_3[10];
      *(uint *)(&DAT_004fed14 + uVar2 * 0x50) = param_3[0xd];
      *(uint *)(uVar2 * 0x50 + 0x4fed18) = param_3[0xe];
      *(uint *)(&DAT_004fed0c + uVar2 * 0x50) = param_3[0xb];
      *(uint *)(uVar2 * 0x50 + 0x4fed10) = param_3[0xc];
      *(uint *)(&DAT_004fed1c + uVar2 * 0x50) = param_3[0xf];
      (&DAT_004fed20)[uVar2 * 0x14] = param_3[0x10];
      *(uint *)(&DAT_004fed24 + uVar2 * 0x50) = param_3[0x11];
      *(uint *)(&DAT_004fed28 + uVar2 * 0x50) = param_3[0x12];
      *param_4 = uVar2;
      local_2c = 0;
    }
  }
  return local_2c;
}



/* @004804bd file=? name=FUN_004804bd */

undefined4 __cdecl FUN_004804bd(uint param_1,int param_2,int param_3)

{
  char cVar1;
  undefined4 uVar2;
  
  if (*(int *)(&DAT_004fe3d4 + param_1 * 4) == 0) {
    uVar2 = 1;
  }
  else {
    *(undefined4 *)(&DAT_004fe3fc + param_1 * 4) = 0;
    if (((*(uint *)(&DAT_004fe488 + param_1 * 4) < 0xe106) &&
        (*(int *)(&DAT_004ff2d8 + param_1 * 4) != 0)) && (param_2 != 0)) {
      cVar1 = FUN_0047ed51();
      if (cVar1 == '\x03') {
        FUN_0048078c();
      }
      else {
        FUN_0047e8c5();
      }
      *(undefined4 *)(&DAT_004ff2d8 + param_1 * 4) = 0;
    }
    FUN_0047e973();
    FUN_0047ea7d();
    FUN_0047ebfd();
    if (param_3 != 0) {
      FUN_0047f27c(param_1);
      FUN_0047f525();
    }
    *(undefined4 *)(&DAT_004fe2e8 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_004fe310 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_004fe4a0 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_004fe360 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_004fe388 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_004fea18 + param_1 * 4) = 0;
    *(undefined4 *)(&DAT_004fe3d4 + param_1 * 4) = 0;
    uVar2 = 0;
  }
  return uVar2;
}



/* @00480686 file=? name=FUN_00480686 */

undefined4 __cdecl FUN_00480686(uint param_1,uint *param_2,undefined4 *param_3,undefined4 *param_4)

{
  char cVar1;
  int iVar2;
  undefined4 uVar3;
  undefined4 local_14;
  uint local_10;
  uint local_c;
  undefined4 local_8;
  
  cVar1 = FUN_0047ed51();
  if (cVar1 == '\x03') {
    iVar2 = FUN_0048073c(param_4,&local_8,&local_c);
    if (iVar2 == 0) {
      *param_2 = local_c;
      *param_3 = local_8;
      uVar3 = 0;
    }
    else {
      uVar3 = 1;
    }
  }
  else {
    FUN_0047e88f((param_1 >> 4) + 4,(int *)&local_10,(undefined2 *)&local_14);
    *param_2 = local_10;
    while (0xffff - param_1 < (local_10 & 0xffff)) {
      FUN_0047e88f((param_1 >> 4) + 4,(int *)&local_10,(undefined2 *)&local_14);
      *param_2 = local_10;
    }
    param_4[1] = local_14;
    *param_4 = 0;
    uVar3 = 0;
  }
  return uVar3;
}



/* @0048073c file=? name=FUN_0048073c */

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

{
  bool bVar1;
  undefined3 extraout_var;
  undefined4 uVar2;
  undefined4 local_c;
  undefined2 local_8 [2];
  
  param_1[1] = 0;
  *param_1 = 0;
  *param_2 = 0;
  *param_3 = 0;
  local_c = 0;
  bVar1 = FUN_0047ed6e(0x20,local_8,(undefined2 *)&local_c);
  if (CONCAT31(extraout_var,bVar1) == 0) {
    uVar2 = 5;
  }
  else {
    uVar2 = 0;
  }
  return uVar2;
}



/* @0048078c file=? name=FUN_0048078c */

void FUN_0048078c(void)

{
  undefined2 local_c [2];
  undefined2 local_8 [2];
  
  FUN_0047ef16();
  FUN_0047ed6e(0x20,local_8,local_c);
  return;
}



/* @004807af file=? name=FUN_004807af */

void FUN_004807af(void)

{
  FUN_0047eff4();
  return;
}



/* @004807c6 file=? name=FUN_004807c6 */

void FUN_004807c6(void)

{
  FUN_0047eff4();
  return;
}



/* @004807dd file=? name=FUN_004807dd */

void FUN_004807dd(void)

{
  FUN_0047eff4();
  return;
}



/* @004807f4 file=? name=FUN_004807f4 */

void FUN_004807f4(void)

{
  FUN_0047eff4();
  return;
}



/* @0048080b file=? name=FUN_0048080b */

void FUN_0048080b(void)

{
  FUN_0047eff4();
  return;
}



/* @00480822 file=? name=FUN_00480822 */

void FUN_00480822(void)

{
  return;
}



/* @00480827 file=? name=FUN_00480827 */

void FUN_00480827(void)

{
  return;
}



/* @0048082c file=? name=FUN_0048082c */

undefined4 __cdecl FUN_0048082c(int param_1,undefined1 *param_2)

{
  undefined4 uVar1;
  
  if (*(int *)(&DAT_004fe2e8 + param_1 * 8) == 0) {
    uVar1 = 1;
  }
  else if (param_2 == (undefined1 *)0x0) {
    uVar1 = 2;
  }
  else {
    FUN_0047e923(*(undefined4 *)(&DAT_004fe30c + param_1 * 8),
                 *(undefined4 *)(&DAT_004fe310 + param_1 * 8),
                 *(undefined6 *)(&DAT_004fe2e4 + param_1 * 8),param_2);
    uVar1 = 0;
  }
  return uVar1;
}



/* @0048088f file=? name=FUN_0048088f */

void FUN_0048088f(void)

{
  return;
}



/* @00480894 file=? name=FUN_00480894 */

void FUN_00480894(void)

{
  return;
}



/* @004809ba file=? name=FUN_004809ba */

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

undefined4 FUN_004809ba(void)

{
  _DAT_004ff1ec = 0;
  FUN_004de420(DAT_004ff214);
  thunk_FUN_004d92c4(DAT_004ff200);
  FUN_0047e693();
  FUN_0047e7c4();
  FUN_0047e7c4();
  return 0;
}



/* @0048116d file=? name=FUN_0048116d */

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

undefined4 __cdecl FUN_0048116d(undefined4 *param_1)

{
  undefined4 uVar1;
  
  if (param_1 == (undefined4 *)0x0) {
    uVar1 = 2;
  }
  else {
    thunk_FUN_004d9334(DAT_004ff200,DAT_004ff204,0);
    FUN_0047e9b9();
    *param_1 = DAT_004fe270;
    param_1[2] = DAT_004fe274;
    param_1[1] = DAT_004fe278;
    param_1[3] = DAT_004fe27c;
    if ((_DAT_004ff258 & 1) == 0) {
      if ((DAT_004fe278 < 2) || (0xf < DAT_004fe278)) {
        uVar1 = 0x11;
      }
      else {
        uVar1 = 0;
      }
    }
    else {
      uVar1 = 0;
    }
  }
  return uVar1;
}



/* @00481286 file=? name=FUN_00481286 */

void FUN_00481286(void)

{
  return;
}



/* @0048130d file=? name=FUN_0048130d */

void __cdecl FUN_0048130d(undefined4 param_1)

{
  byte bVar1;
  
  if (DAT_005005ec != 0) {
    bVar1 = in(0x21);
    out(0x21,bVar1 | 1);
    out(0x43,0x36);
    out(0x40,(char)param_1);
    out(0x40,(char)((uint)param_1 >> 8));
    bVar1 = in(0x21);
    out(0x21,bVar1 & 0xfe);
  }
  return;
}



/* @00481353 file=? name=FUN_00481353 */

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

void __cdecl FUN_00481353(undefined4 param_1,undefined4 param_2)

{
  code *pcVar1;
  byte bVar2;
  undefined2 extraout_CX;
  undefined4 extraout_EDX;
  undefined2 in_DS;
  
  DAT_004ff5c4 = param_2;
  DAT_004ff5c8 = in_DS;
  _DAT_004ff5ce = in_DS;
  if (DAT_005005ec != 0) {
    bVar2 = in(0x21);
    out(0x21,bVar2 | 1);
    pcVar1 = (code *)swi(0x31);
    (*pcVar1)();
    pcVar1 = (code *)swi(0x31);
    DAT_004ff5b8 = extraout_EDX;
    DAT_004ff5bc._0_2_ = extraout_CX;
    (*pcVar1)();
    out(0x43,0x36);
    out(0x40,(char)param_1);
    out(0x40,(char)((uint)param_1 >> 8));
    bVar2 = in(0x21);
    out(0x21,bVar2 & 0xfe);
  }
  return;
}



/* @004813d5 file=? name=FUN_004813d5 */

void FUN_004813d5(void)

{
  byte bVar1;
  
  if (DAT_005005ec != 0) {
    bVar1 = in(0x21);
    out(0x21,bVar1 | 1);
  }
  return;
}



/* @00481401 file=? name=FUN_00481401 */

void FUN_00481401(void)

{
  byte bVar1;
  
  if (DAT_005005ec != 0) {
    bVar1 = in(0x21);
    out(0x21,bVar1 & 0xfe);
  }
  return;
}



/* @0048142d file=? name=FUN_0048142d */

void FUN_0048142d(void)

{
  code *pcVar1;
  byte bVar2;
  
  if (DAT_005005ec != 0) {
    bVar2 = in(0x21);
    out(0x21,bVar2 | 1);
    pcVar1 = (code *)swi(0x31);
    (*pcVar1)();
    out(0x40,0);
    out(0x40,0);
    bVar2 = in(0x21);
    out(0x21,bVar2 & 0xfe);
  }
  return;
}



/* @00481480 file=? name=FUN_00481480 */

/* WARNING: Stack frame is not setup normally: Input value of stackpointer is not used */
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

undefined8 __fastcall FUN_00481480(undefined4 param_1,undefined4 param_2)

{
  undefined4 uVar1;
  undefined4 in_EAX;
  undefined4 uVar2;
  undefined4 *puVar3;
  
  if (DAT_005005ec != 0) {
    DAT_005005e2 = 0;
    uVar2 = *(undefined4 *)(_DAT_005005da + 0x20);
    DAT_005005de = *(undefined4 *)(_DAT_005005da + 0x28);
    puVar3 = (undefined4 *)DAT_004ff5d2;
    uVar1 = *puVar3;
    _DAT_005005da = CONCAT22(DAT_005005da_2,(short)uVar1);
    *puVar3 = uVar1;
    puVar3[-1] = uVar1;
    puVar3[-1] = DAT_004ff5b8;
    *puVar3 = DAT_004ff5bc;
    puVar3[-2] = DAT_005005de;
    return CONCAT44(uVar2,puVar3[-2]);
  }
  return CONCAT44(param_2,in_EAX);
}



/* @004814d9 file=? name=FUN_004814d9 */

undefined2 FUN_004814d9(void)

{
  return DAT_004ff5c8;
}



/* @004814e4 file=? name=FUN_004814e4 */

void FUN_004814e4(void)

{
  return;
}



/* @004814e9 file=? name=FUN_004814e9 */

undefined * __cdecl FUN_004814e9(int param_1)

{
  return (&PTR_s_Error_Code_Does_Not_Indicate_An_E_004ff288)[param_1];
}



/* @004814fc file=? name=FUN_004814fc */

void FUN_004814fc(void)

{
  return;
}



/* @00481528 file=? name=FUN_00481528 */

undefined8 __fastcall
FUN_00481528(undefined4 param_1,undefined4 param_2,int param_3,int param_4,undefined2 param_5)

{
  undefined6 *puVar1;
  int iVar2;
  
  puVar1 = (undefined6 *)(&DAT_004fe4c4 + param_3 * 0x80 + param_4 * 8);
  iVar2 = (int)*puVar1;
  if ((*(ushort *)(iVar2 + 0x30) & 0x8000) != 0) {
    puVar1 = (undefined6 *)(uint)*(ushort *)(iVar2 + 0x32);
    *(undefined2 *)(iVar2 + 0x32) = param_5;
  }
  return CONCAT44(param_2,puVar1);
}



/* @00481675 file=? name=FUN_00481675 */

undefined8 __fastcall
FUN_00481675(undefined4 param_1,undefined4 param_2,int param_3,int param_4,undefined2 param_5)

{
  undefined6 *puVar1;
  int iVar2;
  
  puVar1 = (undefined6 *)(&DAT_004fe4c4 + param_3 * 0x80 + param_4 * 8);
  iVar2 = (int)*puVar1;
  if ((*(ushort *)(iVar2 + 0x30) & 0x8000) != 0) {
    puVar1 = (undefined6 *)(uint)*(ushort *)(iVar2 + 0x54);
    *(undefined2 *)(iVar2 + 0x54) = param_5;
  }
  return CONCAT44(param_2,puVar1);
}



/* @0048186d file=? name=FUN_0048186d */

void FUN_0048186d(void)

{
  return;
}



/* @00481872 file=? name=FUN_00481872 */

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

undefined4 __cdecl FUN_00481872(uint param_1,uint param_2)

{
  DAT_005005f0 = (param_2 & 2) != 0;
  if ((param_2 & 1) == 0) {
    DAT_005005ec._0_1_ = 1;
    FUN_004813d5();
    FUN_00481353(0xffff,&LAB_00481e2b);
    FUN_00481401();
  }
  else {
    DAT_005005ec._0_1_ = 0;
  }
  if ((param_1 == 0) || ((param_2 & 1) != 0)) {
    DAT_004fee74 = 0xffff;
  }
  else {
    if (param_1 == 0xff00) {
      FUN_00481e10(0xffff);
      DAT_004feef4 = 0xff00;
    }
    else {
      FUN_00481e10((int)(0x1234dc / (ulonglong)param_1));
      DAT_004feef4 = param_1;
    }
    _DAT_004feeb4 = FUN_00481eff;
    _DAT_004fef34 = 0x10000;
  }
  return 0;
}



/* @00481934 file=? name=FUN_00481934 */

undefined4 FUN_00481934(void)

{
  if ((char)DAT_005005ec != '\0') {
    FUN_004813d5();
    FUN_0048142d();
    FUN_00481401();
  }
  return 0;
}



/* @00481953 file=? name=FUN_00481953 */

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

{
  undefined4 uVar1;
  uint uVar2;
  uint uVar3;
  uint local_8;
  
  local_8 = 0;
  for (uVar2 = 0; (uVar2 < 0x10 && ((&DAT_004fee78)[uVar2] != 0)); uVar2 = uVar2 + 1) {
  }
  if (uVar2 < 0x10) {
    if ((char)DAT_005005ec != '\0') {
      FUN_004813d5();
    }
    (&DAT_004fee78)[uVar2] = param_2;
    (&DAT_004feeb8)[uVar2] = param_1;
    if ((uint)(0x1234dc / (ulonglong)param_1) < DAT_004fee74) {
      FUN_00481e10((int)(0x1234dc / (ulonglong)param_1));
      local_8 = (DAT_004fee74 << 0x10) / (uint)(0x1234dc / (ulonglong)param_1);
    }
    for (uVar3 = 0; uVar3 < 0x10; uVar3 = uVar3 + 1) {
      if ((&DAT_004fee78)[uVar3] != 0) {
        if ((&DAT_004feeb8)[uVar3] == 0xff00) {
          if (DAT_004fee74 == 0xffff) {
            (&DAT_004feef8)[uVar3] = 0x10000;
          }
          else {
            (&DAT_004feef8)[uVar3] = (int)(0x123333 / (0x1234dc / (ulonglong)DAT_004fee74));
          }
        }
        else {
          (&DAT_004feef8)[uVar3] =
               (uint)((&DAT_004feeb8)[uVar3] << 0x10) / (uint)(0x1234dc / (ulonglong)DAT_004fee74);
        }
        if (local_8 != 0) {
          (&DAT_004fef38)[uVar3] =
               ((local_8 & 0xffff) * (&DAT_004fef38)[uVar3] >> 0x10) +
               ((local_8 >> 0x10) * (&DAT_004fef38)[uVar3] >> 0x10);
        }
      }
    }
    if ((char)DAT_005005ec != '\0') {
      FUN_00481401();
    }
    *param_3 = uVar2;
    uVar1 = 0;
  }
  else {
    uVar1 = 0xb;
  }
  return uVar1;
}



/* @00481b29 file=? name=FUN_00481b29 */

undefined4 __cdecl FUN_00481b29(uint param_1,uint param_2)

{
  undefined4 uVar1;
  uint uVar2;
  
  if (param_1 < 0x10) {
    if ((&DAT_004fee78)[param_1] == 0) {
      uVar1 = 10;
    }
    else {
      if ((char)DAT_005005ec != '\0') {
        FUN_004813d5();
      }
      (&DAT_004feeb8)[param_1] = param_2;
      if ((uint)(0x1234dc / (ulonglong)param_2) < DAT_004fee74) {
        FUN_00481e10((int)(0x1234dc / (ulonglong)param_2));
      }
      for (uVar2 = 0; uVar2 < 0x10; uVar2 = uVar2 + 1) {
        if ((&DAT_004fee78)[uVar2] != 0) {
          if ((&DAT_004feeb8)[uVar2] == 0xff00) {
            if (DAT_004fee74 == 0xffff) {
              (&DAT_004feef8)[uVar2] = 0x10000;
            }
            else {
              (&DAT_004feef8)[uVar2] = (int)(0x123333 / (0x1234dc / (ulonglong)DAT_004fee74));
            }
          }
          else {
            (&DAT_004feef8)[uVar2] =
                 (uint)((&DAT_004feeb8)[uVar2] << 0x10) / (uint)(0x1234dc / (ulonglong)DAT_004fee74)
            ;
          }
          (&DAT_004fef38)[uVar2] = 0;
        }
      }
      if ((char)DAT_005005ec != '\0') {
        FUN_00481401();
      }
      uVar1 = 0;
    }
  }
  else {
    uVar1 = 10;
  }
  return uVar1;
}



/* @00481c82 file=? name=FUN_00481c82 */

undefined4 __cdecl FUN_00481c82(int param_1)

{
  uint uVar1;
  uint uVar2;
  
  uVar1 = 0;
  (&DAT_004fee78)[param_1] = 0;
  for (uVar2 = 0; uVar2 < 0x10; uVar2 = uVar2 + 1) {
    if ((((&DAT_004fee78)[uVar2] != 0) && (uVar1 < (uint)(&DAT_004feeb8)[uVar2])) &&
       ((&DAT_004feeb8)[uVar2] != 0xff00)) {
      uVar1 = (&DAT_004feeb8)[uVar2];
    }
  }
  if (uVar1 == 0) {
    FUN_00481e10(0xffff);
  }
  else {
    FUN_00481e10((int)(0x1234dc / (ulonglong)uVar1));
  }
  if ((char)DAT_005005ec != '\0') {
    FUN_004813d5();
  }
  for (uVar1 = 0; uVar1 < 0x10; uVar1 = uVar1 + 1) {
    if ((&DAT_004fee78)[uVar1] != 0) {
      if ((&DAT_004feeb8)[uVar1] == 0xff00) {
        if (DAT_004fee74 == 0xffff) {
          (&DAT_004feef8)[uVar1] = 0x10000;
        }
        else {
          (&DAT_004feef8)[uVar1] = (int)(0x123333 / (0x1234dc / (ulonglong)DAT_004fee74));
        }
      }
      else {
        (&DAT_004feef8)[uVar1] =
             (uint)((&DAT_004feeb8)[uVar1] << 0x10) / (uint)(0x1234dc / (ulonglong)DAT_004fee74);
      }
      (&DAT_004fef38)[uVar1] = 0;
    }
  }
  if ((char)DAT_005005ec != '\0') {
    FUN_00481401();
  }
  return 0;
}



/* @00481dfd file=? name=FUN_00481dfd */

undefined4 __cdecl FUN_00481dfd(int param_1)

{
  return (&DAT_004feeb8)[param_1];
}



/* @00481e10 file=? name=FUN_00481e10 */

undefined4 __cdecl FUN_00481e10(undefined4 param_1)

{
  DAT_004fee74 = param_1;
  FUN_0048130d(param_1);
  return 0;
}



/* @00481eff file=? name=FUN_00481eff */

undefined8 __fastcall FUN_00481eff(undefined4 param_1,undefined4 param_2)

{
  undefined8 uVar1;
  
  uVar1 = FUN_00481480(param_1,param_2);
  return uVar1;
}



/* @00481f09 file=? name=FUN_00481f09 */

void FUN_00481f09(void)

{
  return;
}



/* @00481f0e file=? name=FUN_00481f0e */

void FUN_00481f0e(void)

{
  return;
}



/* @00481f13 file=? name=FUN_00481f13 */

bool __cdecl FUN_00481f13(int param_1)

{
  return *(int *)(&DAT_00500674 + param_1 * 4) == 0;
}



/* @00481f6d file=? name=FUN_00481f6d */

void FUN_00481f6d(void)

{
  return;
}



/* @00481f72 file=? name=FUN_00481f72 */

void FUN_00481f72(void)

{
  return;
}



/* @0048255c file=? name=FUN_0048255c */

undefined4 __cdecl FUN_0048255c(uint param_1)

{
  undefined4 uVar1;
  
  if (param_1 < 8) {
    *(undefined4 *)(&DAT_005015c8 + param_1 * 4) = 0;
    uVar1 = 0;
  }
  else {
    uVar1 = 10;
  }
  return uVar1;
}



/* @00482587 file=? name=FUN_00482587 */

int __cdecl FUN_00482587(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00481953(*(uint *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x38),&LAB_00486467,
                       (uint *)(&DAT_005015e8 + param_1 * 4));
  if (iVar1 == 0) {
    (&DAT_004fef78)[*(int *)(&DAT_005015e8 + param_1 * 4)] = (char)param_1;
    (&DAT_00501588)[param_1] = 1;
    iVar1 = 0;
  }
  return iVar1;
}



/* @004826d1 file=? name=FUN_004826d1 */

undefined4 __cdecl FUN_004826d1(int param_1,undefined4 *param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  uint uVar4;
  int local_8;
  
  local_8 = 0;
  uVar1 = FUN_00484177(*param_2);
  *(undefined4 *)(&DAT_005015c8 + param_1 * 4) = uVar1;
  iVar2 = *(int *)(&DAT_005015c8 + param_1 * 4) + 0x388;
  *(undefined4 *)(&DAT_00501300 + param_1 * 4) =
       *(undefined4 *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x30);
  *(undefined4 *)(&DAT_00501320 + param_1 * 4) = *(undefined4 *)(&DAT_00501300 + param_1 * 4);
  *(undefined4 *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x380) = param_2[1];
  for (uVar4 = 0; uVar4 < *(uint *)(&DAT_00501300 + param_1 * 4); uVar4 = uVar4 + 1) {
    *(undefined4 *)(&DAT_00500ee0 + param_1 * 0x80 + uVar4 * 4) = 0;
    uVar1 = FUN_00484177(local_8 + iVar2);
    *(undefined4 *)(&DAT_00502bd8 + param_1 * 0x80 + uVar4 * 4) = uVar1;
    uVar1 = FUN_00484177(local_8 + 0xc + iVar2);
    *(undefined4 *)(&DAT_005006e0 + param_1 * 0x80 + uVar4 * 4) = uVar1;
    iVar3 = FUN_004828ab(*(byte **)(&DAT_005006e0 + param_1 * 0x80 + uVar4 * 4),
                         (uint *)(&DAT_00500ae0 + param_1 * 0x80 + uVar4 * 4));
    *(int *)(&DAT_005006e0 + param_1 * 0x80 + uVar4 * 4) =
         *(int *)(&DAT_005006e0 + param_1 * 0x80 + uVar4 * 4) + iVar3;
    iVar3 = FUN_00484177(local_8 + iVar2);
    local_8 = local_8 + *(int *)(iVar3 + 4);
  }
  for (uVar4 = 0; uVar4 < *(uint *)(&DAT_00501320 + param_1 * 4); uVar4 = uVar4 + 1) {
    if (*(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + uVar4 * 4) == 0xff) {
      *(undefined4 *)(&DAT_005006e0 + param_1 * 0x80 + uVar4 * 4) = 0;
      *(int *)(&DAT_00501300 + param_1 * 4) = *(int *)(&DAT_00501300 + param_1 * 4) + -1;
    }
  }
  return 0;
}



/* @004828ab file=? name=FUN_004828ab */

int __cdecl FUN_004828ab(byte *param_1,uint *param_2)

{
  byte bVar1;
  bool bVar2;
  byte bVar3;
  int local_10;
  uint local_c;
  
  bVar2 = false;
  bVar3 = 0;
  local_c = 0;
  local_10 = 0;
  do {
    local_10 = local_10 + 1;
    bVar1 = *param_1;
    param_1 = param_1 + 1;
    if ((bVar1 & 0x80) != 0) {
      bVar2 = true;
    }
    local_c = local_c | (uint)(bVar1 & 0x7f) << (bVar3 & 0x1f);
    bVar3 = bVar3 + 7;
  } while (!bVar2);
  *param_2 = local_c;
  return local_10;
}



/* @00482909 file=? name=FUN_00482909 */

undefined4 __cdecl FUN_00482909(undefined1 param_1)

{
  uint uVar1;
  
  DAT_00503d24 = param_1;
  for (uVar1 = 0; uVar1 < 8; uVar1 = uVar1 + 1) {
    if ((&DAT_00501588)[uVar1] != 0) {
      FUN_00483f75(uVar1,(&DAT_00503d28)[uVar1 * 4]);
    }
  }
  return 0;
}



/* @00482951 file=? name=FUN_00482951 */

undefined4 __cdecl FUN_00482951(int param_1,undefined4 param_2)

{
  *(undefined4 *)(&DAT_005043dc + param_1 * 4) = param_2;
  return 0;
}



/* @0048296b file=? name=FUN_0048296b */

undefined4 __cdecl FUN_0048296b(int param_1,undefined4 param_2)

{
  *(undefined4 *)(&DAT_005043bc + param_1 * 4) = param_2;
  return 0;
}



/* @00482985 file=? name=FUN_00482985 */

undefined4 __cdecl FUN_00482985(int param_1,byte param_2,undefined4 param_3)

{
  *(undefined4 *)(&DAT_005043fc + param_1 * 0x1fc + (uint)param_2 * 4) = param_3;
  return 0;
}



/* @00482c9f file=? name=FUN_00482c9f */

void FUN_00482c9f(void)

{
  return;
}



/* @00482ca4 file=? name=FUN_00482ca4 */

void FUN_00482ca4(void)

{
  return;
}



/* @00482ca9 file=? name=FUN_00482ca9 */

bool __cdecl FUN_00482ca9(int param_1)

{
  return (bool)('\x01' - ((&DAT_00501588)[param_1] != 0));
}



/* @00482cc1 file=? name=FUN_00482cc1 */

void FUN_00482cc1(void)

{
  return;
}



/* @00482cc6 file=? name=FUN_00482cc6 */

void FUN_00482cc6(void)

{
  return;
}



/* @00482ccb file=? name=FUN_00482ccb */

undefined4 FUN_00482ccb(void)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_0047e661();
  if (iVar1 == 0) {
    iVar1 = FUN_0047e661();
    if (iVar1 == 0) {
      iVar1 = FUN_0047e661();
      if (iVar1 == 0) {
        iVar1 = FUN_0047e661();
        if (iVar1 == 0) {
          iVar1 = FUN_0047e661();
          if (iVar1 == 0) {
            iVar1 = FUN_0047e661();
            if (iVar1 == 0) {
              iVar1 = FUN_0047e661();
              if (iVar1 == 0) {
                iVar1 = FUN_0047e661();
                if (iVar1 == 0) {
                  iVar1 = FUN_0047e661();
                  if (iVar1 == 0) {
                    iVar1 = FUN_0047e661();
                    if (iVar1 == 0) {
                      iVar1 = FUN_0047e661();
                      if (iVar1 == 0) {
                        iVar1 = FUN_0047e661();
                        if (iVar1 == 0) {
                          iVar1 = FUN_0047e661();
                          if (iVar1 == 0) {
                            iVar1 = FUN_0047e661();
                            if (iVar1 == 0) {
                              iVar1 = FUN_0047e661();
                              if (iVar1 == 0) {
                                uVar2 = 0;
                              }
                              else {
                                uVar2 = 5;
                              }
                            }
                            else {
                              uVar2 = 5;
                            }
                          }
                          else {
                            uVar2 = 5;
                          }
                        }
                        else {
                          uVar2 = 5;
                        }
                      }
                      else {
                        uVar2 = 5;
                      }
                    }
                    else {
                      uVar2 = 5;
                    }
                  }
                  else {
                    uVar2 = 5;
                  }
                }
                else {
                  uVar2 = 5;
                }
              }
              else {
                uVar2 = 5;
              }
            }
            else {
              uVar2 = 5;
            }
          }
          else {
            uVar2 = 5;
          }
        }
        else {
          uVar2 = 5;
        }
      }
      else {
        uVar2 = 5;
      }
    }
    else {
      uVar2 = 5;
    }
  }
  else {
    uVar2 = 5;
  }
  return uVar2;
}



/* @00482f2f file=? name=FUN_00482f2f */

undefined4 FUN_00482f2f(void)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_0047e693();
  if (iVar1 == 0) {
    iVar1 = FUN_0047e693();
    if (iVar1 == 0) {
      iVar1 = FUN_0047e693();
      if (iVar1 == 0) {
        iVar1 = FUN_0047e693();
        if (iVar1 == 0) {
          iVar1 = FUN_0047e693();
          if (iVar1 == 0) {
            iVar1 = FUN_0047e693();
            if (iVar1 == 0) {
              iVar1 = FUN_0047e693();
              if (iVar1 == 0) {
                iVar1 = FUN_0047e693();
                if (iVar1 == 0) {
                  iVar1 = FUN_0047e693();
                  if (iVar1 == 0) {
                    iVar1 = FUN_0047e693();
                    if (iVar1 == 0) {
                      iVar1 = FUN_0047e693();
                      if (iVar1 == 0) {
                        iVar1 = FUN_0047e693();
                        if (iVar1 == 0) {
                          iVar1 = FUN_0047e693();
                          if (iVar1 == 0) {
                            iVar1 = FUN_0047e693();
                            if (iVar1 == 0) {
                              iVar1 = FUN_0047e693();
                              if (iVar1 == 0) {
                                uVar2 = 0;
                              }
                              else {
                                uVar2 = 5;
                              }
                            }
                            else {
                              uVar2 = 5;
                            }
                          }
                          else {
                            uVar2 = 5;
                          }
                        }
                        else {
                          uVar2 = 5;
                        }
                      }
                      else {
                        uVar2 = 5;
                      }
                    }
                    else {
                      uVar2 = 5;
                    }
                  }
                  else {
                    uVar2 = 5;
                  }
                }
                else {
                  uVar2 = 5;
                }
              }
              else {
                uVar2 = 5;
              }
            }
            else {
              uVar2 = 5;
            }
          }
          else {
            uVar2 = 5;
          }
        }
        else {
          uVar2 = 5;
        }
      }
      else {
        uVar2 = 5;
      }
    }
    else {
      uVar2 = 5;
    }
  }
  else {
    uVar2 = 5;
  }
  return uVar2;
}



/* @00483193 file=? name=FUN_00483193 */

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

int __cdecl FUN_00483193(char *param_1)

{
  int iVar1;
  
  iVar1 = FUN_00482ccb();
  if (iVar1 == 0) {
    if (param_1 == (char *)0x0) {
      DAT_00503dac = 0;
    }
    else {
      FUN_004d4a48(&DAT_00503dac,param_1);
    }
    DAT_00501674 = FUN_00487a02;
    _DAT_0050167c = &LAB_00487a27;
    _DAT_00501684 = &LAB_00487a56;
    _DAT_0050168c = &LAB_00487a85;
    _DAT_00501694 = &LAB_00487ab4;
    DAT_00501678 = FUN_0047ef44();
    _DAT_00501680 = FUN_0047ef44();
    _DAT_00501688 = FUN_0047ef44();
    _DAT_00501690 = FUN_0047ef44();
    _DAT_00501698 = FUN_0047ef44();
    DAT_0050212c = &LAB_00487ae3;
    _DAT_00502134 = &LAB_00487b12;
    _DAT_0050213c = &LAB_00487b41;
    _DAT_00502144 = &LAB_00487b70;
    _DAT_0050214c = &LAB_00487b9f;
    DAT_00502130 = FUN_0047ef44();
    _DAT_00502138 = FUN_0047ef44();
    _DAT_00502140 = FUN_0047ef44();
    _DAT_00502148 = FUN_0047ef44();
    _DAT_00502150 = FUN_0047ef44();
    _DAT_00501670 = 1;
    iVar1 = 0;
  }
  return iVar1;
}



/* @004832a1 file=? name=FUN_004832a1 */

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

undefined4 FUN_004832a1(void)

{
  int iVar1;
  undefined4 uVar2;
  
  iVar1 = FUN_00482f2f();
  if (iVar1 == 0) {
    _DAT_00501670 = 0;
    uVar2 = 0;
  }
  else {
    uVar2 = 5;
  }
  return uVar2;
}



/* @004832c2 file=? name=FUN_004832c2 */

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

{
  int iVar1;
  uint uVar2;
  uint uVar3;
  uint uVar4;
  undefined4 local_34;
  undefined4 local_28;
  undefined4 local_24;
  undefined4 local_20;
  undefined4 local_1c;
  int local_18;
  uint local_14;
  uint local_10;
  undefined4 local_c [2];
  
  for (uVar2 = 0; (uVar4 = 6, uVar2 < 5 && (uVar4 = uVar2, (&DAT_005006b0)[uVar2] != 0));
      uVar2 = uVar2 + 1) {
  }
  if (uVar4 == 6) {
    iVar1 = 0xb;
  }
  else {
    (&DAT_005006b0)[uVar4] = param_1;
    for (uVar2 = 0; uVar2 < 0x10; uVar2 = uVar2 + 1) {
      (&DAT_00503cd4)[uVar4 * 0x10 + uVar2] = (&DAT_00503c24)[(param_1 - 0xa000) * 0x10 + uVar2];
    }
    if ((&DAT_005006b0)[uVar4] == 0xa003) {
      FUN_00485138(local_c);
      uVar2 = 0;
      while (uVar3 = uVar2, uVar3 < 0xd) {
        (&DAT_00501340)[uVar3 * 2 + uVar4 * 0x1a] = (&DAT_00501674)[uVar3 * 2];
        (&DAT_00501344)[uVar3 * 2 + uVar4 * 0x1a] = (&DAT_00501678)[uVar3 * 2];
        local_14 = uVar3;
        local_10 = uVar4;
        uVar2 = uVar3 + 1;
      }
      DAT_00503fac = *(undefined4 *)(param_3 + 0x14);
      iVar1 = FUN_0048790c((&DAT_00501348)[uVar4 * 0x1a],(&DAT_0050134c)[uVar4 * 0x1a],DAT_00503fac,
                           DAT_00503fb0,uVar4,DAT_00503fb4);
      if (iVar1 != 0) {
        return iVar1;
      }
      local_18 = 0;
    }
    else if ((&DAT_005006b0)[uVar4] == 0xa005) {
      FUN_00484221(local_c);
      uVar2 = 0;
      while (uVar3 = uVar2, uVar3 < 0xd) {
        (&DAT_00501340)[uVar3 * 2 + uVar4 * 0x1a] = (&DAT_0050212c)[uVar3 * 2];
        (&DAT_00501344)[uVar3 * 2 + uVar4 * 0x1a] = (&DAT_00502130)[uVar3 * 2];
        local_14 = uVar3;
        local_10 = uVar4;
        uVar2 = uVar3 + 1;
      }
      DAT_00503fac = *(undefined4 *)(param_3 + 0x14);
      iVar1 = FUN_0048790c((&DAT_00501348)[uVar4 * 0x1a],(&DAT_0050134c)[uVar4 * 0x1a],DAT_00503fac,
                           DAT_00503fb0,uVar4,DAT_00503fb4);
      if (iVar1 != 0) {
        return iVar1;
      }
      local_18 = 0;
    }
    else {
      if (*(int *)(param_3 + 8) == 0) {
        iVar1 = FUN_004838a9(param_1,uVar4,&local_28,&local_20,
                             (undefined2 *)(&DAT_0050069c + uVar4 * 4),&DAT_00500638 + uVar4 * 4,
                             (undefined4 *)(&DAT_00500624 + uVar4 * 4));
        if (iVar1 != 0) {
          return iVar1;
        }
        *(undefined4 *)(param_3 + 4) = local_20;
        *(undefined4 *)(param_3 + 8) = local_1c;
        *(undefined4 *)(param_3 + 0xc) = local_28;
        *(undefined4 *)(param_3 + 0x10) = local_24;
        *(undefined4 *)(&DAT_005005fc + uVar4 * 8) = local_20;
        *(undefined4 *)(&DAT_00500600 + uVar4 * 8) = local_1c;
        *(undefined4 *)(&DAT_0050064c + uVar4 * 8) = local_28;
        *(undefined4 *)(&DAT_00500650 + uVar4 * 8) = local_24;
        local_18 = 0;
      }
      else {
        local_20 = *(undefined4 *)(param_3 + 4);
        local_1c = *(undefined4 *)(param_3 + 8);
        local_28 = *(undefined4 *)(param_3 + 0xc);
        local_24 = *(undefined4 *)(param_3 + 0x10);
        *(undefined4 *)(&DAT_005005fc + uVar4 * 8) = local_20;
        *(undefined4 *)(&DAT_00500600 + uVar4 * 8) = local_1c;
        *(undefined4 *)(&DAT_0050064c + uVar4 * 8) = local_28;
        *(undefined4 *)(&DAT_00500650 + uVar4 * 8) = local_24;
      }
      local_14 = uVar2;
      local_10 = uVar4;
      FUN_00481f13(uVar4);
      FUN_0048796e(local_28,(short)local_24,CONCAT24((short)local_1c,local_20),
                   &DAT_00501340 + uVar4 * 0x1a);
      *(undefined4 *)(&DAT_00500674 + uVar4 * 4) = 1;
      *param_4 = uVar4;
      local_18 = FUN_0048790c((&DAT_00501348)[uVar4 * 0x1a],(&DAT_0050134c)[uVar4 * 0x1a],
                              *(undefined4 *)(param_3 + 0x18),local_34,param_2[1],*param_2);
      if (local_18 != 0) {
        return local_18;
      }
    }
    if ((&DAT_005006b0)[uVar4] == 0xa00a) {
      FUN_004879b6();
      FUN_00481953(0x78,FUN_00483888,&DAT_00503fb8);
    }
    *(undefined4 *)(&DAT_00500674 + uVar4 * 4) = 1;
    *param_4 = uVar4;
    iVar1 = 0;
  }
  return iVar1;
}



/* @004836b0 file=? name=FUN_004836b0 */

undefined4 __cdecl FUN_004836b0(uint param_1,int param_2)

{
  int iVar1;
  undefined4 uVar2;
  
  if (*(int *)(&DAT_00500674 + param_1 * 4) == 0) {
    uVar2 = 1;
  }
  else {
    FUN_0048790c(*(undefined4 *)(&DAT_00501350 + param_1 * 0x68),
                 *(undefined4 *)(&DAT_00501354 + param_1 * 0x68),DAT_00503fac,DAT_00503fb0,param_1,
                 DAT_00503fb4);
    if ((((param_2 != 0) && (iVar1 = (&DAT_005006b0)[param_1], iVar1 != 0xa003)) &&
        (iVar1 != 0xa005)) && (iVar1 != 0xa007)) {
      FUN_00483ae7(param_1);
    }
    if ((&DAT_005006b0)[param_1] == 0xa00a) {
      FUN_00481c82(DAT_00503fb8);
    }
    *(undefined4 *)(&DAT_00500600 + param_1 * 8) = 0;
    *(undefined4 *)(&DAT_00500650 + param_1 * 8) = 0;
    (&DAT_005006b0)[param_1] = 0;
    *(undefined4 *)(&DAT_00500674 + param_1 * 4) = 0;
    uVar2 = 0;
  }
  return uVar2;
}



/* @00483799 file=? name=FUN_00483799 */

undefined4 __cdecl FUN_00483799(int param_1)

{
  uint uVar1;
  undefined4 local_8;
  
  for (uVar1 = 0; uVar1 < 0x10; uVar1 = uVar1 + 1) {
    DAT_00503c08 = (byte)uVar1 | 0xb0;
    DAT_00503c09 = 0x79;
    DAT_00503c0a = 0;
    DAT_00503fb0 = FUN_0047ef40();
    DAT_00503fac = &DAT_00503c08;
    FUN_0048790c((&DAT_00501340)[param_1 * 0x1a],(&DAT_00501344)[param_1 * 0x1a],&DAT_00503c08,
                 DAT_00503fb0,3,param_1);
    DAT_00503c08 = (byte)uVar1 | 0xb0;
    DAT_00503c09 = 0x7b;
    DAT_00503c0a = 0;
    local_8 = 3;
    FUN_0048790c((&DAT_00501340)[param_1 * 0x1a],(&DAT_00501344)[param_1 * 0x1a],DAT_00503fac,
                 DAT_00503fb0,3,param_1);
  }
  FUN_0048790c(*(undefined4 *)(&DAT_00501358 + param_1 * 0x68),
               *(undefined4 *)(&DAT_0050135c + param_1 * 0x68),DAT_00503fac,DAT_00503fb0,local_8,
               param_1);
  return 0;
}



/* @00483888 file=? name=FUN_00483888 */

void FUN_00483888(void)

{
  FUN_004879e0();
  return;
}



/* @0048389f file=? name=FUN_0048389f */

void FUN_0048389f(void)

{
  return;
}



/* @004838a4 file=? name=FUN_004838a4 */

void FUN_004838a4(void)

{
  return;
}



/* @004838a9 file=? name=FUN_004838a9 */

undefined4 __cdecl
FUN_004838a9(uint param_1,uint param_2,undefined4 *param_3,undefined4 *param_4,undefined2 *param_5,
            undefined1 *param_6,undefined4 *param_7)

{
  char *pcVar1;
  undefined4 uVar2;
  uint uVar3;
  int iVar4;
  void *this;
  uint unaff_ESI;
  undefined4 local_28;
  undefined4 uStack_24;
  undefined1 *local_20;
  undefined4 local_1c;
  undefined4 local_18;
  uint local_14;
  int local_10;
  char *local_c;
  char *local_8;
  
  local_8 = (char *)0x2c;
  local_c = (char *)0x30;
  local_10 = 0;
  local_14 = 0;
  if (param_2 < 6) {
    if (*(int *)(&DAT_00500674 + param_2 * 4) == 0) {
      if ((param_1 < 0xa000) || (0xa200 < param_1)) {
        uVar2 = 6;
      }
      else {
        FUN_004d4a48(&DAT_00503eac,&DAT_00503dac);
        FUN_004d49b8(&DAT_00503eac,s_hmimdrv_386_00501608);
        uVar3 = thunk_FUN_004d93ac(&DAT_00503eac,0x8000,unaff_ESI);
        if (uVar3 == 0xffffffff) {
          uVar2 = 0xf;
        }
        else {
          thunk_FUN_004d892c(uVar3,&DAT_00501614,local_8);
          while ((local_14 <= DAT_00501634 && (local_10 == 0))) {
            thunk_FUN_004d892c(uVar3,&DAT_00501640,local_c);
            pcVar1 = DAT_00501664;
            if (DAT_00501668 == param_1) {
              local_10 = 1;
              iVar4 = FUN_0047e6c0(this,(uint)DAT_00501664,param_5,(undefined2 *)&local_18,&local_20
                                  );
              if (iVar4 == -1) {
                return 5;
              }
              FUN_0047e7fa(local_20,(ushort)local_1c,&local_28);
              FUN_0047e661();
              DAT_004ff214 = FUN_004de55c((uint)(pcVar1 + 0x100));
              if (DAT_004ff214 == (int *)0x0) {
                return 5;
              }
              thunk_FUN_004d892c(uVar3,(char *)DAT_004ff214,pcVar1);
              FUN_0047efd1(local_20,local_1c,(undefined1 *)DAT_004ff214,(int)pcVar1);
              FUN_004de420(DAT_004ff214);
              *param_3 = local_28;
              param_3[1] = uStack_24;
              *param_4 = local_20;
              param_4[1] = local_1c;
              *param_6 = (char)pcVar1;
              *param_7 = local_18;
            }
            else {
              thunk_FUN_004d9334(uVar3,(LONG)DAT_00501664,1);
            }
            local_14 = local_14 + 1;
          }
          thunk_FUN_004d92c4(uVar3);
          *(uint *)(&DAT_00500688 + param_2 * 4) = DAT_00501668;
          *(undefined4 *)(&DAT_00500674 + param_2 * 4) = 1;
          if (local_10 == 0) {
            uVar2 = 7;
          }
          else {
            uVar2 = 0;
          }
        }
      }
    }
    else {
      uVar2 = 9;
    }
  }
  else {
    uVar2 = 10;
  }
  return uVar2;
}



/* @00483ae7 file=? name=FUN_00483ae7 */

undefined4 __cdecl FUN_00483ae7(uint param_1)

{
  undefined4 uVar1;
  
  if (param_1 < 6) {
    if (*(int *)(&DAT_00500674 + param_1 * 4) == 0) {
      uVar1 = 10;
    }
    else {
      *(undefined4 *)(&DAT_00500674 + param_1 * 4) = 0;
      FUN_0047e693();
      FUN_0047e7c4();
      FUN_0047e7c4();
      uVar1 = 0;
    }
  }
  else {
    uVar1 = 10;
  }
  return uVar1;
}



/* @00483b91 file=? name=FUN_00483b91 */

void FUN_00483b91(void)

{
  return;
}



/* @00483b96 file=? name=FUN_00483b96 */

void FUN_00483b96(void)

{
  return;
}



/* @00483df0 file=? name=FUN_00483df0 */

undefined4 __cdecl FUN_00483df0(int param_1)

{
  uint uVar1;
  
  for (uVar1 = 0; uVar1 < 0x20; uVar1 = uVar1 + 1) {
    if (*(int *)(&DAT_005006e0 + param_1 * 0x80 + uVar1 * 4) != 0) {
      DAT_00503c14 = *(byte *)(*(int *)(&DAT_00502bd8 + param_1 * 0x80 + uVar1 * 4) + 8) | 0xb0;
      DAT_00503c15 = 7;
      DAT_00503c16 = 0;
      FUN_004852c7(param_1,&DAT_00503c14,*(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + uVar1 * 4)
                   ,3);
    }
  }
  *(undefined4 *)(&DAT_00501568 + param_1 * 4) = 1;
  return 0;
}



/* @00483f75 file=? name=FUN_00483f75 */

undefined4 __cdecl FUN_00483f75(int param_1,byte param_2)

{
  byte bVar1;
  int iVar2;
  uint uVar3;
  byte local_10;
  
  *(uint *)(&DAT_00503d28 + param_1 * 4) = (uint)param_2;
  for (uVar3 = 0; uVar3 < 0x20; uVar3 = uVar3 + 1) {
    if (*(int *)(&DAT_005006e0 + param_1 * 0x80 + uVar3 * 4) != 0) {
      bVar1 = *(byte *)(*(int *)(&DAT_00502bd8 + param_1 * 0x80 + uVar3 * 4) + 8);
      iVar2 = *(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + uVar3 * 4);
      local_10 = bVar1;
      if (DAT_00503c20 != 0) {
        local_10 = (&DAT_00502fd8)[iVar2 * 0x80 + param_1 * 0x10 + (uint)bVar1];
      }
      DAT_00503c14 = bVar1 | 0xb0;
      DAT_00503c15 = 7;
      DAT_00503c16 = (&DAT_00503d48)[iVar2 * 0x10 + (uint)local_10];
      FUN_004852c7(param_1,&DAT_00503c14,*(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + uVar3 * 4)
                   ,3);
    }
  }
  return 0;
}



/* @0048416d file=? name=FUN_0048416d */

void FUN_0048416d(void)

{
  return;
}



/* @00484172 file=? name=FUN_00484172 */

void FUN_00484172(void)

{
  return;
}



/* @00484177 file=? name=FUN_00484177 */

undefined4 __cdecl FUN_00484177(undefined4 param_1)

{
  return param_1;
}



/* @0048417f file=? name=FUN_0048417f */

void FUN_0048417f(void)

{
  return;
}



/* @00484184 file=? name=FUN_00484184 */

void FUN_00484184(void)

{
  return;
}



/* @00484189 file=? name=FUN_00484189 */

undefined4 __cdecl FUN_00484189(int param_1,int param_2)

{
  bool bVar1;
  undefined3 extraout_var;
  undefined4 uVar2;
  uint uVar3;
  
  bVar1 = FUN_00482ca9(param_1);
  if (CONCAT31(extraout_var,bVar1) == 0) {
    uVar3 = ((uint)(param_2 << 0x10) / 100) * *(int *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x38)
            >> 0x10;
    if (uVar3 == 0) {
      uVar3 = 1;
    }
    FUN_00481b29(*(uint *)(&DAT_005015e8 + param_1 * 4),uVar3);
    uVar2 = FUN_00481dfd(*(int *)(&DAT_005015e8 + param_1 * 4));
  }
  else {
    uVar2 = 0;
  }
  return uVar2;
}



/* @00484201 file=? name=FUN_00484201 */

undefined4 __cdecl FUN_00484201(int param_1)

{
  return *(undefined4 *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x3c);
}



/* @00484217 file=? name=FUN_00484217 */

void FUN_00484217(void)

{
  return;
}



/* @0048421c file=? name=FUN_0048421c */

void FUN_0048421c(void)

{
  return;
}



/* @00484221 file=? name=FUN_00484221 */

void __cdecl FUN_00484221(undefined4 *param_1)

{
  *param_1 = &DAT_0050212c;
  return;
}



/* @00484230 file=? name=FUN_00484230 */

undefined4 __thiscall
FUN_00484230(void *this,char *param_1,undefined4 param_2,undefined4 param_3,int param_4)

{
  int *piVar1;
  void *extraout_ECX;
  void *extraout_ECX_00;
  void *extraout_ECX_01;
  void *extraout_ECX_02;
  undefined4 extraout_ECX_03;
  undefined4 extraout_ECX_04;
  undefined4 extraout_ECX_05;
  void *extraout_ECX_06;
  uint uVar2;
  int iVar3;
  uint uVar4;
  uint uVar5;
  undefined8 uVar6;
  uint local_20;
  
  iVar3 = (int)param_1[1];
  uVar4 = (uint)param_1[2];
  uVar5 = (int)*param_1 & 0xf;
  uVar2 = (int)*param_1 & 0xf0;
  if (uVar2 == 0x80) {
    if (((*(int *)(&DAT_00502154 + param_4 * 0x200 + iVar3 * 4) != 0) &&
        (*(int *)(*(int *)(&DAT_00502154 + param_4 * 0x200 + iVar3 * 4) + 0x24) != -0x8000)) &&
       (uVar2 = FUN_00484bd7(param_4,iVar3,uVar5), uVar2 != 0xffffffff)) {
      FUN_0047f807(extraout_ECX_04,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),uVar2);
    }
  }
  else if (uVar2 == 0x90) {
    piVar1 = *(int **)(&DAT_00502154 + param_4 * 0x200 + iVar3 * 4);
    if (piVar1 != (int *)0x0) {
      if (uVar4 == 0) {
        if ((piVar1[9] != -0x8000) &&
           (uVar2 = FUN_00484bd7(param_4,iVar3,uVar5), uVar2 != 0xffffffff)) {
          FUN_0047f807(extraout_ECX_03,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),uVar2);
        }
      }
      else {
        if ((piVar1[9] != -0x8000) &&
           (uVar2 = FUN_00484bd7(param_4,iVar3,uVar5), this = extraout_ECX, uVar2 != 0xffffffff)) {
          FUN_0047f807(extraout_ECX,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),uVar2);
          this = extraout_ECX_00;
        }
        if ((*(uint *)(&DAT_00502104 + param_4 * 4) <= *(uint *)(&DAT_00502118 + param_4 * 4)) &&
           (uVar2 = FUN_00484a84(param_4,uVar5), this = extraout_ECX_01, uVar2 != 0xffffffff)) {
          FUN_0047f807(extraout_ECX_01,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),uVar2);
          this = extraout_ECX_02;
        }
        if (*(int *)(&DAT_00502bb8 + param_4 * 4) != 0) {
          piVar1[5] = *(int *)(&DAT_005016a0 + param_4 * 0xc) * uVar4 >> 7;
          piVar1[5] = piVar1[5] << 8;
        }
        piVar1[6] = iVar3;
        if (((&DAT_005016a4)[param_4 * 3] & 0x80) == 0) {
          piVar1[0x10] = (&DAT_005016a4)[param_4 * 3] << 9;
        }
        uVar6 = FUN_0047f629(this,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),piVar1);
        if ((int)uVar6 != -1) {
          FUN_004849f1(param_4,(int)uVar6,piVar1[6],uVar4,uVar5);
        }
      }
    }
  }
  else if (uVar2 == 0xb0) {
    if (iVar3 == 7) {
      *(uint *)(&DAT_005016a0 + param_4 * 0xc) = uVar4;
      for (local_20 = *(uint *)(&DAT_005020f0 + param_4 * 4);
          local_20 != *(uint *)(&DAT_005020dc + param_4 * 4); local_20 = local_20 + 1 & 0x1f) {
        if (*(int *)(&DAT_005016dc + param_4 * 0x200 + local_20 * 0x10) != -1) {
          iVar3 = param_4 * 0x200 + local_20 * 0x10;
          FUN_00481528(iVar3,(int)((ulonglong)uVar4 * (ulonglong)*(uint *)(&DAT_005016e4 + iVar3) >>
                                  0x20),*(int *)(&DAT_00502b68 + param_4 * 4),
                       *(int *)(&DAT_005016dc + param_4 * 0x200 + local_20 * 0x10),
                       (short)((ulonglong)uVar4 * (ulonglong)*(uint *)(&DAT_005016e4 + iVar3)) * 2);
        }
      }
    }
    else if (iVar3 == 10) {
      (&DAT_005016a4)[param_4 * 3] = uVar4;
      for (local_20 = *(uint *)(&DAT_005020f0 + param_4 * 4);
          local_20 != *(uint *)(&DAT_005020dc + param_4 * 4); local_20 = local_20 + 1 & 0x1f) {
        FUN_00481675(this,*(undefined4 *)(&DAT_005016dc + param_4 * 0x200 + local_20 * 0x10),
                     *(int *)(&DAT_00502b68 + param_4 * 4),
                     *(undefined4 *)(&DAT_005016dc + param_4 * 0x200 + local_20 * 0x10),
                     (short)(uVar4 << 9));
        this = extraout_ECX_06;
      }
    }
    else if (iVar3 == 0x7b) {
      while (uVar2 = FUN_00484a84(param_4,uVar5), uVar2 != 0xffffffff) {
        FUN_0047f807(extraout_ECX_05,&DAT_00502b68,*(int *)(&DAT_00502b68 + param_4 * 4),uVar2);
      }
    }
  }
  return 0;
}



/* @004845e4 file=? name=FUN_004845e4 */

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

{
  int iVar1;
  uint uVar2;
  uint local_c;
  uint *local_8;
  
  uVar2 = 0;
  local_8 = param_1;
  do {
    if (4 < uVar2) {
LAB_00484627:
      if (uVar2 == 5) {
        *(undefined4 *)(&DAT_00502ba4 + param_3 * 4) = 1;
        iVar1 = FUN_0047fc2c(*param_1,param_1[6],(uint *)param_1[5],&local_c);
        if (iVar1 != 0) {
          return iVar1;
        }
        *(uint *)(&DAT_00502b68 + param_3 * 4) = local_c;
        iVar1 = FUN_00481953(local_8[1],*(undefined4 *)(local_8[5] + 0x44),
                             (uint *)(&DAT_00502b90 + param_3 * 4));
        if (iVar1 != 0) {
          return iVar1;
        }
        *(undefined4 *)(&DAT_00502b7c + param_3 * 4) = 1;
      }
      else {
        *(undefined4 *)(&DAT_00502ba4 + param_3 * 4) = 0;
      }
      *(uint *)(&DAT_00502bb8 + param_3 * 4) = local_8[4];
      FUN_00484931(param_3,local_8[3]);
      *(int *)(&DAT_00505468 + local_c * 4) = param_3;
      for (uVar2 = 0; uVar2 < 5; uVar2 = uVar2 + 1) {
        (&DAT_005016a4)[uVar2 * 3] = (&DAT_005016a4)[uVar2 * 3] | 0x80;
      }
      return 0;
    }
    if ((&DAT_004fecf4)[uVar2 * 0x14] == *param_1) {
      *(uint *)(&DAT_00502b68 + param_3 * 4) = uVar2;
      local_c = uVar2;
      goto LAB_00484627;
    }
    uVar2 = uVar2 + 1;
  } while( true );
}



/* @0048471f file=? name=FUN_0048471f */

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

{
  if ((*(int *)(&DAT_00502b7c + param_3 * 4) != 0) &&
     (*(undefined4 *)(&DAT_00502b7c + param_3 * 4) = 0, *(int *)(&DAT_00502ba4 + param_3 * 4) != 0))
  {
    FUN_00481c82(*(int *)(&DAT_00502b90 + param_3 * 4));
    FUN_004804bd(*(uint *)(&DAT_00502b68 + param_3 * 4),1,1);
  }
  FUN_004849ec();
  return 0;
}



/* @00484796 file=? name=FUN_00484796 */

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

{
  FUN_00484931(param_3,*(undefined4 *)(&DAT_00502104 + param_3 * 4));
  return 0;
}



/* @004847b8 file=? name=FUN_004847b8 */

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

{
  undefined4 uVar1;
  int iVar2;
  uint uVar3;
  uint local_8;
  
  *(int *)(&DAT_00502b54 + param_3 * 4) = param_1;
  for (local_8 = 0; local_8 < 0x80; local_8 = local_8 + 1) {
    *(undefined4 *)(&DAT_00502154 + param_3 * 0x200 + local_8 * 4) = 0;
  }
  iVar2 = 0;
  while( true ) {
    if (s_HMIDIGIP_00502bcc[iVar2] == '\0') {
      uVar3 = 0x28;
      do {
        iVar2 = FUN_00484177(uVar3 + param_1);
        iVar2 = *(int *)(iVar2 + 0x18);
        uVar1 = FUN_00484177(uVar3 + param_1);
        *(undefined4 *)(&DAT_00502154 + param_3 * 0x200 + iVar2 * 4) = uVar1;
        uVar1 = FUN_00484177(uVar3 + param_1 + 0x74);
        **(undefined4 **)(&DAT_00502154 + param_3 * 0x200 + iVar2 * 4) = uVar1;
        *(code **)(*(int *)(&DAT_00502154 + param_3 * 0x200 + iVar2 * 4) + 0x1c) = FUN_004848f8;
        uVar3 = uVar3 + *(int *)(*(int *)(&DAT_00502154 + param_3 * 0x200 + iVar2 * 4) + 8) + 0x74;
      } while (uVar3 < *(uint *)(*(int *)(&DAT_00502b54 + param_3 * 4) + 0x24));
      return 0;
    }
    if ((int)*(char *)(param_1 + iVar2) != (uint)(byte)s_HMIDIGIP_00502bcc[iVar2]) break;
    iVar2 = iVar2 + 1;
  }
  return 0xe;
}



/* @004848f8 file=? name=FUN_004848f8 */

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

{
  FUN_004814d9();
  if (param_2 == 2) {
    FUN_00484d35(*(int *)(&DAT_00505468 + param_1 * 4),param_3);
  }
  FUN_0047f013();
  return;
}



/* @00484927 file=? name=FUN_00484927 */

void FUN_00484927(void)

{
  return;
}



/* @0048492c file=? name=FUN_0048492c */

void FUN_0048492c(void)

{
  return;
}



/* @00484931 file=? name=FUN_00484931 */

void __cdecl FUN_00484931(int param_1,undefined4 param_2)

{
  uint uVar1;
  
  for (uVar1 = 0; uVar1 < 0x20; uVar1 = uVar1 + 1) {
    *(undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar1 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e0 + param_1 * 0x200 + uVar1 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e8 + param_1 * 0x200 + uVar1 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e4 + param_1 * 0x200 + uVar1 * 0x10) = 0xffffffff;
  }
  *(undefined4 *)(&DAT_005020dc + param_1 * 4) = 0;
  *(undefined4 *)(&DAT_005020f0 + param_1 * 4) = 0;
  *(undefined4 *)(&DAT_00502118 + param_1 * 4) = 0;
  *(undefined4 *)(&DAT_00502104 + param_1 * 4) = param_2;
  return;
}



/* @004849ec file=? name=FUN_004849ec */

void FUN_004849ec(void)

{
  return;
}



/* @004849f1 file=? name=FUN_004849f1 */

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

{
  int iVar1;
  int iVar2;
  
  if (*(uint *)(&DAT_00502118 + param_1 * 4) < *(uint *)(&DAT_00502104 + param_1 * 4)) {
    iVar1 = *(int *)(&DAT_005020dc + param_1 * 4);
    iVar2 = param_1 * 0x200 + iVar1 * 0x10;
    *(undefined4 *)(&DAT_005016dc + iVar2) = param_2;
    *(undefined4 *)(&DAT_005016e0 + iVar2) = param_3;
    *(undefined4 *)(&DAT_005016e4 + iVar2) = param_4;
    *(undefined4 *)(&DAT_005016e8 + iVar2) = param_5;
    *(int *)(&DAT_00502118 + param_1 * 4) = *(int *)(&DAT_00502118 + param_1 * 4) + 1;
    *(int *)(&DAT_005020dc + param_1 * 4) = *(int *)(&DAT_005020dc + param_1 * 4) + 1;
    *(uint *)(&DAT_005020dc + param_1 * 4) = *(uint *)(&DAT_005020dc + param_1 * 4) & 0x1f;
  }
  else {
    iVar1 = -1;
  }
  return iVar1;
}



/* @00484a84 file=? name=FUN_00484a84 */

int __cdecl FUN_00484a84(int param_1,int param_2)

{
  int iVar1;
  uint uVar2;
  int iVar3;
  undefined4 *puVar4;
  uint uVar5;
  undefined4 *puVar6;
  int *local_8;
  
  if (*(int *)(&DAT_00502118 + param_1 * 4) == 0) {
    iVar1 = -1;
  }
  else {
    uVar5 = 0;
    while ((uVar5 < 0x20 &&
           ((iVar1 = param_1 * 0x200 + uVar5 * 0x10, local_8 = (int *)(&DAT_005016dc + iVar1),
            *(int *)(&DAT_005016e8 + iVar1) != param_2 || (*local_8 == -1))))) {
      uVar5 = uVar5 + 1;
    }
    if (uVar5 == 0x20) {
      iVar1 = -1;
    }
    else {
      iVar1 = *local_8;
      while (uVar5 != *(uint *)(&DAT_005020f0 + param_1 * 4)) {
        uVar2 = uVar5 - 1 & 0x1f;
        puVar4 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar2 * 0x10);
        puVar6 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar5 * 0x10);
        for (iVar3 = 4; uVar5 = uVar2, iVar3 != 0; iVar3 = iVar3 + -1) {
          *puVar6 = *puVar4;
          puVar4 = puVar4 + 1;
          puVar6 = puVar6 + 1;
        }
      }
      *(undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e0 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e8 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e4 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(int *)(&DAT_005020f0 + param_1 * 4) = *(int *)(&DAT_005020f0 + param_1 * 4) + 1;
      *(uint *)(&DAT_005020f0 + param_1 * 4) = *(uint *)(&DAT_005020f0 + param_1 * 4) & 0x1f;
      *(int *)(&DAT_00502118 + param_1 * 4) = *(int *)(&DAT_00502118 + param_1 * 4) + -1;
    }
  }
  return iVar1;
}



/* @00484bd7 file=? name=FUN_00484bd7 */

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

{
  int iVar1;
  uint uVar2;
  int iVar3;
  undefined4 *puVar4;
  uint uVar5;
  undefined4 *puVar6;
  int *local_8;
  
  if (*(int *)(&DAT_00502118 + param_1 * 4) == 0) {
    iVar1 = -1;
  }
  else {
    for (uVar5 = 0; uVar5 < 0x20; uVar5 = uVar5 + 1) {
      iVar1 = param_1 * 0x200 + uVar5 * 0x10;
      local_8 = (int *)(&DAT_005016dc + iVar1);
      if (((*(int *)(&DAT_005016e0 + iVar1) == param_2) &&
          (*(int *)(&DAT_005016e8 + iVar1) == param_3)) && (*local_8 != -1)) break;
    }
    if (uVar5 == 0x20) {
      iVar1 = -1;
    }
    else {
      iVar1 = *local_8;
      while (uVar5 != *(uint *)(&DAT_005020f0 + param_1 * 4)) {
        uVar2 = uVar5 - 1 & 0x1f;
        puVar4 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar2 * 0x10);
        puVar6 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar5 * 0x10);
        for (iVar3 = 4; uVar5 = uVar2, iVar3 != 0; iVar3 = iVar3 + -1) {
          *puVar6 = *puVar4;
          puVar4 = puVar4 + 1;
          puVar6 = puVar6 + 1;
        }
      }
      *(undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e0 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e8 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e4 + param_1 * 0x200 + uVar5 * 0x10) = 0xffffffff;
      *(int *)(&DAT_005020f0 + param_1 * 4) = *(int *)(&DAT_005020f0 + param_1 * 4) + 1;
      *(uint *)(&DAT_005020f0 + param_1 * 4) = *(uint *)(&DAT_005020f0 + param_1 * 4) & 0x1f;
      *(int *)(&DAT_00502118 + param_1 * 4) = *(int *)(&DAT_00502118 + param_1 * 4) + -1;
    }
  }
  return iVar1;
}



/* @00484d35 file=? name=FUN_00484d35 */

int __cdecl FUN_00484d35(int param_1,int param_2)

{
  uint uVar1;
  int iVar2;
  undefined4 *puVar3;
  uint uVar4;
  undefined4 *puVar5;
  
  if (*(int *)(&DAT_00502118 + param_1 * 4) == 0) {
    param_2 = -1;
  }
  else {
    uVar4 = 0;
    while ((uVar4 < 0x20 && (*(int *)(&DAT_005016dc + param_1 * 0x200 + uVar4 * 0x10) != param_2)))
    {
      uVar4 = uVar4 + 1;
    }
    if (uVar4 == 0x20) {
      param_2 = -1;
    }
    else {
      while (uVar4 != *(uint *)(&DAT_005020f0 + param_1 * 4)) {
        uVar1 = uVar4 - 1 & 0x1f;
        puVar3 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar1 * 0x10);
        puVar5 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar4 * 0x10);
        for (iVar2 = 4; uVar4 = uVar1, iVar2 != 0; iVar2 = iVar2 + -1) {
          *puVar5 = *puVar3;
          puVar3 = puVar3 + 1;
          puVar5 = puVar5 + 1;
        }
      }
      *(undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar4 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e0 + param_1 * 0x200 + uVar4 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e8 + param_1 * 0x200 + uVar4 * 0x10) = 0xffffffff;
      *(undefined4 *)(&DAT_005016e4 + param_1 * 0x200 + uVar4 * 0x10) = 0xffffffff;
      *(int *)(&DAT_005020f0 + param_1 * 4) = *(int *)(&DAT_005020f0 + param_1 * 4) + 1;
      *(uint *)(&DAT_005020f0 + param_1 * 4) = *(uint *)(&DAT_005020f0 + param_1 * 4) & 0x1f;
      *(int *)(&DAT_00502118 + param_1 * 4) = *(int *)(&DAT_00502118 + param_1 * 4) + -1;
    }
  }
  return param_2;
}



/* @00484e72 file=? name=FUN_00484e72 */

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

{
  int iVar1;
  int *unaff_ESI;
  uint uVar2;
  
  if (*(int *)(&DAT_00502118 + param_1 * 4) == 0) {
    iVar1 = -1;
  }
  else {
    for (uVar2 = 0; uVar2 < 0x20; uVar2 = uVar2 + 1) {
      iVar1 = param_1 * 0x200 + uVar2 * 0x10;
      unaff_ESI = (int *)(&DAT_005016dc + iVar1);
      if (((*(int *)(&DAT_005016e0 + iVar1) == param_2) &&
          (*(int *)(&DAT_005016e8 + iVar1) == param_3)) && (*unaff_ESI != -1)) break;
    }
    if (uVar2 == 0x20) {
      iVar1 = -1;
    }
    else {
      iVar1 = *unaff_ESI;
    }
  }
  return iVar1;
}



/* @00485020 file=? name=FUN_00485020 */

undefined4 __cdecl FUN_00485020(int param_1,uint param_2)

{
  uint uVar1;
  int iVar2;
  undefined4 *puVar3;
  undefined4 *puVar4;
  
  if (*(int *)(&DAT_00502118 + param_1 * 4) != 0) {
    while (param_2 != *(uint *)(&DAT_005020f0 + param_1 * 4)) {
      uVar1 = param_2 - 1 & 0x1f;
      puVar3 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + uVar1 * 0x10);
      puVar4 = (undefined4 *)(&DAT_005016dc + param_1 * 0x200 + param_2 * 0x10);
      for (iVar2 = 4; param_2 = uVar1, iVar2 != 0; iVar2 = iVar2 + -1) {
        *puVar4 = *puVar3;
        puVar3 = puVar3 + 1;
        puVar4 = puVar4 + 1;
      }
    }
    *(undefined4 *)(&DAT_005016dc + param_1 * 0x200 + param_2 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e0 + param_1 * 0x200 + param_2 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e8 + param_1 * 0x200 + param_2 * 0x10) = 0xffffffff;
    *(undefined4 *)(&DAT_005016e4 + param_1 * 0x200 + param_2 * 0x10) = 0xffffffff;
    *(int *)(&DAT_005020f0 + param_1 * 4) = *(int *)(&DAT_005020f0 + param_1 * 4) + 1;
    *(uint *)(&DAT_005020f0 + param_1 * 4) = *(uint *)(&DAT_005020f0 + param_1 * 4) & 0x1f;
    *(int *)(&DAT_00502118 + param_1 * 4) = *(int *)(&DAT_00502118 + param_1 * 4) + -1;
  }
  return 0xffffffff;
}



/* @0048512e file=? name=FUN_0048512e */

void FUN_0048512e(void)

{
  return;
}



/* @00485133 file=? name=FUN_00485133 */

void FUN_00485133(void)

{
  return;
}



/* @00485138 file=? name=FUN_00485138 */

void __cdecl FUN_00485138(undefined4 *param_1)

{
  *param_1 = &DAT_00501674;
  return;
}



/* @00485147 file=? name=FUN_00485147 */

undefined4 __cdecl
FUN_00485147(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4)

{
  (*DAT_0050169c)(param_1,param_2,param_3,param_4);
  return 0;
}



/* @00485166 file=? name=FUN_00485166 */

undefined4 FUN_00485166(void)

{
  return 0;
}



/* @0048516d file=? name=FUN_0048516d */

undefined4 FUN_0048516d(void)

{
  return 0;
}



/* @00485174 file=? name=FUN_00485174 */

undefined4 FUN_00485174(void)

{
  return 0;
}



/* @0048517b file=? name=FUN_0048517b */

undefined4 __cdecl FUN_0048517b(undefined4 param_1)

{
  DAT_0050169c = param_1;
  return 0;
}



/* @0048518a file=? name=FUN_0048518a */

void FUN_0048518a(void)

{
  return;
}



/* @0048518f file=? name=FUN_0048518f */

void FUN_0048518f(void)

{
  return;
}



/* @00485194 file=? name=FUN_00485194 */

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

{
  DAT_00503fac = param_2;
  DAT_00503fb0 = FUN_0047ef40();
  FUN_0048790c(*(undefined4 *)(&DAT_00501360 + param_1 * 0x68),
               *(undefined4 *)(&DAT_00501364 + param_1 * 0x68),DAT_00503fac,DAT_00503fb0,param_1,
               param_3);
  return;
}



/* @004852b1 file=? name=FUN_004852b1 */

void FUN_004852b1(void)

{
  DAT_00503d98 = 1;
  return;
}



/* @004852bd file=? name=FUN_004852bd */

void FUN_004852bd(void)

{
  return;
}



/* @004852c2 file=? name=FUN_004852c2 */

void FUN_004852c2(void)

{
  return;
}



/* @004852c7 file=? name=FUN_004852c7 */

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

{
  byte bVar1;
  byte bVar2;
  undefined4 uVar3;
  byte bVar4;
  uint uVar5;
  uint local_28;
  byte local_24;
  uint local_10;
  byte local_c;
  byte local_8;
  
  local_8 = 0;
  local_c = 0xff;
  local_10 = 0xffffffff;
  bVar1 = *param_2;
  bVar4 = bVar1 & 0xf;
  if (DAT_00503c20 == 0) {
    if (((int)(char)*param_2 & 0xf0U) == 0xb0) {
      if (param_2[1] == 7) {
        DAT_00503c08 = *param_2;
        DAT_00503c09 = 7;
        DAT_00503c0a = (byte)(((uint)((int)(char)param_2[2] * *(int *)(&DAT_00503d28 + param_1 * 4))
                              >> 7) * (uint)DAT_00503d24 >> 7);
        (&DAT_00503d48)[param_3 * 0x10 + (uint)bVar4] = param_2[2];
        if (*(int *)(&DAT_00501568 + param_1 * 4) != 0) {
          DAT_00503c0a = 0;
        }
      }
      else {
        DAT_00503c08 = *param_2;
        DAT_00503c09 = param_2[1];
        DAT_00503c0a = param_2[2];
        DAT_00503c0b = param_2[3];
      }
      DAT_00503fb0 = FUN_0047ef40();
      DAT_00503fac = &DAT_00503c08;
      FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],&DAT_00503c08,
                   DAT_00503fb0,param_4,param_3);
    }
    else {
      DAT_00503fb0 = FUN_0047ef40();
      DAT_00503fac = param_2;
      FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],param_2,
                   DAT_00503fb0,param_4,param_3);
    }
    uVar3 = 1;
  }
  else {
    local_24 = (&DAT_00502fd8)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4];
LAB_00485460:
    if (local_24 == 0xff) {
      if (bVar4 == 9) {
        *(undefined1 *)(param_3 * 0x80 + param_1 * 0x10 + 0x502fe1) = 9;
        local_24 = 9;
      }
      else {
        for (local_28 = 0; local_28 < 0x10; local_28 = local_28 + 1) {
          for (; ((&DAT_00503cd4)[param_3 * 0x10 + local_28] == '\0' && (local_28 < 0x10));
              local_28 = local_28 + 1) {
          }
          if ((local_28 < 0x10) && ((&DAT_005032a8)[param_3 * 0x10 + local_28] == -1)) {
            local_24 = (byte)local_28;
            (&DAT_00502fd8)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] = local_24;
            (&DAT_005032a8)[param_3 * 0x10 + local_28] = bVar4;
            (&DAT_005032f8)[param_3 * 0x10 + local_28] = (char)param_1;
            (&DAT_00503258)[param_3 * 0x10 + local_28] =
                 *(undefined1 *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x40 + (uint)bVar4 * 4);
            uVar5 = (uint)(byte)(&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4];
            if (uVar5 == 0xff) {
              uVar5 = 0;
              goto LAB_00485938;
            }
            (&DAT_00503d48)[param_3 * 0x10 + (local_28 & 0xff)] = 0x7f;
            DAT_00503c08 = local_24 | 0xb0;
            DAT_00503c09 = 0x79;
            DAT_00503c0a = 0;
            DAT_00503fb0 = FUN_0047ef40();
            DAT_00503fac = &DAT_00503c08;
            FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],
                         &DAT_00503c08,DAT_00503fb0,3,param_3);
            if ((&DAT_0050334b)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] != -1) {
              DAT_00503c08 = local_24 | 0xc0;
              DAT_00503c09 = (&DAT_0050334b)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5];
              DAT_00503fb0 = FUN_0047ef40();
              DAT_00503fac = &DAT_00503c08;
              FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],
                           &DAT_00503c08,DAT_00503fb0,2,param_3);
            }
            if ((&DAT_00503349)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] != -1) {
              DAT_00503c08 = local_24 | 0xe0;
              DAT_00503c09 = 0;
              DAT_00503c0a = (&DAT_00503349)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5];
              DAT_00503fb0 = FUN_0047ef40();
              DAT_00503fac = &DAT_00503c08;
              FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],
                           &DAT_00503c08,DAT_00503fb0,2,param_3);
            }
            if ((&DAT_0050334a)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] != -1) {
              DAT_00503c08 = local_24 | 0xb0;
              DAT_00503c09 = 7;
              DAT_00503c0a = (&DAT_0050334a)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5];
              DAT_00503fb0 = FUN_0047ef40();
              DAT_00503fac = &DAT_00503c08;
              FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],
                           &DAT_00503c08,DAT_00503fb0,3,param_3);
            }
            if ((&DAT_0050334c)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] != -1) {
              DAT_00503c08 = local_24 | 0xb0;
              DAT_00503c09 = 0x40;
              DAT_00503c0a = (&DAT_0050334c)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5];
              DAT_00503fb0 = FUN_0047ef40();
              DAT_00503fac = &DAT_00503c08;
              FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],
                           &DAT_00503c08,DAT_00503fb0,3,param_3);
            }
            goto LAB_00485460;
          }
        }
        for (local_28 = 0; local_28 < 0x10; local_28 = local_28 + 1) {
          for (; ((&DAT_00503cd4)[param_3 * 0x10 + local_28] == '\0' && (local_28 < 0x10));
              local_28 = local_28 + 1) {
          }
          if (((local_28 < 0x10) && (local_8 < (byte)(&DAT_00503258)[param_3 * 0x10 + local_28])) &&
             ((&DAT_00503258)[param_3 * 0x10 + local_28] != -1)) {
            local_8 = (&DAT_00503258)[param_3 * 0x10 + local_28];
            local_c = (byte)local_28;
          }
        }
        if (local_c == 0xff) goto LAB_00485cbf;
        if ((uint)local_8 <=
            *(uint *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x40 + (uint)bVar4 * 4)) {
          if ((&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] != -1)
          goto LAB_00485cbf;
          uVar5 = 0;
          goto LAB_00485cba;
        }
        (&DAT_00502fd8)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] = local_c;
        (&DAT_00502fd8)
        [param_3 * 0x80 + (uint)(byte)(&DAT_005032f8)[param_3 * 0x10 + (uint)local_c] * 0x10 +
         (uint)(byte)(&DAT_005032a8)[param_3 * 0x10 + (uint)local_c]] = 0xff;
        (&DAT_005032a8)[param_3 * 0x10 + (uint)local_c] = bVar4;
        (&DAT_005032f8)[param_3 * 0x10 + (uint)local_c] = (char)param_1;
        (&DAT_00503258)[param_3 * 0x10 + (uint)local_c] =
             *(undefined1 *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x40 + (uint)bVar4 * 4);
        (&DAT_00503d48)[param_3 * 0x10 + (uint)local_c] = 0x7f;
        DAT_00503c08 = local_c | 0xb0;
        DAT_00503c09 = 0x7b;
        DAT_00503c0a = 0;
        local_24 = local_c;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,param_3);
        DAT_00503c08 = local_c | 0xb0;
        DAT_00503c09 = 0x79;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,param_3);
        if ((&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] == -1) {
          for (uVar5 = 0; uVar5 < 4; uVar5 = uVar5 + 1) {
            if ((&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] == -1) {
              (&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] = 1;
              (&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] = (char)uVar5;
              break;
            }
          }
        }
      }
      goto LAB_00485460;
    }
    *param_2 = bVar1 & 0xf0 | local_24;
LAB_00485cbf:
    if (bVar4 == 9) {
      if ((bVar1 == 0xb9) && (param_2[1] == 7)) {
        local_10 = (uint)param_2[2];
        (&DAT_00503d51)[param_3 * 0x10] = param_2[2];
      }
    }
    else {
      bVar2 = bVar1 & 0xf0;
      if (bVar2 == 0xb0) {
        if (param_2[1] == 7) {
          (&DAT_0050334a)
          [param_3 * 0x140 + (uint)bVar4 * 0x14 +
           (uint)(byte)(&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] * 5] =
               param_2[2];
          local_10 = (uint)param_2[2];
          (&DAT_00503d48)[param_3 * 0x10 + (uint)local_24] = param_2[2];
        }
        else if (param_2[1] == 0x40) {
          (&DAT_0050334c)
          [param_3 * 0x140 + (uint)bVar4 * 0x14 +
           (uint)(byte)(&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] * 5] =
               param_2[2];
        }
      }
      else if (bVar2 == 0xc0) {
        (&DAT_0050334b)
        [param_3 * 0x140 + (uint)bVar4 * 0x14 +
         (uint)(byte)(&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] * 5] =
             param_2[1];
      }
      else if (bVar2 == 0xe0) {
        (&DAT_00503349)
        [param_3 * 0x140 + (uint)bVar4 * 0x14 +
         (uint)(byte)(&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] * 5] =
             param_2[2];
      }
    }
    if (local_24 == 0xff) {
      uVar3 = 0xffffffff;
    }
    else {
      if (local_10 != 0xffffffff) {
        if (*(int *)(&DAT_00501568 + param_1 * 4) == 0) {
          param_2[2] = (byte)((local_10 * *(int *)(&DAT_00503d28 + param_1 * 4) >> 7) *
                              (uint)DAT_00503d24 >> 7);
        }
        else {
          param_2[2] = 0;
        }
      }
      DAT_00503fb0 = FUN_0047ef40();
      DAT_00503fac = param_2;
      FUN_0048790c((&DAT_00501340)[param_3 * 0x1a],(&DAT_00501344)[param_3 * 0x1a],param_2,
                   DAT_00503fb0,param_4,param_3);
      *param_2 = bVar1;
      if (local_10 != 0xffffffff) {
        param_2[2] = (byte)local_10;
      }
      uVar3 = 0;
    }
  }
  return uVar3;
LAB_00485938:
  if (3 < uVar5) goto LAB_00485460;
  if ((&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] == -1) {
    (&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] = 1;
    (&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] = (char)uVar5;
    goto LAB_00485460;
  }
  uVar5 = uVar5 + 1;
  goto LAB_00485938;
LAB_00485cba:
  if (3 < uVar5) goto LAB_00485cbf;
  if ((&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] == -1) {
    (&DAT_00503348)[param_3 * 0x140 + (uint)bVar4 * 0x14 + uVar5 * 5] = 1;
    (&DAT_00503988)[param_3 * 0x80 + param_1 * 0x10 + (uint)bVar4] = (char)uVar5;
    goto LAB_00485cbf;
  }
  uVar5 = uVar5 + 1;
  goto LAB_00485cba;
}



/* @00485f3e file=? name=FUN_00485f3e */

undefined4 __cdecl FUN_00485f3e(int param_1)

{
  byte bVar1;
  byte bVar2;
  byte bVar3;
  int iVar4;
  uint local_8;
  
  for (local_8 = 1; local_8 < *(uint *)(&DAT_00501320 + param_1 * 4); local_8 = local_8 + 1) {
    iVar4 = *(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + local_8 * 4);
    if ((iVar4 != -1) && (iVar4 != 0xff)) {
      bVar1 = *(byte *)(*(int *)(&DAT_00502bd8 + param_1 * 0x80 + local_8 * 4) + 8);
      if (DAT_00503c20 == 0) {
        DAT_00503c08 = bVar1 | 0xb0;
        DAT_00503c09 = 0x7b;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar1 | 0xb0;
        DAT_00503c09 = 0x79;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar1 | 0xe0;
        DAT_00503c09 = 0x40;
        DAT_00503c0a = 0x40;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar1 | 0xb0;
        DAT_00503c09 = 7;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
      }
      else {
        bVar2 = (&DAT_00502fd8)[iVar4 * 0x80 + param_1 * 0x10 + (uint)bVar1];
        (&DAT_00502fd8)[iVar4 * 0x80 + param_1 * 0x10 + (uint)bVar1] = 0xff;
        bVar3 = (&DAT_00503988)[iVar4 * 0x80 + param_1 * 0x10 + (uint)bVar1];
        (&DAT_005032a8)[iVar4 * 0x10 + (uint)bVar2] = 0xff;
        (&DAT_005032f8)[iVar4 * 0x10 + (uint)bVar2] = 0xff;
        DAT_00503c08 = bVar2 | 0xb0;
        DAT_00503c09 = 0x7b;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar2 | 0xb0;
        DAT_00503c09 = 0x79;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar2 | 0xe0;
        DAT_00503c09 = 0x40;
        DAT_00503c0a = 0x40;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        DAT_00503c08 = bVar2 | 0xb0;
        DAT_00503c09 = 7;
        DAT_00503c0a = 0;
        DAT_00503fb0 = FUN_0047ef40();
        DAT_00503fac = &DAT_00503c08;
        FUN_0048790c((&DAT_00501340)[iVar4 * 0x1a],(&DAT_00501344)[iVar4 * 0x1a],&DAT_00503c08,
                     DAT_00503fb0,3,iVar4);
        if (bVar3 != 0xff) {
          (&DAT_0050334b)[iVar4 * 0x140 + (uint)bVar1 * 0x14 + (uint)bVar3 * 5] = 0xff;
          (&DAT_00503349)[iVar4 * 0x140 + (uint)bVar1 * 0x14 + (uint)bVar3 * 5] = 0xff;
          (&DAT_0050334a)[iVar4 * 0x140 + (uint)bVar1 * 0x14 + (uint)bVar3 * 5] = 0xff;
          (&DAT_0050334c)[iVar4 * 0x140 + (uint)bVar1 * 0x14 + (uint)bVar3 * 5] = 0xff;
          (&DAT_00503348)[iVar4 * 0x140 + (uint)bVar1 * 0x14 + (uint)bVar3 * 5] = 0xff;
          (&DAT_00503988)[iVar4 * 0x80 + param_1 * 0x10 + (uint)bVar1] = 0xff;
        }
      }
    }
  }
  return 1;
}



/* @00486402 file=? name=FUN_00486402 */

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

{
  DAT_00503fb0 = FUN_0047ef40();
  DAT_00503fac = param_2;
  FUN_0048790c((&DAT_00501340)[param_1 * 0x1a],(&DAT_00501344)[param_1 * 0x1a],param_2,DAT_00503fb0,
               param_3,param_1);
  return 0;
}



/* @0048644a file=? name=FUN_0048644a */

undefined4 __cdecl FUN_0048644a(undefined4 param_1)

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



/* @0048645d file=? name=FUN_0048645d */

void FUN_0048645d(void)

{
  return;
}



/* @00486462 file=? name=FUN_00486462 */

void FUN_00486462(void)

{
  return;
}



/* @00487788 file=? name=FUN_00487788 */

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

{
  uint local_14;
  byte local_10;
  byte local_f;
  undefined1 local_e;
  
  if (*(char *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x36c) != '\0') {
    local_10 = **(byte **)(&DAT_005006e0 + param_1 * 0x80 + param_2 * 4) & 0xf | 0xc0;
    local_f = *(undefined1 *)
               (*(int *)(&DAT_00503fbc + param_1 * 0x80 + param_2 * 4) + 5 + param_3 * 0x18);
    FUN_004852c7(param_1,&local_10,*(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + param_2 * 4),2);
  }
  local_10 = **(byte **)(&DAT_005006e0 + param_1 * 0x80 + param_2 * 4) & 0xf | 0xb0;
  for (local_14 = 0;
      local_14 <
      *(byte *)(*(int *)(&DAT_00503fbc + param_1 * 0x80 + param_2 * 4) + 7 + param_3 * 0x18);
      local_14 = local_14 + 2) {
    local_f = *(byte *)(*(int *)(*(int *)(&DAT_00503fbc + param_1 * 0x80 + param_2 * 4) + 8 +
                                param_3 * 0x18) + local_14);
    local_e = *(undefined1 *)
               (*(int *)(*(int *)(&DAT_00503fbc + param_1 * 0x80 + param_2 * 4) + 8 + param_3 * 0x18
                        ) + 1 + local_14);
    if (*(char *)(*(int *)(&DAT_005015c8 + param_1 * 4) + 0x300 + (uint)local_f) != '\0') {
      FUN_004852c7(param_1,&local_10,*(int *)(*(int *)(&DAT_005012e0 + param_1 * 4) + param_2 * 4),3
                  );
    }
  }
  return;
}



/* @00487905 file=? name=FUN_00487905 */

void FUN_00487905(void)

{
  return;
}



/* @0048790c file=? name=FUN_0048790c */

void __cdecl
FUN_0048790c(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
            undefined4 param_5,undefined4 param_6)

{
  (*(code *)&param_1)();
  return;
}



/* @00487939 file=? name=FUN_00487939 */

void FUN_00487939(void)

{
  int iVar1;
  undefined1 *extraout_EDX;
  undefined1 *puVar2;
  undefined1 *in_stack_00000014;
  
  (*(code *)&stack0x00000004)();
  puVar2 = extraout_EDX;
  for (iVar1 = 0x40; iVar1 != 0; iVar1 = iVar1 + -1) {
    *in_stack_00000014 = *puVar2;
    puVar2 = puVar2 + 1;
    in_stack_00000014 = in_stack_00000014 + 1;
  }
  return;
}



/* @0048796e file=? name=FUN_0048796e */

void __cdecl
FUN_0048796e(undefined4 param_1,undefined2 param_2,undefined6 param_3,undefined4 *param_4)

{
  int iVar1;
  int iVar2;
  int unaff_FS_OFFSET;
  
  iVar2 = (int)param_3;
  (*(code *)&param_1)();
  iVar1 = 0xd;
  do {
    *param_4 = *(undefined4 *)(unaff_FS_OFFSET + iVar2);
    *(undefined2 *)(param_4 + 1) = param_2;
    param_4 = param_4 + 2;
    iVar2 = iVar2 + 8;
    iVar1 = iVar1 + -1;
  } while (iVar1 != 0);
  return;
}



/* @004879b6 file=? name=FUN_004879b6 */

void FUN_004879b6(void)

{
  undefined6 uVar1;
  undefined6 *in_stack_00000018;
  
  uVar1 = (*(code *)&stack0x00000004)();
  *in_stack_00000018 = uVar1;
  return;
}



/* @004879e0 file=? name=FUN_004879e0 */

void FUN_004879e0(void)

{
  (*(code *)&stack0x00000004)();
  return;
}



/* @00487a02 file=? name=FUN_00487a02 */

void __cdecl
FUN_00487a02(undefined4 param_1,undefined4 param_2,undefined4 param_3,undefined4 param_4,
            undefined4 param_5)

{
  FUN_00485147(param_2,param_3,param_4,param_5);
  return;
}



/* @00487ca0 file=? name=FUN_00487ca0 */

void __cdecl FUN_00487ca0(int param_1)

{
  if (param_1 == 0) {
    FUN_004d771c(s_NULL_pointer_in__s_005055fc);
    FUN_004d6b9c((int *)&DAT_0051f818);
    FUN_004dee24(0x29a);
  }
  return;
}



/* @00487cd4 file=? name=FUN_00487cd4 */

undefined4 FUN_00487cd4(void)

{
  undefined4 *puVar1;
  int iVar2;
  
  if (DAT_005055f0 == 0) {
    iVar2 = 0;
    puVar1 = &DAT_00523330;
    do {
      *puVar1 = 0;
      iVar2 = iVar2 + 1;
      puVar1 = puVar1 + 1;
    } while (iVar2 < 0x200);
    DAT_005055f0 = 1;
  }
  return 0;
}



/* @00487d04 file=? name=FUN_00487d04 */

void __cdecl FUN_00487d04(uint param_1,undefined4 param_2,undefined4 param_3)

{
  undefined4 *puVar1;
  undefined4 *puVar2;
  
  puVar1 = (undefined4 *)(&DAT_00523330)[param_1 & 0x1ff];
  if ((undefined4 *)(&DAT_00523330)[param_1 & 0x1ff] == (undefined4 *)0x0) {
    puVar1 = (undefined4 *)FUN_00452c38(0x10);
    FUN_00487ca0((int)puVar1);
    puVar1[3] = param_2;
    puVar1[1] = param_1;
    puVar1[2] = param_3;
    *puVar1 = 0;
    (&DAT_00523330)[param_1 & 0x1ff] = puVar1;
  }
  else {
    do {
      puVar2 = puVar1;
      puVar1 = (undefined4 *)*puVar2;
    } while (puVar1 != (undefined4 *)0x0);
    puVar1 = (undefined4 *)FUN_00452c38(0x10);
    *puVar2 = puVar1;
    FUN_00487ca0((int)puVar1);
    puVar1[3] = param_2;
    puVar1[1] = param_1;
    puVar1[2] = param_3;
    *puVar1 = 0;
  }
  return;
}



/* @00487d98 file=? name=FUN_00487d98 */

uint __cdecl FUN_00487d98(int param_1,undefined4 param_2)

{
  uint uVar1;
  
  if (param_1 == 0) {
    return 0;
  }
  uVar1 = *(uint *)(param_1 + 8);
  FUN_00487d04(uVar1,param_1,param_2);
  return uVar1;
}



/* @00487dc0 file=? name=FUN_00487dc0 */

undefined4 __cdecl FUN_00487dc0(uint param_1,int param_2)

{
  int *piVar1;
  int *piVar2;
  int *piVar3;
  
  piVar1 = (int *)(&DAT_00523330)[param_1 & 0x1ff];
  piVar3 = (int *)0x0;
  while (piVar2 = piVar1, param_1 != piVar2[1]) {
    piVar1 = (int *)*piVar2;
    piVar3 = piVar2;
    if (piVar1 == (int *)0x0) {
      FUN_0048900c(param_2);
      FUN_004d771c(s_Name_0x_x___s__not_found_00505626);
      FUN_004dee24(0x29a);
    }
  }
  if ((param_2 != -1) && (piVar2[2] != param_2)) {
    FUN_0048900c(piVar2[2]);
    FUN_0048900c(param_2);
    FUN_004d771c(s_deleteName__name_0x_x_wrong_type_00505640);
    FUN_004dee24(0x29a);
  }
  if (piVar3 == (int *)0x0) {
    (&DAT_00523330)[param_1 & 0x1ff] = *piVar2;
    FUN_00452c88(piVar2);
  }
  else {
    *piVar3 = *piVar2;
    FUN_00452c88(piVar2);
  }
  return 1;
}



/* @00487e7c file=? name=FUN_00487e7c */

undefined4 __cdecl FUN_00487e7c(undefined4 param_1,uint param_2,int param_3)

{
  undefined4 *puVar1;
  
  if (param_2 != 0) {
    for (puVar1 = (undefined4 *)(&DAT_00523330)[param_2 & 0x1ff]; puVar1 != (undefined4 *)0x0;
        puVar1 = (undefined4 *)*puVar1) {
      if (param_2 == puVar1[1]) {
        if (param_3 == puVar1[2]) {
          return puVar1[3];
        }
        if (param_3 != -1) {
          FUN_0048900c(puVar1[2]);
          FUN_0048900c(param_3);
          FUN_004d771c(s_nameToAddress__name_0x_x_wrong_t_00505678);
          FUN_004d771c(s_last_name_op_was__s_005056c0);
          FUN_004d771c(s_allocatedNames____d_005056d5);
          return 0;
        }
        return puVar1[3];
      }
    }
  }
  return 0;
}



/* @00487f18 file=? name=FUN_00487f18 */

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

void FUN_00487f18(void)

{
  DAT_005055f0 = 0;
  DAT_005055f8 = 1;
  _DAT_005055f4 = 0;
  return;
}



/* @00487f34 file=? name=FUN_00487f34 */

int * FUN_00487f34(void)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00452c38(0x8c);
  FUN_0049a300(1,s_dpl2d_NewDisplayList_005056f0);
  if (piVar1 != (int *)0x0) {
    piVar1[1] = 0;
    piVar1[2] = (int)piVar1;
    piVar1[3] = 0;
    piVar1[4] = 0;
    FUN_0048e910(piVar1);
  }
  return piVar1;
}



/* @00487f78 file=? name=FUN_00487f78 */

undefined4 __cdecl FUN_00487f78(int *param_1)

{
  int *piVar1;
  undefined4 uVar2;
  
  FUN_0049a300(1,s_dpl2d_DeleteDisplayList_00505706);
  if (param_1 == (int *)0x0) {
    uVar2 = 0;
  }
  else {
    FUN_0048e96c(param_1);
    while (param_1 != (int *)0x0) {
      piVar1 = (int *)param_1[1];
      FUN_00452c88(param_1);
      param_1 = piVar1;
    }
    uVar2 = 1;
  }
  return uVar2;
}



/* @00487fbc file=? name=FUN_00487fbc */

undefined4 __cdecl FUN_00487fbc(int param_1,int param_2)

{
  int *piVar1;
  int *piVar2;
  undefined4 uVar3;
  
  FUN_0049a300(1,s_dpl2d_OpenDisplayList_0050571f);
  if (param_1 == 0) {
    uVar3 = 0;
  }
  else {
    if (*(int *)(param_1 + 0x10) != 0) {
      FUN_004d771c(s_2_D_warning___attempt_to_open_al_00505736);
    }
    if (param_2 == 2) {
      *(undefined4 *)(param_1 + 0x10) = 1;
    }
    else {
      piVar2 = *(int **)(param_1 + 4);
      while (piVar2 != (int *)0x0) {
        piVar1 = (int *)piVar2[1];
        FUN_00452c88(piVar2);
        piVar2 = piVar1;
      }
      *(undefined4 *)(param_1 + 0x10) = 1;
      *(undefined4 *)(param_1 + 0xc) = 0;
      *(undefined4 *)(param_1 + 4) = 0;
      *(int *)(param_1 + 8) = param_1;
    }
    uVar3 = 1;
  }
  return uVar3;
}



/* @00488030 file=? name=FUN_00488030 */

undefined4 __cdecl FUN_00488030(int param_1)

{
  FUN_0049a300(1,s_dpl2d_CloseDisplayList_00505770);
  *(undefined4 *)(param_1 + 0x10) = 0;
  return 1;
}



/* @00488054 file=? name=FUN_00488054 */

undefined4 __cdecl FUN_00488054(byte *param_1)

{
  FUN_0049a300(1,s_dpl2d_FlushDisplayList_00505788);
  FUN_0048e9ac(param_1,1);
  while (param_1 = *(byte **)(param_1 + 4), param_1 != (byte *)0x0) {
    FUN_0048e9ac(param_1,0);
  }
  return 1;
}



/* @00488094 file=? name=FUN_00488094 */

void FUN_00488094(void)

{
  FUN_004d771c(s_Attempt_to__s_to_closed_displayl_005057a0);
  return;
}



/* @004880a4 file=? name=FUN_004880a4 */

int __cdecl FUN_004880a4(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = FUN_00452c38(0x8c);
  if (iVar1 == 0) {
    FUN_004d771c(s_Out_of_memory_in_grow_2d_display_005057c5);
    FUN_004dee24(0x29a);
    return 0;
  }
  *(int *)(param_1 + 8) = iVar1;
  *(int *)(param_2 + 4) = iVar1;
  *(undefined4 *)(iVar1 + 4) = 0;
  *(undefined4 *)(iVar1 + 0xc) = 0;
  return iVar1;
}



/* @004880e8 file=? name=FUN_004880e8 */

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

undefined4 __cdecl FUN_004880e8(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddOpenPolyline_005057eb);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    _DAT_005056ec = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *_DAT_005056ec = 0;
    uVar1 = 1;
  }
  return uVar1;
}



/* @0048814c file=? name=FUN_0048814c */

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

undefined4 __cdecl FUN_0048814c(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddClosePolyline_00505812);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 1;
    uVar1 = 1;
  }
  return uVar1;
}



/* @004881b0 file=? name=FUN_004881b0 */

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

undefined4 __cdecl FUN_004881b0(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddOpenPolygon_0050583b);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 4;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488214 file=? name=FUN_00488214 */

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

undefined4 __cdecl FUN_00488214(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddClosePolygon_00505860);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 5;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488278 file=? name=FUN_00488278 */

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

undefined4 __cdecl FUN_00488278(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddOpenLines_00505887);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 6;
    uVar1 = 1;
  }
  return uVar1;
}



/* @004882dc file=? name=FUN_004882dc */

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

undefined4 __cdecl FUN_004882dc(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddClosePolyline_005058a8);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 7;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488340 file=? name=FUN_00488340 */

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

undefined4 __cdecl FUN_00488340(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddOpenPolypoint_005058ce);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 2;
    uVar1 = 1;
  }
  return uVar1;
}



/* @004883a4 file=? name=FUN_004883a4 */

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

undefined4 __cdecl FUN_004883a4(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddClosePolypoint_005058f7);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 3;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488408 file=? name=FUN_00488408 */

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

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

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddPoint_00505922);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1b < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 3;
    *(undefined4 *)(iVar3 + 0x14) = 8;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_3;
    uVar1 = 1;
  }
  return uVar1;
}



/* @0048847c file=? name=FUN_0048847c */

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

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

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddCircle_0050593b);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x18 < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 5;
    *(undefined4 *)(iVar3 + 0x14) = 9;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_3;
    *(undefined4 *)(iVar3 + 0x20) = param_4;
    *(undefined4 *)(iVar3 + 0x24) = param_5;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488500 file=? name=FUN_00488500 */

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

undefined4 __cdecl FUN_00488500(int param_1,undefined4 param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddSetLineWidthCircle_00505956);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1b < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    puVar4 = (undefined4 *)(iVar3 + 0x14);
    _DAT_005056ec = puVar4;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 2;
    *puVar4 = 0x15;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    uVar1 = 1;
  }
  return uVar1;
}



/* @0048856c file=? name=FUN_0048856c */

undefined4 __cdecl FUN_0048856c(int param_1)

{
  int iVar1;
  undefined4 uVar2;
  int iVar3;
  
  iVar3 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddPushState_00505983);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar2 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar3 + 0xc)) {
      iVar3 = FUN_004880a4(param_1,iVar3);
    }
    iVar1 = *(int *)(iVar3 + 0xc);
    *(int *)(iVar3 + 0xc) = *(int *)(iVar3 + 0xc) + 1;
    *(undefined4 *)(iVar1 * 4 + iVar3 + 0x14) = 0x12;
    uVar2 = 1;
  }
  return uVar2;
}



/* @004885cc file=? name=FUN_004885cc */

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

undefined4 __cdecl FUN_004885cc(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddPopState_005059a4);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1d < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 0x13;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488630 file=? name=FUN_00488630 */

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

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

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddSetColor_005059c3);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1a < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 4;
    *(undefined4 *)(iVar3 + 0x14) = 0xf;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_3;
    *(undefined4 *)(iVar3 + 0x20) = param_4;
    uVar1 = 1;
  }
  return uVar1;
}



/* @004886ac file=? name=FUN_004886ac */

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

undefined4 __cdecl FUN_004886ac(int param_1,undefined4 param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddSetColor_005059e2);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1c < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    puVar4 = (undefined4 *)(iVar3 + 0x14);
    _DAT_005056ec = puVar4;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 2;
    *puVar4 = 0x16;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488718 file=? name=FUN_00488718 */

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

undefined4 __cdecl FUN_00488718(int param_1,undefined4 *param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddSetMatrix_00505a01);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x16 < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 7;
    *(undefined4 *)(iVar3 + 0x14) = 0x10;
    *(undefined4 *)(iVar3 + 0x18) = *param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_2[1];
    *(undefined4 *)(iVar3 + 0x20) = param_2[2];
    *(undefined4 *)(iVar3 + 0x24) = param_2[3];
    *(undefined4 *)(iVar3 + 0x28) = param_2[4];
    *(undefined4 *)(iVar3 + 0x2c) = param_2[5];
    uVar1 = 1;
  }
  return uVar1;
}



/* @004887b0 file=? name=FUN_004887b0 */

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

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

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddConcatMatrix_00505a22);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x15 < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 8;
    *(undefined4 *)(iVar3 + 0x14) = 0x11;
    *(undefined4 *)(iVar3 + 0x18) = *param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_2[1];
    *(undefined4 *)(iVar3 + 0x20) = param_2[2];
    *(undefined4 *)(iVar3 + 0x24) = param_2[3];
    *(undefined4 *)(iVar3 + 0x28) = param_2[4];
    *(undefined4 *)(iVar3 + 0x2c) = param_2[5];
    *(undefined4 *)(iVar3 + 0x30) = param_3;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488850 file=? name=FUN_00488850 */

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

undefined4 __cdecl FUN_00488850(int param_1,undefined4 *param_2)

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  undefined4 *puVar4;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddCallDisplayList_00505a49);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1c < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    puVar4 = (undefined4 *)(iVar3 + 0x14);
    _DAT_005056ec = puVar4;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 2;
    *puVar4 = 0x14;
    *(undefined4 *)(iVar3 + 0x18) = *param_2;
    uVar1 = 1;
  }
  return uVar1;
}



/* @004888c0 file=? name=FUN_004888c0 */

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

undefined4 __cdecl FUN_004888c0(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddFullScreenClipRegion_00505a76);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1c < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 0xd;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488924 file=? name=FUN_00488924 */

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

undefined4 __cdecl FUN_00488924(int param_1)

{
  undefined4 uVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddFullScreenClipRegion_00505aa7);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1c < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    puVar3 = (undefined4 *)(*(int *)(iVar2 + 0xc) * 4 + iVar2 + 0x14);
    _DAT_005056ec = puVar3;
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 1;
    *puVar3 = 0xe;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488988 file=? name=FUN_00488988 */

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

undefined4 __cdecl FUN_00488988(int param_1)

{
  int iVar1;
  undefined4 *puVar2;
  
  iVar1 = *(int *)(param_1 + 8);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    return 0;
  }
  if (0x1c < *(int *)(iVar1 + 0xc)) {
    iVar1 = FUN_004880a4(param_1,iVar1);
  }
  puVar2 = (undefined4 *)(*(int *)(iVar1 + 0xc) * 4 + iVar1 + 0x14);
  _DAT_005056ec = puVar2;
  *(int *)(iVar1 + 0xc) = *(int *)(iVar1 + 0xc) + 1;
  *puVar2 = 10;
  return 1;
}



/* @004889d8 file=? name=FUN_004889d8 */

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

undefined4 __cdecl FUN_004889d8(int param_1,undefined4 param_2)

{
  int iVar1;
  int iVar2;
  undefined4 *puVar3;
  
  iVar1 = *(int *)(param_1 + 8);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    return 0;
  }
  if (0x1c < *(int *)(iVar1 + 0xc)) {
    iVar1 = FUN_004880a4(param_1,iVar1);
  }
  iVar2 = *(int *)(iVar1 + 0xc) * 4 + iVar1;
  puVar3 = (undefined4 *)(iVar2 + 0x14);
  _DAT_005056ec = puVar3;
  *(int *)(iVar1 + 0xc) = *(int *)(iVar1 + 0xc) + 2;
  *puVar3 = 0xb;
  *(undefined4 *)(iVar2 + 0x18) = param_2;
  return 1;
}



/* @00488a30 file=? name=FUN_00488a30 */

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

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

{
  undefined4 uVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = *(int *)(param_1 + 8);
  FUN_0049a300(1,s_dpl2d_AddClipCircle_00505afa);
  if (*(int *)(param_1 + 0x10) == 0) {
    FUN_00488094();
    uVar1 = 0;
  }
  else {
    if (0x1a < *(int *)(iVar2 + 0xc)) {
      iVar2 = FUN_004880a4(param_1,iVar2);
    }
    iVar3 = *(int *)(iVar2 + 0xc) * 4 + iVar2;
    _DAT_005056ec = (undefined4 *)(iVar3 + 0x14);
    *(int *)(iVar2 + 0xc) = *(int *)(iVar2 + 0xc) + 5;
    *(undefined4 *)(iVar3 + 0x14) = 0xc;
    *(undefined4 *)(iVar3 + 0x18) = param_2;
    *(undefined4 *)(iVar3 + 0x1c) = param_3;
    *(undefined4 *)(iVar3 + 0x20) = param_4;
    *(undefined4 *)(iVar3 + 0x24) = param_5;
    uVar1 = 1;
  }
  return uVar1;
}



/* @00488ab4 file=? name=FUN_00488ab4 */

undefined4 __cdecl FUN_00488ab4(int param_1,undefined4 param_2)

{
  FUN_0049a300(1,s_dpl2d_SetViewDisplayList_00505b1d);
  *(undefined4 *)(param_1 + 0x6c) = param_2;
  return 1;
}



/* @00488ad8 file=? name=FUN_00488ad8 */

undefined4 __cdecl FUN_00488ad8(int param_1)

{
  FUN_0049a300(1,s_dpl2d_GetViewDisplayList_00505b37);
  return *(undefined4 *)(param_1 + 0x6c);
}



/* @00488af4 file=? name=FUN_00488af4 */

void __cdecl FUN_00488af4(undefined4 *param_1,float *param_2,float *param_3)

{
  float local_1c;
  float local_18;
  float local_14;
  float local_10;
  float local_c;
  float local_8;
  
  local_1c = param_2[1] * param_3[2] + *param_2 * *param_3;
  local_18 = param_2[1] * param_3[3] + *param_2 * param_3[1];
  local_14 = param_2[3] * param_3[2] + param_2[2] * *param_3;
  local_10 = param_2[3] * param_3[3] + param_2[2] * param_3[1];
  local_c = param_2[5] * param_3[2] + param_2[4] * *param_3 + param_3[4];
  local_8 = param_2[5] * param_3[3] + param_2[4] * param_3[1] + param_3[5];
  FUN_004d4918(param_1,&local_1c,0x18);
  return;
}



/* @00488b80 file=? name=FUN_00488b80 */

void __cdecl FUN_00488b80(undefined4 *param_1)

{
  *param_1 = 0x3f800000;
  param_1[1] = 0;
  param_1[2] = 0;
  param_1[3] = 0x3f800000;
  param_1[4] = 0;
  param_1[5] = 0;
  return;
}



/* @00488bac file=? name=FUN_00488bac */

void __cdecl FUN_00488bac(int param_1,float param_2,float param_3)

{
  *(float *)(param_1 + 0x10) = param_2 + *(float *)(param_1 + 0x10);
  *(float *)(param_1 + 0x14) = param_3 + *(float *)(param_1 + 0x14);
  return;
}



/* @00488bc8 file=? name=FUN_00488bc8 */

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

void __cdecl FUN_00488bc8(undefined4 *param_1,float param_2)

{
  double dVar1;
  float fVar2;
  float10 fVar3;
  float local_24;
  float local_20;
  float local_1c;
  float local_18;
  undefined4 local_14;
  undefined4 local_10;
  float local_c;
  float local_8;
  
  fVar2 = _DAT_00488c40 * param_2;
  dVar1 = (double)fVar2;
  fVar3 = (float10)FUN_004dd0f4(SUB84(dVar1,0),(int)((ulonglong)dVar1 >> 0x20));
  local_8 = (float)fVar3;
  dVar1 = (double)fVar2;
  fVar3 = (float10)FUN_004dc9b4(SUB84(dVar1,0),(int)((ulonglong)dVar1 >> 0x20));
  local_24 = (float)fVar3;
  local_20 = local_8;
  local_1c = -local_8;
  local_14 = 0;
  local_10 = 0;
  local_18 = local_24;
  local_c = local_24;
  FUN_00488af4(param_1,(float *)param_1,&local_24);
  return;
}



/* @00488c80 file=? name=FUN_00488c80 */

void __cdecl FUN_00488c80(int *param_1,int param_2)

{
  if (param_1 != (int *)0x0) {
    param_1[2] = 0;
    param_1[3] = 0;
    *param_1 = param_2;
    param_1[1] = *(int *)(param_2 + 0xc);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_init_NULL_list_00505b84);
  return;
}



/* @00488cb4 file=? name=FUN_00488cb4 */

void __cdecl FUN_00488cb4(undefined4 param_1,undefined4 *param_2)

{
  if (param_2 != (undefined4 *)0x0) {
    *param_2 = param_1;
    param_2[1] = 0;
    param_2[3] = 0;
    param_2[2] = 0;
    return;
  }
  FUN_0049a300(1,s_Attempt_to_init_NULL_superlist_00505b9f);
  return;
}



/* @00488cec file=? name=FUN_00488cec */

int * __cdecl FUN_00488cec(int param_1)

{
  int *piVar1;
  
  piVar1 = (int *)FUN_00452c38(0x10);
  if (piVar1 != (int *)0x0) {
    FUN_00488c80(piVar1,param_1);
    return piVar1;
  }
  return (int *)0x0;
}



/* @00488d18 file=? name=FUN_00488d18 */

undefined4 __cdecl FUN_00488d18(int param_1)

{
  if (param_1 == 0) {
    FUN_0049a300(1,s_Attempt_to_get_first_on_NULL_sup_00505bbf);
    return 0;
  }
  *(undefined4 *)(param_1 + 4) = *(undefined4 *)(param_1 + 8);
  if (*(undefined4 **)(param_1 + 8) != (undefined4 *)0x0) {
    return **(undefined4 **)(param_1 + 8);
  }
  return 0;
}



/* @00488d50 file=? name=FUN_00488d50 */

undefined4 __cdecl FUN_00488d50(int param_1)

{
  undefined4 *puVar1;
  
  if (*(int *)(param_1 + 4) == 0) {
    FUN_0049a300(1,s_Attempt_to_get_next_on_NULL_supe_00505be7);
    return 0;
  }
  puVar1 = *(undefined4 **)(*(int *)(param_1 + 4) + 8);
  *(undefined4 **)(param_1 + 4) = puVar1;
  if (puVar1 != (undefined4 *)0x0) {
    return *puVar1;
  }
  return 0;
}



/* @00488d88 file=? name=FUN_00488d88 */

void __cdecl FUN_00488d88(int *param_1,int param_2)

{
  int iVar1;
  int *piVar2;
  
  if (param_1 == (int *)0x0) {
    FUN_0049a300(1,s_Attempt_to_add_to_NULL_superlist_00505c0e);
  }
  else {
    piVar2 = FUN_00488cec(param_2);
    FUN_0048d7e0(param_1,param_2);
    if (param_1[2] == param_1[3]) {
      if (param_1[2] == 0) {
        param_1[2] = (int)piVar2;
        param_1[3] = (int)piVar2;
      }
      else {
        *(int **)(param_1[3] + 8) = piVar2;
        param_1[3] = (int)piVar2;
        piVar2[3] = param_1[2];
      }
    }
    else {
      iVar1 = param_1[3];
      *(int **)(iVar1 + 8) = piVar2;
      piVar2[3] = iVar1;
      param_1[3] = (int)piVar2;
    }
  }
  return;
}



/* @00488df8 file=? name=FUN_00488df8 */

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

{
  int *piVar1;
  int iVar2;
  
  iVar2 = 0;
  if (param_1 == 0) {
    FUN_0049a300(1,s_Attempt_to_find_item_in_NULL_sup_00505c30);
    return (int *)0x0;
  }
  piVar1 = *(int **)(param_1 + 8);
  if (piVar1 == (int *)0x0) {
    return (int *)0x0;
  }
  do {
    if (param_2 == *piVar1) {
      *param_3 = iVar2;
      return piVar1;
    }
    piVar1 = (int *)piVar1[2];
    iVar2 = iVar2 + 1;
  } while (piVar1 != (int *)0x0);
  return (int *)0x0;
}



/* @00488e44 file=? name=FUN_00488e44 */

void __cdecl FUN_00488e44(int param_1,int param_2)

{
  if (param_2 == *(int *)(param_1 + 8)) {
    if (*(int *)(param_1 + 8) == *(int *)(param_1 + 0xc)) {
      *(undefined4 *)(param_1 + 8) = 0;
      *(undefined4 *)(param_1 + 0xc) = 0;
    }
    else {
      if (*(int *)(param_2 + 0xc) != 0) {
        FUN_004d771c(s_Bad_error__head_of_list_has_a_pr_00505c58);
      }
      *(undefined4 *)(param_1 + 8) = *(undefined4 *)(param_2 + 8);
      *(undefined4 *)(*(int *)(param_2 + 8) + 0xc) = 0;
    }
  }
  else {
    *(undefined4 *)(*(int *)(param_2 + 0xc) + 8) = *(undefined4 *)(param_2 + 8);
    if (param_2 == *(int *)(param_1 + 0xc)) {
      if (*(int *)(param_2 + 8) != 0) {
        FUN_004d771c(s_Bad_error__tail_of_list_has_a_ne_00505c7c);
      }
      *(undefined4 *)(param_1 + 0xc) = *(undefined4 *)(param_2 + 0xc);
    }
    else {
      *(undefined4 *)(*(int *)(param_2 + 8) + 0xc) = *(undefined4 *)(param_2 + 0xc);
    }
  }
  return;
}



/* @00488ebc file=? name=FUN_00488ebc */

undefined4 __cdecl FUN_00488ebc(int *param_1,int param_2)

{
  int *piVar1;
  undefined4 uVar2;
  int local_8;
  
  if (param_1 == (int *)0x0) {
    FUN_0049a300(1,s_Attempt_to_remove_from_NULL_supe_00505cbd);
    uVar2 = 0;
  }
  else {
    piVar1 = FUN_00488df8((int)param_1,param_2,&local_8);
    if (piVar1 == (int *)0x0) {
      FUN_0049a300(1,s_item_0x_x_not_found_in_list_00505ca0);
      uVar2 = 0;
    }
    else {
      FUN_0048d838(param_1,param_2);
      FUN_00488e44((int)param_1,(int)piVar1);
      FUN_00452c88(piVar1);
      uVar2 = 1;
    }
  }
  return uVar2;
}



/* @00488f34 file=? name=FUN_00488f34 */

undefined4 * __cdecl FUN_00488f34(uint param_1,int param_2,undefined *param_3)

{
  undefined4 *puVar1;
  
  puVar1 = (undefined4 *)FUN_00452c38(param_1);
  if (puVar1 == (undefined4 *)0x0) {
    FUN_004d771c(s_Failed_to_allocate_space_in_new__00505ce4);
    puVar1 = (undefined4 *)0x0;
  }
  else {
    puVar1[3] = param_2;
    if (param_2 - 1U < 0xe) {
      (*(code *)param_3)(puVar1);
    }
    else {
      FUN_004d771c(s_Deeply_erroneous___cant_create_t_00505d0a);
    }
    puVar1[1] = 0;
    FUN_0048d294((int)puVar1);
    FUN_0048d350(puVar1,param_1);
  }
  return puVar1;
}



/* @00488f9c file=? name=FUN_00488f9c */

void __cdecl FUN_00488f9c(undefined4 param_1)

{
  DAT_00505b70 = param_1;
  return;
}



/* @00488fac file=? name=FUN_00488fac */

void FUN_00488fac(void)

{
  int *piVar1;
  
  while (DAT_00505b74 != (int *)0x0) {
    piVar1 = (int *)DAT_00505b74[1];
    FUN_0048d30c((int)DAT_00505b74);
    FUN_00452c88(DAT_00505b74);
    DAT_00505b74 = piVar1;
  }
  return;
}



/* @00488fd8 file=? name=FUN_00488fd8 */

undefined4 __cdecl FUN_00488fd8(int *param_1)

{
  if (DAT_00505b70 == 0) {
    FUN_0048d30c((int)param_1);
    FUN_00452c88(param_1);
  }
  else {
    param_1[1] = (int)DAT_00505b74;
    DAT_00505b74 = param_1;
  }
  return 0;
}



/* @0048900c file=? name=FUN_0048900c */

char * __cdecl FUN_0048900c(undefined4 param_1)

{
  char cVar1;
  uint uVar2;
  uint uVar3;
  int iVar4;
  char *pcVar5;
  char *pcVar6;
  
  iVar4 = DAT_00505b68 * 0x40;
  DAT_00505b68 = DAT_00505b68 + 1;
  DAT_00505b68 = DAT_00505b68 & 3;
  switch(param_1) {
  default:
    pcVar5 = s_not_implemented__00505d86;
    break;
  case 2:
    pcVar5 = &DAT_00505d34;
    break;
  case 3:
    pcVar5 = &DAT_00505d39;
    break;
  case 4:
    pcVar5 = s_instance_00505d3e;
    break;
  case 5:
    pcVar5 = &DAT_00505d4d;
    break;
  case 6:
    pcVar5 = s_light_00505d47;
    break;
  case 7:
    pcVar5 = s_object_00505d51;
    break;
  case 8:
    pcVar5 = &DAT_00505d58;
    break;
  case 9:
    pcVar5 = s_geogroup_00505d5c;
    break;
  case 10:
    pcVar5 = s_geometry_00505d65;
    break;
  case 0xb:
    pcVar5 = s_material_00505d6e;
    break;
  case 0xc:
    pcVar5 = s_texture_00505d7e;
    break;
  case 0xd:
    pcVar5 = &DAT_00505d77;
  }
  uVar2 = 0xffffffff;
  do {
    pcVar6 = pcVar5;
    if (uVar2 == 0) break;
    uVar2 = uVar2 - 1;
    pcVar6 = pcVar5 + 1;
    cVar1 = *pcVar5;
    pcVar5 = pcVar6;
  } while (cVar1 != '\0');
  uVar2 = ~uVar2;
  pcVar5 = pcVar6 + -uVar2;
  pcVar6 = &DAT_00523c08 + iVar4;
  for (uVar3 = uVar2 >> 2; uVar3 != 0; uVar3 = uVar3 - 1) {
    *(undefined4 *)pcVar6 = *(undefined4 *)pcVar5;
    pcVar5 = pcVar5 + 4;
    pcVar6 = pcVar6 + 4;
  }
  for (uVar2 = uVar2 & 3; uVar2 != 0; uVar2 = uVar2 - 1) {
    *pcVar6 = *pcVar5;
    pcVar5 = pcVar5 + 1;
    pcVar6 = pcVar6 + 1;
  }
  return &DAT_00523c08 + iVar4;
}



/* @004890fc file=? name=FUN_004890fc */

void __cdecl FUN_004890fc(undefined4 *param_1)

{
  undefined4 *puVar1;
  int iVar2;
  int iVar3;
  
  iVar2 = 0;
  do {
    iVar3 = 0;
    puVar1 = param_1;
    do {
      *puVar1 = 0;
      if (iVar3 == iVar2) {
        *puVar1 = 0x3f800000;
      }
      iVar3 = iVar3 + 1;
      puVar1 = puVar1 + 1;
    } while (iVar3 < 4);
    iVar2 = iVar2 + 1;
    param_1 = param_1 + 4;
  } while (iVar2 < 4);
  return;
}



/* @00489130 file=? name=FUN_00489130 */

void __cdecl FUN_00489130(int param_1)

{
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x10));
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x20));
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x30));
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x40));
  return;
}



/* @00489174 file=? name=FUN_00489174 */

void __cdecl FUN_00489174(int param_1)

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



/* @00489184 file=? name=FUN_00489184 */

void __cdecl FUN_00489184(int param_1)

{
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(int *)(param_1 + 0x18) = 1 << ((byte)DAT_00505b60 & 0x1f);
  DAT_00505b60 = DAT_00505b60 + 1;
  *(undefined4 *)(param_1 + 0x1c) = 0;
  *(undefined4 *)(param_1 + 0x68) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0xbf800000;
  *(undefined4 *)(param_1 + 0x2c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x24) = 0xbf800000;
  *(undefined4 *)(param_1 + 0x30) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x34) = 0x44200000;
  *(undefined4 *)(param_1 + 0x38) = 0x43f80000;
  *(undefined4 *)(param_1 + 0x3c) = 0x41000000;
  *(undefined4 *)(param_1 + 0x40) = 0x463b8000;
  *(undefined4 *)(param_1 + 0x44) = 0;
  *(undefined4 *)(param_1 + 0x48) = 0x3e4ccccd;
  *(undefined4 *)(param_1 + 0x50) = 0x3ecccccd;
  *(undefined4 *)(param_1 + 0x50) = 1;
  *(undefined4 *)(param_1 + 0x6c) = 0;
  return;
}



/* @00489214 file=? name=FUN_00489214 */

void __cdecl FUN_00489214(int param_1)

{
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x18) = 1;
  *(undefined4 *)(param_1 + 0x38) = 0xffffffff;
  *(undefined4 *)(param_1 + 0x28) = 0x64078678;
  *(undefined4 *)(param_1 + 0x2c) = 0x64078678;
  *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x24) = 0x3f800000;
  return;
}



/* @00489258 file=? name=FUN_00489258 */

void __cdecl FUN_00489258(int param_1)

{
  *(undefined4 *)(param_1 + 0x1c) = 0;
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x2c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x30) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x34) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x38) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x3c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x40) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x44) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x48) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x4c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x60) = 0;
  *(undefined4 *)(param_1 + 0x50) = 0;
  *(undefined4 *)(param_1 + 0x54) = 0;
  *(undefined4 *)(param_1 + 0x58) = 0;
  *(undefined4 *)(param_1 + 0x5c) = 0;
  *(undefined4 *)(param_1 + 0x18) = 3;
  return;
}



/* @004892e0 file=? name=FUN_004892e0 */

void __cdecl FUN_004892e0(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x18) = 0;
  *(undefined4 *)(param_1 + 0x1c) = 0;
  *(undefined4 *)(param_1 + 0x20) = 0;
  return;
}



/* @00489304 file=? name=FUN_00489304 */

void __cdecl FUN_00489304(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x18) = 9;
  *(undefined4 *)(param_1 + 0x14) = 9;
  *(undefined4 *)(param_1 + 0x1c) = 0;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x2c) = 0;
  *(undefined4 *)(param_1 + 0x30) = 0;
  *(undefined4 *)(param_1 + 0x34) = 0;
  *(undefined4 *)(param_1 + 0x38) = 0;
  *(undefined4 *)(param_1 + 0x3c) = 0;
  *(undefined4 *)(param_1 + 0x48) = 0;
  *(undefined4 *)(param_1 + 0x44) = 0;
  *(undefined4 *)(param_1 + 0x40) = 0;
  return;
}



/* @0048935c file=? name=FUN_0048935c */

void __cdecl FUN_0048935c(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x18) = 0;
  *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x24) = 0x3f800000;
  return;
}



/* @00489388 file=? name=FUN_00489388 */

void __cdecl FUN_00489388(int param_1)

{
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x18) = 3;
  *(undefined4 *)(param_1 + 0x1c) = 1;
  *(undefined4 *)(param_1 + 0x34) = 0;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x2c) = 0;
  return;
}



/* @004893c4 file=? name=FUN_004893c4 */

void __cdecl FUN_004893c4(int param_1)

{
  undefined4 *puVar1;
  int iVar2;
  
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x10));
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  iVar2 = 0;
  puVar1 = (undefined4 *)(param_1 + 0x30);
  do {
    *puVar1 = 0;
    iVar2 = iVar2 + 1;
    puVar1 = puVar1 + 1;
  } while (iVar2 < 0x10);
  *(undefined4 *)(param_1 + 0x70) = 0;
  *(undefined4 *)(param_1 + 0x74) = 0;
  *(undefined4 *)(param_1 + 0x78) = 0;
  return;
}



/* @00489410 file=? name=FUN_00489410 */

void __cdecl FUN_00489410(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x18) = 0;
  *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x2c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x30) = 0;
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x34));
  *(undefined4 *)(param_1 + 0x44) = 0;
  *(undefined4 *)(param_1 + 0x48) = 0;
  *(undefined4 *)(param_1 + 0x4c) = 0;
  return;
}



/* @0048946c file=? name=FUN_0048946c */

void __cdecl FUN_0048946c(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x18) = 0;
  *(undefined4 *)(param_1 + 0x1c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0;
  *(undefined4 *)(param_1 + 0x2c) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x30) = 0;
  *(undefined4 *)(param_1 + 0x34) = 0;
  FUN_00488cb4(param_1,(undefined4 *)(param_1 + 0x38));
  *(undefined4 *)(param_1 + 0x48) = 0;
  *(undefined4 *)(param_1 + 0x4c) = 0;
  *(undefined4 *)(param_1 + 0x50) = 0;
  *(undefined4 *)(param_1 + 0x54) = 0;
  return;
}



/* @004894d0 file=? name=FUN_004894d0 */

void __cdecl FUN_004894d0(int param_1)

{
  *(undefined4 *)(param_1 + 0x10) = 1;
  *(undefined4 *)(param_1 + 0x14) = 1;
  *(undefined4 *)(param_1 + 0x18) = 0;
  *(undefined4 *)(param_1 + 0x1c) = 0;
  *(undefined4 *)(param_1 + 0x20) = 0;
  *(undefined4 *)(param_1 + 0x24) = 0;
  *(undefined4 *)(param_1 + 0x28) = 0x3fb4fdf4;
  *(undefined4 *)(param_1 + 0x2c) = 0x3fb4fdf4;
  return;
}



/* @00489508 file=? name=FUN_00489508 */

void __cdecl FUN_00489508(int param_1)

{
  FUN_004890fc((undefined4 *)(param_1 + 0x18));
  *(undefined4 *)(param_1 + 0x10) = 0;
  *(undefined4 *)(param_1 + 0x14) = 0;
  *(undefined4 *)(param_1 + 0x58) = 3;
  *(undefined4 *)(param_1 + 0x5c) = 0;
  *(undefined4 *)(param_1 + 0x60) = 0;
  *(undefined4 *)(param_1 + 100) = 0;
  *(undefined4 *)(param_1 + 0x68) = 0xffffffff;
  *(undefined4 *)(param_1 + 0x6c) = 0;
  *(undefined4 *)(param_1 + 0x70) = 0;
  *(undefined4 *)(param_1 + 0x74) = 0;
  *(undefined4 *)(param_1 + 0x78) = 0x3f800000;
  *(undefined4 *)(param_1 + 0x7c) = 0;
  *(undefined4 *)(param_1 + 0x80) = 0;
  *(undefined4 *)(param_1 + 0x84) = 0;
  *(undefined4 *)(param_1 + 0x88) = 0x3f800000;
  return;
}



/* @00489578 file=? name=FUN_00489578 */

undefined4 __cdecl FUN_00489578(char *param_1)

{
  FUN_004d771c(param_1);
  FUN_004dee24(9);
  return 0;
}



/* @00489594 file=? name=FUN_00489594 */

void __cdecl FUN_00489594(int param_1,int param_2)

{
  if ((param_1 != 0) && (*(int *)(param_1 + 0xc) != param_2)) {
    FUN_0048900c(*(int *)(param_1 + 0xc));
    FUN_0048900c(param_2);
    FUN_0049a300(0,s_inconsistent_type_check_in_point_00505d97);
    FUN_0049a300(0,s_last_API_operation__s_00505dd7);
    FUN_004dee24(9);
  }
  return;
}



/* @004895f0 file=? name=FUN_004895f0 */

void __cdecl FUN_004895f0(int param_1)

{
  FUN_00488d88((int *)&DAT_00523bc8,param_1);
  return;
}



/* @00489608 file=? name=FUN_00489608 */

void __cdecl FUN_00489608(int param_1)

{
  int iVar1;
  
  iVar1 = FUN_00488ebc((int *)&DAT_00523bc8,param_1);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_Failed_to_remove_zone_0x_x__0x_x_00505dee);
  }
  return;
}



/* @00489638 file=? name=FUN_00489638 */

undefined4 __cdecl FUN_00489638(int param_1,int param_2)

{
  int iVar1;
  int iVar2;
  
  if (param_1 == 0) {
    FUN_0049a300(1,s_attempt_to_remove_node_to_NULL_D_00505e6d);
  }
  else if (param_2 == 0) {
    FUN_0049a300(1,s_attempt_to_remove_NULL_from_DCS_00505e4c);
  }
  else {
    iVar1 = 0;
    for (iVar2 = *(int *)(param_1 + 0x10); iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x10)) {
      if (param_2 == iVar2) {
        FUN_0048d7a0(param_1,param_2);
        if (iVar1 == 0) {
          *(undefined4 *)(param_1 + 0x10) = *(undefined4 *)(iVar2 + 0x10);
        }
        else {
          *(undefined4 *)(iVar1 + 0x10) = *(undefined4 *)(iVar2 + 0x10);
        }
        *(undefined4 *)(iVar2 + 0x10) = 0;
        return 1;
      }
      iVar1 = iVar2;
    }
    FUN_0049a300(1,s_dpl_RemoveNodeFromDCS_failed_to_f_00505e1c);
  }
  return 0;
}



/* @004896cc file=? name=FUN_004896cc */

undefined4 * FUN_004896cc(void)

{
  undefined4 *puVar1;
  
  puVar1 = FUN_00488f34(0x14,2,FUN_00489174);
  FUN_004895f0((int)puVar1);
  return puVar1;
}



/* @004896f0 file=? name=FUN_004896f0 */

void FUN_004896f0(void)

{
  FUN_00488f34(0x70,3,FUN_00489184);
  return;
}



/* @00489708 file=? name=FUN_00489708 */

void FUN_00489708(void)

{
  FUN_00488f34(0x8c,5,FUN_00489508);
  return;
}



/* @00489724 file=? name=FUN_00489724 */

void FUN_00489724(void)

{
  FUN_00488f34(0x38,4,FUN_00489388);
  return;
}



/* @0048973c file=? name=FUN_0048973c */

undefined4 * FUN_0048973c(void)

{
  undefined4 *puVar1;
  
  puVar1 = FUN_00488f34(0x3c,6,FUN_00489214);
  FUN_00488d88((int *)&DAT_00523bf8,(int)puVar1);
  return puVar1;
}



/* @00489768 file=? name=FUN_00489768 */

void FUN_00489768(void)

{
  DAT_005081d8 = 0;
  FUN_00488f34(0x4c,0xc,FUN_00489304);
  return;
}



/* @00489788 file=? name=FUN_00489788 */

void FUN_00489788(void)

{
  FUN_00488f34(0x24,0xd,FUN_004892e0);
  return;
}



/* @004897a0 file=? name=FUN_004897a0 */

void FUN_004897a0(void)

{
  FUN_00488f34(100,0xb,FUN_00489258);
  return;
}



/* @004897b8 file=? name=FUN_004897b8 */

void FUN_004897b8(void)

{
  FUN_00488f34(0x2c,0xe,FUN_0048935c);
  return;
}



/* @004897d0 file=? name=FUN_004897d0 */

void FUN_004897d0(void)

{
  FUN_00488f34(0x7c,7,FUN_004893c4);
  return;
}



/* @004897e8 file=? name=FUN_004897e8 */

void FUN_004897e8(void)

{
  FUN_00488f34(0x50,8,FUN_00489410);
  return;
}



/* @00489800 file=? name=FUN_00489800 */

void FUN_00489800(void)

{
  FUN_00488f34(0x58,9,FUN_0048946c);
  return;
}



/* @00489818 file=? name=FUN_00489818 */

void FUN_00489818(void)

{
  FUN_00488f34(0x30,10,FUN_004894d0);
  return;
}



/* @00489830 file=? name=FUN_00489830 */

void __cdecl FUN_00489830(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,2);
  }
  if (param_1 != (int *)0x0) {
    FUN_00489608((int)param_1);
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_Delete_NULL_ZONE_00505e91);
  return;
}



/* @00489878 file=? name=FUN_00489878 */

void __cdecl FUN_00489878(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,3);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_view_00505eae);
  return;
}



/* @004898b8 file=? name=FUN_004898b8 */

void __cdecl FUN_004898b8(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,5);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_Delete_NULL_DCS_00505ecb);
  return;
}



/* @004898f8 file=? name=FUN_004898f8 */

void __cdecl FUN_004898f8(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,4);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_Delete_NULL_instance_00505ee7);
  return;
}



/* @00489938 file=? name=FUN_00489938 */

void __cdecl FUN_00489938(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,6);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488ebc((int *)&DAT_00523bf8,(int)param_1);
    if (param_1[5] != 0) {
      FUN_00489638(param_1[5],(int)param_1);
    }
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_light_00505f08);
  return;
}



/* @00489998 file=? name=FUN_00489998 */

void __cdecl FUN_00489998(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,0xc);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_texture_00505f26);
  return;
}



/* @004899d8 file=? name=FUN_004899d8 */

void __cdecl FUN_004899d8(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,0xd);
  }
  if (param_1 != (int *)0x0) {
    if ((int *)param_1[4] != (int *)0x0) {
      FUN_00452c88((int *)param_1[4]);
    }
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_texmap_00505f46);
  return;
}



/* @00489a28 file=? name=FUN_00489a28 */

void __cdecl FUN_00489a28(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,0xb);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_material_00505f65);
  return;
}



/* @00489a68 file=? name=FUN_00489a68 */

void __cdecl FUN_00489a68(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,0xe);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_ramp_00505f86);
  return;
}



/* @00489aa8 file=? name=FUN_00489aa8 */

void __cdecl FUN_00489aa8(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,7);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_object_00505fa3);
  return;
}



/* @00489ae8 file=? name=FUN_00489ae8 */

void __cdecl FUN_00489ae8(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,8);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_lod_00505fc2);
  return;
}



/* @00489b28 file=? name=FUN_00489b28 */

void __cdecl FUN_00489b28(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,9);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_geogroup_00505fde);
  return;
}



/* @00489b68 file=? name=FUN_00489b68 */

void __cdecl FUN_00489b68(int *param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594((int)param_1,10);
  }
  if (param_1 != (int *)0x0) {
    FUN_00488fd8(param_1);
    return;
  }
  FUN_0049a300(1,s_Attempt_to_delete_NULL_geometry_00505fff);
  return;
}



/* @00489ba8 file=? name=FUN_00489ba8 */

void __cdecl FUN_00489ba8(int param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  FUN_00488d88((int *)&DAT_00523be8,param_1);
  return;
}



/* @00489bd4 file=? name=FUN_00489bd4 */

void __cdecl FUN_00489bd4(int param_1)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,3);
  }
  FUN_00488d88((int *)&DAT_00523bd8,param_1);
  return;
}



/* @00489c00 file=? name=FUN_00489c00 */

void __cdecl FUN_00489c00(int param_1,int param_2)

{
  int local_8;
  
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,8);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,7);
  }
  *(int *)(param_2 + 0x30) = param_1;
  FUN_00488d88((int *)(param_1 + 0x10),param_2);
  FUN_00488df8(param_1 + 0x10,param_2,&local_8);
  return;
}



/* @00489c5c file=? name=FUN_00489c5c */

void __cdecl FUN_00489c5c(int param_1,int param_2)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,8);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,9);
  }
  *(int *)(param_2 + 0x30) = param_1;
  FUN_00488d88((int *)(param_1 + 0x34),param_2);
  return;
}



/* @00489ca4 file=? name=FUN_00489ca4 */

void __cdecl FUN_00489ca4(int param_1,int param_2)

{
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,9);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,10);
  }
  *(int *)(param_2 + 0x1c) = param_1;
  FUN_00488d88((int *)(param_1 + 0x38),param_2);
  return;
}



/* @00489cec file=? name=FUN_00489cec */

void __cdecl FUN_00489cec(int param_1,int param_2)

{
  int iVar1;
  int iVar2;
  
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,5);
  }
  if (param_1 == 0) {
    FUN_0049a300(1,s_attempt_to_add_dcs_0x_x_to_a_NUL_00506047);
  }
  else if (param_2 == 0) {
    FUN_0049a300(1,s_attempt_to_add_a_NULL_dcs_to_dcs_00506020);
  }
  else {
    if (*(int *)(param_1 + 100) == 0) {
      *(int *)(param_2 + 0x5c) = param_1;
      *(int *)(param_1 + 100) = param_2;
    }
    else {
      if (*(int *)(param_2 + 0x5c) != 0) {
        FUN_0048a068(*(int *)(param_2 + 0x5c),param_2);
      }
      *(int *)(param_2 + 0x5c) = param_1;
      iVar1 = *(int *)(param_1 + 100);
      do {
        iVar2 = iVar1;
        iVar1 = *(int *)(iVar2 + 0x60);
      } while (iVar1 != 0);
      *(int *)(iVar2 + 0x60) = param_2;
    }
    FUN_0048d8d8(param_1,param_2);
  }
  return;
}



/* @00489d90 file=? name=FUN_00489d90 */

undefined4 __cdecl FUN_00489d90(int param_1,int param_2)

{
  undefined4 uVar1;
  
  if (param_1 == 0) {
    FUN_0049a300(1,s_attempt_to_add_node_to_NULL_DCS_005060c2);
    uVar1 = 0;
  }
  else if (param_2 == 0) {
    FUN_0049a300(1,s_attempt_to_add_NULL_node_to_DCS_005060a1);
    uVar1 = 0;
  }
  else if (*(int *)(param_2 + 0x10) == 0) {
    FUN_0048d760(param_1,param_2);
    *(undefined4 *)(param_2 + 0x10) = *(undefined4 *)(param_1 + 0x10);
    *(int *)(param_1 + 0x10) = param_2;
    uVar1 = 1;
  }
  else {
    FUN_0049a300(1,s_error_in_AddNodeToDCS___node_alr_00506071);
    uVar1 = 0;
  }
  return uVar1;
}



/* @00489e04 file=? name=FUN_00489e04 */

void __cdecl FUN_00489e04(int param_1,int param_2)

{
  FUN_0049a300(4,s_dpl_AddInstanceToDCS_0x_x_0x_x_005060e3);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,4);
  }
  FUN_00489d90(param_1,param_2);
  return;
}



/* @00489e58 file=? name=FUN_00489e58 */

void __cdecl FUN_00489e58(int param_1)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveDCSFromScene_0x_x_00506103);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  iVar1 = FUN_00488ebc((int *)&DAT_00523be8,param_1);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_Failed_to_remove_dcs_0x_x__0x_x__00506120);
  }
  return;
}



/* @00489eac file=? name=FUN_00489eac */

void __cdecl FUN_00489eac(int param_1)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveViewFromScene_0x_x_0050614d);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,3);
  }
  iVar1 = FUN_00488ebc((int *)&DAT_00523bd8,param_1);
  if (iVar1 == 0) {
    FUN_0049a300(1,s_Failed_to_remove_view_0x_x__0x_x_0050616b);
  }
  return;
}



/* @00489f00 file=? name=FUN_00489f00 */

void __cdecl FUN_00489f00(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveLodFromObject_0x_x_0x__00506199);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,8);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,7);
  }
  *(undefined4 *)(param_2 + 0x30) = 0;
  iVar1 = FUN_00488ebc((int *)(param_1 + 0x10),param_2);
  if (iVar1 == 0) {
    FUN_004d771c(s_Failed_to_remove_lod_0x_x__0x_x__005061bc);
  }
  return;
}



/* @00489f78 file=? name=FUN_00489f78 */

void __cdecl FUN_00489f78(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveGeogroupFromLod_0x_x_0_005061f6);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,8);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,9);
  }
  *(undefined4 *)(param_2 + 0x30) = 0;
  iVar1 = FUN_00488ebc((int *)(param_1 + 0x34),param_2);
  if (iVar1 == 0) {
    FUN_004d771c(s_Failed_to_remove_ggroup_0x_x__0x_0050621b);
  }
  return;
}



/* @00489ff0 file=? name=FUN_00489ff0 */

void __cdecl FUN_00489ff0(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveGeometryFromGeogroup_0_00506255);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,9);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,10);
  }
  *(undefined4 *)(param_2 + 0x1c) = 0;
  iVar1 = FUN_00488ebc((int *)(param_1 + 0x38),param_2);
  if (iVar1 == 0) {
    FUN_004d771c(s_Failed_to_remove_geometry_0x_x___0050627f);
  }
  return;
}



/* @0048a068 file=? name=FUN_0048a068 */

void __cdecl FUN_0048a068(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_RemoveDCSFromDCS_0x_x_0x_x_005062be);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,5);
  }
  if ((param_1 == 0) || (param_2 == 0)) {
    FUN_0049a300(1,s_NULL_node_in_RemoveDCSFromDCS_0x_00506344);
  }
  else if (param_1 == *(int *)(param_2 + 0x5c)) {
    if (param_2 == *(int *)(param_1 + 100)) {
      *(undefined4 *)(param_1 + 100) = *(undefined4 *)(param_2 + 0x60);
    }
    else {
      for (iVar1 = *(int *)(param_1 + 100); param_2 != *(int *)(iVar1 + 0x60);
          iVar1 = *(int *)(iVar1 + 0x60)) {
        if (*(int *)(iVar1 + 0x60) == 0) {
          FUN_0049a300(1,s_badly_formed_DCS_tree_in_RemoveD_00506311);
          return;
        }
      }
      *(undefined4 *)(iVar1 + 0x60) = *(undefined4 *)(param_2 + 0x60);
    }
    *(undefined4 *)(param_2 + 0x5c) = 0;
    *(undefined4 *)(param_2 + 0x60) = 0;
    FUN_0048d920(param_1,param_2);
  }
  else {
    FUN_0049a300(1,s_badly_formed_DCS_tree_in_RemoveD_005062de);
  }
  return;
}



/* @0048a130 file=? name=FUN_0048a130 */

void __cdecl FUN_0048a130(int param_1,int param_2)

{
  FUN_0049a300(4,s_dpl_RemoveInstanceFromDCS_0x_x_0_00506372);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_2,4);
  }
  FUN_00489638(param_1,param_2);
  return;
}



/* @0048a184 file=? name=FUN_0048a184 */

void FUN_0048a184(void)

{
  FUN_0049a300(4,s_dpl_DrawSceneComplete_00506397);
  FUN_0048e330();
  return;
}



/* @0048a1a0 file=? name=FUN_0048a1a0 */

void FUN_0048a1a0(void)

{
  FUN_0049a300(4,s_dpl_WaitSceneComplete_005063ae);
  FUN_0048e340();
  return;
}



/* @0048a1bc file=? name=FUN_0048a1bc */

void FUN_0048a1bc(void)

{
  FUN_0049a300(4,s_dpl_DrawScene_005063c5);
  FUN_0048a1a0();
  FUN_00488fac();
  FUN_0048e2dc(1);
  return;
}



/* @0048a1e4 file=? name=FUN_0048a1e4 */

int __cdecl FUN_0048a1e4(int param_1)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = DAT_00523bd0;
  FUN_0049a300(4,s_dpl_GetSceneZone_005063d4);
  while( true ) {
    if (param_1 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,2);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_1 = param_1 + -1;
  }
  return 0;
}



/* @0048a23c file=? name=FUN_0048a23c */

int __cdecl FUN_0048a23c(int param_1)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = DAT_00523be0;
  FUN_0049a300(4,s_dpl_GetSceneView_005063e6);
  while( true ) {
    if (param_1 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,3);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_1 = param_1 + -1;
  }
  return 0;
}



/* @0048a294 file=? name=FUN_0048a294 */

int __cdecl FUN_0048a294(int param_1)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = DAT_00523bf0;
  FUN_0049a300(4,s_dpl_GetSceneDCS_005063f8);
  while( true ) {
    if (param_1 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,5);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_1 = param_1 + -1;
  }
  return 0;
}



/* @0048a2ec file=? name=FUN_0048a2ec */

int FUN_0048a2ec(int param_1,int param_2)

{
  int iVar1;
  
  iVar1 = *(int *)(param_1 + 100);
  FUN_0049a300(4,s_dpl_GetDCSChildDCS_00506409);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  while( true ) {
    if (param_2 == 0) {
      if (DAT_00505b64 != 0) {
        FUN_00489594(iVar1,5);
      }
      return iVar1;
    }
    if (iVar1 == 0) break;
    iVar1 = *(int *)(iVar1 + 0x60);
    param_2 = param_2 + -1;
  }
  return 0;
}



/* @0048a350 file=? name=FUN_0048a350 */

undefined4 __cdecl FUN_0048a350(int param_1)

{
  FUN_0049a300(4,s_dpl_GetDCSParentDCS_0050641d);
  if (param_1 == 0) {
    return 0;
  }
  if (DAT_00505b64 != 0) {
    FUN_00489594(*(int *)(param_1 + 0x5c),5);
  }
  return *(undefined4 *)(param_1 + 0x5c);
}



/* @0048a38c file=? name=FUN_0048a38c */

int __cdecl FUN_0048a38c(int param_1,int param_2)

{
  int iVar1;
  
  FUN_0049a300(4,s_dpl_GetDCSInstance_00506432);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,5);
  }
  if (param_1 == 0) {
    FUN_0049a300(1,s_NULL_dcs_in_GetDCSInstance_00506446);
  }
  else {
    for (iVar1 = *(int *)(param_1 + 0x10); iVar1 != 0; iVar1 = *(int *)(iVar1 + 0x10)) {
      if ((*(int *)(iVar1 + 0xc) == 4) && (param_2 = param_2 + -1, param_2 == 0)) {
        return iVar1;
      }
    }
  }
  return 0;
}



/* @0048a3f4 file=? name=FUN_0048a3f4 */

int __cdecl FUN_0048a3f4(int param_1,int param_2)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = *(int **)(param_1 + 0x18);
  FUN_0049a300(4,s_dpl_GetObjectLod_00506462);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,7);
  }
  while( true ) {
    if (param_2 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,8);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_2 = param_2 + -1;
  }
  return 0;
}



/* @0048a464 file=? name=FUN_0048a464 */

int __cdecl FUN_0048a464(int param_1,int param_2)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = *(int **)(param_1 + 0x3c);
  FUN_0049a300(4,s_dpl_GetLodGeogroup_00506474);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,8);
  }
  while( true ) {
    if (param_2 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,9);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_2 = param_2 + -1;
  }
  return 0;
}



/* @0048a4d4 file=? name=FUN_0048a4d4 */

int __cdecl FUN_0048a4d4(int param_1,int param_2)

{
  int *piVar1;
  int iVar2;
  
  piVar1 = *(int **)(param_1 + 0x40);
  FUN_0049a300(4,s_dpl_GetGeogroupGeometry_00506488);
  if (DAT_00505b64 != 0) {
    FUN_00489594(param_1,9);
  }
  while( true ) {
    if (param_2 == 0) {
      if (piVar1 == (int *)0x0) {
        iVar2 = 0;
      }
      else {
        if (DAT_00505b64 != 0) {
          FUN_00489594(*piVar1,10);
        }
        iVar2 = *piVar1;
      }
      return iVar2;
    }
    if (piVar1 == (int *)0x0) break;
    piVar1 = (int *)piVar1[2];
    param_2 = param_2 + -1;
  }
  return 0;
}



/* @0048a544 file=? name=FUN_0048a544 */

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

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

{
  if (param_1 < 0x10) {
    FUN_0049a300(4,s_dpl_SetRenderProperty_005064a1);
    (&DAT_00523d08)[param_1 * 2] = param_2;
    (&DAT_00523d0c)[param_1 * 2] = param_3;
    if (param_1 == 8) {
      _DAT_00507930 = *param_3;
    }
    FUN_0048e688(param_1,param_2);
  }
  return;
}



